• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

terminusdb / terminusdb-client-js / 4383766201

pending completion
4383766201

push

github

Francesca-Bit
review typescript declarations

841 of 4548 branches covered (18.49%)

Branch coverage included in aggregate %.

13 of 13 new or added lines in 7 files covered. (100.0%)

2435 of 6438 relevant lines covered (37.82%)

4.01 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

21.68
/lib/woqlClient.js
1
/* eslint-disable camelcase */
2
/* eslint-disable no-param-reassign */
3
/* eslint-disable no-underscore-dangle */
4
/* eslint-disable no-unused-vars */
5
/// /@ts-check
6
const FormData = require('form-data');
1✔
7
const fs = require('fs');
1✔
8
const typedef = require('./typedef');
1✔
9
const CONST = require('./const');
1✔
10
const DispatchRequest = require('./dispatchRequest');
1✔
11
const ErrorMessage = require('./errorMessage');
1✔
12
const ConnectionConfig = require('./connectionConfig');
1✔
13
const WOQL = require('./woql');
1✔
14
const WOQLQuery = require('./query/woqlCore');
1✔
15

16
/**
17
 * @license Apache Version 2
18
 * @class
19
 * @classdesc The core functionality of the TerminusDB javascript client is
20
 * defined in the WOQLClient class - in the woqlClient.js file. This class provides
21
 * methods which allow you to directly get and set all of the configuration and API
22
 * endpoints of the client. The other parts of the WOQL core - connectionConfig.js
23
 * and connectionCapabilities.js - are used by the client to store internal state - they
24
 * should never have to be accessed directly. For situations where you want to communicate
25
 * with a TerminusDB server API, the WOQLClient class is all you will need.
26
 */
27

28
class WOQLClient {
29
  connectionConfig = null;
30

31
  databaseList = [];
32

33
  organizationList = [];
34

35
  /**
36
  * @constructor
37
  * @param {string} serverUrl - the terminusdb server url
38
  * @param {typedef.ParamsObj} [params] - an object with the connection parameters
39
  * @example
40
  * //to connect with your local terminusDB
41
  * const client = new TerminusClient.WOQLClient(SERVER_URL,{user:"admin",key:"myKey"})
42
  * async function getSchema() {
43
  *      client.db("test")
44
  *      client.checkout("dev")
45
  *      const schema = await client.getSchema()
46
  * }
47
  * //The client has an internal state which defines what
48
  * //organization / database / repository / branch / ref it is currently attached to
49
  *
50
  * //to connect with your TerminusDB Cloud Instance
51
  * const client = new TerminusClient.WOQLClient('SERVER_CLOUD_URL/mycloudTeam',
52
  *                      {user:"myemail@something.com", organization:'mycloudTeam'})
53
  *
54
  * client.setApiKey(MY_ACCESS_TOKEN)
55
  *
56
  * //to get the list of all organization's databases
57
  * async function callGetDatabases(){
58
  *      const dbList = await client.getDatabases()
59
  *      console.log(dbList)
60
  * }
61
  *
62
  * async function getSchema() {
63
  *      client.db("test")
64
  *      client.checkout("dev")
65
  *      const schema = await client.getSchema()
66
  * }
67
  */
68
  constructor(serverUrl, params) {
4✔
69
    this.connectionConfig = new ConnectionConfig(serverUrl, params);
1✔
70
  }
71
}
72

73
/**
74
 * set the api key to access the cloud resources
75
 * @param {string} accessToken
76
 */
77
WOQLClient.prototype.setApiKey = function (accessToken) {
1✔
78
  const currentAuth = this.connectionConfig.localAuth() || {};
×
79
  currentAuth.key = accessToken;
×
80
  currentAuth.type = 'apikey';
×
81
  this.connectionConfig.setLocalAuth(currentAuth);
×
82
};
83

84
/**
85
 * add extra headers to your request
86
 * @param {object} customHeaders
87
 * @returns {object}
88
 */
89

90
// eslint-disable-next-line consistent-return
91
WOQLClient.prototype.customHeaders = function (customHeaders) {
1✔
92
  if (customHeaders) this._customHeaders = customHeaders;
4!
93
  else return this._customHeaders;
4✔
94
};
95

96
WOQLClient.prototype.CONST = CONST;
1✔
97

98
/**
99
 * creates a copy of the client with identical internal state and context
100
 * useful if we want to change context for a particular API call without changing
101
 * the current client context
102
 * @returns {WOQLClient}  new client object with identical state to original but
103
 * which can be manipulated independently
104
 * @example
105
 * let newClient = client.copy()
106
 */
107
WOQLClient.prototype.copy = function () {
1✔
108
  const other = new WOQLClient(this.server());
×
109
  // other.connection = this.connection //keep same connection meta data - shared by copy
110
  other.connectionConfig = this.connectionConfig.copy(); // new copy of current connection data
×
111
  other.databaseList = this.databaseList;
×
112
  return other;
×
113
};
114

115
/**
116
 * Gets the current connected server url
117
 * it can only be set creating a new WOQLCLient instance
118
 * @returns {string}
119
 */
120
WOQLClient.prototype.server = function () {
1✔
121
  return this.connectionConfig.serverURL();
×
122
};
123

124
/**
125
 * Retrieve the URL of the server’s API base that we are currently connected to
126
 * @returns {string} the URL of the TerminusDB server api endpoint we are connected
127
 * to (typically server() + “api/”)
128
 * @example
129
 * let api_url = client.api()
130
 */
131
WOQLClient.prototype.api = function () {
1✔
132
  return this.connectionConfig.apiURL();
×
133
};
134

135
/**
136
 * Gets/Sets the client’s internal organization context value, if you change the organization
137
 * name the databases list will be set to empty
138
 * @param {string | boolean} [orgId] the organization id to set the context to
139
 * @returns {string | boolean}
140
 * @example
141
 * client.organization("admin")
142
 */
143
WOQLClient.prototype.organization = function (orgId) {
1✔
144
  if (typeof orgId !== 'undefined') {
1!
145
    this.connectionConfig.setOrganization(orgId);
1✔
146
    // we have to reset the databases list
147
    this.databases([]);
1✔
148
  }
149
  return this.connectionConfig.organization();
1✔
150
};
151

152
/**
153
 * Checks if a database exists
154
 *
155
 * Returns true if a DB exists and false if it doesn't. Other results
156
 * throw an exception.
157
 * @param {string} [orgName] the organization id to set the context to
158
 * @param {string} [dbName] the db name to set the context to
159
 * @returns {Promise}
160
 * @example
161
 * async function executeIfDatabaseExists(f){
162
 *      const hasDB = await client.hasDatabase("admin", "testdb")
163
 *      if (hasDB) {
164
 *          f()
165
 *      }
166
 * }
167
 */
168
WOQLClient.prototype.hasDatabase = async function (orgName, dbName) {
3!
169
  const dbCheckUrl = `${this.connectionConfig.apiURL()}db/${orgName}/${dbName}`;
×
170
  return new Promise((resolve, reject) => {
171
    this.dispatch(CONST.HEAD, dbCheckUrl).then((req) => {
×
172
      resolve(true);
×
173
    }).catch((err) => {
174
      if (err.status === 404) {
×
175
        resolve(false);
×
176
      } else {
177
        reject(err);
×
178
      }
179
    });
180
  });
181
};
182

183
/**
184
 * Gets the organization's databases list.
185
 *
186
 * If no organization has been set up, the function throws an exception
187
 * @returns {Promise}
188
 * @example
189
 * async function callGetDatabases(){
190
 *      const dbList = await client.getDatabases()
191
 *      console.log(dbList)
192
 * }
193
 */
194
WOQLClient.prototype.getDatabases = async function () {
1!
195
  // return response
196
  if (!this.connectionConfig.organization()) {
197
    throw new Error('You need to set the organization name');
198
  }
199
  // when we will have the end point to get the databases only for the current organization
200
  // we'll change this call
201
  await this.getUserOrganizations();
202
  const dbs = this.userOrganizations().find(
×
203
    (element) => element.name === this.connectionConfig.organization(),
×
204
  );
205
  const dbList = dbs && dbs.databases ? dbs.databases : [];
×
206
  this.databases(dbList);
×
207
  return dbList;
208
};
209

210
/**
211
 * Set/Get the organization's databases list (id, label, comment) that the current
212
 * user has access to on the server.
213
 * @param {array} [dbList] a list of databases the user has access to on the server, each having:
214
 * @returns {array} the organization's databases list
215
 * @example
216
 * //to get the list of all organization's databases
217
 * async function callGetDatabases(){
218
 *      await client.getDatabases()
219
 *      console.log(client.databases())
220
 * }
221
 *
222
 */
223
WOQLClient.prototype.databases = function (dbList) {
1✔
224
  if (dbList) this.databaseList = dbList;
1!
225
  return this.databaseList || [];
1!
226
};
227

228
/**
229
 * Gets the current user object as returned by the connect capabilities response
230
 * user has fields: [id, name, notes, author]
231
 * @returns {Object}
232
 */
233
WOQLClient.prototype.user = function () {
1✔
234
  // this is the locacal
235
  return this.connectionConfig.user();
×
236
};
237

238
/**
239
 * @desription Gets the user's organization id
240
 * @returns {string} the user organization name
241
 */
242
// this is something that need review
243
WOQLClient.prototype.userOrganization = function () {
1✔
244
  return this.user();
×
245
};
246

247
/**
248
 * Gets the database's details
249
 * @param {string} [dbName] - the datbase name
250
 * @returns {object} the database description object
251
 */
252
WOQLClient.prototype.databaseInfo = function (dbName) {
1✔
253
  // const dbIdVal = dbId || this.db();
254
  // const orgIdVal = orgId || this.organization()
255
  const database = this.databases().find((element) => element.name === dbName);
×
256
  return database || {};
×
257
};
258

259
/**
260
 * Sets / Gets the current database
261
 * @param {string} [dbId] - the database id to set the context to
262
 * @returns {string|boolean} - the current database or false
263
 * @example
264
 * client.db("mydb")
265
 */
266
WOQLClient.prototype.db = function (dbId) {
1✔
267
  if (typeof dbId !== 'undefined') {
1!
268
    this.connectionConfig.setDB(dbId);
1✔
269
  }
270
  return this.connectionConfig.dbid;
1✔
271
};
272

273
/**
274
 *Sets the internal client context to allow it to talk to the server’s internal system database
275
 *
276
 */
277
WOQLClient.prototype.setSystemDb = function () {
1✔
278
  this.db(this.connectionConfig.system_db);
×
279
};
280

281
/**
282
 * Gets / Sets the client’s internal repository context value (defaults to ‘local’)
283
 * @param {typedef.RepoType | string} [repoId] - default value is local
284
 * @returns {string} the current repository id within the client context
285
 * @example
286
 * client.repo("origin")
287
 */
288
WOQLClient.prototype.repo = function (repoId) {
1✔
289
  if (typeof repoId !== 'undefined') {
×
290
    this.connectionConfig.setRepo(repoId);
×
291
  }
292
  return this.connectionConfig.repo();
×
293
};
294

295
/**
296
 * Gets/Sets the client’s internal branch context value (defaults to ‘main’)
297
 * @param {string} [branchId] - the branch id to set the context to
298
 * @returns {string} the current branch id within the client context
299
 */
300
WOQLClient.prototype.checkout = function (branchId) {
1✔
301
  if (typeof branchId !== 'undefined') {
×
302
    this.connectionConfig.setBranch(branchId);
×
303
  }
304
  return this.connectionConfig.branch();
×
305
};
306

307
/**
308
 *  Sets / gets the current ref pointer (pointer to a commit within a branch)
309
 * Reference ID or Commit ID are unique hashes that are created whenever a new commit is recorded
310
 * @param {string} [commitId] - the reference ID or commit ID
311
 * @returns {string|boolean}  the current commit id within the client context
312
 * @example
313
 * client.ref("mkz98k2h3j8cqjwi3wxxzuyn7cr6cw7")
314
 */
315
WOQLClient.prototype.ref = function (commitId) {
1✔
316
  if (typeof commitId !== 'undefined') {
×
317
    this.connectionConfig.setRef(commitId);
×
318
  }
319
  return this.connectionConfig.ref();
×
320
};
321

322
/**
323
 * Sets/Gets set the database basic connection credential
324
 * @param {typedef.CredentialObj} [newCredential]
325
 * @returns {typedef.CredentialObj | boolean}
326
 * @example
327
 * client.localAuth({user:"admin","key":"mykey","type":"basic"})
328
 */
329
WOQLClient.prototype.localAuth = function (newCredential) {
1✔
330
  if (typeof newCredential !== 'undefined') {
4!
331
    this.connectionConfig.setLocalAuth(newCredential);
×
332
  }
333
  return this.connectionConfig.localAuth();
4✔
334
};
335
/**
336
 * Use {@link #localAuth} instead.
337
 * @deprecated
338
 */
339

340
WOQLClient.prototype.local_auth = WOQLClient.prototype.localAuth;
1✔
341

342
/**
343
 * Sets/Gets the jwt token for authentication
344
 * we need this to connect 2 terminusdb server to each other for push, pull, clone actions
345
 * @param {typedef.CredentialObj} [newCredential]
346
 * @returns {typedef.CredentialObj | boolean}
347
 * @example
348
 * client.remoteAuth({"key":"dhfmnmjglkrelgkptohkn","type":"jwt"})
349
 */
350
WOQLClient.prototype.remoteAuth = function (newCredential) {
1✔
351
  if (typeof newCredential !== 'undefined') {
4!
352
    this.connectionConfig.setRemoteAuth(newCredential);
×
353
  }
354
  return this.connectionConfig.remoteAuth();
4✔
355
};
356

357
/**
358
 * Use {@link #remoteAuth} instead.
359
 * @deprecated
360
 */
361

362
WOQLClient.prototype.remote_auth = WOQLClient.prototype.remoteAuth;
1✔
363

364
/**
365
 * Gets the string that will be written into the commit log for the current user
366
 * @returns {string} the current user
367
 * @example
368
 * client.author()
369
 */
370
WOQLClient.prototype.author = function () {
1✔
371
  // we have to review this with is the author in local and remote
372
  // was a old functionality
373
  // if (ignoreJwt) {
374
  // this.connectionConfig.user(ignoreJwt)
375
  // }
376
  return this.connectionConfig.user();
×
377
};
378

379
/**
380
 * @param {typedef.ParamsObj} params - a object with connection params
381
 * @example sets several of the internal state values in a single call
382
 * (similar to connect, but only sets internal client state, does not communicate with server)
383
 * client.set({key: "mypass", branch: "dev", repo: "origin"})
384
 */
385
WOQLClient.prototype.set = function (params) {
1✔
386
  this.connectionConfig.update(params);
×
387
};
388

389
/**
390
 * Generates a resource string for the required context
391
 * of the current context for "commits" "meta" "branch" and "ref" special resources
392
 * @param {typedef.ResourceType} resourceType - the type of resource string that is required - one
393
 * of “db”, “meta”, “repo”, “commits”, “branch”, “ref”
394
 * @param {string} [resourceId] -  can be used to specify a specific branch / ref - if not supplied
395
 * the current context will be used
396
 * @returns {string} a resource string for the desired context
397
 * @example
398
 * const branch_resource = client.resource("branch")
399
 */
400
// eslint-disable-next-line consistent-return
401
WOQLClient.prototype.resource = function (resourceType, resourceId) {
1✔
402
  let base = `${this.organization()}/${this.db()}/`;
×
403
  if (resourceType === 'db') return base;
×
404
  if (resourceType === 'meta') return `${base}_meta`;
×
405
  base += `${this.repo()}`;
×
406
  if (resourceType === 'repo') return base;
×
407
  if (resourceType === 'commits') return `${base}/_commits`;
×
408
  const resourceIdValue = resourceId || (resourceType === 'ref' ? this.ref() : this.checkout());
×
409
  if (resourceType === 'branch') return `${base}/branch/${resourceIdValue}`;
×
410
  if (resourceType === 'ref') return `${base}/commit/${resourceIdValue}`;
×
411
};
412

413
/**
414
 * You can call this to get the server info or override the start params
415
 * configuration, this.connectionConfig.server will be used if present,
416
 * or the promise will be rejected.
417
 *
418
 * @deprecated
419
 *
420
 * @param {typedef.ParamsObj} [params] - TerminusDB Server connection parameters
421
 * @returns {Promise}  the connection capabilities response object or an error object
422
 * @example
423
 * client.connect()
424
 */
425
WOQLClient.prototype.connect = function (params) {
1✔
426
  if (params) this.connectionConfig.update(params);
1!
427
  // unset the current server setting until successful connect
428
  return this.dispatch(CONST.GET, this.connectionConfig.apiURLInfo()).then((response) => response);
1✔
429
};
430

431
/**
432
 * Creates a new database in TerminusDB server
433
 * @param {string} dbId - The id of the new database to be created
434
 * @param {typedef.DbDetails} dbDetails - object containing details about the database to be created
435
 * @param {string} [orgId] - optional organization id - if absent default local organization
436
 * id is used
437
 * @returns {Promise} A promise that returns the call response object, or an Error if rejected.
438
 * @example
439
 * //remember set schema:true if you need to add a schema graph
440
 * client.createDatabase("mydb", {label: "My Database", comment: "Testing", schema: true})
441
 */
442
// maybe we can pass only the detailObj it is have inside the dbid and org
443
WOQLClient.prototype.createDatabase = function (dbId, dbDetails, orgId) {
1✔
444
  if (orgId) this.organization(orgId);
1!
445
  // console.log("createDatabase", orgId)
446
  if (dbId) {
1!
447
    this.db(dbId);
1✔
448
    // to be review
449
    // console.log('____remoteURL_BFF__', this.connectionConfig.dbURL())
450
    return this.dispatch(CONST.POST, this.connectionConfig.dbURL(), dbDetails);
1✔
451
  }
452
  const errmsg = `Create database parameter error - you must specify a valid database id  - ${dbId} is invalid`;
×
453
  return Promise.reject(
×
454
    new Error(ErrorMessage.getInvalidParameterMessage(CONST.CREATE_DATABASE, errmsg)),
455
  );
456
};
457

458
/**
459
 * Update a database in TerminusDB server
460
 * @param {typedef.DbDoc} dbDoc - object containing details about the database to be updated
461
 * @returns {Promise} A promise that returns the call response object, or an Error if rejected.
462
 * @example
463
 * client.updateDatabase({id: "mydb", label: "My Database", comment: "Testing"})
464
 */
465
WOQLClient.prototype.updateDatabase = function (dbDoc) {
1✔
466
  const dbid = dbDoc.id || this.db();
×
467
  this.organization(dbDoc.organization || this.organization());
×
468
  if (dbid) {
×
469
    this.db(dbid);
×
470
    return this.dispatch(CONST.PUT, this.connectionConfig.dbURL(), dbDoc);
×
471
  }
472
  const errmsg = `Update database error - you must specify a valid database id - ${dbid} is invalid`;
×
473
  return Promise.reject(
×
474
    new Error(ErrorMessage.getInvalidParameterMessage(CONST.UPDATE_DATABASE, errmsg)),
475
  );
476
};
477

478
/**
479
 * Deletes a database from a TerminusDB server
480
 * @param {string} dbId The id of the database to be deleted
481
 * @param {string} [orgId] the id of the organization to which the database belongs
482
 * (in desktop use, this will always be “admin”)
483
 * @param {boolean} [force]
484
 * @returns {Promise} A promise that returns the call response object, or an Error if rejected.
485
 * @example
486
 * client.deleteDatabase("mydb")
487
 */
488
WOQLClient.prototype.deleteDatabase = function (dbId, orgId, force) {
1✔
489
  const orgIdValue = orgId || this.organization();
×
490
  this.organization(orgIdValue);
×
491
  const payload = force ? { force: true } : null;
×
492
  if (dbId && this.db(dbId)) {
×
493
    return this.dispatch(CONST.DELETE, this.connectionConfig.dbURL(), payload);
×
494
  }
495
  const errmsg = `Delete database parameter error - you must specify a valid database id  - ${dbId} is invalid`;
×
496
  return Promise.reject(
×
497
    new Error(ErrorMessage.getInvalidParameterMessage(CONST.DELETE, errmsg)),
498
  );
499
};
500

501
/**
502
 * Retrieve the contents of a graph within a TerminusDB as triples, encoded in
503
 * the turtle (ttl) format
504
 * @param {typedef.GraphType} graphType -  type of graph to get triples from,
505
 * either “instance” or  “schema”
506
 * @returns {Promise}  A promise that returns the call response object (with
507
 * the contents being a string representing a set of triples in turtle (ttl) format),
508
 * or an Error if rejected.
509
 * @example
510
 * const turtle = await client.getTriples("schema", "alt")
511
 */
512
WOQLClient.prototype.getTriples = function (graphType) {
1✔
513
  if (graphType) {
1!
514
    return this.dispatch(
1✔
515
      CONST.GET,
516
      this.connectionConfig.triplesURL(graphType),
517
    );
518
  }
519
  const errmsg = 'Get triples parameter error - you must specify a valid graph type (inference, instance, schema), and graph id';
×
520
  return Promise.reject(
×
521
    new Error(ErrorMessage.getInvalidParameterMessage(CONST.GET, errmsg)),
522
  );
523
};
524

525
/**
526
 * Replace the contents of the specified graph with the passed triples encoded
527
 * in the turtle (ttl) format
528
 * @param {string} graphType - type of graph  |instance|schema|inference|
529
 * @param {string} turtle - string encoding triples in turtle (ttl) format
530
 * @param {string} commitMsg - Textual message describing the reason for the update
531
 * @returns {Promise} A promise that returns the call response object, or an Error if rejected.
532
 * @example
533
 * client.updateTriples("schema", "alt", turtle_string, "dumping triples to graph alt")
534
 */
535
WOQLClient.prototype.updateTriples = function (graphType, turtle, commitMsg) {
1✔
536
  if (commitMsg && turtle && graphType) {
×
537
    const commit = this.generateCommitInfo(commitMsg);
×
538
    commit.turtle = turtle;
×
539
    return this.dispatch(
×
540
      CONST.UPDATE_TRIPLES,
541
      this.connectionConfig.triplesURL(graphType),
542
      commit,
543
    );
544
  }
545
  const errmsg = 'Update triples parameter error - you must specify a valid graph id, graph type, turtle contents and commit message';
×
546
  return Promise.reject(
×
547
    new Error(ErrorMessage.getInvalidParameterMessage(CONST.UPDATE_TRIPLES, errmsg)),
548
  );
549
};
550

551
/**
552
 * Appends the passed turtle to the contents of a graph
553
 * @param {string} graphType type of graph  |instance|schema|inference|
554
 * @param {string} turtle is a valid set of triples in turtle format (OWL)
555
 * @param {string} commitMsg Textual message describing the reason for the update
556
 * @returns {Promise}  A promise that returns the call response object, or an Error if rejected.
557
 */
558
WOQLClient.prototype.insertTriples = function (graphType, turtle, commitMsg) {
1✔
559
  if (commitMsg && turtle && graphType) {
×
560
    const commit = this.generateCommitInfo(commitMsg);
×
561
    commit.turtle = turtle;
×
562
    return this.dispatch(
×
563
      CONST.INSERT_TRIPLES,
564
      this.connectionConfig.triplesURL(graphType),
565
      commit,
566
    );
567
  }
568
  const errmsg = 'Update triples parameter error - you must specify a valid graph id, graph type, turtle contents and commit message';
×
569
  return Promise.reject(
×
570
    new Error(ErrorMessage.getInvalidParameterMessage(CONST.INSERT_TRIPLES, errmsg)),
571
  );
572
};
573

574
/**
575
 *  Sends a message to the server
576
 * @param {string} message - textual string
577
 * @param {string} [pathname] - a server path to send the message to
578
 * @returns {Promise}  A promise that returns the call response object, or an Error if rejected.
579
 */
580
WOQLClient.prototype.message = function (message, pathname) {
1✔
581
  let url = this.api();
×
582
  url += pathname ? this.api() + pathname : 'message';
×
583
  return this.dispatch(CONST.GET, url, message).then((response) => response);
×
584
};
585

586
/**
587
 * Sends an action to the server
588
 * @param {string} actionName - structure of the action
589
 * @param {object} [payload] - a request body call
590
 * @returns {Promise}  A promise that returns the call response object, or an Error if rejected.
591
 */
592
WOQLClient.prototype.action = function (actionName, payload) {
1✔
593
  const url = `${this.api()}action/${actionName}`;
×
594
  return this.dispatch(CONST.ACTION, url, payload).then((response) => response);
×
595
};
596

597
/**
598
 * Gets TerminusDB Server Information
599
 * @returns {Promise}  A promise that returns the call response object, or an Error if rejected.
600
 * @example
601
 * client.info()
602
 */
603
WOQLClient.prototype.info = function () {
1✔
604
  const url = `${this.api()}info`;
×
605
  return this.dispatch(CONST.GET, url).then((response) => response);
×
606
};
607

608
// Get Resource objects from WOQL query
609
function getResourceObjects(queryObject, result_array) {
610
  if (queryObject instanceof Array) {
1!
611
    for (let i = 0; i < queryObject.length; i += 1) {
×
612
      getResourceObjects(queryObject[i], result_array);
×
613
    }
614
  } else {
615
    const keys = Object.keys(queryObject);
1✔
616

617
    for (let i = 0; i < keys.length; i += 1) {
1✔
618
      if (keys[i] === 'resource') {
2!
619
        if (queryObject[keys[i]]['@type'] && queryObject[keys[i]]['@type'] === 'QueryResource') {
×
620
          result_array.push(queryObject[keys[i]]);
×
621
        }
622
      }
623
      if (queryObject[keys[i]] instanceof Object || queryObject[keys[i]] instanceof Array) {
2!
624
        getResourceObjects(queryObject[keys[i]], result_array);
×
625
      }
626
    }
627
  }
628
}
629

630
/**
631
 * Executes a WOQL query on the specified database and returns the results
632
 * @param {WOQLQuery} woql - an instance of the WOQLQuery class
633
 * @param {string} [commitMsg] - a message describing the reason for the change that will
634
 * be written into the commit log (only relevant if the query contains an update)
635
 * @param {boolean} [allWitnesses]
636
 * @param {string} [lastDataVersion] the last data version tracking id.
637
 * @param {boolean} [getDataVersion] If true the function will return object having result
638
 * and dataVersion.
639
 * @returns {Promise}  A promise that returns the call response object or object having *result*
640
 * and *dataVersion* object if ***getDataVersion*** parameter is true, or an Error if rejected.
641
 * @example
642
 * const result = await client.query(WOQL.star())
643
 */
644
WOQLClient.prototype.query = function (woql, commitMsg, allWitnesses, lastDataVersion = '', getDataVersion = false) {
1!
645
  allWitnesses = allWitnesses || false;
1✔
646
  commitMsg = commitMsg || 'Commit generated with javascript client without message';
1✔
647
  if (woql && woql.json && (!woql.containsUpdate() || commitMsg)) {
1!
648
    const doql = woql.containsUpdate() ? this.generateCommitInfo(commitMsg) : {};
1!
649
    doql.query = woql.json();
1✔
650

651
    let postBody;
652
    const resourceObjects = [];
1✔
653
    getResourceObjects(doql.query, resourceObjects);
1✔
654

655
    if (resourceObjects.length > 0) {
1!
656
      const formData = new FormData();
×
657

658
      resourceObjects.forEach((resourceObject) => {
×
659
        const fileName = resourceObject.source.post.split('/').pop();
×
660

661
        formData.append('file', fs.createReadStream(resourceObject.source.post));
×
662
        resourceObject.source.post = fileName;
×
663
      });
664

665
      formData.append('payload', Buffer.from(JSON.stringify(doql)), { filename: 'body.json', contentType: 'application/json' });
×
666
      this.customHeaders(formData.getHeaders());
×
667

668
      postBody = formData;
×
669
    } else {
670
      postBody = doql;
1✔
671
    }
672

673
    if (allWitnesses) doql.all_witnesses = true;
1!
674

675
    if (typeof lastDataVersion === 'string' && lastDataVersion !== '') {
1!
676
      this.customHeaders({ 'TerminusDB-Data-Version': lastDataVersion });
×
677
    }
678

679
    // eslint-disable-next-line max-len
680
    return this.dispatch(CONST.WOQL_QUERY, this.connectionConfig.queryURL(), postBody, getDataVersion);
1✔
681
  }
682

683
  let errmsg = 'WOQL query parameter error';
×
684
  if (woql && woql.json && woql.containsUpdate() && !commitMsg) {
×
685
    errmsg += ' - you must include a textual commit message to perform this update';
×
686
  } else {
687
    errmsg += ' - you must specify a valid WOQL Query';
×
688
  }
689
  return Promise.reject(
×
690
    new Error(ErrorMessage.getInvalidParameterMessage(CONST.WOQL_QUERY, errmsg)),
691
  );
692
};
693

694
/**
695
 * Creates a new branch with a TerminusDB database, starting from the current context of
696
 * the client (branch / ref)
697
 * @param {string} newBranchId - local identifier of the new branch the ID of the new branch
698
 * to be created
699
 * @param {boolean} [isEmpty] - if isEmpty is true it will create a empty branch.
700
 * @returns {Promise}  A promise that returns the call response object, or an Error if rejected.
701
 * @example
702
 * client.branch("dev")
703
 */
704
WOQLClient.prototype.branch = function (newBranchId, isEmpty) {
1✔
705
  if (newBranchId) {
×
706
    let source = this.ref()
×
707
      ? { origin: `${this.organization()}/${this.db()}/${this.repo()}/commit/${this.ref()}` }
708
      : {
709
        origin: `${this.organization()}/${this.db()}/${this.repo()}/branch/${this.checkout()}`,
710
      };
711

712
    if (isEmpty && isEmpty === true) {
×
713
      // @ts-ignore
714
      source = {};
×
715
    }
716
    return this.dispatch(CONST.BRANCH, this.connectionConfig.branchURL(newBranchId), source);
×
717
  }
718
  const errmsg = 'Branch parameter error - you must specify a valid new branch id';
×
719
  return Promise.reject(new Error(ErrorMessage.getInvalidParameterMessage(CONST.BRANCH, errmsg)));
×
720
};
721

722
/**
723
 * Squash branch commits
724
 * @param {string} branchId - local identifier of the new branch
725
 * @param {string} commitMsg - Textual message describing the reason for the update
726
 * @returns {Promise} A promise that returns the call response object, or an Error if rejected.
727
 */
728
WOQLClient.prototype.squashBranch = function (branchId, commitMsg) {
1✔
729
  if (commitMsg && branchId) {
×
730
    const commit = this.generateCommitInfo(commitMsg);
×
731
    return this.dispatch(
×
732
      CONST.SQUASH_BRANCH,
733
      this.connectionConfig.squashBranchURL(branchId),
734
      commit,
735
    );
736
  }
737
  const errmsg = 'Branch parameter error - you must specify a valid new branch id and a commit message';
×
738
  return Promise.reject(
×
739
    new Error(ErrorMessage.getInvalidParameterMessage(CONST.SQUASH_BRANCH, errmsg)),
740
  );
741
};
742

743
/**
744
 * Reset branch to a commit id, Reference ID or Commit ID are unique hashes that are
745
 * created whenever a new commit is recorded
746
 * @param {string} branchId - local identifier of the new branch
747
 * @param {string} commitId - Reference ID or Commit ID
748
 * @returns {Promise}  A promise that returns the call response object, or an Error if rejected.
749
 */
750
WOQLClient.prototype.resetBranch = function (branchId, commitId) {
1✔
751
  if (commitId && branchId) {
×
752
    // eslint-disable-next-line camelcase
753
    const commit_descriptor = this.generateCommitDescriptor(commitId);
×
754
    return this.dispatch(
×
755
      CONST.RESET_BRANCH,
756
      this.connectionConfig.resetBranchUrl(branchId),
757
      commit_descriptor,
758
    );
759
  }
760
  const errmsg = 'Branch parameter error - you must specify a valid new branch id and a commit message';
×
761
  return Promise.reject(
×
762
    new Error(ErrorMessage.getInvalidParameterMessage(CONST.RESET_BRANCH, errmsg)),
763
  );
764
};
765

766
/**
767
 * Optimize db branch
768
 * @param {string} branchId - local identifier of the new branch
769
 * @returns {Promise} A promise that returns the call response object, or an Error if rejected.
770
 */
771
WOQLClient.prototype.optimizeBranch = function (branchId) {
1✔
772
  if (branchId) {
×
773
    return this.dispatch(
×
774
      CONST.OPTIMIZE_SYSTEM,
775
      this.connectionConfig.optimizeBranchUrl(branchId),
776
      {},
777
    );
778
  }
779
  const errmsg = 'Branch parameter error - you must specify a valid branch id';
×
780
  return Promise.reject(new Error(ErrorMessage.getInvalidParameterMessage(CONST.BRANCH, errmsg)));
×
781
};
782

783
/**
784
 * Deletes a branch from database
785
 * @param {string} branchId - local identifier of the branch
786
 * @returns {Promise} A promise that returns the call response object, or an Error if rejected.
787
 */
788
WOQLClient.prototype.deleteBranch = function (branchId) {
1✔
789
  if (branchId) {
×
790
    return this.dispatch(CONST.DELETE, this.connectionConfig.branchURL(branchId));
×
791
  }
792
  const errmsg = 'Branch parameter error - you must specify a valid new branch id';
×
793
  return Promise.reject(new Error(ErrorMessage.getInvalidParameterMessage(CONST.BRANCH, errmsg)));
×
794
};
795

796
/**
797
 * Pull changes from a branch on a remote database to a branch on a local database
798
 * @param {typedef.RemoteRepoDetails} remoteSourceRepo - an object describing the source of the pull
799
 * @returns {Promise}  A promise that returns the call response object, or an Error if rejected.
800
 * @example
801
 * client.pull({remote: "origin", remote_branch: "main", message: "Pulling from remote"})
802
 */
803
WOQLClient.prototype.pull = function (remoteSourceRepo) {
1✔
804
  const rc_args = this.prepareRevisionControlArgs(remoteSourceRepo);
×
805
  if (rc_args && rc_args.remote && rc_args.remote_branch) {
×
806
    return this.dispatch(CONST.PULL, this.connectionConfig.pullURL(), rc_args);
×
807
  }
808
  const errmsg = 'Pull parameter error - you must specify a valid remote source and branch to pull from';
×
809
  return Promise.reject(new Error(ErrorMessage.getInvalidParameterMessage(CONST.PULL, errmsg)));
×
810
};
811

812
/**
813
 * Fetch updates to a remote database to a remote repository with the local database
814
 * @param {string} remoteId - if of the remote to fetch (eg: 'origin')
815
 * @returns {Promise}  A promise that returns the call response object, or an Error if rejected.
816
 */
817
WOQLClient.prototype.fetch = function (remoteId) {
1✔
818
  return this.dispatch(CONST.FETCH, this.connectionConfig.fetchURL(remoteId));
×
819
};
820

821
/**
822
 * Push changes from a branch on a local database to a branch on a remote database
823
 * @param {typedef.RemoteRepoDetails} remoteTargetRepo - an object describing the target of the push
824
 * {remote: "origin", "remote_branch": "main", "author": "admin", "message": "message"}
825
 * @returns {Promise}  A promise that returns the call response object, or an Error if rejected.
826
 * @example
827
 * client.push({remote: "origin", remote_branch: "main", message: "Pulling from remote"})
828
 */
829
WOQLClient.prototype.push = function (remoteTargetRepo) {
1✔
830
  const rc_args = this.prepareRevisionControlArgs(remoteTargetRepo);
×
831
  if (rc_args && rc_args.remote && rc_args.remote_branch) {
×
832
    return this.dispatch(CONST.PUSH, this.connectionConfig.pushURL(), rc_args);
×
833
  }
834
  const errmsg = 'Push parameter error - you must specify a valid remote target';
×
835
  return Promise.reject(new Error(ErrorMessage.getInvalidParameterMessage(CONST.PUSH, errmsg)));
×
836
};
837

838
/**
839
 * Merges the passed branch into the current one using the rebase operation
840
 * @param {object} rebaseSource - json describing the source branch to be used as a base
841
 * @returns {Promise}  A promise that returns the call response object, or an Error if rejected.
842
 * @example
843
 * //from the branch head
844
 * client.rebase({rebase_from: "admin/db_name/local/branch/branch_name", message:
845
 * "Merging from dev")
846
 * //or from a commit id
847
 * client.rebase({rebase_from: "admin/db_name/local/commit/9w8hk3y6rb8tjdy961de3i536ntkqd8",
848
 * message: "Merging from dev")
849
 */
850
WOQLClient.prototype.rebase = function (rebaseSource) {
1✔
851
  const rc_args = this.prepareRevisionControlArgs(rebaseSource);
×
852
  if (rc_args && rc_args.rebase_from) {
×
853
    return this.dispatch(CONST.REBASE, this.connectionConfig.rebaseURL(), rc_args);
×
854
  }
855
  const errmsg = 'Rebase parameter error - you must specify a valid rebase source to rebase from';
×
856
  return Promise.reject(
×
857
    new Error(ErrorMessage.getInvalidParameterMessage(CONST.REBASE, errmsg)),
858
  );
859
};
860

861
/**
862
 * Reset the current branch HEAD to the specified commit path
863
 * @param {string} commitPath - The commit path to set the current branch to
864
 * @returns {Promise}  A promise that returns the call response object, or an Error if rejected.
865
 */
866
WOQLClient.prototype.reset = function (commitPath) {
1✔
867
  return this.dispatch(CONST.RESET, this.connectionConfig.resetURL(), {
×
868
    commit_descriptor: commitPath,
869
  });
870
};
871

872
/**
873
 * Clones a remote repo and creates a local copy
874
 * @param {typedef.CloneSourceDetails} cloneSource - object describing the source branch
875
 * to be used as a base
876
 * @param {string} newDbId - id of the new cloned database on the local server
877
 * @param {string} [orgId] - id of the local organization that the new cloned database
878
 * will be created in (in desktop mode this is always “admin”)
879
 * @returns {Promise}  A promise that returns the call response object, or an Error if rejected.
880
 * @example
881
 * client.clonedb({remote_url: "https://my.terminusdb.com/myorg/mydb", label "Cloned DB", comment: "Cloned from mydb"}, newid: "mydb")
882
 */
883
WOQLClient.prototype.clonedb = function (cloneSource, newDbId, orgId) {
1✔
884
  orgId = orgId || this.user_organization();
×
885
  this.organization(orgId);
×
886
  const rc_args = this.prepareRevisionControlArgs(cloneSource);
×
887
  if (newDbId && rc_args && rc_args.remote_url) {
×
888
    return this.dispatch(CONST.CLONE, this.connectionConfig.cloneURL(newDbId), rc_args);
×
889
  }
890
  const errmsg = 'Clone parameter error - you must specify a valid id for the cloned database';
×
891
  return Promise.reject(new Error(ErrorMessage.getInvalidParameterMessage(CONST.BRANCH, errmsg)));
×
892
};
893

894
/**
895
 * Common request dispatch function
896
 * @property {string} action - the action name
897
 * @property {string} apiUrl - the server call endpoint
898
 * @property {object} [payload] - the post body
899
 * @property {boolean} [getDataVersion] - If true return response with data version
900
 * @property {boolean} [compress] - If true, compress the data if it is bigger than 1024 bytes
901
 * @returns {Promise}  A promise that returns the call response object, or an Error if rejected.
902
 */
903
WOQLClient.prototype.dispatch = function (
1✔
904
  action,
905
  apiUrl,
906
  payload,
907
  getDataVersion,
908
  compress = false,
909
) {
4!
910
  if (!apiUrl) {
4!
911
    return Promise.reject(
×
912
      new Error(
913
        ErrorMessage.getInvalidParameterMessage(
914
          action,
915
          this.connectionConfig.connection_error,
916
        ),
917
      ),
918
    );
919
  }
920
  // I have to review this I don't want a call everytime
921
  /* if(this.connectionConfig.tokenParameter){
922
        const param = this.connectionConfig.tokenParameter
923
        axios.post(param.url,param.options).then(result=>result.data).then(data=>{
924
            if(data.access_token){
925
                console.log("ACCESS_TOKEN",data.access_token)
926
                this.localAuth({"key":data.access_token,"type":"jwt"})
927
            }
928
            return DispatchRequest(
929
                apiUrl,
930
                action,
931
                payload,
932
                this.localAuth(),
933
                this.remoteAuth(),
934
                this.customHeaders(),
935
            )
936
        })
937
    }else{ */
938
  return DispatchRequest(
4✔
939
    apiUrl,
940
    action,
941
    payload,
942
    this.localAuth(),
943
    this.remoteAuth(),
944
    this.customHeaders(),
945
    getDataVersion,
946
    compress,
947
  );
948
  // }
949
};
950

951
/**
952
 * Generates the json structure for commit messages
953
 * @param {string} msg - textual string describing reason for the change
954
 * @param {string} [author] - optional author id string - if absent current user id will be used
955
 * @returns {object}
956
 */
957
WOQLClient.prototype.generateCommitInfo = function (msg, author) {
1✔
958
  if (!author) {
×
959
    author = this.author();
×
960
  }
961
  const commitInfo = { commit_info: { author, message: msg } };
×
962
  return commitInfo;
×
963
};
964

965
/**
966
 * Generates the json structure for commit descriptor
967
 * @param {string} commitId - a valid commit id o
968
 */
969
WOQLClient.prototype.generateCommitDescriptor = function (commitId) {
1✔
970
  const cd = this.connectionConfig.commitDescriptorUrl(commitId);
×
971
  const ci = { commit_descriptor: cd };
×
972
  return ci;
×
973
};
974

975
/**
976
 * Adds an author string (from the user object returned by connect) to the commit message.
977
 * @param {object} [rc_args]
978
 * @returns {object | boolean}
979
 */
980
WOQLClient.prototype.prepareRevisionControlArgs = function (rc_args) {
1✔
981
  if (!rc_args || typeof rc_args !== 'object') return false;
×
982
  if (!rc_args.author) rc_args.author = this.author();
×
983
  return rc_args;
×
984
};
985

986
/**
987
 * to add a new document or a list of new documents into the instance or the schema graph.
988
 * @param {object} json
989
 * @param {typedef.DocParamsPost} [params] - the post parameters {@link #typedef.DocParamsPost}
990
 * @param {string} [dbId] - the dbid
991
 * @param {message} [string] - the insert commit message
992
 * @param {string} [lastDataVersion] the last data version tracking id.
993
 * @param {boolean} [getDataVersion] If true the function will return object having result
994
 * and dataVersion.
995
 * @returns {Promise}  A promise that returns the call response object or object having *result*
996
 * and *dataVersion* object if ***getDataVersion*** parameter is true, or an Error if rejected.
997
 * @example
998
 * const json = [{ "@type" : "Class",
999
 *              "@id" : "Coordinate",
1000
 *              "@key" : { '@type' : 'Hash',
1001
 *              '@fields' : ['x','y'] },
1002
 *              "x" : "xsd:decimal",
1003
 *              "y" : "xsd:decimal" },
1004
 *              { "@type" : "Class",
1005
 *              "@id" : "Country",
1006
 *              "@key" : { '@type' : 'Lexical',
1007
 *                          '@fields' : [name] },
1008
 *              "name" : "xsd:string",
1009
 *              "perimeter" : { "@type" : "List",
1010
 *                              "@class" : "Coordinate" } }]
1011
 * client.addDocument(json,{"graph_type":"schema"},"mydb","add new schema")
1012
 *
1013
 *
1014
 * // Here we will pass true to show how to get dataVersion
1015
 *
1016
 * const response = await client.addDocument(json, {"graph_type": "schema"},
1017
 *   "mydb",
1018
 *   "add new schema", '',
1019
 *   true
1020
 * )
1021
 * console.log(response);
1022
 *
1023
 *  // This will output:
1024
 *  // {
1025
 *  //   result: [ ...... ],
1026
 *  //   dataVersion: 'branch:5fs681tlycnn6jh0ceiqcq4qs89pdfs'
1027
 *  // }
1028
 *
1029
 *  // Now we can use the data version we recieved as a response in previous
1030
 *  // function call and used it is next function call as lastDataVersion
1031
 *
1032
 * const response1 = await client.addDocument(json, {"graph_type": "schema"},
1033
 *   "mydb",
1034
 *   "add new schema", response.dataVersion,
1035
 * )
1036
 */
1037

1038
WOQLClient.prototype.addDocument = function (json, params, dbId, message = 'add a new document', lastDataVersion = '', getDataVersion = false, compress = false) {
1!
1039
  if (dbId) {
×
1040
    this.db(dbId);
×
1041
  }
1042

1043
  if (typeof lastDataVersion === 'string' && lastDataVersion !== '') {
×
1044
    this.customHeaders({ 'TerminusDB-Data-Version': lastDataVersion });
×
1045
  }
1046
  const docParams = params || {};
×
1047
  docParams.author = this.author();
×
1048
  docParams.message = message;
×
1049
  return this.dispatch(
×
1050
    CONST.POST,
1051
    this.connectionConfig.documentURL(docParams),
1052
    json,
1053
    getDataVersion,
1054
    compress,
1055
  );
1056
};
1057

1058
/**
1059
 * Use {@link #getDocument} instead.
1060
 * @deprecated
1061
 *
1062
 * Retrieves all documents that match a given document template
1063
 * @param {object} query - the query template
1064
 * @param {typedef.DocParamsGet} [params] - the get parameters
1065
 * @param {string} [dbId] - the database id
1066
 * @param {string} [branch] - the database branch
1067
 * @param {string} [lastDataVersion] the last data version tracking id.
1068
 * @param {boolean} [getDataVersion] If true the function will return object having result
1069
 * and dataVersion.
1070
 * @returns {Promise}  A promise that returns the call response object or object having *result*
1071
 * and *dataVersion* object if ***getDataVersion*** parameter is true, or an Error if rejected.
1072
 * @example
1073
 * const query = {
1074
 *   "type": "Person",
1075
 *   "query": { "age": 42 },
1076
 *  }
1077
 * client.queryDocument(query, {"as_list":true})
1078
 *
1079
 *
1080
 * // Here we will pass true to show how to get dataVersion
1081
 * const query = {
1082
 *   "type": "Person",
1083
 *   "query": { "age": 42 },
1084
 *  }
1085
 *
1086
 * const response = await client.queryDocument(query, {"as_list": true}, '', '','',true);
1087
 * console.log(response);
1088
 *
1089
 *  // This will output:
1090
 *  // {
1091
 *  //   result: [
1092
 *  //     {
1093
 *  //       '@id': 'Person/052d60ffbd114bf5e7331b03f07fcb7',
1094
 *  //       '@type': 'Person',
1095
 *  //       age: 42,
1096
 *  //       name: 'John',
1097
 *  //     },
1098
 *  //   ],
1099
 *  //   dataVersion: 'branch:5fs681tlycnn6jh0ceiqcq4qs89pdfs'
1100
 *  // }
1101
 *
1102
 *  // Now we can use the data version we recieved as a response in previous
1103
 *  // query and used it is next query as lastDataVersion
1104
 *  const query = {
1105
 *   "type": "Person",
1106
 *   "query": { "age": 18 },
1107
 *  }
1108
 *
1109
 *  const response1 = await client.queryDocument(query, {"as_list": true}, '',
1110
 *    '',
1111
 *    response.dataVersion
1112
 *  );
1113
 */
1114

1115
WOQLClient.prototype.queryDocument = function (query, params, dbId, branch, lastDataVersion = '', getDataVersion = false) {
1!
1116
  if (dbId) {
×
1117
    this.db(dbId);
×
1118
  }
1119
  if (branch) {
×
1120
    this.checkout(branch);
×
1121
  }
1122
  if (typeof lastDataVersion === 'string' && lastDataVersion !== '') {
×
1123
    this.customHeaders({ 'TerminusDB-Data-Version': lastDataVersion });
×
1124
  }
1125

1126
  return this.dispatch(
×
1127
    CONST.QUERY_DOCUMENT,
1128
    this.connectionConfig.documentURL(params),
1129
    query,
1130
    getDataVersion,
1131
  );
1132
};
1133

1134
/**
1135
 *
1136
 * @param {typedef.DocParamsGet} [params] - the get parameters,
1137
 * you can pass document query search template with the params
1138
 * @param {string} [dbId] - the database id
1139
 * @param {string} [branch] - the database branch
1140
 * @param {string} [lastDataVersion] the last data version tracking id.
1141
 * @param {boolean} [getDataVersion] If true the function will return object having result
1142
 * and dataVersion.
1143
 * @param {object} [query] document query search template
1144
 * @returns {Promise}  A promise that returns the call response object or object having *result*
1145
 * and *dataVersion* object if ***getDataVersion*** parameter is true, or an Error if rejected.
1146
 * @example
1147
 * //return the schema graph as a json array
1148
 * client.getDocument({"graph_type":"schema","as_list":true}).then(result={
1149
 *    console.log(result)
1150
 * })
1151
 *
1152
 * //retutn the Country class document from the schema graph
1153
 * client.getDocument({"graph_type":"schema","as_list":true,"id":"Country"}).then(result={
1154
 *    console.log(result)
1155
 * })
1156
 *
1157
 * //pass a document query template to query the document interface
1158
 * const queryTemplate = { "name": "Ireland"}
1159
 * client.getDocument({"as_list":true, "@type":"Country"
1160
 *            query:queryTemplate}).then(result=>{
1161
 *    console.log(result)
1162
 * })
1163
 *
1164
 *
1165
 * // Here we will pass true to show how to get dataVersion
1166
 * const response = await client.getDocument({"graph_type":"schema","as_list":true},
1167
 *   "",
1168
 *   "",
1169
 *   "",
1170
 *   true
1171
 * )
1172
 * console.log(response);
1173
 *
1174
 *  // This will output:
1175
 *  // {
1176
 *  //   result: [ ...... ],
1177
 *  //   dataVersion: 'branch:5fs681tlycnn6jh0ceiqcq4qs89pdfs'
1178
 *  // }
1179
 *
1180
 *  // Now we can use the data version we recieved as a response in previous
1181
 *  // function call and used it is next function call as lastDataVersion
1182
 *
1183
 * const response1 = await client.getDocument({"graph_type":"schema","as_list":true},
1184
 *   "",
1185
 *   "",
1186
 *   response.dataVersion,
1187
 * )
1188
 */
1189
// document interface
1190
WOQLClient.prototype.getDocument = function (params, dbId, branch, lastDataVersion = '', getDataVersion = false, query = undefined) {
1!
1191
  if (dbId) {
×
1192
    this.db(dbId);
×
1193
  }
1194
  if (branch) {
×
1195
    this.checkout(branch);
×
1196
  }
1197
  if (typeof lastDataVersion === 'string' && lastDataVersion !== '') {
×
1198
    this.customHeaders({ 'TerminusDB-Data-Version': lastDataVersion });
×
1199
  }
1200
  let queryDoc;
1201
  if (query) {
×
1202
    queryDoc = query;
×
1203
  } else if (params && typeof params === 'object' && params.query) {
×
1204
    queryDoc = { query: params.query };
×
1205
    delete params.query;
×
1206
  }
1207
  // if query we are send a get with a payload
1208

1209
  if (queryDoc) {
×
1210
    return this.dispatch(
×
1211
      CONST.QUERY_DOCUMENT,
1212
      this.connectionConfig.documentURL(params),
1213
      queryDoc,
1214
      getDataVersion,
1215
    );
1216
  }
1217

1218
  return this.dispatch(CONST.GET, this.connectionConfig.documentURL(params), {}, getDataVersion);
×
1219
};
1220

1221
/**
1222
 *
1223
 * @param {object} json
1224
 * @param {typedef.DocParamsPut} [params] - the Put parameters {@link #typedef.DocParamsPut}
1225
 * @param {*} [dbId] - the database id
1226
 * @param {*} [message] - the update commit message
1227
 * @param {string} [lastDataVersion] the last data version tracking id.
1228
 * @param {boolean} [getDataVersion] If true the function will return object having result
1229
 * and dataVersion.
1230
 * @param {boolean} [create] If true, the function will create a new document if it doesn't exist.
1231
 * @returns {Promise}  A promise that returns the call response object or object having *result*
1232
 * and *dataVersion* object if ***getDataVersion*** parameter is true, or an Error if rejected.
1233
 * @example
1234
 * client.updateDocument(
1235
 * {
1236
 *  "@id": "Person",
1237
 *    "@key": {
1238
 *      "@type": "Random",
1239
 *    },
1240
 *    "@type": "Class",
1241
 *    label: "xsd:string",
1242
 *  },
1243
 * { graph_type: "schema" }
1244
 * );
1245
 *
1246
 *
1247
 * // Here we will pass true to show how to get dataVersion
1248
 *
1249
    const response = await client.updateDocument(
1250
      {
1251
        "@id": "Person",
1252
        "@key": {
1253
          "@type": "Random",
1254
        },
1255
        "@type": "Class",
1256
        label: "xsd:string",
1257
      },
1258
      { graph_type: "schema" },
1259
      "",
1260
      "",
1261
      "",
1262
      true
1263
    );
1264
 * console.log(response);
1265
 *
1266
 *  // This will output:
1267
 *  // {
1268
 *  //   result: [ ...... ],
1269
 *  //   dataVersion: 'branch:5fs681tlycnn6jh0ceiqcq4qs89pdfs'
1270
 *  // }
1271
 *
1272
 *  // Now we can use the data version we recieved as a response in previous
1273
 *  // function call and used it is next function call as lastDataVersion
1274
 *
1275
 * const response1 = await client.updateDocument(
1276
      {
1277
        "@id": "Person",
1278
        "@key": {
1279
          "@type": "Random",
1280
        },
1281
        "@type": "Class",
1282
        label: "xsd:string",
1283
      },
1284
      { graph_type: "schema" },
1285
      "",
1286
      "",
1287
      response.dataVersion
1288
    );
1289
 *
1290
 *  // update a document and create the linked document together
1291
 *  // we are update the document "Person/Person01"
1292
 *  // and create a new document {"@type": "Person","name": "child01"} at the same time
1293
 *  const response1 = await client.updateDocument(
1294
     {
1295
      "@id": "Person/Person01",
1296
      "@type": "Person",
1297
      "name": "Person01"
1298
      "children":[{"@type": "Person","name": "child01"}]
1299
    },{create:true})
1300
 */
1301

1302
WOQLClient.prototype.updateDocument = function (json, params, dbId, message = 'update document', lastDataVersion = '', getDataVersion = false, compress = false, create = false) {
1!
1303
  const docParams = params || {};
×
1304
  docParams.author = this.author();
×
1305
  docParams.message = message;
×
1306
  if (docParams.create) {
×
1307
    docParams.create = create;
×
1308
  }
1309
  if (dbId) {
×
1310
    this.db(dbId);
×
1311
  }
1312
  if (typeof lastDataVersion === 'string' && lastDataVersion !== '') {
×
1313
    this.customHeaders({ 'TerminusDB-Data-Version': lastDataVersion });
×
1314
  }
1315
  return this.dispatch(
×
1316
    CONST.PUT,
1317
    this.connectionConfig.documentURL(docParams),
1318
    json,
1319
    getDataVersion,
1320
    compress,
1321
  );
1322
};
1323

1324
/**
1325
 * to delete the document
1326
 * @param {typedef.DocParamsDelete} [params]
1327
 * @param {string} [dbId] - the database id
1328
 * @param {string} [message] - the delete message
1329
 * @param {string} [lastDataVersion] the last data version tracking id.
1330
 * @param {boolean} [getDataVersion] If true the function will return object having result
1331
 * and dataVersion.
1332
 * @returns {Promise}  A promise that returns the call response object or object having *result*
1333
 * and *dataVersion* object if ***getDataVersion*** parameter is true, or an Error if rejected.
1334
 * @example
1335
 * client.deleteDocument({"graph_type":"schema",id:['Country','Coordinate']})
1336
 *
1337
 *
1338
 * // Here we will pass true to show how to get dataVersion
1339
 *
1340
 * const response = await client.deleteDocument({"graph_type":"schema",id:['Country','Coordinate']},
1341
 *   "",
1342
 *   "",
1343
 *   "",
1344
 *   true
1345
 * )
1346
 * console.log(response);
1347
 *
1348
 *  // This will output:
1349
 *  // {
1350
 *  //   result: [ ...... ],
1351
 *  //   dataVersion: 'branch:5fs681tlycnn6jh0ceiqcq4qs89pdfs'
1352
 *  // }
1353
 *
1354
 *  // Now we can use the data version we recieved as a response in previous
1355
 *  // function call and used it is next function call as lastDataVersion
1356
 *
1357
 * const response1 = await client.deleteDocument({"graph_type":"schema",
1358
 *   id:['Country','Coordinate']},
1359
 *   "",
1360
 *   "",
1361
 *   response.dataVersion,
1362
 * )
1363
 */
1364

1365
WOQLClient.prototype.deleteDocument = function (params, dbId, message = 'delete document', lastDataVersion = '', getDataVersion = false) {
1!
1366
  const docParams = params || {};
×
1367
  let payload = null;
×
1368
  if (Array.isArray(params.id)) {
×
1369
    payload = params.id;
×
1370
    delete docParams.id;
×
1371
  }
1372
  docParams.author = this.author();
×
1373
  docParams.message = message;
×
1374
  if (dbId) {
×
1375
    this.db(dbId);
×
1376
  }
1377
  if (typeof lastDataVersion === 'string' && lastDataVersion !== '') {
×
1378
    this.customHeaders({ 'TerminusDB-Data-Version': lastDataVersion });
×
1379
  }
1380
  return this.dispatch(
×
1381
    CONST.DELETE,
1382
    this.connectionConfig.documentURL(docParams),
1383
    payload,
1384
    getDataVersion,
1385
  );
1386
};
1387
/**
1388
 * The purpose of this method is to quickly discover the supported fields of a particular type.
1389
 * @param {string} [type] - If given, the type to get information for. If omitted, information
1390
 * for all types is returned
1391
 * @param {string} [dbId] - the database id
1392
 * @returns {Promise}  A promise that returns the call response object, or an Error if rejected.
1393
 * @example
1394
 * client.getSchemaFrame("Country")
1395
 */
1396

1397
WOQLClient.prototype.getSchemaFrame = function (type, dbId) {
1✔
1398
  let params;
1399
  if (type) params = { type };
×
1400
  if (dbId) {
×
1401
    this.db(dbId);
×
1402
  }
1403
  return this.dispatch(CONST.GET, this.connectionConfig.jsonSchemaURL(params));
×
1404
};
1405

1406
/**
1407
 * get the database schema in json format
1408
 * @param {string} [dbId] - the database id
1409
 * @param {string} [branch] -  specific a branch/collection
1410
 * @returns {Promise}  A promise that returns the call response object, or an Error if rejected.
1411
 * @example
1412
 * client.getSchema()
1413
 */
1414

1415
WOQLClient.prototype.getSchema = function (dbId, branch) {
1✔
1416
  const params = { graph_type: 'schema', as_list: true };
×
1417
  return this.getDocument(params, dbId, branch);
×
1418
};
1419

1420
/**
1421
 * get all the schema classes (documents,subdocuments,abstracts)
1422
 * @param {string} [dbId] - the database id
1423
 * @returns {Promise}  A promise that returns the call response object, or an Error if rejected.
1424
 * @example
1425
 * client.getClasses()
1426
 */
1427

1428
WOQLClient.prototype.getClasses = function (dbId) {
1✔
1429
  const params = { graph_type: 'schema', as_list: true, type: 'sys:Class' };
×
1430
  return this.getDocument(params, dbId);
×
1431
};
1432

1433
/**
1434
 * get all the Enum Objects
1435
 * @param {string} [dbId]
1436
 * @returns {Promise}  A promise that returns the call response object, or an Error if rejected.
1437
 * @example
1438
 * client.getEnums()
1439
 */
1440
WOQLClient.prototype.getEnums = function (dbId) {
1✔
1441
  const params = { graph_type: 'schema', as_list: true, type: 'sys:Enum' };
×
1442
  return this.getDocument(params, dbId);
×
1443
};
1444

1445
/**
1446
 * get all the Document Classes (no abstract or subdocument)
1447
 * @param {string} [dbId]
1448
 * @returns {Promise}  A promise that returns the call response object, or an Error if rejected.
1449
 * @example
1450
 * client.getClassDocuments()
1451
 */
1452
WOQLClient.prototype.getClassDocuments = function (dbId) {
1✔
1453
  const params = { graph_type: 'schema', as_list: true, type: 'sys:Class' };
×
1454
  return this.getDocument(params, dbId).then((result) => {
×
1455
    let documents = [];
×
1456
    if (result) {
×
1457
      documents = result.filter((item) => !item['@subdocument'] && !item['@abstract']);
×
1458
    }
1459
    return documents;
×
1460
  });
1461
};
1462

1463
/**
1464
 * get the database collections list
1465
 * @param {string} [dbId] - the database id
1466
 * @returns {Promise}  A promise that returns the call response object, or an Error if rejected.
1467
 * @example
1468
 * client.getBranches()
1469
 */
1470
WOQLClient.prototype.getBranches = function (dbId) {
1✔
1471
  const params = { type: 'Branch', as_list: true };
×
1472
  const branch = this.checkout();
×
1473
  return this.getDocument(params, dbId, '_commits').then((result) => {
×
1474
    const branchesObj = {};
×
1475
    if (result) {
×
1476
      result.forEach((item) => {
×
1477
        branchesObj[item.name] = item;
×
1478
      });
1479
    }
1480
    this.checkout(branch);
×
1481
    return branchesObj;
×
1482
  });
1483
  // reset branch
1484
};
1485

1486
/**
1487
 * get the database collections list
1488
 * @param {number} [start=0] - where to start printing the commit
1489
 *    information in the log (starting from the head of the current branch)
1490
 * @param {number} [count=1] - The number of total commit log records to return
1491
 * @returns {Promise}  A promise that returns the call response object, or an Error if rejected.
1492
 * @example
1493
 * client.getCommitsLog(count=10)
1494
 */
1495
WOQLClient.prototype.getCommitsLog = function (start = 0, count = 1) {
1!
1496
  return this.dispatch(
×
1497
    CONST.GET,
1498
    `${this.connectionConfig.log()}?start=${start}&count=${count}`,
1499
  );
1500
};
1501

1502
/**
1503
 * get the database prefixes object
1504
 * @param {string} [dbId] - the database id
1505
 * @returns {Promise}  A promise that returns the call response object, or an Error if rejected.
1506
 * @example
1507
 * client.getPrefixes()
1508
 * //return object example
1509
 * {
1510
 * '@base': 'terminusdb:///data/',
1511
 * '@schema': 'terminusdb:///schema#',
1512
 * '@type': 'Context'}
1513
 */
1514
WOQLClient.prototype.getPrefixes = function (dbId) {
1✔
1515
  if (dbId) this.db(dbId);
×
1516
  return this.dispatch(
×
1517
    CONST.GET,
1518
    this.connectionConfig.prefixesURL(),
1519
  );
1520
};
1521

1522
/**
1523
 * Get the list of the user's organizations and the database related
1524
 * @returns {Promise}  A promise that returns the call response object, or an Error if rejected.
1525
 * @example
1526
 * async funtion callGetUserOrganizations(){
1527
 *      await getUserOrganizations()
1528
 *      console.log(client.userOrganizations())
1529
 * }
1530
 */
1531
WOQLClient.prototype.getUserOrganizations = function () {
1✔
1532
  // this will be change to give back only the organizations list
1533
  return this.dispatch(
×
1534
    CONST.GET,
1535
    this.connectionConfig.userOrganizationsURL(),
1536
  ).then((response) => {
1537
    const orgList = Array.isArray(response) ? response : [];
×
1538
    this.userOrganizations(orgList);
×
1539
    return orgList;
×
1540
  });
1541
};
1542

1543
/**
1544
 * Get/Set the list of the user's organizations (id, organization, label, comment).
1545
 * @param {array} [orgList] a list of user's Organization
1546
 * @returns {array} the user Organizations list
1547
 * @example
1548
 * async funtion callGetUserOrganizations(){
1549
 *      await client.getUserOrganizations()
1550
 *      console.log(client.userOrganizations())
1551
 * }
1552
 */
1553
WOQLClient.prototype.userOrganizations = function (orgList) {
1✔
1554
  if (orgList) this.organizationList = orgList;
×
1555
  return this.organizationList || [];
×
1556
};
1557

1558
/**
1559
 * Get the patch of difference between two documents.
1560
 * @param {object} before - The current state of JSON document
1561
 * @param {object} after - The updated state of JSON document
1562
 * @param {object} [options] - {keep:{}} Options to send to the diff endpoint.
1563
 * The diff api outputs the changes between the input,
1564
 * in options you can list the properties that you would like to see in the diff result in any case.
1565
 * @returns {Promise}  A promise that returns the call response object, or an Error if rejected.
1566
 * @example
1567
 * client.getJSONDiff(
1568
 *      { "@id": "Person/Jane", "@type": "Person", name: "Jane" },
1569
 *      { "@id": "Person/Jane", "@type": "Person", name: "Janine" }
1570
 *  ).then(diffResult=>{
1571
 *  console.log(diffResult)
1572
 * })
1573
 * //result example
1574
 * //{'@id': 'Person/Jane',
1575
 * // name: { '@after': 'Janine', '@before': 'Jane', '@op': 'SwapValue' }}
1576
 */
1577
WOQLClient.prototype.getJSONDiff = function (before, after, options) {
1✔
1578
  if (typeof before !== 'object' || typeof after !== 'object') {
×
1579
    const errmsg = '"before" or "after" parameter error - you must specify a valid before or after json document';
×
1580

1581
    return Promise.reject(
×
1582
      new Error(ErrorMessage.getInvalidParameterMessage(CONST.GET_DIFF, errmsg)),
1583
    );
1584
  }
1585
  const opt = (typeof options === 'undefined') ? {} : options;
×
1586
  const payload = { before, after, ...opt };
×
1587

1588
  return this.dispatch(
×
1589
    CONST.POST,
1590
    `${this.connectionConfig.apiURL()}diff`,
1591
    payload,
1592
  ).then((response) => response);
×
1593
};
1594

1595
/**
1596
 * Get the patch of difference between two documents.
1597
 * @param {string} dataVersion - The version from which to compare the object
1598
 * @param {object} jsonObject - The updated state of JSON document
1599
 * @param {string} id - The document id to be diffed
1600
 * @param {object} [options] - {keep:{}} Options to send to the diff endpoint
1601
 * the diff api outputs the changes between the input,
1602
 * but you can list the properties that you would like to see in the diff result in any case.
1603
 * @returns {Promise}  A promise that returns the call response object, or an Error if rejected.
1604
 * @example
1605
 * const jsonObj =  { "@id": "Person/Jane", "@type": "Person", name: "Janine" }
1606
 * client.getVersionObjectDiff("main",jsonObj
1607
 *      "Person/Jane").then(diffResp=>{
1608
 *    console.log(diffResp)
1609
 * })
1610
 */
1611
WOQLClient.prototype.getVersionObjectDiff = function (dataVersion, jsonObject, id, options) {
1✔
1612
  if (typeof jsonObject !== 'object' || typeof dataVersion !== 'string' || typeof id !== 'string') {
×
1613
    const errmsg = 'Parameters error - you must specify a valid jsonObject document, a valid branch or commit and a valid id';
×
1614

1615
    return Promise.reject(
×
1616
      new Error(ErrorMessage.getInvalidParameterMessage(CONST.GET_DIFF, errmsg)),
1617
    );
1618
  }
1619
  const opt = options || {};
×
1620
  const payload = {
×
1621
    after: jsonObject,
1622
    before_data_version: dataVersion,
1623
    id,
1624
    ...opt,
1625
  };
1626
  return this.dispatch(
×
1627
    CONST.POST,
1628
    this.connectionConfig.diffURL(),
1629
    payload,
1630
  ).then((response) => response);
×
1631
};
1632

1633
/**
1634
 * Get the patch of difference between branches or commits.
1635
 * @param {string} beforeVersion - Before branch/commit to compare
1636
 * @param {string} afterVersion -  After branch/commit to compare
1637
 * @param {string} [id] - The document id to be diffed,
1638
 * if it is omitted all the documents will be compared
1639
 * @param {object} [options] - {keep:{}} Options to send to the diff endpoint.
1640
 * The diff api outputs the changes between the input (branches or commits),
1641
 * in options you can list the properties that you would like to see in the diff result in any case.
1642
 * @returns {Promise}  A promise that returns the call response object, or an Error if rejected.
1643
 * @example
1644
 * //This is to view all the changes between two commits
1645
 * const beforeCommit = "a73ssscfx0kke7z76083cgswszdxy6l"
1646
 * const afterCommit = "73rqpooz65kbsheuno5dsayh71x7wf4"
1647
 *
1648
 * client.getVersionDiff( beforeCommit, afterCommit).then(diffResult=>{
1649
 *  console.log(diffResult)
1650
 * })
1651
 *
1652
 * //This is to view the changes between two commits but only for the given document
1653
 * client.getVersionDiff( beforeCommit, afterCommit, "Person/Tom").then(diffResult=>{
1654
 *  console.log(diffResult)
1655
 * })
1656
 *
1657
 * //This is to view the changes between a branch (head) and a commit for the given document
1658
 * client.getVersionDiff("main", afterCommit, "Person/Tom" ).then(diffResult=>{
1659
 *    console.log(diffResult)
1660
 * })
1661
 *
1662
 * //This is to view the changes between two branches with the keep options
1663
 * const options = {"keep":{"@id":true, "name": true}}
1664
 * client.getVersionDiff("main","mybranch",options).then(diffResult=>{
1665
 *    console.log(diffResult)
1666
 * })
1667
 */
1668

1669
WOQLClient.prototype.getVersionDiff = function (beforeVersion, afterVersion, id, options) {
1✔
1670
  if (typeof beforeVersion !== 'string' || typeof afterVersion !== 'string') {
×
1671
    const errmsg = 'Error, you have to provide a beforeVersion and afterVersion input';
×
1672

1673
    return Promise.reject(
×
1674
      new Error(ErrorMessage.getInvalidParameterMessage(CONST.GET_DIFF, errmsg)),
1675
    );
1676
  }
1677
  const opt = options || {};
×
1678
  const payload = {
×
1679
    before_data_version: beforeVersion,
1680
    after_data_version: afterVersion,
1681
    ...opt,
1682
  };
1683
  if (id) {
×
1684
    payload.document_id = id;
×
1685
  }
1686
  // console.log(this.connectionConfig.diffURL())
1687
  return this.dispatch(
×
1688
    CONST.POST,
1689
    this.connectionConfig.diffURL(),
1690
    payload,
1691
  ).then((response) => response);
×
1692
};
1693

1694
/**
1695
 * Diff two different commits and apply changes on the current branch/commit.
1696
 * If you would like to change branch or commit before apply use client.checkout("branchName")
1697
 * @param {string} beforeVersion - Before branch/commit to compare
1698
 * @param {string} afterVersion - After branch/commit to compare
1699
 * @param {string} message - apply commit message
1700
 * @param {boolean} [matchFinalState] - the default value is false
1701
 * @param {object} [options] - {keep:{}} Options to send to the apply endpoint
1702
 * @example
1703
 * client.checkout("mybranch")
1704
 * client.apply("main","mybranch","merge main").then(result=>{
1705
 *    console.log(result)
1706
 * })
1707
 */
1708

1709
// eslint-disable-next-line max-len
1710
WOQLClient.prototype.apply = function (beforeVersion, afterVersion, message, matchFinalState, options) {
1✔
1711
  const opt = options || {};
×
1712
  const commitMsg = this.generateCommitInfo(message);
×
1713
  const payload = {
×
1714
    before_commit: beforeVersion,
1715
    after_commit: afterVersion,
1716
    ...commitMsg,
1717
    ...opt,
1718
  };
1719
  if (matchFinalState) {
×
1720
    payload.match_final_state = matchFinalState;
×
1721
  }
1722
  return this.dispatch(
×
1723
    CONST.POST,
1724
    this.connectionConfig.applyURL(),
1725
    payload,
1726
  ).then((response) => response);
×
1727
};
1728

1729
/**
1730
 * Patch the difference between two documents.
1731
 * @param {object} before - The current state of JSON document
1732
 * @param {object} patch - The patch object
1733
 * @returns {Promise}  A promise that returns the call response object, or an Error if rejected.
1734
 * @example
1735
 *  let diffPatch = await client.getJSONDiff(
1736
 *      { "@id": "Person/Jane", "@type": "Person", name: "Jane" },
1737
 *      { "@id": "Person/Jane", "@type": "Person", name: "Janine" }
1738
 *  );
1739
 *
1740
 * let patch = await client.patch( { "@id": "Person/Jane", "@type": "Person", name: "Jane" },
1741
 * diffPatch);
1742
 */
1743
WOQLClient.prototype.patch = function (before, patch) {
1✔
1744
  if (typeof before !== 'object' || typeof patch !== 'object') {
×
1745
    const errmsg = '"before" or "patch" parameter error - you must specify a valid before or patch json document';
×
1746

1747
    return Promise.reject(
×
1748
      new Error(ErrorMessage.getInvalidParameterMessage(CONST.PATCH, errmsg)),
1749
    );
1750
  }
1751
  const payload = { before, patch };
×
1752

1753
  return this.dispatch(
×
1754
    CONST.POST,
1755
    `${this.connectionConfig.apiURL()}patch`,
1756
    payload,
1757
  ).then((response) => response);
×
1758
};
1759

1760
/**
1761
 * Call a custom Api endpoit
1762
 * @param {string} requestType - The current state of JSON document
1763
 * @param {string} customRequestURL - The patch object
1764
 * @param {object} [payload] - the request payload
1765
 * @returns {Promise}  A promise that returns the call response object, or an Error if rejected.
1766
 * @example
1767
 * client.sendCustomRequest("GET", "http://localhost:3030/changes/").then(result=>{
1768
 *    console.log(result)
1769
 * })
1770
 */
1771

1772
WOQLClient.prototype.sendCustomRequest = function (requestType, customRequestURL, payload) {
1✔
1773
  return this.dispatch(
×
1774
    requestType,
1775
    customRequestURL,
1776
    payload,
1777
  ).then((response) => response);
×
1778
};
1779

1780
module.exports = WOQLClient;
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc