@slotform/api 0.0.0-stage → 0.1.1

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 (151) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +50 -2
  3. package/dist/client.d.ts +16 -0
  4. package/dist/client.d.ts.map +1 -0
  5. package/dist/client.js +98 -0
  6. package/dist/client.js.map +1 -0
  7. package/dist/error.d.ts +2 -0
  8. package/dist/error.d.ts.map +1 -0
  9. package/dist/error.js +2 -0
  10. package/dist/error.js.map +1 -0
  11. package/dist/index.d.ts +153 -0
  12. package/dist/index.d.ts.map +1 -0
  13. package/dist/index.js +640 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/lib/chosen.d.ts +12 -0
  16. package/dist/lib/chosen.d.ts.map +1 -0
  17. package/dist/lib/chosen.js +18 -0
  18. package/dist/lib/chosen.js.map +1 -0
  19. package/dist/lib/cursor.d.ts +68 -0
  20. package/dist/lib/cursor.d.ts.map +1 -0
  21. package/dist/lib/cursor.js +220 -0
  22. package/dist/lib/cursor.js.map +1 -0
  23. package/dist/lib/limits.d.ts +4 -0
  24. package/dist/lib/limits.d.ts.map +1 -0
  25. package/dist/lib/limits.js +10 -0
  26. package/dist/lib/limits.js.map +1 -0
  27. package/dist/lib/local-origin.d.ts +2 -0
  28. package/dist/lib/local-origin.d.ts.map +1 -0
  29. package/dist/lib/local-origin.js +17 -0
  30. package/dist/lib/local-origin.js.map +1 -0
  31. package/dist/lib/slugify.d.ts +4 -0
  32. package/dist/lib/slugify.d.ts.map +1 -0
  33. package/dist/lib/slugify.js +26 -0
  34. package/dist/lib/slugify.js.map +1 -0
  35. package/dist/lib/window.d.ts +52 -0
  36. package/dist/lib/window.d.ts.map +1 -0
  37. package/dist/lib/window.js +70 -0
  38. package/dist/lib/window.js.map +1 -0
  39. package/dist/mcp-path.d.ts +2 -0
  40. package/dist/mcp-path.d.ts.map +1 -0
  41. package/dist/mcp-path.js +3 -0
  42. package/dist/mcp-path.js.map +1 -0
  43. package/dist/mcp.d.ts +15 -0
  44. package/dist/mcp.d.ts.map +1 -0
  45. package/dist/mcp.js +5 -0
  46. package/dist/mcp.js.map +1 -0
  47. package/dist/node/barrel.d.ts +3 -0
  48. package/dist/node/barrel.d.ts.map +1 -0
  49. package/dist/node/barrel.js +70 -0
  50. package/dist/node/barrel.js.map +1 -0
  51. package/dist/node/codegen.d.ts +10 -0
  52. package/dist/node/codegen.d.ts.map +1 -0
  53. package/dist/node/codegen.js +132 -0
  54. package/dist/node/codegen.js.map +1 -0
  55. package/dist/node/procedure-codegen.d.ts +14 -0
  56. package/dist/node/procedure-codegen.d.ts.map +1 -0
  57. package/dist/node/procedure-codegen.js +95 -0
  58. package/dist/node/procedure-codegen.js.map +1 -0
  59. package/dist/node/schema-child.d.ts +2 -0
  60. package/dist/node/schema-child.d.ts.map +1 -0
  61. package/dist/node/schema-child.js +31 -0
  62. package/dist/node/schema-child.js.map +1 -0
  63. package/dist/node/schema-source.d.ts +3 -0
  64. package/dist/node/schema-source.d.ts.map +1 -0
  65. package/dist/node/schema-source.js +33 -0
  66. package/dist/node/schema-source.js.map +1 -0
  67. package/dist/node/server-client.d.ts +19 -0
  68. package/dist/node/server-client.d.ts.map +1 -0
  69. package/dist/node/server-client.js +45 -0
  70. package/dist/node/server-client.js.map +1 -0
  71. package/dist/node/types.d.ts +42 -0
  72. package/dist/node/types.d.ts.map +1 -0
  73. package/dist/node/types.js +13 -0
  74. package/dist/node/types.js.map +1 -0
  75. package/dist/not-found.d.ts +2 -0
  76. package/dist/not-found.d.ts.map +1 -0
  77. package/dist/not-found.js +6 -0
  78. package/dist/not-found.js.map +1 -0
  79. package/dist/procedure.d.ts +188 -0
  80. package/dist/procedure.d.ts.map +1 -0
  81. package/dist/procedure.js +392 -0
  82. package/dist/procedure.js.map +1 -0
  83. package/dist/query-invalidation.d.ts +20 -0
  84. package/dist/query-invalidation.d.ts.map +1 -0
  85. package/dist/query-invalidation.js +66 -0
  86. package/dist/query-invalidation.js.map +1 -0
  87. package/dist/schema.d.ts +32 -0
  88. package/dist/schema.d.ts.map +1 -0
  89. package/dist/schema.js +103 -0
  90. package/dist/schema.js.map +1 -0
  91. package/dist/types.d.ts +30 -0
  92. package/dist/types.d.ts.map +1 -0
  93. package/dist/types.js +2 -0
  94. package/dist/types.js.map +1 -0
  95. package/dist/wire.d.ts +11 -0
  96. package/dist/wire.d.ts.map +1 -0
  97. package/dist/wire.js +26 -0
  98. package/dist/wire.js.map +1 -0
  99. package/dist/worker/guards.d.ts +6 -0
  100. package/dist/worker/guards.d.ts.map +1 -0
  101. package/dist/worker/guards.js +29 -0
  102. package/dist/worker/guards.js.map +1 -0
  103. package/dist/worker/index.d.ts +57 -0
  104. package/dist/worker/index.d.ts.map +1 -0
  105. package/dist/worker/index.js +418 -0
  106. package/dist/worker/index.js.map +1 -0
  107. package/dist/worker/mcp.d.ts +28 -0
  108. package/dist/worker/mcp.d.ts.map +1 -0
  109. package/dist/worker/mcp.js +361 -0
  110. package/dist/worker/mcp.js.map +1 -0
  111. package/dist/worker/request-log.d.ts +10 -0
  112. package/dist/worker/request-log.d.ts.map +1 -0
  113. package/dist/worker/request-log.js +37 -0
  114. package/dist/worker/request-log.js.map +1 -0
  115. package/guide/add-a-procedure.md +42 -0
  116. package/guide/background.md +86 -0
  117. package/guide/client.md +93 -0
  118. package/guide/config.md +85 -0
  119. package/guide/mcp.md +68 -0
  120. package/guide/middleware.md +79 -0
  121. package/guide/procedures.md +95 -0
  122. package/guide/utilities.md +135 -0
  123. package/package.json +120 -3
  124. package/src/client.ts +129 -0
  125. package/src/error.ts +1 -0
  126. package/src/index.ts +787 -0
  127. package/src/lib/chosen.ts +31 -0
  128. package/src/lib/cursor.ts +354 -0
  129. package/src/lib/limits.ts +10 -0
  130. package/src/lib/local-origin.ts +18 -0
  131. package/src/lib/slugify.ts +29 -0
  132. package/src/lib/window.ts +155 -0
  133. package/src/mcp-path.ts +2 -0
  134. package/src/mcp.ts +30 -0
  135. package/src/node/barrel.ts +77 -0
  136. package/src/node/codegen.ts +173 -0
  137. package/src/node/procedure-codegen.ts +131 -0
  138. package/src/node/schema-child.ts +31 -0
  139. package/src/node/schema-source.ts +45 -0
  140. package/src/node/server-client.ts +67 -0
  141. package/src/node/types.ts +64 -0
  142. package/src/not-found.ts +6 -0
  143. package/src/procedure.ts +935 -0
  144. package/src/query-invalidation.ts +106 -0
  145. package/src/schema.ts +133 -0
  146. package/src/types.ts +72 -0
  147. package/src/wire.ts +34 -0
  148. package/src/worker/guards.ts +37 -0
  149. package/src/worker/index.ts +681 -0
  150. package/src/worker/mcp.ts +470 -0
  151. package/src/worker/request-log.ts +50 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp.js","sourceRoot":"","sources":["../src/mcp.ts"],"names":[],"mappings":"AAuBA,wDAAwD;AACxD,MAAM,UAAU,SAAS,CAAU,UAGlC;IACA,OAAO,UAAU,CAAC;AACnB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare function generateRouteBarrel(cwd: string): string;
2
+ export declare function hasRoutableFiles(cwd: string): boolean;
3
+ //# sourceMappingURL=barrel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"barrel.d.ts","sourceRoot":"","sources":["../../src/node/barrel.ts"],"names":[],"mappings":"AAwCA,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CA8BvD;AAID,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAErD"}
@@ -0,0 +1,70 @@
1
+ import { readdirSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { ROUTES_DIR } from "./types.js";
4
+ const GENERATED_HEADER = "// Generated by @slotform/api — do not edit.";
5
+ // Route directory layout rules: docs/architecture/plugins/api.md, "Routes barrel".
6
+ function isRouteFile(file) {
7
+ if (!(file.endsWith(".ts") || file.endsWith(".tsx")))
8
+ return false;
9
+ if (file.endsWith(".d.ts"))
10
+ return false;
11
+ if (file.endsWith(".test.ts") || file.endsWith(".test.tsx"))
12
+ return false;
13
+ if (file === "index.ts" || file === "index.tsx")
14
+ return false;
15
+ return true;
16
+ }
17
+ function basenameWithoutExt(file) {
18
+ return file.replace(/\.tsx?$/, "");
19
+ }
20
+ // A missing routes directory (or a file standing where a parent directory
21
+ // should be) is an app with no routes; any other read failure is not.
22
+ function routeFiles(cwd) {
23
+ try {
24
+ // `withFileTypes: false` (the default) — we only want top-level
25
+ // regular files. Nested directories appear here as plain names and
26
+ // are filtered out by the extension check.
27
+ return readdirSync(join(cwd, ROUTES_DIR)).filter(isRouteFile);
28
+ }
29
+ catch (error) {
30
+ if (typeof error === "object" &&
31
+ error !== null &&
32
+ "code" in error &&
33
+ (error.code === "ENOENT" || error.code === "ENOTDIR")) {
34
+ return [];
35
+ }
36
+ throw error;
37
+ }
38
+ }
39
+ export function generateRouteBarrel(cwd) {
40
+ const entries = routeFiles(cwd);
41
+ const byBasename = new Map();
42
+ for (const entry of entries) {
43
+ const base = basenameWithoutExt(entry);
44
+ const bucket = byBasename.get(base);
45
+ if (bucket)
46
+ bucket.push(entry);
47
+ else
48
+ byBasename.set(base, [entry]);
49
+ }
50
+ const collisions = [...byBasename.entries()].filter(([, files]) => files.length > 1);
51
+ if (collisions.length > 0) {
52
+ const detail = collisions
53
+ .map(([base, files]) => `${base} (${files.sort().join(" + ")})`)
54
+ .join(", ");
55
+ throw new Error(`generateRouteBarrel: ambiguous route basename(s) — ${detail}. ` +
56
+ "Pick one of .ts or .tsx per route name.");
57
+ }
58
+ // Full filename re-export: docs/architecture/plugins/api.md, "Routes barrel".
59
+ const exports = [...byBasename.entries()]
60
+ .sort(([a], [b]) => a.localeCompare(b))
61
+ .map(([, files]) => `export * from "./${files[0]}";`)
62
+ .join("\n");
63
+ return `${GENERATED_HEADER}\n${exports ? `${exports}\n` : ""}`;
64
+ }
65
+ // Whether the routes directory holds a routable file: `routeBarrelSource` and
66
+ // `routesHandler` are null without one.
67
+ export function hasRoutableFiles(cwd) {
68
+ return routeFiles(cwd).length > 0;
69
+ }
70
+ //# sourceMappingURL=barrel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"barrel.js","sourceRoot":"","sources":["../../src/node/barrel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,MAAM,gBAAgB,GAAG,8CAA8C,CAAC;AAExE,mFAAmF;AACnF,SAAS,WAAW,CAAC,IAAY;IAChC,IAAI,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAAE,OAAO,KAAK,CAAC;IACnE,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;QAAE,OAAO,KAAK,CAAC;IACzC,IAAI,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC;QAAE,OAAO,KAAK,CAAC;IAC1E,IAAI,IAAI,KAAK,UAAU,IAAI,IAAI,KAAK,WAAW;QAAE,OAAO,KAAK,CAAC;IAC9D,OAAO,IAAI,CAAC;AACb,CAAC;AAED,SAAS,kBAAkB,CAAC,IAAY;IACvC,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;AACpC,CAAC;AAED,0EAA0E;AAC1E,sEAAsE;AACtE,SAAS,UAAU,CAAC,GAAW;IAC9B,IAAI,CAAC;QACJ,gEAAgE;QAChE,mEAAmE;QACnE,2CAA2C;QAC3C,OAAO,WAAW,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAC/D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,IACC,OAAO,KAAK,KA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ACH,CAAC;IAED,8EAA8E;IAC9E,MAAM,OAAO,GAAG,CAAC,GAAG,UAAU,CAAC,OAAO,EAAE,CAAC;SACvC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;SACtC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,oBAAoB,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;SACpD,IAAI,CAAC,IAAI,CAAC,CAAC;IAEb,OAAO,GAAG,gBAAgB,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;AAChE,CAAC;AAED,8EAA8E;AAC9E,wCAAwC;AACxC,MAAM,UAAU,gBAAgB,CAAC,GAAW;IAC3C,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;AACnC,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { type MiddlewareSpec, type TsExpression, type TsImportSpec } from "@slotform/cli/ast";
2
+ import type { CallbackSpec, MiddlewareCall, PluginRuntimeEntry, WorkerPayload } from "./types.ts";
3
+ export declare function runtimeChain(base: TsExpression, runtimes: readonly PluginRuntimeEntry[], middlewareChain: readonly MiddlewareCall[], callbacks: Readonly<Record<string, CallbackSpec>>): {
4
+ chain: TsExpression;
5
+ imports: TsImportSpec[];
6
+ };
7
+ export declare function aggregateWorker(payload: WorkerPayload): string;
8
+ export declare function middlewareCallsOf(entries: readonly MiddlewareSpec[]): MiddlewareCall[];
9
+ export declare function middlewareImportsOf(entries: readonly MiddlewareSpec[]): TsImportSpec[];
10
+ //# sourceMappingURL=codegen.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codegen.d.ts","sourceRoot":"","sources":["../../src/node/codegen.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,KAAK,cAAc,EAEnB,KAAK,YAAY,EACjB,KAAK,YAAY,EAEjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EACX,YAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,aAAa,EACb,MAAM,YAAY,CAAC;AAKpB,wBAAgB,YAAY,CAC3B,IAAI,EAAE,YAAY,EAClB,QAAQ,EAAE,SAAS,kBAAkB,EAAE,EACvC,eAAe,EAAE,SAAS,cAAc,EAAE,EAC1C,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,GAC/C;IAAE,KAAK,EAAE,YAAY,CAAC;IAAC,OAAO,EAAE,YAAY,EAAE,CAAA;CAAE,CAsClD;AAGD,wBAAgB,eAAe,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,CAyE9D;AAqBD,wBAAgB,iBAAiB,CAChC,OAAO,EAAE,SAAS,cAAc,EAAE,GAChC,cAAc,EAAE,CAKlB;AAGD,wBAAgB,mBAAmB,CAClC,OAAO,EAAE,SAAS,cAAc,EAAE,GAChC,YAAY,EAAE,CAEhB"}
@@ -0,0 +1,132 @@
1
+ import { dedupeImports, renderTsSourceFile, } from "@slotform/cli/ast";
2
+ // `<base>.use(<rt1>(opts))...use(<mw1>)...`, the chain `.slotform/worker.ts` and
3
+ // `.slotform/procedure.ts` both build, with each runtime's callback spliced into
4
+ // its options: docs/architecture/runtime.md, "Chain order".
5
+ export function runtimeChain(base, runtimes, middlewareChain, callbacks) {
6
+ let chain = base;
7
+ const runtimeImports = [];
8
+ const callbackImports = [];
9
+ for (const rt of runtimes) {
10
+ runtimeImports.push(rt.import);
11
+ const properties = Object.entries(rt.options).map(([key, value]) => ({
12
+ key,
13
+ value,
14
+ }));
15
+ const callback = callbacks[rt.plugin];
16
+ if (callback) {
17
+ properties.push({
18
+ key: "callbacks",
19
+ value: { kind: "identifier", name: callback.identifier },
20
+ });
21
+ callbackImports.push(callback.import);
22
+ }
23
+ chain = {
24
+ kind: "call",
25
+ callee: { kind: "member", object: chain, property: "use" },
26
+ args: [
27
+ {
28
+ kind: "call",
29
+ callee: { kind: "identifier", name: rt.identifier },
30
+ args: [{ kind: "object", properties }],
31
+ },
32
+ ],
33
+ };
34
+ }
35
+ for (const mw of middlewareChain) {
36
+ chain = {
37
+ kind: "call",
38
+ callee: { kind: "member", object: chain, property: mw.method },
39
+ args: [mw.call],
40
+ };
41
+ }
42
+ return { chain, imports: [...runtimeImports, ...callbackImports] };
43
+ }
44
+ // The `.slotform/worker.ts` source, the `workerSource` slot's: docs/architecture/plugins/api.md, "Generated files".
45
+ export function aggregateWorker(payload) {
46
+ const { chain, imports } = runtimeChain(payload.base, payload.pluginRuntimes, payload.middlewareChain, payload.callbacks);
47
+ // The mount object: `mcp` (with the server's name), `queue`, `scheduled`,
48
+ // each key only when its file is there.
49
+ const mount = [];
50
+ if (payload.mcp) {
51
+ mount.push({
52
+ key: "mcp",
53
+ value: { kind: "identifier", name: payload.mcp.identifier },
54
+ }, { key: "name", value: { kind: "string", value: payload.mcp.name } });
55
+ }
56
+ if (payload.queue) {
57
+ mount.push({
58
+ key: "queue",
59
+ value: { kind: "identifier", name: payload.queue.identifier },
60
+ });
61
+ }
62
+ if (payload.scheduled) {
63
+ mount.push({
64
+ key: "scheduled",
65
+ value: { kind: "identifier", name: payload.scheduled.identifier },
66
+ });
67
+ }
68
+ const args = [];
69
+ if (payload.handler || mount.length > 0) {
70
+ // A worker with plugins but no routes still takes a mount: the routes
71
+ // argument is then an empty object.
72
+ args.push(payload.handler
73
+ ? { kind: "identifier", name: payload.handler.identifier }
74
+ : { kind: "object", properties: [] });
75
+ }
76
+ if (mount.length > 0)
77
+ args.push({ kind: "object", properties: mount });
78
+ const spec = {
79
+ imports: dedupeImports([...payload.imports, ...imports]),
80
+ statements: [
81
+ {
82
+ kind: "const",
83
+ name: "worker",
84
+ value: {
85
+ kind: "call",
86
+ callee: { kind: "member", object: chain, property: "handler" },
87
+ args,
88
+ },
89
+ },
90
+ {
91
+ kind: "export-type",
92
+ name: "AppRouter",
93
+ // `typeof <expr>` isn't a first-class TsTypeRef kind; rendering as a
94
+ // bare `reference` pastes the text verbatim which is what we want.
95
+ type: { kind: "reference", name: "typeof worker._router" },
96
+ },
97
+ // Loads `procedure.ts`, and so its `Register` merge (see
98
+ // `./procedure-codegen.ts`), into any program that reads the router type.
99
+ { kind: "export-type-ref", source: "./procedure.ts", names: ["Entity"] },
100
+ {
101
+ kind: "export-default",
102
+ value: { kind: "identifier", name: "worker" },
103
+ },
104
+ ],
105
+ };
106
+ return renderTsSourceFile(spec);
107
+ }
108
+ const MIDDLEWARE_PHASE_ORDER = {
109
+ "before-cors": 0,
110
+ "after-cors": 1,
111
+ "before-routes": 2,
112
+ "after-routes": 3,
113
+ "after-context": 4,
114
+ };
115
+ // Mount order: phase, then `order`, then contribution order (the sort is
116
+ // stable): docs/architecture/runtime.md, "Middleware".
117
+ function mountOrder(entries) {
118
+ return [...entries].sort((a, b) => MIDDLEWARE_PHASE_ORDER[a.phase] - MIDDLEWARE_PHASE_ORDER[b.phase] ||
119
+ a.order - b.order);
120
+ }
121
+ // The `middlewareCalls` slot: each call with the builder method that mounts it.
122
+ export function middlewareCallsOf(entries) {
123
+ return mountOrder(entries).map((entry) => ({
124
+ call: entry.call,
125
+ method: entry.phase === "after-context" ? "useAfterContext" : "use",
126
+ }));
127
+ }
128
+ // The `middlewareImports` slot: the imports the calls name.
129
+ export function middlewareImportsOf(entries) {
130
+ return dedupeImports(mountOrder(entries).flatMap((entry) => entry.imports));
131
+ }
132
+ //# sourceMappingURL=codegen.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codegen.js","sourceRoot":"","sources":["../../src/node/codegen.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,aAAa,EAEb,kBAAkB,GAIlB,MAAM,mBAAmB,CAAC;AAQ3B,iFAAiF;AACjF,iFAAiF;AACjF,4DAA4D;AAC5D,MAAM,UAAU,YAAY,CAC3B,IAAkB,EAClB,QAAuC,EACv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AAC,CAAC;AAC7E,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { type TsExpression, type TsImportSpec } from "@slotform/cli/ast";
2
+ import type { MiddlewareCall, PluginRuntimeEntry } from "./types.ts";
3
+ interface ProcedurePayload {
4
+ base: TsExpression;
5
+ runtimes: PluginRuntimeEntry[];
6
+ imports: TsImportSpec[];
7
+ middlewareChain: MiddlewareCall[];
8
+ middlewareImports: TsImportSpec[];
9
+ statements: Record<string, readonly string[]> | null;
10
+ entities: readonly string[];
11
+ }
12
+ export declare function aggregateProcedure(payload: ProcedurePayload): string;
13
+ export {};
14
+ //# sourceMappingURL=procedure-codegen.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"procedure-codegen.d.ts","sourceRoot":"","sources":["../../src/node/procedure-codegen.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAGrE,UAAU,gBAAgB;IAEzB,IAAI,EAAE,YAAY,CAAC;IAEnB,QAAQ,EAAE,kBAAkB,EAAE,CAAC;IAE/B,OAAO,EAAE,YAAY,EAAE,CAAC;IAExB,eAAe,EAAE,cAAc,EAAE,CAAC;IAElC,iBAAiB,EAAE,YAAY,EAAE,CAAC;IAElC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC;IAErD,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;CAC5B;AAqCD,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,gBAAgB,GAAG,MAAM,CAoEpE"}
@@ -0,0 +1,95 @@
1
+ import { dedupeImports, renderTsSourceFile, } from "@slotform/cli/ast";
2
+ import { runtimeChain } from "./codegen.js";
3
+ const APP_BUILDER_IMPORT = {
4
+ source: "@slotform/api/runtime",
5
+ named: ["AppBuilder"],
6
+ typeOnly: true,
7
+ };
8
+ const CREATE_PROCEDURE_IMPORT = {
9
+ source: "@slotform/api/procedure",
10
+ named: ["createJobs", "createProcedure"],
11
+ };
12
+ const IDENT_RE = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
13
+ // The statements record as an inline type literal: docs/architecture/slot-catalog.md, "`api.slots.*` (the `api` plugin)".
14
+ function renderStatementsType(statements) {
15
+ if (statements === null)
16
+ return "Record<never, never>";
17
+ const entries = Object.entries(statements).map(([key, actions]) => {
18
+ const keyText = IDENT_RE.test(key) ? key : JSON.stringify(key);
19
+ const tuple = actions.map((a) => JSON.stringify(a)).join(", ");
20
+ return `\t${keyText}: readonly [${tuple}];`;
21
+ });
22
+ if (entries.length === 0)
23
+ return "Record<never, never>";
24
+ return `{\n${entries.join("\n")}\n}`;
25
+ }
26
+ // The entity vocabulary (sorted and unique, as the slot holds it) as an inline
27
+ // string-literal union, plain data like `renderStatementsType`; `string` when
28
+ // the app names none.
29
+ function renderEntityType(entities) {
30
+ if (entities.length === 0)
31
+ return "string";
32
+ return entities.map((name) => JSON.stringify(name)).join(" | ");
33
+ }
34
+ export function aggregateProcedure(payload) {
35
+ const { chain, imports: runtimeImports } = runtimeChain(payload.base, payload.runtimes, payload.middlewareChain, {});
36
+ const importsText = renderTsSourceFile({
37
+ imports: dedupeImports([
38
+ ...payload.imports,
39
+ ...runtimeImports,
40
+ ...payload.middlewareImports,
41
+ APP_BUILDER_IMPORT,
42
+ CREATE_PROCEDURE_IMPORT,
43
+ ]),
44
+ statements: [{ kind: "const", name: "__chain", value: chain }],
45
+ });
46
+ const statementsType = renderStatementsType(payload.statements);
47
+ const entityType = renderEntityType(payload.entities);
48
+ return `${importsText}
49
+ // Type-only: \`__chain\` mirrors the runtime plugin composition in
50
+ // .slotform/worker.ts so \`WorkerContext\` matches the real request context
51
+ // without re-deriving each runtime factory's generics by hand. Never
52
+ // exported or called further — only its type is used below.
53
+ type ContextOf<B> = B extends AppBuilder<infer C> ? C : never;
54
+ // Exported so post-context middleware can type \`slotformContext<WorkerContext>(c)\`.
55
+ // Import it type-only: this module imports the middleware file back, and only
56
+ // erasure keeps that from being a real cycle.
57
+ export type WorkerContext = ContextOf<typeof __chain>;
58
+ type RbacStatements = ${statementsType};
59
+ export type Entity = ${entityType};
60
+
61
+ // Types the client's \`invalidateForWrites\` and a query's \`meta.reads\` over
62
+ // \`Entity\` (type-only: nothing reaches the bundle). \`worker.ts\` re-exports
63
+ // \`Entity\`, so an app's program loads this file with the router type. The
64
+ // import puts the module in the program, which an augmentation alone does not.
65
+ import type {} from "@slotform/api/query-invalidation";
66
+ declare module "@slotform/api/query-invalidation" {
67
+ interface Register {
68
+ entity: Entity;
69
+ }
70
+ }
71
+
72
+ // What a queue or cron handler and a node service's \`jobContext()\` receive: a
73
+ // request's context without the request (no \`httpRequest\`, headers or user). A
74
+ // mapped type, not \`Omit\`: the base context's index signature would make
75
+ // \`Omit\` drop every named key.
76
+ export type JobContext = {
77
+ [K in keyof WorkerContext as string extends K
78
+ ? never
79
+ : K extends "httpRequest" | "reqHeaders" | "resHeaders"
80
+ ? never
81
+ : K]: WorkerContext[K];
82
+ };
83
+ export const { defineQueue, defineScheduled } = createJobs<JobContext>();
84
+
85
+ // Types a node service's \`jobContext()\`, which imports nothing of the app.
86
+ declare module "@slotform/api/procedure" {
87
+ interface Register {
88
+ jobContext: JobContext;
89
+ }
90
+ }
91
+
92
+ export const procedure = createProcedure<WorkerContext, RbacStatements, Entity>();
93
+ `;
94
+ }
95
+ //# sourceMappingURL=procedure-codegen.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"procedure-codegen.js","sourceRoot":"","sources":["../../src/node/procedure-codegen.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,aAAa,EACb,kBAAkB,GAGlB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAqB5C,MAAM,kBAAkB,GAAiB;IACxC,MAAM,EAAE,uBAAuB;IAC/B,K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,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACjE,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,OAAyB;IAC3D,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,GAAG,YAAY,CACtD,OAAO,CAAC,IAAI,EACZ,OAAO,CAAC,QAAQ,EAChB,OAAO,CAAC,eAAe,EACvB,EAAE,CACF,CAAC;IAEF,MAAM,WAAW,GAAG,kBAAkB,CAAC;QACtC,OAAO,EAAE,aAAa,CAAC;YACtB,GAAG,OAAO,CAAC,OAAO;YAClB,GAAG,cAAc;YACjB,GAAG,OAAO,CAAC,iBAAiB;YAC5B,kBAAkB;YAClB,uBAAuB;SACvB,CAAC;QACF,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;KAC9D,CAAC,CAAC;IAEH,MAAM,cAAc,GAAG,oBAAoB,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAChE,MAAM,UAAU,GAAG,gBAAgB,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAEtD,OAAO,GAAG,WAAW;;;;;;;;;;wBAUE,cAAc;uBACf,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkChC,CAAC;AACF,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=schema-child.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-child.d.ts","sourceRoot":"","sources":["../../src/node/schema-child.ts"],"names":[],"mappings":""}
@@ -0,0 +1,31 @@
1
+ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
2
+ if (typeof path === "string" && /^\.\.?\//.test(path)) {
3
+ return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
4
+ return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
5
+ });
6
+ }
7
+ return path;
8
+ };
9
+ import { registerHooks } from "node:module";
10
+ import { join } from "node:path";
11
+ import { pathToFileURL } from "node:url";
12
+ import { routerSchema } from "../schema.js";
13
+ import { PROCEDURE_FILE, WORKER_FILE } from "./types.js";
14
+ // The child `slotform generate` runs to read the router: docs/architecture/plugins/api.md, "Schema".
15
+ // It prints the schema as JSON; a failure prints to stderr and exits 1.
16
+ const [cwd] = process.argv.slice(2);
17
+ if (cwd === undefined)
18
+ throw new Error("schema-child: no project directory");
19
+ const procedure = pathToFileURL(join(cwd, PROCEDURE_FILE)).href;
20
+ registerHooks({
21
+ resolve: (specifier, context, next) => next(specifier === "virtual:slotform-procedure" ? procedure : specifier, context),
22
+ });
23
+ try {
24
+ const { default: worker } = (await import(__rewriteRelativeImportExtension(pathToFileURL(join(cwd, WORKER_FILE)).href)));
25
+ process.stdout.write(JSON.stringify(routerSchema(worker._router)));
26
+ }
27
+ catch (error) {
28
+ process.stderr.write(error instanceof Error ? (error.stack ?? error.message) : String(error));
29
+ process.exit(1);
30
+ }
31
+ //# sourceMappingURL=schema-child.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-child.js","sourceRoot":"","sources":["../../src/node/schema-child.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzD,qGAAqG;AACrG,wEAAwE;AACxE,MAAM,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACpC,IAAI,GAAG,KAAK,SAAS;IAAE,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;AAE7E,MAAM,SAAS,GAAG,aAAa,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC;AAChE,aAAa,CAAC;IACb,OAAO,EAAE,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CACrC,IAAI,CACH,SAAS,KAAK,4BAA4B,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,EAClE,OAAO,CACP;CACF,CAAC,CAAC;AAEH,IAAI,CAAC;IACJ,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,MAAM,kCACxC,aAAa,CAAC,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,IAAI,EAC1C,CAAsC,CAAC;IACxC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AACpE,CAAC;AAAC,OAAO,KAAK,EAAE,CAAC;IAChB,OAAO,CAAC,MAAM,CAAC,KAAK,CACnB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CACvE,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACjB,CAAC"}
@@ -0,0 +1,3 @@
1
+ /** The source of `.slotform/schema.ts` (null for a project without routes): every procedure of the app's router (the runtime plugins' routes too) with its input as JSON Schema, its kind and its scope key, which the client reads. The router loads in a child node process, so a long-lived `slotform dev` never writes a stale schema; a procedure that fails to load or convert fails `generate`, naming its path. */
2
+ export declare function schemaSource(cwd: string, env: NodeJS.ProcessEnv): Promise<string | null>;
3
+ //# sourceMappingURL=schema-source.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-source.d.ts","sourceRoot":"","sources":["../../src/node/schema-source.ts"],"names":[],"mappings":"AAkBA,2ZAA2Z;AAC3Z,wBAAsB,YAAY,CACjC,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,CAAC,UAAU,GACpB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAsBxB"}
@@ -0,0 +1,33 @@
1
+ import { execFile } from "node:child_process";
2
+ import { existsSync } from "node:fs";
3
+ import { join } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ import { promisify } from "node:util";
6
+ import { PROCEDURE_FILE, ROUTES_BARREL, WORKER_FILE } from "./types.js";
7
+ const run = promisify(execFile);
8
+ // The child ships beside this module, as the same kind of file (`.js` from
9
+ // `dist/`, `.ts` when the plugin runs from source).
10
+ const CHILD = fileURLToPath(new URL(`./schema-child${import.meta.url.slice(import.meta.url.lastIndexOf("."))}`, import.meta.url));
11
+ /** The source of `.slotform/schema.ts` (null for a project without routes): every procedure of the app's router (the runtime plugins' routes too) with its input as JSON Schema, its kind and its scope key, which the client reads. The router loads in a child node process, so a long-lived `slotform dev` never writes a stale schema; a procedure that fails to load or convert fails `generate`, naming its path. */
12
+ export async function schemaSource(cwd, env) {
13
+ if (!existsSync(join(cwd, PROCEDURE_FILE)) ||
14
+ !existsSync(join(cwd, WORKER_FILE)) ||
15
+ !existsSync(join(cwd, ROUTES_BARREL))) {
16
+ return null;
17
+ }
18
+ let schema;
19
+ try {
20
+ const { stdout } = await run(process.execPath, [CHILD, cwd], {
21
+ maxBuffer: 256 * 1024 * 1024,
22
+ env,
23
+ });
24
+ schema = JSON.parse(stdout);
25
+ }
26
+ catch (error) {
27
+ const detail = error.stderr ??
28
+ (error instanceof Error ? error.message : String(error));
29
+ throw new Error(`generate: could not read the router's schema.\n${detail}`);
30
+ }
31
+ return `// Generated by \`slotform generate\`: each procedure's input as JSON Schema, its kind and its scope key.\nexport const SCHEMA = ${JSON.stringify(schema, null, "\t")} as const;\n`;
32
+ }
33
+ //# sourceMappingURL=schema-source.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-source.js","sourceRoot":"","sources":["../../src/node/schema-source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAExE,MAAM,GAAG,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAEhC,2EAA2E;AAC3E,oDAAoD;AACpD,MAAM,KAAK,GAAG,aAAa,CAC1B,IAAI,GAAG,CACN,iBAAiB,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,EAAE,EAC1E,OAAO,IAAI,CAAC,GAAG,CACf,CACD,CAAC;AAEF,2ZAA2Z;AAC3Z,MAAM,CAAC,KAAK,UAAU,YAAY,CACjC,GAAW,EACX,GAAsB;IAEtB,IACC,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;QACtC,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;QACnC,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC,EACpC,CAAC;QACF,OAAO,IAAI,CAAC;IACb,CAAC;IACD,IAAI,MAAe,CAAC;IACpB,IAAI,CAAC;QACJ,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE;YAC5D,SAAS,EAAE,GAAG,GAAG,IAAI,GAAG,IAAI;YAC5B,GAAG;SACH,CAAC,CAAC;QACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,MAAM,MAAM,GACV,KAA6B,CAAC,MAAM;YACrC,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QAC1D,MAAM,IAAI,KAAK,CAAC,kDAAkD,MAAM,EAAE,CAAC,CAAC;IAC7E,CAAC;IACD,OAAO,oIAAoI,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,cAAc,CAAC;AAC7L,CAAC"}
@@ -0,0 +1,19 @@
1
+ import type { ContributionCtx } from "@slotform/cli";
2
+ import { z } from "zod";
3
+ export declare const SERVER_SCHEMA = ".slotform/schema.ts";
4
+ export declare const SERVER_MANIFEST = ".slotform/server.json";
5
+ export declare const SERVER_TYPES = ".slotform/server.ts";
6
+ declare const serverManifestSchema: z.ZodObject<{
7
+ auth: z.ZodBoolean;
8
+ }, z.core.$strip>;
9
+ type ServerManifest = z.infer<typeof serverManifestSchema>;
10
+ type FileCtx = Pick<ContributionCtx, "fileExists" | "readFile">;
11
+ /** Reads a file the server app generated, or fails naming what to run there. */
12
+ export declare function readServerFile(ctx: FileCtx, server: string, file: string): Promise<string>;
13
+ export declare function readServerManifest(ctx: FileCtx, server: string): Promise<ServerManifest>;
14
+ /** The checks a client app passes at generate time: the server app generated everything the client reads, including the router's declaration. */
15
+ export declare function checkServer(ctx: FileCtx, server: string): Promise<void>;
16
+ /** `.slotform/server.ts` of a client app: the server's `AppRouter` type, re-exported type-only from the declaration the server's `tsc -b` emits, so no server code enters the bundle and the app never type-checks the server's sources. */
17
+ export declare function serverTypesSource(server: string): string;
18
+ export {};
19
+ //# sourceMappingURL=server-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-client.d.ts","sourceRoot":"","sources":["../../src/node/server-client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,aAAa,wBAA+B,CAAC;AAC1D,eAAO,MAAM,eAAe,0BAAiC,CAAC;AAC9D,eAAO,MAAM,YAAY,wBAA+B,CAAC;AAKzD,QAAA,MAAM,oBAAoB;;iBAAkC,CAAC;AAC7D,KAAK,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAE3D,KAAK,OAAO,GAAG,IAAI,CAAC,eAAe,EAAE,YAAY,GAAG,UAAU,CAAC,CAAC;AAEhE,gFAAgF;AAChF,wBAAsB,cAAc,CACnC,GAAG,EAAE,OAAO,EACZ,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,GACV,OAAO,CAAC,MAAM,CAAC,CAQjB;AAED,wBAAsB,kBAAkB,CACvC,GAAG,EAAE,OAAO,EACZ,MAAM,EAAE,MAAM,GACZ,OAAO,CAAC,cAAc,CAAC,CASzB;AAED,iJAAiJ;AACjJ,wBAAsB,WAAW,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAS7E;AAED,4OAA4O;AAC5O,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAMxD"}
@@ -0,0 +1,45 @@
1
+ import { posix } from "node:path";
2
+ import { GENERATED_DIR } from "@slotform/cli";
3
+ import { z } from "zod";
4
+ // Client-only apps: docs/architecture/plugins/api.md, "Client-only apps".
5
+ export const SERVER_SCHEMA = `${GENERATED_DIR}/schema.ts`;
6
+ export const SERVER_MANIFEST = `${GENERATED_DIR}/server.json`;
7
+ export const SERVER_TYPES = `${GENERATED_DIR}/server.ts`;
8
+ // The router declaration the server's `tsc -b` emits for its `.slotform/worker.ts`.
9
+ const SERVER_ROUTER_TYPES = `${GENERATED_DIR}/types/${GENERATED_DIR}/worker.d.ts`;
10
+ // The server manifest: docs/architecture/plugins/api.md, "Client-only apps".
11
+ const serverManifestSchema = z.object({ auth: z.boolean() });
12
+ /** Reads a file the server app generated, or fails naming what to run there. */
13
+ export async function readServerFile(ctx, server, file) {
14
+ const path = posix.join(posix.normalize(server), file);
15
+ if (!(await ctx.fileExists(path))) {
16
+ throw new Error(`api: \`server: "${server}"\` has no ${file}. Run \`slotform generate\` in ${posix.normalize(server)} first.`);
17
+ }
18
+ return ctx.readFile(path);
19
+ }
20
+ export async function readServerManifest(ctx, server) {
21
+ const text = await readServerFile(ctx, server, SERVER_MANIFEST);
22
+ const parsed = serverManifestSchema.safeParse(JSON.parse(text));
23
+ if (!parsed.success) {
24
+ throw new Error(`api: ${posix.join(posix.normalize(server), SERVER_MANIFEST)} is not a server manifest (${parsed.error.message}). Run \`slotform generate\` in ${posix.normalize(server)} again.`);
25
+ }
26
+ return parsed.data;
27
+ }
28
+ /** The checks a client app passes at generate time: the server app generated everything the client reads, including the router's declaration. */
29
+ export async function checkServer(ctx, server) {
30
+ await readServerManifest(ctx, server);
31
+ for (const file of [SERVER_SCHEMA, SERVER_ROUTER_TYPES]) {
32
+ if (!(await ctx.fileExists(posix.join(posix.normalize(server), file)))) {
33
+ throw new Error(`api: \`server: "${server}"\` has no ${file}. Run \`slotform generate\` in ${posix.normalize(server)} first.`);
34
+ }
35
+ }
36
+ }
37
+ /** `.slotform/server.ts` of a client app: the server's `AppRouter` type, re-exported type-only from the declaration the server's `tsc -b` emits, so no server code enters the bundle and the app never type-checks the server's sources. */
38
+ export function serverTypesSource(server) {
39
+ return [
40
+ "// Generated by @slotform/api. Do not edit.",
41
+ `export type { AppRouter } from ${JSON.stringify(`../${posix.normalize(server)}/${SERVER_ROUTER_TYPES.replace(/\.d\.ts$/, "")}`)};`,
42
+ "",
43
+ ].join("\n");
44
+ }
45
+ //# sourceMappingURL=server-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-client.js","sourceRoot":"","sources":["../../src/node/server-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,0EAA0E;AAC1E,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,aAAa,YAAY,CAAC;AAC1D,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,aAAa,cAAc,CAAC;AAC9D,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,aAAa,YAAY,CAAC;AACzD,oFAAoF;AACpF,MAAM,mBAAmB,GAAG,GAAG,aAAa,UAAU,aAAa,cAAc,CAAC;AAElF,6EAA6E;AAC7E,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AAK7D,gFAAgF;AAChF,MAAM,CAAC,KAAK,UAAU,cAAc,CACnC,GAAY,EACZ,MAAc,EACd,IAAY;IAEZ,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,CAAC;IACvD,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;QACnC,MAAM,IAAI,KAAK,CACd,mBAAmB,MAAM,cAAc,IAAI,kCAAkC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,SAAS,CAC7G,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAC3B,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,k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,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG;QACnI,EAAE;KACF,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACd,CAAC"}
@@ -0,0 +1,42 @@
1
+ import type { TsExpression, TsImportSpec } from "@slotform/cli/ast";
2
+ export declare const WORKER_FILE = ".slotform/worker.ts";
3
+ export declare const PROCEDURE_FILE = ".slotform/procedure.ts";
4
+ export declare const ROUTES_DIR = "src/worker/routes";
5
+ export declare const ROUTES_BARREL = "src/worker/routes/index.ts";
6
+ export declare function importSource(file: string): string;
7
+ export declare const ROUTES_BARREL_IMPORT_SOURCE: string;
8
+ export interface PluginRuntimeEntry {
9
+ plugin: string;
10
+ import: TsImportSpec;
11
+ identifier: string;
12
+ options: Record<string, TsExpression>;
13
+ }
14
+ export interface CallbackSpec {
15
+ import: TsImportSpec;
16
+ identifier: string;
17
+ }
18
+ export interface WorkerPayload {
19
+ imports: TsImportSpec[];
20
+ base: TsExpression;
21
+ pluginRuntimes: PluginRuntimeEntry[];
22
+ middlewareChain: MiddlewareCall[];
23
+ handler: {
24
+ identifier: string;
25
+ } | null;
26
+ mcp: {
27
+ identifier: string;
28
+ name: string;
29
+ } | null;
30
+ queue: {
31
+ identifier: string;
32
+ } | null;
33
+ scheduled: {
34
+ identifier: string;
35
+ } | null;
36
+ callbacks: Record<string, CallbackSpec>;
37
+ }
38
+ export interface MiddlewareCall {
39
+ call: TsExpression;
40
+ method: "use" | "useAfterContext";
41
+ }
42
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/node/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGpE,eAAO,MAAM,WAAW,wBAA+B,CAAC;AACxD,eAAO,MAAM,cAAc,2BAAkC,CAAC;AAG9D,eAAO,MAAM,UAAU,sBAAsB,CAAC;AAC9C,eAAO,MAAM,aAAa,+BAA2B,CAAC;AAGtD,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED,eAAO,MAAM,2BAA2B,QAA8B,CAAC;AAQvE,MAAM,WAAW,kBAAkB;IAClC,MAAM,EAAE,MAAM,CAAC;IAGf,MAAM,EAAE,YAAY,CAAC;IAGrB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;CACtC;AAGD,MAAM,WAAW,YAAY;IAC5B,MAAM,EAAE,YAAY,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACnB;AAGD,MAAM,WAAW,aAAa;IAC7B,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,IAAI,EAAE,YAAY,CAAC;IACnB,cAAc,EAAE,kBAAkB,EAAE,CAAC;IACrC,eAAe,EAAE,cAAc,EAAE,CAAC;IAClC,OAAO,EAAE;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAGvC,GAAG,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAGjD,KAAK,EAAE;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IACrC,SAAS,EAAE;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAEzC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;CACxC;AAGD,MAAM,WAAW,cAAc;IAC9B,IAAI,EAAE,YAAY,CAAC;IACnB,MAAM,EAAE,KAAK,GAAG,iBAAiB,CAAC;CAClC"}
@@ -0,0 +1,13 @@
1
+ import { GENERATED_DIR } from "@slotform/cli";
2
+ // The generated files: docs/architecture/plugins/api.md, "Generated files".
3
+ export const WORKER_FILE = `${GENERATED_DIR}/worker.ts`;
4
+ export const PROCEDURE_FILE = `${GENERATED_DIR}/procedure.ts`;
5
+ // The route barrel: docs/architecture/plugins/api.md, "Routes barrel".
6
+ export const ROUTES_DIR = "src/worker/routes";
7
+ export const ROUTES_BARREL = `${ROUTES_DIR}/index.ts`;
8
+ // How a file generated into `.slotform/` imports a consumer source file.
9
+ export function importSource(file) {
10
+ return `../${file}`;
11
+ }
12
+ export const ROUTES_BARREL_IMPORT_SOURCE = importSource(ROUTES_BARREL);
13
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/node/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAG9C,4EAA4E;AAC5E,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,aAAa,YAAY,CAAC;AACxD,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,aAAa,eAAe,CAAC;AAE9D,uEAAuE;AACvE,MAAM,CAAC,MAAM,UAAU,GAAG,mBAAmB,CAAC;AAC9C,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,UAAU,WAAW,CAAC;AAEtD,yEAAyE;AACzE,MAAM,UAAU,YAAY,CAAC,IAAY;IACxC,OAAO,MAAM,IAAI,EAAE,CAAC;AACrB,CAAC;AAED,MAAM,CAAC,MAAM,2BAA2B,GAAG,YAAY,CAAC,aAAa,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function isNotFound(error: unknown): boolean;
2
+ //# sourceMappingURL=not-found.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"not-found.d.ts","sourceRoot":"","sources":["../src/not-found.ts"],"names":[],"mappings":"AAGA,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAElD"}
@@ -0,0 +1,6 @@
1
+ import { ORPCError } from "@orpc/client";
2
+ // Not found: docs/architecture/plugins/api.md, "Not found".
3
+ export function isNotFound(error) {
4
+ return error instanceof ORPCError && error.code === "NOT_FOUND";
5
+ }
6
+ //# sourceMappingURL=not-found.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"not-found.js","sourceRoot":"","sources":["../src/not-found.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,4DAA4D;AAC5D,MAAM,UAAU,UAAU,CAAC,KAAc;IACxC,OAAO,KAAK,YAAY,SAAS,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,CAAC;AACjE,CAAC"}