@sdxc/kit 0.0.0-pre.1 → 0.0.0-stage

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 (144) hide show
  1. package/README.md +2 -92
  2. package/package.json +5 -44
  3. package/LICENSE.md +0 -21
  4. package/config.schema.json +0 -89
  5. package/dist/bin.d.ts +0 -9
  6. package/dist/bin.js +0 -10
  7. package/dist/cli.d.ts +0 -33
  8. package/dist/cli.js +0 -58
  9. package/dist/commands/create.d.ts +0 -20
  10. package/dist/commands/create.js +0 -164
  11. package/dist/commands/init.d.ts +0 -16
  12. package/dist/commands/init.js +0 -27
  13. package/dist/commands/make.d.ts +0 -335
  14. package/dist/commands/make.js +0 -152
  15. package/dist/commands/run.d.ts +0 -23
  16. package/dist/commands/run.js +0 -51
  17. package/dist/commands/ui/add.d.ts +0 -23
  18. package/dist/commands/ui/add.js +0 -50
  19. package/dist/commands/ui/diff.d.ts +0 -20
  20. package/dist/commands/ui/diff.js +0 -28
  21. package/dist/commands/ui/list.d.ts +0 -24
  22. package/dist/commands/ui/list.js +0 -45
  23. package/dist/commands/ui/remove.d.ts +0 -22
  24. package/dist/commands/ui/remove.js +0 -48
  25. package/dist/commands/ui/update.d.ts +0 -23
  26. package/dist/commands/ui/update.js +0 -37
  27. package/dist/commands/upgrade.d.ts +0 -30
  28. package/dist/commands/upgrade.js +0 -184
  29. package/dist/config.d.ts +0 -81
  30. package/dist/config.js +0 -157
  31. package/dist/contract.d.ts +0 -161
  32. package/dist/contract.js +0 -308
  33. package/dist/create/github.d.ts +0 -63
  34. package/dist/create/github.js +0 -172
  35. package/dist/create/target.d.ts +0 -31
  36. package/dist/create/target.js +0 -56
  37. package/dist/create/templates.d.ts +0 -62
  38. package/dist/create/templates.js +0 -228
  39. package/dist/dependencies.d.ts +0 -34
  40. package/dist/dependencies.js +0 -76
  41. package/dist/diff.d.ts +0 -14
  42. package/dist/diff.js +0 -103
  43. package/dist/format.d.ts +0 -21
  44. package/dist/format.js +0 -40
  45. package/dist/init.d.ts +0 -38
  46. package/dist/init.js +0 -92
  47. package/dist/lock.d.ts +0 -74
  48. package/dist/lock.js +0 -214
  49. package/dist/make/declare.d.ts +0 -54
  50. package/dist/make/declare.js +0 -495
  51. package/dist/make/generate.d.ts +0 -56
  52. package/dist/make/generate.js +0 -139
  53. package/dist/make/imports.d.ts +0 -43
  54. package/dist/make/imports.js +0 -104
  55. package/dist/make/index.d.ts +0 -43
  56. package/dist/make/index.js +0 -136
  57. package/dist/make/kinds.d.ts +0 -39
  58. package/dist/make/kinds.js +0 -95
  59. package/dist/make/migrations.d.ts +0 -21
  60. package/dist/make/migrations.js +0 -48
  61. package/dist/make/names.d.ts +0 -31
  62. package/dist/make/names.js +0 -47
  63. package/dist/make/stubs.d.ts +0 -44
  64. package/dist/make/stubs.js +0 -89
  65. package/dist/middleware.d.ts +0 -44
  66. package/dist/middleware.js +0 -49
  67. package/dist/package-manager.d.ts +0 -41
  68. package/dist/package-manager.js +0 -80
  69. package/dist/project.d.ts +0 -19
  70. package/dist/project.js +0 -42
  71. package/dist/releases.d.ts +0 -40
  72. package/dist/releases.js +0 -110
  73. package/dist/testing.d.ts +0 -47
  74. package/dist/testing.js +0 -126
  75. package/dist/ui/commands.d.ts +0 -114
  76. package/dist/ui/commands.js +0 -432
  77. package/dist/ui/imports.d.ts +0 -46
  78. package/dist/ui/imports.js +0 -160
  79. package/dist/ui/layout.d.ts +0 -48
  80. package/dist/ui/layout.js +0 -138
  81. package/dist/ui/registry.d.ts +0 -58
  82. package/dist/ui/registry.js +0 -82
  83. package/dist/upgrade/changelog.d.ts +0 -50
  84. package/dist/upgrade/changelog.js +0 -69
  85. package/dist/upgrade/project.d.ts +0 -62
  86. package/dist/upgrade/project.js +0 -132
  87. package/dist/upgrade/prompt.d.ts +0 -51
  88. package/dist/upgrade/prompt.js +0 -227
  89. package/dist/upgrade/registry.d.ts +0 -33
  90. package/dist/upgrade/registry.js +0 -50
  91. package/lock.schema.json +0 -60
  92. package/stubs/command.stub +0 -12
  93. package/stubs/command.test.stub +0 -18
  94. package/stubs/controller.form.stub +0 -33
  95. package/stubs/controller.stub +0 -17
  96. package/stubs/controller.test.stub +0 -15
  97. package/stubs/email.stub +0 -44
  98. package/stubs/email.test.stub +0 -16
  99. package/stubs/factory.stub +0 -10
  100. package/stubs/initializer.stub +0 -7
  101. package/stubs/initializer.test.stub +0 -13
  102. package/stubs/job.cron.stub +0 -12
  103. package/stubs/job.stub +0 -11
  104. package/stubs/job.test.stub +0 -15
  105. package/stubs/mcp.resource.stub +0 -12
  106. package/stubs/mcp.stub +0 -10
  107. package/stubs/mcp.test.stub +0 -15
  108. package/stubs/middleware.stub +0 -11
  109. package/stubs/middleware.test.stub +0 -13
  110. package/stubs/migration.stub +0 -1
  111. package/stubs/model.stub +0 -24
  112. package/stubs/model.test.stub +0 -15
  113. package/stubs/policy.stub +0 -13
  114. package/stubs/policy.test.stub +0 -17
  115. package/stubs/service.stub +0 -13
  116. package/stubs/service.test.stub +0 -14
  117. package/stubs/validator.stub +0 -14
  118. package/stubs/validator.test.stub +0 -22
  119. package/templates/app/README.md +0 -57
  120. package/templates/app/app/commands/about.test.ts +0 -29
  121. package/templates/app/app/commands/about.ts +0 -34
  122. package/templates/app/app/commands/index.ts +0 -15
  123. package/templates/app/app/http/controllers/home.tsx +0 -22
  124. package/templates/app/app/http/controllers/not-found.tsx +0 -25
  125. package/templates/app/app/initializers/assets.ts +0 -11
  126. package/templates/app/app/initializers/cli.ts +0 -35
  127. package/templates/app/app/initializers/dispatcher.ts +0 -18
  128. package/templates/app/app/initializers/logger.ts +0 -10
  129. package/templates/app/app/initializers/mcp.ts +0 -16
  130. package/templates/app/app/initializers/router.tsx +0 -65
  131. package/templates/app/app/jobs/index.ts +0 -10
  132. package/templates/app/app/mcp/resources/index.ts +0 -9
  133. package/templates/app/app/mcp/tools/index.ts +0 -10
  134. package/templates/app/bootstrap/browser.ts +0 -27
  135. package/templates/app/bootstrap/cli.ts +0 -9
  136. package/templates/app/bootstrap/worker.ts +0 -31
  137. package/templates/app/cloudflare.config.ts +0 -28
  138. package/templates/app/config/router-context.d.ts +0 -20
  139. package/templates/app/gitignore +0 -9
  140. package/templates/app/package.json +0 -38
  141. package/templates/app/resources/layouts/document.tsx +0 -58
  142. package/templates/app/routes/web.ts +0 -12
  143. package/templates/app/tsconfig.json +0 -40
  144. package/templates/app/vite.config.ts +0 -40
@@ -1,13 +0,0 @@
1
- /**
2
- * The {{title}} middleware.
3
- */
4
-
5
- import { describe, expect, test } from "vitest";
6
-
7
- import {{key}} from "{{specifier}}";
8
-
9
- describe("{{name}}", () => {
10
- test("creates a middleware function", () => {
11
- expect(typeof {{key}}()).toBe("function");
12
- });
13
- });
@@ -1 +0,0 @@
1
- -- {{Name}}: write the statements this migration applies, in order.
package/stubs/model.stub DELETED
@@ -1,24 +0,0 @@
1
- /**
2
- * The {{title}} model and its table: describe what a row records and the rules that keep it
3
- * consistent. Keep the columns in step with the migration that creates the table.
4
- */
5
-
6
- import type { TableRow } from "remix/data-table";
7
-
8
- import { column as c, table } from "remix/data-table";
9
- import { createModel } from "@sdxc/data-model";
10
-
11
- /** The `{{snake}}` table, as its migration creates it. */
12
- export const {{key}}Table = table({
13
- name: "{{snake}}",
14
- columns: {
15
- id: c.text().primaryKey(),
16
- created_at: c.integer(),
17
- updated_at: c.integer(),
18
- },
19
- });
20
-
21
- /** One {{title}} row as it reads back from the database. */
22
- export type {{Name}}Row = TableRow<typeof {{key}}Table>;
23
-
24
- export const {{Name}} = createModel({{key}}Table, {});
@@ -1,15 +0,0 @@
1
- /**
2
- * The {{title}} model.
3
- */
4
-
5
- import { describe, expect, test } from "vitest";
6
-
7
- import { {{Name}} } from "{{specifier}}";
8
-
9
- describe("{{Name}}", () => {
10
- test("is defined over its table", () => {
11
- expect({{Name}}).toBeDefined();
12
- });
13
-
14
- test.todo("keeps a {{title}} row consistent");
15
- });
package/stubs/policy.stub DELETED
@@ -1,13 +0,0 @@
1
- /**
2
- * The {{title}} policy: describe who may do what, and why the rule sits here.
3
- */
4
-
5
- /** Who an authorization rule is asked about; `null` for an anonymous visitor. */
6
- export interface Actor {
7
- id: string;
8
- }
9
-
10
- /** Whether `actor` passes the {{title}} rule. */
11
- export function {{key}}(actor: Actor | null): boolean {
12
- return actor !== null;
13
- }
@@ -1,17 +0,0 @@
1
- /**
2
- * The {{title}} policy.
3
- */
4
-
5
- import { describe, expect, test } from "vitest";
6
-
7
- import { {{key}} } from "{{specifier}}";
8
-
9
- describe("{{key}}", () => {
10
- test("refuses an anonymous visitor", () => {
11
- expect({{key}}(null)).toBe(false);
12
- });
13
-
14
- test("allows a signed-in actor", () => {
15
- expect({{key}}({ id: "1" })).toBe(true);
16
- });
17
- });
@@ -1,13 +0,0 @@
1
- /**
2
- * {{title}}: describe the rule this service carries out across models, and what a caller can
3
- * rely on when it succeeds.
4
- */
5
-
6
- import type { Result } from "@sdxc/result";
7
-
8
- import { success } from "@sdxc/result";
9
-
10
- /** Carries out {{title}}; a failure says why nothing changed. */
11
- export function {{key}}(): Result<void, Error> {
12
- return success(undefined);
13
- }
@@ -1,14 +0,0 @@
1
- /**
2
- * The {{title}} service.
3
- */
4
-
5
- import { isSuccess } from "@sdxc/result";
6
- import { describe, expect, test } from "vitest";
7
-
8
- import { {{key}} } from "{{specifier}}";
9
-
10
- describe("{{key}}", () => {
11
- test("succeeds", () => {
12
- expect(isSuccess({{key}}())).toBe(true);
13
- });
14
- });
@@ -1,14 +0,0 @@
1
- /**
2
- * The fields the {{title}} form submits, validated before anything trusts them.
3
- */
4
-
5
- import * as s from "remix/data-schema";
6
- import * as f from "remix/data-schema/form-data";
7
-
8
- /** The {{title}} fields, as an action receives them. */
9
- export const {{Name}}Schema = f.object({
10
- name: f.field(s.string()),
11
- });
12
-
13
- /** A validated {{title}} submission. */
14
- export type {{Name}}Input = s.InferOutput<typeof {{Name}}Schema>;
@@ -1,22 +0,0 @@
1
- /**
2
- * The {{title}} form's validation.
3
- */
4
-
5
- import { isFailure, isSuccess } from "@sdxc/result";
6
- import { validate } from "@sdxc/validate";
7
- import { describe, expect, test } from "vitest";
8
-
9
- import { {{Name}}Schema } from "{{specifier}}";
10
-
11
- describe("{{Name}}Schema", () => {
12
- test("accepts a complete submission", async () => {
13
- let form = new FormData();
14
- form.set("name", "Ada");
15
-
16
- expect(isSuccess(await validate(form, {{Name}}Schema))).toBe(true);
17
- });
18
-
19
- test("refuses a submission missing a field", async () => {
20
- expect(isFailure(await validate(new FormData(), {{Name}}Schema))).toBe(true);
21
- });
22
- });
@@ -1,57 +0,0 @@
1
- # App
2
-
3
- A Remix v3 Worker on Cloudflare, built on the `@sdxc/*` packages.
4
-
5
- ## Develop
6
-
7
- ```sh
8
- bun install
9
- bun cf:typegen
10
- bun dev
11
- ```
12
-
13
- `bun cf:typegen` writes the Worker's types from `cloudflare.config.ts`; run it again after
14
- changing a binding.
15
-
16
- ## Add code
17
-
18
- `sdxc make <kind> <name>` writes a file of that kind where it belongs, with a test beside it,
19
- and adds any `@sdxc/*` package the file imports to `package.json`. The `sdxc` command comes
20
- from `npm add -g @sdxc/kit`:
21
-
22
- ```sh
23
- sdxc make controller about
24
- sdxc make job reports/daily --cron "0 8 * * *"
25
- sdxc make mcp search-posts
26
- ```
27
-
28
- A controller, a job and an MCP tool or resource are also declared and mapped, so they answer
29
- as soon as the command finishes.
30
-
31
- ## Run commands
32
-
33
- `bootstrap/cli.ts` is the app's own command line, for work that belongs to the app but to no
34
- request. It runs on Bun, outside the Worker, through its package script:
35
-
36
- ```sh
37
- bun run cli about
38
- bun run cli --help
39
- ```
40
-
41
- With `@sdxc/kit` installed globally, `sdxc run about` does the same from any folder in the
42
- project.
43
-
44
- `app/commands/index.ts` declares each command, and `sdxc make command users/grant` writes a
45
- new one with its test, declared and mapped.
46
-
47
- ## Check and deploy
48
-
49
- ```sh
50
- bun check
51
- bun test
52
- bun build
53
- bun cf:deploy
54
- ```
55
-
56
- Create the job queue once before the first deploy: `bunx cf queues create <name>`, using the
57
- `name` in `package.json`.
@@ -1,29 +0,0 @@
1
- /**
2
- * The `about` command, run through the app's command line as `bun run cli about` runs it.
3
- */
4
-
5
- import { invoke } from "@sdxc/cli/test";
6
- import { describe, expect, test } from "vitest";
7
-
8
- import { cli } from "~/app/initializers/cli";
9
-
10
- import manifest from "../../package.json" with { type: "json" };
11
-
12
- describe("about", () => {
13
- test("prints the app's name and the versions it is built on", async () => {
14
- let run = await invoke(cli, ["about"]);
15
-
16
- expect(run.code).toBe(0);
17
- expect(run.stdout).toContain(manifest.name);
18
- expect(run.stdout).toContain(`@sdxc/cli ${manifest.dependencies["@sdxc/cli"]}`);
19
- });
20
-
21
- test("--json prints the same as one JSON document", async () => {
22
- let run = await invoke(cli, ["about", "--json"]);
23
-
24
- expect(JSON.parse(run.stdout)).toMatchObject({
25
- name: manifest.name,
26
- remix: manifest.dependencies.remix,
27
- });
28
- });
29
- });
@@ -1,34 +0,0 @@
1
- /**
2
- * `about`: what this project is built on, read from its own `package.json` and the running
3
- * process, so a bug report or a support question starts from the exact versions in use.
4
- */
5
-
6
- import { createCommand, success } from "@sdxc/cli";
7
-
8
- import commandset from "~/app/commands";
9
-
10
- import manifest from "../../package.json" with { type: "json" };
11
-
12
- /** The runtime the command line runs on, as `Bun 1.3.0` or `Node 24.1.0`. */
13
- function runtime(): string {
14
- let bun = process.versions.bun;
15
- return bun === undefined ? `Node ${process.versions.node}` : `Bun ${bun}`;
16
- }
17
-
18
- /** Prints one line per fact, or with `--json` one document a script can read. */
19
- export default createCommand(commandset.about, (ctx) => {
20
- let about = {
21
- name: manifest.name,
22
- cli: manifest.dependencies["@sdxc/cli"],
23
- remix: manifest.dependencies.remix,
24
- runtime: runtime(),
25
- };
26
- if (ctx.flags.json) {
27
- ctx.stdout(`${JSON.stringify(about, null, 2)}\n`);
28
- return success();
29
- }
30
- ctx.stdout(
31
- `${about.name}\n @sdxc/cli ${about.cli}\n remix ${about.remix}\n runtime ${about.runtime}\n`,
32
- );
33
- return success();
34
- });
@@ -1,15 +0,0 @@
1
- /**
2
- * Every command the app's command line answers, declared in one contract: the words typed to
3
- * reach it, its arguments and its flags. Each handler lives in its own file beside this one,
4
- * and a folder of handlers is a `commands({ … })` group here.
5
- */
6
-
7
- import { command, commands, flag } from "@sdxc/cli";
8
-
9
- /** The app's commands; `sdxc make command <name>` declares one here and maps its handler. */
10
- export default commands({
11
- about: command({
12
- description: "Print the app's name, its @sdxc/cli and remix versions, and the runtime",
13
- flags: { json: flag.boolean("json", { description: "Print it as JSON" }) },
14
- }),
15
- });
@@ -1,22 +0,0 @@
1
- /**
2
- * The home page, the first thing a visitor sees. It renders through the document layout,
3
- * which links the stylesheets and client entry the request resolved.
4
- */
5
-
6
- import { createAction } from "remix/router";
7
-
8
- import DocumentLayout from "~/resources/layouts/document";
9
- import routes from "~/routes/web";
10
-
11
- /** GET / — the welcome page. */
12
- export default createAction(routes.home, (ctx) =>
13
- ctx.render(
14
- <DocumentLayout assets={ctx.assets} title="Welcome">
15
- <h1>Welcome</h1>
16
- <p>
17
- Edit <code>app/http/controllers/home.tsx</code>, or add a page with{" "}
18
- <code>sdxc make controller &lt;name&gt;</code>.
19
- </p>
20
- </DocumentLayout>,
21
- ),
22
- );
@@ -1,25 +0,0 @@
1
- /**
2
- * The router's default handler: any request that matches no route gets the app's own 404
3
- * page, with a way back home.
4
- */
5
-
6
- import type { RequestContext } from "remix/router";
7
-
8
- import DocumentLayout from "~/resources/layouts/document";
9
- import routes from "~/routes/web";
10
-
11
- /**
12
- * Renders the 404 document. It takes only the members it reads, since the router derives
13
- * `AppContext` from the options this handler is passed in.
14
- */
15
- export default function notFound(ctx: Pick<RequestContext, "assets" | "render">) {
16
- return ctx.render(
17
- <DocumentLayout assets={ctx.assets} title="Not found">
18
- <h1>Not found</h1>
19
- <p>
20
- <a href={routes.home.href()}>Back home</a>
21
- </p>
22
- </DocumentLayout>,
23
- { status: 404 },
24
- );
25
- }
@@ -1,11 +0,0 @@
1
- /**
2
- * The asset resolver, read from the manifest the Vite plugin writes: the source files
3
- * `vite dev` serves while editing, and the hashed files `vite build` emits. The document
4
- * links what it returns, so no tag names a file the build renamed.
5
- */
6
-
7
- import { createAssetResolver } from "@pitlane/assets";
8
- import manifest from "@pitlane/assets/manifest";
9
-
10
- /** Resolves the document's stylesheets, its client entry and every island by source path. */
11
- export const assetResolver = createAssetResolver(manifest);
@@ -1,35 +0,0 @@
1
- /**
2
- * The app's command line. `app/commands/index.ts` declares its commands and each handler is
3
- * mapped here through `lazy()`, so a run imports only the command it reaches; `sdxc make
4
- * command` adds the mapping. It runs on Bun, outside the Worker, started by `bootstrap/cli.ts`.
5
- */
6
-
7
- import { createCLI, lazy } from "@sdxc/cli";
8
- import { createLogger } from "@sdxc/logger";
9
- import { log } from "@sdxc/logger/middleware/cli";
10
-
11
- import commandset from "~/app/commands";
12
- import { logger } from "~/app/initializers/logger";
13
-
14
- import manifest from "../../package.json" with { type: "json" };
15
-
16
- /**
17
- * The app's logger with each command's record written to stderr as one JSON line, so stdout
18
- * holds only what the command prints and can be piped.
19
- */
20
- const COMMAND_LOGGER = createLogger({
21
- ...logger.options,
22
- sink: (record) => process.stderr.write(`${JSON.stringify(record)}\n`),
23
- });
24
-
25
- /** The command line `bootstrap/cli.ts` runs and a command's test invokes. */
26
- export const cli = createCLI({
27
- name: manifest.name,
28
- commands: commandset,
29
- middleware: [log(COMMAND_LOGGER)],
30
- });
31
-
32
- cli.map(
33
- commandset.about,
34
- lazy(() => import("~/app/commands/about")),
35
- );
@@ -1,18 +0,0 @@
1
- /**
2
- * The job dispatcher: every background job is enqueued through it and runs inside it, over
3
- * the Cloudflare queue the Worker consumes. `sdxc make job` maps each new handler here, as a
4
- * loader, so a module is imported only once a message for its job arrives.
5
- */
6
-
7
- import { createJobDispatcher } from "@sdxc/jobs";
8
- import * as cloudflare from "@sdxc/jobs/cloudflare";
9
- import { env } from "cloudflare:workers";
10
-
11
- import { logger } from "~/app/initializers/logger";
12
-
13
- /** The dispatcher `bootstrap/worker.ts` hands queue batches and cron triggers to. */
14
- export const dispatcher = createJobDispatcher({
15
- logger,
16
- queue: cloudflare.queue(() => env.QUEUE),
17
- timeout: "5 minutes",
18
- });
@@ -1,10 +0,0 @@
1
- /**
2
- * The logger every request and job writes through. The router and the job dispatcher both
3
- * attach it, so their records carry the same `service` and one query finds both halves of
4
- * the work a request started.
5
- */
6
-
7
- import { createLogger } from "@sdxc/logger";
8
-
9
- /** The Worker's one logger; read the invocation's log through `ctx.log`. */
10
- export const logger = createLogger({ service: "worker" });
@@ -1,16 +0,0 @@
1
- /**
2
- * The app's MCP server. `app/mcp/tools/` and `app/mcp/resources/` declare what it offers and
3
- * answer it, one file per handler; `sdxc make mcp` maps each new handler here through
4
- * `lazy()`, so a request imports only the handlers it reaches.
5
- */
6
-
7
- import { createHandler } from "@sdxc/mcp";
8
-
9
- /** The handler the `/mcp` route forwards to. */
10
- const mcp = createHandler({
11
- name: "app",
12
- version: "1.0.0",
13
- cacheScope: "public",
14
- });
15
-
16
- export default mcp;
@@ -1,65 +0,0 @@
1
- /**
2
- * The web router: the global middleware every request runs through, and every route in
3
- * `routes/web.ts` mapped onto its controller through `lazy()`, so a request imports only the
4
- * controller it reaches. `sdxc make controller` maps each new controller here.
5
- */
6
-
7
- import type { RouterContext } from "remix/router";
8
-
9
- import { assets } from "@sdxc/assets-middleware";
10
- import { lazy } from "@sdxc/lazy-route";
11
- import { log } from "@sdxc/logger/middleware";
12
- import { asyncContext } from "remix/middleware/async-context";
13
- import { cop } from "remix/middleware/cop";
14
- import { formData } from "remix/middleware/form-data";
15
- import { render } from "remix/middleware/render";
16
- import { createRouter } from "remix/router";
17
-
18
- import notFound from "~/app/http/controllers/not-found";
19
- import { assetResolver } from "~/app/initializers/assets";
20
- import { logger } from "~/app/initializers/logger";
21
- import routes from "~/routes/web";
22
-
23
- /** The context a controller sees once the global middleware has run. */
24
- export type AppContext = RouterContext<ReturnType<typeof createWebRouter>>;
25
-
26
- declare module "remix/router" {
27
- /** Types `createAction` and `createController` with the context the global chain builds. */
28
- interface RouterTypes {
29
- context: AppContext;
30
- }
31
- }
32
-
33
- /**
34
- * Builds the router the Worker forwards each request to. The middleware is written inline,
35
- * so the router's type carries what each one publishes and {@link AppContext} reads it.
36
- */
37
- export function createWebRouter() {
38
- let router = createRouter({
39
- middleware: [
40
- asyncContext(),
41
- log(logger),
42
- formData(),
43
- cop(),
44
- assets(assetResolver, {
45
- stylesheets: "resources/layouts/document.tsx",
46
- script: "bootstrap/browser.ts",
47
- }),
48
- render({ assets: assetResolver }),
49
- ],
50
- defaultHandler: notFound,
51
- });
52
-
53
- router.map(
54
- routes.home,
55
- lazy(() => import("~/app/http/controllers/home")),
56
- );
57
- router.map(
58
- routes.mcp,
59
- lazy(() =>
60
- import("~/app/initializers/mcp").then((it) => (ctx: AppContext) => it.default.fetch(ctx)),
61
- ),
62
- );
63
-
64
- return router;
65
- }
@@ -1,10 +0,0 @@
1
- /**
2
- * Every background job the app runs, declared in one map: the payload each carries and the
3
- * schedule it is enqueued on. Importing it costs the schemas alone, so a controller enqueues
4
- * a job without loading the handler that runs it.
5
- */
6
-
7
- import { jobs } from "@sdxc/jobs";
8
-
9
- /** The app's jobs; `sdxc make job <name>` declares one here and maps its handler. */
10
- export default jobs({});
@@ -1,9 +0,0 @@
1
- /**
2
- * The resources the MCP server offers, each addressed by a URI pattern a client reads and a
3
- * person attaches to a conversation. Each handler lives in its own file beside this one.
4
- */
5
-
6
- import { resources } from "@sdxc/mcp";
7
-
8
- /** The app's resources; `sdxc make mcp <name> --resource` declares one here and maps it. */
9
- export default resources({});
@@ -1,10 +0,0 @@
1
- /**
2
- * The tools the MCP server offers: the name a client calls, the description a model chooses
3
- * it by, and the schema its arguments satisfy. Each handler lives in its own file beside
4
- * this one.
5
- */
6
-
7
- import { tools } from "@sdxc/mcp";
8
-
9
- /** The app's tools; `sdxc make mcp <name>` declares one here and maps its handler. */
10
- export default tools({});
@@ -1,27 +0,0 @@
1
- /**
2
- * The browser's entry point: boots the Remix component runtime and resolves the island
3
- * modules a server-rendered page hydrates. A page with no island links no script, so this
4
- * file only runs where an island asks for it.
5
- */
6
-
7
- import { run } from "remix/component";
8
-
9
- /**
10
- * The island modules a hydration record can name, keyed by the module URL the island writes.
11
- * Each one is listed here, so a server-rendered component never becomes a client chunk by
12
- * sitting next to one that hydrates.
13
- */
14
- const CLIENT_MODULES: Record<string, () => Promise<Record<string, unknown>>> = {};
15
-
16
- run({
17
- /** Resolves a hydrated island's export from the module URL the server wrote. */
18
- async loadModule(moduleUrl, exportName) {
19
- let load = CLIENT_MODULES[moduleUrl];
20
- if (load === undefined) throw new Error(`Unknown client entry module: ${moduleUrl}`);
21
- let entry = (await load())[exportName];
22
- if (typeof entry !== "function") {
23
- throw new Error(`Missing client entry export ${exportName} in ${moduleUrl}`);
24
- }
25
- return entry;
26
- },
27
- });
@@ -1,9 +0,0 @@
1
- /**
2
- * The command line's entry point, started by `bun run cli` or `sdxc run`: it runs the command
3
- * the arguments name and exits with its code. The Worker never imports it, so no command ships
4
- * in the server build.
5
- */
6
-
7
- import { cli } from "~/app/initializers/cli";
8
-
9
- process.exitCode = await cli.run(process.argv.slice(2));
@@ -1,31 +0,0 @@
1
- /**
2
- * The Worker's entry point. `fetch` builds the router and forwards the request to it, and
3
- * `queue` hands each delivered batch to the job dispatcher, so every request and every job
4
- * reaches the app through the initializers that configure it.
5
- */
6
-
7
- import * as cloudflare from "@sdxc/jobs/cloudflare";
8
-
9
- import { dispatcher } from "~/app/initializers/dispatcher";
10
- import { createWebRouter } from "~/app/initializers/router";
11
-
12
- /** The dispatcher's queue and cron handlers, bound once per isolate. */
13
- const JOBS = cloudflare.worker(dispatcher);
14
-
15
- export default {
16
- /** Answers a request through the web router. */
17
- async fetch(request) {
18
- let router = createWebRouter();
19
- return await router.fetch(request);
20
- },
21
-
22
- /** Runs every job a cron trigger is the schedule for. */
23
- async scheduled(controller) {
24
- await JOBS.scheduled(controller);
25
- },
26
-
27
- /** Runs the job each queued message names, settling once every one of them has. */
28
- async queue(batch) {
29
- await JOBS.queue(batch);
30
- },
31
- } satisfies ExportedHandler<Cloudflare.Env>;
@@ -1,28 +0,0 @@
1
- /**
2
- * Cloudflare configuration for the Worker, read by `cf` and the Vite plugin alike. Every
3
- * binding and trigger the app reads is declared here, so `bun cf:typegen` types `env` from
4
- * this file and local development simulates exactly what production provides.
5
- */
6
-
7
- import { bindings, defineConfig, triggers } from "cf/config";
8
-
9
- import manifest from "./package.json" with { type: "json" };
10
-
11
- export default defineConfig({
12
- worker: {
13
- name: manifest.name,
14
- compatibilityDate: "2026-09-02",
15
- compatibilityFlags: ["nodejs_compat"],
16
- entrypoint: "./bootstrap/worker.ts",
17
- observability: { enabled: true },
18
- /**
19
- * A queue has exactly one consumer, so this Worker owns the role: every job the
20
- * dispatcher enqueues is delivered back here and run through the same dispatcher.
21
- */
22
- triggers: [triggers.queue({ name: manifest.name })],
23
- env: {
24
- /** Where the job dispatcher enqueues; `cf queues create <name>` before the first deploy. */
25
- QUEUE: bindings.queue({ name: manifest.name }),
26
- },
27
- },
28
- });