calmlens 0.28.2 → 0.29.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/bin/calmlens.js +151 -123
- package/cjs/{BrowserUpload-DmKNP0Vy.js → BrowserUpload-CcSQI7Kf.js} +1 -1
- package/cjs/{BrowserUpload-CRbCsX7a.d.ts → BrowserUpload-CeGsM9h1.d.ts} +2 -2
- package/cjs/{CalmLensAppClient-Bl9VU7S2.js → CalmLensAppClient-BPILD5mg.js} +11 -17
- package/cjs/{CalmLensAppClient-B3u6BlP5.d.ts → CalmLensAppClient-D-BD_Ny1.d.ts} +7 -1
- package/cjs/{CalmLensOptionKeys-DolSy6qV.js → CalmLensConnection-Wfxn25LT.js} +660 -643
- package/cjs/{CalmLensServerClient-B8ntjNL3.d.ts → CalmLensServerClient-BYN_N0lt.d.ts} +33 -2
- package/cjs/{CalmLensServerClient-DA-sB9ru.js → CalmLensServerClient-C_42j_i4.js} +72 -41
- package/cjs/{CalmLensTypes-CtO4Dieu.d.ts → CalmLensTypes-C2blKgTu.d.ts} +51 -75
- package/{esm/Core-BJaLU71Q.d.ts → cjs/Core-CNmoxDCW.d.ts} +2 -2
- package/cjs/{Core-RSm9Xcse.js → Core-CfdovxKJ.js} +2 -2
- package/cjs/{ModerationContextLimits-51OdOFof.js → ModerationContextLimits-DXlPrt4K.js} +24 -13
- package/cjs/{ReactUpload-DQYHaJSZ.js → ReactUpload-CzsQwVKM.js} +1 -1
- package/cjs/{ReactUpload-BGUkcMpg.d.ts → ReactUpload-kqEe6gcN.d.ts} +1 -1
- package/cjs/{UploadController-C6Gt-YQA.js → UploadController-D_Y5wktq.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-BGywTQ2M.d.ts → ui-BtmJC-f9.d.ts} +2 -2
- package/cjs/{ui-Ntkv4inL.js → ui-CkOexkAO.js} +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-DJ2euKyv.js} +1 -1
- package/esm/{CalmLensAppClient-ktB4Vfbk.js → CalmLensAppClient-CCT5Em2S.js} +3 -9
- package/esm/{CalmLensAppClient-B3u6BlP5.d.ts → CalmLensAppClient-D-BD_Ny1.d.ts} +7 -1
- package/esm/{CalmLensOptionKeys-DCO58tKr.js → CalmLensConnection-CfBXkam-.js} +661 -644
- package/esm/{CalmLensServerClient-B8ntjNL3.d.ts → CalmLensServerClient-BYN_N0lt.d.ts} +33 -2
- package/esm/{CalmLensServerClient-D02L8AUH.js → CalmLensServerClient-e6gVcMxy.js} +58 -27
- package/esm/{CalmLensTypes-CtO4Dieu.d.ts → CalmLensTypes-C2blKgTu.d.ts} +51 -75
- package/{cjs/Core-BJaLU71Q.d.ts → esm/Core-CNmoxDCW.d.ts} +2 -2
- package/esm/{Core-22KeL-HD.js → Core-CojlqrKH.js} +2 -2
- package/esm/{ModerationContextLimits-BFfngsVu.js → ModerationContextLimits-Abu_L1Df.js} +24 -13
- package/esm/{ReactUpload-CFGawuk6.js → ReactUpload-CDrA7hRn.js} +1 -1
- package/esm/{ReactUpload-BGUkcMpg.d.ts → ReactUpload-kqEe6gcN.d.ts} +1 -1
- package/esm/{UploadController-CLEvEwzd.js → UploadController-BubUXclM.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--AzgLLVf.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
package/cjs/testing.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as CalmLensAppClient } from "./CalmLensAppClient-
|
|
3
|
-
import { I as ApiErrorCode, n as WebhookEventPayload } from "./WebhookPayload-
|
|
4
|
-
import { t as CalmLensServerClient } from "./CalmLensServerClient-
|
|
1
|
+
import { Ln as AssetBinaryPayloadInput, Lt as SignUploadTokenOptions, O as CalmLensAppClientOptions, Xt as UploadPresetDefinition, dn as TypedEvent, k as CalmLensServerClientOptions, m as AssetModeration, r as Asset, vn as PermissionGrant, yn as Folder, zt as SignedUploadToken } from "./CalmLensTypes-C2blKgTu.js";
|
|
2
|
+
import { t as CalmLensAppClient } from "./CalmLensAppClient-D-BD_Ny1.js";
|
|
3
|
+
import { I as ApiErrorCode, n as WebhookEventPayload } from "./WebhookPayload-DZWlnvcY.js";
|
|
4
|
+
import { t as CalmLensServerClient } from "./CalmLensServerClient-BYN_N0lt.js";
|
|
5
5
|
import { t as ClassificationTestSignal } from "./TestTriggers-dognME9k-PWyIfHMI.js";
|
|
6
6
|
import "zod";
|
|
7
7
|
/**
|
|
@@ -19,6 +19,11 @@ export declare const MEDIA_TEST_SIGNALS: readonly ["sexual", "violence", "self-h
|
|
|
19
19
|
export declare function generateMediaTestCode(signal: ClassificationTestSignal, testInputKey: string): Promise<string>;
|
|
20
20
|
export declare const MOCK_API_KEY_PREFIX = "sk_test_";
|
|
21
21
|
export declare const createMockApiKey: (grants?: PermissionGrant[]) => string;
|
|
22
|
+
/**
|
|
23
|
+
* The ID of every mock API key, as the `id` of the `actor` and `decidedBy` its requests record,
|
|
24
|
+
* where CalmLens gives your key's own ID.
|
|
25
|
+
*/
|
|
26
|
+
export declare const MOCK_API_KEY_ID = "key_mock0000000000000000";
|
|
22
27
|
/**
|
|
23
28
|
* The prefix of every kind of object customers can see, so an ID says what it identifies:
|
|
24
29
|
* `proj_8fK2mQx7Lp4NvB3tRz9Y` is a project. Rows that never leave the backend (usage meters, upload
|
|
@@ -240,12 +245,12 @@ type MockReviewDecision = "allowed" | "limited" | "age-restricted" | "blocked" |
|
|
|
240
245
|
* method that sends it; `callsTo` and `failNextRequest` also match the others (see
|
|
241
246
|
* `MockCalmLensCall`).
|
|
242
247
|
*/
|
|
243
|
-
declare const MOCK_OPERATIONS: readonly ["assets.list", "assets.search", "assets.retrieve", "assets.waitForDecision", "assets.update", "assets.listChildren", "assets.listTimeline", "assets.create", "assets.classify", "assets.uploadPart", "assets.move", "assets.retry", "assets.decide", "assets.removeContent", "assets.delete", "assets.batch", "text.classify", "cdn.serve", "cdn.getAssetInfo", "cdn.signAssetUrl", "events.list", "folders.list", "folders.retrieve", "folders.create", "folders.update", "folders.delete", "folders.move", "hashLists.list", "hashLists.retrieve", "hashLists.create", "hashLists.update", "hashLists.delete", "hashLists.listEntries", "hashLists.addEntry", "hashLists.removeEntry", "policies.list", "policies.retrieve", "policies.create", "policies.update", "policies.reset", "policies.upgrade", "policies.setAutomaticUpdates", "policies.delete", "policies.retrieveAssigned", "policies.assign", "lenses.list", "lenses.create", "lenses.retrieve", "lenses.update", "lenses.delete", "ensureLens", "ensureLenses", "uploadPresets.list", "uploadPresets.ensure", "uploadPresets.delete", "projectSettings.get", "projectSettings.update", "metadataFields.list", "metadataFields.ensure", "metadataFields.delete"];
|
|
248
|
+
declare const MOCK_OPERATIONS: readonly ["assets.list", "assets.search", "assets.retrieve", "assets.retrieveByExternalId", "assets.waitForDecision", "assets.update", "assets.listChildren", "assets.listTimeline", "assets.create", "assets.classify", "assets.uploadPart", "assets.move", "assets.retry", "assets.decide", "assets.requestReview", "assets.removeContent", "assets.delete", "assets.batch", "text.classify", "cdn.serve", "cdn.getAssetInfo", "cdn.signAssetUrl", "events.list", "events.retrieveAsset", "folders.list", "folders.retrieve", "folders.create", "folders.update", "folders.delete", "folders.move", "hashLists.list", "hashLists.retrieve", "hashLists.create", "hashLists.update", "hashLists.delete", "hashLists.listEntries", "hashLists.addEntry", "hashLists.removeEntry", "policies.list", "policies.retrieve", "policies.create", "policies.update", "policies.reset", "policies.upgrade", "policies.setAutomaticUpdates", "policies.delete", "policies.retrieveAssigned", "policies.assign", "lenses.list", "lenses.create", "lenses.retrieve", "lenses.update", "lenses.delete", "ensureLens", "ensureLenses", "uploadPresets.list", "uploadPresets.ensure", "uploadPresets.delete", "projectSettings.get", "projectSettings.update", "metadataFields.list", "metadataFields.ensure", "metadataFields.delete"];
|
|
244
249
|
type MockCalmLensOperation = (typeof MOCK_OPERATIONS)[number];
|
|
245
250
|
/**
|
|
246
251
|
* One request a mock client sent, as the in-memory API received it. `operation` is the client
|
|
247
252
|
* method that sends it; requests several methods send are recorded under the first: `ensureLens`
|
|
248
|
-
* as `ensureLenses`, `assets.waitForDecision` polls as `assets.retrieve`, and so on. `callsTo`
|
|
253
|
+
* as `ensureLenses`, `assets.waitForDecision` polls and `events.retrieveAsset` as `assets.retrieve`, and so on. `callsTo`
|
|
249
254
|
* matches all of them. A text upload is `text.classify`'s and a file or URL upload
|
|
250
255
|
* `assets.classify`'s, never both. Methods that send nothing, such as `uploadTokens.sign` or a cached `ensureLens`, are not
|
|
251
256
|
* recorded.
|
|
@@ -278,14 +283,25 @@ interface MockCalmLensCall {
|
|
|
278
283
|
* like an exception from `fetch`.
|
|
279
284
|
*/
|
|
280
285
|
type MockRequestFailure = "transport-error" | "timeout" | ApiErrorCode | Error;
|
|
281
|
-
/**
|
|
286
|
+
/**
|
|
287
|
+
* Options for a simulated failure: the method whose requests it fails, how many of them, and, for
|
|
288
|
+
* an API error, its `details` and the `Retry-After` it answers with.
|
|
289
|
+
*/
|
|
282
290
|
interface MockFailureOptions {
|
|
283
291
|
operation?: MockCalmLensOperation;
|
|
292
|
+
/** How many requests it fails, a positive whole number; 1 unless given. */
|
|
293
|
+
times?: number;
|
|
284
294
|
/** The error's `details`, for an API error code. */
|
|
285
295
|
details?: Record<string, unknown>;
|
|
286
296
|
/** Seconds for the `Retry-After` header, for an API error code. */
|
|
287
297
|
retryAfter?: number;
|
|
288
298
|
}
|
|
299
|
+
/** A URL's content for `serveUrl`: bytes, or text sent as UTF-8. */
|
|
300
|
+
interface MockServedUrl {
|
|
301
|
+
content: Uint8Array | ArrayBuffer | string;
|
|
302
|
+
/** The `Content-Type` the URL answers with, such as `image/png`. */
|
|
303
|
+
type: string;
|
|
304
|
+
}
|
|
289
305
|
/** An event to add to the mock feed; omitted fields get defaults. */
|
|
290
306
|
/** An event to add to the feed; its `assetSequence` is assigned like the API's. */
|
|
291
307
|
type MockEventInput = Partial<Omit<TypedEvent, "type" | "assetSequence">> & {
|
|
@@ -299,7 +315,9 @@ type MockEventInput = Partial<Omit<TypedEvent, "type" | "assetSequence">> & {
|
|
|
299
315
|
* `processingOptions.retainContent` to `true`, so the CDN can serve the upload.
|
|
300
316
|
* `processingOptions.features` turns on features such as face detection for the preset's uploads.
|
|
301
317
|
*/
|
|
302
|
-
type MockUploadPreset = Partial<Pick<UploadPresetDefinition,
|
|
318
|
+
type MockUploadPreset = Partial<Pick<UploadPresetDefinition, (typeof MOCK_UPLOAD_PRESET_KEYS)[number]>>;
|
|
319
|
+
/** The keys a `MockUploadPreset` takes; `checkMockUploadPreset` refuses any other. */
|
|
320
|
+
declare const MOCK_UPLOAD_PRESET_KEYS: readonly ["access", "allowedContentTypes", "maxSizeInBytes", "revealDecision", "visibility", "folderId", "processingOptions"];
|
|
303
321
|
interface MockCalmLensServerClientOptions extends Omit<CalmLensServerClientOptions, "apiKey" | "projectId"> {
|
|
304
322
|
/** A key from `createMockApiKey`, whose grants the mock API enforces. Never read from the environment. */
|
|
305
323
|
apiKey: string;
|
|
@@ -369,11 +387,27 @@ export declare class MockCalmLensServerClient extends CalmLensServerClient {
|
|
|
369
387
|
clearCalls(): void;
|
|
370
388
|
/**
|
|
371
389
|
* Makes the next request (or the next one `operation` sends) fail instead of reaching the
|
|
372
|
-
* in-memory API. Each queued failure fails
|
|
373
|
-
*
|
|
374
|
-
*
|
|
390
|
+
* in-memory API, or the next `times` of them. Each queued failure fails that many requests, so
|
|
391
|
+
* a retry takes it again until it is used up, then the next queued failure or the API. A
|
|
392
|
+
* request takes the oldest queued failure that matches it. An API error code answers with that
|
|
393
|
+
* error and its HTTP status, with `details` and a `Retry-After` of `retryAfter` seconds when
|
|
394
|
+
* given.
|
|
375
395
|
*/
|
|
376
396
|
failNextRequest(failure?: MockRequestFailure, options?: MockFailureOptions): void;
|
|
397
|
+
/**
|
|
398
|
+
* Makes every request (or every one `operation` sends) fail as `failNextRequest` would, until
|
|
399
|
+
* `clearFailures`. Queued after other failures, it fails the requests they don't.
|
|
400
|
+
*/
|
|
401
|
+
failRequests(failure?: MockRequestFailure, options?: Omit<MockFailureOptions, "times">): void;
|
|
402
|
+
/** Drops every failure `failNextRequest` and `failRequests` queued. */
|
|
403
|
+
clearFailures(): void;
|
|
404
|
+
/**
|
|
405
|
+
* Makes `url` answer with `content` (bytes, or text as UTF-8) and `type` when a URL upload
|
|
406
|
+
* fetches it. The upload then stores that content and is typed by `type`, as an upload of the
|
|
407
|
+
* bytes would be: `image/png` is an image, and `text/html` a website. A URL not served this way
|
|
408
|
+
* is typed by its path's extension, and has no content.
|
|
409
|
+
*/
|
|
410
|
+
serveUrl(url: string, content: MockServedUrl): void;
|
|
377
411
|
/**
|
|
378
412
|
* Changes the grants of the mock's API key, as editing the key in the portal would: later
|
|
379
413
|
* requests, such as `cdn.serve`, use them. The key itself stays the same, so idempotency keys
|
|
@@ -443,4 +477,4 @@ export declare const createWebhookHeaders: (options: {
|
|
|
443
477
|
deliveryId: string;
|
|
444
478
|
timestampSeconds?: number;
|
|
445
479
|
}) => Promise<Record<string, string>>;
|
|
446
|
-
export { type MockAssetOutcome, type MockCalmLensAppClientOptions, type MockCalmLensCall, type MockCalmLensOperation, type MockCalmLensServerClientOptions, type MockDatabaseStorage, type MockDetectedFace, type MockDetectedLink, type MockDetectedPerson, type MockEventInput, type MockFailureOptions, type MockImageStorage, type MockModerate, type MockModerationInput, type MockModerationTrigger, type MockQrCode, type MockRequestFailure, type MockReviewDecision, type MockStoredContent, type MockTextRegion, type MockUploadPreset, signUploadTokenWithApiKey as signUploadToken };
|
|
480
|
+
export { type MockAssetOutcome, type MockCalmLensAppClientOptions, type MockCalmLensCall, type MockCalmLensOperation, type MockCalmLensServerClientOptions, type MockDatabaseStorage, type MockDetectedFace, type MockDetectedLink, type MockDetectedPerson, type MockEventInput, type MockFailureOptions, type MockImageStorage, type MockModerate, type MockModerationInput, type MockModerationTrigger, type MockQrCode, type MockRequestFailure, type MockReviewDecision, type MockServedUrl, type MockStoredContent, type MockTextRegion, type MockUploadPreset, signUploadTokenWithApiKey as signUploadToken };
|