@retab/node 0.0.0-reserved → 0.0.42

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 (270) hide show
  1. package/README.md +293 -2
  2. package/dist/api/client.d.ts +15 -0
  3. package/dist/api/client.d.ts.map +1 -0
  4. package/dist/api/client.js +16 -0
  5. package/dist/api/consensus/client.d.ts +7 -0
  6. package/dist/api/consensus/client.d.ts.map +1 -0
  7. package/dist/api/consensus/client.js +14 -0
  8. package/dist/api/deployments/client.d.ts +20 -0
  9. package/dist/api/deployments/client.d.ts.map +1 -0
  10. package/dist/api/deployments/client.js +23 -0
  11. package/dist/api/documents/client.d.ts +10 -0
  12. package/dist/api/documents/client.d.ts.map +1 -0
  13. package/dist/api/documents/client.js +35 -0
  14. package/dist/api/models/client.d.ts +17 -0
  15. package/dist/api/models/client.d.ts.map +1 -0
  16. package/dist/api/models/client.js +15 -0
  17. package/dist/api/schemas/client.d.ts +12 -0
  18. package/dist/api/schemas/client.d.ts.map +1 -0
  19. package/dist/api/schemas/client.js +14 -0
  20. package/dist/client.d.ts +50 -0
  21. package/dist/client.d.ts.map +1 -0
  22. package/dist/client.js +135 -0
  23. package/dist/errors.d.ts +34 -0
  24. package/dist/errors.d.ts.map +1 -0
  25. package/dist/errors.js +53 -0
  26. package/dist/generated_types.d.ts +64373 -0
  27. package/dist/generated_types.d.ts.map +1 -0
  28. package/dist/generated_types.js +2267 -0
  29. package/dist/index.d.ts +8 -0
  30. package/dist/index.d.ts.map +1 -0
  31. package/dist/index.js +9 -0
  32. package/dist/mime.d.ts +5 -0
  33. package/dist/mime.d.ts.map +1 -0
  34. package/dist/mime.js +66 -0
  35. package/dist/resource.d.ts +12 -0
  36. package/dist/resource.d.ts.map +1 -0
  37. package/dist/resource.js +19 -0
  38. package/dist/resources/consensus/completions.d.ts +66 -0
  39. package/dist/resources/consensus/completions.d.ts.map +1 -0
  40. package/dist/resources/consensus/completions.js +84 -0
  41. package/dist/resources/consensus/index.d.ts +72 -0
  42. package/dist/resources/consensus/index.d.ts.map +1 -0
  43. package/dist/resources/consensus/index.js +76 -0
  44. package/dist/resources/consensus/responses.d.ts +69 -0
  45. package/dist/resources/consensus/responses.d.ts.map +1 -0
  46. package/dist/resources/consensus/responses.js +99 -0
  47. package/dist/resources/documents/extractions.d.ts +74 -0
  48. package/dist/resources/documents/extractions.d.ts.map +1 -0
  49. package/dist/resources/documents/extractions.js +196 -0
  50. package/dist/resources/documents/index.d.ts +21 -0
  51. package/dist/resources/documents/index.d.ts.map +1 -0
  52. package/dist/resources/documents/index.js +55 -0
  53. package/dist/resources/evaluations/documents.d.ts +40 -0
  54. package/dist/resources/evaluations/documents.d.ts.map +1 -0
  55. package/dist/resources/evaluations/documents.js +123 -0
  56. package/dist/resources/evaluations/index.d.ts +14 -0
  57. package/dist/resources/evaluations/index.d.ts.map +1 -0
  58. package/dist/resources/evaluations/index.js +17 -0
  59. package/dist/resources/evaluations/iterations.d.ts +50 -0
  60. package/dist/resources/evaluations/iterations.d.ts.map +1 -0
  61. package/dist/resources/evaluations/iterations.js +156 -0
  62. package/dist/resources/files.d.ts +82 -0
  63. package/dist/resources/files.d.ts.map +1 -0
  64. package/dist/resources/files.js +150 -0
  65. package/dist/resources/finetuning.d.ts +105 -0
  66. package/dist/resources/finetuning.d.ts.map +1 -0
  67. package/dist/resources/finetuning.js +181 -0
  68. package/dist/resources/index.d.ts +11 -0
  69. package/dist/resources/index.d.ts.map +1 -0
  70. package/dist/resources/index.js +10 -0
  71. package/dist/resources/models.d.ts +57 -0
  72. package/dist/resources/models.d.ts.map +1 -0
  73. package/dist/resources/models.js +72 -0
  74. package/dist/resources/processors/automations/endpoints.d.ts +90 -0
  75. package/dist/resources/processors/automations/endpoints.d.ts.map +1 -0
  76. package/dist/resources/processors/automations/endpoints.js +145 -0
  77. package/dist/resources/processors/automations/index.d.ts +7 -0
  78. package/dist/resources/processors/automations/index.d.ts.map +1 -0
  79. package/dist/resources/processors/automations/index.js +6 -0
  80. package/dist/resources/processors/automations/links.d.ts +90 -0
  81. package/dist/resources/processors/automations/links.d.ts.map +1 -0
  82. package/dist/resources/processors/automations/links.js +149 -0
  83. package/dist/resources/processors/automations/logs.d.ts +35 -0
  84. package/dist/resources/processors/automations/logs.d.ts.map +1 -0
  85. package/dist/resources/processors/automations/logs.js +60 -0
  86. package/dist/resources/processors/automations/mailboxes.d.ts +102 -0
  87. package/dist/resources/processors/automations/mailboxes.d.ts.map +1 -0
  88. package/dist/resources/processors/automations/mailboxes.js +157 -0
  89. package/dist/resources/processors/automations/outlook.d.ts +114 -0
  90. package/dist/resources/processors/automations/outlook.d.ts.map +1 -0
  91. package/dist/resources/processors/automations/outlook.js +170 -0
  92. package/dist/resources/processors/automations/tests.d.ts +58 -0
  93. package/dist/resources/processors/automations/tests.d.ts.map +1 -0
  94. package/dist/resources/processors/automations/tests.js +90 -0
  95. package/dist/resources/processors/index.d.ts +303 -0
  96. package/dist/resources/processors/index.d.ts.map +1 -0
  97. package/dist/resources/processors/index.js +261 -0
  98. package/dist/resources/schemas.d.ts +63 -0
  99. package/dist/resources/schemas.d.ts.map +1 -0
  100. package/dist/resources/schemas.js +183 -0
  101. package/dist/resources/secrets/external_api_keys.d.ts +61 -0
  102. package/dist/resources/secrets/external_api_keys.d.ts.map +1 -0
  103. package/dist/resources/secrets/external_api_keys.js +120 -0
  104. package/dist/resources/secrets/index.d.ts +14 -0
  105. package/dist/resources/secrets/index.d.ts.map +1 -0
  106. package/dist/resources/secrets/index.js +17 -0
  107. package/dist/resources/secrets/webhooks.d.ts +73 -0
  108. package/dist/resources/secrets/webhooks.d.ts.map +1 -0
  109. package/dist/resources/secrets/webhooks.js +145 -0
  110. package/dist/resources/usage.d.ts +223 -0
  111. package/dist/resources/usage.d.ts.map +1 -0
  112. package/dist/resources/usage.js +310 -0
  113. package/dist/types/ai_models.d.ts +389 -0
  114. package/dist/types/ai_models.d.ts.map +1 -0
  115. package/dist/types/ai_models.js +145 -0
  116. package/dist/types/automations/cron.d.ts +28 -0
  117. package/dist/types/automations/cron.d.ts.map +1 -0
  118. package/dist/types/automations/cron.js +1 -0
  119. package/dist/types/automations/endpoints.d.ts +13 -0
  120. package/dist/types/automations/endpoints.d.ts.map +1 -0
  121. package/dist/types/automations/endpoints.js +1 -0
  122. package/dist/types/automations/index.d.ts +7 -0
  123. package/dist/types/automations/index.d.ts.map +1 -0
  124. package/dist/types/automations/index.js +6 -0
  125. package/dist/types/automations/links.d.ts +15 -0
  126. package/dist/types/automations/links.d.ts.map +1 -0
  127. package/dist/types/automations/links.js +1 -0
  128. package/dist/types/automations/mailboxes.d.ts +18 -0
  129. package/dist/types/automations/mailboxes.d.ts.map +1 -0
  130. package/dist/types/automations/mailboxes.js +1 -0
  131. package/dist/types/automations/outlook.d.ts +37 -0
  132. package/dist/types/automations/outlook.d.ts.map +1 -0
  133. package/dist/types/automations/outlook.js +1 -0
  134. package/dist/types/automations/webhooks.d.ts +13 -0
  135. package/dist/types/automations/webhooks.d.ts.map +1 -0
  136. package/dist/types/automations/webhooks.js +1 -0
  137. package/dist/types/browser_canvas.d.ts +4 -0
  138. package/dist/types/browser_canvas.d.ts.map +1 -0
  139. package/dist/types/browser_canvas.js +2 -0
  140. package/dist/types/chat.d.ts +99 -0
  141. package/dist/types/chat.d.ts.map +1 -0
  142. package/dist/types/chat.js +20 -0
  143. package/dist/types/consensus.d.ts +10 -0
  144. package/dist/types/consensus.d.ts.map +1 -0
  145. package/dist/types/consensus.js +1 -0
  146. package/dist/types/db/annotations.d.ts +108 -0
  147. package/dist/types/db/annotations.d.ts.map +1 -0
  148. package/dist/types/db/annotations.js +6 -0
  149. package/dist/types/db/files.d.ts +133 -0
  150. package/dist/types/db/files.d.ts.map +1 -0
  151. package/dist/types/db/files.js +5 -0
  152. package/dist/types/documents/extractions.d.ts +1849 -0
  153. package/dist/types/documents/extractions.d.ts.map +1 -0
  154. package/dist/types/documents/extractions.js +211 -0
  155. package/dist/types/documents/processing.d.ts +249 -0
  156. package/dist/types/documents/processing.d.ts.map +1 -0
  157. package/dist/types/documents/processing.js +6 -0
  158. package/dist/types/evaluations/iterations.d.ts +41 -0
  159. package/dist/types/evaluations/iterations.d.ts.map +1 -0
  160. package/dist/types/evaluations/iterations.js +1 -0
  161. package/dist/types/jobs/base.d.ts +162 -0
  162. package/dist/types/jobs/base.d.ts.map +1 -0
  163. package/dist/types/jobs/base.js +6 -0
  164. package/dist/types/jobs/specialized.d.ts +200 -0
  165. package/dist/types/jobs/specialized.d.ts.map +1 -0
  166. package/dist/types/jobs/specialized.js +37 -0
  167. package/dist/types/logs.d.ts +92 -0
  168. package/dist/types/logs.d.ts.map +1 -0
  169. package/dist/types/logs.js +1 -0
  170. package/dist/types/mime.d.ts +426 -0
  171. package/dist/types/mime.d.ts.map +1 -0
  172. package/dist/types/mime.js +48 -0
  173. package/dist/types/modalities.d.ts +31 -0
  174. package/dist/types/modalities.d.ts.map +1 -0
  175. package/dist/types/modalities.js +109 -0
  176. package/dist/types/pagination.d.ts +5 -0
  177. package/dist/types/pagination.d.ts.map +1 -0
  178. package/dist/types/pagination.js +1 -0
  179. package/dist/types/schemas/enhancement.d.ts +250 -0
  180. package/dist/types/schemas/enhancement.d.ts.map +1 -0
  181. package/dist/types/schemas/enhancement.js +6 -0
  182. package/dist/types/schemas/generate.d.ts +160 -0
  183. package/dist/types/schemas/generate.d.ts.map +1 -0
  184. package/dist/types/schemas/generate.js +19 -0
  185. package/dist/types/schemas/object.d.ts +116 -0
  186. package/dist/types/schemas/object.d.ts.map +1 -0
  187. package/dist/types/schemas/object.js +861 -0
  188. package/dist/types/secrets/external_api_keys.d.ts +27 -0
  189. package/dist/types/secrets/external_api_keys.d.ts.map +1 -0
  190. package/dist/types/secrets/external_api_keys.js +11 -0
  191. package/dist/types/secrets/index.d.ts +2 -0
  192. package/dist/types/secrets/index.d.ts.map +1 -0
  193. package/dist/types/secrets/index.js +1 -0
  194. package/dist/types/standards.d.ts +37 -0
  195. package/dist/types/standards.d.ts.map +1 -0
  196. package/dist/types/standards.js +1 -0
  197. package/dist/types.d.ts +276 -0
  198. package/dist/types.d.ts.map +1 -0
  199. package/dist/types.js +85 -0
  200. package/dist/utils/ai_models.d.ts +10 -0
  201. package/dist/utils/ai_models.d.ts.map +1 -0
  202. package/dist/utils/ai_models.js +183 -0
  203. package/dist/utils/batch_processing.d.ts +227 -0
  204. package/dist/utils/batch_processing.d.ts.map +1 -0
  205. package/dist/utils/batch_processing.js +268 -0
  206. package/dist/utils/benchmarking.d.ts +115 -0
  207. package/dist/utils/benchmarking.d.ts.map +1 -0
  208. package/dist/utils/benchmarking.js +355 -0
  209. package/dist/utils/chat.d.ts +70 -0
  210. package/dist/utils/chat.d.ts.map +1 -0
  211. package/dist/utils/chat.js +79 -0
  212. package/dist/utils/cost_calculation.d.ts +26 -0
  213. package/dist/utils/cost_calculation.d.ts.map +1 -0
  214. package/dist/utils/cost_calculation.js +99 -0
  215. package/dist/utils/datasets.d.ts +135 -0
  216. package/dist/utils/datasets.d.ts.map +1 -0
  217. package/dist/utils/datasets.js +359 -0
  218. package/dist/utils/display.d.ts +108 -0
  219. package/dist/utils/display.d.ts.map +1 -0
  220. package/dist/utils/display.js +244 -0
  221. package/dist/utils/hash.d.ts +18 -0
  222. package/dist/utils/hash.d.ts.map +1 -0
  223. package/dist/utils/hash.js +31 -0
  224. package/dist/utils/hashing.d.ts +18 -0
  225. package/dist/utils/hashing.d.ts.map +1 -0
  226. package/dist/utils/hashing.js +28 -0
  227. package/dist/utils/index.d.ts +8 -0
  228. package/dist/utils/index.d.ts.map +1 -0
  229. package/dist/utils/index.js +10 -0
  230. package/dist/utils/json_schema.d.ts +18 -0
  231. package/dist/utils/json_schema.d.ts.map +1 -0
  232. package/dist/utils/json_schema.js +334 -0
  233. package/dist/utils/json_schema_utils.d.ts +42 -0
  234. package/dist/utils/json_schema_utils.d.ts.map +1 -0
  235. package/dist/utils/json_schema_utils.js +212 -0
  236. package/dist/utils/jsonl.d.ts +60 -0
  237. package/dist/utils/jsonl.d.ts.map +1 -0
  238. package/dist/utils/jsonl.js +259 -0
  239. package/dist/utils/mime.d.ts +6 -0
  240. package/dist/utils/mime.d.ts.map +1 -0
  241. package/dist/utils/mime.js +129 -0
  242. package/dist/utils/model_cards.d.ts +219 -0
  243. package/dist/utils/model_cards.d.ts.map +1 -0
  244. package/dist/utils/model_cards.js +462 -0
  245. package/dist/utils/prompt_optimization.d.ts +96 -0
  246. package/dist/utils/prompt_optimization.d.ts.map +1 -0
  247. package/dist/utils/prompt_optimization.js +275 -0
  248. package/dist/utils/responses.d.ts +35 -0
  249. package/dist/utils/responses.d.ts.map +1 -0
  250. package/dist/utils/responses.js +37 -0
  251. package/dist/utils/stream.d.ts +13 -0
  252. package/dist/utils/stream.d.ts.map +1 -0
  253. package/dist/utils/stream.js +64 -0
  254. package/dist/utils/stream_context_managers.d.ts +147 -0
  255. package/dist/utils/stream_context_managers.d.ts.map +1 -0
  256. package/dist/utils/stream_context_managers.js +380 -0
  257. package/dist/utils/usage.d.ts +57 -0
  258. package/dist/utils/usage.d.ts.map +1 -0
  259. package/dist/utils/usage.js +97 -0
  260. package/dist/utils/webhook_secrets.d.ts +59 -0
  261. package/dist/utils/webhook_secrets.d.ts.map +1 -0
  262. package/dist/utils/webhook_secrets.js +107 -0
  263. package/dist/utils/zod_to_json_schema.d.ts +11 -0
  264. package/dist/utils/zod_to_json_schema.d.ts.map +1 -0
  265. package/dist/utils/zod_to_json_schema.js +123 -0
  266. package/dist/utils.d.ts +19 -0
  267. package/dist/utils.d.ts.map +1 -0
  268. package/dist/utils.js +1 -0
  269. package/package.json +62 -6
  270. package/index.js +0 -7
@@ -0,0 +1,310 @@
1
+ import { SyncAPIResource, AsyncAPIResource } from '../resource.js';
2
+ // Global variable to track total cost
3
+ let totalCost = 0.0;
4
+ export class UsageMixin {
5
+ prepareMonthlyCreditsUsage() {
6
+ return {
7
+ method: 'GET',
8
+ url: '/v1/usage/monthly_credits',
9
+ };
10
+ }
11
+ prepareTotal(params = {}) {
12
+ const queryParams = {};
13
+ if (params.start_date) {
14
+ queryParams.start_date = params.start_date.toISOString();
15
+ }
16
+ if (params.end_date) {
17
+ queryParams.end_date = params.end_date.toISOString();
18
+ }
19
+ return {
20
+ method: 'GET',
21
+ url: '/v1/usage/total',
22
+ params: queryParams,
23
+ };
24
+ }
25
+ prepareMailbox(params) {
26
+ const queryParams = {};
27
+ if (params.start_date) {
28
+ queryParams.start_date = params.start_date.toISOString();
29
+ }
30
+ if (params.end_date) {
31
+ queryParams.end_date = params.end_date.toISOString();
32
+ }
33
+ return {
34
+ method: 'GET',
35
+ url: `/v1/processors/automations/mailboxes/${params.email}/usage`,
36
+ params: queryParams,
37
+ };
38
+ }
39
+ prepareLink(params) {
40
+ const queryParams = {};
41
+ if (params.start_date) {
42
+ queryParams.start_date = params.start_date.toISOString();
43
+ }
44
+ if (params.end_date) {
45
+ queryParams.end_date = params.end_date.toISOString();
46
+ }
47
+ return {
48
+ method: 'GET',
49
+ url: `/v1/processors/automations/links/${params.link_id}/usage`,
50
+ params: queryParams,
51
+ };
52
+ }
53
+ prepareSchema(params) {
54
+ const queryParams = {};
55
+ if (params.start_date) {
56
+ queryParams.start_date = params.start_date.toISOString();
57
+ }
58
+ if (params.end_date) {
59
+ queryParams.end_date = params.end_date.toISOString();
60
+ }
61
+ return {
62
+ method: 'GET',
63
+ url: `/v1/schemas/${params.schema_id}/usage`,
64
+ params: queryParams,
65
+ };
66
+ }
67
+ prepareSchemaData(params) {
68
+ const queryParams = {};
69
+ if (params.start_date) {
70
+ queryParams.start_date = params.start_date.toISOString();
71
+ }
72
+ if (params.end_date) {
73
+ queryParams.end_date = params.end_date.toISOString();
74
+ }
75
+ return {
76
+ method: 'GET',
77
+ url: `/v1/schemas/${params.schema_data_id}/usage_data`,
78
+ params: queryParams,
79
+ };
80
+ }
81
+ prepareLog(params) {
82
+ let logCompletionRequest;
83
+ if (params.response_format && typeof params.response_format === 'object') {
84
+ if ('json_schema' in params.response_format) {
85
+ const jsonSchema = params.response_format.json_schema;
86
+ if ('schema' in jsonSchema) {
87
+ logCompletionRequest = {
88
+ json_schema: jsonSchema.schema,
89
+ completion: params.completion,
90
+ };
91
+ }
92
+ else {
93
+ throw new Error('Invalid response format');
94
+ }
95
+ }
96
+ else {
97
+ throw new Error('Invalid response format');
98
+ }
99
+ }
100
+ else {
101
+ throw new Error('Invalid response format');
102
+ }
103
+ return {
104
+ method: 'POST',
105
+ url: '/v1/usage/log',
106
+ data: logCompletionRequest,
107
+ };
108
+ }
109
+ }
110
+ export class Usage extends SyncAPIResource {
111
+ constructor() {
112
+ super(...arguments);
113
+ this.mixin = new UsageMixin();
114
+ }
115
+ /**
116
+ * Get monthly credits usage information.
117
+ * Credits are calculated dynamically based on MIME type and consumption.
118
+ *
119
+ * @returns Monthly usage data including credits consumed and limits
120
+ * @throws RetabAPIError if the API request fails
121
+ */
122
+ monthlyCreditsUsage() {
123
+ const request = this.mixin.prepareMonthlyCreditsUsage();
124
+ const response = this._client._preparedRequest(request);
125
+ return response;
126
+ }
127
+ /**
128
+ * Get the total usage cost within an optional date range.
129
+ *
130
+ * @param start_date - Start date for usage calculation
131
+ * @param end_date - End date for usage calculation
132
+ * @returns The total usage cost
133
+ */
134
+ total(_params = {}) {
135
+ return { value: totalCost, currency: 'USD' };
136
+ }
137
+ /**
138
+ * Get the total usage cost for a mailbox within an optional date range.
139
+ *
140
+ * @param email - The email address of the mailbox
141
+ * @param start_date - Start date for usage calculation
142
+ * @param end_date - End date for usage calculation
143
+ * @returns The total usage cost
144
+ */
145
+ mailbox(params) {
146
+ const request = this.mixin.prepareMailbox(params);
147
+ const response = this._client._preparedRequest(request);
148
+ return response;
149
+ }
150
+ /**
151
+ * Get the total usage cost for a link within an optional date range.
152
+ *
153
+ * @param link_id - The ID of the link
154
+ * @param start_date - Start date for usage calculation
155
+ * @param end_date - End date for usage calculation
156
+ * @returns The total usage cost
157
+ */
158
+ link(params) {
159
+ const request = this.mixin.prepareLink(params);
160
+ const response = this._client._preparedRequest(request);
161
+ return response;
162
+ }
163
+ /**
164
+ * Get the total usage cost for a schema within an optional date range.
165
+ *
166
+ * @param schema_id - The ID of the schema
167
+ * @param start_date - Start date for usage calculation
168
+ * @param end_date - End date for usage calculation
169
+ * @returns The total usage cost
170
+ */
171
+ schema(params) {
172
+ const request = this.mixin.prepareSchema(params);
173
+ const response = this._client._preparedRequest(request);
174
+ return response;
175
+ }
176
+ /**
177
+ * Get the total usage cost for a schema data within an optional date range.
178
+ *
179
+ * @param schema_data_id - The ID of the schema data
180
+ * @param start_date - Start date for usage calculation
181
+ * @param end_date - End date for usage calculation
182
+ * @returns The total usage cost
183
+ */
184
+ schemaData(params) {
185
+ const request = this.mixin.prepareSchemaData(params);
186
+ const response = this._client._preparedRequest(request);
187
+ return response;
188
+ }
189
+ /**
190
+ * Logs an OpenAI request completion as an automation log to make usage calculation possible.
191
+ *
192
+ * Example:
193
+ * ```typescript
194
+ * const client = new OpenAI();
195
+ * const completion = await client.beta.chat.completions.parse({
196
+ * model: "gpt-4o-2024-08-06",
197
+ * messages: [
198
+ * {"role": "developer", "content": "Extract the event information."},
199
+ * {"role": "user", "content": "Alice and Bob are going to a science fair on Friday."},
200
+ * ],
201
+ * response_format: CalendarEvent,
202
+ * });
203
+ * reclient.usage.log({
204
+ * response_format: CalendarEvent,
205
+ * completion: completion
206
+ * });
207
+ * ```
208
+ *
209
+ * @param response_format - The response format of the OpenAI request
210
+ * @param completion - The completion of the OpenAI request
211
+ * @returns The automation log
212
+ */
213
+ log(params) {
214
+ const request = this.mixin.prepareLog(params);
215
+ const response = this._client._preparedRequest(request);
216
+ return response;
217
+ }
218
+ }
219
+ export class AsyncUsage extends AsyncAPIResource {
220
+ constructor() {
221
+ super(...arguments);
222
+ this.mixin = new UsageMixin();
223
+ }
224
+ /**
225
+ * Get monthly credits usage information asynchronously.
226
+ * Credits are calculated dynamically based on MIME type and consumption.
227
+ *
228
+ * @returns Monthly usage data including credits consumed and limits
229
+ * @throws RetabAPIError if the API request fails
230
+ */
231
+ async monthlyCreditsUsage() {
232
+ const request = this.mixin.prepareMonthlyCreditsUsage();
233
+ const response = await this._client._preparedRequest(request);
234
+ return response;
235
+ }
236
+ /**
237
+ * Get the total usage cost within an optional date range.
238
+ *
239
+ * @param start_date - Start date for usage calculation
240
+ * @param end_date - End date for usage calculation
241
+ * @returns The total usage cost
242
+ */
243
+ async total(_params = {}) {
244
+ return { value: totalCost, currency: 'USD' };
245
+ }
246
+ /**
247
+ * Get the total usage cost for a mailbox within an optional date range.
248
+ *
249
+ * @param email - The email address of the mailbox
250
+ * @param start_date - Start date for usage calculation
251
+ * @param end_date - End date for usage calculation
252
+ * @returns The total usage cost
253
+ */
254
+ async mailbox(params) {
255
+ const request = this.mixin.prepareMailbox(params);
256
+ const response = await this._client._preparedRequest(request);
257
+ return response;
258
+ }
259
+ /**
260
+ * Get the total usage cost for a link within an optional date range.
261
+ *
262
+ * @param link_id - The ID of the link
263
+ * @param start_date - Start date for usage calculation
264
+ * @param end_date - End date for usage calculation
265
+ * @returns The total usage cost
266
+ */
267
+ async link(params) {
268
+ const request = this.mixin.prepareLink(params);
269
+ const response = await this._client._preparedRequest(request);
270
+ return response;
271
+ }
272
+ /**
273
+ * Get the total usage cost for a schema within an optional date range.
274
+ *
275
+ * @param schema_id - The ID of the schema
276
+ * @param start_date - Start date for usage calculation
277
+ * @param end_date - End date for usage calculation
278
+ * @returns The total usage cost
279
+ */
280
+ async schema(params) {
281
+ const request = this.mixin.prepareSchema(params);
282
+ const response = await this._client._preparedRequest(request);
283
+ return response;
284
+ }
285
+ /**
286
+ * Get the total usage cost for a schema data within an optional date range.
287
+ *
288
+ * @param schema_data_id - The ID of the schema data
289
+ * @param start_date - Start date for usage calculation
290
+ * @param end_date - End date for usage calculation
291
+ * @returns The total usage cost
292
+ */
293
+ async schemaData(params) {
294
+ const request = this.mixin.prepareSchemaData(params);
295
+ const response = await this._client._preparedRequest(request);
296
+ return response;
297
+ }
298
+ /**
299
+ * Logs an OpenAI request completion as an automation log to make usage calculation possible.
300
+ *
301
+ * @param response_format - The response format of the OpenAI request
302
+ * @param completion - The completion of the OpenAI request
303
+ * @returns The automation log
304
+ */
305
+ async log(params) {
306
+ const request = this.mixin.prepareLog(params);
307
+ const response = await this._client._preparedRequest(request);
308
+ return response;
309
+ }
310
+ }