calmlens 0.24.0 → 0.27.2

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/calmlens.rbs CHANGED
@@ -16,6 +16,7 @@ module CalmLens
16
16
  INVALID_RESPONSE: String
17
17
  HTTP_ERROR: String
18
18
  RESPONSE_TOO_LARGE: String
19
+ CANCELLED: String
19
20
  INVALID_WEBHOOK_SIGNATURE: String
20
21
  INVALID_WEBHOOK_PAYLOAD: String
21
22
  end
@@ -27,8 +28,15 @@ module CalmLens
27
28
  attr_reader status: Integer?
28
29
  attr_reader request_id: String?
29
30
  attr_reader headers: Hash[String, String]
31
+ # The error response's body as received, at most BODY_LIMIT bytes; nil without a response.
32
+ attr_reader body: String?
33
+ # The request's HTTP method and URL, for an API error response.
34
+ attr_reader http_method: String?
35
+ attr_reader url: String?
36
+ BODY_LIMIT: Integer
30
37
  def initialize: (String code, ?String? message, ?details: Hash[String, json_value]?, ?status: Integer?,
31
- ?headers: Hash[String, String], ?request_id: String?) -> void
38
+ ?headers: Hash[String, String], ?request_id: String?, ?body: String?, ?http_method: String?,
39
+ ?url: String?) -> void
32
40
  # Whole seconds from the `Retry-After` header.
33
41
  def retry_after: () -> Integer?
34
42
  def local?: () -> bool
@@ -43,15 +51,68 @@ module CalmLens
43
51
  class PermissionDeniedError < APIError end
44
52
  class NotFoundError < APIError end
45
53
  class ConflictError < APIError end
54
+ class PayloadTooLargeError < APIError end
55
+ class UnprocessableEntityError < APIError end
46
56
  class RateLimitError < APIError end
47
57
  class ServerError < APIError end
48
58
  class ConnectionError < Error end
49
- class TimeoutError < ConnectionError end
59
+ class TimeoutError < Error end
60
+ class CancelledError < Error end
50
61
  class InvalidResponseError < Error end
51
62
  class InvalidArgumentError < Error end
52
63
  class ConfigurationError < InvalidArgumentError end
53
64
  class WebhookVerificationError < Error end
54
65
 
66
+ # A read-only API object. Fields have snake_case readers and can be read with `[]` by reader name
67
+ # or API key; to_h is the API's JSON form.
68
+ # What the API answered to the request that returned a result.
69
+ class LastResponse
70
+ attr_reader status: Integer
71
+ attr_reader headers: Hash[String, String]
72
+ attr_reader request_id: String?
73
+ attr_reader idempotency_key: String?
74
+ def initialize: (status: Integer, headers: Hash[String, String], request_id: String?, idempotency_key: String?) -> void
75
+ end
76
+
77
+ class Model
78
+ def initialize: (Hash[String, untyped] values, ?last_response: LastResponse?) -> void
79
+ # The response that returned this result; nil for an object inside one.
80
+ attr_reader last_response: LastResponse?
81
+ def []: (Symbol | String key) -> untyped
82
+ def key?: (Symbol | String key) -> bool
83
+ def dig: (Symbol | String key, *untyped rest) -> untyped
84
+ def values_at: (*(Symbol | String) keys) -> Array[untyped]
85
+ def keys: () -> Array[Symbol]
86
+ def to_h: () -> Hash[String, json_value]
87
+ def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped]
88
+ def to_json: (*untyped) -> String
89
+ def ==: (untyped other) -> bool
90
+ def eql?: (untyped other) -> bool
91
+ def hash: () -> Integer
92
+ end
93
+
94
+ # One page of a list; enumerating it yields this page's items.
95
+ class Page[T] < Model
96
+ include Enumerable[T]
97
+ def initialize: (Hash[String, untyped] values, ?fetch: (^(String cursor) -> Page[T])?, ?cursor: String?,
98
+ ?last_response: LastResponse?) -> void
99
+ def each: () { (T) -> void } -> self
100
+ | () -> Enumerator[T, self]
101
+ def empty?: () -> bool
102
+ def next_page?: () -> bool
103
+ def next_page: () -> self
104
+ def each_page: () { (self) -> void } -> nil
105
+ | () -> Enumerator[self, nil]
106
+ def auto_paging_each: () { (T) -> void } -> nil
107
+ | () -> Enumerator[T, nil]
108
+ end
109
+
110
+ class ServedAssetInfo < Struct[Integer]
111
+ def initialize: (width: Integer, height: Integer) -> void
112
+ attr_reader width: Integer
113
+ attr_reader height: Integer
114
+ end
115
+
55
116
  class Response
56
117
  attr_reader status: Integer
57
118
  attr_reader headers: Hash[String, String]
@@ -62,6 +123,7 @@ module CalmLens
62
123
  def request_id: () -> String?
63
124
  def content_type: () -> String?
64
125
  def content_length: () -> Integer?
126
+ def get_asset_info: () -> ServedAssetInfo?
65
127
  def success?: () -> bool
66
128
  def each_chunk: () { (String chunk) -> void } -> nil
67
129
  | () -> Enumerator[String, nil]
@@ -107,7 +169,7 @@ module CalmLens
107
169
  DEFAULT_OPEN_TIMEOUT: Integer
108
170
  DEFAULT_MAX_RETRIES: Integer
109
171
  DEFAULT_RETRY_BASE_DELAY: Float
110
- RETRY_MAX_DELAY: Integer
172
+ DEFAULT_MAX_RETRY_DELAY: Integer
111
173
  RETRY_AFTER_MAX: Integer
112
174
  DEFAULT_MAX_RESPONSE_BYTES: Integer
113
175
  DEFAULT_PART_SIZE_BYTES: Integer
@@ -129,12 +191,29 @@ module CalmLens
129
191
  attr_reader project_id: String
130
192
  attr_reader base_url: String
131
193
  attr_reader cdn_base_url: String
132
- def initialize: (api_key: String, project_id: String, ?base_url: String, ?cdn_base_url: String, ?timeout: number,
194
+ def initialize: (?api_key: String?, ?project_id: String?, ?base_url: String, ?cdn_base_url: String, ?timeout: number,
133
195
  ?open_timeout: number, ?upload_timeout: number?, ?max_retries: Integer, ?retry_base_delay: number,
134
- ?max_response_bytes: Integer, ?part_size_bytes: Integer, ?transport: Transport::_Transport?) -> void
196
+ ?max_retry_delay: number, ?max_response_bytes: Integer, ?part_size_bytes: Integer,
197
+ ?transport: Transport::_Transport?, ?app_info: app_info?, ?logger: _Logger?, ?log_level: ("info" | "debug")?,
198
+ ?on_request: (^(request_event event) -> void)?) -> void
135
199
  def close: () -> nil
136
- def ensure_lenses: (ensure_lenses_options options) -> Array[lens]
137
- def ensure_lens: (ensure_lens_options options) -> lens
200
+ # Sends a request to any API path with the client's authentication, retries and error mapping.
201
+ def request: (String method, String path, ?query: Hash[String | Symbol, untyped], ?body: Hash[String | Symbol, untyped]?,
202
+ ?headers: Hash[String, String], ?request_options: request_options) -> (Model | json_value)
203
+ def ensure_lenses: (lenses: Array[lens_definition], ?request_options: request_options) -> Array[Lens]
204
+ def ensure_lens: (identifier: String, name: String, type: lens_type, ?active: bool, ?description: String?, ?transform: image_transform_options_input?, ?request_options: request_options) -> Lens
205
+ end
206
+
207
+ # Your integration's name, version and URL, added to the User-Agent.
208
+ type app_info = { name: String, ?version: String, ?url: String }
209
+ # One request attempt, as ServerClient's `on_request:` hook receives it.
210
+ type request_event = { operation: String?, method: String, path: String?, attempt: Integer, delay: number?,
211
+ status: Integer?, request_id: String?, error_code: String?, duration: Float }
212
+
213
+ # A Ruby Logger, or anything with `info` and `debug` taking a block.
214
+ interface _Logger
215
+ def info: () { () -> String } -> untyped
216
+ def debug: () { () -> String } -> untyped
138
217
  end
139
218
 
140
219
  class Resource
@@ -162,102 +241,90 @@ module CalmLens
162
241
  BATCH_OPERATIONS: Array[asset_batch_operation]
163
242
  MAX_BATCH_ASSETS: Integer
164
243
 
165
- def search: (asset_search_options options) -> asset_search_response
166
- def list: (?list_assets_options options) -> asset_page
167
- def each: (?list_assets_options options) { (asset) -> void } -> nil
168
- | (?list_assets_options options) -> Enumerator[asset, nil]
169
- def list_children: (list_asset_children_options options) -> asset_page
170
- def each_child: (list_asset_children_options options) { (asset) -> void } -> nil
171
- | (list_asset_children_options options) -> Enumerator[asset, nil]
172
- def list_timeline: (list_asset_timeline_options options) -> asset_timeline_page
173
- def each_timeline_segment: (list_asset_timeline_options options) { (media_segment) -> void } -> nil
174
- | (list_asset_timeline_options options) -> Enumerator[media_segment, nil]
175
- def retrieve: (asset_id_options options) -> asset
176
- def wait_for_decision: (wait_for_decision_options options) -> asset
177
- def update: (update_asset_options options) -> asset
178
- def retry: (asset_id_options options) -> asset
179
- def decide: (decide_asset_options options) -> asset
180
- def explain: (explain_asset_options options) -> asset
181
- def remove_content: (asset_id_options options) -> asset
182
- def delete: (asset_id_options options) -> nil
183
- def batch: (batch_assets_options options) -> batch_assets_response
184
- def move: (move_asset_options options) -> asset
185
- def create: (upload_options options) -> asset
186
- def classify: (upload_options options) -> asset
187
- def upload_part: (upload_part_options options) -> asset
244
+ def search: (query: String, ?mode: asset_search_mode, ?page_size: Integer, ?request_options: request_options) -> AssetSearchResult
245
+ def list: (?cursor: String, ?page_size: Integer, ?sort: sort, ?filter: String?, ?request_options: request_options) -> AssetPage
246
+ def list_children: (String asset_id, ?cursor: String, ?page_size: Integer, ?sort: sort, ?request_options: request_options) -> AssetPage
247
+ def list_timeline: (String asset_id, ?cursor: String, ?page_size: Integer, ?request_options: request_options) -> AssetTimelinePage
248
+ def retrieve: (String asset_id, ?request_options: request_options) -> Asset
249
+ def wait_for_decision: (String asset_id, ?timeout: number, ?request_options: request_options) -> Asset
250
+ 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
251
+ def retry: (String asset_id, ?request_options: request_options) -> Asset
252
+ def decide: (String asset_id, decision: "allowed" | "limited" | "age-restricted" | "blocked" | "purged", note: String, ?confirm_purge: true, ?request_options: request_options) -> Asset
253
+ def remove_content: (String asset_id, ?request_options: request_options) -> Asset
254
+ def delete: (String asset_id, ?request_options: request_options) -> nil
255
+ def batch: (asset_ids: Array[String], operation: asset_batch_operation, ?request_options: request_options) -> AssetBatch
256
+ def move: (String asset_id, folder_id: String?, ?request_options: request_options) -> Asset
257
+ def create: (name: String, content: upload_content, ?description: String?, ?visibility: asset_visibility?, ?metadata: Array[metadata_item_input]?, ?tags: Array[String]?, ?author_id: String, ?context: moderation_context_input, ?external_id: String?, ?external_url: String?, ?folder_id: String?, ?upload_preset_id: String, ?processing_options: processing_options_input?, ?request_options: request_options) -> Asset
258
+ | (name: String, part: upload_first_part, ?total_size_in_bytes: Integer, ?description: String?, ?visibility: asset_visibility?, ?metadata: Array[metadata_item_input]?, ?tags: Array[String]?, ?author_id: String, ?context: moderation_context_input, ?external_id: String?, ?external_url: String?, ?folder_id: String?, ?upload_preset_id: String, ?processing_options: processing_options_input?, ?request_options: request_options) -> Asset
259
+ | (name: String, url: String, ?description: String?, ?visibility: asset_visibility?, ?metadata: Array[metadata_item_input]?, ?tags: Array[String]?, ?author_id: String, ?context: moderation_context_input, ?external_id: String?, ?external_url: String?, ?folder_id: String?, ?upload_preset_id: String, ?processing_options: processing_options_input?, ?request_options: request_options) -> Asset
260
+ def classify: (name: String, content: upload_content, ?description: String?, ?visibility: asset_visibility?, ?metadata: Array[metadata_item_input]?, ?tags: Array[String]?, ?author_id: String, ?context: moderation_context_input, ?external_id: String?, ?external_url: String?, ?folder_id: String?, ?upload_preset_id: String, ?processing_options: processing_options_input?, ?request_options: request_options) -> Asset
261
+ | (name: String, part: upload_first_part, ?total_size_in_bytes: Integer, ?description: String?, ?visibility: asset_visibility?, ?metadata: Array[metadata_item_input]?, ?tags: Array[String]?, ?author_id: String, ?context: moderation_context_input, ?external_id: String?, ?external_url: String?, ?folder_id: String?, ?upload_preset_id: String, ?processing_options: processing_options_input?, ?request_options: request_options) -> Asset
262
+ | (name: String, url: String, ?description: String?, ?visibility: asset_visibility?, ?metadata: Array[metadata_item_input]?, ?tags: Array[String]?, ?author_id: String, ?context: moderation_context_input, ?external_id: String?, ?external_url: String?, ?folder_id: String?, ?upload_preset_id: String, ?processing_options: processing_options_input?, ?request_options: request_options) -> Asset
263
+ def upload_part: (String asset_id, part: upload_part, ?wait: bool, ?request_options: request_options) -> Asset
188
264
  # Waits between decision checks; a mock client's waits take no real time.
189
265
  private def sleep: (Numeric seconds) -> void
190
266
  end
191
267
 
192
268
  class Folders < Resource
193
- def list: (?list_folders_options options) -> folder_page
194
- def each: (?list_folders_options options) { (folder) -> void } -> nil
195
- | (?list_folders_options options) -> Enumerator[folder, nil]
196
- def create: (create_folder_options options) -> folder
197
- def retrieve: (folder_id_options options) -> folder
198
- def update: (update_folder_options options) -> folder
199
- def move: (move_folder_options options) -> folder
200
- def delete: (folder_id_options options) -> nil
269
+ def list: (?parent_id: String, ?cursor: String, ?page_size: Integer, ?sort: sort, ?search: String, ?request_options: request_options) -> FolderPage
270
+ def create: (name: String, ?parent_id: String?, ?request_options: request_options) -> Folder
271
+ def retrieve: (String folder_id, ?request_options: request_options) -> Folder
272
+ def update: (String folder_id, ?name: String, ?request_options: request_options) -> Folder
273
+ def move: (String folder_id, parent_id: String?, ?request_options: request_options) -> Folder
274
+ def delete: (String folder_id, ?request_options: request_options) -> nil
201
275
  end
202
276
 
203
277
  class HashLists < Resource
204
- def list: (?list_hash_lists_options options) -> hash_list_page
205
- def each: (?list_hash_lists_options options) { (hash_list) -> void } -> nil
206
- | (?list_hash_lists_options options) -> Enumerator[hash_list, nil]
207
- def retrieve: (hash_list_id_options options) -> hash_list
208
- def create: (create_hash_list_options options) -> hash_list
209
- def update: (update_hash_list_options options) -> hash_list
210
- def delete: (hash_list_id_options options) -> nil
211
- def list_entries: (list_hash_list_entries_options options) -> hash_list_entry_page
212
- def each_entry: (list_hash_list_entries_options options) { (hash_list_entry) -> void } -> nil
213
- | (list_hash_list_entries_options options) -> Enumerator[hash_list_entry, nil]
214
- def add_entry: (add_hash_list_entry_options options) -> hash_list_entry
215
- def remove_entry: (hash_list_entry_id_options options) -> nil
278
+ def list: (?cursor: String, ?page_size: Integer, ?sort: sort, ?request_options: request_options) -> HashListPage
279
+ def retrieve: (String hash_list_id, ?request_options: request_options) -> HashList
280
+ def create: (name: String, action: hash_list_action, ?description: String?, ?request_options: request_options) -> HashList
281
+ def update: (String hash_list_id, ?name: String, ?description: String?, ?action: hash_list_action, ?request_options: request_options) -> HashList
282
+ def delete: (String hash_list_id, ?request_options: request_options) -> nil
283
+ def list_entries: (String hash_list_id, ?cursor: String, ?page_size: Integer, ?sort: sort, ?request_options: request_options) -> HashListEntryPage
284
+ def add_entry: (String hash_list_id, ?hash: String, ?quality: number, ?asset_id: String, ?label: String, ?request_options: request_options) -> HashListEntry
285
+ def remove_entry: (String entry_id, ?request_options: request_options) -> nil
216
286
  end
217
287
 
218
288
  class Policies < Resource
219
- def list: (?list_policies_options options) -> policy_page
220
- def each: (?list_policies_options options) { (policy) -> void } -> nil
221
- | (?list_policies_options options) -> Enumerator[policy, nil]
222
- def retrieve: (policy_id_options options) -> policy
289
+ def list: (?cursor: String, ?page_size: Integer, ?sort: sort, ?request_options: request_options) -> PolicyPage
290
+ def retrieve: (String policy_id, ?request_options: request_options) -> Policy
223
291
  # The policy the project moderates with.
224
- def retrieve_assigned: (?request_only_options options) -> policy
225
- def create: (create_policy_options options) -> policy
226
- def update: (update_policy_options options) -> policy
227
- def reset: (restore_policy_options options) -> policy
228
- def upgrade: (restore_policy_options options) -> policy
229
- def set_automatic_updates: (set_policy_automatic_updates_options options) -> policy
230
- def delete: (policy_id_options options) -> nil
231
- def assign: (assign_policy_options options) -> policy
292
+ def retrieve_assigned: (?request_options: request_options) -> Policy
293
+ def create: (?name: String, ?description: String, ?settings: policy_settings_input, ?preset_id: policy_preset_id, ?request_options: request_options) -> Policy
294
+ def update: (String policy_id, revision: Integer, ?name: String, ?description: String, ?settings: policy_settings_input, ?request_options: request_options) -> Policy
295
+ def reset: (String policy_id, revision: Integer, preset_version: Integer, ?request_options: request_options) -> Policy
296
+ def upgrade: (String policy_id, revision: Integer, preset_version: Integer, ?request_options: request_options) -> Policy
297
+ def set_automatic_updates: (String policy_id, enabled: bool, revision: Integer, preset_version: Integer, ?request_options: request_options) -> Policy
298
+ def delete: (String policy_id, ?request_options: request_options) -> nil
299
+ def assign: (policy_id: String, ?request_options: request_options) -> Policy
232
300
  end
233
301
 
234
302
  class Lenses < Resource
235
- def list: (?list_lenses_options options) -> lens_page
236
- def each: (?list_lenses_options options) { (lens) -> void } -> nil
237
- | (?list_lenses_options options) -> Enumerator[lens, nil]
238
- def create: (create_lens_options options) -> lens
239
- def retrieve: (lens_id_options options) -> lens
240
- def update: (update_lens_options options) -> lens
241
- def delete: (lens_id_options options) -> nil
303
+ # ServerClient#ensure_lenses and #ensure_lens call these.
304
+ private def ensure_lenses: (lenses: Array[lens_definition], ?request_options: request_options) -> Array[Lens]
305
+ private def ensure_lens: (identifier: String, name: String, type: lens_type, ?active: bool, ?description: String?, ?transform: image_transform_options_input?, ?request_options: request_options) -> Lens
306
+ def list: (?cursor: String, ?page_size: Integer, ?sort: sort, ?request_options: request_options) -> LensPage
307
+ def create: (identifier: String, name: String, type: lens_type, ?active: bool, ?description: String?, ?transform: image_transform_options_input?, ?request_options: request_options) -> Lens
308
+ def retrieve: (String lens_id, ?request_options: request_options) -> Lens
309
+ def update: (String lens_id, ?name: String, ?description: String?, ?type: lens_type, ?active: bool, ?transform: image_transform_options_input?, ?request_options: request_options) -> Lens
310
+ def delete: (String lens_id, ?request_options: request_options) -> nil
242
311
  end
243
312
 
244
313
  class UploadPresets < Resource
245
- def list: (?list_upload_presets_options options) -> upload_preset_page
246
- def each: (?list_upload_presets_options options) { (upload_preset) -> void } -> nil
247
- | (?list_upload_presets_options options) -> Enumerator[upload_preset, nil]
248
- def ensure: (ensure_upload_presets_options options) -> ensure_upload_presets_response
249
- def delete: (upload_preset_id_options options) -> nil
314
+ def list: (?cursor: String, ?page_size: Integer, ?sort: sort, ?request_options: request_options) -> UploadPresetPage
315
+ def ensure: (upload_presets: Array[upload_preset_definition], ?request_options: request_options) -> UploadPresetsEnsured
316
+ def delete: (String upload_preset_id, ?request_options: request_options) -> nil
250
317
  end
251
318
 
252
319
  class ProjectSettings < Resource
253
- def get: (?request_only_options options) -> project_settings_resource
254
- def update: (update_project_settings_options options) -> project_settings_resource
320
+ def get: (?request_options: request_options) -> ProjectSettingsResource
321
+ def update: (?revision: Integer, settings: project_settings_input, ?search_indexing_budget_units: number, ?request_options: request_options) -> ProjectSettingsResource
255
322
  end
256
323
 
257
324
  class MetadataFields < Resource
258
- def list: (?request_only_options options) -> metadata_fields_resource
259
- def ensure: (ensure_metadata_fields_options options) -> metadata_fields_resource
260
- def delete: (delete_metadata_field_options options) -> nil
325
+ def list: (?request_options: request_options) -> MetadataFieldsResource
326
+ def ensure: (?revision: Integer, fields: Array[metadata_field_input], ?request_options: request_options) -> MetadataFieldsResource
327
+ def delete: (String field_id, ?revision: Integer, ?request_options: request_options) -> nil
261
328
  end
262
329
 
263
330
  class UploadTokens < Resource
@@ -266,20 +333,16 @@ module CalmLens
266
333
  DEFAULT_TTL_SECONDS: Integer
267
334
  MAX_TTL_SECONDS: Integer
268
335
  private def initialize: (untyped session, String api_key) -> void
269
- def sign: (sign_upload_token_options options) -> signed_upload_token
336
+ def sign: (upload_preset_id: String, ?external_id: String, ?expires_in: Integer, ?request_options: request_options) -> SignedUploadToken
270
337
  end
271
338
 
272
339
  class Text < Resource
273
340
  private def initialize: (untyped session, Assets assets) -> void
274
- def classify: (moderate_text_options options) -> asset
341
+ def classify: (text: String, ?name: String, ?description: String?, ?visibility: asset_visibility?, ?metadata: Array[metadata_item_input]?, ?tags: Array[String]?, ?author_id: String, ?context: moderation_context_input, ?external_id: String?, ?external_url: String?, ?folder_id: String?, ?upload_preset_id: String, ?processing_options: processing_options_input?, ?request_options: request_options) -> Asset
275
342
  end
276
343
 
277
344
  class Events < Resource
278
- def list: (?list_events_options options) -> events_page
279
- def each_page: (?list_events_options options) { (events_page) -> void } -> nil
280
- | (?list_events_options options) -> Enumerator[events_page, nil]
281
- def each: (?list_events_options options) { (event) -> void } -> nil
282
- | (?list_events_options options) -> Enumerator[event, nil]
345
+ def list: (?cursor: String, ?page_size: Integer, ?types: Array[event_type], ?asset_id: String, ?request_options: request_options) -> EventPage
283
346
  end
284
347
 
285
348
  class CDN < Resource
@@ -293,40 +356,46 @@ module CalmLens
293
356
  EXTERNAL_ID_PREFIX: String
294
357
  # The ISO 3166-1 alpha-2 countries a viewer's `region` can be.
295
358
  VIEWER_COUNTRIES: Array[String]
296
- def get_asset_url: (asset_url_options options) -> String
297
- def sign_asset_url: (sign_asset_url_options options) -> signed_asset_url
298
- def get_asset_info: (String url, ?viewer_claims: viewer_claims?) -> asset_info
299
- def serve: (serve_options options) -> Response
300
- | [T] (serve_options options) { (Response) -> T } -> T
301
- end
302
-
303
- # A verified webhook delivery, with the fields of an `events.list` item.
304
- class WebhookEvent < Struct[untyped]
305
- attr_accessor id: String
306
- attr_accessor project_id: String
307
- # nil for a delivery without one.
308
- attr_accessor actor: actor?
309
- # New types may appear: ignore unknown ones.
310
- attr_accessor type: event_type | String
311
- attr_accessor severity: event_severity?
312
- attr_accessor title: String?
313
- attr_accessor description: String?
314
- attr_accessor asset_id: String?
315
- # Increases with each event about the same asset; nil for events not about an asset.
316
- attr_accessor asset_sequence: Integer?
317
- attr_accessor asset: event_asset?
318
- attr_accessor facts: Array[event_fact]
319
- # Milliseconds since the Unix epoch.
320
- attr_accessor created_at: Integer
321
- # The delivery body as received, with every field.
322
- attr_accessor payload: Hash[String, json_value]
323
- def initialize: (?id: String, ?project_id: String, ?type: event_type | String, ?severity: event_severity?, ?title: String?,
324
- ?description: String?, ?asset_id: String?, ?asset_sequence: Integer?, ?asset: event_asset?, ?facts: Array[event_fact],
325
- ?created_at: Integer, ?payload: Hash[String, json_value]) -> void
359
+ def get_asset_url: (?asset_id: String, ?external_id: String, ?project_id: String, ?resource: cdn_resource, ?lens: String, ?transform: transform_input, ?viewer_claims: viewer_claims, ?request_options: request_options) -> String
360
+ def sign_asset_url: (?asset_id: String, ?external_id: String, ?project_id: String, ?expires_in: Integer, ?original: bool, ?resource: cdn_resource, ?lens: String, ?transform: transform_input, ?viewer_claims: viewer_claims, ?request_options: request_options) -> SignedAssetUrl
361
+ def get_asset_info: (String url, ?viewer_claims: viewer_claims?) -> AssetInfo
362
+ def serve: (?asset_id: String, ?external_id: String, ?project_id: String, ?viewer_claims: viewer_claims, ?resource: cdn_resource, ?lens: String, ?transform: transform_input, ?init: { ?method: "GET" | "HEAD", ?headers: Hash[String, String] }, ?request_options: request_options) -> Response
363
+ | [T] (?asset_id: String, ?external_id: String, ?project_id: String, ?viewer_claims: viewer_claims, ?resource: cdn_resource, ?lens: String, ?transform: transform_input, ?init: { ?method: "GET" | "HEAD", ?headers: Hash[String, String] }, ?request_options: request_options) { (Response) -> T } -> T
364
+ end
365
+
366
+ class Event
367
+ # Whether the event is a test send from the portal or CLI.
326
368
  def test?: () -> bool
369
+ # Whether to apply this event after `last_sequence`, the highest `asset_sequence` applied for its asset.
327
370
  def newer_than?: (Integer? last_sequence) -> bool
328
- # The delivery body as received, with every field.
329
- def to_payload: () -> Hash[String, json_value]
371
+ end
372
+
373
+ # The display info of an asset URL, from CDN#get_asset_info.
374
+ class AssetInfo < Model
375
+ class Content < Model
376
+ def format: () -> String?
377
+ def width: () -> Integer?
378
+ def height: () -> Integer?
379
+ def duration_seconds: () -> Float?
380
+ def page_count: () -> Integer?
381
+ def rendered: () -> Asset::Content::Rendered?
382
+ def preview: () -> Asset::Content::Preview?
383
+ def hls: () -> Asset::Content::Hls?
384
+ end
385
+
386
+ def id: () -> String
387
+ def project_id: () -> String
388
+ def type: () -> asset_type
389
+ def external_url: () -> String?
390
+ def content: () -> Content
391
+ def availability: () -> asset_availability
392
+ end
393
+
394
+ # A signed upload token from UploadTokens#sign.
395
+ class SignedUploadToken < Model
396
+ def token: () -> String
397
+ # Milliseconds since the Unix epoch.
398
+ def expires_at: () -> Integer
330
399
  end
331
400
 
332
401
  # Request headers to read webhook headers from: names in any case, repeated values as an Array
@@ -340,54 +409,55 @@ module CalmLens
340
409
  module Webhooks
341
410
  def self.signature_header: (payload: String, timestamp: String | Integer, secret: String) -> String
342
411
  def self.headers: (payload: String, delivery_id: String, secret: String, ?timestamp: Integer) -> Hash[String, String]
343
- def self.to_payload: (event event) -> event
412
+ def self.to_payload: (Event | Hash[String, untyped] event) -> Hash[String, json_value]
344
413
  def self.verify: (payload: String, secret: String, ?signature: String?, ?timestamp: String?, ?headers: webhook_headers?,
345
414
  ?tolerance_seconds: Integer, ?now: number) -> bool
346
415
  def self.verify_request: (payload: String, headers: webhook_headers, secret: String, ?tolerance_seconds: Integer,
347
416
  ?now: number) -> bool
348
417
  def self.parse_event: (payload: String, secret: String, ?signature: String?, ?timestamp: String?, ?headers: webhook_headers?,
349
- ?tolerance_seconds: Integer, ?now: number) -> WebhookEvent
350
- def self.test_event?: (WebhookEvent | Hash[String, untyped] event) -> bool
351
- def self.newer_asset_event?: (WebhookEvent | Hash[String, untyped] event, Integer? last_sequence) -> bool
418
+ ?tolerance_seconds: Integer, ?now: number) -> Event
419
+ def self.test_event?: (Event | Hash[String, untyped] event) -> bool
420
+ def self.newer_asset_event?: (Event | Hash[String, untyped] event, Integer? last_sequence) -> bool
352
421
  # The value of an event's fact by key (the first, when the event repeats it), or nil without one.
353
- def self.get_event_fact: (WebhookEvent | Hash[String, untyped] event, String key) -> event_fact_value
422
+ def self.get_event_fact: (Event | Hash[String, untyped] event, String key) -> event_fact_value
354
423
  # An event's facts as values by key; a repeated key keeps its first value.
355
- def self.get_event_facts: (WebhookEvent | Hash[String, untyped] event) -> Hash[String, event_fact_value]
424
+ def self.get_event_facts: (Event | Hash[String, untyped] event) -> Hash[String, event_fact_value]
356
425
  end
357
426
 
358
427
  module EventFacts
359
- def self.value: (WebhookEvent | Hash[String, untyped] event, String key) -> event_fact_value
360
- def self.values: (WebhookEvent | Hash[String, untyped] event) -> Hash[String, event_fact_value]
428
+ def self.value: (Event | Hash[String, untyped] event, String key) -> event_fact_value
429
+ def self.values: (Event | Hash[String, untyped] event) -> Hash[String, event_fact_value]
361
430
  end
362
431
 
363
432
  def self.create_webhook_signature_header: (payload: String, timestamp: String | Integer, secret: String) -> String
364
433
  def self.create_webhook_headers: (payload: String, delivery_id: String, secret: String, ?timestamp: Integer) -> Hash[String, String]
365
- def self.to_webhook_event_payload: (event event) -> event
434
+ def self.to_webhook_event_payload: (Event | Hash[String, untyped] event) -> Hash[String, json_value]
366
435
  def self.verify_webhook_signature: (payload: String, secret: String, ?signature: String?, ?timestamp: String?,
367
436
  ?headers: webhook_headers?, ?tolerance_seconds: Integer, ?now: number) -> bool
368
437
  def self.verify_webhook_request: (payload: String, headers: webhook_headers, secret: String, ?tolerance_seconds: Integer,
369
438
  ?now: number) -> bool
370
439
  def self.parse_webhook_event: (payload: String, secret: String, ?signature: String?, ?timestamp: String?,
371
- ?headers: webhook_headers?, ?tolerance_seconds: Integer, ?now: number) -> WebhookEvent
372
- def self.test_webhook_event?: (WebhookEvent | Hash[String, untyped] event) -> bool
373
- def self.newer_asset_event?: (WebhookEvent | Hash[String, untyped] event, Integer? last_sequence) -> bool
440
+ ?headers: webhook_headers?, ?tolerance_seconds: Integer, ?now: number) -> Event
441
+ def self.test_webhook_event?: (Event | Hash[String, untyped] event) -> bool
442
+ def self.newer_asset_event?: (Event | Hash[String, untyped] event, Integer? last_sequence) -> bool
374
443
  # The value of an event's fact by key (the first, when the event repeats it), or nil without one.
375
- def self.get_event_fact: (WebhookEvent | Hash[String, untyped] event, String key) -> event_fact_value
444
+ def self.get_event_fact: (Event | Hash[String, untyped] event, String key) -> event_fact_value
376
445
  # An event's facts as values by key; a repeated key keeps its first value.
377
- def self.get_event_facts: (WebhookEvent | Hash[String, untyped] event) -> Hash[String, event_fact_value]
446
+ def self.get_event_facts: (Event | Hash[String, untyped] event) -> Hash[String, event_fact_value]
378
447
 
379
448
  # require 'calmlens/testing'
380
449
  module Testing
381
- # The mock's in-memory records. Change them to arrange a test, such as setting an asset's `classification.moderation.status`.
450
+ # The mock's in-memory records. Change them to arrange a test, such as setting an asset's `classification.moderation.decision`.
382
451
  class State < Struct[untyped]
383
- attr_accessor assets: Hash[String, asset]
384
- attr_accessor folders: Hash[String, folder]
452
+ # The records as the API sends them, with camelCase String keys.
453
+ attr_accessor assets: Hash[String, Hash[String, untyped]]
454
+ attr_accessor folders: Hash[String, Hash[String, untyped]]
385
455
  # Stored bytes by asset ID, with each part's bytes by part number.
386
456
  attr_accessor content: Hash[String, { "type" => String, "parts" => Hash[Integer, String] }]
387
- attr_accessor events: Array[event]
388
- attr_accessor lenses: Hash[String, lens]
389
- attr_accessor hash_lists: Hash[String, hash_list]
390
- attr_accessor hash_list_entries: Hash[String, hash_list_entry]
457
+ attr_accessor events: Array[Hash[String, untyped]]
458
+ attr_accessor lenses: Hash[String, Hash[String, untyped]]
459
+ attr_accessor hash_lists: Hash[String, Hash[String, untyped]]
460
+ attr_accessor hash_list_entries: Hash[String, Hash[String, untyped]]
391
461
  end
392
462
  end
393
463
 
@@ -425,14 +495,15 @@ module CalmLens
425
495
  # A mock API key carrying permission grants, such as `assets:download` for CDN reads.
426
496
  def self.create_api_key: (?Array[Hash[Symbol | String, untyped]] grants) -> String
427
497
  # Signs an upload token like UploadTokens#sign at `now` (epoch milliseconds) with `nonce`.
428
- def self.sign_upload_token: (String api_key, sign_upload_token_options options, now: Integer, nonce: String) -> signed_upload_token
498
+ def self.sign_upload_token: (String api_key, sign_upload_token_options options, now: Integer, nonce: String) -> SignedUploadToken
429
499
 
430
500
  REQUEST_FAILURES: Array[String]
431
501
 
432
502
  def initialize: (?project_id: String, ?api_key: String, ?base_url: String, ?cdn_base_url: String, ?now: _Clock, ?create_id: _IdFactory,
433
503
  ?moderate: _Moderate?, ?timeout: number,
434
- ?open_timeout: number, ?upload_timeout: number?, ?max_retries: Integer, ?retry_base_delay: number,
435
- ?max_response_bytes: Integer, ?part_size_bytes: Integer) -> void
504
+ ?open_timeout: number, ?upload_timeout: number?, ?max_retries: Integer, ?retry_base_delay: number, ?max_retry_delay: number,
505
+ ?max_response_bytes: Integer, ?part_size_bytes: Integer, ?app_info: app_info?, ?logger: _Logger?,
506
+ ?log_level: ("info" | "debug")?, ?on_request: (^(request_event event) -> void)?) -> void
436
507
  # Replaces the mock API key's grants for later requests; the key stays the same.
437
508
  def api_key_grants=: (Array[Hash[Symbol | String, untyped]] grants) -> Array[Hash[Symbol | String, untyped]]
438
509
  # Fails the next request (or the next one `operation` sends) with `transport-error`, `timeout`, an
@@ -447,11 +518,11 @@ module CalmLens
447
518
  def enqueue_error: (Exception error) -> self
448
519
  # Fetches a mock CDN URL with a GET and without the API key, as a browser would.
449
520
  def fetch_cdn: (String url) -> Response
450
- def enqueue_event: (mock_event_input event) -> event
521
+ def enqueue_event: (mock_event_input event) -> Event
451
522
  # Applies a reviewer's decision and adds the matching `asset.<decision>` event.
452
- def decide: (String asset_id, asset_moderation_decision decision) -> asset
523
+ def decide: (String asset_id, asset_moderation_decision decision) -> Asset
453
524
  # Finishes processing an asset as the moderation pipeline would, with `decision` or else `moderate`'s answer.
454
- def complete_processing: (String asset_id, ?(MockDecision::status | MockDecision)? decision) -> asset
525
+ def complete_processing: (String asset_id, ?(MockDecision::status | MockDecision)? decision) -> Asset
455
526
  def requests: () -> Array[Request]
456
527
  def clear_requests: () -> self
457
528
  def remaining_responses: () -> Integer
@@ -487,9 +558,10 @@ module CalmLens
487
558
  end
488
559
 
489
560
  # The stored asset, still processing.
490
- attr_accessor asset: asset
561
+ # The stored asset as the API sends it, still processing.
562
+ attr_accessor asset: Hash[String, untyped]
491
563
  attr_accessor content: Content
492
- attr_accessor trigger: "upload" | "retry" | "rerun" | "complete"
564
+ attr_accessor trigger: "upload" | "retry" | "complete"
493
565
  attr_accessor queued: bool
494
566
  def queued?: () -> bool
495
567
  end
@@ -512,7 +584,7 @@ module CalmLens
512
584
  # test input key from the portal.
513
585
  module TestInputs
514
586
  type action = "allow" | "limit" | "age-restrict" | "block"
515
- type region = "DE" | "AT" | "FR" | "GB" | "EU" | "AU" | "BR"
587
+ type region = moderation_region
516
588
  type regional_action = { "region" => region, "action" => "limit" | "age-restrict" | "block" }
517
589
  # One qualifying instance; set an action on every instance or on none.
518
590
  type test_instance = { "category" => classification_category, ?"score" => number, ?"action" => action, "qualifiers" => Array[String] }
data/sig/error_codes.rbs CHANGED
@@ -67,9 +67,6 @@ module CalmLens
67
67
  ASSET_NOT_RETRYABLE: String
68
68
  ASSET_CONTENT_UNAVAILABLE: String
69
69
  ASSET_CONTENT_PURGED: String
70
- ASSET_NOT_DECIDED: String
71
- ASSET_POLICY_CHANGED: String
72
- ASSET_REVIEWED: String
73
70
  SUPPORT_TICKET_NOT_FOUND: String
74
71
  DUPLICATE_EXTERNAL_ID: String
75
72
  FOLDER_NOT_FOUND: String