calmlens 0.28.2 → 0.29.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -77,11 +77,14 @@ module CalmLens
77
77
 
78
78
  # The prefix of mock API keys made by {.create_api_key}.
79
79
  API_KEY_PREFIX = 'sk_test_'
80
+ # The ID of every mock API key: the `id` of the `actor` of the events its requests record and of
81
+ # the `decided_by` of its {Assets#decide} reviews, where CalmLens gives your key's own ID.
82
+ API_KEY_ID = Testing::FakeAPI::API_KEY_ID
80
83
  # Simulated failures for {#fail_next_request}, besides API error codes and exceptions.
81
84
  REQUEST_FAILURES = %w[transport-error timeout].freeze
82
85
  # The methods {#fail_next_request} can target, by resource. Iterators are their list calls.
83
- OPERATIONS = { assets: %i[search list retrieve list_children list_timeline update create classify upload_part move
84
- retry decide wait_for_decision remove_content delete batch],
86
+ OPERATIONS = { assets: %i[search list retrieve retrieve_by_external_id list_children list_timeline update create classify
87
+ upload_part move retry decide request_review wait_for_decision remove_content delete batch],
85
88
  folders: %i[list retrieve create update delete move],
86
89
  hash_lists: %i[list retrieve create update delete list_entries add_entry remove_entry],
87
90
  policies: %i[list retrieve retrieve_assigned create update reset upgrade set_automatic_updates delete
@@ -90,7 +93,7 @@ module CalmLens
90
93
  upload_presets: %i[list ensure delete],
91
94
  project_settings: %i[get update],
92
95
  metadata_fields: %i[list ensure delete],
93
- text: %i[classify], events: %i[list],
96
+ text: %i[classify], events: %i[list retrieve_asset],
94
97
  cdn: %i[serve sign_asset_url get_asset_info] }.freeze
95
98
  private_constant :OPERATIONS
96
99
  # The operation names {#fail_next_request} accepts, in their camelCase form.
@@ -201,7 +204,7 @@ module CalmLens
201
204
 
202
205
  # Applies a reviewer's decision to a stored asset, as the portal or API would: the moderation
203
206
  # status changes (`purged` also removes the content), the review joins `manualReviews` with
204
- # `decidedBy` the mock API key (`{ 'type' => 'api-key', 'id' => nil }`) and `applied: true`, an
207
+ # `decidedBy` the mock API key (`{ 'type' => 'api-key', 'id' => API_KEY_ID }`) and `applied: true`, an
205
208
  # `asset.<decision>` event whose `actor` is a `user` joins the events feed, and a waiting
206
209
  # `pendingReview` is settled ({Assets#decide} leaves it waiting, as with the API).
207
210
  # @param asset_id [String]
@@ -236,36 +239,52 @@ module CalmLens
236
239
  end
237
240
 
238
241
  # Makes the next request (or the next one `operation` sends) fail instead of running, as if it
239
- # never completed. Each queued failure fails one request, so a client retry takes the next
240
- # queued failure or reaches the API. Queue several to fail several requests in a row.
242
+ # never completed, or the next `times` of them. A request takes the oldest queued failure that
243
+ # matches it, using up one of its `times`, so a client retry takes the same failure again until
244
+ # it is used up, then the next queued failure or the API.
241
245
  # @param failure [String, Exception] `transport-error` (`sdk/transport-error`), `timeout`
242
246
  # (`sdk/timeout`), an API error code such as `upload/limit-exceeded` (answered with its HTTP
243
247
  # status), or an exception for the transport to raise.
244
248
  # @param operation [String, nil] a method such as `assets.create`, `assets.upload_part`,
245
249
  # `cdn.serve` or `ensure_lens` (JavaScript names such as `assets.uploadPart` work too).
250
+ # @param times [Integer] how many requests it fails, 1 unless given.
246
251
  # @param details [Hash, nil] the API error's `details`, for an API error code.
247
252
  # @param retry_after [Integer, nil] whole seconds for the API error's `Retry-After` header.
248
253
  # @return [self]
249
- # @raise [InvalidArgumentError] for an unknown failure or operation, or a `retry_after` that isn't
250
- # a whole number of seconds
251
- def fail_next_request(failure = 'transport-error', operation: nil, details: nil, retry_after: nil)
252
- unless failure.is_a?(Exception) || REQUEST_FAILURES.include?(failure) || ErrorCodes::STATUSES.key?(failure)
253
- raise Internal.invalid("Unknown failure #{failure.inspect}: use #{REQUEST_FAILURES.join(', ')}, an API error code or an exception")
254
- end
255
- unless retry_after.nil? || (retry_after.is_a?(Integer) && retry_after >= 0)
256
- raise Internal.invalid('retry_after must be a whole number of seconds')
257
- end
258
- raise Internal.invalid('details must be a Hash') unless details.nil? || details.is_a?(Hash)
259
- if !(failure.is_a?(String) && ErrorCodes::STATUSES.key?(failure)) && !(details.nil? && retry_after.nil?)
260
- raise Internal.invalid('details and retry_after apply only to an API error code')
261
- end
254
+ # @raise [InvalidArgumentError] for an unknown failure or operation, a `times` that isn't a
255
+ # positive Integer, or a `retry_after` that isn't a whole number of seconds
256
+ def fail_next_request(failure = 'transport-error', operation: nil, times: 1, details: nil, retry_after: nil)
257
+ raise Internal.invalid('times must be a positive whole number') unless times.is_a?(Integer) && times.positive?
262
258
 
263
- name = operation && operation.to_s.split('.').map { |part| Internal.camelize(part) }.join('.')
264
- if name && !OPERATION_NAMES.include?(name)
265
- raise Internal.invalid("Unknown operation #{operation.inspect}: use one of #{OPERATION_NAMES.join(', ')}")
266
- end
259
+ queue_failure(failure, operation: operation, times: times, details: details, retry_after: retry_after)
260
+ end
261
+
262
+ # Makes every request (or every one `operation` sends) fail as {#fail_next_request} would, until
263
+ # {#clear_failures}. Queued after other failures, it fails the requests they don't.
264
+ # @return [self]
265
+ def fail_requests(failure = 'transport-error', operation: nil, details: nil, retry_after: nil)
266
+ queue_failure(failure, operation: operation, times: Float::INFINITY, details: details, retry_after: retry_after)
267
+ end
267
268
 
268
- @mock_lock.synchronize { @failures << { failure: failure, operation: name, details: details, retry_after: retry_after } }
269
+ # Drops every failure {#fail_next_request} and {#fail_requests} queued, so requests reach the
270
+ # in-memory API again.
271
+ # @return [self]
272
+ def clear_failures
273
+ @mock_lock.synchronize { @failures.clear }
274
+ self
275
+ end
276
+
277
+ # Makes `url` answer with `content` and its content `type` when a URL upload fetches it, as a
278
+ # site would. The upload then stores that content and is typed by `type`, as an upload of the
279
+ # bytes would be: `image/png` is an image, and `text/html` a website, which stores nothing. A URL
280
+ # not served this way is typed by its path's extension and has no content. Serving a URL again
281
+ # replaces its content.
282
+ # @param url [String] an absolute URL, compared once normalized
283
+ # @param content [String] the bytes, or text sent as UTF-8
284
+ # @param type [String] the `Content-Type` it answers with, such as `image/png`
285
+ # @return [self]
286
+ def serve_url(url, content:, type:)
287
+ @mock_lock.synchronize { @fake.serve_url(url, content, type) }
269
288
  self
270
289
  end
271
290
 
@@ -317,10 +336,9 @@ module CalmLens
317
336
 
318
337
  # Adds an event to the mock's events feed. Fields you omit (`id`, `projectId`, `createdAt`,
319
338
  # `severity`, `title`, `facts`, and nil `description` and `assetId`) are filled in, and `actor`
320
- # is the mock API key (`{ 'type' => 'api-key', 'id' => nil }`) unless you pass one, such as
321
- # `actor: { type: 'user', id: nil }`. An event
322
- # with the `asset_id` of a stored asset carries that asset's snapshot as it is now, unless you
323
- # pass `asset`.
339
+ # is the mock API key (`{ 'type' => 'api-key', 'id' => API_KEY_ID }`) unless you pass one, such as
340
+ # `actor: { type: 'user', id: nil }`. An event with an `asset_id` takes that asset's next
341
+ # `assetSequence`, which becomes the stored asset's `eventSequence`; it changes nothing else.
324
342
  # @param event [Hash] at least `type:`; snake_case keys are converted.
325
343
  # @return [Event] the stored event
326
344
  def enqueue_event(event)
@@ -375,10 +393,39 @@ module CalmLens
375
393
  end
376
394
  end
377
395
 
378
- # The next queued failure for this request, which it uses up.
396
+ # Queues a failure for `times` matching requests, after checking it as {#fail_next_request} says.
397
+ def queue_failure(failure, operation:, times:, details:, retry_after:)
398
+ unless failure.is_a?(Exception) || REQUEST_FAILURES.include?(failure) || ErrorCodes::STATUSES.key?(failure)
399
+ raise Internal.invalid("Unknown failure #{failure.inspect}: use #{REQUEST_FAILURES.join(', ')}, an API error code or an exception")
400
+ end
401
+ unless retry_after.nil? || (retry_after.is_a?(Integer) && retry_after >= 0)
402
+ raise Internal.invalid('retry_after must be a whole number of seconds')
403
+ end
404
+ raise Internal.invalid('details must be a Hash') unless details.nil? || details.is_a?(Hash)
405
+ if !(failure.is_a?(String) && ErrorCodes::STATUSES.key?(failure)) && !(details.nil? && retry_after.nil?)
406
+ raise Internal.invalid('details and retry_after apply only to an API error code')
407
+ end
408
+
409
+ name = operation && operation.to_s.split('.').map { |part| Internal.camelize(part) }.join('.')
410
+ if name && !OPERATION_NAMES.include?(name)
411
+ raise Internal.invalid("Unknown operation #{operation.inspect}: use one of #{OPERATION_NAMES.join(', ')}")
412
+ end
413
+
414
+ @mock_lock.synchronize do
415
+ @failures << { failure: failure, operation: name, remaining: times, details: details, retry_after: retry_after }
416
+ end
417
+ self
418
+ end
419
+
420
+ # The oldest queued failure that matches this request, using up one of its `times`.
379
421
  def failure_for(call)
380
- index = @failures.index { |pending| pending[:operation].nil? || pending[:operation] == call&.dig(:operation) }
381
- index && @failures.delete_at(index)
422
+ index = @failures.index { |queued| queued[:operation].nil? || queued[:operation] == call&.dig(:operation) }
423
+ return unless index
424
+
425
+ pending = @failures[index]
426
+ pending[:remaining] -= 1
427
+ @failures.delete_at(index) unless pending[:remaining].positive?
428
+ pending
382
429
  end
383
430
 
384
431
  # Returns the response rather than yielding it: the client accepts either from a transport.
data/lib/calmlens/text.rb CHANGED
@@ -20,12 +20,14 @@ module CalmLens
20
20
  # @return [Asset] show it to everyone only when `classification.moderation.decision` is
21
21
  # `allowed` or `limited` (reduce the reach of `limited` content).
22
22
  def classify(**options)
23
- call(options, __method__) { nil }
24
- text = options[:text]
25
- raise Internal.invalid('Text to classify must be a non-empty string') unless text.is_a?(String) && !text.strip.empty?
23
+ # Within this call, assets.classify's requests report the text.classify operation.
24
+ call(options, __method__) do
25
+ text = options[:text]
26
+ raise Internal.invalid('Text to classify must be a non-empty string') unless text.is_a?(String) && !text.strip.empty?
26
27
 
27
- @assets.classify(**options.except(:text), name: options.fetch(:name, 'text'),
28
- content: { plain_text: text, type: 'text/plain' })
28
+ @assets.classify(**options.except(:text), name: options.fetch(:name, 'text'),
29
+ content: { plain_text: text, type: 'text/plain' })
30
+ end
29
31
  end
30
32
  end
31
33
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module CalmLens
4
4
  # The gem version. The gemspec and the User-Agent header read it from here.
5
- VERSION = '0.28.2'
5
+ VERSION = '0.29.1'
6
6
  end
@@ -83,11 +83,11 @@ module CalmLens
83
83
  end
84
84
 
85
85
  # Converts an event from {Events#list} to the JSON body of its webhook delivery, which has the
86
- # same fields: `description`, `assetId`, `assetSequence` and `asset` are nil when absent, and
86
+ # same fields: `description`, `assetId` and `assetSequence` are nil when absent, and
87
87
  # `actor` is left out when the event has none.
88
88
  # @param event [Event, Hash] an {Events#list} item, or an event with string keys
89
89
  # @return [Hash] `{ 'id', 'projectId', 'actor', 'type', 'severity', 'title', 'description', 'assetId',
90
- # 'assetSequence', 'asset', 'facts', 'createdAt' }`
90
+ # 'assetSequence', 'facts', 'createdAt' }`
91
91
  def to_payload(event)
92
92
  event = event.to_h if event.is_a?(Model)
93
93
  raise Internal.invalid('event must be an Event or a Hash') unless event.is_a?(Hash)
@@ -96,7 +96,7 @@ module CalmLens
96
96
  payload['actor'] = event['actor'] if event.key?('actor')
97
97
  payload.merge('type' => event['type'], 'severity' => event['severity'], 'title' => event['title'],
98
98
  'description' => event['description'], 'assetId' => event['assetId'],
99
- 'assetSequence' => event['assetSequence'], 'asset' => event['asset'], 'facts' => event['facts'],
99
+ 'assetSequence' => event['assetSequence'], 'facts' => event['facts'],
100
100
  'createdAt' => event['createdAt'])
101
101
  end
102
102
 
@@ -175,12 +175,10 @@ module CalmLens
175
175
  end
176
176
 
177
177
  # The nested fields, when present: `actor` is `{type, id}` with a String type and a String or null
178
- # ID, `asset` has a String `id` and `facts` lists `{key, value, url?}` entries.
178
+ # ID and `facts` lists `{key, value, url?}` entries.
179
179
  def nested?(body)
180
180
  actor = body.fetch('actor', { 'type' => '' })
181
- asset = body['asset']
182
181
  actor.is_a?(Hash) && actor['type'].is_a?(String) && (actor['id'].nil? || actor['id'].is_a?(String)) &&
183
- (asset.nil? || (asset.is_a?(Hash) && asset['id'].is_a?(String))) &&
184
182
  (!body.key?('facts') || (body['facts'].is_a?(Array) && body['facts'].all? { |fact| fact?(fact) }))
185
183
  end
186
184
 
data/lib/calmlens.rb CHANGED
@@ -14,6 +14,7 @@ require_relative 'calmlens/option_keys'
14
14
  require_relative 'calmlens/transform_schema'
15
15
  require_relative 'calmlens/upload_mime_types'
16
16
  require_relative 'calmlens/internal'
17
+ require_relative 'calmlens/request_options'
17
18
  require_relative 'calmlens/transforms'
18
19
  require_relative 'calmlens/transform_rules'
19
20
  require_relative 'calmlens/response'
data/sig/calmlens.rbs CHANGED
@@ -249,10 +249,12 @@ module CalmLens
249
249
  def list_children: (String asset_id, ?cursor: String, ?page_size: Integer, ?sort: sort, ?request_options: request_options) -> AssetPage
250
250
  def list_timeline: (String asset_id, ?cursor: String, ?page_size: Integer, ?request_options: request_options) -> AssetTimelinePage
251
251
  def retrieve: (String asset_id, ?request_options: request_options) -> Asset
252
+ def retrieve_by_external_id: (String external_id, ?request_options: request_options) -> Asset
252
253
  def wait_for_decision: (String asset_id, ?timeout: number, ?request_options: request_options) -> Asset
253
254
  def update: (String asset_id, ?name: String, ?description: String?, ?external_id: String?, ?external_url: String?, ?metadata: Array[metadata_item_input]?, ?tags: Array[String]?, ?visibility: asset_visibility?, ?request_options: request_options) -> Asset
254
255
  def retry: (String asset_id, ?request_options: request_options) -> Asset
255
256
  def decide: (String asset_id, decision: "allowed" | "limited" | "age-restricted" | "blocked" | "purged", note: String, ?confirm_purge: true, ?request_options: request_options) -> Asset
257
+ def request_review: (String asset_id, ?note: String, ?request_options: request_options) -> AssetReviewRequest
256
258
  def remove_content: (String asset_id, ?request_options: request_options) -> Asset
257
259
  def delete: (String asset_id, ?request_options: request_options) -> nil
258
260
  def batch: (asset_ids: Array[String], operation: asset_batch_operation, ?request_options: request_options) -> AssetBatch
@@ -345,7 +347,10 @@ module CalmLens
345
347
  end
346
348
 
347
349
  class Events < Resource
350
+ private def initialize: (untyped session, Assets assets) -> void
348
351
  def list: (?cursor: String, ?page_size: Integer, ?types: Array[event_type], ?asset_id: String, ?request_options: request_options) -> EventPage
352
+ # The asset an event is about, as it is now; nil for an event that isn't about an asset.
353
+ def retrieve_asset: (Event | Hash[String, untyped] event, ?request_options: request_options?) -> Asset?
349
354
  end
350
355
 
351
356
  class CDN < Resource
@@ -494,6 +499,8 @@ module CalmLens
494
499
  end
495
500
 
496
501
  API_KEY_PREFIX: String
502
+ # The ID of every mock API key: the `id` of its events' `actor` and its reviews' `decided_by`.
503
+ API_KEY_ID: String
497
504
 
498
505
  # A mock API key carrying permission grants, such as `assets:download` for CDN reads.
499
506
  def self.create_api_key: (?Array[Hash[Symbol | String, untyped]] grants) -> String
@@ -509,11 +516,17 @@ module CalmLens
509
516
  ?log_level: ("info" | "debug")?, ?on_request: (^(request_event event) -> void)?) -> void
510
517
  # Replaces the mock API key's grants for later requests; the key stays the same.
511
518
  def api_key_grants=: (Array[Hash[Symbol | String, untyped]] grants) -> Array[Hash[Symbol | String, untyped]]
512
- # Fails the next request (or the next one `operation` sends) with `transport-error`, `timeout`, an
513
- # API error code (with optional `details` and `Retry-After` seconds, which only an API error takes) or
514
- # an exception.
515
- def fail_next_request: (?(String | Exception) failure, ?operation: String?, ?details: Hash[String | Symbol, untyped]?,
519
+ # Fails the next request (or the next one `operation` sends), or the next `times` of them, with
520
+ # `transport-error`, `timeout`, an API error code (with optional `details` and `Retry-After` seconds,
521
+ # which only an API error takes) or an exception.
522
+ def fail_next_request: (?(String | Exception) failure, ?operation: String?, ?times: Integer, ?details: Hash[String | Symbol, untyped]?,
516
523
  ?retry_after: Integer?) -> self
524
+ # Fails every matching request as fail_next_request would, until clear_failures.
525
+ def fail_requests: (?(String | Exception) failure, ?operation: String?, ?details: Hash[String | Symbol, untyped]?,
526
+ ?retry_after: Integer?) -> self
527
+ def clear_failures: () -> self
528
+ # Makes a URL upload of `url` store `content` (bytes, or UTF-8 text) typed by its content `type`.
529
+ def serve_url: (String url, content: String, type: String) -> self
517
530
  def state: () -> Testing::State
518
531
  # `body` is any JSON value, encoded as the response body.
519
532
  def enqueue: (body: json_input, ?status: Integer, ?headers: Hash[String, String]) -> self
data/sig/error_codes.rbs CHANGED
@@ -68,6 +68,7 @@ module CalmLens
68
68
  ASSET_NOT_RETRYABLE: String
69
69
  ASSET_CONTENT_UNAVAILABLE: String
70
70
  ASSET_CONTENT_PURGED: String
71
+ ASSET_NOT_REVIEWABLE: String
71
72
  SUPPORT_TICKET_NOT_FOUND: String
72
73
  DUPLICATE_EXTERNAL_ID: String
73
74
  FOLDER_NOT_FOUND: String
data/sig/models.rbs CHANGED
@@ -2,7 +2,7 @@
2
2
  module CalmLens
3
3
  type moderation_qualifier = "sexual-pornographic-media" | "hate-nazi-symbols-public-display" | "hate-nazi-insignia-public-display" | "hate-nazi-genocide-public-peace" | "hate-nazi-genocide-denial-or-approval" | "hate-adjudicated-nazi-crimes-denial" | "violence-high-impact" | "self-harm-age-restricted" | "personal-information-contact" | "personal-information-email" | "personal-information-phone" | "personal-information-government-id" | "personal-information-financial" | "personal-information-location" | "personal-information-identifiers" | "personal-information-credentials" | "personal-information-request" | "personal-information-self-disclosure" | "personal-information-third-party" | "personal-information-historical" | "personal-information-documentary" | "personal-information-educational" | "personal-information-fictional" | "personal-information-support-prevention" | "profanity-mild" | "profanity-strong" | "profanity-slurs" | "profanity-obfuscated" | "profanity-historical" | "profanity-documentary" | "profanity-educational" | "profanity-fictional" | "profanity-support-prevention" | "sexual-nudity" | "sexual-activity" | "sexual-explicit-language" | "sexual-assault-media" | "sexual-non-consensual" | "sexual-intimate-image-abuse" | "sexual-extreme" | "sexual-strangulation" | "sexual-incest" | "sexual-minors" | "sexual-solicitation" | "sexual-paid" | "sexual-adult-promotion" | "sexual-revealing-clothing" | "sexual-suggestive" | "sexual-non-erotic-nudity" | "sexual-text" | "sexual-historical" | "sexual-documentary" | "sexual-educational" | "sexual-discussion" | "sexual-fictional" | "sexual-artistic" | "sexual-support-prevention" | "violence-attack" | "violence-threat" | "violence-preparation" | "violence-encouragement" | "violence-wish" | "violence-coded-incitement" | "violence-extremism" | "violence-injury" | "violence-violent-death" | "violence-natural-death" | "violence-graphic" | "violence-decapitation-act" | "violence-gore" | "violence-weapon" | "violence-sport" | "violence-text" | "violence-historical" | "violence-documentary" | "violence-educational" | "violence-discussion" | "violence-fictional" | "violence-fantasy" | "violence-support-prevention" | "self-harm-thoughts" | "self-harm-preparation" | "self-harm-act" | "self-harm-methods" | "self-harm-encouragement" | "self-harm-historical" | "self-harm-documentary" | "self-harm-educational" | "self-harm-fictional" | "self-harm-support-prevention" | "harassment-abuse" | "harassment-mild" | "harassment-bullying" | "harassment-public-target" | "harassment-threat" | "harassment-sexual" | "harassment-encouragement" | "harassment-historical" | "harassment-documentary" | "harassment-educational" | "harassment-fictional" | "harassment-support-prevention" | "hate-abuse" | "hate-slurs" | "hate-dehumanization" | "hate-inferiority" | "hate-exclusion" | "hate-symbol" | "hate-hostility" | "hate-threat" | "hate-personal" | "hate-historical" | "hate-documentary" | "hate-educational" | "hate-fictional" | "hate-counterspeech" | "hate-support-prevention" | "criminal-activity-demonstration" | "criminal-activity-preparation" | "criminal-activity-request" | "criminal-activity-instructions" | "criminal-activity-promotion" | "criminal-activity-coded-incitement" | "criminal-activity-substances" | "criminal-activity-grooming" | "criminal-activity-csam" | "criminal-activity-alcohol" | "criminal-activity-tobacco" | "criminal-activity-gambling" | "criminal-activity-fraud" | "criminal-activity-sexual-solicitation" | "criminal-activity-graffiti" | "criminal-activity-historical" | "criminal-activity-documentary" | "criminal-activity-educational" | "criminal-activity-discussion" | "criminal-activity-fictional" | "criminal-activity-support-prevention"
4
4
  type event_type = "asset.uploaded" | "asset.classified" | "asset.region-restricted" | "asset.allowed" | "asset.limited" | "asset.age-restricted" | "asset.blocked" | "asset.purged" | "asset.failed" | "asset.progress-updated" | "asset.media-ready" | "asset.deleted" | "asset.content-removed" | "asset.retried" | "asset.review-requested" | "asset.review-completed" | "asset.hash-matched" | "usage.free-uploads-exhausted" | "usage.uploads-paused" | "upload-preset.daily-limit-reached" | "project.member-joined" | "project.member-removed" | "project.member-left" | "project.member-role-changed" | "project.invitation-sent" | "project.transferred" | "api-key.created" | "api-key.revoked" | "api-key.deleted" | "connector.disabled"
5
- type event_fact_key = "asset-name" | "asset-type" | "file-format" | "test" | "parent-asset" | "flagged-categories" | "moderation-status" | "automated-status" | "region" | "rule" | "status" | "reviewer-name" | "note" | "child-asset" | "child-status" | "previous-status" | "failure-reason" | "completed-sections" | "total-sections" | "batch-id" | "review-reason" | "uncertain-categories" | "review-id" | "decision" | "applied-to-asset" | "hash-list-id" | "hash-list-name" | "distance" | "match-action" | "limit" | "used" | "organisation-id" | "reason" | "resumes-at" | "preset-id" | "preset-name" | "daily-limit" | "member-user-id" | "member-name" | "role" | "previous-role" | "invitee-email" | "previous-organisation-id" | "previous-organisation-name" | "organisation-name" | "method" | "api-keys-revoked" | "connectors-paused" | "key-id" | "key-name" | "created-by-name" | "revoked-by-name" | "deleted-by-name" | "connector-id" | "connector-name" | "connector-type" | "consecutive-failures" | "last-error"
5
+ type event_fact_key = "asset-name" | "asset-type" | "file-format" | "test" | "parent-asset" | "flagged-categories" | "moderation-status" | "automated-status" | "region" | "rule" | "status" | "reviewer-name" | "note" | "child-asset" | "child-status" | "previous-status" | "failure-reason" | "completed-sections" | "total-sections" | "batch-id" | "review-id" | "review-reason" | "uncertain-categories" | "decision" | "applied-to-asset" | "hash-list-id" | "hash-list-name" | "distance" | "match-action" | "limit" | "used" | "organisation-id" | "reason" | "resumes-at" | "preset-id" | "preset-name" | "daily-limit" | "member-user-id" | "member-name" | "role" | "previous-role" | "invitee-email" | "previous-organisation-id" | "previous-organisation-name" | "organisation-name" | "method" | "api-keys-revoked" | "connectors-paused" | "key-id" | "key-name" | "created-by-name" | "revoked-by-name" | "deleted-by-name" | "connector-id" | "connector-name" | "connector-type" | "consecutive-failures" | "last-error"
6
6
  class Asset < Model
7
7
  def id: () -> String
8
8
  def project_id: () -> String
@@ -25,6 +25,7 @@ module CalmLens
25
25
  def upload: () -> Asset::Upload
26
26
  def classification: () -> Classification
27
27
  def content: () -> Asset::Content
28
+ def event_sequence: () -> Integer
28
29
  end
29
30
  class AssetBatch < Model
30
31
  def batch_id: () -> String
@@ -36,6 +37,14 @@ module CalmLens
36
37
  def next_cursor: () -> String?
37
38
  def has_more: () -> bool
38
39
  end
40
+ class AssetReviewRequest < Model
41
+ def id: () -> String
42
+ def asset_id: () -> String
43
+ def reason: () -> ("sampled" | "uncertain" | "reported")
44
+ def status: () -> ("pending" | "completed")
45
+ def note: () -> String?
46
+ def created_at: () -> Integer
47
+ end
39
48
  class AssetSearchResult < Model
40
49
  def query: () -> String
41
50
  def items: () -> Array[AssetSearchResult::Item]
@@ -107,7 +116,6 @@ module CalmLens
107
116
  def description: () -> String?
108
117
  def asset_id: () -> String?
109
118
  def asset_sequence: () -> Integer?
110
- def asset: () -> Event::Asset?
111
119
  def facts: () -> Array[Event::Fact]
112
120
  def created_at: () -> Integer
113
121
  end
@@ -344,14 +352,6 @@ module CalmLens
344
352
  def type: () -> actor_type
345
353
  def id: () -> String?
346
354
  end
347
- class Event::Asset < Model
348
- def id: () -> String
349
- def external_id: () -> String?
350
- def upload_preset_id: () -> String?
351
- def upload: () -> Event::Asset::Upload
352
- def classification: () -> Event::Asset::Classification
353
- def content: () -> Event::Asset::Content
354
- end
355
355
  class Event::Fact < Model
356
356
  def key: () -> event_fact_key
357
357
  def value: () -> (Array[classification_category] | String | Integer | bool)?
@@ -375,7 +375,7 @@ module CalmLens
375
375
  end
376
376
  class Moderation::PendingReview < Model
377
377
  def requested_at: () -> Integer
378
- def reason: () -> ("sampled" | "uncertain")
378
+ def reason: () -> ("sampled" | "uncertain" | "reported")
379
379
  def uncertain_categories: () -> Array[classification_category]
380
380
  end
381
381
  class Moderation::Policy < Model
@@ -490,17 +490,6 @@ module CalmLens
490
490
  def box: () -> Classification::Ocr::TextRegion::Box
491
491
  def confidence: () -> number
492
492
  end
493
- class Event::Asset::Classification < Model
494
- def status: () -> asset_classification_status
495
- def test_input: () -> bool
496
- def moderation: () -> Event::Asset::Classification::Moderation
497
- end
498
- class Event::Asset::Content < Model
499
- def status: () -> asset_content_status
500
- end
501
- class Event::Asset::Upload < Model
502
- def status: () -> ("uploading" | "completed")
503
- end
504
493
  class Moderation::ManualReview::DecidedBy < Model
505
494
  def type: () -> ("user" | "api-key")
506
495
  def id: () -> String?
@@ -557,9 +546,6 @@ module CalmLens
557
546
  def width: () -> number
558
547
  def height: () -> number
559
548
  end
560
- class Event::Asset::Classification::Moderation < Model
561
- def decision: () -> asset_moderation_decision?
562
- end
563
549
  class UploadPreset::ProcessingOptions::Features::FaceDetection < Model
564
550
  def enabled: () -> bool
565
551
  def age_estimation: () -> bool?
data/sig/types.rbs CHANGED
@@ -16,6 +16,9 @@ module CalmLens
16
16
  type request_options = {
17
17
  ?idempotency_key: String,
18
18
  ?timeout: number,
19
+ # Milliseconds for the whole call: every attempt, the waits between retries and
20
+ # wait_for_decision's checks.
21
+ ?deadline_ms: Integer,
19
22
  ?open_timeout: number,
20
23
  ?upload_timeout: number,
21
24
  ?max_retries: Integer,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: calmlens
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.28.2
4
+ version: 0.29.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - CalmLens
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-11-28 00:00:00.000000000 Z
11
+ date: 2026-11-29 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: 'Server-side client for the CalmLens API: moderation, uploads, events,
14
14
  webhooks and CDN delivery.'
@@ -35,6 +35,7 @@ files:
35
35
  - lib/calmlens/option_keys.rb
36
36
  - lib/calmlens/policies.rb
37
37
  - lib/calmlens/project_configuration.rb
38
+ - lib/calmlens/request_options.rb
38
39
  - lib/calmlens/resource.rb
39
40
  - lib/calmlens/response.rb
40
41
  - lib/calmlens/server_client.rb