@knowledge-stack/ksapi 1.146.0 → 1.147.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.
@@ -25,6 +25,7 @@ import type {
25
25
  HTTPValidationError,
26
26
  ImageTaxonomy,
27
27
  IngestDocumentResponse,
28
+ IngestZipResponse,
28
29
  IngestionMode,
29
30
  PaginatedResponseDocumentResponse,
30
31
  PathOrder,
@@ -52,6 +53,8 @@ import {
52
53
  ImageTaxonomyToJSON,
53
54
  IngestDocumentResponseFromJSON,
54
55
  IngestDocumentResponseToJSON,
56
+ IngestZipResponseFromJSON,
57
+ IngestZipResponseToJSON,
55
58
  IngestionModeFromJSON,
56
59
  IngestionModeToJSON,
57
60
  PaginatedResponseDocumentResponseFromJSON,
@@ -105,6 +108,12 @@ export interface IngestDocumentVersionRequest {
105
108
  workflowDefinitionId?: string | null;
106
109
  }
107
110
 
111
+ export interface IngestZipRequest {
112
+ file: Blob;
113
+ pathPartId: string;
114
+ ingestionMode?: IngestionMode;
115
+ }
116
+
108
117
  export interface ListDocumentsRequest {
109
118
  parentPathPartId?: string | null;
110
119
  sortOrder?: PathOrder;
@@ -309,6 +318,34 @@ export interface DocumentsApiInterface {
309
318
  */
310
319
  ingestDocumentVersion(requestParameters: IngestDocumentVersionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<IngestDocumentResponse>;
311
320
 
321
+ /**
322
+ * Creates request options for ingestZip without sending the request
323
+ * @param {Blob} file
324
+ * @param {string} pathPartId Parent path part ID (must be a FOLDER type)
325
+ * @param {IngestionMode} [ingestionMode]
326
+ * @throws {RequiredError}
327
+ * @memberof DocumentsApiInterface
328
+ */
329
+ ingestZipRequestOpts(requestParameters: IngestZipRequest): Promise<runtime.RequestOpts>;
330
+
331
+ /**
332
+ * Upload a ZIP archive and ingest each member file individually. Directory structure inside the ZIP is preserved as FOLDER PathParts under the target folder. Returns 202 with per-file outcomes — each file that ingests successfully has its own Temporal workflow ID to poll for status. Whole-archive failures (not a ZIP, zip-bomb, >500 files) return 400 before any DB writes. Per-file failures (unsupported type, oversized) are included in the response with ``error`` set; other files continue processing.
333
+ * @summary Ingest Zip Handler
334
+ * @param {Blob} file
335
+ * @param {string} pathPartId Parent path part ID (must be a FOLDER type)
336
+ * @param {IngestionMode} [ingestionMode]
337
+ * @param {*} [options] Override http request option.
338
+ * @throws {RequiredError}
339
+ * @memberof DocumentsApiInterface
340
+ */
341
+ ingestZipRaw(requestParameters: IngestZipRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<IngestZipResponse>>;
342
+
343
+ /**
344
+ * Upload a ZIP archive and ingest each member file individually. Directory structure inside the ZIP is preserved as FOLDER PathParts under the target folder. Returns 202 with per-file outcomes — each file that ingests successfully has its own Temporal workflow ID to poll for status. Whole-archive failures (not a ZIP, zip-bomb, >500 files) return 400 before any DB writes. Per-file failures (unsupported type, oversized) are included in the response with ``error`` set; other files continue processing.
345
+ * Ingest Zip Handler
346
+ */
347
+ ingestZip(requestParameters: IngestZipRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<IngestZipResponse>;
348
+
312
349
  /**
313
350
  * Creates request options for listDocuments without sending the request
314
351
  * @param {string} [parentPathPartId] Parent PathPart ID (defaults to root)
@@ -836,6 +873,96 @@ export class DocumentsApi extends runtime.BaseAPI implements DocumentsApiInterfa
836
873
  return await response.value();
837
874
  }
838
875
 
876
+ /**
877
+ * Creates request options for ingestZip without sending the request
878
+ */
879
+ async ingestZipRequestOpts(requestParameters: IngestZipRequest): Promise<runtime.RequestOpts> {
880
+ if (requestParameters['file'] == null) {
881
+ throw new runtime.RequiredError(
882
+ 'file',
883
+ 'Required parameter "file" was null or undefined when calling ingestZip().'
884
+ );
885
+ }
886
+
887
+ if (requestParameters['pathPartId'] == null) {
888
+ throw new runtime.RequiredError(
889
+ 'pathPartId',
890
+ 'Required parameter "pathPartId" was null or undefined when calling ingestZip().'
891
+ );
892
+ }
893
+
894
+ const queryParameters: any = {};
895
+
896
+ const headerParameters: runtime.HTTPHeaders = {};
897
+
898
+ if (this.configuration && this.configuration.accessToken) {
899
+ const token = this.configuration.accessToken;
900
+ const tokenString = await token("bearerAuth", []);
901
+
902
+ if (tokenString) {
903
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
904
+ }
905
+ }
906
+ const consumes: runtime.Consume[] = [
907
+ { contentType: 'multipart/form-data' },
908
+ ];
909
+ // @ts-ignore: canConsumeForm may be unused
910
+ const canConsumeForm = runtime.canConsumeForm(consumes);
911
+
912
+ let formParams: { append(param: string, value: any): any };
913
+ let useForm = false;
914
+ // use FormData to transmit files using content-type "multipart/form-data"
915
+ useForm = canConsumeForm;
916
+ if (useForm) {
917
+ formParams = new FormData();
918
+ } else {
919
+ formParams = new URLSearchParams();
920
+ }
921
+
922
+ if (requestParameters['file'] != null) {
923
+ formParams.append('file', requestParameters['file'] as any);
924
+ }
925
+
926
+ if (requestParameters['pathPartId'] != null) {
927
+ formParams.append('path_part_id', requestParameters['pathPartId'] as any);
928
+ }
929
+
930
+ if (requestParameters['ingestionMode'] != null) {
931
+ formParams.append('ingestion_mode', requestParameters['ingestionMode'] as any);
932
+ }
933
+
934
+
935
+ let urlPath = `/v1/documents/ingest-zip`;
936
+
937
+ return {
938
+ path: urlPath,
939
+ method: 'POST',
940
+ headers: headerParameters,
941
+ query: queryParameters,
942
+ body: formParams,
943
+ };
944
+ }
945
+
946
+ /**
947
+ * Upload a ZIP archive and ingest each member file individually. Directory structure inside the ZIP is preserved as FOLDER PathParts under the target folder. Returns 202 with per-file outcomes — each file that ingests successfully has its own Temporal workflow ID to poll for status. Whole-archive failures (not a ZIP, zip-bomb, >500 files) return 400 before any DB writes. Per-file failures (unsupported type, oversized) are included in the response with ``error`` set; other files continue processing.
948
+ * Ingest Zip Handler
949
+ */
950
+ async ingestZipRaw(requestParameters: IngestZipRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<IngestZipResponse>> {
951
+ const requestOptions = await this.ingestZipRequestOpts(requestParameters);
952
+ const response = await this.request(requestOptions, initOverrides);
953
+
954
+ return new runtime.JSONApiResponse(response, (jsonValue) => IngestZipResponseFromJSON(jsonValue));
955
+ }
956
+
957
+ /**
958
+ * Upload a ZIP archive and ingest each member file individually. Directory structure inside the ZIP is preserved as FOLDER PathParts under the target folder. Returns 202 with per-file outcomes — each file that ingests successfully has its own Temporal workflow ID to poll for status. Whole-archive failures (not a ZIP, zip-bomb, >500 files) return 400 before any DB writes. Per-file failures (unsupported type, oversized) are included in the response with ``error`` set; other files continue processing.
959
+ * Ingest Zip Handler
960
+ */
961
+ async ingestZip(requestParameters: IngestZipRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<IngestZipResponse> {
962
+ const response = await this.ingestZipRaw(requestParameters, initOverrides);
963
+ return await response.value();
964
+ }
965
+
839
966
  /**
840
967
  * Creates request options for listDocuments without sending the request
841
968
  */
@@ -0,0 +1,127 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * Knowledge Stack API
5
+ * Knowledge Stack backend API for authentication and knowledge management. ## Integrating (RPA / machine clients) **Base URL.** Knowledge Stack is self-hosted — point at your own deployment host (see `servers`). The `localhost` entry is for local development only. **Authentication.** Send `Authorization: Bearer <api-key>` on every request. Mint an API key once via `POST /v1/api-keys` from a signed-in browser session; the raw `sk-user-...` secret is returned **only** at creation, so store it then. A key inherits its owning user\'s live tenant role and path permissions — create RPA keys from a least-privilege user, and set `expires_at` for rotation. The `ks_uat` cookie scheme is browser-only and cannot be used by headless clients. **Async work is polled, not pushed.** There are no outbound webhooks. - `POST /v1/documents/ingest` returns `201` immediately with a `workflow_id`; poll `GET /v1/system-jobs/document_versions/{workflow_id}` until `status` is terminal (anything other than `pending`/`processing`). The `Location` response header points at this poll resource. - `POST /v1/workflow-runs/{run_id}/start` returns `202`; poll `GET /v1/workflow-runs/{run_id}` until `execution_state` is `COMPLETED` or `FAILED`. The `Location` header points at the run resource. - `POST /v1/agent/ask` is **synchronous** — it blocks until the agent finishes and returns the answer inline. Use a generous HTTP timeout. **Pagination.** List endpoints accept `limit`/`offset` and return `{items, total, limit, offset}`. **Errors.** Every non-2xx body is `{detail, code, request_id}`. `code` is a stable value from a closed set (see the `ErrorResponse` schema\'s `code` enum) — branch on it rather than parsing `detail`. Quota rejections return `429` with a `Retry-After` header; transient lock contention returns a retryable `503`. Quote `request_id` (also the `x-request-id` response header) to support. **Idempotency.** `POST /v1/workflow-runs` accepts an `idempotency_key` to dedupe retried run creation. `agent/ask` charges one message *before* running and does not refund a client-cancelled call.
6
+ *
7
+ * The version of the OpenAPI document: 0.1.0
8
+ *
9
+ *
10
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11
+ * https://openapi-generator.tech
12
+ * Do not edit the class manually.
13
+ */
14
+
15
+ import { mapValues } from '../runtime';
16
+ import type { ZipFileResult } from './ZipFileResult';
17
+ import {
18
+ ZipFileResultFromJSON,
19
+ ZipFileResultFromJSONTyped,
20
+ ZipFileResultToJSON,
21
+ ZipFileResultToJSONTyped,
22
+ } from './ZipFileResult';
23
+
24
+ /**
25
+ * Aggregate response from a ZIP ingestion batch.
26
+ * @export
27
+ * @interface IngestZipResponse
28
+ */
29
+ export interface IngestZipResponse {
30
+ /**
31
+ *
32
+ * @type {Array<ZipFileResult>}
33
+ * @memberof IngestZipResponse
34
+ */
35
+ files: Array<ZipFileResult>;
36
+ /**
37
+ *
38
+ * @type {number}
39
+ * @memberof IngestZipResponse
40
+ */
41
+ totalFound: number;
42
+ /**
43
+ *
44
+ * @type {number}
45
+ * @memberof IngestZipResponse
46
+ */
47
+ succeeded: number;
48
+ /**
49
+ *
50
+ * @type {number}
51
+ * @memberof IngestZipResponse
52
+ */
53
+ skipped: number;
54
+ /**
55
+ *
56
+ * @type {number}
57
+ * @memberof IngestZipResponse
58
+ */
59
+ failed: number;
60
+ }
61
+ export const IngestZipResponsePropertyValidationAttributesMap: {
62
+ [property: string]: {
63
+ maxLength?: number,
64
+ minLength?: number,
65
+ pattern?: string,
66
+ maximum?: number,
67
+ exclusiveMaximum?: boolean,
68
+ minimum?: number,
69
+ exclusiveMinimum?: boolean,
70
+ multipleOf?: number,
71
+ maxItems?: number,
72
+ minItems?: number,
73
+ uniqueItems?: boolean
74
+ }
75
+ } = {
76
+ }
77
+
78
+
79
+ /**
80
+ * Check if a given object implements the IngestZipResponse interface.
81
+ */
82
+ export function instanceOfIngestZipResponse(value: object): value is IngestZipResponse {
83
+ if (!('files' in value) || value['files'] === undefined) return false;
84
+ if (!('totalFound' in value) || value['totalFound'] === undefined) return false;
85
+ if (!('succeeded' in value) || value['succeeded'] === undefined) return false;
86
+ if (!('skipped' in value) || value['skipped'] === undefined) return false;
87
+ if (!('failed' in value) || value['failed'] === undefined) return false;
88
+ return true;
89
+ }
90
+
91
+ export function IngestZipResponseFromJSON(json: any): IngestZipResponse {
92
+ return IngestZipResponseFromJSONTyped(json, false);
93
+ }
94
+
95
+ export function IngestZipResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): IngestZipResponse {
96
+ if (json == null) {
97
+ return json;
98
+ }
99
+ return {
100
+
101
+ 'files': ((json['files'] as Array<any>).map(ZipFileResultFromJSON)),
102
+ 'totalFound': json['total_found'],
103
+ 'succeeded': json['succeeded'],
104
+ 'skipped': json['skipped'],
105
+ 'failed': json['failed'],
106
+ };
107
+ }
108
+
109
+ export function IngestZipResponseToJSON(json: any): IngestZipResponse {
110
+ return IngestZipResponseToJSONTyped(json, false);
111
+ }
112
+
113
+ export function IngestZipResponseToJSONTyped(value?: IngestZipResponse | null, ignoreDiscriminator: boolean = false): any {
114
+ if (value == null) {
115
+ return value;
116
+ }
117
+
118
+ return {
119
+
120
+ 'files': ((value['files'] as Array<any>).map(ZipFileResultToJSON)),
121
+ 'total_found': value['totalFound'],
122
+ 'succeeded': value['succeeded'],
123
+ 'skipped': value['skipped'],
124
+ 'failed': value['failed'],
125
+ };
126
+ }
127
+
@@ -0,0 +1,123 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * Knowledge Stack API
5
+ * Knowledge Stack backend API for authentication and knowledge management. ## Integrating (RPA / machine clients) **Base URL.** Knowledge Stack is self-hosted — point at your own deployment host (see `servers`). The `localhost` entry is for local development only. **Authentication.** Send `Authorization: Bearer <api-key>` on every request. Mint an API key once via `POST /v1/api-keys` from a signed-in browser session; the raw `sk-user-...` secret is returned **only** at creation, so store it then. A key inherits its owning user\'s live tenant role and path permissions — create RPA keys from a least-privilege user, and set `expires_at` for rotation. The `ks_uat` cookie scheme is browser-only and cannot be used by headless clients. **Async work is polled, not pushed.** There are no outbound webhooks. - `POST /v1/documents/ingest` returns `201` immediately with a `workflow_id`; poll `GET /v1/system-jobs/document_versions/{workflow_id}` until `status` is terminal (anything other than `pending`/`processing`). The `Location` response header points at this poll resource. - `POST /v1/workflow-runs/{run_id}/start` returns `202`; poll `GET /v1/workflow-runs/{run_id}` until `execution_state` is `COMPLETED` or `FAILED`. The `Location` header points at the run resource. - `POST /v1/agent/ask` is **synchronous** — it blocks until the agent finishes and returns the answer inline. Use a generous HTTP timeout. **Pagination.** List endpoints accept `limit`/`offset` and return `{items, total, limit, offset}`. **Errors.** Every non-2xx body is `{detail, code, request_id}`. `code` is a stable value from a closed set (see the `ErrorResponse` schema\'s `code` enum) — branch on it rather than parsing `detail`. Quota rejections return `429` with a `Retry-After` header; transient lock contention returns a retryable `503`. Quote `request_id` (also the `x-request-id` response header) to support. **Idempotency.** `POST /v1/workflow-runs` accepts an `idempotency_key` to dedupe retried run creation. `agent/ask` charges one message *before* running and does not refund a client-cancelled call.
6
+ *
7
+ * The version of the OpenAPI document: 0.1.0
8
+ *
9
+ *
10
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11
+ * https://openapi-generator.tech
12
+ * Do not edit the class manually.
13
+ */
14
+
15
+ import { mapValues } from '../runtime';
16
+ /**
17
+ * Per-file outcome from a ZIP ingestion batch.
18
+ * @export
19
+ * @interface ZipFileResult
20
+ */
21
+ export interface ZipFileResult {
22
+ /**
23
+ *
24
+ * @type {string}
25
+ * @memberof ZipFileResult
26
+ */
27
+ zipPath: string;
28
+ /**
29
+ *
30
+ * @type {string}
31
+ * @memberof ZipFileResult
32
+ */
33
+ documentId?: string | null;
34
+ /**
35
+ *
36
+ * @type {string}
37
+ * @memberof ZipFileResult
38
+ */
39
+ documentVersionId?: string | null;
40
+ /**
41
+ *
42
+ * @type {string}
43
+ * @memberof ZipFileResult
44
+ */
45
+ workflowId?: string | null;
46
+ /**
47
+ *
48
+ * @type {boolean}
49
+ * @memberof ZipFileResult
50
+ */
51
+ skipped?: boolean;
52
+ /**
53
+ *
54
+ * @type {string}
55
+ * @memberof ZipFileResult
56
+ */
57
+ error?: string | null;
58
+ }
59
+ export const ZipFileResultPropertyValidationAttributesMap: {
60
+ [property: string]: {
61
+ maxLength?: number,
62
+ minLength?: number,
63
+ pattern?: string,
64
+ maximum?: number,
65
+ exclusiveMaximum?: boolean,
66
+ minimum?: number,
67
+ exclusiveMinimum?: boolean,
68
+ multipleOf?: number,
69
+ maxItems?: number,
70
+ minItems?: number,
71
+ uniqueItems?: boolean
72
+ }
73
+ } = {
74
+ }
75
+
76
+
77
+ /**
78
+ * Check if a given object implements the ZipFileResult interface.
79
+ */
80
+ export function instanceOfZipFileResult(value: object): value is ZipFileResult {
81
+ if (!('zipPath' in value) || value['zipPath'] === undefined) return false;
82
+ return true;
83
+ }
84
+
85
+ export function ZipFileResultFromJSON(json: any): ZipFileResult {
86
+ return ZipFileResultFromJSONTyped(json, false);
87
+ }
88
+
89
+ export function ZipFileResultFromJSONTyped(json: any, ignoreDiscriminator: boolean): ZipFileResult {
90
+ if (json == null) {
91
+ return json;
92
+ }
93
+ return {
94
+
95
+ 'zipPath': json['zip_path'],
96
+ 'documentId': json['document_id'] == null ? undefined : json['document_id'],
97
+ 'documentVersionId': json['document_version_id'] == null ? undefined : json['document_version_id'],
98
+ 'workflowId': json['workflow_id'] == null ? undefined : json['workflow_id'],
99
+ 'skipped': json['skipped'] == null ? undefined : json['skipped'],
100
+ 'error': json['error'] == null ? undefined : json['error'],
101
+ };
102
+ }
103
+
104
+ export function ZipFileResultToJSON(json: any): ZipFileResult {
105
+ return ZipFileResultToJSONTyped(json, false);
106
+ }
107
+
108
+ export function ZipFileResultToJSONTyped(value?: ZipFileResult | null, ignoreDiscriminator: boolean = false): any {
109
+ if (value == null) {
110
+ return value;
111
+ }
112
+
113
+ return {
114
+
115
+ 'zip_path': value['zipPath'],
116
+ 'document_id': value['documentId'],
117
+ 'document_version_id': value['documentVersionId'],
118
+ 'workflow_id': value['workflowId'],
119
+ 'skipped': value['skipped'],
120
+ 'error': value['error'],
121
+ };
122
+ }
123
+
@@ -141,6 +141,7 @@ export * from './IdpType';
141
141
  export * from './ImageTaxonomy';
142
142
  export * from './InformationStatistics';
143
143
  export * from './IngestDocumentResponse';
144
+ export * from './IngestZipResponse';
144
145
  export * from './IngestionMode';
145
146
  export * from './Input';
146
147
  export * from './InputOrigin';
@@ -359,3 +360,4 @@ export * from './XlsxCellAnchorInput';
359
360
  export * from './XlsxCellAnchorInputOrDocxParagraphAnchorInput';
360
361
  export * from './XlsxCellAnchorOutput';
361
362
  export * from './XlsxCellAnchorOutputOrDocxParagraphAnchorOutput';
363
+ export * from './ZipFileResult';