@codemation/host 0.0.16 → 0.0.19
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/CHANGELOG.md +24 -0
- package/LICENSE +37 -0
- package/dist/{AppConfigFactory-D_ReOKfV.d.ts → AppConfigFactory-CaeFn4e9.d.ts} +3 -3
- package/dist/{AppConfigFactory-JjNqYnGg.js → AppConfigFactory-DxoZ4v8r.js} +2 -3
- package/dist/AppConfigFactory-DxoZ4v8r.js.map +1 -0
- package/dist/{AppContainerFactory-_dnF0VOf.js → AppContainerFactory-iVVEyHli.js} +14 -50
- package/dist/AppContainerFactory-iVVEyHli.js.map +1 -0
- package/dist/{CodemationConfig-u80ZoIrc.d.ts → CodemationConfig--9jFRY-f.d.ts} +4 -4
- package/dist/{CodemationConfigNormalizer-DCt0mPPz.d.ts → CodemationConfigNormalizer-GV9M0JnA.d.ts} +2 -2
- package/dist/{CodemationConsumerConfigLoader-C8iscLBJ.d.ts → CodemationConsumerConfigLoader-CMUTDn8g.d.ts} +4 -2
- package/dist/{CodemationConsumerConfigLoader-LGrCspIx.js → CodemationConsumerConfigLoader-C_ISRrpI.js} +11 -4
- package/dist/CodemationConsumerConfigLoader-C_ISRrpI.js.map +1 -0
- package/dist/{CodemationPluginListMerger-ZY3R_kTo.d.ts → CodemationPluginListMerger-HKzQ5LMM.d.ts} +5 -5
- package/dist/{CredentialServices-Uo1jxSYB.d.ts → CredentialServices-5WS6gdqW.d.ts} +3 -3
- package/dist/{PublicFrontendBootstrapFactory-BA65IXL4.d.ts → PublicFrontendBootstrapFactory-DIbPtB7-.d.ts} +2 -2
- package/dist/consumer.d.ts +4 -4
- package/dist/consumer.js +1 -1
- package/dist/credentials.d.ts +3 -3
- package/dist/devServerSidecar.d.ts +1 -1
- package/dist/{index-CkiptHb-.d.ts → index-BYbzmUwS.d.ts} +224 -71
- package/dist/index.d.ts +116 -11
- package/dist/index.js +92 -6
- package/dist/index.js.map +1 -0
- package/dist/nextServer.d.ts +7 -7
- package/dist/nextServer.js +2 -2
- package/dist/{persistenceServer-J2teHIIg.js → persistenceServer-C4L1uMKn.js} +2 -2
- package/dist/{persistenceServer-J2teHIIg.js.map → persistenceServer-C4L1uMKn.js.map} +1 -1
- package/dist/{persistenceServer-BKbOs-TQ.d.ts → persistenceServer-D3dthjEX.d.ts} +2 -2
- package/dist/persistenceServer.d.ts +5 -5
- package/dist/persistenceServer.js +2 -2
- package/dist/{server-CbcnGZHm.d.ts → server-Cm3qiXA1.d.ts} +5 -5
- package/dist/{server-CVC7QBwT.js → server-CvlA-UY1.js} +4 -4
- package/dist/{server-CVC7QBwT.js.map → server-CvlA-UY1.js.map} +1 -1
- package/dist/server.d.ts +8 -8
- package/dist/server.js +5 -5
- package/package.json +9 -6
- package/playwright.scaffolded-dev.config.ts +46 -0
- package/src/application/commands/ReplayWorkflowNodeCommandHandler.ts +4 -37
- package/src/application/commands/StartWorkflowRunCommandHandler.ts +5 -62
- package/src/index.ts +9 -1
- package/src/presentation/config/CodemationAuthoring.types.ts +169 -0
- package/src/presentation/config/CodemationPlugin.ts +1 -0
- package/src/presentation/frontend/CodemationFrontendAuthSnapshotFactory.ts +7 -0
- package/src/presentation/server/CodemationConsumerConfigLoader.ts +12 -3
- package/dist/AppConfigFactory-JjNqYnGg.js.map +0 -1
- package/dist/AppContainerFactory-_dnF0VOf.js.map +0 -1
- package/dist/CodemationConsumerConfigLoader-LGrCspIx.js.map +0 -1
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import type { AnyCredentialType, DefinedNode, WorkflowDefinition } from "@codemation/core";
|
|
2
|
+
import type { CodemationAppContext } from "./CodemationAppContext";
|
|
3
|
+
import type {
|
|
4
|
+
CodemationAppDefinition,
|
|
5
|
+
CodemationAppSchedulerConfig,
|
|
6
|
+
CodemationConfig,
|
|
7
|
+
CodemationDatabaseConfig,
|
|
8
|
+
} from "./CodemationConfig";
|
|
9
|
+
import type { CodemationPlugin, CodemationPluginContext } from "./CodemationPlugin";
|
|
10
|
+
import type { CodemationWhitelabelConfig } from "./CodemationWhitelabelConfig";
|
|
11
|
+
|
|
12
|
+
export interface FriendlyCodemationDatabaseConfig {
|
|
13
|
+
readonly kind: "postgresql" | "pglite";
|
|
14
|
+
readonly url?: string;
|
|
15
|
+
readonly dataDir?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface FriendlyCodemationExecutionConfig {
|
|
19
|
+
readonly mode?: "inline" | "queue";
|
|
20
|
+
readonly queuePrefix?: string;
|
|
21
|
+
readonly workerQueues?: ReadonlyArray<string>;
|
|
22
|
+
readonly redisUrl?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface DefineCodemationAppOptions extends Omit<
|
|
26
|
+
CodemationConfig,
|
|
27
|
+
"app" | "credentialTypes" | "register" | "whitelabel" | "auth"
|
|
28
|
+
> {
|
|
29
|
+
readonly name?: string;
|
|
30
|
+
readonly auth?: CodemationConfig["auth"];
|
|
31
|
+
readonly database?: FriendlyCodemationDatabaseConfig;
|
|
32
|
+
readonly execution?: FriendlyCodemationExecutionConfig;
|
|
33
|
+
readonly nodes?: ReadonlyArray<DefinedNode<string, Record<string, unknown>, unknown, unknown>>;
|
|
34
|
+
readonly credentialTypes?: ReadonlyArray<AnyCredentialType>;
|
|
35
|
+
readonly credentials?: ReadonlyArray<AnyCredentialType>;
|
|
36
|
+
readonly register?: (context: CodemationAppContext) => void;
|
|
37
|
+
readonly whitelabel?: CodemationWhitelabelConfig;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface DefinePluginOptions {
|
|
41
|
+
readonly name?: string;
|
|
42
|
+
readonly pluginPackageId?: string;
|
|
43
|
+
readonly nodes?: ReadonlyArray<DefinedNode<string, Record<string, unknown>, unknown, unknown>>;
|
|
44
|
+
readonly credentials?: ReadonlyArray<AnyCredentialType>;
|
|
45
|
+
readonly register?: (context: CodemationPluginContext) => void | Promise<void>;
|
|
46
|
+
readonly sandbox?: DefineCodemationAppOptions & Readonly<{ workflows?: ReadonlyArray<WorkflowDefinition> }>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
class CodemationAuthoringConfigFactory {
|
|
50
|
+
static createApp(options: DefineCodemationAppOptions): CodemationConfig {
|
|
51
|
+
const appDefinition = this.createAppDefinition(options);
|
|
52
|
+
const credentialTypes = [...(options.credentialTypes ?? []), ...(options.credentials ?? [])];
|
|
53
|
+
const register = this.composeAppRegister(options.register, options.nodes);
|
|
54
|
+
const { workflows, workflowDiscovery, plugins, runtime, log } = options;
|
|
55
|
+
return {
|
|
56
|
+
workflows,
|
|
57
|
+
workflowDiscovery,
|
|
58
|
+
plugins,
|
|
59
|
+
runtime,
|
|
60
|
+
log,
|
|
61
|
+
app: appDefinition,
|
|
62
|
+
credentialTypes,
|
|
63
|
+
register,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
static createPlugin(
|
|
68
|
+
options: DefinePluginOptions,
|
|
69
|
+
): CodemationPlugin & Readonly<{ sandbox?: DefinePluginOptions["sandbox"] }> {
|
|
70
|
+
return {
|
|
71
|
+
pluginPackageId: options.pluginPackageId,
|
|
72
|
+
sandbox: options.sandbox,
|
|
73
|
+
async register(context: CodemationPluginContext): Promise<void> {
|
|
74
|
+
for (const nodeDefinition of options.nodes ?? []) {
|
|
75
|
+
nodeDefinition.register(context);
|
|
76
|
+
}
|
|
77
|
+
for (const credential of options.credentials ?? []) {
|
|
78
|
+
context.registerCredentialType(credential);
|
|
79
|
+
}
|
|
80
|
+
await options.register?.(context);
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
private static createAppDefinition(options: DefineCodemationAppOptions): CodemationAppDefinition | undefined {
|
|
86
|
+
const scheduler = this.createSchedulerConfig(options.execution);
|
|
87
|
+
const database = this.createDatabaseConfig(options.database);
|
|
88
|
+
const whitelabel = this.createWhitelabel(options.name, options.whitelabel);
|
|
89
|
+
if (!options.auth && !database && !scheduler && !whitelabel) {
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
auth: options.auth,
|
|
94
|
+
database,
|
|
95
|
+
scheduler,
|
|
96
|
+
whitelabel,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
private static createDatabaseConfig(
|
|
101
|
+
database: FriendlyCodemationDatabaseConfig | undefined,
|
|
102
|
+
): CodemationDatabaseConfig | undefined {
|
|
103
|
+
if (!database) {
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
if (database.kind === "pglite") {
|
|
107
|
+
return {
|
|
108
|
+
kind: "pglite",
|
|
109
|
+
pgliteDataDir: database.dataDir,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
return {
|
|
113
|
+
kind: "postgresql",
|
|
114
|
+
url: database.url,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
private static createSchedulerConfig(
|
|
119
|
+
execution: FriendlyCodemationExecutionConfig | undefined,
|
|
120
|
+
): CodemationAppSchedulerConfig | undefined {
|
|
121
|
+
if (!execution) {
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
return {
|
|
125
|
+
kind: execution.mode,
|
|
126
|
+
queuePrefix: execution.queuePrefix,
|
|
127
|
+
workerQueues: execution.workerQueues,
|
|
128
|
+
redisUrl: execution.redisUrl,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
private static createWhitelabel(
|
|
133
|
+
name: string | undefined,
|
|
134
|
+
whitelabel: CodemationWhitelabelConfig | undefined,
|
|
135
|
+
): CodemationWhitelabelConfig | undefined {
|
|
136
|
+
if (!name && !whitelabel) {
|
|
137
|
+
return undefined;
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
productName: name ?? whitelabel?.productName,
|
|
141
|
+
logoPath: whitelabel?.logoPath,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
private static composeAppRegister(
|
|
146
|
+
register: ((context: CodemationAppContext) => void) | undefined,
|
|
147
|
+
nodes: ReadonlyArray<DefinedNode<string, Record<string, unknown>, unknown, unknown>> | undefined,
|
|
148
|
+
): ((context: CodemationAppContext) => void) | undefined {
|
|
149
|
+
if (!register && (!nodes || nodes.length === 0)) {
|
|
150
|
+
return undefined;
|
|
151
|
+
}
|
|
152
|
+
return (context: CodemationAppContext) => {
|
|
153
|
+
for (const nodeDefinition of nodes ?? []) {
|
|
154
|
+
nodeDefinition.register(context);
|
|
155
|
+
}
|
|
156
|
+
register?.(context);
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export function defineCodemationApp(options: DefineCodemationAppOptions): CodemationConfig {
|
|
162
|
+
return CodemationAuthoringConfigFactory.createApp(options);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export function definePlugin(
|
|
166
|
+
options: DefinePluginOptions,
|
|
167
|
+
): CodemationPlugin & Readonly<{ sandbox?: DefinePluginOptions["sandbox"] }> {
|
|
168
|
+
return CodemationAuthoringConfigFactory.createPlugin(options);
|
|
169
|
+
}
|
|
@@ -11,6 +11,7 @@ export interface CodemationPluginContext extends CodemationRegistrationContextBa
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export interface CodemationPluginConfig {
|
|
14
|
+
readonly pluginPackageId?: string;
|
|
14
15
|
readonly credentialTypes?: ReadonlyArray<AnyCredentialType>;
|
|
15
16
|
readonly register?: (context: CodemationPluginContext) => void | Promise<void>;
|
|
16
17
|
readonly sandbox?: CodemationConfig;
|
|
@@ -39,6 +39,13 @@ export class CodemationFrontendAuthSnapshotFactory {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
private resolveUiAuthEnabled(authConfig: CodemationAuthConfig | undefined, env: NodeJS.ProcessEnv): boolean {
|
|
42
|
+
const configuredOverride = env.CODEMATION_UI_AUTH_ENABLED?.trim().toLowerCase();
|
|
43
|
+
if (configuredOverride === "true") {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
if (configuredOverride === "false") {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
42
49
|
return !(env.NODE_ENV !== "production" && authConfig?.allowUnauthenticatedInDevelopment === true);
|
|
43
50
|
}
|
|
44
51
|
|
|
@@ -22,6 +22,7 @@ export type CodemationConsumerConfigResolution = Readonly<{
|
|
|
22
22
|
|
|
23
23
|
export class CodemationConsumerConfigLoader {
|
|
24
24
|
private static readonly importerRegistrationsByTsconfig = new Map<string, NamespacedUnregister>();
|
|
25
|
+
private static readonly importerNamespaceVersionByTsconfig = new Map<string, number>();
|
|
25
26
|
private readonly configExportsResolver = new CodemationConsumerConfigExportsResolver();
|
|
26
27
|
private readonly configNormalizer = new CodemationConfigNormalizer();
|
|
27
28
|
private readonly workflowModulePathFinder = new WorkflowModulePathFinder();
|
|
@@ -213,8 +214,10 @@ export class CodemationConsumerConfigLoader {
|
|
|
213
214
|
return existingImporter;
|
|
214
215
|
}
|
|
215
216
|
const { register } = await import(/* webpackIgnore: true */ this.resolveTsxImporterModuleSpecifier());
|
|
217
|
+
const namespaceVersion = this.nextNamespaceVersion(cacheKey);
|
|
216
218
|
const nextImporter = register({
|
|
217
|
-
namespace
|
|
219
|
+
// A fresh namespace prevents cache hits from prior scoped imports after a dev rebuild.
|
|
220
|
+
namespace: this.toNamespace(cacheKey, namespaceVersion),
|
|
218
221
|
tsconfig: tsconfigPath,
|
|
219
222
|
});
|
|
220
223
|
CodemationConsumerConfigLoader.importerRegistrationsByTsconfig.set(cacheKey, nextImporter);
|
|
@@ -231,8 +234,14 @@ export class CodemationConsumerConfigLoader {
|
|
|
231
234
|
await existingImporter.unregister().catch(() => null);
|
|
232
235
|
}
|
|
233
236
|
|
|
234
|
-
private
|
|
235
|
-
|
|
237
|
+
private nextNamespaceVersion(cacheKey: string): number {
|
|
238
|
+
const nextVersion = (CodemationConsumerConfigLoader.importerNamespaceVersionByTsconfig.get(cacheKey) ?? 0) + 1;
|
|
239
|
+
CodemationConsumerConfigLoader.importerNamespaceVersionByTsconfig.set(cacheKey, nextVersion);
|
|
240
|
+
return nextVersion;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
private toNamespace(cacheKey: string, namespaceVersion: number): string {
|
|
244
|
+
return `codemation_consumer_${cacheKey.replace(/[^a-zA-Z0-9_-]+/g, "_")}_${namespaceVersion}`;
|
|
236
245
|
}
|
|
237
246
|
|
|
238
247
|
private resolveTsxImporterModuleSpecifier(): string {
|