@qaecy/cue-cli 0.0.31 → 0.0.32

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 (2) hide show
  1. package/main.js +7 -45
  2. package/package.json +1 -1
package/main.js CHANGED
@@ -4317,7 +4317,6 @@ var CueProjects = class {
4317
4317
  // libs/js/cue-sdk/src/lib/profile.ts
4318
4318
  var import_auth4 = require("firebase/auth");
4319
4319
  var import_firestore3 = require("firebase/firestore");
4320
- var import_nanoid = require("nanoid");
4321
4320
  var COLLECTION_API_KEYS2 = "apiKeys";
4322
4321
  var CueProfile = class {
4323
4322
  constructor(_auth, app, useEmulator, emulatorHost, emulatorPort) {
@@ -4405,7 +4404,9 @@ var CueProfile = class {
4405
4404
  const uid = this._auth.currentUser?.uid;
4406
4405
  if (!uid)
4407
4406
  throw new Error("User not authenticated");
4408
- const data = { key: `cue-${(0, import_nanoid.nanoid)(150)}`, uid, expiration };
4407
+ const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
4408
+ const randomKey = Array.from(globalThis.crypto.getRandomValues(new Uint8Array(150)), (b) => alphabet[b & 63]).join("");
4409
+ const data = { key: `cue-${randomKey}`, uid, expiration };
4409
4410
  const col = (0, import_firestore3.collection)(this._db, COLLECTION_API_KEYS2);
4410
4411
  this._apiKeyDocRef = await (0, import_firestore3.addDoc)(col, data);
4411
4412
  return data;
@@ -5877,7 +5878,6 @@ function turtleFileMetadata(sourceFile, processorId, locationUUID, stored = fals
5877
5878
 
5878
5879
  // libs/js/cue-sdk/src/lib/sync.ts
5879
5880
  var _scanFn = null;
5880
- var _fileMapFn = null;
5881
5881
  var _wasmInitPromise = null;
5882
5882
  async function _initWasm() {
5883
5883
  const wasmDir = (0, import_path3.join)(__dirname, "assets", "wasm");
@@ -5889,7 +5889,6 @@ async function _initWasm() {
5889
5889
  );
5890
5890
  await mod.default({ module_or_path: wasmBinary });
5891
5891
  _scanFn = mod.scan;
5892
- _fileMapFn = mod.scan_file_map;
5893
5892
  }
5894
5893
  var DEFAULT_GRAPH_TYPE = "fuseki";
5895
5894
  var DEFAULT_SERVICE_ID = "cue-cli";
@@ -5929,27 +5928,10 @@ var CueSyncApi = class {
5929
5928
  let syncSize = report.syncSize;
5930
5929
  let failedUploads = 0;
5931
5930
  let rdfWritten = false;
5932
- let unitsConsumed = 0;
5933
- let fileUnits = {};
5934
- try {
5935
- if (!_wasmInitPromise)
5936
- _wasmInitPromise = _initWasm();
5937
- await _wasmInitPromise;
5938
- const entries = await Promise.all(
5939
- localFiles.map(async (f) => ({
5940
- originalPath: f.relativePath,
5941
- data: new Uint8Array(await (0, import_promises3.readFile)(f.fullPath))
5942
- }))
5943
- );
5944
- fileUnits = _fileMapFn(entries);
5945
- } catch (err) {
5946
- console.warn("[CueSyncApi] Unit map failed, proceeding without unit tracking:", err);
5947
- }
5948
5931
  const toUpload = report.localNotOnRemote ?? [];
5949
5932
  if (verbose && toUpload.length)
5950
5933
  console.info("Syncing missing files \u23F3");
5951
5934
  for (const file of toUpload) {
5952
- let uploadSucceeded = false;
5953
5935
  try {
5954
5936
  const rawMeta = uploadedFileMetadata(
5955
5937
  file.relativePath,
@@ -5971,7 +5953,6 @@ var CueSyncApi = class {
5971
5953
  rdfWritten = true;
5972
5954
  syncCount += 1;
5973
5955
  syncSize += file.size || 0;
5974
- uploadSucceeded = true;
5975
5956
  this._logProgress(syncCount, report.totalCount, syncSize, report.totalSize, verbose);
5976
5957
  } catch (err) {
5977
5958
  failedUploads += 1;
@@ -5979,17 +5960,6 @@ var CueSyncApi = class {
5979
5960
  if (verbose)
5980
5961
  console.error("[CueSyncApi] Upload error details:", err);
5981
5962
  }
5982
- if (uploadSucceeded) {
5983
- const fileUnitsCount = fileUnits[file.relativePath] ?? 0;
5984
- if (fileUnitsCount > 0) {
5985
- unitsConsumed += fileUnitsCount;
5986
- try {
5987
- await this._projects.incrementUnitsConsumed(spaceId, fileUnitsCount, userId);
5988
- } catch (err) {
5989
- console.error(`[CueSyncApi] Failed to write clientSync entry for ${file.relativePath}:`, err);
5990
- }
5991
- }
5992
- }
5993
5963
  }
5994
5964
  if (verbose && report.localNotOnRemotePathOnly.length)
5995
5965
  console.info(`Syncing missing file locations (on provider "${providerId}") \u23F3`);
@@ -6008,15 +5978,6 @@ var CueSyncApi = class {
6008
5978
  rdfWritten = true;
6009
5979
  syncCount += 1;
6010
5980
  syncSize += file.size || 0;
6011
- const fileUnitsCount = fileUnits[file.relativePath] ?? 0;
6012
- if (fileUnitsCount > 0) {
6013
- unitsConsumed += fileUnitsCount;
6014
- try {
6015
- await this._projects.incrementUnitsConsumed(spaceId, fileUnitsCount, userId);
6016
- } catch (err) {
6017
- console.error(`[CueSyncApi] Failed to write clientSync entry for ${file.relativePath}:`, err);
6018
- }
6019
- }
6020
5981
  this._logProgress(syncCount, report.totalCount, syncSize, report.totalSize, verbose);
6021
5982
  }
6022
5983
  return {
@@ -6025,8 +5986,7 @@ var CueSyncApi = class {
6025
5986
  failedUploads,
6026
5987
  totalCount: report.totalCount,
6027
5988
  totalSize: report.totalSize,
6028
- rdfWritten,
6029
- unitsConsumed
5989
+ rdfWritten
6030
5990
  };
6031
5991
  }
6032
5992
  async _getOrCreateGraph(spaceId, token) {
@@ -6147,6 +6107,8 @@ WHERE {
6147
6107
  data: new Uint8Array(await (0, import_promises3.readFile)(f.fullPath))
6148
6108
  }))
6149
6109
  );
6110
+ if (!_scanFn)
6111
+ throw new Error("WASM scan function not initialised");
6150
6112
  return _scanFn(entries);
6151
6113
  }
6152
6114
  _logProgress(syncCount, totalCount, syncSize, totalSize, verbose) {
@@ -6933,7 +6895,7 @@ async function syncHandler(options) {
6933
6895
  console.info(`Threw RDF_WRITING_IDLE topic \u2705`);
6934
6896
  } catch (error) {
6935
6897
  if (verbose)
6936
- console.error(`Error throwing RDF_WRITING_IDLE topic: ${error.message}`);
6898
+ console.error(`Error throwing RDF_WRITING_IDLE topic: ${error instanceof Error ? error.message : String(error)}`);
6937
6899
  if (verbose)
6938
6900
  console.warn("Continuing despite PubSub error in emulator mode...");
6939
6901
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qaecy/cue-cli",
3
- "version": "0.0.31",
3
+ "version": "0.0.32",
4
4
  "description": "Cue CLI for QAECY platform",
5
5
  "main": "main.js",
6
6
  "bin": {