@abyss-project/tools 1.0.5 → 1.1.1

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 (195) hide show
  1. package/dist/api/beam.api.d.ts +48 -0
  2. package/dist/api/beam.api.js +104 -0
  3. package/dist/api/beam.api.js.map +1 -0
  4. package/dist/api/extraction-plan-preset.api.d.ts +9 -0
  5. package/dist/api/extraction-plan-preset.api.js +23 -0
  6. package/dist/api/extraction-plan-preset.api.js.map +1 -0
  7. package/dist/api/extraction-plan-preset.api.test.d.ts +1 -0
  8. package/dist/api/extraction-plan-preset.api.test.js +41 -0
  9. package/dist/api/extraction-plan-preset.api.test.js.map +1 -0
  10. package/dist/api/extraction-settings.api.d.ts +4 -0
  11. package/dist/api/extraction-settings.api.js +22 -0
  12. package/dist/api/extraction-settings.api.js.map +1 -0
  13. package/dist/api/extraction.api.d.ts +74 -0
  14. package/dist/api/extraction.api.js +416 -0
  15. package/dist/api/extraction.api.js.map +1 -0
  16. package/dist/api/index.d.ts +4 -1
  17. package/dist/api/index.js +4 -1
  18. package/dist/api/index.js.map +1 -1
  19. package/dist/constants/beam.constants.d.ts +1 -0
  20. package/dist/constants/beam.constants.js +5 -0
  21. package/dist/constants/beam.constants.js.map +1 -0
  22. package/dist/constants/index.d.ts +1 -0
  23. package/dist/constants/index.js +1 -0
  24. package/dist/constants/index.js.map +1 -1
  25. package/dist/index.d.ts +107 -58
  26. package/dist/index.js +105 -58
  27. package/dist/index.js.map +1 -1
  28. package/dist/types/enum/beam.enum.d.ts +12 -0
  29. package/dist/types/enum/beam.enum.js +18 -0
  30. package/dist/types/enum/beam.enum.js.map +1 -0
  31. package/dist/types/enum/combine-strategy.enum.d.ts +5 -0
  32. package/dist/types/enum/combine-strategy.enum.js +10 -0
  33. package/dist/types/enum/combine-strategy.enum.js.map +1 -0
  34. package/dist/types/enum/content-share.enum.d.ts +3 -1
  35. package/dist/types/enum/content-share.enum.js +2 -0
  36. package/dist/types/enum/content-share.enum.js.map +1 -1
  37. package/dist/types/enum/document-type.enum.d.ts +9 -0
  38. package/dist/types/enum/document-type.enum.js +14 -0
  39. package/dist/types/enum/document-type.enum.js.map +1 -0
  40. package/dist/types/enum/extraction-feedback-issue-type.enum.d.ts +8 -0
  41. package/dist/types/enum/extraction-feedback-issue-type.enum.js +13 -0
  42. package/dist/types/enum/extraction-feedback-issue-type.enum.js.map +1 -0
  43. package/dist/types/enum/extraction-warning.enum.d.ts +7 -0
  44. package/dist/types/enum/extraction-warning.enum.js +12 -0
  45. package/dist/types/enum/extraction-warning.enum.js.map +1 -0
  46. package/dist/types/enum/index.d.ts +7 -0
  47. package/dist/types/enum/index.js +7 -0
  48. package/dist/types/enum/index.js.map +1 -1
  49. package/dist/types/enum/interpreter-kind.enum.d.ts +5 -0
  50. package/dist/types/enum/interpreter-kind.enum.js +10 -0
  51. package/dist/types/enum/interpreter-kind.enum.js.map +1 -0
  52. package/dist/types/enum/provider-kind.enum.d.ts +10 -0
  53. package/dist/types/enum/provider-kind.enum.js +16 -0
  54. package/dist/types/enum/provider-kind.enum.js.map +1 -0
  55. package/dist/types/interface/api/requests/beam.request.d.ts +122 -0
  56. package/dist/types/interface/api/{responses/pdf.response.js → requests/beam.request.js} +1 -1
  57. package/dist/types/interface/api/requests/beam.request.js.map +1 -0
  58. package/dist/types/interface/api/requests/{rcb.request.d.ts → extraction.request.d.ts} +81 -52
  59. package/dist/types/interface/api/requests/{pdf.public.request.js → extraction.request.js} +1 -1
  60. package/dist/types/interface/api/requests/extraction.request.js.map +1 -0
  61. package/dist/types/interface/api/requests/index.d.ts +2 -1
  62. package/dist/types/interface/api/requests/index.js +2 -1
  63. package/dist/types/interface/api/requests/index.js.map +1 -1
  64. package/dist/types/interface/api/responses/beam.response.d.ts +92 -0
  65. package/dist/types/interface/api/responses/{rcb.response.js → beam.response.js} +1 -1
  66. package/dist/types/interface/api/responses/beam.response.js.map +1 -0
  67. package/dist/types/interface/api/responses/extraction.response.d.ts +403 -0
  68. package/dist/types/interface/api/{requests/user-tag.request.js → responses/extraction.response.js} +1 -1
  69. package/dist/types/interface/api/responses/extraction.response.js.map +1 -0
  70. package/dist/types/interface/api/responses/index.d.ts +2 -1
  71. package/dist/types/interface/api/responses/index.js +2 -1
  72. package/dist/types/interface/api/responses/index.js.map +1 -1
  73. package/dist/types/interface/models/beam.dto.d.ts +58 -0
  74. package/dist/types/interface/{api/requests/pdf.request.js → models/beam.dto.js} +1 -1
  75. package/dist/types/interface/models/beam.dto.js.map +1 -0
  76. package/dist/types/interface/models/extraction-fetched-provenance.dto.test.d.ts +1 -0
  77. package/dist/types/interface/models/extraction-fetched-provenance.dto.test.js +159 -0
  78. package/dist/types/interface/models/extraction-fetched-provenance.dto.test.js.map +1 -0
  79. package/dist/types/interface/models/extraction-plan.dto.d.ts +163 -0
  80. package/dist/types/interface/models/extraction-plan.dto.js +11 -0
  81. package/dist/types/interface/models/extraction-plan.dto.js.map +1 -0
  82. package/dist/types/interface/models/extraction-plan.dto.test.d.ts +1 -0
  83. package/dist/types/interface/models/extraction-plan.dto.test.js +35 -0
  84. package/dist/types/interface/models/extraction-plan.dto.test.js.map +1 -0
  85. package/dist/types/interface/models/extraction-spatial-template.dto.d.ts +37 -0
  86. package/dist/types/interface/{api/requests/rcb.request.js → models/extraction-spatial-template.dto.js} +1 -1
  87. package/dist/types/interface/models/extraction-spatial-template.dto.js.map +1 -0
  88. package/dist/types/interface/models/extraction-spatial-template.dto.test.d.ts +1 -0
  89. package/dist/types/interface/models/extraction-spatial-template.dto.test.js +15 -0
  90. package/dist/types/interface/models/extraction-spatial-template.dto.test.js.map +1 -0
  91. package/dist/types/interface/models/{rcb.dto.d.ts → extraction.dto.d.ts} +64 -48
  92. package/dist/types/interface/models/extraction.dto.js +28 -0
  93. package/dist/types/interface/models/extraction.dto.js.map +1 -0
  94. package/dist/types/interface/models/index.d.ts +4 -1
  95. package/dist/types/interface/models/index.js +4 -1
  96. package/dist/types/interface/models/index.js.map +1 -1
  97. package/dist/types/interface/models/organization.dto.d.ts +2 -0
  98. package/dist/utils/{rcb-webhook.utils.d.ts → extraction-webhook.utils.d.ts} +2 -2
  99. package/dist/utils/{rcb-webhook.utils.js → extraction-webhook.utils.js} +4 -4
  100. package/dist/utils/extraction-webhook.utils.js.map +1 -0
  101. package/dist/utils/index.d.ts +1 -1
  102. package/dist/utils/index.js +1 -1
  103. package/dist/utils/index.js.map +1 -1
  104. package/package.json +1 -1
  105. package/src/api/beam.api.ts +300 -0
  106. package/src/api/extraction-plan-preset.api.test.ts +24 -0
  107. package/src/api/extraction-plan-preset.api.ts +51 -0
  108. package/src/api/extraction-settings.api.ts +59 -0
  109. package/src/api/extraction.api.ts +899 -0
  110. package/src/api/index.ts +56 -51
  111. package/src/api/tests/beam.api.spec.ts +42 -0
  112. package/src/constants/beam.constants.ts +4 -0
  113. package/src/constants/index.ts +6 -5
  114. package/src/index.ts +840 -747
  115. package/src/types/enum/beam.enum.ts +24 -0
  116. package/src/types/enum/combine-strategy.enum.ts +7 -0
  117. package/src/types/enum/content-share.enum.ts +38 -36
  118. package/src/types/enum/document-type.enum.ts +10 -0
  119. package/src/types/enum/extraction-feedback-issue-type.enum.ts +10 -0
  120. package/src/types/enum/extraction-warning.enum.ts +21 -0
  121. package/src/types/enum/index.ts +13 -6
  122. package/src/types/enum/interpreter-kind.enum.ts +7 -0
  123. package/src/types/enum/provider-kind.enum.ts +13 -0
  124. package/src/types/interface/api/requests/beam.request.ts +152 -0
  125. package/src/types/interface/api/requests/extraction.request.ts +366 -0
  126. package/src/types/interface/api/requests/index.ts +29 -28
  127. package/src/types/interface/api/responses/beam.response.ts +122 -0
  128. package/src/types/interface/api/responses/extraction.response.ts +454 -0
  129. package/src/types/interface/api/responses/index.ts +33 -32
  130. package/src/types/interface/models/beam.dto.ts +67 -0
  131. package/src/types/interface/models/extraction-fetched-provenance.dto.test.ts +193 -0
  132. package/src/types/interface/models/extraction-plan.dto.test.ts +47 -0
  133. package/src/types/interface/models/extraction-plan.dto.ts +241 -0
  134. package/src/types/interface/models/extraction-spatial-template.dto.test.ts +27 -0
  135. package/src/types/interface/models/extraction-spatial-template.dto.ts +48 -0
  136. package/src/types/interface/models/{rcb.dto.ts → extraction.dto.ts} +317 -267
  137. package/src/types/interface/models/index.ts +34 -31
  138. package/src/types/interface/models/organization.dto.ts +21 -12
  139. package/src/types/tests/beam-management-types.spec.ts +38 -0
  140. package/src/types/tests/beam-share-enums.spec.ts +11 -0
  141. package/src/types/tests/beam.dto.spec.ts +61 -0
  142. package/src/types/tests/beam.request-response.spec.ts +43 -0
  143. package/src/utils/{rcb-webhook.utils.ts → extraction-webhook.utils.ts} +30 -30
  144. package/src/utils/index.ts +6 -6
  145. package/tsconfig.json +36 -35
  146. package/dist/api/atlas-page-content.api.d.ts +0 -0
  147. package/dist/api/atlas-page-content.api.js +0 -2
  148. package/dist/api/atlas-page-content.api.js.map +0 -1
  149. package/dist/api/pdf.api.d.ts +0 -15
  150. package/dist/api/pdf.api.js +0 -61
  151. package/dist/api/pdf.api.js.map +0 -1
  152. package/dist/api/pdf.public.api.d.ts +0 -8
  153. package/dist/api/pdf.public.api.js +0 -33
  154. package/dist/api/pdf.public.api.js.map +0 -1
  155. package/dist/api/rcb.api.d.ts +0 -72
  156. package/dist/api/rcb.api.js +0 -400
  157. package/dist/api/rcb.api.js.map +0 -1
  158. package/dist/api/user-tag.api.d.ts +0 -9
  159. package/dist/api/user-tag.api.js +0 -37
  160. package/dist/api/user-tag.api.js.map +0 -1
  161. package/dist/constants/user-tag.constants.d.ts +0 -3
  162. package/dist/constants/user-tag.constants.js +0 -7
  163. package/dist/constants/user-tag.constants.js.map +0 -1
  164. package/dist/types/enum/pdf-session.enum.d.ts +0 -10
  165. package/dist/types/enum/pdf-session.enum.js +0 -16
  166. package/dist/types/enum/pdf-session.enum.js.map +0 -1
  167. package/dist/types/interface/api/requests/pdf.public.request.d.ts +0 -19
  168. package/dist/types/interface/api/requests/pdf.public.request.js.map +0 -1
  169. package/dist/types/interface/api/requests/pdf.request.d.ts +0 -50
  170. package/dist/types/interface/api/requests/pdf.request.js.map +0 -1
  171. package/dist/types/interface/api/requests/rcb.request.js.map +0 -1
  172. package/dist/types/interface/api/requests/user-tag.request.d.ts +0 -44
  173. package/dist/types/interface/api/requests/user-tag.request.js.map +0 -1
  174. package/dist/types/interface/api/responses/pdf.public.response.d.ts +0 -33
  175. package/dist/types/interface/api/responses/pdf.public.response.js +0 -3
  176. package/dist/types/interface/api/responses/pdf.public.response.js.map +0 -1
  177. package/dist/types/interface/api/responses/pdf.response.d.ts +0 -35
  178. package/dist/types/interface/api/responses/pdf.response.js.map +0 -1
  179. package/dist/types/interface/api/responses/rcb.response.d.ts +0 -376
  180. package/dist/types/interface/api/responses/rcb.response.js.map +0 -1
  181. package/dist/types/interface/api/responses/user-tag.response.d.ts +0 -32
  182. package/dist/types/interface/api/responses/user-tag.response.js +0 -3
  183. package/dist/types/interface/api/responses/user-tag.response.js.map +0 -1
  184. package/dist/types/interface/models/pdf-session.dto.d.ts +0 -28
  185. package/dist/types/interface/models/pdf-session.dto.js +0 -3
  186. package/dist/types/interface/models/pdf-session.dto.js.map +0 -1
  187. package/dist/types/interface/models/rcb.dto.js +0 -26
  188. package/dist/types/interface/models/rcb.dto.js.map +0 -1
  189. package/dist/types/interface/models/user-tag.dto.d.ts +0 -22
  190. package/dist/types/interface/models/user-tag.dto.js +0 -3
  191. package/dist/types/interface/models/user-tag.dto.js.map +0 -1
  192. package/dist/utils/rcb-webhook.utils.js.map +0 -1
  193. package/src/api/rcb.api.ts +0 -829
  194. package/src/types/interface/api/requests/rcb.request.ts +0 -267
  195. package/src/types/interface/api/responses/rcb.response.ts +0 -399
@@ -0,0 +1,899 @@
1
+ // ──────────────────────────────────────────────
2
+ // 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
+ IExtractBody,
11
+ IExtractBulkBody,
12
+ IDetectBulkBody,
13
+ IListFilesQuery,
14
+ IPatchFileBody,
15
+ IPatchExtractionBody,
16
+ ISearchExtractionRecordsQuery,
17
+ IExportExtractionQuery,
18
+ IAsyncExportExtractionBody,
19
+ IListUsageQuery,
20
+ ISummaryUsageQuery,
21
+ IListWebhookDeliveriesQuery,
22
+ IReplayWebhookDeliveryBody,
23
+ IMintShareExtractionBody,
24
+ IToggleExtractionTrainingBody,
25
+ } from '../types';
26
+ import {
27
+ IExtractSyncResponse,
28
+ IExtractQueueResponse,
29
+ IExtractBulkResponse,
30
+ IDetectResponse,
31
+ IDetectBulkResponse,
32
+ IListFilesResponse,
33
+ IGetFileResponse,
34
+ IListFileExtractionsResponse,
35
+ IGetExtractionResponse,
36
+ ISearchExtractionRecordsResponse,
37
+ IDiffExtractionsResponse,
38
+ IAsyncExportResponse,
39
+ IGetExportJobResponse,
40
+ ICreateTemplateResponse,
41
+ IUpdateTemplateResponse,
42
+ IListTemplatesResponse,
43
+ IGetTemplateResponse,
44
+ IListTemplateVersionsResponse,
45
+ IExtractionTemplateCollection,
46
+ IImportTemplateCollectionResponse,
47
+ IGetJobResponse,
48
+ ICreateFeedbackResponse,
49
+ IListFeedbackResponse,
50
+ IGetFeedbackResponse,
51
+ IHealthResponse,
52
+ IStatsResponse,
53
+ ISummaryUsageResponse,
54
+ IListWebhookDeliveriesResponse,
55
+ IGetWebhookDeliveryResponse,
56
+ IGetSharedExtractionResponse,
57
+ IMintShareExtractionResponse,
58
+ IChangelogResponse,
59
+ IToggleExtractionTrainingResponse,
60
+ } from '../types';
61
+ import {
62
+ ICreateTemplateBody,
63
+ IUpdateTemplateBody,
64
+ IPatchTemplateMetaBody,
65
+ ISubmitFeedbackExtractionBody,
66
+ IPatchFeedbackBody,
67
+ IListFeedbackQuery,
68
+ IListSharedFilesQuery,
69
+ IPaginateExtractionWebhookQuery,
70
+ ICreateExtractionWebhookBody,
71
+ IUpdateExtractionWebhookBody,
72
+ IExtractionWebhookScopeQuery,
73
+ IExtractionContentScopeQuery,
74
+ IExtractionTemplateScopeQuery,
75
+ } from '../types';
76
+ import type {
77
+ IPaginateExtractionWebhookResponse,
78
+ IGetExtractionWebhookResponse,
79
+ ICreateExtractionWebhookResponse,
80
+ IUpdateExtractionWebhookResponse,
81
+ IDeleteExtractionWebhookResponse,
82
+ IResetSecretExtractionWebhookResponse,
83
+ } from '../types';
84
+
85
+ const DEFAULT_API_KEY_HEADER = 'x-api-key';
86
+
87
+ function authHeader(apiKey?: string): Record<string, string> {
88
+ return apiKey ? { [DEFAULT_API_KEY_HEADER]: apiKey } : {};
89
+ }
90
+
91
+ async function loadFormData(): Promise<any> {
92
+ if (typeof FormData !== 'undefined' && typeof window !== 'undefined') {
93
+ return FormData;
94
+ }
95
+ // Use indirect eval so bundlers (esbuild/vite/webpack) do not try to
96
+ // resolve the Node-only "form-data" package when this file is included
97
+ // in a browser bundle. The require only runs at runtime on Node.
98
+ // eslint-disable-next-line @typescript-eslint/no-implied-eval, no-new-func
99
+ const nodeRequire: NodeRequire = new Function('return require')();
100
+ return nodeRequire('form-data');
101
+ }
102
+
103
+ function serializeParams<T extends object>(o: T): Record<string, unknown> {
104
+ const out: Record<string, unknown> = {};
105
+ for (const [k, v] of Object.entries(o as Record<string, unknown>)) {
106
+ if (v === undefined || v === null) continue;
107
+ out[k] = v instanceof Date ? v.toISOString() : v;
108
+ }
109
+ return out;
110
+ }
111
+
112
+ // ─── EXTRACT ─────────────────────────────────
113
+
114
+ /**
115
+ * Optional per-call extras for extract endpoints. `idempotencyKey` is a
116
+ * Stripe-style replay key (24h window) sent as the `Idempotency-Key` header —
117
+ * not part of the request body.
118
+ */
119
+ export interface ExtractCallOptions {
120
+ idempotencyKey?: string;
121
+ }
122
+
123
+ export const extractSync = async (
124
+ body: IExtractBody,
125
+ scope: IExtractionContentScopeQuery = {},
126
+ apiKey?: string,
127
+ opts: ExtractCallOptions = {},
128
+ ): Promise<IExtractSyncResponse> => {
129
+ return postExtract(
130
+ { ...body, processing: 'sync' },
131
+ scope,
132
+ apiKey,
133
+ opts,
134
+ ) as Promise<IExtractSyncResponse>;
135
+ };
136
+
137
+ export const extractQueue = async (
138
+ body: IExtractBody,
139
+ scope: IExtractionContentScopeQuery = {},
140
+ apiKey?: string,
141
+ opts: ExtractCallOptions = {},
142
+ ): Promise<IExtractQueueResponse> => {
143
+ return postExtract(
144
+ { ...body, processing: 'queue' },
145
+ scope,
146
+ apiKey,
147
+ opts,
148
+ ) as Promise<IExtractQueueResponse>;
149
+ };
150
+
151
+ const postExtract = async (
152
+ body: IExtractBody,
153
+ scope: IExtractionContentScopeQuery = {},
154
+ apiKey?: string,
155
+ opts: ExtractCallOptions = {},
156
+ ): Promise<unknown> => {
157
+ const extraHeaders: Record<string, string> = {};
158
+ if (opts.idempotencyKey) {
159
+ extraHeaders['Idempotency-Key'] = opts.idempotencyKey;
160
+ }
161
+ const params = serializeParams(scope);
162
+ if (body.pdf) {
163
+ const isBrowser = typeof window !== 'undefined' && typeof FormData !== 'undefined';
164
+ const filename = body.pdf_filename ?? 'document.pdf';
165
+ if (isBrowser) {
166
+ const form = new FormData();
167
+ const blob = new Blob([body.pdf as Uint8Array], { type: 'application/pdf' });
168
+ form.append('file', blob, filename);
169
+ appendIf(form, 'mode', body.mode);
170
+ if (body.hint) form.append('hint', JSON.stringify(body.hint));
171
+ appendIf(form, 'template_id', body.template_id);
172
+ if (body.template) form.append('template', JSON.stringify(body.template));
173
+ appendIf(form, 'user_external_id', body.user_external_id);
174
+ if (body.user_metadata) form.append('user_metadata', JSON.stringify(body.user_metadata));
175
+ if (typeof body.archive === 'boolean') form.append('archive', String(body.archive));
176
+ if (typeof body.force === 'boolean') form.append('force', String(body.force));
177
+ if (body.processing) form.append('processing', body.processing);
178
+ return (
179
+ await AbyssToolsCore.axios.post(`extract/extract`, form, {
180
+ params,
181
+ headers: { ...authHeader(apiKey), ...extraHeaders },
182
+ maxBodyLength: Infinity,
183
+ maxContentLength: Infinity,
184
+ })
185
+ ).data;
186
+ }
187
+ const FormDataCtor = await loadFormData();
188
+ const form = new FormDataCtor();
189
+ const buf = Buffer.isBuffer(body.pdf) ? body.pdf : Buffer.from(body.pdf);
190
+ form.append('file', buf, {
191
+ filename,
192
+ contentType: 'application/pdf',
193
+ });
194
+ appendIf(form, 'mode', body.mode);
195
+ if (body.hint) form.append('hint', JSON.stringify(body.hint));
196
+ appendIf(form, 'template_id', body.template_id);
197
+ if (body.template) form.append('template', JSON.stringify(body.template));
198
+ appendIf(form, 'user_external_id', body.user_external_id);
199
+ if (body.user_metadata) form.append('user_metadata', JSON.stringify(body.user_metadata));
200
+ if (typeof body.archive === 'boolean') form.append('archive', String(body.archive));
201
+ if (typeof body.force === 'boolean') form.append('force', String(body.force));
202
+ if (body.processing) form.append('processing', body.processing);
203
+ return (
204
+ await AbyssToolsCore.axios.post(`extract/extract`, form, {
205
+ params,
206
+ headers: {
207
+ ...(typeof form.getHeaders === 'function' ? form.getHeaders() : {}),
208
+ ...authHeader(apiKey),
209
+ ...extraHeaders,
210
+ },
211
+ maxBodyLength: Infinity,
212
+ maxContentLength: Infinity,
213
+ })
214
+ ).data;
215
+ }
216
+ // Strip `pdf` from the JSON body (only used for multipart upload above).
217
+ const jsonBody: Omit<IExtractBody, 'pdf'> = { ...body };
218
+ delete (jsonBody as { pdf?: unknown }).pdf;
219
+ return (
220
+ await AbyssToolsCore.axios.post(`extract/extract`, jsonBody, {
221
+ params,
222
+ headers: { ...authHeader(apiKey), ...extraHeaders },
223
+ })
224
+ ).data;
225
+ };
226
+
227
+ function appendIf(form: any, key: string, value: unknown): void {
228
+ if (value === undefined || value === null) return;
229
+ form.append(key, String(value));
230
+ }
231
+
232
+ export const extractBulk = async (
233
+ body: IExtractBulkBody,
234
+ scope: IExtractionContentScopeQuery = {},
235
+ apiKey?: string,
236
+ ): Promise<IExtractBulkResponse> => {
237
+ return (
238
+ await AbyssToolsCore.axios.post<IExtractBulkResponse>(`extract/extract/bulk`, body, {
239
+ params: serializeParams(scope),
240
+ headers: authHeader(apiKey),
241
+ })
242
+ ).data;
243
+ };
244
+
245
+ // ─── DETECT ──────────────────────────────────
246
+
247
+ export const detect = async (
248
+ pdf: Buffer | Uint8Array,
249
+ pdfFilename = 'document.pdf',
250
+ apiKey?: string,
251
+ ): Promise<IDetectResponse> => {
252
+ const isBrowser = typeof window !== 'undefined' && typeof FormData !== 'undefined';
253
+ if (isBrowser) {
254
+ const form = new FormData();
255
+ const blob = new Blob([pdf as Uint8Array], { type: 'application/pdf' });
256
+ form.append('file', blob, pdfFilename);
257
+ return (
258
+ await AbyssToolsCore.axios.post<IDetectResponse>(`extract/detect`, form, {
259
+ headers: authHeader(apiKey),
260
+ maxBodyLength: Infinity,
261
+ maxContentLength: Infinity,
262
+ })
263
+ ).data;
264
+ }
265
+ const FormDataCtor = await loadFormData();
266
+ const form = new FormDataCtor();
267
+ const buf = Buffer.isBuffer(pdf) ? pdf : Buffer.from(pdf);
268
+ form.append('file', buf, { filename: pdfFilename, contentType: 'application/pdf' });
269
+ return (
270
+ await AbyssToolsCore.axios.post<IDetectResponse>(`extract/detect`, form, {
271
+ headers: {
272
+ ...(typeof form.getHeaders === 'function' ? form.getHeaders() : {}),
273
+ ...authHeader(apiKey),
274
+ },
275
+ maxBodyLength: Infinity,
276
+ maxContentLength: Infinity,
277
+ })
278
+ ).data;
279
+ };
280
+
281
+ export const detectBulk = async (
282
+ body: IDetectBulkBody,
283
+ apiKey?: string,
284
+ ): Promise<IDetectBulkResponse> => {
285
+ return (
286
+ await AbyssToolsCore.axios.post<IDetectBulkResponse>(`extract/detect/bulk`, body, {
287
+ headers: authHeader(apiKey),
288
+ })
289
+ ).data;
290
+ };
291
+
292
+ // ─── FILES ───────────────────────────────────
293
+
294
+ export const listFiles = async (
295
+ query: IListFilesQuery = {},
296
+ apiKey?: string,
297
+ ): Promise<IListFilesResponse> => {
298
+ return (
299
+ await AbyssToolsCore.axios.get<IListFilesResponse>(`extract/files`, {
300
+ params: serializeParams(query),
301
+ headers: authHeader(apiKey),
302
+ })
303
+ ).data;
304
+ };
305
+
306
+ export const getFile = async (
307
+ fileId: string,
308
+ scope: IExtractionContentScopeQuery = {},
309
+ apiKey?: string,
310
+ ): Promise<IGetFileResponse> => {
311
+ return (
312
+ await AbyssToolsCore.axios.get<IGetFileResponse>(`extract/files/${fileId}`, {
313
+ params: serializeParams(scope),
314
+ headers: authHeader(apiKey),
315
+ })
316
+ ).data;
317
+ };
318
+
319
+ export const listFileExtractions = async (
320
+ fileId: string,
321
+ query: { limit?: number; offset?: number } & IExtractionContentScopeQuery = {},
322
+ apiKey?: string,
323
+ ): Promise<IListFileExtractionsResponse> => {
324
+ return (
325
+ await AbyssToolsCore.axios.get<IListFileExtractionsResponse>(
326
+ `extract/files/${fileId}/extractions`,
327
+ { params: serializeParams(query), headers: authHeader(apiKey) },
328
+ )
329
+ ).data;
330
+ };
331
+
332
+ export const patchFile = async (
333
+ fileId: string,
334
+ body: IPatchFileBody,
335
+ scope: IExtractionContentScopeQuery = {},
336
+ apiKey?: string,
337
+ ): Promise<IGetFileResponse> => {
338
+ return (
339
+ await AbyssToolsCore.axios.patch<IGetFileResponse>(`extract/files/${fileId}`, body, {
340
+ params: serializeParams(scope),
341
+ headers: authHeader(apiKey),
342
+ })
343
+ ).data;
344
+ };
345
+
346
+ export const downloadFileBundle = async (
347
+ fileId: string,
348
+ query: { format?: 'csv' | 'json' } & IExtractionContentScopeQuery = {},
349
+ apiKey?: string,
350
+ ): Promise<Buffer> => {
351
+ const res = await AbyssToolsCore.axios.get(`extract/files/${fileId}/bundle`, {
352
+ params: serializeParams(query),
353
+ responseType: 'arraybuffer',
354
+ headers: authHeader(apiKey),
355
+ });
356
+ return Buffer.from(res.data as ArrayBuffer);
357
+ };
358
+
359
+ // ─── EXTRACTIONS ─────────────────────────────
360
+
361
+ export const getExtraction = async (
362
+ extractionId: string,
363
+ scope: IExtractionContentScopeQuery = {},
364
+ apiKey?: string,
365
+ ): Promise<IGetExtractionResponse> => {
366
+ return (
367
+ await AbyssToolsCore.axios.get<IGetExtractionResponse>(`extract/extractions/${extractionId}`, {
368
+ params: serializeParams(scope),
369
+ headers: authHeader(apiKey),
370
+ })
371
+ ).data;
372
+ };
373
+
374
+ export const patchExtraction = async (
375
+ extractionId: string,
376
+ body: IPatchExtractionBody,
377
+ scope: IExtractionContentScopeQuery = {},
378
+ apiKey?: string,
379
+ ): Promise<IGetExtractionResponse> => {
380
+ return (
381
+ await AbyssToolsCore.axios.patch<IGetExtractionResponse>(
382
+ `extract/extractions/${extractionId}`,
383
+ body,
384
+ { params: serializeParams(scope), headers: authHeader(apiKey) },
385
+ )
386
+ ).data;
387
+ };
388
+
389
+ export const searchExtractionRecords = async (
390
+ extractionId: string,
391
+ query: ISearchExtractionRecordsQuery & IExtractionContentScopeQuery = {},
392
+ apiKey?: string,
393
+ ): Promise<ISearchExtractionRecordsResponse> => {
394
+ return (
395
+ await AbyssToolsCore.axios.get<ISearchExtractionRecordsResponse>(
396
+ `extract/extractions/${extractionId}/records`,
397
+ { params: serializeParams(query), headers: authHeader(apiKey) },
398
+ )
399
+ ).data;
400
+ };
401
+
402
+ export const exportExtraction = async (
403
+ extractionId: string,
404
+ query: IExportExtractionQuery & IExtractionContentScopeQuery,
405
+ apiKey?: string,
406
+ ): Promise<{ body: string; contentType: string }> => {
407
+ const res = await AbyssToolsCore.axios.get(`extract/extractions/${extractionId}/export`, {
408
+ params: serializeParams(query),
409
+ responseType: 'text',
410
+ transformResponse: (d) => d,
411
+ headers: authHeader(apiKey),
412
+ });
413
+ return {
414
+ body: typeof res.data === 'string' ? res.data : String(res.data),
415
+ contentType: String(res.headers?.['content-type'] ?? 'application/octet-stream'),
416
+ };
417
+ };
418
+
419
+ export const asyncExportExtraction = async (
420
+ extractionId: string,
421
+ body: IAsyncExportExtractionBody,
422
+ scope: IExtractionContentScopeQuery = {},
423
+ apiKey?: string,
424
+ ): Promise<IAsyncExportResponse> => {
425
+ return (
426
+ await AbyssToolsCore.axios.post<IAsyncExportResponse>(
427
+ `extract/extractions/${extractionId}/export/async`,
428
+ body,
429
+ { params: serializeParams(scope), headers: authHeader(apiKey) },
430
+ )
431
+ ).data;
432
+ };
433
+
434
+ export const getExportJob = async (
435
+ jobId: string,
436
+ apiKey?: string,
437
+ ): Promise<IGetExportJobResponse> => {
438
+ return (
439
+ await AbyssToolsCore.axios.get<IGetExportJobResponse>(`extract/exports/jobs/${jobId}`, {
440
+ headers: authHeader(apiKey),
441
+ })
442
+ ).data;
443
+ };
444
+
445
+ export const diffExtractions = async (
446
+ extractionId: string,
447
+ otherId: string,
448
+ scope: IExtractionContentScopeQuery = {},
449
+ apiKey?: string,
450
+ ): Promise<IDiffExtractionsResponse> => {
451
+ return (
452
+ await AbyssToolsCore.axios.get<IDiffExtractionsResponse>(
453
+ `extract/extractions/${extractionId}/diff/${otherId}`,
454
+ { params: serializeParams(scope), headers: authHeader(apiKey) },
455
+ )
456
+ ).data;
457
+ };
458
+
459
+ /**
460
+ * Retroactive history toggle: opt a specific extraction in/out of the
461
+ * improvement-training dataset.
462
+ * PATCH /extract/extractions/:id/training
463
+ */
464
+ export const toggleExtractionTraining = async (
465
+ extractionId: string,
466
+ body: IToggleExtractionTrainingBody,
467
+ apiKey?: string,
468
+ ): Promise<IToggleExtractionTrainingResponse> => {
469
+ return (
470
+ await AbyssToolsCore.axios.patch<IToggleExtractionTrainingResponse>(
471
+ `extract/extractions/${extractionId}/training`,
472
+ body,
473
+ { headers: authHeader(apiKey) },
474
+ )
475
+ ).data;
476
+ };
477
+
478
+ // ─── TEMPLATES ───────────────────────────────
479
+
480
+ export const listTemplates = async (
481
+ query: { kind?: 'spatial' | 'dsl' } & IExtractionTemplateScopeQuery = {},
482
+ apiKey?: string,
483
+ ): Promise<IListTemplatesResponse> => {
484
+ return (
485
+ await AbyssToolsCore.axios.get<IListTemplatesResponse>(`extract/templates`, {
486
+ params: serializeParams(query),
487
+ headers: authHeader(apiKey),
488
+ })
489
+ ).data;
490
+ };
491
+
492
+ export const createTemplate = async (
493
+ body: ICreateTemplateBody,
494
+ scope: IExtractionTemplateScopeQuery = {},
495
+ apiKey?: string,
496
+ ): Promise<ICreateTemplateResponse> => {
497
+ return (
498
+ await AbyssToolsCore.axios.post<ICreateTemplateResponse>(`extract/templates`, body, {
499
+ params: serializeParams(scope),
500
+ headers: authHeader(apiKey),
501
+ })
502
+ ).data;
503
+ };
504
+
505
+ export const getTemplate = async (
506
+ templateId: string,
507
+ scope: IExtractionTemplateScopeQuery = {},
508
+ apiKey?: string,
509
+ ): Promise<IGetTemplateResponse> => {
510
+ return (
511
+ await AbyssToolsCore.axios.get<IGetTemplateResponse>(`extract/templates/${templateId}`, {
512
+ params: serializeParams(scope),
513
+ headers: authHeader(apiKey),
514
+ })
515
+ ).data;
516
+ };
517
+
518
+ export const updateTemplate = async (
519
+ templateId: string,
520
+ body: IUpdateTemplateBody,
521
+ scope: IExtractionTemplateScopeQuery = {},
522
+ apiKey?: string,
523
+ ): Promise<IUpdateTemplateResponse> => {
524
+ return (
525
+ await AbyssToolsCore.axios.put<IUpdateTemplateResponse>(
526
+ `extract/templates/${templateId}`,
527
+ body,
528
+ { params: serializeParams(scope), headers: authHeader(apiKey) },
529
+ )
530
+ ).data;
531
+ };
532
+
533
+ export const patchTemplateMeta = async (
534
+ templateId: string,
535
+ body: IPatchTemplateMetaBody,
536
+ scope: IExtractionTemplateScopeQuery = {},
537
+ apiKey?: string,
538
+ ): Promise<void> => {
539
+ await AbyssToolsCore.axios.patch(`extract/templates/${templateId}/meta`, body, {
540
+ params: serializeParams(scope),
541
+ headers: authHeader(apiKey),
542
+ });
543
+ };
544
+
545
+ export const deleteTemplate = async (
546
+ templateId: string,
547
+ scope: IExtractionTemplateScopeQuery = {},
548
+ apiKey?: string,
549
+ ): Promise<void> => {
550
+ await AbyssToolsCore.axios.delete(`extract/templates/${templateId}`, {
551
+ params: serializeParams(scope),
552
+ headers: authHeader(apiKey),
553
+ });
554
+ };
555
+
556
+ export const listTemplateVersions = async (
557
+ templateId: string,
558
+ scope: IExtractionTemplateScopeQuery = {},
559
+ apiKey?: string,
560
+ ): Promise<IListTemplateVersionsResponse> => {
561
+ return (
562
+ await AbyssToolsCore.axios.get<IListTemplateVersionsResponse>(
563
+ `extract/templates/${templateId}/versions`,
564
+ { params: serializeParams(scope), headers: authHeader(apiKey) },
565
+ )
566
+ ).data;
567
+ };
568
+
569
+ export const exportTemplateCollection = async (
570
+ ids: string[] | null,
571
+ scope: IExtractionTemplateScopeQuery = {},
572
+ apiKey?: string,
573
+ ): Promise<IExtractionTemplateCollection> => {
574
+ const res = await AbyssToolsCore.axios.get<IExtractionTemplateCollection>(`extract/templates/export`, {
575
+ params: {
576
+ ...(ids && ids.length ? { ids: ids.join(',') } : {}),
577
+ ...serializeParams(scope),
578
+ },
579
+ headers: authHeader(apiKey),
580
+ responseType: 'json',
581
+ });
582
+ return res.data;
583
+ };
584
+
585
+ export const importTemplateCollection = async (
586
+ doc: IExtractionTemplateCollection,
587
+ scope: IExtractionTemplateScopeQuery = {},
588
+ apiKey?: string,
589
+ ): Promise<IImportTemplateCollectionResponse> => {
590
+ return (
591
+ await AbyssToolsCore.axios.post<IImportTemplateCollectionResponse>(
592
+ `extract/templates/import`,
593
+ doc,
594
+ { params: serializeParams(scope), headers: authHeader(apiKey) },
595
+ )
596
+ ).data;
597
+ };
598
+
599
+ // ─── JOBS ────────────────────────────────────
600
+
601
+ export const getJob = async (jobId: string, apiKey?: string): Promise<IGetJobResponse> => {
602
+ return (
603
+ await AbyssToolsCore.axios.get<IGetJobResponse>(`extract/jobs/${jobId}`, {
604
+ headers: authHeader(apiKey),
605
+ })
606
+ ).data;
607
+ };
608
+
609
+ export const retryJob = async (jobId: string, apiKey?: string): Promise<void> => {
610
+ await AbyssToolsCore.axios.post(`extract/jobs/${jobId}/retry`, undefined, {
611
+ headers: authHeader(apiKey),
612
+ });
613
+ };
614
+
615
+ export const cancelJob = async (jobId: string, apiKey?: string): Promise<void> => {
616
+ await AbyssToolsCore.axios.delete(`extract/jobs/${jobId}`, { headers: authHeader(apiKey) });
617
+ };
618
+
619
+ // ─── FEEDBACK ────────────────────────────────
620
+
621
+ /**
622
+ * Submit structured feedback on an extraction. The server ALWAYS mints a
623
+ * SupportTicket (category EXTRACTION) alongside the structured training row;
624
+ * the returned feedback DTO carries the resulting `supportTicketId`.
625
+ * POST /extract/feedback
626
+ */
627
+ export const submitFeedback = async (
628
+ body: ISubmitFeedbackExtractionBody,
629
+ scope: IExtractionContentScopeQuery = {},
630
+ apiKey?: string,
631
+ ): Promise<ICreateFeedbackResponse> => {
632
+ return (
633
+ await AbyssToolsCore.axios.post<ICreateFeedbackResponse>(`extract/feedback`, body, {
634
+ params: serializeParams(scope),
635
+ headers: authHeader(apiKey),
636
+ })
637
+ ).data;
638
+ };
639
+
640
+ export const listFeedback = async (
641
+ query: IListFeedbackQuery = {},
642
+ apiKey?: string,
643
+ ): Promise<IListFeedbackResponse> => {
644
+ return (
645
+ await AbyssToolsCore.axios.get<IListFeedbackResponse>(`extract/feedback`, {
646
+ params: serializeParams(query),
647
+ headers: authHeader(apiKey),
648
+ })
649
+ ).data;
650
+ };
651
+
652
+ export const getFeedback = async (
653
+ feedbackId: string,
654
+ apiKey?: string,
655
+ ): Promise<IGetFeedbackResponse> => {
656
+ return (
657
+ await AbyssToolsCore.axios.get<IGetFeedbackResponse>(`extract/feedback/${feedbackId}`, {
658
+ headers: authHeader(apiKey),
659
+ })
660
+ ).data;
661
+ };
662
+
663
+ export const patchFeedback = async (
664
+ feedbackId: string,
665
+ body: IPatchFeedbackBody,
666
+ apiKey?: string,
667
+ ): Promise<IGetFeedbackResponse> => {
668
+ return (
669
+ await AbyssToolsCore.axios.patch<IGetFeedbackResponse>(`extract/feedback/${feedbackId}`, body, {
670
+ headers: authHeader(apiKey),
671
+ })
672
+ ).data;
673
+ };
674
+
675
+ // ─── HEALTH / STATS / USAGE ─────────────────
676
+
677
+ export const health = async (apiKey?: string): Promise<IHealthResponse> => {
678
+ return (
679
+ await AbyssToolsCore.axios.get<IHealthResponse>(`extract/health`, {
680
+ headers: authHeader(apiKey),
681
+ })
682
+ ).data;
683
+ };
684
+
685
+ export const stats = async (apiKey?: string): Promise<IStatsResponse> => {
686
+ return (
687
+ await AbyssToolsCore.axios.get<IStatsResponse>(`extract/stats`, {
688
+ headers: authHeader(apiKey),
689
+ })
690
+ ).data;
691
+ };
692
+
693
+ export const listUsage = async (
694
+ query: IListUsageQuery = {},
695
+ apiKey?: string,
696
+ ): Promise<{ data: unknown[]; total?: number }> => {
697
+ return (
698
+ await AbyssToolsCore.axios.get<{ data: unknown[]; total?: number }>(`extract/usage`, {
699
+ params: serializeParams(query),
700
+ headers: authHeader(apiKey),
701
+ })
702
+ ).data;
703
+ };
704
+
705
+ export const summaryUsage = async (
706
+ query: ISummaryUsageQuery = {},
707
+ apiKey?: string,
708
+ ): Promise<ISummaryUsageResponse> => {
709
+ return (
710
+ await AbyssToolsCore.axios.get<ISummaryUsageResponse>(`extract/usage/summary`, {
711
+ params: serializeParams(query),
712
+ headers: authHeader(apiKey),
713
+ })
714
+ ).data;
715
+ };
716
+
717
+ // ─── SHARED FILES (content_share-backed) ────
718
+ //
719
+ // Types live in `../types/interface/api/requests/extraction.request.ts` so they
720
+ // stay alongside every other extraction SDK contract.
721
+
722
+ export const listSharedFiles = async (
723
+ query: IListSharedFilesQuery = {},
724
+ apiKey?: string,
725
+ ): Promise<IListFilesResponse> =>
726
+ (
727
+ await AbyssToolsCore.axios.get<IListFilesResponse>(`extract/files/shared`, {
728
+ params: serializeParams(query),
729
+ headers: authHeader(apiKey),
730
+ })
731
+ ).data;
732
+
733
+ // ─── WEBHOOK DELIVERIES ─────────────────────
734
+
735
+ export const listWebhookDeliveries = async (
736
+ query: IListWebhookDeliveriesQuery = {},
737
+ apiKey?: string,
738
+ ): Promise<IListWebhookDeliveriesResponse> => {
739
+ return (
740
+ await AbyssToolsCore.axios.get<IListWebhookDeliveriesResponse>(`extract/webhooks/deliveries`, {
741
+ params: serializeParams(query),
742
+ headers: authHeader(apiKey),
743
+ })
744
+ ).data;
745
+ };
746
+
747
+ export const getWebhookDelivery = async (
748
+ deliveryId: string,
749
+ apiKey?: string,
750
+ ): Promise<IGetWebhookDeliveryResponse> => {
751
+ return (
752
+ await AbyssToolsCore.axios.get<IGetWebhookDeliveryResponse>(
753
+ `extract/webhooks/deliveries/${deliveryId}`,
754
+ { headers: authHeader(apiKey) },
755
+ )
756
+ ).data;
757
+ };
758
+
759
+ export const replayWebhookDelivery = async (
760
+ deliveryId: string,
761
+ body: IReplayWebhookDeliveryBody = {},
762
+ apiKey?: string,
763
+ ): Promise<IGetWebhookDeliveryResponse> => {
764
+ return (
765
+ await AbyssToolsCore.axios.post<IGetWebhookDeliveryResponse>(
766
+ `extract/webhooks/deliveries/${deliveryId}/replay`,
767
+ body,
768
+ { headers: authHeader(apiKey) },
769
+ )
770
+ ).data;
771
+ };
772
+
773
+ // ─── WEBHOOK SUBSCRIPTIONS (CRUD) ───────────
774
+ //
775
+ // Request / response types are defined alongside every other extraction SDK
776
+ // contract — see ../types/interface/api/{requests,responses}/extraction.*.ts.
777
+
778
+ export const paginateExtractionWebhook = async (
779
+ query: IPaginateExtractionWebhookQuery = {},
780
+ apiKey?: string,
781
+ ): Promise<IPaginateExtractionWebhookResponse> =>
782
+ (
783
+ await AbyssToolsCore.axios.get<IPaginateExtractionWebhookResponse>(`extract/webhook`, {
784
+ params: serializeParams(query),
785
+ headers: authHeader(apiKey),
786
+ })
787
+ ).data;
788
+
789
+ export const getExtractionWebhook = async (
790
+ webhookId: string,
791
+ scope: IExtractionWebhookScopeQuery = {},
792
+ apiKey?: string,
793
+ ): Promise<IGetExtractionWebhookResponse> =>
794
+ (
795
+ await AbyssToolsCore.axios.get<IGetExtractionWebhookResponse>(
796
+ `extract/webhook/${webhookId}`,
797
+ { params: serializeParams(scope), headers: authHeader(apiKey) },
798
+ )
799
+ ).data;
800
+
801
+ export const createExtractionWebhook = async (
802
+ body: ICreateExtractionWebhookBody,
803
+ scope: IExtractionWebhookScopeQuery = {},
804
+ apiKey?: string,
805
+ ): Promise<ICreateExtractionWebhookResponse> =>
806
+ (
807
+ await AbyssToolsCore.axios.post<ICreateExtractionWebhookResponse>(
808
+ `extract/webhook`,
809
+ body,
810
+ { params: serializeParams(scope), headers: authHeader(apiKey) },
811
+ )
812
+ ).data;
813
+
814
+ export const updateExtractionWebhook = async (
815
+ webhookId: string,
816
+ body: IUpdateExtractionWebhookBody,
817
+ scope: IExtractionWebhookScopeQuery = {},
818
+ apiKey?: string,
819
+ ): Promise<IUpdateExtractionWebhookResponse> =>
820
+ (
821
+ await AbyssToolsCore.axios.put<IUpdateExtractionWebhookResponse>(
822
+ `extract/webhook/${webhookId}`,
823
+ body,
824
+ { params: serializeParams(scope), headers: authHeader(apiKey) },
825
+ )
826
+ ).data;
827
+
828
+ export const deleteExtractionWebhook = async (
829
+ webhookId: string,
830
+ scope: IExtractionWebhookScopeQuery = {},
831
+ apiKey?: string,
832
+ ): Promise<IDeleteExtractionWebhookResponse> =>
833
+ (
834
+ await AbyssToolsCore.axios.delete<IDeleteExtractionWebhookResponse>(
835
+ `extract/webhook/${webhookId}`,
836
+ { params: serializeParams(scope), headers: authHeader(apiKey) },
837
+ )
838
+ ).data;
839
+
840
+ export const resetSecretExtractionWebhook = async (
841
+ webhookId: string,
842
+ scope: IExtractionWebhookScopeQuery = {},
843
+ apiKey?: string,
844
+ ): Promise<IResetSecretExtractionWebhookResponse> =>
845
+ (
846
+ await AbyssToolsCore.axios.post<IResetSecretExtractionWebhookResponse>(
847
+ `extract/webhook/${webhookId}/reset-secret`,
848
+ undefined,
849
+ { params: serializeParams(scope), headers: authHeader(apiKey) },
850
+ )
851
+ ).data;
852
+
853
+ // ─── SHARE ───────────────────────────────────
854
+
855
+ export const mintShareExtraction = async (
856
+ extractionId: string,
857
+ body: IMintShareExtractionBody = {},
858
+ scope: IExtractionContentScopeQuery = {},
859
+ apiKey?: string,
860
+ ): Promise<IMintShareExtractionResponse> => {
861
+ return (
862
+ await AbyssToolsCore.axios.post<IMintShareExtractionResponse>(
863
+ `extract/share/owner/extractions/${extractionId}`,
864
+ body,
865
+ { params: serializeParams(scope), headers: authHeader(apiKey) },
866
+ )
867
+ ).data;
868
+ };
869
+
870
+ export const revokeShareExtraction = async (
871
+ extractionId: string,
872
+ scope: IExtractionContentScopeQuery = {},
873
+ apiKey?: string,
874
+ ): Promise<void> => {
875
+ await AbyssToolsCore.axios.delete(`extract/share/owner/extractions/${extractionId}`, {
876
+ params: serializeParams(scope),
877
+ headers: authHeader(apiKey),
878
+ });
879
+ };
880
+
881
+ export const getSharedExtractionPublic = async (
882
+ token: string,
883
+ ): Promise<IGetSharedExtractionResponse> => {
884
+ return (
885
+ await AbyssToolsCore.axios.get<IGetSharedExtractionResponse>(
886
+ `extract/share/extractions/${token}`,
887
+ )
888
+ ).data;
889
+ };
890
+
891
+ // ─── CHANGELOG ──────────────────────────────
892
+
893
+ export const changelog = async (apiKey?: string): Promise<IChangelogResponse> => {
894
+ return (
895
+ await AbyssToolsCore.axios.get<IChangelogResponse>(`extract/changelog`, {
896
+ headers: authHeader(apiKey),
897
+ })
898
+ ).data;
899
+ };