calmlens 0.20.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 (110) hide show
  1. package/README.md +15 -10
  2. package/bin/calmlens.js +1848 -679
  3. package/cjs/{BrowserUpload-C07aL9Vq.d.ts → BrowserUpload-BWjZ9ntu.d.ts} +2 -2
  4. package/cjs/{BrowserUpload-CjSHjx3C.js → BrowserUpload-Bwlib4Zc.js} +1 -1
  5. package/cjs/{CalmLensAppClient-DDLojj0P.d.ts → CalmLensAppClient-BaW3ddUR.d.ts} +13 -3
  6. package/cjs/{CalmLensAppClient-NaCxOVlM.js → CalmLensAppClient-DUYMo9PZ.js} +30 -10
  7. package/cjs/{CalmLensOptionKeys-p2QK687A.js → CalmLensOptionKeys-YvgV995V.js} +318 -374
  8. package/cjs/{CalmLensServerClient-BDzTthxE.js → CalmLensServerClient-3N-gdsxC.js} +346 -89
  9. package/cjs/CalmLensServerClient-BKzn8zmp.d.ts +353 -0
  10. package/cjs/{CalmLensTypes-COJbOuiv.d.ts → CalmLensTypes-BDKwThbO.d.ts} +26993 -27187
  11. package/cjs/{Classification-D3SkprrQ-CMnQKW13.d.ts → Classification-Q5zGpR8l-CEWjnE39.d.ts} +731 -607
  12. package/cjs/Core-C33pkBmf.d.ts +826 -0
  13. package/cjs/Core-Cm5Z1oJ9.js +1001 -0
  14. package/cjs/FileIcons-4qSX7DW2.d.ts +67 -0
  15. package/cjs/{ModerationContextLimits-2nIv7Zh3.js → ModerationContextLimits-ud1xpZRK.js} +727 -268
  16. package/cjs/{ReactUpload-BdTRCTGA.js → ReactUpload-DQ0BYISX.js} +1 -1
  17. package/cjs/{ReactUpload-CRJNPB5T.d.ts → ReactUpload-DhF8mm51.d.ts} +1 -1
  18. package/{esm/TestTriggers-D-fwfhEP-hlaP1oW2.d.ts → cjs/TestTriggers-D0pYHbkr-D5T0VdSn.d.ts} +146 -8
  19. package/cjs/{TestTriggers-DbhsNPdg-DjvVuc2h.js → TestTriggers-D29T_R0M-D6Bu-Mln.js} +355 -47
  20. package/cjs/{UploadController-MLVs97Zt.js → UploadController-l8fZM2qT.js} +34 -14
  21. package/{esm/WebhookPayload-DkukERKE.d.ts → cjs/WebhookPayload-Dt6DttS0.d.ts} +120 -86
  22. package/cjs/app.d.ts +6 -7
  23. package/cjs/app.js +4 -3
  24. package/cjs/elements.d.ts +123 -22
  25. package/cjs/elements.js +553 -156
  26. package/cjs/file-icons.d.ts +2 -67
  27. package/cjs/index-Bde1wjiw.d.ts +16 -0
  28. package/cjs/index.d.ts +5 -6
  29. package/cjs/index.js +3 -2
  30. package/cjs/react-native.d.ts +52 -11
  31. package/cjs/react-native.js +231 -99
  32. package/cjs/react.d.ts +42 -9
  33. package/cjs/react.js +381 -118
  34. package/cjs/server.d.ts +48 -7
  35. package/cjs/server.js +7 -3
  36. package/cjs/test-inputs.d.ts +2 -2
  37. package/cjs/test-inputs.js +13 -9
  38. package/cjs/testing.d.ts +29 -15
  39. package/cjs/testing.js +1722 -433
  40. package/cjs/ui-BRA4HQ8r.js +1359 -0
  41. package/cjs/ui-YQuvbidU.d.ts +139 -0
  42. package/cjs/ui.d.ts +3 -2
  43. package/cjs/ui.js +45 -22
  44. package/cjs/vue.d.ts +802 -199
  45. package/cjs/vue.js +359 -127
  46. package/esm/{BrowserUpload-C07aL9Vq.d.ts → BrowserUpload-BWjZ9ntu.d.ts} +2 -2
  47. package/esm/{BrowserUpload-CAVkRotw.js → BrowserUpload-GRZVB0G_.js} +1 -1
  48. package/esm/{CalmLensAppClient-PQ9VBvlW.js → CalmLensAppClient-B5QIJ6KS.js} +30 -10
  49. package/esm/{CalmLensAppClient-DDLojj0P.d.ts → CalmLensAppClient-BaW3ddUR.d.ts} +13 -3
  50. package/esm/{CalmLensOptionKeys-Do2mPP6w.js → CalmLensOptionKeys-BG7Qrh8-.js} +317 -367
  51. package/esm/CalmLensServerClient-BKzn8zmp.d.ts +353 -0
  52. package/esm/{CalmLensServerClient-C_H5aAsV.js → CalmLensServerClient-bRUAebi-.js} +323 -90
  53. package/esm/{CalmLensTypes-COJbOuiv.d.ts → CalmLensTypes-BDKwThbO.d.ts} +26993 -27187
  54. package/esm/{Classification-D3SkprrQ-CMnQKW13.d.ts → Classification-Q5zGpR8l-CEWjnE39.d.ts} +731 -607
  55. package/esm/Core-BvQe4moS.js +846 -0
  56. package/esm/Core-C33pkBmf.d.ts +826 -0
  57. package/esm/FileIcons-4qSX7DW2.d.ts +67 -0
  58. package/esm/{ModerationContextLimits-Chw-AzgL.js → ModerationContextLimits-CrxSnVZ3.js} +682 -253
  59. package/esm/{ReactUpload-CMmL0R5Q.js → ReactUpload-BMO8saxT.js} +1 -1
  60. package/esm/{ReactUpload-CRJNPB5T.d.ts → ReactUpload-DhF8mm51.d.ts} +1 -1
  61. package/{cjs/TestTriggers-D-fwfhEP-hlaP1oW2.d.ts → esm/TestTriggers-D0pYHbkr-D5T0VdSn.d.ts} +146 -8
  62. package/esm/{TestTriggers-DbhsNPdg-CUdrv8Nm.js → TestTriggers-D29T_R0M-Ztc74ucs.js} +332 -48
  63. package/esm/{UploadController-BJZghJpg.js → UploadController-DnJrWiE4.js} +34 -14
  64. package/{cjs/WebhookPayload-DkukERKE.d.ts → esm/WebhookPayload-Dt6DttS0.d.ts} +120 -86
  65. package/esm/app.d.ts +6 -7
  66. package/esm/app.js +3 -3
  67. package/esm/elements.d.ts +123 -22
  68. package/esm/elements.js +497 -128
  69. package/esm/file-icons.d.ts +2 -67
  70. package/esm/index-Bde1wjiw.d.ts +16 -0
  71. package/esm/index.d.ts +5 -6
  72. package/esm/index.js +1 -1
  73. package/esm/react-native.d.ts +52 -11
  74. package/esm/react-native.js +205 -75
  75. package/esm/react.d.ts +42 -9
  76. package/esm/react.js +327 -91
  77. package/esm/server.d.ts +48 -7
  78. package/esm/server.js +3 -3
  79. package/esm/styles.css +142 -22
  80. package/esm/svelte/AssetViewer.svelte +25 -0
  81. package/esm/svelte/CalmLensAsset.svelte +318 -0
  82. package/esm/svelte/CalmLensDocumentViewer.svelte +7 -0
  83. package/esm/svelte/CalmLensImageViewer.svelte +7 -0
  84. package/esm/svelte/CalmLensSpreadsheetViewer.svelte +7 -0
  85. package/esm/svelte/CalmLensTextViewer.svelte +7 -0
  86. package/esm/svelte/CalmLensWebsiteViewer.svelte +7 -0
  87. package/esm/svelte/index.d.ts +29 -6
  88. package/esm/svelte/index.js +7 -2
  89. package/esm/test-inputs.d.ts +2 -2
  90. package/esm/test-inputs.js +1 -1
  91. package/esm/testing.d.ts +29 -15
  92. package/esm/testing.js +1718 -429
  93. package/esm/ui-YQuvbidU.d.ts +139 -0
  94. package/esm/ui-heryDd6g.js +1258 -0
  95. package/esm/ui.d.ts +3 -2
  96. package/esm/ui.js +4 -3
  97. package/esm/vue.d.ts +802 -199
  98. package/esm/vue.js +308 -103
  99. package/package.json +4 -2
  100. package/cjs/CalmLensServerClient-C-jsjn8m.d.ts +0 -259
  101. package/cjs/ModerationContext-9lGm-Mna-CcmbRnOy.d.ts +0 -67
  102. package/cjs/index-DxbJ_Xaa.d.ts +0 -253
  103. package/cjs/ui-BSqPGKrZ.d.ts +0 -539
  104. package/cjs/ui-CX1z2pD9.js +0 -586
  105. package/esm/CalmLensServerClient-C-jsjn8m.d.ts +0 -259
  106. package/esm/ModerationContext-9lGm-Mna-CcmbRnOy.d.ts +0 -67
  107. package/esm/index-DxbJ_Xaa.d.ts +0 -253
  108. package/esm/svelte/CalmLensMedia.svelte +0 -134
  109. package/esm/ui-BSqPGKrZ.d.ts +0 -539
  110. package/esm/ui-CXH7xJpb.js +0 -461
@@ -1,5 +1,5 @@
1
- import { C as validateRequestOptions, F as invalidArgument, I as invalidConfig, N as CalmLensError, P as SDK_ERROR_CODES, S as validateBatchAssetsOptions, T as validateSignedUrlOptions, b as transformSelector, c as DEFAULT_CDN_BASE_URL, d as encodePathSegment, f as getAssetUrl, h as pollForDecision, l as checkOptionKeys, o as isBrowserRuntime, s as isReactNativeRuntime, w as validateServerClientOptions, y as toTextAssetOptions } from "./ModerationContextLimits-Chw-AzgL.js";
2
- import { c as getMockHooks, d as prepareSubmitAssetOptions, f as resolveConnectionOptions, i as CalmLensConnection, l as invalidPayload, n as NULLABLE_OPTION_KEYS, o as expectAsset, p as splitsIntoParts, r as SERVER_OPTION_KEYS, u as newIdempotencyKey } from "./CalmLensOptionKeys-Do2mPP6w.js";
1
+ import { B as invalidArgument, C as validateBatchAssetsOptions, F as isBrowserRuntime, I as isReactNativeRuntime, R as CalmLensError, T as validateServerClientOptions, V as invalidConfig, a as appendAssetLocation, b as toTextAssetOptions, d as checkOptionKeys, g as pollForDecision, l as validateSignAssetUrlOptions, o as buildAssetUrl, p as encodePathSegment, s as getAssetInfo, u as DEFAULT_CDN_BASE_URL, w as validateRequestOptions, z as SDK_ERROR_CODES } from "./ModerationContextLimits-CrxSnVZ3.js";
2
+ import { c as getMockHooks, d as prepareSubmitAssetOptions, f as resolveConnectionOptions, i as CalmLensConnection, l as invalidPayload, n as NULLABLE_OPTION_KEYS, o as expectAsset, p as splitsIntoParts, r as SERVER_OPTION_KEYS, u as newIdempotencyKey } from "./CalmLensOptionKeys-BG7Qrh8-.js";
3
3
  import { n as sha256Hex, r as timingSafeEqual, t as hmacSha256Hex } from "./CryptoUtils-B_x8lMIx-DhuWGzqn.js";
4
4
  // src/contract/JsonUtils.js
5
5
  const stringifyJsonCanonical = (value) => JSON.stringify(value, (_key, nestedValue) => {
@@ -11,6 +11,10 @@ const UPLOAD_TOKEN_PREFIX = "clut_";
11
11
  const UPLOAD_TOKEN_MAX_TTL_SECONDS = 3600;
12
12
  const SIGNING_CONTEXT = "calmlens-upload-token:v1:";
13
13
  const toBase64Url = (value) => btoa(String.fromCharCode(...new TextEncoder().encode(value))).replaceAll("+", "-").replaceAll("/", "_").replace(/=+$/, "");
14
+ const fromBase64Url = (value) => {
15
+ const binary = atob(value.replaceAll("-", "+").replaceAll("_", "/"));
16
+ return new TextDecoder().decode(Uint8Array.from(binary, (char) => char.charCodeAt(0)));
17
+ };
14
18
  /**
15
19
  * The part of an API key a token names so the backend can find the key's hash. The same rule as
16
20
  * the stored `keyPrefix`: the fixed `clsk_<region>_` part plus four random characters.
@@ -24,6 +28,26 @@ const signUploadToken = async (claims, apiKey) => {
24
28
  const signature = await hmacSha256Hex(await signingSecret(apiKey), SIGNING_CONTEXT + body);
25
29
  return `${UPLOAD_TOKEN_PREFIX}${body}.${signature}`;
26
30
  };
31
+ /**
32
+ * Reads a token's claims without checking its signature, or returns undefined when it isn't
33
+ * well formed. Verify it with `verifyUploadTokenSignature` before trusting the claims.
34
+ */
35
+ const decodeUploadToken = (token) => {
36
+ if (!token.startsWith("clut_")) return void 0;
37
+ const [body, signature, extra] = token.slice(5).split(".");
38
+ if (!body || !signature || extra !== void 0 || !/^[0-9a-f]{64}$/.test(signature)) return;
39
+ try {
40
+ const claims = JSON.parse(fromBase64Url(body));
41
+ if (claims.v !== 1 || typeof claims.u !== "string" || typeof claims.k !== "string" || typeof claims.e !== "number" || typeof claims.n !== "string" || claims.x !== void 0 && typeof claims.x !== "string") return;
42
+ return {
43
+ claims,
44
+ body,
45
+ signature
46
+ };
47
+ } catch {
48
+ return;
49
+ }
50
+ };
27
51
  // src/client/CalmLensUploadTokens.ts
28
52
  /**
29
53
  * Signs a single-use upload token with `apiKey`, locally. `CalmLensServerClient` and
@@ -33,11 +57,11 @@ const signUploadToken = async (claims, apiKey) => {
33
57
  */
34
58
  const signUploadTokenWithApiKey = async (apiKey, options, { now = Date.now(), nonce = crypto.randomUUID() } = {}) => {
35
59
  if (!options || typeof options !== "object") throw invalidArgument("Options are required");
36
- const { uploadPresetId, externalId, expiresInSeconds = 600 } = options;
60
+ const { uploadPresetId, externalId, expiresIn = 600 } = options;
37
61
  encodePathSegment(uploadPresetId, "Upload preset ID");
38
- if (!Number.isInteger(expiresInSeconds) || expiresInSeconds < 1 || expiresInSeconds > 3600) throw invalidArgument(`expiresInSeconds must be a whole number from 1 to ${UPLOAD_TOKEN_MAX_TTL_SECONDS}`);
62
+ if (!Number.isInteger(expiresIn) || expiresIn < 1 || expiresIn > 3600) throw invalidArgument(`expiresIn must be a whole number from 1 to ${UPLOAD_TOKEN_MAX_TTL_SECONDS}`);
39
63
  if (externalId !== void 0 && (typeof externalId !== "string" || !externalId)) throw invalidArgument("externalId must be a non-empty string");
40
- const expiresAt = now + expiresInSeconds * 1e3;
64
+ const expiresAt = now + expiresIn * 1e3;
41
65
  return {
42
66
  token: await signUploadToken({
43
67
  v: 1,
@@ -128,22 +152,45 @@ const isOptional = (value, type, nullable) => value === void 0 || nullable && va
128
152
  */
129
153
  const isWebhookEvent = (value) => {
130
154
  if (!isObject(value) || typeof value.id !== "string" || typeof value.type !== "string" || typeof value.projectId !== "string" || typeof value.createdAt !== "number") return false;
131
- const { severity, title, description, assetId, asset, facts } = value;
132
- return isOptional(severity, "string", false) && isOptional(title, "string", false) && isOptional(description, "string", true) && isOptional(assetId, "string", true) && (asset === void 0 || asset === null || isObject(asset) && typeof asset.id === "string") && (facts === void 0 || Array.isArray(facts) && facts.every((fact) => isObject(fact) && typeof fact.key === "string" && "value" in fact && isOptional(fact.url, "string", false)));
155
+ const { severity, title, description, assetId, assetSequence, asset, facts } = value;
156
+ return isOptional(severity, "string", false) && isOptional(title, "string", false) && isOptional(description, "string", true) && isOptional(assetId, "string", true) && isOptional(assetSequence, "number", true) && (asset === void 0 || asset === null || isObject(asset) && typeof asset.id === "string") && (facts === void 0 || Array.isArray(facts) && facts.every((fact) => isObject(fact) && typeof fact.key === "string" && "value" in fact && isOptional(fact.url, "string", false)));
157
+ };
158
+ /**
159
+ * The value of one of an event's facts, by key, or `undefined` when the event doesn't carry it.
160
+ * Typed by the event's `type`, so `getEventFact(event, "flagged-categories")` on an
161
+ * `asset.blocked` event is a list of categories. The fact's `url`, when it has one, is on the fact
162
+ * in `event.facts`.
163
+ */
164
+ const getEventFact = (event, key) => event?.facts?.find((fact) => fact?.key === key)?.value;
165
+ /**
166
+ * An event's facts as an object of values by key, such as `{ "flagged-categories": ["hate"] }`.
167
+ * A key the event repeats keeps its first value, as `getEventFact` reads it.
168
+ */
169
+ const getEventFacts = (event) => {
170
+ const values = {};
171
+ for (const fact of event?.facts ?? []) if (fact && typeof fact.key === "string" && !Object.hasOwn(values, fact.key)) values[fact.key] = fact.value;
172
+ return values;
133
173
  };
134
174
  /**
135
175
  * Whether a webhook event is a test send from the portal or the CLI rather than a real event: it
136
176
  * carries the registered `{ key: "test", value: true }` fact.
137
177
  */
138
178
  const isTestWebhookEvent = (event) => Array.isArray(event?.facts) && event.facts.some((fact) => fact?.key === "test" && fact.value === true);
179
+ /**
180
+ * Whether to apply `event` after `lastSequence`, the highest `assetSequence` you have applied for
181
+ * its asset (`null` or `undefined` when none). Deliveries can arrive out of order: an event about
182
+ * an asset is newer only with a higher `assetSequence`, so a retried or repeated delivery of an
183
+ * earlier one returns `false`. Events that aren't about an asset have no sequence and are always
184
+ * new. Store the event's `assetSequence` per `assetId` once you have applied it.
185
+ */
186
+ const isNewerAssetEvent = (event, lastSequence) => event.assetSequence === null || event.assetSequence === void 0 || lastSequence === null || lastSequence === void 0 || event.assetSequence > lastSequence;
139
187
  const getEnsureLensCacheKey = (options) => stringifyJsonCanonical({
140
188
  identifier: options.identifier,
141
189
  name: options.name,
142
190
  description: options.description ?? null,
143
191
  type: options.type,
144
192
  active: options.active,
145
- transform: options.transform ?? null,
146
- version: options.version
193
+ transform: options.transform ?? null
147
194
  });
148
195
  const requireId = (value, name) => encodePathSegment(value, name);
149
196
  /**
@@ -175,6 +222,8 @@ const inspectSymbol = Symbol.for("nodejs.util.inspect.custom");
175
222
  */
176
223
  var CalmLensServerClient = class CalmLensServerClient {
177
224
  #apiKey;
225
+ /** The options this client was created with, without the API key, for `withRequestOptions`. */
226
+ #options;
178
227
  #settings;
179
228
  #lenses;
180
229
  #connection;
@@ -202,6 +251,7 @@ var CalmLensServerClient = class CalmLensServerClient {
202
251
  if ((isBrowserRuntime() || isReactNativeRuntime()) && !options.dangerouslyAllowBrowser) throw invalidConfig("CalmLensServerClient is running in a browser or app, where anyone could read the API key. Call CalmLens from your server, upload from the browser or app with CalmLensAppClient, or set dangerouslyAllowBrowser: true for trusted internal tools.");
203
252
  const { apiKey, ...rest } = options;
204
253
  this.#apiKey = apiKey;
254
+ this.#options = rest;
205
255
  this.#settings = {
206
256
  ...resolveConnectionOptions(rest),
207
257
  cdnBaseUrl: (rest.cdnBaseUrl ?? getMockHooks(rest)?.defaultCdnBaseUrl ?? DEFAULT_CDN_BASE_URL).replace(/\/+$/, "")
@@ -219,7 +269,7 @@ var CalmLensServerClient = class CalmLensServerClient {
219
269
  withRequestOptions(options) {
220
270
  validateRequestOptions(options);
221
271
  return new CalmLensServerClient({
222
- ...this.#settings,
272
+ ...this.#options,
223
273
  ...options,
224
274
  apiKey: this.#apiKey
225
275
  }, this.#lenses);
@@ -243,20 +293,20 @@ var CalmLensServerClient = class CalmLensServerClient {
243
293
  request(method, path, options = {}) {
244
294
  return this.#connection.json(method, path, options);
245
295
  }
246
- async submitAsset(options, queue) {
296
+ async submitAsset(options, wait) {
247
297
  const body = prepareSubmitAssetOptions(options, {
248
298
  deferUploadChecks: this.#connection.deferUploadChecks,
249
299
  partSizeBytes: this.#connection.partSizeBytes
250
300
  });
251
301
  const uploadsPath = `${this.projectPath}/assets`;
252
- if ("content" in body && splitsIntoParts(body.content, this.#connection.partSizeBytes)) return expectAsset(await this.#connection.submitInParts(uploadsPath, body, queue, {
302
+ if ("content" in body && splitsIntoParts(body.content, this.#connection.partSizeBytes)) return expectAsset(await this.#connection.submitInParts(uploadsPath, body, wait, {
253
303
  partPath: (assetId) => `/assets/${encodeURIComponent(assetId)}/part`,
254
304
  retrieve: (assetId) => this.buildAssets().retrieve({ assetId })
255
305
  }));
256
- if ("content" in body || "part" in body) return expectAsset(await this.#connection.submitRawUpload(uploadsPath, body, queue));
306
+ if ("content" in body || "part" in body) return expectAsset(await this.#connection.submitUpload(uploadsPath, body, wait));
257
307
  const { idempotencyKey, ...fields } = body;
258
308
  const data = await this.#connection.json("POST", uploadsPath, {
259
- query: { queue },
309
+ query: { wait },
260
310
  body: fields,
261
311
  idempotencyKey: idempotencyKey ?? newIdempotencyKey()
262
312
  });
@@ -265,32 +315,59 @@ var CalmLensServerClient = class CalmLensServerClient {
265
315
  get cdn() {
266
316
  return {
267
317
  /**
268
- * Builds a CDN URL for asset content or a preview, without a request. Private assets
269
- * need a signed URL (`assets.createSignedUrl`) or an authenticated request; public
270
- * age-restricted assets additionally require `viewerClaims.ageConfirmed: true`. Your
271
- * platform confirms the viewer's age; CalmLens does not verify this claim, and anyone can
272
- * add it to a public URL.
318
+ * Builds an asset's CDN URL without a request: the asset URL, which every resource is a path
319
+ * beneath, or a resource URL when `resource` is given, with its lens or transform and the
320
+ * viewer claims. Use it for public assets; private ones need `cdn.signAssetUrl`. Viewer
321
+ * claims are your app's unsigned assertions: CalmLens does not verify an age confirmation,
322
+ * and anyone holding the URL can add it.
273
323
  */
274
324
  getAssetUrl: (urlOptions) => {
275
- const { assetIdentifier, ...options } = checked("cdn.getAssetUrl", urlOptions);
276
- const { projectId, cdnBaseUrl } = this.#settings;
277
- return getAssetUrl({
278
- projectId,
279
- cdnBaseUrl,
280
- assetIdentifier,
281
- ...options
282
- });
325
+ const { projectId, ...options } = checked("cdn.getAssetUrl", urlOptions);
326
+ return buildAssetUrl(this.#settings.cdnBaseUrl, projectId ?? this.#settings.projectId, options);
327
+ },
328
+ /**
329
+ * Signs a private asset's URL on your server, so browsers and apps can load it without an API
330
+ * key until it expires. Every resource is a path beneath it, as beneath a public asset URL;
331
+ * `/original` only when signed with `original: true`. With `resource`, returns that resource's
332
+ * URL beneath the grant; lenses, transforms and viewer claims are appended as `getAssetUrl`
333
+ * appends them and aren't part of the signature.
334
+ */
335
+ signAssetUrl: async (signOptions) => {
336
+ const options = checked("cdn.signAssetUrl", signOptions);
337
+ validateSignAssetUrlOptions(options);
338
+ const { projectId, assetId, externalId, expiresIn, original, ...location } = options;
339
+ const project = requireId(projectId ?? this.#settings.projectId, "Project ID");
340
+ const signed = await this.request("POST", `/projects/${project}/signed-asset-urls`, { body: {
341
+ ...assetId !== void 0 ? { assetId } : { externalId },
342
+ expiresIn: expiresIn ?? 900,
343
+ original: original ?? false
344
+ } });
345
+ if (!signed || typeof signed.url !== "string" || !signed.url || typeof signed.expiresAt !== "number") throw new CalmLensError(SDK_ERROR_CODES.INVALID_RESPONSE, { message: "The API returned no signed asset URL" });
346
+ return {
347
+ url: appendAssetLocation(signed.url, location),
348
+ expiresAt: signed.expiresAt
349
+ };
283
350
  },
284
351
  /**
352
+ * The display info of an asset URL, public or signed (`{url}/info`): its type, size,
353
+ * rendered file, preview and stream, and whether the viewer its claims describe can see it.
354
+ * A server can pass it to `CalmLensAsset` as `info`, so the first render is the real
355
+ * element.
356
+ */
357
+ getAssetInfo: (url, options = {}) => getAssetInfo(url, {
358
+ ...options,
359
+ fetch: this.#settings.cdnFetch
360
+ }),
361
+ /**
285
362
  * Fetches asset content or a preview from the CDN with the client's API key, and returns
286
363
  * the `Response` as soon as headers arrive, so the body streams. Non-2xx responses are
287
364
  * returned, not thrown; `timeoutMs` covers only the wait for headers.
288
365
  */
289
366
  serve: async (options) => {
290
- const { assetIdentifier, init, ...urlOptions } = checked("cdn.serve", options);
367
+ const { init, resource = "rendered", ...urlOptions } = checked("cdn.serve", options);
291
368
  const url = this.cdn.getAssetUrl({
292
- assetIdentifier,
293
- ...urlOptions
369
+ ...urlOptions,
370
+ resource
294
371
  });
295
372
  const method = init?.method?.toUpperCase() ?? "GET";
296
373
  const { response } = await this.#connection.transport.send({
@@ -335,7 +412,7 @@ sign: async (options) => {
335
412
  return {
336
413
  /** Searches accessible assets by keyword or a natural-language description. */
337
414
  search: async (options) => this.request("GET", `${this.projectPath}/assets/search`, { query: checked("assets.search", options) }),
338
- /** Lists one page of the project's assets, with optional filter and ordering. */
415
+ /** Lists one page of the project's assets, with an optional filter and sort. */
339
416
  list: async (options = {}) => this.request("GET", `${this.projectPath}/assets`, { query: checked("assets.list", options) }),
340
417
  /**
341
418
  * Yields every asset matching `options`, fetching pages as needed. The cursor keeps the position
@@ -363,6 +440,24 @@ sign: async (options) => {
363
440
  const { assetId, ...query } = checked("assets.listChildren", options);
364
441
  return this.request("GET", `/assets/${requireId(assetId, "Asset ID")}/children`, { query });
365
442
  },
443
+ /**
444
+ * Lists one page of an audio or video asset's findings timeline, in time order.
445
+ * `classification.moderation.timeline.segmentCount` says how many segments there are.
446
+ */
447
+ listTimeline: async (options) => {
448
+ const { assetId, ...query } = checked("assets.listTimeline", options);
449
+ const assetPath = `${this.projectPath}/assets/${requireId(assetId, "Asset ID")}`;
450
+ return this.request("GET", `${assetPath}/timeline`, { query });
451
+ },
452
+ /** Yields every segment of an audio or video asset's findings timeline, in time order. */
453
+ iterateTimeline: (options) => {
454
+ checked("assets.iterateTimeline", options);
455
+ requireId(options?.assetId, "Asset ID");
456
+ return this.iteratePages((cursor) => this.buildAssets().listTimeline({
457
+ ...options,
458
+ cursor
459
+ }));
460
+ },
366
461
  /** Yields every child of an asset, fetching pages as needed. */
367
462
  iterateChildren: (options) => {
368
463
  checked("assets.iterateChildren", options);
@@ -373,11 +468,10 @@ sign: async (options) => {
373
468
  }));
374
469
  },
375
470
  /**
376
- * Uploads an asset and queues it for moderation, returning immediately with processing
377
- * status `processing` (or `uploading` for the first multipart part). Retried safely with an
378
- * `Idempotency-Key`.
471
+ * Uploads an asset and returns without waiting for its decision (`wait=false`), with
472
+ * `classification.status` `queued`. Retried safely with an `Idempotency-Key`.
379
473
  */
380
- create: async (options) => this.submitAsset(checked("assets.create", options), true),
474
+ create: async (options) => this.submitAsset(checked("assets.create", options), false),
381
475
  /**
382
476
  * Uploads an asset and waits for its moderation decision. Audio and video still finish
383
477
  * in the background. Retried safely with an `Idempotency-Key`.
@@ -385,33 +479,17 @@ sign: async (options) => {
385
479
  classify: async (classifyOptions) => {
386
480
  const options = checked("assets.classify", classifyOptions);
387
481
  if (options && "content" in options && "plainText" in options.content && (typeof options.content.plainText !== "string" || !options.content.plainText.trim())) throw invalidPayload("Text to classify must be a non-empty string");
388
- return this.submitAsset(options, false);
482
+ return this.submitAsset(options, true);
389
483
  },
390
484
  /**
391
- * Uploads the next part of a multipart upload. The upload's queue mode, chosen when it
392
- * started, applies when the final part arrives; pass `queue` to override it.
485
+ * Uploads the next part of a multipart upload. Whether the final part waits for the
486
+ * decision was chosen when the upload started; pass `wait` to override it.
393
487
  */
394
488
  uploadPart: async (partOptions) => {
395
489
  const { assetId, ...options } = checked("assets.uploadPart", partOptions);
396
490
  const encodedAssetId = requireId(assetId, "Asset ID");
397
491
  return expectAsset(await this.#connection.uploadPart(`/assets/${encodedAssetId}/part`, options));
398
492
  },
399
- /**
400
- * Creates a short-lived signed CDN URL, so browsers can load private content without
401
- * an API key.
402
- */
403
- createSignedUrl: async (signedUrlOptions) => {
404
- const { assetId, ...options } = checked("assets.createSignedUrl", signedUrlOptions);
405
- const encodedAssetId = requireId(assetId, "Asset ID");
406
- validateSignedUrlOptions(options);
407
- return this.request("POST", `/assets/${encodedAssetId}/signed-url`, { body: {
408
- viewerClaims: options.viewerClaims,
409
- resource: options.resource,
410
- expiresInSeconds: options.expiresInSeconds ?? 900,
411
- lens: options.lens,
412
- transform: transformSelector(options.transform)
413
- } });
414
- },
415
493
  /** Moves an asset into a folder, or to the project root with `folderId: null`. */
416
494
  move: async (options) => {
417
495
  const { assetId, folderId } = checked("assets.move", options);
@@ -437,20 +515,25 @@ sign: async (options) => {
437
515
  return this.request("POST", `/assets/${requireId(assetId, "Asset ID")}/decision`, { body });
438
516
  },
439
517
  /**
440
- * Completes the policy evidence behind a decided asset's moderation decision: the report's
441
- * `classification.moderation.evidence` becomes `full` and every action stays as
518
+ * Completes the policy evidence behind a decided asset's moderation decision: its
519
+ * `classification.moderation.explanationComplete` becomes `true` and every action stays as
442
520
  * decided. With `rerun: true` the asset is moderated again with the project's current policy
443
- * and returns in `processing`; use it when the policy has changed since the decision
444
- * (`asset/policy-changed`).
521
+ * and an `asset.rerun-requested` event is recorded; use it when the policy has changed since
522
+ * the decision (`asset/policy-changed`). The asset returns unchanged: it keeps its decision
523
+ * until the re-run's is stored, reported by `asset.classified` and `asset.<status>` events,
524
+ * and a failed re-run keeps it. A reviewed asset fails with `asset/reviewed`, and one whose
525
+ * content is gone with `asset/content-unavailable`.
445
526
  */
446
527
  explain: async (options) => {
447
528
  const { assetId, rerun } = checked("assets.explain", options);
448
529
  return this.request("POST", `/assets/${requireId(assetId, "Asset ID")}/explain`, { body: rerun ? { rerun } : {} });
449
530
  },
450
531
  /**
451
- * Waits until an asset's `classification.moderation.status` is no longer `pending` (`allowed`,
452
- * `limited`, `age-restricted`, `blocked` or `purged`), or its `classification.status` is `failed`, and returns that asset, checking every few seconds. Rejects with `sdk/timeout` if there is no
453
- * decision within `timeoutMs` (default 60000). Webhooks report decisions without polling.
532
+ * Waits until an asset is settled, its `classification.status` `completed` (with its
533
+ * decision in `classification.moderation.status`) or `failed`, and returns that asset,
534
+ * checking every few seconds. A `queued` or `processing` asset is still waiting, even when a
535
+ * reviewer has already decided it. Rejects with `sdk/timeout` if it is not settled within
536
+ * `timeoutMs` (default 60000). Webhooks report decisions without polling.
454
537
  */
455
538
  waitForDecision: async (waitOptions) => {
456
539
  const { assetId, ...options } = checked("assets.waitForDecision", waitOptions);
@@ -463,11 +546,14 @@ sign: async (options) => {
463
546
  * keeping the asset record, metadata and classification results. The returned asset has
464
547
  * `content.status` set to `removed` and `content.removalReason` to `requested`; the CDN no longer serves it.
465
548
  */
466
- deleteContent: async (options) => {
467
- const { assetId } = checked("assets.deleteContent", options);
549
+ removeContent: async (options) => {
550
+ const { assetId } = checked("assets.removeContent", options);
468
551
  return this.request("DELETE", `/assets/${requireId(assetId, "Asset ID")}/content`);
469
552
  },
470
- /** Deletes an asset record together with its stored content. */
553
+ /**
554
+ * Deletes an asset record together with its stored content. An asset extracted from another
555
+ * (one with a `parentId`) fails with `asset/child-not-deletable`: delete its parent instead.
556
+ */
471
557
  delete: async (options) => {
472
558
  const { assetId } = checked("assets.delete", options);
473
559
  await this.request("DELETE", `/assets/${requireId(assetId, "Asset ID")}`);
@@ -475,10 +561,12 @@ sign: async (options) => {
475
561
  /**
476
562
  * Deletes up to 500 assets (`operation: "delete"`) or removes their stored content
477
563
  * (`"remove-content"`) in one request. Every asset must exist in the project and the key
478
- * needs `assets:delete` for its folder, or nothing is queued. Resolves with
479
- * `{ queued: true }` once queued; the work runs in the background and records
480
- * `asset.deleted` or `asset.content-removed` for each asset. Assets under a safety hold
481
- * are skipped. Not retried: it carries no `Idempotency-Key`.
564
+ * needs `assets:delete` for its folder, and a deletion can't name an asset extracted from
565
+ * another (`asset/child-not-deletable`), or nothing is queued. Resolves with
566
+ * `{ batchId, status: "queued", assetCount }` once queued; the work runs in the background
567
+ * and records `asset.deleted` or `asset.content-removed` for each asset, with a `batch-id`
568
+ * fact naming `batchId`. Assets under a safety hold are skipped. Not retried: it carries no
569
+ * `Idempotency-Key`.
482
570
  */
483
571
  batch: async (options) => {
484
572
  const { assetIds, operation } = checked("assets.batch", options);
@@ -497,10 +585,18 @@ sign: async (options) => {
497
585
  return {
498
586
  /**
499
587
  * Lists project events after a cursor, oldest first. Call without `cursor` to get a cursor
500
- * for "now", then poll with each response's `nextCursor`. Webhook deliveries carry the same
501
- * events reshaped as `{ id, type, createdAt, projectId, data }`.
588
+ * for "now", then poll with each response's `nextCursor`. Webhook deliveries carry each
589
+ * event's same fields as a flat JSON body. `types` and `assetId` narrow the feed to some
590
+ * event types or one asset's events; a cursor belongs to the filters it was issued with, so
591
+ * pass the same ones with each `cursor`.
502
592
  */
503
- list: async (options = {}) => this.request("GET", `${this.projectPath}/events`, { query: { ...checked("events.list", options) } }),
593
+ list: async (options = {}) => {
594
+ const { types, ...query } = checked("events.list", options);
595
+ return this.request("GET", `${this.projectPath}/events`, { query: {
596
+ ...query,
597
+ types: types?.length ? types.join(",") : void 0
598
+ } });
599
+ },
504
600
  /**
505
601
  * Yields pages of events after `cursor` until no more are waiting. Save each page's
506
602
  * `nextCursor` to resume later. Without `cursor`, yields one empty page whose `nextCursor`
@@ -538,10 +634,18 @@ sign: async (options) => {
538
634
  get folders() {
539
635
  return {
540
636
  /**
541
- * Lists one page of child folders, sorted by name unless `ordering` says otherwise. Pass
637
+ * Lists one page of child folders, sorted by name unless `sort` says otherwise. Pass
542
638
  * `nextCursor` as `cursor` for the next page; fetch a branch when it is opened.
543
639
  */
544
640
  list: async (options = {}) => this.request("GET", `${this.projectPath}/folders`, { query: checked("folders.list", options) }),
641
+ /** Yields every child folder of `parentId` (or the project root), fetching pages as needed. */
642
+ iterate: (options = {}) => {
643
+ checked("folders.iterate", options);
644
+ return this.iteratePages((cursor) => this.folders.list({
645
+ ...options,
646
+ cursor
647
+ }));
648
+ },
545
649
  retrieve: async (options) => {
546
650
  const { folderId } = checked("folders.retrieve", options);
547
651
  return this.request("GET", `/folders/${requireId(folderId, "Folder ID")}`);
@@ -570,8 +674,16 @@ sign: async (options) => {
570
674
  */
571
675
  get hashLists() {
572
676
  return {
573
- /** Lists one page of the project's hash lists, newest first. */
677
+ /** Lists one page of the project's hash lists, newest first unless `sort` says otherwise. */
574
678
  list: async (options = {}) => this.request("GET", `${this.projectPath}/hash-lists`, { query: checked("hashLists.list", options) }),
679
+ /** Yields every hash list, fetching pages as needed. */
680
+ iterate: (options = {}) => {
681
+ checked("hashLists.iterate", options);
682
+ return this.iteratePages((cursor) => this.hashLists.list({
683
+ ...options,
684
+ cursor
685
+ }));
686
+ },
575
687
  retrieve: async (options) => {
576
688
  const { hashListId } = checked("hashLists.retrieve", options);
577
689
  return this.request("GET", `/hash-lists/${requireId(hashListId, "Hash list ID")}`);
@@ -587,7 +699,16 @@ sign: async (options) => {
587
699
  const { hashListId } = checked("hashLists.delete", options);
588
700
  await this.request("DELETE", `/hash-lists/${requireId(hashListId, "Hash list ID")}`);
589
701
  },
590
- /** Lists one page of a list's entries, newest first. */
702
+ /** Yields every entry of a list, fetching pages as needed. */
703
+ iterateEntries: (options) => {
704
+ checked("hashLists.iterateEntries", options);
705
+ requireId(options?.hashListId, "Hash list ID");
706
+ return this.iteratePages((cursor) => this.hashLists.listEntries({
707
+ ...options,
708
+ cursor
709
+ }));
710
+ },
711
+ /** Lists one page of a list's entries, newest first unless `sort` says otherwise. */
591
712
  listEntries: async (options) => {
592
713
  const { hashListId, ...query } = checked("hashLists.listEntries", options);
593
714
  return this.request("GET", `/hash-lists/${requireId(hashListId, "Hash list ID")}/entries`, { query });
@@ -604,29 +725,42 @@ sign: async (options) => {
604
725
  };
605
726
  }
606
727
  /**
607
- * Moderation policies belong to the project's organisation and its projects share them. Every
608
- * change sends the policy's `revision`, so a policy changed since is refused. Through a
609
- * project's key you can change only policies no other project uses or owns.
728
+ * Moderation policies belong to the organisation and its projects share them. Every change sends
729
+ * the policy's `revision`, so a policy changed since is refused. Through a project's key you can
730
+ * change only policies no other project uses.
610
731
  */
611
732
  get policies() {
612
- const policyPath = (policyId) => `${this.projectPath}/policies/${requireId(policyId, "Policy ID")}`;
733
+ const policyPath = (policyId) => `/policies/${requireId(policyId, "Policy ID")}`;
613
734
  return {
614
- /** Lists the organisation's policies and the ID of the one the project uses. */
615
- list: async () => this.request("GET", `${this.projectPath}/policies`),
735
+ /** Lists one page of the organisation's policies, oldest first unless `sort` says otherwise. */
736
+ list: async (options = {}) => this.request("GET", "/policies", { query: checked("policies.list", options) }),
737
+ /** Yields every policy of the organisation, fetching pages as needed. */
738
+ iterate: (options = {}) => {
739
+ checked("policies.iterate", options);
740
+ return this.iteratePages((cursor) => this.policies.list({
741
+ ...options,
742
+ cursor
743
+ }));
744
+ },
616
745
  retrieve: async (options) => this.request("GET", policyPath(checked("policies.retrieve", options).policyId)),
617
746
  /** Creates a policy from `settings`, or a copy of a built-in preset with `presetId`. */
618
- create: async (options) => this.request("POST", `${this.projectPath}/policies`, { body: checked("policies.create", options) }),
747
+ create: async (options) => this.request("POST", "/policies", { body: checked("policies.create", options) }),
619
748
  /** Changes the name, description or settings; later moderation uses them. */
620
749
  update: async (options) => {
621
750
  const { policyId, ...body } = checked("policies.update", options);
622
751
  return this.request("PATCH", policyPath(policyId), { body });
623
752
  },
624
- /** Resets a preset copy to its pinned version, or updates an unchanged copy to the latest. */
625
- applyPreset: async (options) => {
626
- const { policyId, ...body } = checked("policies.applyPreset", options);
627
- return this.request("POST", `${policyPath(policyId)}/preset`, { body });
753
+ /** Restores the settings of the preset release a `pinned` or `copy` policy is pinned to. */
754
+ reset: async (options) => {
755
+ const { policyId, ...body } = checked("policies.reset", options);
756
+ return this.request("POST", `${policyPath(policyId)}/reset`, { body });
757
+ },
758
+ /** Moves an unchanged `pinned` or `copy` policy to the latest release of its preset. */
759
+ upgrade: async (options) => {
760
+ const { policyId, ...body } = checked("policies.upgrade", options);
761
+ return this.request("POST", `${policyPath(policyId)}/upgrade`, { body });
628
762
  },
629
- /** Switches automatic updates on or off for the organisation's own preset policy. */
763
+ /** Switches automatic updates on (`live`) or off (`pinned`) for the organisation's own preset policy. */
630
764
  setAutomaticUpdates: async (options) => {
631
765
  const { policyId, ...body } = checked("policies.setAutomaticUpdates", options);
632
766
  return this.request("PUT", `${policyPath(policyId)}/automatic-updates`, { body });
@@ -635,13 +769,112 @@ sign: async (options) => {
635
769
  delete: async (options) => {
636
770
  await this.request("DELETE", policyPath(checked("policies.delete", options).policyId));
637
771
  },
772
+ /** The policy the project moderates with. */
773
+ retrieveAssigned: async () => this.request("GET", `${this.projectPath}/policy`),
638
774
  /** Chooses the policy the project moderates with. */
639
775
  assign: async (options) => this.request("PUT", `${this.projectPath}/policy`, { body: checked("policies.assign", options) })
640
776
  };
641
777
  }
642
778
  /**
643
- * Create a named lens at any positive version, or update it with a greater version.
644
- * Supplying the same definition and version is idempotent.
779
+ * The project's upload presets: the rules for uploads from browsers and apps. `ensure` creates or
780
+ * replaces presets by key, for deploys that declare them in code; send each preset's `revision`
781
+ * to refuse a change made since you read it.
782
+ */
783
+ get uploadPresets() {
784
+ return {
785
+ /** Lists one page of the project's upload presets, oldest first unless `sort` says otherwise. */
786
+ list: async (options = {}) => this.request("GET", `${this.projectPath}/upload-presets`, { query: checked("uploadPresets.list", options) }),
787
+ /** Yields every upload preset of the project, fetching pages as needed. */
788
+ iterate: (options = {}) => {
789
+ checked("uploadPresets.iterate", options);
790
+ return this.iteratePages((cursor) => this.uploadPresets.list({
791
+ ...options,
792
+ cursor
793
+ }));
794
+ },
795
+ /**
796
+ * Creates each preset, or replaces it with the definition sent, by key. Every preset is
797
+ * checked before any is saved. Returns the stored presets in the order sent.
798
+ */
799
+ ensure: async (options) => this.request("PUT", `${this.projectPath}/upload-presets`, { body: checked("uploadPresets.ensure", options) }),
800
+ /** Deletes an upload preset; assets already uploaded through it stay. */
801
+ delete: async (options) => {
802
+ const { uploadPresetId } = checked("uploadPresets.delete", options);
803
+ await this.request("DELETE", `/upload-presets/${requireId(uploadPresetId, "Upload preset ID")}`);
804
+ }
805
+ };
806
+ }
807
+ /**
808
+ * The project's settings, with defaults filled in. `update` replaces them: settings left out
809
+ * return to their defaults. Send the `revision` you read to refuse a change made since.
810
+ */
811
+ get projectSettings() {
812
+ return {
813
+ get: async () => this.request("GET", `${this.projectPath}/settings`),
814
+ update: async (options) => this.request("PUT", `${this.projectPath}/settings`, { body: checked("projectSettings.update", options) })
815
+ };
816
+ }
817
+ /**
818
+ * The project's metadata fields. They share the project settings' `revision`; `ensure` creates
819
+ * or replaces fields by ID and keeps the others.
820
+ */
821
+ get metadataFields() {
822
+ return {
823
+ list: async () => this.request("GET", `${this.projectPath}/metadata-fields`),
824
+ ensure: async (options) => this.request("PUT", `${this.projectPath}/metadata-fields`, { body: checked("metadataFields.ensure", options) }),
825
+ /** Deletes a field definition; assets keep their values. */
826
+ delete: async (options) => {
827
+ const { fieldId, ...query } = checked("metadataFields.delete", options);
828
+ await this.request("DELETE", `${this.projectPath}/metadata-fields/${requireId(fieldId, "Metadata field ID")}`, { query });
829
+ }
830
+ };
831
+ }
832
+ /**
833
+ * The project's lenses: named image transforms the CDN applies at `/@<identifier>`. The CDN
834
+ * serves files made with each lens's current definition. `ensureLenses` creates or changes
835
+ * lenses by identifier, for applications that declare theirs in code.
836
+ */
837
+ get lenses() {
838
+ const lensPath = (lensId) => `/lenses/${requireId(lensId, "Lens ID")}`;
839
+ const forget = (matches) => {
840
+ for (const [cacheKey, lens] of this.#lenses.ensuredLenses) if (matches(lens)) this.#lenses.ensuredLenses.delete(cacheKey);
841
+ };
842
+ return {
843
+ /** Lists one page of the project's lenses, newest first unless `sort` says otherwise. */
844
+ list: async (options = {}) => this.request("GET", `${this.projectPath}/lenses`, { query: checked("lenses.list", options) }),
845
+ /** Yields every lens of the project, fetching pages as needed. */
846
+ iterate: (options = {}) => {
847
+ checked("lenses.iterate", options);
848
+ return this.iteratePages((cursor) => this.lenses.list({
849
+ ...options,
850
+ cursor
851
+ }));
852
+ },
853
+ /** Creates a lens; its identifier must be new to the project. */
854
+ create: async (options) => {
855
+ const lens = await this.request("POST", `${this.projectPath}/lenses`, { body: checked("lenses.create", options) });
856
+ forget((cached) => cached.identifier === lens.identifier);
857
+ return lens;
858
+ },
859
+ retrieve: async (options) => this.request("GET", lensPath(checked("lenses.retrieve", options).lensId)),
860
+ /** Changes a lens's name, description, type, transform or whether the CDN serves it. */
861
+ update: async (options) => {
862
+ const { lensId, ...body } = checked("lenses.update", options);
863
+ const lens = await this.request("PATCH", lensPath(lensId), { body });
864
+ forget((cached) => cached.id === lens.id);
865
+ return lens;
866
+ },
867
+ /** Deletes a lens; URLs that select it stop being served. */
868
+ delete: async (options) => {
869
+ const { lensId } = checked("lenses.delete", options);
870
+ await this.request("DELETE", lensPath(lensId));
871
+ forget((cached) => cached.id === lensId);
872
+ }
873
+ };
874
+ }
875
+ /**
876
+ * Creates a named lens, or changes it to this definition. Sending the same definition again
877
+ * returns the lens unchanged, from the client's lens cache once it has seen it.
645
878
  */
646
879
  async ensureLens(options) {
647
880
  checked("ensureLens", options);
@@ -652,7 +885,7 @@ sign: async (options) => {
652
885
  /**
653
886
  * Create or update several named lenses. New definitions are sent in one API request, or in
654
887
  * consecutive requests of at most {@link ENSURE_LENSES_MAX_PER_REQUEST} definitions, in order.
655
- * Each lens follows the same versioning and idempotency rules as ensureLens().
888
+ * Each lens is created or changed as ensureLens() does.
656
889
  */
657
890
  async ensureLenses(options) {
658
891
  const { lenses } = checked("ensureLenses", options);
@@ -701,4 +934,4 @@ sign: async (options) => {
701
934
  }
702
935
  }
703
936
  };
704
- export { WEBHOOK_TIMESTAMP_HEADER as a, verifyWebhookSignature as c, WEBHOOK_SIGNATURE_TOLERANCE_SECONDS as i, signUploadTokenWithApiKey as l, WEBHOOK_DELIVERY_HEADER as n, isTestWebhookEvent as o, WEBHOOK_SIGNATURE_HEADER as r, parseWebhookEvent as s, CalmLensServerClient as t, stringifyJsonCanonical as u };
937
+ export { WEBHOOK_TIMESTAMP_HEADER as a, isNewerAssetEvent as c, verifyWebhookSignature as d, signUploadTokenWithApiKey as f, WEBHOOK_SIGNATURE_TOLERANCE_SECONDS as i, isTestWebhookEvent as l, stringifyJsonCanonical as m, WEBHOOK_DELIVERY_HEADER as n, getEventFact as o, decodeUploadToken as p, WEBHOOK_SIGNATURE_HEADER as r, getEventFacts as s, CalmLensServerClient as t, parseWebhookEvent as u };