graphlit-client 1.0.20240418025 → 1.0.20240418027

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
@@ -3,14 +3,13 @@ import * as Types from './generated/graphql-types';
3
3
  declare class Graphlit {
4
4
  client: ApolloClient<NormalizedCacheObject> | undefined;
5
5
  token: string | undefined;
6
- correlationId: string | undefined;
7
6
  private apiUri;
8
7
  private organizationId;
9
8
  private environmentId;
10
9
  private ownerId;
11
10
  private jwtSecret;
12
- constructor(organizationId?: string, environmentId?: string, jwtSecret?: string, ownerId?: string, apiUri?: string, correlationId?: string);
13
- createAlert(alert: Types.AlertInput): Promise<Types.CreateAlertMutation>;
11
+ constructor(organizationId?: string, environmentId?: string, jwtSecret?: string, ownerId?: string, apiUri?: string);
12
+ createAlert(alert: Types.AlertInput, correlationId?: string): Promise<Types.CreateAlertMutation>;
14
13
  updateAlert(alert: Types.AlertUpdateInput): Promise<Types.UpdateAlertMutation>;
15
14
  deleteAlert(id: string): Promise<Types.DeleteAlertMutation>;
16
15
  deleteAllAlerts(): Promise<Types.DeleteAllAlertsMutation>;
@@ -25,18 +24,18 @@ declare class Graphlit {
25
24
  removeContentsFromCollection(contents: Types.EntityReferenceInput[], collection: Types.EntityReferenceInput): Promise<Types.RemoveContentsFromCollectionMutation>;
26
25
  getCollection(id: string): Promise<Types.GetCollectionQuery>;
27
26
  queryCollections(filter?: Types.CollectionFilter): Promise<Types.QueryCollectionsQuery>;
28
- ingestUri(uri: string, name?: string, id?: string, isSynchronous?: boolean, workflow?: Types.EntityReferenceInput): Promise<Types.IngestUriMutation>;
29
- ingestText(name: string, text: string, textType?: Types.TextTypes, uri?: string, id?: string, isSynchronous?: boolean, workflow?: Types.EntityReferenceInput): Promise<Types.IngestTextMutation>;
30
- ingestEncodedFile(name: string, data: string, mimeType: string, id?: string, isSynchronous?: boolean, workflow?: Types.EntityReferenceInput): Promise<Types.IngestEncodedFileMutation>;
27
+ ingestUri(uri: string, name?: string, id?: string, isSynchronous?: boolean, workflow?: Types.EntityReferenceInput, correlationId?: string): Promise<Types.IngestUriMutation>;
28
+ ingestText(name: string, text: string, textType?: Types.TextTypes, uri?: string, id?: string, isSynchronous?: boolean, workflow?: Types.EntityReferenceInput, correlationId?: string): Promise<Types.IngestTextMutation>;
29
+ ingestEncodedFile(name: string, data: string, mimeType: string, id?: string, isSynchronous?: boolean, workflow?: Types.EntityReferenceInput, correlationId?: string): Promise<Types.IngestEncodedFileMutation>;
31
30
  updateContent(content: Types.ContentUpdateInput): Promise<Types.UpdateContentMutation>;
32
31
  deleteContent(id: string): Promise<Types.DeleteContentMutation>;
33
32
  deleteAllContents(): Promise<Types.DeleteAllContentsMutation>;
34
- summarizeContents(summarizations: [Types.SummarizationStrategyInput], filter?: Types.ContentFilter): Promise<Types.SummarizeContentsMutation>;
35
- extractContents(prompt: string, filter?: Types.ContentFilter, specification?: Types.EntityReferenceInput): Promise<Types.ExtractContentsMutation>;
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.PublishContentsMutation>;
33
+ summarizeContents(summarizations: [Types.SummarizationStrategyInput], filter?: Types.ContentFilter, correlationId?: string): Promise<Types.SummarizeContentsMutation>;
34
+ extractContents(prompt: string, filter?: Types.ContentFilter, specification?: Types.EntityReferenceInput, correlationId?: string): Promise<Types.ExtractContentsMutation>;
35
+ publishContents(summaryPrompt: string, summarySpecification: Types.EntityReferenceInput, connector: Types.ContentPublishingConnectorInput, publishPrompt?: string, publishSpecification?: Types.EntityReferenceInput, name?: string, filter?: Types.ContentFilter, workflow?: Types.EntityReferenceInput, correlationId?: string): Promise<Types.PublishContentsMutation>;
37
36
  getContent(id: string): Promise<Types.GetContentQuery>;
38
37
  queryContents(filter?: Types.ContentFilter): Promise<Types.QueryContentsQuery>;
39
- createConversation(conversation: Types.ConversationInput): Promise<Types.CreateConversationMutation>;
38
+ createConversation(conversation: Types.ConversationInput, correlationId?: string): Promise<Types.CreateConversationMutation>;
40
39
  updateConversation(conversation: Types.ConversationUpdateInput): Promise<Types.UpdateConversationMutation>;
41
40
  deleteConversation(id: string): Promise<Types.DeleteConversationMutation>;
42
41
  deleteAllConversations(): Promise<Types.DeleteAllConversationsMutation>;
@@ -44,10 +43,10 @@ declare class Graphlit {
44
43
  closeConversation(id: string): Promise<Types.CloseConversationMutation>;
45
44
  getConversation(id: string): Promise<Types.GetConversationQuery>;
46
45
  queryConversations(filter?: Types.ConversationFilter): Promise<Types.QueryConversationsQuery>;
47
- promptConversation(prompt: string, id?: string): Promise<Types.PromptConversationMutation>;
48
- publishConversation(id: string, connector: Types.ContentPublishingConnectorInput, name?: string, workflow?: Types.EntityReferenceInput): Promise<Types.PublishConversationMutation>;
49
- suggestConversation(id: string, count?: number): Promise<Types.SuggestConversationMutation>;
50
- createFeed(feed: Types.FeedInput): Promise<Types.CreateFeedMutation>;
46
+ promptConversation(prompt: string, id?: string, correlationId?: string): Promise<Types.PromptConversationMutation>;
47
+ publishConversation(id: string, connector: Types.ContentPublishingConnectorInput, name?: string, workflow?: Types.EntityReferenceInput, correlationId?: string): Promise<Types.PublishConversationMutation>;
48
+ suggestConversation(id: string, count?: number, correlationId?: string): Promise<Types.SuggestConversationMutation>;
49
+ createFeed(feed: Types.FeedInput, correlationId?: string): Promise<Types.CreateFeedMutation>;
51
50
  updateFeed(feed: Types.FeedUpdateInput): Promise<Types.UpdateFeedMutation>;
52
51
  deleteFeed(id: string): Promise<Types.DeleteFeedMutation>;
53
52
  deleteAllFeeds(): Promise<Types.DeleteAllFeedsMutation>;
package/dist/client.js CHANGED
@@ -39,7 +39,7 @@ const Documents = __importStar(require("./generated/graphql-documents"));
39
39
  const dotenv = __importStar(require("dotenv"));
40
40
  // Define the Graphlit class
41
41
  class Graphlit {
42
- constructor(organizationId, environmentId, jwtSecret, ownerId, apiUri, correlationId) {
42
+ constructor(organizationId, environmentId, jwtSecret, ownerId, apiUri) {
43
43
  this.apiUri = apiUri || "https://data-scus.graphlit.io/api/v1/graphql";
44
44
  if (typeof process !== 'undefined') {
45
45
  dotenv.config();
@@ -56,8 +56,6 @@ class Graphlit {
56
56
  // optional: for multi-tenant support
57
57
  this.ownerId = ownerId;
58
58
  }
59
- // optional: for billing correlation of multiple operations
60
- this.correlationId = correlationId || undefined;
61
59
  if (!this.organizationId) {
62
60
  throw new Error("Graphlit organization identifier is required.");
63
61
  }
@@ -102,9 +100,9 @@ class Graphlit {
102
100
  }
103
101
  });
104
102
  }
105
- createAlert(alert) {
103
+ createAlert(alert, correlationId) {
106
104
  return __awaiter(this, void 0, void 0, function* () {
107
- return this.mutateAndCheckError(Documents.CreateAlert, { alert: alert, correlationId: this.correlationId });
105
+ return this.mutateAndCheckError(Documents.CreateAlert, { alert: alert, correlationId: correlationId });
108
106
  });
109
107
  }
110
108
  updateAlert(alert) {
@@ -184,19 +182,19 @@ class Graphlit {
184
182
  return this.queryAndCheckError(Documents.QueryCollections, { filter: filter });
185
183
  });
186
184
  }
187
- ingestUri(uri, name, id, isSynchronous, workflow) {
185
+ ingestUri(uri, name, id, isSynchronous, workflow, correlationId) {
188
186
  return __awaiter(this, void 0, void 0, function* () {
189
- return this.mutateAndCheckError(Documents.IngestUri, { uri: uri, name: name, id: id, isSynchronous: isSynchronous, workflow: workflow, correlationId: this.correlationId });
187
+ return this.mutateAndCheckError(Documents.IngestUri, { uri: uri, name: name, id: id, isSynchronous: isSynchronous, workflow: workflow, correlationId: correlationId });
190
188
  });
191
189
  }
192
- ingestText(name, text, textType, uri, id, isSynchronous, workflow) {
190
+ ingestText(name, text, textType, uri, id, isSynchronous, workflow, correlationId) {
193
191
  return __awaiter(this, void 0, void 0, function* () {
194
- return this.mutateAndCheckError(Documents.IngestText, { name: name, text: text, textType: textType, uri: uri, id: id, isSynchronous: isSynchronous, workflow: workflow, correlationId: this.correlationId });
192
+ return this.mutateAndCheckError(Documents.IngestText, { name: name, text: text, textType: textType, uri: uri, id: id, isSynchronous: isSynchronous, workflow: workflow, correlationId: correlationId });
195
193
  });
196
194
  }
197
- ingestEncodedFile(name, data, mimeType, id, isSynchronous, workflow) {
195
+ ingestEncodedFile(name, data, mimeType, id, isSynchronous, workflow, correlationId) {
198
196
  return __awaiter(this, void 0, void 0, function* () {
199
- return this.mutateAndCheckError(Documents.IngestEncodedFile, { name: name, data: data, mimeType: mimeType, id: id, isSynchronous: isSynchronous, workflow: workflow, correlationId: this.correlationId });
197
+ return this.mutateAndCheckError(Documents.IngestEncodedFile, { name: name, data: data, mimeType: mimeType, id: id, isSynchronous: isSynchronous, workflow: workflow, correlationId: correlationId });
200
198
  });
201
199
  }
202
200
  updateContent(content) {
@@ -214,19 +212,19 @@ class Graphlit {
214
212
  return this.mutateAndCheckError(Documents.DeleteAllContents);
215
213
  });
216
214
  }
217
- summarizeContents(summarizations, filter) {
215
+ summarizeContents(summarizations, filter, correlationId) {
218
216
  return __awaiter(this, void 0, void 0, function* () {
219
- return this.mutateAndCheckError(Documents.SummarizeContents, { summarizations: summarizations, filter: filter, correlationId: this.correlationId });
217
+ return this.mutateAndCheckError(Documents.SummarizeContents, { summarizations: summarizations, filter: filter, correlationId: correlationId });
220
218
  });
221
219
  }
222
- extractContents(prompt, filter, specification) {
220
+ extractContents(prompt, filter, specification, correlationId) {
223
221
  return __awaiter(this, void 0, void 0, function* () {
224
- return this.mutateAndCheckError(Documents.ExtractContents, { prompt: prompt, filter: filter, specification: specification, correlationId: this.correlationId });
222
+ return this.mutateAndCheckError(Documents.ExtractContents, { prompt: prompt, filter: filter, specification: specification, correlationId: correlationId });
225
223
  });
226
224
  }
227
- publishContents(summaryPrompt, summarySpecification, connector, publishPrompt, publishSpecification, name, filter, workflow) {
225
+ publishContents(summaryPrompt, summarySpecification, connector, publishPrompt, publishSpecification, name, filter, workflow, correlationId) {
228
226
  return __awaiter(this, void 0, void 0, function* () {
229
- return this.mutateAndCheckError(Documents.PublishContents, { summaryPrompt: summaryPrompt, summarySpecification: summarySpecification, connector: connector, publishPrompt: publishPrompt, publishSpecification: publishSpecification, name: name, filter: filter, workflow: workflow, correlationId: this.correlationId });
227
+ return this.mutateAndCheckError(Documents.PublishContents, { summaryPrompt: summaryPrompt, summarySpecification: summarySpecification, connector: connector, publishPrompt: publishPrompt, publishSpecification: publishSpecification, name: name, filter: filter, workflow: workflow, correlationId: correlationId });
230
228
  });
231
229
  }
232
230
  getContent(id) {
@@ -239,9 +237,9 @@ class Graphlit {
239
237
  return this.queryAndCheckError(Documents.QueryContents, { filter: filter });
240
238
  });
241
239
  }
242
- createConversation(conversation) {
240
+ createConversation(conversation, correlationId) {
243
241
  return __awaiter(this, void 0, void 0, function* () {
244
- return this.mutateAndCheckError(Documents.CreateConversation, { conversation: conversation, correlationId: this.correlationId });
242
+ return this.mutateAndCheckError(Documents.CreateConversation, { conversation: conversation, correlationId: correlationId });
245
243
  });
246
244
  }
247
245
  updateConversation(conversation) {
@@ -279,24 +277,24 @@ class Graphlit {
279
277
  return this.queryAndCheckError(Documents.QueryConversations, { filter: filter });
280
278
  });
281
279
  }
282
- promptConversation(prompt, id) {
280
+ promptConversation(prompt, id, correlationId) {
283
281
  return __awaiter(this, void 0, void 0, function* () {
284
- return this.mutateAndCheckError(Documents.PromptConversation, { prompt: prompt, id: id, correlationId: this.correlationId });
282
+ return this.mutateAndCheckError(Documents.PromptConversation, { prompt: prompt, id: id, correlationId: correlationId });
285
283
  });
286
284
  }
287
- publishConversation(id, connector, name, workflow) {
285
+ publishConversation(id, connector, name, workflow, correlationId) {
288
286
  return __awaiter(this, void 0, void 0, function* () {
289
- return this.mutateAndCheckError(Documents.PublishConversation, { id: id, connector: connector, name: name, workflow: workflow, correlationId: this.correlationId });
287
+ return this.mutateAndCheckError(Documents.PublishConversation, { id: id, connector: connector, name: name, workflow: workflow, correlationId: correlationId });
290
288
  });
291
289
  }
292
- suggestConversation(id, count) {
290
+ suggestConversation(id, count, correlationId) {
293
291
  return __awaiter(this, void 0, void 0, function* () {
294
- return this.mutateAndCheckError(Documents.SuggestConversation, { id: id, count: count, correlationId: this.correlationId });
292
+ return this.mutateAndCheckError(Documents.SuggestConversation, { id: id, count: count, correlationId: correlationId });
295
293
  });
296
294
  }
297
- createFeed(feed) {
295
+ createFeed(feed, correlationId) {
298
296
  return __awaiter(this, void 0, void 0, function* () {
299
- return this.mutateAndCheckError(Documents.CreateFeed, { feed: feed, correlationId: this.correlationId });
297
+ return this.mutateAndCheckError(Documents.CreateFeed, { feed: feed, correlationId: correlationId });
300
298
  });
301
299
  }
302
300
  updateFeed(feed) {
@@ -414,11 +412,9 @@ class Graphlit {
414
412
  });
415
413
  if (result.errors) {
416
414
  const errorMessage = result.errors.map(err => err.message).join("\n");
417
- console.log(errorMessage);
418
415
  throw new Error(errorMessage);
419
416
  }
420
417
  if (!result.data) {
421
- console.log('No data returned from mutation.');
422
418
  throw new Error('No data returned from mutation.');
423
419
  }
424
420
  return result.data;
@@ -426,7 +422,7 @@ class Graphlit {
426
422
  catch (error) {
427
423
  if (error instanceof core_1.ApolloError && error.graphQLErrors.length > 0) {
428
424
  const errorMessage = error.graphQLErrors.map(err => err.message).join("\n");
429
- console.log(errorMessage);
425
+ console.error(errorMessage);
430
426
  throw new Error(errorMessage);
431
427
  }
432
428
  if (error instanceof Error) {
@@ -434,7 +430,6 @@ class Graphlit {
434
430
  throw error;
435
431
  }
436
432
  else {
437
- console.error('An unexpected error occurred');
438
433
  throw error;
439
434
  }
440
435
  }
@@ -451,19 +446,17 @@ class Graphlit {
451
446
  });
452
447
  if (result.errors) {
453
448
  const errorMessage = result.errors.map(err => err.message).join("\n");
454
- console.log(errorMessage);
455
449
  throw new Error(errorMessage);
456
450
  }
457
451
  if (!result.data) {
458
- console.log('No data returned from mutation.');
459
- throw new Error('No data returned from query');
452
+ throw new Error('No data returned from query.');
460
453
  }
461
454
  return result.data;
462
455
  }
463
456
  catch (error) {
464
457
  if (error instanceof core_1.ApolloError && error.graphQLErrors.length > 0) {
465
458
  const errorMessage = error.graphQLErrors.map(err => err.message).join("\n");
466
- console.log(errorMessage);
459
+ console.error(errorMessage);
467
460
  throw new Error(errorMessage);
468
461
  }
469
462
  if (error instanceof Error) {
@@ -471,7 +464,6 @@ class Graphlit {
471
464
  throw error;
472
465
  }
473
466
  else {
474
- console.error('An unexpected error occurred');
475
467
  throw error;
476
468
  }
477
469
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graphlit-client",
3
- "version": "1.0.20240418025",
3
+ "version": "1.0.20240418027",
4
4
  "description": "Graphlit API TypeScript Client",
5
5
  "main": "dist/client.js",
6
6
  "types": "dist/client.d.ts",