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.
- package/Contributing.md +36 -0
- package/LICENSE +201 -0
- package/README.md +175 -0
- package/RELEASE_NOTES.md +462 -0
- package/dist/index.html +22 -0
- package/dist/terminusdb-client.min.js +3 -0
- package/dist/terminusdb-client.min.js.LICENSE.txt +188 -0
- package/dist/terminusdb-client.min.js.map +1 -0
- package/dist/typescript/index.d.ts +14 -0
- package/dist/typescript/lib/accessControl.d.ts +554 -0
- package/dist/typescript/lib/axiosInstance.d.ts +2 -0
- package/dist/typescript/lib/connectionConfig.d.ts +381 -0
- package/dist/typescript/lib/const.d.ts +54 -0
- package/dist/typescript/lib/dispatchRequest.d.ts +17 -0
- package/dist/typescript/lib/errorMessage.d.ts +25 -0
- package/dist/typescript/lib/query/woqlBuilder.d.ts +75 -0
- package/dist/typescript/lib/query/woqlCore.d.ts +341 -0
- package/dist/typescript/lib/query/woqlDoc.d.ts +63 -0
- package/dist/typescript/lib/query/woqlLibrary.d.ts +718 -0
- package/dist/typescript/lib/query/woqlPrinter.d.ts +71 -0
- package/dist/typescript/lib/query/woqlQuery.d.ts +833 -0
- package/dist/typescript/lib/typedef.d.ts +624 -0
- package/dist/typescript/lib/utils.d.ts +199 -0
- package/dist/typescript/lib/valueHash.d.ts +146 -0
- package/dist/typescript/lib/viewer/chartConfig.d.ts +62 -0
- package/dist/typescript/lib/viewer/chooserConfig.d.ts +38 -0
- package/dist/typescript/lib/viewer/documentFrame.d.ts +44 -0
- package/dist/typescript/lib/viewer/frameConfig.d.ts +74 -0
- package/dist/typescript/lib/viewer/frameRule.d.ts +145 -0
- package/dist/typescript/lib/viewer/graphConfig.d.ts +73 -0
- package/dist/typescript/lib/viewer/objectFrame.d.ts +212 -0
- package/dist/typescript/lib/viewer/streamConfig.d.ts +23 -0
- package/dist/typescript/lib/viewer/tableConfig.d.ts +66 -0
- package/dist/typescript/lib/viewer/terminusRule.d.ts +75 -0
- package/dist/typescript/lib/viewer/viewConfig.d.ts +47 -0
- package/dist/typescript/lib/viewer/woqlChart.d.ts +1 -0
- package/dist/typescript/lib/viewer/woqlChooser.d.ts +56 -0
- package/dist/typescript/lib/viewer/woqlGraph.d.ts +26 -0
- package/dist/typescript/lib/viewer/woqlPaging.d.ts +1 -0
- package/dist/typescript/lib/viewer/woqlResult.d.ts +128 -0
- package/dist/typescript/lib/viewer/woqlRule.d.ts +96 -0
- package/dist/typescript/lib/viewer/woqlStream.d.ts +31 -0
- package/dist/typescript/lib/viewer/woqlTable.d.ts +102 -0
- package/dist/typescript/lib/viewer/woqlView.d.ts +49 -0
- package/dist/typescript/lib/woql.d.ts +1267 -0
- package/dist/typescript/lib/woqlClient.d.ts +1216 -0
- package/index.js +28 -0
- package/lib/.eslintrc +1 -0
- package/lib/accessControl.js +988 -0
- package/lib/axiosInstance.js +5 -0
- package/lib/connectionConfig.js +765 -0
- package/lib/const.js +59 -0
- package/lib/dispatchRequest.js +236 -0
- package/lib/errorMessage.js +110 -0
- package/lib/query/woqlBuilder.js +234 -0
- package/lib/query/woqlCore.js +934 -0
- package/lib/query/woqlDoc.js +177 -0
- package/lib/query/woqlLibrary.js +1015 -0
- package/lib/query/woqlPrinter.js +476 -0
- package/lib/query/woqlQuery.js +1865 -0
- package/lib/typedef.js +248 -0
- package/lib/utils.js +817 -0
- package/lib/valueHash.js_old +581 -0
- package/lib/viewer/chartConfig.js +411 -0
- package/lib/viewer/chooserConfig.js +234 -0
- package/lib/viewer/documentFrame.js +206 -0
- package/lib/viewer/frameConfig.js +469 -0
- package/lib/viewer/frameRule.js +519 -0
- package/lib/viewer/graphConfig.js +345 -0
- package/lib/viewer/objectFrame.js +1550 -0
- package/lib/viewer/streamConfig.js +82 -0
- package/lib/viewer/tableConfig.js +310 -0
- package/lib/viewer/terminusRule.js +196 -0
- package/lib/viewer/viewConfig.js +219 -0
- package/lib/viewer/woqlChart.js +17 -0
- package/lib/viewer/woqlChooser.js +171 -0
- package/lib/viewer/woqlGraph.js +295 -0
- package/lib/viewer/woqlPaging.js +148 -0
- package/lib/viewer/woqlResult.js +258 -0
- package/lib/viewer/woqlRule.js +312 -0
- package/lib/viewer/woqlStream.js +27 -0
- package/lib/viewer/woqlTable.js +332 -0
- package/lib/viewer/woqlView.js +107 -0
- package/lib/woql.js +1693 -0
- package/lib/woqlClient.js +2091 -0
- package/package.json +110 -0
|
@@ -0,0 +1,1267 @@
|
|
|
1
|
+
import WOQLQuery = require("./query/woqlBuilder");
|
|
2
|
+
import { Var } from "./query/woqlDoc";
|
|
3
|
+
import typedef = require("./typedef");
|
|
4
|
+
import WOQLLibrary = require("./query/woqlLibrary");
|
|
5
|
+
import WOQLClient = require("./woqlClient");
|
|
6
|
+
/**
|
|
7
|
+
* WOQL primitives are WOQL.js functions which directly map onto words in
|
|
8
|
+
* the underlying JSON-LD language. All other WOQL.js functions are compound functions
|
|
9
|
+
* which translate into multiple WOQL primitives, or are helper functions which reduce
|
|
10
|
+
* the need to write verbose JSON-LD directly.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* WOQL Literals, Prefixes & IRI Constant
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Query running against any specific commit Id
|
|
17
|
+
* @param {string} refPath - path to specific reference Id or commit Id
|
|
18
|
+
* @param {WOQLQuery} [subquery] - subquery for the specific commit point
|
|
19
|
+
* @returns {WOQLQuery}
|
|
20
|
+
* @example
|
|
21
|
+
* let [a, b, c] = vars("a", "b", "c")
|
|
22
|
+
* WOQL.using("userName/dbName/local/commit|branch/commitID").triple(a, b, c)
|
|
23
|
+
*/
|
|
24
|
+
export declare function using(refPath: string, subquery?: WOQLQuery): WOQLQuery;
|
|
25
|
+
/**
|
|
26
|
+
* Adds a text comment to a query - can also be used to wrap any part of a query to turn it off
|
|
27
|
+
* @param {string} comment - text comment
|
|
28
|
+
* @param {WOQLQuery} [subquery] - query that is "commented out"
|
|
29
|
+
* @returns {WOQLQuery}
|
|
30
|
+
*/
|
|
31
|
+
export declare function comment(comment: string, subquery?: WOQLQuery): WOQLQuery;
|
|
32
|
+
/**
|
|
33
|
+
* @example
|
|
34
|
+
* let [a, b, c] = vars("a", "b", "c")
|
|
35
|
+
* WOQL.select(a, triple(a, b, c))
|
|
36
|
+
* Filters the query so that only the variables included in [V1...Vn] are returned in the bindings
|
|
37
|
+
* @param {...string|...Var} varNames - only these variables are returned
|
|
38
|
+
* @returns {WOQLQuery}
|
|
39
|
+
*/
|
|
40
|
+
export declare function select(...varNames: any[]): WOQLQuery;
|
|
41
|
+
/**
|
|
42
|
+
* Filter the query to return only results that are distinct in the given variables
|
|
43
|
+
* @param {...string|...Var} varNames - these variables are guaranteed to be unique as a tuple
|
|
44
|
+
* @returns {WOQLQuery}
|
|
45
|
+
*/
|
|
46
|
+
export declare function distinct(...varNames: any[]): WOQLQuery;
|
|
47
|
+
/**
|
|
48
|
+
* Create a localized scope for variables to prevent leaking into outer scope
|
|
49
|
+
* @param {Object} paramSpec - Object mapping parameter names to values or null
|
|
50
|
+
* @returns {Array} - Returns [localized, v] with wrapper function and unique
|
|
51
|
+
* variable names
|
|
52
|
+
* @example
|
|
53
|
+
* const [localized, v] = WOQL.localize({
|
|
54
|
+
* consSubject: 'v:list',
|
|
55
|
+
* valueVar: 'v:value',
|
|
56
|
+
* last_cell: null // null creates a local-only variable
|
|
57
|
+
* });
|
|
58
|
+
* return localized(
|
|
59
|
+
* WOQL.and(
|
|
60
|
+
* WOQL.triple(v.consSubject, 'rdf:type', 'rdf:List'),
|
|
61
|
+
* WOQL.triple(v.last_cell, 'rdf:rest', 'rdf:nil')
|
|
62
|
+
* )
|
|
63
|
+
* );
|
|
64
|
+
*/
|
|
65
|
+
export declare function localize(paramSpec: any): any[];
|
|
66
|
+
/**
|
|
67
|
+
* Logical conjunction of the contained queries - all queries must match or the entire clause fails
|
|
68
|
+
* @param {...WOQLQuery} subqueries - A list of one or more woql queries to execute as a conjunction
|
|
69
|
+
* @returns {WOQLQuery} - A WOQLQuery object containing the conjunction of queries
|
|
70
|
+
* @example
|
|
71
|
+
* //find triples that are of type scm:Journey, and have
|
|
72
|
+
* //a start_station Start, and that start_station is labeled Start_Label
|
|
73
|
+
* let [Journey, Start, Start_Label] = vars("Journey", "Start", "Start_Label")
|
|
74
|
+
* WOQL.and(
|
|
75
|
+
* WOQL.triple(Journey, "rdf:type", "@schema:Journey"),
|
|
76
|
+
* WOQL.triple(Journey, "start_station", Start),
|
|
77
|
+
* WOQL.triple(Start, "label", Start_Label))
|
|
78
|
+
*
|
|
79
|
+
*/
|
|
80
|
+
export declare function and(...subqueries: WOQLQuery[]): WOQLQuery;
|
|
81
|
+
/**
|
|
82
|
+
* Use {@link #read_document|read_document} instead.
|
|
83
|
+
* @deprecated
|
|
84
|
+
*/
|
|
85
|
+
export declare function read_object(IRI: any, output: any, formatObj: any): import("./query/woqlQuery");
|
|
86
|
+
/**
|
|
87
|
+
* Read a node identified by an IRI as a JSON-LD document
|
|
88
|
+
* @param {string} IRI - The document id or a variable to read
|
|
89
|
+
* @param {string} output - Variable which will be bound to the document.
|
|
90
|
+
* @return {WOQLQuery} WOQLQuery
|
|
91
|
+
* @example
|
|
92
|
+
* let [person] = vars("Person")
|
|
93
|
+
* const query = WOQL.read_document(
|
|
94
|
+
* "Person/0b4feda109d9d13c9da809090b342ad9e4d8185545ce05f7cd20b97fe458f547",
|
|
95
|
+
* person
|
|
96
|
+
* );
|
|
97
|
+
* const res = await client.query(query);
|
|
98
|
+
*/
|
|
99
|
+
export declare function read_document(IRI: string, output: string): WOQLQuery;
|
|
100
|
+
/**
|
|
101
|
+
* Insert a document in the graph.
|
|
102
|
+
* @param {object} docjson - The document to insert. Must either have an '@id' or
|
|
103
|
+
* have a class specified key.
|
|
104
|
+
* @param {string} [IRI] - An optional identifier specifying the document location.
|
|
105
|
+
* @return {WOQLQuery} WOQLQuery
|
|
106
|
+
* @example
|
|
107
|
+
* const res = await client.query(
|
|
108
|
+
* WOQL.insert_document(WOQL.doc({ "@type" : "Person", "label": "John" }))
|
|
109
|
+
* )
|
|
110
|
+
*/
|
|
111
|
+
export declare function insert_document(docjson: object, IRI?: string): WOQLQuery;
|
|
112
|
+
/**
|
|
113
|
+
* Update a document identified by an IRI
|
|
114
|
+
* @param {object} docjson - The document to update. Must either have an '@id' or
|
|
115
|
+
* have a class specified key.
|
|
116
|
+
* @param {string} [IRI] - An optional identifier specifying the document location.
|
|
117
|
+
* @return {object} WOQLQuery
|
|
118
|
+
*/
|
|
119
|
+
export declare function update_document(docjson: object, IRI?: string): object;
|
|
120
|
+
/**
|
|
121
|
+
* Delete a document from the graph.
|
|
122
|
+
* @param {string} IRI - The document id or a variable
|
|
123
|
+
* @return {WOQLQuery} WOQLQuery
|
|
124
|
+
*/
|
|
125
|
+
export declare function delete_document(IRI: string): WOQLQuery;
|
|
126
|
+
/**
|
|
127
|
+
* Creates a logical OR of the arguments
|
|
128
|
+
* @param {...WOQLQuery} subqueries - A list of one or more woql queries
|
|
129
|
+
* to execute as alternatives
|
|
130
|
+
* @returns {WOQLQuery} - A WOQLQuery object containing the logical Or of the subqueries
|
|
131
|
+
* @example
|
|
132
|
+
* let [Subject] = vars("Subject")
|
|
133
|
+
* or(
|
|
134
|
+
* triple(Subject, 'label', "A"),
|
|
135
|
+
* triple(Subject, "label", "a")
|
|
136
|
+
* )
|
|
137
|
+
*/
|
|
138
|
+
export declare function or(...subqueries: WOQLQuery[]): WOQLQuery;
|
|
139
|
+
/**
|
|
140
|
+
* Specifies the database URL that will be the default database for the enclosed query
|
|
141
|
+
* @param {typedef.GraphRef} graphRef- A valid graph resource identifier string
|
|
142
|
+
* @param {WOQLQuery} [query] - The query
|
|
143
|
+
* @returns {WOQLQuery} A WOQLQuery object containing the from expression
|
|
144
|
+
*/
|
|
145
|
+
export declare function from(graphRef: any, query?: WOQLQuery): WOQLQuery;
|
|
146
|
+
/**
|
|
147
|
+
* Specifies the graph resource to write the contained query into
|
|
148
|
+
* @param {typedef.GraphRef} graphRef- A valid graph resource identifier string
|
|
149
|
+
* @param {WOQLQuery} [subquery] - The query which will be written into the graph
|
|
150
|
+
* @returns {WOQLQuery} A WOQLQuery which will be written into the graph in question
|
|
151
|
+
* @example
|
|
152
|
+
* //Subq is an argument or a chained query
|
|
153
|
+
* using("admin/minecraft").into("instance/main").add_triple("a", "rdf:type", "@schema:X")
|
|
154
|
+
* //writes a single tripe (doc:a, rdf:type, scm:X) into the main instance graph
|
|
155
|
+
*
|
|
156
|
+
*/
|
|
157
|
+
export declare function into(graphRef: any, subquery?: WOQLQuery): WOQLQuery;
|
|
158
|
+
/**
|
|
159
|
+
* Creates a triple pattern matching rule for the triple [S, P, O] (Subject, Predicate, Object)
|
|
160
|
+
* @param {string|Var} subject - The IRI of a triple’s subject or a variable
|
|
161
|
+
* @param {string|Var} predicate - The IRI of a property or a variable
|
|
162
|
+
* @param {string|Var} object - The IRI of a node or a variable, or a literal
|
|
163
|
+
* @returns {WOQLQuery}
|
|
164
|
+
*/
|
|
165
|
+
export declare function triple(subject: string | Var, predicate: string | Var, object: string | Var): WOQLQuery;
|
|
166
|
+
/**
|
|
167
|
+
* Creates a triple pattern matching rule for the triple [S, P, O] (Subject, Predicate,
|
|
168
|
+
* Object) added in the current layer
|
|
169
|
+
* @param {string|Var} subject - The IRI of a triple’s subject or a variable
|
|
170
|
+
* @param {string|Var} predicate - The IRI of a property or a variable
|
|
171
|
+
* @param {string|Var} object - The IRI of a node or a variable, or a literal
|
|
172
|
+
* @returns {WOQLQuery}
|
|
173
|
+
*/
|
|
174
|
+
export declare function added_triple(subject: string | Var, predicate: string | Var, object: string | Var): WOQLQuery;
|
|
175
|
+
/**
|
|
176
|
+
* Creates a triple pattern matching rule for the triple [S, P, O] (Subject, Predicate,
|
|
177
|
+
* Object) added in the current commit
|
|
178
|
+
* @param {string|Var} subject - The IRI of a triple’s subject or a variable
|
|
179
|
+
* @param {string|Var} predicate - The IRI of a property or a variable
|
|
180
|
+
* @param {string|Var} object - The IRI of a node or a variable, or a literal
|
|
181
|
+
* @returns {WOQLQuery}
|
|
182
|
+
*/
|
|
183
|
+
export declare function removed_triple(subject: string | Var, predicate: string | Var, object: string | Var): WOQLQuery;
|
|
184
|
+
/**
|
|
185
|
+
* Creates a pattern matching rule for the quad [S, P, O, G] (Subject, Predicate, Object, Graph)
|
|
186
|
+
* @param {string|Var} subject - The IRI of a triple’s subject or a variable
|
|
187
|
+
* @param {string|Var} predicate - The IRI of a property or a variable
|
|
188
|
+
* @param {string|Var} object - The IRI of a node or a variable, or a literal
|
|
189
|
+
* @param {typedef.GraphRef} graphRef - A valid graph resource identifier string
|
|
190
|
+
* @returns {WOQLQuery}
|
|
191
|
+
*/
|
|
192
|
+
export declare function quad(subject: string | Var, predicate: string | Var, object: string | Var, graphRef: typedef.GraphRef): WOQLQuery;
|
|
193
|
+
/**
|
|
194
|
+
* Creates a pattern matching rule for the quad [S, P, O, G] (Subject, Predicate,
|
|
195
|
+
* Object, Graph) removed from the current commit
|
|
196
|
+
* @param {string|Var} subject - The IRI of a triple’s subject or a variable
|
|
197
|
+
* @param {string|Var} predicate - The IRI of a property or a variable
|
|
198
|
+
* @param {string|Var} object - The IRI of a node or a variable, or a literal
|
|
199
|
+
* @param {typedef.GraphRef} graphRef- A valid graph resource identifier string
|
|
200
|
+
* @returns {WOQLQuery}
|
|
201
|
+
*/
|
|
202
|
+
export declare function added_quad(subject: string | Var, predicate: string | Var, object: string | Var, graphRef: any): WOQLQuery;
|
|
203
|
+
/**
|
|
204
|
+
* Creates a pattern matching rule for the quad [S, P, O, G] (Subject, Predicate,
|
|
205
|
+
* Object, Graph) removed from the current commit
|
|
206
|
+
* @param {string|Var} subject - The IRI of a triple’s subject or a variable
|
|
207
|
+
* @param {string|Var} predicate - The IRI of a property or a variable
|
|
208
|
+
* @param {string|Var} object - The IRI of a node or a variable, or a literal
|
|
209
|
+
* @param {typedef.GraphRef} graphRef- A valid graph resource identifier string
|
|
210
|
+
* @returns {WOQLQuery}
|
|
211
|
+
*/
|
|
212
|
+
export declare function removed_quad(subject: string | Var, predicate: string | Var, object: string | Var, graphRef: any): WOQLQuery;
|
|
213
|
+
/**
|
|
214
|
+
* Returns true if ClassA subsumes ClassB, according to the current DB schema
|
|
215
|
+
* @param {string} classA - ClassA
|
|
216
|
+
* @param {string} classB - ClassB
|
|
217
|
+
* @returns {WOQLQuery} WOQLQuery
|
|
218
|
+
*/
|
|
219
|
+
export declare function sub(classA: string, classB: string): WOQLQuery;
|
|
220
|
+
export declare function subsumption(classA: any, classB: any): boolean;
|
|
221
|
+
/**
|
|
222
|
+
* Matches if a is equal to b
|
|
223
|
+
* @param {string|number|boolean|array|Var} varName - literal, variable, array, or id
|
|
224
|
+
* @param {string|number|boolean|array|Var} varValue - literal, variable, array, or id
|
|
225
|
+
* @returns {WOQLQuery}
|
|
226
|
+
*
|
|
227
|
+
*
|
|
228
|
+
*/
|
|
229
|
+
export declare function eq(varName: string | number | boolean | any[] | Var, varValue: string | number | boolean | any[] | Var): WOQLQuery;
|
|
230
|
+
export declare function equals(varName: any, varValue: any): import("./query/woqlQuery");
|
|
231
|
+
/**
|
|
232
|
+
* Substring of string
|
|
233
|
+
* @param {string|Var} string - String or variable
|
|
234
|
+
* @param {number|Var} before - integer or variable (characters from start to begin)
|
|
235
|
+
* @param {number|Var} [length] - integer or variable (length of substring)
|
|
236
|
+
* @param {number|Var} [after] - integer or variable (number of characters after substring)
|
|
237
|
+
* @param {string|Var} [substring] - String or variable
|
|
238
|
+
* @returns {WOQLQuery}
|
|
239
|
+
* @example
|
|
240
|
+
* let [after, result] = vars("after", "result")
|
|
241
|
+
* substr("joe", 1, 2, after, result)
|
|
242
|
+
* //result is "oe", after is 2
|
|
243
|
+
*/
|
|
244
|
+
export declare function substr(string: string | Var, before: number | Var, length?: number | Var, after?: number | Var, substring?: string | Var): WOQLQuery;
|
|
245
|
+
export declare function substring(string: any, before: any, length: any, after: any, substring: any): import("./query/woqlQuery");
|
|
246
|
+
/**
|
|
247
|
+
* Use the document interface to import documents
|
|
248
|
+
* @deprecated
|
|
249
|
+
* Retrieves the exernal resource defined by QueryResource and copies values
|
|
250
|
+
* from it into variables defined in AsVars
|
|
251
|
+
* @param {Vars | array<Var>} asvars - an array of AsVar variable mappings (see as for format below)
|
|
252
|
+
* @param {WOQLQuery} queryResource - an external resource (remote, file, post) to query
|
|
253
|
+
* @returns {WOQLQuery} A WOQLQuery which contains the get expression
|
|
254
|
+
* @example
|
|
255
|
+
* let [a, b] = vars("a", "b")
|
|
256
|
+
* get(as("a", a).as("b", b)).remote("http://my.url.com/x.csv")
|
|
257
|
+
* //copies the values from column headed "a" into a variable a and from column
|
|
258
|
+
* //"b" into a variable b from remote CSV
|
|
259
|
+
*/
|
|
260
|
+
export declare function get(asvars: typeof import("./query/woqlDoc").Vars | array<Var>, queryResource: WOQLQuery): WOQLQuery;
|
|
261
|
+
/**
|
|
262
|
+
* Use the document interface to import documents
|
|
263
|
+
* @deprecated
|
|
264
|
+
* @put Outputs the results of a query to a file
|
|
265
|
+
* @param {Vars | array<Var>} varsToExp - an array of AsVar variable
|
|
266
|
+
* mappings (see as for format below)
|
|
267
|
+
* @param {WOQLQuery} query - The query which will be executed to produce the results
|
|
268
|
+
* @param {string} fileResource - an file resource local to the server
|
|
269
|
+
* @returns {WOQLQuery} A WOQLQuery which contains the put expression
|
|
270
|
+
*/
|
|
271
|
+
export declare function put(varsToExp: typeof import("./query/woqlDoc").Vars | array<Var>, query: WOQLQuery, fileResource: string): WOQLQuery;
|
|
272
|
+
/**
|
|
273
|
+
* Imports the value identified by Source to a Target variable
|
|
274
|
+
* @param {string | number | Var} source - Source
|
|
275
|
+
* @param {string | Var} target - Target
|
|
276
|
+
* @param {string} [type] - type to cast value to string|number etc...
|
|
277
|
+
* @returns {WOQLQuery}
|
|
278
|
+
* @example
|
|
279
|
+
* let [First_Var, Second_Var] = vars('First_Var', 'Second_Var')
|
|
280
|
+
* WOQL.as("first var", First_Var, "xsd:string").as("second var", Second_Var)
|
|
281
|
+
* WOQL.as(["first var", First_Var, "xsd:string"], ["second var", Second_Var])
|
|
282
|
+
*/
|
|
283
|
+
export declare function as(source: string | number | Var, target: string | Var, type?: string): WOQLQuery;
|
|
284
|
+
/**
|
|
285
|
+
* Identifies a remote resource by URL and specifies the format of the resource through the options
|
|
286
|
+
* @param {object} remoteObj - The URL at which the remote resource can be accessed
|
|
287
|
+
* @param {typedef.DataFormatObj} [formatObj] - The format of the resource data {}
|
|
288
|
+
* @returns {WOQLQuery} A WOQLQuery which contains the remote resource identifier
|
|
289
|
+
* @example
|
|
290
|
+
* remote({url:"http://url.of.resource"}, {type: "csv"})
|
|
291
|
+
*/
|
|
292
|
+
export declare function remote(remoteObj: object, formatObj?: typedef.DataFormatObj): WOQLQuery;
|
|
293
|
+
/**
|
|
294
|
+
* Identifies a resource as a local path on the client, to be sent to the server through a
|
|
295
|
+
* HTTP POST request, with the format defined through the options
|
|
296
|
+
* @param {string} url - The Path on the server at which the file resource can be accessed
|
|
297
|
+
* @param {typedef.DataFormatObj} [formatObj] - imput options, optional
|
|
298
|
+
* @param {string} [source] - It defines the source of the file, it can be 'url','post'
|
|
299
|
+
* @returns {WOQLQuery} A WOQLQuery which contains the Post resource identifier
|
|
300
|
+
* @example
|
|
301
|
+
* post("/.../.../", {type:'csv'})
|
|
302
|
+
*/
|
|
303
|
+
export declare function post(url: string, formatObj?: typedef.DataFormatObj, source?: string): WOQLQuery;
|
|
304
|
+
/**
|
|
305
|
+
* Deletes a single triple from the default graph of the database
|
|
306
|
+
* @param {string|Var} subject - The IRI of a triple’s subject or a variable
|
|
307
|
+
* @param {string|Var} predicate - The IRI of a property or a variable
|
|
308
|
+
* @param {string|Var} object - The IRI of a node or a variable, or a literal
|
|
309
|
+
* @returns {WOQLQuery} - A WOQLQuery which contains the Triple Deletion statement
|
|
310
|
+
* @example
|
|
311
|
+
* delete_triple("john", "age", 42)
|
|
312
|
+
*/
|
|
313
|
+
export declare function delete_triple(subject: string | Var, predicate: string | Var, object: string | Var): WOQLQuery;
|
|
314
|
+
/**
|
|
315
|
+
* Deletes a single triple from the graph [Subject, Predicate, Object, Graph]
|
|
316
|
+
* @param {string|Var} subject - The IRI of a triple’s subject or a variable
|
|
317
|
+
* @param {string|Var} predicate - The IRI of a property or a variable
|
|
318
|
+
* @param {string|Var} object - The IRI of a node or a variable, or a literal
|
|
319
|
+
* @param {typedef.GraphRef} graphRef - A valid graph resource identifier string
|
|
320
|
+
* @returns {WOQLQuery} - A WOQLQuery which contains the Delete Quad Statement
|
|
321
|
+
* @example remove the class Person from the schema graph
|
|
322
|
+
* WOQL.delete_quad("Person", "rdf:type", "sys:Class", "schema")
|
|
323
|
+
*/
|
|
324
|
+
export declare function delete_quad(subject: string | Var, predicate: string | Var, object: string | Var, graphRef: typedef.GraphRef): WOQLQuery;
|
|
325
|
+
/**
|
|
326
|
+
* Adds triples according to the the pattern [subject,predicate,object]
|
|
327
|
+
* @param {string|Var} subject - The IRI of a triple’s subject or a variable
|
|
328
|
+
* @param {string|Var} predicate - The IRI of a property or a variable
|
|
329
|
+
* @param {string|Var} object - The IRI of a node or a variable, or a literal
|
|
330
|
+
* @returns {WOQLQuery}
|
|
331
|
+
*/
|
|
332
|
+
export declare function add_triple(subject: string | Var, predicate: string | Var, object: string | Var): WOQLQuery;
|
|
333
|
+
/**
|
|
334
|
+
* Adds quads according to the pattern [S,P,O,G]
|
|
335
|
+
* @param {string|Var} subject - The IRI of a triple’s subject or a variable
|
|
336
|
+
* @param {string|Var} predicate - The IRI of a property or a variable
|
|
337
|
+
* @param {string|Var} object - The IRI of a node or a variable, or a literal
|
|
338
|
+
* @param {typedef.GraphRef} graphRef- A valid graph resource identifier string
|
|
339
|
+
* @returns {WOQLQuery}
|
|
340
|
+
*/
|
|
341
|
+
export declare function add_quad(subject: string | Var, predicate: string | Var, object: string | Var, graphRef: any): WOQLQuery;
|
|
342
|
+
/**
|
|
343
|
+
*
|
|
344
|
+
* When the subquery is met, the update query is executed
|
|
345
|
+
* @param {WOQLQuery} subquery - the condition query
|
|
346
|
+
* @param {WOQLQuery} [updateQuery]
|
|
347
|
+
* @returns {WOQLQuery} - A WOQLQuery which contains the when expression
|
|
348
|
+
* @example
|
|
349
|
+
* when(true()).triple("a", "b", "c")
|
|
350
|
+
*/
|
|
351
|
+
/**
|
|
352
|
+
*
|
|
353
|
+
* Remove whitespace from both sides of a string:
|
|
354
|
+
* @param {string|Var} inputStr - A string or variable containing
|
|
355
|
+
* the untrimmed version of the string
|
|
356
|
+
* @param {string|Var} resultVarName - A string or variable
|
|
357
|
+
* containing the trimmed version of the string
|
|
358
|
+
* @returns {WOQLQuery} A WOQLQuery which contains the Trim pattern matching expression
|
|
359
|
+
* @example
|
|
360
|
+
* let [trimmed] = vars("trimmed")
|
|
361
|
+
* trim("hello ", trimmed)
|
|
362
|
+
* //trimmed contains "hello"
|
|
363
|
+
*/
|
|
364
|
+
export declare function trim(inputStr: string | Var, resultVarName: string | Var): WOQLQuery;
|
|
365
|
+
/**
|
|
366
|
+
*
|
|
367
|
+
* Evaluates the passed arithmetic expression and generates or matches the result value
|
|
368
|
+
* @param {object| WOQLQuery | string} arithExp - A WOQL query containing a valid WOQL Arithmetic
|
|
369
|
+
* Expression, which is evaluated by the function
|
|
370
|
+
* @param {string|number|Var} resultVarName - Either a variable, in which the result of the
|
|
371
|
+
* expression will be stored, or a numeric literal which will be used as a test of result of
|
|
372
|
+
* the evaluated expression
|
|
373
|
+
* @returns {WOQLQuery} A WOQLQuery which contains the Arithmetic function
|
|
374
|
+
* @example
|
|
375
|
+
* let [result] = vars("result")
|
|
376
|
+
* evaluate(plus(2, minus(3, 1)), result)
|
|
377
|
+
*/
|
|
378
|
+
export declare function evaluate(arithExp: object | WOQLQuery | string, resultVarName: string | number | Var): WOQLQuery;
|
|
379
|
+
/**
|
|
380
|
+
*
|
|
381
|
+
* Evaluates the passed arithmetic expression and generates or matches the result value
|
|
382
|
+
* @param {object| WOQLQuery | string} arithExp - A WOQL query containing a valid WOQL Arithmetic
|
|
383
|
+
* Expression, which is evaluated by the function
|
|
384
|
+
* @param {string|number|Var} resultVarName - Either a variable, in which the result of the
|
|
385
|
+
* expression will be stored, or a numeric literal which will be used as a test of result of
|
|
386
|
+
* the evaluated expression
|
|
387
|
+
* @returns {WOQLQuery} A WOQLQuery which contains the Arithmetic function
|
|
388
|
+
* @example
|
|
389
|
+
* let [result] = vars("result")
|
|
390
|
+
* eval(plus(2, minus(3, 1)), result)
|
|
391
|
+
* @deprecated Use {@link evaluate} instead. The name 'eval' conflicts with JavaScript's
|
|
392
|
+
* built-in eval in strict mode.
|
|
393
|
+
* @internal
|
|
394
|
+
*/
|
|
395
|
+
/**
|
|
396
|
+
*
|
|
397
|
+
* Adds the numbers together
|
|
398
|
+
* @param {...(string|number|Var)} args - a variable or numeric containing the values to add
|
|
399
|
+
* @returns {WOQLQuery} A WOQLQuery which contains the addition expression
|
|
400
|
+
* @example
|
|
401
|
+
* let [result] = vars("result")
|
|
402
|
+
* evaluate(plus(2, plus(3, 1)), result)
|
|
403
|
+
*/
|
|
404
|
+
export declare function plus(...args: (string | number | Var)[]): WOQLQuery;
|
|
405
|
+
/**
|
|
406
|
+
*
|
|
407
|
+
* Subtracts Numbers N1..Nn
|
|
408
|
+
* @param {...(string|number|Var)} args - variable or numeric containing the value that will be
|
|
409
|
+
* subtracted from
|
|
410
|
+
* @returns {WOQLQuery} A WOQLQuery which contains the subtraction expression
|
|
411
|
+
* @example
|
|
412
|
+
* let [result] = vars("result")
|
|
413
|
+
* evaluate(minus(2.1, plus(0.2, 1)), result)
|
|
414
|
+
*/
|
|
415
|
+
export declare function minus(...args: (string | number | Var)[]): WOQLQuery;
|
|
416
|
+
/**
|
|
417
|
+
*
|
|
418
|
+
* Multiplies numbers N1...Nn together
|
|
419
|
+
* @param {...(string|number|Var)} args - a variable or numeric containing the value
|
|
420
|
+
* @returns {WOQLQuery} A WOQLQuery which contains the multiplication expression
|
|
421
|
+
* @example
|
|
422
|
+
* let [result] = vars("result")
|
|
423
|
+
* evaluate(times(10, minus(2.1, plus(0.2, 1))), result)
|
|
424
|
+
* //result contains 9.000000000000002y
|
|
425
|
+
*/
|
|
426
|
+
export declare function times(...args: (string | number | Var)[]): WOQLQuery;
|
|
427
|
+
/**
|
|
428
|
+
*
|
|
429
|
+
* Divides numbers N1...Nn by each other left, to right precedence
|
|
430
|
+
* @param {...(string|number|Var )} args - numbers to tbe divided
|
|
431
|
+
* @returns {WOQLQuery} A WOQLQuery which contains the division expression
|
|
432
|
+
* let [result] = vars("result")
|
|
433
|
+
* evaluate(divide(times(10, minus(2.1, plus(0.2, 1))), 10), result)
|
|
434
|
+
* //result contains 0.9000000000000001
|
|
435
|
+
*/
|
|
436
|
+
export declare function divide(...args: (string | number | Var)[]): WOQLQuery;
|
|
437
|
+
/**
|
|
438
|
+
*
|
|
439
|
+
* Division - integer division - args are divided left to right
|
|
440
|
+
* @param {...(string|number|Var)} args - numbers for division
|
|
441
|
+
* @returns {WOQLQuery} A WOQLQuery which contains the division expression
|
|
442
|
+
* @example
|
|
443
|
+
* let [result] = vars("result")
|
|
444
|
+
* evaluate(div(10, 3), result)
|
|
445
|
+
* //result contains 3
|
|
446
|
+
*/
|
|
447
|
+
export declare function div(...args: (string | number | Var)[]): WOQLQuery;
|
|
448
|
+
/**
|
|
449
|
+
*
|
|
450
|
+
* Exponent - raises varNum01 to the power of varNum02
|
|
451
|
+
* @param {string|number|Var} varNum - a variable or numeric containing the number to be
|
|
452
|
+
* raised to the power of the second number
|
|
453
|
+
* @param {number} expNum - a variable or numeric containing the exponent
|
|
454
|
+
* @returns {WOQLQuery} A WOQLQuery which contains the exponent expression
|
|
455
|
+
* @example
|
|
456
|
+
* let [result] = vars("result")
|
|
457
|
+
* evaluate(exp(3, 2), result)
|
|
458
|
+
* //result contains 9
|
|
459
|
+
*/
|
|
460
|
+
export declare function exp(varNum: string | number | Var, expNum: number): WOQLQuery;
|
|
461
|
+
/**
|
|
462
|
+
*
|
|
463
|
+
* Generates the nearest lower integer to the passed number
|
|
464
|
+
* @param {string|number|Var} varNum - Variable or numeric containing the number to be floored
|
|
465
|
+
* @returns {WOQLQuery} A WOQLQuery which contains the floor expression
|
|
466
|
+
* @example
|
|
467
|
+
* let [result] = vars("result")
|
|
468
|
+
* evaluate(divide(floor(times(10, minus(2.1, plus(0.2, 1)))), 10), result)
|
|
469
|
+
* //result contains 0.9 - floating point error removed
|
|
470
|
+
*/
|
|
471
|
+
export declare function floor(varNum: string | number | Var): WOQLQuery;
|
|
472
|
+
/**
|
|
473
|
+
*
|
|
474
|
+
* Tests whether a given instance IRI has type Class, according to the current state of the DB
|
|
475
|
+
* @param {string|Var} instanceIRI - A string IRI or a variable that identify the class instance
|
|
476
|
+
* @param {string|Var} classId - A Class IRI or a variable
|
|
477
|
+
* @returns {WOQLQuery} A WOQLQuery object containing the type test
|
|
478
|
+
* @example
|
|
479
|
+
* let [subject] = vars("subject")
|
|
480
|
+
* isa(subject, "Person")
|
|
481
|
+
*/
|
|
482
|
+
export declare function isa(instanceIRI: string | Var, classId: string | Var): WOQLQuery;
|
|
483
|
+
/**
|
|
484
|
+
*
|
|
485
|
+
* Generates a string Leverstein distance measure between stringA and stringB
|
|
486
|
+
* @param {string|Var} stringA - string literal or variable representing a string to be compared
|
|
487
|
+
* @param {string|Var } stringB - string literal or variable
|
|
488
|
+
* representing the other string to be compared
|
|
489
|
+
* @param {number|string|Var} distance - variable representing the distance between the variables
|
|
490
|
+
* @returns {WOQLQuery} A WOQLQuery which contains the Like pattern matching expression
|
|
491
|
+
* @example
|
|
492
|
+
* let [dist] = vars('dist')
|
|
493
|
+
* like("hello", "hallo", dist)
|
|
494
|
+
* //dist contains 0.7265420560747664
|
|
495
|
+
*/
|
|
496
|
+
export declare function like(stringA: string | Var, stringB: string | Var, distance: number | string | Var): WOQLQuery;
|
|
497
|
+
/**
|
|
498
|
+
*
|
|
499
|
+
* Compares the value of v1 against v2 and returns true if v1 is less than v2
|
|
500
|
+
* @param {string|number|Var} varNum01 - a variable or numeric containing
|
|
501
|
+
* the number to be compared
|
|
502
|
+
* @param {string|number|Var} varNum02 - a variable or numeric containing the second comporator
|
|
503
|
+
* @returns {WOQLQuery} A WOQLQuery which contains the comparison expression
|
|
504
|
+
* @example
|
|
505
|
+
* let [result] = vars("result")
|
|
506
|
+
* less(1, 1.1).eq(result, literal(true, "boolean"))
|
|
507
|
+
* //result contains true
|
|
508
|
+
*/
|
|
509
|
+
export declare function less(varNum01: string | number | Var, varNum02: string | number | Var): WOQLQuery;
|
|
510
|
+
/**
|
|
511
|
+
*
|
|
512
|
+
* Compares the value of v1 against v2 and returns true if v1 is greater than v2
|
|
513
|
+
* @param {string|number|Var} varNum01 - a variable or numeric containing the number to be compared
|
|
514
|
+
* @param {string|number|Var} varNum02 - a variable or numeric containing the second comporator
|
|
515
|
+
* @returns {WOQLQuery} A WOQLQuery which contains the comparison expression
|
|
516
|
+
* @example
|
|
517
|
+
* let [result] = vars("result")
|
|
518
|
+
* greater(1.2, 1.1).eq(result, literal(true, "boolean"))
|
|
519
|
+
* //result contains true
|
|
520
|
+
*/
|
|
521
|
+
export declare function greater(varNum01: string | number | Var, varNum02: string | number | Var): WOQLQuery;
|
|
522
|
+
/**
|
|
523
|
+
*
|
|
524
|
+
* Specifies that the Subquery is optional - if it does not match the query will not fail
|
|
525
|
+
* @param {WOQLQuery} [subquery] - A subquery which will be optionally matched
|
|
526
|
+
* @returns {WOQLQuery} A WOQLQuery object containing the optional sub Query
|
|
527
|
+
* @example
|
|
528
|
+
* let [subject] = vars("subject")
|
|
529
|
+
* opt(triple(subject, 'label', "A"))
|
|
530
|
+
* //Subq is an argument or a chained query
|
|
531
|
+
* opt().triple(subject, 'label', "A")
|
|
532
|
+
*/
|
|
533
|
+
export declare function opt(subquery?: WOQLQuery): WOQLQuery;
|
|
534
|
+
export declare function optional(subquery: any): import("./query/woqlQuery");
|
|
535
|
+
/**
|
|
536
|
+
*
|
|
537
|
+
* Generate a new IRI from the prefix and a hash of the variables which will be unique for any
|
|
538
|
+
* given combination of variables
|
|
539
|
+
* @param {string} prefix - A prefix for the IRI - typically formed of the doc prefix and the
|
|
540
|
+
* classtype of the entity (“doc:Person”)
|
|
541
|
+
* @param {array|string|Var} inputVarList - An array of variables and / or strings from which the
|
|
542
|
+
* unique hash will be generated
|
|
543
|
+
* @param {string|Var} resultVarName - Variable in which the unique ID is stored
|
|
544
|
+
* @returns {WOQLQuery} A WOQLQuery object containing the unique ID generating function
|
|
545
|
+
* @example
|
|
546
|
+
* let [newid] = vars("newid")
|
|
547
|
+
* unique("doc:Person", ["John", "Smith"], newid)
|
|
548
|
+
*/
|
|
549
|
+
export declare function unique(prefix: string, inputVarList: any[] | string | Var, resultVarName: string | Var): WOQLQuery;
|
|
550
|
+
/**
|
|
551
|
+
*
|
|
552
|
+
* Generate a new IRI from the prefix and concatention of the variables
|
|
553
|
+
* @param {string} prefix - A prefix for the IRI - typically formed of the doc prefix and the
|
|
554
|
+
* classtype of the entity (“doc:Person”)
|
|
555
|
+
* @param {array|string|Var} inputVarList - An array of variables and / or strings from which the
|
|
556
|
+
* unique hash will be generated
|
|
557
|
+
* @param {string|Var} resultVarName - Variable in which the unique ID is stored
|
|
558
|
+
* @returns {WOQLQuery} A WOQLQuery object containing the ID generating function
|
|
559
|
+
* @example
|
|
560
|
+
* let [newid] = vars("newid")
|
|
561
|
+
* idgen("doc:Person", ["John", "Smith"], newid)
|
|
562
|
+
*/
|
|
563
|
+
export declare function idgen(prefix: string, inputVarList: any[] | string | Var, resultVarName: string | Var): WOQLQuery;
|
|
564
|
+
export declare function idgenerator(prefix: any, inputVarList: any, resultVarName: any): import("./query/woqlQuery");
|
|
565
|
+
/**
|
|
566
|
+
* Generates a random ID with a specified prefix
|
|
567
|
+
* @param {string} prefix - prefix for the generated ID
|
|
568
|
+
* @param {string} resultVarName - variable that stores the generated ID
|
|
569
|
+
* @returns {WOQLQuery} A WOQLQuery object containing the random ID generation function
|
|
570
|
+
* @example
|
|
571
|
+
* let [newid] = vars("newid")
|
|
572
|
+
* idgen_random("Person/", newid)
|
|
573
|
+
*/
|
|
574
|
+
export declare function idgen_random(prefix: string, resultVarName: string): WOQLQuery;
|
|
575
|
+
/**
|
|
576
|
+
* Backward-compatible alias for idgen_random
|
|
577
|
+
* @deprecated Use idgen_random instead
|
|
578
|
+
* @param {string} prefix - prefix for the generated ID
|
|
579
|
+
* @param {string} resultVarName - variable that stores the generated ID
|
|
580
|
+
* @returns {WOQLQuery} A WOQLQuery object containing the random ID generation function
|
|
581
|
+
*/
|
|
582
|
+
export declare function random_idgen(prefix: string, resultVarName: string): WOQLQuery;
|
|
583
|
+
/**
|
|
584
|
+
*
|
|
585
|
+
* Changes a string to upper-case
|
|
586
|
+
* @param {string|Var} inputVarName - string or variable representing the uncapitalized string
|
|
587
|
+
* @param {string|Var} resultVarName - variable that stores the capitalized string output
|
|
588
|
+
* @returns {WOQLQuery} A WOQLQuery which contains the Upper case pattern matching expression
|
|
589
|
+
* @example
|
|
590
|
+
* let [allcaps] = vars("allcaps")
|
|
591
|
+
* upper("aBCe", allcaps)
|
|
592
|
+
* //upper contains "ABCE"
|
|
593
|
+
*/
|
|
594
|
+
export declare function upper(inputVarName: string | Var, resultVarName: string | Var): WOQLQuery;
|
|
595
|
+
/**
|
|
596
|
+
*
|
|
597
|
+
* Changes a string to lower-case
|
|
598
|
+
* @param {string|Var} inputVarName - string or variable representing the non-lowercased string
|
|
599
|
+
* @param {string|Var} resultVarName - variable that stores the lowercased string output
|
|
600
|
+
* @returns {WOQLQuery} A WOQLQuery which contains the Lower case pattern matching expression
|
|
601
|
+
* @example
|
|
602
|
+
* let [lower] = var("l")
|
|
603
|
+
* lower("aBCe", lower)
|
|
604
|
+
* //lower contains "abce"
|
|
605
|
+
*/
|
|
606
|
+
export declare function lower(inputVarName: string | Var, resultVarName: string | Var): WOQLQuery;
|
|
607
|
+
/**
|
|
608
|
+
*
|
|
609
|
+
* Pads out the string input to be exactly len long by appending the pad character pad to
|
|
610
|
+
* form output
|
|
611
|
+
* @param {string|Var} inputVarName - The input string or variable in unpadded state
|
|
612
|
+
* @param {string|Var} pad - The characters to use to pad the string or a variable representing them
|
|
613
|
+
* @param {number | string | Var} len - The variable or integer value representing the length of
|
|
614
|
+
* the output string
|
|
615
|
+
* @param {string|Var} resultVarName - stores output
|
|
616
|
+
* @returns {WOQLQuery} A WOQLQuery which contains the Pad pattern matching expression
|
|
617
|
+
* @example
|
|
618
|
+
* let [fixed] = vars("fixed length")
|
|
619
|
+
* pad("joe", " ", 8, fixed)
|
|
620
|
+
* //fixed contains "joe "
|
|
621
|
+
*/
|
|
622
|
+
export declare function pad(inputVarName: string | Var, pad: string | Var, len: number | string | Var, resultVarName: string | Var): WOQLQuery;
|
|
623
|
+
/**
|
|
624
|
+
* Splits a string (Input) into a list strings (Output) by removing separator
|
|
625
|
+
* @param {string|Var} inputVarName - A string or variable representing the unsplit string
|
|
626
|
+
* @param {string|Var} separator - A string or variable containing a sequence of charatcters
|
|
627
|
+
* to use as a separator
|
|
628
|
+
* @param {string|Var} resultVarName - variable that stores output list
|
|
629
|
+
* @returns {WOQLQuery} A WOQLQuery which contains the Split pattern matching expression
|
|
630
|
+
* @example
|
|
631
|
+
* let [words] = vars("words")
|
|
632
|
+
* split("joe has a hat", " ", words)
|
|
633
|
+
*/
|
|
634
|
+
export declare function split(inputVarName: string | Var, separator: string | Var, resultVarName: string | Var): WOQLQuery;
|
|
635
|
+
/**
|
|
636
|
+
* Matches if List includes Element
|
|
637
|
+
* @param {string|object|Var} element - Either a variable, IRI or any simple datatype
|
|
638
|
+
* @param {string|array|Var} list - List ([string, literal] or string*) Either a variable
|
|
639
|
+
* representing a list or a list of variables or literals
|
|
640
|
+
* @returns {WOQLQuery} A WOQLQuery which contains the List inclusion pattern matching expression
|
|
641
|
+
* @example
|
|
642
|
+
* let [name] = vars("name")
|
|
643
|
+
* member(name, ["john", "joe", "frank"])
|
|
644
|
+
*/
|
|
645
|
+
export declare function member(element: string | object | Var, list: string | any[] | Var): WOQLQuery;
|
|
646
|
+
/**
|
|
647
|
+
*
|
|
648
|
+
* takes a variable number of string arguments and concatenates them into a single string
|
|
649
|
+
* @param {array|string|Var} varList - a variable representing a list or a list of variables or
|
|
650
|
+
* strings - variables can be embedded in the string if they do not contain spaces
|
|
651
|
+
* @param {string|Var} resultVarName - A variable or string containing the output string
|
|
652
|
+
* @returns {WOQLQuery} A WOQLQuery which contains the Concatenation pattern matching expression
|
|
653
|
+
* @example
|
|
654
|
+
* let [first_name, last_name, full_name] = vars("first_name", "last_name", "full_name")
|
|
655
|
+
* concat([first_name, " ", last_name], full_name)
|
|
656
|
+
*/
|
|
657
|
+
export declare function concat(varList: any[] | string | Var, resultVarName: string | Var): WOQLQuery;
|
|
658
|
+
/**
|
|
659
|
+
*
|
|
660
|
+
* Joins a list variable together (Input) into a string variable (Output) by glueing the strings
|
|
661
|
+
* together with Glue
|
|
662
|
+
* @param {string|array|Var} varList - a variable representing a list or a list of strings
|
|
663
|
+
* and / or variables
|
|
664
|
+
* @param {string|Var} glue - A variable (v:glue) or (glue) string representing the characters
|
|
665
|
+
* to put in between the joined strings in input
|
|
666
|
+
* @param {string|Var} resultVarName - A variable or string containing the output string
|
|
667
|
+
* @returns {WOQLQuery} A WOQLQuery which contains the Join pattern matching expression
|
|
668
|
+
* @example
|
|
669
|
+
* let [sentence] = vars("sentence")
|
|
670
|
+
* join(["joe", "has", "a", "hat", " ", sentence)
|
|
671
|
+
*/
|
|
672
|
+
export declare function join(varList: string | any[] | Var, glue: string | Var, resultVarName: string | Var): WOQLQuery;
|
|
673
|
+
/**
|
|
674
|
+
* computes the sum of the List of values passed. In contrast to other arithmetic functions,
|
|
675
|
+
* sum self-evaluates - it does not have to be passed to evaluate()
|
|
676
|
+
* @param {WOQLQuery} subquery - a subquery or ([string or numeric]) - a list variable, or a
|
|
677
|
+
* list of variables or numeric literals
|
|
678
|
+
* @param {string|Var} total - the variable name with the sum result of the values in List
|
|
679
|
+
* @returns {WOQLQuery} - A WOQLQuery which contains the Sum expression
|
|
680
|
+
* @example
|
|
681
|
+
* let [total] = vars("total")
|
|
682
|
+
* sum([2, 3, 4, 5], total)
|
|
683
|
+
*/
|
|
684
|
+
export declare function sum(subquery: WOQLQuery, total: string | Var): WOQLQuery;
|
|
685
|
+
/**
|
|
686
|
+
* Extracts a contiguous subsequence from a list, following JavaScript's slice() semantics
|
|
687
|
+
* @param {string|array|Var} inputList - Either a variable representing a list or a list of
|
|
688
|
+
* variables or literals
|
|
689
|
+
* @param {string|Var} resultVarName - A variable in which the sliced list is stored
|
|
690
|
+
* @param {number|string|Var} start - The start index (0-based, supports negative indices)
|
|
691
|
+
* @param {number|string|Var} [end] - The end index (exclusive, optional - defaults to list length)
|
|
692
|
+
* @returns {WOQLQuery} A WOQLQuery which contains the Slice pattern matching expression
|
|
693
|
+
* @example
|
|
694
|
+
* let [result] = vars("result")
|
|
695
|
+
* slice(["a", "b", "c", "d"], result, 1, 3) // result = ["b", "c"]
|
|
696
|
+
* slice(["a", "b", "c", "d"], result, -2) // result = ["c", "d"]
|
|
697
|
+
*/
|
|
698
|
+
export declare function slice(inputList: string | any[] | Var, resultVarName: string | Var, start: number | string | Var, end?: number | string | Var): WOQLQuery;
|
|
699
|
+
/**
|
|
700
|
+
*
|
|
701
|
+
* Specifies an offset position in the results to start listing results from
|
|
702
|
+
* @param {number|string|Var} start - A variable that refers to an interger or an integer literal
|
|
703
|
+
* @param {WOQLQuery} [subquery] - WOQL Query object, you can pass a subquery as an argument
|
|
704
|
+
* or a chained query
|
|
705
|
+
* @returns {WOQLQuery} A WOQLQuery whose results will be returned starting from
|
|
706
|
+
* the specified offset
|
|
707
|
+
* @example
|
|
708
|
+
* let [a, b, c] = vars("a", "b", "c")
|
|
709
|
+
* start(100).triple(a, b, c)
|
|
710
|
+
*/
|
|
711
|
+
export declare function start(start: number | string | Var, subquery?: WOQLQuery): WOQLQuery;
|
|
712
|
+
/**
|
|
713
|
+
*
|
|
714
|
+
* Specifies a maximum number of results that will be returned from the subquery
|
|
715
|
+
* @param {number|string} limit - A variable that refers to an non-negative integer or a
|
|
716
|
+
* non-negative integer
|
|
717
|
+
* @param {WOQLQuery} [subquery] - A subquery whose results will be limited
|
|
718
|
+
* @returns {WOQLQuery} A WOQLQuery whose results will be returned starting from
|
|
719
|
+
* the specified offset
|
|
720
|
+
* @example
|
|
721
|
+
* let [a, b, c] = vars("a", "b", "c")
|
|
722
|
+
* limit(100).triple(a, b, c)
|
|
723
|
+
* //subquery is an argument or a chained query
|
|
724
|
+
* limit(100,triple(a, b, c))
|
|
725
|
+
*/
|
|
726
|
+
export declare function limit(limit: number | string, subquery?: WOQLQuery): WOQLQuery;
|
|
727
|
+
/**
|
|
728
|
+
*
|
|
729
|
+
* Matches the regular expression defined in Patern against the Test string, to produce
|
|
730
|
+
* the matched patterns in Matches
|
|
731
|
+
* @param {string} pattern - string or variable using normal PCRE regular expression syntax with
|
|
732
|
+
* the exception that special characters have to be escaped twice (to enable transport in JSONLD)
|
|
733
|
+
* @param {string|Var} inputVarName - string or variable containing the string to be tested for
|
|
734
|
+
* patterns with the regex
|
|
735
|
+
* @param {string|array|object|Var} resultVarList - variable representing the list of matches
|
|
736
|
+
* or a list of strings or variables
|
|
737
|
+
* @returns {WOQLQuery} A WOQLQuery which contains the Regular Expression pattern
|
|
738
|
+
* matching expression
|
|
739
|
+
* @example
|
|
740
|
+
* let [All, Sub] = vars("All", "Sub")
|
|
741
|
+
* WOQL.re("h(.).*", "hello", [All, Sub])
|
|
742
|
+
* //e contains 'e', llo contains 'llo'
|
|
743
|
+
* //p is a regex pattern (.*) using normal regular expression syntax, the only unusual
|
|
744
|
+
* thing is that special characters have to be escaped twice, s is the string to be matched
|
|
745
|
+
* and m is a list of matches:
|
|
746
|
+
*/
|
|
747
|
+
export declare function re(pattern: string, inputVarName: string | Var, resultVarList: string | any[] | object | Var): WOQLQuery;
|
|
748
|
+
export declare function regexp(pattern: any, inputVarName: any, resultVarList: any): import("./query/woqlQuery");
|
|
749
|
+
/**
|
|
750
|
+
*
|
|
751
|
+
* Calculates the length of the list in va and stores it in vb
|
|
752
|
+
* @param {string|array} inputVarList - Either a variable representing a list or a list of
|
|
753
|
+
* variables or literals
|
|
754
|
+
* @param {string|Var} resultVarName - A variable in which the length of the list is stored or
|
|
755
|
+
* the length of the list as a non-negative integer
|
|
756
|
+
* @returns {WOQLQuery} A WOQLQuery which contains the Length pattern matching expression
|
|
757
|
+
* @example
|
|
758
|
+
* let [count] = vars("count")
|
|
759
|
+
* length(["john", "joe", "frank"], count)
|
|
760
|
+
*/
|
|
761
|
+
export declare function length(inputVarList: string | any[], resultVarName: string | Var): WOQLQuery;
|
|
762
|
+
/**
|
|
763
|
+
*
|
|
764
|
+
* Logical negation of the contained subquery - if the subquery matches, the query
|
|
765
|
+
* will fail to match
|
|
766
|
+
* @param {string | WOQLQuery} [subquery] - A subquery which will be negated
|
|
767
|
+
* @returns {WOQLQuery} A WOQLQuery object containing the negated sub Query
|
|
768
|
+
* @example
|
|
769
|
+
* let [subject, label] = vars("subject", "label")
|
|
770
|
+
* not().triple(subject, 'label', label)
|
|
771
|
+
*/
|
|
772
|
+
export declare function not(subquery?: string | WOQLQuery): WOQLQuery;
|
|
773
|
+
/**
|
|
774
|
+
* Results in one solution of the subqueries
|
|
775
|
+
* @param {string| WOQLQuery } [subquery] - WOQL Query objects
|
|
776
|
+
* @returns {WOQLQuery} A WOQLQuery object containing the once sub Query
|
|
777
|
+
*/
|
|
778
|
+
export declare function once(subquery?: string | WOQLQuery): WOQLQuery;
|
|
779
|
+
/**
|
|
780
|
+
* Runs the query without backtracking on side-effects
|
|
781
|
+
* @param {string| WOQLQuery } [subquery] - WOQL Query objects
|
|
782
|
+
* @returns {WOQLQuery} A WOQLQuery object containing the immediately sub Query
|
|
783
|
+
*/
|
|
784
|
+
export declare function immediately(subquery?: string | WOQLQuery): WOQLQuery;
|
|
785
|
+
/**
|
|
786
|
+
* Creates a count of the results of the query
|
|
787
|
+
* @param {string|number|Var} countVarName - variable or integer count
|
|
788
|
+
* @param {WOQLQuery} [subquery]
|
|
789
|
+
* @returns {WOQLQuery} A WOQLQuery object containing the count sub Query
|
|
790
|
+
* @example
|
|
791
|
+
* let [count, Person] = vars("count", "Person")
|
|
792
|
+
* WOQL.count(count).triple(Person, "rdf:type", "@schema:Person")
|
|
793
|
+
*/
|
|
794
|
+
export declare function count(countVarName: string | number | Var, subquery?: WOQLQuery): WOQLQuery;
|
|
795
|
+
/**
|
|
796
|
+
*
|
|
797
|
+
* Casts the value of Input to a new value of type Type and stores the result in CastVar
|
|
798
|
+
* @param {string|number|object|Var} varName - Either a single variable or a
|
|
799
|
+
* literal of any basic type
|
|
800
|
+
* @param {string|Var} varType - Either a variable or a basic datatype (xsd / xdd)
|
|
801
|
+
* @param {string|Var} resultVarName - save the return variable
|
|
802
|
+
* @returns {WOQLQuery} A WOQLQuery which contains the casting expression
|
|
803
|
+
* @example
|
|
804
|
+
* let [time] = vars("time")
|
|
805
|
+
* cast("22/3/98", "xsd:dateTime", time)
|
|
806
|
+
*/
|
|
807
|
+
export declare function typecast(varName: string | number | object | Var, varType: string | Var, resultVarName: string | Var): WOQLQuery;
|
|
808
|
+
export declare function cast(varName: any, varType: any, resultVarName: any): import("./query/woqlQuery");
|
|
809
|
+
/**
|
|
810
|
+
* Orders the results of the contained subquery by a precedence list of variables
|
|
811
|
+
* @param {...string|...Var|...array} varNames - A sequence of variables,
|
|
812
|
+
* by which to order the results,
|
|
813
|
+
* each optionally followed by either “asc” or “desc” to represent order as a list, by default
|
|
814
|
+
* it will sort the variable in ascending order
|
|
815
|
+
* @returns {WOQLQuery} A WOQLQuery which contains the ordering expression
|
|
816
|
+
* @example
|
|
817
|
+
* let [A, B, C] = vars("A", "B", "C")
|
|
818
|
+
* WOQL.order_by(A, [B, "asc"], [C, "desc"]).triple(A, B, C);
|
|
819
|
+
*/
|
|
820
|
+
export declare function order_by(...varNames: any[]): WOQLQuery;
|
|
821
|
+
/**
|
|
822
|
+
*
|
|
823
|
+
* Groups the results of the contained subquery on the basis of identical values for Groupvars,
|
|
824
|
+
* extracts the patterns defined in PatternVars and stores the results in GroupedVar.
|
|
825
|
+
* See also {@link /docs/group-query-results/ How to Group Results in WOQL}
|
|
826
|
+
* @param {array|string|Var} varList - Either a single variable or an array of variables
|
|
827
|
+
* @param {array|string|Var} patternVars - Either a single variable or an array of variables
|
|
828
|
+
* @param {string|Var} resultVarName - output variable name
|
|
829
|
+
* @param {WOQLQuery} [subquery] - The query whose results will be grouped
|
|
830
|
+
* @returns {WOQLQuery} A WOQLQuery which contains the grouping expression
|
|
831
|
+
* @example
|
|
832
|
+
* //subquery is an argument or a chained query
|
|
833
|
+
* let [age, last_name, first_name, age_group, person] = vars("age", "last name", "first name",
|
|
834
|
+
* "age group", "person")
|
|
835
|
+
* group_by(age, [last_name, first_name], age_group)
|
|
836
|
+
* .triple(person, "first_name", first_name)
|
|
837
|
+
* .triple(person, "last_name", last_name)
|
|
838
|
+
* .triple(person, "age", age)
|
|
839
|
+
* OR extract a simple list of last_name in age_group that can be
|
|
840
|
+
* used for example with member()
|
|
841
|
+
* group_by([], last_name, age_group)
|
|
842
|
+
* .triple(person, "first_name", first_name)
|
|
843
|
+
*/
|
|
844
|
+
export declare function group_by(varList: any[] | string | Var, patternVars: any[] | string | Var, resultVarName: string | Var, subquery?: WOQLQuery): WOQLQuery;
|
|
845
|
+
/**
|
|
846
|
+
*
|
|
847
|
+
* A function that always matches, always returns true
|
|
848
|
+
* @returns {WOQLQuery} A WOQLQuery object containing the true value that will match any pattern
|
|
849
|
+
* @example
|
|
850
|
+
* when(true()).triple("a", "b", "c")
|
|
851
|
+
*/
|
|
852
|
+
declare function _true(): WOQLQuery;
|
|
853
|
+
export { _true as true };
|
|
854
|
+
/**
|
|
855
|
+
*
|
|
856
|
+
* Performs a path regular expression match on the graph
|
|
857
|
+
* @param {string|Var} subject - An IRI or variable that refers to an IRI representing the subject,
|
|
858
|
+
* i.e. the starting point of the path
|
|
859
|
+
* @param {string} pattern -(string) - A path regular expression describing a pattern through
|
|
860
|
+
* multiple edges of the graph (see: https://terminusdb.com/docs/path-query-reference-guide)
|
|
861
|
+
* @param {string|Var} object - An IRI or variable that refers to an IRI representing the object,
|
|
862
|
+
* i.e. ending point of the path
|
|
863
|
+
* @param {string|Var} [resultVarName] - A variable in which the actual paths
|
|
864
|
+
* traversed will be stored
|
|
865
|
+
* @returns {WOQLQuery} - A WOQLQuery which contains the path regular expression matching expression
|
|
866
|
+
* @example
|
|
867
|
+
* let [person, grand_uncle, lineage] = vars("person", "grand uncle", "lineage")
|
|
868
|
+
* path(person, "((father|mother) {2,2}), brother)", grand_uncle, lineage)
|
|
869
|
+
*/
|
|
870
|
+
export declare function path(subject: string | Var, pattern: string, object: string | Var, resultVarName?: string | Var): WOQLQuery;
|
|
871
|
+
/**
|
|
872
|
+
*
|
|
873
|
+
* Calculates the size in bytes of the contents of the resource identified in ResourceID
|
|
874
|
+
* @param {string|Var} resourceId - A valid resource identifier string (can refer to any graph /
|
|
875
|
+
* branch / commit / db)
|
|
876
|
+
* @param {string|Var} resultVarName - The variable name
|
|
877
|
+
* @example
|
|
878
|
+
* let [varSize] = vars("varSize")
|
|
879
|
+
* size("admin/minecraft/local/branch/main/instance/main", varSize)
|
|
880
|
+
* //returns the number of bytes in the main instance graph on the main branch
|
|
881
|
+
*/
|
|
882
|
+
export declare function size(resourceId: string | Var, resultVarName: string | Var): import("./query/woqlQuery");
|
|
883
|
+
/**
|
|
884
|
+
*
|
|
885
|
+
* Calculates the number of triples of the contents of the resource identified in ResourceID
|
|
886
|
+
* @param {string|Var} resourceId - A valid resource identifier string (can refer to any graph /
|
|
887
|
+
* branch / commit / db)
|
|
888
|
+
* @param {string|number|Var} tripleCount - An integer literal with the size in bytes or a
|
|
889
|
+
* variable containing that integer
|
|
890
|
+
* @returns {WOQLQuery} A WOQLQuery which contains the size expression
|
|
891
|
+
* @example
|
|
892
|
+
* let [count] = vars("count")
|
|
893
|
+
* triple_count("admin/minecraft/local/_commits", count)
|
|
894
|
+
* //returns the number of bytes in the local commit graph
|
|
895
|
+
*/
|
|
896
|
+
export declare function triple_count(resourceId: string | Var, tripleCount: string | number | Var): WOQLQuery;
|
|
897
|
+
/**
|
|
898
|
+
*
|
|
899
|
+
* Returns true if 'elementId' is of type 'elementType', according to the current DB schema
|
|
900
|
+
* @param {string|Var} elementId - the id of a schema graph element
|
|
901
|
+
* @param {string|Var} elementType - the element type
|
|
902
|
+
* @returns {WOQLQuery} A WOQLQuery object containing the type_of pattern matching rule
|
|
903
|
+
*
|
|
904
|
+
*/
|
|
905
|
+
export declare function type_of(elementId: string | Var, elementType: string | Var): WOQLQuery;
|
|
906
|
+
/**
|
|
907
|
+
*
|
|
908
|
+
* Generates a query that by default matches all triples in a graph identified by "graph"
|
|
909
|
+
* or in all the current terminusDB's graph
|
|
910
|
+
* @param {string | boolean} [graph] - false or the resource identifier of a graph possible
|
|
911
|
+
* value are schema/{main - myschema - *} | instance/{main - myschema - *} |
|
|
912
|
+
* inference/{main - myschema - *}
|
|
913
|
+
* @param {string|Var} [subject] - The IRI of a triple’s subject or a variable,
|
|
914
|
+
* default value "v:Subject"
|
|
915
|
+
* @param {string|Var} [predicate] - The IRI of a property or a variable,
|
|
916
|
+
* default value "v:Predicate"
|
|
917
|
+
* @param {string|Var} [object] - The IRI of a node or a variable, or a literal,
|
|
918
|
+
* default value "v:Object"
|
|
919
|
+
* @returns {WOQLQuery} A WOQLQuery which contains the pattern matching expression
|
|
920
|
+
* @example
|
|
921
|
+
* star("schema/main")
|
|
922
|
+
* //will return every triple in schema/main graph
|
|
923
|
+
*/
|
|
924
|
+
export declare function star(graph?: string | boolean, subject?: string | Var, predicate?: string | Var, object?: string | Var): WOQLQuery;
|
|
925
|
+
/**
|
|
926
|
+
*
|
|
927
|
+
* Generates a query that by default matches all triples in a graph - identical to
|
|
928
|
+
* star() except for order of arguments
|
|
929
|
+
* @param {string|Var} [subject] - The IRI of a triple’s subject or a variable
|
|
930
|
+
* @param {string|Var} [predicate] - The IRI of a property or a variable
|
|
931
|
+
* @param {string|Var} [object] - The IRI of a node or a variable, or a literal
|
|
932
|
+
* @param {typedef.GraphRef} [graphRef] - the resource identifier of a graph possible
|
|
933
|
+
* value are schema/{main - myschema - *} | instance/{main - myschema - *} |
|
|
934
|
+
* inference/{main - myschema - *}
|
|
935
|
+
* @returns {WOQLQuery} - A WOQLQuery which contains the pattern matching expression
|
|
936
|
+
* all("mydoc")
|
|
937
|
+
* //will return every triple in the instance/main graph that has "doc:mydoc" as its subject
|
|
938
|
+
*/
|
|
939
|
+
export declare function all(subject?: string | Var, predicate?: string | Var, object?: string | Var, graphRef?: typedef.GraphRef): WOQLQuery;
|
|
940
|
+
/**
|
|
941
|
+
*
|
|
942
|
+
* Specifies the identity of a node that can then be used in subsequent builder functions.
|
|
943
|
+
* Note that node() requires subsequent chained functions to complete the triples / quads
|
|
944
|
+
* that it produces - by itself it only generates the subject.
|
|
945
|
+
* @param {string|Var} nodeid - The IRI of a node or a variable containing an IRI which will
|
|
946
|
+
* be the subject of the builder functions
|
|
947
|
+
* @param {typedef.FuntionType} [chainType] - Optional type of builder function to build
|
|
948
|
+
* (default is triple)
|
|
949
|
+
* @returns {WOQLQuery} - A WOQLQuery which contains the partial Node pattern matching expression
|
|
950
|
+
* @example
|
|
951
|
+
* node("mydoc").label("my label")
|
|
952
|
+
* //equivalent to triple("mydoc", "label", "my label")
|
|
953
|
+
*/
|
|
954
|
+
export declare function node(nodeid: string | Var, chainType?: typedef.FuntionType): WOQLQuery;
|
|
955
|
+
/**
|
|
956
|
+
* Inserts a single triple into the database declaring the Node to have type Type,
|
|
957
|
+
* optionally into the specified graph
|
|
958
|
+
* @param {string|Var} classId - IRI string or variable containing
|
|
959
|
+
* the IRI of the node to be inserted
|
|
960
|
+
* @param {string|Var} classType - IRI string or variable containing the IRI of the
|
|
961
|
+
* type of the node (class/document name)
|
|
962
|
+
* @param {typedef.GraphRef} [graphRef] - Optional Graph resource identifier
|
|
963
|
+
* @returns {WOQLQuery} A WOQLQuery which contains the insert expression
|
|
964
|
+
* @example
|
|
965
|
+
* insert("mydoc", "MyType")
|
|
966
|
+
* //equivalent to add_triple("mydoc", "rdf:type", "@schema:MyType")
|
|
967
|
+
*/
|
|
968
|
+
export declare function insert(classId: string | Var, classType: string | Var, graphRef?: typedef.GraphRef): WOQLQuery;
|
|
969
|
+
/**
|
|
970
|
+
* Sets the graph resource ID that will be used for subsequent chained function calls
|
|
971
|
+
* @param {typedef.GraphRef} [graphRef] Resource String identifying the graph which will
|
|
972
|
+
* be used for subsequent chained schema calls
|
|
973
|
+
* @returns {WOQLQuery} A WOQLQuery which contains the partial Graph pattern matching expression
|
|
974
|
+
* @example
|
|
975
|
+
* WOQL.graph("schema")
|
|
976
|
+
* //equivalent to add_quad("MyClass", "label", "My Class Label", "schema/main")
|
|
977
|
+
*/
|
|
978
|
+
export declare function graph(graphRef?: typedef.GraphRef): WOQLQuery;
|
|
979
|
+
/**
|
|
980
|
+
* Deletes all triples in the passed graph (defaults to instance/main)
|
|
981
|
+
* @param {typedef.GraphRef} [graphRef] - Resource String identifying the graph from
|
|
982
|
+
* which all triples will be removed
|
|
983
|
+
* @returns {WOQLQuery} - A WOQLQuery which contains the deletion expression
|
|
984
|
+
* @example
|
|
985
|
+
* nuke("schema/main")
|
|
986
|
+
* //will delete everything from the schema/main graph
|
|
987
|
+
*/
|
|
988
|
+
export declare function nuke(graphRef?: typedef.GraphRef): WOQLQuery;
|
|
989
|
+
/**
|
|
990
|
+
* Generates an empty WOQLQuery object
|
|
991
|
+
* @returns {WOQLQuery}
|
|
992
|
+
* @example
|
|
993
|
+
* let q = query()
|
|
994
|
+
* //then q.triple(1, 1) ...
|
|
995
|
+
*/
|
|
996
|
+
export declare function query(): WOQLQuery;
|
|
997
|
+
/**
|
|
998
|
+
* Generates a WOQLQuery object from the passed WOQL JSON - if an argument is passed,
|
|
999
|
+
* the query object is created from it, if none is passed, the current state is
|
|
1000
|
+
* returned as a JSON-LD
|
|
1001
|
+
* @param {object} [JSON_LD] - JSON-LD woql document encoding a query
|
|
1002
|
+
* @returns {WOQLQuery | object} either a JSON-LD or a WOQLQuery object
|
|
1003
|
+
*
|
|
1004
|
+
* json version of query for passing to api
|
|
1005
|
+
*/
|
|
1006
|
+
export declare function json(JSON_LD?: object): WOQLQuery | object;
|
|
1007
|
+
/**
|
|
1008
|
+
* get the predefined library query [WOQLLibrary](/api/woqlLibrary.js?id=WOQLLibrary)
|
|
1009
|
+
* @returns {WOQLLibrary} WOQLLibrary object
|
|
1010
|
+
* @example
|
|
1011
|
+
* //get commits older than the specified commit id
|
|
1012
|
+
* const query = WOQL.lib().previousCommits('m8vpxewh2aovfauebfkbzwmj4qwr5lb')
|
|
1013
|
+
*
|
|
1014
|
+
* //return the commits of a specific branch starting from the head
|
|
1015
|
+
* //you can add the limit (how many results to return.) and the start point
|
|
1016
|
+
* //if a timestamp is given, gets the commits before the specified timestamp
|
|
1017
|
+
* //WOQL.lib().commits(branch='main',limit=0,start=0,timestamp=0)
|
|
1018
|
+
*
|
|
1019
|
+
* const query = WOQL.lib().commits('main',10,2,1630683082.9278786)
|
|
1020
|
+
*
|
|
1021
|
+
* //return the branches list with the timestamp and commits id
|
|
1022
|
+
* const query = WOQL.lib().branches()
|
|
1023
|
+
*/
|
|
1024
|
+
export declare function lib(): WOQLLibrary;
|
|
1025
|
+
/**
|
|
1026
|
+
* Generates explicitly a JSON-LD string literal from the input
|
|
1027
|
+
* @param {string | boolean | number} val - any primitive literal type
|
|
1028
|
+
* @returns {string|Var} - A JSON-LD string literal
|
|
1029
|
+
* @example
|
|
1030
|
+
* string(1)
|
|
1031
|
+
* //returns { "@type": "xsd:string", "@value": "1" }
|
|
1032
|
+
*/
|
|
1033
|
+
export declare function string(val: string | boolean | number): string | Var;
|
|
1034
|
+
/**
|
|
1035
|
+
* Generates explicitly a JSON-LD string literal from the input
|
|
1036
|
+
* @param {string} val - any literal type
|
|
1037
|
+
* @param {string} type - an xsd or xdd type
|
|
1038
|
+
* @returns {Var} - A JSON-LD literal
|
|
1039
|
+
* @example
|
|
1040
|
+
* literal(1, "nonNegativeInteger")
|
|
1041
|
+
* //returns { "@type": "xsd:nonNegativeInteger", "@value": 1 }
|
|
1042
|
+
*/
|
|
1043
|
+
export declare function literal(val: string, type: string): Var;
|
|
1044
|
+
/**
|
|
1045
|
+
* Generates explicitly a JSON-LD literal date from the imput
|
|
1046
|
+
* @param {string} date - any date format string (YYYY-MM-DD)
|
|
1047
|
+
* @returns {Var} - A JSON-LD literal date
|
|
1048
|
+
* @example
|
|
1049
|
+
* date("2022-10-02")
|
|
1050
|
+
* //returns { "@type": "xsd:date", "@value": "2022-10-02" }
|
|
1051
|
+
*/
|
|
1052
|
+
export declare function date(date: string): Var;
|
|
1053
|
+
/**
|
|
1054
|
+
* Generates explicitly a JSON-LD literal datetime from the imput
|
|
1055
|
+
* @param {string} datetime - any datetime format string (YYYY-MM-DDThh-mm-ssZ)
|
|
1056
|
+
* @returns {Var} - A JSON-LD literal datetime
|
|
1057
|
+
* @example
|
|
1058
|
+
* datetime("2022-10-19T14:17:12Z")
|
|
1059
|
+
* //returns { "@type": "xsd:dateTime", "@value": "2022-10-19T14:17:12Z" }
|
|
1060
|
+
*/
|
|
1061
|
+
export declare function datetime(datetime: string): Var;
|
|
1062
|
+
/**
|
|
1063
|
+
* Generates explicitly a JSON-LD literal boolean from the input
|
|
1064
|
+
* @param {boolean} bool - true | false
|
|
1065
|
+
* @returns {Var} - A JSON-LD literal boolean
|
|
1066
|
+
* @example
|
|
1067
|
+
* boolean(true)
|
|
1068
|
+
* //returns { "@type": "xsd:boolean", "@value": true }
|
|
1069
|
+
*/
|
|
1070
|
+
export declare function boolean(bool: boolean): Var;
|
|
1071
|
+
/**
|
|
1072
|
+
* Explicitly sets a value to be an IRI - avoiding automatic type marshalling
|
|
1073
|
+
* @param {string} val string which will be treated as an IRI
|
|
1074
|
+
* @returns {Var} - A JSON-LD IRI value
|
|
1075
|
+
*/
|
|
1076
|
+
export declare function iri(val: string): Var;
|
|
1077
|
+
/**
|
|
1078
|
+
* Generates javascript variables for use as WOQL variables within a query
|
|
1079
|
+
* @param {...string} varNames
|
|
1080
|
+
* @returns {Array<Var>} an array of javascript variables which can be dereferenced using the
|
|
1081
|
+
* array destructuring operation
|
|
1082
|
+
* @example
|
|
1083
|
+
* const [a, b, c] = WOQL.vars("a", "b", "c")
|
|
1084
|
+
* //a, b, c are javascript variables which can be used as WOQL variables in subsequent queries
|
|
1085
|
+
*/
|
|
1086
|
+
export declare function vars(...varNames: string[]): Array<Var>;
|
|
1087
|
+
/**
|
|
1088
|
+
* Generates unique javascript variables for use as WOQL variables within a query
|
|
1089
|
+
* @param {...string} varNames
|
|
1090
|
+
* @returns {Array<Var>} an array of javascript variables which can be dereferenced using the
|
|
1091
|
+
* array destructuring operation
|
|
1092
|
+
* @example
|
|
1093
|
+
* const [a, b, c] = WOQL.vars("a", "b", "c")
|
|
1094
|
+
* //a, b, c are javascript variables that are unique WOQL variables
|
|
1095
|
+
*/
|
|
1096
|
+
export declare function vars_unique(...varNames: string[]): Array<Var>;
|
|
1097
|
+
/**
|
|
1098
|
+
* Sets the unique variable counter to a specific value
|
|
1099
|
+
* This is particularly useful together with select() for locally scoped variables
|
|
1100
|
+
* @param {number} start - starting value
|
|
1101
|
+
*/
|
|
1102
|
+
export declare function vars_unique_reset_start(start: number): void;
|
|
1103
|
+
/**
|
|
1104
|
+
* Produces an encoded form of a document that can be used by a WOQL operation
|
|
1105
|
+
* such as `WOQL.insert_document` or with `WOQL.dot` operators
|
|
1106
|
+
* @param {object} object - Document to encode
|
|
1107
|
+
* @returns {Var} The encoded document
|
|
1108
|
+
* @example
|
|
1109
|
+
* WOQL.insert_document(WOQL.doc({ "@type": "Person", name: "Newperson" }), "v:docId")
|
|
1110
|
+
*/
|
|
1111
|
+
export declare function doc(object: object): Var;
|
|
1112
|
+
/**
|
|
1113
|
+
* Use instead to run your query woqlclient.query('myWOQLQuery')
|
|
1114
|
+
* @deprecated
|
|
1115
|
+
* Gets/Sets woqlClient
|
|
1116
|
+
* @param {WOQLClient}
|
|
1117
|
+
* @returns {WOQLClient}
|
|
1118
|
+
*/
|
|
1119
|
+
export declare function client(client: any): WOQLClient;
|
|
1120
|
+
/**
|
|
1121
|
+
*
|
|
1122
|
+
* @param {...string} varNames
|
|
1123
|
+
* @returns {Record<string, Var>}
|
|
1124
|
+
* @example
|
|
1125
|
+
* const v = WOQL.Vars('var01', 'var02', 'var03');
|
|
1126
|
+
* triple(v.var01, v.var02, v.var03)
|
|
1127
|
+
*/
|
|
1128
|
+
export declare function Vars(...varNames: string[]): Record<string, Var>;
|
|
1129
|
+
/**
|
|
1130
|
+
*
|
|
1131
|
+
* Produces variables with unique names by appending an incrementing counter to each variable name.
|
|
1132
|
+
* This is particularly useful together with select() for locally scoped variables
|
|
1133
|
+
*
|
|
1134
|
+
* @param {...string} varNames
|
|
1135
|
+
* @returns {Record<string, Var>}
|
|
1136
|
+
* @example
|
|
1137
|
+
* // Creates variables like "a_4", "b_5" - unique even with same input names
|
|
1138
|
+
* const v = WOQL.VarsUnique('var01', 'var02', 'var03');
|
|
1139
|
+
* triple(v.var01, v.var02, v.var03) // locally scoped
|
|
1140
|
+
*/
|
|
1141
|
+
export declare function VarsUnique(...varNames: string[]): Record<string, Var>;
|
|
1142
|
+
/**
|
|
1143
|
+
*
|
|
1144
|
+
* query module
|
|
1145
|
+
* allow you to use WOQL words as top level functions
|
|
1146
|
+
* @param {*} auto_eval
|
|
1147
|
+
* @returns {WOQLQuery} WOQLQuery
|
|
1148
|
+
*/
|
|
1149
|
+
export declare function emerge(auto_eval: any): WOQLQuery;
|
|
1150
|
+
/**
|
|
1151
|
+
* Update a pattern matching rule for the triple (Subject, Predicate, oldObjValue) with the
|
|
1152
|
+
* new one (Subject, Predicate, newObjValue). Replaces old triple with new triple
|
|
1153
|
+
* @param {string|Var} subject - The IRI of a triple’s subject or a variable
|
|
1154
|
+
* @param {string|Var} predicate - The IRI of a property or a variable
|
|
1155
|
+
* @param {string|Var} newObjValue - The value to update or a literal
|
|
1156
|
+
* @param {string|Var} oldObjValue - The old value of the object
|
|
1157
|
+
* @returns {WOQLQuery} A WOQLQuery which contains the a Update Triple Statement
|
|
1158
|
+
* @example
|
|
1159
|
+
* let [newValue, oldValue] = WOQL.vars("newValue", "oldValue")
|
|
1160
|
+
* WOQL.update_triple("Project/1", "name", newValue, oldValue)
|
|
1161
|
+
*/
|
|
1162
|
+
export declare function update_triple(subject: string | Var, predicate: string | Var, newObjValue: string | Var, oldObjValue: string | Var): WOQLQuery;
|
|
1163
|
+
/**
|
|
1164
|
+
* Update a pattern matching rule for the quad [S, P, O, G] (Subject, Predicate, Object, Graph)
|
|
1165
|
+
* @param {string|Var} subject - The IRI of a triple’s subject or a variable
|
|
1166
|
+
* @param {string|Var} predicate - The IRI of a property or a variable
|
|
1167
|
+
* @param {string|Var} newObject - The value to update or a literal
|
|
1168
|
+
* @param {typedef.GraphRef} graphRef - A valid graph resource identifier string
|
|
1169
|
+
* @returns {WOQLQuery} A WOQLQuery which contains the a Update Quad Statement
|
|
1170
|
+
* @example
|
|
1171
|
+
* let [newObj, oldObj] = WOQL.vars("newObj", "oldObj")
|
|
1172
|
+
* WOQL.update_quad("Project/1", "name", newObj, oldObj, "schema/main")
|
|
1173
|
+
*/
|
|
1174
|
+
export declare function update_quad(subject: string | Var, predicate: string | Var, newObject: string | Var, graphRef: typedef.GraphRef): WOQLQuery;
|
|
1175
|
+
/**
|
|
1176
|
+
* Creates a pattern matching rule for a triple [Subject, Predicate, Object]
|
|
1177
|
+
* add extra information about the type of the value object
|
|
1178
|
+
* @param {string|Var} subject - The IRI of a triple’s subject or a variable
|
|
1179
|
+
* @param {string|Var} predicate - The IRI of a property or a variable
|
|
1180
|
+
* @param {string | number | boolean | Var} objValue - an specific value
|
|
1181
|
+
* @returns {WOQLQuery} A WOQLQuery which contains the a quad or a triple Statement
|
|
1182
|
+
*/
|
|
1183
|
+
export declare function value(subject: string | Var, predicate: string | Var, objValue: string | number | boolean | Var): WOQLQuery;
|
|
1184
|
+
/**
|
|
1185
|
+
* Creates a pattern matching rule for a triple [Subject, Predicate, Object]
|
|
1186
|
+
* @param {string|Var} subject - The IRI of a triple’s subject or a variable
|
|
1187
|
+
* @param {string|Var} predicate - The IRI of a property or a variable
|
|
1188
|
+
* @param {string|Var} object - The IRI of a node or a variable, or a literal
|
|
1189
|
+
* @returns {WOQLQuery} A WOQLQuery which contains the a quad or a triple Statement
|
|
1190
|
+
*/
|
|
1191
|
+
export declare function link(subject: string | Var, predicate: string | Var, object: string | Var): WOQLQuery;
|
|
1192
|
+
/**
|
|
1193
|
+
* Extract the value of a key in a bound document.
|
|
1194
|
+
* @param {string|Var} document - Document which is being accessed.
|
|
1195
|
+
* @param {string|Var} field - The field from which the document which is being accessed.
|
|
1196
|
+
* @param {string|Var} value - The value for the document and field.
|
|
1197
|
+
* @returns {WOQLQuery} A WOQLQuery which contains the a dot Statement
|
|
1198
|
+
* @example
|
|
1199
|
+
* // Use either "v:personName" and "v:doc", OR `personName` and `doc` with variables:
|
|
1200
|
+
* // `let [personName, doc] = WOQL.vars("personName", "doc")`
|
|
1201
|
+
* and(
|
|
1202
|
+
* WOQL.eq("v:doc", WOQL.doc({ "@type": "Person", name: "Alice" })),
|
|
1203
|
+
* WOQL.dot("v:doc", "name", "v:personName")
|
|
1204
|
+
* )
|
|
1205
|
+
* // extracts the "name" field value from the document into personName variable
|
|
1206
|
+
*/
|
|
1207
|
+
export declare function dot(document: string | Var, field: string | Var, value: string | Var): WOQLQuery;
|
|
1208
|
+
/**
|
|
1209
|
+
* Computes the set difference between two lists (elements in listA but not in listB)
|
|
1210
|
+
* @param {string|Var|array} listA - First list or variable
|
|
1211
|
+
* @param {string|Var|array} listB - Second list or variable
|
|
1212
|
+
* @param {string|Var} result - Variable to store the result
|
|
1213
|
+
* @returns {WOQLQuery} A WOQLQuery which contains the SetDifference expression
|
|
1214
|
+
* @example
|
|
1215
|
+
* let [result] = vars("result")
|
|
1216
|
+
* set_difference(["a", "b", "c"], ["b", "d"], result) // result = ["a", "c"]
|
|
1217
|
+
*/
|
|
1218
|
+
export declare function set_difference(listA: string | Var | any[], listB: string | Var | any[], result: string | Var): WOQLQuery;
|
|
1219
|
+
/**
|
|
1220
|
+
* Computes the set intersection between two lists (elements common to both)
|
|
1221
|
+
* @param {string|Var|array} listA - First list or variable
|
|
1222
|
+
* @param {string|Var|array} listB - Second list or variable
|
|
1223
|
+
* @param {string|Var} result - Variable to store the result
|
|
1224
|
+
* @returns {WOQLQuery} A WOQLQuery which contains the SetIntersection expression
|
|
1225
|
+
* @example
|
|
1226
|
+
* let [result] = vars("result")
|
|
1227
|
+
* set_intersection(["a", "b", "c"], ["b", "c", "d"], result) // result = ["b", "c"]
|
|
1228
|
+
*/
|
|
1229
|
+
export declare function set_intersection(listA: string | Var | any[], listB: string | Var | any[], result: string | Var): WOQLQuery;
|
|
1230
|
+
/**
|
|
1231
|
+
* Computes the set union of two lists (all unique elements from both lists)
|
|
1232
|
+
* @param {string|Var|array} listA - First list or variable
|
|
1233
|
+
* @param {string|Var|array} listB - Second list or variable
|
|
1234
|
+
* @param {string|Var} result - Variable to store the result
|
|
1235
|
+
* @returns {WOQLQuery} A WOQLQuery which contains the SetUnion expression
|
|
1236
|
+
* @example
|
|
1237
|
+
* let [result] = vars("result")
|
|
1238
|
+
* set_union(["a", "b"], ["b", "c"], result) // result = ["a", "b", "c"]
|
|
1239
|
+
*/
|
|
1240
|
+
export declare function set_union(listA: string | Var | any[], listB: string | Var | any[], result: string | Var): WOQLQuery;
|
|
1241
|
+
/**
|
|
1242
|
+
* Checks if an element is a member of a set
|
|
1243
|
+
* @param {string|number|Var} element - Element to check for membership
|
|
1244
|
+
* @param {string|Var|array} set - Set (list) to check membership in
|
|
1245
|
+
* @returns {WOQLQuery} A WOQLQuery which contains the SetMember expression
|
|
1246
|
+
* @example
|
|
1247
|
+
* let [result] = vars("result")
|
|
1248
|
+
* set_member("b", ["a", "b", "c"], result) // true if "b" is in the set
|
|
1249
|
+
*/
|
|
1250
|
+
export declare function set_member(element: string | number | Var, set: string | Var | any[]): WOQLQuery;
|
|
1251
|
+
/**
|
|
1252
|
+
* Converts a list to a set by removing duplicates and sorting
|
|
1253
|
+
* @param {string|Var|array} list - List or variable containing a list
|
|
1254
|
+
* @param {string|Var} set - Variable to store the resulting set
|
|
1255
|
+
* @returns {WOQLQuery} A WOQLQuery which contains the ListToSet expression
|
|
1256
|
+
* @example
|
|
1257
|
+
* let [result] = vars("result")
|
|
1258
|
+
* list_to_set(["a", "b", "a", "c", "b"], result) // result = ["a", "b", "c"]
|
|
1259
|
+
* @example
|
|
1260
|
+
* let [mySet, isMember] = vars("mySet", "isMember")
|
|
1261
|
+
* and(
|
|
1262
|
+
* list_to_set(["a", "b", "a", "c"], mySet),
|
|
1263
|
+
* set_member("b", mySet),
|
|
1264
|
+
* opt().eq(is_member, "b-is-member")
|
|
1265
|
+
* ) // mySet = ["a", "b", "c"], "b" is a member, and is_member is set to "b-is-member"
|
|
1266
|
+
*/
|
|
1267
|
+
export declare function list_to_set(list: string | Var | any[], set: string | Var): WOQLQuery;
|