@auto-engineer/narrative 1.28.0 → 1.29.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.
- package/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-test.log +3 -3
- package/.turbo/turbo-type-check.log +1 -1
- package/CHANGELOG.md +46 -0
- package/dist/src/index.d.ts +0 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/node.d.ts +0 -8
- package/dist/src/node.d.ts.map +1 -1
- package/dist/src/node.js +0 -3
- package/dist/src/node.js.map +1 -1
- package/dist/src/schema.d.ts +184 -184
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/index.ts +0 -1
- package/src/node.ts +0 -10
- package/dist/src/commands/export-schema-helper.d.ts +0 -2
- package/dist/src/commands/export-schema-helper.d.ts.map +0 -1
- package/dist/src/commands/export-schema-helper.js +0 -47
- package/dist/src/commands/export-schema-helper.js.map +0 -1
- package/dist/src/commands/export-schema.d.ts +0 -23
- package/dist/src/commands/export-schema.d.ts.map +0 -1
- package/dist/src/commands/export-schema.js +0 -105
- package/dist/src/commands/export-schema.js.map +0 -1
- package/dist/src/commands/filestore.node.d.ts +0 -3
- package/dist/src/commands/filestore.node.d.ts.map +0 -1
- package/dist/src/commands/filestore.node.js +0 -11
- package/dist/src/commands/filestore.node.js.map +0 -1
- package/src/commands/export-schema-helper.ts +0 -73
- package/src/commands/export-schema.ts +0 -137
- package/src/commands/filestore.node.ts +0 -12
package/package.json
CHANGED
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
"typescript": "^5.9.2",
|
|
28
28
|
"zod": "^3.22.4",
|
|
29
29
|
"zod-to-json-schema": "^3.22.3",
|
|
30
|
-
"@auto-engineer/file-store": "1.
|
|
31
|
-
"@auto-engineer/message-bus": "1.
|
|
32
|
-
"@auto-engineer/id": "1.
|
|
30
|
+
"@auto-engineer/file-store": "1.29.0",
|
|
31
|
+
"@auto-engineer/message-bus": "1.29.0",
|
|
32
|
+
"@auto-engineer/id": "1.29.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/node": "^20.0.0",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"publishConfig": {
|
|
40
40
|
"access": "public"
|
|
41
41
|
},
|
|
42
|
-
"version": "1.
|
|
42
|
+
"version": "1.29.0",
|
|
43
43
|
"scripts": {
|
|
44
44
|
"build": "tsx scripts/build.ts",
|
|
45
45
|
"test": "vitest run --reporter=dot",
|
package/src/index.ts
CHANGED
|
@@ -24,7 +24,6 @@ export const get = (strings: TemplateStringsArray, ...values: unknown[]) => {
|
|
|
24
24
|
}, '');
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
export type { ExportSchemaEvents } from './commands/export-schema';
|
|
28
27
|
export type { FieldSelector } from './data-narrative-builders';
|
|
29
28
|
|
|
30
29
|
export { sink, source } from './data-narrative-builders';
|
package/src/node.ts
CHANGED
|
@@ -1,11 +1 @@
|
|
|
1
|
-
export {
|
|
2
|
-
commandHandler as exportSchemaCommandHandler,
|
|
3
|
-
type ExportSchemaCommand,
|
|
4
|
-
type ExportSchemaEvents,
|
|
5
|
-
type SchemaExportedEvent,
|
|
6
|
-
type SchemaExportFailedEvent,
|
|
7
|
-
} from './commands/export-schema.js';
|
|
8
1
|
export * from './index.js';
|
|
9
|
-
|
|
10
|
-
import { commandHandler as exportSchemaHandler } from './commands/export-schema.js';
|
|
11
|
-
export const COMMANDS = [exportSchemaHandler];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"export-schema-helper.d.ts","sourceRoot":"","sources":["../../../src/commands/export-schema-helper.ts"],"names":[],"mappings":""}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { NodeFileStore } from '@auto-engineer/file-store/node';
|
|
2
|
-
import createDebug from 'debug';
|
|
3
|
-
import { getFs } from './filestore.node.js';
|
|
4
|
-
const debug = createDebug('auto:narrative:export-schema-helper');
|
|
5
|
-
if ('color' in debug && typeof debug === 'object') {
|
|
6
|
-
debug.color = '4';
|
|
7
|
-
} // blue
|
|
8
|
-
const main = async () => {
|
|
9
|
-
const directory = process.argv[2] || process.cwd();
|
|
10
|
-
debug('Starting export-schema-helper with directory: %s', directory);
|
|
11
|
-
try {
|
|
12
|
-
const getFileStore = getFs;
|
|
13
|
-
const fs = await getFileStore();
|
|
14
|
-
const projectNarrativePath = fs.join(directory, 'node_modules', '@auto-engineer', 'narrative', 'dist', 'src', 'getNarratives.js');
|
|
15
|
-
debug('Importing getNarratives from: %s', projectNarrativePath);
|
|
16
|
-
const { pathToFileURL } = await import('node:url');
|
|
17
|
-
const narrativeModule = (await import(pathToFileURL(projectNarrativePath).href));
|
|
18
|
-
const { getNarratives } = narrativeModule;
|
|
19
|
-
const narrativesPath = fs.join(directory, 'narratives');
|
|
20
|
-
debug('Resolved narratives path: %s', narrativesPath);
|
|
21
|
-
const result = await getNarratives({ vfs: new NodeFileStore(), root: narrativesPath });
|
|
22
|
-
const schema = result.toModel();
|
|
23
|
-
debug('Schema generated with %d narratives, %d messages, %d integrations', schema.narratives.length, schema.messages.length, schema.integrations?.length ?? 0);
|
|
24
|
-
const json = JSON.stringify(schema, null, 2);
|
|
25
|
-
const contextDir = fs.join(directory, '.context');
|
|
26
|
-
const outPath = fs.join(contextDir, 'schema.json');
|
|
27
|
-
await fs.ensureDir(contextDir);
|
|
28
|
-
await fs.writeText(outPath, json);
|
|
29
|
-
debug('Schema written to: %s', outPath);
|
|
30
|
-
const resultPath = fs.join(contextDir, '.export-result.json');
|
|
31
|
-
await fs.writeText(resultPath, JSON.stringify({ success: true, outputPath: outPath }));
|
|
32
|
-
}
|
|
33
|
-
catch (error) {
|
|
34
|
-
debug('Error occurred: %o', error);
|
|
35
|
-
const getFileStore = getFs;
|
|
36
|
-
const fss = await getFileStore();
|
|
37
|
-
const resultPath = fss.join(process.argv[2] || process.cwd(), '.context', '.export-result.json');
|
|
38
|
-
await fss.ensureDir(fss.dirname(resultPath));
|
|
39
|
-
await fss.writeText(resultPath, JSON.stringify({
|
|
40
|
-
success: false,
|
|
41
|
-
error: error instanceof Error ? error.message : 'Unknown error occurred',
|
|
42
|
-
}));
|
|
43
|
-
process.exit(1);
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
void main();
|
|
47
|
-
//# sourceMappingURL=export-schema-helper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"export-schema-helper.js","sourceRoot":"","sources":["../../../src/commands/export-schema-helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,aAAa,EAAE,MAAM,gCAAgC,CAAC;AACxF,OAAO,WAAW,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,MAAM,KAAK,GAAG,WAAW,CAAC,qCAAqC,CAAC,CAAC;AACjE,IAAI,OAAO,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;IACjD,KAA2B,CAAC,KAAK,GAAG,GAAG,CAAC;AAC3C,CAAC,CAAC,OAAO;AAET,MAAM,IAAI,GAAG,KAAK,IAAI,EAAE;IACtB,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IACnD,KAAK,CAAC,kDAAkD,EAAE,SAAS,CAAC,CAAC;IAErE,IAAI,CAAC;QACH,MAAM,YAAY,GAAG,KAA0C,CAAC;QAChE,MAAM,EAAE,GAAuB,MAAM,YAAY,EAAE,CAAC;QACpD,MAAM,oBAAoB,GAAG,EAAE,CAAC,IAAI,CAClC,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,WAAW,EACX,MAAM,EACN,KAAK,EACL,kBAAkB,CACnB,CAAC;QACF,KAAK,CAAC,kCAAkC,EAAE,oBAAoB,CAAC,CAAC;QAEhE,MAAM,EAAE,aAAa,EAAE,GAAG,MA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OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;IACzF,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,KAAK,CAAC,oBAAoB,EAAE,KAAK,CAAC,CAAC;QACnC,MAAM,YAAY,GAAG,KAA0C,CAAC;QAChE,MAAM,GAAG,GAAuB,MAAM,YAAY,EAAE,CAAC;QACrD,MAAM,UAAU,GAAG,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,GAAG,EAAE,EAAE,UAAU,EAAE,qBAAqB,CAAC,CAAC;QACjG,MAAM,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;QAC7C,MAAM,GAAG,CAAC,SAAS,CACjB,UAAU,EACV,IAAI,CAAC,SAAS,CAAC;YACb,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,wBAAwB;SACzE,CAAC,CACH,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC,CAAC;AAEF,KAAK,IAAI,EAAE,CAAC"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { type Command, type Event } from '@auto-engineer/message-bus';
|
|
2
|
-
export type ExportSchemaCommand = Command<'ExportSchema', {
|
|
3
|
-
directory: string;
|
|
4
|
-
}>;
|
|
5
|
-
export type SchemaExportedEvent = Event<'SchemaExported', {
|
|
6
|
-
directory: string;
|
|
7
|
-
outputPath: string;
|
|
8
|
-
}>;
|
|
9
|
-
export type SchemaExportFailedEvent = Event<'SchemaExportFailed', {
|
|
10
|
-
directory: string;
|
|
11
|
-
error: string;
|
|
12
|
-
}>;
|
|
13
|
-
export type ExportSchemaEvents = SchemaExportedEvent | SchemaExportFailedEvent;
|
|
14
|
-
export declare const commandHandler: import("@auto-engineer/message-bus").UnifiedCommandHandler<Readonly<{
|
|
15
|
-
type: string;
|
|
16
|
-
data: Readonly<Record<string, unknown>>;
|
|
17
|
-
timestamp?: Date;
|
|
18
|
-
requestId?: string;
|
|
19
|
-
correlationId?: string;
|
|
20
|
-
}>>;
|
|
21
|
-
export declare function handleExportSchemaCommand(command: ExportSchemaCommand): Promise<SchemaExportedEvent | SchemaExportFailedEvent>;
|
|
22
|
-
export default commandHandler;
|
|
23
|
-
//# sourceMappingURL=export-schema.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"export-schema.d.ts","sourceRoot":"","sources":["../../../src/commands/export-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAwB,KAAK,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAQ5F,MAAM,MAAM,mBAAmB,GAAG,OAAO,CACvC,cAAc,EACd;IACE,SAAS,EAAE,MAAM,CAAC;CACnB,CACF,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,KAAK,CACrC,gBAAgB,EAChB;IACE,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB,CACF,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG,KAAK,CACzC,oBAAoB,EACpB;IACE,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;CACf,CACF,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,mBAAmB,GAAG,uBAAuB,CAAC;AAE/E,eAAO,MAAM,cAAc;;;;;;GA4BzB,CAAC;AAEH,wBAAsB,yBAAyB,CAC7C,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,mBAAmB,GAAG,uBAAuB,CAAC,CAoExD;AAGD,eAAe,cAAc,CAAC"}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { defineCommandHandler } from '@auto-engineer/message-bus';
|
|
2
|
-
import createDebug from 'debug';
|
|
3
|
-
const debug = createDebug('auto:narrative:export-schema');
|
|
4
|
-
if ('color' in debug && typeof debug === 'object') {
|
|
5
|
-
debug.color = '4';
|
|
6
|
-
}
|
|
7
|
-
export const commandHandler = defineCommandHandler({
|
|
8
|
-
name: 'ExportSchema',
|
|
9
|
-
displayName: 'Export Schema',
|
|
10
|
-
alias: 'export:schema',
|
|
11
|
-
description: 'Export flow schemas to context directory',
|
|
12
|
-
category: 'export',
|
|
13
|
-
icon: 'download',
|
|
14
|
-
events: [
|
|
15
|
-
{ name: 'SchemaExported', displayName: 'Schema Exported' },
|
|
16
|
-
{ name: 'SchemaExportFailed', displayName: 'Schema Export Failed' },
|
|
17
|
-
],
|
|
18
|
-
fields: {
|
|
19
|
-
directory: {
|
|
20
|
-
description: 'Context directory path (defaults to current working directory)',
|
|
21
|
-
required: true,
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
examples: ['$ auto export:schema --directory=./.context'],
|
|
25
|
-
handle: async (command) => {
|
|
26
|
-
const typedCommand = command;
|
|
27
|
-
const result = await handleExportSchemaCommand(typedCommand);
|
|
28
|
-
if (result.type === 'SchemaExported') {
|
|
29
|
-
debug('✅ Flow schema written to: %s', result.data.outputPath);
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
debug('❌ Failed to export schema: %s', result.data.error);
|
|
33
|
-
}
|
|
34
|
-
return result;
|
|
35
|
-
},
|
|
36
|
-
});
|
|
37
|
-
export async function handleExportSchemaCommand(command) {
|
|
38
|
-
const directory = command.data.directory ?? process.cwd();
|
|
39
|
-
try {
|
|
40
|
-
// Run the helper script with tsx
|
|
41
|
-
const { getFs } = await import('./filestore.node.js');
|
|
42
|
-
const fs = await getFs();
|
|
43
|
-
const __dirname = fs.dirname(new URL(import.meta.url).href);
|
|
44
|
-
const helperScript = fs.join(__dirname, 'export-schema-helper.js');
|
|
45
|
-
const resultPath = fs.join(directory, '.context', '.export-result.json');
|
|
46
|
-
const { spawnSync } = await import('node:child_process');
|
|
47
|
-
spawnSync('node', [helperScript, directory], {
|
|
48
|
-
cwd: directory,
|
|
49
|
-
encoding: 'utf-8',
|
|
50
|
-
stdio: 'ignore',
|
|
51
|
-
env: {
|
|
52
|
-
...process.env,
|
|
53
|
-
NODE_ENV: process.env.NODE_ENV ?? 'development',
|
|
54
|
-
DEBUG: process.env.DEBUG,
|
|
55
|
-
DEBUG_COLORS: process.env.DEBUG_COLORS,
|
|
56
|
-
DEBUG_HIDE_DATE: 'true',
|
|
57
|
-
},
|
|
58
|
-
});
|
|
59
|
-
const resultJson = await fs.readText(resultPath);
|
|
60
|
-
if (resultJson == null) {
|
|
61
|
-
return {
|
|
62
|
-
type: 'SchemaExportFailed',
|
|
63
|
-
data: { directory, error: 'No result file found' },
|
|
64
|
-
timestamp: new Date(),
|
|
65
|
-
requestId: command.requestId,
|
|
66
|
-
correlationId: command.correlationId,
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
const parsed = JSON.parse(resultJson);
|
|
70
|
-
if (parsed.success === true) {
|
|
71
|
-
return {
|
|
72
|
-
type: 'SchemaExported',
|
|
73
|
-
data: { directory, outputPath: parsed.outputPath ?? '' },
|
|
74
|
-
timestamp: new Date(),
|
|
75
|
-
requestId: command.requestId,
|
|
76
|
-
correlationId: command.correlationId,
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
return {
|
|
81
|
-
type: 'SchemaExportFailed',
|
|
82
|
-
data: { directory, error: parsed.error ?? 'Unknown error' },
|
|
83
|
-
timestamp: new Date(),
|
|
84
|
-
requestId: command.requestId,
|
|
85
|
-
correlationId: command.correlationId,
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
catch (error) {
|
|
90
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
91
|
-
return {
|
|
92
|
-
type: 'SchemaExportFailed',
|
|
93
|
-
data: {
|
|
94
|
-
directory,
|
|
95
|
-
error: message,
|
|
96
|
-
},
|
|
97
|
-
timestamp: new Date(),
|
|
98
|
-
requestId: command.requestId,
|
|
99
|
-
correlationId: command.correlationId,
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
// Default export is the command handler
|
|
104
|
-
export default commandHandler;
|
|
105
|
-
//# sourceMappingURL=export-schema.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"export-schema.js","sourceRoot":"","sources":["../../../src/commands/export-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,oBAAoB,EAAc,MAAM,4BAA4B,CAAC;AAC5F,OAAO,WAAW,MAAM,OAAO,CAAC;AAEhC,MAAM,KAAK,GAAG,WAAW,CAAC,8BAA8B,CAAC,CAAC;AAC1D,IAAI,OAAO,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;IACjD,KAA2B,CAAC,KAAK,GAAG,GAAG,CAAC;AAC3C,CAAC;AA2BD,MAAM,CAAC,MAAM,cAAc,GAAG,oBAAoB,CAAC;IACjD,IAAI,EAAE,cAAc;IACpB,WAAW,EAAE,eAAe;IAC5B,KAAK,EAAE,eAAe;IACtB,WAAW,EAAE,0CAA0C;IACvD,QAAQ,EAAE,QAAQ;IAClB,IAAI,EAAE,UAAU;IAChB,MAAM,EAAE;QACN,EAAE,IAAI,EAAE,gBAAgB,EAAE,WAAW,EAAE,iBAAiB,EAAE;QAC1D,EAAE,IAAI,EAAE,oBAAoB,EAAE,WAAW,EAAE,sBAAsB,EAAE;KACpE;IACD,MAAM,EAAE;QACN,SAAS,EAAE;YACT,WAAW,EAAE,gEAAgE;YAC7E,QAAQ,EAAE,IAAI;SACf;KACF;IACD,QAAQ,EAAE,CAAC,6CAA6C,CAAC;IACzD,MAAM,EAAE,KAAK,EAAE,OAAgB,EAA0D,EAAE;QACzF,MAAM,YAAY,GAAG,OAA8B,CAAC;QACpD,MAAM,MAAM,GAAG,MAAM,yBAAyB,CAAC,YAAY,CAAC,CAAC;QAC7D,IAAI,M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CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvE,OAAO;YACL,IAAI,EAAE,oBAAoB;YAC1B,IAAI,EAAE;gBACJ,SAAS;gBACT,KAAK,EAAE,OAAO;aACf;YACD,SAAS,EAAE,IAAI,IAAI,EAAE;YACrB,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,aAAa,EAAE,OAAO,CAAC,aAAa;SACrC,CAAC;IACJ,CAAC;AACH,CAAC;AAED,wCAAwC;AACxC,eAAe,cAAc,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"filestore.node.d.ts","sourceRoot":"","sources":["../../../src/commands/filestore.node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGzE,wBAAsB,KAAK,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAQzD"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
let fsPromise = null;
|
|
2
|
-
export async function getFs() {
|
|
3
|
-
if (!fsPromise) {
|
|
4
|
-
fsPromise = (async () => {
|
|
5
|
-
const { NodeFileStore } = await import('@auto-engineer/file-store/node');
|
|
6
|
-
return new NodeFileStore();
|
|
7
|
-
})();
|
|
8
|
-
}
|
|
9
|
-
return fsPromise;
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=filestore.node.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"filestore.node.js","sourceRoot":"","sources":["../../../src/commands/filestore.node.ts"],"names":[],"mappings":"AAEA,IAAI,SAAS,GAAuC,IAAI,CAAC;AACzD,MAAM,CAAC,KAAK,UAAU,KAAK;IACzB,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,SAAS,GAAG,CAAC,KAAK,IAAI,EAAE;YACtB,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,MAAM,CAAC,gCAAgC,CAAC,CAAC;YACzE,OAAO,IAAI,aAAa,EAAwB,CAAC;QACnD,CAAC,CAAC,EAAE,CAAC;IACP,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { type IExtendedFileStore, NodeFileStore } from '@auto-engineer/file-store/node';
|
|
2
|
-
import createDebug from 'debug';
|
|
3
|
-
import { getFs } from './filestore.node';
|
|
4
|
-
|
|
5
|
-
const debug = createDebug('auto:narrative:export-schema-helper');
|
|
6
|
-
if ('color' in debug && typeof debug === 'object') {
|
|
7
|
-
(debug as { color: string }).color = '4';
|
|
8
|
-
} // blue
|
|
9
|
-
|
|
10
|
-
const main = async () => {
|
|
11
|
-
const directory = process.argv[2] || process.cwd();
|
|
12
|
-
debug('Starting export-schema-helper with directory: %s', directory);
|
|
13
|
-
|
|
14
|
-
try {
|
|
15
|
-
const getFileStore = getFs as () => Promise<IExtendedFileStore>;
|
|
16
|
-
const fs: IExtendedFileStore = await getFileStore();
|
|
17
|
-
const projectNarrativePath = fs.join(
|
|
18
|
-
directory,
|
|
19
|
-
'node_modules',
|
|
20
|
-
'@auto-engineer',
|
|
21
|
-
'narrative',
|
|
22
|
-
'dist',
|
|
23
|
-
'src',
|
|
24
|
-
'getNarratives.js',
|
|
25
|
-
);
|
|
26
|
-
debug('Importing getNarratives from: %s', projectNarrativePath);
|
|
27
|
-
|
|
28
|
-
const { pathToFileURL } = await import('node:url');
|
|
29
|
-
const narrativeModule = (await import(pathToFileURL(projectNarrativePath).href)) as {
|
|
30
|
-
getNarratives: typeof import('../getNarratives').getNarratives;
|
|
31
|
-
};
|
|
32
|
-
const { getNarratives } = narrativeModule;
|
|
33
|
-
|
|
34
|
-
const narrativesPath = fs.join(directory, 'narratives');
|
|
35
|
-
debug('Resolved narratives path: %s', narrativesPath);
|
|
36
|
-
|
|
37
|
-
const result = await getNarratives({ vfs: new NodeFileStore(), root: narrativesPath });
|
|
38
|
-
const schema = result.toModel();
|
|
39
|
-
debug(
|
|
40
|
-
'Schema generated with %d narratives, %d messages, %d integrations',
|
|
41
|
-
schema.narratives.length,
|
|
42
|
-
schema.messages.length,
|
|
43
|
-
schema.integrations?.length ?? 0,
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
const json = JSON.stringify(schema, null, 2);
|
|
47
|
-
const contextDir = fs.join(directory, '.context');
|
|
48
|
-
const outPath = fs.join(contextDir, 'schema.json');
|
|
49
|
-
|
|
50
|
-
await fs.ensureDir(contextDir);
|
|
51
|
-
await fs.writeText(outPath, json);
|
|
52
|
-
debug('Schema written to: %s', outPath);
|
|
53
|
-
|
|
54
|
-
const resultPath = fs.join(contextDir, '.export-result.json');
|
|
55
|
-
await fs.writeText(resultPath, JSON.stringify({ success: true, outputPath: outPath }));
|
|
56
|
-
} catch (error) {
|
|
57
|
-
debug('Error occurred: %o', error);
|
|
58
|
-
const getFileStore = getFs as () => Promise<IExtendedFileStore>;
|
|
59
|
-
const fss: IExtendedFileStore = await getFileStore();
|
|
60
|
-
const resultPath = fss.join(process.argv[2] || process.cwd(), '.context', '.export-result.json');
|
|
61
|
-
await fss.ensureDir(fss.dirname(resultPath));
|
|
62
|
-
await fss.writeText(
|
|
63
|
-
resultPath,
|
|
64
|
-
JSON.stringify({
|
|
65
|
-
success: false,
|
|
66
|
-
error: error instanceof Error ? error.message : 'Unknown error occurred',
|
|
67
|
-
}),
|
|
68
|
-
);
|
|
69
|
-
process.exit(1);
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
void main();
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import { type Command, defineCommandHandler, type Event } from '@auto-engineer/message-bus';
|
|
2
|
-
import createDebug from 'debug';
|
|
3
|
-
|
|
4
|
-
const debug = createDebug('auto:narrative:export-schema');
|
|
5
|
-
if ('color' in debug && typeof debug === 'object') {
|
|
6
|
-
(debug as { color: string }).color = '4';
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export type ExportSchemaCommand = Command<
|
|
10
|
-
'ExportSchema',
|
|
11
|
-
{
|
|
12
|
-
directory: string;
|
|
13
|
-
}
|
|
14
|
-
>;
|
|
15
|
-
|
|
16
|
-
export type SchemaExportedEvent = Event<
|
|
17
|
-
'SchemaExported',
|
|
18
|
-
{
|
|
19
|
-
directory: string;
|
|
20
|
-
outputPath: string;
|
|
21
|
-
}
|
|
22
|
-
>;
|
|
23
|
-
|
|
24
|
-
export type SchemaExportFailedEvent = Event<
|
|
25
|
-
'SchemaExportFailed',
|
|
26
|
-
{
|
|
27
|
-
directory: string;
|
|
28
|
-
error: string;
|
|
29
|
-
}
|
|
30
|
-
>;
|
|
31
|
-
|
|
32
|
-
export type ExportSchemaEvents = SchemaExportedEvent | SchemaExportFailedEvent;
|
|
33
|
-
|
|
34
|
-
export const commandHandler = defineCommandHandler({
|
|
35
|
-
name: 'ExportSchema',
|
|
36
|
-
displayName: 'Export Schema',
|
|
37
|
-
alias: 'export:schema',
|
|
38
|
-
description: 'Export flow schemas to context directory',
|
|
39
|
-
category: 'export',
|
|
40
|
-
icon: 'download',
|
|
41
|
-
events: [
|
|
42
|
-
{ name: 'SchemaExported', displayName: 'Schema Exported' },
|
|
43
|
-
{ name: 'SchemaExportFailed', displayName: 'Schema Export Failed' },
|
|
44
|
-
],
|
|
45
|
-
fields: {
|
|
46
|
-
directory: {
|
|
47
|
-
description: 'Context directory path (defaults to current working directory)',
|
|
48
|
-
required: true,
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
examples: ['$ auto export:schema --directory=./.context'],
|
|
52
|
-
handle: async (command: Command): Promise<SchemaExportedEvent | SchemaExportFailedEvent> => {
|
|
53
|
-
const typedCommand = command as ExportSchemaCommand;
|
|
54
|
-
const result = await handleExportSchemaCommand(typedCommand);
|
|
55
|
-
if (result.type === 'SchemaExported') {
|
|
56
|
-
debug('✅ Flow schema written to: %s', result.data.outputPath);
|
|
57
|
-
} else {
|
|
58
|
-
debug('❌ Failed to export schema: %s', result.data.error);
|
|
59
|
-
}
|
|
60
|
-
return result;
|
|
61
|
-
},
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
export async function handleExportSchemaCommand(
|
|
65
|
-
command: ExportSchemaCommand,
|
|
66
|
-
): Promise<SchemaExportedEvent | SchemaExportFailedEvent> {
|
|
67
|
-
const directory = command.data.directory ?? process.cwd();
|
|
68
|
-
|
|
69
|
-
try {
|
|
70
|
-
// Run the helper script with tsx
|
|
71
|
-
const { getFs } = await import('./filestore.node.js');
|
|
72
|
-
const fs = await getFs();
|
|
73
|
-
const __dirname = fs.dirname(new URL(import.meta.url).href);
|
|
74
|
-
const helperScript = fs.join(__dirname, 'export-schema-helper.js');
|
|
75
|
-
|
|
76
|
-
const resultPath = fs.join(directory, '.context', '.export-result.json');
|
|
77
|
-
|
|
78
|
-
const { spawnSync } = await import('node:child_process');
|
|
79
|
-
spawnSync('node', [helperScript, directory], {
|
|
80
|
-
cwd: directory,
|
|
81
|
-
encoding: 'utf-8',
|
|
82
|
-
stdio: 'ignore',
|
|
83
|
-
env: {
|
|
84
|
-
...process.env,
|
|
85
|
-
NODE_ENV: process.env.NODE_ENV ?? 'development',
|
|
86
|
-
DEBUG: process.env.DEBUG,
|
|
87
|
-
DEBUG_COLORS: process.env.DEBUG_COLORS,
|
|
88
|
-
DEBUG_HIDE_DATE: 'true',
|
|
89
|
-
},
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
const resultJson = await fs.readText(resultPath);
|
|
93
|
-
if (resultJson == null) {
|
|
94
|
-
return {
|
|
95
|
-
type: 'SchemaExportFailed',
|
|
96
|
-
data: { directory, error: 'No result file found' },
|
|
97
|
-
timestamp: new Date(),
|
|
98
|
-
requestId: command.requestId,
|
|
99
|
-
correlationId: command.correlationId,
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
const parsed = JSON.parse(resultJson) as { success?: boolean; outputPath?: string; error?: string };
|
|
104
|
-
if (parsed.success === true) {
|
|
105
|
-
return {
|
|
106
|
-
type: 'SchemaExported',
|
|
107
|
-
data: { directory, outputPath: parsed.outputPath ?? '' },
|
|
108
|
-
timestamp: new Date(),
|
|
109
|
-
requestId: command.requestId,
|
|
110
|
-
correlationId: command.correlationId,
|
|
111
|
-
};
|
|
112
|
-
} else {
|
|
113
|
-
return {
|
|
114
|
-
type: 'SchemaExportFailed',
|
|
115
|
-
data: { directory, error: parsed.error ?? 'Unknown error' },
|
|
116
|
-
timestamp: new Date(),
|
|
117
|
-
requestId: command.requestId,
|
|
118
|
-
correlationId: command.correlationId,
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
} catch (error: unknown) {
|
|
122
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
123
|
-
return {
|
|
124
|
-
type: 'SchemaExportFailed',
|
|
125
|
-
data: {
|
|
126
|
-
directory,
|
|
127
|
-
error: message,
|
|
128
|
-
},
|
|
129
|
-
timestamp: new Date(),
|
|
130
|
-
requestId: command.requestId,
|
|
131
|
-
correlationId: command.correlationId,
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// Default export is the command handler
|
|
137
|
-
export default commandHandler;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { IExtendedFileStore } from '@auto-engineer/file-store/node';
|
|
2
|
-
|
|
3
|
-
let fsPromise: Promise<IExtendedFileStore> | null = null;
|
|
4
|
-
export async function getFs(): Promise<IExtendedFileStore> {
|
|
5
|
-
if (!fsPromise) {
|
|
6
|
-
fsPromise = (async () => {
|
|
7
|
-
const { NodeFileStore } = await import('@auto-engineer/file-store/node');
|
|
8
|
-
return new NodeFileStore() as IExtendedFileStore;
|
|
9
|
-
})();
|
|
10
|
-
}
|
|
11
|
-
return fsPromise;
|
|
12
|
-
}
|