graphlit-client 1.0.20240417001
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/LICENSE +21 -0
- package/README.md +53 -0
- package/dist/client.js +320 -0
- package/dist/generated/graphql-documents.js +2302 -0
- package/dist/generated/graphql-types.js +1257 -0
- package/package.json +38 -0
package/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2024 Unstruk Data Inc.
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# TypeScript Client for Graphlit Platform
|
2
|
+
## Overview
|
3
|
+
|
4
|
+
The Graphlit Client for Node.js enables straightforward interactions with the Graphlit API, allowing developers to execute GraphQL queries and mutations against the Graphlit service. This document outlines the setup process and provides a basic example of using the client.
|
5
|
+
|
6
|
+
## Prerequisites
|
7
|
+
|
8
|
+
Before you begin, ensure you have the following:
|
9
|
+
|
10
|
+
- Node.js installed on your system (recommended version 20.x or higher).
|
11
|
+
- An active account on the [Graphlit Platform](https://portal.graphlit.dev) with access to the API settings dashboard.
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
To install the Graphlit Client, use npm or yarn:
|
16
|
+
|
17
|
+
```bash
|
18
|
+
npm install graphlit
|
19
|
+
```
|
20
|
+
or
|
21
|
+
```bash
|
22
|
+
yarn add graphlit
|
23
|
+
```
|
24
|
+
|
25
|
+
## Configuration
|
26
|
+
|
27
|
+
The Graphlit Client supports environment variables to be set for authentication and configuration:
|
28
|
+
|
29
|
+
- `GRAPHLIT_ENVIRONMENT_ID`: Your environment ID.
|
30
|
+
- `GRAPHLIT_ORGANIZATION_ID`: Your organization ID.
|
31
|
+
- `GRAPHLIT_JWT_SECRET`: Your JWT secret for signing the JWT token.
|
32
|
+
|
33
|
+
Alternately, you can pass these values with the constructor of the Graphlit client.
|
34
|
+
|
35
|
+
You can find these values in the API settings dashboard on the [Graphlit Platform](https://portal.graphlit.dev).
|
36
|
+
|
37
|
+
### Setting Environment Variables
|
38
|
+
|
39
|
+
To set these environment variables on your system, you can place them in a `.env` file at the root of your project:
|
40
|
+
|
41
|
+
```env
|
42
|
+
GRAPHLIT_ENVIRONMENT_ID=your_environment_id_value
|
43
|
+
GRAPHLIT_ORGANIZATION_ID=your_organization_id_value
|
44
|
+
GRAPHLIT_JWT_SECRET=your_jwt_secret_value
|
45
|
+
```
|
46
|
+
|
47
|
+
## Support
|
48
|
+
|
49
|
+
Please refer to the [Graphlit API Documentation](https://docs.graphlit.dev/).
|
50
|
+
|
51
|
+
For support with the Graphlit Client, please submit a [GitHub Issue](https://github.com/graphlit/graphlit-client-typescript/issues).
|
52
|
+
|
53
|
+
For further support with the Graphlit Platform, please join our [Discord](https://discord.gg/ygFmfjy3Qx) community.
|
package/dist/client.js
ADDED
@@ -0,0 +1,320 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
+
if (mod && mod.__esModule) return mod;
|
20
|
+
var result = {};
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
+
__setModuleDefault(result, mod);
|
23
|
+
return result;
|
24
|
+
};
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
32
|
+
});
|
33
|
+
};
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
35
|
+
exports.Graphlit = void 0;
|
36
|
+
const client_1 = require("@apollo/client");
|
37
|
+
const Documents = __importStar(require("./generated/graphql-documents"));
|
38
|
+
const jwt = __importStar(require("jsonwebtoken"));
|
39
|
+
const dotenv = __importStar(require("dotenv"));
|
40
|
+
// Initialize dotenv to use environment variables
|
41
|
+
dotenv.config();
|
42
|
+
// Define the Graphlit class
|
43
|
+
class Graphlit {
|
44
|
+
constructor(environmentId, organizationId, jwtSecret, ownerId, apiUri, correlationId) {
|
45
|
+
this.apiUri = apiUri || "https://data-scus.graphlit.io/api/v1";
|
46
|
+
this.environmentId = environmentId || process.env.GRAPHLIT_ENVIRONMENT_ID;
|
47
|
+
this.organizationId = organizationId || process.env.GRAPHLIT_ORGANIZATION_ID;
|
48
|
+
this.jwtSecret = jwtSecret || process.env.GRAPHLIT_JWT_SECRET;
|
49
|
+
// optional: for multi-tenant support
|
50
|
+
this.ownerId = ownerId || process.env.GRAPHLIT_OWNER_ID;
|
51
|
+
// optional: for billing correlation of multiple operations
|
52
|
+
this.correlationId = correlationId || undefined;
|
53
|
+
// Set token expiration to one hour from now
|
54
|
+
const expiration = Math.floor(Date.now() / 1000) + (60 * 60);
|
55
|
+
const payload = {
|
56
|
+
"https://graphlit.io/jwt/claims": Object.assign(Object.assign({ "x-graphlit-environment-id": this.environmentId, "x-graphlit-organization-id": this.organizationId }, (this.ownerId && { "x-graphlit-owner-id": this.ownerId })), { "x-graphlit-role": "Owner" }),
|
57
|
+
exp: expiration,
|
58
|
+
iss: "graphlit",
|
59
|
+
aud: "https://portal.graphlit.io",
|
60
|
+
};
|
61
|
+
if (!this.jwtSecret) {
|
62
|
+
throw new Error("JWT secret is required.");
|
63
|
+
}
|
64
|
+
this.token = jwt.sign(payload, this.jwtSecret, { algorithm: 'HS256' });
|
65
|
+
const httpLink = (0, client_1.createHttpLink)({
|
66
|
+
uri: this.apiUri,
|
67
|
+
});
|
68
|
+
const authLink = new client_1.ApolloLink((operation, forward) => {
|
69
|
+
operation.setContext({
|
70
|
+
headers: {
|
71
|
+
Authorization: this.token ? `Bearer ${this.token}` : "",
|
72
|
+
}
|
73
|
+
});
|
74
|
+
return forward(operation);
|
75
|
+
});
|
76
|
+
this.client = new client_1.ApolloClient({
|
77
|
+
link: authLink.concat(httpLink),
|
78
|
+
cache: new client_1.InMemoryCache(),
|
79
|
+
});
|
80
|
+
}
|
81
|
+
alert() {
|
82
|
+
return {
|
83
|
+
create: (alert) => __awaiter(this, void 0, void 0, function* () {
|
84
|
+
return this.mutateAndCheckError(Documents.CreateAlert, { alert: alert, correlationId: this.correlationId });
|
85
|
+
}),
|
86
|
+
update: (alert) => __awaiter(this, void 0, void 0, function* () {
|
87
|
+
return this.mutateAndCheckError(Documents.UpdateAlert, { alert: alert });
|
88
|
+
}),
|
89
|
+
delete: (id) => __awaiter(this, void 0, void 0, function* () {
|
90
|
+
return this.mutateAndCheckError(Documents.DeleteAlert, { id: id });
|
91
|
+
}),
|
92
|
+
deleteAll: (mutation) => __awaiter(this, void 0, void 0, function* () {
|
93
|
+
return this.mutateAndCheckError(Documents.DeleteAllAlerts);
|
94
|
+
}),
|
95
|
+
enable: (id) => __awaiter(this, void 0, void 0, function* () {
|
96
|
+
return this.mutateAndCheckError(Documents.EnableAlert, { id: id });
|
97
|
+
}),
|
98
|
+
disable: (id) => __awaiter(this, void 0, void 0, function* () {
|
99
|
+
return this.mutateAndCheckError(Documents.DisableAlert, { id: id });
|
100
|
+
}),
|
101
|
+
get: (id) => __awaiter(this, void 0, void 0, function* () {
|
102
|
+
return this.queryAndCheckError(Documents.GetAlert, { id: id });
|
103
|
+
}),
|
104
|
+
query: (filter) => __awaiter(this, void 0, void 0, function* () {
|
105
|
+
return this.queryAndCheckError(Documents.QueryAlerts, { filter: filter });
|
106
|
+
}),
|
107
|
+
};
|
108
|
+
}
|
109
|
+
collection() {
|
110
|
+
return {
|
111
|
+
create: (collection) => __awaiter(this, void 0, void 0, function* () {
|
112
|
+
return this.mutateAndCheckError(Documents.CreateCollection, { collection: collection });
|
113
|
+
}),
|
114
|
+
update: (collection) => __awaiter(this, void 0, void 0, function* () {
|
115
|
+
return this.mutateAndCheckError(Documents.UpdateCollection, { collection: collection });
|
116
|
+
}),
|
117
|
+
delete: (id) => __awaiter(this, void 0, void 0, function* () {
|
118
|
+
return this.mutateAndCheckError(Documents.DeleteCollection, { id: id });
|
119
|
+
}),
|
120
|
+
/*
|
121
|
+
deleteAll: async (mutation?: any) => {
|
122
|
+
return this.mutateAndCheckError(Documents.DeleteAllCollections);
|
123
|
+
},
|
124
|
+
*/
|
125
|
+
add: (contents, collections) => __awaiter(this, void 0, void 0, function* () {
|
126
|
+
return this.mutateAndCheckError(Documents.AddContentsToCollections, { contents: contents, collections: collections });
|
127
|
+
}),
|
128
|
+
remove: (contents, collection) => __awaiter(this, void 0, void 0, function* () {
|
129
|
+
return this.mutateAndCheckError(Documents.RemoveContentsFromCollection, { contents: contents, collection: collection });
|
130
|
+
}),
|
131
|
+
get: (id) => __awaiter(this, void 0, void 0, function* () {
|
132
|
+
return this.queryAndCheckError(Documents.GetCollection, { id: id });
|
133
|
+
}),
|
134
|
+
query: (filter) => __awaiter(this, void 0, void 0, function* () {
|
135
|
+
return this.queryAndCheckError(Documents.QueryCollections, { filter: filter });
|
136
|
+
}),
|
137
|
+
};
|
138
|
+
}
|
139
|
+
content() {
|
140
|
+
return {
|
141
|
+
ingestUri: (uri, name, id, isSynchronous, workflow) => __awaiter(this, void 0, void 0, function* () {
|
142
|
+
return this.mutateAndCheckError(Documents.IngestUri, { uri: uri, name: name, id: id, isSynchronous: isSynchronous, workflow: workflow, correlationId: this.correlationId });
|
143
|
+
}),
|
144
|
+
ingestText: (name, text, textType, uri, id, isSynchronous, workflow) => __awaiter(this, void 0, void 0, function* () {
|
145
|
+
return this.mutateAndCheckError(Documents.IngestText, { name: name, text: text, textType: textType, uri: uri, id: id, isSynchronous: isSynchronous, workflow: workflow, correlationId: this.correlationId });
|
146
|
+
}),
|
147
|
+
ingestEncodedFile: (name, data, mimeType, id, isSynchronous, workflow) => __awaiter(this, void 0, void 0, function* () {
|
148
|
+
return this.mutateAndCheckError(Documents.IngestEncodedFile, { name: name, data: data, mimeType: mimeType, id: id, isSynchronous: isSynchronous, workflow: workflow, correlationId: this.correlationId });
|
149
|
+
}),
|
150
|
+
update: (content) => __awaiter(this, void 0, void 0, function* () {
|
151
|
+
return this.mutateAndCheckError(Documents.UpdateContent, { content: content });
|
152
|
+
}),
|
153
|
+
delete: (id) => __awaiter(this, void 0, void 0, function* () {
|
154
|
+
return this.mutateAndCheckError(Documents.DeleteContent, { id: id });
|
155
|
+
}),
|
156
|
+
deleteAll: (mutation) => __awaiter(this, void 0, void 0, function* () {
|
157
|
+
return this.mutateAndCheckError(Documents.DeleteAllContents);
|
158
|
+
}),
|
159
|
+
summarize: (summarizations, filter) => __awaiter(this, void 0, void 0, function* () {
|
160
|
+
return this.mutateAndCheckError(Documents.SummarizeContents, { summarizations: summarizations, filter: filter, correlationId: this.correlationId });
|
161
|
+
}),
|
162
|
+
extract: (prompt, filter, specification) => __awaiter(this, void 0, void 0, function* () {
|
163
|
+
return this.mutateAndCheckError(Documents.ExtractContents, { prompt: prompt, filter: filter, specification: specification, correlationId: this.correlationId });
|
164
|
+
}),
|
165
|
+
publish: (summaryPrompt, summarySpecification, connector, publishPrompt, publishSpecification, name, filter, workflow) => __awaiter(this, void 0, void 0, function* () {
|
166
|
+
return this.mutateAndCheckError(Documents.PublishContents, { summaryPrompt: summaryPrompt, summarySpecification: summarySpecification, connector: connector, publishPrompt: publishPrompt, publishSpecification: publishSpecification, name: name, filter: filter, workflow: workflow, correlationId: this.correlationId });
|
167
|
+
}),
|
168
|
+
get: (id) => __awaiter(this, void 0, void 0, function* () {
|
169
|
+
return this.queryAndCheckError(Documents.GetContent, { id: id });
|
170
|
+
}),
|
171
|
+
query: (filter) => __awaiter(this, void 0, void 0, function* () {
|
172
|
+
return this.queryAndCheckError(Documents.QueryContents, { filter: filter });
|
173
|
+
}),
|
174
|
+
};
|
175
|
+
}
|
176
|
+
conversation() {
|
177
|
+
return {
|
178
|
+
create: (conversation) => __awaiter(this, void 0, void 0, function* () {
|
179
|
+
return this.mutateAndCheckError(Documents.CreateConversation, { conversation: conversation, correlationId: this.correlationId });
|
180
|
+
}),
|
181
|
+
update: (conversation) => __awaiter(this, void 0, void 0, function* () {
|
182
|
+
return this.mutateAndCheckError(Documents.UpdateConversation, { conversation: conversation });
|
183
|
+
}),
|
184
|
+
delete: (id) => __awaiter(this, void 0, void 0, function* () {
|
185
|
+
return this.mutateAndCheckError(Documents.DeleteConversation, { id: id });
|
186
|
+
}),
|
187
|
+
deleteAll: (mutation) => __awaiter(this, void 0, void 0, function* () {
|
188
|
+
return this.mutateAndCheckError(Documents.DeleteAllConversations);
|
189
|
+
}),
|
190
|
+
clear: (id) => __awaiter(this, void 0, void 0, function* () {
|
191
|
+
return this.mutateAndCheckError(Documents.ClearConversation, { id: id });
|
192
|
+
}),
|
193
|
+
close: (id) => __awaiter(this, void 0, void 0, function* () {
|
194
|
+
return this.mutateAndCheckError(Documents.CloseConversation, { id: id });
|
195
|
+
}),
|
196
|
+
prompt: (prompt, id) => __awaiter(this, void 0, void 0, function* () {
|
197
|
+
return this.mutateAndCheckError(Documents.PromptConversation, { prompt: prompt, id: id, correlationId: this.correlationId });
|
198
|
+
}),
|
199
|
+
publish: (id, connector, name, workflow) => __awaiter(this, void 0, void 0, function* () {
|
200
|
+
return this.mutateAndCheckError(Documents.PublishConversation, { id: id, connector: connector, name: name, workflow: workflow, correlationId: this.correlationId });
|
201
|
+
}),
|
202
|
+
suggest: (id, count) => __awaiter(this, void 0, void 0, function* () {
|
203
|
+
return this.mutateAndCheckError(Documents.SuggestConversation, { id: id, count: count, correlationId: this.correlationId });
|
204
|
+
}),
|
205
|
+
get: (id) => __awaiter(this, void 0, void 0, function* () {
|
206
|
+
return this.queryAndCheckError(Documents.GetConversation, { id: id });
|
207
|
+
}),
|
208
|
+
query: (filter) => __awaiter(this, void 0, void 0, function* () {
|
209
|
+
return this.queryAndCheckError(Documents.QueryConversations, { filter: filter });
|
210
|
+
}),
|
211
|
+
};
|
212
|
+
}
|
213
|
+
feed() {
|
214
|
+
return {
|
215
|
+
create: (feed) => __awaiter(this, void 0, void 0, function* () {
|
216
|
+
return this.mutateAndCheckError(Documents.CreateFeed, { feed: feed, correlationId: this.correlationId });
|
217
|
+
}),
|
218
|
+
update: (feed) => __awaiter(this, void 0, void 0, function* () {
|
219
|
+
return this.mutateAndCheckError(Documents.UpdateFeed, { feed: feed });
|
220
|
+
}),
|
221
|
+
delete: (id) => __awaiter(this, void 0, void 0, function* () {
|
222
|
+
return this.mutateAndCheckError(Documents.DeleteFeed, { id: id });
|
223
|
+
}),
|
224
|
+
deleteAll: (mutation) => __awaiter(this, void 0, void 0, function* () {
|
225
|
+
return this.mutateAndCheckError(Documents.DeleteAllFeeds);
|
226
|
+
}),
|
227
|
+
enable: (id) => __awaiter(this, void 0, void 0, function* () {
|
228
|
+
return this.mutateAndCheckError(Documents.EnableFeed, { id: id });
|
229
|
+
}),
|
230
|
+
disable: (id) => __awaiter(this, void 0, void 0, function* () {
|
231
|
+
return this.mutateAndCheckError(Documents.DisableFeed, { id: id });
|
232
|
+
}),
|
233
|
+
get: (id) => __awaiter(this, void 0, void 0, function* () {
|
234
|
+
return this.queryAndCheckError(Documents.GetFeed, { id: id });
|
235
|
+
}),
|
236
|
+
query: (filter) => __awaiter(this, void 0, void 0, function* () {
|
237
|
+
return this.queryAndCheckError(Documents.QueryFeeds, { filter: filter });
|
238
|
+
}),
|
239
|
+
};
|
240
|
+
}
|
241
|
+
project() {
|
242
|
+
// TODO: credits, usage, etc.
|
243
|
+
}
|
244
|
+
specification() {
|
245
|
+
return {
|
246
|
+
create: (specification) => __awaiter(this, void 0, void 0, function* () {
|
247
|
+
return this.mutateAndCheckError(Documents.CreateSpecification, { specification: specification });
|
248
|
+
}),
|
249
|
+
update: (specification) => __awaiter(this, void 0, void 0, function* () {
|
250
|
+
return this.mutateAndCheckError(Documents.UpdateSpecification, { specification: specification });
|
251
|
+
}),
|
252
|
+
delete: (id) => __awaiter(this, void 0, void 0, function* () {
|
253
|
+
return this.mutateAndCheckError(Documents.DeleteSpecification, { id: id });
|
254
|
+
}),
|
255
|
+
/*
|
256
|
+
deleteAll: async (mutation?: any) => {
|
257
|
+
return this.mutateAndCheckError(Documents.DeleteAllSpecifications);
|
258
|
+
},
|
259
|
+
*/
|
260
|
+
prompt: (prompt, ids) => __awaiter(this, void 0, void 0, function* () {
|
261
|
+
return this.mutateAndCheckError(Documents.PromptSpecifications, { prompt: prompt, ids: ids });
|
262
|
+
}),
|
263
|
+
get: (id) => __awaiter(this, void 0, void 0, function* () {
|
264
|
+
return this.queryAndCheckError(Documents.GetSpecification, { id: id });
|
265
|
+
}),
|
266
|
+
query: (filter) => __awaiter(this, void 0, void 0, function* () {
|
267
|
+
return this.queryAndCheckError(Documents.QuerySpecifications, { filter: filter });
|
268
|
+
}),
|
269
|
+
};
|
270
|
+
}
|
271
|
+
workflow() {
|
272
|
+
return {
|
273
|
+
create: (workflow) => __awaiter(this, void 0, void 0, function* () {
|
274
|
+
return this.mutateAndCheckError(Documents.CreateWorkflow, { workflow: workflow });
|
275
|
+
}),
|
276
|
+
update: (workflow) => __awaiter(this, void 0, void 0, function* () {
|
277
|
+
return this.mutateAndCheckError(Documents.UpdateWorkflow, { workflow: workflow });
|
278
|
+
}),
|
279
|
+
delete: (id) => __awaiter(this, void 0, void 0, function* () {
|
280
|
+
return this.mutateAndCheckError(Documents.DeleteWorkflow, { id: id });
|
281
|
+
}),
|
282
|
+
deleteAll: (mutation) => __awaiter(this, void 0, void 0, function* () {
|
283
|
+
return this.mutateAndCheckError(Documents.DeleteAllWorkflows);
|
284
|
+
}),
|
285
|
+
get: (id) => __awaiter(this, void 0, void 0, function* () {
|
286
|
+
return this.queryAndCheckError(Documents.GetWorkflow, { id: id });
|
287
|
+
}),
|
288
|
+
query: (filter) => __awaiter(this, void 0, void 0, function* () {
|
289
|
+
return this.queryAndCheckError(Documents.QueryWorkflows, { filter: filter });
|
290
|
+
}),
|
291
|
+
};
|
292
|
+
}
|
293
|
+
mutateAndCheckError(mutation, variables) {
|
294
|
+
return __awaiter(this, void 0, void 0, function* () {
|
295
|
+
const result = yield this.client.mutate({
|
296
|
+
mutation,
|
297
|
+
variables,
|
298
|
+
});
|
299
|
+
if (result.errors && result.errors.length > 0) {
|
300
|
+
const errorMessage = result.errors.map(error => error.message).join("\n");
|
301
|
+
throw new Error(errorMessage);
|
302
|
+
}
|
303
|
+
return result.data;
|
304
|
+
});
|
305
|
+
}
|
306
|
+
queryAndCheckError(query, variables) {
|
307
|
+
return __awaiter(this, void 0, void 0, function* () {
|
308
|
+
const result = yield this.client.query({
|
309
|
+
query,
|
310
|
+
variables,
|
311
|
+
});
|
312
|
+
if (result.errors && result.errors.length > 0) {
|
313
|
+
const errorMessage = result.errors.map(error => error.message).join("\n");
|
314
|
+
throw new Error(errorMessage);
|
315
|
+
}
|
316
|
+
return result.data;
|
317
|
+
});
|
318
|
+
}
|
319
|
+
}
|
320
|
+
exports.Graphlit = Graphlit;
|