calmlens 0.37.1 → 0.38.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 (84) hide show
  1. package/bin/calmlens.js +87 -17
  2. package/cjs/{BrowserUpload-84KQWr1Q.js → BrowserUpload-DS0lxg5C.js} +1 -1
  3. package/{esm/BrowserUpload-CuG3tWSo.d.ts → cjs/BrowserUpload-_iMX_nq0.d.ts} +2 -2
  4. package/{esm/CalmLensAppClient-QqtovWE-.d.ts → cjs/CalmLensAppClient-CQpnc4JZ.d.ts} +1 -1
  5. package/cjs/{CalmLensAppClient-D4tRb_P2.js → CalmLensAppClient-Diu1QtBz.js} +3 -3
  6. package/cjs/{CalmLensCdn-CdYY_XtK.js → CalmLensCdn-DCj0AfoS.js} +2 -2
  7. package/cjs/{CalmLensConnection-GkR2cKn5.js → CalmLensConnection-BpBq0nQR.js} +14 -4
  8. package/cjs/{CalmLensError-ifj5rLmk.js → CalmLensError-C9g7GXfU.js} +7 -2
  9. package/{esm/CalmLensServerClient-csSQqHBt.d.ts → cjs/CalmLensServerClient-CeTsE5Jx.d.ts} +5 -5
  10. package/cjs/{CalmLensServerClient-cgPOG4Sv.js → CalmLensServerClient-vdHfH0Nf.js} +15 -6
  11. package/cjs/{CalmLensTypes-_f7QVRtO.d.ts → CalmLensTypes-jond9q6a.d.ts} +28 -9
  12. package/cjs/{Core-BlnBBJKb.js → Core-BHQSo7rY.js} +3 -3
  13. package/{esm/Core-4iFxKJnY.d.ts → cjs/Core-C6_Q5ZME.d.ts} +2 -2
  14. package/cjs/{ReactUpload-D3AYIZBh.js → ReactUpload-bbHMmEUQ.js} +1 -1
  15. package/cjs/{ReactUpload-4qd2xACg.d.ts → ReactUpload-fy6zhY8M.d.ts} +1 -1
  16. package/cjs/{UploadController-BYuHuZ7K.js → UploadController-C1tiTTRR.js} +2 -2
  17. package/{esm/WebhookPayload-BJtggTLd.d.ts → cjs/WebhookPayload-DdpKjQGw.d.ts} +5 -3
  18. package/cjs/app.d.ts +4 -4
  19. package/cjs/app.js +3 -3
  20. package/cjs/elements.d.ts +4 -4
  21. package/cjs/elements.js +4 -4
  22. package/cjs/{index-IEA75nev.d.ts → index-CgAztQdX.d.ts} +2 -2
  23. package/cjs/index.d.ts +3 -3
  24. package/cjs/index.js +2 -2
  25. package/cjs/react-native.d.ts +2 -2
  26. package/cjs/react-native.js +4 -4
  27. package/cjs/react.d.ts +4 -4
  28. package/cjs/react.js +5 -5
  29. package/cjs/server.d.ts +4 -4
  30. package/cjs/server.js +3 -3
  31. package/cjs/{CalmLensTestInputArguments-C6S09FVQ.js → test-inputs-DJnupsBH.js} +231 -22
  32. package/{esm/TestTriggers-CjDhhz78.d.ts → cjs/test-inputs-fugEK0py.d.ts} +36 -142
  33. package/cjs/test-inputs.d.ts +2 -18
  34. package/cjs/test-inputs.js +17 -126
  35. package/cjs/testing.d.ts +11 -14
  36. package/cjs/testing.js +38 -68
  37. package/cjs/{ui-Cy8MWXOw.js → ui-2jJvTcCP.js} +2 -2
  38. package/cjs/{ui-BMQW3Hse.d.ts → ui-Cp18fGXG.d.ts} +2 -2
  39. package/cjs/ui.d.ts +2 -2
  40. package/cjs/ui.js +3 -3
  41. package/cjs/vue.d.ts +5 -5
  42. package/cjs/vue.js +4 -4
  43. package/esm/{BrowserUpload-C429CcUi.js → BrowserUpload-C4YF17a3.js} +1 -1
  44. package/{cjs/BrowserUpload-CuG3tWSo.d.ts → esm/BrowserUpload-_iMX_nq0.d.ts} +2 -2
  45. package/esm/{CalmLensAppClient-Brvc-GXt.js → CalmLensAppClient-B2H7x_SJ.js} +3 -3
  46. package/{cjs/CalmLensAppClient-QqtovWE-.d.ts → esm/CalmLensAppClient-CQpnc4JZ.d.ts} +1 -1
  47. package/esm/{CalmLensCdn-cmxtF_dw.js → CalmLensCdn-Dh546rXe.js} +2 -2
  48. package/esm/{CalmLensConnection-DEfpIugc.js → CalmLensConnection-BbFlVAdl.js} +14 -4
  49. package/esm/{CalmLensError-C15tWu8W.js → CalmLensError-DjkibkdI.js} +7 -2
  50. package/{cjs/CalmLensServerClient-csSQqHBt.d.ts → esm/CalmLensServerClient-CeTsE5Jx.d.ts} +5 -5
  51. package/esm/{CalmLensServerClient-BpsCXVeO.js → CalmLensServerClient-CqH-tqcC.js} +15 -6
  52. package/esm/{CalmLensTypes-_f7QVRtO.d.ts → CalmLensTypes-jond9q6a.d.ts} +28 -9
  53. package/{cjs/Core-4iFxKJnY.d.ts → esm/Core-C6_Q5ZME.d.ts} +2 -2
  54. package/esm/{Core-C_f1o9RQ.js → Core-VNBTpvrG.js} +3 -3
  55. package/esm/{ReactUpload-Ch5qY7PS.js → ReactUpload-CRH6rSaX.js} +1 -1
  56. package/esm/{ReactUpload-4qd2xACg.d.ts → ReactUpload-fy6zhY8M.d.ts} +1 -1
  57. package/esm/{UploadController-9fkYFVZM.js → UploadController-BYxiONcw.js} +2 -2
  58. package/{cjs/WebhookPayload-BJtggTLd.d.ts → esm/WebhookPayload-DdpKjQGw.d.ts} +5 -3
  59. package/esm/app.d.ts +4 -4
  60. package/esm/app.js +3 -3
  61. package/esm/elements.d.ts +4 -4
  62. package/esm/elements.js +4 -4
  63. package/esm/{index-IEA75nev.d.ts → index-CgAztQdX.d.ts} +2 -2
  64. package/esm/index.d.ts +3 -3
  65. package/esm/index.js +2 -2
  66. package/esm/react-native.d.ts +2 -2
  67. package/esm/react-native.js +4 -4
  68. package/esm/react.d.ts +4 -4
  69. package/esm/react.js +5 -5
  70. package/esm/server.d.ts +4 -4
  71. package/esm/server.js +3 -3
  72. package/esm/{CalmLensTestInputArguments-DS_3mt1C.js → test-inputs-BLlkOmNC.js} +212 -15
  73. package/{cjs/TestTriggers-CjDhhz78.d.ts → esm/test-inputs-fugEK0py.d.ts} +36 -142
  74. package/esm/test-inputs.d.ts +2 -18
  75. package/esm/test-inputs.js +1 -115
  76. package/esm/testing.d.ts +11 -14
  77. package/esm/testing.js +27 -57
  78. package/esm/{ui-BMQW3Hse.d.ts → ui-Cp18fGXG.d.ts} +2 -2
  79. package/esm/{ui-HK74e42L.js → ui-siBYiNJZ.js} +2 -2
  80. package/esm/ui.d.ts +2 -2
  81. package/esm/ui.js +3 -3
  82. package/esm/vue.d.ts +5 -5
  83. package/esm/vue.js +4 -4
  84. package/package.json +1 -1
package/cjs/testing.js CHANGED
@@ -1,40 +1,15 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_CalmLensTestInputArguments = require("./CalmLensTestInputArguments-C6S09FVQ.js");
3
- const require_CalmLensError = require("./CalmLensError-ifj5rLmk.js");
4
- const require_CalmLensCdn = require("./CalmLensCdn-CdYY_XtK.js");
5
- const require_CalmLensServerClient = require("./CalmLensServerClient-cgPOG4Sv.js");
6
- const require_CalmLensConnection = require("./CalmLensConnection-GkR2cKn5.js");
2
+ const require_test_inputs = require("./test-inputs-DJnupsBH.js");
3
+ const require_CalmLensError = require("./CalmLensError-C9g7GXfU.js");
4
+ const require_CalmLensCdn = require("./CalmLensCdn-DCj0AfoS.js");
5
+ const require_CalmLensServerClient = require("./CalmLensServerClient-vdHfH0Nf.js");
6
+ const require_CalmLensConnection = require("./CalmLensConnection-BpBq0nQR.js");
7
7
  const require_CryptoUtils_BLCa_oZe = require("./CryptoUtils-BLCa-oZe-leCkr1ko.js");
8
- const require_CalmLensAppClient = require("./CalmLensAppClient-D4tRb_P2.js");
9
- const require_UploadController = require("./UploadController-BYuHuZ7K.js");
8
+ const require_CalmLensAppClient = require("./CalmLensAppClient-Diu1QtBz.js");
9
+ const require_UploadController = require("./UploadController-C1tiTTRR.js");
10
10
  let zod = require("zod");
11
- let zod$1 = require_CalmLensTestInputArguments.__toESM(zod, 1);
12
- zod = require_CalmLensTestInputArguments.__toESM(zod);
13
- // src/contract/MediaTestTriggers.js
14
- const MEDIA_TEST_SIGNALS = [...require_CalmLensTestInputArguments.CLASSIFICATION_CATEGORIES, "violence.graphic"];
15
- const HEX_WORDS = [
16
- "zero",
17
- "one",
18
- "two",
19
- "three",
20
- "four",
21
- "five",
22
- "six",
23
- "seven",
24
- "eight",
25
- "nine",
26
- "alpha",
27
- "bravo",
28
- "charlie",
29
- "delta",
30
- "echo",
31
- "foxtrot"
32
- ];
33
- /** Read this aloud, or render it as large, high-contrast text in a video frame. */
34
- async function generateMediaTestCode$1(signal, testInputKey) {
35
- if (!MEDIA_TEST_SIGNALS.includes(signal)) throw new RangeError("Unsupported media test signal");
36
- return `Calm Lens test ${[...await require_CalmLensTestInputArguments.getTestInputTag("media", signal, testInputKey)].map((character) => HEX_WORDS[Number.parseInt(character, 16)]).join(" ")} ${signal.replace(/[.-]/g, " ")} end test`;
37
- }
11
+ let zod$1 = require_test_inputs.__toESM(zod, 1);
12
+ zod = require_test_inputs.__toESM(zod);
38
13
  /**
39
14
  * The character an asset ID starts with (after `asset_`) to say the region it lives in: the asset
40
15
  * table computes each row's region from it (`AssetTable`), so an ID is only ever in one region and
@@ -8088,7 +8063,7 @@ const PERMISSION_ACTIONS = [
8088
8063
  "reviews:write",
8089
8064
  "project:manage"
8090
8065
  ];
8091
- const ACTION_SCHEMA = /* @__PURE__ */ require_CalmLensTestInputArguments.lazySchema(() => zod$1.enum(PERMISSION_ACTIONS));
8066
+ const ACTION_SCHEMA = /* @__PURE__ */ require_test_inputs.lazySchema(() => zod$1.enum(PERMISSION_ACTIONS));
8092
8067
  const PROJECT_ACTIONS = [...[
8093
8068
  "settings",
8094
8069
  "members",
@@ -8104,12 +8079,12 @@ const PROJECT_ACTIONS = [...[
8104
8079
  const isProjectAction = (action) => PROJECT_ACTIONS.includes(action);
8105
8080
  /** The actions that include `action`: its feature's write action and project:manage. */
8106
8081
  const actionsImplying = (action) => !isProjectAction(action) || action === "project:manage" ? [] : action.endsWith(":read") ? [action.replace(/:read$/, ":write"), "project:manage"] : ["project:manage"];
8107
- const GRANT_SCHEMA = /* @__PURE__ */ require_CalmLensTestInputArguments.lazySchema(() => zod$1.object({
8082
+ const GRANT_SCHEMA = /* @__PURE__ */ require_test_inputs.lazySchema(() => zod$1.object({
8108
8083
  actions: zod$1.array(ACTION_SCHEMA),
8109
8084
  folderId: idField("fldr").nullable(),
8110
8085
  includeSubfolders: zod$1.boolean()
8111
8086
  }).strict().refine((g) => g.folderId === null || !g.actions.some(isProjectAction), "Project configuration permissions require project scope"));
8112
- const GRANTS_SCHEMA = /* @__PURE__ */ require_CalmLensTestInputArguments.lazySchema(() => zod$1.array(GRANT_SCHEMA).max(100));
8087
+ const GRANTS_SCHEMA = /* @__PURE__ */ require_test_inputs.lazySchema(() => zod$1.array(GRANT_SCHEMA).max(100));
8113
8088
  [...PERMISSION_ACTIONS.filter((a) => !isProjectAction(a))];
8114
8089
  [...PERMISSION_ACTIONS.filter((a) => !isProjectAction(a))];
8115
8090
  const permits = (grants, action, folderId, folders) => grants.some((grant) => {
@@ -9769,7 +9744,7 @@ const MOCK_PRESET_NAMES = {
9769
9744
  * personal information and profanity, `block` otherwise) and no rules. The mock holds no built-in
9770
9745
  * preset settings, and uploads are never decided by a policy.
9771
9746
  */
9772
- const mockPresetSettings = () => ({ categorySettings: Object.fromEntries(require_CalmLensTestInputArguments.CLASSIFICATION_CATEGORIES.map((category) => [category, {
9747
+ const mockPresetSettings = () => ({ categorySettings: Object.fromEntries(require_test_inputs.CLASSIFICATION_CATEGORIES.map((category) => [category, {
9773
9748
  action: category === "personal-information" || category === "profanity" ? "allow" : "block",
9774
9749
  allowances: [],
9775
9750
  restrictions: []
@@ -9781,13 +9756,13 @@ const mockPresetSettings = () => ({ categorySettings: Object.fromEntries(require
9781
9756
  const checkPolicySettings = (settings) => {
9782
9757
  const categories = settings?.categorySettings;
9783
9758
  if (!categories || typeof categories !== "object") throw invalidField("validation/invalid-type", "settings.categorySettings");
9784
- for (const category of require_CalmLensTestInputArguments.CLASSIFICATION_CATEGORIES) {
9759
+ for (const category of require_test_inputs.CLASSIFICATION_CATEGORIES) {
9785
9760
  const value = categories[category];
9786
9761
  if (!value || typeof value !== "object") throw invalidField("validation/invalid-type", `settings.categorySettings.${category}`);
9787
9762
  for (const key of ["allowances", "restrictions"]) if (!Array.isArray(value[key])) throw invalidField("validation/invalid-type", `settings.categorySettings.${category}.${key}`);
9788
9763
  if (typeof value.action !== "string") throw invalidField("validation/invalid-value", `settings.categorySettings.${category}.action`);
9789
9764
  }
9790
- for (const key of Object.keys(categories)) if (!require_CalmLensTestInputArguments.CLASSIFICATION_CATEGORIES.includes(key)) throw invalidField("validation/unknown-field", `settings.categorySettings.${key}`);
9765
+ for (const key of Object.keys(categories)) if (!require_test_inputs.CLASSIFICATION_CATEGORIES.includes(key)) throw invalidField("validation/unknown-field", `settings.categorySettings.${key}`);
9791
9766
  };
9792
9767
  /** The client methods that send a request, the one it is recorded under first. */
9793
9768
  const operationsOf = (request) => {
@@ -9860,17 +9835,14 @@ const operationsOf = (request) => {
9860
9835
  return [];
9861
9836
  };
9862
9837
  /**
9863
- * The methods whose requests the API runs under an `Idempotency-Key` (`idempotent` in its request
9864
- * definitions): a retry with the same key replays the first response. Others ignore the header.
9838
+ * Like the API, every write (POST, PUT, PATCH and DELETE) runs under its `Idempotency-Key`: a retry
9839
+ * with the same key replays the first response. Reads ignore the header.
9865
9840
  */
9866
- const IDEMPOTENT_OPERATIONS = [
9867
- "assets.create",
9868
- "assets.classify",
9869
- "text.classify",
9870
- "assets.uploadPart",
9871
- "assets.decide",
9872
- "assets.requestReview",
9873
- "hashLists.addEntry"
9841
+ const IDEMPOTENT_METHODS = [
9842
+ "POST",
9843
+ "PUT",
9844
+ "PATCH",
9845
+ "DELETE"
9874
9846
  ];
9875
9847
  /** A plain-text upload: the SDKs send text as a JSON body with `content.plainText`. */
9876
9848
  const isTextUpload = (request) => {
@@ -10292,7 +10264,7 @@ var MockCalmLensApi = class {
10292
10264
  async answer(request, operation, session) {
10293
10265
  const { url, headers } = request;
10294
10266
  if (!(request.segments[0] === "upload-presets") && headers.get("x-api-key") !== this.apiKey) return this.failureResponse(fail(require_CalmLensError.API_ERROR_CODES.INVALID_API_KEY), url);
10295
- const key = operation && IDEMPOTENT_OPERATIONS.includes(operation) ? headers.get("idempotency-key")?.replace(/^[\t\n\r ]+|[\t\n\r ]+$/g, "") : void 0;
10267
+ const key = IDEMPOTENT_METHODS.includes(request.method) ? headers.get("idempotency-key")?.replace(/^[\t\n\r ]+|[\t\n\r ]+$/g, "") : void 0;
10296
10268
  const upload = headers.get("x-calmlens-upload");
10297
10269
  const contentType = headers.get("content-type");
10298
10270
  const isForm = !!upload && /^multipart\/form-data\b/i.test(contentType ?? "");
@@ -11051,10 +11023,11 @@ var MockCalmLensApi = class {
11051
11023
  const { content, part, sizeInBytes: _size, totalSizeInBytes, ...fields } = body;
11052
11024
  const text = content ?? part;
11053
11025
  if (text === void 0) return fields;
11054
- if (typeof text.plainText !== "string" || typeof text.type !== "string") throw invalidField("validation/invalid-type", content ? "content" : "part");
11026
+ const type = content && text.type === void 0 ? "text/plain" : text.type;
11027
+ if (typeof text.plainText !== "string" || typeof type !== "string") throw invalidField("validation/invalid-type", content ? "content" : "part");
11055
11028
  return {
11056
11029
  ...fields,
11057
- contentType: text.type,
11030
+ contentType: type,
11058
11031
  bytes: new TextEncoder().encode(text.plainText),
11059
11032
  part: part ? {
11060
11033
  partNumber: typeof part.partNumber === "number" ? part.partNumber : 1,
@@ -11855,7 +11828,7 @@ var MockCalmLensApi = class {
11855
11828
  * `search`, by name unless `ordering` says otherwise, with the folders above them.
11856
11829
  */
11857
11830
  async listFolders(query) {
11858
- const all = await this.databaseStorage.listFolders?.(this.projectId) ?? [];
11831
+ const all = await this.databaseStorage.listFolders(this.projectId);
11859
11832
  const parentId = query.get("parentId");
11860
11833
  const search = query.get("search")?.trim() || null;
11861
11834
  const sort = this.sort(query, ["name", "createdAt"], 1);
@@ -11905,7 +11878,7 @@ var MockCalmLensApi = class {
11905
11878
  createdAt: now,
11906
11879
  updatedAt: now
11907
11880
  };
11908
- return this.databaseStorage.createFolder ? await this.databaseStorage.createFolder(folder) : folder;
11881
+ return this.databaseStorage.createFolder(folder);
11909
11882
  }
11910
11883
  async updateFolder(folderId, body) {
11911
11884
  const folder = await this.findOwnFolder(folderId);
@@ -11916,17 +11889,17 @@ var MockCalmLensApi = class {
11916
11889
  ...name !== void 0 ? { name } : {},
11917
11890
  updatedAt: this.now()
11918
11891
  };
11919
- return this.databaseStorage.updateFolder ? await this.databaseStorage.updateFolder(updated) : updated;
11892
+ return this.databaseStorage.updateFolder(updated);
11920
11893
  }
11921
11894
  async deleteFolder(folderId) {
11922
11895
  await this.findOwnFolder(folderId);
11923
11896
  const hasAssets = (await this.databaseStorage.listAssets(this.projectId)).some((asset) => asset.folderId === folderId);
11924
- const hasChildren = (await this.databaseStorage.listFolders?.(this.projectId) ?? []).some((folder) => folder.parentId === folderId);
11897
+ const hasChildren = (await this.databaseStorage.listFolders(this.projectId)).some((folder) => folder.parentId === folderId);
11925
11898
  if (hasAssets || hasChildren) throw fail(require_CalmLensError.API_ERROR_CODES.FOLDER_NOT_EMPTY, { details: {
11926
11899
  hasAssets,
11927
11900
  hasChildren
11928
11901
  } });
11929
- await this.databaseStorage.deleteFolder?.(folderId);
11902
+ await this.databaseStorage.deleteFolder(folderId);
11930
11903
  }
11931
11904
  async moveFolder(folderId, body) {
11932
11905
  const folder = await this.findOwnFolder(folderId);
@@ -11946,10 +11919,10 @@ var MockCalmLensApi = class {
11946
11919
  parentId: targetParentId,
11947
11920
  updatedAt: this.now()
11948
11921
  };
11949
- return this.databaseStorage.updateFolder ? await this.databaseStorage.updateFolder(updated) : updated;
11922
+ return this.databaseStorage.updateFolder(updated);
11950
11923
  }
11951
11924
  async resolveFolder(folderId) {
11952
- const folder = await this.databaseStorage.getFolder?.(folderId);
11925
+ const folder = await this.databaseStorage.getFolder(folderId);
11953
11926
  return folder && folder.projectId === this.projectId ? folder : void 0;
11954
11927
  }
11955
11928
  async findOwnFolder(folderId) {
@@ -11958,7 +11931,7 @@ var MockCalmLensApi = class {
11958
11931
  return folder;
11959
11932
  }
11960
11933
  async assertUniqueFolderName(name, parentId, excludeFolderId) {
11961
- if ((await this.databaseStorage.listFolders?.(this.projectId) ?? []).find((folder) => folder.id !== excludeFolderId && (folder.parentId ?? null) === parentId && folder.name === name)) throw fail(require_CalmLensError.API_ERROR_CODES.DUPLICATE_FOLDER_NAME, { message: `A folder named "${name}" already exists in this location.` });
11934
+ if ((await this.databaseStorage.listFolders(this.projectId)).find((folder) => folder.id !== excludeFolderId && (folder.parentId ?? null) === parentId && folder.name === name)) throw fail(require_CalmLensError.API_ERROR_CODES.DUPLICATE_FOLDER_NAME, { message: `A folder named "${name}" already exists in this location.` });
11962
11935
  }
11963
11936
  /** A page of the project's upload presets, oldest first unless `sort` says otherwise. */
11964
11937
  listUploadPresets(query) {
@@ -12227,7 +12200,7 @@ var MockCalmLensApi = class {
12227
12200
  }, url);
12228
12201
  const hasApiKey = request.headers.get("x-api-key") === this.apiKey;
12229
12202
  const grants = hasApiKey ? this.grants : [];
12230
- const folders = await this.databaseStorage.listFolders?.(this.projectId) ?? [];
12203
+ const folders = await this.databaseStorage.listFolders(this.projectId);
12231
12204
  const canDownload = () => permits(grants, "assets:download", asset.folderId ?? null, folders);
12232
12205
  const status = asset.classification.moderation.decision;
12233
12206
  const isHead = request.method === "HEAD";
@@ -12338,7 +12311,7 @@ var MockCalmLensApi = class {
12338
12311
  availability: "unavailable",
12339
12312
  code: "viewer/region-required"
12340
12313
  };
12341
- const applied = stricter.filter((entry) => entry.region === region || entry.region === "EU" && require_CalmLensTestInputArguments.EU_COUNTRIES.has(region)).sort((a, b) => REGIONAL_STATUS_RANK[b.status] - REGIONAL_STATUS_RANK[a.status])[0];
12314
+ const applied = stricter.filter((entry) => entry.region === region || entry.region === "EU" && require_test_inputs.EU_COUNTRIES.has(region)).sort((a, b) => REGIONAL_STATUS_RANK[b.status] - REGIONAL_STATUS_RANK[a.status])[0];
12342
12315
  if (applied?.status === "blocked" || applied?.status === "purged") return {
12343
12316
  availability: "unavailable",
12344
12317
  code: "asset/not-available"
@@ -12775,12 +12748,9 @@ const createWebhookHeaders = async (options) => {
12775
12748
  [require_CalmLensServerClient.WEBHOOK_SIGNATURE_HEADER]: await createWebhookSignatureHeader(options.secret, timestamp, options.body)
12776
12749
  };
12777
12750
  };
12778
- // src/testing.ts
12779
- /** A spoken media test phrase for `signal`, signed with the project's test input key. */
12780
- const generateMediaTestCode = (signal, key) => require_CalmLensTestInputArguments.withValidTestInputArguments(key, () => generateMediaTestCode$1(signal, key));
12781
12751
  exports.InMemoryMockDatabaseStorage = InMemoryMockDatabaseStorage;
12782
12752
  exports.InMemoryMockImageStorage = InMemoryMockImageStorage;
12783
- exports.MEDIA_TEST_SIGNALS = MEDIA_TEST_SIGNALS;
12753
+ exports.MEDIA_TEST_SIGNALS = require_test_inputs.MEDIA_TEST_SIGNALS;
12784
12754
  exports.MOCK_API_KEY_ID = MOCK_API_KEY_ID;
12785
12755
  exports.MOCK_API_KEY_PREFIX = MOCK_API_KEY_PREFIX;
12786
12756
  exports.MockCalmLensAppClient = MockCalmLensAppClient;
@@ -12789,7 +12759,7 @@ exports.MockDecision = MockDecision;
12789
12759
  exports.createMockApiKey = createMockApiKey;
12790
12760
  exports.createWebhookHeaders = createWebhookHeaders;
12791
12761
  exports.createWebhookSignatureHeader = createWebhookSignatureHeader;
12792
- exports.generateMediaTestCode = generateMediaTestCode;
12762
+ exports.generateMediaTestCode = require_test_inputs.generateMediaTestCode;
12793
12763
  exports.mockDecision = mockDecision;
12794
12764
  exports.signUploadToken = require_CalmLensServerClient.signUploadTokenWithApiKey;
12795
12765
  exports.toWebhookEventPayload = toWebhookEventPayload;
@@ -1,5 +1,5 @@
1
- const require_CalmLensCdn = require("./CalmLensCdn-CdYY_XtK.js");
2
- require("./Core-BlnBBJKb.js");
1
+ const require_CalmLensCdn = require("./CalmLensCdn-DCj0AfoS.js");
2
+ require("./Core-BHQSo7rY.js");
3
3
  // src/ui/viewers/PdfLoader.ts
4
4
  let loading;
5
5
  /**
@@ -1,5 +1,5 @@
1
- import "./CalmLensTypes-_f7QVRtO.js";
2
- import { K as AssetOptions, Z as AssetView, ct as DocumentViewerOptions, dt as TextViewerOptions, lt as PdfAssetOptions, pt as ViewerOptions, q as AssetSession, ut as SpreadsheetViewerOptions } from "./Core-4iFxKJnY.js";
1
+ import "./CalmLensTypes-jond9q6a.js";
2
+ import { K as AssetOptions, Z as AssetView, ct as DocumentViewerOptions, dt as TextViewerOptions, lt as PdfAssetOptions, pt as ViewerOptions, q as AssetSession, ut as SpreadsheetViewerOptions } from "./Core-C6_Q5ZME.js";
3
3
  import "pdfjs-dist";
4
4
  /** A viewer mounted into an element, which it owns the children of. */
5
5
  interface AssetViewer<O extends ViewerOptions = ViewerOptions> {
package/cjs/ui.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { $ as MediaPlayback, A as CustomUploadContext, B as isFileAccepted, C as formatMessage, D as resolveMessages, E as getUploadItemOutcome, F as UploadFile, G as AssetImageSource, H as AssetDisplay, I as UploadItem, J as AssetSessionState, K as AssetOptions, L as UploadSnapshot, M as UploadClient, N as UploadController, O as CalmLensProvidedOptions, P as UploadControllerOptions, Q as INSTANT_LOAD_MS, R as UploadStage, S as formatBytes, T as getUploadItemMessage, U as AssetDocumentOptions, V as withProvidedOptions, W as AssetImageOptions, X as AssetVideoOptions, Y as AssetSpreadsheetOptions, Z as AssetView, _ as DEFAULT_MESSAGES, _t as DEFAULT_VIEWER_MESSAGES, a as ProgressFetchOptions, at as isImageReady, b as describeUploadItem, bt as resolveViewerMessages, c as ICON_ATTRIBUTES, ct as DocumentViewerOptions, d as AssetDisplayOptions, dt as TextViewerOptions, et as getAssetAspectRatio, f as AssetEventHandlers, ft as ViewerAsset, g as CalmLensMessages, gt as isSpreadsheetFormat, h as UploaderProps, ht as getAssetViewerKind, i as CALMLENS_STYLES, it as getPlayedPercent, j as CustomUploadResult, k as CalmLensUpload, l as IconName, lt as PdfAssetOptions, m as UploaderDisplayOptions, mt as ViewerTextOptions, n as CalmLensTheme, nt as getAssetViewKey, o as createProgressFetch, ot as pickAssetSource, p as AssetProps, pt as ViewerOptions, q as AssetSession, r as resolveTheme, rt as getPeakHeights, s as ICONS, st as AssetViewerKind, t as CALMLENS_THEME, tt as getAssetView, u as ASSET_FILE_ICON_SIZE, ut as SpreadsheetViewerOptions, v as UploadItemView, vt as ViewerMessages, w as getDropzoneHint, x as describeUploader, y as UploaderView, yt as formatViewerMessage, z as createUploadController } from "./Core-4iFxKJnY.js";
2
- import { _ as spreadsheetColumnIndex, a as isMountedViewerKind, b as AssetViewer, c as AssetViewerOptionsByKind, d as createTextViewer, f as SpreadsheetCell, g as parseSpreadsheetText, h as getSpreadsheetPage, i as getMountedViewerOptions, l as VIEWER_STYLES, m as SpreadsheetSheet, n as AssetViewerMount, o as ASSET_VIEWERS, p as SpreadsheetRow, r as MountedViewerKind, s as AssetViewerName, t as MediaStreamPlayer, u as createSpreadsheetViewer, v as loadPdfJs, x as ViewerState, y as createDocumentViewer } from "./ui-BMQW3Hse.js";
1
+ import { $ as MediaPlayback, A as CustomUploadContext, B as isFileAccepted, C as formatMessage, D as resolveMessages, E as getUploadItemOutcome, F as UploadFile, G as AssetImageSource, H as AssetDisplay, I as UploadItem, J as AssetSessionState, K as AssetOptions, L as UploadSnapshot, M as UploadClient, N as UploadController, O as CalmLensProvidedOptions, P as UploadControllerOptions, Q as INSTANT_LOAD_MS, R as UploadStage, S as formatBytes, T as getUploadItemMessage, U as AssetDocumentOptions, V as withProvidedOptions, W as AssetImageOptions, X as AssetVideoOptions, Y as AssetSpreadsheetOptions, Z as AssetView, _ as DEFAULT_MESSAGES, _t as DEFAULT_VIEWER_MESSAGES, a as ProgressFetchOptions, at as isImageReady, b as describeUploadItem, bt as resolveViewerMessages, c as ICON_ATTRIBUTES, ct as DocumentViewerOptions, d as AssetDisplayOptions, dt as TextViewerOptions, et as getAssetAspectRatio, f as AssetEventHandlers, ft as ViewerAsset, g as CalmLensMessages, gt as isSpreadsheetFormat, h as UploaderProps, ht as getAssetViewerKind, i as CALMLENS_STYLES, it as getPlayedPercent, j as CustomUploadResult, k as CalmLensUpload, l as IconName, lt as PdfAssetOptions, m as UploaderDisplayOptions, mt as ViewerTextOptions, n as CalmLensTheme, nt as getAssetViewKey, o as createProgressFetch, ot as pickAssetSource, p as AssetProps, pt as ViewerOptions, q as AssetSession, r as resolveTheme, rt as getPeakHeights, s as ICONS, st as AssetViewerKind, t as CALMLENS_THEME, tt as getAssetView, u as ASSET_FILE_ICON_SIZE, ut as SpreadsheetViewerOptions, v as UploadItemView, vt as ViewerMessages, w as getDropzoneHint, x as describeUploader, y as UploaderView, yt as formatViewerMessage, z as createUploadController } from "./Core-C6_Q5ZME.js";
2
+ import { _ as spreadsheetColumnIndex, a as isMountedViewerKind, b as AssetViewer, c as AssetViewerOptionsByKind, d as createTextViewer, f as SpreadsheetCell, g as parseSpreadsheetText, h as getSpreadsheetPage, i as getMountedViewerOptions, l as VIEWER_STYLES, m as SpreadsheetSheet, n as AssetViewerMount, o as ASSET_VIEWERS, p as SpreadsheetRow, r as MountedViewerKind, s as AssetViewerName, t as MediaStreamPlayer, u as createSpreadsheetViewer, v as loadPdfJs, x as ViewerState, y as createDocumentViewer } from "./ui-Cp18fGXG.js";
3
3
  export { ASSET_FILE_ICON_SIZE, ASSET_VIEWERS, type AssetDisplay, type AssetDisplayOptions, type AssetDocumentOptions, type AssetEventHandlers, type AssetImageOptions, type AssetImageSource, type AssetOptions, type AssetProps, AssetSession, type AssetSessionState, type AssetSpreadsheetOptions, type AssetVideoOptions, type AssetView, type AssetViewer, type AssetViewerKind, AssetViewerMount, AssetViewerName, AssetViewerOptionsByKind, CALMLENS_STYLES, CALMLENS_THEME, type CalmLensMessages, type CalmLensProvidedOptions, type CalmLensTheme, type CalmLensUpload, type CustomUploadContext, type CustomUploadResult, DEFAULT_MESSAGES, DEFAULT_VIEWER_MESSAGES, type DocumentViewerOptions, ICONS, ICON_ATTRIBUTES, INSTANT_LOAD_MS, type IconName, type MediaPlayback, MediaStreamPlayer, type MountedViewerKind, type PdfAssetOptions, type ProgressFetchOptions, type SpreadsheetCell, type SpreadsheetRow, type SpreadsheetSheet, type SpreadsheetViewerOptions, type TextViewerOptions, type UploadClient, UploadController, type UploadControllerOptions, type UploadFile, type UploadItem, type UploadItemView, type UploadSnapshot, type UploadStage, type UploaderDisplayOptions, type UploaderProps, type UploaderView, VIEWER_STYLES, type ViewerAsset, type ViewerMessages, type ViewerOptions, type ViewerState, type ViewerTextOptions, createDocumentViewer, createProgressFetch, createSpreadsheetViewer, createTextViewer, createUploadController, describeUploadItem, describeUploader, formatBytes, formatMessage, formatViewerMessage, getAssetAspectRatio, getAssetView, getAssetViewKey, getAssetViewerKind, getDropzoneHint, getMountedViewerOptions, getPeakHeights, getPlayedPercent, getSpreadsheetPage, getUploadItemMessage, getUploadItemOutcome, isFileAccepted, isImageReady, isMountedViewerKind, isSpreadsheetFormat, loadPdfJs, parseSpreadsheetText, pickAssetSource, resolveMessages, resolveTheme, resolveViewerMessages, spreadsheetColumnIndex, withProvidedOptions };
package/cjs/ui.js CHANGED
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_ui = require("./ui-Cy8MWXOw.js");
3
- const require_Core = require("./Core-BlnBBJKb.js");
4
- const require_UploadController = require("./UploadController-BYuHuZ7K.js");
2
+ const require_ui = require("./ui-2jJvTcCP.js");
3
+ const require_Core = require("./Core-BHQSo7rY.js");
4
+ const require_UploadController = require("./UploadController-C1tiTTRR.js");
5
5
  exports.ASSET_FILE_ICON_SIZE = require_Core.ASSET_FILE_ICON_SIZE;
6
6
  exports.ASSET_VIEWERS = require_ui.ASSET_VIEWERS;
7
7
  exports.AssetSession = require_Core.AssetSession;
package/cjs/vue.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { O as CalmLensAppClientOptions, fn as ViewerClaims, g as AssetModerationStatus, i as AssetAvailability } from "./CalmLensTypes-_f7QVRtO.js";
2
- import "./index-IEA75nev.js";
3
- import { $ as MediaPlayback, A as CustomUploadContext, B as isFileAccepted, C as formatMessage, D as resolveMessages, E as getUploadItemOutcome, F as UploadFile, G as AssetImageSource, H as AssetDisplay, J as AssetSessionState, K as AssetOptions, M as UploadClient, N as UploadController, O as CalmLensProvidedOptions, Q as INSTANT_LOAD_MS, R as UploadStage, S as formatBytes, T as getUploadItemMessage, U as AssetDocumentOptions, V as withProvidedOptions, W as AssetImageOptions, X as AssetVideoOptions, Y as AssetSpreadsheetOptions, Z as AssetView, _ as DEFAULT_MESSAGES, _t as DEFAULT_VIEWER_MESSAGES, a as ProgressFetchOptions, at as isImageReady, b as describeUploadItem, bt as resolveViewerMessages, c as ICON_ATTRIBUTES, ct as DocumentViewerOptions, d as AssetDisplayOptions, dt as TextViewerOptions, et as getAssetAspectRatio, f as AssetEventHandlers, ft as ViewerAsset, g as CalmLensMessages, gt as isSpreadsheetFormat, ht as getAssetViewerKind, i as CALMLENS_STYLES, it as getPlayedPercent, j as CustomUploadResult, l as IconName, lt as PdfAssetOptions, m as UploaderDisplayOptions, mt as ViewerTextOptions, n as CalmLensTheme, nt as getAssetViewKey, o as createProgressFetch, ot as pickAssetSource, p as AssetProps, pt as ViewerOptions, q as AssetSession, r as resolveTheme, rt as getPeakHeights, s as ICONS, st as AssetViewerKind, t as CALMLENS_THEME, tt as getAssetView, u as ASSET_FILE_ICON_SIZE, ut as SpreadsheetViewerOptions, v as UploadItemView, vt as ViewerMessages, w as getDropzoneHint, x as describeUploader, y as UploaderView, yt as formatViewerMessage } from "./Core-4iFxKJnY.js";
4
- import { a as UploaderProps, i as UploadSnapshot, n as UploadControllerOptions, r as UploadItem, s as createUploadController, t as CalmLensUpload } from "./BrowserUpload-CuG3tWSo.js";
5
- import { _ as spreadsheetColumnIndex, a as isMountedViewerKind, b as AssetViewer, c as AssetViewerOptionsByKind, d as createTextViewer, f as SpreadsheetCell, g as parseSpreadsheetText, h as getSpreadsheetPage, i as getMountedViewerOptions, l as VIEWER_STYLES, m as SpreadsheetSheet, n as AssetViewerMount, o as ASSET_VIEWERS, p as SpreadsheetRow, r as MountedViewerKind, s as AssetViewerName, t as MediaStreamPlayer, u as createSpreadsheetViewer, v as loadPdfJs, x as ViewerState, y as createDocumentViewer } from "./ui-BMQW3Hse.js";
1
+ import { O as CalmLensAppClientOptions, fn as ViewerClaims, g as AssetModerationStatus, i as AssetAvailability } from "./CalmLensTypes-jond9q6a.js";
2
+ import "./index-CgAztQdX.js";
3
+ import { $ as MediaPlayback, A as CustomUploadContext, B as isFileAccepted, C as formatMessage, D as resolveMessages, E as getUploadItemOutcome, F as UploadFile, G as AssetImageSource, H as AssetDisplay, J as AssetSessionState, K as AssetOptions, M as UploadClient, N as UploadController, O as CalmLensProvidedOptions, Q as INSTANT_LOAD_MS, R as UploadStage, S as formatBytes, T as getUploadItemMessage, U as AssetDocumentOptions, V as withProvidedOptions, W as AssetImageOptions, X as AssetVideoOptions, Y as AssetSpreadsheetOptions, Z as AssetView, _ as DEFAULT_MESSAGES, _t as DEFAULT_VIEWER_MESSAGES, a as ProgressFetchOptions, at as isImageReady, b as describeUploadItem, bt as resolveViewerMessages, c as ICON_ATTRIBUTES, ct as DocumentViewerOptions, d as AssetDisplayOptions, dt as TextViewerOptions, et as getAssetAspectRatio, f as AssetEventHandlers, ft as ViewerAsset, g as CalmLensMessages, gt as isSpreadsheetFormat, ht as getAssetViewerKind, i as CALMLENS_STYLES, it as getPlayedPercent, j as CustomUploadResult, l as IconName, lt as PdfAssetOptions, m as UploaderDisplayOptions, mt as ViewerTextOptions, n as CalmLensTheme, nt as getAssetViewKey, o as createProgressFetch, ot as pickAssetSource, p as AssetProps, pt as ViewerOptions, q as AssetSession, r as resolveTheme, rt as getPeakHeights, s as ICONS, st as AssetViewerKind, t as CALMLENS_THEME, tt as getAssetView, u as ASSET_FILE_ICON_SIZE, ut as SpreadsheetViewerOptions, v as UploadItemView, vt as ViewerMessages, w as getDropzoneHint, x as describeUploader, y as UploaderView, yt as formatViewerMessage } from "./Core-C6_Q5ZME.js";
4
+ import { a as UploaderProps, i as UploadSnapshot, n as UploadControllerOptions, r as UploadItem, s as createUploadController, t as CalmLensUpload } from "./BrowserUpload-_iMX_nq0.js";
5
+ import { _ as spreadsheetColumnIndex, a as isMountedViewerKind, b as AssetViewer, c as AssetViewerOptionsByKind, d as createTextViewer, f as SpreadsheetCell, g as parseSpreadsheetText, h as getSpreadsheetPage, i as getMountedViewerOptions, l as VIEWER_STYLES, m as SpreadsheetSheet, n as AssetViewerMount, o as ASSET_VIEWERS, p as SpreadsheetRow, r as MountedViewerKind, s as AssetViewerName, t as MediaStreamPlayer, u as createSpreadsheetViewer, v as loadPdfJs, x as ViewerState, y as createDocumentViewer } from "./ui-Cp18fGXG.js";
6
6
  import { App, MaybeRefOrGetter, PropType, ShallowRef } from "vue";
7
7
  /** Shows a text asset's text, escaped, in a scrolling region. */
8
8
  export declare const CalmLensTextViewer: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
package/cjs/vue.js CHANGED
@@ -1,9 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_ui = require("./ui-Cy8MWXOw.js");
3
- const require_Core = require("./Core-BlnBBJKb.js");
4
- const require_UploadController = require("./UploadController-BYuHuZ7K.js");
2
+ const require_ui = require("./ui-2jJvTcCP.js");
3
+ const require_Core = require("./Core-BHQSo7rY.js");
4
+ const require_UploadController = require("./UploadController-C1tiTTRR.js");
5
5
  const require_FileIcons = require("./FileIcons-Ob003MdS.js");
6
- const require_BrowserUpload = require("./BrowserUpload-84KQWr1Q.js");
6
+ const require_BrowserUpload = require("./BrowserUpload-DS0lxg5C.js");
7
7
  let vue = require("vue");
8
8
  // src/viewers/Vue.ts
9
9
  const optional$1 = (type) => ({
@@ -1,4 +1,4 @@
1
- import { n as createUploadController$1 } from "./UploadController-9fkYFVZM.js";
1
+ import { n as createUploadController$1 } from "./UploadController-BYxiONcw.js";
2
2
  // src/ui/BrowserUpload.ts
3
3
  /** Creates an upload queue for the browser components, such as one a form starts on submit. */
4
4
  const createUploadController = (options) => createUploadController$1(options);
@@ -1,5 +1,5 @@
1
- import { F as UploadFile, I as UploadItem$1, L as UploadSnapshot$1, N as UploadController, P as UploadControllerOptions$1, h as UploaderProps$1, k as CalmLensUpload$1 } from "./Core-4iFxKJnY.js";
2
- import { r as UseCalmLensUploadResult$1 } from "./ReactUpload-4qd2xACg.js";
1
+ import { F as UploadFile, I as UploadItem$1, L as UploadSnapshot$1, N as UploadController, P as UploadControllerOptions$1, h as UploaderProps$1, k as CalmLensUpload$1 } from "./Core-C6_Q5ZME.js";
2
+ import { r as UseCalmLensUploadResult$1 } from "./ReactUpload-fy6zhY8M.js";
3
3
  type UploadItem<F extends UploadFile = File> = UploadItem$1<F>;
4
4
  type CalmLensUpload<F extends UploadFile = File> = CalmLensUpload$1<F>;
5
5
  type UploadSnapshot<F extends UploadFile = File> = UploadSnapshot$1<F>;
@@ -1,6 +1,6 @@
1
- import { C as invalidConfig, S as invalidArgument } from "./CalmLensError-C15tWu8W.js";
2
- import { S as validateAppClientOptions, d as checkOptionKeys, o as buildAssetUrl, p as encodePathSegment, u as DEFAULT_CDN_BASE_URL } from "./CalmLensCdn-cmxtF_dw.js";
3
- import { c as prepareSubmitAssetOptions, f as APP_OPTION_KEYS, i as expectUploadedAsset, l as resolveConnectionOptions, t as CalmLensConnection, u as splitsIntoParts } from "./CalmLensConnection-DEfpIugc.js";
1
+ import { C as invalidConfig, S as invalidArgument } from "./CalmLensError-DjkibkdI.js";
2
+ import { S as validateAppClientOptions, d as checkOptionKeys, o as buildAssetUrl, p as encodePathSegment, u as DEFAULT_CDN_BASE_URL } from "./CalmLensCdn-Dh546rXe.js";
3
+ import { c as prepareSubmitAssetOptions, f as APP_OPTION_KEYS, i as expectUploadedAsset, l as resolveConnectionOptions, t as CalmLensConnection, u as splitsIntoParts } from "./CalmLensConnection-BbFlVAdl.js";
4
4
  // src/client/CalmLensAppClient.ts
5
5
  const inspectSymbol = Symbol.for("nodejs.util.inspect.custom");
6
6
  /** `options`, once `checkOptionKeys` finds only keys `operation` takes. */
@@ -1,4 +1,4 @@
1
- import { M as CdnAssetUrlOptions, O as CalmLensAppClientOptions, Rt as RequestOptions, Vt as RetrieveAssetOptions, an as UploadAssetPartOptions, ln as UploadPresetSubmitAssetOptions, un as UploadedAsset } from "./CalmLensTypes-_f7QVRtO.js";
1
+ import { M as CdnAssetUrlOptions, O as CalmLensAppClientOptions, Rt as RequestOptions, Vt as RetrieveAssetOptions, an as UploadAssetPartOptions, ln as UploadPresetSubmitAssetOptions, un as UploadedAsset } from "./CalmLensTypes-jond9q6a.js";
2
2
  declare const inspectSymbol: unique symbol;
3
3
  /**
4
4
  * The CalmLens client for browsers and React Native apps. It uploads through an upload preset,
@@ -1,4 +1,4 @@
1
- import { C as invalidConfig, S as invalidArgument, b as MAX_ERROR_BODY_LENGTH, l as CalmLensError, x as SDK_ERROR_CODES } from "./CalmLensError-C15tWu8W.js";
1
+ import { C as invalidConfig, S as invalidArgument, b as MAX_ERROR_BODY_LENGTH, l as CalmLensError, x as SDK_ERROR_CODES } from "./CalmLensError-DjkibkdI.js";
2
2
  // src/client/CalmLensLogging.ts
3
3
  const LOG_LEVELS = [
4
4
  "off",
@@ -152,7 +152,7 @@ const listPages = (fetchPage, { cursor, feed = false } = {}) => {
152
152
  };
153
153
  // src/client/CalmLensVersion.ts
154
154
  /** This SDK's version, from its package.json. */
155
- const SDK_VERSION = "0.37.1";
155
+ const SDK_VERSION = "0.38.1";
156
156
  const runtimeName = () => {
157
157
  const runtime = globalThis;
158
158
  if (isReactNativeRuntime()) return "react-native";
@@ -1,5 +1,5 @@
1
- import { S as invalidArgument, l as CalmLensError, w as API_ERROR_CODES, x as SDK_ERROR_CODES } from "./CalmLensError-C15tWu8W.js";
2
- import { A as MAX_OTHER_DOCUMENT_UPLOAD_BYTES, D as MAX_DIRECT_IMAGE_UPLOAD_BYTES, F as sleep, M as getRejectedUploadMimeTypeError, N as normalizeUploadMimeType, O as MAX_IMAGE_UPLOAD_BYTES, P as CalmLensTransport, T as UPLOAD_MIME_DOCUMENTS, U as resolveLogLevel, _ as randomUuid, j as MAX_PDF_UPLOAD_BYTES, k as MAX_NON_IMAGE_UPLOAD_BYTES, m as isAcceptedUploadMimeType, y as stringifyQuery } from "./CalmLensCdn-cmxtF_dw.js";
1
+ import { S as invalidArgument, l as CalmLensError, w as API_ERROR_CODES, x as SDK_ERROR_CODES } from "./CalmLensError-DjkibkdI.js";
2
+ import { A as MAX_OTHER_DOCUMENT_UPLOAD_BYTES, D as MAX_DIRECT_IMAGE_UPLOAD_BYTES, F as sleep, M as getRejectedUploadMimeTypeError, N as normalizeUploadMimeType, O as MAX_IMAGE_UPLOAD_BYTES, P as CalmLensTransport, T as UPLOAD_MIME_DOCUMENTS, U as resolveLogLevel, _ as randomUuid, j as MAX_PDF_UPLOAD_BYTES, k as MAX_NON_IMAGE_UPLOAD_BYTES, m as isAcceptedUploadMimeType, y as stringifyQuery } from "./CalmLensCdn-Dh546rXe.js";
3
3
  // src/contract/AssetPayload.js
4
4
  const bufferInputToBytes = (value) => {
5
5
  if (value instanceof ArrayBuffer) return new Uint8Array(value);
@@ -606,13 +606,23 @@ const assertUploadSize = (type, size, inParts) => {
606
606
  };
607
607
  /** Checks upload options before anything is sent. */
608
608
  const isBlob = (value) => typeof Blob !== "undefined" && value instanceof Blob;
609
+ /** Plain text given without a type, which is `text/plain`, as the API defaults it. */
610
+ const isUntypedText = (content) => !!content && typeof content === "object" && "plainText" in content && content.type === void 0;
609
611
  /**
610
- * `content` given as a `Blob` or `File`, as the `{ data, type }` the rest of the client reads: the
611
- * content type is the Blob's own, and a File's name is the asset's when the options give none.
612
+ * `content` as the `{ data, type }` or `{ plainText, type }` the rest of the client reads: a `Blob`
613
+ * or `File` has its own type (and a File's name is the asset's when the options give none), and
614
+ * plain text without a type is `text/plain`.
612
615
  */
613
616
  const withContentObject = (options) => {
614
617
  if (!options || typeof options !== "object" || !("content" in options)) return options;
615
618
  const content = options.content;
619
+ if (isUntypedText(content)) return {
620
+ ...options,
621
+ content: {
622
+ ...content,
623
+ type: "text/plain"
624
+ }
625
+ };
616
626
  if (!isBlob(content)) return options;
617
627
  if (!content.type) throw invalidPayload("The Blob has no type: create it with one, such as new Blob([bytes], { type: \"image/png\" }), or pass { data, type }");
618
628
  const fileName = typeof File !== "undefined" && content instanceof File ? content.name : void 0;
@@ -55,6 +55,7 @@ const API_ERROR_CODES = {
55
55
  IDEMPOTENT_REQUEST_IN_PROGRESS: "idempotency/request-in-progress",
56
56
  NO_RENDERED_VERSION: "asset/no-rendered-version",
57
57
  ASSET_NOT_FOUND: "asset/not-found",
58
+ ASSET_NOT_AVAILABLE: "asset/not-available",
58
59
  PROJECT_NOT_FOUND: "project/not-found",
59
60
  ASSET_CHILD_NOT_DELETABLE: "asset/child-not-deletable",
60
61
  ASSET_REVIEW_CHANGED: "asset/review-changed",
@@ -341,6 +342,10 @@ const API_ERROR_DEFINITIONS = {
341
342
  status: 404,
342
343
  message: "Asset not found"
343
344
  },
345
+ "asset/not-available": {
346
+ status: 403,
347
+ message: "This asset isn't available to this viewer: it may still be uploading or awaiting moderation, or its delivery is blocked or restricted."
348
+ },
344
349
  "project/not-found": {
345
350
  status: 404,
346
351
  message: "Project not found"
@@ -784,8 +789,8 @@ var CalmLensError = class CalmLensError extends Error {
784
789
  /**
785
790
  * Whether repeating the same request may succeed: transport failures, timeouts (a request's
786
791
  * `timeoutMs` or `waitForDecision`'s deadline), throttling (429), internal and gateway errors (500, 502, 503, 504)
787
- * and idempotent requests still in progress. Only repeat a create or upload with the same
788
- * `idempotencyKey`.
792
+ * and idempotent requests still in progress. Only repeat a write (a create, upload, change or
793
+ * delete) with the same `idempotencyKey`.
789
794
  */
790
795
  isRetryable() {
791
796
  return RETRYABLE_CODES.has(this.code) || this.status !== void 0 && RETRYABLE_STATUSES.has(this.status);
@@ -1,6 +1,6 @@
1
1
  import { c as HashList, l as HashListEntry } from "./Classification-C3pkrGYS-B7EygpJn.js";
2
- import { $t as UpdateFolderOptions, At as PolicyIdOptions, B as CreateHashListOptions, Bn as AssetSearchQuery, Bt as RetrieveAssetByExternalIdOptions, Ct as ListPoliciesOptions, D as BatchAssetsResponse, E as BatchAssetsOptions, Et as MoveFolderOptions, Ft as RemoveAssetContentOptions, G as DeleteAssetOptions, Gt as SignAssetUrlOptions, Hn as AssetInfo, Ht as RetryAssetOptions, I as ClassifyTextOptions, It as RequestAssetReviewOptions, J as EnsureLensesOptions, Jt as SignedUploadToken, K as DeleteMetadataFieldOptions, Kt as SignUploadTokenOptions, M as CdnAssetUrlOptions, Nt as ProjectSettingsResource, P as CdnServeOptions, Qt as UpdateAssetOptions, Rn as Folder, Rt as RequestOptions, St as ListLensesOptions, T as AssignPolicyOptions, Tt as MoveAssetOptions, U as CreatePolicyOptions, V as CreateLensOptions, Vt as RetrieveAssetOptions, W as DecideAssetOptions, Wt as SetPolicyAutomaticUpdatesOptions, X as EnsureUploadPresetsOptions, Xt as SubmitAssetOptions, Y as EnsureMetadataFieldsOptions, Z as EnsureUploadPresetsResponse, _ as AssetPage, _n as AssetReviewRequest, _t as ListAssetsOptions, an as UploadAssetPartOptions, at as GetAssetInfoOptions, b as AssetTimelinePage, bt as ListHashListEntriesOptions, cn as UploadPresetPage, ct as HashListIdOptions, dn as VerifyWebhookSignatureOptions, en as UpdateHashListOptions, ft as Lens, gt as ListAssetTimelineOptions, ht as ListAssetChildrenOptions, in as UpgradePolicyOptions, it as FolderPage, jt as PolicyPage, k as CalmLensServerClientOptions, kt as Policy, lt as HashListPage, mt as LensPage, nn as UpdatePolicyOptions, nt as EventsPage, o as AssetChildrenPage, ot as HashListEntryIdOptions, pn as WaitForAssetDecisionOptions, pt as LensIdOptions, q as EnsureLensOptions, qt as SignedAssetUrl, r as Asset, rn as UpdateProjectSettingsOptions, rt as FolderIdOptions, sn as UploadPresetIdOptions, st as HashListEntryPage, t as AddHashListEntryOptions, tn as UpdateLensOptions, v as AssetSearchResponse, vt as ListEventsOptions, wt as ListUploadPresetsOptions, xt as ListHashListsOptions, yn as MetadataFieldsResource, yt as ListFoldersOptions, z as CreateFolderOptions, zt as ResetPolicyOptions } from "./CalmLensTypes-_f7QVRtO.js";
3
- import { d as ListPromise, l as CalmLensResponse, r as CdnResponse } from "./WebhookPayload-BJtggTLd.js";
2
+ import { $t as UpdateFolderOptions, At as PolicyIdOptions, B as CreateHashListOptions, Bn as AssetSearchQuery, Bt as RetrieveAssetByExternalIdOptions, Ct as ListPoliciesOptions, D as BatchAssetsResponse, E as BatchAssetsOptions, Et as MoveFolderOptions, Ft as RemoveAssetContentOptions, G as DeleteAssetOptions, Gt as SignAssetUrlOptions, Hn as AssetInfo, Ht as RetryAssetOptions, I as ClassifyTextOptions, It as RequestAssetReviewOptions, J as EnsureLensesOptions, Jt as SignedUploadToken, K as DeleteMetadataFieldOptions, Kt as SignUploadTokenOptions, M as CdnAssetUrlOptions, Nt as ProjectSettingsResource, P as CdnServeOptions, Qt as UpdateAssetOptions, Rn as Folder, Rt as RequestOptions, St as ListLensesOptions, T as AssignPolicyOptions, Tt as MoveAssetOptions, U as CreatePolicyOptions, V as CreateLensOptions, Vt as RetrieveAssetOptions, W as DecideAssetOptions, Wt as SetPolicyAutomaticUpdatesOptions, X as EnsureUploadPresetsOptions, Xt as SubmitAssetOptions, Y as EnsureMetadataFieldsOptions, Z as EnsureUploadPresetsResponse, _ as AssetPage, _n as AssetReviewRequest, _t as ListAssetsOptions, an as UploadAssetPartOptions, at as GetAssetInfoOptions, b as AssetTimelinePage, bt as ListHashListEntriesOptions, cn as UploadPresetPage, ct as HashListIdOptions, dn as VerifyWebhookSignatureOptions, en as UpdateHashListOptions, ft as Lens, gt as ListAssetTimelineOptions, ht as ListAssetChildrenOptions, in as UpgradePolicyOptions, it as FolderPage, jt as PolicyPage, k as CalmLensServerClientOptions, kt as Policy, lt as HashListPage, mt as LensPage, nn as UpdatePolicyOptions, nt as EventsPage, o as AssetChildrenPage, ot as HashListEntryIdOptions, pn as WaitForAssetDecisionOptions, pt as LensIdOptions, q as EnsureLensOptions, qt as SignedAssetUrl, r as Asset, rn as UpdateProjectSettingsOptions, rt as FolderIdOptions, sn as UploadPresetIdOptions, st as HashListEntryPage, t as AddHashListEntryOptions, tn as UpdateLensOptions, v as AssetSearchResponse, vt as ListEventsOptions, wt as ListUploadPresetsOptions, xt as ListHashListsOptions, yn as MetadataFieldsResource, yt as ListFoldersOptions, z as CreateFolderOptions, zt as ResetPolicyOptions } from "./CalmLensTypes-jond9q6a.js";
3
+ import { d as ListPromise, l as CalmLensResponse, r as CdnResponse } from "./WebhookPayload-DdpKjQGw.js";
4
4
  interface TransportRequest {
5
5
  /** The client method sending the request, such as `assets.retrieve`, for hooks and logs. */
6
6
  operation?: string;
@@ -8,7 +8,7 @@ interface TransportRequest {
8
8
  url: string;
9
9
  headers?: Record<string, string>;
10
10
  body?: BodyInit | null;
11
- /** Sent as `Idempotency-Key`; it also makes a POST safe to retry. */
11
+ /** Sent as `Idempotency-Key`; it also makes a write safe to retry. */
12
12
  idempotencyKey?: string;
13
13
  /** Deadline per attempt in milliseconds, or undefined for none. */
14
14
  timeoutMs?: number;
@@ -214,8 +214,8 @@ declare class CalmLensServerClient {
214
214
  * another (`asset/child-not-deletable`), or nothing is queued. Resolves with
215
215
  * `{ batchId, status: "queued", assetCount }` once queued; the work runs in the background
216
216
  * and records `asset.deleted` or `asset.content-removed` for each asset, with a `batch-id`
217
- * fact naming `batchId`. Assets under a safety hold are skipped. Not retried: it carries no
218
- * `Idempotency-Key`.
217
+ * fact naming `batchId`. Assets under a safety hold are skipped. Retried only with an
218
+ * `idempotencyKey` request option.
219
219
  */
220
220
  batch: (options: BatchAssetsOptions, requestOptions?: RequestOptions) => Promise<CalmLensResponse<BatchAssetsResponse>>;
221
221
  };
@@ -1,6 +1,6 @@
1
- import { C as invalidConfig, S as invalidArgument, l as CalmLensError, x as SDK_ERROR_CODES } from "./CalmLensError-C15tWu8W.js";
2
- import { B as copyLastResponse, C as validateBatchAssetsOptions, H as readEnv, L as isBrowserRuntime, R as isReactNativeRuntime, V as listPages, b as toTextAssetOptions, d as checkOptionKeys, g as pollForDecision, i as appendSignedLocation, l as validateSignAssetUrlOptions, o as buildAssetUrl, p as encodePathSegment, s as getAssetInfo, u as DEFAULT_CDN_BASE_URL, w as validateServerClientOptions, y as stringifyQuery } from "./CalmLensCdn-cmxtF_dw.js";
3
- import { a as getMockHooks, c as prepareSubmitAssetOptions, d as validateCallOptions, l as resolveConnectionOptions, m as SERVER_OPTION_KEYS, o as invalidPayload, p as NULLABLE_OPTION_KEYS, r as expectAsset, s as newIdempotencyKey, t as CalmLensConnection, u as splitsIntoParts } from "./CalmLensConnection-DEfpIugc.js";
1
+ import { C as invalidConfig, S as invalidArgument, l as CalmLensError, x as SDK_ERROR_CODES } from "./CalmLensError-DjkibkdI.js";
2
+ import { B as copyLastResponse, C as validateBatchAssetsOptions, H as readEnv, L as isBrowserRuntime, R as isReactNativeRuntime, V as listPages, b as toTextAssetOptions, d as checkOptionKeys, g as pollForDecision, i as appendSignedLocation, l as validateSignAssetUrlOptions, o as buildAssetUrl, p as encodePathSegment, s as getAssetInfo, u as DEFAULT_CDN_BASE_URL, w as validateServerClientOptions, y as stringifyQuery } from "./CalmLensCdn-Dh546rXe.js";
3
+ import { a as getMockHooks, c as prepareSubmitAssetOptions, d as validateCallOptions, l as resolveConnectionOptions, m as SERVER_OPTION_KEYS, o as invalidPayload, p as NULLABLE_OPTION_KEYS, r as expectAsset, s as newIdempotencyKey, t as CalmLensConnection, u as splitsIntoParts } from "./CalmLensConnection-BbFlVAdl.js";
4
4
  import { n as sha256Hex, r as timingSafeEqual, t as hmacSha256Hex } from "./CryptoUtils-BLCa-oZe-DKr3LmN6.js";
5
5
  // src/contract/JsonUtils.js
6
6
  const stringifyJsonCanonical = (value) => JSON.stringify(value, (_key, nestedValue) => {
@@ -654,8 +654,8 @@ sign: async (options) => {
654
654
  * another (`asset/child-not-deletable`), or nothing is queued. Resolves with
655
655
  * `{ batchId, status: "queued", assetCount }` once queued; the work runs in the background
656
656
  * and records `asset.deleted` or `asset.content-removed` for each asset, with a `batch-id`
657
- * fact naming `batchId`. Assets under a safety hold are skipped. Not retried: it carries no
658
- * `Idempotency-Key`.
657
+ * fact naming `batchId`. Assets under a safety hold are skipped. Retried only with an
658
+ * `idempotencyKey` request option.
659
659
  */
660
660
  batch: async (options, requestOptions) => {
661
661
  const { assetIds, operation } = checked("assets.batch", options);
@@ -936,7 +936,16 @@ sign: async (options) => {
936
936
  });
937
937
  }
938
938
  async #submitEnsureLenses(options, requestOptions) {
939
- for (let start = 0; start < options.length; start += 100) await this.#submitEnsureLensesChunk(options.slice(start, start + 100), requestOptions);
939
+ const key = requestOptions?.idempotencyKey;
940
+ const chunked = options.length > 100;
941
+ if (chunked && (key?.length ?? 0) > 240) throw invalidArgument(`idempotencyKey can be at most 240 characters for lenses sent in several requests`);
942
+ for (let start = 0; start < options.length; start += 100) {
943
+ const chunk = start / 100 + 1;
944
+ await this.#submitEnsureLensesChunk(options.slice(start, start + 100), key && chunked ? {
945
+ ...requestOptions,
946
+ idempotencyKey: `${key}:chunk-${chunk}`
947
+ } : requestOptions);
948
+ }
940
949
  }
941
950
  async #submitEnsureLensesChunk(options, requestOptions) {
942
951
  const result = await this.#send("ensureLenses", requestOptions, "PUT", `${this.#projectPath}/lenses`, { body: { lenses: options } });
@@ -42876,8 +42876,8 @@ interface ClientRequestDefaults {
42876
42876
  uploadTimeoutMs?: number;
42877
42877
  /**
42878
42878
  * How many times to retry a request that failed before a response arrived or returned 429,
42879
- * 500, 502, 503, 504 or `idempotency/request-in-progress`. Only reads and requests carrying an
42880
- * `Idempotency-Key` (creates and uploads) are retried, with jittered backoff that honours
42879
+ * 500, 502, 503, 504 or `idempotency/request-in-progress`. Only reads and writes carrying an
42880
+ * `Idempotency-Key` (uploads always do) are retried, with jittered backoff that honours
42881
42881
  * `Retry-After`. Streamed bodies are never retried. Defaults to 2; 0 disables retries.
42882
42882
  */
42883
42883
  maxRetries?: number;
@@ -42902,8 +42902,8 @@ interface RequestOptions {
42902
42902
  /** How many times to retry this call's requests; 0 turns retries off. */
42903
42903
  maxRetries?: number;
42904
42904
  /**
42905
- * Sent as `Idempotency-Key`, which also makes a create, upload or other POST safe to retry.
42906
- * Uploads generate one when you pass none.
42905
+ * Sent as `Idempotency-Key`, which makes any write (POST, PUT, PATCH or DELETE) safe to retry:
42906
+ * CalmLens runs it once and replays its response. Uploads generate one when you pass none.
42907
42907
  */
42908
42908
  idempotencyKey?: string;
42909
42909
  /** Extra headers. The SDK's own (`X-Api-Key`, `User-Agent`, `Idempotency-Key`) win. */
@@ -43339,7 +43339,23 @@ type ListAssetChildrenOptions = Partial<GetAssetChildrenQuery> & {
43339
43339
  type ListAssetTimelineOptions = Partial<GetAssetTimelineQuery> & {
43340
43340
  assetId: string;
43341
43341
  };
43342
- type AssetContentOptions = AssetBinaryPayloadInput & {
43342
+ /**
43343
+ * Content and its MIME type or file extension. `type` defaults to `text/plain` for `plainText`;
43344
+ * give `text/html` to moderate the text as a web page. Other content needs its type.
43345
+ */
43346
+ type AssetContentOptions = ((Extract<AssetBinaryPayloadInput, {
43347
+ plainText: string;
43348
+ }> & {
43349
+ type?: string;
43350
+ }) | (Exclude<AssetBinaryPayloadInput, {
43351
+ plainText: string;
43352
+ }> & {
43353
+ type: string;
43354
+ })) & {
43355
+ sizeInBytes?: number;
43356
+ };
43357
+ /** Content as the client sends it, with its type resolved. */
43358
+ type PreparedAssetContentOptions = AssetBinaryPayloadInput & {
43343
43359
  type: string;
43344
43360
  sizeInBytes?: number;
43345
43361
  };
@@ -43358,7 +43374,7 @@ interface UploadAssetPartOptions extends IdempotencyOptions {
43358
43374
  */
43359
43375
  wait?: boolean;
43360
43376
  }
43361
- type CreateMultipartUploadPartOptions = AssetContentOptions & {
43377
+ type CreateMultipartUploadPartOptions = PreparedAssetContentOptions & {
43362
43378
  partNumber?: number;
43363
43379
  isFinal?: boolean;
43364
43380
  sizeInBytes?: number;
@@ -43397,9 +43413,12 @@ interface SubmitAssetCommonOptions extends IdempotencyOptions {
43397
43413
  * name the asset's name when you give none), or bytes, base64 or plain text with their `type`.
43398
43414
  */
43399
43415
  type AssetContentInput = AssetContentOptions | Blob;
43400
- /** Options as the client sends them, once a `Blob` or `File` is read as `{ data, type }`. */
43416
+ /**
43417
+ * Options as the client sends them, once a `Blob` or `File` is read as `{ data, type }` and plain
43418
+ * text without a type is `text/plain`.
43419
+ */
43401
43420
  type PreparedSubmitAssetOptions = (SubmitAssetCommonOptions & {
43402
- content: AssetContentOptions;
43421
+ content: PreparedAssetContentOptions;
43403
43422
  }) | (SubmitAssetCommonOptions & {
43404
43423
  url: string;
43405
43424
  }) | (SubmitAssetCommonOptions & {
@@ -43414,7 +43433,7 @@ type PreparedSubmitAssetOptions = (SubmitAssetCommonOptions & {
43414
43433
  });
43415
43434
  /** What `assets.create` and `assets.classify` take: content, a URL or a multipart part. */
43416
43435
  type SubmitAssetOptions = PreparedSubmitAssetOptions | (SubmitAssetCommonOptions & {
43417
- content: Blob;
43436
+ content: AssetContentInput;
43418
43437
  });
43419
43438
  interface MultipartUploadOptions extends SubmitAssetCommonOptions {
43420
43439
  part: CreateMultipartUploadPartOptions;