calmlens 0.25.0 → 0.26.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.
Files changed (84) hide show
  1. package/README.md +14 -14
  2. package/bin/calmlens.js +2202 -521
  3. package/cjs/{BrowserUpload-AO2-2U5Z.js → BrowserUpload-DdkcoZLH.js} +1 -1
  4. package/{esm/BrowserUpload-D2lemMIU.d.ts → cjs/BrowserUpload-zYWKtFSs.d.ts} +2 -2
  5. package/cjs/{CalmLensAppClient-nv6qwja0.js → CalmLensAppClient-Gu9mU_66.js} +22 -15
  6. package/{esm/CalmLensAppClient-Dt0t9Bk6.d.ts → cjs/CalmLensAppClient-mTTjqpRc.d.ts} +5 -11
  7. package/cjs/{CalmLensOptionKeys-BvCac9NO.js → CalmLensOptionKeys-BCITGsr9.js} +138 -90
  8. package/cjs/CalmLensServerClient-D5-njsNk.d.ts +357 -0
  9. package/cjs/{CalmLensServerClient-B60kCBCR.js → CalmLensServerClient-DHmAPT1u.js} +283 -303
  10. package/cjs/{CalmLensTypes-BhR7LFDu.d.ts → CalmLensTypes-Df8eBgWB.d.ts} +127 -59
  11. package/cjs/{Core-DSMxC2GL.d.ts → Core-CREGGR0L.d.ts} +10 -3
  12. package/cjs/{Core-Cw4IxFUq.js → Core-DAf9lqe2.js} +30 -12
  13. package/{esm/ModerationContextLimits-Bqr0duav.js → cjs/ModerationContextLimits-D4iwqoN_.js} +858 -28
  14. package/cjs/{ReactUpload--oDFltw2.js → ReactUpload-BNIbpxIH.js} +38 -2
  15. package/cjs/ReactUpload-D4htIz8X.d.ts +27 -0
  16. package/cjs/{UploadController-ObdgTaBl.js → UploadController-B_lKxvpM.js} +16 -3
  17. package/cjs/{WebhookPayload-DLGGOGW6.d.ts → WebhookPayload-DMa6ihHr.d.ts} +152 -3
  18. package/cjs/app.d.ts +5 -5
  19. package/cjs/app.js +20 -2
  20. package/cjs/elements.d.ts +5 -5
  21. package/cjs/elements.js +102 -67
  22. package/cjs/{index-AAWuerkU.d.ts → index-CtpQldn_.d.ts} +2 -2
  23. package/cjs/index.d.ts +4 -4
  24. package/cjs/index.js +19 -1
  25. package/cjs/react-native.d.ts +3 -3
  26. package/cjs/react-native.js +6 -4
  27. package/cjs/react.d.ts +5 -4
  28. package/cjs/react.js +10 -14
  29. package/cjs/server.d.ts +5 -5
  30. package/cjs/server.js +20 -2
  31. package/cjs/testing.d.ts +11 -9
  32. package/cjs/testing.js +72 -41
  33. package/cjs/{ui-CcuGKTcL.d.ts → ui-BwFPFrno.d.ts} +2 -2
  34. package/cjs/{ui-CA16jyfZ.js → ui-CvlJmRYM.js} +6 -4
  35. package/cjs/ui.d.ts +3 -3
  36. package/cjs/ui.js +4 -3
  37. package/cjs/vue.d.ts +15 -8
  38. package/cjs/vue.js +29 -16
  39. package/esm/{BrowserUpload-Co4T6uGk.js → BrowserUpload-BAWYEBd7.js} +1 -1
  40. package/{cjs/BrowserUpload-D2lemMIU.d.ts → esm/BrowserUpload-zYWKtFSs.d.ts} +2 -2
  41. package/esm/{CalmLensAppClient-BRzy4dwn.js → CalmLensAppClient-DNkIZb6x.js} +22 -15
  42. package/{cjs/CalmLensAppClient-Dt0t9Bk6.d.ts → esm/CalmLensAppClient-mTTjqpRc.d.ts} +5 -11
  43. package/esm/{CalmLensOptionKeys-bE3rb5PN.js → CalmLensOptionKeys-CYHJo3nV.js} +133 -91
  44. package/esm/{CalmLensServerClient-_PRi90wI.js → CalmLensServerClient-B1AiR4nv.js} +283 -303
  45. package/esm/CalmLensServerClient-D5-njsNk.d.ts +357 -0
  46. package/esm/{CalmLensTypes-BhR7LFDu.d.ts → CalmLensTypes-Df8eBgWB.d.ts} +127 -59
  47. package/esm/{Core-DSMxC2GL.d.ts → Core-CREGGR0L.d.ts} +10 -3
  48. package/esm/{Core-CtbYmeXG.js → Core-xNBQxZWH.js} +30 -12
  49. package/{cjs/ModerationContextLimits-Cn9RvnZH.js → esm/ModerationContextLimits-DxuPP4uM.js} +475 -285
  50. package/esm/{ReactUpload-B5itHBSF.js → ReactUpload-BWifQdLv.js} +34 -4
  51. package/esm/ReactUpload-D4htIz8X.d.ts +27 -0
  52. package/esm/{UploadController-C7fL3Iz9.js → UploadController-jlJdddyI.js} +11 -4
  53. package/esm/{WebhookPayload-DLGGOGW6.d.ts → WebhookPayload-DMa6ihHr.d.ts} +152 -3
  54. package/esm/app.d.ts +5 -5
  55. package/esm/app.js +3 -3
  56. package/esm/elements.d.ts +5 -5
  57. package/esm/elements.js +102 -68
  58. package/esm/{index-AAWuerkU.d.ts → index-CtpQldn_.d.ts} +2 -2
  59. package/esm/index.d.ts +4 -4
  60. package/esm/index.js +1 -1
  61. package/esm/react-native.d.ts +3 -3
  62. package/esm/react-native.js +5 -5
  63. package/esm/react.d.ts +5 -4
  64. package/esm/react.js +9 -15
  65. package/esm/server.d.ts +5 -5
  66. package/esm/server.js +3 -3
  67. package/esm/styles.css +28 -10
  68. package/esm/svelte/CalmLensUploader.svelte +17 -17
  69. package/esm/svelte/context.js +21 -0
  70. package/esm/svelte/index.d.ts +12 -0
  71. package/esm/svelte/index.js +1 -0
  72. package/esm/testing.d.ts +11 -9
  73. package/esm/testing.js +72 -41
  74. package/esm/{ui-B98AucZA.js → ui-BXzzqh7M.js} +6 -4
  75. package/esm/{ui-CcuGKTcL.d.ts → ui-BwFPFrno.d.ts} +2 -2
  76. package/esm/ui.d.ts +3 -3
  77. package/esm/ui.js +4 -4
  78. package/esm/vue.d.ts +15 -8
  79. package/esm/vue.js +29 -18
  80. package/package.json +16 -6
  81. package/cjs/CalmLensServerClient-7XjQaeKu.d.ts +0 -353
  82. package/cjs/ReactUpload-CW4NzAsh.d.ts +0 -17
  83. package/esm/CalmLensServerClient-7XjQaeKu.d.ts +0 -353
  84. package/esm/ReactUpload-CW4NzAsh.d.ts +0 -17
@@ -0,0 +1,357 @@
1
+ import { d as HashListEntry, u as HashList } from "./Classification-CxRedzgH-C9qlYW_J.js";
2
+ import { $ as FolderIdOptions, At as ResetPolicyOptions, B as CreateHashListOptions, Bt as SubmitAssetOptions, D as BatchAssetsResponse, Dt as RemoveAssetContentOptions, E as BatchAssetsOptions, Et as PolicyPage, Fn as AssetSearchQuery, Ft as SignAssetUrlOptions, G as DeleteAssetOptions, Gt as UpdatePolicyOptions, Ht as UpdateFolderOptions, I as ClassifyTextOptions, It as SignUploadTokenOptions, J as EnsureLensesOptions, Jt as UploadAssetPartOptions, K as DeleteMetadataFieldOptions, Kt as UpdateProjectSettingsOptions, Ln as AssetInfo, Lt as SignedAssetUrl, M as CdnAssetUrlOptions, Mt as RetryAssetOptions, P as CdnServeOptions, Pt as SetPolicyAutomaticUpdatesOptions, Q as ExplainAssetOptions, Rt as SignedUploadToken, St as MoveFolderOptions, T as AssignPolicyOptions, Tt as PolicyIdOptions, U as CreatePolicyOptions, Ut as UpdateHashListOptions, V as CreateLensOptions, Vt as UpdateAssetOptions, W as DecideAssetOptions, Wt as UpdateLensOptions, X as EnsureUploadPresetsOptions, Xt as UploadPresetIdOptions, Y as EnsureMetadataFieldsOptions, Z as EnsureUploadPresetsResponse, Zt as UploadPresetPage, _ as AssetPage, _t as ListHashListsOptions, at as HashListPage, b as AssetTimelinePage, bn as ProjectSettingsResource, bt as ListUploadPresetsOptions, ct as Lens, dt as ListAssetChildrenOptions, en as VerifyWebhookSignatureOptions, et as FolderPage, ft as ListAssetTimelineOptions, gt as ListHashListEntriesOptions, ht as ListFoldersOptions, it as HashListIdOptions, jn as Policy, jt as RetrieveAssetOptions, k as CalmLensServerClientOptions, kt as RequestOptions, lt as LensIdOptions, mt as ListEventsOptions, nn as WaitForAssetDecisionOptions, nt as HashListEntryIdOptions, o as AssetChildrenPage, pt as ListAssetsOptions, q as EnsureLensOptions, qt as UpgradePolicyOptions, r as Asset, rt as HashListEntryPage, sn as GetEventsResponse, t as AddHashListEntryOptions, tt as GetAssetInfoOptions, ut as LensPage, v as AssetSearchResponse, vn as Folder, vt as ListLensesOptions, xt as MoveAssetOptions, yn as MetadataFieldsResource, yt as ListPoliciesOptions, z as CreateFolderOptions } from "./CalmLensTypes-Df8eBgWB.js";
3
+ import { d as ListPromise, l as CalmLensResponse, r as CdnResponse } from "./WebhookPayload-DMa6ihHr.js";
4
+ interface TransportRequest {
5
+ /** The client method sending the request, such as `assets.retrieve`, for hooks and logs. */
6
+ operation?: string;
7
+ method: "GET" | "HEAD" | "POST" | "PUT" | "PATCH" | "DELETE";
8
+ url: string;
9
+ headers?: Record<string, string>;
10
+ body?: BodyInit | null;
11
+ /** Sent as `Idempotency-Key`; it also makes a POST safe to retry. */
12
+ idempotencyKey?: string;
13
+ /** Deadline per attempt in milliseconds, or undefined for none. */
14
+ timeoutMs?: number;
15
+ /** "body": the deadline covers reading the response body. "headers": it ends when headers arrive. */
16
+ deadline: "body" | "headers";
17
+ fetch?: typeof fetch;
18
+ /** Extra fetch options, such as `cache`; credentials, redirects and signals stay the SDK's. */
19
+ init?: RequestInit;
20
+ /** Cancels this request, as well as the client's signal. */
21
+ signal?: AbortSignal;
22
+ /** Overrides the client's `maxRetries` for this request. */
23
+ maxRetries?: number;
24
+ }
25
+ interface LensCache {
26
+ readonly ensuredLenses: Map<string, Lens>;
27
+ readonly pendingEnsureLenses: Map<string, Promise<void>>;
28
+ }
29
+ declare const inspectSymbol: unique symbol;
30
+ /**
31
+ * The CalmLens API client for your server, authenticated with a project API key. Create one per
32
+ * project and reuse it; it holds no connections. Every method takes one options object, then
33
+ * optional `RequestOptions` for that call, and throws `CalmLensError` on failure. Options left
34
+ * out of the constructor come from `CALMLENS_API_KEY`, `CALMLENS_PROJECT_ID`, `CALMLENS_BASE_URL`
35
+ * and `CALMLENS_LOG`. Browsers and apps upload with `CalmLensAppClient` instead.
36
+ */
37
+ declare class CalmLensServerClient {
38
+ #private;
39
+ /**
40
+ * Verifies that a webhook delivery came from CalmLens: checks the `v1=` HMAC-SHA256 in
41
+ * `x-calmlens-signature` over `"<x-calmlens-timestamp>.<raw body>"` and rejects timestamps
42
+ * more than `toleranceSeconds` (default 300) from now, which stops replayed deliveries.
43
+ * Also exported as `verifyWebhookSignature`; `parseWebhookEvent` verifies and parses.
44
+ *
45
+ * @example
46
+ * ```ts
47
+ * const payload = await request.text();
48
+ * const isValid = await CalmLensServerClient.verifyWebhookSignature({
49
+ * payload,
50
+ * headers: request.headers,
51
+ * secret: process.env.CALMLENS_WEBHOOK_SECRET!,
52
+ * });
53
+ * ```
54
+ */
55
+ static verifyWebhookSignature(options: VerifyWebhookSignatureOptions): Promise<boolean>;
56
+ constructor(clientOptions?: CalmLensServerClientOptions, lenses?: LensCache);
57
+ /** Keeps the API key out of `console.log`, `util.inspect` and `JSON.stringify`. */
58
+ [inspectSymbol](): string;
59
+ toJSON(): {
60
+ projectId: string;
61
+ baseUrl: string;
62
+ cdnBaseUrl: string;
63
+ };
64
+ /**
65
+ * Sends any API request with the client's API key, retries, deadlines and error handling, for
66
+ * endpoints or fields this SDK version doesn't cover yet. `path` is relative to the base URL,
67
+ * such as `/assets/asset_123`; `query` and `body` are sent as they are, without the option
68
+ * check the other methods make. GET, HEAD and requests with an `idempotencyKey` are retried.
69
+ * Resolves with the parsed JSON body and its `lastResponse` (`undefined` for an empty body).
70
+ */
71
+ request<T = unknown>(method: TransportRequest["method"], path: string, { query, body, headers }?: {
72
+ query?: Record<string, unknown>;
73
+ body?: unknown;
74
+ headers?: Record<string, string>;
75
+ }, requestOptions?: RequestOptions): Promise<CalmLensResponse<T>>;
76
+ get cdn(): {
77
+ /**
78
+ * Builds an asset's CDN URL without a request: the asset URL, which every resource is a path
79
+ * beneath, or a resource URL when `resource` is given, with its lens or transform and the
80
+ * viewer claims. Use it for public assets; private ones need `cdn.signAssetUrl`. Viewer
81
+ * claims are assertions from your app; CalmLens doesn't verify them.
82
+ */
83
+ getAssetUrl: (urlOptions: CdnAssetUrlOptions) => string;
84
+ /**
85
+ * Signs a private asset's URL on your server, so browsers and apps can load it without an API
86
+ * key until it expires. Every resource is a path beneath it, as beneath a public asset URL;
87
+ * `/original` only when signed with `original: true`. With `resource`, returns that resource's
88
+ * URL beneath the grant; lenses, transforms and viewer claims are appended as `getAssetUrl`
89
+ * appends them and aren't part of the signature.
90
+ */
91
+ signAssetUrl: (signOptions: SignAssetUrlOptions, requestOptions?: RequestOptions) => Promise<CalmLensResponse<SignedAssetUrl>>;
92
+ /**
93
+ * The display info of an asset URL, public or signed (`{url}/info`): its type, size,
94
+ * rendered file, preview and stream, and whether the viewer its claims describe can see it.
95
+ * A server can pass it to `CalmLensAsset` as `info`, so the first render is the real
96
+ * element.
97
+ */
98
+ getAssetInfo: (url: string, options?: Omit<GetAssetInfoOptions, "fetch">) => Promise<AssetInfo>;
99
+ /**
100
+ * Fetches asset content or a preview from the CDN with the client's API key, and returns
101
+ * a `Response` with writable headers as soon as headers arrive, so the body streams.
102
+ * Non-2xx responses are returned, not thrown; `timeoutMs` covers only the wait for headers.
103
+ */
104
+ serve: (options: CdnServeOptions, requestOptions?: RequestOptions) => Promise<CdnResponse>;
105
+ };
106
+ get text(): {
107
+ /**
108
+ * Moderates text and waits for the decision. Sends `text` as `text/plain` content named
109
+ * `text` unless you pass `name`.
110
+ */
111
+ classify: (options: ClassifyTextOptions, requestOptions?: RequestOptions) => Promise<CalmLensResponse<Asset>>;
112
+ };
113
+ /** Assets: uploads, moderation and management. */
114
+ get assets(): {
115
+ /** Searches accessible assets by keyword or a natural-language description. */
116
+ search: (options: Partial<AssetSearchQuery> & {
117
+ query: string;
118
+ }, requestOptions?: RequestOptions) => Promise<CalmLensResponse<AssetSearchResponse>>;
119
+ /**
120
+ * Lists the project's assets, with an optional filter and sort. Await it for one page, or
121
+ * `for await` over it for every matching asset, fetching pages as needed.
122
+ */
123
+ list: (options?: ListAssetsOptions, requestOptions?: RequestOptions) => ListPromise<AssetPage>;
124
+ /** Retrieves an asset with its status and classification results. */
125
+ retrieve: (options: RetrieveAssetOptions, requestOptions?: RequestOptions) => Promise<CalmLensResponse<Asset>>;
126
+ /** Updates an asset's editable fields. */
127
+ update: (options: UpdateAssetOptions, requestOptions?: RequestOptions) => Promise<CalmLensResponse<Asset>>;
128
+ /**
129
+ * Lists the assets extracted from a website or multimedia document. Await it for one page,
130
+ * or `for await` over it for every child.
131
+ */
132
+ listChildren: (options: ListAssetChildrenOptions, requestOptions?: RequestOptions) => ListPromise<AssetChildrenPage>;
133
+ /**
134
+ * Lists an audio or video asset's findings timeline, in time order. Await it for one page,
135
+ * or `for await` over it for every segment.
136
+ * `classification.moderation.timeline.segmentCount` says how many segments there are.
137
+ */
138
+ listTimeline: (options: ListAssetTimelineOptions, requestOptions?: RequestOptions) => ListPromise<AssetTimelinePage>;
139
+ /**
140
+ * Uploads an asset and returns without waiting for its decision (`wait=false`), with
141
+ * `classification.status` `queued`. Retried safely with an `Idempotency-Key`.
142
+ */
143
+ create: (options: SubmitAssetOptions, requestOptions?: RequestOptions) => Promise<CalmLensResponse<Asset>>;
144
+ /**
145
+ * Uploads an asset and waits for its moderation decision. Documents, websites, audio, video
146
+ * and files over 20 MiB sent in parts still finish in the background and return `pending`.
147
+ * Retried safely with an `Idempotency-Key`.
148
+ */
149
+ classify: (options: SubmitAssetOptions, requestOptions?: RequestOptions) => Promise<CalmLensResponse<Asset>>;
150
+ /**
151
+ * Uploads the next part of a multipart upload. Whether the final part waits for the
152
+ * decision was chosen when the upload started; pass `wait` to override it.
153
+ */
154
+ uploadPart: (partOptions: UploadAssetPartOptions, requestOptions?: RequestOptions) => Promise<CalmLensResponse<Asset>>;
155
+ /** Moves an asset into a folder, or to the project root with `folderId: null`. */
156
+ move: (options: MoveAssetOptions, requestOptions?: RequestOptions) => Promise<CalmLensResponse<Asset>>;
157
+ /**
158
+ * Processes an asset that failed (classification status `failed`) again. It returns to
159
+ * `processing` and is
160
+ * moderated like a new upload; its content must still be stored.
161
+ */
162
+ retry: (options: RetryAssetOptions, requestOptions?: RequestOptions) => Promise<CalmLensResponse<Asset>>;
163
+ /**
164
+ * Records a reviewer's decision, replacing the policy's: the asset's moderation status
165
+ * becomes `decision`, the note joins its review history and the matching `asset.<status>`
166
+ * event is sent. An asset still pending moderation can only be blocked or purged. Purging
167
+ * needs `confirmPurge: true` and permanently deletes the stored content.
168
+ */
169
+ decide: (options: DecideAssetOptions, requestOptions?: RequestOptions) => Promise<CalmLensResponse<Asset>>;
170
+ /**
171
+ * Completes the policy evidence behind a decided asset's moderation decision: its
172
+ * `classification.moderation.explanationComplete` becomes `true` and every action stays as
173
+ * decided. With `rerun: true` the asset is moderated again with the project's current policy
174
+ * and an `asset.rerun-requested` event is recorded; use it when the policy has changed since
175
+ * the decision (`asset/policy-changed`). The asset returns unchanged: it keeps its decision
176
+ * until the re-run's is stored, reported by `asset.classified` and `asset.<status>` events,
177
+ * and a failed re-run keeps it. A reviewed asset fails with `asset/reviewed`, and one whose
178
+ * content is gone with `asset/content-unavailable`.
179
+ */
180
+ explain: (options: ExplainAssetOptions, requestOptions?: RequestOptions) => Promise<CalmLensResponse<Asset>>;
181
+ /**
182
+ * Waits until an asset is settled, its `classification.status` `completed` (with its
183
+ * decision in `classification.moderation.decision`) or `failed`, and returns that asset,
184
+ * checking every few seconds. A `queued` or `processing` asset is still waiting, even when a
185
+ * reviewer has already decided it. Rejects with `sdk/timeout` if it is not settled within
186
+ * `timeoutMs` (default 60000). Webhooks report decisions without polling.
187
+ */
188
+ waitForDecision: (waitOptions: WaitForAssetDecisionOptions, requestOptions?: RequestOptions) => Promise<CalmLensResponse<Asset>>;
189
+ /**
190
+ * Removes an asset's stored content (source, preview and retained extracted text) while
191
+ * keeping the asset record, metadata and classification results. The returned asset has
192
+ * `content.status` set to `removed` and `content.removalReason` to `requested`; the CDN no longer serves it.
193
+ */
194
+ removeContent: (options: RemoveAssetContentOptions, requestOptions?: RequestOptions) => Promise<CalmLensResponse<Asset>>;
195
+ /**
196
+ * Deletes an asset record together with its stored content. An asset extracted from another
197
+ * (one with a `parentId`) fails with `asset/child-not-deletable`: delete its parent instead.
198
+ */
199
+ delete: (options: DeleteAssetOptions, requestOptions?: RequestOptions) => Promise<void>;
200
+ /**
201
+ * Deletes up to 500 assets (`operation: "delete"`) or removes their stored content
202
+ * (`"remove-content"`) in one request. Every asset must exist in the project and the key
203
+ * needs `assets:delete` for its folder, and a deletion can't name an asset extracted from
204
+ * another (`asset/child-not-deletable`), or nothing is queued. Resolves with
205
+ * `{ batchId, status: "queued", assetCount }` once queued; the work runs in the background
206
+ * and records `asset.deleted` or `asset.content-removed` for each asset, with a `batch-id`
207
+ * fact naming `batchId`. Assets under a safety hold are skipped. Not retried: it carries no
208
+ * `Idempotency-Key`.
209
+ */
210
+ batch: (options: BatchAssetsOptions, requestOptions?: RequestOptions) => Promise<CalmLensResponse<BatchAssetsResponse>>;
211
+ };
212
+ /**
213
+ * Signs upload tokens on your server, so a browser or app can upload through an upload preset
214
+ * that requires one. Signing happens locally with your API key: it makes no request.
215
+ */
216
+ get uploadTokens(): {
217
+ /**
218
+ * Signs a single-use token for one upload through `uploadPresetId`. Give `token` to the
219
+ * browser or app, which passes it to `CalmLensAppClient` as `token`.
220
+ */
221
+ sign: (options: SignUploadTokenOptions) => Promise<SignedUploadToken>;
222
+ };
223
+ get events(): {
224
+ /**
225
+ * Lists project events after a cursor, oldest first. Call without `cursor` to get a cursor
226
+ * for "now", then poll with each response's `nextCursor`. Webhook deliveries carry each
227
+ * event's same fields as a flat JSON body. `types` and `assetId` narrow the feed to some
228
+ * event types or one asset's events; a cursor belongs to the filters it was issued with, so
229
+ * pass the same ones with each `cursor`. `for await` over it yields every event waiting
230
+ * after `cursor`; save the last page's `nextCursor` to resume later.
231
+ */
232
+ list: (options?: ListEventsOptions, requestOptions?: RequestOptions) => ListPromise<GetEventsResponse>;
233
+ };
234
+ get folders(): {
235
+ /**
236
+ * Lists the child folders of `parentId` (or the project root), sorted by name unless
237
+ * `sort` says otherwise. Await it for one page, or `for await` over it for every folder;
238
+ * fetch a branch when it is opened.
239
+ */
240
+ list: (options?: ListFoldersOptions, requestOptions?: RequestOptions) => ListPromise<FolderPage>;
241
+ retrieve: (options: FolderIdOptions, requestOptions?: RequestOptions) => Promise<CalmLensResponse<Folder>>;
242
+ /** Creates a folder at the project root or inside `parentId`. */
243
+ create: (options: CreateFolderOptions, requestOptions?: RequestOptions) => Promise<CalmLensResponse<Folder>>;
244
+ update: (options: UpdateFolderOptions, requestOptions?: RequestOptions) => Promise<CalmLensResponse<Folder>>;
245
+ /** Deletes an empty folder; throws `folder/not-empty` otherwise. */
246
+ delete: (options: FolderIdOptions, requestOptions?: RequestOptions) => Promise<void>;
247
+ /** Moves a folder under `parentId`, or to the project root with `parentId: null`. */
248
+ move: (options: MoveFolderOptions, requestOptions?: RequestOptions) => Promise<CalmLensResponse<Folder>>;
249
+ };
250
+ /**
251
+ * Hash lists hold PDQ hashes of images the project never wants again. Image uploads are
252
+ * compared with every list: `flag` lists record matches, `block` lists also block close ones.
253
+ */
254
+ get hashLists(): {
255
+ /** Lists the project's hash lists, newest first unless `sort` says otherwise. */
256
+ list: (options?: ListHashListsOptions, requestOptions?: RequestOptions) => ListPromise<HashListPage>;
257
+ retrieve: (options: HashListIdOptions, requestOptions?: RequestOptions) => Promise<CalmLensResponse<HashList>>;
258
+ create: (options: CreateHashListOptions, requestOptions?: RequestOptions) => Promise<CalmLensResponse<HashList>>;
259
+ /** Renames a list or changes its action; the new action applies to later uploads. */
260
+ update: (options: UpdateHashListOptions, requestOptions?: RequestOptions) => Promise<CalmLensResponse<HashList>>;
261
+ /** Deletes the list and every entry in it. */
262
+ delete: (options: HashListIdOptions, requestOptions?: RequestOptions) => Promise<void>;
263
+ /** Lists a list's entries, newest first unless `sort` says otherwise. */
264
+ listEntries: (options: ListHashListEntriesOptions, requestOptions?: RequestOptions) => ListPromise<HashListEntryPage>;
265
+ /** Adds a hash, or an image asset's hash; a hash already in the list returns its entry. */
266
+ addEntry: (options: AddHashListEntryOptions, requestOptions?: RequestOptions) => Promise<CalmLensResponse<HashListEntry>>;
267
+ removeEntry: (options: HashListEntryIdOptions, requestOptions?: RequestOptions) => Promise<void>;
268
+ };
269
+ /**
270
+ * Moderation policies belong to the organisation and its projects share them. Every change sends
271
+ * the policy's `revision`, so a policy changed since is refused. Through a project's key you can
272
+ * change only policies no other project uses.
273
+ */
274
+ get policies(): {
275
+ /** Lists the organisation's policies, oldest first unless `sort` says otherwise. */
276
+ list: (options?: ListPoliciesOptions, requestOptions?: RequestOptions) => ListPromise<PolicyPage>;
277
+ retrieve: (options: PolicyIdOptions, requestOptions?: RequestOptions) => Promise<CalmLensResponse<Policy>>;
278
+ /** Creates a policy from `settings`, or a copy of a built-in preset with `presetId`. */
279
+ create: (options: CreatePolicyOptions, requestOptions?: RequestOptions) => Promise<CalmLensResponse<Policy>>;
280
+ /** Changes the name, description or settings; later moderation uses them. */
281
+ update: (options: UpdatePolicyOptions, requestOptions?: RequestOptions) => Promise<CalmLensResponse<Policy>>;
282
+ /** Restores the settings of the preset release a `pinned` or `copy` policy is pinned to. */
283
+ reset: (options: ResetPolicyOptions, requestOptions?: RequestOptions) => Promise<CalmLensResponse<Policy>>;
284
+ /** Moves an unchanged `pinned` or `copy` policy to the latest release of its preset. */
285
+ upgrade: (options: UpgradePolicyOptions, requestOptions?: RequestOptions) => Promise<CalmLensResponse<Policy>>;
286
+ /** Switches automatic updates on (`live`) or off (`pinned`) for the organisation's own preset policy. */
287
+ setAutomaticUpdates: (options: SetPolicyAutomaticUpdatesOptions, requestOptions?: RequestOptions) => Promise<CalmLensResponse<Policy>>;
288
+ /** Deletes a policy that no project or upload preset uses. */
289
+ delete: (options: PolicyIdOptions, requestOptions?: RequestOptions) => Promise<void>;
290
+ /** The policy the project moderates with. */
291
+ retrieveAssigned: (requestOptions?: RequestOptions) => Promise<CalmLensResponse<Policy>>;
292
+ /** Chooses the policy the project moderates with. */
293
+ assign: (options: AssignPolicyOptions, requestOptions?: RequestOptions) => Promise<CalmLensResponse<Policy>>;
294
+ };
295
+ /**
296
+ * The project's upload presets: the rules for uploads from browsers and apps. `ensure` creates or
297
+ * replaces presets by key, for deploys that declare them in code; send each preset's `revision`
298
+ * to refuse a change made since you read it.
299
+ */
300
+ get uploadPresets(): {
301
+ /** Lists the project's upload presets, oldest first unless `sort` says otherwise. */
302
+ list: (options?: ListUploadPresetsOptions, requestOptions?: RequestOptions) => ListPromise<UploadPresetPage>;
303
+ /**
304
+ * Creates each preset, or replaces it with the definition sent, by key. Every preset is
305
+ * checked before any is saved. Returns the stored presets in the order sent.
306
+ */
307
+ ensure: (options: EnsureUploadPresetsOptions, requestOptions?: RequestOptions) => Promise<CalmLensResponse<EnsureUploadPresetsResponse>>;
308
+ /** Deletes an upload preset; assets already uploaded through it stay. */
309
+ delete: (options: UploadPresetIdOptions, requestOptions?: RequestOptions) => Promise<void>;
310
+ };
311
+ /**
312
+ * The project's settings, with defaults filled in. `update` replaces them: settings left out
313
+ * return to their defaults. Send the `revision` you read to refuse a change made since.
314
+ */
315
+ get projectSettings(): {
316
+ get: (requestOptions?: RequestOptions) => Promise<CalmLensResponse<ProjectSettingsResource>>;
317
+ update: (options: UpdateProjectSettingsOptions, requestOptions?: RequestOptions) => Promise<CalmLensResponse<ProjectSettingsResource>>;
318
+ };
319
+ /**
320
+ * The project's metadata fields. They share the project settings' `revision`; `ensure` creates
321
+ * or replaces fields by ID and keeps the others.
322
+ */
323
+ get metadataFields(): {
324
+ list: (requestOptions?: RequestOptions) => Promise<CalmLensResponse<MetadataFieldsResource>>;
325
+ ensure: (options: EnsureMetadataFieldsOptions, requestOptions?: RequestOptions) => Promise<CalmLensResponse<MetadataFieldsResource>>;
326
+ /** Deletes a field definition; assets keep their values. */
327
+ delete: (options: DeleteMetadataFieldOptions, requestOptions?: RequestOptions) => Promise<void>;
328
+ };
329
+ /**
330
+ * The project's lenses: named image transforms the CDN applies at `/@<identifier>`. The CDN
331
+ * serves files made with each lens's current definition. `ensureLenses` creates or changes
332
+ * lenses by identifier, for applications that declare theirs in code.
333
+ */
334
+ get lenses(): {
335
+ /** Lists the project's lenses, newest first unless `sort` says otherwise. */
336
+ list: (options?: ListLensesOptions, requestOptions?: RequestOptions) => ListPromise<LensPage>;
337
+ /** Creates a lens; its identifier must be new to the project. */
338
+ create: (options: CreateLensOptions, requestOptions?: RequestOptions) => Promise<CalmLensResponse<Lens>>;
339
+ retrieve: (options: LensIdOptions, requestOptions?: RequestOptions) => Promise<CalmLensResponse<Lens>>;
340
+ /** Changes a lens's name, description, type, transform or whether the CDN serves it. */
341
+ update: (options: UpdateLensOptions, requestOptions?: RequestOptions) => Promise<CalmLensResponse<Lens>>;
342
+ /** Deletes a lens; URLs that select it stop being served. */
343
+ delete: (options: LensIdOptions, requestOptions?: RequestOptions) => Promise<void>;
344
+ };
345
+ /**
346
+ * Creates a named lens, or changes it to this definition. Sending the same definition again
347
+ * returns the lens unchanged, from the client's lens cache once it has seen it.
348
+ */
349
+ ensureLens(options: EnsureLensOptions, requestOptions?: RequestOptions): Promise<Lens>;
350
+ /**
351
+ * Create or update several named lenses. New definitions are sent in one API request, or in
352
+ * consecutive requests of at most {@link ENSURE_LENSES_MAX_PER_REQUEST} definitions, in order.
353
+ * Each lens is created or changed as ensureLens() does.
354
+ */
355
+ ensureLenses(options: EnsureLensesOptions, requestOptions?: RequestOptions): Promise<Lens[]>;
356
+ }
357
+ export { CalmLensServerClient as t };