@qaecy/cue-cli 0.0.47 → 0.0.48
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/assets/wasm/dir_scanner_wasm.js +461 -0
- package/main.js +350 -57
- package/package.json +1 -1
|
@@ -0,0 +1,461 @@
|
|
|
1
|
+
/* @ts-self-types="./dir_scanner_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Attempts to extract the unit count from any supported file and returns a plain JS
|
|
5
|
+
* object `{ units: number, error: string | null }`.
|
|
6
|
+
*
|
|
7
|
+
* `original_path` is used only for extension detection.
|
|
8
|
+
*
|
|
9
|
+
* ```js
|
|
10
|
+
* const buf = await file.arrayBuffer();
|
|
11
|
+
* const result = debug_file(file.name, new Uint8Array(buf));
|
|
12
|
+
* console.log(result); // { units: 12, error: null }
|
|
13
|
+
* ```
|
|
14
|
+
* @param {string} original_path
|
|
15
|
+
* @param {Uint8Array} data
|
|
16
|
+
* @returns {any}
|
|
17
|
+
*/
|
|
18
|
+
export function debug_file(original_path, data) {
|
|
19
|
+
const ptr0 = passStringToWasm0(original_path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
20
|
+
const len0 = WASM_VECTOR_LEN;
|
|
21
|
+
const ret = wasm.debug_file(ptr0, len0, data);
|
|
22
|
+
return ret;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Scans a list of in-memory files and returns per-extension metrics sorted by
|
|
27
|
+
* file count descending.
|
|
28
|
+
*
|
|
29
|
+
* Each element of `files` must be a plain JS object with:
|
|
30
|
+
* - `originalPath` (string) — used for extension detection
|
|
31
|
+
* - `data` (Uint8Array | ArrayBuffer) — raw file bytes
|
|
32
|
+
*
|
|
33
|
+
* Returns a JS array of metric objects, or throws on invalid input.
|
|
34
|
+
*
|
|
35
|
+
* # Example (JavaScript)
|
|
36
|
+
* ```js
|
|
37
|
+
* import init, { scan } from './pkg/dir_scanner_wasm.js';
|
|
38
|
+
* await init();
|
|
39
|
+
*
|
|
40
|
+
* const response = await fetch('/docs/report.pdf');
|
|
41
|
+
* const data = new Uint8Array(await response.arrayBuffer());
|
|
42
|
+
*
|
|
43
|
+
* const metrics = scan([{ originalPath: 'report.pdf', data }]);
|
|
44
|
+
* console.log(metrics);
|
|
45
|
+
* // [{ ext: 'pdf', count: 1, percentOfFiltered: 100, percentOfAll: 100, units: 5, sizeMb: 0.12 }]
|
|
46
|
+
* ```
|
|
47
|
+
* @param {Array<any>} files
|
|
48
|
+
* @returns {any}
|
|
49
|
+
*/
|
|
50
|
+
export function scan(files) {
|
|
51
|
+
const ret = wasm.scan(files);
|
|
52
|
+
if (ret[2]) {
|
|
53
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
54
|
+
}
|
|
55
|
+
return takeFromExternrefTable0(ret[0]);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Returns a plain JS object mapping each file's original path to its unit count.
|
|
60
|
+
*
|
|
61
|
+
* Accepts the same `files` array as [`scan`].
|
|
62
|
+
*
|
|
63
|
+
* # Example (JavaScript)
|
|
64
|
+
* ```js
|
|
65
|
+
* const fileMap = scan_file_map(files);
|
|
66
|
+
* // { "docs/report.pdf": 5, "slides/deck.pptx": 12 }
|
|
67
|
+
* ```
|
|
68
|
+
* @param {Array<any>} files
|
|
69
|
+
* @returns {any}
|
|
70
|
+
*/
|
|
71
|
+
export function scan_file_map(files) {
|
|
72
|
+
const ret = wasm.scan_file_map(files);
|
|
73
|
+
if (ret[2]) {
|
|
74
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
75
|
+
}
|
|
76
|
+
return takeFromExternrefTable0(ret[0]);
|
|
77
|
+
}
|
|
78
|
+
function __wbg_get_imports() {
|
|
79
|
+
const import0 = {
|
|
80
|
+
__proto__: null,
|
|
81
|
+
__wbg_Error_960c155d3d49e4c2: function(arg0, arg1) {
|
|
82
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
83
|
+
return ret;
|
|
84
|
+
},
|
|
85
|
+
__wbg_String_8564e559799eccda: function(arg0, arg1) {
|
|
86
|
+
const ret = String(arg1);
|
|
87
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
88
|
+
const len1 = WASM_VECTOR_LEN;
|
|
89
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
90
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
91
|
+
},
|
|
92
|
+
__wbg___wbindgen_debug_string_ab4b34d23d6778bd: function(arg0, arg1) {
|
|
93
|
+
const ret = debugString(arg1);
|
|
94
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
95
|
+
const len1 = WASM_VECTOR_LEN;
|
|
96
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
97
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
98
|
+
},
|
|
99
|
+
__wbg___wbindgen_string_get_7ed5322991caaec5: function(arg0, arg1) {
|
|
100
|
+
const obj = arg1;
|
|
101
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
102
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
103
|
+
var len1 = WASM_VECTOR_LEN;
|
|
104
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
105
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
106
|
+
},
|
|
107
|
+
__wbg___wbindgen_throw_6b64449b9b9ed33c: function(arg0, arg1) {
|
|
108
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
109
|
+
},
|
|
110
|
+
__wbg_get_6011fa3a58f61074: function() { return handleError(function (arg0, arg1) {
|
|
111
|
+
const ret = Reflect.get(arg0, arg1);
|
|
112
|
+
return ret;
|
|
113
|
+
}, arguments); },
|
|
114
|
+
__wbg_get_unchecked_17f53dad852b9588: function(arg0, arg1) {
|
|
115
|
+
const ret = arg0[arg1 >>> 0];
|
|
116
|
+
return ret;
|
|
117
|
+
},
|
|
118
|
+
__wbg_length_3d4ecd04bd8d22f1: function(arg0) {
|
|
119
|
+
const ret = arg0.length;
|
|
120
|
+
return ret;
|
|
121
|
+
},
|
|
122
|
+
__wbg_length_9f1775224cf1d815: function(arg0) {
|
|
123
|
+
const ret = arg0.length;
|
|
124
|
+
return ret;
|
|
125
|
+
},
|
|
126
|
+
__wbg_log_7e1aa9064a1dbdbd: function(arg0) {
|
|
127
|
+
console.log(arg0);
|
|
128
|
+
},
|
|
129
|
+
__wbg_new_0c7403db6e782f19: function(arg0) {
|
|
130
|
+
const ret = new Uint8Array(arg0);
|
|
131
|
+
return ret;
|
|
132
|
+
},
|
|
133
|
+
__wbg_new_682678e2f47e32bc: function() {
|
|
134
|
+
const ret = new Array();
|
|
135
|
+
return ret;
|
|
136
|
+
},
|
|
137
|
+
__wbg_new_aa8d0fa9762c29bd: function() {
|
|
138
|
+
const ret = new Object();
|
|
139
|
+
return ret;
|
|
140
|
+
},
|
|
141
|
+
__wbg_prototypesetcall_a6b02eb00b0f4ce2: function(arg0, arg1, arg2) {
|
|
142
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
143
|
+
},
|
|
144
|
+
__wbg_set_022bee52d0b05b19: function() { return handleError(function (arg0, arg1, arg2) {
|
|
145
|
+
const ret = Reflect.set(arg0, arg1, arg2);
|
|
146
|
+
return ret;
|
|
147
|
+
}, arguments); },
|
|
148
|
+
__wbg_set_3bf1de9fab0cd644: function(arg0, arg1, arg2) {
|
|
149
|
+
arg0[arg1 >>> 0] = arg2;
|
|
150
|
+
},
|
|
151
|
+
__wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
|
|
152
|
+
arg0[arg1] = arg2;
|
|
153
|
+
},
|
|
154
|
+
__wbg_warn_3cc416af27dbdc02: function(arg0) {
|
|
155
|
+
console.warn(arg0);
|
|
156
|
+
},
|
|
157
|
+
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
158
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
159
|
+
const ret = arg0;
|
|
160
|
+
return ret;
|
|
161
|
+
},
|
|
162
|
+
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
163
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
164
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
165
|
+
return ret;
|
|
166
|
+
},
|
|
167
|
+
__wbindgen_cast_0000000000000003: function(arg0) {
|
|
168
|
+
// Cast intrinsic for `U64 -> Externref`.
|
|
169
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
170
|
+
return ret;
|
|
171
|
+
},
|
|
172
|
+
__wbindgen_init_externref_table: function() {
|
|
173
|
+
const table = wasm.__wbindgen_externrefs;
|
|
174
|
+
const offset = table.grow(4);
|
|
175
|
+
table.set(0, undefined);
|
|
176
|
+
table.set(offset + 0, undefined);
|
|
177
|
+
table.set(offset + 1, null);
|
|
178
|
+
table.set(offset + 2, true);
|
|
179
|
+
table.set(offset + 3, false);
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
return {
|
|
183
|
+
__proto__: null,
|
|
184
|
+
"./dir_scanner_wasm_bg.js": import0,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function addToExternrefTable0(obj) {
|
|
189
|
+
const idx = wasm.__externref_table_alloc();
|
|
190
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
191
|
+
return idx;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function debugString(val) {
|
|
195
|
+
// primitive types
|
|
196
|
+
const type = typeof val;
|
|
197
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
198
|
+
return `${val}`;
|
|
199
|
+
}
|
|
200
|
+
if (type == 'string') {
|
|
201
|
+
return `"${val}"`;
|
|
202
|
+
}
|
|
203
|
+
if (type == 'symbol') {
|
|
204
|
+
const description = val.description;
|
|
205
|
+
if (description == null) {
|
|
206
|
+
return 'Symbol';
|
|
207
|
+
} else {
|
|
208
|
+
return `Symbol(${description})`;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
if (type == 'function') {
|
|
212
|
+
const name = val.name;
|
|
213
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
214
|
+
return `Function(${name})`;
|
|
215
|
+
} else {
|
|
216
|
+
return 'Function';
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
// objects
|
|
220
|
+
if (Array.isArray(val)) {
|
|
221
|
+
const length = val.length;
|
|
222
|
+
let debug = '[';
|
|
223
|
+
if (length > 0) {
|
|
224
|
+
debug += debugString(val[0]);
|
|
225
|
+
}
|
|
226
|
+
for(let i = 1; i < length; i++) {
|
|
227
|
+
debug += ', ' + debugString(val[i]);
|
|
228
|
+
}
|
|
229
|
+
debug += ']';
|
|
230
|
+
return debug;
|
|
231
|
+
}
|
|
232
|
+
// Test for built-in
|
|
233
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
234
|
+
let className;
|
|
235
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
236
|
+
className = builtInMatches[1];
|
|
237
|
+
} else {
|
|
238
|
+
// Failed to match the standard '[object ClassName]'
|
|
239
|
+
return toString.call(val);
|
|
240
|
+
}
|
|
241
|
+
if (className == 'Object') {
|
|
242
|
+
// we're a user defined class or Object
|
|
243
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
244
|
+
// easier than looping through ownProperties of `val`.
|
|
245
|
+
try {
|
|
246
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
247
|
+
} catch (_) {
|
|
248
|
+
return 'Object';
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
// errors
|
|
252
|
+
if (val instanceof Error) {
|
|
253
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
254
|
+
}
|
|
255
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
256
|
+
return className;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
260
|
+
ptr = ptr >>> 0;
|
|
261
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
let cachedDataViewMemory0 = null;
|
|
265
|
+
function getDataViewMemory0() {
|
|
266
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
267
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
268
|
+
}
|
|
269
|
+
return cachedDataViewMemory0;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
function getStringFromWasm0(ptr, len) {
|
|
273
|
+
ptr = ptr >>> 0;
|
|
274
|
+
return decodeText(ptr, len);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
let cachedUint8ArrayMemory0 = null;
|
|
278
|
+
function getUint8ArrayMemory0() {
|
|
279
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
280
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
281
|
+
}
|
|
282
|
+
return cachedUint8ArrayMemory0;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
function handleError(f, args) {
|
|
286
|
+
try {
|
|
287
|
+
return f.apply(this, args);
|
|
288
|
+
} catch (e) {
|
|
289
|
+
const idx = addToExternrefTable0(e);
|
|
290
|
+
wasm.__wbindgen_exn_store(idx);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
function isLikeNone(x) {
|
|
295
|
+
return x === undefined || x === null;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
299
|
+
if (realloc === undefined) {
|
|
300
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
301
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
302
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
303
|
+
WASM_VECTOR_LEN = buf.length;
|
|
304
|
+
return ptr;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
let len = arg.length;
|
|
308
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
309
|
+
|
|
310
|
+
const mem = getUint8ArrayMemory0();
|
|
311
|
+
|
|
312
|
+
let offset = 0;
|
|
313
|
+
|
|
314
|
+
for (; offset < len; offset++) {
|
|
315
|
+
const code = arg.charCodeAt(offset);
|
|
316
|
+
if (code > 0x7F) break;
|
|
317
|
+
mem[ptr + offset] = code;
|
|
318
|
+
}
|
|
319
|
+
if (offset !== len) {
|
|
320
|
+
if (offset !== 0) {
|
|
321
|
+
arg = arg.slice(offset);
|
|
322
|
+
}
|
|
323
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
324
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
325
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
326
|
+
|
|
327
|
+
offset += ret.written;
|
|
328
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
WASM_VECTOR_LEN = offset;
|
|
332
|
+
return ptr;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
function takeFromExternrefTable0(idx) {
|
|
336
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
337
|
+
wasm.__externref_table_dealloc(idx);
|
|
338
|
+
return value;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
342
|
+
cachedTextDecoder.decode();
|
|
343
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
344
|
+
let numBytesDecoded = 0;
|
|
345
|
+
function decodeText(ptr, len) {
|
|
346
|
+
numBytesDecoded += len;
|
|
347
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
348
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
349
|
+
cachedTextDecoder.decode();
|
|
350
|
+
numBytesDecoded = len;
|
|
351
|
+
}
|
|
352
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
const cachedTextEncoder = new TextEncoder();
|
|
356
|
+
|
|
357
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
358
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
359
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
360
|
+
view.set(buf);
|
|
361
|
+
return {
|
|
362
|
+
read: arg.length,
|
|
363
|
+
written: buf.length
|
|
364
|
+
};
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
let WASM_VECTOR_LEN = 0;
|
|
369
|
+
|
|
370
|
+
let wasmModule, wasm;
|
|
371
|
+
function __wbg_finalize_init(instance, module) {
|
|
372
|
+
wasm = instance.exports;
|
|
373
|
+
wasmModule = module;
|
|
374
|
+
cachedDataViewMemory0 = null;
|
|
375
|
+
cachedUint8ArrayMemory0 = null;
|
|
376
|
+
wasm.__wbindgen_start();
|
|
377
|
+
return wasm;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
async function __wbg_load(module, imports) {
|
|
381
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
382
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
383
|
+
try {
|
|
384
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
385
|
+
} catch (e) {
|
|
386
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
387
|
+
|
|
388
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
389
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
390
|
+
|
|
391
|
+
} else { throw e; }
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
const bytes = await module.arrayBuffer();
|
|
396
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
397
|
+
} else {
|
|
398
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
399
|
+
|
|
400
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
401
|
+
return { instance, module };
|
|
402
|
+
} else {
|
|
403
|
+
return instance;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
function expectedResponseType(type) {
|
|
408
|
+
switch (type) {
|
|
409
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
410
|
+
}
|
|
411
|
+
return false;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
function initSync(module) {
|
|
416
|
+
if (wasm !== undefined) return wasm;
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
if (module !== undefined) {
|
|
420
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
421
|
+
({module} = module)
|
|
422
|
+
} else {
|
|
423
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
const imports = __wbg_get_imports();
|
|
428
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
429
|
+
module = new WebAssembly.Module(module);
|
|
430
|
+
}
|
|
431
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
432
|
+
return __wbg_finalize_init(instance, module);
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
async function __wbg_init(module_or_path) {
|
|
436
|
+
if (wasm !== undefined) return wasm;
|
|
437
|
+
|
|
438
|
+
|
|
439
|
+
if (module_or_path !== undefined) {
|
|
440
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
441
|
+
({module_or_path} = module_or_path)
|
|
442
|
+
} else {
|
|
443
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
if (module_or_path === undefined) {
|
|
448
|
+
module_or_path = new URL('dir_scanner_wasm_bg.wasm', import.meta.url);
|
|
449
|
+
}
|
|
450
|
+
const imports = __wbg_get_imports();
|
|
451
|
+
|
|
452
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
453
|
+
module_or_path = fetch(module_or_path);
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
457
|
+
|
|
458
|
+
return __wbg_finalize_init(instance, module);
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
export { initSync, __wbg_init as default };
|
package/main.js
CHANGED
|
@@ -5339,6 +5339,46 @@ var CueAuth = class {
|
|
|
5339
5339
|
}
|
|
5340
5340
|
};
|
|
5341
5341
|
|
|
5342
|
+
// libs/js/cue-sdk/src/lib/storage.ts
|
|
5343
|
+
var CueStorage = class {
|
|
5344
|
+
constructor(_blob) {
|
|
5345
|
+
this._blob = _blob;
|
|
5346
|
+
}
|
|
5347
|
+
/**
|
|
5348
|
+
* Returns a Firebase authenticated download URL for a document stored in Cue.
|
|
5349
|
+
*
|
|
5350
|
+
* The storage path is `{projectId}/{uuid}{suffix}`, e.g. `my-project/abc-123.pdf`.
|
|
5351
|
+
*
|
|
5352
|
+
* @param projectId - The Cue project (space) ID.
|
|
5353
|
+
* @param uuid - The document UUID.
|
|
5354
|
+
* @param suffix - File suffix including the leading dot, e.g. `'.pdf'`, `'.ifc'`.
|
|
5355
|
+
* @param bucket - `'raw'` (default, original uploads) or `'processed'` (derived artefacts).
|
|
5356
|
+
*/
|
|
5357
|
+
async getDownloadUrl(projectId, uuid, suffix, bucket = "raw") {
|
|
5358
|
+
const path = `${projectId}/${uuid}${suffix}`;
|
|
5359
|
+
const url = await this._blob.getDownloadURL(bucket, path);
|
|
5360
|
+
if (!url)
|
|
5361
|
+
throw new Error(`File not found in storage: ${path} (bucket: ${bucket})`);
|
|
5362
|
+
return url;
|
|
5363
|
+
}
|
|
5364
|
+
/**
|
|
5365
|
+
* Returns a Firebase authenticated download URL for an alternative representation
|
|
5366
|
+
* using its full `qcy:remoteRelativePath` stored in the processed bucket.
|
|
5367
|
+
*
|
|
5368
|
+
* Use this instead of `getDownloadUrl` when the document info was obtained via
|
|
5369
|
+
* `fetchAlternativeRepresentations` and carries a `remoteRelativePath`.
|
|
5370
|
+
*
|
|
5371
|
+
* @param remoteRelativePath - The full path in the processed bucket,
|
|
5372
|
+
* e.g. `{projectId}/fragments/{uuid}.fragments`.
|
|
5373
|
+
*/
|
|
5374
|
+
async getAltRepDownloadUrl(remoteRelativePath) {
|
|
5375
|
+
const url = await this._blob.getDownloadURL("processed", remoteRelativePath);
|
|
5376
|
+
if (!url)
|
|
5377
|
+
throw new Error(`Alternative representation not found in storage: ${remoteRelativePath}`);
|
|
5378
|
+
return url;
|
|
5379
|
+
}
|
|
5380
|
+
};
|
|
5381
|
+
|
|
5342
5382
|
// libs/js/cue-sdk/src/lib/tables.ts
|
|
5343
5383
|
var ENDPOINT_DATA_VIEWS_TABLES = "/data-views/tables";
|
|
5344
5384
|
var ENDPOINT_COMMANDS_TABLES = "/commands/tables";
|
|
@@ -8502,7 +8542,127 @@ var CueProjectDocuments = class {
|
|
|
8502
8542
|
const newUUIDs = uuids.filter((id) => this._documentInfoMap.get()[id] === void 0);
|
|
8503
8543
|
if (newUUIDs.length === 0)
|
|
8504
8544
|
return;
|
|
8505
|
-
|
|
8545
|
+
this._fetchDocumentInfoBatch(newUUIDs).catch(
|
|
8546
|
+
(err) => console.error("[CueProjectDocuments] requestDocumentData failed:", err)
|
|
8547
|
+
);
|
|
8548
|
+
}
|
|
8549
|
+
/**
|
|
8550
|
+
* Promise-based alternative to {@link requestDocumentData} for non-reactive contexts.
|
|
8551
|
+
*
|
|
8552
|
+
* Resolves with the `DocumentInfo` entries for every requested UUID once the
|
|
8553
|
+
* SPARQL response arrives. UUIDs already present in the cache are returned
|
|
8554
|
+
* immediately without a network request. The result is also written into
|
|
8555
|
+
* `documentInfoMap` so reactive consumers stay in sync.
|
|
8556
|
+
*
|
|
8557
|
+
* UUIDs not found in the triplestore are omitted from the returned map.
|
|
8558
|
+
*
|
|
8559
|
+
* @example
|
|
8560
|
+
* ```ts
|
|
8561
|
+
* const docs = await cueProjectDocs.fetchDocumentData(['uuid1', 'uuid2']);
|
|
8562
|
+
* console.log(docs['uuid1'].subject);
|
|
8563
|
+
* ```
|
|
8564
|
+
*/
|
|
8565
|
+
async fetchDocumentData(uuids) {
|
|
8566
|
+
const current = this._documentInfoMap.get();
|
|
8567
|
+
const newUUIDs = uuids.filter((id) => current[id] === void 0);
|
|
8568
|
+
if (newUUIDs.length > 0) {
|
|
8569
|
+
await this._fetchDocumentInfoBatch(newUUIDs);
|
|
8570
|
+
}
|
|
8571
|
+
const updated = this._documentInfoMap.get();
|
|
8572
|
+
return Object.fromEntries(
|
|
8573
|
+
uuids.filter((id) => updated[id] !== void 0).map((id) => [id, updated[id]])
|
|
8574
|
+
);
|
|
8575
|
+
}
|
|
8576
|
+
/**
|
|
8577
|
+
* Fetches a lightweight document metadata shape (id/path/suffix/size) for
|
|
8578
|
+
* the given UUIDs and merges the results into `documentInfoMap`.
|
|
8579
|
+
*
|
|
8580
|
+
* This is useful for list/table contexts that do not need language-tagged
|
|
8581
|
+
* fields (`subject`, `summary`) or category/tag enrichment.
|
|
8582
|
+
*
|
|
8583
|
+
* UUIDs already present in `documentInfoMap` are skipped.
|
|
8584
|
+
*/
|
|
8585
|
+
async fetchDocumentDataSimple(uuids) {
|
|
8586
|
+
const current = this._documentInfoMap.get();
|
|
8587
|
+
const newUUIDs = uuids.filter((id) => current[id] === void 0);
|
|
8588
|
+
if (newUUIDs.length > 0) {
|
|
8589
|
+
await this._fetchSimpleDocumentInfoBatch(newUUIDs);
|
|
8590
|
+
}
|
|
8591
|
+
const updated = this._documentInfoMap.get();
|
|
8592
|
+
return Object.fromEntries(
|
|
8593
|
+
uuids.filter((id) => updated[id] !== void 0).map((id) => [id, updated[id]])
|
|
8594
|
+
);
|
|
8595
|
+
}
|
|
8596
|
+
/**
|
|
8597
|
+
* Returns the alternative representations of the given document UUID.
|
|
8598
|
+
*
|
|
8599
|
+
* Alternative representations are derived artefacts stored under
|
|
8600
|
+
* `qcy:alternativeRepresentation` in the triplestore — for example a
|
|
8601
|
+
* `.fragments` BIM tile derived from an `.ifc` source file.
|
|
8602
|
+
*
|
|
8603
|
+
* The returned `DocumentInfo` entries are also merged into
|
|
8604
|
+
* `documentInfoMap` so reactive consumers stay in sync.
|
|
8605
|
+
*
|
|
8606
|
+
* @example
|
|
8607
|
+
* ```ts
|
|
8608
|
+
* const alts = await docs.fetchAlternativeRepresentations('abc-123');
|
|
8609
|
+
* // alts[0].suffix => '.fragments'
|
|
8610
|
+
* ```
|
|
8611
|
+
*/
|
|
8612
|
+
async fetchAlternativeRepresentations(uuid) {
|
|
8613
|
+
const q = `PREFIX qcy: <${qaecyPrefixes["qcy"]}>
|
|
8614
|
+
PREFIX r: <${this.baseURL}>
|
|
8615
|
+
SELECT ?altId ?contentIRI ?suffix ?rrp
|
|
8616
|
+
WHERE {
|
|
8617
|
+
r:${uuid} qcy:alternativeRepresentation ?contentIRI .
|
|
8618
|
+
BIND(REPLACE(STR(?contentIRI), "^.*/([^/]*)$", "$1") AS ?altId)
|
|
8619
|
+
?contentIRI qcy:hasFileLocation ?loc .
|
|
8620
|
+
?loc qcy:suffix ?suffix .
|
|
8621
|
+
OPTIONAL { ?loc qcy:remoteRelativePath ?rrp }
|
|
8622
|
+
}`;
|
|
8623
|
+
const data = await this._api.sparql(q, this._projectId, this._graphType);
|
|
8624
|
+
const updates = { ...this._documentInfoMap.get() };
|
|
8625
|
+
const alts = [];
|
|
8626
|
+
data.results.bindings.forEach((b) => {
|
|
8627
|
+
if (!b["altId"] || !b["contentIRI"])
|
|
8628
|
+
return;
|
|
8629
|
+
const id = b["altId"].value;
|
|
8630
|
+
const info = {
|
|
8631
|
+
id,
|
|
8632
|
+
contentIRI: b["contentIRI"].value,
|
|
8633
|
+
path: "",
|
|
8634
|
+
suffix: b["suffix"]?.value ?? "",
|
|
8635
|
+
size: 0,
|
|
8636
|
+
tags: [],
|
|
8637
|
+
categories: [],
|
|
8638
|
+
remoteRelativePath: b["rrp"]?.value
|
|
8639
|
+
};
|
|
8640
|
+
updates[id] = info;
|
|
8641
|
+
alts.push(info);
|
|
8642
|
+
});
|
|
8643
|
+
this._documentInfoMap.set(updates);
|
|
8644
|
+
return alts;
|
|
8645
|
+
}
|
|
8646
|
+
/**
|
|
8647
|
+
* Returns a single arbitrary file path from the project's triplestore.
|
|
8648
|
+
* Useful for pre-filling path-based query inputs with a realistic example.
|
|
8649
|
+
*/
|
|
8650
|
+
async randomFilePath() {
|
|
8651
|
+
const q = `PREFIX qcy: <${qaecyPrefixes["qcy"]}>
|
|
8652
|
+
SELECT ?path
|
|
8653
|
+
WHERE {
|
|
8654
|
+
?fl a qcy:FileLocation ;
|
|
8655
|
+
qcy:filePath ?path .
|
|
8656
|
+
}
|
|
8657
|
+
LIMIT 1`;
|
|
8658
|
+
const data = await this._api.sparql(q, this._projectId, this._graphType);
|
|
8659
|
+
return data.results.bindings[0]?.["path"]?.value ?? null;
|
|
8660
|
+
}
|
|
8661
|
+
// ── Private helpers ────────────────────────────────────────────────────────
|
|
8662
|
+
/** Executes the document-info SPARQL query for the given UUIDs, merges results
|
|
8663
|
+
* into `documentInfoMap`, and returns the newly fetched entries. */
|
|
8664
|
+
async _fetchDocumentInfoBatch(uuids) {
|
|
8665
|
+
const values = uuids.map((id) => `r:${id}`).join(" ");
|
|
8506
8666
|
const lang = this._api.language;
|
|
8507
8667
|
const q = `PREFIX qcy: <${qaecyPrefixes["qcy"]}>
|
|
8508
8668
|
PREFIX r: <${this.baseURL}>
|
|
@@ -8531,47 +8691,73 @@ WHERE {
|
|
|
8531
8691
|
BIND(REPLACE(STR(?contentIRI), "^.*/([^/]*)$", "$1") AS ?id)
|
|
8532
8692
|
}
|
|
8533
8693
|
GROUP BY ?id ?contentIRI ?suffix ?size ?subject ?summary`;
|
|
8534
|
-
this._api.sparql(q, this._projectId)
|
|
8535
|
-
|
|
8536
|
-
|
|
8537
|
-
|
|
8538
|
-
|
|
8539
|
-
|
|
8540
|
-
|
|
8541
|
-
|
|
8542
|
-
|
|
8543
|
-
|
|
8544
|
-
|
|
8545
|
-
|
|
8546
|
-
|
|
8547
|
-
|
|
8548
|
-
|
|
8549
|
-
|
|
8550
|
-
|
|
8551
|
-
|
|
8552
|
-
|
|
8553
|
-
|
|
8554
|
-
|
|
8555
|
-
})
|
|
8556
|
-
|
|
8557
|
-
|
|
8694
|
+
const result = await this._api.sparql(q, this._projectId);
|
|
8695
|
+
const updates = { ...this._documentInfoMap.get() };
|
|
8696
|
+
const fetched = {};
|
|
8697
|
+
result.results.bindings.forEach((b) => {
|
|
8698
|
+
if (!b["id"] || !b["contentIRI"])
|
|
8699
|
+
return;
|
|
8700
|
+
const id = b["id"].value;
|
|
8701
|
+
const info = {
|
|
8702
|
+
id,
|
|
8703
|
+
contentIRI: b["contentIRI"].value,
|
|
8704
|
+
path: b["path"]?.value ?? "",
|
|
8705
|
+
suffix: b["suffix"]?.value ?? "",
|
|
8706
|
+
size: b["size"] ? parseInt(b["size"].value, 10) : 0,
|
|
8707
|
+
tags: b["tags"]?.value?.split(";").filter(Boolean) ?? [],
|
|
8708
|
+
categories: b["categories"]?.value?.split(";").filter(Boolean) ?? [],
|
|
8709
|
+
subject: b["subject"]?.value,
|
|
8710
|
+
summary: b["summary"]?.value,
|
|
8711
|
+
providerId: b["pid"]?.value
|
|
8712
|
+
};
|
|
8713
|
+
updates[id] = info;
|
|
8714
|
+
fetched[id] = info;
|
|
8715
|
+
});
|
|
8716
|
+
this._documentInfoMap.set(updates);
|
|
8717
|
+
return fetched;
|
|
8558
8718
|
}
|
|
8559
|
-
/**
|
|
8560
|
-
*
|
|
8561
|
-
|
|
8562
|
-
|
|
8563
|
-
async randomFilePath() {
|
|
8719
|
+
/** Executes a reduced document-info query (id/path/suffix/size only), merges
|
|
8720
|
+
* into `documentInfoMap`, and returns newly fetched entries. */
|
|
8721
|
+
async _fetchSimpleDocumentInfoBatch(uuids) {
|
|
8722
|
+
const values = uuids.map((id) => `r:${id}`).join(" ");
|
|
8564
8723
|
const q = `PREFIX qcy: <${qaecyPrefixes["qcy"]}>
|
|
8565
|
-
|
|
8724
|
+
PREFIX r: <${this.baseURL}>
|
|
8725
|
+
SELECT ?id ?contentIRI ?suffix ?size (SAMPLE(?fp) AS ?path)
|
|
8566
8726
|
WHERE {
|
|
8567
|
-
?
|
|
8568
|
-
|
|
8727
|
+
VALUES ?contentIRI { ${values} }
|
|
8728
|
+
?contentIRI qcy:sizeBytes ?size ;
|
|
8729
|
+
qcy:hasFileLocation ?loc .
|
|
8730
|
+
?loc qcy:filePath ?fp ;
|
|
8731
|
+
qcy:suffix ?suffix .
|
|
8732
|
+
BIND(REPLACE(STR(?contentIRI), "^.*/([^/]*)$", "$1") AS ?id)
|
|
8569
8733
|
}
|
|
8570
|
-
|
|
8571
|
-
const
|
|
8572
|
-
|
|
8734
|
+
GROUP BY ?id ?contentIRI ?suffix ?size`;
|
|
8735
|
+
const result = await this._api.sparql(q, this._projectId, this._graphType);
|
|
8736
|
+
const updates = { ...this._documentInfoMap.get() };
|
|
8737
|
+
const fetched = {};
|
|
8738
|
+
result.results.bindings.forEach((b) => {
|
|
8739
|
+
if (!b["id"])
|
|
8740
|
+
return;
|
|
8741
|
+
const id = b["id"].value;
|
|
8742
|
+
const existing = updates[id];
|
|
8743
|
+
const info = {
|
|
8744
|
+
id,
|
|
8745
|
+
contentIRI: b["contentIRI"]?.value ?? existing?.contentIRI ?? id,
|
|
8746
|
+
path: b["path"]?.value ?? existing?.path ?? id,
|
|
8747
|
+
suffix: b["suffix"]?.value ?? existing?.suffix ?? "",
|
|
8748
|
+
size: b["size"] ? parseInt(b["size"].value, 10) : existing?.size ?? 0,
|
|
8749
|
+
tags: existing?.tags ?? [],
|
|
8750
|
+
categories: existing?.categories ?? [],
|
|
8751
|
+
subject: existing?.subject,
|
|
8752
|
+
summary: existing?.summary,
|
|
8753
|
+
providerId: existing?.providerId
|
|
8754
|
+
};
|
|
8755
|
+
updates[id] = info;
|
|
8756
|
+
fetched[id] = info;
|
|
8757
|
+
});
|
|
8758
|
+
this._documentInfoMap.set(updates);
|
|
8759
|
+
return fetched;
|
|
8573
8760
|
}
|
|
8574
|
-
// ── Private helpers ────────────────────────────────────────────────────────
|
|
8575
8761
|
async _fetchDocumentsBySuffix() {
|
|
8576
8762
|
return this._runDocumentsBySuffixQuery(this._buildDocumentsBySuffixQuery());
|
|
8577
8763
|
}
|
|
@@ -10506,10 +10692,14 @@ var Cue = class _Cue {
|
|
|
10506
10692
|
profile;
|
|
10507
10693
|
privileges;
|
|
10508
10694
|
cache;
|
|
10695
|
+
storage;
|
|
10509
10696
|
_app;
|
|
10510
10697
|
_endpoints;
|
|
10511
10698
|
_isEmulator;
|
|
10699
|
+
_storageRaw;
|
|
10700
|
+
_storageProcessed;
|
|
10512
10701
|
_gis = null;
|
|
10702
|
+
_projectDocuments = /* @__PURE__ */ new Map();
|
|
10513
10703
|
/**
|
|
10514
10704
|
* Reactive GIS service. Lazily constructed on first access.
|
|
10515
10705
|
*
|
|
@@ -10553,7 +10743,26 @@ var Cue = class _Cue {
|
|
|
10553
10743
|
});
|
|
10554
10744
|
this.auth = new CueAuth(this._app, this._isEmulator, this._endpoints);
|
|
10555
10745
|
this.projects = new CueProjects(this.auth, this._app, this._isEmulator, this._endpoints);
|
|
10746
|
+
this._storageRaw = (0, import_storage5.getStorage)(this._app, BUCKET_RAW2);
|
|
10747
|
+
this._storageProcessed = (0, import_storage5.getStorage)(this._app, BUCKET_PROCESSED2);
|
|
10748
|
+
const storagePublic = (0, import_storage5.getStorage)(this._app, BUCKET_PUBLIC2);
|
|
10749
|
+
const storageLogs = (0, import_storage5.getStorage)(this._app, BUCKET_LOGS2);
|
|
10750
|
+
const storageChatSessions = (0, import_storage5.getStorage)(this._app, BUCKET_CHAT_SESSIONS2);
|
|
10751
|
+
const storagePersistence = (0, import_storage5.getStorage)(this._app, BUCKET_PERSISTENCE2);
|
|
10752
|
+
if (this._isEmulator) {
|
|
10753
|
+
(0, import_storage5.connectStorageEmulator)(this._storageRaw, this._endpoints.storageEmulatorHost, this._endpoints.storageEmulatorPort);
|
|
10754
|
+
(0, import_storage5.connectStorageEmulator)(this._storageProcessed, this._endpoints.storageEmulatorHost, this._endpoints.storageEmulatorPort);
|
|
10755
|
+
}
|
|
10556
10756
|
this.api = this._buildApi(this.projects);
|
|
10757
|
+
const blob = new CueBlobStorage({
|
|
10758
|
+
storageRaw: this._storageRaw,
|
|
10759
|
+
storageProcessed: this._storageProcessed,
|
|
10760
|
+
storagePublic,
|
|
10761
|
+
storageLogs,
|
|
10762
|
+
storageChatSessions,
|
|
10763
|
+
storagePersistence
|
|
10764
|
+
});
|
|
10765
|
+
this.storage = new CueStorage(blob);
|
|
10557
10766
|
this.profile = new CueProfile(
|
|
10558
10767
|
this.auth,
|
|
10559
10768
|
this._app,
|
|
@@ -10561,7 +10770,6 @@ var Cue = class _Cue {
|
|
|
10561
10770
|
this._endpoints.gatewayUrl
|
|
10562
10771
|
);
|
|
10563
10772
|
this.privileges = new CuePrivileges(this.auth.isSuperAdmin);
|
|
10564
|
-
const storagePersistence = (0, import_storage5.getStorage)(this._app, BUCKET_PERSISTENCE2);
|
|
10565
10773
|
if (this._isEmulator) {
|
|
10566
10774
|
(0, import_storage5.connectStorageEmulator)(storagePersistence, this._endpoints.storageEmulatorHost, this._endpoints.storageEmulatorPort);
|
|
10567
10775
|
}
|
|
@@ -10609,16 +10817,20 @@ var Cue = class _Cue {
|
|
|
10609
10817
|
const instance = Object.create(_Cue.prototype);
|
|
10610
10818
|
const privileges = new CuePrivileges(auth.isSuperAdmin);
|
|
10611
10819
|
const cache = new CueCache(storagePersistence);
|
|
10820
|
+
const storage = new CueStorage(blob);
|
|
10612
10821
|
Object.assign(instance, {
|
|
10613
10822
|
_app: app,
|
|
10614
10823
|
_endpoints: endpoints,
|
|
10615
10824
|
_isEmulator: env === "emulator",
|
|
10825
|
+
_storageRaw: storageRaw,
|
|
10826
|
+
_storageProcessed: storageProcessed,
|
|
10616
10827
|
auth,
|
|
10617
10828
|
api,
|
|
10618
10829
|
projects,
|
|
10619
10830
|
profile,
|
|
10620
10831
|
privileges,
|
|
10621
|
-
cache
|
|
10832
|
+
cache,
|
|
10833
|
+
storage
|
|
10622
10834
|
});
|
|
10623
10835
|
return instance;
|
|
10624
10836
|
}
|
|
@@ -10651,27 +10863,105 @@ var Cue = class _Cue {
|
|
|
10651
10863
|
};
|
|
10652
10864
|
return new CueProjectView(this.api, projectId, { ...opts, queryCache });
|
|
10653
10865
|
}
|
|
10866
|
+
/**
|
|
10867
|
+
* Creates a `CueProjectEntities` instance for the given project, with the
|
|
10868
|
+
* SDK query cache wired automatically.
|
|
10869
|
+
*
|
|
10870
|
+
* Prefer this over `new CueProjectEntities(cue.api, projectId)` — it avoids
|
|
10871
|
+
* the manual cache setup and keeps the instance bound to the correct API.
|
|
10872
|
+
*
|
|
10873
|
+
* @example
|
|
10874
|
+
* ```ts
|
|
10875
|
+
* const entities = cue.createProjectEntities('my-project');
|
|
10876
|
+
* entities.requestEntityData(['uuid1']);
|
|
10877
|
+
* const info = entities.entityInfoMap.get()['uuid1'];
|
|
10878
|
+
*
|
|
10879
|
+
* // Promise-based (no signal polling needed):
|
|
10880
|
+
* const graph = await entities.buildSummaryGraph('graph');
|
|
10881
|
+
* ```
|
|
10882
|
+
*/
|
|
10883
|
+
createProjectEntities(projectId, opts) {
|
|
10884
|
+
const queryCache = opts?.queryCache ?? {
|
|
10885
|
+
get: (key) => this.cache.getQueryCache(projectId, key).then((entry) => entry?.results),
|
|
10886
|
+
set: (key, data) => this.cache.setQueryCache(projectId, key, { query: key, results: data })
|
|
10887
|
+
};
|
|
10888
|
+
return new CueProjectEntities(
|
|
10889
|
+
this.api,
|
|
10890
|
+
projectId,
|
|
10891
|
+
opts?.rdfBase,
|
|
10892
|
+
queryCache,
|
|
10893
|
+
opts?.graphType
|
|
10894
|
+
);
|
|
10895
|
+
}
|
|
10896
|
+
/**
|
|
10897
|
+
* Creates a `CueProjectDocuments` instance for the given project, with the
|
|
10898
|
+
* SDK query cache wired automatically.
|
|
10899
|
+
*
|
|
10900
|
+
* Prefer this over `new CueProjectDocuments(cue.api, projectId)` — it avoids
|
|
10901
|
+
* the manual cache setup and keeps the instance bound to the correct API.
|
|
10902
|
+
*
|
|
10903
|
+
* @example
|
|
10904
|
+
* ```ts
|
|
10905
|
+
* const docs = cue.createProjectDocuments('my-project');
|
|
10906
|
+
* await docs.fetchOverview();
|
|
10907
|
+
* const data = await docs.fetchDocumentData(['uuid1', 'uuid2']);
|
|
10908
|
+
* ```
|
|
10909
|
+
*/
|
|
10910
|
+
createProjectDocuments(projectId, opts) {
|
|
10911
|
+
const hasCustomOptions = opts?.language !== void 0 || opts?.rdfBase !== void 0 || opts?.graphType !== void 0 || opts?.queryCache !== void 0;
|
|
10912
|
+
if (!hasCustomOptions) {
|
|
10913
|
+
const existing = this._projectDocuments.get(projectId);
|
|
10914
|
+
if (existing) {
|
|
10915
|
+
existing.setLanguage(this.api.language);
|
|
10916
|
+
return existing;
|
|
10917
|
+
}
|
|
10918
|
+
const queryCache2 = {
|
|
10919
|
+
get: (key) => this.cache.getQueryCache(projectId, key).then((entry) => entry?.results),
|
|
10920
|
+
set: (key, data) => this.cache.setQueryCache(projectId, key, { query: key, results: data })
|
|
10921
|
+
};
|
|
10922
|
+
const docs = new CueProjectDocuments(
|
|
10923
|
+
this.api,
|
|
10924
|
+
projectId,
|
|
10925
|
+
this.api.language,
|
|
10926
|
+
void 0,
|
|
10927
|
+
queryCache2,
|
|
10928
|
+
void 0
|
|
10929
|
+
);
|
|
10930
|
+
this._projectDocuments.set(projectId, docs);
|
|
10931
|
+
return docs;
|
|
10932
|
+
}
|
|
10933
|
+
const queryCache = opts?.queryCache ?? {
|
|
10934
|
+
get: (key) => this.cache.getQueryCache(projectId, key).then((entry) => entry?.results),
|
|
10935
|
+
set: (key, data) => this.cache.setQueryCache(projectId, key, { query: key, results: data })
|
|
10936
|
+
};
|
|
10937
|
+
return new CueProjectDocuments(
|
|
10938
|
+
this.api,
|
|
10939
|
+
projectId,
|
|
10940
|
+
opts?.language ?? this.api.language,
|
|
10941
|
+
opts?.rdfBase,
|
|
10942
|
+
queryCache,
|
|
10943
|
+
opts?.graphType
|
|
10944
|
+
);
|
|
10945
|
+
}
|
|
10654
10946
|
};
|
|
10655
10947
|
|
|
10656
10948
|
// libs/js/cue-sdk/src/lib/cue-node.ts
|
|
10657
|
-
var
|
|
10949
|
+
var import_storage8 = require("firebase/storage");
|
|
10658
10950
|
var CueNode = class extends Cue {
|
|
10659
10951
|
constructor(config) {
|
|
10660
10952
|
super(config);
|
|
10661
10953
|
}
|
|
10662
10954
|
_buildApi(projects) {
|
|
10663
|
-
const storageChatSessions = (0,
|
|
10664
|
-
const storageLogs = (0,
|
|
10665
|
-
const storageRaw =
|
|
10666
|
-
const storagePersistence = (0,
|
|
10667
|
-
const storageProcessed =
|
|
10668
|
-
const storagePublic = (0,
|
|
10955
|
+
const storageChatSessions = (0, import_storage8.getStorage)(this._app, BUCKET_CHAT_SESSIONS2);
|
|
10956
|
+
const storageLogs = (0, import_storage8.getStorage)(this._app, BUCKET_LOGS2);
|
|
10957
|
+
const storageRaw = this._storageRaw;
|
|
10958
|
+
const storagePersistence = (0, import_storage8.getStorage)(this._app, BUCKET_PERSISTENCE2);
|
|
10959
|
+
const storageProcessed = this._storageProcessed;
|
|
10960
|
+
const storagePublic = (0, import_storage8.getStorage)(this._app, BUCKET_PUBLIC2);
|
|
10669
10961
|
if (this._isEmulator) {
|
|
10670
10962
|
const storageHost = this._endpoints.storageEmulatorHost;
|
|
10671
10963
|
const storagePort = this._endpoints.storageEmulatorPort;
|
|
10672
|
-
(0,
|
|
10673
|
-
(0, import_storage6.connectStorageEmulator)(storageProcessed, storageHost, storagePort);
|
|
10674
|
-
(0, import_storage6.connectStorageEmulator)(storagePublic, storageHost, storagePort);
|
|
10964
|
+
(0, import_storage8.connectStorageEmulator)(storagePublic, storageHost, storagePort);
|
|
10675
10965
|
}
|
|
10676
10966
|
const blob = new CueBlobStorage({
|
|
10677
10967
|
storageChatSessions,
|
|
@@ -10834,21 +11124,21 @@ async function compareHandler(options) {
|
|
|
10834
11124
|
}
|
|
10835
11125
|
|
|
10836
11126
|
// apps/desktop/cue-cli/src/helpers/get-files-containing-substring.ts
|
|
10837
|
-
var
|
|
11127
|
+
var import_storage9 = require("firebase/storage");
|
|
10838
11128
|
var import_path2 = require("path");
|
|
10839
11129
|
var import_promises = require("fs/promises");
|
|
10840
11130
|
async function getFilesContainingSubstring(bucket, subDir = "", subString = "") {
|
|
10841
11131
|
const firebase = CueFirebase.getInstance();
|
|
10842
11132
|
const storage = bucket === "raw" ? firebase.storageRaw : firebase.storageProcessed;
|
|
10843
11133
|
console.log("Fetching files from storage bucket:", bucket, "in subdir:", subDir, "containing substring:", subString);
|
|
10844
|
-
const listResult = await (0,
|
|
11134
|
+
const listResult = await (0, import_storage9.listAll)((0, import_storage9.ref)(storage, subDir));
|
|
10845
11135
|
const outputDir = (0, import_path2.join)(process.cwd(), "downloaded_blobs", bucket, subDir);
|
|
10846
11136
|
await (0, import_promises.mkdir)(outputDir, { recursive: true });
|
|
10847
11137
|
for (const fileRef of listResult.items) {
|
|
10848
11138
|
console.log(fileRef.name);
|
|
10849
11139
|
if (subDir && !fileRef.name.includes(subString))
|
|
10850
11140
|
continue;
|
|
10851
|
-
const bytes = await (0,
|
|
11141
|
+
const bytes = await (0, import_storage9.getBytes)(fileRef);
|
|
10852
11142
|
const outputPath = (0, import_path2.join)(outputDir, fileRef.name);
|
|
10853
11143
|
await (0, import_promises.writeFile)(outputPath, Buffer.from(bytes));
|
|
10854
11144
|
console.log(`Downloaded ${fileRef.name} to ${outputPath} \u2705`);
|
|
@@ -11242,16 +11532,16 @@ async function dumpHandler(options) {
|
|
|
11242
11532
|
}
|
|
11243
11533
|
|
|
11244
11534
|
// apps/desktop/cue-cli/src/helpers/repair-remote-ttl.ts
|
|
11245
|
-
var
|
|
11535
|
+
var import_storage10 = require("firebase/storage");
|
|
11246
11536
|
async function repairRemoteTTL(space, subString, regex, substituteString) {
|
|
11247
11537
|
const firebase = CueFirebase.getInstance();
|
|
11248
11538
|
const storage = firebase.storageProcessed;
|
|
11249
11539
|
console.log("Fetching files from storage bucket 'triples' containing substring:", subString);
|
|
11250
|
-
const listResult = await (0,
|
|
11540
|
+
const listResult = await (0, import_storage10.listAll)((0, import_storage10.ref)(storage, `${space}/triples`));
|
|
11251
11541
|
for (const fileRef of listResult.items) {
|
|
11252
11542
|
if (subString && !fileRef.name.match(subString))
|
|
11253
11543
|
continue;
|
|
11254
|
-
const stream = await (0,
|
|
11544
|
+
const stream = await (0, import_storage10.getStream)(fileRef);
|
|
11255
11545
|
const reader = stream.getReader();
|
|
11256
11546
|
const chunks = [];
|
|
11257
11547
|
let done = false;
|
|
@@ -11275,13 +11565,13 @@ async function repairRemoteTTL(space, subString, regex, substituteString) {
|
|
|
11275
11565
|
const buffer = Buffer.from(fileContent, "utf8");
|
|
11276
11566
|
let existingMetadata = {};
|
|
11277
11567
|
try {
|
|
11278
|
-
existingMetadata = await (0,
|
|
11568
|
+
existingMetadata = await (0, import_storage10.getMetadata)(fileRef);
|
|
11279
11569
|
} catch (err) {
|
|
11280
11570
|
console.warn(`Could not fetch metadata for ${fileRef.name}, proceeding with default.`);
|
|
11281
11571
|
}
|
|
11282
11572
|
const customMetadata = { ...existingMetadata.customMetadata || {}, stored: "False" };
|
|
11283
11573
|
const metadata = { customMetadata };
|
|
11284
|
-
await (0,
|
|
11574
|
+
await (0, import_storage10.uploadBytesResumable)((0, import_storage10.ref)(storage, `${space}/triples/${fileRef.name}`), buffer, metadata);
|
|
11285
11575
|
console.log(`Fixed ${fileRef.name} \u2705`);
|
|
11286
11576
|
} else {
|
|
11287
11577
|
console.log(`No changes for ${fileRef.name}`);
|
|
@@ -12036,6 +12326,7 @@ async function listProjectsHandler(options) {
|
|
|
12036
12326
|
lastSync: p.lastSync
|
|
12037
12327
|
}));
|
|
12038
12328
|
console.log(JSON.stringify(output, null, 2));
|
|
12329
|
+
process.exit(0);
|
|
12039
12330
|
} catch (err) {
|
|
12040
12331
|
console.error("Error:", err instanceof Error ? err.message : String(err));
|
|
12041
12332
|
process.exit(1);
|
|
@@ -12057,6 +12348,7 @@ async function entitySummaryGraphHandler(options) {
|
|
|
12057
12348
|
const raw = await entities.buildSummaryGraph();
|
|
12058
12349
|
console.log(JSON.stringify(raw, null, 2));
|
|
12059
12350
|
}
|
|
12351
|
+
process.exit(0);
|
|
12060
12352
|
} catch (err) {
|
|
12061
12353
|
console.error("Error:", err instanceof Error ? err.message : String(err));
|
|
12062
12354
|
process.exit(1);
|
|
@@ -12084,6 +12376,7 @@ async function sparqlHandler(options) {
|
|
|
12084
12376
|
console.error(`Executing SPARQL query against project ${options.space}...`);
|
|
12085
12377
|
const result = await cue.api.sparql(sparqlQuery, options.space);
|
|
12086
12378
|
console.log(JSON.stringify(result, null, 2));
|
|
12379
|
+
process.exit(0);
|
|
12087
12380
|
} catch (err) {
|
|
12088
12381
|
console.error("Error:", err instanceof Error ? err.message : String(err));
|
|
12089
12382
|
process.exit(1);
|