calmlens 0.20.0 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -9
- package/bin/calmlens.js +1329 -664
- package/cjs/{BrowserUpload-CjSHjx3C.js → BrowserUpload-CeSwiMo5.js} +1 -1
- package/cjs/{BrowserUpload-C07aL9Vq.d.ts → BrowserUpload-D-NnAN7g.d.ts} +2 -2
- package/cjs/{CalmLensAppClient-NaCxOVlM.js → CalmLensAppClient-0UVCuNqW.js} +30 -10
- package/cjs/{CalmLensAppClient-DDLojj0P.d.ts → CalmLensAppClient-gG16T2py.d.ts} +13 -3
- package/cjs/{CalmLensOptionKeys-p2QK687A.js → CalmLensOptionKeys-CYY6elxg.js} +183 -347
- package/cjs/{CalmLensServerClient-C-jsjn8m.d.ts → CalmLensServerClient-BHx3x_nZ.d.ts} +106 -48
- package/cjs/{CalmLensServerClient-BDzTthxE.js → CalmLensServerClient-nfu6_YEW.js} +288 -88
- package/cjs/{CalmLensTypes-COJbOuiv.d.ts → CalmLensTypes-CUB0YYVz.d.ts} +26601 -27354
- package/cjs/{Classification-D3SkprrQ-CMnQKW13.d.ts → Classification-Q5zGpR8l-CEWjnE39.d.ts} +731 -607
- package/cjs/Core-C82YmjjX.d.ts +823 -0
- package/cjs/Core-Dc3cteU7.js +998 -0
- package/cjs/FileIcons-4qSX7DW2.d.ts +67 -0
- package/cjs/{ModerationContextLimits-2nIv7Zh3.js → ModerationContextLimits-BxOmeSqq.js} +669 -269
- package/cjs/{ReactUpload-BdTRCTGA.js → ReactUpload-BK2O3dnK.js} +1 -1
- package/cjs/{ReactUpload-CRJNPB5T.d.ts → ReactUpload-DiiXfKvj.d.ts} +1 -1
- package/cjs/{TestTriggers-DbhsNPdg-DjvVuc2h.js → TestTriggers-BTyXtX0Q-ATuFDhLX.js} +342 -34
- package/{esm/TestTriggers-D-fwfhEP-hlaP1oW2.d.ts → cjs/TestTriggers-D0pYHbkr-D5T0VdSn.d.ts} +146 -8
- package/cjs/{UploadController-MLVs97Zt.js → UploadController-DLyiLDTB.js} +34 -14
- package/cjs/{WebhookPayload-DkukERKE.d.ts → WebhookPayload-BLT2y_Jy.d.ts} +93 -86
- package/cjs/app.d.ts +6 -7
- package/cjs/app.js +4 -3
- package/cjs/elements.d.ts +123 -22
- package/cjs/elements.js +553 -156
- package/cjs/file-icons.d.ts +2 -67
- package/cjs/index-CKRgjV16.d.ts +16 -0
- package/cjs/index.d.ts +5 -6
- package/cjs/index.js +3 -2
- package/cjs/react-native.d.ts +52 -11
- package/cjs/react-native.js +231 -99
- package/cjs/react.d.ts +42 -9
- package/cjs/react.js +381 -118
- package/cjs/server.d.ts +48 -7
- package/cjs/server.js +7 -3
- package/cjs/test-inputs.d.ts +2 -2
- package/cjs/test-inputs.js +13 -9
- package/cjs/testing.d.ts +24 -14
- package/cjs/testing.js +1413 -402
- package/cjs/ui-CTBUxnVp.d.ts +139 -0
- package/cjs/ui-CZ8exACq.js +1359 -0
- package/cjs/ui.d.ts +3 -2
- package/cjs/ui.js +45 -22
- package/cjs/vue.d.ts +802 -199
- package/cjs/vue.js +359 -127
- package/esm/{BrowserUpload-C07aL9Vq.d.ts → BrowserUpload-D-NnAN7g.d.ts} +2 -2
- package/esm/{BrowserUpload-CAVkRotw.js → BrowserUpload-i9OhCzMJ.js} +1 -1
- package/esm/{CalmLensAppClient-PQ9VBvlW.js → CalmLensAppClient-CK4_Py0c.js} +30 -10
- package/esm/{CalmLensAppClient-DDLojj0P.d.ts → CalmLensAppClient-gG16T2py.d.ts} +13 -3
- package/esm/{CalmLensOptionKeys-Do2mPP6w.js → CalmLensOptionKeys-BGZlIsT2.js} +182 -340
- package/esm/{CalmLensServerClient-C-jsjn8m.d.ts → CalmLensServerClient-BHx3x_nZ.d.ts} +106 -48
- package/esm/{CalmLensServerClient-C_H5aAsV.js → CalmLensServerClient-dAQUcDWb.js} +265 -89
- package/esm/{CalmLensTypes-COJbOuiv.d.ts → CalmLensTypes-CUB0YYVz.d.ts} +26601 -27354
- package/esm/{Classification-D3SkprrQ-CMnQKW13.d.ts → Classification-Q5zGpR8l-CEWjnE39.d.ts} +731 -607
- package/esm/Core-BxeIud_S.js +843 -0
- package/esm/Core-C82YmjjX.d.ts +823 -0
- package/esm/FileIcons-4qSX7DW2.d.ts +67 -0
- package/esm/{ModerationContextLimits-Chw-AzgL.js → ModerationContextLimits-B6_RalCQ.js} +624 -254
- package/esm/{ReactUpload-CRJNPB5T.d.ts → ReactUpload-DiiXfKvj.d.ts} +1 -1
- package/esm/{ReactUpload-CMmL0R5Q.js → ReactUpload-DxwVqfX1.js} +1 -1
- package/esm/{TestTriggers-DbhsNPdg-CUdrv8Nm.js → TestTriggers-BTyXtX0Q-GRB9jQwo.js} +319 -35
- package/{cjs/TestTriggers-D-fwfhEP-hlaP1oW2.d.ts → esm/TestTriggers-D0pYHbkr-D5T0VdSn.d.ts} +146 -8
- package/esm/{UploadController-BJZghJpg.js → UploadController-D9Z-h00Q.js} +34 -14
- package/esm/{WebhookPayload-DkukERKE.d.ts → WebhookPayload-BLT2y_Jy.d.ts} +93 -86
- package/esm/app.d.ts +6 -7
- package/esm/app.js +3 -3
- package/esm/elements.d.ts +123 -22
- package/esm/elements.js +497 -128
- package/esm/file-icons.d.ts +2 -67
- package/esm/index-CKRgjV16.d.ts +16 -0
- package/esm/index.d.ts +5 -6
- package/esm/index.js +1 -1
- package/esm/react-native.d.ts +52 -11
- package/esm/react-native.js +205 -75
- package/esm/react.d.ts +42 -9
- package/esm/react.js +327 -91
- package/esm/server.d.ts +48 -7
- package/esm/server.js +3 -3
- package/esm/styles.css +142 -22
- package/esm/svelte/AssetViewer.svelte +25 -0
- package/esm/svelte/CalmLensAsset.svelte +318 -0
- package/esm/svelte/CalmLensDocumentViewer.svelte +7 -0
- package/esm/svelte/CalmLensImageViewer.svelte +7 -0
- package/esm/svelte/CalmLensSpreadsheetViewer.svelte +7 -0
- package/esm/svelte/CalmLensTextViewer.svelte +7 -0
- package/esm/svelte/CalmLensWebsiteViewer.svelte +7 -0
- package/esm/svelte/index.d.ts +29 -6
- package/esm/svelte/index.js +7 -2
- package/esm/test-inputs.d.ts +2 -2
- package/esm/test-inputs.js +1 -1
- package/esm/testing.d.ts +24 -14
- package/esm/testing.js +1409 -398
- package/esm/ui-CTBUxnVp.d.ts +139 -0
- package/esm/ui-Cr7s6JHm.js +1258 -0
- package/esm/ui.d.ts +3 -2
- package/esm/ui.js +4 -3
- package/esm/vue.d.ts +802 -199
- package/esm/vue.js +308 -103
- package/package.json +3 -1
- package/cjs/ModerationContext-9lGm-Mna-CcmbRnOy.d.ts +0 -67
- package/cjs/index-DxbJ_Xaa.d.ts +0 -253
- package/cjs/ui-BSqPGKrZ.d.ts +0 -539
- package/cjs/ui-CX1z2pD9.js +0 -586
- package/esm/ModerationContext-9lGm-Mna-CcmbRnOy.d.ts +0 -67
- package/esm/index-DxbJ_Xaa.d.ts +0 -253
- package/esm/svelte/CalmLensMedia.svelte +0 -134
- package/esm/ui-BSqPGKrZ.d.ts +0 -539
- package/esm/ui-CXH7xJpb.js +0 -461
package/bin/calmlens.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// src/cli/index.ts
|
|
3
3
|
import { parseArgs } from "node:util";
|
|
4
4
|
// package.json
|
|
5
|
-
var version = "0.
|
|
5
|
+
var version = "0.21.0";
|
|
6
6
|
|
|
7
7
|
// src/contract/ModerationCategories-CHFRoeWV.js
|
|
8
8
|
var CLASSIFICATION_CATEGORIES = [
|
|
@@ -22,380 +22,65 @@ var stringifyJsonCanonical = (value) => JSON.stringify(value, (_key, nestedValue
|
|
|
22
22
|
return Object.fromEntries(Object.keys(nestedValue).sort().map((key) => [key, nestedValue[key]]));
|
|
23
23
|
});
|
|
24
24
|
|
|
25
|
-
// src/contract/AssetPayload.js
|
|
26
|
-
var bufferInputToBytes = (value) => {
|
|
27
|
-
if (value instanceof ArrayBuffer)
|
|
28
|
-
return new Uint8Array(value);
|
|
29
|
-
return Uint8Array.from(value);
|
|
30
|
-
};
|
|
31
|
-
var BASE64_PART_BOUNDARY_ERROR = "Invalid base64 part. For multipart uploads, split the original bytes first, then base64-encode each part. Do not split one full base64 string into substrings.";
|
|
32
|
-
var MULTIPART_PART_TOO_SMALL_ERROR = `Multipart upload parts must be at least 5MiB except the final part.`;
|
|
33
|
-
var getRawBase64 = (value) => {
|
|
34
|
-
const markerIndex = value.indexOf(";base64,");
|
|
35
|
-
if (markerIndex === -1)
|
|
36
|
-
return value;
|
|
37
|
-
return value.slice(markerIndex + 8);
|
|
38
|
-
};
|
|
39
|
-
var validateBase64PayloadString = (payload, options) => {
|
|
40
|
-
const raw = getRawBase64(payload.base64).replace(/\s/g, "");
|
|
41
|
-
if (options?.multipart && raw.length % 4 !== 0)
|
|
42
|
-
return {
|
|
43
|
-
ok: false,
|
|
44
|
-
error: BASE64_PART_BOUNDARY_ERROR
|
|
45
|
-
};
|
|
46
|
-
return { ok: true };
|
|
47
|
-
};
|
|
48
|
-
var assetToData = (payload) => {
|
|
49
|
-
if ("plainText" in payload && payload.plainText !== undefined)
|
|
50
|
-
return new TextEncoder().encode(payload.plainText);
|
|
51
|
-
if ("data" in payload && payload.data)
|
|
52
|
-
return payload.data;
|
|
53
|
-
if ("buffer" in payload) {
|
|
54
|
-
if (payload.buffer instanceof ArrayBuffer)
|
|
55
|
-
return payload.buffer;
|
|
56
|
-
return bufferInputToBytes(payload.buffer);
|
|
57
|
-
}
|
|
58
|
-
if (payload.uint8Array !== undefined)
|
|
59
|
-
return Uint8Array.from(payload.uint8Array);
|
|
60
|
-
if (payload.base64 === undefined)
|
|
61
|
-
throw new Error("Invalid asset payload");
|
|
62
|
-
const raw = getRawBase64(payload.base64);
|
|
63
|
-
if (typeof Buffer !== "undefined")
|
|
64
|
-
return Uint8Array.from(Buffer.from(raw, "base64"));
|
|
65
|
-
const binary = atob(raw);
|
|
66
|
-
return Uint8Array.from(binary, (char) => char.charCodeAt(0));
|
|
67
|
-
};
|
|
68
|
-
var getAssetPayloadByteLength = (payload) => {
|
|
69
|
-
if ("plainText" in payload && payload.plainText !== undefined)
|
|
70
|
-
return new TextEncoder().encode(payload.plainText).byteLength;
|
|
71
|
-
if ("data" in payload && payload.data) {
|
|
72
|
-
if (payload.data instanceof Blob)
|
|
73
|
-
return payload.data.size;
|
|
74
|
-
if (payload.data instanceof Response) {
|
|
75
|
-
const contentLength = payload.data.headers.get("content-length");
|
|
76
|
-
return contentLength ? Number(contentLength) : undefined;
|
|
77
|
-
}
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
if ("buffer" in payload && payload.buffer)
|
|
81
|
-
return payload.buffer.byteLength;
|
|
82
|
-
if (payload.uint8Array !== undefined) {
|
|
83
|
-
if (Array.isArray(payload.uint8Array))
|
|
84
|
-
return payload.uint8Array.length;
|
|
85
|
-
return payload.uint8Array.byteLength;
|
|
86
|
-
}
|
|
87
|
-
if (payload.base64 === undefined)
|
|
88
|
-
return;
|
|
89
|
-
const raw = getRawBase64(payload.base64).replace(/\s/g, "");
|
|
90
|
-
const padding = raw.endsWith("==") ? 2 : raw.endsWith("=") ? 1 : 0;
|
|
91
|
-
return Math.max(0, Math.floor(raw.length * 3 / 4) - padding);
|
|
92
|
-
};
|
|
93
|
-
var validateAssetPayload = (payload, options) => {
|
|
94
|
-
if ("base64" in payload && payload.base64 !== undefined) {
|
|
95
|
-
const validation = validateBase64PayloadString(payload, options);
|
|
96
|
-
if (!validation.ok)
|
|
97
|
-
return {
|
|
98
|
-
ok: false,
|
|
99
|
-
error: validation.error
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
const byteLength = getAssetPayloadByteLength(payload);
|
|
103
|
-
if (options?.multipart && !options.isFinal && byteLength !== undefined && byteLength < 5242880)
|
|
104
|
-
return {
|
|
105
|
-
ok: false,
|
|
106
|
-
error: MULTIPART_PART_TOO_SMALL_ERROR
|
|
107
|
-
};
|
|
108
|
-
return { ok: true };
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
// src/contract/Media.js
|
|
112
|
-
var MAX_MEDIA_UPLOAD_BYTES = 52428800;
|
|
113
|
-
|
|
114
|
-
// src/contract/ModerationContextLimits-BIMUlk2e.js
|
|
115
|
-
var countModerationContextCharacters = (text) => {
|
|
116
|
-
let count = 0;
|
|
117
|
-
for (const _ of text)
|
|
118
|
-
count++;
|
|
119
|
-
return count;
|
|
120
|
-
};
|
|
121
|
-
var selectModerationContextItems = (items) => {
|
|
122
|
-
const selected = [];
|
|
123
|
-
let characters = 0;
|
|
124
|
-
for (let index = items.length - 1;index >= 0; index--) {
|
|
125
|
-
if (selected.length === 5)
|
|
126
|
-
break;
|
|
127
|
-
const item = items[index];
|
|
128
|
-
const length = countModerationContextCharacters(item.text);
|
|
129
|
-
if (selected.length && characters + length > 2000)
|
|
130
|
-
break;
|
|
131
|
-
selected.unshift(item);
|
|
132
|
-
characters += length;
|
|
133
|
-
}
|
|
134
|
-
return selected;
|
|
135
|
-
};
|
|
136
|
-
// src/contract/SharedConstants-DxUCZwLZ.js
|
|
137
|
-
var IMPERSONATION_COOKIE_NAME = "CL_impersonation";
|
|
138
|
-
var DAY_MS = 86400000;
|
|
139
|
-
var YEAR_MS = 365 * DAY_MS;
|
|
140
|
-
var FIRST_PARTY_COOKIES = {
|
|
141
|
-
ACCEPTED_COOKIES_VERSION: {
|
|
142
|
-
name: "CL_acceptedCookiesVersion",
|
|
143
|
-
description: "Records your cookie choice: the version of this cookie list you answered and whether you allowed functional and analytics cookies",
|
|
144
|
-
expirationDescription: "1 year",
|
|
145
|
-
expirationMs: YEAR_MS,
|
|
146
|
-
type: "essential",
|
|
147
|
-
providerName: "CalmLens"
|
|
148
|
-
},
|
|
149
|
-
EVER_LOGGED_IN: {
|
|
150
|
-
name: "CL_everLoggedIn",
|
|
151
|
-
description: "Remembers which sign-in method you last used on this device so the sign-in page can suggest it",
|
|
152
|
-
expirationDescription: "10 years",
|
|
153
|
-
type: "functional",
|
|
154
|
-
providerName: "CalmLens"
|
|
155
|
-
},
|
|
156
|
-
ID_TOKEN: {
|
|
157
|
-
name: "CL_idToken",
|
|
158
|
-
description: "Authentication token that keeps you signed in (HttpOnly)",
|
|
159
|
-
expirationDescription: "When the token expires (about 1 hour); renewed while you are signed in",
|
|
160
|
-
type: "essential",
|
|
161
|
-
providerName: "CalmLens"
|
|
162
|
-
},
|
|
163
|
-
ID_TOKEN_EXPIRES_AT: {
|
|
164
|
-
name: "CL_idTokenExpiresAt",
|
|
165
|
-
description: "When the current authentication token expires, so it can be renewed in time",
|
|
166
|
-
expirationDescription: "10 years, or until you sign out",
|
|
167
|
-
type: "essential",
|
|
168
|
-
providerName: "CalmLens"
|
|
169
|
-
},
|
|
170
|
-
REFRESH_TOKEN: {
|
|
171
|
-
name: "CL_refreshToken",
|
|
172
|
-
description: "Token used to renew your sign-in without asking for your password again (HttpOnly)",
|
|
173
|
-
expirationDescription: "10 years, or until you sign out",
|
|
174
|
-
type: "essential",
|
|
175
|
-
providerName: "CalmLens"
|
|
176
|
-
},
|
|
177
|
-
LOGGED_IN: {
|
|
178
|
-
name: "CL_loggedIn",
|
|
179
|
-
description: "Indicates that you are signed in, so pages can show the signed-in view",
|
|
180
|
-
expirationDescription: "10 years, or until you sign out",
|
|
181
|
-
type: "essential",
|
|
182
|
-
providerName: "CalmLens"
|
|
183
|
-
},
|
|
184
|
-
IMPERSONATION: {
|
|
185
|
-
name: IMPERSONATION_COOKIE_NAME,
|
|
186
|
-
description: "Staff support access only: lets an authorised CalmLens staff member view the service as a specific user for support, security, safety or legal reasons. Only honoured for staff accounts and never set for other users",
|
|
187
|
-
expirationDescription: "Session",
|
|
188
|
-
type: "essential",
|
|
189
|
-
providerName: "CalmLens"
|
|
190
|
-
},
|
|
191
|
-
MAINTENANCE_BYPASS: {
|
|
192
|
-
name: "CL_maintenanceBypass",
|
|
193
|
-
description: "Staff only: allows authorised staff to use the site while it is in maintenance mode (HttpOnly)",
|
|
194
|
-
expirationDescription: "1 hour",
|
|
195
|
-
expirationMs: 3600000,
|
|
196
|
-
type: "essential",
|
|
197
|
-
providerName: "CalmLens"
|
|
198
|
-
},
|
|
199
|
-
WAITLIST_BYPASS: {
|
|
200
|
-
name: "CL_waitlistBypass",
|
|
201
|
-
description: "Staff only: allows authorised staff to use the site while access is limited to the waitlist (HttpOnly)",
|
|
202
|
-
expirationDescription: "1 hour",
|
|
203
|
-
expirationMs: 3600000,
|
|
204
|
-
type: "essential",
|
|
205
|
-
providerName: "CalmLens"
|
|
206
|
-
},
|
|
207
|
-
SIGN_IN_CODE: {
|
|
208
|
-
name: "CL_signInCode",
|
|
209
|
-
description: "Records that you entered the sign-in code while access is limited to the waitlist, so you can sign in (HttpOnly)",
|
|
210
|
-
expirationDescription: "30 days",
|
|
211
|
-
expirationMs: 30 * DAY_MS,
|
|
212
|
-
type: "essential",
|
|
213
|
-
providerName: "CalmLens"
|
|
214
|
-
},
|
|
215
|
-
SIGN_IN_CODE_ACCEPTED: {
|
|
216
|
-
name: "CL_signInCodeAccepted",
|
|
217
|
-
description: "Indicates that you entered the sign-in code, so the sign-in page shows the sign-in options",
|
|
218
|
-
expirationDescription: "30 days",
|
|
219
|
-
expirationMs: 30 * DAY_MS,
|
|
220
|
-
type: "essential",
|
|
221
|
-
providerName: "CalmLens"
|
|
222
|
-
},
|
|
223
|
-
PRE_RENDERED_WIDTH: {
|
|
224
|
-
name: "CL_preRenderedWidth",
|
|
225
|
-
description: "Your browser's viewport width, so pages are rendered with the right layout for your screen",
|
|
226
|
-
expirationDescription: "30 days",
|
|
227
|
-
expirationMs: 30 * DAY_MS,
|
|
228
|
-
type: "essential",
|
|
229
|
-
providerName: "CalmLens"
|
|
230
|
-
},
|
|
231
|
-
SELECTED_PROJECT_ID: {
|
|
232
|
-
name: "CL_selectedProjectId",
|
|
233
|
-
description: "Remembers the project you last selected in the portal",
|
|
234
|
-
expirationDescription: "1 year",
|
|
235
|
-
expirationMs: YEAR_MS,
|
|
236
|
-
type: "functional",
|
|
237
|
-
providerName: "CalmLens"
|
|
238
|
-
},
|
|
239
|
-
SELECTED_ORGANISATION_ID: {
|
|
240
|
-
name: "CL_selectedOrganisationId",
|
|
241
|
-
description: "Remembers the organisation you last selected in the portal",
|
|
242
|
-
expirationDescription: "1 year",
|
|
243
|
-
expirationMs: YEAR_MS,
|
|
244
|
-
type: "functional",
|
|
245
|
-
providerName: "CalmLens"
|
|
246
|
-
},
|
|
247
|
-
ASSET_DASHBOARD_STATE: {
|
|
248
|
-
name: "CL_assetDashboardState",
|
|
249
|
-
description: "Remembers your asset dashboard view (view mode, filters, sorting and folder)",
|
|
250
|
-
expirationDescription: "1 year",
|
|
251
|
-
expirationMs: YEAR_MS,
|
|
252
|
-
type: "functional",
|
|
253
|
-
providerName: "CalmLens"
|
|
254
|
-
},
|
|
255
|
-
ASSET_VIEW: {
|
|
256
|
-
name: "CL_assetView",
|
|
257
|
-
description: "Remembers whether you chose the grid or table view for an asset's sub-assets (one cookie per asset, named CL_assetView_<assetId>)",
|
|
258
|
-
expirationDescription: "30 days",
|
|
259
|
-
expirationMs: 30 * DAY_MS,
|
|
260
|
-
type: "functional",
|
|
261
|
-
providerName: "CalmLens",
|
|
262
|
-
isPrefix: true
|
|
263
|
-
},
|
|
264
|
-
PORTAL_GUIDANCE_HIDDEN: {
|
|
265
|
-
name: "CL_portalGuidanceHidden",
|
|
266
|
-
description: "Remembers whether you hid next-step tips for a project",
|
|
267
|
-
expirationDescription: "1 year",
|
|
268
|
-
expirationMs: YEAR_MS,
|
|
269
|
-
type: "functional",
|
|
270
|
-
providerName: "CalmLens",
|
|
271
|
-
isPrefix: true
|
|
272
|
-
},
|
|
273
|
-
PORTAL_LAYOUT_SPLIT_PANE: {
|
|
274
|
-
name: "CL_portalLayoutSplitPane",
|
|
275
|
-
description: "Remembers the width you set for the portal sidebar",
|
|
276
|
-
expirationDescription: "1 year",
|
|
277
|
-
expirationMs: YEAR_MS,
|
|
278
|
-
type: "functional",
|
|
279
|
-
providerName: "CalmLens"
|
|
280
|
-
},
|
|
281
|
-
DOCS_UI_LIBRARY: {
|
|
282
|
-
name: "CL_docsUiLibrary",
|
|
283
|
-
description: "Remembers the UI library you selected for documentation examples",
|
|
284
|
-
expirationDescription: "1 year",
|
|
285
|
-
expirationMs: YEAR_MS,
|
|
286
|
-
type: "functional",
|
|
287
|
-
providerName: "CalmLens"
|
|
288
|
-
},
|
|
289
|
-
DOCS_LANGUAGE: {
|
|
290
|
-
name: "CL_docsLanguage",
|
|
291
|
-
description: "Remembers the programming language you selected for documentation examples",
|
|
292
|
-
expirationDescription: "1 year",
|
|
293
|
-
expirationMs: YEAR_MS,
|
|
294
|
-
type: "functional",
|
|
295
|
-
providerName: "CalmLens"
|
|
296
|
-
},
|
|
297
|
-
SEARCH_SDK_LANGUAGE: {
|
|
298
|
-
name: "CL_searchSdkLanguage",
|
|
299
|
-
description: "Remembers the SDK you chose to filter documentation search results by",
|
|
300
|
-
expirationDescription: "1 year",
|
|
301
|
-
expirationMs: YEAR_MS,
|
|
302
|
-
type: "functional",
|
|
303
|
-
providerName: "CalmLens"
|
|
304
|
-
}
|
|
305
|
-
};
|
|
306
|
-
var THIRD_PARTY_COOKIES = {
|
|
307
|
-
GOOGLE_ANALYTICS: {
|
|
308
|
-
name: "_ga",
|
|
309
|
-
description: "Google Analytics distinguishes visitors and maintains session state, only with analytics consent",
|
|
310
|
-
expirationDescription: "2 years",
|
|
311
|
-
type: "analytics",
|
|
312
|
-
providerName: "Google Analytics",
|
|
313
|
-
isPrefix: true
|
|
314
|
-
},
|
|
315
|
-
GOOGLE_AD_CLICK: {
|
|
316
|
-
name: "_gcl",
|
|
317
|
-
description: "Links consented ad clicks to signups; no personalised advertising",
|
|
318
|
-
expirationDescription: "Up to 90 days",
|
|
319
|
-
type: "marketing",
|
|
320
|
-
providerName: "Google",
|
|
321
|
-
isPrefix: true
|
|
322
|
-
},
|
|
323
|
-
GOOGLE_CAMPAIGN: {
|
|
324
|
-
name: "_gac",
|
|
325
|
-
description: "Stores consented campaign attribution",
|
|
326
|
-
expirationDescription: "Up to 90 days",
|
|
327
|
-
type: "marketing",
|
|
328
|
-
providerName: "Google",
|
|
329
|
-
isPrefix: true
|
|
330
|
-
}
|
|
331
|
-
};
|
|
332
|
-
[...Object.values(FIRST_PARTY_COOKIES), ...Object.values(THIRD_PARTY_COOKIES)];
|
|
333
|
-
var MAX_IMAGE_UPLOAD_BYTES = /* @__PURE__ */ (() => 20971520)();
|
|
334
|
-
var MAX_DIRECT_IMAGE_UPLOAD_BYTES = /* @__PURE__ */ (() => 10485760)();
|
|
335
|
-
var MAX_NON_IMAGE_UPLOAD_MB = 5000;
|
|
336
|
-
var MAX_NON_IMAGE_UPLOAD_BYTES = /* @__PURE__ */ (() => MAX_NON_IMAGE_UPLOAD_MB * 1024 * 1024)();
|
|
337
|
-
var normalizeUploadMimeType = (mimeType) => mimeType.toLowerCase().split(";")[0]?.trim() || mimeType.toLowerCase().trim();
|
|
338
|
-
var getRejectedUploadMimeTypeError = (mimeType) => `${normalizeUploadMimeType(mimeType)} is not a valid upload file type. Uploads must use a concrete file MIME type that CalmLens can store and process, such as image/png, image/jpeg, application/pdf, or text/plain.`;
|
|
339
|
-
var DOMAIN = "calmlens.com";
|
|
340
25
|
// src/client/CalmLensErrorCodes.ts
|
|
341
26
|
var API_ERROR_CODES = {
|
|
342
|
-
INVALID_VIEWER_CLAIMS: "viewer/invalid
|
|
27
|
+
INVALID_VIEWER_CLAIMS: "viewer-claims/invalid",
|
|
343
28
|
AGE_CONFIRMATION_REQUIRED: "viewer/age-confirmation-required",
|
|
344
|
-
INVALID_VIEWER_REGION: "viewer/invalid
|
|
29
|
+
INVALID_VIEWER_REGION: "viewer-region/invalid",
|
|
345
30
|
VIEWER_REGION_REQUIRED: "viewer/region-required",
|
|
346
31
|
REGIONAL_EVIDENCE_REQUIRED: "asset/regional-evidence-required",
|
|
347
32
|
SIGNED_URL_EXPIRED: "signed-url/expired",
|
|
348
33
|
SIGNED_URL_INVALID: "signed-url/invalid",
|
|
34
|
+
SIGNED_URL_ORIGINAL_NOT_GRANTED: "signed-url/original-not-granted",
|
|
35
|
+
INVALID_REQUEST: "validation/invalid-request",
|
|
349
36
|
INVALID_TYPE: "validation/invalid-type",
|
|
350
37
|
TOO_SMALL: "validation/too-small",
|
|
351
38
|
TOO_BIG: "validation/too-big",
|
|
352
39
|
INVALID_FORMAT: "validation/invalid-format",
|
|
353
40
|
INVALID_VALUE: "validation/invalid-value",
|
|
354
41
|
UNKNOWN_FIELD: "validation/unknown-field",
|
|
355
|
-
UNSUPPORTED_CONTENT_TYPE: "
|
|
356
|
-
INVALID_FILTER: "
|
|
357
|
-
|
|
358
|
-
ROUTE_NOT_FOUND: "
|
|
359
|
-
INTERNAL_ERROR: "
|
|
42
|
+
UNSUPPORTED_CONTENT_TYPE: "request/unsupported-content-type",
|
|
43
|
+
INVALID_FILTER: "filter/invalid",
|
|
44
|
+
UNSUPPORTED_ORDERING_FIELD: "ordering/unsupported-field",
|
|
45
|
+
ROUTE_NOT_FOUND: "request/route-not-found",
|
|
46
|
+
INTERNAL_ERROR: "server/internal-error",
|
|
360
47
|
UNAUTHENTICATED: "auth/unauthenticated",
|
|
361
|
-
TOKEN_EXPIRED: "
|
|
362
|
-
INVALID_TOKEN: "
|
|
48
|
+
TOKEN_EXPIRED: "session-token/expired",
|
|
49
|
+
INVALID_TOKEN: "session-token/invalid",
|
|
363
50
|
SEARCH_UNAVAILABLE: "search/unavailable",
|
|
364
|
-
INVALID_TRANSFORM: "
|
|
365
|
-
INVALID_TRANSFORM_OPTIONS: "
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
API_KEY_PROJECT_MISMATCH: "auth/project-mismatch",
|
|
373
|
-
API_KEY_NOT_ACCEPTED: "auth/api-key-not-accepted",
|
|
51
|
+
INVALID_TRANSFORM: "transform/invalid",
|
|
52
|
+
INVALID_TRANSFORM_OPTIONS: "transform-options/invalid",
|
|
53
|
+
REMOTE_URL_TOO_MANY_REDIRECTS: "remote-url/too-many-redirects",
|
|
54
|
+
INVALID_CURSOR: "cursor/invalid",
|
|
55
|
+
MISSING_API_KEY: "api-key/missing",
|
|
56
|
+
INVALID_API_KEY: "api-key/invalid",
|
|
57
|
+
API_KEY_PROJECT_MISMATCH: "api-key/project-mismatch",
|
|
58
|
+
API_KEY_NOT_ACCEPTED: "api-key/not-accepted",
|
|
374
59
|
PERMISSION_DENIED: "auth/permission-denied",
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
INVALID_UPLOAD_MIME_TYPE: "upload/invalid-mime-type",
|
|
384
|
-
INVALID_UPLOAD_PAYLOAD: "upload/invalid-payload",
|
|
60
|
+
UPLOAD_TOO_LARGE: "upload/too-large",
|
|
61
|
+
DOCUMENT_TOO_MANY_ITEMS: "document/too-many-items",
|
|
62
|
+
INVALID_IMAGE: "image/invalid",
|
|
63
|
+
IMAGE_TOO_LARGE: "image/too-large",
|
|
64
|
+
FREE_UPLOADS_EXHAUSTED: "usage/free-uploads-exhausted",
|
|
65
|
+
UPLOADS_PAUSED: "usage/uploads-paused",
|
|
66
|
+
UNSUPPORTED_UPLOAD_TYPE: "upload/unsupported-type",
|
|
67
|
+
INVALID_UPLOAD_PAYLOAD: "upload-payload/invalid",
|
|
385
68
|
USE_UPLOAD_PART: "upload/use-upload-part",
|
|
386
69
|
UPLOAD_NOT_OPEN: "upload/not-open",
|
|
387
|
-
INVALID_UPLOAD_PART_NUMBER: "upload/invalid-
|
|
70
|
+
INVALID_UPLOAD_PART_NUMBER: "upload-part/invalid-number",
|
|
388
71
|
UPLOAD_MISSING: "upload/missing",
|
|
389
72
|
UPLOAD_SIZE_MISMATCH: "upload/size-mismatch",
|
|
390
73
|
INVALID_IDEMPOTENCY_KEY: "idempotency/invalid-key",
|
|
391
74
|
IDEMPOTENCY_KEY_REUSED: "idempotency/key-reused",
|
|
392
75
|
IDEMPOTENT_REQUEST_IN_PROGRESS: "idempotency/request-in-progress",
|
|
76
|
+
NO_RENDERED_VERSION: "asset/no-rendered-version",
|
|
393
77
|
ASSET_NOT_FOUND: "asset/not-found",
|
|
394
78
|
PROJECT_NOT_FOUND: "project/not-found",
|
|
79
|
+
ASSET_CHILD_NOT_DELETABLE: "asset/child-not-deletable",
|
|
395
80
|
ASSET_REVIEW_CHANGED: "asset/review-changed",
|
|
396
81
|
ASSET_REVIEW_NOTE_REQUIRED: "asset/review-note-required",
|
|
397
82
|
ASSET_UPDATE_FAILED: "asset/update-failed",
|
|
398
|
-
|
|
83
|
+
ASSET_HELD: "asset/held",
|
|
399
84
|
ASSET_PROCESSING: "asset/processing",
|
|
400
85
|
ASSET_DECISION_NOT_ALLOWED: "asset/decision-not-allowed",
|
|
401
86
|
ASSET_DECISION_UNCHANGED: "asset/decision-unchanged",
|
|
@@ -405,18 +90,19 @@ var API_ERROR_CODES = {
|
|
|
405
90
|
ASSET_NOT_DECIDED: "asset/not-decided",
|
|
406
91
|
ASSET_POLICY_CHANGED: "asset/policy-changed",
|
|
407
92
|
ASSET_REVIEWED: "asset/reviewed",
|
|
408
|
-
SUPPORT_TICKET_NOT_FOUND: "support/
|
|
93
|
+
SUPPORT_TICKET_NOT_FOUND: "support-ticket/not-found",
|
|
409
94
|
DUPLICATE_EXTERNAL_ID: "asset/duplicate-external-id",
|
|
410
95
|
FOLDER_NOT_FOUND: "folder/not-found",
|
|
411
96
|
DUPLICATE_FOLDER_NAME: "folder/duplicate-name",
|
|
412
97
|
FOLDER_NOT_EMPTY: "folder/not-empty",
|
|
413
98
|
FOLDER_PARENT_CYCLE: "folder/parent-cycle",
|
|
414
|
-
|
|
99
|
+
LENS_NOT_FOUND: "lens/not-found",
|
|
100
|
+
LENS_IDENTIFIER_TAKEN: "lens/identifier-taken",
|
|
415
101
|
LENS_IDENTIFIER_RESERVED: "lens/identifier-reserved",
|
|
416
102
|
HASH_LIST_NOT_FOUND: "hash-list/not-found",
|
|
417
|
-
HASH_LIST_ENTRY_NOT_FOUND: "hash-list/
|
|
103
|
+
HASH_LIST_ENTRY_NOT_FOUND: "hash-list-entry/not-found",
|
|
418
104
|
HASH_LIST_LIMIT_REACHED: "hash-list/limit-reached",
|
|
419
|
-
HASH_LIST_ENTRY_LIMIT_REACHED: "hash-list/
|
|
105
|
+
HASH_LIST_ENTRY_LIMIT_REACHED: "hash-list-entry/limit-reached",
|
|
420
106
|
HASH_LIST_ASSET_NOT_HASHED: "hash-list/asset-not-hashed",
|
|
421
107
|
POLICY_NOT_FOUND: "policy/not-found",
|
|
422
108
|
POLICY_REVISION_CONFLICT: "policy/revision-conflict",
|
|
@@ -430,18 +116,16 @@ var API_ERROR_CODES = {
|
|
|
430
116
|
UPLOAD_PRESET_NOT_FOUND: "upload-preset/not-found",
|
|
431
117
|
UPLOAD_PRESET_DISABLED: "upload-preset/disabled",
|
|
432
118
|
UPLOAD_PRESET_TOKEN_REQUIRED: "upload-preset/token-required",
|
|
433
|
-
REMOTE_URL_NOT_ALLOWED: "
|
|
434
|
-
|
|
435
|
-
UPLOAD_PRESET_CONTENT_TYPE_NOT_ALLOWED: "upload-preset/content-type-not-allowed",
|
|
436
|
-
UPLOAD_PRESET_TOO_LARGE: "upload-preset/too-large",
|
|
119
|
+
REMOTE_URL_NOT_ALLOWED: "remote-url/not-allowed",
|
|
120
|
+
WEBSITE_RATE_LIMIT_REACHED: "upload/website-rate-limit-reached",
|
|
437
121
|
UPLOAD_PRESET_DAILY_LIMIT_REACHED: "upload-preset/daily-limit-reached",
|
|
438
122
|
UPLOAD_PRESET_ORIGIN_NOT_ALLOWED: "upload-preset/origin-not-allowed",
|
|
439
123
|
UPLOAD_PRESET_FIELD_NOT_ALLOWED: "upload-preset/field-not-allowed",
|
|
440
124
|
UPLOAD_TOKEN_INVALID: "upload-token/invalid",
|
|
441
125
|
UPLOAD_TOKEN_EXPIRED: "upload-token/expired",
|
|
442
126
|
UPLOAD_TOKEN_USED: "upload-token/used",
|
|
443
|
-
INVALID_REMOTE_URL: "
|
|
444
|
-
REMOTE_URL_UNAVAILABLE: "
|
|
127
|
+
INVALID_REMOTE_URL: "remote-url/invalid",
|
|
128
|
+
REMOTE_URL_UNAVAILABLE: "remote-url/unavailable",
|
|
445
129
|
APPEAL_NOT_FOUND: "appeal/not-found",
|
|
446
130
|
APPEAL_JUDGMENT_NOT_FOUND: "appeal/judgment-not-found",
|
|
447
131
|
APPEAL_ASSET_NOT_FOUND: "appeal/asset-not-found",
|
|
@@ -449,7 +133,6 @@ var API_ERROR_CODES = {
|
|
|
449
133
|
APPEAL_ALREADY_REVIEWED: "appeal/already-reviewed",
|
|
450
134
|
APPEAL_DECISION_CHANGED: "appeal/decision-changed",
|
|
451
135
|
APPEAL_INVALID_ACTION: "appeal/invalid-action",
|
|
452
|
-
APPEAL_SAFETY_HELD: "appeal/safety-held",
|
|
453
136
|
APPEAL_CONTENT_UNAVAILABLE: "appeal/content-unavailable"
|
|
454
137
|
};
|
|
455
138
|
|
|
@@ -469,7 +152,7 @@ var SDK_ERROR_CODES = {
|
|
|
469
152
|
};
|
|
470
153
|
var CALMLENS_ERROR_CODES = { ...API_ERROR_CODES, ...SDK_ERROR_CODES };
|
|
471
154
|
var BRAND = Symbol.for("calmlens.sdk.CalmLensError");
|
|
472
|
-
var RETRYABLE_STATUSES = new Set([429, 502, 503, 504]);
|
|
155
|
+
var RETRYABLE_STATUSES = new Set([429, 500, 502, 503, 504]);
|
|
473
156
|
var RETRYABLE_CODES = new Set([
|
|
474
157
|
SDK_ERROR_CODES.TRANSPORT_ERROR,
|
|
475
158
|
SDK_ERROR_CODES.TIMEOUT,
|
|
@@ -536,7 +219,7 @@ var isReactNativeRuntime = () => globalThis.navigator?.product === "ReactNative"
|
|
|
536
219
|
var RETRY_BASE_DELAY_MS = 500;
|
|
537
220
|
var RETRY_MAX_DELAY_MS = 8000;
|
|
538
221
|
var RETRY_AFTER_MAX_MS = 60000;
|
|
539
|
-
var RETRYABLE_STATUSES2 = new Set([429, 502, 503, 504]);
|
|
222
|
+
var RETRYABLE_STATUSES2 = new Set([429, 500, 502, 503, 504]);
|
|
540
223
|
var timeoutReason = () => {
|
|
541
224
|
const reason = new Error("The operation timed out.");
|
|
542
225
|
reason.name = "TimeoutError";
|
|
@@ -786,30 +469,234 @@ class CalmLensTransport {
|
|
|
786
469
|
throw error;
|
|
787
470
|
}
|
|
788
471
|
}
|
|
789
|
-
async json(request) {
|
|
790
|
-
const { response, attempt } = await this.send(request);
|
|
791
|
-
try {
|
|
792
|
-
const bytes = await readBody(response, this.settings.maxResponseBytes);
|
|
793
|
-
if (bytes.byteLength === 0 && (response.status === 204 || request.method === "DELETE")) {
|
|
794
|
-
return;
|
|
795
|
-
}
|
|
796
|
-
try {
|
|
797
|
-
return JSON.parse(new TextDecoder().decode(bytes));
|
|
798
|
-
} catch (cause) {
|
|
799
|
-
throw new CalmLensError(SDK_ERROR_CODES.INVALID_RESPONSE, {
|
|
800
|
-
message: `Invalid JSON response (HTTP ${response.status})`,
|
|
801
|
-
...responseInfo(response),
|
|
802
|
-
cause
|
|
803
|
-
});
|
|
804
|
-
}
|
|
805
|
-
} catch (cause) {
|
|
806
|
-
throw toFailure(cause, attempt);
|
|
807
|
-
} finally {
|
|
808
|
-
attempt.release();
|
|
809
|
-
}
|
|
472
|
+
async json(request) {
|
|
473
|
+
const { response, attempt } = await this.send(request);
|
|
474
|
+
try {
|
|
475
|
+
const bytes = await readBody(response, this.settings.maxResponseBytes);
|
|
476
|
+
if (bytes.byteLength === 0 && (response.status === 204 || request.method === "DELETE")) {
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
479
|
+
try {
|
|
480
|
+
return JSON.parse(new TextDecoder().decode(bytes));
|
|
481
|
+
} catch (cause) {
|
|
482
|
+
throw new CalmLensError(SDK_ERROR_CODES.INVALID_RESPONSE, {
|
|
483
|
+
message: `Invalid JSON response (HTTP ${response.status})`,
|
|
484
|
+
...responseInfo(response),
|
|
485
|
+
cause
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
} catch (cause) {
|
|
489
|
+
throw toFailure(cause, attempt);
|
|
490
|
+
} finally {
|
|
491
|
+
attempt.release();
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
// src/contract/SharedConstants-DxUCZwLZ.js
|
|
497
|
+
var IMPERSONATION_COOKIE_NAME = "CL_impersonation";
|
|
498
|
+
var DAY_MS = 86400000;
|
|
499
|
+
var YEAR_MS = 365 * DAY_MS;
|
|
500
|
+
var FIRST_PARTY_COOKIES = {
|
|
501
|
+
ACCEPTED_COOKIES_VERSION: {
|
|
502
|
+
name: "CL_acceptedCookiesVersion",
|
|
503
|
+
description: "Records your cookie choice: the version of this cookie list you answered and whether you allowed functional and analytics cookies",
|
|
504
|
+
expirationDescription: "1 year",
|
|
505
|
+
expirationMs: YEAR_MS,
|
|
506
|
+
type: "essential",
|
|
507
|
+
providerName: "CalmLens"
|
|
508
|
+
},
|
|
509
|
+
EVER_LOGGED_IN: {
|
|
510
|
+
name: "CL_everLoggedIn",
|
|
511
|
+
description: "Remembers which sign-in method you last used on this device so the sign-in page can suggest it",
|
|
512
|
+
expirationDescription: "10 years",
|
|
513
|
+
type: "functional",
|
|
514
|
+
providerName: "CalmLens"
|
|
515
|
+
},
|
|
516
|
+
ID_TOKEN: {
|
|
517
|
+
name: "CL_idToken",
|
|
518
|
+
description: "Authentication token that keeps you signed in (HttpOnly)",
|
|
519
|
+
expirationDescription: "When the token expires (about 1 hour); renewed while you are signed in",
|
|
520
|
+
type: "essential",
|
|
521
|
+
providerName: "CalmLens"
|
|
522
|
+
},
|
|
523
|
+
ID_TOKEN_EXPIRES_AT: {
|
|
524
|
+
name: "CL_idTokenExpiresAt",
|
|
525
|
+
description: "When the current authentication token expires, so it can be renewed in time",
|
|
526
|
+
expirationDescription: "10 years, or until you sign out",
|
|
527
|
+
type: "essential",
|
|
528
|
+
providerName: "CalmLens"
|
|
529
|
+
},
|
|
530
|
+
REFRESH_TOKEN: {
|
|
531
|
+
name: "CL_refreshToken",
|
|
532
|
+
description: "Token used to renew your sign-in without asking for your password again (HttpOnly)",
|
|
533
|
+
expirationDescription: "10 years, or until you sign out",
|
|
534
|
+
type: "essential",
|
|
535
|
+
providerName: "CalmLens"
|
|
536
|
+
},
|
|
537
|
+
LOGGED_IN: {
|
|
538
|
+
name: "CL_loggedIn",
|
|
539
|
+
description: "Indicates that you are signed in, so pages can show the signed-in view",
|
|
540
|
+
expirationDescription: "10 years, or until you sign out",
|
|
541
|
+
type: "essential",
|
|
542
|
+
providerName: "CalmLens"
|
|
543
|
+
},
|
|
544
|
+
IMPERSONATION: {
|
|
545
|
+
name: IMPERSONATION_COOKIE_NAME,
|
|
546
|
+
description: "Staff support access only: lets an authorised CalmLens staff member view the service as a specific user for support, security, safety or legal reasons. Only honoured for staff accounts and never set for other users",
|
|
547
|
+
expirationDescription: "Session",
|
|
548
|
+
type: "essential",
|
|
549
|
+
providerName: "CalmLens"
|
|
550
|
+
},
|
|
551
|
+
MAINTENANCE_BYPASS: {
|
|
552
|
+
name: "CL_maintenanceBypass",
|
|
553
|
+
description: "Staff only: allows authorised staff to use the site while it is in maintenance mode (HttpOnly)",
|
|
554
|
+
expirationDescription: "1 hour",
|
|
555
|
+
expirationMs: 3600000,
|
|
556
|
+
type: "essential",
|
|
557
|
+
providerName: "CalmLens"
|
|
558
|
+
},
|
|
559
|
+
WAITLIST_BYPASS: {
|
|
560
|
+
name: "CL_waitlistBypass",
|
|
561
|
+
description: "Staff only: allows authorised staff to use the site while access is limited to the waitlist (HttpOnly)",
|
|
562
|
+
expirationDescription: "1 hour",
|
|
563
|
+
expirationMs: 3600000,
|
|
564
|
+
type: "essential",
|
|
565
|
+
providerName: "CalmLens"
|
|
566
|
+
},
|
|
567
|
+
SIGN_IN_CODE: {
|
|
568
|
+
name: "CL_signInCode",
|
|
569
|
+
description: "Records that you entered the sign-in code while access is limited to the waitlist, so you can sign in (HttpOnly)",
|
|
570
|
+
expirationDescription: "30 days",
|
|
571
|
+
expirationMs: 30 * DAY_MS,
|
|
572
|
+
type: "essential",
|
|
573
|
+
providerName: "CalmLens"
|
|
574
|
+
},
|
|
575
|
+
SIGN_IN_CODE_ACCEPTED: {
|
|
576
|
+
name: "CL_signInCodeAccepted",
|
|
577
|
+
description: "Indicates that you entered the sign-in code, so the sign-in page shows the sign-in options",
|
|
578
|
+
expirationDescription: "30 days",
|
|
579
|
+
expirationMs: 30 * DAY_MS,
|
|
580
|
+
type: "essential",
|
|
581
|
+
providerName: "CalmLens"
|
|
582
|
+
},
|
|
583
|
+
PRE_RENDERED_WIDTH: {
|
|
584
|
+
name: "CL_preRenderedWidth",
|
|
585
|
+
description: "Your browser's viewport width, so pages are rendered with the right layout for your screen",
|
|
586
|
+
expirationDescription: "30 days",
|
|
587
|
+
expirationMs: 30 * DAY_MS,
|
|
588
|
+
type: "essential",
|
|
589
|
+
providerName: "CalmLens"
|
|
590
|
+
},
|
|
591
|
+
SELECTED_PROJECT_ID: {
|
|
592
|
+
name: "CL_selectedProjectId",
|
|
593
|
+
description: "Remembers the project you last selected in the portal",
|
|
594
|
+
expirationDescription: "1 year",
|
|
595
|
+
expirationMs: YEAR_MS,
|
|
596
|
+
type: "functional",
|
|
597
|
+
providerName: "CalmLens"
|
|
598
|
+
},
|
|
599
|
+
SELECTED_ORGANISATION_ID: {
|
|
600
|
+
name: "CL_selectedOrganisationId",
|
|
601
|
+
description: "Remembers the organisation you last selected in the portal",
|
|
602
|
+
expirationDescription: "1 year",
|
|
603
|
+
expirationMs: YEAR_MS,
|
|
604
|
+
type: "functional",
|
|
605
|
+
providerName: "CalmLens"
|
|
606
|
+
},
|
|
607
|
+
ASSET_DASHBOARD_STATE: {
|
|
608
|
+
name: "CL_assetDashboardState",
|
|
609
|
+
description: "Remembers your asset dashboard view (view mode, filters, sorting and folder)",
|
|
610
|
+
expirationDescription: "1 year",
|
|
611
|
+
expirationMs: YEAR_MS,
|
|
612
|
+
type: "functional",
|
|
613
|
+
providerName: "CalmLens"
|
|
614
|
+
},
|
|
615
|
+
ASSET_VIEW: {
|
|
616
|
+
name: "CL_assetView",
|
|
617
|
+
description: "Remembers whether you chose the grid or table view for an asset's sub-assets (one cookie per asset, named CL_assetView_<assetId>)",
|
|
618
|
+
expirationDescription: "30 days",
|
|
619
|
+
expirationMs: 30 * DAY_MS,
|
|
620
|
+
type: "functional",
|
|
621
|
+
providerName: "CalmLens",
|
|
622
|
+
isPrefix: true
|
|
623
|
+
},
|
|
624
|
+
PORTAL_GUIDANCE_HIDDEN: {
|
|
625
|
+
name: "CL_portalGuidanceHidden",
|
|
626
|
+
description: "Remembers whether you hid next-step tips for a project",
|
|
627
|
+
expirationDescription: "1 year",
|
|
628
|
+
expirationMs: YEAR_MS,
|
|
629
|
+
type: "functional",
|
|
630
|
+
providerName: "CalmLens",
|
|
631
|
+
isPrefix: true
|
|
632
|
+
},
|
|
633
|
+
PORTAL_LAYOUT_SPLIT_PANE: {
|
|
634
|
+
name: "CL_portalLayoutSplitPane",
|
|
635
|
+
description: "Remembers the width you set for the portal sidebar",
|
|
636
|
+
expirationDescription: "1 year",
|
|
637
|
+
expirationMs: YEAR_MS,
|
|
638
|
+
type: "functional",
|
|
639
|
+
providerName: "CalmLens"
|
|
640
|
+
},
|
|
641
|
+
DOCS_UI_LIBRARY: {
|
|
642
|
+
name: "CL_docsUiLibrary",
|
|
643
|
+
description: "Remembers the UI library you selected for documentation examples",
|
|
644
|
+
expirationDescription: "1 year",
|
|
645
|
+
expirationMs: YEAR_MS,
|
|
646
|
+
type: "functional",
|
|
647
|
+
providerName: "CalmLens"
|
|
648
|
+
},
|
|
649
|
+
DOCS_LANGUAGE: {
|
|
650
|
+
name: "CL_docsLanguage",
|
|
651
|
+
description: "Remembers the programming language you selected for documentation examples",
|
|
652
|
+
expirationDescription: "1 year",
|
|
653
|
+
expirationMs: YEAR_MS,
|
|
654
|
+
type: "functional",
|
|
655
|
+
providerName: "CalmLens"
|
|
656
|
+
},
|
|
657
|
+
SEARCH_SDK_LANGUAGE: {
|
|
658
|
+
name: "CL_searchSdkLanguage",
|
|
659
|
+
description: "Remembers the SDK you chose to filter documentation search results by",
|
|
660
|
+
expirationDescription: "1 year",
|
|
661
|
+
expirationMs: YEAR_MS,
|
|
662
|
+
type: "functional",
|
|
663
|
+
providerName: "CalmLens"
|
|
664
|
+
}
|
|
665
|
+
};
|
|
666
|
+
var THIRD_PARTY_COOKIES = {
|
|
667
|
+
GOOGLE_ANALYTICS: {
|
|
668
|
+
name: "_ga",
|
|
669
|
+
description: "Google Analytics distinguishes visitors and maintains session state, only with analytics consent",
|
|
670
|
+
expirationDescription: "2 years",
|
|
671
|
+
type: "analytics",
|
|
672
|
+
providerName: "Google Analytics",
|
|
673
|
+
isPrefix: true
|
|
674
|
+
},
|
|
675
|
+
GOOGLE_AD_CLICK: {
|
|
676
|
+
name: "_gcl",
|
|
677
|
+
description: "Links consented ad clicks to signups; no personalised advertising",
|
|
678
|
+
expirationDescription: "Up to 90 days",
|
|
679
|
+
type: "marketing",
|
|
680
|
+
providerName: "Google",
|
|
681
|
+
isPrefix: true
|
|
682
|
+
},
|
|
683
|
+
GOOGLE_CAMPAIGN: {
|
|
684
|
+
name: "_gac",
|
|
685
|
+
description: "Stores consented campaign attribution",
|
|
686
|
+
expirationDescription: "Up to 90 days",
|
|
687
|
+
type: "marketing",
|
|
688
|
+
providerName: "Google",
|
|
689
|
+
isPrefix: true
|
|
810
690
|
}
|
|
811
|
-
}
|
|
812
|
-
|
|
691
|
+
};
|
|
692
|
+
[...Object.values(FIRST_PARTY_COOKIES), ...Object.values(THIRD_PARTY_COOKIES)];
|
|
693
|
+
var MAX_IMAGE_UPLOAD_BYTES = /* @__PURE__ */ (() => 20971520)();
|
|
694
|
+
var MAX_DIRECT_IMAGE_UPLOAD_BYTES = /* @__PURE__ */ (() => 10485760)();
|
|
695
|
+
var MAX_NON_IMAGE_UPLOAD_MB = 5000;
|
|
696
|
+
var MAX_NON_IMAGE_UPLOAD_BYTES = /* @__PURE__ */ (() => MAX_NON_IMAGE_UPLOAD_MB * 1024 * 1024)();
|
|
697
|
+
var normalizeUploadMimeType = (mimeType) => mimeType.toLowerCase().split(";")[0]?.trim() || mimeType.toLowerCase().trim();
|
|
698
|
+
var getRejectedUploadMimeTypeError = (mimeType) => `${normalizeUploadMimeType(mimeType)} is not a valid upload file type. Uploads must use a concrete file MIME type that CalmLens can store and process, such as image/png, image/jpeg, application/pdf, or text/plain.`;
|
|
699
|
+
var DOMAIN = "calmlens.com";
|
|
813
700
|
// src/client/CalmLensTransformSchema.ts
|
|
814
701
|
var TRANSFORM_OPTIONS_SCHEMA = {
|
|
815
702
|
type: "object",
|
|
@@ -1008,6 +895,14 @@ var UPLOAD_MIME_TYPES = [
|
|
|
1008
895
|
"application/msword",
|
|
1009
896
|
"application/rtf",
|
|
1010
897
|
"application/vnd.oasis.opendocument.text",
|
|
898
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
899
|
+
"application/vnd.ms-excel.sheet.macroenabled.12",
|
|
900
|
+
"application/vnd.ms-excel",
|
|
901
|
+
"application/vnd.oasis.opendocument.spreadsheet",
|
|
902
|
+
"application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
903
|
+
"application/vnd.ms-powerpoint.presentation.macroenabled.12",
|
|
904
|
+
"application/vnd.ms-powerpoint",
|
|
905
|
+
"application/vnd.oasis.opendocument.presentation",
|
|
1011
906
|
"application/javascript",
|
|
1012
907
|
"application/json",
|
|
1013
908
|
"application/x-javascript",
|
|
@@ -1016,25 +911,6 @@ var UPLOAD_MIME_TYPES = [
|
|
|
1016
911
|
"application/yaml"
|
|
1017
912
|
];
|
|
1018
913
|
|
|
1019
|
-
// src/client/CalmLensViewerClaims.ts
|
|
1020
|
-
var VIEWER_COUNTRIES = new Set("AD AE AF AG AI AL AM AO AQ AR AS AT AU AW AX AZ BA BB BD BE BF BG BH BI BJ BL BM BN BO BQ BR BS BT BV BW BY BZ CA CC CD CF CG CH CI CK CL CM CN CO CR CU CV CW CX CY CZ DE DJ DK DM DO DZ EC EE EG EH ER ES ET FI FJ FK FM FO FR GA GB GD GE GF GG GH GI GL GM GN GP GQ GR GS GT GU GW GY HK HM HN HR HT HU ID IE IL IM IN IO IQ IR IS IT JE JM JO JP KE KG KH KI KM KN KP KR KW KY KZ LA LB LC LI LK LR LS LT LU LV LY MA MC MD ME MF MG MH MK ML MM MN MO MP MQ MR MS MT MU MV MW MX MY MZ NA NC NE NF NG NI NL NO NP NR NU NZ OM PA PE PF PG PH PK PL PM PN PR PS PT PW PY QA RE RO RS RU RW SA SB SC SD SE SG SH SI SJ SK SL SM SN SO SR SS ST SV SX SY SZ TC TD TF TG TH TJ TK TL TM TN TO TR TT TV TW TZ UA UG UM US UY UZ VA VC VE VG VI VN VU WF WS YE YT ZA ZM ZW".split(" "));
|
|
1021
|
-
var EU_COUNTRIES = new Set("AT BE BG HR CY CZ DK EE FI FR DE GR HU IE IT LV LT LU MT NL PL PT RO SK SI ES SE".split(" "));
|
|
1022
|
-
var parseViewerClaims = (value) => {
|
|
1023
|
-
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
1024
|
-
return;
|
|
1025
|
-
const { region, ageConfirmed, ...rest } = value;
|
|
1026
|
-
if (Object.keys(rest).length)
|
|
1027
|
-
return;
|
|
1028
|
-
if (region !== undefined && (typeof region !== "string" || !VIEWER_COUNTRIES.has(region)))
|
|
1029
|
-
return;
|
|
1030
|
-
if (ageConfirmed !== undefined && typeof ageConfirmed !== "boolean")
|
|
1031
|
-
return;
|
|
1032
|
-
return {
|
|
1033
|
-
...region !== undefined && { region },
|
|
1034
|
-
...ageConfirmed !== undefined && { ageConfirmed }
|
|
1035
|
-
};
|
|
1036
|
-
};
|
|
1037
|
-
|
|
1038
914
|
// src/client/CalmLensUtils.ts
|
|
1039
915
|
var assertHttpUrl = (name, value) => {
|
|
1040
916
|
if (value === undefined)
|
|
@@ -1096,11 +972,20 @@ var validateRequestOptions = (options) => {
|
|
|
1096
972
|
assertInteger("uploadTimeoutMs", options.uploadTimeoutMs, 1);
|
|
1097
973
|
assertInteger("maxRetries", options.maxRetries, 0);
|
|
1098
974
|
};
|
|
975
|
+
var CDN_LOCATION_KEYS = [
|
|
976
|
+
"assetId",
|
|
977
|
+
"externalId",
|
|
978
|
+
"lens",
|
|
979
|
+
"projectId",
|
|
980
|
+
"resource",
|
|
981
|
+
"transform",
|
|
982
|
+
"viewerClaims"
|
|
983
|
+
];
|
|
1099
984
|
var LOCAL_OPTION_KEYS = {
|
|
1100
985
|
"assets.waitForDecision": ["assetId", "signal", "timeoutMs"],
|
|
1101
|
-
"cdn.getAssetUrl":
|
|
1102
|
-
"cdn.serve": [
|
|
1103
|
-
"uploadTokens.sign": ["
|
|
986
|
+
"cdn.getAssetUrl": CDN_LOCATION_KEYS,
|
|
987
|
+
"cdn.serve": [...CDN_LOCATION_KEYS, "init"],
|
|
988
|
+
"uploadTokens.sign": ["expiresIn", "externalId", "uploadPresetId"]
|
|
1104
989
|
};
|
|
1105
990
|
var IDEMPOTENT_OPERATIONS = [
|
|
1106
991
|
"assets.create",
|
|
@@ -1265,13 +1150,6 @@ var transformSelector = (transform) => {
|
|
|
1265
1150
|
return transform;
|
|
1266
1151
|
};
|
|
1267
1152
|
var DEFAULT_CDN_BASE_URL = `https://cdn.${DOMAIN}/v1`;
|
|
1268
|
-
var CDN_RESOURCES = new Set([
|
|
1269
|
-
"original",
|
|
1270
|
-
"rendered",
|
|
1271
|
-
"placeholder"
|
|
1272
|
-
]);
|
|
1273
|
-
var DEFAULT_SIGNED_URL_EXPIRES_IN_SECONDS = 60 * 15;
|
|
1274
|
-
var MAX_SIGNED_URL_SECONDS = 60 * 60 * 24;
|
|
1275
1153
|
var ASSET_BATCH_MAX_ASSETS = 500;
|
|
1276
1154
|
var ASSET_BATCH_OPERATIONS = ["delete", "remove-content"];
|
|
1277
1155
|
var validateBatchAssetsOptions = ({ assetIds, operation }) => {
|
|
@@ -1285,115 +1163,323 @@ var validateBatchAssetsOptions = ({ assetIds, operation }) => {
|
|
|
1285
1163
|
throw invalidArgument(`operation must be one of ${ASSET_BATCH_OPERATIONS.join(", ")}`);
|
|
1286
1164
|
}
|
|
1287
1165
|
};
|
|
1288
|
-
var
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1166
|
+
var stringifyQuery = (query) => Object.entries(query).flatMap(([key, value]) => {
|
|
1167
|
+
if (value === undefined || value === null)
|
|
1168
|
+
return [];
|
|
1169
|
+
const text = Array.isArray(value) ? value.every((item) => typeof item === "string" || typeof item === "number") ? value.join(",") : JSON.stringify(value) : typeof value === "object" ? JSON.stringify(value) : String(value);
|
|
1170
|
+
return [`${encodeURIComponent(key)}=${encodeURIComponent(text)}`];
|
|
1171
|
+
}).join("&");
|
|
1172
|
+
var isAssetDecided = (asset) => asset.classification.status === "completed" || asset.classification.status === "failed";
|
|
1173
|
+
var DECISION_POLL_FIRST_DELAY_MS = 500;
|
|
1174
|
+
var DECISION_POLL_DELAY_FACTOR = 1.5;
|
|
1175
|
+
var DECISION_POLL_MAX_DELAY_MS = 2000;
|
|
1176
|
+
var DEFAULT_DECISION_TIMEOUT_MS = 60000;
|
|
1177
|
+
var pollForDecision = async (retrieve, {
|
|
1178
|
+
timeoutMs = DEFAULT_DECISION_TIMEOUT_MS,
|
|
1179
|
+
signal
|
|
1180
|
+
}, sleep, now = Date.now) => {
|
|
1181
|
+
if (!Number.isFinite(timeoutMs) || timeoutMs < 0) {
|
|
1182
|
+
throw invalidArgument("timeoutMs must be a non-negative number");
|
|
1183
|
+
}
|
|
1184
|
+
const deadline = now() + timeoutMs;
|
|
1185
|
+
let delay = DECISION_POLL_FIRST_DELAY_MS;
|
|
1186
|
+
for (;; ) {
|
|
1187
|
+
if (signal?.aborted) {
|
|
1188
|
+
throw new CalmLensError(SDK_ERROR_CODES.CANCELLED, { message: "Request cancelled" });
|
|
1189
|
+
}
|
|
1190
|
+
const asset = await retrieve();
|
|
1191
|
+
if (isAssetDecided(asset))
|
|
1192
|
+
return asset;
|
|
1193
|
+
const remaining = deadline - now();
|
|
1194
|
+
if (remaining <= 0) {
|
|
1195
|
+
throw new CalmLensError(SDK_ERROR_CODES.TIMEOUT, {
|
|
1196
|
+
message: `Asset ${asset.id} had no moderation decision after ${timeoutMs}ms (processing ${asset.classification.status}, moderation ${asset.classification.moderation.status})`,
|
|
1197
|
+
details: {
|
|
1198
|
+
assetId: asset.id,
|
|
1199
|
+
classificationStatus: asset.classification.status,
|
|
1200
|
+
moderationStatus: asset.classification.moderation.status
|
|
1201
|
+
}
|
|
1202
|
+
});
|
|
1203
|
+
}
|
|
1204
|
+
await sleep(Math.min(delay, remaining), signal);
|
|
1205
|
+
delay = Math.min(DECISION_POLL_MAX_DELAY_MS, delay * DECISION_POLL_DELAY_FACTOR);
|
|
1292
1206
|
}
|
|
1293
|
-
|
|
1294
|
-
|
|
1207
|
+
};
|
|
1208
|
+
|
|
1209
|
+
// src/client/CalmLensViewerClaims.ts
|
|
1210
|
+
var VIEWER_COUNTRIES = new Set("AD AE AF AG AI AL AM AO AQ AR AS AT AU AW AX AZ BA BB BD BE BF BG BH BI BJ BL BM BN BO BQ BR BS BT BV BW BY BZ CA CC CD CF CG CH CI CK CL CM CN CO CR CU CV CW CX CY CZ DE DJ DK DM DO DZ EC EE EG EH ER ES ET FI FJ FK FM FO FR GA GB GD GE GF GG GH GI GL GM GN GP GQ GR GS GT GU GW GY HK HM HN HR HT HU ID IE IL IM IN IO IQ IR IS IT JE JM JO JP KE KG KH KI KM KN KP KR KW KY KZ LA LB LC LI LK LR LS LT LU LV LY MA MC MD ME MF MG MH MK ML MM MN MO MP MQ MR MS MT MU MV MW MX MY MZ NA NC NE NF NG NI NL NO NP NR NU NZ OM PA PE PF PG PH PK PL PM PN PR PS PT PW PY QA RE RO RS RU RW SA SB SC SD SE SG SH SI SJ SK SL SM SN SO SR SS ST SV SX SY SZ TC TD TF TG TH TJ TK TL TM TN TO TR TT TV TW TZ UA UG UM US UY UZ VA VC VE VG VI VN VU WF WS YE YT ZA ZM ZW".split(" "));
|
|
1211
|
+
var EU_COUNTRIES = new Set("AT BE BG HR CY CZ DK EE FI FR DE GR HU IE IT LV LT LU MT NL PL PT RO SK SI ES SE".split(" "));
|
|
1212
|
+
var parseViewerClaims = (value) => {
|
|
1213
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
1214
|
+
return;
|
|
1215
|
+
const { region, ageConfirmed, ...rest } = value;
|
|
1216
|
+
if (Object.keys(rest).length)
|
|
1217
|
+
return;
|
|
1218
|
+
if (region !== undefined && (typeof region !== "string" || !VIEWER_COUNTRIES.has(region)))
|
|
1219
|
+
return;
|
|
1220
|
+
if (ageConfirmed !== undefined && typeof ageConfirmed !== "boolean")
|
|
1221
|
+
return;
|
|
1222
|
+
return {
|
|
1223
|
+
...region !== undefined && { region },
|
|
1224
|
+
...ageConfirmed !== undefined && { ageConfirmed }
|
|
1225
|
+
};
|
|
1226
|
+
};
|
|
1227
|
+
|
|
1228
|
+
// src/client/CalmLensCdn.ts
|
|
1229
|
+
var ASSET_RESOURCE_PATHS = {
|
|
1230
|
+
original: "original",
|
|
1231
|
+
rendered: "rendered",
|
|
1232
|
+
preview: "preview",
|
|
1233
|
+
placeholder: "placeholder",
|
|
1234
|
+
hls: "hls/index.m3u8",
|
|
1235
|
+
embed: "embed",
|
|
1236
|
+
info: "info"
|
|
1237
|
+
};
|
|
1238
|
+
var EXTERNAL_ID_SEGMENT_PREFIX = "ext:";
|
|
1239
|
+
var CDN_RESOURCES = Object.keys(ASSET_RESOURCE_PATHS);
|
|
1240
|
+
var UNSELECTABLE = new Set([
|
|
1241
|
+
"original",
|
|
1242
|
+
"hls",
|
|
1243
|
+
"embed",
|
|
1244
|
+
"placeholder",
|
|
1245
|
+
"info"
|
|
1246
|
+
]);
|
|
1247
|
+
var DEFAULT_SIGNED_URL_EXPIRES_IN = 60 * 15;
|
|
1248
|
+
var MAX_SIGNED_URL_EXPIRES_IN = 60 * 60 * 24;
|
|
1249
|
+
var getAssetSegment = (options) => {
|
|
1250
|
+
const { assetId, externalId } = options;
|
|
1251
|
+
if (assetId === undefined === (externalId === undefined)) {
|
|
1252
|
+
throw invalidArgument("Pass either assetId or externalId");
|
|
1253
|
+
}
|
|
1254
|
+
if (assetId !== undefined)
|
|
1255
|
+
return encodePathSegment(assetId, "Asset ID");
|
|
1256
|
+
if (typeof externalId !== "string" || !externalId) {
|
|
1257
|
+
throw invalidArgument("External ID is required");
|
|
1258
|
+
}
|
|
1259
|
+
return `${EXTERNAL_ID_SEGMENT_PREFIX}${encodeURIComponent(externalId)}`;
|
|
1260
|
+
};
|
|
1261
|
+
var toUrlViewerClaims = (claims) => {
|
|
1262
|
+
if (claims === undefined)
|
|
1263
|
+
return;
|
|
1264
|
+
const parsed = parseViewerClaims(claims);
|
|
1265
|
+
if (!parsed)
|
|
1266
|
+
throw invalidArgument("Invalid viewerClaims");
|
|
1267
|
+
const { region, ageConfirmed } = parsed;
|
|
1268
|
+
if (!region && ageConfirmed !== true)
|
|
1269
|
+
return;
|
|
1270
|
+
return { ...region ? { region } : {}, ...ageConfirmed === true ? { ageConfirmed } : {} };
|
|
1271
|
+
};
|
|
1272
|
+
var viewerClaimsQuery = (claims) => {
|
|
1273
|
+
const sent = toUrlViewerClaims(claims);
|
|
1274
|
+
return sent ? `?${new URLSearchParams({ viewerClaims: JSON.stringify(sent) })}` : "";
|
|
1275
|
+
};
|
|
1276
|
+
var appendAssetLocation = (assetUrl, location) => {
|
|
1277
|
+
const { resource, lens, transform, viewerClaims } = location;
|
|
1278
|
+
const selected = lens !== undefined || transform !== undefined;
|
|
1279
|
+
let path = assetUrl;
|
|
1280
|
+
if (resource === undefined) {
|
|
1281
|
+
if (selected)
|
|
1282
|
+
throw invalidArgument("A lens or transform needs a resource, such as rendered");
|
|
1283
|
+
} else {
|
|
1284
|
+
if (typeof resource !== "string" || !Object.hasOwn(ASSET_RESOURCE_PATHS, resource)) {
|
|
1285
|
+
throw invalidArgument(`resource must be one of ${CDN_RESOURCES.join(", ")}`);
|
|
1286
|
+
}
|
|
1287
|
+
if (UNSELECTABLE.has(resource) && selected) {
|
|
1288
|
+
throw invalidArgument(`The ${resource} resource takes no lens or transform`);
|
|
1289
|
+
}
|
|
1290
|
+
path = `${assetUrl}/${ASSET_RESOURCE_PATHS[resource]}`;
|
|
1291
|
+
const selector = transformSelector(transform);
|
|
1292
|
+
const parts = [
|
|
1293
|
+
...lens !== undefined ? [`@${encodePathSegment(lens, "Lens")}`] : [],
|
|
1294
|
+
...selector ? [typeof transform === "string" ? encodeURI(selector) : selector] : []
|
|
1295
|
+
];
|
|
1296
|
+
if (parts.length)
|
|
1297
|
+
path = `${path}/${parts.join(",")}`;
|
|
1298
|
+
}
|
|
1299
|
+
return `${path}${viewerClaimsQuery(viewerClaims)}`;
|
|
1300
|
+
};
|
|
1301
|
+
var buildAssetUrl = (cdnBaseUrl, projectId, options) => {
|
|
1302
|
+
const { assetId, externalId, resource, lens, transform, viewerClaims } = options;
|
|
1303
|
+
const base = `${cdnBaseUrl.replace(/\/+$/, "")}/assets/${encodePathSegment(projectId, "Project ID")}/${getAssetSegment({ assetId, externalId })}`;
|
|
1304
|
+
return appendAssetLocation(base, { resource, lens, transform, viewerClaims });
|
|
1305
|
+
};
|
|
1306
|
+
var validateSignAssetUrlOptions = (options) => {
|
|
1307
|
+
const { expiresIn, original } = options;
|
|
1308
|
+
if (expiresIn !== undefined && (!Number.isInteger(expiresIn) || expiresIn < 1 || expiresIn > MAX_SIGNED_URL_EXPIRES_IN)) {
|
|
1309
|
+
throw invalidArgument(`expiresIn must be a whole number from 1 to ${MAX_SIGNED_URL_EXPIRES_IN}`);
|
|
1295
1310
|
}
|
|
1296
|
-
if (
|
|
1297
|
-
throw invalidArgument("
|
|
1311
|
+
if (original !== undefined && typeof original !== "boolean") {
|
|
1312
|
+
throw invalidArgument("original must be a boolean");
|
|
1298
1313
|
}
|
|
1314
|
+
getAssetSegment(options);
|
|
1315
|
+
appendAssetLocation("", options);
|
|
1299
1316
|
};
|
|
1300
|
-
var
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1317
|
+
var splitAssetUrl = (url) => {
|
|
1318
|
+
const [path = "", query] = url.split("?", 2);
|
|
1319
|
+
const base = path.replace(/\/+$/, "");
|
|
1320
|
+
const raw = query ? new URLSearchParams(query).get("viewerClaims") : null;
|
|
1321
|
+
if (raw === null)
|
|
1322
|
+
return { base };
|
|
1323
|
+
try {
|
|
1324
|
+
return { base, claims: JSON.parse(raw) };
|
|
1325
|
+
} catch {
|
|
1326
|
+
throw invalidArgument("The asset URL's viewerClaims are not JSON");
|
|
1309
1327
|
}
|
|
1310
|
-
|
|
1311
|
-
|
|
1328
|
+
};
|
|
1329
|
+
var isAssetInfo = (value) => {
|
|
1330
|
+
if (!value || typeof value !== "object")
|
|
1331
|
+
return false;
|
|
1332
|
+
const info = value;
|
|
1333
|
+
return typeof info.id === "string" && typeof info.projectId === "string" && typeof info.type === "string" && !!info.content && typeof info.content === "object" && (info.availability === "available" || info.availability === "age-restricted" || info.availability === "unavailable");
|
|
1334
|
+
};
|
|
1335
|
+
var getAssetInfo = async (url, options = {}) => {
|
|
1336
|
+
if (typeof url !== "string" || !URL.canParse(url)) {
|
|
1337
|
+
throw invalidArgument("url must be an absolute asset URL");
|
|
1338
|
+
}
|
|
1339
|
+
const { base, claims } = splitAssetUrl(url);
|
|
1340
|
+
const infoUrl = `${base}/info${viewerClaimsQuery(options.viewerClaims ?? claims)}`;
|
|
1341
|
+
const fetcher = options.fetch ?? globalThis.fetch;
|
|
1342
|
+
let response;
|
|
1343
|
+
try {
|
|
1344
|
+
response = await fetcher(infoUrl, {
|
|
1345
|
+
headers: { Accept: "application/json" },
|
|
1346
|
+
signal: options.signal
|
|
1347
|
+
});
|
|
1348
|
+
} catch (cause) {
|
|
1349
|
+
if (options.signal?.aborted)
|
|
1350
|
+
throw cause;
|
|
1351
|
+
throw new CalmLensError(SDK_ERROR_CODES.TRANSPORT_ERROR, {
|
|
1352
|
+
message: "The asset's info could not be fetched",
|
|
1353
|
+
cause
|
|
1354
|
+
});
|
|
1312
1355
|
}
|
|
1313
|
-
|
|
1314
|
-
|
|
1356
|
+
const bytes = new Uint8Array(await response.arrayBuffer());
|
|
1357
|
+
if (!response.ok)
|
|
1358
|
+
throw toHttpError(response, bytes);
|
|
1359
|
+
let data;
|
|
1360
|
+
try {
|
|
1361
|
+
data = JSON.parse(new TextDecoder().decode(bytes));
|
|
1362
|
+
} catch {}
|
|
1363
|
+
if (!isAssetInfo(data)) {
|
|
1364
|
+
throw new CalmLensError(SDK_ERROR_CODES.INVALID_RESPONSE, {
|
|
1365
|
+
message: "The CDN returned no asset info",
|
|
1366
|
+
status: response.status
|
|
1367
|
+
});
|
|
1315
1368
|
}
|
|
1316
|
-
|
|
1317
|
-
|
|
1369
|
+
return data;
|
|
1370
|
+
};
|
|
1371
|
+
|
|
1372
|
+
// src/contract/AssetPayload.js
|
|
1373
|
+
var bufferInputToBytes = (value) => {
|
|
1374
|
+
if (value instanceof ArrayBuffer)
|
|
1375
|
+
return new Uint8Array(value);
|
|
1376
|
+
return Uint8Array.from(value);
|
|
1377
|
+
};
|
|
1378
|
+
var BASE64_PART_BOUNDARY_ERROR = "Invalid base64 part. For multipart uploads, split the original bytes first, then base64-encode each part. Do not split one full base64 string into substrings.";
|
|
1379
|
+
var MULTIPART_PART_TOO_SMALL_ERROR = `Multipart upload parts must be at least 5MiB except the final part.`;
|
|
1380
|
+
var getRawBase64 = (value) => {
|
|
1381
|
+
const markerIndex = value.indexOf(";base64,");
|
|
1382
|
+
if (markerIndex === -1)
|
|
1383
|
+
return value;
|
|
1384
|
+
return value.slice(markerIndex + 8);
|
|
1318
1385
|
};
|
|
1319
|
-
var
|
|
1320
|
-
const
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
}
|
|
1328
|
-
return query.size ? `${path}?${query}` : path;
|
|
1386
|
+
var validateBase64PayloadString = (payload, options) => {
|
|
1387
|
+
const raw = getRawBase64(payload.base64).replace(/\s/g, "");
|
|
1388
|
+
if (options?.multipart && raw.length % 4 !== 0)
|
|
1389
|
+
return {
|
|
1390
|
+
ok: false,
|
|
1391
|
+
error: BASE64_PART_BOUNDARY_ERROR
|
|
1392
|
+
};
|
|
1393
|
+
return { ok: true };
|
|
1329
1394
|
};
|
|
1330
|
-
var
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1395
|
+
var assetToData = (payload) => {
|
|
1396
|
+
if ("plainText" in payload && payload.plainText !== undefined)
|
|
1397
|
+
return new TextEncoder().encode(payload.plainText);
|
|
1398
|
+
if ("data" in payload && payload.data)
|
|
1399
|
+
return payload.data;
|
|
1400
|
+
if ("buffer" in payload) {
|
|
1401
|
+
if (payload.buffer instanceof ArrayBuffer)
|
|
1402
|
+
return payload.buffer;
|
|
1403
|
+
return bufferInputToBytes(payload.buffer);
|
|
1404
|
+
}
|
|
1405
|
+
if (payload.uint8Array !== undefined)
|
|
1406
|
+
return Uint8Array.from(payload.uint8Array);
|
|
1407
|
+
if (payload.base64 === undefined)
|
|
1408
|
+
throw new Error("Invalid asset payload");
|
|
1409
|
+
const raw = getRawBase64(payload.base64);
|
|
1410
|
+
if (typeof Buffer !== "undefined")
|
|
1411
|
+
return Uint8Array.from(Buffer.from(raw, "base64"));
|
|
1412
|
+
const binary = atob(raw);
|
|
1413
|
+
return Uint8Array.from(binary, (char) => char.charCodeAt(0));
|
|
1337
1414
|
};
|
|
1338
|
-
var
|
|
1339
|
-
if (
|
|
1340
|
-
return;
|
|
1341
|
-
if (
|
|
1342
|
-
|
|
1343
|
-
|
|
1415
|
+
var getAssetPayloadByteLength = (payload) => {
|
|
1416
|
+
if ("plainText" in payload && payload.plainText !== undefined)
|
|
1417
|
+
return new TextEncoder().encode(payload.plainText).byteLength;
|
|
1418
|
+
if ("data" in payload && payload.data) {
|
|
1419
|
+
if (payload.data instanceof Blob)
|
|
1420
|
+
return payload.data.size;
|
|
1421
|
+
if (payload.data instanceof Response) {
|
|
1422
|
+
const contentLength = payload.data.headers.get("content-length");
|
|
1423
|
+
return contentLength ? Number(contentLength) : undefined;
|
|
1424
|
+
}
|
|
1344
1425
|
return;
|
|
1345
1426
|
}
|
|
1346
|
-
if (
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1427
|
+
if ("buffer" in payload && payload.buffer)
|
|
1428
|
+
return payload.buffer.byteLength;
|
|
1429
|
+
if (payload.uint8Array !== undefined) {
|
|
1430
|
+
if (Array.isArray(payload.uint8Array))
|
|
1431
|
+
return payload.uint8Array.length;
|
|
1432
|
+
return payload.uint8Array.byteLength;
|
|
1433
|
+
}
|
|
1434
|
+
if (payload.base64 === undefined)
|
|
1350
1435
|
return;
|
|
1436
|
+
const raw = getRawBase64(payload.base64).replace(/\s/g, "");
|
|
1437
|
+
const padding = raw.endsWith("==") ? 2 : raw.endsWith("=") ? 1 : 0;
|
|
1438
|
+
return Math.max(0, Math.floor(raw.length * 3 / 4) - padding);
|
|
1439
|
+
};
|
|
1440
|
+
var validateAssetPayload = (payload, options) => {
|
|
1441
|
+
if ("base64" in payload && payload.base64 !== undefined) {
|
|
1442
|
+
const validation = validateBase64PayloadString(payload, options);
|
|
1443
|
+
if (!validation.ok)
|
|
1444
|
+
return {
|
|
1445
|
+
ok: false,
|
|
1446
|
+
error: validation.error
|
|
1447
|
+
};
|
|
1351
1448
|
}
|
|
1352
|
-
|
|
1449
|
+
const byteLength = getAssetPayloadByteLength(payload);
|
|
1450
|
+
if (options?.multipart && !options.isFinal && byteLength !== undefined && byteLength < 5242880)
|
|
1451
|
+
return {
|
|
1452
|
+
ok: false,
|
|
1453
|
+
error: MULTIPART_PART_TOO_SMALL_ERROR
|
|
1454
|
+
};
|
|
1455
|
+
return { ok: true };
|
|
1353
1456
|
};
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1457
|
+
|
|
1458
|
+
// src/contract/Media-B2PMcUf7.js
|
|
1459
|
+
var MAX_MEDIA_UPLOAD_BYTES = 52428800;
|
|
1460
|
+
var MAX_LONG_MEDIA_UPLOAD_BYTES = 2147483648;
|
|
1461
|
+
// src/contract/ModerationContextLimits-BIMUlk2e.js
|
|
1462
|
+
var countModerationContextCharacters = (text) => {
|
|
1463
|
+
let count = 0;
|
|
1464
|
+
for (const _ of text)
|
|
1465
|
+
count++;
|
|
1466
|
+
return count;
|
|
1359
1467
|
};
|
|
1360
|
-
var
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
const deadline = now() + timeoutMs;
|
|
1373
|
-
let delay = DECISION_POLL_FIRST_DELAY_MS;
|
|
1374
|
-
for (;; ) {
|
|
1375
|
-
if (signal?.aborted) {
|
|
1376
|
-
throw new CalmLensError(SDK_ERROR_CODES.CANCELLED, { message: "Request cancelled" });
|
|
1377
|
-
}
|
|
1378
|
-
const asset = await retrieve();
|
|
1379
|
-
if (isAssetDecided(asset))
|
|
1380
|
-
return asset;
|
|
1381
|
-
const remaining = deadline - now();
|
|
1382
|
-
if (remaining <= 0) {
|
|
1383
|
-
throw new CalmLensError(SDK_ERROR_CODES.TIMEOUT, {
|
|
1384
|
-
message: `Asset ${asset.id} had no moderation decision after ${timeoutMs}ms (processing ${asset.classification.status}, moderation ${asset.classification.moderation.status})`,
|
|
1385
|
-
details: {
|
|
1386
|
-
assetId: asset.id,
|
|
1387
|
-
classificationStatus: asset.classification.status,
|
|
1388
|
-
moderationStatus: asset.classification.moderation.status
|
|
1389
|
-
}
|
|
1390
|
-
});
|
|
1391
|
-
}
|
|
1392
|
-
await sleep(Math.min(delay, remaining), signal);
|
|
1393
|
-
delay = Math.min(DECISION_POLL_MAX_DELAY_MS, delay * DECISION_POLL_DELAY_FACTOR);
|
|
1468
|
+
var selectModerationContextItems = (items) => {
|
|
1469
|
+
const selected = [];
|
|
1470
|
+
let characters = 0;
|
|
1471
|
+
for (let index = items.length - 1;index >= 0; index--) {
|
|
1472
|
+
if (selected.length === 5)
|
|
1473
|
+
break;
|
|
1474
|
+
const item = items[index];
|
|
1475
|
+
const length = countModerationContextCharacters(item.text);
|
|
1476
|
+
if (selected.length && characters + length > 2000)
|
|
1477
|
+
break;
|
|
1478
|
+
selected.unshift(item);
|
|
1479
|
+
characters += length;
|
|
1394
1480
|
}
|
|
1481
|
+
return selected;
|
|
1395
1482
|
};
|
|
1396
|
-
|
|
1397
1483
|
// src/client/CalmLensConnection.ts
|
|
1398
1484
|
var DEFAULT_TIMEOUT_MS = 120000;
|
|
1399
1485
|
var MOCK_HOOKS = Symbol.for("@calmlens/sdk.mockHooks");
|
|
@@ -1458,9 +1544,9 @@ var setOptionalQueryValue = (params, key, value) => {
|
|
|
1458
1544
|
};
|
|
1459
1545
|
var assertValidUploadMimeType = (mimeType) => {
|
|
1460
1546
|
if (!isAcceptedUploadMimeType(mimeType)) {
|
|
1461
|
-
throw new CalmLensError(API_ERROR_CODES.
|
|
1547
|
+
throw new CalmLensError(API_ERROR_CODES.UNSUPPORTED_UPLOAD_TYPE, {
|
|
1462
1548
|
message: getRejectedUploadMimeTypeError(mimeType),
|
|
1463
|
-
details: { mimeType }
|
|
1549
|
+
details: { mimeType, source: "calmlens" }
|
|
1464
1550
|
});
|
|
1465
1551
|
}
|
|
1466
1552
|
};
|
|
@@ -1475,17 +1561,23 @@ var assertDeclaredPayloadSize = (payload, declared = payload.sizeInBytes) => {
|
|
|
1475
1561
|
throw invalidPayload("sizeInBytes must match the payload byte length");
|
|
1476
1562
|
}
|
|
1477
1563
|
};
|
|
1478
|
-
var
|
|
1479
|
-
const size = content.sizeInBytes ?? getAssetPayloadByteLength(content);
|
|
1564
|
+
var assertUploadSize = (type, size, inParts) => {
|
|
1480
1565
|
if (size === undefined)
|
|
1481
1566
|
return;
|
|
1482
|
-
const
|
|
1483
|
-
const [limit, message] =
|
|
1567
|
+
const mime = type.toLowerCase();
|
|
1568
|
+
const [limit, message] = mime.startsWith("image/") ? [
|
|
1484
1569
|
MAX_DIRECT_IMAGE_UPLOAD_BYTES,
|
|
1485
1570
|
"Images uploaded in one request can be at most 10 MiB; upload larger images in parts"
|
|
1486
|
-
] :
|
|
1487
|
-
|
|
1488
|
-
|
|
1571
|
+
] : mime.startsWith("audio/") || mime.startsWith("video/") ? [
|
|
1572
|
+
inParts ? MAX_LONG_MEDIA_UPLOAD_BYTES : MAX_MEDIA_UPLOAD_BYTES,
|
|
1573
|
+
"Audio and video files can be at most 50 MiB in one request, or 2 GiB in parts"
|
|
1574
|
+
] : [MAX_NON_IMAGE_UPLOAD_BYTES, "Files can be at most 5,000 MiB"];
|
|
1575
|
+
if (size > limit) {
|
|
1576
|
+
throw new CalmLensError(API_ERROR_CODES.UPLOAD_TOO_LARGE, {
|
|
1577
|
+
message,
|
|
1578
|
+
details: { limitBytes: limit, source: "plan" }
|
|
1579
|
+
});
|
|
1580
|
+
}
|
|
1489
1581
|
};
|
|
1490
1582
|
var prepareSubmitAssetOptions = (options, {
|
|
1491
1583
|
deferUploadChecks = false,
|
|
@@ -1517,12 +1609,14 @@ var prepareSubmitAssetOptions = (options, {
|
|
|
1517
1609
|
}
|
|
1518
1610
|
if (!deferUploadChecks && inParts && isImageMimeType(options.content.type)) {
|
|
1519
1611
|
if ((getAssetPayloadByteLength(options.content) ?? 0) > MAX_IMAGE_UPLOAD_BYTES) {
|
|
1520
|
-
throw new CalmLensError(API_ERROR_CODES.
|
|
1521
|
-
message: "Multipart image uploads cannot exceed
|
|
1612
|
+
throw new CalmLensError(API_ERROR_CODES.UPLOAD_TOO_LARGE, {
|
|
1613
|
+
message: "Multipart image uploads cannot exceed 20 MiB.",
|
|
1614
|
+
details: { limitBytes: MAX_IMAGE_UPLOAD_BYTES, source: "plan" }
|
|
1522
1615
|
});
|
|
1523
1616
|
}
|
|
1524
|
-
} else if (!deferUploadChecks)
|
|
1525
|
-
|
|
1617
|
+
} else if (!deferUploadChecks) {
|
|
1618
|
+
assertUploadSize(options.content.type, options.content.sizeInBytes ?? getAssetPayloadByteLength(options.content), inParts);
|
|
1619
|
+
}
|
|
1526
1620
|
if (!("plainText" in options.content)) {
|
|
1527
1621
|
const validation = validateAssetPayload(options.content);
|
|
1528
1622
|
if (!validation.ok)
|
|
@@ -1535,11 +1629,15 @@ var prepareSubmitAssetOptions = (options, {
|
|
|
1535
1629
|
const partSizeInBytes = options.part.sizeInBytes ?? getAssetPayloadByteLength(options.part);
|
|
1536
1630
|
if (!deferUploadChecks && isImageMimeType(options.part.type) && partSizeInBytes !== undefined) {
|
|
1537
1631
|
if (partSizeInBytes > MAX_IMAGE_UPLOAD_BYTES) {
|
|
1538
|
-
throw new CalmLensError(API_ERROR_CODES.
|
|
1539
|
-
message: "Multipart image uploads cannot exceed
|
|
1632
|
+
throw new CalmLensError(API_ERROR_CODES.UPLOAD_TOO_LARGE, {
|
|
1633
|
+
message: "Multipart image uploads cannot exceed 20 MiB.",
|
|
1634
|
+
details: { limitBytes: MAX_IMAGE_UPLOAD_BYTES, source: "plan" }
|
|
1540
1635
|
});
|
|
1541
1636
|
}
|
|
1542
1637
|
}
|
|
1638
|
+
if (!deferUploadChecks && !isImageMimeType(options.part.type)) {
|
|
1639
|
+
assertUploadSize(options.part.type, options.totalSizeInBytes, true);
|
|
1640
|
+
}
|
|
1543
1641
|
const validation = validateAssetPayload(options.part, {
|
|
1544
1642
|
multipart: true,
|
|
1545
1643
|
isFinal: deferUploadChecks || options.part.isFinal
|
|
@@ -1559,7 +1657,7 @@ var newIdempotencyKey = () => randomUuid();
|
|
|
1559
1657
|
var isTextPayload = (payload) => ("plainText" in payload);
|
|
1560
1658
|
var hasStringStatus = (value) => !!value && typeof value === "object" && typeof value.status === "string";
|
|
1561
1659
|
var isAsset = (data) => !!data && typeof data === "object" && typeof data.id === "string" && !!data.id && hasStringStatus(data.classification) && hasStringStatus(data.upload) && typeof data.classification?.moderation?.status === "string";
|
|
1562
|
-
var isUploadedAsset = (data) => !!data && typeof data === "object" && typeof data.id === "string" && !!data.id;
|
|
1660
|
+
var isUploadedAsset = (data) => !!data && typeof data === "object" && typeof data.id === "string" && !!data.id && hasStringStatus(data.classification) && hasStringStatus(data.upload);
|
|
1563
1661
|
var expectUploadedAsset = (data) => {
|
|
1564
1662
|
if (!isUploadedAsset(data)) {
|
|
1565
1663
|
throw new CalmLensError(SDK_ERROR_CODES.INVALID_RESPONSE, {
|
|
@@ -1649,14 +1747,15 @@ class CalmLensConnection {
|
|
|
1649
1747
|
fetch: this.options.uploadFetch
|
|
1650
1748
|
});
|
|
1651
1749
|
}
|
|
1652
|
-
submitRawUpload(uploadsPath, options,
|
|
1750
|
+
submitRawUpload(uploadsPath, options, wait, authHeaders = {}) {
|
|
1653
1751
|
const query = new URLSearchParams;
|
|
1654
1752
|
query.set("name", options.name);
|
|
1655
|
-
query.set("
|
|
1753
|
+
query.set("wait", String(wait));
|
|
1656
1754
|
setOptionalQueryValue(query, "description", options.description);
|
|
1657
1755
|
setOptionalQueryValue(query, "processingOptions", options.processingOptions);
|
|
1658
1756
|
setOptionalQueryValue(query, "visibility", options.visibility);
|
|
1659
1757
|
setOptionalQueryValue(query, "metadata", options.metadata);
|
|
1758
|
+
setOptionalQueryValue(query, "tags", options.tags);
|
|
1660
1759
|
setOptionalQueryValue(query, "authorId", options.authorId);
|
|
1661
1760
|
setOptionalQueryValue(query, "context", options.context);
|
|
1662
1761
|
setOptionalQueryValue(query, "externalId", options.externalId);
|
|
@@ -1684,7 +1783,7 @@ class CalmLensConnection {
|
|
|
1684
1783
|
get partSizeBytes() {
|
|
1685
1784
|
return this.options.partSizeBytes ?? DEFAULT_PART_SIZE_BYTES;
|
|
1686
1785
|
}
|
|
1687
|
-
async submitInParts(uploadsPath, options,
|
|
1786
|
+
async submitInParts(uploadsPath, options, wait, {
|
|
1688
1787
|
authHeaders = {},
|
|
1689
1788
|
partPath,
|
|
1690
1789
|
onStarted,
|
|
@@ -1701,7 +1800,7 @@ class CalmLensConnection {
|
|
|
1701
1800
|
part: { ...part(1), type: content.type, partNumber: 1, isFinal: false },
|
|
1702
1801
|
totalSizeInBytes: source.size,
|
|
1703
1802
|
idempotencyKey: key
|
|
1704
|
-
},
|
|
1803
|
+
}, wait, authHeaders);
|
|
1705
1804
|
const assetId = expectUploadedAsset(first).id;
|
|
1706
1805
|
onStarted?.(assetId);
|
|
1707
1806
|
let result = first;
|
|
@@ -1728,7 +1827,7 @@ class CalmLensConnection {
|
|
|
1728
1827
|
}
|
|
1729
1828
|
return result;
|
|
1730
1829
|
}
|
|
1731
|
-
uploadPart(partPath, { part,
|
|
1830
|
+
uploadPart(partPath, { part, wait, idempotencyKey }, authHeaders = {}) {
|
|
1732
1831
|
if (!part)
|
|
1733
1832
|
throw invalidArgument("Part options are required");
|
|
1734
1833
|
assertDeclaredPayloadSize(part);
|
|
@@ -1742,8 +1841,8 @@ class CalmLensConnection {
|
|
|
1742
1841
|
partNumber: String(part.partNumber),
|
|
1743
1842
|
isFinal: String(part.isFinal ?? false)
|
|
1744
1843
|
});
|
|
1745
|
-
if (
|
|
1746
|
-
query.set("
|
|
1844
|
+
if (wait !== undefined)
|
|
1845
|
+
query.set("wait", String(wait));
|
|
1747
1846
|
setOptionalQueryValue(query, "sizeInBytes", part.sizeInBytes ?? getAssetPayloadByteLength(part));
|
|
1748
1847
|
return this.upload(this.url(`${partPath}?${query}`), part, { ...authHeaders, "X-CalmLens-Upload": "part" }, idempotencyKey ?? newIdempotencyKey());
|
|
1749
1848
|
}
|
|
@@ -1752,56 +1851,70 @@ class CalmLensConnection {
|
|
|
1752
1851
|
// src/client/CalmLensOptionKeys.ts
|
|
1753
1852
|
var SERVER_OPTION_KEYS = {
|
|
1754
1853
|
"assets.batch": ["assetIds", "operation"],
|
|
1755
|
-
"assets.classify": ["authorId", "content", "context", "description", "externalId", "externalUrl", "folderId", "isFinal", "metadata", "name", "part", "processingOptions", "sizeInBytes", "totalSizeInBytes", "uploadPresetId", "url", "visibility"],
|
|
1756
|
-
"assets.create": ["authorId", "content", "context", "description", "externalId", "externalUrl", "folderId", "isFinal", "metadata", "name", "part", "processingOptions", "sizeInBytes", "totalSizeInBytes", "uploadPresetId", "url", "visibility"],
|
|
1757
|
-
"assets.createSignedUrl": ["assetId", "expiresInSeconds", "lens", "resource", "transform", "viewerClaims"],
|
|
1854
|
+
"assets.classify": ["authorId", "content", "context", "description", "externalId", "externalUrl", "folderId", "isFinal", "metadata", "name", "part", "processingOptions", "sizeInBytes", "tags", "totalSizeInBytes", "uploadPresetId", "url", "visibility"],
|
|
1855
|
+
"assets.create": ["authorId", "content", "context", "description", "externalId", "externalUrl", "folderId", "isFinal", "metadata", "name", "part", "processingOptions", "sizeInBytes", "tags", "totalSizeInBytes", "uploadPresetId", "url", "visibility"],
|
|
1758
1856
|
"assets.decide": ["assetId", "confirmPurge", "decision", "note"],
|
|
1759
1857
|
"assets.delete": ["assetId"],
|
|
1760
|
-
"assets.deleteContent": ["assetId"],
|
|
1761
1858
|
"assets.explain": ["assetId", "rerun"],
|
|
1762
|
-
"assets.iterate": ["cursor", "filter", "
|
|
1763
|
-
"assets.iterateChildren": ["assetId", "cursor", "
|
|
1764
|
-
"assets.
|
|
1765
|
-
"assets.
|
|
1859
|
+
"assets.iterate": ["cursor", "filter", "pageSize", "sort"],
|
|
1860
|
+
"assets.iterateChildren": ["assetId", "cursor", "pageSize", "sort"],
|
|
1861
|
+
"assets.iterateTimeline": ["assetId", "cursor", "pageSize"],
|
|
1862
|
+
"assets.list": ["cursor", "filter", "pageSize", "sort"],
|
|
1863
|
+
"assets.listChildren": ["assetId", "cursor", "pageSize", "sort"],
|
|
1864
|
+
"assets.listTimeline": ["assetId", "cursor", "pageSize"],
|
|
1766
1865
|
"assets.move": ["assetId", "folderId"],
|
|
1866
|
+
"assets.removeContent": ["assetId"],
|
|
1767
1867
|
"assets.retrieve": ["assetId"],
|
|
1768
1868
|
"assets.retry": ["assetId"],
|
|
1769
|
-
"assets.search": ["
|
|
1869
|
+
"assets.search": ["mode", "pageSize", "query"],
|
|
1770
1870
|
"assets.update": ["assetId", "description", "externalId", "externalUrl", "metadata", "name", "tags", "visibility"],
|
|
1771
|
-
"assets.uploadPart": ["assetId", "part", "
|
|
1772
|
-
|
|
1871
|
+
"assets.uploadPart": ["assetId", "part", "wait"],
|
|
1872
|
+
"cdn.signAssetUrl": ["assetId", "expiresIn", "externalId", "lens", "original", "projectId", "resource", "transform", "viewerClaims"],
|
|
1873
|
+
ensureLens: ["active", "description", "identifier", "name", "transform", "type"],
|
|
1773
1874
|
ensureLenses: ["lenses"],
|
|
1774
|
-
"events.list": ["cursor", "pageSize"],
|
|
1775
|
-
"events.pages": ["cursor", "pageSize"],
|
|
1875
|
+
"events.list": ["assetId", "cursor", "pageSize", "types"],
|
|
1876
|
+
"events.pages": ["assetId", "cursor", "pageSize", "types"],
|
|
1776
1877
|
"folders.create": ["name", "parentId"],
|
|
1777
1878
|
"folders.delete": ["folderId"],
|
|
1778
|
-
"folders.
|
|
1879
|
+
"folders.iterate": ["cursor", "pageSize", "parentId", "search", "sort"],
|
|
1880
|
+
"folders.list": ["cursor", "pageSize", "parentId", "search", "sort"],
|
|
1779
1881
|
"folders.move": ["folderId", "parentId"],
|
|
1780
1882
|
"folders.retrieve": ["folderId"],
|
|
1781
1883
|
"folders.update": ["folderId", "name"],
|
|
1782
1884
|
"hashLists.addEntry": ["assetId", "hash", "hashListId", "label", "quality"],
|
|
1783
1885
|
"hashLists.create": ["action", "description", "name"],
|
|
1784
1886
|
"hashLists.delete": ["hashListId"],
|
|
1785
|
-
"hashLists.
|
|
1786
|
-
"hashLists.
|
|
1887
|
+
"hashLists.iterate": ["cursor", "pageSize", "sort"],
|
|
1888
|
+
"hashLists.iterateEntries": ["cursor", "hashListId", "pageSize", "sort"],
|
|
1889
|
+
"hashLists.list": ["cursor", "pageSize", "sort"],
|
|
1890
|
+
"hashLists.listEntries": ["cursor", "hashListId", "pageSize", "sort"],
|
|
1787
1891
|
"hashLists.removeEntry": ["entryId"],
|
|
1788
1892
|
"hashLists.retrieve": ["hashListId"],
|
|
1789
1893
|
"hashLists.update": ["action", "description", "hashListId", "name"],
|
|
1790
|
-
"
|
|
1894
|
+
"lenses.create": ["active", "description", "identifier", "name", "transform", "type"],
|
|
1895
|
+
"lenses.delete": ["lensId"],
|
|
1896
|
+
"lenses.iterate": ["cursor", "pageSize", "sort"],
|
|
1897
|
+
"lenses.list": ["cursor", "pageSize", "sort"],
|
|
1898
|
+
"lenses.retrieve": ["lensId"],
|
|
1899
|
+
"lenses.update": ["active", "description", "lensId", "name", "transform", "type"],
|
|
1791
1900
|
"policies.assign": ["policyId"],
|
|
1792
1901
|
"policies.create": ["description", "name", "presetId", "settings"],
|
|
1793
1902
|
"policies.delete": ["policyId"],
|
|
1794
|
-
"policies.
|
|
1903
|
+
"policies.iterate": ["cursor", "pageSize", "sort"],
|
|
1904
|
+
"policies.list": ["cursor", "pageSize", "sort"],
|
|
1905
|
+
"policies.reset": ["policyId", "presetVersion", "revision"],
|
|
1795
1906
|
"policies.retrieve": ["policyId"],
|
|
1907
|
+
"policies.retrieveAssigned": [],
|
|
1796
1908
|
"policies.setAutomaticUpdates": ["enabled", "policyId", "presetVersion", "revision"],
|
|
1797
1909
|
"policies.update": ["description", "name", "policyId", "revision", "settings"],
|
|
1798
|
-
"
|
|
1910
|
+
"policies.upgrade": ["policyId", "presetVersion", "revision"],
|
|
1911
|
+
"text.classify": ["authorId", "context", "description", "externalId", "externalUrl", "folderId", "metadata", "name", "processingOptions", "tags", "text", "uploadPresetId", "visibility"]
|
|
1799
1912
|
};
|
|
1800
1913
|
var NULLABLE_OPTION_KEYS = {
|
|
1801
|
-
"assets.classify": ["authorId", "context", "description", "externalId", "folderId", "metadata", "processingOptions", "uploadPresetId", "visibility"],
|
|
1802
|
-
"assets.create": ["authorId", "context", "description", "externalId", "folderId", "metadata", "processingOptions", "uploadPresetId", "visibility"],
|
|
1803
|
-
"assets.iterate": ["filter"
|
|
1804
|
-
"assets.list": ["filter"
|
|
1914
|
+
"assets.classify": ["authorId", "context", "description", "externalId", "folderId", "metadata", "processingOptions", "tags", "uploadPresetId", "visibility"],
|
|
1915
|
+
"assets.create": ["authorId", "context", "description", "externalId", "folderId", "metadata", "processingOptions", "tags", "uploadPresetId", "visibility"],
|
|
1916
|
+
"assets.iterate": ["filter"],
|
|
1917
|
+
"assets.list": ["filter"],
|
|
1805
1918
|
"assets.move": ["folderId"],
|
|
1806
1919
|
"assets.update": ["description", "externalId", "externalUrl", "metadata", "tags", "visibility"],
|
|
1807
1920
|
"folders.create": ["parentId"],
|
|
@@ -1809,7 +1922,9 @@ var NULLABLE_OPTION_KEYS = {
|
|
|
1809
1922
|
"hashLists.addEntry": ["label", "quality"],
|
|
1810
1923
|
"hashLists.create": ["description"],
|
|
1811
1924
|
"hashLists.update": ["description"],
|
|
1812
|
-
"
|
|
1925
|
+
"lenses.create": ["description", "transform"],
|
|
1926
|
+
"lenses.update": ["description", "transform"],
|
|
1927
|
+
"text.classify": ["authorId", "context", "description", "externalId", "folderId", "metadata", "processingOptions", "tags", "uploadPresetId", "visibility"]
|
|
1813
1928
|
};
|
|
1814
1929
|
|
|
1815
1930
|
// src/contract/CryptoUtils-B_x8lMIx.js
|
|
@@ -1850,19 +1965,15 @@ var signUploadToken = async (claims, apiKey) => {
|
|
|
1850
1965
|
var signUploadTokenWithApiKey = async (apiKey, options, { now = Date.now(), nonce = crypto.randomUUID() } = {}) => {
|
|
1851
1966
|
if (!options || typeof options !== "object")
|
|
1852
1967
|
throw invalidArgument("Options are required");
|
|
1853
|
-
const {
|
|
1854
|
-
uploadPresetId,
|
|
1855
|
-
externalId,
|
|
1856
|
-
expiresInSeconds = UPLOAD_TOKEN_DEFAULT_TTL_SECONDS
|
|
1857
|
-
} = options;
|
|
1968
|
+
const { uploadPresetId, externalId, expiresIn = UPLOAD_TOKEN_DEFAULT_TTL_SECONDS } = options;
|
|
1858
1969
|
encodePathSegment(uploadPresetId, "Upload preset ID");
|
|
1859
|
-
if (!Number.isInteger(
|
|
1860
|
-
throw invalidArgument(`
|
|
1970
|
+
if (!Number.isInteger(expiresIn) || expiresIn < 1 || expiresIn > UPLOAD_TOKEN_MAX_TTL_SECONDS) {
|
|
1971
|
+
throw invalidArgument(`expiresIn must be a whole number from 1 to ${UPLOAD_TOKEN_MAX_TTL_SECONDS}`);
|
|
1861
1972
|
}
|
|
1862
1973
|
if (externalId !== undefined && (typeof externalId !== "string" || !externalId)) {
|
|
1863
1974
|
throw invalidArgument("externalId must be a non-empty string");
|
|
1864
1975
|
}
|
|
1865
|
-
const expiresAt = now +
|
|
1976
|
+
const expiresAt = now + expiresIn * 1000;
|
|
1866
1977
|
const token = await signUploadToken({
|
|
1867
1978
|
v: 1,
|
|
1868
1979
|
u: uploadPresetId,
|
|
@@ -1937,8 +2048,7 @@ var getEnsureLensCacheKey = (options) => stringifyJsonCanonical({
|
|
|
1937
2048
|
description: options.description ?? null,
|
|
1938
2049
|
type: options.type,
|
|
1939
2050
|
active: options.active,
|
|
1940
|
-
transform: options.transform ?? null
|
|
1941
|
-
version: options.version
|
|
2051
|
+
transform: options.transform ?? null
|
|
1942
2052
|
});
|
|
1943
2053
|
var requireId = (value, name) => encodePathSegment(value, name);
|
|
1944
2054
|
var checked = (operation, options) => {
|
|
@@ -1999,24 +2109,24 @@ class CalmLensServerClient {
|
|
|
1999
2109
|
request(method, path, options = {}) {
|
|
2000
2110
|
return this.#connection.json(method, path, options);
|
|
2001
2111
|
}
|
|
2002
|
-
async submitAsset(options,
|
|
2112
|
+
async submitAsset(options, wait) {
|
|
2003
2113
|
const body = prepareSubmitAssetOptions(options, {
|
|
2004
2114
|
deferUploadChecks: this.#connection.deferUploadChecks,
|
|
2005
2115
|
partSizeBytes: this.#connection.partSizeBytes
|
|
2006
2116
|
});
|
|
2007
2117
|
const uploadsPath = `${this.projectPath}/assets`;
|
|
2008
2118
|
if ("content" in body && splitsIntoParts(body.content, this.#connection.partSizeBytes)) {
|
|
2009
|
-
return expectAsset(await this.#connection.submitInParts(uploadsPath, body,
|
|
2119
|
+
return expectAsset(await this.#connection.submitInParts(uploadsPath, body, wait, {
|
|
2010
2120
|
partPath: (assetId) => `/assets/${encodeURIComponent(assetId)}/part`,
|
|
2011
2121
|
retrieve: (assetId) => this.buildAssets().retrieve({ assetId })
|
|
2012
2122
|
}));
|
|
2013
2123
|
}
|
|
2014
2124
|
if ("content" in body || "part" in body) {
|
|
2015
|
-
return expectAsset(await this.#connection.submitRawUpload(uploadsPath, body,
|
|
2125
|
+
return expectAsset(await this.#connection.submitRawUpload(uploadsPath, body, wait));
|
|
2016
2126
|
}
|
|
2017
2127
|
const { idempotencyKey, ...fields } = body;
|
|
2018
2128
|
const data = await this.#connection.json("POST", uploadsPath, {
|
|
2019
|
-
query: {
|
|
2129
|
+
query: { wait },
|
|
2020
2130
|
body: fields,
|
|
2021
2131
|
idempotencyKey: idempotencyKey ?? newIdempotencyKey()
|
|
2022
2132
|
});
|
|
@@ -2025,13 +2135,32 @@ class CalmLensServerClient {
|
|
|
2025
2135
|
get cdn() {
|
|
2026
2136
|
return {
|
|
2027
2137
|
getAssetUrl: (urlOptions) => {
|
|
2028
|
-
const {
|
|
2029
|
-
|
|
2030
|
-
return getAssetUrl({ projectId, cdnBaseUrl, assetIdentifier, ...options });
|
|
2138
|
+
const { projectId, ...options } = checked("cdn.getAssetUrl", urlOptions);
|
|
2139
|
+
return buildAssetUrl(this.#settings.cdnBaseUrl, projectId ?? this.#settings.projectId, options);
|
|
2031
2140
|
},
|
|
2141
|
+
signAssetUrl: async (signOptions) => {
|
|
2142
|
+
const options = checked("cdn.signAssetUrl", signOptions);
|
|
2143
|
+
validateSignAssetUrlOptions(options);
|
|
2144
|
+
const { projectId, assetId, externalId, expiresIn, original, ...location } = options;
|
|
2145
|
+
const project = requireId(projectId ?? this.#settings.projectId, "Project ID");
|
|
2146
|
+
const signed = await this.request("POST", `/projects/${project}/signed-asset-urls`, {
|
|
2147
|
+
body: {
|
|
2148
|
+
...assetId !== undefined ? { assetId } : { externalId },
|
|
2149
|
+
expiresIn: expiresIn ?? DEFAULT_SIGNED_URL_EXPIRES_IN,
|
|
2150
|
+
original: original ?? false
|
|
2151
|
+
}
|
|
2152
|
+
});
|
|
2153
|
+
if (!signed || typeof signed.url !== "string" || !signed.url || typeof signed.expiresAt !== "number") {
|
|
2154
|
+
throw new CalmLensError(SDK_ERROR_CODES.INVALID_RESPONSE, {
|
|
2155
|
+
message: "The API returned no signed asset URL"
|
|
2156
|
+
});
|
|
2157
|
+
}
|
|
2158
|
+
return { url: appendAssetLocation(signed.url, location), expiresAt: signed.expiresAt };
|
|
2159
|
+
},
|
|
2160
|
+
getAssetInfo: (url, options = {}) => getAssetInfo(url, { ...options, fetch: this.#settings.cdnFetch }),
|
|
2032
2161
|
serve: async (options) => {
|
|
2033
|
-
const {
|
|
2034
|
-
const url = this.cdn.getAssetUrl({
|
|
2162
|
+
const { init, resource = "rendered", ...urlOptions } = checked("cdn.serve", options);
|
|
2163
|
+
const url = this.cdn.getAssetUrl({ ...urlOptions, resource });
|
|
2035
2164
|
const method = init?.method?.toUpperCase() ?? "GET";
|
|
2036
2165
|
const { response } = await this.#connection.transport.send({
|
|
2037
2166
|
method,
|
|
@@ -2086,38 +2215,36 @@ class CalmLensServerClient {
|
|
|
2086
2215
|
query
|
|
2087
2216
|
});
|
|
2088
2217
|
},
|
|
2218
|
+
listTimeline: async (options) => {
|
|
2219
|
+
const { assetId, ...query } = checked("assets.listTimeline", options);
|
|
2220
|
+
const assetPath = `${this.projectPath}/assets/${requireId(assetId, "Asset ID")}`;
|
|
2221
|
+
return this.request("GET", `${assetPath}/timeline`, {
|
|
2222
|
+
query
|
|
2223
|
+
});
|
|
2224
|
+
},
|
|
2225
|
+
iterateTimeline: (options) => {
|
|
2226
|
+
checked("assets.iterateTimeline", options);
|
|
2227
|
+
requireId(options?.assetId, "Asset ID");
|
|
2228
|
+
return this.iteratePages((cursor) => this.buildAssets().listTimeline({ ...options, cursor }));
|
|
2229
|
+
},
|
|
2089
2230
|
iterateChildren: (options) => {
|
|
2090
2231
|
checked("assets.iterateChildren", options);
|
|
2091
2232
|
requireId(options?.assetId, "Asset ID");
|
|
2092
2233
|
return this.iteratePages((cursor) => this.buildAssets().listChildren({ ...options, cursor }));
|
|
2093
2234
|
},
|
|
2094
|
-
create: async (options) => this.submitAsset(checked("assets.create", options),
|
|
2235
|
+
create: async (options) => this.submitAsset(checked("assets.create", options), false),
|
|
2095
2236
|
classify: async (classifyOptions) => {
|
|
2096
2237
|
const options = checked("assets.classify", classifyOptions);
|
|
2097
2238
|
if (options && "content" in options && "plainText" in options.content && (typeof options.content.plainText !== "string" || !options.content.plainText.trim())) {
|
|
2098
2239
|
throw invalidPayload("Text to classify must be a non-empty string");
|
|
2099
2240
|
}
|
|
2100
|
-
return this.submitAsset(options,
|
|
2241
|
+
return this.submitAsset(options, true);
|
|
2101
2242
|
},
|
|
2102
2243
|
uploadPart: async (partOptions) => {
|
|
2103
2244
|
const { assetId, ...options } = checked("assets.uploadPart", partOptions);
|
|
2104
2245
|
const encodedAssetId = requireId(assetId, "Asset ID");
|
|
2105
2246
|
return expectAsset(await this.#connection.uploadPart(`/assets/${encodedAssetId}/part`, options));
|
|
2106
2247
|
},
|
|
2107
|
-
createSignedUrl: async (signedUrlOptions) => {
|
|
2108
|
-
const { assetId, ...options } = checked("assets.createSignedUrl", signedUrlOptions);
|
|
2109
|
-
const encodedAssetId = requireId(assetId, "Asset ID");
|
|
2110
|
-
validateSignedUrlOptions(options);
|
|
2111
|
-
return this.request("POST", `/assets/${encodedAssetId}/signed-url`, {
|
|
2112
|
-
body: {
|
|
2113
|
-
viewerClaims: options.viewerClaims,
|
|
2114
|
-
resource: options.resource,
|
|
2115
|
-
expiresInSeconds: options.expiresInSeconds ?? DEFAULT_SIGNED_URL_EXPIRES_IN_SECONDS,
|
|
2116
|
-
lens: options.lens,
|
|
2117
|
-
transform: transformSelector(options.transform)
|
|
2118
|
-
}
|
|
2119
|
-
});
|
|
2120
|
-
},
|
|
2121
2248
|
move: async (options) => {
|
|
2122
2249
|
const { assetId, folderId } = checked("assets.move", options);
|
|
2123
2250
|
return this.request("POST", `/assets/${requireId(assetId, "Asset ID")}/move`, {
|
|
@@ -2144,8 +2271,8 @@ class CalmLensServerClient {
|
|
|
2144
2271
|
const client = options.signal ? this.withRequestOptions({ signal: options.signal }) : this;
|
|
2145
2272
|
return pollForDecision(() => client.assets.retrieve({ assetId }), options, this.#connection.sleep, this.#connection.hooks?.now);
|
|
2146
2273
|
},
|
|
2147
|
-
|
|
2148
|
-
const { assetId } = checked("assets.
|
|
2274
|
+
removeContent: async (options) => {
|
|
2275
|
+
const { assetId } = checked("assets.removeContent", options);
|
|
2149
2276
|
return this.request("DELETE", `/assets/${requireId(assetId, "Asset ID")}/content`);
|
|
2150
2277
|
},
|
|
2151
2278
|
delete: async (options) => {
|
|
@@ -2163,9 +2290,12 @@ class CalmLensServerClient {
|
|
|
2163
2290
|
}
|
|
2164
2291
|
get events() {
|
|
2165
2292
|
return {
|
|
2166
|
-
list: async (options = {}) =>
|
|
2167
|
-
|
|
2168
|
-
|
|
2293
|
+
list: async (options = {}) => {
|
|
2294
|
+
const { types, ...query } = checked("events.list", options);
|
|
2295
|
+
return this.request("GET", `${this.projectPath}/events`, {
|
|
2296
|
+
query: { ...query, types: types?.length ? types.join(",") : undefined }
|
|
2297
|
+
});
|
|
2298
|
+
},
|
|
2169
2299
|
pages: (options = {}) => this.iterateEventPages(checked("events.pages", options))
|
|
2170
2300
|
};
|
|
2171
2301
|
}
|
|
@@ -2201,6 +2331,10 @@ class CalmLensServerClient {
|
|
|
2201
2331
|
list: async (options = {}) => this.request("GET", `${this.projectPath}/folders`, {
|
|
2202
2332
|
query: checked("folders.list", options)
|
|
2203
2333
|
}),
|
|
2334
|
+
iterate: (options = {}) => {
|
|
2335
|
+
checked("folders.iterate", options);
|
|
2336
|
+
return this.iteratePages((cursor) => this.folders.list({ ...options, cursor }));
|
|
2337
|
+
},
|
|
2204
2338
|
retrieve: async (options) => {
|
|
2205
2339
|
const { folderId } = checked("folders.retrieve", options);
|
|
2206
2340
|
return this.request("GET", `/folders/${requireId(folderId, "Folder ID")}`);
|
|
@@ -2229,6 +2363,10 @@ class CalmLensServerClient {
|
|
|
2229
2363
|
list: async (options = {}) => this.request("GET", `${this.projectPath}/hash-lists`, {
|
|
2230
2364
|
query: checked("hashLists.list", options)
|
|
2231
2365
|
}),
|
|
2366
|
+
iterate: (options = {}) => {
|
|
2367
|
+
checked("hashLists.iterate", options);
|
|
2368
|
+
return this.iteratePages((cursor) => this.hashLists.list({ ...options, cursor }));
|
|
2369
|
+
},
|
|
2232
2370
|
retrieve: async (options) => {
|
|
2233
2371
|
const { hashListId } = checked("hashLists.retrieve", options);
|
|
2234
2372
|
return this.request("GET", `/hash-lists/${requireId(hashListId, "Hash list ID")}`);
|
|
@@ -2246,6 +2384,11 @@ class CalmLensServerClient {
|
|
|
2246
2384
|
const { hashListId } = checked("hashLists.delete", options);
|
|
2247
2385
|
await this.request("DELETE", `/hash-lists/${requireId(hashListId, "Hash list ID")}`);
|
|
2248
2386
|
},
|
|
2387
|
+
iterateEntries: (options) => {
|
|
2388
|
+
checked("hashLists.iterateEntries", options);
|
|
2389
|
+
requireId(options?.hashListId, "Hash list ID");
|
|
2390
|
+
return this.iteratePages((cursor) => this.hashLists.listEntries({ ...options, cursor }));
|
|
2391
|
+
},
|
|
2249
2392
|
listEntries: async (options) => {
|
|
2250
2393
|
const { hashListId, ...query } = checked("hashLists.listEntries", options);
|
|
2251
2394
|
return this.request("GET", `/hash-lists/${requireId(hashListId, "Hash list ID")}/entries`, {
|
|
@@ -2263,20 +2406,26 @@ class CalmLensServerClient {
|
|
|
2263
2406
|
};
|
|
2264
2407
|
}
|
|
2265
2408
|
get policies() {
|
|
2266
|
-
const policyPath = (policyId) =>
|
|
2409
|
+
const policyPath = (policyId) => `/policies/${requireId(policyId, "Policy ID")}`;
|
|
2267
2410
|
return {
|
|
2268
|
-
list: async () => this.request("GET",
|
|
2411
|
+
list: async (options = {}) => this.request("GET", "/policies", { query: checked("policies.list", options) }),
|
|
2412
|
+
iterate: (options = {}) => {
|
|
2413
|
+
checked("policies.iterate", options);
|
|
2414
|
+
return this.iteratePages((cursor) => this.policies.list({ ...options, cursor }));
|
|
2415
|
+
},
|
|
2269
2416
|
retrieve: async (options) => this.request("GET", policyPath(checked("policies.retrieve", options).policyId)),
|
|
2270
|
-
create: async (options) => this.request("POST",
|
|
2271
|
-
body: checked("policies.create", options)
|
|
2272
|
-
}),
|
|
2417
|
+
create: async (options) => this.request("POST", "/policies", { body: checked("policies.create", options) }),
|
|
2273
2418
|
update: async (options) => {
|
|
2274
2419
|
const { policyId, ...body } = checked("policies.update", options);
|
|
2275
2420
|
return this.request("PATCH", policyPath(policyId), { body });
|
|
2276
2421
|
},
|
|
2277
|
-
|
|
2278
|
-
const { policyId, ...body } = checked("policies.
|
|
2279
|
-
return this.request("POST", `${policyPath(policyId)}/
|
|
2422
|
+
reset: async (options) => {
|
|
2423
|
+
const { policyId, ...body } = checked("policies.reset", options);
|
|
2424
|
+
return this.request("POST", `${policyPath(policyId)}/reset`, { body });
|
|
2425
|
+
},
|
|
2426
|
+
upgrade: async (options) => {
|
|
2427
|
+
const { policyId, ...body } = checked("policies.upgrade", options);
|
|
2428
|
+
return this.request("POST", `${policyPath(policyId)}/upgrade`, { body });
|
|
2280
2429
|
},
|
|
2281
2430
|
setAutomaticUpdates: async (options) => {
|
|
2282
2431
|
const { policyId, ...body } = checked("policies.setAutomaticUpdates", options);
|
|
@@ -2285,11 +2434,48 @@ class CalmLensServerClient {
|
|
|
2285
2434
|
delete: async (options) => {
|
|
2286
2435
|
await this.request("DELETE", policyPath(checked("policies.delete", options).policyId));
|
|
2287
2436
|
},
|
|
2437
|
+
retrieveAssigned: async () => this.request("GET", `${this.projectPath}/policy`),
|
|
2288
2438
|
assign: async (options) => this.request("PUT", `${this.projectPath}/policy`, {
|
|
2289
2439
|
body: checked("policies.assign", options)
|
|
2290
2440
|
})
|
|
2291
2441
|
};
|
|
2292
2442
|
}
|
|
2443
|
+
get lenses() {
|
|
2444
|
+
const lensPath = (lensId) => `/lenses/${requireId(lensId, "Lens ID")}`;
|
|
2445
|
+
const forget = (matches) => {
|
|
2446
|
+
for (const [cacheKey, lens] of this.#lenses.ensuredLenses)
|
|
2447
|
+
if (matches(lens))
|
|
2448
|
+
this.#lenses.ensuredLenses.delete(cacheKey);
|
|
2449
|
+
};
|
|
2450
|
+
return {
|
|
2451
|
+
list: async (options = {}) => this.request("GET", `${this.projectPath}/lenses`, {
|
|
2452
|
+
query: checked("lenses.list", options)
|
|
2453
|
+
}),
|
|
2454
|
+
iterate: (options = {}) => {
|
|
2455
|
+
checked("lenses.iterate", options);
|
|
2456
|
+
return this.iteratePages((cursor) => this.lenses.list({ ...options, cursor }));
|
|
2457
|
+
},
|
|
2458
|
+
create: async (options) => {
|
|
2459
|
+
const lens = await this.request("POST", `${this.projectPath}/lenses`, {
|
|
2460
|
+
body: checked("lenses.create", options)
|
|
2461
|
+
});
|
|
2462
|
+
forget((cached) => cached.identifier === lens.identifier);
|
|
2463
|
+
return lens;
|
|
2464
|
+
},
|
|
2465
|
+
retrieve: async (options) => this.request("GET", lensPath(checked("lenses.retrieve", options).lensId)),
|
|
2466
|
+
update: async (options) => {
|
|
2467
|
+
const { lensId, ...body } = checked("lenses.update", options);
|
|
2468
|
+
const lens = await this.request("PATCH", lensPath(lensId), { body });
|
|
2469
|
+
forget((cached) => cached.id === lens.id);
|
|
2470
|
+
return lens;
|
|
2471
|
+
},
|
|
2472
|
+
delete: async (options) => {
|
|
2473
|
+
const { lensId } = checked("lenses.delete", options);
|
|
2474
|
+
await this.request("DELETE", lensPath(lensId));
|
|
2475
|
+
forget((cached) => cached.id === lensId);
|
|
2476
|
+
}
|
|
2477
|
+
};
|
|
2478
|
+
}
|
|
2293
2479
|
async ensureLens(options) {
|
|
2294
2480
|
checked("ensureLens", options);
|
|
2295
2481
|
if (!options?.identifier)
|
|
@@ -4282,39 +4468,162 @@ function handleIntersectionResults(result, left, right) {
|
|
|
4282
4468
|
} else {
|
|
4283
4469
|
return false;
|
|
4284
4470
|
}
|
|
4285
|
-
for (const k of keys) {
|
|
4286
|
-
if (!unrecKeys.has(k))
|
|
4287
|
-
unrecKeys.set(k, {});
|
|
4288
|
-
unrecKeys.get(k)[side] = true;
|
|
4471
|
+
for (const k of keys) {
|
|
4472
|
+
if (!unrecKeys.has(k))
|
|
4473
|
+
unrecKeys.set(k, {});
|
|
4474
|
+
unrecKeys.get(k)[side] = true;
|
|
4475
|
+
}
|
|
4476
|
+
return true;
|
|
4477
|
+
};
|
|
4478
|
+
for (const iss of left.issues) {
|
|
4479
|
+
if (!collect(iss, "l"))
|
|
4480
|
+
result.issues.push(iss);
|
|
4481
|
+
}
|
|
4482
|
+
for (const iss of right.issues) {
|
|
4483
|
+
if (!collect(iss, "r"))
|
|
4484
|
+
result.issues.push(iss);
|
|
4485
|
+
}
|
|
4486
|
+
const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
|
|
4487
|
+
if (bothKeys.length) {
|
|
4488
|
+
const aggregated = unrecIssue ? bothKeys.filter((k) => unrecIssue.keys.includes(k)) : [];
|
|
4489
|
+
if (aggregated.length)
|
|
4490
|
+
result.issues.push({ ...unrecIssue, keys: aggregated });
|
|
4491
|
+
for (const k of bothKeys) {
|
|
4492
|
+
if (!aggregated.includes(k) && keyIssues.has(k))
|
|
4493
|
+
result.issues.push(keyIssues.get(k));
|
|
4494
|
+
}
|
|
4495
|
+
}
|
|
4496
|
+
const merged = mergeValues(left.value, right.value);
|
|
4497
|
+
if (!merged.valid) {
|
|
4498
|
+
if (aborted(result))
|
|
4499
|
+
return result;
|
|
4500
|
+
throw new Error(`Unmergable intersection. Error path: ` + `${JSON.stringify(merged.mergeErrorPath)}`);
|
|
4501
|
+
}
|
|
4502
|
+
result.value = merged.data;
|
|
4503
|
+
return result;
|
|
4504
|
+
}
|
|
4505
|
+
var $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
|
|
4506
|
+
$ZodType.init(inst, def);
|
|
4507
|
+
const items = def.items;
|
|
4508
|
+
const memo = globalConfig.memoizer;
|
|
4509
|
+
memo?.attach(inst);
|
|
4510
|
+
inst._zod.parse = (payload, ctx) => {
|
|
4511
|
+
const input = payload.value;
|
|
4512
|
+
if (!Array.isArray(input)) {
|
|
4513
|
+
payload.issues.push({
|
|
4514
|
+
input,
|
|
4515
|
+
inst,
|
|
4516
|
+
expected: "tuple",
|
|
4517
|
+
code: "invalid_type"
|
|
4518
|
+
});
|
|
4519
|
+
return payload;
|
|
4520
|
+
}
|
|
4521
|
+
payload.value = memo ? memo.alloc(inst, payload, [], ctx) : [];
|
|
4522
|
+
const proms = [];
|
|
4523
|
+
const optinStart = getTupleOptStart(items, "optin");
|
|
4524
|
+
const optoutStart = getTupleOptStart(items, "optout");
|
|
4525
|
+
if (!def.rest) {
|
|
4526
|
+
if (input.length < optinStart) {
|
|
4527
|
+
payload.issues.push({
|
|
4528
|
+
code: "too_small",
|
|
4529
|
+
minimum: optinStart,
|
|
4530
|
+
inclusive: true,
|
|
4531
|
+
input,
|
|
4532
|
+
inst,
|
|
4533
|
+
origin: "array"
|
|
4534
|
+
});
|
|
4535
|
+
return payload;
|
|
4536
|
+
}
|
|
4537
|
+
if (input.length > items.length) {
|
|
4538
|
+
payload.issues.push({
|
|
4539
|
+
code: "too_big",
|
|
4540
|
+
maximum: items.length,
|
|
4541
|
+
inclusive: true,
|
|
4542
|
+
input,
|
|
4543
|
+
inst,
|
|
4544
|
+
origin: "array"
|
|
4545
|
+
});
|
|
4546
|
+
}
|
|
4547
|
+
}
|
|
4548
|
+
const itemResults = new Array(items.length);
|
|
4549
|
+
const abortEarly = def.rest ? ctx?.abortEarly : undefined;
|
|
4550
|
+
let itemAborted = false;
|
|
4551
|
+
for (let i = 0;i < items.length; i++) {
|
|
4552
|
+
const r = items[i]._zod.run({ value: input[i], issues: [] }, ctx);
|
|
4553
|
+
if (r instanceof Promise) {
|
|
4554
|
+
proms.push(r.then((rr) => {
|
|
4555
|
+
itemResults[i] = rr;
|
|
4556
|
+
}));
|
|
4557
|
+
} else {
|
|
4558
|
+
itemResults[i] = r;
|
|
4559
|
+
if (abortEarly && !itemAborted && r.issues.length)
|
|
4560
|
+
itemAborted = aborted(r);
|
|
4561
|
+
}
|
|
4562
|
+
}
|
|
4563
|
+
if (def.rest && !itemAborted) {
|
|
4564
|
+
let i = items.length - 1;
|
|
4565
|
+
const rest = input.slice(items.length);
|
|
4566
|
+
let seen = payload.issues.length;
|
|
4567
|
+
for (const el of rest) {
|
|
4568
|
+
if (abortEarly && payload.issues.length !== seen) {
|
|
4569
|
+
if (aborted(payload, seen))
|
|
4570
|
+
break;
|
|
4571
|
+
seen = payload.issues.length;
|
|
4572
|
+
}
|
|
4573
|
+
i++;
|
|
4574
|
+
const result = def.rest._zod.run({ value: el, issues: [] }, ctx);
|
|
4575
|
+
if (result instanceof Promise) {
|
|
4576
|
+
proms.push(result.then((r) => handleTupleResult(r, payload, i)));
|
|
4577
|
+
} else {
|
|
4578
|
+
handleTupleResult(result, payload, i);
|
|
4579
|
+
}
|
|
4580
|
+
}
|
|
4289
4581
|
}
|
|
4290
|
-
|
|
4582
|
+
if (proms.length) {
|
|
4583
|
+
return Promise.all(proms).then(() => handleTupleResults(itemResults, payload, items, input, optoutStart));
|
|
4584
|
+
}
|
|
4585
|
+
return handleTupleResults(itemResults, payload, items, input, optoutStart);
|
|
4291
4586
|
};
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4587
|
+
});
|
|
4588
|
+
function getTupleOptStart(items, key) {
|
|
4589
|
+
for (let i = items.length - 1;i >= 0; i--) {
|
|
4590
|
+
const omittable = key === "optin" ? items[i]._zod.optin !== undefined : items[i]._zod.optout === "optional";
|
|
4591
|
+
if (!omittable)
|
|
4592
|
+
return i + 1;
|
|
4295
4593
|
}
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
|
|
4594
|
+
return 0;
|
|
4595
|
+
}
|
|
4596
|
+
function handleTupleResult(result, final, index) {
|
|
4597
|
+
if (result.issues.length) {
|
|
4598
|
+
final.issues.push(...prefixIssues(index, result.issues));
|
|
4299
4599
|
}
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4600
|
+
final.value[index] = result.value;
|
|
4601
|
+
}
|
|
4602
|
+
function handleTupleResults(itemResults, final, items, input, optoutStart) {
|
|
4603
|
+
for (let i = 0;i < items.length; i++) {
|
|
4604
|
+
const r = itemResults[i];
|
|
4605
|
+
const isPresent = i < input.length;
|
|
4606
|
+
if (!isPresent && i >= optoutStart && items[i]._zod.optin === "optional") {
|
|
4607
|
+
final.value.length = i;
|
|
4608
|
+
break;
|
|
4609
|
+
}
|
|
4610
|
+
if (r.issues.length) {
|
|
4611
|
+
if (!isPresent && i >= optoutStart) {
|
|
4612
|
+
final.value.length = i;
|
|
4613
|
+
break;
|
|
4614
|
+
}
|
|
4615
|
+
final.issues.push(...prefixIssues(i, r.issues));
|
|
4308
4616
|
}
|
|
4617
|
+
final.value[i] = r.value;
|
|
4309
4618
|
}
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4619
|
+
for (let i = final.value.length - 1;i >= input.length; i--) {
|
|
4620
|
+
if (items[i]._zod.optout === "optional" && final.value[i] === undefined) {
|
|
4621
|
+
final.value.length = i;
|
|
4622
|
+
} else {
|
|
4623
|
+
break;
|
|
4624
|
+
}
|
|
4315
4625
|
}
|
|
4316
|
-
|
|
4317
|
-
return result;
|
|
4626
|
+
return final;
|
|
4318
4627
|
}
|
|
4319
4628
|
var $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
|
|
4320
4629
|
$ZodType.init(inst, def);
|
|
@@ -4339,6 +4648,28 @@ var $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
|
|
|
4339
4648
|
return payload;
|
|
4340
4649
|
};
|
|
4341
4650
|
});
|
|
4651
|
+
var $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
|
|
4652
|
+
$ZodType.init(inst, def);
|
|
4653
|
+
const values = new Set(def.values);
|
|
4654
|
+
inst._zod.values = values;
|
|
4655
|
+
defineLazyInternal(inst, "pattern", (zod) => {
|
|
4656
|
+
const vals = zod.def.values;
|
|
4657
|
+
return new RegExp(vals.length ? `^(${vals.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$` : "^[^\\s\\S]$");
|
|
4658
|
+
});
|
|
4659
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
4660
|
+
const input = payload.value;
|
|
4661
|
+
if (values.has(input)) {
|
|
4662
|
+
return payload;
|
|
4663
|
+
}
|
|
4664
|
+
payload.issues.push({
|
|
4665
|
+
code: "invalid_value",
|
|
4666
|
+
values: def.values,
|
|
4667
|
+
input,
|
|
4668
|
+
inst
|
|
4669
|
+
});
|
|
4670
|
+
return payload;
|
|
4671
|
+
};
|
|
4672
|
+
});
|
|
4342
4673
|
var $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) => {
|
|
4343
4674
|
$ZodType.init(inst, def);
|
|
4344
4675
|
inst._zod.optin = "optional";
|
|
@@ -5855,6 +6186,45 @@ var enumProcessor = (schema, _ctx, json, _params) => {
|
|
|
5855
6186
|
json.type = "string";
|
|
5856
6187
|
json.enum = values;
|
|
5857
6188
|
};
|
|
6189
|
+
var literalProcessor = (schema, ctx, json, params) => {
|
|
6190
|
+
const def = schema._zod.def;
|
|
6191
|
+
if (def.values.length === 0) {
|
|
6192
|
+
json.not = {};
|
|
6193
|
+
return;
|
|
6194
|
+
}
|
|
6195
|
+
const vals = [];
|
|
6196
|
+
for (const val of def.values) {
|
|
6197
|
+
if (val === undefined) {
|
|
6198
|
+
if (handleUnrepresentable(schema, ctx, json, params, "Literal `undefined` cannot be represented in JSON Schema"))
|
|
6199
|
+
return;
|
|
6200
|
+
} else if (typeof val === "bigint") {
|
|
6201
|
+
if (handleUnrepresentable(schema, ctx, json, params, "BigInt literals cannot be represented in JSON Schema"))
|
|
6202
|
+
return;
|
|
6203
|
+
vals.push(Number(val));
|
|
6204
|
+
} else {
|
|
6205
|
+
vals.push(val);
|
|
6206
|
+
}
|
|
6207
|
+
}
|
|
6208
|
+
if (vals.length === 0) {} else if (vals.length === 1) {
|
|
6209
|
+
const val = vals[0];
|
|
6210
|
+
json.type = val === null ? "null" : typeof val;
|
|
6211
|
+
if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
|
|
6212
|
+
json.enum = [val];
|
|
6213
|
+
} else {
|
|
6214
|
+
json.const = val;
|
|
6215
|
+
}
|
|
6216
|
+
} else {
|
|
6217
|
+
if (vals.every((v) => typeof v === "number"))
|
|
6218
|
+
json.type = "number";
|
|
6219
|
+
if (vals.every((v) => typeof v === "string"))
|
|
6220
|
+
json.type = "string";
|
|
6221
|
+
if (vals.every((v) => typeof v === "boolean"))
|
|
6222
|
+
json.type = "boolean";
|
|
6223
|
+
if (vals.every((v) => v === null))
|
|
6224
|
+
json.type = "null";
|
|
6225
|
+
json.enum = vals;
|
|
6226
|
+
}
|
|
6227
|
+
};
|
|
5858
6228
|
var customProcessor = (schema, ctx, json, params) => {
|
|
5859
6229
|
handleUnrepresentable(schema, ctx, json, params, "Custom types cannot be represented in JSON Schema");
|
|
5860
6230
|
};
|
|
@@ -5954,6 +6324,70 @@ var intersectionProcessor = (schema, ctx, json, params) => {
|
|
|
5954
6324
|
json.allOf = allOf;
|
|
5955
6325
|
ctx.intersections.push(allOf);
|
|
5956
6326
|
};
|
|
6327
|
+
var tupleProcessor = (schema, ctx, _json, params) => {
|
|
6328
|
+
const json = _json;
|
|
6329
|
+
const def = schema._zod.def;
|
|
6330
|
+
json.type = "array";
|
|
6331
|
+
const prefixPath = ctx.target === "draft-2020-12" ? "prefixItems" : "items";
|
|
6332
|
+
const restPath = ctx.target === "draft-2020-12" ? "items" : ctx.target === "openapi-3.0" ? "items" : "additionalItems";
|
|
6333
|
+
const prefixItems = def.items.map((x, i) => processSchema(x, ctx, {
|
|
6334
|
+
...params,
|
|
6335
|
+
path: [...params.path, prefixPath, i]
|
|
6336
|
+
}));
|
|
6337
|
+
const rest = def.rest ? processSchema(def.rest, ctx, {
|
|
6338
|
+
...params,
|
|
6339
|
+
path: [...params.path, restPath, ...ctx.target === "openapi-3.0" ? [def.items.length] : []]
|
|
6340
|
+
}) : null;
|
|
6341
|
+
let minItems = def.items.length;
|
|
6342
|
+
while (minItems > 0) {
|
|
6343
|
+
const item = def.items[minItems - 1];
|
|
6344
|
+
const optional = ctx.io === "input" ? inputOptin(item) !== undefined : item._zod.optout === "optional";
|
|
6345
|
+
if (!optional)
|
|
6346
|
+
break;
|
|
6347
|
+
minItems--;
|
|
6348
|
+
}
|
|
6349
|
+
const maxItems = def.items.length;
|
|
6350
|
+
const isClosed = !def.rest;
|
|
6351
|
+
if (ctx.target === "draft-2020-12") {
|
|
6352
|
+
json.prefixItems = prefixItems;
|
|
6353
|
+
if (isClosed) {
|
|
6354
|
+
json.items = false;
|
|
6355
|
+
} else if (rest) {
|
|
6356
|
+
json.items = rest;
|
|
6357
|
+
}
|
|
6358
|
+
if (minItems > 0)
|
|
6359
|
+
json.minItems = minItems;
|
|
6360
|
+
if (isClosed)
|
|
6361
|
+
json.maxItems = maxItems;
|
|
6362
|
+
} else if (ctx.target === "openapi-3.0") {
|
|
6363
|
+
json.items = {
|
|
6364
|
+
anyOf: prefixItems
|
|
6365
|
+
};
|
|
6366
|
+
if (rest) {
|
|
6367
|
+
json.items.anyOf.push(rest);
|
|
6368
|
+
}
|
|
6369
|
+
if (minItems > 0)
|
|
6370
|
+
json.minItems = minItems;
|
|
6371
|
+
if (isClosed)
|
|
6372
|
+
json.maxItems = maxItems;
|
|
6373
|
+
} else {
|
|
6374
|
+
json.items = prefixItems;
|
|
6375
|
+
if (isClosed) {
|
|
6376
|
+
json.additionalItems = false;
|
|
6377
|
+
} else if (rest) {
|
|
6378
|
+
json.additionalItems = rest;
|
|
6379
|
+
}
|
|
6380
|
+
if (minItems > 0)
|
|
6381
|
+
json.minItems = minItems;
|
|
6382
|
+
if (isClosed)
|
|
6383
|
+
json.maxItems = maxItems;
|
|
6384
|
+
}
|
|
6385
|
+
const { minimum, maximum } = aggregateChecks(schema);
|
|
6386
|
+
if (typeof minimum === "number")
|
|
6387
|
+
json.minItems = minimum;
|
|
6388
|
+
if (typeof maximum === "number")
|
|
6389
|
+
json.maxItems = maximum;
|
|
6390
|
+
};
|
|
5957
6391
|
var pendingRecords = new WeakMap;
|
|
5958
6392
|
var nullableProcessor = (schema, ctx, json, params) => {
|
|
5959
6393
|
const def = schema._zod.def;
|
|
@@ -6489,6 +6923,39 @@ function intersection(left, right) {
|
|
|
6489
6923
|
right
|
|
6490
6924
|
});
|
|
6491
6925
|
}
|
|
6926
|
+
var ZodTuple = /* @__PURE__ */ $constructor("ZodTuple", (inst, def) => {
|
|
6927
|
+
_ensureDefaultMemoizer();
|
|
6928
|
+
$ZodTuple.init(inst, def);
|
|
6929
|
+
ZodType.init(inst, def);
|
|
6930
|
+
inst._zod.processJSONSchema = (ctx, json, params) => tupleProcessor(inst, ctx, json, params);
|
|
6931
|
+
}, {
|
|
6932
|
+
rest(rest) {
|
|
6933
|
+
return this.clone({
|
|
6934
|
+
...this._zod.def,
|
|
6935
|
+
rest
|
|
6936
|
+
});
|
|
6937
|
+
},
|
|
6938
|
+
partial() {
|
|
6939
|
+
const def = this._zod.def;
|
|
6940
|
+
if (def.checks?.length)
|
|
6941
|
+
throw new Error(".partial() cannot be used on tuple schemas containing refinements");
|
|
6942
|
+
return this.clone({
|
|
6943
|
+
...def,
|
|
6944
|
+
items: def.items.map((item) => new ZodOptional({ type: "optional", innerType: item }))
|
|
6945
|
+
});
|
|
6946
|
+
}
|
|
6947
|
+
});
|
|
6948
|
+
function tuple(items, _paramsOrRest, _params) {
|
|
6949
|
+
const hasRest = _paramsOrRest instanceof $ZodType;
|
|
6950
|
+
const params = hasRest ? _params : _paramsOrRest;
|
|
6951
|
+
const rest = hasRest ? _paramsOrRest : null;
|
|
6952
|
+
return new ZodTuple({
|
|
6953
|
+
type: "tuple",
|
|
6954
|
+
items,
|
|
6955
|
+
rest,
|
|
6956
|
+
...normalizeParams(params)
|
|
6957
|
+
});
|
|
6958
|
+
}
|
|
6492
6959
|
var ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
|
|
6493
6960
|
$ZodEnum.init(inst, def);
|
|
6494
6961
|
ZodType.init(inst, def);
|
|
@@ -6535,6 +7002,27 @@ function _enum(values, params) {
|
|
|
6535
7002
|
...normalizeParams(params)
|
|
6536
7003
|
});
|
|
6537
7004
|
}
|
|
7005
|
+
var ZodLiteral = /* @__PURE__ */ $constructor("ZodLiteral", (inst, def) => {
|
|
7006
|
+
$ZodLiteral.init(inst, def);
|
|
7007
|
+
ZodType.init(inst, def);
|
|
7008
|
+
inst._zod.processJSONSchema = (ctx, json, params) => literalProcessor(inst, ctx, json, params);
|
|
7009
|
+
inst.values = new Set(def.values);
|
|
7010
|
+
Object.defineProperty(inst, "value", {
|
|
7011
|
+
get() {
|
|
7012
|
+
if (def.values.length > 1) {
|
|
7013
|
+
throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");
|
|
7014
|
+
}
|
|
7015
|
+
return def.values[0];
|
|
7016
|
+
}
|
|
7017
|
+
});
|
|
7018
|
+
});
|
|
7019
|
+
function literal(value, params) {
|
|
7020
|
+
return new ZodLiteral({
|
|
7021
|
+
type: "literal",
|
|
7022
|
+
values: Array.isArray(value) ? value : [value],
|
|
7023
|
+
...normalizeParams(params)
|
|
7024
|
+
});
|
|
7025
|
+
}
|
|
6538
7026
|
var ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
|
|
6539
7027
|
_ensureDefaultMemoizer();
|
|
6540
7028
|
$ZodTransform.init(inst, def);
|
|
@@ -6707,7 +7195,7 @@ function superRefine(fn, params) {
|
|
|
6707
7195
|
return _superRefine(fn, params);
|
|
6708
7196
|
}
|
|
6709
7197
|
|
|
6710
|
-
// src/contract/Jurisdiction-
|
|
7198
|
+
// src/contract/Jurisdiction-DnnDdNKC.js
|
|
6711
7199
|
var JURISDICTIONS = {
|
|
6712
7200
|
global: {
|
|
6713
7201
|
name: "Global",
|
|
@@ -6760,10 +7248,10 @@ var VIEWER_REGION_SCHEMA = _enum([...COUNTRIES]).describe("Viewer's ISO 3166-1 a
|
|
|
6760
7248
|
var EU_COUNTRIES2 = new Set("AT BE BG HR CY CZ DK EE FI FR DE GR HU IE IT LV LT LU MT NL PL PT RO SK SI ES SE".split(" "));
|
|
6761
7249
|
var VIEWER_CLAIMS_SCHEMA = object({
|
|
6762
7250
|
region: VIEWER_REGION_SCHEMA.optional().describe("Viewer country. Defaults to the country of the connection reaching CalmLens; proxies should forward the viewer country explicitly."),
|
|
6763
|
-
ageConfirmed: boolean2().optional().describe("Your platform's confirmation that the viewer passed its age check, so age-restricted content may be delivered. Defaults to false. Your platform confirms the viewer's age; CalmLens does not verify this claim. Anyone requesting
|
|
7251
|
+
ageConfirmed: boolean2().optional().describe("Your platform's confirmation that the viewer passed its age check, so age-restricted content may be delivered. Defaults to false. Your platform confirms the viewer's age; CalmLens does not verify this claim. Anyone requesting an asset's URL, public or signed, can set it: a signed URL's signature does not cover viewer claims, so the claim is not an access control. To restrict who can load an age-restricted asset, make it private and issue signed URLs only to viewers who passed your age check.")
|
|
6764
7252
|
}).strict();
|
|
6765
7253
|
|
|
6766
|
-
// src/contract/TestRegionalActions-
|
|
7254
|
+
// src/contract/TestRegionalActions-DPNhFf9c.js
|
|
6767
7255
|
var msg = (text) => text;
|
|
6768
7256
|
var MODERATION_QUALIFIER_INFO = {
|
|
6769
7257
|
"sexual-pornographic-media": {
|
|
@@ -7060,6 +7548,24 @@ var MODERATION_QUALIFIER_INFO = {
|
|
|
7060
7548
|
description: msg("Pornographic content showing or describing sex with an animal or with a dead body, or a sexual act that threatens a person's life or is likely to cause serious injury to the anus, breasts or genitals, including realistic drawn or generated depictions."),
|
|
7061
7549
|
exclusions: "Consensual adult content without such an act, including bondage, role play or rough play; non-sexual images of animals, death or injury; reports, education, support or discussion that present no such material."
|
|
7062
7550
|
},
|
|
7551
|
+
"sexual-strangulation": {
|
|
7552
|
+
category: "sexual",
|
|
7553
|
+
kind: "harm",
|
|
7554
|
+
harmOption: false,
|
|
7555
|
+
displayName: msg("Pornographic strangulation or suffocation"),
|
|
7556
|
+
description: msg("A pornographic image or video frame showing a person strangling, choking or suffocating another: pressure on the neck from a hand, arm or ligature, or breathing blocked by covering the mouth and nose, smothering or compressing the chest. Realistic staged, generated or computer-made depictions count."),
|
|
7557
|
+
exclusions: "A person alone in the image holding their own throat or miming being choked; a hand resting on the shoulder, jaw or chest without gripping the throat; collars and choker jewellery; oral sex, including gagging, without breathing deliberately held off; non-sexual violence, combat sport or medical images; drawings or animation that don't look real; reports, education or support that show no such image.",
|
|
7558
|
+
inputs: ["image"]
|
|
7559
|
+
},
|
|
7560
|
+
"sexual-incest": {
|
|
7561
|
+
category: "sexual",
|
|
7562
|
+
kind: "harm",
|
|
7563
|
+
harmOption: false,
|
|
7564
|
+
displayName: msg("Pornographic incest"),
|
|
7565
|
+
description: msg("A pornographic image or video frame showing sexual activity between people who are, or are presented as, related as parent, grandparent, child, grandchild, brother, sister, half-brother, half-sister, uncle, aunt, nephew or niece, including by adoption. The relationship can be shown by the image or by its caption, title, dialogue or other accompanying text. Realistic staged, generated or computer-made depictions count."),
|
|
7566
|
+
exclusions: "Step, foster and in-law relationships between adults; a family word that is plainly a nickname or fanciful, such as daddy between adult partners; drawings or animation that don't look real; non-sexual family images; reports or discussion that show no such image. Someone presented as under 18 is Sexualised minors.",
|
|
7567
|
+
inputs: ["image"]
|
|
7568
|
+
},
|
|
7063
7569
|
"sexual-minors": {
|
|
7064
7570
|
category: "sexual",
|
|
7065
7571
|
kind: "harm",
|
|
@@ -7763,7 +8269,7 @@ var TEST_REGIONAL_ACTIONS_SCHEMA = array(object({
|
|
|
7763
8269
|
])
|
|
7764
8270
|
}).strict()).max(7).refine((entries) => new Set(entries.map((entry) => entry.region)).size === entries.length, "Choose each region once");
|
|
7765
8271
|
|
|
7766
|
-
// src/contract/TestTriggers-
|
|
8272
|
+
// src/contract/TestTriggers-BTyXtX0Q.js
|
|
7767
8273
|
var TEST_IMAGE_GRID_LEVELS = [
|
|
7768
8274
|
72,
|
|
7769
8275
|
128,
|
|
@@ -7828,6 +8334,32 @@ function testInputForSignal(signal, kind = "text") {
|
|
|
7828
8334
|
}] });
|
|
7829
8335
|
}
|
|
7830
8336
|
}
|
|
8337
|
+
var TEST_DETECTION_BOX_MAX = 1e4;
|
|
8338
|
+
var basisPoints = number2().int().min(0).max(TEST_DETECTION_BOX_MAX);
|
|
8339
|
+
var detectionShape = {
|
|
8340
|
+
box: tuple([
|
|
8341
|
+
basisPoints,
|
|
8342
|
+
basisPoints,
|
|
8343
|
+
basisPoints,
|
|
8344
|
+
basisPoints
|
|
8345
|
+
]),
|
|
8346
|
+
confidence: number2().int().min(0).max(100).optional()
|
|
8347
|
+
};
|
|
8348
|
+
var fitsImage = ({ box: [left, top, width, height] }) => left + width <= 1e4 && top + height <= 1e4;
|
|
8349
|
+
var BOX_MESSAGE = msg("A box must lie inside the image: left + width and top + height are at most 10000.");
|
|
8350
|
+
var ageYears = number2().int().min(0).max(120);
|
|
8351
|
+
var TEST_DETECTED_PERSON_SCHEMA = object(detectionShape).strict().refine(fitsImage, BOX_MESSAGE);
|
|
8352
|
+
var TEST_DETECTED_FACE_SCHEMA = object({
|
|
8353
|
+
...detectionShape,
|
|
8354
|
+
age: union([_enum(["adult", "minor"]), object({
|
|
8355
|
+
low: ageYears,
|
|
8356
|
+
high: ageYears
|
|
8357
|
+
}).strict().refine(({ low, high }) => low <= high, msg("An age range's low must not be above its high."))]).optional()
|
|
8358
|
+
}).strict().refine(fitsImage, BOX_MESSAGE);
|
|
8359
|
+
var TEST_DETECTIONS_SCHEMA = object({
|
|
8360
|
+
people: union([array(TEST_DETECTED_PERSON_SCHEMA).max(32), literal("unavailable")]).optional(),
|
|
8361
|
+
faces: union([array(TEST_DETECTED_FACE_SCHEMA).max(32), literal("unavailable")]).optional()
|
|
8362
|
+
}).strict();
|
|
7831
8363
|
var TEST_INPUT_SCHEMA = object({
|
|
7832
8364
|
regionalActions: TEST_REGIONAL_ACTIONS_SCHEMA.optional(),
|
|
7833
8365
|
unassessedCategories: array(_enum(CLASSIFICATION_CATEGORIES)).max(CLASSIFICATION_CATEGORIES.length).optional(),
|
|
@@ -7847,7 +8379,8 @@ var TEST_INPUT_SCHEMA = object({
|
|
|
7847
8379
|
code: "custom",
|
|
7848
8380
|
message: "Choose unique content qualifiers from this category; input-type facts are automatic."
|
|
7849
8381
|
});
|
|
7850
|
-
})).max(128)
|
|
8382
|
+
})).max(128),
|
|
8383
|
+
detections: TEST_DETECTIONS_SCHEMA.optional()
|
|
7851
8384
|
}).strict().superRefine((scenario, context) => {
|
|
7852
8385
|
if (scenario.instances.some((instance) => instance.action !== undefined) && scenario.instances.some((instance) => instance.action === undefined))
|
|
7853
8386
|
context.addIssue({
|
|
@@ -7902,13 +8435,124 @@ var TEST_INPUT_PRESETS = {
|
|
|
7902
8435
|
}, {
|
|
7903
8436
|
category: "harassment",
|
|
7904
8437
|
qualifiers: ["harassment-threat"]
|
|
7905
|
-
}] }
|
|
8438
|
+
}] },
|
|
8439
|
+
oneFace: {
|
|
8440
|
+
instances: [],
|
|
8441
|
+
detections: {
|
|
8442
|
+
people: [{ box: [
|
|
8443
|
+
2500,
|
|
8444
|
+
1500,
|
|
8445
|
+
5000,
|
|
8446
|
+
8500
|
|
8447
|
+
] }],
|
|
8448
|
+
faces: [{ box: [
|
|
8449
|
+
3500,
|
|
8450
|
+
2000,
|
|
8451
|
+
3000,
|
|
8452
|
+
3500
|
|
8453
|
+
] }]
|
|
8454
|
+
}
|
|
8455
|
+
},
|
|
8456
|
+
noFace: {
|
|
8457
|
+
instances: [],
|
|
8458
|
+
detections: {
|
|
8459
|
+
people: [],
|
|
8460
|
+
faces: []
|
|
8461
|
+
}
|
|
8462
|
+
},
|
|
8463
|
+
adultFace: {
|
|
8464
|
+
instances: [],
|
|
8465
|
+
detections: {
|
|
8466
|
+
people: [{ box: [
|
|
8467
|
+
2500,
|
|
8468
|
+
1500,
|
|
8469
|
+
5000,
|
|
8470
|
+
8500
|
|
8471
|
+
] }],
|
|
8472
|
+
faces: [{
|
|
8473
|
+
box: [
|
|
8474
|
+
3500,
|
|
8475
|
+
2000,
|
|
8476
|
+
3000,
|
|
8477
|
+
3500
|
|
8478
|
+
],
|
|
8479
|
+
age: "adult"
|
|
8480
|
+
}]
|
|
8481
|
+
}
|
|
8482
|
+
},
|
|
8483
|
+
minorFace: {
|
|
8484
|
+
instances: [],
|
|
8485
|
+
detections: {
|
|
8486
|
+
people: [{ box: [
|
|
8487
|
+
2500,
|
|
8488
|
+
1500,
|
|
8489
|
+
5000,
|
|
8490
|
+
8500
|
|
8491
|
+
] }],
|
|
8492
|
+
faces: [{
|
|
8493
|
+
box: [
|
|
8494
|
+
3500,
|
|
8495
|
+
2000,
|
|
8496
|
+
3000,
|
|
8497
|
+
3500
|
|
8498
|
+
],
|
|
8499
|
+
age: "minor"
|
|
8500
|
+
}]
|
|
8501
|
+
}
|
|
8502
|
+
},
|
|
8503
|
+
group: {
|
|
8504
|
+
instances: [],
|
|
8505
|
+
detections: {
|
|
8506
|
+
people: [
|
|
8507
|
+
{ box: [
|
|
8508
|
+
500,
|
|
8509
|
+
2000,
|
|
8510
|
+
2800,
|
|
8511
|
+
8000
|
|
8512
|
+
] },
|
|
8513
|
+
{ box: [
|
|
8514
|
+
3600,
|
|
8515
|
+
2000,
|
|
8516
|
+
2800,
|
|
8517
|
+
8000
|
|
8518
|
+
] },
|
|
8519
|
+
{ box: [
|
|
8520
|
+
6700,
|
|
8521
|
+
2000,
|
|
8522
|
+
2800,
|
|
8523
|
+
8000
|
|
8524
|
+
] }
|
|
8525
|
+
],
|
|
8526
|
+
faces: [
|
|
8527
|
+
{ box: [
|
|
8528
|
+
1200,
|
|
8529
|
+
2500,
|
|
8530
|
+
1400,
|
|
8531
|
+
2000
|
|
8532
|
+
] },
|
|
8533
|
+
{ box: [
|
|
8534
|
+
4300,
|
|
8535
|
+
2500,
|
|
8536
|
+
1400,
|
|
8537
|
+
2000
|
|
8538
|
+
] },
|
|
8539
|
+
{ box: [
|
|
8540
|
+
7400,
|
|
8541
|
+
2500,
|
|
8542
|
+
1400,
|
|
8543
|
+
2000
|
|
8544
|
+
] }
|
|
8545
|
+
]
|
|
8546
|
+
}
|
|
8547
|
+
}
|
|
7906
8548
|
};
|
|
7907
|
-
var tag = async (payload, key) => (await hmacSha256Hex(key, `calmlens-test:
|
|
8549
|
+
var tag = async (payload, key) => (await hmacSha256Hex(key, `calmlens-test:v2:${payload}`)).slice(0, 32);
|
|
8550
|
+
var toBase64Url2 = (bytes) => btoa(String.fromCharCode(...bytes)).replaceAll("+", "-").replaceAll("/", "_").replace(/=+$/, "");
|
|
8551
|
+
var envelope = (scenario) => new TextEncoder().encode(JSON.stringify(TEST_INPUT_SCHEMA.parse(scenario)));
|
|
7908
8552
|
async function generateTestTextCode(scenario, key) {
|
|
7909
8553
|
if (!/^[a-f0-9]{32}$/.test(key))
|
|
7910
8554
|
throw new TypeError("Invalid test input key");
|
|
7911
|
-
const payload =
|
|
8555
|
+
const payload = toBase64Url2(envelope(typeof scenario === "string" ? testInputForSignal(scenario) : scenario));
|
|
7912
8556
|
if (payload.length > 8000)
|
|
7913
8557
|
throw new RangeError("Test scenario is too large");
|
|
7914
8558
|
return `<!calmlens-test ${await tag(payload, key)} ${payload}>`;
|
|
@@ -7916,7 +8560,7 @@ async function generateTestTextCode(scenario, key) {
|
|
|
7916
8560
|
// src/cli/listen.ts
|
|
7917
8561
|
import { randomBytes } from "node:crypto";
|
|
7918
8562
|
|
|
7919
|
-
// src/contract/Ids-
|
|
8563
|
+
// src/contract/Ids-BESMSxGb.js
|
|
7920
8564
|
var __defProp = Object.defineProperty;
|
|
7921
8565
|
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod, mod.exports), cb = null), mod.exports);
|
|
7922
8566
|
var __exportAll = (all, no_symbols) => {
|
|
@@ -11122,8 +11766,8 @@ var $ZodTuple2 = /* @__PURE__ */ $constructor2("$ZodTuple", (inst, def) => {
|
|
|
11122
11766
|
}
|
|
11123
11767
|
payload.value = memo ? memo.alloc(inst, payload, [], ctx) : [];
|
|
11124
11768
|
const proms = [];
|
|
11125
|
-
const optinStart =
|
|
11126
|
-
const optoutStart =
|
|
11769
|
+
const optinStart = getTupleOptStart2(items, "optin");
|
|
11770
|
+
const optoutStart = getTupleOptStart2(items, "optout");
|
|
11127
11771
|
if (!def.rest) {
|
|
11128
11772
|
if (input.length < optinStart) {
|
|
11129
11773
|
payload.issues.push({
|
|
@@ -11180,28 +11824,28 @@ var $ZodTuple2 = /* @__PURE__ */ $constructor2("$ZodTuple", (inst, def) => {
|
|
|
11180
11824
|
issues: []
|
|
11181
11825
|
}, ctx);
|
|
11182
11826
|
if (result instanceof Promise)
|
|
11183
|
-
proms.push(result.then((r) =>
|
|
11827
|
+
proms.push(result.then((r) => handleTupleResult2(r, payload, i)));
|
|
11184
11828
|
else
|
|
11185
|
-
|
|
11829
|
+
handleTupleResult2(result, payload, i);
|
|
11186
11830
|
}
|
|
11187
11831
|
}
|
|
11188
11832
|
if (proms.length)
|
|
11189
|
-
return Promise.all(proms).then(() =>
|
|
11190
|
-
return
|
|
11833
|
+
return Promise.all(proms).then(() => handleTupleResults2(itemResults, payload, items, input, optoutStart));
|
|
11834
|
+
return handleTupleResults2(itemResults, payload, items, input, optoutStart);
|
|
11191
11835
|
};
|
|
11192
11836
|
});
|
|
11193
|
-
function
|
|
11837
|
+
function getTupleOptStart2(items, key) {
|
|
11194
11838
|
for (let i = items.length - 1;i >= 0; i--)
|
|
11195
11839
|
if (!(key === "optin" ? items[i]._zod.optin !== undefined : items[i]._zod.optout === "optional"))
|
|
11196
11840
|
return i + 1;
|
|
11197
11841
|
return 0;
|
|
11198
11842
|
}
|
|
11199
|
-
function
|
|
11843
|
+
function handleTupleResult2(result, final, index) {
|
|
11200
11844
|
if (result.issues.length)
|
|
11201
11845
|
final.issues.push(...prefixIssues2(index, result.issues));
|
|
11202
11846
|
final.value[index] = result.value;
|
|
11203
11847
|
}
|
|
11204
|
-
function
|
|
11848
|
+
function handleTupleResults2(itemResults, final, items, input, optoutStart) {
|
|
11205
11849
|
for (let i = 0;i < items.length; i++) {
|
|
11206
11850
|
const r = itemResults[i];
|
|
11207
11851
|
const isPresent = i < input.length;
|
|
@@ -14568,7 +15212,7 @@ var schemas_exports = /* @__PURE__ */ __exportAll({
|
|
|
14568
15212
|
ZodJWT: () => ZodJWT,
|
|
14569
15213
|
ZodKSUID: () => ZodKSUID,
|
|
14570
15214
|
ZodLazy: () => ZodLazy,
|
|
14571
|
-
ZodLiteral: () =>
|
|
15215
|
+
ZodLiteral: () => ZodLiteral2,
|
|
14572
15216
|
ZodMAC: () => ZodMAC,
|
|
14573
15217
|
ZodMap: () => ZodMap,
|
|
14574
15218
|
ZodNaN: () => ZodNaN,
|
|
@@ -14594,7 +15238,7 @@ var schemas_exports = /* @__PURE__ */ __exportAll({
|
|
|
14594
15238
|
ZodSymbol: () => ZodSymbol,
|
|
14595
15239
|
ZodTemplateLiteral: () => ZodTemplateLiteral,
|
|
14596
15240
|
ZodTransform: () => ZodTransform2,
|
|
14597
|
-
ZodTuple: () =>
|
|
15241
|
+
ZodTuple: () => ZodTuple2,
|
|
14598
15242
|
ZodType: () => ZodType2,
|
|
14599
15243
|
ZodULID: () => ZodULID,
|
|
14600
15244
|
ZodURL: () => ZodURL,
|
|
@@ -14655,7 +15299,7 @@ var schemas_exports = /* @__PURE__ */ __exportAll({
|
|
|
14655
15299
|
keyof: () => keyof,
|
|
14656
15300
|
ksuid: () => ksuid2,
|
|
14657
15301
|
lazy: () => lazy,
|
|
14658
|
-
literal: () =>
|
|
15302
|
+
literal: () => literal2,
|
|
14659
15303
|
looseObject: () => looseObject,
|
|
14660
15304
|
looseRecord: () => looseRecord,
|
|
14661
15305
|
mac: () => mac2,
|
|
@@ -14690,7 +15334,7 @@ var schemas_exports = /* @__PURE__ */ __exportAll({
|
|
|
14690
15334
|
symbol: () => symbol,
|
|
14691
15335
|
templateLiteral: () => templateLiteral,
|
|
14692
15336
|
transform: () => transform2,
|
|
14693
|
-
tuple: () =>
|
|
15337
|
+
tuple: () => tuple2,
|
|
14694
15338
|
uint32: () => uint32,
|
|
14695
15339
|
uint64: () => uint64,
|
|
14696
15340
|
ulid: () => ulid2,
|
|
@@ -15624,7 +16268,7 @@ function intersection2(left, right) {
|
|
|
15624
16268
|
right
|
|
15625
16269
|
});
|
|
15626
16270
|
}
|
|
15627
|
-
var
|
|
16271
|
+
var ZodTuple2 = /* @__PURE__ */ $constructor2("ZodTuple", (inst, def) => {
|
|
15628
16272
|
_ensureDefaultMemoizer2();
|
|
15629
16273
|
$ZodTuple2.init(inst, def);
|
|
15630
16274
|
ZodType2.init(inst, def);
|
|
@@ -15649,9 +16293,9 @@ var ZodTuple = /* @__PURE__ */ $constructor2("ZodTuple", (inst, def) => {
|
|
|
15649
16293
|
});
|
|
15650
16294
|
}
|
|
15651
16295
|
});
|
|
15652
|
-
function
|
|
16296
|
+
function tuple2(items, _paramsOrRest, _params) {
|
|
15653
16297
|
const hasRest = _paramsOrRest instanceof $ZodType2;
|
|
15654
|
-
return new
|
|
16298
|
+
return new ZodTuple2({
|
|
15655
16299
|
type: "tuple",
|
|
15656
16300
|
items,
|
|
15657
16301
|
rest: hasRest ? _paramsOrRest : null,
|
|
@@ -15787,7 +16431,7 @@ function nativeEnum(entries, params) {
|
|
|
15787
16431
|
...normalizeParams2(params)
|
|
15788
16432
|
});
|
|
15789
16433
|
}
|
|
15790
|
-
var
|
|
16434
|
+
var ZodLiteral2 = /* @__PURE__ */ $constructor2("ZodLiteral", (inst, def) => {
|
|
15791
16435
|
$ZodLiteral2.init(inst, def);
|
|
15792
16436
|
ZodType2.init(inst, def);
|
|
15793
16437
|
inst._zod.processJSONSchema = (ctx, json, params) => literalProcessor2(inst, ctx, json, params);
|
|
@@ -15798,8 +16442,8 @@ var ZodLiteral = /* @__PURE__ */ $constructor2("ZodLiteral", (inst, def) => {
|
|
|
15798
16442
|
return def.values[0];
|
|
15799
16443
|
} });
|
|
15800
16444
|
});
|
|
15801
|
-
function
|
|
15802
|
-
return new
|
|
16445
|
+
function literal2(value, params) {
|
|
16446
|
+
return new ZodLiteral2({
|
|
15803
16447
|
type: "literal",
|
|
15804
16448
|
values: Array.isArray(value) ? value : [value],
|
|
15805
16449
|
...normalizeParams2(params)
|
|
@@ -16068,7 +16712,7 @@ var ZodFunction = /* @__PURE__ */ $constructor2("ZodFunction", (inst, def) => {
|
|
|
16068
16712
|
function _function(params) {
|
|
16069
16713
|
return new ZodFunction({
|
|
16070
16714
|
type: "function",
|
|
16071
|
-
input: Array.isArray(params?.input) ?
|
|
16715
|
+
input: Array.isArray(params?.input) ? tuple2(params?.input) : params?.input ?? array2(unknown2()),
|
|
16072
16716
|
output: params?.output ?? unknown2()
|
|
16073
16717
|
});
|
|
16074
16718
|
}
|
|
@@ -16204,6 +16848,7 @@ var ID_PREFIXES = {
|
|
|
16204
16848
|
member: "mem",
|
|
16205
16849
|
invitation: "inv",
|
|
16206
16850
|
transfer: "xfer",
|
|
16851
|
+
assetBatch: "batch",
|
|
16207
16852
|
supportTicket: "tkt",
|
|
16208
16853
|
supportTicketMessage: "msg",
|
|
16209
16854
|
humanReview: "rev",
|
|
@@ -16235,11 +16880,13 @@ var newId = (prefix) => `${prefix}_${randomBase62(20)}`;
|
|
|
16235
16880
|
var toWebhookEventPayload = (event) => ({
|
|
16236
16881
|
id: event.id,
|
|
16237
16882
|
projectId: event.projectId,
|
|
16883
|
+
actor: event.actor,
|
|
16238
16884
|
type: event.type,
|
|
16239
16885
|
severity: event.severity,
|
|
16240
16886
|
title: event.title,
|
|
16241
16887
|
description: event.description ?? null,
|
|
16242
16888
|
assetId: event.assetId ?? null,
|
|
16889
|
+
assetSequence: event.assetSequence ?? null,
|
|
16243
16890
|
asset: event.asset ?? null,
|
|
16244
16891
|
facts: event.facts,
|
|
16245
16892
|
createdAt: event.createdAt
|
|
@@ -16258,9 +16905,9 @@ var createWebhookHeaders = async (options) => {
|
|
|
16258
16905
|
var FORWARD_TIMEOUT_MS = 1e4;
|
|
16259
16906
|
var MAX_BACKOFF_MS = 30000;
|
|
16260
16907
|
var FATAL_ERROR_CODES = new Set([
|
|
16261
|
-
"
|
|
16262
|
-
"
|
|
16263
|
-
"
|
|
16908
|
+
"api-key/missing",
|
|
16909
|
+
"api-key/invalid",
|
|
16910
|
+
"api-key/project-mismatch",
|
|
16264
16911
|
"project/not-found"
|
|
16265
16912
|
]);
|
|
16266
16913
|
var createLocalSigningSecret = () => `whsec_local_${randomBytes(24).toString("hex")}`;
|
|
@@ -16318,6 +16965,22 @@ var unavailableWarning = (unavailableTypes) => [
|
|
|
16318
16965
|
""
|
|
16319
16966
|
].join(`
|
|
16320
16967
|
`);
|
|
16968
|
+
var inAssetOrder = (events) => {
|
|
16969
|
+
const byAsset = new Map;
|
|
16970
|
+
for (const event of events)
|
|
16971
|
+
if (event.assetId)
|
|
16972
|
+
byAsset.set(event.assetId, [...byAsset.get(event.assetId) ?? [], event]);
|
|
16973
|
+
for (const assetEvents of byAsset.values())
|
|
16974
|
+
assetEvents.sort((a, b) => (a.assetSequence ?? 0) - (b.assetSequence ?? 0));
|
|
16975
|
+
const next = new Map;
|
|
16976
|
+
return events.map((event) => {
|
|
16977
|
+
if (!event.assetId)
|
|
16978
|
+
return event;
|
|
16979
|
+
const index = next.get(event.assetId) ?? 0;
|
|
16980
|
+
next.set(event.assetId, index + 1);
|
|
16981
|
+
return byAsset.get(event.assetId)[index];
|
|
16982
|
+
});
|
|
16983
|
+
};
|
|
16321
16984
|
var listen = async (options) => {
|
|
16322
16985
|
const { client, signal } = options;
|
|
16323
16986
|
const log = options.log ?? ((line) => process.stdout.write(`${line}
|
|
@@ -16334,7 +16997,7 @@ var listen = async (options) => {
|
|
|
16334
16997
|
if (failures > 0)
|
|
16335
16998
|
log(`${formatTime(new Date)} Reconnected to CalmLens.`);
|
|
16336
16999
|
failures = 0;
|
|
16337
|
-
for (const event of page.items) {
|
|
17000
|
+
for (const event of inAssetOrder(page.items)) {
|
|
16338
17001
|
if (eventTypes.size > 0 && !eventTypes.has(event.type))
|
|
16339
17002
|
continue;
|
|
16340
17003
|
log(formatForwardLine(event, await forwardEvent(event, options)));
|
|
@@ -16481,12 +17144,14 @@ Commands:
|
|
|
16481
17144
|
login Sign in through your browser and choose a project. The CLI keeps the key it
|
|
16482
17145
|
receives, so listen and trigger need no API key or project ID.
|
|
16483
17146
|
logout Revoke and forget the key from login.
|
|
16484
|
-
listen Forward your project's events to a local webhook handler with the same
|
|
16485
|
-
(
|
|
16486
|
-
x-calmlens-signature: v1=...) as
|
|
17147
|
+
listen Forward your project's events to a local webhook handler with the same flat
|
|
17148
|
+
body (id, projectId, type, severity, title, description, assetId, asset, facts,
|
|
17149
|
+
createdAt) and headers (x-calmlens-timestamp, x-calmlens-signature: v1=...) as
|
|
17150
|
+
real deliveries. No public URL needed.
|
|
16487
17151
|
trigger Moderate a harmless test comment so CalmLens creates real events. Each trigger
|
|
16488
|
-
counts as one upload. Test comments other than clean
|
|
16489
|
-
test input key (
|
|
17152
|
+
counts as one upload. Test comments other than clean are signed with the
|
|
17153
|
+
project's test input key (Project settings → Test inputs in the portal, with
|
|
17154
|
+
Recognise test inputs turned on).
|
|
16490
17155
|
|
|
16491
17156
|
Options:
|
|
16492
17157
|
--forward-to <url> Local webhook URL, e.g. http://localhost:3000/api/webhooks/calmlens
|
|
@@ -16637,10 +17302,10 @@ var main = async () => {
|
|
|
16637
17302
|
const testInputKey = (values["test-key"] ?? process.env.CALMLENS_TEST_INPUT_KEY)?.trim();
|
|
16638
17303
|
if (!testInputKey)
|
|
16639
17304
|
fail(`trigger ${kind} needs your project's test input key: pass --test-key <key> or set CALMLENS_TEST_INPUT_KEY.
|
|
16640
|
-
` + "Copy it from
|
|
17305
|
+
` + "Copy it from Project settings → Test inputs in the CalmLens portal.");
|
|
16641
17306
|
if (!TEST_INPUT_KEY_PATTERN.test(testInputKey))
|
|
16642
17307
|
fail(`"${testInputKey}" isn't a test input key: it is 32 lowercase hexadecimal characters.
|
|
16643
|
-
` + "Copy it from
|
|
17308
|
+
` + "Copy it from Project settings → Test inputs in the CalmLens portal.");
|
|
16644
17309
|
text = await generateTestTextCode(kind, testInputKey);
|
|
16645
17310
|
}
|
|
16646
17311
|
try {
|