@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.js CHANGED
@@ -1005,6 +1005,49 @@ function stockSnapshotSearchParams(params) {
1005
1005
  }
1006
1006
 
1007
1007
  // src/core/collection/http-client.ts
1008
+ function validateWhere(where) {
1009
+ if (where === void 0) return false;
1010
+ let hasNull = false;
1011
+ function visit(value, depth, key) {
1012
+ if (depth > 10) {
1013
+ throw createValidationError(
1014
+ "Collection where must not exceed nesting depth 10."
1015
+ );
1016
+ }
1017
+ if (value === null && (key === "equals" || key === "not_equals")) {
1018
+ hasNull = true;
1019
+ return;
1020
+ }
1021
+ if (value == null) {
1022
+ throw createValidationError(
1023
+ "Collection where must not contain null or undefined values."
1024
+ );
1025
+ }
1026
+ if (Array.isArray(value)) {
1027
+ if (value.length === 0) {
1028
+ throw createValidationError(
1029
+ "Collection where must not contain empty arrays, including and/or."
1030
+ );
1031
+ }
1032
+ if (value.length > 1e3) {
1033
+ throw createValidationError(
1034
+ "Collection where arrays must not contain more than 1000 elements."
1035
+ );
1036
+ }
1037
+ for (const item of value) visit(item, depth + 1);
1038
+ } else if (typeof value === "object" && !(value instanceof Date)) {
1039
+ const values = Object.entries(value);
1040
+ if (values.length === 0) {
1041
+ throw createValidationError(
1042
+ "Collection where must not contain empty condition objects."
1043
+ );
1044
+ }
1045
+ for (const [key2, item] of values) visit(item, depth + 1, key2);
1046
+ }
1047
+ }
1048
+ visit(where, 0);
1049
+ return hasNull;
1050
+ }
1008
1051
  var HttpClient = class {
1009
1052
  constructor(publishableKey, secretKey, getCustomerToken, onUnauthorized, onRequestId, apiUrl) {
1010
1053
  this.publishableKey = requirePublishableKeyForSecret(
@@ -1051,7 +1094,8 @@ var HttpClient = class {
1051
1094
  ...rest,
1052
1095
  "fallback-locale": fallbackLocale === false ? "none" : fallbackLocale
1053
1096
  };
1054
- const queryString = stringify(queryOptions, { addQueryPrefix: true });
1097
+ const encodedOptions = validateWhere(queryOptions.where) ? { ...queryOptions, where: JSON.stringify(queryOptions.where) } : queryOptions;
1098
+ const queryString = stringify(encodedOptions, { addQueryPrefix: true });
1055
1099
  return queryString ? `${endpoint}${queryString}` : endpoint;
1056
1100
  }
1057
1101
  assertJsonResponse(response) {
@@ -1448,10 +1492,11 @@ var CollectionClient = class extends HttpClient {
1448
1492
  * PATCH /api/{collection}
1449
1493
  */
1450
1494
  async requestUpdateMany(endpoint, data) {
1451
- const response = await this.fetchWithTracking(endpoint, {
1495
+ const url = this.buildUrl(endpoint, { where: data.where });
1496
+ const response = await this.fetchWithTracking(url, {
1452
1497
  ...this.defaultOptions,
1453
1498
  method: "PATCH",
1454
- body: JSON.stringify(data)
1499
+ body: JSON.stringify(data.data)
1455
1500
  });
1456
1501
  return this.parseFindResponse(response);
1457
1502
  }
@@ -1472,10 +1517,10 @@ var CollectionClient = class extends HttpClient {
1472
1517
  * DELETE /api/{collection}
1473
1518
  */
1474
1519
  async requestDeleteMany(endpoint, data) {
1475
- const response = await this.fetchWithTracking(endpoint, {
1520
+ const url = this.buildUrl(endpoint, { where: data.where });
1521
+ const response = await this.fetchWithTracking(url, {
1476
1522
  ...this.defaultOptions,
1477
- method: "DELETE",
1478
- body: JSON.stringify(data)
1523
+ method: "DELETE"
1479
1524
  });
1480
1525
  return this.parseFindResponse(response);
1481
1526
  }
@@ -1628,6 +1673,11 @@ var COMMERCE_ENDPOINT_OPERATIONS = {
1628
1673
  detail: strictCommerceOperation("checkouts", "post", "/detail"),
1629
1674
  query: strictCommerceOperation("checkouts", "post", "/query")
1630
1675
  },
1676
+ draftOrders: {
1677
+ calculate: operation("draft-orders", "post", "/:id/calculate"),
1678
+ complete: operation("draft-orders", "post", "/:id/complete"),
1679
+ finalize: operation("draft-orders", "post", "/:id/finalize")
1680
+ },
1631
1681
  transactions: {
1632
1682
  update: operation("transactions", "post", "/update")
1633
1683
  },
@@ -1727,8 +1777,51 @@ var portOneStandardActionCapabilityOperations = /* @__PURE__ */ new Set([
1727
1777
  ]);
1728
1778
  var MEMBERSHIP_ENDPOINT_OPERATIONS = {
1729
1779
  subscribe: operation(null, "post", "/memberships/subscribe"),
1780
+ billingCustody: operation(null, "post", "/memberships/billing-custody"),
1730
1781
  cancel: operation(null, "post", "/memberships/:id/cancel"),
1731
- me: operation(null, "get", "/memberships/me")
1782
+ me: operation(null, "get", "/memberships/me"),
1783
+ chargeResult: operation(null, "post", "/memberships/:id/charge-result"),
1784
+ refundResult: operation(null, "post", "/memberships/:id/refund-result"),
1785
+ revoke: operation(null, "post", "/memberships/:id/revoke")
1786
+ };
1787
+ var EXTERNAL_EFFECT_CLAIM_ENDPOINT_OPERATIONS = {
1788
+ claim: operation(null, "post", "/external-effect-claims/claim"),
1789
+ get: operation(null, "post", "/external-effect-claims/get"),
1790
+ arm: operation(null, "post", "/external-effect-claims/arm"),
1791
+ release: operation(null, "post", "/external-effect-claims/release"),
1792
+ report: operation(null, "post", "/external-effect-claims/report"),
1793
+ recovery: operation(null, "post", "/external-effect-claims/recovery")
1794
+ };
1795
+ var INSTALLATION_CREDENTIAL_ENDPOINT_OPERATIONS = {
1796
+ create: operation(null, "post", "/installation-credentials/create"),
1797
+ get: operation(null, "post", "/installation-credentials/get"),
1798
+ replace: operation(null, "post", "/installation-credentials/replace"),
1799
+ dispose: operation(null, "post", "/installation-credentials/dispose")
1800
+ };
1801
+ var EXTERNAL_CUSTOMER_LINK_ENDPOINT_OPERATIONS = {
1802
+ connect: operation("customers", "post", "/external-links/connect"),
1803
+ get: operation("customers", "post", "/external-links/get"),
1804
+ list: operation("customers", "post", "/external-links/list"),
1805
+ unlink: operation("customers", "post", "/external-links/unlink"),
1806
+ capturePreviousState: operation(
1807
+ "customers",
1808
+ "post",
1809
+ "/external-links/capture-previous-state"
1810
+ ),
1811
+ clearPreviousState: operation(
1812
+ "customers",
1813
+ "post",
1814
+ "/external-links/clear-previous-state"
1815
+ )
1816
+ };
1817
+ var CUSTOMER_GROUP_ENDPOINT_OPERATIONS = {
1818
+ members: operation("customer-groups", "get", "/:id/members"),
1819
+ grant: operation("customer-groups", "post", "/:id/members/grant"),
1820
+ revoke: operation("customer-groups", "post", "/:id/members/revoke")
1821
+ };
1822
+ var CUSTOMER_AUTH_ENDPOINT_OPERATIONS = {
1823
+ revokeRefresh: operation("customers", "post", "/revoke-refresh"),
1824
+ withdraw: operation("customers", "post", "/withdraw")
1732
1825
  };
1733
1826
  var EMBEDDED_ADMIN_ENDPOINT_OPERATIONS = {
1734
1827
  show: operation("tenants", "get", "/embedded-admin-app"),
@@ -1753,6 +1846,14 @@ var COMMUNITY_ENDPOINT_OPERATIONS = {
1753
1846
  detail: operation("posts", "get", "/detail")
1754
1847
  }
1755
1848
  };
1849
+ var GALLERY_ENDPOINT_OPERATIONS = {
1850
+ items: {
1851
+ storefront: operation("gallery-items", "get", "/storefront")
1852
+ }
1853
+ };
1854
+ var VIDEO_ENDPOINT_OPERATIONS = {
1855
+ playback: operation("videos", "post", "/:id/playback")
1856
+ };
1756
1857
  function resolveOperationTemplate(descriptor) {
1757
1858
  return descriptor.collection ? `/api/${descriptor.collection}${descriptor.path}` : `/api${descriptor.path}`;
1758
1859
  }
@@ -2450,7 +2551,10 @@ var MAX_COMMERCE_CAPABILITY_LENGTH = 512;
2450
2551
  var MAX_CART_DISCOUNT_CODE_LENGTH = 128;
2451
2552
  var CHECKOUT_STATUSES = ["open", "placed", "abandoned"];
2452
2553
  var ABANDONED_REASONS = ["expired", "customer", "operator"];
2453
- var PAYMENT_PROVIDERS = ["toss", "portone"];
2554
+ function managedPaymentProviders(providers) {
2555
+ return providers;
2556
+ }
2557
+ var PAYMENT_PROVIDERS = managedPaymentProviders(["toss", "portone"]);
2454
2558
  var PAYMENT_PROVIDER_STATUSES = [
2455
2559
  "requires_payment_method",
2456
2560
  "requires_action",
@@ -2510,6 +2614,26 @@ function invalidCanonicalResponse(resource, details) {
2510
2614
  function fail(resource, path, expected) {
2511
2615
  invalidCanonicalResponse(resource, { path, expected });
2512
2616
  }
2617
+ function providerMismatch(resource, expected, actual, operation2) {
2618
+ if (operation2 === "cancel") {
2619
+ const method = {
2620
+ toss: "cancel()",
2621
+ portone: "cancelPortOne()"
2622
+ }[actual];
2623
+ throw createApiError(
2624
+ `Canonical ${resource} response provider mismatch: expected ${expected}, received ${actual}.`,
2625
+ 502,
2626
+ { resource, path: "$.provider", expected, actual },
2627
+ `The server applied the cancellation to a ${actual} PaymentSession, but this SDK method expects ${expected}.`,
2628
+ `Re-invoke ${method} with the same idempotencyKey; do not create a new key.`
2629
+ );
2630
+ }
2631
+ invalidCanonicalResponse(resource, {
2632
+ path: "$.provider",
2633
+ expected,
2634
+ actual
2635
+ });
2636
+ }
2513
2637
  function record(value, resource, path) {
2514
2638
  if (!value || typeof value !== "object" || Array.isArray(value)) {
2515
2639
  fail(resource, path, "object");
@@ -3786,7 +3910,7 @@ function validateNextAction(value, provider, resource, path) {
3786
3910
  if (action.customerEmail !== void 0)
3787
3911
  validateCustomer({ email: action.customerEmail }, resource, path);
3788
3912
  }
3789
- function validatePublicPaymentSession(value, expectedProvider) {
3913
+ function validatePublicPaymentSession(value, expectedProvider, operation2) {
3790
3914
  const resource = "PaymentSession";
3791
3915
  const session = record(value, resource, "$");
3792
3916
  const provider = enumValue(
@@ -3795,9 +3919,6 @@ function validatePublicPaymentSession(value, expectedProvider) {
3795
3919
  resource,
3796
3920
  "$.provider"
3797
3921
  );
3798
- if (expectedProvider !== void 0 && provider !== expectedProvider) {
3799
- fail(resource, "$.provider", expectedProvider);
3800
- }
3801
3922
  const status = enumValue(
3802
3923
  session.providerStatus,
3803
3924
  PAYMENT_PROVIDER_STATUSES,
@@ -4001,6 +4122,16 @@ function validatePublicPaymentSession(value, expectedProvider) {
4001
4122
  "$.cancellationReason"
4002
4123
  );
4003
4124
  }
4125
+ if (expectedProvider !== void 0 && provider !== expectedProvider) {
4126
+ if (operation2 === "cancel" && status !== "canceling" && status !== "canceled") {
4127
+ fail(
4128
+ resource,
4129
+ "$.providerStatus",
4130
+ "canceling or canceled after a successful cancellation"
4131
+ );
4132
+ }
4133
+ providerMismatch(resource, expectedProvider, provider, operation2);
4134
+ }
4004
4135
  return value;
4005
4136
  }
4006
4137
 
@@ -5552,8 +5683,12 @@ var PaymentSessionApi = class extends CustomerScopedApi {
5552
5683
  ...Object.keys(headers).length > 0 && { headers }
5553
5684
  });
5554
5685
  }
5555
- async paymentSession(result, expectedProvider) {
5556
- return validatePublicPaymentSession(await result, expectedProvider);
5686
+ async paymentSession(result, expectedProvider, operation2) {
5687
+ return validatePublicPaymentSession(
5688
+ await result,
5689
+ expectedProvider,
5690
+ operation2
5691
+ );
5557
5692
  }
5558
5693
  create(params) {
5559
5694
  const { idempotencyKey, ...body } = params;
@@ -5600,7 +5735,8 @@ var PaymentSessionApi = class extends CustomerScopedApi {
5600
5735
  const endpoint = this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.cancel : COMMERCE_ENDPOINTS.paymentSessions.cancel;
5601
5736
  return this.paymentSession(
5602
5737
  this.post(endpoint, body, idempotencyKey),
5603
- "toss"
5738
+ "toss",
5739
+ "cancel"
5604
5740
  );
5605
5741
  }
5606
5742
  cancelPortOne(params) {
@@ -5609,7 +5745,8 @@ var PaymentSessionApi = class extends CustomerScopedApi {
5609
5745
  const endpoint = this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.cancel : COMMERCE_ENDPOINTS.paymentSessions.cancel;
5610
5746
  return this.paymentSession(
5611
5747
  this.post(endpoint, body, idempotencyKey),
5612
- "portone"
5748
+ "portone",
5749
+ "cancel"
5613
5750
  );
5614
5751
  }
5615
5752
  confirm(params) {
@@ -5995,6 +6132,42 @@ function appendValues(params, key, value) {
5995
6132
  }
5996
6133
  }
5997
6134
 
6135
+ // src/core/video/video-playback-client.ts
6136
+ var VideoPlaybackClient = class {
6137
+ constructor(options) {
6138
+ this.options = options;
6139
+ if (typeof window !== "undefined") {
6140
+ throw new TypeError("VideoPlaybackClient requires a server environment");
6141
+ }
6142
+ }
6143
+ async playback(videoId) {
6144
+ if (!videoId) throw new TypeError("videoId is required");
6145
+ const endpoint = resolveOperationPath(VIDEO_ENDPOINT_OPERATIONS.playback, {
6146
+ pathParams: { id: videoId }
6147
+ });
6148
+ try {
6149
+ const response = await httpFetch(endpoint, {
6150
+ method: resolveOperationMethod(VIDEO_ENDPOINT_OPERATIONS.playback),
6151
+ apiUrl: this.options.apiUrl,
6152
+ publishableKey: this.options.publishableKey,
6153
+ secretKey: this.options.secretKey
6154
+ });
6155
+ this.options.onRequestId?.(response.headers.get("x-request-id") ?? null);
6156
+ const result = await parseApiResponse(response, endpoint);
6157
+ const base = resolveApiUrl(this.options.apiUrl);
6158
+ return {
6159
+ streamUrl: new URL(result.streamPath, base).toString(),
6160
+ mode: result.mode
6161
+ };
6162
+ } catch (error) {
6163
+ this.options.onRequestId?.(
6164
+ error instanceof SDKError ? error.requestId ?? null : null
6165
+ );
6166
+ throw error;
6167
+ }
6168
+ }
6169
+ };
6170
+
5998
6171
  // src/core/market/market-discovery.ts
5999
6172
  function toMarketDTO(row) {
6000
6173
  return {
@@ -6065,14 +6238,34 @@ var TenantIntrospectionApi = class extends RawBaseApi {
6065
6238
  };
6066
6239
 
6067
6240
  // src/core/api/membership-api.ts
6241
+ async function custodySignature(body, secret, timestamp2, deliveryId) {
6242
+ const encoder = new TextEncoder();
6243
+ const key = await crypto.subtle.importKey(
6244
+ "raw",
6245
+ encoder.encode(secret),
6246
+ { name: "HMAC", hash: "SHA-256" },
6247
+ false,
6248
+ ["sign"]
6249
+ );
6250
+ const signature = await crypto.subtle.sign(
6251
+ "HMAC",
6252
+ key,
6253
+ encoder.encode(`${timestamp2}.${deliveryId}.billing-custody.v1:${body}`)
6254
+ );
6255
+ return Array.from(
6256
+ new Uint8Array(signature),
6257
+ (byte) => byte.toString(16).padStart(2, "0")
6258
+ ).join("");
6259
+ }
6068
6260
  var MembershipApi = class extends BaseApi {
6069
6261
  constructor(options) {
6070
6262
  super("MembershipApi", options);
6071
6263
  }
6072
6264
  /**
6073
- * Record a delegated first-charge and activate a membership.
6074
- * The storefront collected the payment; this endpoint deduplicates by
6075
- * `subscribeIntentKey` and records the already-paid charge.
6265
+ * Prepare a delegated first charge for a paid Membership, or immediately
6266
+ * start a trial. For a paid response, charge through the tenant PSP with
6267
+ * `firstCharge.idempotencyKey`, then post the existing signed charge result
6268
+ * to activate the membership.
6076
6269
  *
6077
6270
  * `subscribeIntentKey` is used as the HTTP idempotency key so the call is
6078
6271
  * safely retryable.
@@ -6099,6 +6292,334 @@ var MembershipApi = class extends BaseApi {
6099
6292
  { pathParams: { id } }
6100
6293
  );
6101
6294
  }
6295
+ /**
6296
+ * Store/read only app-encrypted billing ciphertext for the Membership's
6297
+ * method. The tenant server receives the non-secret restore generation from
6298
+ * its platform operator's integration configuration; it is not discovered
6299
+ * from an unauthenticated endpoint.
6300
+ */
6301
+ async billingCustody(params) {
6302
+ const { webhookSecret, ...input } = params;
6303
+ const body = {
6304
+ kind: "billing-custody.v1",
6305
+ ...input
6306
+ };
6307
+ const timestamp2 = Date.now().toString();
6308
+ const deliveryId = crypto.randomUUID();
6309
+ const signature = await custodySignature(
6310
+ JSON.stringify(body),
6311
+ webhookSecret,
6312
+ timestamp2,
6313
+ deliveryId
6314
+ );
6315
+ return this.requestEndpoint(
6316
+ MEMBERSHIP_ENDPOINT_OPERATIONS.billingCustody,
6317
+ body,
6318
+ {
6319
+ headers: {
6320
+ "x-membership-signature": signature,
6321
+ "x-membership-timestamp": timestamp2,
6322
+ "x-membership-delivery-id": deliveryId
6323
+ }
6324
+ }
6325
+ );
6326
+ }
6327
+ };
6328
+
6329
+ // src/core/api/customer-group-api.ts
6330
+ var CustomerGroupApi = class extends BaseApi {
6331
+ constructor(options) {
6332
+ super("CustomerGroupApi", options);
6333
+ }
6334
+ listMembers(params) {
6335
+ const query = new URLSearchParams();
6336
+ if (params.page !== void 0) query.set("page", String(params.page));
6337
+ if (params.limit !== void 0) query.set("limit", String(params.limit));
6338
+ return this.requestEndpoint(
6339
+ CUSTOMER_GROUP_ENDPOINT_OPERATIONS.members,
6340
+ void 0,
6341
+ { pathParams: { id: params.groupId }, query }
6342
+ );
6343
+ }
6344
+ grantMember(params) {
6345
+ const { groupId, ...body } = params;
6346
+ return this.requestEndpoint(
6347
+ CUSTOMER_GROUP_ENDPOINT_OPERATIONS.grant,
6348
+ body,
6349
+ { pathParams: { id: groupId } }
6350
+ );
6351
+ }
6352
+ revokeMember(params) {
6353
+ const { groupId, ...body } = params;
6354
+ return this.requestEndpoint(
6355
+ CUSTOMER_GROUP_ENDPOINT_OPERATIONS.revoke,
6356
+ body,
6357
+ { pathParams: { id: groupId } }
6358
+ );
6359
+ }
6360
+ };
6361
+
6362
+ // src/core/api/external-effect-claims-api.ts
6363
+ var errorReasons = /* @__PURE__ */ new Set([
6364
+ "invalid_evidence",
6365
+ "denied",
6366
+ "conflict",
6367
+ "lease_lost",
6368
+ "unknown",
6369
+ "quota_exceeded",
6370
+ "forbidden",
6371
+ "authority_unavailable",
6372
+ "internal_error"
6373
+ ]);
6374
+ function getExternalEffectClaimErrorReason(error) {
6375
+ const reason = getSDKErrorReason(error);
6376
+ return errorReasons.has(reason) ? reason : void 0;
6377
+ }
6378
+ var states = /* @__PURE__ */ new Set([
6379
+ "pre_dispatch_claimed",
6380
+ "armed_unknown",
6381
+ "reported_effect",
6382
+ "reported_no_effect",
6383
+ "reconciliation_required",
6384
+ "reconciled_effect",
6385
+ "reconciled_no_effect",
6386
+ "unresolved_closed"
6387
+ ]);
6388
+ function invalidResponse() {
6389
+ throw createApiError(
6390
+ "Invalid external-effect claim response",
6391
+ 200,
6392
+ void 0,
6393
+ "Server returned an invalid response.",
6394
+ "Check the API version and retry after resolving the mismatch."
6395
+ );
6396
+ }
6397
+ function claimFromResponse(value) {
6398
+ if (!value || typeof value !== "object" || !("claim" in value))
6399
+ invalidResponse();
6400
+ const claim = value.claim;
6401
+ if (!claim || typeof claim !== "object") invalidResponse();
6402
+ const row = claim;
6403
+ 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)
6404
+ invalidResponse();
6405
+ return {
6406
+ id: row.id,
6407
+ state: row.state,
6408
+ armedAt: row.armedAt,
6409
+ firstReportOutcome: row.firstReportOutcome,
6410
+ reportAuthority: "tenant_supplied_unverified",
6411
+ leaseGranted: row.leaseGranted,
6412
+ leaseToken: row.leaseToken,
6413
+ leaseGeneration: row.leaseGeneration
6414
+ };
6415
+ }
6416
+ var ExternalEffectClaimsApi = class extends BaseApi {
6417
+ constructor(options) {
6418
+ super("ExternalEffectClaimsApi", options);
6419
+ }
6420
+ async claim(params) {
6421
+ return claimFromResponse(
6422
+ await this.requestEndpoint(
6423
+ EXTERNAL_EFFECT_CLAIM_ENDPOINT_OPERATIONS.claim,
6424
+ params
6425
+ )
6426
+ );
6427
+ }
6428
+ async get(params) {
6429
+ return claimFromResponse(
6430
+ await this.requestEndpoint(
6431
+ EXTERNAL_EFFECT_CLAIM_ENDPOINT_OPERATIONS.get,
6432
+ params
6433
+ )
6434
+ );
6435
+ }
6436
+ async arm(params) {
6437
+ return claimFromResponse(
6438
+ await this.requestEndpoint(
6439
+ EXTERNAL_EFFECT_CLAIM_ENDPOINT_OPERATIONS.arm,
6440
+ params
6441
+ )
6442
+ );
6443
+ }
6444
+ async release(params) {
6445
+ const result = await this.requestEndpoint(
6446
+ EXTERNAL_EFFECT_CLAIM_ENDPOINT_OPERATIONS.release,
6447
+ params
6448
+ );
6449
+ if (!result || typeof result !== "object" || !("released" in result) || result.released !== true)
6450
+ invalidResponse();
6451
+ }
6452
+ async report(params) {
6453
+ return claimFromResponse(
6454
+ await this.requestEndpoint(
6455
+ EXTERNAL_EFFECT_CLAIM_ENDPOINT_OPERATIONS.report,
6456
+ params
6457
+ )
6458
+ );
6459
+ }
6460
+ async recovery(params) {
6461
+ const result = await this.requestEndpoint(
6462
+ EXTERNAL_EFFECT_CLAIM_ENDPOINT_OPERATIONS.recovery,
6463
+ params
6464
+ );
6465
+ if (!result || typeof result !== "object" || !("recorded" in result) || result.recorded !== true)
6466
+ invalidResponse();
6467
+ }
6468
+ };
6469
+
6470
+ // src/core/api/installation-credentials-api.ts
6471
+ function invalidResponse2() {
6472
+ throw createApiError(
6473
+ "Invalid installation credential response",
6474
+ 200,
6475
+ void 0,
6476
+ "Server returned an invalid response.",
6477
+ "Check the API version and retry after resolving the mismatch."
6478
+ );
6479
+ }
6480
+ function snapshot(value) {
6481
+ if (!value || typeof value !== "object") invalidResponse2();
6482
+ const row = value;
6483
+ 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)
6484
+ invalidResponse2();
6485
+ return row;
6486
+ }
6487
+ var InstallationCredentialsApi = class extends BaseApi {
6488
+ constructor(options) {
6489
+ super("InstallationCredentialsApi", options);
6490
+ }
6491
+ create(params) {
6492
+ return this.requestEndpoint(
6493
+ INSTALLATION_CREDENTIAL_ENDPOINT_OPERATIONS.create,
6494
+ params
6495
+ ).then(snapshot);
6496
+ }
6497
+ get(params) {
6498
+ return this.requestEndpoint(
6499
+ INSTALLATION_CREDENTIAL_ENDPOINT_OPERATIONS.get,
6500
+ params
6501
+ ).then(snapshot);
6502
+ }
6503
+ replace(params) {
6504
+ return this.requestEndpoint(
6505
+ INSTALLATION_CREDENTIAL_ENDPOINT_OPERATIONS.replace,
6506
+ params
6507
+ ).then(snapshot);
6508
+ }
6509
+ async dispose(params) {
6510
+ const result = await this.requestEndpoint(
6511
+ INSTALLATION_CREDENTIAL_ENDPOINT_OPERATIONS.dispose,
6512
+ params
6513
+ );
6514
+ if (!result || typeof result !== "object") invalidResponse2();
6515
+ const row = result;
6516
+ if (row.installationId !== params.installationId || !Number.isSafeInteger(row.version) || row.version !== params.expectedVersion + 1 || row.state !== "disposed")
6517
+ invalidResponse2();
6518
+ return row;
6519
+ }
6520
+ };
6521
+
6522
+ // src/core/api/external-customer-links-api.ts
6523
+ function invalidResponse3() {
6524
+ throw createApiError("Invalid external-customer link response", 200);
6525
+ }
6526
+ 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;
6527
+ var isUuid = (value) => typeof value === "string" && (uuid.test(value) || value === "00000000-0000-0000-0000-000000000000" || value.toLowerCase() === "ffffffff-ffff-ffff-ffff-ffffffffffff");
6528
+ 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.
6529
+ !/[\u0000-\u001f]/.test(value) && !/[\uD800-\uDFFF]/u.test(value);
6530
+ var isDateTime = (value) => {
6531
+ 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(
6532
+ value
6533
+ ) || !Number.isFinite(Date.parse(value)))
6534
+ return false;
6535
+ const day = value.slice(0, 10);
6536
+ return (/* @__PURE__ */ new Date(`${day}T00:00:00Z`)).toISOString().startsWith(day);
6537
+ };
6538
+ function previousStateFromResponse(value) {
6539
+ if (value === null) return null;
6540
+ if (!value || typeof value !== "object" || Array.isArray(value))
6541
+ invalidResponse3();
6542
+ const entries = Object.entries(value);
6543
+ if (entries.length > 16 || entries.some(
6544
+ ([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.
6545
+ !/[\u0000\uD800-\uDFFF]/u.test(entry) || typeof entry === "number" && Number.isFinite(entry))
6546
+ ))
6547
+ invalidResponse3();
6548
+ const result = Object.fromEntries(entries);
6549
+ if (new TextEncoder().encode(JSON.stringify(result)).length > 2048)
6550
+ invalidResponse3();
6551
+ return result;
6552
+ }
6553
+ function linkFromResponse(value) {
6554
+ if (!value || typeof value !== "object") invalidResponse3();
6555
+ const row = value;
6556
+ 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)
6557
+ invalidResponse3();
6558
+ const previousState = previousStateFromResponse(row.previousState);
6559
+ if (row.state === "erased" ? row.externalCustomerId !== null || previousState !== null : row.externalCustomerId === null)
6560
+ invalidResponse3();
6561
+ return {
6562
+ id: row.id,
6563
+ customerId: row.customerId,
6564
+ namespace: row.namespace,
6565
+ accountScope: row.accountScope,
6566
+ externalCustomerId: row.externalCustomerId,
6567
+ state: row.state,
6568
+ connectedAt: row.connectedAt,
6569
+ releasedAt: row.releasedAt,
6570
+ version: row.version,
6571
+ previousState
6572
+ };
6573
+ }
6574
+ var ExternalCustomerLinksApi = class extends BaseApi {
6575
+ constructor(options) {
6576
+ super("ExternalCustomerLinksApi", options);
6577
+ }
6578
+ async command(operation2, params) {
6579
+ const result = await this.requestEndpoint(operation2, params);
6580
+ if (!result || typeof result !== "object" || !("link" in result))
6581
+ invalidResponse3();
6582
+ return linkFromResponse(result.link);
6583
+ }
6584
+ connect(params) {
6585
+ return this.command(
6586
+ EXTERNAL_CUSTOMER_LINK_ENDPOINT_OPERATIONS.connect,
6587
+ params
6588
+ );
6589
+ }
6590
+ get(params) {
6591
+ return this.command(EXTERNAL_CUSTOMER_LINK_ENDPOINT_OPERATIONS.get, params);
6592
+ }
6593
+ async list(params) {
6594
+ const result = await this.requestEndpoint(
6595
+ EXTERNAL_CUSTOMER_LINK_ENDPOINT_OPERATIONS.list,
6596
+ params
6597
+ );
6598
+ 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))
6599
+ invalidResponse3();
6600
+ return {
6601
+ links: result.links.map(linkFromResponse),
6602
+ nextCursor: result.nextCursor
6603
+ };
6604
+ }
6605
+ unlink(params) {
6606
+ return this.command(
6607
+ EXTERNAL_CUSTOMER_LINK_ENDPOINT_OPERATIONS.unlink,
6608
+ params
6609
+ );
6610
+ }
6611
+ capturePreviousState(params) {
6612
+ return this.command(
6613
+ EXTERNAL_CUSTOMER_LINK_ENDPOINT_OPERATIONS.capturePreviousState,
6614
+ params
6615
+ );
6616
+ }
6617
+ clearPreviousState(params) {
6618
+ return this.command(
6619
+ EXTERNAL_CUSTOMER_LINK_ENDPOINT_OPERATIONS.clearPreviousState,
6620
+ params
6621
+ );
6622
+ }
6102
6623
  };
6103
6624
 
6104
6625
  // src/core/client/client.server.ts
@@ -6135,11 +6656,22 @@ var ServerClient = class _ServerClient {
6135
6656
  onRequestId
6136
6657
  };
6137
6658
  this.commerce = new ServerCommerceClient(serverOptions);
6659
+ this.video = new VideoPlaybackClient({
6660
+ publishableKey: this.config.publishableKey,
6661
+ secretKey: this.config.secretKey,
6662
+ apiUrl: this.config.apiUrl,
6663
+ onRequestId
6664
+ });
6138
6665
  const membershipApi = new MembershipApi(serverOptions);
6139
6666
  this.memberships = {
6140
6667
  subscribe: membershipApi.subscribe.bind(membershipApi),
6141
- cancel: membershipApi.cancel.bind(membershipApi)
6668
+ cancel: membershipApi.cancel.bind(membershipApi),
6669
+ billingCustody: membershipApi.billingCustody.bind(membershipApi)
6142
6670
  };
6671
+ this.customerGroups = new CustomerGroupApi(serverOptions);
6672
+ this.externalEffectClaims = new ExternalEffectClaimsApi(serverOptions);
6673
+ this.installationCredentials = new InstallationCredentialsApi(serverOptions);
6674
+ this.externalCustomerLinks = new ExternalCustomerLinksApi(serverOptions);
6143
6675
  const tenantIntrospectionApi = new TenantIntrospectionApi(serverOptions);
6144
6676
  this.tenant = {
6145
6677
  context: tenantIntrospectionApi.context.bind(tenantIntrospectionApi),
@@ -6208,7 +6740,11 @@ function createServerClient(options) {
6208
6740
  export {
6209
6741
  CollectionClient,
6210
6742
  CommunityClient,
6743
+ CustomerGroupApi,
6211
6744
  EventsClient,
6745
+ ExternalCustomerLinksApi,
6746
+ ExternalEffectClaimsApi,
6747
+ InstallationCredentialsApi,
6212
6748
  ModerationApi,
6213
6749
  ServerClient,
6214
6750
  ServerCollectionClient,
@@ -6217,6 +6753,7 @@ export {
6217
6753
  TENANT_CONTEXT_PATH,
6218
6754
  TenantIntrospectionApi,
6219
6755
  createServerClient,
6756
+ getExternalEffectClaimErrorReason,
6220
6757
  isApiError,
6221
6758
  isAuthError,
6222
6759
  isCommerceSDKError,