@baseplate-dev/project-builder-server 0.3.3 → 0.3.4
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/actions/diff/diff-project.action.d.ts +73 -0
- package/dist/actions/diff/diff-project.action.d.ts.map +1 -0
- package/dist/actions/diff/diff-project.action.js +103 -0
- package/dist/actions/diff/diff-project.action.js.map +1 -0
- package/dist/actions/diff/index.d.ts +2 -0
- package/dist/actions/diff/index.d.ts.map +1 -0
- package/dist/actions/diff/index.js +2 -0
- package/dist/actions/diff/index.js.map +1 -0
- package/dist/actions/index.d.ts +7 -0
- package/dist/actions/index.d.ts.map +1 -0
- package/dist/actions/index.js +7 -0
- package/dist/actions/index.js.map +1 -0
- package/dist/actions/registry.d.ts +270 -0
- package/dist/actions/registry.d.ts.map +1 -0
- package/dist/actions/registry.js +23 -0
- package/dist/actions/registry.js.map +1 -0
- package/dist/actions/snapshot/index.d.ts +5 -0
- package/dist/actions/snapshot/index.d.ts.map +1 -0
- package/dist/actions/snapshot/index.js +5 -0
- package/dist/actions/snapshot/index.js.map +1 -0
- package/dist/actions/snapshot/snapshot-add.action.d.ts +16 -0
- package/dist/actions/snapshot/snapshot-add.action.d.ts.map +1 -0
- package/dist/actions/snapshot/snapshot-add.action.js +80 -0
- package/dist/actions/snapshot/snapshot-add.action.js.map +1 -0
- package/dist/actions/snapshot/snapshot-remove.action.d.ts +15 -0
- package/dist/actions/snapshot/snapshot-remove.action.d.ts.map +1 -0
- package/dist/actions/snapshot/snapshot-remove.action.js +75 -0
- package/dist/actions/snapshot/snapshot-remove.action.js.map +1 -0
- package/dist/actions/snapshot/snapshot-save.action.d.ts +15 -0
- package/dist/actions/snapshot/snapshot-save.action.d.ts.map +1 -0
- package/dist/actions/snapshot/snapshot-save.action.js +82 -0
- package/dist/actions/snapshot/snapshot-save.action.js.map +1 -0
- package/dist/actions/snapshot/snapshot-show.action.d.ts +43 -0
- package/dist/actions/snapshot/snapshot-show.action.d.ts.map +1 -0
- package/dist/actions/snapshot/snapshot-show.action.js +136 -0
- package/dist/actions/snapshot/snapshot-show.action.js.map +1 -0
- package/dist/actions/sync/index.d.ts +2 -0
- package/dist/actions/sync/index.d.ts.map +1 -0
- package/dist/actions/sync/index.js +2 -0
- package/dist/actions/sync/index.js.map +1 -0
- package/dist/actions/sync/sync-project.action.d.ts +14 -0
- package/dist/actions/sync/sync-project.action.d.ts.map +1 -0
- package/dist/actions/sync/sync-project.action.js +94 -0
- package/dist/actions/sync/sync-project.action.js.map +1 -0
- package/dist/actions/template-extractor/discover-generators.action.d.ts +49 -0
- package/dist/actions/template-extractor/discover-generators.action.d.ts.map +1 -0
- package/dist/actions/template-extractor/discover-generators.action.js +57 -0
- package/dist/actions/template-extractor/discover-generators.action.js.map +1 -0
- package/dist/actions/template-extractor/extract-templates.action.d.ts +14 -0
- package/dist/actions/template-extractor/extract-templates.action.d.ts.map +1 -0
- package/dist/actions/template-extractor/extract-templates.action.js +60 -0
- package/dist/actions/template-extractor/extract-templates.action.js.map +1 -0
- package/dist/actions/template-extractor/generate-templates.action.d.ts +12 -0
- package/dist/actions/template-extractor/generate-templates.action.d.ts.map +1 -0
- package/dist/actions/template-extractor/generate-templates.action.js +58 -0
- package/dist/actions/template-extractor/generate-templates.action.js.map +1 -0
- package/dist/actions/template-extractor/index.d.ts +4 -0
- package/dist/actions/template-extractor/index.d.ts.map +1 -0
- package/dist/actions/template-extractor/index.js +4 -0
- package/dist/actions/template-extractor/index.js.map +1 -0
- package/dist/actions/templates/configure-raw-template.action.d.ts +16 -0
- package/dist/actions/templates/configure-raw-template.action.d.ts.map +1 -0
- package/dist/actions/templates/configure-raw-template.action.js +50 -0
- package/dist/actions/templates/configure-raw-template.action.js.map +1 -0
- package/dist/actions/templates/configure-text-template.action.d.ts +27 -0
- package/dist/actions/templates/configure-text-template.action.d.ts.map +1 -0
- package/dist/actions/templates/configure-text-template.action.js +64 -0
- package/dist/actions/templates/configure-text-template.action.js.map +1 -0
- package/dist/actions/templates/configure-ts-template.action.d.ts +18 -0
- package/dist/actions/templates/configure-ts-template.action.d.ts.map +1 -0
- package/dist/actions/templates/configure-ts-template.action.js +58 -0
- package/dist/actions/templates/configure-ts-template.action.js.map +1 -0
- package/dist/actions/templates/delete-template.action.d.ts +15 -0
- package/dist/actions/templates/delete-template.action.d.ts.map +1 -0
- package/dist/actions/templates/delete-template.action.js +49 -0
- package/dist/actions/templates/delete-template.action.js.map +1 -0
- package/dist/actions/templates/index.d.ts +7 -0
- package/dist/actions/templates/index.d.ts.map +1 -0
- package/dist/actions/templates/index.js +7 -0
- package/dist/actions/templates/index.js.map +1 -0
- package/dist/actions/templates/list-templates.action.d.ts +35 -0
- package/dist/actions/templates/list-templates.action.d.ts.map +1 -0
- package/dist/actions/templates/list-templates.action.js +63 -0
- package/dist/actions/templates/list-templates.action.js.map +1 -0
- package/dist/actions/templates/show-template-metadata.action.d.ts +17 -0
- package/dist/actions/templates/show-template-metadata.action.d.ts.map +1 -0
- package/dist/actions/templates/show-template-metadata.action.js +57 -0
- package/dist/actions/templates/show-template-metadata.action.js.map +1 -0
- package/dist/actions/types.d.ts +60 -0
- package/dist/actions/types.d.ts.map +1 -0
- package/dist/actions/types.js +9 -0
- package/dist/actions/types.js.map +1 -0
- package/dist/actions/utils/cli.d.ts +12 -0
- package/dist/actions/utils/cli.d.ts.map +1 -0
- package/dist/actions/utils/cli.js +14 -0
- package/dist/actions/utils/cli.js.map +1 -0
- package/dist/actions/utils/index.d.ts +6 -0
- package/dist/actions/utils/index.d.ts.map +1 -0
- package/dist/actions/utils/index.js +6 -0
- package/dist/actions/utils/index.js.map +1 -0
- package/dist/actions/utils/project-discovery.d.ts +22 -0
- package/dist/actions/utils/project-discovery.d.ts.map +1 -0
- package/dist/actions/utils/project-discovery.js +78 -0
- package/dist/actions/utils/project-discovery.js.map +1 -0
- package/dist/actions/utils/project-id.d.ts +7 -0
- package/dist/actions/utils/project-id.d.ts.map +1 -0
- package/dist/actions/utils/project-id.js +15 -0
- package/dist/actions/utils/project-id.js.map +1 -0
- package/dist/actions/utils/projects.d.ts +9 -0
- package/dist/actions/utils/projects.d.ts.map +1 -0
- package/dist/actions/utils/projects.js +16 -0
- package/dist/actions/utils/projects.js.map +1 -0
- package/dist/actions/utils/run-in-worker.d.ts +13 -0
- package/dist/actions/utils/run-in-worker.d.ts.map +1 -0
- package/dist/actions/utils/run-in-worker.js +78 -0
- package/dist/actions/utils/run-in-worker.js.map +1 -0
- package/dist/actions/utils/trpc.d.ts +16 -0
- package/dist/actions/utils/trpc.d.ts.map +1 -0
- package/dist/actions/utils/trpc.js +19 -0
- package/dist/actions/utils/trpc.js.map +1 -0
- package/dist/actions/utils/worker-script.d.ts +28 -0
- package/dist/actions/utils/worker-script.d.ts.map +1 -0
- package/dist/actions/utils/worker-script.js +55 -0
- package/dist/actions/utils/worker-script.js.map +1 -0
- package/dist/api/context.d.ts.map +1 -1
- package/dist/api/trpc.d.ts.map +1 -1
- package/dist/constants/server.d.ts +1 -1
- package/dist/constants/server.js +1 -1
- package/dist/dev-server/api/router.d.ts +325 -0
- package/dist/dev-server/api/router.d.ts.map +1 -0
- package/dist/dev-server/api/router.js +40 -0
- package/dist/dev-server/api/router.js.map +1 -0
- package/dist/dev-server/api/trpc.d.ts +20 -0
- package/dist/dev-server/api/trpc.d.ts.map +1 -0
- package/dist/dev-server/api/trpc.js +18 -0
- package/dist/dev-server/api/trpc.js.map +1 -0
- package/dist/dev-server/auth-plugin.d.ts +6 -0
- package/dist/dev-server/auth-plugin.d.ts.map +1 -0
- package/dist/dev-server/auth-plugin.js +43 -0
- package/dist/dev-server/auth-plugin.js.map +1 -0
- package/dist/dev-server/get-or-create-config.d.ts +18 -0
- package/dist/dev-server/get-or-create-config.d.ts.map +1 -0
- package/dist/dev-server/get-or-create-config.js +76 -0
- package/dist/dev-server/get-or-create-config.js.map +1 -0
- package/dist/dev-server/index.d.ts +4 -0
- package/dist/dev-server/index.d.ts.map +1 -0
- package/dist/dev-server/index.js +3 -0
- package/dist/dev-server/index.js.map +1 -0
- package/dist/dev-server/mcp/fastify.d.ts +8 -0
- package/dist/dev-server/mcp/fastify.d.ts.map +1 -0
- package/dist/dev-server/mcp/fastify.js +80 -0
- package/dist/dev-server/mcp/fastify.js.map +1 -0
- package/dist/dev-server/mcp/server.d.ts +15 -0
- package/dist/dev-server/mcp/server.d.ts.map +1 -0
- package/dist/dev-server/mcp/server.js +120 -0
- package/dist/dev-server/mcp/server.js.map +1 -0
- package/dist/dev-server/mcp/stdio.d.ts +4 -0
- package/dist/dev-server/mcp/stdio.d.ts.map +1 -0
- package/dist/dev-server/mcp/stdio.js +15 -0
- package/dist/dev-server/mcp/stdio.js.map +1 -0
- package/dist/dev-server/server.d.ts +18 -0
- package/dist/dev-server/server.d.ts.map +1 -0
- package/dist/dev-server/server.js +91 -0
- package/dist/dev-server/server.js.map +1 -0
- package/dist/diff/diff-project.d.ts +37 -20
- package/dist/diff/diff-project.d.ts.map +1 -1
- package/dist/diff/diff-project.js +89 -79
- package/dist/diff/diff-project.js.map +1 -1
- package/dist/fastify-plugins/graceful-shutdown.d.ts.map +1 -0
- package/dist/fastify-plugins/graceful-shutdown.js.map +1 -0
- package/dist/server/builder-service-manager.d.ts +9 -8
- package/dist/server/builder-service-manager.d.ts.map +1 -1
- package/dist/server/builder-service-manager.js +4 -10
- package/dist/server/builder-service-manager.js.map +1 -1
- package/dist/server/server.js +1 -1
- package/dist/server/server.js.map +1 -1
- package/dist/service/builder-service.d.ts +3 -4
- package/dist/service/builder-service.d.ts.map +1 -1
- package/dist/service/builder-service.js +7 -3
- package/dist/service/builder-service.js.map +1 -1
- package/dist/template-extractor/discover-generators.d.ts.map +1 -1
- package/dist/template-extractor/discover-generators.js +1 -1
- package/dist/template-extractor/discover-generators.js.map +1 -1
- package/dist/templates/configure/configure-raw-template.d.ts +13 -0
- package/dist/templates/configure/configure-raw-template.d.ts.map +1 -0
- package/dist/templates/configure/configure-raw-template.js +26 -0
- package/dist/templates/configure/configure-raw-template.js.map +1 -0
- package/dist/templates/configure/configure-text-template.d.ts +18 -0
- package/dist/templates/configure/configure-text-template.d.ts.map +1 -0
- package/dist/templates/configure/configure-text-template.js +48 -0
- package/dist/templates/configure/configure-text-template.js.map +1 -0
- package/dist/templates/configure/configure-ts-template.d.ts +15 -0
- package/dist/templates/configure/configure-ts-template.d.ts.map +1 -0
- package/dist/templates/configure/configure-ts-template.js +44 -0
- package/dist/templates/configure/configure-ts-template.js.map +1 -0
- package/dist/templates/configure/index.d.ts +5 -0
- package/dist/templates/configure/index.d.ts.map +1 -0
- package/dist/templates/configure/index.js +4 -0
- package/dist/templates/configure/index.js.map +1 -0
- package/dist/templates/configure/types.d.ts +7 -0
- package/dist/templates/configure/types.d.ts.map +1 -0
- package/dist/templates/configure/types.js +2 -0
- package/dist/templates/configure/types.js.map +1 -0
- package/dist/templates/delete/delete-template.d.ts +16 -0
- package/dist/templates/delete/delete-template.d.ts.map +1 -0
- package/dist/templates/delete/delete-template.js +45 -0
- package/dist/templates/delete/delete-template.js.map +1 -0
- package/dist/templates/list/list-templates.d.ts +22 -0
- package/dist/templates/list/list-templates.d.ts.map +1 -0
- package/dist/templates/list/list-templates.js +29 -0
- package/dist/templates/list/list-templates.js.map +1 -0
- package/dist/templates/show/show-template-metadata.d.ts +19 -0
- package/dist/templates/show/show-template-metadata.d.ts.map +1 -0
- package/dist/templates/show/show-template-metadata.js +37 -0
- package/dist/templates/show/show-template-metadata.js.map +1 -0
- package/dist/templates/utils/extractor-config.d.ts +18 -0
- package/dist/templates/utils/extractor-config.d.ts.map +1 -0
- package/dist/templates/utils/extractor-config.js +55 -0
- package/dist/templates/utils/extractor-config.js.map +1 -0
- package/dist/templates/utils/infer-exports-from-ts-file.d.ts +10 -0
- package/dist/templates/utils/infer-exports-from-ts-file.d.ts.map +1 -0
- package/dist/templates/utils/infer-exports-from-ts-file.js +87 -0
- package/dist/templates/utils/infer-exports-from-ts-file.js.map +1 -0
- package/dist/templates/utils/resolve-file-path.d.ts +15 -0
- package/dist/templates/utils/resolve-file-path.d.ts.map +1 -0
- package/dist/templates/utils/resolve-file-path.js +48 -0
- package/dist/templates/utils/resolve-file-path.js.map +1 -0
- package/dist/templates/utils/resolve-generator.d.ts +8 -0
- package/dist/templates/utils/resolve-generator.d.ts.map +1 -0
- package/dist/templates/utils/resolve-generator.js +26 -0
- package/dist/templates/utils/resolve-generator.js.map +1 -0
- package/dist/templates/utils/template-metadata.d.ts +14 -0
- package/dist/templates/utils/template-metadata.d.ts.map +1 -0
- package/dist/templates/utils/template-metadata.js +54 -0
- package/dist/templates/utils/template-metadata.js.map +1 -0
- package/package.json +17 -12
- package/dist/server/graceful-shutdown.d.ts.map +0 -1
- package/dist/server/graceful-shutdown.js.map +0 -1
- /package/dist/{server → fastify-plugins}/graceful-shutdown.d.ts +0 -0
- /package/dist/{server → fastify-plugins}/graceful-shutdown.js +0 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Service action to list templates in a specific generator
|
|
4
|
+
*/
|
|
5
|
+
export declare const listTemplatesAction: import("#src/actions/types.js").ServiceAction<{
|
|
6
|
+
generatorDirectory: z.ZodString;
|
|
7
|
+
}, {
|
|
8
|
+
message: z.ZodString;
|
|
9
|
+
generatorName: z.ZodString;
|
|
10
|
+
generatorDirectory: z.ZodString;
|
|
11
|
+
templates: z.ZodArray<z.ZodObject<{
|
|
12
|
+
name: z.ZodString;
|
|
13
|
+
type: z.ZodString;
|
|
14
|
+
sourceFile: z.ZodOptional<z.ZodString>;
|
|
15
|
+
group: z.ZodOptional<z.ZodString>;
|
|
16
|
+
kind: z.ZodOptional<z.ZodString>;
|
|
17
|
+
config: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
18
|
+
}, "strip", z.ZodTypeAny, {
|
|
19
|
+
type: string;
|
|
20
|
+
name: string;
|
|
21
|
+
config: Record<string, any>;
|
|
22
|
+
sourceFile?: string | undefined;
|
|
23
|
+
kind?: string | undefined;
|
|
24
|
+
group?: string | undefined;
|
|
25
|
+
}, {
|
|
26
|
+
type: string;
|
|
27
|
+
name: string;
|
|
28
|
+
config: Record<string, any>;
|
|
29
|
+
sourceFile?: string | undefined;
|
|
30
|
+
kind?: string | undefined;
|
|
31
|
+
group?: string | undefined;
|
|
32
|
+
}>, "many">;
|
|
33
|
+
templateCount: z.ZodNumber;
|
|
34
|
+
}>;
|
|
35
|
+
//# sourceMappingURL=list-templates.action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-templates.action.d.ts","sourceRoot":"","sources":["../../../src/actions/templates/list-templates.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA2BxB;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2C9B,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createServiceAction } from '#src/actions/types.js';
|
|
3
|
+
const listTemplatesInputSchema = {
|
|
4
|
+
generatorDirectory: z
|
|
5
|
+
.string()
|
|
6
|
+
.describe('The directory path containing the generator'),
|
|
7
|
+
};
|
|
8
|
+
const templateInfoSchema = z.object({
|
|
9
|
+
name: z.string().describe('The name of the template'),
|
|
10
|
+
type: z.string().describe('The type of the template'),
|
|
11
|
+
sourceFile: z.string().optional().describe('The source file path'),
|
|
12
|
+
group: z.string().optional().describe('The template group'),
|
|
13
|
+
kind: z.string().optional().describe('The template kind'),
|
|
14
|
+
config: z.record(z.any()).describe('The full template configuration'),
|
|
15
|
+
});
|
|
16
|
+
const listTemplatesOutputSchema = {
|
|
17
|
+
message: z.string().describe('Success message'),
|
|
18
|
+
generatorName: z.string().describe('The name of the generator'),
|
|
19
|
+
generatorDirectory: z.string().describe('The generator directory'),
|
|
20
|
+
templates: z.array(templateInfoSchema).describe('List of templates'),
|
|
21
|
+
templateCount: z.number().describe('Total number of templates'),
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Service action to list templates in a specific generator
|
|
25
|
+
*/
|
|
26
|
+
export const listTemplatesAction = createServiceAction({
|
|
27
|
+
name: 'list-templates',
|
|
28
|
+
title: 'List Templates in Generator',
|
|
29
|
+
description: 'List all templates in a specific generator directory',
|
|
30
|
+
inputSchema: listTemplatesInputSchema,
|
|
31
|
+
outputSchema: listTemplatesOutputSchema,
|
|
32
|
+
handler: async (input, context) => {
|
|
33
|
+
const { generatorDirectory } = input;
|
|
34
|
+
const { logger } = context;
|
|
35
|
+
const { listTemplates } = await import('../../templates/list/list-templates.js');
|
|
36
|
+
const result = await listTemplates({
|
|
37
|
+
generatorDirectory,
|
|
38
|
+
});
|
|
39
|
+
const message = `Found ${result.templateCount} template(s) in generator '${result.generatorName}'`;
|
|
40
|
+
logger.info(message);
|
|
41
|
+
return {
|
|
42
|
+
message,
|
|
43
|
+
generatorName: result.generatorName,
|
|
44
|
+
generatorDirectory,
|
|
45
|
+
templates: result.templates,
|
|
46
|
+
templateCount: result.templateCount,
|
|
47
|
+
};
|
|
48
|
+
},
|
|
49
|
+
writeCliOutput: (output) => {
|
|
50
|
+
console.info(`📦 ${output.generatorName}`);
|
|
51
|
+
console.info(` Directory: ${output.generatorDirectory}`);
|
|
52
|
+
console.info(` Templates: ${output.templateCount}`);
|
|
53
|
+
if (output.templateCount > 0) {
|
|
54
|
+
for (const template of output.templates) {
|
|
55
|
+
const sourceInfo = template.sourceFile
|
|
56
|
+
? ` → ${template.sourceFile}`
|
|
57
|
+
: '';
|
|
58
|
+
console.info(` └─ ${template.name} (${template.type})${sourceInfo}`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
//# sourceMappingURL=list-templates.action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-templates.action.js","sourceRoot":"","sources":["../../../src/actions/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,MAAM,CAAC,SAAS,EAAE,CAAC;gBACxC,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU;oBACpC,CAAC,CAAC,MAAM,QAAQ,CAAC,UAAU,EAAE;oBAC7B,CAAC,CAAC,EAAE,CAAC;gBACP,OAAO,CAAC,IAAI,CAAC,SAAS,QAAQ,CAAC,IAAI,KAAK,QAAQ,CAAC,IAAI,IAAI,UAAU,EAAE,CAAC,CAAC;YACzE,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Service action to show template metadata for a file
|
|
4
|
+
*/
|
|
5
|
+
export declare const showTemplateMetadataAction: import("#src/actions/types.js").ServiceAction<{
|
|
6
|
+
filePath: z.ZodString;
|
|
7
|
+
project: z.ZodOptional<z.ZodString>;
|
|
8
|
+
}, {
|
|
9
|
+
message: z.ZodString;
|
|
10
|
+
filePath: z.ZodString;
|
|
11
|
+
absolutePath: z.ZodString;
|
|
12
|
+
templateName: z.ZodString;
|
|
13
|
+
generator: z.ZodString;
|
|
14
|
+
instanceData: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
15
|
+
hasMetadata: z.ZodBoolean;
|
|
16
|
+
}>;
|
|
17
|
+
//# sourceMappingURL=show-template-metadata.action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"show-template-metadata.action.d.ts","sourceRoot":"","sources":["../../../src/actions/templates/show-template-metadata.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA6BxB;;GAEG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;EAyCrC,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createServiceAction } from '#src/actions/types.js';
|
|
3
|
+
const showTemplateMetadataInputSchema = {
|
|
4
|
+
filePath: z
|
|
5
|
+
.string()
|
|
6
|
+
.describe('Path to file to show metadata for (absolute or relative)'),
|
|
7
|
+
project: z
|
|
8
|
+
.string()
|
|
9
|
+
.optional()
|
|
10
|
+
.describe('Project name or ID (required for relative paths, optional for absolute)'),
|
|
11
|
+
};
|
|
12
|
+
const showTemplateMetadataOutputSchema = {
|
|
13
|
+
message: z.string().describe('Status message'),
|
|
14
|
+
filePath: z.string().describe('The relative file path within the project'),
|
|
15
|
+
absolutePath: z.string().describe('The absolute path to the file'),
|
|
16
|
+
templateName: z.string().describe('The template name (empty if no metadata)'),
|
|
17
|
+
generator: z.string().describe('The generator name (empty if no metadata)'),
|
|
18
|
+
instanceData: z
|
|
19
|
+
.record(z.unknown())
|
|
20
|
+
.optional()
|
|
21
|
+
.describe('Template instance data if available'),
|
|
22
|
+
hasMetadata: z.boolean().describe('Whether the file has template metadata'),
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Service action to show template metadata for a file
|
|
26
|
+
*/
|
|
27
|
+
export const showTemplateMetadataAction = createServiceAction({
|
|
28
|
+
name: 'show-template-metadata',
|
|
29
|
+
title: 'Show Template Metadata',
|
|
30
|
+
description: 'Show template metadata for a file by looking up information from .templates-info.json',
|
|
31
|
+
inputSchema: showTemplateMetadataInputSchema,
|
|
32
|
+
outputSchema: showTemplateMetadataOutputSchema,
|
|
33
|
+
handler: async (input, context) => {
|
|
34
|
+
const { filePath, project } = input;
|
|
35
|
+
const { showTemplateMetadata } = await import('../../templates/show/show-template-metadata.js');
|
|
36
|
+
const result = await showTemplateMetadata({
|
|
37
|
+
filePath,
|
|
38
|
+
project,
|
|
39
|
+
}, context);
|
|
40
|
+
return result;
|
|
41
|
+
},
|
|
42
|
+
writeCliOutput: (output) => {
|
|
43
|
+
if (output.hasMetadata) {
|
|
44
|
+
console.info(`📄 ${output.message}`);
|
|
45
|
+
console.info(` Template: ${output.templateName}`);
|
|
46
|
+
console.info(` Generator: ${output.generator}`);
|
|
47
|
+
if (output.instanceData && Object.keys(output.instanceData).length > 0) {
|
|
48
|
+
console.info(` Instance Data: ${JSON.stringify(output.instanceData, null, 2)}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
console.info(`ℹ️ ${output.message}`);
|
|
53
|
+
console.info(' Use configure-ts-template, configure-text-template, or configure-raw-template to add metadata');
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
//# sourceMappingURL=show-template-metadata.action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"show-template-metadata.action.js","sourceRoot":"","sources":["../../../src/actions/templates/show-template-metadata.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,MAAM,+BAA+B,GAAG;IACtC,QAAQ,EAAE,CAAC;SACR,MAAM,EAAE;SACR,QAAQ,CAAC,0DAA0D,CAAC;IACvE,OAAO,EAAE,CAAC;SACP,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CACP,yEAAyE,CAC1E;CACJ,CAAC;AAEF,MAAM,gCAAgC,GAAG;IACvC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,gBAAgB,CAAC;IAC9C,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,2CAA2C,CAAC;IAC1E,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,+BAA+B,CAAC;IAClE,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,0CAA0C,CAAC;IAC7E,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,2CAA2C,CAAC;IAC3E,YAAY,EAAE,CAAC;SACZ,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC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CAAC;QACH,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,IAAI,CAAC,OAAO,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;YACtC,OAAO,CAAC,IAAI,CACV,iGAAiG,CAClG,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { PluginMetadataWithPaths } from '@baseplate-dev/project-builder-lib';
|
|
2
|
+
import type { Logger } from '@baseplate-dev/sync';
|
|
3
|
+
import type { z } from 'zod';
|
|
4
|
+
import type { BaseplateUserConfig } from '#src/user-config/user-config-schema.js';
|
|
5
|
+
/**
|
|
6
|
+
* A project available to the project builder.
|
|
7
|
+
*/
|
|
8
|
+
export interface ServiceActionProject {
|
|
9
|
+
/** A deterministic ID for the project based off the directory. */
|
|
10
|
+
id: string;
|
|
11
|
+
/** The name of the project. */
|
|
12
|
+
name: string;
|
|
13
|
+
/** The directory of the project. */
|
|
14
|
+
directory: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The context provided to a service action.
|
|
18
|
+
*
|
|
19
|
+
* @remarks All properties must be serializable for worker thread communication. (except logger which we proxy)
|
|
20
|
+
*/
|
|
21
|
+
export interface ServiceActionContext {
|
|
22
|
+
/** The projects available to the project builder. */
|
|
23
|
+
projects: ServiceActionProject[];
|
|
24
|
+
/** The user config for the project builder. */
|
|
25
|
+
userConfig: BaseplateUserConfig;
|
|
26
|
+
/** The plugins available to the project builder. */
|
|
27
|
+
plugins: PluginMetadataWithPaths[];
|
|
28
|
+
/** The logger to write to when executing the service action. */
|
|
29
|
+
logger: Logger;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A service action is a function that can be called by a client via CLI, MCP, or TRPC.
|
|
33
|
+
*/
|
|
34
|
+
export interface ServiceAction<TInputShape extends z.ZodRawShape = z.ZodRawShape, TOutputShape extends z.ZodRawShape = z.ZodRawShape> {
|
|
35
|
+
/** The name of the service action in kebab case. */
|
|
36
|
+
name: string;
|
|
37
|
+
/** The title of the service action. */
|
|
38
|
+
title: string;
|
|
39
|
+
/** The description of the service action. */
|
|
40
|
+
description: string;
|
|
41
|
+
/** The input schema of the service action. */
|
|
42
|
+
inputSchema: TInputShape;
|
|
43
|
+
/** The output schema of the service action. */
|
|
44
|
+
outputSchema: TOutputShape;
|
|
45
|
+
/** The handler of the service action. */
|
|
46
|
+
handler: (input: z.objectOutputType<TInputShape, z.ZodTypeAny, 'strip'>, context: ServiceActionContext) => Promise<z.objectInputType<TOutputShape, z.ZodTypeAny, 'strip'>> | z.objectInputType<TOutputShape, z.ZodTypeAny, 'strip'>;
|
|
47
|
+
/**
|
|
48
|
+
* (Optional) A function to write the output to the CLI.
|
|
49
|
+
* If not provided, the CLI will default to printing the raw JSON output.
|
|
50
|
+
*/
|
|
51
|
+
writeCliOutput?: (output: z.objectInputType<TOutputShape, z.ZodTypeAny, 'strip'>, input: z.objectInputType<TInputShape, z.ZodTypeAny, 'strip'>) => void;
|
|
52
|
+
}
|
|
53
|
+
export type AnyServiceAction = ServiceAction<any, any>;
|
|
54
|
+
/**
|
|
55
|
+
* Create a service action.
|
|
56
|
+
* @param action - The service action to create.
|
|
57
|
+
* @returns The created service action.
|
|
58
|
+
*/
|
|
59
|
+
export declare function createServiceAction<TInputShape extends z.ZodRawShape, TOutputShape extends z.ZodRawShape>(action: ServiceAction<TInputShape, TOutputShape>): ServiceAction<TInputShape, TOutputShape>;
|
|
60
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/actions/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAClF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B,OAAO,KAAK,E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,CAAC,CAAC,eAAe,CAAC,YAAY,EAAE,CAAC,CAAC,UAAU,EAAE,OAAO,CAAC,EAC9D,KAAK,EAAE,CAAC,CAAC,eAAe,CAAC,WAAW,EAAE,CAAC,CAAC,UAAU,EAAE,OAAO,CAAC,KACzD,IAAI,CAAC;CACX;AAGD,MAAM,MAAM,gBAAgB,GAAG,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAEvD;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,WAAW,SAAS,CAAC,CAAC,WAAW,EACjC,YAAY,SAAS,CAAC,CAAC,WAAW,EAElC,MAAM,EAAE,aAAa,CAAC,WAAW,EAAE,YAAY,CAAC,GAC/C,aAAa,CAAC,WAAW,EAAE,YAAY,CAAC,CAE1C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/actions/types.ts"],"names":[],"mappings":"AAuEA;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAIjC,MAAgD;IAEhD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type z from 'zod';
|
|
2
|
+
import type { ServiceAction, ServiceActionContext } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Invoke a service action as a CLI command running the handler and writing the output to the CLI.
|
|
5
|
+
*
|
|
6
|
+
* @param action - The service action to invoke.
|
|
7
|
+
* @param input - The input to pass to the service action.
|
|
8
|
+
* @param context - The context to pass to the service action.
|
|
9
|
+
* @returns The result of the service action.
|
|
10
|
+
*/
|
|
11
|
+
export declare function invokeServiceActionAsCli<TInputShape extends z.ZodRawShape, TOutputShape extends z.ZodRawShape>(action: ServiceAction<TInputShape, TOutputShape>, input: z.infer<z.ZodObject<TInputShape>>, context: ServiceActionContext): Promise<z.infer<z.ZodObject<TOutputShape>>>;
|
|
12
|
+
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../../src/actions/utils/cli.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAEzB,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEvE;;;;;;;GAOG;AACH,wBAAsB,wBAAwB,CAC5C,WAAW,SAAS,CAAC,CAAC,WAAW,EACjC,YAAY,SAAS,CAAC,CAAC,WAAW,EAElC,MAAM,EAAE,aAAa,CAAC,WAAW,EAAE,YAAY,CAAC,EAChD,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,EACxC,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC,CAM7C"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Invoke a service action as a CLI command running the handler and writing the output to the CLI.
|
|
3
|
+
*
|
|
4
|
+
* @param action - The service action to invoke.
|
|
5
|
+
* @param input - The input to pass to the service action.
|
|
6
|
+
* @param context - The context to pass to the service action.
|
|
7
|
+
* @returns The result of the service action.
|
|
8
|
+
*/
|
|
9
|
+
export async function invokeServiceActionAsCli(action, input, context) {
|
|
10
|
+
const result = await action.handler(input, context);
|
|
11
|
+
action.writeCliOutput?.(result, input);
|
|
12
|
+
return result;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../src/actions/utils/cli.ts"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAI5C,MAAgD,EAChD,KAAwC,EACxC,OAA6B;IAE7B,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAEpD,MAAM,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAEvC,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/actions/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/actions/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Logger } from '@baseplate-dev/sync';
|
|
2
|
+
import type { ServiceActionProject } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Checks if a directory contains a valid Baseplate project.
|
|
5
|
+
* @param directory - The directory path to check.
|
|
6
|
+
* @returns True if the directory contains a valid Baseplate project.
|
|
7
|
+
*/
|
|
8
|
+
export declare function isBaseplateProject(directory: string): Promise<boolean>;
|
|
9
|
+
/**
|
|
10
|
+
* Loads project information from a directory containing a Baseplate project.
|
|
11
|
+
* @param directory - The absolute path to the project directory.
|
|
12
|
+
* @returns ServiceActionProject for the project.
|
|
13
|
+
* @throws Error if directory doesn't contain a valid Baseplate project or loading fails.
|
|
14
|
+
*/
|
|
15
|
+
export declare function loadProjectFromDirectory(directory: string): Promise<ServiceActionProject>;
|
|
16
|
+
/**
|
|
17
|
+
* Discovers Baseplate projects from a list of directories.
|
|
18
|
+
* @param directories - Array of directory paths to search.
|
|
19
|
+
* @returns Array of ServiceActionProject for discovered projects.
|
|
20
|
+
*/
|
|
21
|
+
export declare function discoverProjects(directories: string[], logger: Logger): Promise<ServiceActionProject[]>;
|
|
22
|
+
//# sourceMappingURL=project-discovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-discovery.d.ts","sourceRoot":"","sources":["../../../src/actions/utils/project-discovery.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAOlD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAIxD;;;;GAIG;AACH,wBAAsB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAO5E;AAED;;;;;GAKG;AACH,wBAAsB,wBAAwB,CAC5C,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,oBAAoB,CAAC,CAiC/B;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CACpC,WAAW,EAAE,MAAM,EAAE,EACrB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAoCjC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { enhanceErrorWithContext } from '@baseplate-dev/utils';
|
|
2
|
+
import { fileExists } from '@baseplate-dev/utils/node';
|
|
3
|
+
import { readFile } from 'node:fs/promises';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { generateProjectId } from './project-id.js';
|
|
6
|
+
/**
|
|
7
|
+
* Checks if a directory contains a valid Baseplate project.
|
|
8
|
+
* @param directory - The directory path to check.
|
|
9
|
+
* @returns True if the directory contains a valid Baseplate project.
|
|
10
|
+
*/
|
|
11
|
+
export async function isBaseplateProject(directory) {
|
|
12
|
+
const projectDefPath = path.join(directory, 'baseplate', 'project-definition.json');
|
|
13
|
+
return await fileExists(projectDefPath);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Loads project information from a directory containing a Baseplate project.
|
|
17
|
+
* @param directory - The absolute path to the project directory.
|
|
18
|
+
* @returns ServiceActionProject for the project.
|
|
19
|
+
* @throws Error if directory doesn't contain a valid Baseplate project or loading fails.
|
|
20
|
+
*/
|
|
21
|
+
export async function loadProjectFromDirectory(directory) {
|
|
22
|
+
const projectDefPath = path.join(directory, 'baseplate', 'project-definition.json');
|
|
23
|
+
if (!(await fileExists(projectDefPath))) {
|
|
24
|
+
throw new Error(`No project definition found at ${projectDefPath}`);
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
const projectDefContent = await readFile(projectDefPath, 'utf-8');
|
|
28
|
+
const projectDef = JSON.parse(projectDefContent);
|
|
29
|
+
const { name } = projectDef.settings.general;
|
|
30
|
+
if (!name || typeof name !== 'string') {
|
|
31
|
+
throw new Error('Project definition must have a valid name in settings.general.name');
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
id: generateProjectId(directory),
|
|
35
|
+
name,
|
|
36
|
+
directory,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
throw enhanceErrorWithContext(error, `Error loading project definition from ${projectDefPath}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Discovers Baseplate projects from a list of directories.
|
|
45
|
+
* @param directories - Array of directory paths to search.
|
|
46
|
+
* @returns Array of ServiceActionProject for discovered projects.
|
|
47
|
+
*/
|
|
48
|
+
export async function discoverProjects(directories, logger) {
|
|
49
|
+
const projects = [];
|
|
50
|
+
const seenNames = new Set();
|
|
51
|
+
const conflicts = [];
|
|
52
|
+
for (const directory of directories) {
|
|
53
|
+
try {
|
|
54
|
+
const resolvedDir = path.resolve(directory);
|
|
55
|
+
if (await isBaseplateProject(resolvedDir)) {
|
|
56
|
+
const project = await loadProjectFromDirectory(resolvedDir);
|
|
57
|
+
// Check for name conflicts
|
|
58
|
+
if (seenNames.has(project.name)) {
|
|
59
|
+
conflicts.push(project.name);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
seenNames.add(project.name);
|
|
63
|
+
projects.push(project);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
logger.warn(`Warning: Could not load project from ${directory}: ${error instanceof Error ? error.message : String(error)}`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
// Handle name conflicts
|
|
72
|
+
if (conflicts.length > 0) {
|
|
73
|
+
throw new Error(`Duplicate project names found: ${conflicts.join(', ')}. ` +
|
|
74
|
+
'Each project must have a unique name in its project definition.');
|
|
75
|
+
}
|
|
76
|
+
return projects;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=project-discovery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-discovery.js","sourceRoot":"","sources":["../../../src/actions/utils/project-discovery.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAI7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,SAAiB;IACxD,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAC9B,SAAS,EACT,WAAW,EACX,yBAAyB,CAC1B,CAAC;IACF,OAAO,MAAM,UAAU,CAAC,cAAc,CAAC,CAAC;AAC1C,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,SAAiB;IAEjB,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAC9B,SAAS,EACT,WAAW,EACX,yBAAyB,CAC1B,CAAC;IAEF,IAAI,CAAC,CAAC,MAAM,UAAU,CAAC,cAAc,CAA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;oBAChC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;gBAC/B,CAAC;qBAAM,CAAC;oBACN,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;oBAC5B,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBACzB,CAAC;YACH,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,IAAI,CACT,wCAAwC,SAAS,KAAK,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAC/G,CAAC;QACJ,CAAC;IACH,CAAC;IAED,wBAAwB;IACxB,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CACb,kCAAkC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI;YACxD,iEAAiE,CACpE,CAAC;IACJ,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates a deterministic ID for a project based on its directory path.
|
|
3
|
+
* @param directory - The absolute directory path of the project.
|
|
4
|
+
* @returns A deterministic project ID.
|
|
5
|
+
*/
|
|
6
|
+
export declare function generateProjectId(directory: string): string;
|
|
7
|
+
//# sourceMappingURL=project-id.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-id.d.ts","sourceRoot":"","sources":["../../../src/actions/utils/project-id.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAO3D"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import crypto from 'node:crypto';
|
|
2
|
+
/**
|
|
3
|
+
* Generates a deterministic ID for a project based on its directory path.
|
|
4
|
+
* @param directory - The absolute directory path of the project.
|
|
5
|
+
* @returns A deterministic project ID.
|
|
6
|
+
*/
|
|
7
|
+
export function generateProjectId(directory) {
|
|
8
|
+
return crypto
|
|
9
|
+
.createHash('shake256', { outputLength: 9 })
|
|
10
|
+
.update(directory)
|
|
11
|
+
.digest('base64')
|
|
12
|
+
.replaceAll('/', '-')
|
|
13
|
+
.replaceAll('+', '_');
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=project-id.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-id.js","sourceRoot":"","sources":["../../../src/actions/utils/project-id.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,SAAiB;IACjD,OAAO,MAAM;SACV,UAAU,CAAC,UAAU,EAAE,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC;SAC3C,MAAM,CAAC,SAAS,CAAC;SACjB,MAAM,CAAC,QAAQ,CAAC;SAChB,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC;SACpB,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ServiceActionProject } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Get a project by name or ID.
|
|
4
|
+
* @param projects - The list of projects to search through.
|
|
5
|
+
* @param projectNameOrId - The name or ID of the project to find.
|
|
6
|
+
* @returns The project if found, otherwise throws an error.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getProjectByNameOrId(projects: ServiceActionProject[], projectNameOrId: string): ServiceActionProject;
|
|
9
|
+
//# sourceMappingURL=projects.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projects.d.ts","sourceRoot":"","sources":["../../../src/actions/utils/projects.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAExD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,oBAAoB,EAAE,EAChC,eAAe,EAAE,MAAM,GACtB,oBAAoB,CAetB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get a project by name or ID.
|
|
3
|
+
* @param projects - The list of projects to search through.
|
|
4
|
+
* @param projectNameOrId - The name or ID of the project to find.
|
|
5
|
+
* @returns The project if found, otherwise throws an error.
|
|
6
|
+
*/
|
|
7
|
+
export function getProjectByNameOrId(projects, projectNameOrId) {
|
|
8
|
+
const project = projects.find((project) => project.name === projectNameOrId ||
|
|
9
|
+
project.id === projectNameOrId ||
|
|
10
|
+
project.directory === projectNameOrId);
|
|
11
|
+
if (!project) {
|
|
12
|
+
throw new Error(`Project "${projectNameOrId}" not found. Available projects: ${projects.map((p) => p.name).join(', ')}`);
|
|
13
|
+
}
|
|
14
|
+
return project;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=projects.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projects.js","sourceRoot":"","sources":["../../../src/actions/utils/projects.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAClC,QAAgC,EAChC,eAAuB;IAEvB,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAC3B,CAAC,OAAO,EAAE,EAAE,CACV,OAAO,CAAC,IAAI,KAAK,eAAe;QAChC,OAAO,CAAC,EAAE,KAAK,eAAe;QAC9B,OAAO,CAAC,SAAS,KAAK,eAAe,CACxC,CAAC;IAEF,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,YAAY,eAAe,oCAAoC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACxG,CAAC;IACJ,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type z from 'zod';
|
|
2
|
+
import type { ServiceAction, ServiceActionContext } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Executes an action in a new worker thread.
|
|
5
|
+
* Each execution gets a fresh worker thread that loads the latest version of the action file.
|
|
6
|
+
*
|
|
7
|
+
* @param serviceAction - The service action to execute.
|
|
8
|
+
* @param input - Input data for the action
|
|
9
|
+
* @param context - Service action context (must be serializable)
|
|
10
|
+
* @returns Promise that resolves with the action result
|
|
11
|
+
*/
|
|
12
|
+
export declare function runActionInWorker<TInputShape extends z.ZodRawShape, TOutputShape extends z.ZodRawShape>(serviceAction: ServiceAction<TInputShape, TOutputShape>, input: z.objectOutputType<TInputShape, z.ZodTypeAny, 'strip'>, context: ServiceActionContext): Promise<z.objectInputType<TOutputShape, z.ZodTypeAny, 'strip'>>;
|
|
13
|
+
//# sourceMappingURL=run-in-worker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-in-worker.d.ts","sourceRoot":"","sources":["../../../src/actions/utils/run-in-worker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAKzB,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAGvE;;;;;;;;GAQG;AACH,wBAAsB,iBAAiB,CACrC,WAAW,SAAS,CAAC,CAAC,WAAW,EACjC,YAAY,SAAS,CAAC,CAAC,WAAW,EAElC,aAAa,EAAE,aAAa,CAAC,WAAW,EAAE,YAAY,CAAC,EACvD,KAAK,EAAE,CAAC,CAAC,gBAAgB,CAAC,WAAW,EAAE,CAAC,CAAC,UAAU,EAAE,OAAO,CAAC,EAC7D,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,YAAY,EAAE,CAAC,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,CA0FjE"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { Worker } from 'node:worker_threads';
|
|
3
|
+
/**
|
|
4
|
+
* Executes an action in a new worker thread.
|
|
5
|
+
* Each execution gets a fresh worker thread that loads the latest version of the action file.
|
|
6
|
+
*
|
|
7
|
+
* @param serviceAction - The service action to execute.
|
|
8
|
+
* @param input - Input data for the action
|
|
9
|
+
* @param context - Service action context (must be serializable)
|
|
10
|
+
* @returns Promise that resolves with the action result
|
|
11
|
+
*/
|
|
12
|
+
export async function runActionInWorker(serviceAction, input, context) {
|
|
13
|
+
return new Promise((resolve, reject) => {
|
|
14
|
+
const { logger, ...restContext } = context;
|
|
15
|
+
// Log when a new action execution begins with input arguments
|
|
16
|
+
logger.info({
|
|
17
|
+
message: `Starting execution of action: ${serviceAction.name}`,
|
|
18
|
+
input,
|
|
19
|
+
name: serviceAction.name,
|
|
20
|
+
});
|
|
21
|
+
const worker = new Worker(path.join(import.meta.dirname, 'worker-script.js'), {
|
|
22
|
+
workerData: {
|
|
23
|
+
actionName: serviceAction.name,
|
|
24
|
+
input,
|
|
25
|
+
context: restContext,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
const timeout = setTimeout(() => {
|
|
29
|
+
worker.terminate().catch((err) => {
|
|
30
|
+
context.logger.error(err);
|
|
31
|
+
});
|
|
32
|
+
reject(new Error(`Action execution timed out for ${serviceAction.name}`));
|
|
33
|
+
}, 60_000); // 60 second timeout
|
|
34
|
+
worker.on('message', (message) => {
|
|
35
|
+
const typedMessage = message;
|
|
36
|
+
if (typedMessage.type === 'log') {
|
|
37
|
+
logger[typedMessage.level](typedMessage.metadata ?? {}, typedMessage.message);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
clearTimeout(timeout);
|
|
41
|
+
if (typedMessage.type === 'success') {
|
|
42
|
+
logger.info({
|
|
43
|
+
message: `Action ${serviceAction.name} completed successfully`,
|
|
44
|
+
name: serviceAction.name,
|
|
45
|
+
});
|
|
46
|
+
resolve(typedMessage.result);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
logger.error({
|
|
50
|
+
message: `Action ${serviceAction.name} completed with an error`,
|
|
51
|
+
name: serviceAction.name,
|
|
52
|
+
err: typedMessage.error,
|
|
53
|
+
});
|
|
54
|
+
const error = new Error(typedMessage.error.message);
|
|
55
|
+
error.name = typedMessage.error.name ?? 'Error';
|
|
56
|
+
error.stack = typedMessage.error.stack;
|
|
57
|
+
reject(error);
|
|
58
|
+
}
|
|
59
|
+
worker.terminate().catch((err) => {
|
|
60
|
+
context.logger.error(err);
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
worker.on('error', (error) => {
|
|
64
|
+
clearTimeout(timeout);
|
|
65
|
+
reject(error);
|
|
66
|
+
worker.terminate().catch((err) => {
|
|
67
|
+
context.logger.error(err);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
worker.on('exit', (code) => {
|
|
71
|
+
clearTimeout(timeout);
|
|
72
|
+
if (code !== 0) {
|
|
73
|
+
reject(new Error(`Worker stopped with exit code ${code} for action ${serviceAction.name}`));
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=run-in-worker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-in-worker.js","sourceRoot":"","sources":["../../../src/actions/utils/run-in-worker.ts"],"names":[],"mappings":"AAEA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAK7C;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAIrC,aAAuD,EACvD,KAA6D,EAC7D,OAA6B;IAE7B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,EAAE,MAAM,EAAE,GAAG,WAAW,EAAE,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