@01.software/sdk 0.56.1 → 0.65.1

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 +192 -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
package/dist/client.cjs CHANGED
@@ -1048,6 +1048,49 @@ function stockSnapshotSearchParams(params) {
1048
1048
  }
1049
1049
 
1050
1050
  // src/core/collection/http-client.ts
1051
+ function validateWhere(where) {
1052
+ if (where === void 0) return false;
1053
+ let hasNull = false;
1054
+ function visit(value, depth, key) {
1055
+ if (depth > 10) {
1056
+ throw createValidationError(
1057
+ "Collection where must not exceed nesting depth 10."
1058
+ );
1059
+ }
1060
+ if (value === null && (key === "equals" || key === "not_equals")) {
1061
+ hasNull = true;
1062
+ return;
1063
+ }
1064
+ if (value == null) {
1065
+ throw createValidationError(
1066
+ "Collection where must not contain null or undefined values."
1067
+ );
1068
+ }
1069
+ if (Array.isArray(value)) {
1070
+ if (value.length === 0) {
1071
+ throw createValidationError(
1072
+ "Collection where must not contain empty arrays, including and/or."
1073
+ );
1074
+ }
1075
+ if (value.length > 1e3) {
1076
+ throw createValidationError(
1077
+ "Collection where arrays must not contain more than 1000 elements."
1078
+ );
1079
+ }
1080
+ for (const item of value) visit(item, depth + 1);
1081
+ } else if (typeof value === "object" && !(value instanceof Date)) {
1082
+ const values = Object.entries(value);
1083
+ if (values.length === 0) {
1084
+ throw createValidationError(
1085
+ "Collection where must not contain empty condition objects."
1086
+ );
1087
+ }
1088
+ for (const [key2, item] of values) visit(item, depth + 1, key2);
1089
+ }
1090
+ }
1091
+ visit(where, 0);
1092
+ return hasNull;
1093
+ }
1051
1094
  var HttpClient = class {
1052
1095
  constructor(publishableKey, secretKey, getCustomerToken, onUnauthorized, onRequestId, apiUrl) {
1053
1096
  this.publishableKey = requirePublishableKeyForSecret(
@@ -1094,7 +1137,8 @@ var HttpClient = class {
1094
1137
  ...rest,
1095
1138
  "fallback-locale": fallbackLocale === false ? "none" : fallbackLocale
1096
1139
  };
1097
- const queryString = (0, import_qs_esm.stringify)(queryOptions, { addQueryPrefix: true });
1140
+ const encodedOptions = validateWhere(queryOptions.where) ? { ...queryOptions, where: JSON.stringify(queryOptions.where) } : queryOptions;
1141
+ const queryString = (0, import_qs_esm.stringify)(encodedOptions, { addQueryPrefix: true });
1098
1142
  return queryString ? `${endpoint}${queryString}` : endpoint;
1099
1143
  }
1100
1144
  assertJsonResponse(response) {
@@ -1500,17 +1544,52 @@ var portOneStandardActionCapabilityOperations = /* @__PURE__ */ new Set([
1500
1544
  ]);
1501
1545
  var MEMBERSHIP_ENDPOINT_OPERATIONS = {
1502
1546
  subscribe: operation(null, "post", "/memberships/subscribe"),
1547
+ billingCustody: operation(null, "post", "/memberships/billing-custody"),
1503
1548
  cancel: operation(null, "post", "/memberships/:id/cancel"),
1504
1549
  me: operation(null, "get", "/memberships/me"),
1505
1550
  chargeResult: operation(null, "post", "/memberships/:id/charge-result"),
1506
1551
  refundResult: operation(null, "post", "/memberships/:id/refund-result"),
1507
1552
  revoke: operation(null, "post", "/memberships/:id/revoke")
1508
1553
  };
1554
+ var EXTERNAL_EFFECT_CLAIM_ENDPOINT_OPERATIONS = {
1555
+ claim: operation(null, "post", "/external-effect-claims/claim"),
1556
+ get: operation(null, "post", "/external-effect-claims/get"),
1557
+ arm: operation(null, "post", "/external-effect-claims/arm"),
1558
+ release: operation(null, "post", "/external-effect-claims/release"),
1559
+ report: operation(null, "post", "/external-effect-claims/report"),
1560
+ recovery: operation(null, "post", "/external-effect-claims/recovery")
1561
+ };
1562
+ var INSTALLATION_CREDENTIAL_ENDPOINT_OPERATIONS = {
1563
+ create: operation(null, "post", "/installation-credentials/create"),
1564
+ get: operation(null, "post", "/installation-credentials/get"),
1565
+ replace: operation(null, "post", "/installation-credentials/replace"),
1566
+ dispose: operation(null, "post", "/installation-credentials/dispose")
1567
+ };
1568
+ var EXTERNAL_CUSTOMER_LINK_ENDPOINT_OPERATIONS = {
1569
+ connect: operation("customers", "post", "/external-links/connect"),
1570
+ get: operation("customers", "post", "/external-links/get"),
1571
+ list: operation("customers", "post", "/external-links/list"),
1572
+ unlink: operation("customers", "post", "/external-links/unlink"),
1573
+ capturePreviousState: operation(
1574
+ "customers",
1575
+ "post",
1576
+ "/external-links/capture-previous-state"
1577
+ ),
1578
+ clearPreviousState: operation(
1579
+ "customers",
1580
+ "post",
1581
+ "/external-links/clear-previous-state"
1582
+ )
1583
+ };
1509
1584
  var CUSTOMER_GROUP_ENDPOINT_OPERATIONS = {
1510
1585
  members: operation("customer-groups", "get", "/:id/members"),
1511
1586
  grant: operation("customer-groups", "post", "/:id/members/grant"),
1512
1587
  revoke: operation("customer-groups", "post", "/:id/members/revoke")
1513
1588
  };
1589
+ var CUSTOMER_AUTH_ENDPOINT_OPERATIONS = {
1590
+ revokeRefresh: operation("customers", "post", "/revoke-refresh"),
1591
+ withdraw: operation("customers", "post", "/withdraw")
1592
+ };
1514
1593
  var EMBEDDED_ADMIN_ENDPOINT_OPERATIONS = {
1515
1594
  show: operation("tenants", "get", "/embedded-admin-app"),
1516
1595
  configure: operation("tenants", "patch", "/embedded-admin-app"),
@@ -1534,6 +1613,14 @@ var COMMUNITY_ENDPOINT_OPERATIONS = {
1534
1613
  detail: operation("posts", "get", "/detail")
1535
1614
  }
1536
1615
  };
1616
+ var GALLERY_ENDPOINT_OPERATIONS = {
1617
+ items: {
1618
+ storefront: operation("gallery-items", "get", "/storefront")
1619
+ }
1620
+ };
1621
+ var VIDEO_ENDPOINT_OPERATIONS = {
1622
+ playback: operation("videos", "post", "/:id/playback")
1623
+ };
1537
1624
  function resolveOperationTemplate(descriptor) {
1538
1625
  return descriptor.collection ? `/api/${descriptor.collection}${descriptor.path}` : `/api${descriptor.path}`;
1539
1626
  }
@@ -2123,6 +2210,15 @@ var PublicContentApi = class extends RawCustomerScopedApi {
2123
2210
  get(endpoint) {
2124
2211
  return this.request(endpoint, { method: "GET" });
2125
2212
  }
2213
+ galleryItems(options) {
2214
+ const operation2 = GALLERY_ENDPOINT_OPERATIONS.items.storefront;
2215
+ return this.request(
2216
+ resolveOperationPath(operation2, {
2217
+ query: galleryItemsListQuery(options)
2218
+ }),
2219
+ { method: resolveOperationMethod(operation2) }
2220
+ );
2221
+ }
2126
2222
  };
2127
2223
  function appendCommonParams(search, options, defaultSort) {
2128
2224
  search.set("sort", options?.sort ?? defaultSort);
@@ -2142,12 +2238,12 @@ function linksListPath(options) {
2142
2238
  search.set("featured", String(options.featured));
2143
2239
  return `/api/links/storefront?${search}`;
2144
2240
  }
2145
- function galleryItemsListPath(options) {
2241
+ function galleryItemsListQuery(options) {
2146
2242
  const search = new URLSearchParams();
2147
2243
  appendCommonParams(search, options, "manual");
2148
2244
  if (options?.galleryId) search.set("galleryId", options.galleryId);
2149
2245
  if (options?.gallerySlug) search.set("gallerySlug", options.gallerySlug);
2150
- return `/api/gallery-items/storefront?${search}`;
2246
+ return search;
2151
2247
  }
2152
2248
  var ContentClient = class {
2153
2249
  constructor(options) {
@@ -2161,9 +2257,7 @@ var ContentClient = class {
2161
2257
  list: (params) => api.get(linksListPath(params))
2162
2258
  };
2163
2259
  this.galleryItems = {
2164
- list: (params) => api.get(
2165
- galleryItemsListPath(params)
2166
- )
2260
+ list: (params) => api.galleryItems(params)
2167
2261
  };
2168
2262
  }
2169
2263
  };
@@ -4213,11 +4307,46 @@ var CustomerAuth = class {
4213
4307
  };
4214
4308
  }
4215
4309
  /**
4216
- * Clear the stored token
4310
+ * Clear local credentials synchronously. This compatibility API cannot
4311
+ * revoke the server-side refresh family; use logoutAsync() for that.
4312
+ * @deprecated Use logoutAsync() to end the direct server session.
4217
4313
  */
4218
4314
  logout() {
4219
4315
  this.setSession(null, null);
4220
4316
  }
4317
+ /**
4318
+ * End the current direct refresh family and clear local credentials even if
4319
+ * revocation fails. A legacy access-only session has no refresh family here.
4320
+ */
4321
+ async logoutAsync() {
4322
+ this.syncFromPersistedStorage();
4323
+ const refreshToken = this.refreshTokenValue;
4324
+ this.logout();
4325
+ if (!refreshToken) return;
4326
+ const operation2 = CUSTOMER_AUTH_ENDPOINT_OPERATIONS.revokeRefresh;
4327
+ await this.requestJson(resolveOperationPath(operation2), {
4328
+ method: resolveOperationMethod(operation2),
4329
+ body: JSON.stringify({ refreshToken })
4330
+ });
4331
+ }
4332
+ /** Archive the current password account and clear this client's credentials on success. */
4333
+ async withdraw(currentPassword) {
4334
+ const token = this.getToken();
4335
+ if (!token) throw new ApiError("Not authenticated", 401);
4336
+ const operation2 = CUSTOMER_AUTH_ENDPOINT_OPERATIONS.withdraw;
4337
+ const result = await this.requestJson(
4338
+ resolveOperationPath(operation2),
4339
+ {
4340
+ method: resolveOperationMethod(operation2),
4341
+ headers: { Authorization: `Bearer ${token}` },
4342
+ body: JSON.stringify({ currentPassword })
4343
+ }
4344
+ );
4345
+ if (!result || typeof result.withdrawnAt !== "string" || !Number.isFinite(Date.parse(result.withdrawnAt)))
4346
+ throw new ApiError("Invalid customer withdrawal response", 502);
4347
+ this.logout();
4348
+ return { withdrawnAt: result.withdrawnAt };
4349
+ }
4221
4350
  /**
4222
4351
  * Get the current authenticated customer's profile
4223
4352
  */