@calmlens/sdk 0.12.0 → 0.13.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 (35) hide show
  1. package/README.md +14 -1
  2. package/cjs/CalmLensConnection-DzRDCMOP.js +233 -0
  3. package/cjs/CalmLensUtils-vX5H_vMn.js +699 -0
  4. package/cjs/{CalmLensError-CKwMKV0S.js → CalmLensVersion-DjhsJ1gj.js} +48 -0
  5. package/cjs/{CalmLensWebhooks-BTPxKvcD.js → CalmLensWebhooks-hVquX5L1.js} +9 -9
  6. package/cjs/{WebhookPayload-Cgb32aSH.d.ts → WebhookPayload-B7CgSmI5.d.ts} +4996 -3255
  7. package/cjs/app.d.ts +3 -3
  8. package/cjs/app.js +10 -10
  9. package/cjs/{index-BgmWj3KL.d.ts → index-BywTQbRq.d.ts} +3 -1
  10. package/cjs/index.d.ts +3 -3
  11. package/cjs/index.js +4 -5
  12. package/cjs/server.d.ts +12 -4
  13. package/cjs/server.js +31 -18
  14. package/cjs/testing.d.ts +6 -1
  15. package/cjs/testing.js +91 -73
  16. package/esm/CalmLensConnection-D8VsTdsA.js +192 -0
  17. package/esm/{CalmLensUtils-Cx32j2zt.js → CalmLensUtils-B4i3Z2He.js} +316 -2
  18. package/esm/{CalmLensError-CihGG26K.js → CalmLensVersion-DK4BMEST.js} +25 -1
  19. package/esm/{CalmLensWebhooks-DShmAal4.js → CalmLensWebhooks-DyCoEvpf.js} +2 -2
  20. package/esm/{WebhookPayload-Cgb32aSH.d.ts → WebhookPayload-B7CgSmI5.d.ts} +4996 -3255
  21. package/esm/app.d.ts +3 -3
  22. package/esm/app.js +4 -4
  23. package/esm/{index-BgmWj3KL.d.ts → index-BywTQbRq.d.ts} +3 -1
  24. package/esm/index.d.ts +3 -3
  25. package/esm/index.js +1 -3
  26. package/esm/server.d.ts +12 -4
  27. package/esm/server.js +20 -7
  28. package/esm/testing.d.ts +6 -1
  29. package/esm/testing.js +59 -41
  30. package/package.json +1 -1
  31. package/cjs/CalmLensConnection-CYtBP-vu.js +0 -516
  32. package/cjs/CalmLensUtils-Dg3s4loH.js +0 -367
  33. package/cjs/src-Dsc8Pn6v.js +0 -45
  34. package/esm/CalmLensConnection-wLNy0OIP.js +0 -475
  35. package/esm/src-CJhrILvM.js +0 -22
package/cjs/app.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { $ as SearchAssetsOptions, A as DeleteAssetContentOptions, At as AssetSafetyHold, B as Lens, C as CdnAssetUrlOptions, Ct as EventType, D as CreateAssetSignedUrlOptions, Dt as AssetSearchMatchField, E as ConnectionOptions, Et as LensType, F as IdempotencyOptions, Ft as MetadataItem, G as ModerateTextOptions, H as ListAssetChildrenOptions, I as ImageTransform, It as PreviewImage, J as MultipartUploadOptions, K as MoveAssetOptions, L as ImageTransformOptions, Lt as ProcessingOptions, M as EnsureLensOptions, Mt as DocumentData, N as EnsureLensesOptions, Nt as ExtractedText, O as CreateFolderOptions, Ot as AssetSearchQuery, P as FolderIdOptions, Pt as ImageData, Q as RetryAssetOptions, R as IterateAssetChildrenOptions, S as CalmLensServerClientOptions, St as EventSeverity, T as CdnTransform, Tt as Page, U as ListAssetsOptions, V as LensTransform, W as ListEventsOptions, X as RequestOptions, Y as MultipartUploadPartOptions, Z as RetrieveAssetOptions, _ as AssetSearchResult, _t as TypedEvent, a as ClassificationLabel, at as UpdateFolderOptions, b as AssetVisibility, bt as EventFactValues, c as ClassificationReport, ct as UploadedAsset, d as Asset, dt as WebhookPayloadInput, et as SignUploadTokenOptions, f as AssetChecksums, ft as GetEventsResponse, g as AssetSearchResponse, gt as EventAsset, h as AssetPage, i as ClassificationCategoryReport, it as UpdateAssetOptions, j as DeleteAssetOptions, jt as AssetSafetyHoldReason, k as CreateMultipartUploadPartOptions, l as Likelihood, lt as VerifyWebhookSignatureOptions, m as AssetContentOptions, mt as Folder, n as ClassificationCategories, nt as SignedUrl, o as ClassificationNotEvaluatedReason, ot as UploadAssetPartOptions, p as AssetChildrenPage, q as MoveFolderOptions, r as ClassificationCategory, rt as SubmitAssetOptions, s as ClassificationQualifierResults, st as UploadPresetSubmitAssetOptions, t as WebhookEventPayload, tt as SignedUploadToken, u as ModerationQualifier, ut as WebhookHeadersInput, v as AssetStatus, vt as EventCategory, w as CdnServeOptions, wt as Order, x as CalmLensAppClientOptions, xt as EventFacts, y as AssetType, yt as EventFact, z as IterateAssetsOptions } from "./WebhookPayload-Cgb32aSH.js";
2
- import { _ as ProcessingFeatureStage, a as CalmLensErrorDetails, c as ApiErrorCode, d as AgeRange, f as BoundingBox, g as ProcessingFeatureResults, h as ProcessingFeatureId, i as CalmLensErrorCode, l as FlaggedContentAction, m as DetectedPerson, n as CALMLENS_ERROR_CODES, o as CalmLensErrorOptions, p as DetectedFace, r as CalmLensError, s as SdkErrorCode, t as SDK_VERSION, u as FlaggedContentPolicy, v as ProcessingFeatures } from "./index-BgmWj3KL.js";
1
+ import { $ as SearchAssetsOptions, A as DeleteAssetContentOptions, B as Lens, C as CdnAssetUrlOptions, Ct as EventSeverity, D as CreateAssetSignedUrlOptions, Dt as LensType, E as ConnectionOptions, Et as Page, F as IdempotencyOptions, Ft as ImageData, G as ModerateTextOptions, H as ListAssetChildrenOptions, I as ImageTransform, It as MetadataItem, J as MultipartUploadOptions, K as MoveAssetOptions, L as ImageTransformOptions, Lt as PreviewImage, M as EnsureLensOptions, Mt as AssetSafetyHoldReason, N as EnsureLensesOptions, Nt as DocumentData, O as CreateFolderOptions, Ot as AssetSearchMatchField, P as FolderIdOptions, Pt as ExtractedText, Q as RetryAssetOptions, R as IterateAssetChildrenOptions, Rt as ProcessingOptions, S as CalmLensServerClientOptions, St as EventFacts, T as CdnTransform, Tt as Order, U as ListAssetsOptions, V as LensTransform, W as ListEventsOptions, X as RequestOptions, Y as MultipartUploadPartOptions, Z as RetrieveAssetOptions, _ as AssetSearchResult, _t as EventAsset, a as ClassificationLabel, at as UpdateFolderOptions, b as AssetVisibility, bt as EventFact, c as ClassificationReport, ct as UploadedAsset, d as Asset, dt as WebhookHeadersInput, et as SignUploadTokenOptions, f as AssetChecksums, ft as WebhookPayloadInput, g as AssetSearchResponse, h as AssetPage, ht as Folder, i as ClassificationCategoryReport, it as UpdateAssetOptions, j as DeleteAssetOptions, jt as AssetSafetyHold, k as CreateMultipartUploadPartOptions, kt as AssetSearchQuery, l as Likelihood, lt as VerifyWebhookSignatureOptions, m as AssetContentOptions, n as ClassificationCategories, nt as SignedUrl, o as ClassificationNotEvaluatedReason, ot as UploadAssetPartOptions, p as AssetChildrenPage, pt as GetEventsResponse, q as MoveFolderOptions, r as ClassificationCategory, rt as SubmitAssetOptions, s as ClassificationQualifierResults, st as UploadPresetSubmitAssetOptions, t as WebhookEventPayload, tt as SignedUploadToken, u as ModerationQualifier, ut as WaitForAssetDecisionOptions, v as AssetStatus, vt as TypedEvent, w as CdnServeOptions, wt as EventType, x as CalmLensAppClientOptions, xt as EventFactValues, y as AssetType, yt as EventCategory, z as IterateAssetsOptions } from "./WebhookPayload-B7CgSmI5.js";
2
+ import { _ as ProcessingFeatureStage, a as CalmLensErrorDetails, c as ApiErrorCode, d as AgeRange, f as BoundingBox, g as ProcessingFeatureResults, h as ProcessingFeatureId, i as CalmLensErrorCode, l as FlaggedContentAction, m as DetectedPerson, n as CALMLENS_ERROR_CODES, o as CalmLensErrorOptions, p as DetectedFace, r as CalmLensError, s as SdkErrorCode, t as SDK_VERSION, u as FlaggedContentPolicy, v as ProcessingFeatures } from "./index-BywTQbRq.js";
3
3
  //#region src/client/CalmLensAppClient.d.ts
4
4
  declare const inspectSymbol: unique symbol;
5
5
  /**
@@ -40,4 +40,4 @@ declare class CalmLensAppClient {
40
40
  };
41
41
  }
42
42
  //#endregion
43
- export { type AgeRange, type ApiErrorCode, type Asset, type AssetChecksums, type AssetChildrenPage, type AssetContentOptions, type AssetPage, type AssetSafetyHold, type AssetSafetyHoldReason, type AssetSearchMatchField, type AssetSearchQuery, type AssetSearchResponse, type AssetSearchResult, type AssetStatus, type AssetType, type AssetVisibility, type BoundingBox, CALMLENS_ERROR_CODES, CalmLensAppClient, type CalmLensAppClientOptions, CalmLensError, type CalmLensErrorCode, type CalmLensErrorDetails, type CalmLensErrorOptions, type CalmLensServerClientOptions, type CdnAssetUrlOptions, type CdnServeOptions, type CdnTransform, type ClassificationCategories, type ClassificationCategory, type ClassificationCategoryReport, type ClassificationLabel, type ClassificationNotEvaluatedReason, type ClassificationQualifierResults, type ClassificationReport, type ConnectionOptions, type CreateAssetSignedUrlOptions, type CreateFolderOptions, type CreateMultipartUploadPartOptions, type DeleteAssetContentOptions, type DeleteAssetOptions, type DetectedFace, type DetectedPerson, type DocumentData, type EnsureLensOptions, type EnsureLensesOptions, type EventAsset, type EventCategory, type EventFact, type EventFactValues, type EventFacts, type EventSeverity, type EventType, type GetEventsResponse as EventsPage, type ExtractedText, type FlaggedContentAction, type FlaggedContentPolicy, type Folder, type FolderIdOptions, type IdempotencyOptions, type ImageData, type ImageTransform, type ImageTransformOptions, type IterateAssetChildrenOptions, type IterateAssetsOptions, type Lens, type LensTransform, type LensType, type Likelihood, type ListAssetChildrenOptions, type ListAssetsOptions, type ListEventsOptions, type MetadataItem, type ModerateTextOptions, type ModerationQualifier, type MoveAssetOptions, type MoveFolderOptions, type MultipartUploadOptions, type MultipartUploadPartOptions, type Order, type Page, type PreviewImage, type ProcessingFeatureId, type ProcessingFeatureResults, type ProcessingFeatureStage, type ProcessingFeatures, type ProcessingOptions, type RequestOptions, type RetrieveAssetOptions, type RetryAssetOptions, SDK_VERSION, type SdkErrorCode, type SearchAssetsOptions, type SignUploadTokenOptions, type SignedUploadToken, type SignedUrl, type SubmitAssetOptions, type TypedEvent, type UpdateAssetOptions, type UpdateFolderOptions, type UploadAssetPartOptions, type UploadPresetSubmitAssetOptions, type UploadedAsset, type VerifyWebhookSignatureOptions, type WebhookEventPayload, type WebhookHeadersInput, type WebhookPayloadInput };
43
+ export { type AgeRange, type ApiErrorCode, type Asset, type AssetChecksums, type AssetChildrenPage, type AssetContentOptions, type AssetPage, type AssetSafetyHold, type AssetSafetyHoldReason, type AssetSearchMatchField, type AssetSearchQuery, type AssetSearchResponse, type AssetSearchResult, type AssetStatus, type AssetType, type AssetVisibility, type BoundingBox, CALMLENS_ERROR_CODES, CalmLensAppClient, type CalmLensAppClientOptions, CalmLensError, type CalmLensErrorCode, type CalmLensErrorDetails, type CalmLensErrorOptions, type CalmLensServerClientOptions, type CdnAssetUrlOptions, type CdnServeOptions, type CdnTransform, type ClassificationCategories, type ClassificationCategory, type ClassificationCategoryReport, type ClassificationLabel, type ClassificationNotEvaluatedReason, type ClassificationQualifierResults, type ClassificationReport, type ConnectionOptions, type CreateAssetSignedUrlOptions, type CreateFolderOptions, type CreateMultipartUploadPartOptions, type DeleteAssetContentOptions, type DeleteAssetOptions, type DetectedFace, type DetectedPerson, type DocumentData, type EnsureLensOptions, type EnsureLensesOptions, type EventAsset, type EventCategory, type EventFact, type EventFactValues, type EventFacts, type EventSeverity, type EventType, type GetEventsResponse as EventsPage, type ExtractedText, type FlaggedContentAction, type FlaggedContentPolicy, type Folder, type FolderIdOptions, type IdempotencyOptions, type ImageData, type ImageTransform, type ImageTransformOptions, type IterateAssetChildrenOptions, type IterateAssetsOptions, type Lens, type LensTransform, type LensType, type Likelihood, type ListAssetChildrenOptions, type ListAssetsOptions, type ListEventsOptions, type MetadataItem, type ModerateTextOptions, type ModerationQualifier, type MoveAssetOptions, type MoveFolderOptions, type MultipartUploadOptions, type MultipartUploadPartOptions, type Order, type Page, type PreviewImage, type ProcessingFeatureId, type ProcessingFeatureResults, type ProcessingFeatureStage, type ProcessingFeatures, type ProcessingOptions, type RequestOptions, type RetrieveAssetOptions, type RetryAssetOptions, SDK_VERSION, type SdkErrorCode, type SearchAssetsOptions, type SignUploadTokenOptions, type SignedUploadToken, type SignedUrl, type SubmitAssetOptions, type TypedEvent, type UpdateAssetOptions, type UpdateFolderOptions, type UploadAssetPartOptions, type UploadPresetSubmitAssetOptions, type UploadedAsset, type VerifyWebhookSignatureOptions, type WaitForAssetDecisionOptions, type WebhookEventPayload, type WebhookHeadersInput, type WebhookPayloadInput };
package/cjs/app.js CHANGED
@@ -1,8 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_CalmLensError = require("./CalmLensError-CKwMKV0S.js");
3
- const require_src = require("./src-Dsc8Pn6v.js");
4
- const require_CalmLensUtils = require("./CalmLensUtils-Dg3s4loH.js");
5
- const require_CalmLensConnection = require("./CalmLensConnection-CYtBP-vu.js");
2
+ const require_CalmLensVersion = require("./CalmLensVersion-DjhsJ1gj.js");
3
+ require("./index.js");
4
+ const require_CalmLensUtils = require("./CalmLensUtils-vX5H_vMn.js");
5
+ const require_CalmLensConnection = require("./CalmLensConnection-DzRDCMOP.js");
6
6
  //#region src/client/CalmLensAppClient.ts
7
7
  const inspectSymbol = Symbol.for("nodejs.util.inspect.custom");
8
8
  /**
@@ -40,7 +40,7 @@ var CalmLensAppClient = class {
40
40
  /** A fresh token for a new upload, when the client has one. */
41
41
  async newUploadToken() {
42
42
  const token = typeof this.#token === "function" ? await this.#token() : this.#token;
43
- if (token !== void 0 && (typeof token !== "string" || !token)) throw require_CalmLensError.invalidConfig("token must return a non-empty string");
43
+ if (token !== void 0 && (typeof token !== "string" || !token)) throw require_CalmLensVersion.invalidConfig("token must return a non-empty string");
44
44
  return token;
45
45
  }
46
46
  /** The `Authorization` header for an upload this client started. */
@@ -50,8 +50,8 @@ var CalmLensAppClient = class {
50
50
  }
51
51
  /** Uploads with a new token, kept for the upload's parts and status checks. */
52
52
  async submit(options, queue) {
53
- if (!options || typeof options !== "object") throw require_CalmLensError.invalidArgument("Upload options are required");
54
- if (!("content" in options) && !("part" in options)) throw require_CalmLensError.invalidArgument("Uploads through an upload preset need content or a part");
53
+ if (!options || typeof options !== "object") throw require_CalmLensVersion.invalidArgument("Upload options are required");
54
+ if (!("content" in options) && !("part" in options)) throw require_CalmLensVersion.invalidArgument("Uploads through an upload preset need content or a part");
55
55
  require_CalmLensConnection.prepareSubmitAssetOptions(options);
56
56
  const token = await this.newUploadToken();
57
57
  const data = await this.#connection.submitRawUpload(this.uploadsPath, options, queue, token ? { Authorization: `Bearer ${token}` } : {});
@@ -85,7 +85,7 @@ var CalmLensAppClient = class {
85
85
  }
86
86
  };
87
87
  //#endregion
88
- exports.CALMLENS_ERROR_CODES = require_CalmLensError.CALMLENS_ERROR_CODES;
88
+ exports.CALMLENS_ERROR_CODES = require_CalmLensVersion.CALMLENS_ERROR_CODES;
89
89
  exports.CalmLensAppClient = CalmLensAppClient;
90
- exports.CalmLensError = require_CalmLensError.CalmLensError;
91
- exports.SDK_VERSION = require_src.SDK_VERSION;
90
+ exports.CalmLensError = require_CalmLensVersion.CalmLensError;
91
+ exports.SDK_VERSION = require_CalmLensVersion.SDK_VERSION;
@@ -1,4 +1,4 @@
1
- import "./WebhookPayload-Cgb32aSH.js";
1
+ import "./WebhookPayload-B7CgSmI5.js";
2
2
  import * as zod from "zod";
3
3
  //#region ../shared/src/ProcessingFeatures.d.ts
4
4
  /**
@@ -152,6 +152,7 @@ declare const API_ERROR_CODES: {
152
152
  readonly MULTIPART_IMAGE_TOO_LARGE: "upload/multipart-image-too-large";
153
153
  readonly IMAGE_EXCEEDED_MAX_DIMENSIONS: "upload/image-exceeded-max-dimensions";
154
154
  readonly UPLOAD_LIMIT_EXCEEDED: "upload/limit-exceeded";
155
+ readonly SPEND_LIMIT_REACHED: "upload/spend-limit-reached";
155
156
  readonly INVALID_UPLOAD_MIME_TYPE: "upload/invalid-mime-type";
156
157
  readonly INVALID_EVENT_CURSOR: "events/invalid-cursor";
157
158
  readonly INVALID_UPLOAD_PAYLOAD: "upload/invalid-payload";
@@ -230,6 +231,7 @@ declare const CALMLENS_ERROR_CODES: {
230
231
  readonly MULTIPART_IMAGE_TOO_LARGE: "upload/multipart-image-too-large";
231
232
  readonly IMAGE_EXCEEDED_MAX_DIMENSIONS: "upload/image-exceeded-max-dimensions";
232
233
  readonly UPLOAD_LIMIT_EXCEEDED: "upload/limit-exceeded";
234
+ readonly SPEND_LIMIT_REACHED: "upload/spend-limit-reached";
233
235
  readonly INVALID_UPLOAD_MIME_TYPE: "upload/invalid-mime-type";
234
236
  readonly INVALID_EVENT_CURSOR: "events/invalid-cursor";
235
237
  readonly INVALID_UPLOAD_PAYLOAD: "upload/invalid-payload";
package/cjs/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { $ as SearchAssetsOptions, A as DeleteAssetContentOptions, At as AssetSafetyHold, B as Lens, C as CdnAssetUrlOptions, Ct as EventType, D as CreateAssetSignedUrlOptions, Dt as AssetSearchMatchField, E as ConnectionOptions, Et as LensType, F as IdempotencyOptions, Ft as MetadataItem, G as ModerateTextOptions, H as ListAssetChildrenOptions, I as ImageTransform, It as PreviewImage, J as MultipartUploadOptions, K as MoveAssetOptions, L as ImageTransformOptions, Lt as ProcessingOptions, M as EnsureLensOptions, Mt as DocumentData, N as EnsureLensesOptions, Nt as ExtractedText, O as CreateFolderOptions, Ot as AssetSearchQuery, P as FolderIdOptions, Pt as ImageData, Q as RetryAssetOptions, R as IterateAssetChildrenOptions, S as CalmLensServerClientOptions, St as EventSeverity, T as CdnTransform, Tt as Page, U as ListAssetsOptions, V as LensTransform, W as ListEventsOptions, X as RequestOptions, Y as MultipartUploadPartOptions, Z as RetrieveAssetOptions, _ as AssetSearchResult, _t as TypedEvent, a as ClassificationLabel, at as UpdateFolderOptions, b as AssetVisibility, bt as EventFactValues, c as ClassificationReport, ct as UploadedAsset, d as Asset, dt as WebhookPayloadInput, et as SignUploadTokenOptions, f as AssetChecksums, ft as GetEventsResponse, g as AssetSearchResponse, gt as EventAsset, h as AssetPage, i as ClassificationCategoryReport, it as UpdateAssetOptions, j as DeleteAssetOptions, jt as AssetSafetyHoldReason, k as CreateMultipartUploadPartOptions, l as Likelihood, lt as VerifyWebhookSignatureOptions, m as AssetContentOptions, mt as Folder, n as ClassificationCategories, nt as SignedUrl, o as ClassificationNotEvaluatedReason, ot as UploadAssetPartOptions, p as AssetChildrenPage, q as MoveFolderOptions, r as ClassificationCategory, rt as SubmitAssetOptions, s as ClassificationQualifierResults, st as UploadPresetSubmitAssetOptions, t as WebhookEventPayload, tt as SignedUploadToken, u as ModerationQualifier, ut as WebhookHeadersInput, v as AssetStatus, vt as EventCategory, w as CdnServeOptions, wt as Order, x as CalmLensAppClientOptions, xt as EventFacts, y as AssetType, yt as EventFact, z as IterateAssetsOptions } from "./WebhookPayload-Cgb32aSH.js";
2
- import { _ as ProcessingFeatureStage, a as CalmLensErrorDetails, c as ApiErrorCode, d as AgeRange, f as BoundingBox, g as ProcessingFeatureResults, h as ProcessingFeatureId, i as CalmLensErrorCode, l as FlaggedContentAction, m as DetectedPerson, n as CALMLENS_ERROR_CODES, o as CalmLensErrorOptions, p as DetectedFace, r as CalmLensError, s as SdkErrorCode, t as SDK_VERSION, u as FlaggedContentPolicy, v as ProcessingFeatures } from "./index-BgmWj3KL.js";
3
- export { type AgeRange, type ApiErrorCode, type Asset, type AssetChecksums, type AssetChildrenPage, type AssetContentOptions, type AssetPage, type AssetSafetyHold, type AssetSafetyHoldReason, type AssetSearchMatchField, type AssetSearchQuery, type AssetSearchResponse, type AssetSearchResult, type AssetStatus, type AssetType, type AssetVisibility, type BoundingBox, CALMLENS_ERROR_CODES, type CalmLensAppClientOptions, CalmLensError, type CalmLensErrorCode, type CalmLensErrorDetails, type CalmLensErrorOptions, type CalmLensServerClientOptions, type CdnAssetUrlOptions, type CdnServeOptions, type CdnTransform, type ClassificationCategories, type ClassificationCategory, type ClassificationCategoryReport, type ClassificationLabel, type ClassificationNotEvaluatedReason, type ClassificationQualifierResults, type ClassificationReport, type ConnectionOptions, type CreateAssetSignedUrlOptions, type CreateFolderOptions, type CreateMultipartUploadPartOptions, type DeleteAssetContentOptions, type DeleteAssetOptions, type DetectedFace, type DetectedPerson, type DocumentData, type EnsureLensOptions, type EnsureLensesOptions, type EventAsset, type EventCategory, type EventFact, type EventFactValues, type EventFacts, type EventSeverity, type EventType, type GetEventsResponse as EventsPage, type ExtractedText, type FlaggedContentAction, type FlaggedContentPolicy, type Folder, type FolderIdOptions, type IdempotencyOptions, type ImageData, type ImageTransform, type ImageTransformOptions, type IterateAssetChildrenOptions, type IterateAssetsOptions, type Lens, type LensTransform, type LensType, type Likelihood, type ListAssetChildrenOptions, type ListAssetsOptions, type ListEventsOptions, type MetadataItem, type ModerateTextOptions, type ModerationQualifier, type MoveAssetOptions, type MoveFolderOptions, type MultipartUploadOptions, type MultipartUploadPartOptions, type Order, type Page, type PreviewImage, type ProcessingFeatureId, type ProcessingFeatureResults, type ProcessingFeatureStage, type ProcessingFeatures, type ProcessingOptions, type RequestOptions, type RetrieveAssetOptions, type RetryAssetOptions, SDK_VERSION, type SdkErrorCode, type SearchAssetsOptions, type SignUploadTokenOptions, type SignedUploadToken, type SignedUrl, type SubmitAssetOptions, type TypedEvent, type UpdateAssetOptions, type UpdateFolderOptions, type UploadAssetPartOptions, type UploadPresetSubmitAssetOptions, type UploadedAsset, type VerifyWebhookSignatureOptions, type WebhookEventPayload, type WebhookHeadersInput, type WebhookPayloadInput };
1
+ import { $ as SearchAssetsOptions, A as DeleteAssetContentOptions, B as Lens, C as CdnAssetUrlOptions, Ct as EventSeverity, D as CreateAssetSignedUrlOptions, Dt as LensType, E as ConnectionOptions, Et as Page, F as IdempotencyOptions, Ft as ImageData, G as ModerateTextOptions, H as ListAssetChildrenOptions, I as ImageTransform, It as MetadataItem, J as MultipartUploadOptions, K as MoveAssetOptions, L as ImageTransformOptions, Lt as PreviewImage, M as EnsureLensOptions, Mt as AssetSafetyHoldReason, N as EnsureLensesOptions, Nt as DocumentData, O as CreateFolderOptions, Ot as AssetSearchMatchField, P as FolderIdOptions, Pt as ExtractedText, Q as RetryAssetOptions, R as IterateAssetChildrenOptions, Rt as ProcessingOptions, S as CalmLensServerClientOptions, St as EventFacts, T as CdnTransform, Tt as Order, U as ListAssetsOptions, V as LensTransform, W as ListEventsOptions, X as RequestOptions, Y as MultipartUploadPartOptions, Z as RetrieveAssetOptions, _ as AssetSearchResult, _t as EventAsset, a as ClassificationLabel, at as UpdateFolderOptions, b as AssetVisibility, bt as EventFact, c as ClassificationReport, ct as UploadedAsset, d as Asset, dt as WebhookHeadersInput, et as SignUploadTokenOptions, f as AssetChecksums, ft as WebhookPayloadInput, g as AssetSearchResponse, h as AssetPage, ht as Folder, i as ClassificationCategoryReport, it as UpdateAssetOptions, j as DeleteAssetOptions, jt as AssetSafetyHold, k as CreateMultipartUploadPartOptions, kt as AssetSearchQuery, l as Likelihood, lt as VerifyWebhookSignatureOptions, m as AssetContentOptions, n as ClassificationCategories, nt as SignedUrl, o as ClassificationNotEvaluatedReason, ot as UploadAssetPartOptions, p as AssetChildrenPage, pt as GetEventsResponse, q as MoveFolderOptions, r as ClassificationCategory, rt as SubmitAssetOptions, s as ClassificationQualifierResults, st as UploadPresetSubmitAssetOptions, t as WebhookEventPayload, tt as SignedUploadToken, u as ModerationQualifier, ut as WaitForAssetDecisionOptions, v as AssetStatus, vt as TypedEvent, w as CdnServeOptions, wt as EventType, x as CalmLensAppClientOptions, xt as EventFactValues, y as AssetType, yt as EventCategory, z as IterateAssetsOptions } from "./WebhookPayload-B7CgSmI5.js";
2
+ import { _ as ProcessingFeatureStage, a as CalmLensErrorDetails, c as ApiErrorCode, d as AgeRange, f as BoundingBox, g as ProcessingFeatureResults, h as ProcessingFeatureId, i as CalmLensErrorCode, l as FlaggedContentAction, m as DetectedPerson, n as CALMLENS_ERROR_CODES, o as CalmLensErrorOptions, p as DetectedFace, r as CalmLensError, s as SdkErrorCode, t as SDK_VERSION, u as FlaggedContentPolicy, v as ProcessingFeatures } from "./index-BywTQbRq.js";
3
+ export { type AgeRange, type ApiErrorCode, type Asset, type AssetChecksums, type AssetChildrenPage, type AssetContentOptions, type AssetPage, type AssetSafetyHold, type AssetSafetyHoldReason, type AssetSearchMatchField, type AssetSearchQuery, type AssetSearchResponse, type AssetSearchResult, type AssetStatus, type AssetType, type AssetVisibility, type BoundingBox, CALMLENS_ERROR_CODES, type CalmLensAppClientOptions, CalmLensError, type CalmLensErrorCode, type CalmLensErrorDetails, type CalmLensErrorOptions, type CalmLensServerClientOptions, type CdnAssetUrlOptions, type CdnServeOptions, type CdnTransform, type ClassificationCategories, type ClassificationCategory, type ClassificationCategoryReport, type ClassificationLabel, type ClassificationNotEvaluatedReason, type ClassificationQualifierResults, type ClassificationReport, type ConnectionOptions, type CreateAssetSignedUrlOptions, type CreateFolderOptions, type CreateMultipartUploadPartOptions, type DeleteAssetContentOptions, type DeleteAssetOptions, type DetectedFace, type DetectedPerson, type DocumentData, type EnsureLensOptions, type EnsureLensesOptions, type EventAsset, type EventCategory, type EventFact, type EventFactValues, type EventFacts, type EventSeverity, type EventType, type GetEventsResponse as EventsPage, type ExtractedText, type FlaggedContentAction, type FlaggedContentPolicy, type Folder, type FolderIdOptions, type IdempotencyOptions, type ImageData, type ImageTransform, type ImageTransformOptions, type IterateAssetChildrenOptions, type IterateAssetsOptions, type Lens, type LensTransform, type LensType, type Likelihood, type ListAssetChildrenOptions, type ListAssetsOptions, type ListEventsOptions, type MetadataItem, type ModerateTextOptions, type ModerationQualifier, type MoveAssetOptions, type MoveFolderOptions, type MultipartUploadOptions, type MultipartUploadPartOptions, type Order, type Page, type PreviewImage, type ProcessingFeatureId, type ProcessingFeatureResults, type ProcessingFeatureStage, type ProcessingFeatures, type ProcessingOptions, type RequestOptions, type RetrieveAssetOptions, type RetryAssetOptions, SDK_VERSION, type SdkErrorCode, type SearchAssetsOptions, type SignUploadTokenOptions, type SignedUploadToken, type SignedUrl, type SubmitAssetOptions, type TypedEvent, type UpdateAssetOptions, type UpdateFolderOptions, type UploadAssetPartOptions, type UploadPresetSubmitAssetOptions, type UploadedAsset, type VerifyWebhookSignatureOptions, type WaitForAssetDecisionOptions, type WebhookEventPayload, type WebhookHeadersInput, type WebhookPayloadInput };
package/cjs/index.js CHANGED
@@ -1,6 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_CalmLensError = require("./CalmLensError-CKwMKV0S.js");
3
- const require_src = require("./src-Dsc8Pn6v.js");
4
- exports.CALMLENS_ERROR_CODES = require_CalmLensError.CALMLENS_ERROR_CODES;
5
- exports.CalmLensError = require_CalmLensError.CalmLensError;
6
- exports.SDK_VERSION = require_src.SDK_VERSION;
2
+ const require_CalmLensVersion = require("./CalmLensVersion-DjhsJ1gj.js");
3
+ exports.CALMLENS_ERROR_CODES = require_CalmLensVersion.CALMLENS_ERROR_CODES;
4
+ exports.CalmLensError = require_CalmLensVersion.CalmLensError;
5
+ exports.SDK_VERSION = require_CalmLensVersion.SDK_VERSION;
package/cjs/server.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { $ as SearchAssetsOptions, A as DeleteAssetContentOptions, At as AssetSafetyHold, B as Lens, C as CdnAssetUrlOptions, Ct as EventType, D as CreateAssetSignedUrlOptions, Dt as AssetSearchMatchField, E as ConnectionOptions, Et as LensType, F as IdempotencyOptions, Ft as MetadataItem, G as ModerateTextOptions, H as ListAssetChildrenOptions, I as ImageTransform, It as PreviewImage, J as MultipartUploadOptions, K as MoveAssetOptions, L as ImageTransformOptions, Lt as ProcessingOptions, M as EnsureLensOptions, Mt as DocumentData, N as EnsureLensesOptions, Nt as ExtractedText, O as CreateFolderOptions, Ot as AssetSearchQuery, P as FolderIdOptions, Pt as ImageData, Q as RetryAssetOptions, R as IterateAssetChildrenOptions, S as CalmLensServerClientOptions, St as EventSeverity, T as CdnTransform, Tt as Page, U as ListAssetsOptions, V as LensTransform, W as ListEventsOptions, X as RequestOptions, Y as MultipartUploadPartOptions, Z as RetrieveAssetOptions, _ as AssetSearchResult, _t as TypedEvent, a as ClassificationLabel, at as UpdateFolderOptions, b as AssetVisibility, bt as EventFactValues, c as ClassificationReport, ct as UploadedAsset, d as Asset, dt as WebhookPayloadInput, et as SignUploadTokenOptions, f as AssetChecksums, ft as GetEventsResponse, g as AssetSearchResponse, gt as EventAsset, h as AssetPage, i as ClassificationCategoryReport, it as UpdateAssetOptions, j as DeleteAssetOptions, jt as AssetSafetyHoldReason, k as CreateMultipartUploadPartOptions, l as Likelihood, lt as VerifyWebhookSignatureOptions, m as AssetContentOptions, mt as Folder, n as ClassificationCategories, nt as SignedUrl, o as ClassificationNotEvaluatedReason, ot as UploadAssetPartOptions, p as AssetChildrenPage, pt as PostAssetSignedUrlResponse, q as MoveFolderOptions, r as ClassificationCategory, rt as SubmitAssetOptions, s as ClassificationQualifierResults, st as UploadPresetSubmitAssetOptions, t as WebhookEventPayload, tt as SignedUploadToken, u as ModerationQualifier, ut as WebhookHeadersInput, v as AssetStatus, vt as EventCategory, w as CdnServeOptions, wt as Order, x as CalmLensAppClientOptions, xt as EventFacts, y as AssetType, yt as EventFact, z as IterateAssetsOptions } from "./WebhookPayload-Cgb32aSH.js";
2
- import { _ as ProcessingFeatureStage, a as CalmLensErrorDetails, c as ApiErrorCode, d as AgeRange, f as BoundingBox, g as ProcessingFeatureResults, h as ProcessingFeatureId, i as CalmLensErrorCode, l as FlaggedContentAction, m as DetectedPerson, n as CALMLENS_ERROR_CODES, o as CalmLensErrorOptions, p as DetectedFace, r as CalmLensError, s as SdkErrorCode, t as SDK_VERSION, u as FlaggedContentPolicy, v as ProcessingFeatures } from "./index-BgmWj3KL.js";
1
+ import { $ as SearchAssetsOptions, A as DeleteAssetContentOptions, B as Lens, C as CdnAssetUrlOptions, Ct as EventSeverity, D as CreateAssetSignedUrlOptions, Dt as LensType, E as ConnectionOptions, Et as Page, F as IdempotencyOptions, Ft as ImageData, G as ModerateTextOptions, H as ListAssetChildrenOptions, I as ImageTransform, It as MetadataItem, J as MultipartUploadOptions, K as MoveAssetOptions, L as ImageTransformOptions, Lt as PreviewImage, M as EnsureLensOptions, Mt as AssetSafetyHoldReason, N as EnsureLensesOptions, Nt as DocumentData, O as CreateFolderOptions, Ot as AssetSearchMatchField, P as FolderIdOptions, Pt as ExtractedText, Q as RetryAssetOptions, R as IterateAssetChildrenOptions, Rt as ProcessingOptions, S as CalmLensServerClientOptions, St as EventFacts, T as CdnTransform, Tt as Order, U as ListAssetsOptions, V as LensTransform, W as ListEventsOptions, X as RequestOptions, Y as MultipartUploadPartOptions, Z as RetrieveAssetOptions, _ as AssetSearchResult, _t as EventAsset, a as ClassificationLabel, at as UpdateFolderOptions, b as AssetVisibility, bt as EventFact, c as ClassificationReport, ct as UploadedAsset, d as Asset, dt as WebhookHeadersInput, et as SignUploadTokenOptions, f as AssetChecksums, ft as WebhookPayloadInput, g as AssetSearchResponse, h as AssetPage, ht as Folder, i as ClassificationCategoryReport, it as UpdateAssetOptions, j as DeleteAssetOptions, jt as AssetSafetyHold, k as CreateMultipartUploadPartOptions, kt as AssetSearchQuery, l as Likelihood, lt as VerifyWebhookSignatureOptions, m as AssetContentOptions, mt as PostAssetSignedUrlResponse, n as ClassificationCategories, nt as SignedUrl, o as ClassificationNotEvaluatedReason, ot as UploadAssetPartOptions, p as AssetChildrenPage, pt as GetEventsResponse, q as MoveFolderOptions, r as ClassificationCategory, rt as SubmitAssetOptions, s as ClassificationQualifierResults, st as UploadPresetSubmitAssetOptions, t as WebhookEventPayload, tt as SignedUploadToken, u as ModerationQualifier, ut as WaitForAssetDecisionOptions, v as AssetStatus, vt as TypedEvent, w as CdnServeOptions, wt as EventType, x as CalmLensAppClientOptions, xt as EventFactValues, y as AssetType, yt as EventCategory, z as IterateAssetsOptions } from "./WebhookPayload-B7CgSmI5.js";
2
+ import { _ as ProcessingFeatureStage, a as CalmLensErrorDetails, c as ApiErrorCode, d as AgeRange, f as BoundingBox, g as ProcessingFeatureResults, h as ProcessingFeatureId, i as CalmLensErrorCode, l as FlaggedContentAction, m as DetectedPerson, n as CALMLENS_ERROR_CODES, o as CalmLensErrorOptions, p as DetectedFace, r as CalmLensError, s as SdkErrorCode, t as SDK_VERSION, u as FlaggedContentPolicy, v as ProcessingFeatures } from "./index-BywTQbRq.js";
3
3
  //#region src/client/CalmLensServerClient.d.ts
4
4
  interface LensCache {
5
5
  readonly ensuredLenses: Map<string, Lens>;
@@ -115,6 +115,12 @@ declare class CalmLensServerClient {
115
115
  * moderated like a new upload; its content must still be stored.
116
116
  */
117
117
  retry: ({ assetId }: RetryAssetOptions) => Promise<Asset>;
118
+ /**
119
+ * Waits for an asset's moderation decision (`approved`, `rejected` or `error`) and returns
120
+ * the decided asset, checking every few seconds. Rejects with `sdk/timeout` if there is no
121
+ * decision within `timeoutMs` (default 60000). Webhooks report decisions without polling.
122
+ */
123
+ waitForDecision: ({ assetId, ...options }: WaitForAssetDecisionOptions) => Promise<Asset>;
118
124
  /**
119
125
  * Removes an asset's stored content (source, preview and retained extracted text) while
120
126
  * keeping the asset record, metadata and moderation report. The returned asset has
@@ -169,11 +175,13 @@ declare class CalmLensServerClient {
169
175
  */
170
176
  ensureLens(options: EnsureLensOptions): Promise<Lens>;
171
177
  /**
172
- * Create or update several named lenses in one API request.
178
+ * Create or update several named lenses. New definitions are sent in one API request, or in
179
+ * consecutive requests of at most {@link ENSURE_LENSES_MAX_PER_REQUEST} definitions, in order.
173
180
  * Each lens follows the same versioning and idempotency rules as ensureLens().
174
181
  */
175
182
  ensureLenses({ lenses }: EnsureLensesOptions): Promise<Lens[]>;
176
183
  private submitEnsureLenses;
184
+ private submitEnsureLensesChunk;
177
185
  }
178
186
  //#endregion
179
187
  //#region src/client/CalmLensWebhooks.d.ts
@@ -199,4 +207,4 @@ export declare function verifyWebhookSignature(options: VerifyWebhookSignatureOp
199
207
  */
200
208
  export declare function parseWebhookEvent(options: VerifyWebhookSignatureOptions): Promise<WebhookEventPayload>;
201
209
  //#endregion
202
- export { type AgeRange, type ApiErrorCode, type Asset, type AssetChecksums, type AssetChildrenPage, type AssetContentOptions, type AssetPage, type AssetSafetyHold, type AssetSafetyHoldReason, type AssetSearchMatchField, type AssetSearchQuery, type AssetSearchResponse, type AssetSearchResult, type AssetStatus, type AssetType, type AssetVisibility, type BoundingBox, CALMLENS_ERROR_CODES, type CalmLensAppClientOptions, CalmLensError, type CalmLensErrorCode, type CalmLensErrorDetails, type CalmLensErrorOptions, CalmLensServerClient, type CalmLensServerClientOptions, type CdnAssetUrlOptions, type CdnServeOptions, type CdnTransform, type ClassificationCategories, type ClassificationCategory, type ClassificationCategoryReport, type ClassificationLabel, type ClassificationNotEvaluatedReason, type ClassificationQualifierResults, type ClassificationReport, type ConnectionOptions, type CreateAssetSignedUrlOptions, type CreateFolderOptions, type CreateMultipartUploadPartOptions, type DeleteAssetContentOptions, type DeleteAssetOptions, type DetectedFace, type DetectedPerson, type DocumentData, type EnsureLensOptions, type EnsureLensesOptions, type EventAsset, type EventCategory, type EventFact, type EventFactValues, type EventFacts, type EventSeverity, type EventType, type GetEventsResponse as EventsPage, type ExtractedText, type FlaggedContentAction, type FlaggedContentPolicy, type Folder, type FolderIdOptions, type IdempotencyOptions, type ImageData, type ImageTransform, type ImageTransformOptions, type IterateAssetChildrenOptions, type IterateAssetsOptions, type Lens, type LensTransform, type LensType, type Likelihood, type ListAssetChildrenOptions, type ListAssetsOptions, type ListEventsOptions, type MetadataItem, type ModerateTextOptions, type ModerationQualifier, type MoveAssetOptions, type MoveFolderOptions, type MultipartUploadOptions, type MultipartUploadPartOptions, type Order, type Page, type PreviewImage, type ProcessingFeatureId, type ProcessingFeatureResults, type ProcessingFeatureStage, type ProcessingFeatures, type ProcessingOptions, type RequestOptions, type RetrieveAssetOptions, type RetryAssetOptions, SDK_VERSION, type SdkErrorCode, type SearchAssetsOptions, type SignUploadTokenOptions, type SignedUploadToken, type SignedUrl, type SubmitAssetOptions, type TypedEvent, type UpdateAssetOptions, type UpdateFolderOptions, type UploadAssetPartOptions, type UploadPresetSubmitAssetOptions, type UploadedAsset, type VerifyWebhookSignatureOptions, type WebhookEventPayload, type WebhookHeadersInput, type WebhookPayloadInput };
210
+ export { type AgeRange, type ApiErrorCode, type Asset, type AssetChecksums, type AssetChildrenPage, type AssetContentOptions, type AssetPage, type AssetSafetyHold, type AssetSafetyHoldReason, type AssetSearchMatchField, type AssetSearchQuery, type AssetSearchResponse, type AssetSearchResult, type AssetStatus, type AssetType, type AssetVisibility, type BoundingBox, CALMLENS_ERROR_CODES, type CalmLensAppClientOptions, CalmLensError, type CalmLensErrorCode, type CalmLensErrorDetails, type CalmLensErrorOptions, CalmLensServerClient, type CalmLensServerClientOptions, type CdnAssetUrlOptions, type CdnServeOptions, type CdnTransform, type ClassificationCategories, type ClassificationCategory, type ClassificationCategoryReport, type ClassificationLabel, type ClassificationNotEvaluatedReason, type ClassificationQualifierResults, type ClassificationReport, type ConnectionOptions, type CreateAssetSignedUrlOptions, type CreateFolderOptions, type CreateMultipartUploadPartOptions, type DeleteAssetContentOptions, type DeleteAssetOptions, type DetectedFace, type DetectedPerson, type DocumentData, type EnsureLensOptions, type EnsureLensesOptions, type EventAsset, type EventCategory, type EventFact, type EventFactValues, type EventFacts, type EventSeverity, type EventType, type GetEventsResponse as EventsPage, type ExtractedText, type FlaggedContentAction, type FlaggedContentPolicy, type Folder, type FolderIdOptions, type IdempotencyOptions, type ImageData, type ImageTransform, type ImageTransformOptions, type IterateAssetChildrenOptions, type IterateAssetsOptions, type Lens, type LensTransform, type LensType, type Likelihood, type ListAssetChildrenOptions, type ListAssetsOptions, type ListEventsOptions, type MetadataItem, type ModerateTextOptions, type ModerationQualifier, type MoveAssetOptions, type MoveFolderOptions, type MultipartUploadOptions, type MultipartUploadPartOptions, type Order, type Page, type PreviewImage, type ProcessingFeatureId, type ProcessingFeatureResults, type ProcessingFeatureStage, type ProcessingFeatures, type ProcessingOptions, type RequestOptions, type RetrieveAssetOptions, type RetryAssetOptions, SDK_VERSION, type SdkErrorCode, type SearchAssetsOptions, type SignUploadTokenOptions, type SignedUploadToken, type SignedUrl, type SubmitAssetOptions, type TypedEvent, type UpdateAssetOptions, type UpdateFolderOptions, type UploadAssetPartOptions, type UploadPresetSubmitAssetOptions, type UploadedAsset, type VerifyWebhookSignatureOptions, type WaitForAssetDecisionOptions, type WebhookEventPayload, type WebhookHeadersInput, type WebhookPayloadInput };
package/cjs/server.js CHANGED
@@ -1,10 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_CalmLensError = require("./CalmLensError-CKwMKV0S.js");
3
- const require_src = require("./src-Dsc8Pn6v.js");
4
- const require_CalmLensWebhooks = require("./CalmLensWebhooks-BTPxKvcD.js");
5
- const require_CalmLensUtils = require("./CalmLensUtils-Dg3s4loH.js");
6
- const require_CalmLensConnection = require("./CalmLensConnection-CYtBP-vu.js");
7
- //#region src/client/CalmLensServerClient.ts
2
+ const require_CalmLensVersion = require("./CalmLensVersion-DjhsJ1gj.js");
3
+ require("./index.js");
4
+ const require_CalmLensWebhooks = require("./CalmLensWebhooks-hVquX5L1.js");
5
+ const require_CalmLensUtils = require("./CalmLensUtils-vX5H_vMn.js");
6
+ const require_CalmLensConnection = require("./CalmLensConnection-DzRDCMOP.js");
8
7
  const getEnsureLensCacheKey = (options) => require_CalmLensWebhooks.stringifyJsonCanonical({
9
8
  identifier: options.identifier,
10
9
  name: options.name,
@@ -47,7 +46,7 @@ var CalmLensServerClient = class CalmLensServerClient {
47
46
  }
48
47
  constructor(options, lenses) {
49
48
  require_CalmLensUtils.validateServerClientOptions(options);
50
- if ((require_src.isBrowserRuntime() || require_src.isReactNativeRuntime()) && !options.dangerouslyAllowBrowser) throw require_CalmLensError.invalidConfig("CalmLensServerClient is running in a browser or app, where anyone could read the API key. Call CalmLens from your server, upload from the browser or app with CalmLensAppClient, or set dangerouslyAllowBrowser: true for trusted internal tools.");
49
+ if ((require_CalmLensVersion.isBrowserRuntime() || require_CalmLensVersion.isReactNativeRuntime()) && !options.dangerouslyAllowBrowser) throw require_CalmLensVersion.invalidConfig("CalmLensServerClient is running in a browser or app, where anyone could read the API key. Call CalmLens from your server, upload from the browser or app with CalmLensAppClient, or set dangerouslyAllowBrowser: true for trusted internal tools.");
51
50
  const { apiKey, ...rest } = options;
52
51
  this.#apiKey = apiKey;
53
52
  this.#settings = {
@@ -226,7 +225,7 @@ sign: async (options) => {
226
225
  */
227
226
  createSignedUrl: async ({ assetId, ...options }) => {
228
227
  const encodedAssetId = requireId(assetId, "Asset ID");
229
- if (options.lens && options.transform) throw require_CalmLensError.invalidArgument("Specify either a lens or a transform, not both");
228
+ if (options.lens && options.transform) throw require_CalmLensVersion.invalidArgument("Specify either a lens or a transform, not both");
230
229
  return this.request("POST", `/assets/${encodedAssetId}/signed-url`, { body: {
231
230
  resource: options.resource ?? "content",
232
231
  expiresInSeconds: options.expiresInSeconds ?? 900,
@@ -242,6 +241,16 @@ sign: async (options) => {
242
241
  */
243
242
  retry: async ({ assetId }) => this.request("POST", `/assets/${requireId(assetId, "Asset ID")}/retry`),
244
243
  /**
244
+ * Waits for an asset's moderation decision (`approved`, `rejected` or `error`) and returns
245
+ * the decided asset, checking every few seconds. Rejects with `sdk/timeout` if there is no
246
+ * decision within `timeoutMs` (default 60000). Webhooks report decisions without polling.
247
+ */
248
+ waitForDecision: async ({ assetId, ...options }) => {
249
+ requireId(assetId, "Asset ID");
250
+ const client = options.signal ? this.withRequestOptions({ signal: options.signal }) : this;
251
+ return require_CalmLensUtils.pollForDecision(() => client.assets.retrieve({ assetId }), options, require_CalmLensUtils.sleep);
252
+ },
253
+ /**
245
254
  * Removes an asset's stored content (source, preview and retained extracted text) while
246
255
  * keeping the asset record, metadata and moderation report. The returned asset has
247
256
  * `storageDeletedAt` set; the CDN no longer serves it.
@@ -308,17 +317,18 @@ sign: async (options) => {
308
317
  * Supplying the same definition and version is idempotent.
309
318
  */
310
319
  async ensureLens(options) {
311
- if (!options?.identifier) throw require_CalmLensError.invalidArgument("Lens identifier is required");
320
+ if (!options?.identifier) throw require_CalmLensVersion.invalidArgument("Lens identifier is required");
312
321
  const [lens] = await this.ensureLenses({ lenses: [options] });
313
322
  return lens;
314
323
  }
315
324
  /**
316
- * Create or update several named lenses in one API request.
325
+ * Create or update several named lenses. New definitions are sent in one API request, or in
326
+ * consecutive requests of at most {@link ENSURE_LENSES_MAX_PER_REQUEST} definitions, in order.
317
327
  * Each lens follows the same versioning and idempotency rules as ensureLens().
318
328
  */
319
329
  async ensureLenses({ lenses }) {
320
- if (!Array.isArray(lenses) || lenses.length === 0) throw require_CalmLensError.invalidArgument("At least one lens is required");
321
- if (lenses.some((option) => !option?.identifier)) throw require_CalmLensError.invalidArgument("Lens identifier is required");
330
+ if (!Array.isArray(lenses) || lenses.length === 0) throw require_CalmLensVersion.invalidArgument("At least one lens is required");
331
+ if (lenses.some((option) => !option?.identifier)) throw require_CalmLensVersion.invalidArgument("Lens identifier is required");
322
332
  const { ensuredLenses, pendingEnsureLenses } = this.#lenses;
323
333
  const missingOptions = [];
324
334
  const missingKeys = /* @__PURE__ */ new Set();
@@ -341,28 +351,31 @@ sign: async (options) => {
341
351
  }
342
352
  return lenses.map((option) => {
343
353
  const lens = ensuredLenses.get(getEnsureLensCacheKey(option));
344
- if (!lens) throw new require_CalmLensError.CalmLensError(require_CalmLensError.SDK_ERROR_CODES.INVALID_RESPONSE, { message: `CalmLens did not return lens "${option.identifier}"` });
354
+ if (!lens) throw new require_CalmLensVersion.CalmLensError(require_CalmLensVersion.SDK_ERROR_CODES.INVALID_RESPONSE, { message: `CalmLens did not return lens "${option.identifier}"` });
345
355
  return lens;
346
356
  });
347
357
  }
348
358
  async submitEnsureLenses(options) {
359
+ for (let start = 0; start < options.length; start += 100) await this.submitEnsureLensesChunk(options.slice(start, start + 100));
360
+ }
361
+ async submitEnsureLensesChunk(options) {
349
362
  const result = await this.request("PUT", `${this.projectPath}/lenses`, { body: { lenses: options } });
350
363
  const returned = Array.isArray(result?.lenses) ? result.lenses : [];
351
- if (returned.length !== options.length) throw new require_CalmLensError.CalmLensError(require_CalmLensError.SDK_ERROR_CODES.INVALID_RESPONSE, { message: `Expected ${options.length} lenses but CalmLens returned ${returned.length}` });
364
+ if (returned.length !== options.length) throw new require_CalmLensVersion.CalmLensError(require_CalmLensVersion.SDK_ERROR_CODES.INVALID_RESPONSE, { message: `Expected ${options.length} lenses but CalmLens returned ${returned.length}` });
352
365
  const { ensuredLenses } = this.#lenses;
353
366
  for (const [index, lens] of returned.entries()) {
354
367
  const optionsForLens = options[index];
355
- if (lens?.identifier !== optionsForLens.identifier) throw new require_CalmLensError.CalmLensError(require_CalmLensError.SDK_ERROR_CODES.INVALID_RESPONSE, { message: `Expected lens "${optionsForLens.identifier}" at position ${index}` });
368
+ if (lens?.identifier !== optionsForLens.identifier) throw new require_CalmLensVersion.CalmLensError(require_CalmLensVersion.SDK_ERROR_CODES.INVALID_RESPONSE, { message: `Expected lens "${optionsForLens.identifier}" at position ${index}` });
356
369
  for (const [cacheKey, cachedLens] of ensuredLenses) if (cachedLens.identifier === optionsForLens.identifier) ensuredLenses.delete(cacheKey);
357
370
  ensuredLenses.set(getEnsureLensCacheKey(optionsForLens), lens);
358
371
  }
359
372
  }
360
373
  };
361
374
  //#endregion
362
- exports.CALMLENS_ERROR_CODES = require_CalmLensError.CALMLENS_ERROR_CODES;
363
- exports.CalmLensError = require_CalmLensError.CalmLensError;
375
+ exports.CALMLENS_ERROR_CODES = require_CalmLensVersion.CALMLENS_ERROR_CODES;
376
+ exports.CalmLensError = require_CalmLensVersion.CalmLensError;
364
377
  exports.CalmLensServerClient = CalmLensServerClient;
365
- exports.SDK_VERSION = require_src.SDK_VERSION;
378
+ exports.SDK_VERSION = require_CalmLensVersion.SDK_VERSION;
366
379
  exports.WEBHOOK_DELIVERY_HEADER = require_CalmLensWebhooks.WEBHOOK_DELIVERY_HEADER;
367
380
  exports.WEBHOOK_SIGNATURE_HEADER = require_CalmLensWebhooks.WEBHOOK_SIGNATURE_HEADER;
368
381
  exports.WEBHOOK_SIGNATURE_TOLERANCE_SECONDS = require_CalmLensWebhooks.WEBHOOK_SIGNATURE_TOLERANCE_SECONDS;
package/cjs/testing.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as SearchAssetsOptions, A as DeleteAssetContentOptions, B as Lens, C as CdnAssetUrlOptions, D as CreateAssetSignedUrlOptions, G as ModerateTextOptions, H as ListAssetChildrenOptions, K as MoveAssetOptions, M as EnsureLensOptions, N as EnsureLensesOptions, O as CreateFolderOptions, P as FolderIdOptions, Q as RetryAssetOptions, R as IterateAssetChildrenOptions, S as CalmLensServerClientOptions, U as ListAssetsOptions, W as ListEventsOptions, Z as RetrieveAssetOptions, _t as TypedEvent, at as UpdateFolderOptions, d as Asset, et as SignUploadTokenOptions, ft as GetEventsResponse, g as AssetSearchResponse, h as AssetPage, ht as Event, it as UpdateAssetOptions, j as DeleteAssetOptions, kt as AssetBinaryPayloadInput, mt as Folder, ot as UploadAssetPartOptions, p as AssetChildrenPage, pt as PostAssetSignedUrlResponse, q as MoveFolderOptions, r as ClassificationCategory, rt as SubmitAssetOptions, t as WebhookEventPayload, tt as SignedUploadToken, v as AssetStatus, w as CdnServeOptions, z as IterateAssetsOptions } from "./WebhookPayload-Cgb32aSH.js";
1
+ import { $ as SearchAssetsOptions, A as DeleteAssetContentOptions, At as AssetBinaryPayloadInput, B as Lens, C as CdnAssetUrlOptions, D as CreateAssetSignedUrlOptions, G as ModerateTextOptions, H as ListAssetChildrenOptions, K as MoveAssetOptions, M as EnsureLensOptions, N as EnsureLensesOptions, O as CreateFolderOptions, P as FolderIdOptions, Q as RetryAssetOptions, R as IterateAssetChildrenOptions, S as CalmLensServerClientOptions, U as ListAssetsOptions, W as ListEventsOptions, Z as RetrieveAssetOptions, at as UpdateFolderOptions, d as Asset, et as SignUploadTokenOptions, g as AssetSearchResponse, gt as Event, h as AssetPage, ht as Folder, it as UpdateAssetOptions, j as DeleteAssetOptions, mt as PostAssetSignedUrlResponse, ot as UploadAssetPartOptions, p as AssetChildrenPage, pt as GetEventsResponse, q as MoveFolderOptions, r as ClassificationCategory, rt as SubmitAssetOptions, t as WebhookEventPayload, tt as SignedUploadToken, ut as WaitForAssetDecisionOptions, v as AssetStatus, vt as TypedEvent, w as CdnServeOptions, z as IterateAssetsOptions } from "./WebhookPayload-B7CgSmI5.js";
2
2
  import * as zod from "zod";
3
3
  //#region ../shared/src/TestTriggers.d.ts
4
4
  type ClassificationTestSignal = ClassificationCategory | "sexual.involving-minors" | "violence.graphic";
@@ -32,6 +32,8 @@ declare const GRANT_SCHEMA: zod.ZodObject<{
32
32
  "metadata:read": "metadata:read";
33
33
  "metadata:write": "metadata:write";
34
34
  "project:manage": "project:manage";
35
+ "reviews:read": "reviews:read";
36
+ "reviews:write": "reviews:write";
35
37
  "settings:read": "settings:read";
36
38
  "settings:write": "settings:write";
37
39
  "upload-presets:read": "upload-presets:read";
@@ -131,6 +133,7 @@ interface MockCalmLensOperationOptions {
131
133
  "assets.createSignedUrl": CreateAssetSignedUrlOptions;
132
134
  "assets.move": MoveAssetOptions;
133
135
  "assets.retry": RetryAssetOptions;
136
+ "assets.waitForDecision": WaitForAssetDecisionOptions;
134
137
  "assets.deleteContent": DeleteAssetContentOptions;
135
138
  "assets.delete": DeleteAssetOptions;
136
139
  "text.moderate": ModerateTextOptions;
@@ -260,6 +263,8 @@ export declare class MockCalmLensServerClient {
260
263
  createSignedUrl: (signedUrlOptions: CreateAssetSignedUrlOptions) => Promise<PostAssetSignedUrlResponse>;
261
264
  move: (options: MoveAssetOptions) => Promise<Asset>;
262
265
  retry: (options: RetryAssetOptions) => Promise<Asset>;
266
+ /** Waits like the real client, checking the mock's storage for a decision. */
267
+ waitForDecision: (options: WaitForAssetDecisionOptions) => Promise<Asset>;
263
268
  deleteContent: (options: DeleteAssetContentOptions) => Promise<Asset>;
264
269
  delete: (options: DeleteAssetOptions) => Promise<void>;
265
270
  };