@forzalabs/remora-preview 1.0.0

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.
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fromSnapshot = void 0;
4
+ const Affirm_1 = require("./Affirm");
5
+ /**
6
+ * Serves one already-built document — the standalone `remora-preview <file>` entrypoint, and any
7
+ * static export. Resource views come from the snapshot's own `resources`, so a document generated
8
+ * without them shows the graph and reports that the detail was not included.
9
+ */
10
+ const fromSnapshot = (snapshot) => {
11
+ (0, Affirm_1.affirm)(snapshot, 'Cannot serve an empty preview snapshot');
12
+ (0, Affirm_1.affirm)(snapshot.graph, 'The preview snapshot carries no graph');
13
+ const views = new Map((snapshot.resources ?? []).map(view => [view.id, view]));
14
+ return {
15
+ snapshot: () => snapshot,
16
+ resource: nodeId => views.get(nodeId) ?? null
17
+ };
18
+ };
19
+ exports.fromSnapshot = fromSnapshot;
package/dist/bin.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/bin.js ADDED
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ const node_fs_1 = __importDefault(require("node:fs"));
8
+ const node_path_1 = __importDefault(require("node:path"));
9
+ const Server_1 = require("./Server");
10
+ const Snapshot_1 = require("./Snapshot");
11
+ const USAGE = `remora-preview <snapshot.json> [--port <n>] [--no-open]
12
+
13
+ Serves a preview snapshot produced by "remora graph -f json".
14
+ Read-only: this viewer has no drivers and cannot reach a data source.`;
15
+ /**
16
+ * The standalone entrypoint: someone with a snapshot file and no remora CLI, and no licence.
17
+ * `remora ui-preview` does not go through here — it calls `serve()` with a live provider instead.
18
+ */
19
+ const main = async () => {
20
+ const args = process.argv.slice(2);
21
+ const file = args.find(arg => !arg.startsWith('-'));
22
+ if (!file || args.includes('--help') || args.includes('-h')) {
23
+ console.log(USAGE);
24
+ process.exit(file ? 0 : 1);
25
+ }
26
+ const resolved = node_path_1.default.resolve(file);
27
+ if (!node_fs_1.default.existsSync(resolved)) {
28
+ console.error(`No such snapshot file: ${resolved}`);
29
+ process.exit(1);
30
+ }
31
+ const snapshot = read(resolved);
32
+ const server = await (0, Server_1.serve)({
33
+ provider: (0, Snapshot_1.fromSnapshot)(snapshot),
34
+ port: portOf(args),
35
+ open: !args.includes('--no-open')
36
+ });
37
+ console.log(`Preview of "${snapshot.project}" on ${server.url} (Ctrl+C to stop)`);
38
+ process.on('SIGINT', () => server.close().then(() => process.exit(0)));
39
+ };
40
+ const read = (resolved) => {
41
+ try {
42
+ return JSON.parse(node_fs_1.default.readFileSync(resolved, 'utf-8'));
43
+ }
44
+ catch (error) {
45
+ console.error(`${resolved} is not a parseable preview snapshot: ${error.message}`);
46
+ process.exit(1);
47
+ }
48
+ };
49
+ const portOf = (args) => {
50
+ const index = args.indexOf('--port');
51
+ if (index < 0)
52
+ return undefined;
53
+ const port = parseInt(args[index + 1], 10);
54
+ if (isNaN(port) || port <= 0 || port > 65535) {
55
+ console.error(`Invalid --port value: ${args[index + 1]}`);
56
+ process.exit(1);
57
+ }
58
+ return port;
59
+ };
60
+ main().catch(error => {
61
+ console.error(error.message);
62
+ process.exit(1);
63
+ });
@@ -0,0 +1,13 @@
1
+ /**
2
+ * `@forzalabs/remora-preview` — the read-only viewer for a remora project.
3
+ *
4
+ * It receives one versioned JSON document and renders it. It has no drivers, no credentials and no
5
+ * remora configuration reader, so it physically cannot reach a data source: live sampling stays a
6
+ * capability of the CLI that hosts it. See docs/PREVIEW_PLAN.md §2.
7
+ */
8
+ export { SUPPORTED_FORMAT_VERSION } from './Contract';
9
+ export type { ILineageEdge, ILineageGraph, ILineageNode, ILineageRun, IPreviewCapabilities, IPreviewDiagnostic, IPreviewFile, IPreviewLogs, IPreviewRunResult, IPreviewSaveResult, IPreviewSnapshot, IResourceView, IViewCell, IViewColumn, IViewField, IViewTable, LineageEdgeKind, LineageNodeKind, LineageRunStatus, LineageStatus } from './Contract';
10
+ export { fromSnapshot } from './Snapshot';
11
+ export type { IPreviewProvider } from './Snapshot';
12
+ export { serve } from './Server';
13
+ export type { IPreviewServer, IServeOptions } from './Server';
package/dist/index.js ADDED
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.serve = exports.fromSnapshot = exports.SUPPORTED_FORMAT_VERSION = void 0;
4
+ /**
5
+ * `@forzalabs/remora-preview` — the read-only viewer for a remora project.
6
+ *
7
+ * It receives one versioned JSON document and renders it. It has no drivers, no credentials and no
8
+ * remora configuration reader, so it physically cannot reach a data source: live sampling stays a
9
+ * capability of the CLI that hosts it. See docs/PREVIEW_PLAN.md §2.
10
+ */
11
+ var Contract_1 = require("./Contract");
12
+ Object.defineProperty(exports, "SUPPORTED_FORMAT_VERSION", { enumerable: true, get: function () { return Contract_1.SUPPORTED_FORMAT_VERSION; } });
13
+ var Snapshot_1 = require("./Snapshot");
14
+ Object.defineProperty(exports, "fromSnapshot", { enumerable: true, get: function () { return Snapshot_1.fromSnapshot; } });
15
+ var Server_1 = require("./Server");
16
+ Object.defineProperty(exports, "serve", { enumerable: true, get: function () { return Server_1.serve; } });