@webiny/sdk 6.4.0-beta.0 → 6.4.0-beta.2

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.
Files changed (44) hide show
  1. package/WebhooksSdk.d.ts +35 -0
  2. package/WebhooksSdk.js +49 -0
  3. package/WebhooksSdk.js.map +1 -0
  4. package/Webiny.d.ts +2 -0
  5. package/Webiny.js +5 -0
  6. package/Webiny.js.map +1 -1
  7. package/index.d.ts +11 -0
  8. package/index.js +1 -0
  9. package/methods/webhooks/createWebhook.d.ts +12 -0
  10. package/methods/webhooks/createWebhook.js +41 -0
  11. package/methods/webhooks/createWebhook.js.map +1 -0
  12. package/methods/webhooks/deleteWebhook.d.ts +6 -0
  13. package/methods/webhooks/deleteWebhook.js +30 -0
  14. package/methods/webhooks/deleteWebhook.js.map +1 -0
  15. package/methods/webhooks/getWebhook.d.ts +7 -0
  16. package/methods/webhooks/getWebhook.js +41 -0
  17. package/methods/webhooks/getWebhook.js.map +1 -0
  18. package/methods/webhooks/getWebhookDelivery.d.ts +7 -0
  19. package/methods/webhooks/getWebhookDelivery.js +43 -0
  20. package/methods/webhooks/getWebhookDelivery.js.map +1 -0
  21. package/methods/webhooks/listAvailableWebhookEvents.d.ts +7 -0
  22. package/methods/webhooks/listAvailableWebhookEvents.js +31 -0
  23. package/methods/webhooks/listAvailableWebhookEvents.js.map +1 -0
  24. package/methods/webhooks/listWebhookDeliveries.d.ts +17 -0
  25. package/methods/webhooks/listWebhookDeliveries.js +53 -0
  26. package/methods/webhooks/listWebhookDeliveries.js.map +1 -0
  27. package/methods/webhooks/listWebhooks.d.ts +19 -0
  28. package/methods/webhooks/listWebhooks.js +51 -0
  29. package/methods/webhooks/listWebhooks.js.map +1 -0
  30. package/methods/webhooks/resendWebhookDelivery.d.ts +6 -0
  31. package/methods/webhooks/resendWebhookDelivery.js +30 -0
  32. package/methods/webhooks/resendWebhookDelivery.js.map +1 -0
  33. package/methods/webhooks/schemas.d.ts +46 -0
  34. package/methods/webhooks/schemas.js +50 -0
  35. package/methods/webhooks/schemas.js.map +1 -0
  36. package/methods/webhooks/triggerWebhook.d.ts +8 -0
  37. package/methods/webhooks/triggerWebhook.js +44 -0
  38. package/methods/webhooks/triggerWebhook.js.map +1 -0
  39. package/methods/webhooks/updateWebhook.d.ts +13 -0
  40. package/methods/webhooks/updateWebhook.js +42 -0
  41. package/methods/webhooks/updateWebhook.js.map +1 -0
  42. package/methods/webhooks/webhooksTypes.d.ts +32 -0
  43. package/methods/webhooks/webhooksTypes.js +0 -0
  44. package/package.json +3 -3
@@ -0,0 +1,35 @@
1
+ import type { WebinyConfig } from "./types.js";
2
+ import type { HttpError } from "./errors.js";
3
+ import type { ApiError } from "./errors.js";
4
+ import type { NetworkError } from "./errors.js";
5
+ import type { ValidationError } from "./errors.js";
6
+ import type { Result } from "./Result.js";
7
+ import type { Webhook } from "./methods/webhooks/webhooksTypes.js";
8
+ import type { WebhookDelivery } from "./methods/webhooks/webhooksTypes.js";
9
+ import type { WebhookEvent } from "./methods/webhooks/webhooksTypes.js";
10
+ import type { GetWebhookParams } from "./methods/webhooks/getWebhook.js";
11
+ import type { ListWebhooksParams } from "./methods/webhooks/listWebhooks.js";
12
+ import type { ListWebhooksResult } from "./methods/webhooks/listWebhooks.js";
13
+ import type { CreateWebhookParams } from "./methods/webhooks/createWebhook.js";
14
+ import type { UpdateWebhookParams } from "./methods/webhooks/updateWebhook.js";
15
+ import type { DeleteWebhookParams } from "./methods/webhooks/deleteWebhook.js";
16
+ import type { GetWebhookDeliveryParams } from "./methods/webhooks/getWebhookDelivery.js";
17
+ import type { ListWebhookDeliveriesParams } from "./methods/webhooks/listWebhookDeliveries.js";
18
+ import type { ListWebhookDeliveriesResult } from "./methods/webhooks/listWebhookDeliveries.js";
19
+ import type { ResendWebhookDeliveryParams } from "./methods/webhooks/resendWebhookDelivery.js";
20
+ import type { TriggerWebhookParams } from "./methods/webhooks/triggerWebhook.js";
21
+ export declare class WebhooksSdk {
22
+ private readonly config;
23
+ private readonly fetchFn;
24
+ constructor(config: WebinyConfig);
25
+ getWebhook(params: GetWebhookParams): Promise<Result<Webhook, HttpError | ApiError | NetworkError | ValidationError>>;
26
+ listWebhooks(params?: ListWebhooksParams): Promise<Result<ListWebhooksResult, HttpError | ApiError | NetworkError | ValidationError>>;
27
+ createWebhook(params: CreateWebhookParams): Promise<Result<Webhook, HttpError | ApiError | NetworkError | ValidationError>>;
28
+ updateWebhook(params: UpdateWebhookParams): Promise<Result<Webhook, HttpError | ApiError | NetworkError | ValidationError>>;
29
+ deleteWebhook(params: DeleteWebhookParams): Promise<Result<boolean, HttpError | ApiError | NetworkError | ValidationError>>;
30
+ getWebhookDelivery(params: GetWebhookDeliveryParams): Promise<Result<WebhookDelivery, HttpError | ApiError | NetworkError | ValidationError>>;
31
+ listWebhookDeliveries(params: ListWebhookDeliveriesParams): Promise<Result<ListWebhookDeliveriesResult, HttpError | ApiError | NetworkError | ValidationError>>;
32
+ resendWebhookDelivery(params: ResendWebhookDeliveryParams): Promise<Result<boolean, HttpError | ApiError | NetworkError | ValidationError>>;
33
+ listAvailableWebhookEvents(): Promise<Result<WebhookEvent[], HttpError | ApiError | NetworkError>>;
34
+ triggerWebhook(params: TriggerWebhookParams): Promise<Result<WebhookDelivery, HttpError | ApiError | NetworkError | ValidationError>>;
35
+ }
package/WebhooksSdk.js ADDED
@@ -0,0 +1,49 @@
1
+ import { getWebhook } from "./methods/webhooks/getWebhook.js";
2
+ import { listWebhooks } from "./methods/webhooks/listWebhooks.js";
3
+ import { createWebhook } from "./methods/webhooks/createWebhook.js";
4
+ import { updateWebhook } from "./methods/webhooks/updateWebhook.js";
5
+ import { deleteWebhook } from "./methods/webhooks/deleteWebhook.js";
6
+ import { getWebhookDelivery } from "./methods/webhooks/getWebhookDelivery.js";
7
+ import { listWebhookDeliveries } from "./methods/webhooks/listWebhookDeliveries.js";
8
+ import { resendWebhookDelivery } from "./methods/webhooks/resendWebhookDelivery.js";
9
+ import { listAvailableWebhookEvents } from "./methods/webhooks/listAvailableWebhookEvents.js";
10
+ import { triggerWebhook } from "./methods/webhooks/triggerWebhook.js";
11
+ class WebhooksSdk {
12
+ constructor(config){
13
+ this.config = config;
14
+ this.fetchFn = config.fetch || fetch;
15
+ }
16
+ async getWebhook(params) {
17
+ return getWebhook(this.config, this.fetchFn, params);
18
+ }
19
+ async listWebhooks(params) {
20
+ return listWebhooks(this.config, this.fetchFn, params ?? {});
21
+ }
22
+ async createWebhook(params) {
23
+ return createWebhook(this.config, this.fetchFn, params);
24
+ }
25
+ async updateWebhook(params) {
26
+ return updateWebhook(this.config, this.fetchFn, params);
27
+ }
28
+ async deleteWebhook(params) {
29
+ return deleteWebhook(this.config, this.fetchFn, params);
30
+ }
31
+ async getWebhookDelivery(params) {
32
+ return getWebhookDelivery(this.config, this.fetchFn, params);
33
+ }
34
+ async listWebhookDeliveries(params) {
35
+ return listWebhookDeliveries(this.config, this.fetchFn, params);
36
+ }
37
+ async resendWebhookDelivery(params) {
38
+ return resendWebhookDelivery(this.config, this.fetchFn, params);
39
+ }
40
+ async listAvailableWebhookEvents() {
41
+ return listAvailableWebhookEvents(this.config, this.fetchFn);
42
+ }
43
+ async triggerWebhook(params) {
44
+ return triggerWebhook(this.config, this.fetchFn, params);
45
+ }
46
+ }
47
+ export { WebhooksSdk };
48
+
49
+ //# sourceMappingURL=WebhooksSdk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WebhooksSdk.js","sources":["../src/WebhooksSdk.ts"],"sourcesContent":["import type { WebinyConfig } from \"./types.js\";\nimport type { HttpError } from \"./errors.js\";\nimport type { ApiError } from \"./errors.js\";\nimport type { NetworkError } from \"./errors.js\";\nimport type { ValidationError } from \"./errors.js\";\nimport type { Result } from \"./Result.js\";\nimport type { Webhook } from \"./methods/webhooks/webhooksTypes.js\";\nimport type { WebhookDelivery } from \"./methods/webhooks/webhooksTypes.js\";\nimport type { WebhookEvent } from \"./methods/webhooks/webhooksTypes.js\";\nimport type { GetWebhookParams } from \"./methods/webhooks/getWebhook.js\";\nimport type { ListWebhooksParams } from \"./methods/webhooks/listWebhooks.js\";\nimport type { ListWebhooksResult } from \"./methods/webhooks/listWebhooks.js\";\nimport type { CreateWebhookParams } from \"./methods/webhooks/createWebhook.js\";\nimport type { UpdateWebhookParams } from \"./methods/webhooks/updateWebhook.js\";\nimport type { DeleteWebhookParams } from \"./methods/webhooks/deleteWebhook.js\";\nimport type { GetWebhookDeliveryParams } from \"./methods/webhooks/getWebhookDelivery.js\";\nimport type { ListWebhookDeliveriesParams } from \"./methods/webhooks/listWebhookDeliveries.js\";\nimport type { ListWebhookDeliveriesResult } from \"./methods/webhooks/listWebhookDeliveries.js\";\nimport type { ResendWebhookDeliveryParams } from \"./methods/webhooks/resendWebhookDelivery.js\";\nimport type { TriggerWebhookParams } from \"./methods/webhooks/triggerWebhook.js\";\nimport { getWebhook as getWebhookFn } from \"./methods/webhooks/getWebhook.js\";\nimport { listWebhooks as listWebhooksFn } from \"./methods/webhooks/listWebhooks.js\";\nimport { createWebhook as createWebhookFn } from \"./methods/webhooks/createWebhook.js\";\nimport { updateWebhook as updateWebhookFn } from \"./methods/webhooks/updateWebhook.js\";\nimport { deleteWebhook as deleteWebhookFn } from \"./methods/webhooks/deleteWebhook.js\";\nimport { getWebhookDelivery as getWebhookDeliveryFn } from \"./methods/webhooks/getWebhookDelivery.js\";\nimport { listWebhookDeliveries as listWebhookDeliveriesFn } from \"./methods/webhooks/listWebhookDeliveries.js\";\nimport { resendWebhookDelivery as resendWebhookDeliveryFn } from \"./methods/webhooks/resendWebhookDelivery.js\";\nimport { listAvailableWebhookEvents as listAvailableWebhookEventsFn } from \"./methods/webhooks/listAvailableWebhookEvents.js\";\nimport { triggerWebhook as triggerWebhookFn } from \"./methods/webhooks/triggerWebhook.js\";\n\nexport class WebhooksSdk {\n private readonly config: WebinyConfig;\n private readonly fetchFn: typeof fetch;\n\n constructor(config: WebinyConfig) {\n this.config = config;\n this.fetchFn = config.fetch || fetch;\n }\n\n async getWebhook(\n params: GetWebhookParams\n ): Promise<Result<Webhook, HttpError | ApiError | NetworkError | ValidationError>> {\n return getWebhookFn(this.config, this.fetchFn, params);\n }\n\n async listWebhooks(\n params?: ListWebhooksParams\n ): Promise<Result<ListWebhooksResult, HttpError | ApiError | NetworkError | ValidationError>> {\n return listWebhooksFn(this.config, this.fetchFn, params ?? {});\n }\n\n async createWebhook(\n params: CreateWebhookParams\n ): Promise<Result<Webhook, HttpError | ApiError | NetworkError | ValidationError>> {\n return createWebhookFn(this.config, this.fetchFn, params);\n }\n\n async updateWebhook(\n params: UpdateWebhookParams\n ): Promise<Result<Webhook, HttpError | ApiError | NetworkError | ValidationError>> {\n return updateWebhookFn(this.config, this.fetchFn, params);\n }\n\n async deleteWebhook(\n params: DeleteWebhookParams\n ): Promise<Result<boolean, HttpError | ApiError | NetworkError | ValidationError>> {\n return deleteWebhookFn(this.config, this.fetchFn, params);\n }\n\n async getWebhookDelivery(\n params: GetWebhookDeliveryParams\n ): Promise<Result<WebhookDelivery, HttpError | ApiError | NetworkError | ValidationError>> {\n return getWebhookDeliveryFn(this.config, this.fetchFn, params);\n }\n\n async listWebhookDeliveries(\n params: ListWebhookDeliveriesParams\n ): Promise<\n Result<ListWebhookDeliveriesResult, HttpError | ApiError | NetworkError | ValidationError>\n > {\n return listWebhookDeliveriesFn(this.config, this.fetchFn, params);\n }\n\n async resendWebhookDelivery(\n params: ResendWebhookDeliveryParams\n ): Promise<Result<boolean, HttpError | ApiError | NetworkError | ValidationError>> {\n return resendWebhookDeliveryFn(this.config, this.fetchFn, params);\n }\n\n async listAvailableWebhookEvents(): Promise<\n Result<WebhookEvent[], HttpError | ApiError | NetworkError>\n > {\n return listAvailableWebhookEventsFn(this.config, this.fetchFn);\n }\n\n async triggerWebhook(\n params: TriggerWebhookParams\n ): Promise<Result<WebhookDelivery, HttpError | ApiError | NetworkError | ValidationError>> {\n return triggerWebhookFn(this.config, this.fetchFn, params);\n }\n}\n"],"names":["WebhooksSdk","config","fetch","params","getWebhookFn","listWebhooksFn","createWebhookFn","updateWebhookFn","deleteWebhookFn","getWebhookDeliveryFn","listWebhookDeliveriesFn","resendWebhookDeliveryFn","listAvailableWebhookEventsFn","triggerWebhookFn"],"mappings":";;;;;;;;;;AA+BO,MAAMA;IAIT,YAAYC,MAAoB,CAAE;QAC9B,IAAI,CAAC,MAAM,GAAGA;QACd,IAAI,CAAC,OAAO,GAAGA,OAAO,KAAK,IAAIC;IACnC;IAEA,MAAM,WACFC,MAAwB,EACuD;QAC/E,OAAOC,WAAa,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAED;IACnD;IAEA,MAAM,aACFA,MAA2B,EAC+D;QAC1F,OAAOE,aAAe,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAEF,UAAU,CAAC;IAChE;IAEA,MAAM,cACFA,MAA2B,EACoD;QAC/E,OAAOG,cAAgB,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAEH;IACtD;IAEA,MAAM,cACFA,MAA2B,EACoD;QAC/E,OAAOI,cAAgB,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAEJ;IACtD;IAEA,MAAM,cACFA,MAA2B,EACoD;QAC/E,OAAOK,cAAgB,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAEL;IACtD;IAEA,MAAM,mBACFA,MAAgC,EACuD;QACvF,OAAOM,mBAAqB,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAEN;IAC3D;IAEA,MAAM,sBACFA,MAAmC,EAGrC;QACE,OAAOO,sBAAwB,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAEP;IAC9D;IAEA,MAAM,sBACFA,MAAmC,EAC4C;QAC/E,OAAOQ,sBAAwB,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAER;IAC9D;IAEA,MAAM,6BAEJ;QACE,OAAOS,2BAA6B,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO;IACjE;IAEA,MAAM,eACFT,MAA4B,EAC2D;QACvF,OAAOU,eAAiB,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAEV;IACvD;AACJ"}
package/Webiny.d.ts CHANGED
@@ -4,12 +4,14 @@ import { TenantManagerSdk } from "./TenantManagerSdk.js";
4
4
  import { FileManagerSdk } from "./FileManagerSdk.js";
5
5
  import { LanguagesSdk } from "./LanguagesSdk.js";
6
6
  import { TasksSdk } from "./TasksSdk.js";
7
+ import { WebhooksSdk } from "./WebhooksSdk.js";
7
8
  export declare class Webiny {
8
9
  readonly cms: CmsSdk;
9
10
  readonly tenantManager: TenantManagerSdk;
10
11
  readonly fileManager: FileManagerSdk;
11
12
  readonly languages: LanguagesSdk;
12
13
  readonly tasks: TasksSdk;
14
+ readonly webhooks: WebhooksSdk;
13
15
  constructor(config: WebinyConfig);
14
16
  }
15
17
  export { Webiny as Sdk };
package/Webiny.js CHANGED
@@ -3,6 +3,7 @@ import { TenantManagerSdk } from "./TenantManagerSdk.js";
3
3
  import { FileManagerSdk } from "./FileManagerSdk.js";
4
4
  import { LanguagesSdk } from "./LanguagesSdk.js";
5
5
  import { TasksSdk } from "./TasksSdk.js";
6
+ import { WebhooksSdk } from "./WebhooksSdk.js";
6
7
  class Webiny {
7
8
  constructor(config){
8
9
  this.cms = new CmsSdk({
@@ -25,6 +26,10 @@ class Webiny {
25
26
  ...config,
26
27
  tenant: config.tenant || "root"
27
28
  });
29
+ this.webhooks = new WebhooksSdk({
30
+ ...config,
31
+ tenant: config.tenant || "root"
32
+ });
28
33
  }
29
34
  }
30
35
  export { Webiny as Sdk, Webiny };
package/Webiny.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Webiny.js","sources":["../src/Webiny.ts"],"sourcesContent":["import type { WebinyConfig } from \"./types.js\";\nimport { CmsSdk } from \"./CmsSdk.js\";\nimport { TenantManagerSdk } from \"./TenantManagerSdk.js\";\nimport { FileManagerSdk } from \"./FileManagerSdk.js\";\nimport { LanguagesSdk } from \"./LanguagesSdk.js\";\nimport { TasksSdk } from \"./TasksSdk.js\";\n\nexport class Webiny {\n public readonly cms: CmsSdk;\n public readonly tenantManager: TenantManagerSdk;\n public readonly fileManager: FileManagerSdk;\n public readonly languages: LanguagesSdk;\n public readonly tasks: TasksSdk;\n\n constructor(config: WebinyConfig) {\n this.cms = new CmsSdk({\n ...config,\n tenant: config.tenant || \"root\"\n });\n this.tenantManager = new TenantManagerSdk({\n ...config,\n tenant: config.tenant || \"root\"\n });\n this.fileManager = new FileManagerSdk({\n ...config,\n tenant: config.tenant || \"root\"\n });\n this.languages = new LanguagesSdk({\n ...config,\n tenant: config.tenant || \"root\"\n });\n this.tasks = new TasksSdk({\n ...config,\n tenant: config.tenant || \"root\"\n });\n }\n}\n\n// Backward compatibility exports.\nexport { Webiny as Sdk };\nexport type { WebinyConfig as SdkConfig };\n"],"names":["Webiny","config","CmsSdk","TenantManagerSdk","FileManagerSdk","LanguagesSdk","TasksSdk"],"mappings":";;;;;AAOO,MAAMA;IAOT,YAAYC,MAAoB,CAAE;QAC9B,IAAI,CAAC,GAAG,GAAG,IAAIC,OAAO;YAClB,GAAGD,MAAM;YACT,QAAQA,OAAO,MAAM,IAAI;QAC7B;QACA,IAAI,CAAC,aAAa,GAAG,IAAIE,iBAAiB;YACtC,GAAGF,MAAM;YACT,QAAQA,OAAO,MAAM,IAAI;QAC7B;QACA,IAAI,CAAC,WAAW,GAAG,IAAIG,eAAe;YAClC,GAAGH,MAAM;YACT,QAAQA,OAAO,MAAM,IAAI;QAC7B;QACA,IAAI,CAAC,SAAS,GAAG,IAAII,aAAa;YAC9B,GAAGJ,MAAM;YACT,QAAQA,OAAO,MAAM,IAAI;QAC7B;QACA,IAAI,CAAC,KAAK,GAAG,IAAIK,SAAS;YACtB,GAAGL,MAAM;YACT,QAAQA,OAAO,MAAM,IAAI;QAC7B;IACJ;AACJ"}
1
+ {"version":3,"file":"Webiny.js","sources":["../src/Webiny.ts"],"sourcesContent":["import type { WebinyConfig } from \"./types.js\";\nimport { CmsSdk } from \"./CmsSdk.js\";\nimport { TenantManagerSdk } from \"./TenantManagerSdk.js\";\nimport { FileManagerSdk } from \"./FileManagerSdk.js\";\nimport { LanguagesSdk } from \"./LanguagesSdk.js\";\nimport { TasksSdk } from \"./TasksSdk.js\";\nimport { WebhooksSdk } from \"./WebhooksSdk.js\";\n\nexport class Webiny {\n public readonly cms: CmsSdk;\n public readonly tenantManager: TenantManagerSdk;\n public readonly fileManager: FileManagerSdk;\n public readonly languages: LanguagesSdk;\n public readonly tasks: TasksSdk;\n public readonly webhooks: WebhooksSdk;\n\n constructor(config: WebinyConfig) {\n this.cms = new CmsSdk({\n ...config,\n tenant: config.tenant || \"root\"\n });\n this.tenantManager = new TenantManagerSdk({\n ...config,\n tenant: config.tenant || \"root\"\n });\n this.fileManager = new FileManagerSdk({\n ...config,\n tenant: config.tenant || \"root\"\n });\n this.languages = new LanguagesSdk({\n ...config,\n tenant: config.tenant || \"root\"\n });\n this.tasks = new TasksSdk({\n ...config,\n tenant: config.tenant || \"root\"\n });\n this.webhooks = new WebhooksSdk({\n ...config,\n tenant: config.tenant || \"root\"\n });\n }\n}\n\n// Backward compatibility exports.\nexport { Webiny as Sdk };\nexport type { WebinyConfig as SdkConfig };\n"],"names":["Webiny","config","CmsSdk","TenantManagerSdk","FileManagerSdk","LanguagesSdk","TasksSdk","WebhooksSdk"],"mappings":";;;;;;AAQO,MAAMA;IAQT,YAAYC,MAAoB,CAAE;QAC9B,IAAI,CAAC,GAAG,GAAG,IAAIC,OAAO;YAClB,GAAGD,MAAM;YACT,QAAQA,OAAO,MAAM,IAAI;QAC7B;QACA,IAAI,CAAC,aAAa,GAAG,IAAIE,iBAAiB;YACtC,GAAGF,MAAM;YACT,QAAQA,OAAO,MAAM,IAAI;QAC7B;QACA,IAAI,CAAC,WAAW,GAAG,IAAIG,eAAe;YAClC,GAAGH,MAAM;YACT,QAAQA,OAAO,MAAM,IAAI;QAC7B;QACA,IAAI,CAAC,SAAS,GAAG,IAAII,aAAa;YAC9B,GAAGJ,MAAM;YACT,QAAQA,OAAO,MAAM,IAAI;QAC7B;QACA,IAAI,CAAC,KAAK,GAAG,IAAIK,SAAS;YACtB,GAAGL,MAAM;YACT,QAAQA,OAAO,MAAM,IAAI;QAC7B;QACA,IAAI,CAAC,QAAQ,GAAG,IAAIM,YAAY;YAC5B,GAAGN,MAAM;YACT,QAAQA,OAAO,MAAM,IAAI;QAC7B;IACJ;AACJ"}
package/index.d.ts CHANGED
@@ -4,6 +4,7 @@ export * from "./TenantManagerSdk.js";
4
4
  export * from "./FileManagerSdk.js";
5
5
  export * from "./LanguagesSdk.js";
6
6
  export * from "./TasksSdk.js";
7
+ export * from "./WebhooksSdk.js";
7
8
  export * from "./types.js";
8
9
  export { Result } from "./Result.js";
9
10
  export { HttpError, ApiError, NetworkError, ValidationError } from "./errors.js";
@@ -37,3 +38,13 @@ export type { TaskStatus, TaskDefinition, TaskRun, TaskLog, TaskLogItem } from "
37
38
  export type { ListLogsParams } from "./methods/tasks/listLogs.js";
38
39
  export type { TriggerTaskParams } from "./methods/tasks/triggerTask.js";
39
40
  export type { AbortTaskParams } from "./methods/tasks/abortTask.js";
41
+ export type { Webhook, WebhookDelivery, WebhookEvent } from "./methods/webhooks/webhooksTypes.js";
42
+ export type { GetWebhookParams } from "./methods/webhooks/getWebhook.js";
43
+ export type { ListWebhooksParams, ListWebhooksResult } from "./methods/webhooks/listWebhooks.js";
44
+ export type { CreateWebhookParams } from "./methods/webhooks/createWebhook.js";
45
+ export type { UpdateWebhookParams } from "./methods/webhooks/updateWebhook.js";
46
+ export type { DeleteWebhookParams } from "./methods/webhooks/deleteWebhook.js";
47
+ export type { GetWebhookDeliveryParams } from "./methods/webhooks/getWebhookDelivery.js";
48
+ export type { ListWebhookDeliveriesParams, ListWebhookDeliveriesResult } from "./methods/webhooks/listWebhookDeliveries.js";
49
+ export type { ResendWebhookDeliveryParams } from "./methods/webhooks/resendWebhookDelivery.js";
50
+ export type { TriggerWebhookParams } from "./methods/webhooks/triggerWebhook.js";
package/index.js CHANGED
@@ -4,6 +4,7 @@ export * from "./TenantManagerSdk.js";
4
4
  export * from "./FileManagerSdk.js";
5
5
  export * from "./LanguagesSdk.js";
6
6
  export * from "./TasksSdk.js";
7
+ export * from "./WebhooksSdk.js";
7
8
  export * from "./types.js";
8
9
  export { Result } from "./Result.js";
9
10
  export { ApiError, HttpError, NetworkError, ValidationError } from "./errors.js";
@@ -0,0 +1,12 @@
1
+ import { Result } from "../../Result.js";
2
+ import type { Webhook } from "./webhooksTypes.js";
3
+ import { ApiError } from "../../errors.js";
4
+ export interface CreateWebhookParams {
5
+ name: string;
6
+ endpointUrl: string;
7
+ events: string[];
8
+ slug?: string;
9
+ description?: string;
10
+ enabled?: boolean;
11
+ }
12
+ export declare const createWebhook: (config: import("../../types.js").WebinyConfig, fetchFn: typeof fetch, params: unknown) => Promise<Result<Webhook, import("../../errors.js").HttpError | ApiError | import("../../errors.js").NetworkError | import("../../errors.js").ValidationError>>;
@@ -0,0 +1,41 @@
1
+ import { Result } from "../../Result.js";
2
+ import { createMethod } from "../../utils/createMethod.js";
3
+ import { createWebhookSchema } from "./schemas.js";
4
+ import { executeGraphQL } from "../executeGraphQL.js";
5
+ import { ApiError } from "../../errors.js";
6
+ const createWebhook = createMethod(createWebhookSchema, async (config, fetchFn, params)=>{
7
+ const query = `
8
+ mutation CreateWebhook($input: CreateWebhookInput!) {
9
+ webhooks {
10
+ createWebhook(input: $input) {
11
+ data {
12
+ id
13
+ name
14
+ slug
15
+ endpointUrl
16
+ description
17
+ enabled
18
+ events
19
+ signingSecret
20
+ createdOn
21
+ modifiedOn
22
+ }
23
+ error {
24
+ message
25
+ code
26
+ }
27
+ }
28
+ }
29
+ }
30
+ `;
31
+ const result = await executeGraphQL(config, fetchFn, query, {
32
+ input: params
33
+ });
34
+ if (result.isFail()) return Result.fail(result.error);
35
+ const responseData = result.value;
36
+ if (responseData.webhooks.createWebhook.error) return Result.fail(new ApiError(responseData.webhooks.createWebhook.error.message, responseData.webhooks.createWebhook.error.code));
37
+ return Result.ok(responseData.webhooks.createWebhook.data);
38
+ });
39
+ export { createWebhook };
40
+
41
+ //# sourceMappingURL=createWebhook.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"methods/webhooks/createWebhook.js","sources":["../../../src/methods/webhooks/createWebhook.ts"],"sourcesContent":["import { Result } from \"../../Result.js\";\nimport type { Webhook } from \"./webhooksTypes.js\";\nimport { createMethod } from \"../../utils/createMethod.js\";\nimport { createWebhookSchema } from \"./schemas.js\";\nimport { executeGraphQL } from \"../executeGraphQL.js\";\nimport { ApiError } from \"../../errors.js\";\n\nexport interface CreateWebhookParams {\n name: string;\n endpointUrl: string;\n events: string[];\n slug?: string;\n description?: string;\n enabled?: boolean;\n}\n\nexport const createWebhook = createMethod(createWebhookSchema, async (config, fetchFn, params) => {\n const query = `\n mutation CreateWebhook($input: CreateWebhookInput!) {\n webhooks {\n createWebhook(input: $input) {\n data {\n id\n name\n slug\n endpointUrl\n description\n enabled\n events\n signingSecret\n createdOn\n modifiedOn\n }\n error {\n message\n code\n }\n }\n }\n }\n `;\n\n const result = await executeGraphQL(config, fetchFn, query, { input: params });\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n const responseData = result.value;\n\n if (responseData.webhooks.createWebhook.error) {\n return Result.fail(\n new ApiError(\n responseData.webhooks.createWebhook.error.message,\n responseData.webhooks.createWebhook.error.code\n )\n );\n }\n\n return Result.ok(responseData.webhooks.createWebhook.data as Webhook);\n});\n"],"names":["createWebhook","createMethod","createWebhookSchema","config","fetchFn","params","query","result","executeGraphQL","Result","responseData","ApiError"],"mappings":";;;;;AAgBO,MAAMA,gBAAgBC,aAAaC,qBAAqB,OAAOC,QAAQC,SAASC;IACnF,MAAMC,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;IAuBf,CAAC;IAED,MAAMC,SAAS,MAAMC,eAAeL,QAAQC,SAASE,OAAO;QAAE,OAAOD;IAAO;IAE5E,IAAIE,OAAO,MAAM,IACb,OAAOE,OAAO,IAAI,CAACF,OAAO,KAAK;IAGnC,MAAMG,eAAeH,OAAO,KAAK;IAEjC,IAAIG,aAAa,QAAQ,CAAC,aAAa,CAAC,KAAK,EACzC,OAAOD,OAAO,IAAI,CACd,IAAIE,SACAD,aAAa,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,OAAO,EACjDA,aAAa,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI;IAK1D,OAAOD,OAAO,EAAE,CAACC,aAAa,QAAQ,CAAC,aAAa,CAAC,IAAI;AAC7D"}
@@ -0,0 +1,6 @@
1
+ import { Result } from "../../Result.js";
2
+ import { ApiError } from "../../errors.js";
3
+ export interface DeleteWebhookParams {
4
+ id: string;
5
+ }
6
+ export declare const deleteWebhook: (config: import("../../types.js").WebinyConfig, fetchFn: typeof fetch, params: unknown) => Promise<Result<boolean, import("../../errors.js").HttpError | ApiError | import("../../errors.js").NetworkError | import("../../errors.js").ValidationError>>;
@@ -0,0 +1,30 @@
1
+ import { Result } from "../../Result.js";
2
+ import { createMethod } from "../../utils/createMethod.js";
3
+ import { deleteWebhookSchema } from "./schemas.js";
4
+ import { executeGraphQL } from "../executeGraphQL.js";
5
+ import { ApiError } from "../../errors.js";
6
+ const deleteWebhook = createMethod(deleteWebhookSchema, async (config, fetchFn, { id })=>{
7
+ const query = `
8
+ mutation DeleteWebhook($id: ID!) {
9
+ webhooks {
10
+ deleteWebhook(id: $id) {
11
+ data
12
+ error {
13
+ message
14
+ code
15
+ }
16
+ }
17
+ }
18
+ }
19
+ `;
20
+ const result = await executeGraphQL(config, fetchFn, query, {
21
+ id
22
+ });
23
+ if (result.isFail()) return Result.fail(result.error);
24
+ const responseData = result.value;
25
+ if (responseData.webhooks.deleteWebhook.error) return Result.fail(new ApiError(responseData.webhooks.deleteWebhook.error.message, responseData.webhooks.deleteWebhook.error.code));
26
+ return Result.ok(responseData.webhooks.deleteWebhook.data);
27
+ });
28
+ export { deleteWebhook };
29
+
30
+ //# sourceMappingURL=deleteWebhook.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"methods/webhooks/deleteWebhook.js","sources":["../../../src/methods/webhooks/deleteWebhook.ts"],"sourcesContent":["import { Result } from \"../../Result.js\";\nimport { createMethod } from \"../../utils/createMethod.js\";\nimport { deleteWebhookSchema } from \"./schemas.js\";\nimport { executeGraphQL } from \"../executeGraphQL.js\";\nimport { ApiError } from \"../../errors.js\";\n\nexport interface DeleteWebhookParams {\n id: string;\n}\n\nexport const deleteWebhook = createMethod(deleteWebhookSchema, async (config, fetchFn, { id }) => {\n const query = `\n mutation DeleteWebhook($id: ID!) {\n webhooks {\n deleteWebhook(id: $id) {\n data\n error {\n message\n code\n }\n }\n }\n }\n `;\n\n const result = await executeGraphQL(config, fetchFn, query, { id });\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n const responseData = result.value;\n\n if (responseData.webhooks.deleteWebhook.error) {\n return Result.fail(\n new ApiError(\n responseData.webhooks.deleteWebhook.error.message,\n responseData.webhooks.deleteWebhook.error.code\n )\n );\n }\n\n return Result.ok(responseData.webhooks.deleteWebhook.data as boolean);\n});\n"],"names":["deleteWebhook","createMethod","deleteWebhookSchema","config","fetchFn","id","query","result","executeGraphQL","Result","responseData","ApiError"],"mappings":";;;;;AAUO,MAAMA,gBAAgBC,aAAaC,qBAAqB,OAAOC,QAAQC,SAAS,EAAEC,EAAE,EAAE;IACzF,MAAMC,QAAQ,CAAC;;;;;;;;;;;;IAYf,CAAC;IAED,MAAMC,SAAS,MAAMC,eAAeL,QAAQC,SAASE,OAAO;QAAED;IAAG;IAEjE,IAAIE,OAAO,MAAM,IACb,OAAOE,OAAO,IAAI,CAACF,OAAO,KAAK;IAGnC,MAAMG,eAAeH,OAAO,KAAK;IAEjC,IAAIG,aAAa,QAAQ,CAAC,aAAa,CAAC,KAAK,EACzC,OAAOD,OAAO,IAAI,CACd,IAAIE,SACAD,aAAa,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,OAAO,EACjDA,aAAa,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI;IAK1D,OAAOD,OAAO,EAAE,CAACC,aAAa,QAAQ,CAAC,aAAa,CAAC,IAAI;AAC7D"}
@@ -0,0 +1,7 @@
1
+ import { Result } from "../../Result.js";
2
+ import type { Webhook } from "./webhooksTypes.js";
3
+ import { ApiError } from "../../errors.js";
4
+ export interface GetWebhookParams {
5
+ id: string;
6
+ }
7
+ export declare const getWebhook: (config: import("../../types.js").WebinyConfig, fetchFn: typeof fetch, params: unknown) => Promise<Result<Webhook, import("../../errors.js").HttpError | ApiError | import("../../errors.js").NetworkError | import("../../errors.js").ValidationError>>;
@@ -0,0 +1,41 @@
1
+ import { Result } from "../../Result.js";
2
+ import { createMethod } from "../../utils/createMethod.js";
3
+ import { getWebhookSchema } from "./schemas.js";
4
+ import { executeGraphQL } from "../executeGraphQL.js";
5
+ import { ApiError } from "../../errors.js";
6
+ const getWebhook = createMethod(getWebhookSchema, async (config, fetchFn, { id })=>{
7
+ const query = `
8
+ query GetWebhook($id: ID!) {
9
+ webhooks {
10
+ getWebhook(id: $id) {
11
+ data {
12
+ id
13
+ name
14
+ slug
15
+ endpointUrl
16
+ description
17
+ enabled
18
+ events
19
+ signingSecret
20
+ createdOn
21
+ modifiedOn
22
+ }
23
+ error {
24
+ message
25
+ code
26
+ }
27
+ }
28
+ }
29
+ }
30
+ `;
31
+ const result = await executeGraphQL(config, fetchFn, query, {
32
+ id
33
+ });
34
+ if (result.isFail()) return Result.fail(result.error);
35
+ const responseData = result.value;
36
+ if (responseData.webhooks.getWebhook.error) return Result.fail(new ApiError(responseData.webhooks.getWebhook.error.message, responseData.webhooks.getWebhook.error.code));
37
+ return Result.ok(responseData.webhooks.getWebhook.data);
38
+ });
39
+ export { getWebhook };
40
+
41
+ //# sourceMappingURL=getWebhook.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"methods/webhooks/getWebhook.js","sources":["../../../src/methods/webhooks/getWebhook.ts"],"sourcesContent":["import { Result } from \"../../Result.js\";\nimport type { Webhook } from \"./webhooksTypes.js\";\nimport { createMethod } from \"../../utils/createMethod.js\";\nimport { getWebhookSchema } from \"./schemas.js\";\nimport { executeGraphQL } from \"../executeGraphQL.js\";\nimport { ApiError } from \"../../errors.js\";\n\nexport interface GetWebhookParams {\n id: string;\n}\n\nexport const getWebhook = createMethod(getWebhookSchema, async (config, fetchFn, { id }) => {\n const query = `\n query GetWebhook($id: ID!) {\n webhooks {\n getWebhook(id: $id) {\n data {\n id\n name\n slug\n endpointUrl\n description\n enabled\n events\n signingSecret\n createdOn\n modifiedOn\n }\n error {\n message\n code\n }\n }\n }\n }\n `;\n\n const result = await executeGraphQL(config, fetchFn, query, { id });\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n const responseData = result.value;\n\n if (responseData.webhooks.getWebhook.error) {\n return Result.fail(\n new ApiError(\n responseData.webhooks.getWebhook.error.message,\n responseData.webhooks.getWebhook.error.code\n )\n );\n }\n\n return Result.ok(responseData.webhooks.getWebhook.data as Webhook);\n});\n"],"names":["getWebhook","createMethod","getWebhookSchema","config","fetchFn","id","query","result","executeGraphQL","Result","responseData","ApiError"],"mappings":";;;;;AAWO,MAAMA,aAAaC,aAAaC,kBAAkB,OAAOC,QAAQC,SAAS,EAAEC,EAAE,EAAE;IACnF,MAAMC,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;IAuBf,CAAC;IAED,MAAMC,SAAS,MAAMC,eAAeL,QAAQC,SAASE,OAAO;QAAED;IAAG;IAEjE,IAAIE,OAAO,MAAM,IACb,OAAOE,OAAO,IAAI,CAACF,OAAO,KAAK;IAGnC,MAAMG,eAAeH,OAAO,KAAK;IAEjC,IAAIG,aAAa,QAAQ,CAAC,UAAU,CAAC,KAAK,EACtC,OAAOD,OAAO,IAAI,CACd,IAAIE,SACAD,aAAa,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO,EAC9CA,aAAa,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI;IAKvD,OAAOD,OAAO,EAAE,CAACC,aAAa,QAAQ,CAAC,UAAU,CAAC,IAAI;AAC1D"}
@@ -0,0 +1,7 @@
1
+ import { Result } from "../../Result.js";
2
+ import type { WebhookDelivery } from "./webhooksTypes.js";
3
+ import { ApiError } from "../../errors.js";
4
+ export interface GetWebhookDeliveryParams {
5
+ id: string;
6
+ }
7
+ export declare const getWebhookDelivery: (config: import("../../types.js").WebinyConfig, fetchFn: typeof fetch, params: unknown) => Promise<Result<WebhookDelivery, import("../../errors.js").HttpError | ApiError | import("../../errors.js").NetworkError | import("../../errors.js").ValidationError>>;
@@ -0,0 +1,43 @@
1
+ import { Result } from "../../Result.js";
2
+ import { createMethod } from "../../utils/createMethod.js";
3
+ import { getWebhookDeliverySchema } from "./schemas.js";
4
+ import { executeGraphQL } from "../executeGraphQL.js";
5
+ import { ApiError } from "../../errors.js";
6
+ const getWebhookDelivery = createMethod(getWebhookDeliverySchema, async (config, fetchFn, { id })=>{
7
+ const query = `
8
+ query GetWebhookDelivery($id: ID!) {
9
+ webhooks {
10
+ getWebhookDelivery(id: $id) {
11
+ data {
12
+ id
13
+ webhookId
14
+ backgroundTaskId
15
+ eventType
16
+ status
17
+ payload
18
+ requestHeaders
19
+ responseTime
20
+ responseStatus
21
+ responseBody
22
+ expiresAt
23
+ createdOn
24
+ }
25
+ error {
26
+ message
27
+ code
28
+ }
29
+ }
30
+ }
31
+ }
32
+ `;
33
+ const result = await executeGraphQL(config, fetchFn, query, {
34
+ id
35
+ });
36
+ if (result.isFail()) return Result.fail(result.error);
37
+ const responseData = result.value;
38
+ if (responseData.webhooks.getWebhookDelivery.error) return Result.fail(new ApiError(responseData.webhooks.getWebhookDelivery.error.message, responseData.webhooks.getWebhookDelivery.error.code));
39
+ return Result.ok(responseData.webhooks.getWebhookDelivery.data);
40
+ });
41
+ export { getWebhookDelivery };
42
+
43
+ //# sourceMappingURL=getWebhookDelivery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"methods/webhooks/getWebhookDelivery.js","sources":["../../../src/methods/webhooks/getWebhookDelivery.ts"],"sourcesContent":["import { Result } from \"../../Result.js\";\nimport type { WebhookDelivery } from \"./webhooksTypes.js\";\nimport { createMethod } from \"../../utils/createMethod.js\";\nimport { getWebhookDeliverySchema } from \"./schemas.js\";\nimport { executeGraphQL } from \"../executeGraphQL.js\";\nimport { ApiError } from \"../../errors.js\";\n\nexport interface GetWebhookDeliveryParams {\n id: string;\n}\n\nexport const getWebhookDelivery = createMethod(\n getWebhookDeliverySchema,\n async (config, fetchFn, { id }) => {\n const query = `\n query GetWebhookDelivery($id: ID!) {\n webhooks {\n getWebhookDelivery(id: $id) {\n data {\n id\n webhookId\n backgroundTaskId\n eventType\n status\n payload\n requestHeaders\n responseTime\n responseStatus\n responseBody\n expiresAt\n createdOn\n }\n error {\n message\n code\n }\n }\n }\n }\n `;\n\n const result = await executeGraphQL(config, fetchFn, query, { id });\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n const responseData = result.value;\n\n if (responseData.webhooks.getWebhookDelivery.error) {\n return Result.fail(\n new ApiError(\n responseData.webhooks.getWebhookDelivery.error.message,\n responseData.webhooks.getWebhookDelivery.error.code\n )\n );\n }\n\n return Result.ok(responseData.webhooks.getWebhookDelivery.data as WebhookDelivery);\n }\n);\n"],"names":["getWebhookDelivery","createMethod","getWebhookDeliverySchema","config","fetchFn","id","query","result","executeGraphQL","Result","responseData","ApiError"],"mappings":";;;;;AAWO,MAAMA,qBAAqBC,aAC9BC,0BACA,OAAOC,QAAQC,SAAS,EAAEC,EAAE,EAAE;IAC1B,MAAMC,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;IAyBnB,CAAC;IAEG,MAAMC,SAAS,MAAMC,eAAeL,QAAQC,SAASE,OAAO;QAAED;IAAG;IAEjE,IAAIE,OAAO,MAAM,IACb,OAAOE,OAAO,IAAI,CAACF,OAAO,KAAK;IAGnC,MAAMG,eAAeH,OAAO,KAAK;IAEjC,IAAIG,aAAa,QAAQ,CAAC,kBAAkB,CAAC,KAAK,EAC9C,OAAOD,OAAO,IAAI,CACd,IAAIE,SACAD,aAAa,QAAQ,CAAC,kBAAkB,CAAC,KAAK,CAAC,OAAO,EACtDA,aAAa,QAAQ,CAAC,kBAAkB,CAAC,KAAK,CAAC,IAAI;IAK/D,OAAOD,OAAO,EAAE,CAACC,aAAa,QAAQ,CAAC,kBAAkB,CAAC,IAAI;AAClE"}
@@ -0,0 +1,7 @@
1
+ import type { WebinyConfig } from "../../types.js";
2
+ import { Result } from "../../Result.js";
3
+ import type { HttpError } from "../../errors.js";
4
+ import type { NetworkError } from "../../errors.js";
5
+ import type { WebhookEvent } from "./webhooksTypes.js";
6
+ import { ApiError } from "../../errors.js";
7
+ export declare function listAvailableWebhookEvents(config: WebinyConfig, fetchFn: typeof fetch): Promise<Result<WebhookEvent[], HttpError | ApiError | NetworkError>>;
@@ -0,0 +1,31 @@
1
+ import { Result } from "../../Result.js";
2
+ import { executeGraphQL } from "../executeGraphQL.js";
3
+ import { ApiError } from "../../errors.js";
4
+ async function listAvailableWebhookEvents(config, fetchFn) {
5
+ const query = `
6
+ query ListAvailableWebhookEvents {
7
+ webhooks {
8
+ listAvailableWebhookEvents {
9
+ data {
10
+ app
11
+ entity
12
+ eventName
13
+ label
14
+ }
15
+ error {
16
+ message
17
+ code
18
+ }
19
+ }
20
+ }
21
+ }
22
+ `;
23
+ const result = await executeGraphQL(config, fetchFn, query, {});
24
+ if (result.isFail()) return Result.fail(result.error);
25
+ const responseData = result.value;
26
+ if (responseData.webhooks.listAvailableWebhookEvents.error) return Result.fail(new ApiError(responseData.webhooks.listAvailableWebhookEvents.error.message, responseData.webhooks.listAvailableWebhookEvents.error.code));
27
+ return Result.ok(responseData.webhooks.listAvailableWebhookEvents.data);
28
+ }
29
+ export { listAvailableWebhookEvents };
30
+
31
+ //# sourceMappingURL=listAvailableWebhookEvents.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"methods/webhooks/listAvailableWebhookEvents.js","sources":["../../../src/methods/webhooks/listAvailableWebhookEvents.ts"],"sourcesContent":["import type { WebinyConfig } from \"../../types.js\";\nimport { Result } from \"../../Result.js\";\nimport type { HttpError } from \"../../errors.js\";\nimport type { NetworkError } from \"../../errors.js\";\nimport type { WebhookEvent } from \"./webhooksTypes.js\";\nimport { executeGraphQL } from \"../executeGraphQL.js\";\nimport { ApiError } from \"../../errors.js\";\n\nexport async function listAvailableWebhookEvents(\n config: WebinyConfig,\n fetchFn: typeof fetch\n): Promise<Result<WebhookEvent[], HttpError | ApiError | NetworkError>> {\n const query = `\n query ListAvailableWebhookEvents {\n webhooks {\n listAvailableWebhookEvents {\n data {\n app\n entity\n eventName\n label\n }\n error {\n message\n code\n }\n }\n }\n }\n `;\n\n const result = await executeGraphQL(config, fetchFn, query, {});\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n const responseData = result.value;\n\n if (responseData.webhooks.listAvailableWebhookEvents.error) {\n return Result.fail(\n new ApiError(\n responseData.webhooks.listAvailableWebhookEvents.error.message,\n responseData.webhooks.listAvailableWebhookEvents.error.code\n )\n );\n }\n\n return Result.ok(responseData.webhooks.listAvailableWebhookEvents.data as WebhookEvent[]);\n}\n"],"names":["listAvailableWebhookEvents","config","fetchFn","query","result","executeGraphQL","Result","responseData","ApiError"],"mappings":";;;AAQO,eAAeA,2BAClBC,MAAoB,EACpBC,OAAqB;IAErB,MAAMC,QAAQ,CAAC;;;;;;;;;;;;;;;;;IAiBf,CAAC;IAED,MAAMC,SAAS,MAAMC,eAAeJ,QAAQC,SAASC,OAAO,CAAC;IAE7D,IAAIC,OAAO,MAAM,IACb,OAAOE,OAAO,IAAI,CAACF,OAAO,KAAK;IAGnC,MAAMG,eAAeH,OAAO,KAAK;IAEjC,IAAIG,aAAa,QAAQ,CAAC,0BAA0B,CAAC,KAAK,EACtD,OAAOD,OAAO,IAAI,CACd,IAAIE,SACAD,aAAa,QAAQ,CAAC,0BAA0B,CAAC,KAAK,CAAC,OAAO,EAC9DA,aAAa,QAAQ,CAAC,0BAA0B,CAAC,KAAK,CAAC,IAAI;IAKvE,OAAOD,OAAO,EAAE,CAACC,aAAa,QAAQ,CAAC,0BAA0B,CAAC,IAAI;AAC1E"}
@@ -0,0 +1,17 @@
1
+ import { Result } from "../../Result.js";
2
+ import type { WebhookDelivery } from "./webhooksTypes.js";
3
+ import { ApiError } from "../../errors.js";
4
+ export interface ListWebhookDeliveriesParams {
5
+ webhookId: string;
6
+ limit?: number;
7
+ after?: string;
8
+ }
9
+ export interface ListWebhookDeliveriesResult {
10
+ data: WebhookDelivery[];
11
+ meta: {
12
+ cursor: string | null;
13
+ hasMoreItems: boolean;
14
+ totalCount: number;
15
+ };
16
+ }
17
+ export declare const listWebhookDeliveries: (config: import("../../types.js").WebinyConfig, fetchFn: typeof fetch, params: unknown) => Promise<Result<ListWebhookDeliveriesResult, import("../../errors.js").HttpError | ApiError | import("../../errors.js").NetworkError | import("../../errors.js").ValidationError>>;
@@ -0,0 +1,53 @@
1
+ import { Result } from "../../Result.js";
2
+ import { createMethod } from "../../utils/createMethod.js";
3
+ import { listWebhookDeliveriesSchema } from "./schemas.js";
4
+ import { executeGraphQL } from "../executeGraphQL.js";
5
+ import { ApiError } from "../../errors.js";
6
+ const listWebhookDeliveries = createMethod(listWebhookDeliveriesSchema, async (config, fetchFn, { webhookId, limit, after })=>{
7
+ const query = `
8
+ query ListWebhookDeliveries($webhookId: ID!, $limit: Int, $after: String) {
9
+ webhooks {
10
+ listWebhookDeliveries(webhookId: $webhookId, limit: $limit, after: $after) {
11
+ data {
12
+ id
13
+ webhookId
14
+ backgroundTaskId
15
+ eventType
16
+ status
17
+ payload
18
+ requestHeaders
19
+ responseTime
20
+ responseStatus
21
+ responseBody
22
+ expiresAt
23
+ createdOn
24
+ }
25
+ meta {
26
+ cursor
27
+ hasMoreItems
28
+ totalCount
29
+ }
30
+ error {
31
+ message
32
+ code
33
+ }
34
+ }
35
+ }
36
+ }
37
+ `;
38
+ const result = await executeGraphQL(config, fetchFn, query, {
39
+ webhookId,
40
+ limit,
41
+ after
42
+ });
43
+ if (result.isFail()) return Result.fail(result.error);
44
+ const responseData = result.value;
45
+ if (responseData.webhooks.listWebhookDeliveries.error) return Result.fail(new ApiError(responseData.webhooks.listWebhookDeliveries.error.message, responseData.webhooks.listWebhookDeliveries.error.code));
46
+ return Result.ok({
47
+ data: responseData.webhooks.listWebhookDeliveries.data,
48
+ meta: responseData.webhooks.listWebhookDeliveries.meta
49
+ });
50
+ });
51
+ export { listWebhookDeliveries };
52
+
53
+ //# sourceMappingURL=listWebhookDeliveries.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"methods/webhooks/listWebhookDeliveries.js","sources":["../../../src/methods/webhooks/listWebhookDeliveries.ts"],"sourcesContent":["import { Result } from \"../../Result.js\";\nimport type { WebhookDelivery } from \"./webhooksTypes.js\";\nimport { createMethod } from \"../../utils/createMethod.js\";\nimport { listWebhookDeliveriesSchema } from \"./schemas.js\";\nimport { executeGraphQL } from \"../executeGraphQL.js\";\nimport { ApiError } from \"../../errors.js\";\n\nexport interface ListWebhookDeliveriesParams {\n webhookId: string;\n limit?: number;\n after?: string;\n}\n\nexport interface ListWebhookDeliveriesResult {\n data: WebhookDelivery[];\n meta: {\n cursor: string | null;\n hasMoreItems: boolean;\n totalCount: number;\n };\n}\n\nexport const listWebhookDeliveries = createMethod(\n listWebhookDeliveriesSchema,\n async (config, fetchFn, { webhookId, limit, after }) => {\n const query = `\n query ListWebhookDeliveries($webhookId: ID!, $limit: Int, $after: String) {\n webhooks {\n listWebhookDeliveries(webhookId: $webhookId, limit: $limit, after: $after) {\n data {\n id\n webhookId\n backgroundTaskId\n eventType\n status\n payload\n requestHeaders\n responseTime\n responseStatus\n responseBody\n expiresAt\n createdOn\n }\n meta {\n cursor\n hasMoreItems\n totalCount\n }\n error {\n message\n code\n }\n }\n }\n }\n `;\n\n const result = await executeGraphQL(config, fetchFn, query, {\n webhookId,\n limit,\n after\n });\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n const responseData = result.value;\n\n if (responseData.webhooks.listWebhookDeliveries.error) {\n return Result.fail(\n new ApiError(\n responseData.webhooks.listWebhookDeliveries.error.message,\n responseData.webhooks.listWebhookDeliveries.error.code\n )\n );\n }\n\n return Result.ok({\n data: responseData.webhooks.listWebhookDeliveries.data,\n meta: responseData.webhooks.listWebhookDeliveries.meta\n } as ListWebhookDeliveriesResult);\n }\n);\n"],"names":["listWebhookDeliveries","createMethod","listWebhookDeliveriesSchema","config","fetchFn","webhookId","limit","after","query","result","executeGraphQL","Result","responseData","ApiError"],"mappings":";;;;;AAsBO,MAAMA,wBAAwBC,aACjCC,6BACA,OAAOC,QAAQC,SAAS,EAAEC,SAAS,EAAEC,KAAK,EAAEC,KAAK,EAAE;IAC/C,MAAMC,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA8BnB,CAAC;IAEG,MAAMC,SAAS,MAAMC,eAAeP,QAAQC,SAASI,OAAO;QACxDH;QACAC;QACAC;IACJ;IAEA,IAAIE,OAAO,MAAM,IACb,OAAOE,OAAO,IAAI,CAACF,OAAO,KAAK;IAGnC,MAAMG,eAAeH,OAAO,KAAK;IAEjC,IAAIG,aAAa,QAAQ,CAAC,qBAAqB,CAAC,KAAK,EACjD,OAAOD,OAAO,IAAI,CACd,IAAIE,SACAD,aAAa,QAAQ,CAAC,qBAAqB,CAAC,KAAK,CAAC,OAAO,EACzDA,aAAa,QAAQ,CAAC,qBAAqB,CAAC,KAAK,CAAC,IAAI;IAKlE,OAAOD,OAAO,EAAE,CAAC;QACb,MAAMC,aAAa,QAAQ,CAAC,qBAAqB,CAAC,IAAI;QACtD,MAAMA,aAAa,QAAQ,CAAC,qBAAqB,CAAC,IAAI;IAC1D;AACJ"}
@@ -0,0 +1,19 @@
1
+ import { Result } from "../../Result.js";
2
+ import type { Webhook } from "./webhooksTypes.js";
3
+ import { ApiError } from "../../errors.js";
4
+ export interface ListWebhooksParams {
5
+ where?: {
6
+ enabled?: boolean;
7
+ };
8
+ limit?: number;
9
+ after?: string;
10
+ }
11
+ export interface ListWebhooksResult {
12
+ data: Webhook[];
13
+ meta: {
14
+ cursor: string | null;
15
+ hasMoreItems: boolean;
16
+ totalCount: number;
17
+ };
18
+ }
19
+ export declare const listWebhooks: (config: import("../../types.js").WebinyConfig, fetchFn: typeof fetch, params: unknown) => Promise<Result<ListWebhooksResult, import("../../errors.js").HttpError | ApiError | import("../../errors.js").NetworkError | import("../../errors.js").ValidationError>>;
@@ -0,0 +1,51 @@
1
+ import { Result } from "../../Result.js";
2
+ import { createMethod } from "../../utils/createMethod.js";
3
+ import { listWebhooksSchema } from "./schemas.js";
4
+ import { executeGraphQL } from "../executeGraphQL.js";
5
+ import { ApiError } from "../../errors.js";
6
+ const listWebhooks = createMethod(listWebhooksSchema, async (config, fetchFn, { where, limit, after })=>{
7
+ const query = `
8
+ query ListWebhooks($where: ListWebhooksWhereInput, $limit: Int, $after: String) {
9
+ webhooks {
10
+ listWebhooks(where: $where, limit: $limit, after: $after) {
11
+ data {
12
+ id
13
+ name
14
+ slug
15
+ endpointUrl
16
+ description
17
+ enabled
18
+ events
19
+ signingSecret
20
+ createdOn
21
+ modifiedOn
22
+ }
23
+ meta {
24
+ cursor
25
+ hasMoreItems
26
+ totalCount
27
+ }
28
+ error {
29
+ message
30
+ code
31
+ }
32
+ }
33
+ }
34
+ }
35
+ `;
36
+ const result = await executeGraphQL(config, fetchFn, query, {
37
+ where,
38
+ limit,
39
+ after
40
+ });
41
+ if (result.isFail()) return Result.fail(result.error);
42
+ const responseData = result.value;
43
+ if (responseData.webhooks.listWebhooks.error) return Result.fail(new ApiError(responseData.webhooks.listWebhooks.error.message, responseData.webhooks.listWebhooks.error.code));
44
+ return Result.ok({
45
+ data: responseData.webhooks.listWebhooks.data,
46
+ meta: responseData.webhooks.listWebhooks.meta
47
+ });
48
+ });
49
+ export { listWebhooks };
50
+
51
+ //# sourceMappingURL=listWebhooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"methods/webhooks/listWebhooks.js","sources":["../../../src/methods/webhooks/listWebhooks.ts"],"sourcesContent":["import { Result } from \"../../Result.js\";\nimport type { Webhook } from \"./webhooksTypes.js\";\nimport { createMethod } from \"../../utils/createMethod.js\";\nimport { listWebhooksSchema } from \"./schemas.js\";\nimport { executeGraphQL } from \"../executeGraphQL.js\";\nimport { ApiError } from \"../../errors.js\";\n\nexport interface ListWebhooksParams {\n where?: {\n enabled?: boolean;\n };\n limit?: number;\n after?: string;\n}\n\nexport interface ListWebhooksResult {\n data: Webhook[];\n meta: {\n cursor: string | null;\n hasMoreItems: boolean;\n totalCount: number;\n };\n}\n\nexport const listWebhooks = createMethod(\n listWebhooksSchema,\n async (config, fetchFn, { where, limit, after }) => {\n const query = `\n query ListWebhooks($where: ListWebhooksWhereInput, $limit: Int, $after: String) {\n webhooks {\n listWebhooks(where: $where, limit: $limit, after: $after) {\n data {\n id\n name\n slug\n endpointUrl\n description\n enabled\n events\n signingSecret\n createdOn\n modifiedOn\n }\n meta {\n cursor\n hasMoreItems\n totalCount\n }\n error {\n message\n code\n }\n }\n }\n }\n `;\n\n const result = await executeGraphQL(config, fetchFn, query, { where, limit, after });\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n const responseData = result.value;\n\n if (responseData.webhooks.listWebhooks.error) {\n return Result.fail(\n new ApiError(\n responseData.webhooks.listWebhooks.error.message,\n responseData.webhooks.listWebhooks.error.code\n )\n );\n }\n\n return Result.ok({\n data: responseData.webhooks.listWebhooks.data,\n meta: responseData.webhooks.listWebhooks.meta\n } as ListWebhooksResult);\n }\n);\n"],"names":["listWebhooks","createMethod","listWebhooksSchema","config","fetchFn","where","limit","after","query","result","executeGraphQL","Result","responseData","ApiError"],"mappings":";;;;;AAwBO,MAAMA,eAAeC,aACxBC,oBACA,OAAOC,QAAQC,SAAS,EAAEC,KAAK,EAAEC,KAAK,EAAEC,KAAK,EAAE;IAC3C,MAAMC,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA4BnB,CAAC;IAEG,MAAMC,SAAS,MAAMC,eAAeP,QAAQC,SAASI,OAAO;QAAEH;QAAOC;QAAOC;IAAM;IAElF,IAAIE,OAAO,MAAM,IACb,OAAOE,OAAO,IAAI,CAACF,OAAO,KAAK;IAGnC,MAAMG,eAAeH,OAAO,KAAK;IAEjC,IAAIG,aAAa,QAAQ,CAAC,YAAY,CAAC,KAAK,EACxC,OAAOD,OAAO,IAAI,CACd,IAAIE,SACAD,aAAa,QAAQ,CAAC,YAAY,CAAC,KAAK,CAAC,OAAO,EAChDA,aAAa,QAAQ,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI;IAKzD,OAAOD,OAAO,EAAE,CAAC;QACb,MAAMC,aAAa,QAAQ,CAAC,YAAY,CAAC,IAAI;QAC7C,MAAMA,aAAa,QAAQ,CAAC,YAAY,CAAC,IAAI;IACjD;AACJ"}
@@ -0,0 +1,6 @@
1
+ import { Result } from "../../Result.js";
2
+ import { ApiError } from "../../errors.js";
3
+ export interface ResendWebhookDeliveryParams {
4
+ id: string;
5
+ }
6
+ export declare const resendWebhookDelivery: (config: import("../../types.js").WebinyConfig, fetchFn: typeof fetch, params: unknown) => Promise<Result<boolean, import("../../errors.js").HttpError | ApiError | import("../../errors.js").NetworkError | import("../../errors.js").ValidationError>>;
@@ -0,0 +1,30 @@
1
+ import { Result } from "../../Result.js";
2
+ import { createMethod } from "../../utils/createMethod.js";
3
+ import { resendWebhookDeliverySchema } from "./schemas.js";
4
+ import { executeGraphQL } from "../executeGraphQL.js";
5
+ import { ApiError } from "../../errors.js";
6
+ const resendWebhookDelivery = createMethod(resendWebhookDeliverySchema, async (config, fetchFn, { id })=>{
7
+ const query = `
8
+ mutation ResendWebhookDelivery($id: ID!) {
9
+ webhooks {
10
+ resendWebhookDelivery(id: $id) {
11
+ data
12
+ error {
13
+ message
14
+ code
15
+ }
16
+ }
17
+ }
18
+ }
19
+ `;
20
+ const result = await executeGraphQL(config, fetchFn, query, {
21
+ id
22
+ });
23
+ if (result.isFail()) return Result.fail(result.error);
24
+ const responseData = result.value;
25
+ if (responseData.webhooks.resendWebhookDelivery.error) return Result.fail(new ApiError(responseData.webhooks.resendWebhookDelivery.error.message, responseData.webhooks.resendWebhookDelivery.error.code));
26
+ return Result.ok(responseData.webhooks.resendWebhookDelivery.data);
27
+ });
28
+ export { resendWebhookDelivery };
29
+
30
+ //# sourceMappingURL=resendWebhookDelivery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"methods/webhooks/resendWebhookDelivery.js","sources":["../../../src/methods/webhooks/resendWebhookDelivery.ts"],"sourcesContent":["import { Result } from \"../../Result.js\";\nimport { createMethod } from \"../../utils/createMethod.js\";\nimport { resendWebhookDeliverySchema } from \"./schemas.js\";\nimport { executeGraphQL } from \"../executeGraphQL.js\";\nimport { ApiError } from \"../../errors.js\";\n\nexport interface ResendWebhookDeliveryParams {\n id: string;\n}\n\nexport const resendWebhookDelivery = createMethod(\n resendWebhookDeliverySchema,\n async (config, fetchFn, { id }) => {\n const query = `\n mutation ResendWebhookDelivery($id: ID!) {\n webhooks {\n resendWebhookDelivery(id: $id) {\n data\n error {\n message\n code\n }\n }\n }\n }\n `;\n\n const result = await executeGraphQL(config, fetchFn, query, { id });\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n const responseData = result.value;\n\n if (responseData.webhooks.resendWebhookDelivery.error) {\n return Result.fail(\n new ApiError(\n responseData.webhooks.resendWebhookDelivery.error.message,\n responseData.webhooks.resendWebhookDelivery.error.code\n )\n );\n }\n\n return Result.ok(responseData.webhooks.resendWebhookDelivery.data as boolean);\n }\n);\n"],"names":["resendWebhookDelivery","createMethod","resendWebhookDeliverySchema","config","fetchFn","id","query","result","executeGraphQL","Result","responseData","ApiError"],"mappings":";;;;;AAUO,MAAMA,wBAAwBC,aACjCC,6BACA,OAAOC,QAAQC,SAAS,EAAEC,EAAE,EAAE;IAC1B,MAAMC,QAAQ,CAAC;;;;;;;;;;;;IAYnB,CAAC;IAEG,MAAMC,SAAS,MAAMC,eAAeL,QAAQC,SAASE,OAAO;QAAED;IAAG;IAEjE,IAAIE,OAAO,MAAM,IACb,OAAOE,OAAO,IAAI,CAACF,OAAO,KAAK;IAGnC,MAAMG,eAAeH,OAAO,KAAK;IAEjC,IAAIG,aAAa,QAAQ,CAAC,qBAAqB,CAAC,KAAK,EACjD,OAAOD,OAAO,IAAI,CACd,IAAIE,SACAD,aAAa,QAAQ,CAAC,qBAAqB,CAAC,KAAK,CAAC,OAAO,EACzDA,aAAa,QAAQ,CAAC,qBAAqB,CAAC,KAAK,CAAC,IAAI;IAKlE,OAAOD,OAAO,EAAE,CAACC,aAAa,QAAQ,CAAC,qBAAqB,CAAC,IAAI;AACrE"}
@@ -0,0 +1,46 @@
1
+ import { z } from "zod";
2
+ export declare const getWebhookSchema: z.ZodObject<{
3
+ id: z.ZodString;
4
+ }, z.core.$strip>;
5
+ export declare const listWebhooksSchema: z.ZodObject<{
6
+ where: z.ZodOptional<z.ZodObject<{
7
+ enabled: z.ZodOptional<z.ZodBoolean>;
8
+ }, z.core.$strip>>;
9
+ limit: z.ZodOptional<z.ZodNumber>;
10
+ after: z.ZodOptional<z.ZodString>;
11
+ }, z.core.$strip>;
12
+ export declare const createWebhookSchema: z.ZodObject<{
13
+ name: z.ZodString;
14
+ endpointUrl: z.ZodString;
15
+ events: z.ZodArray<z.ZodString>;
16
+ slug: z.ZodOptional<z.ZodString>;
17
+ description: z.ZodOptional<z.ZodString>;
18
+ enabled: z.ZodOptional<z.ZodBoolean>;
19
+ }, z.core.$strip>;
20
+ export declare const updateWebhookSchema: z.ZodObject<{
21
+ id: z.ZodString;
22
+ name: z.ZodOptional<z.ZodString>;
23
+ slug: z.ZodOptional<z.ZodString>;
24
+ endpointUrl: z.ZodOptional<z.ZodString>;
25
+ description: z.ZodOptional<z.ZodString>;
26
+ enabled: z.ZodOptional<z.ZodBoolean>;
27
+ events: z.ZodOptional<z.ZodArray<z.ZodString>>;
28
+ }, z.core.$strip>;
29
+ export declare const deleteWebhookSchema: z.ZodObject<{
30
+ id: z.ZodString;
31
+ }, z.core.$strip>;
32
+ export declare const getWebhookDeliverySchema: z.ZodObject<{
33
+ id: z.ZodString;
34
+ }, z.core.$strip>;
35
+ export declare const listWebhookDeliveriesSchema: z.ZodObject<{
36
+ webhookId: z.ZodString;
37
+ limit: z.ZodOptional<z.ZodNumber>;
38
+ after: z.ZodOptional<z.ZodString>;
39
+ }, z.core.$strip>;
40
+ export declare const resendWebhookDeliverySchema: z.ZodObject<{
41
+ id: z.ZodString;
42
+ }, z.core.$strip>;
43
+ export declare const triggerWebhookSchema: z.ZodObject<{
44
+ id: z.ZodString;
45
+ payload: z.ZodRecord<z.ZodString, z.ZodUnknown>;
46
+ }, z.core.$strip>;
@@ -0,0 +1,50 @@
1
+ import { z } from "zod";
2
+ const id = z.string().min(1, "id is required");
3
+ const getWebhookSchema = z.object({
4
+ id: id
5
+ });
6
+ const listWebhooksSchema = z.object({
7
+ where: z.object({
8
+ enabled: z.boolean().optional()
9
+ }).optional(),
10
+ limit: z.number().int().positive().optional(),
11
+ after: z.string().optional()
12
+ });
13
+ const createWebhookSchema = z.object({
14
+ name: z.string().min(1, "name is required"),
15
+ endpointUrl: z.string().url("endpointUrl must be a valid URL"),
16
+ events: z.array(z.string().min(1)).min(1, "events must contain at least one entry"),
17
+ slug: z.string().optional(),
18
+ description: z.string().optional(),
19
+ enabled: z.boolean().optional()
20
+ });
21
+ const updateWebhookSchema = z.object({
22
+ id: id,
23
+ name: z.string().min(1).optional(),
24
+ slug: z.string().optional(),
25
+ endpointUrl: z.string().url("endpointUrl must be a valid URL").optional(),
26
+ description: z.string().optional(),
27
+ enabled: z.boolean().optional(),
28
+ events: z.array(z.string().min(1)).optional()
29
+ });
30
+ const deleteWebhookSchema = z.object({
31
+ id: id
32
+ });
33
+ const getWebhookDeliverySchema = z.object({
34
+ id: id
35
+ });
36
+ const listWebhookDeliveriesSchema = z.object({
37
+ webhookId: z.string().min(1, "webhookId is required"),
38
+ limit: z.number().int().positive().optional(),
39
+ after: z.string().optional()
40
+ });
41
+ const resendWebhookDeliverySchema = z.object({
42
+ id: id
43
+ });
44
+ const triggerWebhookSchema = z.object({
45
+ id: id,
46
+ payload: z.record(z.string(), z.unknown())
47
+ });
48
+ export { createWebhookSchema, deleteWebhookSchema, getWebhookDeliverySchema, getWebhookSchema, listWebhookDeliveriesSchema, listWebhooksSchema, resendWebhookDeliverySchema, triggerWebhookSchema, updateWebhookSchema };
49
+
50
+ //# sourceMappingURL=schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"methods/webhooks/schemas.js","sources":["../../../src/methods/webhooks/schemas.ts"],"sourcesContent":["import { z } from \"zod\";\n\nconst id = z.string().min(1, \"id is required\");\n\nexport const getWebhookSchema = z.object({\n id\n});\n\nexport const listWebhooksSchema = z.object({\n where: z\n .object({\n enabled: z.boolean().optional()\n })\n .optional(),\n limit: z.number().int().positive().optional(),\n after: z.string().optional()\n});\n\nexport const createWebhookSchema = z.object({\n name: z.string().min(1, \"name is required\"),\n endpointUrl: z.string().url(\"endpointUrl must be a valid URL\"),\n events: z.array(z.string().min(1)).min(1, \"events must contain at least one entry\"),\n slug: z.string().optional(),\n description: z.string().optional(),\n enabled: z.boolean().optional()\n});\n\nexport const updateWebhookSchema = z.object({\n id,\n name: z.string().min(1).optional(),\n slug: z.string().optional(),\n endpointUrl: z.string().url(\"endpointUrl must be a valid URL\").optional(),\n description: z.string().optional(),\n enabled: z.boolean().optional(),\n events: z.array(z.string().min(1)).optional()\n});\n\nexport const deleteWebhookSchema = z.object({\n id\n});\n\nexport const getWebhookDeliverySchema = z.object({\n id\n});\n\nexport const listWebhookDeliveriesSchema = z.object({\n webhookId: z.string().min(1, \"webhookId is required\"),\n limit: z.number().int().positive().optional(),\n after: z.string().optional()\n});\n\nexport const resendWebhookDeliverySchema = z.object({\n id\n});\n\nexport const triggerWebhookSchema = z.object({\n id,\n payload: z.record(z.string(), z.unknown())\n});\n"],"names":["id","z","getWebhookSchema","listWebhooksSchema","createWebhookSchema","updateWebhookSchema","deleteWebhookSchema","getWebhookDeliverySchema","listWebhookDeliveriesSchema","resendWebhookDeliverySchema","triggerWebhookSchema"],"mappings":";AAEA,MAAMA,KAAKC,EAAE,MAAM,GAAG,GAAG,CAAC,GAAG;AAEtB,MAAMC,mBAAmBD,EAAE,MAAM,CAAC;IACrCD,IAAAA;AACJ;AAEO,MAAMG,qBAAqBF,EAAE,MAAM,CAAC;IACvC,OAAOA,EAAAA,MACI,CAAC;QACJ,SAASA,EAAE,OAAO,GAAG,QAAQ;IACjC,GACC,QAAQ;IACb,OAAOA,EAAE,MAAM,GAAG,GAAG,GAAG,QAAQ,GAAG,QAAQ;IAC3C,OAAOA,EAAE,MAAM,GAAG,QAAQ;AAC9B;AAEO,MAAMG,sBAAsBH,EAAE,MAAM,CAAC;IACxC,MAAMA,EAAE,MAAM,GAAG,GAAG,CAAC,GAAG;IACxB,aAAaA,EAAE,MAAM,GAAG,GAAG,CAAC;IAC5B,QAAQA,EAAE,KAAK,CAACA,EAAE,MAAM,GAAG,GAAG,CAAC,IAAI,GAAG,CAAC,GAAG;IAC1C,MAAMA,EAAE,MAAM,GAAG,QAAQ;IACzB,aAAaA,EAAE,MAAM,GAAG,QAAQ;IAChC,SAASA,EAAE,OAAO,GAAG,QAAQ;AACjC;AAEO,MAAMI,sBAAsBJ,EAAE,MAAM,CAAC;IACxCD,IAAAA;IACA,MAAMC,EAAE,MAAM,GAAG,GAAG,CAAC,GAAG,QAAQ;IAChC,MAAMA,EAAE,MAAM,GAAG,QAAQ;IACzB,aAAaA,EAAE,MAAM,GAAG,GAAG,CAAC,mCAAmC,QAAQ;IACvE,aAAaA,EAAE,MAAM,GAAG,QAAQ;IAChC,SAASA,EAAE,OAAO,GAAG,QAAQ;IAC7B,QAAQA,EAAE,KAAK,CAACA,EAAE,MAAM,GAAG,GAAG,CAAC,IAAI,QAAQ;AAC/C;AAEO,MAAMK,sBAAsBL,EAAE,MAAM,CAAC;IACxCD,IAAAA;AACJ;AAEO,MAAMO,2BAA2BN,EAAE,MAAM,CAAC;IAC7CD,IAAAA;AACJ;AAEO,MAAMQ,8BAA8BP,EAAE,MAAM,CAAC;IAChD,WAAWA,EAAE,MAAM,GAAG,GAAG,CAAC,GAAG;IAC7B,OAAOA,EAAE,MAAM,GAAG,GAAG,GAAG,QAAQ,GAAG,QAAQ;IAC3C,OAAOA,EAAE,MAAM,GAAG,QAAQ;AAC9B;AAEO,MAAMQ,8BAA8BR,EAAE,MAAM,CAAC;IAChDD,IAAAA;AACJ;AAEO,MAAMU,uBAAuBT,EAAE,MAAM,CAAC;IACzCD,IAAAA;IACA,SAASC,EAAE,MAAM,CAACA,EAAE,MAAM,IAAIA,EAAE,OAAO;AAC3C"}
@@ -0,0 +1,8 @@
1
+ import { Result } from "../../Result.js";
2
+ import type { WebhookDelivery } from "./webhooksTypes.js";
3
+ import { ApiError } from "../../errors.js";
4
+ export interface TriggerWebhookParams {
5
+ id: string;
6
+ payload: Record<string, unknown>;
7
+ }
8
+ export declare const triggerWebhook: (config: import("../../types.js").WebinyConfig, fetchFn: typeof fetch, params: unknown) => Promise<Result<WebhookDelivery, import("../../errors.js").HttpError | ApiError | import("../../errors.js").NetworkError | import("../../errors.js").ValidationError>>;
@@ -0,0 +1,44 @@
1
+ import { Result } from "../../Result.js";
2
+ import { createMethod } from "../../utils/createMethod.js";
3
+ import { triggerWebhookSchema } from "./schemas.js";
4
+ import { executeGraphQL } from "../executeGraphQL.js";
5
+ import { ApiError } from "../../errors.js";
6
+ const triggerWebhook = createMethod(triggerWebhookSchema, async (config, fetchFn, { id, payload })=>{
7
+ const query = `
8
+ mutation TriggerWebhook($id: ID!, $payload: JSON!) {
9
+ webhooks {
10
+ triggerWebhook(id: $id, payload: $payload) {
11
+ data {
12
+ id
13
+ webhookId
14
+ backgroundTaskId
15
+ eventType
16
+ status
17
+ payload
18
+ requestHeaders
19
+ responseTime
20
+ responseStatus
21
+ responseBody
22
+ expiresAt
23
+ createdOn
24
+ }
25
+ error {
26
+ message
27
+ code
28
+ }
29
+ }
30
+ }
31
+ }
32
+ `;
33
+ const result = await executeGraphQL(config, fetchFn, query, {
34
+ id,
35
+ payload
36
+ });
37
+ if (result.isFail()) return Result.fail(result.error);
38
+ const responseData = result.value;
39
+ if (responseData.webhooks.triggerWebhook.error) return Result.fail(new ApiError(responseData.webhooks.triggerWebhook.error.message, responseData.webhooks.triggerWebhook.error.code));
40
+ return Result.ok(responseData.webhooks.triggerWebhook.data);
41
+ });
42
+ export { triggerWebhook };
43
+
44
+ //# sourceMappingURL=triggerWebhook.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"methods/webhooks/triggerWebhook.js","sources":["../../../src/methods/webhooks/triggerWebhook.ts"],"sourcesContent":["import { Result } from \"../../Result.js\";\nimport type { WebhookDelivery } from \"./webhooksTypes.js\";\nimport { createMethod } from \"../../utils/createMethod.js\";\nimport { triggerWebhookSchema } from \"./schemas.js\";\nimport { executeGraphQL } from \"../executeGraphQL.js\";\nimport { ApiError } from \"../../errors.js\";\n\nexport interface TriggerWebhookParams {\n id: string;\n payload: Record<string, unknown>;\n}\n\nexport const triggerWebhook = createMethod(\n triggerWebhookSchema,\n async (config, fetchFn, { id, payload }) => {\n const query = `\n mutation TriggerWebhook($id: ID!, $payload: JSON!) {\n webhooks {\n triggerWebhook(id: $id, payload: $payload) {\n data {\n id\n webhookId\n backgroundTaskId\n eventType\n status\n payload\n requestHeaders\n responseTime\n responseStatus\n responseBody\n expiresAt\n createdOn\n }\n error {\n message\n code\n }\n }\n }\n }\n `;\n\n const result = await executeGraphQL(config, fetchFn, query, { id, payload });\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n const responseData = result.value;\n\n if (responseData.webhooks.triggerWebhook.error) {\n return Result.fail(\n new ApiError(\n responseData.webhooks.triggerWebhook.error.message,\n responseData.webhooks.triggerWebhook.error.code\n )\n );\n }\n\n return Result.ok(responseData.webhooks.triggerWebhook.data as WebhookDelivery);\n }\n);\n"],"names":["triggerWebhook","createMethod","triggerWebhookSchema","config","fetchFn","id","payload","query","result","executeGraphQL","Result","responseData","ApiError"],"mappings":";;;;;AAYO,MAAMA,iBAAiBC,aAC1BC,sBACA,OAAOC,QAAQC,SAAS,EAAEC,EAAE,EAAEC,OAAO,EAAE;IACnC,MAAMC,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;IAyBnB,CAAC;IAEG,MAAMC,SAAS,MAAMC,eAAeN,QAAQC,SAASG,OAAO;QAAEF;QAAIC;IAAQ;IAE1E,IAAIE,OAAO,MAAM,IACb,OAAOE,OAAO,IAAI,CAACF,OAAO,KAAK;IAGnC,MAAMG,eAAeH,OAAO,KAAK;IAEjC,IAAIG,aAAa,QAAQ,CAAC,cAAc,CAAC,KAAK,EAC1C,OAAOD,OAAO,IAAI,CACd,IAAIE,SACAD,aAAa,QAAQ,CAAC,cAAc,CAAC,KAAK,CAAC,OAAO,EAClDA,aAAa,QAAQ,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI;IAK3D,OAAOD,OAAO,EAAE,CAACC,aAAa,QAAQ,CAAC,cAAc,CAAC,IAAI;AAC9D"}
@@ -0,0 +1,13 @@
1
+ import { Result } from "../../Result.js";
2
+ import type { Webhook } from "./webhooksTypes.js";
3
+ import { ApiError } from "../../errors.js";
4
+ export interface UpdateWebhookParams {
5
+ id: string;
6
+ name?: string;
7
+ slug?: string;
8
+ endpointUrl?: string;
9
+ description?: string;
10
+ enabled?: boolean;
11
+ events?: string[];
12
+ }
13
+ export declare const updateWebhook: (config: import("../../types.js").WebinyConfig, fetchFn: typeof fetch, params: unknown) => Promise<Result<Webhook, import("../../errors.js").HttpError | ApiError | import("../../errors.js").NetworkError | import("../../errors.js").ValidationError>>;
@@ -0,0 +1,42 @@
1
+ import { Result } from "../../Result.js";
2
+ import { createMethod } from "../../utils/createMethod.js";
3
+ import { updateWebhookSchema } from "./schemas.js";
4
+ import { executeGraphQL } from "../executeGraphQL.js";
5
+ import { ApiError } from "../../errors.js";
6
+ const updateWebhook = createMethod(updateWebhookSchema, async (config, fetchFn, { id, ...input })=>{
7
+ const query = `
8
+ mutation UpdateWebhook($id: ID!, $input: UpdateWebhookInput!) {
9
+ webhooks {
10
+ updateWebhook(id: $id, input: $input) {
11
+ data {
12
+ id
13
+ name
14
+ slug
15
+ endpointUrl
16
+ description
17
+ enabled
18
+ events
19
+ signingSecret
20
+ createdOn
21
+ modifiedOn
22
+ }
23
+ error {
24
+ message
25
+ code
26
+ }
27
+ }
28
+ }
29
+ }
30
+ `;
31
+ const result = await executeGraphQL(config, fetchFn, query, {
32
+ id,
33
+ input
34
+ });
35
+ if (result.isFail()) return Result.fail(result.error);
36
+ const responseData = result.value;
37
+ if (responseData.webhooks.updateWebhook.error) return Result.fail(new ApiError(responseData.webhooks.updateWebhook.error.message, responseData.webhooks.updateWebhook.error.code));
38
+ return Result.ok(responseData.webhooks.updateWebhook.data);
39
+ });
40
+ export { updateWebhook };
41
+
42
+ //# sourceMappingURL=updateWebhook.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"methods/webhooks/updateWebhook.js","sources":["../../../src/methods/webhooks/updateWebhook.ts"],"sourcesContent":["import { Result } from \"../../Result.js\";\nimport type { Webhook } from \"./webhooksTypes.js\";\nimport { createMethod } from \"../../utils/createMethod.js\";\nimport { updateWebhookSchema } from \"./schemas.js\";\nimport { executeGraphQL } from \"../executeGraphQL.js\";\nimport { ApiError } from \"../../errors.js\";\n\nexport interface UpdateWebhookParams {\n id: string;\n name?: string;\n slug?: string;\n endpointUrl?: string;\n description?: string;\n enabled?: boolean;\n events?: string[];\n}\n\nexport const updateWebhook = createMethod(\n updateWebhookSchema,\n async (config, fetchFn, { id, ...input }) => {\n const query = `\n mutation UpdateWebhook($id: ID!, $input: UpdateWebhookInput!) {\n webhooks {\n updateWebhook(id: $id, input: $input) {\n data {\n id\n name\n slug\n endpointUrl\n description\n enabled\n events\n signingSecret\n createdOn\n modifiedOn\n }\n error {\n message\n code\n }\n }\n }\n }\n `;\n\n const result = await executeGraphQL(config, fetchFn, query, { id, input });\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n const responseData = result.value;\n\n if (responseData.webhooks.updateWebhook.error) {\n return Result.fail(\n new ApiError(\n responseData.webhooks.updateWebhook.error.message,\n responseData.webhooks.updateWebhook.error.code\n )\n );\n }\n\n return Result.ok(responseData.webhooks.updateWebhook.data as Webhook);\n }\n);\n"],"names":["updateWebhook","createMethod","updateWebhookSchema","config","fetchFn","id","input","query","result","executeGraphQL","Result","responseData","ApiError"],"mappings":";;;;;AAiBO,MAAMA,gBAAgBC,aACzBC,qBACA,OAAOC,QAAQC,SAAS,EAAEC,EAAE,EAAE,GAAGC,OAAO;IACpC,MAAMC,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;IAuBnB,CAAC;IAEG,MAAMC,SAAS,MAAMC,eAAeN,QAAQC,SAASG,OAAO;QAAEF;QAAIC;IAAM;IAExE,IAAIE,OAAO,MAAM,IACb,OAAOE,OAAO,IAAI,CAACF,OAAO,KAAK;IAGnC,MAAMG,eAAeH,OAAO,KAAK;IAEjC,IAAIG,aAAa,QAAQ,CAAC,aAAa,CAAC,KAAK,EACzC,OAAOD,OAAO,IAAI,CACd,IAAIE,SACAD,aAAa,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,OAAO,EACjDA,aAAa,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI;IAK1D,OAAOD,OAAO,EAAE,CAACC,aAAa,QAAQ,CAAC,aAAa,CAAC,IAAI;AAC7D"}
@@ -0,0 +1,32 @@
1
+ export interface Webhook {
2
+ id: string;
3
+ name: string;
4
+ slug: string;
5
+ endpointUrl: string;
6
+ description: string | null;
7
+ enabled: boolean;
8
+ events: string[];
9
+ signingSecret: string;
10
+ createdOn: string | null;
11
+ modifiedOn: string | null;
12
+ }
13
+ export interface WebhookDelivery {
14
+ id: string;
15
+ webhookId: string;
16
+ backgroundTaskId: string | null;
17
+ eventType: string;
18
+ status: string;
19
+ payload: unknown;
20
+ requestHeaders: unknown;
21
+ responseTime: number | null;
22
+ responseStatus: number | null;
23
+ responseBody: string | null;
24
+ expiresAt: string | null;
25
+ createdOn: string | null;
26
+ }
27
+ export interface WebhookEvent {
28
+ app: string;
29
+ entity: string;
30
+ eventName: string;
31
+ label: string;
32
+ }
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/sdk",
3
- "version": "6.4.0-beta.0",
3
+ "version": "6.4.0-beta.2",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -17,7 +17,7 @@
17
17
  "author": "Webiny",
18
18
  "license": "MIT",
19
19
  "devDependencies": {
20
- "@webiny/build-tools": "6.4.0-beta.0",
20
+ "@webiny/build-tools": "6.4.0-beta.2",
21
21
  "typescript": "6.0.3",
22
22
  "vitest": "4.1.6"
23
23
  },
@@ -25,5 +25,5 @@
25
25
  "access": "public",
26
26
  "directory": "dist"
27
27
  },
28
- "gitHead": "a545d7529828af07d08d49c3da1bcb967483b9ce"
28
+ "gitHead": "872f9f50baa1ff6915a5f338216f84bf0b6dfd24"
29
29
  }