retab 0.1.5 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (170) hide show
  1. checksums.yaml +4 -4
  2. data/lib/retab/base_client.rb +9 -2
  3. data/lib/retab/client.rb +8 -0
  4. data/lib/retab/experiment_runs/experiment_run.rb +9 -0
  5. data/lib/retab/files/create_file_blueprint_request.rb +31 -0
  6. data/lib/retab/files/file_blueprint.rb +52 -0
  7. data/lib/retab/files.rb +88 -0
  8. data/lib/retab/multipart.rb +73 -0
  9. data/lib/retab/schemas/generate_schema_request.rb +3 -3
  10. data/lib/retab/schemas/{partial_schema.rb → schema_generation.rb} +12 -3
  11. data/lib/retab/schemas.rb +5 -5
  12. data/lib/retab/secrets/create_secret_request.rb +25 -0
  13. data/lib/retab/secrets/secret.rb +34 -0
  14. data/lib/retab/secrets/secret_list_response.rb +20 -0
  15. data/lib/retab/secrets/secret_response.rb +20 -0
  16. data/lib/retab/secrets/secret_value.rb +28 -0
  17. data/lib/retab/secrets/secret_value_response.rb +20 -0
  18. data/lib/retab/secrets/set_secret_request.rb +20 -0
  19. data/lib/retab/secrets.rb +154 -0
  20. data/lib/retab/tables/create_workflow_table_upload_request.rb +31 -0
  21. data/lib/retab/tables/query_workflow_table_request.rb +72 -0
  22. data/lib/retab/tables/replace_workflow_table_upload_request.rb +25 -0
  23. data/lib/retab/tables/update_workflow_table_request.rb +25 -0
  24. data/lib/retab/tables/workflow_table.rb +58 -0
  25. data/lib/retab/tables/workflow_table_aggregation_request.rb +28 -0
  26. data/lib/retab/tables/workflow_table_column.rb +34 -0
  27. data/lib/retab/tables/workflow_table_distinct_request.rb +20 -0
  28. data/lib/retab/tables/workflow_table_explain.rb +54 -0
  29. data/lib/retab/tables/workflow_table_filter_rule.rb +28 -0
  30. data/lib/retab/tables/workflow_table_list_response.rb +20 -0
  31. data/lib/retab/tables/workflow_table_profile_column.rb +49 -0
  32. data/lib/retab/tables/workflow_table_profile_response.rb +28 -0
  33. data/lib/retab/tables/workflow_table_response.rb +20 -0
  34. data/lib/retab/tables/workflow_table_row.rb +28 -0
  35. data/lib/retab/tables/workflow_table_rows_response.rb +52 -0
  36. data/lib/retab/tables/workflow_table_sample_request.rb +20 -0
  37. data/lib/retab/tables/workflow_table_schema_response.rb +25 -0
  38. data/lib/retab/tables/workflow_table_search_request.rb +25 -0
  39. data/lib/retab/tables/workflow_table_sort_rule.rb +25 -0
  40. data/lib/retab/tables/workflow_table_tail_request.rb +7 -0
  41. data/lib/retab/tables/workflow_table_validation_column_rule.rb +28 -0
  42. data/lib/retab/tables/workflow_table_validation_diagnostic.rb +31 -0
  43. data/lib/retab/tables/workflow_table_validation_request.rb +28 -0
  44. data/lib/retab/tables/workflow_table_validation_response.rb +30 -0
  45. data/lib/retab/tables.rb +361 -0
  46. data/lib/retab/types/artifact_drift_status.rb +15 -0
  47. data/lib/retab/types/artifact_freshness_reasons.rb +16 -0
  48. data/lib/retab/types/artifact_freshness_status.rb +14 -0
  49. data/lib/retab/types/create_file_blueprint_request_mode.rb +13 -0
  50. data/lib/retab/types/declarative_plan_resource_change_type.rb +0 -2
  51. data/lib/retab/types/file_blueprint_mode.rb +9 -0
  52. data/lib/retab/types/file_blueprint_status.rb +9 -0
  53. data/lib/retab/types/schema_generation_status.rb +9 -0
  54. data/lib/retab/types/validate_workflow_block_config_request_config_mode.rb +9 -0
  55. data/lib/retab/types/workflow_authz_status.rb +16 -0
  56. data/lib/retab/types/workflow_block_type.rb +0 -2
  57. data/lib/retab/types/workflow_block_version_type.rb +9 -0
  58. data/lib/retab/types/workflow_capabilities.rb +26 -0
  59. data/lib/retab/types/workflow_config_block_type.rb +9 -0
  60. data/lib/retab/types/workflow_table_aggregation_function.rb +17 -0
  61. data/lib/retab/types/workflow_table_filter_operator.rb +46 -0
  62. data/lib/retab/types/workflow_table_sort_direction.rb +9 -0
  63. data/lib/retab/types/workflow_table_validation_column_rule_type.rb +18 -0
  64. data/lib/retab/types/workflow_table_validation_severity.rb +13 -0
  65. data/lib/retab/workflow_blocks/validate_workflow_block_config_request.rb +25 -0
  66. data/lib/retab/workflow_blocks/validate_workflow_block_config_response.rb +34 -0
  67. data/lib/retab/workflow_blocks/workflow_block.rb +6 -0
  68. data/lib/retab/workflow_blocks/workflow_block_version.rb +64 -0
  69. data/lib/retab/workflow_blocks/workflow_block_version_diff.rb +31 -0
  70. data/lib/retab/workflow_blocks/workflow_version_field_diff.rb +28 -0
  71. data/lib/retab/workflow_blocks.rb +172 -0
  72. data/lib/retab/workflow_edges/workflow_edge_version.rb +49 -0
  73. data/lib/retab/workflow_edges/workflow_edge_version_diff.rb +31 -0
  74. data/lib/retab/workflow_edges.rb +134 -0
  75. data/lib/retab/workflow_experiments/artifact_drift.rb +28 -0
  76. data/lib/retab/workflow_experiments/artifact_freshness.rb +34 -0
  77. data/lib/retab/workflow_experiments/workflow_experiment.rb +8 -2
  78. data/lib/retab/workflow_review_versions.rb +3 -3
  79. data/lib/retab/workflow_reviews.rb +4 -4
  80. data/lib/retab/workflow_runs.rb +1 -1
  81. data/lib/retab/workflow_spec.rb +6 -57
  82. data/lib/retab/workflow_test_runs/workflow_test_run.rb +5 -2
  83. data/lib/retab/workflow_tests/latest_block_test_run_summary.rb +6 -0
  84. data/lib/retab/workflow_tests/workflow_test.rb +6 -0
  85. data/lib/retab/workflows/create_workflow_request.rb +5 -2
  86. data/lib/retab/{workflow_spec → workflows}/declarative_workflow_request.rb +7 -2
  87. data/lib/retab/workflows/workflow.rb +11 -2
  88. data/lib/retab/workflows/workflow_block_position.rb +25 -0
  89. data/lib/retab/workflows/workflow_config_block.rb +46 -0
  90. data/lib/retab/workflows/workflow_config_edge.rb +37 -0
  91. data/lib/retab/workflows/workflow_graph_version.rb +40 -0
  92. data/lib/retab/workflows/workflow_graph_version_diff.rb +43 -0
  93. data/lib/retab/workflows.rb +209 -3
  94. data/lib/retab.rb +2 -0
  95. data/rbi/retab/artifact_drift.rbi +36 -0
  96. data/rbi/retab/artifact_freshness.rbi +48 -0
  97. data/rbi/retab/client.rbi +6 -0
  98. data/rbi/retab/create_file_blueprint_request.rbi +42 -0
  99. data/rbi/retab/create_secret_request.rbi +30 -0
  100. data/rbi/retab/create_upload_response.rbi +2 -2
  101. data/rbi/retab/create_workflow_request.rbi +6 -0
  102. data/rbi/retab/create_workflow_table_upload_request.rbi +42 -0
  103. data/rbi/retab/declarative_workflow_request.rbi +6 -0
  104. data/rbi/retab/experiment_run.rbi +18 -0
  105. data/rbi/retab/file_blueprint.rbi +84 -0
  106. data/rbi/retab/files.rbi +28 -0
  107. data/rbi/retab/generate_schema_request.rbi +2 -2
  108. data/rbi/retab/latest_block_test_run_summary.rbi +12 -0
  109. data/rbi/retab/query_workflow_table_request.rbi +120 -0
  110. data/rbi/retab/replace_workflow_table_upload_request.rbi +30 -0
  111. data/rbi/retab/{partial_schema.rbi → schema_generation.rbi} +19 -1
  112. data/rbi/retab/schemas.rbi +3 -3
  113. data/rbi/retab/secret.rbi +48 -0
  114. data/rbi/retab/secret_list_response.rbi +24 -0
  115. data/rbi/retab/secret_response.rbi +24 -0
  116. data/rbi/retab/secret_value.rbi +36 -0
  117. data/rbi/retab/secret_value_response.rbi +24 -0
  118. data/rbi/retab/secrets.rbi +62 -0
  119. data/rbi/retab/set_secret_request.rbi +24 -0
  120. data/rbi/retab/tables.rbi +129 -0
  121. data/rbi/retab/update_workflow_table_request.rbi +30 -0
  122. data/rbi/retab/validate_workflow_block_config_request.rbi +30 -0
  123. data/rbi/retab/validate_workflow_block_config_response.rbi +48 -0
  124. data/rbi/retab/workflow.rbi +18 -0
  125. data/rbi/retab/workflow_block.rbi +12 -0
  126. data/rbi/retab/workflow_block_position.rbi +30 -0
  127. data/rbi/retab/workflow_block_version.rbi +108 -0
  128. data/rbi/retab/workflow_block_version_diff.rbi +42 -0
  129. data/rbi/retab/workflow_blocks.rbi +49 -0
  130. data/rbi/retab/workflow_config_block.rbi +72 -0
  131. data/rbi/retab/workflow_config_edge.rbi +54 -0
  132. data/rbi/retab/workflow_edge_version.rbi +78 -0
  133. data/rbi/retab/workflow_edge_version_diff.rbi +42 -0
  134. data/rbi/retab/workflow_edges.rbi +38 -0
  135. data/rbi/retab/workflow_experiment.rbi +12 -0
  136. data/rbi/retab/workflow_graph_version.rbi +60 -0
  137. data/rbi/retab/workflow_graph_version_diff.rbi +66 -0
  138. data/rbi/retab/workflow_spec.rbi +2 -17
  139. data/rbi/retab/workflow_table.rbi +96 -0
  140. data/rbi/retab/workflow_table_aggregation_request.rbi +36 -0
  141. data/rbi/retab/workflow_table_column.rbi +48 -0
  142. data/rbi/retab/workflow_table_distinct_request.rbi +24 -0
  143. data/rbi/retab/workflow_table_explain.rbi +84 -0
  144. data/rbi/retab/workflow_table_filter_rule.rbi +36 -0
  145. data/rbi/retab/workflow_table_list_response.rbi +24 -0
  146. data/rbi/retab/workflow_table_profile_column.rbi +78 -0
  147. data/rbi/retab/workflow_table_profile_response.rbi +36 -0
  148. data/rbi/retab/workflow_table_response.rbi +24 -0
  149. data/rbi/retab/workflow_table_row.rbi +36 -0
  150. data/rbi/retab/workflow_table_rows_response.rbi +84 -0
  151. data/rbi/retab/workflow_table_sample_request.rbi +24 -0
  152. data/rbi/retab/workflow_table_schema_response.rbi +30 -0
  153. data/rbi/retab/workflow_table_search_request.rbi +30 -0
  154. data/rbi/retab/workflow_table_sort_rule.rbi +30 -0
  155. data/rbi/retab/workflow_table_tail_request.rbi +24 -0
  156. data/rbi/retab/workflow_table_validation_column_rule.rbi +36 -0
  157. data/rbi/retab/workflow_table_validation_diagnostic.rbi +42 -0
  158. data/rbi/retab/workflow_table_validation_request.rbi +36 -0
  159. data/rbi/retab/workflow_table_validation_response.rbi +36 -0
  160. data/rbi/retab/workflow_test.rbi +12 -0
  161. data/rbi/retab/workflow_test_run.rbi +6 -0
  162. data/rbi/retab/workflow_version_field_diff.rbi +36 -0
  163. data/rbi/retab/workflows.rbi +61 -2
  164. metadata +128 -10
  165. /data/lib/retab/{workflow_spec → workflows}/declarative_apply_response.rb +0 -0
  166. /data/lib/retab/{workflow_spec → workflows}/declarative_plan_change.rb +0 -0
  167. /data/lib/retab/{workflow_spec → workflows}/declarative_plan_field_change.rb +0 -0
  168. /data/lib/retab/{workflow_spec → workflows}/declarative_plan_resource_change.rb +0 -0
  169. /data/lib/retab/{workflow_spec → workflows}/declarative_plan_response.rb +0 -0
  170. /data/lib/retab/{workflow_spec → workflows}/declarative_plan_summary.rb +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 892cc7d33cd77ee2992206da231970259f4f0cf3668c762671b114b78116d1ee
4
- data.tar.gz: 17e6a78b1858ab551518b0b379b92b4d54980e25565ce0d567504b17c2f0294c
3
+ metadata.gz: 67452b4ad04cd58f0437012ee63e052194150a619474218838fe392949156eba
4
+ data.tar.gz: 51cca52e0f5df37488678232d8a41de500613b1ce709b54c98bf1dc4725a72af
5
5
  SHA512:
6
- metadata.gz: 653dc2782eee8ec927931b08da074dff4bceb322e7605a74ba14f2629cc6c9a8dca82c66de8748bc13e72a5cfc38c256b2b147844298b0c82000ccfa84c8d33e
7
- data.tar.gz: 04d599b812516886ac4b0a2f3336af22d96418a40340da1412b45ed43e2b98733d2cbdbee41e35d70af30b7b4ea38df5c7651ef40ece0fba3a1a065b12d74237
6
+ metadata.gz: 329580bdb99646157f8da23afc794d5252fcf925fd21eb988815ef30e61150b900f3a2f63e73eabbc96e5dda2471bd6a2561ed30345bb79ca2d4d7f91ea7580b
7
+ data.tar.gz: 9b8a20793769cf85431a7172bb8be1629f72e39c80f8fdaa6fafcccd32666b1bb6ecf159adec60dbcc88b89ffb869b905fe9d972260b21a30c8b5bc976a52bd2
@@ -86,8 +86,15 @@ module Retab
86
86
  extra_headers = request_options[:headers] || request_options["headers"] || {}
87
87
  extra_headers.each { |k, v| req[k.to_s] = v.to_s }
88
88
  if body && %i[post put patch].include?(method.to_sym)
89
- req["Content-Type"] = "application/json"
90
- req.body = body.is_a?(String) ? body : JSON.generate(body)
89
+ if body.is_a?(Retab::Multipart)
90
+ # multipart/form-data (e.g. table create/replace). Let net/http build
91
+ # the multipart body and set the `Content-Type:
92
+ # multipart/form-data; boundary=...` header itself — never JSON.
93
+ req.set_form(body.to_form_parts, "multipart/form-data")
94
+ else
95
+ req["Content-Type"] = "application/json"
96
+ req.body = body.is_a?(String) ? body : JSON.generate(body)
97
+ end
91
98
  end
92
99
 
93
100
  req
data/lib/retab/client.rb CHANGED
@@ -33,10 +33,18 @@ module Retab
33
33
  @schemas ||= Retab::Schemas.new(self)
34
34
  end
35
35
 
36
+ def secrets
37
+ @secrets ||= Retab::Secrets.new(self)
38
+ end
39
+
36
40
  def splits
37
41
  @splits ||= Retab::Splits.new(self)
38
42
  end
39
43
 
44
+ def tables
45
+ @tables ||= Retab::Tables.new(self)
46
+ end
47
+
40
48
  def workflows
41
49
  @workflows ||= Retab::Workflows.new(self)
42
50
  end
@@ -17,6 +17,9 @@ module Retab
17
17
  lifecycle: :lifecycle,
18
18
  timing: :timing,
19
19
  parent_run_id: :parent_run_id,
20
+ block_version_id: :block_version_id,
21
+ metrics_validity_fingerprint: :metrics_validity_fingerprint,
22
+ metrics_validity_fingerprint_version: :metrics_validity_fingerprint_version,
20
23
  definition_fingerprint: :definition_fingerprint,
21
24
  documents_fingerprint: :documents_fingerprint,
22
25
  score: :score,
@@ -38,6 +41,9 @@ module Retab
38
41
  :lifecycle,
39
42
  :timing,
40
43
  :parent_run_id,
44
+ :block_version_id,
45
+ :metrics_validity_fingerprint,
46
+ :metrics_validity_fingerprint_version,
41
47
  :definition_fingerprint,
42
48
  :documents_fingerprint,
43
49
  :score,
@@ -78,6 +84,9 @@ module Retab
78
84
  ) : nil
79
85
  @timing = hash[:timing] ? Retab::ExperimentRunTiming.new(hash[:timing]) : nil
80
86
  @parent_run_id = hash[:parent_run_id]
87
+ @block_version_id = hash[:block_version_id]
88
+ @metrics_validity_fingerprint = hash[:metrics_validity_fingerprint]
89
+ @metrics_validity_fingerprint_version = hash[:metrics_validity_fingerprint_version]
81
90
  @definition_fingerprint = hash[:definition_fingerprint]
82
91
  @documents_fingerprint = hash[:documents_fingerprint]
83
92
  @score = hash[:score]
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file is auto-generated by oagen. Do not edit.
4
+
5
+ module Retab
6
+ class CreateFileBlueprintRequest < Retab::Types::BaseModel
7
+
8
+ HASH_ATTRS = {
9
+ file_id: :file_id,
10
+ mode: :mode,
11
+ intent: :intent,
12
+ background: :background
13
+ }.freeze
14
+
15
+ attr_accessor(
16
+ :file_id,
17
+ :mode,
18
+ :intent,
19
+ :background
20
+ )
21
+
22
+ def initialize(json)
23
+ super()
24
+ hash = self.class.normalize(json)
25
+ @file_id = hash[:file_id]
26
+ @mode = hash[:mode]
27
+ @intent = hash[:intent]
28
+ @background = hash[:background].nil? ? false : hash[:background]
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file is auto-generated by oagen. Do not edit.
4
+
5
+ module Retab
6
+ class FileBlueprint < Retab::Types::BaseModel
7
+
8
+ HASH_ATTRS = {
9
+ object: :object,
10
+ id: :id,
11
+ file: :file,
12
+ mode: :mode,
13
+ intent: :intent,
14
+ output: :output,
15
+ status: :status,
16
+ error: :error,
17
+ created_at: :created_at,
18
+ started_at: :started_at,
19
+ completed_at: :completed_at
20
+ }.freeze
21
+
22
+ attr_accessor(
23
+ :object,
24
+ :id,
25
+ :file,
26
+ :mode,
27
+ :intent,
28
+ :output,
29
+ :status,
30
+ :error,
31
+ :created_at,
32
+ :started_at,
33
+ :completed_at
34
+ )
35
+
36
+ def initialize(json)
37
+ super()
38
+ hash = self.class.normalize(json)
39
+ @object = hash[:object].nil? ? "file.blueprint" : hash[:object]
40
+ @id = hash[:id]
41
+ @file = hash[:file] ? Retab::FileRef.new(hash[:file]) : nil
42
+ @mode = hash[:mode]
43
+ @intent = hash[:intent]
44
+ @output = hash[:output] || {}
45
+ @status = hash[:status].nil? ? "pending" : hash[:status]
46
+ @error = hash[:error] ? Retab::PrimitiveError.new(hash[:error]) : nil
47
+ @created_at = hash[:created_at]
48
+ @started_at = hash[:started_at]
49
+ @completed_at = hash[:completed_at]
50
+ end
51
+ end
52
+ end
data/lib/retab/files.rb CHANGED
@@ -88,6 +88,94 @@ module Retab
88
88
  )
89
89
  end
90
90
 
91
+ # Create File Blueprint
92
+ # @param file_id [String] File id to analyze.
93
+ # @param mode [Retab::Types::CreateFileBlueprintRequestMode, nil] Optional analysis depth override. Omit to let Retab choose.
94
+ # @param intent [String, nil] Optional user intent used to guide the blueprint analysis.
95
+ # @param background [Boolean, nil] If true, run asynchronously: returns immediately with status 'queued' and an empty output. Poll GET /v1/<primitive>/{id} until status is terminal. Mutually exclusive with stream.
96
+ # @param request_options [Hash] (see Retab::Types::RequestOptions)
97
+ # @return [Retab::FileBlueprint]
98
+ def create_blueprint(
99
+ file_id:,
100
+ mode: nil,
101
+ intent: nil,
102
+ background: nil,
103
+ request_options: {}
104
+ )
105
+ body = {
106
+ "file_id" => file_id,
107
+ "mode" => mode,
108
+ "intent" => intent,
109
+ "background" => background
110
+ }.compact
111
+ response = @client.request(
112
+ method: :post,
113
+ path: "/v1/files/blueprints",
114
+ auth: true,
115
+ body: body,
116
+ request_options: request_options
117
+ )
118
+ result = Retab::FileBlueprint.new(response.body)
119
+ result.last_response = Retab::Types::ApiResponse.new(
120
+ http_status: response.code.to_i,
121
+ http_headers: response.each_header.to_h,
122
+ request_id: response["x-request-id"]
123
+ )
124
+ result
125
+ end
126
+
127
+ # Get File Blueprint
128
+ # @param blueprint_id [String]
129
+ # @param include_output [Boolean, nil] When false, returns a cheap status-only projection (no output), served from cache for in-flight background runs.
130
+ # @param request_options [Hash] (see Retab::Types::RequestOptions)
131
+ # @return [Retab::FileBlueprint]
132
+ def get_blueprint(
133
+ blueprint_id:,
134
+ include_output: true,
135
+ request_options: {}
136
+ )
137
+ params = {
138
+ "include_output" => include_output
139
+ }.compact
140
+ response = @client.request(
141
+ method: :get,
142
+ path: "/v1/files/blueprints/#{Retab::Util.encode_path(blueprint_id)}",
143
+ auth: true,
144
+ params: params,
145
+ request_options: request_options
146
+ )
147
+ result = Retab::FileBlueprint.new(response.body)
148
+ result.last_response = Retab::Types::ApiResponse.new(
149
+ http_status: response.code.to_i,
150
+ http_headers: response.each_header.to_h,
151
+ request_id: response["x-request-id"]
152
+ )
153
+ result
154
+ end
155
+
156
+ # Cancel File Blueprint
157
+ # @param blueprint_id [String]
158
+ # @param request_options [Hash] (see Retab::Types::RequestOptions)
159
+ # @return [Retab::FileBlueprint]
160
+ def create_blueprint_cancel(
161
+ blueprint_id:,
162
+ request_options: {}
163
+ )
164
+ response = @client.request(
165
+ method: :post,
166
+ path: "/v1/files/blueprints/#{Retab::Util.encode_path(blueprint_id)}/cancel",
167
+ auth: true,
168
+ request_options: request_options
169
+ )
170
+ result = Retab::FileBlueprint.new(response.body)
171
+ result.last_response = Retab::Types::ApiResponse.new(
172
+ http_status: response.code.to_i,
173
+ http_headers: response.each_header.to_h,
174
+ request_id: response["x-request-id"]
175
+ )
176
+ result
177
+ end
178
+
91
179
  # Upload File
92
180
  # @param filename [String] Filename to store
93
181
  # @param content_type [String, nil] MIME type the client will upload
@@ -0,0 +1,73 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file is auto-generated by oagen. Do not edit.
4
+
5
+ # @oagen-ignore-file
6
+ #
7
+ # Hand-maintained multipart/form-data marker. Spec-derived resource methods
8
+ # whose operation declares a `multipart/form-data` request body (e.g.
9
+ # `tables.create` / `tables.replace`) build a `Retab::Multipart`
10
+ # instead of a plain Hash. `BaseClient#build_request` detects it and calls
11
+ # `Net::HTTP::Post#set_form(..., 'multipart/form-data')` so net/http emits the
12
+ # boundary itself — never a JSON body. The gateway requires a real multipart
13
+ # file upload for the binary part and rejects JSON ("Expected a
14
+ # multipart/form-data file upload").
15
+
16
+ require "stringio"
17
+
18
+ module Retab
19
+ # A multipart/form-data request body. `fields` maps wire field name =>
20
+ # value, where each value is either a plain scalar (sent as a text part via
21
+ # `#to_s`) or a `FilePart` (sent as a binary file part).
22
+ class Multipart
23
+ attr_reader :fields
24
+
25
+ def initialize(fields = {})
26
+ @fields = fields
27
+ end
28
+
29
+ # Build the `[name, value]` pairs net/http's `#set_form` expects. Binary
30
+ # parts become `[name, io, { filename:, content_type: }]`; scalar parts
31
+ # become `[name, string]`.
32
+ def to_form_parts
33
+ @fields.map do |name, value|
34
+ if value.is_a?(FilePart)
35
+ [name.to_s, value.io, value.form_opts]
36
+ else
37
+ [name.to_s, value.to_s]
38
+ end
39
+ end
40
+ end
41
+
42
+ # A single binary file part. `content` may be a String of bytes, a
43
+ # `Pathname`, or any IO-like object (File/StringIO). Normalised to an IO
44
+ # so net/http streams it as a real file upload.
45
+ class FilePart
46
+ DEFAULT_CONTENT_TYPE = "application/octet-stream"
47
+
48
+ attr_reader :filename, :content_type
49
+
50
+ def initialize(content, filename: "file", content_type: DEFAULT_CONTENT_TYPE)
51
+ @content = content
52
+ @filename = filename
53
+ @content_type = content_type
54
+ end
55
+
56
+ # An IO net/http can read the bytes from. Strings are wrapped in a
57
+ # StringIO; Pathnames are opened in binary mode; existing IOs pass
58
+ # through unchanged.
59
+ def io
60
+ return @content if @content.respond_to?(:read)
61
+ if defined?(Pathname) && @content.is_a?(Pathname)
62
+ return @content.open("rb")
63
+ end
64
+
65
+ StringIO.new(@content.to_s)
66
+ end
67
+
68
+ def form_opts
69
+ {filename: @filename, content_type: @content_type}
70
+ end
71
+ end
72
+ end
73
+ end
@@ -10,7 +10,7 @@ module Retab
10
10
  model: :model,
11
11
  instructions: :instructions,
12
12
  image_resolution_dpi: :image_resolution_dpi,
13
- stream: :stream
13
+ background: :background
14
14
  }.freeze
15
15
 
16
16
  attr_accessor(
@@ -18,7 +18,7 @@ module Retab
18
18
  :model,
19
19
  :instructions,
20
20
  :image_resolution_dpi,
21
- :stream
21
+ :background
22
22
  )
23
23
 
24
24
  def initialize(json)
@@ -28,7 +28,7 @@ module Retab
28
28
  @model = hash[:model].nil? ? "retab-small" : hash[:model]
29
29
  @instructions = hash[:instructions]
30
30
  @image_resolution_dpi = hash[:image_resolution_dpi]
31
- @stream = hash[:stream].nil? ? false : hash[:stream]
31
+ @background = hash[:background].nil? ? false : hash[:background]
32
32
  end
33
33
  end
34
34
  end
@@ -3,20 +3,26 @@
3
3
  # This file is auto-generated by oagen. Do not edit.
4
4
 
5
5
  module Retab
6
- class PartialSchema < Retab::Types::BaseModel
6
+ class SchemaGeneration < Retab::Types::BaseModel
7
7
 
8
8
  HASH_ATTRS = {
9
9
  object: :object,
10
10
  created_at: :created_at,
11
11
  json_schema: :json_schema,
12
- strict: :strict
12
+ strict: :strict,
13
+ id: :id,
14
+ status: :status,
15
+ error: :error
13
16
  }.freeze
14
17
 
15
18
  attr_accessor(
16
19
  :object,
17
20
  :created_at,
18
21
  :json_schema,
19
- :strict
22
+ :strict,
23
+ :id,
24
+ :status,
25
+ :error
20
26
  )
21
27
 
22
28
  def initialize(json)
@@ -26,6 +32,9 @@ module Retab
26
32
  @created_at = hash[:created_at]
27
33
  @json_schema = hash[:json_schema] || {}
28
34
  @strict = hash[:strict].nil? ? true : hash[:strict]
35
+ @id = hash[:id]
36
+ @status = hash[:status].nil? ? "pending" : hash[:status]
37
+ @error = hash[:error] ? Retab::PrimitiveError.new(hash[:error]) : nil
29
38
  end
30
39
  end
31
40
  end
data/lib/retab/schemas.rb CHANGED
@@ -15,15 +15,15 @@ module Retab
15
15
  # @param model [String, nil]
16
16
  # @param instructions [String, nil]
17
17
  # @param image_resolution_dpi [Integer, nil] Resolution of the image sent to the LLM
18
- # @param stream [Boolean, nil]
18
+ # @param background [Boolean, nil] If true, run asynchronously: returns immediately with status 'queued'. Poll GET /v1/schemas/generate/{schema_generation_id} until status is terminal.
19
19
  # @param request_options [Hash] (see Retab::Types::RequestOptions)
20
- # @return [Retab::PartialSchema]
20
+ # @return [Retab::SchemaGeneration]
21
21
  def generate(
22
22
  documents:,
23
23
  model: nil,
24
24
  instructions: nil,
25
25
  image_resolution_dpi: nil,
26
- stream: nil,
26
+ background: nil,
27
27
  request_options: {}
28
28
  )
29
29
  documents = documents.map { |d| Retab::MimeData.coerce(d) } unless documents.nil?
@@ -32,7 +32,7 @@ module Retab
32
32
  "model" => model,
33
33
  "instructions" => instructions,
34
34
  "image_resolution_dpi" => image_resolution_dpi,
35
- "stream" => stream
35
+ "background" => background
36
36
  }.compact
37
37
  response = @client.request(
38
38
  method: :post,
@@ -41,7 +41,7 @@ module Retab
41
41
  body: body,
42
42
  request_options: request_options
43
43
  )
44
- result = Retab::PartialSchema.new(response.body)
44
+ result = Retab::SchemaGeneration.new(response.body)
45
45
  result.last_response = Retab::Types::ApiResponse.new(
46
46
  http_status: response.code.to_i,
47
47
  http_headers: response.each_header.to_h,
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file is auto-generated by oagen. Do not edit.
4
+
5
+ module Retab
6
+ class CreateSecretRequest < Retab::Types::BaseModel
7
+
8
+ HASH_ATTRS = {
9
+ name: :name,
10
+ value: :value
11
+ }.freeze
12
+
13
+ attr_accessor(
14
+ :name,
15
+ :value
16
+ )
17
+
18
+ def initialize(json)
19
+ super()
20
+ hash = self.class.normalize(json)
21
+ @name = hash[:name]
22
+ @value = hash[:value]
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file is auto-generated by oagen. Do not edit.
4
+
5
+ module Retab
6
+ class Secret < Retab::Types::BaseModel
7
+
8
+ HASH_ATTRS = {
9
+ name: :name,
10
+ created_at: :created_at,
11
+ updated_at: :updated_at,
12
+ created_by: :created_by,
13
+ updated_by: :updated_by
14
+ }.freeze
15
+
16
+ attr_accessor(
17
+ :name,
18
+ :created_at,
19
+ :updated_at,
20
+ :created_by,
21
+ :updated_by
22
+ )
23
+
24
+ def initialize(json)
25
+ super()
26
+ hash = self.class.normalize(json)
27
+ @name = hash[:name]
28
+ @created_at = hash[:created_at]
29
+ @updated_at = hash[:updated_at]
30
+ @created_by = hash[:created_by]
31
+ @updated_by = hash[:updated_by]
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file is auto-generated by oagen. Do not edit.
4
+
5
+ module Retab
6
+ class SecretListResponse < Retab::Types::BaseModel
7
+
8
+ HASH_ATTRS = {
9
+ secrets: :secrets
10
+ }.freeze
11
+
12
+ attr_accessor :secrets
13
+
14
+ def initialize(json)
15
+ super()
16
+ hash = self.class.normalize(json)
17
+ @secrets = (hash[:secrets] || []).map { |item| item ? Retab::Secret.new(item) : nil }
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file is auto-generated by oagen. Do not edit.
4
+
5
+ module Retab
6
+ class SecretResponse < Retab::Types::BaseModel
7
+
8
+ HASH_ATTRS = {
9
+ secret: :secret
10
+ }.freeze
11
+
12
+ attr_accessor :secret
13
+
14
+ def initialize(json)
15
+ super()
16
+ hash = self.class.normalize(json)
17
+ @secret = hash[:secret] ? Retab::Secret.new(hash[:secret]) : nil
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file is auto-generated by oagen. Do not edit.
4
+
5
+ module Retab
6
+ class SecretValue < Retab::Types::BaseModel
7
+
8
+ HASH_ATTRS = {
9
+ name: :name,
10
+ value: :value,
11
+ updated_at: :updated_at
12
+ }.freeze
13
+
14
+ attr_accessor(
15
+ :name,
16
+ :value,
17
+ :updated_at
18
+ )
19
+
20
+ def initialize(json)
21
+ super()
22
+ hash = self.class.normalize(json)
23
+ @name = hash[:name]
24
+ @value = hash[:value]
25
+ @updated_at = hash[:updated_at]
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file is auto-generated by oagen. Do not edit.
4
+
5
+ module Retab
6
+ class SecretValueResponse < Retab::Types::BaseModel
7
+
8
+ HASH_ATTRS = {
9
+ secret: :secret
10
+ }.freeze
11
+
12
+ attr_accessor :secret
13
+
14
+ def initialize(json)
15
+ super()
16
+ hash = self.class.normalize(json)
17
+ @secret = hash[:secret] ? Retab::SecretValue.new(hash[:secret]) : nil
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file is auto-generated by oagen. Do not edit.
4
+
5
+ module Retab
6
+ class SetSecretRequest < Retab::Types::BaseModel
7
+
8
+ HASH_ATTRS = {
9
+ value: :value
10
+ }.freeze
11
+
12
+ attr_accessor :value
13
+
14
+ def initialize(json)
15
+ super()
16
+ hash = self.class.normalize(json)
17
+ @value = hash[:value]
18
+ end
19
+ end
20
+ end