@cosmicdrift/kumiko-dev-server 1.0.0 → 2.0.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 (66) hide show
  1. package/bin/kumiko-schema-check.ts +7 -0
  2. package/package.json +12 -7
  3. package/src/__tests__/build-prod-bundle.integration.test.ts +1 -1
  4. package/src/__tests__/build-server-bundle.test.ts +62 -0
  5. package/src/__tests__/compose-stacks.test.ts +271 -0
  6. package/src/__tests__/create-kumiko-server-errors.test.ts +54 -0
  7. package/src/__tests__/create-kumiko-server-options.test.ts +33 -0
  8. package/src/__tests__/create-kumiko-server.integration.test.ts +128 -1
  9. package/src/__tests__/discover-format.test.ts +1 -1
  10. package/src/__tests__/env-schema.integration.test.ts +1 -1
  11. package/src/__tests__/few-shot-corpus.test.ts +16 -11
  12. package/src/__tests__/merge-extra-context.test.ts +56 -0
  13. package/src/__tests__/resolve-stylesheet.test.ts +16 -0
  14. package/src/__tests__/saas-identity-wire.integration.test.ts +430 -0
  15. package/src/__tests__/scaffold-app-feature.test.ts +59 -6
  16. package/src/__tests__/scaffold-app.test.ts +34 -2
  17. package/src/__tests__/schema-apply.integration.test.ts +5 -2
  18. package/src/__tests__/setup-test-stack-from-features.integration.test.ts +30 -0
  19. package/src/__tests__/walkthrough.integration.test.ts +22 -6
  20. package/src/build-server-bundle.ts +33 -15
  21. package/src/build.ts +1 -2
  22. package/src/codegen/__tests__/render-codegen.test.ts +2 -1
  23. package/src/codegen/__tests__/run-codegen.test.ts +2 -2
  24. package/src/codegen/__tests__/strict-mode-diagnostics.test.ts +6 -1
  25. package/src/codegen/__tests__/watch.test.ts +1 -2
  26. package/src/codegen/render.ts +6 -1
  27. package/src/codegen/scan-events.ts +7 -5
  28. package/src/codegen/watch.ts +7 -4
  29. package/src/compose-stacks.ts +184 -0
  30. package/src/create-kumiko-server.ts +28 -5
  31. package/src/few-shot-corpus.ts +4 -3
  32. package/src/index.ts +30 -12
  33. package/src/run-dev-app.ts +195 -61
  34. package/src/scaffold-app-feature.ts +118 -15
  35. package/src/scaffold-app.ts +151 -79
  36. package/src/scaffold-demo-tasks.ts +233 -0
  37. package/src/schema-apply.ts +15 -2
  38. package/src/schema-check-core.ts +1 -1
  39. package/src/setup-test-stack-from-features.ts +61 -0
  40. package/src/welcome-banner.ts +1 -4
  41. package/src/__tests__/boot-extra-context.test.ts +0 -140
  42. package/src/__tests__/build-prod-bundle.test.ts +0 -311
  43. package/src/__tests__/cache-headers.test.ts +0 -83
  44. package/src/__tests__/compose-features-wiring.integration.test.ts +0 -382
  45. package/src/__tests__/compose-features.test.ts +0 -129
  46. package/src/__tests__/config-seed-boot.integration.test.ts +0 -158
  47. package/src/__tests__/inject-schema.test.ts +0 -62
  48. package/src/__tests__/renderer-web-css-relocation.integration.test.ts +0 -85
  49. package/src/__tests__/renderer-web-shell-sentinel.test.ts +0 -35
  50. package/src/__tests__/require-env.test.ts +0 -29
  51. package/src/__tests__/resolve-auth-mail.test.ts +0 -69
  52. package/src/__tests__/resolve-tailwind-cli.test.ts +0 -81
  53. package/src/__tests__/run-prod-app-env-source.test.ts +0 -157
  54. package/src/__tests__/run-prod-app-spec.test.ts +0 -57
  55. package/src/__tests__/run-prod-app.integration.test.ts +0 -840
  56. package/src/__tests__/session-wiring.test.ts +0 -51
  57. package/src/__tests__/try-hono-first.test.ts +0 -63
  58. package/src/boot/apply-boot-seeds.ts +0 -18
  59. package/src/build-prod-bundle.ts +0 -697
  60. package/src/compose-features.ts +0 -145
  61. package/src/extra-routes-deps.ts +0 -47
  62. package/src/inject-schema.ts +0 -24
  63. package/src/resolve-tailwind-cli.ts +0 -45
  64. package/src/run-prod-app.ts +0 -1492
  65. package/src/session-wiring.ts +0 -29
  66. package/src/try-hono-first.ts +0 -46
@@ -1,51 +0,0 @@
1
- import { describe, expect, it } from "bun:test";
2
- import {
3
- createSessionsFeature,
4
- SESSIONS_FEATURE,
5
- } from "@cosmicdrift/kumiko-bundled-features/sessions";
6
- import { resolveProdSessionsConfig, shouldWireProdSessions } from "../session-wiring";
7
-
8
- describe("shouldWireProdSessions — secure-by-default with opt-out (KF-1)", () => {
9
- it("wires sessions when the feature is mounted, even without an explicit config", () => {
10
- // The publicstatus bug: sessions feature mounted + auth set, but no auth.sessions —
11
- // previously left stateless (no revocation). Now it wires automatically.
12
- expect(shouldWireProdSessions(true, true, undefined)).toBe(true);
13
- });
14
-
15
- it("wires sessions when a config object is given", () => {
16
- expect(shouldWireProdSessions(true, true, { expiresInMs: 1000 })).toBe(true);
17
- });
18
-
19
- it("does not wire when sessions: false (explicit opt-out)", () => {
20
- expect(shouldWireProdSessions(true, true, false)).toBe(false);
21
- });
22
-
23
- it("does not wire when the sessions feature is not mounted", () => {
24
- expect(shouldWireProdSessions(true, false, undefined)).toBe(false);
25
- });
26
-
27
- it("does not wire when the app has no auth at all", () => {
28
- expect(shouldWireProdSessions(false, true, undefined)).toBe(false);
29
- });
30
- });
31
-
32
- describe("SESSIONS_FEATURE constant matches the real feature name", () => {
33
- it("createSessionsFeature()'s name equals SESSIONS_FEATURE", () => {
34
- // shouldWireProdSessions's own arm only tests the pure boolean helper —
35
- // the actual run-prod-app.ts integration seam
36
- // (`features.some((f) => f.name === SESSIONS_FEATURE)`) drifts silently
37
- // if the feature is ever renamed without updating this constant.
38
- expect(createSessionsFeature().name).toBe(SESSIONS_FEATURE);
39
- });
40
- });
41
-
42
- describe("resolveProdSessionsConfig", () => {
43
- it("passes a config object through", () => {
44
- expect(resolveProdSessionsConfig({ expiresInMs: 5000 })).toEqual({ expiresInMs: 5000 });
45
- });
46
-
47
- it("collapses false / undefined to defaults", () => {
48
- expect(resolveProdSessionsConfig(undefined)).toEqual({});
49
- expect(resolveProdSessionsConfig(false)).toEqual({});
50
- });
51
- });
@@ -1,63 +0,0 @@
1
- // Pure-function pin für tryHonoFirst. Trivial aber load-bearing:
2
- // Drift zwischen dev (createKumikoServer) und prod (runProdApp) hat
3
- // schon einen Bug verursacht (legal-pages funktionierten in prod aber
4
- // nicht in dev). Beide nutzen jetzt diesen helper — wenn die Semantik
5
- // sich ändert (z.B. "matched" auch für 4xx anders als 404), MÜSSEN
6
- // beide Pfade synchron updaten.
7
-
8
- import { describe, expect, test } from "bun:test";
9
- import { type HonoLikeApp, tryHonoFirst } from "../try-hono-first";
10
-
11
- function makeApp(response: Response): HonoLikeApp {
12
- return { fetch: () => response };
13
- }
14
-
15
- function makeAsyncApp(response: Response): HonoLikeApp {
16
- return { fetch: async () => response };
17
- }
18
-
19
- describe("tryHonoFirst", () => {
20
- test("matched=true bei 200 (Hono-route greift)", async () => {
21
- const app = makeApp(new Response("ok", { status: 200 }));
22
- const res = await tryHonoFirst(app, new Request("http://test/foo"));
23
- expect(res.matched).toBe(true);
24
- expect(res.response.status).toBe(200);
25
- });
26
-
27
- test("matched=false bei 404 (keine Route — caller fällt auf SPA-fallback)", async () => {
28
- const app = makeApp(new Response("not found", { status: 404 }));
29
- const res = await tryHonoFirst(app, new Request("http://test/unknown"));
30
- expect(res.matched).toBe(false);
31
- // response wird trotzdem zurückgegeben — caller kann den 404 als
32
- // letztes Sicherheitsnetz nutzen wenn auch SPA-fallback nichts liefert.
33
- expect(res.response.status).toBe(404);
34
- });
35
-
36
- test("matched=true bei 401/403/500 (Hono hat geantwortet — kein SPA-fallback)", async () => {
37
- // Bug-Pin: matched darf NUR bei status=404 false sein. Wenn Hono
38
- // 401 (auth required) returnt, war die Route klar gefunden + hat
39
- // bewusst rejected — SPA-fallback würde das überschreiben und den
40
- // User auf eine SPA leiten statt die 401-message zu zeigen.
41
- for (const status of [401, 403, 422, 500] as const) {
42
- const app = makeApp(new Response(null, { status }));
43
- const res = await tryHonoFirst(app, new Request("http://test/x"));
44
- expect(res.matched, `status ${status} should be matched`).toBe(true);
45
- }
46
- });
47
-
48
- test("akzeptiert sowohl sync als auch async fetch (Hono-Variation)", async () => {
49
- // Hono.app.fetch returnt Response | Promise<Response> abhängig vom
50
- // handler-mix. createApiEntrypoint's apiHandler dasselbe. Helper
51
- // muss beide schluckable.
52
- const sync = await tryHonoFirst(
53
- makeApp(new Response("s", { status: 200 })),
54
- new Request("http://t/"),
55
- );
56
- const asyncRes = await tryHonoFirst(
57
- makeAsyncApp(new Response("a", { status: 200 })),
58
- new Request("http://t/"),
59
- );
60
- expect(sync.matched).toBe(true);
61
- expect(asyncRes.matched).toBe(true);
62
- });
63
- });
@@ -1,18 +0,0 @@
1
- import { seedAllConfigValues } from "@cosmicdrift/kumiko-bundled-features/config";
2
- import type { DbConnection, EncryptionProvider } from "@cosmicdrift/kumiko-framework/db";
3
- import type { Registry } from "@cosmicdrift/kumiko-framework/engine";
4
-
5
- // Single boot-seed entry-point. runDevApp + runProdApp both call this
6
- // from their post-stack hook, so the wiring lives in exactly one place
7
- // — config-seed-boot.integration.ts pins this helper, which means a
8
- // missing call site (e.g. someone deletes the line from runDevApp)
9
- // surfaces as a missing-helper-use in code review rather than silently
10
- // shipping a server that never seeds.
11
- // @wrapper-known semantic-alias
12
- export async function applyBootSeeds(deps: {
13
- registry: Registry;
14
- db: DbConnection;
15
- encryption?: EncryptionProvider;
16
- }): Promise<void> {
17
- await seedAllConfigValues(deps.registry, deps.db, deps.encryption);
18
- }