-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathindex.d.ts
More file actions
1416 lines (1256 loc) · 63.2 KB
/
index.d.ts
File metadata and controls
1416 lines (1256 loc) · 63.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// TypeScript Version: 2.1
/** stardog.js: The Stardog JS API*/
import {
Headers,
Request,
RequestInit
} from 'node-fetch';
declare namespace Stardog {
namespace HTTP {
export type RdfMimeType = 'application/ld+json'
| 'text/turtle'
| 'application/rdf+xml'
| 'application/n-triples'
| 'application/n-quads'
| 'application/trig';
export type SparqlMimeType = 'application/sparql-results+json'
| 'application/sparql-results+xml';
export type AcceptMimeType = RdfMimeType
| SparqlMimeType
| 'text/plain'
| 'text/boolean'
| 'application/json'
| '*/*';
export type ExplainAcceptMimeType = 'text/plain'
| 'application/json';
export interface Body {
status: number;
statusText: string;
result: object | string | boolean | null;
ok: boolean;
headers: Headers;
body: any;
}
}
interface ConnectionOptions {
endpoint: string;
username: string;
password?: string;
token?: string;
meta?: ConnectionMeta;
}
// Kind of a hack, but necessary to get around the way TS libs define the `Request` object.
type RequestConstructor = {
new (input: string | Request, init?: RequestInit): Request;
};
type RequestCreator<Constructor, ReturnType> = ({ uri, Request }: { uri: string; Request: Constructor }) => ReturnType;
/** Optional meta-configuration for a Connection */
interface ConnectionMeta {
/**
* Sometimes you might need to override stardog.js's default `fetch`
* behavior, which, among other things, disallows fetching via HTTPS
* from servers with self-signed certificates in Node. Defininig this
* method allows you to provide a custom Request (or URI) to stardog.js
* whenever a fetch call is about to occur using your Connection object
* (e.g., you can provide a Request object with an HTTPS agent that
* allows self-signed certificates). The defined method will be called
* with an object containing both the full URI that is about to be
* fetched and a constructor for Request objects (as a convenience,
* since the Request constructor will differ depending on whether the
* environment is browser-like or Node-like). You can use this URI and
* constructor to construct and return the thing that you would like
* stardog.js to pass as the first argument to the corresponding
* `fetch` call (either a string URI or a Request object). For example,
* you could return a Request object that is initialized with the
* same URI passed from stardog.js, but that has a custom `agent`
* attached:
*
* ```
* {
* createRequest: ({ uri, Request }) => new Request(uri, {
* agent: new http.Agent(. . .),
* }),
* }
* ```
*
* @param {Object} requestData
* @param {string} requestData.uri the full URI about to be fetched; includes all URI parts (protocol, hostname, path, query string, etc.)
* @param {RequestConstructor} requestData.Request a request constructor, conforming either to the browser's Request spec or to `node-fetch`'s Request, depending on environment
* @returns {string | Request} a string URI or a Request object
*/
createRequest?: RequestCreator<RequestConstructor, string | Request>;
/**
* Pass this method on `ConnectionMeta` if you need to override or add
* headers for a connection. The method will receive an object with the
* default stardog.js connection headers.
*/
createHeaders?: (defaults: { headers: Headers; }) => Headers;
}
/** Current version of stardog.js. Maps to package.json */
export const version: string;
/** Describes the connection to a running Stardog server. */
export class Connection {
constructor(options: ConnectionOptions, meta?: ConnectionMeta);
config(options: ConnectionOptions, meta?: ConnectionMeta): void;
headers(): Headers;
uri(...resource: string[]): string;
}
/** Stardog HTTP server actions. */
export namespace server {
/** Shuts down a Stardog server. */
function shutdown(conn: Connection, params?: object): Promise<HTTP.Body>;
/**
* Retrieves general status information about a Stardog server. By
* default, also includes status information about all databases on
* that server. If `params.databases` is `false`, however, then the
* information about databases is omitted.
*/
function status(conn: Connection, params?: { databases?: boolean; }): Promise<HTTP.Body>;
}
/** Stardog database actions. */
export namespace db {
/**
* Creates a new database.
*
* @param {Connection} conn the Stardog server connection
* @param {string} database the name of the database to create
* @param {object} databaseOptions an object specifying the various metadata options for this database. See: https://github.com/stardog-union/stardog.js/blob/master/lib/db/dbopts.js
* @param {object} options an object specifying a list of RDF files to bulk load into the database at creation time
* @param {object} params additional parameters if needed
*/
function create(conn: Connection, database: string, databaseOptions?: object, options?: { files: { filename: string}[] }, params?: object): Promise<HTTP.Body>;
/**
* Deletes a database.
*
* @param {Connection} conn the Stardog server connection
* @param {string} database the name of the database to delete
* @param {object} params additional parameters if needed
*/
function drop(conn: Connection, database: string, params?: object): Promise<HTTP.Body>;
/**
* Gets an RDF representation of a database. See: https://www.w3.org/TR/sparql11-http-rdf-update/#http-get
*
* @param {Connection} conn the Stardog server connection
* @param {string} database the name of the database
* @param {object} params additional parameters if needed
*/
function get(conn: Connection, database: string, params?: object): Promise<HTTP.Body>;
/**
* Sets a database offline.
*
* @param {Connection} conn the Stardog server connection
* @param {string} database the name of the database to offline
* @param {object} params additional parameters if needed
*/
function offline(conn: Connection, database: string, params?: object): Promise<HTTP.Body>;
/**
* Sets a database online.
*
* @param {Connection} conn the Stardog server connection
* @param {string} database the name of the database to online
* @param {object} params additional parameters if needed
*/
function online(conn: Connection, database: string, params?: object): Promise<HTTP.Body>;
/**
* Optimizes a database.
*
* @param {Connection} conn the Stardog server connection
* @param {string} database the name of the database to optimize
* @param {object} params additional parameters if needed
*/
function optimize(conn: Connection, database: string, params?: object): Promise<HTTP.Body>;
/**
* Gets a list of all databases on a Stardog server.
*
* @param {Connection} conn the Stardog server connection
* @param {object} params additional parameters if needed
*/
function list(conn: Connection, params?: object): Promise<HTTP.Body>;
/**
* Gets number of triples in a database.
*
* @param {Connection} conn the Stardog server connection
* @param {string} database the name of the database
* @param {object} params additional parameters if needed
*/
function size(conn: Connection, database: string, params?: object): Promise<HTTP.Body>;
/**
* Gets the model for a database.
*
* @param {Connection} conn the Stardog server connection
* @param {string} database the name of the database
* @param {object} options additional options if needed
* @param {object} params additional parameters if needed
*/
function model(conn: Connection, database: string, options?: object, params?: object): Promise<HTTP.Body>;
/**
* Clears the contents of a database.
*
* @param {Connection} conn the Stardog server connection
* @param {string} database the name of the database to clear
* @param {object} params additional parameters if needed
*/
function clear(conn: Connection, database: string, transactionId: string, params?: object): Promise<HTTP.Body>;
/**
* Adds data within a transaction.
*
* @param {Connection} conn the Stardog server connection
* @param {string} database the name of the database to which to add data
* @param {string} transactionId the UUID of the transaction as returned by db.transaction.begin
* @param {string} content a block of RDF data to add
* @param {object} options an object specifying the contentType of the RDF data (e.g., text/turtle)
* @param {object} params additional parameters if needed
*/
function add(conn: Connection, database: string, transactionId: string, content: string, options: transaction.TransactionOptions, params?: object): Promise<transaction.TransactionResponse>;
/**
* Removes data within a transaction.
*
* @param {Connection} conn the Stardog server connection
* @param {string} database the name of the database from which to remove data
* @param {string} transactionId the UUID of the transaction as returned by db.transaction.begin
* @param {string} content a block of RDF data to remove
* @param {object} options an object specifying the contentType of the RDF data. Default: text/turtle
* @param {object} params additional parameters if needed
*/
function remove(conn: Connection, database: string, transactionId: string, content: string, options: transaction.TransactionOptions, params?: object): Promise<transaction.TransactionResponse>;
/**
* Exports the contents of a database.
*
* @param {Connection} conn the Stardog server connection
* @param {string} database the name of the database to clear
* @param {object} options an object specifying the desired HTTP MIME type. Default: application/ld+json
* @param {object} params an object specifying the URI of a named graph to export. Default: ALL
*/
function exportData(conn: Connection, database: string, options?: { mimetype: HTTP.RdfMimeType }, params?: { graphUri: string }): Promise<HTTP.Body>;
/** Database options. */
namespace options {
/** Gets all available database options with their default values. */
function getAvailable(conn: Connection): Promise<HTTP.Body>;
/** Gets set of options on a database. */
function get(conn: Connection, database: string, params?: object): Promise<HTTP.Body>;
/** Gets all options on a database. */
function getAll(conn: Connection, database: string): Promise<HTTP.Body>;
/** Sets options on a database. */
function set(conn: Connection, database: string, databaseOptions: object, params?: object): Promise<HTTP.Body>;
}
/** Wrapper methods for using the SPARQL Graph Store Protocol. See https://www.w3.org/TR/sparql11-http-rdf-update */
namespace graph {
/**
* Retrieves the specified named graph
*
* @param {Connection} conn the Stardog server connection
* @param {string} database the name of the database
* @param {string} graphUri the URI of the graph to retrieve, or null for the default graph
* @param {HTTP.RdfMimeType} accept The desired HTTP MIME type. Default: application/ld+json
* @param {object} params additional parameters if needed
*/
function doGet(conn: Connection, database: string, graphUri?: string, accept?: HTTP.RdfMimeType, params?: object): Promise<HTTP.Body>;
/**
* Stores the given RDF data in the specified named graph
*
* @param {Connection} conn the Stardog server connection
* @param {string} database the name of the database
* @param {string} graphData the RDF data to be stored
* @param {string} graphUri the URI of the graph to retrieve, or null for the default graph
* @param {HTTP.RdfMimeType} contentType The HTTP MIME type of graphData. Default: application/ld+json
* @param {object} params additional parameters if needed
*/
function doPut(conn: Connection, database: string, graphData: string, graphUri?: string, contentType?: HTTP.RdfMimeType, params?: object): Promise<HTTP.Body>;
/**
* Deletes the specified named graph
*
* @param {Connection} conn the Stardog server connection
* @param {string} database the name of the database
* @param {string} graphUri the URI of the graph to retrieve, or null for the default graph
* @param {object} params additional parameters if needed
*/
function doDelete(conn: Connection, database: string, graphUri?: string, params?: object): Promise<HTTP.Body>;
/**
* Merges the given RDF data into the specified named graph
*
* @param {Connection} conn the Stardog server connection
* @param {string} database the name of the database
* @param {string} graphData the RDF data to be stored
* @param {string} graphUri the URI of the graph to retrieve, or null for the default graph
* @param {HTTP.RdfMimeType} contentType The HTTP MIME type of graphData. Default: application/ld+json
* @param {object} params additional parameters if needed
*/
function doPost(conn: Connection, database: string, graphUri?: string, options?: { contentType: HTTP.RdfMimeType }, params?: object): Promise<HTTP.Body>;
}
/** Methods for managing transactions in a database. */
namespace transaction {
type Encodings =
'gzip' |
'compress' |
'deflate' |
'identity' |
'br';
interface TransactionResponse extends HTTP.Body {
transactionId: string
}
interface TransactionOptions {
contentType: HTTP.RdfMimeType,
encoding: Encodings
}
/**
* Begins a new transaction.
*
* @param {Connection} conn the Stardog server connection
* @param {string} database the name of the database on which to open the transaction
* @param {object} params additional parameters if needed
*/
function begin(conn: Connection, database: string, params?: object): Promise<TransactionResponse>;
/**
* Rolls back a transaction, removing the transaction and undoing all changes
*
* @param {Connection} conn the Stardog server connection
* @param {string} database the name of the database
* @param {string} transactionId the UUID of the transaction to roll back as returned by db.transaction.begin
* @param {object} params additional parameters if needed
*/
function rollback(conn: Connection, database: string, transactionId: string, params?: object): Promise<TransactionResponse>;
/**
* Commits a transaction to the database, removing the transaction and making its changes permanent.
*
* @param {Connection} conn the Stardog server connection
* @param {string} database the name of the database
* @param {string} transactionId the UUID of the transaction to commit as returned by db.transaction.begin
* @param {object} params additional parameters if needed
*/
function commit(conn: Connection, database: string, transactionId: string, params?: object): Promise<TransactionResponse>;
}
/** Methods for managing integrity constraints in a database. */
namespace icv {
/**
* Gets the set of integrity constraints on a given database.
*
* @param {Connection} conn the Stardog server connection
* @param {string} database the name of the database
* @param {object} params additional parameters if needed
*/
function get(conn: Connection, database: string, params?: object): Promise<HTTP.Body>;
/**
* Checks constraints to see if they are valid
*
* @param {Connection} conn the Stardog server connection
* @param {string} database the name of the database
* @param {string} constraints an RDF block containing the constraints to be validated
* @param {object} options an object specifying the contentType of the constraints parameter. Default: text/turtle
* @param {object} params additional parameters if needed
*/
function validate(conn: Connection, database: string, constraints: string, options: { contentType: HTTP.RdfMimeType }, params?: { graphUri: string }): Promise<HTTP.Body>;
/**
* Checks constraints to see if they are valid within a transaction
*
* @param {Connection} conn the Stardog server connection
* @param {string} database the name of the database
* @param {string} transactionId the UUID of the transaction as returned by db.transaction.begin
* @param {string} constraints an RDF block containing the constraints to be validated
* @param {object} options an object specifying the contentType of the constraints parameter. Default: text/turtle
* @param {object} params additional parameters if needed
*/
function validateInTx(conn: Connection, database: string, transactionId: string, constraints: string, options: { contentType: HTTP.RdfMimeType }, params?: { graphUri: string }): Promise<HTTP.Body>;
/**
* Accepts integrity constraints as RDF and returns the violation explanations, if any, as RDF.
*
* @param {Connection} conn the Stardog server connection
* @param {string} database the name of the database
* @param {string} constraints an RDF block containing the constraints to be validated
* @param {object} options an object specifying the contentType of the constraints parameter. Default: text/turtle
* @param {object} params additional parameters if needed
*/
function violations(conn: Connection, database: string, constraints: string, options: { contentType: HTTP.RdfMimeType }, params?: { graphUri: string }): Promise<HTTP.Body>;
/**
* Accepts integrity constraints as RDF and returns the violation explanations, if any, as RDF.
*
* @param {Connection} conn the Stardog server connection
* @param {string} database the name of the database
* @param {string} transactionId the UUID of the transaction as returned by db.transaction.begin
* @param {string} constraints an RDF block containing the constraints to be validated
* @param {object} options an object specifying the contentType of the constraints parameter. Default: text/turtle
* @param {object} params additional parameters if needed
*/
function violationsInTx(conn: Connection, database: string, transactionId: string, constraints: string, options?: { contentType: HTTP.RdfMimeType }, params?: { graphUri: string }): Promise<HTTP.Body>;
/**
* Accepts integrity constraints as RDF and returns a validation report.
*
* @param {Connection} conn the Stardog server connection
* @param {string} database the name of the database
* @param {string} constraints an RDF block containing the constraints to be validated
* @param {object} options an object specifying the contentType of the constraints parameter (default: text/turtle) and/or the accept type for the results (default: application/ld+json)
* @param {object} params additional parameters if needed
*/
function report(conn: Connection, database: string, constraints: string, options?: { contentType?: HTTP.RdfMimeType, accept?: HTTP.AcceptMimeType }, params?: { graphUri: string }): Promise<HTTP.Body>;
/**
* Accepts integrity constraints as RDF and returns a validation report.
*
* @param {Connection} conn the Stardog server connection
* @param {string} database the name of the database
* @param {string} transactionId the UUID of the transaction as returned by db.transaction.begin
* @param {string} constraints an RDF block containing the constraints to be validated
* @param {object} options an object specifying the contentType of the constraints parameter (default: text/turtle) and/or the accept type for the results (default: application/ld+json)
* @param {object} params additional parameters if needed
*/
function reportInTx(conn: Connection, database: string, transactionId: string, constraints: string, options?: { contentType?: HTTP.RdfMimeType, accept?: HTTP.AcceptMimeType }, params?: { graphUri: string }): Promise<HTTP.Body>;
}
/** Commands that use the reasoning capabilities of a database */
namespace reasoning {
/**
* Returns if the database is consistent
* @param {Connection} conn the Stardog server connection
* @param {string} database the name of the database
* @param {object} options an object optionally specifying the URI of a graph to evaluate
* @param {object} params additional parameters if needed
*/
function consistency(conn:Connection, database: string, options?: { namedGraph: string }, params?: object): Promise<HTTP.Body>;
/**
* Provides an explanation for an inference
*
* @param {Connection} conn the Stardog server connection
* @param {string} database the name of the database
* @param {string} inference RDF representing the inference to be explained
* @param {config} options an object specifying the contentType of the RDF data (e.g., text/turtle)
* @param {object} params additional parameters if needed
*/
function explainInference(conn: Connection, database: string, inference: string, config: { contentType: string }, params?: object): Promise<HTTP.Body>;
/**
* Provides the reason why a database is inconsistent, as reported by db.reasoning.consistency
*
* @param {Connection} conn the Stardog server connection
* @param {string} database the name of the database
* @param {object} options an object optionally specifying the URI of a graph to evaluate
* @param {object} params additional parameters if needed
*/
function explainInconsistency(conn: Connection, database: string, options?: { namedGraph: string }, params?: object): Promise<HTTP.Body>;
/**
* Provides an explanation for an inference within a transaction
*
* @param {Connection} conn the Stardog server connection
* @param {string} database the name of the database
* @param {string} transactionId the UUID of the transaction as returned by db.transaction.begin
* @param {string} inference RDF representing the inference to be explained
* @param {transaction.TransactionOptions} config an object specifying the contentType of the RDF data (e.g., text/turtle)
* @param {object} params additional parameters if needed
*/
function explainInferenceInTransaction(conn: Connection, database: string, transactionId: string, inference: string, config: transaction.TransactionOptions, params?: object): Promise<HTTP.Body>;
/**
* Provides the reason why a database is inconsistent, as reported by db.reasoning.consistency
*
* @param {Connection} conn the Stardog server connection
* @param {string} database the name of the database
* @param {string} transactionId the UUID of the transaction as returned by db.transaction.begin
* @param {object} options an object optionally specifying the URI of a graph to evaluate
* @param {object} params additional parameters if needed
*/
function explainInconsistencyInTransaction(conn: Connection, database: string, transactionId: string, options?: { namedGraph: string }, params?: object): Promise<HTTP.Body>;
/**
* Gets the reasoning schema of the database
*
* @param {Connection} conn the Stardog server connection
* @param {string} database the name of the database
* @param {object} params additional parameters if needed
*/
function schema(conn: Connection, database: string, params?: object): Promise<HTTP.Body>;
}
/** Commands that interact with the BITES (document store) API */
namespace docs {
/**
* Retrieves the size of the document store
*
* @param {Connection} conn the Stardog server connection
* @param {string} database the name of the database
* @param {object} params additional parameters if needed
*/
function size(conn: Connection, database: string, params?: object): Promise<HTTP.Body>;
/**
* Clears the document store
*
* @param {Connection} conn the Stardog server connection
* @param {string} database the name of the database
* @param {object} params additional parameters if needed
*/
function clear(conn: Connection, database: string, params?: object): Promise<HTTP.Body>;
/**
* Adds a document to the document store
*
* @param {Connection} conn the Stardog server connection
* @param {string} database the name of the database
* @param {string} fileName the name of the file to add
* @param {string} fileContents the contents of the file to add
* @param {object} params additional parameters if needed
*/
function add(conn: Connection, database: string, fileName: string, fileContents: string, params?: object): Promise<HTTP.Body>;
/**
* Removes a document from the document store
*
* @param {Connection} conn the Stardog server connection
* @param {string} database the name of the database
* @param {string} fileName the name of the file
* @param {object} params additional parameters if needed
*/
function remove(conn: Connection, database: string, fileName: string, params?: object): Promise<HTTP.Body>;
/**
* Retrieves a document from the document store
*
* @param {Connection} conn the Stardog server connection
* @param {string} database the name of the database
* @param {string} fileName the name of the file
* @param {object} params additional parameters if needed
*/
function get(conn: Connection, database: string, fileName: string, params?: object): Promise<HTTP.Body>;
}
namespace namespaces {
/**
* Gets a mapping of the namespaces used in a database.
*
* @param {Connection} conn the Stardog server connection
* @param {string} database the name of the database
*/
function get(conn: Connection, database: string): Promise<HTTP.Body>;
/**
* Extracts namespaces from an RDF file or RDF string and adds new
* and updates existing namespaces in the database.
*
* @param {Connection} conn the Stardog server connection
* @param {string} database the name of the database
* @param {object|string} fileOrContents an RDF file or RDF string
* @param {object} options an object specifying the contentType of
* the RDF string; used only if `fileOrContents` is a string and
* defaults to 'text/turtle'
*/
function add(conn: Connection, database: string, fileOrContents: object | string, options?: { contentType?: HTTP.RdfMimeType }): Promise<HTTP.Body>;
}
}
/** Query actions to perform on a database. */
export namespace query {
export type QueryType = 'select' | 'ask' | 'construct' | 'describe' | 'update' | 'paths' | null;
interface PropertyOptions {
uri: string,
property: string
}
interface AdditionalHandlers {
/**
* Specify this method if you wish to act on the HTTP response
* immediately, before any further stardog.js processing.
* NOTE: The stardog.js processing will continue, unless
* `onResponseStart` explicitly returns `false`.
*
* @param {Response} res HTTP response object.
*/
onResponseStart: (res: Response) => boolean | void;
}
/**
* Gets the values for a specific property of a URI individual.
*
* @param {Connection} conn the Stardog server connection
* @param {string} database the name of the database
* @param {PropertyOptions} config an object specifying the URI and property to retrieve
* @param {object} params additional parameters if needed
*/
function property(conn: Connection, database: string, config: PropertyOptions, params?: object): Promise<HTTP.Body>;
/**
* Gets the query plan generated by Stardog for a given SPARQL query.
*
* @param {Connection} conn the Stardog server connection
* @param {string} database the name of the database
* @param {string} query the SPARQL query to be explained
* @param {HTTP.ExplainAcceptMimeType} accept The desired HTTP MIME type of the results
* @param {object} params additional parameters if needed
*/
function explain(conn: Connection, database: string, query: string, accept?: HTTP.ExplainAcceptMimeType, params?: object): Promise<HTTP.Body>
/**
* Executes a query against a database.
*
* @param {Connection} conn the Stardog server connection
* @param {string} database the name of the database
* @param {string} query the SPARQL query to be executed
* @param {HTTP.AcceptMimeType} accept The desired HTTP MIME type of the results
* @param {object} params additional parameters if needed
* @param {object} additionalHandlers additional response handlers (currently only `onResponseStart`)
*/
function execute(conn: Connection, database: string, query: string, accept?: HTTP.AcceptMimeType, params?: object, additionalHandlers?: AdditionalHandlers): Promise<HTTP.Body>;
/**
* Executes a query against a database within a transaction.
*
* @param {Connection} conn the Stardog server connection
* @param {string} database the name of the database
* @param {string} transactionId the UUID of the transaction as returned by db.transaction.begin
* @param {string} query the SPARQL query to be executed
* @param {object} options additional options to customize query
* @param {object} params additional parameters if needed
*/
function executeInTransaction(conn: Connection, database: string, transactionId: string, query: string, options?: { accept: HTTP.RdfMimeType }, params?: object): Promise<HTTP.Body>;
/**
* Gets a list of actively running queries.
*
* @param {Connection} conn the Stardog server connection
*/
function list(conn: Connection): Promise<HTTP.Body>;
/**
* Kills an actively running query.
*
* @param {Connection} conn the Stardog server connection
* @param {string} queryId the ID of the query to be killed
*/
function kill(conn: Connection, queryId: string): Promise<HTTP.Body>;
/**
* Gets information about an actively running query.
*
* @param {Connection} conn the Stardog server connection
* @param {string} queryId the ID of the query
*/
function get(conn: Connection, queryId: string): Promise<HTTP.Body>;
interface StoredQueryOptions {
name: string,
database: string,
query: string,
/** Defaults to false. */
shared: boolean,
/** Attributes introduced in Stardog version 6.2.2, which are optional in versions >= 6.2.2 and ignored in earlier versions. */
reasoning?: boolean,
description?: boolean,
}
/** Manages stored queries. */
namespace stored {
/**
* Stores a query in Stardog, either on the system level or for a given database.
*
* @param {Connection} conn the Stardog server connection
* @param {StoredQueryOptions} config an object specifying the options to set on the new query
* @param {object} params additional parameters if needed
*/
function create(conn: Connection, config: StoredQueryOptions, params?: object): Promise<HTTP.Body>
/**
* Lists all stored queries.
*
* @param {Connection} conn the Stardog server connection
* @param {object} params additional parameters if needed
*/
function list(conn: Connection, params?: object): Promise<HTTP.Body>
/**
* Updates a given stored query and creates it if the name does not refer to an existing stored query.
*
* @param {Connection} conn the Stardog server connection
* @param {StoredQueryOptions} config an object specifying the options to set on the updated query
* @param {object} params additional parameters if needed
* @param {boolean} useUpdateMethod whether to use Stardog's HTTP PUT method, added in version 6.2.0. Default: true
*/
function update(conn: Connection, config: StoredQueryOptions, params?: object, useUpdateMethod?: boolean): Promise<HTTP.Body>
/**
* Removes a given stored query.
*
* @param {Connection} conn the Stardog server connection
* @param {string} storedQuery the name of the stored query to be removed
* @param {object} params additional parameters if needed
*/
function remove(conn: Connection, storedQuery: string, params?: object): Promise<HTTP.Body>
/**
* Renames a given stored query.
*
* @param {Connection} conn the Stardog server connection
* @param {string} name the current name of the existing stored query
* @param {string} newName the new name of the stored query
*/
function rename(conn: Connection, name: string, newName: string): Promise<HTTP.Body>
}
/** GraphQL queries and schema management */
namespace graphql {
/**
* Executes a GraphQL query
*
* @param {Connection} conn the Stardog server connection
* @param {string} database the database name
* @param {string} query the query to run
* @param {object} variables Variable definitions for the query
* @param {object} params additional parameters if needed
* @param {object} additionalHandlers additional response handlers (currently only `onResponseStart`)
*/
function execute(conn: Connection, database: string, query: string, variables?: object, params?: object, additionalHandlers?: AdditionalHandlers): Promise<HTTP.Body>
/**
* Retrieves a list of GraphQL schemas in the database
*
* @param {Connection} conn the Stardog server connection
* @param {string} database the database name
* @param {object} params additional parameters if needed
*/
function listSchemas(conn: Connection, database: string, params?: object): Promise<HTTP.Body>
/**
* Adds a GraphQL schema to the database
*
* @param {Connection} conn the Stardog server connection
* @param {string} database the database name
* @param {string} name the name of the schema
* @param {object} schema an object representing the schema
* @param {object} params additional parameters if needed
*/
function addSchema(conn: Connection, database: string, name: string, schema: object, params?: object): Promise<HTTP.Body>
/**
* Updates (or adds if non-existent) a GraphQL schema to the database
*
* @param {Connection} conn the Stardog server connection
* @param {string} database the database name
* @param {string} name the name of the schema
* @param {object} schema an object representing the schema
* @param {object} params additional parameters if needed
*/
function updateSchema(conn: Connection, database: string, name: string, schema: object, params?: object): Promise<HTTP.Body>
/**
* Retrieves a GraphQL schema from the database
*
* @param {Connection} conn the Stardog server connection
* @param {string} database the database name
* @param {string} name the name of the schema
* @param {object} params additional parameters if needed
*/
function getSchema(conn: Connection, database: string, name: string, params?: object): Promise<HTTP.Body>
/**
* Removes a GraphQL schemafrom the database
*
* @param {Connection} conn the Stardog server connection
* @param {string} database the database name
* @param {string} name the name of the schema
* @param {object} params additional parameters if needed
*/
function removeSchema(conn: Connection, database: string, name: string, params?: object): Promise<HTTP.Body>
/**
* Clears all GraphQL schemas in the database
*
* @param {Connection} conn the Stardog server connection
* @param {string} database the database name
* @param {object} params additional parameters if needed
*/
function clearSchemas(conn: Connection, database: string, params?: object): Promise<HTTP.Body>
}
namespace utils {
/**
* Returns the QueryType (as a string or null) for the given query.
*
* @param {string} query the query for which to get the QueryType
*/
function queryType(query: string): QueryType;
/**
* Returns the default HTTP `Accept` MIME type for the given query.
*
* @param {string} query the query for which to get the AcceptMimeType
*/
function mimeType(query: string): HTTP.AcceptMimeType;
}
}
/** Administrative actions for managing users, roles, and their permissions. */
export namespace user {
interface User {
username: string;
password: string;
superuser?: boolean;
}
type Action =
'CREATE' |
'DELETE' |
'READ' |
'WRITE' |
'GRANT' |
'REVOKE' |
'EXECUTE';
type ResourceType =
'db' |
'user' |
'role' |
'admin' |
'metadata' |
'named-graph' |
'icv-constraints';
/**
* Gets a list of users.
*
* @param {Connection} conn the Stardog server connection
* @param {object} params additional parameters if needed
*/
function list(conn: Connection, params?: object): Promise<HTTP.Body>;
/**
* Gets all information for a given user.
*
* @param {Connection} conn the Stardog server connection
* @param {username} string the username of the user
* @param {object} params additional parameters if needed
*/
function get(conn: Connection, username: string, params?: object): Promise<HTTP.Body>;
/**
* Creates a new user.
*
* @param {Connection} conn the Stardog server connection
* @param {User} user an object specifying the details of the new user
* @param {object} params additional parameters if needed
*/
function create(conn: Connection, user: User, params?: object): Promise<HTTP.Body>;
/**
* Changes a user's password.
*
* @param {Connection} conn the Stardog server connection
* @param {string} username the username of the user
* @param {string} password the new password for the user
* @param {object} params additional parameters if needed
*/
function changePassword(conn: Connection, username: string, password: string, params?: object): Promise<HTTP.Body>;
/**
* Verifies that a Connection's credentials are valid.
*
* @param {Connection} conn the Stardog server connection
* @param {object} params additional parameters if needed
*/
function valid(conn: Connection, params?: object): Promise<HTTP.Body>;
/**
* Verifies that a user is enabled.
*
* @param {Connection} conn the Stardog server connection
* @param {string} username the username of the user
* @param {object} params additional parameters if needed
*/
function enabled(conn: Connection, username: string, params?: object): Promise<HTTP.Body>;
/**
* Enables/disables a user.
*
* @param {Connection} conn the Stardog server connection
* @param {string} username the username of the user
* @param {boolean} enabled a boolean representing the desired status of the user
* @param {object} params additional parameters if needed
*/
function enable(conn: Connection, username: string, enabled: boolean, params?: object): Promise<HTTP.Body>;
/**
* Sets roles for a user.
*
* @param {Connection} conn the Stardog server connection
* @param {string} username the username of the user
* @param {string[]} roles the new list of roles for the user
* @param {object} params additional parameters if needed
*/
function setRoles(conn: Connection, username: string, roles: string[], params?: object): Promise<HTTP.Body>;
/**
* Gets a list of roles assigned to a user.
*
* @param {Connection} conn the Stardog server connection
* @param {string} username the username of the user
* @param {object} params additional parameters if needed
*/
function listRoles(conn: Connection, username: string, params?: object): Promise<HTTP.Body>;
/**
* Creates a new permission for a user over a given resource.
*
* @param {Connection} conn the Stardog server connection
* @param {string} username the username of the user
* @param {Permission} permission the permission to be added
* @param {object} params additional parameters if needed
*/
function assignPermission(conn: Connection, username: string, permission: Permission, params?: object): Promise<HTTP.Body>;
/**
* Removes a permission for a user over a given resource.
*
* @param {Connection} conn the Stardog server connection
* @param {string} username the username of the user
* @param {Permission} permission the permission to be removed
* @param {object} params additional parameters if needed
*/
function deletePermission(conn: Connection, username: string, permission: Permission, params?: object): Promise<HTTP.Body>;
/**
* Gets a list of permissions assigned to user.
*
* @param {Connection} conn the Stardog server connection
* @param {string} username the username of the user
* @param {object} params additional parameters if needed
*/
function permissions(conn: Connection, username: string, params?: object): Promise<HTTP.Body>;
/**
* Gets a list of a user's effective permissions.
*
* @param {Connection} conn the Stardog server connection
* @param {string} username the username of the user
* @param {object} params additional parameters if needed
*/
function effectivePermissions(conn: Connection, username: string, params?: object): Promise<HTTP.Body>;
/**
* Specifies whether a user is a superuser.
*
* @param {Connection} conn the Stardog server connection
* @param {string} username the username of the user
* @param {object} params additional parameters if needed
*/
function superUser(conn: Connection, username: string, params?: object): Promise<HTTP.Body>;
/**
* Deletes a user.
*
* @param {Connection} conn the Stardog server connection
* @param {string} username the username of the user to be deleted
* @param {object} params additional parameters if needed
*/
function remove(conn: Connection, username: string, params?: object): Promise<HTTP.Body>;
/**
* Returns a token for the user if the connection is valid.
*
* @param {Connection} conn the Stardog server connection
*/
function token(conn: Connection): Promise<HTTP.Body>;