@wix/sdk-types 1.6.2 → 1.7.0

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.
@@ -7,6 +7,15 @@ function EventDefinition(type, isDomainEvent = false, _transformations = {}) {
7
7
  transformations: _transformations
8
8
  });
9
9
  }
10
+
11
+ // src/service-plugins.ts
12
+ function ServicePluginDefinition(methods) {
13
+ return {
14
+ __type: "service-plugin-definition",
15
+ methods
16
+ };
17
+ }
10
18
  export {
11
- EventDefinition
19
+ EventDefinition,
20
+ ServicePluginDefinition
12
21
  };
package/build/index.d.mts CHANGED
@@ -70,7 +70,7 @@ type EventIdentity = {
70
70
  };
71
71
  type BaseEventMetadata = {
72
72
  instanceId: string;
73
- identity: EventIdentity;
73
+ identity?: EventIdentity;
74
74
  };
75
75
  type EventDefinition<Payload = unknown, Type extends string = string> = {
76
76
  __type: 'event-definition';
@@ -83,9 +83,31 @@ declare function EventDefinition<Type extends string>(type: Type, isDomainEvent?
83
83
  type EventHandler<T extends EventDefinition> = (payload: T['__payload']) => void | Promise<void>;
84
84
  type BuildEventDefinition<T extends EventDefinition<any, string>> = (handler: EventHandler<T>) => void;
85
85
 
86
- type SPIDefinition<TInput, TResult> = {
87
- __input: TInput;
88
- __result: TResult;
86
+ type ServicePluginContract = Record<string, (payload: {
87
+ request: any;
88
+ metadata: any;
89
+ }) => unknown | Promise<unknown>>;
90
+ type ServicePluginMethodMetadata = {
91
+ name: string;
92
+ primaryHttpMappingPath: string;
93
+ transformations: {
94
+ fromREST: (...args: unknown[]) => unknown;
95
+ toREST: (...args: unknown[]) => unknown;
96
+ };
97
+ };
98
+ type ServicePluginDefinition<Contract extends ServicePluginContract> = {
99
+ __type: 'service-plugin-definition';
100
+ methods: ServicePluginMethodMetadata[];
101
+ __contract: Contract;
102
+ };
103
+ declare function ServicePluginDefinition<Contract extends ServicePluginContract>(methods: ServicePluginMethodMetadata[]): ServicePluginDefinition<Contract>;
104
+ type BuildServicePluginDefinition<T extends ServicePluginDefinition<any>> = {
105
+ provide(implementation: T['__contract']): void;
106
+ processRequest(request: Request): Promise<Response>;
107
+ process(request: {
108
+ url: string;
109
+ body: string;
110
+ }): Promise<unknown>;
89
111
  };
90
112
 
91
- export { type APIMetadata, type AuthenticationStrategy, type BaseEventMetadata, type BoundAuthenticationStrategy, type BuildEventDefinition, type BuildRESTFunction, EventDefinition, type EventHandler, type EventIdentity, type Host, type HostModule, type HostModuleAPI, type HttpClient, type HttpResponse, type RESTFunctionDescriptor, type RequestOptions, type RequestOptionsFactory, type SPIDefinition };
113
+ export { type APIMetadata, type AuthenticationStrategy, type BaseEventMetadata, type BoundAuthenticationStrategy, type BuildEventDefinition, type BuildRESTFunction, type BuildServicePluginDefinition, EventDefinition, type EventHandler, type EventIdentity, type Host, type HostModule, type HostModuleAPI, type HttpClient, type HttpResponse, type RESTFunctionDescriptor, type RequestOptions, type RequestOptionsFactory, type ServicePluginContract, ServicePluginDefinition, type ServicePluginMethodMetadata };
package/build/index.d.ts CHANGED
@@ -70,7 +70,7 @@ type EventIdentity = {
70
70
  };
71
71
  type BaseEventMetadata = {
72
72
  instanceId: string;
73
- identity: EventIdentity;
73
+ identity?: EventIdentity;
74
74
  };
75
75
  type EventDefinition<Payload = unknown, Type extends string = string> = {
76
76
  __type: 'event-definition';
@@ -83,9 +83,31 @@ declare function EventDefinition<Type extends string>(type: Type, isDomainEvent?
83
83
  type EventHandler<T extends EventDefinition> = (payload: T['__payload']) => void | Promise<void>;
84
84
  type BuildEventDefinition<T extends EventDefinition<any, string>> = (handler: EventHandler<T>) => void;
85
85
 
86
- type SPIDefinition<TInput, TResult> = {
87
- __input: TInput;
88
- __result: TResult;
86
+ type ServicePluginContract = Record<string, (payload: {
87
+ request: any;
88
+ metadata: any;
89
+ }) => unknown | Promise<unknown>>;
90
+ type ServicePluginMethodMetadata = {
91
+ name: string;
92
+ primaryHttpMappingPath: string;
93
+ transformations: {
94
+ fromREST: (...args: unknown[]) => unknown;
95
+ toREST: (...args: unknown[]) => unknown;
96
+ };
97
+ };
98
+ type ServicePluginDefinition<Contract extends ServicePluginContract> = {
99
+ __type: 'service-plugin-definition';
100
+ methods: ServicePluginMethodMetadata[];
101
+ __contract: Contract;
102
+ };
103
+ declare function ServicePluginDefinition<Contract extends ServicePluginContract>(methods: ServicePluginMethodMetadata[]): ServicePluginDefinition<Contract>;
104
+ type BuildServicePluginDefinition<T extends ServicePluginDefinition<any>> = {
105
+ provide(implementation: T['__contract']): void;
106
+ processRequest(request: Request): Promise<Response>;
107
+ process(request: {
108
+ url: string;
109
+ body: string;
110
+ }): Promise<unknown>;
89
111
  };
90
112
 
91
- export { type APIMetadata, type AuthenticationStrategy, type BaseEventMetadata, type BoundAuthenticationStrategy, type BuildEventDefinition, type BuildRESTFunction, EventDefinition, type EventHandler, type EventIdentity, type Host, type HostModule, type HostModuleAPI, type HttpClient, type HttpResponse, type RESTFunctionDescriptor, type RequestOptions, type RequestOptionsFactory, type SPIDefinition };
113
+ export { type APIMetadata, type AuthenticationStrategy, type BaseEventMetadata, type BoundAuthenticationStrategy, type BuildEventDefinition, type BuildRESTFunction, type BuildServicePluginDefinition, EventDefinition, type EventHandler, type EventIdentity, type Host, type HostModule, type HostModuleAPI, type HttpClient, type HttpResponse, type RESTFunctionDescriptor, type RequestOptions, type RequestOptionsFactory, type ServicePluginContract, ServicePluginDefinition, type ServicePluginMethodMetadata };
package/build/index.js CHANGED
@@ -20,7 +20,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var src_exports = {};
22
22
  __export(src_exports, {
23
- EventDefinition: () => EventDefinition
23
+ EventDefinition: () => EventDefinition,
24
+ ServicePluginDefinition: () => ServicePluginDefinition
24
25
  });
25
26
  module.exports = __toCommonJS(src_exports);
26
27
 
@@ -33,7 +34,16 @@ function EventDefinition(type, isDomainEvent = false, _transformations = {}) {
33
34
  transformations: _transformations
34
35
  });
35
36
  }
37
+
38
+ // src/service-plugins.ts
39
+ function ServicePluginDefinition(methods) {
40
+ return {
41
+ __type: "service-plugin-definition",
42
+ methods
43
+ };
44
+ }
36
45
  // Annotate the CommonJS export names for ESM import in node:
37
46
  0 && (module.exports = {
38
- EventDefinition
47
+ EventDefinition,
48
+ ServicePluginDefinition
39
49
  });
package/build/index.mjs CHANGED
@@ -7,6 +7,15 @@ function EventDefinition(type, isDomainEvent = false, _transformations = {}) {
7
7
  transformations: _transformations
8
8
  });
9
9
  }
10
+
11
+ // src/service-plugins.ts
12
+ function ServicePluginDefinition(methods) {
13
+ return {
14
+ __type: "service-plugin-definition",
15
+ methods
16
+ };
17
+ }
10
18
  export {
11
- EventDefinition
19
+ EventDefinition,
20
+ ServicePluginDefinition
12
21
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/sdk-types",
3
- "version": "1.6.2",
3
+ "version": "1.7.0",
4
4
  "license": "UNLICENSED",
5
5
  "author": {
6
6
  "name": "Ronny Ringel",
@@ -57,5 +57,5 @@
57
57
  "wallaby": {
58
58
  "autoDetect": true
59
59
  },
60
- "falconPackageHash": "8bdee3bf0efc29f94318cd08f133a2fce89a11e0eee7723cefc8437e"
60
+ "falconPackageHash": "9b7f2792da45401c94a36006c1ff758bcf66103fbd3a40b1d48d3bff"
61
61
  }