@01.software/sdk 0.33.0 → 0.34.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 (70) hide show
  1. package/README.md +214 -22
  2. package/dist/analytics/react.cjs.map +1 -1
  3. package/dist/analytics/react.js.map +1 -1
  4. package/dist/analytics.cjs.map +1 -1
  5. package/dist/analytics.js.map +1 -1
  6. package/dist/client.cjs +341 -26
  7. package/dist/client.cjs.map +1 -1
  8. package/dist/client.d.cts +7 -6
  9. package/dist/client.d.ts +7 -6
  10. package/dist/client.js +341 -26
  11. package/dist/client.js.map +1 -1
  12. package/dist/{collection-client-De6eKW1J.d.cts → collection-client-CR2B8c1v.d.cts} +7 -3
  13. package/dist/{collection-client-B6SlhzIP.d.ts → collection-client-DkREjhQ9.d.ts} +7 -3
  14. package/dist/{const-sPR2IkCe.d.cts → const-BTvdrXtY.d.cts} +4 -4
  15. package/dist/{const-DwmSDeWq.d.ts → const-CdqCauHQ.d.ts} +4 -4
  16. package/dist/index-CjA3U6X3.d.cts +186 -0
  17. package/dist/index-DK8_NXkh.d.ts +186 -0
  18. package/dist/index.cjs +1401 -176
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.d.cts +74 -9
  21. package/dist/index.d.ts +74 -9
  22. package/dist/index.js +1401 -176
  23. package/dist/index.js.map +1 -1
  24. package/dist/{payload-types-dkeQyrDC.d.cts → payload-types-C7tb7Xbs.d.cts} +208 -52
  25. package/dist/{payload-types-dkeQyrDC.d.ts → payload-types-C7tb7Xbs.d.ts} +208 -52
  26. package/dist/query.cjs +194 -35
  27. package/dist/query.cjs.map +1 -1
  28. package/dist/query.d.cts +44 -17
  29. package/dist/query.d.ts +44 -17
  30. package/dist/query.js +194 -35
  31. package/dist/query.js.map +1 -1
  32. package/dist/realtime.cjs.map +1 -1
  33. package/dist/realtime.d.cts +2 -2
  34. package/dist/realtime.d.ts +2 -2
  35. package/dist/realtime.js.map +1 -1
  36. package/dist/{server-CrsPyqEc.d.cts → server-nXOezi4b.d.cts} +22 -6
  37. package/dist/{server-CrsPyqEc.d.ts → server-nXOezi4b.d.ts} +22 -6
  38. package/dist/server.cjs +439 -32
  39. package/dist/server.cjs.map +1 -1
  40. package/dist/server.d.cts +11 -179
  41. package/dist/server.d.ts +11 -179
  42. package/dist/server.js +439 -32
  43. package/dist/server.js.map +1 -1
  44. package/dist/{types-Cel_4L9t.d.ts → types-1ylMrCuW.d.ts} +1 -1
  45. package/dist/{types-B3YT092I.d.cts → types-Bx558PU6.d.cts} +1 -1
  46. package/dist/{types-BHh0YLmq.d.ts → types-Byo_Rty4.d.ts} +705 -69
  47. package/dist/{types-BZKxss8Y.d.cts → types-DDhtZI6E.d.cts} +705 -69
  48. package/dist/ui/canvas/server.cjs +231 -38
  49. package/dist/ui/canvas/server.cjs.map +1 -1
  50. package/dist/ui/canvas/server.d.cts +1 -1
  51. package/dist/ui/canvas/server.d.ts +1 -1
  52. package/dist/ui/canvas/server.js +221 -38
  53. package/dist/ui/canvas/server.js.map +1 -1
  54. package/dist/ui/canvas.cjs +320 -257
  55. package/dist/ui/canvas.cjs.map +1 -1
  56. package/dist/ui/canvas.d.cts +5 -19
  57. package/dist/ui/canvas.d.ts +5 -19
  58. package/dist/ui/canvas.js +323 -260
  59. package/dist/ui/canvas.js.map +1 -1
  60. package/dist/ui/form.d.cts +1 -1
  61. package/dist/ui/form.d.ts +1 -1
  62. package/dist/ui/video.d.cts +1 -1
  63. package/dist/ui/video.d.ts +1 -1
  64. package/dist/webhook.cjs +2 -1
  65. package/dist/webhook.cjs.map +1 -1
  66. package/dist/webhook.d.cts +20 -179
  67. package/dist/webhook.d.ts +20 -179
  68. package/dist/webhook.js +2 -1
  69. package/dist/webhook.js.map +1 -1
  70. package/package.json +4 -5
@@ -1,7 +1,7 @@
1
- import { D as DebugConfig, R as RetryConfig, A as ApiQueryOptions, P as PayloadFindResponse, g as PayloadMutationResponse } from './types-BZKxss8Y.cjs';
1
+ import { D as DebugConfig, R as RetryConfig, A as ApiQueryOptions, P as PayloadFindResponse, h as PayloadMutationResponse } from './types-DDhtZI6E.cjs';
2
2
  import { GenerateMetadataOptions, Metadata } from './metadata.cjs';
3
- import { c as ServerCollection, P as PublicCollection } from './const-sPR2IkCe.cjs';
4
- import { C as CollectionType } from './types-B3YT092I.cjs';
3
+ import { S as ServerCollection, P as PublicCollection } from './const-BTvdrXtY.cjs';
4
+ import { C as CollectionType } from './types-Bx558PU6.cjs';
5
5
 
6
6
  interface FetchOptions extends RequestInit {
7
7
  apiUrl?: string;
@@ -150,6 +150,10 @@ declare class CollectionClient<TCollection extends string = PublicCollection> ex
150
150
  * POST /api/...custom-endpoint
151
151
  */
152
152
  requestFindEndpoint<T = unknown>(endpoint: string, data?: unknown): Promise<PayloadFindResponse<T>>;
153
+ /**
154
+ * Find-like response from a cacheable GET custom endpoint.
155
+ */
156
+ requestFindEndpointGet<T = unknown>(endpoint: string): Promise<PayloadFindResponse<T>>;
153
157
  /**
154
158
  * Find document by ID
155
159
  * GET /api/{collection}/{id}
@@ -1,7 +1,7 @@
1
- import { D as DebugConfig, R as RetryConfig, A as ApiQueryOptions, P as PayloadFindResponse, g as PayloadMutationResponse } from './types-BHh0YLmq.js';
1
+ import { D as DebugConfig, R as RetryConfig, A as ApiQueryOptions, P as PayloadFindResponse, h as PayloadMutationResponse } from './types-Byo_Rty4.js';
2
2
  import { GenerateMetadataOptions, Metadata } from './metadata.js';
3
- import { c as ServerCollection, P as PublicCollection } from './const-DwmSDeWq.js';
4
- import { C as CollectionType } from './types-Cel_4L9t.js';
3
+ import { S as ServerCollection, P as PublicCollection } from './const-CdqCauHQ.js';
4
+ import { C as CollectionType } from './types-1ylMrCuW.js';
5
5
 
6
6
  interface FetchOptions extends RequestInit {
7
7
  apiUrl?: string;
@@ -150,6 +150,10 @@ declare class CollectionClient<TCollection extends string = PublicCollection> ex
150
150
  * POST /api/...custom-endpoint
151
151
  */
152
152
  requestFindEndpoint<T = unknown>(endpoint: string, data?: unknown): Promise<PayloadFindResponse<T>>;
153
+ /**
154
+ * Find-like response from a cacheable GET custom endpoint.
155
+ */
156
+ requestFindEndpointGet<T = unknown>(endpoint: string): Promise<PayloadFindResponse<T>>;
153
157
  /**
154
158
  * Find document by ID
155
159
  * GET /api/{collection}/{id}
@@ -1,4 +1,4 @@
1
- import { e as Config } from './payload-types-dkeQyrDC.cjs';
1
+ import { e as Config } from './payload-types-C7tb7Xbs.cjs';
2
2
 
3
3
  /**
4
4
  * Collection type derived from Payload Config.
@@ -14,7 +14,7 @@ declare const INTERNAL_COLLECTIONS: readonly ["users", "payload-kv", "payload-lo
14
14
  * Array of all public collection names for runtime use (e.g., Zod enum validation).
15
15
  * This is the single source of truth for which collections are publicly accessible via SDK.
16
16
  */
17
- declare const COLLECTIONS: readonly ["tenants", "tenant-metadata", "tenant-logos", "products", "product-variants", "product-options", "product-option-values", "product-categories", "product-tags", "product-collections", "brands", "brand-logos", "orders", "order-items", "returns", "return-items", "fulfillments", "fulfillment-items", "transactions", "customers", "customer-profiles", "customer-addresses", "carts", "cart-items", "discounts", "shipping-policies", "shipping-zones", "documents", "document-categories", "document-types", "articles", "article-authors", "article-categories", "article-tags", "playlists", "playlist-categories", "playlist-tags", "tracks", "track-categories", "track-tags", "galleries", "gallery-categories", "gallery-tags", "gallery-items", "links", "link-categories", "link-tags", "canvases", "canvas-node-types", "canvas-edge-types", "canvas-categories", "canvas-tags", "canvas-nodes", "canvas-edges", "videos", "video-categories", "video-tags", "live-streams", "images", "forms", "form-submissions", "posts", "comments", "reactions", "reaction-types", "bookmarks", "post-categories", "customer-profile-lists", "event-calendars", "events", "event-categories", "event-occurrences", "event-tags"];
17
+ declare const COLLECTIONS: readonly ["tenants", "tenant-metadata", "tenant-logos", "products", "product-variants", "product-options", "product-option-values", "product-categories", "product-tags", "product-collections", "brands", "brand-logos", "orders", "order-items", "returns", "return-items", "fulfillments", "fulfillment-items", "transactions", "customers", "customer-profiles", "customer-addresses", "carts", "cart-items", "discounts", "shipping-policies", "shipping-zones", "documents", "document-categories", "document-types", "articles", "article-authors", "article-categories", "article-tags", "playlists", "playlist-categories", "playlist-tags", "tracks", "track-categories", "track-tags", "galleries", "gallery-categories", "gallery-tags", "gallery-items", "links", "link-categories", "link-tags", "canvases", "canvas-node-types", "canvas-edge-types", "canvas-categories", "canvas-tags", "canvas-nodes", "canvas-edges", "videos", "video-categories", "video-tags", "live-streams", "images", "forms", "form-submissions", "posts", "comments", "reactions", "reaction-types", "bookmarks", "post-categories", "post-tags", "customer-profile-lists", "event-calendars", "events", "event-categories", "event-occurrences", "event-tags"];
18
18
  /**
19
19
  * Server-auth collection names for runtime use. These collections are safe for
20
20
  * secret-key/PAT SDK and MCP server tools, but must not appear in browser or
@@ -26,7 +26,7 @@ declare const SERVER_ONLY_COLLECTIONS: readonly ["customer-groups", "reports", "
26
26
  * Derived from the COLLECTIONS array (single source of truth).
27
27
  */
28
28
  type PublicCollection = (typeof COLLECTIONS)[number];
29
- declare const SERVER_COLLECTIONS: readonly ["tenants", "tenant-metadata", "tenant-logos", "products", "product-variants", "product-options", "product-option-values", "product-categories", "product-tags", "product-collections", "brands", "brand-logos", "orders", "order-items", "returns", "return-items", "fulfillments", "fulfillment-items", "transactions", "customers", "customer-profiles", "customer-addresses", "carts", "cart-items", "discounts", "shipping-policies", "shipping-zones", "documents", "document-categories", "document-types", "articles", "article-authors", "article-categories", "article-tags", "playlists", "playlist-categories", "playlist-tags", "tracks", "track-categories", "track-tags", "galleries", "gallery-categories", "gallery-tags", "gallery-items", "links", "link-categories", "link-tags", "canvases", "canvas-node-types", "canvas-edge-types", "canvas-categories", "canvas-tags", "canvas-nodes", "canvas-edges", "videos", "video-categories", "video-tags", "live-streams", "images", "forms", "form-submissions", "posts", "comments", "reactions", "reaction-types", "bookmarks", "post-categories", "customer-profile-lists", "event-calendars", "events", "event-categories", "event-occurrences", "event-tags", "customer-groups", "reports", "community-bans"];
29
+ declare const SERVER_COLLECTIONS: readonly ["tenants", "tenant-metadata", "tenant-logos", "products", "product-variants", "product-options", "product-option-values", "product-categories", "product-tags", "product-collections", "brands", "brand-logos", "orders", "order-items", "returns", "return-items", "fulfillments", "fulfillment-items", "transactions", "customers", "customer-profiles", "customer-addresses", "carts", "cart-items", "discounts", "shipping-policies", "shipping-zones", "documents", "document-categories", "document-types", "articles", "article-authors", "article-categories", "article-tags", "playlists", "playlist-categories", "playlist-tags", "tracks", "track-categories", "track-tags", "galleries", "gallery-categories", "gallery-tags", "gallery-items", "links", "link-categories", "link-tags", "canvases", "canvas-node-types", "canvas-edge-types", "canvas-categories", "canvas-tags", "canvas-nodes", "canvas-edges", "videos", "video-categories", "video-tags", "live-streams", "images", "forms", "form-submissions", "posts", "comments", "reactions", "reaction-types", "bookmarks", "post-categories", "post-tags", "customer-profile-lists", "event-calendars", "events", "event-categories", "event-occurrences", "event-tags", "customer-groups", "reports", "community-bans"];
30
30
  type ServerCollection = (typeof SERVER_COLLECTIONS)[number];
31
31
 
32
- export { type Collection as C, INTERNAL_COLLECTIONS as I, type PublicCollection as P, SERVER_COLLECTIONS as S, COLLECTIONS as a, SERVER_ONLY_COLLECTIONS as b, type ServerCollection as c };
32
+ export { type Collection as C, INTERNAL_COLLECTIONS as I, type PublicCollection as P, type ServerCollection as S, COLLECTIONS as a, SERVER_COLLECTIONS as b, SERVER_ONLY_COLLECTIONS as c };
@@ -1,4 +1,4 @@
1
- import { e as Config } from './payload-types-dkeQyrDC.js';
1
+ import { e as Config } from './payload-types-C7tb7Xbs.js';
2
2
 
3
3
  /**
4
4
  * Collection type derived from Payload Config.
@@ -14,7 +14,7 @@ declare const INTERNAL_COLLECTIONS: readonly ["users", "payload-kv", "payload-lo
14
14
  * Array of all public collection names for runtime use (e.g., Zod enum validation).
15
15
  * This is the single source of truth for which collections are publicly accessible via SDK.
16
16
  */
17
- declare const COLLECTIONS: readonly ["tenants", "tenant-metadata", "tenant-logos", "products", "product-variants", "product-options", "product-option-values", "product-categories", "product-tags", "product-collections", "brands", "brand-logos", "orders", "order-items", "returns", "return-items", "fulfillments", "fulfillment-items", "transactions", "customers", "customer-profiles", "customer-addresses", "carts", "cart-items", "discounts", "shipping-policies", "shipping-zones", "documents", "document-categories", "document-types", "articles", "article-authors", "article-categories", "article-tags", "playlists", "playlist-categories", "playlist-tags", "tracks", "track-categories", "track-tags", "galleries", "gallery-categories", "gallery-tags", "gallery-items", "links", "link-categories", "link-tags", "canvases", "canvas-node-types", "canvas-edge-types", "canvas-categories", "canvas-tags", "canvas-nodes", "canvas-edges", "videos", "video-categories", "video-tags", "live-streams", "images", "forms", "form-submissions", "posts", "comments", "reactions", "reaction-types", "bookmarks", "post-categories", "customer-profile-lists", "event-calendars", "events", "event-categories", "event-occurrences", "event-tags"];
17
+ declare const COLLECTIONS: readonly ["tenants", "tenant-metadata", "tenant-logos", "products", "product-variants", "product-options", "product-option-values", "product-categories", "product-tags", "product-collections", "brands", "brand-logos", "orders", "order-items", "returns", "return-items", "fulfillments", "fulfillment-items", "transactions", "customers", "customer-profiles", "customer-addresses", "carts", "cart-items", "discounts", "shipping-policies", "shipping-zones", "documents", "document-categories", "document-types", "articles", "article-authors", "article-categories", "article-tags", "playlists", "playlist-categories", "playlist-tags", "tracks", "track-categories", "track-tags", "galleries", "gallery-categories", "gallery-tags", "gallery-items", "links", "link-categories", "link-tags", "canvases", "canvas-node-types", "canvas-edge-types", "canvas-categories", "canvas-tags", "canvas-nodes", "canvas-edges", "videos", "video-categories", "video-tags", "live-streams", "images", "forms", "form-submissions", "posts", "comments", "reactions", "reaction-types", "bookmarks", "post-categories", "post-tags", "customer-profile-lists", "event-calendars", "events", "event-categories", "event-occurrences", "event-tags"];
18
18
  /**
19
19
  * Server-auth collection names for runtime use. These collections are safe for
20
20
  * secret-key/PAT SDK and MCP server tools, but must not appear in browser or
@@ -26,7 +26,7 @@ declare const SERVER_ONLY_COLLECTIONS: readonly ["customer-groups", "reports", "
26
26
  * Derived from the COLLECTIONS array (single source of truth).
27
27
  */
28
28
  type PublicCollection = (typeof COLLECTIONS)[number];
29
- declare const SERVER_COLLECTIONS: readonly ["tenants", "tenant-metadata", "tenant-logos", "products", "product-variants", "product-options", "product-option-values", "product-categories", "product-tags", "product-collections", "brands", "brand-logos", "orders", "order-items", "returns", "return-items", "fulfillments", "fulfillment-items", "transactions", "customers", "customer-profiles", "customer-addresses", "carts", "cart-items", "discounts", "shipping-policies", "shipping-zones", "documents", "document-categories", "document-types", "articles", "article-authors", "article-categories", "article-tags", "playlists", "playlist-categories", "playlist-tags", "tracks", "track-categories", "track-tags", "galleries", "gallery-categories", "gallery-tags", "gallery-items", "links", "link-categories", "link-tags", "canvases", "canvas-node-types", "canvas-edge-types", "canvas-categories", "canvas-tags", "canvas-nodes", "canvas-edges", "videos", "video-categories", "video-tags", "live-streams", "images", "forms", "form-submissions", "posts", "comments", "reactions", "reaction-types", "bookmarks", "post-categories", "customer-profile-lists", "event-calendars", "events", "event-categories", "event-occurrences", "event-tags", "customer-groups", "reports", "community-bans"];
29
+ declare const SERVER_COLLECTIONS: readonly ["tenants", "tenant-metadata", "tenant-logos", "products", "product-variants", "product-options", "product-option-values", "product-categories", "product-tags", "product-collections", "brands", "brand-logos", "orders", "order-items", "returns", "return-items", "fulfillments", "fulfillment-items", "transactions", "customers", "customer-profiles", "customer-addresses", "carts", "cart-items", "discounts", "shipping-policies", "shipping-zones", "documents", "document-categories", "document-types", "articles", "article-authors", "article-categories", "article-tags", "playlists", "playlist-categories", "playlist-tags", "tracks", "track-categories", "track-tags", "galleries", "gallery-categories", "gallery-tags", "gallery-items", "links", "link-categories", "link-tags", "canvases", "canvas-node-types", "canvas-edge-types", "canvas-categories", "canvas-tags", "canvas-nodes", "canvas-edges", "videos", "video-categories", "video-tags", "live-streams", "images", "forms", "form-submissions", "posts", "comments", "reactions", "reaction-types", "bookmarks", "post-categories", "post-tags", "customer-profile-lists", "event-calendars", "events", "event-categories", "event-occurrences", "event-tags", "customer-groups", "reports", "community-bans"];
30
30
  type ServerCollection = (typeof SERVER_COLLECTIONS)[number];
31
31
 
32
- export { type Collection as C, INTERNAL_COLLECTIONS as I, type PublicCollection as P, SERVER_COLLECTIONS as S, COLLECTIONS as a, SERVER_ONLY_COLLECTIONS as b, type ServerCollection as c };
32
+ export { type Collection as C, INTERNAL_COLLECTIONS as I, type PublicCollection as P, type ServerCollection as S, COLLECTIONS as a, SERVER_COLLECTIONS as b, SERVER_ONLY_COLLECTIONS as c };
@@ -0,0 +1,186 @@
1
+ import { C as Collection } from './const-BTvdrXtY.cjs';
2
+ import { C as CollectionType } from './types-Bx558PU6.cjs';
3
+ import './payload-types-C7tb7Xbs.cjs';
4
+
5
+ type WebhookOperation = string;
6
+ /**
7
+ * Semantic event type for manual Admin Panel ordering changes.
8
+ *
9
+ * Order-change webhooks remain `operation: "update"` events for compatibility.
10
+ * Do not filter on or emit `operation: "reorder"`; use this event type with
11
+ * `isOrderChangedWebhookEvent()` to distinguish ordering from normal content
12
+ * updates.
13
+ */
14
+ declare const ORDER_CHANGED_EVENT_TYPE: "collection.orderChanged";
15
+ /** Semantic event type for v1 commerce notification webhooks. */
16
+ declare const COMMERCE_NOTIFICATION_EVENT_TYPE: "commerce.notification";
17
+ /** Collection webhook operations emitted for tenant collection writes. */
18
+ type CollectionWebhookOperation = 'create' | 'update';
19
+ /** Describes the ordered area affected by an order-change webhook. */
20
+ type WebhookOrderScope = {
21
+ kind: 'collection';
22
+ collection: string;
23
+ } | {
24
+ kind: 'join';
25
+ collection: string;
26
+ field: string;
27
+ id: string | number;
28
+ };
29
+ /** Identifies the public moved document for the ordered scope. */
30
+ type WebhookOrderMoved = {
31
+ collection: string;
32
+ id: string | number;
33
+ relatedCollection?: string;
34
+ relatedId?: string | number;
35
+ };
36
+ /** Metadata attached to `collection.orderChanged` webhook events. */
37
+ type WebhookOrderChange = {
38
+ type: 'order';
39
+ source: 'payload-orderable';
40
+ /**
41
+ * Diagnostic Payload order field name.
42
+ *
43
+ * This may contain hidden implementation field names. Application routing
44
+ * should use `change.scope` and `change.moved` instead.
45
+ */
46
+ orderableFieldName?: string;
47
+ previousOrder?: string | null;
48
+ nextOrder?: string | null;
49
+ scope: WebhookOrderScope;
50
+ moved: WebhookOrderMoved;
51
+ };
52
+ /** Known semantic webhook change metadata. */
53
+ type WebhookChange = WebhookOrderChange | WebhookCommerceNotificationChange;
54
+ interface WebhookEvent<T extends Collection | string = Collection, TData = T extends Collection ? CollectionType<T> : Record<string, unknown>> {
55
+ collection: T;
56
+ operation: WebhookOperation;
57
+ data: TData;
58
+ eventType?: string;
59
+ change?: unknown;
60
+ timestamp?: string;
61
+ deliveryId?: string;
62
+ }
63
+ type WebhookHandler<T extends Collection | string = Collection, TData = T extends Collection ? CollectionType<T> : Record<string, unknown>> = (event: WebhookEvent<T, TData>) => Promise<void> | void;
64
+ interface WebhookOptions {
65
+ secret?: string;
66
+ /** Max accepted skew for signed webhook delivery timestamps. Default: 300s. */
67
+ toleranceSeconds?: number;
68
+ }
69
+ declare function isValidWebhookEvent(data: unknown): data is WebhookEvent;
70
+ /** Webhook event emitted when manual Admin Panel ordering changes. */
71
+ type OrderChangedWebhookEvent<T extends Collection | string = Collection, TData = T extends Collection ? CollectionType<T> : Record<string, unknown>> = WebhookEvent<T, TData> & {
72
+ operation: 'update';
73
+ eventType: typeof ORDER_CHANGED_EVENT_TYPE;
74
+ change: WebhookOrderChange;
75
+ };
76
+ declare const COMMERCE_NOTIFICATION_OPERATION: "notification";
77
+ declare const COMMERCE_NOTIFICATION_EVENTS: readonly ["orderPaid", "orderCanceled", "fulfillmentShipped", "orderDelivered", "returnRequested", "returnCompleted"];
78
+ type CommerceNotificationEventName = (typeof COMMERCE_NOTIFICATION_EVENTS)[number];
79
+ type CommerceNotificationSourceCollection = 'orders' | 'fulfillments' | 'returns';
80
+ type CommerceNotificationSource = {
81
+ collection: CommerceNotificationSourceCollection;
82
+ id: string | number;
83
+ };
84
+ type CommerceNotificationData = {
85
+ source?: CommerceNotificationSource;
86
+ orderId?: string | number;
87
+ orderNumber?: string;
88
+ status?: string;
89
+ totalAmount?: number;
90
+ currency?: string;
91
+ fulfillmentId?: string | number;
92
+ fulfillmentStatus?: string;
93
+ shippedAt?: string;
94
+ returnId?: string | number;
95
+ returnStatus?: string;
96
+ refundAmount?: number;
97
+ completedAt?: string;
98
+ };
99
+ type CommerceNotification = {
100
+ event: CommerceNotificationEventName;
101
+ intentId: string;
102
+ dedupeKey: string;
103
+ orderId?: string;
104
+ fulfillmentId?: string;
105
+ returnId?: string;
106
+ };
107
+ type WebhookCommerceNotificationChange = {
108
+ type: 'notification';
109
+ source: 'commerce-notifications';
110
+ event: CommerceNotificationEventName;
111
+ sourceCollection: CommerceNotificationSourceCollection;
112
+ sourceId: string | number;
113
+ };
114
+ /** Webhook event emitted for v1 commerce notification deliveries. */
115
+ type CommerceNotificationWebhookEvent = WebhookEvent<CommerceNotificationSourceCollection, CommerceNotificationData> & {
116
+ operation: typeof COMMERCE_NOTIFICATION_OPERATION;
117
+ eventType: typeof COMMERCE_NOTIFICATION_EVENT_TYPE;
118
+ change?: WebhookCommerceNotificationChange;
119
+ notification: CommerceNotification;
120
+ };
121
+ type CommerceEmailChannel = 'webhook' | 'provider';
122
+ type CommerceEmailEventConfig = {
123
+ enabled: boolean;
124
+ channel: CommerceEmailChannel;
125
+ template?: string;
126
+ };
127
+ type CommerceEmailConfig = {
128
+ version: 1;
129
+ commerceNotifications: Partial<Record<CommerceNotificationEventName, CommerceEmailEventConfig>>;
130
+ };
131
+ type CommerceEmailHandlerContext = {
132
+ event: CommerceNotificationWebhookEvent;
133
+ idempotencyKey: string;
134
+ };
135
+ type MaybePromise<T> = T | Promise<T>;
136
+ type CommerceEmailEventHandlers = Partial<Record<CommerceNotificationEventName, (context: CommerceEmailHandlerContext) => MaybePromise<void>>> & {
137
+ unhandled?: (event: WebhookEvent<string, unknown>) => MaybePromise<void>;
138
+ };
139
+ /**
140
+ * Returns true for semantic order-change webhooks emitted as update events.
141
+ *
142
+ * Use this guard with `ORDER_CHANGED_EVENT_TYPE` instead of filtering on
143
+ * `operation: "reorder"`. Tenant order-change webhooks intentionally keep
144
+ * `operation: "update"` for compatibility with existing webhook handlers.
145
+ */
146
+ declare function isOrderChangedWebhookEvent(event: unknown): event is OrderChangedWebhookEvent<string, unknown>;
147
+ /**
148
+ * Returns true for semantic commerce notification webhooks.
149
+ *
150
+ * Use `notification.intentId` and `notification.dedupeKey` for semantic
151
+ * idempotency. `deliveryId`, when present, identifies a delivery attempt for
152
+ * observability and is not the semantic notification identity.
153
+ */
154
+ declare function isCommerceNotificationWebhookEvent(event: unknown): event is CommerceNotificationWebhookEvent;
155
+ declare function getCommerceNotificationIdempotencyKey(event: Pick<CommerceNotificationWebhookEvent, 'notification'>): string;
156
+ declare function defineCommerceEmailConfig<TConfig extends CommerceEmailConfig>(config: TConfig): TConfig;
157
+ declare function createCommerceEmailWebhookHandler(handlers: CommerceEmailEventHandlers): WebhookHandler<string, unknown>;
158
+ /** Narrows a webhook event to a specific collection. */
159
+ declare function isWebhookCollection<TCollection extends string>(event: unknown, collection: TCollection): event is WebhookEvent<TCollection, unknown>;
160
+ /** Narrows a webhook event to a specific operation. */
161
+ declare function isWebhookOperation<TOperation extends string>(event: unknown, operation: TOperation): event is WebhookEvent<string, unknown> & {
162
+ operation: TOperation;
163
+ };
164
+ declare const CUSTOMER_PASSWORD_RESET_OPERATION: "password-reset";
165
+ type WebhookKnownOperation = CollectionWebhookOperation | typeof CUSTOMER_PASSWORD_RESET_OPERATION | typeof COMMERCE_NOTIFICATION_OPERATION;
166
+ interface CustomerPasswordResetWebhookData {
167
+ customerId: string | number;
168
+ email: string;
169
+ name: string;
170
+ resetPasswordToken: string;
171
+ resetPasswordExpiresAt: string;
172
+ }
173
+ type CustomerPasswordResetWebhookEvent = WebhookEvent<'customers', CustomerPasswordResetWebhookData> & {
174
+ operation: typeof CUSTOMER_PASSWORD_RESET_OPERATION;
175
+ };
176
+ type CustomerAuthWebhookEvent = CustomerPasswordResetWebhookEvent;
177
+ interface CustomerAuthWebhookHandlers {
178
+ passwordReset?: (data: CustomerPasswordResetWebhookData, event: CustomerPasswordResetWebhookEvent) => MaybePromise<void>;
179
+ unhandled?: (event: WebhookEvent<string, unknown>) => MaybePromise<void>;
180
+ }
181
+ declare function isCustomerPasswordResetWebhookEvent(event: WebhookEvent<string, unknown>): event is CustomerPasswordResetWebhookEvent;
182
+ declare function createCustomerAuthWebhookHandler(handlers: CustomerAuthWebhookHandlers): WebhookHandler<string, unknown>;
183
+ declare function handleWebhook<T extends Collection | string = Collection, TData = T extends Collection ? CollectionType<T> : Record<string, unknown>>(request: Request, handler: WebhookHandler<T, TData>, options?: WebhookOptions): Promise<Response>;
184
+ declare function createTypedWebhookHandler<T extends Collection>(collection: T, handler: (event: WebhookEvent<T>) => Promise<void> | void): WebhookHandler<T>;
185
+
186
+ export { type WebhookOrderChange as A, type WebhookOrderMoved as B, COMMERCE_NOTIFICATION_EVENTS as C, type WebhookOrderScope as D, createCommerceEmailWebhookHandler as E, createCustomerAuthWebhookHandler as F, createTypedWebhookHandler as G, defineCommerceEmailConfig as H, getCommerceNotificationIdempotencyKey as I, handleWebhook as J, isCommerceNotificationWebhookEvent as K, isCustomerPasswordResetWebhookEvent as L, isOrderChangedWebhookEvent as M, isValidWebhookEvent as N, ORDER_CHANGED_EVENT_TYPE as O, isWebhookCollection as P, isWebhookOperation as Q, type WebhookChange as W, COMMERCE_NOTIFICATION_EVENT_TYPE as a, COMMERCE_NOTIFICATION_OPERATION as b, CUSTOMER_PASSWORD_RESET_OPERATION as c, type CollectionWebhookOperation as d, type CommerceEmailChannel as e, type CommerceEmailConfig as f, type CommerceEmailEventConfig as g, type CommerceEmailEventHandlers as h, type CommerceEmailHandlerContext as i, type CommerceNotification as j, type CommerceNotificationData as k, type CommerceNotificationEventName as l, type CommerceNotificationSource as m, type CommerceNotificationSourceCollection as n, type CommerceNotificationWebhookEvent as o, type CustomerAuthWebhookEvent as p, type CustomerAuthWebhookHandlers as q, type CustomerPasswordResetWebhookData as r, type CustomerPasswordResetWebhookEvent as s, type OrderChangedWebhookEvent as t, type WebhookCommerceNotificationChange as u, type WebhookEvent as v, type WebhookHandler as w, type WebhookKnownOperation as x, type WebhookOperation as y, type WebhookOptions as z };
@@ -0,0 +1,186 @@
1
+ import { C as Collection } from './const-CdqCauHQ.js';
2
+ import { C as CollectionType } from './types-1ylMrCuW.js';
3
+ import './payload-types-C7tb7Xbs.js';
4
+
5
+ type WebhookOperation = string;
6
+ /**
7
+ * Semantic event type for manual Admin Panel ordering changes.
8
+ *
9
+ * Order-change webhooks remain `operation: "update"` events for compatibility.
10
+ * Do not filter on or emit `operation: "reorder"`; use this event type with
11
+ * `isOrderChangedWebhookEvent()` to distinguish ordering from normal content
12
+ * updates.
13
+ */
14
+ declare const ORDER_CHANGED_EVENT_TYPE: "collection.orderChanged";
15
+ /** Semantic event type for v1 commerce notification webhooks. */
16
+ declare const COMMERCE_NOTIFICATION_EVENT_TYPE: "commerce.notification";
17
+ /** Collection webhook operations emitted for tenant collection writes. */
18
+ type CollectionWebhookOperation = 'create' | 'update';
19
+ /** Describes the ordered area affected by an order-change webhook. */
20
+ type WebhookOrderScope = {
21
+ kind: 'collection';
22
+ collection: string;
23
+ } | {
24
+ kind: 'join';
25
+ collection: string;
26
+ field: string;
27
+ id: string | number;
28
+ };
29
+ /** Identifies the public moved document for the ordered scope. */
30
+ type WebhookOrderMoved = {
31
+ collection: string;
32
+ id: string | number;
33
+ relatedCollection?: string;
34
+ relatedId?: string | number;
35
+ };
36
+ /** Metadata attached to `collection.orderChanged` webhook events. */
37
+ type WebhookOrderChange = {
38
+ type: 'order';
39
+ source: 'payload-orderable';
40
+ /**
41
+ * Diagnostic Payload order field name.
42
+ *
43
+ * This may contain hidden implementation field names. Application routing
44
+ * should use `change.scope` and `change.moved` instead.
45
+ */
46
+ orderableFieldName?: string;
47
+ previousOrder?: string | null;
48
+ nextOrder?: string | null;
49
+ scope: WebhookOrderScope;
50
+ moved: WebhookOrderMoved;
51
+ };
52
+ /** Known semantic webhook change metadata. */
53
+ type WebhookChange = WebhookOrderChange | WebhookCommerceNotificationChange;
54
+ interface WebhookEvent<T extends Collection | string = Collection, TData = T extends Collection ? CollectionType<T> : Record<string, unknown>> {
55
+ collection: T;
56
+ operation: WebhookOperation;
57
+ data: TData;
58
+ eventType?: string;
59
+ change?: unknown;
60
+ timestamp?: string;
61
+ deliveryId?: string;
62
+ }
63
+ type WebhookHandler<T extends Collection | string = Collection, TData = T extends Collection ? CollectionType<T> : Record<string, unknown>> = (event: WebhookEvent<T, TData>) => Promise<void> | void;
64
+ interface WebhookOptions {
65
+ secret?: string;
66
+ /** Max accepted skew for signed webhook delivery timestamps. Default: 300s. */
67
+ toleranceSeconds?: number;
68
+ }
69
+ declare function isValidWebhookEvent(data: unknown): data is WebhookEvent;
70
+ /** Webhook event emitted when manual Admin Panel ordering changes. */
71
+ type OrderChangedWebhookEvent<T extends Collection | string = Collection, TData = T extends Collection ? CollectionType<T> : Record<string, unknown>> = WebhookEvent<T, TData> & {
72
+ operation: 'update';
73
+ eventType: typeof ORDER_CHANGED_EVENT_TYPE;
74
+ change: WebhookOrderChange;
75
+ };
76
+ declare const COMMERCE_NOTIFICATION_OPERATION: "notification";
77
+ declare const COMMERCE_NOTIFICATION_EVENTS: readonly ["orderPaid", "orderCanceled", "fulfillmentShipped", "orderDelivered", "returnRequested", "returnCompleted"];
78
+ type CommerceNotificationEventName = (typeof COMMERCE_NOTIFICATION_EVENTS)[number];
79
+ type CommerceNotificationSourceCollection = 'orders' | 'fulfillments' | 'returns';
80
+ type CommerceNotificationSource = {
81
+ collection: CommerceNotificationSourceCollection;
82
+ id: string | number;
83
+ };
84
+ type CommerceNotificationData = {
85
+ source?: CommerceNotificationSource;
86
+ orderId?: string | number;
87
+ orderNumber?: string;
88
+ status?: string;
89
+ totalAmount?: number;
90
+ currency?: string;
91
+ fulfillmentId?: string | number;
92
+ fulfillmentStatus?: string;
93
+ shippedAt?: string;
94
+ returnId?: string | number;
95
+ returnStatus?: string;
96
+ refundAmount?: number;
97
+ completedAt?: string;
98
+ };
99
+ type CommerceNotification = {
100
+ event: CommerceNotificationEventName;
101
+ intentId: string;
102
+ dedupeKey: string;
103
+ orderId?: string;
104
+ fulfillmentId?: string;
105
+ returnId?: string;
106
+ };
107
+ type WebhookCommerceNotificationChange = {
108
+ type: 'notification';
109
+ source: 'commerce-notifications';
110
+ event: CommerceNotificationEventName;
111
+ sourceCollection: CommerceNotificationSourceCollection;
112
+ sourceId: string | number;
113
+ };
114
+ /** Webhook event emitted for v1 commerce notification deliveries. */
115
+ type CommerceNotificationWebhookEvent = WebhookEvent<CommerceNotificationSourceCollection, CommerceNotificationData> & {
116
+ operation: typeof COMMERCE_NOTIFICATION_OPERATION;
117
+ eventType: typeof COMMERCE_NOTIFICATION_EVENT_TYPE;
118
+ change?: WebhookCommerceNotificationChange;
119
+ notification: CommerceNotification;
120
+ };
121
+ type CommerceEmailChannel = 'webhook' | 'provider';
122
+ type CommerceEmailEventConfig = {
123
+ enabled: boolean;
124
+ channel: CommerceEmailChannel;
125
+ template?: string;
126
+ };
127
+ type CommerceEmailConfig = {
128
+ version: 1;
129
+ commerceNotifications: Partial<Record<CommerceNotificationEventName, CommerceEmailEventConfig>>;
130
+ };
131
+ type CommerceEmailHandlerContext = {
132
+ event: CommerceNotificationWebhookEvent;
133
+ idempotencyKey: string;
134
+ };
135
+ type MaybePromise<T> = T | Promise<T>;
136
+ type CommerceEmailEventHandlers = Partial<Record<CommerceNotificationEventName, (context: CommerceEmailHandlerContext) => MaybePromise<void>>> & {
137
+ unhandled?: (event: WebhookEvent<string, unknown>) => MaybePromise<void>;
138
+ };
139
+ /**
140
+ * Returns true for semantic order-change webhooks emitted as update events.
141
+ *
142
+ * Use this guard with `ORDER_CHANGED_EVENT_TYPE` instead of filtering on
143
+ * `operation: "reorder"`. Tenant order-change webhooks intentionally keep
144
+ * `operation: "update"` for compatibility with existing webhook handlers.
145
+ */
146
+ declare function isOrderChangedWebhookEvent(event: unknown): event is OrderChangedWebhookEvent<string, unknown>;
147
+ /**
148
+ * Returns true for semantic commerce notification webhooks.
149
+ *
150
+ * Use `notification.intentId` and `notification.dedupeKey` for semantic
151
+ * idempotency. `deliveryId`, when present, identifies a delivery attempt for
152
+ * observability and is not the semantic notification identity.
153
+ */
154
+ declare function isCommerceNotificationWebhookEvent(event: unknown): event is CommerceNotificationWebhookEvent;
155
+ declare function getCommerceNotificationIdempotencyKey(event: Pick<CommerceNotificationWebhookEvent, 'notification'>): string;
156
+ declare function defineCommerceEmailConfig<TConfig extends CommerceEmailConfig>(config: TConfig): TConfig;
157
+ declare function createCommerceEmailWebhookHandler(handlers: CommerceEmailEventHandlers): WebhookHandler<string, unknown>;
158
+ /** Narrows a webhook event to a specific collection. */
159
+ declare function isWebhookCollection<TCollection extends string>(event: unknown, collection: TCollection): event is WebhookEvent<TCollection, unknown>;
160
+ /** Narrows a webhook event to a specific operation. */
161
+ declare function isWebhookOperation<TOperation extends string>(event: unknown, operation: TOperation): event is WebhookEvent<string, unknown> & {
162
+ operation: TOperation;
163
+ };
164
+ declare const CUSTOMER_PASSWORD_RESET_OPERATION: "password-reset";
165
+ type WebhookKnownOperation = CollectionWebhookOperation | typeof CUSTOMER_PASSWORD_RESET_OPERATION | typeof COMMERCE_NOTIFICATION_OPERATION;
166
+ interface CustomerPasswordResetWebhookData {
167
+ customerId: string | number;
168
+ email: string;
169
+ name: string;
170
+ resetPasswordToken: string;
171
+ resetPasswordExpiresAt: string;
172
+ }
173
+ type CustomerPasswordResetWebhookEvent = WebhookEvent<'customers', CustomerPasswordResetWebhookData> & {
174
+ operation: typeof CUSTOMER_PASSWORD_RESET_OPERATION;
175
+ };
176
+ type CustomerAuthWebhookEvent = CustomerPasswordResetWebhookEvent;
177
+ interface CustomerAuthWebhookHandlers {
178
+ passwordReset?: (data: CustomerPasswordResetWebhookData, event: CustomerPasswordResetWebhookEvent) => MaybePromise<void>;
179
+ unhandled?: (event: WebhookEvent<string, unknown>) => MaybePromise<void>;
180
+ }
181
+ declare function isCustomerPasswordResetWebhookEvent(event: WebhookEvent<string, unknown>): event is CustomerPasswordResetWebhookEvent;
182
+ declare function createCustomerAuthWebhookHandler(handlers: CustomerAuthWebhookHandlers): WebhookHandler<string, unknown>;
183
+ declare function handleWebhook<T extends Collection | string = Collection, TData = T extends Collection ? CollectionType<T> : Record<string, unknown>>(request: Request, handler: WebhookHandler<T, TData>, options?: WebhookOptions): Promise<Response>;
184
+ declare function createTypedWebhookHandler<T extends Collection>(collection: T, handler: (event: WebhookEvent<T>) => Promise<void> | void): WebhookHandler<T>;
185
+
186
+ export { type WebhookOrderChange as A, type WebhookOrderMoved as B, COMMERCE_NOTIFICATION_EVENTS as C, type WebhookOrderScope as D, createCommerceEmailWebhookHandler as E, createCustomerAuthWebhookHandler as F, createTypedWebhookHandler as G, defineCommerceEmailConfig as H, getCommerceNotificationIdempotencyKey as I, handleWebhook as J, isCommerceNotificationWebhookEvent as K, isCustomerPasswordResetWebhookEvent as L, isOrderChangedWebhookEvent as M, isValidWebhookEvent as N, ORDER_CHANGED_EVENT_TYPE as O, isWebhookCollection as P, isWebhookOperation as Q, type WebhookChange as W, COMMERCE_NOTIFICATION_EVENT_TYPE as a, COMMERCE_NOTIFICATION_OPERATION as b, CUSTOMER_PASSWORD_RESET_OPERATION as c, type CollectionWebhookOperation as d, type CommerceEmailChannel as e, type CommerceEmailConfig as f, type CommerceEmailEventConfig as g, type CommerceEmailEventHandlers as h, type CommerceEmailHandlerContext as i, type CommerceNotification as j, type CommerceNotificationData as k, type CommerceNotificationEventName as l, type CommerceNotificationSource as m, type CommerceNotificationSourceCollection as n, type CommerceNotificationWebhookEvent as o, type CustomerAuthWebhookEvent as p, type CustomerAuthWebhookHandlers as q, type CustomerPasswordResetWebhookData as r, type CustomerPasswordResetWebhookEvent as s, type OrderChangedWebhookEvent as t, type WebhookCommerceNotificationChange as u, type WebhookEvent as v, type WebhookHandler as w, type WebhookKnownOperation as x, type WebhookOperation as y, type WebhookOptions as z };