calmlens 0.30.0 → 0.31.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/bin/calmlens.js +2 -29
- package/{esm/BrowserUpload-DS6KT6o_.d.ts → cjs/BrowserUpload-BAH54V1q.d.ts} +2 -2
- package/cjs/{BrowserUpload-BNeTp6eF.js → BrowserUpload-BwBE37LM.js} +1 -1
- package/cjs/{CalmLensAppClient-B4vzxEzg.d.ts → CalmLensAppClient-CdlcDd5l.d.ts} +1 -1
- package/cjs/{CalmLensAppClient-ClqGwUbl.js → CalmLensAppClient-D6Y7MgH_.js} +10 -10
- package/cjs/{ModerationContextLimits-BVBkcgSU.js → CalmLensCdn-Q68faCEE.js} +2 -52
- package/cjs/{CalmLensConnection-og0jh-Fw.js → CalmLensConnection-j2aBsuNx.js} +15 -22
- package/cjs/{CalmLensError-DPHJaVjX.js → CalmLensError-ifj5rLmk.js} +5 -0
- package/cjs/{CalmLensServerClient-KsXM77rO.js → CalmLensServerClient-CjK691kq.js} +22 -22
- package/{esm/CalmLensServerClient-BJl2Hsxr.d.ts → cjs/CalmLensServerClient-CtS66dCU.d.ts} +3 -3
- package/cjs/{CalmLensTestInputArguments-BXDBAOg_.js → CalmLensTestInputArguments-PYuRmE0j.js} +1 -1
- package/cjs/{CalmLensTypes-fAgF0_lq.d.ts → CalmLensTypes-87kiUg0H.d.ts} +3 -5
- package/cjs/{Classification-DbXUPSvH-C0o2t4mg.d.ts → Classification-C3pkrGYS-B7EygpJn.d.ts} +2 -21
- package/cjs/{Core-DL531ZPG.d.ts → Core-Ccy4-_sN.d.ts} +2 -2
- package/cjs/{Core-eDiPpil9.js → Core-Dsj4tRNP.js} +8 -8
- package/cjs/{ReactUpload-DAPAzAwY.js → ReactUpload-B7SdNAel.js} +1 -1
- package/cjs/{ReactUpload-BoS0lr7U.d.ts → ReactUpload-DBhppuxM.d.ts} +1 -1
- package/{esm/TestTriggers-CLjF01NU.d.ts → cjs/TestTriggers-Daxebd0V.d.ts} +1 -1
- package/cjs/{UploadController-BElzwMic.js → UploadController-DsIENVY1.js} +2 -2
- package/{esm/WebhookPayload-DlGoY_db.d.ts → cjs/WebhookPayload-B4rA_Dvm.d.ts} +3 -1
- package/cjs/app.d.ts +6 -6
- package/cjs/app.js +8 -11
- package/cjs/elements.d.ts +4 -4
- package/cjs/elements.js +4 -4
- package/cjs/{index-ChrzzIRt.d.ts → index-CWUnLKoF.d.ts} +8 -4
- package/cjs/index.d.ts +5 -5
- package/cjs/index.js +7 -10
- package/cjs/react-native.d.ts +2 -2
- package/cjs/react-native.js +7 -7
- package/cjs/react.d.ts +4 -4
- package/cjs/react.js +5 -5
- package/cjs/server.d.ts +6 -6
- package/cjs/server.js +8 -11
- package/cjs/test-inputs.d.ts +1 -1
- package/cjs/test-inputs.js +1 -1
- package/cjs/testing.d.ts +5 -5
- package/cjs/testing.js +82 -25
- package/cjs/{ui-COjb2Hx6.js → ui-BC70R8KT.js} +3 -3
- package/cjs/{ui-DpZOLeVs.d.ts → ui-sjnJhloQ.d.ts} +2 -2
- package/cjs/ui.d.ts +2 -2
- package/cjs/ui.js +3 -3
- package/cjs/vue.d.ts +5 -5
- package/cjs/vue.js +4 -4
- package/{cjs/BrowserUpload-DS6KT6o_.d.ts → esm/BrowserUpload-BAH54V1q.d.ts} +2 -2
- package/esm/{BrowserUpload-BCmj5eGu.js → BrowserUpload-DSLCpWgz.js} +1 -1
- package/esm/{CalmLensAppClient-DcPVLn2y.js → CalmLensAppClient-BKanqwYL.js} +3 -3
- package/esm/{CalmLensAppClient-B4vzxEzg.d.ts → CalmLensAppClient-CdlcDd5l.d.ts} +1 -1
- package/esm/{ModerationContextLimits-DmjWgTBa.js → CalmLensCdn-CL1P1v2t.js} +3 -35
- package/esm/{CalmLensConnection-Pm-g6a1l.js → CalmLensConnection-CHNNULpg.js} +2 -9
- package/esm/{CalmLensError-BDWThPCr.js → CalmLensError-C15tWu8W.js} +5 -0
- package/esm/{CalmLensServerClient-C2HGsjkT.js → CalmLensServerClient-CBjSqROz.js} +3 -3
- package/{cjs/CalmLensServerClient-BJl2Hsxr.d.ts → esm/CalmLensServerClient-CtS66dCU.d.ts} +3 -3
- package/esm/{CalmLensTestInputArguments-Xh4GIadS.js → CalmLensTestInputArguments-CqPADTkl.js} +1 -1
- package/esm/{CalmLensTypes-fAgF0_lq.d.ts → CalmLensTypes-87kiUg0H.d.ts} +3 -5
- package/esm/{Classification-DbXUPSvH-C0o2t4mg.d.ts → Classification-C3pkrGYS-B7EygpJn.d.ts} +2 -21
- package/esm/{Core-DL531ZPG.d.ts → Core-Ccy4-_sN.d.ts} +2 -2
- package/esm/{Core-KYgLJ0eb.js → Core-WxPuobo_.js} +3 -3
- package/esm/{ReactUpload-BoS0lr7U.d.ts → ReactUpload-DBhppuxM.d.ts} +1 -1
- package/esm/{ReactUpload-QW_RNxFp.js → ReactUpload-U49veoZl.js} +1 -1
- package/{cjs/TestTriggers-CLjF01NU.d.ts → esm/TestTriggers-Daxebd0V.d.ts} +1 -1
- package/esm/{UploadController-Civ7QPwT.js → UploadController-X2gEFMGy.js} +2 -2
- package/{cjs/WebhookPayload-DlGoY_db.d.ts → esm/WebhookPayload-B4rA_Dvm.d.ts} +3 -1
- package/esm/app.d.ts +6 -6
- package/esm/app.js +4 -4
- package/esm/elements.d.ts +4 -4
- package/esm/elements.js +4 -4
- package/esm/{index-ChrzzIRt.d.ts → index-CWUnLKoF.d.ts} +8 -4
- package/esm/index.d.ts +5 -5
- package/esm/index.js +3 -3
- package/esm/react-native.d.ts +2 -2
- package/esm/react-native.js +4 -4
- package/esm/react.d.ts +4 -4
- package/esm/react.js +5 -5
- package/esm/server.d.ts +6 -6
- package/esm/server.js +4 -4
- package/esm/test-inputs.d.ts +1 -1
- package/esm/test-inputs.js +1 -1
- package/esm/testing.d.ts +5 -5
- package/esm/testing.js +67 -10
- package/esm/{ui-BVXgDCO2.js → ui-DS85DGfi.js} +2 -2
- package/esm/{ui-DpZOLeVs.d.ts → ui-sjnJhloQ.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 +4 -4
- package/package.json +1 -1
package/bin/calmlens.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
4
4
|
import { parseArgs } from "node:util";
|
|
5
5
|
// package.json
|
|
6
|
-
var version = "0.
|
|
6
|
+
var version = "0.31.1";
|
|
7
7
|
|
|
8
8
|
// src/contract/ModerationCategories-CHFRoeWV.js
|
|
9
9
|
var CLASSIFICATION_CATEGORIES = [
|
|
@@ -139,6 +139,7 @@ var API_ERROR_CODES = {
|
|
|
139
139
|
REMOTE_URL_UNAVAILABLE: "remote-url/unavailable",
|
|
140
140
|
APPEAL_NOT_FOUND: "appeal/not-found",
|
|
141
141
|
APPEAL_JUDGMENT_NOT_FOUND: "appeal/judgment-not-found",
|
|
142
|
+
CONTEXT_ASSET_NOT_FOUND: "context/asset-not-found",
|
|
142
143
|
APPEAL_ASSET_NOT_FOUND: "appeal/asset-not-found",
|
|
143
144
|
APPEAL_PERMISSION_DENIED: "appeal/permission-denied",
|
|
144
145
|
APPEAL_ALREADY_REVIEWED: "appeal/already-reviewed",
|
|
@@ -1882,28 +1883,6 @@ var validateAssetPayload = (payload, options) => {
|
|
|
1882
1883
|
// src/contract/Media-B2PMcUf7.js
|
|
1883
1884
|
var MAX_MEDIA_UPLOAD_BYTES = 52428800;
|
|
1884
1885
|
var MAX_LONG_MEDIA_UPLOAD_BYTES = 2147483648;
|
|
1885
|
-
// src/contract/ModerationContextLimits-k930WU8i.js
|
|
1886
|
-
var countModerationContextCharacters = (text) => {
|
|
1887
|
-
let count = 0;
|
|
1888
|
-
for (const _ of text)
|
|
1889
|
-
count++;
|
|
1890
|
-
return count;
|
|
1891
|
-
};
|
|
1892
|
-
var selectModerationContextItems = (items) => {
|
|
1893
|
-
const selected = [];
|
|
1894
|
-
let characters = 0;
|
|
1895
|
-
for (let index = items.length - 1;index >= 0; index--) {
|
|
1896
|
-
if (selected.length === 5)
|
|
1897
|
-
break;
|
|
1898
|
-
const item = items[index];
|
|
1899
|
-
const length = countModerationContextCharacters(item.text);
|
|
1900
|
-
if (selected.length && characters + length > 2000)
|
|
1901
|
-
break;
|
|
1902
|
-
selected.unshift(item);
|
|
1903
|
-
characters += length;
|
|
1904
|
-
}
|
|
1905
|
-
return selected;
|
|
1906
|
-
};
|
|
1907
1886
|
// src/client/CalmLensOptionKeys.ts
|
|
1908
1887
|
var SERVER_OPTION_KEYS = {
|
|
1909
1888
|
"assets.batch": ["assetIds", "operation"],
|
|
@@ -2235,12 +2214,6 @@ var prepareSubmitAssetOptions = (input, {
|
|
|
2235
2214
|
if (!validation.ok)
|
|
2236
2215
|
throw invalidPayload(validation.error);
|
|
2237
2216
|
}
|
|
2238
|
-
if (options.context !== undefined) {
|
|
2239
|
-
if (!options.context || !Array.isArray(options.context.items)) {
|
|
2240
|
-
throw invalidArgument("context.items must be an array of earlier posts");
|
|
2241
|
-
}
|
|
2242
|
-
return { ...options, context: { items: selectModerationContextItems(options.context.items) } };
|
|
2243
|
-
}
|
|
2244
2217
|
return options;
|
|
2245
2218
|
};
|
|
2246
2219
|
var newIdempotencyKey = () => randomUuid();
|
|
@@ -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-Ccy4-_sN.js";
|
|
2
|
+
import { r as UseCalmLensUploadResult$1 } from "./ReactUpload-DBhppuxM.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
|
-
const require_UploadController = require("./UploadController-
|
|
1
|
+
const require_UploadController = require("./UploadController-DsIENVY1.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) => require_UploadController.createUploadController(options);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $t as UploadPresetSubmitAssetOptions, M as CdnAssetUrlOptions, Mt as RetrieveAssetOptions, O as CalmLensAppClientOptions, Yt as UploadAssetPartOptions, en as UploadedAsset, kt as RequestOptions } from "./CalmLensTypes-
|
|
1
|
+
import { $t as UploadPresetSubmitAssetOptions, M as CdnAssetUrlOptions, Mt as RetrieveAssetOptions, O as CalmLensAppClientOptions, Yt as UploadAssetPartOptions, en as UploadedAsset, kt as RequestOptions } from "./CalmLensTypes-87kiUg0H.js";
|
|
2
2
|
declare const inspectSymbol: unique symbol;
|
|
3
3
|
/**
|
|
4
4
|
* The CalmLens client for browsers and React Native apps. It uploads through an upload preset,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
const require_CalmLensError = require("./CalmLensError-
|
|
2
|
-
const
|
|
3
|
-
const require_CalmLensConnection = require("./CalmLensConnection-
|
|
1
|
+
const require_CalmLensError = require("./CalmLensError-ifj5rLmk.js");
|
|
2
|
+
const require_CalmLensCdn = require("./CalmLensCdn-Q68faCEE.js");
|
|
3
|
+
const require_CalmLensConnection = require("./CalmLensConnection-j2aBsuNx.js");
|
|
4
4
|
// src/client/CalmLensAppClient.ts
|
|
5
5
|
const inspectSymbol = Symbol.for("nodejs.util.inspect.custom");
|
|
6
6
|
/** `options`, once `checkOptionKeys` finds only keys `operation` takes. */
|
|
7
7
|
const checked = (operation, options) => {
|
|
8
|
-
|
|
8
|
+
require_CalmLensCdn.checkOptionKeys(options, operation, require_CalmLensConnection.APP_OPTION_KEYS);
|
|
9
9
|
return options;
|
|
10
10
|
};
|
|
11
11
|
/**
|
|
@@ -23,12 +23,12 @@ var CalmLensAppClient = class {
|
|
|
23
23
|
#projectId;
|
|
24
24
|
#cdnBaseUrl;
|
|
25
25
|
constructor(options) {
|
|
26
|
-
|
|
26
|
+
require_CalmLensCdn.validateAppClientOptions(options);
|
|
27
27
|
const { token, uploadPresetId, projectId, cdnBaseUrl, ...rest } = options;
|
|
28
28
|
this.#uploadPresetId = uploadPresetId;
|
|
29
29
|
this.#token = token;
|
|
30
30
|
this.#projectId = projectId;
|
|
31
|
-
this.#cdnBaseUrl = (cdnBaseUrl ??
|
|
31
|
+
this.#cdnBaseUrl = (cdnBaseUrl ?? require_CalmLensCdn.DEFAULT_CDN_BASE_URL).replace(/\/+$/, "");
|
|
32
32
|
this.#connection = new require_CalmLensConnection.CalmLensConnection(require_CalmLensConnection.resolveConnectionOptions(rest));
|
|
33
33
|
}
|
|
34
34
|
/** Keeps tokens out of `console.log`, `util.inspect` and `JSON.stringify`. */
|
|
@@ -72,7 +72,7 @@ var CalmLensAppClient = class {
|
|
|
72
72
|
onStarted: (assetId) => {
|
|
73
73
|
if (token) this.#uploadTokens.set(assetId, token);
|
|
74
74
|
},
|
|
75
|
-
retrieve: async (assetId, read) => require_CalmLensConnection.expectUploadedAsset(await read.json("GET", `${this.uploadsPath}/${
|
|
75
|
+
retrieve: async (assetId, read) => require_CalmLensConnection.expectUploadedAsset(await read.json("GET", `${this.uploadsPath}/${require_CalmLensCdn.encodePathSegment(assetId, "Asset ID")}`, { headers: this.authHeaders(assetId) }))
|
|
76
76
|
});
|
|
77
77
|
return require_CalmLensConnection.expectUploadedAsset(data);
|
|
78
78
|
}
|
|
@@ -94,7 +94,7 @@ getAssetUrl: (urlOptions) => {
|
|
|
94
94
|
const { projectId, ...options } = checked("cdn.getAssetUrl", urlOptions);
|
|
95
95
|
const project = projectId ?? this.#projectId;
|
|
96
96
|
if (project === void 0) throw require_CalmLensError.invalidArgument("Pass projectId, here or in the client's options");
|
|
97
|
-
return
|
|
97
|
+
return require_CalmLensCdn.buildAssetUrl(this.#cdnBaseUrl, project, options);
|
|
98
98
|
} };
|
|
99
99
|
}
|
|
100
100
|
/** Uploads through the client's upload preset and checks those uploads. */
|
|
@@ -110,14 +110,14 @@ getAssetUrl: (urlOptions) => {
|
|
|
110
110
|
*/
|
|
111
111
|
uploadPart: async (partOptions, requestOptions) => {
|
|
112
112
|
const { assetId, ...options } = checked("assets.uploadPart", partOptions);
|
|
113
|
-
const encodedAssetId =
|
|
113
|
+
const encodedAssetId = require_CalmLensCdn.encodePathSegment(assetId, "Asset ID");
|
|
114
114
|
const data = await this.#connection.forCall("assets.uploadPart", requestOptions).uploadPart(`${this.uploadsPath}/${encodedAssetId}/part`, options, this.authHeaders(assetId));
|
|
115
115
|
return require_CalmLensConnection.expectUploadedAsset(data);
|
|
116
116
|
},
|
|
117
117
|
/** Checks an upload this client made. `classification.moderation.decision` is present when the preset shows decisions. */
|
|
118
118
|
retrieve: async (options, requestOptions) => {
|
|
119
119
|
const { assetId } = checked("assets.retrieve", options);
|
|
120
|
-
const encodedAssetId =
|
|
120
|
+
const encodedAssetId = require_CalmLensCdn.encodePathSegment(assetId, "Asset ID");
|
|
121
121
|
const data = await this.#connection.forCall("assets.retrieve", requestOptions).json("GET", `${this.uploadsPath}/${encodedAssetId}`, { headers: this.authHeaders(assetId) });
|
|
122
122
|
return require_CalmLensConnection.expectUploadedAsset(data);
|
|
123
123
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_CalmLensError = require("./CalmLensError-
|
|
1
|
+
const require_CalmLensError = require("./CalmLensError-ifj5rLmk.js");
|
|
2
2
|
// src/client/CalmLensLogging.ts
|
|
3
3
|
const LOG_LEVELS = [
|
|
4
4
|
"off",
|
|
@@ -152,7 +152,7 @@ const listPages = (fetchPage, { cursor, feed = false } = {}) => {
|
|
|
152
152
|
};
|
|
153
153
|
// src/client/CalmLensVersion.ts
|
|
154
154
|
/** This SDK's version, from its package.json. */
|
|
155
|
-
const SDK_VERSION = "0.
|
|
155
|
+
const SDK_VERSION = "0.31.1";
|
|
156
156
|
const runtimeName = () => {
|
|
157
157
|
const runtime = globalThis;
|
|
158
158
|
if (isReactNativeRuntime()) return "react-native";
|
|
@@ -1483,38 +1483,6 @@ const getAssetInfo = async (url, options = {}) => {
|
|
|
1483
1483
|
});
|
|
1484
1484
|
return data;
|
|
1485
1485
|
};
|
|
1486
|
-
// src/contract/ModerationContextLimits-k930WU8i.js
|
|
1487
|
-
/** The most recent earlier posts CalmLens uses. */
|
|
1488
|
-
const MODERATION_CONTEXT_USED_ITEMS = 5;
|
|
1489
|
-
/**
|
|
1490
|
-
* The most characters of earlier posts CalmLens uses. The newest post always fits, since no post
|
|
1491
|
-
* may be longer.
|
|
1492
|
-
*/
|
|
1493
|
-
const MODERATION_CONTEXT_USED_CHARACTERS = 2e3;
|
|
1494
|
-
/** Unicode code points, as every SDK counts characters. */
|
|
1495
|
-
const countModerationContextCharacters = (text) => {
|
|
1496
|
-
let count = 0;
|
|
1497
|
-
for (const _ of text) count++;
|
|
1498
|
-
return count;
|
|
1499
|
-
};
|
|
1500
|
-
/**
|
|
1501
|
-
* The earlier posts CalmLens uses: the most recent ones, newest first, while at most
|
|
1502
|
-
* `MODERATION_CONTEXT_USED_ITEMS` and `MODERATION_CONTEXT_USED_CHARACTERS` allow, returned oldest
|
|
1503
|
-
* first. The newest post is always kept, so an over-long one is left for validation to reject.
|
|
1504
|
-
*/
|
|
1505
|
-
const selectModerationContextItems = (items) => {
|
|
1506
|
-
const selected = [];
|
|
1507
|
-
let characters = 0;
|
|
1508
|
-
for (let index = items.length - 1; index >= 0; index--) {
|
|
1509
|
-
if (selected.length === 5) break;
|
|
1510
|
-
const item = items[index];
|
|
1511
|
-
const length = countModerationContextCharacters(item.text);
|
|
1512
|
-
if (selected.length && characters + length > 2e3) break;
|
|
1513
|
-
selected.unshift(item);
|
|
1514
|
-
characters += length;
|
|
1515
|
-
}
|
|
1516
|
-
return selected;
|
|
1517
|
-
};
|
|
1518
1486
|
Object.defineProperty(exports, "ASSET_RESOURCE_PATHS", {
|
|
1519
1487
|
enumerable: true,
|
|
1520
1488
|
get: function() {
|
|
@@ -1569,18 +1537,6 @@ Object.defineProperty(exports, "MAX_NON_IMAGE_UPLOAD_BYTES", {
|
|
|
1569
1537
|
return MAX_NON_IMAGE_UPLOAD_BYTES;
|
|
1570
1538
|
}
|
|
1571
1539
|
});
|
|
1572
|
-
Object.defineProperty(exports, "MODERATION_CONTEXT_USED_CHARACTERS", {
|
|
1573
|
-
enumerable: true,
|
|
1574
|
-
get: function() {
|
|
1575
|
-
return MODERATION_CONTEXT_USED_CHARACTERS;
|
|
1576
|
-
}
|
|
1577
|
-
});
|
|
1578
|
-
Object.defineProperty(exports, "MODERATION_CONTEXT_USED_ITEMS", {
|
|
1579
|
-
enumerable: true,
|
|
1580
|
-
get: function() {
|
|
1581
|
-
return MODERATION_CONTEXT_USED_ITEMS;
|
|
1582
|
-
}
|
|
1583
|
-
});
|
|
1584
1540
|
Object.defineProperty(exports, "SDK_VERSION", {
|
|
1585
1541
|
enumerable: true,
|
|
1586
1542
|
get: function() {
|
|
@@ -1707,12 +1663,6 @@ Object.defineProperty(exports, "resolveLogLevel", {
|
|
|
1707
1663
|
return resolveLogLevel;
|
|
1708
1664
|
}
|
|
1709
1665
|
});
|
|
1710
|
-
Object.defineProperty(exports, "selectModerationContextItems", {
|
|
1711
|
-
enumerable: true,
|
|
1712
|
-
get: function() {
|
|
1713
|
-
return selectModerationContextItems;
|
|
1714
|
-
}
|
|
1715
|
-
});
|
|
1716
1666
|
Object.defineProperty(exports, "serializeTransform", {
|
|
1717
1667
|
enumerable: true,
|
|
1718
1668
|
get: function() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_CalmLensError = require("./CalmLensError-
|
|
2
|
-
const
|
|
1
|
+
const require_CalmLensError = require("./CalmLensError-ifj5rLmk.js");
|
|
2
|
+
const require_CalmLensCdn = require("./CalmLensCdn-Q68faCEE.js");
|
|
3
3
|
// src/contract/AssetPayload.js
|
|
4
4
|
const bufferInputToBytes = (value) => {
|
|
5
5
|
if (value instanceof ArrayBuffer) return new Uint8Array(value);
|
|
@@ -514,7 +514,7 @@ const textEncoder = new TextEncoder();
|
|
|
514
514
|
* read only the current part. Streams remain streamed, and buffered bodies remain retryable.
|
|
515
515
|
*/
|
|
516
516
|
const toUploadForm = async (options, payload) => {
|
|
517
|
-
const boundary = `calmlens-${
|
|
517
|
+
const boundary = `calmlens-${require_CalmLensCdn.randomUuid()}`;
|
|
518
518
|
const head = `--${boundary}\r\nContent-Disposition: form-data; name="options"\r\nContent-Type: application/json\r\n\r\n${JSON.stringify(options)}\r\n--${boundary}\r\nContent-Disposition: form-data; name="file"\r\nContent-Type: ${payload.type.replace(/[\r\n]/g, "")}\r\n\r\n`;
|
|
519
519
|
const tail = `\r\n--${boundary}--\r\n`;
|
|
520
520
|
const contentType = `multipart/form-data; boundary=${boundary}`;
|
|
@@ -578,8 +578,8 @@ const setOptionalQueryValue = (params, key, value) => {
|
|
|
578
578
|
if (value !== void 0 && value !== null) params.set(key, String(value));
|
|
579
579
|
};
|
|
580
580
|
const assertValidUploadMimeType = (mimeType) => {
|
|
581
|
-
if (!
|
|
582
|
-
message:
|
|
581
|
+
if (!require_CalmLensCdn.isAcceptedUploadMimeType(mimeType)) throw new require_CalmLensError.CalmLensError(require_CalmLensError.API_ERROR_CODES.UNSUPPORTED_UPLOAD_TYPE, {
|
|
582
|
+
message: require_CalmLensCdn.getRejectedUploadMimeTypeError(mimeType),
|
|
583
583
|
details: {
|
|
584
584
|
mimeType,
|
|
585
585
|
source: "calmlens"
|
|
@@ -604,7 +604,7 @@ const assertDeclaredPayloadSize = (payload, declared = payload.sizeInBytes) => {
|
|
|
604
604
|
const assertUploadSize = (type, size, inParts) => {
|
|
605
605
|
if (size === void 0) return;
|
|
606
606
|
const mime = type.toLowerCase();
|
|
607
|
-
const [limit, message] = mime.startsWith("image/") ? [
|
|
607
|
+
const [limit, message] = mime.startsWith("image/") ? [require_CalmLensCdn.MAX_DIRECT_IMAGE_UPLOAD_BYTES, "Images uploaded in one request can be at most 10 MiB; upload larger images in parts"] : mime.startsWith("audio/") || mime.startsWith("video/") ? [inParts ? MAX_LONG_MEDIA_UPLOAD_BYTES : MAX_MEDIA_UPLOAD_BYTES, "Audio and video files can be at most 50 MiB in one request, or 2 GiB in parts"] : [require_CalmLensCdn.MAX_NON_IMAGE_UPLOAD_BYTES, "Files can be at most 5,000 MiB"];
|
|
608
608
|
if (size > limit) throw new require_CalmLensError.CalmLensError(require_CalmLensError.API_ERROR_CODES.UPLOAD_TOO_LARGE, {
|
|
609
609
|
message,
|
|
610
610
|
details: {
|
|
@@ -648,10 +648,10 @@ const prepareSubmitAssetOptions = (input, { deferUploadChecks = false, partSizeB
|
|
|
648
648
|
const inParts = splitsIntoParts(options.content, partSizeBytes);
|
|
649
649
|
if (inParts && (options.idempotencyKey?.length ?? 0) > 240) throw require_CalmLensError.invalidArgument(`idempotencyKey can be at most 240 characters for an upload sent in parts`);
|
|
650
650
|
if (!deferUploadChecks && inParts && isImageMimeType(options.content.type)) {
|
|
651
|
-
if ((getAssetPayloadByteLength(options.content) ?? 0) >
|
|
651
|
+
if ((getAssetPayloadByteLength(options.content) ?? 0) > require_CalmLensCdn.MAX_IMAGE_UPLOAD_BYTES) throw new require_CalmLensError.CalmLensError(require_CalmLensError.API_ERROR_CODES.UPLOAD_TOO_LARGE, {
|
|
652
652
|
message: "Multipart image uploads cannot exceed 20 MiB.",
|
|
653
653
|
details: {
|
|
654
|
-
limitBytes:
|
|
654
|
+
limitBytes: require_CalmLensCdn.MAX_IMAGE_UPLOAD_BYTES,
|
|
655
655
|
source: "plan"
|
|
656
656
|
}
|
|
657
657
|
});
|
|
@@ -666,10 +666,10 @@ const prepareSubmitAssetOptions = (input, { deferUploadChecks = false, partSizeB
|
|
|
666
666
|
assertValidUploadMimeType(options.part.type);
|
|
667
667
|
const partSizeInBytes = options.part.sizeInBytes ?? getAssetPayloadByteLength(options.part);
|
|
668
668
|
if (!deferUploadChecks && isImageMimeType(options.part.type) && partSizeInBytes !== void 0) {
|
|
669
|
-
if (partSizeInBytes >
|
|
669
|
+
if (partSizeInBytes > require_CalmLensCdn.MAX_IMAGE_UPLOAD_BYTES) throw new require_CalmLensError.CalmLensError(require_CalmLensError.API_ERROR_CODES.UPLOAD_TOO_LARGE, {
|
|
670
670
|
message: "Multipart image uploads cannot exceed 20 MiB.",
|
|
671
671
|
details: {
|
|
672
|
-
limitBytes:
|
|
672
|
+
limitBytes: require_CalmLensCdn.MAX_IMAGE_UPLOAD_BYTES,
|
|
673
673
|
source: "plan"
|
|
674
674
|
}
|
|
675
675
|
});
|
|
@@ -681,16 +681,9 @@ const prepareSubmitAssetOptions = (input, { deferUploadChecks = false, partSizeB
|
|
|
681
681
|
});
|
|
682
682
|
if (!validation.ok) throw invalidPayload(validation.error);
|
|
683
683
|
}
|
|
684
|
-
if (options.context !== void 0) {
|
|
685
|
-
if (!options.context || !Array.isArray(options.context.items)) throw require_CalmLensError.invalidArgument("context.items must be an array of earlier posts");
|
|
686
|
-
return {
|
|
687
|
-
...options,
|
|
688
|
-
context: { items: require_ModerationContextLimits.selectModerationContextItems(options.context.items) }
|
|
689
|
-
};
|
|
690
|
-
}
|
|
691
684
|
return options;
|
|
692
685
|
};
|
|
693
|
-
const newIdempotencyKey = () =>
|
|
686
|
+
const newIdempotencyKey = () => require_CalmLensCdn.randomUuid();
|
|
694
687
|
/** Text content is small, so it keeps the API deadline; binary files may be arbitrarily large. */
|
|
695
688
|
const isTextPayload = (payload) => "plainText" in payload;
|
|
696
689
|
const hasStringStatus = (value) => !!value && typeof value === "object" && typeof value.status === "string";
|
|
@@ -757,8 +750,8 @@ var CalmLensConnection = class CalmLensConnection {
|
|
|
757
750
|
return fetchImpl;
|
|
758
751
|
};
|
|
759
752
|
this.hooks = getMockHooks(options);
|
|
760
|
-
const logLevel =
|
|
761
|
-
this.transport = new
|
|
753
|
+
const logLevel = require_CalmLensCdn.resolveLogLevel(options.logLevel, readEnvironment);
|
|
754
|
+
this.transport = new require_CalmLensCdn.CalmLensTransport({
|
|
762
755
|
apiKey,
|
|
763
756
|
sleep: this.hooks?.sleep,
|
|
764
757
|
fetch: ((input, init) => resolveFetch()(input, init)),
|
|
@@ -831,7 +824,7 @@ var CalmLensConnection = class CalmLensConnection {
|
|
|
831
824
|
}
|
|
832
825
|
/** How the client waits between polls and retries. */
|
|
833
826
|
get sleep() {
|
|
834
|
-
return this.hooks?.sleep ??
|
|
827
|
+
return this.hooks?.sleep ?? require_CalmLensCdn.sleep;
|
|
835
828
|
}
|
|
836
829
|
/** Whether multipart size checks are left to the API (mock clients only). */
|
|
837
830
|
get deferUploadChecks() {
|
|
@@ -842,7 +835,7 @@ var CalmLensConnection = class CalmLensConnection {
|
|
|
842
835
|
}
|
|
843
836
|
/** The URL of `path` (which may carry a query already) with `query` and the call's `extraQuery`. */
|
|
844
837
|
url(path, query) {
|
|
845
|
-
const search = [query, this.call.extraQuery].map((values) => values ?
|
|
838
|
+
const search = [query, this.call.extraQuery].map((values) => values ? require_CalmLensCdn.stringifyQuery(values) : "").filter(Boolean).join("&");
|
|
846
839
|
const separator = path.includes("?") ? "&" : "?";
|
|
847
840
|
return `${this.options.baseUrl}${path}${search ? `${separator}${search}` : ""}`;
|
|
848
841
|
}
|
|
@@ -115,6 +115,7 @@ const API_ERROR_CODES = {
|
|
|
115
115
|
REMOTE_URL_UNAVAILABLE: "remote-url/unavailable",
|
|
116
116
|
APPEAL_NOT_FOUND: "appeal/not-found",
|
|
117
117
|
APPEAL_JUDGMENT_NOT_FOUND: "appeal/judgment-not-found",
|
|
118
|
+
CONTEXT_ASSET_NOT_FOUND: "context/asset-not-found",
|
|
118
119
|
APPEAL_ASSET_NOT_FOUND: "appeal/asset-not-found",
|
|
119
120
|
APPEAL_PERMISSION_DENIED: "appeal/permission-denied",
|
|
120
121
|
APPEAL_ALREADY_REVIEWED: "appeal/already-reviewed",
|
|
@@ -580,6 +581,10 @@ const API_ERROR_DEFINITIONS = {
|
|
|
580
581
|
status: 404,
|
|
581
582
|
message: "The judgment event is unavailable, belongs to another project or cannot supply an asset decision. Supply explicit context instead."
|
|
582
583
|
},
|
|
584
|
+
"context/asset-not-found": {
|
|
585
|
+
status: 400,
|
|
586
|
+
message: "A context item names an asset this project doesn't have. Reference an earlier post uploaded to the same project."
|
|
587
|
+
},
|
|
583
588
|
"appeal/asset-not-found": {
|
|
584
589
|
status: 404,
|
|
585
590
|
message: "The linked asset does not exist in this project."
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const require_CalmLensError = require("./CalmLensError-
|
|
2
|
-
const
|
|
3
|
-
const require_CalmLensConnection = require("./CalmLensConnection-
|
|
1
|
+
const require_CalmLensError = require("./CalmLensError-ifj5rLmk.js");
|
|
2
|
+
const require_CalmLensCdn = require("./CalmLensCdn-Q68faCEE.js");
|
|
3
|
+
const require_CalmLensConnection = require("./CalmLensConnection-j2aBsuNx.js");
|
|
4
4
|
const require_CryptoUtils_BLCa_oZe = require("./CryptoUtils-BLCa-oZe-leCkr1ko.js");
|
|
5
5
|
// src/contract/JsonUtils.js
|
|
6
6
|
const stringifyJsonCanonical = (value) => JSON.stringify(value, (_key, nestedValue) => {
|
|
@@ -59,7 +59,7 @@ const decodeUploadToken = (token) => {
|
|
|
59
59
|
const signUploadTokenWithApiKey = async (apiKey, options, { now = Date.now(), nonce = crypto.randomUUID() } = {}) => {
|
|
60
60
|
if (!options || typeof options !== "object") throw require_CalmLensError.invalidArgument("Options are required");
|
|
61
61
|
const { uploadPresetId, externalId, expiresIn = 600 } = options;
|
|
62
|
-
|
|
62
|
+
require_CalmLensCdn.encodePathSegment(uploadPresetId, "Upload preset ID");
|
|
63
63
|
if (!Number.isInteger(expiresIn) || expiresIn < 1 || expiresIn > 3600) throw require_CalmLensError.invalidArgument(`expiresIn must be a whole number from 1 to ${UPLOAD_TOKEN_MAX_TTL_SECONDS}`);
|
|
64
64
|
if (externalId !== void 0 && (typeof externalId !== "string" || !externalId)) throw require_CalmLensError.invalidArgument("externalId must be a non-empty string");
|
|
65
65
|
const expiresAt = now + expiresIn * 1e3;
|
|
@@ -215,7 +215,7 @@ const getEnsureLensCacheKey = (options) => stringifyJsonCanonical({
|
|
|
215
215
|
active: options.active ?? true,
|
|
216
216
|
transform: options.transform ?? null
|
|
217
217
|
});
|
|
218
|
-
const requireId = (value, name) =>
|
|
218
|
+
const requireId = (value, name) => require_CalmLensCdn.encodePathSegment(value, name);
|
|
219
219
|
/** `options`, after checking that text it classifies isn't empty. */
|
|
220
220
|
const checkedTextContent = (options) => {
|
|
221
221
|
if (options && "content" in options && "plainText" in options.content && (typeof options.content.plainText !== "string" || !options.content.plainText.trim())) throw require_CalmLensConnection.invalidPayload("Text to classify must be a non-empty string");
|
|
@@ -235,9 +235,9 @@ const anySignal = (signals) => {
|
|
|
235
235
|
*/
|
|
236
236
|
const withEnvironmentDefaults = (options) => {
|
|
237
237
|
if (!options || typeof options !== "object" || require_CalmLensConnection.getMockHooks(options)) return options;
|
|
238
|
-
const apiKey = options.apiKey ??
|
|
239
|
-
const projectId = options.projectId ??
|
|
240
|
-
const baseUrl = options.baseUrl ??
|
|
238
|
+
const apiKey = options.apiKey ?? require_CalmLensCdn.readEnv("CALMLENS_API_KEY");
|
|
239
|
+
const projectId = options.projectId ?? require_CalmLensCdn.readEnv("CALMLENS_PROJECT_ID");
|
|
240
|
+
const baseUrl = options.baseUrl ?? require_CalmLensCdn.readEnv("CALMLENS_BASE_URL");
|
|
241
241
|
return {
|
|
242
242
|
...options,
|
|
243
243
|
...apiKey !== void 0 && { apiKey },
|
|
@@ -250,7 +250,7 @@ const withEnvironmentDefaults = (options) => {
|
|
|
250
250
|
* `null` that the API refuses as `null`: those are left out, as if omitted.
|
|
251
251
|
*/
|
|
252
252
|
const checked = (operation, options) => {
|
|
253
|
-
|
|
253
|
+
require_CalmLensCdn.checkOptionKeys(options, operation, require_CalmLensConnection.SERVER_OPTION_KEYS);
|
|
254
254
|
if (!options || typeof options !== "object" || Array.isArray(options)) return options;
|
|
255
255
|
const nullable = require_CalmLensConnection.NULLABLE_OPTION_KEYS[operation] ?? [];
|
|
256
256
|
return Object.fromEntries(Object.entries(options).filter(([key, value]) => value !== null || nullable.includes(key)));
|
|
@@ -308,14 +308,14 @@ var CalmLensServerClient = class {
|
|
|
308
308
|
}
|
|
309
309
|
constructor(clientOptions = {}, lenses) {
|
|
310
310
|
const options = withEnvironmentDefaults(clientOptions);
|
|
311
|
-
|
|
312
|
-
if ((
|
|
311
|
+
require_CalmLensCdn.validateServerClientOptions(options);
|
|
312
|
+
if ((require_CalmLensCdn.isBrowserRuntime() || require_CalmLensCdn.isReactNativeRuntime()) && !options.dangerouslyAllowBrowser) throw require_CalmLensError.invalidConfig("CalmLensServerClient is running in a browser or app, where anyone could read the API key. Call CalmLens from your server, upload from the browser or app with CalmLensAppClient, or set dangerouslyAllowBrowser: true for trusted internal tools.");
|
|
313
313
|
const { apiKey, projectId, ...rest } = options;
|
|
314
314
|
this.#apiKey = apiKey;
|
|
315
315
|
this.#settings = {
|
|
316
316
|
projectId,
|
|
317
317
|
...require_CalmLensConnection.resolveConnectionOptions(rest),
|
|
318
|
-
cdnBaseUrl: (rest.cdnBaseUrl ?? require_CalmLensConnection.getMockHooks(rest)?.defaultCdnBaseUrl ??
|
|
318
|
+
cdnBaseUrl: (rest.cdnBaseUrl ?? require_CalmLensConnection.getMockHooks(rest)?.defaultCdnBaseUrl ?? require_CalmLensCdn.DEFAULT_CDN_BASE_URL).replace(/\/+$/, "")
|
|
319
319
|
};
|
|
320
320
|
this.#lenses = lenses ?? {
|
|
321
321
|
ensuredLenses: /* @__PURE__ */ new Map(),
|
|
@@ -379,7 +379,7 @@ var CalmLensServerClient = class {
|
|
|
379
379
|
*/
|
|
380
380
|
#paginate(operation, options, requestOptions, send) {
|
|
381
381
|
const first = options?.cursor;
|
|
382
|
-
return
|
|
382
|
+
return require_CalmLensCdn.listPages(async (cursor) => {
|
|
383
383
|
const valid = checked(operation, options);
|
|
384
384
|
return send(cursor === first ? valid : {
|
|
385
385
|
...valid,
|
|
@@ -420,7 +420,7 @@ var CalmLensServerClient = class {
|
|
|
420
420
|
*/
|
|
421
421
|
getAssetUrl: (urlOptions) => {
|
|
422
422
|
const { projectId, ...options } = checked("cdn.getAssetUrl", urlOptions);
|
|
423
|
-
return
|
|
423
|
+
return require_CalmLensCdn.buildAssetUrl(this.#settings.cdnBaseUrl, projectId ?? this.#settings.projectId, options);
|
|
424
424
|
},
|
|
425
425
|
/**
|
|
426
426
|
* Signs a private asset's URL on your server, so browsers and apps can load it without an API
|
|
@@ -431,7 +431,7 @@ var CalmLensServerClient = class {
|
|
|
431
431
|
*/
|
|
432
432
|
signAssetUrl: async (signOptions, requestOptions) => {
|
|
433
433
|
const options = checked("cdn.signAssetUrl", signOptions);
|
|
434
|
-
|
|
434
|
+
require_CalmLensCdn.validateSignAssetUrlOptions(options);
|
|
435
435
|
const { projectId, assetId, externalId, expiresIn, ...location } = options;
|
|
436
436
|
const project = requireId(projectId ?? this.#settings.projectId, "Project ID");
|
|
437
437
|
const signed = await this.#send("cdn.signAssetUrl", requestOptions, "POST", `/projects/${project}/signed-asset-urls`, { body: {
|
|
@@ -440,8 +440,8 @@ var CalmLensServerClient = class {
|
|
|
440
440
|
...location.resource !== void 0 ? { resource: location.resource } : {}
|
|
441
441
|
} });
|
|
442
442
|
if (!signed || typeof signed.url !== "string" || !signed.url || typeof signed.expiresAt !== "number") throw new require_CalmLensError.CalmLensError(require_CalmLensError.SDK_ERROR_CODES.INVALID_RESPONSE, { message: "The API returned no signed asset URL" });
|
|
443
|
-
return
|
|
444
|
-
url:
|
|
443
|
+
return require_CalmLensCdn.copyLastResponse({
|
|
444
|
+
url: require_CalmLensCdn.appendSignedLocation(signed.url, location),
|
|
445
445
|
expiresAt: signed.expiresAt
|
|
446
446
|
}, signed);
|
|
447
447
|
},
|
|
@@ -451,7 +451,7 @@ var CalmLensServerClient = class {
|
|
|
451
451
|
* A server can pass it to `CalmLensAsset` as `info`, so the first render is the real
|
|
452
452
|
* element.
|
|
453
453
|
*/
|
|
454
|
-
getAssetInfo: (url, options = {}) =>
|
|
454
|
+
getAssetInfo: (url, options = {}) => require_CalmLensCdn.getAssetInfo(url, {
|
|
455
455
|
...options,
|
|
456
456
|
fetch: this.#settings.cdnFetch
|
|
457
457
|
}),
|
|
@@ -468,7 +468,7 @@ var CalmLensServerClient = class {
|
|
|
468
468
|
...urlOptions,
|
|
469
469
|
resource
|
|
470
470
|
});
|
|
471
|
-
const extraQuery = requestOptions?.extraQuery &&
|
|
471
|
+
const extraQuery = requestOptions?.extraQuery && require_CalmLensCdn.stringifyQuery(requestOptions.extraQuery);
|
|
472
472
|
const method = init?.method?.toUpperCase() ?? "GET";
|
|
473
473
|
const { response } = await connection.transport.send({
|
|
474
474
|
...connection.callRequest(),
|
|
@@ -490,7 +490,7 @@ var CalmLensServerClient = class {
|
|
|
490
490
|
* Moderates text and waits for the decision. Sends `text` as `text/plain` content named
|
|
491
491
|
* `text` unless you pass `name`.
|
|
492
492
|
*/
|
|
493
|
-
classify: async (options, requestOptions) => this.#submitAsset("text.classify", checkedTextContent(
|
|
493
|
+
classify: async (options, requestOptions) => this.#submitAsset("text.classify", checkedTextContent(require_CalmLensCdn.toTextAssetOptions(checked("text.classify", options))), true, requestOptions) };
|
|
494
494
|
}
|
|
495
495
|
/** Assets: uploads, moderation and management. */
|
|
496
496
|
get assets() {
|
|
@@ -627,7 +627,7 @@ sign: async (options) => {
|
|
|
627
627
|
...requestOptions,
|
|
628
628
|
...signal && { signal }
|
|
629
629
|
});
|
|
630
|
-
return
|
|
630
|
+
return require_CalmLensCdn.pollForDecision(() => connection.json("GET", `/assets/${requireId(assetId, "Asset ID")}`), {
|
|
631
631
|
...options,
|
|
632
632
|
deadlineAt: connection.call.deadlineAt
|
|
633
633
|
}, connection.sleep, connection.now);
|
|
@@ -661,7 +661,7 @@ sign: async (options) => {
|
|
|
661
661
|
*/
|
|
662
662
|
batch: async (options, requestOptions) => {
|
|
663
663
|
const { assetIds, operation } = checked("assets.batch", options);
|
|
664
|
-
|
|
664
|
+
require_CalmLensCdn.validateBatchAssetsOptions({
|
|
665
665
|
assetIds,
|
|
666
666
|
operation
|
|
667
667
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { c as HashList, l as HashListEntry } from "./Classification-
|
|
2
|
-
import { $ as FolderPage, At as ResetPolicyOptions, B as CreateHashListOptions, Bn as AssetInfo, Cn as ProjectSettingsResource, D as BatchAssetsResponse, Dt as RequestAssetReviewOptions, E as BatchAssetsOptions, Et as RemoveAssetContentOptions, Ft as SetPolicyAutomaticUpdatesOptions, G as DeleteAssetOptions, Gt as UpdateLensOptions, Ht as UpdateAssetOptions, I as ClassifyTextOptions, It as SignAssetUrlOptions, J as EnsureLensesOptions, Jt as UpgradePolicyOptions, K as DeleteMetadataFieldOptions, Kt as UpdatePolicyOptions, Lt as SignUploadTokenOptions, M as CdnAssetUrlOptions, Mt as RetrieveAssetOptions, Nt as RetryAssetOptions, P as CdnServeOptions, Pn as Policy, Q as FolderIdOptions, Qt as UploadPresetPage, Rn as AssetSearchQuery, Rt as SignedAssetUrl, Sn as MetadataFieldsResource, T as AssignPolicyOptions, Tt as PolicyPage, U as CreatePolicyOptions, Ut as UpdateFolderOptions, V as CreateLensOptions, Vt as SubmitAssetOptions, W as DecideAssetOptions, Wt as UpdateHashListOptions, X as EnsureUploadPresetsOptions, Y as EnsureMetadataFieldsOptions, Yt as UploadAssetPartOptions, Z as EnsureUploadPresetsResponse, Zt as UploadPresetIdOptions, _ as AssetPage, _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 RetrieveAssetByExternalIdOptions, k as CalmLensServerClientOptions, kt as RequestOptions, ln as GetEventsResponse, lt as LensPage, mt as ListFoldersOptions, nt as HashListEntryPage, o as AssetChildrenPage, pt as ListEventsOptions, q as EnsureLensOptions, qt as UpdateProjectSettingsOptions, r as Asset, rn as WaitForAssetDecisionOptions, rt as HashListIdOptions, sn as AssetReviewRequest, st as Lens, t as AddHashListEntryOptions, tn as VerifyWebhookSignatureOptions, tt as HashListEntryIdOptions, ut as ListAssetChildrenOptions, v as AssetSearchResponse, vt as ListPoliciesOptions, wt as PolicyIdOptions, xn as Folder, xt as MoveFolderOptions, yt as ListUploadPresetsOptions, z as CreateFolderOptions, zt as SignedUploadToken } from "./CalmLensTypes-
|
|
3
|
-
import { d as ListPromise, l as CalmLensResponse, r as CdnResponse } from "./WebhookPayload-
|
|
1
|
+
import { c as HashList, l as HashListEntry } from "./Classification-C3pkrGYS-B7EygpJn.js";
|
|
2
|
+
import { $ as FolderPage, At as ResetPolicyOptions, B as CreateHashListOptions, Bn as AssetInfo, Cn as ProjectSettingsResource, D as BatchAssetsResponse, Dt as RequestAssetReviewOptions, E as BatchAssetsOptions, Et as RemoveAssetContentOptions, Ft as SetPolicyAutomaticUpdatesOptions, G as DeleteAssetOptions, Gt as UpdateLensOptions, Ht as UpdateAssetOptions, I as ClassifyTextOptions, It as SignAssetUrlOptions, J as EnsureLensesOptions, Jt as UpgradePolicyOptions, K as DeleteMetadataFieldOptions, Kt as UpdatePolicyOptions, Lt as SignUploadTokenOptions, M as CdnAssetUrlOptions, Mt as RetrieveAssetOptions, Nt as RetryAssetOptions, P as CdnServeOptions, Pn as Policy, Q as FolderIdOptions, Qt as UploadPresetPage, Rn as AssetSearchQuery, Rt as SignedAssetUrl, Sn as MetadataFieldsResource, T as AssignPolicyOptions, Tt as PolicyPage, U as CreatePolicyOptions, Ut as UpdateFolderOptions, V as CreateLensOptions, Vt as SubmitAssetOptions, W as DecideAssetOptions, Wt as UpdateHashListOptions, X as EnsureUploadPresetsOptions, Y as EnsureMetadataFieldsOptions, Yt as UploadAssetPartOptions, Z as EnsureUploadPresetsResponse, Zt as UploadPresetIdOptions, _ as AssetPage, _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 RetrieveAssetByExternalIdOptions, k as CalmLensServerClientOptions, kt as RequestOptions, ln as GetEventsResponse, lt as LensPage, mt as ListFoldersOptions, nt as HashListEntryPage, o as AssetChildrenPage, pt as ListEventsOptions, q as EnsureLensOptions, qt as UpdateProjectSettingsOptions, r as Asset, rn as WaitForAssetDecisionOptions, rt as HashListIdOptions, sn as AssetReviewRequest, st as Lens, t as AddHashListEntryOptions, tn as VerifyWebhookSignatureOptions, tt as HashListEntryIdOptions, ut as ListAssetChildrenOptions, v as AssetSearchResponse, vt as ListPoliciesOptions, wt as PolicyIdOptions, xn as Folder, xt as MoveFolderOptions, yt as ListUploadPresetsOptions, z as CreateFolderOptions, zt as SignedUploadToken } from "./CalmLensTypes-87kiUg0H.js";
|
|
3
|
+
import { d as ListPromise, l as CalmLensResponse, r as CdnResponse } from "./WebhookPayload-B4rA_Dvm.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;
|
package/cjs/{CalmLensTestInputArguments-BXDBAOg_.js → CalmLensTestInputArguments-PYuRmE0j.js}
RENAMED
|
@@ -19,7 +19,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
19
19
|
value: mod,
|
|
20
20
|
enumerable: true
|
|
21
21
|
}) : target, mod));
|
|
22
|
-
const require_CalmLensError = require("./CalmLensError-
|
|
22
|
+
const require_CalmLensError = require("./CalmLensError-ifj5rLmk.js");
|
|
23
23
|
const require_CryptoUtils_BLCa_oZe = require("./CryptoUtils-BLCa-oZe-leCkr1ko.js");
|
|
24
24
|
let zod = require("zod");
|
|
25
25
|
let zod$1 = __toESM(zod, 1);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as HashList, d as ModerationContext, l as HashListEntry } from "./Classification-
|
|
1
|
+
import { c as HashList, d as ModerationContext, l as HashListEntry } from "./Classification-C3pkrGYS-B7EygpJn.js";
|
|
2
2
|
import * as zod from "zod";
|
|
3
3
|
/**
|
|
4
4
|
* Where the asset is in the pipeline: waiting for its content or its turn (`queued`), being
|
|
@@ -10095,8 +10095,7 @@ declare const ASSET_SCHEMA: zod.ZodObject<{
|
|
|
10095
10095
|
authorId: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
|
|
10096
10096
|
context: zod.ZodOptional<zod.ZodNullable<zod.ZodObject<{
|
|
10097
10097
|
items: zod.ZodArray<zod.ZodObject<{
|
|
10098
|
-
|
|
10099
|
-
authorId: zod.ZodOptional<zod.ZodString>;
|
|
10098
|
+
assetId: zod.ZodString;
|
|
10100
10099
|
}, zod.core.$strict>>;
|
|
10101
10100
|
}, zod.core.$strip>>>;
|
|
10102
10101
|
type: zod.ZodEnum<{
|
|
@@ -15368,8 +15367,7 @@ declare const ASSET_SEARCH_RESULT_SCHEMA: zod.ZodObject<{
|
|
|
15368
15367
|
authorId: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
|
|
15369
15368
|
context: zod.ZodOptional<zod.ZodNullable<zod.ZodObject<{
|
|
15370
15369
|
items: zod.ZodArray<zod.ZodObject<{
|
|
15371
|
-
|
|
15372
|
-
authorId: zod.ZodOptional<zod.ZodString>;
|
|
15370
|
+
assetId: zod.ZodString;
|
|
15373
15371
|
}, zod.core.$strict>>;
|
|
15374
15372
|
}, zod.core.$strip>>>;
|
|
15375
15373
|
type: zod.ZodEnum<{
|
|
@@ -1,27 +1,8 @@
|
|
|
1
1
|
import * as zod from "zod";
|
|
2
|
-
/** The most recent earlier posts CalmLens uses. */
|
|
3
|
-
declare const MODERATION_CONTEXT_USED_ITEMS = 5;
|
|
4
|
-
/**
|
|
5
|
-
* The most characters of earlier posts CalmLens uses. The newest post always fits, since no post
|
|
6
|
-
* may be longer.
|
|
7
|
-
*/
|
|
8
|
-
declare const MODERATION_CONTEXT_USED_CHARACTERS = 2000;
|
|
9
|
-
/** An earlier post in the conversation. */
|
|
10
|
-
interface ModerationContextItem {
|
|
11
|
-
text: string;
|
|
12
|
-
authorId?: string;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* The earlier posts CalmLens uses: the most recent ones, newest first, while at most
|
|
16
|
-
* `MODERATION_CONTEXT_USED_ITEMS` and `MODERATION_CONTEXT_USED_CHARACTERS` allow, returned oldest
|
|
17
|
-
* first. The newest post is always kept, so an over-long one is left for validation to reject.
|
|
18
|
-
*/
|
|
19
|
-
declare const selectModerationContextItems: <Item extends ModerationContextItem>(items: readonly Item[]) => Item[];
|
|
20
2
|
/** The context a request may send: up to 20 earlier posts, oldest first. */
|
|
21
3
|
declare const MODERATION_CONTEXT_SCHEMA: zod.ZodObject<{
|
|
22
4
|
items: zod.ZodArray<zod.ZodObject<{
|
|
23
|
-
|
|
24
|
-
authorId: zod.ZodOptional<zod.ZodString>;
|
|
5
|
+
assetId: zod.ZodString;
|
|
25
6
|
}, zod.core.$strict>>;
|
|
26
7
|
}, zod.core.$strict>;
|
|
27
8
|
type ModerationContext = zod.infer<typeof MODERATION_CONTEXT_SCHEMA>;
|
|
@@ -6013,4 +5994,4 @@ declare const CATEGORIES_SCHEMA: zod.ZodObject<{
|
|
|
6013
5994
|
}, zod.core.$strict>], "status">;
|
|
6014
5995
|
}, zod.core.$strict>;
|
|
6015
5996
|
type ClassificationCategories = zod.infer<typeof CATEGORIES_SCHEMA>;
|
|
6016
|
-
export { ClassificationQualifierResults as a, HashList as c, ModerationContext as d,
|
|
5997
|
+
export { ClassificationQualifierResults as a, HashList as c, ModerationContext as d, ClassificationNotEvaluatedReason as i, HashListEntry as l, ClassificationCategory as n, Likelihood as o, ClassificationCategoryReport as r, ModerationQualifier as s, ClassificationCategories as t, PolicyAction as u };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as CdnTransform, O as CalmLensAppClientOptions, g as AssetModerationStatus, i as AssetAvailability, nn as ViewerClaims } from "./CalmLensTypes-
|
|
2
|
-
import { t as CalmLensAppClient } from "./CalmLensAppClient-
|
|
1
|
+
import { F as CdnTransform, O as CalmLensAppClientOptions, g as AssetModerationStatus, i as AssetAvailability, nn as ViewerClaims } from "./CalmLensTypes-87kiUg0H.js";
|
|
2
|
+
import { t as CalmLensAppClient } from "./CalmLensAppClient-CdlcDd5l.js";
|
|
3
3
|
import { o as UploadFileIconFamily } from "./FileIcons-4qSX7DW2.js";
|
|
4
4
|
/**
|
|
5
5
|
* The text the asset viewers show, keyed by name. `{name}` placeholders are filled in when shown.
|