@wix/bookings_availability-calendar
Advanced tools
Comparing version 1.0.34 to 1.0.35
@@ -18,1 +18,2 @@ "use strict"; | ||
__exportStar(require("./src/bookings-availability-v1-slot-availability-availability-calendar.context"), exports); | ||
//# sourceMappingURL=context.js.map |
@@ -18,1 +18,2 @@ "use strict"; | ||
__exportStar(require("./src/bookings-availability-v1-slot-availability-availability-calendar.context"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -18,1 +18,2 @@ "use strict"; | ||
__exportStar(require("./src/bookings-availability-v1-slot-availability-availability-calendar.universal"), exports); | ||
//# sourceMappingURL=index.typings.js.map |
@@ -18,1 +18,2 @@ "use strict"; | ||
__exportStar(require("./src/bookings-availability-v1-slot-availability-availability-calendar.meta"), exports); | ||
//# sourceMappingURL=meta.js.map |
import { queryAvailability as publicQueryAvailability, getScheduleAvailability as publicGetScheduleAvailability, calculateMultiSlotAvailability as publicCalculateMultiSlotAvailability } from './bookings-availability-v1-slot-availability-availability-calendar.public'; | ||
import { BuildRESTFunction } from '@wix/sdk-types'; | ||
export declare const queryAvailability: BuildRESTFunction<typeof publicQueryAvailability> & typeof publicQueryAvailability; | ||
export declare const getScheduleAvailability: BuildRESTFunction<typeof publicGetScheduleAvailability> & typeof publicGetScheduleAvailability; | ||
export declare const calculateMultiSlotAvailability: BuildRESTFunction<typeof publicCalculateMultiSlotAvailability> & typeof publicCalculateMultiSlotAvailability; | ||
import { BuildRESTFunction, MaybeContext } from '@wix/sdk-types'; | ||
export declare const queryAvailability: MaybeContext<BuildRESTFunction<typeof publicQueryAvailability> & typeof publicQueryAvailability>; | ||
export declare const getScheduleAvailability: MaybeContext<BuildRESTFunction<typeof publicGetScheduleAvailability> & typeof publicGetScheduleAvailability>; | ||
export declare const calculateMultiSlotAvailability: MaybeContext<BuildRESTFunction<typeof publicCalculateMultiSlotAvailability> & typeof publicCalculateMultiSlotAvailability>; | ||
export { LocationType, SortOrder, LocationLocationType, } from './bookings-availability-v1-slot-availability-availability-calendar.universal'; | ||
export { SlotAvailability, Slot, SlotResource, Location, AvailabilityWaitingList, BookingPolicyViolations, NestedTimeSlot, QueryAvailabilityRequest, QueryV2, QueryV2PagingMethodOneOf, Sorting, CursorPaging, CustomerChoices, QueryAvailabilityResponse, PagingMetadataV2, Cursors, GetSlotAvailabilityRequest, GetSlotAvailabilityResponse, BookingPolicySettings, GetScheduleAvailabilityRequest, GetScheduleAvailabilityResponse, ScheduleAvailability, CalculateMultiSlotAvailabilityRequest, RuleBasedConstraints, ResourcesFilter, CalculateMultiSlotAvailabilityResponse, CursorPagingMetadata, GetAvailabilityTimeSlotRequest, TimeSlotLocation, GetAvailabilityTimeSlotResponse, TimeSlot, EventInfo, WaitingList, Service_availabilityBookingPolicyViolations, AvailableResources, Resource, Service_availabilityNestedTimeSlot, QueryAvailabilityResponseNonNullableFields, CalculateMultiSlotAvailabilityResponseNonNullableFields, QueryAvailabilityOptions, CalculateMultiSlotAvailabilityOptions, } from './bookings-availability-v1-slot-availability-availability-calendar.universal'; |
@@ -13,1 +13,2 @@ "use strict"; | ||
Object.defineProperty(exports, "LocationLocationType", { enumerable: true, get: function () { return bookings_availability_v1_slot_availability_availability_calendar_universal_1.LocationLocationType; } }); | ||
//# sourceMappingURL=bookings-availability-v1-slot-availability-availability-calendar.context.js.map |
@@ -246,1 +246,2 @@ "use strict"; | ||
exports.calculateMultiSlotAvailability = calculateMultiSlotAvailability; | ||
//# sourceMappingURL=bookings-availability-v1-slot-availability-availability-calendar.http.js.map |
@@ -85,1 +85,2 @@ "use strict"; | ||
exports.calculateMultiSlotAvailability = calculateMultiSlotAvailability; | ||
//# sourceMappingURL=bookings-availability-v1-slot-availability-availability-calendar.meta.js.map |
@@ -28,1 +28,2 @@ "use strict"; | ||
Object.defineProperty(exports, "SortOrder", { enumerable: true, get: function () { return bookings_availability_v1_slot_availability_availability_calendar_universal_2.SortOrder; } }); | ||
//# sourceMappingURL=bookings-availability-v1-slot-availability-availability-calendar.public.js.map |
@@ -26,1 +26,2 @@ "use strict"; | ||
})(LocationLocationType || (exports.LocationLocationType = LocationLocationType = {})); | ||
//# sourceMappingURL=bookings-availability-v1-slot-availability-availability-calendar.types.js.map |
@@ -246,1 +246,2 @@ "use strict"; | ||
exports.calculateMultiSlotAvailability = calculateMultiSlotAvailability; | ||
//# sourceMappingURL=bookings-availability-v1-slot-availability-availability-calendar.universal.js.map |
import { queryAvailability as publicQueryAvailability, getScheduleAvailability as publicGetScheduleAvailability, calculateMultiSlotAvailability as publicCalculateMultiSlotAvailability } from './bookings-availability-v1-slot-availability-availability-calendar.public'; | ||
import { BuildRESTFunction } from '@wix/sdk-types'; | ||
export declare const queryAvailability: BuildRESTFunction<typeof publicQueryAvailability> & typeof publicQueryAvailability; | ||
export declare const getScheduleAvailability: BuildRESTFunction<typeof publicGetScheduleAvailability> & typeof publicGetScheduleAvailability; | ||
export declare const calculateMultiSlotAvailability: BuildRESTFunction<typeof publicCalculateMultiSlotAvailability> & typeof publicCalculateMultiSlotAvailability; | ||
import { BuildRESTFunction, MaybeContext } from '@wix/sdk-types'; | ||
export declare const queryAvailability: MaybeContext<BuildRESTFunction<typeof publicQueryAvailability> & typeof publicQueryAvailability>; | ||
export declare const getScheduleAvailability: MaybeContext<BuildRESTFunction<typeof publicGetScheduleAvailability> & typeof publicGetScheduleAvailability>; | ||
export declare const calculateMultiSlotAvailability: MaybeContext<BuildRESTFunction<typeof publicCalculateMultiSlotAvailability> & typeof publicCalculateMultiSlotAvailability>; | ||
export { LocationType, SortOrder, LocationLocationType, } from './bookings-availability-v1-slot-availability-availability-calendar.universal'; | ||
export { SlotAvailability, Slot, SlotResource, Location, AvailabilityWaitingList, BookingPolicyViolations, NestedTimeSlot, QueryAvailabilityRequest, QueryV2, QueryV2PagingMethodOneOf, Sorting, CursorPaging, CustomerChoices, QueryAvailabilityResponse, PagingMetadataV2, Cursors, GetSlotAvailabilityRequest, GetSlotAvailabilityResponse, BookingPolicySettings, GetScheduleAvailabilityRequest, GetScheduleAvailabilityResponse, ScheduleAvailability, CalculateMultiSlotAvailabilityRequest, RuleBasedConstraints, ResourcesFilter, CalculateMultiSlotAvailabilityResponse, CursorPagingMetadata, GetAvailabilityTimeSlotRequest, TimeSlotLocation, GetAvailabilityTimeSlotResponse, TimeSlot, EventInfo, WaitingList, Service_availabilityBookingPolicyViolations, AvailableResources, Resource, Service_availabilityNestedTimeSlot, QueryAvailabilityResponseNonNullableFields, CalculateMultiSlotAvailabilityResponseNonNullableFields, QueryAvailabilityOptions, CalculateMultiSlotAvailabilityOptions, } from './bookings-availability-v1-slot-availability-availability-calendar.universal'; |
{ | ||
"name": "@wix/bookings_availability-calendar", | ||
"version": "1.0.34", | ||
"version": "1.0.35", | ||
"publishConfig": { | ||
@@ -24,3 +24,3 @@ "registry": "https://registry.npmjs.org/", | ||
"@wix/sdk-runtime": "^0.3.14", | ||
"@wix/sdk-types": "^1.9.2" | ||
"@wix/sdk-types": "^1.12.3" | ||
}, | ||
@@ -49,3 +49,3 @@ "devDependencies": { | ||
}, | ||
"falconPackageHash": "4b01ca8ca554f2782b20d919a3c4a9d7930eb5af211f4319881d1b37" | ||
"falconPackageHash": "d4db47f08b3a5e03227092b35d60d8efe88e1fd4c6083a9e5d8d23c2" | ||
} |
@@ -0,1 +1,39 @@ | ||
type HostModule<T, H extends Host> = { | ||
__type: 'host'; | ||
create(host: H): T; | ||
}; | ||
type HostModuleAPI<T extends HostModule<any, any>> = T extends HostModule<infer U, any> ? U : never; | ||
type Host<Environment = unknown> = { | ||
channel: { | ||
observeState(callback: (props: unknown, environment: Environment) => unknown): { | ||
disconnect: () => void; | ||
} | Promise<{ | ||
disconnect: () => void; | ||
}>; | ||
}; | ||
environment?: Environment; | ||
/** | ||
* Optional bast url to use for API requests, for example `www.wixapis.com` | ||
*/ | ||
apiBaseUrl?: string; | ||
/** | ||
* Possible data to be provided by every host, for cross cutting concerns | ||
* like internationalization, billing, etc. | ||
*/ | ||
essentials?: { | ||
/** | ||
* The language of the currently viewed session | ||
*/ | ||
language?: string; | ||
/** | ||
* The locale of the currently viewed session | ||
*/ | ||
locale?: string; | ||
/** | ||
* Any headers that should be passed through to the API requests | ||
*/ | ||
passThroughHeaders?: Record<string, string>; | ||
}; | ||
}; | ||
type RESTFunctionDescriptor<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient) => T; | ||
@@ -6,2 +44,3 @@ interface HttpClient { | ||
wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>; | ||
getActiveToken?: () => string | undefined; | ||
} | ||
@@ -28,3 +67,62 @@ type RequestOptionsFactory<TResponse = any, TData = any> = (context: any) => RequestOptions<TResponse, TData>; | ||
type BuildRESTFunction<T extends RESTFunctionDescriptor> = T extends RESTFunctionDescriptor<infer U> ? U : never; | ||
type EventDefinition<Payload = unknown, Type extends string = string> = { | ||
__type: 'event-definition'; | ||
type: Type; | ||
isDomainEvent?: boolean; | ||
transformations?: (envelope: unknown) => Payload; | ||
__payload: Payload; | ||
}; | ||
declare function EventDefinition<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition<Payload, Type>; | ||
type EventHandler<T extends EventDefinition> = (payload: T['__payload']) => void | Promise<void>; | ||
type BuildEventDefinition<T extends EventDefinition<any, string>> = (handler: EventHandler<T>) => void; | ||
type ServicePluginMethodInput = { | ||
request: any; | ||
metadata: any; | ||
}; | ||
type ServicePluginContract = Record<string, (payload: ServicePluginMethodInput) => unknown | Promise<unknown>>; | ||
type ServicePluginMethodMetadata = { | ||
name: string; | ||
primaryHttpMappingPath: string; | ||
transformations: { | ||
fromREST: (...args: unknown[]) => ServicePluginMethodInput; | ||
toREST: (...args: unknown[]) => unknown; | ||
}; | ||
}; | ||
type ServicePluginDefinition<Contract extends ServicePluginContract> = { | ||
__type: 'service-plugin-definition'; | ||
componentType: string; | ||
methods: ServicePluginMethodMetadata[]; | ||
__contract: Contract; | ||
}; | ||
declare function ServicePluginDefinition<Contract extends ServicePluginContract>(componentType: string, methods: ServicePluginMethodMetadata[]): ServicePluginDefinition<Contract>; | ||
type BuildServicePluginDefinition<T extends ServicePluginDefinition<any>> = (implementation: T['__contract']) => void; | ||
declare const SERVICE_PLUGIN_ERROR_TYPE = "wix_spi_error"; | ||
type RequestContext = { | ||
isSSR: boolean; | ||
host: string; | ||
protocol?: string; | ||
}; | ||
type ResponseTransformer = (data: any, headers?: any) => any; | ||
/** | ||
* Ambassador request options types are copied mostly from AxiosRequestConfig. | ||
* They are copied and not imported to reduce the amount of dependencies (to reduce install time). | ||
* https://github.com/axios/axios/blob/3f53eb6960f05a1f88409c4b731a40de595cb825/index.d.ts#L307-L315 | ||
*/ | ||
type Method = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK'; | ||
type AmbassadorRequestOptions<T = any> = { | ||
_?: T; | ||
url?: string; | ||
method?: Method; | ||
params?: any; | ||
data?: any; | ||
transformResponse?: ResponseTransformer | ResponseTransformer[]; | ||
}; | ||
type AmbassadorFactory<Request, Response> = (payload: Request) => ((context: RequestContext) => AmbassadorRequestOptions<Response>) & { | ||
__isAmbassador: boolean; | ||
}; | ||
type AmbassadorFunctionDescriptor<Request = any, Response = any> = AmbassadorFactory<Request, Response>; | ||
type BuildAmbassadorFunction<T extends AmbassadorFunctionDescriptor> = T extends AmbassadorFunctionDescriptor<infer Request, infer Response> ? (req: Request) => Promise<Response> : never; | ||
declare global { | ||
@@ -37,2 +135,280 @@ // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged. | ||
declare const emptyObjectSymbol: unique symbol; | ||
/** | ||
Represents a strictly empty plain object, the `{}` value. | ||
When you annotate something as the type `{}`, it can be anything except `null` and `undefined`. This means that you cannot use `{}` to represent an empty plain object ([read more](https://stackoverflow.com/questions/47339869/typescript-empty-object-and-any-difference/52193484#52193484)). | ||
@example | ||
``` | ||
import type {EmptyObject} from 'type-fest'; | ||
// The following illustrates the problem with `{}`. | ||
const foo1: {} = {}; // Pass | ||
const foo2: {} = []; // Pass | ||
const foo3: {} = 42; // Pass | ||
const foo4: {} = {a: 1}; // Pass | ||
// With `EmptyObject` only the first case is valid. | ||
const bar1: EmptyObject = {}; // Pass | ||
const bar2: EmptyObject = 42; // Fail | ||
const bar3: EmptyObject = []; // Fail | ||
const bar4: EmptyObject = {a: 1}; // Fail | ||
``` | ||
Unfortunately, `Record<string, never>`, `Record<keyof any, never>` and `Record<never, never>` do not work. See {@link https://github.com/sindresorhus/type-fest/issues/395 #395}. | ||
@category Object | ||
*/ | ||
type EmptyObject = {[emptyObjectSymbol]?: never}; | ||
/** | ||
Returns a boolean for whether the two given types are equal. | ||
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650 | ||
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796 | ||
Use-cases: | ||
- If you want to make a conditional branch based on the result of a comparison of two types. | ||
@example | ||
``` | ||
import type {IsEqual} from 'type-fest'; | ||
// This type returns a boolean for whether the given array includes the given item. | ||
// `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal. | ||
type Includes<Value extends readonly any[], Item> = | ||
Value extends readonly [Value[0], ...infer rest] | ||
? IsEqual<Value[0], Item> extends true | ||
? true | ||
: Includes<rest, Item> | ||
: false; | ||
``` | ||
@category Type Guard | ||
@category Utilities | ||
*/ | ||
type IsEqual<A, B> = | ||
(<G>() => G extends A ? 1 : 2) extends | ||
(<G>() => G extends B ? 1 : 2) | ||
? true | ||
: false; | ||
/** | ||
Filter out keys from an object. | ||
Returns `never` if `Exclude` is strictly equal to `Key`. | ||
Returns `never` if `Key` extends `Exclude`. | ||
Returns `Key` otherwise. | ||
@example | ||
``` | ||
type Filtered = Filter<'foo', 'foo'>; | ||
//=> never | ||
``` | ||
@example | ||
``` | ||
type Filtered = Filter<'bar', string>; | ||
//=> never | ||
``` | ||
@example | ||
``` | ||
type Filtered = Filter<'bar', 'foo'>; | ||
//=> 'bar' | ||
``` | ||
@see {Except} | ||
*/ | ||
type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType); | ||
type ExceptOptions = { | ||
/** | ||
Disallow assigning non-specified properties. | ||
Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`. | ||
@default false | ||
*/ | ||
requireExactProps?: boolean; | ||
}; | ||
/** | ||
Create a type from an object type without certain keys. | ||
We recommend setting the `requireExactProps` option to `true`. | ||
This type is a stricter version of [`Omit`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-5.html#the-omit-helper-type). The `Omit` type does not restrict the omitted keys to be keys present on the given type, while `Except` does. The benefits of a stricter type are avoiding typos and allowing the compiler to pick up on rename refactors automatically. | ||
This type was proposed to the TypeScript team, which declined it, saying they prefer that libraries implement stricter versions of the built-in types ([microsoft/TypeScript#30825](https://github.com/microsoft/TypeScript/issues/30825#issuecomment-523668235)). | ||
@example | ||
``` | ||
import type {Except} from 'type-fest'; | ||
type Foo = { | ||
a: number; | ||
b: string; | ||
}; | ||
type FooWithoutA = Except<Foo, 'a'>; | ||
//=> {b: string} | ||
const fooWithoutA: FooWithoutA = {a: 1, b: '2'}; | ||
//=> errors: 'a' does not exist in type '{ b: string; }' | ||
type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>; | ||
//=> {a: number} & Partial<Record<"b", never>> | ||
const fooWithoutB: FooWithoutB = {a: 1, b: '2'}; | ||
//=> errors at 'b': Type 'string' is not assignable to type 'undefined'. | ||
``` | ||
@category Object | ||
*/ | ||
type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {requireExactProps: false}> = { | ||
[KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType]; | ||
} & (Options['requireExactProps'] extends true | ||
? Partial<Record<KeysType, never>> | ||
: {}); | ||
/** | ||
Extract the keys from a type where the value type of the key extends the given `Condition`. | ||
Internally this is used for the `ConditionalPick` and `ConditionalExcept` types. | ||
@example | ||
``` | ||
import type {ConditionalKeys} from 'type-fest'; | ||
interface Example { | ||
a: string; | ||
b: string | number; | ||
c?: string; | ||
d: {}; | ||
} | ||
type StringKeysOnly = ConditionalKeys<Example, string>; | ||
//=> 'a' | ||
``` | ||
To support partial types, make sure your `Condition` is a union of undefined (for example, `string | undefined`) as demonstrated below. | ||
@example | ||
``` | ||
import type {ConditionalKeys} from 'type-fest'; | ||
type StringKeysAndUndefined = ConditionalKeys<Example, string | undefined>; | ||
//=> 'a' | 'c' | ||
``` | ||
@category Object | ||
*/ | ||
type ConditionalKeys<Base, Condition> = NonNullable< | ||
// Wrap in `NonNullable` to strip away the `undefined` type from the produced union. | ||
{ | ||
// Map through all the keys of the given base type. | ||
[Key in keyof Base]: | ||
// Pick only keys with types extending the given `Condition` type. | ||
Base[Key] extends Condition | ||
// Retain this key since the condition passes. | ||
? Key | ||
// Discard this key since the condition fails. | ||
: never; | ||
// Convert the produced object into a union type of the keys which passed the conditional test. | ||
}[keyof Base] | ||
>; | ||
/** | ||
Exclude keys from a shape that matches the given `Condition`. | ||
This is useful when you want to create a new type with a specific set of keys from a shape. For example, you might want to exclude all the primitive properties from a class and form a new shape containing everything but the primitive properties. | ||
@example | ||
``` | ||
import type {Primitive, ConditionalExcept} from 'type-fest'; | ||
class Awesome { | ||
name: string; | ||
successes: number; | ||
failures: bigint; | ||
run() {} | ||
} | ||
type ExceptPrimitivesFromAwesome = ConditionalExcept<Awesome, Primitive>; | ||
//=> {run: () => void} | ||
``` | ||
@example | ||
``` | ||
import type {ConditionalExcept} from 'type-fest'; | ||
interface Example { | ||
a: string; | ||
b: string | number; | ||
c: () => void; | ||
d: {}; | ||
} | ||
type NonStringKeysOnly = ConditionalExcept<Example, string>; | ||
//=> {b: string | number; c: () => void; d: {}} | ||
``` | ||
@category Object | ||
*/ | ||
type ConditionalExcept<Base, Condition> = Except< | ||
Base, | ||
ConditionalKeys<Base, Condition> | ||
>; | ||
/** | ||
* Descriptors are objects that describe the API of a module, and the module | ||
* can either be a REST module or a host module. | ||
* This type is recursive, so it can describe nested modules. | ||
*/ | ||
type Descriptors = RESTFunctionDescriptor | AmbassadorFunctionDescriptor | HostModule<any, any> | EventDefinition<any> | ServicePluginDefinition<any> | { | ||
[key: string]: Descriptors | PublicMetadata | any; | ||
}; | ||
/** | ||
* This type takes in a descriptors object of a certain Host (including an `unknown` host) | ||
* and returns an object with the same structure, but with all descriptors replaced with their API. | ||
* Any non-descriptor properties are removed from the returned object, including descriptors that | ||
* do not match the given host (as they will not work with the given host). | ||
*/ | ||
type BuildDescriptors<T extends Descriptors, H extends Host<any> | undefined, Depth extends number = 5> = { | ||
done: T; | ||
recurse: T extends { | ||
__type: typeof SERVICE_PLUGIN_ERROR_TYPE; | ||
} ? never : T extends AmbassadorFunctionDescriptor ? BuildAmbassadorFunction<T> : T extends RESTFunctionDescriptor ? BuildRESTFunction<T> : T extends EventDefinition<any> ? BuildEventDefinition<T> : T extends ServicePluginDefinition<any> ? BuildServicePluginDefinition<T> : T extends HostModule<any, any> ? HostModuleAPI<T> : ConditionalExcept<{ | ||
[Key in keyof T]: T[Key] extends Descriptors ? BuildDescriptors<T[Key], H, [ | ||
-1, | ||
0, | ||
1, | ||
2, | ||
3, | ||
4, | ||
5 | ||
][Depth]> : never; | ||
}, EmptyObject>; | ||
}[Depth extends -1 ? 'done' : 'recurse']; | ||
type PublicMetadata = { | ||
PACKAGE_NAME?: string; | ||
}; | ||
declare global { | ||
interface ContextualClient { | ||
} | ||
} | ||
/** | ||
* A type used to create concerete types from SDK descriptors in | ||
* case a contextual client is available. | ||
*/ | ||
type MaybeContext<T extends Descriptors> = globalThis.ContextualClient extends { | ||
host: Host; | ||
} ? BuildDescriptors<T, globalThis.ContextualClient['host']> : T; | ||
interface SlotAvailability { | ||
@@ -722,6 +1098,6 @@ /** | ||
declare const queryAvailability: BuildRESTFunction<typeof queryAvailability$1> & typeof queryAvailability$1; | ||
declare const getScheduleAvailability: BuildRESTFunction<typeof getScheduleAvailability$1> & typeof getScheduleAvailability$1; | ||
declare const calculateMultiSlotAvailability: BuildRESTFunction<typeof calculateMultiSlotAvailability$1> & typeof calculateMultiSlotAvailability$1; | ||
declare const queryAvailability: MaybeContext<BuildRESTFunction<typeof queryAvailability$1> & typeof queryAvailability$1>; | ||
declare const getScheduleAvailability: MaybeContext<BuildRESTFunction<typeof getScheduleAvailability$1> & typeof getScheduleAvailability$1>; | ||
declare const calculateMultiSlotAvailability: MaybeContext<BuildRESTFunction<typeof calculateMultiSlotAvailability$1> & typeof calculateMultiSlotAvailability$1>; | ||
export { type AvailabilityWaitingList, type AvailableResources, type BookingPolicySettings, type BookingPolicyViolations, type CalculateMultiSlotAvailabilityOptions, type CalculateMultiSlotAvailabilityRequest, type CalculateMultiSlotAvailabilityResponse, type CalculateMultiSlotAvailabilityResponseNonNullableFields, type CursorPaging, type CursorPagingMetadata, type Cursors, type CustomerChoices, type EventInfo, type GetAvailabilityTimeSlotRequest, type GetAvailabilityTimeSlotResponse, type GetScheduleAvailabilityRequest, type GetScheduleAvailabilityResponse, type GetSlotAvailabilityRequest, type GetSlotAvailabilityResponse, type Location, LocationLocationType, LocationType, type NestedTimeSlot, type PagingMetadataV2, type QueryAvailabilityOptions, type QueryAvailabilityRequest, type QueryAvailabilityResponse, type QueryAvailabilityResponseNonNullableFields, type QueryV2, type QueryV2PagingMethodOneOf, type Resource, type ResourcesFilter, type RuleBasedConstraints, type ScheduleAvailability, type Service_availabilityBookingPolicyViolations, type Service_availabilityNestedTimeSlot, type Slot, type SlotAvailability, type SlotResource, SortOrder, type Sorting, type TimeSlot, type TimeSlotLocation, type WaitingList, calculateMultiSlotAvailability, getScheduleAvailability, queryAvailability }; |
@@ -0,1 +1,39 @@ | ||
type HostModule<T, H extends Host> = { | ||
__type: 'host'; | ||
create(host: H): T; | ||
}; | ||
type HostModuleAPI<T extends HostModule<any, any>> = T extends HostModule<infer U, any> ? U : never; | ||
type Host<Environment = unknown> = { | ||
channel: { | ||
observeState(callback: (props: unknown, environment: Environment) => unknown): { | ||
disconnect: () => void; | ||
} | Promise<{ | ||
disconnect: () => void; | ||
}>; | ||
}; | ||
environment?: Environment; | ||
/** | ||
* Optional bast url to use for API requests, for example `www.wixapis.com` | ||
*/ | ||
apiBaseUrl?: string; | ||
/** | ||
* Possible data to be provided by every host, for cross cutting concerns | ||
* like internationalization, billing, etc. | ||
*/ | ||
essentials?: { | ||
/** | ||
* The language of the currently viewed session | ||
*/ | ||
language?: string; | ||
/** | ||
* The locale of the currently viewed session | ||
*/ | ||
locale?: string; | ||
/** | ||
* Any headers that should be passed through to the API requests | ||
*/ | ||
passThroughHeaders?: Record<string, string>; | ||
}; | ||
}; | ||
type RESTFunctionDescriptor<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient) => T; | ||
@@ -6,2 +44,3 @@ interface HttpClient { | ||
wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>; | ||
getActiveToken?: () => string | undefined; | ||
} | ||
@@ -28,3 +67,62 @@ type RequestOptionsFactory<TResponse = any, TData = any> = (context: any) => RequestOptions<TResponse, TData>; | ||
type BuildRESTFunction<T extends RESTFunctionDescriptor> = T extends RESTFunctionDescriptor<infer U> ? U : never; | ||
type EventDefinition<Payload = unknown, Type extends string = string> = { | ||
__type: 'event-definition'; | ||
type: Type; | ||
isDomainEvent?: boolean; | ||
transformations?: (envelope: unknown) => Payload; | ||
__payload: Payload; | ||
}; | ||
declare function EventDefinition<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition<Payload, Type>; | ||
type EventHandler<T extends EventDefinition> = (payload: T['__payload']) => void | Promise<void>; | ||
type BuildEventDefinition<T extends EventDefinition<any, string>> = (handler: EventHandler<T>) => void; | ||
type ServicePluginMethodInput = { | ||
request: any; | ||
metadata: any; | ||
}; | ||
type ServicePluginContract = Record<string, (payload: ServicePluginMethodInput) => unknown | Promise<unknown>>; | ||
type ServicePluginMethodMetadata = { | ||
name: string; | ||
primaryHttpMappingPath: string; | ||
transformations: { | ||
fromREST: (...args: unknown[]) => ServicePluginMethodInput; | ||
toREST: (...args: unknown[]) => unknown; | ||
}; | ||
}; | ||
type ServicePluginDefinition<Contract extends ServicePluginContract> = { | ||
__type: 'service-plugin-definition'; | ||
componentType: string; | ||
methods: ServicePluginMethodMetadata[]; | ||
__contract: Contract; | ||
}; | ||
declare function ServicePluginDefinition<Contract extends ServicePluginContract>(componentType: string, methods: ServicePluginMethodMetadata[]): ServicePluginDefinition<Contract>; | ||
type BuildServicePluginDefinition<T extends ServicePluginDefinition<any>> = (implementation: T['__contract']) => void; | ||
declare const SERVICE_PLUGIN_ERROR_TYPE = "wix_spi_error"; | ||
type RequestContext = { | ||
isSSR: boolean; | ||
host: string; | ||
protocol?: string; | ||
}; | ||
type ResponseTransformer = (data: any, headers?: any) => any; | ||
/** | ||
* Ambassador request options types are copied mostly from AxiosRequestConfig. | ||
* They are copied and not imported to reduce the amount of dependencies (to reduce install time). | ||
* https://github.com/axios/axios/blob/3f53eb6960f05a1f88409c4b731a40de595cb825/index.d.ts#L307-L315 | ||
*/ | ||
type Method = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK'; | ||
type AmbassadorRequestOptions<T = any> = { | ||
_?: T; | ||
url?: string; | ||
method?: Method; | ||
params?: any; | ||
data?: any; | ||
transformResponse?: ResponseTransformer | ResponseTransformer[]; | ||
}; | ||
type AmbassadorFactory<Request, Response> = (payload: Request) => ((context: RequestContext) => AmbassadorRequestOptions<Response>) & { | ||
__isAmbassador: boolean; | ||
}; | ||
type AmbassadorFunctionDescriptor<Request = any, Response = any> = AmbassadorFactory<Request, Response>; | ||
type BuildAmbassadorFunction<T extends AmbassadorFunctionDescriptor> = T extends AmbassadorFunctionDescriptor<infer Request, infer Response> ? (req: Request) => Promise<Response> : never; | ||
declare global { | ||
@@ -37,2 +135,280 @@ // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged. | ||
declare const emptyObjectSymbol: unique symbol; | ||
/** | ||
Represents a strictly empty plain object, the `{}` value. | ||
When you annotate something as the type `{}`, it can be anything except `null` and `undefined`. This means that you cannot use `{}` to represent an empty plain object ([read more](https://stackoverflow.com/questions/47339869/typescript-empty-object-and-any-difference/52193484#52193484)). | ||
@example | ||
``` | ||
import type {EmptyObject} from 'type-fest'; | ||
// The following illustrates the problem with `{}`. | ||
const foo1: {} = {}; // Pass | ||
const foo2: {} = []; // Pass | ||
const foo3: {} = 42; // Pass | ||
const foo4: {} = {a: 1}; // Pass | ||
// With `EmptyObject` only the first case is valid. | ||
const bar1: EmptyObject = {}; // Pass | ||
const bar2: EmptyObject = 42; // Fail | ||
const bar3: EmptyObject = []; // Fail | ||
const bar4: EmptyObject = {a: 1}; // Fail | ||
``` | ||
Unfortunately, `Record<string, never>`, `Record<keyof any, never>` and `Record<never, never>` do not work. See {@link https://github.com/sindresorhus/type-fest/issues/395 #395}. | ||
@category Object | ||
*/ | ||
type EmptyObject = {[emptyObjectSymbol]?: never}; | ||
/** | ||
Returns a boolean for whether the two given types are equal. | ||
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650 | ||
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796 | ||
Use-cases: | ||
- If you want to make a conditional branch based on the result of a comparison of two types. | ||
@example | ||
``` | ||
import type {IsEqual} from 'type-fest'; | ||
// This type returns a boolean for whether the given array includes the given item. | ||
// `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal. | ||
type Includes<Value extends readonly any[], Item> = | ||
Value extends readonly [Value[0], ...infer rest] | ||
? IsEqual<Value[0], Item> extends true | ||
? true | ||
: Includes<rest, Item> | ||
: false; | ||
``` | ||
@category Type Guard | ||
@category Utilities | ||
*/ | ||
type IsEqual<A, B> = | ||
(<G>() => G extends A ? 1 : 2) extends | ||
(<G>() => G extends B ? 1 : 2) | ||
? true | ||
: false; | ||
/** | ||
Filter out keys from an object. | ||
Returns `never` if `Exclude` is strictly equal to `Key`. | ||
Returns `never` if `Key` extends `Exclude`. | ||
Returns `Key` otherwise. | ||
@example | ||
``` | ||
type Filtered = Filter<'foo', 'foo'>; | ||
//=> never | ||
``` | ||
@example | ||
``` | ||
type Filtered = Filter<'bar', string>; | ||
//=> never | ||
``` | ||
@example | ||
``` | ||
type Filtered = Filter<'bar', 'foo'>; | ||
//=> 'bar' | ||
``` | ||
@see {Except} | ||
*/ | ||
type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType); | ||
type ExceptOptions = { | ||
/** | ||
Disallow assigning non-specified properties. | ||
Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`. | ||
@default false | ||
*/ | ||
requireExactProps?: boolean; | ||
}; | ||
/** | ||
Create a type from an object type without certain keys. | ||
We recommend setting the `requireExactProps` option to `true`. | ||
This type is a stricter version of [`Omit`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-5.html#the-omit-helper-type). The `Omit` type does not restrict the omitted keys to be keys present on the given type, while `Except` does. The benefits of a stricter type are avoiding typos and allowing the compiler to pick up on rename refactors automatically. | ||
This type was proposed to the TypeScript team, which declined it, saying they prefer that libraries implement stricter versions of the built-in types ([microsoft/TypeScript#30825](https://github.com/microsoft/TypeScript/issues/30825#issuecomment-523668235)). | ||
@example | ||
``` | ||
import type {Except} from 'type-fest'; | ||
type Foo = { | ||
a: number; | ||
b: string; | ||
}; | ||
type FooWithoutA = Except<Foo, 'a'>; | ||
//=> {b: string} | ||
const fooWithoutA: FooWithoutA = {a: 1, b: '2'}; | ||
//=> errors: 'a' does not exist in type '{ b: string; }' | ||
type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>; | ||
//=> {a: number} & Partial<Record<"b", never>> | ||
const fooWithoutB: FooWithoutB = {a: 1, b: '2'}; | ||
//=> errors at 'b': Type 'string' is not assignable to type 'undefined'. | ||
``` | ||
@category Object | ||
*/ | ||
type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {requireExactProps: false}> = { | ||
[KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType]; | ||
} & (Options['requireExactProps'] extends true | ||
? Partial<Record<KeysType, never>> | ||
: {}); | ||
/** | ||
Extract the keys from a type where the value type of the key extends the given `Condition`. | ||
Internally this is used for the `ConditionalPick` and `ConditionalExcept` types. | ||
@example | ||
``` | ||
import type {ConditionalKeys} from 'type-fest'; | ||
interface Example { | ||
a: string; | ||
b: string | number; | ||
c?: string; | ||
d: {}; | ||
} | ||
type StringKeysOnly = ConditionalKeys<Example, string>; | ||
//=> 'a' | ||
``` | ||
To support partial types, make sure your `Condition` is a union of undefined (for example, `string | undefined`) as demonstrated below. | ||
@example | ||
``` | ||
import type {ConditionalKeys} from 'type-fest'; | ||
type StringKeysAndUndefined = ConditionalKeys<Example, string | undefined>; | ||
//=> 'a' | 'c' | ||
``` | ||
@category Object | ||
*/ | ||
type ConditionalKeys<Base, Condition> = NonNullable< | ||
// Wrap in `NonNullable` to strip away the `undefined` type from the produced union. | ||
{ | ||
// Map through all the keys of the given base type. | ||
[Key in keyof Base]: | ||
// Pick only keys with types extending the given `Condition` type. | ||
Base[Key] extends Condition | ||
// Retain this key since the condition passes. | ||
? Key | ||
// Discard this key since the condition fails. | ||
: never; | ||
// Convert the produced object into a union type of the keys which passed the conditional test. | ||
}[keyof Base] | ||
>; | ||
/** | ||
Exclude keys from a shape that matches the given `Condition`. | ||
This is useful when you want to create a new type with a specific set of keys from a shape. For example, you might want to exclude all the primitive properties from a class and form a new shape containing everything but the primitive properties. | ||
@example | ||
``` | ||
import type {Primitive, ConditionalExcept} from 'type-fest'; | ||
class Awesome { | ||
name: string; | ||
successes: number; | ||
failures: bigint; | ||
run() {} | ||
} | ||
type ExceptPrimitivesFromAwesome = ConditionalExcept<Awesome, Primitive>; | ||
//=> {run: () => void} | ||
``` | ||
@example | ||
``` | ||
import type {ConditionalExcept} from 'type-fest'; | ||
interface Example { | ||
a: string; | ||
b: string | number; | ||
c: () => void; | ||
d: {}; | ||
} | ||
type NonStringKeysOnly = ConditionalExcept<Example, string>; | ||
//=> {b: string | number; c: () => void; d: {}} | ||
``` | ||
@category Object | ||
*/ | ||
type ConditionalExcept<Base, Condition> = Except< | ||
Base, | ||
ConditionalKeys<Base, Condition> | ||
>; | ||
/** | ||
* Descriptors are objects that describe the API of a module, and the module | ||
* can either be a REST module or a host module. | ||
* This type is recursive, so it can describe nested modules. | ||
*/ | ||
type Descriptors = RESTFunctionDescriptor | AmbassadorFunctionDescriptor | HostModule<any, any> | EventDefinition<any> | ServicePluginDefinition<any> | { | ||
[key: string]: Descriptors | PublicMetadata | any; | ||
}; | ||
/** | ||
* This type takes in a descriptors object of a certain Host (including an `unknown` host) | ||
* and returns an object with the same structure, but with all descriptors replaced with their API. | ||
* Any non-descriptor properties are removed from the returned object, including descriptors that | ||
* do not match the given host (as they will not work with the given host). | ||
*/ | ||
type BuildDescriptors<T extends Descriptors, H extends Host<any> | undefined, Depth extends number = 5> = { | ||
done: T; | ||
recurse: T extends { | ||
__type: typeof SERVICE_PLUGIN_ERROR_TYPE; | ||
} ? never : T extends AmbassadorFunctionDescriptor ? BuildAmbassadorFunction<T> : T extends RESTFunctionDescriptor ? BuildRESTFunction<T> : T extends EventDefinition<any> ? BuildEventDefinition<T> : T extends ServicePluginDefinition<any> ? BuildServicePluginDefinition<T> : T extends HostModule<any, any> ? HostModuleAPI<T> : ConditionalExcept<{ | ||
[Key in keyof T]: T[Key] extends Descriptors ? BuildDescriptors<T[Key], H, [ | ||
-1, | ||
0, | ||
1, | ||
2, | ||
3, | ||
4, | ||
5 | ||
][Depth]> : never; | ||
}, EmptyObject>; | ||
}[Depth extends -1 ? 'done' : 'recurse']; | ||
type PublicMetadata = { | ||
PACKAGE_NAME?: string; | ||
}; | ||
declare global { | ||
interface ContextualClient { | ||
} | ||
} | ||
/** | ||
* A type used to create concerete types from SDK descriptors in | ||
* case a contextual client is available. | ||
*/ | ||
type MaybeContext<T extends Descriptors> = globalThis.ContextualClient extends { | ||
host: Host; | ||
} ? BuildDescriptors<T, globalThis.ContextualClient['host']> : T; | ||
interface SlotAvailability { | ||
@@ -722,6 +1098,6 @@ /** | ||
declare const queryAvailability: BuildRESTFunction<typeof queryAvailability$1> & typeof queryAvailability$1; | ||
declare const getScheduleAvailability: BuildRESTFunction<typeof getScheduleAvailability$1> & typeof getScheduleAvailability$1; | ||
declare const calculateMultiSlotAvailability: BuildRESTFunction<typeof calculateMultiSlotAvailability$1> & typeof calculateMultiSlotAvailability$1; | ||
declare const queryAvailability: MaybeContext<BuildRESTFunction<typeof queryAvailability$1> & typeof queryAvailability$1>; | ||
declare const getScheduleAvailability: MaybeContext<BuildRESTFunction<typeof getScheduleAvailability$1> & typeof getScheduleAvailability$1>; | ||
declare const calculateMultiSlotAvailability: MaybeContext<BuildRESTFunction<typeof calculateMultiSlotAvailability$1> & typeof calculateMultiSlotAvailability$1>; | ||
export { type AvailabilityWaitingList, type AvailableResources, type BookingPolicySettings, type BookingPolicyViolations, type CalculateMultiSlotAvailabilityOptions, type CalculateMultiSlotAvailabilityRequest, type CalculateMultiSlotAvailabilityResponse, type CalculateMultiSlotAvailabilityResponseNonNullableFields, type CursorPaging, type CursorPagingMetadata, type Cursors, type CustomerChoices, type EventInfo, type GetAvailabilityTimeSlotRequest, type GetAvailabilityTimeSlotResponse, type GetScheduleAvailabilityRequest, type GetScheduleAvailabilityResponse, type GetSlotAvailabilityRequest, type GetSlotAvailabilityResponse, type Location, LocationLocationType, LocationType, type NestedTimeSlot, type PagingMetadataV2, type QueryAvailabilityOptions, type QueryAvailabilityRequest, type QueryAvailabilityResponse, type QueryAvailabilityResponseNonNullableFields, type QueryV2, type QueryV2PagingMethodOneOf, type Resource, type ResourcesFilter, type RuleBasedConstraints, type ScheduleAvailability, type Service_availabilityBookingPolicyViolations, type Service_availabilityNestedTimeSlot, type Slot, type SlotAvailability, type SlotResource, SortOrder, type Sorting, type TimeSlot, type TimeSlotLocation, type WaitingList, calculateMultiSlotAvailability, getScheduleAvailability, queryAvailability }; |
Sorry, the diff of this file is not supported yet
353468
67
7627
Updated@wix/sdk-types@^1.12.3