@codemation/host 0.1.6 → 0.2.0

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.
Files changed (47) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/{AppConfigFactory-BiFHnorf.d.ts → AppConfigFactory-DHdAGOmC.d.ts} +3 -3
  3. package/dist/{AppContainerFactory-BRU02PTm.js → AppContainerFactory-BKaAUIi-.js} +91 -27
  4. package/dist/AppContainerFactory-BKaAUIi-.js.map +1 -0
  5. package/dist/{CodemationConfig-DuGk7uN5.d.ts → CodemationConfig-DBbMU3HB.d.ts} +2 -2
  6. package/dist/{CodemationConfigNormalizer-BP2-0ZDE.d.ts → CodemationConfigNormalizer-C8wC0skq.d.ts} +2 -2
  7. package/dist/{CodemationConsumerConfigLoader-D5CSz3TQ.d.ts → CodemationConsumerConfigLoader-Ceh6sB3X.d.ts} +3 -2
  8. package/dist/{CodemationConsumerConfigLoader-C_ISRrpI.js → CodemationConsumerConfigLoader-D6LFSlp5.js} +20 -7
  9. package/dist/CodemationConsumerConfigLoader-D6LFSlp5.js.map +1 -0
  10. package/dist/{CodemationPluginListMerger-DFzGgfyI.d.ts → CodemationPluginListMerger-Cx9DnyR-.d.ts} +5 -5
  11. package/dist/{CredentialServices-Bhejvys-.d.ts → CredentialServices-CYETzKyb.d.ts} +14 -5
  12. package/dist/{CredentialServices-xVxVA9Tq.js → CredentialServices-D8BBZH1i.js} +40 -6
  13. package/dist/CredentialServices-D8BBZH1i.js.map +1 -0
  14. package/dist/{PublicFrontendBootstrapFactory-CSgWyTra.d.ts → PublicFrontendBootstrapFactory-DeMjp3cs.d.ts} +5 -2
  15. package/dist/consumer.d.ts +4 -4
  16. package/dist/consumer.js +1 -1
  17. package/dist/credentials.d.ts +3 -3
  18. package/dist/credentials.js +1 -1
  19. package/dist/devServerSidecar.d.ts +1 -1
  20. package/dist/{index-BQaZZmOm.d.ts → index-dK05sTQ4.d.ts} +50 -60
  21. package/dist/index.d.ts +97 -12
  22. package/dist/index.js +4 -4
  23. package/dist/nextServer.d.ts +16 -8
  24. package/dist/nextServer.js +2 -2
  25. package/dist/{persistenceServer-fdldtXJH.d.ts → persistenceServer-D9vUTMqc.d.ts} +2 -2
  26. package/dist/persistenceServer.d.ts +5 -5
  27. package/dist/{server-ChTCEc6R.js → server-C-WZcsId.js} +5 -6
  28. package/dist/{server-ChTCEc6R.js.map → server-C-WZcsId.js.map} +1 -1
  29. package/dist/{server-Cpzpy1Ar.d.ts → server-fxqY2WEi.d.ts} +5 -5
  30. package/dist/server.d.ts +8 -8
  31. package/dist/server.js +4 -4
  32. package/package.json +6 -5
  33. package/playwright.config.ts +10 -6
  34. package/src/application/contracts/WorkflowViewContracts.ts +3 -0
  35. package/src/application/mapping/WorkflowDefinitionMapper.ts +117 -19
  36. package/src/bootstrap/AppContainerFactory.ts +2 -0
  37. package/src/domain/credentials/CredentialInstanceService.ts +8 -1
  38. package/src/domain/credentials/CredentialOAuth2ScopeResolver.ts +61 -0
  39. package/src/domain/credentials/CredentialServices.ts +1 -0
  40. package/src/domain/credentials/OAuth2ConnectServiceFactory.ts +9 -2
  41. package/src/presentation/http/routeHandlers/CredentialHttpRouteHandler.ts +2 -1
  42. package/src/presentation/http/routeHandlers/WorkflowHttpRouteHandler.ts +4 -2
  43. package/src/presentation/server/CodemationConsumerConfigLoader.ts +28 -5
  44. package/src/presentation/server/CodemationPluginDiscovery.ts +4 -6
  45. package/dist/AppContainerFactory-BRU02PTm.js.map +0 -1
  46. package/dist/CodemationConsumerConfigLoader-C_ISRrpI.js.map +0 -1
  47. package/dist/CredentialServices-xVxVA9Tq.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { a as CodemationWhitelabelConfig, o as CodemationLogConfig, t as CodemationAuthConfig, u as LoggerFactory } from "./CodemationAuthConfig-7hEfICPf.js";
2
- import { B as EngineExecutionLimitsPolicyConfig, M as WorkflowDefinition, R as Container, s as AnyCredentialType, z as TypeToken } from "./index-BQaZZmOm.js";
2
+ import { B as Container, H as EngineExecutionLimitsPolicyConfig, N as WorkflowDefinition, V as TypeToken, s as AnyCredentialType } from "./index-dK05sTQ4.js";
3
3
 
4
4
  //#region src/presentation/config/CodemationClassToken.d.ts
5
5
  type CodemationClassToken<TValue> = TypeToken<TValue> & (new (...args: never[]) => TValue);
@@ -177,4 +177,4 @@ interface CodemationConfig {
177
177
  }
178
178
  //#endregion
179
179
  export { CodemationContainerRegistration as C, CodemationPluginPackageMetadata as S, AppPersistenceConfig as _, CodemationConfig as a, CodemationPluginConfig as b, CodemationEngineExecutionLimitsConfig as c, CodemationSchedulerConfig as d, CodemationSchedulerKind as f, AppConfig as g, CodemationRegistrationContextBase as h, CodemationApplicationRuntimeConfig as i, CodemationEventBusConfig as l, CodemationAppContext as m, CodemationAppSchedulerConfig as n, CodemationDatabaseConfig as o, CodemationWorkflowDiscovery as p, CodemationAppSchedulerKind as r, CodemationDatabaseKind as s, CodemationAppDefinition as t, CodemationEventBusKind as u, AppPluginLoadSummary as v, CodemationClassToken as w, CodemationPluginContext as x, CodemationPlugin as y };
180
- //# sourceMappingURL=CodemationConfig-DuGk7uN5.d.ts.map
180
+ //# sourceMappingURL=CodemationConfig-DBbMU3HB.d.ts.map
@@ -1,4 +1,4 @@
1
- import { C as CodemationContainerRegistration, a as CodemationConfig } from "./CodemationConfig-DuGk7uN5.js";
1
+ import { C as CodemationContainerRegistration, a as CodemationConfig } from "./CodemationConfig-DBbMU3HB.js";
2
2
 
3
3
  //#region src/presentation/config/CodemationConfigNormalizer.d.ts
4
4
  type NormalizedCodemationConfig = CodemationConfig & Readonly<{
@@ -6,4 +6,4 @@ type NormalizedCodemationConfig = CodemationConfig & Readonly<{
6
6
  }>;
7
7
  //#endregion
8
8
  export { NormalizedCodemationConfig as t };
9
- //# sourceMappingURL=CodemationConfigNormalizer-BP2-0ZDE.d.ts.map
9
+ //# sourceMappingURL=CodemationConfigNormalizer-C8wC0skq.d.ts.map
@@ -1,4 +1,4 @@
1
- import { t as NormalizedCodemationConfig } from "./CodemationConfigNormalizer-BP2-0ZDE.js";
1
+ import { t as NormalizedCodemationConfig } from "./CodemationConfigNormalizer-C8wC0skq.js";
2
2
 
3
3
  //#region src/presentation/server/CodemationConsumerAppResolver.d.ts
4
4
  type CodemationConsumerApp = Readonly<{
@@ -57,9 +57,10 @@ declare class CodemationConsumerConfigLoader {
57
57
  private createImportSpecifier;
58
58
  private shouldUseNativeRuntimeImport;
59
59
  private shouldResetImporterBeforeImport;
60
+ private createImportSession;
60
61
  private isStoppedTransformServiceError;
61
62
  private exists;
62
63
  }
63
64
  //#endregion
64
65
  export { CodemationConsumerAppResolver as i, CodemationConsumerConfigResolution as n, CodemationConsumerApp as r, CodemationConsumerConfigLoader as t };
65
- //# sourceMappingURL=CodemationConsumerConfigLoader-D5CSz3TQ.d.ts.map
66
+ //# sourceMappingURL=CodemationConsumerConfigLoader-Ceh6sB3X.d.ts.map
@@ -299,23 +299,26 @@ var CodemationConsumerConfigLoader = class CodemationConsumerConfigLoader {
299
299
  async load(args) {
300
300
  const loadStarted = performance.now();
301
301
  let mark = loadStarted;
302
+ const importSession = this.createImportSession();
303
+ const phaseDurations = /* @__PURE__ */ new Map();
302
304
  const phaseMs = (label) => {
303
305
  const now = performance.now();
304
306
  const delta = now - mark;
305
307
  mark = now;
308
+ phaseDurations.set(label, delta);
306
309
  this.performanceDiagnosticsLogger.info(`load.${label} +${delta.toFixed(1)}ms (cumulative ${(now - loadStarted).toFixed(1)}ms)`);
307
310
  };
308
311
  const bootstrapSource = await this.resolveConfigPath(args.consumerRoot, args.configPathOverride);
309
312
  phaseMs("resolveConfigPath");
310
313
  if (!bootstrapSource) throw new Error("Codemation config not found. Expected \"codemation.config.ts\" in the consumer project root or \"src/\".");
311
- const moduleExports = await this.importModule(bootstrapSource);
314
+ const moduleExports = await this.importModule(bootstrapSource, importSession);
312
315
  phaseMs("importConfigModule");
313
316
  const rawConfig = this.configExportsResolver.resolveConfig(moduleExports);
314
317
  if (!rawConfig) throw new Error(`Config file does not export a Codemation config object: ${bootstrapSource}`);
315
318
  const config = this.configNormalizer.normalize(rawConfig);
316
319
  const workflowSources = await this.resolveWorkflowSources(args.consumerRoot, config);
317
320
  phaseMs("resolveWorkflowSources");
318
- const workflows = this.mergeWorkflows(config.workflows ?? [], await this.loadDiscoveredWorkflows(args.consumerRoot, config, workflowSources));
321
+ const workflows = this.mergeWorkflows(config.workflows ?? [], await this.loadDiscoveredWorkflows(args.consumerRoot, config, workflowSources, importSession));
319
322
  phaseMs("loadDiscoveredWorkflows");
320
323
  const resolvedConfig = {
321
324
  ...config,
@@ -353,7 +356,7 @@ var CodemationConsumerConfigLoader = class CodemationConsumerConfigLoader {
353
356
  exists: (absolutePath) => this.exists(absolutePath)
354
357
  })].sort((left, right) => left.localeCompare(right));
355
358
  }
356
- async loadDiscoveredWorkflows(consumerRoot, config, workflowSources) {
359
+ async loadDiscoveredWorkflows(consumerRoot, config, workflowSources, importSession) {
357
360
  const workflowDiscoveryDirectories = config.workflowDiscovery?.directories ?? [];
358
361
  const workflowsById = /* @__PURE__ */ new Map();
359
362
  const loadedWorkflowModules = await Promise.all(workflowSources.map(async (workflowSource) => ({
@@ -363,7 +366,7 @@ var CodemationConsumerConfigLoader = class CodemationConsumerConfigLoader {
363
366
  workflowDiscoveryDirectories,
364
367
  absoluteWorkflowModulePath: workflowSource
365
368
  }),
366
- moduleExports: await this.importModule(workflowSource)
369
+ moduleExports: await this.importModule(workflowSource, importSession)
367
370
  })));
368
371
  for (const loadedWorkflowModule of loadedWorkflowModules) for (const workflow of this.workflowDefinitionExportsResolver.resolve(loadedWorkflowModule.moduleExports)) {
369
372
  const enriched = loadedWorkflowModule.segments && loadedWorkflowModule.segments.length > 0 ? {
@@ -381,10 +384,14 @@ var CodemationConsumerConfigLoader = class CodemationConsumerConfigLoader {
381
384
  for (const workflow of configuredWorkflows) workflowsById.set(workflow.id, workflow);
382
385
  return [...workflowsById.values()];
383
386
  }
384
- async importModule(modulePath) {
387
+ async importModule(modulePath, importSession) {
385
388
  if (this.shouldUseNativeRuntimeImport()) return await this.importModuleWithNativeRuntime(modulePath);
386
389
  const tsconfigPath = await this.resolveTsconfigPath(modulePath);
387
- if (this.shouldResetImporterBeforeImport()) await this.resetImporter(tsconfigPath);
390
+ const cacheKey = tsconfigPath || "default";
391
+ if (importSession.shouldResetImporter && !importSession.resetCacheKeys.has(cacheKey)) {
392
+ await this.resetImporter(tsconfigPath);
393
+ importSession.resetCacheKeys.add(cacheKey);
394
+ }
388
395
  const importSpecifier = await this.createImportSpecifier(modulePath);
389
396
  for (let attempt = 0; attempt < 3; attempt += 1) try {
390
397
  return await (await this.getOrCreateImporter(tsconfigPath)).import(importSpecifier, import.meta.url);
@@ -462,6 +469,12 @@ var CodemationConsumerConfigLoader = class CodemationConsumerConfigLoader {
462
469
  shouldResetImporterBeforeImport() {
463
470
  return (process.env.CODEMATION_DEV_SERVER_TOKEN?.trim().length ?? 0) > 0;
464
471
  }
472
+ createImportSession() {
473
+ return {
474
+ resetCacheKeys: /* @__PURE__ */ new Set(),
475
+ shouldResetImporter: this.shouldResetImporterBeforeImport()
476
+ };
477
+ }
465
478
  isStoppedTransformServiceError(error) {
466
479
  return error instanceof Error && error.message.includes("The service is no longer running");
467
480
  }
@@ -477,4 +490,4 @@ var CodemationConsumerConfigLoader = class CodemationConsumerConfigLoader {
477
490
 
478
491
  //#endregion
479
492
  export { CodemationConfigNormalizer as a, CodemationConsumerAppResolver as i, WorkflowDiscoveryPathSegmentsComputer as n, WorkflowModulePathFinder as r, CodemationConsumerConfigLoader as t };
480
- //# sourceMappingURL=CodemationConsumerConfigLoader-C_ISRrpI.js.map
493
+ //# sourceMappingURL=CodemationConsumerConfigLoader-D6LFSlp5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CodemationConsumerConfigLoader-D6LFSlp5.js","names":["containerRegistrations: Array<CodemationContainerRegistration<unknown>>","credentialTypes: Array<AnyCredentialType>","workflows: Array<WorkflowDefinition>","workflowDirectories: Array<string>","workflows: WorkflowDefinition[]","workflowModulePaths: string[]","bestRoot: string | null","resolvedConfig: NormalizedCodemationConfig"],"sources":["../src/presentation/config/CodemationConfigNormalizer.ts","../src/presentation/server/CodemationConsumerConfigExportsResolver.ts","../src/presentation/server/DiscoveredWorkflowsEmptyMessageFactory.ts","../src/presentation/server/WorkflowDefinitionExportsResolver.ts","../src/presentation/server/CodemationConsumerAppResolver.ts","../src/presentation/server/WorkflowModulePathFinder.ts","../src/presentation/server/WorkflowDiscoveryPathSegmentsComputer.ts","../src/presentation/server/CodemationConsumerConfigLoader.ts"],"sourcesContent":["import type { AnyCredentialType, Container, TypeToken, WorkflowDefinition } from \"@codemation/core\";\nimport type { CodemationContainerRegistration } from \"../../bootstrap/CodemationContainerRegistration\";\nimport type { CodemationAppContext } from \"./CodemationAppContext\";\nimport type { CodemationClassToken } from \"./CodemationClassToken\";\nimport type {\n CodemationApplicationRuntimeConfig,\n CodemationConfig,\n CodemationDatabaseConfig,\n CodemationEventBusConfig,\n CodemationSchedulerConfig,\n} from \"./CodemationConfig\";\n\nexport type NormalizedCodemationConfig = CodemationConfig &\n Readonly<{\n containerRegistrations: ReadonlyArray<CodemationContainerRegistration<unknown>>;\n }>;\n\nexport class CodemationConfigNormalizer {\n normalize(config: CodemationConfig): NormalizedCodemationConfig {\n const collected = this.collectRegistration(config);\n const normalizedRuntime = this.normalizeRuntimeConfig(config);\n const normalizedWorkflowDiscoveryDirectories = [\n ...(config.workflowDiscovery?.directories ?? []),\n ...collected.workflowDirectories,\n ];\n\n return {\n ...config,\n auth: config.app?.auth ?? config.auth,\n containerRegistrations: collected.containerRegistrations,\n credentialTypes: [...(config.credentialTypes ?? []), ...collected.credentialTypes],\n log: config.app?.log ?? config.log,\n runtime: normalizedRuntime,\n whitelabel: config.app?.whitelabel ?? config.whitelabel,\n workflowDiscovery:\n normalizedWorkflowDiscoveryDirectories.length > 0\n ? { directories: normalizedWorkflowDiscoveryDirectories }\n : config.workflowDiscovery,\n workflows: this.mergeWorkflows(config.workflows ?? [], collected.workflows),\n };\n }\n\n private collectRegistration(config: CodemationConfig): Readonly<{\n containerRegistrations: ReadonlyArray<CodemationContainerRegistration<unknown>>;\n credentialTypes: ReadonlyArray<AnyCredentialType>;\n workflows: ReadonlyArray<WorkflowDefinition>;\n workflowDirectories: ReadonlyArray<string>;\n }> {\n if (!config.register) {\n return {\n containerRegistrations: [],\n credentialTypes: [],\n workflows: [],\n workflowDirectories: [],\n };\n }\n\n const containerRegistrations: Array<CodemationContainerRegistration<unknown>> = [];\n const credentialTypes: Array<AnyCredentialType> = [];\n const workflows: Array<WorkflowDefinition> = [];\n const workflowDirectories: Array<string> = [];\n\n const context: CodemationAppContext = {\n registerCredentialType(type) {\n credentialTypes.push(type);\n },\n registerNode<TValue>(token: TypeToken<TValue>, implementation?: CodemationClassToken<TValue>) {\n containerRegistrations.push({\n token,\n useClass: implementation ?? (token as CodemationClassToken<TValue>),\n });\n },\n registerValue<TValue>(token: TypeToken<TValue>, value: TValue) {\n containerRegistrations.push({ token, useValue: value });\n },\n registerClass<TValue>(token: TypeToken<TValue>, implementation: CodemationClassToken<TValue>) {\n containerRegistrations.push({ token, useClass: implementation });\n },\n registerFactory<TValue>(token: TypeToken<TValue>, factory: (container: Container) => TValue) {\n containerRegistrations.push({ token, useFactory: factory });\n },\n registerWorkflow(workflow: WorkflowDefinition) {\n workflows.push(workflow);\n },\n registerWorkflows(nextWorkflows: ReadonlyArray<WorkflowDefinition>) {\n workflows.push(...nextWorkflows);\n },\n discoverWorkflows(...directories: ReadonlyArray<string>) {\n workflowDirectories.push(...directories);\n },\n };\n\n config.register(context);\n\n return {\n containerRegistrations,\n credentialTypes,\n workflows,\n workflowDirectories,\n };\n }\n\n private normalizeRuntimeConfig(config: CodemationConfig): CodemationApplicationRuntimeConfig | undefined {\n if (!config.app) {\n return config.runtime;\n }\n const nextRuntime: CodemationApplicationRuntimeConfig = {\n ...(config.runtime ?? {}),\n frontendPort: config.app.frontendPort ?? config.runtime?.frontendPort,\n database: this.normalizeDatabaseConfig(config),\n eventBus: this.normalizeEventBusConfig(config),\n scheduler: this.normalizeSchedulerConfig(config),\n engineExecutionLimits: config.app.engineExecutionLimits ?? config.runtime?.engineExecutionLimits,\n };\n return nextRuntime;\n }\n\n private normalizeDatabaseConfig(config: CodemationConfig): CodemationDatabaseConfig | undefined {\n if (!config.app) {\n return config.runtime?.database;\n }\n if (config.app.database) {\n return config.app.database;\n }\n if (!config.app.databaseUrl) {\n return config.runtime?.database;\n }\n return {\n ...(config.runtime?.database ?? {}),\n url: config.app.databaseUrl,\n };\n }\n\n private normalizeSchedulerConfig(config: CodemationConfig): CodemationSchedulerConfig | undefined {\n if (!config.app?.scheduler) {\n return config.runtime?.scheduler;\n }\n const scheduler = config.app.scheduler;\n return {\n ...(config.runtime?.scheduler ?? {}),\n kind:\n scheduler.kind === \"queue\" ? \"bullmq\" : scheduler.kind === \"inline\" ? \"local\" : config.runtime?.scheduler?.kind,\n queuePrefix: scheduler.queuePrefix ?? config.runtime?.scheduler?.queuePrefix,\n workerQueues: scheduler.workerQueues ?? config.runtime?.scheduler?.workerQueues,\n };\n }\n\n private normalizeEventBusConfig(config: CodemationConfig): CodemationEventBusConfig | undefined {\n if (!config.app?.scheduler) {\n return config.runtime?.eventBus;\n }\n const scheduler = config.app.scheduler;\n const eventBusKind =\n scheduler.kind === \"queue\" ? \"redis\" : scheduler.kind === \"inline\" ? \"memory\" : config.runtime?.eventBus?.kind;\n return {\n ...(config.runtime?.eventBus ?? {}),\n kind: eventBusKind,\n queuePrefix: scheduler.queuePrefix ?? config.runtime?.eventBus?.queuePrefix,\n redisUrl: scheduler.redisUrl ?? config.runtime?.eventBus?.redisUrl,\n };\n }\n\n private mergeWorkflows(\n configuredWorkflows: ReadonlyArray<WorkflowDefinition>,\n registeredWorkflows: ReadonlyArray<WorkflowDefinition>,\n ): ReadonlyArray<WorkflowDefinition> | undefined {\n if (configuredWorkflows.length === 0 && registeredWorkflows.length === 0) {\n return undefined;\n }\n const workflowsById = new Map<string, WorkflowDefinition>();\n for (const workflow of registeredWorkflows) {\n workflowsById.set(workflow.id, workflow);\n }\n for (const workflow of configuredWorkflows) {\n workflowsById.set(workflow.id, workflow);\n }\n return [...workflowsById.values()];\n }\n}\n","import type { CodemationConfig } from \"../config/CodemationConfig\";\n\nexport class CodemationConsumerConfigExportsResolver {\n resolveConfig(moduleExports: Readonly<Record<string, unknown>>): CodemationConfig | null {\n const defaultExport = moduleExports.default;\n if (this.isConfig(defaultExport)) {\n return defaultExport;\n }\n const namedConfig = moduleExports.codemationHost ?? moduleExports.config;\n if (this.isConfig(namedConfig)) {\n return namedConfig;\n }\n return null;\n }\n\n private isConfig(value: unknown): value is CodemationConfig {\n if (!value || typeof value !== \"object\") {\n return false;\n }\n return (\n \"app\" in value ||\n \"register\" in value ||\n \"credentials\" in value ||\n \"runtime\" in value ||\n \"workflows\" in value ||\n \"workflowDiscovery\" in value ||\n \"plugins\" in value ||\n \"whitelabel\" in value ||\n \"auth\" in value ||\n \"log\" in value\n );\n }\n}\n","export class DiscoveredWorkflowsEmptyMessageFactory {\n create(discoveredPaths: ReadonlyArray<string>): string {\n const lines = discoveredPaths.map((p) => ` - ${p}`).join(\"\\n\");\n return [\n `Discovered ${discoveredPaths.length} file(s) under workflow discovery, but none export a WorkflowDefinition.`,\n lines,\n \"\",\n \"Move shared helpers outside the discovery directories (for example src/lib), or export at least one object with id, name, nodes, and edges from a workflow module.\",\n ].join(\"\\n\");\n }\n}\n","import type { WorkflowDefinition } from \"@codemation/core\";\n\n/**\n * Collects exported values that match the {@link WorkflowDefinition} shape.\n * Other exports (helpers, constants, type-only re-exports) are ignored.\n */\nexport class WorkflowDefinitionExportsResolver {\n resolve(moduleExports: Readonly<Record<string, unknown>>): ReadonlyArray<WorkflowDefinition> {\n const workflows: WorkflowDefinition[] = [];\n for (const exportedValue of Object.values(moduleExports)) {\n if (this.isWorkflowDefinition(exportedValue)) {\n workflows.push(exportedValue);\n }\n }\n return workflows;\n }\n\n private isWorkflowDefinition(value: unknown): value is WorkflowDefinition {\n if (!value || typeof value !== \"object\") {\n return false;\n }\n return \"id\" in value && \"name\" in value && \"nodes\" in value && \"edges\" in value;\n }\n}\n","import type { WorkflowDefinition } from \"@codemation/core\";\nimport { CodemationConfigNormalizer } from \"../config/CodemationConfigNormalizer\";\nimport type { NormalizedCodemationConfig } from \"../config/CodemationConfigNormalizer\";\nimport { CodemationConsumerConfigExportsResolver } from \"./CodemationConsumerConfigExportsResolver\";\nimport { DiscoveredWorkflowsEmptyMessageFactory } from \"./DiscoveredWorkflowsEmptyMessageFactory\";\nimport { WorkflowDefinitionExportsResolver } from \"./WorkflowDefinitionExportsResolver\";\n\nexport type CodemationConsumerApp = Readonly<{\n config: NormalizedCodemationConfig;\n workflowSources: ReadonlyArray<string>;\n}>;\n\nexport class CodemationConsumerAppResolver {\n private readonly configExportsResolver = new CodemationConsumerConfigExportsResolver();\n private readonly configNormalizer = new CodemationConfigNormalizer();\n private readonly workflowDefinitionExportsResolver = new WorkflowDefinitionExportsResolver();\n private readonly discoveredWorkflowsEmptyMessageFactory = new DiscoveredWorkflowsEmptyMessageFactory();\n\n resolve(\n args: Readonly<{\n configModule: Readonly<Record<string, unknown>>;\n workflowModules: ReadonlyArray<Readonly<Record<string, unknown>>>;\n workflowSourcePaths: ReadonlyArray<string>;\n workflowDiscoveryPathSegmentsList?: ReadonlyArray<readonly string[]>;\n }>,\n ): CodemationConsumerApp {\n const rawConfig = this.configExportsResolver.resolveConfig(args.configModule);\n if (!rawConfig) {\n throw new Error(\"Consumer app module does not export a Codemation config object.\");\n }\n const config = this.configNormalizer.normalize(rawConfig);\n const discoveredWorkflows = this.resolveDiscoveredWorkflows(\n args.workflowModules,\n args.workflowSourcePaths,\n args.workflowDiscoveryPathSegmentsList,\n );\n return {\n config: {\n ...config,\n workflows: this.mergeWorkflows(config.workflows ?? [], discoveredWorkflows),\n },\n workflowSources: args.workflowSourcePaths,\n };\n }\n\n private resolveDiscoveredWorkflows(\n workflowModules: ReadonlyArray<Readonly<Record<string, unknown>>>,\n workflowSourcePaths: ReadonlyArray<string>,\n workflowDiscoveryPathSegmentsList: ReadonlyArray<readonly string[]> | undefined,\n ): ReadonlyArray<WorkflowDefinition> {\n const workflowsById = new Map<string, WorkflowDefinition>();\n workflowModules.forEach((workflowModule: Readonly<Record<string, unknown>>, index: number) => {\n const pathSegments = workflowDiscoveryPathSegmentsList?.[index];\n const workflows = this.workflowDefinitionExportsResolver.resolve(workflowModule);\n workflows.forEach((workflow: WorkflowDefinition) => {\n const enriched =\n pathSegments && pathSegments.length > 0\n ? ({ ...workflow, discoveryPathSegments: pathSegments } satisfies WorkflowDefinition)\n : workflow;\n workflowsById.set(workflow.id, enriched);\n });\n });\n if (workflowsById.size === 0 && workflowSourcePaths.length > 0) {\n throw new Error(this.discoveredWorkflowsEmptyMessageFactory.create(workflowSourcePaths));\n }\n return [...workflowsById.values()];\n }\n\n private mergeWorkflows(\n configuredWorkflows: ReadonlyArray<WorkflowDefinition>,\n discoveredWorkflows: ReadonlyArray<WorkflowDefinition>,\n ): ReadonlyArray<WorkflowDefinition> {\n const workflowsById = new Map<string, WorkflowDefinition>();\n for (const workflow of discoveredWorkflows) {\n workflowsById.set(workflow.id, workflow);\n }\n for (const workflow of configuredWorkflows) {\n workflowsById.set(workflow.id, workflow);\n }\n return [...workflowsById.values()];\n }\n}\n","import { readdir } from \"node:fs/promises\";\nimport path from \"node:path\";\n\nexport class WorkflowModulePathFinder {\n static readonly defaultWorkflowDirectories = [\"src/workflows\", \"workflows\"] as const;\n private readonly workflowExtensions = new Set([\".ts\", \".js\", \".mts\", \".mjs\"]);\n\n async discoverModulePaths(\n args: Readonly<{\n consumerRoot: string;\n workflowDirectories: ReadonlyArray<string> | undefined;\n exists: (absolutePath: string) => Promise<boolean>;\n }>,\n ): Promise<ReadonlyArray<string>> {\n const directories = args.workflowDirectories ?? WorkflowModulePathFinder.defaultWorkflowDirectories;\n const workflowModulePaths: string[] = [];\n for (const directory of directories) {\n const absoluteDirectory = path.resolve(args.consumerRoot, directory);\n if (!(await args.exists(absoluteDirectory))) {\n continue;\n }\n workflowModulePaths.push(...(await this.collectWorkflowModulePaths(absoluteDirectory)));\n }\n return workflowModulePaths;\n }\n\n private async collectWorkflowModulePaths(directoryPath: string): Promise<ReadonlyArray<string>> {\n const entries = await readdir(directoryPath, { withFileTypes: true });\n const workflowModulePaths: string[] = [];\n for (const entry of entries) {\n const entryPath = path.resolve(directoryPath, entry.name);\n if (entry.isDirectory()) {\n workflowModulePaths.push(...(await this.collectWorkflowModulePaths(entryPath)));\n continue;\n }\n if (this.isWorkflowModulePath(entryPath)) {\n workflowModulePaths.push(entryPath);\n }\n }\n return workflowModulePaths;\n }\n\n private isWorkflowModulePath(modulePath: string): boolean {\n const extension = path.extname(modulePath);\n return this.workflowExtensions.has(extension) && !modulePath.endsWith(\".d.ts\");\n }\n}\n","import path from \"node:path\";\n\nimport { WorkflowModulePathFinder } from \"./WorkflowModulePathFinder\";\n\nexport class WorkflowDiscoveryPathSegmentsComputer {\n compute(\n args: Readonly<{\n consumerRoot: string;\n workflowDiscoveryDirectories: ReadonlyArray<string>;\n absoluteWorkflowModulePath: string;\n }>,\n ): readonly string[] | undefined {\n const normalizedConsumer = path.resolve(args.consumerRoot);\n const normalizedWorkflowPath = path.resolve(args.absoluteWorkflowModulePath);\n const directories =\n args.workflowDiscoveryDirectories.length > 0\n ? args.workflowDiscoveryDirectories\n : [...WorkflowModulePathFinder.defaultWorkflowDirectories];\n\n let bestRoot: string | null = null;\n for (const directory of directories) {\n const absoluteDirectory = path.resolve(normalizedConsumer, directory);\n const isPrefix =\n normalizedWorkflowPath === absoluteDirectory ||\n normalizedWorkflowPath.startsWith(`${absoluteDirectory}${path.sep}`);\n if (!isPrefix) {\n continue;\n }\n if (!bestRoot || absoluteDirectory.length > bestRoot.length) {\n bestRoot = absoluteDirectory;\n }\n }\n if (!bestRoot) {\n return undefined;\n }\n const relative = path.relative(bestRoot, normalizedWorkflowPath);\n if (relative.startsWith(\"..\") || path.isAbsolute(relative)) {\n return undefined;\n }\n if (relative.length === 0) {\n return undefined;\n }\n const parts = relative.split(path.sep).filter((segment) => segment.length > 0);\n if (parts.length === 0) {\n return undefined;\n }\n const lastIndex = parts.length - 1;\n const last = parts[lastIndex] ?? \"\";\n const ext = path.extname(last);\n parts[lastIndex] = ext ? last.slice(0, -ext.length) : last;\n return parts;\n }\n}\n","import type { WorkflowDefinition } from \"@codemation/core\";\nimport { access, stat } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport type { NamespacedUnregister } from \"tsx/esm/api\";\nimport type { CodemationConfig } from \"../config/CodemationConfig\";\nimport { CodemationConfigNormalizer } from \"../config/CodemationConfigNormalizer\";\nimport type { NormalizedCodemationConfig } from \"../config/CodemationConfigNormalizer\";\nimport { logLevelPolicyFactory } from \"../../infrastructure/logging/LogLevelPolicyFactory\";\nimport { ServerLoggerFactory } from \"../../infrastructure/logging/ServerLoggerFactory\";\nimport { DiscoveredWorkflowsEmptyMessageFactory } from \"./DiscoveredWorkflowsEmptyMessageFactory\";\nimport { CodemationConsumerConfigExportsResolver } from \"./CodemationConsumerConfigExportsResolver\";\nimport { WorkflowDefinitionExportsResolver } from \"./WorkflowDefinitionExportsResolver\";\nimport { WorkflowDiscoveryPathSegmentsComputer } from \"./WorkflowDiscoveryPathSegmentsComputer\";\nimport { WorkflowModulePathFinder } from \"./WorkflowModulePathFinder\";\n\nexport type CodemationConsumerConfigResolution = Readonly<{\n config: NormalizedCodemationConfig;\n bootstrapSource: string | null;\n workflowSources: ReadonlyArray<string>;\n}>;\n\ntype ConsumerImportSession = Readonly<{\n shouldResetImporter: boolean;\n resetCacheKeys: Set<string>;\n}>;\n\nexport class CodemationConsumerConfigLoader {\n private static readonly importerRegistrationsByTsconfig = new Map<string, NamespacedUnregister>();\n private static readonly importerNamespaceVersionByTsconfig = new Map<string, number>();\n private readonly configExportsResolver = new CodemationConsumerConfigExportsResolver();\n private readonly configNormalizer = new CodemationConfigNormalizer();\n private readonly workflowModulePathFinder = new WorkflowModulePathFinder();\n private readonly workflowDefinitionExportsResolver = new WorkflowDefinitionExportsResolver();\n private readonly discoveredWorkflowsEmptyMessageFactory = new DiscoveredWorkflowsEmptyMessageFactory();\n private readonly pathSegmentsComputer = new WorkflowDiscoveryPathSegmentsComputer();\n private readonly performanceDiagnosticsLogger = new ServerLoggerFactory(\n logLevelPolicyFactory,\n ).createPerformanceDiagnostics(\"codemation-config-loader.timing\");\n\n async load(\n args: Readonly<{ consumerRoot: string; configPathOverride?: string }>,\n ): Promise<CodemationConsumerConfigResolution> {\n const loadStarted = performance.now();\n let mark = loadStarted;\n const importSession = this.createImportSession();\n const phaseDurations = new Map<string, number>();\n const phaseMs = (label: string): void => {\n const now = performance.now();\n const delta = now - mark;\n mark = now;\n phaseDurations.set(label, delta);\n this.performanceDiagnosticsLogger.info(\n `load.${label} +${delta.toFixed(1)}ms (cumulative ${(now - loadStarted).toFixed(1)}ms)`,\n );\n };\n const bootstrapSource = await this.resolveConfigPath(args.consumerRoot, args.configPathOverride);\n phaseMs(\"resolveConfigPath\");\n if (!bootstrapSource) {\n throw new Error(\n 'Codemation config not found. Expected \"codemation.config.ts\" in the consumer project root or \"src/\".',\n );\n }\n const moduleExports = await this.importModule(bootstrapSource, importSession);\n phaseMs(\"importConfigModule\");\n const rawConfig = this.configExportsResolver.resolveConfig(moduleExports);\n if (!rawConfig) {\n throw new Error(`Config file does not export a Codemation config object: ${bootstrapSource}`);\n }\n const config = this.configNormalizer.normalize(rawConfig);\n const workflowSources = await this.resolveWorkflowSources(args.consumerRoot, config);\n phaseMs(\"resolveWorkflowSources\");\n const workflows = this.mergeWorkflows(\n config.workflows ?? [],\n await this.loadDiscoveredWorkflows(args.consumerRoot, config, workflowSources, importSession),\n );\n phaseMs(\"loadDiscoveredWorkflows\");\n const resolvedConfig: NormalizedCodemationConfig = {\n ...config,\n workflows,\n };\n logLevelPolicyFactory.create().applyCodemationLogConfig(resolvedConfig.log);\n return {\n config: resolvedConfig,\n bootstrapSource,\n workflowSources,\n };\n }\n\n private async resolveConfigPath(\n consumerRoot: string,\n configPathOverride: string | undefined,\n ): Promise<string | null> {\n if (configPathOverride) {\n const explicitPath = path.isAbsolute(configPathOverride)\n ? configPathOverride\n : path.resolve(consumerRoot, configPathOverride);\n if (!(await this.exists(explicitPath))) {\n throw new Error(`Config file not found: ${explicitPath}`);\n }\n return explicitPath;\n }\n for (const candidate of this.getConventionCandidates(consumerRoot)) {\n if (await this.exists(candidate)) {\n return candidate;\n }\n }\n return null;\n }\n\n private getConventionCandidates(consumerRoot: string): ReadonlyArray<string> {\n return [\n path.resolve(consumerRoot, \"codemation.config.ts\"),\n path.resolve(consumerRoot, \"codemation.config.js\"),\n path.resolve(consumerRoot, \"src\", \"codemation.config.ts\"),\n path.resolve(consumerRoot, \"src\", \"codemation.config.js\"),\n ];\n }\n\n private async resolveWorkflowSources(consumerRoot: string, config: CodemationConfig): Promise<ReadonlyArray<string>> {\n if ((config.workflowDiscovery?.directories?.length ?? 0) === 0) {\n return [];\n }\n const discoveredPaths = await this.workflowModulePathFinder.discoverModulePaths({\n consumerRoot,\n workflowDirectories: config.workflowDiscovery?.directories,\n exists: (absolutePath) => this.exists(absolutePath),\n });\n return [...discoveredPaths].sort((left: string, right: string) => left.localeCompare(right));\n }\n\n private async loadDiscoveredWorkflows(\n consumerRoot: string,\n config: CodemationConfig,\n workflowSources: ReadonlyArray<string>,\n importSession: ConsumerImportSession,\n ): Promise<ReadonlyArray<WorkflowDefinition>> {\n const workflowDiscoveryDirectories = config.workflowDiscovery?.directories ?? [];\n const workflowsById = new Map<string, WorkflowDefinition>();\n const loadedWorkflowModules = await Promise.all(\n workflowSources.map(async (workflowSource: string) => ({\n workflowSource,\n segments: this.pathSegmentsComputer.compute({\n consumerRoot,\n workflowDiscoveryDirectories,\n absoluteWorkflowModulePath: workflowSource,\n }),\n moduleExports: await this.importModule(workflowSource, importSession),\n })),\n );\n for (const loadedWorkflowModule of loadedWorkflowModules) {\n for (const workflow of this.workflowDefinitionExportsResolver.resolve(loadedWorkflowModule.moduleExports)) {\n const enriched =\n loadedWorkflowModule.segments && loadedWorkflowModule.segments.length > 0\n ? ({ ...workflow, discoveryPathSegments: loadedWorkflowModule.segments } satisfies WorkflowDefinition)\n : workflow;\n workflowsById.set(workflow.id, enriched);\n }\n }\n if (workflowsById.size === 0 && workflowSources.length > 0) {\n throw new Error(this.discoveredWorkflowsEmptyMessageFactory.create(workflowSources));\n }\n return [...workflowsById.values()];\n }\n\n private mergeWorkflows(\n configuredWorkflows: ReadonlyArray<WorkflowDefinition>,\n discoveredWorkflows: ReadonlyArray<WorkflowDefinition>,\n ): ReadonlyArray<WorkflowDefinition> {\n const workflowsById = new Map<string, WorkflowDefinition>();\n for (const workflow of discoveredWorkflows) {\n workflowsById.set(workflow.id, workflow);\n }\n for (const workflow of configuredWorkflows) {\n workflowsById.set(workflow.id, workflow);\n }\n return [...workflowsById.values()];\n }\n\n private async importModule(\n modulePath: string,\n importSession: ConsumerImportSession,\n ): Promise<Record<string, unknown>> {\n if (this.shouldUseNativeRuntimeImport()) {\n return await this.importModuleWithNativeRuntime(modulePath);\n }\n const tsconfigPath = await this.resolveTsconfigPath(modulePath);\n const cacheKey = tsconfigPath || \"default\";\n const shouldResetImporter = importSession.shouldResetImporter;\n const didResetImporterForThisImport = shouldResetImporter && !importSession.resetCacheKeys.has(cacheKey);\n if (didResetImporterForThisImport) {\n await this.resetImporter(tsconfigPath);\n importSession.resetCacheKeys.add(cacheKey);\n }\n const importSpecifier = await this.createImportSpecifier(modulePath);\n for (let attempt = 0; attempt < 3; attempt += 1) {\n try {\n const importedModule = await (\n await this.getOrCreateImporter(tsconfigPath)\n ).import(importSpecifier, import.meta.url);\n return importedModule as Record<string, unknown>;\n } catch (error) {\n if (!this.isStoppedTransformServiceError(error) || attempt === 2) {\n throw error;\n }\n await this.resetImporter(tsconfigPath);\n }\n }\n throw new Error(`Failed to import consumer module after retries: ${modulePath}`);\n }\n\n private async importModuleWithNativeRuntime(modulePath: string): Promise<Record<string, unknown>> {\n const importedModule = await import(await this.createImportSpecifier(modulePath));\n return importedModule as Record<string, unknown>;\n }\n\n private async resolveTsconfigPath(modulePath: string): Promise<string | false> {\n const overridePath = process.env.CODEMATION_TSCONFIG_PATH;\n if (overridePath && (await this.exists(overridePath))) {\n return overridePath;\n }\n const discoveredPath = await this.findNearestTsconfig(modulePath);\n return discoveredPath ?? false;\n }\n\n private async getOrCreateImporter(tsconfigPath: string | false): Promise<NamespacedUnregister> {\n const cacheKey = tsconfigPath || \"default\";\n const existingImporter = CodemationConsumerConfigLoader.importerRegistrationsByTsconfig.get(cacheKey);\n if (existingImporter) {\n return existingImporter;\n }\n const { register } = await import(/* webpackIgnore: true */ this.resolveTsxImporterModuleSpecifier());\n const namespaceVersion = this.nextNamespaceVersion(cacheKey);\n const nextImporter = register({\n // A fresh namespace prevents cache hits from prior scoped imports after a dev rebuild.\n namespace: this.toNamespace(cacheKey, namespaceVersion),\n tsconfig: tsconfigPath,\n });\n CodemationConsumerConfigLoader.importerRegistrationsByTsconfig.set(cacheKey, nextImporter);\n return nextImporter;\n }\n\n private async resetImporter(tsconfigPath: string | false): Promise<void> {\n const cacheKey = tsconfigPath || \"default\";\n const existingImporter = CodemationConsumerConfigLoader.importerRegistrationsByTsconfig.get(cacheKey);\n if (!existingImporter) {\n return;\n }\n CodemationConsumerConfigLoader.importerRegistrationsByTsconfig.delete(cacheKey);\n await existingImporter.unregister().catch(() => null);\n }\n\n private nextNamespaceVersion(cacheKey: string): number {\n const nextVersion = (CodemationConsumerConfigLoader.importerNamespaceVersionByTsconfig.get(cacheKey) ?? 0) + 1;\n CodemationConsumerConfigLoader.importerNamespaceVersionByTsconfig.set(cacheKey, nextVersion);\n return nextVersion;\n }\n\n private toNamespace(cacheKey: string, namespaceVersion: number): string {\n return `codemation_consumer_${cacheKey.replace(/[^a-zA-Z0-9_-]+/g, \"_\")}_${namespaceVersion}`;\n }\n\n private resolveTsxImporterModuleSpecifier(): string {\n return [\"tsx\", \"esm\", \"api\"].join(\"/\");\n }\n\n private async findNearestTsconfig(modulePath: string): Promise<string | null> {\n let currentDirectory = path.dirname(modulePath);\n while (true) {\n const candidate = path.resolve(currentDirectory, \"tsconfig.json\");\n if (await this.exists(candidate)) {\n return candidate;\n }\n const parentDirectory = path.dirname(currentDirectory);\n if (parentDirectory === currentDirectory) {\n return null;\n }\n currentDirectory = parentDirectory;\n }\n }\n\n private async createImportSpecifier(modulePath: string): Promise<string> {\n const moduleUrl = pathToFileURL(modulePath);\n const moduleStats = await stat(modulePath);\n moduleUrl.searchParams.set(\"t\", String(moduleStats.mtimeMs));\n return moduleUrl.href;\n }\n\n private shouldUseNativeRuntimeImport(): boolean {\n return process.env.CODEMATION_TS_RUNTIME === \"ts-node\";\n }\n\n private shouldResetImporterBeforeImport(): boolean {\n return (process.env.CODEMATION_DEV_SERVER_TOKEN?.trim().length ?? 0) > 0;\n }\n\n private createImportSession(): ConsumerImportSession {\n return {\n resetCacheKeys: new Set<string>(),\n shouldResetImporter: this.shouldResetImporterBeforeImport(),\n };\n }\n\n private isStoppedTransformServiceError(error: unknown): boolean {\n return error instanceof Error && error.message.includes(\"The service is no longer running\");\n }\n\n private async exists(filePath: string): Promise<boolean> {\n try {\n await access(filePath);\n return true;\n } catch {\n return false;\n }\n }\n}\n"],"mappings":";;;;;;AAiBA,IAAa,6BAAb,MAAwC;CACtC,UAAU,QAAsD;EAC9D,MAAM,YAAY,KAAK,oBAAoB,OAAO;EAClD,MAAM,oBAAoB,KAAK,uBAAuB,OAAO;EAC7D,MAAM,yCAAyC,CAC7C,GAAI,OAAO,mBAAmB,eAAe,EAAE,EAC/C,GAAG,UAAU,oBACd;AAED,SAAO;GACL,GAAG;GACH,MAAM,OAAO,KAAK,QAAQ,OAAO;GACjC,wBAAwB,UAAU;G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AGnB,AAAQ,+BAAwC;AAC9C,SAAO,QAAQ,IAAI,0BAA0B;;CAG/C,AAAQ,kCAA2C;AACjD,UAAQ,QAAQ,IAAI,6BAA6B,MAAM,CAAC,UAAU,KAAK;;CAGzE,AAAQ,sBAA6C;AACnD,SAAO;GACL,gCAAgB,IAAI,KAAa;GACjC,qBAAqB,KAAK,iCAAiC;GAC5D;;CAGH,AAAQ,+BAA+B,OAAyB;AAC9D,SAAO,iBAAiB,SAAS,MAAM,QAAQ,SAAS,mCAAmC;;CAG7F,MAAc,OAAO,UAAoC;AACvD,MAAI;AACF,SAAM,OAAO,SAAS;AACtB,UAAO;UACD;AACN,UAAO"}
@@ -1,8 +1,8 @@
1
1
  import { a as CodemationWhitelabelConfig, l as Logger, t as CodemationAuthConfig, u as LoggerFactory } from "./CodemationAuthConfig-7hEfICPf.js";
2
- import { F as NodeExecutionRequestHandler, G as WorkflowActivationPolicy, H as RunEventBus, I as NodeExecutionScheduler, J as PersistedRunState, L as WorkflowRepository, M as WorkflowDefinition, N as WorkflowId, O as RunId, Q as Clock, R as Container, V as RunEvent, X as RunPruneCandidate, Y as RunCurrentState, Z as RunSummary, n as Engine, q as WorkflowRunDetailDto, s as AnyCredentialType, z as TypeToken } from "./index-BQaZZmOm.js";
3
- import { C as CodemationContainerRegistration, S as CodemationPluginPackageMetadata, g as AppConfig, y as CodemationPlugin } from "./CodemationConfig-DuGk7uN5.js";
4
- import { t as CredentialStore } from "./CredentialServices-Bhejvys-.js";
5
- import { n as PrismaMigrationDeployer, r as PrismaDatabaseClient } from "./AppConfigFactory-BiFHnorf.js";
2
+ import { $ as RunSummary, B as Container, L as NodeExecutionRequestHandler, N as WorkflowDefinition, P as WorkflowId, Q as RunPruneCandidate, R as NodeExecutionScheduler, U as RunEvent, V as TypeToken, W as RunEventBus, X as PersistedRunState, Y as WorkflowRunDetailDto, Z as RunCurrentState, et as Clock, k as RunId, n as Engine, q as WorkflowActivationPolicy, s as AnyCredentialType, z as WorkflowRepository } from "./index-dK05sTQ4.js";
3
+ import { C as CodemationContainerRegistration, S as CodemationPluginPackageMetadata, g as AppConfig, y as CodemationPlugin } from "./CodemationConfig-DBbMU3HB.js";
4
+ import { t as CredentialStore } from "./CredentialServices-CYETzKyb.js";
5
+ import { n as PrismaMigrationDeployer, r as PrismaDatabaseClient } from "./AppConfigFactory-DHdAGOmC.js";
6
6
  import "reflect-metadata";
7
7
  import { Hono } from "hono";
8
8
 
@@ -354,4 +354,4 @@ declare class CodemationPluginListMerger {
354
354
  }
355
355
  //#endregion
356
356
  export { Command as _, WorkflowDebuggerOverlayRepository as a, WorkerRuntime as c, AppContainerLifecycle as d, AppContainerFactory as f, CommandBus as g, Query as h, HonoApiRouteRegistrar as i, FrontendRuntime as l, QueryBus as m, CodemationBootstrapRequest as n, WorkflowRunRepository as o, WorkflowWebsocketServer as p, ApplicationTokens as r, SessionVerifier as s, CodemationPluginListMerger as t, DatabaseMigrations as u };
357
- //# sourceMappingURL=CodemationPluginListMerger-DFzGgfyI.d.ts.map
357
+ //# sourceMappingURL=CodemationPluginListMerger-Cx9DnyR-.d.ts.map
@@ -1,5 +1,5 @@
1
- import { C as CredentialTypeId, L as WorkflowRepository, M as WorkflowDefinition, S as CredentialTypeDefinition, _ as CredentialRequirement, b as CredentialSetupStatus, c as CredentialBinding, d as CredentialHealth, f as CredentialInstanceId, h as CredentialMaterialSourceKind, l as CredentialBindingKey, m as CredentialJsonRecord, p as CredentialInstanceRecord, s as AnyCredentialType, u as CredentialFieldSchema, w as CredentialTypeRegistry, x as CredentialType, y as CredentialSessionService } from "./index-BQaZZmOm.js";
2
- import { g as AppConfig } from "./CodemationConfig-DuGk7uN5.js";
1
+ import { C as CredentialTypeId, N as WorkflowDefinition, S as CredentialTypeDefinition, _ as CredentialRequirement, b as CredentialSetupStatus, c as CredentialBinding, d as CredentialHealth, f as CredentialInstanceId, g as CredentialOAuth2AuthDefinition, h as CredentialMaterialSourceKind, l as CredentialBindingKey, m as CredentialJsonRecord, p as CredentialInstanceRecord, s as AnyCredentialType, u as CredentialFieldSchema, w as CredentialTypeRegistry, x as CredentialType, y as CredentialSessionService, z as WorkflowRepository } from "./index-dK05sTQ4.js";
2
+ import { g as AppConfig } from "./CodemationConfig-DBbMU3HB.js";
3
3
 
4
4
  //#region src/domain/credentials/CredentialTypeRegistryImpl.d.ts
5
5
  declare class CredentialTypeRegistryImpl implements CredentialTypeRegistry {
@@ -146,6 +146,14 @@ declare class CredentialMaterialResolver {
146
146
  private resolveEnvMaterial;
147
147
  }
148
148
  //#endregion
149
+ //#region src/domain/credentials/CredentialOAuth2ScopeResolver.d.ts
150
+ declare class CredentialOAuth2ScopeResolver {
151
+ resolveRequestedScopes(auth: CredentialOAuth2AuthDefinition, publicConfig: JsonRecord): ReadonlyArray<string>;
152
+ private resolveString;
153
+ private resolveScopeList;
154
+ private dedupe;
155
+ }
156
+ //#endregion
149
157
  //#region src/domain/credentials/CredentialInstanceService.d.ts
150
158
  declare class CredentialInstanceService {
151
159
  private readonly credentialStore;
@@ -153,8 +161,9 @@ declare class CredentialInstanceService {
153
161
  private readonly credentialSecretCipher;
154
162
  private readonly credentialFieldEnvOverlayService;
155
163
  private readonly credentialMaterialResolver;
164
+ private readonly credentialOAuth2ScopeResolver;
156
165
  private readonly credentialSessionService;
157
- constructor(credentialStore: CredentialStore, credentialTypeRegistry: CredentialTypeRegistryImpl, credentialSecretCipher: CredentialSecretCipher, credentialFieldEnvOverlayService: CredentialFieldEnvOverlayService, credentialMaterialResolver: CredentialMaterialResolver, credentialSessionService: MutableCredentialSessionService);
166
+ constructor(credentialStore: CredentialStore, credentialTypeRegistry: CredentialTypeRegistryImpl, credentialSecretCipher: CredentialSecretCipher, credentialFieldEnvOverlayService: CredentialFieldEnvOverlayService, credentialMaterialResolver: CredentialMaterialResolver, credentialOAuth2ScopeResolver: CredentialOAuth2ScopeResolver, credentialSessionService: MutableCredentialSessionService);
158
167
  listInstances(): Promise<ReadonlyArray<CredentialInstanceDto>>;
159
168
  getInstance(instanceId: CredentialInstanceId): Promise<CredentialInstanceDto | undefined>;
160
169
  getInstanceWithSecrets(instanceId: CredentialInstanceId): Promise<CredentialInstanceWithSecretsDto | undefined>;
@@ -288,5 +297,5 @@ type MutableCredentialSessionService = CredentialSessionService & Readonly<{
288
297
  evictBinding(bindingKey: CredentialBindingKey): void;
289
298
  }>;
290
299
  //#endregion
291
- export { CredentialInstanceService as a, CredentialFieldEnvOverlayService as c, CredentialBindingService as i, CredentialTypeRegistryImpl as l, CredentialType$1 as n, CredentialMaterialResolver as o, CredentialRuntimeMaterialService as r, CredentialSecretCipher as s, CredentialStore as t };
292
- //# sourceMappingURL=CredentialServices-Bhejvys-.d.ts.map
300
+ export { CredentialInstanceService as a, CredentialSecretCipher as c, CredentialBindingService as i, CredentialFieldEnvOverlayService as l, CredentialType$1 as n, CredentialOAuth2ScopeResolver as o, CredentialRuntimeMaterialService as r, CredentialMaterialResolver as s, CredentialStore as t, CredentialTypeRegistryImpl as u };
301
+ //# sourceMappingURL=CredentialServices-CYETzKyb.d.ts.map
@@ -420,16 +420,48 @@ CredentialMaterialResolver = __decorate([
420
420
  ])
421
421
  ], CredentialMaterialResolver);
422
422
 
423
+ //#endregion
424
+ //#region src/domain/credentials/CredentialOAuth2ScopeResolver.ts
425
+ let CredentialOAuth2ScopeResolver = class CredentialOAuth2ScopeResolver$1 {
426
+ resolveRequestedScopes(auth, publicConfig) {
427
+ const scopesFromPublicConfig = auth.scopesFromPublicConfig;
428
+ if (!scopesFromPublicConfig) return [...auth.scopes];
429
+ const preset = this.resolveString(publicConfig[scopesFromPublicConfig.presetFieldKey]);
430
+ if (!preset) return [...auth.scopes];
431
+ const presetScopes = scopesFromPublicConfig.presetScopes[preset];
432
+ if (presetScopes) return [...presetScopes];
433
+ if (preset !== (scopesFromPublicConfig.customPresetKey ?? "custom")) return [...auth.scopes];
434
+ const customScopes = this.resolveScopeList(publicConfig[scopesFromPublicConfig.customScopesFieldKey ?? "customScopes"]);
435
+ if (customScopes.length > 0) return customScopes;
436
+ return [...auth.scopes];
437
+ }
438
+ resolveString(value) {
439
+ if (typeof value !== "string") return;
440
+ const normalized = value.trim();
441
+ return normalized.length > 0 ? normalized : void 0;
442
+ }
443
+ resolveScopeList(value) {
444
+ if (Array.isArray(value)) return this.dedupe(value.map((entry) => typeof entry === "string" ? entry.trim() : "").filter((entry) => entry.length > 0));
445
+ if (typeof value !== "string") return [];
446
+ return this.dedupe(value.split(/[\s,]+/).map((entry) => entry.trim()).filter((entry) => entry.length > 0));
447
+ }
448
+ dedupe(entries) {
449
+ return [...new Set(entries)];
450
+ }
451
+ };
452
+ CredentialOAuth2ScopeResolver = __decorate([injectable()], CredentialOAuth2ScopeResolver);
453
+
423
454
  //#endregion
424
455
  //#region src/domain/credentials/CredentialInstanceService.ts
425
- var _ref$4, _ref2$4, _ref3$3, _ref4$2;
456
+ var _ref$4, _ref2$4, _ref3$3, _ref4$2, _ref5;
426
457
  let CredentialInstanceService = class CredentialInstanceService$1 {
427
- constructor(credentialStore, credentialTypeRegistry, credentialSecretCipher, credentialFieldEnvOverlayService, credentialMaterialResolver, credentialSessionService) {
458
+ constructor(credentialStore, credentialTypeRegistry, credentialSecretCipher, credentialFieldEnvOverlayService, credentialMaterialResolver, credentialOAuth2ScopeResolver, credentialSessionService) {
428
459
  this.credentialStore = credentialStore;
429
460
  this.credentialTypeRegistry = credentialTypeRegistry;
430
461
  this.credentialSecretCipher = credentialSecretCipher;
431
462
  this.credentialFieldEnvOverlayService = credentialFieldEnvOverlayService;
432
463
  this.credentialMaterialResolver = credentialMaterialResolver;
464
+ this.credentialOAuth2ScopeResolver = credentialOAuth2ScopeResolver;
433
465
  this.credentialSessionService = credentialSessionService;
434
466
  }
435
467
  async listInstances() {
@@ -640,7 +672,7 @@ let CredentialInstanceService = class CredentialInstanceService$1 {
640
672
  if (!material) return {
641
673
  status: "disconnected",
642
674
  providerId,
643
- scopes: [...credentialType.definition.auth.scopes]
675
+ scopes: [...this.credentialOAuth2ScopeResolver.resolveRequestedScopes(credentialType.definition.auth, instance.publicConfig)]
644
676
  };
645
677
  return {
646
678
  status: "connected",
@@ -659,13 +691,15 @@ CredentialInstanceService = __decorate([
659
691
  __decorateParam(2, inject(CredentialSecretCipher)),
660
692
  __decorateParam(3, inject(CredentialFieldEnvOverlayService)),
661
693
  __decorateParam(4, inject(CredentialMaterialResolver)),
662
- __decorateParam(5, inject(CoreTokens.CredentialSessionService)),
694
+ __decorateParam(5, inject(CredentialOAuth2ScopeResolver)),
695
+ __decorateParam(6, inject(CoreTokens.CredentialSessionService)),
663
696
  __decorateMetadata("design:paramtypes", [
664
697
  Object,
665
698
  typeof (_ref$4 = typeof CredentialTypeRegistryImpl !== "undefined" && CredentialTypeRegistryImpl) === "function" ? _ref$4 : Object,
666
699
  typeof (_ref2$4 = typeof CredentialSecretCipher !== "undefined" && CredentialSecretCipher) === "function" ? _ref2$4 : Object,
667
700
  typeof (_ref3$3 = typeof CredentialFieldEnvOverlayService !== "undefined" && CredentialFieldEnvOverlayService) === "function" ? _ref3$3 : Object,
668
701
  typeof (_ref4$2 = typeof CredentialMaterialResolver !== "undefined" && CredentialMaterialResolver) === "function" ? _ref4$2 : Object,
702
+ typeof (_ref5 = typeof CredentialOAuth2ScopeResolver !== "undefined" && CredentialOAuth2ScopeResolver) === "function" ? _ref5 : Object,
669
703
  Object
670
704
  ])
671
705
  ], CredentialInstanceService);
@@ -972,5 +1006,5 @@ CredentialTestService = __decorate([
972
1006
  ], CredentialTestService);
973
1007
 
974
1008
  //#endregion
975
- export { CredentialInstanceService as a, CredentialFieldEnvOverlayService as c, ApplicationRequestError as d, CredentialTypeRegistryImpl as f, CredentialBindingService as i, WorkflowCredentialNodeResolver as l, OpenAiApiKeyCredentialHealthTester as m, CredentialSessionServiceImpl as n, CredentialMaterialResolver as o, OpenAiApiKeyCredentialTypeFactory as p, CredentialRuntimeMaterialService as r, CredentialSecretCipher as s, CredentialTestService as t, ApplicationTokens as u };
976
- //# sourceMappingURL=CredentialServices-xVxVA9Tq.js.map
1009
+ export { CredentialInstanceService as a, CredentialSecretCipher as c, ApplicationTokens as d, ApplicationRequestError as f, OpenAiApiKeyCredentialHealthTester as h, CredentialBindingService as i, CredentialFieldEnvOverlayService as l, OpenAiApiKeyCredentialTypeFactory as m, CredentialSessionServiceImpl as n, CredentialOAuth2ScopeResolver as o, CredentialTypeRegistryImpl as p, CredentialRuntimeMaterialService as r, CredentialMaterialResolver as s, CredentialTestService as t, WorkflowCredentialNodeResolver as u };
1010
+ //# sourceMappingURL=CredentialServices-D8BBZH1i.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CredentialServices-D8BBZH1i.js","names":["fetchImpl: typeof globalThis.fetch","healthTester: OpenAiApiKeyCredentialHealthTester","CredentialTypeRegistryImpl","WorkflowCredentialNodeResolver","entry","labels: string[]","CredentialFieldEnvOverlayService","appConfig: AppConfig","pub: Record<string, unknown>","mat: Record<string, unknown>","CredentialSecretCipher","appConfig: AppConfig","CredentialMaterialResolver","credentialStore: CredentialStore","credentialSecretCipher: CredentialSecretCipher","appConfig: AppConfig","resolved: Record<string, unknown>","missingEnvironmentVariables: string[]","CredentialOAuth2ScopeResolver","CredentialInstanceService","credentialStore: CredentialStore","credentialTypeRegistry: CredentialTypeRegistryImpl","credentialSecretCipher: CredentialSecretCipher","credentialFieldEnvOverlayService: CredentialFieldEnvOverlayService","credentialMaterialResolver: CredentialMaterialResolver","credentialOAuth2ScopeResolver: CredentialOAuth2ScopeResolver","credentialSessionService: MutableCredentialSessionService","instance: CredentialInstanceRecord","updatedInstance: CredentialInstanceRecord","out: Record<string, unknown>","CredentialBindingService","credentialStore: CredentialStore","credentialInstanceService: CredentialInstanceService","workflowRepository: WorkflowRepository","credentialSessionService: MutableCredentialSessionService","workflowCredentialNodeResolver: WorkflowCredentialNodeResolver","binding: CredentialBinding","slots: WorkflowCredentialHealthSlotDto[]","CredentialRuntimeMaterialService","credentialStore: CredentialStore","credentialMaterialResolver: CredentialMaterialResolver","credentialSecretCipher: CredentialSecretCipher","credentialTypeRegistry: CredentialTypeRegistryImpl","CredentialSessionServiceImpl","credentialStore: CredentialStore","credentialRuntimeMaterialService: CredentialRuntimeMaterialService","credentialFieldEnvOverlayService: CredentialFieldEnvOverlayService","credentialTypeRegistry: CredentialTypeRegistryImpl","workflowRepository: WorkflowRepository","workflowCredentialNodeResolver: WorkflowCredentialNodeResolver","bindingKey: CredentialBindingKey","CredentialTestService","credentialInstanceService: CredentialInstanceService","credentialRuntimeMaterialService: CredentialRuntimeMaterialService","credentialFieldEnvOverlayService: CredentialFieldEnvOverlayService","credentialTypeRegistry: CredentialTypeRegistryImpl","credentialStore: CredentialStore","credentialSessionService: MutableCredentialSessionService"],"sources":["../src/infrastructure/credentials/OpenAiApiKeyCredentialHealthTester.ts","../src/infrastructure/credentials/OpenAiApiKeyCredentialTypeFactory.ts","../src/domain/credentials/CredentialTypeRegistryImpl.ts","../src/application/ApplicationRequestError.ts","../src/applicationTokens.ts","../src/domain/credentials/WorkflowCredentialNodeResolver.ts","../src/domain/credentials/CredentialFieldEnvOverlayService.ts","../src/domain/credentials/CredentialSecretCipher.ts","../src/domain/credentials/CredentialMaterialResolver.ts","../src/domain/credentials/CredentialOAuth2ScopeResolver.ts","../src/domain/credentials/CredentialInstanceService.ts","../src/domain/credentials/CredentialBindingService.ts","../src/domain/credentials/CredentialRuntimeMaterialService.ts","../src/domain/credentials/CredentialSessionServiceImpl.ts","../src/domain/credentials/CredentialTestService.ts"],"sourcesContent":["import type { CredentialHealth, CredentialSessionFactoryArgs } from \"@codemation/core\";\n\nimport type { OpenAiApiKeyMaterial, OpenAiApiKeyPublicConfig } from \"./OpenAiApiKeyCredentialShapes.types\";\n\n/**\n * Verifies an OpenAI-compatible API key by calling the provider's models list endpoint\n * (GET `/v1/models` relative to the configured base URL).\n */\nexport class OpenAiApiKeyCredentialHealthTester {\n constructor(private readonly fetchImpl: typeof globalThis.fetch) {}\n\n async test(\n args: CredentialSessionFactoryArgs<OpenAiApiKeyPublicConfig, OpenAiApiKeyMaterial>,\n ): Promise<CredentialHealth> {\n const testedAt = new Date().toISOString();\n const apiKey = String(args.material.apiKey ?? \"\").trim();\n if (apiKey.length === 0) {\n return {\n status: \"failing\",\n message: \"OpenAI API key is empty.\",\n testedAt,\n };\n }\n\n const modelsUrl = this.resolveModelsListUrl(args.publicConfig.baseUrl);\n\n try {\n const response = await this.fetchImpl(modelsUrl, {\n method: \"GET\",\n headers: {\n Authorization: `Bearer ${apiKey}`,\n },\n signal: AbortSignal.timeout(25_000),\n });\n\n if (response.ok) {\n return {\n status: \"healthy\",\n message: \"API key verified against the models endpoint.\",\n testedAt,\n };\n }\n\n const message = await this.parseErrorMessage(response);\n return {\n status: \"failing\",\n message,\n testedAt,\n };\n } catch (error) {\n return {\n status: \"failing\",\n message: error instanceof Error ? error.message : String(error),\n testedAt,\n };\n }\n }\n\n private resolveModelsListUrl(baseUrlRaw: unknown): string {\n const defaultBase = \"https://api.openai.com/v1\";\n const raw = typeof baseUrlRaw === \"string\" ? baseUrlRaw.trim() : \"\";\n const base = raw === \"\" ? defaultBase : raw.replace(/\\/+$/, \"\");\n if (base.endsWith(\"/models\")) {\n return base;\n }\n if (base.endsWith(\"/v1\")) {\n return `${base}/models`;\n }\n return `${base}/v1/models`;\n }\n\n private async parseErrorMessage(response: Response): Promise<string> {\n const prefix = `HTTP ${response.status}`;\n try {\n const text = await response.text();\n if (text.trim() === \"\") {\n return prefix;\n }\n const parsed = JSON.parse(text) as { error?: { message?: string } };\n const fromApi = parsed.error?.message;\n if (typeof fromApi === \"string\" && fromApi.trim() !== \"\") {\n return `${prefix}: ${fromApi.trim()}`;\n }\n return `${prefix}: ${text.length > 280 ? `${text.slice(0, 280)}…` : text}`;\n } catch {\n return prefix;\n }\n }\n}\n","import type { CredentialType } from \"../../domain/credentials/CredentialServices\";\n\nimport type { OpenAiApiKeyCredentialHealthTester } from \"./OpenAiApiKeyCredentialHealthTester\";\nimport type {\n OpenAiApiKeyMaterial,\n OpenAiApiKeyPublicConfig,\n OpenAiApiKeySession,\n} from \"./OpenAiApiKeyCredentialShapes.types\";\n\n/**\n * Builds the OpenAI-compatible API key credential (`openai.apiKey`) registration.\n * Used by {@link FrameworkBuiltinCredentialTypesRegistrar} and may be listed in {@link CodemationConfig.credentialTypes}\n * so consumer apps always register the type even when bootstrap order differs.\n */\nexport class OpenAiApiKeyCredentialTypeFactory {\n constructor(private readonly healthTester: OpenAiApiKeyCredentialHealthTester) {}\n\n createCredentialType(): CredentialType<OpenAiApiKeyPublicConfig, OpenAiApiKeyMaterial, OpenAiApiKeySession> {\n return {\n definition: {\n typeId: \"openai.apiKey\",\n displayName: \"OpenAI API key\",\n description: \"API key and optional base URL for OpenAI or OpenAI-compatible chat endpoints.\",\n publicFields: [\n {\n key: \"baseUrl\",\n label: \"Base URL\",\n type: \"string\",\n placeholder: \"https://api.openai.com/v1\",\n helpText: \"Leave empty to use the default OpenAI API endpoint.\",\n },\n ],\n secretFields: [{ key: \"apiKey\", label: \"API key\", type: \"password\", required: true }],\n supportedSourceKinds: [\"db\", \"env\", \"code\"],\n },\n createSession: async (args) => {\n const baseUrlRaw = args.publicConfig.baseUrl;\n const baseUrl = typeof baseUrlRaw === \"string\" && baseUrlRaw.trim() !== \"\" ? baseUrlRaw.trim() : undefined;\n return {\n apiKey: String(args.material.apiKey ?? \"\"),\n baseUrl,\n };\n },\n test: async (args) => this.healthTester.test(args),\n };\n }\n}\n","import type { CredentialTypeDefinition, CredentialTypeId, CredentialTypeRegistry } from \"@codemation/core\";\n\nimport { injectable } from \"@codemation/core\";\n\nimport type { AnyCredentialType, CredentialType } from \"./CredentialServices\";\n\n@injectable()\nexport class CredentialTypeRegistryImpl implements CredentialTypeRegistry {\n private readonly credentialTypesById = new Map<CredentialTypeId, AnyCredentialType>();\n\n register(type: CredentialType<any, any, unknown>): void {\n if (this.credentialTypesById.has(type.definition.typeId)) {\n throw new Error(`Credential type already registered: ${type.definition.typeId}`);\n }\n this.credentialTypesById.set(type.definition.typeId, type);\n }\n\n listTypes(): ReadonlyArray<CredentialTypeDefinition> {\n return [...this.credentialTypesById.values()].map((entry) => entry.definition);\n }\n\n getType(typeId: CredentialTypeId): CredentialTypeDefinition | undefined {\n return this.credentialTypesById.get(typeId)?.definition;\n }\n\n getCredentialType(typeId: CredentialTypeId): AnyCredentialType | undefined {\n return this.credentialTypesById.get(typeId);\n }\n}\n","export class ApplicationRequestError extends Error {\n readonly status: number;\n\n readonly payload: Readonly<{ error: string; errors?: ReadonlyArray<string> }>;\n\n constructor(status: number, message: string, errors?: ReadonlyArray<string>) {\n super(message);\n this.name = \"ApplicationRequestError\";\n this.status = status;\n this.payload = errors && errors.length > 0 ? { error: message, errors } : { error: message };\n }\n}\n","import type { Clock, TypeToken } from \"@codemation/core\";\nimport type { SessionVerifier } from \"./application/auth/SessionVerifier\";\nimport type { Command } from \"./application/bus/Command\";\nimport type { CommandBus } from \"./application/bus/CommandBus\";\nimport type { CommandHandler } from \"./application/bus/CommandHandler\";\nimport type { DomainEvent } from \"./application/bus/DomainEvent\";\nimport type { DomainEventBus } from \"./application/bus/DomainEventBus\";\nimport type { DomainEventHandler } from \"./application/bus/DomainEventHandler\";\nimport type { Query } from \"./application/bus/Query\";\nimport type { QueryBus } from \"./application/bus/QueryBus\";\nimport type { QueryHandler } from \"./application/bus/QueryHandler\";\nimport type { Logger, LoggerFactory } from \"./application/logging/Logger\";\nimport type { WorkflowWebsocketPublisher } from \"./application/websocket/WorkflowWebsocketPublisher\";\nimport type { CredentialStore } from \"./domain/credentials/CredentialServices\";\nimport type { WorkflowRunRepository } from \"./domain/runs/WorkflowRunRepository\";\nimport type { WorkflowDebuggerOverlayRepository } from \"./domain/workflows/WorkflowDebuggerOverlayRepository\";\nimport type { WorkflowDefinitionRepository } from \"./domain/workflows/WorkflowDefinitionRepository\";\nimport type { WorkflowActivationRepository } from \"./domain/workflows/WorkflowActivationRepository\";\nimport type { PrismaDatabaseClient } from \"./infrastructure/persistence/PrismaDatabaseClient\";\nimport type { WorkerRuntimeScheduler } from \"./infrastructure/scheduler/WorkerRuntimeScheduler\";\nimport type { AppConfig } from \"./presentation/config/AppConfig\";\nimport type { CodemationAuthConfig } from \"./presentation/config/CodemationAuthConfig\";\nimport type { CodemationWhitelabelConfig } from \"./presentation/config/CodemationWhitelabelConfig\";\nimport type { HonoApiRouteRegistrar } from \"./presentation/http/hono/HonoApiRouteRegistrar\";\n\nexport const ApplicationTokens = {\n CodemationAuthConfig: Symbol.for(\"codemation.application.CodemationAuthConfig\") as TypeToken<\n CodemationAuthConfig | undefined\n >,\n CodemationWhitelabelConfig: Symbol.for(\n \"codemation.application.CodemationWhitelabelConfig\",\n ) as TypeToken<CodemationWhitelabelConfig>,\n AppConfig: Symbol.for(\"codemation.application.AppConfig\") as TypeToken<AppConfig>,\n WebSocketPort: Symbol.for(\"codemation.application.WebSocketPort\") as TypeToken<number>,\n WebSocketBindHost: Symbol.for(\"codemation.application.WebSocketBindHost\") as TypeToken<string>,\n QueryBus: Symbol.for(\"codemation.application.QueryBus\") as TypeToken<QueryBus>,\n CommandBus: Symbol.for(\"codemation.application.CommandBus\") as TypeToken<CommandBus>,\n DomainEventBus: Symbol.for(\"codemation.application.DomainEventBus\") as TypeToken<DomainEventBus>,\n QueryHandler: Symbol.for(\"codemation.application.QueryHandler\") as TypeToken<QueryHandler<Query<unknown>, unknown>>,\n CommandHandler: Symbol.for(\"codemation.application.CommandHandler\") as TypeToken<\n CommandHandler<Command<unknown>, unknown>\n >,\n DomainEventHandler: Symbol.for(\"codemation.application.DomainEventHandler\") as TypeToken<\n DomainEventHandler<DomainEvent>\n >,\n HonoApiRouteRegistrar: Symbol.for(\"codemation.application.HonoApiRouteRegistrar\") as TypeToken<HonoApiRouteRegistrar>,\n WorkflowWebsocketPublisher: Symbol.for(\n \"codemation.application.WorkflowWebsocketPublisher\",\n ) as TypeToken<WorkflowWebsocketPublisher>,\n WorkerRuntimeScheduler: Symbol.for(\n \"codemation.application.WorkerRuntimeScheduler\",\n ) as TypeToken<WorkerRuntimeScheduler>,\n WorkflowDefinitionRepository: Symbol.for(\n \"codemation.application.WorkflowDefinitionRepository\",\n ) as TypeToken<WorkflowDefinitionRepository>,\n WorkflowActivationRepository: Symbol.for(\n \"codemation.application.WorkflowActivationRepository\",\n ) as TypeToken<WorkflowActivationRepository>,\n WorkflowDebuggerOverlayRepository: Symbol.for(\n \"codemation.application.WorkflowDebuggerOverlayRepository\",\n ) as TypeToken<WorkflowDebuggerOverlayRepository>,\n WorkflowRunRepository: Symbol.for(\"codemation.application.WorkflowRunRepository\") as TypeToken<WorkflowRunRepository>,\n LoggerFactory: Symbol.for(\"codemation.application.LoggerFactory\") as TypeToken<LoggerFactory>,\n /**\n * Opt-in timing/diagnostics logger (`CODEMATION_PERFORMANCE_LOGGING` + normal minimum log level).\n */\n PerformanceDiagnosticsLogger: Symbol.for(\"codemation.application.PerformanceDiagnosticsLogger\") as TypeToken<Logger>,\n CredentialStore: Symbol.for(\"codemation.application.CredentialStore\") as TypeToken<CredentialStore>,\n PrismaClient: Symbol.for(\"codemation.application.PrismaClient\") as TypeToken<PrismaDatabaseClient>,\n SessionVerifier: Symbol.for(\"codemation.application.SessionVerifier\") as TypeToken<SessionVerifier>,\n Clock: Symbol.for(\"codemation.application.Clock\") as TypeToken<Clock>,\n} as const;\n","import type { CredentialRequirement, WorkflowDefinition } from \"@codemation/core\";\nimport {\n AgentConfigInspector,\n AgentConnectionNodeCollector,\n type AgentConnectionNodeDescriptor,\n ConnectionNodeIdFactory,\n} from \"@codemation/core\";\n\nimport { injectable } from \"@codemation/core\";\n\nexport type WorkflowCredentialSlotRef = Readonly<{\n workflowId: string;\n nodeId: string;\n nodeName: string;\n requirement: CredentialRequirement;\n}>;\n\n/**\n * Resolves credential requirements for workflow node ids, including connection-owned LLM/tool children.\n */\n@injectable()\nexport class WorkflowCredentialNodeResolver {\n /**\n * Human-readable label for credential errors (workflow node name or agent › attachment).\n */\n describeCredentialNodeDisplay(workflow: WorkflowDefinition, nodeId: string): string {\n const direct = workflow.nodes.find((n) => n.id === nodeId);\n if (direct) {\n return direct.name ?? direct.config.name ?? direct.id;\n }\n const recursive = this.findRecursiveConnectionNode(workflow, nodeId);\n if (!recursive) {\n return nodeId;\n }\n return this.buildRecursiveDisplayLabel(recursive.rootAgentLabel, recursive.entry, recursive.entriesById);\n }\n\n isCredentialNodeIdInWorkflow(workflow: WorkflowDefinition, nodeId: string): boolean {\n if (workflow.nodes.some((n) => n.id === nodeId)) {\n return true;\n }\n return this.findRecursiveConnectionNode(workflow, nodeId) !== undefined;\n }\n\n findRequirement(\n workflow: WorkflowDefinition,\n nodeId: string,\n slotKey: string,\n ): Readonly<{ nodeName: string; requirement: CredentialRequirement }> | undefined {\n const direct = this.findDirectRequirement(workflow, nodeId, slotKey);\n if (direct) {\n return direct;\n }\n const recursive = this.findRecursiveConnectionNode(workflow, nodeId);\n if (!recursive) {\n return undefined;\n }\n const requirement = recursive.entry.credentialSource\n .getCredentialRequirements?.()\n ?.find((entry) => entry.slotKey === slotKey);\n return requirement ? { nodeName: recursive.entry.name, requirement } : undefined;\n }\n\n listSlots(workflow: WorkflowDefinition): ReadonlyArray<WorkflowCredentialSlotRef> {\n const slotsByKey = new Map<string, WorkflowCredentialSlotRef>();\n\n for (const node of workflow.nodes) {\n if (AgentConfigInspector.isAgentNodeConfig(node.config)) {\n this.addRecursiveAgentSlots(workflow.id, node.id, node.config, slotsByKey);\n continue;\n }\n this.addSlotsForRequirements(\n workflow.id,\n node.id,\n node.name ?? node.config.name ?? node.id,\n node.config.getCredentialRequirements?.() ?? [],\n slotsByKey,\n );\n }\n return [...slotsByKey.values()];\n }\n\n private findDirectRequirement(\n workflow: WorkflowDefinition,\n nodeId: string,\n slotKey: string,\n ): Readonly<{ nodeName: string; requirement: CredentialRequirement }> | undefined {\n const node = workflow.nodes.find((entry) => entry.id === nodeId);\n if (!node || AgentConfigInspector.isAgentNodeConfig(node.config)) {\n return undefined;\n }\n const requirement = node.config.getCredentialRequirements?.()?.find((entry) => entry.slotKey === slotKey);\n if (!requirement) {\n return undefined;\n }\n return { nodeName: node.name ?? node.config.name ?? node.id, requirement };\n }\n\n private addRecursiveAgentSlots(\n workflowId: string,\n rootAgentNodeId: string,\n agentConfig: Parameters<typeof AgentConnectionNodeCollector.collect>[1],\n slotsByKey: Map<string, WorkflowCredentialSlotRef>,\n ): void {\n for (const entry of AgentConnectionNodeCollector.collect(rootAgentNodeId, agentConfig)) {\n this.addSlotsForRequirements(\n workflowId,\n entry.nodeId,\n entry.name,\n entry.credentialSource.getCredentialRequirements?.() ?? [],\n slotsByKey,\n );\n }\n }\n\n private addSlotsForRequirements(\n workflowId: string,\n nodeId: string,\n nodeName: string,\n requirements: ReadonlyArray<CredentialRequirement>,\n slotsByKey: Map<string, WorkflowCredentialSlotRef>,\n ): void {\n for (const requirement of requirements) {\n const key = `${nodeId}\\0${requirement.slotKey}`;\n if (slotsByKey.has(key)) {\n continue;\n }\n slotsByKey.set(key, {\n workflowId,\n nodeId,\n nodeName,\n requirement,\n });\n }\n }\n\n private findRecursiveConnectionNode(\n workflow: WorkflowDefinition,\n nodeId: string,\n ):\n | Readonly<{\n rootAgentNodeId: string;\n rootAgentLabel: string;\n entry: AgentConnectionNodeDescriptor;\n entriesById: ReadonlyMap<string, AgentConnectionNodeDescriptor>;\n }>\n | undefined {\n if (\n !ConnectionNodeIdFactory.isLanguageModelConnectionNodeId(nodeId) &&\n !ConnectionNodeIdFactory.isToolConnectionNodeId(nodeId)\n ) {\n return undefined;\n }\n for (const node of workflow.nodes) {\n if (!AgentConfigInspector.isAgentNodeConfig(node.config)) {\n continue;\n }\n const entries = AgentConnectionNodeCollector.collect(node.id, node.config);\n const entriesById = new Map(entries.map((entry) => [entry.nodeId, entry]));\n const entry = entriesById.get(nodeId);\n if (!entry) {\n continue;\n }\n return {\n rootAgentNodeId: node.id,\n rootAgentLabel: node.name ?? node.config.name ?? node.id,\n entry,\n entriesById,\n };\n }\n return undefined;\n }\n\n private buildRecursiveDisplayLabel(\n rootAgentLabel: string,\n entry: AgentConnectionNodeDescriptor,\n entriesById: ReadonlyMap<string, AgentConnectionNodeDescriptor>,\n ): string {\n const labels = [rootAgentLabel, ...this.collectAncestorToolLabels(entry.parentNodeId, entriesById)];\n labels.push(entry.role === \"languageModel\" ? \"Language model\" : entry.name);\n return labels.join(\" › \");\n }\n\n private collectAncestorToolLabels(\n parentNodeId: string,\n entriesById: ReadonlyMap<string, AgentConnectionNodeDescriptor>,\n ): ReadonlyArray<string> {\n const labels: string[] = [];\n let currentNodeId = parentNodeId;\n while (true) {\n const parentEntry = entriesById.get(currentNodeId);\n if (!parentEntry) {\n return labels.reverse();\n }\n if (parentEntry.role === \"tool\" || parentEntry.role === \"nestedAgent\") {\n labels.push(parentEntry.name);\n }\n currentNodeId = parentEntry.parentNodeId;\n }\n }\n}\n","import type { CredentialFieldSchema, CredentialTypeDefinition } from \"@codemation/core\";\nimport { inject, injectable } from \"@codemation/core\";\n\nimport { ApplicationTokens } from \"../../applicationTokens\";\nimport type { AppConfig } from \"../../presentation/config/AppConfig\";\n\nimport type { JsonRecord } from \"./CredentialServices\";\n\n@injectable()\nexport class CredentialFieldEnvOverlayService {\n constructor(\n @inject(ApplicationTokens.AppConfig)\n private readonly appConfig: AppConfig,\n ) {}\n\n /** True when the field declares an env var and process.env has a non-empty string for it. */\n isFieldResolvedFromEnv(field: CredentialFieldSchema): boolean {\n const name = field.envVarName?.trim();\n if (!name) {\n return false;\n }\n const v = this.appConfig.env[name];\n return typeof v === \"string\" && v.length > 0;\n }\n\n apply(\n args: Readonly<{\n definition: CredentialTypeDefinition;\n publicConfig: JsonRecord;\n material: JsonRecord;\n }>,\n ): Readonly<{ resolvedPublicConfig: JsonRecord; resolvedMaterial: JsonRecord }> {\n const pub: Record<string, unknown> = { ...args.publicConfig };\n const mat: Record<string, unknown> = { ...args.material };\n for (const field of args.definition.publicFields ?? []) {\n const name = field.envVarName?.trim();\n if (!name) {\n continue;\n }\n const v = this.appConfig.env[name];\n if (typeof v === \"string\" && v.length > 0) {\n pub[field.key] = v;\n }\n }\n for (const field of args.definition.secretFields ?? []) {\n const name = field.envVarName?.trim();\n if (!name) {\n continue;\n }\n const v = this.appConfig.env[name];\n if (typeof v === \"string\" && v.length > 0) {\n mat[field.key] = v;\n }\n }\n return Object.freeze({\n resolvedPublicConfig: Object.freeze(pub),\n resolvedMaterial: Object.freeze(mat),\n });\n }\n}\n","import { createCipheriv, createDecipheriv, createHash, randomBytes } from \"node:crypto\";\n\nimport { inject, injectable } from \"@codemation/core\";\n\nimport { ApplicationTokens } from \"../../applicationTokens\";\nimport type { AppConfig } from \"../../presentation/config/AppConfig\";\n\nimport type { JsonRecord } from \"./CredentialServices\";\n\n@injectable()\nexport class CredentialSecretCipher {\n private static readonly algorithm = \"aes-256-gcm\";\n private static readonly schemaVersion = 1;\n private static readonly ivLength = 12;\n\n constructor(\n @inject(ApplicationTokens.AppConfig)\n private readonly appConfig: AppConfig,\n ) {}\n\n encrypt(value: JsonRecord): Readonly<{\n encryptedJson: string;\n encryptionKeyId: string;\n schemaVersion: number;\n }> {\n const iv = randomBytes(CredentialSecretCipher.ivLength);\n const cipher = createCipheriv(CredentialSecretCipher.algorithm, this.resolveKeyMaterial(), iv);\n const plaintext = Buffer.from(JSON.stringify(value), \"utf8\");\n const encrypted = Buffer.concat([cipher.update(plaintext), cipher.final()]);\n const authTag = cipher.getAuthTag();\n return {\n encryptedJson: Buffer.concat([iv, authTag, encrypted]).toString(\"base64\"),\n encryptionKeyId: this.resolveKeyId(),\n schemaVersion: CredentialSecretCipher.schemaVersion,\n };\n }\n\n decrypt(\n record: Readonly<{\n encryptedJson: string;\n encryptionKeyId: string;\n schemaVersion: number;\n }>,\n ): JsonRecord {\n const packed = Buffer.from(record.encryptedJson, \"base64\");\n const iv = packed.subarray(0, CredentialSecretCipher.ivLength);\n const authTag = packed.subarray(CredentialSecretCipher.ivLength, CredentialSecretCipher.ivLength + 16);\n const encrypted = packed.subarray(CredentialSecretCipher.ivLength + 16);\n const decipher = createDecipheriv(CredentialSecretCipher.algorithm, this.resolveKeyMaterial(), iv);\n decipher.setAuthTag(authTag);\n const plaintext = Buffer.concat([decipher.update(encrypted), decipher.final()]).toString(\"utf8\");\n return JSON.parse(plaintext) as JsonRecord;\n }\n\n private resolveKeyMaterial(): Buffer {\n const rawValue = this.appConfig.env.CODEMATION_CREDENTIALS_MASTER_KEY;\n if (!rawValue || rawValue.trim().length === 0) {\n throw new Error(\"CODEMATION_CREDENTIALS_MASTER_KEY is required to encrypt database-managed credentials.\");\n }\n return createHash(\"sha256\").update(rawValue).digest();\n }\n\n private resolveKeyId(): string {\n const rawValue = this.appConfig.env.CODEMATION_CREDENTIALS_MASTER_KEY;\n return createHash(\"sha256\")\n .update(rawValue ?? \"\")\n .digest(\"hex\")\n .slice(0, 12);\n }\n}\n","import { inject, injectable } from \"@codemation/core\";\n\nimport { ApplicationTokens } from \"../../applicationTokens\";\nimport type { AppConfig } from \"../../presentation/config/AppConfig\";\n\nimport { CredentialSecretCipher } from \"./CredentialSecretCipher\";\nimport type { CredentialInstanceRecord, CredentialStore, JsonRecord } from \"./CredentialServices\";\n\n@injectable()\nexport class CredentialMaterialResolver {\n constructor(\n @inject(ApplicationTokens.CredentialStore)\n private readonly credentialStore: CredentialStore,\n @inject(CredentialSecretCipher)\n private readonly credentialSecretCipher: CredentialSecretCipher,\n @inject(ApplicationTokens.AppConfig)\n private readonly appConfig: AppConfig,\n ) {}\n\n async resolveMaterial(instance: CredentialInstanceRecord): Promise<JsonRecord> {\n if (instance.secretRef.kind === \"db\") {\n const secretMaterial = await this.credentialStore.getSecretMaterial(instance.instanceId);\n if (!secretMaterial) {\n throw new Error(`Credential ${instance.instanceId} is missing encrypted secret material.`);\n }\n return this.credentialSecretCipher.decrypt(secretMaterial);\n }\n if (instance.secretRef.kind === \"env\") {\n return this.resolveEnvMaterial(instance);\n }\n return instance.secretRef.value;\n }\n\n private resolveEnvMaterial(instance: CredentialInstanceRecord): JsonRecord {\n if (instance.secretRef.kind !== \"env\") {\n throw new Error(`Credential ${instance.instanceId} is not environment-backed.`);\n }\n const resolved: Record<string, unknown> = {};\n const missingEnvironmentVariables: string[] = [];\n for (const [fieldKey, envVarName] of Object.entries(instance.secretRef.envByField)) {\n const value = this.appConfig.env[envVarName];\n if (value === undefined || value.length === 0) {\n missingEnvironmentVariables.push(envVarName);\n continue;\n }\n resolved[fieldKey] = value;\n }\n if (missingEnvironmentVariables.length > 0) {\n throw new Error(\n `Credential ${instance.instanceId} requires environment variables that are not set: ${missingEnvironmentVariables.join(\", \")}.`,\n );\n }\n return resolved;\n }\n}\n","import type { CredentialOAuth2AuthDefinition } from \"@codemation/core\";\nimport { injectable } from \"@codemation/core\";\nimport type { JsonRecord } from \"./CredentialServices\";\n\n@injectable()\nexport class CredentialOAuth2ScopeResolver {\n resolveRequestedScopes(auth: CredentialOAuth2AuthDefinition, publicConfig: JsonRecord): ReadonlyArray<string> {\n const scopesFromPublicConfig = auth.scopesFromPublicConfig;\n if (!scopesFromPublicConfig) {\n return [...auth.scopes];\n }\n const preset = this.resolveString(publicConfig[scopesFromPublicConfig.presetFieldKey]);\n if (!preset) {\n return [...auth.scopes];\n }\n const presetScopes = scopesFromPublicConfig.presetScopes[preset];\n if (presetScopes) {\n return [...presetScopes];\n }\n const customPresetKey = scopesFromPublicConfig.customPresetKey ?? \"custom\";\n if (preset !== customPresetKey) {\n return [...auth.scopes];\n }\n const customScopes = this.resolveScopeList(\n publicConfig[scopesFromPublicConfig.customScopesFieldKey ?? \"customScopes\"],\n );\n if (customScopes.length > 0) {\n return customScopes;\n }\n return [...auth.scopes];\n }\n\n private resolveString(value: unknown): string | undefined {\n if (typeof value !== \"string\") {\n return undefined;\n }\n const normalized = value.trim();\n return normalized.length > 0 ? normalized : undefined;\n }\n\n private resolveScopeList(value: unknown): ReadonlyArray<string> {\n if (Array.isArray(value)) {\n return this.dedupe(\n value.map((entry) => (typeof entry === \"string\" ? entry.trim() : \"\")).filter((entry) => entry.length > 0),\n );\n }\n if (typeof value !== \"string\") {\n return [];\n }\n return this.dedupe(\n value\n .split(/[\\s,]+/)\n .map((entry) => entry.trim())\n .filter((entry) => entry.length > 0),\n );\n }\n\n private dedupe(entries: ReadonlyArray<string>): ReadonlyArray<string> {\n return [...new Set(entries)];\n }\n}\n","import { randomUUID } from \"node:crypto\";\n\nimport type {\n CredentialFieldSchema,\n CredentialInstanceId,\n CredentialMaterialSourceKind,\n CredentialTypeId,\n} from \"@codemation/core\";\n\nimport { CoreTokens, inject, injectable } from \"@codemation/core\";\n\nimport { ApplicationRequestError } from \"../../application/ApplicationRequestError\";\n\nimport type {\n CreateCredentialInstanceRequest,\n CredentialInstanceDto,\n CredentialInstanceWithSecretsDto,\n CredentialOAuth2ConnectionDto,\n UpdateCredentialInstanceRequest,\n} from \"../../application/contracts/CredentialContractsRegistry\";\n\nimport { ApplicationTokens } from \"../../applicationTokens\";\n\nimport { CredentialFieldEnvOverlayService } from \"./CredentialFieldEnvOverlayService\";\nimport { CredentialMaterialResolver } from \"./CredentialMaterialResolver\";\nimport { CredentialOAuth2ScopeResolver } from \"./CredentialOAuth2ScopeResolver\";\nimport { CredentialSecretCipher } from \"./CredentialSecretCipher\";\nimport type {\n CredentialInstanceRecord,\n CredentialSecretMaterialRecord,\n CredentialSecretRef,\n CredentialStore,\n CredentialTestRecord,\n AnyCredentialType,\n JsonRecord,\n MutableCredentialSessionService,\n} from \"./CredentialServices\";\nimport { CredentialTypeRegistryImpl } from \"./CredentialServices\";\n\n@injectable()\nexport class CredentialInstanceService {\n constructor(\n @inject(ApplicationTokens.CredentialStore)\n private readonly credentialStore: CredentialStore,\n @inject(CredentialTypeRegistryImpl)\n private readonly credentialTypeRegistry: CredentialTypeRegistryImpl,\n @inject(CredentialSecretCipher)\n private readonly credentialSecretCipher: CredentialSecretCipher,\n @inject(CredentialFieldEnvOverlayService)\n private readonly credentialFieldEnvOverlayService: CredentialFieldEnvOverlayService,\n @inject(CredentialMaterialResolver)\n private readonly credentialMaterialResolver: CredentialMaterialResolver,\n @inject(CredentialOAuth2ScopeResolver)\n private readonly credentialOAuth2ScopeResolver: CredentialOAuth2ScopeResolver,\n @inject(CoreTokens.CredentialSessionService)\n private readonly credentialSessionService: MutableCredentialSessionService,\n ) {}\n\n async listInstances(): Promise<ReadonlyArray<CredentialInstanceDto>> {\n const instances = await this.credentialStore.listInstances();\n const latestTestResults = await this.credentialStore.getLatestTestResults(\n instances.map((instance) => instance.instanceId),\n );\n return await Promise.all(\n instances.map(async (instance) => await this.toDto(instance, latestTestResults.get(instance.instanceId))),\n );\n }\n\n async getInstance(instanceId: CredentialInstanceId): Promise<CredentialInstanceDto | undefined> {\n const instance = await this.credentialStore.getInstance(instanceId);\n if (!instance) {\n return undefined;\n }\n const latestTestResult = await this.credentialStore.getLatestTestResult(instanceId);\n return await this.toDto(instance, latestTestResult);\n }\n\n async getInstanceWithSecrets(\n instanceId: CredentialInstanceId,\n ): Promise<CredentialInstanceWithSecretsDto | undefined> {\n const instance = await this.credentialStore.getInstance(instanceId);\n if (!instance) {\n return undefined;\n }\n const latestTestResult = await this.credentialStore.getLatestTestResult(instanceId);\n const base = await this.toDto(instance, latestTestResult);\n try {\n const material = await this.credentialMaterialResolver.resolveMaterial(instance);\n const secretConfig = Object.fromEntries(Object.entries(material).map(([k, v]) => [k, String(v ?? \"\")])) as Record<\n string,\n string\n >;\n const envSecretRefs =\n instance.secretRef.kind === \"env\" ? (instance.secretRef.envByField as Record<string, string>) : undefined;\n return { ...base, secretConfig, envSecretRefs };\n } catch {\n return base;\n }\n }\n\n async create(request: CreateCredentialInstanceRequest): Promise<CredentialInstanceDto> {\n const credentialType = this.requireCredentialType(request.typeId);\n const publicFields = credentialType.definition.publicFields ?? [];\n const secretFields = credentialType.definition.secretFields ?? [];\n this.validateRequestFields({\n displayName: request.displayName,\n publicFields,\n publicConfig: request.publicConfig ?? {},\n secretFields,\n sourceKind: request.sourceKind,\n secretConfig: request.secretConfig ?? {},\n envSecretRefs: request.envSecretRefs ?? {},\n });\n const timestamp = new Date().toISOString();\n const strippedPublic = this.stripEnvManagedFieldValues(publicFields, request.publicConfig ?? {});\n const strippedSecretForRef = this.stripEnvManagedFieldValues(secretFields, request.secretConfig ?? {});\n const instance: CredentialInstanceRecord = {\n instanceId: randomUUID(),\n typeId: request.typeId,\n displayName: request.displayName.trim(),\n sourceKind: request.sourceKind,\n publicConfig: Object.freeze({ ...strippedPublic }),\n secretRef: this.createSecretRef(request.sourceKind, strippedSecretForRef, request.envSecretRefs ?? {}),\n tags: Object.freeze([...(request.tags ?? [])]),\n setupStatus: credentialType.definition.auth?.kind === \"oauth2\" ? \"draft\" : \"ready\",\n createdAt: timestamp,\n updatedAt: timestamp,\n };\n await this.credentialStore.saveInstance({\n instance,\n secretMaterial: this.createSecretMaterial(instance, strippedSecretForRef, timestamp),\n });\n this.credentialSessionService.evictInstance(instance.instanceId);\n return this.toDto(instance, undefined);\n }\n\n async update(\n instanceId: CredentialInstanceId,\n request: UpdateCredentialInstanceRequest,\n ): Promise<CredentialInstanceDto> {\n const existing = await this.requireInstance(instanceId);\n const credentialType = this.requireCredentialType(existing.typeId);\n const mergedPublicRaw = { ...(request.publicConfig ?? existing.publicConfig) };\n const updatedAt = new Date().toISOString();\n const nextSecretConfig = request.secretConfig;\n const nextEnvSecretRefs = request.envSecretRefs;\n const secretFields = credentialType.definition.secretFields ?? [];\n this.validateRequestFields({\n displayName: request.displayName ?? existing.displayName,\n publicFields: credentialType.definition.publicFields ?? [],\n publicConfig: mergedPublicRaw,\n secretFields,\n sourceKind: existing.sourceKind,\n secretConfig: nextSecretConfig ?? {},\n envSecretRefs: nextEnvSecretRefs ?? {},\n allowSecretOmission: true,\n });\n const publicConfig = Object.freeze({\n ...this.stripEnvManagedFieldValues(credentialType.definition.publicFields ?? [], mergedPublicRaw),\n });\n const mergedSecretForRef =\n nextSecretConfig !== undefined ? this.stripEnvManagedFieldValues(secretFields, nextSecretConfig) : undefined;\n const instance: CredentialInstanceRecord = {\n ...existing,\n displayName: request.displayName?.trim() || existing.displayName,\n publicConfig,\n tags: Object.freeze([...(request.tags ?? existing.tags)]),\n setupStatus: request.setupStatus ?? existing.setupStatus,\n secretRef:\n nextSecretConfig || nextEnvSecretRefs\n ? this.createSecretRef(existing.sourceKind, mergedSecretForRef ?? {}, nextEnvSecretRefs ?? {})\n : existing.secretRef,\n updatedAt,\n };\n await this.credentialStore.saveInstance({\n instance,\n secretMaterial:\n nextSecretConfig !== undefined && mergedSecretForRef !== undefined\n ? this.createSecretMaterial(instance, mergedSecretForRef, updatedAt)\n : undefined,\n });\n this.credentialSessionService.evictInstance(instance.instanceId);\n return this.toDto(instance, await this.credentialStore.getLatestTestResult(instance.instanceId));\n }\n\n async delete(instanceId: CredentialInstanceId): Promise<void> {\n await this.credentialStore.deleteInstance(instanceId);\n this.credentialSessionService.evictInstance(instanceId);\n }\n\n async disconnectOAuth2(instanceId: CredentialInstanceId): Promise<CredentialInstanceDto> {\n const instance = await this.requireInstance(instanceId);\n const credentialType = this.requireCredentialType(instance.typeId);\n if (credentialType.definition.auth?.kind !== \"oauth2\") {\n throw new ApplicationRequestError(400, `Credential instance ${instanceId} does not use OAuth2.`);\n }\n const updatedInstance: CredentialInstanceRecord = {\n ...instance,\n setupStatus: \"draft\",\n updatedAt: new Date().toISOString(),\n };\n await this.credentialStore.saveInstance({\n instance: updatedInstance,\n });\n await this.credentialStore.deleteOAuth2Material(instanceId);\n this.credentialSessionService.evictInstance(instanceId);\n return await this.toDto(updatedInstance, await this.credentialStore.getLatestTestResult(instanceId));\n }\n\n async requireInstance(instanceId: CredentialInstanceId): Promise<CredentialInstanceRecord> {\n const instance = await this.credentialStore.getInstance(instanceId);\n if (!instance) {\n throw new ApplicationRequestError(404, `Unknown credential instance: ${instanceId}`);\n }\n return instance;\n }\n\n private createSecretRef(\n sourceKind: CredentialMaterialSourceKind,\n secretConfig: JsonRecord,\n envSecretRefs: Readonly<Record<string, string>>,\n ): CredentialSecretRef {\n if (sourceKind === \"db\") {\n return { kind: \"db\" };\n }\n if (sourceKind === \"env\") {\n return {\n kind: \"env\",\n envByField: Object.freeze({ ...envSecretRefs }),\n };\n }\n return {\n kind: \"code\",\n value: Object.freeze({ ...secretConfig }),\n };\n }\n\n private createSecretMaterial(\n instance: CredentialInstanceRecord,\n secretConfig: JsonRecord,\n updatedAt: string,\n ): CredentialSecretMaterialRecord | undefined {\n if (instance.sourceKind !== \"db\") {\n return undefined;\n }\n const encrypted = this.credentialSecretCipher.encrypt(secretConfig);\n return {\n instanceId: instance.instanceId,\n encryptedJson: encrypted.encryptedJson,\n encryptionKeyId: encrypted.encryptionKeyId,\n schemaVersion: encrypted.schemaVersion,\n updatedAt,\n };\n }\n\n private validateRequestFields(\n args: Readonly<{\n displayName: string;\n publicFields: ReadonlyArray<CredentialFieldSchema>;\n publicConfig: JsonRecord;\n secretFields: ReadonlyArray<CredentialFieldSchema>;\n sourceKind: CredentialMaterialSourceKind;\n secretConfig: JsonRecord;\n envSecretRefs: Readonly<Record<string, string>>;\n allowSecretOmission?: boolean;\n }>,\n ): void {\n if (!args.displayName || args.displayName.trim().length === 0) {\n throw new ApplicationRequestError(400, \"Credential displayName is required.\");\n }\n this.assertRequiredFields(\"publicConfig\", args.publicFields, args.publicConfig);\n if (args.sourceKind === \"db\") {\n if (!args.allowSecretOmission || Object.keys(args.secretConfig).length > 0) {\n this.assertRequiredFields(\"secretConfig\", args.secretFields, args.secretConfig);\n }\n return;\n }\n if (args.sourceKind === \"env\") {\n if (!args.allowSecretOmission || Object.keys(args.envSecretRefs).length > 0) {\n this.assertRequiredEnvFields(args.secretFields, args.envSecretRefs);\n }\n return;\n }\n if (!args.allowSecretOmission || Object.keys(args.secretConfig).length > 0) {\n this.assertRequiredFields(\"secretConfig\", args.secretFields, args.secretConfig);\n }\n }\n\n private stripEnvManagedFieldValues(fields: ReadonlyArray<CredentialFieldSchema>, value: JsonRecord): JsonRecord {\n const out: Record<string, unknown> = { ...value };\n for (const field of fields) {\n if (this.credentialFieldEnvOverlayService.isFieldResolvedFromEnv(field)) {\n delete out[field.key];\n }\n }\n return Object.freeze(out);\n }\n\n private assertRequiredFields(\n fieldName: string,\n schema: ReadonlyArray<CredentialFieldSchema>,\n value: JsonRecord,\n ): void {\n const missing = schema\n .filter((field) => field.required === true)\n .filter((field) => !this.credentialFieldEnvOverlayService.isFieldResolvedFromEnv(field))\n .filter((field) => value[field.key] === undefined || value[field.key] === null || value[field.key] === \"\")\n .map((field) => field.key);\n if (missing.length > 0) {\n throw new ApplicationRequestError(400, `Missing required ${fieldName} field(s): ${missing.join(\", \")}`);\n }\n }\n\n private assertRequiredEnvFields(\n schema: ReadonlyArray<CredentialFieldSchema>,\n envSecretRefs: Readonly<Record<string, string>>,\n ): void {\n const missing = schema\n .filter((field) => field.required === true)\n .filter((field) => !this.credentialFieldEnvOverlayService.isFieldResolvedFromEnv(field))\n .filter((field) => !envSecretRefs[field.key] || envSecretRefs[field.key]!.trim().length === 0)\n .map((field) => field.key);\n if (missing.length > 0) {\n throw new ApplicationRequestError(400, `Missing required envSecretRefs field(s): ${missing.join(\", \")}`);\n }\n }\n\n private requireCredentialType(typeId: CredentialTypeId): AnyCredentialType {\n const credentialType = this.credentialTypeRegistry.getCredentialType(typeId);\n if (!credentialType) {\n throw new ApplicationRequestError(400, `Unknown credential type: ${typeId}`);\n }\n return credentialType;\n }\n\n async markOAuth2Connected(instanceId: CredentialInstanceId, connectedAt: string): Promise<void> {\n const instance = await this.requireInstance(instanceId);\n await this.credentialStore.saveInstance({\n instance: {\n ...instance,\n setupStatus: \"ready\",\n updatedAt: connectedAt,\n },\n });\n this.credentialSessionService.evictInstance(instanceId);\n }\n\n private async toDto(\n instance: CredentialInstanceRecord,\n latestTestResult: CredentialTestRecord | undefined,\n ): Promise<CredentialInstanceDto> {\n const oauth2Connection = await this.toOAuth2ConnectionDto(instance);\n return {\n instanceId: instance.instanceId,\n typeId: instance.typeId,\n displayName: instance.displayName,\n sourceKind: instance.sourceKind,\n publicConfig: instance.publicConfig,\n tags: instance.tags,\n setupStatus: instance.setupStatus,\n createdAt: instance.createdAt,\n updatedAt: instance.updatedAt,\n latestHealth: latestTestResult?.health,\n oauth2Connection,\n };\n }\n\n private async toOAuth2ConnectionDto(\n instance: CredentialInstanceRecord,\n ): Promise<CredentialOAuth2ConnectionDto | undefined> {\n const credentialType = this.credentialTypeRegistry.getCredentialType(instance.typeId);\n if (credentialType?.definition.auth?.kind !== \"oauth2\") {\n return undefined;\n }\n const providerId =\n \"providerId\" in credentialType.definition.auth ? credentialType.definition.auth.providerId : \"custom\";\n const material = await this.credentialStore.getOAuth2Material(instance.instanceId);\n if (!material) {\n const requestedScopes = this.credentialOAuth2ScopeResolver.resolveRequestedScopes(\n credentialType.definition.auth,\n instance.publicConfig,\n );\n return {\n status: \"disconnected\",\n providerId,\n scopes: [...requestedScopes],\n };\n }\n return {\n status: \"connected\",\n providerId: material.providerId,\n connectedEmail: material.connectedEmail,\n connectedAt: material.connectedAt,\n scopes: material.scopes,\n updatedAt: material.updatedAt,\n };\n }\n}\n","import type {\n CredentialBinding,\n CredentialBindingKey,\n CredentialInstanceId,\n CredentialRequirement,\n WorkflowDefinition,\n WorkflowRepository,\n} from \"@codemation/core\";\n\nimport { CoreTokens, inject, injectable } from \"@codemation/core\";\n\nimport { ApplicationRequestError } from \"../../application/ApplicationRequestError\";\n\nimport type {\n WorkflowCredentialHealthDto,\n WorkflowCredentialHealthSlotDto,\n} from \"../../application/contracts/CredentialContractsRegistry\";\n\nimport { ApplicationTokens } from \"../../applicationTokens\";\n\nimport { WorkflowCredentialNodeResolver } from \"./WorkflowCredentialNodeResolver\";\nimport { CredentialInstanceService } from \"./CredentialInstanceService\";\nimport type { CredentialStore, MutableCredentialSessionService } from \"./CredentialServices\";\n\n@injectable()\nexport class CredentialBindingService {\n constructor(\n @inject(ApplicationTokens.CredentialStore)\n private readonly credentialStore: CredentialStore,\n @inject(CredentialInstanceService)\n private readonly credentialInstanceService: CredentialInstanceService,\n @inject(CoreTokens.WorkflowRepository)\n private readonly workflowRepository: WorkflowRepository,\n @inject(CoreTokens.CredentialSessionService)\n private readonly credentialSessionService: MutableCredentialSessionService,\n @inject(WorkflowCredentialNodeResolver)\n private readonly workflowCredentialNodeResolver: WorkflowCredentialNodeResolver,\n ) {}\n\n async upsertBinding(\n args: Readonly<{ workflowId: string; nodeId: string; slotKey: string; instanceId: CredentialInstanceId }>,\n ): Promise<CredentialBinding> {\n const workflow = this.requireWorkflow(args.workflowId);\n const requirement = this.requireRequirement(workflow, args.nodeId, args.slotKey);\n const instance = await this.credentialInstanceService.requireInstance(args.instanceId);\n if (!requirement.acceptedTypes.includes(instance.typeId)) {\n throw new ApplicationRequestError(\n 400,\n `Credential instance ${instance.instanceId} (${instance.typeId}) is not compatible with slot ${args.slotKey}. Accepted types: ${requirement.acceptedTypes.join(\", \")}`,\n );\n }\n const binding: CredentialBinding = {\n key: {\n workflowId: args.workflowId,\n nodeId: args.nodeId,\n slotKey: args.slotKey,\n },\n instanceId: args.instanceId,\n updatedAt: new Date().toISOString(),\n };\n await this.credentialStore.upsertBinding(binding);\n this.credentialSessionService.evictBinding(binding.key);\n return binding;\n }\n\n async listWorkflowHealth(workflowId: string): Promise<WorkflowCredentialHealthDto> {\n const workflow = this.requireWorkflow(workflowId);\n const bindings = await this.credentialStore.listBindingsByWorkflowId(workflowId);\n const bindingsByKey = new Map(bindings.map((binding) => [this.toBindingKeyString(binding.key), binding] as const));\n const slots: WorkflowCredentialHealthSlotDto[] = [];\n for (const slotRef of this.workflowCredentialNodeResolver.listSlots(workflow)) {\n const requirement = slotRef.requirement;\n const bindingKey = {\n workflowId,\n nodeId: slotRef.nodeId,\n slotKey: requirement.slotKey,\n } satisfies CredentialBindingKey;\n const binding = bindingsByKey.get(this.toBindingKeyString(bindingKey));\n if (!binding) {\n slots.push({\n workflowId,\n nodeId: slotRef.nodeId,\n nodeName: slotRef.nodeName,\n requirement,\n health: {\n status: requirement.optional ? \"optional-unbound\" : \"unbound\",\n },\n });\n continue;\n }\n const instance = await this.credentialInstanceService.requireInstance(binding.instanceId);\n const latestTestResult = await this.credentialStore.getLatestTestResult(instance.instanceId);\n slots.push({\n workflowId,\n nodeId: slotRef.nodeId,\n nodeName: slotRef.nodeName,\n requirement,\n instance: {\n instanceId: instance.instanceId,\n typeId: instance.typeId,\n displayName: instance.displayName,\n setupStatus: instance.setupStatus,\n },\n health: {\n status: latestTestResult?.health.status ?? \"unknown\",\n message: latestTestResult?.health.message,\n testedAt: latestTestResult?.health.testedAt,\n },\n });\n }\n return {\n workflowId,\n slots,\n };\n }\n\n private requireWorkflow(workflowId: string): WorkflowDefinition {\n const workflow = this.workflowRepository.get(decodeURIComponent(workflowId));\n if (!workflow) {\n throw new ApplicationRequestError(404, `Unknown workflowId: ${workflowId}`);\n }\n return workflow;\n }\n\n private requireRequirement(workflow: WorkflowDefinition, nodeId: string, slotKey: string): CredentialRequirement {\n const resolved = this.workflowCredentialNodeResolver.findRequirement(workflow, nodeId, slotKey);\n if (!resolved) {\n if (!this.workflowCredentialNodeResolver.isCredentialNodeIdInWorkflow(workflow, nodeId)) {\n throw new ApplicationRequestError(404, `Unknown workflow node: ${nodeId}`);\n }\n throw new ApplicationRequestError(400, `Node ${nodeId} does not declare credential slot ${slotKey}.`);\n }\n return resolved.requirement;\n }\n\n private toBindingKeyString(bindingKey: CredentialBindingKey): string {\n return `${bindingKey.workflowId}:${bindingKey.nodeId}:${bindingKey.slotKey}`;\n }\n}\n","import { inject, injectable } from \"@codemation/core\";\n\nimport { ApplicationTokens } from \"../../applicationTokens\";\n\nimport { CredentialMaterialResolver } from \"./CredentialMaterialResolver\";\nimport { CredentialSecretCipher } from \"./CredentialSecretCipher\";\nimport type { CredentialInstanceRecord, CredentialStore, JsonRecord } from \"./CredentialServices\";\nimport { CredentialTypeRegistryImpl } from \"./CredentialServices\";\n\n@injectable()\nexport class CredentialRuntimeMaterialService {\n constructor(\n @inject(ApplicationTokens.CredentialStore)\n private readonly credentialStore: CredentialStore,\n @inject(CredentialMaterialResolver)\n private readonly credentialMaterialResolver: CredentialMaterialResolver,\n @inject(CredentialSecretCipher)\n private readonly credentialSecretCipher: CredentialSecretCipher,\n @inject(CredentialTypeRegistryImpl)\n private readonly credentialTypeRegistry: CredentialTypeRegistryImpl,\n ) {}\n\n async compose(instance: CredentialInstanceRecord): Promise<JsonRecord> {\n const baseMaterial = await this.credentialMaterialResolver.resolveMaterial(instance);\n const auth = this.credentialTypeRegistry.getCredentialType(instance.typeId)?.definition.auth;\n if (auth?.kind !== \"oauth2\") {\n return baseMaterial;\n }\n const oauth2Material = await this.credentialStore.getOAuth2Material(instance.instanceId);\n if (!oauth2Material) {\n return baseMaterial;\n }\n const decryptedOauth2Material = this.credentialSecretCipher.decrypt(oauth2Material);\n return Object.freeze({\n ...baseMaterial,\n ...decryptedOauth2Material,\n });\n }\n}\n","import type {\n CredentialBindingKey,\n CredentialInstanceId,\n CredentialSessionService,\n WorkflowRepository,\n} from \"@codemation/core\";\n\nimport { CoreTokens, CredentialUnboundError, inject, injectable } from \"@codemation/core\";\n\nimport { ApplicationRequestError } from \"../../application/ApplicationRequestError\";\n\nimport { ApplicationTokens } from \"../../applicationTokens\";\n\nimport { WorkflowCredentialNodeResolver } from \"./WorkflowCredentialNodeResolver\";\nimport { CredentialFieldEnvOverlayService } from \"./CredentialFieldEnvOverlayService\";\nimport { CredentialRuntimeMaterialService } from \"./CredentialRuntimeMaterialService\";\nimport type { CredentialStore } from \"./CredentialServices\";\nimport { CredentialTypeRegistryImpl } from \"./CredentialServices\";\n\n@injectable()\nexport class CredentialSessionServiceImpl implements CredentialSessionService {\n private readonly cachedSessionsByInstanceId = new Map<CredentialInstanceId, Promise<unknown>>();\n private readonly cachedInstanceIdsByBindingKey = new Map<string, CredentialInstanceId>();\n\n constructor(\n @inject(ApplicationTokens.CredentialStore)\n private readonly credentialStore: CredentialStore,\n @inject(CredentialRuntimeMaterialService)\n private readonly credentialRuntimeMaterialService: CredentialRuntimeMaterialService,\n @inject(CredentialFieldEnvOverlayService)\n private readonly credentialFieldEnvOverlayService: CredentialFieldEnvOverlayService,\n @inject(CredentialTypeRegistryImpl)\n private readonly credentialTypeRegistry: CredentialTypeRegistryImpl,\n @inject(CoreTokens.WorkflowRepository)\n private readonly workflowRepository: WorkflowRepository,\n @inject(WorkflowCredentialNodeResolver)\n private readonly workflowCredentialNodeResolver: WorkflowCredentialNodeResolver,\n ) {}\n\n async getSession<TSession = unknown>(\n args: Readonly<{ workflowId: string; nodeId: string; slotKey: string }>,\n ): Promise<TSession> {\n const workflow = this.workflowRepository.get(decodeURIComponent(args.workflowId));\n const displayLabel = workflow\n ? this.workflowCredentialNodeResolver.describeCredentialNodeDisplay(workflow, args.nodeId)\n : undefined;\n const requirement = workflow\n ? this.workflowCredentialNodeResolver.findRequirement(workflow, args.nodeId, args.slotKey)?.requirement\n : undefined;\n const bindingKey: CredentialBindingKey = {\n workflowId: args.workflowId,\n nodeId: args.nodeId,\n slotKey: args.slotKey,\n };\n const binding = await this.credentialStore.getBinding(bindingKey);\n if (!binding) {\n const unbound = new CredentialUnboundError(bindingKey, requirement?.acceptedTypes ?? []);\n if (displayLabel) {\n throw new Error(`${displayLabel}: ${unbound.message}`, { cause: unbound });\n }\n throw unbound;\n }\n const bindingCacheKey = this.toBindingKeyString(bindingKey);\n this.cachedInstanceIdsByBindingKey.set(bindingCacheKey, binding.instanceId);\n const cachedSession = this.cachedSessionsByInstanceId.get(binding.instanceId);\n if (cachedSession) {\n return (await cachedSession) as TSession;\n }\n const nextSessionPromise = this.createSession(binding.instanceId, displayLabel).catch((error) => {\n this.cachedSessionsByInstanceId.delete(binding.instanceId);\n throw error;\n });\n this.cachedSessionsByInstanceId.set(binding.instanceId, nextSessionPromise);\n return (await nextSessionPromise) as TSession;\n }\n\n evictInstance(instanceId: CredentialInstanceId): void {\n this.cachedSessionsByInstanceId.delete(instanceId);\n }\n\n evictBinding(bindingKey: CredentialBindingKey): void {\n const cacheKey = this.toBindingKeyString(bindingKey);\n const instanceId = this.cachedInstanceIdsByBindingKey.get(cacheKey);\n if (instanceId) {\n this.cachedSessionsByInstanceId.delete(instanceId);\n }\n this.cachedInstanceIdsByBindingKey.delete(cacheKey);\n }\n\n private async createSession(instanceId: CredentialInstanceId, displayLabel?: string): Promise<unknown> {\n const instance = await this.credentialStore.getInstance(instanceId);\n if (!instance) {\n throw new ApplicationRequestError(404, `Unknown credential instance: ${instanceId}`);\n }\n const credentialType = this.credentialTypeRegistry.getCredentialType(instance.typeId);\n if (!credentialType) {\n const prefix = displayLabel ? `${displayLabel}: ` : \"\";\n throw new ApplicationRequestError(\n 400,\n `${prefix}Credential type \"${instance.typeId}\" is not registered in this runtime (binding points at an unknown type).`,\n );\n }\n const material = await this.credentialRuntimeMaterialService.compose(instance);\n const { resolvedPublicConfig, resolvedMaterial } = this.credentialFieldEnvOverlayService.apply({\n definition: credentialType.definition,\n publicConfig: instance.publicConfig,\n material,\n });\n return await credentialType.createSession({\n instance,\n material: resolvedMaterial,\n publicConfig: resolvedPublicConfig,\n });\n }\n\n private toBindingKeyString(bindingKey: CredentialBindingKey): string {\n return `${bindingKey.workflowId}:${bindingKey.nodeId}:${bindingKey.slotKey}`;\n }\n}\n","import { randomUUID } from \"node:crypto\";\n\nimport type { CredentialHealth, CredentialInstanceId, CredentialTypeId } from \"@codemation/core\";\n\nimport { CoreTokens, inject, injectable } from \"@codemation/core\";\n\nimport { ApplicationRequestError } from \"../../application/ApplicationRequestError\";\n\nimport { ApplicationTokens } from \"../../applicationTokens\";\n\nimport { CredentialFieldEnvOverlayService } from \"./CredentialFieldEnvOverlayService\";\nimport { CredentialInstanceService } from \"./CredentialInstanceService\";\nimport { CredentialRuntimeMaterialService } from \"./CredentialRuntimeMaterialService\";\nimport type { CredentialStore, AnyCredentialType, MutableCredentialSessionService } from \"./CredentialServices\";\nimport { CredentialTypeRegistryImpl } from \"./CredentialServices\";\n\n@injectable()\nexport class CredentialTestService {\n constructor(\n @inject(CredentialInstanceService)\n private readonly credentialInstanceService: CredentialInstanceService,\n @inject(CredentialRuntimeMaterialService)\n private readonly credentialRuntimeMaterialService: CredentialRuntimeMaterialService,\n @inject(CredentialFieldEnvOverlayService)\n private readonly credentialFieldEnvOverlayService: CredentialFieldEnvOverlayService,\n @inject(CredentialTypeRegistryImpl)\n private readonly credentialTypeRegistry: CredentialTypeRegistryImpl,\n @inject(ApplicationTokens.CredentialStore)\n private readonly credentialStore: CredentialStore,\n @inject(CoreTokens.CredentialSessionService)\n private readonly credentialSessionService: MutableCredentialSessionService,\n ) {}\n\n async test(instanceId: CredentialInstanceId): Promise<CredentialHealth> {\n const instance = await this.credentialInstanceService.requireInstance(instanceId);\n const credentialType = this.requireCredentialType(instance.typeId);\n const material = await this.credentialRuntimeMaterialService.compose(instance);\n const { resolvedPublicConfig, resolvedMaterial } = this.credentialFieldEnvOverlayService.apply({\n definition: credentialType.definition,\n publicConfig: instance.publicConfig,\n material,\n });\n const health = await credentialType.test({\n instance,\n material: resolvedMaterial,\n publicConfig: resolvedPublicConfig,\n });\n const testedAt = health.testedAt ?? new Date().toISOString();\n await this.credentialStore.saveTestResult({\n testId: randomUUID(),\n instanceId,\n health: {\n ...health,\n testedAt,\n },\n testedAt,\n expiresAt: health.expiresAt,\n });\n this.credentialSessionService.evictInstance(instanceId);\n return {\n ...health,\n testedAt,\n };\n }\n\n private requireCredentialType(typeId: CredentialTypeId): AnyCredentialType {\n const credentialType = this.credentialTypeRegistry.getCredentialType(typeId);\n if (!credentialType) {\n throw new ApplicationRequestError(400, `Unknown credential type: ${typeId}`);\n }\n return credentialType;\n }\n}\n"],"mappings":";;;;;;;;;;AAQA,IAAa,qCAAb,MAAgD;CAC9C,YAAY,AAAiBA,WAAoC;EAApC;;CAE7B,MAAM,KACJ,MAC2B;EAC3B,MAAM,4BAAW,IAAI,MAAM,EAAC,aAAa;EACzC,MAAM,SAA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