calmlens 0.26.1 → 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 +1 -1
- package/bin/calmlens.js +117 -92
- package/cjs/{BrowserUpload-DdkcoZLH.js → BrowserUpload-CTqIjCV5.js} +1 -1
- package/{esm/BrowserUpload-zYWKtFSs.d.ts → cjs/BrowserUpload-D4sEmd0X.d.ts} +2 -2
- package/{esm/CalmLensAppClient-mTTjqpRc.d.ts → cjs/CalmLensAppClient-CCeFnKX8.d.ts} +1 -1
- package/cjs/{CalmLensAppClient-Gu9mU_66.js → CalmLensAppClient-CZm-9g22.js} +6 -6
- package/cjs/{CalmLensOptionKeys-BCITGsr9.js → CalmLensOptionKeys-C1w3SqmL.js} +28 -6
- package/cjs/{CalmLensServerClient-D5-njsNk.d.ts → CalmLensServerClient-B7PfocET.d.ts} +3 -14
- package/cjs/{CalmLensServerClient-DHmAPT1u.js → CalmLensServerClient-ucq3ITjd.js} +2 -16
- package/cjs/{CalmLensTypes-Df8eBgWB.d.ts → CalmLensTypes-HUERg5hI.d.ts} +16 -97
- package/cjs/{Classification-CxRedzgH-C9qlYW_J.d.ts → Classification-CMM2tZpJ-IdIh63n0.d.ts} +6 -7
- package/cjs/{Core-DAf9lqe2.js → Core-D-1KCqT7.js} +11 -6
- package/{esm/Core-CREGGR0L.d.ts → cjs/Core-DXAs8mcx.d.ts} +2 -2
- package/cjs/{ModerationContextLimits-D4iwqoN_.js → ModerationContextLimits-BcYKgU2X.js} +2 -17
- package/{esm/ReactUpload-D4htIz8X.d.ts → cjs/ReactUpload-BTciTpwB.d.ts} +1 -1
- package/cjs/{ReactUpload-BNIbpxIH.js → ReactUpload-BymgWiC8.js} +1 -1
- 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-B_lKxvpM.js → UploadController-C8GPbDKI.js} +2 -2
- package/cjs/{WebhookPayload-DMa6ihHr.d.ts → WebhookPayload-mUmOFH55.d.ts} +1 -7
- package/cjs/app.d.ts +6 -6
- package/cjs/app.js +2 -2
- package/cjs/elements.d.ts +4 -4
- package/cjs/elements.js +7 -5
- package/cjs/{index-CtpQldn_.d.ts → index-Ck7x1YjM.d.ts} +3 -3
- package/cjs/index.d.ts +5 -5
- package/cjs/index.js +1 -1
- package/cjs/react-native.d.ts +2 -2
- package/cjs/react-native.js +5 -5
- package/cjs/react.d.ts +4 -4
- package/cjs/react.js +6 -6
- package/cjs/server.d.ts +6 -6
- package/cjs/server.js +2 -2
- package/cjs/test-inputs.d.ts +1 -1
- package/cjs/test-inputs.js +13 -13
- package/cjs/testing.d.ts +12 -17
- package/cjs/testing.js +35 -114
- package/cjs/{ui-BwFPFrno.d.ts → ui-BfJNO3c6.d.ts} +2 -2
- package/cjs/{ui-CvlJmRYM.js → ui-CW8BqtZk.js} +4 -4
- package/cjs/ui.d.ts +2 -2
- package/cjs/ui.js +3 -3
- package/cjs/vue.d.ts +5 -5
- package/cjs/vue.js +5 -5
- package/esm/{BrowserUpload-BAWYEBd7.js → BrowserUpload-C01iLeOs.js} +1 -1
- package/{cjs/BrowserUpload-zYWKtFSs.d.ts → esm/BrowserUpload-D4sEmd0X.d.ts} +2 -2
- package/{cjs/CalmLensAppClient-mTTjqpRc.d.ts → esm/CalmLensAppClient-CCeFnKX8.d.ts} +1 -1
- package/esm/{CalmLensAppClient-DNkIZb6x.js → CalmLensAppClient-CgDogQQC.js} +6 -6
- package/esm/{CalmLensOptionKeys-CYHJo3nV.js → CalmLensOptionKeys-CEwNbpEz.js} +28 -6
- package/esm/{CalmLensServerClient-D5-njsNk.d.ts → CalmLensServerClient-B7PfocET.d.ts} +3 -14
- package/esm/{CalmLensServerClient-B1AiR4nv.js → CalmLensServerClient-TT6zrAG5.js} +2 -16
- package/esm/{CalmLensTypes-Df8eBgWB.d.ts → CalmLensTypes-HUERg5hI.d.ts} +16 -97
- package/esm/{Classification-CxRedzgH-C9qlYW_J.d.ts → Classification-CMM2tZpJ-IdIh63n0.d.ts} +6 -7
- package/esm/{Core-xNBQxZWH.js → Core-CP6NaqJz.js} +11 -6
- package/{cjs/Core-CREGGR0L.d.ts → esm/Core-DXAs8mcx.d.ts} +2 -2
- package/esm/{ModerationContextLimits-DxuPP4uM.js → ModerationContextLimits-BmV8QD32.js} +2 -17
- package/esm/{ReactUpload-BWifQdLv.js → ReactUpload-B72Oq3qE.js} +1 -1
- package/{cjs/ReactUpload-D4htIz8X.d.ts → esm/ReactUpload-BTciTpwB.d.ts} +1 -1
- 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-jlJdddyI.js → UploadController-Q7xTqh5w.js} +2 -2
- package/esm/{WebhookPayload-DMa6ihHr.d.ts → WebhookPayload-mUmOFH55.d.ts} +1 -7
- package/esm/app.d.ts +6 -6
- package/esm/app.js +2 -2
- package/esm/elements.d.ts +4 -4
- package/esm/elements.js +7 -5
- package/esm/{index-CtpQldn_.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 +2 -2
- package/esm/react-native.js +5 -5
- package/esm/react.d.ts +4 -4
- package/esm/react.js +6 -6
- package/esm/server.d.ts +6 -6
- package/esm/server.js +2 -2
- package/esm/styles.css +9 -4
- package/esm/svelte/CalmLensAsset.svelte +1 -1
- package/esm/test-inputs.d.ts +1 -1
- package/esm/test-inputs.js +1 -1
- package/esm/testing.d.ts +12 -17
- package/esm/testing.js +29 -108
- package/esm/{ui-BXzzqh7M.js → ui-BBDJJkFL.js} +4 -4
- package/esm/{ui-BwFPFrno.d.ts → ui-BfJNO3c6.d.ts} +2 -2
- package/esm/ui.d.ts +2 -2
- package/esm/ui.js +3 -3
- package/esm/vue.d.ts +5 -5
- package/esm/vue.js +5 -5
- package/package.json +1 -1
package/cjs/testing.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
3
|
-
const require_ModerationContextLimits = require("./ModerationContextLimits-
|
|
4
|
-
const require_CalmLensServerClient = require("./CalmLensServerClient-
|
|
5
|
-
const require_CalmLensOptionKeys = require("./CalmLensOptionKeys-
|
|
2
|
+
const require_TestTriggers_Cvi7e2KA = require("./TestTriggers-Cvi7e2KA-DcT1pc_W.js");
|
|
3
|
+
const require_ModerationContextLimits = require("./ModerationContextLimits-BcYKgU2X.js");
|
|
4
|
+
const require_CalmLensServerClient = require("./CalmLensServerClient-ucq3ITjd.js");
|
|
5
|
+
const require_CalmLensOptionKeys = require("./CalmLensOptionKeys-C1w3SqmL.js");
|
|
6
6
|
const require_CryptoUtils_B_x8lMIx = require("./CryptoUtils-B_x8lMIx-YBW1-bvL.js");
|
|
7
|
-
const require_CalmLensAppClient = require("./CalmLensAppClient-
|
|
8
|
-
const require_UploadController = require("./UploadController-
|
|
7
|
+
const require_CalmLensAppClient = require("./CalmLensAppClient-CZm-9g22.js");
|
|
8
|
+
const require_UploadController = require("./UploadController-C8GPbDKI.js");
|
|
9
9
|
let zod = require("zod");
|
|
10
|
-
zod =
|
|
10
|
+
zod = require_TestTriggers_Cvi7e2KA.__toESM(zod, 1);
|
|
11
11
|
// src/contract/MediaTestTriggers.js
|
|
12
|
-
const MEDIA_TEST_SIGNALS = [...
|
|
12
|
+
const MEDIA_TEST_SIGNALS = [...require_TestTriggers_Cvi7e2KA.CLASSIFICATION_CATEGORIES, "violence.graphic"];
|
|
13
13
|
const HEX_WORDS = [
|
|
14
14
|
"zero",
|
|
15
15
|
"one",
|
|
@@ -31,9 +31,9 @@ const HEX_WORDS = [
|
|
|
31
31
|
/** Read this aloud, or render it as large, high-contrast text in a video frame. */
|
|
32
32
|
async function generateMediaTestCode(signal, testInputKey) {
|
|
33
33
|
if (!MEDIA_TEST_SIGNALS.includes(signal)) throw new RangeError("Unsupported media test signal");
|
|
34
|
-
return `Calm Lens test ${[...await
|
|
34
|
+
return `Calm Lens test ${[...await require_TestTriggers_Cvi7e2KA.getTestInputTag("media", signal, testInputKey)].map((character) => HEX_WORDS[Number.parseInt(character, 16)]).join(" ")} ${signal.replace(/[.-]/g, " ")} end test`;
|
|
35
35
|
}
|
|
36
|
-
// src/contract/Ids-
|
|
36
|
+
// src/contract/Ids-C2cLdFM0.js
|
|
37
37
|
var __defProp = Object.defineProperty;
|
|
38
38
|
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod, mod.exports), cb = null), mod.exports);
|
|
39
39
|
var __exportAll = (all, no_symbols) => {
|
|
@@ -4268,7 +4268,7 @@ function registry() {
|
|
|
4268
4268
|
return new $ZodRegistry();
|
|
4269
4269
|
}
|
|
4270
4270
|
(_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
|
|
4271
|
-
const globalRegistry = globalThis.__zod_globalRegistry;
|
|
4271
|
+
const globalRegistry$1 = globalThis.__zod_globalRegistry;
|
|
4272
4272
|
function snapshotChecks(def) {
|
|
4273
4273
|
if (def.checks) def.checks = [...def.checks];
|
|
4274
4274
|
return def;
|
|
@@ -5006,8 +5006,8 @@ function _check(fn, params) {
|
|
|
5006
5006
|
function describe$1(description) {
|
|
5007
5007
|
const ch = new $ZodCheck({ check: "describe" });
|
|
5008
5008
|
ch._zod.onattach = [(inst) => {
|
|
5009
|
-
const existing = globalRegistry.get(inst) ?? {};
|
|
5010
|
-
globalRegistry.add(inst, {
|
|
5009
|
+
const existing = globalRegistry$1.get(inst) ?? {};
|
|
5010
|
+
globalRegistry$1.add(inst, {
|
|
5011
5011
|
...existing,
|
|
5012
5012
|
description
|
|
5013
5013
|
});
|
|
@@ -5019,8 +5019,8 @@ function describe$1(description) {
|
|
|
5019
5019
|
function meta$1(metadata) {
|
|
5020
5020
|
const ch = new $ZodCheck({ check: "meta" });
|
|
5021
5021
|
ch._zod.onattach = [(inst) => {
|
|
5022
|
-
const existing = globalRegistry.get(inst) ?? {};
|
|
5023
|
-
globalRegistry.add(inst, {
|
|
5022
|
+
const existing = globalRegistry$1.get(inst) ?? {};
|
|
5023
|
+
globalRegistry$1.add(inst, {
|
|
5024
5024
|
...existing,
|
|
5025
5025
|
...metadata
|
|
5026
5026
|
});
|
|
@@ -5116,7 +5116,7 @@ function initializeContext(params) {
|
|
|
5116
5116
|
if (target === "draft-7") target = "draft-07";
|
|
5117
5117
|
return {
|
|
5118
5118
|
processors: params.processors ?? {},
|
|
5119
|
-
metadataRegistry: params?.metadata ?? globalRegistry,
|
|
5119
|
+
metadataRegistry: params?.metadata ?? globalRegistry$1,
|
|
5120
5120
|
target,
|
|
5121
5121
|
unrepresentable: params?.unrepresentable ?? "throw",
|
|
5122
5122
|
override: params?.override ?? (() => {}),
|
|
@@ -6472,13 +6472,13 @@ const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
|
|
|
6472
6472
|
},
|
|
6473
6473
|
describe(description) {
|
|
6474
6474
|
const cl = this.clone();
|
|
6475
|
-
globalRegistry.add(cl, { description });
|
|
6475
|
+
globalRegistry$1.add(cl, { description });
|
|
6476
6476
|
return cl;
|
|
6477
6477
|
},
|
|
6478
6478
|
meta(...args) {
|
|
6479
|
-
if (args.length === 0) return globalRegistry.get(this);
|
|
6479
|
+
if (args.length === 0) return globalRegistry$1.get(this);
|
|
6480
6480
|
const cl = this.clone();
|
|
6481
|
-
globalRegistry.add(cl, args[0]);
|
|
6481
|
+
globalRegistry$1.add(cl, args[0]);
|
|
6482
6482
|
return cl;
|
|
6483
6483
|
},
|
|
6484
6484
|
isOptional() {
|
|
@@ -6554,7 +6554,7 @@ const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
|
|
|
6554
6554
|
return createToJSONSchemaMethod(this, {})(params);
|
|
6555
6555
|
},
|
|
6556
6556
|
get description() {
|
|
6557
|
-
return globalRegistry.get(this)?.description;
|
|
6557
|
+
return globalRegistry$1.get(this)?.description;
|
|
6558
6558
|
},
|
|
6559
6559
|
get _def() {
|
|
6560
6560
|
return this._zod.def;
|
|
@@ -8030,8 +8030,8 @@ const EXAMPLE_IDS = {
|
|
|
8030
8030
|
* across the packages that build records from plain strings).
|
|
8031
8031
|
*/
|
|
8032
8032
|
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]] });
|
|
8033
|
-
// src/contract/Permissions-
|
|
8034
|
-
const ACTION_SCHEMA = zod.enum([
|
|
8033
|
+
// src/contract/Permissions-CzuRcPMS.js
|
|
8034
|
+
const ACTION_SCHEMA = /* @__PURE__ */ require_TestTriggers_Cvi7e2KA.lazySchema(() => zod.enum([
|
|
8035
8035
|
"assets:read",
|
|
8036
8036
|
"assets:download",
|
|
8037
8037
|
"assets:create",
|
|
@@ -8063,7 +8063,7 @@ const ACTION_SCHEMA = zod.enum([
|
|
|
8063
8063
|
"reviews:read",
|
|
8064
8064
|
"reviews:write",
|
|
8065
8065
|
"project:manage"
|
|
8066
|
-
]);
|
|
8066
|
+
]));
|
|
8067
8067
|
const PROJECT_ACTIONS = [...[
|
|
8068
8068
|
"settings",
|
|
8069
8069
|
"members",
|
|
@@ -8079,19 +8079,12 @@ const PROJECT_ACTIONS = [...[
|
|
|
8079
8079
|
const isProjectAction = (action) => PROJECT_ACTIONS.includes(action);
|
|
8080
8080
|
/** The actions that include `action`: its feature's write action and project:manage. */
|
|
8081
8081
|
const actionsImplying = (action) => !isProjectAction(action) || action === "project:manage" ? [] : action.endsWith(":read") ? [action.replace(/:read$/, ":write"), "project:manage"] : ["project:manage"];
|
|
8082
|
-
const GRANT_SCHEMA = zod.object({
|
|
8082
|
+
const GRANT_SCHEMA = /* @__PURE__ */ require_TestTriggers_Cvi7e2KA.lazySchema(() => zod.object({
|
|
8083
8083
|
actions: zod.array(ACTION_SCHEMA),
|
|
8084
8084
|
folderId: idField("fldr").nullable(),
|
|
8085
8085
|
includeSubfolders: zod.boolean()
|
|
8086
|
-
}).strict().refine((g) => g.folderId === null || !g.actions.some(isProjectAction), "Project configuration permissions require project scope");
|
|
8087
|
-
const GRANTS_SCHEMA = zod.array(GRANT_SCHEMA).max(100);
|
|
8088
|
-
zod.enum([
|
|
8089
|
-
"admin",
|
|
8090
|
-
"configurator",
|
|
8091
|
-
"editor",
|
|
8092
|
-
"viewer",
|
|
8093
|
-
"custom"
|
|
8094
|
-
]);
|
|
8086
|
+
}).strict().refine((g) => g.folderId === null || !g.actions.some(isProjectAction), "Project configuration permissions require project scope"));
|
|
8087
|
+
const GRANTS_SCHEMA = /* @__PURE__ */ require_TestTriggers_Cvi7e2KA.lazySchema(() => zod.array(GRANT_SCHEMA).max(100));
|
|
8095
8088
|
[...ACTION_SCHEMA.options.filter((a) => !isProjectAction(a))];
|
|
8096
8089
|
[...ACTION_SCHEMA.options.filter((a) => !isProjectAction(a))];
|
|
8097
8090
|
const permits = (grants, action, folderId, folders) => grants.some((grant) => {
|
|
@@ -8107,14 +8100,6 @@ const permits = (grants, action, folderId, folders) => grants.some((grant) => {
|
|
|
8107
8100
|
}
|
|
8108
8101
|
return false;
|
|
8109
8102
|
});
|
|
8110
|
-
/**
|
|
8111
|
-
* What a person can let an AI assistant or the CLI do for them. `read` looks at assets, folders,
|
|
8112
|
-
* hash lists and events; `write` also creates, changes and deletes assets, folders and hash lists.
|
|
8113
|
-
* Members, API keys, connectors, sharing, downloads and project settings are never delegated.
|
|
8114
|
-
*/
|
|
8115
|
-
const AGENT_SCOPE_SCHEMA = zod.enum(["read", "write"]);
|
|
8116
|
-
zod.array(AGENT_SCOPE_SCHEMA).min(1).max(2);
|
|
8117
|
-
zod.enum(["active", "banned"]);
|
|
8118
8103
|
// src/testing/MockApiKey.ts
|
|
8119
8104
|
const MOCK_API_KEY_PREFIX = "sk_test_";
|
|
8120
8105
|
const toBase64Url = (value) => btoa(value).replaceAll("+", "-").replaceAll("/", "_").replaceAll("=", "");
|
|
@@ -9170,7 +9155,6 @@ const MOCK_OPERATIONS = [
|
|
|
9170
9155
|
"assets.uploadPart",
|
|
9171
9156
|
"assets.move",
|
|
9172
9157
|
"assets.retry",
|
|
9173
|
-
"assets.explain",
|
|
9174
9158
|
"assets.decide",
|
|
9175
9159
|
"assets.removeContent",
|
|
9176
9160
|
"assets.delete",
|
|
@@ -9550,7 +9534,7 @@ const MOCK_PRESET_NAMES = {
|
|
|
9550
9534
|
* personal information and profanity, `block` otherwise) and no rules. The mock holds no built-in
|
|
9551
9535
|
* preset settings, and uploads are never decided by a policy.
|
|
9552
9536
|
*/
|
|
9553
|
-
const mockPresetSettings = () => ({ categorySettings: Object.fromEntries(
|
|
9537
|
+
const mockPresetSettings = () => ({ categorySettings: Object.fromEntries(require_TestTriggers_Cvi7e2KA.CLASSIFICATION_CATEGORIES.map((category) => [category, {
|
|
9554
9538
|
action: category === "personal-information" || category === "profanity" ? "allow" : "block",
|
|
9555
9539
|
allowances: [],
|
|
9556
9540
|
restrictions: []
|
|
@@ -9562,13 +9546,13 @@ const mockPresetSettings = () => ({ categorySettings: Object.fromEntries(require
|
|
|
9562
9546
|
const checkPolicySettings = (settings) => {
|
|
9563
9547
|
const categories = settings?.categorySettings;
|
|
9564
9548
|
if (!categories || typeof categories !== "object") throw invalidField("validation/invalid-type", "settings.categorySettings");
|
|
9565
|
-
for (const category of
|
|
9549
|
+
for (const category of require_TestTriggers_Cvi7e2KA.CLASSIFICATION_CATEGORIES) {
|
|
9566
9550
|
const value = categories[category];
|
|
9567
9551
|
if (!value || typeof value !== "object") throw invalidField("validation/invalid-type", `settings.categorySettings.${category}`);
|
|
9568
9552
|
for (const key of ["allowances", "restrictions"]) if (!Array.isArray(value[key])) throw invalidField("validation/invalid-type", `settings.categorySettings.${category}.${key}`);
|
|
9569
9553
|
if (typeof value.action !== "string") throw invalidField("validation/invalid-value", `settings.categorySettings.${category}.action`);
|
|
9570
9554
|
}
|
|
9571
|
-
for (const key of Object.keys(categories)) if (!
|
|
9555
|
+
for (const key of Object.keys(categories)) if (!require_TestTriggers_Cvi7e2KA.CLASSIFICATION_CATEGORIES.includes(key)) throw invalidField("validation/unknown-field", `settings.categorySettings.${key}`);
|
|
9572
9556
|
};
|
|
9573
9557
|
/** The client methods that send a request, the one it is recorded under first. */
|
|
9574
9558
|
const operationsOf = (request) => {
|
|
@@ -9630,7 +9614,6 @@ const operationsOf = (request) => {
|
|
|
9630
9614
|
case "part": return ["assets.uploadPart"];
|
|
9631
9615
|
case "move": return ["assets.move"];
|
|
9632
9616
|
case "retry": return ["assets.retry"];
|
|
9633
|
-
case "explain": return ["assets.explain"];
|
|
9634
9617
|
case "decision": return ["assets.decide"];
|
|
9635
9618
|
}
|
|
9636
9619
|
return [];
|
|
@@ -9677,7 +9660,6 @@ var MockCalmLensApi = class {
|
|
|
9677
9660
|
this.eventFeed = [];
|
|
9678
9661
|
this.assetEventSequences = /* @__PURE__ */ new Map();
|
|
9679
9662
|
this.processingOptions = /* @__PURE__ */ new Map();
|
|
9680
|
-
this.pendingReruns = /* @__PURE__ */ new Set();
|
|
9681
9663
|
this.openUploads = /* @__PURE__ */ new Map();
|
|
9682
9664
|
this.idempotentResults = /* @__PURE__ */ new Map();
|
|
9683
9665
|
this.pendingFailures = [];
|
|
@@ -9775,11 +9757,9 @@ var MockCalmLensApi = class {
|
|
|
9775
9757
|
} catch (failure) {
|
|
9776
9758
|
throw this.toError(failure);
|
|
9777
9759
|
}
|
|
9778
|
-
|
|
9779
|
-
if (!rerun && asset.classification.status !== "processing") throw require_ModerationContextLimits.invalidArgument(`asset ${assetId} isn't processing`);
|
|
9760
|
+
if (asset.classification.status !== "processing") throw require_ModerationContextLimits.invalidArgument(`asset ${assetId} isn't processing`);
|
|
9780
9761
|
const settled = decision === void 0 ? void 0 : toDecision(decision);
|
|
9781
|
-
|
|
9782
|
-
return structuredClone(await this.settleRerun(asset, settled ?? await this.decisionFor(asset, "complete", true)));
|
|
9762
|
+
return structuredClone(await this.moderateStored(asset, "complete", settled));
|
|
9783
9763
|
}
|
|
9784
9764
|
/**
|
|
9785
9765
|
* `POST /assets/:assetId/decision`, like the API: an asset still uploading or processing can't
|
|
@@ -9810,7 +9790,6 @@ var MockCalmLensApi = class {
|
|
|
9810
9790
|
* the mock API key's; the test hook records no note, the API's handler records it.
|
|
9811
9791
|
*/
|
|
9812
9792
|
async recordDecision(asset, decision, review) {
|
|
9813
|
-
this.pendingReruns.delete(asset.id);
|
|
9814
9793
|
const decided = await this.applyOutcome(asset, decision, "requested");
|
|
9815
9794
|
const now = this.now();
|
|
9816
9795
|
if (!review) decided.classification.moderation.pendingReview = null;
|
|
@@ -10096,7 +10075,6 @@ var MockCalmLensApi = class {
|
|
|
10096
10075
|
case "POST part": return [200, await this.uploadPart(id, request)];
|
|
10097
10076
|
case "POST move": return [200, await this.moveAsset(id, this.json(request))];
|
|
10098
10077
|
case "POST retry": return [200, await this.retryAsset(id)];
|
|
10099
|
-
case "POST explain": return [200, await this.explainAsset(id, this.json(request))];
|
|
10100
10078
|
case "POST decision": return [200, await this.decideAsset(id, this.json(request))];
|
|
10101
10079
|
case "DELETE content": return [200, await this.removeContent(await this.findOwnAsset(id))];
|
|
10102
10080
|
}
|
|
@@ -10518,47 +10496,6 @@ var MockCalmLensApi = class {
|
|
|
10518
10496
|
this.recordLifecycleEvent("asset.retried", retried);
|
|
10519
10497
|
return this.moderateStored(retried, "retry");
|
|
10520
10498
|
}
|
|
10521
|
-
async explainAsset(assetId, body) {
|
|
10522
|
-
const asset = await this.findOwnAsset(assetId);
|
|
10523
|
-
if (asset.classification.status !== "completed") throw fail(require_ModerationContextLimits.API_ERROR_CODES.ASSET_NOT_DECIDED);
|
|
10524
|
-
if (!body.rerun) {
|
|
10525
|
-
if (asset.classification.moderation?.explanationComplete !== false) return asset;
|
|
10526
|
-
return this.databaseStorage.updateAsset({
|
|
10527
|
-
...asset,
|
|
10528
|
-
updatedAt: this.now(),
|
|
10529
|
-
classification: {
|
|
10530
|
-
...asset.classification,
|
|
10531
|
-
moderation: {
|
|
10532
|
-
...asset.classification.moderation,
|
|
10533
|
-
explanationComplete: true
|
|
10534
|
-
}
|
|
10535
|
-
}
|
|
10536
|
-
});
|
|
10537
|
-
}
|
|
10538
|
-
if (asset.classification.moderation.manualReviews.length) throw fail(require_ModerationContextLimits.API_ERROR_CODES.ASSET_REVIEWED);
|
|
10539
|
-
if (asset.content.status === "removed") throw fail(require_ModerationContextLimits.API_ERROR_CODES.ASSET_CONTENT_UNAVAILABLE);
|
|
10540
|
-
this.pushEvent({
|
|
10541
|
-
type: "asset.rerun-requested",
|
|
10542
|
-
actor: MOCK_API_KEY_ACTOR,
|
|
10543
|
-
severity: "low",
|
|
10544
|
-
assetId: asset.id,
|
|
10545
|
-
asset: toEventAsset(asset),
|
|
10546
|
-
facts: [
|
|
10547
|
-
assetNameFact(asset),
|
|
10548
|
-
{
|
|
10549
|
-
key: "asset-type",
|
|
10550
|
-
value: asset.type
|
|
10551
|
-
},
|
|
10552
|
-
{
|
|
10553
|
-
key: "moderation-status",
|
|
10554
|
-
value: asset.classification.moderation.decision
|
|
10555
|
-
}
|
|
10556
|
-
]
|
|
10557
|
-
});
|
|
10558
|
-
const response = structuredClone(asset);
|
|
10559
|
-
await this.settleRerun(asset, await this.decisionFor(asset, "rerun", true));
|
|
10560
|
-
return response;
|
|
10561
|
-
}
|
|
10562
10499
|
/**
|
|
10563
10500
|
* Checks every asset like the API (an ID that is not an asset ID is
|
|
10564
10501
|
* `validation/invalid-format`, an unknown
|
|
@@ -11003,20 +10940,6 @@ var MockCalmLensApi = class {
|
|
|
11003
10940
|
this.recordProcessingEvents(stored, decision);
|
|
11004
10941
|
return stored;
|
|
11005
10942
|
}
|
|
11006
|
-
/**
|
|
11007
|
-
* Applies a re-run's `decision` to a decided asset like the pipeline: a `pending` decision stays
|
|
11008
|
-
* queued for `completeProcessing`, a `failed` one keeps the asset's decision, and any other
|
|
11009
|
-
* replaces it with the pipeline's events.
|
|
11010
|
-
*/
|
|
11011
|
-
async settleRerun(asset, decision) {
|
|
11012
|
-
this.pendingReruns.delete(asset.id);
|
|
11013
|
-
if (decision.status === "pending") {
|
|
11014
|
-
this.pendingReruns.add(asset.id);
|
|
11015
|
-
return asset;
|
|
11016
|
-
}
|
|
11017
|
-
if (decision.status === "failed") return asset;
|
|
11018
|
-
return this.settle(asset, decision);
|
|
11019
|
-
}
|
|
11020
10943
|
/** Asks `moderate` (unless `decision` is given) and settles a processing asset. */
|
|
11021
10944
|
async moderateStored(asset, trigger, decision) {
|
|
11022
10945
|
return this.settle(asset, decision ?? await this.decisionFor(asset, trigger, true));
|
|
@@ -11679,6 +11602,7 @@ var MockCalmLensApi = class {
|
|
|
11679
11602
|
const status = asset.classification.moderation.decision;
|
|
11680
11603
|
const isHead = request.method === "HEAD";
|
|
11681
11604
|
const { rendered, preview } = asset.content;
|
|
11605
|
+
if (resource !== "info" && asset.content.status === "removed") return notFound();
|
|
11682
11606
|
if (asset.visibility !== "public" && !grant && !hasApiKey && resource !== "info") return notFound();
|
|
11683
11607
|
if (resource === "info") return this.serveInfo(request, asset, Boolean(grant) || canDownload());
|
|
11684
11608
|
if (asset.content.safetyHold) return notAvailable();
|
|
@@ -11695,7 +11619,7 @@ var MockCalmLensApi = class {
|
|
|
11695
11619
|
});
|
|
11696
11620
|
}
|
|
11697
11621
|
const storedContent = await this.imageStorage.getContent(asset.id);
|
|
11698
|
-
if (asset.upload.status === "uploading" || status === "purged" || status === "blocked" || asset.classification.status === "failed" ||
|
|
11622
|
+
if (asset.upload.status === "uploading" || status === "purged" || status === "blocked" || asset.classification.status === "failed" || resource === "original" && !storedContent) return notAvailable();
|
|
11699
11623
|
let claims = {};
|
|
11700
11624
|
try {
|
|
11701
11625
|
claims = JSON.parse(query.get("viewerClaims") ?? request.headers.get("X-CalmLens-Viewer-Claims") ?? "{}");
|
|
@@ -12045,11 +11969,8 @@ var MockCalmLensServerClient = class extends require_CalmLensServerClient.CalmLe
|
|
|
12045
11969
|
* else what `mockOptions.moderate` returns for the `complete` trigger (`allowed` by default).
|
|
12046
11970
|
* The asset gets the decision's report, and `asset.classified` and the automated
|
|
12047
11971
|
* `asset.<status>` (or `asset.failed`) join the events feed. No review is recorded, so the
|
|
12048
|
-
* asset can still be moderated again.
|
|
12049
|
-
* `
|
|
12050
|
-
* `pending` or `failed`. Rejects with `asset/not-found` for an unknown asset and
|
|
12051
|
-
* `sdk/invalid-argument` for one that isn't processing or awaiting a pending re-run. It sends
|
|
12052
|
-
* no request.
|
|
11972
|
+
* asset can still be moderated again. Rejects with `asset/not-found` for an unknown asset and
|
|
11973
|
+
* `sdk/invalid-argument` for one that isn't processing. It sends no request.
|
|
12053
11974
|
*/
|
|
12054
11975
|
completeProcessing(assetId, decision) {
|
|
12055
11976
|
return this.#api.completeProcessing(assetId, decision);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./CalmLensTypes-
|
|
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-
|
|
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> {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const require_ModerationContextLimits = require("./ModerationContextLimits-
|
|
2
|
-
const require_UploadController = require("./UploadController-
|
|
3
|
-
require("./Core-
|
|
1
|
+
const require_ModerationContextLimits = require("./ModerationContextLimits-BcYKgU2X.js");
|
|
2
|
+
const require_UploadController = require("./UploadController-C8GPbDKI.js");
|
|
3
|
+
require("./Core-D-1KCqT7.js");
|
|
4
4
|
// src/ui/viewers/PdfLoader.ts
|
|
5
5
|
let loading;
|
|
6
6
|
/**
|
|
@@ -490,7 +490,7 @@ var DocumentViewer = class extends ViewerBase {
|
|
|
490
490
|
const page = await document.getPage(pageNumber);
|
|
491
491
|
if (render !== this.#renders) return;
|
|
492
492
|
const natural = page.getViewport({ scale: 1 });
|
|
493
|
-
const available = controls.pages.clientWidth
|
|
493
|
+
const available = controls.pages.clientWidth;
|
|
494
494
|
const scale = this.#zoom ?? (available > 0 ? available / natural.width : 1);
|
|
495
495
|
this.#scale = scale;
|
|
496
496
|
controls.zoomLevel.textContent = formatViewerMessage(messages.zoomLevel, { percent: Math.round(scale * 100) });
|
package/cjs/ui.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
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-
|
|
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-
|
|
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
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/cjs/ui.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_ui = require("./ui-
|
|
3
|
-
const require_UploadController = require("./UploadController-
|
|
4
|
-
const require_Core = require("./Core-
|
|
2
|
+
const require_ui = require("./ui-CW8BqtZk.js");
|
|
3
|
+
const require_UploadController = require("./UploadController-C8GPbDKI.js");
|
|
4
|
+
const require_Core = require("./Core-D-1KCqT7.js");
|
|
5
5
|
exports.ASSET_FILE_ICON_SIZE = require_Core.ASSET_FILE_ICON_SIZE;
|
|
6
6
|
exports.ASSET_VIEWERS = require_ui.ASSET_VIEWERS;
|
|
7
7
|
exports.AssetSession = require_Core.AssetSession;
|
package/cjs/vue.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { O as CalmLensAppClientOptions,
|
|
2
|
-
import "./index-
|
|
3
|
-
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, J as AssetSessionState, K as AssetOptions, M as UploadClient, N as UploadController, O as CalmLensProvidedOptions, 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, ht as getAssetViewerKind, i as CALMLENS_STYLES, it as pickAssetSource, j as CustomUploadResult, 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 } from "./Core-
|
|
4
|
-
import { a as UploaderProps, i as UploadSnapshot, n as UploadControllerOptions, r as UploadItem, s as createUploadController, t as CalmLensUpload } from "./BrowserUpload-
|
|
5
|
-
import { C as ViewerState, S as AssetViewer, _ as spreadsheetColumnIndex, a as isMountedViewerKind, b as createWebsiteViewer, c as AssetViewerOptionsByKind, d as createTextViewer, f as SpreadsheetCell, g as parseSpreadsheetText, h as getSpreadsheetPage, i as getMountedViewerOptions, l as VIEWER_STYLES, m as SpreadsheetSheet, n as AssetViewerMount, o as ASSET_VIEWERS, p as SpreadsheetRow, r as MountedViewerKind, s as AssetViewerName, t as MediaStreamPlayer, u as createSpreadsheetViewer, v as loadPdfJs, x as createDocumentViewer, y as createImageViewer } from "./ui-
|
|
1
|
+
import { O as CalmLensAppClientOptions, en as ViewerClaims, g as AssetModerationStatus, i as AssetAvailability } from "./CalmLensTypes-HUERg5hI.js";
|
|
2
|
+
import "./index-Ck7x1YjM.js";
|
|
3
|
+
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, J as AssetSessionState, K as AssetOptions, M as UploadClient, N as UploadController, O as CalmLensProvidedOptions, 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, ht as getAssetViewerKind, i as CALMLENS_STYLES, it as pickAssetSource, j as CustomUploadResult, 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 } from "./Core-DXAs8mcx.js";
|
|
4
|
+
import { a as UploaderProps, i as UploadSnapshot, n as UploadControllerOptions, r as UploadItem, s as createUploadController, t as CalmLensUpload } from "./BrowserUpload-D4sEmd0X.js";
|
|
5
|
+
import { C as ViewerState, S as AssetViewer, _ as spreadsheetColumnIndex, a as isMountedViewerKind, b as createWebsiteViewer, c as AssetViewerOptionsByKind, d as createTextViewer, f as SpreadsheetCell, g as parseSpreadsheetText, h as getSpreadsheetPage, i as getMountedViewerOptions, l as VIEWER_STYLES, m as SpreadsheetSheet, n as AssetViewerMount, o as ASSET_VIEWERS, p as SpreadsheetRow, r as MountedViewerKind, s as AssetViewerName, t as MediaStreamPlayer, u as createSpreadsheetViewer, v as loadPdfJs, x as createDocumentViewer, y as createImageViewer } from "./ui-BfJNO3c6.js";
|
|
6
6
|
import { App, MaybeRefOrGetter, PropType, ShallowRef } from "vue";
|
|
7
7
|
/** Shows an image asset's rendered file, fitted to the element, over its placeholder. */
|
|
8
8
|
export declare const CalmLensImageViewer: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
package/cjs/vue.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_ui = require("./ui-
|
|
3
|
-
const require_UploadController = require("./UploadController-
|
|
4
|
-
const require_Core = require("./Core-
|
|
2
|
+
const require_ui = require("./ui-CW8BqtZk.js");
|
|
3
|
+
const require_UploadController = require("./UploadController-C8GPbDKI.js");
|
|
4
|
+
const require_Core = require("./Core-D-1KCqT7.js");
|
|
5
5
|
const require_FileIcons = require("./FileIcons-Ob003MdS.js");
|
|
6
|
-
const require_BrowserUpload = require("./BrowserUpload-
|
|
6
|
+
const require_BrowserUpload = require("./BrowserUpload-CTqIjCV5.js");
|
|
7
7
|
let vue = require("vue");
|
|
8
8
|
// src/viewers/Vue.ts
|
|
9
9
|
const optional$1 = (type) => ({
|
|
@@ -513,7 +513,7 @@ const CalmLensAsset = (0, vue.defineComponent)({
|
|
|
513
513
|
"aria-busy": current.kind === "pending" ? "true" : void 0,
|
|
514
514
|
style: {
|
|
515
515
|
aspectRatio: ratio,
|
|
516
|
-
|
|
516
|
+
"--calmlens-average-color": state.value.info?.content?.preview?.averageColor ?? void 0,
|
|
517
517
|
"--calmlens-fit": props.fit
|
|
518
518
|
}
|
|
519
519
|
}, [
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as createUploadController$1 } from "./UploadController-
|
|
1
|
+
import { n as createUploadController$1 } from "./UploadController-Q7xTqh5w.js";
|
|
2
2
|
// src/ui/BrowserUpload.ts
|
|
3
3
|
/** Creates an upload queue for the browser components, such as one a form starts on submit. */
|
|
4
4
|
const createUploadController = (options) => createUploadController$1(options);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as UploadFile, I as UploadItem$1, L as UploadSnapshot$1, N as UploadController, P as UploadControllerOptions$1, h as UploaderProps$1, k as CalmLensUpload$1 } from "./Core-
|
|
2
|
-
import { r as UseCalmLensUploadResult$1 } from "./ReactUpload-
|
|
1
|
+
import { F as UploadFile, I as UploadItem$1, L as UploadSnapshot$1, N as UploadController, P as UploadControllerOptions$1, h as UploaderProps$1, k as CalmLensUpload$1 } from "./Core-DXAs8mcx.js";
|
|
2
|
+
import { r as UseCalmLensUploadResult$1 } from "./ReactUpload-BTciTpwB.js";
|
|
3
3
|
type UploadItem<F extends UploadFile = File> = UploadItem$1<F>;
|
|
4
4
|
type CalmLensUpload<F extends UploadFile = File> = CalmLensUpload$1<F>;
|
|
5
5
|
type UploadSnapshot<F extends UploadFile = File> = UploadSnapshot$1<F>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { At as RetrieveAssetOptions, M as CdnAssetUrlOptions, O as CalmLensAppClientOptions, Ot as RequestOptions, Qt as UploadedAsset, Zt as UploadPresetSubmitAssetOptions, qt as UploadAssetPartOptions } from "./CalmLensTypes-HUERg5hI.js";
|
|
2
2
|
declare const inspectSymbol: unique symbol;
|
|
3
3
|
declare class CalmLensAppClient {
|
|
4
4
|
#private;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as validateAppClientOptions, ct as invalidConfig, d as checkOptionKeys, o as buildAssetUrl, p as encodePathSegment, st as invalidArgument, u as DEFAULT_CDN_BASE_URL } from "./ModerationContextLimits-
|
|
2
|
-
import { d as prepareSubmitAssetOptions, f as resolveConnectionOptions, i as CalmLensConnection, p as splitsIntoParts, s as expectUploadedAsset, t as APP_OPTION_KEYS } from "./CalmLensOptionKeys-
|
|
1
|
+
import { S as validateAppClientOptions, ct as invalidConfig, d as checkOptionKeys, o as buildAssetUrl, p as encodePathSegment, st as invalidArgument, u as DEFAULT_CDN_BASE_URL } from "./ModerationContextLimits-BmV8QD32.js";
|
|
2
|
+
import { d as prepareSubmitAssetOptions, f as resolveConnectionOptions, i as CalmLensConnection, p as splitsIntoParts, s as expectUploadedAsset, t as APP_OPTION_KEYS } from "./CalmLensOptionKeys-CEwNbpEz.js";
|
|
3
3
|
// src/client/CalmLensAppClient.ts
|
|
4
4
|
const inspectSymbol = Symbol.for("nodejs.util.inspect.custom");
|
|
5
5
|
/** `options`, once `checkOptionKeys` finds only keys `operation` takes. */
|
|
@@ -65,13 +65,13 @@ var CalmLensAppClient = class {
|
|
|
65
65
|
const connection = this.#connection.forCall(operation, requestOptions);
|
|
66
66
|
if (!options || typeof options !== "object") throw invalidArgument("Upload options are required");
|
|
67
67
|
if (!("content" in options) && !("part" in options)) throw invalidArgument("Uploads through an upload preset need content or a part");
|
|
68
|
-
prepareSubmitAssetOptions(options, {
|
|
68
|
+
const prepared = prepareSubmitAssetOptions(options, {
|
|
69
69
|
deferUploadChecks: connection.deferUploadChecks,
|
|
70
70
|
partSizeBytes: connection.partSizeBytes
|
|
71
71
|
});
|
|
72
72
|
const token = await this.newUploadToken();
|
|
73
|
-
if ("content" in
|
|
74
|
-
const data = await connection.submitInParts(this.uploadsPath,
|
|
73
|
+
if ("content" in prepared && splitsIntoParts(prepared.content, connection.partSizeBytes)) {
|
|
74
|
+
const data = await connection.submitInParts(this.uploadsPath, prepared, wait, {
|
|
75
75
|
authHeaders: token ? { Authorization: `Bearer ${token}` } : {},
|
|
76
76
|
partPath: (assetId) => `${this.uploadsPath}/${encodeURIComponent(assetId)}/part`,
|
|
77
77
|
onStarted: (assetId) => {
|
|
@@ -81,7 +81,7 @@ var CalmLensAppClient = class {
|
|
|
81
81
|
});
|
|
82
82
|
return expectUploadedAsset(data);
|
|
83
83
|
}
|
|
84
|
-
const data = await connection.submitUpload(this.uploadsPath,
|
|
84
|
+
const data = await connection.submitUpload(this.uploadsPath, prepared, wait, token ? { Authorization: `Bearer ${token}` } : {});
|
|
85
85
|
const uploaded = expectUploadedAsset(data);
|
|
86
86
|
if (token) this.#uploadTokens.set(uploaded.id, token);
|
|
87
87
|
return uploaded;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as resolveLogLevel, D as MAX_IMAGE_UPLOAD_BYTES, E as MAX_DIRECT_IMAGE_UPLOAD_BYTES, M as sleep, O as MAX_NON_IMAGE_UPLOAD_BYTES, Y as CalmLensError, _ as randomUuid, j as CalmLensTransport, k as getRejectedUploadMimeTypeError, lt as API_ERROR_CODES, m as isAcceptedUploadMimeType, ot as SDK_ERROR_CODES, r as selectModerationContextItems, st as invalidArgument, y as stringifyQuery } from "./ModerationContextLimits-
|
|
1
|
+
import { B as resolveLogLevel, D as MAX_IMAGE_UPLOAD_BYTES, E as MAX_DIRECT_IMAGE_UPLOAD_BYTES, M as sleep, O as MAX_NON_IMAGE_UPLOAD_BYTES, Y as CalmLensError, _ as randomUuid, j as CalmLensTransport, k as getRejectedUploadMimeTypeError, lt as API_ERROR_CODES, m as isAcceptedUploadMimeType, ot as SDK_ERROR_CODES, r as selectModerationContextItems, st as invalidArgument, y as stringifyQuery } from "./ModerationContextLimits-BmV8QD32.js";
|
|
2
2
|
// src/contract/AssetPayload.js
|
|
3
3
|
const bufferInputToBytes = (value) => {
|
|
4
4
|
if (value instanceof ArrayBuffer) return new Uint8Array(value);
|
|
@@ -12,8 +12,9 @@ const getRawBase64 = (value) => {
|
|
|
12
12
|
return value.slice(markerIndex + 8);
|
|
13
13
|
};
|
|
14
14
|
const validateBase64PayloadString = (payload, options) => {
|
|
15
|
-
const raw = getRawBase64(payload.base64)
|
|
16
|
-
|
|
15
|
+
const raw = getRawBase64(payload.base64);
|
|
16
|
+
const whitespace = /\s/.test(raw) ? raw.match(/\s/g)?.length ?? 0 : 0;
|
|
17
|
+
if (options?.multipart && (raw.length - whitespace) % 4 !== 0) return {
|
|
17
18
|
ok: false,
|
|
18
19
|
error: BASE64_PART_BOUNDARY_ERROR
|
|
19
20
|
};
|
|
@@ -30,7 +31,7 @@ const assetToData = (payload) => {
|
|
|
30
31
|
if (payload.uint8Array !== void 0) return Uint8Array.from(payload.uint8Array);
|
|
31
32
|
if (payload.base64 === void 0) throw new Error("Invalid asset payload");
|
|
32
33
|
const raw = getRawBase64(payload.base64);
|
|
33
|
-
if (typeof Buffer !== "undefined") return
|
|
34
|
+
if (typeof Buffer !== "undefined") return Buffer.from(raw, "base64");
|
|
34
35
|
const binary = atob(raw);
|
|
35
36
|
return Uint8Array.from(binary, (char) => char.charCodeAt(0));
|
|
36
37
|
};
|
|
@@ -258,7 +259,29 @@ const assertUploadSize = (type, size, inParts) => {
|
|
|
258
259
|
});
|
|
259
260
|
};
|
|
260
261
|
/** Checks upload options before anything is sent. */
|
|
261
|
-
const
|
|
262
|
+
const isBlob = (value) => typeof Blob !== "undefined" && value instanceof Blob;
|
|
263
|
+
/**
|
|
264
|
+
* `content` given as a `Blob` or `File`, as the `{ data, type }` the rest of the client reads: the
|
|
265
|
+
* content type is the Blob's own, and a File's name is the asset's when the options give none.
|
|
266
|
+
*/
|
|
267
|
+
const withContentObject = (options) => {
|
|
268
|
+
if (!options || typeof options !== "object" || !("content" in options)) return options;
|
|
269
|
+
const content = options.content;
|
|
270
|
+
if (!isBlob(content)) return options;
|
|
271
|
+
if (!content.type) throw invalidPayload("The Blob has no type: create it with one, such as new Blob([bytes], { type: \"image/png\" }), or pass { data, type }");
|
|
272
|
+
const fileName = typeof File !== "undefined" && content instanceof File ? content.name : void 0;
|
|
273
|
+
const named = options;
|
|
274
|
+
return {
|
|
275
|
+
...options,
|
|
276
|
+
...named.name || !fileName ? {} : { name: fileName },
|
|
277
|
+
content: {
|
|
278
|
+
data: content,
|
|
279
|
+
type: content.type
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
};
|
|
283
|
+
const prepareSubmitAssetOptions = (input, { deferUploadChecks = false, partSizeBytes = DEFAULT_PART_SIZE_BYTES } = {}) => {
|
|
284
|
+
const options = withContentObject(input);
|
|
262
285
|
if (!options || typeof options !== "object") throw invalidArgument("Asset options are required");
|
|
263
286
|
if (!("content" in options) && !("url" in options) && !("part" in options)) throw invalidPayload("Either file content, URL, or multipart part is required");
|
|
264
287
|
if (!options.name) throw invalidPayload("Asset name is required");
|
|
@@ -677,7 +700,6 @@ const SERVER_OPTION_KEYS = {
|
|
|
677
700
|
"note"
|
|
678
701
|
],
|
|
679
702
|
"assets.delete": ["assetId"],
|
|
680
|
-
"assets.explain": ["assetId", "rerun"],
|
|
681
703
|
"assets.list": [
|
|
682
704
|
"cursor",
|
|
683
705
|
"filter",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { d as HashListEntry, u as HashList } from "./Classification-
|
|
2
|
-
import { $ as
|
|
3
|
-
import { d as ListPromise, l as CalmLensResponse, r as CdnResponse } from "./WebhookPayload-
|
|
1
|
+
import { d as HashListEntry, u as HashList } from "./Classification-CMM2tZpJ-IdIh63n0.js";
|
|
2
|
+
import { $ as FolderPage, $t as VerifyWebhookSignatureOptions, An as Policy, At as RetrieveAssetOptions, B as CreateHashListOptions, Bt as UpdateAssetOptions, D as BatchAssetsResponse, E as BatchAssetsOptions, Et as RemoveAssetContentOptions, Ft as SignUploadTokenOptions, G as DeleteAssetOptions, Gt as UpdateProjectSettingsOptions, Ht as UpdateHashListOptions, I as ClassifyTextOptions, In as AssetInfo, It as SignedAssetUrl, J as EnsureLensesOptions, K as DeleteMetadataFieldOptions, Kt as UpgradePolicyOptions, Lt as SignedUploadToken, M as CdnAssetUrlOptions, Nt as SetPolicyAutomaticUpdatesOptions, Ot as RequestOptions, P as CdnServeOptions, Pn as AssetSearchQuery, Pt as SignAssetUrlOptions, Q as FolderIdOptions, T as AssignPolicyOptions, Tt as PolicyPage, U as CreatePolicyOptions, Ut as UpdateLensOptions, V as CreateLensOptions, Vt as UpdateFolderOptions, W as DecideAssetOptions, Wt as UpdatePolicyOptions, X as EnsureUploadPresetsOptions, Xt as UploadPresetPage, Y as EnsureMetadataFieldsOptions, Yt as UploadPresetIdOptions, Z as EnsureUploadPresetsResponse, _ as AssetPage, _n as Folder, _t as ListLensesOptions, b as AssetTimelinePage, bt as MoveAssetOptions, ct as LensIdOptions, dt as ListAssetTimelineOptions, et as GetAssetInfoOptions, ft as ListAssetsOptions, gt as ListHashListsOptions, ht as ListHashListEntriesOptions, it as HashListPage, jt as RetryAssetOptions, k as CalmLensServerClientOptions, kt as ResetPolicyOptions, lt as LensPage, mt as ListFoldersOptions, nt as HashListEntryPage, o as AssetChildrenPage, on as GetEventsResponse, pt as ListEventsOptions, q as EnsureLensOptions, qt as UploadAssetPartOptions, r as Asset, rt as HashListIdOptions, st as Lens, t as AddHashListEntryOptions, tn as WaitForAssetDecisionOptions, tt as HashListEntryIdOptions, ut as ListAssetChildrenOptions, v as AssetSearchResponse, vn as MetadataFieldsResource, vt as ListPoliciesOptions, wt as PolicyIdOptions, xt as MoveFolderOptions, yn as ProjectSettingsResource, yt as ListUploadPresetsOptions, z as CreateFolderOptions, zt as SubmitAssetOptions } from "./CalmLensTypes-HUERg5hI.js";
|
|
3
|
+
import { d as ListPromise, l as CalmLensResponse, r as CdnResponse } from "./WebhookPayload-mUmOFH55.js";
|
|
4
4
|
interface TransportRequest {
|
|
5
5
|
/** The client method sending the request, such as `assets.retrieve`, for hooks and logs. */
|
|
6
6
|
operation?: string;
|
|
@@ -167,17 +167,6 @@ declare class CalmLensServerClient {
|
|
|
167
167
|
* needs `confirmPurge: true` and permanently deletes the stored content.
|
|
168
168
|
*/
|
|
169
169
|
decide: (options: DecideAssetOptions, requestOptions?: RequestOptions) => Promise<CalmLensResponse<Asset>>;
|
|
170
|
-
/**
|
|
171
|
-
* Completes the policy evidence behind a decided asset's moderation decision: its
|
|
172
|
-
* `classification.moderation.explanationComplete` becomes `true` and every action stays as
|
|
173
|
-
* decided. With `rerun: true` the asset is moderated again with the project's current policy
|
|
174
|
-
* and an `asset.rerun-requested` event is recorded; use it when the policy has changed since
|
|
175
|
-
* the decision (`asset/policy-changed`). The asset returns unchanged: it keeps its decision
|
|
176
|
-
* until the re-run's is stored, reported by `asset.classified` and `asset.<status>` events,
|
|
177
|
-
* and a failed re-run keeps it. A reviewed asset fails with `asset/reviewed`, and one whose
|
|
178
|
-
* content is gone with `asset/content-unavailable`.
|
|
179
|
-
*/
|
|
180
|
-
explain: (options: ExplainAssetOptions, requestOptions?: RequestOptions) => Promise<CalmLensResponse<Asset>>;
|
|
181
170
|
/**
|
|
182
171
|
* Waits until an asset is settled, its `classification.status` `completed` (with its
|
|
183
172
|
* decision in `classification.moderation.decision`) or `failed`, and returns that asset,
|