@wildo-ai/wildo-cli 1.1.3 → 1.1.4
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/src/commands/context/__tests__/assurance-basis.command.test.d.ts +2 -0
- package/dist/src/commands/context/__tests__/assurance-basis.command.test.d.ts.map +1 -0
- package/dist/src/commands/context/__tests__/assurance-basis.command.test.js +63 -0
- package/dist/src/commands/context/__tests__/assurance-basis.command.test.js.map +1 -0
- package/dist/src/commands/context/assurance-basis.command.d.ts +61 -0
- package/dist/src/commands/context/assurance-basis.command.d.ts.map +1 -0
- package/dist/src/commands/context/assurance-basis.command.js +166 -0
- package/dist/src/commands/context/assurance-basis.command.js.map +1 -0
- package/dist/src/commands/dev/charts-audit.command.d.ts +5 -3
- package/dist/src/commands/dev/charts-audit.command.d.ts.map +1 -1
- package/dist/src/commands/dev/charts-audit.command.js +35 -6
- package/dist/src/commands/dev/charts-audit.command.js.map +1 -1
- package/dist/src/commands/fwk/generate-providers.command.d.ts.map +1 -1
- package/dist/src/commands/fwk/generate-providers.command.js +18 -2
- package/dist/src/commands/fwk/generate-providers.command.js.map +1 -1
- package/dist/src/commands/generate/email-preview.command.d.ts +8 -0
- package/dist/src/commands/generate/email-preview.command.d.ts.map +1 -1
- package/dist/src/commands/generate/email-preview.command.js +57 -0
- package/dist/src/commands/generate/email-preview.command.js.map +1 -1
- package/dist/src/commands/init.command.d.ts.map +1 -1
- package/dist/src/commands/init.command.js +32 -0
- package/dist/src/commands/init.command.js.map +1 -1
- package/dist/src/commands/lock/check.command.d.ts.map +1 -1
- package/dist/src/commands/lock/check.command.js +3 -2
- package/dist/src/commands/lock/check.command.js.map +1 -1
- package/dist/src/commands/registry/login.command.d.ts.map +1 -1
- package/dist/src/commands/registry/login.command.js +2 -0
- package/dist/src/commands/registry/login.command.js.map +1 -1
- package/dist/src/commands/registry/publish.command.d.ts.map +1 -1
- package/dist/src/commands/registry/publish.command.js +2 -0
- package/dist/src/commands/registry/publish.command.js.map +1 -1
- package/dist/src/commands/registry/registry-transport.constants.d.ts +33 -0
- package/dist/src/commands/registry/registry-transport.constants.d.ts.map +1 -0
- package/dist/src/commands/registry/registry-transport.constants.js +33 -0
- package/dist/src/commands/registry/registry-transport.constants.js.map +1 -0
- package/dist/src/commands/registry/whoami.command.d.ts.map +1 -1
- package/dist/src/commands/registry/whoami.command.js +2 -0
- package/dist/src/commands/registry/whoami.command.js.map +1 -1
- package/dist/src/modules/domain/credentials/__tests__/approver-user.module.test.d.ts +2 -0
- package/dist/src/modules/domain/credentials/__tests__/approver-user.module.test.d.ts.map +1 -0
- package/dist/src/modules/domain/credentials/__tests__/approver-user.module.test.js +146 -0
- package/dist/src/modules/domain/credentials/__tests__/approver-user.module.test.js.map +1 -0
- package/dist/src/modules/domain/credentials/approver-user.module.d.ts +85 -0
- package/dist/src/modules/domain/credentials/approver-user.module.d.ts.map +1 -0
- package/dist/src/modules/domain/credentials/approver-user.module.js +92 -0
- package/dist/src/modules/domain/credentials/approver-user.module.js.map +1 -0
- package/dist/src/services/application/__tests__/app-bootstrap.approving-administrator.test.d.ts +2 -0
- package/dist/src/services/application/__tests__/app-bootstrap.approving-administrator.test.d.ts.map +1 -0
- package/dist/src/services/application/__tests__/app-bootstrap.approving-administrator.test.js +111 -0
- package/dist/src/services/application/__tests__/app-bootstrap.approving-administrator.test.js.map +1 -0
- package/dist/src/services/application/__tests__/provider-package-links.service.test.js +68 -0
- package/dist/src/services/application/__tests__/provider-package-links.service.test.js.map +1 -1
- package/dist/src/services/application/app-bootstrap.service.d.ts +9 -0
- package/dist/src/services/application/app-bootstrap.service.d.ts.map +1 -1
- package/dist/src/services/application/app-bootstrap.service.js +30 -1
- package/dist/src/services/application/app-bootstrap.service.js.map +1 -1
- package/dist/src/services/application/application-runtime-bootstrap.service.d.ts +6 -0
- package/dist/src/services/application/application-runtime-bootstrap.service.d.ts.map +1 -1
- package/dist/src/services/application/application-runtime-bootstrap.service.js +41 -0
- package/dist/src/services/application/application-runtime-bootstrap.service.js.map +1 -1
- package/dist/src/services/application/provider-package-links.service.d.ts +30 -0
- package/dist/src/services/application/provider-package-links.service.d.ts.map +1 -1
- package/dist/src/services/application/provider-package-links.service.js +35 -3
- package/dist/src/services/application/provider-package-links.service.js.map +1 -1
- package/dist/src/services/application/provider-runtime-sync.service.d.ts.map +1 -1
- package/dist/src/services/application/provider-runtime-sync.service.js +4 -3
- package/dist/src/services/application/provider-runtime-sync.service.js.map +1 -1
- package/dist/src/services/application/saas-skeleton.service.d.ts.map +1 -1
- package/dist/src/services/application/saas-skeleton.service.js +22 -2
- package/dist/src/services/application/saas-skeleton.service.js.map +1 -1
- package/dist/src/services/companion/workbench-cli.service.js +10 -1
- package/dist/src/services/companion/workbench-cli.service.js.map +1 -1
- package/dist/src/services/credentials/__tests__/provider-contribution-registration.guard.test.d.ts +2 -0
- package/dist/src/services/credentials/__tests__/provider-contribution-registration.guard.test.d.ts.map +1 -0
- package/dist/src/services/credentials/__tests__/provider-contribution-registration.guard.test.js +94 -0
- package/dist/src/services/credentials/__tests__/provider-contribution-registration.guard.test.js.map +1 -0
- package/dist/src/services/credentials/ci-secrets-adapter.service.d.ts.map +1 -1
- package/dist/src/services/credentials/ci-secrets-adapter.service.js +16 -0
- package/dist/src/services/credentials/ci-secrets-adapter.service.js.map +1 -1
- package/dist/src/services/credentials/composed-provider-catalogue.d.ts +34 -0
- package/dist/src/services/credentials/composed-provider-catalogue.d.ts.map +1 -1
- package/dist/src/services/credentials/composed-provider-catalogue.js +35 -0
- package/dist/src/services/credentials/composed-provider-catalogue.js.map +1 -1
- package/dist/src/services/credentials/credentials.schemas.d.ts +27 -0
- package/dist/src/services/credentials/credentials.schemas.d.ts.map +1 -1
- package/dist/src/services/credentials/credentials.schemas.js +50 -0
- package/dist/src/services/credentials/credentials.schemas.js.map +1 -1
- package/dist/src/services/credentials/framework-managed-secrets.d.ts +1 -1
- package/dist/src/services/credentials/framework-managed-secrets.d.ts.map +1 -1
- package/dist/src/services/credentials/framework-managed-secrets.js +49 -8
- package/dist/src/services/credentials/framework-managed-secrets.js.map +1 -1
- package/dist/src/services/deployment/infra-writer.service.d.ts.map +1 -1
- package/dist/src/services/deployment/infra-writer.service.js +23 -4
- package/dist/src/services/deployment/infra-writer.service.js.map +1 -1
- package/dist/src/services/deployment/k8s/__tests__/k8s-bootstrap.service.test.js +45 -2
- package/dist/src/services/deployment/k8s/__tests__/k8s-bootstrap.service.test.js.map +1 -1
- package/dist/src/services/deployment/k8s/k8s-bootstrap.service.d.ts +23 -0
- package/dist/src/services/deployment/k8s/k8s-bootstrap.service.d.ts.map +1 -1
- package/dist/src/services/deployment/k8s/k8s-bootstrap.service.js +49 -6
- package/dist/src/services/deployment/k8s/k8s-bootstrap.service.js.map +1 -1
- package/dist/src/services/environment/env-vars-builder.service.d.ts.map +1 -1
- package/dist/src/services/environment/env-vars-builder.service.js +19 -0
- package/dist/src/services/environment/env-vars-builder.service.js.map +1 -1
- package/dist/src/services/framework/__tests__/engine-provider-specifications.reconciliation.test.js +8 -0
- package/dist/src/services/framework/__tests__/engine-provider-specifications.reconciliation.test.js.map +1 -1
- package/dist/src/services/framework/__tests__/framework-knowledge-audit.live.contract.test.js +17 -0
- package/dist/src/services/framework/__tests__/framework-knowledge-audit.live.contract.test.js.map +1 -1
- package/dist/src/services/framework/__tests__/framework-knowledge-audit.service.test.js +51 -0
- package/dist/src/services/framework/__tests__/framework-knowledge-audit.service.test.js.map +1 -1
- package/dist/src/services/framework/framework-knowledge-audit.service.d.ts +41 -1
- package/dist/src/services/framework/framework-knowledge-audit.service.d.ts.map +1 -1
- package/dist/src/services/framework/framework-knowledge-audit.service.js +90 -0
- package/dist/src/services/framework/framework-knowledge-audit.service.js.map +1 -1
- package/dist/src/services/framework/provider-transposition/__tests__/base-url-is-a-declared-env-slot.test.d.ts +2 -0
- package/dist/src/services/framework/provider-transposition/__tests__/base-url-is-a-declared-env-slot.test.d.ts.map +1 -0
- package/dist/src/services/framework/provider-transposition/__tests__/base-url-is-a-declared-env-slot.test.js +100 -0
- package/dist/src/services/framework/provider-transposition/__tests__/base-url-is-a-declared-env-slot.test.js.map +1 -0
- package/dist/src/services/framework/provider-transposition/__tests__/plan-matches-emit.test.js +55 -2
- package/dist/src/services/framework/provider-transposition/__tests__/plan-matches-emit.test.js.map +1 -1
- package/dist/src/services/framework/provider-transposition/provider-package.emitter.d.ts +9 -0
- package/dist/src/services/framework/provider-transposition/provider-package.emitter.d.ts.map +1 -1
- package/dist/src/services/framework/provider-transposition/provider-package.emitter.js +139 -19
- package/dist/src/services/framework/provider-transposition/provider-package.emitter.js.map +1 -1
- package/dist/src/services/frontend/cloudflare-cdn.service.d.ts.map +1 -1
- package/dist/src/services/frontend/cloudflare-cdn.service.js +33 -2
- package/dist/src/services/frontend/cloudflare-cdn.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +17 -17
- package/scripts/app-dependency-alignment/propagated-engine-overrides.json +13 -0
- package/templates/infra/docker-compose/docker-compose.wildo-platform.yml.hbs +64 -16
- package/templates/saas/engine-peer-closure.json +12 -0
- package/templates/saas/scenarios/add-provider/scenario.json +11 -11
- package/templates/saas/scenarios/add-technical-doc/files/technical-doc/docusaurus.config.ts.hbs +34 -0
- package/templates/saas/scenarios/add-technical-doc/files/technical-doc/src/pages/auth/exchange.tsx +24 -1
- package/templates/saas/scenarios/add-technical-doc/files/technical-doc/src/theme/Root.tsx +22 -2
- package/templates/saas/skeleton/backend-api/package.json.hbs +1 -1
- package/templates/saas/skeleton/backend-api/src/companion-exports.ts +13 -2
- package/wildo-framework.info.json +1 -1
- package/templates/saas/scenarios/add-backend-provider/scenario.json +0 -17
- package/templates/saas/skeleton/backend-api/src/provider-contributions.ts +0 -44
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"approver-user.module.js","sourceRoot":"","sources":["../../../../../src/modules/domain/credentials/approver-user.module.ts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C,SAAU,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAS,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE;YACvH,UAAU,EAAE,0BAA0B,CAAC,MAAM;SAC9C,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,kBAAkB,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CACb,2DAA2D,MAAM,CAAC,MAAM,CAAC,2BAA2B,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI;cAClH,oIAAoI;cACpI,iFAAiF;cACjF,iIAAiI;cACjI,wDAAwD,CAC3D,CAAC;IACJ,CAAC;IAED,MAAM,QAAQ,GAAG,2BAA2B,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC3D,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,oDAAoD,QAAQ,CAAC,KAAK,gCAAgC,CAAC,CAAC,CAAC;IAC/H,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,0BAA0B,CAAC,0BAA0B,EAAE,CAAC;AACzF,CAAC;AAED,SAAS,OAAO,CAAC,GAAgC;IAC/C,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC;IACvC,OAAO,KAAK,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACvD,CAAC","sourcesContent":["import chalk from 'chalk';\n\nimport { WildoCliInitApproverEnvKeys } from '~wildo-cli/services/credentials/credentials.schemas';\nimport type { AdminUserInput } from '~wildo-cli/modules/domain/credentials/module.types';\nimport type { Logger } from '~wildo-cli/kernel/types';\n\n/**\n * The SECOND platform administrator — the one who approves an application-wide access grant (#575).\n *\n * ## Why a second identity is not optional\n *\n * `applicationAccessGrantApproverIsDistinct` refuses `operator === approver`, and refuses an ABSENT\n * approver too, so no system context can stand in. The application-scoped grant has deliberately no\n * auto-approval branch — the schema explains that the per-tenant grant may auto-approve because a\n * named tenant can opt in above it, while an application-wide grant names no tenant, so *\"a grant\n * that could approve itself would make the two-person rule ceremonial\"*.\n *\n * A platform with one administrator therefore cannot use the widest read it offers. Not \"is\n * discouraged from\" — cannot. The refusal was built and the party who discharges it never was, which\n * is the shape `.claude/rules/administrative-continuity-floors.md` exists to catch: a block shipped\n * without the paired path.\n *\n * ## Stated, or derived — never invented\n *\n * `admin-user.module.ts` documents at length why the administrator's identity is never a\n * placeholder: a literal `Admin` / `User` / `noreply@example.com` silently seeds the platform-admin\n * USER RECORD with non-meaningful identity, regressing audit trails, password-reset email and the\n * bootstrap email-confirm flow. That doctrine binds here too, and it is why there are exactly two\n * doors and no third:\n *\n * 1. **STATED** — `WILDO_INIT_APPROVER_*`, all four together. Available in every environment, and\n * the only door for a real second person.\n * 2. **DERIVED** — sub-addressed from the administrator the operator already supplied, for a LOCAL\n * environment only.\n *\n * The derived form is not a placeholder: every field of it comes from a real identity the operator\n * authored moments earlier. `ada@example.com` becomes `ada+approver@example.com`, which RFC 5233\n * sub-addressing delivers to the same mailbox — so one developer can complete both legs of the\n * ceremony without a second inbox, which is the whole point of deriving rather than prompting again.\n *\n * ## The local property that must never travel\n *\n * The derived approver shares the administrator's password, so locally ONE PERSON HOLDS BOTH\n * SIGNATURES and the two-person rule is ceremonial there. That is the accepted trade — the\n * alternative is a developer who cannot exercise an application-wide read at all — and it is exactly\n * why {@link resolveApproverIdentity} takes `isLocalEnvironment` as an argument it cannot infer.\n * A caller must SAY that it is local; nothing here guesses, and no environment acquires the\n * derivation by default.\n */\nexport interface ApproverIdentityResolution {\n readonly approver: AdminUserInput;\n /** How the identity was obtained — reported to the operator, because the two differ in strength. */\n readonly provenance: ApproverIdentityProvenance;\n}\n\nexport enum ApproverIdentityProvenance {\n /** Every field came from `WILDO_INIT_APPROVER_*`. A real second person. */\n STATED = 'stated',\n /** Sub-addressed from the administrator, local only. One human, two accounts. */\n DERIVED_FROM_ADMINISTRATOR = 'derived-from-administrator',\n}\n\n/**\n * Sub-address a local approver from the administrator's own identity.\n *\n * Exported for its own pin. The rule is the whole contract and is easy to get subtly wrong: the tag\n * goes before the `@`, an address that ALREADY carries a `+tag` must not grow a second one (that\n * produces `ada+ci+approver@…`, a third mailbox nobody asked for), and the name fields carry through\n * unchanged because they describe the same human.\n */\nexport function deriveLocalApproverIdentity(admin: AdminUserInput): AdminUserInput {\n const separatorIndex = admin.email.lastIndexOf('@');\n const localPart = admin.email.slice(0, separatorIndex);\n const domain = admin.email.slice(separatorIndex + 1);\n // An existing `+tag` is REPLACED, not appended to: `ada+ci@x` and `ada@x` must both derive\n // `ada+approver@x`, or a CI environment and a laptop would disagree about who the approver is\n // while both believing they had derived one.\n const baseLocalPart = localPart.includes('+') ? localPart.slice(0, localPart.indexOf('+')) : localPart;\n\n return {\n email: `${baseLocalPart}+approver@${domain}`,\n firstName: admin.firstName,\n lastName: admin.lastName,\n password: admin.password,\n };\n}\n\n/**\n * Resolve the approver identity for an environment, or refuse.\n *\n * `isLocalEnvironment` is a required argument rather than something read from the ambient\n * environment, so that no caller acquires the derivation by omission. A remote deployment states its\n * approver or gets nothing — and \"nothing\" here is a thrown error, because an approver silently\n * absent is a platform whose widest read stops working weeks later, at a moment nobody connects to\n * setup.\n *\n * `admin.password` may be `undefined` at this point (the secrets writer mints one when the operator\n * typed none), and the derived approver inherits that. The caller resolves both passwords from the\n * same place afterwards, which is what keeps \"same password as the administrator\" true rather than\n * approximately true.\n */\nexport function resolveApproverIdentity(params: {\n readonly admin: AdminUserInput;\n readonly isLocalEnvironment: boolean;\n readonly log: Logger;\n}): ApproverIdentityResolution {\n const stated = {\n email: readEnv(WildoCliInitApproverEnvKeys.WILDO_INIT_APPROVER_EMAIL),\n firstName: readEnv(WildoCliInitApproverEnvKeys.WILDO_INIT_APPROVER_FIRSTNAME),\n lastName: readEnv(WildoCliInitApproverEnvKeys.WILDO_INIT_APPROVER_LASTNAME),\n password: readEnv(WildoCliInitApproverEnvKeys.WILDO_INIT_APPROVER_PASSWORD),\n };\n\n const statedKeys = Object.entries(stated).filter(([, value]) => Boolean(value));\n\n // A PARTIAL set is an operator mistake, never a request to fall back — the same reading\n // `init.command.ts` applies to a partial `--admin-*` flag set. Falling through to the derivation\n // here would silently discard the fields that WERE supplied and hand back a different person.\n if (statedKeys.length > 0 && statedKeys.length < 4) {\n const missing = Object.values(WildoCliInitApproverEnvKeys).filter((key) => !process.env[key]?.trim());\n throw new Error(\n `The approving administrator is partially stated. Missing: ${missing.join(', ')}. `\n + `Set all four, or set none — a partial set would silently produce a different identity than the one intended.`,\n );\n }\n\n if (statedKeys.length === 4) {\n if (stated.email === params.admin.email) {\n // The two-person rule compares USER IDs at the moment of approval, so two identical identities\n // would provision one account and refuse every approval — a failure that surfaces far from\n // here and reads as a permissions bug. Refuse where the cause is visible.\n throw new Error(\n `${WildoCliInitApproverEnvKeys.WILDO_INIT_APPROVER_EMAIL} is the same address as the administrator's. `\n + `The approving administrator must be a DIFFERENT person: an application-wide access grant refuses an approver who is its own requester.`,\n );\n }\n params.log.info(chalk.dim(` Approving administrator from env seeds: ${stated.email}`));\n return {\n approver: { email: stated.email!, firstName: stated.firstName!, lastName: stated.lastName!, password: stated.password },\n provenance: ApproverIdentityProvenance.STATED,\n };\n }\n\n if (!params.isLocalEnvironment) {\n throw new Error(\n `This environment states no approving administrator. Set ${Object.values(WildoCliInitApproverEnvKeys).join(', ')}. `\n + `An application-wide access grant is approved by a SECOND platform administrator and refuses an approver who is its own requester, `\n + `so a platform with one administrator cannot read any application-wide surface. `\n + `Only a local environment may derive the second identity from the first, and it does so only because one developer holds both — `\n + `which is precisely what a real deployment must not do.`,\n );\n }\n\n const approver = deriveLocalApproverIdentity(params.admin);\n params.log.info(chalk.dim(` Approving administrator derived for local use: ${approver.email} (same mailbox, same password)`));\n return { approver, provenance: ApproverIdentityProvenance.DERIVED_FROM_ADMINISTRATOR };\n}\n\nfunction readEnv(key: WildoCliInitApproverEnvKeys): string | undefined {\n const value = process.env[key]?.trim();\n return value && value.length > 0 ? value : undefined;\n}\n"]}
|
package/dist/src/services/application/__tests__/app-bootstrap.approving-administrator.test.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-bootstrap.approving-administrator.test.d.ts","sourceRoot":"","sources":["../../../../../src/services/application/__tests__/app-bootstrap.approving-administrator.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The CLI carries the SECOND administrator into the generated application (#575).
|
|
3
|
+
*
|
|
4
|
+
* ## Why this is the site that matters
|
|
5
|
+
*
|
|
6
|
+
* When the CLI half of #575 landed, this site was enumerated as *"read only — no change expected"*.
|
|
7
|
+
* That was wrong, and the correction is the whole point of this file: `applicationAccessGrants` has
|
|
8
|
+
* ZERO mentions under `platform/` — it is an ENGINE resource, so the two-person rule bites inside the
|
|
9
|
+
* GENERATED APPLICATION, not on the platform plane. `ensureApplicationRegistered` is the request
|
|
10
|
+
* that carries an identity into that application's own database, where `_getDefault_App_FirstUser`
|
|
11
|
+
* is the only writer of `APP_ADMIN_SUPER_ADMIN` at provisioning time.
|
|
12
|
+
*
|
|
13
|
+
* A hop pinned nowhere else. The apps-manager doors are pinned to forward what they RECEIVE, and
|
|
14
|
+
* the lifecycle layer to seed what it is GIVEN; if this request omits the approver, both stay green
|
|
15
|
+
* and every application still ships with one super-administrator.
|
|
16
|
+
*/
|
|
17
|
+
import { describe, expect, it, vi, beforeEach } from 'vitest';
|
|
18
|
+
import { AdminAppInitializeRequestSchema, ApproverIdentityCompleteness, classifyApproverIdentity, } from '@wildo-ai/platform-config-lib';
|
|
19
|
+
import { AppBootstrapService } from '../app-bootstrap.service.js';
|
|
20
|
+
const MANAGED_DECLARATION = {
|
|
21
|
+
app: { name: 'Wonder Todos', slug: 'wonder-todos', displayName: 'Wonder Todos', type: 'saas' },
|
|
22
|
+
frontendServices: [],
|
|
23
|
+
minions: {},
|
|
24
|
+
workers: {},
|
|
25
|
+
engineCapabilities: {},
|
|
26
|
+
providers: { scopes: {}, connections: {} },
|
|
27
|
+
providerConfigurations: {},
|
|
28
|
+
};
|
|
29
|
+
const ADMIN = { email: 'ada@example.com', password: 'first-secret', firstName: 'Ada', lastName: 'Lovelace' };
|
|
30
|
+
const APPROVER = { email: 'ada+approver@example.com', password: 'second-secret', firstName: 'Ada', lastName: 'Lovelace' };
|
|
31
|
+
/** The parsed body the request carried, or `undefined` when the call was never made. */
|
|
32
|
+
async function bodySentFor(credentials) {
|
|
33
|
+
let sent;
|
|
34
|
+
const requestJson = vi
|
|
35
|
+
.spyOn(AppBootstrapService, 'requestJson')
|
|
36
|
+
.mockImplementation(async (..._args) => {
|
|
37
|
+
const init = _args[3];
|
|
38
|
+
sent = init?.body ? JSON.parse(init.body) : undefined;
|
|
39
|
+
// The real response shape — `ensureApplicationRegistered` parses it through
|
|
40
|
+
// `AdminAppInitializeResponseSchema`, so a loose stub makes the method throw before it has
|
|
41
|
+
// told us anything about the body it SENT.
|
|
42
|
+
return {
|
|
43
|
+
success: true,
|
|
44
|
+
application: { name: 'Wonder Todos', slug: 'wonder-todos' },
|
|
45
|
+
credentials: { email: 'ada@example.com', password: 'first-secret' },
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
await AppBootstrapService.ensureApplicationRegistered({ serviceAuth: undefined }, credentials, { appSlug: 'wonder-todos', appDisplayName: 'Wonder Todos', managedDeclaration: MANAGED_DECLARATION });
|
|
49
|
+
requestJson.mockRestore();
|
|
50
|
+
return sent;
|
|
51
|
+
}
|
|
52
|
+
describe('#575 the CLI forwards the approving administrator', () => {
|
|
53
|
+
beforeEach(() => { vi.restoreAllMocks(); });
|
|
54
|
+
it('CA-1 sends the approver from `secrets.json` alongside the administrator', async () => {
|
|
55
|
+
const body = await bodySentFor({ admin: ADMIN, approver: APPROVER });
|
|
56
|
+
expect(body).toMatchObject({
|
|
57
|
+
userEmail: 'ada@example.com',
|
|
58
|
+
approverEmail: 'ada+approver@example.com',
|
|
59
|
+
approverFirstName: 'Ada',
|
|
60
|
+
approverLastName: 'Lovelace',
|
|
61
|
+
approverPassword: 'second-secret',
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
it('CA-2 OMITS the fields entirely when `secrets.json` predates the approver block', async () => {
|
|
65
|
+
/*
|
|
66
|
+
* Absence must be absence, not four `undefined`s. `approver` is `.optional()` precisely so a
|
|
67
|
+
* secrets file written before this existed still parses, and the apps-manager door classifies a
|
|
68
|
+
* PARTIAL identity as an operator mistake and refuses it — so a body carrying the keys with no
|
|
69
|
+
* values would turn every pre-existing environment's next provisioning run into a 400.
|
|
70
|
+
*
|
|
71
|
+
* ## What actually guarantees this, measured rather than assumed
|
|
72
|
+
*
|
|
73
|
+
* `JSON.stringify` drops a key whose value is `undefined`, so the wire is clean whether the
|
|
74
|
+
* producer spreads conditionally or writes `approverEmail: credentials.approver?.email`.
|
|
75
|
+
* Mutation-checked: replacing the conditional spread with unconditional optional-chaining left
|
|
76
|
+
* this pin GREEN. It was passing for a reason it did not name.
|
|
77
|
+
*
|
|
78
|
+
* The assertion is kept, because the WIRE is the contract and this is the only pin on it. What
|
|
79
|
+
* changed is the claim: this does NOT discriminate the producer's shape. The conditional spread
|
|
80
|
+
* is belt-and-braces against a future non-JSON transport or a schema default, and CA-3 below
|
|
81
|
+
* pins the schema behaviour it guards. Do not read a green CA-2 as proof the spread survives.
|
|
82
|
+
*/
|
|
83
|
+
const body = await bodySentFor({ admin: ADMIN });
|
|
84
|
+
expect(body?.userEmail).toBe('ada@example.com');
|
|
85
|
+
expect('approverEmail' in (body ?? {})).toBe(false);
|
|
86
|
+
expect('approverPassword' in (body ?? {})).toBe(false);
|
|
87
|
+
});
|
|
88
|
+
it('CA-3 an explicitly-undefined approver key still parses as ABSENT, never as a partial identity', () => {
|
|
89
|
+
/*
|
|
90
|
+
* The property CA-2 depends on, asserted where it lives. If `approverEmail` ever gained a
|
|
91
|
+
* default, or the schema stopped accepting an explicit `undefined`, a `secrets.json` with no
|
|
92
|
+
* approver would start sending a half-stated identity — and the receiving door refuses those.
|
|
93
|
+
* That failure would surface as "provisioning suddenly 400s on every existing environment", with
|
|
94
|
+
* nothing pointing here.
|
|
95
|
+
*/
|
|
96
|
+
const parsed = AdminAppInitializeRequestSchema.parse({
|
|
97
|
+
userEmail: 'ada@example.com',
|
|
98
|
+
userFirstName: 'Ada',
|
|
99
|
+
userLastName: 'Lovelace',
|
|
100
|
+
managedDeclaration: MANAGED_DECLARATION,
|
|
101
|
+
approverEmail: undefined,
|
|
102
|
+
approverFirstName: undefined,
|
|
103
|
+
approverLastName: undefined,
|
|
104
|
+
approverPassword: undefined,
|
|
105
|
+
});
|
|
106
|
+
expect(classifyApproverIdentity({
|
|
107
|
+
email: parsed.approverEmail, firstName: parsed.approverFirstName, lastName: parsed.approverLastName,
|
|
108
|
+
}).completeness).toBe(ApproverIdentityCompleteness.ABSENT);
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
//# sourceMappingURL=app-bootstrap.approving-administrator.test.js.map
|
package/dist/src/services/application/__tests__/app-bootstrap.approving-administrator.test.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-bootstrap.approving-administrator.test.js","sourceRoot":"","sources":["../../../../../src/services/application/__tests__/app-bootstrap.approving-administrator.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAE9D,OAAO,EACL,+BAA+B,EAC/B,4BAA4B,EAC5B,wBAAwB,GACzB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,MAAM,mBAAmB,GAAG;IAC1B,GAAG,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,c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C,CAAC,CAAC;IAEH,EAAE,CAAC,+FAA+F,EAAE,GAAG,EAAE;QACvG;;;;;;WAMG;QACH,MAAM,MAAM,GAAG,+BAA+B,CAAC,KAAK,CAAC;YACnD,SAAS,EAAE,iBAAiB;YAC5B,aAAa,EAAE,KAAK;YACpB,YAAY,EAAE,UAAU;YACxB,kBAAkB,EAAE,mBAAmB;YACvC,aAAa,EAAE,SAAS;YACxB,iBAAiB,EAAE,SAAS;YAC5B,gBAAgB,EAAE,SAAS;YAC3B,gBAAgB,EAAE,SAAS;SAC5B,CAAC,CAAC;QAEH,MAAM,CAAC,wBAAwB,CAAC;YAC9B,KAAK,EAAE,MAAM,CAAC,aAAa,EAAE,SAAS,EAAE,MAAM,CAAC,iBAAiB,EAAE,QAAQ,EAAE,MAAM,CAAC,gBAAgB;SACpG,CAAC,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,4BAA4B,CAAC,MAAM,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["/**\n * The CLI carries the SECOND administrator into the generated application (#575).\n *\n * ## Why this is the site that matters\n *\n * When the CLI half of #575 landed, this site was enumerated as *\"read only — no change expected\"*.\n * That was wrong, and the correction is the whole point of this file: `applicationAccessGrants` has\n * ZERO mentions under `platform/` — it is an ENGINE resource, so the two-person rule bites inside the\n * GENERATED APPLICATION, not on the platform plane. `ensureApplicationRegistered` is the request\n * that carries an identity into that application's own database, where `_getDefault_App_FirstUser`\n * is the only writer of `APP_ADMIN_SUPER_ADMIN` at provisioning time.\n *\n * A hop pinned nowhere else. The apps-manager doors are pinned to forward what they RECEIVE, and\n * the lifecycle layer to seed what it is GIVEN; if this request omits the approver, both stay green\n * and every application still ships with one super-administrator.\n */\nimport { describe, expect, it, vi, beforeEach } from 'vitest';\n\nimport {\n AdminAppInitializeRequestSchema,\n ApproverIdentityCompleteness,\n classifyApproverIdentity,\n} from '@wildo-ai/platform-config-lib';\n\nimport { AppBootstrapService } from '../app-bootstrap.service';\n\nconst MANAGED_DECLARATION = {\n app: { name: 'Wonder Todos', slug: 'wonder-todos', displayName: 'Wonder Todos', type: 'saas' as const },\n frontendServices: [],\n minions: {},\n workers: {},\n engineCapabilities: {},\n providers: { scopes: {}, connections: {} },\n providerConfigurations: {},\n};\n\nconst ADMIN = { email: 'ada@example.com', password: 'first-secret', firstName: 'Ada', lastName: 'Lovelace' };\nconst APPROVER = { email: 'ada+approver@example.com', password: 'second-secret', firstName: 'Ada', lastName: 'Lovelace' };\n\n/** The parsed body the request carried, or `undefined` when the call was never made. */\nasync function bodySentFor(credentials: Record<string, unknown>): Promise<Record<string, unknown> | undefined> {\n let sent: Record<string, unknown> | undefined;\n const requestJson = vi\n .spyOn(AppBootstrapService as never, 'requestJson' as never)\n .mockImplementation(async (..._args: unknown[]) => {\n const init = _args[3] as { body?: string };\n sent = init?.body ? JSON.parse(init.body) as Record<string, unknown> : undefined;\n // The real response shape — `ensureApplicationRegistered` parses it through\n // `AdminAppInitializeResponseSchema`, so a loose stub makes the method throw before it has\n // told us anything about the body it SENT.\n return {\n success: true,\n application: { name: 'Wonder Todos', slug: 'wonder-todos' },\n credentials: { email: 'ada@example.com', password: 'first-secret' },\n };\n });\n\n await (AppBootstrapService as never as {\n ensureApplicationRegistered: (env: unknown, credentials: unknown, input: unknown) => Promise<unknown>;\n }).ensureApplicationRegistered(\n { serviceAuth: undefined } as never,\n credentials as never,\n { appSlug: 'wonder-todos', appDisplayName: 'Wonder Todos', managedDeclaration: MANAGED_DECLARATION } as never,\n );\n\n requestJson.mockRestore();\n return sent;\n}\n\ndescribe('#575 the CLI forwards the approving administrator', () => {\n beforeEach(() => { vi.restoreAllMocks(); });\n\n it('CA-1 sends the approver from `secrets.json` alongside the administrator', async () => {\n const body = await bodySentFor({ admin: ADMIN, approver: APPROVER });\n\n expect(body).toMatchObject({\n userEmail: 'ada@example.com',\n approverEmail: 'ada+approver@example.com',\n approverFirstName: 'Ada',\n approverLastName: 'Lovelace',\n approverPassword: 'second-secret',\n });\n });\n\n it('CA-2 OMITS the fields entirely when `secrets.json` predates the approver block', async () => {\n /*\n * Absence must be absence, not four `undefined`s. `approver` is `.optional()` precisely so a\n * secrets file written before this existed still parses, and the apps-manager door classifies a\n * PARTIAL identity as an operator mistake and refuses it — so a body carrying the keys with no\n * values would turn every pre-existing environment's next provisioning run into a 400.\n *\n * ## What actually guarantees this, measured rather than assumed\n *\n * `JSON.stringify` drops a key whose value is `undefined`, so the wire is clean whether the\n * producer spreads conditionally or writes `approverEmail: credentials.approver?.email`.\n * Mutation-checked: replacing the conditional spread with unconditional optional-chaining left\n * this pin GREEN. It was passing for a reason it did not name.\n *\n * The assertion is kept, because the WIRE is the contract and this is the only pin on it. What\n * changed is the claim: this does NOT discriminate the producer's shape. The conditional spread\n * is belt-and-braces against a future non-JSON transport or a schema default, and CA-3 below\n * pins the schema behaviour it guards. Do not read a green CA-2 as proof the spread survives.\n */\n const body = await bodySentFor({ admin: ADMIN });\n\n expect(body?.userEmail).toBe('ada@example.com');\n expect('approverEmail' in (body ?? {})).toBe(false);\n expect('approverPassword' in (body ?? {})).toBe(false);\n });\n\n it('CA-3 an explicitly-undefined approver key still parses as ABSENT, never as a partial identity', () => {\n /*\n * The property CA-2 depends on, asserted where it lives. If `approverEmail` ever gained a\n * default, or the schema stopped accepting an explicit `undefined`, a `secrets.json` with no\n * approver would start sending a half-stated identity — and the receiving door refuses those.\n * That failure would surface as \"provisioning suddenly 400s on every existing environment\", with\n * nothing pointing here.\n */\n const parsed = AdminAppInitializeRequestSchema.parse({\n userEmail: 'ada@example.com',\n userFirstName: 'Ada',\n userLastName: 'Lovelace',\n managedDeclaration: MANAGED_DECLARATION,\n approverEmail: undefined,\n approverFirstName: undefined,\n approverLastName: undefined,\n approverPassword: undefined,\n });\n\n expect(classifyApproverIdentity({\n email: parsed.approverEmail, firstName: parsed.approverFirstName, lastName: parsed.approverLastName,\n }).completeness).toBe(ApproverIdentityCompleteness.ABSENT);\n });\n});\n"]}
|
|
@@ -153,4 +153,72 @@ describe('ProviderPackageLinksService', () => {
|
|
|
153
153
|
expect(ProviderPackageLinksService.discoverDeclaredProviderPackages(applicationRoot)).toEqual([]);
|
|
154
154
|
});
|
|
155
155
|
});
|
|
156
|
+
/**
|
|
157
|
+
* The CATALOGUE package, which is the shape that actually ships.
|
|
158
|
+
*
|
|
159
|
+
* Everything above declares `@wildo-ai/provider-<ref>` — one package per vendor, the population
|
|
160
|
+
* this service was designed around (issue #334, slice S6). That shape was reversed on 2026-09-06
|
|
161
|
+
* for ONE package with a subpath per vendor, and the matcher was never moved: measured 2026-09-09,
|
|
162
|
+
* **no `@wildo-ai/provider-<ref>` package exists anywhere in the repository**, while both dogfood
|
|
163
|
+
* applications declare `@wildo-ai/providers`.
|
|
164
|
+
*
|
|
165
|
+
* So the service ran at both of its production call sites, matched nothing, and reported success —
|
|
166
|
+
* the quietest possible failure, and one no test above could see, because every fixture here was
|
|
167
|
+
* written in the vocabulary the matcher understood. An application adding its first catalogue
|
|
168
|
+
* provider got the dependency and no override, and could not install.
|
|
169
|
+
*/
|
|
170
|
+
describe('the catalogue package is one package, and the service must link it', () => {
|
|
171
|
+
/** A framework checkout in the shape that ships: ONE catalogue package at `providers/`. */
|
|
172
|
+
function buildCatalogueCheckout() {
|
|
173
|
+
const frameworkRoot = makeTempDirectory('wildo-framework-catalogue-');
|
|
174
|
+
writeFileSync(join(frameworkRoot, 'pnpm-workspace.yaml'), "packages:\n - 'engine/saas-models'\n - 'providers'\n", 'utf8');
|
|
175
|
+
writeFileSync(join(frameworkRoot, 'wildo-framework.info.json'), JSON.stringify({ version: '1.4.2' }), 'utf8');
|
|
176
|
+
writeManifest(frameworkRoot, 'engine/saas-models', { name: '@wildo-ai/saas-models', version: '1.4.2' });
|
|
177
|
+
writeManifest(frameworkRoot, 'providers', { name: '@wildo-ai/providers', version: '1.4.2' });
|
|
178
|
+
return frameworkRoot;
|
|
179
|
+
}
|
|
180
|
+
it('links @wildo-ai/providers when the application declares it', () => {
|
|
181
|
+
const frameworkRoot = buildCatalogueCheckout();
|
|
182
|
+
const applicationRoot = buildApplication({
|
|
183
|
+
'backend-api': { '@wildo-ai/saas-backend-lib': '*', '@wildo-ai/providers': '*' },
|
|
184
|
+
frontend: { react: '*' },
|
|
185
|
+
});
|
|
186
|
+
const result = ProviderPackageLinksService.reconcileAndReport({ applicationRoot, frameworkPath: frameworkRoot, log: silentLog });
|
|
187
|
+
expect(result.declared).toEqual(['@wildo-ai/providers']);
|
|
188
|
+
expect(result.added).toHaveLength(1);
|
|
189
|
+
const overrides = JSON.parse(readFileSync(join(applicationRoot, 'package.json'), 'utf8')).pnpm.overrides;
|
|
190
|
+
// The exact thing that had to be hand-written in Wonder Todos on 2026-09-09.
|
|
191
|
+
expect(overrides['@wildo-ai/providers']).toMatch(/^file:.*providers$/);
|
|
192
|
+
expect(overrides['@wildo-ai/saas-models']).toBe('file:../../engine/saas-models');
|
|
193
|
+
});
|
|
194
|
+
it('still leaves an application that declares no provider alone — the control', () => {
|
|
195
|
+
// Without this, a matcher that linked the catalogue unconditionally would pass the case above.
|
|
196
|
+
// Demand-driven is the property the whole service exists for, and widening the matcher is
|
|
197
|
+
// exactly the change that could lose it.
|
|
198
|
+
const frameworkRoot = buildCatalogueCheckout();
|
|
199
|
+
const applicationRoot = buildApplication({ 'backend-api': { '@wildo-ai/saas-backend-lib': '*' } });
|
|
200
|
+
const result = ProviderPackageLinksService.reconcileAndReport({ applicationRoot, frameworkPath: frameworkRoot, log: silentLog });
|
|
201
|
+
expect(result.declared).toEqual([]);
|
|
202
|
+
expect(result.added).toEqual([]);
|
|
203
|
+
const overrides = JSON.parse(readFileSync(join(applicationRoot, 'package.json'), 'utf8')).pnpm.overrides;
|
|
204
|
+
expect(overrides['@wildo-ai/providers']).toBeUndefined();
|
|
205
|
+
});
|
|
206
|
+
it('links the catalogue and a per-vendor package together, so neither shape displaces the other', () => {
|
|
207
|
+
// The prefix was KEPT rather than replaced: an application-owned or future per-vendor package is
|
|
208
|
+
// still a provider this service links. One predicate answers for both, so a call site cannot
|
|
209
|
+
// remember only one — which is how the matcher came to see nothing at all.
|
|
210
|
+
const frameworkRoot = makeTempDirectory('wildo-framework-both-');
|
|
211
|
+
writeFileSync(join(frameworkRoot, 'pnpm-workspace.yaml'), "packages:\n - 'engine/saas-models'\n - 'providers'\n - 'providers-owned/*'\n", 'utf8');
|
|
212
|
+
writeFileSync(join(frameworkRoot, 'wildo-framework.info.json'), JSON.stringify({ version: '1.4.2' }), 'utf8');
|
|
213
|
+
writeManifest(frameworkRoot, 'engine/saas-models', { name: '@wildo-ai/saas-models', version: '1.4.2' });
|
|
214
|
+
writeManifest(frameworkRoot, 'providers', { name: '@wildo-ai/providers', version: '1.4.2' });
|
|
215
|
+
writeManifest(frameworkRoot, 'providers-owned/acme', { name: '@wildo-ai/provider-acme', version: '1.4.2' });
|
|
216
|
+
const applicationRoot = buildApplication({
|
|
217
|
+
'backend-api': { '@wildo-ai/providers': '*', '@wildo-ai/provider-acme': '*' },
|
|
218
|
+
});
|
|
219
|
+
const result = ProviderPackageLinksService.reconcileAndReport({ applicationRoot, frameworkPath: frameworkRoot, log: silentLog });
|
|
220
|
+
expect(result.declared).toEqual(['@wildo-ai/provider-acme', '@wildo-ai/providers']);
|
|
221
|
+
expect(result.added).toHaveLength(2);
|
|
222
|
+
});
|
|
223
|
+
});
|
|
156
224
|
//# sourceMappingURL=provider-package-links.service.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider-package-links.service.test.js","sourceRoot":"","sources":["../../../../../src/services/application/__tests__/provider-package-links.service.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AACjF,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAC5B,OAA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EAAE,SAAS,EAAE,CAAC,CAAC;QAEjI,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,6BAA6B,CAAC,CAAC,CAAC;QAChE,MAAM,SAAS,GAAI,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,eAAe,EAAE,cAAc,CAAC,EAAE,MAAM,CAAC,CAEvF,CAAC,IAAI,CAAC,SAAS,CAAC;QAClB,MAAM,CAAC,SAAS,CAAC,6BAA6B,CAAC,CAAC,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAC;IACzF,CAAC,CAAC,CAAC;IAEH,6GAA6G;IAC7G,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;QAC9C,MAAM,eAAe,GAAG,gBAAgB,CAAC,EAAE,aAAa,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;QAC5E,aAAa,CACX,IAAI,CAAC,eAAe,EAAE,qBAAqB,CAAC,EAC5C,uEAAuE,EACvE,MAAM,CACP,CAAC;QACF,aAAa,CAAC,eAAe,EAAE,iCAAiC,EAAE;YAChE,IAAI,EAAE,iBAAiB;YACvB,YAAY,EAAE,EAAE,0BAA0B,EAAE,GAAG,EAAE;SAClD,CAAC,CAAC;QAEH,MAAM,CAAC,2BAA2B,CAAC,gCAAgC,CAAC,eAAe,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACpG,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'fs';\nimport { join } from 'path';\nimport { tmpdir } from 'os';\nimport { afterEach, describe, expect, it } from 'vitest';\nimport { ProviderPackageLinksService } from '~wildo-cli/services/application/provider-package-links.service';\n\nconst tempDirs: string[] = [];\nafterEach(() => {\n for (const dir of tempDirs.splice(0)) rmSync(dir, { recursive: true, force: true });\n});\n\nfunction makeTempDirectory(prefix: string): string {\n const dir = mkdtempSync(join(tmpdir(), prefix));\n tempDirs.push(dir);\n return dir;\n}\n\nfunction writeManifest(root: string, memberRelative: string, manifest: unknown): void {\n const directory = join(root, memberRelative);\n mkdirSync(directory, { recursive: true });\n writeFileSync(join(directory, 'package.json'), `${JSON.stringify(manifest, null, 2)}\\n`, 'utf8');\n}\n\n/**\n * A framework checkout carrying two provider packages and one engine package, discovered through\n * the `providers/*` workspace glob — the shape that makes adding a provider a zero-edit event.\n */\nfunction buildFrameworkCheckout(): string {\n const frameworkRoot = makeTempDirectory('wildo-framework-links-');\n writeFileSync(\n join(frameworkRoot, 'pnpm-workspace.yaml'),\n \"packages:\\n - 'engine/saas-models'\\n - 'providers/*'\\n\",\n 'utf8',\n );\n writeFileSync(join(frameworkRoot, 'wildo-framework.info.json'), JSON.stringify({ version: '1.4.2' }), 'utf8');\n writeManifest(frameworkRoot, 'engine/saas-models', { name: '@wildo-ai/saas-models', version: '1.4.2' });\n writeManifest(frameworkRoot, 'providers/slack', { name: '@wildo-ai/provider-slack', version: '1.4.2' });\n writeManifest(frameworkRoot, 'providers/airtable', { name: '@wildo-ai/provider-airtable', version: '1.4.2' });\n return frameworkRoot;\n}\n\nfunction buildApplication(declaredProviders: Record<string, Record<string, string>>): string {\n const applicationRoot = makeTempDirectory('wildo-app-links-');\n writeFileSync(join(applicationRoot, 'pnpm-workspace.yaml'), \"packages:\\n - 'backend-api'\\n - 'frontend'\\n\", 'utf8');\n writeManifest(applicationRoot, '.', {\n name: '@demo/root',\n pnpm: { overrides: { '@wildo-ai/saas-models': 'file:../../engine/saas-models' } },\n });\n for (const [member, dependencies] of Object.entries(declaredProviders)) {\n writeManifest(applicationRoot, member, { name: `@demo/${member}`, dependencies });\n }\n return applicationRoot;\n}\n\nconst silentLog = { info: () => undefined, warn: () => undefined };\n\ndescribe('ProviderPackageLinksService', () => {\n /**\n * The defect this closes (issue #334): in framework-developer mode every\n * `frameworkFileLinkPackages` name becomes a `file:` override in every scaffolded application. At\n * two hundred provider packages that is two hundred links per application, to packages it never\n * imports — and the scaffolder THROWS on any name the workspace cannot produce, so the failure is\n * not even quiet. Demand-driven means the application's own declaration is the whole input.\n */\n it('links only the providers the application declares, never the whole population', () => {\n const frameworkRoot = buildFrameworkCheckout();\n const applicationRoot = buildApplication({\n 'backend-api': { '@wildo-ai/saas-backend-lib': '*', '@wildo-ai/provider-slack': '*' },\n frontend: { react: '*' },\n });\n\n const result = ProviderPackageLinksService.reconcileAndReport({ applicationRoot, frameworkPath: frameworkRoot, log: silentLog });\n\n expect(result.declared).toEqual(['@wildo-ai/provider-slack']);\n expect(result.added).toHaveLength(1);\n const overrides = (JSON.parse(readFileSync(join(applicationRoot, 'package.json'), 'utf8')) as {\n pnpm: { overrides: Record<string, string> };\n }).pnpm.overrides;\n // `airtable` EXISTS in the framework workspace and is deliberately absent: the population is not\n // the link set.\n expect(overrides['@wildo-ai/provider-airtable']).toBeUndefined();\n expect(overrides['@wildo-ai/provider-slack']).toMatch(/^file:.*providers\\/slack$/);\n // The framework core override the application already carried is untouched.\n expect(overrides['@wildo-ai/saas-models']).toBe('file:../../engine/saas-models');\n expect(Object.keys(overrides)).toEqual([...Object.keys(overrides)].sort());\n });\n\n /** Every dependency field counts: a provider used only by a test is still a package that must resolve. */\n it('reads devDependencies and peerDependencies, and every workspace member', () => {\n const frameworkRoot = buildFrameworkCheckout();\n const applicationRoot = buildApplication({\n 'backend-api': { '@wildo-ai/provider-slack': '*' },\n });\n writeManifest(applicationRoot, 'frontend', {\n name: '@demo/frontend',\n devDependencies: { '@wildo-ai/provider-airtable': '*' },\n });\n\n expect(ProviderPackageLinksService.discoverDeclaredProviderPackages(applicationRoot))\n .toEqual(['@wildo-ai/provider-airtable', '@wildo-ai/provider-slack']);\n });\n\n /** A second run must be a no-op — this runs after every `wildo compose`. */\n it('is idempotent', () => {\n const frameworkRoot = buildFrameworkCheckout();\n const applicationRoot = buildApplication({ 'backend-api': { '@wildo-ai/provider-slack': '*' } });\n\n ProviderPackageLinksService.reconcileAndReport({ applicationRoot, frameworkPath: frameworkRoot, log: silentLog });\n const afterFirst = readFileSync(join(applicationRoot, 'package.json'), 'utf8');\n const second = ProviderPackageLinksService.reconcileAndReport({ applicationRoot, frameworkPath: frameworkRoot, log: silentLog });\n\n expect(second.added).toEqual([]);\n expect(second.alreadyLinked).toHaveLength(1);\n expect(readFileSync(join(applicationRoot, 'package.json'), 'utf8')).toBe(afterFirst);\n });\n\n /**\n * Reported, never thrown. A declaration for a provider that has not been generated yet is a state\n * an operator can legitimately be in, and refusing the whole reconciliation would take every OTHER\n * provider's link down with it.\n */\n it('reports an unresolvable provider instead of refusing the whole reconciliation', () => {\n const frameworkRoot = buildFrameworkCheckout();\n const applicationRoot = buildApplication({\n 'backend-api': { '@wildo-ai/provider-slack': '*', '@wildo-ai/provider-nonexistent': '*' },\n });\n\n const result = ProviderPackageLinksService.reconcileAndReport({ applicationRoot, frameworkPath: frameworkRoot, log: silentLog });\n\n expect(result.unresolved).toEqual(['@wildo-ai/provider-nonexistent']);\n expect(result.added.map((link) => link.packageName)).toEqual(['@wildo-ai/provider-slack']);\n });\n\n /** App-creator mode: no checkout, so a provider pins to the release the application already has. */\n it('pins to the framework version in app-creator mode, taken from the application\\'s own pins', () => {\n const applicationRoot = buildApplication({ 'backend-api': { '@wildo-ai/provider-slack': '*' } });\n writeManifest(applicationRoot, '.', {\n name: '@demo/root',\n pnpm: { overrides: { '@wildo-ai/saas-models': '1.1.1' } },\n });\n\n const result = ProviderPackageLinksService.reconcileAndReport({ applicationRoot, frameworkPath: null, log: silentLog });\n\n expect(result.added).toEqual([{ packageName: '@wildo-ai/provider-slack', overrideValue: '1.1.1' }]);\n });\n\n /**\n * The early return, and it is load-bearing: this runs after EVERY scenario, and the version\n * resolution REFUSES rather than inventing a release. Without it, `wildo compose add-locale` in an\n * application that declares no provider could fail on a version it never needed.\n */\n it('does nothing, and resolves no version, when the application declares no provider', () => {\n const applicationRoot = buildApplication({ 'backend-api': { react: '*' } });\n writeManifest(applicationRoot, '.', { name: '@demo/root' });\n\n const result = ProviderPackageLinksService.reconcileAndReport({ applicationRoot, frameworkPath: null, log: silentLog });\n\n expect(result).toEqual({ declared: [], added: [], alreadyLinked: [], unresolved: [], surplus: [] });\n });\n\n /** Surplus is REPORTED, never removed: an override in the root manifest is authored content. */\n it('reports a provider override no manifest declares any more, and leaves it in place', () => {\n const frameworkRoot = buildFrameworkCheckout();\n const applicationRoot = buildApplication({ 'backend-api': { '@wildo-ai/provider-slack': '*' } });\n writeManifest(applicationRoot, '.', {\n name: '@demo/root',\n pnpm: { overrides: { '@wildo-ai/provider-airtable': 'file:../../providers/airtable' } },\n });\n\n const result = ProviderPackageLinksService.reconcileAndReport({ applicationRoot, frameworkPath: frameworkRoot, log: silentLog });\n\n expect(result.surplus).toEqual(['@wildo-ai/provider-airtable']);\n const overrides = (JSON.parse(readFileSync(join(applicationRoot, 'package.json'), 'utf8')) as {\n pnpm: { overrides: Record<string, string> };\n }).pnpm.overrides;\n expect(overrides['@wildo-ai/provider-airtable']).toBe('file:../../providers/airtable');\n });\n\n /** The generated companion drop rewrites its own manifest on every start — reconciling into it is erased. */\n it('skips .wildo-saas/ workspace members', () => {\n const applicationRoot = buildApplication({ 'backend-api': { react: '*' } });\n writeFileSync(\n join(applicationRoot, 'pnpm-workspace.yaml'),\n \"packages:\\n - 'backend-api'\\n - '.wildo-saas/wildo-dev-companion'\\n\",\n 'utf8',\n );\n writeManifest(applicationRoot, '.wildo-saas/wildo-dev-companion', {\n name: '@demo/companion',\n dependencies: { '@wildo-ai/provider-slack': '*' },\n });\n\n expect(ProviderPackageLinksService.discoverDeclaredProviderPackages(applicationRoot)).toEqual([]);\n });\n});\n"]}
|
|
1
|
+
{"version":3,"file":"provider-package-links.service.test.js","sourceRoot":"","sources":["../../../../../src/services/application/__tests__/provider-package-links.service.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE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CACP,CAAC;QACF,aAAa,CAAC,IAAI,CAAC,aAAa,EAAE,2BAA2B,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;QAC9G,aAAa,CAAC,aAAa,EAAE,oBAAoB,EAAE,EAAE,IAAI,EAAE,uBAAuB,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;QACxG,aAAa,CAAC,aAAa,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,qBAAqB,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;QAC7F,aAAa,CAAC,aAAa,EAAE,sBAAsB,EAAE,EAAE,IAAI,EAAE,yBAAyB,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;QAE5G,MAAM,eAAe,GAAG,gBAAgB,CAAC;YACvC,aAAa,EAAE,EAAE,qBAAqB,EAAE,GAAG,EAAE,yBAAyB,EAAE,GAAG,EAAE;SAC9E,CAAC,CAAC;QAEH,MAAM,MAAM,GAAG,2BAA2B,CAAC,kBAAkB,CAAC,EAAE,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC;QAEjI,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,yBAAyB,EAAE,qBAAqB,CAAC,CAAC,CAAC;QACpF,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'fs';\nimport { join } from 'path';\nimport { tmpdir } from 'os';\nimport { afterEach, describe, expect, it } from 'vitest';\nimport { ProviderPackageLinksService } from '~wildo-cli/services/application/provider-package-links.service';\n\nconst tempDirs: string[] = [];\nafterEach(() => {\n for (const dir of tempDirs.splice(0)) rmSync(dir, { recursive: true, force: true });\n});\n\nfunction makeTempDirectory(prefix: string): string {\n const dir = mkdtempSync(join(tmpdir(), prefix));\n tempDirs.push(dir);\n return dir;\n}\n\nfunction writeManifest(root: string, memberRelative: string, manifest: unknown): void {\n const directory = join(root, memberRelative);\n mkdirSync(directory, { recursive: true });\n writeFileSync(join(directory, 'package.json'), `${JSON.stringify(manifest, null, 2)}\\n`, 'utf8');\n}\n\n/**\n * A framework checkout carrying two provider packages and one engine package, discovered through\n * the `providers/*` workspace glob — the shape that makes adding a provider a zero-edit event.\n */\nfunction buildFrameworkCheckout(): string {\n const frameworkRoot = makeTempDirectory('wildo-framework-links-');\n writeFileSync(\n join(frameworkRoot, 'pnpm-workspace.yaml'),\n \"packages:\\n - 'engine/saas-models'\\n - 'providers/*'\\n\",\n 'utf8',\n );\n writeFileSync(join(frameworkRoot, 'wildo-framework.info.json'), JSON.stringify({ version: '1.4.2' }), 'utf8');\n writeManifest(frameworkRoot, 'engine/saas-models', { name: '@wildo-ai/saas-models', version: '1.4.2' });\n writeManifest(frameworkRoot, 'providers/slack', { name: '@wildo-ai/provider-slack', version: '1.4.2' });\n writeManifest(frameworkRoot, 'providers/airtable', { name: '@wildo-ai/provider-airtable', version: '1.4.2' });\n return frameworkRoot;\n}\n\nfunction buildApplication(declaredProviders: Record<string, Record<string, string>>): string {\n const applicationRoot = makeTempDirectory('wildo-app-links-');\n writeFileSync(join(applicationRoot, 'pnpm-workspace.yaml'), \"packages:\\n - 'backend-api'\\n - 'frontend'\\n\", 'utf8');\n writeManifest(applicationRoot, '.', {\n name: '@demo/root',\n pnpm: { overrides: { '@wildo-ai/saas-models': 'file:../../engine/saas-models' } },\n });\n for (const [member, dependencies] of Object.entries(declaredProviders)) {\n writeManifest(applicationRoot, member, { name: `@demo/${member}`, dependencies });\n }\n return applicationRoot;\n}\n\nconst silentLog = { info: () => undefined, warn: () => undefined };\n\ndescribe('ProviderPackageLinksService', () => {\n /**\n * The defect this closes (issue #334): in framework-developer mode every\n * `frameworkFileLinkPackages` name becomes a `file:` override in every scaffolded application. At\n * two hundred provider packages that is two hundred links per application, to packages it never\n * imports — and the scaffolder THROWS on any name the workspace cannot produce, so the failure is\n * not even quiet. Demand-driven means the application's own declaration is the whole input.\n */\n it('links only the providers the application declares, never the whole population', () => {\n const frameworkRoot = buildFrameworkCheckout();\n const applicationRoot = buildApplication({\n 'backend-api': { '@wildo-ai/saas-backend-lib': '*', '@wildo-ai/provider-slack': '*' },\n frontend: { react: '*' },\n });\n\n const result = ProviderPackageLinksService.reconcileAndReport({ applicationRoot, frameworkPath: frameworkRoot, log: silentLog });\n\n expect(result.declared).toEqual(['@wildo-ai/provider-slack']);\n expect(result.added).toHaveLength(1);\n const overrides = (JSON.parse(readFileSync(join(applicationRoot, 'package.json'), 'utf8')) as {\n pnpm: { overrides: Record<string, string> };\n }).pnpm.overrides;\n // `airtable` EXISTS in the framework workspace and is deliberately absent: the population is not\n // the link set.\n expect(overrides['@wildo-ai/provider-airtable']).toBeUndefined();\n expect(overrides['@wildo-ai/provider-slack']).toMatch(/^file:.*providers\\/slack$/);\n // The framework core override the application already carried is untouched.\n expect(overrides['@wildo-ai/saas-models']).toBe('file:../../engine/saas-models');\n expect(Object.keys(overrides)).toEqual([...Object.keys(overrides)].sort());\n });\n\n /** Every dependency field counts: a provider used only by a test is still a package that must resolve. */\n it('reads devDependencies and peerDependencies, and every workspace member', () => {\n const frameworkRoot = buildFrameworkCheckout();\n const applicationRoot = buildApplication({\n 'backend-api': { '@wildo-ai/provider-slack': '*' },\n });\n writeManifest(applicationRoot, 'frontend', {\n name: '@demo/frontend',\n devDependencies: { '@wildo-ai/provider-airtable': '*' },\n });\n\n expect(ProviderPackageLinksService.discoverDeclaredProviderPackages(applicationRoot))\n .toEqual(['@wildo-ai/provider-airtable', '@wildo-ai/provider-slack']);\n });\n\n /** A second run must be a no-op — this runs after every `wildo compose`. */\n it('is idempotent', () => {\n const frameworkRoot = buildFrameworkCheckout();\n const applicationRoot = buildApplication({ 'backend-api': { '@wildo-ai/provider-slack': '*' } });\n\n ProviderPackageLinksService.reconcileAndReport({ applicationRoot, frameworkPath: frameworkRoot, log: silentLog });\n const afterFirst = readFileSync(join(applicationRoot, 'package.json'), 'utf8');\n const second = ProviderPackageLinksService.reconcileAndReport({ applicationRoot, frameworkPath: frameworkRoot, log: silentLog });\n\n expect(second.added).toEqual([]);\n expect(second.alreadyLinked).toHaveLength(1);\n expect(readFileSync(join(applicationRoot, 'package.json'), 'utf8')).toBe(afterFirst);\n });\n\n /**\n * Reported, never thrown. A declaration for a provider that has not been generated yet is a state\n * an operator can legitimately be in, and refusing the whole reconciliation would take every OTHER\n * provider's link down with it.\n */\n it('reports an unresolvable provider instead of refusing the whole reconciliation', () => {\n const frameworkRoot = buildFrameworkCheckout();\n const applicationRoot = buildApplication({\n 'backend-api': { '@wildo-ai/provider-slack': '*', '@wildo-ai/provider-nonexistent': '*' },\n });\n\n const result = ProviderPackageLinksService.reconcileAndReport({ applicationRoot, frameworkPath: frameworkRoot, log: silentLog });\n\n expect(result.unresolved).toEqual(['@wildo-ai/provider-nonexistent']);\n expect(result.added.map((link) => link.packageName)).toEqual(['@wildo-ai/provider-slack']);\n });\n\n /** App-creator mode: no checkout, so a provider pins to the release the application already has. */\n it('pins to the framework version in app-creator mode, taken from the application\\'s own pins', () => {\n const applicationRoot = buildApplication({ 'backend-api': { '@wildo-ai/provider-slack': '*' } });\n writeManifest(applicationRoot, '.', {\n name: '@demo/root',\n pnpm: { overrides: { '@wildo-ai/saas-models': '1.1.1' } },\n });\n\n const result = ProviderPackageLinksService.reconcileAndReport({ applicationRoot, frameworkPath: null, log: silentLog });\n\n expect(result.added).toEqual([{ packageName: '@wildo-ai/provider-slack', overrideValue: '1.1.1' }]);\n });\n\n /**\n * The early return, and it is load-bearing: this runs after EVERY scenario, and the version\n * resolution REFUSES rather than inventing a release. Without it, `wildo compose add-locale` in an\n * application that declares no provider could fail on a version it never needed.\n */\n it('does nothing, and resolves no version, when the application declares no provider', () => {\n const applicationRoot = buildApplication({ 'backend-api': { react: '*' } });\n writeManifest(applicationRoot, '.', { name: '@demo/root' });\n\n const result = ProviderPackageLinksService.reconcileAndReport({ applicationRoot, frameworkPath: null, log: silentLog });\n\n expect(result).toEqual({ declared: [], added: [], alreadyLinked: [], unresolved: [], surplus: [] });\n });\n\n /** Surplus is REPORTED, never removed: an override in the root manifest is authored content. */\n it('reports a provider override no manifest declares any more, and leaves it in place', () => {\n const frameworkRoot = buildFrameworkCheckout();\n const applicationRoot = buildApplication({ 'backend-api': { '@wildo-ai/provider-slack': '*' } });\n writeManifest(applicationRoot, '.', {\n name: '@demo/root',\n pnpm: { overrides: { '@wildo-ai/provider-airtable': 'file:../../providers/airtable' } },\n });\n\n const result = ProviderPackageLinksService.reconcileAndReport({ applicationRoot, frameworkPath: frameworkRoot, log: silentLog });\n\n expect(result.surplus).toEqual(['@wildo-ai/provider-airtable']);\n const overrides = (JSON.parse(readFileSync(join(applicationRoot, 'package.json'), 'utf8')) as {\n pnpm: { overrides: Record<string, string> };\n }).pnpm.overrides;\n expect(overrides['@wildo-ai/provider-airtable']).toBe('file:../../providers/airtable');\n });\n\n /** The generated companion drop rewrites its own manifest on every start — reconciling into it is erased. */\n it('skips .wildo-saas/ workspace members', () => {\n const applicationRoot = buildApplication({ 'backend-api': { react: '*' } });\n writeFileSync(\n join(applicationRoot, 'pnpm-workspace.yaml'),\n \"packages:\\n - 'backend-api'\\n - '.wildo-saas/wildo-dev-companion'\\n\",\n 'utf8',\n );\n writeManifest(applicationRoot, '.wildo-saas/wildo-dev-companion', {\n name: '@demo/companion',\n dependencies: { '@wildo-ai/provider-slack': '*' },\n });\n\n expect(ProviderPackageLinksService.discoverDeclaredProviderPackages(applicationRoot)).toEqual([]);\n });\n});\n\n/**\n * The CATALOGUE package, which is the shape that actually ships.\n *\n * Everything above declares `@wildo-ai/provider-<ref>` — one package per vendor, the population\n * this service was designed around (issue #334, slice S6). That shape was reversed on 2026-09-06\n * for ONE package with a subpath per vendor, and the matcher was never moved: measured 2026-09-09,\n * **no `@wildo-ai/provider-<ref>` package exists anywhere in the repository**, while both dogfood\n * applications declare `@wildo-ai/providers`.\n *\n * So the service ran at both of its production call sites, matched nothing, and reported success —\n * the quietest possible failure, and one no test above could see, because every fixture here was\n * written in the vocabulary the matcher understood. An application adding its first catalogue\n * provider got the dependency and no override, and could not install.\n */\ndescribe('the catalogue package is one package, and the service must link it', () => {\n /** A framework checkout in the shape that ships: ONE catalogue package at `providers/`. */\n function buildCatalogueCheckout(): string {\n const frameworkRoot = makeTempDirectory('wildo-framework-catalogue-');\n writeFileSync(\n join(frameworkRoot, 'pnpm-workspace.yaml'),\n \"packages:\\n - 'engine/saas-models'\\n - 'providers'\\n\",\n 'utf8',\n );\n writeFileSync(join(frameworkRoot, 'wildo-framework.info.json'), JSON.stringify({ version: '1.4.2' }), 'utf8');\n writeManifest(frameworkRoot, 'engine/saas-models', { name: '@wildo-ai/saas-models', version: '1.4.2' });\n writeManifest(frameworkRoot, 'providers', { name: '@wildo-ai/providers', version: '1.4.2' });\n return frameworkRoot;\n }\n\n it('links @wildo-ai/providers when the application declares it', () => {\n const frameworkRoot = buildCatalogueCheckout();\n const applicationRoot = buildApplication({\n 'backend-api': { '@wildo-ai/saas-backend-lib': '*', '@wildo-ai/providers': '*' },\n frontend: { react: '*' },\n });\n\n const result = ProviderPackageLinksService.reconcileAndReport({ applicationRoot, frameworkPath: frameworkRoot, log: silentLog });\n\n expect(result.declared).toEqual(['@wildo-ai/providers']);\n expect(result.added).toHaveLength(1);\n const overrides = (JSON.parse(readFileSync(join(applicationRoot, 'package.json'), 'utf8')) as {\n pnpm: { overrides: Record<string, string> };\n }).pnpm.overrides;\n // The exact thing that had to be hand-written in Wonder Todos on 2026-09-09.\n expect(overrides['@wildo-ai/providers']).toMatch(/^file:.*providers$/);\n expect(overrides['@wildo-ai/saas-models']).toBe('file:../../engine/saas-models');\n });\n\n it('still leaves an application that declares no provider alone — the control', () => {\n // Without this, a matcher that linked the catalogue unconditionally would pass the case above.\n // Demand-driven is the property the whole service exists for, and widening the matcher is\n // exactly the change that could lose it.\n const frameworkRoot = buildCatalogueCheckout();\n const applicationRoot = buildApplication({ 'backend-api': { '@wildo-ai/saas-backend-lib': '*' } });\n\n const result = ProviderPackageLinksService.reconcileAndReport({ applicationRoot, frameworkPath: frameworkRoot, log: silentLog });\n\n expect(result.declared).toEqual([]);\n expect(result.added).toEqual([]);\n const overrides = (JSON.parse(readFileSync(join(applicationRoot, 'package.json'), 'utf8')) as {\n pnpm: { overrides: Record<string, string> };\n }).pnpm.overrides;\n expect(overrides['@wildo-ai/providers']).toBeUndefined();\n });\n\n it('links the catalogue and a per-vendor package together, so neither shape displaces the other', () => {\n // The prefix was KEPT rather than replaced: an application-owned or future per-vendor package is\n // still a provider this service links. One predicate answers for both, so a call site cannot\n // remember only one — which is how the matcher came to see nothing at all.\n const frameworkRoot = makeTempDirectory('wildo-framework-both-');\n writeFileSync(\n join(frameworkRoot, 'pnpm-workspace.yaml'),\n \"packages:\\n - 'engine/saas-models'\\n - 'providers'\\n - 'providers-owned/*'\\n\",\n 'utf8',\n );\n writeFileSync(join(frameworkRoot, 'wildo-framework.info.json'), JSON.stringify({ version: '1.4.2' }), 'utf8');\n writeManifest(frameworkRoot, 'engine/saas-models', { name: '@wildo-ai/saas-models', version: '1.4.2' });\n writeManifest(frameworkRoot, 'providers', { name: '@wildo-ai/providers', version: '1.4.2' });\n writeManifest(frameworkRoot, 'providers-owned/acme', { name: '@wildo-ai/provider-acme', version: '1.4.2' });\n\n const applicationRoot = buildApplication({\n 'backend-api': { '@wildo-ai/providers': '*', '@wildo-ai/provider-acme': '*' },\n });\n\n const result = ProviderPackageLinksService.reconcileAndReport({ applicationRoot, frameworkPath: frameworkRoot, log: silentLog });\n\n expect(result.declared).toEqual(['@wildo-ai/provider-acme', '@wildo-ai/providers']);\n expect(result.added).toHaveLength(2);\n });\n});\n"]}
|
|
@@ -244,6 +244,15 @@ export declare class AppBootstrapService {
|
|
|
244
244
|
* general-purpose readiness wait — `wildo local dev`'s own platform-readiness
|
|
245
245
|
* barrier already owns that responsibility before this service is entered.
|
|
246
246
|
*/
|
|
247
|
+
/**
|
|
248
|
+
* One reconnect PROBE, inside the poll loop.
|
|
249
|
+
*
|
|
250
|
+
* Short on purpose, and shorter than the loop's own budget: the caller already owns "how long do
|
|
251
|
+
* we wait for apps-manager" through `APPS_MANAGER_RECONNECT_WAIT_MS`, so a probe that lingers
|
|
252
|
+
* only eats that budget in one bite instead of polling with it. 5s is enough for a service on
|
|
253
|
+
* this machine to answer a readiness route, and a probe that cannot is not ready.
|
|
254
|
+
*/
|
|
255
|
+
private static readonly APPS_MANAGER_PROBE_TIMEOUT_MS;
|
|
247
256
|
private static waitForAppsManagerReconnect;
|
|
248
257
|
/**
|
|
249
258
|
* Connects with a bounded reconnect-retry on connection-level failure only
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-bootstrap.service.d.ts","sourceRoot":"","sources":["../../../../src/services/application/app-bootstrap.service.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAmB,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAOL,KAAK,0BAA0B,EAC/B,KAAK,uBAAuB,EAC5B,KAAK,0BAA0B,EAK/B,KAAK,kCAAkC,EA0BvC,KAAK,2BAA2B,EAChC,cAAc,EACd,uBAAuB,EACvB,yBAAyB,EAC1B,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qDAAqD,CAAC;AAClG,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qDAAqD,CAAC;AACjG,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,qDAAqD,CAAC;AAC5G,OAAO,KAAK,EACV,2BAA2B,EAC3B,0BAA0B,EAC1B,mCAAmC,EACnC,4BAA4B,EAC5B,0BAA0B,EAC1B,0BAA0B,EAE3B,MAAM,qEAAqE,C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;;;;;;;OAoBG;IACH,OAAO,CAAC,MAAM,CAAC,eAAe;IAQ9B,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAkHpC;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,6BAA6B;IAkC5C;;;;;;;;;;;;;;;;OAgBG;IACH,OAAO,CAAC,MAAM,CAAC,oBAAoB;IAkDnC;;;;;;;;OAQG;IACH,OAAO,CAAC,MAAM,CAAC,qCAAqC;IA6BpD;;;;;;;;;OASG;IACH,OAAO,CAAC,MAAM,CAAC,4BAA4B;IAY3C;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,MAAM,CAAC,sCAAsC;IAmBrD;;;;;;;OAOG;IACH,OAAO,CAAC,MAAM,CAAC,wBAAwB;IAIvC;;;;;;;;;;;;;;OAcG;mBACkB,6CAA6C;WAgDrD,4BAA4B,CACvC,KAAK,EAAE,mCAAmC,GACzC,OAAO,CAAC,6BAA6B,GAAG,IAAI,CAAC;IAyMhD,OAAO,CAAC,MAAM,CAAC,iCAAiC;IAYhD,OAAO,CAAC,MAAM,CAAC,qCAAqC;mBAgB/B,0CAA0C;IAsC/D;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,yBAAyB;mBAQnB,oBAAoB;IAOzC,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAMpC,OAAO,CAAC,MAAM,CAAC,cAAc;IAI7B;;;;;;;OAOG;
|
|
1
|
+
{"version":3,"file":"app-bootstrap.service.d.ts","sourceRoot":"","sources":["../../../../src/services/application/app-bootstrap.service.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAmB,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAOL,KAAK,0BAA0B,EAC/B,KAAK,uBAAuB,EAC5B,KAAK,0BAA0B,EAK/B,KAAK,kCAAkC,EA0BvC,KAAK,2BAA2B,EAChC,cAAc,EACd,uBAAuB,EACvB,yBAAyB,EAC1B,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EA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;;;;;;;;;OAaG;mBACkB,wCAAwC;IA0B7D;;;;;;;;OAQG;IACH;;;;;;;;;;OAUG;IACH,OAAO,CAAC,MAAM,CAAC,wCAAwC;IAUvD,OAAO,CAAC,MAAM,CAAC,kCAAkC;WAepC,8BAA8B,CACzC,KAAK,EAAE,6BAA6B,GACnC,OAAO,CAAC,2BAA2B,EAAE,CAAC;IA0EzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACH,OAAO,CAAC,MAAM,CAAC,kCAAkC;WAcpC,gCAAgC,CAC3C,KAAK,EAAE,6BAA6B,GACnC,OAAO,CAAC,0BAA0B,EAAE,CAAC;WAmC3B,6BAA6B,CACxC,KAAK,EAAE,6BAA6B,GACnC,OAAO,CAAC,0BAA0B,EAAE,CAAC;WA6E3B,6BAA6B,CACxC,KAAK,EAAE,6BAA6B,GACnC,OAAO,CAAC,0BAA0B,EAAE,CAAC;WAqJ3B,+BAA+B,CAAC,KAAK,EAAE;QAClD,QAAQ,EAAE,MAAM,CAAC;QACjB,gBAAgB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QACtC,QAAQ,CAAC,EAAE,6BAA6B,CAAC;KAC1C,GAAG,OAAO,CAAC,mCAAmC,EAAE,CAAC;IAuGlD;;;;;;;OAOG;IACH,MAAM,CAAC,kCAAkC,CAAC,KAAK,EAAE;QAC/C,GAAG,EAAE,gCAAgC,CAAC;QACtC,MAAM,EAAE,qBAAqB,CAAC;QAC9B,QAAQ,EAAE,MAAM,CAAC;KAClB,GAAG,4BAA4B,EAAE;CAoBnC"}
|
|
@@ -801,6 +801,15 @@ export class AppBootstrapService {
|
|
|
801
801
|
* general-purpose readiness wait — `wildo local dev`'s own platform-readiness
|
|
802
802
|
* barrier already owns that responsibility before this service is entered.
|
|
803
803
|
*/
|
|
804
|
+
/**
|
|
805
|
+
* One reconnect PROBE, inside the poll loop.
|
|
806
|
+
*
|
|
807
|
+
* Short on purpose, and shorter than the loop's own budget: the caller already owns "how long do
|
|
808
|
+
* we wait for apps-manager" through `APPS_MANAGER_RECONNECT_WAIT_MS`, so a probe that lingers
|
|
809
|
+
* only eats that budget in one bite instead of polling with it. 5s is enough for a service on
|
|
810
|
+
* this machine to answer a readiness route, and a probe that cannot is not ready.
|
|
811
|
+
*/
|
|
812
|
+
static APPS_MANAGER_PROBE_TIMEOUT_MS = 5_000;
|
|
804
813
|
static async waitForAppsManagerReconnect(env) {
|
|
805
814
|
const addressContext = ServiceAddressResolver.fromEnvironment(env, AddressPerspective.HOST_FACING);
|
|
806
815
|
const addresses = ServiceAddressResolver.resolve(addressContext);
|
|
@@ -808,7 +817,7 @@ export class AppBootstrapService {
|
|
|
808
817
|
const deadline = Date.now() + APPS_MANAGER_RECONNECT_WAIT_MS;
|
|
809
818
|
while (Date.now() < deadline) {
|
|
810
819
|
try {
|
|
811
|
-
const probe = await fetch(readyUrl, { signal: AbortSignal.timeout(
|
|
820
|
+
const probe = await fetch(readyUrl, { signal: AbortSignal.timeout(AppBootstrapService.APPS_MANAGER_PROBE_TIMEOUT_MS), redirect: 'manual' });
|
|
812
821
|
if (probe.ok)
|
|
813
822
|
return true;
|
|
814
823
|
}
|
|
@@ -973,6 +982,26 @@ export class AppBootstrapService {
|
|
|
973
982
|
userFirstName: credentials.admin.firstName,
|
|
974
983
|
userLastName: credentials.admin.lastName,
|
|
975
984
|
userPassword: credentials.admin.password,
|
|
985
|
+
/*
|
|
986
|
+
* The SECOND administrator (#575), and this site was enumerated as "read only — no change
|
|
987
|
+
* expected" when the CLI half landed. That was WRONG, and it is the site that matters most:
|
|
988
|
+
* `applicationAccessGrants` has zero mentions under `platform/` — it is an ENGINE resource, so
|
|
989
|
+
* the two-person rule bites inside the GENERATED APPLICATION, not on the platform plane. This
|
|
990
|
+
* request is what carries an identity into that application's own database, where
|
|
991
|
+
* `_getDefault_App_FirstUser` is the only writer of `APP_ADMIN_SUPER_ADMIN` at provisioning
|
|
992
|
+
* time.
|
|
993
|
+
*
|
|
994
|
+
* Spread, so a `secrets.json` predating the `approver` block sends nothing at all rather than
|
|
995
|
+
* four `undefined`s that would read as a half-stated identity at the door.
|
|
996
|
+
*/
|
|
997
|
+
...(credentials.approver
|
|
998
|
+
? {
|
|
999
|
+
approverEmail: credentials.approver.email,
|
|
1000
|
+
approverFirstName: credentials.approver.firstName,
|
|
1001
|
+
approverLastName: credentials.approver.lastName,
|
|
1002
|
+
approverPassword: credentials.approver.password,
|
|
1003
|
+
}
|
|
1004
|
+
: {}),
|
|
976
1005
|
managedDeclaration: input.managedDeclaration,
|
|
977
1006
|
applicationDatabase: input.applicationDatabase,
|
|
978
1007
|
firstAdminSeed: input.firstAdminSeed,
|