@wix/sdk-types 1.5.11 → 1.6.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.
@@ -1,4 +1,4 @@
1
- // src/webhooks.ts
1
+ // src/event-handlers-modules.ts
2
2
  function EventDefinition(type, isDomainEvent = false, _transformations = {}) {
3
3
  return () => ({
4
4
  __type: "event-definition",
package/build/index.d.mts CHANGED
@@ -92,10 +92,13 @@ type DomainEvent<ActionType extends 'create' | 'update' | 'delete' | 'action', P
92
92
  } : ActionType extends 'delete' ? {
93
93
  deletedEvent: Payload;
94
94
  } : never);
95
+ type PayloadOfEventDefinition<T extends EventDefinition<any, any>> = T extends EventDefinition<infer P, any> ? P : never;
96
+ type EventHandler<T extends EventDefinition> = (payload: PayloadOfEventDefinition<T>, metadata: unknown) => void | Promise<void>;
97
+ type BuildEventDefinition<T extends EventDefinition<any, string>> = (handler: EventHandler<T>) => void;
95
98
 
96
99
  type SPIDefinition<TInput, TResult> = {
97
100
  __input: TInput;
98
101
  __result: TResult;
99
102
  };
100
103
 
101
- export { type APIMetadata, type AuthenticationStrategy, type BoundAuthenticationStrategy, type BuildRESTFunction, type DomainEvent, EventDefinition, type Host, type HostModule, type HostModuleAPI, type HttpClient, type HttpResponse, type RESTFunctionDescriptor, type RequestOptions, type RequestOptionsFactory, type SPIDefinition };
104
+ export { type APIMetadata, type AuthenticationStrategy, type BoundAuthenticationStrategy, type BuildEventDefinition, type BuildRESTFunction, type DomainEvent, EventDefinition, type EventHandler, type Host, type HostModule, type HostModuleAPI, type HttpClient, type HttpResponse, type RESTFunctionDescriptor, type RequestOptions, type RequestOptionsFactory, type SPIDefinition };
package/build/index.d.ts CHANGED
@@ -92,10 +92,13 @@ type DomainEvent<ActionType extends 'create' | 'update' | 'delete' | 'action', P
92
92
  } : ActionType extends 'delete' ? {
93
93
  deletedEvent: Payload;
94
94
  } : never);
95
+ type PayloadOfEventDefinition<T extends EventDefinition<any, any>> = T extends EventDefinition<infer P, any> ? P : never;
96
+ type EventHandler<T extends EventDefinition> = (payload: PayloadOfEventDefinition<T>, metadata: unknown) => void | Promise<void>;
97
+ type BuildEventDefinition<T extends EventDefinition<any, string>> = (handler: EventHandler<T>) => void;
95
98
 
96
99
  type SPIDefinition<TInput, TResult> = {
97
100
  __input: TInput;
98
101
  __result: TResult;
99
102
  };
100
103
 
101
- export { type APIMetadata, type AuthenticationStrategy, type BoundAuthenticationStrategy, type BuildRESTFunction, type DomainEvent, EventDefinition, type Host, type HostModule, type HostModuleAPI, type HttpClient, type HttpResponse, type RESTFunctionDescriptor, type RequestOptions, type RequestOptionsFactory, type SPIDefinition };
104
+ export { type APIMetadata, type AuthenticationStrategy, type BoundAuthenticationStrategy, type BuildEventDefinition, type BuildRESTFunction, type DomainEvent, EventDefinition, type EventHandler, type Host, type HostModule, type HostModuleAPI, type HttpClient, type HttpResponse, type RESTFunctionDescriptor, type RequestOptions, type RequestOptionsFactory, type SPIDefinition };
package/build/index.js CHANGED
@@ -24,7 +24,7 @@ __export(src_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(src_exports);
26
26
 
27
- // src/webhooks.ts
27
+ // src/event-handlers-modules.ts
28
28
  function EventDefinition(type, isDomainEvent = false, _transformations = {}) {
29
29
  return () => ({
30
30
  __type: "event-definition",
package/build/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- // src/webhooks.ts
1
+ // src/event-handlers-modules.ts
2
2
  function EventDefinition(type, isDomainEvent = false, _transformations = {}) {
3
3
  return () => ({
4
4
  __type: "event-definition",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/sdk-types",
3
- "version": "1.5.11",
3
+ "version": "1.6.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": "7f942fce22de14c416d155809e4c307aa5562cd2de9d257c5031e400"
60
+ "falconPackageHash": "dfd4b7c02207e404e4c5aef688534e4416df961e3a6b42271666041b"
61
61
  }