@01.software/sdk 0.3.0 → 0.4.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.
Files changed (50) hide show
  1. package/README.md +5 -2
  2. package/dist/auth.d.cts +1 -1
  3. package/dist/auth.d.ts +1 -1
  4. package/dist/const-BpirbGBD.d.cts +19 -0
  5. package/dist/const-qZSQiSSC.d.ts +19 -0
  6. package/dist/index.cjs +228 -78
  7. package/dist/index.cjs.map +1 -1
  8. package/dist/index.d.cts +114 -196
  9. package/dist/index.d.ts +114 -196
  10. package/dist/index.js +228 -78
  11. package/dist/index.js.map +1 -1
  12. package/dist/{payload-types-ggU6BNuH.d.cts → payload-types-CZiaL4Wr.d.cts} +6 -5
  13. package/dist/{payload-types-ggU6BNuH.d.ts → payload-types-CZiaL4Wr.d.ts} +6 -5
  14. package/dist/realtime-DupPIYx-.d.cts +33 -0
  15. package/dist/realtime-DupPIYx-.d.ts +33 -0
  16. package/dist/realtime.cjs +261 -0
  17. package/dist/realtime.cjs.map +1 -0
  18. package/dist/realtime.d.cts +38 -0
  19. package/dist/realtime.d.ts +38 -0
  20. package/dist/realtime.js +239 -0
  21. package/dist/realtime.js.map +1 -0
  22. package/dist/ui/code-block.cjs +3 -1
  23. package/dist/ui/code-block.cjs.map +1 -1
  24. package/dist/ui/code-block.js +4 -2
  25. package/dist/ui/code-block.js.map +1 -1
  26. package/dist/ui/flow.cjs +18 -3
  27. package/dist/ui/flow.cjs.map +1 -1
  28. package/dist/ui/flow.js +18 -3
  29. package/dist/ui/flow.js.map +1 -1
  30. package/dist/ui/form.d.cts +1 -1
  31. package/dist/ui/form.d.ts +1 -1
  32. package/dist/ui/video.cjs +219 -0
  33. package/dist/ui/video.cjs.map +1 -0
  34. package/dist/ui/video.d.cts +96 -0
  35. package/dist/ui/video.d.ts +96 -0
  36. package/dist/ui/video.js +191 -0
  37. package/dist/ui/video.js.map +1 -0
  38. package/dist/video-DbLL8yuc.d.cts +85 -0
  39. package/dist/video-DbLL8yuc.d.ts +85 -0
  40. package/dist/webhook-3iL9OEyq.d.cts +20 -0
  41. package/dist/webhook-DuTqrH9x.d.ts +20 -0
  42. package/dist/webhook.cjs +8 -8
  43. package/dist/webhook.cjs.map +1 -1
  44. package/dist/webhook.d.cts +3 -2
  45. package/dist/webhook.d.ts +3 -2
  46. package/dist/webhook.js +8 -8
  47. package/dist/webhook.js.map +1 -1
  48. package/package.json +29 -4
  49. package/dist/webhook-B54a-HGd.d.ts +0 -35
  50. package/dist/webhook-DInps2xX.d.cts +0 -35
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/core/webhook/index.ts"],"sourcesContent":["import type { Collection } from '../client/types'\nimport type { CollectionType } from '../collection/types'\n\nexport type WebhookOperation = 'create' | 'update'\n\nexport interface WebhookEvent<T extends Collection = Collection> {\n collection: T\n operation: WebhookOperation\n data: CollectionType<T>\n}\n\nexport type WebhookHandler<T extends Collection = Collection> = (\n event: WebhookEvent<T>,\n) => Promise<void> | void\n\nexport interface WebhookOptions {\n secret?: string\n}\n\nexport function isValidWebhookEvent(data: unknown): data is WebhookEvent {\n if (typeof data !== 'object' || data === null) return false\n const obj = data as Record<string, unknown>\n return (\n typeof obj.collection === 'string' &&\n (obj.operation === 'create' || obj.operation === 'update') &&\n typeof obj.data === 'object' &&\n obj.data !== null\n )\n}\n\nasync function verifySignature(\n payload: string,\n secret: string,\n signature: string,\n): Promise<boolean> {\n const encoder = new TextEncoder()\n const key = await crypto.subtle.importKey(\n 'raw',\n encoder.encode(secret),\n { name: 'HMAC', hash: 'SHA-256' },\n false,\n ['sign'],\n )\n const sig = await crypto.subtle.sign('HMAC', key, encoder.encode(payload))\n const expected = Array.from(new Uint8Array(sig))\n .map((b) => b.toString(16).padStart(2, '0'))\n .join('')\n // Constant-time comparison to prevent timing attacks\n let result = expected.length !== signature.length ? 1 : 0\n const len = Math.max(expected.length, signature.length)\n for (let i = 0; i < len; i++) {\n result |= (expected.charCodeAt(i) || 0) ^ (signature.charCodeAt(i) || 0)\n }\n return result === 0\n}\n\nexport async function handleWebhook<T extends Collection = Collection>(\n request: Request,\n handler: WebhookHandler<T>,\n options?: WebhookOptions,\n): Promise<Response> {\n try {\n const rawBody = await request.text()\n\n if (options?.secret) {\n const signature = request.headers.get('x-webhook-signature') || ''\n const valid = await verifySignature(rawBody, options.secret, signature)\n if (!valid) {\n return new Response(\n JSON.stringify({ error: 'Invalid webhook signature' }),\n { status: 401, headers: { 'Content-Type': 'application/json' } },\n )\n }\n } else {\n console.warn(\n '[@01.software/sdk] Webhook signature verification is disabled. ' +\n 'Set { secret } in handleWebhook() options to enable HMAC-SHA256 verification.',\n )\n }\n\n const body = JSON.parse(rawBody)\n\n if (!isValidWebhookEvent(body)) {\n return new Response(\n JSON.stringify({ error: 'Invalid webhook event format' }),\n { status: 400, headers: { 'Content-Type': 'application/json' } },\n )\n }\n\n await handler(body as WebhookEvent<T>)\n\n return new Response(\n JSON.stringify({ success: true, message: 'Webhook processed' }),\n { status: 200, headers: { 'Content-Type': 'application/json' } },\n )\n } catch (error) {\n console.error('Webhook processing error:', error)\n\n return new Response(JSON.stringify({ error: 'Internal server error' }), {\n status: 500,\n headers: { 'Content-Type': 'application/json' },\n })\n }\n}\n\nexport function createTypedWebhookHandler<T extends Collection>(\n collection: T,\n handler: (event: WebhookEvent<T>) => Promise<void> | void,\n): WebhookHandler<T> {\n return async (event: WebhookEvent<T>) => {\n if (event.collection !== collection) {\n throw new Error(\n `Expected collection \"${collection}\", got \"${event.collection}\"`,\n )\n }\n return handler(event)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAmBO,SAAS,oBAAoB,MAAqC;AACvE,MAAI,OAAO,SAAS,YAAY,SAAS,KAAM,QAAO;AACtD,QAAM,MAAM;AACZ,SACE,OAAO,IAAI,eAAe,aACzB,IAAI,cAAc,YAAY,IAAI,cAAc,aACjD,OAAO,IAAI,SAAS,YACpB,IAAI,SAAS;AAEjB;AAEA,SAAe,gBACb,SACA,QACA,WACkB;AAAA;AAClB,UAAM,UAAU,IAAI,YAAY;AAChC,UAAM,MAAM,MAAM,OAAO,OAAO;AAAA,MAC9B;AAAA,MACA,QAAQ,OAAO,MAAM;AAAA,MACrB,EAAE,MAAM,QAAQ,MAAM,UAAU;AAAA,MAChC;AAAA,MACA,CAAC,MAAM;AAAA,IACT;AACA,UAAM,MAAM,MAAM,OAAO,OAAO,KAAK,QAAQ,KAAK,QAAQ,OAAO,OAAO,CAAC;AACzE,UAAM,WAAW,MAAM,KAAK,IAAI,WAAW,GAAG,CAAC,EAC5C,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG,CAAC,EAC1C,KAAK,EAAE;AAEV,QAAI,SAAS,SAAS,WAAW,UAAU,SAAS,IAAI;AACxD,UAAM,MAAM,KAAK,IAAI,SAAS,QAAQ,UAAU,MAAM;AACtD,aAAS,IAAI,GAAG,IAAI,KAAK,KAAK;AAC5B,iBAAW,SAAS,WAAW,CAAC,KAAK,MAAM,UAAU,WAAW,CAAC,KAAK;AAAA,IACxE;AACA,WAAO,WAAW;AAAA,EACpB;AAAA;AAEA,SAAsB,cACpB,SACA,SACA,SACmB;AAAA;AACnB,QAAI;AACF,YAAM,UAAU,MAAM,QAAQ,KAAK;AAEnC,UAAI,mCAAS,QAAQ;AACnB,cAAM,YAAY,QAAQ,QAAQ,IAAI,qBAAqB,KAAK;AAChE,cAAM,QAAQ,MAAM,gBAAgB,SAAS,QAAQ,QAAQ,SAAS;AACtE,YAAI,CAAC,OAAO;AACV,iBAAO,IAAI;AAAA,YACT,KAAK,UAAU,EAAE,OAAO,4BAA4B,CAAC;AAAA,YACrD,EAAE,QAAQ,KAAK,SAAS,EAAE,gBAAgB,mBAAmB,EAAE;AAAA,UACjE;AAAA,QACF;AAAA,MACF,OAAO;AACL,gBAAQ;AAAA,UACN;AAAA,QAEF;AAAA,MACF;AAEA,YAAM,OAAO,KAAK,MAAM,OAAO;AAE/B,UAAI,CAAC,oBAAoB,IAAI,GAAG;AAC9B,eAAO,IAAI;AAAA,UACT,KAAK,UAAU,EAAE,OAAO,+BAA+B,CAAC;AAAA,UACxD,EAAE,QAAQ,KAAK,SAAS,EAAE,gBAAgB,mBAAmB,EAAE;AAAA,QACjE;AAAA,MACF;AAEA,YAAM,QAAQ,IAAuB;AAErC,aAAO,IAAI;AAAA,QACT,KAAK,UAAU,EAAE,SAAS,MAAM,SAAS,oBAAoB,CAAC;AAAA,QAC9D,EAAE,QAAQ,KAAK,SAAS,EAAE,gBAAgB,mBAAmB,EAAE;AAAA,MACjE;AAAA,IACF,SAAS,OAAO;AACd,cAAQ,MAAM,6BAA6B,KAAK;AAEhD,aAAO,IAAI,SAAS,KAAK,UAAU,EAAE,OAAO,wBAAwB,CAAC,GAAG;AAAA,QACtE,QAAQ;AAAA,QACR,SAAS,EAAE,gBAAgB,mBAAmB;AAAA,MAChD,CAAC;AAAA,IACH;AAAA,EACF;AAAA;AAEO,SAAS,0BACd,YACA,SACmB;AACnB,SAAO,CAAO,UAA2B;AACvC,QAAI,MAAM,eAAe,YAAY;AACnC,YAAM,IAAI;AAAA,QACR,wBAAwB,UAAU,WAAW,MAAM,UAAU;AAAA,MAC/D;AAAA,IACF;AACA,WAAO,QAAQ,KAAK;AAAA,EACtB;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/core/webhook/index.ts"],"sourcesContent":["import type { Collection } from '../client/types'\nimport type { CollectionType } from '../collection/types'\n\nexport type WebhookOperation = 'create' | 'update'\n\nexport interface WebhookEvent<T extends Collection = Collection> {\n collection: T\n operation: WebhookOperation\n data: CollectionType<T>\n}\n\nexport type WebhookHandler<T extends Collection = Collection> = (\n event: WebhookEvent<T>,\n) => Promise<void> | void\n\nexport interface WebhookOptions {\n secret?: string\n}\n\nexport function isValidWebhookEvent(data: unknown): data is WebhookEvent {\n if (typeof data !== 'object' || data === null) return false\n const obj = data as Record<string, unknown>\n return (\n typeof obj.collection === 'string' &&\n (obj.operation === 'create' || obj.operation === 'update') &&\n typeof obj.data === 'object' &&\n obj.data !== null\n )\n}\n\nasync function verifySignature(\n payload: string,\n secret: string,\n signature: string,\n): Promise<boolean> {\n const encoder = new TextEncoder()\n const key = await crypto.subtle.importKey(\n 'raw',\n encoder.encode(secret),\n { name: 'HMAC', hash: 'SHA-256' },\n false,\n ['verify'],\n )\n // Validate and convert hex signature to Uint8Array\n if (signature.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(signature)) {\n return false\n }\n const sigBytes = new Uint8Array(\n (signature.match(/.{2}/g) ?? []).map((byte) => parseInt(byte, 16)),\n )\n // crypto.subtle.verify performs constant-time comparison internally\n return crypto.subtle.verify('HMAC', key, sigBytes, encoder.encode(payload))\n}\n\nexport async function handleWebhook<T extends Collection = Collection>(\n request: Request,\n handler: WebhookHandler<T>,\n options?: WebhookOptions,\n): Promise<Response> {\n try {\n const rawBody = await request.text()\n\n if (options?.secret) {\n const signature = request.headers.get('x-webhook-signature') || ''\n const valid = await verifySignature(rawBody, options.secret, signature)\n if (!valid) {\n return new Response(\n JSON.stringify({ error: 'Invalid webhook signature' }),\n { status: 401, headers: { 'Content-Type': 'application/json' } },\n )\n }\n } else {\n console.warn(\n '[@01.software/sdk] Webhook signature verification is disabled. ' +\n 'Set { secret } in handleWebhook() options to enable HMAC-SHA256 verification.',\n )\n }\n\n const body = JSON.parse(rawBody)\n\n if (!isValidWebhookEvent(body)) {\n return new Response(\n JSON.stringify({ error: 'Invalid webhook event format' }),\n { status: 400, headers: { 'Content-Type': 'application/json' } },\n )\n }\n\n await handler(body as WebhookEvent<T>)\n\n return new Response(\n JSON.stringify({ success: true, message: 'Webhook processed' }),\n { status: 200, headers: { 'Content-Type': 'application/json' } },\n )\n } catch (error) {\n console.error('Webhook processing error:', error)\n\n return new Response(JSON.stringify({ error: 'Internal server error' }), {\n status: 500,\n headers: { 'Content-Type': 'application/json' },\n })\n }\n}\n\nexport function createTypedWebhookHandler<T extends Collection>(\n collection: T,\n handler: (event: WebhookEvent<T>) => Promise<void> | void,\n): WebhookHandler<T> {\n return async (event: WebhookEvent<T>) => {\n if (event.collection !== collection) {\n throw new Error(\n `Expected collection \"${collection}\", got \"${event.collection}\"`,\n )\n }\n return handler(event)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAmBO,SAAS,oBAAoB,MAAqC;AACvE,MAAI,OAAO,SAAS,YAAY,SAAS,KAAM,QAAO;AACtD,QAAM,MAAM;AACZ,SACE,OAAO,IAAI,eAAe,aACzB,IAAI,cAAc,YAAY,IAAI,cAAc,aACjD,OAAO,IAAI,SAAS,YACpB,IAAI,SAAS;AAEjB;AAEA,SAAe,gBACb,SACA,QACA,WACkB;AAAA;AAlCpB;AAmCE,UAAM,UAAU,IAAI,YAAY;AAChC,UAAM,MAAM,MAAM,OAAO,OAAO;AAAA,MAC9B;AAAA,MACA,QAAQ,OAAO,MAAM;AAAA,MACrB,EAAE,MAAM,QAAQ,MAAM,UAAU;AAAA,MAChC;AAAA,MACA,CAAC,QAAQ;AAAA,IACX;AAEA,QAAI,UAAU,SAAS,MAAM,KAAK,CAAC,iBAAiB,KAAK,SAAS,GAAG;AACnE,aAAO;AAAA,IACT;AACA,UAAM,WAAW,IAAI;AAAA,QAClB,eAAU,MAAM,OAAO,MAAvB,YAA4B,CAAC,GAAG,IAAI,CAAC,SAAS,SAAS,MAAM,EAAE,CAAC;AAAA,IACnE;AAEA,WAAO,OAAO,OAAO,OAAO,QAAQ,KAAK,UAAU,QAAQ,OAAO,OAAO,CAAC;AAAA,EAC5E;AAAA;AAEA,SAAsB,cACpB,SACA,SACA,SACmB;AAAA;AACnB,QAAI;AACF,YAAM,UAAU,MAAM,QAAQ,KAAK;AAEnC,UAAI,mCAAS,QAAQ;AACnB,cAAM,YAAY,QAAQ,QAAQ,IAAI,qBAAqB,KAAK;AAChE,cAAM,QAAQ,MAAM,gBAAgB,SAAS,QAAQ,QAAQ,SAAS;AACtE,YAAI,CAAC,OAAO;AACV,iBAAO,IAAI;AAAA,YACT,KAAK,UAAU,EAAE,OAAO,4BAA4B,CAAC;AAAA,YACrD,EAAE,QAAQ,KAAK,SAAS,EAAE,gBAAgB,mBAAmB,EAAE;AAAA,UACjE;AAAA,QACF;AAAA,MACF,OAAO;AACL,gBAAQ;AAAA,UACN;AAAA,QAEF;AAAA,MACF;AAEA,YAAM,OAAO,KAAK,MAAM,OAAO;AAE/B,UAAI,CAAC,oBAAoB,IAAI,GAAG;AAC9B,eAAO,IAAI;AAAA,UACT,KAAK,UAAU,EAAE,OAAO,+BAA+B,CAAC;AAAA,UACxD,EAAE,QAAQ,KAAK,SAAS,EAAE,gBAAgB,mBAAmB,EAAE;AAAA,QACjE;AAAA,MACF;AAEA,YAAM,QAAQ,IAAuB;AAErC,aAAO,IAAI;AAAA,QACT,KAAK,UAAU,EAAE,SAAS,MAAM,SAAS,oBAAoB,CAAC;AAAA,QAC9D,EAAE,QAAQ,KAAK,SAAS,EAAE,gBAAgB,mBAAmB,EAAE;AAAA,MACjE;AAAA,IACF,SAAS,OAAO;AACd,cAAQ,MAAM,6BAA6B,KAAK;AAEhD,aAAO,IAAI,SAAS,KAAK,UAAU,EAAE,OAAO,wBAAwB,CAAC,GAAG;AAAA,QACtE,QAAQ;AAAA,QACR,SAAS,EAAE,gBAAgB,mBAAmB;AAAA,MAChD,CAAC;AAAA,IACH;AAAA,EACF;AAAA;AAEO,SAAS,0BACd,YACA,SACmB;AACnB,SAAO,CAAO,UAA2B;AACvC,QAAI,MAAM,eAAe,YAAY;AACnC,YAAM,IAAI;AAAA,QACR,wBAAwB,UAAU,WAAW,MAAM,UAAU;AAAA,MAC/D;AAAA,IACF;AACA,WAAO,QAAQ,KAAK;AAAA,EACtB;AACF;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@01.software/sdk",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "01.software SDK",
5
5
  "author": "<office@01.works>",
6
6
  "keywords": [],
@@ -39,6 +39,16 @@
39
39
  "default": "./dist/webhook.cjs"
40
40
  }
41
41
  },
42
+ "./realtime": {
43
+ "import": {
44
+ "types": "./dist/realtime.d.ts",
45
+ "default": "./dist/realtime.js"
46
+ },
47
+ "require": {
48
+ "types": "./dist/realtime.d.cts",
49
+ "default": "./dist/realtime.cjs"
50
+ }
51
+ },
42
52
  "./ui/image": {
43
53
  "import": {
44
54
  "types": "./dist/ui/image.d.ts",
@@ -89,6 +99,16 @@
89
99
  "default": "./dist/ui/flow.cjs"
90
100
  }
91
101
  },
102
+ "./ui/video": {
103
+ "import": {
104
+ "types": "./dist/ui/video.d.ts",
105
+ "default": "./dist/ui/video.js"
106
+ },
107
+ "require": {
108
+ "types": "./dist/ui/video.d.cts",
109
+ "default": "./dist/ui/video.cjs"
110
+ }
111
+ },
92
112
  "./package.json": "./package.json"
93
113
  },
94
114
  "sideEffects": false,
@@ -100,6 +120,7 @@
100
120
  ],
101
121
  "devDependencies": {
102
122
  "@arethetypeswrong/cli": "^0.17.3",
123
+ "@mux/mux-player-react": "^3.3.4",
103
124
  "@tanstack/react-query": "5.90.16",
104
125
  "@testing-library/jest-dom": "^6.9.1",
105
126
  "@testing-library/react": "16.3.0",
@@ -120,10 +141,10 @@
120
141
  "@repo/typescript-config": "0.0.0"
121
142
  },
122
143
  "dependencies": {
123
- "@payloadcms/richtext-lexical": "3.78.0",
144
+ "@payloadcms/richtext-lexical": ">=3.78.0",
124
145
  "hast-util-to-jsx-runtime": "^2.3.6",
125
146
  "jose": "^6.1.3",
126
- "payload": "3.78.0",
147
+ "payload": ">=3.78.0",
127
148
  "qs-esm": "^7.0.2",
128
149
  "shiki": "^4.0.1"
129
150
  },
@@ -132,11 +153,15 @@
132
153
  "@xyflow/react": ">=12",
133
154
  "next": ">=14",
134
155
  "react": ">=18",
135
- "react-dom": ">=18"
156
+ "react-dom": ">=18",
157
+ "@mux/mux-player-react": ">=3"
136
158
  },
137
159
  "peerDependenciesMeta": {
138
160
  "@xyflow/react": {
139
161
  "optional": true
162
+ },
163
+ "@mux/mux-player-react": {
164
+ "optional": true
140
165
  }
141
166
  },
142
167
  "publishConfig": {
@@ -1,35 +0,0 @@
1
- import { d as Config } from './payload-types-ggU6BNuH.js';
2
-
3
- /**
4
- * Collection type derived from Payload Config.
5
- * This ensures type safety and automatic synchronization with payload-types.ts
6
- */
7
- type Collection = keyof Config['collections'];
8
- /**
9
- * Array of all public collection names for runtime use (e.g., Zod enum validation).
10
- * This is the single source of truth for which collections are publicly accessible via SDK.
11
- */
12
- declare const COLLECTIONS: readonly ["tenants", "tenant-metadata", "tenant-logos", "products", "product-variants", "product-options", "product-categories", "product-tags", "product-collections", "brands", "brand-logos", "orders", "order-products", "returns", "return-products", "exchanges", "exchange-products", "fulfillments", "fulfillment-items", "transactions", "customers", "customer-addresses", "customer-groups", "carts", "cart-items", "discounts", "shipping-policies", "documents", "document-categories", "document-types", "posts", "post-categories", "post-tags", "playlists", "playlist-categories", "playlist-tags", "musics", "galleries", "gallery-categories", "gallery-tags", "gallery-items", "flows", "flow-node-types", "flow-edge-types", "flow-categories", "flow-tags", "videos", "video-categories", "video-tags", "live-streams", "images", "forms", "form-submissions"];
13
- /**
14
- * Public collections available for SDK access.
15
- * Derived from the COLLECTIONS array (single source of truth).
16
- */
17
- type PublicCollection = (typeof COLLECTIONS)[number];
18
-
19
- type CollectionType<T extends Collection> = T extends keyof Config['collections'] ? Config['collections'][T] : never;
20
-
21
- type WebhookOperation = 'create' | 'update';
22
- interface WebhookEvent<T extends Collection = Collection> {
23
- collection: T;
24
- operation: WebhookOperation;
25
- data: CollectionType<T>;
26
- }
27
- type WebhookHandler<T extends Collection = Collection> = (event: WebhookEvent<T>) => Promise<void> | void;
28
- interface WebhookOptions {
29
- secret?: string;
30
- }
31
- declare function isValidWebhookEvent(data: unknown): data is WebhookEvent;
32
- declare function handleWebhook<T extends Collection = Collection>(request: Request, handler: WebhookHandler<T>, options?: WebhookOptions): Promise<Response>;
33
- declare function createTypedWebhookHandler<T extends Collection>(collection: T, handler: (event: WebhookEvent<T>) => Promise<void> | void): WebhookHandler<T>;
34
-
35
- export { type CollectionType as C, type PublicCollection as P, type WebhookOperation as W, type Collection as a, COLLECTIONS as b, type WebhookEvent as c, type WebhookHandler as d, type WebhookOptions as e, createTypedWebhookHandler as f, handleWebhook as h, isValidWebhookEvent as i };
@@ -1,35 +0,0 @@
1
- import { d as Config } from './payload-types-ggU6BNuH.cjs';
2
-
3
- /**
4
- * Collection type derived from Payload Config.
5
- * This ensures type safety and automatic synchronization with payload-types.ts
6
- */
7
- type Collection = keyof Config['collections'];
8
- /**
9
- * Array of all public collection names for runtime use (e.g., Zod enum validation).
10
- * This is the single source of truth for which collections are publicly accessible via SDK.
11
- */
12
- declare const COLLECTIONS: readonly ["tenants", "tenant-metadata", "tenant-logos", "products", "product-variants", "product-options", "product-categories", "product-tags", "product-collections", "brands", "brand-logos", "orders", "order-products", "returns", "return-products", "exchanges", "exchange-products", "fulfillments", "fulfillment-items", "transactions", "customers", "customer-addresses", "customer-groups", "carts", "cart-items", "discounts", "shipping-policies", "documents", "document-categories", "document-types", "posts", "post-categories", "post-tags", "playlists", "playlist-categories", "playlist-tags", "musics", "galleries", "gallery-categories", "gallery-tags", "gallery-items", "flows", "flow-node-types", "flow-edge-types", "flow-categories", "flow-tags", "videos", "video-categories", "video-tags", "live-streams", "images", "forms", "form-submissions"];
13
- /**
14
- * Public collections available for SDK access.
15
- * Derived from the COLLECTIONS array (single source of truth).
16
- */
17
- type PublicCollection = (typeof COLLECTIONS)[number];
18
-
19
- type CollectionType<T extends Collection> = T extends keyof Config['collections'] ? Config['collections'][T] : never;
20
-
21
- type WebhookOperation = 'create' | 'update';
22
- interface WebhookEvent<T extends Collection = Collection> {
23
- collection: T;
24
- operation: WebhookOperation;
25
- data: CollectionType<T>;
26
- }
27
- type WebhookHandler<T extends Collection = Collection> = (event: WebhookEvent<T>) => Promise<void> | void;
28
- interface WebhookOptions {
29
- secret?: string;
30
- }
31
- declare function isValidWebhookEvent(data: unknown): data is WebhookEvent;
32
- declare function handleWebhook<T extends Collection = Collection>(request: Request, handler: WebhookHandler<T>, options?: WebhookOptions): Promise<Response>;
33
- declare function createTypedWebhookHandler<T extends Collection>(collection: T, handler: (event: WebhookEvent<T>) => Promise<void> | void): WebhookHandler<T>;
34
-
35
- export { type CollectionType as C, type PublicCollection as P, type WebhookOperation as W, type Collection as a, COLLECTIONS as b, type WebhookEvent as c, type WebhookHandler as d, type WebhookOptions as e, createTypedWebhookHandler as f, handleWebhook as h, isValidWebhookEvent as i };