@wix/sdk-types 1.12.3 → 1.12.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.d.mts +91 -10
- package/build/index.d.ts +91 -10
- package/package.json +6 -6
package/build/index.d.mts
CHANGED
|
@@ -12,6 +12,10 @@ type Host<Environment = unknown> = {
|
|
|
12
12
|
}>;
|
|
13
13
|
};
|
|
14
14
|
environment?: Environment;
|
|
15
|
+
/**
|
|
16
|
+
* Optional name of the environment, use for logging
|
|
17
|
+
*/
|
|
18
|
+
name?: string;
|
|
15
19
|
/**
|
|
16
20
|
* Optional bast url to use for API requests, for example `www.wixapis.com`
|
|
17
21
|
*/
|
|
@@ -36,6 +40,7 @@ type Host<Environment = unknown> = {
|
|
|
36
40
|
};
|
|
37
41
|
};
|
|
38
42
|
|
|
43
|
+
type HTTPMethod = 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
|
|
39
44
|
type RESTFunctionDescriptor<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient) => T;
|
|
40
45
|
interface HttpClient {
|
|
41
46
|
request<TResponse, TData = any>(req: RequestOptionsFactory<TResponse, TData>): Promise<HttpResponse<TResponse>>;
|
|
@@ -52,7 +57,7 @@ type HttpResponse<T = any> = {
|
|
|
52
57
|
request?: any;
|
|
53
58
|
};
|
|
54
59
|
type RequestOptions<_TResponse = any, Data = any> = {
|
|
55
|
-
method:
|
|
60
|
+
method: HTTPMethod;
|
|
56
61
|
url: string;
|
|
57
62
|
data?: Data;
|
|
58
63
|
params?: URLSearchParams;
|
|
@@ -63,6 +68,18 @@ type APIMetadata = {
|
|
|
63
68
|
packageName?: string;
|
|
64
69
|
};
|
|
65
70
|
type BuildRESTFunction<T extends RESTFunctionDescriptor> = T extends RESTFunctionDescriptor<infer U> ? U : never;
|
|
71
|
+
type RestModuleMeta<TMethod extends HTTPMethod = HTTPMethod, TPathParams = unknown, RequestType = unknown, TOriginalRequestType = unknown, ResponseType = unknown, OriginalResponseType = unknown> = {
|
|
72
|
+
getUrl(context: {
|
|
73
|
+
host: string;
|
|
74
|
+
}): string;
|
|
75
|
+
httpMethod: TMethod;
|
|
76
|
+
pathParams: TPathParams;
|
|
77
|
+
path: string;
|
|
78
|
+
__requestType: RequestType;
|
|
79
|
+
__originalRequestType: TOriginalRequestType;
|
|
80
|
+
__responseType: ResponseType;
|
|
81
|
+
__originalResponseType: OriginalResponseType;
|
|
82
|
+
};
|
|
66
83
|
|
|
67
84
|
type AuthenticationStrategy<Host = unknown> = {
|
|
68
85
|
getAuthHeaders: (host: Host) => Promise<{
|
|
@@ -311,6 +328,72 @@ type Except<ObjectType, KeysType extends keyof ObjectType, Options extends Excep
|
|
|
311
328
|
? Partial<Record<KeysType, never>>
|
|
312
329
|
: {});
|
|
313
330
|
|
|
331
|
+
/**
|
|
332
|
+
Returns a boolean for whether the given type is `never`.
|
|
333
|
+
|
|
334
|
+
@link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
|
|
335
|
+
@link https://stackoverflow.com/a/53984913/10292952
|
|
336
|
+
@link https://www.zhenghao.io/posts/ts-never
|
|
337
|
+
|
|
338
|
+
Useful in type utilities, such as checking if something does not occur.
|
|
339
|
+
|
|
340
|
+
@example
|
|
341
|
+
```
|
|
342
|
+
import type {IsNever, And} from 'type-fest';
|
|
343
|
+
|
|
344
|
+
// https://github.com/andnp/SimplyTyped/blob/master/src/types/strings.ts
|
|
345
|
+
type AreStringsEqual<A extends string, B extends string> =
|
|
346
|
+
And<
|
|
347
|
+
IsNever<Exclude<A, B>> extends true ? true : false,
|
|
348
|
+
IsNever<Exclude<B, A>> extends true ? true : false
|
|
349
|
+
>;
|
|
350
|
+
|
|
351
|
+
type EndIfEqual<I extends string, O extends string> =
|
|
352
|
+
AreStringsEqual<I, O> extends true
|
|
353
|
+
? never
|
|
354
|
+
: void;
|
|
355
|
+
|
|
356
|
+
function endIfEqual<I extends string, O extends string>(input: I, output: O): EndIfEqual<I, O> {
|
|
357
|
+
if (input === output) {
|
|
358
|
+
process.exit(0);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
endIfEqual('abc', 'abc');
|
|
363
|
+
//=> never
|
|
364
|
+
|
|
365
|
+
endIfEqual('abc', '123');
|
|
366
|
+
//=> void
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
@category Type Guard
|
|
370
|
+
@category Utilities
|
|
371
|
+
*/
|
|
372
|
+
type IsNever<T> = [T] extends [never] ? true : false;
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
An if-else-like type that resolves depending on whether the given type is `never`.
|
|
376
|
+
|
|
377
|
+
@see {@link IsNever}
|
|
378
|
+
|
|
379
|
+
@example
|
|
380
|
+
```
|
|
381
|
+
import type {IfNever} from 'type-fest';
|
|
382
|
+
|
|
383
|
+
type ShouldBeTrue = IfNever<never>;
|
|
384
|
+
//=> true
|
|
385
|
+
|
|
386
|
+
type ShouldBeBar = IfNever<'not never', 'foo', 'bar'>;
|
|
387
|
+
//=> 'bar'
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
@category Type Guard
|
|
391
|
+
@category Utilities
|
|
392
|
+
*/
|
|
393
|
+
type IfNever<T, TypeIfNever = true, TypeIfNotNever = false> = (
|
|
394
|
+
IsNever<T> extends true ? TypeIfNever : TypeIfNotNever
|
|
395
|
+
);
|
|
396
|
+
|
|
314
397
|
/**
|
|
315
398
|
Extract the keys from a type where the value type of the key extends the given `Condition`.
|
|
316
399
|
|
|
@@ -343,21 +426,19 @@ type StringKeysAndUndefined = ConditionalKeys<Example, string | undefined>;
|
|
|
343
426
|
|
|
344
427
|
@category Object
|
|
345
428
|
*/
|
|
346
|
-
type ConditionalKeys<Base, Condition> =
|
|
347
|
-
// Wrap in `NonNullable` to strip away the `undefined` type from the produced union.
|
|
429
|
+
type ConditionalKeys<Base, Condition> =
|
|
348
430
|
{
|
|
349
431
|
// Map through all the keys of the given base type.
|
|
350
|
-
[Key in keyof Base]
|
|
432
|
+
[Key in keyof Base]-?:
|
|
351
433
|
// Pick only keys with types extending the given `Condition` type.
|
|
352
434
|
Base[Key] extends Condition
|
|
353
|
-
// Retain this key
|
|
354
|
-
|
|
435
|
+
// Retain this key
|
|
436
|
+
// If the value for the key extends never, only include it if `Condition` also extends never
|
|
437
|
+
? IfNever<Base[Key], IfNever<Condition, Key, never>, Key>
|
|
355
438
|
// Discard this key since the condition fails.
|
|
356
439
|
: never;
|
|
357
|
-
|
|
358
440
|
// Convert the produced object into a union type of the keys which passed the conditional test.
|
|
359
|
-
}[keyof Base]
|
|
360
|
-
>;
|
|
441
|
+
}[keyof Base];
|
|
361
442
|
|
|
362
443
|
/**
|
|
363
444
|
Exclude keys from a shape that matches the given `Condition`.
|
|
@@ -448,4 +529,4 @@ type MaybeContext<T extends Descriptors> = globalThis.ContextualClient extends {
|
|
|
448
529
|
host: Host;
|
|
449
530
|
} ? BuildDescriptors<T, globalThis.ContextualClient['host']> : T;
|
|
450
531
|
|
|
451
|
-
export { type APIMetadata, type AmbassadorFactory, type AmbassadorFunctionDescriptor, type AmbassadorRequestOptions, type AuthenticationStrategy, type BaseEventMetadata, type BoundAuthenticationStrategy, type BuildAmbassadorFunction, type BuildDescriptors, type BuildEventDefinition, type BuildRESTFunction, type BuildServicePluginDefinition, type Descriptors, EventDefinition, type EventHandler, type EventIdentity, type Host, type HostModule, type HostModuleAPI, type HttpClient, type HttpResponse, type MaybeContext, type Method, type PublicMetadata, type RESTFunctionDescriptor, type RequestContext, type RequestOptions, type RequestOptionsFactory, SERVICE_PLUGIN_ERROR_TYPE, type ServicePluginContract, ServicePluginDefinition, type ServicePluginMethodInput, type ServicePluginMethodMetadata };
|
|
532
|
+
export { type APIMetadata, type AmbassadorFactory, type AmbassadorFunctionDescriptor, type AmbassadorRequestOptions, type AuthenticationStrategy, type BaseEventMetadata, type BoundAuthenticationStrategy, type BuildAmbassadorFunction, type BuildDescriptors, type BuildEventDefinition, type BuildRESTFunction, type BuildServicePluginDefinition, type Descriptors, EventDefinition, type EventHandler, type EventIdentity, type HTTPMethod, type Host, type HostModule, type HostModuleAPI, type HttpClient, type HttpResponse, type MaybeContext, type Method, type PublicMetadata, type RESTFunctionDescriptor, type RequestContext, type RequestOptions, type RequestOptionsFactory, type RestModuleMeta, SERVICE_PLUGIN_ERROR_TYPE, type ServicePluginContract, ServicePluginDefinition, type ServicePluginMethodInput, type ServicePluginMethodMetadata };
|
package/build/index.d.ts
CHANGED
|
@@ -12,6 +12,10 @@ type Host<Environment = unknown> = {
|
|
|
12
12
|
}>;
|
|
13
13
|
};
|
|
14
14
|
environment?: Environment;
|
|
15
|
+
/**
|
|
16
|
+
* Optional name of the environment, use for logging
|
|
17
|
+
*/
|
|
18
|
+
name?: string;
|
|
15
19
|
/**
|
|
16
20
|
* Optional bast url to use for API requests, for example `www.wixapis.com`
|
|
17
21
|
*/
|
|
@@ -36,6 +40,7 @@ type Host<Environment = unknown> = {
|
|
|
36
40
|
};
|
|
37
41
|
};
|
|
38
42
|
|
|
43
|
+
type HTTPMethod = 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
|
|
39
44
|
type RESTFunctionDescriptor<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient) => T;
|
|
40
45
|
interface HttpClient {
|
|
41
46
|
request<TResponse, TData = any>(req: RequestOptionsFactory<TResponse, TData>): Promise<HttpResponse<TResponse>>;
|
|
@@ -52,7 +57,7 @@ type HttpResponse<T = any> = {
|
|
|
52
57
|
request?: any;
|
|
53
58
|
};
|
|
54
59
|
type RequestOptions<_TResponse = any, Data = any> = {
|
|
55
|
-
method:
|
|
60
|
+
method: HTTPMethod;
|
|
56
61
|
url: string;
|
|
57
62
|
data?: Data;
|
|
58
63
|
params?: URLSearchParams;
|
|
@@ -63,6 +68,18 @@ type APIMetadata = {
|
|
|
63
68
|
packageName?: string;
|
|
64
69
|
};
|
|
65
70
|
type BuildRESTFunction<T extends RESTFunctionDescriptor> = T extends RESTFunctionDescriptor<infer U> ? U : never;
|
|
71
|
+
type RestModuleMeta<TMethod extends HTTPMethod = HTTPMethod, TPathParams = unknown, RequestType = unknown, TOriginalRequestType = unknown, ResponseType = unknown, OriginalResponseType = unknown> = {
|
|
72
|
+
getUrl(context: {
|
|
73
|
+
host: string;
|
|
74
|
+
}): string;
|
|
75
|
+
httpMethod: TMethod;
|
|
76
|
+
pathParams: TPathParams;
|
|
77
|
+
path: string;
|
|
78
|
+
__requestType: RequestType;
|
|
79
|
+
__originalRequestType: TOriginalRequestType;
|
|
80
|
+
__responseType: ResponseType;
|
|
81
|
+
__originalResponseType: OriginalResponseType;
|
|
82
|
+
};
|
|
66
83
|
|
|
67
84
|
type AuthenticationStrategy<Host = unknown> = {
|
|
68
85
|
getAuthHeaders: (host: Host) => Promise<{
|
|
@@ -311,6 +328,72 @@ type Except<ObjectType, KeysType extends keyof ObjectType, Options extends Excep
|
|
|
311
328
|
? Partial<Record<KeysType, never>>
|
|
312
329
|
: {});
|
|
313
330
|
|
|
331
|
+
/**
|
|
332
|
+
Returns a boolean for whether the given type is `never`.
|
|
333
|
+
|
|
334
|
+
@link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
|
|
335
|
+
@link https://stackoverflow.com/a/53984913/10292952
|
|
336
|
+
@link https://www.zhenghao.io/posts/ts-never
|
|
337
|
+
|
|
338
|
+
Useful in type utilities, such as checking if something does not occur.
|
|
339
|
+
|
|
340
|
+
@example
|
|
341
|
+
```
|
|
342
|
+
import type {IsNever, And} from 'type-fest';
|
|
343
|
+
|
|
344
|
+
// https://github.com/andnp/SimplyTyped/blob/master/src/types/strings.ts
|
|
345
|
+
type AreStringsEqual<A extends string, B extends string> =
|
|
346
|
+
And<
|
|
347
|
+
IsNever<Exclude<A, B>> extends true ? true : false,
|
|
348
|
+
IsNever<Exclude<B, A>> extends true ? true : false
|
|
349
|
+
>;
|
|
350
|
+
|
|
351
|
+
type EndIfEqual<I extends string, O extends string> =
|
|
352
|
+
AreStringsEqual<I, O> extends true
|
|
353
|
+
? never
|
|
354
|
+
: void;
|
|
355
|
+
|
|
356
|
+
function endIfEqual<I extends string, O extends string>(input: I, output: O): EndIfEqual<I, O> {
|
|
357
|
+
if (input === output) {
|
|
358
|
+
process.exit(0);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
endIfEqual('abc', 'abc');
|
|
363
|
+
//=> never
|
|
364
|
+
|
|
365
|
+
endIfEqual('abc', '123');
|
|
366
|
+
//=> void
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
@category Type Guard
|
|
370
|
+
@category Utilities
|
|
371
|
+
*/
|
|
372
|
+
type IsNever<T> = [T] extends [never] ? true : false;
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
An if-else-like type that resolves depending on whether the given type is `never`.
|
|
376
|
+
|
|
377
|
+
@see {@link IsNever}
|
|
378
|
+
|
|
379
|
+
@example
|
|
380
|
+
```
|
|
381
|
+
import type {IfNever} from 'type-fest';
|
|
382
|
+
|
|
383
|
+
type ShouldBeTrue = IfNever<never>;
|
|
384
|
+
//=> true
|
|
385
|
+
|
|
386
|
+
type ShouldBeBar = IfNever<'not never', 'foo', 'bar'>;
|
|
387
|
+
//=> 'bar'
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
@category Type Guard
|
|
391
|
+
@category Utilities
|
|
392
|
+
*/
|
|
393
|
+
type IfNever<T, TypeIfNever = true, TypeIfNotNever = false> = (
|
|
394
|
+
IsNever<T> extends true ? TypeIfNever : TypeIfNotNever
|
|
395
|
+
);
|
|
396
|
+
|
|
314
397
|
/**
|
|
315
398
|
Extract the keys from a type where the value type of the key extends the given `Condition`.
|
|
316
399
|
|
|
@@ -343,21 +426,19 @@ type StringKeysAndUndefined = ConditionalKeys<Example, string | undefined>;
|
|
|
343
426
|
|
|
344
427
|
@category Object
|
|
345
428
|
*/
|
|
346
|
-
type ConditionalKeys<Base, Condition> =
|
|
347
|
-
// Wrap in `NonNullable` to strip away the `undefined` type from the produced union.
|
|
429
|
+
type ConditionalKeys<Base, Condition> =
|
|
348
430
|
{
|
|
349
431
|
// Map through all the keys of the given base type.
|
|
350
|
-
[Key in keyof Base]
|
|
432
|
+
[Key in keyof Base]-?:
|
|
351
433
|
// Pick only keys with types extending the given `Condition` type.
|
|
352
434
|
Base[Key] extends Condition
|
|
353
|
-
// Retain this key
|
|
354
|
-
|
|
435
|
+
// Retain this key
|
|
436
|
+
// If the value for the key extends never, only include it if `Condition` also extends never
|
|
437
|
+
? IfNever<Base[Key], IfNever<Condition, Key, never>, Key>
|
|
355
438
|
// Discard this key since the condition fails.
|
|
356
439
|
: never;
|
|
357
|
-
|
|
358
440
|
// Convert the produced object into a union type of the keys which passed the conditional test.
|
|
359
|
-
}[keyof Base]
|
|
360
|
-
>;
|
|
441
|
+
}[keyof Base];
|
|
361
442
|
|
|
362
443
|
/**
|
|
363
444
|
Exclude keys from a shape that matches the given `Condition`.
|
|
@@ -448,4 +529,4 @@ type MaybeContext<T extends Descriptors> = globalThis.ContextualClient extends {
|
|
|
448
529
|
host: Host;
|
|
449
530
|
} ? BuildDescriptors<T, globalThis.ContextualClient['host']> : T;
|
|
450
531
|
|
|
451
|
-
export { type APIMetadata, type AmbassadorFactory, type AmbassadorFunctionDescriptor, type AmbassadorRequestOptions, type AuthenticationStrategy, type BaseEventMetadata, type BoundAuthenticationStrategy, type BuildAmbassadorFunction, type BuildDescriptors, type BuildEventDefinition, type BuildRESTFunction, type BuildServicePluginDefinition, type Descriptors, EventDefinition, type EventHandler, type EventIdentity, type Host, type HostModule, type HostModuleAPI, type HttpClient, type HttpResponse, type MaybeContext, type Method, type PublicMetadata, type RESTFunctionDescriptor, type RequestContext, type RequestOptions, type RequestOptionsFactory, SERVICE_PLUGIN_ERROR_TYPE, type ServicePluginContract, ServicePluginDefinition, type ServicePluginMethodInput, type ServicePluginMethodMetadata };
|
|
532
|
+
export { type APIMetadata, type AmbassadorFactory, type AmbassadorFunctionDescriptor, type AmbassadorRequestOptions, type AuthenticationStrategy, type BaseEventMetadata, type BoundAuthenticationStrategy, type BuildAmbassadorFunction, type BuildDescriptors, type BuildEventDefinition, type BuildRESTFunction, type BuildServicePluginDefinition, type Descriptors, EventDefinition, type EventHandler, type EventIdentity, type HTTPMethod, type Host, type HostModule, type HostModuleAPI, type HttpClient, type HttpResponse, type MaybeContext, type Method, type PublicMetadata, type RESTFunctionDescriptor, type RequestContext, type RequestOptions, type RequestOptionsFactory, type RestModuleMeta, SERVICE_PLUGIN_ERROR_TYPE, type ServicePluginContract, ServicePluginDefinition, type ServicePluginMethodInput, type ServicePluginMethodMetadata };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/sdk-types",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.5",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Ronny Ringel",
|
|
@@ -28,12 +28,12 @@
|
|
|
28
28
|
"*.{js,ts}": "yarn lint"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@types/node": "^20.
|
|
32
|
-
"eslint": "^8.
|
|
31
|
+
"@types/node": "^20.17.9",
|
|
32
|
+
"eslint": "^8.57.1",
|
|
33
33
|
"eslint-config-sdk": "0.0.0",
|
|
34
34
|
"tsup": "^7.3.0",
|
|
35
|
-
"type-fest": "^4.
|
|
36
|
-
"typescript": "^5.
|
|
35
|
+
"type-fest": "^4.29.0",
|
|
36
|
+
"typescript": "^5.7.2"
|
|
37
37
|
},
|
|
38
38
|
"yoshiFlowLibrary": {
|
|
39
39
|
"buildEsmWithBabel": true
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"wallaby": {
|
|
59
59
|
"autoDetect": true
|
|
60
60
|
},
|
|
61
|
-
"falconPackageHash": "
|
|
61
|
+
"falconPackageHash": "0d2624979aa91d2fdf561413936058ec3500f8622d610fd50c7cc8da"
|
|
62
62
|
}
|