calmlens 0.25.0 → 0.27.3

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.
data/sig/types.rbs CHANGED
@@ -1,12 +1,9 @@
1
- # Request and response shapes of the CalmLens API, mirroring the Zod schemas in packages/shared/src.
1
+ # Enums and option shapes of the CalmLens API, mirroring the Zod schemas in packages/shared/src.
2
+ # Results are model classes, generated in sig/models.rbs.
2
3
  #
3
- # Options (`*_options`, `*_input`) are the snake_case Symbol keys the SDK documents. At runtime the
4
- # SDK also accepts camelCase and String keys, which these records do not describe.
5
- #
6
- # Responses keep the API's camelCase String keys. Fields marked optional (`?"key"`) can be missing
7
- # from the JSON; `T?` values can be null. Records whose variants differ by `status` (category,
8
- # qualifier and feature results) are one record with every variant's keys optional, because Steep
9
- # cannot narrow a union of records on a key's value: read `status` first, then the keys it names.
4
+ # Options (`*_input`) are snake_case Symbol keys; nested ones may also take the API's camelCase
5
+ # String keys, as a result's `to_h` gives them. Fields marked optional (`?key:`) can be left out;
6
+ # `T?` values can be null.
10
7
  module CalmLens
11
8
  # Any JSON value the API returns where it allows arbitrary JSON (metadata values, error details).
12
9
  type json_value = String | Integer | Float | bool | nil | Array[json_value] | Hash[String, json_value]
@@ -22,7 +19,12 @@ module CalmLens
22
19
  ?open_timeout: number,
23
20
  ?upload_timeout: number,
24
21
  ?max_retries: Integer,
25
- ?max_response_bytes: Integer
22
+ ?max_response_bytes: Integer,
23
+ # Extra headers; the client's API key and user agent can't be replaced.
24
+ ?headers: Hash[String, String],
25
+ # Query parameters and JSON body fields added to the request, for API fields this release lacks.
26
+ ?extra_query: Hash[String | Symbol, untyped],
27
+ ?extra_body: Hash[String | Symbol, untyped]
26
28
  }
27
29
 
28
30
  # ---- Assets (Asset.ts) ----------------------------------------------------------------------
@@ -36,9 +38,6 @@ module CalmLens
36
38
  # URLs or API keys (`age-restricted`), not served (`blocked`), or not served with the stored
37
39
  # content deleted (`purged`).
38
40
  type asset_moderation_decision = "allowed" | "limited" | "age-restricted" | "blocked" | "purged"
39
- # The decision in force: `pending` until classification decides, then a reviewer's decision when
40
- # there is one, else the policy's.
41
- type asset_moderation_status = "pending" | asset_moderation_decision
42
41
  # Whether CalmLens holds the content: only until processing finishes, retained, or deleted.
43
42
  type asset_content_status = "temporary" | "stored" | "removed"
44
43
  type asset_content_removal_reason = "policy" | "retention" | "requested" | "parent-removed" | "disposed"
@@ -49,14 +48,10 @@ module CalmLens
49
48
  # FLAGGED_CONTENT_ACTION_SCHEMA in PolicyRule.ts.
50
49
  type flagged_content_action = "allow" | "limit" | "age-restrict" | "block" | "purge"
51
50
 
52
- # A custom metadata item. `value` is any JSON value you chose.
53
- type metadata_item = { "id" => String, "value" => json_value }
54
51
  # A metadata item to send. Keys inside `metadata` are sent unchanged, so use `id:` and `value:`.
55
52
  type metadata_item_input = { id: String, value: json_input }
56
53
  # An earlier post in the conversation, as the API returns it.
57
54
  type moderation_context_item = { "text" => String, ?"authorId" => String }
58
- # Earlier posts in the conversation, oldest first.
59
- type moderation_context = { "items" => Array[moderation_context_item] }
60
55
  # An earlier post to send. `author_id` is your identifier for who wrote it.
61
56
  type moderation_context_item_input = { text: String, ?author_id: String }
62
57
  # Earlier posts to send, oldest first; only the posts CalmLens uses are sent.
@@ -82,219 +77,13 @@ module CalmLens
82
77
  ?features: processing_features_input?
83
78
  }
84
79
 
85
- type checksums = {
86
- ?"md5" => String?,
87
- ?"sha1" => String?,
88
- ?"sha256" => String?,
89
- ?"sha384" => String?,
90
- ?"sha512" => String?
91
- }
92
- # One rendition of an adaptive stream: `video` for a picture size (video renditions carry no sound;
93
- # they play with the `audio` rendition), or `audio`. `bandwidth` is the peak bit rate in bits per
94
- # second, counting the audio a video rendition plays with; `codecs` are RFC 6381 names.
95
- type asset_hls_rendition = {
96
- "kind" => "video" | "audio",
97
- "width" => Integer?,
98
- "height" => Integer?,
99
- "bandwidth" => Integer,
100
- "codecs" => String
101
- }
102
- # Preview. The adaptive stream of audio or video: HLS with fragmented MP4 (CMAF) segments, served
103
- # at the CDN's `hls` resource (`hls/index.m3u8`) and played by its `embed` resource. Renditions list
104
- # video from the largest down, then audio.
105
- type asset_hls = {
106
- "status" => String,
107
- "reason" => String?,
108
- "renditions" => Array[asset_hls_rendition]
109
- }
80
+ # Why there is no stream: the streaming allowance is used up, billing or the spend limit stops it,
81
+ # preparing it failed, or the content was not kept.
82
+ type asset_hls_unavailable_reason = "allowance-used" | "billing-required" | "spend-limit" | "processing-failed" | "content-not-kept"
110
83
  type asset_rendered_kind = "image" | "pdf" | "video" | "audio"
111
- # The asset's one displayable file, as the CDN's `rendered` resource serves it: an image, a PDF, or
112
- # browser-safe video or audio. `peaks` is an audio waveform's normalised peaks.
113
- type asset_rendered = {
114
- "kind" => asset_rendered_kind,
115
- "format" => String,
116
- "width" => Integer?,
117
- "height" => Integer?,
118
- ?"peaks" => Array[Float]
119
- }
120
- # The still image that stands for the asset, as the CDN's `preview` resource serves it; the
121
- # `placeholder` resource is its ThumbHash as a small blurred PNG.
122
- type asset_preview = {
123
- "width" => Integer?,
124
- "height" => Integer?,
125
- "thumbhash" => String?,
126
- "averageColor" => String?
127
- }
128
- type safety_hold = { "placedAt" => Integer, "reason" => "suspected-illegal-content", ?"disposedAt" => Integer? }
129
- # `type: "string"` carries the text in `content`; `type: "document"` stores it under `id`.
130
- type extracted_text = { "type" => "string" | "document", ?"content" => String, ?"id" => String }
131
- # Descriptive metadata embedded in an uploaded file. `capturedAt` is ISO 8601, with a UTC offset
132
- # only when the file records one. `digitalSourceType` is the IPTC code the file declares, such as
133
- # `digitalCapture`. `containsLocation` says whether the uploaded file embedded GPS coordinates;
134
- # `creator` and `location` are sensitive and recorded only when `storeSensitiveMetadata` is on.
135
- type file_metadata_location = { "latitude" => number, "longitude" => number }
136
- type file_metadata = {
137
- "capturedAt" => String?,
138
- "cameraMake" => String?,
139
- "cameraModel" => String?,
140
- "lensModel" => String?,
141
- "software" => String?,
142
- "creator" => String?,
143
- "copyright" => String?,
144
- "digitalSourceType" => String?,
145
- "containsLocation" => bool,
146
- "location" => file_metadata_location?
147
- }
148
84
 
149
- type asset_upload = { "status" => "uploading" | "completed", "updatedAt" => Integer?, "partsReceived" => Integer? }
150
- # How many sections of long audio or video are analysed so far.
151
- type classification_progress = { "completedSections" => Integer, "totalSections" => Integer }
152
- type asset_classification = {
153
- "status" => asset_classification_status,
154
- # `null` unless `status` is `failed`.
155
- "failureReason" => asset_classification_failure_reason?,
156
- "updatedAt" => Integer?,
157
- "completedAt" => Integer?,
158
- # While long audio or video is analysed in sections and `status` is `processing`: how many of its
159
- # sections are done. `nil` otherwise.
160
- "progress" => classification_progress?,
161
- # Whether the results came from one of the project's test inputs rather than analysing the
162
- # content. Never use test results, such as age ranges, for real decisions.
163
- "testInput" => bool,
164
- "moderation" => asset_moderation,
165
- # OCR's result for an image processed with OCR turned on; `nil` when OCR didn't run.
166
- "ocr" => ocr_result?,
167
- # Link detection's result for an image; `nil` when it didn't run.
168
- "linkDetection" => link_detection_result?,
169
- # Preview. Person and face detection's results; `nil` when they didn't run.
170
- ?"personDetection" => person_detection_result?,
171
- ?"faceDetection" => face_detection_result?,
172
- # Preview. Where the asset's links lead when the project's policy acts on links; otherwise `nil`.
173
- ?"linkSafety" => link_safety_result?,
174
- ?"aiGeneratedDetection" => ai_generated_detection_result?
175
- }
176
- # Who made a review: a person (`user`, also when an assistant's key acts for one) or an API key
177
- # (`api-key`), with the user's or API key's ID, `nil` only when it was not recorded.
178
- type review_actor = { "type" => "user" | "api-key", "id" => String? }
179
- type asset_review = {
180
- "id" => String,
181
- "decision" => asset_moderation_decision,
182
- "note" => String?,
183
- "decidedBy" => review_actor,
184
- "reviewedAt" => Integer,
185
- # Whether the decision was applied to the asset; `false` for a review queue decision recorded
186
- # without changing the asset's status.
187
- "applied" => bool
188
- }
189
- # A stricter delivery decision in one region the project serves: the status in force there, the
190
- # mandatory rule that sets it and the category whose findings it acted on, when it acts on one.
191
- type regional_decision = {
192
- "region" => String,
193
- "status" => "limited" | "age-restricted" | "blocked" | "purged",
194
- "rule" => String,
195
- ?"category" => String
196
- }
197
- # What decided the automated status: the `policy`'s categories, the asset's `children`, a
198
- # `hash-list` match, a `mandatory-rule` or `link-safety`.
199
- type moderation_source = "policy" | "children" | "hash-list" | "mandatory-rule" | "link-safety"
200
- # The policy that made a decision: its ID, its revision then and, for a policy from a preset, the
201
- # preset release it used.
202
- type decision_policy = {
203
- "id" => String,
204
- "revision" => Integer,
205
- "preset" => { "id" => String, "version" => Integer }?
206
- }
207
- # A review the human review queue is waiting for: when the asset joined it (Unix milliseconds),
208
- # why, and the categories that made the decision uncertain.
209
- type asset_pending_review = {
210
- "requestedAt" => Integer,
211
- "reason" => "sampled" | "uncertain",
212
- "uncertainCategories" => Array[String]
213
- }
214
- # Every field but `status`, `manualReviews`, `flaggedCategories`, `regions` and `timeline` is `nil`
215
- # until moderation decides; `pendingReview` is `nil` when no review is waiting.
216
- type asset_moderation = {
217
- "manualReviews" => Array[asset_review],
218
- "status" => asset_moderation_status,
219
- # The policy's original decision; a reviewer's decision can change `status` without changing it.
220
- "automatedStatus" => asset_moderation_decision?,
221
- # The policy that made the automated decision, as it was then.
222
- "policy" => decision_policy?,
223
- # The review the human review queue is waiting for, set with the automated decision that
224
- # joined the queue; `nil` when no review is waiting.
225
- "pendingReview" => asset_pending_review?,
226
- "source" => moderation_source?,
227
- # The mandatory rule that decided, when `source` is `mandatory-rule`; otherwise `nil`.
228
- "rule" => String?,
229
- "flaggedCategories" => Array[String], "regions" => Array[regional_decision],
230
- "explanationComplete" => bool?,
231
- "categories" => Hash[String, category_policy_score]?,
232
- # Preview. What the policy's link-safety section made of the asset's links; `nil` when the
233
- # policy doesn't act on links.
234
- ?"linkSafety" => link_safety_decision?,
235
- # An audio or video asset's findings timeline: how many segments `assets.list_timeline` lists.
236
- # `null` for other assets and media without findings.
237
- "timeline" => moderation_timeline?,
238
- "raw" => moderation_raw?
239
- }
240
- # ASSET_CONTENT_SCHEMA. `format` is the MIME type.
241
- type asset_content = {
242
- "status" => asset_content_status,
243
- "removalReason" => asset_content_removal_reason?,
244
- "updatedAt" => Integer?,
245
- "safetyHold" => safety_hold?,
246
- "format" => String?,
247
- "extension" => String?,
248
- "sizeInBytes" => Integer?,
249
- "checksums" => checksums?,
250
- # The file's own size, length and page count, where they apply; `null` when unknown.
251
- "width" => Integer?,
252
- "height" => Integer?,
253
- "durationSeconds" => Float?,
254
- "pageCount" => Integer?,
255
- "perceptualHash" => String?,
256
- # How much detail `perceptualHash` captured, from 0 to 100; hashes below 50 match unrelated pictures.
257
- "perceptualHashQuality" => Integer?,
258
- # Metadata embedded in the uploaded file; `null` when it declares none, once the content is
259
- # removed and while the asset is held.
260
- "metadata" => file_metadata?,
261
- "extractedText" => extracted_text?,
262
- # `null` until processing makes it, for text, spreadsheets and other files, once the content is
263
- # removed and while the asset is held.
264
- "rendered" => asset_rendered?,
265
- # Preview. The adaptive stream once streaming has prepared one for audio or video; `nil` for
266
- # other assets, until then, once the content is removed and while the asset is held.
267
- "hls" => asset_hls?,
268
- "preview" => asset_preview?
269
- }
270
-
271
- type asset = {
272
- "id" => String,
273
- "projectId" => String,
274
- ?"parentId" => String?,
275
- # The pages of the parent document a child shows, from 1; empty when unknown or not a child.
276
- ?"parentPages" => Array[Integer],
277
- ?"folderId" => String?,
278
- ?"uploadPresetId" => String?,
279
- "createdAt" => Integer,
280
- ?"updatedAt" => Integer,
281
- "name" => String,
282
- ?"description" => String?,
283
- ?"externalId" => String?,
284
- ?"externalUrl" => String?,
285
- "type" => asset_type,
286
- # Empty when the asset has none.
287
- "metadata" => Array[metadata_item],
288
- ?"authorId" => String?,
289
- # The earlier posts CalmLens used; null once the content is removed.
290
- ?"context" => moderation_context?,
291
- # Empty when the asset has none.
292
- "tags" => Array[String],
293
- "visibility" => asset_visibility,
294
- "upload" => asset_upload,
295
- "classification" => asset_classification,
296
- "content" => asset_content
297
- }
85
+ # The regions whose laws set mandatory delivery rules.
86
+ type moderation_region = "DE" | "AT" | "FR" | "GB" | "EU" | "AU" | "BR"
298
87
 
299
88
  # ---- Moderation report (Classification.ts, ProcessingFeatures.ts) ----------------------------
300
89
 
@@ -305,9 +94,10 @@ module CalmLens
305
94
  # a child asset with its own result (`assets.list_children`).
306
95
  type feature_not_evaluated_reason = not_evaluated_reason | "in-children"
307
96
  type classification_category = "sexual" | "violence" | "self-harm" | "harassment" | "hate" | "criminal-activity"
97
+ | "personal-information" | "profanity"
308
98
 
309
- # `status: "evaluated"` carries `someScore`, `likelihood` and optionally `allScore`;
310
- # `status: "not-evaluated"` carries `reason`.
99
+ # One qualifier's result, the values of qualifiers.rbs's qualifier_results (written by
100
+ # packages/sdk-contract/generate.ts). Results read them as {QualifierResult} models.
311
101
  type qualifier_result = {
312
102
  "status" => "evaluated" | "not-evaluated",
313
103
  ?"someScore" => number,
@@ -315,157 +105,9 @@ module CalmLens
315
105
  ?"likelihood" => likelihood,
316
106
  ?"reason" => not_evaluated_reason
317
107
  }
318
- # qualifier_results is generated in qualifiers.rbs.
319
108
 
320
- # `status: "evaluated"` or `"partial"` carries `likelihood` and `score`; `"not-evaluated"`
321
- # carries `reason`.
322
- type category_report = {
323
- "status" => "evaluated" | "partial" | "not-evaluated",
324
- ?"likelihood" => likelihood,
325
- ?"score" => number,
326
- ?"reason" => not_evaluated_reason,
327
- ?"qualifiers" => qualifier_results
328
- }
329
- type classification_categories = {
330
- "sexual" => category_report,
331
- "violence" => category_report,
332
- "self-harm" => category_report,
333
- "harassment" => category_report,
334
- "hate" => category_report,
335
- "criminal-activity" => category_report,
336
- "personal-information" => category_report,
337
- "profanity" => category_report
338
- }
339
- type media_segment = {
340
- "source" => "frame" | "speech" | "frame-text" | "clip",
341
- "startSeconds" => number,
342
- "endSeconds" => number,
343
- "categories" => classification_categories
344
- }
345
-
346
- # Position and size as fractions of the image width and height, from 0 to 1.
347
- type bounding_box = { "left" => number, "top" => number, "width" => number, "height" => number }
348
- type age_range = { "low" => Integer, "high" => Integer }
349
- type detected_person = { "box" => bounding_box, "confidence" => number }
350
- type detected_face = { "box" => bounding_box, "confidence" => number, ?"ageRange" => age_range }
351
- # `status: "evaluated"` carries `people`; `"not-evaluated"` carries `reason`.
352
- type person_detection_result = {
353
- "status" => "evaluated" | "not-evaluated",
354
- ?"people" => Array[detected_person],
355
- ?"reason" => feature_not_evaluated_reason
356
- }
357
- # `status: "evaluated"` carries `faces`; `"not-evaluated"` carries `reason`.
358
- type face_detection_result = {
359
- "status" => "evaluated" | "not-evaluated",
360
- ?"faces" => Array[detected_face],
361
- ?"reason" => feature_not_evaluated_reason
362
- }
363
- type detected_qr_code = { "value" => String, "box" => bounding_box }
364
- # A web link found in a QR code or in the text OCR extracted.
365
- type detected_link = { "url" => String, "source" => "qr-code" | "text" }
366
- # `status: "evaluated"` carries `qrCodes` and `links`; `"not-evaluated"` carries `reason`.
367
- type link_detection_result = {
368
- "status" => "evaluated" | "not-evaluated",
369
- ?"qrCodes" => Array[detected_qr_code],
370
- ?"links" => Array[detected_link],
371
- ?"reason" => feature_not_evaluated_reason
372
- }
373
- # Link safety (preview, LinkSafety.ts).
374
- # What a link's destination is: `safe` when every reputation check passed, `adult` or `gambling`
375
- # from its domain's content categories, `phishing` or `malware` from a threat list or the domain's
376
- # security risks, and `unresolved` when a short link or redirect chain could not be followed or a
377
- # check failed. Every address on a link's way is checked, and the most severe verdict is the
378
- # link's.
379
- type link_safety_verdict = "safe" | "adult" | "gambling" | "phishing" | "malware" | "unresolved"
380
- # The verdicts a policy can act on.
381
- type flagged_link_verdict = "phishing" | "malware" | "adult" | "gambling" | "unresolved"
382
109
  # What a link does to its asset, weakest first. Purging content over a link is never offered.
383
110
  type link_safety_action = "allow" | "limit" | "age-restrict" | "block"
384
- # One reputation check of a link, every address it redirects through and its destination: their
385
- # domain categories, or a threat-list lookup of their URLs. `failed` makes the link `unresolved`;
386
- # `labels` is what the check reported for any of the addresses.
387
- type link_safety_evidence = {
388
- "check" => "domain-categories" | "threat-lists",
389
- "status" => "checked" | "failed",
390
- "labels" => Array[String]
391
- }
392
- # A link in the asset and what its destination is. `finalUrl` is where it leads after `redirects`
393
- # redirects, or `null` when a short link or redirect chain could not be
394
- # followed.
395
- type checked_link = {
396
- "url" => String,
397
- "finalUrl" => String?,
398
- "redirects" => Integer,
399
- "source" => "qr-code" | "text",
400
- "verdict" => link_safety_verdict,
401
- "evidence" => Array[link_safety_evidence]
402
- }
403
- # Preview. `status: "evaluated"` carries `links`; `"not-evaluated"` carries `reason`.
404
- type link_safety_result = {
405
- "status" => "evaluated" | "not-evaluated",
406
- ?"links" => Array[checked_link],
407
- ?"reason" => not_evaluated_reason
408
- }
409
- # Preview. LINK_SAFETY_SETTINGS_SCHEMA: the action for an asset with a link of each verdict (a
410
- # verdict left out is allowed), and optionally an action for every link whose destination is
411
- # outside `allowedDomains` (bare lowercase domains, which also cover their subdomains).
412
- type link_safety_settings = {
413
- "verdictActions" => {
414
- ?"phishing" => link_safety_action,
415
- ?"malware" => link_safety_action,
416
- ?"adult" => link_safety_action,
417
- ?"gambling" => link_safety_action,
418
- ?"unresolved" => link_safety_action
419
- },
420
- ?"offPlatformLinks" => { "action" => "limit" | "age-restrict" | "block", "allowedDomains" => Array[String] }
421
- }
422
- # Preview. The strongest action the asset's links take, the checked links that take it, and the
423
- # settings in force.
424
- type link_safety_decision = {
425
- "action" => link_safety_action,
426
- "links" => Array[checked_link],
427
- "settings" => link_safety_settings
428
- }
429
- type provenance_signal = { "kind" => "c2pa" | "iptc-digital-source-type" | "generator-metadata", "value" => String }
430
- # `status: "evaluated"` carries `provenance` and `signals`; `"not-evaluated"` carries `reason`.
431
- type ai_generated_detection_result = {
432
- "status" => "evaluated" | "not-evaluated",
433
- ?"provenance" => "ai-generated" | "ai-edited" | "unknown",
434
- ?"signals" => Array[provenance_signal],
435
- ?"reason" => feature_not_evaluated_reason
436
- }
437
- # Where OCR found text in an image, and whether it is personal information.
438
- type text_region = { "box" => bounding_box, "personalInformation" => bool }
439
- # `status: "evaluated"` carries `textRegions`, where OCR found text; `"not-evaluated"` carries `reason`. The text itself is `content.extractedText`.
440
- type ocr_result = {
441
- "status" => "evaluated" | "not-evaluated",
442
- ?"textRegions" => Array[text_region],
443
- ?"reason" => feature_not_evaluated_reason
444
- }
445
-
446
- # How strongly each assessed category meets the policy and what the policy does with it.
447
- type policy_rule_snapshot = {
448
- "when" => Array[String], "action" => flagged_content_action,
449
- ?"name" => String, ?"unless" => Array[String]
450
- }
451
- # What decided a category's action: its `default` action, a policy score `below-threshold`, or the
452
- # `allowance` or `restriction` rules listed by `indexes` (at least one, the decisive rule first).
453
- type category_policy_source = { "kind" => "default" | "below-threshold" } |
454
- { "kind" => "allowance" | "restriction", "indexes" => Array[Integer], "conditionScore" => Float }
455
- type category_policy_settings_snapshot = {
456
- "action" => flagged_content_action,
457
- "allowances" => Array[policy_rule_snapshot], "restrictions" => Array[policy_rule_snapshot]
458
- }
459
- type category_policy_score = {
460
- "score" => number, "action" => flagged_content_action,
461
- ?"source" => category_policy_source, ?"settings" => category_policy_settings_snapshot
462
- }
463
- type moderation_timeline = { "segmentCount" => Integer }
464
- type moderation_raw = {
465
- "categories" => classification_categories,
466
- # Empty when the image matched no hash list entry.
467
- "hashMatches" => Array[hash_match]
468
- }
469
111
 
470
112
  # ---- Pages and search (Page.ts, AssetSearch.ts) --------------------------------------------
471
113
 
@@ -473,55 +115,13 @@ module CalmLens
473
115
  # `-createdAt,id`.
474
116
  type sort = String
475
117
 
476
- type asset_page = {
477
- "items" => Array[asset],
478
- "hasMore" => bool,
479
- "nextCursor" => String?
480
- }
481
- # One page of an audio or video asset's findings timeline, in time order.
482
- type asset_timeline_page = {
483
- "items" => Array[media_segment],
484
- "hasMore" => bool,
485
- "nextCursor" => String?
486
- }
487
-
488
118
  type asset_search_mode = "keyword" | "semantic" | "hybrid"
489
119
  type asset_search_match_field = "name" | "id" | "externalId" | "description" | "tags" | "type" | "content.format" |
490
- "content.extension" | "classification.moderation.status" | "visual" | "transcript"
491
- type asset_search_result = { "asset" => asset, "score" => number, "matchedFields" => Array[asset_search_match_field] }
492
- type asset_search_response = {
493
- "query" => String,
494
- "items" => Array[asset_search_result],
495
- "semanticStatus" => "disabled" | "ready" | "indexing" | "unavailable"
496
- }
120
+ "content.extension" | "classification.moderation.decision" | "visual" | "transcript"
497
121
 
498
122
  type asset_batch_operation = "delete" | "remove-content"
499
- # `batchId` is named by the `batch-id` fact of the events the batch causes.
500
- type batch_assets_response = { "batchId" => String, "status" => "queued", "assetCount" => Integer }
501
- # A signed asset URL, with any resource, selector and viewer claims appended, and when it expires
502
- # (milliseconds since the Unix epoch).
503
- type signed_asset_url = { "url" => String, "expiresAt" => Integer }
504
123
  # Whether the viewer an asset URL's claims describe can see the content now.
505
124
  type asset_availability = "available" | "age-restricted" | "unavailable"
506
- # ASSET_INFO_SCHEMA: what the CDN's `info` resource returns, an allowlist of the asset's public
507
- # fields plus the viewer's `availability`.
508
- type asset_info = {
509
- "id" => String,
510
- "projectId" => String,
511
- "type" => asset_type,
512
- "externalUrl" => String?,
513
- "content" => {
514
- "format" => String?,
515
- "width" => Integer?,
516
- "height" => Integer?,
517
- "durationSeconds" => Float?,
518
- "pageCount" => Integer?,
519
- "rendered" => asset_rendered?,
520
- "preview" => asset_preview?,
521
- "hls" => asset_hls?
522
- },
523
- "availability" => asset_availability
524
- }
525
125
 
526
126
  # ---- Transforms and lenses (AssetTransform.ts, Lens.ts) -------------------------------------
527
127
 
@@ -635,350 +235,62 @@ module CalmLens
635
235
  ?description: String?,
636
236
  ?transform: image_transform_options_input?
637
237
  }
638
- type lens = {
639
- "id" => String,
640
- ?"projectId" => String?,
641
- "identifier" => String,
642
- "name" => String,
643
- ?"description" => String?,
644
- "type" => lens_type,
645
- "active" => bool,
646
- ?"transform" => image_transform_options?,
647
- "createdAt" => Integer,
648
- ?"updatedAt" => Integer
649
- }
650
- type lens_page = {
651
- "items" => Array[lens],
652
- "hasMore" => bool,
653
- "nextCursor" => String?
654
- }
655
238
 
656
239
  # ---- Configuration as data (UploadPreset.ts, ProjectConfiguration.ts) --------------------------
657
240
 
658
241
  type upload_preset_access = "token" | "anyone"
659
- # An upload preset's processing options, as the API returns them.
660
- type upload_preset_processing_options = {
661
- ?"retainContent" => bool?,
662
- ?"storeSensitiveMetadata" => bool?,
663
- ?"features" => {
664
- ?"ocr" => { "enabled" => bool }?,
665
- ?"personDetection" => { "enabled" => bool }?,
666
- ?"faceDetection" => { "enabled" => bool, ?"ageEstimation" => bool? }?,
667
- ?"linkDetection" => { "enabled" => bool }?,
668
- ?"streaming" => { "enabled" => bool }?
669
- }?
670
- }
671
- # The rules for uploads made from browsers and apps. `key` is unique in its project; `revision`
672
- # counts changes, starting at 1. Send it back with a change.
673
- type upload_preset = {
674
- "id" => String,
675
- "projectId" => String,
676
- ?"createdByUserId" => String?,
677
- "key" => String,
678
- "revision" => Integer,
679
- "name" => String,
680
- "access" => upload_preset_access,
681
- "enabled" => bool,
682
- ?"allowedContentTypes" => Array[String]?,
683
- ?"maxSizeInBytes" => Integer?,
684
- ?"folderId" => String?,
685
- ?"policyId" => String?,
686
- "visibility" => asset_visibility,
687
- ?"processingOptions" => upload_preset_processing_options?,
688
- "revealDecision" => bool,
689
- ?"dailyUploadLimit" => Integer?,
690
- ?"allowedOrigins" => Array[String]?,
691
- "createdAt" => Integer,
692
- "updatedAt" => Integer
693
- }
694
- type upload_preset_page = { "items" => Array[upload_preset], "hasMore" => bool, "nextCursor" => String? }
695
- type ensure_upload_presets_response = { "uploadPresets" => Array[upload_preset] }
696
242
 
697
- type remote_url_rule = { "mode" => "allow" | "deny", "domains" => Array[String] }
698
- type human_review_settings = {
699
- "allowedSamplePercent" => number,
700
- "restrictedSamplePercent" => number,
701
- "uncertaintyMarginPercent" => number,
702
- "reviewMissingEvidence" => bool
703
- }
704
- type public_project_settings = {
705
- "optOutJurisdictions" => Array[String],
706
- "retainContent" => bool,
707
- "blockUnmoderatedAssets" => bool,
708
- "storeSensitiveMetadata" => bool,
709
- "streamingEnabled" => bool,
710
- "aiMediaSearchEnabled" => bool,
711
- "linkCheckingEnabled" => bool,
712
- "remoteUrlRule" => remote_url_rule?,
713
- "websiteSubmissionsPerMinute" => Integer?,
714
- "humanReview" => human_review_settings
715
- }
716
- # The project's settings, with defaults filled in. `revision` counts changes to the settings and
717
- # metadata fields, starting at 1. Send it back with a change.
718
- type project_settings_resource = { "projectId" => String, "revision" => Integer, "settings" => public_project_settings }
243
+ # Jurisdictions a project can opt out of serving.
244
+ type opt_out_jurisdiction = "EU"
719
245
 
720
246
  type metadata_field_type = "string" | "number" | "boolean" | "date" | "url"
721
247
  type metadata_field_icon = "tag" | "hash" | "user" | "folder" | "layers" | "photo" | "link"
722
- # A metadata field the portal shows and filters by. `color` is `#rrggbb`.
723
- type metadata_field = {
724
- "id" => String,
725
- "title" => String,
726
- ?"description" => String,
727
- "type" => metadata_field_type,
728
- "icon" => metadata_field_icon,
729
- "color" => String
730
- }
731
- type metadata_fields_resource = { "projectId" => String, "revision" => Integer, "fields" => Array[metadata_field] }
732
248
 
733
249
  # ---- Folders (Folder.ts) --------------------------------------------------------------------
734
250
 
735
- type folder = {
736
- "id" => String,
737
- "projectId" => String,
738
- ?"parentId" => String?,
739
- "name" => String,
740
- "createdAt" => Integer,
741
- ?"updatedAt" => Integer
742
- }
743
-
744
251
  # ---- Hash lists (HashList.ts) ----------------------------------------------------------------
745
252
 
746
253
  type hash_list_action = "flag" | "block"
747
254
 
748
- type hash_list = {
749
- "id" => String,
750
- "projectId" => String,
751
- "name" => String,
752
- ?"description" => String?,
753
- "action" => hash_list_action,
754
- "createdAt" => Integer,
755
- ?"updatedAt" => Integer
756
- }
757
-
758
- # A hash list entry an image matched. `distance` is the number of differing bits (0 is the same
759
- # picture); `action` is `block` when the match was close enough for a block list to block.
760
- type hash_match = {
761
- "source" => "hash-list",
762
- "hashListId" => String,
763
- "hashListEntryId" => String,
764
- "distance" => Integer,
765
- "action" => hash_list_action
766
- }
767
-
768
- type hash_list_entry = {
769
- "id" => String,
770
- "projectId" => String,
771
- "hashListId" => String,
772
- "hash" => String,
773
- "quality" => number?,
774
- ?"label" => String?,
775
- # The asset the hash was taken from, when the entry was added from an asset.
776
- ?"assetId" => String?,
777
- "createdAt" => Integer
778
- }
779
-
780
- type hash_list_entry_page = {
781
- "items" => Array[hash_list_entry],
782
- "hasMore" => bool,
783
- "nextCursor" => String?
784
- }
785
-
786
255
  # ---- Policies (Policy.ts) ---------------------------------------------------------------------
787
256
 
788
257
  type policy_preset_id = "general-community" | "children-platform" | "education-support" | "wholesome-community"
789
- # What a policy does with one category: `action` when its policy score reaches 0.5, allowances
790
- # that let covered content through or act on it more softly, and restrictions, which outweigh
791
- # allowances.
792
- type category_policy_settings = {
793
- "action" => flagged_content_action,
794
- "allowances" => Array[policy_rule_snapshot],
795
- "restrictions" => Array[policy_rule_snapshot]
796
- }
797
- # Settings for every category, and optionally link safety.
798
- type policy_settings = {
799
- "categorySettings" => {
800
- "sexual" => category_policy_settings,
801
- "violence" => category_policy_settings,
802
- "self-harm" => category_policy_settings,
803
- "harassment" => category_policy_settings,
804
- "hate" => category_policy_settings,
805
- "criminal-activity" => category_policy_settings,
806
- "personal-information" => category_policy_settings,
807
- "profanity" => category_policy_settings
808
- },
809
- ?"linkSafety" => link_safety_settings
810
- }
811
258
  # How a policy relates to its preset: `live` follows the latest release (the organisation's own
812
259
  # preset policy with automatic updates on), `pinned` is the organisation's own preset policy held
813
260
  # at one release, and `copy` is a policy made from a preset.
814
261
  type policy_preset_mode = "live" | "pinned" | "copy"
815
- # Where a policy started from a built-in preset. `version` is the release it is pinned to,
816
- # `latestVersion` the newest.
817
- type policy_preset_origin = {
818
- "id" => policy_preset_id,
819
- "version" => Integer,
820
- "latestVersion" => Integer,
821
- "mode" => policy_preset_mode
822
- }
823
- # A moderation policy. Policies belong to the organisation and its projects share them. Send
824
- # `revision` with each change; a policy changed since is refused with `policy/revision-conflict`.
825
- type policy = {
826
- "id" => String,
827
- "name" => String,
828
- "description" => String,
829
- "settings" => policy_settings,
830
- "revision" => Integer,
831
- "preset" => policy_preset_origin?,
832
- "projectIds" => Array[String],
833
- "createdAt" => Integer,
834
- "updatedAt" => Integer
835
- }
836
- # A page of the organisation's policies, oldest first unless `sort` says otherwise.
837
- type policy_page = { "items" => Array[policy], "hasMore" => bool, "nextCursor" => String? }
838
262
 
839
263
  # ---- Events and webhooks (Event.ts, EventCatalog.ts, WebhookPayload.ts) ----------------------
840
264
 
841
- # EVENT_TYPES in EventCatalog.ts. Ignore types your code does not handle. Webhook, Slack and email
842
- # deliveries and the public events feed leave out facts that hold personal or account data.
843
- type event_type = "asset.uploaded" | "asset.classified" | "asset.region-restricted" | "asset.allowed" | "asset.limited" |
844
- "asset.age-restricted" | "asset.blocked" | "asset.purged" | "asset.failed" | "asset.progress-updated" |
845
- "asset.deleted" | "asset.content-removed" | "asset.retried" | "asset.rerun-requested" | "asset.review-requested" |
846
- "asset.hash-matched" | "asset.link-flagged" | "usage.free-uploads-exhausted" | "usage.uploads-paused" |
847
- "upload-preset.daily-limit-reached" | "project.member-joined" | "project.member-removed" |
848
- "project.member-left" | "project.member-role-changed" | "project.invitation-sent" |
849
- "project.transferred" | "api-key.created" | "api-key.revoked" | "api-key.deleted" |
850
- "connector.disabled" | "appeal.submitted" | "appeal.resolved"
851
265
  type event_severity = "low" | "high"
852
266
  # A registered fact's value: text, an enum value, a count or a time in milliseconds (such as
853
267
  # `resumes-at`), a list of enum values (such as `flagged-categories`), or null.
854
268
  # Test sends carry `{ "key" => "test", "value" => true }`.
855
- type event_fact_value = String | Integer | bool | Array[String] | nil
856
- # A registered fact. `key` is a kebab-case key registered for the event's type, such as
857
- # `asset-name` or `flagged-categories`. Render `url` only when it is an internal path or HTTP(S) URL.
858
- type event_fact = { "key" => String, "value" => event_fact_value, ?"url" => String }
269
+ type event_fact_value = String | Integer | bool | Array[classification_category] | nil
270
+ | "moderation-status" | "automated-status" | "region" | "rule" | "status" | "reviewer-name" | "note"
271
+ | "child-asset" | "child-status" | "previous-status" | "failure-reason" | "completed-sections"
272
+ | "total-sections" | "batch-id" | "review-reason" | "uncertain-categories" | "review-id" | "decision"
273
+ | "applied-to-asset" | "hash-list-id" | "hash-list-name" | "distance" | "match-action" | "limit" | "used"
274
+ | "organisation-id" | "reason" | "resumes-at" | "preset-id" | "preset-name" | "daily-limit"
275
+ | "member-user-id" | "member-name" | "role" | "previous-role" | "invitee-email"
276
+ | "previous-organisation-id" | "previous-organisation-name" | "organisation-name" | "method"
277
+ | "api-keys-revoked" | "connectors-paused" | "key-id" | "key-name" | "created-by-name"
278
+ | "revoked-by-name" | "deleted-by-name" | "connector-id" | "connector-name" | "connector-type"
279
+ | "consecutive-failures" | "last-error"
859
280
  type event_fact_input = { key: String, value: event_fact_value, ?url: String }
860
281
 
861
- # Snapshot of the asset's processing, moderation and content status when the event was created.
862
- type event_asset = {
863
- "id" => String,
864
- ?"uploadPresetId" => String?,
865
- ?"externalId" => String?,
866
- "upload" => { "status" => "uploading" | "completed" },
867
- # `testInput`: whether the results came from one of the project's test inputs rather than
868
- # analysing the content. Never use test results, such as age ranges, for real decisions.
869
- "classification" => { "status" => asset_classification_status, "testInput" => bool,
870
- "moderation" => { "status" => asset_moderation_status } },
871
- "content" => { "status" => asset_content_status }
872
- }
873
282
  # Who caused an event: a `user` (a person in the portal, or an assistant acting for one), an
874
283
  # `api-key`, `automated` moderation or CalmLens itself (`system`). `id` is the user's or API key's
875
284
  # ID, nil for `automated` and `system` and when it was not recorded.
876
285
  type actor_type = "user" | "api-key" | "automated" | "system"
877
- type actor = { "type" => actor_type, "id" => String? }
878
286
  type actor_input = { type: actor_type, id: String? }
879
287
 
880
- # An `events.list` item, and the body of its webhook delivery.
881
- type event = {
882
- "id" => String,
883
- "projectId" => String,
884
- "actor" => actor,
885
- "type" => event_type,
886
- "severity" => event_severity,
887
- "title" => String,
888
- "description" => String?,
889
- "assetId" => String?,
890
- # Increases with each event about the same asset; nil for events not about an asset.
891
- "assetSequence" => Integer?,
892
- "asset" => event_asset?,
893
- "facts" => Array[event_fact],
894
- "createdAt" => Integer
895
- }
896
- # Unlike other lists, `nextCursor` is never nil: keep it to receive later events.
897
- # `excludedTypes` are the event types the feed never includes, because the API key lacks the permission
898
- # to see them.
899
- type events_page = {
900
- "items" => Array[event],
901
- "nextCursor" => String,
902
- "hasMore" => bool,
903
- "excludedTypes" => Array[event_type]
904
- }
905
-
906
288
  # ---- Method options -------------------------------------------------------------------------
907
289
 
908
290
  type viewer_claims = { ?region: String, ?age_confirmed: bool }
909
- type asset_id_options = { asset_id: String, ?request_options: request_options }
910
- # `timeout` is the whole wait in seconds (default 60).
911
- type wait_for_decision_options = { asset_id: String, ?timeout: number, ?request_options: request_options }
912
291
 
913
- type asset_search_options = {
914
- query: String,
915
- ?mode: asset_search_mode,
916
- # How many results, 1 to 20 (default 10).
917
- ?page_size: Integer,
918
- ?request_options: request_options
919
- }
920
- type list_assets_options = {
921
- ?cursor: String,
922
- ?page_size: Integer,
923
- # `createdAt` and `id`; `-createdAt` by default.
924
- ?sort: sort,
925
- # An RSQL filter such as `classification.moderation.status==allowed`; `folderId==fldr_…` lists
926
- # one folder's assets.
927
- ?filter: String?,
928
- ?request_options: request_options
929
- }
930
- type list_asset_children_options = {
931
- asset_id: String,
932
- ?cursor: String,
933
- ?page_size: Integer,
934
- ?sort: sort,
935
- ?request_options: request_options
936
- }
937
- type list_asset_timeline_options = {
938
- asset_id: String,
939
- ?cursor: String,
940
- ?page_size: Integer,
941
- ?request_options: request_options
942
- }
943
- type update_asset_options = {
944
- asset_id: String,
945
- ?name: String,
946
- ?description: String?,
947
- ?external_id: String?,
948
- ?external_url: String?,
949
- ?metadata: Array[metadata_item_input]?,
950
- ?tags: Array[String]?,
951
- ?visibility: asset_visibility?,
952
- ?request_options: request_options
953
- }
954
- type batch_assets_options = { asset_ids: Array[String], operation: asset_batch_operation, ?request_options: request_options }
955
- type move_asset_options = { asset_id: String, folder_id: String?, ?request_options: request_options }
956
- type explain_asset_options = { asset_id: String, ?rerun: bool, ?request_options: request_options }
957
- # A reviewer's decision. `note` is 1 to 1499 characters; purging also needs `confirm_purge: true`.
958
- type decide_asset_options = {
959
- asset_id: String,
960
- decision: "allowed" | "limited" | "age-restricted" | "blocked" | "purged",
961
- note: String,
962
- ?confirm_purge: bool,
963
- ?request_options: request_options
964
- }
965
292
  # The resources beneath an asset URL ({CalmLens::CDN::RESOURCES}).
966
293
  type cdn_resource = "original" | "rendered" | "preview" | "hls" | "embed" | "placeholder" | "info"
967
- type sign_asset_url_options = {
968
- # Exactly one of `asset_id` and `external_id`.
969
- ?asset_id: String,
970
- ?external_id: String,
971
- ?project_id: String,
972
- # Whole seconds from 1 to 86400; 900 by default.
973
- ?expires_in: Integer,
974
- # Whether the URL also serves `original`; false by default.
975
- ?original: bool,
976
- ?resource: cdn_resource,
977
- ?lens: String,
978
- ?transform: transform_input,
979
- ?viewer_claims: viewer_claims,
980
- ?request_options: request_options
981
- }
982
294
 
983
295
  # Upload content: exactly one of `plain_text`, `base64` (optionally a data URL) or `data` (a
984
296
  # binary String or an IO, which streams). `size_in_bytes` is required for an IO of unknown length.
@@ -994,82 +306,6 @@ module CalmLens
994
306
  | { part_number: Integer, base64: String, ?is_final: bool, ?size_in_bytes: Integer }
995
307
  | { part_number: Integer, data: String | Transport::_Reader, ?is_final: bool, ?size_in_bytes: Integer }
996
308
 
997
- # Options of {Assets#create} and {Assets#classify}: the shared asset fields with exactly one of
998
- # `content:` (a whole file), `part:` (the first part of a multipart upload) or `url:` (a page or
999
- # file CalmLens fetches).
1000
- type upload_options = {
1001
- name: String,
1002
- content: upload_content,
1003
- ?description: String?,
1004
- ?visibility: asset_visibility?,
1005
- ?metadata: Array[metadata_item_input]?,
1006
- # Tags for the asset, such as `['catalogue', 'backpacks']`.
1007
- ?tags: Array[String]?,
1008
- ?author_id: String,
1009
- ?context: moderation_context_input,
1010
- ?external_id: String?,
1011
- ?external_url: String?,
1012
- ?folder_id: String?,
1013
- ?upload_preset_id: String,
1014
- ?processing_options: processing_options_input?,
1015
- ?request_options: request_options
1016
- }
1017
- | {
1018
- name: String,
1019
- part: upload_first_part,
1020
- ?total_size_in_bytes: Integer,
1021
- ?description: String?,
1022
- ?visibility: asset_visibility?,
1023
- ?metadata: Array[metadata_item_input]?,
1024
- # Tags for the asset, such as `['catalogue', 'backpacks']`.
1025
- ?tags: Array[String]?,
1026
- ?author_id: String,
1027
- ?context: moderation_context_input,
1028
- ?external_id: String?,
1029
- ?external_url: String?,
1030
- ?folder_id: String?,
1031
- ?upload_preset_id: String,
1032
- ?processing_options: processing_options_input?,
1033
- ?request_options: request_options
1034
- }
1035
- | {
1036
- name: String,
1037
- url: String,
1038
- ?description: String?,
1039
- ?visibility: asset_visibility?,
1040
- ?metadata: Array[metadata_item_input]?,
1041
- # Tags for the asset, such as `['catalogue', 'backpacks']`.
1042
- ?tags: Array[String]?,
1043
- ?author_id: String,
1044
- ?context: moderation_context_input,
1045
- ?external_id: String?,
1046
- ?external_url: String?,
1047
- ?folder_id: String?,
1048
- ?upload_preset_id: String,
1049
- ?processing_options: processing_options_input?,
1050
- ?request_options: request_options
1051
- }
1052
- # `wait` overrides whether the final part waits for the decision, chosen when the upload started.
1053
- type upload_part_options = { asset_id: String, part: upload_part, ?wait: bool, ?request_options: request_options }
1054
-
1055
- # Options of {Text#classify}: the text, with the shared asset fields. `name` defaults to `text`.
1056
- type moderate_text_options = {
1057
- text: String,
1058
- ?name: String,
1059
- ?description: String?,
1060
- ?visibility: asset_visibility?,
1061
- ?metadata: Array[metadata_item_input]?,
1062
- ?tags: Array[String]?,
1063
- ?author_id: String,
1064
- ?context: moderation_context_input,
1065
- ?external_id: String?,
1066
- ?external_url: String?,
1067
- ?folder_id: String?,
1068
- ?upload_preset_id: String,
1069
- ?processing_options: processing_options_input?,
1070
- ?request_options: request_options
1071
- }
1072
-
1073
309
  # Options of {UploadTokens#sign}.
1074
310
  type sign_upload_token_options = {
1075
311
  upload_preset_id: String,
@@ -1078,47 +314,9 @@ module CalmLens
1078
314
  ?expires_in: Integer,
1079
315
  ?request_options: request_options
1080
316
  }
1081
- type signed_upload_token = { "token" => String, "expiresAt" => Integer }
1082
-
1083
- type list_folders_options = {
1084
- ?parent_id: String,
1085
- ?cursor: String,
1086
- # 1 to 100, default 50.
1087
- ?page_size: Integer,
1088
- # `name` (the default) or `createdAt`, descending when prefixed with `-`.
1089
- ?sort: sort,
1090
- ?search: String,
1091
- ?request_options: request_options
1092
- }
1093
- type folder_page = {
1094
- "items" => Array[folder],
1095
- "ancestors" => Array[folder],
1096
- "hasMore" => bool,
1097
- "nextCursor" => String?
1098
- }
1099
- type folder_id_options = { folder_id: String, ?request_options: request_options }
1100
- type create_folder_options = { name: String, ?parent_id: String?, ?request_options: request_options }
1101
- type update_folder_options = { folder_id: String, ?name: String, ?request_options: request_options }
1102
- type move_folder_options = { folder_id: String, parent_id: String?, ?request_options: request_options }
1103
- # 1 to 100 lists per page, default 50; `sort` is `createdAt` and `id`, `-createdAt` by default.
1104
- type list_hash_lists_options = { ?cursor: String, ?page_size: Integer, ?sort: sort, ?request_options: request_options }
1105
- type hash_list_page = {
1106
- "items" => Array[hash_list],
1107
- "hasMore" => bool,
1108
- "nextCursor" => String?
1109
- }
1110
- type hash_list_id_options = { hash_list_id: String, ?request_options: request_options }
1111
- type create_hash_list_options = { name: String, action: hash_list_action, ?description: String?, ?request_options: request_options }
1112
- type update_hash_list_options = { hash_list_id: String, ?name: String, ?description: String?, ?action: hash_list_action,
1113
- ?request_options: request_options }
1114
- type list_hash_list_entries_options = { hash_list_id: String, ?cursor: String, ?page_size: Integer, ?sort: sort,
1115
- ?request_options: request_options }
1116
- type add_hash_list_entry_options = { hash_list_id: String, ?hash: String, ?quality: number, ?asset_id: String, ?label: String,
1117
- ?request_options: request_options }
1118
- type hash_list_entry_id_options = { entry_id: String, ?request_options: request_options }
1119
317
 
1120
318
  # Policy settings as options: snake_case Symbol keys, or a policy's `settings` as the API returned it.
1121
- type policy_rule_input = { when: Array[String], action: flagged_content_action, ?name: String, ?unless: Array[String] }
319
+ type policy_rule_input = { when: Array[moderation_qualifier], action: flagged_content_action, ?name: String, ?unless: Array[moderation_qualifier] }
1122
320
  # Every category needs its `action`, `allowances` and `restrictions`.
1123
321
  type category_policy_settings_input = {
1124
322
  action: flagged_content_action,
@@ -1129,60 +327,20 @@ module CalmLens
1129
327
  verdict_actions: Hash[String | Symbol, link_safety_action],
1130
328
  ?off_platform_links: { action: "limit" | "age-restrict" | "block", allowed_domains: Array[String] }
1131
329
  }
1132
- type policy_settings_input = policy_settings | {
1133
- category_settings: Hash[String | Symbol, category_policy_settings_input],
330
+ type policy_settings_input = PolicySettings | {
331
+ category_settings: {
332
+ sexual: category_policy_settings_input,
333
+ violence: category_policy_settings_input,
334
+ :"self-harm" => category_policy_settings_input,
335
+ harassment: category_policy_settings_input,
336
+ hate: category_policy_settings_input,
337
+ :"criminal-activity" => category_policy_settings_input,
338
+ :"personal-information" => category_policy_settings_input,
339
+ profanity: category_policy_settings_input
340
+ },
1134
341
  ?link_safety: link_safety_settings_input
1135
342
  }
1136
- # `sort` is `createdAt` and `id`, `createdAt` (oldest first) by default.
1137
- type list_policies_options = { ?cursor: String, ?page_size: Integer, ?sort: sort, ?request_options: request_options }
1138
- type request_only_options = { ?request_options: request_options }
1139
- type policy_id_options = { policy_id: String, ?request_options: request_options }
1140
- # Send `settings` (defining every category) with a `name`, or `preset_id` to copy the latest
1141
- # release of a built-in preset, named after it unless you give a `name`.
1142
- type create_policy_options = { ?name: String, ?description: String, ?settings: policy_settings_input,
1143
- ?preset_id: policy_preset_id, ?request_options: request_options }
1144
- type update_policy_options = { policy_id: String, revision: Integer, ?name: String, ?description: String,
1145
- ?settings: policy_settings_input, ?request_options: request_options }
1146
- # `reset` restores the pinned release (send `preset.version`); `upgrade` moves an unchanged
1147
- # `pinned` or `copy` policy to the latest release (send `preset.latestVersion`).
1148
- type restore_policy_options = { policy_id: String, revision: Integer, preset_version: Integer,
1149
- ?request_options: request_options }
1150
- type set_policy_automatic_updates_options = { policy_id: String, enabled: bool, revision: Integer,
1151
- preset_version: Integer, ?request_options: request_options }
1152
- type assign_policy_options = { policy_id: String, ?request_options: request_options }
1153
-
1154
- # `page_size` is 1 to 100, default 50. `types` and `asset_id` narrow the feed; a cursor belongs to
1155
- # the filters it was issued with.
1156
- type list_events_options = { ?cursor: String, ?page_size: Integer, ?types: Array[event_type], ?asset_id: String,
1157
- ?request_options: request_options }
1158
343
 
1159
- type ensure_lenses_options = { lenses: Array[lens_definition], ?request_options: request_options }
1160
- type ensure_lens_options = {
1161
- identifier: String,
1162
- name: String,
1163
- type: lens_type,
1164
- ?active: bool,
1165
- ?description: String?,
1166
- ?transform: image_transform_options_input?,
1167
- ?request_options: request_options
1168
- }
1169
- # `sort` is `createdAt` and `id`, `-createdAt` (newest first) by default.
1170
- type list_lenses_options = { ?cursor: String, ?page_size: Integer, ?sort: sort, ?request_options: request_options }
1171
- type lens_id_options = { lens_id: String, ?request_options: request_options }
1172
- # The identifier must be new to the project.
1173
- type create_lens_options = ensure_lens_options
1174
- type update_lens_options = {
1175
- lens_id: String,
1176
- ?name: String,
1177
- ?description: String?,
1178
- ?type: lens_type,
1179
- ?active: bool,
1180
- ?transform: image_transform_options_input?,
1181
- ?request_options: request_options
1182
- }
1183
-
1184
- # `sort` is `createdAt` and `id`, `createdAt` (oldest first) by default.
1185
- type list_upload_presets_options = { ?cursor: String, ?page_size: Integer, ?sort: sort, ?request_options: request_options }
1186
344
  # One preset's whole definition, by `key`; fields left out take their defaults. Send the `revision`
1187
345
  # you read (0 for a preset that must not exist yet) to refuse a change made since.
1188
346
  type upload_preset_definition = {
@@ -1201,18 +359,16 @@ module CalmLens
1201
359
  ?daily_upload_limit: Integer?,
1202
360
  ?allowed_origins: Array[String]?
1203
361
  }
1204
- type ensure_upload_presets_options = { upload_presets: Array[upload_preset_definition], ?request_options: request_options }
1205
- type upload_preset_id_options = { upload_preset_id: String, ?request_options: request_options }
1206
362
  # The complete settings: those left out return to their defaults.
1207
363
  type project_settings_input = {
1208
- ?opt_out_jurisdictions: Array[String],
364
+ ?opt_out_jurisdictions: Array[opt_out_jurisdiction],
1209
365
  ?retain_content: bool,
1210
366
  ?block_unmoderated_assets: bool,
1211
367
  ?store_sensitive_metadata: bool,
368
+ ?link_checking_enabled: bool,
1212
369
  ?streaming_enabled: bool,
1213
370
  ?ai_media_search_enabled: bool,
1214
371
  ?remote_url_rule: { mode: "allow" | "deny", domains: Array[String] }?,
1215
- ?website_submissions_per_minute: Integer?,
1216
372
  ?human_review: {
1217
373
  ?allowed_sample_percent: number,
1218
374
  ?restricted_sample_percent: number,
@@ -1220,14 +376,6 @@ module CalmLens
1220
376
  ?review_missing_evidence: bool
1221
377
  }
1222
378
  }
1223
- # Send the `revision` you read to refuse settings changed since. `search_indexing_budget_units` is
1224
- # needed when turning on `ai_media_search_enabled`.
1225
- type update_project_settings_options = {
1226
- ?revision: Integer,
1227
- settings: project_settings_input,
1228
- ?search_indexing_budget_units: number,
1229
- ?request_options: request_options
1230
- }
1231
379
  type metadata_field_input = {
1232
380
  id: String,
1233
381
  title: String,
@@ -1236,40 +384,6 @@ module CalmLens
1236
384
  icon: metadata_field_icon,
1237
385
  color: String
1238
386
  }
1239
- # Fields to create or replace by ID; other fields are kept.
1240
- type ensure_metadata_fields_options = { ?revision: Integer, fields: Array[metadata_field_input], ?request_options: request_options }
1241
- type delete_metadata_field_options = { field_id: String, ?revision: Integer, ?request_options: request_options }
1242
-
1243
- type asset_url_options = {
1244
- # Exactly one of `asset_id` and `external_id`.
1245
- ?asset_id: String,
1246
- ?external_id: String,
1247
- # The client's project by default.
1248
- ?project_id: String,
1249
- # Without one, the URL is the asset URL itself. `original`, `hls` (the HLS master playlist),
1250
- # `embed` (the page that shows the asset), `placeholder` (a small blurred PNG) and `info` take no
1251
- # lens or transform; `preview` takes them, and `rendered` does when it is an image.
1252
- ?resource: cdn_resource,
1253
- # Transform options replace the lens's options of the same name; both need a resource.
1254
- ?lens: String,
1255
- ?transform: transform_input,
1256
- # Unsigned viewer assertions, sent as the `viewerClaims` query without the defaults. Set
1257
- # `age_confirmed` only where your app has already decided the viewer may see age-restricted content.
1258
- ?viewer_claims: viewer_claims,
1259
- ?request_options: request_options
1260
- }
1261
- type serve_options = {
1262
- ?asset_id: String,
1263
- ?external_id: String,
1264
- ?project_id: String,
1265
- ?viewer_claims: viewer_claims,
1266
- # `rendered` by default.
1267
- ?resource: cdn_resource,
1268
- ?lens: String,
1269
- ?transform: transform_input,
1270
- ?init: { ?method: "GET" | "HEAD", ?headers: Hash[String, String] },
1271
- ?request_options: request_options
1272
- }
1273
387
 
1274
388
  # Options of {MockServerClient#enqueue_event}. Omitted fields are filled in.
1275
389
  type mock_event_input = {
@@ -1286,7 +400,7 @@ module CalmLens
1286
400
  id: String,
1287
401
  ?external_id: String?,
1288
402
  upload: { status: "uploading" | "completed" },
1289
- classification: { status: asset_classification_status, moderation: { status: asset_moderation_status } },
403
+ classification: { status: asset_classification_status, moderation: { decision: asset_moderation_decision? } },
1290
404
  content: { status: asset_content_status }
1291
405
  }?,
1292
406
  ?facts: Array[event_fact_input],