@01.software/sdk 0.51.0 → 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 (67) hide show
  1. package/CHANGELOG.md +313 -0
  2. package/README.md +228 -102
  3. package/dist/client.cjs +556 -60
  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 +556 -60
  8. package/dist/client.js.map +1 -1
  9. package/dist/{collection-client-CWAeuzV4.d.cts → collection-client-B7rsTtVj.d.cts} +6 -6
  10. package/dist/{collection-client-hYvVfHIm.d.ts → collection-client-C2sMvfme.d.ts} +6 -6
  11. package/dist/{const-JD8obaKg.d.ts → const-CRxPTDGt.d.ts} +2 -2
  12. package/dist/{const-D8LixhAJ.d.cts → const-D6ZRQLxI.d.cts} +2 -2
  13. package/dist/{index-B0Hjh3Ey.d.ts → index-1auUEYrl.d.ts} +24 -7
  14. package/dist/{index-Bu0kCc6o.d.cts → index-Bbpf5t-l.d.cts} +24 -7
  15. package/dist/index.cjs +573 -260
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/index.d.cts +19 -12
  18. package/dist/index.d.ts +19 -12
  19. package/dist/index.js +573 -260
  20. package/dist/index.js.map +1 -1
  21. package/dist/{payload-types-BOsckg8B.d.cts → payload-types-BnIET0xU.d.cts} +567 -438
  22. package/dist/{payload-types-BOsckg8B.d.ts → payload-types-BnIET0xU.d.ts} +567 -438
  23. package/dist/query.cjs +62 -3
  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 +62 -3
  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 +557 -20
  32. package/dist/server.cjs.map +1 -1
  33. package/dist/server.d.cts +14 -8
  34. package/dist/server.d.ts +14 -8
  35. package/dist/server.js +557 -20
  36. package/dist/server.js.map +1 -1
  37. package/dist/{types-5ZlcAFuU.d.ts → types-D1y4TgQm.d.ts} +2 -2
  38. package/dist/{types-Bj8j7VHU.d.ts → types-DnRC3nLG.d.ts} +464 -16
  39. package/dist/{types-B14sEt1z.d.cts → types-Dp1oYpD3.d.cts} +2 -2
  40. package/dist/{types-CM5qiR2k.d.cts → types-Dzn0LD2N.d.cts} +464 -16
  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.cjs +13 -2
  50. package/dist/webhook.cjs.map +1 -1
  51. package/dist/webhook.d.cts +5 -5
  52. package/dist/webhook.d.ts +5 -5
  53. package/dist/webhook.js +13 -2
  54. package/dist/webhook.js.map +1 -1
  55. package/package.json +9 -28
  56. package/dist/analytics/react.cjs +0 -344
  57. package/dist/analytics/react.cjs.map +0 -1
  58. package/dist/analytics/react.d.cts +0 -24
  59. package/dist/analytics/react.d.ts +0 -24
  60. package/dist/analytics/react.js +0 -319
  61. package/dist/analytics/react.js.map +0 -1
  62. package/dist/analytics.cjs +0 -238
  63. package/dist/analytics.cjs.map +0 -1
  64. package/dist/analytics.d.cts +0 -39
  65. package/dist/analytics.d.ts +0 -39
  66. package/dist/analytics.js +0 -215
  67. package/dist/analytics.js.map +0 -1
package/dist/server.cjs CHANGED
@@ -22,7 +22,11 @@ var server_exports = {};
22
22
  __export(server_exports, {
23
23
  CollectionClient: () => CollectionClient,
24
24
  CommunityClient: () => CommunityClient,
25
+ CustomerGroupApi: () => CustomerGroupApi,
25
26
  EventsClient: () => EventsClient,
27
+ ExternalCustomerLinksApi: () => ExternalCustomerLinksApi,
28
+ ExternalEffectClaimsApi: () => ExternalEffectClaimsApi,
29
+ InstallationCredentialsApi: () => InstallationCredentialsApi,
26
30
  ModerationApi: () => ModerationApi,
27
31
  ServerClient: () => ServerClient,
28
32
  ServerCollectionClient: () => ServerCollectionClient,
@@ -31,6 +35,7 @@ __export(server_exports, {
31
35
  TENANT_CONTEXT_PATH: () => TENANT_CONTEXT_PATH,
32
36
  TenantIntrospectionApi: () => TenantIntrospectionApi,
33
37
  createServerClient: () => createServerClient,
38
+ getExternalEffectClaimErrorReason: () => getExternalEffectClaimErrorReason,
34
39
  isApiError: () => isApiError,
35
40
  isAuthError: () => isAuthError,
36
41
  isCommerceSDKError: () => isCommerceSDKError,
@@ -1056,6 +1061,49 @@ function stockSnapshotSearchParams(params) {
1056
1061
  }
1057
1062
 
1058
1063
  // src/core/collection/http-client.ts
1064
+ function validateWhere(where) {
1065
+ if (where === void 0) return false;
1066
+ let hasNull = false;
1067
+ function visit(value, depth, key) {
1068
+ if (depth > 10) {
1069
+ throw createValidationError(
1070
+ "Collection where must not exceed nesting depth 10."
1071
+ );
1072
+ }
1073
+ if (value === null && (key === "equals" || key === "not_equals")) {
1074
+ hasNull = true;
1075
+ return;
1076
+ }
1077
+ if (value == null) {
1078
+ throw createValidationError(
1079
+ "Collection where must not contain null or undefined values."
1080
+ );
1081
+ }
1082
+ if (Array.isArray(value)) {
1083
+ if (value.length === 0) {
1084
+ throw createValidationError(
1085
+ "Collection where must not contain empty arrays, including and/or."
1086
+ );
1087
+ }
1088
+ if (value.length > 1e3) {
1089
+ throw createValidationError(
1090
+ "Collection where arrays must not contain more than 1000 elements."
1091
+ );
1092
+ }
1093
+ for (const item of value) visit(item, depth + 1);
1094
+ } else if (typeof value === "object" && !(value instanceof Date)) {
1095
+ const values = Object.entries(value);
1096
+ if (values.length === 0) {
1097
+ throw createValidationError(
1098
+ "Collection where must not contain empty condition objects."
1099
+ );
1100
+ }
1101
+ for (const [key2, item] of values) visit(item, depth + 1, key2);
1102
+ }
1103
+ }
1104
+ visit(where, 0);
1105
+ return hasNull;
1106
+ }
1059
1107
  var HttpClient = class {
1060
1108
  constructor(publishableKey, secretKey, getCustomerToken, onUnauthorized, onRequestId, apiUrl) {
1061
1109
  this.publishableKey = requirePublishableKeyForSecret(
@@ -1102,7 +1150,8 @@ var HttpClient = class {
1102
1150
  ...rest,
1103
1151
  "fallback-locale": fallbackLocale === false ? "none" : fallbackLocale
1104
1152
  };
1105
- const queryString = (0, import_qs_esm.stringify)(queryOptions, { addQueryPrefix: true });
1153
+ const encodedOptions = validateWhere(queryOptions.where) ? { ...queryOptions, where: JSON.stringify(queryOptions.where) } : queryOptions;
1154
+ const queryString = (0, import_qs_esm.stringify)(encodedOptions, { addQueryPrefix: true });
1106
1155
  return queryString ? `${endpoint}${queryString}` : endpoint;
1107
1156
  }
1108
1157
  assertJsonResponse(response) {
@@ -1499,10 +1548,11 @@ var CollectionClient = class extends HttpClient {
1499
1548
  * PATCH /api/{collection}
1500
1549
  */
1501
1550
  async requestUpdateMany(endpoint, data) {
1502
- const response = await this.fetchWithTracking(endpoint, {
1551
+ const url = this.buildUrl(endpoint, { where: data.where });
1552
+ const response = await this.fetchWithTracking(url, {
1503
1553
  ...this.defaultOptions,
1504
1554
  method: "PATCH",
1505
- body: JSON.stringify(data)
1555
+ body: JSON.stringify(data.data)
1506
1556
  });
1507
1557
  return this.parseFindResponse(response);
1508
1558
  }
@@ -1523,10 +1573,10 @@ var CollectionClient = class extends HttpClient {
1523
1573
  * DELETE /api/{collection}
1524
1574
  */
1525
1575
  async requestDeleteMany(endpoint, data) {
1526
- const response = await this.fetchWithTracking(endpoint, {
1576
+ const url = this.buildUrl(endpoint, { where: data.where });
1577
+ const response = await this.fetchWithTracking(url, {
1527
1578
  ...this.defaultOptions,
1528
- method: "DELETE",
1529
- body: JSON.stringify(data)
1579
+ method: "DELETE"
1530
1580
  });
1531
1581
  return this.parseFindResponse(response);
1532
1582
  }
@@ -1679,6 +1729,11 @@ var COMMERCE_ENDPOINT_OPERATIONS = {
1679
1729
  detail: strictCommerceOperation("checkouts", "post", "/detail"),
1680
1730
  query: strictCommerceOperation("checkouts", "post", "/query")
1681
1731
  },
1732
+ draftOrders: {
1733
+ calculate: operation("draft-orders", "post", "/:id/calculate"),
1734
+ complete: operation("draft-orders", "post", "/:id/complete"),
1735
+ finalize: operation("draft-orders", "post", "/:id/finalize")
1736
+ },
1682
1737
  transactions: {
1683
1738
  update: operation("transactions", "post", "/update")
1684
1739
  },
@@ -1778,8 +1833,51 @@ var portOneStandardActionCapabilityOperations = /* @__PURE__ */ new Set([
1778
1833
  ]);
1779
1834
  var MEMBERSHIP_ENDPOINT_OPERATIONS = {
1780
1835
  subscribe: operation(null, "post", "/memberships/subscribe"),
1836
+ billingCustody: operation(null, "post", "/memberships/billing-custody"),
1781
1837
  cancel: operation(null, "post", "/memberships/:id/cancel"),
1782
- me: operation(null, "get", "/memberships/me")
1838
+ me: operation(null, "get", "/memberships/me"),
1839
+ chargeResult: operation(null, "post", "/memberships/:id/charge-result"),
1840
+ refundResult: operation(null, "post", "/memberships/:id/refund-result"),
1841
+ revoke: operation(null, "post", "/memberships/:id/revoke")
1842
+ };
1843
+ var EXTERNAL_EFFECT_CLAIM_ENDPOINT_OPERATIONS = {
1844
+ claim: operation(null, "post", "/external-effect-claims/claim"),
1845
+ get: operation(null, "post", "/external-effect-claims/get"),
1846
+ arm: operation(null, "post", "/external-effect-claims/arm"),
1847
+ release: operation(null, "post", "/external-effect-claims/release"),
1848
+ report: operation(null, "post", "/external-effect-claims/report"),
1849
+ recovery: operation(null, "post", "/external-effect-claims/recovery")
1850
+ };
1851
+ var INSTALLATION_CREDENTIAL_ENDPOINT_OPERATIONS = {
1852
+ create: operation(null, "post", "/installation-credentials/create"),
1853
+ get: operation(null, "post", "/installation-credentials/get"),
1854
+ replace: operation(null, "post", "/installation-credentials/replace"),
1855
+ dispose: operation(null, "post", "/installation-credentials/dispose")
1856
+ };
1857
+ var EXTERNAL_CUSTOMER_LINK_ENDPOINT_OPERATIONS = {
1858
+ connect: operation("customers", "post", "/external-links/connect"),
1859
+ get: operation("customers", "post", "/external-links/get"),
1860
+ list: operation("customers", "post", "/external-links/list"),
1861
+ unlink: operation("customers", "post", "/external-links/unlink"),
1862
+ capturePreviousState: operation(
1863
+ "customers",
1864
+ "post",
1865
+ "/external-links/capture-previous-state"
1866
+ ),
1867
+ clearPreviousState: operation(
1868
+ "customers",
1869
+ "post",
1870
+ "/external-links/clear-previous-state"
1871
+ )
1872
+ };
1873
+ var CUSTOMER_GROUP_ENDPOINT_OPERATIONS = {
1874
+ members: operation("customer-groups", "get", "/:id/members"),
1875
+ grant: operation("customer-groups", "post", "/:id/members/grant"),
1876
+ revoke: operation("customer-groups", "post", "/:id/members/revoke")
1877
+ };
1878
+ var CUSTOMER_AUTH_ENDPOINT_OPERATIONS = {
1879
+ revokeRefresh: operation("customers", "post", "/revoke-refresh"),
1880
+ withdraw: operation("customers", "post", "/withdraw")
1783
1881
  };
1784
1882
  var EMBEDDED_ADMIN_ENDPOINT_OPERATIONS = {
1785
1883
  show: operation("tenants", "get", "/embedded-admin-app"),
@@ -1804,6 +1902,14 @@ var COMMUNITY_ENDPOINT_OPERATIONS = {
1804
1902
  detail: operation("posts", "get", "/detail")
1805
1903
  }
1806
1904
  };
1905
+ var GALLERY_ENDPOINT_OPERATIONS = {
1906
+ items: {
1907
+ storefront: operation("gallery-items", "get", "/storefront")
1908
+ }
1909
+ };
1910
+ var VIDEO_ENDPOINT_OPERATIONS = {
1911
+ playback: operation("videos", "post", "/:id/playback")
1912
+ };
1807
1913
  function resolveOperationTemplate(descriptor) {
1808
1914
  return descriptor.collection ? `/api/${descriptor.collection}${descriptor.path}` : `/api${descriptor.path}`;
1809
1915
  }
@@ -2501,7 +2607,10 @@ var MAX_COMMERCE_CAPABILITY_LENGTH = 512;
2501
2607
  var MAX_CART_DISCOUNT_CODE_LENGTH = 128;
2502
2608
  var CHECKOUT_STATUSES = ["open", "placed", "abandoned"];
2503
2609
  var ABANDONED_REASONS = ["expired", "customer", "operator"];
2504
- var PAYMENT_PROVIDERS = ["toss", "portone"];
2610
+ function managedPaymentProviders(providers) {
2611
+ return providers;
2612
+ }
2613
+ var PAYMENT_PROVIDERS = managedPaymentProviders(["toss", "portone"]);
2505
2614
  var PAYMENT_PROVIDER_STATUSES = [
2506
2615
  "requires_payment_method",
2507
2616
  "requires_action",
@@ -2561,6 +2670,26 @@ function invalidCanonicalResponse(resource, details) {
2561
2670
  function fail(resource, path, expected) {
2562
2671
  invalidCanonicalResponse(resource, { path, expected });
2563
2672
  }
2673
+ function providerMismatch(resource, expected, actual, operation2) {
2674
+ if (operation2 === "cancel") {
2675
+ const method = {
2676
+ toss: "cancel()",
2677
+ portone: "cancelPortOne()"
2678
+ }[actual];
2679
+ throw createApiError(
2680
+ `Canonical ${resource} response provider mismatch: expected ${expected}, received ${actual}.`,
2681
+ 502,
2682
+ { resource, path: "$.provider", expected, actual },
2683
+ `The server applied the cancellation to a ${actual} PaymentSession, but this SDK method expects ${expected}.`,
2684
+ `Re-invoke ${method} with the same idempotencyKey; do not create a new key.`
2685
+ );
2686
+ }
2687
+ invalidCanonicalResponse(resource, {
2688
+ path: "$.provider",
2689
+ expected,
2690
+ actual
2691
+ });
2692
+ }
2564
2693
  function record(value, resource, path) {
2565
2694
  if (!value || typeof value !== "object" || Array.isArray(value)) {
2566
2695
  fail(resource, path, "object");
@@ -3837,7 +3966,7 @@ function validateNextAction(value, provider, resource, path) {
3837
3966
  if (action.customerEmail !== void 0)
3838
3967
  validateCustomer({ email: action.customerEmail }, resource, path);
3839
3968
  }
3840
- function validatePublicPaymentSession(value, expectedProvider) {
3969
+ function validatePublicPaymentSession(value, expectedProvider, operation2) {
3841
3970
  const resource = "PaymentSession";
3842
3971
  const session = record(value, resource, "$");
3843
3972
  const provider = enumValue(
@@ -3846,9 +3975,6 @@ function validatePublicPaymentSession(value, expectedProvider) {
3846
3975
  resource,
3847
3976
  "$.provider"
3848
3977
  );
3849
- if (expectedProvider !== void 0 && provider !== expectedProvider) {
3850
- fail(resource, "$.provider", expectedProvider);
3851
- }
3852
3978
  const status = enumValue(
3853
3979
  session.providerStatus,
3854
3980
  PAYMENT_PROVIDER_STATUSES,
@@ -4052,6 +4178,16 @@ function validatePublicPaymentSession(value, expectedProvider) {
4052
4178
  "$.cancellationReason"
4053
4179
  );
4054
4180
  }
4181
+ if (expectedProvider !== void 0 && provider !== expectedProvider) {
4182
+ if (operation2 === "cancel" && status !== "canceling" && status !== "canceled") {
4183
+ fail(
4184
+ resource,
4185
+ "$.providerStatus",
4186
+ "canceling or canceled after a successful cancellation"
4187
+ );
4188
+ }
4189
+ providerMismatch(resource, expectedProvider, provider, operation2);
4190
+ }
4055
4191
  return value;
4056
4192
  }
4057
4193
 
@@ -5603,8 +5739,12 @@ var PaymentSessionApi = class extends CustomerScopedApi {
5603
5739
  ...Object.keys(headers).length > 0 && { headers }
5604
5740
  });
5605
5741
  }
5606
- async paymentSession(result, expectedProvider) {
5607
- return validatePublicPaymentSession(await result, expectedProvider);
5742
+ async paymentSession(result, expectedProvider, operation2) {
5743
+ return validatePublicPaymentSession(
5744
+ await result,
5745
+ expectedProvider,
5746
+ operation2
5747
+ );
5608
5748
  }
5609
5749
  create(params) {
5610
5750
  const { idempotencyKey, ...body } = params;
@@ -5651,7 +5791,8 @@ var PaymentSessionApi = class extends CustomerScopedApi {
5651
5791
  const endpoint = this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.cancel : COMMERCE_ENDPOINTS.paymentSessions.cancel;
5652
5792
  return this.paymentSession(
5653
5793
  this.post(endpoint, body, idempotencyKey),
5654
- "toss"
5794
+ "toss",
5795
+ "cancel"
5655
5796
  );
5656
5797
  }
5657
5798
  cancelPortOne(params) {
@@ -5660,7 +5801,8 @@ var PaymentSessionApi = class extends CustomerScopedApi {
5660
5801
  const endpoint = this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.cancel : COMMERCE_ENDPOINTS.paymentSessions.cancel;
5661
5802
  return this.paymentSession(
5662
5803
  this.post(endpoint, body, idempotencyKey),
5663
- "portone"
5804
+ "portone",
5805
+ "cancel"
5664
5806
  );
5665
5807
  }
5666
5808
  confirm(params) {
@@ -6046,6 +6188,42 @@ function appendValues(params, key, value) {
6046
6188
  }
6047
6189
  }
6048
6190
 
6191
+ // src/core/video/video-playback-client.ts
6192
+ var VideoPlaybackClient = class {
6193
+ constructor(options) {
6194
+ this.options = options;
6195
+ if (typeof window !== "undefined") {
6196
+ throw new TypeError("VideoPlaybackClient requires a server environment");
6197
+ }
6198
+ }
6199
+ async playback(videoId) {
6200
+ if (!videoId) throw new TypeError("videoId is required");
6201
+ const endpoint = resolveOperationPath(VIDEO_ENDPOINT_OPERATIONS.playback, {
6202
+ pathParams: { id: videoId }
6203
+ });
6204
+ try {
6205
+ const response = await httpFetch(endpoint, {
6206
+ method: resolveOperationMethod(VIDEO_ENDPOINT_OPERATIONS.playback),
6207
+ apiUrl: this.options.apiUrl,
6208
+ publishableKey: this.options.publishableKey,
6209
+ secretKey: this.options.secretKey
6210
+ });
6211
+ this.options.onRequestId?.(response.headers.get("x-request-id") ?? null);
6212
+ const result = await parseApiResponse(response, endpoint);
6213
+ const base = resolveApiUrl(this.options.apiUrl);
6214
+ return {
6215
+ streamUrl: new URL(result.streamPath, base).toString(),
6216
+ mode: result.mode
6217
+ };
6218
+ } catch (error) {
6219
+ this.options.onRequestId?.(
6220
+ error instanceof SDKError ? error.requestId ?? null : null
6221
+ );
6222
+ throw error;
6223
+ }
6224
+ }
6225
+ };
6226
+
6049
6227
  // src/core/market/market-discovery.ts
6050
6228
  function toMarketDTO(row) {
6051
6229
  return {
@@ -6116,14 +6294,34 @@ var TenantIntrospectionApi = class extends RawBaseApi {
6116
6294
  };
6117
6295
 
6118
6296
  // src/core/api/membership-api.ts
6297
+ async function custodySignature(body, secret, timestamp2, deliveryId) {
6298
+ const encoder = new TextEncoder();
6299
+ const key = await crypto.subtle.importKey(
6300
+ "raw",
6301
+ encoder.encode(secret),
6302
+ { name: "HMAC", hash: "SHA-256" },
6303
+ false,
6304
+ ["sign"]
6305
+ );
6306
+ const signature = await crypto.subtle.sign(
6307
+ "HMAC",
6308
+ key,
6309
+ encoder.encode(`${timestamp2}.${deliveryId}.billing-custody.v1:${body}`)
6310
+ );
6311
+ return Array.from(
6312
+ new Uint8Array(signature),
6313
+ (byte) => byte.toString(16).padStart(2, "0")
6314
+ ).join("");
6315
+ }
6119
6316
  var MembershipApi = class extends BaseApi {
6120
6317
  constructor(options) {
6121
6318
  super("MembershipApi", options);
6122
6319
  }
6123
6320
  /**
6124
- * Record a delegated first-charge and activate a membership.
6125
- * The storefront collected the payment; this endpoint deduplicates by
6126
- * `subscribeIntentKey` and records the already-paid charge.
6321
+ * Prepare a delegated first charge for a paid Membership, or immediately
6322
+ * start a trial. For a paid response, charge through the tenant PSP with
6323
+ * `firstCharge.idempotencyKey`, then post the existing signed charge result
6324
+ * to activate the membership.
6127
6325
  *
6128
6326
  * `subscribeIntentKey` is used as the HTTP idempotency key so the call is
6129
6327
  * safely retryable.
@@ -6150,6 +6348,334 @@ var MembershipApi = class extends BaseApi {
6150
6348
  { pathParams: { id } }
6151
6349
  );
6152
6350
  }
6351
+ /**
6352
+ * Store/read only app-encrypted billing ciphertext for the Membership's
6353
+ * method. The tenant server receives the non-secret restore generation from
6354
+ * its platform operator's integration configuration; it is not discovered
6355
+ * from an unauthenticated endpoint.
6356
+ */
6357
+ async billingCustody(params) {
6358
+ const { webhookSecret, ...input } = params;
6359
+ const body = {
6360
+ kind: "billing-custody.v1",
6361
+ ...input
6362
+ };
6363
+ const timestamp2 = Date.now().toString();
6364
+ const deliveryId = crypto.randomUUID();
6365
+ const signature = await custodySignature(
6366
+ JSON.stringify(body),
6367
+ webhookSecret,
6368
+ timestamp2,
6369
+ deliveryId
6370
+ );
6371
+ return this.requestEndpoint(
6372
+ MEMBERSHIP_ENDPOINT_OPERATIONS.billingCustody,
6373
+ body,
6374
+ {
6375
+ headers: {
6376
+ "x-membership-signature": signature,
6377
+ "x-membership-timestamp": timestamp2,
6378
+ "x-membership-delivery-id": deliveryId
6379
+ }
6380
+ }
6381
+ );
6382
+ }
6383
+ };
6384
+
6385
+ // src/core/api/customer-group-api.ts
6386
+ var CustomerGroupApi = class extends BaseApi {
6387
+ constructor(options) {
6388
+ super("CustomerGroupApi", options);
6389
+ }
6390
+ listMembers(params) {
6391
+ const query = new URLSearchParams();
6392
+ if (params.page !== void 0) query.set("page", String(params.page));
6393
+ if (params.limit !== void 0) query.set("limit", String(params.limit));
6394
+ return this.requestEndpoint(
6395
+ CUSTOMER_GROUP_ENDPOINT_OPERATIONS.members,
6396
+ void 0,
6397
+ { pathParams: { id: params.groupId }, query }
6398
+ );
6399
+ }
6400
+ grantMember(params) {
6401
+ const { groupId, ...body } = params;
6402
+ return this.requestEndpoint(
6403
+ CUSTOMER_GROUP_ENDPOINT_OPERATIONS.grant,
6404
+ body,
6405
+ { pathParams: { id: groupId } }
6406
+ );
6407
+ }
6408
+ revokeMember(params) {
6409
+ const { groupId, ...body } = params;
6410
+ return this.requestEndpoint(
6411
+ CUSTOMER_GROUP_ENDPOINT_OPERATIONS.revoke,
6412
+ body,
6413
+ { pathParams: { id: groupId } }
6414
+ );
6415
+ }
6416
+ };
6417
+
6418
+ // src/core/api/external-effect-claims-api.ts
6419
+ var errorReasons = /* @__PURE__ */ new Set([
6420
+ "invalid_evidence",
6421
+ "denied",
6422
+ "conflict",
6423
+ "lease_lost",
6424
+ "unknown",
6425
+ "quota_exceeded",
6426
+ "forbidden",
6427
+ "authority_unavailable",
6428
+ "internal_error"
6429
+ ]);
6430
+ function getExternalEffectClaimErrorReason(error) {
6431
+ const reason = getSDKErrorReason(error);
6432
+ return errorReasons.has(reason) ? reason : void 0;
6433
+ }
6434
+ var states = /* @__PURE__ */ new Set([
6435
+ "pre_dispatch_claimed",
6436
+ "armed_unknown",
6437
+ "reported_effect",
6438
+ "reported_no_effect",
6439
+ "reconciliation_required",
6440
+ "reconciled_effect",
6441
+ "reconciled_no_effect",
6442
+ "unresolved_closed"
6443
+ ]);
6444
+ function invalidResponse() {
6445
+ throw createApiError(
6446
+ "Invalid external-effect claim response",
6447
+ 200,
6448
+ void 0,
6449
+ "Server returned an invalid response.",
6450
+ "Check the API version and retry after resolving the mismatch."
6451
+ );
6452
+ }
6453
+ function claimFromResponse(value) {
6454
+ if (!value || typeof value !== "object" || !("claim" in value))
6455
+ invalidResponse();
6456
+ const claim = value.claim;
6457
+ if (!claim || typeof claim !== "object") invalidResponse();
6458
+ const row = claim;
6459
+ if (typeof row.id !== "string" || !states.has(row.state) || row.armedAt !== null && typeof row.armedAt !== "string" || row.firstReportOutcome !== null && row.firstReportOutcome !== "effect" && row.firstReportOutcome !== "no_effect" || row.reportAuthority !== "tenant_supplied_unverified" || typeof row.leaseGranted !== "boolean" || row.leaseToken !== null && typeof row.leaseToken !== "string" || !Number.isSafeInteger(row.leaseGeneration) || row.leaseGranted && row.leaseToken === null || !row.leaseGranted && row.leaseToken !== null)
6460
+ invalidResponse();
6461
+ return {
6462
+ id: row.id,
6463
+ state: row.state,
6464
+ armedAt: row.armedAt,
6465
+ firstReportOutcome: row.firstReportOutcome,
6466
+ reportAuthority: "tenant_supplied_unverified",
6467
+ leaseGranted: row.leaseGranted,
6468
+ leaseToken: row.leaseToken,
6469
+ leaseGeneration: row.leaseGeneration
6470
+ };
6471
+ }
6472
+ var ExternalEffectClaimsApi = class extends BaseApi {
6473
+ constructor(options) {
6474
+ super("ExternalEffectClaimsApi", options);
6475
+ }
6476
+ async claim(params) {
6477
+ return claimFromResponse(
6478
+ await this.requestEndpoint(
6479
+ EXTERNAL_EFFECT_CLAIM_ENDPOINT_OPERATIONS.claim,
6480
+ params
6481
+ )
6482
+ );
6483
+ }
6484
+ async get(params) {
6485
+ return claimFromResponse(
6486
+ await this.requestEndpoint(
6487
+ EXTERNAL_EFFECT_CLAIM_ENDPOINT_OPERATIONS.get,
6488
+ params
6489
+ )
6490
+ );
6491
+ }
6492
+ async arm(params) {
6493
+ return claimFromResponse(
6494
+ await this.requestEndpoint(
6495
+ EXTERNAL_EFFECT_CLAIM_ENDPOINT_OPERATIONS.arm,
6496
+ params
6497
+ )
6498
+ );
6499
+ }
6500
+ async release(params) {
6501
+ const result = await this.requestEndpoint(
6502
+ EXTERNAL_EFFECT_CLAIM_ENDPOINT_OPERATIONS.release,
6503
+ params
6504
+ );
6505
+ if (!result || typeof result !== "object" || !("released" in result) || result.released !== true)
6506
+ invalidResponse();
6507
+ }
6508
+ async report(params) {
6509
+ return claimFromResponse(
6510
+ await this.requestEndpoint(
6511
+ EXTERNAL_EFFECT_CLAIM_ENDPOINT_OPERATIONS.report,
6512
+ params
6513
+ )
6514
+ );
6515
+ }
6516
+ async recovery(params) {
6517
+ const result = await this.requestEndpoint(
6518
+ EXTERNAL_EFFECT_CLAIM_ENDPOINT_OPERATIONS.recovery,
6519
+ params
6520
+ );
6521
+ if (!result || typeof result !== "object" || !("recorded" in result) || result.recorded !== true)
6522
+ invalidResponse();
6523
+ }
6524
+ };
6525
+
6526
+ // src/core/api/installation-credentials-api.ts
6527
+ function invalidResponse2() {
6528
+ throw createApiError(
6529
+ "Invalid installation credential response",
6530
+ 200,
6531
+ void 0,
6532
+ "Server returned an invalid response.",
6533
+ "Check the API version and retry after resolving the mismatch."
6534
+ );
6535
+ }
6536
+ function snapshot(value) {
6537
+ if (!value || typeof value !== "object") invalidResponse2();
6538
+ const row = value;
6539
+ if (typeof row.installationId !== "string" || typeof row.providerNamespace !== "string" || typeof row.providerAccountId !== "string" || typeof row.ciphertext !== "string" || row.ciphertext.length < 32 || row.ciphertext.length > 8192 || !Number.isSafeInteger(row.version) || row.version < 1)
6540
+ invalidResponse2();
6541
+ return row;
6542
+ }
6543
+ var InstallationCredentialsApi = class extends BaseApi {
6544
+ constructor(options) {
6545
+ super("InstallationCredentialsApi", options);
6546
+ }
6547
+ create(params) {
6548
+ return this.requestEndpoint(
6549
+ INSTALLATION_CREDENTIAL_ENDPOINT_OPERATIONS.create,
6550
+ params
6551
+ ).then(snapshot);
6552
+ }
6553
+ get(params) {
6554
+ return this.requestEndpoint(
6555
+ INSTALLATION_CREDENTIAL_ENDPOINT_OPERATIONS.get,
6556
+ params
6557
+ ).then(snapshot);
6558
+ }
6559
+ replace(params) {
6560
+ return this.requestEndpoint(
6561
+ INSTALLATION_CREDENTIAL_ENDPOINT_OPERATIONS.replace,
6562
+ params
6563
+ ).then(snapshot);
6564
+ }
6565
+ async dispose(params) {
6566
+ const result = await this.requestEndpoint(
6567
+ INSTALLATION_CREDENTIAL_ENDPOINT_OPERATIONS.dispose,
6568
+ params
6569
+ );
6570
+ if (!result || typeof result !== "object") invalidResponse2();
6571
+ const row = result;
6572
+ if (row.installationId !== params.installationId || !Number.isSafeInteger(row.version) || row.version !== params.expectedVersion + 1 || row.state !== "disposed")
6573
+ invalidResponse2();
6574
+ return row;
6575
+ }
6576
+ };
6577
+
6578
+ // src/core/api/external-customer-links-api.ts
6579
+ function invalidResponse3() {
6580
+ throw createApiError("Invalid external-customer link response", 200);
6581
+ }
6582
+ var uuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
6583
+ var isUuid = (value) => typeof value === "string" && (uuid.test(value) || value === "00000000-0000-0000-0000-000000000000" || value.toLowerCase() === "ffffffff-ffff-ffff-ffff-ffffffffffff");
6584
+ var isIdentity = (value) => typeof value === "string" && value.length > 0 && value.length <= 256 && value === value.trim() && // eslint-disable-next-line no-control-regex -- Normalized identity forbids C0 controls.
6585
+ !/[\u0000-\u001f]/.test(value) && !/[\uD800-\uDFFF]/u.test(value);
6586
+ var isDateTime = (value) => {
6587
+ if (typeof value !== "string" || !/^\d{4}-\d{2}-\d{2}T(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/.test(
6588
+ value
6589
+ ) || !Number.isFinite(Date.parse(value)))
6590
+ return false;
6591
+ const day = value.slice(0, 10);
6592
+ return (/* @__PURE__ */ new Date(`${day}T00:00:00Z`)).toISOString().startsWith(day);
6593
+ };
6594
+ function previousStateFromResponse(value) {
6595
+ if (value === null) return null;
6596
+ if (!value || typeof value !== "object" || Array.isArray(value))
6597
+ invalidResponse3();
6598
+ const entries = Object.entries(value);
6599
+ if (entries.length > 16 || entries.some(
6600
+ ([key, entry]) => !/^[a-zA-Z][a-zA-Z0-9_]{0,63}$/.test(key) || !(entry === null || typeof entry === "boolean" || typeof entry === "string" && entry.length <= 512 && // eslint-disable-next-line no-control-regex -- PostgreSQL JSON cannot store NUL or lone surrogates.
6601
+ !/[\u0000\uD800-\uDFFF]/u.test(entry) || typeof entry === "number" && Number.isFinite(entry))
6602
+ ))
6603
+ invalidResponse3();
6604
+ const result = Object.fromEntries(entries);
6605
+ if (new TextEncoder().encode(JSON.stringify(result)).length > 2048)
6606
+ invalidResponse3();
6607
+ return result;
6608
+ }
6609
+ function linkFromResponse(value) {
6610
+ if (!value || typeof value !== "object") invalidResponse3();
6611
+ const row = value;
6612
+ if (!isUuid(row.id) || !isUuid(row.customerId) || !isIdentity(row.namespace) || !isIdentity(row.accountScope) || row.externalCustomerId !== null && !isIdentity(row.externalCustomerId) || !["active", "released", "erased"].includes(row.state) || !isDateTime(row.connectedAt) || row.releasedAt !== null && !isDateTime(row.releasedAt) || !Number.isSafeInteger(row.version) || row.version < 1)
6613
+ invalidResponse3();
6614
+ const previousState = previousStateFromResponse(row.previousState);
6615
+ if (row.state === "erased" ? row.externalCustomerId !== null || previousState !== null : row.externalCustomerId === null)
6616
+ invalidResponse3();
6617
+ return {
6618
+ id: row.id,
6619
+ customerId: row.customerId,
6620
+ namespace: row.namespace,
6621
+ accountScope: row.accountScope,
6622
+ externalCustomerId: row.externalCustomerId,
6623
+ state: row.state,
6624
+ connectedAt: row.connectedAt,
6625
+ releasedAt: row.releasedAt,
6626
+ version: row.version,
6627
+ previousState
6628
+ };
6629
+ }
6630
+ var ExternalCustomerLinksApi = class extends BaseApi {
6631
+ constructor(options) {
6632
+ super("ExternalCustomerLinksApi", options);
6633
+ }
6634
+ async command(operation2, params) {
6635
+ const result = await this.requestEndpoint(operation2, params);
6636
+ if (!result || typeof result !== "object" || !("link" in result))
6637
+ invalidResponse3();
6638
+ return linkFromResponse(result.link);
6639
+ }
6640
+ connect(params) {
6641
+ return this.command(
6642
+ EXTERNAL_CUSTOMER_LINK_ENDPOINT_OPERATIONS.connect,
6643
+ params
6644
+ );
6645
+ }
6646
+ get(params) {
6647
+ return this.command(EXTERNAL_CUSTOMER_LINK_ENDPOINT_OPERATIONS.get, params);
6648
+ }
6649
+ async list(params) {
6650
+ const result = await this.requestEndpoint(
6651
+ EXTERNAL_CUSTOMER_LINK_ENDPOINT_OPERATIONS.list,
6652
+ params
6653
+ );
6654
+ if (!result || typeof result !== "object" || !("links" in result) || !Array.isArray(result.links) || result.links.length > 100 || !("nextCursor" in result) || result.nextCursor !== null && !isUuid(result.nextCursor))
6655
+ invalidResponse3();
6656
+ return {
6657
+ links: result.links.map(linkFromResponse),
6658
+ nextCursor: result.nextCursor
6659
+ };
6660
+ }
6661
+ unlink(params) {
6662
+ return this.command(
6663
+ EXTERNAL_CUSTOMER_LINK_ENDPOINT_OPERATIONS.unlink,
6664
+ params
6665
+ );
6666
+ }
6667
+ capturePreviousState(params) {
6668
+ return this.command(
6669
+ EXTERNAL_CUSTOMER_LINK_ENDPOINT_OPERATIONS.capturePreviousState,
6670
+ params
6671
+ );
6672
+ }
6673
+ clearPreviousState(params) {
6674
+ return this.command(
6675
+ EXTERNAL_CUSTOMER_LINK_ENDPOINT_OPERATIONS.clearPreviousState,
6676
+ params
6677
+ );
6678
+ }
6153
6679
  };
6154
6680
 
6155
6681
  // src/core/client/client.server.ts
@@ -6186,11 +6712,22 @@ var ServerClient = class _ServerClient {
6186
6712
  onRequestId
6187
6713
  };
6188
6714
  this.commerce = new ServerCommerceClient(serverOptions);
6715
+ this.video = new VideoPlaybackClient({
6716
+ publishableKey: this.config.publishableKey,
6717
+ secretKey: this.config.secretKey,
6718
+ apiUrl: this.config.apiUrl,
6719
+ onRequestId
6720
+ });
6189
6721
  const membershipApi = new MembershipApi(serverOptions);
6190
6722
  this.memberships = {
6191
6723
  subscribe: membershipApi.subscribe.bind(membershipApi),
6192
- cancel: membershipApi.cancel.bind(membershipApi)
6724
+ cancel: membershipApi.cancel.bind(membershipApi),
6725
+ billingCustody: membershipApi.billingCustody.bind(membershipApi)
6193
6726
  };
6727
+ this.customerGroups = new CustomerGroupApi(serverOptions);
6728
+ this.externalEffectClaims = new ExternalEffectClaimsApi(serverOptions);
6729
+ this.installationCredentials = new InstallationCredentialsApi(serverOptions);
6730
+ this.externalCustomerLinks = new ExternalCustomerLinksApi(serverOptions);
6194
6731
  const tenantIntrospectionApi = new TenantIntrospectionApi(serverOptions);
6195
6732
  this.tenant = {
6196
6733
  context: tenantIntrospectionApi.context.bind(tenantIntrospectionApi),