@codemation/host 0.8.0 → 0.9.1
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 +59 -0
- package/dist/{ApiPaths-Dv1dcHu_.js → ApiPaths-DCvrlIjg.js} +12 -1
- package/dist/{ApiPaths-Dv1dcHu_.js.map → ApiPaths-DCvrlIjg.js.map} +1 -1
- package/dist/{AppConfigFactory-Cx4qQvRk.js → AppConfigFactory-D4LL1aOR.js} +77 -297
- package/dist/AppConfigFactory-D4LL1aOR.js.map +1 -0
- package/dist/{AppConfigFactory-BT0y0LVC.d.ts → AppConfigFactory-DncmwCD1.d.ts} +2918 -199
- package/dist/{AppContainerFactory-DRTjG7nG.js → AppContainerFactory-CHCXP2rn.js} +1735 -474
- package/dist/AppContainerFactory-CHCXP2rn.js.map +1 -0
- package/dist/{CodemationAppContext-CGFYVcSb.d.ts → CodemationAppContext-K51b7oXe.d.ts} +3 -3
- package/dist/{CodemationAuthoring.types-DiKKogum.d.ts → CodemationAuthoring.types-BXlXIl4K.d.ts} +4 -4
- package/dist/{CodemationConfigNormalizer-48f-T66P.d.ts → CodemationConfigNormalizer-B4rDYC9h.d.ts} +3 -3
- package/dist/{CodemationConsumerConfigLoader-_PIYqwVx.d.ts → CodemationConsumerConfigLoader-Dt4jyLx6.d.ts} +2 -2
- package/dist/{CodemationPluginListMerger-DP7djJ9S.d.ts → CodemationPluginListMerger-DS6I3Xe0.d.ts} +24 -12
- package/dist/{persistenceServer-C-hH4z6l.js → CodemationPostgresPrismaClientFactory-C7156Fe-.js} +2 -2
- package/dist/CodemationPostgresPrismaClientFactory-C7156Fe-.js.map +1 -0
- package/dist/CodemationPostgresPrismaClientFactory-CTNTPnDr.d.ts +9 -0
- package/dist/{CredentialContractsRegistry-Bq2bq28t.d.ts → CredentialContractsRegistry-Dgu-rEXi.d.ts} +16 -3
- package/dist/{CredentialServices-BLloBztI.d.ts → CredentialServices-B3wPyp2y.d.ts} +4 -4
- package/dist/{CredentialServices-Dk8yypeL.js → CredentialServices-Bios0dM8.js} +10 -4
- package/dist/CredentialServices-Bios0dM8.js.map +1 -0
- package/dist/{InternalHonoApiRouteRegistrar-c7t3KnV_.d.ts → InternalHonoApiRouteRegistrar-Ce1yxpnO.d.ts} +1 -1
- package/dist/{InternalPingRegistrar-DY3kSfxP.js → InternalPingRegistrar-BavAAnvk.js} +19 -16
- package/dist/InternalPingRegistrar-BavAAnvk.js.map +1 -0
- package/dist/{ItemsInputNormalizer-_RwIfRIQ.d.ts → ItemsInputNormalizer-CFkfNMLt.d.ts} +1434 -1225
- package/dist/PrismaMigrationDeployer-DdEcXXVi.d.ts +14 -0
- package/dist/{PublicFrontendBootstrapFactory-Dv04tJ-6.d.ts → PublicFrontendBootstrapFactory-ClEjZP74.d.ts} +2 -2
- package/dist/{PublicFrontendBootstrapJsonCodec-CXG9Dxft.d.ts → PublicFrontendBootstrapJsonCodec-HNItQ7ol.d.ts} +6 -1
- package/dist/{TelemetryContracts-BtDx84Cp.d.ts → TelemetryContracts-DpZEODQM.d.ts} +2 -2
- package/dist/{WorkflowPolicyUiPresentationFactory-6MyjCvBO.d.ts → WorkflowPolicyUiPresentationFactory-BNn2fvR_.d.ts} +2 -2
- package/dist/{WorkflowPolicyUiPresentationFactory-Bb-ae_Zh.js → WorkflowPolicyUiPresentationFactory-DfvD2VHk.js} +1 -1
- package/dist/{WorkflowPolicyUiPresentationFactory-Bb-ae_Zh.js.map → WorkflowPolicyUiPresentationFactory-DfvD2VHk.js.map} +1 -1
- package/dist/authoring.d.ts +4 -4
- package/dist/client.d.ts +1 -1
- package/dist/client.js +1 -1
- package/dist/consumer.d.ts +5 -5
- package/dist/credentials.d.ts +5 -5
- package/dist/credentials.js +1 -1
- package/dist/devServerSidecar.d.ts +2 -2
- package/dist/dto.d.ts +5 -5
- package/dist/{index-DilAYwnH.d.ts → index-ChIfeWzk.d.ts} +71 -28
- package/dist/index.d.ts +17 -16
- package/dist/index.js +8 -8
- package/dist/infrastructure/persistence/PrismaMigrationOperations.d.ts +44 -0
- package/dist/infrastructure/persistence/PrismaMigrationOperations.js +302 -0
- package/dist/infrastructure/persistence/PrismaMigrationOperations.js.map +1 -0
- package/dist/mapping.d.ts +2 -2
- package/dist/mapping.js +1 -1
- package/dist/nextServer.d.ts +15 -13
- package/dist/nextServer.js +6 -6
- package/dist/pairing.d.ts +28 -9
- package/dist/pairing.js +19 -3
- package/dist/pairing.js.map +1 -0
- package/dist/{pairing.types-snfZ_OzB.d.ts → pairing.types-D9Bjn98U.d.ts} +1 -1
- package/dist/persistenceServer.d.ts +31 -7
- package/dist/persistenceServer.js +2 -2
- package/dist/{server-09PKasWR.d.ts → server-B5trn7y4.d.ts} +5 -5
- package/dist/{server-vtRCPgRJ.js → server-CNj_y0QO.js} +4 -4
- package/dist/{server-vtRCPgRJ.js.map → server-CNj_y0QO.js.map} +1 -1
- package/dist/server.d.ts +10 -10
- package/dist/server.js +8 -8
- package/package.json +11 -10
- package/playwright.config.ts +8 -2
- package/playwright.scaffolded-dev.config.ts +8 -2
- package/prisma/migrations/20260526120000_credential_material_pointer/migration.sql +18 -0
- package/prisma/migrations/20260527120000_add_human_task/migration.sql +32 -0
- package/prisma/migrations/20260527130000_add_hitl_state_json/migration.sql +6 -0
- package/prisma/migrations/20260527130000_add_hmac_nonce/migration.sql +12 -0
- package/prisma/migrations.sqlite/20260526120000_credential_material_pointer/migration.sql +13 -0
- package/prisma/migrations.sqlite/20260527120000_add_human_task/migration.sql +30 -0
- package/prisma/migrations.sqlite/20260527130000_add_hitl_state_json/migration.sql +6 -0
- package/prisma/migrations.sqlite/20260527130000_add_hmac_nonce/migration.sql +9 -0
- package/prisma/schema.postgresql.prisma +48 -0
- package/prisma/schema.sqlite.prisma +48 -0
- package/prisma-generated/prisma-postgresql-client/edge.js +40 -6
- package/prisma-generated/prisma-postgresql-client/index-browser.js +36 -2
- package/prisma-generated/prisma-postgresql-client/index.d.ts +3179 -163
- package/prisma-generated/prisma-postgresql-client/index.js +40 -6
- package/prisma-generated/prisma-postgresql-client/package.json +1 -1
- package/prisma-generated/prisma-postgresql-client/schema.prisma +48 -0
- package/prisma-generated/prisma-sqlite-client/edge.js +40 -6
- package/prisma-generated/prisma-sqlite-client/index-browser.js +36 -2
- package/prisma-generated/prisma-sqlite-client/index.d.ts +3175 -163
- package/prisma-generated/prisma-sqlite-client/index.js +40 -6
- package/prisma-generated/prisma-sqlite-client/package.json +1 -1
- package/prisma-generated/prisma-sqlite-client/schema.prisma +48 -0
- package/src/application/contracts/CredentialContractsRegistry.ts +15 -0
- package/src/application/credentials/AppGalleryProjector.ts +69 -0
- package/src/application/hitl/DecideHumanTaskCommandHandler.ts +149 -0
- package/src/application/hitl/DecisionSchemaValidator.ts +22 -0
- package/src/application/hitl/HitlCallbackHandler.ts +96 -0
- package/src/application/mapping/WorkflowDefinitionMapper.ts +1 -3
- package/src/application/queries/CredentialQueryHandlers.ts +2 -0
- package/src/application/queries/GetCredentialAppsQuery.ts +4 -0
- package/src/application/queries/GetCredentialAppsQueryHandler.ts +27 -0
- package/src/application/telemetry/ResumeTelemetryContextForRun.ts +53 -0
- package/src/application/telemetry/TelemetryRetentionTimestampFactory.ts +9 -8
- package/src/applicationTokens.ts +11 -1
- package/src/auth/managed/ManagedCorsMiddleware.ts +20 -5
- package/src/bootstrap/AppContainerFactory.ts +100 -0
- package/src/credentials/CachingCredentialMaterialProvider.ts +96 -0
- package/src/credentials/CompositeCredentialMaterialProvider.ts +47 -0
- package/src/credentials/ControlPlaneCatalogFetcher.ts +4 -24
- package/src/credentials/ControlPlaneCredentialMaterialProvider.ts +79 -0
- package/src/credentials/CredentialOAuth2MaterialReader.ts +2 -7
- package/src/credentials/InternalCredentialsBindingRegistrar.ts +83 -0
- package/src/credentials/LocalCredentialMaterialProvider.ts +92 -0
- package/src/domain/credentials/CredentialInstanceService.ts +5 -1
- package/src/domain/credentials/CredentialTypeRegistryImpl.ts +18 -4
- package/src/domain/workflows/WorkflowActivationPreflightRules.ts +7 -4
- package/src/dto.ts +2 -0
- package/src/hitl/ControlPlaneInboxChannel.ts +102 -0
- package/src/hitl/HitlResumeTokenSigner.ts +80 -0
- package/src/hitl/HitlTimeoutJobScheduler.ts +89 -0
- package/src/hitl/HitlTimeoutWorker.ts +143 -0
- package/src/hitl/InboxChannelResolver.ts +49 -0
- package/src/hitl/LocalInboxChannel.ts +37 -0
- package/src/infrastructure/persistence/PrismaCredentialStore.ts +10 -0
- package/src/infrastructure/persistence/PrismaHmacNonceStore.ts +29 -0
- package/src/infrastructure/persistence/PrismaHumanTaskStore.ts +156 -0
- package/src/infrastructure/persistence/PrismaMigrationDeployer.ts +53 -383
- package/src/infrastructure/persistence/PrismaMigrationOperations.ts +401 -0
- package/src/infrastructure/persistence/PrismaWorkflowRunRepository.ts +39 -0
- package/src/mcp/AgentMcpIntegrationImpl.ts +5 -1
- package/src/pairing/HmacNonceStore.ts +14 -0
- package/src/pairing/HmacNonceStoreToken.ts +4 -0
- package/src/pairing/HmacRequestSigner.ts +10 -1
- package/src/pairing/InMemoryHmacNonceStore.ts +24 -0
- package/src/pairing/IncomingHmacVerifier.ts +28 -12
- package/src/pairing/InternalHmacAuthMiddleware.ts +1 -1
- package/src/pairing/index.ts +3 -0
- package/src/presentation/http/ApiPaths.ts +14 -0
- package/src/presentation/http/hono/HonoHttpAnonymousRoutePolicyRegistry.ts +4 -0
- package/src/presentation/http/hono/registrars/CredentialHonoApiRouteRegistrar.ts +1 -0
- package/src/presentation/http/hono/registrars/HitlDecideHonoApiRouteRegistrar.ts +54 -0
- package/src/presentation/http/hono/registrars/HitlInternalCallbackHonoApiRouteRegistrar.ts +33 -0
- package/src/presentation/http/hono/registrars/HitlResumeHonoApiRouteRegistrar.ts +43 -0
- package/src/presentation/http/routeHandlers/CredentialHttpRouteHandler.ts +9 -0
- package/src/presentation/http/routeHandlers/OAuth2HttpRouteHandlerFactory.ts +1 -1
- package/src/server.ts +7 -2
- package/src/workflows/InternalWorkflowTestRunRegistrar.ts +9 -0
- package/tsconfig.json +1 -0
- package/dist/AppConfigFactory-Cx4qQvRk.js.map +0 -1
- package/dist/AppContainerFactory-DRTjG7nG.js.map +0 -1
- package/dist/CredentialServices-Dk8yypeL.js.map +0 -1
- package/dist/InternalPingRegistrar-DY3kSfxP.js.map +0 -1
- package/dist/persistenceServer-B71RGvSj.d.ts +0 -30
- package/dist/persistenceServer-C-hH4z6l.js.map +0 -1
- package/src/credentials/catalogTypes.ts +0 -4
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import { mkdir } from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { existsSync } from "node:fs";
|
|
6
|
+
import { spawn } from "node:child_process";
|
|
7
|
+
|
|
8
|
+
//#region src/infrastructure/persistence/PrismaMigrationOperations.ts
|
|
9
|
+
/**
|
|
10
|
+
* Contains all runtime logic for deploying Prisma migrations.
|
|
11
|
+
* This class is loaded lazily via `await import(...)` from PrismaMigrationDeployer
|
|
12
|
+
* so that the dynamic fs/path/createRequire operations never appear in the
|
|
13
|
+
* static module graph visible to the Turbopack / Next.js NFT tracer.
|
|
14
|
+
*/
|
|
15
|
+
var PrismaMigrationOperations = class PrismaMigrationOperations {
|
|
16
|
+
static normalizedRuntimeMigrationName = "20260407140000_run_normalized_persistence";
|
|
17
|
+
require = createRequire(import.meta.url);
|
|
18
|
+
async deployPersistence(persistence, env) {
|
|
19
|
+
if (persistence.kind === "none") return;
|
|
20
|
+
if (persistence.kind === "postgresql") {
|
|
21
|
+
await this.deployPostgres({
|
|
22
|
+
databaseUrl: persistence.databaseUrl,
|
|
23
|
+
env
|
|
24
|
+
});
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
await this.deploySqlite({
|
|
28
|
+
databaseFilePath: persistence.databaseFilePath,
|
|
29
|
+
env
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
async deploy(args) {
|
|
33
|
+
await this.deployPostgres(args);
|
|
34
|
+
}
|
|
35
|
+
resolvePackageRoot(env = process.env) {
|
|
36
|
+
const configuredRoot = env.CODEMATION_HOST_PACKAGE_ROOT;
|
|
37
|
+
if (configuredRoot) return configuredRoot;
|
|
38
|
+
let currentDirectory = path.dirname(fileURLToPath(import.meta.url));
|
|
39
|
+
for (let depth = 0; depth < 8; depth += 1) {
|
|
40
|
+
if (existsSync(path.join(currentDirectory, "prisma", "schema.postgresql.prisma"))) return currentDirectory;
|
|
41
|
+
const parentDirectory = path.dirname(currentDirectory);
|
|
42
|
+
if (parentDirectory === currentDirectory) break;
|
|
43
|
+
currentDirectory = parentDirectory;
|
|
44
|
+
}
|
|
45
|
+
throw new Error(`Could not locate prisma/schema.postgresql.prisma near ${fileURLToPath(import.meta.url)}.`);
|
|
46
|
+
}
|
|
47
|
+
async deploySqlite(args) {
|
|
48
|
+
await this.ensureSqliteParentDirectoryExists(args.databaseFilePath);
|
|
49
|
+
const databaseUrl = this.sqliteFilePathToDatabaseUrl(args.databaseFilePath);
|
|
50
|
+
try {
|
|
51
|
+
await this.deployWithProvider({
|
|
52
|
+
provider: "sqlite",
|
|
53
|
+
databaseUrl,
|
|
54
|
+
env: args.env
|
|
55
|
+
});
|
|
56
|
+
} catch (error) {
|
|
57
|
+
if (!await this.tryRecoverPartiallyAppliedNormalizedRuntimeMigration({
|
|
58
|
+
databaseFilePath: args.databaseFilePath,
|
|
59
|
+
databaseUrl,
|
|
60
|
+
env: args.env,
|
|
61
|
+
error
|
|
62
|
+
})) throw error;
|
|
63
|
+
}
|
|
64
|
+
await this.cleanupNormalizedRuntimeLegacyArtifacts(args.databaseFilePath);
|
|
65
|
+
}
|
|
66
|
+
async deployPostgres(args) {
|
|
67
|
+
await this.deployWithProvider({
|
|
68
|
+
provider: "postgresql",
|
|
69
|
+
databaseUrl: args.databaseUrl,
|
|
70
|
+
env: args.env
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
async deployWithProvider(args) {
|
|
74
|
+
await this.runPrismaCommand({
|
|
75
|
+
prismaArgs: ["migrate", "deploy"],
|
|
76
|
+
provider: args.provider,
|
|
77
|
+
databaseUrl: args.databaseUrl,
|
|
78
|
+
env: args.env
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
async resolveAppliedMigration(args) {
|
|
82
|
+
await this.runPrismaCommand({
|
|
83
|
+
prismaArgs: [
|
|
84
|
+
"migrate",
|
|
85
|
+
"resolve",
|
|
86
|
+
"--applied",
|
|
87
|
+
args.migrationName
|
|
88
|
+
],
|
|
89
|
+
provider: args.provider,
|
|
90
|
+
databaseUrl: args.databaseUrl,
|
|
91
|
+
env: args.env
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
async runPrismaCommand(args) {
|
|
95
|
+
const resolverEnv = {
|
|
96
|
+
...process.env,
|
|
97
|
+
...args.env ?? {}
|
|
98
|
+
};
|
|
99
|
+
const prismaConfigPath = this.resolveAbsolutePrismaConfigPath(resolverEnv);
|
|
100
|
+
await new Promise((resolve, reject) => {
|
|
101
|
+
const command = spawn(process.execPath, [
|
|
102
|
+
...[this.resolvePrismaCliPath(resolverEnv), ...args.prismaArgs],
|
|
103
|
+
"--config",
|
|
104
|
+
path.basename(prismaConfigPath)
|
|
105
|
+
], {
|
|
106
|
+
cwd: path.dirname(prismaConfigPath),
|
|
107
|
+
env: this.createProcessEnvironment(args.databaseUrl, args.provider, args.env),
|
|
108
|
+
stdio: [
|
|
109
|
+
"ignore",
|
|
110
|
+
"pipe",
|
|
111
|
+
"pipe"
|
|
112
|
+
]
|
|
113
|
+
});
|
|
114
|
+
let stdout = "";
|
|
115
|
+
let stderr = "";
|
|
116
|
+
command.stdout.on("data", (chunk) => {
|
|
117
|
+
stdout += chunk.toString();
|
|
118
|
+
});
|
|
119
|
+
command.stderr.on("data", (chunk) => {
|
|
120
|
+
stderr += chunk.toString();
|
|
121
|
+
});
|
|
122
|
+
command.once("error", (error) => {
|
|
123
|
+
reject(error);
|
|
124
|
+
});
|
|
125
|
+
command.once("close", (exitCode) => {
|
|
126
|
+
if (exitCode === 0) {
|
|
127
|
+
resolve();
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
reject(this.createDeployError(exitCode, stdout, stderr));
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
async tryRecoverPartiallyAppliedNormalizedRuntimeMigration(args) {
|
|
135
|
+
if (!this.isRecoverableNormalizedRuntimeMigrationError(args.error)) return false;
|
|
136
|
+
if (!await this.repairPartiallyAppliedNormalizedRuntimeSqliteDatabase(args.databaseFilePath)) return false;
|
|
137
|
+
await this.resolveAppliedMigration({
|
|
138
|
+
provider: "sqlite",
|
|
139
|
+
databaseUrl: args.databaseUrl,
|
|
140
|
+
migrationName: PrismaMigrationOperations.normalizedRuntimeMigrationName,
|
|
141
|
+
env: args.env
|
|
142
|
+
});
|
|
143
|
+
await this.deployWithProvider({
|
|
144
|
+
provider: "sqlite",
|
|
145
|
+
databaseUrl: args.databaseUrl,
|
|
146
|
+
env: args.env
|
|
147
|
+
});
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
isRecoverableNormalizedRuntimeMigrationError(error) {
|
|
151
|
+
if (!(error instanceof Error)) return false;
|
|
152
|
+
return error.message.includes("Error: P3009") && error.message.includes(PrismaMigrationOperations.normalizedRuntimeMigrationName);
|
|
153
|
+
}
|
|
154
|
+
async repairPartiallyAppliedNormalizedRuntimeSqliteDatabase(databaseFilePath) {
|
|
155
|
+
const { createClient } = await import("@libsql/client");
|
|
156
|
+
const client = createClient({ url: this.sqliteFilePathToDatabaseUrl(databaseFilePath) });
|
|
157
|
+
try {
|
|
158
|
+
if (!await this.hasActiveFailedMigrationRecord(client, PrismaMigrationOperations.normalizedRuntimeMigrationName)) return false;
|
|
159
|
+
const runColumns = await this.readSqliteTableColumns(client, "Run");
|
|
160
|
+
if (!(runColumns.has("finished_at") && runColumns.has("revision") && runColumns.has("outputs_by_node_json") && !runColumns.has("state_json"))) return false;
|
|
161
|
+
await this.ensureNormalizedRuntimeRepairArtifacts(client);
|
|
162
|
+
return true;
|
|
163
|
+
} finally {
|
|
164
|
+
client.close();
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
async hasActiveFailedMigrationRecord(client, migrationName) {
|
|
168
|
+
return (await client.execute({
|
|
169
|
+
sql: [
|
|
170
|
+
"SELECT 1 AS \"has_failed\"",
|
|
171
|
+
"FROM \"_prisma_migrations\"",
|
|
172
|
+
"WHERE \"migration_name\" = ?",
|
|
173
|
+
" AND \"finished_at\" IS NULL",
|
|
174
|
+
" AND \"rolled_back_at\" IS NULL",
|
|
175
|
+
"LIMIT 1"
|
|
176
|
+
].join(" "),
|
|
177
|
+
args: [migrationName]
|
|
178
|
+
})).rows.length > 0;
|
|
179
|
+
}
|
|
180
|
+
async readSqliteTableColumns(client, tableName) {
|
|
181
|
+
const result = await client.execute(`PRAGMA table_info("${tableName}")`);
|
|
182
|
+
return new Set(result.rows.map((row) => String(row.name)));
|
|
183
|
+
}
|
|
184
|
+
async ensureNormalizedRuntimeRepairArtifacts(client) {
|
|
185
|
+
await client.execute(`
|
|
186
|
+
CREATE TABLE IF NOT EXISTS "RunWorkItem" (
|
|
187
|
+
"work_item_id" TEXT NOT NULL PRIMARY KEY,
|
|
188
|
+
"run_id" TEXT NOT NULL,
|
|
189
|
+
"workflow_id" TEXT NOT NULL,
|
|
190
|
+
"status" TEXT NOT NULL,
|
|
191
|
+
"target_node_id" TEXT NOT NULL,
|
|
192
|
+
"batch_id" TEXT NOT NULL,
|
|
193
|
+
"queue_name" TEXT,
|
|
194
|
+
"claim_token" TEXT,
|
|
195
|
+
"claimed_by" TEXT,
|
|
196
|
+
"claimed_at" TEXT,
|
|
197
|
+
"available_at" TEXT NOT NULL,
|
|
198
|
+
"enqueued_at" TEXT NOT NULL,
|
|
199
|
+
"completed_at" TEXT,
|
|
200
|
+
"failed_at" TEXT,
|
|
201
|
+
"source_instance_id" TEXT,
|
|
202
|
+
"parent_instance_id" TEXT,
|
|
203
|
+
"items_in" INTEGER NOT NULL,
|
|
204
|
+
"inputs_by_port_json" TEXT NOT NULL,
|
|
205
|
+
"error_json" TEXT,
|
|
206
|
+
CONSTRAINT "RunWorkItem_run_id_fkey" FOREIGN KEY ("run_id") REFERENCES "Run"("run_id") ON DELETE CASCADE ON UPDATE CASCADE
|
|
207
|
+
)
|
|
208
|
+
`);
|
|
209
|
+
await client.execute(`
|
|
210
|
+
CREATE INDEX IF NOT EXISTS "RunWorkItem_run_id_status_available_at_idx"
|
|
211
|
+
ON "RunWorkItem"("run_id", "status", "available_at")
|
|
212
|
+
`);
|
|
213
|
+
await client.execute(`
|
|
214
|
+
CREATE INDEX IF NOT EXISTS "RunWorkItem_run_id_target_node_id_batch_id_idx"
|
|
215
|
+
ON "RunWorkItem"("run_id", "target_node_id", "batch_id")
|
|
216
|
+
`);
|
|
217
|
+
await client.execute(`
|
|
218
|
+
CREATE TABLE IF NOT EXISTS "RunSlotProjection" (
|
|
219
|
+
"run_id" TEXT NOT NULL PRIMARY KEY,
|
|
220
|
+
"workflow_id" TEXT NOT NULL,
|
|
221
|
+
"revision" INTEGER NOT NULL,
|
|
222
|
+
"updated_at" TEXT NOT NULL,
|
|
223
|
+
"slot_states_json" TEXT NOT NULL,
|
|
224
|
+
CONSTRAINT "RunSlotProjection_run_id_fkey" FOREIGN KEY ("run_id") REFERENCES "Run"("run_id") ON DELETE CASCADE ON UPDATE CASCADE
|
|
225
|
+
)
|
|
226
|
+
`);
|
|
227
|
+
await client.execute(`
|
|
228
|
+
CREATE INDEX IF NOT EXISTS "RunSlotProjection_workflow_id_updated_at_idx"
|
|
229
|
+
ON "RunSlotProjection"("workflow_id", "updated_at")
|
|
230
|
+
`);
|
|
231
|
+
await client.execute(`
|
|
232
|
+
INSERT OR IGNORE INTO "RunSlotProjection" (
|
|
233
|
+
"run_id",
|
|
234
|
+
"workflow_id",
|
|
235
|
+
"revision",
|
|
236
|
+
"updated_at",
|
|
237
|
+
"slot_states_json"
|
|
238
|
+
)
|
|
239
|
+
SELECT
|
|
240
|
+
"run_id",
|
|
241
|
+
"workflow_id",
|
|
242
|
+
"revision",
|
|
243
|
+
"updated_at",
|
|
244
|
+
json_object('slotStatesByNodeId', json('{}'))
|
|
245
|
+
FROM "Run"
|
|
246
|
+
`);
|
|
247
|
+
}
|
|
248
|
+
async cleanupNormalizedRuntimeLegacyArtifacts(databaseFilePath) {
|
|
249
|
+
const { createClient } = await import("@libsql/client");
|
|
250
|
+
const client = createClient({ url: this.sqliteFilePathToDatabaseUrl(databaseFilePath) });
|
|
251
|
+
try {
|
|
252
|
+
const runColumns = await this.readSqliteTableColumns(client, "Run");
|
|
253
|
+
if (!(runColumns.has("finished_at") && runColumns.has("revision") && runColumns.has("outputs_by_node_json") && !runColumns.has("state_json"))) return;
|
|
254
|
+
const runSlotProjectionColumns = await this.readSqliteTableColumns(client, "RunSlotProjection");
|
|
255
|
+
await client.execute("DROP TABLE IF EXISTS \"Run_legacy\"");
|
|
256
|
+
if (runSlotProjectionColumns.size > 0) await client.execute("DROP TABLE IF EXISTS \"RunProjection\"");
|
|
257
|
+
} finally {
|
|
258
|
+
client.close();
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
sqliteFilePathToDatabaseUrl(databaseFilePath) {
|
|
262
|
+
return `file:${path.resolve(databaseFilePath)}`;
|
|
263
|
+
}
|
|
264
|
+
createProcessEnvironment(databaseUrl, provider, env) {
|
|
265
|
+
return {
|
|
266
|
+
...process.env,
|
|
267
|
+
...env ?? {},
|
|
268
|
+
DATABASE_URL: databaseUrl,
|
|
269
|
+
CODEMATION_PRISMA_PROVIDER: provider
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
resolvePrismaCliPath(env) {
|
|
273
|
+
const configuredPath = env.CODEMATION_PRISMA_CLI_PATH;
|
|
274
|
+
if (configuredPath && existsSync(configuredPath)) return configuredPath;
|
|
275
|
+
const packageRoot = this.resolvePackageRoot(env);
|
|
276
|
+
const packageManagerCandidates = [path.resolve(process.cwd(), "node_modules", "prisma", "build", "index.js"), path.resolve(packageRoot, "node_modules", "prisma", "build", "index.js")];
|
|
277
|
+
for (const candidate of packageManagerCandidates) if (existsSync(candidate)) return candidate;
|
|
278
|
+
try {
|
|
279
|
+
return this.require.resolve("prisma/build/index.js", { paths: [process.cwd(), packageRoot] });
|
|
280
|
+
} catch {
|
|
281
|
+
throw new Error("Unable to resolve the Prisma CLI required for startup migrations. Ensure `prisma` is installed.");
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
resolveAbsolutePrismaConfigPath(env) {
|
|
285
|
+
const configuredPath = env.CODEMATION_PRISMA_CONFIG_PATH;
|
|
286
|
+
const packageRoot = this.resolvePackageRoot(env);
|
|
287
|
+
if (configuredPath) return path.isAbsolute(configuredPath) ? configuredPath : path.resolve(packageRoot, configuredPath);
|
|
288
|
+
return path.resolve(packageRoot, "prisma.config.ts");
|
|
289
|
+
}
|
|
290
|
+
async ensureSqliteParentDirectoryExists(databaseFilePath) {
|
|
291
|
+
await mkdir(path.dirname(databaseFilePath), { recursive: true });
|
|
292
|
+
}
|
|
293
|
+
createDeployError(exitCode, stdout, stderr) {
|
|
294
|
+
const output = stderr.trim() || stdout.trim();
|
|
295
|
+
if (!output) return /* @__PURE__ */ new Error(`Prisma migrate deploy failed during startup with exit code ${exitCode ?? "unknown"}.`);
|
|
296
|
+
return /* @__PURE__ */ new Error(`Prisma migrate deploy failed during startup with exit code ${exitCode ?? "unknown"}.\n${output}`);
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
//#endregion
|
|
301
|
+
export { PrismaMigrationOperations };
|
|
302
|
+
//# sourceMappingURL=PrismaMigrationOperations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrismaMigrationOperations.js","names":[],"sources":["../../../src/infrastructure/persistence/PrismaMigrationOperations.ts"],"sourcesContent":["import type { Client } from \"@libsql/client\";\nimport { spawn } from \"node:child_process\";\nimport { existsSync } from \"node:fs\";\nimport { mkdir } from \"node:fs/promises\";\nimport { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport type { AppPersistenceConfig } from \"../../presentation/config/AppConfig\";\n\n/**\n * Contains all runtime logic for deploying Prisma migrations.\n * This class is loaded lazily via `await import(...)` from PrismaMigrationDeployer\n * so that the dynamic fs/path/createRequire operations never appear in the\n * static module graph visible to the Turbopack / Next.js NFT tracer.\n */\nexport class PrismaMigrationOperations {\n private static readonly normalizedRuntimeMigrationName = \"20260407140000_run_normalized_persistence\";\n private readonly require = createRequire(import.meta.url);\n\n async deployPersistence(persistence: AppPersistenceConfig, env?: Readonly<NodeJS.ProcessEnv>): Promise<void> {\n if (persistence.kind === \"none\") {\n return;\n }\n if (persistence.kind === \"postgresql\") {\n await this.deployPostgres({ databaseUrl: persistence.databaseUrl, env });\n return;\n }\n await this.deploySqlite({ databaseFilePath: persistence.databaseFilePath, env });\n }\n\n async deploy(args: Readonly<{ databaseUrl: string; env?: Readonly<NodeJS.ProcessEnv> }>): Promise<void> {\n await this.deployPostgres(args);\n }\n\n resolvePackageRoot(env: Readonly<NodeJS.ProcessEnv> = process.env): string {\n const configuredRoot = env.CODEMATION_HOST_PACKAGE_ROOT;\n if (configuredRoot) {\n return configuredRoot;\n }\n let currentDirectory = path.dirname(fileURLToPath(import.meta.url));\n for (let depth = 0; depth < 8; depth += 1) {\n if (existsSync(path.join(currentDirectory, \"prisma\", \"schema.postgresql.prisma\"))) {\n return currentDirectory;\n }\n const parentDirectory = path.dirname(currentDirectory);\n if (parentDirectory === currentDirectory) {\n break;\n }\n currentDirectory = parentDirectory;\n }\n throw new Error(`Could not locate prisma/schema.postgresql.prisma near ${fileURLToPath(import.meta.url)}.`);\n }\n\n private async deploySqlite(\n args: Readonly<{ databaseFilePath: string; env?: Readonly<NodeJS.ProcessEnv> }>,\n ): Promise<void> {\n await this.ensureSqliteParentDirectoryExists(args.databaseFilePath);\n const databaseUrl = this.sqliteFilePathToDatabaseUrl(args.databaseFilePath);\n try {\n await this.deployWithProvider({\n provider: \"sqlite\",\n databaseUrl,\n env: args.env,\n });\n } catch (error) {\n const recovered = await this.tryRecoverPartiallyAppliedNormalizedRuntimeMigration({\n databaseFilePath: args.databaseFilePath,\n databaseUrl,\n env: args.env,\n error,\n });\n if (!recovered) {\n throw error;\n }\n }\n await this.cleanupNormalizedRuntimeLegacyArtifacts(args.databaseFilePath);\n }\n\n private async deployPostgres(\n args: Readonly<{ databaseUrl: string; env?: Readonly<NodeJS.ProcessEnv> }>,\n ): Promise<void> {\n await this.deployWithProvider({\n provider: \"postgresql\",\n databaseUrl: args.databaseUrl,\n env: args.env,\n });\n }\n\n private async deployWithProvider(\n args: Readonly<{\n provider: \"postgresql\" | \"sqlite\";\n databaseUrl: string;\n env?: Readonly<NodeJS.ProcessEnv>;\n }>,\n ): Promise<void> {\n await this.runPrismaCommand({\n prismaArgs: [\"migrate\", \"deploy\"],\n provider: args.provider,\n databaseUrl: args.databaseUrl,\n env: args.env,\n });\n }\n\n private async resolveAppliedMigration(\n args: Readonly<{\n provider: \"postgresql\" | \"sqlite\";\n databaseUrl: string;\n migrationName: string;\n env?: Readonly<NodeJS.ProcessEnv>;\n }>,\n ): Promise<void> {\n await this.runPrismaCommand({\n prismaArgs: [\"migrate\", \"resolve\", \"--applied\", args.migrationName],\n provider: args.provider,\n databaseUrl: args.databaseUrl,\n env: args.env,\n });\n }\n\n private async runPrismaCommand(\n args: Readonly<{\n prismaArgs: string[];\n provider: \"postgresql\" | \"sqlite\";\n databaseUrl: string;\n env?: Readonly<NodeJS.ProcessEnv>;\n }>,\n ): Promise<void> {\n const resolverEnv = { ...process.env, ...(args.env ?? {}) };\n const prismaConfigPath = this.resolveAbsolutePrismaConfigPath(resolverEnv);\n await new Promise<void>((resolve, reject) => {\n const command = spawn(\n process.execPath,\n [...[this.resolvePrismaCliPath(resolverEnv), ...args.prismaArgs], \"--config\", path.basename(prismaConfigPath)],\n {\n cwd: path.dirname(prismaConfigPath),\n env: this.createProcessEnvironment(args.databaseUrl, args.provider, args.env),\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n },\n );\n let stdout = \"\";\n let stderr = \"\";\n command.stdout.on(\"data\", (chunk: Buffer | string) => {\n stdout += chunk.toString();\n });\n command.stderr.on(\"data\", (chunk: Buffer | string) => {\n stderr += chunk.toString();\n });\n command.once(\"error\", (error) => {\n reject(error);\n });\n command.once(\"close\", (exitCode) => {\n if (exitCode === 0) {\n resolve();\n return;\n }\n reject(this.createDeployError(exitCode, stdout, stderr));\n });\n });\n }\n\n private async tryRecoverPartiallyAppliedNormalizedRuntimeMigration(\n args: Readonly<{\n databaseFilePath: string;\n databaseUrl: string;\n env?: Readonly<NodeJS.ProcessEnv>;\n error: unknown;\n }>,\n ): Promise<boolean> {\n if (!this.isRecoverableNormalizedRuntimeMigrationError(args.error)) {\n return false;\n }\n const repaired = await this.repairPartiallyAppliedNormalizedRuntimeSqliteDatabase(args.databaseFilePath);\n if (!repaired) {\n return false;\n }\n await this.resolveAppliedMigration({\n provider: \"sqlite\",\n databaseUrl: args.databaseUrl,\n migrationName: PrismaMigrationOperations.normalizedRuntimeMigrationName,\n env: args.env,\n });\n await this.deployWithProvider({\n provider: \"sqlite\",\n databaseUrl: args.databaseUrl,\n env: args.env,\n });\n return true;\n }\n\n private isRecoverableNormalizedRuntimeMigrationError(error: unknown): boolean {\n if (!(error instanceof Error)) {\n return false;\n }\n return (\n error.message.includes(\"Error: P3009\") &&\n error.message.includes(PrismaMigrationOperations.normalizedRuntimeMigrationName)\n );\n }\n\n private async repairPartiallyAppliedNormalizedRuntimeSqliteDatabase(databaseFilePath: string): Promise<boolean> {\n // Lazy import: @libsql/client pulls in platform-specific native bindings that confuse the\n // Next.js / Turbopack module tracer (forcing the whole project to be traced via NFT). This\n // recovery path is rarely needed, so defer the load until it's actually invoked.\n const { createClient } = await import(\"@libsql/client\");\n const client = createClient({ url: this.sqliteFilePathToDatabaseUrl(databaseFilePath) });\n try {\n const failedMigration = await this.hasActiveFailedMigrationRecord(\n client,\n PrismaMigrationOperations.normalizedRuntimeMigrationName,\n );\n if (!failedMigration) {\n return false;\n }\n const runColumns = await this.readSqliteTableColumns(client, \"Run\");\n const hasNormalizedRunShape =\n runColumns.has(\"finished_at\") &&\n runColumns.has(\"revision\") &&\n runColumns.has(\"outputs_by_node_json\") &&\n !runColumns.has(\"state_json\");\n if (!hasNormalizedRunShape) {\n return false;\n }\n await this.ensureNormalizedRuntimeRepairArtifacts(client);\n return true;\n } finally {\n client.close();\n }\n }\n\n private async hasActiveFailedMigrationRecord(client: Client, migrationName: string): Promise<boolean> {\n const result = await client.execute({\n sql: [\n 'SELECT 1 AS \"has_failed\"',\n 'FROM \"_prisma_migrations\"',\n 'WHERE \"migration_name\" = ?',\n ' AND \"finished_at\" IS NULL',\n ' AND \"rolled_back_at\" IS NULL',\n \"LIMIT 1\",\n ].join(\" \"),\n args: [migrationName],\n });\n return result.rows.length > 0;\n }\n\n private async readSqliteTableColumns(client: Client, tableName: string): Promise<Set<string>> {\n const result = await client.execute(`PRAGMA table_info(\"${tableName}\")`);\n return new Set(result.rows.map((row) => String(row.name)));\n }\n\n private async ensureNormalizedRuntimeRepairArtifacts(client: Client): Promise<void> {\n await client.execute(`\n CREATE TABLE IF NOT EXISTS \"RunWorkItem\" (\n \"work_item_id\" TEXT NOT NULL PRIMARY KEY,\n \"run_id\" TEXT NOT NULL,\n \"workflow_id\" TEXT NOT NULL,\n \"status\" TEXT NOT NULL,\n \"target_node_id\" TEXT NOT NULL,\n \"batch_id\" TEXT NOT NULL,\n \"queue_name\" TEXT,\n \"claim_token\" TEXT,\n \"claimed_by\" TEXT,\n \"claimed_at\" TEXT,\n \"available_at\" TEXT NOT NULL,\n \"enqueued_at\" TEXT NOT NULL,\n \"completed_at\" TEXT,\n \"failed_at\" TEXT,\n \"source_instance_id\" TEXT,\n \"parent_instance_id\" TEXT,\n \"items_in\" INTEGER NOT NULL,\n \"inputs_by_port_json\" TEXT NOT NULL,\n \"error_json\" TEXT,\n CONSTRAINT \"RunWorkItem_run_id_fkey\" FOREIGN KEY (\"run_id\") REFERENCES \"Run\"(\"run_id\") ON DELETE CASCADE ON UPDATE CASCADE\n )\n `);\n await client.execute(`\n CREATE INDEX IF NOT EXISTS \"RunWorkItem_run_id_status_available_at_idx\"\n ON \"RunWorkItem\"(\"run_id\", \"status\", \"available_at\")\n `);\n await client.execute(`\n CREATE INDEX IF NOT EXISTS \"RunWorkItem_run_id_target_node_id_batch_id_idx\"\n ON \"RunWorkItem\"(\"run_id\", \"target_node_id\", \"batch_id\")\n `);\n await client.execute(`\n CREATE TABLE IF NOT EXISTS \"RunSlotProjection\" (\n \"run_id\" TEXT NOT NULL PRIMARY KEY,\n \"workflow_id\" TEXT NOT NULL,\n \"revision\" INTEGER NOT NULL,\n \"updated_at\" TEXT NOT NULL,\n \"slot_states_json\" TEXT NOT NULL,\n CONSTRAINT \"RunSlotProjection_run_id_fkey\" FOREIGN KEY (\"run_id\") REFERENCES \"Run\"(\"run_id\") ON DELETE CASCADE ON UPDATE CASCADE\n )\n `);\n await client.execute(`\n CREATE INDEX IF NOT EXISTS \"RunSlotProjection_workflow_id_updated_at_idx\"\n ON \"RunSlotProjection\"(\"workflow_id\", \"updated_at\")\n `);\n await client.execute(`\n INSERT OR IGNORE INTO \"RunSlotProjection\" (\n \"run_id\",\n \"workflow_id\",\n \"revision\",\n \"updated_at\",\n \"slot_states_json\"\n )\n SELECT\n \"run_id\",\n \"workflow_id\",\n \"revision\",\n \"updated_at\",\n json_object('slotStatesByNodeId', json('{}'))\n FROM \"Run\"\n `);\n }\n\n private async cleanupNormalizedRuntimeLegacyArtifacts(databaseFilePath: string): Promise<void> {\n const { createClient } = await import(\"@libsql/client\");\n const client = createClient({ url: this.sqliteFilePathToDatabaseUrl(databaseFilePath) });\n try {\n const runColumns = await this.readSqliteTableColumns(client, \"Run\");\n const hasNormalizedRunShape =\n runColumns.has(\"finished_at\") &&\n runColumns.has(\"revision\") &&\n runColumns.has(\"outputs_by_node_json\") &&\n !runColumns.has(\"state_json\");\n if (!hasNormalizedRunShape) {\n return;\n }\n const runSlotProjectionColumns = await this.readSqliteTableColumns(client, \"RunSlotProjection\");\n await client.execute('DROP TABLE IF EXISTS \"Run_legacy\"');\n if (runSlotProjectionColumns.size > 0) {\n await client.execute('DROP TABLE IF EXISTS \"RunProjection\"');\n }\n } finally {\n client.close();\n }\n }\n\n private sqliteFilePathToDatabaseUrl(databaseFilePath: string): string {\n return `file:${path.resolve(databaseFilePath)}`;\n }\n\n private createProcessEnvironment(\n databaseUrl: string,\n provider: \"postgresql\" | \"sqlite\",\n env?: Readonly<NodeJS.ProcessEnv>,\n ): NodeJS.ProcessEnv {\n return {\n ...process.env,\n ...(env ?? {}),\n DATABASE_URL: databaseUrl,\n CODEMATION_PRISMA_PROVIDER: provider,\n };\n }\n\n private resolvePrismaCliPath(env: Readonly<NodeJS.ProcessEnv>): string {\n const configuredPath = env.CODEMATION_PRISMA_CLI_PATH;\n if (configuredPath && existsSync(configuredPath)) {\n return configuredPath;\n }\n const packageRoot = this.resolvePackageRoot(env);\n const packageManagerCandidates = [\n path.resolve(process.cwd(), \"node_modules\", \"prisma\", \"build\", \"index.js\"),\n path.resolve(packageRoot, \"node_modules\", \"prisma\", \"build\", \"index.js\"),\n ];\n for (const candidate of packageManagerCandidates) {\n if (existsSync(candidate)) {\n return candidate;\n }\n }\n try {\n return this.require.resolve(\"prisma/build/index.js\", {\n paths: [process.cwd(), packageRoot],\n });\n } catch {\n throw new Error(\n \"Unable to resolve the Prisma CLI required for startup migrations. Ensure `prisma` is installed.\",\n );\n }\n }\n\n private resolveAbsolutePrismaConfigPath(env: Readonly<NodeJS.ProcessEnv>): string {\n const configuredPath = env.CODEMATION_PRISMA_CONFIG_PATH;\n const packageRoot = this.resolvePackageRoot(env);\n if (configuredPath) {\n return path.isAbsolute(configuredPath) ? configuredPath : path.resolve(packageRoot, configuredPath);\n }\n return path.resolve(packageRoot, \"prisma.config.ts\");\n }\n\n private async ensureSqliteParentDirectoryExists(databaseFilePath: string): Promise<void> {\n await mkdir(path.dirname(databaseFilePath), { recursive: true });\n }\n\n private createDeployError(exitCode: number | null, stdout: string, stderr: string): Error {\n const output = stderr.trim() || stdout.trim();\n if (!output) {\n return new Error(`Prisma migrate deploy failed during startup with exit code ${exitCode ?? \"unknown\"}.`);\n }\n return new Error(`Prisma migrate deploy failed during startup with exit code ${exitCode ?? \"unknown\"}.\\n${output}`);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAeA,IAAa,4BAAb,MAAa,0BAA0B;CACrC,OAAwB,iCAAiC;CACzD,AAAiB,UAAU,cAAc,OAAO,KAAK,IAAI;CAEzD,MAAM,kBAAkB,aAAmC,KAAkD;AAC3G,MAAI,YAAY,SAAS,OACvB;AAEF,MAAI,YAAY,SAAS,cAAc;AACrC,SAAM,KAAK,eAAe;IAAE,aAAa,YAAY;IAAa;IAAK,CAAC;AACxE;;AAEF,QAAM,KAAK,aAAa;GAAE,kBAAkB,YAAY;GAAkB;GAAK,CAAC;;CAGlF,MAAM,OAAO,MAA2F;AACtG,QAAM,KAAK,eAAe,KAAK;;CAGjC,mBAAmB,MAAmC,QAAQ,KAAa;EACzE,MAAM,iBAAiB,IAAI;AAC3B,MAAI,eACF,QAAO;EAET,IAAI,mBAAmB,KAAK,QAAQ,cAAc,OAAO,KAAK,IAAI,CAAC;AACnE,OAAK,IAAI,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG;AACzC,OAAI,WAAW,KAAK,KAAK,kBAAkB,UAAU,2BAA2B,CAAC,CAC/E,QAAO;GAET,MAAM,kBAAkB,KAAK,QAAQ,iBAAiB;AACtD,OAAI,oBAAoB,iBACtB;AAEF,sBAAmB;;AAErB,QAAM,IAAI,MAAM,yDAAyD,cAAc,OAAO,KAAK,IAAI,CAAC,GAAG;;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AY,UAAU,KAAK,SAAS"}
|
package/dist/mapping.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "./ItemsInputNormalizer-
|
|
2
|
-
import { t as WorkflowPolicyUiPresentationFactory } from "./WorkflowPolicyUiPresentationFactory-
|
|
1
|
+
import "./ItemsInputNormalizer-CFkfNMLt.js";
|
|
2
|
+
import { t as WorkflowPolicyUiPresentationFactory } from "./WorkflowPolicyUiPresentationFactory-BNn2fvR_.js";
|
|
3
3
|
export { WorkflowPolicyUiPresentationFactory };
|
package/dist/mapping.js
CHANGED
package/dist/nextServer.d.ts
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import { n as
|
|
2
|
-
import {
|
|
3
|
-
import { r as AppConfig } from "./CodemationAppContext-
|
|
1
|
+
import { n as OAuthFlowExecutor, r as RunIntentService } from "./index-ChIfeWzk.js";
|
|
2
|
+
import { A as WorkflowDefinition, D as RunIdFactory, St as WebhookInvocationMatch, _ as Item, a as BinaryStorage, g as BinaryAttachment, h as ActivationIdFactory, tt as WorkflowActivationPolicy } from "./ItemsInputNormalizer-CFkfNMLt.js";
|
|
3
|
+
import { r as AppConfig } from "./CodemationAppContext-K51b7oXe.js";
|
|
4
4
|
import { l as Logger, u as LoggerFactory } from "./CodemationWhitelabelConfig-Ca2mCUeC.js";
|
|
5
5
|
import { n as logLevelPolicyFactory, t as LogLevelPolicyFactory } from "./LogLevelPolicyFactory-ewCHLDLn.js";
|
|
6
6
|
import { a as CodemationFrontendAuthSnapshot, i as CodemationFrontendAuthProviderSnapshot, n as InternalAuthBootstrap, r as FrontendAppConfig, t as PublicFrontendBootstrap } from "./PublicFrontendBootstrap-Cev3qK46.js";
|
|
7
|
-
import "./CodemationConfigNormalizer-
|
|
8
|
-
import { a as CredentialSecretCipher, i as CredentialInstanceService, o as McpServerCatalog, r as CredentialBindingService, t as CredentialStore } from "./CredentialServices-
|
|
9
|
-
import "./CredentialContractsRegistry-
|
|
10
|
-
import "./TelemetryContracts-
|
|
7
|
+
import "./CodemationConfigNormalizer-B4rDYC9h.js";
|
|
8
|
+
import { a as CredentialSecretCipher, i as CredentialInstanceService, o as McpServerCatalog, r as CredentialBindingService, t as CredentialStore } from "./CredentialServices-B3wPyp2y.js";
|
|
9
|
+
import "./CredentialContractsRegistry-Dgu-rEXi.js";
|
|
10
|
+
import "./TelemetryContracts-DpZEODQM.js";
|
|
11
11
|
import { i as WorkflowSummary, t as WorkflowDto } from "./WorkflowViewContracts-B7aFQcIw.js";
|
|
12
|
-
import { S as CommandBus, _ as AppContainerLifecycle, a as CodemationHonoApiApp, b as QueryBus, c as SessionVerifier, d as WorkflowRunRetentionPruneScheduler, f as ServerLoggerFactory, g as DatabaseMigrations, i as WorkflowDebuggerOverlayRepository, l as WorkerRuntime, m as WorkflowRunRepository, n as CodemationBootstrapRequest, o as BinaryHttpRouteHandler, p as LogFilter, r as ApplicationTokens, s as ServerHttpRouteParams, t as CodemationPluginListMerger, u as FrontendRuntime, v as AppContainerFactory, y as WorkflowWebsocketServer } from "./CodemationPluginListMerger-
|
|
13
|
-
import { t as AppConfigFactory } from "./AppConfigFactory-
|
|
14
|
-
import "./
|
|
15
|
-
import
|
|
16
|
-
import { t as
|
|
17
|
-
import { t as
|
|
12
|
+
import { S as CommandBus, _ as AppContainerLifecycle, a as CodemationHonoApiApp, b as QueryBus, c as SessionVerifier, d as WorkflowRunRetentionPruneScheduler, f as ServerLoggerFactory, g as DatabaseMigrations, i as WorkflowDebuggerOverlayRepository, l as WorkerRuntime, m as WorkflowRunRepository, n as CodemationBootstrapRequest, o as BinaryHttpRouteHandler, p as LogFilter, r as ApplicationTokens, s as ServerHttpRouteParams, t as CodemationPluginListMerger, u as FrontendRuntime, v as AppContainerFactory, y as WorkflowWebsocketServer } from "./CodemationPluginListMerger-DS6I3Xe0.js";
|
|
13
|
+
import { t as AppConfigFactory } from "./AppConfigFactory-DncmwCD1.js";
|
|
14
|
+
import "./PrismaMigrationDeployer-DdEcXXVi.js";
|
|
15
|
+
import "./InternalHonoApiRouteRegistrar-Ce1yxpnO.js";
|
|
16
|
+
import { n as InternalAuthBootstrapFactory, r as FrontendAppConfigFactory, t as PublicFrontendBootstrapFactory } from "./PublicFrontendBootstrapFactory-ClEjZP74.js";
|
|
17
|
+
import { t as WorkflowPolicyUiPresentationFactory } from "./WorkflowPolicyUiPresentationFactory-BNn2fvR_.js";
|
|
18
|
+
import { t as PairingConfig } from "./pairing.types-D9Bjn98U.js";
|
|
18
19
|
|
|
19
20
|
//#region src/application/dev/DevBootstrapSummaryJson.types.d.ts
|
|
20
21
|
type DevBootstrapSummaryJson = Readonly<{
|
|
@@ -141,6 +142,7 @@ declare class CredentialHttpRouteHandler {
|
|
|
141
142
|
getCredentialTypes(): Promise<Response>;
|
|
142
143
|
getCredentialFieldEnvStatus(): Promise<Response>;
|
|
143
144
|
getCredentialInstances(): Promise<Response>;
|
|
145
|
+
getCredentialApps(): Promise<Response>;
|
|
144
146
|
getCredentialInstance(request: Request, params: ServerHttpRouteParams): Promise<Response>;
|
|
145
147
|
postCredentialInstance(request: Request): Promise<Response>;
|
|
146
148
|
putCredentialInstance(request: Request, params: ServerHttpRouteParams): Promise<Response>;
|
package/dist/nextServer.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { n as logLevelPolicyFactory, t as LogLevelPolicyFactory } from "./LogLevelPolicyFactory-DCUzIN6G.js";
|
|
2
|
-
import "./ApiPaths-
|
|
2
|
+
import "./ApiPaths-DCvrlIjg.js";
|
|
3
3
|
import { a as FilteringLogger, i as PerformanceLogPolicy, n as PerformanceLogPolicyFactory, r as performanceLogPolicyFactory, t as ServerLoggerFactory } from "./ServerLoggerFactory-Ckk52S3w.js";
|
|
4
4
|
import "./decorateParam-BWxkAUSj.js";
|
|
5
5
|
import "./decorate-CXWmflG_.js";
|
|
6
|
-
import { a as CredentialInstanceService, i as CredentialBindingService, m as ApplicationTokens } from "./CredentialServices-
|
|
6
|
+
import { a as CredentialInstanceService, i as CredentialBindingService, m as ApplicationTokens } from "./CredentialServices-Bios0dM8.js";
|
|
7
7
|
import "./CodemationTsyringeTypeInfoRegistrar-Bj6FJYFz.js";
|
|
8
|
-
import { A as WorkflowDefinitionMapper, C as CodemationHonoApiApp, D as FrontendAppConfigFactory, E as InternalAuthBootstrapFactory, P as RunBinaryAttachmentLookupService, S as CredentialHttpRouteHandler, T as PublicFrontendBootstrapFactory, _ as WorkflowHttpRouteHandler, b as RunHttpRouteHandler, d as FrontendRuntime, h as WorkflowRunRetentionPruneScheduler, k as WorkflowWebsocketServer, m as AppContainerLifecycle, p as DatabaseMigrations, t as AppContainerFactory, u as WorkerRuntime, v as WebhookHttpRouteHandler, w as BinaryHttpRouteHandler, x as OAuth2HttpRouteHandler, y as RequestToWebhookItemMapper } from "./AppContainerFactory-
|
|
9
|
-
import
|
|
10
|
-
import "./
|
|
11
|
-
import { t as AppConfigFactory } from "./AppConfigFactory-
|
|
8
|
+
import { A as WorkflowDefinitionMapper, C as CodemationHonoApiApp, D as FrontendAppConfigFactory, E as InternalAuthBootstrapFactory, P as RunBinaryAttachmentLookupService, S as CredentialHttpRouteHandler, T as PublicFrontendBootstrapFactory, _ as WorkflowHttpRouteHandler, b as RunHttpRouteHandler, d as FrontendRuntime, h as WorkflowRunRetentionPruneScheduler, k as WorkflowWebsocketServer, m as AppContainerLifecycle, p as DatabaseMigrations, t as AppContainerFactory, u as WorkerRuntime, v as WebhookHttpRouteHandler, w as BinaryHttpRouteHandler, x as OAuth2HttpRouteHandler, y as RequestToWebhookItemMapper } from "./AppContainerFactory-CHCXP2rn.js";
|
|
9
|
+
import "./InternalPingRegistrar-BavAAnvk.js";
|
|
10
|
+
import { t as WorkflowPolicyUiPresentationFactory } from "./WorkflowPolicyUiPresentationFactory-DfvD2VHk.js";
|
|
11
|
+
import { t as AppConfigFactory } from "./AppConfigFactory-D4LL1aOR.js";
|
|
12
12
|
import { n as CodemationBootstrapRequest, t as CodemationPluginListMerger } from "./CodemationPluginListMerger-D1B1IEbt.js";
|
|
13
13
|
|
|
14
14
|
export { AppConfigFactory, AppContainerFactory, AppContainerLifecycle, ApplicationTokens, BinaryHttpRouteHandler, CodemationBootstrapRequest, CodemationHonoApiApp, CodemationPluginListMerger, CredentialBindingService, CredentialHttpRouteHandler, CredentialInstanceService, DatabaseMigrations, FilteringLogger, FrontendAppConfigFactory, FrontendRuntime, InternalAuthBootstrapFactory, LogLevelPolicyFactory, OAuth2HttpRouteHandler, PerformanceLogPolicy, PerformanceLogPolicyFactory, PublicFrontendBootstrapFactory, RequestToWebhookItemMapper, RunBinaryAttachmentLookupService, RunHttpRouteHandler, ServerLoggerFactory, WebhookHttpRouteHandler, WorkerRuntime, WorkflowDefinitionMapper, WorkflowHttpRouteHandler, WorkflowPolicyUiPresentationFactory, WorkflowRunRetentionPruneScheduler, WorkflowWebsocketServer, logLevelPolicyFactory, performanceLogPolicyFactory };
|
package/dist/pairing.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "./index-
|
|
2
|
-
import {
|
|
3
|
-
import { t as InternalHonoApiRouteRegistrar } from "./InternalHonoApiRouteRegistrar-
|
|
4
|
-
import { i as PairingVerificationSuccess, n as PairingVerificationFailure, r as PairingVerificationResult, t as PairingConfig } from "./pairing.types-
|
|
1
|
+
import "./index-ChIfeWzk.js";
|
|
2
|
+
import { G as TypeToken } from "./ItemsInputNormalizer-CFkfNMLt.js";
|
|
3
|
+
import { t as InternalHonoApiRouteRegistrar } from "./InternalHonoApiRouteRegistrar-Ce1yxpnO.js";
|
|
4
|
+
import { i as PairingVerificationSuccess, n as PairingVerificationFailure, r as PairingVerificationResult, t as PairingConfig } from "./pairing.types-D9Bjn98U.js";
|
|
5
5
|
import { Hono, MiddlewareHandler } from "hono";
|
|
6
6
|
|
|
7
7
|
//#region src/pairing/HmacRequestSigner.d.ts
|
|
@@ -10,7 +10,7 @@ interface SignedHeaders {
|
|
|
10
10
|
}
|
|
11
11
|
declare class HmacRequestSigner {
|
|
12
12
|
private readonly config;
|
|
13
|
-
constructor(config
|
|
13
|
+
constructor(config?: PairingConfig | null);
|
|
14
14
|
sign(method: string, urlOrPath: string, body: string): SignedHeaders;
|
|
15
15
|
}
|
|
16
16
|
//#endregion
|
|
@@ -29,19 +29,38 @@ declare class PairedFetch {
|
|
|
29
29
|
delete(url: string): Promise<Response>;
|
|
30
30
|
}
|
|
31
31
|
//#endregion
|
|
32
|
+
//#region src/pairing/HmacNonceStore.d.ts
|
|
33
|
+
/**
|
|
34
|
+
* Seam for durable HMAC replay-protection nonce storage (T6 security fix).
|
|
35
|
+
*
|
|
36
|
+
* The default in-process store (InMemoryHmacNonceStore) clears on restart, allowing
|
|
37
|
+
* replay within the timestamp window. PrismaHmacNonceStore provides durability.
|
|
38
|
+
*/
|
|
39
|
+
interface HmacNonceStore {
|
|
40
|
+
/**
|
|
41
|
+
* Atomically record a nonce if it has not been seen before.
|
|
42
|
+
* Returns `true` if the nonce was new (request should proceed),
|
|
43
|
+
* `false` if the nonce was already present (replay — reject).
|
|
44
|
+
*/
|
|
45
|
+
recordIfNew(nonce: string, expiresAt: Date): Promise<boolean>;
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
32
48
|
//#region src/pairing/IncomingHmacVerifier.d.ts
|
|
33
49
|
/**
|
|
34
50
|
* Verifies incoming HMAC-signed requests from the control plane.
|
|
35
51
|
* Mirrors the control-plane HmacVerifier — both sides follow docs/pairing-protocol.md.
|
|
52
|
+
*
|
|
53
|
+
* Security (T6): The nonce store is injected and defaults to PrismaHmacNonceStore in
|
|
54
|
+
* managed mode so replay protection survives process restarts within the 300-second
|
|
55
|
+
* timestamp window.
|
|
36
56
|
*/
|
|
37
57
|
declare class IncomingHmacVerifier {
|
|
38
58
|
private readonly config;
|
|
39
|
-
private readonly
|
|
59
|
+
private readonly nonceStore;
|
|
40
60
|
private readonly nonceTtlSeconds;
|
|
41
|
-
constructor(config: PairingConfig);
|
|
42
|
-
verify(method: string, url: string, body: string, authHeader: string | null): PairingVerificationResult
|
|
61
|
+
constructor(config: (PairingConfig | null) | undefined, nonceStore: HmacNonceStore);
|
|
62
|
+
verify(method: string, url: string, body: string, authHeader: string | null): Promise<PairingVerificationResult>;
|
|
43
63
|
private parseHeader;
|
|
44
|
-
private pruneExpiredNonces;
|
|
45
64
|
}
|
|
46
65
|
//#endregion
|
|
47
66
|
//#region src/pairing/InternalHmacAuthMiddleware.d.ts
|
package/dist/pairing.js
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
import "./decorateParam-BWxkAUSj.js";
|
|
2
|
-
import "./decorate-CXWmflG_.js";
|
|
3
|
-
import { a as
|
|
2
|
+
import { t as __decorate } from "./decorate-CXWmflG_.js";
|
|
3
|
+
import { a as PairingConfigFactory, c as PairingConfigToken, n as InternalHmacAuthMiddleware, o as PairedFetch, r as IncomingHmacVerifier, s as HmacRequestSigner, t as InternalPingRegistrar } from "./InternalPingRegistrar-BavAAnvk.js";
|
|
4
|
+
import { injectable } from "@codemation/core";
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
//#region src/pairing/InMemoryHmacNonceStore.ts
|
|
7
|
+
let InMemoryHmacNonceStore = class InMemoryHmacNonceStore$1 {
|
|
8
|
+
store = /* @__PURE__ */ new Map();
|
|
9
|
+
async recordIfNew(nonce, expiresAt) {
|
|
10
|
+
const nowSec = Math.floor(Date.now() / 1e3);
|
|
11
|
+
for (const [key, expirySec] of this.store.entries()) if (expirySec <= nowSec) this.store.delete(key);
|
|
12
|
+
if (this.store.has(nonce)) return false;
|
|
13
|
+
this.store.set(nonce, Math.floor(expiresAt.getTime() / 1e3));
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
InMemoryHmacNonceStore = __decorate([injectable()], InMemoryHmacNonceStore);
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
export { HmacRequestSigner, IncomingHmacVerifier, InternalHmacAuthMiddleware, InternalPingRegistrar, PairedFetch, PairingConfigFactory, PairingConfigToken };
|
|
21
|
+
//# sourceMappingURL=pairing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pairing.js","names":["InMemoryHmacNonceStore"],"sources":["../src/pairing/InMemoryHmacNonceStore.ts"],"sourcesContent":["import { injectable } from \"@codemation/core\";\nimport type { HmacNonceStore } from \"./HmacNonceStore\";\n\n/**\n * In-memory HMAC nonce store for unit tests and non-managed mode.\n *\n * NOTE: Nonces are lost on process restart; this is intentional for non-managed\n * mode where replay risk is low. Use PrismaHmacNonceStore in managed mode.\n */\n@injectable()\nexport class InMemoryHmacNonceStore implements HmacNonceStore {\n private readonly store = new Map<string, number>();\n\n async recordIfNew(nonce: string, expiresAt: Date): Promise<boolean> {\n const nowSec = Math.floor(Date.now() / 1000);\n // Prune expired entries on each call (mirrors original in-process behaviour)\n for (const [key, expirySec] of this.store.entries()) {\n if (expirySec <= nowSec) this.store.delete(key);\n }\n if (this.store.has(nonce)) return false;\n this.store.set(nonce, Math.floor(expiresAt.getTime() / 1000));\n return true;\n }\n}\n"],"mappings":";;;;;;AAUO,mCAAMA,yBAAiD;CAC5D,AAAiB,wBAAQ,IAAI,KAAqB;CAElD,MAAM,YAAY,OAAe,WAAmC;EAClE,MAAM,SAAS,KAAK,MAAM,KAAK,KAAK,GAAG,IAAK;AAE5C,OAAK,MAAM,CAAC,KAAK,cAAc,KAAK,MAAM,SAAS,CACjD,KAAI,aAAa,OAAQ,MAAK,MAAM,OAAO,IAAI;AAEjD,MAAI,KAAK,MAAM,IAAI,MAAM,CAAE,QAAO;AAClC,OAAK,MAAM,IAAI,OAAO,KAAK,MAAM,UAAU,SAAS,GAAG,IAAK,CAAC;AAC7D,SAAO;;;qCAZV,YAAY"}
|
|
@@ -16,4 +16,4 @@ type PairingVerificationSuccess = {
|
|
|
16
16
|
type PairingVerificationResult = PairingVerificationSuccess | PairingVerificationFailure;
|
|
17
17
|
//#endregion
|
|
18
18
|
export { PairingVerificationSuccess as i, PairingVerificationFailure as n, PairingVerificationResult as r, PairingConfig as t };
|
|
19
|
-
//# sourceMappingURL=pairing.types-
|
|
19
|
+
//# sourceMappingURL=pairing.types-D9Bjn98U.d.ts.map
|
|
@@ -1,8 +1,32 @@
|
|
|
1
|
-
import "./index-
|
|
2
|
-
import "./ItemsInputNormalizer-
|
|
3
|
-
import { i as AppPersistenceConfig } from "./CodemationAppContext-
|
|
1
|
+
import "./index-ChIfeWzk.js";
|
|
2
|
+
import "./ItemsInputNormalizer-CFkfNMLt.js";
|
|
3
|
+
import { i as AppPersistenceConfig } from "./CodemationAppContext-K51b7oXe.js";
|
|
4
4
|
import "./CodemationWhitelabelConfig-Ca2mCUeC.js";
|
|
5
|
-
import "./CodemationConfigNormalizer-
|
|
6
|
-
import { n as
|
|
7
|
-
import {
|
|
8
|
-
|
|
5
|
+
import "./CodemationConfigNormalizer-B4rDYC9h.js";
|
|
6
|
+
import { n as PrismaDatabaseClient, t as AppConfigFactory } from "./AppConfigFactory-DncmwCD1.js";
|
|
7
|
+
import { t as PrismaMigrationDeployer } from "./PrismaMigrationDeployer-DdEcXXVi.js";
|
|
8
|
+
import { t as CodemationPostgresPrismaClientFactory } from "./CodemationPostgresPrismaClientFactory-CTNTPnDr.js";
|
|
9
|
+
|
|
10
|
+
//#region src/infrastructure/persistence/CodemationDatabaseUrlParser.d.ts
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Parses `CODEMATION_DATABASE_URL` into an {@link AppPersistenceConfig}.
|
|
14
|
+
*
|
|
15
|
+
* Supported schemes (case-insensitive):
|
|
16
|
+
* - `sqlite://relative/path/to/file.db` → resolved relative to consumerRoot
|
|
17
|
+
* - `sqlite:///absolute/path/to/file.db` → leading slash = POSIX absolute
|
|
18
|
+
* - `sqlite://C:/path/file.db` → Windows-style absolute (path.isAbsolute()
|
|
19
|
+
* returns true for these)
|
|
20
|
+
* - `pgsql://user:pass@host:5432/dbname` → normalised to postgresql://
|
|
21
|
+
* - `postgresql://user:pass@host:5432/db` → pass-through (Prisma's expected scheme)
|
|
22
|
+
* - `postgres://user:pass@host:5432/db` → pass-through (common alias)
|
|
23
|
+
*
|
|
24
|
+
* Throws on any other scheme. Empty / whitespace input is also an error — callers
|
|
25
|
+
* should default before calling parse().
|
|
26
|
+
*/
|
|
27
|
+
declare class CodemationDatabaseUrlParser {
|
|
28
|
+
parse(url: string, consumerRoot: string): AppPersistenceConfig;
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
export { AppConfigFactory, type AppPersistenceConfig, CodemationDatabaseUrlParser, CodemationPostgresPrismaClientFactory, type PrismaDatabaseClient as PrismaClient, PrismaMigrationDeployer };
|
|
32
|
+
//# sourceMappingURL=persistenceServer.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./decorate-CXWmflG_.js";
|
|
2
|
-
import { i as PrismaMigrationDeployer, n as CodemationDatabaseUrlParser, t as AppConfigFactory } from "./AppConfigFactory-
|
|
3
|
-
import { t as CodemationPostgresPrismaClientFactory } from "./
|
|
2
|
+
import { i as PrismaMigrationDeployer, n as CodemationDatabaseUrlParser, t as AppConfigFactory } from "./AppConfigFactory-D4LL1aOR.js";
|
|
3
|
+
import { t as CodemationPostgresPrismaClientFactory } from "./CodemationPostgresPrismaClientFactory-C7156Fe-.js";
|
|
4
4
|
|
|
5
5
|
export { AppConfigFactory, CodemationDatabaseUrlParser, CodemationPostgresPrismaClientFactory, PrismaMigrationDeployer };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { m as CodemationConfig, o as CodemationPlugin, r as AppConfig } from "./CodemationAppContext-
|
|
2
|
-
import { t as CodemationConsumerConfigLoader } from "./CodemationConsumerConfigLoader-
|
|
1
|
+
import { m as CodemationConfig, o as CodemationPlugin, r as AppConfig } from "./CodemationAppContext-K51b7oXe.js";
|
|
2
|
+
import { t as CodemationConsumerConfigLoader } from "./CodemationConsumerConfigLoader-Dt4jyLx6.js";
|
|
3
3
|
import { i as WorkflowSummary, t as WorkflowDto } from "./WorkflowViewContracts-B7aFQcIw.js";
|
|
4
|
-
import { t as AppConfigFactory } from "./AppConfigFactory-
|
|
5
|
-
import { a as ProcessRunOptions, o as ProcessRunResult, s as ProcessRunner } from "./PublicFrontendBootstrapFactory-
|
|
4
|
+
import { t as AppConfigFactory } from "./AppConfigFactory-DncmwCD1.js";
|
|
5
|
+
import { a as ProcessRunOptions, o as ProcessRunResult, s as ProcessRunner } from "./PublicFrontendBootstrapFactory-ClEjZP74.js";
|
|
6
6
|
import { ChildProcess } from "node:child_process";
|
|
7
7
|
|
|
8
8
|
//#region src/process/ExecaProcessRunner.d.ts
|
|
@@ -104,4 +104,4 @@ declare class WorkflowDiscoveryPathSegmentsComputer {
|
|
|
104
104
|
}
|
|
105
105
|
//#endregion
|
|
106
106
|
export { CodemationResolvedPluginPackage as a, CodemationServerGateway as c, CodemationPluginDiscovery as i, ExecaProcessRunner as l, WorkflowModulePathFinder as n, AppConfigLoadResult as o, CodemationDiscoveredPluginPackage as r, AppConfigLoader as s, WorkflowDiscoveryPathSegmentsComputer as t };
|
|
107
|
-
//# sourceMappingURL=server-
|
|
107
|
+
//# sourceMappingURL=server-B5trn7y4.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as CodemationConfigNormalizer, t as CodemationConsumerConfigLoader } from "./CodemationConsumerConfigLoader-By-6tuGc.js";
|
|
2
|
-
import { m as ApplicationTokens } from "./CredentialServices-
|
|
3
|
-
import { A as WorkflowDefinitionMapper, C as CodemationHonoApiApp, M as GetWorkflowDetailQuery, d as FrontendRuntime, j as GetWorkflowSummariesQuery, m as AppContainerLifecycle, t as AppContainerFactory } from "./AppContainerFactory-
|
|
4
|
-
import { r as CodemationPluginPackageMetadata, t as AppConfigFactory } from "./AppConfigFactory-
|
|
2
|
+
import { m as ApplicationTokens } from "./CredentialServices-Bios0dM8.js";
|
|
3
|
+
import { A as WorkflowDefinitionMapper, C as CodemationHonoApiApp, M as GetWorkflowDetailQuery, d as FrontendRuntime, j as GetWorkflowSummariesQuery, m as AppContainerLifecycle, t as AppContainerFactory } from "./AppContainerFactory-CHCXP2rn.js";
|
|
4
|
+
import { r as CodemationPluginPackageMetadata, t as AppConfigFactory } from "./AppConfigFactory-D4LL1aOR.js";
|
|
5
5
|
import { readFile, readdir } from "node:fs/promises";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import { pathToFileURL } from "node:url";
|
|
@@ -219,4 +219,4 @@ var CodemationPluginDiscovery = class {
|
|
|
219
219
|
|
|
220
220
|
//#endregion
|
|
221
221
|
export { AppConfigLoader as n, CodemationServerGateway as r, CodemationPluginDiscovery as t };
|
|
222
|
-
//# sourceMappingURL=server-
|
|
222
|
+
//# sourceMappingURL=server-CNj_y0QO.js.map
|