@calmlens/sdk 0.16.0 → 0.16.3

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 (38) hide show
  1. package/README.md +3 -1
  2. package/cjs/{CalmLensConnection-CPdx_acA.js → CalmLensConnection-BNUHp_AQ.js} +2 -2
  3. package/cjs/{CalmLensUtils-DvhY8-cU.js → CalmLensUtils-o171ownK.js} +7 -7
  4. package/cjs/{CalmLensVersion-CrlGk2gX.js → CalmLensVersion-DwhgxQK5.js} +1 -1
  5. package/cjs/{CalmLensWebhooks-C2VrleZm.js → CalmLensWebhooks-BKrq30Yp.js} +5 -5
  6. package/cjs/{Classification-DJU_DfOO.d.ts → Classification-BNhgwGEm-DmA9VEuE.d.ts} +497 -256
  7. package/cjs/{TestTriggers-CxFZ-3uz.d.ts → TestTriggers-CRKtulyp-vrzEq2wm.d.ts} +3 -2
  8. package/cjs/{WebhookPayload-BfUmVu2y.d.ts → WebhookPayload-CJoIkGBD.d.ts} +943 -479
  9. package/cjs/app.d.ts +3 -3
  10. package/cjs/app.js +3 -3
  11. package/cjs/{index-VxklV9OQ.d.ts → index-C9Xw1aid.d.ts} +137 -142
  12. package/cjs/index.d.ts +3 -3
  13. package/cjs/index.js +1 -1
  14. package/cjs/server.d.ts +3 -3
  15. package/cjs/server.js +4 -5
  16. package/cjs/test-inputs.d.ts +1 -1
  17. package/cjs/test-inputs.js +1 -1
  18. package/cjs/testing.d.ts +5 -3
  19. package/cjs/testing.js +7956 -135
  20. package/esm/{CalmLensConnection-DYo5U2L0.js → CalmLensConnection-XTqmlwzG.js} +2 -2
  21. package/esm/{CalmLensUtils-BDtpOfho.js → CalmLensUtils-DsF8Aa_x.js} +7 -7
  22. package/esm/{CalmLensVersion-CchG7NWy.js → CalmLensVersion-DcifRKsx.js} +1 -1
  23. package/esm/{CalmLensWebhooks-B7nQMCHx.js → CalmLensWebhooks-BvGyk5d3.js} +5 -5
  24. package/esm/{Classification-DJU_DfOO.d.ts → Classification-BNhgwGEm-DmA9VEuE.d.ts} +497 -256
  25. package/esm/{TestTriggers-CxFZ-3uz.d.ts → TestTriggers-CRKtulyp-vrzEq2wm.d.ts} +3 -2
  26. package/esm/{WebhookPayload-BfUmVu2y.d.ts → WebhookPayload-CJoIkGBD.d.ts} +943 -479
  27. package/esm/app.d.ts +3 -3
  28. package/esm/app.js +3 -3
  29. package/esm/{index-VxklV9OQ.d.ts → index-C9Xw1aid.d.ts} +137 -142
  30. package/esm/index.d.ts +3 -3
  31. package/esm/index.js +1 -1
  32. package/esm/server.d.ts +3 -3
  33. package/esm/server.js +4 -5
  34. package/esm/test-inputs.d.ts +1 -1
  35. package/esm/test-inputs.js +1 -1
  36. package/esm/testing.d.ts +5 -3
  37. package/esm/testing.js +7927 -106
  38. package/package.json +7 -6
package/README.md CHANGED
@@ -508,7 +508,7 @@ const asset = await client.assets.moderate({ name: file.name, content: { data: f
508
508
 
509
509
  The client has `assets.create`, `assets.moderate`, `assets.uploadPart` and `assets.retrieve`, for its own uploads, and each returns an `UploadedAsset`. It fetches a new token for each upload and reuses that token for the upload's parts and status checks.
510
510
 
511
- The same client works in React Native and Expo apps. Mobile apps send no `Origin` header, so use a preset that requires a token and leave its allowed sites empty. Pass the picked file's bytes, for example `content: { buffer: await new File(uri).arrayBuffer(), type }` with `expo-file-system`. See the [Calmsnap example](https://github.com/CalmLens/CalmLens/tree/main/examples/mobile-uploads-expo).
511
+ The same client works in React Native and Expo apps. Mobile apps send no `Origin` header, so use a preset that requires a token and leave its allowed sites empty. Pass the picked file's bytes, for example `content: { buffer: await new File(uri).arrayBuffer(), type }` with `expo-file-system`. See the [Calmsnap example](https://github.com/CalmLens/sdks/tree/main/examples/mobile-uploads-expo).
512
512
 
513
513
  On your server, sign a single-use token for each upload with `CalmLensServerClient`. Signing is local and makes no request:
514
514
 
@@ -830,3 +830,5 @@ lossy compression; cropping, rotation, and severe colour changes are unsupported
830
830
  The entry also exports `generateTestTextCode` and `detectTestTrigger` for text
831
831
  test inputs. Use your project's test input key; another project's key does not
832
832
  activate its test signals.
833
+
834
+ Image moderation considers readable text directly. Optional OCR (`processingOptions.features.ocr.enabled: true` on the wire) adds a text moderation pass and stores retained text in the image’s `content.extractedText`. No separate text child is created. Read the image’s combined `moderation.report`; removing its content also removes the extracted text.
@@ -1,5 +1,5 @@
1
- const require_CalmLensVersion = require("./CalmLensVersion-CrlGk2gX.js");
2
- const require_CalmLensUtils = require("./CalmLensUtils-DvhY8-cU.js");
1
+ const require_CalmLensVersion = require("./CalmLensVersion-DwhgxQK5.js");
2
+ const require_CalmLensUtils = require("./CalmLensUtils-o171ownK.js");
3
3
  //#region src/client/CalmLensConnection.ts
4
4
  const DEFAULT_TIMEOUT_MS = 12e4;
5
5
  const DEFAULT_MAX_RETRIES = 2;
@@ -1,4 +1,5 @@
1
- const require_CalmLensVersion = require("./CalmLensVersion-CrlGk2gX.js");
1
+ const require_CalmLensVersion = require("./CalmLensVersion-DwhgxQK5.js");
2
+ //#region src/contract/SharedConstants-Dn7ZJF5S.js
2
3
  const MAX_IMAGE_UPLOAD_BYTES = /* @__PURE__ */ (() => 20971520)();
3
4
  const MIN_MULTIPART_IMAGE_UPLOAD_BYTES = /* @__PURE__ */ (() => 10485760)();
4
5
  const REJECTED_UPLOAD_MIME_TYPE_SET = /* @__PURE__ */ new Set([
@@ -15,7 +16,7 @@ const isRejectedUploadMimeType = (mimeType) => REJECTED_UPLOAD_MIME_TYPE_SET.has
15
16
  const 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.`;
16
17
  const DOMAIN = "calmlens.com";
17
18
  //#endregion
18
- //#region ../shared/src/AssetPayload.ts
19
+ //#region src/contract/AssetPayload.js
19
20
  const uint8ArrayInputToNumbers = (value) => {
20
21
  if (Array.isArray(value)) return value;
21
22
  return Array.from(value);
@@ -505,15 +506,14 @@ const serializeTransform = (transform) => {
505
506
  };
506
507
  /** Returns the selector string the API and CDN accept for a string or structured transform. */
507
508
  const transformSelector = (transform) => transform === void 0 || typeof transform === "string" ? transform : serializeTransform(transform);
508
- /** Appends a CDN lens (`/@name`) or direct transform selector to an asset URL. */
509
+ /** Appends a CDN lens (`/@name`) followed by any direct transform selector to an asset URL. */
509
510
  const appendCdnSelector = (url, options) => {
510
- if (options.lens && options.transform) throw require_CalmLensVersion.invalidArgument("Specify either a lens or a transform, not both");
511
- if (options.lens) return `${url}/@${encodePathSegment(options.lens, "Lens")}`;
511
+ if (options.lens) url = `${url}/@${encodePathSegment(options.lens, "Lens")}`;
512
512
  if (!options.transform) return url;
513
- if (typeof options.transform !== "string") return `${url}/${serializeTransform(options.transform)}`;
513
+ if (typeof options.transform !== "string") return `${url}${options.lens ? "," : "/"}${serializeTransform(options.transform)}`;
514
514
  const transform = options.transform.replace(/^\/+/, "");
515
515
  if (transform.includes("..") || transform.includes("?") || transform.includes("#")) throw require_CalmLensVersion.invalidArgument("Transform cannot contain \"..\", \"?\" or \"#\"");
516
- return `${url}/${encodeURI(transform).replace(/%5B/g, "[").replace(/%5D/g, "]")}`;
516
+ return `${url}${options.lens ? "," : "/"}${encodeURI(transform).replace(/%5B/g, "[").replace(/%5D/g, "]")}`;
517
517
  };
518
518
  const appendQueryValue = (parts, key, value) => {
519
519
  if (value === void 0 || value === null) return;
@@ -395,7 +395,7 @@ const invalidConfig = (message) => new CalmLensError(SDK_ERROR_CODES.INVALID_CON
395
395
  //#endregion
396
396
  //#region src/client/CalmLensVersion.ts
397
397
  /** This SDK's version, from its package.json. */
398
- const SDK_VERSION = "0.16.0";
398
+ const SDK_VERSION = "0.16.3";
399
399
  const runtimeName = () => {
400
400
  const runtime = globalThis;
401
401
  if (isReactNativeRuntime()) return "react-native";
@@ -1,12 +1,12 @@
1
- const require_CalmLensVersion = require("./CalmLensVersion-CrlGk2gX.js");
2
- const require_CalmLensUtils = require("./CalmLensUtils-DvhY8-cU.js");
3
- //#region ../shared/src/JsonUtils.ts
1
+ const require_CalmLensVersion = require("./CalmLensVersion-DwhgxQK5.js");
2
+ const require_CalmLensUtils = require("./CalmLensUtils-o171ownK.js");
3
+ //#region src/contract/JsonUtils.js
4
4
  const stringifyJsonCanonical = (value) => JSON.stringify(value, (_key, nestedValue) => {
5
5
  if (!nestedValue || typeof nestedValue !== "object" || Array.isArray(nestedValue)) return nestedValue;
6
6
  return Object.fromEntries(Object.keys(nestedValue).sort().map((key) => [key, nestedValue[key]]));
7
7
  });
8
8
  //#endregion
9
- //#region ../shared/src/CryptoUtils.ts
9
+ //#region src/contract/CryptoUtils-Cb7_Afa0.js
10
10
  const encoder = new TextEncoder();
11
11
  /** Lowercase hex of `bytes`, two characters per byte. */
12
12
  const bytesToHex = (bytes) => Array.from(bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes), (byte) => byte.toString(16).padStart(2, "0")).join("");
@@ -31,7 +31,7 @@ const timingSafeEqual = (a, b) => {
31
31
  return difference === 0;
32
32
  };
33
33
  //#endregion
34
- //#region ../shared/src/UploadToken.ts
34
+ //#region src/contract/UploadToken.js
35
35
  const UPLOAD_TOKEN_PREFIX = "clut_";
36
36
  const UPLOAD_TOKEN_MAX_TTL_SECONDS = 3600;
37
37
  const SIGNING_CONTEXT = "calmlens-upload-token:v1:";