Skip to content

Commit 56a4508

Browse files
authored
Add support for document indexing (#176)
* Add support for indexing documents * Add changeset
1 parent ac47674 commit 56a4508

File tree

5 files changed

+285
-15
lines changed

5 files changed

+285
-15
lines changed

.changeset/cyan-houses-admire.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@team-plain/typescript-sdk': minor
3+
---
4+
5+
Add support for indexing documents into Plain.

src/client.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ import {
4141
DeleteThreadFieldDocument,
4242
DeleteWebhookTargetDocument,
4343
type EmailPartsFragment,
44+
IndexDocumentDocument,
45+
type IndexedDocumentPartsFragment,
4446
type LabelPartsFragment,
4547
LabelTypeDocument,
4648
type LabelTypePartsFragment,
@@ -1171,4 +1173,17 @@ export class PlainClient {
11711173

11721174
return unwrapData(res, (q) => nonNullable(q.createLabelType.labelType));
11731175
}
1176+
1177+
async indexDocument(
1178+
input: VariablesOf<typeof IndexDocumentDocument>['input']
1179+
): SDKResult<IndexedDocumentPartsFragment> {
1180+
const res = await request(this.#ctx, {
1181+
query: IndexDocumentDocument,
1182+
variables: {
1183+
input,
1184+
},
1185+
});
1186+
1187+
return unwrapData(res, (q) => nonNullable(q.createIndexedDocument.indexedDocument));
1188+
}
11741189
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
fragment IndexedDocumentParts on IndexedDocument {
2+
__typename
3+
id
4+
url
5+
createdAt {
6+
...DateTimeParts
7+
}
8+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
mutation indexDocument($input:CreateIndexedDocumentInput!) {
2+
createIndexedDocument(input: $input) {
3+
indexedDocument {
4+
...IndexedDocumentParts
5+
}
6+
error {
7+
...MutationErrorParts
8+
}
9+
}
10+
}

0 commit comments

Comments
 (0)