@whaly/connector-sdk 0.3.11 → 0.3.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +25 -4
- package/dist/index.d.ts +25 -4
- package/dist/index.js +19 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1489,6 +1489,12 @@ interface WhalyDocument {
|
|
|
1489
1489
|
size_kb: number;
|
|
1490
1490
|
storage: string;
|
|
1491
1491
|
metadata: Record<string, string> | null;
|
|
1492
|
+
/**
|
|
1493
|
+
* The document source this document belongs to.
|
|
1494
|
+
* `null` means the org's default source. On create this field is optional —
|
|
1495
|
+
* when omitted the document is attached to the default source.
|
|
1496
|
+
*/
|
|
1497
|
+
document_source_id: string | null;
|
|
1492
1498
|
}
|
|
1493
1499
|
/** Paginated response from the Whaly Document API. */
|
|
1494
1500
|
interface WhalyPaginatedResponse<T> {
|
|
@@ -1566,6 +1572,16 @@ interface WhalyDocumentServiceConfig {
|
|
|
1566
1572
|
serviceAccountKey?: string;
|
|
1567
1573
|
/** Object storage ID for file uploads. */
|
|
1568
1574
|
objectStorageId: string;
|
|
1575
|
+
/**
|
|
1576
|
+
* The document source this connector manages. One connector maps to exactly
|
|
1577
|
+
* one source. All operations are scoped to it:
|
|
1578
|
+
* - `listAllDocuments()` only returns documents belonging to this source,
|
|
1579
|
+
* so the reconciliation (create / update / **delete**) never touches
|
|
1580
|
+
* documents from other sources — important because the DocumentTap
|
|
1581
|
+
* deletes any listed document not present in the source.
|
|
1582
|
+
* - Created and updated documents are always attached to this source.
|
|
1583
|
+
*/
|
|
1584
|
+
documentSourceId: string;
|
|
1569
1585
|
}
|
|
1570
1586
|
interface WhalyUploadResult {
|
|
1571
1587
|
storage: string;
|
|
@@ -1575,17 +1591,22 @@ interface WhalyUploadResult {
|
|
|
1575
1591
|
declare class WhalyDocumentService {
|
|
1576
1592
|
private axiosClient;
|
|
1577
1593
|
readonly objectStorageId: string;
|
|
1594
|
+
readonly documentSourceId: string;
|
|
1578
1595
|
private gcsBucket;
|
|
1579
1596
|
constructor(config: WhalyDocumentServiceConfig);
|
|
1580
|
-
/**
|
|
1597
|
+
/**
|
|
1598
|
+
* Fetch all documents belonging to the configured document source,
|
|
1599
|
+
* handling cursor-based pagination. The `document_source_id` server-side
|
|
1600
|
+
* filter scopes the result to this connector's source only.
|
|
1601
|
+
*/
|
|
1581
1602
|
listAllDocuments(): Promise<WhalyDocument[]>;
|
|
1582
1603
|
/** Upload a file to object storage. Returns storage path and size. */
|
|
1583
1604
|
uploadFile(destinationPath: string, localFilePath: string, fileName: string): Promise<WhalyUploadResult>;
|
|
1584
1605
|
private uploadFileViaGCS;
|
|
1585
1606
|
private uploadFileViaAPI;
|
|
1586
|
-
/** Create a new document record. */
|
|
1587
|
-
createDocument(payload: Omit<WhalyDocument, "id">): Promise<WhalyDocument>;
|
|
1588
|
-
/** Update an existing document record. */
|
|
1607
|
+
/** Create a new document record, attached to the configured document source. */
|
|
1608
|
+
createDocument(payload: Omit<WhalyDocument, "id" | "document_source_id">): Promise<WhalyDocument>;
|
|
1609
|
+
/** Update an existing document record, keeping it in the configured document source. */
|
|
1589
1610
|
updateDocument(id: string, payload: Partial<WhalyDocument>): Promise<WhalyDocument>;
|
|
1590
1611
|
/** Delete a document record. */
|
|
1591
1612
|
deleteDocument(id: string): Promise<void>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1489,6 +1489,12 @@ interface WhalyDocument {
|
|
|
1489
1489
|
size_kb: number;
|
|
1490
1490
|
storage: string;
|
|
1491
1491
|
metadata: Record<string, string> | null;
|
|
1492
|
+
/**
|
|
1493
|
+
* The document source this document belongs to.
|
|
1494
|
+
* `null` means the org's default source. On create this field is optional —
|
|
1495
|
+
* when omitted the document is attached to the default source.
|
|
1496
|
+
*/
|
|
1497
|
+
document_source_id: string | null;
|
|
1492
1498
|
}
|
|
1493
1499
|
/** Paginated response from the Whaly Document API. */
|
|
1494
1500
|
interface WhalyPaginatedResponse<T> {
|
|
@@ -1566,6 +1572,16 @@ interface WhalyDocumentServiceConfig {
|
|
|
1566
1572
|
serviceAccountKey?: string;
|
|
1567
1573
|
/** Object storage ID for file uploads. */
|
|
1568
1574
|
objectStorageId: string;
|
|
1575
|
+
/**
|
|
1576
|
+
* The document source this connector manages. One connector maps to exactly
|
|
1577
|
+
* one source. All operations are scoped to it:
|
|
1578
|
+
* - `listAllDocuments()` only returns documents belonging to this source,
|
|
1579
|
+
* so the reconciliation (create / update / **delete**) never touches
|
|
1580
|
+
* documents from other sources — important because the DocumentTap
|
|
1581
|
+
* deletes any listed document not present in the source.
|
|
1582
|
+
* - Created and updated documents are always attached to this source.
|
|
1583
|
+
*/
|
|
1584
|
+
documentSourceId: string;
|
|
1569
1585
|
}
|
|
1570
1586
|
interface WhalyUploadResult {
|
|
1571
1587
|
storage: string;
|
|
@@ -1575,17 +1591,22 @@ interface WhalyUploadResult {
|
|
|
1575
1591
|
declare class WhalyDocumentService {
|
|
1576
1592
|
private axiosClient;
|
|
1577
1593
|
readonly objectStorageId: string;
|
|
1594
|
+
readonly documentSourceId: string;
|
|
1578
1595
|
private gcsBucket;
|
|
1579
1596
|
constructor(config: WhalyDocumentServiceConfig);
|
|
1580
|
-
/**
|
|
1597
|
+
/**
|
|
1598
|
+
* Fetch all documents belonging to the configured document source,
|
|
1599
|
+
* handling cursor-based pagination. The `document_source_id` server-side
|
|
1600
|
+
* filter scopes the result to this connector's source only.
|
|
1601
|
+
*/
|
|
1581
1602
|
listAllDocuments(): Promise<WhalyDocument[]>;
|
|
1582
1603
|
/** Upload a file to object storage. Returns storage path and size. */
|
|
1583
1604
|
uploadFile(destinationPath: string, localFilePath: string, fileName: string): Promise<WhalyUploadResult>;
|
|
1584
1605
|
private uploadFileViaGCS;
|
|
1585
1606
|
private uploadFileViaAPI;
|
|
1586
|
-
/** Create a new document record. */
|
|
1587
|
-
createDocument(payload: Omit<WhalyDocument, "id">): Promise<WhalyDocument>;
|
|
1588
|
-
/** Update an existing document record. */
|
|
1607
|
+
/** Create a new document record, attached to the configured document source. */
|
|
1608
|
+
createDocument(payload: Omit<WhalyDocument, "id" | "document_source_id">): Promise<WhalyDocument>;
|
|
1609
|
+
/** Update an existing document record, keeping it in the configured document source. */
|
|
1589
1610
|
updateDocument(id: string, payload: Partial<WhalyDocument>): Promise<WhalyDocument>;
|
|
1590
1611
|
/** Delete a document record. */
|
|
1591
1612
|
deleteDocument(id: string): Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -14782,11 +14782,13 @@ var MAX_RETRIES2 = 10;
|
|
|
14782
14782
|
var WhalyDocumentService = class {
|
|
14783
14783
|
axiosClient;
|
|
14784
14784
|
objectStorageId;
|
|
14785
|
+
documentSourceId;
|
|
14785
14786
|
gcsBucket;
|
|
14786
14787
|
constructor(config) {
|
|
14787
14788
|
const resolvedKey = getServiceAccountKey(config.serviceAccountKey);
|
|
14788
14789
|
const resolvedEndpoint = getApiEndpoint(config.apiEndpoint);
|
|
14789
14790
|
this.objectStorageId = config.objectStorageId;
|
|
14791
|
+
this.documentSourceId = config.documentSourceId;
|
|
14790
14792
|
const gcsBucketName = process.env["WLY_GCS_BUCKET"];
|
|
14791
14793
|
if (gcsBucketName) {
|
|
14792
14794
|
this.gcsBucket = new import_storage2.Storage().bucket(gcsBucketName);
|
|
@@ -14821,12 +14823,16 @@ var WhalyDocumentService = class {
|
|
|
14821
14823
|
}
|
|
14822
14824
|
});
|
|
14823
14825
|
}
|
|
14824
|
-
/**
|
|
14826
|
+
/**
|
|
14827
|
+
* Fetch all documents belonging to the configured document source,
|
|
14828
|
+
* handling cursor-based pagination. The `document_source_id` server-side
|
|
14829
|
+
* filter scopes the result to this connector's source only.
|
|
14830
|
+
*/
|
|
14825
14831
|
async listAllDocuments() {
|
|
14826
14832
|
const documents = [];
|
|
14827
14833
|
let after;
|
|
14828
14834
|
while (true) {
|
|
14829
|
-
const params = {};
|
|
14835
|
+
const params = { document_source_id: this.documentSourceId };
|
|
14830
14836
|
if (after) params["after"] = after;
|
|
14831
14837
|
const response = await this.axiosClient.get(
|
|
14832
14838
|
"/v1/documents",
|
|
@@ -14886,19 +14892,26 @@ var WhalyDocumentService = class {
|
|
|
14886
14892
|
throw enrichAxiosError(err);
|
|
14887
14893
|
}
|
|
14888
14894
|
}
|
|
14889
|
-
/** Create a new document record. */
|
|
14895
|
+
/** Create a new document record, attached to the configured document source. */
|
|
14890
14896
|
async createDocument(payload) {
|
|
14891
14897
|
try {
|
|
14892
|
-
const response = await this.axiosClient.post("/v1/documents",
|
|
14898
|
+
const response = await this.axiosClient.post("/v1/documents", {
|
|
14899
|
+
...payload,
|
|
14900
|
+
document_source_id: this.documentSourceId
|
|
14901
|
+
});
|
|
14893
14902
|
return response.data.data ?? response.data;
|
|
14894
14903
|
} catch (err) {
|
|
14895
14904
|
throw enrichAxiosError(err);
|
|
14896
14905
|
}
|
|
14897
14906
|
}
|
|
14898
|
-
/** Update an existing document record. */
|
|
14907
|
+
/** Update an existing document record, keeping it in the configured document source. */
|
|
14899
14908
|
async updateDocument(id, payload) {
|
|
14900
14909
|
try {
|
|
14901
|
-
const response = await this.axiosClient.put(`/v1/documents/${id}`, {
|
|
14910
|
+
const response = await this.axiosClient.put(`/v1/documents/${id}`, {
|
|
14911
|
+
id,
|
|
14912
|
+
...payload,
|
|
14913
|
+
document_source_id: this.documentSourceId
|
|
14914
|
+
});
|
|
14902
14915
|
return response.data.data ?? response.data;
|
|
14903
14916
|
} catch (err) {
|
|
14904
14917
|
throw enrichAxiosError(err);
|