@01.software/sdk 0.21.0 → 0.23.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.
package/dist/webhook.d.ts CHANGED
@@ -1,3 +1,42 @@
1
- export { d as CUSTOMER_PASSWORD_RESET_OPERATION, g as CustomerAuthWebhookEvent, h as CustomerAuthWebhookHandlers, e as CustomerPasswordResetWebhookData, f as CustomerPasswordResetWebhookEvent, a as WebhookEvent, b as WebhookHandler, W as WebhookOperation, c as WebhookOptions, k as createCustomerAuthWebhookHandler, m as createTypedWebhookHandler, l as handleWebhook, j as isCustomerPasswordResetWebhookEvent, i as isValidWebhookEvent } from './webhook-C6vne8Ve.js';
2
- import './const-BNJRuk3V.js';
3
- import './payload-types-D7lnu9By.js';
1
+ import { C as Collection } from './const-CMdmNgEs.js';
2
+ import { C as CollectionType } from './types-BQqfXbB2.js';
3
+ import './payload-types-D8-G1PiT.js';
4
+
5
+ type WebhookOperation = string;
6
+ interface WebhookEvent<T extends Collection | string = Collection, TData = T extends Collection ? CollectionType<T> : Record<string, unknown>> {
7
+ collection: T;
8
+ operation: WebhookOperation;
9
+ data: TData;
10
+ timestamp?: string;
11
+ deliveryId?: string;
12
+ }
13
+ type WebhookHandler<T extends Collection | string = Collection, TData = T extends Collection ? CollectionType<T> : Record<string, unknown>> = (event: WebhookEvent<T, TData>) => Promise<void> | void;
14
+ interface WebhookOptions {
15
+ secret?: string;
16
+ /** Max accepted skew for signed webhook delivery timestamps. Default: 300s. */
17
+ toleranceSeconds?: number;
18
+ }
19
+ declare function isValidWebhookEvent(data: unknown): data is WebhookEvent;
20
+ declare const CUSTOMER_PASSWORD_RESET_OPERATION: "password-reset";
21
+ interface CustomerPasswordResetWebhookData {
22
+ customerId: string | number;
23
+ email: string;
24
+ name: string;
25
+ resetPasswordToken: string;
26
+ resetPasswordExpiresAt: string;
27
+ }
28
+ type CustomerPasswordResetWebhookEvent = WebhookEvent<'customers', CustomerPasswordResetWebhookData> & {
29
+ operation: typeof CUSTOMER_PASSWORD_RESET_OPERATION;
30
+ };
31
+ type CustomerAuthWebhookEvent = CustomerPasswordResetWebhookEvent;
32
+ type MaybePromise<T> = T | Promise<T>;
33
+ interface CustomerAuthWebhookHandlers {
34
+ passwordReset?: (data: CustomerPasswordResetWebhookData, event: CustomerPasswordResetWebhookEvent) => MaybePromise<void>;
35
+ unhandled?: (event: WebhookEvent<string, unknown>) => MaybePromise<void>;
36
+ }
37
+ declare function isCustomerPasswordResetWebhookEvent(event: WebhookEvent<string, unknown>): event is CustomerPasswordResetWebhookEvent;
38
+ declare function createCustomerAuthWebhookHandler(handlers: CustomerAuthWebhookHandlers): WebhookHandler<string, unknown>;
39
+ 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>;
40
+ declare function createTypedWebhookHandler<T extends Collection>(collection: T, handler: (event: WebhookEvent<T>) => Promise<void> | void): WebhookHandler<T>;
41
+
42
+ export { CUSTOMER_PASSWORD_RESET_OPERATION, type CustomerAuthWebhookEvent, type CustomerAuthWebhookHandlers, type CustomerPasswordResetWebhookData, type CustomerPasswordResetWebhookEvent, type WebhookEvent, type WebhookHandler, type WebhookOperation, type WebhookOptions, createCustomerAuthWebhookHandler, createTypedWebhookHandler, handleWebhook, isCustomerPasswordResetWebhookEvent, isValidWebhookEvent };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@01.software/sdk",
3
- "version": "0.21.0",
3
+ "version": "0.23.0",
4
4
  "description": "01.software SDK",
5
5
  "author": "<office@01.works>",
6
6
  "keywords": [],
@@ -19,6 +19,16 @@
19
19
  "default": "./dist/index.cjs"
20
20
  }
21
21
  },
22
+ "./server": {
23
+ "import": {
24
+ "types": "./dist/server.d.ts",
25
+ "default": "./dist/server.js"
26
+ },
27
+ "require": {
28
+ "types": "./dist/server.d.cts",
29
+ "default": "./dist/server.cjs"
30
+ }
31
+ },
22
32
  "./analytics": {
23
33
  "import": {
24
34
  "types": "./dist/analytics.d.ts",
@@ -148,8 +158,8 @@
148
158
  "shadcn": "^3.6.3",
149
159
  "tsup": "^8.3.7",
150
160
  "vitest": "^3.2.3",
151
- "@repo/eslint-config": "0.0.0",
152
- "@repo/typescript-config": "0.0.0"
161
+ "@repo/typescript-config": "0.0.0",
162
+ "@repo/eslint-config": "0.0.0"
153
163
  },
154
164
  "dependencies": {
155
165
  "@payloadcms/richtext-lexical": ">=3.82.0",
@@ -187,7 +197,8 @@
187
197
  "lint": "eslint ./src",
188
198
  "test": "vitest run",
189
199
  "test:react": "vitest run --config vitest.config.react.ts",
190
- "test:all": "vitest run && vitest run --config vitest.config.react.ts",
200
+ "test:types": "tsc --noEmit -p tsconfig.type-tests.json",
201
+ "test:all": "vitest run && vitest run --config vitest.config.react.ts && pnpm run test:types",
191
202
  "test:watch": "vitest --watch",
192
203
  "test:publish": "publint --strict && attw --pack --ignore-rules no-resolution",
193
204
  "check-types": "tsc --noEmit",
@@ -1,24 +0,0 @@
1
- import { C as Config } from './payload-types-D7lnu9By.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
- * Internal collections that should not be exposed via SDK.
10
- * Includes Payload system collections and admin-only collections.
11
- */
12
- declare const INTERNAL_COLLECTIONS: readonly ["users", "payload-kv", "payload-locked-documents", "payload-preferences", "payload-migrations", "field-configs", "system-media", "track-assets", "audiences", "email-logs", "api-usage", "tenant-analytics-daily", "analytics-event-schemas", "subscriptions", "billing-history", "order-status-logs", "api-keys", "personal-access-tokens", "tenant-entitlements", "webhook-events", "webhook-deliveries", "audit-logs", "plans", "webhooks", "event-registrations"];
13
- /**
14
- * Array of all public collection names for runtime use (e.g., Zod enum validation).
15
- * This is the single source of truth for which collections are publicly accessible via SDK.
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", "customer-groups", "carts", "cart-items", "discounts", "promotions", "shipping-policies", "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", "reports", "community-bans", "event-calendars", "events", "event-categories", "event-occurrences", "event-tags"];
18
- /**
19
- * Public collections available for SDK access.
20
- * Derived from the COLLECTIONS array (single source of truth).
21
- */
22
- type PublicCollection = (typeof COLLECTIONS)[number];
23
-
24
- export { type Collection as C, INTERNAL_COLLECTIONS as I, type PublicCollection as P, COLLECTIONS as a };
@@ -1,24 +0,0 @@
1
- import { C as Config } from './payload-types-D7lnu9By.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
- * Internal collections that should not be exposed via SDK.
10
- * Includes Payload system collections and admin-only collections.
11
- */
12
- declare const INTERNAL_COLLECTIONS: readonly ["users", "payload-kv", "payload-locked-documents", "payload-preferences", "payload-migrations", "field-configs", "system-media", "track-assets", "audiences", "email-logs", "api-usage", "tenant-analytics-daily", "analytics-event-schemas", "subscriptions", "billing-history", "order-status-logs", "api-keys", "personal-access-tokens", "tenant-entitlements", "webhook-events", "webhook-deliveries", "audit-logs", "plans", "webhooks", "event-registrations"];
13
- /**
14
- * Array of all public collection names for runtime use (e.g., Zod enum validation).
15
- * This is the single source of truth for which collections are publicly accessible via SDK.
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", "customer-groups", "carts", "cart-items", "discounts", "promotions", "shipping-policies", "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", "reports", "community-bans", "event-calendars", "events", "event-categories", "event-occurrences", "event-tags"];
18
- /**
19
- * Public collections available for SDK access.
20
- * Derived from the COLLECTIONS array (single source of truth).
21
- */
22
- type PublicCollection = (typeof COLLECTIONS)[number];
23
-
24
- export { type Collection as C, INTERNAL_COLLECTIONS as I, type PublicCollection as P, COLLECTIONS as a };
@@ -1,61 +0,0 @@
1
- import { C as Collection } from './const-BApEF1Hu.cjs';
2
- import { l as CustomerProfile, h as Post, m as Comment, n as Reaction, C as Config } from './payload-types-D7lnu9By.cjs';
3
-
4
- type PublicCustomerProfile = Omit<CustomerProfile, 'tenant' | 'customer' | 'isPublic' | 'anonymizedAt' | 'metadata'>;
5
- type PublicProfileRelation = string | PublicCustomerProfile;
6
- type PublicPost = Omit<Post, 'authorProfile' | 'lastCommentByProfile'> & {
7
- authorProfile: PublicProfileRelation;
8
- lastCommentByProfile?: PublicProfileRelation | null;
9
- };
10
- type PublicComment = Omit<Comment, 'authorProfile'> & {
11
- authorProfile: PublicProfileRelation;
12
- };
13
- type PublicReaction = Omit<Reaction, 'actorProfile'> & {
14
- actorProfile: PublicProfileRelation;
15
- };
16
- type PublicCollectionOverrides = {
17
- 'customer-profiles': PublicCustomerProfile;
18
- posts: PublicPost;
19
- comments: PublicComment;
20
- reactions: PublicReaction;
21
- };
22
- type CollectionType<T extends string> = T extends keyof PublicCollectionOverrides ? PublicCollectionOverrides[T] : T extends keyof Config['collections'] ? Config['collections'][T] : never;
23
-
24
- type WebhookOperation = string;
25
- interface WebhookEvent<T extends Collection | string = Collection, TData = T extends Collection ? CollectionType<T> : Record<string, unknown>> {
26
- collection: T;
27
- operation: WebhookOperation;
28
- data: TData;
29
- timestamp?: string;
30
- deliveryId?: string;
31
- }
32
- type WebhookHandler<T extends Collection | string = Collection, TData = T extends Collection ? CollectionType<T> : Record<string, unknown>> = (event: WebhookEvent<T, TData>) => Promise<void> | void;
33
- interface WebhookOptions {
34
- secret?: string;
35
- /** Max accepted skew for signed webhook delivery timestamps. Default: 300s. */
36
- toleranceSeconds?: number;
37
- }
38
- declare function isValidWebhookEvent(data: unknown): data is WebhookEvent;
39
- declare const CUSTOMER_PASSWORD_RESET_OPERATION: "password-reset";
40
- interface CustomerPasswordResetWebhookData {
41
- customerId: string | number;
42
- email: string;
43
- name: string;
44
- resetPasswordToken: string;
45
- resetPasswordExpiresAt: string;
46
- }
47
- type CustomerPasswordResetWebhookEvent = WebhookEvent<'customers', CustomerPasswordResetWebhookData> & {
48
- operation: typeof CUSTOMER_PASSWORD_RESET_OPERATION;
49
- };
50
- type CustomerAuthWebhookEvent = CustomerPasswordResetWebhookEvent;
51
- type MaybePromise<T> = T | Promise<T>;
52
- interface CustomerAuthWebhookHandlers {
53
- passwordReset?: (data: CustomerPasswordResetWebhookData, event: CustomerPasswordResetWebhookEvent) => MaybePromise<void>;
54
- unhandled?: (event: WebhookEvent<string, unknown>) => MaybePromise<void>;
55
- }
56
- declare function isCustomerPasswordResetWebhookEvent(event: WebhookEvent<string, unknown>): event is CustomerPasswordResetWebhookEvent;
57
- declare function createCustomerAuthWebhookHandler(handlers: CustomerAuthWebhookHandlers): WebhookHandler<string, unknown>;
58
- 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>;
59
- declare function createTypedWebhookHandler<T extends Collection>(collection: T, handler: (event: WebhookEvent<T>) => Promise<void> | void): WebhookHandler<T>;
60
-
61
- export { type CollectionType as C, type WebhookOperation as W, type WebhookEvent as a, type WebhookHandler as b, type WebhookOptions as c, CUSTOMER_PASSWORD_RESET_OPERATION as d, type CustomerPasswordResetWebhookData as e, type CustomerPasswordResetWebhookEvent as f, type CustomerAuthWebhookEvent as g, type CustomerAuthWebhookHandlers as h, isValidWebhookEvent as i, isCustomerPasswordResetWebhookEvent as j, createCustomerAuthWebhookHandler as k, handleWebhook as l, createTypedWebhookHandler as m };
@@ -1,61 +0,0 @@
1
- import { C as Collection } from './const-BNJRuk3V.js';
2
- import { l as CustomerProfile, h as Post, m as Comment, n as Reaction, C as Config } from './payload-types-D7lnu9By.js';
3
-
4
- type PublicCustomerProfile = Omit<CustomerProfile, 'tenant' | 'customer' | 'isPublic' | 'anonymizedAt' | 'metadata'>;
5
- type PublicProfileRelation = string | PublicCustomerProfile;
6
- type PublicPost = Omit<Post, 'authorProfile' | 'lastCommentByProfile'> & {
7
- authorProfile: PublicProfileRelation;
8
- lastCommentByProfile?: PublicProfileRelation | null;
9
- };
10
- type PublicComment = Omit<Comment, 'authorProfile'> & {
11
- authorProfile: PublicProfileRelation;
12
- };
13
- type PublicReaction = Omit<Reaction, 'actorProfile'> & {
14
- actorProfile: PublicProfileRelation;
15
- };
16
- type PublicCollectionOverrides = {
17
- 'customer-profiles': PublicCustomerProfile;
18
- posts: PublicPost;
19
- comments: PublicComment;
20
- reactions: PublicReaction;
21
- };
22
- type CollectionType<T extends string> = T extends keyof PublicCollectionOverrides ? PublicCollectionOverrides[T] : T extends keyof Config['collections'] ? Config['collections'][T] : never;
23
-
24
- type WebhookOperation = string;
25
- interface WebhookEvent<T extends Collection | string = Collection, TData = T extends Collection ? CollectionType<T> : Record<string, unknown>> {
26
- collection: T;
27
- operation: WebhookOperation;
28
- data: TData;
29
- timestamp?: string;
30
- deliveryId?: string;
31
- }
32
- type WebhookHandler<T extends Collection | string = Collection, TData = T extends Collection ? CollectionType<T> : Record<string, unknown>> = (event: WebhookEvent<T, TData>) => Promise<void> | void;
33
- interface WebhookOptions {
34
- secret?: string;
35
- /** Max accepted skew for signed webhook delivery timestamps. Default: 300s. */
36
- toleranceSeconds?: number;
37
- }
38
- declare function isValidWebhookEvent(data: unknown): data is WebhookEvent;
39
- declare const CUSTOMER_PASSWORD_RESET_OPERATION: "password-reset";
40
- interface CustomerPasswordResetWebhookData {
41
- customerId: string | number;
42
- email: string;
43
- name: string;
44
- resetPasswordToken: string;
45
- resetPasswordExpiresAt: string;
46
- }
47
- type CustomerPasswordResetWebhookEvent = WebhookEvent<'customers', CustomerPasswordResetWebhookData> & {
48
- operation: typeof CUSTOMER_PASSWORD_RESET_OPERATION;
49
- };
50
- type CustomerAuthWebhookEvent = CustomerPasswordResetWebhookEvent;
51
- type MaybePromise<T> = T | Promise<T>;
52
- interface CustomerAuthWebhookHandlers {
53
- passwordReset?: (data: CustomerPasswordResetWebhookData, event: CustomerPasswordResetWebhookEvent) => MaybePromise<void>;
54
- unhandled?: (event: WebhookEvent<string, unknown>) => MaybePromise<void>;
55
- }
56
- declare function isCustomerPasswordResetWebhookEvent(event: WebhookEvent<string, unknown>): event is CustomerPasswordResetWebhookEvent;
57
- declare function createCustomerAuthWebhookHandler(handlers: CustomerAuthWebhookHandlers): WebhookHandler<string, unknown>;
58
- 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>;
59
- declare function createTypedWebhookHandler<T extends Collection>(collection: T, handler: (event: WebhookEvent<T>) => Promise<void> | void): WebhookHandler<T>;
60
-
61
- export { type CollectionType as C, type WebhookOperation as W, type WebhookEvent as a, type WebhookHandler as b, type WebhookOptions as c, CUSTOMER_PASSWORD_RESET_OPERATION as d, type CustomerPasswordResetWebhookData as e, type CustomerPasswordResetWebhookEvent as f, type CustomerAuthWebhookEvent as g, type CustomerAuthWebhookHandlers as h, isValidWebhookEvent as i, isCustomerPasswordResetWebhookEvent as j, createCustomerAuthWebhookHandler as k, handleWebhook as l, createTypedWebhookHandler as m };