calmlens 0.25.0 → 0.27.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -15
- package/bin/calmlens.js +2383 -677
- package/cjs/{BrowserUpload-AO2-2U5Z.js → BrowserUpload-CTqIjCV5.js} +1 -1
- package/{esm/BrowserUpload-D2lemMIU.d.ts → cjs/BrowserUpload-D4sEmd0X.d.ts} +2 -2
- package/{esm/CalmLensAppClient-Dt0t9Bk6.d.ts → cjs/CalmLensAppClient-CCeFnKX8.d.ts} +5 -11
- package/cjs/{CalmLensAppClient-nv6qwja0.js → CalmLensAppClient-CZm-9g22.js} +23 -16
- package/cjs/{CalmLensOptionKeys-BvCac9NO.js → CalmLensOptionKeys-C1w3SqmL.js} +165 -95
- package/cjs/CalmLensServerClient-B7PfocET.d.ts +346 -0
- package/cjs/{CalmLensServerClient-B60kCBCR.js → CalmLensServerClient-ucq3ITjd.js} +281 -315
- package/cjs/{CalmLensTypes-BhR7LFDu.d.ts → CalmLensTypes-HUERg5hI.d.ts} +142 -155
- package/cjs/{Classification-CxRedzgH-C9qlYW_J.d.ts → Classification-CMM2tZpJ-IdIh63n0.d.ts} +6 -7
- package/cjs/{Core-Cw4IxFUq.js → Core-D-1KCqT7.js} +39 -16
- package/cjs/{Core-DSMxC2GL.d.ts → Core-DXAs8mcx.d.ts} +10 -3
- package/{esm/ModerationContextLimits-Bqr0duav.js → cjs/ModerationContextLimits-BcYKgU2X.js} +859 -44
- package/cjs/ReactUpload-BTciTpwB.d.ts +27 -0
- package/cjs/{ReactUpload--oDFltw2.js → ReactUpload-BymgWiC8.js} +38 -2
- package/cjs/{TestTriggers-CiFcTHX3-BmfH4J3f.js → TestTriggers-Cvi7e2KA-DcT1pc_W.js} +91 -22
- package/{esm/TestTriggers-BJ4B-MXR-D1tGifPU.d.ts → cjs/TestTriggers-Dnukm-jm-DoEB7jJc.d.ts} +1 -1
- package/cjs/{UploadController-ObdgTaBl.js → UploadController-C8GPbDKI.js} +16 -3
- package/{esm/WebhookPayload-DLGGOGW6.d.ts → cjs/WebhookPayload-mUmOFH55.d.ts} +152 -9
- package/cjs/app.d.ts +6 -6
- package/cjs/app.js +20 -2
- package/cjs/elements.d.ts +5 -5
- package/cjs/elements.js +105 -68
- package/cjs/{index-AAWuerkU.d.ts → index-Ck7x1YjM.d.ts} +3 -3
- package/cjs/index.d.ts +5 -5
- package/cjs/index.js +19 -1
- package/cjs/react-native.d.ts +3 -3
- package/cjs/react-native.js +7 -5
- package/cjs/react.d.ts +5 -4
- package/cjs/react.js +11 -15
- package/cjs/server.d.ts +6 -6
- package/cjs/server.js +20 -2
- package/cjs/test-inputs.d.ts +1 -1
- package/cjs/test-inputs.js +13 -13
- package/cjs/testing.d.ts +18 -21
- package/cjs/testing.js +99 -147
- package/cjs/{ui-CcuGKTcL.d.ts → ui-BfJNO3c6.d.ts} +2 -2
- package/cjs/{ui-CA16jyfZ.js → ui-CW8BqtZk.js} +7 -5
- package/cjs/ui.d.ts +3 -3
- package/cjs/ui.js +4 -3
- package/cjs/vue.d.ts +15 -8
- package/cjs/vue.js +30 -17
- package/esm/{BrowserUpload-Co4T6uGk.js → BrowserUpload-C01iLeOs.js} +1 -1
- package/{cjs/BrowserUpload-D2lemMIU.d.ts → esm/BrowserUpload-D4sEmd0X.d.ts} +2 -2
- package/{cjs/CalmLensAppClient-Dt0t9Bk6.d.ts → esm/CalmLensAppClient-CCeFnKX8.d.ts} +5 -11
- package/esm/{CalmLensAppClient-BRzy4dwn.js → CalmLensAppClient-CgDogQQC.js} +23 -16
- package/esm/{CalmLensOptionKeys-bE3rb5PN.js → CalmLensOptionKeys-CEwNbpEz.js} +160 -96
- package/esm/CalmLensServerClient-B7PfocET.d.ts +346 -0
- package/esm/{CalmLensServerClient-_PRi90wI.js → CalmLensServerClient-TT6zrAG5.js} +281 -315
- package/esm/{CalmLensTypes-BhR7LFDu.d.ts → CalmLensTypes-HUERg5hI.d.ts} +142 -155
- package/esm/{Classification-CxRedzgH-C9qlYW_J.d.ts → Classification-CMM2tZpJ-IdIh63n0.d.ts} +6 -7
- package/esm/{Core-CtbYmeXG.js → Core-CP6NaqJz.js} +39 -16
- package/esm/{Core-DSMxC2GL.d.ts → Core-DXAs8mcx.d.ts} +10 -3
- package/{cjs/ModerationContextLimits-Cn9RvnZH.js → esm/ModerationContextLimits-BmV8QD32.js} +476 -301
- package/esm/{ReactUpload-B5itHBSF.js → ReactUpload-B72Oq3qE.js} +34 -4
- package/esm/ReactUpload-BTciTpwB.d.ts +27 -0
- package/esm/{TestTriggers-CiFcTHX3-BK2-sgOC.js → TestTriggers-Cvi7e2KA-BA83CRJb.js} +87 -23
- package/{cjs/TestTriggers-BJ4B-MXR-D1tGifPU.d.ts → esm/TestTriggers-Dnukm-jm-DoEB7jJc.d.ts} +1 -1
- package/esm/{UploadController-C7fL3Iz9.js → UploadController-Q7xTqh5w.js} +11 -4
- package/{cjs/WebhookPayload-DLGGOGW6.d.ts → esm/WebhookPayload-mUmOFH55.d.ts} +152 -9
- package/esm/app.d.ts +6 -6
- package/esm/app.js +3 -3
- package/esm/elements.d.ts +5 -5
- package/esm/elements.js +105 -69
- package/esm/{index-AAWuerkU.d.ts → index-Ck7x1YjM.d.ts} +3 -3
- package/esm/index.d.ts +5 -5
- package/esm/index.js +1 -1
- package/esm/react-native.d.ts +3 -3
- package/esm/react-native.js +6 -6
- package/esm/react.d.ts +5 -4
- package/esm/react.js +10 -16
- package/esm/server.d.ts +6 -6
- package/esm/server.js +3 -3
- package/esm/styles.css +37 -14
- package/esm/svelte/CalmLensAsset.svelte +1 -1
- package/esm/svelte/CalmLensUploader.svelte +17 -17
- package/esm/svelte/context.js +21 -0
- package/esm/svelte/index.d.ts +12 -0
- package/esm/svelte/index.js +1 -0
- package/esm/test-inputs.d.ts +1 -1
- package/esm/test-inputs.js +1 -1
- package/esm/testing.d.ts +18 -21
- package/esm/testing.js +93 -141
- package/esm/{ui-B98AucZA.js → ui-BBDJJkFL.js} +7 -5
- package/esm/{ui-CcuGKTcL.d.ts → ui-BfJNO3c6.d.ts} +2 -2
- package/esm/ui.d.ts +3 -3
- package/esm/ui.js +4 -4
- package/esm/vue.d.ts +15 -8
- package/esm/vue.js +30 -19
- package/package.json +16 -6
- package/cjs/CalmLensServerClient-7XjQaeKu.d.ts +0 -353
- package/cjs/ReactUpload-CW4NzAsh.d.ts +0 -17
- package/esm/CalmLensServerClient-7XjQaeKu.d.ts +0 -353
- package/esm/ReactUpload-CW4NzAsh.d.ts +0 -17
package/esm/testing.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { A as
|
|
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-
|
|
3
|
-
import {
|
|
1
|
+
import { A as normalizeUploadMimeType, D as MAX_IMAGE_UPLOAD_BYTES, M as sleep, S as validateAppClientOptions, Y as CalmLensError, _ as randomUuid, ct as invalidConfig, f as checkTransformOptions, h as parseTransformSelector, k as getRejectedUploadMimeTypeError, lt as API_ERROR_CODES, m as isAcceptedUploadMimeType, ot as SDK_ERROR_CODES, r as selectModerationContextItems, st as invalidArgument, ut as API_ERROR_DEFINITIONS, w as validateServerClientOptions } from "./ModerationContextLimits-BmV8QD32.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-TT6zrAG5.js";
|
|
3
|
+
import { _ as validateAssetPayload, a as MOCK_HOOKS, g as assetToData, h as assetDataToUint8Array } from "./CalmLensOptionKeys-CEwNbpEz.js";
|
|
4
4
|
import { t as hmacSha256Hex } from "./CryptoUtils-B_x8lMIx-DhuWGzqn.js";
|
|
5
|
-
import { t as CalmLensAppClient } from "./CalmLensAppClient-
|
|
6
|
-
import {
|
|
7
|
-
import { d as getTestInputTag,
|
|
5
|
+
import { t as CalmLensAppClient } from "./CalmLensAppClient-CgDogQQC.js";
|
|
6
|
+
import { o as placeholderHashToDataURL, r as isFileAccepted } from "./UploadController-Q7xTqh5w.js";
|
|
7
|
+
import { d as getTestInputTag, h as CLASSIFICATION_CATEGORIES, m as lazySchema } from "./TestTriggers-Cvi7e2KA-BA83CRJb.js";
|
|
8
8
|
import * as zod from "zod";
|
|
9
9
|
// src/contract/MediaTestTriggers.js
|
|
10
10
|
const MEDIA_TEST_SIGNALS = [...CLASSIFICATION_CATEGORIES, "violence.graphic"];
|
|
@@ -31,7 +31,7 @@ async function generateMediaTestCode(signal, testInputKey) {
|
|
|
31
31
|
if (!MEDIA_TEST_SIGNALS.includes(signal)) throw new RangeError("Unsupported media test signal");
|
|
32
32
|
return `Calm Lens test ${[...await getTestInputTag("media", signal, testInputKey)].map((character) => HEX_WORDS[Number.parseInt(character, 16)]).join(" ")} ${signal.replace(/[.-]/g, " ")} end test`;
|
|
33
33
|
}
|
|
34
|
-
// src/contract/Ids-
|
|
34
|
+
// src/contract/Ids-C2cLdFM0.js
|
|
35
35
|
var __defProp = Object.defineProperty;
|
|
36
36
|
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod, mod.exports), cb = null), mod.exports);
|
|
37
37
|
var __exportAll = (all, no_symbols) => {
|
|
@@ -4266,7 +4266,7 @@ function registry() {
|
|
|
4266
4266
|
return new $ZodRegistry();
|
|
4267
4267
|
}
|
|
4268
4268
|
(_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
|
|
4269
|
-
const globalRegistry = globalThis.__zod_globalRegistry;
|
|
4269
|
+
const globalRegistry$1 = globalThis.__zod_globalRegistry;
|
|
4270
4270
|
function snapshotChecks(def) {
|
|
4271
4271
|
if (def.checks) def.checks = [...def.checks];
|
|
4272
4272
|
return def;
|
|
@@ -5004,8 +5004,8 @@ function _check(fn, params) {
|
|
|
5004
5004
|
function describe$1(description) {
|
|
5005
5005
|
const ch = new $ZodCheck({ check: "describe" });
|
|
5006
5006
|
ch._zod.onattach = [(inst) => {
|
|
5007
|
-
const existing = globalRegistry.get(inst) ?? {};
|
|
5008
|
-
globalRegistry.add(inst, {
|
|
5007
|
+
const existing = globalRegistry$1.get(inst) ?? {};
|
|
5008
|
+
globalRegistry$1.add(inst, {
|
|
5009
5009
|
...existing,
|
|
5010
5010
|
description
|
|
5011
5011
|
});
|
|
@@ -5017,8 +5017,8 @@ function describe$1(description) {
|
|
|
5017
5017
|
function meta$1(metadata) {
|
|
5018
5018
|
const ch = new $ZodCheck({ check: "meta" });
|
|
5019
5019
|
ch._zod.onattach = [(inst) => {
|
|
5020
|
-
const existing = globalRegistry.get(inst) ?? {};
|
|
5021
|
-
globalRegistry.add(inst, {
|
|
5020
|
+
const existing = globalRegistry$1.get(inst) ?? {};
|
|
5021
|
+
globalRegistry$1.add(inst, {
|
|
5022
5022
|
...existing,
|
|
5023
5023
|
...metadata
|
|
5024
5024
|
});
|
|
@@ -5114,7 +5114,7 @@ function initializeContext(params) {
|
|
|
5114
5114
|
if (target === "draft-7") target = "draft-07";
|
|
5115
5115
|
return {
|
|
5116
5116
|
processors: params.processors ?? {},
|
|
5117
|
-
metadataRegistry: params?.metadata ?? globalRegistry,
|
|
5117
|
+
metadataRegistry: params?.metadata ?? globalRegistry$1,
|
|
5118
5118
|
target,
|
|
5119
5119
|
unrepresentable: params?.unrepresentable ?? "throw",
|
|
5120
5120
|
override: params?.override ?? (() => {}),
|
|
@@ -6470,13 +6470,13 @@ const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
|
|
|
6470
6470
|
},
|
|
6471
6471
|
describe(description) {
|
|
6472
6472
|
const cl = this.clone();
|
|
6473
|
-
globalRegistry.add(cl, { description });
|
|
6473
|
+
globalRegistry$1.add(cl, { description });
|
|
6474
6474
|
return cl;
|
|
6475
6475
|
},
|
|
6476
6476
|
meta(...args) {
|
|
6477
|
-
if (args.length === 0) return globalRegistry.get(this);
|
|
6477
|
+
if (args.length === 0) return globalRegistry$1.get(this);
|
|
6478
6478
|
const cl = this.clone();
|
|
6479
|
-
globalRegistry.add(cl, args[0]);
|
|
6479
|
+
globalRegistry$1.add(cl, args[0]);
|
|
6480
6480
|
return cl;
|
|
6481
6481
|
},
|
|
6482
6482
|
isOptional() {
|
|
@@ -6552,7 +6552,7 @@ const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
|
|
|
6552
6552
|
return createToJSONSchemaMethod(this, {})(params);
|
|
6553
6553
|
},
|
|
6554
6554
|
get description() {
|
|
6555
|
-
return globalRegistry.get(this)?.description;
|
|
6555
|
+
return globalRegistry$1.get(this)?.description;
|
|
6556
6556
|
},
|
|
6557
6557
|
get _def() {
|
|
6558
6558
|
return this._zod.def;
|
|
@@ -7828,6 +7828,14 @@ ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
|
7828
7828
|
...schemas_exports,
|
|
7829
7829
|
...checks_exports
|
|
7830
7830
|
});
|
|
7831
|
+
const createMetaType = (type) => {
|
|
7832
|
+
return Object.assign((value) => {
|
|
7833
|
+
return {
|
|
7834
|
+
type,
|
|
7835
|
+
data: value ?? {}
|
|
7836
|
+
};
|
|
7837
|
+
}, type);
|
|
7838
|
+
};
|
|
7831
7839
|
(/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
7832
7840
|
const CHARS_GLOBAL_BACKSLASH_SUPPORTED_RX = /[\0\b\t\n\r\x1a"'\\]/g;
|
|
7833
7841
|
const CHARS_ESCAPE_BACKSLASH_SUPPORTED_MAP = {
|
|
@@ -7884,6 +7892,39 @@ ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
|
7884
7892
|
}
|
|
7885
7893
|
module.exports = escapeString;
|
|
7886
7894
|
})))();
|
|
7895
|
+
const isZodTypeExtends = (type, zodType) => {
|
|
7896
|
+
if (type instanceof zodType) return type;
|
|
7897
|
+
if (type.def.type === "union") {
|
|
7898
|
+
for (const option of type.def.options) if (isZodTypeExtends(option, zodType)) return option;
|
|
7899
|
+
return false;
|
|
7900
|
+
}
|
|
7901
|
+
const rootType = type.def.innerType ?? type.def.in;
|
|
7902
|
+
if (rootType) return isZodTypeExtends(rootType, zodType);
|
|
7903
|
+
return false;
|
|
7904
|
+
};
|
|
7905
|
+
createMetaType({
|
|
7906
|
+
id: "foreignKey",
|
|
7907
|
+
check: (type) => {
|
|
7908
|
+
if (isZodTypeExtends(type, zod.ZodString) || isZodTypeExtends(type, zod.ZodNumber)) return { success: true };
|
|
7909
|
+
return {
|
|
7910
|
+
success: false,
|
|
7911
|
+
message: "Foreign key must be a string or number"
|
|
7912
|
+
};
|
|
7913
|
+
}
|
|
7914
|
+
});
|
|
7915
|
+
createMetaType({
|
|
7916
|
+
id: "primaryKey",
|
|
7917
|
+
check: (type) => {
|
|
7918
|
+
if (isZodTypeExtends(type, zod.ZodString) || isZodTypeExtends(type, zod.ZodNumber)) return { success: true };
|
|
7919
|
+
return {
|
|
7920
|
+
success: false,
|
|
7921
|
+
message: "Primary key must be a string or number"
|
|
7922
|
+
};
|
|
7923
|
+
}
|
|
7924
|
+
});
|
|
7925
|
+
createMetaType({ id: "updatedAt" });
|
|
7926
|
+
createMetaType({ id: "monotonicTimestamp" });
|
|
7927
|
+
createMetaType({ id: "backfill" });
|
|
7887
7928
|
/**
|
|
7888
7929
|
* The prefix of every kind of object customers can see, so an ID says what it identifies:
|
|
7889
7930
|
* `proj_8fK2mQx7Lp4NvB3tRz9Y` is a project. Rows that never leave the backend (usage meters, upload
|
|
@@ -7987,8 +8028,8 @@ const EXAMPLE_IDS = {
|
|
|
7987
8028
|
* across the packages that build records from plain strings).
|
|
7988
8029
|
*/
|
|
7989
8030
|
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-
|
|
7991
|
-
const ACTION_SCHEMA = zod.enum([
|
|
8031
|
+
// src/contract/Permissions-CzuRcPMS.js
|
|
8032
|
+
const ACTION_SCHEMA = /* @__PURE__ */ lazySchema(() => zod.enum([
|
|
7992
8033
|
"assets:read",
|
|
7993
8034
|
"assets:download",
|
|
7994
8035
|
"assets:create",
|
|
@@ -8020,7 +8061,7 @@ const ACTION_SCHEMA = zod.enum([
|
|
|
8020
8061
|
"reviews:read",
|
|
8021
8062
|
"reviews:write",
|
|
8022
8063
|
"project:manage"
|
|
8023
|
-
]);
|
|
8064
|
+
]));
|
|
8024
8065
|
const PROJECT_ACTIONS = [...[
|
|
8025
8066
|
"settings",
|
|
8026
8067
|
"members",
|
|
@@ -8036,19 +8077,12 @@ const PROJECT_ACTIONS = [...[
|
|
|
8036
8077
|
const isProjectAction = (action) => PROJECT_ACTIONS.includes(action);
|
|
8037
8078
|
/** The actions that include `action`: its feature's write action and project:manage. */
|
|
8038
8079
|
const actionsImplying = (action) => !isProjectAction(action) || action === "project:manage" ? [] : action.endsWith(":read") ? [action.replace(/:read$/, ":write"), "project:manage"] : ["project:manage"];
|
|
8039
|
-
const GRANT_SCHEMA = zod.object({
|
|
8080
|
+
const GRANT_SCHEMA = /* @__PURE__ */ lazySchema(() => zod.object({
|
|
8040
8081
|
actions: zod.array(ACTION_SCHEMA),
|
|
8041
8082
|
folderId: idField("fldr").nullable(),
|
|
8042
8083
|
includeSubfolders: zod.boolean()
|
|
8043
|
-
}).strict().refine((g) => g.folderId === null || !g.actions.some(isProjectAction), "Project configuration permissions require project scope");
|
|
8044
|
-
const GRANTS_SCHEMA = zod.array(GRANT_SCHEMA).max(100);
|
|
8045
|
-
zod.enum([
|
|
8046
|
-
"admin",
|
|
8047
|
-
"configurator",
|
|
8048
|
-
"editor",
|
|
8049
|
-
"viewer",
|
|
8050
|
-
"custom"
|
|
8051
|
-
]);
|
|
8084
|
+
}).strict().refine((g) => g.folderId === null || !g.actions.some(isProjectAction), "Project configuration permissions require project scope"));
|
|
8085
|
+
const GRANTS_SCHEMA = /* @__PURE__ */ lazySchema(() => zod.array(GRANT_SCHEMA).max(100));
|
|
8052
8086
|
[...ACTION_SCHEMA.options.filter((a) => !isProjectAction(a))];
|
|
8053
8087
|
[...ACTION_SCHEMA.options.filter((a) => !isProjectAction(a))];
|
|
8054
8088
|
const permits = (grants, action, folderId, folders) => grants.some((grant) => {
|
|
@@ -8064,14 +8098,6 @@ const permits = (grants, action, folderId, folders) => grants.some((grant) => {
|
|
|
8064
8098
|
}
|
|
8065
8099
|
return false;
|
|
8066
8100
|
});
|
|
8067
|
-
/**
|
|
8068
|
-
* What a person can let an AI assistant or the CLI do for them. `read` looks at assets, folders,
|
|
8069
|
-
* hash lists and events; `write` also creates, changes and deletes assets, folders and hash lists.
|
|
8070
|
-
* Members, API keys, connectors, sharing, downloads and project settings are never delegated.
|
|
8071
|
-
*/
|
|
8072
|
-
const AGENT_SCOPE_SCHEMA = zod.enum(["read", "write"]);
|
|
8073
|
-
zod.array(AGENT_SCOPE_SCHEMA).min(1).max(2);
|
|
8074
|
-
zod.enum(["active", "banned"]);
|
|
8075
8101
|
// src/testing/MockApiKey.ts
|
|
8076
8102
|
const MOCK_API_KEY_PREFIX = "sk_test_";
|
|
8077
8103
|
const toBase64Url = (value) => btoa(value).replaceAll("+", "-").replaceAll("/", "_").replaceAll("=", "");
|
|
@@ -8664,9 +8690,9 @@ const MOCK_ASSET_FILTER_FIELDS = {
|
|
|
8664
8690
|
"=out="
|
|
8665
8691
|
]
|
|
8666
8692
|
},
|
|
8667
|
-
"classification.moderation.
|
|
8693
|
+
"classification.moderation.decision": {
|
|
8668
8694
|
kind: "text",
|
|
8669
|
-
nullable:
|
|
8695
|
+
nullable: true,
|
|
8670
8696
|
operators: [
|
|
8671
8697
|
"==",
|
|
8672
8698
|
"!=",
|
|
@@ -9061,7 +9087,7 @@ const searchFieldValues = (asset) => [
|
|
|
9061
9087
|
["type", asset.type],
|
|
9062
9088
|
["content.format", asset.content?.format ?? ""],
|
|
9063
9089
|
["content.extension", asset.content?.extension ?? ""],
|
|
9064
|
-
["classification.moderation.
|
|
9090
|
+
["classification.moderation.decision", asset.classification.moderation.decision ?? "pending"]
|
|
9065
9091
|
];
|
|
9066
9092
|
/** The API's keyword score for the whole lowercased query. */
|
|
9067
9093
|
const keywordScore = (values, query) => {
|
|
@@ -9116,21 +9142,17 @@ const REVIEW_DECISIONS = [
|
|
|
9116
9142
|
*/
|
|
9117
9143
|
const MOCK_OPERATIONS = [
|
|
9118
9144
|
"assets.list",
|
|
9119
|
-
"assets.iterate",
|
|
9120
9145
|
"assets.search",
|
|
9121
9146
|
"assets.retrieve",
|
|
9122
9147
|
"assets.waitForDecision",
|
|
9123
9148
|
"assets.update",
|
|
9124
9149
|
"assets.listChildren",
|
|
9125
|
-
"assets.iterateChildren",
|
|
9126
9150
|
"assets.listTimeline",
|
|
9127
|
-
"assets.iterateTimeline",
|
|
9128
9151
|
"assets.create",
|
|
9129
9152
|
"assets.classify",
|
|
9130
9153
|
"assets.uploadPart",
|
|
9131
9154
|
"assets.move",
|
|
9132
9155
|
"assets.retry",
|
|
9133
|
-
"assets.explain",
|
|
9134
9156
|
"assets.decide",
|
|
9135
9157
|
"assets.removeContent",
|
|
9136
9158
|
"assets.delete",
|
|
@@ -9140,26 +9162,21 @@ const MOCK_OPERATIONS = [
|
|
|
9140
9162
|
"cdn.getAssetInfo",
|
|
9141
9163
|
"cdn.signAssetUrl",
|
|
9142
9164
|
"events.list",
|
|
9143
|
-
"events.pages",
|
|
9144
9165
|
"folders.list",
|
|
9145
|
-
"folders.iterate",
|
|
9146
9166
|
"folders.retrieve",
|
|
9147
9167
|
"folders.create",
|
|
9148
9168
|
"folders.update",
|
|
9149
9169
|
"folders.delete",
|
|
9150
9170
|
"folders.move",
|
|
9151
9171
|
"hashLists.list",
|
|
9152
|
-
"hashLists.iterate",
|
|
9153
9172
|
"hashLists.retrieve",
|
|
9154
9173
|
"hashLists.create",
|
|
9155
9174
|
"hashLists.update",
|
|
9156
9175
|
"hashLists.delete",
|
|
9157
9176
|
"hashLists.listEntries",
|
|
9158
|
-
"hashLists.iterateEntries",
|
|
9159
9177
|
"hashLists.addEntry",
|
|
9160
9178
|
"hashLists.removeEntry",
|
|
9161
9179
|
"policies.list",
|
|
9162
|
-
"policies.iterate",
|
|
9163
9180
|
"policies.retrieve",
|
|
9164
9181
|
"policies.create",
|
|
9165
9182
|
"policies.update",
|
|
@@ -9170,7 +9187,6 @@ const MOCK_OPERATIONS = [
|
|
|
9170
9187
|
"policies.retrieveAssigned",
|
|
9171
9188
|
"policies.assign",
|
|
9172
9189
|
"lenses.list",
|
|
9173
|
-
"lenses.iterate",
|
|
9174
9190
|
"lenses.create",
|
|
9175
9191
|
"lenses.retrieve",
|
|
9176
9192
|
"lenses.update",
|
|
@@ -9178,7 +9194,6 @@ const MOCK_OPERATIONS = [
|
|
|
9178
9194
|
"ensureLens",
|
|
9179
9195
|
"ensureLenses",
|
|
9180
9196
|
"uploadPresets.list",
|
|
9181
|
-
"uploadPresets.iterate",
|
|
9182
9197
|
"uploadPresets.ensure",
|
|
9183
9198
|
"uploadPresets.delete",
|
|
9184
9199
|
"projectSettings.get",
|
|
@@ -9236,7 +9251,7 @@ const toEventAsset = (asset) => ({
|
|
|
9236
9251
|
classification: {
|
|
9237
9252
|
status: asset.classification.status,
|
|
9238
9253
|
testInput: asset.classification.testInput,
|
|
9239
|
-
moderation: {
|
|
9254
|
+
moderation: { decision: asset.classification.moderation.decision }
|
|
9240
9255
|
},
|
|
9241
9256
|
content: { status: asset.content.status }
|
|
9242
9257
|
});
|
|
@@ -9544,29 +9559,29 @@ const operationsOf = (request) => {
|
|
|
9544
9559
|
const [root] = segments;
|
|
9545
9560
|
if (root === "projects") {
|
|
9546
9561
|
switch (segments.slice(2).join("/")) {
|
|
9547
|
-
case "events": return ["events.list"
|
|
9548
|
-
case "lenses": return method === "GET" ? ["lenses.list"
|
|
9549
|
-
case "folders": return method === "GET" ? ["folders.list"
|
|
9550
|
-
case "hash-lists": return method === "GET" ? ["hashLists.list"
|
|
9562
|
+
case "events": return ["events.list"];
|
|
9563
|
+
case "lenses": return method === "GET" ? ["lenses.list"] : method === "POST" ? ["lenses.create"] : ["ensureLenses", "ensureLens"];
|
|
9564
|
+
case "folders": return method === "GET" ? ["folders.list"] : ["folders.create"];
|
|
9565
|
+
case "hash-lists": return method === "GET" ? ["hashLists.list"] : ["hashLists.create"];
|
|
9551
9566
|
case "policy": return method === "GET" ? ["policies.retrieveAssigned"] : ["policies.assign"];
|
|
9552
|
-
case "upload-presets": return method === "GET" ? ["uploadPresets.list"
|
|
9567
|
+
case "upload-presets": return method === "GET" ? ["uploadPresets.list"] : ["uploadPresets.ensure"];
|
|
9553
9568
|
case "settings": return method === "GET" ? ["projectSettings.get"] : ["projectSettings.update"];
|
|
9554
9569
|
case "metadata-fields": return method === "GET" ? ["metadataFields.list"] : ["metadataFields.ensure"];
|
|
9555
9570
|
case "assets/search": return ["assets.search"];
|
|
9556
9571
|
case "assets/batch": return ["assets.batch"];
|
|
9557
9572
|
case "signed-asset-urls": return ["cdn.signAssetUrl"];
|
|
9558
9573
|
case "assets":
|
|
9559
|
-
if (method === "GET") return ["assets.list"
|
|
9574
|
+
if (method === "GET") return ["assets.list"];
|
|
9560
9575
|
if (query.get("wait") === "false") return ["assets.create"];
|
|
9561
9576
|
return isTextUpload(request) ? ["assets.classify", "text.classify"] : ["assets.classify"];
|
|
9562
9577
|
}
|
|
9563
|
-
if (segments[2] === "assets" && segments[4] === "timeline" && segments.length === 5) return ["assets.listTimeline"
|
|
9578
|
+
if (segments[2] === "assets" && segments[4] === "timeline" && segments.length === 5) return ["assets.listTimeline"];
|
|
9564
9579
|
if (segments[2] === "metadata-fields" && segments.length === 4) return ["metadataFields.delete"];
|
|
9565
9580
|
return [];
|
|
9566
9581
|
}
|
|
9567
9582
|
if (root === "policies") {
|
|
9568
9583
|
const [, policyId, policyAction] = segments;
|
|
9569
|
-
if (policyId === void 0) return method === "GET" ? ["policies.list"
|
|
9584
|
+
if (policyId === void 0) return method === "GET" ? ["policies.list"] : ["policies.create"];
|
|
9570
9585
|
if (policyAction === "reset") return ["policies.reset"];
|
|
9571
9586
|
if (policyAction === "upgrade") return ["policies.upgrade"];
|
|
9572
9587
|
if (policyAction === "automatic-updates") return ["policies.setAutomaticUpdates"];
|
|
@@ -9585,7 +9600,7 @@ const operationsOf = (request) => {
|
|
|
9585
9600
|
return method === "GET" ? ["folders.retrieve"] : method === "PATCH" ? ["folders.update"] : ["folders.delete"];
|
|
9586
9601
|
}
|
|
9587
9602
|
if (root === "hash-lists" && id !== void 0) {
|
|
9588
|
-
if (action === "entries") return method === "GET" ? ["hashLists.listEntries"
|
|
9603
|
+
if (action === "entries") return method === "GET" ? ["hashLists.listEntries"] : ["hashLists.addEntry"];
|
|
9589
9604
|
return method === "GET" ? ["hashLists.retrieve"] : method === "PATCH" ? ["hashLists.update"] : ["hashLists.delete"];
|
|
9590
9605
|
}
|
|
9591
9606
|
if (root === "hash-list-entries" && id !== void 0) return ["hashLists.removeEntry"];
|
|
@@ -9593,11 +9608,10 @@ const operationsOf = (request) => {
|
|
|
9593
9608
|
switch (action) {
|
|
9594
9609
|
case void 0: return method === "GET" ? ["assets.retrieve", "assets.waitForDecision"] : method === "PATCH" ? ["assets.update"] : ["assets.delete"];
|
|
9595
9610
|
case "content": return ["assets.removeContent"];
|
|
9596
|
-
case "children": return ["assets.listChildren"
|
|
9611
|
+
case "children": return ["assets.listChildren"];
|
|
9597
9612
|
case "part": return ["assets.uploadPart"];
|
|
9598
9613
|
case "move": return ["assets.move"];
|
|
9599
9614
|
case "retry": return ["assets.retry"];
|
|
9600
|
-
case "explain": return ["assets.explain"];
|
|
9601
9615
|
case "decision": return ["assets.decide"];
|
|
9602
9616
|
}
|
|
9603
9617
|
return [];
|
|
@@ -9644,7 +9658,6 @@ var MockCalmLensApi = class {
|
|
|
9644
9658
|
this.eventFeed = [];
|
|
9645
9659
|
this.assetEventSequences = /* @__PURE__ */ new Map();
|
|
9646
9660
|
this.processingOptions = /* @__PURE__ */ new Map();
|
|
9647
|
-
this.pendingReruns = /* @__PURE__ */ new Set();
|
|
9648
9661
|
this.openUploads = /* @__PURE__ */ new Map();
|
|
9649
9662
|
this.idempotentResults = /* @__PURE__ */ new Map();
|
|
9650
9663
|
this.pendingFailures = [];
|
|
@@ -9691,7 +9704,7 @@ var MockCalmLensApi = class {
|
|
|
9691
9704
|
if (!asset) return this.pushEvent(input);
|
|
9692
9705
|
const snapshot = toEventAsset(asset);
|
|
9693
9706
|
const announced = ANNOUNCED_STATUS[input.type];
|
|
9694
|
-
if (announced) snapshot.classification.moderation.
|
|
9707
|
+
if (announced) snapshot.classification.moderation.decision = announced;
|
|
9695
9708
|
return this.pushEvent({
|
|
9696
9709
|
...input,
|
|
9697
9710
|
asset: snapshot
|
|
@@ -9742,11 +9755,9 @@ var MockCalmLensApi = class {
|
|
|
9742
9755
|
} catch (failure) {
|
|
9743
9756
|
throw this.toError(failure);
|
|
9744
9757
|
}
|
|
9745
|
-
|
|
9746
|
-
if (!rerun && asset.classification.status !== "processing") throw invalidArgument(`asset ${assetId} isn't processing`);
|
|
9758
|
+
if (asset.classification.status !== "processing") throw invalidArgument(`asset ${assetId} isn't processing`);
|
|
9747
9759
|
const settled = decision === void 0 ? void 0 : toDecision(decision);
|
|
9748
|
-
|
|
9749
|
-
return structuredClone(await this.settleRerun(asset, settled ?? await this.decisionFor(asset, "complete", true)));
|
|
9760
|
+
return structuredClone(await this.moderateStored(asset, "complete", settled));
|
|
9750
9761
|
}
|
|
9751
9762
|
/**
|
|
9752
9763
|
* `POST /assets/:assetId/decision`, like the API: an asset still uploading or processing can't
|
|
@@ -9765,8 +9776,8 @@ var MockCalmLensApi = class {
|
|
|
9765
9776
|
if (note.length > MAX_DECISION_NOTE_LENGTH) throw invalidField("validation/too-big", "note");
|
|
9766
9777
|
const asset = await this.findOwnAsset(assetId);
|
|
9767
9778
|
if (asset.upload.status === "uploading" || asset.classification.status === "processing") throw fail(API_ERROR_CODES.ASSET_PROCESSING);
|
|
9768
|
-
const status = asset.classification.moderation.
|
|
9769
|
-
if (decision !== "purged" && decision !== "blocked" && status ===
|
|
9779
|
+
const status = asset.classification.moderation.decision;
|
|
9780
|
+
if (decision !== "purged" && decision !== "blocked" && status === null) throw fail(API_ERROR_CODES.ASSET_DECISION_NOT_ALLOWED);
|
|
9770
9781
|
if (status === decision) throw fail(API_ERROR_CODES.ASSET_DECISION_UNCHANGED);
|
|
9771
9782
|
if (decision !== "purged" && decision !== "blocked" && status === "purged") throw fail(API_ERROR_CODES.ASSET_CONTENT_PURGED);
|
|
9772
9783
|
return this.recordDecision(asset, decision, { note });
|
|
@@ -9777,7 +9788,6 @@ var MockCalmLensApi = class {
|
|
|
9777
9788
|
* the mock API key's; the test hook records no note, the API's handler records it.
|
|
9778
9789
|
*/
|
|
9779
9790
|
async recordDecision(asset, decision, review) {
|
|
9780
|
-
this.pendingReruns.delete(asset.id);
|
|
9781
9791
|
const decided = await this.applyOutcome(asset, decision, "requested");
|
|
9782
9792
|
const now = this.now();
|
|
9783
9793
|
if (!review) decided.classification.moderation.pendingReview = null;
|
|
@@ -10063,7 +10073,6 @@ var MockCalmLensApi = class {
|
|
|
10063
10073
|
case "POST part": return [200, await this.uploadPart(id, request)];
|
|
10064
10074
|
case "POST move": return [200, await this.moveAsset(id, this.json(request))];
|
|
10065
10075
|
case "POST retry": return [200, await this.retryAsset(id)];
|
|
10066
|
-
case "POST explain": return [200, await this.explainAsset(id, this.json(request))];
|
|
10067
10076
|
case "POST decision": return [200, await this.decideAsset(id, this.json(request))];
|
|
10068
10077
|
case "DELETE content": return [200, await this.removeContent(await this.findOwnAsset(id))];
|
|
10069
10078
|
}
|
|
@@ -10479,53 +10488,12 @@ var MockCalmLensApi = class {
|
|
|
10479
10488
|
}
|
|
10480
10489
|
async retryAsset(assetId) {
|
|
10481
10490
|
const asset = await this.findOwnAsset(assetId);
|
|
10482
|
-
if (asset.classification.status !== "failed" || asset.classification.moderation.
|
|
10491
|
+
if (asset.classification.status !== "failed" || asset.classification.moderation.decision !== null) throw fail(API_ERROR_CODES.ASSET_NOT_RETRYABLE);
|
|
10483
10492
|
if (asset.content.status === "removed") throw fail(API_ERROR_CODES.ASSET_CONTENT_UNAVAILABLE);
|
|
10484
10493
|
const retried = await this.databaseStorage.updateAsset(await this.applyOutcome(asset, "pending"));
|
|
10485
10494
|
this.recordLifecycleEvent("asset.retried", retried);
|
|
10486
10495
|
return this.moderateStored(retried, "retry");
|
|
10487
10496
|
}
|
|
10488
|
-
async explainAsset(assetId, body) {
|
|
10489
|
-
const asset = await this.findOwnAsset(assetId);
|
|
10490
|
-
if (asset.classification.status !== "completed") throw fail(API_ERROR_CODES.ASSET_NOT_DECIDED);
|
|
10491
|
-
if (!body.rerun) {
|
|
10492
|
-
if (asset.classification.moderation?.explanationComplete !== false) return asset;
|
|
10493
|
-
return this.databaseStorage.updateAsset({
|
|
10494
|
-
...asset,
|
|
10495
|
-
updatedAt: this.now(),
|
|
10496
|
-
classification: {
|
|
10497
|
-
...asset.classification,
|
|
10498
|
-
moderation: {
|
|
10499
|
-
...asset.classification.moderation,
|
|
10500
|
-
explanationComplete: true
|
|
10501
|
-
}
|
|
10502
|
-
}
|
|
10503
|
-
});
|
|
10504
|
-
}
|
|
10505
|
-
if (asset.classification.moderation.manualReviews.length) throw fail(API_ERROR_CODES.ASSET_REVIEWED);
|
|
10506
|
-
if (asset.content.status === "removed") throw fail(API_ERROR_CODES.ASSET_CONTENT_UNAVAILABLE);
|
|
10507
|
-
this.pushEvent({
|
|
10508
|
-
type: "asset.rerun-requested",
|
|
10509
|
-
actor: MOCK_API_KEY_ACTOR,
|
|
10510
|
-
severity: "low",
|
|
10511
|
-
assetId: asset.id,
|
|
10512
|
-
asset: toEventAsset(asset),
|
|
10513
|
-
facts: [
|
|
10514
|
-
assetNameFact(asset),
|
|
10515
|
-
{
|
|
10516
|
-
key: "asset-type",
|
|
10517
|
-
value: asset.type
|
|
10518
|
-
},
|
|
10519
|
-
{
|
|
10520
|
-
key: "moderation-status",
|
|
10521
|
-
value: asset.classification.moderation.status
|
|
10522
|
-
}
|
|
10523
|
-
]
|
|
10524
|
-
});
|
|
10525
|
-
const response = structuredClone(asset);
|
|
10526
|
-
await this.settleRerun(asset, await this.decisionFor(asset, "rerun", true));
|
|
10527
|
-
return response;
|
|
10528
|
-
}
|
|
10529
10497
|
/**
|
|
10530
10498
|
* Checks every asset like the API (an ID that is not an asset ID is
|
|
10531
10499
|
* `validation/invalid-format`, an unknown
|
|
@@ -10791,7 +10759,7 @@ var MockCalmLensApi = class {
|
|
|
10791
10759
|
progress: null,
|
|
10792
10760
|
testInput: false,
|
|
10793
10761
|
moderation: {
|
|
10794
|
-
|
|
10762
|
+
decision: null,
|
|
10795
10763
|
manualReviews: [],
|
|
10796
10764
|
automatedStatus: null,
|
|
10797
10765
|
policy: null,
|
|
@@ -10970,20 +10938,6 @@ var MockCalmLensApi = class {
|
|
|
10970
10938
|
this.recordProcessingEvents(stored, decision);
|
|
10971
10939
|
return stored;
|
|
10972
10940
|
}
|
|
10973
|
-
/**
|
|
10974
|
-
* Applies a re-run's `decision` to a decided asset like the pipeline: a `pending` decision stays
|
|
10975
|
-
* queued for `completeProcessing`, a `failed` one keeps the asset's decision, and any other
|
|
10976
|
-
* replaces it with the pipeline's events.
|
|
10977
|
-
*/
|
|
10978
|
-
async settleRerun(asset, decision) {
|
|
10979
|
-
this.pendingReruns.delete(asset.id);
|
|
10980
|
-
if (decision.status === "pending") {
|
|
10981
|
-
this.pendingReruns.add(asset.id);
|
|
10982
|
-
return asset;
|
|
10983
|
-
}
|
|
10984
|
-
if (decision.status === "failed") return asset;
|
|
10985
|
-
return this.settle(asset, decision);
|
|
10986
|
-
}
|
|
10987
10941
|
/** Asks `moderate` (unless `decision` is given) and settles a processing asset. */
|
|
10988
10942
|
async moderateStored(asset, trigger, decision) {
|
|
10989
10943
|
return this.settle(asset, decision ?? await this.decisionFor(asset, trigger, true));
|
|
@@ -11124,7 +11078,7 @@ var MockCalmLensApi = class {
|
|
|
11124
11078
|
completedAt: decided ? now : null,
|
|
11125
11079
|
moderation: {
|
|
11126
11080
|
...asset.classification.moderation,
|
|
11127
|
-
|
|
11081
|
+
decision: decided ? outcome : null,
|
|
11128
11082
|
...report
|
|
11129
11083
|
}
|
|
11130
11084
|
}
|
|
@@ -11175,7 +11129,7 @@ var MockCalmLensApi = class {
|
|
|
11175
11129
|
classification: {
|
|
11176
11130
|
status: asset.classification.status,
|
|
11177
11131
|
failureReason: asset.classification.failureReason,
|
|
11178
|
-
...preset.showDecisions !== false && { moderation: {
|
|
11132
|
+
...preset.showDecisions !== false && { moderation: { decision: asset.classification.moderation.decision } }
|
|
11179
11133
|
}
|
|
11180
11134
|
});
|
|
11181
11135
|
const [assetId, action] = rest;
|
|
@@ -11643,9 +11597,10 @@ var MockCalmLensApi = class {
|
|
|
11643
11597
|
const grants = hasApiKey ? this.grants : [];
|
|
11644
11598
|
const folders = await this.databaseStorage.listFolders?.(this.projectId) ?? [];
|
|
11645
11599
|
const canDownload = () => permits(grants, "assets:download", asset.folderId ?? null, folders);
|
|
11646
|
-
const status = asset.classification.moderation.
|
|
11600
|
+
const status = asset.classification.moderation.decision;
|
|
11647
11601
|
const isHead = request.method === "HEAD";
|
|
11648
11602
|
const { rendered, preview } = asset.content;
|
|
11603
|
+
if (resource !== "info" && asset.content.status === "removed") return notFound();
|
|
11649
11604
|
if (asset.visibility !== "public" && !grant && !hasApiKey && resource !== "info") return notFound();
|
|
11650
11605
|
if (resource === "info") return this.serveInfo(request, asset, Boolean(grant) || canDownload());
|
|
11651
11606
|
if (asset.content.safetyHold) return notAvailable();
|
|
@@ -11662,7 +11617,7 @@ var MockCalmLensApi = class {
|
|
|
11662
11617
|
});
|
|
11663
11618
|
}
|
|
11664
11619
|
const storedContent = await this.imageStorage.getContent(asset.id);
|
|
11665
|
-
if (asset.upload.status === "uploading" || status === "purged" || status === "blocked" || asset.classification.status === "failed" ||
|
|
11620
|
+
if (asset.upload.status === "uploading" || status === "purged" || status === "blocked" || asset.classification.status === "failed" || resource === "original" && !storedContent) return notAvailable();
|
|
11666
11621
|
let claims = {};
|
|
11667
11622
|
try {
|
|
11668
11623
|
claims = JSON.parse(query.get("viewerClaims") ?? request.headers.get("X-CalmLens-Viewer-Claims") ?? "{}");
|
|
@@ -11741,7 +11696,7 @@ var MockCalmLensApi = class {
|
|
|
11741
11696
|
} catch {
|
|
11742
11697
|
return this.jsonResponse(400, { code: "viewer-claims/invalid" }, url);
|
|
11743
11698
|
}
|
|
11744
|
-
const status = asset.classification.moderation.
|
|
11699
|
+
const status = asset.classification.moderation.decision;
|
|
11745
11700
|
const restrictedInfo = isPrivate || status === "blocked" || status === "purged";
|
|
11746
11701
|
if (restrictedInfo && !authorised) return this.jsonResponse(403, { code: "asset/not-available" }, url);
|
|
11747
11702
|
const availability = asset.content.safetyHold || asset.upload.status === "uploading" || status === "blocked" || status === "purged" || asset.classification.status === "failed" || asset.content.status === "removed" ? "unavailable" : status === "age-restricted" && claims.ageConfirmed !== true ? "age-restricted" : "available";
|
|
@@ -12012,11 +11967,8 @@ var MockCalmLensServerClient = class extends CalmLensServerClient {
|
|
|
12012
11967
|
* else what `mockOptions.moderate` returns for the `complete` trigger (`allowed` by default).
|
|
12013
11968
|
* The asset gets the decision's report, and `asset.classified` and the automated
|
|
12014
11969
|
* `asset.<status>` (or `asset.failed`) join the events feed. No review is recorded, so the
|
|
12015
|
-
* asset can still be moderated again.
|
|
12016
|
-
* `
|
|
12017
|
-
* `pending` or `failed`. Rejects with `asset/not-found` for an unknown asset and
|
|
12018
|
-
* `sdk/invalid-argument` for one that isn't processing or awaiting a pending re-run. It sends
|
|
12019
|
-
* no request.
|
|
11970
|
+
* asset can still be moderated again. Rejects with `asset/not-found` for an unknown asset and
|
|
11971
|
+
* `sdk/invalid-argument` for one that isn't processing. It sends no request.
|
|
12020
11972
|
*/
|
|
12021
11973
|
completeProcessing(assetId, decision) {
|
|
12022
11974
|
return this.#api.completeProcessing(assetId, decision);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as appendAssetLocation } from "./ModerationContextLimits-
|
|
2
|
-
import {
|
|
3
|
-
import "./Core-
|
|
1
|
+
import { a as appendAssetLocation } from "./ModerationContextLimits-BmV8QD32.js";
|
|
2
|
+
import { o as placeholderHashToDataURL } from "./UploadController-Q7xTqh5w.js";
|
|
3
|
+
import "./Core-CP6NaqJz.js";
|
|
4
4
|
// src/ui/viewers/PdfLoader.ts
|
|
5
5
|
let loading;
|
|
6
6
|
/**
|
|
@@ -398,7 +398,9 @@ var DocumentViewer = class extends ViewerBase {
|
|
|
398
398
|
toolbar.insertBefore(next, count.nextSibling);
|
|
399
399
|
page.addEventListener("change", () => this.#go(Number(page.value)));
|
|
400
400
|
page.addEventListener("keydown", (event) => {
|
|
401
|
-
if (event.key
|
|
401
|
+
if (event.key !== "Enter") return;
|
|
402
|
+
event.preventDefault();
|
|
403
|
+
if (!event.isComposing && event.keyCode !== 229) this.#go(Number(page.value));
|
|
402
404
|
});
|
|
403
405
|
zoomOut.addEventListener("click", () => this.#setZoom(this.#scale / ZOOM_STEP));
|
|
404
406
|
zoomIn.addEventListener("click", () => this.#setZoom(this.#scale * ZOOM_STEP));
|
|
@@ -488,7 +490,7 @@ var DocumentViewer = class extends ViewerBase {
|
|
|
488
490
|
const page = await document.getPage(pageNumber);
|
|
489
491
|
if (render !== this.#renders) return;
|
|
490
492
|
const natural = page.getViewport({ scale: 1 });
|
|
491
|
-
const available = controls.pages.clientWidth
|
|
493
|
+
const available = controls.pages.clientWidth;
|
|
492
494
|
const scale = this.#zoom ?? (available > 0 ? available / natural.width : 1);
|
|
493
495
|
this.#scale = scale;
|
|
494
496
|
controls.zoomLevel.textContent = formatViewerMessage(messages.zoomLevel, { percent: Math.round(scale * 100) });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./CalmLensTypes-
|
|
2
|
-
import {
|
|
1
|
+
import "./CalmLensTypes-HUERg5hI.js";
|
|
2
|
+
import { K as AssetOptions, Z as AssetView, ct as PdfAssetOptions, ft as ViewerOptions, lt as SpreadsheetViewerOptions, mt as WebsiteViewerOptions, ot as DocumentViewerOptions, q as AssetSession, st as ImageViewerOptions, ut as TextViewerOptions } from "./Core-DXAs8mcx.js";
|
|
3
3
|
import "pdfjs-dist";
|
|
4
4
|
/** A viewer mounted into an element, which it owns the children of. */
|
|
5
5
|
interface AssetViewer<O extends ViewerOptions = ViewerOptions> {
|
package/esm/ui.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { $ as
|
|
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-
|
|
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 };
|
|
1
|
+
import { $ as getAssetAspectRatio, A as CustomUploadContext, B as isFileAccepted, C as formatMessage, D as resolveMessages, E as getUploadItemOutcome, F as UploadFile, G as AssetImageSource, H as AssetDisplay, I as UploadItem, J as AssetSessionState, K as AssetOptions, L as UploadSnapshot, M as UploadClient, N as UploadController, O as CalmLensProvidedOptions, P as UploadControllerOptions, Q as MediaPlayback, R as UploadStage, S as formatBytes, T as getUploadItemMessage, U as AssetDocumentOptions, V as withProvidedOptions, W as AssetImageOptions, X as AssetVideoOptions, Y as AssetSpreadsheetOptions, Z as AssetView, _ as DEFAULT_MESSAGES, _t as DEFAULT_VIEWER_MESSAGES, a as ProgressFetchOptions, at as AssetViewerKind, b as describeUploadItem, bt as resolveViewerMessages, c as ICON_ATTRIBUTES, ct as PdfAssetOptions, d as AssetDisplayOptions, dt as ViewerAsset, et as getAssetView, f as AssetEventHandlers, ft as ViewerOptions, g as CalmLensMessages, gt as isSpreadsheetFormat, h as UploaderProps, ht as getAssetViewerKind, i as CALMLENS_STYLES, it as pickAssetSource, j as CustomUploadResult, k as CalmLensUpload, l as IconName, lt as SpreadsheetViewerOptions, m as UploaderDisplayOptions, mt as WebsiteViewerOptions, n as CalmLensTheme, nt as getPeakHeights, o as createProgressFetch, ot as DocumentViewerOptions, p as AssetProps, pt as ViewerTextOptions, q as AssetSession, r as resolveTheme, rt as getPlayedPercent, s as ICONS, st as ImageViewerOptions, t as CALMLENS_THEME, tt as getAssetViewKey, u as ASSET_FILE_ICON_SIZE, ut as TextViewerOptions, v as UploadItemView, vt as ViewerMessages, w as getDropzoneHint, x as describeUploader, y as UploaderView, yt as formatViewerMessage, z as createUploadController } from "./Core-DXAs8mcx.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-BfJNO3c6.js";
|
|
3
|
+
export { ASSET_FILE_ICON_SIZE, ASSET_VIEWERS, type AssetDisplay, type AssetDisplayOptions, type AssetDocumentOptions, type AssetEventHandlers, type AssetImageOptions, type AssetImageSource, type AssetOptions, type AssetProps, AssetSession, type AssetSessionState, type AssetSpreadsheetOptions, type AssetVideoOptions, type AssetView, type AssetViewer, type AssetViewerKind, AssetViewerMount, AssetViewerName, AssetViewerOptionsByKind, CALMLENS_STYLES, CALMLENS_THEME, type CalmLensMessages, type CalmLensProvidedOptions, type CalmLensTheme, type CalmLensUpload, type CustomUploadContext, type CustomUploadResult, DEFAULT_MESSAGES, DEFAULT_VIEWER_MESSAGES, type DocumentViewerOptions, ICONS, ICON_ATTRIBUTES, 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, withProvidedOptions };
|
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-
|
|
2
|
-
import {
|
|
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-
|
|
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 };
|
|
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-BBDJJkFL.js";
|
|
2
|
+
import { a as createProgressFetch, i as withProvidedOptions, n as createUploadController, r as isFileAccepted, t as UploadController } from "./UploadController-Q7xTqh5w.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-CP6NaqJz.js";
|
|
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, withProvidedOptions };
|