@01.software/sdk 0.21.0 → 0.22.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@01.software/sdk",
3
- "version": "0.21.0",
3
+ "version": "0.22.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",
@@ -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,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 };