@ontrails/trails 1.0.0-beta.13 → 1.0.0-beta.15
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/.turbo/turbo-lint.log +1 -1
- package/CHANGELOG.md +29 -0
- package/__tests__/examples.test.ts +39 -0
- package/dist/src/app.d.ts.map +1 -1
- package/dist/src/app.js +12 -1
- package/dist/src/app.js.map +1 -1
- package/dist/src/cli.js +4 -3
- package/dist/src/cli.js.map +1 -1
- package/dist/src/trails/add-surface.d.ts +3 -3
- package/dist/src/trails/add-surface.d.ts.map +1 -1
- package/dist/src/trails/add-surface.js +46 -24
- package/dist/src/trails/add-surface.js.map +1 -1
- package/dist/src/trails/add-trail.d.ts +3 -1
- package/dist/src/trails/add-trail.d.ts.map +1 -1
- package/dist/src/trails/add-trail.js +49 -22
- package/dist/src/trails/add-trail.js.map +1 -1
- package/dist/src/trails/add-trailhead.d.ts +13 -0
- package/dist/src/trails/add-trailhead.d.ts.map +1 -0
- package/dist/src/trails/add-trailhead.js +88 -0
- package/dist/src/trails/add-trailhead.js.map +1 -0
- package/dist/src/trails/add-verify.d.ts +1 -1
- package/dist/src/trails/add-verify.d.ts.map +1 -1
- package/dist/src/trails/add-verify.js +17 -16
- package/dist/src/trails/add-verify.js.map +1 -1
- package/dist/src/trails/create-scaffold.d.ts +1 -1
- package/dist/src/trails/create-scaffold.d.ts.map +1 -1
- package/dist/src/trails/create-scaffold.js +34 -27
- package/dist/src/trails/create-scaffold.js.map +1 -1
- package/dist/src/trails/create.d.ts +9 -13
- package/dist/src/trails/create.d.ts.map +1 -1
- package/dist/src/trails/create.js +40 -35
- package/dist/src/trails/create.js.map +1 -1
- package/dist/src/trails/dev-clean.d.ts +9 -0
- package/dist/src/trails/dev-clean.d.ts.map +1 -0
- package/dist/src/trails/dev-clean.js +66 -0
- package/dist/src/trails/dev-clean.js.map +1 -0
- package/dist/src/trails/dev-reset.d.ts +6 -0
- package/dist/src/trails/dev-reset.d.ts.map +1 -0
- package/dist/src/trails/dev-reset.js +39 -0
- package/dist/src/trails/dev-reset.js.map +1 -0
- package/dist/src/trails/dev-stats.d.ts +7 -0
- package/dist/src/trails/dev-stats.d.ts.map +1 -0
- package/dist/src/trails/dev-stats.js +61 -0
- package/dist/src/trails/dev-stats.js.map +1 -0
- package/dist/src/trails/dev-support.d.ts +64 -0
- package/dist/src/trails/dev-support.d.ts.map +1 -0
- package/dist/src/trails/dev-support.js +181 -0
- package/dist/src/trails/dev-support.js.map +1 -0
- package/dist/src/trails/draft-promote.d.ts +18 -0
- package/dist/src/trails/draft-promote.d.ts.map +1 -0
- package/dist/src/trails/draft-promote.js +400 -0
- package/dist/src/trails/draft-promote.js.map +1 -0
- package/dist/src/trails/guide.d.ts +14 -4
- package/dist/src/trails/guide.d.ts.map +1 -1
- package/dist/src/trails/guide.js +22 -41
- package/dist/src/trails/guide.js.map +1 -1
- package/dist/src/trails/load-app.d.ts +9 -1
- package/dist/src/trails/load-app.d.ts.map +1 -1
- package/dist/src/trails/load-app.js +404 -13
- package/dist/src/trails/load-app.js.map +1 -1
- package/dist/src/trails/project.d.ts.map +1 -1
- package/dist/src/trails/project.js +14 -3
- package/dist/src/trails/project.js.map +1 -1
- package/dist/src/trails/survey.d.ts +6 -60
- package/dist/src/trails/survey.d.ts.map +1 -1
- package/dist/src/trails/survey.js +83 -182
- package/dist/src/trails/survey.js.map +1 -1
- package/dist/src/trails/topo-constants.d.ts +3 -0
- package/dist/src/trails/topo-constants.d.ts.map +1 -0
- package/dist/src/trails/topo-constants.js +3 -0
- package/dist/src/trails/topo-constants.js.map +1 -0
- package/dist/src/trails/topo-export.d.ts +19 -0
- package/dist/src/trails/topo-export.d.ts.map +1 -0
- package/dist/src/trails/topo-export.js +31 -0
- package/dist/src/trails/topo-export.js.map +1 -0
- package/dist/src/trails/topo-history.d.ts +20 -0
- package/dist/src/trails/topo-history.d.ts.map +1 -0
- package/dist/src/trails/topo-history.js +32 -0
- package/dist/src/trails/topo-history.js.map +1 -0
- package/dist/src/trails/topo-pin.d.ts +17 -0
- package/dist/src/trails/topo-pin.d.ts.map +1 -0
- package/dist/src/trails/topo-pin.js +31 -0
- package/dist/src/trails/topo-pin.js.map +1 -0
- package/dist/src/trails/topo-read-support.d.ts +58 -0
- package/dist/src/trails/topo-read-support.d.ts.map +1 -0
- package/dist/src/trails/topo-read-support.js +167 -0
- package/dist/src/trails/topo-read-support.js.map +1 -0
- package/dist/src/trails/topo-reports.d.ts +54 -0
- package/dist/src/trails/topo-reports.d.ts.map +1 -0
- package/dist/src/trails/topo-reports.js +128 -0
- package/dist/src/trails/topo-reports.js.map +1 -0
- package/dist/src/trails/topo-show.d.ts +23 -0
- package/dist/src/trails/topo-show.d.ts.map +1 -0
- package/dist/src/trails/topo-show.js +49 -0
- package/dist/src/trails/topo-show.js.map +1 -0
- package/dist/src/trails/topo-store-support.d.ts +13 -0
- package/dist/src/trails/topo-store-support.d.ts.map +1 -0
- package/dist/src/trails/topo-store-support.js +55 -0
- package/dist/src/trails/topo-store-support.js.map +1 -0
- package/dist/src/trails/topo-support.d.ts +76 -0
- package/dist/src/trails/topo-support.d.ts.map +1 -0
- package/dist/src/trails/topo-support.js +132 -0
- package/dist/src/trails/topo-support.js.map +1 -0
- package/dist/src/trails/topo-unpin.d.ts +20 -0
- package/dist/src/trails/topo-unpin.d.ts.map +1 -0
- package/dist/src/trails/topo-unpin.js +44 -0
- package/dist/src/trails/topo-unpin.js.map +1 -0
- package/dist/src/trails/topo-verify.d.ts +5 -0
- package/dist/src/trails/topo-verify.d.ts.map +1 -0
- package/dist/src/trails/topo-verify.js +24 -0
- package/dist/src/trails/topo-verify.js.map +1 -0
- package/dist/src/trails/topo.d.ts +5 -0
- package/dist/src/trails/topo.d.ts.map +1 -0
- package/dist/src/trails/topo.js +63 -0
- package/dist/src/trails/topo.js.map +1 -0
- package/dist/src/trails/warden.d.ts +3 -2
- package/dist/src/trails/warden.d.ts.map +1 -1
- package/dist/src/trails/warden.js +37 -27
- package/dist/src/trails/warden.js.map +1 -1
- package/dist/src/versions.d.ts +12 -0
- package/dist/src/versions.d.ts.map +1 -0
- package/dist/src/versions.js +23 -0
- package/dist/src/versions.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -7
- package/src/__tests__/add-trail.test.ts +97 -0
- package/src/__tests__/create.test.ts +91 -27
- package/src/__tests__/draft-promote.test.ts +144 -0
- package/src/__tests__/guide.test.ts +10 -5
- package/src/__tests__/load-app.test.ts +406 -2
- package/src/__tests__/survey.test.ts +221 -60
- package/src/__tests__/topo-dev.test.ts +426 -0
- package/src/app.ts +24 -2
- package/src/clack.ts +1 -1
- package/src/cli.ts +4 -3
- package/src/trails/add-surface.ts +150 -0
- package/src/trails/add-trail.ts +46 -10
- package/src/trails/add-verify.ts +11 -6
- package/src/trails/create-scaffold.ts +16 -3
- package/src/trails/create.ts +76 -71
- package/src/trails/dev-clean.ts +77 -0
- package/src/trails/dev-reset.ts +45 -0
- package/src/trails/dev-stats.ts +67 -0
- package/src/trails/dev-support.ts +328 -0
- package/src/trails/draft-promote.ts +739 -0
- package/src/trails/guide.ts +23 -41
- package/src/trails/load-app.ts +556 -14
- package/src/trails/project.ts +17 -3
- package/src/trails/survey.ts +110 -285
- package/src/trails/topo-constants.ts +2 -0
- package/src/trails/topo-export.ts +35 -0
- package/src/trails/topo-history.ts +38 -0
- package/src/trails/topo-pin.ts +38 -0
- package/src/trails/topo-read-support.ts +329 -0
- package/src/trails/topo-reports.ts +228 -0
- package/src/trails/topo-show.ts +54 -0
- package/src/trails/topo-store-support.ts +104 -0
- package/src/trails/topo-support.ts +230 -0
- package/src/trails/topo-unpin.ts +56 -0
- package/src/trails/topo-verify.ts +25 -0
- package/src/trails/topo.ts +69 -0
- package/src/trails/warden.ts +13 -3
- package/src/versions.ts +43 -0
- package/tsconfig.tests.json +10 -0
- package/src/trails/add-trailhead.ts +0 -121
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read-only topo store consumer helpers.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from topo-support.ts to isolate read-only store consumer helpers,
|
|
5
|
+
* keeping module boundaries clean.
|
|
6
|
+
*/
|
|
7
|
+
import { Result } from '@ontrails/core';
|
|
8
|
+
import type { Topo } from '@ontrails/core';
|
|
9
|
+
import type { BriefReport, SurveyListReport } from './topo-reports.js';
|
|
10
|
+
import type { TopoSummaryReport, TopoVerifyReport } from './topo-support.js';
|
|
11
|
+
interface CurrentTrailDetail {
|
|
12
|
+
readonly crosses: string[];
|
|
13
|
+
readonly description: string | null;
|
|
14
|
+
readonly detours: readonly {
|
|
15
|
+
readonly on: string;
|
|
16
|
+
readonly maxAttempts: number;
|
|
17
|
+
}[] | null;
|
|
18
|
+
readonly examples: unknown[];
|
|
19
|
+
readonly id: string;
|
|
20
|
+
readonly intent: 'destroy' | 'read' | 'write';
|
|
21
|
+
readonly kind: string;
|
|
22
|
+
readonly pattern: string | null;
|
|
23
|
+
readonly resources: string[];
|
|
24
|
+
readonly safety: string;
|
|
25
|
+
}
|
|
26
|
+
interface CurrentResourceDetail {
|
|
27
|
+
readonly description: string | null;
|
|
28
|
+
readonly health: 'available' | 'none';
|
|
29
|
+
readonly id: string;
|
|
30
|
+
readonly kind: 'resource';
|
|
31
|
+
readonly lifetime: 'singleton';
|
|
32
|
+
readonly usedBy: string[];
|
|
33
|
+
}
|
|
34
|
+
export declare const buildTopoSummary: (app: Topo, options?: {
|
|
35
|
+
readonly rootDir?: string;
|
|
36
|
+
}) => TopoSummaryReport;
|
|
37
|
+
export declare const buildCurrentTopoBrief: (app: Topo, options?: {
|
|
38
|
+
readonly rootDir?: string;
|
|
39
|
+
}) => BriefReport;
|
|
40
|
+
export declare const buildCurrentTopoList: (app: Topo, options?: {
|
|
41
|
+
readonly rootDir?: string;
|
|
42
|
+
}) => SurveyListReport;
|
|
43
|
+
export declare const buildCurrentGuideEntries: (app: Topo, options?: {
|
|
44
|
+
readonly rootDir?: string;
|
|
45
|
+
}) => readonly {
|
|
46
|
+
readonly description: string;
|
|
47
|
+
readonly exampleCount: number;
|
|
48
|
+
readonly id: string;
|
|
49
|
+
readonly kind: string;
|
|
50
|
+
}[];
|
|
51
|
+
export declare const buildCurrentTopoDetail: (app: Topo, id: string, options?: {
|
|
52
|
+
readonly rootDir?: string;
|
|
53
|
+
}) => CurrentResourceDetail | CurrentTrailDetail | undefined;
|
|
54
|
+
export declare const verifyCurrentTopo: (app: Topo, options?: {
|
|
55
|
+
readonly rootDir?: string;
|
|
56
|
+
}) => Promise<Result<TopoVerifyReport, Error>>;
|
|
57
|
+
export {};
|
|
58
|
+
//# sourceMappingURL=topo-read-support.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"topo-read-support.d.ts","sourceRoot":"","sources":["../../../src/trails/topo-read-support.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,EAML,MAAM,EACP,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,IAAI,EAAgB,MAAM,gBAAgB,CAAC;AAOzD,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAoB7E,UAAU,kBAAkB;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IAC3B,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,QAAQ,CAAC,OAAO,EACZ,SAAS;QAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;KAAE,EAAE,GAChE,IAAI,CAAC;IACT,QAAQ,CAAC,QAAQ,EAAE,OAAO,EAAE,CAAC;IAC7B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,MAAM,EAAE,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E,MAAM,CAAC;CACvB,EAUA,CAAC;AAEF,eAAO,MAAM,sBAAsB,GACjC,KAAK,IAAI,EACT,IAAI,MAAM,EACV,UAAU;IAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,KACtC,qBAAqB,GAAG,kBAAkB,GAAG,SAa/C,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAC5B,KAAK,IAAI,EACT,UAAU;IAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,KACtC,OAAO,CAAC,MAAM,CAAC,gBAAgB,EAAE,KAAK,CAAC,CA0CzC,CAAC"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read-only topo store consumer helpers.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from topo-support.ts to isolate read-only store consumer helpers,
|
|
5
|
+
* keeping module boundaries clean.
|
|
6
|
+
*/
|
|
7
|
+
import { existsSync } from 'node:fs';
|
|
8
|
+
import { join } from 'node:path';
|
|
9
|
+
import { ConflictError, createTopoStore, InternalError, listTopoSnapshots, NotFoundError, Result, } from '@ontrails/core';
|
|
10
|
+
import { deriveTrailsDbPath, deriveTrailsDir, } from '@ontrails/core/internal/trails-db';
|
|
11
|
+
import { readSurfaceLockData } from '@ontrails/schema';
|
|
12
|
+
import { REPORT_CONTRACT_VERSION, REPORT_VERSION } from './topo-constants.js';
|
|
13
|
+
import { createCurrentTopoSnapshot, deriveRootDir, LOCK_PATH, } from './topo-support.js';
|
|
14
|
+
// ---------------------------------------------------------------------------
|
|
15
|
+
// Store helpers
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
const topoStoreRef = (snapshotId) => ({ snapshotId });
|
|
18
|
+
const hasCommittedLock = (trailsDir) => existsSync(join(trailsDir, 'trails.lock'));
|
|
19
|
+
const readSurfaceEntries = (surfaceMapJson) => JSON.parse(surfaceMapJson).entries;
|
|
20
|
+
const buildBriefReportFromStore = (app, store, ref, snapshot) => {
|
|
21
|
+
const trails = store.trails.list({ snapshot: ref });
|
|
22
|
+
const exportRecord = store.exports.get(ref);
|
|
23
|
+
const trailEntries = exportRecord === undefined
|
|
24
|
+
? []
|
|
25
|
+
: readSurfaceEntries(exportRecord.surfaceMapJson).filter((entry) => entry.kind === 'trail');
|
|
26
|
+
return {
|
|
27
|
+
contractVersion: REPORT_CONTRACT_VERSION,
|
|
28
|
+
features: {
|
|
29
|
+
detours: trailEntries.some((entry) => (entry.detours ?? []).length > 0),
|
|
30
|
+
examples: trails.some((trail) => trail.hasExamples),
|
|
31
|
+
outputSchemas: trails.some((trail) => trail.hasOutput),
|
|
32
|
+
resources: snapshot.resourceCount > 0,
|
|
33
|
+
signals: snapshot.signalCount > 0,
|
|
34
|
+
},
|
|
35
|
+
name: app.name,
|
|
36
|
+
resources: snapshot.resourceCount,
|
|
37
|
+
signals: snapshot.signalCount,
|
|
38
|
+
trails: snapshot.trailCount,
|
|
39
|
+
version: REPORT_VERSION,
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
const buildSurveyListFromStore = (store, ref) => {
|
|
43
|
+
const trails = store.trails.list({ snapshot: ref });
|
|
44
|
+
const resources = store.resources.list({ snapshot: ref });
|
|
45
|
+
return {
|
|
46
|
+
count: trails.length,
|
|
47
|
+
entries: trails.map((trail) => ({
|
|
48
|
+
examples: trail.exampleCount,
|
|
49
|
+
id: trail.id,
|
|
50
|
+
kind: trail.kind,
|
|
51
|
+
safety: trail.safety,
|
|
52
|
+
})),
|
|
53
|
+
resourceCount: resources.length,
|
|
54
|
+
resources: resources.map((resource) => ({
|
|
55
|
+
description: resource.description,
|
|
56
|
+
health: resource.health,
|
|
57
|
+
id: resource.id,
|
|
58
|
+
kind: resource.kind,
|
|
59
|
+
lifetime: resource.lifetime,
|
|
60
|
+
usedBy: resource.usedBy,
|
|
61
|
+
})),
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
const buildTrailDetailFromStore = (detail) => ({
|
|
65
|
+
crosses: [...detail.crosses],
|
|
66
|
+
description: detail.description,
|
|
67
|
+
detours: detail.detours,
|
|
68
|
+
examples: [...detail.examples],
|
|
69
|
+
id: detail.id,
|
|
70
|
+
intent: detail.intent,
|
|
71
|
+
kind: detail.kind,
|
|
72
|
+
pattern: detail.pattern,
|
|
73
|
+
resources: [...detail.resources],
|
|
74
|
+
safety: detail.safety,
|
|
75
|
+
});
|
|
76
|
+
const buildResourceDetailFromStore = (resource) => ({
|
|
77
|
+
description: resource.description,
|
|
78
|
+
health: resource.health,
|
|
79
|
+
id: resource.id,
|
|
80
|
+
kind: resource.kind,
|
|
81
|
+
lifetime: resource.lifetime,
|
|
82
|
+
usedBy: [...resource.usedBy],
|
|
83
|
+
});
|
|
84
|
+
// ---------------------------------------------------------------------------
|
|
85
|
+
// withCurrentTopoStore
|
|
86
|
+
// ---------------------------------------------------------------------------
|
|
87
|
+
/**
|
|
88
|
+
* Run a read callback against the latest topo store state.
|
|
89
|
+
*
|
|
90
|
+
* Uses the most recent existing snapshot when available, only creating a new
|
|
91
|
+
* snapshot when no prior snapshot exists. This avoids unbounded snapshot
|
|
92
|
+
* accumulation from
|
|
93
|
+
* read-only operations like survey, guide, and show.
|
|
94
|
+
*/
|
|
95
|
+
const withCurrentTopoStore = (app, rootDir, read) => {
|
|
96
|
+
const [existingSnapshot] = listTopoSnapshots({ limit: 1, rootDir });
|
|
97
|
+
const snapshot = existingSnapshot ?? createCurrentTopoSnapshot(app, { rootDir });
|
|
98
|
+
const store = createTopoStore({ rootDir });
|
|
99
|
+
return read(store, topoStoreRef(snapshot.id), snapshot);
|
|
100
|
+
};
|
|
101
|
+
// ---------------------------------------------------------------------------
|
|
102
|
+
// Public read-only consumers
|
|
103
|
+
// ---------------------------------------------------------------------------
|
|
104
|
+
export const buildTopoSummary = (app, options) => {
|
|
105
|
+
const rootDir = deriveRootDir(options?.rootDir);
|
|
106
|
+
const trailsDir = deriveTrailsDir({ rootDir });
|
|
107
|
+
return withCurrentTopoStore(app, rootDir, (store, ref, snapshot) => ({
|
|
108
|
+
app: buildBriefReportFromStore(app, store, ref, snapshot),
|
|
109
|
+
dbPath: deriveTrailsDbPath({ rootDir }),
|
|
110
|
+
list: buildSurveyListFromStore(store, ref),
|
|
111
|
+
lockExists: hasCommittedLock(trailsDir),
|
|
112
|
+
lockPath: LOCK_PATH,
|
|
113
|
+
}));
|
|
114
|
+
};
|
|
115
|
+
export const buildCurrentTopoBrief = (app, options) => {
|
|
116
|
+
const rootDir = deriveRootDir(options?.rootDir);
|
|
117
|
+
return withCurrentTopoStore(app, rootDir, (store, ref, snapshot) => buildBriefReportFromStore(app, store, ref, snapshot));
|
|
118
|
+
};
|
|
119
|
+
export const buildCurrentTopoList = (app, options) => {
|
|
120
|
+
const rootDir = deriveRootDir(options?.rootDir);
|
|
121
|
+
return withCurrentTopoStore(app, rootDir, (store, ref) => buildSurveyListFromStore(store, ref));
|
|
122
|
+
};
|
|
123
|
+
export const buildCurrentGuideEntries = (app, options) => {
|
|
124
|
+
const rootDir = deriveRootDir(options?.rootDir);
|
|
125
|
+
return withCurrentTopoStore(app, rootDir, (store, ref) => store.trails.list({ snapshot: ref }).map((trail) => ({
|
|
126
|
+
description: trail.description ?? '(no description)',
|
|
127
|
+
exampleCount: trail.exampleCount,
|
|
128
|
+
id: trail.id,
|
|
129
|
+
kind: trail.kind,
|
|
130
|
+
})));
|
|
131
|
+
};
|
|
132
|
+
export const buildCurrentTopoDetail = (app, id, options) => {
|
|
133
|
+
const rootDir = deriveRootDir(options?.rootDir);
|
|
134
|
+
return withCurrentTopoStore(app, rootDir, (store, ref) => {
|
|
135
|
+
const trail = store.trails.get(id, { snapshot: ref });
|
|
136
|
+
if (trail !== undefined) {
|
|
137
|
+
return buildTrailDetailFromStore(trail);
|
|
138
|
+
}
|
|
139
|
+
const resource = store.resources.get(id, { snapshot: ref });
|
|
140
|
+
return resource === undefined
|
|
141
|
+
? undefined
|
|
142
|
+
: buildResourceDetailFromStore(resource);
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
export const verifyCurrentTopo = async (app, options) => {
|
|
146
|
+
const rootDir = deriveRootDir(options?.rootDir);
|
|
147
|
+
const committedLock = await readSurfaceLockData({
|
|
148
|
+
dir: deriveTrailsDir({ rootDir }),
|
|
149
|
+
});
|
|
150
|
+
if (committedLock === null) {
|
|
151
|
+
return Result.err(new NotFoundError('No committed trails.lock found. Run `trails topo export` first.'));
|
|
152
|
+
}
|
|
153
|
+
const currentHash = withCurrentTopoStore(app, rootDir, (store, ref) => store.exports.get(ref)?.surfaceHash);
|
|
154
|
+
if (currentHash === undefined) {
|
|
155
|
+
return Result.err(new InternalError('No stored topo export found for the current topo snapshot'));
|
|
156
|
+
}
|
|
157
|
+
if (committedLock.hash !== currentHash) {
|
|
158
|
+
return Result.err(new ConflictError('trails.lock is stale. Run `trails topo export` to refresh it.'));
|
|
159
|
+
}
|
|
160
|
+
return Result.ok({
|
|
161
|
+
committedHash: committedLock.hash,
|
|
162
|
+
currentHash,
|
|
163
|
+
lockPath: LOCK_PATH,
|
|
164
|
+
stale: false,
|
|
165
|
+
});
|
|
166
|
+
};
|
|
167
|
+
//# sourceMappingURL=topo-read-support.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"topo-read-support.js","sourceRoot":"","sources":["../../../src/trails/topo-read-support.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EACL,aAAa,EACb,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,MAAM,GACP,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,kBAAkB,EAClB,eAAe,GAChB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAIvD,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE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CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC,EAAE,CAAC;QACf,aAAa,EAAE,aAAa,CAAC,IAAI;QACjC,WAAW;QACX,QAAQ,EAAE,SAAS;QACnB,KAAK,EAAE,KAAK;KACb,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { Topo, Trail } from '@ontrails/core';
|
|
2
|
+
export interface BriefReport {
|
|
3
|
+
readonly name: string;
|
|
4
|
+
readonly version: string;
|
|
5
|
+
readonly contractVersion: string;
|
|
6
|
+
readonly features: {
|
|
7
|
+
readonly resources: boolean;
|
|
8
|
+
readonly outputSchemas: boolean;
|
|
9
|
+
readonly examples: boolean;
|
|
10
|
+
readonly detours: boolean;
|
|
11
|
+
readonly signals: boolean;
|
|
12
|
+
};
|
|
13
|
+
readonly trails: number;
|
|
14
|
+
readonly signals: number;
|
|
15
|
+
readonly resources: number;
|
|
16
|
+
}
|
|
17
|
+
export interface SurveyListReport {
|
|
18
|
+
readonly count: number;
|
|
19
|
+
readonly entries: readonly {
|
|
20
|
+
readonly examples: number;
|
|
21
|
+
readonly id: string;
|
|
22
|
+
readonly kind: string;
|
|
23
|
+
readonly safety: string;
|
|
24
|
+
}[];
|
|
25
|
+
readonly resourceCount: number;
|
|
26
|
+
readonly resources: readonly {
|
|
27
|
+
readonly description: string | null;
|
|
28
|
+
readonly health: 'available' | 'none';
|
|
29
|
+
readonly id: string;
|
|
30
|
+
readonly kind: 'resource';
|
|
31
|
+
readonly lifetime: 'singleton';
|
|
32
|
+
readonly usedBy: readonly string[];
|
|
33
|
+
}[];
|
|
34
|
+
}
|
|
35
|
+
export interface TrailDetailReport {
|
|
36
|
+
readonly description: string | null;
|
|
37
|
+
readonly detours: readonly {
|
|
38
|
+
readonly on: string;
|
|
39
|
+
readonly maxAttempts: number;
|
|
40
|
+
}[] | null;
|
|
41
|
+
readonly examples: readonly unknown[];
|
|
42
|
+
readonly crosses: readonly string[];
|
|
43
|
+
readonly id: string;
|
|
44
|
+
readonly intent: 'read' | 'write' | 'destroy';
|
|
45
|
+
readonly kind: string;
|
|
46
|
+
readonly pattern: string | null;
|
|
47
|
+
readonly safety: string;
|
|
48
|
+
readonly resources: readonly string[];
|
|
49
|
+
}
|
|
50
|
+
export declare const deriveBriefReport: (app: Topo) => BriefReport;
|
|
51
|
+
export declare const deriveResourceDetail: (app: Topo, resourceId: string) => object;
|
|
52
|
+
export declare const deriveSurveyList: (app: Topo) => SurveyListReport;
|
|
53
|
+
export declare const deriveTrailDetail: (item: Trail<unknown, unknown>) => TrailDetailReport;
|
|
54
|
+
//# sourceMappingURL=topo-reports.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"topo-reports.d.ts","sourceRoot":"","sources":["../../../src/trails/topo-reports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAIlD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,QAAQ,EAAE;QACjB,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;QAC5B,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;QAChC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;QAC3B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;QAC1B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;KAC3B,CAAC;IACF,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QA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,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;CACvC;AAgCD,eAAO,MAAM,iBAAiB,GAAI,KAAK,IAAI,KAAG,WAmB7C,CAAC;AAwCF,eAAO,MAAM,oBAAoB,GAAI,KAAK,IAAI,EAAE,YAAY,MAAM,KAAG,MAYpE,CAAC;AAiBF,eAAO,MAAM,gBAAgB,GAAI,KAAK,IAAI,KAAG,gBA4B5C,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAC5B,MAAM,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,KAC5B,iBAuBF,CAAC"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { REPORT_CONTRACT_VERSION, REPORT_VERSION } from './topo-constants.js';
|
|
2
|
+
const trailHas = (raw, key) => {
|
|
3
|
+
if (key === 'examples' || key === 'detours') {
|
|
4
|
+
return Array.isArray(raw[key]) && raw[key].length > 0;
|
|
5
|
+
}
|
|
6
|
+
return Boolean(raw[key]);
|
|
7
|
+
};
|
|
8
|
+
const detectFeatures = (app) => {
|
|
9
|
+
const trails = [...app.trails.values()].map((item) => item);
|
|
10
|
+
return {
|
|
11
|
+
hasDetours: trails.some((r) => trailHas(r, 'detours')),
|
|
12
|
+
hasExamples: trails.some((r) => trailHas(r, 'examples')),
|
|
13
|
+
hasOutputSchemas: trails.some((r) => trailHas(r, 'output')),
|
|
14
|
+
hasResources: trails.some((r) => Array.isArray(r['resources']) &&
|
|
15
|
+
r['resources'].length > 0),
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export const deriveBriefReport = (app) => {
|
|
19
|
+
const { hasDetours, hasExamples, hasOutputSchemas, hasResources } = detectFeatures(app);
|
|
20
|
+
return {
|
|
21
|
+
contractVersion: REPORT_CONTRACT_VERSION,
|
|
22
|
+
features: {
|
|
23
|
+
detours: hasDetours,
|
|
24
|
+
examples: hasExamples,
|
|
25
|
+
outputSchemas: hasOutputSchemas,
|
|
26
|
+
resources: hasResources,
|
|
27
|
+
signals: app.signals.size > 0,
|
|
28
|
+
},
|
|
29
|
+
name: app.name,
|
|
30
|
+
resources: app.resources.size,
|
|
31
|
+
signals: app.signals.size,
|
|
32
|
+
trails: app.trails.size,
|
|
33
|
+
version: REPORT_VERSION,
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
const safetyLabel = (entry) => {
|
|
37
|
+
if (entry.intent === 'destroy') {
|
|
38
|
+
return 'destroy';
|
|
39
|
+
}
|
|
40
|
+
if (entry.intent === 'write') {
|
|
41
|
+
return 'write';
|
|
42
|
+
}
|
|
43
|
+
if (entry.intent === 'read') {
|
|
44
|
+
return 'read';
|
|
45
|
+
}
|
|
46
|
+
return '-';
|
|
47
|
+
};
|
|
48
|
+
const buildResourceUsage = (app) => {
|
|
49
|
+
const usage = new Map();
|
|
50
|
+
for (const trailDef of app.list()) {
|
|
51
|
+
for (const declaredResource of trailDef.resources) {
|
|
52
|
+
const users = usage.get(declaredResource.id) ?? [];
|
|
53
|
+
users.push(trailDef.id);
|
|
54
|
+
usage.set(declaredResource.id, users);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return new Map([...usage.entries()].map(([id, users]) => [id, users.toSorted()]));
|
|
58
|
+
};
|
|
59
|
+
const resourceHealthStatus = (resource) => resource.health === undefined ? 'none' : 'available';
|
|
60
|
+
export const deriveResourceDetail = (app, resourceId) => {
|
|
61
|
+
const item = app.getResource(resourceId);
|
|
62
|
+
const usedBy = buildResourceUsage(app).get(resourceId) ?? [];
|
|
63
|
+
return {
|
|
64
|
+
description: item?.description ?? null,
|
|
65
|
+
health: item ? resourceHealthStatus(item) : 'none',
|
|
66
|
+
id: resourceId,
|
|
67
|
+
kind: 'resource',
|
|
68
|
+
lifetime: 'singleton',
|
|
69
|
+
usedBy,
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
const formatResourceList = (app) => {
|
|
73
|
+
const usage = buildResourceUsage(app);
|
|
74
|
+
return app
|
|
75
|
+
.listResources()
|
|
76
|
+
.map((resource) => ({
|
|
77
|
+
description: resource.description ?? null,
|
|
78
|
+
health: resourceHealthStatus(resource),
|
|
79
|
+
id: resource.id,
|
|
80
|
+
kind: resource.kind,
|
|
81
|
+
lifetime: 'singleton',
|
|
82
|
+
usedBy: usage.get(resource.id) ?? [],
|
|
83
|
+
}))
|
|
84
|
+
.toSorted((a, b) => a.id.localeCompare(b.id));
|
|
85
|
+
};
|
|
86
|
+
export const deriveSurveyList = (app) => {
|
|
87
|
+
const items = app.list();
|
|
88
|
+
const entries = items.map((item) => {
|
|
89
|
+
const safety = safetyLabel(item);
|
|
90
|
+
const examples = Array.isArray(item.examples)
|
|
91
|
+
? item.examples.length
|
|
92
|
+
: 0;
|
|
93
|
+
return {
|
|
94
|
+
examples,
|
|
95
|
+
id: item.id,
|
|
96
|
+
kind: item.kind,
|
|
97
|
+
safety,
|
|
98
|
+
};
|
|
99
|
+
});
|
|
100
|
+
const resources = formatResourceList(app);
|
|
101
|
+
return {
|
|
102
|
+
count: items.length,
|
|
103
|
+
entries,
|
|
104
|
+
resourceCount: resources.length,
|
|
105
|
+
resources,
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
export const deriveTrailDetail = (item) => {
|
|
109
|
+
const safety = safetyLabel(item);
|
|
110
|
+
return {
|
|
111
|
+
crosses: item.crosses.toSorted(),
|
|
112
|
+
description: item.description ?? null,
|
|
113
|
+
detours: item.detours.length > 0
|
|
114
|
+
? item.detours.map((d) => ({
|
|
115
|
+
maxAttempts: d.maxAttempts ?? 1,
|
|
116
|
+
on: d.on.name,
|
|
117
|
+
}))
|
|
118
|
+
: null,
|
|
119
|
+
examples: item.examples ?? [],
|
|
120
|
+
id: item.id,
|
|
121
|
+
intent: item.intent,
|
|
122
|
+
kind: item.kind,
|
|
123
|
+
pattern: item.pattern ?? null,
|
|
124
|
+
resources: item.resources.map((resource) => resource.id).toSorted(),
|
|
125
|
+
safety,
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
//# sourceM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KAAK,EAAE,KAAK,CAAC,MAAM;QACnB,OAAO;QACP,aAAa,EAAE,SAAS,CAAC,MAAM;QAC/B,SAAS;KACV,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,IAA6B,EACV,EAAE;IACrB,MAAM,MAAM,GAAG,WAAW,CACxB,IAA4D,CAC7D,CAAC;IAEF,OAAO;QACL,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE;QAChC,WAAW,EAAE,IAAI,CAAC,WAAW,IAAI,IAAI;QACrC,OAAO,EACL,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC;YACrB,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;gBACvB,WAAW,EAAE,CAAC,CAAC,WAAW,IAAI,CAAC;gBAC/B,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,IAAI;aACd,CAAC,CAAC;YACL,CAAC,CAAC,IAAI;QACV,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,EAAE;QAC7B,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,IAAI;QAC7B,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE;QACnE,MAAM;KACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare const topoShowTrail: import("@ontrails/core").Trail<{
|
|
2
|
+
id: string;
|
|
3
|
+
module?: string | undefined;
|
|
4
|
+
rootDir?: string | undefined;
|
|
5
|
+
}, {
|
|
6
|
+
crosses: string[];
|
|
7
|
+
description: unknown;
|
|
8
|
+
detours: unknown;
|
|
9
|
+
examples: unknown[];
|
|
10
|
+
id: string;
|
|
11
|
+
intent: "read" | "write" | "destroy";
|
|
12
|
+
kind: string;
|
|
13
|
+
resources: string[];
|
|
14
|
+
safety: string;
|
|
15
|
+
} | {
|
|
16
|
+
description: string | null;
|
|
17
|
+
health: "available" | "none";
|
|
18
|
+
id: string;
|
|
19
|
+
kind: "resource";
|
|
20
|
+
lifetime: "singleton";
|
|
21
|
+
usedBy: string[];
|
|
22
|
+
}, never>;
|
|
23
|
+
//# sourceMappingURL=topo-show.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"topo-show.d.ts","sourceRoot":"","sources":["../../../src/trails/topo-show.ts"],"names":[],"mappings":"AA2BA,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;SA0BxB,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { NotFoundError, Result, trail } from '@ontrails/core';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { loadApp } from './load-app.js';
|
|
4
|
+
import { buildCurrentTopoDetail } from './topo-read-support.js';
|
|
5
|
+
const trailDetailOutput = z.object({
|
|
6
|
+
crosses: z.array(z.string()),
|
|
7
|
+
description: z.unknown().nullable(),
|
|
8
|
+
detours: z.unknown().nullable(),
|
|
9
|
+
examples: z.array(z.unknown()),
|
|
10
|
+
id: z.string(),
|
|
11
|
+
intent: z.enum(['read', 'write', 'destroy']),
|
|
12
|
+
kind: z.string(),
|
|
13
|
+
resources: z.array(z.string()),
|
|
14
|
+
safety: z.string(),
|
|
15
|
+
});
|
|
16
|
+
const resourceDetailOutput = z.object({
|
|
17
|
+
description: z.string().nullable(),
|
|
18
|
+
health: z.enum(['available', 'none']),
|
|
19
|
+
id: z.string(),
|
|
20
|
+
kind: z.literal('resource'),
|
|
21
|
+
lifetime: z.literal('singleton'),
|
|
22
|
+
usedBy: z.array(z.string()),
|
|
23
|
+
});
|
|
24
|
+
export const topoShowTrail = trail('topo.show', {
|
|
25
|
+
blaze: async (input, ctx) => {
|
|
26
|
+
const rootDir = input.rootDir ?? ctx.cwd ?? process.cwd();
|
|
27
|
+
const app = await loadApp(input.module, rootDir);
|
|
28
|
+
const detail = buildCurrentTopoDetail(app, input.id, { rootDir });
|
|
29
|
+
if (detail !== undefined) {
|
|
30
|
+
return Result.ok(detail);
|
|
31
|
+
}
|
|
32
|
+
return Result.err(new NotFoundError(`Trail or resource not found: ${input.id}`));
|
|
33
|
+
},
|
|
34
|
+
description: 'Show detail for a current trail or resource',
|
|
35
|
+
examples: [
|
|
36
|
+
{
|
|
37
|
+
input: { id: 'topo' },
|
|
38
|
+
name: 'Show current trail detail',
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
input: z.object({
|
|
42
|
+
id: z.string().describe('Trail or resource ID to inspect'),
|
|
43
|
+
module: z.string().optional().describe('Path to the app module'),
|
|
44
|
+
rootDir: z.string().optional().describe('Workspace root directory'),
|
|
45
|
+
}),
|
|
46
|
+
intent: 'read',
|
|
47
|
+
output: z.union([trailDetailOutput, resourceDetailOutput]),
|
|
48
|
+
});
|
|
49
|
+
//# sourceMappingURL=topo-show.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"topo-show.js","sourceRoot":"","sources":["../../../src/trails/topo-show.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACjC,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAC5B,WAAW,EAAE,CAAC,CAAC,OAAO,EAAE,C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BAAsB,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;QAClE,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,OAAO,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;QAC3B,CAAC;QACD,OAAO,MAAM,CAAC,GAAG,CACf,IAAI,aAAa,CAAC,gCAAgC,KAAK,CAAC,EAAE,EAAE,CAAC,CAC9D,CAAC;IACJ,CAAC;IACD,WAAW,EAAE,6CAA6C;IAC1D,QAAQ,EAAE;QACR;YACE,KAAK,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE;YACrB,IAAI,EAAE,2BAA2B;SAClC;KACF;IACD,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC;QACd,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,iCAAiC,CAAC;QAC1D,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,wBAAwB,CAAC;QAChE,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,0BAA0B,CAAC;KACpE,CAAC;IACF,MAAM,EAAE,MAAM;IACd,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,CAAC;CAC3D,CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stored-export pipeline for topo persistence.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from topo-support.ts to isolate store persistence concerns,
|
|
5
|
+
* keeping module boundaries clean.
|
|
6
|
+
*/
|
|
7
|
+
import type { Topo } from '@ontrails/core';
|
|
8
|
+
import { Result } from '@ontrails/core';
|
|
9
|
+
import type { TopoExportReport } from './topo-support.js';
|
|
10
|
+
export declare const exportCurrentTopo: (app: Topo, options?: {
|
|
11
|
+
readonly rootDir?: string;
|
|
12
|
+
}) => Promise<Result<TopoExportReport, Error>>;
|
|
13
|
+
//# sourceMappingURL=topo-store-support.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"topo-store-support.d.ts","sourceRoot":"","sources":["../../../src/trails/topo-store-support.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAgB,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAiB,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAavD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AA4D1D,eAAO,MAAM,iBAAiB,GAC5B,KAAK,IAAI,EACT,UAAU;IAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,KACtC,OAAO,CAAC,MAAM,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAmBzC,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stored-export pipeline for topo persistence.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from topo-support.ts to isolate store persistence concerns,
|
|
5
|
+
* keeping module boundaries clean.
|
|
6
|
+
*/
|
|
7
|
+
import { InternalError, Result } from '@ontrails/core';
|
|
8
|
+
import { createTopoSnapshot, getStoredTopoExport, } from '@ontrails/core/internal/topo-store';
|
|
9
|
+
import { openWriteTrailsDb, deriveTrailsDir, } from '@ontrails/core/internal/trails-db';
|
|
10
|
+
import { writeSurfaceLock, writeSurfaceMap } from '@ontrails/schema';
|
|
11
|
+
import { deriveRootDir, deriveTopoCounts, readGitState, } from './topo-support.js';
|
|
12
|
+
const persistAndReadStoredExport = (app, db, rootDir) => {
|
|
13
|
+
const snapshotResult = createTopoSnapshot(db, app, {
|
|
14
|
+
...readGitState(rootDir),
|
|
15
|
+
...deriveTopoCounts(app),
|
|
16
|
+
});
|
|
17
|
+
if (snapshotResult.isErr()) {
|
|
18
|
+
return snapshotResult;
|
|
19
|
+
}
|
|
20
|
+
const snapshot = snapshotResult.value;
|
|
21
|
+
const storedExport = getStoredTopoExport(db, snapshot.id);
|
|
22
|
+
if (storedExport === undefined) {
|
|
23
|
+
return Result.err(new InternalError(`Missing stored topo export for snapshot "${snapshot.id}"`));
|
|
24
|
+
}
|
|
25
|
+
return Result.ok({
|
|
26
|
+
snapshot,
|
|
27
|
+
storedExport,
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
const writeStoredExportArtifacts = async (storedExport, trailsDir) => {
|
|
31
|
+
const mapPath = await writeSurfaceMap(JSON.parse(storedExport.surfaceMapJson), { dir: trailsDir });
|
|
32
|
+
const lockPath = await writeSurfaceLock(JSON.parse(storedExport.lockContent), { dir: trailsDir });
|
|
33
|
+
return {
|
|
34
|
+
hash: storedExport.surfaceHash,
|
|
35
|
+
lockPath,
|
|
36
|
+
mapPath,
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
export const exportCurrentTopo = async (app, options) => {
|
|
40
|
+
const rootDir = deriveRootDir(options?.rootDir);
|
|
41
|
+
const db = openWriteTrailsDb({ rootDir });
|
|
42
|
+
try {
|
|
43
|
+
const persisted = persistAndReadStoredExport(app, db, rootDir);
|
|
44
|
+
if (persisted.isErr()) {
|
|
45
|
+
return persisted;
|
|
46
|
+
}
|
|
47
|
+
const { snapshot, storedExport } = persisted.value;
|
|
48
|
+
const artifacts = await writeStoredExportArtifacts(storedExport, deriveTrailsDir({ rootDir }));
|
|
49
|
+
return Result.ok({ ...artifacts, snapshot });
|
|
50
|
+
}
|
|
51
|
+
finally {
|
|
52
|
+
db.close();
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=topo-store-support.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"topo-store-support.js","sourceRoot":"","sources":["../../../src/trails/topo-store-support.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,EAA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