@01.software/sdk 0.56.1 → 0.65.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 (63) hide show
  1. package/CHANGELOG.md +186 -0
  2. package/README.md +174 -91
  3. package/dist/client.cjs +136 -7
  4. package/dist/client.cjs.map +1 -1
  5. package/dist/client.d.cts +6 -6
  6. package/dist/client.d.ts +6 -6
  7. package/dist/client.js +136 -7
  8. package/dist/client.js.map +1 -1
  9. package/dist/{collection-client-DxuBDso_.d.cts → collection-client-B7rsTtVj.d.cts} +6 -6
  10. package/dist/{collection-client-Bmr53saa.d.ts → collection-client-C2sMvfme.d.ts} +6 -6
  11. package/dist/{const-Cv1DCsp6.d.cts → const-CRxPTDGt.d.ts} +2 -2
  12. package/dist/{const-BKUqg96Q.d.ts → const-D6ZRQLxI.d.cts} +2 -2
  13. package/dist/{index-DFHLLqYu.d.ts → index-1auUEYrl.d.ts} +3 -3
  14. package/dist/{index-CGsT4AQ8.d.cts → index-Bbpf5t-l.d.cts} +3 -3
  15. package/dist/index.cjs +139 -205
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/index.d.cts +15 -9
  18. package/dist/index.d.ts +15 -9
  19. package/dist/index.js +139 -205
  20. package/dist/index.js.map +1 -1
  21. package/dist/{payload-types-Bk-duc5k.d.cts → payload-types-BnIET0xU.d.cts} +262 -328
  22. package/dist/{payload-types-Bk-duc5k.d.ts → payload-types-BnIET0xU.d.ts} +262 -328
  23. package/dist/query.cjs +48 -2
  24. package/dist/query.cjs.map +1 -1
  25. package/dist/query.d.cts +5 -5
  26. package/dist/query.d.ts +5 -5
  27. package/dist/query.js +48 -2
  28. package/dist/query.js.map +1 -1
  29. package/dist/realtime.d.cts +2 -2
  30. package/dist/realtime.d.ts +2 -2
  31. package/dist/server.cjs +459 -7
  32. package/dist/server.cjs.map +1 -1
  33. package/dist/server.d.cts +13 -8
  34. package/dist/server.d.ts +13 -8
  35. package/dist/server.js +459 -7
  36. package/dist/server.js.map +1 -1
  37. package/dist/{types-D4mjGFj4.d.ts → types-D1y4TgQm.d.ts} +2 -2
  38. package/dist/{types-CEK8uTvU.d.ts → types-DnRC3nLG.d.ts} +256 -9
  39. package/dist/{types-CNdpj2fI.d.cts → types-Dp1oYpD3.d.cts} +2 -2
  40. package/dist/{types-Dhk5NX7Z.d.cts → types-Dzn0LD2N.d.cts} +256 -9
  41. package/dist/ui/form.d.cts +1 -1
  42. package/dist/ui/form.d.ts +1 -1
  43. package/dist/ui/video.cjs +4 -2
  44. package/dist/ui/video.cjs.map +1 -1
  45. package/dist/ui/video.d.cts +4 -2
  46. package/dist/ui/video.d.ts +4 -2
  47. package/dist/ui/video.js +4 -2
  48. package/dist/ui/video.js.map +1 -1
  49. package/dist/webhook.d.cts +5 -5
  50. package/dist/webhook.d.ts +5 -5
  51. package/package.json +8 -28
  52. package/dist/analytics/react.cjs +0 -344
  53. package/dist/analytics/react.cjs.map +0 -1
  54. package/dist/analytics/react.d.cts +0 -24
  55. package/dist/analytics/react.d.ts +0 -24
  56. package/dist/analytics/react.js +0 -319
  57. package/dist/analytics/react.js.map +0 -1
  58. package/dist/analytics.cjs +0 -238
  59. package/dist/analytics.cjs.map +0 -1
  60. package/dist/analytics.d.cts +0 -39
  61. package/dist/analytics.d.ts +0 -39
  62. package/dist/analytics.js +0 -215
  63. package/dist/analytics.js.map +0 -1
@@ -1,8 +1,8 @@
1
- import { G as DebugConfig, ak as RetryConfig, i as ApiQueryOptions, P as PayloadFindResponse, L as PayloadMutationResponse, cf as ApiDeleteOptions, cg as PublicReadQueryOptions } from './types-Dhk5NX7Z.cjs';
2
- import './payload-types-Bk-duc5k.cjs';
1
+ import { G as DebugConfig, ak as RetryConfig, i as ApiQueryOptions, P as PayloadFindResponse, L as PayloadMutationResponse, cM as ApiDeleteOptions, cN as PublicReadQueryOptions } from './types-Dzn0LD2N.cjs';
2
+ import './payload-types-BnIET0xU.cjs';
3
3
  import { GenerateMetadataOptions, Metadata } from './metadata.cjs';
4
- import { C as Collection, S as ServerCollection, P as PublicCollection } from './const-Cv1DCsp6.cjs';
5
- import { C as CollectionType } from './types-CNdpj2fI.cjs';
4
+ import { C as Collection, S as ServerCollection, P as PublicCollection } from './const-D6ZRQLxI.cjs';
5
+ import { C as CollectionType } from './types-Dp1oYpD3.cjs';
6
6
 
7
7
  interface FetchOptions extends RequestInit {
8
8
  apiUrl?: string;
@@ -190,7 +190,7 @@ declare class CollectionClient<TCollection extends Collection = PublicCollection
190
190
  * PATCH /api/{collection}
191
191
  */
192
192
  requestUpdateMany<T = unknown>(endpoint: string, data: {
193
- where?: unknown;
193
+ where?: ApiQueryOptions['where'];
194
194
  data: unknown;
195
195
  }): Promise<PayloadFindResponse<T>>;
196
196
  /**
@@ -203,7 +203,7 @@ declare class CollectionClient<TCollection extends Collection = PublicCollection
203
203
  * DELETE /api/{collection}
204
204
  */
205
205
  requestDeleteMany<T = unknown>(endpoint: string, data: {
206
- where?: unknown;
206
+ where?: ApiQueryOptions['where'];
207
207
  }): Promise<PayloadFindResponse<T>>;
208
208
  /**
209
209
  * Create document with file upload
@@ -1,8 +1,8 @@
1
- import { G as DebugConfig, ak as RetryConfig, i as ApiQueryOptions, P as PayloadFindResponse, L as PayloadMutationResponse, cf as ApiDeleteOptions, cg as PublicReadQueryOptions } from './types-CEK8uTvU.js';
2
- import './payload-types-Bk-duc5k.js';
1
+ import { G as DebugConfig, ak as RetryConfig, i as ApiQueryOptions, P as PayloadFindResponse, L as PayloadMutationResponse, cM as ApiDeleteOptions, cN as PublicReadQueryOptions } from './types-DnRC3nLG.js';
2
+ import './payload-types-BnIET0xU.js';
3
3
  import { GenerateMetadataOptions, Metadata } from './metadata.js';
4
- import { C as Collection, S as ServerCollection, P as PublicCollection } from './const-BKUqg96Q.js';
5
- import { C as CollectionType } from './types-D4mjGFj4.js';
4
+ import { C as Collection, S as ServerCollection, P as PublicCollection } from './const-CRxPTDGt.js';
5
+ import { C as CollectionType } from './types-D1y4TgQm.js';
6
6
 
7
7
  interface FetchOptions extends RequestInit {
8
8
  apiUrl?: string;
@@ -190,7 +190,7 @@ declare class CollectionClient<TCollection extends Collection = PublicCollection
190
190
  * PATCH /api/{collection}
191
191
  */
192
192
  requestUpdateMany<T = unknown>(endpoint: string, data: {
193
- where?: unknown;
193
+ where?: ApiQueryOptions['where'];
194
194
  data: unknown;
195
195
  }): Promise<PayloadFindResponse<T>>;
196
196
  /**
@@ -203,7 +203,7 @@ declare class CollectionClient<TCollection extends Collection = PublicCollection
203
203
  * DELETE /api/{collection}
204
204
  */
205
205
  requestDeleteMany<T = unknown>(endpoint: string, data: {
206
- where?: unknown;
206
+ where?: ApiQueryOptions['where'];
207
207
  }): Promise<PayloadFindResponse<T>>;
208
208
  /**
209
209
  * Create document with file upload
@@ -1,10 +1,10 @@
1
- import './payload-types-Bk-duc5k.cjs';
1
+ import './payload-types-BnIET0xU.js';
2
2
 
3
3
  /**
4
4
  * Internal collections that should not be exposed via SDK.
5
5
  * Includes Payload system collections and admin-only collections.
6
6
  */
7
- declare const INTERNAL_COLLECTIONS: readonly ["users", "payload-kv", "payload-locked-documents", "payload-preferences", "payload-migrations", "payload-folders", "field-configs", "system-media", "track-assets", "audiences", "email-logs", "api-usage", "tenant-analytics-daily", "tenant-web-analytics-config", "analytics-event-schemas", "subscriptions", "billing-history", "usage-rate-cards", "usage-invoices", "inventory-reservations", "inventory-adjustments", "payment-sessions", "payment-event-inbox", "payment-refund-attempts", "portone-payment-interactions", "commerce-payment-webhook-routes", "commerce-notification-intents", "commerce-idempotency-records", "product-collection-items", "order-status-logs", "fulfillment-events", "tenant-commerce-config", "customer-oauth-clients", "customer-group-grants", "api-keys", "personal-access-tokens", "tenant-entitlements", "tenant-purge-jobs", "direct-upload-sessions", "webhook-events", "webhook-deliveries", "webhook-outbox-deliveries", "audit-logs", "plans", "webhooks", "custom-field-definitions", "event-registrations", "event-admission-holds", "event-admission-types", "customer-payment-methods", "tenant-payment-credentials", "commerce-payment-accounts", "payment-provider-customer-aliases"];
7
+ declare const INTERNAL_COLLECTIONS: readonly ["users", "payload-kv", "payload-locked-documents", "payload-preferences", "payload-migrations", "payload-folders", "field-configs", "system-media", "track-assets", "audiences", "email-logs", "api-usage", "tenant-mcp-usage-daily", "subscriptions", "billing-history", "usage-rate-cards", "usage-invoices", "inventory-reservations", "inventory-adjustments", "payment-sessions", "payment-event-inbox", "payment-refund-attempts", "portone-payment-interactions", "commerce-payment-webhook-routes", "commerce-notification-intents", "commerce-idempotency-records", "product-collection-items", "order-status-logs", "fulfillment-events", "tenant-commerce-config", "customer-oauth-clients", "customer-consent-receipts", "customer-group-grants", "api-keys", "personal-access-tokens", "tenant-entitlements", "tenant-purge-jobs", "direct-upload-sessions", "webhook-events", "webhook-deliveries", "webhook-outbox-deliveries", "audit-logs", "plans", "webhooks", "custom-field-definitions", "event-registrations", "event-admission-holds", "event-admission-types", "customer-payment-methods", "tenant-payment-credentials", "membership-unapplied-paid-evidence", "commerce-payment-accounts", "payment-provider-customer-aliases"];
8
8
  type InternalCollection = (typeof INTERNAL_COLLECTIONS)[number];
9
9
  /**
10
10
  * Array of browser-public collection names for runtime use (e.g., Zod enum validation).
@@ -1,10 +1,10 @@
1
- import './payload-types-Bk-duc5k.js';
1
+ import './payload-types-BnIET0xU.cjs';
2
2
 
3
3
  /**
4
4
  * Internal collections that should not be exposed via SDK.
5
5
  * Includes Payload system collections and admin-only collections.
6
6
  */
7
- declare const INTERNAL_COLLECTIONS: readonly ["users", "payload-kv", "payload-locked-documents", "payload-preferences", "payload-migrations", "payload-folders", "field-configs", "system-media", "track-assets", "audiences", "email-logs", "api-usage", "tenant-analytics-daily", "tenant-web-analytics-config", "analytics-event-schemas", "subscriptions", "billing-history", "usage-rate-cards", "usage-invoices", "inventory-reservations", "inventory-adjustments", "payment-sessions", "payment-event-inbox", "payment-refund-attempts", "portone-payment-interactions", "commerce-payment-webhook-routes", "commerce-notification-intents", "commerce-idempotency-records", "product-collection-items", "order-status-logs", "fulfillment-events", "tenant-commerce-config", "customer-oauth-clients", "customer-group-grants", "api-keys", "personal-access-tokens", "tenant-entitlements", "tenant-purge-jobs", "direct-upload-sessions", "webhook-events", "webhook-deliveries", "webhook-outbox-deliveries", "audit-logs", "plans", "webhooks", "custom-field-definitions", "event-registrations", "event-admission-holds", "event-admission-types", "customer-payment-methods", "tenant-payment-credentials", "commerce-payment-accounts", "payment-provider-customer-aliases"];
7
+ declare const INTERNAL_COLLECTIONS: readonly ["users", "payload-kv", "payload-locked-documents", "payload-preferences", "payload-migrations", "payload-folders", "field-configs", "system-media", "track-assets", "audiences", "email-logs", "api-usage", "tenant-mcp-usage-daily", "subscriptions", "billing-history", "usage-rate-cards", "usage-invoices", "inventory-reservations", "inventory-adjustments", "payment-sessions", "payment-event-inbox", "payment-refund-attempts", "portone-payment-interactions", "commerce-payment-webhook-routes", "commerce-notification-intents", "commerce-idempotency-records", "product-collection-items", "order-status-logs", "fulfillment-events", "tenant-commerce-config", "customer-oauth-clients", "customer-consent-receipts", "customer-group-grants", "api-keys", "personal-access-tokens", "tenant-entitlements", "tenant-purge-jobs", "direct-upload-sessions", "webhook-events", "webhook-deliveries", "webhook-outbox-deliveries", "audit-logs", "plans", "webhooks", "custom-field-definitions", "event-registrations", "event-admission-holds", "event-admission-types", "customer-payment-methods", "tenant-payment-credentials", "membership-unapplied-paid-evidence", "commerce-payment-accounts", "payment-provider-customer-aliases"];
8
8
  type InternalCollection = (typeof INTERNAL_COLLECTIONS)[number];
9
9
  /**
10
10
  * Array of browser-public collection names for runtime use (e.g., Zod enum validation).
@@ -1,6 +1,6 @@
1
- import { C as Collection } from './const-BKUqg96Q.js';
2
- import { C as CollectionType } from './types-D4mjGFj4.js';
3
- import './payload-types-Bk-duc5k.js';
1
+ import { C as Collection } from './const-CRxPTDGt.js';
2
+ import { C as CollectionType } from './types-D1y4TgQm.js';
3
+ import './payload-types-BnIET0xU.js';
4
4
 
5
5
  type WebhookOperation = string;
6
6
  /**
@@ -1,6 +1,6 @@
1
- import { C as Collection } from './const-Cv1DCsp6.cjs';
2
- import { C as CollectionType } from './types-CNdpj2fI.cjs';
3
- import './payload-types-Bk-duc5k.cjs';
1
+ import { C as Collection } from './const-D6ZRQLxI.cjs';
2
+ import { C as CollectionType } from './types-Dp1oYpD3.cjs';
3
+ import './payload-types-BnIET0xU.cjs';
4
4
 
5
5
  type WebhookOperation = string;
6
6
  /**
package/dist/index.cjs CHANGED
@@ -65,7 +65,6 @@ __export(src_exports, {
65
65
  buildProductListingGroupsByOption: () => buildProductListingGroupsByOption,
66
66
  buildProductOptionMatrix: () => buildProductOptionMatrix,
67
67
  buildProductOptionMatrixFromDetail: () => buildProductOptionMatrixFromDetail,
68
- createAnalytics: () => createAnalytics,
69
68
  createAuthError: () => createAuthError,
70
69
  createClient: () => createClient2,
71
70
  createCommerceEmailWebhookHandler: () => createCommerceEmailWebhookHandler,
@@ -1149,6 +1148,49 @@ function stockSnapshotSearchParams(params) {
1149
1148
  }
1150
1149
 
1151
1150
  // src/core/collection/http-client.ts
1151
+ function validateWhere(where) {
1152
+ if (where === void 0) return false;
1153
+ let hasNull = false;
1154
+ function visit(value, depth, key) {
1155
+ if (depth > 10) {
1156
+ throw createValidationError(
1157
+ "Collection where must not exceed nesting depth 10."
1158
+ );
1159
+ }
1160
+ if (value === null && (key === "equals" || key === "not_equals")) {
1161
+ hasNull = true;
1162
+ return;
1163
+ }
1164
+ if (value == null) {
1165
+ throw createValidationError(
1166
+ "Collection where must not contain null or undefined values."
1167
+ );
1168
+ }
1169
+ if (Array.isArray(value)) {
1170
+ if (value.length === 0) {
1171
+ throw createValidationError(
1172
+ "Collection where must not contain empty arrays, including and/or."
1173
+ );
1174
+ }
1175
+ if (value.length > 1e3) {
1176
+ throw createValidationError(
1177
+ "Collection where arrays must not contain more than 1000 elements."
1178
+ );
1179
+ }
1180
+ for (const item of value) visit(item, depth + 1);
1181
+ } else if (typeof value === "object" && !(value instanceof Date)) {
1182
+ const values = Object.entries(value);
1183
+ if (values.length === 0) {
1184
+ throw createValidationError(
1185
+ "Collection where must not contain empty condition objects."
1186
+ );
1187
+ }
1188
+ for (const [key2, item] of values) visit(item, depth + 1, key2);
1189
+ }
1190
+ }
1191
+ visit(where, 0);
1192
+ return hasNull;
1193
+ }
1152
1194
  var HttpClient = class {
1153
1195
  constructor(publishableKey, secretKey, getCustomerToken, onUnauthorized, onRequestId, apiUrl) {
1154
1196
  this.publishableKey = requirePublishableKeyForSecret(
@@ -1195,7 +1237,8 @@ var HttpClient = class {
1195
1237
  ...rest,
1196
1238
  "fallback-locale": fallbackLocale === false ? "none" : fallbackLocale
1197
1239
  };
1198
- const queryString = (0, import_qs_esm.stringify)(queryOptions, { addQueryPrefix: true });
1240
+ const encodedOptions = validateWhere(queryOptions.where) ? { ...queryOptions, where: JSON.stringify(queryOptions.where) } : queryOptions;
1241
+ const queryString = (0, import_qs_esm.stringify)(encodedOptions, { addQueryPrefix: true });
1199
1242
  return queryString ? `${endpoint}${queryString}` : endpoint;
1200
1243
  }
1201
1244
  assertJsonResponse(response) {
@@ -1608,17 +1651,52 @@ var portOneStandardActionCapabilityOperations = /* @__PURE__ */ new Set([
1608
1651
  ]);
1609
1652
  var MEMBERSHIP_ENDPOINT_OPERATIONS = {
1610
1653
  subscribe: operation(null, "post", "/memberships/subscribe"),
1654
+ billingCustody: operation(null, "post", "/memberships/billing-custody"),
1611
1655
  cancel: operation(null, "post", "/memberships/:id/cancel"),
1612
1656
  me: operation(null, "get", "/memberships/me"),
1613
1657
  chargeResult: operation(null, "post", "/memberships/:id/charge-result"),
1614
1658
  refundResult: operation(null, "post", "/memberships/:id/refund-result"),
1615
1659
  revoke: operation(null, "post", "/memberships/:id/revoke")
1616
1660
  };
1661
+ var EXTERNAL_EFFECT_CLAIM_ENDPOINT_OPERATIONS = {
1662
+ claim: operation(null, "post", "/external-effect-claims/claim"),
1663
+ get: operation(null, "post", "/external-effect-claims/get"),
1664
+ arm: operation(null, "post", "/external-effect-claims/arm"),
1665
+ release: operation(null, "post", "/external-effect-claims/release"),
1666
+ report: operation(null, "post", "/external-effect-claims/report"),
1667
+ recovery: operation(null, "post", "/external-effect-claims/recovery")
1668
+ };
1669
+ var INSTALLATION_CREDENTIAL_ENDPOINT_OPERATIONS = {
1670
+ create: operation(null, "post", "/installation-credentials/create"),
1671
+ get: operation(null, "post", "/installation-credentials/get"),
1672
+ replace: operation(null, "post", "/installation-credentials/replace"),
1673
+ dispose: operation(null, "post", "/installation-credentials/dispose")
1674
+ };
1675
+ var EXTERNAL_CUSTOMER_LINK_ENDPOINT_OPERATIONS = {
1676
+ connect: operation("customers", "post", "/external-links/connect"),
1677
+ get: operation("customers", "post", "/external-links/get"),
1678
+ list: operation("customers", "post", "/external-links/list"),
1679
+ unlink: operation("customers", "post", "/external-links/unlink"),
1680
+ capturePreviousState: operation(
1681
+ "customers",
1682
+ "post",
1683
+ "/external-links/capture-previous-state"
1684
+ ),
1685
+ clearPreviousState: operation(
1686
+ "customers",
1687
+ "post",
1688
+ "/external-links/clear-previous-state"
1689
+ )
1690
+ };
1617
1691
  var CUSTOMER_GROUP_ENDPOINT_OPERATIONS = {
1618
1692
  members: operation("customer-groups", "get", "/:id/members"),
1619
1693
  grant: operation("customer-groups", "post", "/:id/members/grant"),
1620
1694
  revoke: operation("customer-groups", "post", "/:id/members/revoke")
1621
1695
  };
1696
+ var CUSTOMER_AUTH_ENDPOINT_OPERATIONS = {
1697
+ revokeRefresh: operation("customers", "post", "/revoke-refresh"),
1698
+ withdraw: operation("customers", "post", "/withdraw")
1699
+ };
1622
1700
  var EMBEDDED_ADMIN_ENDPOINT_OPERATIONS = {
1623
1701
  show: operation("tenants", "get", "/embedded-admin-app"),
1624
1702
  configure: operation("tenants", "patch", "/embedded-admin-app"),
@@ -1642,6 +1720,14 @@ var COMMUNITY_ENDPOINT_OPERATIONS = {
1642
1720
  detail: operation("posts", "get", "/detail")
1643
1721
  }
1644
1722
  };
1723
+ var GALLERY_ENDPOINT_OPERATIONS = {
1724
+ items: {
1725
+ storefront: operation("gallery-items", "get", "/storefront")
1726
+ }
1727
+ };
1728
+ var VIDEO_ENDPOINT_OPERATIONS = {
1729
+ playback: operation("videos", "post", "/:id/playback")
1730
+ };
1645
1731
  function resolveOperationTemplate(descriptor) {
1646
1732
  return descriptor.collection ? `/api/${descriptor.collection}${descriptor.path}` : `/api${descriptor.path}`;
1647
1733
  }
@@ -2231,6 +2317,15 @@ var PublicContentApi = class extends RawCustomerScopedApi {
2231
2317
  get(endpoint) {
2232
2318
  return this.request(endpoint, { method: "GET" });
2233
2319
  }
2320
+ galleryItems(options) {
2321
+ const operation2 = GALLERY_ENDPOINT_OPERATIONS.items.storefront;
2322
+ return this.request(
2323
+ resolveOperationPath(operation2, {
2324
+ query: galleryItemsListQuery(options)
2325
+ }),
2326
+ { method: resolveOperationMethod(operation2) }
2327
+ );
2328
+ }
2234
2329
  };
2235
2330
  function appendCommonParams(search, options, defaultSort) {
2236
2331
  search.set("sort", options?.sort ?? defaultSort);
@@ -2250,12 +2345,12 @@ function linksListPath(options) {
2250
2345
  search.set("featured", String(options.featured));
2251
2346
  return `/api/links/storefront?${search}`;
2252
2347
  }
2253
- function galleryItemsListPath(options) {
2348
+ function galleryItemsListQuery(options) {
2254
2349
  const search = new URLSearchParams();
2255
2350
  appendCommonParams(search, options, "manual");
2256
2351
  if (options?.galleryId) search.set("galleryId", options.galleryId);
2257
2352
  if (options?.gallerySlug) search.set("gallerySlug", options.gallerySlug);
2258
- return `/api/gallery-items/storefront?${search}`;
2353
+ return search;
2259
2354
  }
2260
2355
  var ContentClient = class {
2261
2356
  constructor(options) {
@@ -2269,9 +2364,7 @@ var ContentClient = class {
2269
2364
  list: (params) => api.get(linksListPath(params))
2270
2365
  };
2271
2366
  this.galleryItems = {
2272
- list: (params) => api.get(
2273
- galleryItemsListPath(params)
2274
- )
2367
+ list: (params) => api.galleryItems(params)
2275
2368
  };
2276
2369
  }
2277
2370
  };
@@ -4321,11 +4414,46 @@ var CustomerAuth = class {
4321
4414
  };
4322
4415
  }
4323
4416
  /**
4324
- * Clear the stored token
4417
+ * Clear local credentials synchronously. This compatibility API cannot
4418
+ * revoke the server-side refresh family; use logoutAsync() for that.
4419
+ * @deprecated Use logoutAsync() to end the direct server session.
4325
4420
  */
4326
4421
  logout() {
4327
4422
  this.setSession(null, null);
4328
4423
  }
4424
+ /**
4425
+ * End the current direct refresh family and clear local credentials even if
4426
+ * revocation fails. A legacy access-only session has no refresh family here.
4427
+ */
4428
+ async logoutAsync() {
4429
+ this.syncFromPersistedStorage();
4430
+ const refreshToken = this.refreshTokenValue;
4431
+ this.logout();
4432
+ if (!refreshToken) return;
4433
+ const operation2 = CUSTOMER_AUTH_ENDPOINT_OPERATIONS.revokeRefresh;
4434
+ await this.requestJson(resolveOperationPath(operation2), {
4435
+ method: resolveOperationMethod(operation2),
4436
+ body: JSON.stringify({ refreshToken })
4437
+ });
4438
+ }
4439
+ /** Archive the current password account and clear this client's credentials on success. */
4440
+ async withdraw(currentPassword) {
4441
+ const token = this.getToken();
4442
+ if (!token) throw new ApiError("Not authenticated", 401);
4443
+ const operation2 = CUSTOMER_AUTH_ENDPOINT_OPERATIONS.withdraw;
4444
+ const result = await this.requestJson(
4445
+ resolveOperationPath(operation2),
4446
+ {
4447
+ method: resolveOperationMethod(operation2),
4448
+ headers: { Authorization: `Bearer ${token}` },
4449
+ body: JSON.stringify({ currentPassword })
4450
+ }
4451
+ );
4452
+ if (!result || typeof result.withdrawnAt !== "string" || !Number.isFinite(Date.parse(result.withdrawnAt)))
4453
+ throw new ApiError("Invalid customer withdrawal response", 502);
4454
+ this.logout();
4455
+ return { withdrawnAt: result.withdrawnAt };
4456
+ }
4329
4457
  /**
4330
4458
  * Get the current authenticated customer's profile
4331
4459
  */
@@ -7524,9 +7652,7 @@ var INTERNAL_COLLECTIONS = [
7524
7652
  "audiences",
7525
7653
  "email-logs",
7526
7654
  "api-usage",
7527
- "tenant-analytics-daily",
7528
- "tenant-web-analytics-config",
7529
- "analytics-event-schemas",
7655
+ "tenant-mcp-usage-daily",
7530
7656
  "subscriptions",
7531
7657
  "billing-history",
7532
7658
  "usage-rate-cards",
@@ -7545,6 +7671,7 @@ var INTERNAL_COLLECTIONS = [
7545
7671
  "fulfillment-events",
7546
7672
  "tenant-commerce-config",
7547
7673
  "customer-oauth-clients",
7674
+ "customer-consent-receipts",
7548
7675
  "customer-group-grants",
7549
7676
  "api-keys",
7550
7677
  "personal-access-tokens",
@@ -7563,6 +7690,7 @@ var INTERNAL_COLLECTIONS = [
7563
7690
  "event-admission-types",
7564
7691
  "customer-payment-methods",
7565
7692
  "tenant-payment-credentials",
7693
+ "membership-unapplied-paid-evidence",
7566
7694
  "commerce-payment-accounts",
7567
7695
  "payment-provider-customer-aliases"
7568
7696
  ];
@@ -7945,200 +8073,6 @@ function getVideoMp4Url(playbackId, resolution = "high") {
7945
8073
  return `${MUX_STREAM_BASE}/${playbackId}/${resolution}.mp4`;
7946
8074
  }
7947
8075
 
7948
- // src/analytics.ts
7949
- function createAnalytics(config) {
7950
- if (typeof window === "undefined") {
7951
- return { pageview() {
7952
- }, track() {
7953
- }, destroy() {
7954
- } };
7955
- }
7956
- const endpoint = config.endpoint ?? `${resolveApiUrl()}/api/analytics/collect`;
7957
- const respectDnt = config.respectDnt !== false;
7958
- function isDntActive() {
7959
- if (!respectDnt) return false;
7960
- const nav = navigator;
7961
- return nav.doNotTrack === "1" || nav.globalPrivacyControl === true;
7962
- }
7963
- const isLocalHost = (() => {
7964
- try {
7965
- const h = location.hostname;
7966
- return h === "localhost" || h === "127.0.0.1" || h.endsWith(".local");
7967
- } catch {
7968
- return false;
7969
- }
7970
- })();
7971
- const mode = config.mode ?? "auto";
7972
- const sendSuppressed = mode === "development" || mode === "auto" && isLocalHost;
7973
- let suppressNoticeShown = false;
7974
- function devSuppressNotice() {
7975
- if (suppressNoticeShown) return;
7976
- suppressNoticeShown = true;
7977
- try {
7978
- console.info(
7979
- `[01 analytics] events disabled on local host (mode: '${mode}'). Pass mode: 'production' to send while developing.`
7980
- );
7981
- } catch {
7982
- }
7983
- }
7984
- let lastPath = null;
7985
- let lastAt = 0;
7986
- const autoTrack = config.autoTrack !== false;
7987
- const originalPushState = history.pushState;
7988
- const originalReplaceState = history.replaceState;
7989
- let destroyed = false;
7990
- function newEventId() {
7991
- return typeof crypto !== "undefined" && typeof crypto.randomUUID === "function" ? crypto.randomUUID() : String(Date.now()) + String(Math.random());
7992
- }
7993
- function sendBeaconOrFetch(body) {
7994
- try {
7995
- if (typeof navigator.sendBeacon === "function") {
7996
- const blob = new Blob([body], { type: "text/plain" });
7997
- const sent = navigator.sendBeacon(endpoint, blob);
7998
- if (sent) return;
7999
- }
8000
- fetch(endpoint, {
8001
- method: "POST",
8002
- keepalive: true,
8003
- headers: { "Content-Type": "application/json" },
8004
- body
8005
- }).catch(() => {
8006
- });
8007
- } catch {
8008
- }
8009
- }
8010
- function sendPageview(pathname) {
8011
- if (isDntActive()) return;
8012
- const doc = document;
8013
- if (doc.prerendering === true || document.visibilityState === "prerender") return;
8014
- if (sendSuppressed) {
8015
- devSuppressNotice();
8016
- return;
8017
- }
8018
- const now = Date.now();
8019
- if (pathname === lastPath && now - lastAt < 500) return;
8020
- lastPath = pathname;
8021
- lastAt = now;
8022
- const body = JSON.stringify({
8023
- publishableKey: config.publishableKey,
8024
- pathname,
8025
- referrer: document.referrer || "",
8026
- eventId: newEventId(),
8027
- eventTs: Date.now()
8028
- });
8029
- sendBeaconOrFetch(body);
8030
- }
8031
- function trackCurrentPath() {
8032
- if (destroyed) return;
8033
- sendPageview(location.pathname);
8034
- }
8035
- function patchedPushState(data, unused, url) {
8036
- originalPushState.apply(this, [data, unused, url]);
8037
- if (!destroyed) setTimeout(trackCurrentPath, 0);
8038
- }
8039
- function patchedReplaceState(data, unused, url) {
8040
- originalReplaceState.apply(this, [data, unused, url]);
8041
- if (!destroyed) setTimeout(trackCurrentPath, 0);
8042
- }
8043
- if (autoTrack) {
8044
- history.pushState = patchedPushState;
8045
- history.replaceState = patchedReplaceState;
8046
- window.addEventListener("popstate", trackCurrentPath);
8047
- if (document.readyState === "complete") {
8048
- trackCurrentPath();
8049
- } else {
8050
- window.addEventListener("load", trackCurrentPath, { once: true });
8051
- }
8052
- }
8053
- const isProduction = !isLocalHost;
8054
- const warnedReasons = /* @__PURE__ */ new Set();
8055
- function devWarn(name, reason) {
8056
- if (isProduction) return;
8057
- if (warnedReasons.has(reason)) return;
8058
- warnedReasons.add(reason);
8059
- console.warn(`[01 analytics] dropped event ${name}: ${reason}`);
8060
- }
8061
- const EVENT_NAME_RE = /^[a-zA-Z][a-zA-Z0-9_:-]{0,49}$/;
8062
- const RESERVED_PREFIXES = ["__", "_pv_"];
8063
- function validateEventName(name) {
8064
- if (!name || typeof name !== "string") return "name-empty";
8065
- for (const prefix of RESERVED_PREFIXES) {
8066
- if (name.startsWith(prefix)) return "name-reserved";
8067
- }
8068
- if (!EVENT_NAME_RE.test(name)) return "name-regex";
8069
- return null;
8070
- }
8071
- const PROP_KEY_RE = /^[a-zA-Z_][a-zA-Z0-9_]{0,31}$/;
8072
- function validateEventProps(props) {
8073
- if (props === void 0 || props === null) return null;
8074
- if (typeof props !== "object" || Array.isArray(props)) return "props-value-type";
8075
- const keys = Object.keys(props);
8076
- if (keys.length > 10) return "props-too-many-keys";
8077
- for (const k of keys) {
8078
- const v = props[k];
8079
- if (!PROP_KEY_RE.test(k)) return "props-key-regex";
8080
- if (typeof v === "string") {
8081
- if (v.length > 80) return "props-value-too-long";
8082
- } else if (typeof v === "number") {
8083
- if (!isFinite(v)) return "props-value-not-finite";
8084
- } else if (typeof v === "boolean") {
8085
- } else {
8086
- return "props-value-type";
8087
- }
8088
- }
8089
- return null;
8090
- }
8091
- return {
8092
- pageview(path) {
8093
- if (destroyed) return;
8094
- sendPageview(path ?? location.pathname);
8095
- },
8096
- track(name, props) {
8097
- if (destroyed) return;
8098
- if (isDntActive()) return;
8099
- const doc = document;
8100
- if (doc.prerendering === true || document.visibilityState === "prerender") return;
8101
- const nameErr = validateEventName(name);
8102
- if (nameErr) {
8103
- devWarn(name, nameErr);
8104
- return;
8105
- }
8106
- if (props !== void 0) {
8107
- const propsErr = validateEventProps(props);
8108
- if (propsErr) {
8109
- devWarn(name, propsErr);
8110
- return;
8111
- }
8112
- }
8113
- if (sendSuppressed) {
8114
- devSuppressNotice();
8115
- return;
8116
- }
8117
- const body = JSON.stringify({
8118
- publishableKey: config.publishableKey,
8119
- pathname: location.pathname,
8120
- referrer: document.referrer || "",
8121
- eventId: newEventId(),
8122
- eventName: name,
8123
- eventProps: props,
8124
- eventTs: Date.now()
8125
- });
8126
- sendBeaconOrFetch(body);
8127
- },
8128
- destroy() {
8129
- if (destroyed) return;
8130
- destroyed = true;
8131
- if (autoTrack) {
8132
- history.pushState = originalPushState;
8133
- history.replaceState = originalReplaceState;
8134
- window.removeEventListener("popstate", trackCurrentPath);
8135
- }
8136
- lastPath = null;
8137
- lastAt = 0;
8138
- }
8139
- };
8140
- }
8141
-
8142
8076
  // src/index.ts
8143
8077
  function createClient2(options) {
8144
8078
  return createClient(options);