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,718 @@
|
|
|
1
|
+
export = WOQLLibrary;
|
|
2
|
+
/**
|
|
3
|
+
* @typedef {Object} WOQLQuery - WOQL Query Builder class
|
|
4
|
+
* @property {function} triple - Add a triple pattern
|
|
5
|
+
* @property {function} and - Logical AND
|
|
6
|
+
* @property {function} or - Logical OR
|
|
7
|
+
* @property {function} select - Select variables
|
|
8
|
+
* @property {function} ask - Ask query
|
|
9
|
+
* @property {function} limit - Limit results
|
|
10
|
+
* @property {function} offset - Offset results
|
|
11
|
+
* @property {function} start - Start query
|
|
12
|
+
* @property {function} path - Path query
|
|
13
|
+
* @property {function} subquery - Subquery
|
|
14
|
+
* @property {function} from - Graph specifier
|
|
15
|
+
* @property {function} eq - Equality
|
|
16
|
+
* @property {function} not - Negation
|
|
17
|
+
* @property {function} greaterThan - Greater than
|
|
18
|
+
* @property {function} lessThan - Less than
|
|
19
|
+
* @property {function} greaterThanOrEqual - Greater than or equal
|
|
20
|
+
* @property {function} lessThanOrEqual - Less than or equal
|
|
21
|
+
* @property {function} like - String pattern matching
|
|
22
|
+
* @property {function} plus - Addition
|
|
23
|
+
* @property {function} minus - Subtraction
|
|
24
|
+
* @property {function} times - Multiplication
|
|
25
|
+
* @property {function} divide - Division
|
|
26
|
+
* @property {function} count - Count aggregation
|
|
27
|
+
* @property {function} sum - Sum aggregation
|
|
28
|
+
* @property {function} min - Minimum aggregation
|
|
29
|
+
* @property {function} max - Maximum aggregation
|
|
30
|
+
* @property {function} avg - Average aggregation
|
|
31
|
+
* @property {function} groupBy - Group by
|
|
32
|
+
* @property {function} orderBy - Order by
|
|
33
|
+
* @property {function} asc - Ascending order
|
|
34
|
+
* @property {function} desc - Descending order
|
|
35
|
+
* @property {function} json - JSON object
|
|
36
|
+
* @property {function} id - IRI
|
|
37
|
+
* @property {function} string - String literal
|
|
38
|
+
* @property {function} datetime - DateTime literal
|
|
39
|
+
* @property {function} date - Date literal
|
|
40
|
+
* @property {function} time - Time literal
|
|
41
|
+
* @property {function} boolean - Boolean literal
|
|
42
|
+
* @property {function} integer - Integer literal
|
|
43
|
+
* @property {function} decimal - Decimal literal
|
|
44
|
+
* @property {function} double - Double literal
|
|
45
|
+
* @property {function} value - Value literal
|
|
46
|
+
* @property {function} var - Variable
|
|
47
|
+
* @property {function} v - Variable shorthand
|
|
48
|
+
* @property {function} doc - Document
|
|
49
|
+
* @property {function} class - Class
|
|
50
|
+
* @property {function} property - Property
|
|
51
|
+
* @property {function} comment - Comment
|
|
52
|
+
* @property {function} label - Label
|
|
53
|
+
* @property {function} prefix - Prefix
|
|
54
|
+
* @property {function} using - Using
|
|
55
|
+
* @property {function} optional - Optional
|
|
56
|
+
* @property {function} union - Union
|
|
57
|
+
* @property {function} filter - Filter
|
|
58
|
+
* @property {function} bind - Bind
|
|
59
|
+
* @property {function} exists - Exists
|
|
60
|
+
* @property {function} notExists - Not exists
|
|
61
|
+
* @property {function} graph - Graph
|
|
62
|
+
* @property {function} named - Named graph
|
|
63
|
+
* @property {function} values - Values
|
|
64
|
+
* @property {function} minus - Minus
|
|
65
|
+
* @property {function} service - Service
|
|
66
|
+
* @property {function} load - Load
|
|
67
|
+
* @property {function} clear - Clear
|
|
68
|
+
* @property {function} drop - Drop
|
|
69
|
+
* @property {function} add - Add
|
|
70
|
+
* @property {function} move - Move
|
|
71
|
+
* @property {function} copy - Copy
|
|
72
|
+
* @property {function} insert - Insert
|
|
73
|
+
* @property {function} delete - Delete
|
|
74
|
+
* @property {function} modify - Modify
|
|
75
|
+
* @property {function} construct - Construct
|
|
76
|
+
* @property {function} describe - Describe
|
|
77
|
+
*/
|
|
78
|
+
/**
|
|
79
|
+
* @license Apache Version 2
|
|
80
|
+
* @module WOQLLibrary
|
|
81
|
+
* @constructor WOQLLibrary
|
|
82
|
+
* @description Library Functions to manage the commits graph
|
|
83
|
+
* @example
|
|
84
|
+
* const woqlLib = WOQLLibrary()
|
|
85
|
+
* woqlLib.branches()
|
|
86
|
+
*
|
|
87
|
+
* //or you can call this functions using WOQL Class
|
|
88
|
+
* WOQL.lib().branches()
|
|
89
|
+
* */
|
|
90
|
+
declare class WOQLLibrary {
|
|
91
|
+
default_schema_resource: string;
|
|
92
|
+
default_commit_resource: string;
|
|
93
|
+
default_meta_resource: string;
|
|
94
|
+
masterdb_resource: string;
|
|
95
|
+
empty: string;
|
|
96
|
+
/**
|
|
97
|
+
* General Pattern 4: Retrieves Branches, Their ID, Head Commit ID, Head Commit Time
|
|
98
|
+
* (if present, new branches have no commits)
|
|
99
|
+
*/
|
|
100
|
+
branches(): import("./woqlQuery");
|
|
101
|
+
/**
|
|
102
|
+
* get all the commits of a specific branch
|
|
103
|
+
* if a timestamp is given, gets all the commits before the specified timestamp
|
|
104
|
+
* @param {string} [branch] - the branch name
|
|
105
|
+
* @param {number} [limit] - the max number of result
|
|
106
|
+
* @param {number} [start] - the start of the pagination
|
|
107
|
+
* @param {number} [timestamp] - Unix timestamp in seconds
|
|
108
|
+
*/
|
|
109
|
+
commits(branch?: string, limit?: number, start?: number, timestamp?: number): import("./woqlQuery");
|
|
110
|
+
/**
|
|
111
|
+
*get commits older than the specified commit id
|
|
112
|
+
* @param {string} [commit_id] - the commit id
|
|
113
|
+
* @param {number} [limit] - the max number of result
|
|
114
|
+
*/
|
|
115
|
+
previousCommits(commit_id?: string, limit?: number): import("./woqlQuery");
|
|
116
|
+
/**
|
|
117
|
+
* Finds the id of the very first commit in a database's history
|
|
118
|
+
*
|
|
119
|
+
* This is useful for finding information about when, by who and why the database was created
|
|
120
|
+
* The first commit is the only commit in the database that does not have a parent commit
|
|
121
|
+
*
|
|
122
|
+
*/
|
|
123
|
+
first_commit(): import("./woqlQuery");
|
|
124
|
+
/**
|
|
125
|
+
* Collect all rdf:List elements into a single array.
|
|
126
|
+
* Works in two modes:
|
|
127
|
+
* - Generator: If listVar is unbound, binds it to the array of all rdf:first values
|
|
128
|
+
* - Matching: If listVar is bound to an array, succeeds only if values match
|
|
129
|
+
* Uses group_by to collect all values in order (path queries return in hop-count order).
|
|
130
|
+
* @param {string} consSubject - Variable or IRI of the list cons cell (rdf:List head)
|
|
131
|
+
* @param {string} listVar - Variable to bind/match the resulting list values array
|
|
132
|
+
* @returns {WOQLQuery} Query that binds list as array to listVar (single binding)
|
|
133
|
+
* @example
|
|
134
|
+
* // Collect all task titles from a document's task list
|
|
135
|
+
* const query = WOQL.and(
|
|
136
|
+
* WOQL.triple("doc:Project/1", "tasks", "v:list_head"),
|
|
137
|
+
* WOQL.lib().rdflist_list("v:list_head", "v:all_tasks")
|
|
138
|
+
* );
|
|
139
|
+
* // Result: { bindings: [{ "v:all_tasks": ["Task A", "Task B", "Task C"] }] }
|
|
140
|
+
*/
|
|
141
|
+
rdflist_list(consSubject: string, listVar: string): WOQLQuery;
|
|
142
|
+
private _rdflist_peek_raw;
|
|
143
|
+
/**
|
|
144
|
+
* Get the first element of an rdf:List (peek operation).
|
|
145
|
+
* Works as generator (binds value) or matcher (checks if first element matches).
|
|
146
|
+
* @param {string} consSubject - Variable or IRI of the list cons cell
|
|
147
|
+
* @param {string} valueVar - Variable to bind the first value
|
|
148
|
+
* @returns {WOQLQuery} Query that binds first value to valueVar
|
|
149
|
+
* @example
|
|
150
|
+
* // Get the first task from a project's task list
|
|
151
|
+
* const query = WOQL.and(
|
|
152
|
+
* WOQL.triple("doc:Project/1", "tasks", "v:list_head"),
|
|
153
|
+
* WOQL.lib().rdflist_peek("v:list_head", "v:first_task")
|
|
154
|
+
* );
|
|
155
|
+
* // Result: { bindings: [{ "v:first_task": "Task A" }] }
|
|
156
|
+
*/
|
|
157
|
+
rdflist_peek(consSubject: string, valueVar: string): WOQLQuery;
|
|
158
|
+
/**
|
|
159
|
+
* Get the last element of an rdf:List
|
|
160
|
+
* Traverses to the final cons cell (whose rdf:rest is rdf:nil) and gets its rdf:first
|
|
161
|
+
* @param {string} consSubject - Variable or IRI of the list cons cell
|
|
162
|
+
* @param {string} valueVar - Variable to bind the last value
|
|
163
|
+
* @returns {WOQLQuery} Query that binds last value to valueVar
|
|
164
|
+
*/
|
|
165
|
+
rdflist_last(consSubject: string, valueVar: string): WOQLQuery;
|
|
166
|
+
private _rdflist_nth0_raw;
|
|
167
|
+
/**
|
|
168
|
+
* Get element at 0-indexed position in an rdf:List.
|
|
169
|
+
* Works as generator (binds value) or matcher (checks if element at index matches).
|
|
170
|
+
* @param {string} consSubject - Variable or IRI of the list cons cell
|
|
171
|
+
* @param {number|string} index - 0-based index (number or variable)
|
|
172
|
+
* @param {string} valueVar - Variable to bind the value at that index
|
|
173
|
+
* @returns {WOQLQuery} Query that binds value at index to valueVar
|
|
174
|
+
* @example
|
|
175
|
+
* // Get the second task (index 1) from a project's task list
|
|
176
|
+
* const query = WOQL.and(
|
|
177
|
+
* WOQL.triple("doc:Project/1", "tasks", "v:list_head"),
|
|
178
|
+
* WOQL.lib().rdflist_nth0("v:list_head", 1, "v:second_task")
|
|
179
|
+
* );
|
|
180
|
+
* // Result: { bindings: [{ "v:second_task": "Task B" }] }
|
|
181
|
+
*/
|
|
182
|
+
rdflist_nth0(consSubject: string, index: number | string, valueVar: string): WOQLQuery;
|
|
183
|
+
/**
|
|
184
|
+
* Get element at 1-indexed position in an rdf:List.
|
|
185
|
+
* Works as generator (binds value) or matcher (checks if element at index matches).
|
|
186
|
+
* @param {string} consSubject - Variable or IRI of the list cons cell
|
|
187
|
+
* @param {number|string} index - 1-based index (number or variable)
|
|
188
|
+
* @param {string} valueVar - Variable to bind the value at that index
|
|
189
|
+
* @returns {WOQLQuery} Query that binds value at index to valueVar
|
|
190
|
+
* @example
|
|
191
|
+
* // Get the second task (index 2, 1-based) from a project's task list
|
|
192
|
+
* const query = WOQL.and(
|
|
193
|
+
* WOQL.triple("doc:Project/1", "tasks", "v:list_head"),
|
|
194
|
+
* WOQL.lib().rdflist_nth1("v:list_head", 2, "v:second_task")
|
|
195
|
+
* );
|
|
196
|
+
* // Result: { bindings: [{ "v:second_task": "Task B" }] }
|
|
197
|
+
*/
|
|
198
|
+
rdflist_nth1(consSubject: string, index: number | string, valueVar: string): WOQLQuery;
|
|
199
|
+
private _rdflist_member_raw;
|
|
200
|
+
/**
|
|
201
|
+
* Traverse an rdf:List and yield each element as a separate binding (streaming).
|
|
202
|
+
* Works in two modes:
|
|
203
|
+
* - Generator: If value is unbound, yields one binding per list element
|
|
204
|
+
* - Matcher: If value is bound, succeeds only if value is a member of the list
|
|
205
|
+
* Ideal for large lists and streaming use cases.
|
|
206
|
+
* @param {string} consSubject - Variable or IRI of the list cons cell (rdf:List head)
|
|
207
|
+
* @param {string} value - Variable to bind each value, or value to check membership
|
|
208
|
+
* @returns {WOQLQuery} Query that yields/matches list elements
|
|
209
|
+
* @example
|
|
210
|
+
* // Stream all tasks from a project's task list (one binding per element)
|
|
211
|
+
* const query = WOQL.and(
|
|
212
|
+
* WOQL.triple("doc:Project/1", "tasks", "v:list_head"),
|
|
213
|
+
* WOQL.lib().rdflist_member("v:list_head", "v:task")
|
|
214
|
+
* );
|
|
215
|
+
* // Result: { bindings: [{ "v:task": "Task A" }, { "v:task": "Task B" }, ...] }
|
|
216
|
+
*/
|
|
217
|
+
rdflist_member(consSubject: string, value: string): WOQLQuery;
|
|
218
|
+
private _rdflist_length_raw;
|
|
219
|
+
/**
|
|
220
|
+
* Get the length of an rdf:List.
|
|
221
|
+
* Uses path query to traverse all rest links and count them.
|
|
222
|
+
* Works as generator (binds length) or matcher (checks if length matches).
|
|
223
|
+
* @param {string} consSubject - Variable or IRI of the list cons cell
|
|
224
|
+
* @param {string} lengthVar - Variable to bind the length
|
|
225
|
+
* @returns {WOQLQuery} Query that binds list length to lengthVar
|
|
226
|
+
* @example
|
|
227
|
+
* // Get the number of tasks in a project's task list
|
|
228
|
+
* const query = WOQL.and(
|
|
229
|
+
* WOQL.triple("doc:Project/1", "tasks", "v:list_head"),
|
|
230
|
+
* WOQL.lib().rdflist_length("v:list_head", "v:count")
|
|
231
|
+
* );
|
|
232
|
+
* // Result: { bindings: [{ "v:count": 3 }] }
|
|
233
|
+
*/
|
|
234
|
+
rdflist_length(consSubject: string, lengthVar: string): WOQLQuery;
|
|
235
|
+
/**
|
|
236
|
+
* Pop the first element from an rdf:List in-place.
|
|
237
|
+
* Removes the first element and promotes the second element to head position.
|
|
238
|
+
* The list head IRI remains unchanged - the second cons cell is removed.
|
|
239
|
+
* @param {string} consSubject - Variable or IRI of the list cons cell
|
|
240
|
+
* @param {string} valueVar - Variable to bind the popped value
|
|
241
|
+
* @returns {WOQLQuery} Query that pops first element and binds it to valueVar
|
|
242
|
+
* @example
|
|
243
|
+
* // Pop the first task from a project's task list
|
|
244
|
+
* const query = WOQL.and(
|
|
245
|
+
* WOQL.triple("doc:Project/1", "tasks", "v:list_head"),
|
|
246
|
+
* WOQL.lib().rdflist_pop("v:list_head", "v:first_task")
|
|
247
|
+
* );
|
|
248
|
+
* // Result: list [A, B, C] becomes [B, C], binds "A" to v:first_task
|
|
249
|
+
*/
|
|
250
|
+
rdflist_pop(consSubject: string, valueVar: string): WOQLQuery;
|
|
251
|
+
/**
|
|
252
|
+
* Push a new element to the front of an rdf:List in-place.
|
|
253
|
+
* Modifies the existing cons cell: moves old first value to a new cons cell,
|
|
254
|
+
* sets new value as rdf:first, and links to the new cons as rdf:rest.
|
|
255
|
+
* The list head IRI remains unchanged.
|
|
256
|
+
* @param {string|Var} consSubject - Variable or IRI of the list cons cell
|
|
257
|
+
* @param {string|Var} value - Value to push to the front
|
|
258
|
+
* @returns {WOQLQuery} Query that pushes value to front of list in-place
|
|
259
|
+
* @example
|
|
260
|
+
* // Push a new task to the front of a project's task list
|
|
261
|
+
* const query = WOQL.and(
|
|
262
|
+
* WOQL.triple("doc:Project/1", "tasks", "v:list_head"),
|
|
263
|
+
* WOQL.lib().rdflist_push("v:list_head", WOQL.string("New Task"))
|
|
264
|
+
* );
|
|
265
|
+
* // Result: list [A, B, C] becomes [New Task, A, B, C], head IRI unchanged
|
|
266
|
+
*/
|
|
267
|
+
rdflist_push(consSubject: string | Var, value: string | Var): WOQLQuery;
|
|
268
|
+
/**
|
|
269
|
+
* Append an element to the end of an rdf:List.
|
|
270
|
+
* Traverses to the last cell and adds new cell there.
|
|
271
|
+
* @param {string|Var} consSubject - Variable or IRI of the list head
|
|
272
|
+
* @param {string|Var} value - Value to append
|
|
273
|
+
* @param {string} [newCellVar] - Optional variable to bind the new cell
|
|
274
|
+
* @returns {WOQLQuery} Query that appends value to end of list
|
|
275
|
+
* @example
|
|
276
|
+
* // Append a new task to the end of a project's task list
|
|
277
|
+
* const query = WOQL.and(
|
|
278
|
+
* WOQL.triple("doc:Project/1", "tasks", "v:list_head"),
|
|
279
|
+
* WOQL.lib().rdflist_append("v:list_head", WOQL.string("New Task"))
|
|
280
|
+
* );
|
|
281
|
+
* // Result: appends "New Task" to end of list
|
|
282
|
+
*/
|
|
283
|
+
rdflist_append(consSubject: string | Var, value: string | Var, newCell?: string): WOQLQuery;
|
|
284
|
+
/**
|
|
285
|
+
* Delete all cons cells of an rdf:List and return rdf:nil as the new list value.
|
|
286
|
+
* Since a cons cell cannot become rdf:nil, this deletes all cells and binds
|
|
287
|
+
* rdf:nil to a variable so the caller can update the reference to the list.
|
|
288
|
+
* NOTE: This only removes the list structure. To delete subdocuments
|
|
289
|
+
* referenced by the list, use rdflist_member with delete_document first.
|
|
290
|
+
* @param {string} consSubject - Variable or IRI of the list head
|
|
291
|
+
* @param {string} newListVar - Variable to bind rdf:nil (the empty list)
|
|
292
|
+
* @returns {WOQLQuery} Query that deletes all cons cells and binds rdf:nil
|
|
293
|
+
* @example
|
|
294
|
+
* // Clear a list of literals and update the reference to point to rdf:nil:
|
|
295
|
+
* const clearListQuery = WOQL.and(
|
|
296
|
+
* WOQL.triple("doc:Project/1", "tasks", "v:old_list"),
|
|
297
|
+
* WOQL.lib().rdflist_clear("v:old_list", "v:empty_list"),
|
|
298
|
+
* WOQL.delete_triple("doc:Project/1", "tasks", "v:old_list"),
|
|
299
|
+
* WOQL.add_triple("doc:Project/1", "tasks", "v:empty_list")
|
|
300
|
+
* );
|
|
301
|
+
*
|
|
302
|
+
* // Full pattern: delete subdocuments, clear list, update reference:
|
|
303
|
+
* const fullClearQuery = WOQL.and(
|
|
304
|
+
* WOQL.triple("doc:Project/1", "tasks", "v:old_list"),
|
|
305
|
+
* WOQL.group_by([], "v:subdoc", "v:members",
|
|
306
|
+
* WOQL.and(
|
|
307
|
+
* WOQL.lib().rdflist_member("v:old_list", "v:subdoc"),
|
|
308
|
+
* WOQL.delete_document("v:subdoc")
|
|
309
|
+
* )
|
|
310
|
+
* ),
|
|
311
|
+
* WOQL.lib().rdflist_clear("v:old_list", "v:empty_list"),
|
|
312
|
+
* WOQL.delete_triple("doc:Project/1", "tasks", "v:old_list"),
|
|
313
|
+
* WOQL.add_triple("doc:Project/1", "tasks", "v:empty_list")
|
|
314
|
+
* );
|
|
315
|
+
*/
|
|
316
|
+
rdflist_clear(consSubject: string, newListVar: string): WOQLQuery;
|
|
317
|
+
/**
|
|
318
|
+
* Insert a value at a specific position in an rdf:List.
|
|
319
|
+
* @param {string} consSubject - Variable or IRI of the list head
|
|
320
|
+
* @param {number} position - Position to insert at (0-indexed)
|
|
321
|
+
* @param {string|Var} value - Value to insert
|
|
322
|
+
* @param {string|Var} [newNodeVar] - Optional variable to bind the new node
|
|
323
|
+
* @returns {WOQLQuery} Query that inserts value at position
|
|
324
|
+
* @example
|
|
325
|
+
* // Insert a task at position 1 in a project's task list
|
|
326
|
+
* const query = WOQL.and(
|
|
327
|
+
* WOQL.triple("doc:Project/1", "tasks", "v:list_head"),
|
|
328
|
+
* WOQL.lib().rdflist_insert("v:list_head", 1, WOQL.string("Inserted Task"))
|
|
329
|
+
* );
|
|
330
|
+
* // Result: [A, Inserted Task, B, C]
|
|
331
|
+
*/
|
|
332
|
+
rdflist_insert(consSubject: string, position: number, value: string | Var, newNodeVar?: string | Var): WOQLQuery;
|
|
333
|
+
/**
|
|
334
|
+
* Drop/remove a single element from an rdf:List at a specific position.
|
|
335
|
+
* @param {string} consSubject - Variable or IRI of the list head
|
|
336
|
+
* @param {number} position - Position of element to remove (0-indexed)
|
|
337
|
+
* @returns {WOQLQuery} Query that removes the element at position
|
|
338
|
+
* @example
|
|
339
|
+
* // Remove the task at position 1 from a project's task list
|
|
340
|
+
* const query = WOQL.and(
|
|
341
|
+
* WOQL.triple("doc:Project/1", "tasks", "v:list_head"),
|
|
342
|
+
* WOQL.lib().rdflist_drop("v:list_head", 1)
|
|
343
|
+
* );
|
|
344
|
+
* // Result: [A, C] (B removed)
|
|
345
|
+
*/
|
|
346
|
+
rdflist_drop(consSubject: string, position: number): WOQLQuery;
|
|
347
|
+
/**
|
|
348
|
+
* Swap elements at two positions in an rdf:List by exchanging their rdf:first values.
|
|
349
|
+
* This is a simplified implementation that swaps values in-place without moving cons cells.
|
|
350
|
+
* @param {string} consSubject - Variable or IRI of the list head
|
|
351
|
+
* @param {number} posA - First position (0-indexed)
|
|
352
|
+
* @param {number} posB - Second position (0-indexed)
|
|
353
|
+
* @returns {WOQLQuery} Query that swaps elements at the two positions
|
|
354
|
+
* @example
|
|
355
|
+
* // Swap the first and third tasks in a project's task list
|
|
356
|
+
* const query = WOQL.and(
|
|
357
|
+
* WOQL.triple("doc:Project/1", "tasks", "v:list_head"),
|
|
358
|
+
* WOQL.lib().rdflist_swap("v:list_head", 0, 2)
|
|
359
|
+
* );
|
|
360
|
+
* // Result: [C, B, A] (A and C swapped)
|
|
361
|
+
*/
|
|
362
|
+
rdflist_swap(consSubject: string, posA: number, posB: number): WOQLQuery;
|
|
363
|
+
/**
|
|
364
|
+
* Create an empty rdf:List (just rdf:nil).
|
|
365
|
+
* @param {string} listVar - Variable to bind to rdf:nil
|
|
366
|
+
* @returns {WOQLQuery} Query that creates empty list
|
|
367
|
+
* @example
|
|
368
|
+
* // Create an empty list reference
|
|
369
|
+
* const query = WOQL.lib().rdflist_empty("v:empty_list");
|
|
370
|
+
* // Result: { bindings: [{ "v:empty_list": "rdf:nil" }] }
|
|
371
|
+
*/
|
|
372
|
+
rdflist_empty(listVar: string): WOQLQuery;
|
|
373
|
+
/**
|
|
374
|
+
* Check if an rdf:List is empty (equals rdf:nil).
|
|
375
|
+
* @param {string} consSubject - Variable or IRI to check
|
|
376
|
+
* @returns {WOQLQuery} Query that succeeds if list is empty
|
|
377
|
+
* @example
|
|
378
|
+
* // Check if a project's task list is empty
|
|
379
|
+
* const query = WOQL.and(
|
|
380
|
+
* WOQL.triple("doc:Project/1", "tasks", "v:list_head"),
|
|
381
|
+
* WOQL.lib().rdflist_is_empty("v:list_head")
|
|
382
|
+
* );
|
|
383
|
+
* // Succeeds only if tasks list is rdf:nil
|
|
384
|
+
*/
|
|
385
|
+
rdflist_is_empty(consSubject: string): WOQLQuery;
|
|
386
|
+
/**
|
|
387
|
+
* Extract a slice of an rdf:List (range of elements) as an array.
|
|
388
|
+
* Works in two modes:
|
|
389
|
+
* - Generator: If resultVar is unbound, binds it to the array of sliced values
|
|
390
|
+
* - Matcher: If resultVar is bound to an array, succeeds only if values match
|
|
391
|
+
* Path queries return results in hop-count order, preserving list element order.
|
|
392
|
+
* @param {string} consSubject - Variable or IRI of the list head
|
|
393
|
+
* @param {number|string} start - Start index (inclusive) or variable
|
|
394
|
+
* @param {number|string} end - End index (exclusive) or variable
|
|
395
|
+
* @param {string} resultVar - Variable to bind/match the array of sliced values
|
|
396
|
+
* @returns {WOQLQuery} Query that extracts/matches list slice values
|
|
397
|
+
* @example
|
|
398
|
+
* // Get the first two tasks from a project's task list
|
|
399
|
+
* const query = WOQL.and(
|
|
400
|
+
* WOQL.triple("doc:Project/1", "tasks", "v:list_head"),
|
|
401
|
+
* WOQL.lib().rdflist_slice("v:list_head", 0, 2, "v:first_two")
|
|
402
|
+
* );
|
|
403
|
+
* // Result: { bindings: [{ "v:first_two": ["Task A", "Task B"] }] }
|
|
404
|
+
*/
|
|
405
|
+
rdflist_slice(consSubject: string, start: number | string, end: number | string, resultVar: string): WOQLQuery;
|
|
406
|
+
/**
|
|
407
|
+
* Reverse an rdf:List in-place by swapping rdf:first values across nodes.
|
|
408
|
+
* Optimized: collects all values once via group_by, then uses slice+member
|
|
409
|
+
* to index into the collected list instead of double path traversal.
|
|
410
|
+
* @param {string} consSubject - Variable or IRI of the list to reverse
|
|
411
|
+
* @returns {WOQLQuery} Query that reverses the list in place
|
|
412
|
+
* @example
|
|
413
|
+
* // Reverse a project's task list in place
|
|
414
|
+
* const query = WOQL.and(
|
|
415
|
+
* WOQL.triple("doc:Project/1", "tasks", "v:list_head"),
|
|
416
|
+
* WOQL.lib().rdflist_reverse("v:list_head")
|
|
417
|
+
* );
|
|
418
|
+
* // Result: [A, B, C] becomes [C, B, A]
|
|
419
|
+
*/
|
|
420
|
+
rdflist_reverse(consSubject: string): WOQLQuery;
|
|
421
|
+
}
|
|
422
|
+
declare namespace WOQLLibrary {
|
|
423
|
+
export { WOQLQuery };
|
|
424
|
+
}
|
|
425
|
+
import WOQLQuery = require("./woqlBuilder");
|
|
426
|
+
/**
|
|
427
|
+
* - WOQL Query Builder class
|
|
428
|
+
*/
|
|
429
|
+
type WOQLQuery = {
|
|
430
|
+
/**
|
|
431
|
+
* - Add a triple pattern
|
|
432
|
+
*/
|
|
433
|
+
triple: Function;
|
|
434
|
+
/**
|
|
435
|
+
* - Logical AND
|
|
436
|
+
*/
|
|
437
|
+
and: Function;
|
|
438
|
+
/**
|
|
439
|
+
* - Logical OR
|
|
440
|
+
*/
|
|
441
|
+
or: Function;
|
|
442
|
+
/**
|
|
443
|
+
* - Select variables
|
|
444
|
+
*/
|
|
445
|
+
select: Function;
|
|
446
|
+
/**
|
|
447
|
+
* - Ask query
|
|
448
|
+
*/
|
|
449
|
+
ask: Function;
|
|
450
|
+
/**
|
|
451
|
+
* - Limit results
|
|
452
|
+
*/
|
|
453
|
+
limit: Function;
|
|
454
|
+
/**
|
|
455
|
+
* - Offset results
|
|
456
|
+
*/
|
|
457
|
+
offset: Function;
|
|
458
|
+
/**
|
|
459
|
+
* - Start query
|
|
460
|
+
*/
|
|
461
|
+
start: Function;
|
|
462
|
+
/**
|
|
463
|
+
* - Path query
|
|
464
|
+
*/
|
|
465
|
+
path: Function;
|
|
466
|
+
/**
|
|
467
|
+
* - Subquery
|
|
468
|
+
*/
|
|
469
|
+
subquery: Function;
|
|
470
|
+
/**
|
|
471
|
+
* - Graph specifier
|
|
472
|
+
*/
|
|
473
|
+
from: Function;
|
|
474
|
+
/**
|
|
475
|
+
* - Equality
|
|
476
|
+
*/
|
|
477
|
+
eq: Function;
|
|
478
|
+
/**
|
|
479
|
+
* - Negation
|
|
480
|
+
*/
|
|
481
|
+
not: Function;
|
|
482
|
+
/**
|
|
483
|
+
* - Greater than
|
|
484
|
+
*/
|
|
485
|
+
greaterThan: Function;
|
|
486
|
+
/**
|
|
487
|
+
* - Less than
|
|
488
|
+
*/
|
|
489
|
+
lessThan: Function;
|
|
490
|
+
/**
|
|
491
|
+
* - Greater than or equal
|
|
492
|
+
*/
|
|
493
|
+
greaterThanOrEqual: Function;
|
|
494
|
+
/**
|
|
495
|
+
* - Less than or equal
|
|
496
|
+
*/
|
|
497
|
+
lessThanOrEqual: Function;
|
|
498
|
+
/**
|
|
499
|
+
* - String pattern matching
|
|
500
|
+
*/
|
|
501
|
+
like: Function;
|
|
502
|
+
/**
|
|
503
|
+
* - Addition
|
|
504
|
+
*/
|
|
505
|
+
plus: Function;
|
|
506
|
+
/**
|
|
507
|
+
* - Subtraction
|
|
508
|
+
*/
|
|
509
|
+
minus: Function;
|
|
510
|
+
/**
|
|
511
|
+
* - Multiplication
|
|
512
|
+
*/
|
|
513
|
+
times: Function;
|
|
514
|
+
/**
|
|
515
|
+
* - Division
|
|
516
|
+
*/
|
|
517
|
+
divide: Function;
|
|
518
|
+
/**
|
|
519
|
+
* - Count aggregation
|
|
520
|
+
*/
|
|
521
|
+
count: Function;
|
|
522
|
+
/**
|
|
523
|
+
* - Sum aggregation
|
|
524
|
+
*/
|
|
525
|
+
sum: Function;
|
|
526
|
+
/**
|
|
527
|
+
* - Minimum aggregation
|
|
528
|
+
*/
|
|
529
|
+
min: Function;
|
|
530
|
+
/**
|
|
531
|
+
* - Maximum aggregation
|
|
532
|
+
*/
|
|
533
|
+
max: Function;
|
|
534
|
+
/**
|
|
535
|
+
* - Average aggregation
|
|
536
|
+
*/
|
|
537
|
+
avg: Function;
|
|
538
|
+
/**
|
|
539
|
+
* - Group by
|
|
540
|
+
*/
|
|
541
|
+
groupBy: Function;
|
|
542
|
+
/**
|
|
543
|
+
* - Order by
|
|
544
|
+
*/
|
|
545
|
+
orderBy: Function;
|
|
546
|
+
/**
|
|
547
|
+
* - Ascending order
|
|
548
|
+
*/
|
|
549
|
+
asc: Function;
|
|
550
|
+
/**
|
|
551
|
+
* - Descending order
|
|
552
|
+
*/
|
|
553
|
+
desc: Function;
|
|
554
|
+
/**
|
|
555
|
+
* - JSON object
|
|
556
|
+
*/
|
|
557
|
+
json: Function;
|
|
558
|
+
/**
|
|
559
|
+
* - IRI
|
|
560
|
+
*/
|
|
561
|
+
id: Function;
|
|
562
|
+
/**
|
|
563
|
+
* - String literal
|
|
564
|
+
*/
|
|
565
|
+
string: Function;
|
|
566
|
+
/**
|
|
567
|
+
* - DateTime literal
|
|
568
|
+
*/
|
|
569
|
+
datetime: Function;
|
|
570
|
+
/**
|
|
571
|
+
* - Date literal
|
|
572
|
+
*/
|
|
573
|
+
date: Function;
|
|
574
|
+
/**
|
|
575
|
+
* - Time literal
|
|
576
|
+
*/
|
|
577
|
+
time: Function;
|
|
578
|
+
/**
|
|
579
|
+
* - Boolean literal
|
|
580
|
+
*/
|
|
581
|
+
boolean: Function;
|
|
582
|
+
/**
|
|
583
|
+
* - Integer literal
|
|
584
|
+
*/
|
|
585
|
+
integer: Function;
|
|
586
|
+
/**
|
|
587
|
+
* - Decimal literal
|
|
588
|
+
*/
|
|
589
|
+
decimal: Function;
|
|
590
|
+
/**
|
|
591
|
+
* - Double literal
|
|
592
|
+
*/
|
|
593
|
+
double: Function;
|
|
594
|
+
/**
|
|
595
|
+
* - Value literal
|
|
596
|
+
*/
|
|
597
|
+
value: Function;
|
|
598
|
+
/**
|
|
599
|
+
* - Variable
|
|
600
|
+
*/
|
|
601
|
+
var: Function;
|
|
602
|
+
/**
|
|
603
|
+
* - Variable shorthand
|
|
604
|
+
*/
|
|
605
|
+
v: Function;
|
|
606
|
+
/**
|
|
607
|
+
* - Document
|
|
608
|
+
*/
|
|
609
|
+
doc: Function;
|
|
610
|
+
/**
|
|
611
|
+
* - Class
|
|
612
|
+
*/
|
|
613
|
+
class: Function;
|
|
614
|
+
/**
|
|
615
|
+
* - Property
|
|
616
|
+
*/
|
|
617
|
+
property: Function;
|
|
618
|
+
/**
|
|
619
|
+
* - Comment
|
|
620
|
+
*/
|
|
621
|
+
comment: Function;
|
|
622
|
+
/**
|
|
623
|
+
* - Label
|
|
624
|
+
*/
|
|
625
|
+
label: Function;
|
|
626
|
+
/**
|
|
627
|
+
* - Prefix
|
|
628
|
+
*/
|
|
629
|
+
prefix: Function;
|
|
630
|
+
/**
|
|
631
|
+
* - Using
|
|
632
|
+
*/
|
|
633
|
+
using: Function;
|
|
634
|
+
/**
|
|
635
|
+
* - Optional
|
|
636
|
+
*/
|
|
637
|
+
optional: Function;
|
|
638
|
+
/**
|
|
639
|
+
* - Union
|
|
640
|
+
*/
|
|
641
|
+
union: Function;
|
|
642
|
+
/**
|
|
643
|
+
* - Filter
|
|
644
|
+
*/
|
|
645
|
+
filter: Function;
|
|
646
|
+
/**
|
|
647
|
+
* - Bind
|
|
648
|
+
*/
|
|
649
|
+
bind: Function;
|
|
650
|
+
/**
|
|
651
|
+
* - Exists
|
|
652
|
+
*/
|
|
653
|
+
exists: Function;
|
|
654
|
+
/**
|
|
655
|
+
* - Not exists
|
|
656
|
+
*/
|
|
657
|
+
notExists: Function;
|
|
658
|
+
/**
|
|
659
|
+
* - Graph
|
|
660
|
+
*/
|
|
661
|
+
graph: Function;
|
|
662
|
+
/**
|
|
663
|
+
* - Named graph
|
|
664
|
+
*/
|
|
665
|
+
named: Function;
|
|
666
|
+
/**
|
|
667
|
+
* - Values
|
|
668
|
+
*/
|
|
669
|
+
values: Function;
|
|
670
|
+
/**
|
|
671
|
+
* - Service
|
|
672
|
+
*/
|
|
673
|
+
service: Function;
|
|
674
|
+
/**
|
|
675
|
+
* - Load
|
|
676
|
+
*/
|
|
677
|
+
load: Function;
|
|
678
|
+
/**
|
|
679
|
+
* - Clear
|
|
680
|
+
*/
|
|
681
|
+
clear: Function;
|
|
682
|
+
/**
|
|
683
|
+
* - Drop
|
|
684
|
+
*/
|
|
685
|
+
drop: Function;
|
|
686
|
+
/**
|
|
687
|
+
* - Add
|
|
688
|
+
*/
|
|
689
|
+
add: Function;
|
|
690
|
+
/**
|
|
691
|
+
* - Move
|
|
692
|
+
*/
|
|
693
|
+
move: Function;
|
|
694
|
+
/**
|
|
695
|
+
* - Copy
|
|
696
|
+
*/
|
|
697
|
+
copy: Function;
|
|
698
|
+
/**
|
|
699
|
+
* - Insert
|
|
700
|
+
*/
|
|
701
|
+
insert: Function;
|
|
702
|
+
/**
|
|
703
|
+
* - Delete
|
|
704
|
+
*/
|
|
705
|
+
delete: Function;
|
|
706
|
+
/**
|
|
707
|
+
* - Modify
|
|
708
|
+
*/
|
|
709
|
+
modify: Function;
|
|
710
|
+
/**
|
|
711
|
+
* - Construct
|
|
712
|
+
*/
|
|
713
|
+
construct: Function;
|
|
714
|
+
/**
|
|
715
|
+
* - Describe
|
|
716
|
+
*/
|
|
717
|
+
describe: Function;
|
|
718
|
+
};
|