@ontos-ai/knowhere-sdk 0.9.0 → 0.10.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/README.md +9 -2
- package/dist/index.d.mts +33 -7
- package/dist/index.d.ts +33 -7
- package/dist/index.js +41 -10
- package/dist/index.mjs +41 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -252,16 +252,22 @@ const updateJob = await client.jobs.create({
|
|
|
252
252
|
documentId,
|
|
253
253
|
});
|
|
254
254
|
|
|
255
|
-
const documents = await client.documents.list({
|
|
255
|
+
const documents = await client.documents.list({
|
|
256
|
+
namespace: 'support-center',
|
|
257
|
+
page: 1,
|
|
258
|
+
pageSize: 50,
|
|
259
|
+
});
|
|
256
260
|
const document = await client.documents.get(documentId);
|
|
257
261
|
const chunks = await client.documents.listChunks(documentId, {
|
|
258
262
|
page: 1,
|
|
259
263
|
pageSize: 50,
|
|
260
|
-
chunkType: '
|
|
264
|
+
chunkType: 'image',
|
|
265
|
+
includeAssetUrls: true,
|
|
261
266
|
});
|
|
262
267
|
const archived = await client.documents.archive(documentId);
|
|
263
268
|
|
|
264
269
|
console.log(documents.documents.length);
|
|
270
|
+
console.log(documents.pagination.totalPages);
|
|
265
271
|
console.log(document.status);
|
|
266
272
|
console.log(chunks.pagination.total);
|
|
267
273
|
if (chunks.chunks[0]) {
|
|
@@ -269,6 +275,7 @@ if (chunks.chunks[0]) {
|
|
|
269
275
|
includeAssetUrls: true,
|
|
270
276
|
});
|
|
271
277
|
console.log(chunk.chunk.content);
|
|
278
|
+
console.log(chunk.chunk.assetUrl);
|
|
272
279
|
}
|
|
273
280
|
console.log(archived.status);
|
|
274
281
|
```
|
package/dist/index.d.mts
CHANGED
|
@@ -799,6 +799,30 @@ interface Document {
|
|
|
799
799
|
/** Archive timestamp, when archived */
|
|
800
800
|
archivedAt?: Date;
|
|
801
801
|
}
|
|
802
|
+
/**
|
|
803
|
+
* Pagination metadata returned by document list endpoints.
|
|
804
|
+
*/
|
|
805
|
+
interface DocumentListPagination {
|
|
806
|
+
/** Current page number */
|
|
807
|
+
page: number;
|
|
808
|
+
/** Number of items requested per page */
|
|
809
|
+
pageSize: number;
|
|
810
|
+
/** Total matching documents */
|
|
811
|
+
total: number;
|
|
812
|
+
/** Total number of pages */
|
|
813
|
+
totalPages: number;
|
|
814
|
+
}
|
|
815
|
+
/**
|
|
816
|
+
* Query parameters for GET /v1/documents.
|
|
817
|
+
*/
|
|
818
|
+
interface DocumentListParams {
|
|
819
|
+
/** Retrieval namespace */
|
|
820
|
+
namespace?: string;
|
|
821
|
+
/** Page number (default: 1) */
|
|
822
|
+
page?: number;
|
|
823
|
+
/** Items per page (default: 50, maximum: 200) */
|
|
824
|
+
pageSize?: number;
|
|
825
|
+
}
|
|
802
826
|
/**
|
|
803
827
|
* Response from GET /v1/documents.
|
|
804
828
|
*/
|
|
@@ -807,6 +831,8 @@ interface DocumentListResponse {
|
|
|
807
831
|
namespace: string;
|
|
808
832
|
/** Documents visible in the namespace */
|
|
809
833
|
documents: Document[];
|
|
834
|
+
/** Pagination metadata */
|
|
835
|
+
pagination: DocumentListPagination;
|
|
810
836
|
}
|
|
811
837
|
/**
|
|
812
838
|
* Document chunk types supported by document chunk endpoints.
|
|
@@ -835,14 +861,14 @@ interface DocumentChunkListParams {
|
|
|
835
861
|
pageSize?: number;
|
|
836
862
|
/** Optional chunk type filter */
|
|
837
863
|
chunkType?: DocumentChunkType;
|
|
838
|
-
/**
|
|
864
|
+
/** Set true to include 7-day asset URLs for media chunks */
|
|
839
865
|
includeAssetUrls?: boolean;
|
|
840
866
|
}
|
|
841
867
|
/**
|
|
842
868
|
* Query parameters for GET /v1/documents/{document_id}/chunks/{document_chunk_id}.
|
|
843
869
|
*/
|
|
844
870
|
interface DocumentChunkGetParams {
|
|
845
|
-
/**
|
|
871
|
+
/** Set true to include 7-day asset URLs for media chunks */
|
|
846
872
|
includeAssetUrls?: boolean;
|
|
847
873
|
}
|
|
848
874
|
/**
|
|
@@ -869,7 +895,7 @@ interface DocumentChunk {
|
|
|
869
895
|
sortOrder: number;
|
|
870
896
|
/** Chunk metadata returned by the API */
|
|
871
897
|
metadata: Record<string, unknown>;
|
|
872
|
-
/**
|
|
898
|
+
/** 7-day asset URL for media chunks when available */
|
|
873
899
|
assetUrl?: string | null;
|
|
874
900
|
/** Chunk creation timestamp */
|
|
875
901
|
createdAt?: Date;
|
|
@@ -914,9 +940,7 @@ declare class Documents extends BaseResource {
|
|
|
914
940
|
/**
|
|
915
941
|
* List canonical documents in a namespace.
|
|
916
942
|
*/
|
|
917
|
-
list(params?:
|
|
918
|
-
namespace?: string;
|
|
919
|
-
}): Promise<DocumentListResponse>;
|
|
943
|
+
list(params?: DocumentListParams): Promise<DocumentListResponse>;
|
|
920
944
|
/**
|
|
921
945
|
* Get one canonical document by ID.
|
|
922
946
|
*/
|
|
@@ -933,6 +957,8 @@ declare class Documents extends BaseResource {
|
|
|
933
957
|
* Archive one canonical document by ID.
|
|
934
958
|
*/
|
|
935
959
|
archive(documentId: string): Promise<Document>;
|
|
960
|
+
private createDocumentListRequestConfig;
|
|
961
|
+
private normalizeDocumentListResponse;
|
|
936
962
|
private createChunkListRequestConfig;
|
|
937
963
|
private createChunkGetRequestConfig;
|
|
938
964
|
}
|
|
@@ -1358,4 +1384,4 @@ declare class JobFailedError extends KnowhereError {
|
|
|
1358
1384
|
constructor(message: string, code: string, jobResult: JobResult);
|
|
1359
1385
|
}
|
|
1360
1386
|
|
|
1361
|
-
export { APIError, type AuthTokenProvider, AuthenticationError, BadRequestError, type BaseChunk, ChecksumError, type Chunk, ConflictError, type CreateJobParams, type DocType, type Document, type DocumentChunk, type DocumentChunkGetParams, type DocumentChunkListParams, type DocumentChunkListResponse, type DocumentChunkPagination, type DocumentChunkResponse, type DocumentChunkType, type DocumentListResponse, type DocumentMetadata, Documents, type FileIndex, GatewayTimeoutError, type ImageChunk, InternalServerError, InvalidStateError, type Job, type JobError, JobFailedError, type JobResult, type JobStatus, Jobs, Knowhere, KnowhereError, type KnowhereOptions, Knowledge, type KnowledgeAsyncJobStatusResponse, type KnowledgeAsyncParseParams, type KnowledgeAsyncParseResponse, type KnowledgeCacheDocumentParams, type KnowledgeCacheJobResultParams, type KnowledgeChunkType, type KnowledgeDocumentReference, type KnowledgeGrepMatch, type KnowledgeGrepParams, type KnowledgeGrepResponse, type KnowledgeOutline, type KnowledgeParseParams, type KnowledgeReadChunk, type KnowledgeReadParams, type KnowledgeReadResponse, type KnowledgeSearchParams, type KnowledgeSearchReference, type KnowledgeSearchResponse, type KnowledgeSearchResult, type KnowledgeSection, type KnowledgeStartupRecoveryResponse, type LoadOptions, type LocalKnowledgeDocument, type LocalKnowledgeParseResponse, LocalKnowledgeStore, type Manifest, NetworkError, NotFoundError, type ParseParams, type ParseResult, type ParsingModel, type ParsingParams, PaymentRequiredError, PermissionDeniedError, type PollProgress, PollingTimeoutError, RateLimitError, Retrieval, type RetrievalChannel, type RetrievalFilterMode, type RetrievalQueryParams, type RetrievalQueryResponse, type RetrievalReferencedChunk, type RetrievalResult, type RetrievalSectionExclusion, type RetrievalSource, ServiceUnavailableError, type Statistics, type TableChunk, type TextChunk, TimeoutError, type UploadParams, type UploadProgress, VERSION, ValidationError, type WaitOptions, type WebhookConfig, Knowhere as default };
|
|
1387
|
+
export { APIError, type AuthTokenProvider, AuthenticationError, BadRequestError, type BaseChunk, ChecksumError, type Chunk, ConflictError, type CreateJobParams, type DocType, type Document, type DocumentChunk, type DocumentChunkGetParams, type DocumentChunkListParams, type DocumentChunkListResponse, type DocumentChunkPagination, type DocumentChunkResponse, type DocumentChunkType, type DocumentListPagination, type DocumentListParams, type DocumentListResponse, type DocumentMetadata, Documents, type FileIndex, GatewayTimeoutError, type ImageChunk, InternalServerError, InvalidStateError, type Job, type JobError, JobFailedError, type JobResult, type JobStatus, Jobs, Knowhere, KnowhereError, type KnowhereOptions, Knowledge, type KnowledgeAsyncJobStatusResponse, type KnowledgeAsyncParseParams, type KnowledgeAsyncParseResponse, type KnowledgeCacheDocumentParams, type KnowledgeCacheJobResultParams, type KnowledgeChunkType, type KnowledgeDocumentReference, type KnowledgeGrepMatch, type KnowledgeGrepParams, type KnowledgeGrepResponse, type KnowledgeOutline, type KnowledgeParseParams, type KnowledgeReadChunk, type KnowledgeReadParams, type KnowledgeReadResponse, type KnowledgeSearchParams, type KnowledgeSearchReference, type KnowledgeSearchResponse, type KnowledgeSearchResult, type KnowledgeSection, type KnowledgeStartupRecoveryResponse, type LoadOptions, type LocalKnowledgeDocument, type LocalKnowledgeParseResponse, LocalKnowledgeStore, type Manifest, NetworkError, NotFoundError, type ParseParams, type ParseResult, type ParsingModel, type ParsingParams, PaymentRequiredError, PermissionDeniedError, type PollProgress, PollingTimeoutError, RateLimitError, Retrieval, type RetrievalChannel, type RetrievalFilterMode, type RetrievalQueryParams, type RetrievalQueryResponse, type RetrievalReferencedChunk, type RetrievalResult, type RetrievalSectionExclusion, type RetrievalSource, ServiceUnavailableError, type Statistics, type TableChunk, type TextChunk, TimeoutError, type UploadParams, type UploadProgress, VERSION, ValidationError, type WaitOptions, type WebhookConfig, Knowhere as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -799,6 +799,30 @@ interface Document {
|
|
|
799
799
|
/** Archive timestamp, when archived */
|
|
800
800
|
archivedAt?: Date;
|
|
801
801
|
}
|
|
802
|
+
/**
|
|
803
|
+
* Pagination metadata returned by document list endpoints.
|
|
804
|
+
*/
|
|
805
|
+
interface DocumentListPagination {
|
|
806
|
+
/** Current page number */
|
|
807
|
+
page: number;
|
|
808
|
+
/** Number of items requested per page */
|
|
809
|
+
pageSize: number;
|
|
810
|
+
/** Total matching documents */
|
|
811
|
+
total: number;
|
|
812
|
+
/** Total number of pages */
|
|
813
|
+
totalPages: number;
|
|
814
|
+
}
|
|
815
|
+
/**
|
|
816
|
+
* Query parameters for GET /v1/documents.
|
|
817
|
+
*/
|
|
818
|
+
interface DocumentListParams {
|
|
819
|
+
/** Retrieval namespace */
|
|
820
|
+
namespace?: string;
|
|
821
|
+
/** Page number (default: 1) */
|
|
822
|
+
page?: number;
|
|
823
|
+
/** Items per page (default: 50, maximum: 200) */
|
|
824
|
+
pageSize?: number;
|
|
825
|
+
}
|
|
802
826
|
/**
|
|
803
827
|
* Response from GET /v1/documents.
|
|
804
828
|
*/
|
|
@@ -807,6 +831,8 @@ interface DocumentListResponse {
|
|
|
807
831
|
namespace: string;
|
|
808
832
|
/** Documents visible in the namespace */
|
|
809
833
|
documents: Document[];
|
|
834
|
+
/** Pagination metadata */
|
|
835
|
+
pagination: DocumentListPagination;
|
|
810
836
|
}
|
|
811
837
|
/**
|
|
812
838
|
* Document chunk types supported by document chunk endpoints.
|
|
@@ -835,14 +861,14 @@ interface DocumentChunkListParams {
|
|
|
835
861
|
pageSize?: number;
|
|
836
862
|
/** Optional chunk type filter */
|
|
837
863
|
chunkType?: DocumentChunkType;
|
|
838
|
-
/**
|
|
864
|
+
/** Set true to include 7-day asset URLs for media chunks */
|
|
839
865
|
includeAssetUrls?: boolean;
|
|
840
866
|
}
|
|
841
867
|
/**
|
|
842
868
|
* Query parameters for GET /v1/documents/{document_id}/chunks/{document_chunk_id}.
|
|
843
869
|
*/
|
|
844
870
|
interface DocumentChunkGetParams {
|
|
845
|
-
/**
|
|
871
|
+
/** Set true to include 7-day asset URLs for media chunks */
|
|
846
872
|
includeAssetUrls?: boolean;
|
|
847
873
|
}
|
|
848
874
|
/**
|
|
@@ -869,7 +895,7 @@ interface DocumentChunk {
|
|
|
869
895
|
sortOrder: number;
|
|
870
896
|
/** Chunk metadata returned by the API */
|
|
871
897
|
metadata: Record<string, unknown>;
|
|
872
|
-
/**
|
|
898
|
+
/** 7-day asset URL for media chunks when available */
|
|
873
899
|
assetUrl?: string | null;
|
|
874
900
|
/** Chunk creation timestamp */
|
|
875
901
|
createdAt?: Date;
|
|
@@ -914,9 +940,7 @@ declare class Documents extends BaseResource {
|
|
|
914
940
|
/**
|
|
915
941
|
* List canonical documents in a namespace.
|
|
916
942
|
*/
|
|
917
|
-
list(params?:
|
|
918
|
-
namespace?: string;
|
|
919
|
-
}): Promise<DocumentListResponse>;
|
|
943
|
+
list(params?: DocumentListParams): Promise<DocumentListResponse>;
|
|
920
944
|
/**
|
|
921
945
|
* Get one canonical document by ID.
|
|
922
946
|
*/
|
|
@@ -933,6 +957,8 @@ declare class Documents extends BaseResource {
|
|
|
933
957
|
* Archive one canonical document by ID.
|
|
934
958
|
*/
|
|
935
959
|
archive(documentId: string): Promise<Document>;
|
|
960
|
+
private createDocumentListRequestConfig;
|
|
961
|
+
private normalizeDocumentListResponse;
|
|
936
962
|
private createChunkListRequestConfig;
|
|
937
963
|
private createChunkGetRequestConfig;
|
|
938
964
|
}
|
|
@@ -1358,4 +1384,4 @@ declare class JobFailedError extends KnowhereError {
|
|
|
1358
1384
|
constructor(message: string, code: string, jobResult: JobResult);
|
|
1359
1385
|
}
|
|
1360
1386
|
|
|
1361
|
-
export { APIError, type AuthTokenProvider, AuthenticationError, BadRequestError, type BaseChunk, ChecksumError, type Chunk, ConflictError, type CreateJobParams, type DocType, type Document, type DocumentChunk, type DocumentChunkGetParams, type DocumentChunkListParams, type DocumentChunkListResponse, type DocumentChunkPagination, type DocumentChunkResponse, type DocumentChunkType, type DocumentListResponse, type DocumentMetadata, Documents, type FileIndex, GatewayTimeoutError, type ImageChunk, InternalServerError, InvalidStateError, type Job, type JobError, JobFailedError, type JobResult, type JobStatus, Jobs, Knowhere, KnowhereError, type KnowhereOptions, Knowledge, type KnowledgeAsyncJobStatusResponse, type KnowledgeAsyncParseParams, type KnowledgeAsyncParseResponse, type KnowledgeCacheDocumentParams, type KnowledgeCacheJobResultParams, type KnowledgeChunkType, type KnowledgeDocumentReference, type KnowledgeGrepMatch, type KnowledgeGrepParams, type KnowledgeGrepResponse, type KnowledgeOutline, type KnowledgeParseParams, type KnowledgeReadChunk, type KnowledgeReadParams, type KnowledgeReadResponse, type KnowledgeSearchParams, type KnowledgeSearchReference, type KnowledgeSearchResponse, type KnowledgeSearchResult, type KnowledgeSection, type KnowledgeStartupRecoveryResponse, type LoadOptions, type LocalKnowledgeDocument, type LocalKnowledgeParseResponse, LocalKnowledgeStore, type Manifest, NetworkError, NotFoundError, type ParseParams, type ParseResult, type ParsingModel, type ParsingParams, PaymentRequiredError, PermissionDeniedError, type PollProgress, PollingTimeoutError, RateLimitError, Retrieval, type RetrievalChannel, type RetrievalFilterMode, type RetrievalQueryParams, type RetrievalQueryResponse, type RetrievalReferencedChunk, type RetrievalResult, type RetrievalSectionExclusion, type RetrievalSource, ServiceUnavailableError, type Statistics, type TableChunk, type TextChunk, TimeoutError, type UploadParams, type UploadProgress, VERSION, ValidationError, type WaitOptions, type WebhookConfig, Knowhere as default };
|
|
1387
|
+
export { APIError, type AuthTokenProvider, AuthenticationError, BadRequestError, type BaseChunk, ChecksumError, type Chunk, ConflictError, type CreateJobParams, type DocType, type Document, type DocumentChunk, type DocumentChunkGetParams, type DocumentChunkListParams, type DocumentChunkListResponse, type DocumentChunkPagination, type DocumentChunkResponse, type DocumentChunkType, type DocumentListPagination, type DocumentListParams, type DocumentListResponse, type DocumentMetadata, Documents, type FileIndex, GatewayTimeoutError, type ImageChunk, InternalServerError, InvalidStateError, type Job, type JobError, JobFailedError, type JobResult, type JobStatus, Jobs, Knowhere, KnowhereError, type KnowhereOptions, Knowledge, type KnowledgeAsyncJobStatusResponse, type KnowledgeAsyncParseParams, type KnowledgeAsyncParseResponse, type KnowledgeCacheDocumentParams, type KnowledgeCacheJobResultParams, type KnowledgeChunkType, type KnowledgeDocumentReference, type KnowledgeGrepMatch, type KnowledgeGrepParams, type KnowledgeGrepResponse, type KnowledgeOutline, type KnowledgeParseParams, type KnowledgeReadChunk, type KnowledgeReadParams, type KnowledgeReadResponse, type KnowledgeSearchParams, type KnowledgeSearchReference, type KnowledgeSearchResponse, type KnowledgeSearchResult, type KnowledgeSection, type KnowledgeStartupRecoveryResponse, type LoadOptions, type LocalKnowledgeDocument, type LocalKnowledgeParseResponse, LocalKnowledgeStore, type Manifest, NetworkError, NotFoundError, type ParseParams, type ParseResult, type ParsingModel, type ParsingParams, PaymentRequiredError, PermissionDeniedError, type PollProgress, PollingTimeoutError, RateLimitError, Retrieval, type RetrievalChannel, type RetrievalFilterMode, type RetrievalQueryParams, type RetrievalQueryResponse, type RetrievalReferencedChunk, type RetrievalResult, type RetrievalSectionExclusion, type RetrievalSource, ServiceUnavailableError, type Statistics, type TableChunk, type TextChunk, TimeoutError, type UploadParams, type UploadProgress, VERSION, ValidationError, type WaitOptions, type WebhookConfig, Knowhere as default };
|
package/dist/index.js
CHANGED
|
@@ -1438,12 +1438,11 @@ var Documents = class extends BaseResource {
|
|
|
1438
1438
|
* List canonical documents in a namespace.
|
|
1439
1439
|
*/
|
|
1440
1440
|
async list(params) {
|
|
1441
|
-
const
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
return this.httpClient.get("/v1/documents", requestConfig);
|
|
1441
|
+
const response = await this.httpClient.get(
|
|
1442
|
+
"/v1/documents",
|
|
1443
|
+
this.createDocumentListRequestConfig(params)
|
|
1444
|
+
);
|
|
1445
|
+
return this.normalizeDocumentListResponse(response);
|
|
1447
1446
|
}
|
|
1448
1447
|
/**
|
|
1449
1448
|
* Get one canonical document by ID.
|
|
@@ -1475,6 +1474,38 @@ var Documents = class extends BaseResource {
|
|
|
1475
1474
|
async archive(documentId) {
|
|
1476
1475
|
return this.httpClient.post(`/v1/documents/${documentId}/archive`);
|
|
1477
1476
|
}
|
|
1477
|
+
createDocumentListRequestConfig(params) {
|
|
1478
|
+
if (!params) {
|
|
1479
|
+
return void 0;
|
|
1480
|
+
}
|
|
1481
|
+
const queryParams = {};
|
|
1482
|
+
if (params.namespace !== void 0) {
|
|
1483
|
+
queryParams.namespace = params.namespace;
|
|
1484
|
+
}
|
|
1485
|
+
if (params.page !== void 0) {
|
|
1486
|
+
queryParams.page = params.page;
|
|
1487
|
+
}
|
|
1488
|
+
if (params.pageSize !== void 0) {
|
|
1489
|
+
queryParams.page_size = params.pageSize;
|
|
1490
|
+
}
|
|
1491
|
+
return Object.keys(queryParams).length > 0 ? { params: queryParams } : void 0;
|
|
1492
|
+
}
|
|
1493
|
+
normalizeDocumentListResponse(response) {
|
|
1494
|
+
const maybePaginatedResponse = response;
|
|
1495
|
+
if (maybePaginatedResponse.pagination) {
|
|
1496
|
+
return response;
|
|
1497
|
+
}
|
|
1498
|
+
const total = response.documents.length;
|
|
1499
|
+
return {
|
|
1500
|
+
...response,
|
|
1501
|
+
pagination: {
|
|
1502
|
+
page: 1,
|
|
1503
|
+
pageSize: total,
|
|
1504
|
+
total,
|
|
1505
|
+
totalPages: total > 0 ? 1 : 0
|
|
1506
|
+
}
|
|
1507
|
+
};
|
|
1508
|
+
}
|
|
1478
1509
|
createChunkListRequestConfig(params) {
|
|
1479
1510
|
if (!params) {
|
|
1480
1511
|
return void 0;
|
|
@@ -1489,18 +1520,18 @@ var Documents = class extends BaseResource {
|
|
|
1489
1520
|
if (params.chunkType !== void 0) {
|
|
1490
1521
|
queryParams.chunk_type = params.chunkType;
|
|
1491
1522
|
}
|
|
1492
|
-
if (params.includeAssetUrls
|
|
1493
|
-
queryParams.include_asset_urls =
|
|
1523
|
+
if (params.includeAssetUrls !== void 0) {
|
|
1524
|
+
queryParams.include_asset_urls = params.includeAssetUrls;
|
|
1494
1525
|
}
|
|
1495
1526
|
return Object.keys(queryParams).length > 0 ? { params: queryParams } : void 0;
|
|
1496
1527
|
}
|
|
1497
1528
|
createChunkGetRequestConfig(params) {
|
|
1498
|
-
if (params?.includeAssetUrls
|
|
1529
|
+
if (params?.includeAssetUrls === void 0) {
|
|
1499
1530
|
return void 0;
|
|
1500
1531
|
}
|
|
1501
1532
|
return {
|
|
1502
1533
|
params: {
|
|
1503
|
-
include_asset_urls:
|
|
1534
|
+
include_asset_urls: params.includeAssetUrls
|
|
1504
1535
|
}
|
|
1505
1536
|
};
|
|
1506
1537
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1378,12 +1378,11 @@ var Documents = class extends BaseResource {
|
|
|
1378
1378
|
* List canonical documents in a namespace.
|
|
1379
1379
|
*/
|
|
1380
1380
|
async list(params) {
|
|
1381
|
-
const
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
return this.httpClient.get("/v1/documents", requestConfig);
|
|
1381
|
+
const response = await this.httpClient.get(
|
|
1382
|
+
"/v1/documents",
|
|
1383
|
+
this.createDocumentListRequestConfig(params)
|
|
1384
|
+
);
|
|
1385
|
+
return this.normalizeDocumentListResponse(response);
|
|
1387
1386
|
}
|
|
1388
1387
|
/**
|
|
1389
1388
|
* Get one canonical document by ID.
|
|
@@ -1415,6 +1414,38 @@ var Documents = class extends BaseResource {
|
|
|
1415
1414
|
async archive(documentId) {
|
|
1416
1415
|
return this.httpClient.post(`/v1/documents/${documentId}/archive`);
|
|
1417
1416
|
}
|
|
1417
|
+
createDocumentListRequestConfig(params) {
|
|
1418
|
+
if (!params) {
|
|
1419
|
+
return void 0;
|
|
1420
|
+
}
|
|
1421
|
+
const queryParams = {};
|
|
1422
|
+
if (params.namespace !== void 0) {
|
|
1423
|
+
queryParams.namespace = params.namespace;
|
|
1424
|
+
}
|
|
1425
|
+
if (params.page !== void 0) {
|
|
1426
|
+
queryParams.page = params.page;
|
|
1427
|
+
}
|
|
1428
|
+
if (params.pageSize !== void 0) {
|
|
1429
|
+
queryParams.page_size = params.pageSize;
|
|
1430
|
+
}
|
|
1431
|
+
return Object.keys(queryParams).length > 0 ? { params: queryParams } : void 0;
|
|
1432
|
+
}
|
|
1433
|
+
normalizeDocumentListResponse(response) {
|
|
1434
|
+
const maybePaginatedResponse = response;
|
|
1435
|
+
if (maybePaginatedResponse.pagination) {
|
|
1436
|
+
return response;
|
|
1437
|
+
}
|
|
1438
|
+
const total = response.documents.length;
|
|
1439
|
+
return {
|
|
1440
|
+
...response,
|
|
1441
|
+
pagination: {
|
|
1442
|
+
page: 1,
|
|
1443
|
+
pageSize: total,
|
|
1444
|
+
total,
|
|
1445
|
+
totalPages: total > 0 ? 1 : 0
|
|
1446
|
+
}
|
|
1447
|
+
};
|
|
1448
|
+
}
|
|
1418
1449
|
createChunkListRequestConfig(params) {
|
|
1419
1450
|
if (!params) {
|
|
1420
1451
|
return void 0;
|
|
@@ -1429,18 +1460,18 @@ var Documents = class extends BaseResource {
|
|
|
1429
1460
|
if (params.chunkType !== void 0) {
|
|
1430
1461
|
queryParams.chunk_type = params.chunkType;
|
|
1431
1462
|
}
|
|
1432
|
-
if (params.includeAssetUrls
|
|
1433
|
-
queryParams.include_asset_urls =
|
|
1463
|
+
if (params.includeAssetUrls !== void 0) {
|
|
1464
|
+
queryParams.include_asset_urls = params.includeAssetUrls;
|
|
1434
1465
|
}
|
|
1435
1466
|
return Object.keys(queryParams).length > 0 ? { params: queryParams } : void 0;
|
|
1436
1467
|
}
|
|
1437
1468
|
createChunkGetRequestConfig(params) {
|
|
1438
|
-
if (params?.includeAssetUrls
|
|
1469
|
+
if (params?.includeAssetUrls === void 0) {
|
|
1439
1470
|
return void 0;
|
|
1440
1471
|
}
|
|
1441
1472
|
return {
|
|
1442
1473
|
params: {
|
|
1443
|
-
include_asset_urls:
|
|
1474
|
+
include_asset_urls: params.includeAssetUrls
|
|
1444
1475
|
}
|
|
1445
1476
|
};
|
|
1446
1477
|
}
|