@wix/sdk-types 1.12.4 → 1.12.6

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 CHANGED
@@ -1,3 +1,39 @@
1
+ type Primitive = number | string | boolean | bigint | symbol | null | undefined;
2
+ type Tags = Record<string, Primitive>;
3
+ type Context = Record<string, unknown>;
4
+ type Contexts = Record<string, Context | undefined>;
5
+
6
+ interface SpanContextData {
7
+ traceId: string;
8
+ spanId: string;
9
+ }
10
+ interface Span {
11
+ spanContext(): SpanContextData;
12
+ end(): void;
13
+ }
14
+ interface SpanOptions {
15
+ name: string;
16
+ tags?: Tags;
17
+ }
18
+ interface Breadcrumb {
19
+ type?: string;
20
+ category?: string;
21
+ message: string;
22
+ level?: 'info' | 'warning' | 'error';
23
+ data?: Record<string, unknown>;
24
+ }
25
+ interface CaptureContext {
26
+ level?: 'info' | 'warning' | 'error';
27
+ tags?: Tags;
28
+ contexts?: Contexts;
29
+ }
30
+ interface MonitoringClient {
31
+ captureException(error: unknown, context?: CaptureContext): void;
32
+ captureMessage(message: string, context?: CaptureContext): void;
33
+ startSpan<T>(options: SpanOptions, callback: (span: Span | undefined) => T): T;
34
+ addBreadcrumb(breadcrumb: Breadcrumb): void;
35
+ }
36
+
1
37
  type HostModule<T, H extends Host> = {
2
38
  __type: 'host';
3
39
  create(host: H): T;
@@ -20,6 +56,10 @@ type Host<Environment = unknown> = {
20
56
  * Optional bast url to use for API requests, for example `www.wixapis.com`
21
57
  */
22
58
  apiBaseUrl?: string;
59
+ /**
60
+ * Optional function to get a monitoring client
61
+ */
62
+ getMonitoringClient?: () => MonitoringClient;
23
63
  /**
24
64
  * Possible data to be provided by every host, for cross cutting concerns
25
65
  * like internationalization, billing, etc.
@@ -40,6 +80,7 @@ type Host<Environment = unknown> = {
40
80
  };
41
81
  };
42
82
 
83
+ type HTTPMethod = 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
43
84
  type RESTFunctionDescriptor<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient) => T;
44
85
  interface HttpClient {
45
86
  request<TResponse, TData = any>(req: RequestOptionsFactory<TResponse, TData>): Promise<HttpResponse<TResponse>>;
@@ -56,7 +97,7 @@ type HttpResponse<T = any> = {
56
97
  request?: any;
57
98
  };
58
99
  type RequestOptions<_TResponse = any, Data = any> = {
59
- method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
100
+ method: HTTPMethod;
60
101
  url: string;
61
102
  data?: Data;
62
103
  params?: URLSearchParams;
@@ -67,6 +108,18 @@ type APIMetadata = {
67
108
  packageName?: string;
68
109
  };
69
110
  type BuildRESTFunction<T extends RESTFunctionDescriptor> = T extends RESTFunctionDescriptor<infer U> ? U : never;
111
+ type RestModuleMeta<TMethod extends HTTPMethod = HTTPMethod, TPathParams = unknown, RequestType = unknown, TOriginalRequestType = unknown, ResponseType = unknown, OriginalResponseType = unknown> = {
112
+ getUrl(context: {
113
+ host: string;
114
+ }): string;
115
+ httpMethod: TMethod;
116
+ pathParams: TPathParams;
117
+ path: string;
118
+ __requestType: RequestType;
119
+ __originalRequestType: TOriginalRequestType;
120
+ __responseType: ResponseType;
121
+ __originalResponseType: OriginalResponseType;
122
+ };
70
123
 
71
124
  type AuthenticationStrategy<Host = unknown> = {
72
125
  getAuthHeaders: (host: Host) => Promise<{
@@ -516,4 +569,4 @@ type MaybeContext<T extends Descriptors> = globalThis.ContextualClient extends {
516
569
  host: Host;
517
570
  } ? BuildDescriptors<T, globalThis.ContextualClient['host']> : T;
518
571
 
519
- 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 };
572
+ 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
@@ -1,3 +1,39 @@
1
+ type Primitive = number | string | boolean | bigint | symbol | null | undefined;
2
+ type Tags = Record<string, Primitive>;
3
+ type Context = Record<string, unknown>;
4
+ type Contexts = Record<string, Context | undefined>;
5
+
6
+ interface SpanContextData {
7
+ traceId: string;
8
+ spanId: string;
9
+ }
10
+ interface Span {
11
+ spanContext(): SpanContextData;
12
+ end(): void;
13
+ }
14
+ interface SpanOptions {
15
+ name: string;
16
+ tags?: Tags;
17
+ }
18
+ interface Breadcrumb {
19
+ type?: string;
20
+ category?: string;
21
+ message: string;
22
+ level?: 'info' | 'warning' | 'error';
23
+ data?: Record<string, unknown>;
24
+ }
25
+ interface CaptureContext {
26
+ level?: 'info' | 'warning' | 'error';
27
+ tags?: Tags;
28
+ contexts?: Contexts;
29
+ }
30
+ interface MonitoringClient {
31
+ captureException(error: unknown, context?: CaptureContext): void;
32
+ captureMessage(message: string, context?: CaptureContext): void;
33
+ startSpan<T>(options: SpanOptions, callback: (span: Span | undefined) => T): T;
34
+ addBreadcrumb(breadcrumb: Breadcrumb): void;
35
+ }
36
+
1
37
  type HostModule<T, H extends Host> = {
2
38
  __type: 'host';
3
39
  create(host: H): T;
@@ -20,6 +56,10 @@ type Host<Environment = unknown> = {
20
56
  * Optional bast url to use for API requests, for example `www.wixapis.com`
21
57
  */
22
58
  apiBaseUrl?: string;
59
+ /**
60
+ * Optional function to get a monitoring client
61
+ */
62
+ getMonitoringClient?: () => MonitoringClient;
23
63
  /**
24
64
  * Possible data to be provided by every host, for cross cutting concerns
25
65
  * like internationalization, billing, etc.
@@ -40,6 +80,7 @@ type Host<Environment = unknown> = {
40
80
  };
41
81
  };
42
82
 
83
+ type HTTPMethod = 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
43
84
  type RESTFunctionDescriptor<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient) => T;
44
85
  interface HttpClient {
45
86
  request<TResponse, TData = any>(req: RequestOptionsFactory<TResponse, TData>): Promise<HttpResponse<TResponse>>;
@@ -56,7 +97,7 @@ type HttpResponse<T = any> = {
56
97
  request?: any;
57
98
  };
58
99
  type RequestOptions<_TResponse = any, Data = any> = {
59
- method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
100
+ method: HTTPMethod;
60
101
  url: string;
61
102
  data?: Data;
62
103
  params?: URLSearchParams;
@@ -67,6 +108,18 @@ type APIMetadata = {
67
108
  packageName?: string;
68
109
  };
69
110
  type BuildRESTFunction<T extends RESTFunctionDescriptor> = T extends RESTFunctionDescriptor<infer U> ? U : never;
111
+ type RestModuleMeta<TMethod extends HTTPMethod = HTTPMethod, TPathParams = unknown, RequestType = unknown, TOriginalRequestType = unknown, ResponseType = unknown, OriginalResponseType = unknown> = {
112
+ getUrl(context: {
113
+ host: string;
114
+ }): string;
115
+ httpMethod: TMethod;
116
+ pathParams: TPathParams;
117
+ path: string;
118
+ __requestType: RequestType;
119
+ __originalRequestType: TOriginalRequestType;
120
+ __responseType: ResponseType;
121
+ __originalResponseType: OriginalResponseType;
122
+ };
70
123
 
71
124
  type AuthenticationStrategy<Host = unknown> = {
72
125
  getAuthHeaders: (host: Host) => Promise<{
@@ -516,4 +569,4 @@ type MaybeContext<T extends Descriptors> = globalThis.ContextualClient extends {
516
569
  host: Host;
517
570
  } ? BuildDescriptors<T, globalThis.ContextualClient['host']> : T;
518
571
 
519
- 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 };
572
+ 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.4",
3
+ "version": "1.12.6",
4
4
  "license": "UNLICENSED",
5
5
  "author": {
6
6
  "name": "Ronny Ringel",
@@ -28,15 +28,13 @@
28
28
  "*.{js,ts}": "yarn lint"
29
29
  },
30
30
  "devDependencies": {
31
- "@types/node": "^20.17.1",
31
+ "@types/node": "^20.17.9",
32
+ "@wix/monitoring-types": "^0.1.0",
32
33
  "eslint": "^8.57.1",
33
34
  "eslint-config-sdk": "0.0.0",
34
35
  "tsup": "^7.3.0",
35
- "type-fest": "^4.26.1",
36
- "typescript": "^5.6.3"
37
- },
38
- "yoshiFlowLibrary": {
39
- "buildEsmWithBabel": true
36
+ "type-fest": "^4.30.0",
37
+ "typescript": "^5.7.2"
40
38
  },
41
39
  "eslintConfig": {
42
40
  "extends": "sdk"
@@ -58,5 +56,5 @@
58
56
  "wallaby": {
59
57
  "autoDetect": true
60
58
  },
61
- "falconPackageHash": "8469d4de3131c4bcc8fc47df34db04866cf00b50a23e8a32eb180346"
59
+ "falconPackageHash": "dcaa5ad4bac20edaae049eb3a12a7b3d0f70e9e87414bd56ba7ba402"
62
60
  }