@cosmicdrift/kumiko-server-runtime 0.387.0 → 0.389.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/boot/boot-crypto.js +3 -3
  2. package/dist/boot/shared-boot-steps.d.ts +46 -0
  3. package/dist/boot/shared-boot-steps.js +160 -0
  4. package/dist/boot/wait-for-database.d.ts +5 -0
  5. package/dist/boot/wait-for-database.js +7 -6
  6. package/dist/boot/worker-boot-core.js +24 -38
  7. package/dist/boot-options/billing-option.d.ts +18 -9
  8. package/dist/boot-options/billing-option.js +44 -18
  9. package/dist/boot-options/demo-mode.d.ts +3 -3
  10. package/dist/boot-options/demo-mode.js +4 -1
  11. package/dist/boot-options/file-storage-option.js +6 -6
  12. package/dist/boot-options/option-env-schema.js +11 -2
  13. package/dist/boot-options/resolve-boot-options.d.ts +1 -0
  14. package/dist/boot-options/resolve-boot-options.js +11 -5
  15. package/dist/boot-options/stack-boot-requirements.d.ts +1 -1
  16. package/dist/boot-options/stack-boot-requirements.js +2 -14
  17. package/dist/build-prod-bundle.js +13 -13
  18. package/dist/bundled-lists-table.d.ts +2 -0
  19. package/dist/bundled-lists-table.js +56 -0
  20. package/dist/compose-auth-options.d.ts +16 -0
  21. package/dist/compose-auth-options.js +49 -0
  22. package/dist/compose-features.d.ts +5 -17
  23. package/dist/compose-features.js +6 -53
  24. package/dist/csp-hashes.js +1 -1
  25. package/dist/extra-routes-deps.d.ts +4 -0
  26. package/dist/extra-routes-deps.js +1 -0
  27. package/dist/fatal-error-handlers.js +7 -0
  28. package/dist/files-for-tenant.d.ts +3 -0
  29. package/dist/files-for-tenant.js +10 -0
  30. package/dist/renderer-web-fonts.js +3 -9
  31. package/dist/require-env.d.ts +2 -0
  32. package/dist/require-env.js +21 -0
  33. package/dist/resolve-installed-package.d.ts +10 -0
  34. package/dist/resolve-installed-package.js +32 -0
  35. package/dist/resolve-tailwind-cli.d.ts +3 -8
  36. package/dist/resolve-tailwind-cli.js +8 -25
  37. package/dist/run-bootstrap.d.ts +1 -1
  38. package/dist/run-bootstrap.js +1 -1
  39. package/dist/run-prod-app-auth.d.ts +17 -0
  40. package/dist/run-prod-app-auth.js +83 -0
  41. package/dist/run-prod-app-boot-context.d.ts +2 -0
  42. package/dist/run-prod-app-boot-context.js +15 -7
  43. package/dist/run-prod-app-config.d.ts +36 -0
  44. package/dist/run-prod-app-config.js +169 -0
  45. package/dist/run-prod-app-connections.d.ts +17 -0
  46. package/dist/run-prod-app-connections.js +59 -0
  47. package/dist/run-prod-app-entrypoint.d.ts +14 -0
  48. package/dist/run-prod-app-entrypoint.js +149 -0
  49. package/dist/run-prod-app-handle.d.ts +20 -0
  50. package/dist/run-prod-app-handle.js +105 -0
  51. package/dist/run-prod-app-request-context.d.ts +15 -0
  52. package/dist/run-prod-app-request-context.js +103 -0
  53. package/dist/run-prod-app-seeds.d.ts +13 -0
  54. package/dist/run-prod-app-seeds.js +88 -0
  55. package/dist/run-prod-app-static-files.js +9 -1
  56. package/dist/run-prod-app.d.ts +27 -19
  57. package/dist/run-prod-app.js +47 -727
  58. package/dist/run-worker-app.d.ts +12 -2
  59. package/dist/run-worker-app.js +2 -0
  60. package/package.json +27 -8
  61. package/src/changes.json +86 -0
@@ -1,19 +1,21 @@
1
1
  import type { ServerOptions } from "@cosmicdrift/kumiko-framework/api";
2
2
  import type { KmsAdapter } from "@cosmicdrift/kumiko-framework/crypto";
3
3
  import type { DbConnection } from "@cosmicdrift/kumiko-framework/db";
4
- import type { FeatureDefinition, Registry, ValidateBootOptions } from "@cosmicdrift/kumiko-framework/engine";
4
+ import type { BundledListsOptions, FeatureDefinition, Registry, ValidateBootOptions } from "@cosmicdrift/kumiko-framework/engine";
5
5
  import type { WorkerEntrypoint } from "@cosmicdrift/kumiko-framework/entrypoint";
6
6
  import type { ComposedEnvSchema, KumikoBootError } from "@cosmicdrift/kumiko-framework/env";
7
7
  import type { JobRunnerOptions } from "@cosmicdrift/kumiko-framework/jobs";
8
8
  import { type ObservabilityProvider } from "@cosmicdrift/kumiko-framework/observability";
9
9
  import type { MasterKeyProvider, SecretsContext } from "@cosmicdrift/kumiko-framework/secrets";
10
10
  import type { Redis } from "ioredis";
11
+ import type { DatabaseWaitClock } from "./boot/wait-for-database.ts";
11
12
  import { type WorkerMetricsOptions, type WorkerMetricsServer } from "./boot/worker-metrics-server.ts";
12
13
  import type { BillingBootOption } from "./boot-options/billing-option.ts";
13
14
  import type { FileStorageBootOption } from "./boot-options/file-storage-option.ts";
14
15
  import type { KmsMode } from "./boot-options/kms-mode.ts";
15
16
  import type { MailBootOption } from "./boot-options/mail-option.ts";
16
17
  import { type SystemWireDeps } from "./extra-routes-deps.ts";
18
+ import type { ConfigOverridesInput } from "./run-prod-app-boot-context.ts";
17
19
  export type WorkerContextOption = Record<string, unknown> | ((deps: WorkerDeps) => Record<string, unknown>);
18
20
  export type WorkerDeps = {
19
21
  readonly db: DbConnection;
@@ -39,6 +41,8 @@ export type RunWorkerAppOptions = {
39
41
  readonly features: readonly FeatureDefinition[];
40
42
  /** Opt-in boot-validator warnings — see ValidateBootOptions. */
41
43
  readonly validateBootOptions?: ValidateBootOptions;
44
+ /** One table block for every list of the bundled features, see ComposeFeaturesOptions.bundledLists. Must match the API process. */
45
+ readonly bundledLists?: BundledListsOptions;
42
46
  /** Mount the auto-mixed config/user/tenant/auth-email-password features —
43
47
  * MUST match the API process's `includeBundled` value, otherwise API
44
48
  * and worker run with a diverging registry topology. Also controls
@@ -62,6 +66,12 @@ export type RunWorkerAppOptions = {
62
66
  /** Subject-key adapter for crypto-shredding — boot checks health()
63
67
  * before any connection (see RunProdAppOptions["kms"]). */
64
68
  readonly kms?: KmsAdapter;
69
+ /** App-level config values, same semantics and merge as RunProdAppOptions["appOverrides"];
70
+ * the worker renders the mail layouts and must resolve the same branding as the API. */
71
+ readonly appOverrides?: ConfigOverridesInput;
72
+ /** Replaces the real clock, sleep and log sink of the boot backoff for the database and
73
+ * KMS waits; tests use it to run the retry path without real waiting. */
74
+ readonly databaseWait?: DatabaseWaitClock;
65
75
  /** Blind-index key for lookupable fields (see
66
76
  * RunProdAppOptions["blindIndexKey"]). */
67
77
  readonly blindIndexKey?: string;
@@ -90,7 +100,7 @@ export type RunWorkerAppOptions = {
90
100
  readonly fileStorage?: FileStorageBootOption;
91
101
  /** Same as RunProdAppOptions["kmsMode"]; cannot be combined with `kms` / `blindIndexKey` / `allowPlaintextPii`. */
92
102
  readonly kmsMode?: KmsMode;
93
- /** Same as RunProdAppOptions["billing"]: mounts subscription-stripe so the registry matches the API. The webhook route belongs to the API process. */
103
+ /** Same as RunProdAppOptions["billing"]: mounts the configured subscription providers so the registry matches the API. The webhook route belongs to the API process. */
94
104
  readonly billing?: BillingBootOption;
95
105
  /** Same as RunProdAppOptions["featureToggles"]: mounts feature-toggles and layers the operator switches over the tier resolver. */
96
106
  readonly featureToggles?: boolean;
@@ -27,6 +27,7 @@ import { resolveBootOptionWiring } from "./boot-options/resolve-boot-options.js"
27
27
  import { assertStackBootRequirements } from "./boot-options/stack-boot-requirements.js";
28
28
  import { makeDispatchSystemQuery, makeDispatchSystemWrite, } from "./extra-routes-deps.js";
29
29
  import { installFatalErrorHandlers } from "./fatal-error-handlers.js";
30
+ import { makeFilesForTenant } from "./files-for-tenant.js";
30
31
  import { installProcessLogger, uninstallProcessLogger } from "./process-logger.js";
31
32
  function makeBootModeHandle() {
32
33
  return {
@@ -127,6 +128,7 @@ export async function runWorkerApp(options) {
127
128
  db,
128
129
  redis,
129
130
  registry,
131
+ filesForTenant: makeFilesForTenant(entrypoint.context),
130
132
  metricsFor: createMetricsForFactory(entrypoint.observability.meter),
131
133
  dispatchSystemWrite: makeDispatchSystemWrite(entrypoint.dispatcher),
132
134
  dispatchSystemQuery: makeDispatchSystemQuery(entrypoint.dispatcher),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cosmicdrift/kumiko-server-runtime",
3
- "version": "0.387.0",
3
+ "version": "0.389.0",
4
4
  "description": "Production server-boot runtime for Kumiko apps: connections, schema-drift-gate, seeds, lifecycle, graceful shutdown. Symmetric to kumiko-dev-server's runDevApp, without dev/scaffold tooling.",
5
5
  "license": "MIT",
6
6
  "author": "Marc Frost <marc@cosmicdriftgamestudio.com>",
@@ -50,6 +50,10 @@
50
50
  "types": "./dist/boot/apply-boot-seeds.d.ts",
51
51
  "default": "./dist/boot/apply-boot-seeds.js"
52
52
  },
53
+ "./boot/shared-boot-steps": {
54
+ "types": "./dist/boot/shared-boot-steps.d.ts",
55
+ "default": "./dist/boot/shared-boot-steps.js"
56
+ },
53
57
  "./boot/boot-crypto": {
54
58
  "types": "./dist/boot/boot-crypto.d.ts",
55
59
  "default": "./dist/boot/boot-crypto.js"
@@ -66,6 +70,10 @@
66
70
  "types": "./dist/renderer-web-fonts.d.ts",
67
71
  "default": "./dist/renderer-web-fonts.js"
68
72
  },
73
+ "./resolve-installed-package": {
74
+ "types": "./dist/resolve-installed-package.d.ts",
75
+ "default": "./dist/resolve-installed-package.js"
76
+ },
69
77
  "./resolve-tailwind-cli": {
70
78
  "types": "./dist/resolve-tailwind-cli.d.ts",
71
79
  "default": "./dist/resolve-tailwind-cli.js"
@@ -88,18 +96,21 @@
88
96
  }
89
97
  },
90
98
  "dependencies": {
91
- "@cosmicdrift/kumiko-bundled-features": "0.387.0",
92
- "@cosmicdrift/kumiko-framework": "0.387.0",
93
- "@cosmicdrift/kumiko-renderer": "0.387.0",
94
- "@cosmicdrift/kumiko-renderer-mail-html": "0.387.0",
95
- "@cosmicdrift/kumiko-types": "0.387.0",
96
- "bun-types": "^1.3.13",
99
+ "@cosmicdrift/kumiko-bundled-features": "0.389.0",
100
+ "@cosmicdrift/kumiko-framework": "0.389.0",
101
+ "@cosmicdrift/kumiko-renderer": "0.389.0",
102
+ "@cosmicdrift/kumiko-renderer-mail-html": "0.389.0",
103
+ "@cosmicdrift/kumiko-types": "0.389.0",
97
104
  "ioredis": "^5.10.1",
98
105
  "temporal-polyfill": "^0.3.2",
99
106
  "zod": "^4.4.3"
100
107
  },
108
+ "peerDependencies": {
109
+ "bun-types": "^1.4.4"
110
+ },
101
111
  "devDependencies": {
102
- "@cosmicdrift/kumiko-testing": "0.387.0"
112
+ "@cosmicdrift/kumiko-testing": "0.389.0",
113
+ "bun-types": "^1.4.4"
103
114
  },
104
115
  "publishConfig": {
105
116
  "registry": "https://registry.npmjs.org",
@@ -137,6 +148,10 @@
137
148
  "types": "./dist/boot/apply-boot-seeds.d.ts",
138
149
  "default": "./dist/boot/apply-boot-seeds.js"
139
150
  },
151
+ "./boot/shared-boot-steps": {
152
+ "types": "./dist/boot/shared-boot-steps.d.ts",
153
+ "default": "./dist/boot/shared-boot-steps.js"
154
+ },
140
155
  "./boot/boot-crypto": {
141
156
  "types": "./dist/boot/boot-crypto.d.ts",
142
157
  "default": "./dist/boot/boot-crypto.js"
@@ -153,6 +168,10 @@
153
168
  "types": "./dist/renderer-web-fonts.d.ts",
154
169
  "default": "./dist/renderer-web-fonts.js"
155
170
  },
171
+ "./resolve-installed-package": {
172
+ "types": "./dist/resolve-installed-package.d.ts",
173
+ "default": "./dist/resolve-installed-package.js"
174
+ },
156
175
  "./resolve-tailwind-cli": {
157
176
  "types": "./dist/resolve-tailwind-cli.d.ts",
158
177
  "default": "./dist/resolve-tailwind-cli.js"
package/src/changes.json CHANGED
@@ -1,4 +1,90 @@
1
1
  [
2
+ {
3
+ "version": "0.389.0",
4
+ "type": "fix",
5
+ "title": "The renderer-web stylesheet fallback checks tailwindcss in node_modules",
6
+ "detail": "canResolveTailwindStylesheet looks for tailwindcss in the node_modules directories above the stylesheet, as Tailwind does, instead of asking Bun.resolveSync. On Bun 1.4.4 the resolver auto-installs tailwindcss next to a renderer copy in Bun's install cache, so a build without a node_modules tree took the fallback and then failed in Tailwind with \"Can't resolve 'tailwindcss'\". Such a build skips the fallback stylesheet again."
7
+ },
8
+ {
9
+ "version": "0.389.0",
10
+ "type": "improvement",
11
+ "title": "Package lookups no longer auto-install from the registry",
12
+ "detail": "The new @cosmicdrift/kumiko-server-runtime/resolve-installed-package export looks up node_modules before asking Bun.resolveSync, which installs missing packages from the registry since Bun 1.4.4. The prod build, the dev-server stylesheet lookup and the handbuch commands use it."
13
+ },
14
+ {
15
+ "version": "0.389.0",
16
+ "type": "improvement",
17
+ "title": "bundledLists sets one table block for every bundled list",
18
+ "detail": "composeFeatures takes bundledLists with a table block and an optional pinFirstColumn flag. The block is mixed into every entityList, projectionList and relatedList section of the bundled features, the foundation features user and tenant as well as the features an app mounts from @cosmicdrift/kumiko-bundled-features, before the boot validator runs. A key the screen sets itself wins, export is left out on relatedList sections, and pinFirstColumn pins the first visible column left where no column is pinned yet. grouping and totals are rejected in the shared block. App screens stay untouched. Features opt in with the new registrar method r.adoptsBundledLists(), which every bundled feature with lists calls and which feature packages such as Enterprise can call for their own lists; app features never do. No migration for apps. The option lives in AppConfig.bundledLists for the managed kumiko/schema.ts and in the run options of runProdApp, runDevApp and runWorkerApp, so kumiko check and the running app see the same screens."
19
+ },
20
+ {
21
+ "version": "0.389.0",
22
+ "type": "improvement",
23
+ "title": "Boot database backoff takes an injectable clock",
24
+ "detail": "The new databaseWait option on runProdApp and runWorkerApp swaps sleep, now and the log sink of the database, KMS and seed waits. A worker boot against an unreachable database is now tested to retry until the deadline, abort with the connection error and close its Redis clients."
25
+ },
26
+ {
27
+ "version": "0.389.0",
28
+ "type": "fix",
29
+ "title": "Default CSP covers inline scripts of HTML written after the build",
30
+ "detail": "At boot the hashes from csp-hashes.json are merged with the inline scripts found in the HTML files under staticDir, for the default CSP and for hostDispatch. Boot-rendered pages keep their inline scripts working without a custom securityHeaders.csp."
31
+ },
32
+ {
33
+ "version": "0.389.0",
34
+ "type": "fix",
35
+ "title": "Read-only demo mode blocks WebSocket upgrades",
36
+ "detail": "Upgrade requests count as mutating in the demo read-only gate and get 403 demo_read_only unless the route path is in allowedWritePaths. Socket routes in a read-only demo that need to stay open must be listed there."
37
+ },
38
+ {
39
+ "version": "0.389.0",
40
+ "type": "breaking",
41
+ "title": "BootOptionName drops demoMode, seeds and signals",
42
+ "detail": "No stack declared them in bootRequires, so their boot checks never ran. A name returns together with its check and a test once a stack needs it.",
43
+ "migration": "no known callers; remove \"demoMode\", \"seeds\" and \"signals\" from bootRequires options"
44
+ },
45
+ {
46
+ "version": "0.389.0",
47
+ "type": "improvement",
48
+ "title": "appOverrides work in runWorkerApp and runDevApp",
49
+ "detail": "Both boot functions take the same appOverrides option as runProdApp and share its merge, so worker-rendered mails and the dev server resolve the same tenant model, branding and SEO values as the API. The runSingleInstance:false warning names appOverrides next to mail, fileStorage and featureToggles."
50
+ },
51
+ {
52
+ "version": "0.389.0",
53
+ "type": "fix",
54
+ "title": "Boot seeds survive a short database outage",
55
+ "detail": "applyStandardBootSeeds re-runs the idempotent seed sequence with the database backoff on transient connection errors (ECONNREFUSED, connection class 08, too_many_connections) until the 90 second deadline. Non-transient errors still abort the boot at once."
56
+ },
57
+ {
58
+ "version": "0.389.0",
59
+ "type": "improvement",
60
+ "title": "filesForTenant in SystemWireDeps",
61
+ "detail": "The wire hook and the worker wireComponents receive filesForTenant, built from the AppContext after buildServer wired it. ApiEntrypoint and WorkerEntrypoint expose that context as entrypoint.context."
62
+ },
63
+ {
64
+ "version": "0.388.0",
65
+ "type": "improvement",
66
+ "title": "runProdApp split into boot phases, boot steps shared with dev and worker",
67
+ "detail": "runProdApp() keeps its signature and behavior. Config resolution, feature composition, dependency connection, request context, auth wiring, entrypoint, seeds and the returned handle now live in run-prod-app-*.ts files next to run-prod-app.ts. Steps that prod, dev and the worker ran as copies (env defaults, feature composition, boot validation, the auth-mfa switch-tenant gate, the tier and feature-toggle resolver, standard boot seeds, shared auth routes, the KMS health gate and the database pools) live once in the new subpath @cosmicdrift/kumiko-server-runtime/boot/shared-boot-steps. requireEnv is still exported from run-prod-app under the same name."
68
+ },
69
+ {
70
+ "version": "0.388.0",
71
+ "type": "fix",
72
+ "title": "runProdApp releases connections when the boot fails",
73
+ "detail": "A failing boot closes the database pools, the Redis client and the KMS adapter it already opened. The KMS health wait logs \"KMS not reachable\" instead of \"database not reachable\"."
74
+ },
75
+ {
76
+ "version": "0.388.0",
77
+ "type": "fix",
78
+ "title": "Boot validation and shutdown hardening",
79
+ "detail": "The KMS and app database waits share one deadline so a boot never outlasts the liveness window. An app-supplied master key provider is checked at boot, also in a dry run. Additional fileStorage providers get the same production and S3 checks as the default one, and their env keys are validated. appOverrides without auth or delivery feature abort instead of being dropped. A fatal shutdown keeps its listeners installed, and inline script hashing handles a \">\" inside quoted attributes."
80
+ },
81
+ {
82
+ "version": "0.388.0",
83
+ "type": "breaking",
84
+ "title": "billing boot option takes stripe and/or dodo",
85
+ "detail": "billing.stripe is now optional and billing.dodo is new (priceToTier, oneOffPriceIds). At least one is required. resolveBillingOption returns features (an array) instead of feature, and one webhook route serves every provider on stripe.webhookPath or SUBSCRIPTION_WEBHOOK_PATH. DODO_PAYMENTS_API_KEY and DODO_PAYMENTS_WEBHOOK_KEY are the env bridge.",
86
+ "migration": "Callers of resolveBillingOption use billing.features instead of billing.feature."
87
+ },
2
88
  {
3
89
  "version": "0.385.0",
4
90
  "type": "improvement",