@brickkit/cli 0.11.0 → 0.13.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 (177) hide show
  1. package/dashboard-dist/CollapsiblePanel-CbUysOp5.js +2 -0
  2. package/dashboard-dist/CompositeRoot-D4sRkYq3.js +1 -0
  3. package/dashboard-dist/Geist-Variable.woff2 +0 -0
  4. package/dashboard-dist/GeistMono-Variable.woff2 +0 -0
  5. package/dashboard-dist/PopoverPopup-CiI2avT_.js +1 -0
  6. package/dashboard-dist/api-reference-mT9VNcPb.js +265 -0
  7. package/dashboard-dist/app.css +2 -2
  8. package/dashboard-dist/app.js +12 -13
  9. package/dashboard-dist/ccount-CcG1m-Yh.js +1 -0
  10. package/dashboard-dist/client-CwATkLJa.js +1 -0
  11. package/dashboard-dist/core-BEUWp6B5.js +1 -0
  12. package/dashboard-dist/docs-BRrtyxDB.js +4 -0
  13. package/dashboard-dist/docs.css +1 -1
  14. package/dashboard-dist/kit.js +1 -1
  15. package/dashboard-dist/popover-Bj9x-88h.js +1 -0
  16. package/dist/bin.d.ts +0 -2
  17. package/dist/bin.js +309 -211
  18. package/dist/bin.js.map +1 -1
  19. package/dist/build.js +463 -0
  20. package/dist/build.js.map +1 -0
  21. package/dist/client-contract-file.js +356 -1
  22. package/dist/client-contract-file.js.map +1 -0
  23. package/dist/compiler.d.ts +12 -3
  24. package/dist/compiler.js +1 -1
  25. package/dist/compiler2.js +13 -7
  26. package/dist/compiler2.js.map +1 -1
  27. package/dist/config.d.ts +3 -0
  28. package/dist/config.js +1 -252
  29. package/dist/config2.d.ts +122 -0
  30. package/dist/config2.js +207 -0
  31. package/dist/config2.js.map +1 -0
  32. package/dist/dashboard-extension.d.ts +3 -2
  33. package/dist/{dev-telemetry-store.js → dashboard-host.js} +1381 -1432
  34. package/dist/dashboard-host.js.map +1 -0
  35. package/dist/dashboard-protocol.js +189 -0
  36. package/dist/dashboard-protocol.js.map +1 -0
  37. package/dist/dashboard.d.ts +8 -135
  38. package/dist/definitions.js +33 -0
  39. package/dist/definitions.js.map +1 -0
  40. package/dist/dev-application.js +34 -0
  41. package/dist/dev-application.js.map +1 -0
  42. package/dist/dev-protocol.js +21 -0
  43. package/dist/dev-protocol.js.map +1 -0
  44. package/dist/dev-reporter.d.ts +0 -2
  45. package/dist/dev-reporter.js +3 -3
  46. package/dist/dev-reporter.js.map +1 -1
  47. package/dist/dev-telemetry.js +8 -24
  48. package/dist/dev-telemetry.js.map +1 -1
  49. package/dist/dev-worker.js +80 -21
  50. package/dist/dev-worker.js.map +1 -1
  51. package/dist/index.d.ts +18 -87
  52. package/dist/index.js +12 -6
  53. package/dist/index.js.map +1 -0
  54. package/dist/lint/oxlint.d.ts +0 -2
  55. package/dist/lint/oxlint.js +6 -5
  56. package/dist/lint/oxlint.js.map +1 -1
  57. package/dist/own-module.js +7 -0
  58. package/dist/own-module.js.map +1 -0
  59. package/dist/plugin.d.ts +6 -11
  60. package/dist/plugin.js +6 -42
  61. package/dist/plugin.js.map +1 -1
  62. package/dist/production-dashboard.d.ts +2 -0
  63. package/dist/production-dashboard.js +51 -0
  64. package/dist/production-dashboard.js.map +1 -0
  65. package/dist/production-dashboard2.d.ts +34 -0
  66. package/dist/{presets.js → project.js} +107 -113
  67. package/dist/project.js.map +1 -0
  68. package/dist/serve.d.ts +24 -0
  69. package/dist/serve.js +1 -0
  70. package/dist/serve2.js +49 -0
  71. package/dist/serve2.js.map +1 -0
  72. package/dist/vite.d.ts +0 -2
  73. package/dist/vite.js +28 -51
  74. package/dist/vite.js.map +1 -1
  75. package/dist/workflows.d.ts +2 -4
  76. package/dist/workflows2.js +60 -39
  77. package/dist/workflows2.js.map +1 -1
  78. package/inspector-dist/client/assets/api.rpc-BvRk9kiK.js +0 -0
  79. package/inspector-dist/client/assets/api.stream._streamId-BvRk9kiK.js +0 -0
  80. package/inspector-dist/client/assets/app-CeSwVsRm.css +2 -0
  81. package/inspector-dist/client/assets/dist-BK8w6xOr.js +3930 -0
  82. package/inspector-dist/client/assets/dist-CG2aVufI.js +197 -0
  83. package/inspector-dist/client/assets/entry.client-D9jbgmTR.js +9391 -0
  84. package/inspector-dist/client/assets/highlighted-body-B3W2YXNL-CfRnuITN.js +34 -0
  85. package/inspector-dist/client/assets/home-hwPlkNhv.js +4034 -0
  86. package/inspector-dist/client/assets/jsx-runtime-CPEah4WQ.js +7084 -0
  87. package/inspector-dist/client/assets/manifest-0e76e9ac.js +1 -0
  88. package/inspector-dist/client/assets/mermaid-3ZIDBTTL-ZDR2PNY_.js +1 -0
  89. package/inspector-dist/client/assets/root-ChBNTZd2.css +2 -0
  90. package/inspector-dist/client/assets/root-SLeEf-sT.js +320 -0
  91. package/inspector-dist/client/assets/run-detail-DYbVkIFH.js +1871 -0
  92. package/inspector-dist/client/assets/tabs-CaJisoyb.js +73751 -0
  93. package/inspector-dist/client/assets/tabs-L5XKzOpP.css +1 -0
  94. package/inspector-dist/client/assets/zstd-browser-decoder-D94wmfAU.js +41 -0
  95. package/inspector-dist/server/assets/app-DGlfWVUI.js +99330 -0
  96. package/inspector-dist/server/assets/chunk-RLXIAIE6-F0SJZlei.js +42975 -0
  97. package/inspector-dist/server/assets/dist-BCbwm6jl.js +10325 -0
  98. package/inspector-dist/server/assets/dist-CG2aVufI.js +197 -0
  99. package/inspector-dist/server/assets/dist-Ce0I2PUv.js +1137 -0
  100. package/inspector-dist/server/assets/dist-DY0UlahA.js +1642 -0
  101. package/inspector-dist/server/assets/encryption-DdQgC8Rk.js +886 -0
  102. package/inspector-dist/server/assets/event-metadata-n7E4zEmT.js +145 -0
  103. package/inspector-dist/server/assets/functions-CNVQtbgg.js +1170 -0
  104. package/inspector-dist/server/assets/global-singleton-D8sIN5du.js +80 -0
  105. package/inspector-dist/server/assets/highlighted-body-B3W2YXNL-CWRzMxYD.js +34 -0
  106. package/inspector-dist/server/assets/mermaid-3ZIDBTTL-D0v0ngVr.js +1 -0
  107. package/inspector-dist/server/assets/parse-Begau9cA.js +469 -0
  108. package/inspector-dist/server/assets/rolldown-runtime-C1I3wEg2.js +43 -0
  109. package/inspector-dist/server/assets/serialization-format-BbuGfHog.js +476 -0
  110. package/inspector-dist/server/assets/token-BgMmJNP5.js +60 -0
  111. package/inspector-dist/server/assets/token-BrUX0bxz.js +55 -0
  112. package/inspector-dist/server/assets/token-util-DZN32qmT.js +455 -0
  113. package/inspector-dist/server/assets/wrapper-CIC3w0oC.js +3624 -0
  114. package/inspector-dist/server/assets/ws-transport-CxTYB11n.js +29476 -0
  115. package/inspector-dist/server/assets/zstd-browser-decoder-D7bCXbGg.js +38 -0
  116. package/inspector-dist/server/index.js +1 -58
  117. package/package.json +39 -28
  118. package/vite-client.d.ts +1 -1
  119. package/dashboard-dist/CollapsiblePanel-BX79_W-b.js +0 -2
  120. package/dashboard-dist/CompositeRoot-xzybXjnx.js +0 -1
  121. package/dashboard-dist/PopoverPopup-CvlmC7EL.js +0 -1
  122. package/dashboard-dist/api-reference-BcAYVYwJ.js +0 -260
  123. package/dashboard-dist/core-BGO9JZ1r.js +0 -1
  124. package/dashboard-dist/docs-DHikPD2v.js +0 -4
  125. package/dashboard-dist/popover-DG498XHH.js +0 -1
  126. package/dist/app-entry.js +0 -1
  127. package/dist/app-entry2.js +0 -19
  128. package/dist/app-entry2.js.map +0 -1
  129. package/dist/bin.d.ts.map +0 -1
  130. package/dist/client-contract-file2.js +0 -34
  131. package/dist/client-contract-file2.js.map +0 -1
  132. package/dist/client-contract.js +0 -1
  133. package/dist/client-contract2.js +0 -294
  134. package/dist/client-contract2.js.map +0 -1
  135. package/dist/config.js.map +0 -1
  136. package/dist/dashboard-extension.d.ts.map +0 -1
  137. package/dist/dev-reporter.d.ts.map +0 -1
  138. package/dist/dev-telemetry-store.js.map +0 -1
  139. package/dist/emit.d.ts +0 -7
  140. package/dist/emit.d.ts.map +0 -1
  141. package/dist/index.d.ts.map +0 -1
  142. package/dist/lint/oxlint.d.ts.map +0 -1
  143. package/dist/plugin.d.ts.map +0 -1
  144. package/dist/presets.js.map +0 -1
  145. package/dist/runner.js +0 -523
  146. package/dist/runner.js.map +0 -1
  147. package/dist/vite.d.ts.map +0 -1
  148. package/dist/workflows.d.ts.map +0 -1
  149. package/inspector-dist/client/assets/api.rpc-l0sNRNKZ.js +0 -1
  150. package/inspector-dist/client/assets/api.stream._streamId-l0sNRNKZ.js +0 -1
  151. package/inspector-dist/client/assets/app-CvoGgWcV.css +0 -1
  152. package/inspector-dist/client/assets/entry.client-BJ6G3n5t.js +0 -11697
  153. package/inspector-dist/client/assets/highlighted-body-B3W2YXNL-C-3wZnxf.js +0 -19
  154. package/inspector-dist/client/assets/home-CSKAS4P2.js +0 -4979
  155. package/inspector-dist/client/assets/index-DECCyMR0.js +0 -4482
  156. package/inspector-dist/client/assets/index-Dot7CgrA.js +0 -9837
  157. package/inspector-dist/client/assets/index-HqNj_XIX.js +0 -200
  158. package/inspector-dist/client/assets/manifest-139c9319.js +0 -1
  159. package/inspector-dist/client/assets/mermaid-3ZIDBTTL-DC0K8uTy.js +0 -58626
  160. package/inspector-dist/client/assets/mermaid-3ZIDBTTL-F88p7PFX.css +0 -1
  161. package/inspector-dist/client/assets/root-BMHd_XHz.css +0 -1
  162. package/inspector-dist/client/assets/root-cbi6iYwg.js +0 -305
  163. package/inspector-dist/client/assets/run-detail-CWoGxu_0.css +0 -1
  164. package/inspector-dist/client/assets/run-detail-Cc7tSGNq.js +0 -6237
  165. package/inspector-dist/client/assets/world-config-context-BAD1QCrR.js +0 -26
  166. package/inspector-dist/client/assets/zstd-browser-decoder-BQoRpP7L.js +0 -28
  167. package/inspector-dist/server/assets/app-DUP5RybL.js +0 -174880
  168. package/inspector-dist/server/assets/highlighted-body-B3W2YXNL-D2g4hL2-.js +0 -71
  169. package/inspector-dist/server/assets/index-BfLBLRRi.js +0 -204
  170. package/inspector-dist/server/assets/index-BzrGWk7J.js +0 -1164
  171. package/inspector-dist/server/assets/index-D71yP6AL.js +0 -191
  172. package/inspector-dist/server/assets/index-wGSWRns3.js +0 -1296
  173. package/inspector-dist/server/assets/mermaid-3ZIDBTTL-DsvuKoEV.js +0 -58
  174. package/inspector-dist/server/assets/token-ClUZZwXl.js +0 -95
  175. package/inspector-dist/server/assets/token-util-DSxMZ6nI.js +0 -33
  176. package/inspector-dist/server/assets/wrapper-B3vstpCO.js +0 -67
  177. package/inspector-dist/server/assets/zstd-browser-decoder-Dn82m2BU.js +0 -77
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project.js","names":["posix","rule"],"sources":["../src/lint/ast.ts","../package.json","../src/lint/rules/checks.ts","../src/lint/rules/layout.ts","../src/lint/presets.ts","../src/lint/project.ts"],"sourcesContent":["import { basename, dirname, relative, resolve, sep } from \"node:path\";\nimport { kebabCase } from \"@brickkit/core/client\";\nimport { PROJECT_DEFAULTS } from \"../config\";\nimport {\n DEFINITION_FILE,\n TEST_FILE,\n type DefinitionKind,\n} from \"../definitions\";\n\n// ESTree nodes as ESLint and oxlint hand them to rules. Kept loose on purpose:\n// the rules read a handful of fields and run under both linters.\n// oxlint-disable-next-line typescript/no-explicit-any\nexport type Node = any;\n\nexport interface RuleContext {\n filename: string;\n cwd?: string;\n settings?: { brick?: Partial<BrickSettings> };\n options?: unknown[];\n sourceCode: { getText(node?: Node): string };\n report(descriptor: {\n node: Node;\n message: string;\n fix?: (fixer: Fixer) => unknown;\n }): void;\n}\n\nexport interface Fixer {\n insertTextBefore(node: Node, text: string): unknown;\n insertTextAfter(node: Node, text: string): unknown;\n insertTextBeforeRange(range: [number, number], text: string): unknown;\n replaceText(node: Node, text: string): unknown;\n}\n\nexport interface Rule {\n meta: {\n type: \"problem\" | \"suggestion\" | \"layout\";\n docs: { description: string };\n fixable?: \"code\";\n schema: unknown[];\n };\n create(\n context: RuleContext,\n ): Record<string, ((node: Node) => void) | undefined>;\n}\n\nexport function defineRule(\n type: Rule[\"meta\"][\"type\"],\n description: string,\n create: Rule[\"create\"],\n options: { fixable?: \"code\"; schema?: unknown[] } = {},\n): Rule {\n return {\n meta: {\n type,\n docs: { description },\n fixable: options.fixable,\n schema: options.schema ?? [],\n },\n create,\n };\n}\n\n/** Paths from brick.config.ts, relative to `root`. Linters pass them in `settings.brick`. */\nexport interface BrickSettings {\n root: string;\n services: string;\n entry: string;\n generated: string;\n}\n\n/** Browser code folder, which may import only the client and the contract. */\nexport const WEB_DIR = \"web\";\n\nconst posix = (path: string) => path.split(sep).join(\"/\");\n\n/** The settings with Brick's default paths, each relative to the root without a trailing slash. */\nexport function brickSettings(context: RuleContext): BrickSettings {\n const given = context.settings?.brick ?? {};\n const root = given.root ?? context.cwd ?? process.cwd();\n const from = (path: string) => posix(relative(root, resolve(root, path)));\n return {\n root,\n services: from(given.services ?? PROJECT_DEFAULTS.services),\n entry: from(given.entry ?? PROJECT_DEFAULTS.entry),\n generated: from(given.generated ?? PROJECT_DEFAULTS.generated),\n };\n}\n\n/** The folders a service may live in: its kebab-case name, or the name itself. */\nexport const serviceFolders = (name: string) => [kebabCase(name), name];\n\nexport interface FileInfo {\n settings: BrickSettings;\n rel: string;\n base: string;\n inServices: boolean;\n /** Service folder name, for files under `<services>/<name>/`. */\n service?: string;\n /** Path segments after the service folder (the last one is the file). */\n rest: string[];\n /** Definition kind from the file suffix, and the name before it. */\n kind?: DefinitionKind;\n stem?: string;\n /** Tests, dependencies and generated files: no rule checks them. */\n ignored: boolean;\n /** Tests, local plugins and generated files are not app definitions. */\n exempt: boolean;\n}\n\nexport function fileInfo(context: RuleContext): FileInfo {\n const settings = brickSettings(context);\n const rel = posix(relative(settings.root, context.filename));\n const { services: servicesDir, generated } = settings;\n const base = basename(rel);\n const inServices = rel.startsWith(`${servicesDir}/`);\n const parts = inServices ? rel.slice(servicesDir.length + 1).split(\"/\") : [];\n const match = DEFINITION_FILE.exec(base);\n const segments = rel.split(\"/\");\n const ignored =\n TEST_FILE.test(base) ||\n segments.includes(\"test\") ||\n segments.includes(\"tests\") ||\n segments.includes(\"__tests__\") ||\n segments.includes(\"node_modules\") ||\n rel.startsWith(`${generated}/`);\n return {\n settings,\n rel,\n base,\n inServices,\n service: parts.length > 1 ? parts[0] : undefined,\n rest: parts.slice(1),\n kind: match?.[2] as DefinitionKind | undefined,\n stem: match?.[1],\n ignored,\n exempt: ignored || segments.includes(\"plugins\"),\n };\n}\n\n/** A string literal's value, or a template literal's text when it has no expressions. */\nexport function stringValue(node: Node): string | undefined {\n if (node?.type === \"Literal\" && typeof node.value === \"string\")\n return node.value;\n if (node?.type === \"TemplateLiteral\" && node.expressions.length === 0)\n return node.quasis[0]?.value.cooked ?? undefined;\n return undefined;\n}\n\nexport function propertyName(property: Node): string | undefined {\n if (property?.type !== \"Property\" || property.computed) return undefined;\n const key = property.key;\n if (key.type === \"Identifier\") return key.name;\n return typeof key.value === \"string\" ? key.value : undefined;\n}\n\nexport function getProperty(object: Node, name: string): Node | undefined {\n if (object?.type !== \"ObjectExpression\") return undefined;\n return object.properties.find(\n (property: Node) => propertyName(property) === name,\n );\n}\n\nexport function objectKeys(object: Node): string[] | undefined {\n if (object?.type !== \"ObjectExpression\") return undefined;\n const keys: string[] = [];\n for (const property of object.properties) {\n const name = propertyName(property);\n if (name === undefined) return undefined; // a spread or computed key: unknown keys\n keys.push(name);\n }\n return keys;\n}\n\n/** `t.Object(...)` or `Type.Object(...)`. */\nexport function isSchemaCall(node: Node, kind?: string): boolean {\n return (\n node?.type === \"CallExpression\" &&\n node.callee.type === \"MemberExpression\" &&\n !node.callee.computed &&\n node.callee.object.type === \"Identifier\" &&\n (node.callee.object.name === \"t\" || node.callee.object.name === \"Type\") &&\n (kind === undefined || node.callee.property.name === kind)\n );\n}\n\nexport interface Definition {\n kind: DefinitionKind | \"plugin\" | \"crud\";\n call: Node;\n /** The service or resource it attaches to (`orders` in `orders.action(...)`). */\n owner?: string;\n config?: Node;\n name?: string;\n nameNode?: Node;\n}\n\nexport const DEFINE_FUNCTIONS: Record<string, Definition[\"kind\"]> = {\n defineService: \"service\",\n defineAction: \"action\",\n defineTool: \"tool\",\n defineListener: \"listener\",\n definePlugin: \"plugin\",\n defineResource: \"resource\",\n crud: \"crud\",\n sqliteTable: \"table\",\n pgTable: \"table\",\n};\n\nconst ATTACH_METHODS: Record<string, Definition[\"kind\"]> = {\n action: \"action\",\n tool: \"tool\",\n socket: \"socket\",\n resource: \"resource\",\n command: \"command\",\n};\n\n/** What a call defines, matching the call shapes in the project structure. */\nexport function definitionOf(call: Node): Definition | undefined {\n if (call?.type !== \"CallExpression\") return undefined;\n const [first, second] = call.arguments;\n const callee = call.callee;\n if (callee.type === \"Identifier\" && DEFINE_FUNCTIONS[callee.name]) {\n const kind = DEFINE_FUNCTIONS[callee.name]!;\n // defineResource(service, config) is service.resource(config).\n if (kind === \"resource\")\n return first?.type === \"Identifier\"\n ? attached(call, kind, first.name, second)\n : undefined;\n if (kind === \"service\" || kind === \"table\") {\n const name = stringValue(first);\n if (name === undefined) return undefined;\n return { kind, call, name, nameNode: first, config: second };\n }\n if (first?.type !== \"ObjectExpression\") return undefined;\n const nameNode = getProperty(first, \"name\")?.value;\n return {\n kind,\n call,\n config: first,\n name: stringValue(nameNode),\n nameNode,\n };\n }\n if (\n callee.type !== \"MemberExpression\" ||\n callee.computed ||\n callee.object.type !== \"Identifier\"\n )\n return undefined;\n const kind = ATTACH_METHODS[callee.property.name];\n if (!kind) return undefined;\n const owner = callee.object.name;\n if (kind === \"command\") {\n const name = stringValue(first);\n if (name === undefined || second?.type !== \"ObjectExpression\")\n return undefined;\n return { kind, call, owner, name, nameNode: first, config: second };\n }\n return attached(call, kind, owner, first);\n}\n\nfunction attached(\n call: Node,\n kind: Definition[\"kind\"],\n owner: string,\n config: Node,\n): Definition | undefined {\n if (config?.type !== \"ObjectExpression\") return undefined;\n const nameNode = getProperty(config, \"name\")?.value;\n const name = stringValue(nameNode);\n // A resource needs its name and table; anything else called `.resource` is not one.\n if (kind === \"resource\" && name === undefined) return undefined;\n return { kind, call, owner, config, name, nameNode };\n}\n\n/** The nearest enclosing definition of one of `kinds`. */\nexport function enclosingDefinition(\n node: Node,\n kinds?: Definition[\"kind\"][],\n): Definition | undefined {\n for (let current = node.parent; current; current = current.parent) {\n const definition = definitionOf(current);\n if (definition && (!kinds || kinds.includes(definition.kind)))\n return definition;\n }\n return undefined;\n}\n\nexport function isFunction(node: Node): boolean {\n return (\n node?.type === \"FunctionDeclaration\" ||\n node?.type === \"FunctionExpression\" ||\n node?.type === \"ArrowFunctionExpression\"\n );\n}\n\nexport function enclosingFunction(node: Node): Node | undefined {\n for (let current = node.parent; current; current = current.parent)\n if (isFunction(current)) return current;\n return undefined;\n}\n\n/** Directives at the top of a function body or of the program. */\nexport function directivesOf(node: Node): string[] {\n const body =\n node?.type === \"Program\"\n ? node.body\n : node?.body?.type === \"BlockStatement\"\n ? node.body.body\n : [];\n const directives: string[] = [];\n for (const statement of body) {\n if (\n statement.type !== \"ExpressionStatement\" ||\n typeof statement.directive !== \"string\"\n )\n break;\n directives.push(statement.directive);\n }\n return directives;\n}\n\nexport function programOf(node: Node): Node {\n let current = node;\n while (current.parent) current = current.parent;\n return current;\n}\n\n/** Local name to import source, for the file's import declarations. */\nexport function importSources(program: Node): Map<string, string> {\n const sources = new Map<string, string>();\n for (const statement of program.body)\n if (statement.type === \"ImportDeclaration\")\n for (const specifier of statement.specifiers)\n sources.set(specifier.local.name, statement.source.value);\n return sources;\n}\n\n/** An import source resolved to a project-relative path; undefined for packages. */\nexport function resolveImport(\n info: FileInfo,\n context: RuleContext,\n source: string,\n): string | undefined {\n if (!source.startsWith(\".\")) return undefined;\n return posix(\n relative(info.settings.root, resolve(dirname(context.filename), source)),\n );\n}\n\n/** `name.method(...)` with a non-computed property, or a bare `fn(...)` (no `object`). */\nexport function memberCall(\n node: Node,\n): { object?: string; property: string } | undefined {\n if (node?.type !== \"CallExpression\") return undefined;\n const callee = node.callee;\n if (callee.type === \"Identifier\") return { property: callee.name };\n if (callee.type !== \"MemberExpression\" || callee.computed) return undefined;\n return {\n object:\n callee.object.type === \"Identifier\" ? callee.object.name : undefined,\n property: callee.property.name,\n };\n}\n","","import {\n defineRule,\n definitionOf,\n directivesOf,\n enclosingDefinition,\n enclosingFunction,\n fileInfo,\n getProperty,\n isFunction,\n isSchemaCall,\n memberCall,\n objectKeys,\n programOf,\n propertyName,\n resolveImport,\n stringValue,\n type Definition,\n type Node,\n type Rule,\n type RuleContext,\n WEB_DIR,\n} from \"../ast\";\nimport { isControlEvent, STANDARD_ERRORS } from \"@brickkit/core/client\";\nimport { MANIFEST_FILE } from \"../../definitions\";\nimport { version } from \"../../../package.json\";\n\nconst MANIFEST_STEM = MANIFEST_FILE.replace(/\\.ts$/, \"\");\n/** This release's range, for the `brick` field example: `^0.12.0`. */\nconst BRICK_RANGE = `^${version.split(\".\").slice(0, 2).join(\".\")}.0`;\n\nconst rule = (\n description: string,\n create: Rule[\"create\"],\n options?: { fixable?: \"code\"; schema?: unknown[] },\n) => defineRule(\"problem\", description, create, options);\n\n/** Skip tests and generated files; local plugins are checked like app code. */\nconst skip = (context: RuleContext) => fileInfo(context).ignored;\n\nconst HANDLERS: Definition[\"kind\"][] = [\"action\", \"command\", \"tool\"];\n/** What clients call: described in OpenAPI, MCP and the dashboard. */\nconst ENDPOINTS: Definition[\"kind\"][] = [...HANDLERS, \"socket\"];\n/** What gets the error helpers. */\nconst ERROR_KINDS: Definition[\"kind\"][] = [...ENDPOINTS, \"crud\"];\n/** What runs with a request or delivery context. */\nconst CTX_KINDS: Definition[\"kind\"][] = [...ERROR_KINDS, \"listener\"];\nconst BUILT_IN_ERRORS = new Set(Object.keys(STANDARD_ERRORS));\n\nfunction errorHelper(node: Node): string | undefined {\n const call = memberCall(node);\n return call?.object === \"error\" ? call.property : undefined;\n}\n\nfunction isEmit(node: Node): \"emitEvent\" | \"emit\" | undefined {\n const call = memberCall(node);\n if (!call) return undefined;\n if (call.property === \"emitEvent\" && call.object === undefined)\n return \"emitEvent\";\n if (call.property === \"emit\" && call.object && node.arguments.length >= 3)\n return \"emit\";\n return undefined;\n}\n\nconst WRITE_METHODS = new Set([\"insert\", \"update\", \"delete\"]);\nconst WRITE_CALL = new RegExp(`\\\\.(${[...WRITE_METHODS].join(\"|\")})\\\\s*\\\\(`);\n\n// Verbs an action name may start with (getUser, archive, importCsv).\nconst VERBS = new Set(\n `get list find search query count read load fetch check validate verify preview render export download\ncreate add insert import upload register invite book place submit send post publish issue open start schedule\nupdate set edit change rename move copy clone merge assign attach link mark toggle enable disable approve reject\naccept confirm complete cancel close finish stop end archive restore refund pay charge ship track sync refresh\nreset delete remove detach unlink clear purge run process handle compute calculate generate build apply sign\nlogin logout subscribe unsubscribe notify ping upsert transfer resend retry lock unlock save write report`.split(\n /\\s+/,\n ),\n);\nconst IRREGULAR_PAST = new Set(\n `sent paid built made sold bought won lost begun done held kept left met read run set shut spent taken given\nwritten chosen frozen broken spoken stolen hidden driven fallen forgotten known shown thrown drawn grown seen\nput cut hit quit split spread cast cost let upset rebuilt resent undone withdrawn`.split(\n /\\s+/,\n ),\n);\n/** definePlugin's parts that run while the plugin installs. */\nconst SETUP_PARTS = [\"app\", \"service\", \"resource\", \"tables\"];\nconst CONNECTION_CLASS = /(Client|Pool|Redis|Connection|Socket)$/;\nconst CONNECTION_CALL = /^(connect|createClient|createPool|createConnection)$/;\nconst isPastTense = (word: string) =>\n word.endsWith(\"ed\") || IRREGULAR_PAST.has(word);\nconst lastWord = (name: string) =>\n (name.match(/[A-Z]?[a-z0-9]+$/)?.[0] ?? name).toLowerCase();\nconst firstWord = (name: string) => name.match(/^[a-z0-9]+/)?.[0] ?? \"\";\nconst ROOM = /^[a-z][a-zA-Z0-9_-]*:./;\n\nexport const checkRules: Record<string, Rule> = {\n \"no-server-in-client\": rule(\n \"Browser code imports only @brickkit/core/client and the generated contract.\",\n (context) => {\n const info = fileInfo(context);\n if (!info.rel.startsWith(`${WEB_DIR}/`)) return {};\n const { generated } = info.settings;\n const check = (node: Node, source: unknown) => {\n if (typeof source !== \"string\") return;\n let allowed: boolean;\n if (source.startsWith(\".\")) {\n const path = resolveImport(info, context, source)!;\n allowed =\n path.startsWith(`${WEB_DIR}/`) ||\n (path.startsWith(`${generated}/`) &&\n !path.endsWith(MANIFEST_STEM) &&\n !path.endsWith(MANIFEST_FILE));\n } else\n allowed =\n !/^(@brickkit\\/|bun:|node:)/.test(source) ||\n source === \"@brickkit/core/client\" ||\n source === \"@brickkit/core/tanstack-query\";\n if (!allowed)\n context.report({\n node,\n message: `Browser code imports only @brickkit/core/client and the generated contract, not \"${source}\".`,\n });\n };\n return {\n ImportDeclaration: (node) => {\n if (node.importKind !== \"type\") check(node.source, node.source.value);\n },\n ExportNamedDeclaration: (node) =>\n node.source && check(node.source, node.source.value),\n ExportAllDeclaration: (node) => check(node.source, node.source.value),\n ImportExpression: (node) =>\n check(node.source, stringValue(node.source)),\n };\n },\n ),\n\n \"no-global-context\": rule(\n \"No module-level mutable singletons for dependencies (the setOrdersContext pattern); use deps.\",\n (context) => {\n if (skip(context)) return {};\n const mutable = new Set<string>();\n const reported = new Set<string>();\n return {\n Program(program: Node) {\n for (let statement of program.body) {\n if (statement.type === \"ExportNamedDeclaration\")\n statement = statement.declaration;\n if (\n statement?.type === \"VariableDeclaration\" &&\n statement.kind !== \"const\"\n )\n for (const declarator of statement.declarations)\n if (declarator.id.type === \"Identifier\")\n mutable.add(declarator.id.name);\n }\n },\n AssignmentExpression(node: Node) {\n const name =\n node.left.type === \"Identifier\" ? node.left.name : undefined;\n if (!name || !mutable.has(name) || reported.has(name)) return;\n if (!enclosingFunction(node)) return;\n reported.add(name);\n context.report({\n node,\n message: `Module-level \"${name}\" is set from a function, a global context. Declare it in the service's deps (port<T>()) and read ctx.deps, or useDeps() in listeners and workflow steps.`,\n });\n },\n };\n },\n ),\n\n \"no-env-outside-secrets\": rule(\n \"process.env and Bun.env are read only through defineSecret or config files.\",\n (context) => {\n const info = fileInfo(context);\n if (\n info.ignored ||\n /(^|\\.)secrets\\.[cm]?[jt]s$/.test(info.base) ||\n /\\.config\\.[cm]?[jt]s$/.test(info.base)\n )\n return {};\n return {\n MemberExpression(node: Node) {\n const object = node.object;\n const property = node.computed ? undefined : node.property.name;\n const env =\n (object.type === \"Identifier\" &&\n (object.name === \"process\" || object.name === \"Bun\") &&\n property === \"env\") ||\n (object.type === \"MetaProperty\" && property === \"env\");\n if (env)\n context.report({\n node,\n message:\n \"Read configuration through defineSecret() in secrets.ts, not from the environment directly.\",\n });\n },\n };\n },\n ),\n\n \"action-schemas\": rule(\n \"Every action, command and tool declares input and output.\",\n (context) => {\n if (skip(context)) return {};\n return {\n CallExpression(node: Node) {\n const definition = definitionOf(node);\n if (!definition || !HANDLERS.includes(definition.kind)) return;\n const missing = [\"input\", \"output\"].filter(\n (key) => !getProperty(definition.config, key),\n );\n if (missing.length)\n context.report({\n node: definition.nameNode ?? node,\n message: `${definition.kind} ${definition.name ? `\"${definition.name}\" ` : \"\"}declares no ${missing.join(\" or \")}.`,\n });\n },\n };\n },\n ),\n\n \"declared-errors\": rule(\n \"Every error.X() names an entry in that action's errors or a built-in error.\",\n (context) => {\n if (skip(context)) return {};\n return {\n CallExpression(node: Node) {\n const name = errorHelper(node);\n if (!name) return;\n const definition = enclosingDefinition(node, HANDLERS);\n if (!definition) return;\n const errors = getProperty(definition.config, \"errors\")?.value;\n const declared = errors ? objectKeys(errors) : [];\n if (declared === undefined) return; // errors built elsewhere: unknown\n if (!BUILT_IN_ERRORS.has(name) && !declared.includes(name))\n context.report({\n node: node.callee.property,\n message: `error.${name} is not in this ${definition.kind}'s errors or the built-in errors.`,\n });\n },\n };\n },\n ),\n\n \"return-error\": rule(\n \"Error helpers are returned (return error.NOT_FOUND()), so TypeScript narrows the value after them.\",\n (context) => {\n if (skip(context)) return {};\n return {\n CallExpression(node: Node) {\n const name = errorHelper(node);\n if (!name || node.parent?.type !== \"ExpressionStatement\") return;\n if (!enclosingDefinition(node, ERROR_KINDS)) return;\n context.report({\n node,\n message: `Return the error: return error.${name}(...).`,\n fix: (fixer) => fixer.insertTextBefore(node, \"return \"),\n });\n },\n };\n },\n { fixable: \"code\" },\n ),\n\n \"path-params-in-input\": rule(\n \"Each :param in path is a field of input.\",\n (context) => {\n if (skip(context)) return {};\n return {\n CallExpression(node: Node) {\n const definition = definitionOf(node);\n if (!definition || !HANDLERS.includes(definition.kind)) return;\n const pathNode = getProperty(definition.config, \"path\")?.value;\n const path = stringValue(pathNode);\n if (!path) return;\n const input = getProperty(definition.config, \"input\")?.value;\n const fields = isSchemaCall(input, \"Object\")\n ? objectKeys(input.arguments[0])\n : input\n ? undefined // a schema built elsewhere: fields unknown\n : [];\n if (!fields) return;\n const record = getProperty(definition.config, \"record\")?.value?.value;\n for (const [, param] of path.matchAll(/:([A-Za-z_$][\\w$]*)/g))\n if (\n !fields.includes(param!) &&\n !(record === true && param === \"id\")\n )\n context.report({\n node: pathNode,\n message: `Path parameter :${param} is not a field of input.`,\n });\n },\n };\n },\n ),\n\n \"get-is-read-only\": rule(\n \"GET actions don't insert, update, delete or emit.\",\n (context) => {\n if (skip(context)) return {};\n return {\n CallExpression(node: Node) {\n const call = memberCall(node);\n if (!call) return;\n // A write on the database or a transaction, not Map.delete and the like.\n const write =\n node.callee.type === \"MemberExpression\" &&\n WRITE_METHODS.has(call.property) &&\n /\\b(db|tx)\\b/.test(context.sourceCode.getText(node.callee.object));\n if (!write && !isEmit(node)) return;\n const definition = enclosingDefinition(node, HANDLERS);\n const method = stringValue(\n getProperty(definition?.config, \"method\")?.value,\n );\n if (method === \"GET\")\n context.report({\n node,\n message: `A GET ${definition!.kind} only reads; ${call.property}() writes. Use POST.`,\n });\n },\n };\n },\n ),\n\n \"emit-in-transaction\": rule(\n \"emitEvent or live.emit inside a transaction callback passes { tx } or { after: tx }.\",\n (context) => {\n if (skip(context)) return {};\n return {\n CallExpression(node: Node) {\n const kind = isEmit(node);\n if (!kind) return;\n let tx: string | undefined;\n let inside = false;\n for (\n let fn = enclosingFunction(node);\n fn;\n fn = enclosingFunction(fn)\n ) {\n const parent = fn.parent;\n if (\n parent?.type === \"CallExpression\" &&\n parent.arguments[0] === fn &&\n memberCall(parent)?.property === \"transaction\"\n ) {\n inside = true;\n if (fn.params[0]?.type === \"Identifier\") tx = fn.params[0].name;\n break;\n }\n }\n if (!inside) return;\n const options = node.arguments[3];\n const keys = objectKeys(options);\n if (\n options &&\n (!keys || keys.includes(\"tx\") || keys.includes(\"after\"))\n )\n return;\n const option = kind === \"emitEvent\" ? \"tx\" : \"after\";\n context.report({\n node,\n message: `Inside a transaction, pass { ${option}: ${tx ?? \"tx\"} } so the ${kind === \"emitEvent\" ? \"event is recorded in it\" : \"message is sent on commit\"}.`,\n fix:\n tx && !options && node.arguments.length === 3\n ? (fixer) =>\n fixer.insertTextAfter(\n node.arguments[2],\n `, { ${option}: ${tx} }`,\n )\n : undefined,\n });\n },\n };\n },\n { fixable: \"code\" },\n ),\n\n \"deterministic-workflow\": rule(\n \"No Date.now, Math.random, fetch or database access in a workflow function outside its steps.\",\n (context) => {\n if (skip(context)) return {};\n const inWorkflow = (node: Node) => {\n for (let fn = enclosingFunction(node); fn; fn = enclosingFunction(fn)) {\n const directives = directivesOf(fn);\n if (directives.includes(\"use step\")) return false;\n if (directives.includes(\"use workflow\")) return true;\n }\n return directivesOf(programOf(node)).includes(\"use workflow\");\n };\n const report = (node: Node, what: string) => {\n if (inWorkflow(node))\n context.report({\n node,\n message: `${what} in a workflow function is not replayed the same way; move it into a step.`,\n });\n };\n return {\n CallExpression(node: Node) {\n const call = memberCall(node);\n if (!call) return;\n if (call.object === \"Date\" && call.property === \"now\")\n report(node, \"Date.now()\");\n else if (call.object === \"Math\" && call.property === \"random\")\n report(node, \"Math.random()\");\n else if (call.object === undefined && call.property === \"fetch\")\n report(node, \"fetch()\");\n },\n NewExpression(node: Node) {\n if (node.callee.name === \"Date\" && node.arguments.length === 0)\n report(node, \"new Date()\");\n },\n MemberExpression(node: Node) {\n if (!node.computed && node.property.name === \"db\")\n report(node, \"Database access\");\n },\n };\n },\n ),\n\n \"idempotent-listener\": rule(\n \"Listener writes are keyed by deliveryId or use onConflictDoNothing, because delivery is at least once.\",\n (context) => {\n if (skip(context)) return {};\n return {\n CallExpression(node: Node) {\n const definition = definitionOf(node);\n if (definition?.kind !== \"listener\") return;\n const text = context.sourceCode.getText(definition.config);\n if (\n WRITE_CALL.test(text) &&\n !/deliveryId|onConflictDo(Nothing|Update)/.test(text)\n )\n context.report({\n node: definition.nameNode ?? node,\n message:\n \"This listener writes without deliveryId or onConflictDoNothing; a redelivered event would write twice.\",\n });\n },\n };\n },\n ),\n\n \"socket-schemas\": rule(\n \"Socket schemas have no format or transforms, and event names don't start with $.\",\n (context) => {\n if (skip(context)) return {};\n return {\n CallExpression(node: Node) {\n const definition = definitionOf(node);\n if (definition?.kind !== \"socket\") return;\n for (const key of [\"input\", \"output\"]) {\n const schemas = getProperty(definition.config, key)?.value;\n if (schemas?.type !== \"ObjectExpression\") continue;\n for (const property of schemas.properties) {\n const name = propertyName(property);\n if (name !== undefined && isControlEvent(name))\n context.report({\n node: property.key,\n message: `Socket ${key} event \"${name}\" starts with $, which is reserved for control messages.`,\n });\n // shortcut: a text search; a schema imported from another file is not checked.\n const text = context.sourceCode.getText(property.value);\n if (/\\bformat\\s*:|\\b(Transform|Decode|Encode)\\s*\\(/.test(text))\n context.report({\n node: property.value,\n message: `Socket ${key} \"${name}\" uses a format or transform, which sockets cannot check.`,\n });\n }\n }\n },\n };\n },\n ),\n\n \"no-unregistered-format\": rule(\n \"A TypeBox format is used only when it is registered with FormatRegistry.\",\n (context) => {\n if (skip(context)) return {};\n const options = (context.options?.[0] ?? {}) as { formats?: string[] };\n const registered = new Set(options.formats ?? []);\n const used: Node[] = [];\n return {\n CallExpression(node: Node) {\n const call = memberCall(node);\n if (call?.object === \"FormatRegistry\" && call.property === \"Set\") {\n const name = stringValue(node.arguments[0]);\n if (name) registered.add(name);\n }\n if (!isSchemaCall(node)) return;\n for (const argument of node.arguments) {\n const format = getProperty(argument, \"format\");\n if (stringValue(format?.value)) used.push(format.value);\n }\n },\n \"Program:exit\"() {\n for (const node of used)\n if (!registered.has(node.value))\n context.report({\n node,\n message: `Format \"${node.value}\" is not registered; call FormatRegistry.Set(\"${node.value}\", ...) or list it in this rule's formats option.`,\n });\n },\n };\n },\n {\n schema: [\n {\n type: \"object\",\n properties: { formats: { type: \"array\", items: { type: \"string\" } } },\n additionalProperties: false,\n },\n ],\n },\n ),\n\n \"no-floating-calls\": rule(\n \"Promises from service calls and emitEvent are awaited.\",\n (context) => {\n if (skip(context)) return {};\n const proxies = new Set<string>();\n const candidates: Node[] = [];\n return {\n VariableDeclarator(node: Node) {\n const call = memberCall(node.init);\n if (node.id.type === \"Identifier\" && call?.property === \"useService\")\n proxies.add(node.id.name);\n },\n ExpressionStatement(node: Node) {\n if (node.expression.type === \"CallExpression\")\n candidates.push(node.expression);\n },\n \"Program:exit\"() {\n for (const call of candidates) {\n const target = memberCall(call);\n const floating =\n (target?.property === \"emitEvent\" && !target.object) ||\n (target?.object !== undefined && proxies.has(target.object));\n if (!floating) continue;\n const async = enclosingFunction(call)?.async === true;\n context.report({\n node: call,\n message: `Await this call (or mark it with void): an unawaited promise loses its errors.`,\n fix: async\n ? (fixer) => fixer.insertTextBefore(call, \"await \")\n : undefined,\n });\n }\n },\n };\n },\n { fixable: \"code\" },\n ),\n\n \"explicit-access\": rule(\n \"Every action and CRUD resource sets access, and record actions and commands set `access`; nothing is public by omission.\",\n (context) => {\n if (skip(context)) return {};\n return {\n CallExpression(node: Node) {\n const definition = definitionOf(node);\n if (!definition) return;\n // Record actions and commands load a row, so they always need access.\n const record =\n definition.kind === \"command\" ||\n (definition.kind === \"action\" &&\n getProperty(definition.config, \"record\")?.value?.value === true);\n if (record && !getProperty(definition.config, \"access\"))\n context.report({\n node: definition.nameNode ?? node,\n message: `Set access on this ${definition.kind === \"command\" ? \"command\" : \"record action\"}: access: { scope } or \"public\"; it decides which rows it can load.`,\n });\n else if (\n definition.kind === \"action\" &&\n !getProperty(definition.config, \"authorize\") &&\n !getProperty(definition.config, \"access\")\n )\n context.report({\n node: definition.nameNode ?? node,\n message: `Set access on this action: authorize, or access: \"public\" when anyone may call it.`,\n });\n if (\n definition.kind === \"crud\" &&\n !getProperty(definition.config, \"access\")\n )\n context.report({\n node,\n message:\n 'Set access on this CRUD resource ({ authorize, scope } or \"public\").',\n });\n },\n };\n },\n ),\n\n \"socket-authorize\": rule(\"Sockets declare authorize and join.\", (context) => {\n if (skip(context)) return {};\n return {\n CallExpression(node: Node) {\n const definition = definitionOf(node);\n if (definition?.kind !== \"socket\") return;\n const missing = [\"authorize\", \"join\"].filter(\n (key) => !getProperty(definition.config, key),\n );\n if (missing.length)\n context.report({\n node: definition.nameNode ?? node,\n message: `Socket declares no ${missing.join(\" or \")}; add ${missing.length > 1 ? \"them\" : \"it\"}.`,\n });\n },\n };\n }),\n\n \"no-wildcard-origins\": rule(\n 'No \"*\" in allowedOrigins or trustedOrigins.',\n (context) => {\n if (skip(context)) return {};\n return {\n Property(node: Node) {\n const name = propertyName(node);\n if (name !== \"allowedOrigins\" && name !== \"trustedOrigins\") return;\n const values =\n node.value.type === \"ArrayExpression\"\n ? node.value.elements\n : [node.value];\n for (const value of values)\n if (stringValue(value) === \"*\")\n context.report({\n node: value,\n message: `\"*\" in ${name} lets any site in; list the origins.`,\n });\n },\n };\n },\n ),\n\n \"strict-input\": rule(\n \"Input objects set additionalProperties: false.\",\n (context) => {\n if (skip(context)) return {};\n return {\n CallExpression(node: Node) {\n const definition = definitionOf(node);\n if (!definition || !HANDLERS.includes(definition.kind)) return;\n const input = getProperty(definition.config, \"input\")?.value;\n if (!isSchemaCall(input, \"Object\")) return;\n const [fields, options] = input.arguments;\n const strict = getProperty(options, \"additionalProperties\")?.value;\n if (strict?.type === \"Literal\" && strict.value === false) return;\n if (options && options.type !== \"ObjectExpression\") return;\n context.report({\n node: input,\n message: \"Set additionalProperties: false on this input object.\",\n fix: strict\n ? undefined\n : !options\n ? (fixer) =>\n fixer.insertTextAfter(\n fields,\n \", { additionalProperties: false }\",\n )\n : options.properties.length === 0\n ? (fixer) =>\n fixer.replaceText(\n options,\n \"{ additionalProperties: false }\",\n )\n : (fixer) =>\n fixer.insertTextAfter(\n options.properties.at(-1),\n \", additionalProperties: false\",\n ),\n });\n },\n };\n },\n { fixable: \"code\" },\n ),\n\n \"description-required\": rule(\n \"Actions, commands, tools, sockets and events have a description, which feeds OpenAPI, MCP and the dashboard.\",\n (context) => {\n if (skip(context)) return {};\n return {\n CallExpression(node: Node) {\n const definition = definitionOf(node);\n if (!definition) return;\n if (\n ENDPOINTS.includes(definition.kind) &&\n !getProperty(definition.config, \"description\")\n )\n context.report({\n node: definition.nameNode ?? node,\n message: `Describe this ${definition.kind}: the description feeds OpenAPI, MCP and the dashboard.`,\n });\n const events =\n definition.kind === \"service\" || definition.kind === \"plugin\"\n ? getProperty(definition.config, \"events\")?.value\n : undefined;\n for (const event of events?.properties ?? []) {\n const schema = event.value;\n if (!isSchemaCall(schema)) continue;\n const described = schema.arguments.some((argument: Node) =>\n getProperty(argument, \"description\"),\n );\n if (!described)\n context.report({\n node: event.key,\n message: `Describe event \"${propertyName(event)}\" with { description } on its schema.`,\n });\n }\n },\n };\n },\n ),\n\n naming: rule(\n \"Actions are camelCase verbs (getUser), events are service.pastTense (orders.shipped), and rooms are prefix:value.\",\n (context) => {\n if (skip(context)) return {};\n const checkRoom = (node: Node) => {\n const text =\n node?.type === \"TemplateLiteral\"\n ? node.quasis[0].value.cooked + (node.expressions.length ? \"x\" : \"\")\n : stringValue(node);\n if (text !== undefined && !ROOM.test(text))\n context.report({\n node,\n message: `Room \"${text}\" should be prefix:value, such as doc:42 or user:7.`,\n });\n };\n return {\n CallExpression(node: Node) {\n const definition = definitionOf(node);\n if (\n (definition?.kind === \"action\" || definition?.kind === \"command\") &&\n definition.name\n ) {\n const name = definition.name;\n if (\n !/^[a-z][a-zA-Z0-9]*$/.test(name) ||\n !VERBS.has(firstWord(name))\n )\n context.report({\n node: definition.nameNode,\n message: `${definition.kind} \"${name}\" should be a camelCase verb, such as getUser or archive.`,\n });\n }\n if (definition?.kind === \"service\") {\n const events = getProperty(definition.config, \"events\")?.value;\n for (const name of objectKeys(events) ?? [])\n if (\n !/^[a-z][a-zA-Z0-9]*$/.test(name) ||\n !isPastTense(lastWord(name))\n )\n context.report({\n node: getProperty(events, name).key,\n message: `Event \"${name}\" should be camelCase past tense, such as shipped or itemAdded.`,\n });\n }\n if (definition?.kind === \"socket\") {\n const rooms = getProperty(definition.config, \"rooms\")?.value;\n const list = isFunction(rooms) ? rooms.body : rooms;\n if (list?.type === \"ArrayExpression\")\n for (const element of list.elements) checkRoom(element);\n }\n const kind = isEmit(node);\n if (kind === \"emitEvent\") {\n const name = stringValue(node.arguments[1]);\n if (\n name !== undefined &&\n (!/^[a-z][a-zA-Z0-9]*\\.[a-z][a-zA-Z0-9]*$/.test(name) ||\n !isPastTense(lastWord(name)))\n )\n context.report({\n node: node.arguments[1],\n message: `Event \"${name}\" should be service.pastTense, such as orders.shipped.`,\n });\n }\n if (kind === \"emit\") {\n const room = node.arguments[0];\n if (room.type === \"ArrayExpression\")\n room.elements.forEach(checkRoom);\n else checkRoom(room);\n }\n },\n };\n },\n ),\n\n \"no-console\": rule(\n \"Handlers log through the request logger, so lines carry the request and trace ids.\",\n (context) => {\n if (skip(context)) return {};\n return {\n CallExpression(node: Node) {\n if (memberCall(node)?.object !== \"console\") return;\n if (!enclosingDefinition(node, CTX_KINDS)) return;\n context.report({\n node,\n message:\n \"Log through ctx.logger, so the line carries the request and trace ids.\",\n });\n },\n };\n },\n ),\n\n \"plugin-manifest\": rule(\n 'definePlugin has a scoped name, a brick range and declared options with descriptions; its setup functions are synchronous and open no connections outside on(\"start\").',\n (context) => {\n if (skip(context)) return {};\n const connection = (node: Node) => {\n const opens =\n node.type === \"NewExpression\"\n ? node.callee.type === \"Identifier\" &&\n CONNECTION_CLASS.test(node.callee.name)\n : CONNECTION_CALL.test(memberCall(node)?.property ?? \"\");\n if (!opens) return;\n // Inside on(\"start\", ...) is the place; inside a setup part is not.\n for (let current = node.parent; current; current = current.parent) {\n const call = memberCall(current);\n if (\n call?.property === \"on\" &&\n stringValue(current.arguments[0]) === \"start\"\n )\n return;\n if (\n current.type === \"Property\" &&\n SETUP_PARTS.includes(propertyName(current) ?? \"\") &&\n definitionOf(current.parent?.parent)?.kind === \"plugin\"\n )\n return context.report({\n node,\n message:\n 'Open connections in on(\"start\") (and close them in on(\"stop\")), not while the plugin installs.',\n });\n }\n };\n return {\n NewExpression: connection,\n CallExpression(node: Node) {\n connection(node);\n const definition = definitionOf(node);\n if (definition?.kind !== \"plugin\") return;\n const config = definition.config;\n if (!definition.name || !/^@[^/\\s]+\\/[^/\\s]+$/.test(definition.name))\n context.report({\n node: definition.nameNode ?? node,\n message:\n 'Give the plugin a scoped package name, such as \"@acme/brick-comments\".',\n });\n if (!stringValue(getProperty(config, \"brick\")?.value))\n context.report({\n node: node.callee,\n message: `Declare the Brick versions this plugin supports: brick: \"${BRICK_RANGE}\".`,\n });\n const options = getProperty(config, \"options\")?.value;\n if (!options)\n context.report({\n node: node.callee,\n message:\n \"Declare the plugin's options as a TypeBox schema (options: t.Object({ ... })).\",\n });\n else if (\n isSchemaCall(options, \"Object\") &&\n options.arguments[0]?.type === \"ObjectExpression\"\n )\n for (const option of options.arguments[0].properties) {\n const schema = option.value;\n const settings = isSchemaCall(schema)\n ? schema.arguments.at(-1)\n : undefined;\n if (!getProperty(settings, \"description\"))\n context.report({\n node: option,\n message: `Describe option \"${propertyName(option) ?? \"?\"}\": add { description: \"...\" } to its schema.`,\n });\n }\n for (const key of [\"setup\", ...SETUP_PARTS]) {\n const setup = getProperty(config, key)?.value;\n if (isFunction(setup) && setup.async)\n context.report({\n node: setup,\n message: `${key} must be synchronous; open connections in on(\"start\").`,\n });\n }\n },\n };\n },\n ),\n};\n","import { readdirSync } from \"node:fs\";\nimport { dirname } from \"node:path\";\nimport { kebabCase } from \"@brickkit/core/client\";\nimport { DEFINITION_FILE } from \"../../definitions\";\nimport {\n defineRule,\n definitionOf,\n fileInfo,\n importSources,\n resolveImport,\n serviceFolders,\n type Definition,\n type Node,\n type Rule,\n} from \"../ast\";\n\nconst rule = (description: string, create: Rule[\"create\"], fixable?: \"code\") =>\n defineRule(\"suggestion\", description, create, { fixable });\n\n/** Collect every definition in the file, then check them once the file is read. */\nfunction onDefinitions(\n check: (definitions: Definition[], program: Node) => void,\n) {\n const definitions: Definition[] = [];\n return {\n CallExpression(node: Node) {\n const definition = definitionOf(node);\n if (definition) definitions.push(definition);\n },\n \"Program:exit\"(program: Node) {\n check(definitions, program);\n },\n };\n}\n\nconst SERVICE_FOLDERS: Partial<Record<string, string>> = {\n action: \"actions\",\n tool: \"tools\",\n socket: \"sockets\",\n listener: \"listeners\",\n workflow: \"workflows\",\n step: \"workflows\",\n table: \"tables\",\n};\n\nexport const layoutRules: Record<string, Rule> = {\n \"one-action-per-file\": rule(\n \"A *.action.ts file defines exactly one action, and actions are defined nowhere else.\",\n (context) => {\n const info = fileInfo(context);\n if (info.exempt) return {};\n return onDefinitions((definitions, program) => {\n const actions = definitions.filter((d) => d.kind === \"action\");\n if (info.kind !== \"action\") {\n for (const action of actions)\n context.report({\n node: action.call,\n message: `Define this action in its own *.action.ts file.`,\n });\n return;\n }\n if (actions.length === 0)\n context.report({\n node: program,\n message: `${info.base} defines no action; a *.action.ts file defines exactly one.`,\n });\n for (const extra of actions.slice(1))\n context.report({\n node: extra.call,\n message: `${info.base} already defines an action; move this one to its own *.action.ts file.`,\n });\n });\n },\n ),\n\n \"file-suffixes\": rule(\n \"Each kind of definition goes in a file with its suffix: .service, .action, .command, .tool, .socket, .listener, .workflow, .step, .resource, .table, .events.\",\n (context) => {\n const info = fileInfo(context);\n if (info.exempt) return {};\n return onDefinitions((definitions) => {\n for (const definition of definitions) {\n const kind = definition.kind;\n // Actions are one-action-per-file's; plugins and crud() have no file of their own.\n if (kind === \"action\" || kind === \"plugin\" || kind === \"crud\")\n continue;\n // A resource file holds its resource's child tables too.\n if (kind === \"table\" && info.kind === \"resource\") continue;\n if (info.kind !== kind)\n context.report({\n node: definition.call,\n message: `Define this ${kind} in a *.${kind}.ts file.`,\n });\n }\n });\n },\n ),\n\n \"kind-folders\": rule(\n \"Files sit in their kind's folder, as in the project structure.\",\n (context) => {\n const info = fileInfo(context);\n if (info.exempt || !info.kind) return {};\n return {\n Program(program: Node) {\n const report = (where: string) =>\n context.report({\n node: program,\n message: `Move ${info.base} to ${where}.`,\n });\n const kind = info.kind!;\n if (!info.inServices || !info.service)\n return report(\n `${info.settings.services}/<service>/, where it is registered`,\n );\n const service = `${info.settings.services}/${info.service}`;\n const rest = info.rest;\n if (kind === \"service\" || kind === \"events\") {\n if (rest.length !== 1) report(`${service}/`);\n return;\n }\n if (rest[0] === \"resources\") {\n const resource = `${service}/resources/${rest[1]}`;\n if ((kind === \"resource\" || kind === \"table\") && rest.length === 3)\n return;\n if (kind === \"action\" && rest.length === 4 && rest[2] === \"actions\")\n return;\n if (\n kind === \"command\" &&\n rest.length === 4 &&\n rest[2] === \"commands\"\n )\n return;\n if (kind === \"resource\" || kind === \"table\")\n return report(`${resource}/`);\n if (kind === \"action\" || kind === \"command\")\n return report(`${resource}/${kind}s/`);\n return report(`${service}/${SERVICE_FOLDERS[kind]}/`);\n }\n if (kind === \"command\" || kind === \"resource\")\n return report(`${service}/resources/<resource>/`);\n const folder = SERVICE_FOLDERS[kind];\n if (rest.length !== 2 || rest[0] !== folder)\n report(`${service}/${folder}/`);\n },\n };\n },\n ),\n\n \"resource-folder\": rule(\n \"Each .resource.ts is alone in resources/<name>/, and resource actions and commands attach to their own folder's resource.\",\n (context) => {\n const info = fileInfo(context);\n if (info.exempt || !info.inServices) return {};\n const inResource = info.rest[0] === \"resources\" && info.rest.length >= 3;\n const folder = inResource ? info.rest[1] : undefined;\n return onDefinitions((definitions, program) => {\n const imports = importSources(program);\n for (const definition of definitions) {\n if (definition.kind === \"resource\" && info.kind === \"resource\") {\n if (!folder || info.rest.length !== 3) continue; // kind-folders reports it\n if (definition.name && kebabCase(definition.name) !== folder)\n context.report({\n node: definition.nameNode,\n message: `Resource \"${definition.name}\" lives in resources/${kebabCase(definition.name)}/, not resources/${folder}/.`,\n });\n const siblings = readdirSync(dirname(context.filename)).filter(\n (file) => DEFINITION_FILE.exec(file)?.[2] === \"resource\",\n );\n if (siblings.length > 1)\n context.report({\n node: definition.call,\n message: `resources/${folder}/ holds ${siblings.length} resources; give each its own folder.`,\n });\n }\n if (\n definition.kind === \"command\" &&\n !(folder && info.rest[2] === \"commands\")\n )\n context.report({\n node: definition.call,\n message:\n \"Commands exist only inside a resource folder: resources/<name>/commands/.\",\n });\n if (\n folder &&\n (definition.kind === \"action\" || definition.kind === \"command\") &&\n definition.owner\n ) {\n const source = imports.get(definition.owner);\n const owner = source\n ?.split(\"/\")\n .pop()\n ?.replace(/\\.[cm]?[jt]sx?$/, \"\");\n if (source && owner !== `${folder}.resource`)\n context.report({\n node: definition.call.callee,\n message: `Files in resources/${folder}/ attach to the ${folder} resource (import it from \"../${folder}.resource\").`,\n });\n }\n }\n });\n },\n ),\n\n \"file-name-matches\": rule(\n \"The file name is the kebab-case of the definition's name, without its owner.\",\n (context) => {\n const info = fileInfo(context);\n if (info.exempt || !info.kind) return {};\n return onDefinitions((definitions) => {\n for (const definition of definitions) {\n if (definition.kind !== info.kind || !definition.name) continue;\n const expected = kebabCase(definition.name.split(\".\").pop()!);\n if (expected !== info.stem)\n context.report({\n node: definition.nameNode,\n message: `\"${definition.name}\" belongs in ${expected}.${info.kind}.ts, not ${info.base}.`,\n });\n }\n });\n },\n ),\n\n \"service-folder\": rule(\n \"One defineService per *.service.ts, inside services/<name>/, where the folder name is the service name.\",\n (context) => {\n const info = fileInfo(context);\n if (info.exempt || info.kind !== \"service\") return {};\n return onDefinitions((definitions, program) => {\n const services = definitions.filter((d) => d.kind === \"service\");\n if (services.length === 0)\n context.report({\n node: program,\n message: `${info.base} has no defineService(); a *.service.ts file defines exactly one.`,\n });\n for (const extra of services.slice(1))\n context.report({\n node: extra.call,\n message: `${info.base} already defines a service; give this one its own folder.`,\n });\n const service = services[0];\n if (!service?.name || !info.inServices) return;\n const folder = info.rest.length === 1 ? info.service : undefined;\n if (!serviceFolders(service.name).includes(folder!))\n context.report({\n node: service.nameNode,\n message: `Service \"${service.name}\" lives in ${info.settings.services}/${kebabCase(service.name)}/${kebabCase(service.name)}.service.ts.`,\n });\n });\n },\n ),\n\n \"colocate-in-service\": rule(\n \"Everything under services/<name>/ attaches to that service, or to one of its resources.\",\n (context) => {\n const info = fileInfo(context);\n if (info.exempt || !info.service) return {};\n return onDefinitions((definitions, program) => {\n const imports = importSources(program);\n for (const definition of definitions) {\n if (!definition.owner) continue;\n const source = imports.get(definition.owner);\n const path = source && resolveImport(info, context, source);\n if (!path?.startsWith(`${info.settings.services}/`)) continue;\n const owner = path\n .slice(info.settings.services.length + 1)\n .split(\"/\")[0];\n if (owner !== info.service)\n context.report({\n node: definition.call.callee,\n message: `This file is in ${info.service}/ but attaches to ${owner}; move it to ${info.settings.services}/${owner}/.`,\n });\n }\n });\n },\n ),\n\n \"workflow-directive\": rule(\n 'Workflow files use \"use workflow\", step files \"use step\", and the directives appear nowhere else.',\n (context) => {\n const info = fileInfo(context);\n if (info.exempt) return {};\n const found: Node[] = [];\n return {\n ExpressionStatement(node: Node) {\n if (\n node.directive === \"use workflow\" ||\n node.directive === \"use step\"\n )\n found.push(node);\n },\n \"Program:exit\"(program: Node) {\n const own =\n info.kind === \"workflow\"\n ? \"use workflow\"\n : info.kind === \"step\"\n ? \"use step\"\n : undefined;\n for (const node of found)\n if (node.directive !== own)\n context.report({\n node,\n message: `\"${node.directive}\" belongs in a *.${node.directive === \"use step\" ? \"step\" : \"workflow\"}.ts file.`,\n });\n if (own && !found.some((node) => node.directive === own))\n context.report({\n node: program,\n message: `${info.base} must start with \"${own}\".`,\n fix: (fixer) =>\n fixer.insertTextBeforeRange([0, 0], `\"${own}\";\\n\\n`),\n });\n },\n };\n },\n \"code\",\n ),\n};\n","import { checkRules } from \"./rules/checks\";\nimport { layoutRules } from \"./rules/layout\";\nimport type { LintPreset, LintSeverity } from \"../config\";\n\nexport type Severity = LintSeverity;\nexport type PresetName = LintPreset;\n\n/** Rules that check one file at a time, in ESLint, oxlint or brick lint. */\nexport const rules = { ...layoutRules, ...checkRules };\n\n/** Rules that need the loaded app; only `brick lint` runs them. */\nexport const APP_RULES = [\n \"single-app-entry\",\n \"no-cross-service-tables\",\n \"unique-names\",\n \"declared-events\",\n \"test-colocated\",\n] as const;\n\n/** Always an error: no preset or rule setting turns it down. */\nexport const ALWAYS_ERROR = \"no-cross-service-tables\";\n\nconst RECOMMENDED: Record<string, Severity> = {\n \"workflow-directive\": \"error\",\n \"no-cross-service-tables\": \"error\",\n \"unique-names\": \"error\",\n \"no-server-in-client\": \"error\",\n \"action-schemas\": \"error\",\n \"declared-errors\": \"error\",\n \"return-error\": \"error\",\n \"path-params-in-input\": \"error\",\n \"get-is-read-only\": \"error\",\n \"emit-in-transaction\": \"error\",\n \"declared-events\": \"error\",\n \"deterministic-workflow\": \"error\",\n \"idempotent-listener\": \"warn\",\n \"socket-schemas\": \"error\",\n \"no-unregistered-format\": \"error\",\n \"no-floating-calls\": \"error\",\n \"explicit-access\": \"error\",\n \"socket-authorize\": \"error\",\n \"no-wildcard-origins\": \"error\",\n};\n\n/** Every preset, with app rules, by bare rule name. */\nexport const PRESETS: Record<PresetName, Record<string, Severity>> = {\n recommended: RECOMMENDED,\n layout: {\n \"one-action-per-file\": \"error\",\n \"file-suffixes\": \"error\",\n \"kind-folders\": \"error\",\n \"resource-folder\": \"error\",\n \"file-name-matches\": \"error\",\n \"service-folder\": \"error\",\n \"colocate-in-service\": \"error\",\n \"single-app-entry\": \"error\",\n },\n strict: {\n ...RECOMMENDED,\n \"no-global-context\": \"error\",\n \"no-env-outside-secrets\": \"error\",\n \"strict-input\": \"error\",\n \"description-required\": \"error\",\n naming: \"error\",\n \"no-console\": \"error\",\n \"test-colocated\": \"error\",\n },\n plugin: {\n \"plugin-manifest\": \"error\",\n \"explicit-access\": \"error\",\n \"description-required\": \"error\",\n },\n};\n\nconst KNOWN = new Set<string>([...Object.keys(rules), ...APP_RULES]);\n\n/**\n * Severity of every rule, keyed `brick/<rule>`, from presets then per-rule\n * settings. Throws on an unknown rule, or on turning down no-cross-service-tables.\n */\nexport function resolveRules(\n presets: PresetName[] = [\"recommended\"],\n overrides: Record<string, Severity> = {},\n): Record<string, Severity> {\n const resolved: Record<string, Severity> = {};\n for (const preset of presets) {\n if (!PRESETS[preset]) throw new Error(`Brick: unknown preset \"${preset}\"`);\n for (const [name, severity] of Object.entries(PRESETS[preset]))\n resolved[`brick/${name}`] = severity;\n }\n for (const [key, severity] of Object.entries(overrides)) {\n const name = key.replace(/^brick\\//, \"\");\n if (!KNOWN.has(name)) throw new Error(`Brick: unknown rule \"${key}\"`);\n if (name === ALWAYS_ERROR && severity !== \"error\")\n throw new Error(\n `Brick: brick/${ALWAYS_ERROR} is always an error and cannot be turned off`,\n );\n resolved[`brick/${name}`] = severity;\n }\n resolved[`brick/${ALWAYS_ERROR}`] = \"error\";\n return resolved;\n}\n\n/** The file rules of a resolved rule set, as ESLint and oxlint take them. */\nexport function fileRules(\n resolved: Record<string, Severity>,\n): Record<string, Severity> {\n return Object.fromEntries(\n Object.entries(resolved).filter(\n ([key]) => key.replace(/^brick\\//, \"\") in rules,\n ),\n );\n}\n","import { relative, sep } from \"node:path\";\nimport type { BrickSettings } from \"./ast\";\nimport { ConfigError, type LoadedConfig } from \"../config\";\nimport { fileRules, resolveRules, type Severity } from \"./presets\";\n\n/** Rules, settings and ignores of a project, shared by brick lint and both linters. */\nexport function projectRules(project: LoadedConfig) {\n const lint = project.config.lint ?? {};\n let resolved: Record<string, Severity>;\n try {\n resolved = resolveRules(lint.presets, lint.rules);\n } catch (error) {\n throw new ConfigError(\n `brick.config.ts: lint.rules: ${(error as Error).message}`,\n );\n }\n const from = (path: string) =>\n relative(project.root, path).split(sep).join(\"/\") || \".\";\n const settings: BrickSettings = {\n root: project.root,\n services: from(project.services),\n entry: from(project.entry),\n generated: from(project.generated),\n };\n return {\n resolved,\n rules: fileRules(resolved),\n settings,\n ignore: [...(lint.ignore ?? []), `${settings.generated}/**`],\n };\n}\n"],"mappings":";;;;;;AA8CA,SAAgB,WACd,MACA,aACA,QACA,UAAoD,CAAC,GAC/C;CACN,OAAO;EACL,MAAM;GACJ;GACA,MAAM,EAAE,YAAY;GACpB,SAAS,QAAQ;GACjB,QAAQ,QAAQ,UAAU,CAAC;EAC7B;EACA;CACF;AACF;AAaA,MAAMA,WAAS,SAAiB,KAAK,MAAM,GAAG,CAAC,CAAC,KAAK,GAAG;;AAGxD,SAAgB,cAAc,SAAqC;CACjE,MAAM,QAAQ,QAAQ,UAAU,SAAS,CAAC;CAC1C,MAAM,OAAO,MAAM,QAAQ,QAAQ,OAAO,QAAQ,IAAI;CACtD,MAAM,QAAQ,SAAiBA,QAAM,SAAS,MAAM,QAAQ,MAAM,IAAI,CAAC,CAAC;CACxE,OAAO;EACL;EACA,UAAU,KAAK,MAAM,YAAY,iBAAiB,QAAQ;EAC1D,OAAO,KAAK,MAAM,SAAS,iBAAiB,KAAK;EACjD,WAAW,KAAK,MAAM,aAAa,iBAAiB,SAAS;CAC/D;AACF;;AAGA,MAAa,kBAAkB,SAAiB,CAAC,UAAU,IAAI,GAAG,IAAI;AAoBtE,SAAgB,SAAS,SAAgC;CACvD,MAAM,WAAW,cAAc,OAAO;CACtC,MAAM,MAAMA,QAAM,SAAS,SAAS,MAAM,QAAQ,QAAQ,CAAC;CAC3D,MAAM,EAAE,UAAU,aAAa,cAAc;CAC7C,MAAM,OAAO,SAAS,GAAG;CACzB,MAAM,aAAa,IAAI,WAAW,GAAG,YAAY,EAAE;CACnD,MAAM,QAAQ,aAAa,IAAI,MAAM,YAAY,SAAS,CAAC,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC;CAC3E,MA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A,QAAQ,CAAC,GAAI,KAAK,UAAU,CAAC,GAAI,GAAG,SAAS,UAAU,IAAI;CAC7D;AACF"}
@@ -0,0 +1,24 @@
1
+ import { t as DashboardExtensionOptions } from "./dashboard-extension.js";
2
+ import { t as ProductionDashboard } from "./production-dashboard2.js";
3
+ import { BrickApp } from "@brickkit/core";
4
+ /**
5
+ * Serve an app: the monitoring dashboard it asks for with `brick({ dashboard })`
6
+ * (unless `dashboard` is false), then the app itself. What `brick dev`'s
7
+ * worker, `brick start` and a built server run.
8
+ */
9
+ export declare function serveApp(app: BrickApp, options: {
10
+ port: number;
11
+ dashboard?: DashboardExtensionOptions | false;
12
+ }): Promise<ProductionDashboard | undefined>;
13
+ /**
14
+ * Shut the app down at SIGINT or SIGTERM, finishing the deliveries in flight,
15
+ * then exit. A second signal exits at once, for a delivery that never finishes.
16
+ */
17
+ export declare function shutdownOnSignal(app: Pick<BrickApp, "shutdown">): void;
18
+ /** The startup lines: each service's routes as mounted, then where to reach the app. */
19
+ export declare function printBanner(app: BrickApp, options: {
20
+ label: string;
21
+ port: number;
22
+ dashboard?: Pick<ProductionDashboard, "host" | "port">;
23
+ }): void;
24
+ //# sourceMappingURL=serve.d.ts.map
package/dist/serve.js ADDED
@@ -0,0 +1 @@
1
+ export { t as printBanner, n as serveApp, r as shutdownOnSignal } from "./serve2.js";
package/dist/serve2.js ADDED
@@ -0,0 +1,49 @@
1
+ // src/serve.ts
2
+ /**
3
+ * Serve an app: the monitoring dashboard it asks for with `brick({ dashboard })`
4
+ * (unless `dashboard` is false), then the app itself. What `brick dev`'s
5
+ * worker, `brick start` and a built server run.
6
+ */
7
+ async function serveApp(app, options) {
8
+ const dashboard = app.definition.dashboard && options.dashboard !== false ? await (await import("./production-dashboard.js")).startProductionDashboard(app, {
9
+ appPort: options.port,
10
+ dashboard: options.dashboard
11
+ }) : void 0;
12
+ await app.serve({ port: options.port });
13
+ return dashboard;
14
+ }
15
+ /**
16
+ * Shut the app down at SIGINT or SIGTERM, finishing the deliveries in flight,
17
+ * then exit. A second signal exits at once, for a delivery that never finishes.
18
+ */
19
+ function shutdownOnSignal(app) {
20
+ let stopping = false;
21
+ const stop = (signal) => {
22
+ if (stopping) return process.exit(signal === "SIGINT" ? 130 : 143);
23
+ stopping = true;
24
+ app.shutdown().finally(() => process.exit(0));
25
+ };
26
+ for (const signal of ["SIGINT", "SIGTERM"]) process.on(signal, stop);
27
+ }
28
+ /** The startup lines: each service's routes as mounted, then where to reach the app. */
29
+ function printBanner(app, options) {
30
+ const { services, routes } = app.definition;
31
+ console.log(`\n🧱 Brick-TS ${options.label} Server`);
32
+ console.log(` Registered Services: ${services.length}`);
33
+ for (const svc of services) {
34
+ console.log(` • ${svc.name} (${svc.listActions().length} actions)`);
35
+ for (const route of routes) if (route.service === svc.name) console.log(` -> ${route.method.padEnd(6)} ${route.path}`);
36
+ }
37
+ const base = `http://localhost:${options.port}`;
38
+ console.log(`\n⚡ API Gateway running on: ${base}`);
39
+ console.log(`🩺 Health check: ${base}/_health`);
40
+ const dashboard = options.dashboard;
41
+ if (dashboard) {
42
+ const shown = dashboard.host === "0.0.0.0" || dashboard.host === "::" ? "localhost" : dashboard.host.includes(":") ? `[${dashboard.host.replace(/^\[|\]$/g, "")}]` : dashboard.host;
43
+ console.log(`📊 Dashboard: http://${shown}:${dashboard.port} (health: /_health)`);
44
+ }
45
+ console.log(`🗺️ Architecture graph: ${base}/_brick/services\n`);
46
+ }
47
+ export { serveApp as n, shutdownOnSignal as r, printBanner as t };
48
+
49
+ //# sourceMappingURL=serve2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serve2.js","names":[],"sources":["../src/serve.ts"],"sourcesContent":["import type { BrickApp } from \"@brickkit/core\";\nimport type { DashboardExtensionOptions } from \"./dashboard-extension\";\nimport type { ProductionDashboard } from \"./production-dashboard\";\n\n/**\n * Serve an app: the monitoring dashboard it asks for with `brick({ dashboard })`\n * (unless `dashboard` is false), then the app itself. What `brick dev`'s\n * worker, `brick start` and a built server run.\n */\nexport async function serveApp(\n app: BrickApp,\n options: { port: number; dashboard?: DashboardExtensionOptions | false },\n): Promise<ProductionDashboard | undefined> {\n // Before listening, so the first request is already traced and its logs kept.\n // Loaded only when asked for: a built server bundles this file, and resolves\n // the dashboard from @brickkit/cli at run time (see build.ts).\n const dashboard =\n app.definition.dashboard && options.dashboard !== false\n ? await (\n await import(\"./production-dashboard\")\n ).startProductionDashboard(app, {\n appPort: options.port,\n dashboard: options.dashboard,\n })\n : undefined;\n await app.serve({ port: options.port });\n return dashboard;\n}\n\n/**\n * Shut the app down at SIGINT or SIGTERM, finishing the deliveries in flight,\n * then exit. A second signal exits at once, for a delivery that never finishes.\n */\nexport function shutdownOnSignal(app: Pick<BrickApp, \"shutdown\">) {\n let stopping = false;\n const stop = (signal: NodeJS.Signals) => {\n if (stopping) return process.exit(signal === \"SIGINT\" ? 130 : 143);\n stopping = true;\n void app.shutdown().finally(() => process.exit(0));\n };\n // `on`, not `once`: the workflow bundle loads signal-exit, which re-raises the\n // signal itself when it finds no listener left, and `once` removes ours first.\n for (const signal of [\"SIGINT\", \"SIGTERM\"] as const) process.on(signal, stop);\n}\n\n/** The startup lines: each service's routes as mounted, then where to reach the app. */\nexport function printBanner(\n app: BrickApp,\n options: {\n label: string;\n port: number;\n dashboard?: Pick<ProductionDashboard, \"host\" | \"port\">;\n },\n) {\n const { services, routes } = app.definition;\n console.log(`\\n🧱 Brick-TS ${options.label} Server`);\n console.log(` Registered Services: ${services.length}`);\n for (const svc of services) {\n console.log(` • ${svc.name} (${svc.listActions().length} actions)`);\n for (const route of routes)\n if (route.service === svc.name)\n console.log(` -> ${route.method.padEnd(6)} ${route.path}`);\n }\n const base = `http://localhost:${options.port}`;\n console.log(`\\n⚡ API Gateway running on: ${base}`);\n console.log(`🩺 Health check: ${base}/_health`);\n const dashboard = options.dashboard;\n if (dashboard) {\n const shown =\n dashboard.host === \"0.0.0.0\" || dashboard.host === \"::\"\n ? \"localhost\"\n : dashboard.host.includes(\":\")\n ? `[${dashboard.host.replace(/^\\[|\\]$/g, \"\")}]`\n : dashboard.host;\n console.log(\n `📊 Dashboard: http://${shown}:${dashboard.port} (health: /_health)`,\n );\n }\n console.log(`🗺️ Architecture graph: ${base}/_brick/services\\n`);\n}\n"],"mappings":";;;;;;AASA,eAAsB,SACpB,KACA,SAC0C;CAI1C,MAAM,YACJ,IAAI,WAAW,aAAa,QAAQ,cAAc,QAC9C,OACE,MAAM,OAAO,6BAAA,CACb,yBAAyB,KAAK;EAC9B,SAAS,QAAQ;EACjB,WAAW,QAAQ;CACrB,CAAC,IACD,KAAA;CACN,MAAM,IAAI,MAAM,EAAE,MAAM,QAAQ,KAAK,CAAC;CACtC,OAAO;AACT;;;;;AAMA,SAAgB,iBAAiB,KAAiC;CAChE,IAAI,WAAW;CACf,MAAM,QAAQ,WAA2B;EACvC,IAAI,UAAU,OAAO,QAAQ,KAAK,WAAW,WAAW,MAAM,GAAG;EACjE,WAAW;EACX,IAAS,SAAS,CAAC,CAAC,cAAc,QAAQ,KAAK,CAAC,CAAC;CACnD;CAGA,KAAK,MAAM,UAAU,CAAC,UAAU,SAAS,GAAY,QAAQ,GAAG,QAAQ,IAAI;AAC9E;;AAGA,SAAgB,YACd,KACA,SAKA;CACA,MAAM,EAAE,UAAU,WAAW,IAAI;CACjC,QAAQ,IAAI,iBAAiB,QAAQ,MAAM,QAAQ;CACnD,QAAQ,IAAI,2BAA2B,SAAS,QAAQ;CACxD,KAAK,MAAM,OAAO,UAAU;EAC1B,QAAQ,IAAI,QAAQ,IAAI,KAAK,IAAI,IAAI,YAAY,CAAC,CAAC,OAAO,UAAU;EACpE,KAAK,MAAM,SAAS,QAClB,IAAI,MAAM,YAAY,IAAI,MACxB,QAAQ,IAAI,WAAW,MAAM,OAAO,OAAO,CAAC,EAAE,GAAG,MAAM,MAAM;CACnE;CACA,MAAM,OAAO,oBAAoB,QAAQ;CACzC,QAAQ,IAAI,+BAA+B,MAAM;CACjD,QAAQ,IAAI,2BAA2B,KAAK,SAAS;CACrD,MAAM,YAAY,QAAQ;CAC1B,IAAI,WAAW;EACb,MAAM,QACJ,UAAU,SAAS,aAAa,UAAU,SAAS,OAC/C,cACA,UAAU,KAAK,SAAS,GAAG,IACzB,IAAI,UAAU,KAAK,QAAQ,YAAY,EAAE,EAAE,KAC3C,UAAU;EAClB,QAAQ,IACN,kCAAkC,MAAM,GAAG,UAAU,KAAK,oBAC5D;CACF;CACA,QAAQ,IAAI,4BAA4B,KAAK,mBAAmB;AAClE"}
package/dist/vite.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { n as DashboardTheme, t as DashboardExtensionOptions } from "./dashboard-extension.js";
2
2
  import { Plugin } from "vite";
3
- //#region src/vite.d.ts
4
3
  export interface BrickClientPluginOptions {
5
4
  /** Any module whose default export is a BrickApp; do not call listen() there. */
6
5
  entry: string;
@@ -21,6 +20,5 @@ export interface BrickClientPluginOptions {
21
20
  }
22
21
  /** Load a BrickApp through Vite's server module graph, including dependency HMR. */
23
22
  export declare function brickClient(options: BrickClientPluginOptions): Plugin;
24
- //#endregion
25
23
  export type { DashboardTheme };
26
24
  //# sourceMappingURL=vite.d.ts.map
package/dist/vite.js CHANGED
@@ -1,41 +1,30 @@
1
- import { c as openHistory, i as themeCss, o as DocsHost, r as startDevDashboard, t as DevTelemetryStore } from "./dev-telemetry-store.js";
2
- import { t as generateClientContract } from "./client-contract2.js";
3
- import { n as requireBrickApp } from "./app-entry2.js";
4
- import { n as writeContractSource } from "./client-contract-file2.js";
5
- import { getGlobalRegistry } from "@brickkit/core";
6
- import { fileURLToPath } from "node:url";
7
- import { dirname, resolve } from "node:path";
1
+ import { n as writeAppContract } from "./client-contract-file.js";
2
+ import { s as PROJECT_DEFAULTS } from "./config2.js";
3
+ import { t as ownModule } from "./own-module.js";
4
+ import { t as openDashboard } from "./dashboard-host.js";
5
+ import { s as ROUTES } from "./dashboard-protocol.js";
6
+ import { dirname, join, resolve } from "node:path";
7
+ import { getGlobalRegistry, requireBrickApp } from "@brickkit/core";
8
8
  import { createServer, isRunnableDevEnvironment, normalizePath } from "vite";
9
9
  import { ModuleRunner } from "vite/module-runner";
10
- //#region src/dev-vite-dashboard.ts
10
+ // src/dev-vite-dashboard.ts
11
11
  /**
12
12
  * Serve the dashboard from inside the Vite dev server. Dev servers run the app
13
13
  * in a worker, which reports its spans here over HTTP. This process keeps the
14
14
  * history, so it survives worker restarts.
15
15
  */
16
16
  async function startViteDashboard(options) {
17
- const history = await openHistory({
17
+ const dashboard = await openDashboard({
18
+ port: options.port,
18
19
  directory: options.directory,
19
- days: options.historyDays ?? 90,
20
- warn: (message) => options.logger.warn(message)
20
+ historyDays: options.historyDays,
21
+ warn: (message) => options.logger.warn(message),
22
+ docs: true,
23
+ dashboard: options.dashboard,
24
+ portHint: "Set dashboard.port in brickClient() to another, or dashboard: false."
21
25
  });
22
- const store = new DevTelemetryStore({ history });
23
- const docs = new DocsHost(store, (message) => options.logger.warn(message));
24
- let dashboard;
25
- try {
26
- dashboard = await startDevDashboard({
27
- port: options.port ?? 9400,
28
- store,
29
- history,
30
- docs: () => docs.current,
31
- dashboard: options.dashboard
32
- });
33
- } catch (error) {
34
- history?.close();
35
- const reason = error instanceof Error ? error.message : String(error);
36
- options.logger.warn(`[Brick-TS] ${reason} Continuing without the dashboard.`);
37
- return;
38
- }
26
+ if (!dashboard) return void 0;
27
+ const { store, docs } = dashboard;
39
28
  options.logger.info(` ➜ Brick dashboard: http://127.0.0.1:${dashboard.port}`);
40
29
  let stopped = false;
41
30
  let origin;
@@ -45,10 +34,10 @@ async function startViteDashboard(options) {
45
34
  if (documents) store.setApiDocuments(documents, origin);
46
35
  };
47
36
  return {
48
- ingestUrl: `http://127.0.0.1:${dashboard.port}/api/ingest`,
37
+ ingestUrl: `http://127.0.0.1:${dashboard.port}${ROUTES.ingest.path}`,
49
38
  architecture(app) {
50
39
  store.setArchitecture(getGlobalRegistry().exportArchitecture(app.definition), store.latestGeneration);
51
- docs.configure(dirname(options.entry), app.definition.documentation);
40
+ docs?.configure(dirname(options.entry), app.definition.documentation);
52
41
  const load = ++loads;
53
42
  app.referenceDocuments().then((loaded) => {
54
43
  if (load !== loads || stopped) return;
@@ -64,20 +53,17 @@ async function startViteDashboard(options) {
64
53
  if (stopped) return;
65
54
  stopped = true;
66
55
  dashboard.stop();
67
- docs.close();
68
- history?.close();
69
56
  }
70
57
  };
71
58
  }
72
- //#endregion
73
- //#region src/vite.ts
59
+ // src/vite.ts
74
60
  /** Load a BrickApp through Vite's server module graph, including dependency HMR. */
75
61
  function brickClient(options) {
76
62
  const virtualId = "virtual:brick-app";
77
63
  const resolvedId = "\0" + virtualId;
78
64
  const reporterId = "virtual:brick-dev-reporter";
79
65
  const resolvedReporterId = "\0" + reporterId;
80
- const reporterModule = fileURLToPath(new URL(import.meta.url.endsWith(".ts") ? "./dev-reporter.ts" : "./dev-reporter.js", import.meta.url));
66
+ const reporterModule = ownModule("dev-reporter");
81
67
  let entry;
82
68
  let output;
83
69
  let config;
@@ -88,10 +74,6 @@ function brickClient(options) {
88
74
  const dependencies = /* @__PURE__ */ new Set();
89
75
  let revision = 0;
90
76
  const changedFiles = /* @__PURE__ */ new Set();
91
- async function writeContract(value) {
92
- const source = generateClientContract(requireBrickApp(value));
93
- await writeContractSource(output, source);
94
- }
95
77
  function collectDependencies(node, seen = /* @__PURE__ */ new Set()) {
96
78
  if (!node || seen.has(node)) return;
97
79
  seen.add(node);
@@ -104,9 +86,7 @@ function brickClient(options) {
104
86
  configResolved(resolved) {
105
87
  config = resolved;
106
88
  entry = normalizePath(resolve(config.root, options.entry));
107
- output = normalizePath(resolve(config.root, options.output ?? "_brick/contract.ts"));
108
- if (entry === output) throw new Error("Brick: contract output must not overwrite the app entry.");
109
- if (options.dashboard) themeCss(options.dashboard.theme);
89
+ output = normalizePath(resolve(config.root, options.output ?? join(PROJECT_DEFAULTS.generated, "contract.ts")));
110
90
  },
111
91
  async configureServer(server) {
112
92
  const environment = server.environments.ssr;
@@ -138,7 +118,7 @@ function brickClient(options) {
138
118
  });
139
119
  }
140
120
  const app = (await runner.import(entry)).default;
141
- await writeContract(app);
121
+ await writeAppContract(app, entry, output);
142
122
  dashboard?.architecture(requireBrickApp(app));
143
123
  dependencies.clear();
144
124
  collectDependencies(environment.moduleGraph.getModuleById(entry));
@@ -170,7 +150,7 @@ function brickClient(options) {
170
150
  invalidate(entry);
171
151
  try {
172
152
  const app = (await currentRunner.import(entry)).default;
173
- await writeContract(app);
153
+ await writeAppContract(app, entry, output);
174
154
  dashboard?.architecture(requireBrickApp(app));
175
155
  } finally {
176
156
  collectDependencies(this.environment.moduleGraph.getModuleById(entry));
@@ -206,7 +186,7 @@ function brickClient(options) {
206
186
  try {
207
187
  const environment = loader.environments.ssr;
208
188
  if (!environment || !isRunnableDevEnvironment(environment)) throw new Error("Brick: missing build-time SSR loader.");
209
- await writeContract((await environment.runner.import(entry)).default);
189
+ await writeAppContract((await environment.runner.import(entry)).default, entry, output);
210
190
  } finally {
211
191
  await loader.close();
212
192
  }
@@ -226,16 +206,13 @@ installDevReporter({ url: ${JSON.stringify(dashboard.ingestUrl)} });
226
206
  `;
227
207
  }
228
208
  if (id !== resolvedId) return;
229
- return `${dashboard ? `import ${JSON.stringify(reporterId)};\n` : ""}import app from ${JSON.stringify(entry)};
230
- if (!app || typeof app.fetch !== "function" || typeof app.endpoint !== "function") {
231
- throw new Error("Brick: the entry module must default-export a BrickApp created by brick().");
232
- }
233
- export default app;
209
+ return `${dashboard ? `import ${JSON.stringify(reporterId)};\n` : ""}import { requireBrickApp } from "@brickkit/core";
210
+ import app from ${JSON.stringify(entry)};
211
+ export default requireBrickApp(app);
234
212
  `;
235
213
  }
236
214
  };
237
215
  }
238
- //#endregion
239
216
  export { brickClient };
240
217
 
241
218
  //# sourceMappingURL=vite.js.map
package/dist/vite.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"vite.js","names":[],"sources":["../src/dev-vite-dashboard.ts","../src/vite.ts"],"sourcesContent":["import { dirname } from \"node:path\";\nimport {\n getGlobalRegistry,\n type ApiDocument,\n type BrickApp,\n} from \"@brickkit/core\";\nimport {\n DEFAULT_DASHBOARD_PORT,\n startDevDashboard,\n type DevDashboard,\n} from \"./dev-dashboard\";\nimport { DocsHost } from \"./dev-docs\";\nimport type { DashboardExtensionOptions } from \"./dashboard-extension\";\nimport { DEFAULT_HISTORY_DAYS, openHistory } from \"./dev-history\";\nimport { DevTelemetryStore } from \"./dev-telemetry-store\";\n\nexport interface DashboardLogger {\n info(message: string): void;\n warn(message: string): void;\n}\n\nexport interface ViteDashboard {\n /** Where the app reports its spans; see installDevReporter. */\n readonly ingestUrl: string;\n /** Record the architecture of the application module Vite loaded. */\n architecture(app: BrickApp): void;\n /** Where the dev server is reachable, once it is listening. */\n origin(url: string): void;\n stop(): void;\n}\n\n/**\n * Serve the dashboard from inside the Vite dev server. Dev servers run the app\n * in a worker, which reports its spans here over HTTP. This process keeps the\n * history, so it survives worker restarts.\n */\nexport async function startViteDashboard(options: {\n port?: number;\n /** The project folder; history is kept in `.brick/` inside it. */\n directory: string;\n /** The app entry module; the paths in `documentation` start at its folder. */\n entry: string;\n /** Days of requests to keep on disk; zero for none. */\n historyDays?: number;\n /** The extension (an absolute path) and theme. */\n dashboard?: DashboardExtensionOptions;\n logger: DashboardLogger;\n}): Promise<ViteDashboard | undefined> {\n const history = await openHistory({\n directory: options.directory,\n days: options.historyDays ?? DEFAULT_HISTORY_DAYS,\n warn: (message) => options.logger.warn(message),\n });\n const store = new DevTelemetryStore({ history });\n const docs = new DocsHost(store, (message) => options.logger.warn(message));\n let dashboard: DevDashboard;\n try {\n dashboard = await startDevDashboard({\n port: options.port ?? DEFAULT_DASHBOARD_PORT,\n store,\n history,\n docs: () => docs.current,\n dashboard: options.dashboard,\n });\n } catch (error) {\n history?.close();\n const reason = error instanceof Error ? error.message : String(error);\n options.logger.warn(\n `[Brick-TS] ${reason} Continuing without the dashboard.`,\n );\n return undefined;\n }\n options.logger.info(\n ` ➜ Brick dashboard: http://127.0.0.1:${dashboard.port}`,\n );\n\n let stopped = false;\n let origin: string | undefined;\n let documents: ApiDocument[] | undefined;\n let loads = 0;\n // The server starts listening after the app first loads, so the documents\n // are published again once its address is known.\n const publishDocuments = () => {\n if (documents) store.setApiDocuments(documents, origin);\n };\n return {\n ingestUrl: `http://127.0.0.1:${dashboard.port}/api/ingest`,\n architecture(app) {\n store.setArchitecture(\n getGlobalRegistry().exportArchitecture(app.definition),\n store.latestGeneration,\n );\n void docs.configure(dirname(options.entry), app.definition.documentation);\n // A later load supersedes this one if it finishes first.\n const load = ++loads;\n app.referenceDocuments().then(\n (loaded) => {\n if (load !== loads || stopped) return;\n documents = loaded;\n publishDocuments();\n },\n (error: unknown) =>\n options.logger.warn(\n `[Brick-TS] Could not load the API documents: ${error instanceof Error ? error.message : String(error)}`,\n ),\n );\n },\n origin(url) {\n origin = url;\n publishDocuments();\n },\n stop() {\n if (stopped) return;\n stopped = true;\n dashboard.stop();\n docs.close();\n history?.close();\n },\n };\n}\n","import { resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { writeContractSource } from \"./client-contract-file\";\nimport {\n createServer,\n isRunnableDevEnvironment,\n normalizePath,\n type Plugin,\n type ResolvedConfig,\n type EnvironmentModuleNode,\n} from \"vite\";\nimport { generateClientContract } from \"./client-contract\";\nimport { requireBrickApp } from \"./app-entry\";\nimport { startViteDashboard, type ViteDashboard } from \"./dev-vite-dashboard\";\nimport {\n themeCss,\n type DashboardExtensionOptions,\n type DashboardTheme,\n} from \"./dashboard-extension\";\n\nexport type { DashboardTheme };\nimport { ModuleRunner } from \"vite/module-runner\";\n\nexport interface BrickClientPluginOptions {\n /** Any module whose default export is a BrickApp; do not call listen() there. */\n entry: string;\n /** Generated browser contract, relative to the Vite root (default _brick/contract.ts). */\n output?: string;\n /**\n * Local dashboard for the app's requests, traces, errors, and reloads, served\n * during `vite dev` (default: on at port 9400). Apps must pass\n * `telemetry: true` to brick() to record requests. `historyDays` is how long\n * finished requests are kept in `.brick/` (default 90, 0 for none). Set to\n * false to disable. `extension` (relative to the Vite root) and `theme`\n * customise it, as in `brick dev`.\n */\n dashboard?:\n | ({ port?: number; historyDays?: number } & DashboardExtensionOptions)\n | false;\n}\n\n/** Load a BrickApp through Vite's server module graph, including dependency HMR. */\nexport function brickClient(options: BrickClientPluginOptions): Plugin {\n const virtualId = \"virtual:brick-app\";\n const resolvedId = \"\\0\" + virtualId;\n const reporterId = \"virtual:brick-dev-reporter\";\n const resolvedReporterId = \"\\0\" + reporterId;\n // Imported by file path: the package name may not resolve from the app's root.\n const reporterModule = fileURLToPath(\n new URL(\n import.meta.url.endsWith(\".ts\")\n ? \"./dev-reporter.ts\"\n : \"./dev-reporter.js\",\n import.meta.url,\n ),\n );\n let entry: string;\n let output: string;\n let config: ResolvedConfig;\n let buildGeneration: Promise<void> | undefined;\n let runner: ModuleRunner | undefined;\n let dashboard: ViteDashboard | undefined;\n let reload = Promise.resolve();\n const dependencies = new Set<string>();\n let revision = 0;\n const changedFiles = new Set<string>();\n\n async function writeContract(value: unknown) {\n const source = generateClientContract(requireBrickApp(value));\n await writeContractSource(output, source);\n }\n\n function collectDependencies(\n node: EnvironmentModuleNode | undefined,\n seen = new Set<EnvironmentModuleNode>(),\n ) {\n if (!node || seen.has(node)) return;\n seen.add(node);\n if (node.file) dependencies.add(node.file);\n for (const imported of node.importedModules)\n collectDependencies(imported, seen);\n }\n\n return {\n name: \"brick:client\",\n enforce: \"pre\",\n configResolved(resolved) {\n config = resolved;\n entry = normalizePath(resolve(config.root, options.entry));\n output = normalizePath(\n resolve(config.root, options.output ?? \"_brick/contract.ts\"),\n );\n if (entry === output)\n throw new Error(\n \"Brick: contract output must not overwrite the app entry.\",\n );\n if (options.dashboard) themeCss(options.dashboard.theme);\n },\n async configureServer(server) {\n const environment = server.environments.ssr;\n if (!environment)\n throw new Error(\n \"Brick: client generation requires a Vite SSR environment.\",\n );\n // Frameworks such as Start own their SSR runner. Use an independent runner\n // on the same transform graph to read app metadata without changing theirs.\n runner = new ModuleRunner({\n hmr: false,\n transport: {\n invoke: (payload) => environment.hot.handleInvoke(payload),\n },\n });\n // The dashboard starts before the app is evaluated, so its tracer is\n // registered before the app's first request can be made.\n if (options.dashboard !== false) {\n const started = await startViteDashboard({\n port: options.dashboard?.port,\n historyDays: options.dashboard?.historyDays,\n dashboard: {\n extension: options.dashboard?.extension\n ? resolve(server.config.root, options.dashboard.extension)\n : undefined,\n theme: options.dashboard?.theme,\n },\n directory: server.config.root,\n entry,\n logger: server.config.logger,\n });\n dashboard = started;\n server.httpServer?.once(\"close\", () => started?.stop());\n server.httpServer?.once(\"listening\", () => {\n const address = server.httpServer?.address();\n if (address && typeof address === \"object\") {\n const scheme = server.config.server.https ? \"https\" : \"http\";\n started?.origin(`${scheme}://localhost:${address.port}`);\n }\n });\n }\n const app = (await runner.import(entry)).default;\n await writeContract(app);\n dashboard?.architecture(requireBrickApp(app));\n dependencies.clear();\n collectDependencies(environment.moduleGraph.getModuleById(entry));\n dependencies.add(entry);\n },\n async hotUpdate(context) {\n if (\n this.environment.name !== \"ssr\" ||\n !dependencies.has(context.file) ||\n context.file === output\n )\n return;\n if (!runner) return;\n const currentRunner = runner;\n const currentRevision = ++revision;\n changedFiles.add(context.file);\n reload = reload\n .catch(() => {})\n .then(async () => {\n await new Promise((done) => setTimeout(done, 30));\n if (currentRevision !== revision) return;\n for (const module of context.modules)\n this.environment.moduleGraph.invalidateModule(module);\n const graph = currentRunner.evaluatedModules;\n const seen = new Set<string>();\n const invalidate = (id: string) => {\n if (seen.has(id)) return;\n seen.add(id);\n const node = graph.getModuleById(id);\n if (!node) return;\n for (const importer of node.importers) invalidate(importer);\n // Registration modules mutate imported services. Reevaluate their\n // dependencies too so removed actions cannot survive in a singleton.\n for (const imported of node.imports) invalidate(imported);\n graph.invalidateModule(node);\n };\n for (const file of changedFiles) {\n for (const node of graph.getModulesByFile(file) ?? [])\n invalidate(node.id);\n }\n changedFiles.clear();\n invalidate(entry);\n try {\n const app = (await currentRunner.import(entry)).default;\n await writeContract(app);\n dashboard?.architecture(requireBrickApp(app));\n } finally {\n collectDependencies(\n this.environment.moduleGraph.getModuleById(entry),\n );\n }\n dependencies.clear();\n collectDependencies(\n this.environment.moduleGraph.getModuleById(entry),\n );\n dependencies.add(entry);\n });\n await reload;\n },\n async closeBundle() {\n await runner?.close();\n dashboard?.stop();\n },\n async buildStart() {\n if (config.command !== \"build\") return;\n buildGeneration ??= (async () => {\n // Evaluate the server entry through Vite's TS/alias resolver before client compilation.\n // This loader has no app plugins, so it cannot recursively trigger generation.\n const loader = await createServer({\n configFile: false,\n root: config.root,\n mode: config.mode,\n envDir: config.envDir,\n base: config.base,\n define: config.define,\n logLevel: \"silent\",\n resolve: { alias: config.resolve.alias },\n ssr: config.ssr,\n server: { middlewareMode: true, watch: null },\n });\n try {\n const environment = loader.environments.ssr;\n if (!environment || !isRunnableDevEnvironment(environment))\n throw new Error(\"Brick: missing build-time SSR loader.\");\n await writeContract((await environment.runner.import(entry)).default);\n } finally {\n await loader.close();\n }\n })();\n await buildGeneration;\n },\n resolveId(id) {\n if (id !== virtualId && id !== reporterId) return;\n if (this.environment.config.consumer === \"client\") {\n throw new Error(\n \"Brick: virtual:brick-app is server-only; never import the backend app in the browser.\",\n );\n }\n return id === virtualId ? resolvedId : resolvedReporterId;\n },\n load(id) {\n if (id === resolvedReporterId) {\n // The app imports the reporter only while the dashboard is running.\n if (!dashboard) return \"\";\n return `import { installDevReporter } from ${JSON.stringify(reporterModule)};\ninstallDevReporter({ url: ${JSON.stringify(dashboard.ingestUrl)} });\n`;\n }\n if (id !== resolvedId) return;\n // The reporter is imported first so tracing is installed before the app is built.\n const reporter = dashboard\n ? `import ${JSON.stringify(reporterId)};\\n`\n : \"\";\n return `${reporter}import app from ${JSON.stringify(entry)};\nif (!app || typeof app.fetch !== \"function\" || typeof app.endpoint !== \"function\") {\n throw new Error(\"Brick: the entry module must default-export a BrickApp created by brick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AS,EAAE,OAAO,OAAO,QAAQ,MAAM;KACvC,KAAK,OAAO;KACZ,QAAQ;MAAE,gBAAgB;MAAM,OAAO;KAAK;IAC9C,CAAC;IACD,IAAI;KACF,MAAM,cAAc,OAAO,aAAa;KACxC,IAAI,CAAC,eAAe,CAAC,yBAAyB,WAAW,GACvD,MAAM,IAAI,MAAM,uCAAuC;KACzD,MAAM,eAAe,MAAM,YAAY,OAAO,OAAO,KAAK,EAAA,CAAG,OAAO;IACtE,UAAU;KACR,MAAM,OAAO,MAAM;IACrB;GACF,EAAA,CAAG;GACH,MAAM;EACR;EACA,UAAU,IAAI;GACZ,IAAI,OAAO,aAAa,OAAO,YAAY;GAC3C,IAAI,KAAK,YAAY,OAAO,aAAa,UACvC,MAAM,IAAI,MACR,uFACF;GAEF,OAAO,OAAO,YAAY,aAAa;EACzC;EACA,KAAK,IAAI;GACP,IAAI,OAAO,oBAAoB;IAE7B,IAAI,CAAC,WAAW,OAAO;IACvB,OAAO,sCAAsC,KAAK,UAAU,cAAc,EAAE;4BACxD,KAAK,UAAU,UAAU,SAAS,EAAE;;GAE1D;GACA,IAAI,OAAO,YAAY;GAKvB,OAAO,GAHU,YACb,UAAU,KAAK,UAAU,UAAU,EAAE,OACrC,GACe,kBAAkB,KAAK,UAAU,KAAK,EAAE;;;;;;EAM7D;CACF;AACF"}
1
+ {"version":3,"file":"vite.js","names":[],"sources":["../src/dev-vite-dashboard.ts","../src/vite.ts"],"sourcesContent":["import { dirname } from \"node:path\";\nimport {\n getGlobalRegistry,\n type ApiDocument,\n type BrickApp,\n} from \"@brickkit/core\";\nimport { openDashboard } from \"./dashboard-host\";\nimport { ROUTES } from \"./dashboard-protocol\";\nimport type { DashboardExtensionOptions } from \"./dashboard-extension\";\n\nexport interface DashboardLogger {\n info(message: string): void;\n warn(message: string): void;\n}\n\nexport interface ViteDashboard {\n /** Where the app reports its spans; see installDevReporter. */\n readonly ingestUrl: string;\n /** Record the architecture of the application module Vite loaded. */\n architecture(app: BrickApp): void;\n /** Where the dev server is reachable, once it is listening. */\n origin(url: string): void;\n stop(): void;\n}\n\n/**\n * Serve the dashboard from inside the Vite dev server. Dev servers run the app\n * in a worker, which reports its spans here over HTTP. This process keeps the\n * history, so it survives worker restarts.\n */\nexport async function startViteDashboard(options: {\n port?: number;\n /** The project folder; history is kept in `.brick/` inside it. */\n directory: string;\n /** The app entry module; the paths in `documentation` start at its folder. */\n entry: string;\n /** Days of requests to keep on disk; zero for none. */\n historyDays?: number;\n /** The extension (an absolute path) and theme. */\n dashboard?: DashboardExtensionOptions;\n logger: DashboardLogger;\n}): Promise<ViteDashboard | undefined> {\n const dashboard = await openDashboard({\n port: options.port,\n directory: options.directory,\n historyDays: options.historyDays,\n warn: (message) => options.logger.warn(message),\n docs: true,\n dashboard: options.dashboard,\n portHint:\n \"Set dashboard.port in brickClient() to another, or dashboard: false.\",\n });\n if (!dashboard) return undefined;\n const { store, docs } = dashboard;\n options.logger.info(\n ` ➜ Brick dashboard: http://127.0.0.1:${dashboard.port}`,\n );\n\n let stopped = false;\n let origin: string | undefined;\n let documents: ApiDocument[] | undefined;\n let loads = 0;\n // The server starts listening after the app first loads, so the documents\n // are published again once its address is known.\n const publishDocuments = () => {\n if (documents) store.setApiDocuments(documents, origin);\n };\n return {\n ingestUrl: `http://127.0.0.1:${dashboard.port}${ROUTES.ingest.path}`,\n architecture(app) {\n store.setArchitecture(\n getGlobalRegistry().exportArchitecture(app.definition),\n store.latestGeneration,\n );\n void docs?.configure(\n dirname(options.entry),\n app.definition.documentation,\n );\n // A later load supersedes this one if it finishes first.\n const load = ++loads;\n app.referenceDocuments().then(\n (loaded) => {\n if (load !== loads || stopped) return;\n documents = loaded;\n publishDocuments();\n },\n (error: unknown) =>\n options.logger.warn(\n `[Brick-TS] Could not load the API documents: ${error instanceof Error ? error.message : String(error)}`,\n ),\n );\n },\n origin(url) {\n origin = url;\n publishDocuments();\n },\n stop() {\n if (stopped) return;\n stopped = true;\n dashboard.stop();\n },\n };\n}\n","import { join, resolve } from \"node:path\";\nimport { writeAppContract } from \"./client-contract-file\";\nimport { CONTRACT_FILE, PROJECT_DEFAULTS } from \"./config\";\nimport { ownModule } from \"./own-module\";\nimport {\n createServer,\n isRunnableDevEnvironment,\n normalizePath,\n type Plugin,\n type ResolvedConfig,\n type EnvironmentModuleNode,\n} from \"vite\";\nimport { requireBrickApp } from \"@brickkit/core\";\nimport { startViteDashboard, type ViteDashboard } from \"./dev-vite-dashboard\";\nimport type {\n DashboardExtensionOptions,\n DashboardTheme,\n} from \"./dashboard-extension\";\nimport { ModuleRunner } from \"vite/module-runner\";\n\nexport type { DashboardTheme };\n\nexport interface BrickClientPluginOptions {\n /** Any module whose default export is a BrickApp; do not call listen() there. */\n entry: string;\n /** Generated browser contract, relative to the Vite root (default _brick/contract.ts). */\n output?: string;\n /**\n * Local dashboard for the app's requests, traces, errors, and reloads, served\n * during `vite dev` (default: on at port 9400). Apps must pass\n * `telemetry: true` to brick() to record requests. `historyDays` is how long\n * finished requests are kept in `.brick/` (default 90, 0 for none). Set to\n * false to disable. `extension` (relative to the Vite root) and `theme`\n * customise it, as in `brick dev`.\n */\n dashboard?:\n | ({ port?: number; historyDays?: number } & DashboardExtensionOptions)\n | false;\n}\n\n/** Load a BrickApp through Vite's server module graph, including dependency HMR. */\nexport function brickClient(options: BrickClientPluginOptions): Plugin {\n const virtualId = \"virtual:brick-app\";\n const resolvedId = \"\\0\" + virtualId;\n const reporterId = \"virtual:brick-dev-reporter\";\n const resolvedReporterId = \"\\0\" + reporterId;\n // Imported by file path: the package name may not resolve from the app's root.\n const reporterModule = ownModule(\"dev-reporter\");\n let entry: string;\n let output: string;\n let config: ResolvedConfig;\n let buildGeneration: Promise<void> | undefined;\n let runner: ModuleRunner | undefined;\n let dashboard: ViteDashboard | undefined;\n let reload = Promise.resolve();\n const dependencies = new Set<string>();\n let revision = 0;\n const changedFiles = new Set<string>();\n\n function collectDependencies(\n node: EnvironmentModuleNode | undefined,\n seen = new Set<EnvironmentModuleNode>(),\n ) {\n if (!node || seen.has(node)) return;\n seen.add(node);\n if (node.file) dependencies.add(node.file);\n for (const imported of node.importedModules)\n collectDependencies(imported, seen);\n }\n\n return {\n name: \"brick:client\",\n enforce: \"pre\",\n configResolved(resolved) {\n config = resolved;\n entry = normalizePath(resolve(config.root, options.entry));\n output = normalizePath(\n resolve(\n config.root,\n options.output ?? join(PROJECT_DEFAULTS.generated, CONTRACT_FILE),\n ),\n );\n },\n async configureServer(server) {\n const environment = server.environments.ssr;\n if (!environment)\n throw new Error(\n \"Brick: client generation requires a Vite SSR environment.\",\n );\n // Frameworks such as Start own their SSR runner. Use an independent runner\n // on the same transform graph to read app metadata without changing theirs.\n runner = new ModuleRunner({\n hmr: false,\n transport: {\n invoke: (payload) => environment.hot.handleInvoke(payload),\n },\n });\n // The dashboard starts before the app is evaluated, so its tracer is\n // registered before the app's first request can be made.\n if (options.dashboard !== false) {\n const started = await startViteDashboard({\n port: options.dashboard?.port,\n historyDays: options.dashboard?.historyDays,\n dashboard: {\n extension: options.dashboard?.extension\n ? resolve(server.config.root, options.dashboard.extension)\n : undefined,\n theme: options.dashboard?.theme,\n },\n directory: server.config.root,\n entry,\n logger: server.config.logger,\n });\n dashboard = started;\n server.httpServer?.once(\"close\", () => started?.stop());\n server.httpServer?.once(\"listening\", () => {\n const address = server.httpServer?.address();\n if (address && typeof address === \"object\") {\n const scheme = server.config.server.https ? \"https\" : \"http\";\n started?.origin(`${scheme}://localhost:${address.port}`);\n }\n });\n }\n const app = (await runner.import(entry)).default;\n await writeAppContract(app, entry, output);\n dashboard?.architecture(requireBrickApp(app));\n dependencies.clear();\n collectDependencies(environment.moduleGraph.getModuleById(entry));\n dependencies.add(entry);\n },\n async hotUpdate(context) {\n if (\n this.environment.name !== \"ssr\" ||\n !dependencies.has(context.file) ||\n context.file === output\n )\n return;\n if (!runner) return;\n const currentRunner = runner;\n const currentRevision = ++revision;\n changedFiles.add(context.file);\n reload = reload\n .catch(() => {})\n .then(async () => {\n await new Promise((done) => setTimeout(done, 30));\n if (currentRevision !== revision) return;\n for (const module of context.modules)\n this.environment.moduleGraph.invalidateModule(module);\n const graph = currentRunner.evaluatedModules;\n const seen = new Set<string>();\n const invalidate = (id: string) => {\n if (seen.has(id)) return;\n seen.add(id);\n const node = graph.getModuleById(id);\n if (!node) return;\n for (const importer of node.importers) invalidate(importer);\n // Registration modules mutate imported services. Reevaluate their\n // dependencies too so removed actions cannot survive in a singleton.\n for (const imported of node.imports) invalidate(imported);\n graph.invalidateModule(node);\n };\n for (const file of changedFiles) {\n for (const node of graph.getModulesByFile(file) ?? [])\n invalidate(node.id);\n }\n changedFiles.clear();\n invalidate(entry);\n try {\n const app = (await currentRunner.import(entry)).default;\n await writeAppContract(app, entry, output);\n dashboard?.architecture(requireBrickApp(app));\n } finally {\n collectDependencies(\n this.environment.moduleGraph.getModuleById(entry),\n );\n }\n dependencies.clear();\n collectDependencies(\n this.environment.moduleGraph.getModuleById(entry),\n );\n dependencies.add(entry);\n });\n await reload;\n },\n async closeBundle() {\n await runner?.close();\n dashboard?.stop();\n },\n async buildStart() {\n if (config.command !== \"build\") return;\n buildGeneration ??= (async () => {\n // Evaluate the server entry through Vite's TS/alias resolver before client compilation.\n // This loader has no app plugins, so it cannot recursively trigger generation.\n const loader = await createServer({\n configFile: false,\n root: config.root,\n mode: config.mode,\n envDir: config.envDir,\n base: config.base,\n define: config.define,\n logLevel: \"silent\",\n resolve: { alias: config.resolve.alias },\n ssr: config.ssr,\n server: { middlewareMode: true, watch: null },\n });\n try {\n const environment = loader.environments.ssr;\n if (!environment || !isRunnableDevEnvironment(environment))\n throw new Error(\"Brick: missing build-time SSR loader.\");\n await writeAppContract(\n (await environment.runner.import(entry)).default,\n entry,\n output,\n );\n } finally {\n await loader.close();\n }\n })();\n await buildGeneration;\n },\n resolveId(id) {\n if (id !== virtualId && id !== reporterId) return;\n if (this.environment.config.consumer === \"client\") {\n throw new Error(\n \"Brick: virtual:brick-app is server-only; never import the backend app in the browser.\",\n );\n }\n return id === virtualId ? resolvedId : resolvedReporterId;\n },\n load(id) {\n if (id === resolvedReporterId) {\n if (!dashboard) return \"\";\n return `import { installDevReporter } from ${JSON.stringify(reporterModule)};\ninstallDevReporter({ url: ${JSON.stringify(dashboard.ingestUrl)} });\n`;\n }\n if (id !== resolvedId) return;\n // The reporter is imported first so tracing is installed before the app is built.\n const reporter = dashboard\n ? `import ${JSON.stringify(reporterId)};\\n`\n : \"\";\n return `${reporter}import { requireBrickApp } from \"@brickkit/core\";\nimport app from ${JSON.stringify(entry)};\nexport default requireBrickApp(app);\n`;\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;AA8BA,eAAsB,mBAAmB,SAWF;CACrC,MAAM,YAAY,MAAM,cAAc;EACpC,MAAM,QAAQ;EACd,WAAW,QAAQ;EACnB,aAAa,QAAQ;EACrB,OAAO,YAAY,QAAQ,OAAO,KAAK,OAAO;EAC9C,MAAM;EACN,WAAW,QAAQ;EACnB,UACE;CACJ,CAAC;CACD,IAAI,CAAC,WAAW,OAAO,KAAA;CACvB,MAAM,EAAE,OAAO,SAAS;CACxB,QAAQ,OAAO,KACb,0CAA0C,UAAU,MACtD;CAEA,IAAI,UAAU;CACd,IAAI;CACJ,IAAI;CACJ,IAAI,QAAQ;CAGZ,MAAM,yBAAyB;EAC7B,IAAI,WAAW,MAAM,gBAAgB,WAAW,MAAM;CACxD;CACA,OAAO;EACL,WAAW,oBAAoB,UAAU,OAAO,OAAO,OAAO;EAC9D,aAAa,KAAK;GAChB,MAAM,gBACJ,kBAAkB,CAAC,CAAC,mBAAmB,IAAI,UAAU,GACrD,MAAM,gBACR;GACA,MAAW,UACT,QAAQ,QAAQ,KAAK,GACrB,IAAI,WAAW,aACjB;GAEA,MAAM,OAAO,EAAE;GACf,IAAI,mBAAmB,CAAC,CAAC,MACtB,WAAW;IACV,IAAI,SAAS,SAAS,SAAS;IAC/B,YAAY;IACZ,iBAAiB;GACnB,IACC,UACC,QAAQ,OAA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C,yBAAyB,WAAW,GACvD,MAAM,IAAI,MAAM,uCAAuC;KACzD,MAAM,kBACH,MAAM,YAAY,OAAO,OAAO,KAAK,EAAA,CAAG,SACzC,OACA,MACF;IACF,UAAU;KACR,MAAM,OAAO,MAAM;IACrB;GACF,EAAA,CAAG;GACH,MAAM;EACR;EACA,UAAU,IAAI;GACZ,IAAI,OAAO,aAAa,OAAO,YAAY;GAC3C,IAAI,KAAK,YAAY,OAAO,aAAa,UACvC,MAAM,IAAI,MACR,uFACF;GAEF,OAAO,OAAO,YAAY,aAAa;EACzC;EACA,KAAK,IAAI;GACP,IAAI,OAAO,oBAAoB;IAC7B,IAAI,CAAC,WAAW,OAAO;IACvB,OAAO,sCAAsC,KAAK,UAAU,cAAc,EAAE;4BACxD,KAAK,UAAU,UAAU,SAAS,EAAE;;GAE1D;GACA,IAAI,OAAO,YAAY;GAKvB,OAAO,GAHU,YACb,UAAU,KAAK,UAAU,UAAU,EAAE,OACrC,GACe;kBACP,KAAK,UAAU,KAAK,EAAE;;;EAGpC;CACF;AACF"}
@@ -1,5 +1,4 @@
1
1
  import { BrickApp } from "@brickkit/core";
2
- //#region src/workflows.d.ts
3
2
  type BunPlugin = Parameters<typeof Bun.plugin>[0];
4
3
  /**
5
4
  * The plugin that turns `"use workflow"` and `"use step"` files into workflows and
@@ -20,8 +19,8 @@ export declare function workflowTransformPlugin(root?: string): Promise<BunPlugi
20
19
  * Call it in a script or test before importing the files, with the project root.
21
20
  *
22
21
  * It does nothing, and returns `false`, when the Workflow SDK and its builders are
23
- * not installed in the project. Bun allows plugins once per process, so a second
24
- * call is ignored.
22
+ * not installed in the project. Each root gets ids relative to itself; a file
23
+ * under no registered root uses the first one.
25
24
  *
26
25
  * @param root - The project root, where the SDK is installed. Default: the working directory.
27
26
  * @returns Whether the transform is active.
@@ -56,6 +55,5 @@ export declare function buildWorkflows(options?: {
56
55
  export declare function buildAppWorkflows(app: BrickApp, options?: {
57
56
  reuse?: boolean;
58
57
  }): Promise<boolean>;
59
- //#endregion
60
58
  export {};
61
59
  //# sourceMappingURL=workflows.d.ts.map