@codemation/host 0.0.5 → 0.0.7
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/README.md +3 -3
- package/dist/{PrismaMigrationDeployer-B7cHGrXP.js → AppConfigFactory-DWIz2hy-.js} +104 -58
- package/dist/AppConfigFactory-DWIz2hy-.js.map +1 -0
- package/dist/{client-Yh7-CQud.d.ts → AppConfigFactory-DmHOpg8O.d.ts} +52 -31
- package/dist/{CodemationFrontendBootstrapRequest-CNEk-C4D.js → AppContainerFactory-B5eRpvAa.js} +3269 -3374
- package/dist/AppContainerFactory-B5eRpvAa.js.map +1 -0
- package/dist/{CodemationWhitelabelConfig-DgbjgtrR.d.ts → CodemationAuthConfig-Bh2cCNCI.d.ts} +32 -2
- package/dist/{CodemationConfig-XCkSV2dj.d.ts → CodemationConfig-D2ULNkec.d.ts} +53 -49
- package/dist/CodemationConfigNormalizer-CBLxXaRV.d.ts +9 -0
- package/dist/{CodemationConsumerConfigLoader-scS_RQMy.js → CodemationConsumerConfigLoader-BBzAr6L_.js} +128 -3
- package/dist/CodemationConsumerConfigLoader-BBzAr6L_.js.map +1 -0
- package/dist/{CodemationConsumerConfigLoader-Dmm2TzAA.d.ts → CodemationConsumerConfigLoader-BLvzcfb7.d.ts} +4 -4
- package/dist/CodemationPluginListMerger-B0-e4CJ6.d.ts +391 -0
- package/dist/{CodemationPluginListMerger-BNmaoXQL.js → CodemationPluginListMerger-DrVOw9KP.js} +18 -10
- package/dist/CodemationPluginListMerger-DrVOw9KP.js.map +1 -0
- package/dist/{CredentialServices-DpDpm8mL.d.ts → CredentialServices-BeuMtqYA.d.ts} +3 -3
- package/dist/{CredentialServices-BKBGe7l3.js → CredentialServices-DNb3CZwW.js} +3 -3
- package/dist/CredentialServices-DNb3CZwW.js.map +1 -0
- package/dist/FrontendAppConfig-D50wjj_n.d.ts +27 -0
- package/dist/{WorkflowViewContracts-DCLpTn25.d.ts → FrontendAppConfigFactory-Bj-DZNlt.d.ts} +29 -2
- package/dist/FrontendAppConfigJsonCodec-1_L7H_Qo.d.ts +20 -0
- package/dist/FrontendAppConfigJsonCodec-nOCQI0ag.js +84 -0
- package/dist/FrontendAppConfigJsonCodec-nOCQI0ag.js.map +1 -0
- package/dist/{LogLevelPolicy-4cq9z0TI.d.ts → LogLevelPolicy-BS_NlAOg.d.ts} +2 -2
- package/dist/{ServerLoggerFactory-BRHxIDS7.js → ServerLoggerFactory-BltIIDfQ.js} +4 -129
- package/dist/ServerLoggerFactory-BltIIDfQ.js.map +1 -0
- package/dist/client.d.ts +5 -3
- package/dist/client.js +2 -1
- package/dist/client.js.map +1 -1
- package/dist/consumer.d.ts +5 -4
- package/dist/consumer.js +4 -4
- package/dist/credentials.d.ts +4 -4
- package/dist/credentials.js +3 -3
- package/dist/devServerSidecar.d.ts +1 -1
- package/dist/{index-Bs4F1IsC.d.ts → index-CkiptHb-.d.ts} +19 -20
- package/dist/index.d.ts +14 -19
- package/dist/index.js +12 -11
- package/dist/nextServer.d.ts +244 -9
- package/dist/nextServer.js +8 -8
- package/dist/persistenceServer-CaehMh3M.d.ts +9 -0
- package/dist/{persistenceServer-8tcM2S48.js → persistenceServer-DVeWUbc3.js} +2 -2
- package/dist/{persistenceServer-8tcM2S48.js.map → persistenceServer-DVeWUbc3.js.map} +1 -1
- package/dist/persistenceServer.d.ts +7 -6
- package/dist/persistenceServer.js +4 -4
- package/dist/{server-Dd65rNm6.js → server-C65z_kqm.js} +47 -17
- package/dist/server-C65z_kqm.js.map +1 -0
- package/dist/{server-BBdsATju.d.ts → server-Dyo8qh4k.d.ts} +23 -4
- package/dist/server.d.ts +12 -9
- package/dist/server.js +11 -10
- package/package.json +6 -6
- package/src/application/commands/WorkflowCommandHandlers.ts +9 -0
- package/src/application/dev/BootRuntimeSnapshotHolder.ts +2 -2
- package/src/application/dev/BootRuntimeSummary.types.ts +2 -2
- package/src/application/queries/WorkflowQueryHandlers.ts +7 -0
- package/src/applicationTokens.ts +1 -1
- package/src/bootstrap/AppContainerFactory.ts +584 -0
- package/src/bootstrap/{PreparedCodemationRuntime.ts → AppContainerLifecycle.ts} +3 -8
- package/src/bootstrap/runtime/AppConfigFactory.ts +155 -30
- package/src/bootstrap/runtime/DatabaseMigrations.ts +18 -0
- package/src/bootstrap/runtime/FrontendRuntime.ts +44 -0
- package/src/bootstrap/runtime/WorkerRuntime.ts +55 -0
- package/src/client.ts +7 -0
- package/src/index.ts +15 -5
- package/src/infrastructure/persistence/PrismaMigrationDeployer.ts +2 -2
- package/src/infrastructure/persistence/SchedulerPersistenceCompatibilityValidator.ts +2 -2
- package/src/infrastructure/scheduler/WorkerRuntimeScheduler.ts +16 -0
- package/src/infrastructure/scheduler/bullmq/BullmqNodeExecutionScheduler.ts +47 -0
- package/src/infrastructure/scheduler/bullmq/BullmqScheduler.ts +33 -0
- package/src/infrastructure/scheduler/bullmq/BullmqWorker.ts +48 -0
- package/src/infrastructure/scheduler/bullmq/RedisConnectionOptionsFactory.ts +48 -0
- package/src/nextServer.ts +12 -3
- package/src/persistenceServer.ts +2 -2
- package/src/presentation/config/AppConfig.ts +25 -1
- package/src/presentation/frontend/CodemationFrontendAuthSnapshot.ts +14 -0
- package/src/presentation/frontend/CodemationFrontendAuthSnapshotFactory.ts +84 -0
- package/src/presentation/frontend/CodemationFrontendAuthSnapshotJsonCodec.ts +58 -0
- package/src/presentation/frontend/FrontendAppConfig.ts +10 -0
- package/src/presentation/frontend/FrontendAppConfigFactory.ts +26 -0
- package/src/presentation/frontend/FrontendAppConfigJsonCodec.ts +58 -0
- package/src/presentation/http/CodemationServerGatewayFactory.ts +22 -16
- package/src/presentation/server/AppConfigLoader.ts +39 -0
- package/src/presentation/server/CodemationConsumerAppResolver.ts +2 -2
- package/src/presentation/server/CodemationConsumerConfigLoader.ts +3 -2
- package/src/server.ts +7 -0
- package/vitest.shared.ts +0 -4
- package/dist/CodemationConsumerConfigLoader-scS_RQMy.js.map +0 -1
- package/dist/CodemationFrontendBootstrapRequest-CNEk-C4D.js.map +0 -1
- package/dist/CodemationPluginListMerger-BNmaoXQL.js.map +0 -1
- package/dist/CodemationPluginListMerger-BRYqEk0y.d.ts +0 -793
- package/dist/CredentialServices-BKBGe7l3.js.map +0 -1
- package/dist/PrismaMigrationDeployer-B7cHGrXP.js.map +0 -1
- package/dist/ServerLoggerFactory-BRHxIDS7.js.map +0 -1
- package/dist/persistenceServer-DPSj_-oU.d.ts +0 -37
- package/dist/server-Dd65rNm6.js.map +0 -1
- package/src/bootstrap/CodemationContainerFactory.ts +0 -310
- package/src/bootstrap/CodemationFrontendBootstrapRequest.ts +0 -16
- package/src/bootstrap/CodemationWorkerBootstrapRequest.ts +0 -19
- package/src/bootstrap/PreparedCodemationRuntimeFactory.ts +0 -308
- package/src/bootstrap/boot/CliRuntimeBootService.ts +0 -27
- package/src/bootstrap/boot/FrontendRuntimeBootService.ts +0 -86
- package/src/bootstrap/boot/WorkerRuntimeBootService.ts +0 -64
- package/src/bootstrap/runtime/ResolvedImplementationSelectionFactory.ts +0 -118
- package/src/codemationApplication.ts +0 -311
- package/src/infrastructure/credentials/FrameworkBuiltinCredentialTypesRegistrar.ts +0 -21
- package/src/infrastructure/persistence/DatabasePersistenceResolver.ts +0 -91
- package/src/infrastructure/runtime/WorkerRuntimeScheduler.ts +0 -35
- package/src/presentation/config/CodemationApplicationFacade.ts +0 -5
- /package/dist/{decorate-B-N_5S4p.js → decorate-B0PP651O.js} +0 -0
- /package/dist/{decorateParam-BTcc3KNk.js → decorateParam-DrsXNPuw.js} +0 -0
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# `@codemation/host`
|
|
2
2
|
|
|
3
|
-
The **framework host**:
|
|
3
|
+
The **framework host**: app-config loading, app-container composition, HTTP/WebSocket gateway (Hono), persistence (Prisma/Postgres), plugin and workflow discovery, shared React UI shell pieces, and server/client **subpath bundles** so Next.js and Node servers only import what they need.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -16,10 +16,10 @@ Depend on this package when you embed Codemation in a custom server, extend the
|
|
|
16
16
|
|
|
17
17
|
## Usage
|
|
18
18
|
|
|
19
|
-
Root re-exports
|
|
19
|
+
Root re-exports the container-oriented hosting surface:
|
|
20
20
|
|
|
21
21
|
```ts
|
|
22
|
-
import {
|
|
22
|
+
import { AppContainerFactory, AppConfigFactory } from "@codemation/host";
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
Common subpaths (see `package.json` `exports`):
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { r as __require, t as __commonJS } from "./chunk-7V6ThxGB.js";
|
|
2
|
-
import { t as __decorate } from "./decorate-
|
|
2
|
+
import { t as __decorate } from "./decorate-B0PP651O.js";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import { mkdir } from "node:fs/promises";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
|
-
import { injectable } from "@codemation/core";
|
|
7
|
+
import { CoreTokens, injectable } from "@codemation/core";
|
|
8
8
|
import { existsSync } from "node:fs";
|
|
9
9
|
import { PGlite } from "@electric-sql/pglite";
|
|
10
10
|
import { PGLiteSocketServer } from "@electric-sql/pglite-socket";
|
|
@@ -8014,60 +8014,6 @@ var require_client = /* @__PURE__ */ __commonJS({ "src/infrastructure/persistenc
|
|
|
8014
8014
|
module.exports = { ...require_prisma_client() };
|
|
8015
8015
|
}) });
|
|
8016
8016
|
|
|
8017
|
-
//#endregion
|
|
8018
|
-
//#region src/infrastructure/persistence/DatabasePersistenceResolver.ts
|
|
8019
|
-
const DEFAULT_PGLITE_RELATIVE_DIR = ".codemation/pglite";
|
|
8020
|
-
/**
|
|
8021
|
-
* Resolves whether persistence uses TCP PostgreSQL, embedded PGlite, or in-memory stores.
|
|
8022
|
-
* Uses {@link CodemationConfig.runtime.database} as the source of truth; optional `CODEMATION_DATABASE_KIND`
|
|
8023
|
-
* and `CODEMATION_PGLITE_DATA_DIR` can override kind / PGlite directory. `DATABASE_URL` is not read here—put
|
|
8024
|
-
* connection strings in `runtime.database.url` (often sourced from `process.env` inside `codemation.config.ts`).
|
|
8025
|
-
*/
|
|
8026
|
-
var DatabasePersistenceResolver = class {
|
|
8027
|
-
resolve(args) {
|
|
8028
|
-
const db = args.runtimeConfig.database;
|
|
8029
|
-
if (!db) return { kind: "none" };
|
|
8030
|
-
if (this.resolveDatabaseKind(this.inferDatabaseKind(db), args.env) === "postgresql") {
|
|
8031
|
-
const url = db.url?.trim() ?? "";
|
|
8032
|
-
if (!url) throw new Error("runtime.database.kind is \"postgresql\" but no database URL was set (runtime.database.url).");
|
|
8033
|
-
if (!this.isPostgresUrl(url)) throw new Error(`runtime.database.url must be a postgresql:// or postgres:// URL when kind is postgresql. Received: ${url}`);
|
|
8034
|
-
return {
|
|
8035
|
-
kind: "postgresql",
|
|
8036
|
-
databaseUrl: url
|
|
8037
|
-
};
|
|
8038
|
-
}
|
|
8039
|
-
return {
|
|
8040
|
-
kind: "pglite",
|
|
8041
|
-
dataDir: this.resolvePgliteDataDirFromConfig(db, args.env, args.consumerRoot)
|
|
8042
|
-
};
|
|
8043
|
-
}
|
|
8044
|
-
resolveDatabaseKind(configured, env) {
|
|
8045
|
-
const fromEnv = env.CODEMATION_DATABASE_KIND?.trim();
|
|
8046
|
-
if (fromEnv === "postgresql" || fromEnv === "pglite") return fromEnv;
|
|
8047
|
-
if (configured) return configured;
|
|
8048
|
-
return "pglite";
|
|
8049
|
-
}
|
|
8050
|
-
inferDatabaseKind(db) {
|
|
8051
|
-
if (db.kind) return db.kind;
|
|
8052
|
-
const url = db.url?.trim();
|
|
8053
|
-
if (url && this.isPostgresUrl(url)) return "postgresql";
|
|
8054
|
-
return "pglite";
|
|
8055
|
-
}
|
|
8056
|
-
isPostgresUrl(value) {
|
|
8057
|
-
return value.startsWith("postgresql://") || value.startsWith("postgres://");
|
|
8058
|
-
}
|
|
8059
|
-
isPgliteUrl(value) {
|
|
8060
|
-
return value.startsWith("pglite:");
|
|
8061
|
-
}
|
|
8062
|
-
resolvePgliteDataDirFromConfig(db, env, consumerRoot) {
|
|
8063
|
-
const fromEnv = env.CODEMATION_PGLITE_DATA_DIR?.trim();
|
|
8064
|
-
if (fromEnv && fromEnv.length > 0) return path.isAbsolute(fromEnv) ? fromEnv : path.resolve(consumerRoot, fromEnv);
|
|
8065
|
-
const configured = db.pgliteDataDir?.trim();
|
|
8066
|
-
if (configured && configured.length > 0) return path.isAbsolute(configured) ? configured : path.resolve(consumerRoot, configured);
|
|
8067
|
-
return path.resolve(consumerRoot, DEFAULT_PGLITE_RELATIVE_DIR);
|
|
8068
|
-
}
|
|
8069
|
-
};
|
|
8070
|
-
|
|
8071
8017
|
//#endregion
|
|
8072
8018
|
//#region src/infrastructure/persistence/PrismaMigrationDeployer.ts
|
|
8073
8019
|
let PrismaMigrationDeployer = class PrismaMigrationDeployer$1 {
|
|
@@ -8221,5 +8167,105 @@ let PrismaMigrationDeployer = class PrismaMigrationDeployer$1 {
|
|
|
8221
8167
|
PrismaMigrationDeployer = __decorate([injectable()], PrismaMigrationDeployer);
|
|
8222
8168
|
|
|
8223
8169
|
//#endregion
|
|
8224
|
-
|
|
8225
|
-
|
|
8170
|
+
//#region src/bootstrap/runtime/AppConfigFactory.ts
|
|
8171
|
+
var AppConfigFactory = class {
|
|
8172
|
+
create(args) {
|
|
8173
|
+
const runtimeConfig = args.config.runtime ?? {};
|
|
8174
|
+
const persistence = this.resolvePersistence(runtimeConfig, args.env, args.consumerRoot);
|
|
8175
|
+
const redisUrl = runtimeConfig.eventBus?.redisUrl ?? args.env.REDIS_URL;
|
|
8176
|
+
const schedulerKind = this.resolveSchedulerKind(runtimeConfig, args.env, redisUrl);
|
|
8177
|
+
const eventBusKind = this.resolveEventBusKind(runtimeConfig, args.env, schedulerKind, redisUrl);
|
|
8178
|
+
const workerQueues = runtimeConfig.scheduler?.workerQueues ?? [];
|
|
8179
|
+
const queuePrefix = runtimeConfig.scheduler?.queuePrefix ?? runtimeConfig.eventBus?.queuePrefix ?? args.env.QUEUE_PREFIX;
|
|
8180
|
+
const hasConfiguredCredentialSessionServiceRegistration = args.config.containerRegistrations.some((entry) => entry.token === CoreTokens.CredentialSessionService);
|
|
8181
|
+
return {
|
|
8182
|
+
consumerRoot: args.consumerRoot,
|
|
8183
|
+
repoRoot: args.repoRoot,
|
|
8184
|
+
env: args.env,
|
|
8185
|
+
workflowSources: [...args.workflowSources],
|
|
8186
|
+
workflows: [...args.config.workflows ?? []],
|
|
8187
|
+
containerRegistrations: [...args.config.containerRegistrations],
|
|
8188
|
+
credentialTypes: [...args.config.credentialTypes ?? []],
|
|
8189
|
+
plugins: [...args.config.plugins ?? []],
|
|
8190
|
+
hasConfiguredCredentialSessionServiceRegistration,
|
|
8191
|
+
log: args.config.log,
|
|
8192
|
+
engineExecutionLimits: runtimeConfig.engineExecutionLimits,
|
|
8193
|
+
databaseUrl: persistence.kind === "postgresql" ? persistence.databaseUrl : runtimeConfig.database?.url?.trim() || void 0,
|
|
8194
|
+
database: runtimeConfig.database,
|
|
8195
|
+
persistence,
|
|
8196
|
+
scheduler: {
|
|
8197
|
+
kind: schedulerKind,
|
|
8198
|
+
queuePrefix,
|
|
8199
|
+
workerQueues,
|
|
8200
|
+
redisUrl
|
|
8201
|
+
},
|
|
8202
|
+
eventing: {
|
|
8203
|
+
kind: eventBusKind,
|
|
8204
|
+
queuePrefix,
|
|
8205
|
+
redisUrl
|
|
8206
|
+
},
|
|
8207
|
+
auth: args.config.auth,
|
|
8208
|
+
whitelabel: args.config.whitelabel ?? {},
|
|
8209
|
+
webSocketPort: this.resolveWebSocketPort(args.env),
|
|
8210
|
+
webSocketBindHost: args.env.CODEMATION_WS_BIND_HOST ?? "0.0.0.0"
|
|
8211
|
+
};
|
|
8212
|
+
}
|
|
8213
|
+
resolvePersistence(runtimeConfig, env, consumerRoot) {
|
|
8214
|
+
const database = runtimeConfig.database;
|
|
8215
|
+
if (!database) return { kind: "none" };
|
|
8216
|
+
if (this.resolveDatabaseKind(database.kind, database.url, env) === "postgresql") {
|
|
8217
|
+
const databaseUrl = database.url?.trim() ?? "";
|
|
8218
|
+
if (!databaseUrl) throw new Error("runtime.database.kind is \"postgresql\" but no database URL was set (runtime.database.url).");
|
|
8219
|
+
if (!databaseUrl.startsWith("postgresql://") && !databaseUrl.startsWith("postgres://")) throw new Error(`runtime.database.url must be a postgresql:// or postgres:// URL when kind is postgresql. Received: ${databaseUrl}`);
|
|
8220
|
+
return {
|
|
8221
|
+
kind: "postgresql",
|
|
8222
|
+
databaseUrl
|
|
8223
|
+
};
|
|
8224
|
+
}
|
|
8225
|
+
return {
|
|
8226
|
+
kind: "pglite",
|
|
8227
|
+
dataDir: this.resolvePgliteDataDir(database.pgliteDataDir, env, consumerRoot)
|
|
8228
|
+
};
|
|
8229
|
+
}
|
|
8230
|
+
resolveDatabaseKind(configuredKind, databaseUrl, env) {
|
|
8231
|
+
const kindFromEnv = env.CODEMATION_DATABASE_KIND?.trim();
|
|
8232
|
+
if (kindFromEnv === "postgresql" || kindFromEnv === "pglite") return kindFromEnv;
|
|
8233
|
+
if (configuredKind) return configuredKind;
|
|
8234
|
+
const trimmedUrl = databaseUrl?.trim();
|
|
8235
|
+
if (trimmedUrl && (trimmedUrl.startsWith("postgresql://") || trimmedUrl.startsWith("postgres://"))) return "postgresql";
|
|
8236
|
+
return "pglite";
|
|
8237
|
+
}
|
|
8238
|
+
resolvePgliteDataDir(configuredPath, env, consumerRoot) {
|
|
8239
|
+
const envPath = env.CODEMATION_PGLITE_DATA_DIR?.trim();
|
|
8240
|
+
if (envPath && envPath.length > 0) return path.isAbsolute(envPath) ? envPath : path.resolve(consumerRoot, envPath);
|
|
8241
|
+
const trimmedConfiguredPath = configuredPath?.trim();
|
|
8242
|
+
if (trimmedConfiguredPath && trimmedConfiguredPath.length > 0) return path.isAbsolute(trimmedConfiguredPath) ? trimmedConfiguredPath : path.resolve(consumerRoot, trimmedConfiguredPath);
|
|
8243
|
+
return path.resolve(consumerRoot, ".codemation", "pglite");
|
|
8244
|
+
}
|
|
8245
|
+
resolveSchedulerKind(runtimeConfig, env, redisUrl) {
|
|
8246
|
+
const configuredKind = runtimeConfig.scheduler?.kind ?? this.readSchedulerKind(env.CODEMATION_SCHEDULER);
|
|
8247
|
+
if (configuredKind) return configuredKind;
|
|
8248
|
+
return redisUrl ? "bullmq" : "local";
|
|
8249
|
+
}
|
|
8250
|
+
resolveEventBusKind(runtimeConfig, env, schedulerKind, redisUrl) {
|
|
8251
|
+
const configuredKind = runtimeConfig.eventBus?.kind ?? this.readEventBusKind(env.CODEMATION_EVENT_BUS);
|
|
8252
|
+
if (configuredKind) return configuredKind;
|
|
8253
|
+
if (schedulerKind === "bullmq") return "redis";
|
|
8254
|
+
return redisUrl ? "redis" : "memory";
|
|
8255
|
+
}
|
|
8256
|
+
readSchedulerKind(value) {
|
|
8257
|
+
if (value === "local" || value === "bullmq") return value;
|
|
8258
|
+
}
|
|
8259
|
+
readEventBusKind(value) {
|
|
8260
|
+
if (value === "memory" || value === "redis") return value;
|
|
8261
|
+
}
|
|
8262
|
+
resolveWebSocketPort(env) {
|
|
8263
|
+
const configuredPort = Number(env.CODEMATION_WS_PORT ?? 3001);
|
|
8264
|
+
if (Number.isNaN(configuredPort) || configuredPort <= 0) return 3001;
|
|
8265
|
+
return configuredPort;
|
|
8266
|
+
}
|
|
8267
|
+
};
|
|
8268
|
+
|
|
8269
|
+
//#endregion
|
|
8270
|
+
export { PrismaMigrationDeployer as n, require_client as r, AppConfigFactory as t };
|
|
8271
|
+
//# sourceMappingURL=AppConfigFactory-DWIz2hy-.js.map
|