latticesql 4.2.0 → 4.2.2
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/dist/cli.js +292 -181
- package/dist/index.cjs +582 -470
- package/dist/index.js +306 -195
- package/docs/configuration.md +27 -0
- package/docs/workspaces.md +10 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -231,10 +231,10 @@ function manifestPath(outputDir) {
|
|
|
231
231
|
return (0, import_node_path2.join)(outputDir, ".lattice", "manifest.json");
|
|
232
232
|
}
|
|
233
233
|
function readManifest(outputDir) {
|
|
234
|
-
const
|
|
235
|
-
if (!(0, import_node_fs2.existsSync)(
|
|
234
|
+
const path3 = manifestPath(outputDir);
|
|
235
|
+
if (!(0, import_node_fs2.existsSync)(path3)) return null;
|
|
236
236
|
try {
|
|
237
|
-
return JSON.parse((0, import_node_fs2.readFileSync)(
|
|
237
|
+
return JSON.parse((0, import_node_fs2.readFileSync)(path3, "utf8"));
|
|
238
238
|
} catch {
|
|
239
239
|
return null;
|
|
240
240
|
}
|
|
@@ -249,7 +249,7 @@ var init_manifest = __esm({
|
|
|
249
249
|
import_node_path2 = require("path");
|
|
250
250
|
import_node_fs2 = require("fs");
|
|
251
251
|
init_writer();
|
|
252
|
-
TEMPLATE_VERSION =
|
|
252
|
+
TEMPLATE_VERSION = 2;
|
|
253
253
|
}
|
|
254
254
|
});
|
|
255
255
|
|
|
@@ -424,20 +424,131 @@ var init_render_cursor = __esm({
|
|
|
424
424
|
}
|
|
425
425
|
});
|
|
426
426
|
|
|
427
|
+
// src/db/load-sqlite.ts
|
|
428
|
+
function runtimeRequire() {
|
|
429
|
+
const importMetaUrl = import_meta.url;
|
|
430
|
+
return importMetaUrl ? (0, import_node_module.createRequire)(importMetaUrl) : (
|
|
431
|
+
// CJS fallback — Node provides `require` on every CJS module scope. Under
|
|
432
|
+
// tsup's CJS output `import.meta.url` is rewritten to undefined, so this
|
|
433
|
+
// branch keeps the loader working in the published .cjs bundle.
|
|
434
|
+
require
|
|
435
|
+
);
|
|
436
|
+
}
|
|
437
|
+
function asCtor(mod) {
|
|
438
|
+
return mod.default ?? mod;
|
|
439
|
+
}
|
|
440
|
+
function isAbiMismatch(err) {
|
|
441
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
442
|
+
const code = err.code;
|
|
443
|
+
return message.includes("NODE_MODULE_VERSION") || code === "ERR_DLOPEN_FAILED" || message.includes("was compiled against a different Node.js version");
|
|
444
|
+
}
|
|
445
|
+
function autoRebuildDisabled() {
|
|
446
|
+
const v2 = process.env.LATTICE_SQLITE_NO_AUTOREBUILD;
|
|
447
|
+
if (!v2) return false;
|
|
448
|
+
const normalized = v2.trim().toLowerCase();
|
|
449
|
+
return normalized !== "" && normalized !== "0" && normalized !== "false" && normalized !== "no";
|
|
450
|
+
}
|
|
451
|
+
function installRootFor(req) {
|
|
452
|
+
const pkgJsonPath = req.resolve("better-sqlite3/package.json");
|
|
453
|
+
return import_node_path3.default.resolve(import_node_path3.default.dirname(pkgJsonPath), "..", "..");
|
|
454
|
+
}
|
|
455
|
+
function defaultRebuild(installRoot) {
|
|
456
|
+
const npmBin = process.platform === "win32" ? "npm.cmd" : "npm";
|
|
457
|
+
const res = (0, import_node_child_process.spawnSync)(npmBin, ["rebuild", "better-sqlite3"], {
|
|
458
|
+
cwd: installRoot,
|
|
459
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
460
|
+
encoding: "utf8",
|
|
461
|
+
timeout: 5 * 60 * 1e3
|
|
462
|
+
});
|
|
463
|
+
if (res.error) {
|
|
464
|
+
return { ok: false, reason: res.error.message };
|
|
465
|
+
}
|
|
466
|
+
if (res.status !== 0) {
|
|
467
|
+
const stderr = res.stderr.trim();
|
|
468
|
+
const tail = stderr ? stderr.slice(-300) : `npm rebuild exited with code ${String(res.status)}`;
|
|
469
|
+
return { ok: false, reason: tail };
|
|
470
|
+
}
|
|
471
|
+
return { ok: true };
|
|
472
|
+
}
|
|
473
|
+
function resolveSqliteCtor(options = {}) {
|
|
474
|
+
const req = options.require ?? runtimeRequire();
|
|
475
|
+
const rebuild = options.rebuild ?? defaultRebuild;
|
|
476
|
+
const resolveInstallRoot = options.installRoot ?? installRootFor;
|
|
477
|
+
const log = options.log ?? ((msg) => process.stderr.write(msg + "\n"));
|
|
478
|
+
let firstError;
|
|
479
|
+
try {
|
|
480
|
+
return asCtor(req("better-sqlite3"));
|
|
481
|
+
} catch (err) {
|
|
482
|
+
firstError = err;
|
|
483
|
+
}
|
|
484
|
+
if (!isAbiMismatch(firstError)) {
|
|
485
|
+
throw new Error(PEER_DEP_MISSING_MESSAGE);
|
|
486
|
+
}
|
|
487
|
+
if (autoRebuildDisabled()) {
|
|
488
|
+
throw new Error(
|
|
489
|
+
rebuildFailedMessage("automatic rebuild is disabled (LATTICE_SQLITE_NO_AUTOREBUILD)")
|
|
490
|
+
);
|
|
491
|
+
}
|
|
492
|
+
log("[latticesql] SQLite engine built for a different Node runtime \u2014 rebuilding better-sqlite3\u2026");
|
|
493
|
+
let installRoot;
|
|
494
|
+
try {
|
|
495
|
+
installRoot = resolveInstallRoot(req);
|
|
496
|
+
} catch (err) {
|
|
497
|
+
throw new Error(
|
|
498
|
+
rebuildFailedMessage(
|
|
499
|
+
"could not locate the better-sqlite3 install root (" + (err instanceof Error ? err.message : String(err)) + ")"
|
|
500
|
+
)
|
|
501
|
+
);
|
|
502
|
+
}
|
|
503
|
+
const outcome = rebuild(installRoot);
|
|
504
|
+
if (!outcome.ok) {
|
|
505
|
+
throw new Error(rebuildFailedMessage(outcome.reason));
|
|
506
|
+
}
|
|
507
|
+
try {
|
|
508
|
+
return asCtor(req("better-sqlite3"));
|
|
509
|
+
} catch (err) {
|
|
510
|
+
throw new Error(
|
|
511
|
+
rebuildFailedMessage(
|
|
512
|
+
"the rebuilt module still failed to load (" + (err instanceof Error ? err.message : String(err)) + ")"
|
|
513
|
+
)
|
|
514
|
+
);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
function rebuildFailedMessage(reason) {
|
|
518
|
+
return "latticesql: the better-sqlite3 native module doesn\u2019t match this Node runtime and an automatic rebuild did not complete (" + reason + "). Run `npm rebuild better-sqlite3` (or reinstall) and retry.";
|
|
519
|
+
}
|
|
520
|
+
function loadSqlite() {
|
|
521
|
+
if (_ctor) return _ctor;
|
|
522
|
+
_ctor = resolveSqliteCtor();
|
|
523
|
+
return _ctor;
|
|
524
|
+
}
|
|
525
|
+
var import_node_path3, import_node_module, import_node_child_process, import_meta, PEER_DEP_MISSING_MESSAGE, _ctor;
|
|
526
|
+
var init_load_sqlite = __esm({
|
|
527
|
+
"src/db/load-sqlite.ts"() {
|
|
528
|
+
"use strict";
|
|
529
|
+
import_node_path3 = __toESM(require("path"), 1);
|
|
530
|
+
import_node_module = require("module");
|
|
531
|
+
import_node_child_process = require("child_process");
|
|
532
|
+
import_meta = {};
|
|
533
|
+
PEER_DEP_MISSING_MESSAGE = "better-sqlite3 is a required peer dependency of latticesql \u2014 install it (npm install better-sqlite3).";
|
|
534
|
+
_ctor = null;
|
|
535
|
+
}
|
|
536
|
+
});
|
|
537
|
+
|
|
427
538
|
// src/db/sqlite.ts
|
|
428
|
-
var
|
|
539
|
+
var SQLiteAdapter;
|
|
429
540
|
var init_sqlite = __esm({
|
|
430
541
|
"src/db/sqlite.ts"() {
|
|
431
542
|
"use strict";
|
|
432
|
-
|
|
543
|
+
init_load_sqlite();
|
|
433
544
|
SQLiteAdapter = class {
|
|
434
545
|
dialect = "sqlite";
|
|
435
546
|
_db = null;
|
|
436
547
|
_path;
|
|
437
548
|
_wal;
|
|
438
549
|
_busyTimeout;
|
|
439
|
-
constructor(
|
|
440
|
-
this._path =
|
|
550
|
+
constructor(path3, options) {
|
|
551
|
+
this._path = path3;
|
|
441
552
|
this._wal = options?.wal ?? true;
|
|
442
553
|
this._busyTimeout = options?.busyTimeout ?? 5e3;
|
|
443
554
|
}
|
|
@@ -446,7 +557,8 @@ var init_sqlite = __esm({
|
|
|
446
557
|
return this._db;
|
|
447
558
|
}
|
|
448
559
|
open() {
|
|
449
|
-
|
|
560
|
+
const Ctor = loadSqlite();
|
|
561
|
+
this._db = new Ctor(this._path);
|
|
450
562
|
this._db.pragma(`busy_timeout = ${this._busyTimeout.toString()}`);
|
|
451
563
|
if (this._wal) {
|
|
452
564
|
this._db.pragma("journal_mode = WAL");
|
|
@@ -620,11 +732,11 @@ var init_sqlite = __esm({
|
|
|
620
732
|
// src/db/postgres.ts
|
|
621
733
|
function moduleContext() {
|
|
622
734
|
if (_moduleContext) return _moduleContext;
|
|
623
|
-
const importMetaUrl =
|
|
735
|
+
const importMetaUrl = import_meta2.url;
|
|
624
736
|
if (importMetaUrl) {
|
|
625
737
|
_moduleContext = {
|
|
626
|
-
dir:
|
|
627
|
-
require: (0,
|
|
738
|
+
dir: import_node_path4.default.dirname((0, import_node_url.fileURLToPath)(importMetaUrl)),
|
|
739
|
+
require: (0, import_node_module2.createRequire)(importMetaUrl)
|
|
628
740
|
};
|
|
629
741
|
} else {
|
|
630
742
|
_moduleContext = { dir: __dirname, require };
|
|
@@ -882,14 +994,14 @@ function rewriteParams(sql) {
|
|
|
882
994
|
function rewrite(sql) {
|
|
883
995
|
return rewriteParams(translateDialect(sql));
|
|
884
996
|
}
|
|
885
|
-
var
|
|
997
|
+
var import_node_path4, import_node_url, import_node_module2, import_meta2, _moduleContext, SYNC_NOT_SUPPORTED_MSG, PostgresAdapter, POSTGRES_POLYFILLS;
|
|
886
998
|
var init_postgres = __esm({
|
|
887
999
|
"src/db/postgres.ts"() {
|
|
888
1000
|
"use strict";
|
|
889
|
-
|
|
1001
|
+
import_node_path4 = __toESM(require("path"), 1);
|
|
890
1002
|
import_node_url = require("url");
|
|
891
|
-
|
|
892
|
-
|
|
1003
|
+
import_node_module2 = require("module");
|
|
1004
|
+
import_meta2 = {};
|
|
893
1005
|
_moduleContext = null;
|
|
894
1006
|
SYNC_NOT_SUPPORTED_MSG = "PostgresAdapter: synchronous adapter methods (run/get/all/prepare/introspectColumns/addColumn) are no longer supported on Postgres as of latticesql 1.10.0. Use the async surface (runAsync/getAsync/allAsync/prepareAsync/introspectColumnsAsync/addColumnAsync/withClient) instead. Lattice core methods (Lattice.query, .insert, .update, .render, etc.) already route through the async surface \u2014 only consumer code that escapes into adapter.run/get/all directly needs migrating.";
|
|
895
1007
|
PostgresAdapter = class {
|
|
@@ -2557,14 +2669,14 @@ var init_core = __esm({
|
|
|
2557
2669
|
columnRef(f6) {
|
|
2558
2670
|
const col = `"${ident(f6.col)}"`;
|
|
2559
2671
|
if (f6.jsonPath === void 0) return { sql: col, params: [] };
|
|
2560
|
-
const
|
|
2672
|
+
const path3 = Array.isArray(f6.jsonPath) ? f6.jsonPath : [f6.jsonPath];
|
|
2561
2673
|
const numeric = isNumericComparison(f6);
|
|
2562
2674
|
if (this.adapter.dialect === "postgres") {
|
|
2563
2675
|
const extract2 = `((${col})::jsonb #>> ?::text[])`;
|
|
2564
2676
|
const sql2 = numeric ? `(${extract2})::numeric` : extract2;
|
|
2565
|
-
return { sql: sql2, params: [
|
|
2677
|
+
return { sql: sql2, params: [path3] };
|
|
2566
2678
|
}
|
|
2567
|
-
const jsonpath = `$.${
|
|
2679
|
+
const jsonpath = `$.${path3.join(".")}`;
|
|
2568
2680
|
const extract = `json_extract(${col}, ?)`;
|
|
2569
2681
|
const sql = numeric ? `CAST(${extract} AS REAL)` : extract;
|
|
2570
2682
|
return { sql, params: [jsonpath] };
|
|
@@ -3343,14 +3455,14 @@ function cleanupEntityContexts(outputDir, entityContexts, currentSlugsByTable, m
|
|
|
3343
3455
|
...def.protectedFiles ?? [],
|
|
3344
3456
|
...options.protectedFiles ?? []
|
|
3345
3457
|
]);
|
|
3346
|
-
const rootPath = (0,
|
|
3458
|
+
const rootPath = (0, import_node_path5.join)(outputDir, directoryRoot);
|
|
3347
3459
|
if (!(0, import_node_fs3.existsSync)(rootPath)) continue;
|
|
3348
3460
|
if (options.removeOrphanedDirectories !== false && !def.directory) {
|
|
3349
3461
|
let actualDirs;
|
|
3350
3462
|
try {
|
|
3351
3463
|
actualDirs = (0, import_node_fs3.readdirSync)(rootPath).filter((name) => {
|
|
3352
3464
|
try {
|
|
3353
|
-
return (0, import_node_fs3.statSync)((0,
|
|
3465
|
+
return (0, import_node_fs3.statSync)((0, import_node_path5.join)(rootPath, name)).isDirectory();
|
|
3354
3466
|
} catch {
|
|
3355
3467
|
return false;
|
|
3356
3468
|
}
|
|
@@ -3361,11 +3473,11 @@ function cleanupEntityContexts(outputDir, entityContexts, currentSlugsByTable, m
|
|
|
3361
3473
|
for (const dirName of actualDirs) {
|
|
3362
3474
|
if (currentSlugs.has(dirName)) continue;
|
|
3363
3475
|
if (!Object.prototype.hasOwnProperty.call(entry.entities, dirName)) continue;
|
|
3364
|
-
const entityDir = (0,
|
|
3476
|
+
const entityDir = (0, import_node_path5.join)(rootPath, dirName);
|
|
3365
3477
|
const managedFiles = entityFileNames(entry.entities[dirName] ?? []);
|
|
3366
3478
|
for (const filename of managedFiles) {
|
|
3367
3479
|
if (globalProtected.has(filename)) continue;
|
|
3368
|
-
const filePath = (0,
|
|
3480
|
+
const filePath = (0, import_node_path5.join)(entityDir, filename);
|
|
3369
3481
|
if (!(0, import_node_fs3.existsSync)(filePath)) continue;
|
|
3370
3482
|
if (!options.dryRun) (0, import_node_fs3.unlinkSync)(filePath);
|
|
3371
3483
|
options.onOrphan?.(filePath, "file");
|
|
@@ -3399,7 +3511,7 @@ function cleanupEntityContexts(outputDir, entityContexts, currentSlugsByTable, m
|
|
|
3399
3511
|
const declaredFiles = new Set(Object.keys(def.files));
|
|
3400
3512
|
if (def.combined) declaredFiles.add(def.combined.outputFile);
|
|
3401
3513
|
for (const slug of currentSlugs) {
|
|
3402
|
-
const entityDir = def.directory ? null : (0,
|
|
3514
|
+
const entityDir = def.directory ? null : (0, import_node_path5.join)(rootPath, slug);
|
|
3403
3515
|
if (!entityDir || !(0, import_node_fs3.existsSync)(entityDir)) continue;
|
|
3404
3516
|
const previouslyWritten = entityFileNames(entry.entities[slug] ?? []);
|
|
3405
3517
|
const currentlyWritten = new Set(entityFileNames(newEntry?.entities[slug] ?? []));
|
|
@@ -3410,7 +3522,7 @@ function cleanupEntityContexts(outputDir, entityContexts, currentSlugsByTable, m
|
|
|
3410
3522
|
if (declaredFiles.has(filename)) continue;
|
|
3411
3523
|
}
|
|
3412
3524
|
if (globalProtected.has(filename)) continue;
|
|
3413
|
-
const filePath = (0,
|
|
3525
|
+
const filePath = (0, import_node_path5.join)(entityDir, filename);
|
|
3414
3526
|
if (!(0, import_node_fs3.existsSync)(filePath)) continue;
|
|
3415
3527
|
if (!options.dryRun) (0, import_node_fs3.unlinkSync)(filePath);
|
|
3416
3528
|
options.onOrphan?.(filePath, "file");
|
|
@@ -3421,11 +3533,11 @@ function cleanupEntityContexts(outputDir, entityContexts, currentSlugsByTable, m
|
|
|
3421
3533
|
}
|
|
3422
3534
|
return result;
|
|
3423
3535
|
}
|
|
3424
|
-
var
|
|
3536
|
+
var import_node_path5, import_node_fs3;
|
|
3425
3537
|
var init_cleanup = __esm({
|
|
3426
3538
|
"src/lifecycle/cleanup.ts"() {
|
|
3427
3539
|
"use strict";
|
|
3428
|
-
|
|
3540
|
+
import_node_path5 = require("path");
|
|
3429
3541
|
import_node_fs3 = require("fs");
|
|
3430
3542
|
init_manifest();
|
|
3431
3543
|
}
|
|
@@ -3517,11 +3629,11 @@ function isScalarKey(v2) {
|
|
|
3517
3629
|
const t8 = typeof v2;
|
|
3518
3630
|
return t8 === "string" || t8 === "number" || t8 === "bigint" || t8 === "boolean";
|
|
3519
3631
|
}
|
|
3520
|
-
var
|
|
3632
|
+
var import_node_path6, import_node_fs4, DeferredTableProgress, YIELD_EVERY_ENTITIES, RENDER_TABLE_CONCURRENCY, NOOP_RENDER, RenderEngine;
|
|
3521
3633
|
var init_engine = __esm({
|
|
3522
3634
|
"src/render/engine.ts"() {
|
|
3523
3635
|
"use strict";
|
|
3524
|
-
|
|
3636
|
+
import_node_path6 = require("path");
|
|
3525
3637
|
import_node_fs4 = require("fs");
|
|
3526
3638
|
init_adapter();
|
|
3527
3639
|
init_writer();
|
|
@@ -3689,7 +3801,7 @@ var init_engine = __esm({
|
|
|
3689
3801
|
for (const fn of def.enrich) rows = fn(rows);
|
|
3690
3802
|
}
|
|
3691
3803
|
const content = def.tokenBudget ? applyTokenBudget(rows, def.render, def.tokenBudget, def.prioritizeBy) : def.render(rows);
|
|
3692
|
-
const filePath = (0,
|
|
3804
|
+
const filePath = (0, import_node_path6.join)(outputDir, def.outputFile);
|
|
3693
3805
|
const wrote = atomicWrite(filePath, content);
|
|
3694
3806
|
if (wrote) {
|
|
3695
3807
|
filesWritten.push(filePath);
|
|
@@ -3723,7 +3835,7 @@ var init_engine = __esm({
|
|
|
3723
3835
|
let wroteAny = false;
|
|
3724
3836
|
for (const key of keys) {
|
|
3725
3837
|
const content = def.render(key, tables);
|
|
3726
|
-
const filePath = (0,
|
|
3838
|
+
const filePath = (0, import_node_path6.join)(outputDir, def.outputFile(key));
|
|
3727
3839
|
if (atomicWrite(filePath, content)) {
|
|
3728
3840
|
filesWritten.push(filePath);
|
|
3729
3841
|
wroteAny = true;
|
|
@@ -3801,9 +3913,9 @@ var init_engine = __esm({
|
|
|
3801
3913
|
* not pre-empted.
|
|
3802
3914
|
*/
|
|
3803
3915
|
_preflightWritable(outputDir) {
|
|
3804
|
-
const dirs = /* @__PURE__ */ new Set([outputDir, (0,
|
|
3916
|
+
const dirs = /* @__PURE__ */ new Set([outputDir, (0, import_node_path6.join)(outputDir, ".lattice")]);
|
|
3805
3917
|
for (const [table, def] of this._schema.getEntityContexts()) {
|
|
3806
|
-
dirs.add((0,
|
|
3918
|
+
dirs.add((0, import_node_path6.join)(outputDir, def.directoryRoot ?? table));
|
|
3807
3919
|
}
|
|
3808
3920
|
for (const dir of dirs) probeDirWritable(dir);
|
|
3809
3921
|
}
|
|
@@ -3990,7 +4102,7 @@ var init_engine = __esm({
|
|
|
3990
4102
|
entities: {}
|
|
3991
4103
|
};
|
|
3992
4104
|
if (def.index) {
|
|
3993
|
-
const indexPath = (0,
|
|
4105
|
+
const indexPath = (0, import_node_path6.join)(outputDir, def.index.outputFile);
|
|
3994
4106
|
if (atomicWrite(indexPath, def.index.render(allRows))) {
|
|
3995
4107
|
filesWritten.push(indexPath);
|
|
3996
4108
|
} else {
|
|
@@ -4008,10 +4120,10 @@ var init_engine = __esm({
|
|
|
4008
4120
|
if (/[^a-zA-Z0-9.\-_ @(),#&'+:;!~[\]]/.test(slug)) {
|
|
4009
4121
|
throw new Error(`Invalid slug "${slug}": contains characters outside the allowed set`);
|
|
4010
4122
|
}
|
|
4011
|
-
const entityDir = def.directory ? (0,
|
|
4012
|
-
const resolvedDir = (0,
|
|
4013
|
-
const resolvedBase = (0,
|
|
4014
|
-
if (!resolvedDir.startsWith(resolvedBase +
|
|
4123
|
+
const entityDir = def.directory ? (0, import_node_path6.join)(outputDir, def.directory(entityRow)) : (0, import_node_path6.join)(outputDir, directoryRoot, slug);
|
|
4124
|
+
const resolvedDir = (0, import_node_path6.resolve)(entityDir);
|
|
4125
|
+
const resolvedBase = (0, import_node_path6.resolve)(outputDir);
|
|
4126
|
+
if (!resolvedDir.startsWith(resolvedBase + import_node_path6.sep) && resolvedDir !== resolvedBase) {
|
|
4015
4127
|
throw new Error(`Path traversal detected: slug "${slug}" escapes output directory`);
|
|
4016
4128
|
}
|
|
4017
4129
|
(0, import_node_fs4.mkdirSync)(entityDir, { recursive: true });
|
|
@@ -4019,7 +4131,7 @@ var init_engine = __esm({
|
|
|
4019
4131
|
const filePath = entityRow[def.attachFileColumn];
|
|
4020
4132
|
if (filePath && typeof filePath === "string" && filePath.length > 0) {
|
|
4021
4133
|
if (def.attachFileMode === "reference") {
|
|
4022
|
-
const refPath = (0,
|
|
4134
|
+
const refPath = (0, import_node_path6.join)(entityDir, `${(0, import_node_path6.basename)(filePath)}.ref.md`);
|
|
4023
4135
|
if (atomicWrite(refPath, `# Reference
|
|
4024
4136
|
|
|
4025
4137
|
- **location:** ${filePath}
|
|
@@ -4027,9 +4139,9 @@ var init_engine = __esm({
|
|
|
4027
4139
|
filesWritten.push(refPath);
|
|
4028
4140
|
}
|
|
4029
4141
|
} else {
|
|
4030
|
-
const absPath = (0,
|
|
4142
|
+
const absPath = (0, import_node_path6.isAbsolute)(filePath) ? filePath : (0, import_node_path6.resolve)(outputDir, filePath);
|
|
4031
4143
|
if ((0, import_node_fs4.existsSync)(absPath)) {
|
|
4032
|
-
const destPath = (0,
|
|
4144
|
+
const destPath = (0, import_node_path6.join)(entityDir, (0, import_node_path6.basename)(absPath));
|
|
4033
4145
|
if (!(0, import_node_fs4.existsSync)(destPath)) {
|
|
4034
4146
|
(0, import_node_fs4.copyFileSync)(absPath, destPath);
|
|
4035
4147
|
filesWritten.push(destPath);
|
|
@@ -4067,7 +4179,7 @@ var init_engine = __esm({
|
|
|
4067
4179
|
const content = truncateContent(renderFn(rows), spec.budget);
|
|
4068
4180
|
renderedFiles.set(filename, content);
|
|
4069
4181
|
entityFileHashes[filename] = { hash: contentHash(content), rowVersion };
|
|
4070
|
-
const filePath = (0,
|
|
4182
|
+
const filePath = (0, import_node_path6.join)(entityDir, filename);
|
|
4071
4183
|
if (atomicWrite(filePath, content)) {
|
|
4072
4184
|
filesWritten.push(filePath);
|
|
4073
4185
|
} else {
|
|
@@ -4089,7 +4201,7 @@ var init_engine = __esm({
|
|
|
4089
4201
|
}
|
|
4090
4202
|
if (parts.length > 0) {
|
|
4091
4203
|
const combinedContent = parts.join("\n\n---\n\n");
|
|
4092
|
-
const combinedPath = (0,
|
|
4204
|
+
const combinedPath = (0, import_node_path6.join)(entityDir, effectiveCombined.outputFile);
|
|
4093
4205
|
if (atomicWrite(combinedPath, combinedContent)) {
|
|
4094
4206
|
filesWritten.push(combinedPath);
|
|
4095
4207
|
} else {
|
|
@@ -4421,11 +4533,11 @@ function parseEntityProfileContent(content) {
|
|
|
4421
4533
|
}
|
|
4422
4534
|
return row;
|
|
4423
4535
|
}
|
|
4424
|
-
var
|
|
4536
|
+
var import_node_path7, import_node_fs5, ReverseSeedEngine;
|
|
4425
4537
|
var init_engine2 = __esm({
|
|
4426
4538
|
"src/reverse-seed/engine.ts"() {
|
|
4427
4539
|
"use strict";
|
|
4428
|
-
|
|
4540
|
+
import_node_path7 = require("path");
|
|
4429
4541
|
import_node_fs5 = require("fs");
|
|
4430
4542
|
init_adapter();
|
|
4431
4543
|
ReverseSeedEngine = class {
|
|
@@ -4455,7 +4567,7 @@ var init_engine2 = __esm({
|
|
|
4455
4567
|
const tableDef = this._schema.getTables().get(table);
|
|
4456
4568
|
if (tableDef?.reverseSeed === false) continue;
|
|
4457
4569
|
const directoryRoot = ecDef.directoryRoot ?? table;
|
|
4458
|
-
const rootPath = (0,
|
|
4570
|
+
const rootPath = (0, import_node_path7.join)(outputDir, directoryRoot);
|
|
4459
4571
|
if (!(0, import_node_fs5.existsSync)(rootPath)) continue;
|
|
4460
4572
|
let dbRows;
|
|
4461
4573
|
try {
|
|
@@ -4472,7 +4584,7 @@ var init_engine2 = __esm({
|
|
|
4472
4584
|
}
|
|
4473
4585
|
for (const entry of entries) {
|
|
4474
4586
|
if (entry.startsWith(".")) continue;
|
|
4475
|
-
const entityDir = (0,
|
|
4587
|
+
const entityDir = (0, import_node_path7.join)(rootPath, entry);
|
|
4476
4588
|
try {
|
|
4477
4589
|
if (!(0, import_node_fs5.statSync)(entityDir).isDirectory()) continue;
|
|
4478
4590
|
} catch {
|
|
@@ -4489,7 +4601,7 @@ var init_engine2 = __esm({
|
|
|
4489
4601
|
const countRow = await getAsyncOrSync(this._adapter, `SELECT COUNT(*) AS n FROM "${name}"`);
|
|
4490
4602
|
const count = Number(countRow?.n ?? 0);
|
|
4491
4603
|
if (count > 0) continue;
|
|
4492
|
-
const filePath = (0,
|
|
4604
|
+
const filePath = (0, import_node_path7.join)(outputDir, def.outputFile);
|
|
4493
4605
|
if (!(0, import_node_fs5.existsSync)(filePath)) continue;
|
|
4494
4606
|
try {
|
|
4495
4607
|
const content = (0, import_node_fs5.readFileSync)(filePath, "utf8");
|
|
@@ -4540,7 +4652,7 @@ var init_engine2 = __esm({
|
|
|
4540
4652
|
}
|
|
4541
4653
|
continue;
|
|
4542
4654
|
}
|
|
4543
|
-
const filePath = (0,
|
|
4655
|
+
const filePath = (0, import_node_path7.join)(outputDir, def.outputFile);
|
|
4544
4656
|
if (!(0, import_node_fs5.existsSync)(filePath)) continue;
|
|
4545
4657
|
let content;
|
|
4546
4658
|
try {
|
|
@@ -4572,7 +4684,7 @@ var init_engine2 = __esm({
|
|
|
4572
4684
|
}
|
|
4573
4685
|
if (!selfFilename && !entityParser) continue;
|
|
4574
4686
|
const directoryRoot = ecDef.directoryRoot ?? table;
|
|
4575
|
-
const rootPath = (0,
|
|
4687
|
+
const rootPath = (0, import_node_path7.join)(outputDir, directoryRoot);
|
|
4576
4688
|
if (!(0, import_node_fs5.existsSync)(rootPath)) continue;
|
|
4577
4689
|
let entries;
|
|
4578
4690
|
try {
|
|
@@ -4592,7 +4704,7 @@ var init_engine2 = __esm({
|
|
|
4592
4704
|
await withClient(async (tx) => {
|
|
4593
4705
|
for (const entry of entries) {
|
|
4594
4706
|
if (entry.startsWith(".")) continue;
|
|
4595
|
-
const entityDir = (0,
|
|
4707
|
+
const entityDir = (0, import_node_path7.join)(rootPath, entry);
|
|
4596
4708
|
try {
|
|
4597
4709
|
if (!(0, import_node_fs5.statSync)(entityDir).isDirectory()) continue;
|
|
4598
4710
|
} catch {
|
|
@@ -4601,7 +4713,7 @@ var init_engine2 = __esm({
|
|
|
4601
4713
|
if (dbSlugs.has(entry)) continue;
|
|
4602
4714
|
const targetFile = selfFilename ?? Object.keys(ecDef.files)[0];
|
|
4603
4715
|
if (!targetFile) continue;
|
|
4604
|
-
const filePath = (0,
|
|
4716
|
+
const filePath = (0, import_node_path7.join)(entityDir, targetFile);
|
|
4605
4717
|
if (!(0, import_node_fs5.existsSync)(filePath)) continue;
|
|
4606
4718
|
let content;
|
|
4607
4719
|
try {
|
|
@@ -4768,11 +4880,11 @@ var init_default_reverse_sync = __esm({
|
|
|
4768
4880
|
});
|
|
4769
4881
|
|
|
4770
4882
|
// src/reverse-sync/engine.ts
|
|
4771
|
-
var
|
|
4883
|
+
var import_node_path8, import_node_fs6, ReverseSyncEngine;
|
|
4772
4884
|
var init_engine3 = __esm({
|
|
4773
4885
|
"src/reverse-sync/engine.ts"() {
|
|
4774
4886
|
"use strict";
|
|
4775
|
-
|
|
4887
|
+
import_node_path8 = require("path");
|
|
4776
4888
|
import_node_fs6 = require("fs");
|
|
4777
4889
|
init_writer();
|
|
4778
4890
|
init_default_reverse_sync();
|
|
@@ -4826,14 +4938,14 @@ var init_engine3 = __esm({
|
|
|
4826
4938
|
for (const [slug, entityFilesRaw] of Object.entries(manifestEntry.entities)) {
|
|
4827
4939
|
const entityRow = slugToRow.get(slug);
|
|
4828
4940
|
if (!entityRow) continue;
|
|
4829
|
-
const entityDir = def.directory ? (0,
|
|
4941
|
+
const entityDir = def.directory ? (0, import_node_path8.join)(outputDir, def.directory(entityRow)) : (0, import_node_path8.join)(outputDir, directoryRoot, slug);
|
|
4830
4942
|
if (Array.isArray(entityFilesRaw)) continue;
|
|
4831
4943
|
const entityFiles = entityFilesRaw;
|
|
4832
4944
|
for (const [filename, reverseSyncFn] of fileFns) {
|
|
4833
4945
|
const fileInfo = entityFiles[filename];
|
|
4834
4946
|
if (!fileInfo) continue;
|
|
4835
4947
|
if (!fileInfo.hash) continue;
|
|
4836
|
-
const filePath = (0,
|
|
4948
|
+
const filePath = (0, import_node_path8.join)(entityDir, filename);
|
|
4837
4949
|
result.filesScanned++;
|
|
4838
4950
|
if (!(0, import_node_fs6.existsSync)(filePath)) continue;
|
|
4839
4951
|
let currentContent;
|
|
@@ -5088,13 +5200,13 @@ var init_state_store = __esm({
|
|
|
5088
5200
|
});
|
|
5089
5201
|
|
|
5090
5202
|
// src/writeback/pipeline.ts
|
|
5091
|
-
var import_node_fs7, import_node_string_decoder,
|
|
5203
|
+
var import_node_fs7, import_node_string_decoder, import_node_path9, WritebackPipeline;
|
|
5092
5204
|
var init_pipeline = __esm({
|
|
5093
5205
|
"src/writeback/pipeline.ts"() {
|
|
5094
5206
|
"use strict";
|
|
5095
5207
|
import_node_fs7 = require("fs");
|
|
5096
5208
|
import_node_string_decoder = require("string_decoder");
|
|
5097
|
-
|
|
5209
|
+
import_node_path9 = require("path");
|
|
5098
5210
|
init_state_store();
|
|
5099
5211
|
WritebackPipeline = class {
|
|
5100
5212
|
_definitions = [];
|
|
@@ -5179,12 +5291,12 @@ var init_pipeline = __esm({
|
|
|
5179
5291
|
if (!pattern.includes("*") && !pattern.includes("?")) {
|
|
5180
5292
|
return [pattern];
|
|
5181
5293
|
}
|
|
5182
|
-
const dir = (0,
|
|
5183
|
-
const filePattern = (0,
|
|
5294
|
+
const dir = (0, import_node_path9.dirname)(pattern);
|
|
5295
|
+
const filePattern = (0, import_node_path9.basename)(pattern);
|
|
5184
5296
|
if (!(0, import_node_fs7.existsSync)(dir)) return [];
|
|
5185
5297
|
const regexStr = filePattern.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*").replace(/\?/g, ".");
|
|
5186
5298
|
const regex = new RegExp(`^${regexStr}$`);
|
|
5187
|
-
return (0, import_node_fs7.readdirSync)(dir).filter((f6) => regex.test(f6)).map((f6) => (0,
|
|
5299
|
+
return (0, import_node_fs7.readdirSync)(dir).filter((f6) => regex.test(f6)).map((f6) => (0, import_node_path9.join)(dir, f6));
|
|
5188
5300
|
}
|
|
5189
5301
|
};
|
|
5190
5302
|
}
|
|
@@ -5192,8 +5304,8 @@ var init_pipeline = __esm({
|
|
|
5192
5304
|
|
|
5193
5305
|
// src/render/interpolate.ts
|
|
5194
5306
|
function interpolate(template, row) {
|
|
5195
|
-
return template.replace(/\{\{([^}]+)\}\}/g, (_,
|
|
5196
|
-
const parts =
|
|
5307
|
+
return template.replace(/\{\{([^}]+)\}\}/g, (_, path3) => {
|
|
5308
|
+
const parts = path3.trim().split(".");
|
|
5197
5309
|
let val = row;
|
|
5198
5310
|
for (const part of parts) {
|
|
5199
5311
|
if (val == null || typeof val !== "object") return "";
|
|
@@ -5318,7 +5430,7 @@ var init_templates = __esm({
|
|
|
5318
5430
|
|
|
5319
5431
|
// src/framework/lattice-root.ts
|
|
5320
5432
|
function isRoot(dir) {
|
|
5321
|
-
return (0, import_node_fs8.existsSync)((0,
|
|
5433
|
+
return (0, import_node_fs8.existsSync)((0, import_node_path10.join)(dir, CONFIG_SUBDIR));
|
|
5322
5434
|
}
|
|
5323
5435
|
function findLatticeRoot(startDir = process.cwd()) {
|
|
5324
5436
|
const override = process.env.LATTICE_ROOT;
|
|
@@ -5326,18 +5438,18 @@ function findLatticeRoot(startDir = process.cwd()) {
|
|
|
5326
5438
|
return override;
|
|
5327
5439
|
}
|
|
5328
5440
|
let dir = startDir;
|
|
5329
|
-
const { root: fsRoot } = (0,
|
|
5441
|
+
const { root: fsRoot } = (0, import_node_path10.parse)(dir);
|
|
5330
5442
|
for (; ; ) {
|
|
5331
|
-
const candidate = (0,
|
|
5443
|
+
const candidate = (0, import_node_path10.join)(dir, ROOT_DIRNAME);
|
|
5332
5444
|
if (isRoot(candidate)) return candidate;
|
|
5333
5445
|
if (dir === fsRoot) return null;
|
|
5334
|
-
const parent = (0,
|
|
5446
|
+
const parent = (0, import_node_path10.dirname)(dir);
|
|
5335
5447
|
if (parent === dir) return null;
|
|
5336
5448
|
dir = parent;
|
|
5337
5449
|
}
|
|
5338
5450
|
}
|
|
5339
5451
|
function resolveLatticeRoot(startDir = process.cwd()) {
|
|
5340
|
-
return findLatticeRoot(startDir) ?? (0,
|
|
5452
|
+
return findLatticeRoot(startDir) ?? (0, import_node_path10.join)(startDir, ROOT_DIRNAME);
|
|
5341
5453
|
}
|
|
5342
5454
|
function chmod0700(dir) {
|
|
5343
5455
|
if ((0, import_node_os2.platform)() === "win32") return;
|
|
@@ -5352,48 +5464,48 @@ function ensureLatticeRoot(startDir = process.cwd()) {
|
|
|
5352
5464
|
(0, import_node_fs8.mkdirSync)(root6, { recursive: true });
|
|
5353
5465
|
chmod0700(root6);
|
|
5354
5466
|
}
|
|
5355
|
-
const config = (0,
|
|
5467
|
+
const config = (0, import_node_path10.join)(root6, CONFIG_SUBDIR);
|
|
5356
5468
|
if (!(0, import_node_fs8.existsSync)(config)) {
|
|
5357
5469
|
(0, import_node_fs8.mkdirSync)(config, { recursive: true });
|
|
5358
5470
|
chmod0700(config);
|
|
5359
5471
|
}
|
|
5360
|
-
const workspaces = (0,
|
|
5472
|
+
const workspaces = (0, import_node_path10.join)(root6, WORKSPACES_SUBDIR);
|
|
5361
5473
|
if (!(0, import_node_fs8.existsSync)(workspaces)) {
|
|
5362
5474
|
(0, import_node_fs8.mkdirSync)(workspaces, { recursive: true });
|
|
5363
5475
|
}
|
|
5364
5476
|
return root6;
|
|
5365
5477
|
}
|
|
5366
5478
|
function rootConfigDir(root6) {
|
|
5367
|
-
return (0,
|
|
5479
|
+
return (0, import_node_path10.join)(root6, CONFIG_SUBDIR);
|
|
5368
5480
|
}
|
|
5369
5481
|
function workspacesDir(root6) {
|
|
5370
|
-
return (0,
|
|
5482
|
+
return (0, import_node_path10.join)(root6, WORKSPACES_SUBDIR);
|
|
5371
5483
|
}
|
|
5372
5484
|
function registryPath(root6) {
|
|
5373
|
-
return (0,
|
|
5485
|
+
return (0, import_node_path10.join)(rootConfigDir(root6), "registry.json");
|
|
5374
5486
|
}
|
|
5375
5487
|
function workspaceDir(root6, dir) {
|
|
5376
|
-
return (0,
|
|
5488
|
+
return (0, import_node_path10.join)(workspacesDir(root6), dir);
|
|
5377
5489
|
}
|
|
5378
5490
|
function workspaceDataDir(root6, dir) {
|
|
5379
|
-
return (0,
|
|
5491
|
+
return (0, import_node_path10.join)(workspaceDir(root6, dir), "Data");
|
|
5380
5492
|
}
|
|
5381
5493
|
function workspaceContextDir(root6, dir) {
|
|
5382
|
-
return (0,
|
|
5494
|
+
return (0, import_node_path10.join)(workspaceDir(root6, dir), "Context");
|
|
5383
5495
|
}
|
|
5384
5496
|
function workspaceBlobsDir(root6, dir) {
|
|
5385
|
-
return (0,
|
|
5497
|
+
return (0, import_node_path10.join)(workspaceDataDir(root6, dir), "blobs");
|
|
5386
5498
|
}
|
|
5387
5499
|
function workspaceConfigPath(root6, dir) {
|
|
5388
|
-
return (0,
|
|
5500
|
+
return (0, import_node_path10.join)(workspaceDir(root6, dir), "workspace.yml");
|
|
5389
5501
|
}
|
|
5390
|
-
var import_node_fs8, import_node_os2,
|
|
5502
|
+
var import_node_fs8, import_node_os2, import_node_path10, ROOT_DIRNAME, CONFIG_SUBDIR, WORKSPACES_SUBDIR;
|
|
5391
5503
|
var init_lattice_root = __esm({
|
|
5392
5504
|
"src/framework/lattice-root.ts"() {
|
|
5393
5505
|
"use strict";
|
|
5394
5506
|
import_node_fs8 = require("fs");
|
|
5395
5507
|
import_node_os2 = require("os");
|
|
5396
|
-
|
|
5508
|
+
import_node_path10 = require("path");
|
|
5397
5509
|
ROOT_DIRNAME = ".lattice";
|
|
5398
5510
|
CONFIG_SUBDIR = ".config";
|
|
5399
5511
|
WORKSPACES_SUBDIR = "Workspaces";
|
|
@@ -5403,12 +5515,12 @@ var init_lattice_root = __esm({
|
|
|
5403
5515
|
// src/framework/user-config.ts
|
|
5404
5516
|
function configDir() {
|
|
5405
5517
|
if (process.env.LATTICE_CONFIG_DIR) return process.env.LATTICE_CONFIG_DIR;
|
|
5406
|
-
const legacy = (0,
|
|
5518
|
+
const legacy = (0, import_node_path11.join)((0, import_node_os3.homedir)(), ".lattice");
|
|
5407
5519
|
const root6 = findLatticeRoot();
|
|
5408
5520
|
if (root6) {
|
|
5409
5521
|
const rootDir = rootConfigDir(root6);
|
|
5410
|
-
if ((0, import_node_fs9.existsSync)((0,
|
|
5411
|
-
if (!(0, import_node_fs9.existsSync)((0,
|
|
5522
|
+
if ((0, import_node_fs9.existsSync)((0, import_node_path11.join)(rootDir, MASTER_KEY_FILENAME))) return rootDir;
|
|
5523
|
+
if (!(0, import_node_fs9.existsSync)((0, import_node_path11.join)(legacy, MASTER_KEY_FILENAME))) return rootDir;
|
|
5412
5524
|
}
|
|
5413
5525
|
return legacy;
|
|
5414
5526
|
}
|
|
@@ -5429,7 +5541,7 @@ function getOrCreateMasterKey() {
|
|
|
5429
5541
|
const envKey = process.env.LATTICE_ENCRYPTION_KEY;
|
|
5430
5542
|
if (envKey && envKey.length > 0) return envKey;
|
|
5431
5543
|
const dir = ensureConfigDir();
|
|
5432
|
-
const keyPath = (0,
|
|
5544
|
+
const keyPath = (0, import_node_path11.join)(dir, MASTER_KEY_FILENAME);
|
|
5433
5545
|
if ((0, import_node_fs9.existsSync)(keyPath)) {
|
|
5434
5546
|
return (0, import_node_fs9.readFileSync)(keyPath, "utf8").trim();
|
|
5435
5547
|
}
|
|
@@ -5442,10 +5554,10 @@ function getOrCreateMasterKey() {
|
|
|
5442
5554
|
}
|
|
5443
5555
|
function readIdentity() {
|
|
5444
5556
|
const dir = ensureConfigDir();
|
|
5445
|
-
const
|
|
5446
|
-
if (!(0, import_node_fs9.existsSync)(
|
|
5557
|
+
const path3 = (0, import_node_path11.join)(dir, IDENTITY_FILENAME);
|
|
5558
|
+
if (!(0, import_node_fs9.existsSync)(path3)) return { ...EMPTY_IDENTITY };
|
|
5447
5559
|
try {
|
|
5448
|
-
const parsed = JSON.parse((0, import_node_fs9.readFileSync)(
|
|
5560
|
+
const parsed = JSON.parse((0, import_node_fs9.readFileSync)(path3, "utf8"));
|
|
5449
5561
|
return {
|
|
5450
5562
|
display_name: typeof parsed.display_name === "string" ? parsed.display_name : "",
|
|
5451
5563
|
email: typeof parsed.email === "string" ? parsed.email : ""
|
|
@@ -5456,26 +5568,26 @@ function readIdentity() {
|
|
|
5456
5568
|
}
|
|
5457
5569
|
function writeIdentity(identity) {
|
|
5458
5570
|
const dir = ensureConfigDir();
|
|
5459
|
-
const
|
|
5571
|
+
const path3 = (0, import_node_path11.join)(dir, IDENTITY_FILENAME);
|
|
5460
5572
|
const body = JSON.stringify(
|
|
5461
5573
|
{ display_name: identity.display_name, email: identity.email },
|
|
5462
5574
|
null,
|
|
5463
5575
|
2
|
|
5464
5576
|
);
|
|
5465
|
-
(0, import_node_fs9.writeFileSync)(
|
|
5577
|
+
(0, import_node_fs9.writeFileSync)(path3, body + "\n", "utf8");
|
|
5466
5578
|
if ((0, import_node_os3.platform)() !== "win32") {
|
|
5467
5579
|
try {
|
|
5468
|
-
(0, import_node_fs9.chmodSync)(
|
|
5580
|
+
(0, import_node_fs9.chmodSync)(path3, 384);
|
|
5469
5581
|
} catch {
|
|
5470
5582
|
}
|
|
5471
5583
|
}
|
|
5472
5584
|
}
|
|
5473
5585
|
function readPreferences() {
|
|
5474
5586
|
const dir = ensureConfigDir();
|
|
5475
|
-
const
|
|
5476
|
-
if (!(0, import_node_fs9.existsSync)(
|
|
5587
|
+
const path3 = (0, import_node_path11.join)(dir, PREFERENCES_FILENAME);
|
|
5588
|
+
if (!(0, import_node_fs9.existsSync)(path3)) return { ...DEFAULT_PREFERENCES };
|
|
5477
5589
|
try {
|
|
5478
|
-
const parsed = JSON.parse((0, import_node_fs9.readFileSync)(
|
|
5590
|
+
const parsed = JSON.parse((0, import_node_fs9.readFileSync)(path3, "utf8"));
|
|
5479
5591
|
const agg = typeof parsed.aggressiveness === "number" ? parsed.aggressiveness : NaN;
|
|
5480
5592
|
return {
|
|
5481
5593
|
show_system_tables: typeof parsed.show_system_tables === "boolean" ? parsed.show_system_tables : DEFAULT_PREFERENCES.show_system_tables,
|
|
@@ -5489,7 +5601,7 @@ function readPreferences() {
|
|
|
5489
5601
|
}
|
|
5490
5602
|
function writePreferences(prefs) {
|
|
5491
5603
|
const dir = ensureConfigDir();
|
|
5492
|
-
const
|
|
5604
|
+
const path3 = (0, import_node_path11.join)(dir, PREFERENCES_FILENAME);
|
|
5493
5605
|
const body = JSON.stringify(
|
|
5494
5606
|
{
|
|
5495
5607
|
show_system_tables: prefs.show_system_tables,
|
|
@@ -5500,10 +5612,10 @@ function writePreferences(prefs) {
|
|
|
5500
5612
|
null,
|
|
5501
5613
|
2
|
|
5502
5614
|
);
|
|
5503
|
-
(0, import_node_fs9.writeFileSync)(
|
|
5615
|
+
(0, import_node_fs9.writeFileSync)(path3, body + "\n", "utf8");
|
|
5504
5616
|
if ((0, import_node_os3.platform)() !== "win32") {
|
|
5505
5617
|
try {
|
|
5506
|
-
(0, import_node_fs9.chmodSync)(
|
|
5618
|
+
(0, import_node_fs9.chmodSync)(path3, 384);
|
|
5507
5619
|
} catch {
|
|
5508
5620
|
}
|
|
5509
5621
|
}
|
|
@@ -5528,7 +5640,7 @@ function withCredentialLock(fn) {
|
|
|
5528
5640
|
}
|
|
5529
5641
|
}
|
|
5530
5642
|
const dir = ensureConfigDir();
|
|
5531
|
-
const lockPath = (0,
|
|
5643
|
+
const lockPath = (0, import_node_path11.join)(dir, CRED_LOCK_FILENAME);
|
|
5532
5644
|
const deadline = Date.now() + LOCK_TIMEOUT_MS;
|
|
5533
5645
|
let fd;
|
|
5534
5646
|
for (; ; ) {
|
|
@@ -5567,8 +5679,8 @@ function withCredentialLock(fn) {
|
|
|
5567
5679
|
}
|
|
5568
5680
|
}
|
|
5569
5681
|
}
|
|
5570
|
-
function writeFileAtomic(
|
|
5571
|
-
const tmp = `${
|
|
5682
|
+
function writeFileAtomic(path3, data) {
|
|
5683
|
+
const tmp = `${path3}.${String(process.pid)}.${(0, import_node_crypto5.randomBytes)(4).toString("hex")}.tmp`;
|
|
5572
5684
|
(0, import_node_fs9.writeFileSync)(tmp, data, "utf8");
|
|
5573
5685
|
if ((0, import_node_os3.platform)() !== "win32") {
|
|
5574
5686
|
try {
|
|
@@ -5576,7 +5688,7 @@ function writeFileAtomic(path2, data) {
|
|
|
5576
5688
|
} catch {
|
|
5577
5689
|
}
|
|
5578
5690
|
}
|
|
5579
|
-
(0, import_node_fs9.renameSync)(tmp,
|
|
5691
|
+
(0, import_node_fs9.renameSync)(tmp, path3);
|
|
5580
5692
|
}
|
|
5581
5693
|
function mutateCredentials(mutate) {
|
|
5582
5694
|
withCredentialLock(() => {
|
|
@@ -5587,11 +5699,11 @@ function mutateCredentials(mutate) {
|
|
|
5587
5699
|
}
|
|
5588
5700
|
function loadCredentials() {
|
|
5589
5701
|
const dir = ensureConfigDir();
|
|
5590
|
-
const
|
|
5591
|
-
if (!(0, import_node_fs9.existsSync)(
|
|
5702
|
+
const path3 = (0, import_node_path11.join)(dir, DB_CREDENTIALS_FILENAME);
|
|
5703
|
+
if (!(0, import_node_fs9.existsSync)(path3)) return {};
|
|
5592
5704
|
const key = deriveKey(getOrCreateMasterKey());
|
|
5593
5705
|
try {
|
|
5594
|
-
const ciphertext = (0, import_node_fs9.readFileSync)(
|
|
5706
|
+
const ciphertext = (0, import_node_fs9.readFileSync)(path3, "utf8").trim();
|
|
5595
5707
|
const plaintext = decrypt(ciphertext, key);
|
|
5596
5708
|
const parsed = JSON.parse(plaintext);
|
|
5597
5709
|
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
@@ -5606,10 +5718,10 @@ function loadCredentials() {
|
|
|
5606
5718
|
}
|
|
5607
5719
|
function saveCredentials(creds) {
|
|
5608
5720
|
const dir = ensureConfigDir();
|
|
5609
|
-
const
|
|
5721
|
+
const path3 = (0, import_node_path11.join)(dir, DB_CREDENTIALS_FILENAME);
|
|
5610
5722
|
const key = deriveKey(getOrCreateMasterKey());
|
|
5611
5723
|
const ciphertext = encrypt(JSON.stringify(creds), key);
|
|
5612
|
-
writeFileAtomic(
|
|
5724
|
+
writeFileAtomic(path3, ciphertext + "\n");
|
|
5613
5725
|
}
|
|
5614
5726
|
function listDbCredentials() {
|
|
5615
5727
|
return Object.keys(loadCredentials()).sort();
|
|
@@ -5657,11 +5769,11 @@ function healRawDbUrl(configPath) {
|
|
|
5657
5769
|
}
|
|
5658
5770
|
function loadS3Configs() {
|
|
5659
5771
|
const dir = ensureConfigDir();
|
|
5660
|
-
const
|
|
5661
|
-
if (!(0, import_node_fs9.existsSync)(
|
|
5772
|
+
const path3 = (0, import_node_path11.join)(dir, S3_CONFIG_FILENAME);
|
|
5773
|
+
if (!(0, import_node_fs9.existsSync)(path3)) return {};
|
|
5662
5774
|
const key = deriveKey(getOrCreateMasterKey());
|
|
5663
5775
|
try {
|
|
5664
|
-
const parsed = JSON.parse(decrypt((0, import_node_fs9.readFileSync)(
|
|
5776
|
+
const parsed = JSON.parse(decrypt((0, import_node_fs9.readFileSync)(path3, "utf8").trim(), key));
|
|
5665
5777
|
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
5666
5778
|
return parsed;
|
|
5667
5779
|
}
|
|
@@ -5675,12 +5787,12 @@ function loadS3Configs() {
|
|
|
5675
5787
|
}
|
|
5676
5788
|
function saveS3Configs(cfgs) {
|
|
5677
5789
|
const dir = ensureConfigDir();
|
|
5678
|
-
const
|
|
5790
|
+
const path3 = (0, import_node_path11.join)(dir, S3_CONFIG_FILENAME);
|
|
5679
5791
|
const key = deriveKey(getOrCreateMasterKey());
|
|
5680
|
-
(0, import_node_fs9.writeFileSync)(
|
|
5792
|
+
(0, import_node_fs9.writeFileSync)(path3, encrypt(JSON.stringify(cfgs), key) + "\n", "utf8");
|
|
5681
5793
|
if ((0, import_node_os3.platform)() !== "win32") {
|
|
5682
5794
|
try {
|
|
5683
|
-
(0, import_node_fs9.chmodSync)(
|
|
5795
|
+
(0, import_node_fs9.chmodSync)(path3, 384);
|
|
5684
5796
|
} catch {
|
|
5685
5797
|
}
|
|
5686
5798
|
}
|
|
@@ -5717,11 +5829,11 @@ function deleteDbCredential(label) {
|
|
|
5717
5829
|
}
|
|
5718
5830
|
function loadAssistantCredentials() {
|
|
5719
5831
|
const dir = ensureConfigDir();
|
|
5720
|
-
const
|
|
5721
|
-
if (!(0, import_node_fs9.existsSync)(
|
|
5832
|
+
const path3 = (0, import_node_path11.join)(dir, ASSISTANT_CREDENTIALS_FILENAME);
|
|
5833
|
+
if (!(0, import_node_fs9.existsSync)(path3)) return {};
|
|
5722
5834
|
const key = deriveKey(getOrCreateMasterKey());
|
|
5723
5835
|
try {
|
|
5724
|
-
const ciphertext = (0, import_node_fs9.readFileSync)(
|
|
5836
|
+
const ciphertext = (0, import_node_fs9.readFileSync)(path3, "utf8").trim();
|
|
5725
5837
|
const plaintext = decrypt(ciphertext, key);
|
|
5726
5838
|
const parsed = JSON.parse(plaintext);
|
|
5727
5839
|
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
@@ -5736,13 +5848,13 @@ function loadAssistantCredentials() {
|
|
|
5736
5848
|
}
|
|
5737
5849
|
function saveAssistantCredentials(creds) {
|
|
5738
5850
|
const dir = ensureConfigDir();
|
|
5739
|
-
const
|
|
5851
|
+
const path3 = (0, import_node_path11.join)(dir, ASSISTANT_CREDENTIALS_FILENAME);
|
|
5740
5852
|
const key = deriveKey(getOrCreateMasterKey());
|
|
5741
5853
|
const ciphertext = encrypt(JSON.stringify(creds), key);
|
|
5742
|
-
(0, import_node_fs9.writeFileSync)(
|
|
5854
|
+
(0, import_node_fs9.writeFileSync)(path3, ciphertext + "\n", "utf8");
|
|
5743
5855
|
if ((0, import_node_os3.platform)() !== "win32") {
|
|
5744
5856
|
try {
|
|
5745
|
-
(0, import_node_fs9.chmodSync)(
|
|
5857
|
+
(0, import_node_fs9.chmodSync)(path3, 384);
|
|
5746
5858
|
} catch {
|
|
5747
5859
|
}
|
|
5748
5860
|
}
|
|
@@ -5780,7 +5892,7 @@ function clearAssistantCredentialCleared(kind) {
|
|
|
5780
5892
|
saveAssistantCredentials(rest);
|
|
5781
5893
|
}
|
|
5782
5894
|
function ensureKeysDir() {
|
|
5783
|
-
const dir = (0,
|
|
5895
|
+
const dir = (0, import_node_path11.join)(ensureConfigDir(), KEYS_SUBDIR);
|
|
5784
5896
|
if (!(0, import_node_fs9.existsSync)(dir)) {
|
|
5785
5897
|
(0, import_node_fs9.mkdirSync)(dir, { recursive: true });
|
|
5786
5898
|
if ((0, import_node_os3.platform)() !== "win32") {
|
|
@@ -5803,34 +5915,34 @@ function listTokens() {
|
|
|
5803
5915
|
}
|
|
5804
5916
|
function readToken(label) {
|
|
5805
5917
|
assertSafeLabel(label);
|
|
5806
|
-
const
|
|
5807
|
-
if (!(0, import_node_fs9.existsSync)(
|
|
5808
|
-
return (0, import_node_fs9.readFileSync)(
|
|
5918
|
+
const path3 = (0, import_node_path11.join)(ensureKeysDir(), label + TOKEN_EXT);
|
|
5919
|
+
if (!(0, import_node_fs9.existsSync)(path3)) return null;
|
|
5920
|
+
return (0, import_node_fs9.readFileSync)(path3, "utf8").trim();
|
|
5809
5921
|
}
|
|
5810
5922
|
function writeToken(label, token) {
|
|
5811
5923
|
assertSafeLabel(label);
|
|
5812
|
-
const
|
|
5813
|
-
(0, import_node_fs9.writeFileSync)(
|
|
5924
|
+
const path3 = (0, import_node_path11.join)(ensureKeysDir(), label + TOKEN_EXT);
|
|
5925
|
+
(0, import_node_fs9.writeFileSync)(path3, token + "\n", "utf8");
|
|
5814
5926
|
if ((0, import_node_os3.platform)() !== "win32") {
|
|
5815
5927
|
try {
|
|
5816
|
-
(0, import_node_fs9.chmodSync)(
|
|
5928
|
+
(0, import_node_fs9.chmodSync)(path3, 384);
|
|
5817
5929
|
} catch {
|
|
5818
5930
|
}
|
|
5819
5931
|
}
|
|
5820
5932
|
}
|
|
5821
5933
|
function deleteToken(label) {
|
|
5822
5934
|
assertSafeLabel(label);
|
|
5823
|
-
const
|
|
5824
|
-
if ((0, import_node_fs9.existsSync)(
|
|
5935
|
+
const path3 = (0, import_node_path11.join)(ensureKeysDir(), label + TOKEN_EXT);
|
|
5936
|
+
if ((0, import_node_fs9.existsSync)(path3)) (0, import_node_fs9.unlinkSync)(path3);
|
|
5825
5937
|
}
|
|
5826
|
-
var import_node_crypto5, import_node_fs9, import_node_os3,
|
|
5938
|
+
var import_node_crypto5, import_node_fs9, import_node_os3, import_node_path11, import_yaml2, MASTER_KEY_FILENAME, IDENTITY_FILENAME, EMPTY_IDENTITY, PREFERENCES_FILENAME, DEFAULT_PREFERENCES, DB_CREDENTIALS_FILENAME, CRED_LOCK_FILENAME, LOCK_STALE_MS, LOCK_TIMEOUT_MS, lockDepthInProcess, S3_CONFIG_FILENAME, ASSISTANT_CREDENTIALS_FILENAME, CLEARED_SENTINEL_PREFIX, KEYS_SUBDIR, TOKEN_EXT;
|
|
5827
5939
|
var init_user_config = __esm({
|
|
5828
5940
|
"src/framework/user-config.ts"() {
|
|
5829
5941
|
"use strict";
|
|
5830
5942
|
import_node_crypto5 = require("crypto");
|
|
5831
5943
|
import_node_fs9 = require("fs");
|
|
5832
5944
|
import_node_os3 = require("os");
|
|
5833
|
-
|
|
5945
|
+
import_node_path11 = require("path");
|
|
5834
5946
|
import_yaml2 = require("yaml");
|
|
5835
5947
|
init_encryption();
|
|
5836
5948
|
init_lattice_root();
|
|
@@ -5859,8 +5971,8 @@ var init_user_config = __esm({
|
|
|
5859
5971
|
|
|
5860
5972
|
// src/config/parser.ts
|
|
5861
5973
|
function parseConfigFile(configPath) {
|
|
5862
|
-
const absPath = (0,
|
|
5863
|
-
const configDir2 = (0,
|
|
5974
|
+
const absPath = (0, import_node_path12.resolve)(configPath);
|
|
5975
|
+
const configDir2 = (0, import_node_path12.dirname)(absPath);
|
|
5864
5976
|
let raw;
|
|
5865
5977
|
try {
|
|
5866
5978
|
raw = (0, import_node_fs10.readFileSync)(absPath, "utf-8");
|
|
@@ -5943,7 +6055,7 @@ function resolveDbPath(raw, configDir2) {
|
|
|
5943
6055
|
)} as a database path \u2014 it looks like a malformed variable reference, not a file path.`
|
|
5944
6056
|
);
|
|
5945
6057
|
}
|
|
5946
|
-
return (0,
|
|
6058
|
+
return (0, import_node_path12.resolve)(configDir2, raw);
|
|
5947
6059
|
}
|
|
5948
6060
|
function entityToTableDef(entityName, entity) {
|
|
5949
6061
|
const rawFields = entity.fields;
|
|
@@ -6165,12 +6277,12 @@ function parseEntityContexts(entityContexts) {
|
|
|
6165
6277
|
}
|
|
6166
6278
|
return result;
|
|
6167
6279
|
}
|
|
6168
|
-
var import_node_fs10,
|
|
6280
|
+
var import_node_fs10, import_node_path12, import_yaml3;
|
|
6169
6281
|
var init_parser = __esm({
|
|
6170
6282
|
"src/config/parser.ts"() {
|
|
6171
6283
|
"use strict";
|
|
6172
6284
|
import_node_fs10 = require("fs");
|
|
6173
|
-
|
|
6285
|
+
import_node_path12 = require("path");
|
|
6174
6286
|
import_yaml3 = require("yaml");
|
|
6175
6287
|
init_user_config();
|
|
6176
6288
|
}
|
|
@@ -6199,13 +6311,13 @@ function uniqueDirName(displayName, existing) {
|
|
|
6199
6311
|
}
|
|
6200
6312
|
}
|
|
6201
6313
|
function readRegistry(root6) {
|
|
6202
|
-
const
|
|
6203
|
-
if (!(0, import_node_fs11.existsSync)(
|
|
6314
|
+
const path3 = registryPath(root6);
|
|
6315
|
+
if (!(0, import_node_fs11.existsSync)(path3)) return { ...EMPTY_REGISTRY, workspaces: [] };
|
|
6204
6316
|
let parsed;
|
|
6205
6317
|
try {
|
|
6206
|
-
parsed = JSON.parse((0, import_node_fs11.readFileSync)(
|
|
6318
|
+
parsed = JSON.parse((0, import_node_fs11.readFileSync)(path3, "utf-8"));
|
|
6207
6319
|
} catch (e6) {
|
|
6208
|
-
throw new Error(`Lattice: corrupt workspace registry at "${
|
|
6320
|
+
throw new Error(`Lattice: corrupt workspace registry at "${path3}": ${e6.message}`);
|
|
6209
6321
|
}
|
|
6210
6322
|
const reg = parsed;
|
|
6211
6323
|
return {
|
|
@@ -6215,11 +6327,11 @@ function readRegistry(root6) {
|
|
|
6215
6327
|
};
|
|
6216
6328
|
}
|
|
6217
6329
|
function writeRegistry(root6, registry) {
|
|
6218
|
-
const
|
|
6219
|
-
const tmp = `${
|
|
6330
|
+
const path3 = registryPath(root6);
|
|
6331
|
+
const tmp = `${path3}.tmp-${String(process.pid)}`;
|
|
6220
6332
|
(0, import_node_fs11.writeFileSync)(tmp, `${JSON.stringify(registry, null, 2)}
|
|
6221
6333
|
`, "utf-8");
|
|
6222
|
-
(0, import_node_fs11.renameSync)(tmp,
|
|
6334
|
+
(0, import_node_fs11.renameSync)(tmp, path3);
|
|
6223
6335
|
}
|
|
6224
6336
|
function listWorkspaces(root6) {
|
|
6225
6337
|
return readRegistry(root6).workspaces;
|
|
@@ -6242,12 +6354,12 @@ function setActiveWorkspace(root6, id) {
|
|
|
6242
6354
|
}
|
|
6243
6355
|
function resolveWorkspacePaths(root6, ws) {
|
|
6244
6356
|
if (ws.configPath) {
|
|
6245
|
-
const dir = (0,
|
|
6357
|
+
const dir = (0, import_node_path13.dirname)(ws.configPath);
|
|
6246
6358
|
return {
|
|
6247
6359
|
dir,
|
|
6248
6360
|
configPath: ws.configPath,
|
|
6249
|
-
dataDir: (0,
|
|
6250
|
-
contextDir: ws.contextDir ?? (0,
|
|
6361
|
+
dataDir: (0, import_node_path13.join)(dir, "Data"),
|
|
6362
|
+
contextDir: ws.contextDir ?? (0, import_node_path13.resolve)(dir, "context")
|
|
6251
6363
|
};
|
|
6252
6364
|
}
|
|
6253
6365
|
return {
|
|
@@ -6261,8 +6373,8 @@ function effectiveConfigPath(root6, ws) {
|
|
|
6261
6373
|
return ws.configPath ?? workspaceConfigPath(root6, ws.dir);
|
|
6262
6374
|
}
|
|
6263
6375
|
function findWorkspaceByConfigPath(root6, configPath) {
|
|
6264
|
-
const target = (0,
|
|
6265
|
-
return listWorkspaces(root6).find((w2) => (0,
|
|
6376
|
+
const target = (0, import_node_path13.resolve)(configPath);
|
|
6377
|
+
return listWorkspaces(root6).find((w2) => (0, import_node_path13.resolve)(effectiveConfigPath(root6, w2)) === target) ?? null;
|
|
6266
6378
|
}
|
|
6267
6379
|
function isCloudDb(db) {
|
|
6268
6380
|
const trimmed = db.trim();
|
|
@@ -6307,7 +6419,7 @@ function addWorkspace(root6, opts) {
|
|
|
6307
6419
|
return record;
|
|
6308
6420
|
}
|
|
6309
6421
|
function workspaceDbPath(root6, ws) {
|
|
6310
|
-
return (0,
|
|
6422
|
+
return (0, import_node_path13.join)(workspaceDataDir(root6, ws.dir), "database.db");
|
|
6311
6423
|
}
|
|
6312
6424
|
function addAdoptedWorkspace(root6, opts) {
|
|
6313
6425
|
if (!(0, import_node_fs11.existsSync)(rootConfigDir(root6))) {
|
|
@@ -6327,8 +6439,8 @@ function addAdoptedWorkspace(root6, opts) {
|
|
|
6327
6439
|
db: opts.db,
|
|
6328
6440
|
kind: isCloudDb(opts.db) ? "cloud" : "local",
|
|
6329
6441
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
6330
|
-
configPath: (0,
|
|
6331
|
-
contextDir: (0,
|
|
6442
|
+
configPath: (0, import_node_path13.resolve)(opts.configPath),
|
|
6443
|
+
contextDir: (0, import_node_path13.resolve)(opts.contextDir)
|
|
6332
6444
|
};
|
|
6333
6445
|
reg.workspaces.push(record);
|
|
6334
6446
|
const makeActive = opts.makeActive ?? reg.activeWorkspaceId === null;
|
|
@@ -6378,12 +6490,12 @@ function renameWorkspaceByConfigPath(root6, configPath, displayName) {
|
|
|
6378
6490
|
writeRegistry(root6, reg);
|
|
6379
6491
|
}
|
|
6380
6492
|
}
|
|
6381
|
-
var import_node_fs11,
|
|
6493
|
+
var import_node_fs11, import_node_path13, import_uuid2, EMPTY_REGISTRY, LOCAL_DB_RELPATH, WINDOWS_RESERVED, ILLEGAL_DIR_CHARS;
|
|
6382
6494
|
var init_workspace = __esm({
|
|
6383
6495
|
"src/framework/workspace.ts"() {
|
|
6384
6496
|
"use strict";
|
|
6385
6497
|
import_node_fs11 = require("fs");
|
|
6386
|
-
|
|
6498
|
+
import_node_path13 = require("path");
|
|
6387
6499
|
import_uuid2 = require("uuid");
|
|
6388
6500
|
init_lattice_root();
|
|
6389
6501
|
EMPTY_REGISTRY = {
|
|
@@ -8003,18 +8115,18 @@ function computedColumnOrder(table, computed) {
|
|
|
8003
8115
|
const names = new Set(Object.keys(computed));
|
|
8004
8116
|
const order = [];
|
|
8005
8117
|
const state2 = /* @__PURE__ */ new Map();
|
|
8006
|
-
const visit = (name,
|
|
8118
|
+
const visit = (name, path3) => {
|
|
8007
8119
|
const st = state2.get(name);
|
|
8008
8120
|
if (st === "done") return;
|
|
8009
8121
|
if (st === "visiting") {
|
|
8010
|
-
const start =
|
|
8011
|
-
throw new ComputedColumnCycleError(table, [...
|
|
8122
|
+
const start = path3.indexOf(name);
|
|
8123
|
+
throw new ComputedColumnCycleError(table, [...path3.slice(start), name]);
|
|
8012
8124
|
}
|
|
8013
8125
|
state2.set(name, "visiting");
|
|
8014
8126
|
const spec = computed[name];
|
|
8015
8127
|
if (spec) {
|
|
8016
8128
|
for (const dep of spec.deps) {
|
|
8017
|
-
if (names.has(dep)) visit(dep, [...
|
|
8129
|
+
if (names.has(dep)) visit(dep, [...path3, name]);
|
|
8018
8130
|
}
|
|
8019
8131
|
}
|
|
8020
8132
|
state2.set(name, "done");
|
|
@@ -15907,12 +16019,12 @@ var init_types = __esm({
|
|
|
15907
16019
|
});
|
|
15908
16020
|
|
|
15909
16021
|
// node_modules/@smithy/core/dist-es/submodules/config/shared-ini-file-loader/getHomeDir.js
|
|
15910
|
-
var import_node_os4,
|
|
16022
|
+
var import_node_os4, import_node_path16, homeDirCache, getHomeDirCacheKey, getHomeDir;
|
|
15911
16023
|
var init_getHomeDir = __esm({
|
|
15912
16024
|
"node_modules/@smithy/core/dist-es/submodules/config/shared-ini-file-loader/getHomeDir.js"() {
|
|
15913
16025
|
"use strict";
|
|
15914
16026
|
import_node_os4 = require("os");
|
|
15915
|
-
|
|
16027
|
+
import_node_path16 = require("path");
|
|
15916
16028
|
homeDirCache = {};
|
|
15917
16029
|
getHomeDirCacheKey = () => {
|
|
15918
16030
|
if (process && process.geteuid) {
|
|
@@ -15921,7 +16033,7 @@ var init_getHomeDir = __esm({
|
|
|
15921
16033
|
return "DEFAULT";
|
|
15922
16034
|
};
|
|
15923
16035
|
getHomeDir = () => {
|
|
15924
|
-
const { HOME, USERPROFILE, HOMEPATH, HOMEDRIVE = `C:${
|
|
16036
|
+
const { HOME, USERPROFILE, HOMEPATH, HOMEDRIVE = `C:${import_node_path16.sep}` } = process.env;
|
|
15925
16037
|
if (HOME)
|
|
15926
16038
|
return HOME;
|
|
15927
16039
|
if (USERPROFILE)
|
|
@@ -15948,17 +16060,17 @@ var init_getProfileName = __esm({
|
|
|
15948
16060
|
});
|
|
15949
16061
|
|
|
15950
16062
|
// node_modules/@smithy/core/dist-es/submodules/config/shared-ini-file-loader/getSSOTokenFilepath.js
|
|
15951
|
-
var import_node_crypto9,
|
|
16063
|
+
var import_node_crypto9, import_node_path17, getSSOTokenFilepath;
|
|
15952
16064
|
var init_getSSOTokenFilepath = __esm({
|
|
15953
16065
|
"node_modules/@smithy/core/dist-es/submodules/config/shared-ini-file-loader/getSSOTokenFilepath.js"() {
|
|
15954
16066
|
"use strict";
|
|
15955
16067
|
import_node_crypto9 = require("crypto");
|
|
15956
|
-
|
|
16068
|
+
import_node_path17 = require("path");
|
|
15957
16069
|
init_getHomeDir();
|
|
15958
16070
|
getSSOTokenFilepath = (id) => {
|
|
15959
16071
|
const hasher = (0, import_node_crypto9.createHash)("sha1");
|
|
15960
16072
|
const cacheName = hasher.update(id).digest("hex");
|
|
15961
|
-
return (0,
|
|
16073
|
+
return (0, import_node_path17.join)(getHomeDir(), ".aws", "sso", "cache", `${cacheName}.json`);
|
|
15962
16074
|
};
|
|
15963
16075
|
}
|
|
15964
16076
|
});
|
|
@@ -16016,26 +16128,26 @@ var init_getConfigData = __esm({
|
|
|
16016
16128
|
});
|
|
16017
16129
|
|
|
16018
16130
|
// node_modules/@smithy/core/dist-es/submodules/config/shared-ini-file-loader/getConfigFilepath.js
|
|
16019
|
-
var
|
|
16131
|
+
var import_node_path18, ENV_CONFIG_PATH, getConfigFilepath;
|
|
16020
16132
|
var init_getConfigFilepath = __esm({
|
|
16021
16133
|
"node_modules/@smithy/core/dist-es/submodules/config/shared-ini-file-loader/getConfigFilepath.js"() {
|
|
16022
16134
|
"use strict";
|
|
16023
|
-
|
|
16135
|
+
import_node_path18 = require("path");
|
|
16024
16136
|
init_getHomeDir();
|
|
16025
16137
|
ENV_CONFIG_PATH = "AWS_CONFIG_FILE";
|
|
16026
|
-
getConfigFilepath = () => process.env[ENV_CONFIG_PATH] || (0,
|
|
16138
|
+
getConfigFilepath = () => process.env[ENV_CONFIG_PATH] || (0, import_node_path18.join)(getHomeDir(), ".aws", "config");
|
|
16027
16139
|
}
|
|
16028
16140
|
});
|
|
16029
16141
|
|
|
16030
16142
|
// node_modules/@smithy/core/dist-es/submodules/config/shared-ini-file-loader/getCredentialsFilepath.js
|
|
16031
|
-
var
|
|
16143
|
+
var import_node_path19, ENV_CREDENTIALS_PATH, getCredentialsFilepath;
|
|
16032
16144
|
var init_getCredentialsFilepath = __esm({
|
|
16033
16145
|
"node_modules/@smithy/core/dist-es/submodules/config/shared-ini-file-loader/getCredentialsFilepath.js"() {
|
|
16034
16146
|
"use strict";
|
|
16035
|
-
|
|
16147
|
+
import_node_path19 = require("path");
|
|
16036
16148
|
init_getHomeDir();
|
|
16037
16149
|
ENV_CREDENTIALS_PATH = "AWS_SHARED_CREDENTIALS_FILE";
|
|
16038
|
-
getCredentialsFilepath = () => process.env[ENV_CREDENTIALS_PATH] || (0,
|
|
16150
|
+
getCredentialsFilepath = () => process.env[ENV_CREDENTIALS_PATH] || (0, import_node_path19.join)(getHomeDir(), ".aws", "credentials");
|
|
16039
16151
|
}
|
|
16040
16152
|
});
|
|
16041
16153
|
|
|
@@ -16104,24 +16216,24 @@ var init_readFile = __esm({
|
|
|
16104
16216
|
import_promises2 = require("fs/promises");
|
|
16105
16217
|
filePromises = {};
|
|
16106
16218
|
fileIntercept = {};
|
|
16107
|
-
readFile2 = (
|
|
16108
|
-
if (fileIntercept[
|
|
16109
|
-
return fileIntercept[
|
|
16219
|
+
readFile2 = (path3, options) => {
|
|
16220
|
+
if (fileIntercept[path3] !== void 0) {
|
|
16221
|
+
return fileIntercept[path3];
|
|
16110
16222
|
}
|
|
16111
|
-
if (!filePromises[
|
|
16112
|
-
filePromises[
|
|
16223
|
+
if (!filePromises[path3] || options?.ignoreCache) {
|
|
16224
|
+
filePromises[path3] = (0, import_promises2.readFile)(path3, "utf8");
|
|
16113
16225
|
}
|
|
16114
|
-
return filePromises[
|
|
16226
|
+
return filePromises[path3];
|
|
16115
16227
|
};
|
|
16116
16228
|
}
|
|
16117
16229
|
});
|
|
16118
16230
|
|
|
16119
16231
|
// node_modules/@smithy/core/dist-es/submodules/config/shared-ini-file-loader/loadSharedConfigFiles.js
|
|
16120
|
-
var
|
|
16232
|
+
var import_node_path20, swallowError, loadSharedConfigFiles;
|
|
16121
16233
|
var init_loadSharedConfigFiles = __esm({
|
|
16122
16234
|
"node_modules/@smithy/core/dist-es/submodules/config/shared-ini-file-loader/loadSharedConfigFiles.js"() {
|
|
16123
16235
|
"use strict";
|
|
16124
|
-
|
|
16236
|
+
import_node_path20 = require("path");
|
|
16125
16237
|
init_getConfigData();
|
|
16126
16238
|
init_getConfigFilepath();
|
|
16127
16239
|
init_getCredentialsFilepath();
|
|
@@ -16136,11 +16248,11 @@ var init_loadSharedConfigFiles = __esm({
|
|
|
16136
16248
|
const relativeHomeDirPrefix = "~/";
|
|
16137
16249
|
let resolvedFilepath = filepath;
|
|
16138
16250
|
if (filepath.startsWith(relativeHomeDirPrefix)) {
|
|
16139
|
-
resolvedFilepath = (0,
|
|
16251
|
+
resolvedFilepath = (0, import_node_path20.join)(homeDir, filepath.slice(2));
|
|
16140
16252
|
}
|
|
16141
16253
|
let resolvedConfigFilepath = configFilepath;
|
|
16142
16254
|
if (configFilepath.startsWith(relativeHomeDirPrefix)) {
|
|
16143
|
-
resolvedConfigFilepath = (0,
|
|
16255
|
+
resolvedConfigFilepath = (0, import_node_path20.join)(homeDir, configFilepath.slice(2));
|
|
16144
16256
|
}
|
|
16145
16257
|
const parsedFiles = await Promise.all([
|
|
16146
16258
|
readFile2(resolvedConfigFilepath, {
|
|
@@ -16229,8 +16341,8 @@ var init_externalDataInterceptor = __esm({
|
|
|
16229
16341
|
getFileRecord() {
|
|
16230
16342
|
return fileIntercept;
|
|
16231
16343
|
},
|
|
16232
|
-
interceptFile(
|
|
16233
|
-
fileIntercept[
|
|
16344
|
+
interceptFile(path3, contents) {
|
|
16345
|
+
fileIntercept[path3] = Promise.resolve(contents);
|
|
16234
16346
|
},
|
|
16235
16347
|
getTokenRecord() {
|
|
16236
16348
|
return tokenIntercept;
|
|
@@ -16564,13 +16676,13 @@ var init_resolveDefaultsModeConfig = __esm({
|
|
|
16564
16676
|
}
|
|
16565
16677
|
return { hostname: "169.254.169.254", path: "/" };
|
|
16566
16678
|
};
|
|
16567
|
-
imdsHttpGet = async ({ hostname, path:
|
|
16679
|
+
imdsHttpGet = async ({ hostname, path: path3 }) => {
|
|
16568
16680
|
const { request } = await import("http");
|
|
16569
16681
|
return new Promise((resolve17, reject) => {
|
|
16570
16682
|
const req = request({
|
|
16571
16683
|
method: "GET",
|
|
16572
16684
|
hostname: hostname.replace(/^\[(.+)]$/, "$1"),
|
|
16573
|
-
path:
|
|
16685
|
+
path: path3,
|
|
16574
16686
|
timeout: 1e3,
|
|
16575
16687
|
signal: AbortSignal.timeout(1e3)
|
|
16576
16688
|
});
|
|
@@ -16771,8 +16883,8 @@ var init_createConfigValueProvider = __esm({
|
|
|
16771
16883
|
return endpoint.url.href;
|
|
16772
16884
|
}
|
|
16773
16885
|
if ("hostname" in endpoint) {
|
|
16774
|
-
const { protocol, hostname, port, path:
|
|
16775
|
-
return `${protocol}//${hostname}${port ? ":" + port : ""}${
|
|
16886
|
+
const { protocol, hostname, port, path: path3 } = endpoint;
|
|
16887
|
+
return `${protocol}//${hostname}${port ? ":" + port : ""}${path3}`;
|
|
16776
16888
|
}
|
|
16777
16889
|
}
|
|
16778
16890
|
return endpoint;
|
|
@@ -17209,18 +17321,18 @@ var init_getAttrPathList = __esm({
|
|
|
17209
17321
|
"node_modules/@smithy/core/dist-es/submodules/endpoints/util-endpoints/lib/getAttrPathList.js"() {
|
|
17210
17322
|
"use strict";
|
|
17211
17323
|
init_types2();
|
|
17212
|
-
getAttrPathList = (
|
|
17213
|
-
const parts =
|
|
17324
|
+
getAttrPathList = (path3) => {
|
|
17325
|
+
const parts = path3.split(".");
|
|
17214
17326
|
const pathList = [];
|
|
17215
17327
|
for (const part of parts) {
|
|
17216
17328
|
const squareBracketIndex = part.indexOf("[");
|
|
17217
17329
|
if (squareBracketIndex !== -1) {
|
|
17218
17330
|
if (part.indexOf("]") !== part.length - 1) {
|
|
17219
|
-
throw new EndpointError(`Path: '${
|
|
17331
|
+
throw new EndpointError(`Path: '${path3}' does not end with ']'`);
|
|
17220
17332
|
}
|
|
17221
17333
|
const arrayIndex = part.slice(squareBracketIndex + 1, -1);
|
|
17222
17334
|
if (Number.isNaN(parseInt(arrayIndex))) {
|
|
17223
|
-
throw new EndpointError(`Invalid array index: '${arrayIndex}' in path: '${
|
|
17335
|
+
throw new EndpointError(`Invalid array index: '${arrayIndex}' in path: '${path3}'`);
|
|
17224
17336
|
}
|
|
17225
17337
|
if (squareBracketIndex !== 0) {
|
|
17226
17338
|
pathList.push(part.slice(0, squareBracketIndex));
|
|
@@ -17242,9 +17354,9 @@ var init_getAttr = __esm({
|
|
|
17242
17354
|
"use strict";
|
|
17243
17355
|
init_types2();
|
|
17244
17356
|
init_getAttrPathList();
|
|
17245
|
-
getAttr = (value,
|
|
17357
|
+
getAttr = (value, path3) => getAttrPathList(path3).reduce((acc, index) => {
|
|
17246
17358
|
if (typeof acc !== "object") {
|
|
17247
|
-
throw new EndpointError(`Index '${index}' in '${
|
|
17359
|
+
throw new EndpointError(`Index '${index}' in '${path3}' not found in '${JSON.stringify(value)}'`);
|
|
17248
17360
|
} else if (Array.isArray(acc)) {
|
|
17249
17361
|
const i6 = parseInt(index);
|
|
17250
17362
|
return acc[i6 < 0 ? acc.length + i6 : i6];
|
|
@@ -17310,8 +17422,8 @@ var init_parseURL = __esm({
|
|
|
17310
17422
|
return value;
|
|
17311
17423
|
}
|
|
17312
17424
|
if (typeof value === "object" && "hostname" in value) {
|
|
17313
|
-
const { hostname: hostname2, port, protocol: protocol2 = "", path:
|
|
17314
|
-
const url = new URL(`${protocol2}//${hostname2}${port ? `:${port}` : ""}${
|
|
17425
|
+
const { hostname: hostname2, port, protocol: protocol2 = "", path: path3 = "", query = {} } = value;
|
|
17426
|
+
const url = new URL(`${protocol2}//${hostname2}${port ? `:${port}` : ""}${path3}`);
|
|
17315
17427
|
url.search = Object.entries(query).map(([k6, v2]) => `${k6}=${v2}`).join("&");
|
|
17316
17428
|
return url;
|
|
17317
17429
|
}
|
|
@@ -20424,11 +20536,11 @@ var init_HttpBindingProtocol = __esm({
|
|
|
20424
20536
|
const opTraits = translateTraits(operationSchema.traits);
|
|
20425
20537
|
if (opTraits.http) {
|
|
20426
20538
|
request.method = opTraits.http[0];
|
|
20427
|
-
const [
|
|
20539
|
+
const [path3, search] = opTraits.http[1].split("?");
|
|
20428
20540
|
if (request.path == "/") {
|
|
20429
|
-
request.path =
|
|
20541
|
+
request.path = path3;
|
|
20430
20542
|
} else {
|
|
20431
|
-
request.path +=
|
|
20543
|
+
request.path += path3;
|
|
20432
20544
|
}
|
|
20433
20545
|
const traitSearchParams = new URLSearchParams(search ?? "");
|
|
20434
20546
|
for (const [key, value] of traitSearchParams) {
|
|
@@ -22407,9 +22519,9 @@ var init_createPaginator = __esm({
|
|
|
22407
22519
|
command = withCommand(command) ?? command;
|
|
22408
22520
|
return await client.send(command, ...args);
|
|
22409
22521
|
};
|
|
22410
|
-
get = (fromObject,
|
|
22522
|
+
get = (fromObject, path3) => {
|
|
22411
22523
|
let cursor = fromObject;
|
|
22412
|
-
const pathComponents =
|
|
22524
|
+
const pathComponents = path3.split(".");
|
|
22413
22525
|
for (const step of pathComponents) {
|
|
22414
22526
|
if (!cursor || typeof cursor !== "object") {
|
|
22415
22527
|
return void 0;
|
|
@@ -22853,20 +22965,20 @@ var init_getRuntimeUserAgentPair = __esm({
|
|
|
22853
22965
|
});
|
|
22854
22966
|
|
|
22855
22967
|
// node_modules/@aws-sdk/core/dist-es/submodules/client/util-user-agent-node/getNodeModulesParentDirs.js
|
|
22856
|
-
var
|
|
22968
|
+
var import_node_path21, getNodeModulesParentDirs;
|
|
22857
22969
|
var init_getNodeModulesParentDirs = __esm({
|
|
22858
22970
|
"node_modules/@aws-sdk/core/dist-es/submodules/client/util-user-agent-node/getNodeModulesParentDirs.js"() {
|
|
22859
22971
|
"use strict";
|
|
22860
|
-
|
|
22972
|
+
import_node_path21 = require("path");
|
|
22861
22973
|
getNodeModulesParentDirs = (dirname18) => {
|
|
22862
22974
|
const cwd = process.cwd();
|
|
22863
22975
|
if (!dirname18) {
|
|
22864
22976
|
return [cwd];
|
|
22865
22977
|
}
|
|
22866
|
-
const normalizedPath = (0,
|
|
22867
|
-
const parts = normalizedPath.split(
|
|
22978
|
+
const normalizedPath = (0, import_node_path21.normalize)(dirname18);
|
|
22979
|
+
const parts = normalizedPath.split(import_node_path21.sep);
|
|
22868
22980
|
const nodeModulesIndex = parts.indexOf("node_modules");
|
|
22869
|
-
const parentDir = nodeModulesIndex !== -1 ? parts.slice(0, nodeModulesIndex).join(
|
|
22981
|
+
const parentDir = nodeModulesIndex !== -1 ? parts.slice(0, nodeModulesIndex).join(import_node_path21.sep) : normalizedPath;
|
|
22870
22982
|
if (cwd === parentDir) {
|
|
22871
22983
|
return [cwd];
|
|
22872
22984
|
}
|
|
@@ -22915,17 +23027,17 @@ var init_getSanitizedDevTypeScriptVersion = __esm({
|
|
|
22915
23027
|
});
|
|
22916
23028
|
|
|
22917
23029
|
// node_modules/@aws-sdk/core/dist-es/submodules/client/util-user-agent-node/getTypeScriptUserAgentPair.js
|
|
22918
|
-
var import_promises3,
|
|
23030
|
+
var import_promises3, import_node_path22, tscVersion, TS_PACKAGE_JSON, getTypeScriptUserAgentPair;
|
|
22919
23031
|
var init_getTypeScriptUserAgentPair = __esm({
|
|
22920
23032
|
"node_modules/@aws-sdk/core/dist-es/submodules/client/util-user-agent-node/getTypeScriptUserAgentPair.js"() {
|
|
22921
23033
|
"use strict";
|
|
22922
23034
|
init_config3();
|
|
22923
23035
|
import_promises3 = require("fs/promises");
|
|
22924
|
-
|
|
23036
|
+
import_node_path22 = require("path");
|
|
22925
23037
|
init_getNodeModulesParentDirs();
|
|
22926
23038
|
init_getSanitizedDevTypeScriptVersion();
|
|
22927
23039
|
init_getSanitizedTypeScriptVersion();
|
|
22928
|
-
TS_PACKAGE_JSON = (0,
|
|
23040
|
+
TS_PACKAGE_JSON = (0, import_node_path22.join)("node_modules", "typescript", "package.json");
|
|
22929
23041
|
getTypeScriptUserAgentPair = async () => {
|
|
22930
23042
|
if (tscVersion === null) {
|
|
22931
23043
|
return void 0;
|
|
@@ -22946,7 +23058,7 @@ var init_getTypeScriptUserAgentPair = __esm({
|
|
|
22946
23058
|
let versionFromApp;
|
|
22947
23059
|
for (const nodeModulesParentDir of nodeModulesParentDirs) {
|
|
22948
23060
|
try {
|
|
22949
|
-
const appPackageJsonPath = (0,
|
|
23061
|
+
const appPackageJsonPath = (0, import_node_path22.join)(nodeModulesParentDir, "package.json");
|
|
22950
23062
|
const packageJson = await (0, import_promises3.readFile)(appPackageJsonPath, "utf-8");
|
|
22951
23063
|
const { dependencies, devDependencies } = JSON.parse(packageJson);
|
|
22952
23064
|
const version = devDependencies?.typescript ?? dependencies?.typescript;
|
|
@@ -22965,7 +23077,7 @@ var init_getTypeScriptUserAgentPair = __esm({
|
|
|
22965
23077
|
let versionFromNodeModules;
|
|
22966
23078
|
for (const nodeModulesParentDir of nodeModulesParentDirs) {
|
|
22967
23079
|
try {
|
|
22968
|
-
const tsPackageJsonPath = (0,
|
|
23080
|
+
const tsPackageJsonPath = (0, import_node_path22.join)(nodeModulesParentDir, TS_PACKAGE_JSON);
|
|
22969
23081
|
const packageJson = await (0, import_promises3.readFile)(tsPackageJsonPath, "utf-8");
|
|
22970
23082
|
const { version } = JSON.parse(packageJson);
|
|
22971
23083
|
const sanitizedVersion2 = getSanitizedTypeScriptVersion(version);
|
|
@@ -24901,10 +25013,10 @@ ${longDate}
|
|
|
24901
25013
|
${credentialScope}
|
|
24902
25014
|
${toHex(hashedRequest)}`;
|
|
24903
25015
|
}
|
|
24904
|
-
getCanonicalPath({ path:
|
|
25016
|
+
getCanonicalPath({ path: path3 }) {
|
|
24905
25017
|
if (this.uriEscapePath) {
|
|
24906
25018
|
const normalizedPathSegments = [];
|
|
24907
|
-
for (const pathSegment of
|
|
25019
|
+
for (const pathSegment of path3.split("/")) {
|
|
24908
25020
|
if (pathSegment?.length === 0)
|
|
24909
25021
|
continue;
|
|
24910
25022
|
if (pathSegment === ".")
|
|
@@ -24915,11 +25027,11 @@ ${toHex(hashedRequest)}`;
|
|
|
24915
25027
|
normalizedPathSegments.push(pathSegment);
|
|
24916
25028
|
}
|
|
24917
25029
|
}
|
|
24918
|
-
const normalizedPath = `${
|
|
25030
|
+
const normalizedPath = `${path3?.startsWith("/") ? "/" : ""}${normalizedPathSegments.join("/")}${normalizedPathSegments.length > 0 && path3?.endsWith("/") ? "/" : ""}`;
|
|
24919
25031
|
const doubleEncoded = escapeUri(normalizedPath);
|
|
24920
25032
|
return doubleEncoded.replace(/%2F/g, "/");
|
|
24921
25033
|
}
|
|
24922
|
-
return
|
|
25034
|
+
return path3;
|
|
24923
25035
|
}
|
|
24924
25036
|
validateResolvedCredentials(credentials) {
|
|
24925
25037
|
if (typeof credentials !== "object" || typeof credentials.accessKeyId !== "string" || typeof credentials.secretAccessKey !== "string") {
|
|
@@ -29837,16 +29949,16 @@ var init_Matcher = __esm({
|
|
|
29837
29949
|
* @returns {string|undefined}
|
|
29838
29950
|
*/
|
|
29839
29951
|
getCurrentTag() {
|
|
29840
|
-
const
|
|
29841
|
-
return
|
|
29952
|
+
const path3 = this._matcher.path;
|
|
29953
|
+
return path3.length > 0 ? path3[path3.length - 1].tag : void 0;
|
|
29842
29954
|
}
|
|
29843
29955
|
/**
|
|
29844
29956
|
* Get current namespace.
|
|
29845
29957
|
* @returns {string|undefined}
|
|
29846
29958
|
*/
|
|
29847
29959
|
getCurrentNamespace() {
|
|
29848
|
-
const
|
|
29849
|
-
return
|
|
29960
|
+
const path3 = this._matcher.path;
|
|
29961
|
+
return path3.length > 0 ? path3[path3.length - 1].namespace : void 0;
|
|
29850
29962
|
}
|
|
29851
29963
|
/**
|
|
29852
29964
|
* Get current node's attribute value.
|
|
@@ -29854,9 +29966,9 @@ var init_Matcher = __esm({
|
|
|
29854
29966
|
* @returns {*}
|
|
29855
29967
|
*/
|
|
29856
29968
|
getAttrValue(attrName) {
|
|
29857
|
-
const
|
|
29858
|
-
if (
|
|
29859
|
-
return
|
|
29969
|
+
const path3 = this._matcher.path;
|
|
29970
|
+
if (path3.length === 0) return void 0;
|
|
29971
|
+
return path3[path3.length - 1].values?.[attrName];
|
|
29860
29972
|
}
|
|
29861
29973
|
/**
|
|
29862
29974
|
* Check if current node has an attribute.
|
|
@@ -29864,9 +29976,9 @@ var init_Matcher = __esm({
|
|
|
29864
29976
|
* @returns {boolean}
|
|
29865
29977
|
*/
|
|
29866
29978
|
hasAttr(attrName) {
|
|
29867
|
-
const
|
|
29868
|
-
if (
|
|
29869
|
-
const current =
|
|
29979
|
+
const path3 = this._matcher.path;
|
|
29980
|
+
if (path3.length === 0) return false;
|
|
29981
|
+
const current = path3[path3.length - 1];
|
|
29870
29982
|
return current.values !== void 0 && attrName in current.values;
|
|
29871
29983
|
}
|
|
29872
29984
|
/**
|
|
@@ -29874,18 +29986,18 @@ var init_Matcher = __esm({
|
|
|
29874
29986
|
* @returns {number}
|
|
29875
29987
|
*/
|
|
29876
29988
|
getPosition() {
|
|
29877
|
-
const
|
|
29878
|
-
if (
|
|
29879
|
-
return
|
|
29989
|
+
const path3 = this._matcher.path;
|
|
29990
|
+
if (path3.length === 0) return -1;
|
|
29991
|
+
return path3[path3.length - 1].position ?? 0;
|
|
29880
29992
|
}
|
|
29881
29993
|
/**
|
|
29882
29994
|
* Get current node's repeat counter (occurrence count of this tag name).
|
|
29883
29995
|
* @returns {number}
|
|
29884
29996
|
*/
|
|
29885
29997
|
getCounter() {
|
|
29886
|
-
const
|
|
29887
|
-
if (
|
|
29888
|
-
return
|
|
29998
|
+
const path3 = this._matcher.path;
|
|
29999
|
+
if (path3.length === 0) return -1;
|
|
30000
|
+
return path3[path3.length - 1].counter ?? 0;
|
|
29889
30001
|
}
|
|
29890
30002
|
/**
|
|
29891
30003
|
* Get current node's sibling index (alias for getPosition).
|
|
@@ -41653,12 +41765,12 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
41653
41765
|
const password = request.password ?? "";
|
|
41654
41766
|
auth = `${username}:${password}`;
|
|
41655
41767
|
}
|
|
41656
|
-
let
|
|
41768
|
+
let path3 = request.path;
|
|
41657
41769
|
if (queryString) {
|
|
41658
|
-
|
|
41770
|
+
path3 += `?${queryString}`;
|
|
41659
41771
|
}
|
|
41660
41772
|
if (request.fragment) {
|
|
41661
|
-
|
|
41773
|
+
path3 += `#${request.fragment}`;
|
|
41662
41774
|
}
|
|
41663
41775
|
let hostname = request.hostname ?? "";
|
|
41664
41776
|
if (hostname[0] === "[" && hostname.endsWith("]")) {
|
|
@@ -41670,7 +41782,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
41670
41782
|
headers: request.headers,
|
|
41671
41783
|
host: hostname,
|
|
41672
41784
|
method: request.method,
|
|
41673
|
-
path:
|
|
41785
|
+
path: path3,
|
|
41674
41786
|
port: request.port,
|
|
41675
41787
|
agent,
|
|
41676
41788
|
auth
|
|
@@ -46417,7 +46529,7 @@ var init_signin = __esm({
|
|
|
46417
46529
|
});
|
|
46418
46530
|
|
|
46419
46531
|
// node_modules/@aws-sdk/credential-provider-login/dist-es/LoginCredentialsFetcher.js
|
|
46420
|
-
var import_node_crypto12, import_node_fs17, import_node_os6,
|
|
46532
|
+
var import_node_crypto12, import_node_fs17, import_node_os6, import_node_path23, LoginCredentialsFetcher;
|
|
46421
46533
|
var init_LoginCredentialsFetcher = __esm({
|
|
46422
46534
|
"node_modules/@aws-sdk/credential-provider-login/dist-es/LoginCredentialsFetcher.js"() {
|
|
46423
46535
|
"use strict";
|
|
@@ -46426,7 +46538,7 @@ var init_LoginCredentialsFetcher = __esm({
|
|
|
46426
46538
|
import_node_crypto12 = require("crypto");
|
|
46427
46539
|
import_node_fs17 = require("fs");
|
|
46428
46540
|
import_node_os6 = require("os");
|
|
46429
|
-
|
|
46541
|
+
import_node_path23 = require("path");
|
|
46430
46542
|
LoginCredentialsFetcher = class _LoginCredentialsFetcher {
|
|
46431
46543
|
profileData;
|
|
46432
46544
|
init;
|
|
@@ -46574,7 +46686,7 @@ var init_LoginCredentialsFetcher = __esm({
|
|
|
46574
46686
|
}
|
|
46575
46687
|
async saveToken(token) {
|
|
46576
46688
|
const tokenFilePath = this.getTokenFilePath();
|
|
46577
|
-
const directory = (0,
|
|
46689
|
+
const directory = (0, import_node_path23.dirname)(tokenFilePath);
|
|
46578
46690
|
try {
|
|
46579
46691
|
await import_node_fs17.promises.mkdir(directory, { recursive: true });
|
|
46580
46692
|
} catch (error) {
|
|
@@ -46582,10 +46694,10 @@ var init_LoginCredentialsFetcher = __esm({
|
|
|
46582
46694
|
await import_node_fs17.promises.writeFile(tokenFilePath, JSON.stringify(token, null, 2), "utf8");
|
|
46583
46695
|
}
|
|
46584
46696
|
getTokenFilePath() {
|
|
46585
|
-
const directory = process.env.AWS_LOGIN_CACHE_DIRECTORY ?? (0,
|
|
46697
|
+
const directory = process.env.AWS_LOGIN_CACHE_DIRECTORY ?? (0, import_node_path23.join)((0, import_node_os6.homedir)(), ".aws", "login", "cache");
|
|
46586
46698
|
const loginSessionBytes = Buffer.from(this.loginSession, "utf8");
|
|
46587
46699
|
const loginSessionSha256 = (0, import_node_crypto12.createHash)("sha256").update(loginSessionBytes).digest("hex");
|
|
46588
|
-
return (0,
|
|
46700
|
+
return (0, import_node_path23.join)(directory, `${loginSessionSha256}.json`);
|
|
46589
46701
|
}
|
|
46590
46702
|
derToRawSignature(derSignature) {
|
|
46591
46703
|
let offset = 2;
|
|
@@ -46779,12 +46891,12 @@ var init_getValidatedProcessCredentials = __esm({
|
|
|
46779
46891
|
});
|
|
46780
46892
|
|
|
46781
46893
|
// node_modules/@aws-sdk/credential-provider-process/dist-es/resolveProcessCredentials.js
|
|
46782
|
-
var
|
|
46894
|
+
var import_node_child_process3, import_node_util, resolveProcessCredentials;
|
|
46783
46895
|
var init_resolveProcessCredentials = __esm({
|
|
46784
46896
|
"node_modules/@aws-sdk/credential-provider-process/dist-es/resolveProcessCredentials.js"() {
|
|
46785
46897
|
"use strict";
|
|
46786
46898
|
init_config3();
|
|
46787
|
-
|
|
46899
|
+
import_node_child_process3 = require("child_process");
|
|
46788
46900
|
import_node_util = require("util");
|
|
46789
46901
|
init_getValidatedProcessCredentials();
|
|
46790
46902
|
resolveProcessCredentials = async (profileName, profiles, logger2) => {
|
|
@@ -46792,7 +46904,7 @@ var init_resolveProcessCredentials = __esm({
|
|
|
46792
46904
|
if (profiles[profileName]) {
|
|
46793
46905
|
const credentialProcess = profile["credential_process"];
|
|
46794
46906
|
if (credentialProcess !== void 0) {
|
|
46795
|
-
const execPromise = (0, import_node_util.promisify)(externalDataInterceptor?.getTokenRecord?.().exec ??
|
|
46907
|
+
const execPromise = (0, import_node_util.promisify)(externalDataInterceptor?.getTokenRecord?.().exec ?? import_node_child_process3.exec);
|
|
46796
46908
|
try {
|
|
46797
46909
|
const { stdout } = await execPromise(credentialProcess);
|
|
46798
46910
|
let data;
|
|
@@ -52251,11 +52363,11 @@ var init_table_policy = __esm({
|
|
|
52251
52363
|
});
|
|
52252
52364
|
|
|
52253
52365
|
// src/ai/llm-client.ts
|
|
52254
|
-
var
|
|
52366
|
+
var import_node_module3, DEFAULT_MODEL, CHEAPEST_MODEL;
|
|
52255
52367
|
var init_llm_client = __esm({
|
|
52256
52368
|
"src/ai/llm-client.ts"() {
|
|
52257
52369
|
"use strict";
|
|
52258
|
-
|
|
52370
|
+
import_node_module3 = require("module");
|
|
52259
52371
|
DEFAULT_MODEL = "claude-haiku-4-5";
|
|
52260
52372
|
CHEAPEST_MODEL = "claude-haiku-4-5";
|
|
52261
52373
|
}
|
|
@@ -52640,7 +52752,7 @@ function strippedBodyText(dom) {
|
|
|
52640
52752
|
function titleFromUrl(rawUrl) {
|
|
52641
52753
|
try {
|
|
52642
52754
|
const u2 = new URL(rawUrl);
|
|
52643
|
-
const last = (0,
|
|
52755
|
+
const last = (0, import_node_path27.basename)(u2.pathname);
|
|
52644
52756
|
return last && last !== "/" ? last : u2.hostname;
|
|
52645
52757
|
} catch {
|
|
52646
52758
|
return rawUrl;
|
|
@@ -52667,8 +52779,8 @@ async function sniffMime(body) {
|
|
|
52667
52779
|
async function renderViaPlaywright(url, timeoutMs, warnIfMissing = false) {
|
|
52668
52780
|
let chromium;
|
|
52669
52781
|
try {
|
|
52670
|
-
const importMetaUrl =
|
|
52671
|
-
const req = importMetaUrl ? (0,
|
|
52782
|
+
const importMetaUrl = import_meta3.url;
|
|
52783
|
+
const req = importMetaUrl ? (0, import_node_module4.createRequire)(importMetaUrl) : require;
|
|
52672
52784
|
const pw = req("playwright");
|
|
52673
52785
|
chromium = pw.chromium;
|
|
52674
52786
|
} catch {
|
|
@@ -52692,16 +52804,16 @@ async function renderViaPlaywright(url, timeoutMs, warnIfMissing = false) {
|
|
|
52692
52804
|
if (browser) await browser.close().catch(() => void 0);
|
|
52693
52805
|
}
|
|
52694
52806
|
}
|
|
52695
|
-
var import_jsdom, import_readability,
|
|
52807
|
+
var import_jsdom, import_readability, import_node_path27, import_node_module4, import_meta3, DEFAULT_MAX_BYTES2, DEFAULT_TIMEOUT_MS, DEFAULT_UA, DOMAIN_EXTRACTORS, warnedPlaywrightMissing;
|
|
52696
52808
|
var init_crawl = __esm({
|
|
52697
52809
|
"src/ai/crawl.ts"() {
|
|
52698
52810
|
"use strict";
|
|
52699
52811
|
import_jsdom = require("jsdom");
|
|
52700
52812
|
import_readability = require("@mozilla/readability");
|
|
52701
|
-
|
|
52702
|
-
|
|
52813
|
+
import_node_path27 = require("path");
|
|
52814
|
+
import_node_module4 = require("module");
|
|
52703
52815
|
init_url_safety();
|
|
52704
|
-
|
|
52816
|
+
import_meta3 = {};
|
|
52705
52817
|
DEFAULT_MAX_BYTES2 = 25 * 1024 * 1024;
|
|
52706
52818
|
DEFAULT_TIMEOUT_MS = 3e4;
|
|
52707
52819
|
DEFAULT_UA = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36";
|
|
@@ -53267,9 +53379,9 @@ function entityDescriptions(configPath, outputDir) {
|
|
|
53267
53379
|
return out;
|
|
53268
53380
|
}
|
|
53269
53381
|
function safeResolveInside(baseDir, requestedPath) {
|
|
53270
|
-
const resolvedBase = (0,
|
|
53271
|
-
const resolved = (0,
|
|
53272
|
-
if (resolved !== resolvedBase && !resolved.startsWith(resolvedBase +
|
|
53382
|
+
const resolvedBase = (0, import_node_path28.resolve)(baseDir);
|
|
53383
|
+
const resolved = (0, import_node_path28.resolve)(baseDir, requestedPath);
|
|
53384
|
+
if (resolved !== resolvedBase && !resolved.startsWith(resolvedBase + import_node_path28.sep)) {
|
|
53273
53385
|
throw new Error(`Path escapes output directory: ${requestedPath}`);
|
|
53274
53386
|
}
|
|
53275
53387
|
return resolved;
|
|
@@ -53281,7 +53393,7 @@ function fileSummary(outputDir, relPath) {
|
|
|
53281
53393
|
if (exists) {
|
|
53282
53394
|
bytes = (0, import_node_fs26.readFileSync)(absPath).byteLength;
|
|
53283
53395
|
}
|
|
53284
|
-
return { name: (0,
|
|
53396
|
+
return { name: (0, import_node_path28.basename)(relPath), path: relPath, exists, bytes };
|
|
53285
53397
|
}
|
|
53286
53398
|
function collectEntities(outputDir, manifest) {
|
|
53287
53399
|
if (!manifest) return [];
|
|
@@ -53332,9 +53444,9 @@ function loadGuiData(configPath, outputDir) {
|
|
|
53332
53444
|
tables,
|
|
53333
53445
|
entities,
|
|
53334
53446
|
project: {
|
|
53335
|
-
configPath: (0,
|
|
53336
|
-
outputDir: (0,
|
|
53337
|
-
dbName: (0,
|
|
53447
|
+
configPath: (0, import_node_path28.resolve)(configPath),
|
|
53448
|
+
outputDir: (0, import_node_path28.resolve)(outputDir),
|
|
53449
|
+
dbName: (0, import_node_path28.basename)(parsed.dbPath),
|
|
53338
53450
|
tableCount: tables.length,
|
|
53339
53451
|
entityContextCount: parsed.entityContexts.length,
|
|
53340
53452
|
manifestVersion: manifest?.version ?? null,
|
|
@@ -53499,10 +53611,10 @@ function buildGuiGraph(configPath, outputDir, options = {}) {
|
|
|
53499
53611
|
for (const href of markdownLinks(content)) {
|
|
53500
53612
|
let relTarget;
|
|
53501
53613
|
try {
|
|
53502
|
-
relTarget = (0,
|
|
53503
|
-
(0,
|
|
53504
|
-
safeResolveInside(outputDir, (0,
|
|
53505
|
-
).split(
|
|
53614
|
+
relTarget = (0, import_node_path28.relative)(
|
|
53615
|
+
(0, import_node_path28.resolve)(outputDir),
|
|
53616
|
+
safeResolveInside(outputDir, (0, import_node_path28.join)(fileDir, href))
|
|
53617
|
+
).split(import_node_path28.sep).join("/");
|
|
53506
53618
|
} catch {
|
|
53507
53619
|
continue;
|
|
53508
53620
|
}
|
|
@@ -53599,12 +53711,12 @@ function tableJunctions(table, configPath, outputDir) {
|
|
|
53599
53711
|
}
|
|
53600
53712
|
return out;
|
|
53601
53713
|
}
|
|
53602
|
-
var import_node_fs26,
|
|
53714
|
+
var import_node_fs26, import_node_path28, _parsedCache, JUNCTION_ALLOWED_NONFK;
|
|
53603
53715
|
var init_data = __esm({
|
|
53604
53716
|
"src/gui/data.ts"() {
|
|
53605
53717
|
"use strict";
|
|
53606
53718
|
import_node_fs26 = require("fs");
|
|
53607
|
-
|
|
53719
|
+
import_node_path28 = require("path");
|
|
53608
53720
|
init_parser();
|
|
53609
53721
|
init_manifest();
|
|
53610
53722
|
init_native_entities();
|
|
@@ -54613,17 +54725,17 @@ function findDocsDir() {
|
|
|
54613
54725
|
if (_docsDir !== void 0) return _docsDir;
|
|
54614
54726
|
let dir;
|
|
54615
54727
|
try {
|
|
54616
|
-
dir = (0,
|
|
54728
|
+
dir = (0, import_node_path29.dirname)((0, import_node_url2.fileURLToPath)(import_meta6.url));
|
|
54617
54729
|
} catch {
|
|
54618
54730
|
dir = process.cwd();
|
|
54619
54731
|
}
|
|
54620
54732
|
for (let i6 = 0; i6 < 8; i6++) {
|
|
54621
|
-
const candidate = (0,
|
|
54622
|
-
if ((0, import_node_fs27.existsSync)((0,
|
|
54733
|
+
const candidate = (0, import_node_path29.join)(dir, "docs");
|
|
54734
|
+
if ((0, import_node_fs27.existsSync)((0, import_node_path29.join)(candidate, "cloud.md"))) {
|
|
54623
54735
|
_docsDir = candidate;
|
|
54624
54736
|
return _docsDir;
|
|
54625
54737
|
}
|
|
54626
|
-
const parent = (0,
|
|
54738
|
+
const parent = (0, import_node_path29.dirname)(dir);
|
|
54627
54739
|
if (parent === dir) break;
|
|
54628
54740
|
dir = parent;
|
|
54629
54741
|
}
|
|
@@ -54666,7 +54778,7 @@ function allSections() {
|
|
|
54666
54778
|
}
|
|
54667
54779
|
for (const f6 of files) {
|
|
54668
54780
|
try {
|
|
54669
|
-
out.push(...sectionsOf(f6, (0, import_node_fs27.readFileSync)((0,
|
|
54781
|
+
out.push(...sectionsOf(f6, (0, import_node_fs27.readFileSync)((0, import_node_path29.join)(dir, f6), "utf8")));
|
|
54670
54782
|
} catch {
|
|
54671
54783
|
}
|
|
54672
54784
|
}
|
|
@@ -54708,14 +54820,14 @@ function searchLatticeDocs(query, limit = 4) {
|
|
|
54708
54820
|
}))
|
|
54709
54821
|
};
|
|
54710
54822
|
}
|
|
54711
|
-
var import_node_fs27,
|
|
54823
|
+
var import_node_fs27, import_node_path29, import_node_url2, import_meta6, _docsDir, MAX_SECTION_CHARS, _cache;
|
|
54712
54824
|
var init_lattice_docs = __esm({
|
|
54713
54825
|
"src/gui/ai/lattice-docs.ts"() {
|
|
54714
54826
|
"use strict";
|
|
54715
54827
|
import_node_fs27 = require("fs");
|
|
54716
|
-
|
|
54828
|
+
import_node_path29 = require("path");
|
|
54717
54829
|
import_node_url2 = require("url");
|
|
54718
|
-
|
|
54830
|
+
import_meta6 = {};
|
|
54719
54831
|
MAX_SECTION_CHARS = 2400;
|
|
54720
54832
|
_cache = /* @__PURE__ */ new Map();
|
|
54721
54833
|
}
|
|
@@ -54748,13 +54860,13 @@ function buildRowContextLocator(table, row, schemaDef, manifest) {
|
|
|
54748
54860
|
}
|
|
54749
54861
|
function readRowContext(outputDir, locator, secretCols) {
|
|
54750
54862
|
const { slug, directoryRoot, fileNames } = locator;
|
|
54751
|
-
const entityDir = (0,
|
|
54752
|
-
const resolvedBase = (0,
|
|
54753
|
-
if (entityDir !== resolvedBase && !entityDir.startsWith(resolvedBase +
|
|
54863
|
+
const entityDir = (0, import_node_path30.resolve)(outputDir, directoryRoot, slug);
|
|
54864
|
+
const resolvedBase = (0, import_node_path30.resolve)(outputDir);
|
|
54865
|
+
if (entityDir !== resolvedBase && !entityDir.startsWith(resolvedBase + import_node_path30.sep)) {
|
|
54754
54866
|
throw new Error(`Path traversal detected: slug "${slug}" escapes output directory`);
|
|
54755
54867
|
}
|
|
54756
54868
|
return fileNames.map((filename) => {
|
|
54757
|
-
const absPath = (0,
|
|
54869
|
+
const absPath = (0, import_node_path30.join)(entityDir, filename);
|
|
54758
54870
|
const relPath = [directoryRoot, slug, filename].join("/");
|
|
54759
54871
|
if (!(0, import_node_fs28.existsSync)(absPath)) return { name: filename, path: relPath, content: "" };
|
|
54760
54872
|
let content = (0, import_node_fs28.readFileSync)(absPath, "utf8");
|
|
@@ -54765,11 +54877,11 @@ function readRowContext(outputDir, locator, secretCols) {
|
|
|
54765
54877
|
return { name: filename, path: relPath, content };
|
|
54766
54878
|
});
|
|
54767
54879
|
}
|
|
54768
|
-
var
|
|
54880
|
+
var import_node_path30, import_node_fs28;
|
|
54769
54881
|
var init_row_context = __esm({
|
|
54770
54882
|
"src/gui/row-context.ts"() {
|
|
54771
54883
|
"use strict";
|
|
54772
|
-
|
|
54884
|
+
import_node_path30 = require("path");
|
|
54773
54885
|
import_node_fs28 = require("fs");
|
|
54774
54886
|
init_manifest();
|
|
54775
54887
|
}
|
|
@@ -55595,11 +55707,11 @@ function stripHtml(html) {
|
|
|
55595
55707
|
const text = decodeXmlEntities(stripTags(noScript));
|
|
55596
55708
|
return text.replace(/[ \t\f\r]+/g, " ").replace(/ *\n */g, "\n").replace(/\n{3,}/g, "\n\n").trim();
|
|
55597
55709
|
}
|
|
55598
|
-
async function unzip(
|
|
55710
|
+
async function unzip(path3) {
|
|
55599
55711
|
const fflate = await loadParser("fflate");
|
|
55600
55712
|
if (!fflate || typeof fflate.unzipSync !== "function") return null;
|
|
55601
55713
|
try {
|
|
55602
|
-
const buf = await (0, import_promises8.readFile)(
|
|
55714
|
+
const buf = await (0, import_promises8.readFile)(path3);
|
|
55603
55715
|
let total = 0;
|
|
55604
55716
|
return fflate.unzipSync(new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength), {
|
|
55605
55717
|
filter: (file) => {
|
|
@@ -55628,35 +55740,35 @@ var init_helpers2 = __esm({
|
|
|
55628
55740
|
});
|
|
55629
55741
|
|
|
55630
55742
|
// src/gui/ai/doc/ooxml.ts
|
|
55631
|
-
async function extractDocx(
|
|
55743
|
+
async function extractDocx(path3) {
|
|
55632
55744
|
const mod = await loadParser("mammoth");
|
|
55633
55745
|
const lib = mod?.default ?? mod;
|
|
55634
55746
|
if (!lib || typeof lib.extractRawText !== "function") return null;
|
|
55635
55747
|
try {
|
|
55636
|
-
const { value } = await lib.extractRawText({ path:
|
|
55748
|
+
const { value } = await lib.extractRawText({ path: path3 });
|
|
55637
55749
|
return nullIfEmpty(value);
|
|
55638
55750
|
} catch {
|
|
55639
55751
|
return null;
|
|
55640
55752
|
}
|
|
55641
55753
|
}
|
|
55642
|
-
async function extractDoc(
|
|
55754
|
+
async function extractDoc(path3) {
|
|
55643
55755
|
const mod = await loadParser(
|
|
55644
55756
|
"word-extractor"
|
|
55645
55757
|
);
|
|
55646
55758
|
const Ctor = mod && "default" in mod ? mod.default : mod;
|
|
55647
55759
|
if (typeof Ctor !== "function") return null;
|
|
55648
55760
|
try {
|
|
55649
|
-
const doc = await new Ctor().extract(
|
|
55761
|
+
const doc = await new Ctor().extract(path3);
|
|
55650
55762
|
return nullIfEmpty(doc.getBody());
|
|
55651
55763
|
} catch {
|
|
55652
55764
|
return null;
|
|
55653
55765
|
}
|
|
55654
55766
|
}
|
|
55655
|
-
async function extractPdf(
|
|
55767
|
+
async function extractPdf(path3) {
|
|
55656
55768
|
const unpdf = await loadParser("unpdf");
|
|
55657
55769
|
if (!unpdf || typeof unpdf.getDocumentProxy !== "function") return null;
|
|
55658
55770
|
try {
|
|
55659
|
-
const buf = await (0, import_promises9.readFile)(
|
|
55771
|
+
const buf = await (0, import_promises9.readFile)(path3);
|
|
55660
55772
|
const data = new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
55661
55773
|
const text = await withTimeout(
|
|
55662
55774
|
(async () => {
|
|
@@ -55688,8 +55800,8 @@ function slideText(xml) {
|
|
|
55688
55800
|
}
|
|
55689
55801
|
return paras.join("\n");
|
|
55690
55802
|
}
|
|
55691
|
-
async function extractPptx(
|
|
55692
|
-
const entries = await unzip(
|
|
55803
|
+
async function extractPptx(path3) {
|
|
55804
|
+
const entries = await unzip(path3);
|
|
55693
55805
|
if (!entries) return null;
|
|
55694
55806
|
const slides = Object.keys(entries).filter((n3) => /^ppt\/slides\/slide\d+\.xml$/.test(n3)).sort((a6, b6) => partNumber(a6) - partNumber(b6));
|
|
55695
55807
|
if (slides.length === 0) return null;
|
|
@@ -55707,8 +55819,8 @@ async function extractPptx(path2) {
|
|
|
55707
55819
|
}
|
|
55708
55820
|
return nullIfEmpty(parts.join("\n\n"));
|
|
55709
55821
|
}
|
|
55710
|
-
async function extractXlsx(
|
|
55711
|
-
const entries = await unzip(
|
|
55822
|
+
async function extractXlsx(path3) {
|
|
55823
|
+
const entries = await unzip(path3);
|
|
55712
55824
|
if (!entries) return null;
|
|
55713
55825
|
const shared = [];
|
|
55714
55826
|
const ssBytes = entries["xl/sharedStrings.xml"];
|
|
@@ -55768,8 +55880,8 @@ function odfWhitespace(s2) {
|
|
|
55768
55880
|
function odfParagraph(inner) {
|
|
55769
55881
|
return decodeXmlEntities(stripTags(odfWhitespace(inner))).trim();
|
|
55770
55882
|
}
|
|
55771
|
-
async function extractOdfText(
|
|
55772
|
-
const entries = await unzip(
|
|
55883
|
+
async function extractOdfText(path3) {
|
|
55884
|
+
const entries = await unzip(path3);
|
|
55773
55885
|
if (!entries) return null;
|
|
55774
55886
|
const contentBytes = entries["content.xml"];
|
|
55775
55887
|
if (!contentBytes) return null;
|
|
@@ -55791,8 +55903,8 @@ async function extractOdfText(path2) {
|
|
|
55791
55903
|
}
|
|
55792
55904
|
return nullIfEmpty(lines.join("\n"));
|
|
55793
55905
|
}
|
|
55794
|
-
async function extractOds(
|
|
55795
|
-
const entries = await unzip(
|
|
55906
|
+
async function extractOds(path3) {
|
|
55907
|
+
const entries = await unzip(path3);
|
|
55796
55908
|
if (!entries) return null;
|
|
55797
55909
|
const contentBytes = entries["content.xml"];
|
|
55798
55910
|
if (!contentBytes) return null;
|
|
@@ -55850,8 +55962,8 @@ function resolveHref(baseDir, href) {
|
|
|
55850
55962
|
}
|
|
55851
55963
|
return normalizeZipPath(baseDir + h6);
|
|
55852
55964
|
}
|
|
55853
|
-
async function extractEpub(
|
|
55854
|
-
const entries = await unzip(
|
|
55965
|
+
async function extractEpub(path3) {
|
|
55966
|
+
const entries = await unzip(path3);
|
|
55855
55967
|
if (!entries) return null;
|
|
55856
55968
|
let order = [];
|
|
55857
55969
|
const container = entries["META-INF/container.xml"];
|
|
@@ -55935,9 +56047,9 @@ function rtfToText(rtf) {
|
|
|
55935
56047
|
s2 = s2.replace(/[{}]/g, "");
|
|
55936
56048
|
return s2.replace(/[ \t]+/g, (m4) => m4.includes(" ") ? " " : " ").replace(/[ \t]\n/g, "\n").replace(/\n{3,}/g, "\n\n").trim();
|
|
55937
56049
|
}
|
|
55938
|
-
async function extractRtf(
|
|
56050
|
+
async function extractRtf(path3) {
|
|
55939
56051
|
try {
|
|
55940
|
-
const raw = await (0, import_promises10.readFile)(
|
|
56052
|
+
const raw = await (0, import_promises10.readFile)(path3, "latin1");
|
|
55941
56053
|
if (!raw.startsWith("{\\rtf")) return null;
|
|
55942
56054
|
return nullIfEmpty(rtfToText(raw));
|
|
55943
56055
|
} catch {
|
|
@@ -55984,27 +56096,27 @@ var init_other = __esm({
|
|
|
55984
56096
|
});
|
|
55985
56097
|
|
|
55986
56098
|
// src/gui/ai/doc-extractors.ts
|
|
55987
|
-
async function extractDocument(
|
|
56099
|
+
async function extractDocument(path3, ext) {
|
|
55988
56100
|
switch (ext) {
|
|
55989
56101
|
case ".docx":
|
|
55990
|
-
return extractDocx(
|
|
56102
|
+
return extractDocx(path3);
|
|
55991
56103
|
case ".doc":
|
|
55992
|
-
return extractDoc(
|
|
56104
|
+
return extractDoc(path3);
|
|
55993
56105
|
case ".pdf":
|
|
55994
|
-
return extractPdf(
|
|
56106
|
+
return extractPdf(path3);
|
|
55995
56107
|
case ".pptx":
|
|
55996
|
-
return extractPptx(
|
|
56108
|
+
return extractPptx(path3);
|
|
55997
56109
|
case ".xlsx":
|
|
55998
|
-
return extractXlsx(
|
|
56110
|
+
return extractXlsx(path3);
|
|
55999
56111
|
case ".odt":
|
|
56000
56112
|
case ".odp":
|
|
56001
|
-
return extractOdfText(
|
|
56113
|
+
return extractOdfText(path3);
|
|
56002
56114
|
case ".ods":
|
|
56003
|
-
return extractOds(
|
|
56115
|
+
return extractOds(path3);
|
|
56004
56116
|
case ".epub":
|
|
56005
|
-
return extractEpub(
|
|
56117
|
+
return extractEpub(path3);
|
|
56006
56118
|
case ".rtf":
|
|
56007
|
-
return extractRtf(
|
|
56119
|
+
return extractRtf(path3);
|
|
56008
56120
|
default:
|
|
56009
56121
|
return null;
|
|
56010
56122
|
}
|
|
@@ -56020,22 +56132,22 @@ var init_doc_extractors = __esm({
|
|
|
56020
56132
|
|
|
56021
56133
|
// src/gui/ai/extract.ts
|
|
56022
56134
|
function languageOf(name) {
|
|
56023
|
-
return CODE_LANGS[(0,
|
|
56135
|
+
return CODE_LANGS[(0, import_node_path31.extname)(name).toLowerCase()] ?? null;
|
|
56024
56136
|
}
|
|
56025
56137
|
function truncate2(s2) {
|
|
56026
56138
|
return s2.length > MAX_TEXT2 ? s2.slice(0, MAX_TEXT2) : s2;
|
|
56027
56139
|
}
|
|
56028
|
-
async function parseFile(
|
|
56029
|
-
const name = originalName ?? (0,
|
|
56030
|
-
const ext = (0,
|
|
56140
|
+
async function parseFile(path3, mimeHint, originalName) {
|
|
56141
|
+
const name = originalName ?? (0, import_node_path31.basename)(path3);
|
|
56142
|
+
const ext = (0, import_node_path31.extname)(name).toLowerCase();
|
|
56031
56143
|
const lang = languageOf(name);
|
|
56032
56144
|
if (lang) {
|
|
56033
|
-
return { text: truncate2(await (0, import_promises11.readFile)(
|
|
56145
|
+
return { text: truncate2(await (0, import_promises11.readFile)(path3, "utf8")), language: lang };
|
|
56034
56146
|
}
|
|
56035
56147
|
if (mimeHint && TEXT_MIME.test(mimeHint) || TEXT_EXT.has(ext)) {
|
|
56036
|
-
return { text: truncate2(await (0, import_promises11.readFile)(
|
|
56148
|
+
return { text: truncate2(await (0, import_promises11.readFile)(path3, "utf8")) };
|
|
56037
56149
|
}
|
|
56038
|
-
const doc = await extractDocument(
|
|
56150
|
+
const doc = await extractDocument(path3, ext);
|
|
56039
56151
|
if (doc != null) {
|
|
56040
56152
|
return { text: truncate2(doc) };
|
|
56041
56153
|
}
|
|
@@ -56048,12 +56160,12 @@ function describe(text, mime, name) {
|
|
|
56048
56160
|
}
|
|
56049
56161
|
return `Binary file: ${name}${mime ? ` (${mime})` : ""}`;
|
|
56050
56162
|
}
|
|
56051
|
-
var import_promises11,
|
|
56163
|
+
var import_promises11, import_node_path31, MAX_TEXT2, CODE_LANGS, TEXT_EXT, TEXT_MIME;
|
|
56052
56164
|
var init_extract = __esm({
|
|
56053
56165
|
"src/gui/ai/extract.ts"() {
|
|
56054
56166
|
"use strict";
|
|
56055
56167
|
import_promises11 = require("fs/promises");
|
|
56056
|
-
|
|
56168
|
+
import_node_path31 = require("path");
|
|
56057
56169
|
init_doc_extractors();
|
|
56058
56170
|
MAX_TEXT2 = 2e5;
|
|
56059
56171
|
CODE_LANGS = {
|
|
@@ -56625,8 +56737,8 @@ function isWriteConflict(e6) {
|
|
|
56625
56737
|
function normalizeUrl(s2) {
|
|
56626
56738
|
try {
|
|
56627
56739
|
const u2 = new URL(s2.trim());
|
|
56628
|
-
const
|
|
56629
|
-
return `${u2.protocol}//${u2.host.toLowerCase()}${
|
|
56740
|
+
const path3 = u2.pathname.replace(/\/+$/, "");
|
|
56741
|
+
return `${u2.protocol}//${u2.host.toLowerCase()}${path3}${u2.search}`;
|
|
56630
56742
|
} catch {
|
|
56631
56743
|
return null;
|
|
56632
56744
|
}
|
|
@@ -57582,8 +57694,8 @@ async function* runChat(opts) {
|
|
|
57582
57694
|
}
|
|
57583
57695
|
function loadSdk() {
|
|
57584
57696
|
if (!_sdk) {
|
|
57585
|
-
const importMetaUrl =
|
|
57586
|
-
const req = importMetaUrl ? (0,
|
|
57697
|
+
const importMetaUrl = import_meta7.url;
|
|
57698
|
+
const req = importMetaUrl ? (0, import_node_module7.createRequire)(importMetaUrl) : require;
|
|
57587
57699
|
try {
|
|
57588
57700
|
_sdk = req("@anthropic-ai/sdk");
|
|
57589
57701
|
} catch (err) {
|
|
@@ -57640,15 +57752,15 @@ function createAnthropicClient(auth) {
|
|
|
57640
57752
|
}
|
|
57641
57753
|
};
|
|
57642
57754
|
}
|
|
57643
|
-
var
|
|
57755
|
+
var import_node_module7, import_meta7, DEFAULT_MODEL2, MAX_TOOL_LOOPS, MAX_CONSECUTIVE_TOOL_FAILURES, MAX_TOKENS, MAX_TOOL_RESULT_CHARS, MAX_TOOL_RESULT_SKIP, MAX_TOOL_INPUT_CHARS, LIVE_TOOL_RESULT_CHARS, MAX_CONTEXT_RECOVERY_TRIMS, TRIMMED_PLACEHOLDER, BASE_SYSTEM_PROMPT, LOCAL_GUI_RECORD_RE, _sdk;
|
|
57644
57756
|
var init_chat = __esm({
|
|
57645
57757
|
"src/gui/ai/chat.ts"() {
|
|
57646
57758
|
"use strict";
|
|
57647
|
-
|
|
57759
|
+
import_node_module7 = require("module");
|
|
57648
57760
|
init_dispatch();
|
|
57649
57761
|
init_tools();
|
|
57650
57762
|
init_column_descriptions();
|
|
57651
|
-
|
|
57763
|
+
import_meta7 = {};
|
|
57652
57764
|
DEFAULT_MODEL2 = "claude-haiku-4-5";
|
|
57653
57765
|
MAX_TOOL_LOOPS = 16;
|
|
57654
57766
|
MAX_CONSECUTIVE_TOOL_FAILURES = 3;
|
|
@@ -58383,13 +58495,13 @@ function applyWriteEntry(db, entry) {
|
|
|
58383
58495
|
init_constants();
|
|
58384
58496
|
|
|
58385
58497
|
// src/auto-update.ts
|
|
58386
|
-
var
|
|
58498
|
+
var import_node_child_process2 = require("child_process");
|
|
58387
58499
|
var import_node_fs13 = require("fs");
|
|
58388
|
-
var
|
|
58500
|
+
var import_node_path14 = require("path");
|
|
58389
58501
|
init_user_config();
|
|
58390
58502
|
function getInstalledVersion(pkgName) {
|
|
58391
58503
|
try {
|
|
58392
|
-
const pkgPath = (0,
|
|
58504
|
+
const pkgPath = (0, import_node_path14.join)(process.cwd(), "node_modules", pkgName, "package.json");
|
|
58393
58505
|
const pkg = JSON.parse((0, import_node_fs13.readFileSync)(pkgPath, "utf-8"));
|
|
58394
58506
|
return pkg.version;
|
|
58395
58507
|
} catch {
|
|
@@ -58433,7 +58545,7 @@ async function autoUpdate(opts) {
|
|
|
58433
58545
|
}
|
|
58434
58546
|
log(`[latticesql] Updating: latticesql@${installed} \u2192 ${latest}`);
|
|
58435
58547
|
try {
|
|
58436
|
-
(0,
|
|
58548
|
+
(0, import_node_child_process2.execFileSync)("npm", ["install", `latticesql@${latest}`], {
|
|
58437
58549
|
cwd: process.cwd(),
|
|
58438
58550
|
stdio: opts?.quiet ? "ignore" : "inherit",
|
|
58439
58551
|
timeout: 6e4,
|
|
@@ -58690,7 +58802,7 @@ init_native_entities();
|
|
|
58690
58802
|
// src/framework/blob-store.ts
|
|
58691
58803
|
var import_node_crypto8 = require("crypto");
|
|
58692
58804
|
var import_node_fs14 = require("fs");
|
|
58693
|
-
var
|
|
58805
|
+
var import_node_path15 = require("path");
|
|
58694
58806
|
async function hashFile(srcPath) {
|
|
58695
58807
|
return new Promise((resolve17, reject) => {
|
|
58696
58808
|
const hash = (0, import_node_crypto8.createHash)("sha256");
|
|
@@ -58708,9 +58820,9 @@ async function attachBlob(srcPath, latticeRoot) {
|
|
|
58708
58820
|
throw new Error(`attachBlob: ${srcPath} is not a regular file`);
|
|
58709
58821
|
}
|
|
58710
58822
|
const sha256 = await hashFile(srcPath);
|
|
58711
|
-
const blobDir = (0,
|
|
58823
|
+
const blobDir = (0, import_node_path15.join)(latticeRoot, "data", "blobs");
|
|
58712
58824
|
(0, import_node_fs14.mkdirSync)(blobDir, { recursive: true });
|
|
58713
|
-
const destAbs = (0,
|
|
58825
|
+
const destAbs = (0, import_node_path15.join)(blobDir, sha256);
|
|
58714
58826
|
if (!(0, import_node_fs14.existsSync)(destAbs)) {
|
|
58715
58827
|
(0, import_node_fs14.copyFileSync)(srcPath, destAbs);
|
|
58716
58828
|
}
|
|
@@ -58720,7 +58832,7 @@ async function attachBlob(srcPath, latticeRoot) {
|
|
|
58720
58832
|
// across machines (path.join would emit backslashes on Windows).
|
|
58721
58833
|
blob_path: `data/blobs/${sha256}`,
|
|
58722
58834
|
size_bytes: stats.size,
|
|
58723
|
-
original_name: (0,
|
|
58835
|
+
original_name: (0, import_node_path15.basename)(srcPath)
|
|
58724
58836
|
};
|
|
58725
58837
|
}
|
|
58726
58838
|
|
|
@@ -58878,7 +58990,7 @@ init_canonical_context();
|
|
|
58878
58990
|
// src/framework/migrate-to-root.ts
|
|
58879
58991
|
var import_node_fs20 = require("fs");
|
|
58880
58992
|
var import_node_os7 = require("os");
|
|
58881
|
-
var
|
|
58993
|
+
var import_node_path24 = require("path");
|
|
58882
58994
|
init_lattice_root();
|
|
58883
58995
|
var LEGACY_ENTRIES = [
|
|
58884
58996
|
"master.key",
|
|
@@ -58888,16 +59000,16 @@ var LEGACY_ENTRIES = [
|
|
|
58888
59000
|
"keys"
|
|
58889
59001
|
];
|
|
58890
59002
|
function importLegacyUserConfig(root6) {
|
|
58891
|
-
const legacy = process.env.LATTICE_CONFIG_DIR ?? (0,
|
|
59003
|
+
const legacy = process.env.LATTICE_CONFIG_DIR ?? (0, import_node_path24.join)((0, import_node_os7.homedir)(), ".lattice");
|
|
58892
59004
|
const dest = rootConfigDir(root6);
|
|
58893
59005
|
const copied = [];
|
|
58894
|
-
if (!(0, import_node_fs20.existsSync)((0,
|
|
58895
|
-
if ((0, import_node_fs20.existsSync)((0,
|
|
59006
|
+
if (!(0, import_node_fs20.existsSync)((0, import_node_path24.join)(legacy, "master.key"))) return { migrated: false, copied };
|
|
59007
|
+
if ((0, import_node_fs20.existsSync)((0, import_node_path24.join)(dest, "master.key"))) return { migrated: false, copied };
|
|
58896
59008
|
(0, import_node_fs20.mkdirSync)(dest, { recursive: true });
|
|
58897
59009
|
for (const entry of LEGACY_ENTRIES) {
|
|
58898
|
-
const src = (0,
|
|
59010
|
+
const src = (0, import_node_path24.join)(legacy, entry);
|
|
58899
59011
|
if ((0, import_node_fs20.existsSync)(src)) {
|
|
58900
|
-
(0, import_node_fs20.cpSync)(src, (0,
|
|
59012
|
+
(0, import_node_fs20.cpSync)(src, (0, import_node_path24.join)(dest, entry), { recursive: true });
|
|
58901
59013
|
copied.push(entry);
|
|
58902
59014
|
}
|
|
58903
59015
|
}
|
|
@@ -58906,7 +59018,7 @@ function importLegacyUserConfig(root6) {
|
|
|
58906
59018
|
|
|
58907
59019
|
// src/sources/resolver.ts
|
|
58908
59020
|
var import_promises6 = require("fs/promises");
|
|
58909
|
-
var
|
|
59021
|
+
var import_node_path25 = require("path");
|
|
58910
59022
|
init_url_safety();
|
|
58911
59023
|
|
|
58912
59024
|
// src/sources/types.ts
|
|
@@ -58935,7 +59047,7 @@ function refKindOf(row) {
|
|
|
58935
59047
|
}
|
|
58936
59048
|
function blobHandle(row, latticeRoot) {
|
|
58937
59049
|
const rel = row.blob_path ?? null;
|
|
58938
|
-
const abs = rel ? (0,
|
|
59050
|
+
const abs = rel ? (0, import_node_path25.join)(latticeRoot, rel) : null;
|
|
58939
59051
|
const location = rel ? `blob:${rel}` : "blob:?";
|
|
58940
59052
|
return {
|
|
58941
59053
|
kind: "blob",
|
|
@@ -58956,20 +59068,20 @@ function blobHandle(row, latticeRoot) {
|
|
|
58956
59068
|
};
|
|
58957
59069
|
}
|
|
58958
59070
|
function fsHandle(row) {
|
|
58959
|
-
const
|
|
59071
|
+
const path3 = row.ref_uri ?? "";
|
|
58960
59072
|
return {
|
|
58961
59073
|
kind: "local_ref",
|
|
58962
59074
|
provider: "fs",
|
|
58963
|
-
location:
|
|
59075
|
+
location: path3,
|
|
58964
59076
|
async readContent() {
|
|
58965
59077
|
try {
|
|
58966
|
-
return await (0, import_promises6.readFile)(
|
|
59078
|
+
return await (0, import_promises6.readFile)(path3);
|
|
58967
59079
|
} catch (e6) {
|
|
58968
|
-
throw new ReferenceUnavailableError(
|
|
59080
|
+
throw new ReferenceUnavailableError(path3, e6.message);
|
|
58969
59081
|
}
|
|
58970
59082
|
},
|
|
58971
59083
|
async getMetadata() {
|
|
58972
|
-
return statMeta(
|
|
59084
|
+
return statMeta(path3, row);
|
|
58973
59085
|
}
|
|
58974
59086
|
};
|
|
58975
59087
|
}
|
|
@@ -59038,9 +59150,9 @@ function meta(available, parts = {}) {
|
|
|
59038
59150
|
if (parts.extra != null) m4.extra = parts.extra;
|
|
59039
59151
|
return m4;
|
|
59040
59152
|
}
|
|
59041
|
-
async function statMeta(
|
|
59153
|
+
async function statMeta(path3, row) {
|
|
59042
59154
|
try {
|
|
59043
|
-
const s2 = await (0, import_promises6.stat)(
|
|
59155
|
+
const s2 = await (0, import_promises6.stat)(path3);
|
|
59044
59156
|
return meta(true, {
|
|
59045
59157
|
size_bytes: s2.size,
|
|
59046
59158
|
modified_at: s2.mtime.toISOString(),
|
|
@@ -59068,15 +59180,15 @@ init_benchmark();
|
|
|
59068
59180
|
|
|
59069
59181
|
// src/framework/reference-store.ts
|
|
59070
59182
|
var import_node_fs21 = require("fs");
|
|
59071
|
-
var
|
|
59183
|
+
var import_node_path26 = require("path");
|
|
59072
59184
|
init_url_safety();
|
|
59073
59185
|
function referenceLocalFile(srcPath) {
|
|
59074
|
-
const abs = (0,
|
|
59186
|
+
const abs = (0, import_node_path26.resolve)(srcPath);
|
|
59075
59187
|
const meta2 = {
|
|
59076
59188
|
ref_kind: "local_ref",
|
|
59077
59189
|
ref_uri: abs,
|
|
59078
59190
|
ref_provider: "fs",
|
|
59079
|
-
original_name: (0,
|
|
59191
|
+
original_name: (0, import_node_path26.basename)(abs),
|
|
59080
59192
|
extraction_status: "pending",
|
|
59081
59193
|
source_json: JSON.stringify({ last_seen_at: (/* @__PURE__ */ new Date()).toISOString() })
|
|
59082
59194
|
};
|
|
@@ -59774,14 +59886,14 @@ function isBetter(next, prev) {
|
|
|
59774
59886
|
}
|
|
59775
59887
|
|
|
59776
59888
|
// src/ai/vision.ts
|
|
59777
|
-
var
|
|
59889
|
+
var import_node_module5 = require("module");
|
|
59778
59890
|
var import_promises7 = require("fs/promises");
|
|
59779
59891
|
init_llm_client();
|
|
59780
|
-
var
|
|
59892
|
+
var import_meta4 = {};
|
|
59781
59893
|
var DEFAULT_PROMPT = "Describe this image for a knowledge base in 2-4 factual sentences: what it shows, any visible text, and notable details. No preamble.";
|
|
59782
59894
|
var MAX_DIM = 1568;
|
|
59783
|
-
async function describeImage(auth,
|
|
59784
|
-
const data = (await normalizeImage(
|
|
59895
|
+
async function describeImage(auth, path3, opts = {}) {
|
|
59896
|
+
const data = (await normalizeImage(path3, opts.maxBytes ?? 14e5)).toString("base64");
|
|
59785
59897
|
const sender = opts.sender ?? defaultSender(auth);
|
|
59786
59898
|
const text = await sender({
|
|
59787
59899
|
media_type: "image/jpeg",
|
|
@@ -59792,8 +59904,8 @@ async function describeImage(auth, path2, opts = {}) {
|
|
|
59792
59904
|
return text.trim();
|
|
59793
59905
|
}
|
|
59794
59906
|
var DEFAULT_PDF_PROMPT = "Read this document for a knowledge base. First transcribe its readable text, then add a 2-4 sentence factual summary of what it is and its key details. It may be a scanned/image-only PDF \u2014 read the text from the page images. No preamble.";
|
|
59795
|
-
async function describePdf(auth,
|
|
59796
|
-
const buf = await (0, import_promises7.readFile)(
|
|
59907
|
+
async function describePdf(auth, path3, opts = {}) {
|
|
59908
|
+
const buf = await (0, import_promises7.readFile)(path3);
|
|
59797
59909
|
const maxBytes = opts.maxBytes ?? 3e7;
|
|
59798
59910
|
if (buf.length > maxBytes) {
|
|
59799
59911
|
throw new Error(
|
|
@@ -59808,19 +59920,19 @@ async function describePdf(auth, path2, opts = {}) {
|
|
|
59808
59920
|
});
|
|
59809
59921
|
return text.trim();
|
|
59810
59922
|
}
|
|
59811
|
-
async function normalizeImage(
|
|
59923
|
+
async function normalizeImage(path3, maxBytes) {
|
|
59812
59924
|
const sharpMod = await import("sharp");
|
|
59813
59925
|
const sharp = sharpMod.default;
|
|
59814
59926
|
let quality = 80;
|
|
59815
|
-
let buf = await renderJpeg(sharp,
|
|
59927
|
+
let buf = await renderJpeg(sharp, path3, quality);
|
|
59816
59928
|
while (buf.length > maxBytes && quality > 35) {
|
|
59817
59929
|
quality -= 15;
|
|
59818
|
-
buf = await renderJpeg(sharp,
|
|
59930
|
+
buf = await renderJpeg(sharp, path3, quality);
|
|
59819
59931
|
}
|
|
59820
59932
|
return buf;
|
|
59821
59933
|
}
|
|
59822
|
-
function renderJpeg(sharp,
|
|
59823
|
-
return sharp(
|
|
59934
|
+
function renderJpeg(sharp, path3, quality) {
|
|
59935
|
+
return sharp(path3).rotate().resize({ width: MAX_DIM, height: MAX_DIM, fit: "inside", withoutEnlargement: true }).jpeg({ quality }).toBuffer();
|
|
59824
59936
|
}
|
|
59825
59937
|
function buildVisionAnthropicConfig(auth) {
|
|
59826
59938
|
const config = {};
|
|
@@ -59837,8 +59949,8 @@ function buildVisionAnthropicConfig(auth) {
|
|
|
59837
59949
|
}
|
|
59838
59950
|
function defaultSender(auth) {
|
|
59839
59951
|
return async (input) => {
|
|
59840
|
-
const importMetaUrl =
|
|
59841
|
-
const req = importMetaUrl ? (0,
|
|
59952
|
+
const importMetaUrl = import_meta4.url;
|
|
59953
|
+
const req = importMetaUrl ? (0, import_node_module5.createRequire)(importMetaUrl) : require;
|
|
59842
59954
|
const sdk = req("@anthropic-ai/sdk");
|
|
59843
59955
|
const Anthropic = sdk.Anthropic ?? sdk.default;
|
|
59844
59956
|
if (!Anthropic) throw new Error("Could not resolve Anthropic from '@anthropic-ai/sdk'");
|
|
@@ -59864,8 +59976,8 @@ function defaultSender(auth) {
|
|
|
59864
59976
|
}
|
|
59865
59977
|
function defaultPdfSender(auth) {
|
|
59866
59978
|
return async (input) => {
|
|
59867
|
-
const importMetaUrl =
|
|
59868
|
-
const req = importMetaUrl ? (0,
|
|
59979
|
+
const importMetaUrl = import_meta4.url;
|
|
59980
|
+
const req = importMetaUrl ? (0, import_node_module5.createRequire)(importMetaUrl) : require;
|
|
59869
59981
|
const sdk = req("@anthropic-ai/sdk");
|
|
59870
59982
|
const Anthropic = sdk.Anthropic ?? sdk.default;
|
|
59871
59983
|
if (!Anthropic) throw new Error("Could not resolve Anthropic from '@anthropic-ai/sdk'");
|
|
@@ -59895,9 +60007,9 @@ init_summarize();
|
|
|
59895
60007
|
|
|
59896
60008
|
// src/gui/server.ts
|
|
59897
60009
|
var import_node_http3 = require("http");
|
|
59898
|
-
var
|
|
60010
|
+
var import_node_child_process6 = require("child_process");
|
|
59899
60011
|
var import_ws = require("ws");
|
|
59900
|
-
var
|
|
60012
|
+
var import_node_path48 = require("path");
|
|
59901
60013
|
init_http2();
|
|
59902
60014
|
|
|
59903
60015
|
// src/gui/active-db.ts
|
|
@@ -59950,7 +60062,7 @@ async function attachRowAccess(db, table, rows) {
|
|
|
59950
60062
|
}
|
|
59951
60063
|
|
|
59952
60064
|
// src/gui/lifecycle.ts
|
|
59953
|
-
var
|
|
60065
|
+
var import_node_path32 = require("path");
|
|
59954
60066
|
var import_node_fs29 = require("fs");
|
|
59955
60067
|
init_lattice();
|
|
59956
60068
|
init_parser();
|
|
@@ -60176,13 +60288,13 @@ init_postgres();
|
|
|
60176
60288
|
|
|
60177
60289
|
// src/gui/realtime.ts
|
|
60178
60290
|
var import_node_events = require("events");
|
|
60179
|
-
var
|
|
60180
|
-
var
|
|
60291
|
+
var import_node_module6 = require("module");
|
|
60292
|
+
var import_meta5 = {};
|
|
60181
60293
|
var _pgModule = null;
|
|
60182
60294
|
function loadPg() {
|
|
60183
60295
|
if (_pgModule) return _pgModule;
|
|
60184
|
-
const importMetaUrl =
|
|
60185
|
-
const requireFromHere = importMetaUrl ? (0,
|
|
60296
|
+
const importMetaUrl = import_meta5.url;
|
|
60297
|
+
const requireFromHere = importMetaUrl ? (0, import_node_module6.createRequire)(importMetaUrl) : (
|
|
60186
60298
|
// CJS fallback — Node provides `require` on every CJS module scope.
|
|
60187
60299
|
require
|
|
60188
60300
|
);
|
|
@@ -61067,7 +61179,7 @@ async function openConfig(configPath, outputDir, autoRender = false, realtimeWat
|
|
|
61067
61179
|
}
|
|
61068
61180
|
const parsed = parseConfigFile(configPath);
|
|
61069
61181
|
if (!/^postgres(ql)?:\/\//i.test(parsed.dbPath) && !parsed.dbPath.startsWith("file:") && parsed.dbPath !== ":memory:") {
|
|
61070
|
-
(0, import_node_fs29.mkdirSync)((0,
|
|
61182
|
+
(0, import_node_fs29.mkdirSync)((0, import_node_path32.dirname)(parsed.dbPath), { recursive: true });
|
|
61071
61183
|
}
|
|
61072
61184
|
const encryptionKey = getOrCreateMasterKey();
|
|
61073
61185
|
if (/^postgres(ql)?:\/\//i.test(parsed.dbPath)) {
|
|
@@ -61556,7 +61668,7 @@ async function applySchemaConfig(active, entry, direction, autoRender) {
|
|
|
61556
61668
|
const doc = loadConfigDoc(active.configPath);
|
|
61557
61669
|
const inv = direction === "inverse";
|
|
61558
61670
|
const ddl = [];
|
|
61559
|
-
const has = (
|
|
61671
|
+
const has = (path3) => doc.getIn(path3) !== void 0;
|
|
61560
61672
|
const reAddEntity = async (name, def) => {
|
|
61561
61673
|
if (has(["entities", name])) {
|
|
61562
61674
|
throw new Error(`Cannot restore "${name}": an entity with that name already exists`);
|
|
@@ -71485,7 +71597,7 @@ var guiAppHtml = `<!doctype html>
|
|
|
71485
71597
|
|
|
71486
71598
|
// src/update-check.ts
|
|
71487
71599
|
var import_node_fs30 = require("fs");
|
|
71488
|
-
var
|
|
71600
|
+
var import_node_path33 = require("path");
|
|
71489
71601
|
var import_node_os8 = require("os");
|
|
71490
71602
|
var ONE_DAY_MS = 864e5;
|
|
71491
71603
|
function isNewer2(latest, current) {
|
|
@@ -71501,8 +71613,8 @@ function isNewer2(latest, current) {
|
|
|
71501
71613
|
}
|
|
71502
71614
|
async function checkForUpdate(pkgName, currentVersion, opts = {}) {
|
|
71503
71615
|
const ttlMs = opts.ttlMs ?? ONE_DAY_MS;
|
|
71504
|
-
const cacheDir = (0,
|
|
71505
|
-
const cachePath = (0,
|
|
71616
|
+
const cacheDir = (0, import_node_path33.join)((0, import_node_os8.homedir)(), ".lattice");
|
|
71617
|
+
const cachePath = (0, import_node_path33.join)(cacheDir, `update-check-${pkgName}.json`);
|
|
71506
71618
|
try {
|
|
71507
71619
|
if (!opts.force && (0, import_node_fs30.existsSync)(cachePath)) {
|
|
71508
71620
|
const cached = JSON.parse((0, import_node_fs30.readFileSync)(cachePath, "utf-8"));
|
|
@@ -71528,9 +71640,9 @@ async function checkForUpdate(pkgName, currentVersion, opts = {}) {
|
|
|
71528
71640
|
}
|
|
71529
71641
|
|
|
71530
71642
|
// src/update-context.ts
|
|
71531
|
-
var
|
|
71643
|
+
var import_node_child_process4 = require("child_process");
|
|
71532
71644
|
var import_node_fs31 = require("fs");
|
|
71533
|
-
var
|
|
71645
|
+
var import_node_path34 = require("path");
|
|
71534
71646
|
init_user_config();
|
|
71535
71647
|
var SEMVER_RE = /^\d+\.\d+\.\d+(-[\w.]+)?$/;
|
|
71536
71648
|
function isValidVersion(v2) {
|
|
@@ -71539,7 +71651,7 @@ function isValidVersion(v2) {
|
|
|
71539
71651
|
function findPackageRoot(start, pkgName) {
|
|
71540
71652
|
let dir = start;
|
|
71541
71653
|
for (let depth = 0; depth < 12; depth++) {
|
|
71542
|
-
const pkgJson = (0,
|
|
71654
|
+
const pkgJson = (0, import_node_path34.join)(dir, "package.json");
|
|
71543
71655
|
if ((0, import_node_fs31.existsSync)(pkgJson)) {
|
|
71544
71656
|
try {
|
|
71545
71657
|
const { name } = JSON.parse((0, import_node_fs31.readFileSync)(pkgJson, "utf-8"));
|
|
@@ -71547,16 +71659,16 @@ function findPackageRoot(start, pkgName) {
|
|
|
71547
71659
|
} catch {
|
|
71548
71660
|
}
|
|
71549
71661
|
}
|
|
71550
|
-
const parent = (0,
|
|
71662
|
+
const parent = (0, import_node_path34.dirname)(dir);
|
|
71551
71663
|
if (parent === dir) break;
|
|
71552
71664
|
dir = parent;
|
|
71553
71665
|
}
|
|
71554
71666
|
return null;
|
|
71555
71667
|
}
|
|
71556
71668
|
function isUnderGlobalPrefix(packageRoot, execPath) {
|
|
71557
|
-
if (packageRoot.includes(`${
|
|
71558
|
-
const prefix = (0,
|
|
71559
|
-
return packageRoot.startsWith(prefix +
|
|
71669
|
+
if (packageRoot.includes(`${import_node_path34.sep}lib${import_node_path34.sep}node_modules${import_node_path34.sep}`)) return true;
|
|
71670
|
+
const prefix = (0, import_node_path34.dirname)((0, import_node_path34.dirname)(execPath));
|
|
71671
|
+
return packageRoot.startsWith(prefix + import_node_path34.sep) && packageRoot.includes(`node_modules${import_node_path34.sep}`);
|
|
71560
71672
|
}
|
|
71561
71673
|
function detectInstallContext(opts = {}) {
|
|
71562
71674
|
const pkgName = opts.pkgName ?? "latticesql";
|
|
@@ -71573,8 +71685,8 @@ function detectInstallContext(opts = {}) {
|
|
|
71573
71685
|
};
|
|
71574
71686
|
const modulePath = resolveReal(rawModulePath);
|
|
71575
71687
|
const cwd = resolveReal(rawCwd);
|
|
71576
|
-
const packageRoot = findPackageRoot((0,
|
|
71577
|
-
if (packageRoot && (0, import_node_fs31.existsSync)((0,
|
|
71688
|
+
const packageRoot = findPackageRoot((0, import_node_path34.dirname)(modulePath), pkgName);
|
|
71689
|
+
if (packageRoot && (0, import_node_fs31.existsSync)((0, import_node_path34.join)(packageRoot, ".git"))) {
|
|
71578
71690
|
return {
|
|
71579
71691
|
kind: "linked-dev",
|
|
71580
71692
|
installable: false,
|
|
@@ -71583,7 +71695,7 @@ function detectInstallContext(opts = {}) {
|
|
|
71583
71695
|
reason: "running from a git checkout \u2014 auto-update disabled (dev build)"
|
|
71584
71696
|
};
|
|
71585
71697
|
}
|
|
71586
|
-
const localLink = (0,
|
|
71698
|
+
const localLink = (0, import_node_path34.join)(cwd, "node_modules", pkgName);
|
|
71587
71699
|
try {
|
|
71588
71700
|
if ((0, import_node_fs31.lstatSync)(localLink).isSymbolicLink()) {
|
|
71589
71701
|
return {
|
|
@@ -71597,7 +71709,7 @@ function detectInstallContext(opts = {}) {
|
|
|
71597
71709
|
} catch {
|
|
71598
71710
|
}
|
|
71599
71711
|
const ua = env2.npm_config_user_agent ?? "";
|
|
71600
|
-
const npxLike = ua.includes("npx") || env2.npm_command === "exec" || (packageRoot?.includes(`${
|
|
71712
|
+
const npxLike = ua.includes("npx") || env2.npm_command === "exec" || (packageRoot?.includes(`${import_node_path34.sep}_npx${import_node_path34.sep}`) ?? false) || modulePath.includes(`${import_node_path34.sep}_npx${import_node_path34.sep}`);
|
|
71601
71713
|
if (npxLike) {
|
|
71602
71714
|
return {
|
|
71603
71715
|
kind: "npx",
|
|
@@ -71640,7 +71752,7 @@ function installArgsFor(ctx, version, pkgName = "latticesql") {
|
|
|
71640
71752
|
function installLatest(ctx, version, opts = {}) {
|
|
71641
71753
|
const args = installArgsFor(ctx, version, opts.pkgName ?? "latticesql");
|
|
71642
71754
|
if (!args) return false;
|
|
71643
|
-
(0,
|
|
71755
|
+
(0, import_node_child_process4.execFileSync)("npm", args, {
|
|
71644
71756
|
cwd: ctx.cwd,
|
|
71645
71757
|
stdio: opts.quiet ? "ignore" : "inherit",
|
|
71646
71758
|
timeout: 12e4,
|
|
@@ -71775,15 +71887,15 @@ init_column_descriptions();
|
|
|
71775
71887
|
|
|
71776
71888
|
// src/gui/userconfig-routes.ts
|
|
71777
71889
|
var import_node_fs33 = require("fs");
|
|
71778
|
-
var
|
|
71890
|
+
var import_node_path36 = require("path");
|
|
71779
71891
|
init_user_config();
|
|
71780
71892
|
init_parser();
|
|
71781
71893
|
init_http2();
|
|
71782
71894
|
|
|
71783
71895
|
// src/gui/files-routes.ts
|
|
71784
71896
|
var import_node_fs32 = require("fs");
|
|
71785
|
-
var
|
|
71786
|
-
var
|
|
71897
|
+
var import_node_path35 = require("path");
|
|
71898
|
+
var import_node_child_process5 = require("child_process");
|
|
71787
71899
|
init_http2();
|
|
71788
71900
|
function localFileOpenEnabled() {
|
|
71789
71901
|
return process.env.LATTICE_LOCAL_OPEN !== "0";
|
|
@@ -71793,7 +71905,7 @@ function localPathOf(row, latticeRoot) {
|
|
|
71793
71905
|
return row.ref_uri;
|
|
71794
71906
|
}
|
|
71795
71907
|
if ((row.ref_kind === "blob" || row.ref_kind === "cloud_ref") && typeof row.blob_path === "string" && row.blob_path) {
|
|
71796
|
-
return (0,
|
|
71908
|
+
return (0, import_node_path35.isAbsolute)(row.blob_path) ? row.blob_path : latticeRoot ? (0, import_node_path35.join)(latticeRoot, row.blob_path) : null;
|
|
71797
71909
|
}
|
|
71798
71910
|
return null;
|
|
71799
71911
|
}
|
|
@@ -71818,8 +71930,8 @@ function revealTargetFor(row, latticeRoot, loc, id) {
|
|
|
71818
71930
|
const ext = typeof row.mime === "string" ? MIME_EXT[row.mime] : void 0;
|
|
71819
71931
|
if (ext) name += ext;
|
|
71820
71932
|
}
|
|
71821
|
-
const dir = (0,
|
|
71822
|
-
const named = (0,
|
|
71933
|
+
const dir = (0, import_node_path35.join)(latticeRoot, "data", "finder", id.replace(/[^A-Za-z0-9_-]/g, "_"));
|
|
71934
|
+
const named = (0, import_node_path35.join)(dir, name);
|
|
71823
71935
|
try {
|
|
71824
71936
|
const fresh = (0, import_node_fs32.existsSync)(named) && (0, import_node_fs32.statSync)(named).size === (0, import_node_fs32.statSync)(loc).size;
|
|
71825
71937
|
if (!fresh) {
|
|
@@ -71955,9 +72067,9 @@ async function dispatchFilesRoute(req, res, ctx) {
|
|
|
71955
72067
|
return true;
|
|
71956
72068
|
}
|
|
71957
72069
|
const target = revealTargetFor(row, ctx.latticeRoot, loc, id);
|
|
71958
|
-
const reveal = process.platform === "darwin" ? { cmd: "open", args: ["-R", target] } : process.platform === "win32" ? { cmd: "explorer", args: [`/select,${target}`] } : { cmd: "xdg-open", args: [(0,
|
|
72070
|
+
const reveal = process.platform === "darwin" ? { cmd: "open", args: ["-R", target] } : process.platform === "win32" ? { cmd: "explorer", args: [`/select,${target}`] } : { cmd: "xdg-open", args: [(0, import_node_path35.dirname)(target)] };
|
|
71959
72071
|
try {
|
|
71960
|
-
const child = (0,
|
|
72072
|
+
const child = (0, import_node_child_process5.spawn)(reveal.cmd, reveal.args, { detached: true, stdio: "ignore" });
|
|
71961
72073
|
child.on("error", () => {
|
|
71962
72074
|
});
|
|
71963
72075
|
child.unref();
|
|
@@ -71990,18 +72102,18 @@ async function upsertIdentityRow(db, identity) {
|
|
|
71990
72102
|
}
|
|
71991
72103
|
}
|
|
71992
72104
|
function listProjectConfigs(activeConfigPath) {
|
|
71993
|
-
const dir = (0,
|
|
72105
|
+
const dir = (0, import_node_path36.dirname)(activeConfigPath);
|
|
71994
72106
|
const out = [];
|
|
71995
72107
|
if (!(0, import_node_fs33.existsSync)(dir)) return out;
|
|
71996
72108
|
for (const fname of (0, import_node_fs33.readdirSync)(dir)) {
|
|
71997
72109
|
if (!fname.endsWith(".yml") && !fname.endsWith(".yaml")) continue;
|
|
71998
|
-
const full = (0,
|
|
72110
|
+
const full = (0, import_node_path36.join)(dir, fname);
|
|
71999
72111
|
try {
|
|
72000
72112
|
const parsed = parseConfigFile(full);
|
|
72001
72113
|
out.push({
|
|
72002
72114
|
path: full,
|
|
72003
72115
|
name: fname.replace(/\.(ya?ml)$/, ""),
|
|
72004
|
-
dbFile: (0,
|
|
72116
|
+
dbFile: (0, import_node_path36.basename)(parsed.dbPath)
|
|
72005
72117
|
});
|
|
72006
72118
|
} catch {
|
|
72007
72119
|
}
|
|
@@ -72088,7 +72200,7 @@ async function dispatchUserConfigRoute(req, res, ctx) {
|
|
|
72088
72200
|
|
|
72089
72201
|
// src/gui/dbconfig/shared.ts
|
|
72090
72202
|
var import_node_fs34 = require("fs");
|
|
72091
|
-
var
|
|
72203
|
+
var import_node_path37 = require("path");
|
|
72092
72204
|
var import_yaml6 = require("yaml");
|
|
72093
72205
|
function buildPostgresUrl(params) {
|
|
72094
72206
|
const u2 = encodeURIComponent(params.user);
|
|
@@ -72118,9 +72230,9 @@ function rewriteDbLine(configPath, newValue) {
|
|
|
72118
72230
|
function parseSaveBody(body) {
|
|
72119
72231
|
const type = body.type;
|
|
72120
72232
|
if (type === "sqlite") {
|
|
72121
|
-
const
|
|
72122
|
-
if (!
|
|
72123
|
-
return { type: "sqlite", path:
|
|
72233
|
+
const path3 = typeof body.path === "string" && body.path.trim() ? body.path.trim() : "";
|
|
72234
|
+
if (!path3) return null;
|
|
72235
|
+
return { type: "sqlite", path: path3 };
|
|
72124
72236
|
}
|
|
72125
72237
|
if (type === "postgres") {
|
|
72126
72238
|
const label = typeof body.label === "string" && body.label.trim() ? body.label.trim() : "";
|
|
@@ -72136,12 +72248,12 @@ function parseSaveBody(body) {
|
|
|
72136
72248
|
return null;
|
|
72137
72249
|
}
|
|
72138
72250
|
function resolveRelativeToConfig(configPath, candidate) {
|
|
72139
|
-
return (0,
|
|
72251
|
+
return (0, import_node_path37.isAbsolute)(candidate) ? candidate : (0, import_node_path37.resolve)(configPath, "..", candidate);
|
|
72140
72252
|
}
|
|
72141
72253
|
|
|
72142
72254
|
// src/gui/dbconfig/connection-routes.ts
|
|
72143
72255
|
var import_node_fs35 = require("fs");
|
|
72144
|
-
var
|
|
72256
|
+
var import_node_path38 = require("path");
|
|
72145
72257
|
var import_yaml7 = require("yaml");
|
|
72146
72258
|
init_lattice();
|
|
72147
72259
|
init_http2();
|
|
@@ -72190,7 +72302,7 @@ async function describeCurrent(configPath, db) {
|
|
|
72190
72302
|
return {
|
|
72191
72303
|
type: "sqlite",
|
|
72192
72304
|
state: "local",
|
|
72193
|
-
dbFile: (0,
|
|
72305
|
+
dbFile: (0, import_node_path38.basename)(dbLine),
|
|
72194
72306
|
isCloud: false
|
|
72195
72307
|
};
|
|
72196
72308
|
}
|
|
@@ -72231,8 +72343,8 @@ async function dispatchConnection(req, res, ctx) {
|
|
|
72231
72343
|
return;
|
|
72232
72344
|
}
|
|
72233
72345
|
const abs = resolveRelativeToConfig(ctx.configPath, parsed.path);
|
|
72234
|
-
const rel = (0,
|
|
72235
|
-
const dbLine = rel.startsWith("..") ? abs : "./" + rel.split(
|
|
72346
|
+
const rel = (0, import_node_path38.relative)((0, import_node_path38.resolve)(ctx.configPath, ".."), abs);
|
|
72347
|
+
const dbLine = rel.startsWith("..") ? abs : "./" + rel.split(import_node_path38.sep).join("/");
|
|
72236
72348
|
rewriteDbLine(ctx.configPath, dbLine);
|
|
72237
72349
|
sendJson(res, { ok: true, type: "sqlite", path: dbLine });
|
|
72238
72350
|
});
|
|
@@ -72298,7 +72410,7 @@ async function dispatchConnection(req, res, ctx) {
|
|
|
72298
72410
|
const doc = (0, import_yaml7.parseDocument)((0, import_node_fs35.readFileSync)(ctx.configPath, "utf8"));
|
|
72299
72411
|
doc.set("name", name);
|
|
72300
72412
|
(0, import_node_fs35.writeFileSync)(ctx.configPath, doc.toString(), "utf8");
|
|
72301
|
-
const root6 = findLatticeRoot((0,
|
|
72413
|
+
const root6 = findLatticeRoot((0, import_node_path38.dirname)(ctx.configPath));
|
|
72302
72414
|
if (root6) renameWorkspaceByConfigPath(root6, ctx.configPath, name);
|
|
72303
72415
|
const info = await describeCurrent(ctx.configPath, ctx.db);
|
|
72304
72416
|
sendJson(res, { ok: true, kind: info.isCloud ? "cloud" : "local", name });
|
|
@@ -72310,7 +72422,7 @@ async function dispatchConnection(req, res, ctx) {
|
|
|
72310
72422
|
|
|
72311
72423
|
// src/gui/dbconfig/cloud-state-routes.ts
|
|
72312
72424
|
var import_node_fs37 = require("fs");
|
|
72313
|
-
var
|
|
72425
|
+
var import_node_path40 = require("path");
|
|
72314
72426
|
var import_yaml9 = require("yaml");
|
|
72315
72427
|
var import_node_crypto20 = require("crypto");
|
|
72316
72428
|
init_http2();
|
|
@@ -72415,22 +72527,22 @@ init_workspace();
|
|
|
72415
72527
|
|
|
72416
72528
|
// src/framework/gui-bootstrap.ts
|
|
72417
72529
|
var import_node_fs36 = require("fs");
|
|
72418
|
-
var
|
|
72530
|
+
var import_node_path39 = require("path");
|
|
72419
72531
|
var import_yaml8 = require("yaml");
|
|
72420
72532
|
init_lattice_root();
|
|
72421
72533
|
init_workspace();
|
|
72422
72534
|
function resolveContextDirForConfig(configPath) {
|
|
72423
|
-
const base = (0,
|
|
72535
|
+
const base = (0, import_node_path39.dirname)((0, import_node_path39.resolve)(configPath));
|
|
72424
72536
|
for (const dir of ["context", ".", "generated"]) {
|
|
72425
|
-
const abs = (0,
|
|
72426
|
-
if ((0, import_node_fs36.existsSync)((0,
|
|
72537
|
+
const abs = (0, import_node_path39.resolve)(base, dir);
|
|
72538
|
+
if ((0, import_node_fs36.existsSync)((0, import_node_path39.join)(abs, ".lattice", "manifest.json"))) return abs;
|
|
72427
72539
|
}
|
|
72428
|
-
return (0,
|
|
72540
|
+
return (0, import_node_path39.resolve)(base, "context");
|
|
72429
72541
|
}
|
|
72430
72542
|
|
|
72431
72543
|
// src/gui/dbconfig/cloud-state-routes.ts
|
|
72432
72544
|
function updateActiveWorkspaceToCloud(configPath, displayName, key) {
|
|
72433
|
-
const root6 = findLatticeRoot((0,
|
|
72545
|
+
const root6 = findLatticeRoot((0, import_node_path40.dirname)(configPath));
|
|
72434
72546
|
if (!root6) return;
|
|
72435
72547
|
registerOrUpdateCloudWorkspace(root6, {
|
|
72436
72548
|
configPath,
|
|
@@ -72694,7 +72806,7 @@ async function dispatchCloudState(req, res, ctx) {
|
|
|
72694
72806
|
await assertScopedMemberRole(ctx.db, role);
|
|
72695
72807
|
const user = poolerAwareUser(coords.host, role, coords.user);
|
|
72696
72808
|
const expiresAt = new Date(Date.now() + 7 * 24 * 60 * 60 * 1e3);
|
|
72697
|
-
const inviteRoot = findLatticeRoot((0,
|
|
72809
|
+
const inviteRoot = findLatticeRoot((0, import_node_path40.dirname)(ctx.configPath));
|
|
72698
72810
|
const ownerWs = inviteRoot ? getActiveWorkspace(inviteRoot) : null;
|
|
72699
72811
|
const token = mintInviteToken({
|
|
72700
72812
|
coords,
|
|
@@ -73637,7 +73749,7 @@ async function dispatchChatRoute(req, res, ctx) {
|
|
|
73637
73749
|
var import_node_fs40 = require("fs");
|
|
73638
73750
|
var import_promises12 = require("fs/promises");
|
|
73639
73751
|
var import_node_os9 = require("os");
|
|
73640
|
-
var
|
|
73752
|
+
var import_node_path43 = require("path");
|
|
73641
73753
|
init_mutations();
|
|
73642
73754
|
init_extract();
|
|
73643
73755
|
var import_node_crypto23 = require("crypto");
|
|
@@ -74098,7 +74210,7 @@ function dedupeAndDetectViews(plan, data) {
|
|
|
74098
74210
|
}
|
|
74099
74211
|
|
|
74100
74212
|
// src/import/excel.ts
|
|
74101
|
-
var
|
|
74213
|
+
var import_node_path41 = require("path");
|
|
74102
74214
|
var HEADER_SCAN_ROWS = 25;
|
|
74103
74215
|
function cellValue(v2) {
|
|
74104
74216
|
if (v2 === null || v2 === void 0) return null;
|
|
@@ -74169,7 +74281,7 @@ function sheetToRecords(ws) {
|
|
|
74169
74281
|
}
|
|
74170
74282
|
var preambleCache = /* @__PURE__ */ new Map();
|
|
74171
74283
|
function excelPreambleText(absPath) {
|
|
74172
|
-
return preambleCache.get((0,
|
|
74284
|
+
return preambleCache.get((0, import_node_path41.resolve)(absPath)) ?? "";
|
|
74173
74285
|
}
|
|
74174
74286
|
function sheetPreamble(ws) {
|
|
74175
74287
|
const lines = [];
|
|
@@ -74206,7 +74318,7 @@ async function excelToRecords(absPath) {
|
|
|
74206
74318
|
const records = sheetToRecords(ws);
|
|
74207
74319
|
if (records.length > 0) out[ws.name] = records;
|
|
74208
74320
|
}
|
|
74209
|
-
preambleCache.set((0,
|
|
74321
|
+
preambleCache.set((0, import_node_path41.resolve)(absPath), preamble.filter(Boolean).join("\n"));
|
|
74210
74322
|
return out;
|
|
74211
74323
|
}
|
|
74212
74324
|
|
|
@@ -74643,7 +74755,7 @@ async function materializeImport(ctx, data, plan, views = [], opts = {}) {
|
|
|
74643
74755
|
init_native_entities();
|
|
74644
74756
|
|
|
74645
74757
|
// src/gui/import-detect.ts
|
|
74646
|
-
var
|
|
74758
|
+
var import_node_path42 = require("path");
|
|
74647
74759
|
|
|
74648
74760
|
// src/gui/ai/asof-llm.ts
|
|
74649
74761
|
init_assistant_routes();
|
|
@@ -74687,7 +74799,7 @@ ${trimmed.slice(0, MAX_CHARS)}` }],
|
|
|
74687
74799
|
|
|
74688
74800
|
// src/gui/import-detect.ts
|
|
74689
74801
|
async function detectImportAsOf(db, data, opts = {}) {
|
|
74690
|
-
const fileName = opts.fileName ?? (opts.abs ? (0,
|
|
74802
|
+
const fileName = opts.fileName ?? (opts.abs ? (0, import_node_path42.basename)(opts.abs).replace(/^[0-9a-f]{8}-/, "") : "");
|
|
74691
74803
|
const texts = [];
|
|
74692
74804
|
for (const [k6, v2] of Object.entries(data)) {
|
|
74693
74805
|
if (!Array.isArray(v2)) texts.push({ label: "data", text: `${k6}: ${JSON.stringify(v2)}` });
|
|
@@ -74826,7 +74938,7 @@ var MIME_BY_EXT = {
|
|
|
74826
74938
|
".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
74827
74939
|
};
|
|
74828
74940
|
function mimeFor(name) {
|
|
74829
|
-
return MIME_BY_EXT[(0,
|
|
74941
|
+
return MIME_BY_EXT[(0, import_node_path43.extname)(name).toLowerCase()] ?? "application/octet-stream";
|
|
74830
74942
|
}
|
|
74831
74943
|
var RETAINABLE_DOC_MIMES = /* @__PURE__ */ new Set([
|
|
74832
74944
|
"application/pdf",
|
|
@@ -74901,28 +75013,28 @@ ${err.stack ?? ""}`
|
|
|
74901
75013
|
return null;
|
|
74902
75014
|
}
|
|
74903
75015
|
}
|
|
74904
|
-
async function extractImage(db,
|
|
75016
|
+
async function extractImage(db, path3, mime) {
|
|
74905
75017
|
if (!mime.startsWith("image/")) return null;
|
|
74906
75018
|
const auth = await resolveClaudeAuth(db);
|
|
74907
75019
|
if (!auth) return null;
|
|
74908
75020
|
try {
|
|
74909
|
-
const text = await describeImage(auth,
|
|
75021
|
+
const text = await describeImage(auth, path3);
|
|
74910
75022
|
return text.trim() ? { text, skip: false } : null;
|
|
74911
75023
|
} catch (e6) {
|
|
74912
75024
|
console.warn("[ingest] image vision failed:", e6.message);
|
|
74913
75025
|
return null;
|
|
74914
75026
|
}
|
|
74915
75027
|
}
|
|
74916
|
-
async function extractSource(db,
|
|
74917
|
-
const vision = await extractImage(db,
|
|
75028
|
+
async function extractSource(db, path3, mime, name) {
|
|
75029
|
+
const vision = await extractImage(db, path3, mime);
|
|
74918
75030
|
if (vision) return vision;
|
|
74919
|
-
const parsed = await parseFile(
|
|
75031
|
+
const parsed = await parseFile(path3, mime, name);
|
|
74920
75032
|
if (!parsed.skip) return parsed;
|
|
74921
75033
|
if (mime === "application/pdf") {
|
|
74922
75034
|
const auth = await resolveClaudeAuth(db);
|
|
74923
75035
|
if (auth) {
|
|
74924
75036
|
try {
|
|
74925
|
-
const text = await describePdf(auth,
|
|
75037
|
+
const text = await describePdf(auth, path3);
|
|
74926
75038
|
if (text.trim()) return { ...parsed, text, skip: false };
|
|
74927
75039
|
} catch (e6) {
|
|
74928
75040
|
console.warn("[ingest] Claude PDF read failed:", e6.message);
|
|
@@ -74993,7 +75105,7 @@ async function dispatchIngestRoute(req, res, ctx) {
|
|
|
74993
75105
|
sendJson(res, { error: "empty upload" }, 400);
|
|
74994
75106
|
return true;
|
|
74995
75107
|
}
|
|
74996
|
-
const tmp = (0,
|
|
75108
|
+
const tmp = (0, import_node_path43.join)((0, import_node_os9.tmpdir)(), `lattice-ingest-${crypto.randomUUID()}${(0, import_node_path43.extname)(name2)}`);
|
|
74997
75109
|
let result;
|
|
74998
75110
|
let blob = null;
|
|
74999
75111
|
let autoImport = null;
|
|
@@ -75216,7 +75328,7 @@ async function dispatchIngestRoute(req, res, ctx) {
|
|
|
75216
75328
|
sendJson(res, { error: "path is required" }, 400);
|
|
75217
75329
|
return true;
|
|
75218
75330
|
}
|
|
75219
|
-
const abs = (0,
|
|
75331
|
+
const abs = (0, import_node_path43.resolve)(rawPath);
|
|
75220
75332
|
let size = 0;
|
|
75221
75333
|
try {
|
|
75222
75334
|
const st = (0, import_node_fs40.statSync)(abs);
|
|
@@ -75233,7 +75345,7 @@ async function dispatchIngestRoute(req, res, ctx) {
|
|
|
75233
75345
|
sendJson(res, { error: "file too large" }, 413);
|
|
75234
75346
|
return true;
|
|
75235
75347
|
}
|
|
75236
|
-
const name = (0,
|
|
75348
|
+
const name = (0, import_node_path43.basename)(abs);
|
|
75237
75349
|
const mime = mimeFor(name);
|
|
75238
75350
|
const localFileId = crypto.randomUUID();
|
|
75239
75351
|
const localRow = {
|
|
@@ -75301,7 +75413,7 @@ ${err.stack ?? ""}`
|
|
|
75301
75413
|
|
|
75302
75414
|
// src/gui/import-routes.ts
|
|
75303
75415
|
var import_node_fs41 = require("fs");
|
|
75304
|
-
var
|
|
75416
|
+
var import_node_path44 = require("path");
|
|
75305
75417
|
init_adapter();
|
|
75306
75418
|
init_http2();
|
|
75307
75419
|
init_native_entities();
|
|
@@ -75313,7 +75425,7 @@ function badRequest(message) {
|
|
|
75313
75425
|
function localPathOf2(row, latticeRoot) {
|
|
75314
75426
|
if (row.ref_kind === "local_ref" && row.ref_uri) return row.ref_uri;
|
|
75315
75427
|
if ((row.ref_kind === "blob" || row.ref_kind === "cloud_ref") && row.blob_path) {
|
|
75316
|
-
return (0,
|
|
75428
|
+
return (0, import_node_path44.isAbsolute)(row.blob_path) ? row.blob_path : latticeRoot ? (0, import_node_path44.join)(latticeRoot, row.blob_path) : null;
|
|
75317
75429
|
}
|
|
75318
75430
|
return null;
|
|
75319
75431
|
}
|
|
@@ -75335,11 +75447,11 @@ async function readImportSourceFromFile(db, fileId, latticeRoot) {
|
|
|
75335
75447
|
[fileId]
|
|
75336
75448
|
);
|
|
75337
75449
|
if (!row) throw badRequest("Unknown import file: " + fileId);
|
|
75338
|
-
const
|
|
75339
|
-
if (!
|
|
75450
|
+
const path3 = localPathOf2(row, latticeRoot);
|
|
75451
|
+
if (!path3 || !(0, import_node_fs41.existsSync)(path3)) {
|
|
75340
75452
|
throw badRequest("The import file\u2019s bytes are not available locally.");
|
|
75341
75453
|
}
|
|
75342
|
-
const sizeBytes = (0, import_node_fs41.statSync)(
|
|
75454
|
+
const sizeBytes = (0, import_node_fs41.statSync)(path3).size;
|
|
75343
75455
|
if (sizeBytes > MAX_INGEST_BYTES) {
|
|
75344
75456
|
throw badRequest(
|
|
75345
75457
|
`The import file is too large (${String(Math.round(sizeBytes / 1e6))} MB); the limit is ${String(Math.round(MAX_INGEST_BYTES / 1e6))} MB.`
|
|
@@ -75348,11 +75460,11 @@ async function readImportSourceFromFile(db, fileId, latticeRoot) {
|
|
|
75348
75460
|
const name = row.original_name ?? "";
|
|
75349
75461
|
const mime = row.mime ?? "";
|
|
75350
75462
|
if (/\.xlsx?$/i.test(name) || mime.includes("spreadsheet") || mime.includes("excel")) {
|
|
75351
|
-
return excelToRecords(
|
|
75463
|
+
return excelToRecords(path3);
|
|
75352
75464
|
}
|
|
75353
75465
|
let parsed;
|
|
75354
75466
|
try {
|
|
75355
|
-
parsed = JSON.parse((0, import_node_fs41.readFileSync)(
|
|
75467
|
+
parsed = JSON.parse((0, import_node_fs41.readFileSync)(path3, "utf8"));
|
|
75356
75468
|
} catch {
|
|
75357
75469
|
throw badRequest("The import file is not valid JSON.");
|
|
75358
75470
|
}
|
|
@@ -76776,7 +76888,7 @@ async function handleHistoryRoutes(req, res, ctx, deps) {
|
|
|
76776
76888
|
}
|
|
76777
76889
|
|
|
76778
76890
|
// src/gui/workspaces-routes.ts
|
|
76779
|
-
var
|
|
76891
|
+
var import_node_path45 = require("path");
|
|
76780
76892
|
var import_node_fs42 = require("fs");
|
|
76781
76893
|
init_http2();
|
|
76782
76894
|
init_workspace();
|
|
@@ -76940,7 +77052,7 @@ async function handleWorkspacesRoutes(req, res, ctx, deps) {
|
|
|
76940
77052
|
return true;
|
|
76941
77053
|
}
|
|
76942
77054
|
const wsPaths = resolveWorkspacePaths(latticeRoot, ws);
|
|
76943
|
-
const isActive = (0,
|
|
77055
|
+
const isActive = (0, import_node_path45.resolve)(active.configPath) === (0, import_node_path45.resolve)(wsPaths.configPath);
|
|
76944
77056
|
let switchedTo = null;
|
|
76945
77057
|
if (isActive) {
|
|
76946
77058
|
const fallback = listWorkspaces(latticeRoot).find((w2) => w2.id !== ws.id);
|
|
@@ -76988,34 +77100,34 @@ async function handleWorkspacesRoutes(req, res, ctx, deps) {
|
|
|
76988
77100
|
}
|
|
76989
77101
|
|
|
76990
77102
|
// src/gui/databases-routes.ts
|
|
76991
|
-
var
|
|
77103
|
+
var import_node_path47 = require("path");
|
|
76992
77104
|
var import_node_fs44 = require("fs");
|
|
76993
77105
|
init_http2();
|
|
76994
77106
|
init_parser();
|
|
76995
77107
|
|
|
76996
77108
|
// src/gui/config-paths.ts
|
|
76997
|
-
var
|
|
77109
|
+
var import_node_path46 = require("path");
|
|
76998
77110
|
var import_node_fs43 = require("fs");
|
|
76999
77111
|
var import_yaml10 = require("yaml");
|
|
77000
77112
|
init_parser();
|
|
77001
77113
|
function resolveOutputDirForConfig(configPath) {
|
|
77002
|
-
const base = (0,
|
|
77114
|
+
const base = (0, import_node_path46.dirname)((0, import_node_path46.resolve)(configPath));
|
|
77003
77115
|
for (const dir of ["context", ".", "generated"]) {
|
|
77004
|
-
const abs = (0,
|
|
77005
|
-
if ((0, import_node_fs43.existsSync)((0,
|
|
77116
|
+
const abs = (0, import_node_path46.resolve)(base, dir);
|
|
77117
|
+
if ((0, import_node_fs43.existsSync)((0, import_node_path46.join)(abs, ".lattice", "manifest.json"))) return abs;
|
|
77006
77118
|
}
|
|
77007
|
-
return (0,
|
|
77119
|
+
return (0, import_node_path46.resolve)(base, "context");
|
|
77008
77120
|
}
|
|
77009
77121
|
function friendlyConfigName(parsedName, configPath) {
|
|
77010
77122
|
if (parsedName && parsedName.trim().length > 0) return parsedName.trim();
|
|
77011
|
-
return (0,
|
|
77123
|
+
return (0, import_node_path46.basename)(configPath).replace(/\.(ya?ml)$/, "");
|
|
77012
77124
|
}
|
|
77013
77125
|
function listConfigs(activeConfigPath) {
|
|
77014
|
-
const dir = (0,
|
|
77126
|
+
const dir = (0, import_node_path46.dirname)(activeConfigPath);
|
|
77015
77127
|
const entries = [];
|
|
77016
77128
|
for (const fname of (0, import_node_fs43.readdirSync)(dir)) {
|
|
77017
77129
|
if (!fname.endsWith(".yml") && !fname.endsWith(".yaml")) continue;
|
|
77018
|
-
const full = (0,
|
|
77130
|
+
const full = (0, import_node_path46.join)(dir, fname);
|
|
77019
77131
|
try {
|
|
77020
77132
|
const parsed = parseConfigFile(full);
|
|
77021
77133
|
entries.push({
|
|
@@ -77026,7 +77138,7 @@ function listConfigs(activeConfigPath) {
|
|
|
77026
77138
|
// `label` is the friendly DB name — what the user sees in the
|
|
77027
77139
|
// dropdown + settings. Falls back to the basename when unset.
|
|
77028
77140
|
label: friendlyConfigName(parsed.name, full),
|
|
77029
|
-
dbFile: (0,
|
|
77141
|
+
dbFile: (0, import_node_path46.basename)(parsed.dbPath),
|
|
77030
77142
|
active: full === activeConfigPath,
|
|
77031
77143
|
// `${LATTICE_DB:...}` and postgres:// configs resolve to a
|
|
77032
77144
|
// postgres URL; everything else is a local SQLite file. This
|
|
@@ -77040,17 +77152,17 @@ function listConfigs(activeConfigPath) {
|
|
|
77040
77152
|
return entries.sort((a6, b6) => a6.label.localeCompare(b6.label));
|
|
77041
77153
|
}
|
|
77042
77154
|
function createBlankConfig(activeConfigPath, dbName) {
|
|
77043
|
-
const dir = (0,
|
|
77155
|
+
const dir = (0, import_node_path46.dirname)(activeConfigPath);
|
|
77044
77156
|
const slug = dbName.toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
77045
77157
|
if (!slug) throw new Error("Workspace name must contain at least one alphanumeric character");
|
|
77046
|
-
const configPath = (0,
|
|
77158
|
+
const configPath = (0, import_node_path46.join)(dir, `${slug}.config.yml`);
|
|
77047
77159
|
if ((0, import_node_fs43.existsSync)(configPath)) throw new Error(`Config already exists: ${slug}.config.yml`);
|
|
77048
77160
|
const yaml = `db: ./data/${slug}.db
|
|
77049
77161
|
|
|
77050
77162
|
entities: {}
|
|
77051
77163
|
`;
|
|
77052
77164
|
(0, import_node_fs43.writeFileSync)(configPath, yaml, "utf8");
|
|
77053
|
-
(0, import_node_fs43.mkdirSync)((0,
|
|
77165
|
+
(0, import_node_fs43.mkdirSync)((0, import_node_path46.join)(dir, "data"), { recursive: true });
|
|
77054
77166
|
return configPath;
|
|
77055
77167
|
}
|
|
77056
77168
|
function sqliteFileForConfig(configPath) {
|
|
@@ -77059,7 +77171,7 @@ function sqliteFileForConfig(configPath) {
|
|
|
77059
77171
|
if (!raw) return null;
|
|
77060
77172
|
if (isPostgresUrl(raw) || raw.startsWith("${LATTICE_DB:")) return null;
|
|
77061
77173
|
if (raw === ":memory:" || raw.startsWith("file:")) return null;
|
|
77062
|
-
return (0,
|
|
77174
|
+
return (0, import_node_path46.resolve)((0, import_node_path46.dirname)(configPath), raw);
|
|
77063
77175
|
}
|
|
77064
77176
|
function deleteDatabaseFiles(targetConfigPath) {
|
|
77065
77177
|
const sqliteFile = sqliteFileForConfig(targetConfigPath);
|
|
@@ -77073,7 +77185,7 @@ function deleteDatabaseFiles(targetConfigPath) {
|
|
|
77073
77185
|
if ((0, import_node_fs43.existsSync)(sidecar)) (0, import_node_fs43.unlinkSync)(sidecar);
|
|
77074
77186
|
}
|
|
77075
77187
|
}
|
|
77076
|
-
return { deletedConfig: (0,
|
|
77188
|
+
return { deletedConfig: (0, import_node_path46.basename)(targetConfigPath), deletedDbFile };
|
|
77077
77189
|
}
|
|
77078
77190
|
|
|
77079
77191
|
// src/gui/databases-routes.ts
|
|
@@ -77089,7 +77201,7 @@ async function handleDatabasesRoutes(req, res, ctx, deps) {
|
|
|
77089
77201
|
sendJson(res, {
|
|
77090
77202
|
current: {
|
|
77091
77203
|
path: active.configPath,
|
|
77092
|
-
dbFile: (0,
|
|
77204
|
+
dbFile: (0, import_node_path47.basename)(parsedActive.dbPath),
|
|
77093
77205
|
label: friendlyLabel,
|
|
77094
77206
|
kind
|
|
77095
77207
|
},
|
|
@@ -77103,7 +77215,7 @@ async function handleDatabasesRoutes(req, res, ctx, deps) {
|
|
|
77103
77215
|
sendJson(res, { error: "path must be a string" }, 400);
|
|
77104
77216
|
return true;
|
|
77105
77217
|
}
|
|
77106
|
-
const newPath = (0,
|
|
77218
|
+
const newPath = (0, import_node_path47.resolve)(body.path);
|
|
77107
77219
|
if (!(0, import_node_fs44.existsSync)(newPath)) {
|
|
77108
77220
|
sendJson(res, { error: `Config not found: ${newPath}` }, 400);
|
|
77109
77221
|
return true;
|
|
@@ -77146,16 +77258,16 @@ async function handleDatabasesRoutes(req, res, ctx, deps) {
|
|
|
77146
77258
|
sendJson(res, { error: "path must be a non-empty string" }, 400);
|
|
77147
77259
|
return true;
|
|
77148
77260
|
}
|
|
77149
|
-
const target = (0,
|
|
77261
|
+
const target = (0, import_node_path47.resolve)(body.path);
|
|
77150
77262
|
const known = listConfigs(active.configPath);
|
|
77151
|
-
const match = known.find((c6) => (0,
|
|
77263
|
+
const match = known.find((c6) => (0, import_node_path47.resolve)(c6.path) === target);
|
|
77152
77264
|
if (!match) {
|
|
77153
77265
|
sendJson(res, { error: `Not a known database config: ${target}` }, 400);
|
|
77154
77266
|
return true;
|
|
77155
77267
|
}
|
|
77156
77268
|
let switchedTo = null;
|
|
77157
|
-
if ((0,
|
|
77158
|
-
const fallback = known.find((c6) => (0,
|
|
77269
|
+
if ((0, import_node_path47.resolve)(active.configPath) === target) {
|
|
77270
|
+
const fallback = known.find((c6) => (0, import_node_path47.resolve)(c6.path) !== target);
|
|
77159
77271
|
if (!fallback) {
|
|
77160
77272
|
sendJson(
|
|
77161
77273
|
res,
|
|
@@ -77216,7 +77328,7 @@ function sendText(res, body, status = 200, contentType = "text/plain; charset=ut
|
|
|
77216
77328
|
function openUrl(url) {
|
|
77217
77329
|
const command = process.platform === "darwin" ? "open" : process.platform === "win32" ? "cmd" : "xdg-open";
|
|
77218
77330
|
const args = process.platform === "win32" ? ["/c", "start", "", url] : [url];
|
|
77219
|
-
const child = (0,
|
|
77331
|
+
const child = (0, import_node_child_process6.spawn)(command, args, { stdio: "ignore", detached: true });
|
|
77220
77332
|
child.unref();
|
|
77221
77333
|
}
|
|
77222
77334
|
function listen(server, port, host) {
|
|
@@ -77246,8 +77358,8 @@ async function listenWithPortFallback(server, startPort, host) {
|
|
|
77246
77358
|
throw new Error(`No available port found starting at ${String(startPort)}`);
|
|
77247
77359
|
}
|
|
77248
77360
|
async function startGuiServer(options) {
|
|
77249
|
-
const bootConfigPath = options.configPath ? (0,
|
|
77250
|
-
const bootOutputDir = options.outputDir ? (0,
|
|
77361
|
+
const bootConfigPath = options.configPath ? (0, import_node_path48.resolve)(options.configPath) : null;
|
|
77362
|
+
const bootOutputDir = options.outputDir ? (0, import_node_path48.resolve)(options.outputDir) : null;
|
|
77251
77363
|
const startPort = options.port ?? 4317;
|
|
77252
77364
|
const host = options.host ?? "127.0.0.1";
|
|
77253
77365
|
const isLoopbackHost2 = host === "localhost" || host === "::1" || host.startsWith("127.");
|
|
@@ -77261,11 +77373,11 @@ async function startGuiServer(options) {
|
|
|
77261
77373
|
const sessionId = crypto.randomUUID();
|
|
77262
77374
|
let updateService = null;
|
|
77263
77375
|
let activeRef = bootConfigPath && bootOutputDir ? await openConfig(bootConfigPath, bootOutputDir, autoRender, options.realtimeWatchdogMs) : null;
|
|
77264
|
-
const latticeRoot = (bootConfigPath ? findLatticeRoot((0,
|
|
77376
|
+
const latticeRoot = (bootConfigPath ? findLatticeRoot((0, import_node_path48.dirname)(bootConfigPath)) : null) ?? (options.latticeRoot ? (0, import_node_path48.resolve)(options.latticeRoot) : null);
|
|
77265
77377
|
let currentWorkspaceId = null;
|
|
77266
77378
|
if (latticeRoot && bootConfigPath) {
|
|
77267
77379
|
const launched = listWorkspaces(latticeRoot).find(
|
|
77268
|
-
(w2) => (0,
|
|
77380
|
+
(w2) => (0, import_node_path48.resolve)(resolveWorkspacePaths(latticeRoot, w2).configPath) === (0, import_node_path48.resolve)(bootConfigPath)
|
|
77269
77381
|
);
|
|
77270
77382
|
if (launched) {
|
|
77271
77383
|
currentWorkspaceId = launched.id;
|
|
@@ -77601,7 +77713,7 @@ async function startGuiServer(options) {
|
|
|
77601
77713
|
createJunction: (otherTable) => createFileJunction(active, otherTable, sessionId),
|
|
77602
77714
|
createEntity: (entity, columns) => createUserEntity(active, entity, columns, sessionId),
|
|
77603
77715
|
aggressiveness: getAggressiveness(),
|
|
77604
|
-
latticeRoot: (0,
|
|
77716
|
+
latticeRoot: (0, import_node_path48.dirname)(active.configPath),
|
|
77605
77717
|
configPath: active.configPath,
|
|
77606
77718
|
outputDir: active.outputDir,
|
|
77607
77719
|
sessionId,
|
|
@@ -77620,7 +77732,7 @@ async function startGuiServer(options) {
|
|
|
77620
77732
|
return await dispatchImportRoute(req2, res2, {
|
|
77621
77733
|
db: active.db,
|
|
77622
77734
|
configPath: active.configPath,
|
|
77623
|
-
latticeRoot: (0,
|
|
77735
|
+
latticeRoot: (0, import_node_path48.dirname)(active.configPath),
|
|
77624
77736
|
validTables: active.validTables,
|
|
77625
77737
|
softDeletable: active.softDeletable
|
|
77626
77738
|
});
|
|
@@ -77632,7 +77744,7 @@ async function startGuiServer(options) {
|
|
|
77632
77744
|
if (!pathname.startsWith("/api/files/")) return false;
|
|
77633
77745
|
return await dispatchFilesRoute(req2, res2, {
|
|
77634
77746
|
db: active.db,
|
|
77635
|
-
latticeRoot: (0,
|
|
77747
|
+
latticeRoot: (0, import_node_path48.dirname)(active.configPath),
|
|
77636
77748
|
configPath: active.configPath,
|
|
77637
77749
|
pathname,
|
|
77638
77750
|
method
|
|
@@ -77844,7 +77956,7 @@ ${e6.stack ?? ""}`
|
|
|
77844
77956
|
|
|
77845
77957
|
// src/cloud/file-source-key-store.ts
|
|
77846
77958
|
var import_node_fs45 = require("fs");
|
|
77847
|
-
var
|
|
77959
|
+
var import_node_path49 = require("path");
|
|
77848
77960
|
var import_node_crypto24 = require("crypto");
|
|
77849
77961
|
var ENC_HEADER = "LATTICE-KMS-v1\n";
|
|
77850
77962
|
var SCRYPT_N = 1 << 15;
|
|
@@ -77862,7 +77974,7 @@ var FileSourceKeyStore = class {
|
|
|
77862
77974
|
if (!opts.path || typeof opts.path !== "string") {
|
|
77863
77975
|
throw new Error("lattice: FileSourceKeyStore requires a non-empty `path`");
|
|
77864
77976
|
}
|
|
77865
|
-
this.path = (0,
|
|
77977
|
+
this.path = (0, import_node_path49.resolve)(opts.path);
|
|
77866
77978
|
this.passphrase = opts.passphrase;
|
|
77867
77979
|
this.cache = this.load();
|
|
77868
77980
|
}
|
|
@@ -77896,7 +78008,7 @@ var FileSourceKeyStore = class {
|
|
|
77896
78008
|
load() {
|
|
77897
78009
|
const out = /* @__PURE__ */ new Map();
|
|
77898
78010
|
if (!(0, import_node_fs45.existsSync)(this.path)) {
|
|
77899
|
-
const dir = (0,
|
|
78011
|
+
const dir = (0, import_node_path49.dirname)(this.path);
|
|
77900
78012
|
if (!(0, import_node_fs45.existsSync)(dir)) (0, import_node_fs45.mkdirSync)(dir, { recursive: true, mode: 448 });
|
|
77901
78013
|
return out;
|
|
77902
78014
|
}
|