@camstack/server 1.2.714 → 1.2.716
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/CHANGELOG.md +13 -0
- package/dist/api/trpc/generated-cap-mounts.js +3 -1
- package/dist/api/trpc/generated-cap-routers.js +1531 -1429
- package/dist/launcher.js +3 -0
- package/dist/pre-migration-restore.js +136 -0
- package/dist/sqlite-restore.js +3 -2
- package/package.json +6 -6
package/dist/launcher.js
CHANGED
|
@@ -63,6 +63,7 @@ const closure_node_modules_js_1 = require("./closure-node-modules.js");
|
|
|
63
63
|
const framework_nodepath_js_1 = require("./framework-nodepath.js");
|
|
64
64
|
const package_inventory_js_1 = require("./package-inventory.js");
|
|
65
65
|
const pending_restore_js_1 = require("./pending-restore.js");
|
|
66
|
+
const pre_migration_restore_js_1 = require("./pre-migration-restore.js");
|
|
66
67
|
/** Resolve the data directory from env or default */
|
|
67
68
|
const DATA_DIR = process.env['CAMSTACK_DATA'] ?? 'camstack-data';
|
|
68
69
|
/** Narrow `CAMSTACK_INSTALL_SOURCE` env into the typed union. */
|
|
@@ -246,6 +247,8 @@ async function launch() {
|
|
|
246
247
|
// installer + symlink step pick up — otherwise we'd install a stale
|
|
247
248
|
// set and overwrite it a step later.
|
|
248
249
|
await (0, pending_restore_js_1.applyPendingRestore)(dataDir, (line) => console.log(line));
|
|
250
|
+
// A pre-migration snapshot the operator chose to go back to (D987).
|
|
251
|
+
(0, pre_migration_restore_js_1.applyPendingPreMigrationRestore)(dataDir, (line) => console.log(line));
|
|
249
252
|
// @camstack/system is imported DYNAMICALLY here — AFTER the active framework
|
|
250
253
|
// dir + NODE_PATH are resolved above — so the correct framework copy is what
|
|
251
254
|
// gets loaded. Never import it at module top.
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.PRE_MIGRATION_RESTORE_MARKER = void 0;
|
|
37
|
+
exports.applyPendingPreMigrationRestore = applyPendingPreMigrationRestore;
|
|
38
|
+
/**
|
|
39
|
+
* The boot-time restore of a PRE-MIGRATION snapshot (D987). The sqlite-settings
|
|
40
|
+
* owner writes `.pending-restore.json`'s sibling marker; the launcher promotes
|
|
41
|
+
* the snapshot over the database before any runner starts, so nothing holds the
|
|
42
|
+
* file open (D679). It is its own marker, not a field of the system-restore one:
|
|
43
|
+
* that one is owned by the backup service and carries an archive.
|
|
44
|
+
*
|
|
45
|
+
* Marker: `{ requests: [{ livePath, snapshotPath }] }`, both relative to the
|
|
46
|
+
* data dir. The snapshot is COPIED (temp file + rename) and kept, so the same
|
|
47
|
+
* restore can be asked for again. The launcher has no `@camstack/*` imports.
|
|
48
|
+
*/
|
|
49
|
+
const fs = __importStar(require("node:fs"));
|
|
50
|
+
const path = __importStar(require("node:path"));
|
|
51
|
+
const sqlite_restore_js_1 = require("./sqlite-restore.js");
|
|
52
|
+
exports.PRE_MIGRATION_RESTORE_MARKER = '.pending-migration-restore.json';
|
|
53
|
+
function isRequest(value) {
|
|
54
|
+
return (typeof value === 'object' &&
|
|
55
|
+
value !== null &&
|
|
56
|
+
'livePath' in value &&
|
|
57
|
+
typeof value.livePath === 'string' &&
|
|
58
|
+
'snapshotPath' in value &&
|
|
59
|
+
typeof value.snapshotPath === 'string');
|
|
60
|
+
}
|
|
61
|
+
function requestsOf(raw) {
|
|
62
|
+
const parsed = JSON.parse(raw);
|
|
63
|
+
if (typeof parsed !== 'object' || parsed === null)
|
|
64
|
+
return null;
|
|
65
|
+
if (!('requests' in parsed) || !Array.isArray(parsed.requests))
|
|
66
|
+
return null;
|
|
67
|
+
const requests = parsed.requests;
|
|
68
|
+
return requests.every(isRequest) ? requests.filter(isRequest) : null;
|
|
69
|
+
}
|
|
70
|
+
function inside(dataDir, relative) {
|
|
71
|
+
const root = path.resolve(dataDir);
|
|
72
|
+
const full = path.resolve(root, relative);
|
|
73
|
+
return full === root || full.startsWith(root + path.sep) ? full : null;
|
|
74
|
+
}
|
|
75
|
+
function fsyncDirectory(dir) {
|
|
76
|
+
const fd = fs.openSync(dir, 'r');
|
|
77
|
+
try {
|
|
78
|
+
fs.fsyncSync(fd);
|
|
79
|
+
}
|
|
80
|
+
finally {
|
|
81
|
+
fs.closeSync(fd);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/** Apply the marker if present. Never throws: a launcher that threw would fail every boot. */
|
|
85
|
+
function applyPendingPreMigrationRestore(dataDir, log) {
|
|
86
|
+
const markerPath = path.join(dataDir, exports.PRE_MIGRATION_RESTORE_MARKER);
|
|
87
|
+
if (!fs.existsSync(markerPath))
|
|
88
|
+
return;
|
|
89
|
+
let requests;
|
|
90
|
+
try {
|
|
91
|
+
requests = requestsOf(fs.readFileSync(markerPath, 'utf-8'));
|
|
92
|
+
}
|
|
93
|
+
catch (err) {
|
|
94
|
+
log(`[launcher] Pre-migration restore marker malformed — leaving in place: ${String(err)}`);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (requests === null) {
|
|
98
|
+
log('[launcher] Pre-migration restore marker malformed — leaving in place');
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
let allDone = true;
|
|
102
|
+
for (const request of requests) {
|
|
103
|
+
const live = inside(dataDir, request.livePath);
|
|
104
|
+
const snapshot = inside(dataDir, request.snapshotPath);
|
|
105
|
+
if (live === null || snapshot === null) {
|
|
106
|
+
log(`[launcher] Pre-migration restore: ${request.livePath} is outside the data dir — refused`);
|
|
107
|
+
allDone = false;
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
if (!fs.existsSync(snapshot)) {
|
|
111
|
+
log(`[launcher] Pre-migration restore: snapshot ${request.snapshotPath} is missing`);
|
|
112
|
+
allDone = false;
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
try {
|
|
116
|
+
for (const suffix of sqlite_restore_js_1.SQLITE_SIDECAR_SUFFIXES)
|
|
117
|
+
fs.rmSync(live + suffix, { force: true });
|
|
118
|
+
const temp = `${live}.restore-tmp`;
|
|
119
|
+
fs.copyFileSync(snapshot, temp);
|
|
120
|
+
fs.renameSync(temp, live);
|
|
121
|
+
try {
|
|
122
|
+
fsyncDirectory(path.dirname(live));
|
|
123
|
+
}
|
|
124
|
+
catch (err) {
|
|
125
|
+
log(`[launcher] WARNING Pre-migration restore: could not fsync (${String(err)}) — continuing`);
|
|
126
|
+
}
|
|
127
|
+
log(`[launcher] Pre-migration restore: ${request.snapshotPath} → ${request.livePath}`);
|
|
128
|
+
}
|
|
129
|
+
catch (err) {
|
|
130
|
+
log(`[launcher] Pre-migration restore of ${request.livePath} failed: ${String(err)}`);
|
|
131
|
+
allDone = false;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (allDone)
|
|
135
|
+
fs.rmSync(markerPath, { force: true });
|
|
136
|
+
}
|
package/dist/sqlite-restore.js
CHANGED
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.SQLITE_SNAPSHOT_SUFFIX = void 0;
|
|
36
|
+
exports.SQLITE_SIDECAR_SUFFIXES = exports.SQLITE_SNAPSHOT_SUFFIX = void 0;
|
|
37
37
|
exports.planSqliteRestore = planSqliteRestore;
|
|
38
38
|
exports.applySqliteRestore = applySqliteRestore;
|
|
39
39
|
exports.missingPromisedSnapshots = missingPromisedSnapshots;
|
|
@@ -68,7 +68,8 @@ const fs = __importStar(require("node:fs"));
|
|
|
68
68
|
const path = __importStar(require("node:path"));
|
|
69
69
|
/** Mirrors `DATABASE_SNAPSHOT_SUFFIX` in `@camstack/types` (spec-pinned). */
|
|
70
70
|
exports.SQLITE_SNAPSHOT_SUFFIX = '.backup-snapshot';
|
|
71
|
-
|
|
71
|
+
exports.SQLITE_SIDECAR_SUFFIXES = ['-wal', '-shm', '-journal'];
|
|
72
|
+
const SIDECARS = exports.SQLITE_SIDECAR_SUFFIXES;
|
|
72
73
|
const DATABASE_SUFFIXES = ['.db', '.sqlite', '.sqlite3'];
|
|
73
74
|
/** Decide, from the paths an extraction wrote, what the target needs. */
|
|
74
75
|
function planSqliteRestore(extracted) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camstack/server",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.716",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
]
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@camstack/addon-admin-ui": "1.2.
|
|
54
|
-
"@camstack/addon-agent-ui": "1.2.
|
|
53
|
+
"@camstack/addon-admin-ui": "1.2.539",
|
|
54
|
+
"@camstack/addon-agent-ui": "1.2.306",
|
|
55
55
|
"@camstack/addon-auth": "1.2.174",
|
|
56
56
|
"@camstack/addon-benchmark": "1.2.304",
|
|
57
57
|
"@camstack/addon-decoder-nodeav": "1.2.144",
|
|
@@ -61,9 +61,9 @@
|
|
|
61
61
|
"@camstack/addon-post-analysis": "1.2.656",
|
|
62
62
|
"@camstack/develop": "0.1.41",
|
|
63
63
|
"@camstack/sdk": "1.2.154",
|
|
64
|
-
"@camstack/system": "1.2.
|
|
65
|
-
"@camstack/types": "1.2.
|
|
66
|
-
"@camstack/ui-library": "1.2.
|
|
64
|
+
"@camstack/system": "1.2.535",
|
|
65
|
+
"@camstack/types": "1.2.460",
|
|
66
|
+
"@camstack/ui-library": "1.2.364",
|
|
67
67
|
"@fastify/compress": "^9.0.0",
|
|
68
68
|
"@fastify/cookie": "^11.0.2",
|
|
69
69
|
"@fastify/cors": "^11.2.0",
|