@calmlens/sdk 0.12.0 → 0.14.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 (37) hide show
  1. package/README.md +54 -37
  2. package/cjs/CalmLensConnection-Bth5fJyp.js +234 -0
  3. package/cjs/CalmLensUtils-DNdmYeX6.js +699 -0
  4. package/cjs/{CalmLensError-CKwMKV0S.js → CalmLensVersion-Bs0DreBV.js} +114 -1
  5. package/cjs/{CalmLensWebhooks-BTPxKvcD.js → CalmLensWebhooks-6thkvr_F.js} +9 -9
  6. package/cjs/WebhookPayload-vy8HNMaK.d.ts +15834 -0
  7. package/cjs/app.d.ts +3 -3
  8. package/cjs/app.js +10 -10
  9. package/cjs/{index-BgmWj3KL.d.ts → index-Dz340UQ9.d.ts} +29 -1
  10. package/cjs/index.d.ts +3 -3
  11. package/cjs/index.js +4 -5
  12. package/cjs/server.d.ts +16 -7
  13. package/cjs/server.js +35 -21
  14. package/cjs/testing.d.ts +21 -42
  15. package/cjs/testing.js +181 -94
  16. package/esm/CalmLensConnection-DrCOL9h9.js +193 -0
  17. package/esm/{CalmLensUtils-Cx32j2zt.js → CalmLensUtils-BQo79TA1.js} +316 -2
  18. package/esm/{CalmLensError-CihGG26K.js → CalmLensVersion-DPnL_Ebv.js} +91 -2
  19. package/esm/{CalmLensWebhooks-DShmAal4.js → CalmLensWebhooks-CWlD-f_P.js} +2 -2
  20. package/esm/WebhookPayload-vy8HNMaK.d.ts +15834 -0
  21. package/esm/app.d.ts +3 -3
  22. package/esm/app.js +4 -4
  23. package/esm/{index-BgmWj3KL.d.ts → index-Dz340UQ9.d.ts} +29 -1
  24. package/esm/index.d.ts +3 -3
  25. package/esm/index.js +1 -3
  26. package/esm/server.d.ts +16 -7
  27. package/esm/server.js +24 -10
  28. package/esm/testing.d.ts +21 -42
  29. package/esm/testing.js +152 -65
  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/WebhookPayload-Cgb32aSH.d.ts +0 -10187
  34. package/cjs/src-Dsc8Pn6v.js +0 -45
  35. package/esm/CalmLensConnection-wLNy0OIP.js +0 -475
  36. package/esm/WebhookPayload-Cgb32aSH.d.ts +0 -10187
  37. 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 ModerateTextOptions, A as CalmLensServerClientOptions, At as EventSeverity, B as EnsureLensOptions, Bt as AssetSafetyHold, C as AssetProcessingStatus, D as AssetType, Dt as EventFact, E as AssetSearchResult, Et as EventCategory, F as CreateAssetSignedUrlOptions, Ft as Page, G as ImageTransformOptions, Gt as PreviewImage, H as FolderIdOptions, Ht as ExtractedText, I as CreateFolderOptions, It as LensType, J as Lens, K as IterateAssetChildrenOptions, Kt as ProcessingOptions, L as CreateMultipartUploadPartOptions, Lt as AssetSearchMatchField, M as CdnServeOptions, N as CdnTransform, Nt as Folder, O as AssetVisibility, Ot as EventFactValues, P as ConnectionOptions, Pt as Order, Q as ListEventsOptions, R as DeleteAssetContentOptions, Rt as AssetSearchQuery, S as AssetProcessing, T as AssetSearchResponse, Tt as TypedEvent, U as IdempotencyOptions, Ut as ImageData, V as EnsureLensesOptions, Vt as AssetSafetyHoldReason, W as ImageTransform, Wt as MetadataItem, X as ListAssetChildrenOptions, Y as LensTransform, Z as ListAssetsOptions, _ as AssetContentStatus, _t as VerifyWebhookSignatureOptions, a as ClassificationLabel, at as RetrieveAssetOptions, b as AssetModerationStatus, bt as WebhookPayloadInput, c as ClassificationReport, ct as SignUploadTokenOptions, d as Asset, dt as SubmitAssetOptions, et as MoveAssetOptions, f as AssetChecksums, ft as UpdateAssetOptions, g as AssetContentRemovalReason, gt as UploadedAsset, h as AssetContentOptions, ht as UploadPresetSubmitAssetOptions, i as ClassificationCategoryReport, it as RequestOptions, j as CdnAssetUrlOptions, jt as EventType, k as CalmLensAppClientOptions, kt as EventFacts, l as Likelihood, lt as SignedUploadToken, m as AssetContent, mt as UploadAssetPartOptions, n as ClassificationCategories, nt as MultipartUploadOptions, o as ClassificationNotEvaluatedReason, ot as RetryAssetOptions, p as AssetChildrenPage, pt as UpdateFolderOptions, q as IterateAssetsOptions, r as ClassificationCategory, rt as MultipartUploadPartOptions, s as ClassificationQualifierResults, st as SearchAssetsOptions, t as WebhookEventPayload, tt as MoveFolderOptions, u as ModerationQualifier, ut as SignedUrl, v as AssetModeration, vt as WaitForAssetDecisionOptions, w as AssetReviewerAction, wt as EventAsset, x as AssetPage, xt as GetEventsResponse, y as AssetModerationAction, yt as WebhookHeadersInput, z as DeleteAssetOptions } from "./WebhookPayload-vy8HNMaK.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-Dz340UQ9.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 AssetContent, type AssetContentOptions, type AssetContentRemovalReason, type AssetContentStatus, type AssetModeration, type AssetModerationAction, type AssetModerationStatus, type AssetPage, type AssetProcessing, type AssetProcessingStatus, type AssetReviewerAction, type AssetSafetyHold, type AssetSafetyHoldReason, type AssetSearchMatchField, type AssetSearchQuery, type AssetSearchResponse, type AssetSearchResult, 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 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-Bs0DreBV.js");
3
+ require("./index.js");
4
+ const require_CalmLensUtils = require("./CalmLensUtils-DNdmYeX6.js");
5
+ const require_CalmLensConnection = require("./CalmLensConnection-Bth5fJyp.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-vy8HNMaK.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";
@@ -179,6 +180,8 @@ declare const API_ERROR_CODES: {
179
180
  readonly UPLOAD_PRESET_NOT_FOUND: "upload-preset/not-found";
180
181
  readonly UPLOAD_PRESET_DISABLED: "upload-preset/disabled";
181
182
  readonly UPLOAD_PRESET_TOKEN_REQUIRED: "upload-preset/token-required";
183
+ readonly REMOTE_URL_NOT_ALLOWED: "upload/remote-url-not-allowed";
184
+ readonly WEBSITE_RATE_LIMIT_EXCEEDED: "upload/website-rate-limit-exceeded";
182
185
  readonly UPLOAD_PRESET_CONTENT_TYPE_NOT_ALLOWED: "upload-preset/content-type-not-allowed";
183
186
  readonly UPLOAD_PRESET_TOO_LARGE: "upload-preset/too-large";
184
187
  readonly UPLOAD_PRESET_DAILY_LIMIT_REACHED: "upload-preset/daily-limit-reached";
@@ -187,6 +190,17 @@ declare const API_ERROR_CODES: {
187
190
  readonly UPLOAD_TOKEN_INVALID: "upload-token/invalid";
188
191
  readonly UPLOAD_TOKEN_EXPIRED: "upload-token/expired";
189
192
  readonly UPLOAD_TOKEN_USED: "upload-token/used";
193
+ readonly INVALID_REMOTE_URL: "asset/invalid-remote-url";
194
+ readonly REMOTE_URL_UNAVAILABLE: "asset/remote-url-unavailable";
195
+ readonly APPEAL_NOT_FOUND: "appeal/not-found";
196
+ readonly APPEAL_JUDGMENT_NOT_FOUND: "appeal/judgment-not-found";
197
+ readonly APPEAL_ASSET_NOT_FOUND: "appeal/asset-not-found";
198
+ readonly APPEAL_PERMISSION_DENIED: "appeal/permission-denied";
199
+ readonly APPEAL_ALREADY_REVIEWED: "appeal/already-reviewed";
200
+ readonly APPEAL_DECISION_CHANGED: "appeal/decision-changed";
201
+ readonly APPEAL_INVALID_ACTION: "appeal/invalid-action";
202
+ readonly APPEAL_SAFETY_HELD: "appeal/safety-held";
203
+ readonly APPEAL_CONTENT_UNAVAILABLE: "appeal/content-unavailable";
190
204
  };
191
205
  type ApiErrorCode = (typeof API_ERROR_CODES)[keyof typeof API_ERROR_CODES];
192
206
  //#endregion
@@ -230,6 +244,7 @@ declare const CALMLENS_ERROR_CODES: {
230
244
  readonly MULTIPART_IMAGE_TOO_LARGE: "upload/multipart-image-too-large";
231
245
  readonly IMAGE_EXCEEDED_MAX_DIMENSIONS: "upload/image-exceeded-max-dimensions";
232
246
  readonly UPLOAD_LIMIT_EXCEEDED: "upload/limit-exceeded";
247
+ readonly SPEND_LIMIT_REACHED: "upload/spend-limit-reached";
233
248
  readonly INVALID_UPLOAD_MIME_TYPE: "upload/invalid-mime-type";
234
249
  readonly INVALID_EVENT_CURSOR: "events/invalid-cursor";
235
250
  readonly INVALID_UPLOAD_PAYLOAD: "upload/invalid-payload";
@@ -257,6 +272,8 @@ declare const CALMLENS_ERROR_CODES: {
257
272
  readonly UPLOAD_PRESET_NOT_FOUND: "upload-preset/not-found";
258
273
  readonly UPLOAD_PRESET_DISABLED: "upload-preset/disabled";
259
274
  readonly UPLOAD_PRESET_TOKEN_REQUIRED: "upload-preset/token-required";
275
+ readonly REMOTE_URL_NOT_ALLOWED: "upload/remote-url-not-allowed";
276
+ readonly WEBSITE_RATE_LIMIT_EXCEEDED: "upload/website-rate-limit-exceeded";
260
277
  readonly UPLOAD_PRESET_CONTENT_TYPE_NOT_ALLOWED: "upload-preset/content-type-not-allowed";
261
278
  readonly UPLOAD_PRESET_TOO_LARGE: "upload-preset/too-large";
262
279
  readonly UPLOAD_PRESET_DAILY_LIMIT_REACHED: "upload-preset/daily-limit-reached";
@@ -265,6 +282,17 @@ declare const CALMLENS_ERROR_CODES: {
265
282
  readonly UPLOAD_TOKEN_INVALID: "upload-token/invalid";
266
283
  readonly UPLOAD_TOKEN_EXPIRED: "upload-token/expired";
267
284
  readonly UPLOAD_TOKEN_USED: "upload-token/used";
285
+ readonly INVALID_REMOTE_URL: "asset/invalid-remote-url";
286
+ readonly REMOTE_URL_UNAVAILABLE: "asset/remote-url-unavailable";
287
+ readonly APPEAL_NOT_FOUND: "appeal/not-found";
288
+ readonly APPEAL_JUDGMENT_NOT_FOUND: "appeal/judgment-not-found";
289
+ readonly APPEAL_ASSET_NOT_FOUND: "appeal/asset-not-found";
290
+ readonly APPEAL_PERMISSION_DENIED: "appeal/permission-denied";
291
+ readonly APPEAL_ALREADY_REVIEWED: "appeal/already-reviewed";
292
+ readonly APPEAL_DECISION_CHANGED: "appeal/decision-changed";
293
+ readonly APPEAL_INVALID_ACTION: "appeal/invalid-action";
294
+ readonly APPEAL_SAFETY_HELD: "appeal/safety-held";
295
+ readonly APPEAL_CONTENT_UNAVAILABLE: "appeal/content-unavailable";
268
296
  /** The request could not be completed: DNS, TLS, a refused or reset connection, a truncated body. */
269
297
  readonly TRANSPORT_ERROR: "sdk/transport-error";
270
298
  /** The request did not finish within `timeoutMs`. */
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 ModerateTextOptions, A as CalmLensServerClientOptions, At as EventSeverity, B as EnsureLensOptions, Bt as AssetSafetyHold, C as AssetProcessingStatus, D as AssetType, Dt as EventFact, E as AssetSearchResult, Et as EventCategory, F as CreateAssetSignedUrlOptions, Ft as Page, G as ImageTransformOptions, Gt as PreviewImage, H as FolderIdOptions, Ht as ExtractedText, I as CreateFolderOptions, It as LensType, J as Lens, K as IterateAssetChildrenOptions, Kt as ProcessingOptions, L as CreateMultipartUploadPartOptions, Lt as AssetSearchMatchField, M as CdnServeOptions, N as CdnTransform, Nt as Folder, O as AssetVisibility, Ot as EventFactValues, P as ConnectionOptions, Pt as Order, Q as ListEventsOptions, R as DeleteAssetContentOptions, Rt as AssetSearchQuery, S as AssetProcessing, T as AssetSearchResponse, Tt as TypedEvent, U as IdempotencyOptions, Ut as ImageData, V as EnsureLensesOptions, Vt as AssetSafetyHoldReason, W as ImageTransform, Wt as MetadataItem, X as ListAssetChildrenOptions, Y as LensTransform, Z as ListAssetsOptions, _ as AssetContentStatus, _t as VerifyWebhookSignatureOptions, a as ClassificationLabel, at as RetrieveAssetOptions, b as AssetModerationStatus, bt as WebhookPayloadInput, c as ClassificationReport, ct as SignUploadTokenOptions, d as Asset, dt as SubmitAssetOptions, et as MoveAssetOptions, f as AssetChecksums, ft as UpdateAssetOptions, g as AssetContentRemovalReason, gt as UploadedAsset, h as AssetContentOptions, ht as UploadPresetSubmitAssetOptions, i as ClassificationCategoryReport, it as RequestOptions, j as CdnAssetUrlOptions, jt as EventType, k as CalmLensAppClientOptions, kt as EventFacts, l as Likelihood, lt as SignedUploadToken, m as AssetContent, mt as UploadAssetPartOptions, n as ClassificationCategories, nt as MultipartUploadOptions, o as ClassificationNotEvaluatedReason, ot as RetryAssetOptions, p as AssetChildrenPage, pt as UpdateFolderOptions, q as IterateAssetsOptions, r as ClassificationCategory, rt as MultipartUploadPartOptions, s as ClassificationQualifierResults, st as SearchAssetsOptions, t as WebhookEventPayload, tt as MoveFolderOptions, u as ModerationQualifier, ut as SignedUrl, v as AssetModeration, vt as WaitForAssetDecisionOptions, w as AssetReviewerAction, wt as EventAsset, x as AssetPage, xt as GetEventsResponse, y as AssetModerationAction, yt as WebhookHeadersInput, z as DeleteAssetOptions } from "./WebhookPayload-vy8HNMaK.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-Dz340UQ9.js";
3
+ export { type AgeRange, type ApiErrorCode, type Asset, type AssetChecksums, type AssetChildrenPage, type AssetContent, type AssetContentOptions, type AssetContentRemovalReason, type AssetContentStatus, type AssetModeration, type AssetModerationAction, type AssetModerationStatus, type AssetPage, type AssetProcessing, type AssetProcessingStatus, type AssetReviewerAction, type AssetSafetyHold, type AssetSafetyHoldReason, type AssetSearchMatchField, type AssetSearchQuery, type AssetSearchResponse, type AssetSearchResult, 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 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-Bs0DreBV.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 ModerateTextOptions, A as CalmLensServerClientOptions, At as EventSeverity, B as EnsureLensOptions, Bt as AssetSafetyHold, C as AssetProcessingStatus, D as AssetType, Dt as EventFact, E as AssetSearchResult, Et as EventCategory, F as CreateAssetSignedUrlOptions, Ft as Page, G as ImageTransformOptions, Gt as PreviewImage, H as FolderIdOptions, Ht as ExtractedText, I as CreateFolderOptions, It as LensType, J as Lens, K as IterateAssetChildrenOptions, Kt as ProcessingOptions, L as CreateMultipartUploadPartOptions, Lt as AssetSearchMatchField, M as CdnServeOptions, N as CdnTransform, Nt as Folder, O as AssetVisibility, Ot as EventFactValues, P as ConnectionOptions, Pt as Order, Q as ListEventsOptions, R as DeleteAssetContentOptions, Rt as AssetSearchQuery, S as AssetProcessing, St as PostAssetSignedUrlResponse, T as AssetSearchResponse, Tt as TypedEvent, U as IdempotencyOptions, Ut as ImageData, V as EnsureLensesOptions, Vt as AssetSafetyHoldReason, W as ImageTransform, Wt as MetadataItem, X as ListAssetChildrenOptions, Y as LensTransform, Z as ListAssetsOptions, _ as AssetContentStatus, _t as VerifyWebhookSignatureOptions, a as ClassificationLabel, at as RetrieveAssetOptions, b as AssetModerationStatus, bt as WebhookPayloadInput, c as ClassificationReport, ct as SignUploadTokenOptions, d as Asset, dt as SubmitAssetOptions, et as MoveAssetOptions, f as AssetChecksums, ft as UpdateAssetOptions, g as AssetContentRemovalReason, gt as UploadedAsset, h as AssetContentOptions, ht as UploadPresetSubmitAssetOptions, i as ClassificationCategoryReport, it as RequestOptions, j as CdnAssetUrlOptions, jt as EventType, k as CalmLensAppClientOptions, kt as EventFacts, l as Likelihood, lt as SignedUploadToken, m as AssetContent, mt as UploadAssetPartOptions, n as ClassificationCategories, nt as MultipartUploadOptions, o as ClassificationNotEvaluatedReason, ot as RetryAssetOptions, p as AssetChildrenPage, pt as UpdateFolderOptions, q as IterateAssetsOptions, r as ClassificationCategory, rt as MultipartUploadPartOptions, s as ClassificationQualifierResults, st as SearchAssetsOptions, t as WebhookEventPayload, tt as MoveFolderOptions, u as ModerationQualifier, ut as SignedUrl, v as AssetModeration, vt as WaitForAssetDecisionOptions, w as AssetReviewerAction, wt as EventAsset, x as AssetPage, xt as GetEventsResponse, y as AssetModerationAction, yt as WebhookHeadersInput, z as DeleteAssetOptions } from "./WebhookPayload-vy8HNMaK.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-Dz340UQ9.js";
3
3
  //#region src/client/CalmLensServerClient.d.ts
4
4
  interface LensCache {
5
5
  readonly ensuredLenses: Map<string, Lens>;
@@ -88,8 +88,8 @@ declare class CalmLensServerClient {
88
88
  /** Yields every child of an asset, fetching pages as needed. */
89
89
  iterateChildren: (options: IterateAssetChildrenOptions) => AsyncGenerator<Asset, void, undefined>;
90
90
  /**
91
- * Uploads an asset and queues it for moderation, returning immediately with status
92
- * `pending` (or `uploading` for the first multipart part). Retried safely with an
91
+ * Uploads an asset and queues it for moderation, returning immediately with processing
92
+ * status `processing` (or `uploading` for the first multipart part). Retried safely with an
93
93
  * `Idempotency-Key`.
94
94
  */
95
95
  create: (options: SubmitAssetOptions) => Promise<Asset>;
@@ -111,10 +111,17 @@ declare class CalmLensServerClient {
111
111
  /** Moves an asset into a folder, or to the project root with `folderId: null`. */
112
112
  move: ({ assetId, folderId }: MoveAssetOptions) => Promise<Asset>;
113
113
  /**
114
- * Processes an asset that failed (status `error`) again. It returns to `pending` and is
114
+ * Processes an asset that failed (processing status `failed`) again. It returns to
115
+ * `processing` and is
115
116
  * moderated like a new upload; its content must still be stored.
116
117
  */
117
118
  retry: ({ assetId }: RetryAssetOptions) => Promise<Asset>;
119
+ /**
120
+ * Waits until an asset's `moderation.status` is `approved` or `rejected`, or its
121
+ * `processing.status` is `failed`, and returns that asset, checking every few seconds. Rejects with `sdk/timeout` if there is no
122
+ * decision within `timeoutMs` (default 60000). Webhooks report decisions without polling.
123
+ */
124
+ waitForDecision: ({ assetId, ...options }: WaitForAssetDecisionOptions) => Promise<Asset>;
118
125
  /**
119
126
  * Removes an asset's stored content (source, preview and retained extracted text) while
120
127
  * keeping the asset record, metadata and moderation report. The returned asset has
@@ -169,11 +176,13 @@ declare class CalmLensServerClient {
169
176
  */
170
177
  ensureLens(options: EnsureLensOptions): Promise<Lens>;
171
178
  /**
172
- * Create or update several named lenses in one API request.
179
+ * Create or update several named lenses. New definitions are sent in one API request, or in
180
+ * consecutive requests of at most {@link ENSURE_LENSES_MAX_PER_REQUEST} definitions, in order.
173
181
  * Each lens follows the same versioning and idempotency rules as ensureLens().
174
182
  */
175
183
  ensureLenses({ lenses }: EnsureLensesOptions): Promise<Lens[]>;
176
184
  private submitEnsureLenses;
185
+ private submitEnsureLensesChunk;
177
186
  }
178
187
  //#endregion
179
188
  //#region src/client/CalmLensWebhooks.d.ts
@@ -199,4 +208,4 @@ export declare function verifyWebhookSignature(options: VerifyWebhookSignatureOp
199
208
  */
200
209
  export declare function parseWebhookEvent(options: VerifyWebhookSignatureOptions): Promise<WebhookEventPayload>;
201
210
  //#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 };
211
+ export { type AgeRange, type ApiErrorCode, type Asset, type AssetChecksums, type AssetChildrenPage, type AssetContent, type AssetContentOptions, type AssetContentRemovalReason, type AssetContentStatus, type AssetModeration, type AssetModerationAction, type AssetModerationStatus, type AssetPage, type AssetProcessing, type AssetProcessingStatus, type AssetReviewerAction, type AssetSafetyHold, type AssetSafetyHoldReason, type AssetSearchMatchField, type AssetSearchQuery, type AssetSearchResponse, type AssetSearchResult, 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 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-Bs0DreBV.js");
3
+ require("./index.js");
4
+ const require_CalmLensWebhooks = require("./CalmLensWebhooks-6thkvr_F.js");
5
+ const require_CalmLensUtils = require("./CalmLensUtils-DNdmYeX6.js");
6
+ const require_CalmLensConnection = require("./CalmLensConnection-Bth5fJyp.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 = {
@@ -199,8 +198,8 @@ sign: async (options) => {
199
198
  }));
200
199
  },
201
200
  /**
202
- * Uploads an asset and queues it for moderation, returning immediately with status
203
- * `pending` (or `uploading` for the first multipart part). Retried safely with an
201
+ * Uploads an asset and queues it for moderation, returning immediately with processing
202
+ * status `processing` (or `uploading` for the first multipart part). Retried safely with an
204
203
  * `Idempotency-Key`.
205
204
  */
206
205
  create: async (options) => this.submitAsset(options, true),
@@ -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,
@@ -237,11 +236,22 @@ sign: async (options) => {
237
236
  /** Moves an asset into a folder, or to the project root with `folderId: null`. */
238
237
  move: async ({ assetId, folderId }) => this.request("POST", `/assets/${requireId(assetId, "Asset ID")}/move`, { body: { folderId } }),
239
238
  /**
240
- * Processes an asset that failed (status `error`) again. It returns to `pending` and is
239
+ * Processes an asset that failed (processing status `failed`) again. It returns to
240
+ * `processing` and is
241
241
  * moderated like a new upload; its content must still be stored.
242
242
  */
243
243
  retry: async ({ assetId }) => this.request("POST", `/assets/${requireId(assetId, "Asset ID")}/retry`),
244
244
  /**
245
+ * Waits until an asset's `moderation.status` is `approved` or `rejected`, or its
246
+ * `processing.status` is `failed`, and returns that asset, checking every few seconds. Rejects with `sdk/timeout` if there is no
247
+ * decision within `timeoutMs` (default 60000). Webhooks report decisions without polling.
248
+ */
249
+ waitForDecision: async ({ assetId, ...options }) => {
250
+ requireId(assetId, "Asset ID");
251
+ const client = options.signal ? this.withRequestOptions({ signal: options.signal }) : this;
252
+ return require_CalmLensUtils.pollForDecision(() => client.assets.retrieve({ assetId }), options, require_CalmLensUtils.sleep);
253
+ },
254
+ /**
245
255
  * Removes an asset's stored content (source, preview and retained extracted text) while
246
256
  * keeping the asset record, metadata and moderation report. The returned asset has
247
257
  * `storageDeletedAt` set; the CDN no longer serves it.
@@ -308,17 +318,18 @@ sign: async (options) => {
308
318
  * Supplying the same definition and version is idempotent.
309
319
  */
310
320
  async ensureLens(options) {
311
- if (!options?.identifier) throw require_CalmLensError.invalidArgument("Lens identifier is required");
321
+ if (!options?.identifier) throw require_CalmLensVersion.invalidArgument("Lens identifier is required");
312
322
  const [lens] = await this.ensureLenses({ lenses: [options] });
313
323
  return lens;
314
324
  }
315
325
  /**
316
- * Create or update several named lenses in one API request.
326
+ * Create or update several named lenses. New definitions are sent in one API request, or in
327
+ * consecutive requests of at most {@link ENSURE_LENSES_MAX_PER_REQUEST} definitions, in order.
317
328
  * Each lens follows the same versioning and idempotency rules as ensureLens().
318
329
  */
319
330
  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");
331
+ if (!Array.isArray(lenses) || lenses.length === 0) throw require_CalmLensVersion.invalidArgument("At least one lens is required");
332
+ if (lenses.some((option) => !option?.identifier)) throw require_CalmLensVersion.invalidArgument("Lens identifier is required");
322
333
  const { ensuredLenses, pendingEnsureLenses } = this.#lenses;
323
334
  const missingOptions = [];
324
335
  const missingKeys = /* @__PURE__ */ new Set();
@@ -341,28 +352,31 @@ sign: async (options) => {
341
352
  }
342
353
  return lenses.map((option) => {
343
354
  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}"` });
355
+ if (!lens) throw new require_CalmLensVersion.CalmLensError(require_CalmLensVersion.SDK_ERROR_CODES.INVALID_RESPONSE, { message: `CalmLens did not return lens "${option.identifier}"` });
345
356
  return lens;
346
357
  });
347
358
  }
348
359
  async submitEnsureLenses(options) {
360
+ for (let start = 0; start < options.length; start += 100) await this.submitEnsureLensesChunk(options.slice(start, start + 100));
361
+ }
362
+ async submitEnsureLensesChunk(options) {
349
363
  const result = await this.request("PUT", `${this.projectPath}/lenses`, { body: { lenses: options } });
350
364
  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}` });
365
+ 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
366
  const { ensuredLenses } = this.#lenses;
353
367
  for (const [index, lens] of returned.entries()) {
354
368
  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}` });
369
+ 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
370
  for (const [cacheKey, cachedLens] of ensuredLenses) if (cachedLens.identifier === optionsForLens.identifier) ensuredLenses.delete(cacheKey);
357
371
  ensuredLenses.set(getEnsureLensCacheKey(optionsForLens), lens);
358
372
  }
359
373
  }
360
374
  };
361
375
  //#endregion
362
- exports.CALMLENS_ERROR_CODES = require_CalmLensError.CALMLENS_ERROR_CODES;
363
- exports.CalmLensError = require_CalmLensError.CalmLensError;
376
+ exports.CALMLENS_ERROR_CODES = require_CalmLensVersion.CALMLENS_ERROR_CODES;
377
+ exports.CalmLensError = require_CalmLensVersion.CalmLensError;
364
378
  exports.CalmLensServerClient = CalmLensServerClient;
365
- exports.SDK_VERSION = require_src.SDK_VERSION;
379
+ exports.SDK_VERSION = require_CalmLensVersion.SDK_VERSION;
366
380
  exports.WEBHOOK_DELIVERY_HEADER = require_CalmLensWebhooks.WEBHOOK_DELIVERY_HEADER;
367
381
  exports.WEBHOOK_SIGNATURE_HEADER = require_CalmLensWebhooks.WEBHOOK_SIGNATURE_HEADER;
368
382
  exports.WEBHOOK_SIGNATURE_TOLERANCE_SECONDS = require_CalmLensWebhooks.WEBHOOK_SIGNATURE_TOLERANCE_SECONDS;
package/cjs/testing.d.ts CHANGED
@@ -1,5 +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";
2
- import * as zod from "zod";
1
+ import { $ as ModerateTextOptions, A as CalmLensServerClientOptions, B as EnsureLensOptions, Ct as Event, F as CreateAssetSignedUrlOptions, H as FolderIdOptions, I as CreateFolderOptions, J as Lens, K as IterateAssetChildrenOptions, M as CdnServeOptions, Mt as PermissionGrant, Nt as Folder, Q as ListEventsOptions, R as DeleteAssetContentOptions, St as PostAssetSignedUrlResponse, T as AssetSearchResponse, Tt as TypedEvent, V as EnsureLensesOptions, X as ListAssetChildrenOptions, Z as ListAssetsOptions, at as RetrieveAssetOptions, ct as SignUploadTokenOptions, d as Asset, dt as SubmitAssetOptions, et as MoveAssetOptions, ft as UpdateAssetOptions, j as CdnAssetUrlOptions, lt as SignedUploadToken, mt as UploadAssetPartOptions, ot as RetryAssetOptions, p as AssetChildrenPage, pt as UpdateFolderOptions, q as IterateAssetsOptions, r as ClassificationCategory, st as SearchAssetsOptions, t as WebhookEventPayload, tt as MoveFolderOptions, vt as WaitForAssetDecisionOptions, x as AssetPage, xt as GetEventsResponse, z as DeleteAssetOptions, zt as AssetBinaryPayloadInput } from "./WebhookPayload-vy8HNMaK.js";
3
2
  //#region ../shared/src/TestTriggers.d.ts
4
3
  type ClassificationTestSignal = ClassificationCategory | "sexual.involving-minors" | "violence.graphic";
5
4
  //#endregion
@@ -8,40 +7,6 @@ export declare const MEDIA_TEST_SIGNALS: readonly ["sexual", "violence", "self-h
8
7
  /** Read this aloud, or render it as large, high-contrast text in a video frame. */
9
8
  export declare function generateMediaTestCode(signal: ClassificationTestSignal, projectId: string): string;
10
9
  //#endregion
11
- //#region ../shared/src/Permissions.d.ts
12
- declare const GRANT_SCHEMA: zod.ZodObject<{
13
- actions: zod.ZodArray<zod.ZodEnum<{
14
- "api-keys:read": "api-keys:read";
15
- "api-keys:write": "api-keys:write";
16
- "assets:create": "assets:create";
17
- "assets:delete": "assets:delete";
18
- "assets:download": "assets:download";
19
- "assets:read": "assets:read";
20
- "assets:share": "assets:share";
21
- "assets:update": "assets:update";
22
- "connectors:read": "connectors:read";
23
- "connectors:write": "connectors:write";
24
- "folders:create": "folders:create";
25
- "folders:delete": "folders:delete";
26
- "folders:read": "folders:read";
27
- "folders:update": "folders:update";
28
- "lenses:read": "lenses:read";
29
- "lenses:write": "lenses:write";
30
- "members:read": "members:read";
31
- "members:write": "members:write";
32
- "metadata:read": "metadata:read";
33
- "metadata:write": "metadata:write";
34
- "project:manage": "project:manage";
35
- "settings:read": "settings:read";
36
- "settings:write": "settings:write";
37
- "upload-presets:read": "upload-presets:read";
38
- "upload-presets:write": "upload-presets:write";
39
- }>>;
40
- folderId: zod.ZodNullable<zod.ZodString>;
41
- includeSubfolders: zod.ZodBoolean;
42
- }, zod.core.$strict>;
43
- type PermissionGrant = zod.infer<typeof GRANT_SCHEMA>;
44
- //#endregion
45
10
  //#region src/testing/MockApiKey.d.ts
46
11
  export declare const MOCK_API_KEY_PREFIX = "sk_test_";
47
12
  export declare const createMockApiKey: (grants?: PermissionGrant[]) => string;
@@ -111,13 +76,18 @@ interface MockCalmLensServerClientOptions extends CalmLensServerClientOptions {
111
76
  imageStorage?: MockImageStorage;
112
77
  createId?: () => string;
113
78
  now?: () => number;
114
- /** Status `assets.create` returns. Defaults to `pending`. */
115
- queuedStatus?: AssetStatus;
116
- /** Status `assets.moderate` and `text.moderate` return. Defaults to `approved`. */
117
- analyzedStatus?: AssetStatus;
79
+ /** Outcome of `assets.create` (and queued multipart uploads). Defaults to `pending`. */
80
+ queuedOutcome?: MockAssetOutcome;
81
+ /** Outcome of `assets.moderate` and `text.moderate`. Defaults to `approved`. */
82
+ analyzedOutcome?: MockAssetOutcome;
118
83
  signedUrlBaseUrl?: string;
119
84
  };
120
85
  }
86
+ /**
87
+ * Where a mock upload ends up: `pending` (still processing), `approved` or `rejected` (processing
88
+ * done with that decision), or `failed` (processing failed, retryable).
89
+ */
90
+ type MockAssetOutcome = "pending" | "approved" | "rejected" | "failed";
121
91
  /** The options each `MockCalmLensServerClient` method was given, by operation name. */
122
92
  interface MockCalmLensOperationOptions {
123
93
  "assets.list": ListAssetsOptions;
@@ -131,6 +101,7 @@ interface MockCalmLensOperationOptions {
131
101
  "assets.createSignedUrl": CreateAssetSignedUrlOptions;
132
102
  "assets.move": MoveAssetOptions;
133
103
  "assets.retry": RetryAssetOptions;
104
+ "assets.waitForDecision": WaitForAssetDecisionOptions;
134
105
  "assets.deleteContent": DeleteAssetContentOptions;
135
106
  "assets.delete": DeleteAssetOptions;
136
107
  "text.moderate": ModerateTextOptions;
@@ -176,8 +147,8 @@ export declare class MockCalmLensServerClient {
176
147
  readonly imageStorage: MockImageStorage;
177
148
  private readonly createId;
178
149
  private readonly now;
179
- private readonly queuedStatus;
180
- private readonly analyzedStatus;
150
+ private readonly queuedOutcome;
151
+ private readonly analyzedOutcome;
181
152
  private readonly apiKeyGrants;
182
153
  private readonly signedUrlBaseUrl;
183
154
  private readonly cdnBaseUrl;
@@ -260,6 +231,8 @@ export declare class MockCalmLensServerClient {
260
231
  createSignedUrl: (signedUrlOptions: CreateAssetSignedUrlOptions) => Promise<PostAssetSignedUrlResponse>;
261
232
  move: (options: MoveAssetOptions) => Promise<Asset>;
262
233
  retry: (options: RetryAssetOptions) => Promise<Asset>;
234
+ /** Waits like the real client, checking the mock's storage for a decision. */
235
+ waitForDecision: (options: WaitForAssetDecisionOptions) => Promise<Asset>;
263
236
  deleteContent: (options: DeleteAssetContentOptions) => Promise<Asset>;
264
237
  delete: (options: DeleteAssetOptions) => Promise<void>;
265
238
  };
@@ -282,9 +255,15 @@ export declare class MockCalmLensServerClient {
282
255
  private withIdempotency;
283
256
  private moderateAsset;
284
257
  private createAsset;
258
+ /**
259
+ * Moves an asset to `outcome` like the pipeline would: a decision finishes processing, and
260
+ * finished processing removes content kept only temporarily (`keepContentAfterProcessing` off).
261
+ */
262
+ private applyOutcome;
285
263
  private resolveFolder;
286
264
  private findOwnFolder;
287
265
  private assertUniqueFolderName;
266
+ private getContentFormat;
288
267
  private getSizeInBytes;
289
268
  }
290
269
  //#endregion