@sdxc/kit 2026.10.20 → 2026.10.23
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/README.md +178 -93
- package/changelog.jsonl +97 -0
- package/config.schema.json +160 -0
- package/dist/architecture/complexity.d.ts +73 -0
- package/dist/architecture/complexity.js +185 -0
- package/dist/architecture/crap.d.ts +62 -0
- package/dist/architecture/crap.js +121 -0
- package/dist/architecture/graph.d.ts +55 -0
- package/dist/architecture/graph.js +194 -0
- package/dist/architecture/layers.d.ts +29 -0
- package/dist/architecture/layers.js +81 -0
- package/dist/architecture/mermaid.d.ts +20 -0
- package/dist/architecture/mermaid.js +51 -0
- package/dist/cli.js +9 -0
- package/dist/commands/create.js +4 -3
- package/dist/commands/deploy.js +10 -9
- package/dist/commands/destroy.d.ts +1 -1
- package/dist/commands/diagram.d.ts +17 -0
- package/dist/commands/diagram.js +45 -0
- package/dist/commands/fix.d.ts +69 -0
- package/dist/commands/fix.js +102 -0
- package/dist/commands/make.d.ts +77 -2
- package/dist/commands/make.js +53 -1
- package/dist/commands/run.d.ts +15 -11
- package/dist/commands/run.js +21 -16
- package/dist/commands/scaffold.d.ts +2 -1
- package/dist/commands/scaffold.js +1 -0
- package/dist/commands/setup.d.ts +26 -0
- package/dist/commands/setup.js +33 -0
- package/dist/config.d.ts +54 -0
- package/dist/config.js +92 -1
- package/dist/contract.d.ts +56 -3
- package/dist/contract.js +140 -7
- package/dist/dependencies.d.ts +2 -1
- package/dist/dependencies.js +11 -2
- package/dist/deploy/plan.d.ts +5 -0
- package/dist/deploy/plan.js +10 -0
- package/dist/destroy.d.ts +4 -4
- package/dist/destroy.js +24 -11
- package/dist/diagram.d.ts +32 -0
- package/dist/diagram.js +47 -0
- package/dist/doctor/checks.d.ts +2 -1
- package/dist/doctor/checks.js +26 -1
- package/dist/doctor/complexity.d.ts +13 -0
- package/dist/doctor/complexity.js +52 -0
- package/dist/doctor/crap.d.ts +14 -0
- package/dist/doctor/crap.js +67 -0
- package/dist/doctor/dependencies.d.ts +13 -0
- package/dist/doctor/dependencies.js +42 -0
- package/dist/doctor/duplication.d.ts +19 -0
- package/dist/doctor/duplication.js +106 -0
- package/dist/doctor/fan-out.d.ts +12 -0
- package/dist/doctor/fan-out.js +42 -0
- package/dist/doctor/feature-scatter.d.ts +15 -0
- package/dist/doctor/feature-scatter.js +84 -0
- package/dist/doctor/jsdoc.d.ts +44 -0
- package/dist/doctor/jsdoc.js +201 -0
- package/dist/doctor/module-size.d.ts +13 -0
- package/dist/doctor/module-size.js +50 -0
- package/dist/doctor/mutation.d.ts +20 -0
- package/dist/doctor/mutation.js +97 -0
- package/dist/doctor/orphans.d.ts +13 -0
- package/dist/doctor/orphans.js +50 -0
- package/dist/doctor/project.js +8 -5
- package/dist/doctor/result-throws.d.ts +17 -0
- package/dist/doctor/result-throws.js +72 -0
- package/dist/doctor/test-ratio.d.ts +12 -0
- package/dist/doctor/test-ratio.js +31 -0
- package/dist/fix/commands.d.ts +37 -0
- package/dist/fix/commands.js +63 -0
- package/dist/fix/emails.d.ts +21 -0
- package/dist/fix/emails.js +159 -0
- package/dist/fix/env.d.ts +29 -0
- package/dist/fix/env.js +58 -0
- package/dist/fix/index.d.ts +11 -0
- package/dist/fix/index.js +11 -0
- package/dist/fix/models.d.ts +20 -0
- package/dist/fix/models.js +95 -0
- package/dist/lock.js +12 -2
- package/dist/make/binding.d.ts +42 -0
- package/dist/make/binding.js +237 -0
- package/dist/make/generate.d.ts +11 -2
- package/dist/make/generate.js +47 -16
- package/dist/make/imports.js +7 -5
- package/dist/make/index.d.ts +4 -2
- package/dist/make/index.js +4 -1
- package/dist/make/kinds.d.ts +5 -0
- package/dist/make/kinds.js +14 -2
- package/dist/make/schema-diff.js +8 -1
- package/dist/make/stubs.d.ts +7 -2
- package/dist/make/stubs.js +8 -3
- package/dist/make/test.js +1 -0
- package/dist/models.js +7 -7
- package/dist/routes/modules.js +8 -5
- package/dist/routes/parse.js +8 -7
- package/dist/routes/routers.js +9 -5
- package/dist/scaffold/index.d.ts +2 -0
- package/dist/scaffold/index.js +13 -4
- package/dist/scaffold/render.d.ts +11 -1
- package/dist/scaffold/render.js +86 -1
- package/dist/setup/auth.d.ts +12 -0
- package/dist/setup/auth.js +209 -0
- package/dist/setup/billing.d.ts +11 -0
- package/dist/setup/billing.js +116 -0
- package/dist/setup/catalog.d.ts +25 -0
- package/dist/setup/catalog.js +34 -0
- package/dist/setup/credit.d.ts +13 -0
- package/dist/setup/credit.js +21 -0
- package/dist/setup/flags.d.ts +11 -0
- package/dist/setup/flags.js +62 -0
- package/dist/setup/index.d.ts +25 -0
- package/dist/setup/index.js +53 -0
- package/dist/setup/plan.d.ts +38 -0
- package/dist/setup/plan.js +62 -0
- package/dist/testing.js +3 -3
- package/dist/ui/layout.js +1 -1
- package/dist/ui/registry.d.ts +2 -2
- package/dist/upgrade/project.d.ts +2 -2
- package/dist/upgrade/prompt.js +7 -5
- package/package.json +10 -7
- package/registry/ui/attachment.json +2 -2
- package/registry/ui/sidebar.json +3 -3
- package/registry/ui/typeset.json +3 -3
- package/stubs/command.spec.stub +15 -0
- package/stubs/controller.api.spec.stub +15 -0
- package/stubs/controller.spec.stub +15 -0
- package/stubs/mcp.spec.stub +16 -0
- package/stubs/scaffold.migration.stub +2 -1
- package/stubs/scaffold.spec.stub +7 -0
- package/templates/app/AGENTS.md +21 -4
- package/templates/app/README.md +6 -3
- package/templates/app/app/commands/typegen.test.ts +20 -1
- package/templates/app/app/commands/typegen.ts +16 -2
- package/templates/app/app/initializers/cli.ts +7 -0
- package/templates/app/app/initializers/mail-transport.test.ts +8 -2
- package/templates/app/app/test/cloudflare-workers.ts +2 -0
- package/templates/app/package.json +1 -0
- package/templates/app/spec/config.jsonc +16 -0
package/templates/app/README.md
CHANGED
|
@@ -25,7 +25,7 @@ sdxc make migration create-tags name # then: sdxc run db migrate
|
|
|
25
25
|
sdxc make job reports/daily --cron "0 8 * * *"
|
|
26
26
|
sdxc make email welcome name # then: ctx.email.later(emails.welcome, { to, props })
|
|
27
27
|
sdxc make command users/grant # then: sdxc run users grant
|
|
28
|
-
sdxc scaffold post title body:text # model, migration, CRUD pages and
|
|
28
|
+
sdxc scaffold post title body:text # model, migration, CRUD pages, tests and a .spec
|
|
29
29
|
|
|
30
30
|
sdxc run db console # SQL prompt over the local database
|
|
31
31
|
sdxc run console # Bun's REPL with db and models loaded
|
|
@@ -34,12 +34,15 @@ sdxc run db fresh --seed # drop every local table, migrate, se
|
|
|
34
34
|
sdxc run emails preview welcome # print an email from its preview(); /_emails in bun dev
|
|
35
35
|
sdxc routes # every route and its controller (-g, -c, --unused)
|
|
36
36
|
sdxc doctor # release drift, secrets, migrations and wiring
|
|
37
|
+
bunx spec run spec --allow-config # black-box .spec suite under spec/
|
|
37
38
|
bun check # format, lint and types
|
|
38
39
|
bun run test
|
|
39
40
|
```
|
|
40
41
|
|
|
41
|
-
`sdxc make` writes the file where it belongs with a test beside it, and
|
|
42
|
-
|
|
42
|
+
`sdxc make` writes the file where it belongs with a test beside it, and for a controller, command
|
|
43
|
+
or MCP tool a pairing `.spec` under `spec/` so you can exercise it as a black box. It maps the
|
|
44
|
+
file so it works right away. `sdxc` comes with the project; `npm add -g @sdxc/kit` puts it on
|
|
45
|
+
your path.
|
|
43
46
|
|
|
44
47
|
`AGENTS.md` teaches an AI coding agent these commands and conventions, and `CLAUDE.md` points
|
|
45
48
|
Claude Code at it. `sdxc upgrade` keeps its sdxc section current; add your own rules below it.
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The `typegen` command, which hands type generation to `cf` in the project's root
|
|
2
|
+
* The `typegen` command, which hands type generation to `cf` in the project's root and stamps the
|
|
3
|
+
* types as current even when `cf` found nothing to change.
|
|
3
4
|
*/
|
|
4
5
|
|
|
6
|
+
import { mkdir, stat, utimes, writeFile } from "node:fs/promises";
|
|
7
|
+
import { dirname } from "node:path";
|
|
8
|
+
|
|
5
9
|
import { invoke } from "@sdxc/cli/test";
|
|
10
|
+
import { isFailure, wrap } from "@sdxc/result";
|
|
6
11
|
import { describe, expect, test } from "vitest";
|
|
7
12
|
|
|
13
|
+
import { TYPES_FILE } from "~/app/commands/typegen";
|
|
8
14
|
import { cli } from "~/app/initializers/cli";
|
|
9
15
|
|
|
10
16
|
describe("typegen", () => {
|
|
@@ -14,4 +20,17 @@ describe("typegen", () => {
|
|
|
14
20
|
expect(run.code).toBe(0);
|
|
15
21
|
expect(run.exec.map((call) => call.command)).toEqual([["cf", "workers", "types"]]);
|
|
16
22
|
});
|
|
23
|
+
|
|
24
|
+
test("stamps types cf left unchanged, so sdxc doctor reads them as current", async () => {
|
|
25
|
+
if (isFailure(await wrap(() => stat(TYPES_FILE)))) {
|
|
26
|
+
await mkdir(dirname(TYPES_FILE), { recursive: true });
|
|
27
|
+
await writeFile(TYPES_FILE, "");
|
|
28
|
+
}
|
|
29
|
+
await utimes(TYPES_FILE, new Date(0), new Date(0));
|
|
30
|
+
let started = Date.now();
|
|
31
|
+
|
|
32
|
+
await invoke(cli, ["typegen"], { exec: { "cf workers types": { code: 0 } } });
|
|
33
|
+
|
|
34
|
+
expect((await stat(TYPES_FILE)).mtimeMs).toBeGreaterThanOrEqual(started - 1_000);
|
|
35
|
+
});
|
|
17
36
|
});
|
|
@@ -4,13 +4,27 @@
|
|
|
4
4
|
* type check against what the Worker receives. Safe to run twice.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import { utimes } from "node:fs/promises";
|
|
8
|
+
import { join } from "node:path";
|
|
9
|
+
|
|
7
10
|
import { createCommand, success } from "@sdxc/cli";
|
|
8
|
-
import { isFailure } from "@sdxc/result";
|
|
11
|
+
import { isFailure, wrap } from "@sdxc/result";
|
|
9
12
|
|
|
10
13
|
import commandset from "~/app/commands";
|
|
11
14
|
import { PROJECT_ROOT } from "~/app/initializers/local-database";
|
|
12
15
|
|
|
16
|
+
/** Where `cf workers types` writes the types, the file the project's tsconfig includes. */
|
|
17
|
+
export const TYPES_FILE = join(PROJECT_ROOT, ".cloudflare/types/index.d.ts");
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Generates the types, then stamps them with the current time: `cf` keeps an unchanged file as it
|
|
21
|
+
* was, and the stamp is what tells `sdxc doctor` the types match the config after an edit that
|
|
22
|
+
* adds no binding, like a cron trigger.
|
|
23
|
+
*/
|
|
13
24
|
export default createCommand(commandset.typegen, async (ctx) => {
|
|
14
25
|
let generated = await ctx.exec(["cf", "workers", "types"], { cwd: PROJECT_ROOT });
|
|
15
|
-
|
|
26
|
+
if (isFailure(generated)) return generated;
|
|
27
|
+
let now = new Date();
|
|
28
|
+
await wrap(() => utimes(TYPES_FILE, now, now));
|
|
29
|
+
return success();
|
|
16
30
|
});
|
|
@@ -99,3 +99,10 @@ cli.map(
|
|
|
99
99
|
commandset.typegen,
|
|
100
100
|
lazy(() => import("~/app/commands/typegen")),
|
|
101
101
|
);
|
|
102
|
+
|
|
103
|
+
declare module "@sdxc/cli" {
|
|
104
|
+
/** Types every command handler's `ctx` with what the middleware above publishes: `ctx.db`, `ctx.models`, `ctx.email` and `ctx.intl`. */
|
|
105
|
+
interface CLITypes {
|
|
106
|
+
cli: typeof cli;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The app's mail transport, delivering into the in-memory `send_email` stand-in tests receive
|
|
3
|
-
* as the `EMAIL` binding.
|
|
3
|
+
* as the `EMAIL` binding, and its queue, handing deliveries to the `QUEUE` binding.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { Mailer } from "@sdxc/mail";
|
|
7
7
|
import { env } from "cloudflare:workers";
|
|
8
8
|
import { describe, expect, test } from "vitest";
|
|
9
9
|
|
|
10
|
-
import { transport } from "~/app/initializers/mail-transport";
|
|
10
|
+
import { queue, transport } from "~/app/initializers/mail-transport";
|
|
11
11
|
import { MAIL_FROM } from "~/config/constants";
|
|
12
12
|
|
|
13
13
|
describe("transport", () => {
|
|
@@ -24,4 +24,10 @@ describe("transport", () => {
|
|
|
24
24
|
messages: [expect.objectContaining({ subject: "Welcome" })],
|
|
25
25
|
});
|
|
26
26
|
});
|
|
27
|
+
|
|
28
|
+
test("queues a delivery for the email job on the QUEUE binding", async () => {
|
|
29
|
+
await queue({ email: "welcome", to: "ada@example.com", props: {} });
|
|
30
|
+
|
|
31
|
+
expect(env.QUEUE).toMatchObject({ messages: [expect.anything()] });
|
|
32
|
+
});
|
|
27
33
|
});
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import {
|
|
9
9
|
createD1Database,
|
|
10
10
|
createKVNamespace,
|
|
11
|
+
createQueue,
|
|
11
12
|
createRateLimit,
|
|
12
13
|
createSendEmail,
|
|
13
14
|
} from "@sdxc/cloudflare-mocks";
|
|
@@ -16,6 +17,7 @@ import {
|
|
|
16
17
|
export const env = {
|
|
17
18
|
DB: createD1Database(),
|
|
18
19
|
EMAIL: createSendEmail(),
|
|
20
|
+
QUEUE: createQueue(),
|
|
19
21
|
RATE_LIMITER: createRateLimit(),
|
|
20
22
|
SESSIONS: createKVNamespace(),
|
|
21
23
|
SESSION_SECRET: "development-session-secret",
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
// The URL `browser`, `http` and `mcp` resolve `/path` targets against. Set APP_BASE_URL
|
|
3
|
+
// to point the suite at another host; the default matches `bun run dev`.
|
|
4
|
+
"bases": {
|
|
5
|
+
"web": { "env": "APP_BASE_URL", "default": "http://localhost:5173" },
|
|
6
|
+
},
|
|
7
|
+
// Applied once a run adds `--allow-config`. Pairing specs from `sdxc make` and
|
|
8
|
+
// `sdxc scaffold` expect these grants for a local black-box run.
|
|
9
|
+
"permissions": {
|
|
10
|
+
"allow": [
|
|
11
|
+
["run", "bun"],
|
|
12
|
+
["host-fs", "."],
|
|
13
|
+
["net", "localhost:5173"],
|
|
14
|
+
],
|
|
15
|
+
},
|
|
16
|
+
}
|