calmlens 0.28.2 → 0.29.1
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/bin/calmlens.js +151 -123
- package/cjs/{BrowserUpload-CRbCsX7a.d.ts → BrowserUpload-CeGsM9h1.d.ts} +2 -2
- package/cjs/{BrowserUpload-DmKNP0Vy.js → BrowserUpload-CsxEB1Pr.js} +1 -1
- package/cjs/{CalmLensAppClient-Bl9VU7S2.js → CalmLensAppClient-BWMcQM9v.js} +11 -17
- package/cjs/{CalmLensAppClient-B3u6BlP5.d.ts → CalmLensAppClient-D-BD_Ny1.d.ts} +7 -1
- package/cjs/{CalmLensOptionKeys-DolSy6qV.js → CalmLensConnection-DBgV8D1B.js} +660 -643
- package/cjs/{CalmLensServerClient-B8ntjNL3.d.ts → CalmLensServerClient-BYN_N0lt.d.ts} +33 -2
- package/cjs/{CalmLensServerClient-DA-sB9ru.js → CalmLensServerClient-DYO3geSA.js} +72 -41
- package/cjs/{CalmLensTypes-CtO4Dieu.d.ts → CalmLensTypes-C2blKgTu.d.ts} +51 -75
- package/cjs/{Core-RSm9Xcse.js → Core-Bl-aESvN.js} +2 -2
- package/{esm/Core-BJaLU71Q.d.ts → cjs/Core-CNmoxDCW.d.ts} +2 -2
- package/cjs/{ModerationContextLimits-51OdOFof.js → ModerationContextLimits-DHu2jHpo.js} +24 -13
- package/cjs/{ReactUpload-DQYHaJSZ.js → ReactUpload-BFVNyWoI.js} +1 -1
- package/cjs/{ReactUpload-BGUkcMpg.d.ts → ReactUpload-kqEe6gcN.d.ts} +1 -1
- package/cjs/{UploadController-C6Gt-YQA.js → UploadController-VM1qYwNq.js} +2 -2
- package/cjs/{WebhookPayload-DZadhbAJ.d.ts → WebhookPayload-DZWlnvcY.d.ts} +3 -2
- package/cjs/app.d.ts +5 -5
- package/cjs/app.js +2 -2
- package/cjs/elements.d.ts +4 -4
- package/cjs/elements.js +4 -4
- package/cjs/{index-DQUZYLVY.d.ts → index-Dl2qwS8L.d.ts} +2 -2
- package/cjs/index.d.ts +4 -4
- package/cjs/index.js +1 -1
- package/cjs/react-native.d.ts +2 -2
- package/cjs/react-native.js +4 -4
- package/cjs/react.d.ts +4 -4
- package/cjs/react.js +5 -5
- package/cjs/server.d.ts +5 -5
- package/cjs/server.js +2 -2
- package/cjs/testing.d.ts +46 -12
- package/cjs/testing.js +405 -88
- package/cjs/{ui-Ntkv4inL.js → ui-BCiLF8cU.js} +2 -2
- package/cjs/{ui-BGywTQ2M.d.ts → ui-BtmJC-f9.d.ts} +2 -2
- package/cjs/ui.d.ts +2 -2
- package/cjs/ui.js +3 -3
- package/cjs/vue.d.ts +5 -5
- package/cjs/vue.js +4 -4
- package/esm/{BrowserUpload-CRbCsX7a.d.ts → BrowserUpload-CeGsM9h1.d.ts} +2 -2
- package/esm/{BrowserUpload-CvUgnS8I.js → BrowserUpload-DB3WpaC1.js} +1 -1
- package/esm/{CalmLensAppClient-B3u6BlP5.d.ts → CalmLensAppClient-D-BD_Ny1.d.ts} +7 -1
- package/esm/{CalmLensAppClient-ktB4Vfbk.js → CalmLensAppClient-Dg-jPs4B.js} +3 -9
- package/esm/{CalmLensOptionKeys-DCO58tKr.js → CalmLensConnection-Di7K7Wnl.js} +661 -644
- package/esm/{CalmLensServerClient-B8ntjNL3.d.ts → CalmLensServerClient-BYN_N0lt.d.ts} +33 -2
- package/esm/{CalmLensServerClient-D02L8AUH.js → CalmLensServerClient-Pdp7TI8y.js} +58 -27
- package/esm/{CalmLensTypes-CtO4Dieu.d.ts → CalmLensTypes-C2blKgTu.d.ts} +51 -75
- package/esm/{Core-22KeL-HD.js → Core-CKk4teFu.js} +2 -2
- package/{cjs/Core-BJaLU71Q.d.ts → esm/Core-CNmoxDCW.d.ts} +2 -2
- package/esm/{ModerationContextLimits-BFfngsVu.js → ModerationContextLimits-xvxUjGfL.js} +24 -13
- package/esm/{ReactUpload-CFGawuk6.js → ReactUpload-DY5qQ70s.js} +1 -1
- package/esm/{ReactUpload-BGUkcMpg.d.ts → ReactUpload-kqEe6gcN.d.ts} +1 -1
- package/esm/{UploadController-CLEvEwzd.js → UploadController-wyor-5Z2.js} +2 -2
- package/esm/{WebhookPayload-DZadhbAJ.d.ts → WebhookPayload-DZWlnvcY.d.ts} +3 -2
- package/esm/app.d.ts +5 -5
- package/esm/app.js +2 -2
- package/esm/elements.d.ts +4 -4
- package/esm/elements.js +4 -4
- package/esm/{index-DQUZYLVY.d.ts → index-Dl2qwS8L.d.ts} +2 -2
- package/esm/index.d.ts +4 -4
- package/esm/index.js +1 -1
- package/esm/react-native.d.ts +2 -2
- package/esm/react-native.js +4 -4
- package/esm/react.d.ts +4 -4
- package/esm/react.js +5 -5
- package/esm/server.d.ts +5 -5
- package/esm/server.js +2 -2
- package/esm/testing.d.ts +46 -12
- package/esm/testing.js +398 -82
- package/esm/{ui-C9u03xc3.js → ui-BqF49fSy.js} +2 -2
- package/esm/{ui-BGywTQ2M.d.ts → ui-BtmJC-f9.d.ts} +2 -2
- package/esm/ui.d.ts +2 -2
- package/esm/ui.js +3 -3
- package/esm/vue.d.ts +5 -5
- package/esm/vue.js +4 -4
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { d as HashListEntry, u as HashList } from "./Classification-CMM2tZpJ-IdIh63n0.js";
|
|
2
|
-
import { $ as FolderPage,
|
|
3
|
-
import { d as ListPromise, l as CalmLensResponse, r as CdnResponse } from "./WebhookPayload-
|
|
2
|
+
import { $ as FolderPage, At as ResetPolicyOptions, B as CreateHashListOptions, D as BatchAssetsResponse, Dt as RequestAssetReviewOptions, E as BatchAssetsOptions, Et as RemoveAssetContentOptions, Ft as SetPolicyAutomaticUpdatesOptions, G as DeleteAssetOptions, Gt as UpdateLensOptions, Ht as UpdateAssetOptions, I as ClassifyTextOptions, In as AssetSearchQuery, It as SignAssetUrlOptions, J as EnsureLensesOptions, Jt as UpgradePolicyOptions, K as DeleteMetadataFieldOptions, Kt as UpdatePolicyOptions, Lt as SignUploadTokenOptions, M as CdnAssetUrlOptions, Mn as Policy, Mt as RetrieveAssetOptions, Nt as RetryAssetOptions, P as CdnServeOptions, Q as FolderIdOptions, Qt as UploadPresetPage, Rn as AssetInfo, Rt as SignedAssetUrl, T as AssignPolicyOptions, Tt as PolicyPage, U as CreatePolicyOptions, Ut as UpdateFolderOptions, V as CreateLensOptions, Vt as SubmitAssetOptions, W as DecideAssetOptions, Wt as UpdateHashListOptions, X as EnsureUploadPresetsOptions, Y as EnsureMetadataFieldsOptions, Yt as UploadAssetPartOptions, Z as EnsureUploadPresetsResponse, Zt as UploadPresetIdOptions, _ as AssetPage, _t as ListLensesOptions, b as AssetTimelinePage, bn as MetadataFieldsResource, bt as MoveAssetOptions, ct as LensIdOptions, dt as ListAssetTimelineOptions, et as GetAssetInfoOptions, ft as ListAssetsOptions, gt as ListHashListsOptions, ht as ListHashListEntriesOptions, it as HashListPage, jt as RetrieveAssetByExternalIdOptions, k as CalmLensServerClientOptions, kt as RequestOptions, ln as GetEventsResponse, lt as LensPage, mt as ListFoldersOptions, nt as HashListEntryPage, o as AssetChildrenPage, pt as ListEventsOptions, q as EnsureLensOptions, qt as UpdateProjectSettingsOptions, r as Asset, rn as WaitForAssetDecisionOptions, rt as HashListIdOptions, sn as AssetReviewRequest, st as Lens, t as AddHashListEntryOptions, tn as VerifyWebhookSignatureOptions, tt as HashListEntryIdOptions, ut as ListAssetChildrenOptions, v as AssetSearchResponse, vt as ListPoliciesOptions, wt as PolicyIdOptions, xn as ProjectSettingsResource, xt as MoveFolderOptions, yn as Folder, yt as ListUploadPresetsOptions, z as CreateFolderOptions, zt as SignedUploadToken } from "./CalmLensTypes-C2blKgTu.js";
|
|
3
|
+
import { d as ListPromise, l as CalmLensResponse, r as CdnResponse } from "./WebhookPayload-DZWlnvcY.js";
|
|
4
4
|
interface TransportRequest {
|
|
5
5
|
/** The client method sending the request, such as `assets.retrieve`, for hooks and logs. */
|
|
6
6
|
operation?: string;
|
|
@@ -21,6 +21,11 @@ interface TransportRequest {
|
|
|
21
21
|
signal?: AbortSignal;
|
|
22
22
|
/** Overrides the client's `maxRetries` for this request. */
|
|
23
23
|
maxRetries?: number;
|
|
24
|
+
/**
|
|
25
|
+
* When the call's deadline passes, on the transport's clock: no attempt starts after it, an
|
|
26
|
+
* attempt's own deadline never runs past it, and no retry waits up to it.
|
|
27
|
+
*/
|
|
28
|
+
deadlineAt?: number;
|
|
24
29
|
}
|
|
25
30
|
interface LensCache {
|
|
26
31
|
readonly ensuredLenses: Map<string, Lens>;
|
|
@@ -123,6 +128,12 @@ declare class CalmLensServerClient {
|
|
|
123
128
|
list: (options?: ListAssetsOptions, requestOptions?: RequestOptions) => ListPromise<AssetPage>;
|
|
124
129
|
/** Retrieves an asset with its status and classification results. */
|
|
125
130
|
retrieve: (options: RetrieveAssetOptions, requestOptions?: RequestOptions) => Promise<CalmLensResponse<Asset>>;
|
|
131
|
+
/**
|
|
132
|
+
* Retrieves the project's asset that has this `externalId`, such as the one an
|
|
133
|
+
* `asset/duplicate-external-id` error names. Rejects with `asset/not-found` when no asset
|
|
134
|
+
* has it.
|
|
135
|
+
*/
|
|
136
|
+
retrieveByExternalId: (options: RetrieveAssetByExternalIdOptions, requestOptions?: RequestOptions) => Promise<CalmLensResponse<Asset>>;
|
|
126
137
|
/** Updates an asset's editable fields. */
|
|
127
138
|
update: (options: UpdateAssetOptions, requestOptions?: RequestOptions) => Promise<CalmLensResponse<Asset>>;
|
|
128
139
|
/**
|
|
@@ -167,6 +178,16 @@ declare class CalmLensServerClient {
|
|
|
167
178
|
* needs `confirmPurge: true` and permanently deletes the stored content.
|
|
168
179
|
*/
|
|
169
180
|
decide: (options: DecideAssetOptions, requestOptions?: RequestOptions) => Promise<CalmLensResponse<Asset>>;
|
|
181
|
+
/**
|
|
182
|
+
* Sends an asset to the project's human review queue, such as when one of your app's users
|
|
183
|
+
* reports it, with an optional `note` reviewers see. It doesn't change how the asset is
|
|
184
|
+
* delivered: a reviewer's decision does. Resolves with the review: a new one (HTTP 201,
|
|
185
|
+
* reason `reported`, sending `asset.review-requested`), or the one already waiting for the
|
|
186
|
+
* asset (HTTP 200), unchanged. Rejects with `asset/not-reviewable` (`details.reason`:
|
|
187
|
+
* `child-asset`, `not-moderated` or `content-unavailable`) and `asset/held`. Retried safely
|
|
188
|
+
* with an `idempotencyKey` request option.
|
|
189
|
+
*/
|
|
190
|
+
requestReview: (options: RequestAssetReviewOptions, requestOptions?: RequestOptions) => Promise<CalmLensResponse<AssetReviewRequest>>;
|
|
170
191
|
/**
|
|
171
192
|
* Waits until an asset is settled, its `classification.status` `completed` (with its
|
|
172
193
|
* decision in `classification.moderation.decision`) or `failed`, and returns that asset,
|
|
@@ -219,6 +240,16 @@ declare class CalmLensServerClient {
|
|
|
219
240
|
* after `cursor`; save the last page's `nextCursor` to resume later.
|
|
220
241
|
*/
|
|
221
242
|
list: (options?: ListEventsOptions, requestOptions?: RequestOptions) => ListPromise<GetEventsResponse>;
|
|
243
|
+
/**
|
|
244
|
+
* Retrieves the asset an event is about, as it is now, such as one from `events.list` or a
|
|
245
|
+
* parsed webhook delivery; events carry only the asset's ID. Resolves to `null` for an
|
|
246
|
+
* event that isn't about an asset, and rejects with `asset/not-found` once the asset is
|
|
247
|
+
* deleted. The asset's `eventSequence` orders it against events: an event with a higher
|
|
248
|
+
* `assetSequence` happened after this state, one with an equal or lower one is reflected in it.
|
|
249
|
+
*/
|
|
250
|
+
retrieveAsset: (event: {
|
|
251
|
+
readonly assetId?: string | null;
|
|
252
|
+
}, requestOptions?: RequestOptions) => Promise<CalmLensResponse<Asset> | null>;
|
|
222
253
|
};
|
|
223
254
|
get folders(): {
|
|
224
255
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { B as copyLastResponse, C as toTextAssetOptions, D as validateServerClientOptions, E as validateBatchAssetsOptions, H as readEnv, L as isBrowserRuntime, Q as CalmLensError, R as isReactNativeRuntime, S as stringifyQuery, V as listPages, dt as invalidConfig, f as validateSignAssetUrlOptions, g as encodePathSegment, l as buildAssetUrl, lt as SDK_ERROR_CODES, m as checkOptionKeys, p as DEFAULT_CDN_BASE_URL, s as appendSignedLocation, u as getAssetInfo, ut as invalidArgument, y as pollForDecision } from "./ModerationContextLimits-
|
|
2
|
-
import {
|
|
1
|
+
import { B as copyLastResponse, C as toTextAssetOptions, D as validateServerClientOptions, E as validateBatchAssetsOptions, H as readEnv, L as isBrowserRuntime, Q as CalmLensError, R as isReactNativeRuntime, S as stringifyQuery, V as listPages, dt as invalidConfig, f as validateSignAssetUrlOptions, g as encodePathSegment, l as buildAssetUrl, lt as SDK_ERROR_CODES, m as checkOptionKeys, p as DEFAULT_CDN_BASE_URL, s as appendSignedLocation, u as getAssetInfo, ut as invalidArgument, y as pollForDecision } from "./ModerationContextLimits-xvxUjGfL.js";
|
|
2
|
+
import { a as getMockHooks, c as prepareSubmitAssetOptions, d as validateCallOptions, l as resolveConnectionOptions, m as SERVER_OPTION_KEYS, o as invalidPayload, p as NULLABLE_OPTION_KEYS, r as expectAsset, s as newIdempotencyKey, t as CalmLensConnection, u as splitsIntoParts } from "./CalmLensConnection-Di7K7Wnl.js";
|
|
3
3
|
import { n as sha256Hex, r as timingSafeEqual, t as hmacSha256Hex } from "./CryptoUtils-BLCa-oZe-DKr3LmN6.js";
|
|
4
4
|
// src/contract/JsonUtils.js
|
|
5
5
|
const stringifyJsonCanonical = (value) => JSON.stringify(value, (_key, nestedValue) => {
|
|
@@ -152,8 +152,8 @@ const isOptional = (value, type, nullable) => value === void 0 || nullable && va
|
|
|
152
152
|
*/
|
|
153
153
|
const isWebhookEvent = (value) => {
|
|
154
154
|
if (!isObject(value) || typeof value.id !== "string" || typeof value.type !== "string" || typeof value.projectId !== "string" || typeof value.createdAt !== "number") return false;
|
|
155
|
-
const { severity, title, description, assetId, assetSequence,
|
|
156
|
-
return isOptional(severity, "string", false) && isOptional(title, "string", false) && isOptional(description, "string", true) && isOptional(assetId, "string", true) && isOptional(assetSequence, "number", true) && (
|
|
155
|
+
const { severity, title, description, assetId, assetSequence, facts } = value;
|
|
156
|
+
return isOptional(severity, "string", false) && isOptional(title, "string", false) && isOptional(description, "string", true) && isOptional(assetId, "string", true) && isOptional(assetSequence, "number", true) && (facts === void 0 || Array.isArray(facts) && facts.every((fact) => isObject(fact) && typeof fact.key === "string" && "value" in fact && isOptional(fact.url, "string", false)));
|
|
157
157
|
};
|
|
158
158
|
/**
|
|
159
159
|
* The value of one of an event's facts, by key, or `undefined` when the event doesn't carry it.
|
|
@@ -396,13 +396,10 @@ var CalmLensServerClient = class {
|
|
|
396
396
|
partSizeBytes: connection.partSizeBytes
|
|
397
397
|
});
|
|
398
398
|
const uploadsPath = `${this.#projectPath}/assets`;
|
|
399
|
-
if ("content" in body && splitsIntoParts(body.content, connection.partSizeBytes)) {
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
retrieve: (assetId) => this.#buildAssets().retrieve({ assetId }, readOptions)
|
|
404
|
-
}));
|
|
405
|
-
}
|
|
399
|
+
if ("content" in body && splitsIntoParts(body.content, connection.partSizeBytes)) return expectAsset(await connection.submitInParts(uploadsPath, body, wait, {
|
|
400
|
+
partPath: (assetId) => `/assets/${encodeURIComponent(assetId)}/part`,
|
|
401
|
+
retrieve: (assetId, read) => read.json("GET", `/assets/${requireId(assetId, "Asset ID")}`)
|
|
402
|
+
}));
|
|
406
403
|
if ("content" in body || "part" in body) return expectAsset(await connection.submitUpload(uploadsPath, body, wait));
|
|
407
404
|
const { idempotencyKey, ...fields } = body;
|
|
408
405
|
const data = await connection.json("POST", uploadsPath, {
|
|
@@ -526,6 +523,15 @@ sign: async (options) => {
|
|
|
526
523
|
const { assetId } = checked("assets.retrieve", options);
|
|
527
524
|
return this.#send("assets.retrieve", requestOptions, "GET", `/assets/${requireId(assetId, "Asset ID")}`);
|
|
528
525
|
},
|
|
526
|
+
/**
|
|
527
|
+
* Retrieves the project's asset that has this `externalId`, such as the one an
|
|
528
|
+
* `asset/duplicate-external-id` error names. Rejects with `asset/not-found` when no asset
|
|
529
|
+
* has it.
|
|
530
|
+
*/
|
|
531
|
+
retrieveByExternalId: async (options, requestOptions) => {
|
|
532
|
+
const { externalId } = checked("assets.retrieveByExternalId", options);
|
|
533
|
+
return this.#send("assets.retrieveByExternalId", requestOptions, "GET", `${this.#projectPath}/assets/by-external-id/${requireId(externalId, "External ID")}`);
|
|
534
|
+
},
|
|
529
535
|
/** Updates an asset's editable fields. */
|
|
530
536
|
update: async (options, requestOptions) => {
|
|
531
537
|
const { assetId, ...body } = checked("assets.update", options);
|
|
@@ -591,6 +597,19 @@ sign: async (options) => {
|
|
|
591
597
|
return this.#send("assets.decide", requestOptions, "POST", `/assets/${requireId(assetId, "Asset ID")}/decision`, { body });
|
|
592
598
|
},
|
|
593
599
|
/**
|
|
600
|
+
* Sends an asset to the project's human review queue, such as when one of your app's users
|
|
601
|
+
* reports it, with an optional `note` reviewers see. It doesn't change how the asset is
|
|
602
|
+
* delivered: a reviewer's decision does. Resolves with the review: a new one (HTTP 201,
|
|
603
|
+
* reason `reported`, sending `asset.review-requested`), or the one already waiting for the
|
|
604
|
+
* asset (HTTP 200), unchanged. Rejects with `asset/not-reviewable` (`details.reason`:
|
|
605
|
+
* `child-asset`, `not-moderated` or `content-unavailable`) and `asset/held`. Retried safely
|
|
606
|
+
* with an `idempotencyKey` request option.
|
|
607
|
+
*/
|
|
608
|
+
requestReview: async (options, requestOptions) => {
|
|
609
|
+
const { assetId, ...body } = checked("assets.requestReview", options);
|
|
610
|
+
return this.#send("assets.requestReview", requestOptions, "POST", `/assets/${requireId(assetId, "Asset ID")}/review-requests`, { body });
|
|
611
|
+
},
|
|
612
|
+
/**
|
|
594
613
|
* Waits until an asset is settled, its `classification.status` `completed` (with its
|
|
595
614
|
* decision in `classification.moderation.decision`) or `failed`, and returns that asset,
|
|
596
615
|
* checking every few seconds. A `queued` or `processing` asset is still waiting, even when a
|
|
@@ -603,11 +622,14 @@ sign: async (options) => {
|
|
|
603
622
|
validateCallOptions(requestOptions);
|
|
604
623
|
const signals = [options.signal, requestOptions?.signal].filter((signal) => signal !== void 0);
|
|
605
624
|
const signal = signals.length > 1 ? anySignal(signals) : signals[0];
|
|
606
|
-
const
|
|
625
|
+
const connection = this.#connection.forCall("assets.waitForDecision", {
|
|
607
626
|
...requestOptions,
|
|
608
627
|
...signal && { signal }
|
|
609
|
-
};
|
|
610
|
-
return pollForDecision(() =>
|
|
628
|
+
});
|
|
629
|
+
return pollForDecision(() => connection.json("GET", `/assets/${requireId(assetId, "Asset ID")}`), {
|
|
630
|
+
...options,
|
|
631
|
+
deadlineAt: connection.call.deadlineAt
|
|
632
|
+
}, connection.sleep, connection.now);
|
|
611
633
|
},
|
|
612
634
|
/**
|
|
613
635
|
* Removes an asset's stored content (source, preview and retained extracted text) while
|
|
@@ -650,19 +672,28 @@ sign: async (options) => {
|
|
|
650
672
|
};
|
|
651
673
|
}
|
|
652
674
|
get events() {
|
|
653
|
-
return {
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
list: (options = {}, requestOptions) => this.#paginate("events.list", options, requestOptions, ({ types, ...query }) => this.#send("events.list", requestOptions, "GET", `${this.#projectPath}/events`, { query: {
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
675
|
+
return {
|
|
676
|
+
/**
|
|
677
|
+
* Lists project events after a cursor, oldest first. Call without `cursor` to get a cursor
|
|
678
|
+
* for "now", then poll with each response's `nextCursor`. Webhook deliveries carry each
|
|
679
|
+
* event's same fields as a flat JSON body. `types` and `assetId` narrow the feed to some
|
|
680
|
+
* event types or one asset's events; a cursor belongs to the filters it was issued with, so
|
|
681
|
+
* pass the same ones with each `cursor`. `for await` over it yields every event waiting
|
|
682
|
+
* after `cursor`; save the last page's `nextCursor` to resume later.
|
|
683
|
+
*/
|
|
684
|
+
list: (options = {}, requestOptions) => this.#paginate("events.list", options, requestOptions, ({ types, ...query }) => this.#send("events.list", requestOptions, "GET", `${this.#projectPath}/events`, { query: {
|
|
685
|
+
...query,
|
|
686
|
+
types: types?.length ? types.join(",") : void 0
|
|
687
|
+
} })),
|
|
688
|
+
/**
|
|
689
|
+
* Retrieves the asset an event is about, as it is now, such as one from `events.list` or a
|
|
690
|
+
* parsed webhook delivery; events carry only the asset's ID. Resolves to `null` for an
|
|
691
|
+
* event that isn't about an asset, and rejects with `asset/not-found` once the asset is
|
|
692
|
+
* deleted. The asset's `eventSequence` orders it against events: an event with a higher
|
|
693
|
+
* `assetSequence` happened after this state, one with an equal or lower one is reflected in it.
|
|
694
|
+
*/
|
|
695
|
+
retrieveAsset: async (event, requestOptions) => event.assetId ? this.assets.retrieve({ assetId: event.assetId }, requestOptions) : null
|
|
696
|
+
};
|
|
666
697
|
}
|
|
667
698
|
get folders() {
|
|
668
699
|
return {
|
|
@@ -263,6 +263,7 @@ declare const ASSET_MODERATION_SCHEMA: zod.ZodObject<{
|
|
|
263
263
|
pendingReview: zod.ZodNullable<zod.ZodObject<{
|
|
264
264
|
requestedAt: zod.ZodNumber;
|
|
265
265
|
reason: zod.ZodEnum<{
|
|
266
|
+
reported: "reported";
|
|
266
267
|
sampled: "sampled";
|
|
267
268
|
uncertain: "uncertain";
|
|
268
269
|
}>;
|
|
@@ -5088,6 +5089,7 @@ declare const ASSET_CLASSIFICATION_SCHEMA: zod.ZodObject<{
|
|
|
5088
5089
|
pendingReview: zod.ZodNullable<zod.ZodObject<{
|
|
5089
5090
|
requestedAt: zod.ZodNumber;
|
|
5090
5091
|
reason: zod.ZodEnum<{
|
|
5092
|
+
reported: "reported";
|
|
5091
5093
|
sampled: "sampled";
|
|
5092
5094
|
uncertain: "uncertain";
|
|
5093
5095
|
}>;
|
|
@@ -10211,6 +10213,7 @@ declare const ASSET_SCHEMA: zod.ZodObject<{
|
|
|
10211
10213
|
pendingReview: zod.ZodNullable<zod.ZodObject<{
|
|
10212
10214
|
requestedAt: zod.ZodNumber;
|
|
10213
10215
|
reason: zod.ZodEnum<{
|
|
10216
|
+
reported: "reported";
|
|
10214
10217
|
sampled: "sampled";
|
|
10215
10218
|
uncertain: "uncertain";
|
|
10216
10219
|
}>;
|
|
@@ -15199,6 +15202,7 @@ declare const ASSET_SCHEMA: zod.ZodObject<{
|
|
|
15199
15202
|
averageColor: zod.ZodNullable<zod.ZodPipe<zod.ZodString, zod.ZodTransform<string, string>>>;
|
|
15200
15203
|
}, zod.core.$strip>>;
|
|
15201
15204
|
}, zod.core.$strip>;
|
|
15205
|
+
eventSequence: zod.ZodNumber;
|
|
15202
15206
|
}, zod.core.$strip>;
|
|
15203
15207
|
type Asset$1 = zod.infer<typeof ASSET_SCHEMA>;
|
|
15204
15208
|
/**
|
|
@@ -15467,6 +15471,7 @@ declare const ASSET_SEARCH_RESULT_SCHEMA: zod.ZodObject<{
|
|
|
15467
15471
|
pendingReview: zod.ZodNullable<zod.ZodObject<{
|
|
15468
15472
|
requestedAt: zod.ZodNumber;
|
|
15469
15473
|
reason: zod.ZodEnum<{
|
|
15474
|
+
reported: "reported";
|
|
15470
15475
|
sampled: "sampled";
|
|
15471
15476
|
uncertain: "uncertain";
|
|
15472
15477
|
}>;
|
|
@@ -20455,6 +20460,7 @@ declare const ASSET_SEARCH_RESULT_SCHEMA: zod.ZodObject<{
|
|
|
20455
20460
|
averageColor: zod.ZodNullable<zod.ZodPipe<zod.ZodString, zod.ZodTransform<string, string>>>;
|
|
20456
20461
|
}, zod.core.$strip>>;
|
|
20457
20462
|
}, zod.core.$strip>;
|
|
20463
|
+
eventSequence: zod.ZodNumber;
|
|
20458
20464
|
}, zod.core.$strip>;
|
|
20459
20465
|
score: zod.ZodNumber;
|
|
20460
20466
|
matchedFields: zod.ZodArray<zod.ZodEnum<{
|
|
@@ -36808,6 +36814,7 @@ declare const EVENT_TYPE_INFO: {
|
|
|
36808
36814
|
website: "website";
|
|
36809
36815
|
}>>>>;
|
|
36810
36816
|
parentAsset: EventFieldDefinition<zod.ZodOptional<zod.ZodString>>;
|
|
36817
|
+
reviewId: EventFieldDefinition<zod.ZodString>;
|
|
36811
36818
|
automatedStatus: EventFieldDefinition<zod.ZodEnum<{
|
|
36812
36819
|
"age-restricted": "age-restricted";
|
|
36813
36820
|
allowed: "allowed";
|
|
@@ -36815,6 +36822,7 @@ declare const EVENT_TYPE_INFO: {
|
|
|
36815
36822
|
limited: "limited";
|
|
36816
36823
|
}>>;
|
|
36817
36824
|
reviewReason: EventFieldDefinition<zod.ZodEnum<{
|
|
36825
|
+
reported: "reported";
|
|
36818
36826
|
sampled: "sampled";
|
|
36819
36827
|
uncertain: "uncertain";
|
|
36820
36828
|
}>>;
|
|
@@ -36828,15 +36836,18 @@ declare const EVENT_TYPE_INFO: {
|
|
|
36828
36836
|
sexual: "sexual";
|
|
36829
36837
|
violence: "violence";
|
|
36830
36838
|
}>>>;
|
|
36839
|
+
note: EventFieldDefinition<zod.ZodOptional<zod.ZodString>>;
|
|
36831
36840
|
};
|
|
36832
36841
|
/** Example data, used for synthetic test sends (`createSampleEvent`). */
|
|
36833
36842
|
example: NoInfer<{
|
|
36834
36843
|
assetName?: string | null | undefined;
|
|
36835
36844
|
assetType?: "audio" | "file" | "image" | "multimedia-document" | "plaintext-document" | "video" | "website" | null | undefined;
|
|
36836
36845
|
parentAsset?: string | undefined;
|
|
36846
|
+
reviewId: string;
|
|
36837
36847
|
automatedStatus: "age-restricted" | "allowed" | "blocked" | "limited";
|
|
36838
|
-
reviewReason: "sampled" | "uncertain";
|
|
36848
|
+
reviewReason: "reported" | "sampled" | "uncertain";
|
|
36839
36849
|
uncertainCategories: ("criminal-activity" | "harassment" | "hate" | "personal-information" | "profanity" | "self-harm" | "sexual" | "violence")[];
|
|
36850
|
+
note?: string | undefined;
|
|
36840
36851
|
}>;
|
|
36841
36852
|
factInfo: {
|
|
36842
36853
|
label: string;
|
|
@@ -36871,6 +36882,7 @@ declare const EVENT_TYPE_INFO: {
|
|
|
36871
36882
|
website: "website";
|
|
36872
36883
|
}>>>;
|
|
36873
36884
|
parentAsset: zod.ZodOptional<zod.ZodString>;
|
|
36885
|
+
reviewId: zod.ZodString;
|
|
36874
36886
|
automatedStatus: zod.ZodEnum<{
|
|
36875
36887
|
"age-restricted": "age-restricted";
|
|
36876
36888
|
allowed: "allowed";
|
|
@@ -36878,6 +36890,7 @@ declare const EVENT_TYPE_INFO: {
|
|
|
36878
36890
|
limited: "limited";
|
|
36879
36891
|
}>;
|
|
36880
36892
|
reviewReason: zod.ZodEnum<{
|
|
36893
|
+
reported: "reported";
|
|
36881
36894
|
sampled: "sampled";
|
|
36882
36895
|
uncertain: "uncertain";
|
|
36883
36896
|
}>;
|
|
@@ -36891,6 +36904,7 @@ declare const EVENT_TYPE_INFO: {
|
|
|
36891
36904
|
sexual: "sexual";
|
|
36892
36905
|
violence: "violence";
|
|
36893
36906
|
}>>;
|
|
36907
|
+
note: zod.ZodOptional<zod.ZodString>;
|
|
36894
36908
|
}, zod.core.$strip>;
|
|
36895
36909
|
};
|
|
36896
36910
|
readonly "asset.review-completed": {
|
|
@@ -38176,43 +38190,6 @@ declare const ACTOR_SCHEMA: zod.ZodObject<{
|
|
|
38176
38190
|
id: zod.ZodNullable<zod.ZodString>;
|
|
38177
38191
|
}, zod.core.$strict>;
|
|
38178
38192
|
type Actor = zod.infer<typeof ACTOR_SCHEMA>;
|
|
38179
|
-
declare const EVENT_ASSET_SCHEMA: zod.ZodObject<{
|
|
38180
|
-
id: zod.ZodString;
|
|
38181
|
-
externalId: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
|
|
38182
|
-
uploadPresetId: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
|
|
38183
|
-
upload: zod.ZodObject<{
|
|
38184
|
-
status: zod.ZodEnum<{
|
|
38185
|
-
completed: "completed";
|
|
38186
|
-
uploading: "uploading";
|
|
38187
|
-
}>;
|
|
38188
|
-
}, zod.core.$strip>;
|
|
38189
|
-
classification: zod.ZodObject<{
|
|
38190
|
-
status: zod.ZodEnum<{
|
|
38191
|
-
completed: "completed";
|
|
38192
|
-
failed: "failed";
|
|
38193
|
-
processing: "processing";
|
|
38194
|
-
queued: "queued";
|
|
38195
|
-
}>;
|
|
38196
|
-
testInput: zod.ZodBoolean;
|
|
38197
|
-
moderation: zod.ZodObject<{
|
|
38198
|
-
decision: zod.ZodNullable<zod.ZodEnum<{
|
|
38199
|
-
"age-restricted": "age-restricted";
|
|
38200
|
-
allowed: "allowed";
|
|
38201
|
-
blocked: "blocked";
|
|
38202
|
-
limited: "limited";
|
|
38203
|
-
purged: "purged";
|
|
38204
|
-
}>>;
|
|
38205
|
-
}, zod.core.$strip>;
|
|
38206
|
-
}, zod.core.$strip>;
|
|
38207
|
-
content: zod.ZodObject<{
|
|
38208
|
-
status: zod.ZodEnum<{
|
|
38209
|
-
removed: "removed";
|
|
38210
|
-
stored: "stored";
|
|
38211
|
-
temporary: "temporary";
|
|
38212
|
-
}>;
|
|
38213
|
-
}, zod.core.$strip>;
|
|
38214
|
-
}, zod.core.$strip>;
|
|
38215
|
-
type EventAsset = zod.infer<typeof EVENT_ASSET_SCHEMA>;
|
|
38216
38193
|
/** An event as `GET /events` lists it and webhooks deliver it. */
|
|
38217
38194
|
declare const PUBLIC_EVENT_SCHEMA: zod.ZodObject<{
|
|
38218
38195
|
id: zod.ZodString;
|
|
@@ -38269,42 +38246,6 @@ declare const PUBLIC_EVENT_SCHEMA: zod.ZodObject<{
|
|
|
38269
38246
|
description: zod.ZodOptional<zod.ZodNullable<zod.ZodPipe<zod.ZodString, zod.ZodTransform<string, string>>>>;
|
|
38270
38247
|
assetId: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
|
|
38271
38248
|
assetSequence: zod.ZodOptional<zod.ZodNullable<zod.ZodNumber>>;
|
|
38272
|
-
asset: zod.ZodOptional<zod.ZodNullable<zod.ZodObject<{
|
|
38273
|
-
id: zod.ZodString;
|
|
38274
|
-
externalId: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
|
|
38275
|
-
uploadPresetId: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
|
|
38276
|
-
upload: zod.ZodObject<{
|
|
38277
|
-
status: zod.ZodEnum<{
|
|
38278
|
-
completed: "completed";
|
|
38279
|
-
uploading: "uploading";
|
|
38280
|
-
}>;
|
|
38281
|
-
}, zod.core.$strip>;
|
|
38282
|
-
classification: zod.ZodObject<{
|
|
38283
|
-
status: zod.ZodEnum<{
|
|
38284
|
-
completed: "completed";
|
|
38285
|
-
failed: "failed";
|
|
38286
|
-
processing: "processing";
|
|
38287
|
-
queued: "queued";
|
|
38288
|
-
}>;
|
|
38289
|
-
testInput: zod.ZodBoolean;
|
|
38290
|
-
moderation: zod.ZodObject<{
|
|
38291
|
-
decision: zod.ZodNullable<zod.ZodEnum<{
|
|
38292
|
-
"age-restricted": "age-restricted";
|
|
38293
|
-
allowed: "allowed";
|
|
38294
|
-
blocked: "blocked";
|
|
38295
|
-
limited: "limited";
|
|
38296
|
-
purged: "purged";
|
|
38297
|
-
}>>;
|
|
38298
|
-
}, zod.core.$strip>;
|
|
38299
|
-
}, zod.core.$strip>;
|
|
38300
|
-
content: zod.ZodObject<{
|
|
38301
|
-
status: zod.ZodEnum<{
|
|
38302
|
-
removed: "removed";
|
|
38303
|
-
stored: "stored";
|
|
38304
|
-
temporary: "temporary";
|
|
38305
|
-
}>;
|
|
38306
|
-
}, zod.core.$strip>;
|
|
38307
|
-
}, zod.core.$strip>>>;
|
|
38308
38249
|
facts: zod.ZodArray<zod.ZodObject<{
|
|
38309
38250
|
key: zod.ZodString;
|
|
38310
38251
|
value: zod.ZodUnknown & zod.ZodType<{} | null, unknown, zod.core.$ZodTypeInternals<{} | null, unknown>>;
|
|
@@ -42416,6 +42357,26 @@ declare const POST_ASSET_DECISION_BODY_SCHEMA: zod.ZodDiscriminatedUnion<[zod.Zo
|
|
|
42416
42357
|
confirmPurge: zod.ZodLiteral<true>;
|
|
42417
42358
|
}, zod.core.$strip>], "decision">;
|
|
42418
42359
|
type PostAssetDecisionBody = zod.infer<typeof POST_ASSET_DECISION_BODY_SCHEMA>;
|
|
42360
|
+
declare const POST_ASSET_REVIEW_REQUEST_BODY_SCHEMA: zod.ZodObject<{
|
|
42361
|
+
note: zod.ZodOptional<zod.ZodString>;
|
|
42362
|
+
}, zod.core.$strip>;
|
|
42363
|
+
type PostAssetReviewRequestBody = zod.infer<typeof POST_ASSET_REVIEW_REQUEST_BODY_SCHEMA>;
|
|
42364
|
+
declare const ASSET_REVIEW_REQUEST_SCHEMA: zod.ZodObject<{
|
|
42365
|
+
id: zod.ZodString;
|
|
42366
|
+
assetId: zod.ZodString;
|
|
42367
|
+
reason: zod.ZodEnum<{
|
|
42368
|
+
reported: "reported";
|
|
42369
|
+
sampled: "sampled";
|
|
42370
|
+
uncertain: "uncertain";
|
|
42371
|
+
}>;
|
|
42372
|
+
status: zod.ZodEnum<{
|
|
42373
|
+
completed: "completed";
|
|
42374
|
+
pending: "pending";
|
|
42375
|
+
}>;
|
|
42376
|
+
note: zod.ZodNullable<zod.ZodString>;
|
|
42377
|
+
createdAt: zod.ZodNumber;
|
|
42378
|
+
}, zod.core.$strip>;
|
|
42379
|
+
type AssetReviewRequest = zod.infer<typeof ASSET_REVIEW_REQUEST_SCHEMA>;
|
|
42419
42380
|
declare const ASSET_BATCH_OPERATIONS: readonly ["delete", "remove-content"];
|
|
42420
42381
|
type AssetBatchOperation = (typeof ASSET_BATCH_OPERATIONS)[number];
|
|
42421
42382
|
declare const POST_ASSET_BATCH_OPERATION_RESPONSE_SCHEMA: zod.ZodObject<{
|
|
@@ -42734,6 +42695,13 @@ interface RequestOptions {
|
|
|
42734
42695
|
signal?: AbortSignal;
|
|
42735
42696
|
/** Deadline in milliseconds for each attempt of this call's requests. */
|
|
42736
42697
|
timeoutMs?: number;
|
|
42698
|
+
/**
|
|
42699
|
+
* Deadline in milliseconds for the whole call: every attempt, the waits between retries
|
|
42700
|
+
* (`Retry-After` included) and `assets.waitForDecision`'s polling. When it passes, the call
|
|
42701
|
+
* rejects with `sdk/timeout` and makes no further attempt; a retry whose wait would reach it
|
|
42702
|
+
* isn't made, and the last attempt's error is thrown. A list call's deadline covers each page.
|
|
42703
|
+
*/
|
|
42704
|
+
deadlineMs?: number;
|
|
42737
42705
|
/** How many times to retry this call's requests; 0 turns retries off. */
|
|
42738
42706
|
maxRetries?: number;
|
|
42739
42707
|
/**
|
|
@@ -43016,6 +42984,14 @@ type ListEventsOptions = GetEventsQuery;
|
|
|
43016
42984
|
interface RetrieveAssetOptions {
|
|
43017
42985
|
assetId: string;
|
|
43018
42986
|
}
|
|
42987
|
+
interface RetrieveAssetByExternalIdOptions {
|
|
42988
|
+
/** The `externalId` the asset was uploaded or updated with. */
|
|
42989
|
+
externalId: string;
|
|
42990
|
+
}
|
|
42991
|
+
/** Options for `assets.requestReview`: the asset, and an optional note reviewers see. */
|
|
42992
|
+
type RequestAssetReviewOptions = {
|
|
42993
|
+
assetId: string;
|
|
42994
|
+
} & PostAssetReviewRequestBody;
|
|
43019
42995
|
interface RetryAssetOptions {
|
|
43020
42996
|
assetId: string;
|
|
43021
42997
|
}
|
|
@@ -43243,4 +43219,4 @@ interface ClassifyTextOptions extends Omit<SubmitAssetCommonOptions, "name" | "i
|
|
|
43243
43219
|
/** `folders.list` options. `sort` is `name` (the default) or `createdAt`, descending when prefixed with `-`. */
|
|
43244
43220
|
type ListFoldersOptions = GetFoldersQuery;
|
|
43245
43221
|
type FolderPage = GetFoldersResponse;
|
|
43246
|
-
export { FolderPage as $,
|
|
43222
|
+
export { FolderPage as $, UploadPresetSubmitAssetOptions as $t, CdnAssetLocation as A, ProcessingFeatureStage as An, ResetPolicyOptions as At, CreateHashListOptions as B, AssetHlsRendition as Bn, StreamingFeatureOptions as Bt, AssetUploadStatus as C, UploadPreset as Cn, MultipartUploadPartOptions as Ct, BatchAssetsResponse as D, DetectedPerson as Dn, RequestAssetReviewOptions as Dt, BatchAssetsOptions as E, DetectedFace as En, RemoveAssetContentOptions as Et, CdnTransform as F, AssetSearchMatchField as Fn, SetPolicyAutomaticUpdatesOptions as Ft, DeleteAssetOptions as G, AssetSafetyHoldReason as Gn, UpdateLensOptions as Gt, CreateMultipartUploadPartOptions as H, AssetRendered as Hn, UpdateAssetOptions as Ht, ClassifyTextOptions as I, AssetSearchQuery as In, SignAssetUrlOptions as It, EnsureLensesOptions as J, MetadataItem as Jn, UpgradePolicyOptions as Jt, DeleteMetadataFieldOptions as K, ExtractedText as Kn, UpdatePolicyOptions as Kt, ClientRequestDefaults as L, AssetBinaryPayloadInput as Ln, SignUploadTokenOptions as Lt, CdnAssetUrlOptions as M, Policy as Mn, RetrieveAssetOptions as Mt, CdnResource as N, CursorPage as Nn, RetryAssetOptions as Nt, CalmLensAppClientOptions as O, ProcessingFeatureId as On, RequestAttempt as Ot, CdnServeOptions as P, LensType as Pn, SearchAssetsOptions as Pt, FolderIdOptions as Q, UploadPresetPage as Qt, ConnectionOptions as R, AssetInfo as Rn, SignedAssetUrl as Rt, AssetUpload as S, PublicProjectSettings as Sn, MultipartUploadOptions as St, AssignPolicyOptions as T, BoundingBox as Tn, PolicyPage as Tt, CreatePolicyOptions as U, AssetRenderedKind as Un, UpdateFolderOptions as Ut, CreateLensOptions as V, AssetPreview as Vn, SubmitAssetOptions as Vt, DecideAssetOptions as W, AssetSafetyHold as Wn, UpdateHashListOptions as Wt, EnsureUploadPresetsOptions as X, UploadPresetDefinition as Xt, EnsureMetadataFieldsOptions as Y, ProcessingOptions as Yn, UploadAssetPartOptions as Yt, EnsureUploadPresetsResponse as Z, UploadPresetIdOptions as Zt, AssetPage as _, EventType as _n, ListLensesOptions as _t, AssetChecksums as a, WebhookPayloadInput as an, IdempotencyOptions as at, AssetTimelinePage as b, MetadataFieldsResource as bn, MoveAssetOptions as bt, AssetClassificationFailureReason as c, AssetTimelineSegment as cn, LensIdOptions as ct, AssetContentOptions as d, TypedEvent as dn, ListAssetTimelineOptions as dt, UploadedAsset as en, GetAssetInfoOptions as et, AssetContentRemovalReason as f, EventCategory as fn, ListAssetsOptions as ft, AssetModerationStatus as g, EventSeverity as gn, ListHashListsOptions as gt, AssetModerationDecision as h, EventFacts as hn, ListHashListEntriesOptions as ht, AssetAvailability as i, WebhookHeadersInput as in, HashListPage as it, CdnAssetReference as j, ProcessingFeatures as jn, RetrieveAssetByExternalIdOptions as jt, CalmLensServerClientOptions as k, ProcessingFeatureResults as kn, RequestOptions as kt, AssetClassificationStatus as l, GetEventsResponse as ln, LensPage as lt, AssetModeration as m, EventFactValues as mn, ListFoldersOptions as mt, AppInfo as n, ViewerClaims as nn, HashListEntryPage as nt, AssetChildrenPage as o, AssetBatchOperation as on, ImageTransformOptions as ot, AssetContentStatus as p, EventFact as pn, ListEventsOptions as pt, EnsureLensOptions as q, FileMetadata as qn, UpdateProjectSettingsOptions as qt, Asset as r, WaitForAssetDecisionOptions as rn, HashListIdOptions as rt, AssetClassification as s, AssetReviewRequest as sn, Lens as st, AddHashListEntryOptions as t, VerifyWebhookSignatureOptions as tn, HashListEntryIdOptions as tt, AssetContent as u, Actor as un, ListAssetChildrenOptions as ut, AssetSearchResponse as v, PermissionGrant as vn, ListPoliciesOptions as vt, AssetVisibility as w, AgeRange as wn, PolicyIdOptions as wt, AssetType as x, ProjectSettingsResource as xn, MoveFolderOptions as xt, AssetSearchResult as y, Folder as yn, ListUploadPresetsOptions as yt, CreateFolderOptions as z, AssetHls as zn, SignedUploadToken as zt };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Q as CalmLensError, c as assetUrlOf, d as toUrlViewerClaims, o as appendAssetLocation, u as getAssetInfo, w as transformSelector, x as serializeTransform } from "./ModerationContextLimits-
|
|
2
|
-
import { o as placeholderHashToDataURL } from "./UploadController-
|
|
1
|
+
import { Q as CalmLensError, c as assetUrlOf, d as toUrlViewerClaims, o as appendAssetLocation, u as getAssetInfo, w as transformSelector, x as serializeTransform } from "./ModerationContextLimits-xvxUjGfL.js";
|
|
2
|
+
import { o as placeholderHashToDataURL } from "./UploadController-wyor-5Z2.js";
|
|
3
3
|
import { a as getFileIcon, c as renderFileIconSvg } from "./FileIcons-M6dzjFxd.js";
|
|
4
4
|
// src/ui/viewers/ViewerAsset.ts
|
|
5
5
|
/** Spreadsheet MIME types, as `content.format` reports them (compared lower-cased). */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as CdnTransform, O as CalmLensAppClientOptions,
|
|
2
|
-
import { t as CalmLensAppClient } from "./CalmLensAppClient-
|
|
1
|
+
import { F as CdnTransform, O as CalmLensAppClientOptions, g as AssetModerationStatus, i as AssetAvailability, nn as ViewerClaims } from "./CalmLensTypes-C2blKgTu.js";
|
|
2
|
+
import { t as CalmLensAppClient } from "./CalmLensAppClient-D-BD_Ny1.js";
|
|
3
3
|
import { o as UploadFileIconFamily } from "./FileIcons-4qSX7DW2.js";
|
|
4
4
|
/**
|
|
5
5
|
* The text the asset viewers show, keyed by name. `{name}` placeholders are filled in when shown.
|
|
@@ -67,6 +67,7 @@ const API_ERROR_CODES = {
|
|
|
67
67
|
ASSET_NOT_RETRYABLE: "asset/not-retryable",
|
|
68
68
|
ASSET_CONTENT_UNAVAILABLE: "asset/content-unavailable",
|
|
69
69
|
ASSET_CONTENT_PURGED: "asset/content-purged",
|
|
70
|
+
ASSET_NOT_REVIEWABLE: "asset/not-reviewable",
|
|
70
71
|
SUPPORT_TICKET_NOT_FOUND: "support-ticket/not-found",
|
|
71
72
|
DUPLICATE_EXTERNAL_ID: "asset/duplicate-external-id",
|
|
72
73
|
FOLDER_NOT_FOUND: "folder/not-found",
|
|
@@ -387,6 +388,10 @@ const API_ERROR_DEFINITIONS = {
|
|
|
387
388
|
status: 409,
|
|
388
389
|
message: "This asset's content was purged, so it can only be blocked. Upload it again to have it moderated afresh."
|
|
389
390
|
},
|
|
391
|
+
"asset/not-reviewable": {
|
|
392
|
+
status: 409,
|
|
393
|
+
message: "The human review queue can't take this asset. details.reason is `child-asset` for content extracted from another asset (report the uploaded asset instead), `not-moderated` while it has no moderation decision yet, or `content-unavailable` when its content is no longer stored."
|
|
394
|
+
},
|
|
390
395
|
"support-ticket/not-found": {
|
|
391
396
|
status: 404,
|
|
392
397
|
message: "Support ticket not found."
|
|
@@ -1062,7 +1067,7 @@ const listPages = (fetchPage, { cursor, feed = false } = {}) => {
|
|
|
1062
1067
|
};
|
|
1063
1068
|
// src/client/CalmLensVersion.ts
|
|
1064
1069
|
/** This SDK's version, from its package.json. */
|
|
1065
|
-
const SDK_VERSION = "0.
|
|
1070
|
+
const SDK_VERSION = "0.29.1";
|
|
1066
1071
|
const runtimeName = () => {
|
|
1067
1072
|
const runtime = globalThis;
|
|
1068
1073
|
if (isReactNativeRuntime()) return "react-native";
|
|
@@ -1321,9 +1326,13 @@ var CalmLensTransport = class {
|
|
|
1321
1326
|
const headers = this.headersFor(request);
|
|
1322
1327
|
const now = this.settings.now ?? Date.now;
|
|
1323
1328
|
const path = pathOf(request.url);
|
|
1329
|
+
const { deadlineAt } = request;
|
|
1330
|
+
const startsInTime = (delayMs) => deadlineAt === void 0 || now() + delayMs < deadlineAt;
|
|
1324
1331
|
for (let attemptNumber = 0;; attemptNumber++) {
|
|
1325
1332
|
const canRetryAgain = retryable && attemptNumber < this.maxRetriesFor(request);
|
|
1326
|
-
const
|
|
1333
|
+
const remainingMs = deadlineAt === void 0 ? void 0 : deadlineAt - now();
|
|
1334
|
+
if (remainingMs !== void 0 && remainingMs <= 0) throw new CalmLensError(SDK_ERROR_CODES.TIMEOUT, { message: "The call's deadline passed" });
|
|
1335
|
+
const attempt = createAttemptSignal(this.signalsFor(request), remainingMs === void 0 ? request.timeoutMs : Math.min(request.timeoutMs ?? remainingMs, remainingMs));
|
|
1327
1336
|
const started = now();
|
|
1328
1337
|
const report = (outcome, delayMs) => this.report({
|
|
1329
1338
|
operation: request.operation ?? null,
|
|
@@ -1359,8 +1368,8 @@ var CalmLensTransport = class {
|
|
|
1359
1368
|
} catch (cause) {
|
|
1360
1369
|
attempt.release();
|
|
1361
1370
|
const failure = toFailure(cause, attempt);
|
|
1362
|
-
|
|
1363
|
-
|
|
1371
|
+
const delayMs = getRetryDelayMs(attemptNumber);
|
|
1372
|
+
if (canRetryAgain && failure.isRetryable() && startsInTime(delayMs)) {
|
|
1364
1373
|
report({ error: failure }, delayMs);
|
|
1365
1374
|
await this.backoff(delayMs, request);
|
|
1366
1375
|
continue;
|
|
@@ -1379,7 +1388,7 @@ var CalmLensTransport = class {
|
|
|
1379
1388
|
if (allowHttpErrors) {
|
|
1380
1389
|
const retryAfter = parseRetryAfter(response.headers.get("retry-after"));
|
|
1381
1390
|
const delayMs = retryAfter !== void 0 ? retryAfter * 1e3 : getRetryDelayMs(attemptNumber);
|
|
1382
|
-
if (!canRetryAgain || !RETRYABLE_STATUSES.has(response.status) || delayMs > 6e4) {
|
|
1391
|
+
if (!canRetryAgain || !RETRYABLE_STATUSES.has(response.status) || delayMs > 6e4 || !startsInTime(delayMs)) {
|
|
1383
1392
|
report({ response }, null);
|
|
1384
1393
|
return {
|
|
1385
1394
|
response,
|
|
@@ -1401,7 +1410,7 @@ var CalmLensTransport = class {
|
|
|
1401
1410
|
attempt.release();
|
|
1402
1411
|
}
|
|
1403
1412
|
const retryDelayMs = error.retryAfter !== void 0 ? error.retryAfter * 1e3 : getRetryDelayMs(attemptNumber);
|
|
1404
|
-
if (canRetryAgain && retryDelayMs <= 6e4 && error.isRetryable()) {
|
|
1413
|
+
if (canRetryAgain && retryDelayMs <= 6e4 && error.isRetryable() && startsInTime(retryDelayMs)) {
|
|
1405
1414
|
report({ error }, retryDelayMs);
|
|
1406
1415
|
await this.backoff(retryDelayMs, request);
|
|
1407
1416
|
continue;
|
|
@@ -2173,27 +2182,29 @@ const DECISION_POLL_MAX_DELAY_MS = 2e3;
|
|
|
2173
2182
|
const DEFAULT_DECISION_TIMEOUT_MS = 6e4;
|
|
2174
2183
|
/**
|
|
2175
2184
|
* Retrieves an asset until it is settled (see `isAssetDecided`), waiting 0.5s between checks and
|
|
2176
|
-
* 1.5 times longer
|
|
2177
|
-
*
|
|
2185
|
+
* 1.5 times longer each time, up to 2s. Rejects with `sdk/timeout` once `timeoutMs` passes
|
|
2186
|
+
* without one, or the call's `deadlineAt`, whichever comes first.
|
|
2178
2187
|
*/
|
|
2179
|
-
const pollForDecision = async (retrieve, { timeoutMs = DEFAULT_DECISION_TIMEOUT_MS, signal }, sleep, now = Date.now) => {
|
|
2188
|
+
const pollForDecision = async (retrieve, { timeoutMs = DEFAULT_DECISION_TIMEOUT_MS, signal, deadlineAt }, sleep, now = Date.now) => {
|
|
2180
2189
|
if (!Number.isFinite(timeoutMs) || timeoutMs < 0) throw invalidArgument("timeoutMs must be a non-negative number");
|
|
2181
|
-
const
|
|
2190
|
+
const started = now();
|
|
2191
|
+
const deadline = started + timeoutMs;
|
|
2182
2192
|
let delay = 500;
|
|
2183
2193
|
for (;;) {
|
|
2184
2194
|
if (signal?.aborted) throw new CalmLensError(SDK_ERROR_CODES.CANCELLED, { message: "Request cancelled" });
|
|
2185
2195
|
const asset = await retrieve();
|
|
2186
2196
|
if (isAssetDecided(asset)) return asset;
|
|
2187
2197
|
const remaining = deadline - now();
|
|
2188
|
-
|
|
2189
|
-
|
|
2198
|
+
const wait = Math.min(delay, remaining);
|
|
2199
|
+
if (remaining <= 0 || deadlineAt !== void 0 && now() + wait >= deadlineAt) throw new CalmLensError(SDK_ERROR_CODES.TIMEOUT, {
|
|
2200
|
+
message: `Asset ${asset.id} had no moderation decision after ${now() - started}ms (classification status: ${asset.classification.status}, moderation decision: ${asset.classification.moderation.decision})`,
|
|
2190
2201
|
details: {
|
|
2191
2202
|
assetId: asset.id,
|
|
2192
2203
|
classificationStatus: asset.classification.status,
|
|
2193
2204
|
moderationDecision: asset.classification.moderation.decision
|
|
2194
2205
|
}
|
|
2195
2206
|
});
|
|
2196
|
-
await sleep(
|
|
2207
|
+
await sleep(wait, signal);
|
|
2197
2208
|
delay = Math.min(DECISION_POLL_MAX_DELAY_MS, delay * DECISION_POLL_DELAY_FACTOR);
|
|
2198
2209
|
}
|
|
2199
2210
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as withProvidedOptions, n as createUploadController } from "./UploadController-
|
|
1
|
+
import { i as withProvidedOptions, n as createUploadController } from "./UploadController-wyor-5Z2.js";
|
|
2
2
|
import { createContext, createElement, useContext, useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
3
3
|
// src/ui/ReactUpload.ts
|
|
4
4
|
const CalmLensContext = createContext(void 0);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as UploadFile, L as UploadSnapshot, N as UploadController, O as CalmLensProvidedOptions, P as UploadControllerOptions } from "./Core-
|
|
1
|
+
import { F as UploadFile, L as UploadSnapshot, N as UploadController, O as CalmLensProvidedOptions, P as UploadControllerOptions } from "./Core-CNmoxDCW.js";
|
|
2
2
|
import { ReactNode } from "react";
|
|
3
3
|
type CalmLensProviderProps<F extends UploadFile = File> = CalmLensProvidedOptions<F> & {
|
|
4
4
|
children?: ReactNode;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Q as CalmLensError, lt as SDK_ERROR_CODES } from "./ModerationContextLimits-
|
|
2
|
-
import { t as CalmLensAppClient } from "./CalmLensAppClient-
|
|
1
|
+
import { Q as CalmLensError, lt as SDK_ERROR_CODES } from "./ModerationContextLimits-xvxUjGfL.js";
|
|
2
|
+
import { t as CalmLensAppClient } from "./CalmLensAppClient-Dg-jPs4B.js";
|
|
3
3
|
// src/contract/PlaceholderHashDecode.js
|
|
4
4
|
/**
|
|
5
5
|
* Decodes a ThumbHash to an RGBA image. RGB is not be premultiplied by A.
|