riveter-sdk 1.0.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/riveter/errors.rb +1 -1
- data/lib/riveter/models.rb +41 -17
- data/lib/riveter/page.rb +6 -4
- data/lib/riveter/resources.rb +22 -6
- data/lib/riveter/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5287a59260bd3fbf2f4069af7bcc49ec2c8cb9015d55e36db170c50c62ca5fa9
|
|
4
|
+
data.tar.gz: 50ecfae1ff05b163f8479d9c63aabad0a18e31f001fd2a7fb4656901dc471f00
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2bd4722b2d5c49a06390a520ca1b7f0319923390debe5a3301496cd58f6257de10aff9e28254175a52c9745b9a9038915a27bc6acaa354137641fc3b61b3c414
|
|
7
|
+
data.tar.gz: ad7644661ae6d842485962aa4db8006936f26db528243ebebcdc721440f2cf879c4a05734a78924b3cf4b75d335e70ab2a36409f32a65c4d64b5af73426c81f3
|
data/lib/riveter/errors.rb
CHANGED
|
@@ -43,7 +43,7 @@ module Riveter
|
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
# Builds an APIError from either the clean { "error" => {...} } envelope
|
|
46
|
-
# or the
|
|
46
|
+
# or the { "request_status" => "error" } shape (401s).
|
|
47
47
|
def self.from_response(status, body)
|
|
48
48
|
if body.is_a?(Hash)
|
|
49
49
|
error = body["error"]
|
data/lib/riveter/models.rb
CHANGED
|
@@ -57,14 +57,13 @@ module Riveter
|
|
|
57
57
|
# Endpoint-specific kickoff extras (dataset_id, credits_charged, ...) are
|
|
58
58
|
# plain fields; #output is nil until the run finishes. An `estimate_cost: true`
|
|
59
59
|
# kickoff returns this shape with #estimate_cost set, no #id, and the priced
|
|
60
|
-
# #credit_detail.
|
|
61
|
-
# kickoff took a legacy mode.
|
|
60
|
+
# #credit_detail.
|
|
62
61
|
class Run < Model
|
|
63
62
|
field :id, :type, :status, :credits_used, :estimate_cost, :app_url, :result_url,
|
|
64
63
|
:started_at, :finished_at, :error, :stopped_reason, :enrichment_id, :enrichment_name,
|
|
65
64
|
:dataset_id, :extraction_id, :monitor_id, :webhook_url, :output,
|
|
66
65
|
:max_items, :configured_dataset_id, :credits_charged, :variables,
|
|
67
|
-
:validation_warning, :tier
|
|
66
|
+
:validation_warning, :tier
|
|
68
67
|
model_field :progress, RunProgress
|
|
69
68
|
model_field :credit_detail, CreditDetail
|
|
70
69
|
|
|
@@ -87,21 +86,18 @@ module Riveter
|
|
|
87
86
|
field :counts
|
|
88
87
|
end
|
|
89
88
|
|
|
90
|
-
# Compact list-endpoint shape. Column configuration is on Enrichments#get.
|
|
91
|
-
# #app_url, and #dataset_id (the dataset copy to fill instead) are set on legacy
|
|
92
|
-
# enrichments only.
|
|
89
|
+
# Compact list-endpoint shape. Column configuration is on Enrichments#get.
|
|
93
90
|
class EnrichmentSummary < Model
|
|
94
|
-
field :id, :name, :
|
|
91
|
+
field :id, :name, :column_count, :input_columns,
|
|
95
92
|
:output_columns, :column_names_truncated, :created_at, :updated_at
|
|
96
93
|
end
|
|
97
94
|
|
|
98
95
|
# An enrichment: #prompt, #input_columns, #output as an array of column hashes ("name" /
|
|
99
96
|
# "prompt" / "output_schema" / "tool"), #tools, the budget fields, and #version.
|
|
100
|
-
# #dataset_id / #app_url are set on Enrichments#create.
|
|
101
|
-
# its older shape (the legacy API docs, kept in #raw) with #legacy set.
|
|
97
|
+
# #dataset_id / #app_url are set on Enrichments#create.
|
|
102
98
|
class Enrichment < Model
|
|
103
99
|
field :id, :name, :prompt, :input_columns, :output, :tools, :budget_credits_per_row,
|
|
104
|
-
:budget_locked, :version, :created_at, :updated_at, :app_url, :dataset_id
|
|
100
|
+
:budget_locked, :version, :created_at, :updated_at, :app_url, :dataset_id
|
|
105
101
|
end
|
|
106
102
|
|
|
107
103
|
# One cell. #state is pending / running / ok / not_found / failed / manual / stale;
|
|
@@ -120,6 +116,36 @@ module Riveter
|
|
|
120
116
|
end
|
|
121
117
|
end
|
|
122
118
|
|
|
119
|
+
# A row as compact: true answers it: the values alone. #cells is each output column's value
|
|
120
|
+
# (nil when the cell has none). Address the row by #position elsewhere.
|
|
121
|
+
class CompactDatasetRow < Model
|
|
122
|
+
field :position, :input, :cells
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
# One of a column's most common values (a string is cut at 200 characters) and its row count.
|
|
126
|
+
class DatasetColumnValueCount < Model
|
|
127
|
+
field :value, :count
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
# One column's counts over every row: #states (output columns only: cells by state, pending /
|
|
131
|
+
# stale / failed / not_found / ok / manual), #filled, #distinct_values, the most common #values.
|
|
132
|
+
class DatasetColumnSummary < Model
|
|
133
|
+
field :name, :kind, :states, :filled, :distinct_values
|
|
134
|
+
|
|
135
|
+
def values
|
|
136
|
+
(@raw["values"] || []).map { |item| DatasetColumnValueCount.new(item) }
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
# Per-column counts over every row of a dataset (Datasets#summary).
|
|
141
|
+
class DatasetSummary < Model
|
|
142
|
+
field :row_count
|
|
143
|
+
|
|
144
|
+
def columns
|
|
145
|
+
(@raw["columns"] || []).map { |item| DatasetColumnSummary.new(item) }
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
|
|
123
149
|
# A run on a dataset as the dataset lists it; #type is dataset_build or enrichment.
|
|
124
150
|
class DatasetRunSummary < Model
|
|
125
151
|
field :id, :type, :status, :created_at, :finished_at
|
|
@@ -207,19 +233,17 @@ module Riveter
|
|
|
207
233
|
end
|
|
208
234
|
|
|
209
235
|
# A monitor fills #dataset_id's #columns (every output column when nil) again on a
|
|
210
|
-
# schedule.
|
|
211
|
-
# #
|
|
212
|
-
# `estimate_cost: true` create returns this shape with #estimate_cost set, no #id, and
|
|
213
|
-
# the priced #credit_detail for one tick.
|
|
236
|
+
# schedule. An `estimate_cost: true` create returns this shape with #estimate_cost set,
|
|
237
|
+
# no #id, and the priced #credit_detail for one tick.
|
|
214
238
|
class Monitor < Model
|
|
215
239
|
field :id, :name, :enabled, :cadence, :minute, :hour, :day_of_week,
|
|
216
240
|
:day_of_month, :timezone, :webhook_url, :alert_rule, :output_format,
|
|
217
241
|
:next_run_at, :schedule_summary, :dataset_id, :dataset_name, :columns,
|
|
218
|
-
:enrichment_id, :
|
|
242
|
+
:enrichment_id, :created_at, :estimate_cost
|
|
219
243
|
model_field :credit_detail, CreditDetail
|
|
220
244
|
end
|
|
221
245
|
|
|
222
|
-
# Synchronous scrape result (
|
|
246
|
+
# Synchronous scrape result (request_status format, per the spec).
|
|
223
247
|
class ScrapeResult < Model
|
|
224
248
|
field :request_status, :text, :url, :base_url_for_links, :status_code,
|
|
225
249
|
:possibly_blocked, :credit_used, :riveter_app_link, :estimate_cost
|
|
@@ -239,7 +263,7 @@ module Riveter
|
|
|
239
263
|
field :name, :last_used_at, :created_by
|
|
240
264
|
end
|
|
241
265
|
|
|
242
|
-
# Account info (
|
|
266
|
+
# Account info (request_status format, per the spec).
|
|
243
267
|
class AccountInfo < Model
|
|
244
268
|
field :request_status, :message
|
|
245
269
|
model_field :account, Account
|
data/lib/riveter/page.rb
CHANGED
|
@@ -41,18 +41,20 @@ module Riveter
|
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
# One page of dataset rows (cursor-paginated). #each iterates the page;
|
|
44
|
-
# #auto_paging_each walks every following page too.
|
|
44
|
+
# #auto_paging_each walks every following page too. Rows are DatasetRow, or
|
|
45
|
+
# CompactDatasetRow for a compact: true read (row_class).
|
|
45
46
|
class DatasetRowsPage
|
|
46
47
|
include Enumerable
|
|
47
48
|
|
|
48
49
|
attr_reader :rows, :next_cursor, :row_count
|
|
49
50
|
|
|
50
|
-
def initialize(data, fetch_page)
|
|
51
|
+
def initialize(data, fetch_page, row_class: DatasetRow)
|
|
51
52
|
data = data.is_a?(Hash) ? data : {}
|
|
52
|
-
@rows = (data["rows"] || []).map { |item|
|
|
53
|
+
@rows = (data["rows"] || []).map { |item| row_class.new(item) }
|
|
53
54
|
@next_cursor = data["next_cursor"]
|
|
54
55
|
@row_count = data["row_count"]
|
|
55
56
|
@fetch_page = fetch_page
|
|
57
|
+
@row_class = row_class
|
|
56
58
|
end
|
|
57
59
|
|
|
58
60
|
def each(&block)
|
|
@@ -66,7 +68,7 @@ module Riveter
|
|
|
66
68
|
def next_page
|
|
67
69
|
raise Error, "No next page" unless next_page?
|
|
68
70
|
|
|
69
|
-
DatasetRowsPage.new(@fetch_page.call(next_cursor), @fetch_page)
|
|
71
|
+
DatasetRowsPage.new(@fetch_page.call(next_cursor), @fetch_page, row_class: @row_class)
|
|
70
72
|
end
|
|
71
73
|
|
|
72
74
|
def auto_paging_each(&block)
|
data/lib/riveter/resources.rb
CHANGED
|
@@ -58,8 +58,8 @@ module Riveter
|
|
|
58
58
|
@client = client
|
|
59
59
|
end
|
|
60
60
|
|
|
61
|
-
# Paginated compact list of enrichments: names,
|
|
62
|
-
#
|
|
61
|
+
# Paginated compact list of enrichments: names, column names and counts.
|
|
62
|
+
# Params: name:, page:, per_page:. (operationId: listEnrichments)
|
|
63
63
|
def list(**params)
|
|
64
64
|
fetch_page = ->(page) { @client.request(:get, "/enrichments", query: params.merge(page: page)) }
|
|
65
65
|
EnrichmentsPage.new(fetch_page.call(params[:page] || 1), fetch_page)
|
|
@@ -135,12 +135,28 @@ module Riveter
|
|
|
135
135
|
end
|
|
136
136
|
|
|
137
137
|
# A page of rows in position order (`limit:`, `cursor:`, `updated_since:`);
|
|
138
|
-
# #auto_paging_each walks every following page. (
|
|
139
|
-
|
|
138
|
+
# #auto_paging_each walks every following page. `columns:` (an Array of names) keeps only
|
|
139
|
+
# those columns; `compact: true` answers CompactDatasetRow (the values alone), so a
|
|
140
|
+
# 1,000-row page of one column is one small call. (operationId: listDatasetRows)
|
|
141
|
+
def list_rows(dataset_id, columns: nil, compact: false, **params)
|
|
142
|
+
query = params.merge(columns: columns && Array(columns).join(","), compact: compact ? "true" : nil)
|
|
140
143
|
fetch_page = lambda do |cursor|
|
|
141
|
-
@client.request(:get, "/datasets/#{dataset_id}/rows", query:
|
|
144
|
+
@client.request(:get, "/datasets/#{dataset_id}/rows", query: query.merge(cursor: cursor))
|
|
142
145
|
end
|
|
143
|
-
|
|
146
|
+
row_class = compact ? CompactDatasetRow : DatasetRow
|
|
147
|
+
DatasetRowsPage.new(fetch_page.call(params[:cursor]), fetch_page, row_class: row_class)
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
# Per-column counts over every row, no rows read: an output column's cells by state and its
|
|
151
|
+
# most common values; an input column's filled rows and values. `columns:` picks the columns,
|
|
152
|
+
# `top_values:` how many values per column (1–100, default 20). (operationId: getDatasetSummary)
|
|
153
|
+
def summary(dataset_id, columns: nil, top_values: nil)
|
|
154
|
+
DatasetSummary.new(
|
|
155
|
+
@client.request(
|
|
156
|
+
:get, "/datasets/#{dataset_id}/summary",
|
|
157
|
+
query: { columns: columns && Array(columns).join(","), top_values: top_values }
|
|
158
|
+
)
|
|
159
|
+
)
|
|
144
160
|
end
|
|
145
161
|
|
|
146
162
|
# Append rows (≤ 100 per call) keyed by input column name; duplicates on the index
|
data/lib/riveter/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: riveter-sdk
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0
|
|
4
|
+
version: 1.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Riveter
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-11-12 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Client for the Riveter API — enrich data, build datasets, scrape pages,
|
|
14
14
|
and run web searches. https://docs.riveterhq.com
|