@percepta/create 4.1.3 → 4.1.5
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/index.js +1 -1
- package/dist/{register-app-0iB8cN97.js → register-app-DeyAp8hw.js} +51 -46
- package/dist/register-app-DeyAp8hw.js.map +1 -0
- package/package.json +1 -1
- package/templates/infra/os.blueprint.yaml.template +32 -15
- package/templates/monorepo/auth/src/auth.ts +9 -1
- package/templates/webapp/AGENTS.md +2 -2
- package/templates/webapp/README.md +9 -9
- package/templates/webapp/env.example.template +3 -7
- package/templates/webapp/src/config/getEnvConfig.ts +1 -7
- package/templates/webapp/src/instrumentation.ts +13 -0
- package/dist/register-app-0iB8cN97.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1208,7 +1208,7 @@ infra.command("register-os-blueprint").description("Register this customer monor
|
|
|
1208
1208
|
await registerOsBlueprintCommand();
|
|
1209
1209
|
});
|
|
1210
1210
|
infra.command("register-app").description("Register a webapp database in this customer OS blueprint").argument("<app>", "Webapp package name").action(async (appName) => {
|
|
1211
|
-
const { registerAppCommand } = await import("./register-app-
|
|
1211
|
+
const { registerAppCommand } = await import("./register-app-DeyAp8hw.js");
|
|
1212
1212
|
await registerAppCommand(appName);
|
|
1213
1213
|
});
|
|
1214
1214
|
program.command("status").description("Show template sync status for current app").option("--mosaic-template-path <path>", "Path to local mosaic repo checkout").action(async (options) => {
|
|
@@ -9,6 +9,30 @@ import { isMap, isSeq, parseDocument } from "yaml";
|
|
|
9
9
|
//#region src/commands/infra/register-app.ts
|
|
10
10
|
const OS_POSTGRESQL_TERRAFORM_ALIAS = "os-postgresql-terraform";
|
|
11
11
|
const OS_POSTGRESQL_TERRAFORM_SERVICES = new Set(["os-postgresql-terraform-aws", "os-postgresql-terraform-azure"]);
|
|
12
|
+
const OS_BLUEPRINT_INPUT_GROUPS = [
|
|
13
|
+
{
|
|
14
|
+
name: "general",
|
|
15
|
+
displayName: "General",
|
|
16
|
+
description: "Shared OS infrastructure settings."
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: "applications",
|
|
20
|
+
displayName: "Applications",
|
|
21
|
+
description: "Generated OS webapp settings."
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: "aws_postgresql",
|
|
25
|
+
displayName: "AWS PostgreSQL",
|
|
26
|
+
description: "AWS Aurora PostgreSQL settings.",
|
|
27
|
+
condition: "{{ eq EnvironmentProviderType \"aws\" }}"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: "azure_postgresql",
|
|
31
|
+
displayName: "Azure PostgreSQL",
|
|
32
|
+
description: "Azure PostgreSQL Flexible Server settings.",
|
|
33
|
+
condition: "{{ eq EnvironmentProviderType \"azure\" }}"
|
|
34
|
+
}
|
|
35
|
+
];
|
|
12
36
|
async function registerApp(appNameInput, args = {}) {
|
|
13
37
|
const appName = normalizeAppName(appNameInput);
|
|
14
38
|
const monorepoContext = await detectMonorepo(args.cwd ?? process.cwd());
|
|
@@ -113,6 +137,7 @@ function updateBlueprint(blueprintContent, appName, options) {
|
|
|
113
137
|
let changed = false;
|
|
114
138
|
const inputs = spec.get("inputs", true);
|
|
115
139
|
if (!isSeq(inputs)) throw new Error("OS blueprint spec.inputs must be a sequence.");
|
|
140
|
+
changed = ensureInputGroups(document, spec) || changed;
|
|
116
141
|
if (options.appInputs) {
|
|
117
142
|
changed = addAppInput(document, inputs, renderIngressDomainInput()) || changed;
|
|
118
143
|
changed = addAppInput(document, inputs, renderBetterAuthSecretInput(appName)) || changed;
|
|
@@ -130,6 +155,21 @@ function updateBlueprint(blueprintContent, appName, options) {
|
|
|
130
155
|
}
|
|
131
156
|
return changed ? document.toString() : blueprintContent;
|
|
132
157
|
}
|
|
158
|
+
function ensureInputGroups(document, spec) {
|
|
159
|
+
let changed = false;
|
|
160
|
+
const inputGroups = spec.get("inputGroups", true);
|
|
161
|
+
if (inputGroups == null) {
|
|
162
|
+
spec.set("inputGroups", document.createNode(OS_BLUEPRINT_INPUT_GROUPS));
|
|
163
|
+
return true;
|
|
164
|
+
}
|
|
165
|
+
if (!isSeq(inputGroups)) throw new Error("OS blueprint spec.inputGroups must be a sequence.");
|
|
166
|
+
for (const group of OS_BLUEPRINT_INPUT_GROUPS) {
|
|
167
|
+
if (inputGroups.items.some((item) => isMap(item) && item.get("name") === group.name)) continue;
|
|
168
|
+
inputGroups.add(document.createNode(group));
|
|
169
|
+
changed = true;
|
|
170
|
+
}
|
|
171
|
+
return changed;
|
|
172
|
+
}
|
|
133
173
|
function ensureOsPostgresqlInstallationAlias(installations) {
|
|
134
174
|
let changed = false;
|
|
135
175
|
for (const installation of installations.items) {
|
|
@@ -172,7 +212,7 @@ function renderIngressDomainInput() {
|
|
|
172
212
|
return {
|
|
173
213
|
name: ingressDomainInputName(),
|
|
174
214
|
type: "string",
|
|
175
|
-
group: "
|
|
215
|
+
group: "applications",
|
|
176
216
|
displayName: "Ingress Domain",
|
|
177
217
|
description: "Shared ingress domain for generated OS webapps.",
|
|
178
218
|
default: "{{ default \"example.local\" .ryvn.env.state.public_domain.name }}"
|
|
@@ -183,7 +223,7 @@ function renderBetterAuthSecretInput(appName) {
|
|
|
183
223
|
name: betterAuthSecretInputName(appName),
|
|
184
224
|
type: "string",
|
|
185
225
|
isSecret: true,
|
|
186
|
-
group: "
|
|
226
|
+
group: "applications",
|
|
187
227
|
displayName: `${toTitleCase(appName)} Better Auth Secret`,
|
|
188
228
|
description: `Generated Better Auth signing secret for ${appName}.`,
|
|
189
229
|
hidden: true,
|
|
@@ -198,7 +238,7 @@ function renderInngestEventKeyInput() {
|
|
|
198
238
|
name: inngestEventKeyInputName(),
|
|
199
239
|
type: "string",
|
|
200
240
|
isSecret: true,
|
|
201
|
-
group: "
|
|
241
|
+
group: "applications",
|
|
202
242
|
displayName: "Inngest Event Key",
|
|
203
243
|
description: "Shared Inngest event key for generated OS webapps. Leave unset when the target Inngest installation does not require one."
|
|
204
244
|
};
|
|
@@ -208,7 +248,7 @@ function renderInngestSigningKeyInput() {
|
|
|
208
248
|
name: inngestSigningKeyInputName(),
|
|
209
249
|
type: "string",
|
|
210
250
|
isSecret: true,
|
|
211
|
-
group: "
|
|
251
|
+
group: "applications",
|
|
212
252
|
displayName: "Inngest Signing Key",
|
|
213
253
|
description: "Shared Inngest signing key for generated OS webapps. Leave unset when the target Inngest installation does not require one."
|
|
214
254
|
};
|
|
@@ -217,7 +257,7 @@ function renderLangfusePublicKeyInput() {
|
|
|
217
257
|
return {
|
|
218
258
|
name: langfusePublicKeyInputName(),
|
|
219
259
|
type: "string",
|
|
220
|
-
group: "
|
|
260
|
+
group: "applications",
|
|
221
261
|
displayName: "Langfuse Public Key",
|
|
222
262
|
description: "Shared Langfuse public key for generated OS webapps. Leave empty to disable Langfuse export.",
|
|
223
263
|
default: ""
|
|
@@ -228,9 +268,10 @@ function renderLangfuseSecretKeyInput() {
|
|
|
228
268
|
name: langfuseSecretKeyInputName(),
|
|
229
269
|
type: "string",
|
|
230
270
|
isSecret: true,
|
|
231
|
-
group: "
|
|
271
|
+
group: "applications",
|
|
232
272
|
displayName: "Langfuse Secret Key",
|
|
233
|
-
description: "Shared Langfuse secret key for generated OS webapps. Leave unset to disable Langfuse export."
|
|
273
|
+
description: "Shared Langfuse secret key for generated OS webapps. Leave unset to disable Langfuse export.",
|
|
274
|
+
condition: `{{ ne (input "${langfusePublicKeyInputName()}") "" }}`
|
|
234
275
|
};
|
|
235
276
|
}
|
|
236
277
|
function renderAppInstallationEnv(appName) {
|
|
@@ -257,34 +298,18 @@ function renderAppInstallationEnv(appName) {
|
|
|
257
298
|
value: `https://${appHost}`
|
|
258
299
|
},
|
|
259
300
|
{
|
|
260
|
-
key: "
|
|
261
|
-
value:
|
|
301
|
+
key: "DEPLOYMENT_ENVIRONMENT",
|
|
302
|
+
value: "{{ EnvironmentName }}"
|
|
262
303
|
},
|
|
263
304
|
{
|
|
264
305
|
key: "BETTER_AUTH_SECRET",
|
|
265
306
|
isSecret: true,
|
|
266
307
|
valueFromInput: { name: betterAuthSecretInputName(appName) }
|
|
267
308
|
},
|
|
268
|
-
{
|
|
269
|
-
key: "NODE_ENV",
|
|
270
|
-
value: "production"
|
|
271
|
-
},
|
|
272
|
-
{
|
|
273
|
-
key: "PORT",
|
|
274
|
-
value: "3000"
|
|
275
|
-
},
|
|
276
|
-
{
|
|
277
|
-
key: "AUTH_TRUST_HOST",
|
|
278
|
-
value: "true"
|
|
279
|
-
},
|
|
280
309
|
{
|
|
281
310
|
key: "INNGEST_BASE_URL",
|
|
282
311
|
value: "{{ (blueprintInstallation \"mosaic\").outputs.inngest_base_url }}"
|
|
283
312
|
},
|
|
284
|
-
{
|
|
285
|
-
key: "INNGEST_APP_URL",
|
|
286
|
-
value: `http://${appName}-web-server.{{ EnvironmentNamespace }}.svc.cluster.local:3000/api/inngest`
|
|
287
|
-
},
|
|
288
313
|
{
|
|
289
314
|
key: "INNGEST_EVENT_KEY",
|
|
290
315
|
isSecret: true,
|
|
@@ -308,26 +333,6 @@ function renderAppInstallationEnv(appName) {
|
|
|
308
333
|
isSecret: true,
|
|
309
334
|
valueFromInput: { name: langfuseSecretKeyInputName() }
|
|
310
335
|
},
|
|
311
|
-
{
|
|
312
|
-
key: "OTEL_SERVICE_NAME",
|
|
313
|
-
value: appName
|
|
314
|
-
},
|
|
315
|
-
{
|
|
316
|
-
key: "OTEL_RESOURCE_ATTRIBUTES",
|
|
317
|
-
value: `deployment.environment={{ EnvironmentName }},service.name=${appName}`
|
|
318
|
-
},
|
|
319
|
-
{
|
|
320
|
-
key: "OTEL_TRACES_EXPORTER",
|
|
321
|
-
value: "otlp"
|
|
322
|
-
},
|
|
323
|
-
{
|
|
324
|
-
key: "OTEL_METRICS_EXPORTER",
|
|
325
|
-
value: "otlp"
|
|
326
|
-
},
|
|
327
|
-
{
|
|
328
|
-
key: "OTEL_EXPORTER_OTLP_PROTOCOL",
|
|
329
|
-
value: "http/protobuf"
|
|
330
|
-
},
|
|
331
336
|
{
|
|
332
337
|
key: "OTEL_EXPORTER_OTLP_ENDPOINT",
|
|
333
338
|
value: "{{ (blueprintInstallation \"mosaic\").outputs.otel_exporter_otlp_endpoint }}"
|
|
@@ -425,4 +430,4 @@ function normalizeAppName(appNameInput) {
|
|
|
425
430
|
//#endregion
|
|
426
431
|
export { registerAppCommand };
|
|
427
432
|
|
|
428
|
-
//# sourceMappingURL=register-app-
|
|
433
|
+
//# sourceMappingURL=register-app-DeyAp8hw.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register-app-DeyAp8hw.js","names":[],"sources":["../src/commands/infra/register-app.ts"],"sourcesContent":["import path from \"node:path\";\nimport chalk from \"chalk\";\nimport fs from \"fs-extra\";\nimport { isMap, isSeq, parseDocument } from \"yaml\";\nimport {\n toKebabCase,\n toSnakeCase,\n toTitleCase,\n} from \"../../utils/case-converters.js\";\nimport { detectMonorepo } from \"../../utils/detect-monorepo.js\";\nimport { validateProjectName } from \"../../utils/validate.js\";\nimport { readWorkspaceManifest } from \"../../utils/workspace-manifest.js\";\nimport {\n createInfraGitHubApi,\n createOrUpdateInfraPullRequestFiles,\n INFRA_BASE_BRANCH,\n INFRA_REPOSITORY,\n type InfraGitHubApi,\n type InfraPullRequestFile,\n resolveGitHubToken,\n} from \"./github.js\";\n\nconst OS_POSTGRESQL_TERRAFORM_ALIAS = \"os-postgresql-terraform\";\nconst OS_POSTGRESQL_TERRAFORM_SERVICES = new Set([\n \"os-postgresql-terraform-aws\",\n \"os-postgresql-terraform-azure\",\n]);\nconst OS_BLUEPRINT_INPUT_GROUPS = [\n {\n name: \"general\",\n displayName: \"General\",\n description: \"Shared OS infrastructure settings.\",\n },\n {\n name: \"applications\",\n displayName: \"Applications\",\n description: \"Generated OS webapp settings.\",\n },\n {\n name: \"aws_postgresql\",\n displayName: \"AWS PostgreSQL\",\n description: \"AWS Aurora PostgreSQL settings.\",\n condition: '{{ eq EnvironmentProviderType \"aws\" }}',\n },\n {\n name: \"azure_postgresql\",\n displayName: \"Azure PostgreSQL\",\n description: \"Azure PostgreSQL Flexible Server settings.\",\n condition: '{{ eq EnvironmentProviderType \"azure\" }}',\n },\n];\n\nexport interface RegisterAppResult {\n appName: string;\n blueprintName: string;\n blueprintPath: string;\n branchName: string;\n customerSlug: string;\n pullRequestUrl: string | null;\n repository: typeof INFRA_REPOSITORY;\n status: \"already_registered\" | \"created_pr\" | \"updated_pr\";\n servicePath: string;\n targetPath: string;\n}\n\nexport async function registerApp(\n appNameInput: string,\n args: {\n cwd?: string;\n github?: InfraGitHubApi;\n } = {},\n): Promise<RegisterAppResult> {\n const appName = normalizeAppName(appNameInput);\n const cwd = args.cwd ?? process.cwd();\n const monorepoContext = await detectMonorepo(cwd);\n if (!monorepoContext.found || !monorepoContext.rootDir) {\n throw new Error(\n \"Run this command from a Mosaic customer monorepo with a .mosaic-workspace.json file.\",\n );\n }\n\n const workspaceManifest = await readWorkspaceManifest(\n monorepoContext.rootDir,\n );\n const customerSlug = workspaceManifest?.customerSlug;\n if (!customerSlug) {\n throw new Error(\n \".mosaic-workspace.json is missing customerSlug. Recreate the monorepo with a current @percepta/create.\",\n );\n }\n\n const github = args.github ?? createInfraGitHubApi(resolveGitHubToken());\n const blueprintName = `${customerSlug}-os`;\n const branchName = `blueberry/register-${customerSlug}-${appName}`;\n const blueprintPath = [\n \"ryvn\",\n \"definitions\",\n customerSlug,\n \"blueprints\",\n `${blueprintName}.blueprint.yaml`,\n ].join(\"/\");\n const servicePath = [\n \"ryvn\",\n \"definitions\",\n customerSlug,\n \"services\",\n `${appName}.service.yaml`,\n ].join(\"/\");\n\n const mainBlueprintFile = await github.getFile(\n blueprintPath,\n INFRA_BASE_BRANCH,\n );\n if (!mainBlueprintFile) {\n throw new Error(\n `${blueprintPath} does not exist in ${INFRA_REPOSITORY}. Run \\`pnpm mosaic infra register-os-blueprint\\` and merge that infra PR first.`,\n );\n }\n\n const mainServiceFile = await github.getFile(servicePath, INFRA_BASE_BRANCH);\n const serviceContent =\n mainServiceFile == null\n ? await readLocalServiceDefinition(monorepoContext.rootDir, appName)\n : null;\n const blueprintContent = registerAppInBlueprint(\n mainBlueprintFile.content,\n appName,\n );\n\n const files: InfraPullRequestFile[] = [];\n if (blueprintContent !== mainBlueprintFile.content) {\n files.push({\n baseFileSha: mainBlueprintFile.sha,\n content: blueprintContent,\n message: `Register ${appName} in ${blueprintName}`,\n path: blueprintPath,\n });\n }\n if (serviceContent != null) {\n files.push({\n content: serviceContent,\n message: `Register ${appName} service`,\n path: servicePath,\n });\n }\n\n if (files.length === 0) {\n return {\n appName,\n blueprintName,\n blueprintPath,\n branchName,\n customerSlug,\n pullRequestUrl: null,\n repository: INFRA_REPOSITORY,\n status: \"already_registered\",\n servicePath,\n targetPath: blueprintPath,\n };\n }\n\n const pullRequest = await createOrUpdateInfraPullRequestFiles({\n branchName,\n github,\n files,\n title: `Register ${appName} app`,\n body: [\n `Registers the ${appName} service and deployment in ${blueprintName}.`,\n \"\",\n \"Generated by `mosaic infra register-app`.\",\n ].join(\"\\n\"),\n });\n\n return {\n appName,\n blueprintName,\n blueprintPath,\n branchName,\n customerSlug,\n pullRequestUrl: pullRequest.pullRequestUrl,\n repository: INFRA_REPOSITORY,\n status: pullRequest.status,\n servicePath,\n targetPath: blueprintPath,\n };\n}\n\nexport async function registerAppCommand(appName: string): Promise<void> {\n try {\n const result = await registerApp(appName);\n\n if (result.status === \"already_registered\") {\n console.log(\n chalk.green(\"✔\"),\n `${result.appName} is already registered in ${result.repository} at`,\n chalk.cyan(result.targetPath),\n );\n return;\n }\n\n const verb =\n result.status === \"created_pr\" ? \"Created\" : \"Updated existing\";\n console.log(\n chalk.green(\"✔\"),\n `${verb} infra PR for ${result.appName}:`,\n chalk.cyan(result.pullRequestUrl),\n );\n } catch (error) {\n console.error(chalk.red(\"Error:\"), (error as Error).message);\n process.exit(1);\n }\n}\n\nexport function addAppDatabaseToBlueprint(\n blueprintContent: string,\n appName: string,\n): string {\n return updateBlueprint(blueprintContent, appName, {\n appDatabase: true,\n appInstallation: false,\n appInputs: false,\n });\n}\n\nexport function registerAppInBlueprint(\n blueprintContent: string,\n appName: string,\n): string {\n return updateBlueprint(blueprintContent, appName, {\n appDatabase: true,\n appInstallation: true,\n appInputs: true,\n });\n}\n\nfunction updateBlueprint(\n blueprintContent: string,\n appName: string,\n options: {\n appDatabase: boolean;\n appInstallation: boolean;\n appInputs: boolean;\n },\n): string {\n const document = parseDocument(blueprintContent);\n if (document.errors.length > 0) {\n throw new Error(\n `Invalid OS blueprint YAML: ${document.errors.map((error) => error.message).join(\"; \")}`,\n );\n }\n\n const spec = document.get(\"spec\", true);\n if (!isMap(spec)) {\n throw new Error(\"OS blueprint must include a spec map.\");\n }\n\n let changed = false;\n const inputs = spec.get(\"inputs\", true);\n if (!isSeq(inputs)) {\n throw new Error(\"OS blueprint spec.inputs must be a sequence.\");\n }\n\n changed = ensureInputGroups(document, spec) || changed;\n\n if (options.appInputs) {\n changed =\n addAppInput(document, inputs, renderIngressDomainInput()) || changed;\n changed =\n addAppInput(document, inputs, renderBetterAuthSecretInput(appName)) ||\n changed;\n changed =\n addAppInput(document, inputs, renderInngestEventKeyInput()) || changed;\n changed =\n addAppInput(document, inputs, renderInngestSigningKeyInput()) || changed;\n changed =\n addAppInput(document, inputs, renderLangfusePublicKeyInput()) || changed;\n changed =\n addAppInput(document, inputs, renderLangfuseSecretKeyInput()) || changed;\n }\n\n if (options.appDatabase) {\n changed = addAppDatabase(document, inputs, appName) || changed;\n }\n\n if (options.appInstallation) {\n const installations = spec.get(\"installations\", true);\n if (!isSeq(installations)) {\n throw new Error(\"OS blueprint spec.installations must be a sequence.\");\n }\n changed = ensureOsPostgresqlInstallationAlias(installations) || changed;\n changed = addAppInstallation(document, installations, appName) || changed;\n }\n\n return changed ? document.toString() : blueprintContent;\n}\n\nfunction ensureInputGroups(\n document: ReturnType<typeof parseDocument>,\n spec: {\n get(key: string, keepScalar?: true): unknown;\n set(key: string, value: unknown): void;\n },\n): boolean {\n let changed = false;\n const inputGroups = spec.get(\"inputGroups\", true);\n\n if (inputGroups == null) {\n spec.set(\"inputGroups\", document.createNode(OS_BLUEPRINT_INPUT_GROUPS));\n return true;\n }\n\n if (!isSeq(inputGroups)) {\n throw new Error(\"OS blueprint spec.inputGroups must be a sequence.\");\n }\n\n for (const group of OS_BLUEPRINT_INPUT_GROUPS) {\n const exists = inputGroups.items.some(\n (item) => isMap(item) && item.get(\"name\") === group.name,\n );\n if (exists) continue;\n\n inputGroups.add(document.createNode(group));\n changed = true;\n }\n\n return changed;\n}\n\nfunction ensureOsPostgresqlInstallationAlias(installations: {\n items: unknown[];\n}): boolean {\n let changed = false;\n\n for (const installation of installations.items) {\n if (!isMap(installation)) continue;\n\n const service = installation.get(\"service\");\n if (\n typeof service !== \"string\" ||\n !OS_POSTGRESQL_TERRAFORM_SERVICES.has(service)\n ) {\n continue;\n }\n\n if (installation.get(\"name\") === OS_POSTGRESQL_TERRAFORM_ALIAS) continue;\n\n installation.set(\"name\", OS_POSTGRESQL_TERRAFORM_ALIAS);\n changed = true;\n }\n\n return changed;\n}\n\nfunction addAppInput(\n document: ReturnType<typeof parseDocument>,\n inputs: { add(value: unknown): void; items: unknown[] },\n input: Record<string, unknown> & { name: string },\n): boolean {\n if (\n inputs.items.some((item) => isMap(item) && item.get(\"name\") === input.name)\n ) {\n return false;\n }\n\n inputs.add(document.createNode(input));\n return true;\n}\n\nfunction addAppDatabase(\n document: ReturnType<typeof parseDocument>,\n inputs: { items: unknown[] },\n appName: string,\n): boolean {\n const appDatabasesInput = inputs.items.find(\n (item) => isMap(item) && item.get(\"name\") === \"app_databases\",\n );\n if (!isMap(appDatabasesInput)) {\n throw new Error(\"OS blueprint must include an app_databases input.\");\n }\n\n const defaultValue = appDatabasesInput.get(\"default\", true);\n if (!isMap(defaultValue)) {\n throw new Error(\"OS blueprint app_databases default must be a map.\");\n }\n\n if (defaultValue.has(appName)) return false;\n\n defaultValue.flow = false;\n const appDatabaseValue = document.createNode({});\n if (isMap(appDatabaseValue)) appDatabaseValue.flow = true;\n defaultValue.set(appName, appDatabaseValue);\n return true;\n}\n\nfunction addAppInstallation(\n document: ReturnType<typeof parseDocument>,\n installations: { add(value: unknown): void; items: unknown[] },\n appName: string,\n): boolean {\n if (\n installations.items.some(\n (item) => isMap(item) && item.get(\"service\") === appName,\n )\n ) {\n return false;\n }\n\n installations.add(\n document.createNode({\n service: appName,\n env: renderAppInstallationEnv(appName),\n config: renderAppInstallationConfig(appName),\n }),\n );\n return true;\n}\n\nfunction renderIngressDomainInput(): Record<string, unknown> & {\n name: string;\n} {\n return {\n name: ingressDomainInputName(),\n type: \"string\",\n group: \"applications\",\n displayName: \"Ingress Domain\",\n description: \"Shared ingress domain for generated OS webapps.\",\n default: '{{ default \"example.local\" .ryvn.env.state.public_domain.name }}',\n };\n}\n\nfunction renderBetterAuthSecretInput(\n appName: string,\n): Record<string, unknown> & { name: string } {\n return {\n name: betterAuthSecretInputName(appName),\n type: \"string\",\n isSecret: true,\n group: \"applications\",\n displayName: `${toTitleCase(appName)} Better Auth Secret`,\n description: `Generated Better Auth signing secret for ${appName}.`,\n hidden: true,\n generated: {\n type: \"random-bytes\",\n length: 32,\n },\n };\n}\n\nfunction renderInngestEventKeyInput(): Record<string, unknown> & {\n name: string;\n} {\n return {\n name: inngestEventKeyInputName(),\n type: \"string\",\n isSecret: true,\n group: \"applications\",\n displayName: \"Inngest Event Key\",\n description:\n \"Shared Inngest event key for generated OS webapps. Leave unset when the target Inngest installation does not require one.\",\n };\n}\n\nfunction renderInngestSigningKeyInput(): Record<string, unknown> & {\n name: string;\n} {\n return {\n name: inngestSigningKeyInputName(),\n type: \"string\",\n isSecret: true,\n group: \"applications\",\n displayName: \"Inngest Signing Key\",\n description:\n \"Shared Inngest signing key for generated OS webapps. Leave unset when the target Inngest installation does not require one.\",\n };\n}\n\nfunction renderLangfusePublicKeyInput(): Record<string, unknown> & {\n name: string;\n} {\n return {\n name: langfusePublicKeyInputName(),\n type: \"string\",\n group: \"applications\",\n displayName: \"Langfuse Public Key\",\n description:\n \"Shared Langfuse public key for generated OS webapps. Leave empty to disable Langfuse export.\",\n default: \"\",\n };\n}\n\nfunction renderLangfuseSecretKeyInput(): Record<string, unknown> & {\n name: string;\n} {\n return {\n name: langfuseSecretKeyInputName(),\n type: \"string\",\n isSecret: true,\n group: \"applications\",\n displayName: \"Langfuse Secret Key\",\n description:\n \"Shared Langfuse secret key for generated OS webapps. Leave unset to disable Langfuse export.\",\n condition: `{{ ne (input \"${langfusePublicKeyInputName()}\") \"\" }}`,\n };\n}\n\nfunction renderAppInstallationEnv(\n appName: string,\n): Array<Record<string, unknown>> {\n const appHost = `${appName}.{{ input \"${ingressDomainInputName()}\" }}`;\n\n return [\n {\n key: \"DATABASE_URL\",\n isSecret: true,\n valueFromOutput: {\n serviceInstallation: \"os-postgresql-terraform\",\n name: `app_database_urls.${appName}`,\n },\n },\n {\n key: \"AUTH_DATABASE_URL\",\n isSecret: true,\n valueFromOutput: {\n serviceInstallation: \"os-postgresql-terraform\",\n name: \"auth_database_url\",\n },\n },\n {\n key: \"APP_BASE_URL\",\n value: `https://${appHost}`,\n },\n {\n key: \"DEPLOYMENT_ENVIRONMENT\",\n value: \"{{ EnvironmentName }}\",\n },\n {\n key: \"BETTER_AUTH_SECRET\",\n isSecret: true,\n valueFromInput: {\n name: betterAuthSecretInputName(appName),\n },\n },\n {\n key: \"INNGEST_BASE_URL\",\n value: '{{ (blueprintInstallation \"mosaic\").outputs.inngest_base_url }}',\n },\n {\n key: \"INNGEST_EVENT_KEY\",\n isSecret: true,\n valueFromInput: {\n name: inngestEventKeyInputName(),\n },\n },\n {\n key: \"INNGEST_SIGNING_KEY\",\n isSecret: true,\n valueFromInput: {\n name: inngestSigningKeyInputName(),\n },\n },\n {\n key: \"LANGFUSE_BASE_URL\",\n value: '{{ (blueprintInstallation \"mosaic\").outputs.langfuse_base_url }}',\n },\n {\n key: \"LANGFUSE_PUBLIC_KEY\",\n valueFromInput: {\n name: langfusePublicKeyInputName(),\n },\n },\n {\n key: \"LANGFUSE_SECRET_KEY\",\n isSecret: true,\n valueFromInput: {\n name: langfuseSecretKeyInputName(),\n },\n },\n {\n key: \"OTEL_EXPORTER_OTLP_ENDPOINT\",\n value:\n '{{ (blueprintInstallation \"mosaic\").outputs.otel_exporter_otlp_endpoint }}',\n },\n {\n key: \"SPICEDB_ENDPOINT\",\n value: '{{ (blueprintInstallation \"mosaic\").outputs.spicedb_endpoint }}',\n },\n {\n key: \"SPICEDB_PRESHARED_KEY\",\n isSecret: true,\n value:\n '{{ (blueprintInstallation \"mosaic\").outputs.spicedb_preshared_key }}',\n },\n {\n key: \"SPICEDB_INSECURE\",\n value: '{{ (blueprintInstallation \"mosaic\").outputs.spicedb_insecure }}',\n },\n ];\n}\n\nfunction renderAppInstallationConfig(appName: string): string {\n const appHost = `${appName}.{{ input \"${ingressDomainInputName()}\" }}`;\n\n return [\n \"replicaCount: 1\",\n \"\",\n \"service:\",\n \" port: 3000\",\n \"\",\n \"livenessEnabled: true\",\n \"readinessEnabled: true\",\n \"startupEnabled: true\",\n \"\",\n \"resources:\",\n \" requests:\",\n ' cpu: \"100m\"',\n \" memory: 256Mi\",\n \" limits:\",\n ' cpu: \"500m\"',\n \" memory: 512Mi\",\n \"\",\n \"ingress:\",\n \" enabled: true\",\n \" className: external-nginx\",\n \" annotations:\",\n \" cert-manager.io/cluster-issuer: external-issuer\",\n ' nginx.ingress.kubernetes.io/ssl-redirect: \"true\"',\n \" hosts:\",\n ` - host: '${appHost}'`,\n \" paths:\",\n \" - path: /\",\n \" pathType: Prefix\",\n \" tls:\",\n ` - secretName: ${appName}-tls`,\n \" hosts:\",\n ` - '${appHost}'`,\n \"\",\n ].join(\"\\n\");\n}\n\nasync function readLocalServiceDefinition(\n monorepoRoot: string,\n appName: string,\n): Promise<string> {\n const serviceDefinitionPath = path.join(\n monorepoRoot,\n \"packages\",\n appName,\n \"deploy\",\n \"ryvn\",\n `${appName}.service.yaml`,\n );\n if (!(await fs.pathExists(serviceDefinitionPath))) {\n throw new Error(\n `${serviceDefinitionPath} does not exist. Add the app's Ryvn service definition before registering it in infra.`,\n );\n }\n\n const content = await fs.readFile(serviceDefinitionPath, \"utf-8\");\n validateLocalServiceDefinition(content, appName, serviceDefinitionPath);\n return content.endsWith(\"\\n\") ? content : `${content}\\n`;\n}\n\nfunction validateLocalServiceDefinition(\n content: string,\n appName: string,\n serviceDefinitionPath: string,\n): void {\n const document = parseDocument(content);\n if (document.errors.length > 0) {\n throw new Error(\n `Invalid Ryvn service YAML at ${serviceDefinitionPath}: ${document.errors.map((error) => error.message).join(\"; \")}`,\n );\n }\n\n const service = document.toJS() as {\n kind?: unknown;\n metadata?: { name?: unknown };\n };\n if (service.kind !== \"Service\" || service.metadata?.name !== appName) {\n throw new Error(\n `${serviceDefinitionPath} must define kind: Service with metadata.name: ${appName}.`,\n );\n }\n}\n\nfunction ingressDomainInputName(): string {\n return \"ingress_domain\";\n}\n\nfunction betterAuthSecretInputName(appName: string): string {\n return `${toSnakeCase(appName)}_better_auth_secret`;\n}\n\nfunction inngestEventKeyInputName(): string {\n return \"inngest_event_key\";\n}\n\nfunction inngestSigningKeyInputName(): string {\n return \"inngest_signing_key\";\n}\n\nfunction langfusePublicKeyInputName(): string {\n return \"langfuse_public_key\";\n}\n\nfunction langfuseSecretKeyInputName(): string {\n return \"langfuse_secret_key\";\n}\n\nfunction normalizeAppName(appNameInput: string): string {\n const appName = toKebabCase(appNameInput);\n const validation = validateProjectName(appName);\n if (!validation.valid) {\n throw new Error(`Invalid app name: ${validation.error}`);\n }\n return appName;\n}\n"],"mappings":";;;;;;;;;AAsBA,MAAM,gCAAgC;AACtC,MAAM,mCAAmC,IAAI,IAAI,CAC/C,+BACA,gCACD,CAAC;AACF,MAAM,4BAA4B;CAChC;EACE,MAAM;EACN,aAAa;EACb,aAAa;EACd;CACD;EACE,MAAM;EACN,aAAa;EACb,aAAa;EACd;CACD;EACE,MAAM;EACN,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ACD;GACE,KAAK;GACL,OAAO;GACR;EACD;GACE,KAAK;GACL,UAAU;GACV,gBAAgB,EACd,MAAM,0BAA0B,QAAQ,EACzC;GACF;EACD;GACE,KAAK;GACL,OAAO;GACR;EACD;GACE,KAAK;GACL,UAAU;GACV,gBAAgB,EACd,MAAM,0BAA0B,EACjC;GACF;EACD;GACE,KAAK;GACL,UAAU;GACV,gBAAgB,EACd,MAAM,4BAA4B,EACnC;GACF;EACD;GACE,KAAK;GACL,OAAO;GACR;EACD;GACE,KAAK;GACL,gBAAgB,EACd,MAAM,4BAA4B,EACnC;GACF;EACD;GACE,KAAK;GACL,UAAU;GACV,gBAAgB,EACd,MAAM,4BAA4B,EACnC;GACF;EACD;GACE,KAAK;GACL,OACE;GACH;EACD;GACE,KAAK;GACL,OAAO;GACR;EACD;GACE,KAAK;GACL,UAAU;GACV,OACE;GACH;EACD;GACE,KAAK;GACL,OAAO;GACR;EACF;;AAGH,SAAS,4BAA4B,SAAyB;CAC5D,MAAM,UAAU,GAAG,QAAQ,aAAa,wBAAwB,CAAC;AAEjE,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,gBAAgB,QAAQ;EACxB;EACA;EACA;EACA;EACA,qBAAqB,QAAQ;EAC7B;EACA,cAAc,QAAQ;EACtB;EACD,CAAC,KAAK,KAAK;;AAGd,eAAe,2BACb,cACA,SACiB;CACjB,MAAM,wBAAwB,KAAK,KACjC,cACA,YACA,SACA,UACA,QACA,GAAG,QAAQ,eACZ;AACD,KAAI,CAAE,MAAM,GAAG,WAAW,sBAAsB,CAC9C,OAAM,IAAI,MACR,GAAG,sBAAsB,wFAC1B;CAGH,MAAM,UAAU,MAAM,GAAG,SAAS,uBAAuB,QAAQ;AACjE,gCAA+B,SAAS,SAAS,sBAAsB;AACvE,QAAO,QAAQ,SAAS,KAAK,GAAG,UAAU,GAAG,QAAQ;;AAGvD,SAAS,+BACP,SACA,SACA,uBACM;CACN,MAAM,WAAW,cAAc,QAAQ;AACvC,KAAI,SAAS,OAAO,SAAS,EAC3B,OAAM,IAAI,MACR,gCAAgC,sBAAsB,IAAI,SAAS,OAAO,KAAK,UAAU,MAAM,QAAQ,CAAC,KAAK,KAAK,GACnH;CAGH,MAAM,UAAU,SAAS,MAAM;AAI/B,KAAI,QAAQ,SAAS,aAAa,QAAQ,UAAU,SAAS,QAC3D,OAAM,IAAI,MACR,GAAG,sBAAsB,iDAAiD,QAAQ,GACnF;;AAIL,SAAS,yBAAiC;AACxC,QAAO;;AAGT,SAAS,0BAA0B,SAAyB;AAC1D,QAAO,GAAG,YAAY,QAAQ,CAAC;;AAGjC,SAAS,2BAAmC;AAC1C,QAAO;;AAGT,SAAS,6BAAqC;AAC5C,QAAO;;AAGT,SAAS,6BAAqC;AAC5C,QAAO;;AAGT,SAAS,6BAAqC;AAC5C,QAAO;;AAGT,SAAS,iBAAiB,cAA8B;CACtD,MAAM,UAAU,YAAY,aAAa;CACzC,MAAM,aAAa,oBAAoB,QAAQ;AAC/C,KAAI,CAAC,WAAW,MACd,OAAM,IAAI,MAAM,qBAAqB,WAAW,QAAQ;AAE1D,QAAO"}
|
package/package.json
CHANGED
|
@@ -6,100 +6,117 @@ spec:
|
|
|
6
6
|
description: "__CUSTOMER_TITLE__-owned infrastructure for the OS monorepo"
|
|
7
7
|
displayName: "__CUSTOMER_TITLE__ OS"
|
|
8
8
|
|
|
9
|
+
inputGroups:
|
|
10
|
+
- name: general
|
|
11
|
+
displayName: "General"
|
|
12
|
+
description: "Shared OS infrastructure settings."
|
|
13
|
+
- name: applications
|
|
14
|
+
displayName: "Applications"
|
|
15
|
+
description: "Generated OS webapp settings."
|
|
16
|
+
- name: aws_postgresql
|
|
17
|
+
displayName: "AWS PostgreSQL"
|
|
18
|
+
description: "AWS Aurora PostgreSQL settings."
|
|
19
|
+
condition: '{{ eq EnvironmentProviderType "aws" }}'
|
|
20
|
+
- name: azure_postgresql
|
|
21
|
+
displayName: "Azure PostgreSQL"
|
|
22
|
+
description: "Azure PostgreSQL Flexible Server settings."
|
|
23
|
+
condition: '{{ eq EnvironmentProviderType "azure" }}'
|
|
24
|
+
|
|
9
25
|
inputs:
|
|
10
26
|
- name: app_databases
|
|
11
27
|
type: map
|
|
12
|
-
group:
|
|
28
|
+
group: general
|
|
13
29
|
displayName: "App Databases"
|
|
14
30
|
description: "Application database declarations keyed by app name. This default is the __CUSTOMER_TITLE__ OS app registry; BlueprintInstallation inputs should only override it for environment-specific drift. Each value may set database_name, schema_name, username, and secret_name."
|
|
15
31
|
default: {}
|
|
16
32
|
- name: ingress_domain
|
|
17
33
|
type: string
|
|
18
|
-
group:
|
|
34
|
+
group: applications
|
|
19
35
|
displayName: "Ingress Domain"
|
|
20
36
|
description: "Shared ingress domain for generated OS webapps."
|
|
21
37
|
default: '{{ default "example.local" .ryvn.env.state.public_domain.name }}'
|
|
22
38
|
- name: inngest_event_key
|
|
23
39
|
type: string
|
|
24
40
|
isSecret: true
|
|
25
|
-
group:
|
|
41
|
+
group: applications
|
|
26
42
|
displayName: "Inngest Event Key"
|
|
27
43
|
description: "Shared Inngest event key for generated OS webapps. Leave unset when the target Inngest installation does not require one."
|
|
28
44
|
- name: inngest_signing_key
|
|
29
45
|
type: string
|
|
30
46
|
isSecret: true
|
|
31
|
-
group:
|
|
47
|
+
group: applications
|
|
32
48
|
displayName: "Inngest Signing Key"
|
|
33
49
|
description: "Shared Inngest signing key for generated OS webapps. Leave unset when the target Inngest installation does not require one."
|
|
34
50
|
- name: langfuse_public_key
|
|
35
51
|
type: string
|
|
36
|
-
group:
|
|
52
|
+
group: applications
|
|
37
53
|
displayName: "Langfuse Public Key"
|
|
38
54
|
description: "Shared Langfuse public key for generated OS webapps. Leave empty to disable Langfuse export."
|
|
39
55
|
default: ""
|
|
40
56
|
- name: langfuse_secret_key
|
|
41
57
|
type: string
|
|
42
58
|
isSecret: true
|
|
43
|
-
group:
|
|
59
|
+
group: applications
|
|
44
60
|
displayName: "Langfuse Secret Key"
|
|
45
61
|
description: "Shared Langfuse secret key for generated OS webapps. Leave unset to disable Langfuse export."
|
|
62
|
+
condition: '{{ ne (input "langfuse_public_key") "" }}'
|
|
46
63
|
- name: auth_secret_name
|
|
47
64
|
type: string
|
|
48
|
-
group:
|
|
65
|
+
group: general
|
|
49
66
|
displayName: "Auth Secret Name"
|
|
50
67
|
description: "Optional Kubernetes Secret name for shared auth database credentials. Defaults to <environment>-auth-postgresql."
|
|
51
68
|
default: ""
|
|
52
69
|
- name: auth_username
|
|
53
70
|
type: string
|
|
54
|
-
group:
|
|
71
|
+
group: general
|
|
55
72
|
displayName: "Auth Username"
|
|
56
73
|
description: "Optional shared auth database username. Defaults to <environment>_auth."
|
|
57
74
|
default: ""
|
|
58
75
|
- name: aws_postgresql_cluster_name
|
|
59
76
|
type: string
|
|
60
|
-
group:
|
|
77
|
+
group: aws_postgresql
|
|
61
78
|
displayName: "AWS PostgreSQL Cluster Name"
|
|
62
79
|
description: "Optional Aurora PostgreSQL cluster name. Defaults to <environment>-postgresql."
|
|
63
80
|
default: ""
|
|
64
81
|
condition: '{{ eq EnvironmentProviderType "aws" }}'
|
|
65
82
|
- name: azure_postgresql_server_name
|
|
66
83
|
type: string
|
|
67
|
-
group:
|
|
84
|
+
group: azure_postgresql
|
|
68
85
|
displayName: "Azure PostgreSQL Server Name"
|
|
69
86
|
description: "Optional Azure PostgreSQL flexible server name. Defaults to <environment>-postgresql."
|
|
70
87
|
default: ""
|
|
71
88
|
condition: '{{ eq EnvironmentProviderType "azure" }}'
|
|
72
89
|
- name: azure_postgresql_private_dns_zone_id
|
|
73
90
|
type: string
|
|
74
|
-
group:
|
|
91
|
+
group: azure_postgresql
|
|
75
92
|
displayName: "Azure PostgreSQL Private DNS Zone ID"
|
|
76
93
|
description: "Existing Azure PostgreSQL private DNS zone ID. Leave empty to create one."
|
|
77
94
|
default: ""
|
|
78
95
|
condition: '{{ eq EnvironmentProviderType "azure" }}'
|
|
79
96
|
- name: azure_postgresql_subnet_id
|
|
80
97
|
type: string
|
|
81
|
-
group:
|
|
98
|
+
group: azure_postgresql
|
|
82
99
|
displayName: "Azure PostgreSQL Subnet ID"
|
|
83
100
|
description: "Existing delegated PostgreSQL subnet ID. Leave empty to create one."
|
|
84
101
|
default: ""
|
|
85
102
|
condition: '{{ eq EnvironmentProviderType "azure" }}'
|
|
86
103
|
- name: azure_postgresql_subnet_address_prefix
|
|
87
104
|
type: string
|
|
88
|
-
group:
|
|
105
|
+
group: azure_postgresql
|
|
89
106
|
displayName: "Azure PostgreSQL Subnet Address Prefix"
|
|
90
107
|
description: "Address prefix for the delegated PostgreSQL subnet when creating one."
|
|
91
108
|
default: ""
|
|
92
109
|
condition: '{{ eq EnvironmentProviderType "azure" }}'
|
|
93
110
|
- name: azure_postgresql_key_vault_id
|
|
94
111
|
type: string
|
|
95
|
-
group:
|
|
112
|
+
group: azure_postgresql
|
|
96
113
|
displayName: "Azure PostgreSQL Key Vault ID"
|
|
97
114
|
description: "Optional Key Vault ID for storing generated PostgreSQL admin credentials."
|
|
98
115
|
default: ""
|
|
99
116
|
condition: '{{ eq EnvironmentProviderType "azure" }}'
|
|
100
117
|
- name: azure_postgresql_sku_name
|
|
101
118
|
type: string
|
|
102
|
-
group:
|
|
119
|
+
group: azure_postgresql
|
|
103
120
|
displayName: "Azure PostgreSQL SKU Name"
|
|
104
121
|
description: "Azure PostgreSQL flexible server SKU."
|
|
105
122
|
default: "B_Standard_B2s"
|
|
@@ -23,9 +23,17 @@ function getSecret(): string {
|
|
|
23
23
|
return requiredEnv("BETTER_AUTH_SECRET");
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
function getBaseUrl(): string {
|
|
27
|
+
return (
|
|
28
|
+
process.env.BETTER_AUTH_URL ??
|
|
29
|
+
process.env.APP_BASE_URL ??
|
|
30
|
+
"http://localhost:3000"
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
26
34
|
function createAuth() {
|
|
27
35
|
return createPerceptaAuth({
|
|
28
|
-
baseURL:
|
|
36
|
+
baseURL: getBaseUrl(),
|
|
29
37
|
database: db,
|
|
30
38
|
schema: {
|
|
31
39
|
user: users,
|
|
@@ -226,7 +226,7 @@ Better Auth is configured in the customer monorepo's shared `@__REPO_NAME__/auth
|
|
|
226
226
|
- **Sign in**: `authClient.signIn.email({ email, password })` — client-side
|
|
227
227
|
- **Sign out**: `authClient.signOut()` — client-side
|
|
228
228
|
- **API route**: `src/app/api/auth/[...all]/route.ts` — Better Auth handler
|
|
229
|
-
- **Env vars**: `BETTER_AUTH_SECRET` (required), `BETTER_AUTH_URL`
|
|
229
|
+
- **Env vars**: `BETTER_AUTH_SECRET` (required), optional `BETTER_AUTH_URL` override, `AUTH_DATABASE_URL` for deployed shared auth DB wiring
|
|
230
230
|
|
|
231
231
|
### Background Jobs
|
|
232
232
|
|
|
@@ -242,7 +242,7 @@ PostgreSQL with Drizzle ORM. Schema in `src/drizzle/schema/`, migrations in `src
|
|
|
242
242
|
|
|
243
243
|
### Observability
|
|
244
244
|
|
|
245
|
-
OpenTelemetry initialized in `src/instrumentation.ts`. Server traces
|
|
245
|
+
OpenTelemetry initialized in `src/instrumentation.ts`. Server traces export to the configured OTEL collector; platform logs are collected from stdout. Langfuse for LLM tracking in `src/services/langfuse/` activates when `LANGFUSE_*` env vars are configured, but only AI SDK spans are forwarded to Langfuse by default. Faro for frontend monitoring via `@percepta/next-utils/faro`.
|
|
246
246
|
|
|
247
247
|
## Deployment
|
|
248
248
|
|
|
@@ -155,9 +155,11 @@ Required auth environment variables:
|
|
|
155
155
|
|
|
156
156
|
```bash
|
|
157
157
|
BETTER_AUTH_SECRET=generate-with-openssl-rand-base64-32
|
|
158
|
-
BETTER_AUTH_URL=http://localhost:3000
|
|
159
158
|
```
|
|
160
159
|
|
|
160
|
+
Auth uses `BETTER_AUTH_URL`, `APP_BASE_URL`, or `http://localhost:3000`, in
|
|
161
|
+
that order, for its base URL.
|
|
162
|
+
|
|
161
163
|
Remote deployments should also set `AUTH_DATABASE_URL` from the shared auth
|
|
162
164
|
database Secret. Local development can omit it and use the root-created local
|
|
163
165
|
`auth` database.
|
|
@@ -183,6 +185,7 @@ App permissions are authored in `src/access/schema.zed`; `src/access/access.mani
|
|
|
183
185
|
|----------|-------------|---------|
|
|
184
186
|
| `NODE_ENV` | Environment mode | `development` |
|
|
185
187
|
| `APP_BASE_URL` | Base URL for the app | - |
|
|
188
|
+
| `DEPLOYMENT_ENVIRONMENT` | Deployment environment label for telemetry | `NODE_ENV` |
|
|
186
189
|
|
|
187
190
|
### App Database
|
|
188
191
|
|
|
@@ -260,17 +263,14 @@ For local development, `pnpm dev` also loads `~/.config/percepta/create.env` whe
|
|
|
260
263
|
|
|
261
264
|
| Variable | Description |
|
|
262
265
|
|----------|-------------|
|
|
263
|
-
| `OTEL_SERVICE_NAME` | Service name attached to traces and metrics |
|
|
264
|
-
| `OTEL_RESOURCE_ATTRIBUTES` | Extra resource labels such as deployment environment |
|
|
265
|
-
| `OTEL_EXPORTER_OTLP_PROTOCOL` | OTLP protocol, usually `http/protobuf` |
|
|
266
266
|
| `OTEL_EXPORTER_OTLP_ENDPOINT` | Base OTLP HTTP collector endpoint |
|
|
267
267
|
| `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT` | Optional trace-specific OTLP endpoint |
|
|
268
|
-
| `
|
|
269
|
-
| `OTEL_TRACES_EXPORTER` | Set to `otlp` to export server traces |
|
|
270
|
-
| `OTEL_METRICS_EXPORTER` | Set to `otlp` to export server metrics |
|
|
271
|
-
| `OTEL_METRIC_EXPORT_INTERVAL` | Metrics export interval in milliseconds |
|
|
268
|
+
| `OTEL_TRACES_EXPORTER` | Set to `none` to disable server trace export |
|
|
272
269
|
|
|
273
|
-
|
|
270
|
+
The generated app sets its OpenTelemetry service name and deployment
|
|
271
|
+
environment resource label internally. Configure the collector endpoint through
|
|
272
|
+
the target deployment platform. Application logs are written to stdout so the
|
|
273
|
+
platform collector can collect them.
|
|
274
274
|
|
|
275
275
|
## Local AWS Development
|
|
276
276
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# Application
|
|
2
2
|
NODE_ENV=development
|
|
3
3
|
APP_BASE_URL=http://localhost:3000
|
|
4
|
+
# DEPLOYMENT_ENVIRONMENT=development
|
|
4
5
|
|
|
5
6
|
# App Database
|
|
6
7
|
DATABASE_URL=postgresql://postgres:postgres@localhost:5434/__DB_NAME__
|
|
7
8
|
|
|
8
9
|
# Authentication (Better Auth)
|
|
9
10
|
BETTER_AUTH_SECRET=generate-with-openssl-rand-base64-32
|
|
10
|
-
BETTER_AUTH_URL=http://localhost:3000
|
|
11
11
|
|
|
12
12
|
# Shared Auth Database
|
|
13
13
|
# Deployed apps should set this from the customer monorepo auth database Secret.
|
|
@@ -48,14 +48,10 @@ NEXT_PUBLIC_FARO_APP_ENVIRONMENT=development
|
|
|
48
48
|
# LLM_PROVIDER=anthropic
|
|
49
49
|
# LLM_MODEL=claude-sonnet-4-5-20250929
|
|
50
50
|
|
|
51
|
-
# OpenTelemetry (server-side traces
|
|
52
|
-
# OTEL_SERVICE_NAME=__APP_NAME__
|
|
53
|
-
# OTEL_TRACES_EXPORTER=otlp
|
|
54
|
-
# OTEL_METRICS_EXPORTER=otlp
|
|
55
|
-
# OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
|
|
51
|
+
# OpenTelemetry (server-side traces)
|
|
56
52
|
# OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318
|
|
57
53
|
# OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://localhost:4318/v1/traces
|
|
58
|
-
#
|
|
54
|
+
# OTEL_TRACES_EXPORTER=none
|
|
59
55
|
|
|
60
56
|
# AWS (uses default credential chain in development)
|
|
61
57
|
# AWS_REGION=us-east-1
|
|
@@ -9,6 +9,7 @@ export const { getEnvConfig, schema: ENV_CONFIG_SCHEMA } = createEnvConfig(
|
|
|
9
9
|
z.object({
|
|
10
10
|
// Application:
|
|
11
11
|
APP_BASE_URL: z.string().optional(),
|
|
12
|
+
DEPLOYMENT_ENVIRONMENT: z.string().optional(),
|
|
12
13
|
|
|
13
14
|
// App database:
|
|
14
15
|
DATABASE_URL: z
|
|
@@ -20,7 +21,6 @@ export const { getEnvConfig, schema: ENV_CONFIG_SCHEMA } = createEnvConfig(
|
|
|
20
21
|
|
|
21
22
|
// Authentication (Better Auth):
|
|
22
23
|
BETTER_AUTH_SECRET: z.string().optional(),
|
|
23
|
-
BETTER_AUTH_URL: z.string().default("http://localhost:3000"),
|
|
24
24
|
AUTH_DATABASE_URL: z.string().optional(),
|
|
25
25
|
|
|
26
26
|
// Inngest:
|
|
@@ -39,15 +39,9 @@ export const { getEnvConfig, schema: ENV_CONFIG_SCHEMA } = createEnvConfig(
|
|
|
39
39
|
LANGFUSE_SECRET_KEY: z.string().optional(),
|
|
40
40
|
|
|
41
41
|
// OpenTelemetry:
|
|
42
|
-
OTEL_SERVICE_NAME: z.string().optional(),
|
|
43
|
-
OTEL_RESOURCE_ATTRIBUTES: z.string().optional(),
|
|
44
42
|
OTEL_TRACES_EXPORTER: z.string().optional(),
|
|
45
|
-
OTEL_METRICS_EXPORTER: z.string().optional(),
|
|
46
|
-
OTEL_EXPORTER_OTLP_PROTOCOL: z.string().optional(),
|
|
47
43
|
OTEL_EXPORTER_OTLP_ENDPOINT: z.string().optional(),
|
|
48
44
|
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: z.string().optional(),
|
|
49
|
-
OTEL_EXPORTER_OTLP_METRICS_ENDPOINT: z.string().optional(),
|
|
50
|
-
OTEL_METRIC_EXPORT_INTERVAL: z.string().optional(),
|
|
51
45
|
|
|
52
46
|
// Security:
|
|
53
47
|
ENCRYPTION_SECRET_KEY: z.string().optional(),
|
|
@@ -8,6 +8,17 @@ import { getLogger } from "./services/logger/AppLogger";
|
|
|
8
8
|
|
|
9
9
|
type SpanProcessor = tracing.SpanProcessor;
|
|
10
10
|
|
|
11
|
+
function setDefaultOpenTelemetryEnv(): void {
|
|
12
|
+
const {
|
|
13
|
+
DEPLOYMENT_ENVIRONMENT: deploymentEnvironment,
|
|
14
|
+
NODE_ENV: nodeEnv,
|
|
15
|
+
} = getEnvConfig();
|
|
16
|
+
|
|
17
|
+
process.env.OTEL_SERVICE_NAME ??= "__APP_NAME__";
|
|
18
|
+
process.env.OTEL_RESOURCE_ATTRIBUTES ??=
|
|
19
|
+
`deployment.environment=${deploymentEnvironment ?? nodeEnv}`;
|
|
20
|
+
}
|
|
21
|
+
|
|
11
22
|
function getOtlpTracesEndpoint(): string | undefined {
|
|
12
23
|
const {
|
|
13
24
|
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: tracesEndpoint,
|
|
@@ -53,6 +64,8 @@ function getLangfuseSpanProcessor(): SpanProcessor | undefined {
|
|
|
53
64
|
return createLangfuseSpanProcessor(getEnvConfig(), getLogger());
|
|
54
65
|
}
|
|
55
66
|
|
|
67
|
+
setDefaultOpenTelemetryEnv();
|
|
68
|
+
|
|
56
69
|
const spanProcessors: tracing.SpanProcessor[] = compact([
|
|
57
70
|
getOtlpSpanProcessor(),
|
|
58
71
|
getLangfuseSpanProcessor(),
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"register-app-0iB8cN97.js","names":[],"sources":["../src/commands/infra/register-app.ts"],"sourcesContent":["import path from \"node:path\";\nimport chalk from \"chalk\";\nimport fs from \"fs-extra\";\nimport { isMap, isSeq, parseDocument } from \"yaml\";\nimport {\n toKebabCase,\n toSnakeCase,\n toTitleCase,\n} from \"../../utils/case-converters.js\";\nimport { detectMonorepo } from \"../../utils/detect-monorepo.js\";\nimport { validateProjectName } from \"../../utils/validate.js\";\nimport { readWorkspaceManifest } from \"../../utils/workspace-manifest.js\";\nimport {\n createInfraGitHubApi,\n createOrUpdateInfraPullRequestFiles,\n INFRA_BASE_BRANCH,\n INFRA_REPOSITORY,\n type InfraGitHubApi,\n type InfraPullRequestFile,\n resolveGitHubToken,\n} from \"./github.js\";\n\nconst OS_POSTGRESQL_TERRAFORM_ALIAS = \"os-postgresql-terraform\";\nconst OS_POSTGRESQL_TERRAFORM_SERVICES = new Set([\n \"os-postgresql-terraform-aws\",\n \"os-postgresql-terraform-azure\",\n]);\n\nexport interface RegisterAppResult {\n appName: string;\n blueprintName: string;\n blueprintPath: string;\n branchName: string;\n customerSlug: string;\n pullRequestUrl: string | null;\n repository: typeof INFRA_REPOSITORY;\n status: \"already_registered\" | \"created_pr\" | \"updated_pr\";\n servicePath: string;\n targetPath: string;\n}\n\nexport async function registerApp(\n appNameInput: string,\n args: {\n cwd?: string;\n github?: InfraGitHubApi;\n } = {},\n): Promise<RegisterAppResult> {\n const appName = normalizeAppName(appNameInput);\n const cwd = args.cwd ?? process.cwd();\n const monorepoContext = await detectMonorepo(cwd);\n if (!monorepoContext.found || !monorepoContext.rootDir) {\n throw new Error(\n \"Run this command from a Mosaic customer monorepo with a .mosaic-workspace.json file.\",\n );\n }\n\n const workspaceManifest = await readWorkspaceManifest(\n monorepoContext.rootDir,\n );\n const customerSlug = workspaceManifest?.customerSlug;\n if (!customerSlug) {\n throw new Error(\n \".mosaic-workspace.json is missing customerSlug. Recreate the monorepo with a current @percepta/create.\",\n );\n }\n\n const github = args.github ?? createInfraGitHubApi(resolveGitHubToken());\n const blueprintName = `${customerSlug}-os`;\n const branchName = `blueberry/register-${customerSlug}-${appName}`;\n const blueprintPath = [\n \"ryvn\",\n \"definitions\",\n customerSlug,\n \"blueprints\",\n `${blueprintName}.blueprint.yaml`,\n ].join(\"/\");\n const servicePath = [\n \"ryvn\",\n \"definitions\",\n customerSlug,\n \"services\",\n `${appName}.service.yaml`,\n ].join(\"/\");\n\n const mainBlueprintFile = await github.getFile(\n blueprintPath,\n INFRA_BASE_BRANCH,\n );\n if (!mainBlueprintFile) {\n throw new Error(\n `${blueprintPath} does not exist in ${INFRA_REPOSITORY}. Run \\`pnpm mosaic infra register-os-blueprint\\` and merge that infra PR first.`,\n );\n }\n\n const mainServiceFile = await github.getFile(servicePath, INFRA_BASE_BRANCH);\n const serviceContent =\n mainServiceFile == null\n ? await readLocalServiceDefinition(monorepoContext.rootDir, appName)\n : null;\n const blueprintContent = registerAppInBlueprint(\n mainBlueprintFile.content,\n appName,\n );\n\n const files: InfraPullRequestFile[] = [];\n if (blueprintContent !== mainBlueprintFile.content) {\n files.push({\n baseFileSha: mainBlueprintFile.sha,\n content: blueprintContent,\n message: `Register ${appName} in ${blueprintName}`,\n path: blueprintPath,\n });\n }\n if (serviceContent != null) {\n files.push({\n content: serviceContent,\n message: `Register ${appName} service`,\n path: servicePath,\n });\n }\n\n if (files.length === 0) {\n return {\n appName,\n blueprintName,\n blueprintPath,\n branchName,\n customerSlug,\n pullRequestUrl: null,\n repository: INFRA_REPOSITORY,\n status: \"already_registered\",\n servicePath,\n targetPath: blueprintPath,\n };\n }\n\n const pullRequest = await createOrUpdateInfraPullRequestFiles({\n branchName,\n github,\n files,\n title: `Register ${appName} app`,\n body: [\n `Registers the ${appName} service and deployment in ${blueprintName}.`,\n \"\",\n \"Generated by `mosaic infra register-app`.\",\n ].join(\"\\n\"),\n });\n\n return {\n appName,\n blueprintName,\n blueprintPath,\n branchName,\n customerSlug,\n pullRequestUrl: pullRequest.pullRequestUrl,\n repository: INFRA_REPOSITORY,\n status: pullRequest.status,\n servicePath,\n targetPath: blueprintPath,\n };\n}\n\nexport async function registerAppCommand(appName: string): Promise<void> {\n try {\n const result = await registerApp(appName);\n\n if (result.status === \"already_registered\") {\n console.log(\n chalk.green(\"✔\"),\n `${result.appName} is already registered in ${result.repository} at`,\n chalk.cyan(result.targetPath),\n );\n return;\n }\n\n const verb =\n result.status === \"created_pr\" ? \"Created\" : \"Updated existing\";\n console.log(\n chalk.green(\"✔\"),\n `${verb} infra PR for ${result.appName}:`,\n chalk.cyan(result.pullRequestUrl),\n );\n } catch (error) {\n console.error(chalk.red(\"Error:\"), (error as Error).message);\n process.exit(1);\n }\n}\n\nexport function addAppDatabaseToBlueprint(\n blueprintContent: string,\n appName: string,\n): string {\n return updateBlueprint(blueprintContent, appName, {\n appDatabase: true,\n appInstallation: false,\n appInputs: false,\n });\n}\n\nexport function registerAppInBlueprint(\n blueprintContent: string,\n appName: string,\n): string {\n return updateBlueprint(blueprintContent, appName, {\n appDatabase: true,\n appInstallation: true,\n appInputs: true,\n });\n}\n\nfunction updateBlueprint(\n blueprintContent: string,\n appName: string,\n options: {\n appDatabase: boolean;\n appInstallation: boolean;\n appInputs: boolean;\n },\n): string {\n const document = parseDocument(blueprintContent);\n if (document.errors.length > 0) {\n throw new Error(\n `Invalid OS blueprint YAML: ${document.errors.map((error) => error.message).join(\"; \")}`,\n );\n }\n\n const spec = document.get(\"spec\", true);\n if (!isMap(spec)) {\n throw new Error(\"OS blueprint must include a spec map.\");\n }\n\n let changed = false;\n const inputs = spec.get(\"inputs\", true);\n if (!isSeq(inputs)) {\n throw new Error(\"OS blueprint spec.inputs must be a sequence.\");\n }\n\n if (options.appInputs) {\n changed =\n addAppInput(document, inputs, renderIngressDomainInput()) || changed;\n changed =\n addAppInput(document, inputs, renderBetterAuthSecretInput(appName)) ||\n changed;\n changed =\n addAppInput(document, inputs, renderInngestEventKeyInput()) || changed;\n changed =\n addAppInput(document, inputs, renderInngestSigningKeyInput()) || changed;\n changed =\n addAppInput(document, inputs, renderLangfusePublicKeyInput()) || changed;\n changed =\n addAppInput(document, inputs, renderLangfuseSecretKeyInput()) || changed;\n }\n\n if (options.appDatabase) {\n changed = addAppDatabase(document, inputs, appName) || changed;\n }\n\n if (options.appInstallation) {\n const installations = spec.get(\"installations\", true);\n if (!isSeq(installations)) {\n throw new Error(\"OS blueprint spec.installations must be a sequence.\");\n }\n changed = ensureOsPostgresqlInstallationAlias(installations) || changed;\n changed = addAppInstallation(document, installations, appName) || changed;\n }\n\n return changed ? document.toString() : blueprintContent;\n}\n\nfunction ensureOsPostgresqlInstallationAlias(installations: {\n items: unknown[];\n}): boolean {\n let changed = false;\n\n for (const installation of installations.items) {\n if (!isMap(installation)) continue;\n\n const service = installation.get(\"service\");\n if (\n typeof service !== \"string\" ||\n !OS_POSTGRESQL_TERRAFORM_SERVICES.has(service)\n ) {\n continue;\n }\n\n if (installation.get(\"name\") === OS_POSTGRESQL_TERRAFORM_ALIAS) continue;\n\n installation.set(\"name\", OS_POSTGRESQL_TERRAFORM_ALIAS);\n changed = true;\n }\n\n return changed;\n}\n\nfunction addAppInput(\n document: ReturnType<typeof parseDocument>,\n inputs: { add(value: unknown): void; items: unknown[] },\n input: Record<string, unknown> & { name: string },\n): boolean {\n if (\n inputs.items.some((item) => isMap(item) && item.get(\"name\") === input.name)\n ) {\n return false;\n }\n\n inputs.add(document.createNode(input));\n return true;\n}\n\nfunction addAppDatabase(\n document: ReturnType<typeof parseDocument>,\n inputs: { items: unknown[] },\n appName: string,\n): boolean {\n const appDatabasesInput = inputs.items.find(\n (item) => isMap(item) && item.get(\"name\") === \"app_databases\",\n );\n if (!isMap(appDatabasesInput)) {\n throw new Error(\"OS blueprint must include an app_databases input.\");\n }\n\n const defaultValue = appDatabasesInput.get(\"default\", true);\n if (!isMap(defaultValue)) {\n throw new Error(\"OS blueprint app_databases default must be a map.\");\n }\n\n if (defaultValue.has(appName)) return false;\n\n defaultValue.flow = false;\n const appDatabaseValue = document.createNode({});\n if (isMap(appDatabaseValue)) appDatabaseValue.flow = true;\n defaultValue.set(appName, appDatabaseValue);\n return true;\n}\n\nfunction addAppInstallation(\n document: ReturnType<typeof parseDocument>,\n installations: { add(value: unknown): void; items: unknown[] },\n appName: string,\n): boolean {\n if (\n installations.items.some(\n (item) => isMap(item) && item.get(\"service\") === appName,\n )\n ) {\n return false;\n }\n\n installations.add(\n document.createNode({\n service: appName,\n env: renderAppInstallationEnv(appName),\n config: renderAppInstallationConfig(appName),\n }),\n );\n return true;\n}\n\nfunction renderIngressDomainInput(): Record<string, unknown> & {\n name: string;\n} {\n return {\n name: ingressDomainInputName(),\n type: \"string\",\n group: \"Applications\",\n displayName: \"Ingress Domain\",\n description: \"Shared ingress domain for generated OS webapps.\",\n default: '{{ default \"example.local\" .ryvn.env.state.public_domain.name }}',\n };\n}\n\nfunction renderBetterAuthSecretInput(\n appName: string,\n): Record<string, unknown> & { name: string } {\n return {\n name: betterAuthSecretInputName(appName),\n type: \"string\",\n isSecret: true,\n group: \"Applications\",\n displayName: `${toTitleCase(appName)} Better Auth Secret`,\n description: `Generated Better Auth signing secret for ${appName}.`,\n hidden: true,\n generated: {\n type: \"random-bytes\",\n length: 32,\n },\n };\n}\n\nfunction renderInngestEventKeyInput(): Record<string, unknown> & {\n name: string;\n} {\n return {\n name: inngestEventKeyInputName(),\n type: \"string\",\n isSecret: true,\n group: \"Applications\",\n displayName: \"Inngest Event Key\",\n description:\n \"Shared Inngest event key for generated OS webapps. Leave unset when the target Inngest installation does not require one.\",\n };\n}\n\nfunction renderInngestSigningKeyInput(): Record<string, unknown> & {\n name: string;\n} {\n return {\n name: inngestSigningKeyInputName(),\n type: \"string\",\n isSecret: true,\n group: \"Applications\",\n displayName: \"Inngest Signing Key\",\n description:\n \"Shared Inngest signing key for generated OS webapps. Leave unset when the target Inngest installation does not require one.\",\n };\n}\n\nfunction renderLangfusePublicKeyInput(): Record<string, unknown> & {\n name: string;\n} {\n return {\n name: langfusePublicKeyInputName(),\n type: \"string\",\n group: \"Applications\",\n displayName: \"Langfuse Public Key\",\n description:\n \"Shared Langfuse public key for generated OS webapps. Leave empty to disable Langfuse export.\",\n default: \"\",\n };\n}\n\nfunction renderLangfuseSecretKeyInput(): Record<string, unknown> & {\n name: string;\n} {\n return {\n name: langfuseSecretKeyInputName(),\n type: \"string\",\n isSecret: true,\n group: \"Applications\",\n displayName: \"Langfuse Secret Key\",\n description:\n \"Shared Langfuse secret key for generated OS webapps. Leave unset to disable Langfuse export.\",\n };\n}\n\nfunction renderAppInstallationEnv(\n appName: string,\n): Array<Record<string, unknown>> {\n const appHost = `${appName}.{{ input \"${ingressDomainInputName()}\" }}`;\n\n return [\n {\n key: \"DATABASE_URL\",\n isSecret: true,\n valueFromOutput: {\n serviceInstallation: \"os-postgresql-terraform\",\n name: `app_database_urls.${appName}`,\n },\n },\n {\n key: \"AUTH_DATABASE_URL\",\n isSecret: true,\n valueFromOutput: {\n serviceInstallation: \"os-postgresql-terraform\",\n name: \"auth_database_url\",\n },\n },\n {\n key: \"APP_BASE_URL\",\n value: `https://${appHost}`,\n },\n {\n key: \"BETTER_AUTH_URL\",\n value: `https://${appHost}`,\n },\n {\n key: \"BETTER_AUTH_SECRET\",\n isSecret: true,\n valueFromInput: {\n name: betterAuthSecretInputName(appName),\n },\n },\n {\n key: \"NODE_ENV\",\n value: \"production\",\n },\n {\n key: \"PORT\",\n value: \"3000\",\n },\n {\n key: \"AUTH_TRUST_HOST\",\n value: \"true\",\n },\n {\n key: \"INNGEST_BASE_URL\",\n value: '{{ (blueprintInstallation \"mosaic\").outputs.inngest_base_url }}',\n },\n {\n key: \"INNGEST_APP_URL\",\n value: `http://${appName}-web-server.{{ EnvironmentNamespace }}.svc.cluster.local:3000/api/inngest`,\n },\n {\n key: \"INNGEST_EVENT_KEY\",\n isSecret: true,\n valueFromInput: {\n name: inngestEventKeyInputName(),\n },\n },\n {\n key: \"INNGEST_SIGNING_KEY\",\n isSecret: true,\n valueFromInput: {\n name: inngestSigningKeyInputName(),\n },\n },\n {\n key: \"LANGFUSE_BASE_URL\",\n value: '{{ (blueprintInstallation \"mosaic\").outputs.langfuse_base_url }}',\n },\n {\n key: \"LANGFUSE_PUBLIC_KEY\",\n valueFromInput: {\n name: langfusePublicKeyInputName(),\n },\n },\n {\n key: \"LANGFUSE_SECRET_KEY\",\n isSecret: true,\n valueFromInput: {\n name: langfuseSecretKeyInputName(),\n },\n },\n {\n key: \"OTEL_SERVICE_NAME\",\n value: appName,\n },\n {\n key: \"OTEL_RESOURCE_ATTRIBUTES\",\n value: `deployment.environment={{ EnvironmentName }},service.name=${appName}`,\n },\n {\n key: \"OTEL_TRACES_EXPORTER\",\n value: \"otlp\",\n },\n {\n key: \"OTEL_METRICS_EXPORTER\",\n value: \"otlp\",\n },\n {\n key: \"OTEL_EXPORTER_OTLP_PROTOCOL\",\n value: \"http/protobuf\",\n },\n {\n key: \"OTEL_EXPORTER_OTLP_ENDPOINT\",\n value:\n '{{ (blueprintInstallation \"mosaic\").outputs.otel_exporter_otlp_endpoint }}',\n },\n {\n key: \"SPICEDB_ENDPOINT\",\n value: '{{ (blueprintInstallation \"mosaic\").outputs.spicedb_endpoint }}',\n },\n {\n key: \"SPICEDB_PRESHARED_KEY\",\n isSecret: true,\n value:\n '{{ (blueprintInstallation \"mosaic\").outputs.spicedb_preshared_key }}',\n },\n {\n key: \"SPICEDB_INSECURE\",\n value: '{{ (blueprintInstallation \"mosaic\").outputs.spicedb_insecure }}',\n },\n ];\n}\n\nfunction renderAppInstallationConfig(appName: string): string {\n const appHost = `${appName}.{{ input \"${ingressDomainInputName()}\" }}`;\n\n return [\n \"replicaCount: 1\",\n \"\",\n \"service:\",\n \" port: 3000\",\n \"\",\n \"livenessEnabled: true\",\n \"readinessEnabled: true\",\n \"startupEnabled: true\",\n \"\",\n \"resources:\",\n \" requests:\",\n ' cpu: \"100m\"',\n \" memory: 256Mi\",\n \" limits:\",\n ' cpu: \"500m\"',\n \" memory: 512Mi\",\n \"\",\n \"ingress:\",\n \" enabled: true\",\n \" className: external-nginx\",\n \" annotations:\",\n \" cert-manager.io/cluster-issuer: external-issuer\",\n ' nginx.ingress.kubernetes.io/ssl-redirect: \"true\"',\n \" hosts:\",\n ` - host: '${appHost}'`,\n \" paths:\",\n \" - path: /\",\n \" pathType: Prefix\",\n \" tls:\",\n ` - secretName: ${appName}-tls`,\n \" hosts:\",\n ` - '${appHost}'`,\n \"\",\n ].join(\"\\n\");\n}\n\nasync function readLocalServiceDefinition(\n monorepoRoot: string,\n appName: string,\n): Promise<string> {\n const serviceDefinitionPath = path.join(\n monorepoRoot,\n \"packages\",\n appName,\n \"deploy\",\n \"ryvn\",\n `${appName}.service.yaml`,\n );\n if (!(await fs.pathExists(serviceDefinitionPath))) {\n throw new Error(\n `${serviceDefinitionPath} does not exist. Add the app's Ryvn service definition before registering it in infra.`,\n );\n }\n\n const content = await fs.readFile(serviceDefinitionPath, \"utf-8\");\n validateLocalServiceDefinition(content, appName, serviceDefinitionPath);\n return content.endsWith(\"\\n\") ? content : `${content}\\n`;\n}\n\nfunction validateLocalServiceDefinition(\n content: string,\n appName: string,\n serviceDefinitionPath: string,\n): void {\n const document = parseDocument(content);\n if (document.errors.length > 0) {\n throw new Error(\n `Invalid Ryvn service YAML at ${serviceDefinitionPath}: ${document.errors.map((error) => error.message).join(\"; \")}`,\n );\n }\n\n const service = document.toJS() as {\n kind?: unknown;\n metadata?: { name?: unknown };\n };\n if (service.kind !== \"Service\" || service.metadata?.name !== appName) {\n throw new Error(\n `${serviceDefinitionPath} must define kind: Service with metadata.name: ${appName}.`,\n );\n }\n}\n\nfunction ingressDomainInputName(): string {\n return \"ingress_domain\";\n}\n\nfunction betterAuthSecretInputName(appName: string): string {\n return `${toSnakeCase(appName)}_better_auth_secret`;\n}\n\nfunction inngestEventKeyInputName(): string {\n return \"inngest_event_key\";\n}\n\nfunction inngestSigningKeyInputName(): string {\n return \"inngest_signing_key\";\n}\n\nfunction langfusePublicKeyInputName(): string {\n return \"langfuse_public_key\";\n}\n\nfunction langfuseSecretKeyInputName(): string {\n return \"langfuse_secret_key\";\n}\n\nfunction normalizeAppName(appNameInput: string): string {\n const appName = toKebabCase(appNameInput);\n const validation = validateProjectName(appName);\n if (!validation.valid) {\n throw new Error(`Invalid app name: ${validation.error}`);\n }\n return appName;\n}\n"],"mappings":";;;;;;;;;AAsBA,MAAM,gCAAgC;AACtC,MAAM,mCAAmC,IAAI,IAAI,CAC/C,+BACA,gCACD,CAAC;AAeF,eAAsB,YACpB,cACA,OAGI,EAAE,EACsB;CAC5B,MAAM,UAAU,iBAAiB,aAAa;CAE9C,MAAM,kBAAkB,MAAM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ACE;EACH;;AAGH,SAAS,+BAEP;AACA,QAAO;EACL,MAAM,4BAA4B;EAClC,MAAM;EACN,OAAO;EACP,aAAa;EACb,aACE;EACF,SAAS;EACV;;AAGH,SAAS,+BAEP;AACA,QAAO;EACL,MAAM,4BAA4B;EAClC,MAAM;EACN,UAAU;EACV,OAAO;EACP,aAAa;EACb,aACE;EACH;;AAGH,SAAS,yBACP,SACgC;CAChC,MAAM,UAAU,GAAG,QAAQ,aAAa,wBAAwB,CAAC;AAEjE,QAAO;EACL;GACE,KAAK;GACL,UAAU;GACV,iBAAiB;IACf,qBAAqB;IACrB,MAAM,qBAAqB;IAC5B;GACF;EACD;GACE,KAAK;GACL,UAAU;GACV,iBAAiB;IACf,qBAAqB;IACrB,MAAM;IACP;GACF;EACD;GACE,KAAK;GACL,OAAO,WAAW;GACnB;EACD;GACE,KAAK;GACL,OAAO,WAAW;GACnB;EACD;GACE,KAAK;GACL,UAAU;GACV,gBAAgB,EACd,MAAM,0BAA0B,QAAQ,EACzC;GACF;EACD;GACE,KAAK;GACL,OAAO;GACR;EACD;GACE,KAAK;GACL,OAAO;GACR;EACD;GACE,KAAK;GACL,OAAO;GACR;EACD;GACE,KAAK;GACL,OAAO;GACR;EACD;GACE,KAAK;GACL,OAAO,UAAU,QAAQ;GAC1B;EACD;GACE,KAAK;GACL,UAAU;GACV,gBAAgB,EACd,MAAM,0BAA0B,EACjC;GACF;EACD;GACE,KAAK;GACL,UAAU;GACV,gBAAgB,EACd,MAAM,4BAA4B,EACnC;GACF;EACD;GACE,KAAK;GACL,OAAO;GACR;EACD;GACE,KAAK;GACL,gBAAgB,EACd,MAAM,4BAA4B,EACnC;GACF;EACD;GACE,KAAK;GACL,UAAU;GACV,gBAAgB,EACd,MAAM,4BAA4B,EACnC;GACF;EACD;GACE,KAAK;GACL,OAAO;GACR;EACD;GACE,KAAK;GACL,OAAO,6DAA6D;GACrE;EACD;GACE,KAAK;GACL,OAAO;GACR;EACD;GACE,KAAK;GACL,OAAO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