@01.software/sdk 0.17.0 → 0.18.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/README.md +15 -6
- package/dist/{const-D2K5HxpP.d.cts → const-_gW__LA1.d.ts} +3 -3
- package/dist/{const-DG8TrouX.d.ts → const-zEoxAfGX.d.cts} +3 -3
- package/dist/index.cjs +37 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -15
- package/dist/index.d.ts +6 -15
- package/dist/index.js +37 -23
- package/dist/index.js.map +1 -1
- package/dist/{payload-types-CMoyAOjJ.d.cts → payload-types-Cwnj_qN4.d.cts} +578 -78
- package/dist/{payload-types-CMoyAOjJ.d.ts → payload-types-Cwnj_qN4.d.ts} +578 -78
- package/dist/realtime.d.cts +2 -2
- package/dist/realtime.d.ts +2 -2
- package/dist/ui/form.d.cts +1 -1
- package/dist/ui/form.d.ts +1 -1
- package/dist/ui/video.d.cts +1 -1
- package/dist/ui/video.d.ts +1 -1
- package/dist/webhook-Ce9uNv5c.d.cts +58 -0
- package/dist/webhook-ger4JSeS.d.ts +58 -0
- package/dist/webhook.cjs +29 -1
- package/dist/webhook.cjs.map +1 -1
- package/dist/webhook.d.cts +3 -3
- package/dist/webhook.d.ts +3 -3
- package/dist/webhook.js +29 -1
- package/dist/webhook.js.map +1 -1
- package/package.json +1 -1
- package/dist/webhook-Dm2zz7FQ.d.cts +0 -20
- package/dist/webhook-IhuUWnt5.d.ts +0 -20
package/README.md
CHANGED
|
@@ -307,7 +307,6 @@ login({ email: 'user@example.com', password: 'password' })
|
|
|
307
307
|
// Other customer mutations
|
|
308
308
|
client.query.useCustomerForgotPassword()
|
|
309
309
|
client.query.useCustomerResetPassword()
|
|
310
|
-
client.query.useCustomerVerifyEmail()
|
|
311
310
|
client.query.useCustomerChangePassword()
|
|
312
311
|
|
|
313
312
|
// Customer cache utilities
|
|
@@ -349,11 +348,10 @@ const orders = await client.commerce.orders.listMine({
|
|
|
349
348
|
status: 'paid',
|
|
350
349
|
})
|
|
351
350
|
|
|
352
|
-
// Password
|
|
351
|
+
// Password
|
|
353
352
|
await client.customer.auth.forgotPassword('john@example.com')
|
|
354
353
|
await client.customer.auth.resetPassword(token, newPassword)
|
|
355
354
|
await client.customer.auth.changePassword(currentPassword, newPassword)
|
|
356
|
-
await client.customer.auth.verifyEmail(verificationToken)
|
|
357
355
|
```
|
|
358
356
|
|
|
359
357
|
### Commerce Orders (ServerClient-only writes)
|
|
@@ -440,7 +438,11 @@ await server.community.moderation.unbanCustomer({ customerId })
|
|
|
440
438
|
### Webhook
|
|
441
439
|
|
|
442
440
|
```typescript
|
|
443
|
-
import {
|
|
441
|
+
import {
|
|
442
|
+
handleWebhook,
|
|
443
|
+
createCustomerAuthWebhookHandler,
|
|
444
|
+
createTypedWebhookHandler,
|
|
445
|
+
} from '@01.software/sdk'
|
|
444
446
|
|
|
445
447
|
// Basic handler
|
|
446
448
|
export async function POST(request: Request) {
|
|
@@ -461,11 +463,18 @@ const handler = createTypedWebhookHandler('orders', async (event) => {
|
|
|
461
463
|
// event.data is typed as Order
|
|
462
464
|
console.log(event.data.orderNumber)
|
|
463
465
|
})
|
|
466
|
+
|
|
467
|
+
// Customer auth helper
|
|
468
|
+
const customerAuthHandler = createCustomerAuthWebhookHandler({
|
|
469
|
+
passwordReset: async ({ email, resetPasswordToken }) => {
|
|
470
|
+
await sendPasswordResetEmail(email, resetPasswordToken)
|
|
471
|
+
},
|
|
472
|
+
})
|
|
464
473
|
```
|
|
465
474
|
|
|
466
475
|
## Supported Collections
|
|
467
476
|
|
|
468
|
-
Source of truth: `packages/sdk/src/core/collection/const.ts` (`COLLECTIONS`:
|
|
477
|
+
Source of truth: `packages/sdk/src/core/collection/const.ts` (`COLLECTIONS`: 74).
|
|
469
478
|
|
|
470
479
|
| Category | Collections |
|
|
471
480
|
| --- | --- |
|
|
@@ -484,6 +493,7 @@ Source of truth: `packages/sdk/src/core/collection/const.ts` (`COLLECTIONS`: 70)
|
|
|
484
493
|
| Media | `images` |
|
|
485
494
|
| Forms | `forms`, `form-submissions` |
|
|
486
495
|
| Community | `threads`, `comments`, `reactions`, `reaction-types`, `bookmarks`, `thread-categories`, `reports`, `community-bans` |
|
|
496
|
+
| Events | `event-calendars`, `events`, `event-occurrences`, `event-tags` |
|
|
487
497
|
|
|
488
498
|
## Utilities
|
|
489
499
|
|
|
@@ -618,7 +628,6 @@ P5 also adds JWT-`jti` revocation: `revokeCustomerJti(jti, ttl)` on the server i
|
|
|
618
628
|
| Collection | Old | New |
|
|
619
629
|
|---|---|---|
|
|
620
630
|
| Customers | `socialId` | `providerUserId` |
|
|
621
|
-
| Customers | `isVerified` | `isEmailVerified` |
|
|
622
631
|
| Customers | `loginAttempts` | `loginAttemptCount` |
|
|
623
632
|
| Customers | `resetPasswordExpiry` | `resetPasswordExpiresAt` |
|
|
624
633
|
| Orders, Carts | `shippingFee` | `shippingAmount` |
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as Config } from './payload-types-
|
|
1
|
+
import { C as Config } from './payload-types-Cwnj_qN4.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Collection type derived from Payload Config.
|
|
@@ -9,12 +9,12 @@ type Collection = keyof Config['collections'];
|
|
|
9
9
|
* Internal collections that should not be exposed via SDK.
|
|
10
10
|
* Includes Payload system collections and admin-only collections.
|
|
11
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", "
|
|
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
13
|
/**
|
|
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", "customer-groups", "carts", "cart-items", "discounts", "promotions", "shipping-policies", "documents", "document-categories", "document-types", "posts", "post-authors", "post-categories", "post-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", "threads", "comments", "reactions", "reaction-types", "bookmarks", "thread-categories", "reports", "community-bans"];
|
|
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", "posts", "post-authors", "post-categories", "post-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", "threads", "comments", "reactions", "reaction-types", "bookmarks", "thread-categories", "reports", "community-bans", "event-calendars", "events", "event-occurrences", "event-tags"];
|
|
18
18
|
/**
|
|
19
19
|
* Public collections available for SDK access.
|
|
20
20
|
* Derived from the COLLECTIONS array (single source of truth).
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as Config } from './payload-types-
|
|
1
|
+
import { C as Config } from './payload-types-Cwnj_qN4.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Collection type derived from Payload Config.
|
|
@@ -9,12 +9,12 @@ type Collection = keyof Config['collections'];
|
|
|
9
9
|
* Internal collections that should not be exposed via SDK.
|
|
10
10
|
* Includes Payload system collections and admin-only collections.
|
|
11
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", "
|
|
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
13
|
/**
|
|
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", "customer-groups", "carts", "cart-items", "discounts", "promotions", "shipping-policies", "documents", "document-categories", "document-types", "posts", "post-authors", "post-categories", "post-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", "threads", "comments", "reactions", "reaction-types", "bookmarks", "thread-categories", "reports", "community-bans"];
|
|
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", "posts", "post-authors", "post-categories", "post-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", "threads", "comments", "reactions", "reaction-types", "bookmarks", "thread-categories", "reports", "community-bans", "event-calendars", "events", "event-occurrences", "event-tags"];
|
|
18
18
|
/**
|
|
19
19
|
* Public collections available for SDK access.
|
|
20
20
|
* Derived from the COLLECTIONS array (single source of truth).
|
package/dist/index.cjs
CHANGED
|
@@ -24,6 +24,7 @@ __export(src_exports, {
|
|
|
24
24
|
AuthError: () => AuthError,
|
|
25
25
|
BaseApi: () => BaseApi,
|
|
26
26
|
COLLECTIONS: () => COLLECTIONS,
|
|
27
|
+
CUSTOMER_PASSWORD_RESET_OPERATION: () => CUSTOMER_PASSWORD_RESET_OPERATION,
|
|
27
28
|
CartApi: () => CartApi,
|
|
28
29
|
Client: () => Client,
|
|
29
30
|
CollectionClient: () => CollectionClient,
|
|
@@ -65,6 +66,7 @@ __export(src_exports, {
|
|
|
65
66
|
createAuthError: () => createAuthError,
|
|
66
67
|
createClient: () => createClient,
|
|
67
68
|
createConflictError: () => createConflictError,
|
|
69
|
+
createCustomerAuthWebhookHandler: () => createCustomerAuthWebhookHandler,
|
|
68
70
|
createNotFoundError: () => createNotFoundError,
|
|
69
71
|
createPermissionError: () => createPermissionError,
|
|
70
72
|
createRateLimitError: () => createRateLimitError,
|
|
@@ -91,6 +93,7 @@ __export(src_exports, {
|
|
|
91
93
|
isAuthError: () => isAuthError,
|
|
92
94
|
isConfigError: () => isConfigError,
|
|
93
95
|
isConflictError: () => isConflictError,
|
|
96
|
+
isCustomerPasswordResetWebhookEvent: () => isCustomerPasswordResetWebhookEvent,
|
|
94
97
|
isGoneError: () => isGoneError,
|
|
95
98
|
isNetworkError: () => isNetworkError,
|
|
96
99
|
isNotFoundError: () => isNotFoundError,
|
|
@@ -1077,8 +1080,6 @@ var INTERNAL_COLLECTIONS = [
|
|
|
1077
1080
|
"track-assets",
|
|
1078
1081
|
"audiences",
|
|
1079
1082
|
"email-logs",
|
|
1080
|
-
"tenant-auth-settings",
|
|
1081
|
-
"tenant-community-settings",
|
|
1082
1083
|
"api-usage",
|
|
1083
1084
|
"tenant-analytics-daily",
|
|
1084
1085
|
"analytics-event-schemas",
|
|
@@ -1092,7 +1093,8 @@ var INTERNAL_COLLECTIONS = [
|
|
|
1092
1093
|
"webhook-deliveries",
|
|
1093
1094
|
"audit-logs",
|
|
1094
1095
|
"plans",
|
|
1095
|
-
"webhooks"
|
|
1096
|
+
"webhooks",
|
|
1097
|
+
"event-registrations"
|
|
1096
1098
|
];
|
|
1097
1099
|
var COLLECTIONS = [
|
|
1098
1100
|
"tenants",
|
|
@@ -1165,7 +1167,12 @@ var COLLECTIONS = [
|
|
|
1165
1167
|
"bookmarks",
|
|
1166
1168
|
"thread-categories",
|
|
1167
1169
|
"reports",
|
|
1168
|
-
"community-bans"
|
|
1170
|
+
"community-bans",
|
|
1171
|
+
// Events
|
|
1172
|
+
"event-calendars",
|
|
1173
|
+
"events",
|
|
1174
|
+
"event-occurrences",
|
|
1175
|
+
"event-tags"
|
|
1169
1176
|
];
|
|
1170
1177
|
|
|
1171
1178
|
// src/core/api/parse-response.ts
|
|
@@ -1581,15 +1588,6 @@ var CustomerAuth = class {
|
|
|
1581
1588
|
body: JSON.stringify({ currentPassword, newPassword })
|
|
1582
1589
|
});
|
|
1583
1590
|
}
|
|
1584
|
-
/**
|
|
1585
|
-
* Verify email using the verification token
|
|
1586
|
-
*/
|
|
1587
|
-
async verifyEmail(token) {
|
|
1588
|
-
await this.requestJson("/api/customers/verify-email", {
|
|
1589
|
-
method: "POST",
|
|
1590
|
-
body: JSON.stringify({ token })
|
|
1591
|
-
});
|
|
1592
|
-
}
|
|
1593
1591
|
/**
|
|
1594
1592
|
* Get the authenticated customer's orders with pagination and optional status filter
|
|
1595
1593
|
*/
|
|
@@ -2309,14 +2307,6 @@ var CustomerHooks = class {
|
|
|
2309
2307
|
options
|
|
2310
2308
|
);
|
|
2311
2309
|
}
|
|
2312
|
-
useCustomerVerifyEmail(options) {
|
|
2313
|
-
return createMutation(
|
|
2314
|
-
(token) => this.ensureCustomerAuth().verifyEmail(token).then(() => {
|
|
2315
|
-
}),
|
|
2316
|
-
options,
|
|
2317
|
-
this.invalidateMe
|
|
2318
|
-
);
|
|
2319
|
-
}
|
|
2320
2310
|
useCustomerRefreshToken(options) {
|
|
2321
2311
|
return createMutation(
|
|
2322
2312
|
() => this.ensureCustomerAuth().refreshToken(),
|
|
@@ -2361,7 +2351,6 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
2361
2351
|
this.useCustomerLogout = (...args) => this._customer.useCustomerLogout(...args);
|
|
2362
2352
|
this.useCustomerForgotPassword = (...args) => this._customer.useCustomerForgotPassword(...args);
|
|
2363
2353
|
this.useCustomerResetPassword = (...args) => this._customer.useCustomerResetPassword(...args);
|
|
2364
|
-
this.useCustomerVerifyEmail = (...args) => this._customer.useCustomerVerifyEmail(...args);
|
|
2365
2354
|
this.useCustomerRefreshToken = (...args) => this._customer.useCustomerRefreshToken(...args);
|
|
2366
2355
|
this.useCustomerUpdateProfile = (...args) => this._customer.useCustomerUpdateProfile(...args);
|
|
2367
2356
|
this.useCustomerChangePassword = (...args) => this._customer.useCustomerChangePassword(...args);
|
|
@@ -2745,7 +2734,32 @@ var RealtimeConnection = class {
|
|
|
2745
2734
|
function isValidWebhookEvent(data) {
|
|
2746
2735
|
if (typeof data !== "object" || data === null) return false;
|
|
2747
2736
|
const obj = data;
|
|
2748
|
-
return typeof obj.collection === "string" &&
|
|
2737
|
+
return typeof obj.collection === "string" && typeof obj.operation === "string" && obj.operation.length > 0 && typeof obj.data === "object" && obj.data !== null;
|
|
2738
|
+
}
|
|
2739
|
+
var CUSTOMER_PASSWORD_RESET_OPERATION = "password-reset";
|
|
2740
|
+
function isRecord(value) {
|
|
2741
|
+
return typeof value === "object" && value !== null;
|
|
2742
|
+
}
|
|
2743
|
+
function hasString(value, key) {
|
|
2744
|
+
return typeof value[key] === "string";
|
|
2745
|
+
}
|
|
2746
|
+
function hasStringOrNumber(value, key) {
|
|
2747
|
+
return typeof value[key] === "string" || typeof value[key] === "number";
|
|
2748
|
+
}
|
|
2749
|
+
function isCustomerPasswordResetWebhookEvent(event) {
|
|
2750
|
+
if (event.collection !== "customers" || event.operation !== CUSTOMER_PASSWORD_RESET_OPERATION || !isRecord(event.data)) {
|
|
2751
|
+
return false;
|
|
2752
|
+
}
|
|
2753
|
+
return hasStringOrNumber(event.data, "customerId") && hasString(event.data, "email") && hasString(event.data, "name") && hasString(event.data, "resetPasswordToken") && hasString(event.data, "resetPasswordExpiresAt");
|
|
2754
|
+
}
|
|
2755
|
+
function createCustomerAuthWebhookHandler(handlers) {
|
|
2756
|
+
return async (event) => {
|
|
2757
|
+
if (isCustomerPasswordResetWebhookEvent(event) && handlers.passwordReset) {
|
|
2758
|
+
await handlers.passwordReset(event.data, event);
|
|
2759
|
+
return;
|
|
2760
|
+
}
|
|
2761
|
+
await handlers.unhandled?.(event);
|
|
2762
|
+
};
|
|
2749
2763
|
}
|
|
2750
2764
|
async function verifySignature(payload, secret, signature) {
|
|
2751
2765
|
const encoder = new TextEncoder();
|