calmlens 0.20.0 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/README.md +13 -9
  2. package/bin/calmlens.js +1329 -664
  3. package/cjs/{BrowserUpload-CjSHjx3C.js → BrowserUpload-CeSwiMo5.js} +1 -1
  4. package/cjs/{BrowserUpload-C07aL9Vq.d.ts → BrowserUpload-D-NnAN7g.d.ts} +2 -2
  5. package/cjs/{CalmLensAppClient-NaCxOVlM.js → CalmLensAppClient-0UVCuNqW.js} +30 -10
  6. package/cjs/{CalmLensAppClient-DDLojj0P.d.ts → CalmLensAppClient-gG16T2py.d.ts} +13 -3
  7. package/cjs/{CalmLensOptionKeys-p2QK687A.js → CalmLensOptionKeys-CYY6elxg.js} +183 -347
  8. package/cjs/{CalmLensServerClient-C-jsjn8m.d.ts → CalmLensServerClient-BHx3x_nZ.d.ts} +106 -48
  9. package/cjs/{CalmLensServerClient-BDzTthxE.js → CalmLensServerClient-nfu6_YEW.js} +288 -88
  10. package/cjs/{CalmLensTypes-COJbOuiv.d.ts → CalmLensTypes-CUB0YYVz.d.ts} +26601 -27354
  11. package/cjs/{Classification-D3SkprrQ-CMnQKW13.d.ts → Classification-Q5zGpR8l-CEWjnE39.d.ts} +731 -607
  12. package/cjs/Core-C82YmjjX.d.ts +823 -0
  13. package/cjs/Core-Dc3cteU7.js +998 -0
  14. package/cjs/FileIcons-4qSX7DW2.d.ts +67 -0
  15. package/cjs/{ModerationContextLimits-2nIv7Zh3.js → ModerationContextLimits-BxOmeSqq.js} +669 -269
  16. package/cjs/{ReactUpload-BdTRCTGA.js → ReactUpload-BK2O3dnK.js} +1 -1
  17. package/cjs/{ReactUpload-CRJNPB5T.d.ts → ReactUpload-DiiXfKvj.d.ts} +1 -1
  18. package/cjs/{TestTriggers-DbhsNPdg-DjvVuc2h.js → TestTriggers-BTyXtX0Q-ATuFDhLX.js} +342 -34
  19. package/{esm/TestTriggers-D-fwfhEP-hlaP1oW2.d.ts → cjs/TestTriggers-D0pYHbkr-D5T0VdSn.d.ts} +146 -8
  20. package/cjs/{UploadController-MLVs97Zt.js → UploadController-DLyiLDTB.js} +34 -14
  21. package/cjs/{WebhookPayload-DkukERKE.d.ts → WebhookPayload-BLT2y_Jy.d.ts} +93 -86
  22. package/cjs/app.d.ts +6 -7
  23. package/cjs/app.js +4 -3
  24. package/cjs/elements.d.ts +123 -22
  25. package/cjs/elements.js +553 -156
  26. package/cjs/file-icons.d.ts +2 -67
  27. package/cjs/index-CKRgjV16.d.ts +16 -0
  28. package/cjs/index.d.ts +5 -6
  29. package/cjs/index.js +3 -2
  30. package/cjs/react-native.d.ts +52 -11
  31. package/cjs/react-native.js +231 -99
  32. package/cjs/react.d.ts +42 -9
  33. package/cjs/react.js +381 -118
  34. package/cjs/server.d.ts +48 -7
  35. package/cjs/server.js +7 -3
  36. package/cjs/test-inputs.d.ts +2 -2
  37. package/cjs/test-inputs.js +13 -9
  38. package/cjs/testing.d.ts +24 -14
  39. package/cjs/testing.js +1413 -402
  40. package/cjs/ui-CTBUxnVp.d.ts +139 -0
  41. package/cjs/ui-CZ8exACq.js +1359 -0
  42. package/cjs/ui.d.ts +3 -2
  43. package/cjs/ui.js +45 -22
  44. package/cjs/vue.d.ts +802 -199
  45. package/cjs/vue.js +359 -127
  46. package/esm/{BrowserUpload-C07aL9Vq.d.ts → BrowserUpload-D-NnAN7g.d.ts} +2 -2
  47. package/esm/{BrowserUpload-CAVkRotw.js → BrowserUpload-i9OhCzMJ.js} +1 -1
  48. package/esm/{CalmLensAppClient-PQ9VBvlW.js → CalmLensAppClient-CK4_Py0c.js} +30 -10
  49. package/esm/{CalmLensAppClient-DDLojj0P.d.ts → CalmLensAppClient-gG16T2py.d.ts} +13 -3
  50. package/esm/{CalmLensOptionKeys-Do2mPP6w.js → CalmLensOptionKeys-BGZlIsT2.js} +182 -340
  51. package/esm/{CalmLensServerClient-C-jsjn8m.d.ts → CalmLensServerClient-BHx3x_nZ.d.ts} +106 -48
  52. package/esm/{CalmLensServerClient-C_H5aAsV.js → CalmLensServerClient-dAQUcDWb.js} +265 -89
  53. package/esm/{CalmLensTypes-COJbOuiv.d.ts → CalmLensTypes-CUB0YYVz.d.ts} +26601 -27354
  54. package/esm/{Classification-D3SkprrQ-CMnQKW13.d.ts → Classification-Q5zGpR8l-CEWjnE39.d.ts} +731 -607
  55. package/esm/Core-BxeIud_S.js +843 -0
  56. package/esm/Core-C82YmjjX.d.ts +823 -0
  57. package/esm/FileIcons-4qSX7DW2.d.ts +67 -0
  58. package/esm/{ModerationContextLimits-Chw-AzgL.js → ModerationContextLimits-B6_RalCQ.js} +624 -254
  59. package/esm/{ReactUpload-CRJNPB5T.d.ts → ReactUpload-DiiXfKvj.d.ts} +1 -1
  60. package/esm/{ReactUpload-CMmL0R5Q.js → ReactUpload-DxwVqfX1.js} +1 -1
  61. package/esm/{TestTriggers-DbhsNPdg-CUdrv8Nm.js → TestTriggers-BTyXtX0Q-GRB9jQwo.js} +319 -35
  62. package/{cjs/TestTriggers-D-fwfhEP-hlaP1oW2.d.ts → esm/TestTriggers-D0pYHbkr-D5T0VdSn.d.ts} +146 -8
  63. package/esm/{UploadController-BJZghJpg.js → UploadController-D9Z-h00Q.js} +34 -14
  64. package/esm/{WebhookPayload-DkukERKE.d.ts → WebhookPayload-BLT2y_Jy.d.ts} +93 -86
  65. package/esm/app.d.ts +6 -7
  66. package/esm/app.js +3 -3
  67. package/esm/elements.d.ts +123 -22
  68. package/esm/elements.js +497 -128
  69. package/esm/file-icons.d.ts +2 -67
  70. package/esm/index-CKRgjV16.d.ts +16 -0
  71. package/esm/index.d.ts +5 -6
  72. package/esm/index.js +1 -1
  73. package/esm/react-native.d.ts +52 -11
  74. package/esm/react-native.js +205 -75
  75. package/esm/react.d.ts +42 -9
  76. package/esm/react.js +327 -91
  77. package/esm/server.d.ts +48 -7
  78. package/esm/server.js +3 -3
  79. package/esm/styles.css +142 -22
  80. package/esm/svelte/AssetViewer.svelte +25 -0
  81. package/esm/svelte/CalmLensAsset.svelte +318 -0
  82. package/esm/svelte/CalmLensDocumentViewer.svelte +7 -0
  83. package/esm/svelte/CalmLensImageViewer.svelte +7 -0
  84. package/esm/svelte/CalmLensSpreadsheetViewer.svelte +7 -0
  85. package/esm/svelte/CalmLensTextViewer.svelte +7 -0
  86. package/esm/svelte/CalmLensWebsiteViewer.svelte +7 -0
  87. package/esm/svelte/index.d.ts +29 -6
  88. package/esm/svelte/index.js +7 -2
  89. package/esm/test-inputs.d.ts +2 -2
  90. package/esm/test-inputs.js +1 -1
  91. package/esm/testing.d.ts +24 -14
  92. package/esm/testing.js +1409 -398
  93. package/esm/ui-CTBUxnVp.d.ts +139 -0
  94. package/esm/ui-Cr7s6JHm.js +1258 -0
  95. package/esm/ui.d.ts +3 -2
  96. package/esm/ui.js +4 -3
  97. package/esm/vue.d.ts +802 -199
  98. package/esm/vue.js +308 -103
  99. package/package.json +3 -1
  100. package/cjs/ModerationContext-9lGm-Mna-CcmbRnOy.d.ts +0 -67
  101. package/cjs/index-DxbJ_Xaa.d.ts +0 -253
  102. package/cjs/ui-BSqPGKrZ.d.ts +0 -539
  103. package/cjs/ui-CX1z2pD9.js +0 -586
  104. package/esm/ModerationContext-9lGm-Mna-CcmbRnOy.d.ts +0 -67
  105. package/esm/index-DxbJ_Xaa.d.ts +0 -253
  106. package/esm/svelte/CalmLensMedia.svelte +0 -134
  107. package/esm/ui-BSqPGKrZ.d.ts +0 -539
  108. package/esm/ui-CXH7xJpb.js +0 -461
package/cjs/server.d.ts CHANGED
@@ -1,9 +1,8 @@
1
- import { a as selectModerationContextItems, i as ModerationContextItem, n as MODERATION_CONTEXT_USED_CHARACTERS, o as HashList, r as MODERATION_CONTEXT_USED_ITEMS, s as HashListEntry, t as ModerationContext } from "./ModerationContext-9lGm-Mna-CcmbRnOy.js";
2
- import { $ as ImageTransformOptions, $t as AssetSearchMatchField, A as CdnServeOptions, At as UploadedAsset, B as DeleteAssetContentOptions, Bt as TypedEvent, C as AssignPolicyOptions, Ct as SubmitAssetOptions, D as CalmLensServerClientOptions, Dt as UpdatePolicyOptions, E as CalmLensAppClientOptions, Et as UpdateHashListOptions, F as CreateFolderOptions, Ft as WebhookPayloadInput, G as FolderIdOptions, Gt as EventSeverity, H as EnsureLensOptions, Ht as EventFact, I as CreateHashListOptions, It as AssetBatchOperation, J as HashListEntryIdOptions, Jt as Folder, Kt as EventType, L as CreateMultipartUploadPartOptions, Lt as GetEventsResponse, M as ClassifyTextOptions, Mt as ViewerClaims, N as ConnectionOptions, Nt as WaitForAssetDecisionOptions, O as CdnAssetUrlOptions, Ot as UploadAssetPartOptions, P as CreateAssetSignedUrlOptions, Pt as WebhookHeadersInput, Q as IdempotencyOptions, Qt as LensType, R as CreatePolicyOptions, S as AssetVisibility, St as SignedUrl, T as BatchAssetsResponse, Tt as UpdateFolderOptions, U as EnsureLensesOptions, Ut as EventFactValues, V as DeleteAssetOptions, Vt as EventCategory, W as ExplainAssetOptions, Wt as EventFacts, X as HashListIdOptions, Xt as CursorPage, Y as HashListEntryPage, Yt as Policy, Z as HashListPage, Zt as Order, _ as AssetSearchResponse, _t as RetryAssetOptions, a as AssetChildrenPage, an as ExtractedText, at as ListEventsOptions, b as AssetUpload, bt as SignUploadTokenOptions, c as AssetClassificationStatus, cn as ProcessingOptions, ct as ListHashListsOptions, d as AssetContentRemovalReason, dt as MultipartUploadOptions, en as AssetSearchQuery, et as IterateAssetChildrenOptions, f as AssetContentStatus, ft as MultipartUploadPartOptions, g as AssetPage, gt as RetrieveAssetOptions, h as AssetModerationStatus, ht as RequestOptions, i as AssetChecksums, in as AssetSafetyHoldReason, it as ListAssetsOptions, j as CdnTransform, jt as VerifyWebhookSignatureOptions, k as CdnResource, kt as UploadPresetSubmitAssetOptions, l as AssetContent, lt as MoveAssetOptions, m as AssetModerationDecision, mt as PolicyList, n as ApplyPolicyPresetOptions, nn as AssetImage, nt as Lens, o as AssetClassification, on as FileMetadata, p as AssetModeration, pt as PolicyIdOptions, q as GetAssetUrlOptions, r as Asset, rn as AssetSafetyHold, rt as ListAssetChildrenOptions, s as AssetClassificationFailureReason, sn as MetadataItem, st as ListHashListEntriesOptions, t as AddHashListEntryOptions, tt as IterateAssetsOptions, u as AssetContentOptions, ut as MoveFolderOptions, v as AssetSearchResult, vt as SearchAssetsOptions, w as BatchAssetsOptions, wt as UpdateAssetOptions, x as AssetUploadStatus, xt as SignedUploadToken, y as AssetType, yt as SetPolicyAutomaticUpdatesOptions, z as DecideAssetOptions, zt as EventAsset } from "./CalmLensTypes-COJbOuiv.js";
3
- import { a as CalmLensErrorCode, c as SdkErrorCode, i as CalmLensError, l as ApiErrorCode, o as CalmLensErrorDetails, r as CALMLENS_ERROR_CODES, s as CalmLensErrorOptions, t as ReceivedWebhookEventPayload } from "./WebhookPayload-DkukERKE.js";
4
- import { a as ProcessingFeatureId, c as ProcessingFeatures, d as getAssetUrl, i as DetectedPerson, l as SDK_VERSION, n as BoundingBox, o as ProcessingFeatureResults, r as DetectedFace, s as ProcessingFeatureStage, t as AgeRange, u as DEFAULT_CDN_BASE_URL } from "./index-DxbJ_Xaa.js";
5
- import { a as ClassificationNotEvaluatedReason, c as ModerationQualifier, i as ClassificationLabel, l as PolicyAction, n as ClassificationCategory, o as ClassificationQualifierResults, r as ClassificationCategoryReport, s as Likelihood, t as ClassificationCategories } from "./Classification-D3SkprrQ-CMnQKW13.js";
6
- import { t as CalmLensServerClient } from "./CalmLensServerClient-C-jsjn8m.js";
1
+ import { a as ClassificationNotEvaluatedReason, c as ModerationQualifier, d as HashListEntry, f as ModerationContext, g as selectModerationContextItems, h as ModerationContextItem, i as ClassificationCategoryReport, l as PolicyAction, m as MODERATION_CONTEXT_USED_ITEMS, n as ClassificationCategories, o as ClassificationQualifierResults, p as MODERATION_CONTEXT_USED_CHARACTERS, r as ClassificationCategory, s as Likelihood, u as HashList } from "./Classification-Q5zGpR8l-CEWjnE39.js";
2
+ import { $ as HashListPage, $t as WebhookHeadersInput, A as CdnAssetReference, An as AssetHls, At as ResetPolicyOptions, B as CreateMultipartUploadPartOptions, Bn as ProcessingOptions, Bt as SubmitAssetOptions, C as AssetVisibility, Cn as Policy, Ct as MoveFolderOptions, D as CalmLensAppClientOptions, Dn as AssetSearchQuery, Dt as PolicyPage, E as BatchAssetsResponse, En as AssetSearchMatchField, Et as PolicyIdOptions, F as ClassifyTextOptions, Fn as AssetSafetyHold, Ft as SignAssetUrlOptions, G as EnsureLensesOptions, Gt as UpdatePolicyOptions, H as DecideAssetOptions, Ht as UpdateFolderOptions, I as ConnectionOptions, In as AssetSafetyHoldReason, It as SignUploadTokenOptions, J as FolderPage, Jt as UploadPresetSubmitAssetOptions, K as ExplainAssetOptions, Kt as UpgradePolicyOptions, L as CreateFolderOptions, Ln as ExtractedText, Lt as SignedAssetUrl, M as CdnResource, Mn as AssetPreview, Mt as RetryAssetOptions, N as CdnServeOptions, Nn as AssetRendered, Nt as SearchAssetsOptions, O as CalmLensServerClientOptions, Ot as RemoveAssetContentOptions, P as CdnTransform, Pn as AssetRenderedKind, Pt as SetPolicyAutomaticUpdatesOptions, Q as HashListIdOptions, Qt as WaitForAssetDecisionOptions, R as CreateHashListOptions, Rn as FileMetadata, Rt as SignedUploadToken, S as AssetUploadStatus, Sn as ProcessingFeatures, St as MoveAssetOptions, T as BatchAssetsOptions, Tn as LensType, Tt as MultipartUploadPartOptions, U as DeleteAssetOptions, Ut as UpdateHashListOptions, V as CreatePolicyOptions, Vt as UpdateAssetOptions, W as EnsureLensOptions, Wt as UpdateLensOptions, X as HashListEntryIdOptions, Xt as VerifyWebhookSignatureOptions, Y as GetAssetInfoOptions, Yt as UploadedAsset, Z as HashListEntryPage, Zt as ViewerClaims, _ as AssetSearchResponse, _n as DetectedFace, _t as ListFoldersOptions, a as AssetChildrenPage, an as EventAsset, at as IterateFoldersOptions, b as AssetType, bn as ProcessingFeatureResults, bt as ListLensesOptions, c as AssetClassificationStatus, cn as EventFact, ct as IterateLensesOptions, d as AssetContentRemovalReason, dn as EventSeverity, dt as LensIdOptions, en as WebhookPayloadInput, et as IdempotencyOptions, f as AssetContentStatus, fn as EventType, ft as LensPage, g as AssetPage, gn as BoundingBox, gt as ListEventsOptions, h as AssetModerationStatus, hn as AgeRange, ht as ListAssetsOptions, i as AssetChecksums, it as IterateAssetsOptions, j as CdnAssetUrlOptions, jn as AssetHlsRendition, jt as RetrieveAssetOptions, k as CdnAssetLocation, kn as AssetInfo, kt as RequestOptions, l as AssetContent, ln as EventFactValues, lt as IteratePoliciesOptions, m as AssetModerationDecision, mn as Folder, mt as ListAssetTimelineOptions, n as Asset, nn as AssetTimelineSegment, nt as IterateAssetChildrenOptions, o as AssetClassification, on as TypedEvent, ot as IterateHashListEntriesOptions, p as AssetModeration, pt as ListAssetChildrenOptions, q as FolderIdOptions, qt as UploadAssetPartOptions, r as AssetAvailability, rn as GetEventsResponse, rt as IterateAssetTimelineOptions, s as AssetClassificationFailureReason, sn as EventCategory, st as IterateHashListsOptions, t as AddHashListEntryOptions, tn as AssetBatchOperation, tt as ImageTransformOptions, u as AssetContentOptions, un as EventFacts, ut as Lens, v as AssetSearchResult, vn as DetectedPerson, vt as ListHashListEntriesOptions, w as AssignPolicyOptions, wn as CursorPage, wt as MultipartUploadOptions, x as AssetUpload, xn as ProcessingFeatureStage, xt as ListPoliciesOptions, y as AssetTimelinePage, yn as ProcessingFeatureId, yt as ListHashListsOptions, z as CreateLensOptions, zn as MetadataItem, zt as StreamingFeatureOptions } from "./CalmLensTypes-CUB0YYVz.js";
3
+ import { i as getAssetInfo, n as DEFAULT_CDN_BASE_URL, r as CDN_RESOURCES, t as SDK_VERSION } from "./index-CKRgjV16.js";
4
+ import { a as CalmLensErrorCode, c as SdkErrorCode, i as CalmLensError, l as ApiErrorCode, o as CalmLensErrorDetails, r as CALMLENS_ERROR_CODES, s as CalmLensErrorOptions, t as ReceivedWebhookEventPayload } from "./WebhookPayload-BLT2y_Jy.js";
5
+ import { t as CalmLensServerClient } from "./CalmLensServerClient-BHx3x_nZ.js";
7
6
  export declare const WEBHOOK_DELIVERY_HEADER = "x-calmlens-delivery";
8
7
  export declare const WEBHOOK_TIMESTAMP_HEADER = "x-calmlens-timestamp";
9
8
  export declare const WEBHOOK_SIGNATURE_HEADER = "x-calmlens-signature";
@@ -25,9 +24,51 @@ export declare function verifyWebhookSignature(options: VerifyWebhookSignatureOp
25
24
  * so keep a default branch when you switch on `type`.
26
25
  */
27
26
  export declare function parseWebhookEvent(options: VerifyWebhookSignatureOptions): Promise<ReceivedWebhookEventPayload>;
27
+ type FactsOf<TEvent> = TEvent extends {
28
+ facts: ReadonlyArray<infer TFact>;
29
+ } ? TFact : never;
30
+ type FactValue<TEvent, TKey> = Extract<FactsOf<TEvent>, {
31
+ key: TKey;
32
+ }> extends {
33
+ value: infer V;
34
+ } ? V : unknown;
35
+ /**
36
+ * The value of one of an event's facts, by key, or `undefined` when the event doesn't carry it.
37
+ * Typed by the event's `type`, so `getEventFact(event, "flagged-categories")` on an
38
+ * `asset.blocked` event is a list of categories. The fact's `url`, when it has one, is on the fact
39
+ * in `event.facts`.
40
+ */
41
+ export declare const getEventFact: <TEvent extends {
42
+ facts?: ReadonlyArray<{
43
+ key: string;
44
+ value: unknown;
45
+ }>;
46
+ }, TKey extends FactsOf<TEvent> extends {
47
+ key: infer K;
48
+ } ? K : string>(event: TEvent, key: TKey) => FactValue<TEvent, TKey> | undefined;
49
+ /**
50
+ * An event's facts as an object of values by key, such as `{ "flagged-categories": ["hate"] }`.
51
+ * A key the event repeats keeps its first value, as `getEventFact` reads it.
52
+ */
53
+ export declare const getEventFacts: <TEvent extends {
54
+ facts?: ReadonlyArray<{
55
+ key: string;
56
+ value: unknown;
57
+ }>;
58
+ }>(event: TEvent) => { [TKey in FactsOf<TEvent> extends {
59
+ key: infer K extends string;
60
+ } ? K : string]?: FactValue<TEvent, TKey>; };
28
61
  /**
29
62
  * Whether a webhook event is a test send from the portal or the CLI rather than a real event: it
30
63
  * carries the registered `{ key: "test", value: true }` fact.
31
64
  */
32
65
  export declare const isTestWebhookEvent: (event: Pick<ReceivedWebhookEventPayload, "facts">) => boolean;
33
- export { type AddHashListEntryOptions, type AgeRange, type ApiErrorCode, type ApplyPolicyPresetOptions, type Asset, type AssetBatchOperation, type AssetChecksums, type AssetChildrenPage, type AssetClassification, type AssetClassificationFailureReason, type AssetClassificationStatus, type AssetContent, type AssetContentOptions, type AssetContentRemovalReason, type AssetContentStatus, type AssetImage, type AssetModeration, type AssetModerationDecision, type AssetModerationStatus, type AssetPage, type AssetSafetyHold, type AssetSafetyHoldReason, type AssetSearchMatchField, type AssetSearchQuery, type AssetSearchResponse, type AssetSearchResult, type AssetType, type AssetUpload, type AssetUploadStatus, type AssetVisibility, type AssignPolicyOptions, type BatchAssetsOptions, type BatchAssetsResponse, type BoundingBox, CALMLENS_ERROR_CODES, type CalmLensAppClientOptions, CalmLensError, type CalmLensErrorCode, type CalmLensErrorDetails, type CalmLensErrorOptions, CalmLensServerClient, type CalmLensServerClientOptions, type CdnAssetUrlOptions, type CdnResource, type CdnServeOptions, type CdnTransform, type ClassificationCategories, type ClassificationCategory, type ClassificationCategoryReport, type ClassificationLabel, type ClassificationNotEvaluatedReason, type ClassificationQualifierResults, type ClassifyTextOptions, type ConnectionOptions, type CreateAssetSignedUrlOptions, type CreateFolderOptions, type CreateHashListOptions, type CreateMultipartUploadPartOptions, type CreatePolicyOptions, type CursorPage, DEFAULT_CDN_BASE_URL, type DecideAssetOptions, type DeleteAssetContentOptions, type DeleteAssetOptions, type DetectedFace, type DetectedPerson, type EnsureLensOptions, type EnsureLensesOptions, type EventAsset, type EventCategory, type EventFact, type EventFactValues, type EventFacts, type EventSeverity, type EventType, type GetEventsResponse as EventsPage, type ExplainAssetOptions, type ExtractedText, type FileMetadata, type Folder, type FolderIdOptions, type GetAssetUrlOptions, type HashList, type HashListEntry, type HashListEntryIdOptions, type HashListEntryPage, type HashListIdOptions, type HashListPage, type IdempotencyOptions, type ImageTransformOptions, type IterateAssetChildrenOptions, type IterateAssetsOptions, type Lens, type LensType, type Likelihood, type ListAssetChildrenOptions, type ListAssetsOptions, type ListEventsOptions, type ListHashListEntriesOptions, type ListHashListsOptions, MODERATION_CONTEXT_USED_CHARACTERS, MODERATION_CONTEXT_USED_ITEMS, type MetadataItem, type ModerationContext, type ModerationContextItem, type ModerationQualifier, type MoveAssetOptions, type MoveFolderOptions, type MultipartUploadOptions, type MultipartUploadPartOptions, type Order, type Policy, type PolicyAction, type PolicyIdOptions, type PolicyList, type ProcessingFeatureId, type ProcessingFeatureResults, type ProcessingFeatureStage, type ProcessingFeatures, type ProcessingOptions, type RequestOptions, type RetrieveAssetOptions, type RetryAssetOptions, SDK_VERSION, type SdkErrorCode, type SearchAssetsOptions, type SetPolicyAutomaticUpdatesOptions, type SignUploadTokenOptions, type SignedUploadToken, type SignedUrl, type SubmitAssetOptions, type TypedEvent, type UpdateAssetOptions, type UpdateFolderOptions, type UpdateHashListOptions, type UpdatePolicyOptions, type UploadAssetPartOptions, type UploadPresetSubmitAssetOptions, type UploadedAsset, type VerifyWebhookSignatureOptions, type ViewerClaims, type WaitForAssetDecisionOptions, type ReceivedWebhookEventPayload as WebhookEventPayload, type WebhookHeadersInput, type WebhookPayloadInput, getAssetUrl, selectModerationContextItems };
66
+ /**
67
+ * Whether to apply `event` after `lastSequence`, the highest `assetSequence` you have applied for
68
+ * its asset (`null` or `undefined` when none). Deliveries can arrive out of order: an event about
69
+ * an asset is newer only with a higher `assetSequence`, so a retried or repeated delivery of an
70
+ * earlier one returns `false`. Events that aren't about an asset have no sequence and are always
71
+ * new. Store the event's `assetSequence` per `assetId` once you have applied it.
72
+ */
73
+ export declare const isNewerAssetEvent: (event: Pick<ReceivedWebhookEventPayload, "assetSequence">, lastSequence: number | null | undefined) => boolean;
74
+ export { type AddHashListEntryOptions, type AgeRange, type ApiErrorCode, type Asset, type AssetAvailability, type AssetBatchOperation, type AssetChecksums, type AssetChildrenPage, type AssetClassification, type AssetClassificationFailureReason, type AssetClassificationStatus, type AssetContent, type AssetContentOptions, type AssetContentRemovalReason, type AssetContentStatus, type AssetHls, type AssetHlsRendition, type AssetInfo, type AssetModeration, type AssetModerationDecision, type AssetModerationStatus, type AssetPage, type AssetPreview, type AssetRendered, type AssetRenderedKind, type AssetSafetyHold, type AssetSafetyHoldReason, type AssetSearchMatchField, type AssetSearchQuery, type AssetSearchResponse, type AssetSearchResult, type AssetTimelinePage, type AssetTimelineSegment, type AssetType, type AssetUpload, type AssetUploadStatus, type AssetVisibility, type AssignPolicyOptions, type BatchAssetsOptions, type BatchAssetsResponse, type BoundingBox, CALMLENS_ERROR_CODES, CDN_RESOURCES, type CalmLensAppClientOptions, CalmLensError, type CalmLensErrorCode, type CalmLensErrorDetails, type CalmLensErrorOptions, CalmLensServerClient, type CalmLensServerClientOptions, type CdnAssetLocation, type CdnAssetReference, type CdnAssetUrlOptions, type CdnResource, type CdnServeOptions, type CdnTransform, type ClassificationCategories, type ClassificationCategory, type ClassificationCategoryReport, type ClassificationNotEvaluatedReason, type ClassificationQualifierResults, type ClassifyTextOptions, type ConnectionOptions, type CreateFolderOptions, type CreateHashListOptions, type CreateLensOptions, type CreateMultipartUploadPartOptions, type CreatePolicyOptions, type CursorPage, DEFAULT_CDN_BASE_URL, type DecideAssetOptions, type DeleteAssetOptions, type DetectedFace, type DetectedPerson, type EnsureLensOptions, type EnsureLensesOptions, type EventAsset, type EventCategory, type EventFact, type EventFactValues, type EventFacts, type EventSeverity, type EventType, type GetEventsResponse as EventsPage, type ExplainAssetOptions, type ExtractedText, type FileMetadata, type Folder, type FolderIdOptions, type FolderPage, type GetAssetInfoOptions, type HashList, type HashListEntry, type HashListEntryIdOptions, type HashListEntryPage, type HashListIdOptions, type HashListPage, type IdempotencyOptions, type ImageTransformOptions, type IterateAssetChildrenOptions, type IterateAssetTimelineOptions, type IterateAssetsOptions, type IterateFoldersOptions, type IterateHashListEntriesOptions, type IterateHashListsOptions, type IterateLensesOptions, type IteratePoliciesOptions, type Lens, type LensIdOptions, type LensPage, type LensType, type Likelihood, type ListAssetChildrenOptions, type ListAssetTimelineOptions, type ListAssetsOptions, type ListEventsOptions, type ListFoldersOptions, type ListHashListEntriesOptions, type ListHashListsOptions, type ListLensesOptions, type ListPoliciesOptions, MODERATION_CONTEXT_USED_CHARACTERS, MODERATION_CONTEXT_USED_ITEMS, type MetadataItem, type ModerationContext, type ModerationContextItem, type ModerationQualifier, type MoveAssetOptions, type MoveFolderOptions, type MultipartUploadOptions, type MultipartUploadPartOptions, type Policy, type PolicyAction, type PolicyIdOptions, type PolicyPage, type ProcessingFeatureId, type ProcessingFeatureResults, type ProcessingFeatureStage, type ProcessingFeatures, type ProcessingOptions, type RemoveAssetContentOptions, type RequestOptions, type ResetPolicyOptions, type RetrieveAssetOptions, type RetryAssetOptions, SDK_VERSION, type SdkErrorCode, type SearchAssetsOptions, type SetPolicyAutomaticUpdatesOptions, type SignAssetUrlOptions, type SignUploadTokenOptions, type SignedAssetUrl, type SignedUploadToken, type StreamingFeatureOptions, type SubmitAssetOptions, type TypedEvent, type UpdateAssetOptions, type UpdateFolderOptions, type UpdateHashListOptions, type UpdateLensOptions, type UpdatePolicyOptions, type UpgradePolicyOptions, type UploadAssetPartOptions, type UploadPresetSubmitAssetOptions, type UploadedAsset, type VerifyWebhookSignatureOptions, type ViewerClaims, type WaitForAssetDecisionOptions, type ReceivedWebhookEventPayload as WebhookEventPayload, type WebhookHeadersInput, type WebhookPayloadInput, getAssetInfo, selectModerationContextItems };
package/cjs/server.js CHANGED
@@ -1,8 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_ModerationContextLimits = require("./ModerationContextLimits-2nIv7Zh3.js");
2
+ const require_ModerationContextLimits = require("./ModerationContextLimits-BxOmeSqq.js");
3
3
  require("./index.js");
4
- const require_CalmLensServerClient = require("./CalmLensServerClient-BDzTthxE.js");
4
+ const require_CalmLensServerClient = require("./CalmLensServerClient-nfu6_YEW.js");
5
5
  exports.CALMLENS_ERROR_CODES = require_ModerationContextLimits.CALMLENS_ERROR_CODES;
6
+ exports.CDN_RESOURCES = require_ModerationContextLimits.CDN_RESOURCES;
6
7
  exports.CalmLensError = require_ModerationContextLimits.CalmLensError;
7
8
  exports.CalmLensServerClient = require_CalmLensServerClient.CalmLensServerClient;
8
9
  exports.DEFAULT_CDN_BASE_URL = require_ModerationContextLimits.DEFAULT_CDN_BASE_URL;
@@ -13,7 +14,10 @@ exports.WEBHOOK_DELIVERY_HEADER = require_CalmLensServerClient.WEBHOOK_DELIVERY_
13
14
  exports.WEBHOOK_SIGNATURE_HEADER = require_CalmLensServerClient.WEBHOOK_SIGNATURE_HEADER;
14
15
  exports.WEBHOOK_SIGNATURE_TOLERANCE_SECONDS = require_CalmLensServerClient.WEBHOOK_SIGNATURE_TOLERANCE_SECONDS;
15
16
  exports.WEBHOOK_TIMESTAMP_HEADER = require_CalmLensServerClient.WEBHOOK_TIMESTAMP_HEADER;
16
- exports.getAssetUrl = require_ModerationContextLimits.getAssetUrl;
17
+ exports.getAssetInfo = require_ModerationContextLimits.getAssetInfo;
18
+ exports.getEventFact = require_CalmLensServerClient.getEventFact;
19
+ exports.getEventFacts = require_CalmLensServerClient.getEventFacts;
20
+ exports.isNewerAssetEvent = require_CalmLensServerClient.isNewerAssetEvent;
17
21
  exports.isTestWebhookEvent = require_CalmLensServerClient.isTestWebhookEvent;
18
22
  exports.parseWebhookEvent = require_CalmLensServerClient.parseWebhookEvent;
19
23
  exports.selectModerationContextItems = require_ModerationContextLimits.selectModerationContextItems;
@@ -1,2 +1,2 @@
1
- import { a as detectTestImage, c as getImageTestCategories, i as TestInput, l as paintTestImage, n as TEST_INPUT_KEY_PATTERN, o as detectTestTrigger, r as TEST_INPUT_PRESETS, s as generateTestTextCode, t as ClassificationTestSignal, u as testInputForSignal } from "./TestTriggers-D-fwfhEP-hlaP1oW2.js";
2
- export { type ClassificationTestSignal, TEST_INPUT_KEY_PATTERN, TEST_INPUT_PRESETS, type TestInput, detectTestImage, detectTestTrigger, generateTestTextCode, getImageTestCategories, paintTestImage, testInputForSignal };
1
+ import { a as TEST_FACE_AGE_PRESETS, c as TestDetections, d as detectTestTrigger, f as generateTestTextCode, h as testInputForSignal, i as TEST_FACE_AGE_MAX, l as TestInput, m as paintTestImage, n as TEST_DETECTIONS_MAX, o as TEST_INPUT_KEY_PATTERN, p as getImageTestCategories, r as TEST_DETECTION_BOX_MAX, s as TEST_INPUT_PRESETS, t as ClassificationTestSignal, u as detectTestImage } from "./TestTriggers-D0pYHbkr-D5T0VdSn.js";
2
+ export { type ClassificationTestSignal, TEST_DETECTIONS_MAX, TEST_DETECTION_BOX_MAX, TEST_FACE_AGE_MAX, TEST_FACE_AGE_PRESETS, TEST_INPUT_KEY_PATTERN, TEST_INPUT_PRESETS, type TestDetections, type TestInput, detectTestImage, detectTestTrigger, generateTestTextCode, getImageTestCategories, paintTestImage, testInputForSignal };
@@ -1,10 +1,14 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_TestTriggers_DbhsNPdg = require("./TestTriggers-DbhsNPdg-DjvVuc2h.js");
3
- exports.TEST_INPUT_KEY_PATTERN = require_TestTriggers_DbhsNPdg.TEST_INPUT_KEY_PATTERN;
4
- exports.TEST_INPUT_PRESETS = require_TestTriggers_DbhsNPdg.TEST_INPUT_PRESETS;
5
- exports.detectTestImage = require_TestTriggers_DbhsNPdg.detectTestImage;
6
- exports.detectTestTrigger = require_TestTriggers_DbhsNPdg.detectTestTrigger;
7
- exports.generateTestTextCode = require_TestTriggers_DbhsNPdg.generateTestTextCode;
8
- exports.getImageTestCategories = require_TestTriggers_DbhsNPdg.getImageTestCategories;
9
- exports.paintTestImage = require_TestTriggers_DbhsNPdg.paintTestImage;
10
- exports.testInputForSignal = require_TestTriggers_DbhsNPdg.testInputForSignal;
2
+ const require_TestTriggers_BTyXtX0Q = require("./TestTriggers-BTyXtX0Q-ATuFDhLX.js");
3
+ exports.TEST_DETECTIONS_MAX = require_TestTriggers_BTyXtX0Q.TEST_DETECTIONS_MAX;
4
+ exports.TEST_DETECTION_BOX_MAX = require_TestTriggers_BTyXtX0Q.TEST_DETECTION_BOX_MAX;
5
+ exports.TEST_FACE_AGE_MAX = require_TestTriggers_BTyXtX0Q.TEST_FACE_AGE_MAX;
6
+ exports.TEST_FACE_AGE_PRESETS = require_TestTriggers_BTyXtX0Q.TEST_FACE_AGE_PRESETS;
7
+ exports.TEST_INPUT_KEY_PATTERN = require_TestTriggers_BTyXtX0Q.TEST_INPUT_KEY_PATTERN;
8
+ exports.TEST_INPUT_PRESETS = require_TestTriggers_BTyXtX0Q.TEST_INPUT_PRESETS;
9
+ exports.detectTestImage = require_TestTriggers_BTyXtX0Q.detectTestImage;
10
+ exports.detectTestTrigger = require_TestTriggers_BTyXtX0Q.detectTestTrigger;
11
+ exports.generateTestTextCode = require_TestTriggers_BTyXtX0Q.generateTestTextCode;
12
+ exports.getImageTestCategories = require_TestTriggers_BTyXtX0Q.getImageTestCategories;
13
+ exports.paintTestImage = require_TestTriggers_BTyXtX0Q.paintTestImage;
14
+ exports.testInputForSignal = require_TestTriggers_BTyXtX0Q.testInputForSignal;
package/cjs/testing.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { Bt as TypedEvent, D as CalmLensServerClientOptions, E as CalmLensAppClientOptions, Jt as Folder, bt as SignUploadTokenOptions, p as AssetModeration, qt as PermissionGrant, r as Asset, tn as AssetBinaryPayloadInput, xt as SignedUploadToken } from "./CalmLensTypes-COJbOuiv.js";
2
- import { t as CalmLensAppClient } from "./CalmLensAppClient-DDLojj0P.js";
3
- import { l as ApiErrorCode, n as WebhookEventPayload } from "./WebhookPayload-DkukERKE.js";
4
- import { t as CalmLensServerClient } from "./CalmLensServerClient-C-jsjn8m.js";
5
- import { t as ClassificationTestSignal } from "./TestTriggers-D-fwfhEP-hlaP1oW2.js";
1
+ import { D as CalmLensAppClientOptions, It as SignUploadTokenOptions, O as CalmLensServerClientOptions, On as AssetBinaryPayloadInput, Rt as SignedUploadToken, mn as Folder, n as Asset, on as TypedEvent, p as AssetModeration, pn as PermissionGrant } from "./CalmLensTypes-CUB0YYVz.js";
2
+ import { t as CalmLensAppClient } from "./CalmLensAppClient-gG16T2py.js";
3
+ import { l as ApiErrorCode, n as WebhookEventPayload } from "./WebhookPayload-BLT2y_Jy.js";
4
+ import { t as CalmLensServerClient } from "./CalmLensServerClient-BHx3x_nZ.js";
5
+ import { t as ClassificationTestSignal } from "./TestTriggers-D0pYHbkr-D5T0VdSn.js";
6
6
  import "zod";
7
7
  /**
8
8
  * Signs a single-use upload token with `apiKey`, locally. `CalmLensServerClient` and
@@ -42,6 +42,7 @@ declare const ID_PREFIXES: {
42
42
  readonly member: "mem";
43
43
  readonly invitation: "inv";
44
44
  readonly transfer: "xfer";
45
+ readonly assetBatch: "batch";
45
46
  readonly supportTicket: "tkt";
46
47
  readonly supportTicketMessage: "msg";
47
48
  readonly humanReview: "rev";
@@ -83,7 +84,7 @@ export declare class MockDecision {
83
84
  notEvaluated(category: Category): this;
84
85
  /**
85
86
  * The report a decided asset gets, as the API sends it: every category (unflagged ones
86
- * evaluated with score 0), policy-adjusted results and the automated action and
87
+ * evaluated with score 0), policy-adjusted results and the automated status and
87
88
  * `flaggedCategories`. `undefined` for `pending` and `failed`.
88
89
  */
89
90
  report(): Omit<AssetModeration, "status" | "manualReviews"> | undefined;
@@ -184,7 +185,7 @@ type MockReviewDecision = "allowed" | "limited" | "age-restricted" | "blocked" |
184
185
  * method that sends it; `callsTo` and `failNextRequest` also match the others (see
185
186
  * `MockCalmLensCall`).
186
187
  */
187
- declare const MOCK_OPERATIONS: readonly ["assets.list", "assets.iterate", "assets.search", "assets.retrieve", "assets.waitForDecision", "assets.update", "assets.listChildren", "assets.iterateChildren", "assets.create", "assets.classify", "assets.uploadPart", "assets.createSignedUrl", "assets.move", "assets.retry", "assets.explain", "assets.decide", "assets.deleteContent", "assets.delete", "assets.batch", "text.classify", "cdn.serve", "events.list", "events.pages", "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.applyPreset", "policies.setAutomaticUpdates", "policies.delete", "policies.assign", "ensureLens", "ensureLenses"];
188
+ declare const MOCK_OPERATIONS: readonly ["assets.list", "assets.iterate", "assets.search", "assets.retrieve", "assets.waitForDecision", "assets.update", "assets.listChildren", "assets.iterateChildren", "assets.listTimeline", "assets.iterateTimeline", "assets.create", "assets.classify", "assets.uploadPart", "assets.move", "assets.retry", "assets.explain", "assets.decide", "assets.removeContent", "assets.delete", "assets.batch", "text.classify", "cdn.serve", "cdn.getAssetInfo", "cdn.signAssetUrl", "events.list", "events.pages", "folders.list", "folders.iterate", "folders.retrieve", "folders.create", "folders.update", "folders.delete", "folders.move", "hashLists.list", "hashLists.iterate", "hashLists.retrieve", "hashLists.create", "hashLists.update", "hashLists.delete", "hashLists.listEntries", "hashLists.iterateEntries", "hashLists.addEntry", "hashLists.removeEntry", "policies.list", "policies.iterate", "policies.retrieve", "policies.create", "policies.update", "policies.reset", "policies.upgrade", "policies.setAutomaticUpdates", "policies.delete", "policies.retrieveAssigned", "policies.assign", "lenses.list", "lenses.iterate", "lenses.create", "lenses.retrieve", "lenses.update", "lenses.delete", "ensureLens", "ensureLenses"];
188
189
  type MockCalmLensOperation = (typeof MOCK_OPERATIONS)[number];
189
190
  /**
190
191
  * One request a mock client sent, as the in-memory API received it. `operation` is the client
@@ -213,7 +214,7 @@ interface MockCalmLensCall {
213
214
  /**
214
215
  * What a simulated request failure does: `"transport-error"` and `"timeout"` fail the request
215
216
  * like a network failure (`sdk/transport-error`) or a deadline (`sdk/timeout`); an API error
216
- * code, such as `"upload/limit-exceeded"`, answers with that API error and its HTTP status; a
217
+ * code, such as `"usage/free-uploads-exhausted"`, answers with that API error and its HTTP status; a
217
218
  * `CalmLensError` is thrown as is and any other `Error` as the cause of `sdk/transport-error`,
218
219
  * like an exception from `fetch`.
219
220
  */
@@ -227,7 +228,8 @@ interface MockFailureOptions {
227
228
  retryAfter?: number;
228
229
  }
229
230
  /** An event to add to the mock feed; omitted fields get defaults. */
230
- type MockEventInput = Partial<Omit<TypedEvent, "type">> & {
231
+ /** An event to add to the feed; its `assetSequence` is assigned like the API's. */
232
+ type MockEventInput = Partial<Omit<TypedEvent, "type" | "assetSequence">> & {
231
233
  type: TypedEvent["type"];
232
234
  };
233
235
  /** The upload preset settings a `MockCalmLensAppClient` applies, as the API would. */
@@ -237,7 +239,7 @@ interface MockUploadPreset {
237
239
  /** Accepted content types, such as `["image/*"]`. Defaults to any type. */
238
240
  allowedContentTypes?: string[];
239
241
  maxFileSizeInBytes?: number;
240
- /** Return `status` to the uploader. Defaults to `true`. */
242
+ /** Return `classification.moderation.status` to the uploader. Defaults to `true`. */
241
243
  showDecisions?: boolean;
242
244
  /** Defaults to `public`. */
243
245
  visibility?: "public" | "private";
@@ -271,7 +273,6 @@ interface MockCalmLensServerClientOptions extends Omit<CalmLensServerClientOptio
271
273
  * `completeProcessing`, and everything else is `allowed`.
272
274
  */
273
275
  moderate?: MockModerate;
274
- signedUrlBaseUrl?: string;
275
276
  };
276
277
  }
277
278
  /**
@@ -301,6 +302,12 @@ export declare class MockCalmLensServerClient extends CalmLensServerClient {
301
302
  * `callsTo("assets.waitForDecision")` the `assets.retrieve` requests it polls with.
302
303
  */
303
304
  callsTo(operation: MockCalmLensOperation): MockCalmLensCall[];
305
+ /**
306
+ * Fetches a URL of the mock's CDN as a browser would, without the API key: a signed asset URL
307
+ * from `cdn.signAssetUrl` (with a resource appended), or a public one from `cdn.getAssetUrl`.
308
+ * The request is recorded like any other.
309
+ */
310
+ fetchCdn(url: string, init?: RequestInit): Promise<Response>;
304
311
  /** Forgets the requests recorded so far, so `calls` lists only later ones. */
305
312
  clearCalls(): void;
306
313
  /**
@@ -325,7 +332,7 @@ export declare class MockCalmLensServerClient extends CalmLensServerClient {
325
332
  * Applies a reviewer's decision to a stored asset, as the portal or API would: the moderation
326
333
  * status changes (`purged` also removes the content, with reason `requested` and an
327
334
  * `asset.content-removed` event), the review joins `manualReviews`, and an `asset.<decision>`
328
- * event with a `decided-by: reviewer` fact joins the events feed. Rejects with
335
+ * event whose `actor` is a `user` joins the events feed. Rejects with
329
336
  * `asset/not-found` for an unknown asset. It sends no request.
330
337
  */
331
338
  decide(assetId: string, decision: MockReviewDecision): Promise<Asset>;
@@ -334,8 +341,11 @@ export declare class MockCalmLensServerClient extends CalmLensServerClient {
334
341
  * else what `mockOptions.moderate` returns for the `complete` trigger (`allowed` by default).
335
342
  * The asset gets the decision's report, and `asset.classified` and the automated
336
343
  * `asset.<status>` (or `asset.failed`) join the events feed. No review is recorded, so the
337
- * asset can still be moderated again. Rejects with `asset/not-found` for an unknown asset and
338
- * `sdk/invalid-argument` for one that isn't processing. It sends no request.
344
+ * asset can still be moderated again. A decided asset whose re-run (`assets.explain` with
345
+ * `rerun: true`) is still pending gets the decision in place of its old one, unless it is
346
+ * `pending` or `failed`. Rejects with `asset/not-found` for an unknown asset and
347
+ * `sdk/invalid-argument` for one that isn't processing or awaiting a pending re-run. It sends
348
+ * no request.
339
349
  */
340
350
  completeProcessing(assetId: string, decision?: MockAssetOutcome | MockDecision): Promise<Asset>;
341
351
  }