graphlit-client 1.0.20240418005 → 1.0.20240418006
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/client.d.ts +57 -57
- package/dist/client.js +63 -39
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
@@ -10,63 +10,63 @@ declare class Graphlit {
|
|
10
10
|
private correlationId;
|
11
11
|
private token;
|
12
12
|
constructor(organizationId?: string, environmentId?: string, jwtSecret?: string, ownerId?: string, apiUri?: string, correlationId?: string);
|
13
|
-
createAlert(alert: Types.AlertInput): Promise<
|
14
|
-
updateAlert(alert: Types.AlertUpdateInput): Promise<
|
15
|
-
deleteAlert(id: string): Promise<
|
16
|
-
deleteAllAlerts(): Promise<
|
17
|
-
enableAlert(id: string): Promise<
|
18
|
-
disableAlert(id: string): Promise<
|
19
|
-
getAlert(id: string): Promise<
|
20
|
-
queryAlerts(filter: Types.AlertFilter): Promise<
|
21
|
-
createCollection(
|
22
|
-
updateCollection(
|
23
|
-
deleteCollection(id: string): Promise<
|
24
|
-
addContentsToCollections(contents: Types.EntityReferenceInput[], collections: Types.EntityReferenceInput[]): Promise<
|
25
|
-
removeContentsFromCollection(contents: Types.EntityReferenceInput[], collection: Types.EntityReferenceInput): Promise<
|
26
|
-
getCollection(id: string): Promise<
|
27
|
-
queryCollections(filter: Types.CollectionFilter): Promise<
|
28
|
-
ingestUri(uri: string, name?: string, id?: string, isSynchronous?: boolean, workflow?: Types.EntityReferenceInput): Promise<
|
29
|
-
ingestText(name: string, text: string, textType?: Types.TextTypes, uri?: string, id?: string, isSynchronous?: boolean, workflow?: Types.EntityReferenceInput): Promise<
|
30
|
-
ingestEncodedFile(name: string, data: string, mimeType: string, id?: string, isSynchronous?: boolean, workflow?: Types.EntityReferenceInput): Promise<
|
31
|
-
updateContent(content: Types.ContentUpdateInput): Promise<
|
32
|
-
deleteContent(id: string): Promise<
|
33
|
-
deleteAllContents(): Promise<
|
34
|
-
summarizeContents(summarizations: [Types.SummarizationStrategyInput], filter?: Types.ContentFilter): Promise<
|
35
|
-
extractContents(prompt: string, filter?: Types.ContentFilter, specification?: Types.EntityReferenceInput): Promise<
|
36
|
-
publishContents(summaryPrompt: string, summarySpecification: Types.EntityReferenceInput, connector: Types.ContentPublishingConnectorInput, publishPrompt?: string, publishSpecification?: Types.EntityReferenceInput, name?: string, filter?: Types.ContentFilter, workflow?: Types.EntityReferenceInput): Promise<
|
37
|
-
getContent(id: string): Promise<
|
38
|
-
queryContents(filter: Types.ContentFilter): Promise<
|
39
|
-
createConversation(conversation: Types.ConversationInput): Promise<
|
40
|
-
updateConversation(conversation: Types.ConversationUpdateInput): Promise<
|
41
|
-
deleteConversation(id: string): Promise<
|
42
|
-
deleteAllConversations(): Promise<
|
43
|
-
clearConversation(id: string): Promise<
|
44
|
-
closeConversation(id: string): Promise<
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
createFeed(feed: Types.FeedInput): Promise<
|
51
|
-
updateFeed(feed: Types.FeedUpdateInput): Promise<
|
52
|
-
deleteFeed(id: string): Promise<
|
53
|
-
deleteAllFeeds(): Promise<
|
54
|
-
enableFeed(id: string): Promise<
|
55
|
-
disableFeed(id: string): Promise<
|
56
|
-
getFeed(id: string): Promise<
|
57
|
-
queryFeeds(filter: Types.FeedFilter): Promise<
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
getSpecification(id: string): Promise<
|
63
|
-
querySpecifications(filter: Types.SpecificationFilter): Promise<
|
64
|
-
createWorkflow(workflow: Types.WorkflowInput): Promise<
|
65
|
-
updateWorkflow(workflow: Types.WorkflowUpdateInput): Promise<
|
66
|
-
deleteWorkflow(id: string): Promise<
|
67
|
-
deleteAllWorkflows(): Promise<
|
68
|
-
getWorkflow(id: string): Promise<
|
69
|
-
queryWorkflows(filter: Types.WorkflowFilter): Promise<
|
13
|
+
createAlert(alert: Types.AlertInput): Promise<Types.Alert>;
|
14
|
+
updateAlert(alert: Types.AlertUpdateInput): Promise<Types.Alert>;
|
15
|
+
deleteAlert(id: string): Promise<Types.Alert>;
|
16
|
+
deleteAllAlerts(): Promise<void>;
|
17
|
+
enableAlert(id: string): Promise<Types.Alert>;
|
18
|
+
disableAlert(id: string): Promise<Types.Alert>;
|
19
|
+
getAlert(id: string): Promise<Types.Alert>;
|
20
|
+
queryAlerts(filter: Types.AlertFilter): Promise<Types.AlertResults>;
|
21
|
+
createCollection(Collection: Types.CollectionInput): Promise<Types.Collection>;
|
22
|
+
updateCollection(Collection: Types.CollectionUpdateInput): Promise<Types.Collection>;
|
23
|
+
deleteCollection(id: string): Promise<Types.Collection>;
|
24
|
+
addContentsToCollections(contents: Types.EntityReferenceInput[], collections: Types.EntityReferenceInput[]): Promise<Types.Collection[]>;
|
25
|
+
removeContentsFromCollection(contents: Types.EntityReferenceInput[], collection: Types.EntityReferenceInput): Promise<Types.Collection>;
|
26
|
+
getCollection(id: string): Promise<Types.Collection>;
|
27
|
+
queryCollections(filter: Types.CollectionFilter): Promise<Types.CollectionResults>;
|
28
|
+
ingestUri(uri: string, name?: string, id?: string, isSynchronous?: boolean, workflow?: Types.EntityReferenceInput): Promise<Types.Content>;
|
29
|
+
ingestText(name: string, text: string, textType?: Types.TextTypes, uri?: string, id?: string, isSynchronous?: boolean, workflow?: Types.EntityReferenceInput): Promise<Types.Content>;
|
30
|
+
ingestEncodedFile(name: string, data: string, mimeType: string, id?: string, isSynchronous?: boolean, workflow?: Types.EntityReferenceInput): Promise<Types.Content>;
|
31
|
+
updateContent(content: Types.ContentUpdateInput): Promise<Types.Content>;
|
32
|
+
deleteContent(id: string): Promise<Types.Content>;
|
33
|
+
deleteAllContents(): Promise<void>;
|
34
|
+
summarizeContents(summarizations: [Types.SummarizationStrategyInput], filter?: Types.ContentFilter): Promise<Types.PromptSummarization[]>;
|
35
|
+
extractContents(prompt: string, filter?: Types.ContentFilter, specification?: Types.EntityReferenceInput): Promise<Types.ExtractCompletion[]>;
|
36
|
+
publishContents(summaryPrompt: string, summarySpecification: Types.EntityReferenceInput, connector: Types.ContentPublishingConnectorInput, publishPrompt?: string, publishSpecification?: Types.EntityReferenceInput, name?: string, filter?: Types.ContentFilter, workflow?: Types.EntityReferenceInput): Promise<Types.Content>;
|
37
|
+
getContent(id: string): Promise<Types.Content>;
|
38
|
+
queryContents(filter: Types.ContentFilter): Promise<Types.ContentResults>;
|
39
|
+
createConversation(conversation: Types.ConversationInput): Promise<Types.Conversation>;
|
40
|
+
updateConversation(conversation: Types.ConversationUpdateInput): Promise<Types.Conversation>;
|
41
|
+
deleteConversation(id: string): Promise<Types.Conversation>;
|
42
|
+
deleteAllConversations(): Promise<void>;
|
43
|
+
clearConversation(id: string): Promise<Types.Conversation>;
|
44
|
+
closeConversation(id: string): Promise<Types.Conversation>;
|
45
|
+
getConversation(id: string): Promise<Types.Conversation>;
|
46
|
+
queryConversations(filter: Types.ConversationFilter): Promise<Types.ConversationResults>;
|
47
|
+
promptConversation(prompt: string, id?: string): Promise<Types.PromptConversation>;
|
48
|
+
publishConversation(id: string, connector: Types.ContentPublishingConnectorInput, name?: string, workflow?: Types.EntityReferenceInput): Promise<Types.Content>;
|
49
|
+
suggestConversation(id: string, count?: number): Promise<Types.PromptSuggestion>;
|
50
|
+
createFeed(feed: Types.FeedInput): Promise<Types.Feed>;
|
51
|
+
updateFeed(feed: Types.FeedUpdateInput): Promise<Types.Feed>;
|
52
|
+
deleteFeed(id: string): Promise<Types.Feed>;
|
53
|
+
deleteAllFeeds(): Promise<void>;
|
54
|
+
enableFeed(id: string): Promise<Types.Feed>;
|
55
|
+
disableFeed(id: string): Promise<Types.Feed>;
|
56
|
+
getFeed(id: string): Promise<Types.Feed>;
|
57
|
+
queryFeeds(filter: Types.FeedFilter): Promise<Types.FeedResults>;
|
58
|
+
promptSpecifications(prompt: string, ids: [string]): Promise<Types.PromptCompletion[]>;
|
59
|
+
createSpecification(specification: Types.SpecificationInput): Promise<Types.Specification>;
|
60
|
+
updateSpecification(specification: Types.SpecificationUpdateInput): Promise<Types.Specification>;
|
61
|
+
deleteSpecification(id: string): Promise<Types.Specification>;
|
62
|
+
getSpecification(id: string): Promise<Types.Specification>;
|
63
|
+
querySpecifications(filter: Types.SpecificationFilter): Promise<Types.SpecificationResults>;
|
64
|
+
createWorkflow(workflow: Types.WorkflowInput): Promise<Types.Workflow>;
|
65
|
+
updateWorkflow(workflow: Types.WorkflowUpdateInput): Promise<Types.Workflow>;
|
66
|
+
deleteWorkflow(id: string): Promise<Types.Workflow>;
|
67
|
+
deleteAllWorkflows(): Promise<void>;
|
68
|
+
getWorkflow(id: string): Promise<Types.Workflow>;
|
69
|
+
queryWorkflows(filter: Types.WorkflowFilter): Promise<Types.WorkflowResults>;
|
70
70
|
private mutateAndCheckError;
|
71
71
|
private queryAndCheckError;
|
72
72
|
}
|
package/dist/client.js
CHANGED
@@ -118,14 +118,14 @@ class Graphlit {
|
|
118
118
|
return this.queryAndCheckError(Documents.QueryAlerts, { filter: filter });
|
119
119
|
});
|
120
120
|
}
|
121
|
-
createCollection(
|
121
|
+
createCollection(Collection) {
|
122
122
|
return __awaiter(this, void 0, void 0, function* () {
|
123
|
-
return this.mutateAndCheckError(Documents.CreateCollection, {
|
123
|
+
return this.mutateAndCheckError(Documents.CreateCollection, { Collection: Collection });
|
124
124
|
});
|
125
125
|
}
|
126
|
-
updateCollection(
|
126
|
+
updateCollection(Collection) {
|
127
127
|
return __awaiter(this, void 0, void 0, function* () {
|
128
|
-
return this.mutateAndCheckError(Documents.UpdateCollection, {
|
128
|
+
return this.mutateAndCheckError(Documents.UpdateCollection, { Collection: Collection });
|
129
129
|
});
|
130
130
|
}
|
131
131
|
deleteCollection(id) {
|
@@ -134,8 +134,10 @@ class Graphlit {
|
|
134
134
|
});
|
135
135
|
}
|
136
136
|
/*
|
137
|
-
public async deleteAllCollections() {
|
138
|
-
return this.mutateAndCheckError(
|
137
|
+
public async deleteAllCollections(): Promise<void> {
|
138
|
+
return this.mutateAndCheckError<void>(
|
139
|
+
Documents.DeleteAllCollections
|
140
|
+
);
|
139
141
|
}
|
140
142
|
*/
|
141
143
|
addContentsToCollections(contents, collections) {
|
@@ -243,29 +245,29 @@ class Graphlit {
|
|
243
245
|
return this.mutateAndCheckError(Documents.CloseConversation, { id: id });
|
244
246
|
});
|
245
247
|
}
|
246
|
-
|
248
|
+
getConversation(id) {
|
247
249
|
return __awaiter(this, void 0, void 0, function* () {
|
248
|
-
return this.
|
250
|
+
return this.queryAndCheckError(Documents.GetConversation, { id: id });
|
249
251
|
});
|
250
252
|
}
|
251
|
-
|
253
|
+
queryConversations(filter) {
|
252
254
|
return __awaiter(this, void 0, void 0, function* () {
|
253
|
-
return this.
|
255
|
+
return this.queryAndCheckError(Documents.QueryConversations, { filter: filter });
|
254
256
|
});
|
255
257
|
}
|
256
|
-
|
258
|
+
promptConversation(prompt, id) {
|
257
259
|
return __awaiter(this, void 0, void 0, function* () {
|
258
|
-
return this.mutateAndCheckError(Documents.
|
260
|
+
return this.mutateAndCheckError(Documents.PromptConversation, { prompt: prompt, id: id, correlationId: this.correlationId });
|
259
261
|
});
|
260
262
|
}
|
261
|
-
|
263
|
+
publishConversation(id, connector, name, workflow) {
|
262
264
|
return __awaiter(this, void 0, void 0, function* () {
|
263
|
-
return this.
|
265
|
+
return this.mutateAndCheckError(Documents.PublishConversation, { id: id, connector: connector, name: name, workflow: workflow, correlationId: this.correlationId });
|
264
266
|
});
|
265
267
|
}
|
266
|
-
|
268
|
+
suggestConversation(id, count) {
|
267
269
|
return __awaiter(this, void 0, void 0, function* () {
|
268
|
-
return this.
|
270
|
+
return this.mutateAndCheckError(Documents.SuggestConversation, { id: id, count: count, correlationId: this.correlationId });
|
269
271
|
});
|
270
272
|
}
|
271
273
|
createFeed(feed) {
|
@@ -309,6 +311,11 @@ class Graphlit {
|
|
309
311
|
});
|
310
312
|
}
|
311
313
|
// TODO: project credits, usage, etc.
|
314
|
+
promptSpecifications(prompt, ids) {
|
315
|
+
return __awaiter(this, void 0, void 0, function* () {
|
316
|
+
return this.mutateAndCheckError(Documents.PromptSpecifications, { prompt: prompt, ids: ids });
|
317
|
+
});
|
318
|
+
}
|
312
319
|
createSpecification(specification) {
|
313
320
|
return __awaiter(this, void 0, void 0, function* () {
|
314
321
|
return this.mutateAndCheckError(Documents.CreateSpecification, { specification: specification });
|
@@ -325,15 +332,12 @@ class Graphlit {
|
|
325
332
|
});
|
326
333
|
}
|
327
334
|
/*
|
328
|
-
public async deleteAllSpecifications() {
|
329
|
-
return this.mutateAndCheckError(
|
335
|
+
public async deleteAllSpecifications(): Promise<void> {
|
336
|
+
return this.mutateAndCheckError<void>(
|
337
|
+
Documents.DeleteAllSpecifications
|
338
|
+
);
|
330
339
|
}
|
331
340
|
*/
|
332
|
-
promptSpecifications(prompt, ids) {
|
333
|
-
return __awaiter(this, void 0, void 0, function* () {
|
334
|
-
return this.mutateAndCheckError(Documents.PromptSpecifications, { prompt: prompt, ids: ids });
|
335
|
-
});
|
336
|
-
}
|
337
341
|
getSpecification(id) {
|
338
342
|
return __awaiter(this, void 0, void 0, function* () {
|
339
343
|
return this.queryAndCheckError(Documents.GetSpecification, { id: id });
|
@@ -377,28 +381,48 @@ class Graphlit {
|
|
377
381
|
// helper functions
|
378
382
|
mutateAndCheckError(mutation, variables) {
|
379
383
|
return __awaiter(this, void 0, void 0, function* () {
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
384
|
+
try {
|
385
|
+
const result = yield this.client.mutate({
|
386
|
+
mutation,
|
387
|
+
variables: variables || {}
|
388
|
+
});
|
389
|
+
if (!result.data) {
|
390
|
+
throw new Error('No data returned from mutation.');
|
391
|
+
}
|
392
|
+
return result.data;
|
393
|
+
}
|
394
|
+
catch (error) {
|
395
|
+
if (error instanceof client_1.ApolloError && error.graphQLErrors.length > 0) {
|
396
|
+
const errorMessage = error.graphQLErrors.map(err => err.message).join("\n");
|
397
|
+
throw new Error(errorMessage);
|
398
|
+
}
|
399
|
+
else {
|
400
|
+
throw error;
|
401
|
+
}
|
387
402
|
}
|
388
|
-
return result.data;
|
389
403
|
});
|
390
404
|
}
|
391
405
|
queryAndCheckError(query, variables) {
|
392
406
|
return __awaiter(this, void 0, void 0, function* () {
|
393
|
-
|
394
|
-
query
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
407
|
+
try {
|
408
|
+
const result = yield this.client.query({
|
409
|
+
query,
|
410
|
+
variables: variables || {}
|
411
|
+
});
|
412
|
+
if (!result.data) {
|
413
|
+
throw new Error('No data returned from query');
|
414
|
+
}
|
415
|
+
return result.data;
|
416
|
+
}
|
417
|
+
catch (error) {
|
418
|
+
if (error instanceof client_1.ApolloError && error.graphQLErrors.length > 0) {
|
419
|
+
const errorMessage = error.graphQLErrors.map(err => err.message).join("\n");
|
420
|
+
throw new Error(errorMessage);
|
421
|
+
}
|
422
|
+
else {
|
423
|
+
throw error;
|
424
|
+
}
|
400
425
|
}
|
401
|
-
return result.data;
|
402
426
|
});
|
403
427
|
}
|
404
428
|
}
|