@calmlens/sdk 0.13.0 → 0.15.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.
- package/README.md +44 -40
- package/cjs/{CalmLensConnection-DzRDCMOP.js → CalmLensConnection-DoemramF.js} +4 -3
- package/cjs/{CalmLensUtils-vX5H_vMn.js → CalmLensUtils-Cv1Ylp9-.js} +10 -10
- package/cjs/{CalmLensVersion-DjhsJ1gj.js → CalmLensVersion-CuxKdijk.js} +67 -2
- package/cjs/{CalmLensWebhooks-hVquX5L1.js → CalmLensWebhooks-qrL-Zdu3.js} +2 -2
- package/cjs/{WebhookPayload-B7CgSmI5.d.ts → WebhookPayload-vy8HNMaK.d.ts} +4355 -449
- package/cjs/app.d.ts +3 -3
- package/cjs/app.js +3 -3
- package/cjs/{index-BywTQbRq.d.ts → index-Dz340UQ9.d.ts} +27 -1
- package/cjs/index.d.ts +3 -3
- package/cjs/index.js +1 -1
- package/cjs/server.d.ts +9 -8
- package/cjs/server.js +10 -9
- package/cjs/testing.d.ts +19 -45
- package/cjs/testing.js +99 -30
- package/esm/{CalmLensConnection-D8VsTdsA.js → CalmLensConnection-CQLoUoBd.js} +4 -3
- package/esm/{CalmLensUtils-B4i3Z2He.js → CalmLensUtils-B3S--hBG.js} +10 -10
- package/esm/{CalmLensVersion-DK4BMEST.js → CalmLensVersion-N71PMJAz.js} +67 -2
- package/esm/{CalmLensWebhooks-DyCoEvpf.js → CalmLensWebhooks-BxMSx1Vm.js} +2 -2
- package/esm/{WebhookPayload-B7CgSmI5.d.ts → WebhookPayload-vy8HNMaK.d.ts} +4355 -449
- package/esm/app.d.ts +3 -3
- package/esm/app.js +3 -3
- package/esm/{index-BywTQbRq.d.ts → index-Dz340UQ9.d.ts} +27 -1
- package/esm/index.d.ts +3 -3
- package/esm/index.js +1 -1
- package/esm/server.d.ts +9 -8
- package/esm/server.js +10 -9
- package/esm/testing.d.ts +19 -45
- package/esm/testing.js +99 -30
- package/package.json +1 -1
package/cjs/app.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { $ as
|
|
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-
|
|
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
|
|
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_CalmLensVersion = require("./CalmLensVersion-
|
|
2
|
+
const require_CalmLensVersion = require("./CalmLensVersion-CuxKdijk.js");
|
|
3
3
|
require("./index.js");
|
|
4
|
-
const require_CalmLensUtils = require("./CalmLensUtils-
|
|
5
|
-
const require_CalmLensConnection = require("./CalmLensConnection-
|
|
4
|
+
const require_CalmLensUtils = require("./CalmLensUtils-Cv1Ylp9-.js");
|
|
5
|
+
const require_CalmLensConnection = require("./CalmLensConnection-DoemramF.js");
|
|
6
6
|
//#region src/client/CalmLensAppClient.ts
|
|
7
7
|
const inspectSymbol = Symbol.for("nodejs.util.inspect.custom");
|
|
8
8
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./WebhookPayload-
|
|
1
|
+
import "./WebhookPayload-vy8HNMaK.js";
|
|
2
2
|
import * as zod from "zod";
|
|
3
3
|
//#region ../shared/src/ProcessingFeatures.d.ts
|
|
4
4
|
/**
|
|
@@ -180,6 +180,8 @@ declare const API_ERROR_CODES: {
|
|
|
180
180
|
readonly UPLOAD_PRESET_NOT_FOUND: "upload-preset/not-found";
|
|
181
181
|
readonly UPLOAD_PRESET_DISABLED: "upload-preset/disabled";
|
|
182
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";
|
|
183
185
|
readonly UPLOAD_PRESET_CONTENT_TYPE_NOT_ALLOWED: "upload-preset/content-type-not-allowed";
|
|
184
186
|
readonly UPLOAD_PRESET_TOO_LARGE: "upload-preset/too-large";
|
|
185
187
|
readonly UPLOAD_PRESET_DAILY_LIMIT_REACHED: "upload-preset/daily-limit-reached";
|
|
@@ -188,6 +190,17 @@ declare const API_ERROR_CODES: {
|
|
|
188
190
|
readonly UPLOAD_TOKEN_INVALID: "upload-token/invalid";
|
|
189
191
|
readonly UPLOAD_TOKEN_EXPIRED: "upload-token/expired";
|
|
190
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";
|
|
191
204
|
};
|
|
192
205
|
type ApiErrorCode = (typeof API_ERROR_CODES)[keyof typeof API_ERROR_CODES];
|
|
193
206
|
//#endregion
|
|
@@ -259,6 +272,8 @@ declare const CALMLENS_ERROR_CODES: {
|
|
|
259
272
|
readonly UPLOAD_PRESET_NOT_FOUND: "upload-preset/not-found";
|
|
260
273
|
readonly UPLOAD_PRESET_DISABLED: "upload-preset/disabled";
|
|
261
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";
|
|
262
277
|
readonly UPLOAD_PRESET_CONTENT_TYPE_NOT_ALLOWED: "upload-preset/content-type-not-allowed";
|
|
263
278
|
readonly UPLOAD_PRESET_TOO_LARGE: "upload-preset/too-large";
|
|
264
279
|
readonly UPLOAD_PRESET_DAILY_LIMIT_REACHED: "upload-preset/daily-limit-reached";
|
|
@@ -267,6 +282,17 @@ declare const CALMLENS_ERROR_CODES: {
|
|
|
267
282
|
readonly UPLOAD_TOKEN_INVALID: "upload-token/invalid";
|
|
268
283
|
readonly UPLOAD_TOKEN_EXPIRED: "upload-token/expired";
|
|
269
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";
|
|
270
296
|
/** The request could not be completed: DNS, TLS, a refused or reset connection, a truncated body. */
|
|
271
297
|
readonly TRANSPORT_ERROR: "sdk/transport-error";
|
|
272
298
|
/** The request did not finish within `timeoutMs`. */
|
package/cjs/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { $ as
|
|
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-
|
|
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
|
|
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,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_CalmLensVersion = require("./CalmLensVersion-
|
|
2
|
+
const require_CalmLensVersion = require("./CalmLensVersion-CuxKdijk.js");
|
|
3
3
|
exports.CALMLENS_ERROR_CODES = require_CalmLensVersion.CALMLENS_ERROR_CODES;
|
|
4
4
|
exports.CalmLensError = require_CalmLensVersion.CalmLensError;
|
|
5
5
|
exports.SDK_VERSION = require_CalmLensVersion.SDK_VERSION;
|
package/cjs/server.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { $ as
|
|
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-
|
|
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
|
|
92
|
-
* `
|
|
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,13 +111,14 @@ 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 `
|
|
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>;
|
|
118
119
|
/**
|
|
119
|
-
* Waits
|
|
120
|
-
*
|
|
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
|
|
121
122
|
* decision within `timeoutMs` (default 60000). Webhooks report decisions without polling.
|
|
122
123
|
*/
|
|
123
124
|
waitForDecision: ({ assetId, ...options }: WaitForAssetDecisionOptions) => Promise<Asset>;
|
|
@@ -207,4 +208,4 @@ export declare function verifyWebhookSignature(options: VerifyWebhookSignatureOp
|
|
|
207
208
|
*/
|
|
208
209
|
export declare function parseWebhookEvent(options: VerifyWebhookSignatureOptions): Promise<WebhookEventPayload>;
|
|
209
210
|
//#endregion
|
|
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
|
|
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,9 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_CalmLensVersion = require("./CalmLensVersion-
|
|
2
|
+
const require_CalmLensVersion = require("./CalmLensVersion-CuxKdijk.js");
|
|
3
3
|
require("./index.js");
|
|
4
|
-
const require_CalmLensWebhooks = require("./CalmLensWebhooks-
|
|
5
|
-
const require_CalmLensUtils = require("./CalmLensUtils-
|
|
6
|
-
const require_CalmLensConnection = require("./CalmLensConnection-
|
|
4
|
+
const require_CalmLensWebhooks = require("./CalmLensWebhooks-qrL-Zdu3.js");
|
|
5
|
+
const require_CalmLensUtils = require("./CalmLensUtils-Cv1Ylp9-.js");
|
|
6
|
+
const require_CalmLensConnection = require("./CalmLensConnection-DoemramF.js");
|
|
7
7
|
const getEnsureLensCacheKey = (options) => require_CalmLensWebhooks.stringifyJsonCanonical({
|
|
8
8
|
identifier: options.identifier,
|
|
9
9
|
name: options.name,
|
|
@@ -198,8 +198,8 @@ sign: async (options) => {
|
|
|
198
198
|
}));
|
|
199
199
|
},
|
|
200
200
|
/**
|
|
201
|
-
* Uploads an asset and queues it for moderation, returning immediately with
|
|
202
|
-
* `
|
|
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
|
|
203
203
|
* `Idempotency-Key`.
|
|
204
204
|
*/
|
|
205
205
|
create: async (options) => this.submitAsset(options, true),
|
|
@@ -236,13 +236,14 @@ sign: async (options) => {
|
|
|
236
236
|
/** Moves an asset into a folder, or to the project root with `folderId: null`. */
|
|
237
237
|
move: async ({ assetId, folderId }) => this.request("POST", `/assets/${requireId(assetId, "Asset ID")}/move`, { body: { folderId } }),
|
|
238
238
|
/**
|
|
239
|
-
* Processes an asset that failed (status `
|
|
239
|
+
* Processes an asset that failed (processing status `failed`) again. It returns to
|
|
240
|
+
* `processing` and is
|
|
240
241
|
* moderated like a new upload; its content must still be stored.
|
|
241
242
|
*/
|
|
242
243
|
retry: async ({ assetId }) => this.request("POST", `/assets/${requireId(assetId, "Asset ID")}/retry`),
|
|
243
244
|
/**
|
|
244
|
-
* Waits
|
|
245
|
-
*
|
|
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
|
|
246
247
|
* decision within `timeoutMs` (default 60000). Webhooks report decisions without polling.
|
|
247
248
|
*/
|
|
248
249
|
waitForDecision: async ({ assetId, ...options }) => {
|
package/cjs/testing.d.ts
CHANGED
|
@@ -1,48 +1,11 @@
|
|
|
1
|
-
import { $ as
|
|
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
|
|
6
5
|
//#region ../shared/src/MediaTestTriggers.d.ts
|
|
7
6
|
export declare const MEDIA_TEST_SIGNALS: readonly ["sexual", "violence", "self-harm", "harassment", "hate", "criminal-activity", "violence.graphic"];
|
|
8
7
|
/** Read this aloud, or render it as large, high-contrast text in a video frame. */
|
|
9
|
-
export declare function generateMediaTestCode(signal: ClassificationTestSignal,
|
|
10
|
-
//#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
|
-
"reviews:read": "reviews:read";
|
|
36
|
-
"reviews:write": "reviews:write";
|
|
37
|
-
"settings:read": "settings:read";
|
|
38
|
-
"settings:write": "settings:write";
|
|
39
|
-
"upload-presets:read": "upload-presets:read";
|
|
40
|
-
"upload-presets:write": "upload-presets:write";
|
|
41
|
-
}>>;
|
|
42
|
-
folderId: zod.ZodNullable<zod.ZodString>;
|
|
43
|
-
includeSubfolders: zod.ZodBoolean;
|
|
44
|
-
}, zod.core.$strict>;
|
|
45
|
-
type PermissionGrant = zod.infer<typeof GRANT_SCHEMA>;
|
|
8
|
+
export declare function generateMediaTestCode(signal: ClassificationTestSignal, testInputKey: string): string;
|
|
46
9
|
//#endregion
|
|
47
10
|
//#region src/testing/MockApiKey.d.ts
|
|
48
11
|
export declare const MOCK_API_KEY_PREFIX = "sk_test_";
|
|
@@ -113,13 +76,18 @@ interface MockCalmLensServerClientOptions extends CalmLensServerClientOptions {
|
|
|
113
76
|
imageStorage?: MockImageStorage;
|
|
114
77
|
createId?: () => string;
|
|
115
78
|
now?: () => number;
|
|
116
|
-
/**
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
|
|
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;
|
|
120
83
|
signedUrlBaseUrl?: string;
|
|
121
84
|
};
|
|
122
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";
|
|
123
91
|
/** The options each `MockCalmLensServerClient` method was given, by operation name. */
|
|
124
92
|
interface MockCalmLensOperationOptions {
|
|
125
93
|
"assets.list": ListAssetsOptions;
|
|
@@ -179,8 +147,8 @@ export declare class MockCalmLensServerClient {
|
|
|
179
147
|
readonly imageStorage: MockImageStorage;
|
|
180
148
|
private readonly createId;
|
|
181
149
|
private readonly now;
|
|
182
|
-
private readonly
|
|
183
|
-
private readonly
|
|
150
|
+
private readonly queuedOutcome;
|
|
151
|
+
private readonly analyzedOutcome;
|
|
184
152
|
private readonly apiKeyGrants;
|
|
185
153
|
private readonly signedUrlBaseUrl;
|
|
186
154
|
private readonly cdnBaseUrl;
|
|
@@ -287,9 +255,15 @@ export declare class MockCalmLensServerClient {
|
|
|
287
255
|
private withIdempotency;
|
|
288
256
|
private moderateAsset;
|
|
289
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;
|
|
290
263
|
private resolveFolder;
|
|
291
264
|
private findOwnFolder;
|
|
292
265
|
private assertUniqueFolderName;
|
|
266
|
+
private getContentFormat;
|
|
293
267
|
private getSizeInBytes;
|
|
294
268
|
}
|
|
295
269
|
//#endregion
|
package/cjs/testing.js
CHANGED
|
@@ -21,9 +21,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
21
21
|
enumerable: true
|
|
22
22
|
}) : target, mod));
|
|
23
23
|
//#endregion
|
|
24
|
-
const require_CalmLensVersion = require("./CalmLensVersion-
|
|
25
|
-
const require_CalmLensWebhooks = require("./CalmLensWebhooks-
|
|
26
|
-
const require_CalmLensUtils = require("./CalmLensUtils-
|
|
24
|
+
const require_CalmLensVersion = require("./CalmLensVersion-CuxKdijk.js");
|
|
25
|
+
const require_CalmLensWebhooks = require("./CalmLensWebhooks-qrL-Zdu3.js");
|
|
26
|
+
const require_CalmLensUtils = require("./CalmLensUtils-Cv1Ylp9-.js");
|
|
27
27
|
let zod = require("zod");
|
|
28
28
|
zod = __toESM(zod);
|
|
29
29
|
require("zod/v4");
|
|
@@ -335,7 +335,6 @@ const CLASSIFICATION_LABEL_SCHEMA = zod.object({
|
|
|
335
335
|
zod.object({
|
|
336
336
|
processedAt: zod.number(),
|
|
337
337
|
categories: CATEGORIES_SCHEMA,
|
|
338
|
-
flagged: zod.boolean(),
|
|
339
338
|
score: zod.number(),
|
|
340
339
|
notes: saneStringField().nullish(),
|
|
341
340
|
media: zod.object({
|
|
@@ -380,10 +379,10 @@ const HEX_WORDS = [
|
|
|
380
379
|
"foxtrot"
|
|
381
380
|
];
|
|
382
381
|
/** Read this aloud, or render it as large, high-contrast text in a video frame. */
|
|
383
|
-
function generateMediaTestCode(signal,
|
|
382
|
+
function generateMediaTestCode(signal, testInputKey) {
|
|
384
383
|
if (!MEDIA_TEST_SIGNALS.includes(signal)) throw new Error("Unsupported media test signal");
|
|
385
|
-
const suffix =
|
|
386
|
-
if (!/^[a-f0-9]{8}$/.test(suffix)) throw new Error("Expected
|
|
384
|
+
const suffix = testInputKey.toLowerCase();
|
|
385
|
+
if (!/^[a-f0-9]{8}$/.test(suffix)) throw new Error("Expected an eight-character hexadecimal test input key");
|
|
387
386
|
return `Calm Lens test ${[...suffix].map((character) => HEX_WORDS[Number.parseInt(character, 16)]).join(" ")} ${signal.replace(/[.-]/g, " ")} end test`;
|
|
388
387
|
}
|
|
389
388
|
//#endregion
|
|
@@ -732,8 +731,8 @@ var MockCalmLensServerClient = class {
|
|
|
732
731
|
this.imageStorage = options.mockOptions?.imageStorage ?? new InMemoryMockImageStorage();
|
|
733
732
|
this.createId = options.mockOptions?.createId ?? crypto.randomUUID.bind(crypto);
|
|
734
733
|
this.now = options.mockOptions?.now ?? Date.now;
|
|
735
|
-
this.
|
|
736
|
-
this.
|
|
734
|
+
this.queuedOutcome = options.mockOptions?.queuedOutcome ?? "pending";
|
|
735
|
+
this.analyzedOutcome = options.mockOptions?.analyzedOutcome ?? "approved";
|
|
737
736
|
this.apiKeyGrants = getMockApiKeyGrants(options.apiKey);
|
|
738
737
|
this.signedUrlBaseUrl = options.mockOptions?.signedUrlBaseUrl ?? "mock://calmlens";
|
|
739
738
|
this.cdnBaseUrl = (options.cdnBaseUrl ?? "mock://calmlens/v1").replace(/\/+$/, "");
|
|
@@ -1045,18 +1044,22 @@ var MockCalmLensServerClient = class {
|
|
|
1045
1044
|
isFinal: part.isFinal
|
|
1046
1045
|
});
|
|
1047
1046
|
if (!validation.ok) throw this.invalidPayload(validation.error);
|
|
1048
|
-
if (asset.status !== "uploading") throw this.apiError(require_CalmLensVersion.API_ERROR_CODES.UPLOAD_NOT_OPEN);
|
|
1049
|
-
const expectedPartNumber = (asset.uploadPartsReceived ?? 1) + 1;
|
|
1047
|
+
if (asset.processing.status !== "uploading") throw this.apiError(require_CalmLensVersion.API_ERROR_CODES.UPLOAD_NOT_OPEN);
|
|
1048
|
+
const expectedPartNumber = (asset.processing.uploadPartsReceived ?? 1) + 1;
|
|
1050
1049
|
if (part.partNumber !== expectedPartNumber) throw this.apiError(require_CalmLensVersion.API_ERROR_CODES.INVALID_UPLOAD_PART_NUMBER, { details: { expectedPartNumber } });
|
|
1051
1050
|
await this.imageStorage.putPart(assetId, part);
|
|
1052
1051
|
const queue = options.queue ?? this.uploadQueues.get(assetId) ?? false;
|
|
1053
1052
|
if (part.isFinal) this.uploadQueues.delete(assetId);
|
|
1054
|
-
|
|
1053
|
+
const now = this.now();
|
|
1054
|
+
const received = {
|
|
1055
1055
|
...asset,
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1056
|
+
processing: {
|
|
1057
|
+
...asset.processing,
|
|
1058
|
+
uploadPartsReceived: part.partNumber
|
|
1059
|
+
},
|
|
1060
|
+
updatedAt: now
|
|
1061
|
+
};
|
|
1062
|
+
return this.databaseStorage.updateAsset(part.isFinal ? await this.applyOutcome(received, queue ? this.queuedOutcome : this.analyzedOutcome) : received);
|
|
1060
1063
|
});
|
|
1061
1064
|
},
|
|
1062
1065
|
createSignedUrl: async (signedUrlOptions) => {
|
|
@@ -1089,13 +1092,9 @@ var MockCalmLensServerClient = class {
|
|
|
1089
1092
|
retry: async (options) => {
|
|
1090
1093
|
this.begin("assets.retry", options);
|
|
1091
1094
|
const asset = await this.findOwnAsset(options?.assetId);
|
|
1092
|
-
if (asset.status !== "
|
|
1093
|
-
if (asset.
|
|
1094
|
-
return this.databaseStorage.updateAsset(
|
|
1095
|
-
...asset,
|
|
1096
|
-
status: "pending",
|
|
1097
|
-
updatedAt: this.now()
|
|
1098
|
-
});
|
|
1095
|
+
if (asset.processing.status !== "failed") throw this.apiError(require_CalmLensVersion.API_ERROR_CODES.ASSET_NOT_RETRYABLE);
|
|
1096
|
+
if (asset.content.status === "removed") throw this.apiError(require_CalmLensVersion.API_ERROR_CODES.ASSET_CONTENT_UNAVAILABLE);
|
|
1097
|
+
return this.databaseStorage.updateAsset(await this.applyOutcome(asset, "pending"));
|
|
1099
1098
|
},
|
|
1100
1099
|
/** Waits like the real client, checking the mock's storage for a decision. */
|
|
1101
1100
|
waitForDecision: async (options) => {
|
|
@@ -1107,11 +1106,17 @@ var MockCalmLensServerClient = class {
|
|
|
1107
1106
|
this.begin("assets.deleteContent", options);
|
|
1108
1107
|
const asset = await this.findOwnAsset(options?.assetId);
|
|
1109
1108
|
await this.imageStorage.deleteContent(asset.id);
|
|
1109
|
+
const now = this.now();
|
|
1110
1110
|
return this.databaseStorage.updateAsset({
|
|
1111
1111
|
...asset,
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1112
|
+
content: asset.content.status === "removed" ? asset.content : {
|
|
1113
|
+
...asset.content,
|
|
1114
|
+
status: "removed",
|
|
1115
|
+
removalReason: "requested",
|
|
1116
|
+
updatedAt: now,
|
|
1117
|
+
extractedText: null
|
|
1118
|
+
},
|
|
1119
|
+
updatedAt: now
|
|
1115
1120
|
});
|
|
1116
1121
|
},
|
|
1117
1122
|
delete: async (options) => {
|
|
@@ -1295,6 +1300,7 @@ var MockCalmLensServerClient = class {
|
|
|
1295
1300
|
const id = this.createId();
|
|
1296
1301
|
const now = this.now();
|
|
1297
1302
|
const isOpenUpload = "part" in options && !options.part.isFinal;
|
|
1303
|
+
const keepContent = options.processingOptions?.keepContentAfterProcessing === true;
|
|
1298
1304
|
const asset = {
|
|
1299
1305
|
id,
|
|
1300
1306
|
projectId: this.projectId,
|
|
@@ -1307,11 +1313,37 @@ var MockCalmLensServerClient = class {
|
|
|
1307
1313
|
externalUrl: "url" in options ? options.url : "content" in options ? options.externalUrl : void 0,
|
|
1308
1314
|
type: inferAssetType(options),
|
|
1309
1315
|
metadata: options.metadata,
|
|
1310
|
-
status: isOpenUpload ? "uploading" : queue ? this.queuedStatus : this.analyzedStatus,
|
|
1311
1316
|
processingOptions: options.processingOptions,
|
|
1312
1317
|
visibility: options.visibility ?? "private",
|
|
1313
|
-
|
|
1314
|
-
|
|
1318
|
+
processing: {
|
|
1319
|
+
status: isOpenUpload ? "uploading" : "processing",
|
|
1320
|
+
updatedAt: now,
|
|
1321
|
+
uploadPartsReceived: "part" in options ? options.part.partNumber ?? 1 : null
|
|
1322
|
+
},
|
|
1323
|
+
moderation: {
|
|
1324
|
+
status: "pending",
|
|
1325
|
+
action: null,
|
|
1326
|
+
note: null,
|
|
1327
|
+
reviewerAction: null,
|
|
1328
|
+
reviewerNote: null,
|
|
1329
|
+
reviewerUserId: null,
|
|
1330
|
+
reviewedAt: null,
|
|
1331
|
+
decidedAt: null,
|
|
1332
|
+
report: null
|
|
1333
|
+
},
|
|
1334
|
+
content: {
|
|
1335
|
+
status: keepContent ? "stored" : "temporary",
|
|
1336
|
+
removalReason: null,
|
|
1337
|
+
updatedAt: now,
|
|
1338
|
+
safetyHold: null,
|
|
1339
|
+
format: this.getContentFormat(options),
|
|
1340
|
+
extension: null,
|
|
1341
|
+
sizeInBytes: this.getSizeInBytes(options) ?? null,
|
|
1342
|
+
checksums: null,
|
|
1343
|
+
image: null,
|
|
1344
|
+
previewImage: null,
|
|
1345
|
+
extractedText: null
|
|
1346
|
+
}
|
|
1315
1347
|
};
|
|
1316
1348
|
if ("content" in options) {
|
|
1317
1349
|
if (!("plainText" in options.content)) await this.imageStorage.putContent(id, options.content);
|
|
@@ -1319,7 +1351,39 @@ var MockCalmLensServerClient = class {
|
|
|
1319
1351
|
await this.imageStorage.putPart(id, options.part);
|
|
1320
1352
|
if (isOpenUpload) this.uploadQueues.set(id, queue);
|
|
1321
1353
|
}
|
|
1322
|
-
return this.databaseStorage.createAsset(asset);
|
|
1354
|
+
return this.databaseStorage.createAsset(isOpenUpload ? asset : await this.applyOutcome(asset, queue ? this.queuedOutcome : this.analyzedOutcome));
|
|
1355
|
+
}
|
|
1356
|
+
/**
|
|
1357
|
+
* Moves an asset to `outcome` like the pipeline would: a decision finishes processing, and
|
|
1358
|
+
* finished processing removes content kept only temporarily (`keepContentAfterProcessing` off).
|
|
1359
|
+
*/
|
|
1360
|
+
async applyOutcome(asset, outcome) {
|
|
1361
|
+
const now = this.now();
|
|
1362
|
+
const decided = outcome === "approved" || outcome === "rejected";
|
|
1363
|
+
const processingStatus = decided ? "done" : outcome === "failed" ? "failed" : "processing";
|
|
1364
|
+
const removeContent = processingStatus === "done" && asset.content.status === "temporary";
|
|
1365
|
+
if (removeContent) await this.imageStorage.deleteContent(asset.id);
|
|
1366
|
+
return {
|
|
1367
|
+
...asset,
|
|
1368
|
+
updatedAt: now,
|
|
1369
|
+
processing: {
|
|
1370
|
+
...asset.processing,
|
|
1371
|
+
status: processingStatus,
|
|
1372
|
+
updatedAt: now
|
|
1373
|
+
},
|
|
1374
|
+
moderation: {
|
|
1375
|
+
...asset.moderation,
|
|
1376
|
+
status: decided ? outcome : "pending",
|
|
1377
|
+
decidedAt: decided ? now : null
|
|
1378
|
+
},
|
|
1379
|
+
content: removeContent ? {
|
|
1380
|
+
...asset.content,
|
|
1381
|
+
status: "removed",
|
|
1382
|
+
removalReason: "retention",
|
|
1383
|
+
updatedAt: now,
|
|
1384
|
+
extractedText: null
|
|
1385
|
+
} : asset.content
|
|
1386
|
+
};
|
|
1323
1387
|
}
|
|
1324
1388
|
async resolveFolder(folderId) {
|
|
1325
1389
|
if (!this.databaseStorage.getFolder) return void 0;
|
|
@@ -1336,6 +1400,11 @@ var MockCalmLensServerClient = class {
|
|
|
1336
1400
|
async assertUniqueFolderName(name, parentId, excludeFolderId) {
|
|
1337
1401
|
if ((this.databaseStorage.listFolders ? await this.databaseStorage.listFolders(this.projectId) : []).find((f) => f.id !== excludeFolderId && f.parentId === (parentId ?? null) && f.name === name)) throw this.apiError(require_CalmLensVersion.API_ERROR_CODES.DUPLICATE_FOLDER_NAME, { message: `A folder named "${name}" already exists in this location.` });
|
|
1338
1402
|
}
|
|
1403
|
+
getContentFormat(options) {
|
|
1404
|
+
if ("content" in options) return options.content.type;
|
|
1405
|
+
if ("part" in options) return options.part.type;
|
|
1406
|
+
return null;
|
|
1407
|
+
}
|
|
1339
1408
|
getSizeInBytes(options) {
|
|
1340
1409
|
if ("content" in options) {
|
|
1341
1410
|
if ("plainText" in options.content) return new TextEncoder().encode(options.content.plainText).byteLength;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as invalidArgument, o as CalmLensError, s as SDK_ERROR_CODES, u as API_ERROR_CODES } from "./CalmLensVersion-
|
|
2
|
-
import { a as stringifyQuery, b as getRejectedUploadMimeTypeError, d as CalmLensTransport, g as validateAssetPayload, h as getAssetPayloadByteLength, i as randomUuid, m as assetToData, v as MAX_IMAGE_UPLOAD_BYTES, x as isRejectedUploadMimeType, y as MIN_MULTIPART_IMAGE_UPLOAD_BYTES } from "./CalmLensUtils-
|
|
1
|
+
import { c as invalidArgument, o as CalmLensError, s as SDK_ERROR_CODES, u as API_ERROR_CODES } from "./CalmLensVersion-N71PMJAz.js";
|
|
2
|
+
import { a as stringifyQuery, b as getRejectedUploadMimeTypeError, d as CalmLensTransport, g as validateAssetPayload, h as getAssetPayloadByteLength, i as randomUuid, m as assetToData, v as MAX_IMAGE_UPLOAD_BYTES, x as isRejectedUploadMimeType, y as MIN_MULTIPART_IMAGE_UPLOAD_BYTES } from "./CalmLensUtils-B3S--hBG.js";
|
|
3
3
|
//#region src/client/CalmLensConnection.ts
|
|
4
4
|
const DEFAULT_TIMEOUT_MS = 12e4;
|
|
5
5
|
const DEFAULT_MAX_RETRIES = 2;
|
|
@@ -62,7 +62,8 @@ const prepareSubmitAssetOptions = (options) => {
|
|
|
62
62
|
const newIdempotencyKey = () => randomUuid();
|
|
63
63
|
/** Text content is small, so it keeps the API deadline; binary files may be arbitrarily large. */
|
|
64
64
|
const isTextPayload = (payload) => "plainText" in payload;
|
|
65
|
-
const
|
|
65
|
+
const hasStringStatus = (value) => !!value && typeof value === "object" && typeof value.status === "string";
|
|
66
|
+
const isAsset = (data) => !!data && typeof data === "object" && typeof data.id === "string" && !!data.id && hasStringStatus(data.processing) && hasStringStatus(data.moderation);
|
|
66
67
|
const isUploadedAsset = (data) => !!data && typeof data === "object" && typeof data.id === "string" && !!data.id;
|
|
67
68
|
const expectUploadedAsset = (data) => {
|
|
68
69
|
if (!isUploadedAsset(data)) throw new CalmLensError(SDK_ERROR_CODES.INVALID_RESPONSE, {
|