@abyss-project/tools 2.10.0 → 2.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +33 -33
- package/.prettierrc +5 -5
- package/dist/api/atlas-group.api.js.map +1 -1
- package/dist/api/atlas-page.api.js.map +1 -1
- package/dist/api/atlas.api.js +3 -3
- package/dist/api/atlas.api.js.map +1 -1
- package/dist/api/atlas.public.api.js.map +1 -1
- package/dist/api/board-card.api.js.map +1 -1
- package/dist/api/board-column.api.js.map +1 -1
- package/dist/api/board-label.api.js +1 -2
- package/dist/api/board-label.api.js.map +1 -1
- package/dist/api/board.api.js +7 -5
- package/dist/api/board.api.js.map +1 -1
- package/dist/api/draw.api.js +1 -2
- package/dist/api/draw.api.js.map +1 -1
- package/dist/api/draw.public.api.js.map +1 -1
- package/dist/api/extraction-plan-preset.api.js +19 -6
- package/dist/api/extraction-plan-preset.api.js.map +1 -1
- package/dist/api/extraction-settings.api.js.map +1 -1
- package/dist/api/extraction.api.d.ts +0 -4
- package/dist/api/extraction.api.js +57 -46
- package/dist/api/extraction.api.js.map +1 -1
- package/dist/api/index.d.ts +0 -1
- package/dist/api/index.js +0 -1
- package/dist/api/index.js.map +1 -1
- package/dist/api/probe-scan.api.d.ts +2 -9
- package/dist/api/probe-scan.api.js +16 -26
- package/dist/api/probe-scan.api.js.map +1 -1
- package/dist/api/probe-scan.api.test.js +10 -0
- package/dist/api/probe-scan.api.test.js.map +1 -1
- package/dist/api/probe-scan.application.api.js +2 -2
- package/dist/api/probe-scan.application.api.js.map +1 -1
- package/dist/api/probe-scan.application.api.test.js +4 -0
- package/dist/api/probe-scan.application.api.test.js.map +1 -1
- package/dist/api/retrospective.api.js +2 -1
- package/dist/api/retrospective.api.js.map +1 -1
- package/dist/api/short-link.admin.api.js.map +1 -1
- package/dist/api/short-link.api.js.map +1 -1
- package/dist/api/short-link.public.api.js.map +1 -1
- package/dist/api/tag.api.js.map +1 -1
- package/dist/index.d.ts +0 -4
- package/dist/index.js +0 -4
- package/dist/index.js.map +1 -1
- package/dist/server-sent-events/server-sent-events.manager.d.ts +1 -2
- package/dist/server-sent-events/server-sent-events.manager.js +1 -2
- package/dist/server-sent-events/server-sent-events.manager.js.map +1 -1
- package/dist/types/enum/document-type.enum.d.ts +0 -1
- package/dist/types/enum/document-type.enum.js +0 -1
- package/dist/types/enum/document-type.enum.js.map +1 -1
- package/dist/types/enum/extraction-warning.enum.d.ts +2 -1
- package/dist/types/enum/extraction-warning.enum.js +1 -0
- package/dist/types/enum/extraction-warning.enum.js.map +1 -1
- package/dist/types/enum/rcb-bank.enum.js +252 -36
- package/dist/types/enum/rcb-bank.enum.js.map +1 -1
- package/dist/types/interface/models/extraction-fetched-provenance.dto.test.js +8 -2
- package/dist/types/interface/models/extraction-fetched-provenance.dto.test.js.map +1 -1
- package/dist/types/interface/models/extraction-plan.dto.test.js +6 -1
- package/dist/types/interface/models/extraction-plan.dto.test.js.map +1 -1
- package/dist/types/interface/models/extraction-spatial-template.dto.test.js +20 -3
- package/dist/types/interface/models/extraction-spatial-template.dto.test.js.map +1 -1
- package/dist/types/interface/models/extraction.dto.d.ts +0 -10
- package/dist/types/interface/models/extraction.dto.js.map +1 -1
- package/package.json +4 -1
- package/src/api/atlas-group.api.ts +4 -1
- package/src/api/atlas-page.api.ts +12 -6
- package/src/api/atlas.api.ts +12 -7
- package/src/api/atlas.public.api.ts +3 -1
- package/src/api/board-card.api.ts +6 -3
- package/src/api/board-column.api.ts +4 -1
- package/src/api/board-label.api.ts +7 -3
- package/src/api/board.api.ts +19 -10
- package/src/api/draw.api.ts +16 -12
- package/src/api/draw.public.api.ts +3 -1
- package/src/api/extraction-plan-preset.api.ts +64 -18
- package/src/api/extraction-settings.api.ts +2 -8
- package/src/api/extraction.api.ts +45 -52
- package/src/api/index.ts +0 -1
- package/src/api/probe-scan.api.test.ts +26 -0
- package/src/api/probe-scan.api.ts +66 -54
- package/src/api/probe-scan.application.api.test.ts +14 -0
- package/src/api/probe-scan.application.api.ts +5 -5
- package/src/api/retrospective.api.ts +8 -5
- package/src/api/short-link.admin.api.ts +14 -4
- package/src/api/short-link.api.ts +39 -17
- package/src/api/short-link.public.api.ts +25 -11
- package/src/api/tag.api.ts +3 -1
- package/src/index.ts +0 -17
- package/src/server-sent-events/server-sent-events.manager.ts +5 -3
- package/src/types/enum/document-type.enum.ts +0 -1
- package/src/types/enum/extraction-warning.enum.ts +16 -0
- package/src/types/enum/rcb-bank.enum.ts +255 -41
- package/src/types/interface/api/requests/probe-scan.request.ts +5 -1
- package/src/types/interface/api/responses/retrospective.response.ts +2 -1
- package/src/types/interface/models/content-share.dto.ts +5 -1
- package/src/types/interface/models/extraction-fetched-provenance.dto.test.ts +20 -9
- package/src/types/interface/models/extraction-plan.dto.test.ts +17 -4
- package/src/types/interface/models/extraction-spatial-template.dto.test.ts +26 -5
- package/src/types/interface/models/extraction.dto.ts +0 -17
- package/src/types/interface/models/probe-webhook.dto.ts +3 -4
- package/tsconfig.check.json +15 -0
- package/dist/api/extraction.application.api.d.ts +0 -4
- package/dist/api/extraction.application.api.js +0 -30
- package/dist/api/extraction.application.api.js.map +0 -1
- package/dist/api/memo.api.d.ts +0 -15
- package/dist/api/memo.api.js +0 -49
- package/dist/api/memo.api.js.map +0 -1
- package/dist/constants/memo.constants.d.ts +0 -3
- package/dist/constants/memo.constants.js +0 -7
- package/dist/constants/memo.constants.js.map +0 -1
- package/dist/types/interface/api/requests/memo.request.d.ts +0 -41
- package/dist/types/interface/api/requests/memo.request.js +0 -3
- package/dist/types/interface/api/requests/memo.request.js.map +0 -1
- package/dist/types/interface/api/responses/memo.response.d.ts +0 -27
- package/dist/types/interface/api/responses/memo.response.js +0 -3
- package/dist/types/interface/api/responses/memo.response.js.map +0 -1
- package/dist/types/interface/models/memo.dto.d.ts +0 -20
- package/dist/types/interface/models/memo.dto.js +0 -3
- package/dist/types/interface/models/memo.dto.js.map +0 -1
- package/src/api/extraction.application.api.ts +0 -74
|
@@ -55,7 +55,10 @@ export const createBoardLabel = async (
|
|
|
55
55
|
body: ICreateBoardLabelBody,
|
|
56
56
|
): Promise<ICreateBoardLabelResponse> => {
|
|
57
57
|
return (
|
|
58
|
-
await AbyssToolsCore.axios.post<ICreateBoardLabelResponse>(
|
|
58
|
+
await AbyssToolsCore.axios.post<ICreateBoardLabelResponse>(
|
|
59
|
+
`board/${params.boardId}/label`,
|
|
60
|
+
body,
|
|
61
|
+
)
|
|
59
62
|
).data;
|
|
60
63
|
};
|
|
61
64
|
|
|
@@ -82,6 +85,7 @@ export const removeBoardLabel = async (
|
|
|
82
85
|
export const listBoardLabels = async (
|
|
83
86
|
params: IListBoardLabelParams,
|
|
84
87
|
): Promise<IListBoardLabelResponse> => {
|
|
85
|
-
return (
|
|
86
|
-
.
|
|
88
|
+
return (
|
|
89
|
+
await AbyssToolsCore.axios.get<IListBoardLabelResponse>(`board/${params.boardId}/label/list`)
|
|
90
|
+
).data;
|
|
87
91
|
};
|
package/src/api/board.api.ts
CHANGED
|
@@ -31,7 +31,8 @@ export const getBoard = async (params: IGetBoardParams): Promise<IGetBoardRespon
|
|
|
31
31
|
export const getBySlugBoard = async (
|
|
32
32
|
params: IGetBySlugBoardParams,
|
|
33
33
|
): Promise<IGetBySlugBoardResponse> => {
|
|
34
|
-
return (await AbyssToolsCore.axios.get<IGetBySlugBoardResponse>(`board/slug/${params.slug}`))
|
|
34
|
+
return (await AbyssToolsCore.axios.get<IGetBySlugBoardResponse>(`board/slug/${params.slug}`))
|
|
35
|
+
.data;
|
|
35
36
|
};
|
|
36
37
|
|
|
37
38
|
export const deleteBoard = async (params: IDeleteBoardParams): Promise<IDeleteBoardResponse> => {
|
|
@@ -42,7 +43,8 @@ export const updateBoard = async (
|
|
|
42
43
|
params: IUpdateBoardParams,
|
|
43
44
|
body: IUpdateBoardBody,
|
|
44
45
|
): Promise<IUpdateBoardResponse> => {
|
|
45
|
-
return (await AbyssToolsCore.axios.put<IUpdateBoardResponse>(`board/${params.boardId}`, body))
|
|
46
|
+
return (await AbyssToolsCore.axios.put<IUpdateBoardResponse>(`board/${params.boardId}`, body))
|
|
47
|
+
.data;
|
|
46
48
|
};
|
|
47
49
|
|
|
48
50
|
export const createBoard = async (body: ICreateBoardBody): Promise<ICreateBoardResponse> => {
|
|
@@ -54,12 +56,18 @@ export const createForOrganizationBoard = async (
|
|
|
54
56
|
body: ICreateBoardBody,
|
|
55
57
|
): Promise<ICreateBoardResponse> => {
|
|
56
58
|
return (
|
|
57
|
-
await AbyssToolsCore.axios.post<ICreateBoardResponse>(
|
|
59
|
+
await AbyssToolsCore.axios.post<ICreateBoardResponse>(
|
|
60
|
+
`board/organization/${params.organizationId}`,
|
|
61
|
+
body,
|
|
62
|
+
)
|
|
58
63
|
).data;
|
|
59
64
|
};
|
|
60
65
|
|
|
61
|
-
export const listBoard = async (query?: {
|
|
62
|
-
|
|
66
|
+
export const listBoard = async (query?: {
|
|
67
|
+
sharedWithMe?: boolean;
|
|
68
|
+
}): Promise<IListBoardUserResponse> => {
|
|
69
|
+
return (await AbyssToolsCore.axios.get<IListBoardUserResponse>('board/list', { params: query }))
|
|
70
|
+
.data;
|
|
63
71
|
};
|
|
64
72
|
|
|
65
73
|
export const listBoardProject = async (params: {
|
|
@@ -71,8 +79,9 @@ export const listBoardProject = async (params: {
|
|
|
71
79
|
};
|
|
72
80
|
|
|
73
81
|
export const getNextCardPreviewBoard = async (): Promise<IGetNextCardPreviewBoardResponse> => {
|
|
74
|
-
return (
|
|
75
|
-
.
|
|
82
|
+
return (
|
|
83
|
+
await AbyssToolsCore.axios.post<IGetNextCardPreviewBoardResponse>(`board/next-card-preview`)
|
|
84
|
+
).data;
|
|
76
85
|
};
|
|
77
86
|
|
|
78
87
|
export const listBoardOrganization = async (
|
|
@@ -111,9 +120,9 @@ export const transferBoard = async (
|
|
|
111
120
|
).data;
|
|
112
121
|
};
|
|
113
122
|
|
|
114
|
-
export const countOrganizationBoard = async (
|
|
115
|
-
|
|
116
|
-
): Promise<ICountOrganizationResponse> => {
|
|
123
|
+
export const countOrganizationBoard = async (params: {
|
|
124
|
+
organizationId: string;
|
|
125
|
+
}): Promise<ICountOrganizationResponse> => {
|
|
117
126
|
return (
|
|
118
127
|
await AbyssToolsCore.axios.get<ICountOrganizationResponse>(
|
|
119
128
|
`board/organization/${params.organizationId}/count`,
|
package/src/api/draw.api.ts
CHANGED
|
@@ -29,9 +29,12 @@ export const paginateProjectDraw = async (
|
|
|
29
29
|
query: IPaginateDrawQuery,
|
|
30
30
|
): Promise<IPaginateDrawResponse> => {
|
|
31
31
|
return (
|
|
32
|
-
await AbyssToolsCore.axios.get<IPaginateDrawResponse>(
|
|
33
|
-
params
|
|
34
|
-
|
|
32
|
+
await AbyssToolsCore.axios.get<IPaginateDrawResponse>(
|
|
33
|
+
`project/${params.projectId}/draw/paginate`,
|
|
34
|
+
{
|
|
35
|
+
params: query,
|
|
36
|
+
},
|
|
37
|
+
)
|
|
35
38
|
).data;
|
|
36
39
|
};
|
|
37
40
|
|
|
@@ -58,8 +61,12 @@ export const createForOrganizationDraw = async (
|
|
|
58
61
|
params: ICreateForOrganizationDrawParams,
|
|
59
62
|
body: ICreateDrawBody,
|
|
60
63
|
): Promise<ICreateDrawResponse> => {
|
|
61
|
-
return (
|
|
62
|
-
.
|
|
64
|
+
return (
|
|
65
|
+
await AbyssToolsCore.axios.post<ICreateDrawResponse>(
|
|
66
|
+
`draw/organization/${params.organizationId}`,
|
|
67
|
+
body,
|
|
68
|
+
)
|
|
69
|
+
).data;
|
|
63
70
|
};
|
|
64
71
|
|
|
65
72
|
export const paginateOrganizationDraw = async (
|
|
@@ -79,16 +86,13 @@ export const transferDraw = async (
|
|
|
79
86
|
body: ITransferContentBody,
|
|
80
87
|
): Promise<ITransferDrawResponse> => {
|
|
81
88
|
return (
|
|
82
|
-
await AbyssToolsCore.axios.post<ITransferDrawResponse>(
|
|
83
|
-
`draw/${params.drawId}/transfer`,
|
|
84
|
-
body,
|
|
85
|
-
)
|
|
89
|
+
await AbyssToolsCore.axios.post<ITransferDrawResponse>(`draw/${params.drawId}/transfer`, body)
|
|
86
90
|
).data;
|
|
87
91
|
};
|
|
88
92
|
|
|
89
|
-
export const countOrganizationDraw = async (
|
|
90
|
-
|
|
91
|
-
): Promise<ICountOrganizationResponse> => {
|
|
93
|
+
export const countOrganizationDraw = async (params: {
|
|
94
|
+
organizationId: string;
|
|
95
|
+
}): Promise<ICountOrganizationResponse> => {
|
|
92
96
|
return (
|
|
93
97
|
await AbyssToolsCore.axios.get<ICountOrganizationResponse>(
|
|
94
98
|
`draw/organization/${params.organizationId}/count`,
|
|
@@ -15,7 +15,9 @@ export const getDrawPublic = async (
|
|
|
15
15
|
params: IGetDrawPublicParams,
|
|
16
16
|
): Promise<IGetDrawPublicResponse> => {
|
|
17
17
|
return (
|
|
18
|
-
await AbyssToolsCore.axios.get<IGetDrawPublicResponse>(
|
|
18
|
+
await AbyssToolsCore.axios.get<IGetDrawPublicResponse>(
|
|
19
|
+
`draw/public/${params.publicAccessToken}`,
|
|
20
|
+
)
|
|
19
21
|
).data;
|
|
20
22
|
};
|
|
21
23
|
|
|
@@ -11,11 +11,7 @@
|
|
|
11
11
|
// ──────────────────────────────────────────────
|
|
12
12
|
|
|
13
13
|
import { AbyssToolsCore } from '..';
|
|
14
|
-
import type {
|
|
15
|
-
ICreatePlanPresetBody,
|
|
16
|
-
IUpdatePlanPresetBody,
|
|
17
|
-
IListPlanPresetQuery,
|
|
18
|
-
} from '../types';
|
|
14
|
+
import type { ICreatePlanPresetBody, IUpdatePlanPresetBody, IListPlanPresetQuery } from '../types';
|
|
19
15
|
import type {
|
|
20
16
|
IListModesResponse,
|
|
21
17
|
IListPlanPresetsResponse,
|
|
@@ -30,22 +26,72 @@ function authHeader(apiKey?: string): Record<string, string> {
|
|
|
30
26
|
}
|
|
31
27
|
|
|
32
28
|
export const listModes = async (apiKey?: string): Promise<IListModesResponse> =>
|
|
33
|
-
(
|
|
29
|
+
(
|
|
30
|
+
await AbyssToolsCore.axios.get<IListModesResponse>(`extract/modes`, {
|
|
31
|
+
headers: authHeader(apiKey),
|
|
32
|
+
})
|
|
33
|
+
).data;
|
|
34
34
|
|
|
35
|
-
export const listExtractionPlanPresets = async (
|
|
36
|
-
|
|
35
|
+
export const listExtractionPlanPresets = async (
|
|
36
|
+
query: IListPlanPresetQuery = {},
|
|
37
|
+
apiKey?: string,
|
|
38
|
+
): Promise<IListPlanPresetsResponse> =>
|
|
39
|
+
(
|
|
40
|
+
await AbyssToolsCore.axios.get<IListPlanPresetsResponse>(`extract/plans`, {
|
|
41
|
+
params: query,
|
|
42
|
+
headers: authHeader(apiKey),
|
|
43
|
+
})
|
|
44
|
+
).data;
|
|
37
45
|
|
|
38
|
-
export const getExtractionPlanPreset = async (
|
|
39
|
-
|
|
46
|
+
export const getExtractionPlanPreset = async (
|
|
47
|
+
id: string,
|
|
48
|
+
apiKey?: string,
|
|
49
|
+
): Promise<IGetPlanPresetResponse> =>
|
|
50
|
+
(
|
|
51
|
+
await AbyssToolsCore.axios.get<IGetPlanPresetResponse>(`extract/plans/${id}`, {
|
|
52
|
+
headers: authHeader(apiKey),
|
|
53
|
+
})
|
|
54
|
+
).data;
|
|
40
55
|
|
|
41
|
-
export const createExtractionPlanPreset = async (
|
|
42
|
-
|
|
56
|
+
export const createExtractionPlanPreset = async (
|
|
57
|
+
body: ICreatePlanPresetBody,
|
|
58
|
+
apiKey?: string,
|
|
59
|
+
): Promise<IGetPlanPresetResponse> =>
|
|
60
|
+
(
|
|
61
|
+
await AbyssToolsCore.axios.post<IGetPlanPresetResponse>(`extract/plans`, body, {
|
|
62
|
+
headers: authHeader(apiKey),
|
|
63
|
+
})
|
|
64
|
+
).data;
|
|
43
65
|
|
|
44
|
-
export const updateExtractionPlanPreset = async (
|
|
45
|
-
|
|
66
|
+
export const updateExtractionPlanPreset = async (
|
|
67
|
+
id: string,
|
|
68
|
+
body: IUpdatePlanPresetBody,
|
|
69
|
+
apiKey?: string,
|
|
70
|
+
): Promise<IGetPlanPresetResponse> =>
|
|
71
|
+
(
|
|
72
|
+
await AbyssToolsCore.axios.put<IGetPlanPresetResponse>(`extract/plans/${id}`, body, {
|
|
73
|
+
headers: authHeader(apiKey),
|
|
74
|
+
})
|
|
75
|
+
).data;
|
|
46
76
|
|
|
47
|
-
export const deleteExtractionPlanPreset = async (
|
|
48
|
-
|
|
77
|
+
export const deleteExtractionPlanPreset = async (
|
|
78
|
+
id: string,
|
|
79
|
+
apiKey?: string,
|
|
80
|
+
): Promise<IDeletePlanPresetResponse> =>
|
|
81
|
+
(
|
|
82
|
+
await AbyssToolsCore.axios.delete<IDeletePlanPresetResponse>(`extract/plans/${id}`, {
|
|
83
|
+
headers: authHeader(apiKey),
|
|
84
|
+
})
|
|
85
|
+
).data;
|
|
49
86
|
|
|
50
|
-
export const setDefaultExtractionPlanPreset = async (
|
|
51
|
-
|
|
87
|
+
export const setDefaultExtractionPlanPreset = async (
|
|
88
|
+
id: string,
|
|
89
|
+
apiKey?: string,
|
|
90
|
+
): Promise<IGetPlanPresetResponse> =>
|
|
91
|
+
(
|
|
92
|
+
await AbyssToolsCore.axios.post<IGetPlanPresetResponse>(
|
|
93
|
+
`extract/plans/${id}/default`,
|
|
94
|
+
{},
|
|
95
|
+
{ headers: authHeader(apiKey) },
|
|
96
|
+
)
|
|
97
|
+
).data;
|
|
@@ -9,14 +9,8 @@
|
|
|
9
9
|
// ──────────────────────────────────────────────
|
|
10
10
|
|
|
11
11
|
import { AbyssToolsCore } from '..';
|
|
12
|
-
import type {
|
|
13
|
-
|
|
14
|
-
IUpsertExtractionSettingsBody,
|
|
15
|
-
} from '../types';
|
|
16
|
-
import type {
|
|
17
|
-
IGetExtractionSettingsResponse,
|
|
18
|
-
IUpsertExtractionSettingsResponse,
|
|
19
|
-
} from '../types';
|
|
12
|
+
import type { IGetExtractionSettingsQuery, IUpsertExtractionSettingsBody } from '../types';
|
|
13
|
+
import type { IGetExtractionSettingsResponse, IUpsertExtractionSettingsResponse } from '../types';
|
|
20
14
|
|
|
21
15
|
const DEFAULT_API_KEY_HEADER = 'abyss-api-key';
|
|
22
16
|
|
|
@@ -164,11 +164,54 @@ const postExtract = async (
|
|
|
164
164
|
}
|
|
165
165
|
const params = serializeParams(scope);
|
|
166
166
|
if (body.pdf) {
|
|
167
|
-
const
|
|
167
|
+
const isBrowser = typeof window !== 'undefined' && typeof FormData !== 'undefined';
|
|
168
|
+
const filename = body.pdf_filename ?? 'document.pdf';
|
|
169
|
+
if (isBrowser) {
|
|
170
|
+
const form = new FormData();
|
|
171
|
+
const blob = new Blob([body.pdf as Uint8Array], { type: 'application/pdf' });
|
|
172
|
+
form.append('file', blob, filename);
|
|
173
|
+
appendIf(form, 'mode', body.mode);
|
|
174
|
+
if (body.hint) form.append('hint', JSON.stringify(body.hint));
|
|
175
|
+
appendIf(form, 'template_id', body.template_id);
|
|
176
|
+
if (body.template) form.append('template', JSON.stringify(body.template));
|
|
177
|
+
appendIf(form, 'user_external_id', body.user_external_id);
|
|
178
|
+
if (body.user_metadata) form.append('user_metadata', JSON.stringify(body.user_metadata));
|
|
179
|
+
if (typeof body.archive === 'boolean') form.append('archive', String(body.archive));
|
|
180
|
+
if (typeof body.force === 'boolean') form.append('force', String(body.force));
|
|
181
|
+
if (body.processing) form.append('processing', body.processing);
|
|
182
|
+
return (
|
|
183
|
+
await AbyssToolsCore.axios.post(`extract/extract`, form, {
|
|
184
|
+
params,
|
|
185
|
+
headers: { ...authHeader(apiKey), ...extraHeaders },
|
|
186
|
+
maxBodyLength: Infinity,
|
|
187
|
+
maxContentLength: Infinity,
|
|
188
|
+
})
|
|
189
|
+
).data;
|
|
190
|
+
}
|
|
191
|
+
const FormDataCtor = await loadFormData();
|
|
192
|
+
const form = new FormDataCtor();
|
|
193
|
+
const buf = Buffer.isBuffer(body.pdf) ? body.pdf : Buffer.from(body.pdf);
|
|
194
|
+
form.append('file', buf, {
|
|
195
|
+
filename,
|
|
196
|
+
contentType: 'application/pdf',
|
|
197
|
+
});
|
|
198
|
+
appendIf(form, 'mode', body.mode);
|
|
199
|
+
if (body.hint) form.append('hint', JSON.stringify(body.hint));
|
|
200
|
+
appendIf(form, 'template_id', body.template_id);
|
|
201
|
+
if (body.template) form.append('template', JSON.stringify(body.template));
|
|
202
|
+
appendIf(form, 'user_external_id', body.user_external_id);
|
|
203
|
+
if (body.user_metadata) form.append('user_metadata', JSON.stringify(body.user_metadata));
|
|
204
|
+
if (typeof body.archive === 'boolean') form.append('archive', String(body.archive));
|
|
205
|
+
if (typeof body.force === 'boolean') form.append('force', String(body.force));
|
|
206
|
+
if (body.processing) form.append('processing', body.processing);
|
|
168
207
|
return (
|
|
169
208
|
await AbyssToolsCore.axios.post(`extract/extract`, form, {
|
|
170
209
|
params,
|
|
171
|
-
headers: {
|
|
210
|
+
headers: {
|
|
211
|
+
...(typeof form.getHeaders === 'function' ? form.getHeaders() : {}),
|
|
212
|
+
...authHeader(apiKey),
|
|
213
|
+
...extraHeaders,
|
|
214
|
+
},
|
|
172
215
|
maxBodyLength: Infinity,
|
|
173
216
|
maxContentLength: Infinity,
|
|
174
217
|
})
|
|
@@ -190,56 +233,6 @@ function appendIf(form: any, key: string, value: unknown): void {
|
|
|
190
233
|
form.append(key, String(value));
|
|
191
234
|
}
|
|
192
235
|
|
|
193
|
-
/** Append the shared extract text fields (all optional) onto a multipart form. */
|
|
194
|
-
function appendExtractFields(form: any, body: IExtractBody): void {
|
|
195
|
-
appendIf(form, 'mode', body.mode);
|
|
196
|
-
if (body.hint) form.append('hint', JSON.stringify(body.hint));
|
|
197
|
-
appendIf(form, 'template_id', body.template_id);
|
|
198
|
-
if (body.template) form.append('template', JSON.stringify(body.template));
|
|
199
|
-
appendIf(form, 'user_external_id', body.user_external_id);
|
|
200
|
-
if (body.user_metadata) form.append('user_metadata', JSON.stringify(body.user_metadata));
|
|
201
|
-
if (typeof body.archive === 'boolean') form.append('archive', String(body.archive));
|
|
202
|
-
if (typeof body.force === 'boolean') form.append('force', String(body.force));
|
|
203
|
-
if (body.processing) form.append('processing', body.processing);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* Build the multipart form for an extract upload — browser `FormData`/`Blob`
|
|
208
|
-
* or Node `Buffer` + lazy-required `form-data` — shared by the personal and
|
|
209
|
-
* application extract clients. Returns the form plus the content-type headers
|
|
210
|
-
* it needs (empty for the browser, which sets its own boundary;
|
|
211
|
-
* `form.getHeaders()` for Node). Scope params + auth headers are added by the
|
|
212
|
-
* caller. Requires `body.pdf` to be set.
|
|
213
|
-
*/
|
|
214
|
-
export async function buildExtractMultipart(
|
|
215
|
-
body: IExtractBody,
|
|
216
|
-
): Promise<{ form: any; formHeaders: Record<string, string> }> {
|
|
217
|
-
const pdf = body.pdf;
|
|
218
|
-
if (!pdf) {
|
|
219
|
-
// Precondition: only the multipart-upload path calls this (both callers
|
|
220
|
-
// guard on `body.pdf` first). Enforced here so the helper is self-contained.
|
|
221
|
-
throw new Error('buildExtractMultipart requires body.pdf');
|
|
222
|
-
}
|
|
223
|
-
const isBrowser = typeof window !== 'undefined' && typeof FormData !== 'undefined';
|
|
224
|
-
const filename = body.pdf_filename ?? 'document.pdf';
|
|
225
|
-
if (isBrowser) {
|
|
226
|
-
const form = new FormData();
|
|
227
|
-
const blob = new Blob([pdf as Uint8Array], { type: 'application/pdf' });
|
|
228
|
-
form.append('file', blob, filename);
|
|
229
|
-
appendExtractFields(form, body);
|
|
230
|
-
return { form, formHeaders: {} };
|
|
231
|
-
}
|
|
232
|
-
const FormDataCtor = await loadFormData();
|
|
233
|
-
const form = new FormDataCtor();
|
|
234
|
-
const buf = Buffer.isBuffer(pdf) ? pdf : Buffer.from(pdf);
|
|
235
|
-
form.append('file', buf, { filename, contentType: 'application/pdf' });
|
|
236
|
-
appendExtractFields(form, body);
|
|
237
|
-
return {
|
|
238
|
-
form,
|
|
239
|
-
formHeaders: typeof form.getHeaders === 'function' ? form.getHeaders() : {},
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
|
|
243
236
|
export const extractBulk = async (
|
|
244
237
|
body: IExtractBulkBody,
|
|
245
238
|
scope: IExtractionContentScopeQuery = {},
|
package/src/api/index.ts
CHANGED
|
@@ -18,4 +18,30 @@ void _scanAsync;
|
|
|
18
18
|
void _getScan;
|
|
19
19
|
void _listScans;
|
|
20
20
|
|
|
21
|
+
// The accepted file inputs (#519). A Blob covers the browser's File and Node's
|
|
22
|
+
// file-backed fs.openAsBlob(path); raw bytes are accepted as a Uint8Array (and
|
|
23
|
+
// therefore a Buffer). A Node stream is refused AT COMPILE TIME: the body is a
|
|
24
|
+
// spec FormData, whose parts need a known length, so honouring a stream would
|
|
25
|
+
// mean buffering up to 2 GiB in memory.
|
|
26
|
+
declare const blob: Blob;
|
|
27
|
+
declare const bytes: Uint8Array;
|
|
28
|
+
declare const buffer: Buffer;
|
|
29
|
+
declare const stream: NodeJS.ReadableStream;
|
|
30
|
+
|
|
31
|
+
const _fromBlob: api.ProbeScanFileInput = blob;
|
|
32
|
+
const _fromBytes: api.ProbeScanFileInput = bytes;
|
|
33
|
+
const _fromBuffer: api.ProbeScanFileInput = buffer;
|
|
34
|
+
// @ts-expect-error a Readable stream is not an accepted scan input since 2.12.0
|
|
35
|
+
const _fromStream: api.ProbeScanFileInput = stream;
|
|
36
|
+
|
|
37
|
+
void _fromBlob;
|
|
38
|
+
void _fromBytes;
|
|
39
|
+
void _fromBuffer;
|
|
40
|
+
void _fromStream;
|
|
41
|
+
|
|
42
|
+
// buildScanForm returns the FormData alone — axios sets the multipart
|
|
43
|
+
// content type and boundary, so there are no headers to merge in.
|
|
44
|
+
const _form: FormData = api.buildScanForm(blob, { filename: 'f.bin' });
|
|
45
|
+
void _form;
|
|
46
|
+
|
|
21
47
|
export {};
|
|
@@ -6,13 +6,20 @@
|
|
|
6
6
|
// add no extra path segment (`@Controller({ prefixPath: '/scan' })`), so
|
|
7
7
|
// these calls hit `scan`/`scan/:id` directly — no `probe/` prefix.
|
|
8
8
|
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
// extraction.api.ts
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
9
|
+
// Multipart bodies are built with the global `FormData` + `Blob` — the same
|
|
10
|
+
// code in a browser and on Node, mirroring this package's own
|
|
11
|
+
// extraction.api.ts. axios serializes a spec-compliant FormData on both and
|
|
12
|
+
// sets the multipart boundary itself, so no content-type header is ever set by
|
|
13
|
+
// hand. AbyssProbe is called from the abyss-main UI (a browser) as well as
|
|
14
|
+
// from Node services (abyss-storage, external integrators).
|
|
15
|
+
//
|
|
16
|
+
// A Node caller holding a file ON DISK passes `await fs.openAsBlob(path)`,
|
|
17
|
+
// which requires Node >= 19.8 — hence `engines.node` in package.json.
|
|
18
|
+
// `FormData` and `Blob` alone would only need Node 18, but openAsBlob is this
|
|
19
|
+
// client's documented way to send a file, and promising 18.x only to fail at
|
|
20
|
+
// runtime is worse than refusing the install. A caller that already holds its
|
|
21
|
+
// bytes passes a `Buffer`/`Uint8Array` and has no such constraint (see
|
|
22
|
+
// {@link ProbeScanFileInput}).
|
|
16
23
|
//
|
|
17
24
|
// `authHeader`/`serializeProbeQuery` are kept LOCAL and unexported (not a
|
|
18
25
|
// shared utils file) — same convention as every other extract/*.api.ts file
|
|
@@ -61,60 +68,65 @@ function serializeProbeQuery<T extends object>(query: T): Record<string, unknown
|
|
|
61
68
|
return out;
|
|
62
69
|
}
|
|
63
70
|
|
|
64
|
-
/**
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
71
|
+
/**
|
|
72
|
+
* Anything `sdk.probe.scan` accepts as the file to submit.
|
|
73
|
+
*
|
|
74
|
+
* `Blob` covers the browser's `File` (a `Blob` subclass) and, on Node, a
|
|
75
|
+
* FILE-BACKED blob from `await fs.openAsBlob(path)` (Node >= 19.8): its bytes
|
|
76
|
+
* are read from disk as the request body is written, so scanning a file at the
|
|
77
|
+
* 2 GiB ceiling never holds the file in memory. `Uint8Array` (and therefore
|
|
78
|
+
* `Buffer`) is for a caller that already holds the bytes.
|
|
79
|
+
*
|
|
80
|
+
* A Node `Readable` is NOT accepted. The body is a spec `FormData`, whose
|
|
81
|
+
* parts must have a known length, so a stream could only be honoured by
|
|
82
|
+
* buffering it whole — precisely what a 2 GiB scan must not do. A caller
|
|
83
|
+
* holding a path passes `await fs.openAsBlob(path)` instead.
|
|
84
|
+
*/
|
|
85
|
+
export type ProbeScanFileInput = Blob | Uint8Array;
|
|
79
86
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
87
|
+
/**
|
|
88
|
+
* The file as one multipart part.
|
|
89
|
+
*
|
|
90
|
+
* A `Blob` is used as-is, keeping whatever streaming its implementation gives
|
|
91
|
+
* (a file-backed `openAsBlob` reads from disk lazily); raw bytes are wrapped
|
|
92
|
+
* in a `Blob` carrying `mimeType`. `Buffer` is never named here — this code
|
|
93
|
+
* also runs in a browser bundle, where the global does not exist — and
|
|
94
|
+
* `Buffer` is a `Uint8Array` subclass, so the check below already covers it.
|
|
95
|
+
*
|
|
96
|
+
* Anything else is refused with an actionable message. Until 2.12.0 the same
|
|
97
|
+
* call died on Node with `ReferenceError: require is not defined`, thrown by a
|
|
98
|
+
* `form-data` loader before any request was made (#519): it named neither the
|
|
99
|
+
* cause nor the fix.
|
|
100
|
+
*/
|
|
101
|
+
function toScanFilePart(file: ProbeScanFileInput, mimeType?: string): Blob {
|
|
102
|
+
if (file instanceof Blob) return file;
|
|
103
|
+
if (file instanceof Uint8Array) return new Blob([file], { type: mimeType ?? '' });
|
|
104
|
+
|
|
105
|
+
const isStream = typeof (file as { pipe?: unknown } | null | undefined)?.pipe === 'function';
|
|
106
|
+
throw new TypeError(
|
|
107
|
+
`A probe scan file must be a Blob (a browser File, or fs.openAsBlob(path) on Node), ` +
|
|
108
|
+
`a Buffer or a Uint8Array — received ${isStream ? 'a stream' : typeof file}. ` +
|
|
109
|
+
`On Node, pass \`await fs.openAsBlob(path)\`: a file-backed Blob is streamed from ` +
|
|
110
|
+
`disk, so the file is never buffered in memory.`,
|
|
111
|
+
);
|
|
83
112
|
}
|
|
84
113
|
|
|
85
114
|
/**
|
|
86
115
|
* Exported (not just this file's own `scan` internals) so
|
|
87
116
|
* probe-scan.application.api.ts reuses this EXACT multipart-building logic
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
117
|
+
* rather than duplicating it — the file-upload contract is identical for a
|
|
118
|
+
* personal/org caller and an application caller; only the URL/auth differ
|
|
119
|
+
* (see that file's header comment).
|
|
120
|
+
*
|
|
121
|
+
* Returns the form alone: axios sets the multipart content type, boundary
|
|
122
|
+
* included, so there is no header for the caller to merge in.
|
|
92
123
|
*/
|
|
93
|
-
export
|
|
94
|
-
|
|
95
|
-
options
|
|
96
|
-
): Promise<BuiltScanForm> {
|
|
97
|
-
const filename = options.filename ?? 'file';
|
|
98
|
-
|
|
99
|
-
if (isBrowserEnv()) {
|
|
100
|
-
const form = new FormData();
|
|
101
|
-
const blob =
|
|
102
|
-
file instanceof Blob ? file : new Blob([file as BlobPart], { type: options.mimeType });
|
|
103
|
-
form.append('file', blob, filename);
|
|
104
|
-
if (options.context) form.append('context', JSON.stringify(options.context));
|
|
105
|
-
if (options.callbackUrl) form.append('callbackUrl', options.callbackUrl);
|
|
106
|
-
return { form, headers: {} };
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
const FormDataCtor = await loadNodeFormData();
|
|
110
|
-
const form = new FormDataCtor();
|
|
111
|
-
const filePart =
|
|
112
|
-
Buffer.isBuffer(file) || file instanceof Uint8Array ? Buffer.from(file as Uint8Array) : file;
|
|
113
|
-
form.append('file', filePart, { filename, contentType: options.mimeType });
|
|
124
|
+
export function buildScanForm(file: ProbeScanFileInput, options: IScanOptions): FormData {
|
|
125
|
+
const form = new FormData();
|
|
126
|
+
form.append('file', toScanFilePart(file, options.mimeType), options.filename ?? 'file');
|
|
114
127
|
if (options.context) form.append('context', JSON.stringify(options.context));
|
|
115
128
|
if (options.callbackUrl) form.append('callbackUrl', options.callbackUrl);
|
|
116
|
-
|
|
117
|
-
return { form, headers };
|
|
129
|
+
return form;
|
|
118
130
|
}
|
|
119
131
|
|
|
120
132
|
/**
|
|
@@ -134,11 +146,11 @@ export const scan = async (
|
|
|
134
146
|
options: IScanOptions = {},
|
|
135
147
|
apiKey?: string,
|
|
136
148
|
): Promise<IScanResponse> => {
|
|
137
|
-
const
|
|
149
|
+
const form = buildScanForm(file, options);
|
|
138
150
|
return (
|
|
139
151
|
await AbyssToolsCore.axios.post<IScanResponse>('scan', form, {
|
|
140
152
|
params: serializeProbeQuery({ mode: options.mode, organizationId: options.organizationId }),
|
|
141
|
-
headers:
|
|
153
|
+
headers: authHeader(apiKey),
|
|
142
154
|
maxBodyLength: Infinity,
|
|
143
155
|
maxContentLength: Infinity,
|
|
144
156
|
})
|
|
@@ -18,4 +18,18 @@ void _scanAsync;
|
|
|
18
18
|
void _getScan;
|
|
19
19
|
void _listScans;
|
|
20
20
|
|
|
21
|
+
// The application client takes the SAME file input as the personal one (it
|
|
22
|
+
// reuses buildScanForm verbatim) — abyss-storage, its main caller, hands over
|
|
23
|
+
// `await fs.openAsBlob(path)`. A stream is refused at compile time (#519); see
|
|
24
|
+
// probe-scan.api.test.ts for the full input matrix.
|
|
25
|
+
declare const blob: Blob;
|
|
26
|
+
declare const stream: NodeJS.ReadableStream;
|
|
27
|
+
|
|
28
|
+
const _fromBlob: Parameters<typeof api.scanSyncApplication>[1] = blob;
|
|
29
|
+
// @ts-expect-error a Readable stream is not an accepted scan input since 2.12.0
|
|
30
|
+
const _fromStream: Parameters<typeof api.scanSyncApplication>[1] = stream;
|
|
31
|
+
|
|
32
|
+
void _fromBlob;
|
|
33
|
+
void _fromStream;
|
|
34
|
+
|
|
21
35
|
export {};
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
// (abyss-storage, external integrations) authenticating with a project API
|
|
9
9
|
// key instead of a personal/org session.
|
|
10
10
|
//
|
|
11
|
-
// Reuses probe-scan.api.ts's `buildScanForm` (
|
|
12
|
-
//
|
|
13
|
-
//
|
|
11
|
+
// Reuses probe-scan.api.ts's `buildScanForm` (the global `FormData` + `Blob`,
|
|
12
|
+
// one code path for the browser and for Node — see that file's header for what
|
|
13
|
+
// a Node caller passes) and every request/response TYPE verbatim
|
|
14
14
|
// (`IScanOptions`, `IListScansQuery`, `IScanResponse`, `IScanSyncResponse`,
|
|
15
15
|
// `IScanAsyncResponse`, `IGetScanResponse`, `IPaginateScanResponse`) — never
|
|
16
16
|
// redefined here. `organizationId` is `Omit`'d from every option/query type
|
|
@@ -79,11 +79,11 @@ export const scanApplication = async (
|
|
|
79
79
|
options: Omit<IScanOptions, 'organizationId'> = {},
|
|
80
80
|
applicationApiKey?: string,
|
|
81
81
|
): Promise<IScanResponse> => {
|
|
82
|
-
const
|
|
82
|
+
const form = buildScanForm(file, options);
|
|
83
83
|
return (
|
|
84
84
|
await AbyssToolsCore.axios.post<IScanResponse>(`application/${applicationId}/scan`, form, {
|
|
85
85
|
params: serializeProbeQuery({ mode: options.mode }),
|
|
86
|
-
headers:
|
|
86
|
+
headers: authHeaderApplication(applicationApiKey),
|
|
87
87
|
maxBodyLength: Infinity,
|
|
88
88
|
maxContentLength: Infinity,
|
|
89
89
|
})
|