@qaecy/cue-cli 0.0.12 → 0.0.14

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.
Files changed (3) hide show
  1. package/main.js +66 -10
  2. package/package.json +1 -1
  3. package/readme.md +14 -1
package/main.js CHANGED
@@ -113,7 +113,7 @@ var FIREBASE_CONFIG = (useEmulator = false) => ({
113
113
  useEmulator
114
114
  });
115
115
  var IGNORED_LOCAL = {
116
- dirs: ["node_modules", ".git", ".hg", ".svn", ".DS_Store"],
116
+ dirs: ["node_modules", ".git", ".hg", ".svn", ".DS_Store", ".Trash", ".Trashes", "$RECYCLE.BIN", "System Volume Information"],
117
117
  suffix: [".tmp", ".part", ".crdownload", ".zip", ".tar", ".gz"]
118
118
  };
119
119
 
@@ -211,6 +211,7 @@ var BUCKET_CHAT_SESSIONS = "spaces_chats_eu_west6";
211
211
  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
+ var BUCKET_PUBLIC = "cue_public_eu_west6";
214
215
  var COLLECTION_CHAT_SESSIONS = "chatSessions";
215
216
  var COLLECTION_ORGANIZATIONS = "organizations";
216
217
  var COLLECTION_PROJECTS = "projects";
@@ -272,6 +273,9 @@ var CueFirebase = class _CueFirebase {
272
273
  get storageChatSessions() {
273
274
  return this._storageChatSessions;
274
275
  }
276
+ get storagePublic() {
277
+ return this._storagePublic;
278
+ }
275
279
  get collectionChatSessions() {
276
280
  return this._collectionChatSessions;
277
281
  }
@@ -342,6 +346,7 @@ var CueFirebase = class _CueFirebase {
342
346
  this._storageRaw = (0, import_storage.getStorage)(app, BUCKET_RAW);
343
347
  this._storageChatSessions = (0, import_storage.getStorage)(app, BUCKET_CHAT_SESSIONS);
344
348
  this._storageLogs = (0, import_storage.getStorage)(app, BUCKET_LOGS);
349
+ this._storagePublic = (0, import_storage.getStorage)(app, BUCKET_PUBLIC);
345
350
  this._collectionChatSessions = (0, import_firestore.collection)(
346
351
  (0, import_firestore.getFirestore)(app),
347
352
  COLLECTION_CHAT_SESSIONS
@@ -377,6 +382,8 @@ var CueFirebase = class _CueFirebase {
377
382
  throw new Error("Storage chat sessions is not initialized");
378
383
  if (this._storageLogs === void 0)
379
384
  throw new Error("Storage logs is not initialized");
385
+ if (this._storagePublic === void 0)
386
+ throw new Error("Storage public is not initialized");
380
387
  if (this._app === void 0)
381
388
  throw new Error("App is not initialized");
382
389
  const functions = (0, import_functions.getFunctions)(this._app, GCP_REGION);
@@ -387,6 +394,7 @@ var CueFirebase = class _CueFirebase {
387
394
  (0, import_storage.connectStorageEmulator)(this._storageRaw, "localhost", 9199);
388
395
  (0, import_storage.connectStorageEmulator)(this._storageChatSessions, "localhost", 9199);
389
396
  (0, import_storage.connectStorageEmulator)(this._storageLogs, "localhost", 9199);
397
+ (0, import_storage.connectStorageEmulator)(this._storagePublic, "localhost", 9199);
390
398
  if (!this._muted)
391
399
  console.info("Firebase emulators attached");
392
400
  }
@@ -402,6 +410,7 @@ var import_storage2 = require("firebase/storage");
402
410
  var qaecyPrefixes = {
403
411
  qcy: "https://dev.qaecy.com/ont#",
404
412
  "qcy-e": "https://dev.qaecy.com/enum#",
413
+ "qcy-f": "https://dev.qaecy.com/functions#",
405
414
  obc: "https://w3id.org/obc#",
406
415
  // OpenBIM Components
407
416
  dicc: "https://w3id.org/digitalconstruction/0.5/Contexts#",
@@ -3894,12 +3903,42 @@ async function listLocalFiles(dir, providerId = "", verbose = false, logInterval
3894
3903
  });
3895
3904
  }
3896
3905
  async function filesInLocalDirRecursive(dir, filterFunc = () => true, excludeDirs = true) {
3897
- const entries = await (0, import_promises.readdir)(dir, { withFileTypes: true, recursive: true });
3898
- return entries.filter((entry) => {
3899
- if (excludeDirs && !entry.isFile())
3900
- return false;
3901
- return filterFunc(entry);
3902
- }).map((entry) => (0, import_path2.join)(entry.parentPath, entry.name));
3906
+ const results = [];
3907
+ async function traverseDir(currentDir) {
3908
+ try {
3909
+ const entries = await (0, import_promises.readdir)(currentDir, { withFileTypes: true });
3910
+ for (const entry of entries) {
3911
+ const fullPath = (0, import_path2.join)(currentDir, entry.name);
3912
+ if (entry.isFile()) {
3913
+ if (filterFunc(entry)) {
3914
+ results.push(fullPath);
3915
+ }
3916
+ } else if (entry.isDirectory() && !excludeDirs) {
3917
+ if (filterFunc(entry)) {
3918
+ results.push(fullPath);
3919
+ }
3920
+ if (filterFunc(entry)) {
3921
+ await traverseDir(fullPath);
3922
+ }
3923
+ } else if (entry.isDirectory()) {
3924
+ if (filterFunc(entry)) {
3925
+ await traverseDir(fullPath);
3926
+ }
3927
+ }
3928
+ }
3929
+ } catch (error) {
3930
+ if (error instanceof Error && "code" in error) {
3931
+ const nodeError = error;
3932
+ if (nodeError.code === "EPERM" || nodeError.code === "EACCES") {
3933
+ console.warn(`Skipping directory due to permission error: ${currentDir}`);
3934
+ return;
3935
+ }
3936
+ }
3937
+ throw error;
3938
+ }
3939
+ }
3940
+ await traverseDir(dir);
3941
+ return results;
3903
3942
  }
3904
3943
  var DEFAULT_MAX_UNCOMPRESSED_SIZE = 500 * 1024 * 1024;
3905
3944
  var DEFAULT_MAX_RECURSION_DEPTH = 3;
@@ -5694,7 +5733,7 @@ function turtleFileMetadata(sourceFile, processorId, locationUUID, stored = fals
5694
5733
 
5695
5734
  // apps/desktop/cue-cli/src/helpers/upload-file.ts
5696
5735
  var import_promises6 = require("fs/promises");
5697
- async function uploadFile(file, spaceId, userId, providerId) {
5736
+ async function uploadFile(file, spaceId, userId, providerId, verbose) {
5698
5737
  const firebase = CueFirebase.getInstance();
5699
5738
  const rawFileMetadata = uploadedFileMetadata(
5700
5739
  file.relativePath,
@@ -5713,10 +5752,27 @@ async function uploadFile(file, spaceId, userId, providerId) {
5713
5752
  uploadTask.on(
5714
5753
  "state_changed",
5715
5754
  null,
5716
- (error) => reject(error),
5755
+ (error) => {
5756
+ console.error("[uploadFile] Error uploading file:", {
5757
+ filePath: file.fullPath,
5758
+ relativePath: file.relativePath,
5759
+ md5: file.md5,
5760
+ blobName: rawFileMetadata.blob_name,
5761
+ errorCode: error?.code,
5762
+ errorMessage: error?.message,
5763
+ errorPayload: error
5764
+ });
5765
+ reject(error);
5766
+ },
5717
5767
  () => resolve()
5718
5768
  );
5719
5769
  if (!uploadTask) {
5770
+ console.error("[uploadFile] Upload task could not be created:", {
5771
+ filePath: file.fullPath,
5772
+ relativePath: file.relativePath,
5773
+ md5: file.md5,
5774
+ blobName: rawFileMetadata.blob_name
5775
+ });
5720
5776
  reject(new Error("Upload task could not be created"));
5721
5777
  }
5722
5778
  });
@@ -5840,7 +5896,7 @@ async function syncHandler(options) {
5840
5896
  console.info("Syncing missing files \u23F3");
5841
5897
  let rdfWritten = false;
5842
5898
  for (const file of report.localNotOnRemote) {
5843
- const rawFileMetadata = await uploadFile(file, space, userId, provider);
5899
+ const rawFileMetadata = await uploadFile(file, space, userId, provider, verbose);
5844
5900
  await uploadFileRDF(file, rawFileMetadata, verbose);
5845
5901
  syncCount += 1;
5846
5902
  syncSize += file.size || 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qaecy/cue-cli",
3
- "version": "0.0.12",
3
+ "version": "0.0.14",
4
4
  "description": "Cue CLI for QAECY platform",
5
5
  "main": "main.js",
6
6
  "bin": {
package/readme.md CHANGED
@@ -18,4 +18,17 @@ You need an API key in order to authenticate with the CLI tool.
18
18
  ### Sync a folder
19
19
  To sync the current dir to the space with id `<space-id>` under the provider id `d_drive` (provider id is used to distinguish different document sources and if none is provided the default provider is used). The `v`-flag is for verbose logging so we can follow the progress.
20
20
 
21
- `npx @qaecy/cue-cli sync -s <space-id> -p . --provider d_drive -v`
21
+ `npx @qaecy/cue-cli sync -s <space-id> -p . --provider d_drive -v`
22
+
23
+
24
+ ### Sync command options
25
+
26
+ | Option | Description | Default |
27
+ |-----------------------|------------------------------------------------------------------------------------------------------|--------------|
28
+ | `-s, --space <id>` | Specify the space ID (required) | N/A |
29
+ | `-p, --path <id>` | Specify the folder path to sync (required) | N/A |
30
+ | `-k, --key <api-key>` | Specify the API key (or set `CUE_API_KEY` env variable) | N/A |
31
+ | `--provider <id>` | Specify the provider ID (e.g., sharepoint, drive, dropbox). Leave empty for default provider | `""` |
32
+ | `-v, --verbose` | Enable verbose output | `false` |
33
+ | `-e, --emulators` | Use emulators for sync | `false` |
34
+ | `-z, --zip` | Include zipped content. Will be unzipped to `<zip_path>_unzipped`. Max uncompressed size: 500 MB, max recursion depth: 3. Cleans up unzipped files after sync. | `false` |