calmlens 0.29.1 → 0.29.2

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 (50) hide show
  1. package/bin/calmlens.js +24 -2
  2. package/cjs/{BrowserUpload-CsxEB1Pr.js → BrowserUpload-CCXt4DAY.js} +1 -1
  3. package/cjs/{CalmLensAppClient-BWMcQM9v.js → CalmLensAppClient-ea-qXkmD.js} +7 -6
  4. package/cjs/{CalmLensConnection-DBgV8D1B.js → CalmLensConnection-BrySN2M3.js} +29 -28
  5. package/cjs/CalmLensError-DPHJaVjX.js +1066 -0
  6. package/cjs/{CalmLensServerClient-DYO3geSA.js → CalmLensServerClient-FD7H7KvL.js} +21 -20
  7. package/cjs/{TestTriggers-uL2Ec8Vt-cPmmKvYd.js → CalmLensTestInputArguments-BXDBAOg_.js} +50 -22
  8. package/cjs/{Core-Bl-aESvN.js → Core-DMFa3EUp.js} +4 -3
  9. package/cjs/{ModerationContextLimits-DHu2jHpo.js → ModerationContextLimits-1XP4ZTQk.js} +67 -1126
  10. package/cjs/{ReactUpload-BFVNyWoI.js → ReactUpload-gaeiPSeH.js} +1 -1
  11. package/cjs/{TestTriggers-dognME9k-PWyIfHMI.d.ts → TestTriggers-CFnel6a9.d.ts} +1 -2
  12. package/cjs/{UploadController-VM1qYwNq.js → UploadController-CyPTBuZg.js} +6 -6
  13. package/cjs/app.js +22 -21
  14. package/cjs/elements.js +4 -4
  15. package/cjs/index.js +21 -20
  16. package/cjs/react-native.js +4 -4
  17. package/cjs/react.js +5 -5
  18. package/cjs/server.js +22 -21
  19. package/cjs/test-inputs.d.ts +6 -2
  20. package/cjs/test-inputs.js +23 -13
  21. package/cjs/testing.d.ts +3 -3
  22. package/cjs/testing.js +138 -133
  23. package/cjs/{ui-BCiLF8cU.js → ui-DNP1uWQy.js} +2 -2
  24. package/cjs/ui.js +3 -3
  25. package/cjs/vue.js +4 -4
  26. package/esm/{BrowserUpload-DB3WpaC1.js → BrowserUpload-Bu6eWqQS.js} +1 -1
  27. package/esm/{CalmLensAppClient-Dg-jPs4B.js → CalmLensAppClient-xp-fH6Lz.js} +3 -2
  28. package/esm/{CalmLensConnection-Di7K7Wnl.js → CalmLensConnection-DwG5yBk2.js} +2 -1
  29. package/esm/CalmLensError-BDWThPCr.js +917 -0
  30. package/esm/{CalmLensServerClient-Pdp7TI8y.js → CalmLensServerClient-CKlNBBo3.js} +3 -2
  31. package/esm/{TestTriggers-uL2Ec8Vt-DYbTEJWm.js → CalmLensTestInputArguments-Xh4GIadS.js} +22 -1
  32. package/esm/{Core-CKk4teFu.js → Core-DnCeTmvS.js} +3 -2
  33. package/esm/{ModerationContextLimits-xvxUjGfL.js → ModerationContextLimits-CtAyz60h.js} +3 -918
  34. package/esm/{ReactUpload-DY5qQ70s.js → ReactUpload-D30YlRui.js} +1 -1
  35. package/esm/{TestTriggers-dognME9k-PWyIfHMI.d.ts → TestTriggers-CFnel6a9.d.ts} +1 -2
  36. package/esm/{UploadController-wyor-5Z2.js → UploadController-DENryQ8H.js} +2 -2
  37. package/esm/app.js +3 -2
  38. package/esm/elements.js +4 -4
  39. package/esm/index.js +3 -1
  40. package/esm/react-native.js +4 -4
  41. package/esm/react.js +5 -5
  42. package/esm/server.js +3 -2
  43. package/esm/test-inputs.d.ts +6 -2
  44. package/esm/test-inputs.js +12 -1
  45. package/esm/testing.d.ts +3 -3
  46. package/esm/testing.js +11 -7
  47. package/esm/{ui-BqF49fSy.js → ui-DUEBbRJ0.js} +2 -2
  48. package/esm/ui.js +3 -3
  49. package/esm/vue.js +4 -4
  50. package/package.json +1 -1
package/bin/calmlens.js CHANGED
@@ -3,7 +3,7 @@
3
3
  import { readFile as readFile2 } from "node:fs/promises";
4
4
  import { parseArgs } from "node:util";
5
5
  // package.json
6
- var version = "0.29.1";
6
+ var version = "0.29.2";
7
7
 
8
8
  // src/contract/ModerationCategories-CHFRoeWV.js
9
9
  var CLASSIFICATION_CATEGORIES = [
@@ -8016,6 +8016,7 @@ var initializer2 = (inst, issues) => {
8016
8016
  }
8017
8017
  });
8018
8018
  };
8019
+ var ZodError = /* @__PURE__ */ $constructor("ZodError", initializer2);
8019
8020
  var ZodRealError = /* @__PURE__ */ $constructor("ZodError", initializer2, undefined, {
8020
8021
  Parent: Error
8021
8022
  });
@@ -10348,6 +10349,27 @@ async function generateTestTextCode(scenario, key) {
10348
10349
  throw new RangeError("Test scenario is too large");
10349
10350
  return `<!calmlens-test ${await tag(payload, key)} ${payload}>`;
10350
10351
  }
10352
+ // src/client/CalmLensTestInputArguments.ts
10353
+ async function withValidTestInputArguments(key, generate) {
10354
+ if (!TEST_INPUT_KEY_PATTERN.test(key))
10355
+ throw invalidArgument("key must be a test input key: 32 lowercase hexadecimal characters");
10356
+ try {
10357
+ return await generate();
10358
+ } catch (error) {
10359
+ if (error instanceof ZodError) {
10360
+ const [issue] = error.issues;
10361
+ const path = (issue?.path ?? []).map((segment) => typeof segment === "number" ? segment : String(segment));
10362
+ throw invalidArgument(`Invalid test scenario at ${path.length ? path.join(".") : "scenario"}: ${issue?.message ?? error.message}`, { path });
10363
+ }
10364
+ if (error instanceof RangeError)
10365
+ throw invalidArgument(error.message);
10366
+ throw error;
10367
+ }
10368
+ }
10369
+
10370
+ // src/test-inputs.ts
10371
+ var generateTestTextCode2 = (scenario, key) => withValidTestInputArguments(key, () => generateTestTextCode(scenario, key));
10372
+
10351
10373
  // src/cli/configuration.ts
10352
10374
  class ConfigurationError extends Error {
10353
10375
  }
@@ -19549,7 +19571,7 @@ var main = async () => {
19549
19571
  if (!TEST_INPUT_KEY_PATTERN.test(testInputKey))
19550
19572
  fail(`"${testInputKey}" isn't a test input key: it is 32 lowercase hexadecimal characters.
19551
19573
  ` + "Copy it from Project settings → Test inputs in the CalmLens portal.");
19552
- text = await generateTestTextCode(kind, testInputKey);
19574
+ text = await generateTestTextCode2(kind, testInputKey);
19553
19575
  }
19554
19576
  try {
19555
19577
  const asset = await client.assets.classify({
@@ -1,4 +1,4 @@
1
- const require_UploadController = require("./UploadController-VM1qYwNq.js");
1
+ const require_UploadController = require("./UploadController-CyPTBuZg.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,5 +1,6 @@
1
- const require_ModerationContextLimits = require("./ModerationContextLimits-DHu2jHpo.js");
2
- const require_CalmLensConnection = require("./CalmLensConnection-DBgV8D1B.js");
1
+ const require_CalmLensError = require("./CalmLensError-DPHJaVjX.js");
2
+ const require_ModerationContextLimits = require("./ModerationContextLimits-1XP4ZTQk.js");
3
+ const require_CalmLensConnection = require("./CalmLensConnection-BrySN2M3.js");
3
4
  // src/client/CalmLensAppClient.ts
4
5
  const inspectSymbol = Symbol.for("nodejs.util.inspect.custom");
5
6
  /** `options`, once `checkOptionKeys` finds only keys `operation` takes. */
@@ -46,7 +47,7 @@ var CalmLensAppClient = class {
46
47
  /** A fresh token for a new upload, when the client has one. */
47
48
  async newUploadToken() {
48
49
  const token = typeof this.#token === "function" ? await this.#token() : this.#token;
49
- if (token !== void 0 && (typeof token !== "string" || !token)) throw require_ModerationContextLimits.invalidConfig("token must return a non-empty string");
50
+ if (token !== void 0 && (typeof token !== "string" || !token)) throw require_CalmLensError.invalidConfig("token must return a non-empty string");
50
51
  return token;
51
52
  }
52
53
  /** The `Authorization` header for an upload this client started. */
@@ -57,8 +58,8 @@ var CalmLensAppClient = class {
57
58
  /** Uploads with a new token, kept for the upload's parts and status checks. */
58
59
  async submit(operation, options, wait, requestOptions) {
59
60
  const connection = this.#connection.forCall(operation, requestOptions);
60
- if (!options || typeof options !== "object") throw require_ModerationContextLimits.invalidArgument("Upload options are required");
61
- if (!("content" in options) && !("part" in options)) throw require_ModerationContextLimits.invalidArgument("Uploads through an upload preset need content or a part");
61
+ if (!options || typeof options !== "object") throw require_CalmLensError.invalidArgument("Upload options are required");
62
+ if (!("content" in options) && !("part" in options)) throw require_CalmLensError.invalidArgument("Uploads through an upload preset need content or a part");
62
63
  const prepared = require_CalmLensConnection.prepareSubmitAssetOptions(options, {
63
64
  deferUploadChecks: connection.deferUploadChecks,
64
65
  partSizeBytes: connection.partSizeBytes
@@ -92,7 +93,7 @@ var CalmLensAppClient = class {
92
93
  getAssetUrl: (urlOptions) => {
93
94
  const { projectId, ...options } = checked("cdn.getAssetUrl", urlOptions);
94
95
  const project = projectId ?? this.#projectId;
95
- if (project === void 0) throw require_ModerationContextLimits.invalidArgument("Pass projectId, here or in the client's options");
96
+ if (project === void 0) throw require_CalmLensError.invalidArgument("Pass projectId, here or in the client's options");
96
97
  return require_ModerationContextLimits.buildAssetUrl(this.#cdnBaseUrl, project, options);
97
98
  } };
98
99
  }
@@ -1,4 +1,5 @@
1
- const require_ModerationContextLimits = require("./ModerationContextLimits-DHu2jHpo.js");
1
+ const require_CalmLensError = require("./CalmLensError-DPHJaVjX.js");
2
+ const require_ModerationContextLimits = require("./ModerationContextLimits-1XP4ZTQk.js");
2
3
  // src/contract/AssetPayload.js
3
4
  const bufferInputToBytes = (value) => {
4
5
  if (value instanceof ArrayBuffer) return new Uint8Array(value);
@@ -494,7 +495,7 @@ const toBodyBytes = (value) => value.buffer instanceof ArrayBuffer ? value : Uin
494
495
  const toUploadData = (payload) => {
495
496
  const data = assetToData(payload);
496
497
  if (data instanceof Response) {
497
- if (!data.body) throw new require_ModerationContextLimits.CalmLensError(require_ModerationContextLimits.API_ERROR_CODES.INVALID_UPLOAD_PAYLOAD, { message: "Response upload data must have a body" });
498
+ if (!data.body) throw new require_CalmLensError.CalmLensError(require_CalmLensError.API_ERROR_CODES.INVALID_UPLOAD_PAYLOAD, { message: "Response upload data must have a body" });
498
499
  return data.body;
499
500
  }
500
501
  if (data instanceof Blob) return data;
@@ -577,7 +578,7 @@ const setOptionalQueryValue = (params, key, value) => {
577
578
  if (value !== void 0 && value !== null) params.set(key, String(value));
578
579
  };
579
580
  const assertValidUploadMimeType = (mimeType) => {
580
- if (!require_ModerationContextLimits.isAcceptedUploadMimeType(mimeType)) throw new require_ModerationContextLimits.CalmLensError(require_ModerationContextLimits.API_ERROR_CODES.UNSUPPORTED_UPLOAD_TYPE, {
581
+ if (!require_ModerationContextLimits.isAcceptedUploadMimeType(mimeType)) throw new require_CalmLensError.CalmLensError(require_CalmLensError.API_ERROR_CODES.UNSUPPORTED_UPLOAD_TYPE, {
581
582
  message: require_ModerationContextLimits.getRejectedUploadMimeTypeError(mimeType),
582
583
  details: {
583
584
  mimeType,
@@ -586,7 +587,7 @@ const assertValidUploadMimeType = (mimeType) => {
586
587
  });
587
588
  };
588
589
  const isImageMimeType = (mimeType) => mimeType.toLowerCase().startsWith("image/");
589
- const invalidPayload = (message) => new require_ModerationContextLimits.CalmLensError(require_ModerationContextLimits.API_ERROR_CODES.INVALID_UPLOAD_PAYLOAD, { message });
590
+ const invalidPayload = (message) => new require_CalmLensError.CalmLensError(require_CalmLensError.API_ERROR_CODES.INVALID_UPLOAD_PAYLOAD, { message });
590
591
  const assertDeclaredPayloadSize = (payload, declared = payload.sizeInBytes) => {
591
592
  if (declared === void 0) return;
592
593
  const data = "data" in payload ? payload.data : void 0;
@@ -604,7 +605,7 @@ const assertUploadSize = (type, size, inParts) => {
604
605
  if (size === void 0) return;
605
606
  const mime = type.toLowerCase();
606
607
  const [limit, message] = mime.startsWith("image/") ? [require_ModerationContextLimits.MAX_DIRECT_IMAGE_UPLOAD_BYTES, "Images uploaded in one request can be at most 10 MiB; upload larger images in parts"] : mime.startsWith("audio/") || mime.startsWith("video/") ? [inParts ? MAX_LONG_MEDIA_UPLOAD_BYTES : MAX_MEDIA_UPLOAD_BYTES, "Audio and video files can be at most 50 MiB in one request, or 2 GiB in parts"] : [require_ModerationContextLimits.MAX_NON_IMAGE_UPLOAD_BYTES, "Files can be at most 5,000 MiB"];
607
- if (size > limit) throw new require_ModerationContextLimits.CalmLensError(require_ModerationContextLimits.API_ERROR_CODES.UPLOAD_TOO_LARGE, {
608
+ if (size > limit) throw new require_CalmLensError.CalmLensError(require_CalmLensError.API_ERROR_CODES.UPLOAD_TOO_LARGE, {
608
609
  message,
609
610
  details: {
610
611
  limitBytes: limit,
@@ -636,18 +637,18 @@ const withContentObject = (options) => {
636
637
  };
637
638
  const prepareSubmitAssetOptions = (input, { deferUploadChecks = false, partSizeBytes = DEFAULT_PART_SIZE_BYTES } = {}) => {
638
639
  const options = withContentObject(input);
639
- if (!options || typeof options !== "object") throw require_ModerationContextLimits.invalidArgument("Asset options are required");
640
+ if (!options || typeof options !== "object") throw require_CalmLensError.invalidArgument("Asset options are required");
640
641
  if (!("content" in options) && !("url" in options) && !("part" in options)) throw invalidPayload("Either file content, URL, or multipart part is required");
641
642
  if (!options.name) throw invalidPayload("Asset name is required");
642
643
  if (!("part" in options) && "isFinal" in options) throw invalidPayload("isFinal is only valid for multipart uploads");
643
- if ("part" in options && options.part.partNumber && options.part.partNumber > 1) throw new require_ModerationContextLimits.CalmLensError(require_ModerationContextLimits.API_ERROR_CODES.USE_UPLOAD_PART, { message: "Use uploadPart for multipart upload parts after the first part" });
644
+ if ("part" in options && options.part.partNumber && options.part.partNumber > 1) throw new require_CalmLensError.CalmLensError(require_CalmLensError.API_ERROR_CODES.USE_UPLOAD_PART, { message: "Use uploadPart for multipart upload parts after the first part" });
644
645
  if ("content" in options) {
645
646
  assertDeclaredPayloadSize(options.content);
646
647
  assertValidUploadMimeType(options.content.type);
647
648
  const inParts = splitsIntoParts(options.content, partSizeBytes);
648
- if (inParts && (options.idempotencyKey?.length ?? 0) > 240) throw require_ModerationContextLimits.invalidArgument(`idempotencyKey can be at most 240 characters for an upload sent in parts`);
649
+ if (inParts && (options.idempotencyKey?.length ?? 0) > 240) throw require_CalmLensError.invalidArgument(`idempotencyKey can be at most 240 characters for an upload sent in parts`);
649
650
  if (!deferUploadChecks && inParts && isImageMimeType(options.content.type)) {
650
- if ((getAssetPayloadByteLength(options.content) ?? 0) > require_ModerationContextLimits.MAX_IMAGE_UPLOAD_BYTES) throw new require_ModerationContextLimits.CalmLensError(require_ModerationContextLimits.API_ERROR_CODES.UPLOAD_TOO_LARGE, {
651
+ if ((getAssetPayloadByteLength(options.content) ?? 0) > require_ModerationContextLimits.MAX_IMAGE_UPLOAD_BYTES) throw new require_CalmLensError.CalmLensError(require_CalmLensError.API_ERROR_CODES.UPLOAD_TOO_LARGE, {
651
652
  message: "Multipart image uploads cannot exceed 20 MiB.",
652
653
  details: {
653
654
  limitBytes: require_ModerationContextLimits.MAX_IMAGE_UPLOAD_BYTES,
@@ -665,7 +666,7 @@ const prepareSubmitAssetOptions = (input, { deferUploadChecks = false, partSizeB
665
666
  assertValidUploadMimeType(options.part.type);
666
667
  const partSizeInBytes = options.part.sizeInBytes ?? getAssetPayloadByteLength(options.part);
667
668
  if (!deferUploadChecks && isImageMimeType(options.part.type) && partSizeInBytes !== void 0) {
668
- if (partSizeInBytes > require_ModerationContextLimits.MAX_IMAGE_UPLOAD_BYTES) throw new require_ModerationContextLimits.CalmLensError(require_ModerationContextLimits.API_ERROR_CODES.UPLOAD_TOO_LARGE, {
669
+ if (partSizeInBytes > require_ModerationContextLimits.MAX_IMAGE_UPLOAD_BYTES) throw new require_CalmLensError.CalmLensError(require_CalmLensError.API_ERROR_CODES.UPLOAD_TOO_LARGE, {
669
670
  message: "Multipart image uploads cannot exceed 20 MiB.",
670
671
  details: {
671
672
  limitBytes: require_ModerationContextLimits.MAX_IMAGE_UPLOAD_BYTES,
@@ -681,7 +682,7 @@ const prepareSubmitAssetOptions = (input, { deferUploadChecks = false, partSizeB
681
682
  if (!validation.ok) throw invalidPayload(validation.error);
682
683
  }
683
684
  if (options.context !== void 0) {
684
- if (!options.context || !Array.isArray(options.context.items)) throw require_ModerationContextLimits.invalidArgument("context.items must be an array of earlier posts");
685
+ if (!options.context || !Array.isArray(options.context.items)) throw require_CalmLensError.invalidArgument("context.items must be an array of earlier posts");
685
686
  return {
686
687
  ...options,
687
688
  context: { items: require_ModerationContextLimits.selectModerationContextItems(options.context.items) }
@@ -700,14 +701,14 @@ const hasDecision = (data) => {
700
701
  const isAsset = (data) => !!data && typeof data === "object" && typeof data.id === "string" && !!data.id && hasStringStatus(data.classification) && hasStringStatus(data.upload) && hasDecision(data);
701
702
  const isUploadedAsset = (data) => !!data && typeof data === "object" && typeof data.id === "string" && !!data.id && hasStringStatus(data.classification) && hasStringStatus(data.upload);
702
703
  const expectUploadedAsset = (data) => {
703
- if (!isUploadedAsset(data)) throw new require_ModerationContextLimits.CalmLensError(require_ModerationContextLimits.SDK_ERROR_CODES.INVALID_RESPONSE, {
704
+ if (!isUploadedAsset(data)) throw new require_CalmLensError.CalmLensError(require_CalmLensError.SDK_ERROR_CODES.INVALID_RESPONSE, {
704
705
  message: "Expected an uploaded asset response",
705
706
  status: 200
706
707
  });
707
708
  return data;
708
709
  };
709
710
  const expectAsset = (data) => {
710
- if (!isAsset(data)) throw new require_ModerationContextLimits.CalmLensError(require_ModerationContextLimits.SDK_ERROR_CODES.INVALID_RESPONSE, {
711
+ if (!isAsset(data)) throw new require_CalmLensError.CalmLensError(require_CalmLensError.SDK_ERROR_CODES.INVALID_RESPONSE, {
711
712
  message: "Expected an asset response",
712
713
  status: 200
713
714
  });
@@ -716,22 +717,22 @@ const expectAsset = (data) => {
716
717
  /** Checks one call's request options. */
717
718
  const validateCallOptions = (options) => {
718
719
  if (options === void 0) return;
719
- if (!options || typeof options !== "object" || Array.isArray(options)) throw require_ModerationContextLimits.invalidArgument("Request options must be an object");
720
+ if (!options || typeof options !== "object" || Array.isArray(options)) throw require_CalmLensError.invalidArgument("Request options must be an object");
720
721
  const unknown = Object.keys(options).filter((key) => !REQUEST_OPTION_KEYS.includes(key));
721
- if (unknown.length) throw require_ModerationContextLimits.invalidArgument(`Unknown request options: ${unknown.join(", ")}`, { options: unknown });
722
+ if (unknown.length) throw require_CalmLensError.invalidArgument(`Unknown request options: ${unknown.join(", ")}`, { options: unknown });
722
723
  const { timeoutMs, deadlineMs, maxRetries, idempotencyKey, headers, extraQuery, extraBody } = options;
723
724
  for (const [name, value] of Object.entries({
724
725
  timeoutMs,
725
726
  deadlineMs
726
- })) if (value !== void 0 && (!Number.isSafeInteger(value) || value < 1)) throw require_ModerationContextLimits.invalidArgument(`${name} must be a positive integer`);
727
- if (maxRetries !== void 0 && (!Number.isSafeInteger(maxRetries) || maxRetries < 0)) throw require_ModerationContextLimits.invalidArgument("maxRetries must be a non-negative integer");
728
- if (idempotencyKey !== void 0 && (typeof idempotencyKey !== "string" || !idempotencyKey)) throw require_ModerationContextLimits.invalidArgument("idempotencyKey must be a non-empty string");
727
+ })) if (value !== void 0 && (!Number.isSafeInteger(value) || value < 1)) throw require_CalmLensError.invalidArgument(`${name} must be a positive integer`);
728
+ if (maxRetries !== void 0 && (!Number.isSafeInteger(maxRetries) || maxRetries < 0)) throw require_CalmLensError.invalidArgument("maxRetries must be a non-negative integer");
729
+ if (idempotencyKey !== void 0 && (typeof idempotencyKey !== "string" || !idempotencyKey)) throw require_CalmLensError.invalidArgument("idempotencyKey must be a non-empty string");
729
730
  for (const [name, value] of Object.entries({
730
731
  headers,
731
732
  extraQuery,
732
733
  extraBody
733
- })) if (value !== void 0 && (!value || typeof value !== "object" || Array.isArray(value))) throw require_ModerationContextLimits.invalidArgument(`${name} must be an object`);
734
- if (options.signal !== void 0 && !(options.signal instanceof AbortSignal)) throw require_ModerationContextLimits.invalidArgument("signal must be an AbortSignal");
734
+ })) if (value !== void 0 && (!value || typeof value !== "object" || Array.isArray(value))) throw require_CalmLensError.invalidArgument(`${name} must be an object`);
735
+ if (options.signal !== void 0 && !(options.signal instanceof AbortSignal)) throw require_CalmLensError.invalidArgument("signal must be an AbortSignal");
735
736
  };
736
737
  const isPlainObject = (value) => !!value && typeof value === "object" && !Array.isArray(value);
737
738
  /** Fills in the default API base URL and drops trailing slashes. */
@@ -752,7 +753,7 @@ var CalmLensConnection = class CalmLensConnection {
752
753
  this.call = {};
753
754
  const resolveFetch = () => {
754
755
  const fetchImpl = this.options.fetch ?? globalThis.fetch;
755
- if (typeof fetchImpl !== "function") throw new require_ModerationContextLimits.CalmLensError(require_ModerationContextLimits.SDK_ERROR_CODES.NO_FETCH, { message: "No fetch implementation is available; pass one as the fetch option" });
756
+ if (typeof fetchImpl !== "function") throw new require_CalmLensError.CalmLensError(require_CalmLensError.SDK_ERROR_CODES.NO_FETCH, { message: "No fetch implementation is available; pass one as the fetch option" });
756
757
  return fetchImpl;
757
758
  };
758
759
  this.hooks = getMockHooks(options);
@@ -820,9 +821,9 @@ var CalmLensConnection = class CalmLensConnection {
820
821
  callBody(method, body) {
821
822
  const { extraBody } = this.call;
822
823
  if (!extraBody) return body;
823
- if (method === "GET" || method === "HEAD") throw require_ModerationContextLimits.invalidArgument("extraBody needs a request with a body");
824
+ if (method === "GET" || method === "HEAD") throw require_CalmLensError.invalidArgument("extraBody needs a request with a body");
824
825
  if (body === void 0) return extraBody;
825
- if (!isPlainObject(body)) throw require_ModerationContextLimits.invalidArgument("extraBody needs a JSON object body");
826
+ if (!isPlainObject(body)) throw require_CalmLensError.invalidArgument("extraBody needs a JSON object body");
826
827
  return {
827
828
  ...body,
828
829
  ...extraBody
@@ -969,13 +970,13 @@ var CalmLensConnection = class CalmLensConnection {
969
970
  }, authHeaders);
970
971
  partNumber++;
971
972
  } catch (error) {
972
- if (!(error instanceof require_ModerationContextLimits.CalmLensError)) throw error;
973
+ if (!(error instanceof require_CalmLensError.CalmLensError)) throw error;
973
974
  const expected = error.details?.expectedPartNumber;
974
- if (error.code === require_ModerationContextLimits.API_ERROR_CODES.INVALID_UPLOAD_PART_NUMBER && typeof expected === "number" && expected > partNumber && expected <= count) {
975
+ if (error.code === require_CalmLensError.API_ERROR_CODES.INVALID_UPLOAD_PART_NUMBER && typeof expected === "number" && expected > partNumber && expected <= count) {
975
976
  partNumber = expected;
976
977
  continue;
977
978
  }
978
- if (isFinal && error.code === require_ModerationContextLimits.API_ERROR_CODES.UPLOAD_NOT_OPEN) return retrieve(assetId, this.withCall({
979
+ if (isFinal && error.code === require_CalmLensError.API_ERROR_CODES.UPLOAD_NOT_OPEN) return retrieve(assetId, this.withCall({
979
980
  operation: "assets.retrieve",
980
981
  idempotencyKey: void 0,
981
982
  extraBody: void 0
@@ -987,8 +988,8 @@ var CalmLensConnection = class CalmLensConnection {
987
988
  }
988
989
  /** Uploads the next part of a multipart upload to `partPath` (`.../assets/{id}/part`). */
989
990
  uploadPart(partPath, { part, wait, idempotencyKey }, authHeaders = {}) {
990
- if (!part) throw require_ModerationContextLimits.invalidArgument("Part options are required");
991
- if (this.call.extraBody) throw require_ModerationContextLimits.invalidArgument("A part's body is its bytes: extraBody can't apply");
991
+ if (!part) throw require_CalmLensError.invalidArgument("Part options are required");
992
+ if (this.call.extraBody) throw require_CalmLensError.invalidArgument("A part's body is its bytes: extraBody can't apply");
992
993
  assertDeclaredPayloadSize(part);
993
994
  const validation = validateAssetPayload(part, {
994
995
  multipart: true,