@wildo-ai/platform-config-lib 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/bootstrap/application-backend-env.contracts.d.ts +2 -0
- package/dist/esm/bootstrap/application-backend-env.contracts.d.ts.map +1 -0
- package/dist/esm/bootstrap/application-backend-env.contracts.js +2 -0
- package/dist/esm/bootstrap/application-backend-env.contracts.js.map +1 -0
- package/dist/esm/bootstrap/bootstrap-planner.d.ts +20 -0
- package/dist/esm/bootstrap/bootstrap-planner.d.ts.map +1 -0
- package/dist/esm/bootstrap/bootstrap-planner.js +26 -0
- package/dist/esm/bootstrap/bootstrap-planner.js.map +1 -0
- package/dist/esm/bootstrap/bootstrap.contracts.d.ts +120 -0
- package/dist/esm/bootstrap/bootstrap.contracts.d.ts.map +1 -0
- package/dist/esm/bootstrap/bootstrap.contracts.js +117 -0
- package/dist/esm/bootstrap/bootstrap.contracts.js.map +1 -0
- package/dist/esm/bootstrap/bootstrap.schemas.d.ts +485 -0
- package/dist/esm/bootstrap/bootstrap.schemas.d.ts.map +1 -0
- package/dist/esm/bootstrap/bootstrap.schemas.js +130 -0
- package/dist/esm/bootstrap/bootstrap.schemas.js.map +1 -0
- package/dist/esm/bootstrap/platform-runtime-env.contracts.d.ts +78 -0
- package/dist/esm/bootstrap/platform-runtime-env.contracts.d.ts.map +1 -0
- package/dist/esm/bootstrap/platform-runtime-env.contracts.js +98 -0
- package/dist/esm/bootstrap/platform-runtime-env.contracts.js.map +1 -0
- package/dist/esm/bootstrap/runtime-topology.contracts.d.ts +17 -0
- package/dist/esm/bootstrap/runtime-topology.contracts.d.ts.map +1 -0
- package/dist/esm/bootstrap/runtime-topology.contracts.js +60 -0
- package/dist/esm/bootstrap/runtime-topology.contracts.js.map +1 -0
- package/dist/esm/credentials/credential-generator.service.d.ts +11 -0
- package/dist/esm/credentials/credential-generator.service.d.ts.map +1 -0
- package/dist/esm/credentials/credential-generator.service.js +31 -0
- package/dist/esm/credentials/credential-generator.service.js.map +1 -0
- package/dist/esm/credentials/credentials-provisioner.service.d.ts +190 -0
- package/dist/esm/credentials/credentials-provisioner.service.d.ts.map +1 -0
- package/dist/esm/credentials/credentials-provisioner.service.js +278 -0
- package/dist/esm/credentials/credentials-provisioner.service.js.map +1 -0
- package/dist/esm/index.d.ts +16 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +16 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/infra-managers/infra-manager.models.d.ts +146 -0
- package/dist/esm/infra-managers/infra-manager.models.d.ts.map +1 -0
- package/dist/esm/infra-managers/infra-manager.models.js +2 -0
- package/dist/esm/infra-managers/infra-manager.models.js.map +1 -0
- package/dist/esm/infra-managers/mongo-atlas-manager.service.d.ts +64 -0
- package/dist/esm/infra-managers/mongo-atlas-manager.service.d.ts.map +1 -0
- package/dist/esm/infra-managers/mongo-atlas-manager.service.js +307 -0
- package/dist/esm/infra-managers/mongo-atlas-manager.service.js.map +1 -0
- package/dist/esm/infra-managers/postgresql-manager.service.d.ts +115 -0
- package/dist/esm/infra-managers/postgresql-manager.service.d.ts.map +1 -0
- package/dist/esm/infra-managers/postgresql-manager.service.js +403 -0
- package/dist/esm/infra-managers/postgresql-manager.service.js.map +1 -0
- package/dist/esm/infra-managers/rabbitmq-manager.service.d.ts +64 -0
- package/dist/esm/infra-managers/rabbitmq-manager.service.d.ts.map +1 -0
- package/dist/esm/infra-managers/rabbitmq-manager.service.js +288 -0
- package/dist/esm/infra-managers/rabbitmq-manager.service.js.map +1 -0
- package/dist/esm/infra-managers/redis-manager.service.d.ts +78 -0
- package/dist/esm/infra-managers/redis-manager.service.d.ts.map +1 -0
- package/dist/esm/infra-managers/redis-manager.service.js +326 -0
- package/dist/esm/infra-managers/redis-manager.service.js.map +1 -0
- package/dist/esm/project-config/define-framework-config.d.ts +36 -0
- package/dist/esm/project-config/define-framework-config.d.ts.map +1 -0
- package/dist/esm/project-config/define-framework-config.js +30 -0
- package/dist/esm/project-config/define-framework-config.js.map +1 -0
- package/dist/esm/project-config/define-infra-config.d.ts +128 -0
- package/dist/esm/project-config/define-infra-config.d.ts.map +1 -0
- package/dist/esm/project-config/define-infra-config.js +87 -0
- package/dist/esm/project-config/define-infra-config.js.map +1 -0
- package/dist/esm/project-config/define-minion-config.d.ts +41 -0
- package/dist/esm/project-config/define-minion-config.d.ts.map +1 -0
- package/dist/esm/project-config/define-minion-config.js +24 -0
- package/dist/esm/project-config/define-minion-config.js.map +1 -0
- package/dist/esm/project-config/define-platform-config.d.ts +65 -0
- package/dist/esm/project-config/define-platform-config.d.ts.map +1 -0
- package/dist/esm/project-config/define-platform-config.js +22 -0
- package/dist/esm/project-config/define-platform-config.js.map +1 -0
- package/dist/esm/project-config/define-platform-env-config.d.ts +41 -0
- package/dist/esm/project-config/define-platform-env-config.d.ts.map +1 -0
- package/dist/esm/project-config/define-platform-env-config.js +45 -0
- package/dist/esm/project-config/define-platform-env-config.js.map +1 -0
- package/dist/esm/project-config/define-project-config.d.ts +38 -0
- package/dist/esm/project-config/define-project-config.d.ts.map +1 -0
- package/dist/esm/project-config/define-project-config.js +57 -0
- package/dist/esm/project-config/define-project-config.js.map +1 -0
- package/dist/esm/project-config/define-saas-config.d.ts +252 -0
- package/dist/esm/project-config/define-saas-config.d.ts.map +1 -0
- package/dist/esm/project-config/define-saas-config.js +137 -0
- package/dist/esm/project-config/define-saas-config.js.map +1 -0
- package/dist/esm/project-config/define-sharing-policy.d.ts +35 -0
- package/dist/esm/project-config/define-sharing-policy.d.ts.map +1 -0
- package/dist/esm/project-config/define-sharing-policy.js +30 -0
- package/dist/esm/project-config/define-sharing-policy.js.map +1 -0
- package/dist/esm/project-config/define-worker-config.d.ts +42 -0
- package/dist/esm/project-config/define-worker-config.d.ts.map +1 -0
- package/dist/esm/project-config/define-worker-config.js +24 -0
- package/dist/esm/project-config/define-worker-config.js.map +1 -0
- package/dist/esm/project-config/index.d.ts +22 -0
- package/dist/esm/project-config/index.d.ts.map +1 -0
- package/dist/esm/project-config/index.js +22 -0
- package/dist/esm/project-config/index.js.map +1 -0
- package/dist/esm/project-config/loader.d.ts +42 -0
- package/dist/esm/project-config/loader.d.ts.map +1 -0
- package/dist/esm/project-config/loader.js +164 -0
- package/dist/esm/project-config/loader.js.map +1 -0
- package/dist/esm/project-config/shared/application-modules.schemas.d.ts +10 -0
- package/dist/esm/project-config/shared/application-modules.schemas.d.ts.map +1 -0
- package/dist/esm/project-config/shared/application-modules.schemas.js +6 -0
- package/dist/esm/project-config/shared/application-modules.schemas.js.map +1 -0
- package/dist/esm/project-config/shared/application-modules.utils.d.ts +6 -0
- package/dist/esm/project-config/shared/application-modules.utils.d.ts.map +1 -0
- package/dist/esm/project-config/shared/application-modules.utils.js +26 -0
- package/dist/esm/project-config/shared/application-modules.utils.js.map +1 -0
- package/dist/esm/project-config/shared/backing-services.schemas.d.ts +68 -0
- package/dist/esm/project-config/shared/backing-services.schemas.d.ts.map +1 -0
- package/dist/esm/project-config/shared/backing-services.schemas.js +49 -0
- package/dist/esm/project-config/shared/backing-services.schemas.js.map +1 -0
- package/dist/esm/project-config/shared/data-services.schemas.d.ts +33 -0
- package/dist/esm/project-config/shared/data-services.schemas.d.ts.map +1 -0
- package/dist/esm/project-config/shared/data-services.schemas.js +47 -0
- package/dist/esm/project-config/shared/data-services.schemas.js.map +1 -0
- package/dist/esm/project-config/shared/env-example-defaults.d.ts +27 -0
- package/dist/esm/project-config/shared/env-example-defaults.d.ts.map +1 -0
- package/dist/esm/project-config/shared/env-example-defaults.js +30 -0
- package/dist/esm/project-config/shared/env-example-defaults.js.map +1 -0
- package/dist/esm/project-config/shared/environment.schemas.d.ts +106 -0
- package/dist/esm/project-config/shared/environment.schemas.d.ts.map +1 -0
- package/dist/esm/project-config/shared/environment.schemas.js +111 -0
- package/dist/esm/project-config/shared/environment.schemas.js.map +1 -0
- package/dist/esm/project-config/shared/infrastructure-defaults.schemas.d.ts +42 -0
- package/dist/esm/project-config/shared/infrastructure-defaults.schemas.d.ts.map +1 -0
- package/dist/esm/project-config/shared/infrastructure-defaults.schemas.js +42 -0
- package/dist/esm/project-config/shared/infrastructure-defaults.schemas.js.map +1 -0
- package/dist/esm/project-config/shared/k8s-utils.d.ts +36 -0
- package/dist/esm/project-config/shared/k8s-utils.d.ts.map +1 -0
- package/dist/esm/project-config/shared/k8s-utils.js +50 -0
- package/dist/esm/project-config/shared/k8s-utils.js.map +1 -0
- package/dist/esm/project-config/shared/platform-services.schemas.d.ts +30 -0
- package/dist/esm/project-config/shared/platform-services.schemas.d.ts.map +1 -0
- package/dist/esm/project-config/shared/platform-services.schemas.js +27 -0
- package/dist/esm/project-config/shared/platform-services.schemas.js.map +1 -0
- package/dist/esm/project-config/shared/service-definitions.schemas.d.ts +42 -0
- package/dist/esm/project-config/shared/service-definitions.schemas.d.ts.map +1 -0
- package/dist/esm/project-config/shared/service-definitions.schemas.js +29 -0
- package/dist/esm/project-config/shared/service-definitions.schemas.js.map +1 -0
- package/dist/esm/project-config/sharing-policy-validation.d.ts +40 -0
- package/dist/esm/project-config/sharing-policy-validation.d.ts.map +1 -0
- package/dist/esm/project-config/sharing-policy-validation.js +143 -0
- package/dist/esm/project-config/sharing-policy-validation.js.map +1 -0
- package/dist/esm/release/framework-release.constants.d.ts +3 -0
- package/dist/esm/release/framework-release.constants.d.ts.map +1 -0
- package/dist/esm/release/framework-release.constants.js +3 -0
- package/dist/esm/release/framework-release.constants.js.map +1 -0
- package/dist/esm/runtime-bridge/platform-runtime-bridge.contracts.d.ts +23 -0
- package/dist/esm/runtime-bridge/platform-runtime-bridge.contracts.d.ts.map +1 -0
- package/dist/esm/runtime-bridge/platform-runtime-bridge.contracts.js +13 -0
- package/dist/esm/runtime-bridge/platform-runtime-bridge.contracts.js.map +1 -0
- package/dist/esm/schemas/framework-info.schemas.d.ts +8 -0
- package/dist/esm/schemas/framework-info.schemas.d.ts.map +1 -0
- package/dist/esm/schemas/framework-info.schemas.js +8 -0
- package/dist/esm/schemas/framework-info.schemas.js.map +1 -0
- package/dist/esm/schemas/framework-secrets.schemas.d.ts +22 -0
- package/dist/esm/schemas/framework-secrets.schemas.d.ts.map +1 -0
- package/dist/esm/schemas/framework-secrets.schemas.js +14 -0
- package/dist/esm/schemas/framework-secrets.schemas.js.map +1 -0
- package/dist/esm/schemas/platform-application-config.schemas.d.ts +20 -0
- package/dist/esm/schemas/platform-application-config.schemas.d.ts.map +1 -0
- package/dist/esm/schemas/platform-application-config.schemas.js +19 -0
- package/dist/esm/schemas/platform-application-config.schemas.js.map +1 -0
- package/dist/esm/schemas/platform-application-secrets.schemas.d.ts +54 -0
- package/dist/esm/schemas/platform-application-secrets.schemas.d.ts.map +1 -0
- package/dist/esm/schemas/platform-application-secrets.schemas.js +67 -0
- package/dist/esm/schemas/platform-application-secrets.schemas.js.map +1 -0
- package/dist/esm/schemas/platform-config.schemas.d.ts +66 -0
- package/dist/esm/schemas/platform-config.schemas.d.ts.map +1 -0
- package/dist/esm/schemas/platform-config.schemas.js +28 -0
- package/dist/esm/schemas/platform-config.schemas.js.map +1 -0
- package/dist/esm/workspace-scope/index.d.ts +3 -0
- package/dist/esm/workspace-scope/index.d.ts.map +1 -0
- package/dist/esm/workspace-scope/index.js +3 -0
- package/dist/esm/workspace-scope/index.js.map +1 -0
- package/dist/esm/workspace-scope/workspace-scope-detector.d.ts +15 -0
- package/dist/esm/workspace-scope/workspace-scope-detector.d.ts.map +1 -0
- package/dist/esm/workspace-scope/workspace-scope-detector.js +87 -0
- package/dist/esm/workspace-scope/workspace-scope-detector.js.map +1 -0
- package/dist/esm/workspace-scope/workspace-scope.schemas.d.ts +118 -0
- package/dist/esm/workspace-scope/workspace-scope.schemas.d.ts.map +1 -0
- package/dist/esm/workspace-scope/workspace-scope.schemas.js +157 -0
- package/dist/esm/workspace-scope/workspace-scope.schemas.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/package.json +52 -0
- package/src/bootstrap/application-backend-env.contracts.ts +17 -0
- package/src/bootstrap/bootstrap-planner.ts +46 -0
- package/src/bootstrap/bootstrap.contracts.ts +251 -0
- package/src/bootstrap/bootstrap.schemas.ts +164 -0
- package/src/bootstrap/platform-runtime-env.contracts.ts +99 -0
- package/src/bootstrap/runtime-topology.contracts.ts +102 -0
- package/src/credentials/credential-generator.service.ts +39 -0
- package/src/index.ts +16 -0
- package/src/project-config/__tests__/application-modules.utils.test.ts +53 -0
- package/src/project-config/__tests__/define-framework-config.test.ts +43 -0
- package/src/project-config/__tests__/define-saas-config.test.ts +210 -0
- package/src/project-config/__tests__/loader.test.ts +100 -0
- package/src/project-config/define-framework-config.ts +44 -0
- package/src/project-config/define-infra-config.ts +168 -0
- package/src/project-config/define-minion-config.ts +27 -0
- package/src/project-config/define-platform-config.ts +28 -0
- package/src/project-config/define-platform-env-config.ts +59 -0
- package/src/project-config/define-project-config.ts +63 -0
- package/src/project-config/define-saas-config.ts +171 -0
- package/src/project-config/define-sharing-policy.ts +36 -0
- package/src/project-config/define-worker-config.ts +27 -0
- package/src/project-config/index.ts +23 -0
- package/src/project-config/loader.ts +220 -0
- package/src/project-config/shared/application-modules.schemas.ts +12 -0
- package/src/project-config/shared/application-modules.utils.ts +65 -0
- package/src/project-config/shared/backing-services.schemas.ts +59 -0
- package/src/project-config/shared/data-services.schemas.ts +58 -0
- package/src/project-config/shared/env-example-defaults.ts +50 -0
- package/src/project-config/shared/environment.schemas.ts +136 -0
- package/src/project-config/shared/infrastructure-defaults.schemas.ts +47 -0
- package/src/project-config/shared/k8s-utils.ts +56 -0
- package/src/project-config/shared/platform-services.schemas.ts +33 -0
- package/src/project-config/shared/service-definitions.schemas.ts +38 -0
- package/src/project-config/sharing-policy-validation.ts +159 -0
- package/src/release/framework-release.constants.ts +2 -0
- package/src/schemas/__tests__/platform-config.schemas.test.ts +90 -0
- package/src/schemas/framework-info.schemas.ts +13 -0
- package/src/schemas/framework-secrets.schemas.ts +19 -0
- package/src/schemas/platform-application-config.schemas.ts +25 -0
- package/src/schemas/platform-application-secrets.schemas.ts +78 -0
- package/src/schemas/platform-config.schemas.ts +45 -0
- package/src/workspace-scope/index.ts +2 -0
- package/src/workspace-scope/workspace-scope-detector.ts +98 -0
- package/src/workspace-scope/workspace-scope.schemas.ts +224 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { WorkerRuntimeSchema, ResourceLimitsSchema, DataAccessSchema } from './shared/service-definitions.schemas';
|
|
3
|
+
|
|
4
|
+
export const WildoMinionConfigSchema = z.object({
|
|
5
|
+
version: z.number().int().positive().default(1),
|
|
6
|
+
name: z.string().min(1),
|
|
7
|
+
displayName: z.string().min(1),
|
|
8
|
+
description: z.string().optional(),
|
|
9
|
+
runtime: WorkerRuntimeSchema,
|
|
10
|
+
/** Cron expression for scheduling (e.g. every 6 hours) */
|
|
11
|
+
schedule: z.string().min(1),
|
|
12
|
+
resources: ResourceLimitsSchema.optional(),
|
|
13
|
+
providers: z.record(z.string(), z.object({
|
|
14
|
+
required: z.boolean().default(true),
|
|
15
|
+
})).optional(),
|
|
16
|
+
dataAccess: DataAccessSchema.optional(),
|
|
17
|
+
});
|
|
18
|
+
export type WildoMinionConfig = z.infer<typeof WildoMinionConfigSchema>;
|
|
19
|
+
export type WildoMinionConfigInput = z.input<typeof WildoMinionConfigSchema>;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Define a minion (scheduled task / cron agent) configuration.
|
|
23
|
+
* Minions run on a schedule and can access data services and providers.
|
|
24
|
+
*/
|
|
25
|
+
export function defineMinionConfig(config: WildoMinionConfigInput): WildoMinionConfig {
|
|
26
|
+
return WildoMinionConfigSchema.parse(config);
|
|
27
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BackingServicesDeclarationSchema } from './shared/backing-services.schemas';
|
|
3
|
+
import { PlatformServicesDeclarationSchema } from './shared/platform-services.schemas';
|
|
4
|
+
|
|
5
|
+
export const WildoAuthConfigSchema = z.object({
|
|
6
|
+
jwtAlgorithm: z.enum(['RS256', 'RS384', 'RS512', 'ES256', 'ES384', 'ES512']).default('RS256'),
|
|
7
|
+
accessTokenExpirationMinutes: z.number().int().positive().default(60),
|
|
8
|
+
refreshTokenExpirationDays: z.number().int().positive().default(30),
|
|
9
|
+
});
|
|
10
|
+
export type WildoAuthConfig = z.infer<typeof WildoAuthConfigSchema>;
|
|
11
|
+
export type WildoAuthConfigInput = z.input<typeof WildoAuthConfigSchema>;
|
|
12
|
+
|
|
13
|
+
export const WildoPlatformConfigSchema = z.object({
|
|
14
|
+
version: z.number().int().positive().default(1),
|
|
15
|
+
platformServices: PlatformServicesDeclarationSchema,
|
|
16
|
+
backingServices: BackingServicesDeclarationSchema,
|
|
17
|
+
auth: WildoAuthConfigSchema,
|
|
18
|
+
});
|
|
19
|
+
export type WildoPlatformConfig = z.infer<typeof WildoPlatformConfigSchema>;
|
|
20
|
+
export type WildoPlatformConfigInput = z.input<typeof WildoPlatformConfigSchema>;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Define the base platform configuration (environment-independent).
|
|
24
|
+
* Declares which platform services and backing services are available.
|
|
25
|
+
*/
|
|
26
|
+
export function definePlatformConfig(config: WildoPlatformConfigInput): WildoPlatformConfig {
|
|
27
|
+
return WildoPlatformConfigSchema.parse(config);
|
|
28
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { RuntimeEnvironment } from '@wildo-ai/saas-models';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { BackingServicesEnvConfigSchema } from './shared/backing-services.schemas';
|
|
4
|
+
import {
|
|
5
|
+
WildoDeploymentRuntime,
|
|
6
|
+
WildoEnvironment,
|
|
7
|
+
WildoEnvironmentIdSchema,
|
|
8
|
+
WildoKubernetesConfigSchema,
|
|
9
|
+
WildoLocationType,
|
|
10
|
+
WildoLoggingConfigSchema,
|
|
11
|
+
WildoRemoteProviderSchema,
|
|
12
|
+
isLocalEnvironmentId,
|
|
13
|
+
} from './shared/environment.schemas';
|
|
14
|
+
|
|
15
|
+
export const WildoPlatformEnvConfigSchema = z.object({
|
|
16
|
+
environment: WildoEnvironmentIdSchema,
|
|
17
|
+
locationType: z.enum(WildoLocationType).optional(),
|
|
18
|
+
runtimeEnvironment: z.nativeEnum(RuntimeEnvironment).optional(),
|
|
19
|
+
runtime: z.enum(WildoDeploymentRuntime),
|
|
20
|
+
kubernetes: WildoKubernetesConfigSchema.optional(),
|
|
21
|
+
remoteProvider: WildoRemoteProviderSchema.optional(),
|
|
22
|
+
backingServices: BackingServicesEnvConfigSchema,
|
|
23
|
+
logging: WildoLoggingConfigSchema.optional(),
|
|
24
|
+
}).superRefine((config, ctx) => {
|
|
25
|
+
if (isLocalEnvironmentId(config.environment) && config.locationType === WildoLocationType.REMOTE) {
|
|
26
|
+
ctx.addIssue({
|
|
27
|
+
code: z.ZodIssueCode.custom,
|
|
28
|
+
path: ['locationType'],
|
|
29
|
+
message: `"${WildoEnvironment.LOCAL}" environment cannot use remote locationType`,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (!isLocalEnvironmentId(config.environment) && config.locationType === WildoLocationType.LOCAL) {
|
|
34
|
+
ctx.addIssue({
|
|
35
|
+
code: z.ZodIssueCode.custom,
|
|
36
|
+
path: ['locationType'],
|
|
37
|
+
message: 'Only the "local" environment id can use local locationType',
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (!isLocalEnvironmentId(config.environment) && !config.runtimeEnvironment) {
|
|
42
|
+
ctx.addIssue({
|
|
43
|
+
code: z.ZodIssueCode.custom,
|
|
44
|
+
path: ['runtimeEnvironment'],
|
|
45
|
+
message: 'runtimeEnvironment is required for remote environments',
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
export type WildoPlatformEnvConfig = z.infer<typeof WildoPlatformEnvConfigSchema>;
|
|
50
|
+
export type WildoPlatformEnvConfigInput = z.input<typeof WildoPlatformEnvConfigSchema>;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Define a per-environment platform configuration.
|
|
54
|
+
* Specifies the environment id, runtime semantics, backing service sources,
|
|
55
|
+
* and environment-specific overrides.
|
|
56
|
+
*/
|
|
57
|
+
export function definePlatformEnvConfig(config: WildoPlatformEnvConfigInput): WildoPlatformEnvConfig {
|
|
58
|
+
return WildoPlatformEnvConfigSchema.parse(config);
|
|
59
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { isAbsolute, normalize } from 'path';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
const ProjectRelativePathSchema = z.string().min(1).superRefine((value, ctx) => {
|
|
5
|
+
const normalizedValue = normalize(value);
|
|
6
|
+
if (isAbsolute(value)) {
|
|
7
|
+
ctx.addIssue({
|
|
8
|
+
code: z.ZodIssueCode.custom,
|
|
9
|
+
message: 'platformPath must stay relative to the project root',
|
|
10
|
+
});
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (normalizedValue === '.' || normalizedValue === '') {
|
|
15
|
+
ctx.addIssue({
|
|
16
|
+
code: z.ZodIssueCode.custom,
|
|
17
|
+
message: 'platformPath must point to a subdirectory such as ./wildo-platform or ../shared-platform',
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const ProjectAppKeySchema = z
|
|
23
|
+
.string()
|
|
24
|
+
.min(1)
|
|
25
|
+
.regex(/^[a-z0-9-]+$/, 'app keys must be lowercase alphanumeric with hyphens');
|
|
26
|
+
|
|
27
|
+
export const WildoProjectConfigSchema = z.object({
|
|
28
|
+
version: z.number().int().positive().default(1),
|
|
29
|
+
name: z.string().min(1),
|
|
30
|
+
projectSlug: z.string().min(1).regex(/^[a-z0-9-]+$/, 'projectSlug must be lowercase alphanumeric with hyphens'),
|
|
31
|
+
displayName: z.string().min(1),
|
|
32
|
+
platformPath: ProjectRelativePathSchema,
|
|
33
|
+
apps: z.record(ProjectAppKeySchema, z.object({
|
|
34
|
+
path: z.string().min(1),
|
|
35
|
+
type: z.enum(['saas']),
|
|
36
|
+
})),
|
|
37
|
+
});
|
|
38
|
+
export type WildoProjectConfig = z.infer<typeof WildoProjectConfigSchema>;
|
|
39
|
+
export type WildoProjectConfigInput = z.input<typeof WildoProjectConfigSchema>;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Define a Wildo project configuration.
|
|
43
|
+
* Provides full IDE autocompletion and runtime Zod validation.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* import { defineProjectConfig } from '@wildo-ai/platform-config-lib';
|
|
48
|
+
*
|
|
49
|
+
* export default defineProjectConfig({
|
|
50
|
+
* version: 1,
|
|
51
|
+
* name: 'wonder-todos-project',
|
|
52
|
+
* projectSlug: 'wonder-todos',
|
|
53
|
+
* displayName: 'Wonder Todos Project',
|
|
54
|
+
* platformPath: './wildo-platform',
|
|
55
|
+
* apps: {
|
|
56
|
+
* 'wonder-todos': { path: './wonder-todos', type: 'saas' },
|
|
57
|
+
* },
|
|
58
|
+
* });
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export function defineProjectConfig(config: WildoProjectConfigInput): WildoProjectConfig {
|
|
62
|
+
return WildoProjectConfigSchema.parse(config);
|
|
63
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CLIRuntime_ConfigurationSchema,
|
|
3
|
+
ExternalProvider_ExchangeProtocol_Configuration_BaseSchema,
|
|
4
|
+
ExternalProvider_ExchangeProtocol_Kind,
|
|
5
|
+
} from '@wildo-ai/external-connectors-models';
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import { EngineCapability } from '@wildo-ai/saas-models';
|
|
8
|
+
import { AppDataServicesSchema } from './shared/data-services.schemas';
|
|
9
|
+
import { ApplicationModulesSchema } from './shared/application-modules.schemas';
|
|
10
|
+
import { AppServiceDefinitionSchema, AppRefSchema } from './shared/service-definitions.schemas';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Capability binding in the app config.
|
|
14
|
+
* Declares whether a capability is enabled, its lifecycle scope,
|
|
15
|
+
* and which provider(s) back it.
|
|
16
|
+
*
|
|
17
|
+
* Provider refs are validated at CLI evaluation time against the
|
|
18
|
+
* external-connectors catalog to ensure the provider actually supports
|
|
19
|
+
* the declared capability.
|
|
20
|
+
*
|
|
21
|
+
* - `runtime` = app needs this at runtime (mandatory for production)
|
|
22
|
+
* - `tooling` = dev tooling needs this (companion, CLI, agents)
|
|
23
|
+
* - `servicesRestrictions` = per-service provider overrides
|
|
24
|
+
* (omitted services get the default; empty array = unavailable for that service)
|
|
25
|
+
*/
|
|
26
|
+
export const CapabilityBindingSchema = z.object({
|
|
27
|
+
enabled: z.boolean(),
|
|
28
|
+
/** App needs this capability at runtime (mandatory for production) */
|
|
29
|
+
runtime: z.boolean().default(false),
|
|
30
|
+
/** Dev tooling needs this capability (companion, CLI, agents) */
|
|
31
|
+
tooling: z.boolean().default(false),
|
|
32
|
+
/** Single provider ref (for SINGLE mode capabilities) */
|
|
33
|
+
provider: z.string().min(1).optional(),
|
|
34
|
+
/** Multiple provider refs (for MULTIPLE mode capabilities like AI) */
|
|
35
|
+
providers: z.array(z.string().min(1)).optional(),
|
|
36
|
+
/** Whether this capability is required for the app to function */
|
|
37
|
+
required: z.boolean().optional(),
|
|
38
|
+
/**
|
|
39
|
+
* Per-service provider restrictions.
|
|
40
|
+
* Keys are service identifiers (e.g., 'minions.marketingScrapper').
|
|
41
|
+
* Values are arrays of allowed provider refs for that service.
|
|
42
|
+
* Omitted services inherit the default `provider`/`providers` list.
|
|
43
|
+
* Empty array = capability unavailable for that service.
|
|
44
|
+
*/
|
|
45
|
+
servicesRestrictions: z.record(z.string(), z.array(z.string().min(1))).optional(),
|
|
46
|
+
});
|
|
47
|
+
export type CapabilityBinding = z.infer<typeof CapabilityBindingSchema>;
|
|
48
|
+
export type CapabilityBindingInput = z.input<typeof CapabilityBindingSchema>;
|
|
49
|
+
|
|
50
|
+
export const ExternalProvidersConfigurationsSchema = z.record(
|
|
51
|
+
z.string(),
|
|
52
|
+
z.partialRecord(
|
|
53
|
+
z.enum(ExternalProvider_ExchangeProtocol_Kind),
|
|
54
|
+
z.union([
|
|
55
|
+
CLIRuntime_ConfigurationSchema,
|
|
56
|
+
ExternalProvider_ExchangeProtocol_Configuration_BaseSchema,
|
|
57
|
+
]),
|
|
58
|
+
).optional(),
|
|
59
|
+
).optional().default(() => ({}));
|
|
60
|
+
export type ExternalProvidersConfigurations = z.infer<typeof ExternalProvidersConfigurationsSchema>;
|
|
61
|
+
export type ExternalProvidersConfigurationsInput = z.input<typeof ExternalProvidersConfigurationsSchema>;
|
|
62
|
+
|
|
63
|
+
const AppFeaturesSchema = z.object({
|
|
64
|
+
organizations: z.boolean().default(false),
|
|
65
|
+
billing: z.boolean().default(false),
|
|
66
|
+
multiLanguage: z.boolean().default(false),
|
|
67
|
+
compliance: z.object({
|
|
68
|
+
auditTrail: z.boolean().default(false),
|
|
69
|
+
gdpr: z.boolean().default(false),
|
|
70
|
+
}).optional(),
|
|
71
|
+
});
|
|
72
|
+
export type AppFeatures = z.infer<typeof AppFeaturesSchema>;
|
|
73
|
+
|
|
74
|
+
const BootstrapFirstAdminSeedSchema = z.object({
|
|
75
|
+
userTypes: z.array(z.string().min(1)).min(1),
|
|
76
|
+
});
|
|
77
|
+
export type BootstrapFirstAdminSeed = z.infer<typeof BootstrapFirstAdminSeedSchema>;
|
|
78
|
+
|
|
79
|
+
const AppBootstrapSchema = z.object({
|
|
80
|
+
firstAdmin: BootstrapFirstAdminSeedSchema.optional(),
|
|
81
|
+
});
|
|
82
|
+
export type AppBootstrap = z.infer<typeof AppBootstrapSchema>;
|
|
83
|
+
|
|
84
|
+
export const WildoSaasConfigSchema = z.object({
|
|
85
|
+
version: z.number().int().positive().default(1),
|
|
86
|
+
name: z.string().min(1),
|
|
87
|
+
slug: z.string().min(1).regex(/^[a-z0-9-]+$/, 'slug must be lowercase alphanumeric with hyphens'),
|
|
88
|
+
displayName: z.string().min(1),
|
|
89
|
+
description: z.string().optional(),
|
|
90
|
+
type: z.literal('saas'),
|
|
91
|
+
|
|
92
|
+
services: z.record(z.string(), AppServiceDefinitionSchema),
|
|
93
|
+
modules: ApplicationModulesSchema,
|
|
94
|
+
minions: z.record(z.string(), AppRefSchema).optional(),
|
|
95
|
+
workers: z.record(z.string(), AppRefSchema).optional(),
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Capabilities the app requires, keyed by EngineCapability enum.
|
|
99
|
+
* Each entry declares whether the capability is enabled and which provider(s) back it.
|
|
100
|
+
*/
|
|
101
|
+
capabilities: z.partialRecord(
|
|
102
|
+
z.enum(EngineCapability),
|
|
103
|
+
CapabilityBindingSchema,
|
|
104
|
+
).optional(),
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* App-authored, non-secret provider runtime policy.
|
|
108
|
+
* Secret values are never authored here and stay env/K8s-delivered.
|
|
109
|
+
*/
|
|
110
|
+
externalProvidersConfigurations: ExternalProvidersConfigurationsSchema,
|
|
111
|
+
|
|
112
|
+
features: AppFeaturesSchema,
|
|
113
|
+
bootstrap: AppBootstrapSchema.optional(),
|
|
114
|
+
dataServices: AppDataServicesSchema,
|
|
115
|
+
}).superRefine((config, ctx) => {
|
|
116
|
+
const availableServiceKeys = new Set(Object.keys(config.services));
|
|
117
|
+
|
|
118
|
+
for (const [moduleId, moduleBinding] of Object.entries(config.modules ?? {})) {
|
|
119
|
+
for (const serviceKey of moduleBinding.services) {
|
|
120
|
+
if (availableServiceKeys.has(serviceKey)) {
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
ctx.addIssue({
|
|
125
|
+
code: z.ZodIssueCode.custom,
|
|
126
|
+
path: ['modules', moduleId, 'services'],
|
|
127
|
+
message: `Module "${moduleId}" references unknown service "${serviceKey}".`,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
export type WildoSaasConfig = z.infer<typeof WildoSaasConfigSchema>;
|
|
133
|
+
export type WildoSaasConfigInput = z.input<typeof WildoSaasConfigSchema>;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Define a SaaS application configuration.
|
|
137
|
+
* Provides full IDE autocompletion for capabilities (via EngineCapability enum),
|
|
138
|
+
* features, services, and data services.
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```ts
|
|
142
|
+
* import { defineSaasConfig } from '@wildo-ai/platform-config-lib';
|
|
143
|
+
* import { EngineCapability } from '@wildo-ai/saas-models';
|
|
144
|
+
*
|
|
145
|
+
* export default defineSaasConfig({
|
|
146
|
+
* version: 1,
|
|
147
|
+
* name: 'wonder-todos',
|
|
148
|
+
* slug: 'wonder-todos',
|
|
149
|
+
* displayName: 'Wonder Todos',
|
|
150
|
+
* type: 'saas',
|
|
151
|
+
* capabilities: {
|
|
152
|
+
* [EngineCapability.EMAIL_TRANSACTIONAL]: {
|
|
153
|
+
* enabled: true,
|
|
154
|
+
* runtime: true, // optional, defaults to false
|
|
155
|
+
* provider: 'resend',
|
|
156
|
+
* },
|
|
157
|
+
* [EngineCapability.SMS]: { enabled: false },
|
|
158
|
+
* [EngineCapability.AI_LLM]: {
|
|
159
|
+
* enabled: true,
|
|
160
|
+
* runtime: true,
|
|
161
|
+
* tooling: true, // optional, defaults to false
|
|
162
|
+
* providers: ['openai', 'anthropic'],
|
|
163
|
+
* },
|
|
164
|
+
* },
|
|
165
|
+
* // ...
|
|
166
|
+
* });
|
|
167
|
+
* ```
|
|
168
|
+
*/
|
|
169
|
+
export function defineSaasConfig(config: WildoSaasConfigInput): WildoSaasConfig {
|
|
170
|
+
return WildoSaasConfigSchema.parse(config);
|
|
171
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
const SharingScope = z.enum(['all-apps', 'named-apps', 'none']);
|
|
4
|
+
|
|
5
|
+
const SecretSharingRuleSchema = z.object({
|
|
6
|
+
scope: SharingScope,
|
|
7
|
+
mode: z.string().optional(),
|
|
8
|
+
description: z.string().optional(),
|
|
9
|
+
defaults: z.array(z.string()).optional(),
|
|
10
|
+
perApp: z.record(z.string(), z.object({
|
|
11
|
+
include: z.array(z.string()).optional(),
|
|
12
|
+
exclude: z.array(z.string()).optional(),
|
|
13
|
+
})).optional(),
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
const ConfigSharingRuleSchema = z.object({
|
|
17
|
+
scope: SharingScope,
|
|
18
|
+
overridable: z.boolean().optional(),
|
|
19
|
+
description: z.string().optional(),
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export const WildoSharingPolicySchema = z.object({
|
|
23
|
+
version: z.number().int().positive().default(1),
|
|
24
|
+
secrets: z.record(z.string(), SecretSharingRuleSchema),
|
|
25
|
+
config: z.record(z.string(), ConfigSharingRuleSchema),
|
|
26
|
+
});
|
|
27
|
+
export type WildoSharingPolicy = z.infer<typeof WildoSharingPolicySchema>;
|
|
28
|
+
export type WildoSharingPolicyInput = z.input<typeof WildoSharingPolicySchema>;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Define a per-environment sharing policy.
|
|
32
|
+
* Controls which secrets and config are shared across apps, and with what restrictions.
|
|
33
|
+
*/
|
|
34
|
+
export function defineSharingPolicy(config: WildoSharingPolicyInput): WildoSharingPolicy {
|
|
35
|
+
return WildoSharingPolicySchema.parse(config);
|
|
36
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { WorkerRuntimeSchema, ResourceLimitsSchema, DataAccessSchema } from './shared/service-definitions.schemas';
|
|
3
|
+
|
|
4
|
+
export const WildoWorkerConfigSchema = z.object({
|
|
5
|
+
version: z.number().int().positive().default(1),
|
|
6
|
+
name: z.string().min(1),
|
|
7
|
+
displayName: z.string().min(1),
|
|
8
|
+
description: z.string().optional(),
|
|
9
|
+
runtime: WorkerRuntimeSchema,
|
|
10
|
+
queue: z.object({
|
|
11
|
+
consumes: z.array(z.string().min(1)),
|
|
12
|
+
concurrency: z.number().int().positive().optional(),
|
|
13
|
+
prefetchCount: z.number().int().positive().optional(),
|
|
14
|
+
}),
|
|
15
|
+
resources: ResourceLimitsSchema.optional(),
|
|
16
|
+
dataAccess: DataAccessSchema.optional(),
|
|
17
|
+
});
|
|
18
|
+
export type WildoWorkerConfig = z.infer<typeof WildoWorkerConfigSchema>;
|
|
19
|
+
export type WildoWorkerConfigInput = z.input<typeof WildoWorkerConfigSchema>;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Define a worker service configuration.
|
|
23
|
+
* Workers are long-running queue consumers that process background tasks.
|
|
24
|
+
*/
|
|
25
|
+
export function defineWorkerConfig(config: WildoWorkerConfigInput): WildoWorkerConfig {
|
|
26
|
+
return WildoWorkerConfigSchema.parse(config);
|
|
27
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export * from './shared/backing-services.schemas';
|
|
2
|
+
export * from './shared/platform-services.schemas';
|
|
3
|
+
export * from './shared/data-services.schemas';
|
|
4
|
+
export * from './shared/application-modules.schemas';
|
|
5
|
+
export * from './shared/application-modules.utils';
|
|
6
|
+
export * from './shared/service-definitions.schemas';
|
|
7
|
+
export * from './shared/environment.schemas';
|
|
8
|
+
export * from './shared/infrastructure-defaults.schemas';
|
|
9
|
+
export * from './shared/k8s-utils';
|
|
10
|
+
export * from './shared/env-example-defaults';
|
|
11
|
+
|
|
12
|
+
export * from './loader';
|
|
13
|
+
|
|
14
|
+
export * from './define-project-config';
|
|
15
|
+
export * from './define-framework-config';
|
|
16
|
+
export * from './define-platform-config';
|
|
17
|
+
export * from './define-platform-env-config';
|
|
18
|
+
export * from './define-sharing-policy';
|
|
19
|
+
export * from './define-saas-config';
|
|
20
|
+
export * from './define-infra-config';
|
|
21
|
+
export * from './define-worker-config';
|
|
22
|
+
export * from './define-minion-config';
|
|
23
|
+
export * from './sharing-policy-validation';
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { createHash } from 'crypto';
|
|
2
|
+
import { existsSync, mkdirSync, readFileSync } from 'fs';
|
|
3
|
+
import { dirname, join, resolve } from 'path';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
5
|
+
import { createJiti } from 'jiti';
|
|
6
|
+
import { WORKSPACE_CONFIG_NAMES } from '../workspace-scope/workspace-scope.schemas';
|
|
7
|
+
import type { WildoFrameworkConfig } from './define-framework-config';
|
|
8
|
+
import type { WildoSaasConfig } from './define-saas-config';
|
|
9
|
+
import type { WildoSharingPolicy } from './define-sharing-policy';
|
|
10
|
+
import {
|
|
11
|
+
ConfigArtifactsZone,
|
|
12
|
+
resolveConfigArtifactsBaseDir,
|
|
13
|
+
type ConfigArtifactsLocationOptions,
|
|
14
|
+
} from '../workspace-scope/workspace-scope.schemas';
|
|
15
|
+
|
|
16
|
+
export interface LoadConfigOptions {
|
|
17
|
+
/**
|
|
18
|
+
* Optional explicit owner zone for generated loader artifacts.
|
|
19
|
+
* Use this when the authored config file lives outside its semantic runtime
|
|
20
|
+
* owner, such as project-owned platform configs stored in a sibling
|
|
21
|
+
* `platformPath`.
|
|
22
|
+
*/
|
|
23
|
+
artifactLocation?: ConfigArtifactsLocationOptions;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const PACKAGE_COMPANION_SUBPATH = './companion';
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Load and evaluate a TypeScript config file via jiti.
|
|
30
|
+
* The file must `export default defineXxxConfig({...})`.
|
|
31
|
+
* Zod validation runs inside the defineConfig helper at evaluation time,
|
|
32
|
+
* so the returned object is guaranteed valid.
|
|
33
|
+
*
|
|
34
|
+
* @param filePath - Absolute path to the `.ts` config file
|
|
35
|
+
* @returns The validated config object (the default export)
|
|
36
|
+
* @throws If the file doesn't exist, has syntax errors, or Zod validation fails
|
|
37
|
+
*/
|
|
38
|
+
export async function loadConfig<T>(filePath: string, options?: LoadConfigOptions): Promise<T> {
|
|
39
|
+
const absolutePath = resolve(filePath);
|
|
40
|
+
if (!existsSync(absolutePath)) {
|
|
41
|
+
throw new Error(`Config file not found: ${absolutePath}`);
|
|
42
|
+
}
|
|
43
|
+
const cacheBaseDir = options?.artifactLocation
|
|
44
|
+
? resolveConfigArtifactsBaseDir(options.artifactLocation)
|
|
45
|
+
: resolveConfigArtifactsBaseDir(absolutePath);
|
|
46
|
+
const cacheDir = join(cacheBaseDir, createHash('sha1').update(absolutePath).digest('hex'));
|
|
47
|
+
mkdirSync(cacheDir, { recursive: true });
|
|
48
|
+
|
|
49
|
+
const currentModuleDirectory = dirname(fileURLToPath(import.meta.url));
|
|
50
|
+
const platformConfigLibEntry = resolvePlatformConfigLibEntry(currentModuleDirectory);
|
|
51
|
+
const workspaceRoot = resolveLoaderWorkspaceRoot(currentModuleDirectory);
|
|
52
|
+
|
|
53
|
+
const jiti = createJiti(import.meta.url, {
|
|
54
|
+
fsCache: cacheDir,
|
|
55
|
+
alias: {
|
|
56
|
+
'@wildo-ai/platform-config-lib': platformConfigLibEntry,
|
|
57
|
+
'~wildo-backend-lib': resolve(workspaceRoot, 'engine/saas-backend-lib/src'),
|
|
58
|
+
'~wildo-connectors': resolve(workspaceRoot, 'engine/external-connectors/src'),
|
|
59
|
+
'~wildo-connectors-models': resolve(workspaceRoot, 'engine/external-connectors-models/src'),
|
|
60
|
+
'~wildo-models': resolve(workspaceRoot, 'engine/saas-models/src'),
|
|
61
|
+
'~wildo-zod': resolve(workspaceRoot, 'engine/zod-decorators/src'),
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const module = await jiti.import(absolutePath) as { default: T };
|
|
66
|
+
if (!module.default) {
|
|
67
|
+
throw new Error(`Config file must use \`export default\`: ${absolutePath}`);
|
|
68
|
+
}
|
|
69
|
+
return module.default;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function resolvePackageCompanionEntryPath(
|
|
73
|
+
packageRoot: string,
|
|
74
|
+
subpath: string = PACKAGE_COMPANION_SUBPATH,
|
|
75
|
+
): string {
|
|
76
|
+
const packageJsonPath = join(packageRoot, 'package.json');
|
|
77
|
+
if (!existsSync(packageJsonPath)) {
|
|
78
|
+
throw new Error(`Missing package.json for companion target at "${packageRoot}".`);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8')) as {
|
|
82
|
+
exports?: Record<string, string | { import?: string; default?: string }>;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const subpathExport = packageJson.exports?.[subpath];
|
|
86
|
+
if (typeof subpathExport === 'string') {
|
|
87
|
+
const exportPath = resolve(packageRoot, subpathExport);
|
|
88
|
+
if (existsSync(exportPath)) {
|
|
89
|
+
return exportPath;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (subpathExport && typeof subpathExport === 'object') {
|
|
94
|
+
const declaredEntryPath = subpathExport.import ?? subpathExport.default;
|
|
95
|
+
if (typeof declaredEntryPath === 'string') {
|
|
96
|
+
const exportPath = resolve(packageRoot, declaredEntryPath);
|
|
97
|
+
if (existsSync(exportPath)) {
|
|
98
|
+
return exportPath;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (subpath === PACKAGE_COMPANION_SUBPATH) {
|
|
104
|
+
const sourceCandidates = [
|
|
105
|
+
join(packageRoot, 'src', 'companion-exports.ts'),
|
|
106
|
+
join(packageRoot, 'src', 'companion-exports.tsx'),
|
|
107
|
+
join(packageRoot, 'src', 'companion-exports.js'),
|
|
108
|
+
join(packageRoot, 'src', 'companion-exports.mjs'),
|
|
109
|
+
];
|
|
110
|
+
|
|
111
|
+
for (const candidate of sourceCandidates) {
|
|
112
|
+
if (existsSync(candidate)) {
|
|
113
|
+
return candidate;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
throw new Error(
|
|
119
|
+
`Could not resolve companion entry for subpath "${subpath}" in package "${packageRoot}".`,
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export async function loadPackageCompanionExport<T>(
|
|
124
|
+
packageRoot: string,
|
|
125
|
+
subpath: string = PACKAGE_COMPANION_SUBPATH,
|
|
126
|
+
options?: LoadConfigOptions,
|
|
127
|
+
): Promise<T> {
|
|
128
|
+
const entryPath = resolvePackageCompanionEntryPath(packageRoot, subpath);
|
|
129
|
+
return loadConfig<T>(entryPath, options);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function resolvePlatformConfigLibEntry(startDirectory: string): string {
|
|
133
|
+
const packageRoot = resolveCurrentPackageRoot(startDirectory);
|
|
134
|
+
const sourceEntry = join(packageRoot, 'src', 'index.ts');
|
|
135
|
+
if (existsSync(sourceEntry)) {
|
|
136
|
+
return sourceEntry;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return join(packageRoot, 'dist', 'esm', 'index.js');
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function resolveCurrentPackageRoot(startDirectory: string): string {
|
|
143
|
+
let currentDirectory = startDirectory;
|
|
144
|
+
|
|
145
|
+
while (true) {
|
|
146
|
+
if (existsSync(join(currentDirectory, 'package.json'))) {
|
|
147
|
+
return currentDirectory;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const parentDirectory = dirname(currentDirectory);
|
|
151
|
+
if (parentDirectory === currentDirectory) {
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
currentDirectory = parentDirectory;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return startDirectory;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function resolveLoaderWorkspaceRoot(startDirectory: string): string {
|
|
161
|
+
let currentDirectory = startDirectory;
|
|
162
|
+
|
|
163
|
+
while (true) {
|
|
164
|
+
if (
|
|
165
|
+
existsSync(join(currentDirectory, 'wildo-framework.info.json'))
|
|
166
|
+
|| existsSync(join(currentDirectory, 'pnpm-workspace.yaml'))
|
|
167
|
+
) {
|
|
168
|
+
return currentDirectory;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const parentDirectory = dirname(currentDirectory);
|
|
172
|
+
if (parentDirectory === currentDirectory) {
|
|
173
|
+
break;
|
|
174
|
+
}
|
|
175
|
+
currentDirectory = parentDirectory;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return resolve(startDirectory, '../../../../..');
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Load a `wildo.saas.config.ts` file.
|
|
183
|
+
* Returns `null` if the file doesn't exist (non-throwing variant for optional loading).
|
|
184
|
+
*/
|
|
185
|
+
export async function loadSaasConfig(filePath: string, options?: LoadConfigOptions): Promise<WildoSaasConfig | null> {
|
|
186
|
+
const absolutePath = resolve(filePath);
|
|
187
|
+
if (!existsSync(absolutePath)) return null;
|
|
188
|
+
return loadConfig<WildoSaasConfig>(absolutePath, options);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Load a `wildo.sharing-policy.{env}.ts` file.
|
|
193
|
+
* Returns `null` if the file doesn't exist (non-throwing variant for optional loading).
|
|
194
|
+
*/
|
|
195
|
+
export async function loadSharingPolicy(filePath: string, options?: LoadConfigOptions): Promise<WildoSharingPolicy | null> {
|
|
196
|
+
const absolutePath = resolve(filePath);
|
|
197
|
+
if (!existsSync(absolutePath)) return null;
|
|
198
|
+
return loadConfig<WildoSharingPolicy>(absolutePath, options);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Load the framework-scoped `wildo.framework.config.ts` file.
|
|
203
|
+
* Returns `null` if the file does not exist.
|
|
204
|
+
*/
|
|
205
|
+
export async function loadFrameworkConfig(
|
|
206
|
+
frameworkRoot: string,
|
|
207
|
+
options?: Omit<LoadConfigOptions, 'artifactLocation'>,
|
|
208
|
+
): Promise<WildoFrameworkConfig | null> {
|
|
209
|
+
const filePath = join(frameworkRoot, WORKSPACE_CONFIG_NAMES.FRAMEWORK_DIR, 'wildo.framework.config.ts');
|
|
210
|
+
const absolutePath = resolve(filePath);
|
|
211
|
+
if (!existsSync(absolutePath)) return null;
|
|
212
|
+
|
|
213
|
+
return loadConfig<WildoFrameworkConfig>(absolutePath, {
|
|
214
|
+
...options,
|
|
215
|
+
artifactLocation: {
|
|
216
|
+
zone: ConfigArtifactsZone.FRAMEWORK,
|
|
217
|
+
ownerRoot: frameworkRoot,
|
|
218
|
+
},
|
|
219
|
+
});
|
|
220
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export const ApplicationModuleBindingSchema = z.object({
|
|
4
|
+
services: z.array(z.string().min(1)).min(1),
|
|
5
|
+
});
|
|
6
|
+
export type ApplicationModuleBinding = z.infer<typeof ApplicationModuleBindingSchema>;
|
|
7
|
+
|
|
8
|
+
export const ApplicationModulesSchema = z.record(
|
|
9
|
+
z.string().min(1),
|
|
10
|
+
ApplicationModuleBindingSchema,
|
|
11
|
+
).optional();
|
|
12
|
+
export type ApplicationModules = z.infer<typeof ApplicationModulesSchema>;
|