The WOQL Library in TypeScript aims to provide AST manipulation capabilities which can be included in clients etc in Typescript or Javascript, allowing convenient handling of queries.
The file src/woql_defs/woql.ts
is generated automatically from
woql.json
and should not be altered manually. Additions to the
processing or manipulation should either change the method of
producing woql.ts
which is contained in src/woql_defs/generate.ts
,
or should be wrapper code which uses src/woql_defs/woql.ts
.
For development you will need to get the latest woql.json
from the
terminusdb repository. Assuming you have wget installed, you can run:
$ npm run woql-get
After which you can build the new woql.ts
file by running
$ npx src/generate.ts
The WOQL below query identifies document identifiers that are not subdocuments.
const woqlStr = `
and(triple(doc, "rdf:type", type),
not(quad(type, "sys:subdocument", unbound, "schema")),
)
`
const woql = parseWoqlString(woqlStr);
const postBody = prepareWoqlHttpPostBody(woql);
const result = await terminusClient.sendCustomRequest("POST", `http://localhost:6363/api/woql/admin/sandbox/local/branch/main`, postBody);
The WOQL DSL parser and WOQL transformer supports new WOQL authoring styles. Variables can now be declared in multiple ways, and the DSL even support undeclared variables.
- Variables get assigned through the new
(var1, var2, var3...) => { ... }
- Undeclared variables are supported for the DSL (similar to datalog variables)
- Variables support the
v:
prefix to maintain backwards compatibility
(doc, type, unbound) =>
and(
triple(doc, "rdf:type", type),
not(quad(type, "sys:subdocument", unbound, "schema")),
)
and(
triple(doc, "rdf:type", type),
not(quad(type, "sys:subdocument", unbound, "schema")),
)
and(
triple("v:doc", "rdf:type", "v:type"),
not(quad("v:type", "sys:subdocument", "v:unbound", "schema")),
)
- As (for CSV Get handling to support previous functionality)