@abyss-project/tools 1.0.1 → 1.0.3
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.
- package/dist/api/index.js.map +1 -1
- package/dist/types/interface/api/responses/recent.response.d.ts +1 -0
- package/package.json +52 -57
- package/src/api/index.ts +0 -1
- package/src/api/rcb.api.ts +829 -829
- package/src/types/enum/pdf-operation.enum.ts +98 -98
- package/src/types/enum/rcb-bank.enum.ts +137 -137
- package/src/types/interface/api/requests/rcb.request.ts +267 -267
- package/src/types/interface/api/responses/rcb.response.ts +399 -399
- package/src/types/interface/api/responses/recent.response.ts +2 -0
- package/src/types/interface/models/rcb.dto.ts +267 -267
- package/src/utils/rcb-webhook.utils.ts +30 -30
- package/src/api/atlas-page-content.api.ts +0 -0
package/src/api/rcb.api.ts
CHANGED
|
@@ -1,829 +1,829 @@
|
|
|
1
|
-
// ──────────────────────────────────────────────
|
|
2
|
-
// RCB (bank statement extraction) — user-facing API.
|
|
3
|
-
//
|
|
4
|
-
// Sync helper accepts an inline PDF buffer (multipart) or a storage_file_id.
|
|
5
|
-
// Queue helper enqueues for async processing + webhook delivery.
|
|
6
|
-
// ──────────────────────────────────────────────
|
|
7
|
-
|
|
8
|
-
import { AbyssToolsCore } from '..';
|
|
9
|
-
import {
|
|
10
|
-
IExtractRcbBody,
|
|
11
|
-
IExtractBulkRcbBody,
|
|
12
|
-
IDetectBulkRcbBody,
|
|
13
|
-
IListFilesRcbQuery,
|
|
14
|
-
IPatchFileRcbBody,
|
|
15
|
-
IPatchExtractionRcbBody,
|
|
16
|
-
ISearchExtractionRecordsRcbQuery,
|
|
17
|
-
IExportExtractionRcbQuery,
|
|
18
|
-
IAsyncExportExtractionRcbBody,
|
|
19
|
-
IListUsageRcbQuery,
|
|
20
|
-
ISummaryUsageRcbQuery,
|
|
21
|
-
IListWebhookDeliveriesRcbQuery,
|
|
22
|
-
IReplayWebhookDeliveryRcbBody,
|
|
23
|
-
IMintShareExtractionRcbBody,
|
|
24
|
-
} from '../types';
|
|
25
|
-
import {
|
|
26
|
-
IExtractSyncRcbResponse,
|
|
27
|
-
IExtractQueueRcbResponse,
|
|
28
|
-
IExtractBulkRcbResponse,
|
|
29
|
-
IDetectRcbResponse,
|
|
30
|
-
IDetectBulkRcbResponse,
|
|
31
|
-
IListFilesRcbResponse,
|
|
32
|
-
IGetFileRcbResponse,
|
|
33
|
-
IListFileExtractionsRcbResponse,
|
|
34
|
-
IGetExtractionRcbResponse,
|
|
35
|
-
ISearchExtractionRecordsRcbResponse,
|
|
36
|
-
IDiffExtractionsRcbResponse,
|
|
37
|
-
IAsyncExportRcbResponse,
|
|
38
|
-
IGetExportJobRcbResponse,
|
|
39
|
-
ICreateTemplateRcbResponse,
|
|
40
|
-
IUpdateTemplateRcbResponse,
|
|
41
|
-
IListTemplatesRcbResponse,
|
|
42
|
-
IGetTemplateRcbResponse,
|
|
43
|
-
IListTemplateVersionsRcbResponse,
|
|
44
|
-
IRcbTemplateCollection,
|
|
45
|
-
IImportTemplateCollectionRcbResponse,
|
|
46
|
-
IGetJobRcbResponse,
|
|
47
|
-
ICreateFeedbackRcbResponse,
|
|
48
|
-
IListFeedbackRcbResponse,
|
|
49
|
-
IGetFeedbackRcbResponse,
|
|
50
|
-
IHealthRcbResponse,
|
|
51
|
-
IStatsRcbResponse,
|
|
52
|
-
ISummaryUsageRcbResponse,
|
|
53
|
-
IGetQuotaRcbResponse,
|
|
54
|
-
IListWebhookDeliveriesRcbResponse,
|
|
55
|
-
IGetWebhookDeliveryRcbResponse,
|
|
56
|
-
IGetSharedExtractionRcbResponse,
|
|
57
|
-
IMintShareExtractionRcbResponse,
|
|
58
|
-
IChangelogRcbResponse,
|
|
59
|
-
} from '../types';
|
|
60
|
-
import {
|
|
61
|
-
ICreateTemplateRcbBody,
|
|
62
|
-
IUpdateTemplateRcbBody,
|
|
63
|
-
IPatchTemplateMetaRcbBody,
|
|
64
|
-
ICreateFeedbackRcbBody,
|
|
65
|
-
IPatchFeedbackRcbBody,
|
|
66
|
-
IListFeedbackRcbQuery,
|
|
67
|
-
IListSharedFilesRcbQuery,
|
|
68
|
-
IPaginateRcbWebhookQuery,
|
|
69
|
-
ICreateRcbWebhookBody,
|
|
70
|
-
IUpdateRcbWebhookBody,
|
|
71
|
-
IRcbWebhookScopeQuery,
|
|
72
|
-
} from '../types';
|
|
73
|
-
import type {
|
|
74
|
-
IPaginateRcbWebhookResponse,
|
|
75
|
-
IGetRcbWebhookResponse,
|
|
76
|
-
ICreateRcbWebhookResponse,
|
|
77
|
-
IUpdateRcbWebhookResponse,
|
|
78
|
-
IDeleteRcbWebhookResponse,
|
|
79
|
-
IResetSecretRcbWebhookResponse,
|
|
80
|
-
} from '../types';
|
|
81
|
-
|
|
82
|
-
const DEFAULT_API_KEY_HEADER = 'x-api-key';
|
|
83
|
-
|
|
84
|
-
function authHeader(apiKey?: string): Record<string, string> {
|
|
85
|
-
return apiKey ? { [DEFAULT_API_KEY_HEADER]: apiKey } : {};
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
async function loadFormData(): Promise<any> {
|
|
89
|
-
if (typeof FormData !== 'undefined' && typeof window !== 'undefined') {
|
|
90
|
-
return FormData;
|
|
91
|
-
}
|
|
92
|
-
// Use indirect eval so bundlers (esbuild/vite/webpack) do not try to
|
|
93
|
-
// resolve the Node-only "form-data" package when this file is included
|
|
94
|
-
// in a browser bundle. The require only runs at runtime on Node.
|
|
95
|
-
// eslint-disable-next-line @typescript-eslint/no-implied-eval, no-new-func
|
|
96
|
-
const nodeRequire: NodeRequire = new Function('return require')();
|
|
97
|
-
return nodeRequire('form-data');
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
function serializeParams<T extends object>(o: T): Record<string, unknown> {
|
|
101
|
-
const out: Record<string, unknown> = {};
|
|
102
|
-
for (const [k, v] of Object.entries(o as Record<string, unknown>)) {
|
|
103
|
-
if (v === undefined || v === null) continue;
|
|
104
|
-
out[k] = v instanceof Date ? v.toISOString() : v;
|
|
105
|
-
}
|
|
106
|
-
return out;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// ─── EXTRACT ─────────────────────────────────
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Optional per-call extras for extract endpoints. `idempotencyKey` is a
|
|
113
|
-
* Stripe-style replay key (24h window) sent as the `Idempotency-Key` header —
|
|
114
|
-
* not part of the request body.
|
|
115
|
-
*/
|
|
116
|
-
export interface ExtractCallOptions {
|
|
117
|
-
idempotencyKey?: string;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export const extractSyncRcb = async (
|
|
121
|
-
body: IExtractRcbBody,
|
|
122
|
-
apiKey?: string,
|
|
123
|
-
opts: ExtractCallOptions = {},
|
|
124
|
-
): Promise<IExtractSyncRcbResponse> => {
|
|
125
|
-
return postExtract(
|
|
126
|
-
{ ...body, processing: 'sync' },
|
|
127
|
-
apiKey,
|
|
128
|
-
opts,
|
|
129
|
-
) as Promise<IExtractSyncRcbResponse>;
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
export const extractQueueRcb = async (
|
|
133
|
-
body: IExtractRcbBody,
|
|
134
|
-
apiKey?: string,
|
|
135
|
-
opts: ExtractCallOptions = {},
|
|
136
|
-
): Promise<IExtractQueueRcbResponse> => {
|
|
137
|
-
return postExtract(
|
|
138
|
-
{ ...body, processing: 'queue' },
|
|
139
|
-
apiKey,
|
|
140
|
-
opts,
|
|
141
|
-
) as Promise<IExtractQueueRcbResponse>;
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
const postExtract = async (
|
|
145
|
-
body: IExtractRcbBody,
|
|
146
|
-
apiKey?: string,
|
|
147
|
-
opts: ExtractCallOptions = {},
|
|
148
|
-
): Promise<unknown> => {
|
|
149
|
-
const extraHeaders: Record<string, string> = {};
|
|
150
|
-
if (opts.idempotencyKey) {
|
|
151
|
-
extraHeaders['Idempotency-Key'] = opts.idempotencyKey;
|
|
152
|
-
}
|
|
153
|
-
if (body.pdf) {
|
|
154
|
-
const isBrowser = typeof window !== 'undefined' && typeof FormData !== 'undefined';
|
|
155
|
-
const filename = body.pdf_filename ?? 'rcb.pdf';
|
|
156
|
-
if (isBrowser) {
|
|
157
|
-
const form = new FormData();
|
|
158
|
-
const blob = new Blob([body.pdf as Uint8Array], { type: 'application/pdf' });
|
|
159
|
-
form.append('file', blob, filename);
|
|
160
|
-
appendIf(form, 'mode', body.mode);
|
|
161
|
-
if (body.hint) form.append('hint', JSON.stringify(body.hint));
|
|
162
|
-
appendIf(form, 'template_id', body.template_id);
|
|
163
|
-
if (body.template) form.append('template', JSON.stringify(body.template));
|
|
164
|
-
appendIf(form, 'user_external_id', body.user_external_id);
|
|
165
|
-
if (body.user_metadata) form.append('user_metadata', JSON.stringify(body.user_metadata));
|
|
166
|
-
if (typeof body.archive === 'boolean') form.append('archive', String(body.archive));
|
|
167
|
-
if (typeof body.force === 'boolean') form.append('force', String(body.force));
|
|
168
|
-
if (body.processing) form.append('processing', body.processing);
|
|
169
|
-
return (
|
|
170
|
-
await AbyssToolsCore.axios.post(`rcb/extract`, form, {
|
|
171
|
-
headers: { ...authHeader(apiKey), ...extraHeaders },
|
|
172
|
-
maxBodyLength: Infinity,
|
|
173
|
-
maxContentLength: Infinity,
|
|
174
|
-
})
|
|
175
|
-
).data;
|
|
176
|
-
}
|
|
177
|
-
const FormDataCtor = await loadFormData();
|
|
178
|
-
const form = new FormDataCtor();
|
|
179
|
-
const buf = Buffer.isBuffer(body.pdf) ? body.pdf : Buffer.from(body.pdf);
|
|
180
|
-
form.append('file', buf, {
|
|
181
|
-
filename,
|
|
182
|
-
contentType: 'application/pdf',
|
|
183
|
-
});
|
|
184
|
-
appendIf(form, 'mode', body.mode);
|
|
185
|
-
if (body.hint) form.append('hint', JSON.stringify(body.hint));
|
|
186
|
-
appendIf(form, 'template_id', body.template_id);
|
|
187
|
-
if (body.template) form.append('template', JSON.stringify(body.template));
|
|
188
|
-
appendIf(form, 'user_external_id', body.user_external_id);
|
|
189
|
-
if (body.user_metadata) form.append('user_metadata', JSON.stringify(body.user_metadata));
|
|
190
|
-
if (typeof body.archive === 'boolean') form.append('archive', String(body.archive));
|
|
191
|
-
if (typeof body.force === 'boolean') form.append('force', String(body.force));
|
|
192
|
-
if (body.processing) form.append('processing', body.processing);
|
|
193
|
-
return (
|
|
194
|
-
await AbyssToolsCore.axios.post(`rcb/extract`, form, {
|
|
195
|
-
headers: {
|
|
196
|
-
...(typeof form.getHeaders === 'function' ? form.getHeaders() : {}),
|
|
197
|
-
...authHeader(apiKey),
|
|
198
|
-
...extraHeaders,
|
|
199
|
-
},
|
|
200
|
-
maxBodyLength: Infinity,
|
|
201
|
-
maxContentLength: Infinity,
|
|
202
|
-
})
|
|
203
|
-
).data;
|
|
204
|
-
}
|
|
205
|
-
// Strip `pdf` from the JSON body (only used for multipart upload above).
|
|
206
|
-
const jsonBody: Omit<IExtractRcbBody, 'pdf'> = { ...body };
|
|
207
|
-
delete (jsonBody as { pdf?: unknown }).pdf;
|
|
208
|
-
return (
|
|
209
|
-
await AbyssToolsCore.axios.post(`rcb/extract`, jsonBody, {
|
|
210
|
-
headers: { ...authHeader(apiKey), ...extraHeaders },
|
|
211
|
-
})
|
|
212
|
-
).data;
|
|
213
|
-
};
|
|
214
|
-
|
|
215
|
-
function appendIf(form: any, key: string, value: unknown): void {
|
|
216
|
-
if (value === undefined || value === null) return;
|
|
217
|
-
form.append(key, String(value));
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
export const extractBulkRcb = async (
|
|
221
|
-
body: IExtractBulkRcbBody,
|
|
222
|
-
apiKey?: string,
|
|
223
|
-
): Promise<IExtractBulkRcbResponse> => {
|
|
224
|
-
return (
|
|
225
|
-
await AbyssToolsCore.axios.post<IExtractBulkRcbResponse>(`rcb/extract/bulk`, body, {
|
|
226
|
-
headers: authHeader(apiKey),
|
|
227
|
-
})
|
|
228
|
-
).data;
|
|
229
|
-
};
|
|
230
|
-
|
|
231
|
-
// ─── DETECT ──────────────────────────────────
|
|
232
|
-
|
|
233
|
-
export const detectRcb = async (
|
|
234
|
-
pdf: Buffer | Uint8Array,
|
|
235
|
-
pdfFilename = 'rcb.pdf',
|
|
236
|
-
apiKey?: string,
|
|
237
|
-
): Promise<IDetectRcbResponse> => {
|
|
238
|
-
const isBrowser = typeof window !== 'undefined' && typeof FormData !== 'undefined';
|
|
239
|
-
if (isBrowser) {
|
|
240
|
-
const form = new FormData();
|
|
241
|
-
const blob = new Blob([pdf as Uint8Array], { type: 'application/pdf' });
|
|
242
|
-
form.append('file', blob, pdfFilename);
|
|
243
|
-
return (
|
|
244
|
-
await AbyssToolsCore.axios.post<IDetectRcbResponse>(`rcb/detect`, form, {
|
|
245
|
-
headers: authHeader(apiKey),
|
|
246
|
-
maxBodyLength: Infinity,
|
|
247
|
-
maxContentLength: Infinity,
|
|
248
|
-
})
|
|
249
|
-
).data;
|
|
250
|
-
}
|
|
251
|
-
const FormDataCtor = await loadFormData();
|
|
252
|
-
const form = new FormDataCtor();
|
|
253
|
-
const buf = Buffer.isBuffer(pdf) ? pdf : Buffer.from(pdf);
|
|
254
|
-
form.append('file', buf, { filename: pdfFilename, contentType: 'application/pdf' });
|
|
255
|
-
return (
|
|
256
|
-
await AbyssToolsCore.axios.post<IDetectRcbResponse>(`rcb/detect`, form, {
|
|
257
|
-
headers: {
|
|
258
|
-
...(typeof form.getHeaders === 'function' ? form.getHeaders() : {}),
|
|
259
|
-
...authHeader(apiKey),
|
|
260
|
-
},
|
|
261
|
-
maxBodyLength: Infinity,
|
|
262
|
-
maxContentLength: Infinity,
|
|
263
|
-
})
|
|
264
|
-
).data;
|
|
265
|
-
};
|
|
266
|
-
|
|
267
|
-
export const detectBulkRcb = async (
|
|
268
|
-
body: IDetectBulkRcbBody,
|
|
269
|
-
apiKey?: string,
|
|
270
|
-
): Promise<IDetectBulkRcbResponse> => {
|
|
271
|
-
return (
|
|
272
|
-
await AbyssToolsCore.axios.post<IDetectBulkRcbResponse>(`rcb/detect/bulk`, body, {
|
|
273
|
-
headers: authHeader(apiKey),
|
|
274
|
-
})
|
|
275
|
-
).data;
|
|
276
|
-
};
|
|
277
|
-
|
|
278
|
-
// ─── FILES ───────────────────────────────────
|
|
279
|
-
|
|
280
|
-
export const listFilesRcb = async (
|
|
281
|
-
query: IListFilesRcbQuery = {},
|
|
282
|
-
apiKey?: string,
|
|
283
|
-
): Promise<IListFilesRcbResponse> => {
|
|
284
|
-
return (
|
|
285
|
-
await AbyssToolsCore.axios.get<IListFilesRcbResponse>(`rcb/files`, {
|
|
286
|
-
params: serializeParams(query),
|
|
287
|
-
headers: authHeader(apiKey),
|
|
288
|
-
})
|
|
289
|
-
).data;
|
|
290
|
-
};
|
|
291
|
-
|
|
292
|
-
export const getFileRcb = async (fileId: string, apiKey?: string): Promise<IGetFileRcbResponse> => {
|
|
293
|
-
return (
|
|
294
|
-
await AbyssToolsCore.axios.get<IGetFileRcbResponse>(`rcb/files/${fileId}`, {
|
|
295
|
-
headers: authHeader(apiKey),
|
|
296
|
-
})
|
|
297
|
-
).data;
|
|
298
|
-
};
|
|
299
|
-
|
|
300
|
-
export const listFileExtractionsRcb = async (
|
|
301
|
-
fileId: string,
|
|
302
|
-
query: { limit?: number; offset?: number } = {},
|
|
303
|
-
apiKey?: string,
|
|
304
|
-
): Promise<IListFileExtractionsRcbResponse> => {
|
|
305
|
-
return (
|
|
306
|
-
await AbyssToolsCore.axios.get<IListFileExtractionsRcbResponse>(
|
|
307
|
-
`rcb/files/${fileId}/extractions`,
|
|
308
|
-
{ params: serializeParams(query), headers: authHeader(apiKey) },
|
|
309
|
-
)
|
|
310
|
-
).data;
|
|
311
|
-
};
|
|
312
|
-
|
|
313
|
-
export const patchFileRcb = async (
|
|
314
|
-
fileId: string,
|
|
315
|
-
body: IPatchFileRcbBody,
|
|
316
|
-
apiKey?: string,
|
|
317
|
-
): Promise<IGetFileRcbResponse> => {
|
|
318
|
-
return (
|
|
319
|
-
await AbyssToolsCore.axios.patch<IGetFileRcbResponse>(`rcb/files/${fileId}`, body, {
|
|
320
|
-
headers: authHeader(apiKey),
|
|
321
|
-
})
|
|
322
|
-
).data;
|
|
323
|
-
};
|
|
324
|
-
|
|
325
|
-
export const downloadFileBundleRcb = async (
|
|
326
|
-
fileId: string,
|
|
327
|
-
query: { format?: 'csv' | 'json' } = {},
|
|
328
|
-
apiKey?: string,
|
|
329
|
-
): Promise<Buffer> => {
|
|
330
|
-
const res = await AbyssToolsCore.axios.get(`rcb/files/${fileId}/bundle`, {
|
|
331
|
-
params: serializeParams(query),
|
|
332
|
-
responseType: 'arraybuffer',
|
|
333
|
-
headers: authHeader(apiKey),
|
|
334
|
-
});
|
|
335
|
-
return Buffer.from(res.data as ArrayBuffer);
|
|
336
|
-
};
|
|
337
|
-
|
|
338
|
-
// ─── EXTRACTIONS ─────────────────────────────
|
|
339
|
-
|
|
340
|
-
export const getExtractionRcb = async (
|
|
341
|
-
extractionId: string,
|
|
342
|
-
apiKey?: string,
|
|
343
|
-
): Promise<IGetExtractionRcbResponse> => {
|
|
344
|
-
return (
|
|
345
|
-
await AbyssToolsCore.axios.get<IGetExtractionRcbResponse>(`rcb/extractions/${extractionId}`, {
|
|
346
|
-
headers: authHeader(apiKey),
|
|
347
|
-
})
|
|
348
|
-
).data;
|
|
349
|
-
};
|
|
350
|
-
|
|
351
|
-
export const patchExtractionRcb = async (
|
|
352
|
-
extractionId: string,
|
|
353
|
-
body: IPatchExtractionRcbBody,
|
|
354
|
-
apiKey?: string,
|
|
355
|
-
): Promise<IGetExtractionRcbResponse> => {
|
|
356
|
-
return (
|
|
357
|
-
await AbyssToolsCore.axios.patch<IGetExtractionRcbResponse>(
|
|
358
|
-
`rcb/extractions/${extractionId}`,
|
|
359
|
-
body,
|
|
360
|
-
{ headers: authHeader(apiKey) },
|
|
361
|
-
)
|
|
362
|
-
).data;
|
|
363
|
-
};
|
|
364
|
-
|
|
365
|
-
export const searchExtractionRecordsRcb = async (
|
|
366
|
-
extractionId: string,
|
|
367
|
-
query: ISearchExtractionRecordsRcbQuery = {},
|
|
368
|
-
apiKey?: string,
|
|
369
|
-
): Promise<ISearchExtractionRecordsRcbResponse> => {
|
|
370
|
-
return (
|
|
371
|
-
await AbyssToolsCore.axios.get<ISearchExtractionRecordsRcbResponse>(
|
|
372
|
-
`rcb/extractions/${extractionId}/records`,
|
|
373
|
-
{ params: serializeParams(query), headers: authHeader(apiKey) },
|
|
374
|
-
)
|
|
375
|
-
).data;
|
|
376
|
-
};
|
|
377
|
-
|
|
378
|
-
export const exportExtractionRcb = async (
|
|
379
|
-
extractionId: string,
|
|
380
|
-
query: IExportExtractionRcbQuery,
|
|
381
|
-
apiKey?: string,
|
|
382
|
-
): Promise<{ body: string; contentType: string }> => {
|
|
383
|
-
const res = await AbyssToolsCore.axios.get(`rcb/extractions/${extractionId}/export`, {
|
|
384
|
-
params: serializeParams(query),
|
|
385
|
-
responseType: 'text',
|
|
386
|
-
transformResponse: (d) => d,
|
|
387
|
-
headers: authHeader(apiKey),
|
|
388
|
-
});
|
|
389
|
-
return {
|
|
390
|
-
body: typeof res.data === 'string' ? res.data : String(res.data),
|
|
391
|
-
contentType: String(res.headers?.['content-type'] ?? 'application/octet-stream'),
|
|
392
|
-
};
|
|
393
|
-
};
|
|
394
|
-
|
|
395
|
-
export const asyncExportExtractionRcb = async (
|
|
396
|
-
extractionId: string,
|
|
397
|
-
body: IAsyncExportExtractionRcbBody,
|
|
398
|
-
apiKey?: string,
|
|
399
|
-
): Promise<IAsyncExportRcbResponse> => {
|
|
400
|
-
return (
|
|
401
|
-
await AbyssToolsCore.axios.post<IAsyncExportRcbResponse>(
|
|
402
|
-
`rcb/extractions/${extractionId}/export/async`,
|
|
403
|
-
body,
|
|
404
|
-
{ headers: authHeader(apiKey) },
|
|
405
|
-
)
|
|
406
|
-
).data;
|
|
407
|
-
};
|
|
408
|
-
|
|
409
|
-
export const getExportJobRcb = async (
|
|
410
|
-
jobId: string,
|
|
411
|
-
apiKey?: string,
|
|
412
|
-
): Promise<IGetExportJobRcbResponse> => {
|
|
413
|
-
return (
|
|
414
|
-
await AbyssToolsCore.axios.get<IGetExportJobRcbResponse>(`rcb/exports/jobs/${jobId}`, {
|
|
415
|
-
headers: authHeader(apiKey),
|
|
416
|
-
})
|
|
417
|
-
).data;
|
|
418
|
-
};
|
|
419
|
-
|
|
420
|
-
export const diffExtractionsRcb = async (
|
|
421
|
-
extractionId: string,
|
|
422
|
-
otherId: string,
|
|
423
|
-
apiKey?: string,
|
|
424
|
-
): Promise<IDiffExtractionsRcbResponse> => {
|
|
425
|
-
return (
|
|
426
|
-
await AbyssToolsCore.axios.get<IDiffExtractionsRcbResponse>(
|
|
427
|
-
`rcb/extractions/${extractionId}/diff/${otherId}`,
|
|
428
|
-
{ headers: authHeader(apiKey) },
|
|
429
|
-
)
|
|
430
|
-
).data;
|
|
431
|
-
};
|
|
432
|
-
|
|
433
|
-
// ─── TEMPLATES ───────────────────────────────
|
|
434
|
-
|
|
435
|
-
export const listTemplatesRcb = async (apiKey?: string): Promise<IListTemplatesRcbResponse> => {
|
|
436
|
-
return (
|
|
437
|
-
await AbyssToolsCore.axios.get<IListTemplatesRcbResponse>(`rcb/templates`, {
|
|
438
|
-
headers: authHeader(apiKey),
|
|
439
|
-
})
|
|
440
|
-
).data;
|
|
441
|
-
};
|
|
442
|
-
|
|
443
|
-
export const createTemplateRcb = async (
|
|
444
|
-
body: ICreateTemplateRcbBody,
|
|
445
|
-
apiKey?: string,
|
|
446
|
-
): Promise<ICreateTemplateRcbResponse> => {
|
|
447
|
-
return (
|
|
448
|
-
await AbyssToolsCore.axios.post<ICreateTemplateRcbResponse>(`rcb/templates`, body, {
|
|
449
|
-
headers: authHeader(apiKey),
|
|
450
|
-
})
|
|
451
|
-
).data;
|
|
452
|
-
};
|
|
453
|
-
|
|
454
|
-
export const getTemplateRcb = async (
|
|
455
|
-
templateId: string,
|
|
456
|
-
apiKey?: string,
|
|
457
|
-
): Promise<IGetTemplateRcbResponse> => {
|
|
458
|
-
return (
|
|
459
|
-
await AbyssToolsCore.axios.get<IGetTemplateRcbResponse>(`rcb/templates/${templateId}`, {
|
|
460
|
-
headers: authHeader(apiKey),
|
|
461
|
-
})
|
|
462
|
-
).data;
|
|
463
|
-
};
|
|
464
|
-
|
|
465
|
-
export const updateTemplateRcb = async (
|
|
466
|
-
templateId: string,
|
|
467
|
-
body: IUpdateTemplateRcbBody,
|
|
468
|
-
apiKey?: string,
|
|
469
|
-
): Promise<IUpdateTemplateRcbResponse> => {
|
|
470
|
-
return (
|
|
471
|
-
await AbyssToolsCore.axios.put<IUpdateTemplateRcbResponse>(
|
|
472
|
-
`rcb/templates/${templateId}`,
|
|
473
|
-
body,
|
|
474
|
-
{ headers: authHeader(apiKey) },
|
|
475
|
-
)
|
|
476
|
-
).data;
|
|
477
|
-
};
|
|
478
|
-
|
|
479
|
-
export const patchTemplateMetaRcb = async (
|
|
480
|
-
templateId: string,
|
|
481
|
-
body: IPatchTemplateMetaRcbBody,
|
|
482
|
-
apiKey?: string,
|
|
483
|
-
): Promise<void> => {
|
|
484
|
-
await AbyssToolsCore.axios.patch(`rcb/templates/${templateId}/meta`, body, {
|
|
485
|
-
headers: authHeader(apiKey),
|
|
486
|
-
});
|
|
487
|
-
};
|
|
488
|
-
|
|
489
|
-
export const deleteTemplateRcb = async (templateId: string, apiKey?: string): Promise<void> => {
|
|
490
|
-
await AbyssToolsCore.axios.delete(`rcb/templates/${templateId}`, {
|
|
491
|
-
headers: authHeader(apiKey),
|
|
492
|
-
});
|
|
493
|
-
};
|
|
494
|
-
|
|
495
|
-
export const listTemplateVersionsRcb = async (
|
|
496
|
-
templateId: string,
|
|
497
|
-
apiKey?: string,
|
|
498
|
-
): Promise<IListTemplateVersionsRcbResponse> => {
|
|
499
|
-
return (
|
|
500
|
-
await AbyssToolsCore.axios.get<IListTemplateVersionsRcbResponse>(
|
|
501
|
-
`rcb/templates/${templateId}/versions`,
|
|
502
|
-
{ headers: authHeader(apiKey) },
|
|
503
|
-
)
|
|
504
|
-
).data;
|
|
505
|
-
};
|
|
506
|
-
|
|
507
|
-
export const exportTemplateCollectionRcb = async (
|
|
508
|
-
ids: string[] | null,
|
|
509
|
-
apiKey?: string,
|
|
510
|
-
): Promise<IRcbTemplateCollection> => {
|
|
511
|
-
const res = await AbyssToolsCore.axios.get<IRcbTemplateCollection>(`rcb/templates/export`, {
|
|
512
|
-
params: ids && ids.length ? { ids: ids.join(',') } : {},
|
|
513
|
-
headers: authHeader(apiKey),
|
|
514
|
-
responseType: 'json',
|
|
515
|
-
});
|
|
516
|
-
return res.data;
|
|
517
|
-
};
|
|
518
|
-
|
|
519
|
-
export const importTemplateCollectionRcb = async (
|
|
520
|
-
doc: IRcbTemplateCollection,
|
|
521
|
-
apiKey?: string,
|
|
522
|
-
): Promise<IImportTemplateCollectionRcbResponse> => {
|
|
523
|
-
return (
|
|
524
|
-
await AbyssToolsCore.axios.post<IImportTemplateCollectionRcbResponse>(
|
|
525
|
-
`rcb/templates/import`,
|
|
526
|
-
doc,
|
|
527
|
-
{ headers: authHeader(apiKey) },
|
|
528
|
-
)
|
|
529
|
-
).data;
|
|
530
|
-
};
|
|
531
|
-
|
|
532
|
-
// ─── JOBS ────────────────────────────────────
|
|
533
|
-
|
|
534
|
-
export const getJobRcb = async (jobId: string, apiKey?: string): Promise<IGetJobRcbResponse> => {
|
|
535
|
-
return (
|
|
536
|
-
await AbyssToolsCore.axios.get<IGetJobRcbResponse>(`rcb/jobs/${jobId}`, {
|
|
537
|
-
headers: authHeader(apiKey),
|
|
538
|
-
})
|
|
539
|
-
).data;
|
|
540
|
-
};
|
|
541
|
-
|
|
542
|
-
export const retryJobRcb = async (jobId: string, apiKey?: string): Promise<void> => {
|
|
543
|
-
await AbyssToolsCore.axios.post(`rcb/jobs/${jobId}/retry`, undefined, {
|
|
544
|
-
headers: authHeader(apiKey),
|
|
545
|
-
});
|
|
546
|
-
};
|
|
547
|
-
|
|
548
|
-
export const cancelJobRcb = async (jobId: string, apiKey?: string): Promise<void> => {
|
|
549
|
-
await AbyssToolsCore.axios.delete(`rcb/jobs/${jobId}`, { headers: authHeader(apiKey) });
|
|
550
|
-
};
|
|
551
|
-
|
|
552
|
-
// ─── FEEDBACK ────────────────────────────────
|
|
553
|
-
|
|
554
|
-
export const submitFeedbackRcb = async (
|
|
555
|
-
body: ICreateFeedbackRcbBody,
|
|
556
|
-
apiKey?: string,
|
|
557
|
-
): Promise<ICreateFeedbackRcbResponse> => {
|
|
558
|
-
return (
|
|
559
|
-
await AbyssToolsCore.axios.post<ICreateFeedbackRcbResponse>(`rcb/feedback`, body, {
|
|
560
|
-
headers: authHeader(apiKey),
|
|
561
|
-
})
|
|
562
|
-
).data;
|
|
563
|
-
};
|
|
564
|
-
|
|
565
|
-
export const listFeedbackRcb = async (
|
|
566
|
-
query: IListFeedbackRcbQuery = {},
|
|
567
|
-
apiKey?: string,
|
|
568
|
-
): Promise<IListFeedbackRcbResponse> => {
|
|
569
|
-
return (
|
|
570
|
-
await AbyssToolsCore.axios.get<IListFeedbackRcbResponse>(`rcb/feedback`, {
|
|
571
|
-
params: serializeParams(query),
|
|
572
|
-
headers: authHeader(apiKey),
|
|
573
|
-
})
|
|
574
|
-
).data;
|
|
575
|
-
};
|
|
576
|
-
|
|
577
|
-
export const getFeedbackRcb = async (
|
|
578
|
-
feedbackId: string,
|
|
579
|
-
apiKey?: string,
|
|
580
|
-
): Promise<IGetFeedbackRcbResponse> => {
|
|
581
|
-
return (
|
|
582
|
-
await AbyssToolsCore.axios.get<IGetFeedbackRcbResponse>(`rcb/feedback/${feedbackId}`, {
|
|
583
|
-
headers: authHeader(apiKey),
|
|
584
|
-
})
|
|
585
|
-
).data;
|
|
586
|
-
};
|
|
587
|
-
|
|
588
|
-
export const patchFeedbackRcb = async (
|
|
589
|
-
feedbackId: string,
|
|
590
|
-
body: IPatchFeedbackRcbBody,
|
|
591
|
-
apiKey?: string,
|
|
592
|
-
): Promise<IGetFeedbackRcbResponse> => {
|
|
593
|
-
return (
|
|
594
|
-
await AbyssToolsCore.axios.patch<IGetFeedbackRcbResponse>(`rcb/feedback/${feedbackId}`, body, {
|
|
595
|
-
headers: authHeader(apiKey),
|
|
596
|
-
})
|
|
597
|
-
).data;
|
|
598
|
-
};
|
|
599
|
-
|
|
600
|
-
// ─── HEALTH / STATS / USAGE / QUOTA ─────────
|
|
601
|
-
|
|
602
|
-
export const healthRcb = async (apiKey?: string): Promise<IHealthRcbResponse> => {
|
|
603
|
-
return (
|
|
604
|
-
await AbyssToolsCore.axios.get<IHealthRcbResponse>(`rcb/health`, {
|
|
605
|
-
headers: authHeader(apiKey),
|
|
606
|
-
})
|
|
607
|
-
).data;
|
|
608
|
-
};
|
|
609
|
-
|
|
610
|
-
export const statsRcb = async (apiKey?: string): Promise<IStatsRcbResponse> => {
|
|
611
|
-
return (
|
|
612
|
-
await AbyssToolsCore.axios.get<IStatsRcbResponse>(`rcb/stats`, {
|
|
613
|
-
headers: authHeader(apiKey),
|
|
614
|
-
})
|
|
615
|
-
).data;
|
|
616
|
-
};
|
|
617
|
-
|
|
618
|
-
export const listUsageRcb = async (
|
|
619
|
-
query: IListUsageRcbQuery = {},
|
|
620
|
-
apiKey?: string,
|
|
621
|
-
): Promise<{ data: unknown[]; total?: number }> => {
|
|
622
|
-
return (
|
|
623
|
-
await AbyssToolsCore.axios.get<{ data: unknown[]; total?: number }>(`rcb/usage`, {
|
|
624
|
-
params: serializeParams(query),
|
|
625
|
-
headers: authHeader(apiKey),
|
|
626
|
-
})
|
|
627
|
-
).data;
|
|
628
|
-
};
|
|
629
|
-
|
|
630
|
-
export const summaryUsageRcb = async (
|
|
631
|
-
query: ISummaryUsageRcbQuery = {},
|
|
632
|
-
apiKey?: string,
|
|
633
|
-
): Promise<ISummaryUsageRcbResponse> => {
|
|
634
|
-
return (
|
|
635
|
-
await AbyssToolsCore.axios.get<ISummaryUsageRcbResponse>(`rcb/usage/summary`, {
|
|
636
|
-
params: serializeParams(query),
|
|
637
|
-
headers: authHeader(apiKey),
|
|
638
|
-
})
|
|
639
|
-
).data;
|
|
640
|
-
};
|
|
641
|
-
|
|
642
|
-
export const getQuotaRcb = async (apiKey?: string): Promise<IGetQuotaRcbResponse> => {
|
|
643
|
-
return (
|
|
644
|
-
await AbyssToolsCore.axios.get<IGetQuotaRcbResponse>(`rcb/quota`, {
|
|
645
|
-
headers: authHeader(apiKey),
|
|
646
|
-
})
|
|
647
|
-
).data;
|
|
648
|
-
};
|
|
649
|
-
|
|
650
|
-
// ─── SHARED FILES (content_share-backed) ────
|
|
651
|
-
//
|
|
652
|
-
// Types live in `../types/interface/api/requests/rcb.request.ts` so they
|
|
653
|
-
// stay alongside every other RCB SDK contract.
|
|
654
|
-
|
|
655
|
-
export const listSharedFilesRcb = async (
|
|
656
|
-
query: IListSharedFilesRcbQuery = {},
|
|
657
|
-
apiKey?: string,
|
|
658
|
-
): Promise<IListFilesRcbResponse> =>
|
|
659
|
-
(
|
|
660
|
-
await AbyssToolsCore.axios.get<IListFilesRcbResponse>(`rcb/files/shared`, {
|
|
661
|
-
params: serializeParams(query),
|
|
662
|
-
headers: authHeader(apiKey),
|
|
663
|
-
})
|
|
664
|
-
).data;
|
|
665
|
-
|
|
666
|
-
// ─── WEBHOOK DELIVERIES ─────────────────────
|
|
667
|
-
|
|
668
|
-
export const listWebhookDeliveriesRcb = async (
|
|
669
|
-
query: IListWebhookDeliveriesRcbQuery = {},
|
|
670
|
-
apiKey?: string,
|
|
671
|
-
): Promise<IListWebhookDeliveriesRcbResponse> => {
|
|
672
|
-
return (
|
|
673
|
-
await AbyssToolsCore.axios.get<IListWebhookDeliveriesRcbResponse>(`rcb/webhooks/deliveries`, {
|
|
674
|
-
params: serializeParams(query),
|
|
675
|
-
headers: authHeader(apiKey),
|
|
676
|
-
})
|
|
677
|
-
).data;
|
|
678
|
-
};
|
|
679
|
-
|
|
680
|
-
export const getWebhookDeliveryRcb = async (
|
|
681
|
-
deliveryId: string,
|
|
682
|
-
apiKey?: string,
|
|
683
|
-
): Promise<IGetWebhookDeliveryRcbResponse> => {
|
|
684
|
-
return (
|
|
685
|
-
await AbyssToolsCore.axios.get<IGetWebhookDeliveryRcbResponse>(
|
|
686
|
-
`rcb/webhooks/deliveries/${deliveryId}`,
|
|
687
|
-
{ headers: authHeader(apiKey) },
|
|
688
|
-
)
|
|
689
|
-
).data;
|
|
690
|
-
};
|
|
691
|
-
|
|
692
|
-
export const replayWebhookDeliveryRcb = async (
|
|
693
|
-
deliveryId: string,
|
|
694
|
-
body: IReplayWebhookDeliveryRcbBody = {},
|
|
695
|
-
apiKey?: string,
|
|
696
|
-
): Promise<IGetWebhookDeliveryRcbResponse> => {
|
|
697
|
-
return (
|
|
698
|
-
await AbyssToolsCore.axios.post<IGetWebhookDeliveryRcbResponse>(
|
|
699
|
-
`rcb/webhooks/deliveries/${deliveryId}/replay`,
|
|
700
|
-
body,
|
|
701
|
-
{ headers: authHeader(apiKey) },
|
|
702
|
-
)
|
|
703
|
-
).data;
|
|
704
|
-
};
|
|
705
|
-
|
|
706
|
-
// ─── WEBHOOK SUBSCRIPTIONS (CRUD) ───────────
|
|
707
|
-
//
|
|
708
|
-
// Request / response types are defined alongside every other RCB SDK
|
|
709
|
-
// contract — see ../types/interface/api/{requests,responses}/rcb.*.ts.
|
|
710
|
-
|
|
711
|
-
export const paginateRcbWebhook = async (
|
|
712
|
-
query: IPaginateRcbWebhookQuery = {},
|
|
713
|
-
apiKey?: string,
|
|
714
|
-
): Promise<IPaginateRcbWebhookResponse> =>
|
|
715
|
-
(
|
|
716
|
-
await AbyssToolsCore.axios.get<IPaginateRcbWebhookResponse>(`rcb/webhook`, {
|
|
717
|
-
params: serializeParams(query),
|
|
718
|
-
headers: authHeader(apiKey),
|
|
719
|
-
})
|
|
720
|
-
).data;
|
|
721
|
-
|
|
722
|
-
export const getRcbWebhook = async (
|
|
723
|
-
webhookId: string,
|
|
724
|
-
scope: IRcbWebhookScopeQuery = {},
|
|
725
|
-
apiKey?: string,
|
|
726
|
-
): Promise<IGetRcbWebhookResponse> =>
|
|
727
|
-
(
|
|
728
|
-
await AbyssToolsCore.axios.get<IGetRcbWebhookResponse>(
|
|
729
|
-
`rcb/webhook/${webhookId}`,
|
|
730
|
-
{ params: serializeParams(scope), headers: authHeader(apiKey) },
|
|
731
|
-
)
|
|
732
|
-
).data;
|
|
733
|
-
|
|
734
|
-
export const createRcbWebhook = async (
|
|
735
|
-
body: ICreateRcbWebhookBody,
|
|
736
|
-
scope: IRcbWebhookScopeQuery = {},
|
|
737
|
-
apiKey?: string,
|
|
738
|
-
): Promise<ICreateRcbWebhookResponse> =>
|
|
739
|
-
(
|
|
740
|
-
await AbyssToolsCore.axios.post<ICreateRcbWebhookResponse>(
|
|
741
|
-
`rcb/webhook`,
|
|
742
|
-
body,
|
|
743
|
-
{ params: serializeParams(scope), headers: authHeader(apiKey) },
|
|
744
|
-
)
|
|
745
|
-
).data;
|
|
746
|
-
|
|
747
|
-
export const updateRcbWebhook = async (
|
|
748
|
-
webhookId: string,
|
|
749
|
-
body: IUpdateRcbWebhookBody,
|
|
750
|
-
scope: IRcbWebhookScopeQuery = {},
|
|
751
|
-
apiKey?: string,
|
|
752
|
-
): Promise<IUpdateRcbWebhookResponse> =>
|
|
753
|
-
(
|
|
754
|
-
await AbyssToolsCore.axios.put<IUpdateRcbWebhookResponse>(
|
|
755
|
-
`rcb/webhook/${webhookId}`,
|
|
756
|
-
body,
|
|
757
|
-
{ params: serializeParams(scope), headers: authHeader(apiKey) },
|
|
758
|
-
)
|
|
759
|
-
).data;
|
|
760
|
-
|
|
761
|
-
export const deleteRcbWebhook = async (
|
|
762
|
-
webhookId: string,
|
|
763
|
-
scope: IRcbWebhookScopeQuery = {},
|
|
764
|
-
apiKey?: string,
|
|
765
|
-
): Promise<IDeleteRcbWebhookResponse> =>
|
|
766
|
-
(
|
|
767
|
-
await AbyssToolsCore.axios.delete<IDeleteRcbWebhookResponse>(
|
|
768
|
-
`rcb/webhook/${webhookId}`,
|
|
769
|
-
{ params: serializeParams(scope), headers: authHeader(apiKey) },
|
|
770
|
-
)
|
|
771
|
-
).data;
|
|
772
|
-
|
|
773
|
-
export const resetSecretRcbWebhook = async (
|
|
774
|
-
webhookId: string,
|
|
775
|
-
scope: IRcbWebhookScopeQuery = {},
|
|
776
|
-
apiKey?: string,
|
|
777
|
-
): Promise<IResetSecretRcbWebhookResponse> =>
|
|
778
|
-
(
|
|
779
|
-
await AbyssToolsCore.axios.post<IResetSecretRcbWebhookResponse>(
|
|
780
|
-
`rcb/webhook/${webhookId}/reset-secret`,
|
|
781
|
-
undefined,
|
|
782
|
-
{ params: serializeParams(scope), headers: authHeader(apiKey) },
|
|
783
|
-
)
|
|
784
|
-
).data;
|
|
785
|
-
|
|
786
|
-
// ─── SHARE ───────────────────────────────────
|
|
787
|
-
|
|
788
|
-
export const mintShareExtractionRcb = async (
|
|
789
|
-
extractionId: string,
|
|
790
|
-
body: IMintShareExtractionRcbBody = {},
|
|
791
|
-
apiKey?: string,
|
|
792
|
-
): Promise<IMintShareExtractionRcbResponse> => {
|
|
793
|
-
return (
|
|
794
|
-
await AbyssToolsCore.axios.post<IMintShareExtractionRcbResponse>(
|
|
795
|
-
`rcb/share/owner/extractions/${extractionId}`,
|
|
796
|
-
body,
|
|
797
|
-
{ headers: authHeader(apiKey) },
|
|
798
|
-
)
|
|
799
|
-
).data;
|
|
800
|
-
};
|
|
801
|
-
|
|
802
|
-
export const revokeShareExtractionRcb = async (
|
|
803
|
-
extractionId: string,
|
|
804
|
-
apiKey?: string,
|
|
805
|
-
): Promise<void> => {
|
|
806
|
-
await AbyssToolsCore.axios.delete(`rcb/share/owner/extractions/${extractionId}`, {
|
|
807
|
-
headers: authHeader(apiKey),
|
|
808
|
-
});
|
|
809
|
-
};
|
|
810
|
-
|
|
811
|
-
export const getSharedExtractionRcbPublic = async (
|
|
812
|
-
token: string,
|
|
813
|
-
): Promise<IGetSharedExtractionRcbResponse> => {
|
|
814
|
-
return (
|
|
815
|
-
await AbyssToolsCore.axios.get<IGetSharedExtractionRcbResponse>(
|
|
816
|
-
`rcb/share/extractions/${token}`,
|
|
817
|
-
)
|
|
818
|
-
).data;
|
|
819
|
-
};
|
|
820
|
-
|
|
821
|
-
// ─── CHANGELOG ──────────────────────────────
|
|
822
|
-
|
|
823
|
-
export const changelogRcb = async (apiKey?: string): Promise<IChangelogRcbResponse> => {
|
|
824
|
-
return (
|
|
825
|
-
await AbyssToolsCore.axios.get<IChangelogRcbResponse>(`rcb/changelog`, {
|
|
826
|
-
headers: authHeader(apiKey),
|
|
827
|
-
})
|
|
828
|
-
).data;
|
|
829
|
-
};
|
|
1
|
+
// ──────────────────────────────────────────────
|
|
2
|
+
// RCB (bank statement extraction) — user-facing API.
|
|
3
|
+
//
|
|
4
|
+
// Sync helper accepts an inline PDF buffer (multipart) or a storage_file_id.
|
|
5
|
+
// Queue helper enqueues for async processing + webhook delivery.
|
|
6
|
+
// ──────────────────────────────────────────────
|
|
7
|
+
|
|
8
|
+
import { AbyssToolsCore } from '..';
|
|
9
|
+
import {
|
|
10
|
+
IExtractRcbBody,
|
|
11
|
+
IExtractBulkRcbBody,
|
|
12
|
+
IDetectBulkRcbBody,
|
|
13
|
+
IListFilesRcbQuery,
|
|
14
|
+
IPatchFileRcbBody,
|
|
15
|
+
IPatchExtractionRcbBody,
|
|
16
|
+
ISearchExtractionRecordsRcbQuery,
|
|
17
|
+
IExportExtractionRcbQuery,
|
|
18
|
+
IAsyncExportExtractionRcbBody,
|
|
19
|
+
IListUsageRcbQuery,
|
|
20
|
+
ISummaryUsageRcbQuery,
|
|
21
|
+
IListWebhookDeliveriesRcbQuery,
|
|
22
|
+
IReplayWebhookDeliveryRcbBody,
|
|
23
|
+
IMintShareExtractionRcbBody,
|
|
24
|
+
} from '../types';
|
|
25
|
+
import {
|
|
26
|
+
IExtractSyncRcbResponse,
|
|
27
|
+
IExtractQueueRcbResponse,
|
|
28
|
+
IExtractBulkRcbResponse,
|
|
29
|
+
IDetectRcbResponse,
|
|
30
|
+
IDetectBulkRcbResponse,
|
|
31
|
+
IListFilesRcbResponse,
|
|
32
|
+
IGetFileRcbResponse,
|
|
33
|
+
IListFileExtractionsRcbResponse,
|
|
34
|
+
IGetExtractionRcbResponse,
|
|
35
|
+
ISearchExtractionRecordsRcbResponse,
|
|
36
|
+
IDiffExtractionsRcbResponse,
|
|
37
|
+
IAsyncExportRcbResponse,
|
|
38
|
+
IGetExportJobRcbResponse,
|
|
39
|
+
ICreateTemplateRcbResponse,
|
|
40
|
+
IUpdateTemplateRcbResponse,
|
|
41
|
+
IListTemplatesRcbResponse,
|
|
42
|
+
IGetTemplateRcbResponse,
|
|
43
|
+
IListTemplateVersionsRcbResponse,
|
|
44
|
+
IRcbTemplateCollection,
|
|
45
|
+
IImportTemplateCollectionRcbResponse,
|
|
46
|
+
IGetJobRcbResponse,
|
|
47
|
+
ICreateFeedbackRcbResponse,
|
|
48
|
+
IListFeedbackRcbResponse,
|
|
49
|
+
IGetFeedbackRcbResponse,
|
|
50
|
+
IHealthRcbResponse,
|
|
51
|
+
IStatsRcbResponse,
|
|
52
|
+
ISummaryUsageRcbResponse,
|
|
53
|
+
IGetQuotaRcbResponse,
|
|
54
|
+
IListWebhookDeliveriesRcbResponse,
|
|
55
|
+
IGetWebhookDeliveryRcbResponse,
|
|
56
|
+
IGetSharedExtractionRcbResponse,
|
|
57
|
+
IMintShareExtractionRcbResponse,
|
|
58
|
+
IChangelogRcbResponse,
|
|
59
|
+
} from '../types';
|
|
60
|
+
import {
|
|
61
|
+
ICreateTemplateRcbBody,
|
|
62
|
+
IUpdateTemplateRcbBody,
|
|
63
|
+
IPatchTemplateMetaRcbBody,
|
|
64
|
+
ICreateFeedbackRcbBody,
|
|
65
|
+
IPatchFeedbackRcbBody,
|
|
66
|
+
IListFeedbackRcbQuery,
|
|
67
|
+
IListSharedFilesRcbQuery,
|
|
68
|
+
IPaginateRcbWebhookQuery,
|
|
69
|
+
ICreateRcbWebhookBody,
|
|
70
|
+
IUpdateRcbWebhookBody,
|
|
71
|
+
IRcbWebhookScopeQuery,
|
|
72
|
+
} from '../types';
|
|
73
|
+
import type {
|
|
74
|
+
IPaginateRcbWebhookResponse,
|
|
75
|
+
IGetRcbWebhookResponse,
|
|
76
|
+
ICreateRcbWebhookResponse,
|
|
77
|
+
IUpdateRcbWebhookResponse,
|
|
78
|
+
IDeleteRcbWebhookResponse,
|
|
79
|
+
IResetSecretRcbWebhookResponse,
|
|
80
|
+
} from '../types';
|
|
81
|
+
|
|
82
|
+
const DEFAULT_API_KEY_HEADER = 'x-api-key';
|
|
83
|
+
|
|
84
|
+
function authHeader(apiKey?: string): Record<string, string> {
|
|
85
|
+
return apiKey ? { [DEFAULT_API_KEY_HEADER]: apiKey } : {};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async function loadFormData(): Promise<any> {
|
|
89
|
+
if (typeof FormData !== 'undefined' && typeof window !== 'undefined') {
|
|
90
|
+
return FormData;
|
|
91
|
+
}
|
|
92
|
+
// Use indirect eval so bundlers (esbuild/vite/webpack) do not try to
|
|
93
|
+
// resolve the Node-only "form-data" package when this file is included
|
|
94
|
+
// in a browser bundle. The require only runs at runtime on Node.
|
|
95
|
+
// eslint-disable-next-line @typescript-eslint/no-implied-eval, no-new-func
|
|
96
|
+
const nodeRequire: NodeRequire = new Function('return require')();
|
|
97
|
+
return nodeRequire('form-data');
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function serializeParams<T extends object>(o: T): Record<string, unknown> {
|
|
101
|
+
const out: Record<string, unknown> = {};
|
|
102
|
+
for (const [k, v] of Object.entries(o as Record<string, unknown>)) {
|
|
103
|
+
if (v === undefined || v === null) continue;
|
|
104
|
+
out[k] = v instanceof Date ? v.toISOString() : v;
|
|
105
|
+
}
|
|
106
|
+
return out;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// ─── EXTRACT ─────────────────────────────────
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Optional per-call extras for extract endpoints. `idempotencyKey` is a
|
|
113
|
+
* Stripe-style replay key (24h window) sent as the `Idempotency-Key` header —
|
|
114
|
+
* not part of the request body.
|
|
115
|
+
*/
|
|
116
|
+
export interface ExtractCallOptions {
|
|
117
|
+
idempotencyKey?: string;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export const extractSyncRcb = async (
|
|
121
|
+
body: IExtractRcbBody,
|
|
122
|
+
apiKey?: string,
|
|
123
|
+
opts: ExtractCallOptions = {},
|
|
124
|
+
): Promise<IExtractSyncRcbResponse> => {
|
|
125
|
+
return postExtract(
|
|
126
|
+
{ ...body, processing: 'sync' },
|
|
127
|
+
apiKey,
|
|
128
|
+
opts,
|
|
129
|
+
) as Promise<IExtractSyncRcbResponse>;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export const extractQueueRcb = async (
|
|
133
|
+
body: IExtractRcbBody,
|
|
134
|
+
apiKey?: string,
|
|
135
|
+
opts: ExtractCallOptions = {},
|
|
136
|
+
): Promise<IExtractQueueRcbResponse> => {
|
|
137
|
+
return postExtract(
|
|
138
|
+
{ ...body, processing: 'queue' },
|
|
139
|
+
apiKey,
|
|
140
|
+
opts,
|
|
141
|
+
) as Promise<IExtractQueueRcbResponse>;
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const postExtract = async (
|
|
145
|
+
body: IExtractRcbBody,
|
|
146
|
+
apiKey?: string,
|
|
147
|
+
opts: ExtractCallOptions = {},
|
|
148
|
+
): Promise<unknown> => {
|
|
149
|
+
const extraHeaders: Record<string, string> = {};
|
|
150
|
+
if (opts.idempotencyKey) {
|
|
151
|
+
extraHeaders['Idempotency-Key'] = opts.idempotencyKey;
|
|
152
|
+
}
|
|
153
|
+
if (body.pdf) {
|
|
154
|
+
const isBrowser = typeof window !== 'undefined' && typeof FormData !== 'undefined';
|
|
155
|
+
const filename = body.pdf_filename ?? 'rcb.pdf';
|
|
156
|
+
if (isBrowser) {
|
|
157
|
+
const form = new FormData();
|
|
158
|
+
const blob = new Blob([body.pdf as Uint8Array], { type: 'application/pdf' });
|
|
159
|
+
form.append('file', blob, filename);
|
|
160
|
+
appendIf(form, 'mode', body.mode);
|
|
161
|
+
if (body.hint) form.append('hint', JSON.stringify(body.hint));
|
|
162
|
+
appendIf(form, 'template_id', body.template_id);
|
|
163
|
+
if (body.template) form.append('template', JSON.stringify(body.template));
|
|
164
|
+
appendIf(form, 'user_external_id', body.user_external_id);
|
|
165
|
+
if (body.user_metadata) form.append('user_metadata', JSON.stringify(body.user_metadata));
|
|
166
|
+
if (typeof body.archive === 'boolean') form.append('archive', String(body.archive));
|
|
167
|
+
if (typeof body.force === 'boolean') form.append('force', String(body.force));
|
|
168
|
+
if (body.processing) form.append('processing', body.processing);
|
|
169
|
+
return (
|
|
170
|
+
await AbyssToolsCore.axios.post(`rcb/extract`, form, {
|
|
171
|
+
headers: { ...authHeader(apiKey), ...extraHeaders },
|
|
172
|
+
maxBodyLength: Infinity,
|
|
173
|
+
maxContentLength: Infinity,
|
|
174
|
+
})
|
|
175
|
+
).data;
|
|
176
|
+
}
|
|
177
|
+
const FormDataCtor = await loadFormData();
|
|
178
|
+
const form = new FormDataCtor();
|
|
179
|
+
const buf = Buffer.isBuffer(body.pdf) ? body.pdf : Buffer.from(body.pdf);
|
|
180
|
+
form.append('file', buf, {
|
|
181
|
+
filename,
|
|
182
|
+
contentType: 'application/pdf',
|
|
183
|
+
});
|
|
184
|
+
appendIf(form, 'mode', body.mode);
|
|
185
|
+
if (body.hint) form.append('hint', JSON.stringify(body.hint));
|
|
186
|
+
appendIf(form, 'template_id', body.template_id);
|
|
187
|
+
if (body.template) form.append('template', JSON.stringify(body.template));
|
|
188
|
+
appendIf(form, 'user_external_id', body.user_external_id);
|
|
189
|
+
if (body.user_metadata) form.append('user_metadata', JSON.stringify(body.user_metadata));
|
|
190
|
+
if (typeof body.archive === 'boolean') form.append('archive', String(body.archive));
|
|
191
|
+
if (typeof body.force === 'boolean') form.append('force', String(body.force));
|
|
192
|
+
if (body.processing) form.append('processing', body.processing);
|
|
193
|
+
return (
|
|
194
|
+
await AbyssToolsCore.axios.post(`rcb/extract`, form, {
|
|
195
|
+
headers: {
|
|
196
|
+
...(typeof form.getHeaders === 'function' ? form.getHeaders() : {}),
|
|
197
|
+
...authHeader(apiKey),
|
|
198
|
+
...extraHeaders,
|
|
199
|
+
},
|
|
200
|
+
maxBodyLength: Infinity,
|
|
201
|
+
maxContentLength: Infinity,
|
|
202
|
+
})
|
|
203
|
+
).data;
|
|
204
|
+
}
|
|
205
|
+
// Strip `pdf` from the JSON body (only used for multipart upload above).
|
|
206
|
+
const jsonBody: Omit<IExtractRcbBody, 'pdf'> = { ...body };
|
|
207
|
+
delete (jsonBody as { pdf?: unknown }).pdf;
|
|
208
|
+
return (
|
|
209
|
+
await AbyssToolsCore.axios.post(`rcb/extract`, jsonBody, {
|
|
210
|
+
headers: { ...authHeader(apiKey), ...extraHeaders },
|
|
211
|
+
})
|
|
212
|
+
).data;
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
function appendIf(form: any, key: string, value: unknown): void {
|
|
216
|
+
if (value === undefined || value === null) return;
|
|
217
|
+
form.append(key, String(value));
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export const extractBulkRcb = async (
|
|
221
|
+
body: IExtractBulkRcbBody,
|
|
222
|
+
apiKey?: string,
|
|
223
|
+
): Promise<IExtractBulkRcbResponse> => {
|
|
224
|
+
return (
|
|
225
|
+
await AbyssToolsCore.axios.post<IExtractBulkRcbResponse>(`rcb/extract/bulk`, body, {
|
|
226
|
+
headers: authHeader(apiKey),
|
|
227
|
+
})
|
|
228
|
+
).data;
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
// ─── DETECT ──────────────────────────────────
|
|
232
|
+
|
|
233
|
+
export const detectRcb = async (
|
|
234
|
+
pdf: Buffer | Uint8Array,
|
|
235
|
+
pdfFilename = 'rcb.pdf',
|
|
236
|
+
apiKey?: string,
|
|
237
|
+
): Promise<IDetectRcbResponse> => {
|
|
238
|
+
const isBrowser = typeof window !== 'undefined' && typeof FormData !== 'undefined';
|
|
239
|
+
if (isBrowser) {
|
|
240
|
+
const form = new FormData();
|
|
241
|
+
const blob = new Blob([pdf as Uint8Array], { type: 'application/pdf' });
|
|
242
|
+
form.append('file', blob, pdfFilename);
|
|
243
|
+
return (
|
|
244
|
+
await AbyssToolsCore.axios.post<IDetectRcbResponse>(`rcb/detect`, form, {
|
|
245
|
+
headers: authHeader(apiKey),
|
|
246
|
+
maxBodyLength: Infinity,
|
|
247
|
+
maxContentLength: Infinity,
|
|
248
|
+
})
|
|
249
|
+
).data;
|
|
250
|
+
}
|
|
251
|
+
const FormDataCtor = await loadFormData();
|
|
252
|
+
const form = new FormDataCtor();
|
|
253
|
+
const buf = Buffer.isBuffer(pdf) ? pdf : Buffer.from(pdf);
|
|
254
|
+
form.append('file', buf, { filename: pdfFilename, contentType: 'application/pdf' });
|
|
255
|
+
return (
|
|
256
|
+
await AbyssToolsCore.axios.post<IDetectRcbResponse>(`rcb/detect`, form, {
|
|
257
|
+
headers: {
|
|
258
|
+
...(typeof form.getHeaders === 'function' ? form.getHeaders() : {}),
|
|
259
|
+
...authHeader(apiKey),
|
|
260
|
+
},
|
|
261
|
+
maxBodyLength: Infinity,
|
|
262
|
+
maxContentLength: Infinity,
|
|
263
|
+
})
|
|
264
|
+
).data;
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
export const detectBulkRcb = async (
|
|
268
|
+
body: IDetectBulkRcbBody,
|
|
269
|
+
apiKey?: string,
|
|
270
|
+
): Promise<IDetectBulkRcbResponse> => {
|
|
271
|
+
return (
|
|
272
|
+
await AbyssToolsCore.axios.post<IDetectBulkRcbResponse>(`rcb/detect/bulk`, body, {
|
|
273
|
+
headers: authHeader(apiKey),
|
|
274
|
+
})
|
|
275
|
+
).data;
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
// ─── FILES ───────────────────────────────────
|
|
279
|
+
|
|
280
|
+
export const listFilesRcb = async (
|
|
281
|
+
query: IListFilesRcbQuery = {},
|
|
282
|
+
apiKey?: string,
|
|
283
|
+
): Promise<IListFilesRcbResponse> => {
|
|
284
|
+
return (
|
|
285
|
+
await AbyssToolsCore.axios.get<IListFilesRcbResponse>(`rcb/files`, {
|
|
286
|
+
params: serializeParams(query),
|
|
287
|
+
headers: authHeader(apiKey),
|
|
288
|
+
})
|
|
289
|
+
).data;
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
export const getFileRcb = async (fileId: string, apiKey?: string): Promise<IGetFileRcbResponse> => {
|
|
293
|
+
return (
|
|
294
|
+
await AbyssToolsCore.axios.get<IGetFileRcbResponse>(`rcb/files/${fileId}`, {
|
|
295
|
+
headers: authHeader(apiKey),
|
|
296
|
+
})
|
|
297
|
+
).data;
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
export const listFileExtractionsRcb = async (
|
|
301
|
+
fileId: string,
|
|
302
|
+
query: { limit?: number; offset?: number } = {},
|
|
303
|
+
apiKey?: string,
|
|
304
|
+
): Promise<IListFileExtractionsRcbResponse> => {
|
|
305
|
+
return (
|
|
306
|
+
await AbyssToolsCore.axios.get<IListFileExtractionsRcbResponse>(
|
|
307
|
+
`rcb/files/${fileId}/extractions`,
|
|
308
|
+
{ params: serializeParams(query), headers: authHeader(apiKey) },
|
|
309
|
+
)
|
|
310
|
+
).data;
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
export const patchFileRcb = async (
|
|
314
|
+
fileId: string,
|
|
315
|
+
body: IPatchFileRcbBody,
|
|
316
|
+
apiKey?: string,
|
|
317
|
+
): Promise<IGetFileRcbResponse> => {
|
|
318
|
+
return (
|
|
319
|
+
await AbyssToolsCore.axios.patch<IGetFileRcbResponse>(`rcb/files/${fileId}`, body, {
|
|
320
|
+
headers: authHeader(apiKey),
|
|
321
|
+
})
|
|
322
|
+
).data;
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
export const downloadFileBundleRcb = async (
|
|
326
|
+
fileId: string,
|
|
327
|
+
query: { format?: 'csv' | 'json' } = {},
|
|
328
|
+
apiKey?: string,
|
|
329
|
+
): Promise<Buffer> => {
|
|
330
|
+
const res = await AbyssToolsCore.axios.get(`rcb/files/${fileId}/bundle`, {
|
|
331
|
+
params: serializeParams(query),
|
|
332
|
+
responseType: 'arraybuffer',
|
|
333
|
+
headers: authHeader(apiKey),
|
|
334
|
+
});
|
|
335
|
+
return Buffer.from(res.data as ArrayBuffer);
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
// ─── EXTRACTIONS ─────────────────────────────
|
|
339
|
+
|
|
340
|
+
export const getExtractionRcb = async (
|
|
341
|
+
extractionId: string,
|
|
342
|
+
apiKey?: string,
|
|
343
|
+
): Promise<IGetExtractionRcbResponse> => {
|
|
344
|
+
return (
|
|
345
|
+
await AbyssToolsCore.axios.get<IGetExtractionRcbResponse>(`rcb/extractions/${extractionId}`, {
|
|
346
|
+
headers: authHeader(apiKey),
|
|
347
|
+
})
|
|
348
|
+
).data;
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
export const patchExtractionRcb = async (
|
|
352
|
+
extractionId: string,
|
|
353
|
+
body: IPatchExtractionRcbBody,
|
|
354
|
+
apiKey?: string,
|
|
355
|
+
): Promise<IGetExtractionRcbResponse> => {
|
|
356
|
+
return (
|
|
357
|
+
await AbyssToolsCore.axios.patch<IGetExtractionRcbResponse>(
|
|
358
|
+
`rcb/extractions/${extractionId}`,
|
|
359
|
+
body,
|
|
360
|
+
{ headers: authHeader(apiKey) },
|
|
361
|
+
)
|
|
362
|
+
).data;
|
|
363
|
+
};
|
|
364
|
+
|
|
365
|
+
export const searchExtractionRecordsRcb = async (
|
|
366
|
+
extractionId: string,
|
|
367
|
+
query: ISearchExtractionRecordsRcbQuery = {},
|
|
368
|
+
apiKey?: string,
|
|
369
|
+
): Promise<ISearchExtractionRecordsRcbResponse> => {
|
|
370
|
+
return (
|
|
371
|
+
await AbyssToolsCore.axios.get<ISearchExtractionRecordsRcbResponse>(
|
|
372
|
+
`rcb/extractions/${extractionId}/records`,
|
|
373
|
+
{ params: serializeParams(query), headers: authHeader(apiKey) },
|
|
374
|
+
)
|
|
375
|
+
).data;
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
export const exportExtractionRcb = async (
|
|
379
|
+
extractionId: string,
|
|
380
|
+
query: IExportExtractionRcbQuery,
|
|
381
|
+
apiKey?: string,
|
|
382
|
+
): Promise<{ body: string; contentType: string }> => {
|
|
383
|
+
const res = await AbyssToolsCore.axios.get(`rcb/extractions/${extractionId}/export`, {
|
|
384
|
+
params: serializeParams(query),
|
|
385
|
+
responseType: 'text',
|
|
386
|
+
transformResponse: (d) => d,
|
|
387
|
+
headers: authHeader(apiKey),
|
|
388
|
+
});
|
|
389
|
+
return {
|
|
390
|
+
body: typeof res.data === 'string' ? res.data : String(res.data),
|
|
391
|
+
contentType: String(res.headers?.['content-type'] ?? 'application/octet-stream'),
|
|
392
|
+
};
|
|
393
|
+
};
|
|
394
|
+
|
|
395
|
+
export const asyncExportExtractionRcb = async (
|
|
396
|
+
extractionId: string,
|
|
397
|
+
body: IAsyncExportExtractionRcbBody,
|
|
398
|
+
apiKey?: string,
|
|
399
|
+
): Promise<IAsyncExportRcbResponse> => {
|
|
400
|
+
return (
|
|
401
|
+
await AbyssToolsCore.axios.post<IAsyncExportRcbResponse>(
|
|
402
|
+
`rcb/extractions/${extractionId}/export/async`,
|
|
403
|
+
body,
|
|
404
|
+
{ headers: authHeader(apiKey) },
|
|
405
|
+
)
|
|
406
|
+
).data;
|
|
407
|
+
};
|
|
408
|
+
|
|
409
|
+
export const getExportJobRcb = async (
|
|
410
|
+
jobId: string,
|
|
411
|
+
apiKey?: string,
|
|
412
|
+
): Promise<IGetExportJobRcbResponse> => {
|
|
413
|
+
return (
|
|
414
|
+
await AbyssToolsCore.axios.get<IGetExportJobRcbResponse>(`rcb/exports/jobs/${jobId}`, {
|
|
415
|
+
headers: authHeader(apiKey),
|
|
416
|
+
})
|
|
417
|
+
).data;
|
|
418
|
+
};
|
|
419
|
+
|
|
420
|
+
export const diffExtractionsRcb = async (
|
|
421
|
+
extractionId: string,
|
|
422
|
+
otherId: string,
|
|
423
|
+
apiKey?: string,
|
|
424
|
+
): Promise<IDiffExtractionsRcbResponse> => {
|
|
425
|
+
return (
|
|
426
|
+
await AbyssToolsCore.axios.get<IDiffExtractionsRcbResponse>(
|
|
427
|
+
`rcb/extractions/${extractionId}/diff/${otherId}`,
|
|
428
|
+
{ headers: authHeader(apiKey) },
|
|
429
|
+
)
|
|
430
|
+
).data;
|
|
431
|
+
};
|
|
432
|
+
|
|
433
|
+
// ─── TEMPLATES ───────────────────────────────
|
|
434
|
+
|
|
435
|
+
export const listTemplatesRcb = async (apiKey?: string): Promise<IListTemplatesRcbResponse> => {
|
|
436
|
+
return (
|
|
437
|
+
await AbyssToolsCore.axios.get<IListTemplatesRcbResponse>(`rcb/templates`, {
|
|
438
|
+
headers: authHeader(apiKey),
|
|
439
|
+
})
|
|
440
|
+
).data;
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
export const createTemplateRcb = async (
|
|
444
|
+
body: ICreateTemplateRcbBody,
|
|
445
|
+
apiKey?: string,
|
|
446
|
+
): Promise<ICreateTemplateRcbResponse> => {
|
|
447
|
+
return (
|
|
448
|
+
await AbyssToolsCore.axios.post<ICreateTemplateRcbResponse>(`rcb/templates`, body, {
|
|
449
|
+
headers: authHeader(apiKey),
|
|
450
|
+
})
|
|
451
|
+
).data;
|
|
452
|
+
};
|
|
453
|
+
|
|
454
|
+
export const getTemplateRcb = async (
|
|
455
|
+
templateId: string,
|
|
456
|
+
apiKey?: string,
|
|
457
|
+
): Promise<IGetTemplateRcbResponse> => {
|
|
458
|
+
return (
|
|
459
|
+
await AbyssToolsCore.axios.get<IGetTemplateRcbResponse>(`rcb/templates/${templateId}`, {
|
|
460
|
+
headers: authHeader(apiKey),
|
|
461
|
+
})
|
|
462
|
+
).data;
|
|
463
|
+
};
|
|
464
|
+
|
|
465
|
+
export const updateTemplateRcb = async (
|
|
466
|
+
templateId: string,
|
|
467
|
+
body: IUpdateTemplateRcbBody,
|
|
468
|
+
apiKey?: string,
|
|
469
|
+
): Promise<IUpdateTemplateRcbResponse> => {
|
|
470
|
+
return (
|
|
471
|
+
await AbyssToolsCore.axios.put<IUpdateTemplateRcbResponse>(
|
|
472
|
+
`rcb/templates/${templateId}`,
|
|
473
|
+
body,
|
|
474
|
+
{ headers: authHeader(apiKey) },
|
|
475
|
+
)
|
|
476
|
+
).data;
|
|
477
|
+
};
|
|
478
|
+
|
|
479
|
+
export const patchTemplateMetaRcb = async (
|
|
480
|
+
templateId: string,
|
|
481
|
+
body: IPatchTemplateMetaRcbBody,
|
|
482
|
+
apiKey?: string,
|
|
483
|
+
): Promise<void> => {
|
|
484
|
+
await AbyssToolsCore.axios.patch(`rcb/templates/${templateId}/meta`, body, {
|
|
485
|
+
headers: authHeader(apiKey),
|
|
486
|
+
});
|
|
487
|
+
};
|
|
488
|
+
|
|
489
|
+
export const deleteTemplateRcb = async (templateId: string, apiKey?: string): Promise<void> => {
|
|
490
|
+
await AbyssToolsCore.axios.delete(`rcb/templates/${templateId}`, {
|
|
491
|
+
headers: authHeader(apiKey),
|
|
492
|
+
});
|
|
493
|
+
};
|
|
494
|
+
|
|
495
|
+
export const listTemplateVersionsRcb = async (
|
|
496
|
+
templateId: string,
|
|
497
|
+
apiKey?: string,
|
|
498
|
+
): Promise<IListTemplateVersionsRcbResponse> => {
|
|
499
|
+
return (
|
|
500
|
+
await AbyssToolsCore.axios.get<IListTemplateVersionsRcbResponse>(
|
|
501
|
+
`rcb/templates/${templateId}/versions`,
|
|
502
|
+
{ headers: authHeader(apiKey) },
|
|
503
|
+
)
|
|
504
|
+
).data;
|
|
505
|
+
};
|
|
506
|
+
|
|
507
|
+
export const exportTemplateCollectionRcb = async (
|
|
508
|
+
ids: string[] | null,
|
|
509
|
+
apiKey?: string,
|
|
510
|
+
): Promise<IRcbTemplateCollection> => {
|
|
511
|
+
const res = await AbyssToolsCore.axios.get<IRcbTemplateCollection>(`rcb/templates/export`, {
|
|
512
|
+
params: ids && ids.length ? { ids: ids.join(',') } : {},
|
|
513
|
+
headers: authHeader(apiKey),
|
|
514
|
+
responseType: 'json',
|
|
515
|
+
});
|
|
516
|
+
return res.data;
|
|
517
|
+
};
|
|
518
|
+
|
|
519
|
+
export const importTemplateCollectionRcb = async (
|
|
520
|
+
doc: IRcbTemplateCollection,
|
|
521
|
+
apiKey?: string,
|
|
522
|
+
): Promise<IImportTemplateCollectionRcbResponse> => {
|
|
523
|
+
return (
|
|
524
|
+
await AbyssToolsCore.axios.post<IImportTemplateCollectionRcbResponse>(
|
|
525
|
+
`rcb/templates/import`,
|
|
526
|
+
doc,
|
|
527
|
+
{ headers: authHeader(apiKey) },
|
|
528
|
+
)
|
|
529
|
+
).data;
|
|
530
|
+
};
|
|
531
|
+
|
|
532
|
+
// ─── JOBS ────────────────────────────────────
|
|
533
|
+
|
|
534
|
+
export const getJobRcb = async (jobId: string, apiKey?: string): Promise<IGetJobRcbResponse> => {
|
|
535
|
+
return (
|
|
536
|
+
await AbyssToolsCore.axios.get<IGetJobRcbResponse>(`rcb/jobs/${jobId}`, {
|
|
537
|
+
headers: authHeader(apiKey),
|
|
538
|
+
})
|
|
539
|
+
).data;
|
|
540
|
+
};
|
|
541
|
+
|
|
542
|
+
export const retryJobRcb = async (jobId: string, apiKey?: string): Promise<void> => {
|
|
543
|
+
await AbyssToolsCore.axios.post(`rcb/jobs/${jobId}/retry`, undefined, {
|
|
544
|
+
headers: authHeader(apiKey),
|
|
545
|
+
});
|
|
546
|
+
};
|
|
547
|
+
|
|
548
|
+
export const cancelJobRcb = async (jobId: string, apiKey?: string): Promise<void> => {
|
|
549
|
+
await AbyssToolsCore.axios.delete(`rcb/jobs/${jobId}`, { headers: authHeader(apiKey) });
|
|
550
|
+
};
|
|
551
|
+
|
|
552
|
+
// ─── FEEDBACK ────────────────────────────────
|
|
553
|
+
|
|
554
|
+
export const submitFeedbackRcb = async (
|
|
555
|
+
body: ICreateFeedbackRcbBody,
|
|
556
|
+
apiKey?: string,
|
|
557
|
+
): Promise<ICreateFeedbackRcbResponse> => {
|
|
558
|
+
return (
|
|
559
|
+
await AbyssToolsCore.axios.post<ICreateFeedbackRcbResponse>(`rcb/feedback`, body, {
|
|
560
|
+
headers: authHeader(apiKey),
|
|
561
|
+
})
|
|
562
|
+
).data;
|
|
563
|
+
};
|
|
564
|
+
|
|
565
|
+
export const listFeedbackRcb = async (
|
|
566
|
+
query: IListFeedbackRcbQuery = {},
|
|
567
|
+
apiKey?: string,
|
|
568
|
+
): Promise<IListFeedbackRcbResponse> => {
|
|
569
|
+
return (
|
|
570
|
+
await AbyssToolsCore.axios.get<IListFeedbackRcbResponse>(`rcb/feedback`, {
|
|
571
|
+
params: serializeParams(query),
|
|
572
|
+
headers: authHeader(apiKey),
|
|
573
|
+
})
|
|
574
|
+
).data;
|
|
575
|
+
};
|
|
576
|
+
|
|
577
|
+
export const getFeedbackRcb = async (
|
|
578
|
+
feedbackId: string,
|
|
579
|
+
apiKey?: string,
|
|
580
|
+
): Promise<IGetFeedbackRcbResponse> => {
|
|
581
|
+
return (
|
|
582
|
+
await AbyssToolsCore.axios.get<IGetFeedbackRcbResponse>(`rcb/feedback/${feedbackId}`, {
|
|
583
|
+
headers: authHeader(apiKey),
|
|
584
|
+
})
|
|
585
|
+
).data;
|
|
586
|
+
};
|
|
587
|
+
|
|
588
|
+
export const patchFeedbackRcb = async (
|
|
589
|
+
feedbackId: string,
|
|
590
|
+
body: IPatchFeedbackRcbBody,
|
|
591
|
+
apiKey?: string,
|
|
592
|
+
): Promise<IGetFeedbackRcbResponse> => {
|
|
593
|
+
return (
|
|
594
|
+
await AbyssToolsCore.axios.patch<IGetFeedbackRcbResponse>(`rcb/feedback/${feedbackId}`, body, {
|
|
595
|
+
headers: authHeader(apiKey),
|
|
596
|
+
})
|
|
597
|
+
).data;
|
|
598
|
+
};
|
|
599
|
+
|
|
600
|
+
// ─── HEALTH / STATS / USAGE / QUOTA ─────────
|
|
601
|
+
|
|
602
|
+
export const healthRcb = async (apiKey?: string): Promise<IHealthRcbResponse> => {
|
|
603
|
+
return (
|
|
604
|
+
await AbyssToolsCore.axios.get<IHealthRcbResponse>(`rcb/health`, {
|
|
605
|
+
headers: authHeader(apiKey),
|
|
606
|
+
})
|
|
607
|
+
).data;
|
|
608
|
+
};
|
|
609
|
+
|
|
610
|
+
export const statsRcb = async (apiKey?: string): Promise<IStatsRcbResponse> => {
|
|
611
|
+
return (
|
|
612
|
+
await AbyssToolsCore.axios.get<IStatsRcbResponse>(`rcb/stats`, {
|
|
613
|
+
headers: authHeader(apiKey),
|
|
614
|
+
})
|
|
615
|
+
).data;
|
|
616
|
+
};
|
|
617
|
+
|
|
618
|
+
export const listUsageRcb = async (
|
|
619
|
+
query: IListUsageRcbQuery = {},
|
|
620
|
+
apiKey?: string,
|
|
621
|
+
): Promise<{ data: unknown[]; total?: number }> => {
|
|
622
|
+
return (
|
|
623
|
+
await AbyssToolsCore.axios.get<{ data: unknown[]; total?: number }>(`rcb/usage`, {
|
|
624
|
+
params: serializeParams(query),
|
|
625
|
+
headers: authHeader(apiKey),
|
|
626
|
+
})
|
|
627
|
+
).data;
|
|
628
|
+
};
|
|
629
|
+
|
|
630
|
+
export const summaryUsageRcb = async (
|
|
631
|
+
query: ISummaryUsageRcbQuery = {},
|
|
632
|
+
apiKey?: string,
|
|
633
|
+
): Promise<ISummaryUsageRcbResponse> => {
|
|
634
|
+
return (
|
|
635
|
+
await AbyssToolsCore.axios.get<ISummaryUsageRcbResponse>(`rcb/usage/summary`, {
|
|
636
|
+
params: serializeParams(query),
|
|
637
|
+
headers: authHeader(apiKey),
|
|
638
|
+
})
|
|
639
|
+
).data;
|
|
640
|
+
};
|
|
641
|
+
|
|
642
|
+
export const getQuotaRcb = async (apiKey?: string): Promise<IGetQuotaRcbResponse> => {
|
|
643
|
+
return (
|
|
644
|
+
await AbyssToolsCore.axios.get<IGetQuotaRcbResponse>(`rcb/quota`, {
|
|
645
|
+
headers: authHeader(apiKey),
|
|
646
|
+
})
|
|
647
|
+
).data;
|
|
648
|
+
};
|
|
649
|
+
|
|
650
|
+
// ─── SHARED FILES (content_share-backed) ────
|
|
651
|
+
//
|
|
652
|
+
// Types live in `../types/interface/api/requests/rcb.request.ts` so they
|
|
653
|
+
// stay alongside every other RCB SDK contract.
|
|
654
|
+
|
|
655
|
+
export const listSharedFilesRcb = async (
|
|
656
|
+
query: IListSharedFilesRcbQuery = {},
|
|
657
|
+
apiKey?: string,
|
|
658
|
+
): Promise<IListFilesRcbResponse> =>
|
|
659
|
+
(
|
|
660
|
+
await AbyssToolsCore.axios.get<IListFilesRcbResponse>(`rcb/files/shared`, {
|
|
661
|
+
params: serializeParams(query),
|
|
662
|
+
headers: authHeader(apiKey),
|
|
663
|
+
})
|
|
664
|
+
).data;
|
|
665
|
+
|
|
666
|
+
// ─── WEBHOOK DELIVERIES ─────────────────────
|
|
667
|
+
|
|
668
|
+
export const listWebhookDeliveriesRcb = async (
|
|
669
|
+
query: IListWebhookDeliveriesRcbQuery = {},
|
|
670
|
+
apiKey?: string,
|
|
671
|
+
): Promise<IListWebhookDeliveriesRcbResponse> => {
|
|
672
|
+
return (
|
|
673
|
+
await AbyssToolsCore.axios.get<IListWebhookDeliveriesRcbResponse>(`rcb/webhooks/deliveries`, {
|
|
674
|
+
params: serializeParams(query),
|
|
675
|
+
headers: authHeader(apiKey),
|
|
676
|
+
})
|
|
677
|
+
).data;
|
|
678
|
+
};
|
|
679
|
+
|
|
680
|
+
export const getWebhookDeliveryRcb = async (
|
|
681
|
+
deliveryId: string,
|
|
682
|
+
apiKey?: string,
|
|
683
|
+
): Promise<IGetWebhookDeliveryRcbResponse> => {
|
|
684
|
+
return (
|
|
685
|
+
await AbyssToolsCore.axios.get<IGetWebhookDeliveryRcbResponse>(
|
|
686
|
+
`rcb/webhooks/deliveries/${deliveryId}`,
|
|
687
|
+
{ headers: authHeader(apiKey) },
|
|
688
|
+
)
|
|
689
|
+
).data;
|
|
690
|
+
};
|
|
691
|
+
|
|
692
|
+
export const replayWebhookDeliveryRcb = async (
|
|
693
|
+
deliveryId: string,
|
|
694
|
+
body: IReplayWebhookDeliveryRcbBody = {},
|
|
695
|
+
apiKey?: string,
|
|
696
|
+
): Promise<IGetWebhookDeliveryRcbResponse> => {
|
|
697
|
+
return (
|
|
698
|
+
await AbyssToolsCore.axios.post<IGetWebhookDeliveryRcbResponse>(
|
|
699
|
+
`rcb/webhooks/deliveries/${deliveryId}/replay`,
|
|
700
|
+
body,
|
|
701
|
+
{ headers: authHeader(apiKey) },
|
|
702
|
+
)
|
|
703
|
+
).data;
|
|
704
|
+
};
|
|
705
|
+
|
|
706
|
+
// ─── WEBHOOK SUBSCRIPTIONS (CRUD) ───────────
|
|
707
|
+
//
|
|
708
|
+
// Request / response types are defined alongside every other RCB SDK
|
|
709
|
+
// contract — see ../types/interface/api/{requests,responses}/rcb.*.ts.
|
|
710
|
+
|
|
711
|
+
export const paginateRcbWebhook = async (
|
|
712
|
+
query: IPaginateRcbWebhookQuery = {},
|
|
713
|
+
apiKey?: string,
|
|
714
|
+
): Promise<IPaginateRcbWebhookResponse> =>
|
|
715
|
+
(
|
|
716
|
+
await AbyssToolsCore.axios.get<IPaginateRcbWebhookResponse>(`rcb/webhook`, {
|
|
717
|
+
params: serializeParams(query),
|
|
718
|
+
headers: authHeader(apiKey),
|
|
719
|
+
})
|
|
720
|
+
).data;
|
|
721
|
+
|
|
722
|
+
export const getRcbWebhook = async (
|
|
723
|
+
webhookId: string,
|
|
724
|
+
scope: IRcbWebhookScopeQuery = {},
|
|
725
|
+
apiKey?: string,
|
|
726
|
+
): Promise<IGetRcbWebhookResponse> =>
|
|
727
|
+
(
|
|
728
|
+
await AbyssToolsCore.axios.get<IGetRcbWebhookResponse>(
|
|
729
|
+
`rcb/webhook/${webhookId}`,
|
|
730
|
+
{ params: serializeParams(scope), headers: authHeader(apiKey) },
|
|
731
|
+
)
|
|
732
|
+
).data;
|
|
733
|
+
|
|
734
|
+
export const createRcbWebhook = async (
|
|
735
|
+
body: ICreateRcbWebhookBody,
|
|
736
|
+
scope: IRcbWebhookScopeQuery = {},
|
|
737
|
+
apiKey?: string,
|
|
738
|
+
): Promise<ICreateRcbWebhookResponse> =>
|
|
739
|
+
(
|
|
740
|
+
await AbyssToolsCore.axios.post<ICreateRcbWebhookResponse>(
|
|
741
|
+
`rcb/webhook`,
|
|
742
|
+
body,
|
|
743
|
+
{ params: serializeParams(scope), headers: authHeader(apiKey) },
|
|
744
|
+
)
|
|
745
|
+
).data;
|
|
746
|
+
|
|
747
|
+
export const updateRcbWebhook = async (
|
|
748
|
+
webhookId: string,
|
|
749
|
+
body: IUpdateRcbWebhookBody,
|
|
750
|
+
scope: IRcbWebhookScopeQuery = {},
|
|
751
|
+
apiKey?: string,
|
|
752
|
+
): Promise<IUpdateRcbWebhookResponse> =>
|
|
753
|
+
(
|
|
754
|
+
await AbyssToolsCore.axios.put<IUpdateRcbWebhookResponse>(
|
|
755
|
+
`rcb/webhook/${webhookId}`,
|
|
756
|
+
body,
|
|
757
|
+
{ params: serializeParams(scope), headers: authHeader(apiKey) },
|
|
758
|
+
)
|
|
759
|
+
).data;
|
|
760
|
+
|
|
761
|
+
export const deleteRcbWebhook = async (
|
|
762
|
+
webhookId: string,
|
|
763
|
+
scope: IRcbWebhookScopeQuery = {},
|
|
764
|
+
apiKey?: string,
|
|
765
|
+
): Promise<IDeleteRcbWebhookResponse> =>
|
|
766
|
+
(
|
|
767
|
+
await AbyssToolsCore.axios.delete<IDeleteRcbWebhookResponse>(
|
|
768
|
+
`rcb/webhook/${webhookId}`,
|
|
769
|
+
{ params: serializeParams(scope), headers: authHeader(apiKey) },
|
|
770
|
+
)
|
|
771
|
+
).data;
|
|
772
|
+
|
|
773
|
+
export const resetSecretRcbWebhook = async (
|
|
774
|
+
webhookId: string,
|
|
775
|
+
scope: IRcbWebhookScopeQuery = {},
|
|
776
|
+
apiKey?: string,
|
|
777
|
+
): Promise<IResetSecretRcbWebhookResponse> =>
|
|
778
|
+
(
|
|
779
|
+
await AbyssToolsCore.axios.post<IResetSecretRcbWebhookResponse>(
|
|
780
|
+
`rcb/webhook/${webhookId}/reset-secret`,
|
|
781
|
+
undefined,
|
|
782
|
+
{ params: serializeParams(scope), headers: authHeader(apiKey) },
|
|
783
|
+
)
|
|
784
|
+
).data;
|
|
785
|
+
|
|
786
|
+
// ─── SHARE ───────────────────────────────────
|
|
787
|
+
|
|
788
|
+
export const mintShareExtractionRcb = async (
|
|
789
|
+
extractionId: string,
|
|
790
|
+
body: IMintShareExtractionRcbBody = {},
|
|
791
|
+
apiKey?: string,
|
|
792
|
+
): Promise<IMintShareExtractionRcbResponse> => {
|
|
793
|
+
return (
|
|
794
|
+
await AbyssToolsCore.axios.post<IMintShareExtractionRcbResponse>(
|
|
795
|
+
`rcb/share/owner/extractions/${extractionId}`,
|
|
796
|
+
body,
|
|
797
|
+
{ headers: authHeader(apiKey) },
|
|
798
|
+
)
|
|
799
|
+
).data;
|
|
800
|
+
};
|
|
801
|
+
|
|
802
|
+
export const revokeShareExtractionRcb = async (
|
|
803
|
+
extractionId: string,
|
|
804
|
+
apiKey?: string,
|
|
805
|
+
): Promise<void> => {
|
|
806
|
+
await AbyssToolsCore.axios.delete(`rcb/share/owner/extractions/${extractionId}`, {
|
|
807
|
+
headers: authHeader(apiKey),
|
|
808
|
+
});
|
|
809
|
+
};
|
|
810
|
+
|
|
811
|
+
export const getSharedExtractionRcbPublic = async (
|
|
812
|
+
token: string,
|
|
813
|
+
): Promise<IGetSharedExtractionRcbResponse> => {
|
|
814
|
+
return (
|
|
815
|
+
await AbyssToolsCore.axios.get<IGetSharedExtractionRcbResponse>(
|
|
816
|
+
`rcb/share/extractions/${token}`,
|
|
817
|
+
)
|
|
818
|
+
).data;
|
|
819
|
+
};
|
|
820
|
+
|
|
821
|
+
// ─── CHANGELOG ──────────────────────────────
|
|
822
|
+
|
|
823
|
+
export const changelogRcb = async (apiKey?: string): Promise<IChangelogRcbResponse> => {
|
|
824
|
+
return (
|
|
825
|
+
await AbyssToolsCore.axios.get<IChangelogRcbResponse>(`rcb/changelog`, {
|
|
826
|
+
headers: authHeader(apiKey),
|
|
827
|
+
})
|
|
828
|
+
).data;
|
|
829
|
+
};
|