@qaecy/cue-cli 0.0.21 → 0.0.25
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/main.js +134 -15
- package/package.json +6 -3
package/main.js
CHANGED
|
@@ -93,14 +93,16 @@ var init_worker_pool = __esm({
|
|
|
93
93
|
|
|
94
94
|
// apps/desktop/cue-cli/src/main.ts
|
|
95
95
|
var import_commander = require("commander");
|
|
96
|
-
var
|
|
96
|
+
var import_fs9 = require("fs");
|
|
97
97
|
var import_path5 = require("path");
|
|
98
98
|
|
|
99
99
|
// apps/desktop/cue-cli/src/variables.ts
|
|
100
100
|
var import_path = require("path");
|
|
101
|
-
var
|
|
101
|
+
var EMULATOR_API_GATEWAY_PORT = process.env.CUE_EMULATOR_API_GATEWAY_PORT ?? "8093";
|
|
102
|
+
var EMULATOR_API_GATEWAY_BASE = `http://localhost:${EMULATOR_API_GATEWAY_PORT}`;
|
|
103
|
+
var TOKEN_ENDPOINT_EMULATOR = `${EMULATOR_API_GATEWAY_BASE}/token`;
|
|
102
104
|
var TOKEN_ENDPOINT = "https://accessors-api-gateway-ueyeemwf2a-oa.a.run.app/token";
|
|
103
|
-
var SPARQL_ENDPOINT_EMULATOR =
|
|
105
|
+
var SPARQL_ENDPOINT_EMULATOR = `${EMULATOR_API_GATEWAY_BASE}/triplestore/query`;
|
|
104
106
|
var SPARQL_ENDPOINT = "https://accessors-api-gateway-ueyeemwf2a-oa.a.run.app/triplestore/query";
|
|
105
107
|
var HASH_WORKER_PATH = (0, import_path.join)(__dirname, "hash-worker.js");
|
|
106
108
|
var SERVICE_ID = "cue-cli";
|
|
@@ -441,6 +443,7 @@ var import_storage2 = require("firebase/storage");
|
|
|
441
443
|
var qaecyPrefixes = {
|
|
442
444
|
qcy: "https://dev.qaecy.com/ont#",
|
|
443
445
|
"qcy-e": "https://dev.qaecy.com/enum#",
|
|
446
|
+
"qcy-l": "https://dev.qaecy.com/logs#",
|
|
444
447
|
"qcy-f": "https://dev.qaecy.com/functions#",
|
|
445
448
|
obc: "https://w3id.org/obc#",
|
|
446
449
|
// OpenBIM Components
|
|
@@ -5715,18 +5718,33 @@ function getFileSuffix(filename) {
|
|
|
5715
5718
|
var { namedNode: namedNode4, literal: literal3 } = import_n34.DataFactory;
|
|
5716
5719
|
var a3 = namedNode4("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
|
|
5717
5720
|
|
|
5721
|
+
// libs/js/rdf-document-writers/src/lib/process-logs.ts
|
|
5722
|
+
var import_n35 = require("n3");
|
|
5723
|
+
|
|
5718
5724
|
// libs/js/rdf-document-writers/src/lib/serialize-rdf.ts
|
|
5719
|
-
async function serializeRDF(namespace, writer) {
|
|
5725
|
+
async function serializeRDF(namespace, writer, format = "ttl") {
|
|
5720
5726
|
return new Promise((resolve2, reject) => {
|
|
5721
5727
|
writer.end((err, res) => {
|
|
5722
5728
|
if (err)
|
|
5723
5729
|
reject(err);
|
|
5724
|
-
|
|
5730
|
+
const addBase = format === "ttl" && namespace !== "";
|
|
5731
|
+
resolve2(addBase ? `@base <${namespace}>.
|
|
5725
5732
|
${res}` : res);
|
|
5726
5733
|
});
|
|
5727
5734
|
});
|
|
5728
5735
|
}
|
|
5729
5736
|
|
|
5737
|
+
// libs/js/rdf-document-writers/src/lib/process-logs.ts
|
|
5738
|
+
var import_uuid6 = require("uuid");
|
|
5739
|
+
var { namedNode: namedNode5, literal: literal4 } = import_n35.DataFactory;
|
|
5740
|
+
var a4 = namedNode5("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
|
|
5741
|
+
var prefixes3 = {
|
|
5742
|
+
qcy: qaecyPrefixes["qcy"],
|
|
5743
|
+
"qcy-e": qaecyPrefixes["qcy-e"],
|
|
5744
|
+
"qcy-l": qaecyPrefixes["qcy-l"],
|
|
5745
|
+
xsd: prefixCC["xsd"]
|
|
5746
|
+
};
|
|
5747
|
+
|
|
5730
5748
|
// libs/js/file-metadata-helpers/src/lib/js-file-metadata-helpers.ts
|
|
5731
5749
|
function uploadedFileMetadata(originalName, projectId, userId, md5, providerId, clientMetadata, mime, skipLoading = false, skipProcessing = false) {
|
|
5732
5750
|
const suffix = getFileSuffix(originalName);
|
|
@@ -5750,19 +5768,23 @@ function uploadedFileMetadata(originalName, projectId, userId, md5, providerId,
|
|
|
5750
5768
|
provider_id: providerId ?? "",
|
|
5751
5769
|
mime,
|
|
5752
5770
|
additional_metadata: clientMetadata ?? "",
|
|
5753
|
-
last_seen_as: JSON.stringify({
|
|
5771
|
+
last_seen_as: JSON.stringify({
|
|
5772
|
+
hostId: providerId ?? "",
|
|
5773
|
+
fileUUID
|
|
5774
|
+
})
|
|
5754
5775
|
};
|
|
5755
5776
|
}
|
|
5756
5777
|
function turtleFileMetadata(sourceFile, processorId, locationUUID, stored = false) {
|
|
5757
5778
|
const ids = extractIdsFromRawPath(sourceFile);
|
|
5758
5779
|
const blob_name = locationUUID !== void 0 ? `${ids.projectId}/triples/${ids.documentUUID}_${locationUUID}_${processorId}.ttl` : `${ids.projectId}/triples/${ids.documentUUID}_${processorId}.ttl`;
|
|
5780
|
+
const identifier = locationUUID !== void 0 ? `${ids.documentUUID}_${locationUUID}` : ids.documentUUID;
|
|
5759
5781
|
return {
|
|
5760
5782
|
blob_name,
|
|
5761
5783
|
processor: processorId,
|
|
5762
5784
|
space_id: ids.projectId,
|
|
5763
5785
|
stored: stored ? "True" : "False",
|
|
5764
5786
|
suffix: ".ttl",
|
|
5765
|
-
identifier
|
|
5787
|
+
identifier,
|
|
5766
5788
|
source: sourceFile
|
|
5767
5789
|
};
|
|
5768
5790
|
}
|
|
@@ -6070,22 +6092,22 @@ var import_fs7 = require("fs");
|
|
|
6070
6092
|
var import_zlib2 = require("zlib");
|
|
6071
6093
|
|
|
6072
6094
|
// libs/js/rdf-tools/src/lib/nq-to-nt.ts
|
|
6073
|
-
var
|
|
6074
|
-
var { quad, defaultGraph } =
|
|
6095
|
+
var import_n36 = require("n3");
|
|
6096
|
+
var { quad, defaultGraph } = import_n36.DataFactory;
|
|
6075
6097
|
|
|
6076
6098
|
// libs/js/rdf-tools/src/lib/remove-rdf-star.ts
|
|
6077
|
-
var
|
|
6099
|
+
var import_n37 = require("n3");
|
|
6078
6100
|
var import_stream2 = require("stream");
|
|
6079
6101
|
function isRDFStarTerm(term) {
|
|
6080
6102
|
return term.termType === "Quad";
|
|
6081
6103
|
}
|
|
6082
6104
|
function removeRDFStar(inputStream, starCount) {
|
|
6083
|
-
const parser = new
|
|
6105
|
+
const parser = new import_n37.Parser({ format: "N-Quads*" });
|
|
6084
6106
|
const outputStream = new import_stream2.PassThrough();
|
|
6085
|
-
const writer = new
|
|
6107
|
+
const writer = new import_n37.StreamWriter({ format: "N-Quads" });
|
|
6086
6108
|
writer.pipe(outputStream);
|
|
6087
6109
|
let count = 0;
|
|
6088
|
-
parser.parse(inputStream, (error, quad2,
|
|
6110
|
+
parser.parse(inputStream, (error, quad2, prefixes4) => {
|
|
6089
6111
|
if (error) {
|
|
6090
6112
|
outputStream.emit("error", error);
|
|
6091
6113
|
writer.end();
|
|
@@ -6149,13 +6171,109 @@ async function utilRemoveRdfStarHandler(options) {
|
|
|
6149
6171
|
console.info(`Done. Removed ${removed} RDF-star triple(s). Output written to: ${output}`);
|
|
6150
6172
|
}
|
|
6151
6173
|
|
|
6174
|
+
// apps/desktop/cue-cli/src/cue-cli-util-rdf-compare.ts
|
|
6175
|
+
var import_fs8 = require("fs");
|
|
6176
|
+
|
|
6177
|
+
// libs/js/rdf-compare/src/lib/js-rdf-compare.ts
|
|
6178
|
+
var import_n38 = require("n3");
|
|
6179
|
+
var import_jsonld = require("jsonld");
|
|
6180
|
+
function parseTurtle(content) {
|
|
6181
|
+
return new Promise((resolve2, reject) => {
|
|
6182
|
+
const parser = new import_n38.Parser({ format: "Turtle" });
|
|
6183
|
+
const quads = [];
|
|
6184
|
+
parser.parse(content, (error, quad2) => {
|
|
6185
|
+
if (error)
|
|
6186
|
+
reject(error);
|
|
6187
|
+
else if (quad2)
|
|
6188
|
+
quads.push(quad2);
|
|
6189
|
+
else
|
|
6190
|
+
resolve2(quads);
|
|
6191
|
+
});
|
|
6192
|
+
});
|
|
6193
|
+
}
|
|
6194
|
+
function quadsToNQuads(quads) {
|
|
6195
|
+
return new Promise((resolve2, reject) => {
|
|
6196
|
+
const writer = new import_n38.Writer({ format: "N-Quads" });
|
|
6197
|
+
writer.addQuads(quads);
|
|
6198
|
+
writer.end((error, result) => {
|
|
6199
|
+
if (error)
|
|
6200
|
+
reject(error);
|
|
6201
|
+
else
|
|
6202
|
+
resolve2(result);
|
|
6203
|
+
});
|
|
6204
|
+
});
|
|
6205
|
+
}
|
|
6206
|
+
async function canonicalTriples(turtleContent) {
|
|
6207
|
+
const quads = await parseTurtle(turtleContent);
|
|
6208
|
+
const nquads = await quadsToNQuads(quads);
|
|
6209
|
+
const canonized = await (0, import_jsonld.canonize)(nquads, {
|
|
6210
|
+
algorithm: "URDNA2015",
|
|
6211
|
+
inputFormat: "application/n-quads",
|
|
6212
|
+
format: "application/n-quads"
|
|
6213
|
+
});
|
|
6214
|
+
return new Set(
|
|
6215
|
+
canonized.split("\n").map((t) => t.trim()).filter((t) => t !== "")
|
|
6216
|
+
);
|
|
6217
|
+
}
|
|
6218
|
+
async function compareTTL(file1Content, file2Content) {
|
|
6219
|
+
const [triples1, triples2] = await Promise.all([
|
|
6220
|
+
canonicalTriples(file1Content),
|
|
6221
|
+
canonicalTriples(file2Content)
|
|
6222
|
+
]);
|
|
6223
|
+
const triplesOnlyInFile1 = new Set(
|
|
6224
|
+
[...triples1].filter((x) => !triples2.has(x))
|
|
6225
|
+
);
|
|
6226
|
+
const triplesOnlyInFile2 = new Set(
|
|
6227
|
+
[...triples2].filter((x) => !triples1.has(x))
|
|
6228
|
+
);
|
|
6229
|
+
return {
|
|
6230
|
+
triplesOnlyInFile1,
|
|
6231
|
+
triplesOnlyInFile2,
|
|
6232
|
+
file1TripleCount: triples1.size,
|
|
6233
|
+
file2TripleCount: triples2.size
|
|
6234
|
+
};
|
|
6235
|
+
}
|
|
6236
|
+
|
|
6237
|
+
// apps/desktop/cue-cli/src/cue-cli-util-rdf-compare.ts
|
|
6238
|
+
async function utilRdfCompareHandler(options) {
|
|
6239
|
+
const { file1, file2, verbose } = options;
|
|
6240
|
+
if (verbose)
|
|
6241
|
+
console.info(`File 1: ${file1}`);
|
|
6242
|
+
if (verbose)
|
|
6243
|
+
console.info(`File 2: ${file2}`);
|
|
6244
|
+
const content1 = (0, import_fs8.readFileSync)(file1, "utf8");
|
|
6245
|
+
const content2 = (0, import_fs8.readFileSync)(file2, "utf8");
|
|
6246
|
+
const result = await compareTTL(content1, content2);
|
|
6247
|
+
console.info(`File 1 triple count: ${result.file1TripleCount}`);
|
|
6248
|
+
console.info(`File 2 triple count: ${result.file2TripleCount}`);
|
|
6249
|
+
if (result.triplesOnlyInFile1.size === 0 && result.triplesOnlyInFile2.size === 0) {
|
|
6250
|
+
console.info("Files are semantically equivalent.");
|
|
6251
|
+
return;
|
|
6252
|
+
}
|
|
6253
|
+
if (result.triplesOnlyInFile1.size > 0) {
|
|
6254
|
+
console.info(`
|
|
6255
|
+
Triples only in file 1 (${result.triplesOnlyInFile1.size}):`);
|
|
6256
|
+
for (const triple of result.triplesOnlyInFile1) {
|
|
6257
|
+
console.info(` ${triple}`);
|
|
6258
|
+
}
|
|
6259
|
+
}
|
|
6260
|
+
if (result.triplesOnlyInFile2.size > 0) {
|
|
6261
|
+
console.info(`
|
|
6262
|
+
Triples only in file 2 (${result.triplesOnlyInFile2.size}):`);
|
|
6263
|
+
for (const triple of result.triplesOnlyInFile2) {
|
|
6264
|
+
console.info(` ${triple}`);
|
|
6265
|
+
}
|
|
6266
|
+
}
|
|
6267
|
+
process.exitCode = 1;
|
|
6268
|
+
}
|
|
6269
|
+
|
|
6152
6270
|
// apps/desktop/cue-cli/src/main.ts
|
|
6153
6271
|
var packageJson;
|
|
6154
6272
|
try {
|
|
6155
|
-
packageJson = JSON.parse((0,
|
|
6273
|
+
packageJson = JSON.parse((0, import_fs9.readFileSync)((0, import_path5.join)(__dirname, "package.json"), "utf8"));
|
|
6156
6274
|
} catch {
|
|
6157
6275
|
try {
|
|
6158
|
-
packageJson = JSON.parse((0,
|
|
6276
|
+
packageJson = JSON.parse((0, import_fs9.readFileSync)((0, import_path5.join)(__dirname, "../package.json"), "utf8"));
|
|
6159
6277
|
} catch {
|
|
6160
6278
|
packageJson = { version: "0.0.0" };
|
|
6161
6279
|
console.warn("Could not find package.json, using fallback version");
|
|
@@ -6168,5 +6286,6 @@ program.command("dump").description("Dump Cue Knowledge Graph data to file\n
|
|
|
6168
6286
|
program.command("compare").description("Compares folder content to files already updated to Cue").requiredOption("-s, --space <id>", "Specify the space ID (required)").requiredOption("-p, --path <id>", "Specify the folder path (required)").option("-k, --key <api-key>", "Specify the API key (or set CUE_API_KEY env variable)").option("--provider <provider ID>", "Specify the provider ID (eg. sharepoint, drive, dropbox) or leave empty for default provider", "").option("-v, --verbose", "Enable verbose output", false).option("-e, --emulators", "Uses emulators for sync", false).option("-z, --zip", "Include zipped content (will temporarily unzip files with same logic as when syncing and delete them again after the comparison)", false).action(compareHandler);
|
|
6169
6287
|
program.command("dump-processed").description("Dump processed files to local folder").requiredOption("-s, --space <id>", "Specify the space ID (required)").requiredOption("-p, --processor <id>", "Id of the processor to dump processed files from (required) [eg. writers-blob, processors-cad-files]").option("-k, --key <api-key>", "Specify the API key (or set CUE_API_KEY env variable)").option("-v, --verbose", "Enable verbose output", false).option("-e, --emulators", "Uses emulators for sync", false).action(dumpProcessedHandler);
|
|
6170
6288
|
program.command("repair-ttl").description("Repair TTL files in the specified space").requiredOption("-s, --space <id>", "Specify the space ID (required)").requiredOption("-p, --processor <id>", "Id of the processor to repair TTL files (required) [eg. writers-blob, processors-cad-files]").requiredOption("-f, --from <subString>", "Substring (Regex) to replace in the TTL file (required)").requiredOption("-t, --to <substituteString>", "Substring to replace in the TTL file (required)").option("-k, --key <api-key>", "Specify the API key (or set CUE_API_KEY env variable)").option("-v, --verbose", "Enable verbose output", false).option("-e, --emulators", "Uses emulators for sync", false).action(repairTtlHandler);
|
|
6289
|
+
program.command("util-rdf-compare").description("Compare two Turtle (.ttl) files and report semantic differences").requiredOption("--file1 <path>", "Path to the first TTL file").requiredOption("--file2 <path>", "Path to the second TTL file").option("-v, --verbose", "Enable verbose output", false).action(utilRdfCompareHandler);
|
|
6171
6290
|
program.command("util-remove-rdf-star").description("Remove RDF-star (quoted) triples from an NQuads file. Supports .nq and .nq.gz input/output.").requiredOption("-i, --input <path>", "Input file path (.nq or .nq.gz)").requiredOption("-o, --output <path>", "Output file path (.nq or .nq.gz)").option("-v, --verbose", "Enable verbose output", false).action(utilRemoveRdfStarHandler);
|
|
6172
6291
|
program.parse(process.argv);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qaecy/cue-cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.25",
|
|
4
4
|
"description": "Cue CLI for QAECY platform",
|
|
5
5
|
"main": "main.js",
|
|
6
6
|
"bin": {
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
],
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@google-cloud/pubsub": "4.4.1",
|
|
18
|
+
"axios": "1.13.2",
|
|
18
19
|
"commander": "13.1.0",
|
|
19
20
|
"firebase": "12.4.0",
|
|
20
21
|
"jsonld": "8.3.3",
|
|
@@ -25,11 +26,13 @@
|
|
|
25
26
|
"spark-md5": "3.0.2",
|
|
26
27
|
"sparqljs": "3.7.3",
|
|
27
28
|
"tslib": "2.3.0",
|
|
28
|
-
"uuid": "9.0.0"
|
|
29
|
-
"axios": "1.13.2"
|
|
29
|
+
"uuid": "9.0.0"
|
|
30
30
|
},
|
|
31
31
|
"engines": {
|
|
32
32
|
"node": ">=18"
|
|
33
33
|
},
|
|
34
|
+
"overrides": {
|
|
35
|
+
"vite": "^6.0.0"
|
|
36
|
+
},
|
|
34
37
|
"type": "commonjs"
|
|
35
38
|
}
|