@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,7 +1,7 @@
1
1
  import { R as RealtimeEvent } from './realtime-D7HtUpqt.cjs';
2
2
  export { a as RealtimeConnection, b as RealtimeListener } from './realtime-D7HtUpqt.cjs';
3
- import { P as PublicCollection } from './const-Cv1DCsp6.cjs';
4
- import './payload-types-Bk-duc5k.cjs';
3
+ import { P as PublicCollection } from './const-D6ZRQLxI.cjs';
4
+ import './payload-types-BnIET0xU.cjs';
5
5
 
6
6
  interface UseRealtimeQueryOptions {
7
7
  /** Filter events to specific collections. Empty/undefined = all collections. */
@@ -1,7 +1,7 @@
1
1
  import { R as RealtimeEvent } from './realtime-D7HtUpqt.js';
2
2
  export { a as RealtimeConnection, b as RealtimeListener } from './realtime-D7HtUpqt.js';
3
- import { P as PublicCollection } from './const-BKUqg96Q.js';
4
- import './payload-types-Bk-duc5k.js';
3
+ import { P as PublicCollection } from './const-CRxPTDGt.js';
4
+ import './payload-types-BnIET0xU.js';
5
5
 
6
6
  interface UseRealtimeQueryOptions {
7
7
  /** Filter events to specific collections. Empty/undefined = all collections. */
package/dist/server.cjs CHANGED
@@ -24,6 +24,9 @@ __export(server_exports, {
24
24
  CommunityClient: () => CommunityClient,
25
25
  CustomerGroupApi: () => CustomerGroupApi,
26
26
  EventsClient: () => EventsClient,
27
+ ExternalCustomerLinksApi: () => ExternalCustomerLinksApi,
28
+ ExternalEffectClaimsApi: () => ExternalEffectClaimsApi,
29
+ InstallationCredentialsApi: () => InstallationCredentialsApi,
27
30
  ModerationApi: () => ModerationApi,
28
31
  ServerClient: () => ServerClient,
29
32
  ServerCollectionClient: () => ServerCollectionClient,
@@ -32,6 +35,7 @@ __export(server_exports, {
32
35
  TENANT_CONTEXT_PATH: () => TENANT_CONTEXT_PATH,
33
36
  TenantIntrospectionApi: () => TenantIntrospectionApi,
34
37
  createServerClient: () => createServerClient,
38
+ getExternalEffectClaimErrorReason: () => getExternalEffectClaimErrorReason,
35
39
  isApiError: () => isApiError,
36
40
  isAuthError: () => isAuthError,
37
41
  isCommerceSDKError: () => isCommerceSDKError,
@@ -1057,6 +1061,49 @@ function stockSnapshotSearchParams(params) {
1057
1061
  }
1058
1062
 
1059
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
+ }
1060
1107
  var HttpClient = class {
1061
1108
  constructor(publishableKey, secretKey, getCustomerToken, onUnauthorized, onRequestId, apiUrl) {
1062
1109
  this.publishableKey = requirePublishableKeyForSecret(
@@ -1103,7 +1150,8 @@ var HttpClient = class {
1103
1150
  ...rest,
1104
1151
  "fallback-locale": fallbackLocale === false ? "none" : fallbackLocale
1105
1152
  };
1106
- 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 });
1107
1155
  return queryString ? `${endpoint}${queryString}` : endpoint;
1108
1156
  }
1109
1157
  assertJsonResponse(response) {
@@ -1500,10 +1548,11 @@ var CollectionClient = class extends HttpClient {
1500
1548
  * PATCH /api/{collection}
1501
1549
  */
1502
1550
  async requestUpdateMany(endpoint, data) {
1503
- const response = await this.fetchWithTracking(endpoint, {
1551
+ const url = this.buildUrl(endpoint, { where: data.where });
1552
+ const response = await this.fetchWithTracking(url, {
1504
1553
  ...this.defaultOptions,
1505
1554
  method: "PATCH",
1506
- body: JSON.stringify(data)
1555
+ body: JSON.stringify(data.data)
1507
1556
  });
1508
1557
  return this.parseFindResponse(response);
1509
1558
  }
@@ -1524,10 +1573,10 @@ var CollectionClient = class extends HttpClient {
1524
1573
  * DELETE /api/{collection}
1525
1574
  */
1526
1575
  async requestDeleteMany(endpoint, data) {
1527
- const response = await this.fetchWithTracking(endpoint, {
1576
+ const url = this.buildUrl(endpoint, { where: data.where });
1577
+ const response = await this.fetchWithTracking(url, {
1528
1578
  ...this.defaultOptions,
1529
- method: "DELETE",
1530
- body: JSON.stringify(data)
1579
+ method: "DELETE"
1531
1580
  });
1532
1581
  return this.parseFindResponse(response);
1533
1582
  }
@@ -1784,17 +1833,52 @@ var portOneStandardActionCapabilityOperations = /* @__PURE__ */ new Set([
1784
1833
  ]);
1785
1834
  var MEMBERSHIP_ENDPOINT_OPERATIONS = {
1786
1835
  subscribe: operation(null, "post", "/memberships/subscribe"),
1836
+ billingCustody: operation(null, "post", "/memberships/billing-custody"),
1787
1837
  cancel: operation(null, "post", "/memberships/:id/cancel"),
1788
1838
  me: operation(null, "get", "/memberships/me"),
1789
1839
  chargeResult: operation(null, "post", "/memberships/:id/charge-result"),
1790
1840
  refundResult: operation(null, "post", "/memberships/:id/refund-result"),
1791
1841
  revoke: operation(null, "post", "/memberships/:id/revoke")
1792
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
+ };
1793
1873
  var CUSTOMER_GROUP_ENDPOINT_OPERATIONS = {
1794
1874
  members: operation("customer-groups", "get", "/:id/members"),
1795
1875
  grant: operation("customer-groups", "post", "/:id/members/grant"),
1796
1876
  revoke: operation("customer-groups", "post", "/:id/members/revoke")
1797
1877
  };
1878
+ var CUSTOMER_AUTH_ENDPOINT_OPERATIONS = {
1879
+ revokeRefresh: operation("customers", "post", "/revoke-refresh"),
1880
+ withdraw: operation("customers", "post", "/withdraw")
1881
+ };
1798
1882
  var EMBEDDED_ADMIN_ENDPOINT_OPERATIONS = {
1799
1883
  show: operation("tenants", "get", "/embedded-admin-app"),
1800
1884
  configure: operation("tenants", "patch", "/embedded-admin-app"),
@@ -1818,6 +1902,14 @@ var COMMUNITY_ENDPOINT_OPERATIONS = {
1818
1902
  detail: operation("posts", "get", "/detail")
1819
1903
  }
1820
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
+ };
1821
1913
  function resolveOperationTemplate(descriptor) {
1822
1914
  return descriptor.collection ? `/api/${descriptor.collection}${descriptor.path}` : `/api${descriptor.path}`;
1823
1915
  }
@@ -6096,6 +6188,42 @@ function appendValues(params, key, value) {
6096
6188
  }
6097
6189
  }
6098
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
+
6099
6227
  // src/core/market/market-discovery.ts
6100
6228
  function toMarketDTO(row) {
6101
6229
  return {
@@ -6166,6 +6294,25 @@ var TenantIntrospectionApi = class extends RawBaseApi {
6166
6294
  };
6167
6295
 
6168
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
+ }
6169
6316
  var MembershipApi = class extends BaseApi {
6170
6317
  constructor(options) {
6171
6318
  super("MembershipApi", options);
@@ -6201,6 +6348,38 @@ var MembershipApi = class extends BaseApi {
6201
6348
  { pathParams: { id } }
6202
6349
  );
6203
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
+ }
6204
6383
  };
6205
6384
 
6206
6385
  // src/core/api/customer-group-api.ts
@@ -6236,6 +6415,269 @@ var CustomerGroupApi = class extends BaseApi {
6236
6415
  }
6237
6416
  };
6238
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
+ }
6679
+ };
6680
+
6239
6681
  // src/core/client/client.server.ts
6240
6682
  var ServerClient = class _ServerClient {
6241
6683
  constructor(options) {
@@ -6270,12 +6712,22 @@ var ServerClient = class _ServerClient {
6270
6712
  onRequestId
6271
6713
  };
6272
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
+ });
6273
6721
  const membershipApi = new MembershipApi(serverOptions);
6274
6722
  this.memberships = {
6275
6723
  subscribe: membershipApi.subscribe.bind(membershipApi),
6276
- cancel: membershipApi.cancel.bind(membershipApi)
6724
+ cancel: membershipApi.cancel.bind(membershipApi),
6725
+ billingCustody: membershipApi.billingCustody.bind(membershipApi)
6277
6726
  };
6278
6727
  this.customerGroups = new CustomerGroupApi(serverOptions);
6728
+ this.externalEffectClaims = new ExternalEffectClaimsApi(serverOptions);
6729
+ this.installationCredentials = new InstallationCredentialsApi(serverOptions);
6730
+ this.externalCustomerLinks = new ExternalCustomerLinksApi(serverOptions);
6279
6731
  const tenantIntrospectionApi = new TenantIntrospectionApi(serverOptions);
6280
6732
  this.tenant = {
6281
6733
  context: tenantIntrospectionApi.context.bind(tenantIntrospectionApi),