@01.software/sdk 0.56.1 → 0.65.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/CHANGELOG.md +192 -0
  2. package/README.md +174 -91
  3. package/dist/client.cjs +136 -7
  4. package/dist/client.cjs.map +1 -1
  5. package/dist/client.d.cts +6 -6
  6. package/dist/client.d.ts +6 -6
  7. package/dist/client.js +136 -7
  8. package/dist/client.js.map +1 -1
  9. package/dist/{collection-client-DxuBDso_.d.cts → collection-client-B7rsTtVj.d.cts} +6 -6
  10. package/dist/{collection-client-Bmr53saa.d.ts → collection-client-C2sMvfme.d.ts} +6 -6
  11. package/dist/{const-Cv1DCsp6.d.cts → const-CRxPTDGt.d.ts} +2 -2
  12. package/dist/{const-BKUqg96Q.d.ts → const-D6ZRQLxI.d.cts} +2 -2
  13. package/dist/{index-DFHLLqYu.d.ts → index-1auUEYrl.d.ts} +3 -3
  14. package/dist/{index-CGsT4AQ8.d.cts → index-Bbpf5t-l.d.cts} +3 -3
  15. package/dist/index.cjs +139 -205
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/index.d.cts +15 -9
  18. package/dist/index.d.ts +15 -9
  19. package/dist/index.js +139 -205
  20. package/dist/index.js.map +1 -1
  21. package/dist/{payload-types-Bk-duc5k.d.cts → payload-types-BnIET0xU.d.cts} +262 -328
  22. package/dist/{payload-types-Bk-duc5k.d.ts → payload-types-BnIET0xU.d.ts} +262 -328
  23. package/dist/query.cjs +48 -2
  24. package/dist/query.cjs.map +1 -1
  25. package/dist/query.d.cts +5 -5
  26. package/dist/query.d.ts +5 -5
  27. package/dist/query.js +48 -2
  28. package/dist/query.js.map +1 -1
  29. package/dist/realtime.d.cts +2 -2
  30. package/dist/realtime.d.ts +2 -2
  31. package/dist/server.cjs +459 -7
  32. package/dist/server.cjs.map +1 -1
  33. package/dist/server.d.cts +13 -8
  34. package/dist/server.d.ts +13 -8
  35. package/dist/server.js +459 -7
  36. package/dist/server.js.map +1 -1
  37. package/dist/{types-D4mjGFj4.d.ts → types-D1y4TgQm.d.ts} +2 -2
  38. package/dist/{types-CEK8uTvU.d.ts → types-DnRC3nLG.d.ts} +256 -9
  39. package/dist/{types-CNdpj2fI.d.cts → types-Dp1oYpD3.d.cts} +2 -2
  40. package/dist/{types-Dhk5NX7Z.d.cts → types-Dzn0LD2N.d.cts} +256 -9
  41. package/dist/ui/form.d.cts +1 -1
  42. package/dist/ui/form.d.ts +1 -1
  43. package/dist/ui/video.cjs +4 -2
  44. package/dist/ui/video.cjs.map +1 -1
  45. package/dist/ui/video.d.cts +4 -2
  46. package/dist/ui/video.d.ts +4 -2
  47. package/dist/ui/video.js +4 -2
  48. package/dist/ui/video.js.map +1 -1
  49. package/dist/webhook.d.cts +5 -5
  50. package/dist/webhook.d.ts +5 -5
  51. package/package.json +8 -28
  52. package/dist/analytics/react.cjs +0 -344
  53. package/dist/analytics/react.cjs.map +0 -1
  54. package/dist/analytics/react.d.cts +0 -24
  55. package/dist/analytics/react.d.ts +0 -24
  56. package/dist/analytics/react.js +0 -319
  57. package/dist/analytics/react.js.map +0 -1
  58. package/dist/analytics.cjs +0 -238
  59. package/dist/analytics.cjs.map +0 -1
  60. package/dist/analytics.d.cts +0 -39
  61. package/dist/analytics.d.ts +0 -39
  62. package/dist/analytics.js +0 -215
  63. package/dist/analytics.js.map +0 -1
package/dist/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
  }
@@ -1732,17 +1777,52 @@ var portOneStandardActionCapabilityOperations = /* @__PURE__ */ new Set([
1732
1777
  ]);
1733
1778
  var MEMBERSHIP_ENDPOINT_OPERATIONS = {
1734
1779
  subscribe: operation(null, "post", "/memberships/subscribe"),
1780
+ billingCustody: operation(null, "post", "/memberships/billing-custody"),
1735
1781
  cancel: operation(null, "post", "/memberships/:id/cancel"),
1736
1782
  me: operation(null, "get", "/memberships/me"),
1737
1783
  chargeResult: operation(null, "post", "/memberships/:id/charge-result"),
1738
1784
  refundResult: operation(null, "post", "/memberships/:id/refund-result"),
1739
1785
  revoke: operation(null, "post", "/memberships/:id/revoke")
1740
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
+ };
1741
1817
  var CUSTOMER_GROUP_ENDPOINT_OPERATIONS = {
1742
1818
  members: operation("customer-groups", "get", "/:id/members"),
1743
1819
  grant: operation("customer-groups", "post", "/:id/members/grant"),
1744
1820
  revoke: operation("customer-groups", "post", "/:id/members/revoke")
1745
1821
  };
1822
+ var CUSTOMER_AUTH_ENDPOINT_OPERATIONS = {
1823
+ revokeRefresh: operation("customers", "post", "/revoke-refresh"),
1824
+ withdraw: operation("customers", "post", "/withdraw")
1825
+ };
1746
1826
  var EMBEDDED_ADMIN_ENDPOINT_OPERATIONS = {
1747
1827
  show: operation("tenants", "get", "/embedded-admin-app"),
1748
1828
  configure: operation("tenants", "patch", "/embedded-admin-app"),
@@ -1766,6 +1846,14 @@ var COMMUNITY_ENDPOINT_OPERATIONS = {
1766
1846
  detail: operation("posts", "get", "/detail")
1767
1847
  }
1768
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
+ };
1769
1857
  function resolveOperationTemplate(descriptor) {
1770
1858
  return descriptor.collection ? `/api/${descriptor.collection}${descriptor.path}` : `/api${descriptor.path}`;
1771
1859
  }
@@ -6044,6 +6132,42 @@ function appendValues(params, key, value) {
6044
6132
  }
6045
6133
  }
6046
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
+
6047
6171
  // src/core/market/market-discovery.ts
6048
6172
  function toMarketDTO(row) {
6049
6173
  return {
@@ -6114,6 +6238,25 @@ var TenantIntrospectionApi = class extends RawBaseApi {
6114
6238
  };
6115
6239
 
6116
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
+ }
6117
6260
  var MembershipApi = class extends BaseApi {
6118
6261
  constructor(options) {
6119
6262
  super("MembershipApi", options);
@@ -6149,6 +6292,38 @@ var MembershipApi = class extends BaseApi {
6149
6292
  { pathParams: { id } }
6150
6293
  );
6151
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
+ }
6152
6327
  };
6153
6328
 
6154
6329
  // src/core/api/customer-group-api.ts
@@ -6184,6 +6359,269 @@ var CustomerGroupApi = class extends BaseApi {
6184
6359
  }
6185
6360
  };
6186
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
+ }
6623
+ };
6624
+
6187
6625
  // src/core/client/client.server.ts
6188
6626
  var ServerClient = class _ServerClient {
6189
6627
  constructor(options) {
@@ -6218,12 +6656,22 @@ var ServerClient = class _ServerClient {
6218
6656
  onRequestId
6219
6657
  };
6220
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
+ });
6221
6665
  const membershipApi = new MembershipApi(serverOptions);
6222
6666
  this.memberships = {
6223
6667
  subscribe: membershipApi.subscribe.bind(membershipApi),
6224
- cancel: membershipApi.cancel.bind(membershipApi)
6668
+ cancel: membershipApi.cancel.bind(membershipApi),
6669
+ billingCustody: membershipApi.billingCustody.bind(membershipApi)
6225
6670
  };
6226
6671
  this.customerGroups = new CustomerGroupApi(serverOptions);
6672
+ this.externalEffectClaims = new ExternalEffectClaimsApi(serverOptions);
6673
+ this.installationCredentials = new InstallationCredentialsApi(serverOptions);
6674
+ this.externalCustomerLinks = new ExternalCustomerLinksApi(serverOptions);
6227
6675
  const tenantIntrospectionApi = new TenantIntrospectionApi(serverOptions);
6228
6676
  this.tenant = {
6229
6677
  context: tenantIntrospectionApi.context.bind(tenantIntrospectionApi),
@@ -6294,6 +6742,9 @@ export {
6294
6742
  CommunityClient,
6295
6743
  CustomerGroupApi,
6296
6744
  EventsClient,
6745
+ ExternalCustomerLinksApi,
6746
+ ExternalEffectClaimsApi,
6747
+ InstallationCredentialsApi,
6297
6748
  ModerationApi,
6298
6749
  ServerClient,
6299
6750
  ServerCollectionClient,
@@ -6302,6 +6753,7 @@ export {
6302
6753
  TENANT_CONTEXT_PATH,
6303
6754
  TenantIntrospectionApi,
6304
6755
  createServerClient,
6756
+ getExternalEffectClaimErrorReason,
6305
6757
  isApiError,
6306
6758
  isAuthError,
6307
6759
  isCommerceSDKError,