@qaecy/cue-cli 0.0.15 → 0.0.17
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 +90 -31
- package/package.json +3 -3
package/main.js
CHANGED
|
@@ -67,20 +67,20 @@ var init_worker_pool = __esm({
|
|
|
67
67
|
}
|
|
68
68
|
_next() {
|
|
69
69
|
if (this.queue.length > 0 && this.idleWorkers.length > 0) {
|
|
70
|
-
const { filePath, resolve, reject } = this.queue.shift();
|
|
70
|
+
const { filePath, resolve: resolve2, reject } = this.queue.shift();
|
|
71
71
|
const worker = this.idleWorkers.pop();
|
|
72
72
|
worker._currentCallback = (result) => {
|
|
73
73
|
if (result.error)
|
|
74
74
|
reject(new Error(result.error));
|
|
75
75
|
else
|
|
76
|
-
|
|
76
|
+
resolve2(result.hash);
|
|
77
77
|
};
|
|
78
78
|
worker.postMessage(filePath);
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
hashFile(filePath) {
|
|
82
|
-
return new Promise((
|
|
83
|
-
this.queue.push({ filePath, resolve, reject });
|
|
82
|
+
return new Promise((resolve2, reject) => {
|
|
83
|
+
this.queue.push({ filePath, resolve: resolve2, reject });
|
|
84
84
|
this._next();
|
|
85
85
|
});
|
|
86
86
|
}
|
|
@@ -93,8 +93,8 @@ 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
|
|
97
|
-
var
|
|
96
|
+
var import_fs7 = require("fs");
|
|
97
|
+
var import_path5 = require("path");
|
|
98
98
|
|
|
99
99
|
// apps/desktop/cue-cli/src/variables.ts
|
|
100
100
|
var import_path = require("path");
|
|
@@ -119,7 +119,7 @@ var IGNORED_LOCAL = {
|
|
|
119
119
|
|
|
120
120
|
// libs/js/sync-tools/src/lib/compare-local-remote.ts
|
|
121
121
|
function compareLocalRemote(localFiles, remoteFiles) {
|
|
122
|
-
return new Promise((
|
|
122
|
+
return new Promise((resolve2) => {
|
|
123
123
|
const localByContentUUID = /* @__PURE__ */ new Map();
|
|
124
124
|
const localBylocationUUID = /* @__PURE__ */ new Map();
|
|
125
125
|
for (const lf of localFiles) {
|
|
@@ -180,7 +180,7 @@ function compareLocalRemote(localFiles, remoteFiles) {
|
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
182
|
const synctPctSize = totalSize > 0 ? syncSize / totalSize : 1;
|
|
183
|
-
|
|
183
|
+
resolve2({
|
|
184
184
|
localNotOnRemote,
|
|
185
185
|
localNotOnRemotePathOnly,
|
|
186
186
|
remoteNotOnLocal,
|
|
@@ -212,6 +212,7 @@ var BUCKET_RAW = "spaces_raw_eu_west6";
|
|
|
212
212
|
var BUCKET_PROCESSED = "spaces_processed_eu_west6";
|
|
213
213
|
var BUCKET_LOGS = "spaces_logs_eu_west6";
|
|
214
214
|
var BUCKET_PUBLIC = "cue_public_eu_west6";
|
|
215
|
+
var BUCKET_PERSISTENCE = "db_persistence_eu_west6";
|
|
215
216
|
var COLLECTION_CHAT_SESSIONS = "chatSessions";
|
|
216
217
|
var COLLECTION_ORGANIZATIONS = "organizations";
|
|
217
218
|
var COLLECTION_PROJECTS = "projects";
|
|
@@ -227,9 +228,10 @@ var import_firestore = require("firebase/firestore");
|
|
|
227
228
|
var import_auth = require("firebase/auth");
|
|
228
229
|
var import_app = require("firebase/app");
|
|
229
230
|
var CueFirebase = class _CueFirebase {
|
|
231
|
+
static _instance;
|
|
232
|
+
_muted = true;
|
|
233
|
+
_emulator = false;
|
|
230
234
|
constructor(config, auth, muted = false) {
|
|
231
|
-
this._muted = true;
|
|
232
|
-
this._emulator = false;
|
|
233
235
|
this._muted = muted;
|
|
234
236
|
this._init(config, auth);
|
|
235
237
|
}
|
|
@@ -243,6 +245,28 @@ var CueFirebase = class _CueFirebase {
|
|
|
243
245
|
}
|
|
244
246
|
return _CueFirebase._instance;
|
|
245
247
|
}
|
|
248
|
+
_functionAcceptTerms;
|
|
249
|
+
_functionEmitMessage;
|
|
250
|
+
_functionGetUserInfo;
|
|
251
|
+
_functionChangeUserRoleOnProject;
|
|
252
|
+
_functionInviteUserToProject;
|
|
253
|
+
_functionRemoveUserFromProject;
|
|
254
|
+
_storageProcessed;
|
|
255
|
+
_storageRaw;
|
|
256
|
+
_storageLogs;
|
|
257
|
+
_storageChatSessions;
|
|
258
|
+
_storagePublic;
|
|
259
|
+
_storagePersistence;
|
|
260
|
+
_collectionChatSessions;
|
|
261
|
+
_collectionOrganizations;
|
|
262
|
+
_collectionProjects;
|
|
263
|
+
_collectionRDFWriting;
|
|
264
|
+
_collectionAPIKeys;
|
|
265
|
+
_collectionUsers;
|
|
266
|
+
_collectionUserTermsAcceptance;
|
|
267
|
+
_collectionTiers;
|
|
268
|
+
_auth;
|
|
269
|
+
_app;
|
|
246
270
|
get functionAcceptTerms() {
|
|
247
271
|
return this._functionAcceptTerms;
|
|
248
272
|
}
|
|
@@ -276,6 +300,9 @@ var CueFirebase = class _CueFirebase {
|
|
|
276
300
|
get storagePublic() {
|
|
277
301
|
return this._storagePublic;
|
|
278
302
|
}
|
|
303
|
+
get storagePersistence() {
|
|
304
|
+
return this._storagePersistence;
|
|
305
|
+
}
|
|
279
306
|
get collectionChatSessions() {
|
|
280
307
|
return this._collectionChatSessions;
|
|
281
308
|
}
|
|
@@ -347,6 +374,7 @@ var CueFirebase = class _CueFirebase {
|
|
|
347
374
|
this._storageChatSessions = (0, import_storage.getStorage)(app, BUCKET_CHAT_SESSIONS);
|
|
348
375
|
this._storageLogs = (0, import_storage.getStorage)(app, BUCKET_LOGS);
|
|
349
376
|
this._storagePublic = (0, import_storage.getStorage)(app, BUCKET_PUBLIC);
|
|
377
|
+
this._storagePersistence = (0, import_storage.getStorage)(app, BUCKET_PERSISTENCE);
|
|
350
378
|
this._collectionChatSessions = (0, import_firestore.collection)(
|
|
351
379
|
(0, import_firestore.getFirestore)(app),
|
|
352
380
|
COLLECTION_CHAT_SESSIONS
|
|
@@ -384,6 +412,8 @@ var CueFirebase = class _CueFirebase {
|
|
|
384
412
|
throw new Error("Storage logs is not initialized");
|
|
385
413
|
if (this._storagePublic === void 0)
|
|
386
414
|
throw new Error("Storage public is not initialized");
|
|
415
|
+
if (this._storagePersistence === void 0)
|
|
416
|
+
throw new Error("Storage persistence is not initialized");
|
|
387
417
|
if (this._app === void 0)
|
|
388
418
|
throw new Error("App is not initialized");
|
|
389
419
|
const functions = (0, import_functions.getFunctions)(this._app, GCP_REGION);
|
|
@@ -395,6 +425,7 @@ var CueFirebase = class _CueFirebase {
|
|
|
395
425
|
(0, import_storage.connectStorageEmulator)(this._storageChatSessions, "localhost", 9199);
|
|
396
426
|
(0, import_storage.connectStorageEmulator)(this._storageLogs, "localhost", 9199);
|
|
397
427
|
(0, import_storage.connectStorageEmulator)(this._storagePublic, "localhost", 9199);
|
|
428
|
+
(0, import_storage.connectStorageEmulator)(this._storagePersistence, "localhost", 9199);
|
|
398
429
|
if (!this._muted)
|
|
399
430
|
console.info("Firebase emulators attached");
|
|
400
431
|
}
|
|
@@ -3782,20 +3813,20 @@ var extractIdsFromRawPath = (filePath) => {
|
|
|
3782
3813
|
const projectId = pathParts[0];
|
|
3783
3814
|
const fileName = pathParts.pop() ?? "";
|
|
3784
3815
|
const suffix = `.${fileName.split(".").pop()?.toLowerCase()}`;
|
|
3785
|
-
const documentUUID = fileName.
|
|
3816
|
+
const documentUUID = fileName.replace(/\.[^.]+$/, "");
|
|
3786
3817
|
return { projectId, documentUUID, suffix };
|
|
3787
3818
|
};
|
|
3788
3819
|
|
|
3789
3820
|
// libs/js/id-builders/src/lib/md5-builder.ts
|
|
3790
3821
|
var import_spark_md5 = __toESM(require("spark-md5"));
|
|
3791
3822
|
async function fromReadStream(readStream) {
|
|
3792
|
-
return new Promise((
|
|
3823
|
+
return new Promise((resolve2, reject) => {
|
|
3793
3824
|
const spark = new import_spark_md5.default.ArrayBuffer();
|
|
3794
3825
|
readStream.on("data", (chunk) => {
|
|
3795
3826
|
spark.append(chunk);
|
|
3796
3827
|
});
|
|
3797
3828
|
readStream.on("end", () => {
|
|
3798
|
-
|
|
3829
|
+
resolve2(spark.end());
|
|
3799
3830
|
});
|
|
3800
3831
|
readStream.on("error", (err) => reject(err));
|
|
3801
3832
|
});
|
|
@@ -4405,11 +4436,11 @@ async function retryWithBackoff(fn, maxRetries, delayMs, label) {
|
|
|
4405
4436
|
}
|
|
4406
4437
|
async function _doGzip(filePath) {
|
|
4407
4438
|
const gzFilePath = `${filePath}.gz`;
|
|
4408
|
-
await new Promise((
|
|
4439
|
+
await new Promise((resolve2, reject) => {
|
|
4409
4440
|
const gzip = (0, import_zlib.createGzip)();
|
|
4410
4441
|
const source = (0, import_fs3.createReadStream)(filePath);
|
|
4411
4442
|
const dest = (0, import_fs2.createWriteStream)(gzFilePath);
|
|
4412
|
-
(0, import_promises4.pipeline)(source, gzip, dest).then(
|
|
4443
|
+
(0, import_promises4.pipeline)(source, gzip, dest).then(resolve2).catch(reject);
|
|
4413
4444
|
});
|
|
4414
4445
|
await (0, import_promises5.unlink)(filePath);
|
|
4415
4446
|
}
|
|
@@ -5663,8 +5694,13 @@ var prefixes2 = {
|
|
|
5663
5694
|
"xsd": prefixCC["xsd"]
|
|
5664
5695
|
};
|
|
5665
5696
|
|
|
5666
|
-
// libs/js/rdf-document-writers/src/lib/
|
|
5697
|
+
// libs/js/rdf-document-writers/src/lib/custom-template-parser.ts
|
|
5667
5698
|
var import_n33 = require("n3");
|
|
5699
|
+
var { namedNode: namedNode3, literal: literal2 } = import_n33.DataFactory;
|
|
5700
|
+
var a2 = namedNode3("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
|
|
5701
|
+
|
|
5702
|
+
// libs/js/rdf-document-writers/src/lib/document-file.ts
|
|
5703
|
+
var import_n34 = require("n3");
|
|
5668
5704
|
|
|
5669
5705
|
// libs/js/rdf-document-writers/src/lib/file-suffix.ts
|
|
5670
5706
|
function getFileSuffix(filename) {
|
|
@@ -5676,17 +5712,17 @@ function getFileSuffix(filename) {
|
|
|
5676
5712
|
}
|
|
5677
5713
|
|
|
5678
5714
|
// libs/js/rdf-document-writers/src/lib/document-file.ts
|
|
5679
|
-
var { namedNode:
|
|
5680
|
-
var
|
|
5715
|
+
var { namedNode: namedNode4, literal: literal3 } = import_n34.DataFactory;
|
|
5716
|
+
var a3 = namedNode4("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
|
|
5681
5717
|
|
|
5682
5718
|
// libs/js/rdf-document-writers/src/lib/serialize-rdf.ts
|
|
5683
5719
|
async function serializeRDF(namespace, writer) {
|
|
5684
|
-
return new Promise((
|
|
5720
|
+
return new Promise((resolve2, reject) => {
|
|
5685
5721
|
writer.end((err, res) => {
|
|
5686
5722
|
if (err)
|
|
5687
5723
|
reject(err);
|
|
5688
|
-
|
|
5689
|
-
${res}`);
|
|
5724
|
+
resolve2(namespace !== "" ? `@base <${namespace}>.
|
|
5725
|
+
${res}` : res);
|
|
5690
5726
|
});
|
|
5691
5727
|
});
|
|
5692
5728
|
}
|
|
@@ -5750,7 +5786,7 @@ async function uploadFile(file, spaceId, userId, providerId) {
|
|
|
5750
5786
|
let lastError = null;
|
|
5751
5787
|
while (attempt < maxRetries) {
|
|
5752
5788
|
try {
|
|
5753
|
-
await new Promise((
|
|
5789
|
+
await new Promise((resolve2, reject) => {
|
|
5754
5790
|
const uploadTask = (0, import_storage5.uploadBytesResumable)(fileRef, fileBuffer, {
|
|
5755
5791
|
customMetadata: rawFileMetadata
|
|
5756
5792
|
});
|
|
@@ -5776,7 +5812,7 @@ async function uploadFile(file, spaceId, userId, providerId) {
|
|
|
5776
5812
|
});
|
|
5777
5813
|
reject(error);
|
|
5778
5814
|
},
|
|
5779
|
-
() =>
|
|
5815
|
+
() => resolve2()
|
|
5780
5816
|
);
|
|
5781
5817
|
if (!uploadTask) {
|
|
5782
5818
|
console.error("[uploadFile] Upload task could not be created:", {
|
|
@@ -5874,6 +5910,9 @@ async function publishMessage(topicName, data, useEmulator) {
|
|
|
5874
5910
|
}
|
|
5875
5911
|
|
|
5876
5912
|
// apps/desktop/cue-cli/src/cue-cli-sync.ts
|
|
5913
|
+
var import_promises7 = require("fs/promises");
|
|
5914
|
+
var import_fs6 = require("fs");
|
|
5915
|
+
var import_path4 = require("path");
|
|
5877
5916
|
async function syncHandler(options) {
|
|
5878
5917
|
const { space, path, verbose, provider, emulators, zip } = options;
|
|
5879
5918
|
try {
|
|
@@ -5881,8 +5920,28 @@ async function syncHandler(options) {
|
|
|
5881
5920
|
if (verbose)
|
|
5882
5921
|
console.info("Building sync base \u23F3");
|
|
5883
5922
|
const qh = async (query) => queryHandler(query, space, emulators);
|
|
5884
|
-
const
|
|
5885
|
-
|
|
5923
|
+
const resolvedPath = (0, import_path4.resolve)(path);
|
|
5924
|
+
const pathStat = await (0, import_promises7.stat)(resolvedPath);
|
|
5925
|
+
const isFile = pathStat.isFile();
|
|
5926
|
+
let localFiles;
|
|
5927
|
+
if (isFile) {
|
|
5928
|
+
if (verbose)
|
|
5929
|
+
console.info(`Path is a file, syncing single file: ${resolvedPath}`);
|
|
5930
|
+
const md5 = await fromReadStream((0, import_fs6.createReadStream)(resolvedPath));
|
|
5931
|
+
const relativePath = (0, import_path4.basename)(resolvedPath);
|
|
5932
|
+
const contentUUID = contextBasedGuid(md5);
|
|
5933
|
+
const locationUUID = generateFileUUID(relativePath, provider);
|
|
5934
|
+
localFiles = [{
|
|
5935
|
+
relativePath,
|
|
5936
|
+
fullPath: resolvedPath,
|
|
5937
|
+
md5,
|
|
5938
|
+
contentUUID,
|
|
5939
|
+
locationUUID,
|
|
5940
|
+
mtimeMs: pathStat.mtimeMs,
|
|
5941
|
+
size: pathStat.size
|
|
5942
|
+
}];
|
|
5943
|
+
} else {
|
|
5944
|
+
localFiles = await listLocalFiles(
|
|
5886
5945
|
path,
|
|
5887
5946
|
provider,
|
|
5888
5947
|
verbose,
|
|
@@ -5890,9 +5949,9 @@ async function syncHandler(options) {
|
|
|
5890
5949
|
IGNORED_LOCAL,
|
|
5891
5950
|
HASH_WORKER_PATH,
|
|
5892
5951
|
zip
|
|
5893
|
-
)
|
|
5894
|
-
|
|
5895
|
-
|
|
5952
|
+
);
|
|
5953
|
+
}
|
|
5954
|
+
const remoteFiles = await listRemoteFiles(space, provider, qh, verbose);
|
|
5896
5955
|
const report = await compareLocalRemote(localFiles, remoteFiles);
|
|
5897
5956
|
if (verbose) {
|
|
5898
5957
|
console.info("Built sync base \u2705");
|
|
@@ -5948,7 +6007,7 @@ async function syncHandler(options) {
|
|
|
5948
6007
|
continue;
|
|
5949
6008
|
}
|
|
5950
6009
|
}
|
|
5951
|
-
const zipDeletePromise = zip ? deleteUnzipped(path) : Promise.resolve();
|
|
6010
|
+
const zipDeletePromise = zip && !isFile ? deleteUnzipped(path) : Promise.resolve();
|
|
5952
6011
|
if (verbose && report.localNotOnRemotePathOnly.length)
|
|
5953
6012
|
console.info(
|
|
5954
6013
|
`Starting sync of missing file locations (on provider "${provider}") \u23F3`
|
|
@@ -6009,10 +6068,10 @@ async function syncHandler(options) {
|
|
|
6009
6068
|
// apps/desktop/cue-cli/src/main.ts
|
|
6010
6069
|
var packageJson;
|
|
6011
6070
|
try {
|
|
6012
|
-
packageJson = JSON.parse((0,
|
|
6071
|
+
packageJson = JSON.parse((0, import_fs7.readFileSync)((0, import_path5.join)(__dirname, "package.json"), "utf8"));
|
|
6013
6072
|
} catch {
|
|
6014
6073
|
try {
|
|
6015
|
-
packageJson = JSON.parse((0,
|
|
6074
|
+
packageJson = JSON.parse((0, import_fs7.readFileSync)((0, import_path5.join)(__dirname, "../package.json"), "utf8"));
|
|
6016
6075
|
} catch {
|
|
6017
6076
|
packageJson = { version: "0.0.0" };
|
|
6018
6077
|
console.warn("Could not find package.json, using fallback version");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qaecy/cue-cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.17",
|
|
4
4
|
"description": "Cue CLI for QAECY platform",
|
|
5
5
|
"main": "main.js",
|
|
6
6
|
"bin": {
|
|
@@ -20,13 +20,13 @@
|
|
|
20
20
|
"jsonld": "8.3.3",
|
|
21
21
|
"jszip": "3.10.1",
|
|
22
22
|
"n3": "1.26.0",
|
|
23
|
-
"oxigraph": "0.5.
|
|
23
|
+
"oxigraph": "0.5.3",
|
|
24
24
|
"protobufjs": "7.5.4",
|
|
25
25
|
"spark-md5": "3.0.2",
|
|
26
26
|
"sparqljs": "3.7.3",
|
|
27
27
|
"tslib": "2.3.0",
|
|
28
28
|
"uuid": "9.0.0",
|
|
29
|
-
"axios": "1.13.
|
|
29
|
+
"axios": "1.13.2"
|
|
30
30
|
},
|
|
31
31
|
"engines": {
|
|
32
32
|
"node": ">=18"
|