terminusdb 12.0.2

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.
Files changed (86) hide show
  1. package/Contributing.md +36 -0
  2. package/LICENSE +201 -0
  3. package/README.md +175 -0
  4. package/RELEASE_NOTES.md +462 -0
  5. package/dist/index.html +22 -0
  6. package/dist/terminusdb-client.min.js +3 -0
  7. package/dist/terminusdb-client.min.js.LICENSE.txt +188 -0
  8. package/dist/terminusdb-client.min.js.map +1 -0
  9. package/dist/typescript/index.d.ts +14 -0
  10. package/dist/typescript/lib/accessControl.d.ts +554 -0
  11. package/dist/typescript/lib/axiosInstance.d.ts +2 -0
  12. package/dist/typescript/lib/connectionConfig.d.ts +381 -0
  13. package/dist/typescript/lib/const.d.ts +54 -0
  14. package/dist/typescript/lib/dispatchRequest.d.ts +17 -0
  15. package/dist/typescript/lib/errorMessage.d.ts +25 -0
  16. package/dist/typescript/lib/query/woqlBuilder.d.ts +75 -0
  17. package/dist/typescript/lib/query/woqlCore.d.ts +341 -0
  18. package/dist/typescript/lib/query/woqlDoc.d.ts +63 -0
  19. package/dist/typescript/lib/query/woqlLibrary.d.ts +718 -0
  20. package/dist/typescript/lib/query/woqlPrinter.d.ts +71 -0
  21. package/dist/typescript/lib/query/woqlQuery.d.ts +833 -0
  22. package/dist/typescript/lib/typedef.d.ts +624 -0
  23. package/dist/typescript/lib/utils.d.ts +199 -0
  24. package/dist/typescript/lib/valueHash.d.ts +146 -0
  25. package/dist/typescript/lib/viewer/chartConfig.d.ts +62 -0
  26. package/dist/typescript/lib/viewer/chooserConfig.d.ts +38 -0
  27. package/dist/typescript/lib/viewer/documentFrame.d.ts +44 -0
  28. package/dist/typescript/lib/viewer/frameConfig.d.ts +74 -0
  29. package/dist/typescript/lib/viewer/frameRule.d.ts +145 -0
  30. package/dist/typescript/lib/viewer/graphConfig.d.ts +73 -0
  31. package/dist/typescript/lib/viewer/objectFrame.d.ts +212 -0
  32. package/dist/typescript/lib/viewer/streamConfig.d.ts +23 -0
  33. package/dist/typescript/lib/viewer/tableConfig.d.ts +66 -0
  34. package/dist/typescript/lib/viewer/terminusRule.d.ts +75 -0
  35. package/dist/typescript/lib/viewer/viewConfig.d.ts +47 -0
  36. package/dist/typescript/lib/viewer/woqlChart.d.ts +1 -0
  37. package/dist/typescript/lib/viewer/woqlChooser.d.ts +56 -0
  38. package/dist/typescript/lib/viewer/woqlGraph.d.ts +26 -0
  39. package/dist/typescript/lib/viewer/woqlPaging.d.ts +1 -0
  40. package/dist/typescript/lib/viewer/woqlResult.d.ts +128 -0
  41. package/dist/typescript/lib/viewer/woqlRule.d.ts +96 -0
  42. package/dist/typescript/lib/viewer/woqlStream.d.ts +31 -0
  43. package/dist/typescript/lib/viewer/woqlTable.d.ts +102 -0
  44. package/dist/typescript/lib/viewer/woqlView.d.ts +49 -0
  45. package/dist/typescript/lib/woql.d.ts +1267 -0
  46. package/dist/typescript/lib/woqlClient.d.ts +1216 -0
  47. package/index.js +28 -0
  48. package/lib/.eslintrc +1 -0
  49. package/lib/accessControl.js +988 -0
  50. package/lib/axiosInstance.js +5 -0
  51. package/lib/connectionConfig.js +765 -0
  52. package/lib/const.js +59 -0
  53. package/lib/dispatchRequest.js +236 -0
  54. package/lib/errorMessage.js +110 -0
  55. package/lib/query/woqlBuilder.js +234 -0
  56. package/lib/query/woqlCore.js +934 -0
  57. package/lib/query/woqlDoc.js +177 -0
  58. package/lib/query/woqlLibrary.js +1015 -0
  59. package/lib/query/woqlPrinter.js +476 -0
  60. package/lib/query/woqlQuery.js +1865 -0
  61. package/lib/typedef.js +248 -0
  62. package/lib/utils.js +817 -0
  63. package/lib/valueHash.js_old +581 -0
  64. package/lib/viewer/chartConfig.js +411 -0
  65. package/lib/viewer/chooserConfig.js +234 -0
  66. package/lib/viewer/documentFrame.js +206 -0
  67. package/lib/viewer/frameConfig.js +469 -0
  68. package/lib/viewer/frameRule.js +519 -0
  69. package/lib/viewer/graphConfig.js +345 -0
  70. package/lib/viewer/objectFrame.js +1550 -0
  71. package/lib/viewer/streamConfig.js +82 -0
  72. package/lib/viewer/tableConfig.js +310 -0
  73. package/lib/viewer/terminusRule.js +196 -0
  74. package/lib/viewer/viewConfig.js +219 -0
  75. package/lib/viewer/woqlChart.js +17 -0
  76. package/lib/viewer/woqlChooser.js +171 -0
  77. package/lib/viewer/woqlGraph.js +295 -0
  78. package/lib/viewer/woqlPaging.js +148 -0
  79. package/lib/viewer/woqlResult.js +258 -0
  80. package/lib/viewer/woqlRule.js +312 -0
  81. package/lib/viewer/woqlStream.js +27 -0
  82. package/lib/viewer/woqlTable.js +332 -0
  83. package/lib/viewer/woqlView.js +107 -0
  84. package/lib/woql.js +1693 -0
  85. package/lib/woqlClient.js +2091 -0
  86. package/package.json +110 -0
@@ -0,0 +1,1216 @@
1
+ export = WOQLClient;
2
+ /**
3
+ * @typedef {Object} NamedResourceData
4
+ */
5
+ /**
6
+ * @license Apache Version 2
7
+ * @class
8
+ * @classdesc The core functionality of the TerminusDB javascript client is
9
+ * defined in the WOQLClient class - in the woqlClient.js file. This class provides
10
+ * methods which allow you to directly get and set all of the configuration and API
11
+ * endpoints of the client. The other parts of the WOQL core - connectionConfig.js
12
+ * and connectionCapabilities.js - are used by the client to store internal state - they
13
+ * should never have to be accessed directly. For situations where you want to communicate
14
+ * with a TerminusDB server API, the WOQLClient class is all you will need.
15
+ */
16
+ declare class WOQLClient {
17
+ /**
18
+ * @constructor
19
+ * @param {string} serverUrl - the terminusdb server url
20
+ * @param {typedef.ParamsObj} [params] - an object with the connection parameters
21
+ * @example
22
+ * //to connect with your local terminusDB. "key" is the password for the user
23
+ * //for admin, this is the initial password set during the installation
24
+ * const client = new TerminusClient.WOQLClient(SERVER_URL,{user:"admin",key:"myKey"})
25
+ * async function getSchema() {
26
+ * client.db("test")
27
+ * client.checkout("dev")
28
+ * const schema = await client.getSchema()
29
+ * }
30
+ * //The client has an internal state which defines what
31
+ * //organization / database / repository / branch / ref it is currently attached to
32
+ *
33
+ * //to connect with your TerminusDB Cloud Instance
34
+ * const client = new TerminusClient.WOQLClient('SERVER_CLOUD_URL/mycloudTeam',
35
+ * {user:"myemail@something.com", organization:'mycloudTeam'})
36
+ *
37
+ * client.setApiKey(MY_ACCESS_TOKEN)
38
+ *
39
+ * //to get the list of all organization's databases
40
+ * async function callGetDatabases(){
41
+ * const dbList = await client.getDatabases()
42
+ * console.log(dbList)
43
+ * }
44
+ *
45
+ * async function getSchema() {
46
+ * client.db("test")
47
+ * client.checkout("dev")
48
+ * const schema = await client.getSchema()
49
+ * }
50
+ */
51
+ constructor(serverUrl: string, params?: typedef.ParamsObj);
52
+ connectionConfig: any;
53
+ databaseList: any[];
54
+ organizationList: any[];
55
+ /**
56
+ * set the api key to access the cloud resources
57
+ * @param {string} accessToken
58
+ */
59
+ setApiKey(accessToken: string): void;
60
+ /**
61
+ * add extra headers to your request
62
+ * @param {object} customHeaders
63
+ * @returns {object}
64
+ */
65
+ customHeaders(customHeaders: object): object;
66
+ _customHeaders: any;
67
+ CONST: Readonly<{
68
+ POST: "POST";
69
+ GET: "GET";
70
+ DELETE: "DELETE";
71
+ PUT: "PUT";
72
+ HEAD: "HEAD";
73
+ QUERY_DOCUMENT: "QUERY_DOCUMENT";
74
+ SQUASH_BRANCH: "SQUASH_BRANCH";
75
+ UPDATE_SCHEMA: "UPDATE_SCHEMA";
76
+ CONNECT: "connect";
77
+ CREATE_DATABASE: "create_database";
78
+ READ_DATABASE: "read_database";
79
+ UPDATE_DATABASE: "update_database";
80
+ CREATE_USER: "create_user";
81
+ READ_USER: "read_user";
82
+ UPDATE_USER: "update_user";
83
+ CREATE_ORGANIZATION: "create_organization";
84
+ READ_ORGANIZATION: "read_organization";
85
+ UPDATE_ORGANIZATION: "update_organization";
86
+ GET_ROLES: "get_roles";
87
+ UPDATE_ROLES: "update_roles";
88
+ CREATE_GRAPH: "create_graph";
89
+ GET_TRIPLES: "get_triples";
90
+ INSERT_TRIPLES: "insert_triples";
91
+ UPDATE_TRIPLES: "update_triples";
92
+ CLASS_FRAME: "class_frame";
93
+ WOQL_QUERY: "woql_query";
94
+ CLONE: "clone";
95
+ CSV: "csv";
96
+ WOQL: "woql";
97
+ FRAME: "frame";
98
+ PUSH: "push";
99
+ PULL: "pull";
100
+ FETCH: "fetch";
101
+ REBASE: "rebase";
102
+ RESET: "reset";
103
+ BRANCH: "branch";
104
+ REMOTE: "remote";
105
+ CREATE_REMOTE: "create_remote";
106
+ GET_REMOTE: "get_remote";
107
+ UPDATE_REMOTE: "update_remote";
108
+ DELETE_REMOTE: "delete_remote";
109
+ RESET_BRANCH: "reset_branch";
110
+ ADD_CSV: "add_csv";
111
+ GET_CSV: "get_csv";
112
+ UPDATE_CSV: "update_csv";
113
+ MESSAGE: "message";
114
+ ACTION: "action";
115
+ INFO: "info";
116
+ OPTIMIZE_SYSTEM: "optimize_system";
117
+ GET_DIFF: "getDiff";
118
+ PATCH: "patch";
119
+ }>;
120
+ /**
121
+ * creates a copy of the client with identical internal state and context
122
+ * useful if we want to change context for a particular API call without changing
123
+ * the current client context
124
+ * @returns {WOQLClient} new client object with identical state to original but
125
+ * which can be manipulated independently
126
+ * @example
127
+ * let newClient = client.copy()
128
+ */
129
+ copy(): WOQLClient;
130
+ /**
131
+ * Gets the current connected server url
132
+ * it can only be set creating a new WOQLCLient instance
133
+ * @returns {string}
134
+ */
135
+ server(): string;
136
+ /**
137
+ * Retrieve the URL of the server’s API base that we are currently connected to
138
+ * @returns {string} the URL of the TerminusDB server api endpoint we are connected
139
+ * to (typically server() + “api/”)
140
+ * @example
141
+ * let api_url = client.api()
142
+ */
143
+ api(): string;
144
+ /**
145
+ * Gets/Sets the client’s internal organization context value, if you change the organization
146
+ * name the databases list will be set to empty
147
+ * @param {string | boolean} [orgId] the organization id to set the context to
148
+ * @returns {string | boolean}
149
+ * @example
150
+ * client.organization("admin")
151
+ */
152
+ organization(orgId?: string | boolean): string | boolean;
153
+ /**
154
+ * Checks if a database exists
155
+ *
156
+ * Returns true if a DB exists and false if it doesn't. Other results
157
+ * throw an exception.
158
+ * @param {string} [orgName] the organization id to set the context to
159
+ * @param {string} [dbName] the db name to set the context to
160
+ * @returns {Promise}
161
+ * @example
162
+ * async function executeIfDatabaseExists(f){
163
+ * const hasDB = await client.hasDatabase("admin", "testdb")
164
+ * if (hasDB) {
165
+ * f()
166
+ * }
167
+ * }
168
+ */
169
+ hasDatabase(orgName?: string, dbName?: string): Promise<any>;
170
+ /**
171
+ * Gets the organization's databases list.
172
+ *
173
+ * If no organization has been set up, the function throws an exception
174
+ * @returns {Promise}
175
+ * @example
176
+ * async function callGetDatabases(){
177
+ * const dbList = await client.getDatabases()
178
+ * console.log(dbList)
179
+ * }
180
+ */
181
+ getDatabases(): Promise<any>;
182
+ /**
183
+ * Set/Get the organization's databases list (id, label, comment) that the current
184
+ * user has access to on the server.
185
+ * @param {array} [dbList] a list of databases the user has access to on the server, each having:
186
+ * @returns {array} the organization's databases list
187
+ * @example
188
+ * //to get the list of all organization's databases
189
+ * async function callGetDatabases(){
190
+ * await client.getDatabases()
191
+ * console.log(client.databases())
192
+ * }
193
+ *
194
+ */
195
+ databases(dbList?: any[]): any[];
196
+ /**
197
+ * Gets the current user object as returned by the connect capabilities response
198
+ * user has fields: [id, name, notes, author]
199
+ * @returns {Object}
200
+ */
201
+ user(): any;
202
+ /**
203
+ * @desription Gets the user's organization id
204
+ * @returns {string} the user organization name
205
+ */
206
+ userOrganization(): string;
207
+ /**
208
+ * Gets the database's details
209
+ * @param {string} [dbName] - the datbase name
210
+ * @returns {object} the database description object
211
+ */
212
+ databaseInfo(dbName?: string): object;
213
+ /**
214
+ * Sets / Gets the current database
215
+ * @param {string} [dbId] - the database id to set the context to
216
+ * @returns {string|boolean} - the current database or false
217
+ * @example
218
+ * client.db("mydb")
219
+ */
220
+ db(dbId?: string): string | boolean;
221
+ /**
222
+ *Sets the internal client context to allow it to talk to the server’s internal system database
223
+ *
224
+ */
225
+ setSystemDb(): void;
226
+ /**
227
+ * Gets / Sets the client’s internal repository context value (defaults to ‘local’)
228
+ * @param {typedef.RepoType | string} [repoId] - default value is local
229
+ * @returns {string} the current repository id within the client context
230
+ * @example
231
+ * client.repo("origin")
232
+ */
233
+ repo(repoId?: typedef.RepoType | string): string;
234
+ /**
235
+ * Gets/Sets the client’s internal branch context value (defaults to ‘main’)
236
+ * @param {string} [branchId] - the branch id to set the context to
237
+ * @returns {string} the current branch id within the client context
238
+ */
239
+ checkout(branchId?: string): string;
240
+ /**
241
+ * Sets / gets the current ref pointer (pointer to a commit within a branch)
242
+ * Reference ID or Commit ID are unique hashes that are created whenever a new commit is recorded
243
+ * @param {string} [commitId] - the reference ID or commit ID
244
+ * @returns {string|boolean} the current commit id within the client context
245
+ * @example
246
+ * client.ref("mkz98k2h3j8cqjwi3wxxzuyn7cr6cw7")
247
+ */
248
+ ref(commitId?: string): string | boolean;
249
+ /**
250
+ * Sets/Gets set the database basic connection credential
251
+ * @param {typedef.CredentialObj} [newCredential]
252
+ * @returns {typedef.CredentialObj | boolean}
253
+ * @example
254
+ * client.localAuth({user:"admin","key":"mykey","type":"basic"})
255
+ */
256
+ localAuth(newCredential?: typedef.CredentialObj): typedef.CredentialObj | boolean;
257
+ /**
258
+ * Use {@link #localAuth} instead.
259
+ * @deprecated
260
+ */
261
+ local_auth: (newCredential?: typedef.CredentialObj) => typedef.CredentialObj | boolean;
262
+ /**
263
+ * Sets/Gets the jwt token for authentication
264
+ * we need this to connect 2 terminusdb server to each other for push, pull, clone actions
265
+ * @param {typedef.CredentialObj} [newCredential]
266
+ * @returns {typedef.CredentialObj | boolean}
267
+ * @example
268
+ * client.remoteAuth({"key":"dhfmnmjglkrelgkptohkn","type":"jwt"})
269
+ */
270
+ remoteAuth(newCredential?: typedef.CredentialObj): typedef.CredentialObj | boolean;
271
+ /**
272
+ * Use {@link #remoteAuth} instead.
273
+ * @deprecated
274
+ */
275
+ remote_auth: (newCredential?: typedef.CredentialObj) => typedef.CredentialObj | boolean;
276
+ /**
277
+ * Gets the string that will be written into the commit log for the current user
278
+ * @returns {string} the current user
279
+ * @example
280
+ * client.author()
281
+ */
282
+ author(): string;
283
+ /**
284
+ * @param {typedef.ParamsObj} params - a object with connection params
285
+ * @example sets several of the internal state values in a single call
286
+ * (similar to connect, but only sets internal client state, does not communicate with server)
287
+ * client.set({key: "mypass", branch: "dev", repo: "origin"})
288
+ */
289
+ set(params: typedef.ParamsObj): void;
290
+ /**
291
+ * Generates a resource string for the required context
292
+ * of the current context for "commits" "meta" "branch" and "ref" special resources
293
+ * @param {typedef.ResourceType} resourceType - the type of resource string that is required - one
294
+ * of “db”, “meta”, “repo”, “commits”, “branch”, “ref”
295
+ * @param {string} [resourceId] - can be used to specify a specific branch / ref - if not supplied
296
+ * the current context will be used
297
+ * @returns {string} a resource string for the desired context
298
+ * @example
299
+ * const branch_resource = client.resource("branch")
300
+ */
301
+ resource(resourceType: typedef.ResourceType, resourceId?: string): string;
302
+ /**
303
+ * You can call this to get the server info or override the start params
304
+ * configuration, this.connectionConfig.server will be used if present,
305
+ * or the promise will be rejected.
306
+ *
307
+ * @deprecated
308
+ *
309
+ * @param {typedef.ParamsObj} [params] - TerminusDB Server connection parameters
310
+ * @returns {Promise} the connection capabilities response object or an error object
311
+ * @example
312
+ * client.connect()
313
+ */
314
+ connect(params?: typedef.ParamsObj): Promise<any>;
315
+ /**
316
+ * Creates a new database in TerminusDB server
317
+ * @param {string} dbId - The id of the new database to be created
318
+ * @param {typedef.DbDetails} dbDetails - object containing details about the database to be created
319
+ * @param {string} [orgId] - optional organization id - if absent default local organization
320
+ * id is used
321
+ * @returns {Promise} A promise that returns the call response object, or an Error if rejected.
322
+ * @example
323
+ * //remember set schema:true if you need to add a schema graph
324
+ * client.createDatabase("mydb", {label: "My Database", comment: "Testing", schema: true})
325
+ */
326
+ createDatabase(dbId: string, dbDetails: typedef.DbDetails, orgId?: string): Promise<any>;
327
+ /**
328
+ * Update a database in TerminusDB server
329
+ * @param {typedef.DbDoc} dbDoc - object containing details about the database to be updated
330
+ * @returns {Promise} A promise that returns the call response object, or an Error if rejected.
331
+ * @example
332
+ * client.updateDatabase({id: "mydb", label: "My Database", comment: "Testing"})
333
+ */
334
+ updateDatabase(dbDoc: typedef.DbDoc): Promise<any>;
335
+ /**
336
+ * Deletes a database from a TerminusDB server
337
+ * @param {string} dbId The id of the database to be deleted
338
+ * @param {string} [orgId] the id of the organization to which the database belongs
339
+ * (in desktop use, this will always be “admin”)
340
+ * @param {boolean} [force]
341
+ * @returns {Promise} A promise that returns the call response object, or an Error if rejected.
342
+ * @example
343
+ * client.deleteDatabase("mydb")
344
+ */
345
+ deleteDatabase(dbId: string, orgId?: string, force?: boolean): Promise<any>;
346
+ /**
347
+ * Retrieve the contents of a graph within a TerminusDB as triples, encoded in
348
+ * the turtle (ttl) format
349
+ * @param {typedef.GraphType} graphType - type of graph to get triples from,
350
+ * either “instance” or “schema”
351
+ * @returns {Promise} A promise that returns the call response object (with
352
+ * the contents being a string representing a set of triples in turtle (ttl) format),
353
+ * or an Error if rejected.
354
+ * @example
355
+ * const turtle = await client.getTriples("schema", "alt")
356
+ */
357
+ getTriples(graphType: typedef.GraphType): Promise<any>;
358
+ /**
359
+ * Replace the contents of the specified graph with the passed triples encoded
360
+ * in the turtle (ttl) format
361
+ * @param {string} graphType - type of graph |instance|schema|inference|
362
+ * @param {string} turtle - string encoding triples in turtle (ttl) format
363
+ * @param {string} commitMsg - Textual message describing the reason for the update
364
+ * @returns {Promise} A promise that returns the call response object, or an Error if rejected.
365
+ * @example
366
+ * client.updateTriples("schema", "alt", turtle_string, "dumping triples to graph alt")
367
+ */
368
+ updateTriples(graphType: string, turtle: string, commitMsg: string): Promise<any>;
369
+ /**
370
+ * Appends the passed turtle to the contents of a graph
371
+ * @param {string} graphType type of graph |instance|schema|inference|
372
+ * @param {string} turtle is a valid set of triples in turtle format (OWL)
373
+ * @param {string} commitMsg Textual message describing the reason for the update
374
+ * @returns {Promise} A promise that returns the call response object, or an Error if rejected.
375
+ */
376
+ insertTriples(graphType: string, turtle: string, commitMsg: string): Promise<any>;
377
+ /**
378
+ * Sends a message to the server
379
+ * @param {string} message - textual string
380
+ * @param {string} [pathname] - a server path to send the message to
381
+ * @returns {Promise} A promise that returns the call response object, or an Error if rejected.
382
+ */
383
+ message(message: string, pathname?: string): Promise<any>;
384
+ /**
385
+ * Sends an action to the server
386
+ * @param {string} actionName - structure of the action
387
+ * @param {object} [payload] - a request body call
388
+ * @returns {Promise} A promise that returns the call response object, or an Error if rejected.
389
+ */
390
+ action(actionName: string, payload?: object): Promise<any>;
391
+ /**
392
+ * Gets TerminusDB Server Information
393
+ * @returns {Promise} A promise that returns the call response object, or an Error if rejected.
394
+ * @example
395
+ * client.info()
396
+ */
397
+ info(): Promise<any>;
398
+ /**
399
+ * Executes a WOQL query on the specified database and returns the results
400
+ * @param {WOQLQuery} woql - an instance of the WOQLQuery class
401
+ * @param {string} [commitMsg] - a message describing the reason for the change that will
402
+ * be written into the commit log (only relevant if the query contains an update)
403
+ * @param {boolean} [allWitnesses]
404
+ * @param {string} [lastDataVersion] the last data version tracking id.
405
+ * @param {boolean} [getDataVersion] If true the function will return object having result
406
+ * and dataVersion.
407
+ * @param {Array<NamedResourceData>} [resources] csv resources supplied as strings
408
+ * @returns {Promise} A promise that returns the call response object or object having *result*
409
+ * and *dataVersion* object if ***getDataVersion*** parameter is true, or an Error if rejected.
410
+ * @example
411
+ * const result = await client.query(WOQL.star())
412
+ */
413
+ query(woql: WOQLQuery, commitMsg?: string, allWitnesses?: boolean, lastDataVersion?: string, getDataVersion?: boolean, resources?: Array<NamedResourceData>): Promise<any>;
414
+ /**
415
+ * Creates a new branch with a TerminusDB database, starting from the current context of
416
+ * the client (branch / ref)
417
+ * @param {string} newBranchId - local identifier of the new branch the ID of the new branch
418
+ * to be created
419
+ * @param {boolean} [isEmpty] - if isEmpty is true it will create a empty branch.
420
+ * @returns {Promise} A promise that returns the call response object, or an Error if rejected.
421
+ * @example
422
+ * client.branch("dev")
423
+ */
424
+ branch(newBranchId: string, isEmpty?: boolean): Promise<any>;
425
+ /**
426
+ * Squash branch commits
427
+ * @param {string} branchId - local identifier of the new branch
428
+ * @param {string} commitMsg - Textual message describing the reason for the update
429
+ * @returns {Promise} A promise that returns the call response object, or an Error if rejected.
430
+ */
431
+ squashBranch(branchId: string, commitMsg: string): Promise<any>;
432
+ /**
433
+ * Reset branch to a commit id, Reference ID or Commit ID are unique hashes that are
434
+ * created whenever a new commit is recorded
435
+ * @param {string} branchId - local identifier of the new branch
436
+ * @param {string} commitId - Reference ID or Commit ID
437
+ * @returns {Promise} A promise that returns the call response object, or an Error if rejected.
438
+ */
439
+ resetBranch(branchId: string, commitId: string): Promise<any>;
440
+ /**
441
+ * Optimize db branch
442
+ * @param {string} branchId - local identifier of the new branch
443
+ * @returns {Promise} A promise that returns the call response object, or an Error if rejected.
444
+ */
445
+ optimizeBranch(branchId: string): Promise<any>;
446
+ /**
447
+ * Deletes a branch from database
448
+ * @param {string} branchId - local identifier of the branch
449
+ * @returns {Promise} A promise that returns the call response object, or an Error if rejected.
450
+ */
451
+ deleteBranch(branchId: string): Promise<any>;
452
+ /**
453
+ * Pull changes from a branch on a remote database to a branch on a local database
454
+ * @param {typedef.RemoteRepoDetails} remoteSourceRepo - an object describing the source of the pull
455
+ * @returns {Promise} A promise that returns the call response object, or an Error if rejected.
456
+ * @example
457
+ * client.pull({remote: "origin", remote_branch: "main", message: "Pulling from remote"})
458
+ */
459
+ pull(remoteSourceRepo: typedef.RemoteRepoDetails): Promise<any>;
460
+ /**
461
+ * Fetch updates to a remote database to a remote repository with the local database
462
+ * @param {string} remoteId - if of the remote to fetch (eg: 'origin')
463
+ * @returns {Promise} A promise that returns the call response object, or an Error if rejected.
464
+ */
465
+ fetch(remoteId: string): Promise<any>;
466
+ /**
467
+ * Push changes from a branch on a local database to a branch on a remote database
468
+ * @param {typedef.RemoteRepoDetails} remoteTargetRepo - an object describing the target of the push
469
+ * {remote: "origin", "remote_branch": "main", "author": "admin", "message": "message"}
470
+ * @returns {Promise} A promise that returns the call response object, or an Error if rejected.
471
+ * @example
472
+ * client.push({remote: "origin", remote_branch: "main", message: "Pulling from remote"})
473
+ */
474
+ push(remoteTargetRepo: typedef.RemoteRepoDetails): Promise<any>;
475
+ /**
476
+ * Merges the passed branch into the current one using the rebase operation
477
+ * @param {object} rebaseSource - json describing the source branch to be used as a base
478
+ * @returns {Promise} A promise that returns the call response object, or an Error if rejected.
479
+ * @example
480
+ * //from the branch head
481
+ * client.rebase({rebase_from: "admin/db_name/local/branch/branch_name", message:
482
+ * "Merging from dev")
483
+ * //or from a commit id
484
+ * client.rebase({rebase_from: "admin/db_name/local/commit/9w8hk3y6rb8tjdy961de3i536ntkqd8",
485
+ * message: "Merging from dev")
486
+ */
487
+ rebase(rebaseSource: object): Promise<any>;
488
+ /**
489
+ * Reset the current branch HEAD to the specified commit path
490
+ * @param {string} commitPath - The commit path to set the current branch to
491
+ * @returns {Promise} A promise that returns the call response object, or an Error if rejected.
492
+ */
493
+ reset(commitPath: string): Promise<any>;
494
+ /**
495
+ * Creates a new remote connection for the database
496
+ * @param {string} remoteName - The name of the remote to create
497
+ * @param {string} remoteLocation - The URL of the remote repository
498
+ * @returns {Promise} A promise that returns the call response object, or an Error if rejected.
499
+ * @example
500
+ * client.createRemote("origin", "http://remote.server.com/org/db")
501
+ */
502
+ createRemote(remoteName: string, remoteLocation: string): Promise<any>;
503
+ /**
504
+ * Gets information about a remote connection
505
+ * @param {string} remoteName - The name of the remote to retrieve
506
+ * @returns {Promise} A promise that returns the remote details, or an Error if rejected.
507
+ * @example
508
+ * const remote = await client.getRemote("origin")
509
+ */
510
+ getRemote(remoteName: string): Promise<any>;
511
+ /**
512
+ * Updates an existing remote connection
513
+ * @param {string} remoteName - The name of the remote to update
514
+ * @param {string} remoteLocation - The new URL for the remote repository
515
+ * @returns {Promise} A promise that returns the call response object, or an Error if rejected.
516
+ * @example
517
+ * client.updateRemote("origin", "http://new.remote.server.com/org/db")
518
+ */
519
+ updateRemote(remoteName: string, remoteLocation: string): Promise<any>;
520
+ /**
521
+ * Deletes a remote connection
522
+ * @param {string} remoteName - The name of the remote to delete
523
+ * @returns {Promise} A promise that returns the call response object, or an Error if rejected.
524
+ * @example
525
+ * client.deleteRemote("origin")
526
+ */
527
+ deleteRemote(remoteName: string): Promise<any>;
528
+ /**
529
+ * Clones a remote repo and creates a local copy
530
+ * @param {typedef.CloneSourceDetails} cloneSource - object describing the source branch
531
+ * to be used as a base
532
+ * @param {string} newDbId - id of the new cloned database on the local server
533
+ * @param {string} [orgId] - id of the local organization that the new cloned database
534
+ * will be created in (in desktop mode this is always “admin”)
535
+ * @returns {Promise} A promise that returns the call response object, or an Error if rejected.
536
+ * @example
537
+ * client.clonedb({remote_url: "https://my.terminusdb.com/myorg/mydb", label "Cloned DB", comment: "Cloned from mydb"}, newid: "mydb")
538
+ */
539
+ clonedb(cloneSource: typedef.CloneSourceDetails, newDbId: string, orgId?: string): Promise<any>;
540
+ /**
541
+ * Common request dispatch function
542
+ * @property {string} action - the action name
543
+ * @property {string} apiUrl - the server call endpoint
544
+ * @property {object} [payload] - the post body
545
+ * @property {boolean} [getDataVersion] - If true return response with data version
546
+ * @property {boolean} [compress] - If true, compress the data if it is bigger than 1024 bytes
547
+ * @returns {Promise} A promise that returns the call response object, or an Error if rejected.
548
+ */
549
+ dispatch(action: any, apiUrl: any, payload: any, getDataVersion: any, compress?: boolean): Promise<any>;
550
+ /**
551
+ * Generates the json structure for commit messages
552
+ * @param {string} msg - textual string describing reason for the change
553
+ * @param {string} [author] - optional author id string - if absent current user id will be used
554
+ * @returns {object}
555
+ */
556
+ generateCommitInfo(msg: string, author?: string): object;
557
+ /**
558
+ * Generates the json structure for commit descriptor
559
+ * @param {string} commitId - a valid commit id o
560
+ */
561
+ generateCommitDescriptor(commitId: string): {
562
+ commit_descriptor: any;
563
+ };
564
+ /**
565
+ * Adds an author string (from the user object returned by connect) to the commit message.
566
+ * @param {object} [rc_args]
567
+ * @returns {object | boolean}
568
+ */
569
+ prepareRevisionControlArgs(rc_args?: object): object | boolean;
570
+ /**
571
+ * to add a new document or a list of new documents into the instance or the schema graph.
572
+ * @param {object} json
573
+ * @param {typedef.DocParamsPost} [params] - the post parameters {@link #typedef.DocParamsPost}
574
+ * @param {string} [dbId] - the dbid
575
+ * @param {message} [string] - the insert commit message
576
+ * @param {string} [lastDataVersion] the last data version tracking id.
577
+ * @param {boolean} [getDataVersion] If true the function will return object having result
578
+ * and dataVersion.
579
+ * @returns {Promise} A promise that returns the call response object or object having *result*
580
+ * and *dataVersion* object if ***getDataVersion*** parameter is true, or an Error if rejected.
581
+ * @example
582
+ * const json = [{ "@type" : "Class",
583
+ * "@id" : "Coordinate",
584
+ * "@key" : { '@type' : 'Hash',
585
+ * '@fields' : ['x','y'] },
586
+ * "x" : "xsd:decimal",
587
+ * "y" : "xsd:decimal" },
588
+ * { "@type" : "Class",
589
+ * "@id" : "Country",
590
+ * "@key" : { '@type' : 'Lexical',
591
+ * '@fields' : [name] },
592
+ * "name" : "xsd:string",
593
+ * "perimeter" : { "@type" : "List",
594
+ * "@class" : "Coordinate" } }]
595
+ * client.addDocument(json,{"graph_type":"schema"},"mydb","add new schema documents")
596
+ *
597
+ * //if we would like to override the entire schema
598
+ * const json = [
599
+ * {"@base": "terminusdb:///data/",
600
+ * "@schema": "terminusdb:///schema#",
601
+ * "@type": "@context"
602
+ * },
603
+ * {
604
+ * "@id": "Person",
605
+ * "@key": {
606
+ * "@type": "Random"
607
+ * },
608
+ * "@type": "Class",
609
+ * "name": {
610
+ * "@class": "xsd:string",
611
+ * "@type": "Optional"
612
+ * }
613
+ * }]
614
+ *
615
+ * // client.addDocument(json,{"graph_type":"schema","full_replace:true"},
616
+ "mydb","update the all schema");
617
+ *
618
+ * // Here we will pass true to show how to get dataVersion
619
+ *
620
+ * const response = await client.addDocument(json, {"graph_type": "schema"},
621
+ * "mydb",
622
+ * "add new schema", '',
623
+ * true
624
+ * )
625
+ * console.log(response);
626
+ *
627
+ * // This will output:
628
+ * // {
629
+ * // result: [ ...... ],
630
+ * // dataVersion: 'branch:5fs681tlycnn6jh0ceiqcq4qs89pdfs'
631
+ * // }
632
+ *
633
+ * // Now we can use the data version we recieved as a response in previous
634
+ * // function call and used it is next function call as lastDataVersion
635
+ *
636
+ * const response1 = await client.addDocument(json, {"graph_type": "schema"},
637
+ * "mydb",
638
+ * "add new schema", response.dataVersion,
639
+ * )
640
+ */
641
+ addDocument(json: object, params?: typedef.DocParamsPost, dbId?: string, message?: string, lastDataVersion?: string, getDataVersion?: boolean, compress?: boolean): Promise<any>;
642
+ /**
643
+ * Use {@link #getDocument} instead.
644
+ * @deprecated
645
+ *
646
+ * Retrieves all documents that match a given document template
647
+ * @param {object} query - the query template
648
+ * @param {typedef.DocParamsGet} [params] - the get parameters
649
+ * @param {string} [dbId] - the database id
650
+ * @param {string} [branch] - the database branch
651
+ * @param {string} [lastDataVersion] the last data version tracking id.
652
+ * @param {boolean} [getDataVersion] If true the function will return object having result
653
+ * and dataVersion.
654
+ * @returns {Promise} A promise that returns the call response object or object having *result*
655
+ * and *dataVersion* object if ***getDataVersion*** parameter is true, or an Error if rejected.
656
+ * @example
657
+ * const query = {
658
+ * "type": "Person",
659
+ * "query": { "age": 42 },
660
+ * }
661
+ * client.queryDocument(query, {"as_list":true})
662
+ *
663
+ *
664
+ * // Here we will pass true to show how to get dataVersion
665
+ * const query = {
666
+ * "type": "Person",
667
+ * "query": { "age": 42 },
668
+ * }
669
+ *
670
+ * const response = await client.queryDocument(query, {"as_list": true}, '', '','',true);
671
+ * console.log(response);
672
+ *
673
+ * // This will output:
674
+ * // {
675
+ * // result: [
676
+ * // {
677
+ * // '@id': 'Person/052d60ffbd114bf5e7331b03f07fcb7',
678
+ * // '@type': 'Person',
679
+ * // age: 42,
680
+ * // name: 'John',
681
+ * // },
682
+ * // ],
683
+ * // dataVersion: 'branch:5fs681tlycnn6jh0ceiqcq4qs89pdfs'
684
+ * // }
685
+ *
686
+ * // Now we can use the data version we recieved as a response in previous
687
+ * // query and used it is next query as lastDataVersion
688
+ * const query = {
689
+ * "type": "Person",
690
+ * "query": { "age": 18 },
691
+ * }
692
+ *
693
+ * const response1 = await client.queryDocument(query, {"as_list": true}, '',
694
+ * '',
695
+ * response.dataVersion
696
+ * );
697
+ */
698
+ queryDocument(query: object, params?: typedef.DocParamsGet, dbId?: string, branch?: string, lastDataVersion?: string, getDataVersion?: boolean): Promise<any>;
699
+ /**
700
+ *
701
+ * @param {typedef.DocParamsGet} [params] - the get parameters,
702
+ * you can pass document query search template with the params
703
+ * @param {string} [dbId] - the database id
704
+ * @param {string} [branch] - the database branch
705
+ * @param {string} [lastDataVersion] the last data version tracking id.
706
+ * @param {boolean} [getDataVersion] If true the function will return object having result
707
+ * and dataVersion.
708
+ * @param {object} [query] document query search template
709
+ * @returns {Promise} A promise that returns the call response object or object having *result*
710
+ * and *dataVersion* object if ***getDataVersion*** parameter is true, or an Error if rejected.
711
+ * @example
712
+ * //return the schema graph as a json array
713
+ * client.getDocument({"graph_type":"schema","as_list":true}).then(result={
714
+ * console.log(result)
715
+ * })
716
+ *
717
+ * //retutn the Country class document from the schema graph
718
+ * client.getDocument({"graph_type":"schema","as_list":true,"id":"Country"}).then(result={
719
+ * console.log(result)
720
+ * })
721
+ *
722
+ * //pass a document query template to query the document interface
723
+ * const queryTemplate = { "name": "Ireland"}
724
+ * client.getDocument({"as_list":true, "@type":"Country"
725
+ * query:queryTemplate}).then(result=>{
726
+ * console.log(result)
727
+ * })
728
+ *
729
+ *
730
+ * // Here we will pass true to show how to get dataVersion
731
+ * const response = await client.getDocument({"graph_type":"schema","as_list":true},
732
+ * "",
733
+ * "",
734
+ * "",
735
+ * true
736
+ * )
737
+ * console.log(response);
738
+ *
739
+ * // This will output:
740
+ * // {
741
+ * // result: [ ...... ],
742
+ * // dataVersion: 'branch:5fs681tlycnn6jh0ceiqcq4qs89pdfs'
743
+ * // }
744
+ *
745
+ * // Now we can use the data version we recieved as a response in previous
746
+ * // function call and used it is next function call as lastDataVersion
747
+ *
748
+ * const response1 = await client.getDocument({"graph_type":"schema","as_list":true},
749
+ * "",
750
+ * "",
751
+ * response.dataVersion,
752
+ * )
753
+ */
754
+ getDocument(params?: typedef.DocParamsGet, dbId?: string, branch?: string, lastDataVersion?: string, getDataVersion?: boolean, query?: object): Promise<any>;
755
+ /**
756
+ *
757
+ * @param {object} json
758
+ * @param {typedef.DocParamsPut} [params] - the Put parameters {@link #typedef.DocParamsPut}
759
+ * @param {*} [dbId] - the database id
760
+ * @param {*} [message] - the update commit message
761
+ * @param {string} [lastDataVersion] the last data version tracking id.
762
+ * @param {boolean} [getDataVersion] If true the function will return object having result
763
+ * and dataVersion.
764
+ * @param {boolean} [compress] If true, the function will create a new document if it doesn't exist.
765
+ * @param {boolean} [create] Perform an *upsert* which inserts if the document
766
+ * is not present (also works on nested documents)
767
+ * @returns {Promise} A promise that returns the call response object or object having *result*
768
+ * and *dataVersion* object if ***getDataVersion*** parameter is true, or an Error if rejected.
769
+ * @example
770
+ * client.updateDocument(
771
+ * {
772
+ * "@id": "Person",
773
+ * "@key": {
774
+ * "@type": "Random",
775
+ * },
776
+ * "@type": "Class",
777
+ * label: "xsd:string",
778
+ * },
779
+ * { graph_type: "schema" }
780
+ * );
781
+ *
782
+ *
783
+ * // Here we will pass true to show how to get dataVersion
784
+ *
785
+ const response = await client.updateDocument(
786
+ {
787
+ "@id": "Person",
788
+ "@key": {
789
+ "@type": "Random",
790
+ },
791
+ "@type": "Class",
792
+ label: "xsd:string",
793
+ },
794
+ { graph_type: "schema" },
795
+ "",
796
+ "",
797
+ "",
798
+ true
799
+ );
800
+ * console.log(response);
801
+ *
802
+ * // This will output:
803
+ * // {
804
+ * // result: [ ...... ],
805
+ * // dataVersion: 'branch:5fs681tlycnn6jh0ceiqcq4qs89pdfs'
806
+ * // }
807
+ *
808
+ * // Now we can use the data version we recieved as a response in previous
809
+ * // function call and used it is next function call as lastDataVersion
810
+ *
811
+ * const response1 = await client.updateDocument(
812
+ {
813
+ "@id": "Person",
814
+ "@key": {
815
+ "@type": "Random",
816
+ },
817
+ "@type": "Class",
818
+ label: "xsd:string",
819
+ },
820
+ { graph_type: "schema" },
821
+ "",
822
+ "",
823
+ response.dataVersion
824
+ );
825
+ *
826
+ * // update a document and create the linked document together
827
+ * // we are update the document "Person/Person01"
828
+ * // and create a new document {"@type": "Person","name": "child01"} at the same time
829
+ * const response1 = await client.updateDocument(
830
+ {
831
+ "@id": "Person/Person01",
832
+ "@type": "Person",
833
+ "name": "Person01"
834
+ "children":[{"@type": "Person","name": "child01"}]
835
+ },{create:true})
836
+ */
837
+ updateDocument(json: object, params?: typedef.DocParamsPut, dbId?: any, message?: any, lastDataVersion?: string, getDataVersion?: boolean, compress?: boolean, create?: boolean): Promise<any>;
838
+ /**
839
+ * to delete the document
840
+ * @param {typedef.DocParamsDelete} [params]
841
+ * @param {string} [dbId] - the database id
842
+ * @param {string} [message] - the delete message
843
+ * @param {string} [lastDataVersion] the last data version tracking id.
844
+ * @param {boolean} [getDataVersion] If true the function will return object having result
845
+ * and dataVersion.
846
+ * @returns {Promise} A promise that returns the call response object or object having *result*
847
+ * and *dataVersion* object if ***getDataVersion*** parameter is true, or an Error if rejected.
848
+ * @example
849
+ * client.deleteDocument({"graph_type":"schema",id:['Country','Coordinate']})
850
+ *
851
+ *
852
+ * // Here we will pass true to show how to get dataVersion
853
+ *
854
+ * const response = await client.deleteDocument({"graph_type":"schema",id:['Country','Coordinate']},
855
+ * "",
856
+ * "",
857
+ * "",
858
+ * true
859
+ * )
860
+ * console.log(response);
861
+ *
862
+ * // This will output:
863
+ * // {
864
+ * // result: [ ...... ],
865
+ * // dataVersion: 'branch:5fs681tlycnn6jh0ceiqcq4qs89pdfs'
866
+ * // }
867
+ *
868
+ * // Now we can use the data version we recieved as a response in previous
869
+ * // function call and used it is next function call as lastDataVersion
870
+ *
871
+ * const response1 = await client.deleteDocument({"graph_type":"schema",
872
+ * id:['Country','Coordinate']},
873
+ * "",
874
+ * "",
875
+ * response.dataVersion,
876
+ * )
877
+ */
878
+ deleteDocument(params?: typedef.DocParamsDelete, dbId?: string, message?: string, lastDataVersion?: string, getDataVersion?: boolean): Promise<any>;
879
+ /**
880
+ * The purpose of this method is to quickly discover the supported fields of a particular type.
881
+ * @param {string} [type] - If given, the type to get information for. If omitted, information
882
+ * for all types is returned
883
+ * @param {string} [dbId] - the database id
884
+ * @returns {Promise} A promise that returns the call response object, or an Error if rejected.
885
+ * @example
886
+ * client.getSchemaFrame("Country")
887
+ */
888
+ getSchemaFrame(type?: string, dbId?: string): Promise<any>;
889
+ /**
890
+ * get the database schema in json format
891
+ * @param {string} [dbId] - the database id
892
+ * @param {string} [branch] - specific a branch/collection
893
+ * @returns {Promise} A promise that returns the call response object, or an Error if rejected.
894
+ * @example
895
+ * client.getSchema()
896
+ */
897
+ getSchema(dbId?: string, branch?: string): Promise<any>;
898
+ /**
899
+ * get all the schema classes (documents,subdocuments,abstracts)
900
+ * @param {string} [dbId] - the database id
901
+ * @returns {Promise} A promise that returns the call response object, or an Error if rejected.
902
+ * @example
903
+ * client.getClasses()
904
+ */
905
+ getClasses(dbId?: string): Promise<any>;
906
+ /**
907
+ * get all the Enum Objects
908
+ * @param {string} [dbId]
909
+ * @returns {Promise} A promise that returns the call response object, or an Error if rejected.
910
+ * @example
911
+ * client.getEnums()
912
+ */
913
+ getEnums(dbId?: string): Promise<any>;
914
+ /**
915
+ * get all the Document Classes (no abstract or subdocument)
916
+ * @param {string} [dbId]
917
+ * @returns {Promise} A promise that returns the call response object, or an Error if rejected.
918
+ * @example
919
+ * client.getClassDocuments()
920
+ */
921
+ getClassDocuments(dbId?: string): Promise<any>;
922
+ /**
923
+ * get the database collections list
924
+ * @param {string} [dbId] - the database id
925
+ * @returns {Promise} A promise that returns the call response object, or an Error if rejected.
926
+ * @example
927
+ * client.getBranches()
928
+ */
929
+ getBranches(dbId?: string): Promise<any>;
930
+ /**
931
+ * get the database collections list
932
+ * @param {number} [start=0] - where to start printing the commit
933
+ * information in the log (starting from the head of the current branch)
934
+ * @param {number} [count=1] - The number of total commit log records to return
935
+ * @returns {Promise} A promise that returns the call response object, or an Error if rejected.
936
+ * @example
937
+ * client.getCommitsLog(count=10)
938
+ */
939
+ getCommitsLog(start?: number, count?: number): Promise<any>;
940
+ /**
941
+ * get the database prefixes object
942
+ * @param {string} [dbId] - the database id
943
+ * @returns {Promise} A promise that returns the call response object, or an Error if rejected.
944
+ * @example
945
+ * client.getPrefixes()
946
+ * //return object example
947
+ * {
948
+ * '@base': 'terminusdb:///data/',
949
+ * '@schema': 'terminusdb:///schema#',
950
+ * '@type': 'Context'}
951
+ */
952
+ getPrefixes(dbId?: string): Promise<any>;
953
+ /**
954
+ * Get the list of the user's organizations and the database related
955
+ * @returns {Promise} A promise that returns the call response object, or an Error if rejected.
956
+ * @example
957
+ * async funtion callGetUserOrganizations(){
958
+ * await getUserOrganizations()
959
+ * console.log(client.userOrganizations())
960
+ * }
961
+ */
962
+ getUserOrganizations(): Promise<any>;
963
+ /**
964
+ * Get/Set the list of the user's organizations (id, organization, label, comment).
965
+ * @param {array} [orgList] a list of user's Organization
966
+ * @returns {array} the user Organizations list
967
+ * @example
968
+ * async funtion callGetUserOrganizations(){
969
+ * await client.getUserOrganizations()
970
+ * console.log(client.userOrganizations())
971
+ * }
972
+ */
973
+ userOrganizations(orgList?: any[]): any[];
974
+ /**
975
+ * Apply a patch object to another object
976
+ * @param {object} before - The current state of JSON document
977
+ * @param {object} patch - The patch object
978
+ * @returns {Promise} A promise that returns the call response object, or an Error if rejected.
979
+ * @example
980
+ * client.patch(
981
+ * { "@id" : "Person/Jane", "@type" : "Person", "name" : "Jane"},
982
+ * { "name" : { "@op" : "ValueSwap", "@before" : "Jane", "@after": "Janine" }}
983
+ * ).then(patchResult=>{
984
+ * console.log(patchResult)
985
+ * })
986
+ * //result example
987
+ * //{ "@id" : "Person/Jane", "@type" : "Person", "name" : "Jannet"}
988
+ */
989
+ patch(before: object, patch: object): Promise<any>;
990
+ /**
991
+ * Apply a patch object to the current resource
992
+ * @param {array} patch - The patch object
993
+ * @param {string} message - The commit message
994
+ * @returns {Promise} A promise that returns the call response object, or an Error if rejected.
995
+ * @example
996
+ * const patch = [
997
+ * {
998
+ * "@id": "Obj/id1",
999
+ * "name": {
1000
+ * "@op": "SwapValue",
1001
+ * "@before": "foo",
1002
+ * "@after": "bar"
1003
+ * }
1004
+ * },
1005
+ * {
1006
+ * "@id": "Obj/id2",
1007
+ * "name": {
1008
+ * "@op": "SwapValue",
1009
+ * "@before": "foo",
1010
+ * "@after": "bar"
1011
+ * }
1012
+ * }
1013
+ * ]
1014
+ * client.db("mydb")
1015
+ * client.checkout("mybranch")
1016
+ * client.patchResource(patch,"apply patch to mybranch").then(patchResult=>{
1017
+ * console.log(patchResult)
1018
+ * })
1019
+ * // result example
1020
+ * // ["Obj/id1",
1021
+ * // "Obj/id2"]
1022
+ * // or conflict error 409
1023
+ * // {
1024
+ * // "@type": "api:PatchError",
1025
+ * // "api:status": "api:conflict",
1026
+ * // "api:witnesses": [
1027
+ * // {
1028
+ * // "@op": "InsertConflict",
1029
+ * // "@id_already_exists": "Person/Jane"
1030
+ * // }
1031
+ * //]
1032
+ * //}
1033
+ */
1034
+ patchResource(patch: any[], message: string): Promise<any>;
1035
+ /**
1036
+ * Get the patch of difference between two documents.
1037
+ * @param {object} before - The current state of JSON document
1038
+ * @param {object} after - The updated state of JSON document
1039
+ * @param {object} [options] - {keep:{}} Options to send to the diff endpoint.
1040
+ * The diff api outputs the changes between the input,
1041
+ * in options you can list the properties that you would like to see in the diff result in any case.
1042
+ * @returns {Promise} A promise that returns the call response object, or an Error if rejected.
1043
+ * @example
1044
+ * client.getJSONDiff(
1045
+ * { "@id": "Person/Jane", "@type": "Person", name: "Jane" },
1046
+ * { "@id": "Person/Jane", "@type": "Person", name: "Janine" }
1047
+ * ).then(diffResult=>{
1048
+ * console.log(diffResult)
1049
+ * })
1050
+ * //result example
1051
+ * //{'@id': 'Person/Jane',
1052
+ * // name: { '@after': 'Janine', '@before': 'Jane', '@op': 'SwapValue' }}
1053
+ */
1054
+ getJSONDiff(before: object, after: object, options?: object): Promise<any>;
1055
+ /**
1056
+ * Get the patch of difference between two documents.
1057
+ * @param {string} dataVersion - The version from which to compare the object
1058
+ * @param {object} jsonObject - The updated state of JSON document
1059
+ * @param {string} id - The document id to be diffed
1060
+ * @param {object} [options] - {keep:{}} Options to send to the diff endpoint
1061
+ * the diff api outputs the changes between the input,
1062
+ * but you can list the properties that you would like to see in the diff result in any case.
1063
+ * @returns {Promise} A promise that returns the call response object, or an Error if rejected.
1064
+ * @example
1065
+ * const jsonObj = { "@id": "Person/Jane", "@type": "Person", name: "Janine" }
1066
+ * client.getVersionObjectDiff("main",jsonObj
1067
+ * "Person/Jane").then(diffResp=>{
1068
+ * console.log(diffResp)
1069
+ * })
1070
+ */
1071
+ getVersionObjectDiff(dataVersion: string, jsonObject: object, id: string, options?: object): Promise<any>;
1072
+ /**
1073
+ * Get the patch of difference between branches or commits.
1074
+ * @param {string} beforeVersion - Before branch/commit to compare
1075
+ * @param {string} afterVersion - After branch/commit to compare
1076
+ * @param {string} [id] - The document id to be diffed,
1077
+ * if it is omitted all the documents will be compared
1078
+ * @param {typedef.DiffObject} [options] - {keep:{},count:10,start:0}
1079
+ * Options to send to the diff endpoint.
1080
+ * The diff api outputs the changes between the input (branches or commits),
1081
+ * in options you can list the properties that you would like to see in the diff result in any case.
1082
+ * @returns {Promise} A promise that returns the call response object, or an Error if rejected.
1083
+ * @example
1084
+ * //This is to view all the changes between two commits
1085
+ * const beforeCommit = "a73ssscfx0kke7z76083cgswszdxy6l"
1086
+ * const afterCommit = "73rqpooz65kbsheuno5dsayh71x7wf4"
1087
+ *
1088
+ * client.getVersionDiff( beforeCommit, afterCommit).then(diffResult=>{
1089
+ * console.log(diffResult)
1090
+ * })
1091
+ *
1092
+ * //This is to view the changes between two commits but only for the given document
1093
+ * client.getVersionDiff( beforeCommit, afterCommit, "Person/Tom").then(diffResult=>{
1094
+ * console.log(diffResult)
1095
+ * })
1096
+ *
1097
+ * //This is to view the changes between a branch (head) and a commit for the given document
1098
+ * client.getVersionDiff("main", afterCommit, "Person/Tom" ).then(diffResult=>{
1099
+ * console.log(diffResult)
1100
+ * })
1101
+ *
1102
+ * //This is to view the changes between two branches with the keep options
1103
+ * const options = {"keep":{"@id":true, "name": true}, start:0, count:10}
1104
+ * client.getVersionDiff("main","mybranch",options).then(diffResult=>{
1105
+ * console.log(diffResult)
1106
+ * })
1107
+ */
1108
+ getVersionDiff(beforeVersion: string, afterVersion: string, id?: string, options?: typedef.DiffObject): Promise<any>;
1109
+ /**
1110
+ * Diff two different commits and apply changes on the current branch/commit.
1111
+ * If you would like to change branch or commit before apply use client.checkout("branchName")
1112
+ * @param {string} beforeVersion - Before branch/commit to compare
1113
+ * @param {string} afterVersion - After branch/commit to compare
1114
+ * @param {string} message - apply commit message
1115
+ * @param {boolean} [matchFinalState] - the default value is false
1116
+ * @param {object} [options] - {keep:{}} Options to send to the apply endpoint
1117
+ * @example
1118
+ * client.checkout("mybranch")
1119
+ * client.apply("mybranch","mybranch_new","merge main").then(result=>{
1120
+ * console.log(result)
1121
+ * })
1122
+ */
1123
+ apply(beforeVersion: string, afterVersion: string, message: string, matchFinalState?: boolean, options?: object): Promise<any>;
1124
+ /**
1125
+ * Get the document's history for a specific database or branch
1126
+ * @param {string} id - id of document to report history of
1127
+ * @param {typedef.DocHistoryParams} [historyParams]
1128
+ * @example
1129
+ * //this will return the last 5 commits for the Person/Anna document
1130
+ * client.checkout("mybranch")
1131
+ * client.docHistory("Person/Anna",{start:0,count:5}).then(result=>{
1132
+ * console.log(result)
1133
+ * })
1134
+ * //this will return the last and the first commit for the Person/Anna document
1135
+ * client.docHistory("Person/Anna",{updated:true,created:true}).then(result=>{
1136
+ * console.log(result)
1137
+ * })
1138
+ */
1139
+ getDocumentHistory(id: string, historyParams?: typedef.DocHistoryParams): Promise<any>;
1140
+ /**
1141
+ * Call a custom Api endpoit
1142
+ * @param {string} requestType - The current state of JSON document
1143
+ * @param {string} customRequestURL - The patch object
1144
+ * @param {object} [payload] - the request payload
1145
+ * @returns {Promise} A promise that returns the call response object, or an Error if rejected.
1146
+ * @example
1147
+ * client.sendCustomRequest("GET", "http://localhost:3030/changes/").then(result=>{
1148
+ * console.log(result)
1149
+ * })
1150
+ */
1151
+ sendCustomRequest(requestType: string, customRequestURL: string, payload?: object): Promise<any>;
1152
+ /**
1153
+ * Get a single prefix mapping
1154
+ * @param {string} prefixName - The prefix name (e.g., 'ex', 'schema')
1155
+ * @param {string} [dbId] - The database id
1156
+ * @returns {Promise<string>} A promise that returns the prefix IRI, or an Error if rejected.
1157
+ * @example
1158
+ * client.getPrefix("schema").then(uri => {
1159
+ * console.log(uri) // "http://schema.org/"
1160
+ * })
1161
+ */
1162
+ getPrefix(prefixName: string, dbId?: string): Promise<string>;
1163
+ /**
1164
+ * Add a new prefix mapping
1165
+ * @param {string} prefixName - The prefix name to create
1166
+ * @param {string} uri - The IRI (namespace URL) this prefix expands to
1167
+ * @param {string} [dbId] - The database id
1168
+ * @returns {Promise} A promise that returns the call response object, or an Error if rejected.
1169
+ * @example
1170
+ * client.addPrefix("ex", "http://example.org/").then(result => {
1171
+ * console.log("Prefix added successfully")
1172
+ * })
1173
+ */
1174
+ addPrefix(prefixName: string, uri: string, dbId?: string): Promise<any>;
1175
+ /**
1176
+ * Update an existing prefix mapping
1177
+ * @param {string} prefixName - The prefix name to update
1178
+ * @param {string} uri - The new IRI for this prefix
1179
+ * @param {string} [dbId] - The database id
1180
+ * @returns {Promise} A promise that returns the call response object, or an Error if rejected.
1181
+ * @example
1182
+ * client.updatePrefix("ex", "http://example.com/").then(result => {
1183
+ * console.log("Prefix updated successfully")
1184
+ * })
1185
+ */
1186
+ updatePrefix(prefixName: string, uri: string, dbId?: string): Promise<any>;
1187
+ /**
1188
+ * Create or update a prefix mapping (upsert)
1189
+ * @param {string} prefixName - The prefix name
1190
+ * @param {string} uri - The IRI for this prefix
1191
+ * @param {string} [dbId] - The database id
1192
+ * @returns {Promise} A promise that returns the call response object, or an Error if rejected.
1193
+ * @example
1194
+ * client.upsertPrefix("ex", "http://example.org/").then(result => {
1195
+ * console.log("Prefix created or updated successfully")
1196
+ * })
1197
+ */
1198
+ upsertPrefix(prefixName: string, uri: string, dbId?: string): Promise<any>;
1199
+ /**
1200
+ * Delete a prefix mapping
1201
+ * @param {string} prefixName - The prefix name to delete
1202
+ * @param {string} [dbId] - The database id
1203
+ * @returns {Promise} A promise that returns the call response object, or an Error if rejected.
1204
+ * @example
1205
+ * client.deletePrefix("ex").then(result => {
1206
+ * console.log("Prefix deleted successfully")
1207
+ * })
1208
+ */
1209
+ deletePrefix(prefixName: string, dbId?: string): Promise<any>;
1210
+ }
1211
+ declare namespace WOQLClient {
1212
+ export { NamedResourceData };
1213
+ }
1214
+ import typedef = require("./typedef");
1215
+ import WOQLQuery = require("./query/woqlCore");
1216
+ type NamedResourceData = any;