@calmlens/sdk 0.10.1 → 0.12.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 +60 -16
- package/cjs/CalmLensConnection-CYtBP-vu.js +516 -0
- package/cjs/CalmLensError-CKwMKV0S.js +362 -0
- package/cjs/CalmLensUtils-Dg3s4loH.js +367 -0
- package/cjs/CalmLensWebhooks-BTPxKvcD.js +201 -0
- package/cjs/{CalmLensTypes-DjYFaTyh.d.ts → WebhookPayload-Cgb32aSH.d.ts} +5423 -3844
- package/cjs/app.d.ts +43 -0
- package/cjs/app.js +91 -0
- package/cjs/index-BgmWj3KL.d.ts +350 -0
- package/cjs/index.d.ts +3 -382
- package/cjs/index.js +5 -816
- package/cjs/server.d.ts +202 -0
- package/cjs/server.js +371 -0
- package/cjs/src-Dsc8Pn6v.js +45 -0
- package/cjs/testing.d.ts +54 -18
- package/cjs/testing.js +191 -62
- package/esm/CalmLensConnection-wLNy0OIP.js +475 -0
- package/esm/CalmLensError-CihGG26K.js +321 -0
- package/esm/CalmLensUtils-Cx32j2zt.js +260 -0
- package/esm/CalmLensWebhooks-DShmAal4.js +148 -0
- package/esm/{CalmLensTypes-DjYFaTyh.d.ts → WebhookPayload-Cgb32aSH.d.ts} +5423 -3844
- package/esm/app.d.ts +43 -0
- package/esm/app.js +87 -0
- package/esm/index-BgmWj3KL.d.ts +350 -0
- package/esm/index.d.ts +3 -382
- package/esm/index.js +3 -807
- package/esm/server.d.ts +202 -0
- package/esm/server.js +361 -0
- package/esm/src-CJhrILvM.js +22 -0
- package/esm/testing.d.ts +54 -18
- package/esm/testing.js +142 -13
- package/package.json +23 -1
- package/cjs/CalmLensWebhooks-DJnaLpRy.js +0 -741
- package/esm/CalmLensWebhooks-DLUozliX.js +0 -556
package/esm/app.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
//#region src/client/CalmLensAppClient.d.ts
|
|
4
|
+
declare const inspectSymbol: unique symbol;
|
|
5
|
+
/**
|
|
6
|
+
* The CalmLens client for browsers and React Native apps. It uploads through an upload preset,
|
|
7
|
+
* with an upload token from your server when the preset requires one, and never holds an API
|
|
8
|
+
* key. It can upload (`assets.create`, `assets.moderate`, `assets.uploadPart`) and check its own
|
|
9
|
+
* uploads (`assets.retrieve`). Every method throws `CalmLensError` on failure.
|
|
10
|
+
*/
|
|
11
|
+
declare class CalmLensAppClient {
|
|
12
|
+
#private;
|
|
13
|
+
constructor(options: CalmLensAppClientOptions);
|
|
14
|
+
/** Keeps tokens out of `console.log`, `util.inspect` and `JSON.stringify`. */
|
|
15
|
+
[inspectSymbol](): string;
|
|
16
|
+
toJSON(): {
|
|
17
|
+
uploadPresetId: string;
|
|
18
|
+
baseUrl: string;
|
|
19
|
+
};
|
|
20
|
+
private get uploadsPath();
|
|
21
|
+
/** A fresh token for a new upload, when the client has one. */
|
|
22
|
+
private newUploadToken;
|
|
23
|
+
/** The `Authorization` header for an upload this client started. */
|
|
24
|
+
private authHeaders;
|
|
25
|
+
/** Uploads with a new token, kept for the upload's parts and status checks. */
|
|
26
|
+
private submit;
|
|
27
|
+
/** Uploads through the client's upload preset and checks those uploads. */
|
|
28
|
+
get assets(): {
|
|
29
|
+
/** Uploads a file and queues it for moderation. */
|
|
30
|
+
create: (options: UploadPresetSubmitAssetOptions) => Promise<UploadedAsset>;
|
|
31
|
+
/** Uploads a file and waits for its moderation decision. */
|
|
32
|
+
moderate: (options: UploadPresetSubmitAssetOptions) => Promise<UploadedAsset>;
|
|
33
|
+
/**
|
|
34
|
+
* Uploads the next part of a multipart upload this client started. The upload's queue
|
|
35
|
+
* mode, chosen when it started, applies when the final part arrives.
|
|
36
|
+
*/
|
|
37
|
+
uploadPart: ({ assetId, ...options }: UploadAssetPartOptions) => Promise<UploadedAsset>;
|
|
38
|
+
/** Checks an upload this client made. `status` is present when the preset shows decisions. */
|
|
39
|
+
retrieve: ({ assetId }: RetrieveAssetOptions) => Promise<UploadedAsset>;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
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 };
|
package/esm/app.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { a as invalidConfig, i as invalidArgument, n as CalmLensError, t as CALMLENS_ERROR_CODES } from "./CalmLensError-CihGG26K.js";
|
|
2
|
+
import { t as SDK_VERSION } from "./src-CJhrILvM.js";
|
|
3
|
+
import { n as encodePathSegment, s as validateAppClientOptions } from "./CalmLensUtils-Cx32j2zt.js";
|
|
4
|
+
import { o as prepareSubmitAssetOptions, r as expectUploadedAsset, s as resolveConnectionOptions, t as CalmLensConnection } from "./CalmLensConnection-wLNy0OIP.js";
|
|
5
|
+
//#region src/client/CalmLensAppClient.ts
|
|
6
|
+
const inspectSymbol = Symbol.for("nodejs.util.inspect.custom");
|
|
7
|
+
/**
|
|
8
|
+
* The CalmLens client for browsers and React Native apps. It uploads through an upload preset,
|
|
9
|
+
* with an upload token from your server when the preset requires one, and never holds an API
|
|
10
|
+
* key. It can upload (`assets.create`, `assets.moderate`, `assets.uploadPart`) and check its own
|
|
11
|
+
* uploads (`assets.retrieve`). Every method throws `CalmLensError` on failure.
|
|
12
|
+
*/
|
|
13
|
+
var CalmLensAppClient = class {
|
|
14
|
+
#uploadPresetId;
|
|
15
|
+
#token;
|
|
16
|
+
/** The token each upload started with, for its parts and status checks. */
|
|
17
|
+
#uploadTokens = /* @__PURE__ */ new Map();
|
|
18
|
+
#connection;
|
|
19
|
+
constructor(options) {
|
|
20
|
+
validateAppClientOptions(options);
|
|
21
|
+
const { token, uploadPresetId, ...rest } = options;
|
|
22
|
+
this.#uploadPresetId = uploadPresetId;
|
|
23
|
+
this.#token = token;
|
|
24
|
+
this.#connection = new CalmLensConnection(resolveConnectionOptions(rest));
|
|
25
|
+
}
|
|
26
|
+
/** Keeps tokens out of `console.log`, `util.inspect` and `JSON.stringify`. */
|
|
27
|
+
[inspectSymbol]() {
|
|
28
|
+
return `CalmLensAppClient { uploadPresetId: ${JSON.stringify(this.#uploadPresetId)}, baseUrl: ${JSON.stringify(this.#connection.options.baseUrl)} }`;
|
|
29
|
+
}
|
|
30
|
+
toJSON() {
|
|
31
|
+
return {
|
|
32
|
+
uploadPresetId: this.#uploadPresetId,
|
|
33
|
+
baseUrl: this.#connection.options.baseUrl
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
get uploadsPath() {
|
|
37
|
+
return `/upload-presets/${encodeURIComponent(this.#uploadPresetId)}/assets`;
|
|
38
|
+
}
|
|
39
|
+
/** A fresh token for a new upload, when the client has one. */
|
|
40
|
+
async newUploadToken() {
|
|
41
|
+
const token = typeof this.#token === "function" ? await this.#token() : this.#token;
|
|
42
|
+
if (token !== void 0 && (typeof token !== "string" || !token)) throw invalidConfig("token must return a non-empty string");
|
|
43
|
+
return token;
|
|
44
|
+
}
|
|
45
|
+
/** The `Authorization` header for an upload this client started. */
|
|
46
|
+
authHeaders(assetId) {
|
|
47
|
+
const token = this.#uploadTokens.get(assetId);
|
|
48
|
+
return token ? { Authorization: `Bearer ${token}` } : {};
|
|
49
|
+
}
|
|
50
|
+
/** Uploads with a new token, kept for the upload's parts and status checks. */
|
|
51
|
+
async submit(options, queue) {
|
|
52
|
+
if (!options || typeof options !== "object") throw invalidArgument("Upload options are required");
|
|
53
|
+
if (!("content" in options) && !("part" in options)) throw invalidArgument("Uploads through an upload preset need content or a part");
|
|
54
|
+
prepareSubmitAssetOptions(options);
|
|
55
|
+
const token = await this.newUploadToken();
|
|
56
|
+
const data = await this.#connection.submitRawUpload(this.uploadsPath, options, queue, token ? { Authorization: `Bearer ${token}` } : {});
|
|
57
|
+
const uploaded = expectUploadedAsset(data);
|
|
58
|
+
if (token) this.#uploadTokens.set(uploaded.id, token);
|
|
59
|
+
return uploaded;
|
|
60
|
+
}
|
|
61
|
+
/** Uploads through the client's upload preset and checks those uploads. */
|
|
62
|
+
get assets() {
|
|
63
|
+
return {
|
|
64
|
+
/** Uploads a file and queues it for moderation. */
|
|
65
|
+
create: (options) => this.submit(options, true),
|
|
66
|
+
/** Uploads a file and waits for its moderation decision. */
|
|
67
|
+
moderate: (options) => this.submit(options, false),
|
|
68
|
+
/**
|
|
69
|
+
* Uploads the next part of a multipart upload this client started. The upload's queue
|
|
70
|
+
* mode, chosen when it started, applies when the final part arrives.
|
|
71
|
+
*/
|
|
72
|
+
uploadPart: async ({ assetId, ...options }) => {
|
|
73
|
+
const encodedAssetId = encodePathSegment(assetId, "Asset ID");
|
|
74
|
+
const data = await this.#connection.uploadPart(`${this.uploadsPath}/${encodedAssetId}/part`, options, this.authHeaders(assetId));
|
|
75
|
+
return expectUploadedAsset(data);
|
|
76
|
+
},
|
|
77
|
+
/** Checks an upload this client made. `status` is present when the preset shows decisions. */
|
|
78
|
+
retrieve: async ({ assetId }) => {
|
|
79
|
+
const encodedAssetId = encodePathSegment(assetId, "Asset ID");
|
|
80
|
+
const data = await this.#connection.json("GET", `${this.uploadsPath}/${encodedAssetId}`, { headers: this.authHeaders(assetId) });
|
|
81
|
+
return expectUploadedAsset(data);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
//#endregion
|
|
87
|
+
export { CALMLENS_ERROR_CODES, CalmLensAppClient, CalmLensError, SDK_VERSION };
|
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
import "./WebhookPayload-Cgb32aSH.js";
|
|
2
|
+
import * as zod from "zod";
|
|
3
|
+
//#region ../shared/src/ProcessingFeatures.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Optional analyses a request can turn on with `processingOptions.features.<id>`. The catalog is
|
|
6
|
+
* the single source for the request and result schemas, cache keys and metering. Features are
|
|
7
|
+
* chosen per request only; there is no project-level default.
|
|
8
|
+
*/
|
|
9
|
+
/** How mature a feature is. Beta results may change shape. */
|
|
10
|
+
declare const PROCESSING_FEATURE_STAGES: readonly ["beta", "ga"];
|
|
11
|
+
type ProcessingFeatureStage = (typeof PROCESSING_FEATURE_STAGES)[number];
|
|
12
|
+
declare const PROCESSING_FEATURE_IDS: readonly ["ocr", "personDetection", "faceDetection"];
|
|
13
|
+
type ProcessingFeatureId = (typeof PROCESSING_FEATURE_IDS)[number];
|
|
14
|
+
declare const PROCESSING_FEATURES_SCHEMA: zod.ZodObject<{
|
|
15
|
+
ocr: zod.ZodOptional<zod.ZodNullable<zod.ZodObject<{
|
|
16
|
+
enabled: zod.ZodBoolean;
|
|
17
|
+
}, zod.core.$strict>>>;
|
|
18
|
+
personDetection: zod.ZodOptional<zod.ZodNullable<zod.ZodObject<{
|
|
19
|
+
enabled: zod.ZodBoolean;
|
|
20
|
+
}, zod.core.$strict>>>;
|
|
21
|
+
faceDetection: zod.ZodOptional<zod.ZodNullable<zod.ZodObject<{
|
|
22
|
+
enabled: zod.ZodBoolean;
|
|
23
|
+
ageEstimation: zod.ZodOptional<zod.ZodBoolean>;
|
|
24
|
+
}, zod.core.$strict>>>;
|
|
25
|
+
}, zod.core.$strict>;
|
|
26
|
+
type ProcessingFeatures = zod.infer<typeof PROCESSING_FEATURES_SCHEMA>;
|
|
27
|
+
/** Position and size as fractions of the image width and height, from 0 to 1. */
|
|
28
|
+
declare const BOUNDING_BOX_SCHEMA: zod.ZodObject<{
|
|
29
|
+
left: zod.ZodNumber;
|
|
30
|
+
top: zod.ZodNumber;
|
|
31
|
+
width: zod.ZodNumber;
|
|
32
|
+
height: zod.ZodNumber;
|
|
33
|
+
}, zod.core.$strict>;
|
|
34
|
+
type BoundingBox = zod.infer<typeof BOUNDING_BOX_SCHEMA>;
|
|
35
|
+
declare const AGE_RANGE_SCHEMA: zod.ZodObject<{
|
|
36
|
+
low: zod.ZodNumber;
|
|
37
|
+
high: zod.ZodNumber;
|
|
38
|
+
}, zod.core.$strict>;
|
|
39
|
+
type AgeRange = zod.infer<typeof AGE_RANGE_SCHEMA>;
|
|
40
|
+
declare const DETECTED_PERSON_SCHEMA: zod.ZodObject<{
|
|
41
|
+
box: zod.ZodObject<{
|
|
42
|
+
left: zod.ZodNumber;
|
|
43
|
+
top: zod.ZodNumber;
|
|
44
|
+
width: zod.ZodNumber;
|
|
45
|
+
height: zod.ZodNumber;
|
|
46
|
+
}, zod.core.$strict>;
|
|
47
|
+
confidence: zod.ZodNumber;
|
|
48
|
+
}, zod.core.$strict>;
|
|
49
|
+
type DetectedPerson = zod.infer<typeof DETECTED_PERSON_SCHEMA>;
|
|
50
|
+
declare const DETECTED_FACE_SCHEMA: zod.ZodObject<{
|
|
51
|
+
box: zod.ZodObject<{
|
|
52
|
+
left: zod.ZodNumber;
|
|
53
|
+
top: zod.ZodNumber;
|
|
54
|
+
width: zod.ZodNumber;
|
|
55
|
+
height: zod.ZodNumber;
|
|
56
|
+
}, zod.core.$strict>;
|
|
57
|
+
confidence: zod.ZodNumber;
|
|
58
|
+
ageRange: zod.ZodOptional<zod.ZodObject<{
|
|
59
|
+
low: zod.ZodNumber;
|
|
60
|
+
high: zod.ZodNumber;
|
|
61
|
+
}, zod.core.$strict>>;
|
|
62
|
+
}, zod.core.$strict>;
|
|
63
|
+
type DetectedFace = zod.infer<typeof DETECTED_FACE_SCHEMA>;
|
|
64
|
+
declare const PROCESSING_FEATURE_RESULTS_SCHEMA: zod.ZodObject<{
|
|
65
|
+
personDetection: zod.ZodOptional<zod.ZodDiscriminatedUnion<[zod.ZodObject<{
|
|
66
|
+
status: zod.ZodLiteral<"evaluated">;
|
|
67
|
+
stage: zod.ZodEnum<{
|
|
68
|
+
beta: "beta";
|
|
69
|
+
ga: "ga";
|
|
70
|
+
}>;
|
|
71
|
+
people: zod.ZodArray<zod.ZodObject<{
|
|
72
|
+
box: zod.ZodObject<{
|
|
73
|
+
left: zod.ZodNumber;
|
|
74
|
+
top: zod.ZodNumber;
|
|
75
|
+
width: zod.ZodNumber;
|
|
76
|
+
height: zod.ZodNumber;
|
|
77
|
+
}, zod.core.$strict>;
|
|
78
|
+
confidence: zod.ZodNumber;
|
|
79
|
+
}, zod.core.$strict>>;
|
|
80
|
+
}, zod.core.$strict>, zod.ZodObject<{
|
|
81
|
+
status: zod.ZodLiteral<"not-evaluated">;
|
|
82
|
+
stage: zod.ZodEnum<{
|
|
83
|
+
beta: "beta";
|
|
84
|
+
ga: "ga";
|
|
85
|
+
}>;
|
|
86
|
+
reason: zod.ZodEnum<{
|
|
87
|
+
"not-supported": "not-supported";
|
|
88
|
+
unavailable: "unavailable";
|
|
89
|
+
}>;
|
|
90
|
+
}, zod.core.$strict>], "status">>;
|
|
91
|
+
faceDetection: zod.ZodOptional<zod.ZodDiscriminatedUnion<[zod.ZodObject<{
|
|
92
|
+
status: zod.ZodLiteral<"evaluated">;
|
|
93
|
+
stage: zod.ZodEnum<{
|
|
94
|
+
beta: "beta";
|
|
95
|
+
ga: "ga";
|
|
96
|
+
}>;
|
|
97
|
+
faces: zod.ZodArray<zod.ZodObject<{
|
|
98
|
+
box: zod.ZodObject<{
|
|
99
|
+
left: zod.ZodNumber;
|
|
100
|
+
top: zod.ZodNumber;
|
|
101
|
+
width: zod.ZodNumber;
|
|
102
|
+
height: zod.ZodNumber;
|
|
103
|
+
}, zod.core.$strict>;
|
|
104
|
+
confidence: zod.ZodNumber;
|
|
105
|
+
ageRange: zod.ZodOptional<zod.ZodObject<{
|
|
106
|
+
low: zod.ZodNumber;
|
|
107
|
+
high: zod.ZodNumber;
|
|
108
|
+
}, zod.core.$strict>>;
|
|
109
|
+
}, zod.core.$strict>>;
|
|
110
|
+
}, zod.core.$strict>, zod.ZodObject<{
|
|
111
|
+
status: zod.ZodLiteral<"not-evaluated">;
|
|
112
|
+
stage: zod.ZodEnum<{
|
|
113
|
+
beta: "beta";
|
|
114
|
+
ga: "ga";
|
|
115
|
+
}>;
|
|
116
|
+
reason: zod.ZodEnum<{
|
|
117
|
+
"not-supported": "not-supported";
|
|
118
|
+
unavailable: "unavailable";
|
|
119
|
+
}>;
|
|
120
|
+
}, zod.core.$strict>], "status">>;
|
|
121
|
+
}, zod.core.$strict>;
|
|
122
|
+
type ProcessingFeatureResults = zod.infer<typeof PROCESSING_FEATURE_RESULTS_SCHEMA>;
|
|
123
|
+
//#endregion
|
|
124
|
+
//#region ../shared/src/Project.d.ts
|
|
125
|
+
declare const FLAGGED_CONTENT_ACTION_SCHEMA: zod.ZodEnum<{
|
|
126
|
+
alert: "alert";
|
|
127
|
+
hide: "hide";
|
|
128
|
+
ignore: "ignore";
|
|
129
|
+
purge: "purge";
|
|
130
|
+
}>;
|
|
131
|
+
type FlaggedContentAction = zod.infer<typeof FLAGGED_CONTENT_ACTION_SCHEMA>;
|
|
132
|
+
declare const FLAGGED_CONTENT_POLICY_SCHEMA: zod.ZodObject<{
|
|
133
|
+
action: zod.ZodEnum<{
|
|
134
|
+
alert: "alert";
|
|
135
|
+
hide: "hide";
|
|
136
|
+
ignore: "ignore";
|
|
137
|
+
purge: "purge";
|
|
138
|
+
}>;
|
|
139
|
+
}, zod.core.$strip>;
|
|
140
|
+
type FlaggedContentPolicy = zod.infer<typeof FLAGGED_CONTENT_POLICY_SCHEMA>;
|
|
141
|
+
//#endregion
|
|
142
|
+
//#region src/client/CalmLensErrorCodes.d.ts
|
|
143
|
+
/** Error codes the CalmLens API documents, by name. */
|
|
144
|
+
declare const API_ERROR_CODES: {
|
|
145
|
+
readonly MISSING_TOKEN: "auth/missing-token";
|
|
146
|
+
readonly INVALID_API_KEY: "auth/invalid-api-key";
|
|
147
|
+
readonly API_KEY_PROJECT_MISMATCH: "auth/project-mismatch";
|
|
148
|
+
readonly API_KEY_NOT_ACCEPTED: "auth/api-key-not-accepted";
|
|
149
|
+
readonly FILE_TOO_LARGE: "upload/file-too-large";
|
|
150
|
+
readonly IMAGE_REQUIRES_MULTIPART_UPLOAD: "upload/image-requires-multipart-upload";
|
|
151
|
+
readonly MULTIPART_IMAGE_TOO_SMALL: "upload/multipart-image-too-small";
|
|
152
|
+
readonly MULTIPART_IMAGE_TOO_LARGE: "upload/multipart-image-too-large";
|
|
153
|
+
readonly IMAGE_EXCEEDED_MAX_DIMENSIONS: "upload/image-exceeded-max-dimensions";
|
|
154
|
+
readonly UPLOAD_LIMIT_EXCEEDED: "upload/limit-exceeded";
|
|
155
|
+
readonly INVALID_UPLOAD_MIME_TYPE: "upload/invalid-mime-type";
|
|
156
|
+
readonly INVALID_EVENT_CURSOR: "events/invalid-cursor";
|
|
157
|
+
readonly INVALID_UPLOAD_PAYLOAD: "upload/invalid-payload";
|
|
158
|
+
readonly USE_UPLOAD_PART: "upload/use-upload-part";
|
|
159
|
+
readonly UPLOAD_NOT_OPEN: "upload/not-open";
|
|
160
|
+
readonly INVALID_UPLOAD_PART_NUMBER: "upload/invalid-part-number";
|
|
161
|
+
readonly UPLOAD_MISSING: "upload/missing";
|
|
162
|
+
readonly UPLOAD_SIZE_MISMATCH: "upload/size-mismatch";
|
|
163
|
+
readonly INVALID_IDEMPOTENCY_KEY: "idempotency/invalid-key";
|
|
164
|
+
readonly IDEMPOTENCY_KEY_REUSED: "idempotency/key-reused";
|
|
165
|
+
readonly IDEMPOTENT_REQUEST_IN_PROGRESS: "idempotency/request-in-progress";
|
|
166
|
+
readonly ASSET_NOT_FOUND: "asset/not-found";
|
|
167
|
+
readonly PROJECT_NOT_FOUND: "project/not-found";
|
|
168
|
+
readonly ASSET_UPDATE_FAILED: "asset/update-failed";
|
|
169
|
+
readonly ASSET_SAFETY_HELD: "asset/safety-held";
|
|
170
|
+
readonly ASSET_NOT_RETRYABLE: "asset/not-retryable";
|
|
171
|
+
readonly ASSET_CONTENT_UNAVAILABLE: "asset/content-unavailable";
|
|
172
|
+
readonly SUPPORT_TICKET_NOT_FOUND: "support/ticket-not-found";
|
|
173
|
+
readonly DUPLICATE_EXTERNAL_ID: "asset/duplicate-external-id";
|
|
174
|
+
readonly FOLDER_NOT_FOUND: "folder/not-found";
|
|
175
|
+
readonly DUPLICATE_FOLDER_NAME: "folder/duplicate-name";
|
|
176
|
+
readonly FOLDER_NOT_EMPTY: "folder/not-empty";
|
|
177
|
+
readonly FOLDER_PARENT_CYCLE: "folder/parent-cycle";
|
|
178
|
+
readonly LENS_VERSION_CONFLICT: "lens/version-conflict";
|
|
179
|
+
readonly UPLOAD_PRESET_NOT_FOUND: "upload-preset/not-found";
|
|
180
|
+
readonly UPLOAD_PRESET_DISABLED: "upload-preset/disabled";
|
|
181
|
+
readonly UPLOAD_PRESET_TOKEN_REQUIRED: "upload-preset/token-required";
|
|
182
|
+
readonly UPLOAD_PRESET_CONTENT_TYPE_NOT_ALLOWED: "upload-preset/content-type-not-allowed";
|
|
183
|
+
readonly UPLOAD_PRESET_TOO_LARGE: "upload-preset/too-large";
|
|
184
|
+
readonly UPLOAD_PRESET_DAILY_LIMIT_REACHED: "upload-preset/daily-limit-reached";
|
|
185
|
+
readonly UPLOAD_PRESET_ORIGIN_NOT_ALLOWED: "upload-preset/origin-not-allowed";
|
|
186
|
+
readonly UPLOAD_PRESET_FIELD_NOT_ALLOWED: "upload-preset/field-not-allowed";
|
|
187
|
+
readonly UPLOAD_TOKEN_INVALID: "upload-token/invalid";
|
|
188
|
+
readonly UPLOAD_TOKEN_EXPIRED: "upload-token/expired";
|
|
189
|
+
readonly UPLOAD_TOKEN_USED: "upload-token/used";
|
|
190
|
+
};
|
|
191
|
+
type ApiErrorCode = (typeof API_ERROR_CODES)[keyof typeof API_ERROR_CODES];
|
|
192
|
+
//#endregion
|
|
193
|
+
//#region src/client/CalmLensError.d.ts
|
|
194
|
+
type CalmLensErrorDetails = Record<string, unknown>;
|
|
195
|
+
/** Codes for failures the SDK detects itself, before or instead of an API error response. */
|
|
196
|
+
declare const SDK_ERROR_CODES: {
|
|
197
|
+
/** The request could not be completed: DNS, TLS, a refused or reset connection, a truncated body. */
|
|
198
|
+
readonly TRANSPORT_ERROR: "sdk/transport-error";
|
|
199
|
+
/** The request did not finish within `timeoutMs`. */
|
|
200
|
+
readonly TIMEOUT: "sdk/timeout";
|
|
201
|
+
/** The caller's `AbortSignal` cancelled the request. */
|
|
202
|
+
readonly CANCELLED: "sdk/cancelled";
|
|
203
|
+
/** A successful response whose body is not the JSON the operation returns. */
|
|
204
|
+
readonly INVALID_RESPONSE: "sdk/invalid-response";
|
|
205
|
+
/** An HTTP failure without a CalmLens error body, for example from a proxy. */
|
|
206
|
+
readonly HTTP_ERROR: "sdk/http-error";
|
|
207
|
+
/** A response body larger than `maxResponseBytes`. */
|
|
208
|
+
readonly RESPONSE_TOO_LARGE: "sdk/response-too-large";
|
|
209
|
+
/** A method argument is missing or invalid, for example an empty asset ID. */
|
|
210
|
+
readonly INVALID_ARGUMENT: "sdk/invalid-argument";
|
|
211
|
+
/** The client options are invalid, for example a missing API key. */
|
|
212
|
+
readonly INVALID_CONFIG: "sdk/invalid-config";
|
|
213
|
+
/** No `fetch` implementation is available in this runtime. */
|
|
214
|
+
readonly NO_FETCH: "sdk/no-fetch";
|
|
215
|
+
/** A webhook delivery whose signature or timestamp did not verify. */
|
|
216
|
+
readonly INVALID_WEBHOOK_SIGNATURE: "sdk/invalid-webhook-signature";
|
|
217
|
+
/** A verified webhook delivery whose body is not a webhook event. */
|
|
218
|
+
readonly INVALID_WEBHOOK_PAYLOAD: "sdk/invalid-webhook-payload";
|
|
219
|
+
};
|
|
220
|
+
type SdkErrorCode = (typeof SDK_ERROR_CODES)[keyof typeof SDK_ERROR_CODES];
|
|
221
|
+
/** Every error code the SDK can throw: the documented API codes and the SDK's own `sdk/*` codes. */
|
|
222
|
+
declare const CALMLENS_ERROR_CODES: {
|
|
223
|
+
readonly MISSING_TOKEN: "auth/missing-token";
|
|
224
|
+
readonly INVALID_API_KEY: "auth/invalid-api-key";
|
|
225
|
+
readonly API_KEY_PROJECT_MISMATCH: "auth/project-mismatch";
|
|
226
|
+
readonly API_KEY_NOT_ACCEPTED: "auth/api-key-not-accepted";
|
|
227
|
+
readonly FILE_TOO_LARGE: "upload/file-too-large";
|
|
228
|
+
readonly IMAGE_REQUIRES_MULTIPART_UPLOAD: "upload/image-requires-multipart-upload";
|
|
229
|
+
readonly MULTIPART_IMAGE_TOO_SMALL: "upload/multipart-image-too-small";
|
|
230
|
+
readonly MULTIPART_IMAGE_TOO_LARGE: "upload/multipart-image-too-large";
|
|
231
|
+
readonly IMAGE_EXCEEDED_MAX_DIMENSIONS: "upload/image-exceeded-max-dimensions";
|
|
232
|
+
readonly UPLOAD_LIMIT_EXCEEDED: "upload/limit-exceeded";
|
|
233
|
+
readonly INVALID_UPLOAD_MIME_TYPE: "upload/invalid-mime-type";
|
|
234
|
+
readonly INVALID_EVENT_CURSOR: "events/invalid-cursor";
|
|
235
|
+
readonly INVALID_UPLOAD_PAYLOAD: "upload/invalid-payload";
|
|
236
|
+
readonly USE_UPLOAD_PART: "upload/use-upload-part";
|
|
237
|
+
readonly UPLOAD_NOT_OPEN: "upload/not-open";
|
|
238
|
+
readonly INVALID_UPLOAD_PART_NUMBER: "upload/invalid-part-number";
|
|
239
|
+
readonly UPLOAD_MISSING: "upload/missing";
|
|
240
|
+
readonly UPLOAD_SIZE_MISMATCH: "upload/size-mismatch";
|
|
241
|
+
readonly INVALID_IDEMPOTENCY_KEY: "idempotency/invalid-key";
|
|
242
|
+
readonly IDEMPOTENCY_KEY_REUSED: "idempotency/key-reused";
|
|
243
|
+
readonly IDEMPOTENT_REQUEST_IN_PROGRESS: "idempotency/request-in-progress";
|
|
244
|
+
readonly ASSET_NOT_FOUND: "asset/not-found";
|
|
245
|
+
readonly PROJECT_NOT_FOUND: "project/not-found";
|
|
246
|
+
readonly ASSET_UPDATE_FAILED: "asset/update-failed";
|
|
247
|
+
readonly ASSET_SAFETY_HELD: "asset/safety-held";
|
|
248
|
+
readonly ASSET_NOT_RETRYABLE: "asset/not-retryable";
|
|
249
|
+
readonly ASSET_CONTENT_UNAVAILABLE: "asset/content-unavailable";
|
|
250
|
+
readonly SUPPORT_TICKET_NOT_FOUND: "support/ticket-not-found";
|
|
251
|
+
readonly DUPLICATE_EXTERNAL_ID: "asset/duplicate-external-id";
|
|
252
|
+
readonly FOLDER_NOT_FOUND: "folder/not-found";
|
|
253
|
+
readonly DUPLICATE_FOLDER_NAME: "folder/duplicate-name";
|
|
254
|
+
readonly FOLDER_NOT_EMPTY: "folder/not-empty";
|
|
255
|
+
readonly FOLDER_PARENT_CYCLE: "folder/parent-cycle";
|
|
256
|
+
readonly LENS_VERSION_CONFLICT: "lens/version-conflict";
|
|
257
|
+
readonly UPLOAD_PRESET_NOT_FOUND: "upload-preset/not-found";
|
|
258
|
+
readonly UPLOAD_PRESET_DISABLED: "upload-preset/disabled";
|
|
259
|
+
readonly UPLOAD_PRESET_TOKEN_REQUIRED: "upload-preset/token-required";
|
|
260
|
+
readonly UPLOAD_PRESET_CONTENT_TYPE_NOT_ALLOWED: "upload-preset/content-type-not-allowed";
|
|
261
|
+
readonly UPLOAD_PRESET_TOO_LARGE: "upload-preset/too-large";
|
|
262
|
+
readonly UPLOAD_PRESET_DAILY_LIMIT_REACHED: "upload-preset/daily-limit-reached";
|
|
263
|
+
readonly UPLOAD_PRESET_ORIGIN_NOT_ALLOWED: "upload-preset/origin-not-allowed";
|
|
264
|
+
readonly UPLOAD_PRESET_FIELD_NOT_ALLOWED: "upload-preset/field-not-allowed";
|
|
265
|
+
readonly UPLOAD_TOKEN_INVALID: "upload-token/invalid";
|
|
266
|
+
readonly UPLOAD_TOKEN_EXPIRED: "upload-token/expired";
|
|
267
|
+
readonly UPLOAD_TOKEN_USED: "upload-token/used";
|
|
268
|
+
/** The request could not be completed: DNS, TLS, a refused or reset connection, a truncated body. */
|
|
269
|
+
readonly TRANSPORT_ERROR: "sdk/transport-error";
|
|
270
|
+
/** The request did not finish within `timeoutMs`. */
|
|
271
|
+
readonly TIMEOUT: "sdk/timeout";
|
|
272
|
+
/** The caller's `AbortSignal` cancelled the request. */
|
|
273
|
+
readonly CANCELLED: "sdk/cancelled";
|
|
274
|
+
/** A successful response whose body is not the JSON the operation returns. */
|
|
275
|
+
readonly INVALID_RESPONSE: "sdk/invalid-response";
|
|
276
|
+
/** An HTTP failure without a CalmLens error body, for example from a proxy. */
|
|
277
|
+
readonly HTTP_ERROR: "sdk/http-error";
|
|
278
|
+
/** A response body larger than `maxResponseBytes`. */
|
|
279
|
+
readonly RESPONSE_TOO_LARGE: "sdk/response-too-large";
|
|
280
|
+
/** A method argument is missing or invalid, for example an empty asset ID. */
|
|
281
|
+
readonly INVALID_ARGUMENT: "sdk/invalid-argument";
|
|
282
|
+
/** The client options are invalid, for example a missing API key. */
|
|
283
|
+
readonly INVALID_CONFIG: "sdk/invalid-config";
|
|
284
|
+
/** No `fetch` implementation is available in this runtime. */
|
|
285
|
+
readonly NO_FETCH: "sdk/no-fetch";
|
|
286
|
+
/** A webhook delivery whose signature or timestamp did not verify. */
|
|
287
|
+
readonly INVALID_WEBHOOK_SIGNATURE: "sdk/invalid-webhook-signature";
|
|
288
|
+
/** A verified webhook delivery whose body is not a webhook event. */
|
|
289
|
+
readonly INVALID_WEBHOOK_PAYLOAD: "sdk/invalid-webhook-payload";
|
|
290
|
+
};
|
|
291
|
+
/**
|
|
292
|
+
* A known error code. API validation codes (`validation/*`) and codes added to the API after
|
|
293
|
+
* this SDK version are still delivered as plain strings, so compare against `string`.
|
|
294
|
+
*/
|
|
295
|
+
type CalmLensErrorCode = ApiErrorCode | SdkErrorCode;
|
|
296
|
+
interface CalmLensErrorOptions {
|
|
297
|
+
message?: string;
|
|
298
|
+
status?: number;
|
|
299
|
+
details?: CalmLensErrorDetails;
|
|
300
|
+
cause?: unknown;
|
|
301
|
+
/** The `X-Request-Id` response header. */
|
|
302
|
+
requestId?: string;
|
|
303
|
+
/** The response headers, when there was a response. */
|
|
304
|
+
headers?: Headers;
|
|
305
|
+
/** Seconds to wait before retrying, from the `Retry-After` response header. */
|
|
306
|
+
retryAfter?: number;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Every failure the SDK reports, whether the API returned an error or the request never
|
|
310
|
+
* completed. Branch on `code`; `status`, `requestId`, `headers` and `retryAfter` describe the
|
|
311
|
+
* HTTP response when there was one, and `cause` holds the underlying error.
|
|
312
|
+
*
|
|
313
|
+
* `instanceof CalmLensError` and `CalmLensError.isCalmLensError(value)` both recognise errors
|
|
314
|
+
* from any copy of the SDK, so they work when ESM and CommonJS builds are loaded side by side.
|
|
315
|
+
*/
|
|
316
|
+
declare class CalmLensError extends Error {
|
|
317
|
+
/** A stable identifier such as `asset/not-found` or `sdk/timeout`. */
|
|
318
|
+
readonly code: CalmLensErrorCode | (string & {});
|
|
319
|
+
/** The HTTP status, when the API responded. */
|
|
320
|
+
readonly status?: number;
|
|
321
|
+
/** Structured diagnostics from the API, such as validation issues and `traceId`. */
|
|
322
|
+
readonly details?: CalmLensErrorDetails;
|
|
323
|
+
/** The `X-Request-Id` response header. Include it when you contact support. */
|
|
324
|
+
readonly requestId?: string;
|
|
325
|
+
/** The response headers, when the API responded. */
|
|
326
|
+
readonly headers?: Headers;
|
|
327
|
+
/** Seconds to wait before retrying, from the `Retry-After` response header. */
|
|
328
|
+
readonly retryAfter?: number;
|
|
329
|
+
constructor(code: CalmLensErrorCode | (string & {}) | {
|
|
330
|
+
id: string;
|
|
331
|
+
defaultMessage?: string;
|
|
332
|
+
}, options?: CalmLensErrorOptions);
|
|
333
|
+
/** True for any `CalmLensError`, including one created by another copy or build of the SDK. */
|
|
334
|
+
static isCalmLensError(value: unknown): value is CalmLensError;
|
|
335
|
+
static [Symbol.hasInstance](value: unknown): boolean;
|
|
336
|
+
/** The resource does not exist or is not visible to this API key. */
|
|
337
|
+
isNotFound(): boolean;
|
|
338
|
+
/**
|
|
339
|
+
* Whether repeating the same request may succeed: transport failures, throttling (429),
|
|
340
|
+
* gateway errors (502, 503, 504) and idempotent requests still in progress. Only repeat a
|
|
341
|
+
* create or upload with the same `idempotencyKey`.
|
|
342
|
+
*/
|
|
343
|
+
isRetryable(): boolean;
|
|
344
|
+
}
|
|
345
|
+
//#endregion
|
|
346
|
+
//#region src/client/CalmLensVersion.d.ts
|
|
347
|
+
/** This SDK's version, from its package.json. */
|
|
348
|
+
declare const SDK_VERSION: string;
|
|
349
|
+
//#endregion
|
|
350
|
+
export { ProcessingFeatureStage as _, CalmLensErrorDetails as a, ApiErrorCode as c, AgeRange as d, BoundingBox as f, ProcessingFeatureResults as g, ProcessingFeatureId as h, CalmLensErrorCode as i, FlaggedContentAction as l, DetectedPerson as m, CALMLENS_ERROR_CODES as n, CalmLensErrorOptions as o, DetectedFace as p, CalmLensError as r, SdkErrorCode as s, SDK_VERSION as t, FlaggedContentPolicy as u, ProcessingFeatures as v };
|