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 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<any>;
14
- updateAlert(alert: Types.AlertUpdateInput): Promise<any>;
15
- deleteAlert(id: string): Promise<any>;
16
- deleteAllAlerts(): Promise<any>;
17
- enableAlert(id: string): Promise<any>;
18
- disableAlert(id: string): Promise<any>;
19
- getAlert(id: string): Promise<any>;
20
- queryAlerts(filter: Types.AlertFilter): Promise<any>;
21
- createCollection(collection: Types.CollectionInput): Promise<any>;
22
- updateCollection(collection: Types.CollectionUpdateInput): Promise<any>;
23
- deleteCollection(id: string): Promise<any>;
24
- addContentsToCollections(contents: Types.EntityReferenceInput[], collections: Types.EntityReferenceInput[]): Promise<any>;
25
- removeContentsFromCollection(contents: Types.EntityReferenceInput[], collection: Types.EntityReferenceInput): Promise<any>;
26
- getCollection(id: string): Promise<any>;
27
- queryCollections(filter: Types.CollectionFilter): Promise<any>;
28
- ingestUri(uri: string, name?: string, id?: string, isSynchronous?: boolean, workflow?: Types.EntityReferenceInput): Promise<any>;
29
- ingestText(name: string, text: string, textType?: Types.TextTypes, uri?: string, id?: string, isSynchronous?: boolean, workflow?: Types.EntityReferenceInput): Promise<any>;
30
- ingestEncodedFile(name: string, data: string, mimeType: string, id?: string, isSynchronous?: boolean, workflow?: Types.EntityReferenceInput): Promise<any>;
31
- updateContent(content: Types.ContentUpdateInput): Promise<any>;
32
- deleteContent(id: string): Promise<any>;
33
- deleteAllContents(): Promise<any>;
34
- summarizeContents(summarizations: [Types.SummarizationStrategyInput], filter?: Types.ContentFilter): Promise<any>;
35
- extractContents(prompt: string, filter?: Types.ContentFilter, specification?: Types.EntityReferenceInput): Promise<any>;
36
- publishContents(summaryPrompt: string, summarySpecification: Types.EntityReferenceInput, connector: Types.ContentPublishingConnectorInput, publishPrompt?: string, publishSpecification?: Types.EntityReferenceInput, name?: string, filter?: Types.ContentFilter, workflow?: Types.EntityReferenceInput): Promise<any>;
37
- getContent(id: string): Promise<any>;
38
- queryContents(filter: Types.ContentFilter): Promise<any>;
39
- createConversation(conversation: Types.ConversationInput): Promise<any>;
40
- updateConversation(conversation: Types.ConversationUpdateInput): Promise<any>;
41
- deleteConversation(id: string): Promise<any>;
42
- deleteAllConversations(): Promise<any>;
43
- clearConversation(id: string): Promise<any>;
44
- closeConversation(id: string): Promise<any>;
45
- promptConversation(prompt: string, id?: string): Promise<any>;
46
- publishConversation(id: string, connector: Types.ContentPublishingConnectorInput, name?: string, workflow?: Types.EntityReferenceInput): Promise<any>;
47
- suggestConversation(id: string, count?: number): Promise<any>;
48
- getConversation(id: string): Promise<any>;
49
- queryConversations(filter: Types.ConversationFilter): Promise<any>;
50
- createFeed(feed: Types.FeedInput): Promise<any>;
51
- updateFeed(feed: Types.FeedUpdateInput): Promise<any>;
52
- deleteFeed(id: string): Promise<any>;
53
- deleteAllFeeds(): Promise<any>;
54
- enableFeed(id: string): Promise<any>;
55
- disableFeed(id: string): Promise<any>;
56
- getFeed(id: string): Promise<any>;
57
- queryFeeds(filter: Types.FeedFilter): Promise<any>;
58
- createSpecification(specification: Types.SpecificationInput): Promise<any>;
59
- updateSpecification(specification: Types.SpecificationUpdateInput): Promise<any>;
60
- deleteSpecification(id: string): Promise<any>;
61
- promptSpecifications(prompt: string, ids: [string]): Promise<any>;
62
- getSpecification(id: string): Promise<any>;
63
- querySpecifications(filter: Types.SpecificationFilter): Promise<any>;
64
- createWorkflow(workflow: Types.WorkflowInput): Promise<any>;
65
- updateWorkflow(workflow: Types.WorkflowUpdateInput): Promise<any>;
66
- deleteWorkflow(id: string): Promise<any>;
67
- deleteAllWorkflows(): Promise<any>;
68
- getWorkflow(id: string): Promise<any>;
69
- queryWorkflows(filter: Types.WorkflowFilter): Promise<any>;
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(collection) {
121
+ createCollection(Collection) {
122
122
  return __awaiter(this, void 0, void 0, function* () {
123
- return this.mutateAndCheckError(Documents.CreateCollection, { collection: collection });
123
+ return this.mutateAndCheckError(Documents.CreateCollection, { Collection: Collection });
124
124
  });
125
125
  }
126
- updateCollection(collection) {
126
+ updateCollection(Collection) {
127
127
  return __awaiter(this, void 0, void 0, function* () {
128
- return this.mutateAndCheckError(Documents.UpdateCollection, { collection: collection });
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(Documents.DeleteAllCollections);
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
- promptConversation(prompt, id) {
248
+ getConversation(id) {
247
249
  return __awaiter(this, void 0, void 0, function* () {
248
- return this.mutateAndCheckError(Documents.PromptConversation, { prompt: prompt, id: id, correlationId: this.correlationId });
250
+ return this.queryAndCheckError(Documents.GetConversation, { id: id });
249
251
  });
250
252
  }
251
- publishConversation(id, connector, name, workflow) {
253
+ queryConversations(filter) {
252
254
  return __awaiter(this, void 0, void 0, function* () {
253
- return this.mutateAndCheckError(Documents.PublishConversation, { id: id, connector: connector, name: name, workflow: workflow, correlationId: this.correlationId });
255
+ return this.queryAndCheckError(Documents.QueryConversations, { filter: filter });
254
256
  });
255
257
  }
256
- suggestConversation(id, count) {
258
+ promptConversation(prompt, id) {
257
259
  return __awaiter(this, void 0, void 0, function* () {
258
- return this.mutateAndCheckError(Documents.SuggestConversation, { id: id, count: count, correlationId: this.correlationId });
260
+ return this.mutateAndCheckError(Documents.PromptConversation, { prompt: prompt, id: id, correlationId: this.correlationId });
259
261
  });
260
262
  }
261
- getConversation(id) {
263
+ publishConversation(id, connector, name, workflow) {
262
264
  return __awaiter(this, void 0, void 0, function* () {
263
- return this.queryAndCheckError(Documents.GetConversation, { id: id });
265
+ return this.mutateAndCheckError(Documents.PublishConversation, { id: id, connector: connector, name: name, workflow: workflow, correlationId: this.correlationId });
264
266
  });
265
267
  }
266
- queryConversations(filter) {
268
+ suggestConversation(id, count) {
267
269
  return __awaiter(this, void 0, void 0, function* () {
268
- return this.queryAndCheckError(Documents.QueryConversations, { filter: filter });
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(Documents.DeleteAllSpecifications);
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
- const result = yield this.client.mutate({
381
- mutation,
382
- variables,
383
- });
384
- if (result.errors && result.errors.length > 0) {
385
- const errorMessage = result.errors.map(error => error.message).join("\n");
386
- throw new Error(errorMessage);
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
- const result = yield this.client.query({
394
- query,
395
- variables,
396
- });
397
- if (result.errors && result.errors.length > 0) {
398
- const errorMessage = result.errors.map(error => error.message).join("\n");
399
- throw new Error(errorMessage);
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graphlit-client",
3
- "version": "1.0.20240418005",
3
+ "version": "1.0.20240418006",
4
4
  "description": "Graphlit API TypeScript Client",
5
5
  "main": "dist/client.js",
6
6
  "types": "dist/client.d.ts",