calmlens 0.19.0 → 0.21.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.
- package/README.md +13 -9
- package/bin/calmlens.js +1646 -706
- package/cjs/{BrowserUpload-CJ4Xc9bR.js → BrowserUpload-CeSwiMo5.js} +1 -1
- package/{esm/BrowserUpload-RkxV_Vv7.d.ts → cjs/BrowserUpload-D-NnAN7g.d.ts} +2 -2
- package/cjs/{CalmLensAppClient-LHMEQ-UZ.js → CalmLensAppClient-0UVCuNqW.js} +30 -10
- package/cjs/{CalmLensAppClient-B5gfOB6J.d.ts → CalmLensAppClient-gG16T2py.d.ts} +13 -3
- package/cjs/{CalmLensOptionKeys-BUj7v5AG.js → CalmLensOptionKeys-CYY6elxg.js} +242 -345
- package/cjs/{CalmLensServerClient-DCSbwIBs.d.ts → CalmLensServerClient-BHx3x_nZ.d.ts} +107 -49
- package/cjs/{CalmLensServerClient-BVOEUT_v.js → CalmLensServerClient-nfu6_YEW.js} +297 -92
- package/cjs/{CalmLensTypes-DpU-hXq2.d.ts → CalmLensTypes-CUB0YYVz.d.ts} +26601 -27354
- package/cjs/{Classification-D3SkprrQ-CMnQKW13.d.ts → Classification-Q5zGpR8l-CEWjnE39.d.ts} +731 -607
- package/cjs/Core-C82YmjjX.d.ts +823 -0
- package/cjs/Core-Dc3cteU7.js +998 -0
- package/cjs/FileIcons-4qSX7DW2.d.ts +67 -0
- package/cjs/{ModerationContextLimits-FDpQmw_T.js → ModerationContextLimits-BxOmeSqq.js} +970 -278
- package/cjs/{ReactUpload-BvpW4hJi.js → ReactUpload-BK2O3dnK.js} +1 -1
- package/cjs/{ReactUpload-huIMnOJ4.d.ts → ReactUpload-DiiXfKvj.d.ts} +1 -1
- package/cjs/{TestTriggers-CMwMrbjy-K0YBzu2a.js → TestTriggers-BTyXtX0Q-ATuFDhLX.js} +343 -35
- package/{esm/TestTriggers-D-fwfhEP-hlaP1oW2.d.ts → cjs/TestTriggers-D0pYHbkr-D5T0VdSn.d.ts} +146 -8
- package/cjs/{UploadController-D4qOZZc3.js → UploadController-DLyiLDTB.js} +34 -14
- package/cjs/{WebhookPayload-CQg8BBZQ.d.ts → WebhookPayload-BLT2y_Jy.d.ts} +93 -86
- package/cjs/app.d.ts +6 -7
- package/cjs/app.js +4 -3
- package/cjs/elements.d.ts +123 -22
- package/cjs/elements.js +553 -156
- package/cjs/file-icons.d.ts +2 -67
- package/cjs/index-CKRgjV16.d.ts +16 -0
- package/cjs/index.d.ts +5 -6
- package/cjs/index.js +3 -2
- package/cjs/react-native.d.ts +52 -11
- package/cjs/react-native.js +231 -99
- package/cjs/react.d.ts +42 -9
- package/cjs/react.js +381 -118
- package/cjs/server.d.ts +48 -7
- package/cjs/server.js +7 -3
- package/cjs/test-inputs.d.ts +2 -2
- package/cjs/test-inputs.js +13 -9
- package/cjs/testing.d.ts +29 -16
- package/cjs/testing.js +1511 -397
- package/cjs/ui-CTBUxnVp.d.ts +139 -0
- package/cjs/ui-CZ8exACq.js +1359 -0
- package/cjs/ui.d.ts +3 -2
- package/cjs/ui.js +45 -22
- package/cjs/vue.d.ts +802 -199
- package/cjs/vue.js +359 -127
- package/{cjs/BrowserUpload-RkxV_Vv7.d.ts → esm/BrowserUpload-D-NnAN7g.d.ts} +2 -2
- package/esm/{BrowserUpload-DpzS2bbj.js → BrowserUpload-i9OhCzMJ.js} +1 -1
- package/esm/{CalmLensAppClient-BjlvBweS.js → CalmLensAppClient-CK4_Py0c.js} +30 -10
- package/esm/{CalmLensAppClient-B5gfOB6J.d.ts → CalmLensAppClient-gG16T2py.d.ts} +13 -3
- package/esm/{CalmLensOptionKeys-BKez0Wiw.js → CalmLensOptionKeys-BGZlIsT2.js} +235 -338
- package/esm/{CalmLensServerClient-DCSbwIBs.d.ts → CalmLensServerClient-BHx3x_nZ.d.ts} +107 -49
- package/esm/{CalmLensServerClient-DemxbNMn.js → CalmLensServerClient-dAQUcDWb.js} +274 -93
- package/esm/{CalmLensTypes-DpU-hXq2.d.ts → CalmLensTypes-CUB0YYVz.d.ts} +26601 -27354
- package/esm/{Classification-D3SkprrQ-CMnQKW13.d.ts → Classification-Q5zGpR8l-CEWjnE39.d.ts} +731 -607
- package/esm/Core-BxeIud_S.js +843 -0
- package/esm/Core-C82YmjjX.d.ts +823 -0
- package/esm/FileIcons-4qSX7DW2.d.ts +67 -0
- package/esm/{ModerationContextLimits-lLfmyLni.js → ModerationContextLimits-B6_RalCQ.js} +911 -261
- package/esm/{ReactUpload-huIMnOJ4.d.ts → ReactUpload-DiiXfKvj.d.ts} +1 -1
- package/esm/{ReactUpload-6klucehl.js → ReactUpload-DxwVqfX1.js} +1 -1
- package/esm/{TestTriggers-CMwMrbjy-bdowBBKw.js → TestTriggers-BTyXtX0Q-GRB9jQwo.js} +320 -36
- package/{cjs/TestTriggers-D-fwfhEP-hlaP1oW2.d.ts → esm/TestTriggers-D0pYHbkr-D5T0VdSn.d.ts} +146 -8
- package/esm/{UploadController-UxP6gj7A.js → UploadController-D9Z-h00Q.js} +34 -14
- package/esm/{WebhookPayload-CQg8BBZQ.d.ts → WebhookPayload-BLT2y_Jy.d.ts} +93 -86
- package/esm/app.d.ts +6 -7
- package/esm/app.js +3 -3
- package/esm/elements.d.ts +123 -22
- package/esm/elements.js +497 -128
- package/esm/file-icons.d.ts +2 -67
- package/esm/index-CKRgjV16.d.ts +16 -0
- package/esm/index.d.ts +5 -6
- package/esm/index.js +1 -1
- package/esm/react-native.d.ts +52 -11
- package/esm/react-native.js +205 -75
- package/esm/react.d.ts +42 -9
- package/esm/react.js +327 -91
- package/esm/server.d.ts +48 -7
- package/esm/server.js +3 -3
- package/esm/styles.css +142 -22
- package/esm/svelte/AssetViewer.svelte +25 -0
- package/esm/svelte/CalmLensAsset.svelte +318 -0
- package/esm/svelte/CalmLensDocumentViewer.svelte +7 -0
- package/esm/svelte/CalmLensImageViewer.svelte +7 -0
- package/esm/svelte/CalmLensSpreadsheetViewer.svelte +7 -0
- package/esm/svelte/CalmLensTextViewer.svelte +7 -0
- package/esm/svelte/CalmLensWebsiteViewer.svelte +7 -0
- package/esm/svelte/index.d.ts +29 -6
- package/esm/svelte/index.js +7 -2
- package/esm/test-inputs.d.ts +2 -2
- package/esm/test-inputs.js +1 -1
- package/esm/testing.d.ts +29 -16
- package/esm/testing.js +1507 -393
- package/esm/ui-CTBUxnVp.d.ts +139 -0
- package/esm/ui-Cr7s6JHm.js +1258 -0
- package/esm/ui.d.ts +3 -2
- package/esm/ui.js +4 -3
- package/esm/vue.d.ts +802 -199
- package/esm/vue.js +308 -103
- package/package.json +3 -1
- package/cjs/ModerationContext-9lGm-Mna-CcmbRnOy.d.ts +0 -67
- package/cjs/index-BcDDQJF2.d.ts +0 -253
- package/cjs/ui-B23r8BvW.d.ts +0 -539
- package/cjs/ui-Dq-cm6Rx.js +0 -586
- package/esm/ModerationContext-9lGm-Mna-CcmbRnOy.d.ts +0 -67
- package/esm/index-BcDDQJF2.d.ts +0 -253
- package/esm/svelte/CalmLensMedia.svelte +0 -134
- package/esm/ui-B23r8BvW.d.ts +0 -539
- package/esm/ui-Bn29rfAi.js +0 -461
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_ModerationContextLimits = require("./ModerationContextLimits-
|
|
2
|
-
const require_CalmLensOptionKeys = require("./CalmLensOptionKeys-
|
|
1
|
+
const require_ModerationContextLimits = require("./ModerationContextLimits-BxOmeSqq.js");
|
|
2
|
+
const require_CalmLensOptionKeys = require("./CalmLensOptionKeys-CYY6elxg.js");
|
|
3
3
|
const require_CryptoUtils_B_x8lMIx = require("./CryptoUtils-B_x8lMIx-YBW1-bvL.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 require_CryptoUtils_B_x8lMIx.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 require_ModerationContextLimits.invalidArgument("Options are required");
|
|
36
|
-
const { uploadPresetId, externalId,
|
|
60
|
+
const { uploadPresetId, externalId, expiresIn = 600 } = options;
|
|
37
61
|
require_ModerationContextLimits.encodePathSegment(uploadPresetId, "Upload preset ID");
|
|
38
|
-
if (!Number.isInteger(
|
|
62
|
+
if (!Number.isInteger(expiresIn) || expiresIn < 1 || expiresIn > 3600) throw require_ModerationContextLimits.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 require_ModerationContextLimits.invalidArgument("externalId must be a non-empty string");
|
|
40
|
-
const expiresAt = now +
|
|
64
|
+
const expiresAt = now + expiresIn * 1e3;
|
|
41
65
|
return {
|
|
42
66
|
token: await signUploadToken({
|
|
43
67
|
v: 1,
|
|
@@ -128,28 +152,56 @@ 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) => require_ModerationContextLimits.encodePathSegment(value, name);
|
|
149
|
-
/**
|
|
196
|
+
/**
|
|
197
|
+
* `options`, once `checkOptionKeys` finds only keys `operation` takes, without the options given as
|
|
198
|
+
* `null` that the API refuses as `null`: those are left out, as if omitted.
|
|
199
|
+
*/
|
|
150
200
|
const checked = (operation, options) => {
|
|
151
201
|
require_ModerationContextLimits.checkOptionKeys(options, operation, require_CalmLensOptionKeys.SERVER_OPTION_KEYS);
|
|
152
|
-
return options;
|
|
202
|
+
if (!options || typeof options !== "object" || Array.isArray(options)) return options;
|
|
203
|
+
const nullable = require_CalmLensOptionKeys.NULLABLE_OPTION_KEYS[operation] ?? [];
|
|
204
|
+
return Object.fromEntries(Object.entries(options).filter(([key, value]) => value !== null || nullable.includes(key)));
|
|
153
205
|
};
|
|
154
206
|
/**
|
|
155
207
|
* Iterators stop rather than loop: a page that says more follow must not hand back a cursor this
|
|
@@ -238,20 +290,20 @@ var CalmLensServerClient = class CalmLensServerClient {
|
|
|
238
290
|
request(method, path, options = {}) {
|
|
239
291
|
return this.#connection.json(method, path, options);
|
|
240
292
|
}
|
|
241
|
-
async submitAsset(options,
|
|
293
|
+
async submitAsset(options, wait) {
|
|
242
294
|
const body = require_CalmLensOptionKeys.prepareSubmitAssetOptions(options, {
|
|
243
295
|
deferUploadChecks: this.#connection.deferUploadChecks,
|
|
244
296
|
partSizeBytes: this.#connection.partSizeBytes
|
|
245
297
|
});
|
|
246
298
|
const uploadsPath = `${this.projectPath}/assets`;
|
|
247
|
-
if ("content" in body && require_CalmLensOptionKeys.splitsIntoParts(body.content, this.#connection.partSizeBytes)) return require_CalmLensOptionKeys.expectAsset(await this.#connection.submitInParts(uploadsPath, body,
|
|
299
|
+
if ("content" in body && require_CalmLensOptionKeys.splitsIntoParts(body.content, this.#connection.partSizeBytes)) return require_CalmLensOptionKeys.expectAsset(await this.#connection.submitInParts(uploadsPath, body, wait, {
|
|
248
300
|
partPath: (assetId) => `/assets/${encodeURIComponent(assetId)}/part`,
|
|
249
301
|
retrieve: (assetId) => this.buildAssets().retrieve({ assetId })
|
|
250
302
|
}));
|
|
251
|
-
if ("content" in body || "part" in body) return require_CalmLensOptionKeys.expectAsset(await this.#connection.submitRawUpload(uploadsPath, body,
|
|
303
|
+
if ("content" in body || "part" in body) return require_CalmLensOptionKeys.expectAsset(await this.#connection.submitRawUpload(uploadsPath, body, wait));
|
|
252
304
|
const { idempotencyKey, ...fields } = body;
|
|
253
305
|
const data = await this.#connection.json("POST", uploadsPath, {
|
|
254
|
-
query: {
|
|
306
|
+
query: { wait },
|
|
255
307
|
body: fields,
|
|
256
308
|
idempotencyKey: idempotencyKey ?? require_CalmLensOptionKeys.newIdempotencyKey()
|
|
257
309
|
});
|
|
@@ -260,32 +312,59 @@ var CalmLensServerClient = class CalmLensServerClient {
|
|
|
260
312
|
get cdn() {
|
|
261
313
|
return {
|
|
262
314
|
/**
|
|
263
|
-
* Builds
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
-
*
|
|
267
|
-
*
|
|
315
|
+
* Builds an asset's CDN URL without a request: the asset URL, which every resource is a path
|
|
316
|
+
* beneath, or a resource URL when `resource` is given, with its lens or transform and the
|
|
317
|
+
* viewer claims. Use it for public assets; private ones need `cdn.signAssetUrl`. Viewer
|
|
318
|
+
* claims are your app's unsigned assertions: CalmLens does not verify an age confirmation,
|
|
319
|
+
* and anyone holding the URL can add it.
|
|
268
320
|
*/
|
|
269
321
|
getAssetUrl: (urlOptions) => {
|
|
270
|
-
const {
|
|
271
|
-
|
|
272
|
-
return require_ModerationContextLimits.getAssetUrl({
|
|
273
|
-
projectId,
|
|
274
|
-
cdnBaseUrl,
|
|
275
|
-
assetIdentifier,
|
|
276
|
-
...options
|
|
277
|
-
});
|
|
322
|
+
const { projectId, ...options } = checked("cdn.getAssetUrl", urlOptions);
|
|
323
|
+
return require_ModerationContextLimits.buildAssetUrl(this.#settings.cdnBaseUrl, projectId ?? this.#settings.projectId, options);
|
|
278
324
|
},
|
|
279
325
|
/**
|
|
326
|
+
* Signs a private asset's URL on your server, so browsers and apps can load it without an API
|
|
327
|
+
* key until it expires. Every resource is a path beneath it, as beneath a public asset URL;
|
|
328
|
+
* `/original` only when signed with `original: true`. With `resource`, returns that resource's
|
|
329
|
+
* URL beneath the grant; lenses, transforms and viewer claims are appended as `getAssetUrl`
|
|
330
|
+
* appends them and aren't part of the signature.
|
|
331
|
+
*/
|
|
332
|
+
signAssetUrl: async (signOptions) => {
|
|
333
|
+
const options = checked("cdn.signAssetUrl", signOptions);
|
|
334
|
+
require_ModerationContextLimits.validateSignAssetUrlOptions(options);
|
|
335
|
+
const { projectId, assetId, externalId, expiresIn, original, ...location } = options;
|
|
336
|
+
const project = requireId(projectId ?? this.#settings.projectId, "Project ID");
|
|
337
|
+
const signed = await this.request("POST", `/projects/${project}/signed-asset-urls`, { body: {
|
|
338
|
+
...assetId !== void 0 ? { assetId } : { externalId },
|
|
339
|
+
expiresIn: expiresIn ?? 900,
|
|
340
|
+
original: original ?? false
|
|
341
|
+
} });
|
|
342
|
+
if (!signed || typeof signed.url !== "string" || !signed.url || typeof signed.expiresAt !== "number") throw new require_ModerationContextLimits.CalmLensError(require_ModerationContextLimits.SDK_ERROR_CODES.INVALID_RESPONSE, { message: "The API returned no signed asset URL" });
|
|
343
|
+
return {
|
|
344
|
+
url: require_ModerationContextLimits.appendAssetLocation(signed.url, location),
|
|
345
|
+
expiresAt: signed.expiresAt
|
|
346
|
+
};
|
|
347
|
+
},
|
|
348
|
+
/**
|
|
349
|
+
* The display info of an asset URL, public or signed (`{url}/info`): its type, size,
|
|
350
|
+
* rendered file, preview and stream, and whether the viewer its claims describe can see it.
|
|
351
|
+
* A server can pass it to `CalmLensAsset` as `info`, so the first render is the real
|
|
352
|
+
* element.
|
|
353
|
+
*/
|
|
354
|
+
getAssetInfo: (url, options = {}) => require_ModerationContextLimits.getAssetInfo(url, {
|
|
355
|
+
...options,
|
|
356
|
+
fetch: this.#settings.cdnFetch
|
|
357
|
+
}),
|
|
358
|
+
/**
|
|
280
359
|
* Fetches asset content or a preview from the CDN with the client's API key, and returns
|
|
281
360
|
* the `Response` as soon as headers arrive, so the body streams. Non-2xx responses are
|
|
282
361
|
* returned, not thrown; `timeoutMs` covers only the wait for headers.
|
|
283
362
|
*/
|
|
284
363
|
serve: async (options) => {
|
|
285
|
-
const {
|
|
364
|
+
const { init, resource = "rendered", ...urlOptions } = checked("cdn.serve", options);
|
|
286
365
|
const url = this.cdn.getAssetUrl({
|
|
287
|
-
|
|
288
|
-
|
|
366
|
+
...urlOptions,
|
|
367
|
+
resource
|
|
289
368
|
});
|
|
290
369
|
const method = init?.method?.toUpperCase() ?? "GET";
|
|
291
370
|
const { response } = await this.#connection.transport.send({
|
|
@@ -330,7 +409,7 @@ sign: async (options) => {
|
|
|
330
409
|
return {
|
|
331
410
|
/** Searches accessible assets by keyword or a natural-language description. */
|
|
332
411
|
search: async (options) => this.request("GET", `${this.projectPath}/assets/search`, { query: checked("assets.search", options) }),
|
|
333
|
-
/** Lists one page of the project's assets, with optional filter and
|
|
412
|
+
/** Lists one page of the project's assets, with an optional filter and sort. */
|
|
334
413
|
list: async (options = {}) => this.request("GET", `${this.projectPath}/assets`, { query: checked("assets.list", options) }),
|
|
335
414
|
/**
|
|
336
415
|
* Yields every asset matching `options`, fetching pages as needed. The cursor keeps the position
|
|
@@ -358,6 +437,24 @@ sign: async (options) => {
|
|
|
358
437
|
const { assetId, ...query } = checked("assets.listChildren", options);
|
|
359
438
|
return this.request("GET", `/assets/${requireId(assetId, "Asset ID")}/children`, { query });
|
|
360
439
|
},
|
|
440
|
+
/**
|
|
441
|
+
* Lists one page of an audio or video asset's findings timeline, in time order.
|
|
442
|
+
* `classification.moderation.timeline.segmentCount` says how many segments there are.
|
|
443
|
+
*/
|
|
444
|
+
listTimeline: async (options) => {
|
|
445
|
+
const { assetId, ...query } = checked("assets.listTimeline", options);
|
|
446
|
+
const assetPath = `${this.projectPath}/assets/${requireId(assetId, "Asset ID")}`;
|
|
447
|
+
return this.request("GET", `${assetPath}/timeline`, { query });
|
|
448
|
+
},
|
|
449
|
+
/** Yields every segment of an audio or video asset's findings timeline, in time order. */
|
|
450
|
+
iterateTimeline: (options) => {
|
|
451
|
+
checked("assets.iterateTimeline", options);
|
|
452
|
+
requireId(options?.assetId, "Asset ID");
|
|
453
|
+
return this.iteratePages((cursor) => this.buildAssets().listTimeline({
|
|
454
|
+
...options,
|
|
455
|
+
cursor
|
|
456
|
+
}));
|
|
457
|
+
},
|
|
361
458
|
/** Yields every child of an asset, fetching pages as needed. */
|
|
362
459
|
iterateChildren: (options) => {
|
|
363
460
|
checked("assets.iterateChildren", options);
|
|
@@ -368,45 +465,28 @@ sign: async (options) => {
|
|
|
368
465
|
}));
|
|
369
466
|
},
|
|
370
467
|
/**
|
|
371
|
-
* Uploads an asset and
|
|
372
|
-
* status
|
|
373
|
-
* `Idempotency-Key`.
|
|
468
|
+
* Uploads an asset and returns without waiting for its decision (`wait=false`), with
|
|
469
|
+
* `classification.status` `queued`. Retried safely with an `Idempotency-Key`.
|
|
374
470
|
*/
|
|
375
|
-
create: async (options) => this.submitAsset(checked("assets.create", options),
|
|
471
|
+
create: async (options) => this.submitAsset(checked("assets.create", options), false),
|
|
376
472
|
/**
|
|
377
473
|
* Uploads an asset and waits for its moderation decision. Audio and video still finish
|
|
378
474
|
* in the background. Retried safely with an `Idempotency-Key`.
|
|
379
475
|
*/
|
|
380
|
-
classify: async (
|
|
381
|
-
checked("assets.classify",
|
|
476
|
+
classify: async (classifyOptions) => {
|
|
477
|
+
const options = checked("assets.classify", classifyOptions);
|
|
382
478
|
if (options && "content" in options && "plainText" in options.content && (typeof options.content.plainText !== "string" || !options.content.plainText.trim())) throw require_CalmLensOptionKeys.invalidPayload("Text to classify must be a non-empty string");
|
|
383
|
-
return this.submitAsset(options,
|
|
479
|
+
return this.submitAsset(options, true);
|
|
384
480
|
},
|
|
385
481
|
/**
|
|
386
|
-
* Uploads the next part of a multipart upload.
|
|
387
|
-
*
|
|
482
|
+
* Uploads the next part of a multipart upload. Whether the final part waits for the
|
|
483
|
+
* decision was chosen when the upload started; pass `wait` to override it.
|
|
388
484
|
*/
|
|
389
485
|
uploadPart: async (partOptions) => {
|
|
390
486
|
const { assetId, ...options } = checked("assets.uploadPart", partOptions);
|
|
391
487
|
const encodedAssetId = requireId(assetId, "Asset ID");
|
|
392
488
|
return require_CalmLensOptionKeys.expectAsset(await this.#connection.uploadPart(`/assets/${encodedAssetId}/part`, options));
|
|
393
489
|
},
|
|
394
|
-
/**
|
|
395
|
-
* Creates a short-lived signed CDN URL, so browsers can load private content without
|
|
396
|
-
* an API key.
|
|
397
|
-
*/
|
|
398
|
-
createSignedUrl: async (signedUrlOptions) => {
|
|
399
|
-
const { assetId, ...options } = checked("assets.createSignedUrl", signedUrlOptions);
|
|
400
|
-
const encodedAssetId = requireId(assetId, "Asset ID");
|
|
401
|
-
require_ModerationContextLimits.validateSignedUrlOptions(options);
|
|
402
|
-
return this.request("POST", `/assets/${encodedAssetId}/signed-url`, { body: {
|
|
403
|
-
viewerClaims: options.viewerClaims,
|
|
404
|
-
resource: options.resource,
|
|
405
|
-
expiresInSeconds: options.expiresInSeconds ?? 900,
|
|
406
|
-
lens: options.lens,
|
|
407
|
-
transform: require_ModerationContextLimits.transformSelector(options.transform)
|
|
408
|
-
} });
|
|
409
|
-
},
|
|
410
490
|
/** Moves an asset into a folder, or to the project root with `folderId: null`. */
|
|
411
491
|
move: async (options) => {
|
|
412
492
|
const { assetId, folderId } = checked("assets.move", options);
|
|
@@ -432,20 +512,25 @@ sign: async (options) => {
|
|
|
432
512
|
return this.request("POST", `/assets/${requireId(assetId, "Asset ID")}/decision`, { body });
|
|
433
513
|
},
|
|
434
514
|
/**
|
|
435
|
-
* Completes the policy evidence behind a decided asset's moderation decision:
|
|
436
|
-
* `classification.moderation.
|
|
515
|
+
* Completes the policy evidence behind a decided asset's moderation decision: its
|
|
516
|
+
* `classification.moderation.explanationComplete` becomes `true` and every action stays as
|
|
437
517
|
* decided. With `rerun: true` the asset is moderated again with the project's current policy
|
|
438
|
-
* and
|
|
439
|
-
* (`asset/policy-changed`).
|
|
518
|
+
* and an `asset.rerun-requested` event is recorded; use it when the policy has changed since
|
|
519
|
+
* the decision (`asset/policy-changed`). The asset returns unchanged: it keeps its decision
|
|
520
|
+
* until the re-run's is stored, reported by `asset.classified` and `asset.<status>` events,
|
|
521
|
+
* and a failed re-run keeps it. A reviewed asset fails with `asset/reviewed`, and one whose
|
|
522
|
+
* content is gone with `asset/content-unavailable`.
|
|
440
523
|
*/
|
|
441
524
|
explain: async (options) => {
|
|
442
525
|
const { assetId, rerun } = checked("assets.explain", options);
|
|
443
526
|
return this.request("POST", `/assets/${requireId(assetId, "Asset ID")}/explain`, { body: rerun ? { rerun } : {} });
|
|
444
527
|
},
|
|
445
528
|
/**
|
|
446
|
-
* Waits until an asset
|
|
447
|
-
*
|
|
448
|
-
*
|
|
529
|
+
* Waits until an asset is settled, its `classification.status` `completed` (with its
|
|
530
|
+
* decision in `classification.moderation.status`) or `failed`, and returns that asset,
|
|
531
|
+
* checking every few seconds. A `queued` or `processing` asset is still waiting, even when a
|
|
532
|
+
* reviewer has already decided it. Rejects with `sdk/timeout` if it is not settled within
|
|
533
|
+
* `timeoutMs` (default 60000). Webhooks report decisions without polling.
|
|
449
534
|
*/
|
|
450
535
|
waitForDecision: async (waitOptions) => {
|
|
451
536
|
const { assetId, ...options } = checked("assets.waitForDecision", waitOptions);
|
|
@@ -458,11 +543,14 @@ sign: async (options) => {
|
|
|
458
543
|
* keeping the asset record, metadata and classification results. The returned asset has
|
|
459
544
|
* `content.status` set to `removed` and `content.removalReason` to `requested`; the CDN no longer serves it.
|
|
460
545
|
*/
|
|
461
|
-
|
|
462
|
-
const { assetId } = checked("assets.
|
|
546
|
+
removeContent: async (options) => {
|
|
547
|
+
const { assetId } = checked("assets.removeContent", options);
|
|
463
548
|
return this.request("DELETE", `/assets/${requireId(assetId, "Asset ID")}/content`);
|
|
464
549
|
},
|
|
465
|
-
/**
|
|
550
|
+
/**
|
|
551
|
+
* Deletes an asset record together with its stored content. An asset extracted from another
|
|
552
|
+
* (one with a `parentId`) fails with `asset/child-not-deletable`: delete its parent instead.
|
|
553
|
+
*/
|
|
466
554
|
delete: async (options) => {
|
|
467
555
|
const { assetId } = checked("assets.delete", options);
|
|
468
556
|
await this.request("DELETE", `/assets/${requireId(assetId, "Asset ID")}`);
|
|
@@ -470,10 +558,12 @@ sign: async (options) => {
|
|
|
470
558
|
/**
|
|
471
559
|
* Deletes up to 500 assets (`operation: "delete"`) or removes their stored content
|
|
472
560
|
* (`"remove-content"`) in one request. Every asset must exist in the project and the key
|
|
473
|
-
* needs `assets:delete` for its folder,
|
|
474
|
-
* `
|
|
475
|
-
* `
|
|
476
|
-
*
|
|
561
|
+
* needs `assets:delete` for its folder, and a deletion can't name an asset extracted from
|
|
562
|
+
* another (`asset/child-not-deletable`), or nothing is queued. Resolves with
|
|
563
|
+
* `{ batchId, status: "queued", assetCount }` once queued; the work runs in the background
|
|
564
|
+
* and records `asset.deleted` or `asset.content-removed` for each asset, with a `batch-id`
|
|
565
|
+
* fact naming `batchId`. Assets under a safety hold are skipped. Not retried: it carries no
|
|
566
|
+
* `Idempotency-Key`.
|
|
477
567
|
*/
|
|
478
568
|
batch: async (options) => {
|
|
479
569
|
const { assetIds, operation } = checked("assets.batch", options);
|
|
@@ -492,10 +582,18 @@ sign: async (options) => {
|
|
|
492
582
|
return {
|
|
493
583
|
/**
|
|
494
584
|
* Lists project events after a cursor, oldest first. Call without `cursor` to get a cursor
|
|
495
|
-
* for "now", then poll with each response's `nextCursor`. Webhook deliveries carry
|
|
496
|
-
*
|
|
585
|
+
* for "now", then poll with each response's `nextCursor`. Webhook deliveries carry each
|
|
586
|
+
* event's same fields as a flat JSON body. `types` and `assetId` narrow the feed to some
|
|
587
|
+
* event types or one asset's events; a cursor belongs to the filters it was issued with, so
|
|
588
|
+
* pass the same ones with each `cursor`.
|
|
497
589
|
*/
|
|
498
|
-
list: async (options = {}) =>
|
|
590
|
+
list: async (options = {}) => {
|
|
591
|
+
const { types, ...query } = checked("events.list", options);
|
|
592
|
+
return this.request("GET", `${this.projectPath}/events`, { query: {
|
|
593
|
+
...query,
|
|
594
|
+
types: types?.length ? types.join(",") : void 0
|
|
595
|
+
} });
|
|
596
|
+
},
|
|
499
597
|
/**
|
|
500
598
|
* Yields pages of events after `cursor` until no more are waiting. Save each page's
|
|
501
599
|
* `nextCursor` to resume later. Without `cursor`, yields one empty page whose `nextCursor`
|
|
@@ -533,10 +631,18 @@ sign: async (options) => {
|
|
|
533
631
|
get folders() {
|
|
534
632
|
return {
|
|
535
633
|
/**
|
|
536
|
-
* Lists one page of child folders, sorted by name unless `
|
|
634
|
+
* Lists one page of child folders, sorted by name unless `sort` says otherwise. Pass
|
|
537
635
|
* `nextCursor` as `cursor` for the next page; fetch a branch when it is opened.
|
|
538
636
|
*/
|
|
539
637
|
list: async (options = {}) => this.request("GET", `${this.projectPath}/folders`, { query: checked("folders.list", options) }),
|
|
638
|
+
/** Yields every child folder of `parentId` (or the project root), fetching pages as needed. */
|
|
639
|
+
iterate: (options = {}) => {
|
|
640
|
+
checked("folders.iterate", options);
|
|
641
|
+
return this.iteratePages((cursor) => this.folders.list({
|
|
642
|
+
...options,
|
|
643
|
+
cursor
|
|
644
|
+
}));
|
|
645
|
+
},
|
|
540
646
|
retrieve: async (options) => {
|
|
541
647
|
const { folderId } = checked("folders.retrieve", options);
|
|
542
648
|
return this.request("GET", `/folders/${requireId(folderId, "Folder ID")}`);
|
|
@@ -565,8 +671,16 @@ sign: async (options) => {
|
|
|
565
671
|
*/
|
|
566
672
|
get hashLists() {
|
|
567
673
|
return {
|
|
568
|
-
/** Lists one page of the project's hash lists, newest first. */
|
|
674
|
+
/** Lists one page of the project's hash lists, newest first unless `sort` says otherwise. */
|
|
569
675
|
list: async (options = {}) => this.request("GET", `${this.projectPath}/hash-lists`, { query: checked("hashLists.list", options) }),
|
|
676
|
+
/** Yields every hash list, fetching pages as needed. */
|
|
677
|
+
iterate: (options = {}) => {
|
|
678
|
+
checked("hashLists.iterate", options);
|
|
679
|
+
return this.iteratePages((cursor) => this.hashLists.list({
|
|
680
|
+
...options,
|
|
681
|
+
cursor
|
|
682
|
+
}));
|
|
683
|
+
},
|
|
570
684
|
retrieve: async (options) => {
|
|
571
685
|
const { hashListId } = checked("hashLists.retrieve", options);
|
|
572
686
|
return this.request("GET", `/hash-lists/${requireId(hashListId, "Hash list ID")}`);
|
|
@@ -582,7 +696,16 @@ sign: async (options) => {
|
|
|
582
696
|
const { hashListId } = checked("hashLists.delete", options);
|
|
583
697
|
await this.request("DELETE", `/hash-lists/${requireId(hashListId, "Hash list ID")}`);
|
|
584
698
|
},
|
|
585
|
-
/**
|
|
699
|
+
/** Yields every entry of a list, fetching pages as needed. */
|
|
700
|
+
iterateEntries: (options) => {
|
|
701
|
+
checked("hashLists.iterateEntries", options);
|
|
702
|
+
requireId(options?.hashListId, "Hash list ID");
|
|
703
|
+
return this.iteratePages((cursor) => this.hashLists.listEntries({
|
|
704
|
+
...options,
|
|
705
|
+
cursor
|
|
706
|
+
}));
|
|
707
|
+
},
|
|
708
|
+
/** Lists one page of a list's entries, newest first unless `sort` says otherwise. */
|
|
586
709
|
listEntries: async (options) => {
|
|
587
710
|
const { hashListId, ...query } = checked("hashLists.listEntries", options);
|
|
588
711
|
return this.request("GET", `/hash-lists/${requireId(hashListId, "Hash list ID")}/entries`, { query });
|
|
@@ -599,29 +722,42 @@ sign: async (options) => {
|
|
|
599
722
|
};
|
|
600
723
|
}
|
|
601
724
|
/**
|
|
602
|
-
* Moderation policies belong to the
|
|
603
|
-
*
|
|
604
|
-
*
|
|
725
|
+
* Moderation policies belong to the organisation and its projects share them. Every change sends
|
|
726
|
+
* the policy's `revision`, so a policy changed since is refused. Through a project's key you can
|
|
727
|
+
* change only policies no other project uses.
|
|
605
728
|
*/
|
|
606
729
|
get policies() {
|
|
607
|
-
const policyPath = (policyId) =>
|
|
730
|
+
const policyPath = (policyId) => `/policies/${requireId(policyId, "Policy ID")}`;
|
|
608
731
|
return {
|
|
609
|
-
/** Lists the organisation's policies
|
|
610
|
-
list: async () => this.request("GET",
|
|
732
|
+
/** Lists one page of the organisation's policies, oldest first unless `sort` says otherwise. */
|
|
733
|
+
list: async (options = {}) => this.request("GET", "/policies", { query: checked("policies.list", options) }),
|
|
734
|
+
/** Yields every policy of the organisation, fetching pages as needed. */
|
|
735
|
+
iterate: (options = {}) => {
|
|
736
|
+
checked("policies.iterate", options);
|
|
737
|
+
return this.iteratePages((cursor) => this.policies.list({
|
|
738
|
+
...options,
|
|
739
|
+
cursor
|
|
740
|
+
}));
|
|
741
|
+
},
|
|
611
742
|
retrieve: async (options) => this.request("GET", policyPath(checked("policies.retrieve", options).policyId)),
|
|
612
743
|
/** Creates a policy from `settings`, or a copy of a built-in preset with `presetId`. */
|
|
613
|
-
create: async (options) => this.request("POST",
|
|
744
|
+
create: async (options) => this.request("POST", "/policies", { body: checked("policies.create", options) }),
|
|
614
745
|
/** Changes the name, description or settings; later moderation uses them. */
|
|
615
746
|
update: async (options) => {
|
|
616
747
|
const { policyId, ...body } = checked("policies.update", options);
|
|
617
748
|
return this.request("PATCH", policyPath(policyId), { body });
|
|
618
749
|
},
|
|
619
|
-
/**
|
|
620
|
-
|
|
621
|
-
const { policyId, ...body } = checked("policies.
|
|
622
|
-
return this.request("POST", `${policyPath(policyId)}/
|
|
750
|
+
/** Restores the settings of the preset release a `pinned` or `copy` policy is pinned to. */
|
|
751
|
+
reset: async (options) => {
|
|
752
|
+
const { policyId, ...body } = checked("policies.reset", options);
|
|
753
|
+
return this.request("POST", `${policyPath(policyId)}/reset`, { body });
|
|
623
754
|
},
|
|
624
|
-
/**
|
|
755
|
+
/** Moves an unchanged `pinned` or `copy` policy to the latest release of its preset. */
|
|
756
|
+
upgrade: async (options) => {
|
|
757
|
+
const { policyId, ...body } = checked("policies.upgrade", options);
|
|
758
|
+
return this.request("POST", `${policyPath(policyId)}/upgrade`, { body });
|
|
759
|
+
},
|
|
760
|
+
/** Switches automatic updates on (`live`) or off (`pinned`) for the organisation's own preset policy. */
|
|
625
761
|
setAutomaticUpdates: async (options) => {
|
|
626
762
|
const { policyId, ...body } = checked("policies.setAutomaticUpdates", options);
|
|
627
763
|
return this.request("PUT", `${policyPath(policyId)}/automatic-updates`, { body });
|
|
@@ -630,13 +766,58 @@ sign: async (options) => {
|
|
|
630
766
|
delete: async (options) => {
|
|
631
767
|
await this.request("DELETE", policyPath(checked("policies.delete", options).policyId));
|
|
632
768
|
},
|
|
769
|
+
/** The policy the project moderates with. */
|
|
770
|
+
retrieveAssigned: async () => this.request("GET", `${this.projectPath}/policy`),
|
|
633
771
|
/** Chooses the policy the project moderates with. */
|
|
634
772
|
assign: async (options) => this.request("PUT", `${this.projectPath}/policy`, { body: checked("policies.assign", options) })
|
|
635
773
|
};
|
|
636
774
|
}
|
|
637
775
|
/**
|
|
638
|
-
*
|
|
639
|
-
*
|
|
776
|
+
* The project's lenses: named image transforms the CDN applies at `/@<identifier>`. The CDN
|
|
777
|
+
* serves files made with each lens's current definition. `ensureLenses` creates or changes
|
|
778
|
+
* lenses by identifier, for applications that declare theirs in code.
|
|
779
|
+
*/
|
|
780
|
+
get lenses() {
|
|
781
|
+
const lensPath = (lensId) => `/lenses/${requireId(lensId, "Lens ID")}`;
|
|
782
|
+
const forget = (matches) => {
|
|
783
|
+
for (const [cacheKey, lens] of this.#lenses.ensuredLenses) if (matches(lens)) this.#lenses.ensuredLenses.delete(cacheKey);
|
|
784
|
+
};
|
|
785
|
+
return {
|
|
786
|
+
/** Lists one page of the project's lenses, newest first unless `sort` says otherwise. */
|
|
787
|
+
list: async (options = {}) => this.request("GET", `${this.projectPath}/lenses`, { query: checked("lenses.list", options) }),
|
|
788
|
+
/** Yields every lens of the project, fetching pages as needed. */
|
|
789
|
+
iterate: (options = {}) => {
|
|
790
|
+
checked("lenses.iterate", options);
|
|
791
|
+
return this.iteratePages((cursor) => this.lenses.list({
|
|
792
|
+
...options,
|
|
793
|
+
cursor
|
|
794
|
+
}));
|
|
795
|
+
},
|
|
796
|
+
/** Creates a lens; its identifier must be new to the project. */
|
|
797
|
+
create: async (options) => {
|
|
798
|
+
const lens = await this.request("POST", `${this.projectPath}/lenses`, { body: checked("lenses.create", options) });
|
|
799
|
+
forget((cached) => cached.identifier === lens.identifier);
|
|
800
|
+
return lens;
|
|
801
|
+
},
|
|
802
|
+
retrieve: async (options) => this.request("GET", lensPath(checked("lenses.retrieve", options).lensId)),
|
|
803
|
+
/** Changes a lens's name, description, type, transform or whether the CDN serves it. */
|
|
804
|
+
update: async (options) => {
|
|
805
|
+
const { lensId, ...body } = checked("lenses.update", options);
|
|
806
|
+
const lens = await this.request("PATCH", lensPath(lensId), { body });
|
|
807
|
+
forget((cached) => cached.id === lens.id);
|
|
808
|
+
return lens;
|
|
809
|
+
},
|
|
810
|
+
/** Deletes a lens; URLs that select it stop being served. */
|
|
811
|
+
delete: async (options) => {
|
|
812
|
+
const { lensId } = checked("lenses.delete", options);
|
|
813
|
+
await this.request("DELETE", lensPath(lensId));
|
|
814
|
+
forget((cached) => cached.id === lensId);
|
|
815
|
+
}
|
|
816
|
+
};
|
|
817
|
+
}
|
|
818
|
+
/**
|
|
819
|
+
* Creates a named lens, or changes it to this definition. Sending the same definition again
|
|
820
|
+
* returns the lens unchanged, from the client's lens cache once it has seen it.
|
|
640
821
|
*/
|
|
641
822
|
async ensureLens(options) {
|
|
642
823
|
checked("ensureLens", options);
|
|
@@ -647,7 +828,7 @@ sign: async (options) => {
|
|
|
647
828
|
/**
|
|
648
829
|
* Create or update several named lenses. New definitions are sent in one API request, or in
|
|
649
830
|
* consecutive requests of at most {@link ENSURE_LENSES_MAX_PER_REQUEST} definitions, in order.
|
|
650
|
-
* Each lens
|
|
831
|
+
* Each lens is created or changed as ensureLens() does.
|
|
651
832
|
*/
|
|
652
833
|
async ensureLenses(options) {
|
|
653
834
|
const { lenses } = checked("ensureLenses", options);
|
|
@@ -726,6 +907,30 @@ Object.defineProperty(exports, "WEBHOOK_TIMESTAMP_HEADER", {
|
|
|
726
907
|
return WEBHOOK_TIMESTAMP_HEADER;
|
|
727
908
|
}
|
|
728
909
|
});
|
|
910
|
+
Object.defineProperty(exports, "decodeUploadToken", {
|
|
911
|
+
enumerable: true,
|
|
912
|
+
get: function() {
|
|
913
|
+
return decodeUploadToken;
|
|
914
|
+
}
|
|
915
|
+
});
|
|
916
|
+
Object.defineProperty(exports, "getEventFact", {
|
|
917
|
+
enumerable: true,
|
|
918
|
+
get: function() {
|
|
919
|
+
return getEventFact;
|
|
920
|
+
}
|
|
921
|
+
});
|
|
922
|
+
Object.defineProperty(exports, "getEventFacts", {
|
|
923
|
+
enumerable: true,
|
|
924
|
+
get: function() {
|
|
925
|
+
return getEventFacts;
|
|
926
|
+
}
|
|
927
|
+
});
|
|
928
|
+
Object.defineProperty(exports, "isNewerAssetEvent", {
|
|
929
|
+
enumerable: true,
|
|
930
|
+
get: function() {
|
|
931
|
+
return isNewerAssetEvent;
|
|
932
|
+
}
|
|
933
|
+
});
|
|
729
934
|
Object.defineProperty(exports, "isTestWebhookEvent", {
|
|
730
935
|
enumerable: true,
|
|
731
936
|
get: function() {
|