calmlens 0.21.0 → 0.22.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 (79) hide show
  1. package/README.md +3 -2
  2. package/bin/calmlens.js +571 -67
  3. package/{esm/BrowserUpload-D-NnAN7g.d.ts → cjs/BrowserUpload-BWjZ9ntu.d.ts} +2 -2
  4. package/cjs/{BrowserUpload-CeSwiMo5.js → BrowserUpload-Bwlib4Zc.js} +1 -1
  5. package/{esm/CalmLensAppClient-gG16T2py.d.ts → cjs/CalmLensAppClient-BaW3ddUR.d.ts} +1 -1
  6. package/cjs/{CalmLensAppClient-0UVCuNqW.js → CalmLensAppClient-DUYMo9PZ.js} +3 -3
  7. package/cjs/{CalmLensOptionKeys-CYY6elxg.js → CalmLensOptionKeys-YvgV995V.js} +139 -31
  8. package/cjs/{CalmLensServerClient-nfu6_YEW.js → CalmLensServerClient-3N-gdsxC.js} +61 -4
  9. package/cjs/{CalmLensServerClient-BHx3x_nZ.d.ts → CalmLensServerClient-BKzn8zmp.d.ts} +38 -2
  10. package/cjs/{CalmLensTypes-CUB0YYVz.d.ts → CalmLensTypes-BDKwThbO.d.ts} +612 -53
  11. package/{esm/Core-C82YmjjX.d.ts → cjs/Core-C33pkBmf.d.ts} +7 -4
  12. package/cjs/{Core-Dc3cteU7.js → Core-Cm5Z1oJ9.js} +9 -6
  13. package/cjs/{ModerationContextLimits-BxOmeSqq.js → ModerationContextLimits-ud1xpZRK.js} +61 -2
  14. package/cjs/{ReactUpload-BK2O3dnK.js → ReactUpload-DQ0BYISX.js} +1 -1
  15. package/cjs/{ReactUpload-DiiXfKvj.d.ts → ReactUpload-DhF8mm51.d.ts} +1 -1
  16. package/cjs/{TestTriggers-BTyXtX0Q-ATuFDhLX.js → TestTriggers-D29T_R0M-D6Bu-Mln.js} +16 -16
  17. package/cjs/{UploadController-DLyiLDTB.js → UploadController-l8fZM2qT.js} +2 -2
  18. package/cjs/{WebhookPayload-BLT2y_Jy.d.ts → WebhookPayload-Dt6DttS0.d.ts} +28 -1
  19. package/cjs/app.d.ts +5 -5
  20. package/cjs/app.js +2 -2
  21. package/cjs/elements.d.ts +4 -4
  22. package/cjs/elements.js +4 -4
  23. package/{esm/index-CKRgjV16.d.ts → cjs/index-Bde1wjiw.d.ts} +2 -2
  24. package/cjs/index.d.ts +4 -4
  25. package/cjs/index.js +1 -1
  26. package/cjs/react-native.d.ts +2 -2
  27. package/cjs/react-native.js +4 -4
  28. package/cjs/react.d.ts +3 -3
  29. package/cjs/react.js +5 -5
  30. package/cjs/server.d.ts +5 -5
  31. package/cjs/server.js +2 -2
  32. package/cjs/test-inputs.js +13 -13
  33. package/cjs/testing.d.ts +10 -6
  34. package/cjs/testing.js +332 -54
  35. package/cjs/{ui-CZ8exACq.js → ui-BRA4HQ8r.js} +3 -3
  36. package/cjs/{ui-CTBUxnVp.d.ts → ui-YQuvbidU.d.ts} +2 -2
  37. package/cjs/ui.d.ts +2 -2
  38. package/cjs/ui.js +3 -3
  39. package/cjs/vue.d.ts +5 -5
  40. package/cjs/vue.js +4 -4
  41. package/{cjs/BrowserUpload-D-NnAN7g.d.ts → esm/BrowserUpload-BWjZ9ntu.d.ts} +2 -2
  42. package/esm/{BrowserUpload-i9OhCzMJ.js → BrowserUpload-GRZVB0G_.js} +1 -1
  43. package/esm/{CalmLensAppClient-CK4_Py0c.js → CalmLensAppClient-B5QIJ6KS.js} +3 -3
  44. package/{cjs/CalmLensAppClient-gG16T2py.d.ts → esm/CalmLensAppClient-BaW3ddUR.d.ts} +1 -1
  45. package/esm/{CalmLensOptionKeys-BGZlIsT2.js → CalmLensOptionKeys-BG7Qrh8-.js} +139 -31
  46. package/esm/{CalmLensServerClient-BHx3x_nZ.d.ts → CalmLensServerClient-BKzn8zmp.d.ts} +38 -2
  47. package/esm/{CalmLensServerClient-dAQUcDWb.js → CalmLensServerClient-bRUAebi-.js} +61 -4
  48. package/esm/{CalmLensTypes-CUB0YYVz.d.ts → CalmLensTypes-BDKwThbO.d.ts} +612 -53
  49. package/esm/{Core-BxeIud_S.js → Core-BvQe4moS.js} +9 -6
  50. package/{cjs/Core-C82YmjjX.d.ts → esm/Core-C33pkBmf.d.ts} +7 -4
  51. package/esm/{ModerationContextLimits-B6_RalCQ.js → ModerationContextLimits-CrxSnVZ3.js} +61 -2
  52. package/esm/{ReactUpload-DxwVqfX1.js → ReactUpload-BMO8saxT.js} +1 -1
  53. package/esm/{ReactUpload-DiiXfKvj.d.ts → ReactUpload-DhF8mm51.d.ts} +1 -1
  54. package/esm/{TestTriggers-BTyXtX0Q-GRB9jQwo.js → TestTriggers-D29T_R0M-Ztc74ucs.js} +16 -16
  55. package/esm/{UploadController-D9Z-h00Q.js → UploadController-DnJrWiE4.js} +2 -2
  56. package/esm/{WebhookPayload-BLT2y_Jy.d.ts → WebhookPayload-Dt6DttS0.d.ts} +28 -1
  57. package/esm/app.d.ts +5 -5
  58. package/esm/app.js +2 -2
  59. package/esm/elements.d.ts +4 -4
  60. package/esm/elements.js +4 -4
  61. package/{cjs/index-CKRgjV16.d.ts → esm/index-Bde1wjiw.d.ts} +2 -2
  62. package/esm/index.d.ts +4 -4
  63. package/esm/index.js +1 -1
  64. package/esm/react-native.d.ts +2 -2
  65. package/esm/react-native.js +4 -4
  66. package/esm/react.d.ts +3 -3
  67. package/esm/react.js +5 -5
  68. package/esm/server.d.ts +5 -5
  69. package/esm/server.js +2 -2
  70. package/esm/test-inputs.js +1 -1
  71. package/esm/testing.d.ts +10 -6
  72. package/esm/testing.js +326 -48
  73. package/esm/{ui-CTBUxnVp.d.ts → ui-YQuvbidU.d.ts} +2 -2
  74. package/esm/{ui-Cr7s6JHm.js → ui-heryDd6g.js} +3 -3
  75. package/esm/ui.d.ts +2 -2
  76. package/esm/ui.js +3 -3
  77. package/esm/vue.d.ts +5 -5
  78. package/esm/vue.js +4 -4
  79. package/package.json +2 -2
package/esm/testing.js CHANGED
@@ -1,10 +1,10 @@
1
- import { A as getRejectedUploadMimeTypeError, B as invalidArgument, H as API_ERROR_CODES, N as sleep, O as MAX_IMAGE_UPLOAD_BYTES, R as CalmLensError, S as validateAppClientOptions, T as validateServerClientOptions, U as API_ERROR_DEFINITIONS, V as invalidConfig, _ as randomUuid, f as checkTransformOptions, h as parseTransformSelector, j as normalizeUploadMimeType, m as isAcceptedUploadMimeType, r as selectModerationContextItems, z as SDK_ERROR_CODES } from "./ModerationContextLimits-B6_RalCQ.js";
2
- import { a as WEBHOOK_TIMESTAMP_HEADER, f as signUploadTokenWithApiKey, m as stringifyJsonCanonical, n as WEBHOOK_DELIVERY_HEADER, p as decodeUploadToken, r as WEBHOOK_SIGNATURE_HEADER, t as CalmLensServerClient } from "./CalmLensServerClient-dAQUcDWb.js";
3
- import { a as MOCK_HOOKS, g as validateAssetPayload, h as assetToData, m as assetDataToUint8Array } from "./CalmLensOptionKeys-BGZlIsT2.js";
1
+ import { A as getRejectedUploadMimeTypeError, B as invalidArgument, H as API_ERROR_CODES, N as sleep, O as MAX_IMAGE_UPLOAD_BYTES, R as CalmLensError, S as validateAppClientOptions, T as validateServerClientOptions, U as API_ERROR_DEFINITIONS, V as invalidConfig, _ as randomUuid, f as checkTransformOptions, h as parseTransformSelector, j as normalizeUploadMimeType, m as isAcceptedUploadMimeType, r as selectModerationContextItems, z as SDK_ERROR_CODES } from "./ModerationContextLimits-CrxSnVZ3.js";
2
+ import { a as WEBHOOK_TIMESTAMP_HEADER, f as signUploadTokenWithApiKey, m as stringifyJsonCanonical, n as WEBHOOK_DELIVERY_HEADER, p as decodeUploadToken, r as WEBHOOK_SIGNATURE_HEADER, t as CalmLensServerClient } from "./CalmLensServerClient-bRUAebi-.js";
3
+ import { a as MOCK_HOOKS, g as validateAssetPayload, h as assetToData, m as assetDataToUint8Array } from "./CalmLensOptionKeys-BG7Qrh8-.js";
4
4
  import { t as hmacSha256Hex } from "./CryptoUtils-B_x8lMIx-DhuWGzqn.js";
5
- import { t as CalmLensAppClient } from "./CalmLensAppClient-CK4_Py0c.js";
6
- import { a as placeholderHashToDataURL, r as isFileAccepted } from "./UploadController-D9Z-h00Q.js";
7
- import { d as getTestInputTag, m as CLASSIFICATION_CATEGORIES } from "./TestTriggers-BTyXtX0Q-GRB9jQwo.js";
5
+ import { t as CalmLensAppClient } from "./CalmLensAppClient-B5QIJ6KS.js";
6
+ import { a as placeholderHashToDataURL, r as isFileAccepted } from "./UploadController-DnJrWiE4.js";
7
+ import { d as getTestInputTag, m as CLASSIFICATION_CATEGORIES } from "./TestTriggers-D29T_R0M-Ztc74ucs.js";
8
8
  import * as zod from "zod";
9
9
  // src/contract/MediaTestTriggers.js
10
10
  const MEDIA_TEST_SIGNALS = [...CLASSIFICATION_CATEGORIES, "violence.graphic"];
@@ -7987,7 +7987,7 @@ const EXAMPLE_IDS = {
7987
7987
  * across the packages that build records from plain strings).
7988
7988
  */
7989
7989
  const idField = (prefix) => zod.string().regex(idPattern(prefix), { message: `Must be a valid ID: "${prefix}_" followed by 20 letters or digits` }).meta({ examples: [EXAMPLE_IDS[prefix]] });
7990
- // src/contract/Permissions-BqpmE0Qa.js
7990
+ // src/contract/Permissions-DPNlE8m-.js
7991
7991
  const ACTION_SCHEMA = zod.enum([
7992
7992
  "assets:read",
7993
7993
  "assets:download",
@@ -8044,10 +8044,13 @@ const GRANT_SCHEMA = zod.object({
8044
8044
  const GRANTS_SCHEMA = zod.array(GRANT_SCHEMA).max(100);
8045
8045
  zod.enum([
8046
8046
  "admin",
8047
+ "configurator",
8047
8048
  "editor",
8048
8049
  "viewer",
8049
8050
  "custom"
8050
8051
  ]);
8052
+ [...ACTION_SCHEMA.options.filter((a) => !isProjectAction(a))];
8053
+ [...ACTION_SCHEMA.options.filter((a) => !isProjectAction(a))];
8051
8054
  const permits = (grants, action, folderId, folders) => grants.some((grant) => {
8052
8055
  if (![action, ...actionsImplying(action)].some((held) => grant.actions.includes(held))) return false;
8053
8056
  if (grant.folderId === null) return true;
@@ -8353,6 +8356,8 @@ var MockDecision = class {
8353
8356
  action: action(score)
8354
8357
  }])),
8355
8358
  explanationComplete: true,
8359
+ policy: null,
8360
+ pendingReview: null,
8356
8361
  source: "policy",
8357
8362
  rule: null,
8358
8363
  automatedStatus: status,
@@ -9143,7 +9148,16 @@ const MOCK_OPERATIONS = [
9143
9148
  "lenses.update",
9144
9149
  "lenses.delete",
9145
9150
  "ensureLens",
9146
- "ensureLenses"
9151
+ "ensureLenses",
9152
+ "uploadPresets.list",
9153
+ "uploadPresets.iterate",
9154
+ "uploadPresets.ensure",
9155
+ "uploadPresets.delete",
9156
+ "projectSettings.get",
9157
+ "projectSettings.update",
9158
+ "metadataFields.list",
9159
+ "metadataFields.ensure",
9160
+ "metadataFields.delete"
9147
9161
  ];
9148
9162
  const MAX_PAGE_SIZE = 100;
9149
9163
  const MAX_DECISION_NOTE_LENGTH = 1499;
@@ -9226,7 +9240,8 @@ const mockPlaceholderPng = (thumbhash) => Uint8Array.from(atob(placeholderHashTo
9226
9240
  const NO_RENDERING = {
9227
9241
  rendered: null,
9228
9242
  preview: null,
9229
- hls: null
9243
+ hls: null,
9244
+ hlsStatus: null
9230
9245
  };
9231
9246
  /** The size of the waveform the API makes as an audio asset's preview. */
9232
9247
  const WAVEFORM_SIZE = {
@@ -9284,7 +9299,8 @@ const mockRendering = (asset, processed) => {
9284
9299
  ...unsized
9285
9300
  },
9286
9301
  preview: preview(unsized),
9287
- hls: null
9302
+ hls: null,
9303
+ hlsStatus: null
9288
9304
  };
9289
9305
  case "website": return {
9290
9306
  rendered: {
@@ -9293,7 +9309,8 @@ const mockRendering = (asset, processed) => {
9293
9309
  ...unsized
9294
9310
  },
9295
9311
  preview: preview(unsized),
9296
- hls: null
9312
+ hls: null,
9313
+ hlsStatus: null
9297
9314
  };
9298
9315
  case "multimedia-document":
9299
9316
  if (SPREADSHEET_MIME_TYPES.includes(mimeType)) return NO_RENDERING;
@@ -9304,7 +9321,8 @@ const mockRendering = (asset, processed) => {
9304
9321
  ...unsized
9305
9322
  },
9306
9323
  preview: processed ? preview(unsized) : null,
9307
- hls: null
9324
+ hls: null,
9325
+ hlsStatus: null
9308
9326
  };
9309
9327
  case "video": return {
9310
9328
  rendered: {
@@ -9313,7 +9331,8 @@ const mockRendering = (asset, processed) => {
9313
9331
  ...unsized
9314
9332
  },
9315
9333
  preview: null,
9316
- hls: null
9334
+ hls: null,
9335
+ hlsStatus: null
9317
9336
  };
9318
9337
  case "audio": return {
9319
9338
  rendered: {
@@ -9323,7 +9342,8 @@ const mockRendering = (asset, processed) => {
9323
9342
  ...processed && { peaks: [] }
9324
9343
  },
9325
9344
  preview: processed ? preview(WAVEFORM_SIZE) : null,
9326
- hls: null
9345
+ hls: null,
9346
+ hlsStatus: null
9327
9347
  };
9328
9348
  default: return NO_RENDERING;
9329
9349
  }
@@ -9382,6 +9402,74 @@ const invalidField = (code, path) => new ApiFailure(400, API_ERROR_CODES.INVALID
9382
9402
  message: `Invalid ${path}`,
9383
9403
  code
9384
9404
  }] });
9405
+ /** The asset fields an upload carries in its body; the API refuses them in the query string. */
9406
+ const UPLOAD_OPTION_KEYS = [
9407
+ "name",
9408
+ "description",
9409
+ "processingOptions",
9410
+ "visibility",
9411
+ "metadata",
9412
+ "tags",
9413
+ "authorId",
9414
+ "context",
9415
+ "externalId",
9416
+ "externalUrl",
9417
+ "folderId",
9418
+ "uploadPresetId"
9419
+ ];
9420
+ const indexOfBytes = (haystack, needle, from = 0) => {
9421
+ for (let index = haystack.indexOf(needle[0], from); index !== -1;) {
9422
+ if (index + needle.length > haystack.length) return -1;
9423
+ let offset = 1;
9424
+ while (offset < needle.length && haystack[index + offset] === needle[offset]) offset++;
9425
+ if (offset === needle.length) return index;
9426
+ index = haystack.indexOf(needle[0], index + 1);
9427
+ }
9428
+ return -1;
9429
+ };
9430
+ /**
9431
+ * Reads a raw upload's `multipart/form-data` body like the API: an `options` part, then a `file`
9432
+ * part, then the closing boundary. Anything else is refused.
9433
+ */
9434
+ const readUploadForm = (request) => {
9435
+ const contentType = request.headers.get("content-type") ?? "";
9436
+ if (contentType.split(";")[0].trim().toLowerCase() !== "multipart/form-data") throw new ApiFailure(415, API_ERROR_CODES.UNSUPPORTED_CONTENT_TYPE, "Send a raw upload as multipart/form-data: an options part, then a file part.", { contentType: contentType.split(";")[0].trim() || null });
9437
+ const boundary = /;\s*boundary=(?:"([^"]+)"|([^;\s]+))/i.exec(contentType);
9438
+ const invalid = (message) => fail(API_ERROR_CODES.INVALID_UPLOAD_PAYLOAD, { message });
9439
+ if (!boundary) throw invalid("The multipart/form-data Content-Type needs a boundary");
9440
+ const encoder = new TextEncoder();
9441
+ const delimiter = encoder.encode(`\r\n--${boundary[1] ?? boundary[2]}`);
9442
+ const body = new Uint8Array(2 + request.bytes.length);
9443
+ body.set(encoder.encode("\r\n"));
9444
+ body.set(request.bytes, 2);
9445
+ const parts = [];
9446
+ let at = indexOfBytes(body, delimiter);
9447
+ while (at !== -1) {
9448
+ const start = at + delimiter.length;
9449
+ if (body[start] === 45 && body[start + 1] === 45) break;
9450
+ const headerEnd = indexOfBytes(body, encoder.encode("\r\n\r\n"), start);
9451
+ const next = headerEnd === -1 ? -1 : indexOfBytes(body, delimiter, headerEnd + 4);
9452
+ if (next === -1) throw invalid("The upload body ended before its closing boundary");
9453
+ const headers = new TextDecoder().decode(body.slice(start, headerEnd));
9454
+ const name = /content-disposition:\s*form-data\s*;[^\r\n]*?\bname="([^"]*)"/i.exec(headers)?.[1];
9455
+ parts.push({
9456
+ name,
9457
+ content: body.slice(headerEnd + 4, next)
9458
+ });
9459
+ at = next;
9460
+ }
9461
+ if (at === -1) throw invalid("The upload body ended before its closing boundary");
9462
+ if (parts.length !== 2 || parts[0].name !== "options" || parts[1].name !== "file") throw invalid("The upload form must hold an options part, then a file part");
9463
+ return {
9464
+ options: new TextDecoder().decode(parts[0].content),
9465
+ bytes: parts[1].content
9466
+ };
9467
+ };
9468
+ /** A request that names asset fields in its query, which the API refuses. */
9469
+ const assertNoUploadOptionsInQuery = (query) => {
9470
+ const fields = UPLOAD_OPTION_KEYS.filter((key) => query.has(key));
9471
+ if (fields.length) throw fail(API_ERROR_CODES.UPLOAD_OPTIONS_IN_QUERY, { details: { fields } });
9472
+ };
9385
9473
  /**
9386
9474
  * Refuses `metadata` the API's schema refuses (METADATA_ITEM_SCHEMA): it is `null` or a list of
9387
9475
  * `{ id, value }` objects with a string `id` and any JSON `value`.
@@ -9439,6 +9527,9 @@ const operationsOf = (request) => {
9439
9527
  case "folders": return method === "GET" ? ["folders.list", "folders.iterate"] : ["folders.create"];
9440
9528
  case "hash-lists": return method === "GET" ? ["hashLists.list", "hashLists.iterate"] : ["hashLists.create"];
9441
9529
  case "policy": return method === "GET" ? ["policies.retrieveAssigned"] : ["policies.assign"];
9530
+ case "upload-presets": return method === "GET" ? ["uploadPresets.list", "uploadPresets.iterate"] : ["uploadPresets.ensure"];
9531
+ case "settings": return method === "GET" ? ["projectSettings.get"] : ["projectSettings.update"];
9532
+ case "metadata-fields": return method === "GET" ? ["metadataFields.list"] : ["metadataFields.ensure"];
9442
9533
  case "assets/search": return ["assets.search"];
9443
9534
  case "assets/batch": return ["assets.batch"];
9444
9535
  case "signed-asset-urls": return ["cdn.signAssetUrl"];
@@ -9448,6 +9539,7 @@ const operationsOf = (request) => {
9448
9539
  return isTextUpload(request) ? ["assets.classify", "text.classify"] : ["assets.classify"];
9449
9540
  }
9450
9541
  if (segments[2] === "assets" && segments[4] === "timeline" && segments.length === 5) return ["assets.listTimeline", "assets.iterateTimeline"];
9542
+ if (segments[2] === "metadata-fields" && segments.length === 4) return ["metadataFields.delete"];
9451
9543
  return [];
9452
9544
  }
9453
9545
  if (root === "policies") {
@@ -9459,6 +9551,7 @@ const operationsOf = (request) => {
9459
9551
  return method === "GET" ? ["policies.retrieve"] : method === "PATCH" ? ["policies.update"] : ["policies.delete"];
9460
9552
  }
9461
9553
  if (root === "lenses" && segments[1] !== void 0) return method === "GET" ? ["lenses.retrieve"] : method === "PATCH" ? ["lenses.update"] : ["lenses.delete"];
9554
+ if (root === "upload-presets" && segments.length === 2) return ["uploadPresets.delete"];
9462
9555
  if (root === "upload-presets") {
9463
9556
  if (segments[3] === void 0) return [query.get("wait") === "false" ? "assets.create" : "assets.classify"];
9464
9557
  return segments[4] === "part" ? ["assets.uploadPart"] : ["assets.retrieve"];
@@ -9487,7 +9580,15 @@ const operationsOf = (request) => {
9487
9580
  }
9488
9581
  return [];
9489
9582
  };
9490
- const isTextUpload = (request) => request.headers.get("x-calmlens-upload") === "content" && request.headers.get("content-type") === "text/plain";
9583
+ /** A plain-text upload: the SDKs send text as a JSON body with `content.plainText`. */
9584
+ const isTextUpload = (request) => {
9585
+ if (request.headers.get("x-calmlens-upload")) return false;
9586
+ try {
9587
+ return typeof JSON.parse(new TextDecoder().decode(request.bytes))?.content?.plainText === "string";
9588
+ } catch {
9589
+ return false;
9590
+ }
9591
+ };
9491
9592
  /** Like the API: a new folder is 201 Created, a queued batch 202 Accepted, everything else 200. */
9492
9593
  const SUCCESS_STATUS = {
9493
9594
  "folders.create": 201,
@@ -9531,6 +9632,10 @@ var MockCalmLensApi = class {
9531
9632
  this.hashLists = /* @__PURE__ */ new Map();
9532
9633
  this.hashListEntries = /* @__PURE__ */ new Map();
9533
9634
  this.pageFailure = (code, path) => code === "cursor/invalid" ? fail(API_ERROR_CODES.INVALID_CURSOR) : invalidField(code, path ?? "pageSize");
9635
+ this.configuredPresets = /* @__PURE__ */ new Map();
9636
+ this.settingsRevision = 1;
9637
+ this.projectSettingsValues = {};
9638
+ this.metadataFieldList = [];
9534
9639
  this.options = options;
9535
9640
  this.projectId = options.projectId;
9536
9641
  this.apiKey = options.apiKey;
@@ -9772,9 +9877,20 @@ var MockCalmLensApi = class {
9772
9877
  }
9773
9878
  return failure;
9774
9879
  }
9775
- describeBody({ bytes, headers }) {
9880
+ describeBody(request) {
9881
+ const { bytes, headers } = request;
9776
9882
  if (bytes.byteLength === 0) return void 0;
9777
9883
  const type = headers.get("content-type") ?? "";
9884
+ if (type.startsWith("multipart/form-data")) try {
9885
+ const form = readUploadForm(request);
9886
+ const file = request.query.get("contentType") ?? "";
9887
+ return {
9888
+ options: JSON.parse(form.options),
9889
+ file: file.startsWith("text/") ? new TextDecoder().decode(form.bytes) : form.bytes.slice()
9890
+ };
9891
+ } catch {
9892
+ return bytes.slice();
9893
+ }
9778
9894
  const text = () => new TextDecoder().decode(bytes);
9779
9895
  if (type === "application/json") try {
9780
9896
  return JSON.parse(text());
@@ -9816,13 +9932,20 @@ var MockCalmLensApi = class {
9816
9932
  if (!(request.segments[0] === "upload-presets") && headers.get("x-api-key") !== this.apiKey) return this.failureResponse(fail(API_ERROR_CODES.INVALID_API_KEY), url);
9817
9933
  const key = headers.get("idempotency-key")?.replace(/^[\t\n\r ]+|[\t\n\r ]+$/g, "");
9818
9934
  const upload = headers.get("x-calmlens-upload");
9935
+ const contentType = headers.get("content-type");
9936
+ const isForm = !!upload && /^multipart\/form-data\b/i.test(contentType ?? "");
9937
+ let formOptions;
9938
+ if (isForm && request.segments.at(-1) !== "part") try {
9939
+ formOptions = readUploadForm(request).options;
9940
+ } catch {}
9819
9941
  const fingerprint = JSON.stringify([
9820
9942
  request.method,
9821
9943
  request.segments,
9822
9944
  [...request.query].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0),
9823
- headers.get("content-type"),
9945
+ isForm ? "multipart/form-data" : contentType,
9824
9946
  upload,
9825
- upload ? request.bytes.byteLength : new TextDecoder().decode(request.bytes)
9947
+ upload ? request.bytes.byteLength : new TextDecoder().decode(request.bytes),
9948
+ formOptions ?? null
9826
9949
  ]);
9827
9950
  if (key !== void 0) {
9828
9951
  if (!isValidIdempotencyKey(key)) return this.failureResponse(fail(API_ERROR_CODES.INVALID_IDEMPOTENCY_KEY), url);
@@ -9873,8 +9996,17 @@ var MockCalmLensApi = class {
9873
9996
  case "POST lenses": return [201, this.createLens(this.json(request))];
9874
9997
  case "GET policy": return [200, this.toPolicy(this.findPolicy(this.ensurePolicies()))];
9875
9998
  case "PUT policy": return [200, this.assignPolicy(this.json(request))];
9999
+ case "GET upload-presets": return [200, this.listUploadPresets(request.query)];
10000
+ case "PUT upload-presets": return [200, this.ensureUploadPresets(this.json(request))];
10001
+ case "GET settings": return [200, this.toProjectSettings()];
10002
+ case "PUT settings": return [200, this.updateProjectSettings(this.json(request))];
10003
+ case "GET metadata-fields": return [200, this.toMetadataFields()];
10004
+ case "PUT metadata-fields": return [200, this.ensureMetadataFields(this.json(request))];
9876
10005
  }
9877
10006
  const [, , collection, itemId, itemAction, ...more] = segments;
10007
+ if (collection === "metadata-fields" && itemId !== void 0 && itemAction === void 0) {
10008
+ if (method === "DELETE") return [200, this.deleteMetadataField(itemId, request.query)];
10009
+ }
9878
10010
  if (collection === "assets" && itemId !== void 0 && itemAction === "timeline" && more.length === 0 && method === "GET") return [200, await this.listTimeline(itemId, request.query)];
9879
10011
  }
9880
10012
  if (root === "policies" && rest.length === 0) {
@@ -9895,6 +10027,9 @@ var MockCalmLensApi = class {
9895
10027
  case "PATCH": return [200, this.updateLens(id, this.json(request))];
9896
10028
  case "DELETE": return [200, this.deleteLens(id)];
9897
10029
  }
10030
+ if (root === "upload-presets" && id !== void 0 && action === void 0) {
10031
+ if (method === "DELETE") return [200, this.deleteUploadPreset(id)];
10032
+ }
9898
10033
  if (root === "upload-presets" && id !== void 0 && action === "assets") return [200, await this.presetRoute(request, id, rest, session)];
9899
10034
  if (root === "assets" && id !== void 0 && rest.length === 0) switch (`${method} ${action ?? ""}`) {
9900
10035
  case "GET ": return [200, await this.findOwnAsset(id)];
@@ -10450,42 +10585,49 @@ var MockCalmLensApi = class {
10450
10585
  await this.databaseStorage.deleteAsset(id);
10451
10586
  }
10452
10587
  }
10453
- /** The upload fields of `POST .../assets`: raw uploads carry them in the query. */
10588
+ /**
10589
+ * The upload fields of `POST .../assets`, from the JSON body (text and URLs) or an upload form's
10590
+ * options (files). Like the API, asset fields in the query are refused.
10591
+ */
10454
10592
  uploadFields(request) {
10593
+ const { query } = request;
10594
+ assertNoUploadOptionsInQuery(query);
10455
10595
  const upload = request.headers.get("x-calmlens-upload");
10456
10596
  if (upload !== "content" && upload !== "part") {
10457
10597
  const body = this.json(request);
10458
10598
  checkMetadata(body.metadata);
10459
- return body;
10599
+ const { content, part, sizeInBytes: _size, totalSizeInBytes, ...fields } = body;
10600
+ const text = content ?? part;
10601
+ if (text === void 0) return fields;
10602
+ if (typeof text.plainText !== "string" || typeof text.type !== "string") throw invalidField("validation/invalid-type", content ? "content" : "part");
10603
+ return {
10604
+ ...fields,
10605
+ contentType: text.type,
10606
+ bytes: new TextEncoder().encode(text.plainText),
10607
+ part: part ? {
10608
+ partNumber: typeof part.partNumber === "number" ? part.partNumber : 1,
10609
+ isFinal: part.isFinal === true,
10610
+ totalSizeInBytes: typeof totalSizeInBytes === "number" ? totalSizeInBytes : void 0
10611
+ } : void 0
10612
+ };
10460
10613
  }
10461
- const { query } = request;
10462
- const text = (name) => query.get(name) ?? void 0;
10463
- const parsed = (name) => {
10464
- const raw = query.get(name);
10465
- if (raw === null) return void 0;
10466
- try {
10467
- return JSON.parse(raw);
10468
- } catch {
10469
- throw invalidField("validation/invalid-value", name);
10470
- }
10471
- };
10614
+ const form = readUploadForm(request);
10615
+ let options;
10616
+ try {
10617
+ options = JSON.parse(form.options);
10618
+ } catch {
10619
+ throw fail(API_ERROR_CODES.INVALID_UPLOAD_PAYLOAD, { message: "The options part must be a JSON object with the asset's fields" });
10620
+ }
10621
+ if (!options || typeof options !== "object" || Array.isArray(options)) throw fail(API_ERROR_CODES.INVALID_UPLOAD_PAYLOAD, { message: "The options part must be a JSON object with the asset's fields" });
10622
+ const unknown = Object.keys(options).find((key) => !UPLOAD_OPTION_KEYS.includes(key));
10623
+ if (unknown !== void 0) throw invalidField("validation/unknown-field", unknown);
10624
+ if (typeof options.name !== "string") throw invalidField("validation/invalid-type", "name");
10625
+ checkMetadata(options.metadata);
10472
10626
  const total = query.get("totalSizeInBytes");
10473
- checkMetadata(parsed("metadata"));
10474
10627
  return {
10475
- name: query.get("name") ?? "",
10476
- description: text("description"),
10477
- processingOptions: parsed("processingOptions"),
10478
- visibility: text("visibility"),
10479
- metadata: parsed("metadata"),
10480
- tags: parsed("tags"),
10481
- authorId: text("authorId"),
10482
- context: parsed("context"),
10483
- externalId: text("externalId"),
10484
- externalUrl: text("externalUrl"),
10485
- folderId: text("folderId"),
10486
- uploadPresetId: text("uploadPresetId"),
10487
- contentType: query.get("contentType") ?? request.headers.get("content-type") ?? "",
10488
- bytes: request.bytes,
10628
+ ...options,
10629
+ contentType: query.get("contentType") ?? "",
10630
+ bytes: form.bytes,
10489
10631
  part: upload === "part" ? {
10490
10632
  partNumber: this.integer(query, "partNumber", 1),
10491
10633
  isFinal: query.get("isFinal") === "true",
@@ -10539,6 +10681,7 @@ var MockCalmLensApi = class {
10539
10681
  id,
10540
10682
  projectId: this.projectId,
10541
10683
  parentId: null,
10684
+ parentPages: [],
10542
10685
  folderId: fields.folderId ?? null,
10543
10686
  uploadPresetId: fields.uploadPresetId ?? null,
10544
10687
  createdAt: now,
@@ -10588,6 +10731,8 @@ var MockCalmLensApi = class {
10588
10731
  status: "pending",
10589
10732
  manualReviews: [],
10590
10733
  automatedStatus: null,
10734
+ policy: null,
10735
+ pendingReview: null,
10591
10736
  source: null,
10592
10737
  rule: null,
10593
10738
  explanationComplete: null,
@@ -11160,6 +11305,139 @@ var MockCalmLensApi = class {
11160
11305
  async assertUniqueFolderName(name, parentId, excludeFolderId) {
11161
11306
  if ((await this.databaseStorage.listFolders?.(this.projectId) ?? []).find((folder) => folder.id !== excludeFolderId && (folder.parentId ?? null) === parentId && folder.name === name)) throw fail(API_ERROR_CODES.DUPLICATE_FOLDER_NAME, { message: `A folder named "${name}" already exists in this location.` });
11162
11307
  }
11308
+ /** A page of the project's upload presets, oldest first unless `sort` says otherwise. */
11309
+ listUploadPresets(query) {
11310
+ return createPage([...this.configuredPresets.values()], this.pageQuery(query), {
11311
+ scope: `upload-presets:${this.projectId}`,
11312
+ fail: this.pageFailure,
11313
+ defaultSort: [{
11314
+ field: "createdAt",
11315
+ direction: "asc"
11316
+ }]
11317
+ });
11318
+ }
11319
+ /** Like the API: every preset's revision and settings are checked before any is saved. */
11320
+ ensureUploadPresets(body) {
11321
+ const definitions = Array.isArray(body.uploadPresets) ? body.uploadPresets : [];
11322
+ if (definitions.length === 0) throw invalidField("validation/too-small", "uploadPresets");
11323
+ return { uploadPresets: definitions.map((definition, index) => {
11324
+ if (typeof definition.key !== "string" || !definition.key) throw invalidField("validation/invalid-type", `uploadPresets.${index}.key`);
11325
+ if (typeof definition.name !== "string" || !definition.name) throw invalidField("validation/invalid-type", `uploadPresets.${index}.name`);
11326
+ const existing = this.configuredPresets.get(definition.key);
11327
+ if (definition.revision !== void 0 && definition.revision !== (existing?.revision ?? 0)) throw fail(API_ERROR_CODES.UPLOAD_PRESET_REVISION_CONFLICT, { details: {
11328
+ key: definition.key,
11329
+ revision: existing?.revision ?? 0
11330
+ } });
11331
+ const list = (value) => Array.isArray(value) && value.length ? [...new Set(value)] : null;
11332
+ const values = {
11333
+ key: definition.key,
11334
+ name: definition.name,
11335
+ access: definition.access ?? "token",
11336
+ enabled: definition.enabled ?? true,
11337
+ allowedContentTypes: list(definition.allowedContentTypes),
11338
+ maxSizeInBytes: definition.maxSizeInBytes ?? null,
11339
+ folderId: definition.folderId ?? null,
11340
+ policyId: definition.policyId ?? null,
11341
+ visibility: definition.visibility ?? "private",
11342
+ processingOptions: definition.processingOptions ?? null,
11343
+ revealDecision: definition.revealDecision ?? false,
11344
+ dailyUploadLimit: definition.dailyUploadLimit ?? null,
11345
+ allowedOrigins: list(definition.allowedOrigins)
11346
+ };
11347
+ if (values.access === "anyone" && !values.dailyUploadLimit) throw fail(API_ERROR_CODES.UPLOAD_PRESET_DAILY_LIMIT_REQUIRED);
11348
+ return {
11349
+ existing,
11350
+ values
11351
+ };
11352
+ }).map(({ existing, values }) => {
11353
+ if (existing) {
11354
+ if (Object.entries(values).every(([key, value]) => stringifyJsonCanonical(value) === stringifyJsonCanonical(existing[key] ?? null))) return existing;
11355
+ }
11356
+ const now = this.now();
11357
+ const preset = {
11358
+ id: existing?.id ?? this.createId("preset"),
11359
+ projectId: this.projectId,
11360
+ createdByUserId: null,
11361
+ ...values,
11362
+ revision: (existing?.revision ?? 0) + 1,
11363
+ createdAt: existing?.createdAt ?? now,
11364
+ updatedAt: now
11365
+ };
11366
+ this.configuredPresets.set(preset.key, preset);
11367
+ return preset;
11368
+ }) };
11369
+ }
11370
+ deleteUploadPreset(uploadPresetId) {
11371
+ const preset = [...this.configuredPresets.values()].find(({ id }) => id === uploadPresetId);
11372
+ if (!preset) throw fail(API_ERROR_CODES.UPLOAD_PRESET_NOT_FOUND);
11373
+ this.configuredPresets.delete(preset.key);
11374
+ return {};
11375
+ }
11376
+ toProjectSettings() {
11377
+ return {
11378
+ projectId: this.projectId,
11379
+ revision: this.settingsRevision,
11380
+ settings: {
11381
+ optOutJurisdictions: [],
11382
+ blockUnmoderatedAssets: true,
11383
+ storeSensitiveMetadata: false,
11384
+ streamingEnabled: false,
11385
+ aiMediaSearchEnabled: false,
11386
+ remoteUrlRule: null,
11387
+ websiteSubmissionsPerMinute: null,
11388
+ ...this.projectSettingsValues,
11389
+ humanReview: {
11390
+ allowedSamplePercent: 0,
11391
+ restrictedSamplePercent: 0,
11392
+ uncertaintyMarginPercent: 0,
11393
+ reviewMissingEvidence: false,
11394
+ ...this.projectSettingsValues.humanReview
11395
+ }
11396
+ }
11397
+ };
11398
+ }
11399
+ checkSettingsRevision(revision) {
11400
+ if (revision !== void 0 && revision !== null && Number(revision) !== this.settingsRevision) throw fail(API_ERROR_CODES.PROJECT_SETTINGS_REVISION_CONFLICT);
11401
+ }
11402
+ /** Replaces the settings: those left out return to their defaults. */
11403
+ updateProjectSettings(body) {
11404
+ this.checkSettingsRevision(body.revision);
11405
+ const settings = body.settings;
11406
+ if (!settings || typeof settings !== "object" || Array.isArray(settings)) throw invalidField("validation/invalid-type", "settings");
11407
+ const before = stringifyJsonCanonical(this.toProjectSettings().settings);
11408
+ const previous = this.projectSettingsValues;
11409
+ this.projectSettingsValues = { ...settings };
11410
+ if (stringifyJsonCanonical(this.toProjectSettings().settings) === before) this.projectSettingsValues = previous;
11411
+ else this.settingsRevision += 1;
11412
+ return this.toProjectSettings();
11413
+ }
11414
+ toMetadataFields() {
11415
+ return {
11416
+ projectId: this.projectId,
11417
+ revision: this.settingsRevision,
11418
+ fields: this.metadataFieldList
11419
+ };
11420
+ }
11421
+ /** Creates or replaces fields by ID, keeping the others in order. */
11422
+ ensureMetadataFields(body) {
11423
+ this.checkSettingsRevision(body.revision);
11424
+ const fields = Array.isArray(body.fields) ? body.fields : [];
11425
+ if (fields.length === 0) throw invalidField("validation/too-small", "fields");
11426
+ const byId = new Map(fields.map((field) => [field.id, field]));
11427
+ const merged = [...this.metadataFieldList.map((field) => byId.get(field.id) ?? field), ...fields.filter((field) => !this.metadataFieldList.some(({ id }) => id === field.id))];
11428
+ if (stringifyJsonCanonical(merged) !== stringifyJsonCanonical(this.metadataFieldList)) {
11429
+ this.metadataFieldList = merged;
11430
+ this.settingsRevision += 1;
11431
+ }
11432
+ return this.toMetadataFields();
11433
+ }
11434
+ deleteMetadataField(fieldId, query) {
11435
+ if (!this.metadataFieldList.some(({ id }) => id === fieldId)) throw fail(API_ERROR_CODES.METADATA_FIELD_NOT_FOUND, { details: { fieldId } });
11436
+ this.checkSettingsRevision(query.get("revision") ?? void 0);
11437
+ this.metadataFieldList = this.metadataFieldList.filter(({ id }) => id !== fieldId);
11438
+ this.settingsRevision += 1;
11439
+ return this.toMetadataFields();
11440
+ }
11163
11441
  /** Saves each lens in order, like the API: new ones, or a changed definition. */
11164
11442
  ensureLenses(body) {
11165
11443
  const lenses = Array.isArray(body.lenses) ? body.lenses : [];
@@ -11379,8 +11657,8 @@ var MockCalmLensApi = class {
11379
11657
  const { url, query } = request;
11380
11658
  const isPrivate = asset.visibility !== "public";
11381
11659
  if (isPrivate && !authorised) return this.jsonResponse(404, {
11382
- code: "asset/not-available",
11383
- message: "Asset is not available"
11660
+ code: "asset/not-found",
11661
+ message: "Asset not found"
11384
11662
  }, url);
11385
11663
  let claims = {};
11386
11664
  try {
@@ -1,5 +1,5 @@
1
- import "./CalmLensTypes-CUB0YYVz.js";
2
- import { G as AssetSession, W as AssetOptions, Y as AssetView, at as ImageViewerOptions, ct as TextViewerOptions, ft as WebsiteViewerOptions, it as DocumentViewerOptions, ot as PdfAssetOptions, st as SpreadsheetViewerOptions, ut as ViewerOptions } from "./Core-C82YmjjX.js";
1
+ import "./CalmLensTypes-BDKwThbO.js";
2
+ import { G as AssetSession, W as AssetOptions, Y as AssetView, at as ImageViewerOptions, ct as TextViewerOptions, ft as WebsiteViewerOptions, it as DocumentViewerOptions, ot as PdfAssetOptions, st as SpreadsheetViewerOptions, ut as ViewerOptions } from "./Core-C33pkBmf.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> {
@@ -1,6 +1,6 @@
1
- import { a as appendAssetLocation } from "./ModerationContextLimits-B6_RalCQ.js";
2
- import { a as placeholderHashToDataURL } from "./UploadController-D9Z-h00Q.js";
3
- import "./Core-BxeIud_S.js";
1
+ import { a as appendAssetLocation } from "./ModerationContextLimits-CrxSnVZ3.js";
2
+ import { a as placeholderHashToDataURL } from "./UploadController-DnJrWiE4.js";
3
+ import "./Core-BvQe4moS.js";
4
4
  // src/ui/viewers/PdfLoader.ts
5
5
  let loading;
6
6
  /**
package/esm/ui.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { $ as getAssetViewKey, A as CustomUploadResult, B as AssetDisplay, C as formatMessage, D as resolveMessages, E as getUploadItemOutcome, F as UploadItem, G as AssetSession, H as AssetImageOptions, I as UploadSnapshot, J as AssetVideoOptions, K as AssetSessionState, L as UploadStage, M as UploadController, N as UploadControllerOptions, O as CalmLensUpload, P as UploadFile, Q as getAssetView, R as createUploadController, S as formatBytes, T as getUploadItemMessage, U as AssetImageSource, V as AssetDocumentOptions, W as AssetOptions, X as MediaPlayback, Y as AssetView, Z as getAssetAspectRatio, _ as DEFAULT_MESSAGES, _t as formatViewerMessage, a as ProgressFetchOptions, at as ImageViewerOptions, b as describeUploadItem, c as ICON_ATTRIBUTES, ct as TextViewerOptions, d as AssetDisplayOptions, dt as ViewerTextOptions, et as getPeakHeights, f as AssetEventHandlers, ft as WebsiteViewerOptions, g as CalmLensMessages, gt as ViewerMessages, h as UploaderProps, ht as DEFAULT_VIEWER_MESSAGES, i as CALMLENS_STYLES, it as DocumentViewerOptions, j as UploadClient, k as CustomUploadContext, l as IconName, lt as ViewerAsset, m as UploaderDisplayOptions, mt as isSpreadsheetFormat, n as CalmLensTheme, nt as pickAssetSource, o as createProgressFetch, ot as PdfAssetOptions, p as AssetProps, pt as getAssetViewerKind, q as AssetSpreadsheetOptions, r as resolveTheme, rt as AssetViewerKind, s as ICONS, st as SpreadsheetViewerOptions, t as CALMLENS_THEME, tt as getPlayedPercent, u as ASSET_FILE_ICON_SIZE, ut as ViewerOptions, v as UploadItemView, vt as resolveViewerMessages, w as getDropzoneHint, x as describeUploader, y as UploaderView, z as isFileAccepted } from "./Core-C82YmjjX.js";
2
- import { C as ViewerState, S as AssetViewer, _ as spreadsheetColumnIndex, a as isMountedViewerKind, b as createWebsiteViewer, 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 createDocumentViewer, y as createImageViewer } from "./ui-CTBUxnVp.js";
1
+ import { $ as getAssetViewKey, A as CustomUploadResult, B as AssetDisplay, C as formatMessage, D as resolveMessages, E as getUploadItemOutcome, F as UploadItem, G as AssetSession, H as AssetImageOptions, I as UploadSnapshot, J as AssetVideoOptions, K as AssetSessionState, L as UploadStage, M as UploadController, N as UploadControllerOptions, O as CalmLensUpload, P as UploadFile, Q as getAssetView, R as createUploadController, S as formatBytes, T as getUploadItemMessage, U as AssetImageSource, V as AssetDocumentOptions, W as AssetOptions, X as MediaPlayback, Y as AssetView, Z as getAssetAspectRatio, _ as DEFAULT_MESSAGES, _t as formatViewerMessage, a as ProgressFetchOptions, at as ImageViewerOptions, b as describeUploadItem, c as ICON_ATTRIBUTES, ct as TextViewerOptions, d as AssetDisplayOptions, dt as ViewerTextOptions, et as getPeakHeights, f as AssetEventHandlers, ft as WebsiteViewerOptions, g as CalmLensMessages, gt as ViewerMessages, h as UploaderProps, ht as DEFAULT_VIEWER_MESSAGES, i as CALMLENS_STYLES, it as DocumentViewerOptions, j as UploadClient, k as CustomUploadContext, l as IconName, lt as ViewerAsset, m as UploaderDisplayOptions, mt as isSpreadsheetFormat, n as CalmLensTheme, nt as pickAssetSource, o as createProgressFetch, ot as PdfAssetOptions, p as AssetProps, pt as getAssetViewerKind, q as AssetSpreadsheetOptions, r as resolveTheme, rt as AssetViewerKind, s as ICONS, st as SpreadsheetViewerOptions, t as CALMLENS_THEME, tt as getPlayedPercent, u as ASSET_FILE_ICON_SIZE, ut as ViewerOptions, v as UploadItemView, vt as resolveViewerMessages, w as getDropzoneHint, x as describeUploader, y as UploaderView, z as isFileAccepted } from "./Core-C33pkBmf.js";
2
+ import { C as ViewerState, S as AssetViewer, _ as spreadsheetColumnIndex, a as isMountedViewerKind, b as createWebsiteViewer, 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 createDocumentViewer, y as createImageViewer } from "./ui-YQuvbidU.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 CalmLensTheme, type CalmLensUpload, type CustomUploadContext, type CustomUploadResult, DEFAULT_MESSAGES, DEFAULT_VIEWER_MESSAGES, type DocumentViewerOptions, ICONS, ICON_ATTRIBUTES, type IconName, type ImageViewerOptions, 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, type WebsiteViewerOptions, createDocumentViewer, createImageViewer, createProgressFetch, createSpreadsheetViewer, createTextViewer, createUploadController, createWebsiteViewer, describeUploadItem, describeUploader, formatBytes, formatMessage, formatViewerMessage, getAssetAspectRatio, getAssetView, getAssetViewKey, getAssetViewerKind, getDropzoneHint, getMountedViewerOptions, getPeakHeights, getPlayedPercent, getSpreadsheetPage, getUploadItemMessage, getUploadItemOutcome, isFileAccepted, isMountedViewerKind, isSpreadsheetFormat, loadPdfJs, parseSpreadsheetText, pickAssetSource, resolveMessages, resolveTheme, resolveViewerMessages, spreadsheetColumnIndex };
package/esm/ui.js CHANGED
@@ -1,4 +1,4 @@
1
- import { _ as loadPdfJs, a as ASSET_VIEWERS, c as getSpreadsheetPage, d as createImageViewer, f as createWebsiteViewer, g as resolveViewerMessages, h as formatViewerMessage, i as isMountedViewerKind, l as parseSpreadsheetText, m as DEFAULT_VIEWER_MESSAGES, n as AssetViewerMount, o as createSpreadsheetViewer, p as createDocumentViewer, r as getMountedViewerOptions, s as createTextViewer, t as MediaStreamPlayer, u as spreadsheetColumnIndex } from "./ui-Cr7s6JHm.js";
2
- import { i as createProgressFetch, n as createUploadController, r as isFileAccepted, t as UploadController } from "./UploadController-D9Z-h00Q.js";
3
- import { C as CALMLENS_THEME, E as isSpreadsheetFormat, S as VIEWER_STYLES, T as getAssetViewerKind, _ as getAssetView, a as describeUploadItem, b as getPlayedPercent, c as formatMessage, d as getUploadItemOutcome, f as resolveMessages, g as getAssetAspectRatio, h as AssetSession, i as DEFAULT_MESSAGES, l as getDropzoneHint, m as ICON_ATTRIBUTES, o as describeUploader, p as ICONS, r as ASSET_FILE_ICON_SIZE, s as formatBytes, t as CALMLENS_STYLES, u as getUploadItemMessage, v as getAssetViewKey, w as resolveTheme, x as pickAssetSource, y as getPeakHeights } from "./Core-BxeIud_S.js";
1
+ import { _ as loadPdfJs, a as ASSET_VIEWERS, c as getSpreadsheetPage, d as createImageViewer, f as createWebsiteViewer, g as resolveViewerMessages, h as formatViewerMessage, i as isMountedViewerKind, l as parseSpreadsheetText, m as DEFAULT_VIEWER_MESSAGES, n as AssetViewerMount, o as createSpreadsheetViewer, p as createDocumentViewer, r as getMountedViewerOptions, s as createTextViewer, t as MediaStreamPlayer, u as spreadsheetColumnIndex } from "./ui-heryDd6g.js";
2
+ import { i as createProgressFetch, n as createUploadController, r as isFileAccepted, t as UploadController } from "./UploadController-DnJrWiE4.js";
3
+ import { C as CALMLENS_THEME, E as isSpreadsheetFormat, S as VIEWER_STYLES, T as getAssetViewerKind, _ as getAssetView, a as describeUploadItem, b as getPlayedPercent, c as formatMessage, d as getUploadItemOutcome, f as resolveMessages, g as getAssetAspectRatio, h as AssetSession, i as DEFAULT_MESSAGES, l as getDropzoneHint, m as ICON_ATTRIBUTES, o as describeUploader, p as ICONS, r as ASSET_FILE_ICON_SIZE, s as formatBytes, t as CALMLENS_STYLES, u as getUploadItemMessage, v as getAssetViewKey, w as resolveTheme, x as pickAssetSource, y as getPeakHeights } from "./Core-BvQe4moS.js";
4
4
  export { ASSET_FILE_ICON_SIZE, ASSET_VIEWERS, AssetSession, AssetViewerMount, CALMLENS_STYLES, CALMLENS_THEME, DEFAULT_MESSAGES, DEFAULT_VIEWER_MESSAGES, ICONS, ICON_ATTRIBUTES, MediaStreamPlayer, UploadController, VIEWER_STYLES, createDocumentViewer, createImageViewer, createProgressFetch, createSpreadsheetViewer, createTextViewer, createUploadController, createWebsiteViewer, describeUploadItem, describeUploader, formatBytes, formatMessage, formatViewerMessage, getAssetAspectRatio, getAssetView, getAssetViewKey, getAssetViewerKind, getDropzoneHint, getMountedViewerOptions, getPeakHeights, getPlayedPercent, getSpreadsheetPage, getUploadItemMessage, getUploadItemOutcome, isFileAccepted, isMountedViewerKind, isSpreadsheetFormat, loadPdfJs, parseSpreadsheetText, pickAssetSource, resolveMessages, resolveTheme, resolveViewerMessages, spreadsheetColumnIndex };
package/esm/vue.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { D as CalmLensAppClientOptions, Zt as ViewerClaims, h as AssetModerationStatus, r as AssetAvailability } from "./CalmLensTypes-CUB0YYVz.js";
2
- import "./index-CKRgjV16.js";
3
- import { $ as getAssetViewKey, A as CustomUploadResult, B as AssetDisplay, C as formatMessage, D as resolveMessages, E as getUploadItemOutcome, G as AssetSession, H as AssetImageOptions, J as AssetVideoOptions, K as AssetSessionState, L as UploadStage, M as UploadController, P as UploadFile, Q as getAssetView, S as formatBytes, T as getUploadItemMessage, U as AssetImageSource, V as AssetDocumentOptions, W as AssetOptions, X as MediaPlayback, Y as AssetView, Z as getAssetAspectRatio, _ as DEFAULT_MESSAGES, _t as formatViewerMessage, a as ProgressFetchOptions, at as ImageViewerOptions, b as describeUploadItem, c as ICON_ATTRIBUTES, ct as TextViewerOptions, d as AssetDisplayOptions, dt as ViewerTextOptions, et as getPeakHeights, f as AssetEventHandlers, ft as WebsiteViewerOptions, g as CalmLensMessages, gt as ViewerMessages, ht as DEFAULT_VIEWER_MESSAGES, i as CALMLENS_STYLES, it as DocumentViewerOptions, j as UploadClient, k as CustomUploadContext, l as IconName, lt as ViewerAsset, m as UploaderDisplayOptions, mt as isSpreadsheetFormat, n as CalmLensTheme, nt as pickAssetSource, o as createProgressFetch, ot as PdfAssetOptions, p as AssetProps, pt as getAssetViewerKind, q as AssetSpreadsheetOptions, r as resolveTheme, rt as AssetViewerKind, s as ICONS, st as SpreadsheetViewerOptions, t as CALMLENS_THEME, tt as getPlayedPercent, u as ASSET_FILE_ICON_SIZE, ut as ViewerOptions, v as UploadItemView, vt as resolveViewerMessages, w as getDropzoneHint, x as describeUploader, y as UploaderView, z as isFileAccepted } from "./Core-C82YmjjX.js";
4
- import { a as UploaderProps, i as UploadSnapshot, n as UploadControllerOptions, r as UploadItem, s as createUploadController, t as CalmLensUpload } from "./BrowserUpload-D-NnAN7g.js";
5
- import { C as ViewerState, S as AssetViewer, _ as spreadsheetColumnIndex, a as isMountedViewerKind, b as createWebsiteViewer, 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 createDocumentViewer, y as createImageViewer } from "./ui-CTBUxnVp.js";
1
+ import { D as CalmLensAppClientOptions, h as AssetModerationStatus, r as AssetAvailability, sn as ViewerClaims } from "./CalmLensTypes-BDKwThbO.js";
2
+ import "./index-Bde1wjiw.js";
3
+ import { $ as getAssetViewKey, A as CustomUploadResult, B as AssetDisplay, C as formatMessage, D as resolveMessages, E as getUploadItemOutcome, G as AssetSession, H as AssetImageOptions, J as AssetVideoOptions, K as AssetSessionState, L as UploadStage, M as UploadController, P as UploadFile, Q as getAssetView, S as formatBytes, T as getUploadItemMessage, U as AssetImageSource, V as AssetDocumentOptions, W as AssetOptions, X as MediaPlayback, Y as AssetView, Z as getAssetAspectRatio, _ as DEFAULT_MESSAGES, _t as formatViewerMessage, a as ProgressFetchOptions, at as ImageViewerOptions, b as describeUploadItem, c as ICON_ATTRIBUTES, ct as TextViewerOptions, d as AssetDisplayOptions, dt as ViewerTextOptions, et as getPeakHeights, f as AssetEventHandlers, ft as WebsiteViewerOptions, g as CalmLensMessages, gt as ViewerMessages, ht as DEFAULT_VIEWER_MESSAGES, i as CALMLENS_STYLES, it as DocumentViewerOptions, j as UploadClient, k as CustomUploadContext, l as IconName, lt as ViewerAsset, m as UploaderDisplayOptions, mt as isSpreadsheetFormat, n as CalmLensTheme, nt as pickAssetSource, o as createProgressFetch, ot as PdfAssetOptions, p as AssetProps, pt as getAssetViewerKind, q as AssetSpreadsheetOptions, r as resolveTheme, rt as AssetViewerKind, s as ICONS, st as SpreadsheetViewerOptions, t as CALMLENS_THEME, tt as getPlayedPercent, u as ASSET_FILE_ICON_SIZE, ut as ViewerOptions, v as UploadItemView, vt as resolveViewerMessages, w as getDropzoneHint, x as describeUploader, y as UploaderView, z as isFileAccepted } from "./Core-C33pkBmf.js";
4
+ import { a as UploaderProps, i as UploadSnapshot, n as UploadControllerOptions, r as UploadItem, s as createUploadController, t as CalmLensUpload } from "./BrowserUpload-BWjZ9ntu.js";
5
+ import { C as ViewerState, S as AssetViewer, _ as spreadsheetColumnIndex, a as isMountedViewerKind, b as createWebsiteViewer, 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 createDocumentViewer, y as createImageViewer } from "./ui-YQuvbidU.js";
6
6
  import { MaybeRefOrGetter, PropType, ShallowRef } from "vue";
7
7
  /** Shows an image asset's rendered file, fitted to the element, over its placeholder. */
8
8
  export declare const CalmLensImageViewer: import("vue").DefineComponent<import("vue").ExtractPropTypes<{