@brickkit/cli 0.14.0 → 0.16.0-beta.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 (89) hide show
  1. package/dashboard-dist/{CollapsiblePanel-CbUysOp5.js → CollapsiblePanel-DvJpFahB.js} +2 -2
  2. package/dashboard-dist/Geist-Variable.woff2 +0 -0
  3. package/dashboard-dist/GeistMono-Variable.woff2 +0 -0
  4. package/dashboard-dist/{api-reference-lLhahVJi.js → api-reference-C2_JX174.js} +82 -70
  5. package/dashboard-dist/app.css +2 -2
  6. package/dashboard-dist/app.js +5 -5
  7. package/dashboard-dist/{client-DRtkFydB.js → client-DsITZplk.js} +1 -1
  8. package/dashboard-dist/{core-BSTqZqMg.js → core-sW89OSz5.js} +1 -1
  9. package/dashboard-dist/docs-D3U7gUWq.js +4 -0
  10. package/dashboard-dist/kit.js +1 -1
  11. package/dashboard-dist/{popover-CKxhB1QI.js → popover-Bb2Q3jiK.js} +1 -1
  12. package/dist/bin.d.ts +1 -2
  13. package/dist/bin.js +6 -6
  14. package/dist/bin.js.map +1 -1
  15. package/dist/build.js +5 -1
  16. package/dist/build.js.map +1 -1
  17. package/dist/client-contract-file.js +3 -2
  18. package/dist/client-contract-file.js.map +1 -1
  19. package/dist/compiler.d.ts +1 -2
  20. package/dist/config2.d.ts +1 -2
  21. package/dist/dashboard-extension.d.ts +1 -2
  22. package/dist/dashboard-host.js +26 -7
  23. package/dist/dashboard-host.js.map +1 -1
  24. package/dist/dashboard.d.ts +4 -4
  25. package/dist/definitions.js +1 -0
  26. package/dist/definitions.js.map +1 -1
  27. package/dist/dev-application.js.map +1 -1
  28. package/dist/dev-reporter.d.ts +1 -2
  29. package/dist/dev-reporter.js.map +1 -1
  30. package/dist/dev-telemetry.js.map +1 -1
  31. package/dist/dev-worker.js.map +1 -1
  32. package/dist/index.d.ts +1 -2
  33. package/dist/lint/oxlint.d.ts +1 -2
  34. package/dist/plugin.d.ts +1 -2
  35. package/dist/production-dashboard2.d.ts +1 -2
  36. package/dist/project.js +35 -12
  37. package/dist/project.js.map +1 -1
  38. package/dist/serve.d.ts +1 -2
  39. package/dist/serve2.js.map +1 -1
  40. package/dist/vite.d.ts +1 -2
  41. package/dist/vite.js +2 -1
  42. package/dist/vite.js.map +1 -1
  43. package/dist/workflows.d.ts +1 -2
  44. package/inspector-dist/client/assets/app-Wfnqu2Ic.css +4610 -0
  45. package/inspector-dist/client/assets/{dist-BK8w6xOr.js → dist-CEyPxAJU.js} +2008 -334
  46. package/inspector-dist/client/assets/{entry.client-D9jbgmTR.js → entry.client-Cszf0uLP.js} +4628 -2593
  47. package/inspector-dist/client/assets/highlighted-body-JLMTFACH-CgFt8UnP.js +41 -0
  48. package/inspector-dist/client/assets/{home-hwPlkNhv.js → home-B2m1nnIz.js} +191 -105
  49. package/inspector-dist/client/assets/{jsx-runtime-CPEah4WQ.js → jsx-runtime-DRYYXgdJ.js} +2946 -2001
  50. package/inspector-dist/client/assets/{manifest-0e76e9ac.js → manifest-cfc09adc.js} +1 -1
  51. package/inspector-dist/client/assets/mermaid-WFAXDIZX-BoRESrqm.js +1 -0
  52. package/inspector-dist/client/assets/root-CVescmwt.css +4544 -0
  53. package/inspector-dist/client/assets/{root-SLeEf-sT.js → root-CVhM1JOR.js} +3 -3
  54. package/inspector-dist/client/assets/{run-detail-DYbVkIFH.js → run-detail-BdV01jxD.js} +90 -50
  55. package/inspector-dist/client/assets/tabs-BVrPbzfI.css +66 -0
  56. package/inspector-dist/client/assets/{tabs-CaJisoyb.js → tabs-C2hdi5D4.js} +12496 -8708
  57. package/inspector-dist/client/assets/{zstd-browser-decoder-D94wmfAU.js → zstd-browser-decoder-DQWDmc2d.js} +2 -2
  58. package/inspector-dist/server/assets/{app-DGlfWVUI.js → app-w0nTXgJd.js} +51489 -51478
  59. package/inspector-dist/server/assets/{chunk-RLXIAIE6-F0SJZlei.js → chunk-7TTQLYRW-BO6_qAAU.js} +10986 -7848
  60. package/inspector-dist/server/assets/cjs-DPK66Gxq.js +3600 -0
  61. package/inspector-dist/server/assets/{dist-BCbwm6jl.js → dist-DTHqO9VA.js} +149 -1619
  62. package/inspector-dist/server/assets/{dist-Ce0I2PUv.js → dist-OLuKLJ4s.js} +8 -8
  63. package/inspector-dist/server/assets/{encryption-DdQgC8Rk.js → encryption-DMo4uOFN.js} +5 -5
  64. package/inspector-dist/server/assets/{event-metadata-n7E4zEmT.js → event-metadata-Bx8Ts484.js} +1 -1
  65. package/inspector-dist/server/assets/functions-B9XwHSzK.js +6972 -0
  66. package/inspector-dist/server/assets/{global-singleton-D8sIN5du.js → global-singleton-rNtXNHKV.js} +1 -1
  67. package/inspector-dist/server/assets/highlighted-body-JLMTFACH-B0HDNeQE.js +41 -0
  68. package/inspector-dist/server/assets/mermaid-WFAXDIZX-B-AIJZhh.js +1 -0
  69. package/inspector-dist/server/assets/serialization-DsMds3lJ.js +5716 -0
  70. package/inspector-dist/server/assets/{serialization-format-BbuGfHog.js → serialization-format-B27jSUCM.js} +30 -9
  71. package/inspector-dist/server/assets/state-resolver-DVs_zsEO.js +1422 -0
  72. package/inspector-dist/server/assets/{token-BgMmJNP5.js → token-CvvD8Y5H.js} +1 -1
  73. package/inspector-dist/server/assets/token-CxjWFNNq.js +63 -0
  74. package/inspector-dist/server/assets/token-util-D9IsWeEs.js +3 -0
  75. package/inspector-dist/server/assets/{wrapper-CIC3w0oC.js → wrapper-B_u9Z5Up.js} +58 -26
  76. package/inspector-dist/server/assets/{ws-transport-CxTYB11n.js → ws-transport-CamzQ5O8.js} +24379 -24240
  77. package/inspector-dist/server/assets/{zstd-browser-decoder-D7bCXbGg.js → zstd-browser-decoder-DlGbqUuc.js} +2 -2
  78. package/inspector-dist/server/index.js +1 -1
  79. package/package.json +21 -21
  80. package/dashboard-dist/docs-Cye2p0fM.js +0 -4
  81. package/inspector-dist/client/assets/app-CeSwVsRm.css +0 -2
  82. package/inspector-dist/client/assets/highlighted-body-B3W2YXNL-CfRnuITN.js +0 -34
  83. package/inspector-dist/client/assets/mermaid-3ZIDBTTL-ZDR2PNY_.js +0 -1
  84. package/inspector-dist/client/assets/root-ChBNTZd2.css +0 -2
  85. package/inspector-dist/client/assets/tabs-L5XKzOpP.css +0 -1
  86. package/inspector-dist/server/assets/functions-CNVQtbgg.js +0 -1170
  87. package/inspector-dist/server/assets/highlighted-body-B3W2YXNL-CWRzMxYD.js +0 -34
  88. package/inspector-dist/server/assets/mermaid-3ZIDBTTL-D0v0ngVr.js +0 -1
  89. package/inspector-dist/server/assets/parse-Begau9cA.js +0 -469
@@ -1 +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 defineSchedule: \"schedule\",\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 schedule: \"schedules\",\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, .schedule, .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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;EACd,UAAU,KAAK,QAAQ,QAAQ;EAC/B,OAAO,KAAK,QAAQ,KAAK;EACzB,WAAW,KAAK,QAAQ,SAAS;CACnC;CACA,OAAO;EACL;EACA,OAAO,UAAU,QAAQ;EACzB;EACA,QAAQ,CAAC,GAAI,KAAK,UAAU,CAAC,GAAI,GAAG,SAAS,UAAU,IAAI;CAC7D;AACF"}
1
+ {"version":3,"file":"project.js","names":["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 defineSchedule: \"schedule\",\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 webhook: \"webhook\",\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 outside callers reach, a client or a provider (a webhook): described in OpenAPI, MCP and the dashboard. */\nconst OUTSIDE_ENDPOINTS: Definition[\"kind\"][] = [\n ...HANDLERS,\n \"socket\",\n \"webhook\",\n];\n/** What gets the error helpers. */\nconst ERROR_KINDS: Definition[\"kind\"][] = [...OUTSIDE_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. Pass it in the service's deps (defineService({ deps })) 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, [\n ...HANDLERS,\n \"webhook\",\n ]);\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 \"public-rate-limit\": rule(\n \"Public actions, commands and tools declare rateLimit.\",\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 if (objectKeys(definition.config) === undefined) return;\n const access = getProperty(definition.config, \"access\")?.value;\n const isPublic =\n !getProperty(definition.config, \"authorize\") &&\n getProperty(definition.config, \"dashboard\")?.value?.value !==\n true &&\n (!access || stringValue(access) === \"public\");\n const limit = getProperty(definition.config, \"rateLimit\")?.value;\n const limited =\n limit &&\n !(limit.type === \"ArrayExpression\" && limit.elements.length === 0);\n if (isPublic && !limited)\n context.report({\n node: definition.nameNode ?? node,\n message: `Anyone can call this ${definition.kind} as often as they like; add rateLimit: { per: \"ip\", max, windowMs }, or authorize.`,\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 OUTSIDE_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 webhook: \"webhooks\",\n socket: \"sockets\",\n listener: \"listeners\",\n schedule: \"schedules\",\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, .webhook, .socket, .listener, .schedule, .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 \"public-rate-limit\": \"warn\",\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,MAAM,SAAS,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,OA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,KAAK,GAAG,KAAK;CACvD,MAAM,WAA0B;EAC9B,MAAM,QAAQ;EACd,UAAU,KAAK,QAAQ,QAAQ;EAC/B,OAAO,KAAK,QAAQ,KAAK;EACzB,WAAW,KAAK,QAAQ,SAAS;CACnC;CACA,OAAO;EACL;EACA,OAAO,UAAU,QAAQ;EACzB;EACA,QAAQ,CAAC,GAAI,KAAK,UAAU,CAAC,GAAI,GAAG,SAAS,UAAU,IAAI;CAC7D;AACF"}
package/dist/serve.d.ts CHANGED
@@ -20,5 +20,4 @@ export declare function printBanner(app: BrickApp, options: {
20
20
  label: string;
21
21
  port: number;
22
22
  dashboard?: Pick<ProductionDashboard, "host" | "port">;
23
- }): void;
24
- //# sourceMappingURL=serve.d.ts.map
23
+ }): void;
@@ -1 +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"}
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;EACN,IAAI,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
@@ -20,5 +20,4 @@ export interface BrickClientPluginOptions {
20
20
  }
21
21
  /** Load a BrickApp through Vite's server module graph, including dependency HMR. */
22
22
  export declare function brickClient(options: BrickClientPluginOptions): Plugin;
23
- export type { DashboardTheme };
24
- //# sourceMappingURL=vite.d.ts.map
23
+ export type { DashboardTheme };
package/dist/vite.js CHANGED
@@ -4,7 +4,7 @@ import { t as ownModule } from "./own-module.js";
4
4
  import { t as openDashboard } from "./dashboard-host.js";
5
5
  import { s as ROUTES } from "./dashboard-protocol.js";
6
6
  import { dirname, join, resolve } from "node:path";
7
- import { getGlobalRegistry, requireBrickApp } from "@brickkit/core";
7
+ import { GLOBAL_SYMBOL, dashboardKey, getGlobalRegistry, requireBrickApp } from "@brickkit/core";
8
8
  import { createServer, isRunnableDevEnvironment, normalizePath } from "vite";
9
9
  import { ModuleRunner } from "vite/module-runner";
10
10
  // src/dev-vite-dashboard.ts
@@ -203,6 +203,7 @@ function brickClient(options) {
203
203
  if (!dashboard) return "";
204
204
  return `import { installDevReporter } from ${JSON.stringify(reporterModule)};
205
205
  installDevReporter({ url: ${JSON.stringify(dashboard.ingestUrl)} });
206
+ globalThis[Symbol.for(${JSON.stringify(GLOBAL_SYMBOL.dashboardKey)})] = ${JSON.stringify(dashboardKey())};
206
207
  `;
207
208
  }
208
209
  if (id !== resolvedId) return;