@open-mercato/cli 0.6.2-develop.3400.1.d948268f50 → 0.6.2-develop.3406.1.2b403f40da

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.
@@ -1,4 +1,4 @@
1
- [build:cli] found 70 entry points
1
+ [build:cli] found 71 entry points
2
2
  Copied create-app/agentic/ → dist/agentic/
3
3
  Discovered 16 standalone guides → dist/agentic/guides/
4
4
  [build:cli] built successfully
@@ -15,6 +15,7 @@ import { createNotificationsExtension } from "./notifications.js";
15
15
  import { createPageMiddlewareExtension } from "./page-middleware.js";
16
16
  import { createSearchExtension } from "./search.js";
17
17
  import { createTranslatableFieldsExtension } from "./translatable-fields.js";
18
+ import { createWorkflowsExtension } from "./workflows.js";
18
19
  function loadGeneratorExtensions() {
19
20
  return [
20
21
  createSearchExtension(),
@@ -33,7 +34,8 @@ function loadGeneratorExtensions() {
33
34
  createCommandInterceptorsExtension(),
34
35
  createPageMiddlewareExtension(),
35
36
  createDashboardWidgetsExtension(),
36
- createInjectionWidgetsExtension()
37
+ createInjectionWidgetsExtension(),
38
+ createWorkflowsExtension()
37
39
  ];
38
40
  }
39
41
  export {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/lib/generators/extensions/index.ts"],
4
- "sourcesContent": ["import type { GeneratorExtension } from '../extension'\nimport { createAiAgentsExtension } from './ai-agents'\nimport { createAiToolsExtension } from './ai-tools'\nimport { createAnalyticsExtension } from './analytics'\nimport { createCommandInterceptorsExtension } from './command-interceptors'\nimport { createComponentOverridesExtension } from './component-overrides'\nimport { createDashboardWidgetsExtension } from './dashboard-widgets'\nimport { createEnrichersExtension } from './enrichers'\nimport { createEventsExtension } from './events'\nimport { createGuardsExtension } from './guards'\nimport { createInboxActionsExtension } from './inbox-actions'\nimport { createInjectionWidgetsExtension } from './injection-widgets'\nimport { createInterceptorsExtension } from './interceptors'\nimport { createMessagesExtension } from './messages'\nimport { createNotificationsExtension } from './notifications'\nimport { createPageMiddlewareExtension } from './page-middleware'\nimport { createSearchExtension } from './search'\nimport { createTranslatableFieldsExtension } from './translatable-fields'\n\nexport function loadGeneratorExtensions(): GeneratorExtension[] {\n return [\n createSearchExtension(),\n createNotificationsExtension(),\n createMessagesExtension(),\n createAiToolsExtension(),\n createAiAgentsExtension(),\n createEventsExtension(),\n createAnalyticsExtension(),\n createTranslatableFieldsExtension(),\n createEnrichersExtension(),\n createInterceptorsExtension(),\n createComponentOverridesExtension(),\n createInboxActionsExtension(),\n createGuardsExtension(),\n createCommandInterceptorsExtension(),\n createPageMiddlewareExtension(),\n createDashboardWidgetsExtension(),\n createInjectionWidgetsExtension(),\n ]\n}\n"],
5
- "mappings": "AACA,SAAS,+BAA+B;AACxC,SAAS,8BAA8B;AACvC,SAAS,gCAAgC;AACzC,SAAS,0CAA0C;AACnD,SAAS,yCAAyC;AAClD,SAAS,uCAAuC;AAChD,SAAS,gCAAgC;AACzC,SAAS,6BAA6B;AACtC,SAAS,6BAA6B;AACtC,SAAS,mCAAmC;AAC5C,SAAS,uCAAuC;AAChD,SAAS,mCAAmC;AAC5C,SAAS,+BAA+B;AACxC,SAAS,oCAAoC;AAC7C,SAAS,qCAAqC;AAC9C,SAAS,6BAA6B;AACtC,SAAS,yCAAyC;AAE3C,SAAS,0BAAgD;AAC9D,SAAO;AAAA,IACL,sBAAsB;AAAA,IACtB,6BAA6B;AAAA,IAC7B,wBAAwB;AAAA,IACxB,uBAAuB;AAAA,IACvB,wBAAwB;AAAA,IACxB,sBAAsB;AAAA,IACtB,yBAAyB;AAAA,IACzB,kCAAkC;AAAA,IAClC,yBAAyB;AAAA,IACzB,4BAA4B;AAAA,IAC5B,kCAAkC;AAAA,IAClC,4BAA4B;AAAA,IAC5B,sBAAsB;AAAA,IACtB,mCAAmC;AAAA,IACnC,8BAA8B;AAAA,IAC9B,gCAAgC;AAAA,IAChC,gCAAgC;AAAA,EAClC;AACF;",
4
+ "sourcesContent": ["import type { GeneratorExtension } from '../extension'\nimport { createAiAgentsExtension } from './ai-agents'\nimport { createAiToolsExtension } from './ai-tools'\nimport { createAnalyticsExtension } from './analytics'\nimport { createCommandInterceptorsExtension } from './command-interceptors'\nimport { createComponentOverridesExtension } from './component-overrides'\nimport { createDashboardWidgetsExtension } from './dashboard-widgets'\nimport { createEnrichersExtension } from './enrichers'\nimport { createEventsExtension } from './events'\nimport { createGuardsExtension } from './guards'\nimport { createInboxActionsExtension } from './inbox-actions'\nimport { createInjectionWidgetsExtension } from './injection-widgets'\nimport { createInterceptorsExtension } from './interceptors'\nimport { createMessagesExtension } from './messages'\nimport { createNotificationsExtension } from './notifications'\nimport { createPageMiddlewareExtension } from './page-middleware'\nimport { createSearchExtension } from './search'\nimport { createTranslatableFieldsExtension } from './translatable-fields'\nimport { createWorkflowsExtension } from './workflows'\n\nexport function loadGeneratorExtensions(): GeneratorExtension[] {\n return [\n createSearchExtension(),\n createNotificationsExtension(),\n createMessagesExtension(),\n createAiToolsExtension(),\n createAiAgentsExtension(),\n createEventsExtension(),\n createAnalyticsExtension(),\n createTranslatableFieldsExtension(),\n createEnrichersExtension(),\n createInterceptorsExtension(),\n createComponentOverridesExtension(),\n createInboxActionsExtension(),\n createGuardsExtension(),\n createCommandInterceptorsExtension(),\n createPageMiddlewareExtension(),\n createDashboardWidgetsExtension(),\n createInjectionWidgetsExtension(),\n createWorkflowsExtension(),\n ]\n}\n"],
5
+ "mappings": "AACA,SAAS,+BAA+B;AACxC,SAAS,8BAA8B;AACvC,SAAS,gCAAgC;AACzC,SAAS,0CAA0C;AACnD,SAAS,yCAAyC;AAClD,SAAS,uCAAuC;AAChD,SAAS,gCAAgC;AACzC,SAAS,6BAA6B;AACtC,SAAS,6BAA6B;AACtC,SAAS,mCAAmC;AAC5C,SAAS,uCAAuC;AAChD,SAAS,mCAAmC;AAC5C,SAAS,+BAA+B;AACxC,SAAS,oCAAoC;AAC7C,SAAS,qCAAqC;AAC9C,SAAS,6BAA6B;AACtC,SAAS,yCAAyC;AAClD,SAAS,gCAAgC;AAElC,SAAS,0BAAgD;AAC9D,SAAO;AAAA,IACL,sBAAsB;AAAA,IACtB,6BAA6B;AAAA,IAC7B,wBAAwB;AAAA,IACxB,uBAAuB;AAAA,IACvB,wBAAwB;AAAA,IACxB,sBAAsB;AAAA,IACtB,yBAAyB;AAAA,IACzB,kCAAkC;AAAA,IAClC,yBAAyB;AAAA,IACzB,4BAA4B;AAAA,IAC5B,kCAAkC;AAAA,IAClC,4BAA4B;AAAA,IAC5B,sBAAsB;AAAA,IACtB,mCAAmC;AAAA,IACnC,8BAA8B;AAAA,IAC9B,gCAAgC;AAAA,IAChC,gCAAgC;AAAA,IAChC,yBAAyB;AAAA,EAC3B;AACF;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,139 @@
1
+ import { VariableDeclarationKind } from "ts-morph";
2
+ import {
3
+ asExpression,
4
+ arrayLiteral,
5
+ arrowFunction,
6
+ binaryExpression,
7
+ identifier,
8
+ methodCall,
9
+ propertyAccess,
10
+ writeValue
11
+ } from "../ast/index.js";
12
+ import {
13
+ moduleEntry,
14
+ namespaceFallback,
15
+ renderGeneratedTsSource
16
+ } from "./shared.js";
17
+ function createWorkflowsExtension() {
18
+ const imports = [];
19
+ const entries = [];
20
+ return {
21
+ id: "registry.workflows",
22
+ outputFiles: ["workflows.generated.ts"],
23
+ scanModule(ctx) {
24
+ ctx.processStandaloneConfig({
25
+ roots: ctx.roots,
26
+ imps: ctx.imps,
27
+ modId: ctx.moduleId,
28
+ relativePath: "workflows.ts",
29
+ prefix: "WORKFLOWS",
30
+ importIdRef: ctx.importIdRef,
31
+ standaloneImports: imports,
32
+ standaloneEntries: entries,
33
+ sharedImports: ctx.sharedImports,
34
+ writeConfig: ({ importName, moduleId }) => moduleEntry(moduleId, [
35
+ {
36
+ name: "config",
37
+ value: namespaceFallback({
38
+ importName,
39
+ members: ["default", "workflowsConfig"],
40
+ fallback: identifier("null"),
41
+ castType: "WorkflowsModuleConfig | null"
42
+ })
43
+ }
44
+ ])
45
+ });
46
+ },
47
+ getModuleDeclContribution() {
48
+ return null;
49
+ },
50
+ generateOutput() {
51
+ const output = renderGeneratedTsSource({
52
+ fileName: "workflows.generated.ts",
53
+ imports: [
54
+ {
55
+ namedImports: [
56
+ { name: "WorkflowsModuleConfig", isTypeOnly: true },
57
+ { name: "CodeWorkflowDefinition", isTypeOnly: true }
58
+ ],
59
+ moduleSpecifier: "@open-mercato/shared/modules/workflows"
60
+ },
61
+ ...imports
62
+ ],
63
+ build(sourceFile) {
64
+ sourceFile.addTypeAlias({
65
+ name: "WorkflowsConfigEntry",
66
+ type: "{ moduleId: string; config: WorkflowsModuleConfig | null }"
67
+ });
68
+ sourceFile.addTypeAlias({
69
+ name: "ResolvedWorkflowsConfigEntry",
70
+ type: "{ moduleId: string; config: WorkflowsModuleConfig }"
71
+ });
72
+ sourceFile.addVariableStatement({
73
+ declarationKind: VariableDeclarationKind.Const,
74
+ declarations: [
75
+ {
76
+ name: "entriesRaw",
77
+ type: "WorkflowsConfigEntry[]",
78
+ initializer: arrayLiteral(entries, writeValue)
79
+ }
80
+ ]
81
+ });
82
+ sourceFile.addVariableStatement({
83
+ declarationKind: VariableDeclarationKind.Const,
84
+ declarations: [
85
+ {
86
+ name: "entries",
87
+ type: "ResolvedWorkflowsConfigEntry[]",
88
+ initializer: asExpression(
89
+ methodCall(identifier("entriesRaw"), "filter", [
90
+ arrowFunction({
91
+ parameters: ["entry"],
92
+ body: binaryExpression(propertyAccess(identifier("entry"), "config"), "!=", null)
93
+ })
94
+ ]),
95
+ "ResolvedWorkflowsConfigEntry[]"
96
+ )
97
+ }
98
+ ]
99
+ });
100
+ sourceFile.addVariableStatement({
101
+ declarationKind: VariableDeclarationKind.Const,
102
+ isExported: true,
103
+ declarations: [
104
+ {
105
+ name: "workflowModuleConfigEntries",
106
+ initializer: identifier("entries")
107
+ },
108
+ {
109
+ name: "workflowModuleConfigs",
110
+ type: "WorkflowsModuleConfig[]",
111
+ initializer: methodCall(identifier("entries"), "map", [
112
+ arrowFunction({
113
+ parameters: ["entry"],
114
+ body: propertyAccess(identifier("entry"), "config")
115
+ })
116
+ ])
117
+ },
118
+ {
119
+ name: "allCodeWorkflows",
120
+ type: "CodeWorkflowDefinition[]",
121
+ initializer: methodCall(identifier("entries"), "flatMap", [
122
+ arrowFunction({
123
+ parameters: ["entry"],
124
+ body: propertyAccess(propertyAccess(identifier("entry"), "config"), "workflows")
125
+ })
126
+ ])
127
+ }
128
+ ]
129
+ });
130
+ }
131
+ });
132
+ return /* @__PURE__ */ new Map([["workflows.generated.ts", output]]);
133
+ }
134
+ };
135
+ }
136
+ export {
137
+ createWorkflowsExtension
138
+ };
139
+ //# sourceMappingURL=workflows.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/lib/generators/extensions/workflows.ts"],
4
+ "sourcesContent": ["import { VariableDeclarationKind, type WriterFunction } from 'ts-morph'\nimport type { GeneratorExtension } from '../extension'\nimport {\n asExpression,\n arrayLiteral,\n arrowFunction,\n binaryExpression,\n identifier,\n methodCall,\n propertyAccess,\n writeValue,\n} from '../ast'\nimport {\n moduleEntry,\n namespaceFallback,\n namespaceImportSpec,\n renderGeneratedTsSource,\n} from './shared'\n\nexport function createWorkflowsExtension(): GeneratorExtension {\n const imports: Array<ReturnType<typeof namespaceImportSpec>> = []\n const entries: WriterFunction[] = []\n\n return {\n id: 'registry.workflows',\n outputFiles: ['workflows.generated.ts'],\n scanModule(ctx) {\n ctx.processStandaloneConfig({\n roots: ctx.roots,\n imps: ctx.imps,\n modId: ctx.moduleId,\n relativePath: 'workflows.ts',\n prefix: 'WORKFLOWS',\n importIdRef: ctx.importIdRef,\n standaloneImports: imports,\n standaloneEntries: entries,\n sharedImports: ctx.sharedImports,\n writeConfig: ({ importName, moduleId }) =>\n moduleEntry(moduleId, [\n {\n name: 'config',\n value: namespaceFallback({\n importName,\n members: ['default', 'workflowsConfig'],\n fallback: identifier('null'),\n castType: 'WorkflowsModuleConfig | null',\n }),\n },\n ]),\n })\n },\n getModuleDeclContribution() {\n return null\n },\n generateOutput() {\n const output = renderGeneratedTsSource({\n fileName: 'workflows.generated.ts',\n imports: [\n {\n namedImports: [\n { name: 'WorkflowsModuleConfig', isTypeOnly: true },\n { name: 'CodeWorkflowDefinition', isTypeOnly: true },\n ],\n moduleSpecifier: '@open-mercato/shared/modules/workflows',\n },\n ...imports,\n ],\n build(sourceFile) {\n sourceFile.addTypeAlias({\n name: 'WorkflowsConfigEntry',\n type: '{ moduleId: string; config: WorkflowsModuleConfig | null }',\n })\n sourceFile.addTypeAlias({\n name: 'ResolvedWorkflowsConfigEntry',\n type: '{ moduleId: string; config: WorkflowsModuleConfig }',\n })\n sourceFile.addVariableStatement({\n declarationKind: VariableDeclarationKind.Const,\n declarations: [\n {\n name: 'entriesRaw',\n type: 'WorkflowsConfigEntry[]',\n initializer: arrayLiteral(entries, writeValue),\n },\n ],\n })\n sourceFile.addVariableStatement({\n declarationKind: VariableDeclarationKind.Const,\n declarations: [\n {\n name: 'entries',\n type: 'ResolvedWorkflowsConfigEntry[]',\n initializer: asExpression(\n methodCall(identifier('entriesRaw'), 'filter', [\n arrowFunction({\n parameters: ['entry'],\n body: binaryExpression(propertyAccess(identifier('entry'), 'config'), '!=', null),\n }),\n ]),\n 'ResolvedWorkflowsConfigEntry[]',\n ),\n },\n ],\n })\n sourceFile.addVariableStatement({\n declarationKind: VariableDeclarationKind.Const,\n isExported: true,\n declarations: [\n {\n name: 'workflowModuleConfigEntries',\n initializer: identifier('entries'),\n },\n {\n name: 'workflowModuleConfigs',\n type: 'WorkflowsModuleConfig[]',\n initializer: methodCall(identifier('entries'), 'map', [\n arrowFunction({\n parameters: ['entry'],\n body: propertyAccess(identifier('entry'), 'config'),\n }),\n ]),\n },\n {\n name: 'allCodeWorkflows',\n type: 'CodeWorkflowDefinition[]',\n initializer: methodCall(identifier('entries'), 'flatMap', [\n arrowFunction({\n parameters: ['entry'],\n body: propertyAccess(propertyAccess(identifier('entry'), 'config'), 'workflows'),\n }),\n ]),\n },\n ],\n })\n },\n })\n\n return new Map([['workflows.generated.ts', output]])\n },\n }\n}\n"],
5
+ "mappings": "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",
6
+ "names": []
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-mercato/cli",
3
- "version": "0.6.2-develop.3400.1.d948268f50",
3
+ "version": "0.6.2-develop.3406.1.2b403f40da",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "exports": {
@@ -59,8 +59,8 @@
59
59
  "@mikro-orm/decorators": "^7.0.15",
60
60
  "@mikro-orm/migrations": "^7.0.15",
61
61
  "@mikro-orm/postgresql": "^7.0.15",
62
- "@open-mercato/queue": "0.6.2-develop.3400.1.d948268f50",
63
- "@open-mercato/shared": "0.6.2-develop.3400.1.d948268f50",
62
+ "@open-mercato/queue": "0.6.2-develop.3406.1.2b403f40da",
63
+ "@open-mercato/shared": "0.6.2-develop.3406.1.2b403f40da",
64
64
  "cross-spawn": "^7.0.6",
65
65
  "pg": "8.20.0",
66
66
  "semver": "^7.8.0",
@@ -70,10 +70,10 @@
70
70
  "typescript": "^5.9.3"
71
71
  },
72
72
  "peerDependencies": {
73
- "@open-mercato/shared": "0.6.2-develop.3400.1.d948268f50"
73
+ "@open-mercato/shared": "0.6.2-develop.3406.1.2b403f40da"
74
74
  },
75
75
  "devDependencies": {
76
- "@open-mercato/shared": "0.6.2-develop.3400.1.d948268f50",
76
+ "@open-mercato/shared": "0.6.2-develop.3406.1.2b403f40da",
77
77
  "@types/jest": "^30.0.0",
78
78
  "jest": "^30.4.2",
79
79
  "ts-jest": "^29.4.9"
@@ -16,6 +16,7 @@ import { createNotificationsExtension } from './notifications'
16
16
  import { createPageMiddlewareExtension } from './page-middleware'
17
17
  import { createSearchExtension } from './search'
18
18
  import { createTranslatableFieldsExtension } from './translatable-fields'
19
+ import { createWorkflowsExtension } from './workflows'
19
20
 
20
21
  export function loadGeneratorExtensions(): GeneratorExtension[] {
21
22
  return [
@@ -36,5 +37,6 @@ export function loadGeneratorExtensions(): GeneratorExtension[] {
36
37
  createPageMiddlewareExtension(),
37
38
  createDashboardWidgetsExtension(),
38
39
  createInjectionWidgetsExtension(),
40
+ createWorkflowsExtension(),
39
41
  ]
40
42
  }
@@ -0,0 +1,141 @@
1
+ import { VariableDeclarationKind, type WriterFunction } from 'ts-morph'
2
+ import type { GeneratorExtension } from '../extension'
3
+ import {
4
+ asExpression,
5
+ arrayLiteral,
6
+ arrowFunction,
7
+ binaryExpression,
8
+ identifier,
9
+ methodCall,
10
+ propertyAccess,
11
+ writeValue,
12
+ } from '../ast'
13
+ import {
14
+ moduleEntry,
15
+ namespaceFallback,
16
+ namespaceImportSpec,
17
+ renderGeneratedTsSource,
18
+ } from './shared'
19
+
20
+ export function createWorkflowsExtension(): GeneratorExtension {
21
+ const imports: Array<ReturnType<typeof namespaceImportSpec>> = []
22
+ const entries: WriterFunction[] = []
23
+
24
+ return {
25
+ id: 'registry.workflows',
26
+ outputFiles: ['workflows.generated.ts'],
27
+ scanModule(ctx) {
28
+ ctx.processStandaloneConfig({
29
+ roots: ctx.roots,
30
+ imps: ctx.imps,
31
+ modId: ctx.moduleId,
32
+ relativePath: 'workflows.ts',
33
+ prefix: 'WORKFLOWS',
34
+ importIdRef: ctx.importIdRef,
35
+ standaloneImports: imports,
36
+ standaloneEntries: entries,
37
+ sharedImports: ctx.sharedImports,
38
+ writeConfig: ({ importName, moduleId }) =>
39
+ moduleEntry(moduleId, [
40
+ {
41
+ name: 'config',
42
+ value: namespaceFallback({
43
+ importName,
44
+ members: ['default', 'workflowsConfig'],
45
+ fallback: identifier('null'),
46
+ castType: 'WorkflowsModuleConfig | null',
47
+ }),
48
+ },
49
+ ]),
50
+ })
51
+ },
52
+ getModuleDeclContribution() {
53
+ return null
54
+ },
55
+ generateOutput() {
56
+ const output = renderGeneratedTsSource({
57
+ fileName: 'workflows.generated.ts',
58
+ imports: [
59
+ {
60
+ namedImports: [
61
+ { name: 'WorkflowsModuleConfig', isTypeOnly: true },
62
+ { name: 'CodeWorkflowDefinition', isTypeOnly: true },
63
+ ],
64
+ moduleSpecifier: '@open-mercato/shared/modules/workflows',
65
+ },
66
+ ...imports,
67
+ ],
68
+ build(sourceFile) {
69
+ sourceFile.addTypeAlias({
70
+ name: 'WorkflowsConfigEntry',
71
+ type: '{ moduleId: string; config: WorkflowsModuleConfig | null }',
72
+ })
73
+ sourceFile.addTypeAlias({
74
+ name: 'ResolvedWorkflowsConfigEntry',
75
+ type: '{ moduleId: string; config: WorkflowsModuleConfig }',
76
+ })
77
+ sourceFile.addVariableStatement({
78
+ declarationKind: VariableDeclarationKind.Const,
79
+ declarations: [
80
+ {
81
+ name: 'entriesRaw',
82
+ type: 'WorkflowsConfigEntry[]',
83
+ initializer: arrayLiteral(entries, writeValue),
84
+ },
85
+ ],
86
+ })
87
+ sourceFile.addVariableStatement({
88
+ declarationKind: VariableDeclarationKind.Const,
89
+ declarations: [
90
+ {
91
+ name: 'entries',
92
+ type: 'ResolvedWorkflowsConfigEntry[]',
93
+ initializer: asExpression(
94
+ methodCall(identifier('entriesRaw'), 'filter', [
95
+ arrowFunction({
96
+ parameters: ['entry'],
97
+ body: binaryExpression(propertyAccess(identifier('entry'), 'config'), '!=', null),
98
+ }),
99
+ ]),
100
+ 'ResolvedWorkflowsConfigEntry[]',
101
+ ),
102
+ },
103
+ ],
104
+ })
105
+ sourceFile.addVariableStatement({
106
+ declarationKind: VariableDeclarationKind.Const,
107
+ isExported: true,
108
+ declarations: [
109
+ {
110
+ name: 'workflowModuleConfigEntries',
111
+ initializer: identifier('entries'),
112
+ },
113
+ {
114
+ name: 'workflowModuleConfigs',
115
+ type: 'WorkflowsModuleConfig[]',
116
+ initializer: methodCall(identifier('entries'), 'map', [
117
+ arrowFunction({
118
+ parameters: ['entry'],
119
+ body: propertyAccess(identifier('entry'), 'config'),
120
+ }),
121
+ ]),
122
+ },
123
+ {
124
+ name: 'allCodeWorkflows',
125
+ type: 'CodeWorkflowDefinition[]',
126
+ initializer: methodCall(identifier('entries'), 'flatMap', [
127
+ arrowFunction({
128
+ parameters: ['entry'],
129
+ body: propertyAccess(propertyAccess(identifier('entry'), 'config'), 'workflows'),
130
+ }),
131
+ ]),
132
+ },
133
+ ],
134
+ })
135
+ },
136
+ })
137
+
138
+ return new Map([['workflows.generated.ts', output]])
139
+ },
140
+ }
141
+ }