calmlens 0.19.0 → 0.20.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.
Files changed (74) hide show
  1. package/bin/calmlens.js +293 -18
  2. package/{esm/BrowserUpload-RkxV_Vv7.d.ts → cjs/BrowserUpload-C07aL9Vq.d.ts} +2 -2
  3. package/cjs/{BrowserUpload-CJ4Xc9bR.js → BrowserUpload-CjSHjx3C.js} +1 -1
  4. package/{esm/CalmLensAppClient-B5gfOB6J.d.ts → cjs/CalmLensAppClient-DDLojj0P.d.ts} +1 -1
  5. package/cjs/{CalmLensAppClient-LHMEQ-UZ.js → CalmLensAppClient-NaCxOVlM.js} +2 -2
  6. package/cjs/{CalmLensOptionKeys-BUj7v5AG.js → CalmLensOptionKeys-p2QK687A.js} +63 -2
  7. package/cjs/{CalmLensServerClient-BVOEUT_v.js → CalmLensServerClient-BDzTthxE.js} +12 -7
  8. package/cjs/{CalmLensServerClient-DCSbwIBs.d.ts → CalmLensServerClient-C-jsjn8m.d.ts} +4 -4
  9. package/cjs/{CalmLensTypes-DpU-hXq2.d.ts → CalmLensTypes-COJbOuiv.d.ts} +2 -2
  10. package/cjs/{ModerationContextLimits-FDpQmw_T.js → ModerationContextLimits-2nIv7Zh3.js} +304 -12
  11. package/cjs/{ReactUpload-BvpW4hJi.js → ReactUpload-BdTRCTGA.js} +1 -1
  12. package/cjs/{ReactUpload-huIMnOJ4.d.ts → ReactUpload-CRJNPB5T.d.ts} +1 -1
  13. package/cjs/{TestTriggers-CMwMrbjy-K0YBzu2a.js → TestTriggers-DbhsNPdg-DjvVuc2h.js} +2 -2
  14. package/cjs/{UploadController-D4qOZZc3.js → UploadController-MLVs97Zt.js} +2 -2
  15. package/cjs/{WebhookPayload-CQg8BBZQ.d.ts → WebhookPayload-DkukERKE.d.ts} +1 -1
  16. package/cjs/app.d.ts +4 -4
  17. package/cjs/app.js +2 -2
  18. package/cjs/elements.d.ts +2 -2
  19. package/cjs/elements.js +3 -3
  20. package/{esm/index-BcDDQJF2.d.ts → cjs/index-DxbJ_Xaa.d.ts} +2 -2
  21. package/cjs/index.d.ts +3 -3
  22. package/cjs/index.js +1 -1
  23. package/cjs/react-native.d.ts +2 -2
  24. package/cjs/react-native.js +3 -3
  25. package/cjs/react.d.ts +2 -2
  26. package/cjs/react.js +4 -4
  27. package/cjs/server.d.ts +4 -4
  28. package/cjs/server.js +2 -2
  29. package/cjs/test-inputs.js +9 -9
  30. package/cjs/testing.d.ts +10 -7
  31. package/cjs/testing.js +121 -18
  32. package/cjs/{ui-B23r8BvW.d.ts → ui-BSqPGKrZ.d.ts} +2 -2
  33. package/cjs/{ui-Dq-cm6Rx.js → ui-CX1z2pD9.js} +2 -2
  34. package/cjs/ui.d.ts +1 -1
  35. package/cjs/ui.js +2 -2
  36. package/cjs/vue.d.ts +4 -4
  37. package/cjs/vue.js +3 -3
  38. package/{cjs/BrowserUpload-RkxV_Vv7.d.ts → esm/BrowserUpload-C07aL9Vq.d.ts} +2 -2
  39. package/esm/{BrowserUpload-DpzS2bbj.js → BrowserUpload-CAVkRotw.js} +1 -1
  40. package/{cjs/CalmLensAppClient-B5gfOB6J.d.ts → esm/CalmLensAppClient-DDLojj0P.d.ts} +1 -1
  41. package/esm/{CalmLensAppClient-BjlvBweS.js → CalmLensAppClient-PQ9VBvlW.js} +2 -2
  42. package/esm/{CalmLensOptionKeys-BKez0Wiw.js → CalmLensOptionKeys-Do2mPP6w.js} +58 -3
  43. package/esm/{CalmLensServerClient-DCSbwIBs.d.ts → CalmLensServerClient-C-jsjn8m.d.ts} +4 -4
  44. package/esm/{CalmLensServerClient-DemxbNMn.js → CalmLensServerClient-C_H5aAsV.js} +12 -7
  45. package/esm/{CalmLensTypes-DpU-hXq2.d.ts → CalmLensTypes-COJbOuiv.d.ts} +2 -2
  46. package/esm/{ModerationContextLimits-lLfmyLni.js → ModerationContextLimits-Chw-AzgL.js} +291 -11
  47. package/esm/{ReactUpload-6klucehl.js → ReactUpload-CMmL0R5Q.js} +1 -1
  48. package/esm/{ReactUpload-huIMnOJ4.d.ts → ReactUpload-CRJNPB5T.d.ts} +1 -1
  49. package/esm/{TestTriggers-CMwMrbjy-bdowBBKw.js → TestTriggers-DbhsNPdg-CUdrv8Nm.js} +2 -2
  50. package/esm/{UploadController-UxP6gj7A.js → UploadController-BJZghJpg.js} +2 -2
  51. package/esm/{WebhookPayload-CQg8BBZQ.d.ts → WebhookPayload-DkukERKE.d.ts} +1 -1
  52. package/esm/app.d.ts +4 -4
  53. package/esm/app.js +2 -2
  54. package/esm/elements.d.ts +2 -2
  55. package/esm/elements.js +3 -3
  56. package/{cjs/index-BcDDQJF2.d.ts → esm/index-DxbJ_Xaa.d.ts} +2 -2
  57. package/esm/index.d.ts +3 -3
  58. package/esm/index.js +1 -1
  59. package/esm/react-native.d.ts +2 -2
  60. package/esm/react-native.js +3 -3
  61. package/esm/react.d.ts +2 -2
  62. package/esm/react.js +4 -4
  63. package/esm/server.d.ts +4 -4
  64. package/esm/server.js +2 -2
  65. package/esm/test-inputs.js +1 -1
  66. package/esm/testing.d.ts +10 -7
  67. package/esm/testing.js +118 -15
  68. package/esm/{ui-B23r8BvW.d.ts → ui-BSqPGKrZ.d.ts} +2 -2
  69. package/esm/{ui-Bn29rfAi.js → ui-CXH7xJpb.js} +2 -2
  70. package/esm/ui.d.ts +1 -1
  71. package/esm/ui.js +2 -2
  72. package/esm/vue.d.ts +4 -4
  73. package/esm/vue.js +3 -3
  74. package/package.json +1 -1
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.19.0";
5
+ var version = "0.20.0";
6
6
 
7
7
  // src/contract/ModerationCategories-CHFRoeWV.js
8
8
  var CLASSIFICATION_CATEGORIES = [
@@ -133,7 +133,7 @@ var selectModerationContextItems = (items) => {
133
133
  }
134
134
  return selected;
135
135
  };
136
- // src/contract/SharedConstants-CrqW8Uco.js
136
+ // src/contract/SharedConstants-DxUCZwLZ.js
137
137
  var IMPERSONATION_COOKIE_NAME = "CL_impersonation";
138
138
  var DAY_MS = 86400000;
139
139
  var YEAR_MS = 365 * DAY_MS;
@@ -334,17 +334,7 @@ var MAX_IMAGE_UPLOAD_BYTES = /* @__PURE__ */ (() => 20971520)();
334
334
  var MAX_DIRECT_IMAGE_UPLOAD_BYTES = /* @__PURE__ */ (() => 10485760)();
335
335
  var MAX_NON_IMAGE_UPLOAD_MB = 5000;
336
336
  var MAX_NON_IMAGE_UPLOAD_BYTES = /* @__PURE__ */ (() => MAX_NON_IMAGE_UPLOAD_MB * 1024 * 1024)();
337
- var REJECTED_UPLOAD_MIME_TYPE_SET = /* @__PURE__ */ new Set([
338
- "application/octet-stream",
339
- "multipart/form-data",
340
- "multipart/mixed",
341
- "multipart/alternative",
342
- "multipart/related",
343
- "multipart/signed",
344
- "multipart/encrypted"
345
- ]);
346
337
  var normalizeUploadMimeType = (mimeType) => mimeType.toLowerCase().split(";")[0]?.trim() || mimeType.toLowerCase().trim();
347
- var isRejectedUploadMimeType = (mimeType) => REJECTED_UPLOAD_MIME_TYPE_SET.has(normalizeUploadMimeType(mimeType));
348
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.`;
349
339
  var DOMAIN = "calmlens.com";
350
340
  // src/client/CalmLensErrorCodes.ts
@@ -820,6 +810,212 @@ class CalmLensTransport {
820
810
  }
821
811
  }
822
812
 
813
+ // src/client/CalmLensTransformSchema.ts
814
+ var TRANSFORM_OPTIONS_SCHEMA = {
815
+ type: "object",
816
+ properties: {
817
+ format: {
818
+ type: "string",
819
+ enum: ["jpg", "png", "webp", "avif", "gif"]
820
+ },
821
+ width: {
822
+ type: "integer",
823
+ minimum: 1,
824
+ maximum: 1e4
825
+ },
826
+ height: {
827
+ type: "integer",
828
+ minimum: 1,
829
+ maximum: 1e4
830
+ },
831
+ dpr: {
832
+ type: "number",
833
+ minimum: 1,
834
+ maximum: 3
835
+ },
836
+ anim: {
837
+ type: "boolean"
838
+ },
839
+ background: {
840
+ type: "string"
841
+ },
842
+ blur: {
843
+ type: "number"
844
+ },
845
+ redact: {
846
+ type: "object",
847
+ properties: {
848
+ text: {
849
+ type: "boolean"
850
+ },
851
+ personalInformation: {
852
+ type: "boolean"
853
+ },
854
+ faces: {
855
+ type: "boolean"
856
+ }
857
+ }
858
+ },
859
+ border: {
860
+ type: "object",
861
+ properties: {
862
+ color: {
863
+ type: "string"
864
+ },
865
+ width: {
866
+ type: "number"
867
+ }
868
+ }
869
+ },
870
+ brightness: {
871
+ type: "number"
872
+ },
873
+ contrast: {
874
+ type: "number"
875
+ },
876
+ quality: {
877
+ oneOf: [
878
+ {
879
+ type: "integer",
880
+ minimum: 1,
881
+ maximum: 100
882
+ },
883
+ {
884
+ type: "string",
885
+ enum: ["low", "medium", "high"]
886
+ }
887
+ ]
888
+ },
889
+ fit: {
890
+ type: "string",
891
+ enum: ["scale-down", "contain", "pad", "squeeze", "cover", "crop"]
892
+ },
893
+ flip: {
894
+ type: "string",
895
+ enum: ["h", "v", "hv"]
896
+ },
897
+ gamma: {
898
+ type: "number"
899
+ },
900
+ segment: {
901
+ type: "string",
902
+ enum: ["foreground"]
903
+ },
904
+ gravity: {
905
+ oneOf: [
906
+ {
907
+ type: "string",
908
+ enum: ["face", "left", "right", "top", "bottom", "center", "auto", "entropy"]
909
+ },
910
+ {
911
+ type: "object",
912
+ properties: {
913
+ mode: {
914
+ type: "string",
915
+ enum: ["remainder", "box-center"]
916
+ },
917
+ x: {
918
+ type: "number"
919
+ },
920
+ y: {
921
+ type: "number"
922
+ }
923
+ },
924
+ required: ["mode"]
925
+ }
926
+ ]
927
+ },
928
+ rotate: {
929
+ type: "integer",
930
+ enum: [0, 90, 180, 270]
931
+ },
932
+ saturation: {
933
+ type: "number"
934
+ },
935
+ sharpen: {
936
+ type: "number"
937
+ },
938
+ trim: {
939
+ oneOf: [
940
+ {
941
+ type: "string",
942
+ enum: ["border"]
943
+ },
944
+ {
945
+ type: "object",
946
+ properties: {
947
+ top: {
948
+ type: "number"
949
+ },
950
+ bottom: {
951
+ type: "number"
952
+ },
953
+ left: {
954
+ type: "number"
955
+ },
956
+ right: {
957
+ type: "number"
958
+ },
959
+ width: {
960
+ type: "number"
961
+ },
962
+ height: {
963
+ type: "number"
964
+ },
965
+ border: {
966
+ oneOf: [
967
+ {
968
+ type: "boolean"
969
+ },
970
+ {
971
+ type: "object",
972
+ properties: {
973
+ color: {
974
+ type: "string"
975
+ },
976
+ tolerance: {
977
+ type: "number"
978
+ },
979
+ keep: {
980
+ type: "number"
981
+ }
982
+ }
983
+ }
984
+ ]
985
+ }
986
+ }
987
+ }
988
+ ]
989
+ }
990
+ }
991
+ };
992
+
993
+ // src/client/CalmLensUploadMimeTypes.ts
994
+ var UPLOAD_MIME_REJECTED = [
995
+ "application/octet-stream",
996
+ "multipart/form-data",
997
+ "multipart/mixed",
998
+ "multipart/alternative",
999
+ "multipart/related",
1000
+ "multipart/signed",
1001
+ "multipart/encrypted"
1002
+ ];
1003
+ var UPLOAD_MIME_PREFIXES = ["image/", "video/", "audio/", "text/"];
1004
+ var UPLOAD_MIME_SUFFIXES = ["+json", "+xml"];
1005
+ var UPLOAD_MIME_TYPES = [
1006
+ "application/pdf",
1007
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
1008
+ "application/msword",
1009
+ "application/rtf",
1010
+ "application/vnd.oasis.opendocument.text",
1011
+ "application/javascript",
1012
+ "application/json",
1013
+ "application/x-javascript",
1014
+ "application/x-yaml",
1015
+ "application/xml",
1016
+ "application/yaml"
1017
+ ];
1018
+
823
1019
  // src/client/CalmLensViewerClaims.ts
824
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(" "));
825
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(" "));
@@ -954,6 +1150,12 @@ var encodePathSegment = (value, name) => {
954
1150
  throw invalidArgument(`${name} cannot be "." or ".."`);
955
1151
  return encodeURIComponent(value);
956
1152
  };
1153
+ var isAcceptedUploadMimeType = (mimeType) => {
1154
+ const type = normalizeUploadMimeType(mimeType);
1155
+ if (UPLOAD_MIME_REJECTED.includes(type))
1156
+ return false;
1157
+ return UPLOAD_MIME_PREFIXES.some((prefix) => type.startsWith(prefix)) || UPLOAD_MIME_SUFFIXES.some((suffix) => type.endsWith(suffix)) || UPLOAD_MIME_TYPES.includes(type);
1158
+ };
957
1159
  var TRANSFORM_OPTION_NAME = /^[a-z][a-zA-Z0-9]*$/;
958
1160
  var TRANSFORM_COLOUR_KEYS = new Set(["background", "border.color", "trim.border.color"]);
959
1161
  var HEX_COLOUR = /^#((?:[0-9a-f]{3}){1,2}|(?:[0-9a-f]{4}){1,2})$/i;
@@ -983,9 +1185,65 @@ var appendTransformOptions = (pairs, key, value) => {
983
1185
  throw invalidArgument(`Transform option "${key}" must be a string, number, boolean or object`);
984
1186
  pairs.push(`${key}=${encodeTransformComponent(text)}`);
985
1187
  };
1188
+ var hasRuleType = (type, value) => {
1189
+ switch (type) {
1190
+ case "object":
1191
+ return isPlainObject(value);
1192
+ case "string":
1193
+ case "boolean":
1194
+ return typeof value === type;
1195
+ case "number":
1196
+ return typeof value === "number" && Number.isFinite(value);
1197
+ case "integer":
1198
+ return typeof value === "number" && Number.isInteger(value);
1199
+ default:
1200
+ return true;
1201
+ }
1202
+ };
1203
+ var checkTransformOptions = (options) => {
1204
+ const unknownKeys = [];
1205
+ const invalidKeys = [];
1206
+ const check = (schema, value, key) => {
1207
+ const rule = schema.oneOf ? schema.oneOf.find(({ type }) => hasRuleType(type, value)) : schema;
1208
+ if (!rule || !hasRuleType(rule.type, value) || rule.enum && !rule.enum.includes(value) || rule.minimum !== undefined && value < rule.minimum || rule.maximum !== undefined && value > rule.maximum) {
1209
+ invalidKeys.push(key);
1210
+ return;
1211
+ }
1212
+ if (rule.type !== "object")
1213
+ return;
1214
+ const object = value;
1215
+ const path = (name) => key ? `${key}.${name}` : name;
1216
+ for (const name of rule.required ?? []) {
1217
+ if (object[name] === undefined || object[name] === null)
1218
+ invalidKeys.push(path(name));
1219
+ }
1220
+ for (const name of Object.keys(object).sort()) {
1221
+ if (object[name] === undefined || object[name] === null)
1222
+ continue;
1223
+ const child = rule.properties?.[name];
1224
+ if (child)
1225
+ check(child, object[name], path(name));
1226
+ else
1227
+ unknownKeys.push(path(name));
1228
+ }
1229
+ };
1230
+ check(TRANSFORM_OPTIONS_SCHEMA, options, "");
1231
+ return { unknownKeys, invalidKeys };
1232
+ };
1233
+ var assertTransformOptions = (options) => {
1234
+ const { unknownKeys, invalidKeys } = checkTransformOptions(options);
1235
+ if (!unknownKeys.length && !invalidKeys.length)
1236
+ return;
1237
+ const problems = [
1238
+ ...unknownKeys.length ? [`unknown option${unknownKeys.length > 1 ? "s" : ""} ${unknownKeys.join(", ")}`] : [],
1239
+ ...invalidKeys.length ? [`invalid value${invalidKeys.length > 1 ? "s" : ""} for ${invalidKeys.join(", ")}`] : []
1240
+ ];
1241
+ throw invalidArgument(`Transform options are invalid: ${problems.join("; ")}. Pass the options themselves, such as { width: 640, format: "webp" }.`, { unknownKeys, invalidKeys });
1242
+ };
986
1243
  var serializeTransform = (transform) => {
987
1244
  if (!isPlainObject(transform))
988
1245
  throw invalidArgument("Transform options must be an object");
1246
+ assertTransformOptions(transform);
989
1247
  const pairs = [];
990
1248
  for (const key of Object.keys(transform).sort()) {
991
1249
  if (!TRANSFORM_OPTION_NAME.test(key)) {
@@ -1199,7 +1457,7 @@ var setOptionalQueryValue = (params, key, value) => {
1199
1457
  }
1200
1458
  };
1201
1459
  var assertValidUploadMimeType = (mimeType) => {
1202
- if (isRejectedUploadMimeType(mimeType)) {
1460
+ if (!isAcceptedUploadMimeType(mimeType)) {
1203
1461
  throw new CalmLensError(API_ERROR_CODES.INVALID_UPLOAD_MIME_TYPE, {
1204
1462
  message: getRejectedUploadMimeTypeError(mimeType),
1205
1463
  details: { mimeType }
@@ -1539,6 +1797,20 @@ var SERVER_OPTION_KEYS = {
1539
1797
  "policies.update": ["description", "name", "policyId", "revision", "settings"],
1540
1798
  "text.classify": ["authorId", "context", "description", "externalId", "externalUrl", "folderId", "metadata", "name", "processingOptions", "text", "uploadPresetId", "visibility"]
1541
1799
  };
1800
+ 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", "folderId"],
1804
+ "assets.list": ["filter", "folderId"],
1805
+ "assets.move": ["folderId"],
1806
+ "assets.update": ["description", "externalId", "externalUrl", "metadata", "tags", "visibility"],
1807
+ "folders.create": ["parentId"],
1808
+ "folders.move": ["parentId"],
1809
+ "hashLists.addEntry": ["label", "quality"],
1810
+ "hashLists.create": ["description"],
1811
+ "hashLists.update": ["description"],
1812
+ "text.classify": ["authorId", "context", "description", "externalId", "folderId", "metadata", "processingOptions", "uploadPresetId", "visibility"]
1813
+ };
1542
1814
 
1543
1815
  // src/contract/CryptoUtils-B_x8lMIx.js
1544
1816
  var encoder = new TextEncoder;
@@ -1671,7 +1943,10 @@ var getEnsureLensCacheKey = (options) => stringifyJsonCanonical({
1671
1943
  var requireId = (value, name) => encodePathSegment(value, name);
1672
1944
  var checked = (operation, options) => {
1673
1945
  checkOptionKeys(options, operation, SERVER_OPTION_KEYS);
1674
- return options;
1946
+ if (!options || typeof options !== "object" || Array.isArray(options))
1947
+ return options;
1948
+ const nullable = NULLABLE_OPTION_KEYS[operation] ?? [];
1949
+ return Object.fromEntries(Object.entries(options).filter(([key, value]) => value !== null || nullable.includes(key)));
1675
1950
  };
1676
1951
  var assertNewCursor = (sent, cursor) => {
1677
1952
  if (sent.has(cursor)) {
@@ -1817,8 +2092,8 @@ class CalmLensServerClient {
1817
2092
  return this.iteratePages((cursor) => this.buildAssets().listChildren({ ...options, cursor }));
1818
2093
  },
1819
2094
  create: async (options) => this.submitAsset(checked("assets.create", options), true),
1820
- classify: async (options) => {
1821
- checked("assets.classify", options);
2095
+ classify: async (classifyOptions) => {
2096
+ const options = checked("assets.classify", classifyOptions);
1822
2097
  if (options && "content" in options && "plainText" in options.content && (typeof options.content.plainText !== "string" || !options.content.plainText.trim())) {
1823
2098
  throw invalidPayload("Text to classify must be a non-empty string");
1824
2099
  }
@@ -7488,7 +7763,7 @@ var TEST_REGIONAL_ACTIONS_SCHEMA = array(object({
7488
7763
  ])
7489
7764
  }).strict()).max(7).refine((entries) => new Set(entries.map((entry) => entry.region)).size === entries.length, "Choose each region once");
7490
7765
 
7491
- // src/contract/TestTriggers-CMwMrbjy.js
7766
+ // src/contract/TestTriggers-DbhsNPdg.js
7492
7767
  var TEST_IMAGE_GRID_LEVELS = [
7493
7768
  72,
7494
7769
  128,
@@ -7544,7 +7819,7 @@ function testInputForSignal(signal, kind = "text") {
7544
7819
  case "violence.graphic":
7545
7820
  return { instances: [{
7546
7821
  category: "violence",
7547
- qualifiers: ["violence-graphic"]
7822
+ qualifiers: ["violence-injury", "violence-graphic"]
7548
7823
  }] };
7549
7824
  default:
7550
7825
  return TEST_INPUT_SCHEMA.parse({ instances: [{
@@ -1,5 +1,5 @@
1
- import { F as UploadFile, I as UploadItem$1, L as UploadSnapshot$1, N as UploadController, P as UploadControllerOptions$1, k as CalmLensUpload$1, p as UploaderProps$1 } from "./ui-B23r8BvW.js";
2
- import { t as UseCalmLensUploadResult$1 } from "./ReactUpload-huIMnOJ4.js";
1
+ import { F as UploadFile, I as UploadItem$1, L as UploadSnapshot$1, N as UploadController, P as UploadControllerOptions$1, k as CalmLensUpload$1, p as UploaderProps$1 } from "./ui-BSqPGKrZ.js";
2
+ import { t as UseCalmLensUploadResult$1 } from "./ReactUpload-CRJNPB5T.js";
3
3
  type UploadItem<F extends UploadFile = File> = UploadItem$1<F>;
4
4
  type CalmLensUpload<F extends UploadFile = File> = CalmLensUpload$1<F>;
5
5
  type UploadSnapshot<F extends UploadFile = File> = UploadSnapshot$1<F>;
@@ -1,4 +1,4 @@
1
- const require_UploadController = require("./UploadController-D4qOZZc3.js");
1
+ const require_UploadController = require("./UploadController-MLVs97Zt.js");
2
2
  // src/ui/BrowserUpload.ts
3
3
  /** Creates an upload queue for the browser components, such as one a form starts on submit. */
4
4
  const createUploadController = (options) => require_UploadController.createUploadController(options);
@@ -1,4 +1,4 @@
1
- import { At as UploadedAsset, E as CalmLensAppClientOptions, Ot as UploadAssetPartOptions, gt as RetrieveAssetOptions, kt as UploadPresetSubmitAssetOptions } from "./CalmLensTypes-DpU-hXq2.js";
1
+ import { At as UploadedAsset, E as CalmLensAppClientOptions, Ot as UploadAssetPartOptions, gt as RetrieveAssetOptions, kt as UploadPresetSubmitAssetOptions } from "./CalmLensTypes-COJbOuiv.js";
2
2
  declare const inspectSymbol: unique symbol;
3
3
  /**
4
4
  * The CalmLens client for browsers and React Native apps. It uploads through an upload preset,
@@ -1,5 +1,5 @@
1
- const require_ModerationContextLimits = require("./ModerationContextLimits-FDpQmw_T.js");
2
- const require_CalmLensOptionKeys = require("./CalmLensOptionKeys-BUj7v5AG.js");
1
+ const require_ModerationContextLimits = require("./ModerationContextLimits-2nIv7Zh3.js");
2
+ const require_CalmLensOptionKeys = require("./CalmLensOptionKeys-p2QK687A.js");
3
3
  // src/client/CalmLensAppClient.ts
4
4
  const inspectSymbol = Symbol.for("nodejs.util.inspect.custom");
5
5
  /** `options`, once `checkOptionKeys` finds only keys `operation` takes. */
@@ -1,4 +1,4 @@
1
- const require_ModerationContextLimits = require("./ModerationContextLimits-FDpQmw_T.js");
1
+ const require_ModerationContextLimits = require("./ModerationContextLimits-2nIv7Zh3.js");
2
2
  // src/contract/AssetPayload.js
3
3
  const bufferInputToBytes = (value) => {
4
4
  if (value instanceof ArrayBuffer) return new Uint8Array(value);
@@ -419,7 +419,7 @@ const setOptionalQueryValue = (params, key, value) => {
419
419
  if (value !== void 0 && value !== null) params.set(key, typeof value === "string" ? value : JSON.stringify(value));
420
420
  };
421
421
  const assertValidUploadMimeType = (mimeType) => {
422
- if (require_ModerationContextLimits.isRejectedUploadMimeType(mimeType)) throw new require_ModerationContextLimits.CalmLensError(require_ModerationContextLimits.API_ERROR_CODES.INVALID_UPLOAD_MIME_TYPE, {
422
+ if (!require_ModerationContextLimits.isAcceptedUploadMimeType(mimeType)) throw new require_ModerationContextLimits.CalmLensError(require_ModerationContextLimits.API_ERROR_CODES.INVALID_UPLOAD_MIME_TYPE, {
423
423
  message: require_ModerationContextLimits.getRejectedUploadMimeTypeError(mimeType),
424
424
  details: { mimeType }
425
425
  });
@@ -921,6 +921,61 @@ const APP_OPTION_KEYS = {
921
921
  "queue"
922
922
  ]
923
923
  };
924
+ /**
925
+ * The option keys each `CalmLensServerClient` method sends as `null` when given `null`; any
926
+ * other option given as `null` is left out, as the API refuses `null` for it.
927
+ */
928
+ const NULLABLE_OPTION_KEYS = {
929
+ "assets.classify": [
930
+ "authorId",
931
+ "context",
932
+ "description",
933
+ "externalId",
934
+ "folderId",
935
+ "metadata",
936
+ "processingOptions",
937
+ "uploadPresetId",
938
+ "visibility"
939
+ ],
940
+ "assets.create": [
941
+ "authorId",
942
+ "context",
943
+ "description",
944
+ "externalId",
945
+ "folderId",
946
+ "metadata",
947
+ "processingOptions",
948
+ "uploadPresetId",
949
+ "visibility"
950
+ ],
951
+ "assets.iterate": ["filter", "folderId"],
952
+ "assets.list": ["filter", "folderId"],
953
+ "assets.move": ["folderId"],
954
+ "assets.update": [
955
+ "description",
956
+ "externalId",
957
+ "externalUrl",
958
+ "metadata",
959
+ "tags",
960
+ "visibility"
961
+ ],
962
+ "folders.create": ["parentId"],
963
+ "folders.move": ["parentId"],
964
+ "hashLists.addEntry": ["label", "quality"],
965
+ "hashLists.create": ["description"],
966
+ "hashLists.update": ["description"],
967
+ "text.classify": [
968
+ "authorId",
969
+ "context",
970
+ "description",
971
+ "externalId",
972
+ "folderId",
973
+ "metadata",
974
+ "processingOptions",
975
+ "uploadPresetId",
976
+ "visibility"
977
+ ]
978
+ };
924
979
  Object.defineProperty(exports, "APP_OPTION_KEYS", {
925
980
  enumerable: true,
926
981
  get: function() {
@@ -939,6 +994,12 @@ Object.defineProperty(exports, "MOCK_HOOKS", {
939
994
  return MOCK_HOOKS;
940
995
  }
941
996
  });
997
+ Object.defineProperty(exports, "NULLABLE_OPTION_KEYS", {
998
+ enumerable: true,
999
+ get: function() {
1000
+ return NULLABLE_OPTION_KEYS;
1001
+ }
1002
+ });
942
1003
  Object.defineProperty(exports, "SERVER_OPTION_KEYS", {
943
1004
  enumerable: true,
944
1005
  get: function() {
@@ -1,5 +1,5 @@
1
- const require_ModerationContextLimits = require("./ModerationContextLimits-FDpQmw_T.js");
2
- const require_CalmLensOptionKeys = require("./CalmLensOptionKeys-BUj7v5AG.js");
1
+ const require_ModerationContextLimits = require("./ModerationContextLimits-2nIv7Zh3.js");
2
+ const require_CalmLensOptionKeys = require("./CalmLensOptionKeys-p2QK687A.js");
3
3
  const require_CryptoUtils_B_x8lMIx = require("./CryptoUtils-B_x8lMIx-YBW1-bvL.js");
4
4
  // src/contract/JsonUtils.js
5
5
  const stringifyJsonCanonical = (value) => JSON.stringify(value, (_key, nestedValue) => {
@@ -146,10 +146,15 @@ const getEnsureLensCacheKey = (options) => stringifyJsonCanonical({
146
146
  version: options.version
147
147
  });
148
148
  const requireId = (value, name) => require_ModerationContextLimits.encodePathSegment(value, name);
149
- /** `options`, once `checkOptionKeys` finds only keys `operation` takes. */
149
+ /**
150
+ * `options`, once `checkOptionKeys` finds only keys `operation` takes, without the options given as
151
+ * `null` that the API refuses as `null`: those are left out, as if omitted.
152
+ */
150
153
  const checked = (operation, options) => {
151
154
  require_ModerationContextLimits.checkOptionKeys(options, operation, require_CalmLensOptionKeys.SERVER_OPTION_KEYS);
152
- return options;
155
+ if (!options || typeof options !== "object" || Array.isArray(options)) return options;
156
+ const nullable = require_CalmLensOptionKeys.NULLABLE_OPTION_KEYS[operation] ?? [];
157
+ return Object.fromEntries(Object.entries(options).filter(([key, value]) => value !== null || nullable.includes(key)));
153
158
  };
154
159
  /**
155
160
  * Iterators stop rather than loop: a page that says more follow must not hand back a cursor this
@@ -377,8 +382,8 @@ sign: async (options) => {
377
382
  * Uploads an asset and waits for its moderation decision. Audio and video still finish
378
383
  * in the background. Retried safely with an `Idempotency-Key`.
379
384
  */
380
- classify: async (options) => {
381
- checked("assets.classify", options);
385
+ classify: async (classifyOptions) => {
386
+ const options = checked("assets.classify", classifyOptions);
382
387
  if (options && "content" in options && "plainText" in options.content && (typeof options.content.plainText !== "string" || !options.content.plainText.trim())) throw require_CalmLensOptionKeys.invalidPayload("Text to classify must be a non-empty string");
383
388
  return this.submitAsset(options, false);
384
389
  },
@@ -621,7 +626,7 @@ sign: async (options) => {
621
626
  const { policyId, ...body } = checked("policies.applyPreset", options);
622
627
  return this.request("POST", `${policyPath(policyId)}/preset`, { body });
623
628
  },
624
- /** Switches automatic updates on or off for the project's preset policy. */
629
+ /** Switches automatic updates on or off for the organisation's own preset policy. */
625
630
  setAutomaticUpdates: async (options) => {
626
631
  const { policyId, ...body } = checked("policies.setAutomaticUpdates", options);
627
632
  return this.request("PUT", `${policyPath(policyId)}/automatic-updates`, { body });
@@ -1,6 +1,6 @@
1
1
  import { o as HashList, s as HashListEntry } from "./ModerationContext-9lGm-Mna-CcmbRnOy.js";
2
- import { A as CdnServeOptions, B as DeleteAssetContentOptions, C as AssignPolicyOptions, Ct as SubmitAssetOptions, D as CalmLensServerClientOptions, Dt as UpdatePolicyOptions, Et as UpdateHashListOptions, F as CreateFolderOptions, G as FolderIdOptions, H as EnsureLensOptions, I as CreateHashListOptions, J as HashListEntryIdOptions, Jt as Folder, K as FolderPage, Lt as GetEventsResponse, M as ClassifyTextOptions, Nt as WaitForAssetDecisionOptions, O as CdnAssetUrlOptions, Ot as UploadAssetPartOptions, P as CreateAssetSignedUrlOptions, R as CreatePolicyOptions, Rt as PostAssetSignedUrlResponse, T as BatchAssetsResponse, Tt as UpdateFolderOptions, U as EnsureLensesOptions, V as DeleteAssetOptions, W as ExplainAssetOptions, X as HashListIdOptions, Y as HashListEntryPage, Yt as Policy, Z as HashListPage, _ as AssetSearchResponse, _t as RetryAssetOptions, a as AssetChildrenPage, at as ListEventsOptions, bt as SignUploadTokenOptions, ct as ListHashListsOptions, en as AssetSearchQuery, et as IterateAssetChildrenOptions, g as AssetPage, gt as RetrieveAssetOptions, ht as RequestOptions, it as ListAssetsOptions, jt as VerifyWebhookSignatureOptions, lt as MoveAssetOptions, mt as PolicyList, n as ApplyPolicyPresetOptions, nt as Lens, ot as ListFoldersOptions, pt as PolicyIdOptions, r as Asset, rt as ListAssetChildrenOptions, st as ListHashListEntriesOptions, t as AddHashListEntryOptions, tt as IterateAssetsOptions, ut as MoveFolderOptions, w as BatchAssetsOptions, wt as UpdateAssetOptions, xt as SignedUploadToken, yt as SetPolicyAutomaticUpdatesOptions, z as DecideAssetOptions } from "./CalmLensTypes-DpU-hXq2.js";
3
- import "./WebhookPayload-CQg8BBZQ.js";
2
+ import { A as CdnServeOptions, B as DeleteAssetContentOptions, C as AssignPolicyOptions, Ct as SubmitAssetOptions, D as CalmLensServerClientOptions, Dt as UpdatePolicyOptions, Et as UpdateHashListOptions, F as CreateFolderOptions, G as FolderIdOptions, H as EnsureLensOptions, I as CreateHashListOptions, J as HashListEntryIdOptions, Jt as Folder, K as FolderPage, Lt as GetEventsResponse, M as ClassifyTextOptions, Nt as WaitForAssetDecisionOptions, O as CdnAssetUrlOptions, Ot as UploadAssetPartOptions, P as CreateAssetSignedUrlOptions, R as CreatePolicyOptions, Rt as PostAssetSignedUrlResponse, T as BatchAssetsResponse, Tt as UpdateFolderOptions, U as EnsureLensesOptions, V as DeleteAssetOptions, W as ExplainAssetOptions, X as HashListIdOptions, Y as HashListEntryPage, Yt as Policy, Z as HashListPage, _ as AssetSearchResponse, _t as RetryAssetOptions, a as AssetChildrenPage, at as ListEventsOptions, bt as SignUploadTokenOptions, ct as ListHashListsOptions, en as AssetSearchQuery, et as IterateAssetChildrenOptions, g as AssetPage, gt as RetrieveAssetOptions, ht as RequestOptions, it as ListAssetsOptions, jt as VerifyWebhookSignatureOptions, lt as MoveAssetOptions, mt as PolicyList, n as ApplyPolicyPresetOptions, nt as Lens, ot as ListFoldersOptions, pt as PolicyIdOptions, r as Asset, rt as ListAssetChildrenOptions, st as ListHashListEntriesOptions, t as AddHashListEntryOptions, tt as IterateAssetsOptions, ut as MoveFolderOptions, w as BatchAssetsOptions, wt as UpdateAssetOptions, xt as SignedUploadToken, yt as SetPolicyAutomaticUpdatesOptions, z as DecideAssetOptions } from "./CalmLensTypes-COJbOuiv.js";
3
+ import "./WebhookPayload-DkukERKE.js";
4
4
  interface LensCache {
5
5
  readonly ensuredLenses: Map<string, Lens>;
6
6
  readonly pendingEnsureLenses: Map<string, Promise<void>>;
@@ -100,7 +100,7 @@ declare class CalmLensServerClient {
100
100
  * Uploads an asset and waits for its moderation decision. Audio and video still finish
101
101
  * in the background. Retried safely with an `Idempotency-Key`.
102
102
  */
103
- classify: (options: SubmitAssetOptions) => Promise<Asset>;
103
+ classify: (classifyOptions: SubmitAssetOptions) => Promise<Asset>;
104
104
  /**
105
105
  * Uploads the next part of a multipart upload. The upload's queue mode, chosen when it
106
106
  * started, applies when the final part arrives; pass `queue` to override it.
@@ -235,7 +235,7 @@ declare class CalmLensServerClient {
235
235
  update: (options: UpdatePolicyOptions) => Promise<Policy>;
236
236
  /** Resets a preset copy to its pinned version, or updates an unchanged copy to the latest. */
237
237
  applyPreset: (options: ApplyPolicyPresetOptions) => Promise<Policy>;
238
- /** Switches automatic updates on or off for the project's preset policy. */
238
+ /** Switches automatic updates on or off for the organisation's own preset policy. */
239
239
  setAutomaticUpdates: (options: SetPolicyAutomaticUpdatesOptions) => Promise<Policy>;
240
240
  /** Deletes a policy that no project or upload preset uses. */
241
241
  delete: (options: PolicyIdOptions) => Promise<void>;
@@ -38198,7 +38198,7 @@ declare const POLICY_SCHEMA: zod.ZodObject<{
38198
38198
  }>;
38199
38199
  version: zod.ZodNumber;
38200
38200
  latestVersion: zod.ZodNumber;
38201
- projectId: zod.ZodNullable<zod.ZodString>;
38201
+ own: zod.ZodBoolean;
38202
38202
  }, zod.core.$strip>>;
38203
38203
  projectIds: zod.ZodArray<zod.ZodString>;
38204
38204
  createdAt: zod.ZodNumber;
@@ -38833,7 +38833,7 @@ declare const GET_POLICIES_RESPONSE_SCHEMA: zod.ZodObject<{
38833
38833
  }>;
38834
38834
  version: zod.ZodNumber;
38835
38835
  latestVersion: zod.ZodNumber;
38836
- projectId: zod.ZodNullable<zod.ZodString>;
38836
+ own: zod.ZodBoolean;
38837
38837
  }, zod.core.$strip>>;
38838
38838
  projectIds: zod.ZodArray<zod.ZodString>;
38839
38839
  createdAt: zod.ZodNumber;