@brickkit/cli 0.12.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/dashboard-dist/{api-reference-B-bZRtNV.js → api-reference-mT9VNcPb.js} +69 -69
  2. package/dashboard-dist/app.js +12 -13
  3. package/dashboard-dist/{client-BJJtVSVr.js → client-CwATkLJa.js} +1 -1
  4. package/dashboard-dist/{core-Z7NJFk0K.js → core-BEUWp6B5.js} +1 -1
  5. package/dashboard-dist/docs-BRrtyxDB.js +4 -0
  6. package/dashboard-dist/kit.js +1 -1
  7. package/dashboard-dist/popover-Bj9x-88h.js +1 -0
  8. package/dist/bin.js +154 -217
  9. package/dist/bin.js.map +1 -1
  10. package/dist/build.js +463 -0
  11. package/dist/build.js.map +1 -0
  12. package/dist/client-contract-file.js +356 -1
  13. package/dist/client-contract-file.js.map +1 -0
  14. package/dist/compiler.d.ts +12 -2
  15. package/dist/compiler2.js +12 -5
  16. package/dist/compiler2.js.map +1 -1
  17. package/dist/config.d.ts +3 -0
  18. package/dist/config.js +1 -250
  19. package/dist/config2.d.ts +122 -0
  20. package/dist/config2.js +207 -0
  21. package/dist/config2.js.map +1 -0
  22. package/dist/dashboard-extension.d.ts +3 -0
  23. package/dist/{dev-telemetry-store.js → dashboard-host.js} +1533 -1574
  24. package/dist/dashboard-host.js.map +1 -0
  25. package/dist/dashboard-protocol.js +189 -0
  26. package/dist/dashboard-protocol.js.map +1 -0
  27. package/dist/dashboard.d.ts +4 -1
  28. package/dist/definitions.js +33 -0
  29. package/dist/definitions.js.map +1 -0
  30. package/dist/dev-application.js +34 -0
  31. package/dist/dev-application.js.map +1 -0
  32. package/dist/dev-protocol.js +21 -0
  33. package/dist/dev-protocol.js.map +1 -0
  34. package/dist/dev-reporter.js +2 -1
  35. package/dist/dev-reporter.js.map +1 -1
  36. package/dist/dev-telemetry.js +5 -20
  37. package/dist/dev-telemetry.js.map +1 -1
  38. package/dist/dev-worker.js +79 -19
  39. package/dist/dev-worker.js.map +1 -1
  40. package/dist/index.d.ts +15 -74
  41. package/dist/index.js +12 -5
  42. package/dist/index.js.map +1 -0
  43. package/dist/lint/oxlint.js +5 -3
  44. package/dist/lint/oxlint.js.map +1 -1
  45. package/dist/own-module.js +7 -0
  46. package/dist/own-module.js.map +1 -0
  47. package/dist/plugin.d.ts +6 -5
  48. package/dist/plugin.js +5 -39
  49. package/dist/plugin.js.map +1 -1
  50. package/dist/production-dashboard.d.ts +2 -0
  51. package/dist/production-dashboard.js +51 -0
  52. package/dist/production-dashboard.js.map +1 -0
  53. package/dist/production-dashboard2.d.ts +34 -0
  54. package/dist/{presets.js → project.js} +104 -106
  55. package/dist/project.js.map +1 -0
  56. package/dist/serve.d.ts +24 -0
  57. package/dist/serve.js +1 -0
  58. package/dist/serve2.js +49 -0
  59. package/dist/serve2.js.map +1 -0
  60. package/dist/vite.js +26 -47
  61. package/dist/vite.js.map +1 -1
  62. package/dist/workflows.d.ts +2 -2
  63. package/dist/workflows2.js +59 -37
  64. package/dist/workflows2.js.map +1 -1
  65. package/inspector-dist/client/assets/app-CeSwVsRm.css +2 -0
  66. package/inspector-dist/client/assets/{highlighted-body-B3W2YXNL-DYVdwGy2.js → highlighted-body-B3W2YXNL-CfRnuITN.js} +1 -1
  67. package/inspector-dist/client/assets/{home-CyjkvtII.js → home-hwPlkNhv.js} +1529 -378
  68. package/inspector-dist/client/assets/manifest-0e76e9ac.js +1 -0
  69. package/inspector-dist/client/assets/mermaid-3ZIDBTTL-ZDR2PNY_.js +1 -0
  70. package/inspector-dist/client/assets/root-ChBNTZd2.css +2 -0
  71. package/inspector-dist/client/assets/{root-DX9wtogx.js → root-SLeEf-sT.js} +17 -29
  72. package/inspector-dist/client/assets/{run-detail-C69EJGql.js → run-detail-DYbVkIFH.js} +398 -76
  73. package/inspector-dist/client/assets/{tabs-B6B88IjT.js → tabs-CaJisoyb.js} +189 -2130
  74. package/inspector-dist/client/assets/{zstd-browser-decoder-ByUgcY9H.js → zstd-browser-decoder-D94wmfAU.js} +1 -1
  75. package/inspector-dist/server/assets/{app-WoDoT62X.js → app-DGlfWVUI.js} +69783 -70608
  76. package/inspector-dist/server/assets/{chunk-RLXIAIE6-CbvDIAEa.js → chunk-RLXIAIE6-F0SJZlei.js} +4 -6
  77. package/inspector-dist/server/assets/{dist-qR-969AD.js → dist-BCbwm6jl.js} +2 -4
  78. package/inspector-dist/server/assets/{dist-CQnQcIJg.js → dist-CG2aVufI.js} +0 -2
  79. package/inspector-dist/server/assets/{dist-BRxZSWUN.js → dist-Ce0I2PUv.js} +2 -5
  80. package/inspector-dist/server/assets/{dist-DqRd9pyS.js → dist-DY0UlahA.js} +0 -2
  81. package/inspector-dist/server/assets/{encryption-_PuklZNX.js → encryption-DdQgC8Rk.js} +2 -4
  82. package/inspector-dist/server/assets/{event-metadata-BVakQJ_y.js → event-metadata-n7E4zEmT.js} +0 -2
  83. package/inspector-dist/server/assets/{functions-CImcpqNl.js → functions-CNVQtbgg.js} +2 -4
  84. package/inspector-dist/server/assets/{global-singleton-CPirHxFh.js → global-singleton-D8sIN5du.js} +0 -2
  85. package/inspector-dist/server/assets/{highlighted-body-B3W2YXNL-fPMB_t7F.js → highlighted-body-B3W2YXNL-CWRzMxYD.js} +2 -4
  86. package/inspector-dist/server/assets/mermaid-3ZIDBTTL-D0v0ngVr.js +1 -0
  87. package/inspector-dist/server/assets/{parse-D9Vvgzt9.js → parse-Begau9cA.js} +0 -2
  88. package/inspector-dist/server/assets/{rolldown-runtime-CLg409Sh.js → rolldown-runtime-C1I3wEg2.js} +1 -2
  89. package/inspector-dist/server/assets/{serialization-format-DDtsVTU1.js → serialization-format-BbuGfHog.js} +6 -8
  90. package/inspector-dist/server/assets/{token-BW4GdQZh.js → token-BgMmJNP5.js} +2 -4
  91. package/inspector-dist/server/assets/{token-D6FXdkJT.js → token-BrUX0bxz.js} +2 -4
  92. package/inspector-dist/server/assets/{token-util-BoNmi-wE.js → token-util-DZN32qmT.js} +1 -3
  93. package/inspector-dist/server/assets/{wrapper-wiqsGXcE.js → wrapper-CIC3w0oC.js} +1 -3
  94. package/inspector-dist/server/assets/{ws-transport-DV7oG4mL.js → ws-transport-CxTYB11n.js} +24094 -24096
  95. package/inspector-dist/server/assets/{zstd-browser-decoder-Cswf0KO6.js → zstd-browser-decoder-D7bCXbGg.js} +2 -4
  96. package/inspector-dist/server/index.js +1 -3
  97. package/package.json +12 -2
  98. package/dashboard-dist/docs-Dpfc0wJb.js +0 -4
  99. package/dashboard-dist/popover-BzejBolB.js +0 -1
  100. package/dist/app-entry.js +0 -1
  101. package/dist/app-entry2.js +0 -18
  102. package/dist/app-entry2.js.map +0 -1
  103. package/dist/client-contract-file2.js +0 -33
  104. package/dist/client-contract-file2.js.map +0 -1
  105. package/dist/client-contract.js +0 -1
  106. package/dist/client-contract2.js +0 -296
  107. package/dist/client-contract2.js.map +0 -1
  108. package/dist/config.js.map +0 -1
  109. package/dist/dev-telemetry-store.js.map +0 -1
  110. package/dist/emit.d.ts +0 -5
  111. package/dist/presets.js.map +0 -1
  112. package/dist/runner.js +0 -519
  113. package/dist/runner.js.map +0 -1
  114. package/inspector-dist/client/assets/app-CCzpuUz_.css +0 -2
  115. package/inspector-dist/client/assets/manifest-ba30b52d.js +0 -1
  116. package/inspector-dist/client/assets/mermaid-3ZIDBTTL-Dy6IVqPy.js +0 -1
  117. package/inspector-dist/client/assets/root-8BMab1lL.css +0 -2
  118. package/inspector-dist/client/assets/world-config-context-C3BqXPIv.js +0 -30
  119. package/inspector-dist/server/assets/mermaid-3ZIDBTTL-bADXySE3.js +0 -3
@@ -1,55 +1,58 @@
1
- import { basename, dirname, relative, resolve, sep } from "node:path";
1
+ import { n as ConfigError, s as PROJECT_DEFAULTS } from "./config2.js";
2
+ import { a as TEST_FILE, i as MANIFEST_FILE, n as DEFINITION_FILE } from "./definitions.js";
2
3
  import { readdirSync } from "node:fs";
3
- const SUFFIX = new RegExp(`^(.*)\\.(${[
4
- "service",
5
- "events",
6
- "resource",
7
- "table",
8
- "action",
9
- "command",
10
- "tool",
11
- "socket",
12
- "listener",
13
- "workflow",
14
- "step"
15
- ].join("|")})\\.(ts|tsx|mts|js|jsx|mjs)$`);
4
+ import { basename, dirname, relative, resolve, sep } from "node:path";
5
+ import { STANDARD_ERRORS, isControlEvent, kebabCase } from "@brickkit/core/client";
6
+ // src/lint/ast.ts
7
+ function defineRule(type, description, create, options = {}) {
8
+ return {
9
+ meta: {
10
+ type,
11
+ docs: { description },
12
+ fixable: options.fixable,
13
+ schema: options.schema ?? []
14
+ },
15
+ create
16
+ };
17
+ }
16
18
  const posix$1 = (path) => path.split(sep).join("/");
19
+ /** The settings with Brick's default paths, each relative to the root without a trailing slash. */
17
20
  function brickSettings(context) {
18
21
  const given = context.settings?.brick ?? {};
22
+ const root = given.root ?? context.cwd ?? process.cwd();
23
+ const from = (path) => posix$1(relative(root, resolve(root, path)));
19
24
  return {
20
- root: given.root ?? context.cwd ?? process.cwd(),
21
- services: given.services ?? "src/services",
22
- entry: given.entry ?? "src/app.ts",
23
- generated: given.generated ?? "_brick",
24
- web: given.web ?? "web"
25
+ root,
26
+ services: from(given.services ?? PROJECT_DEFAULTS.services),
27
+ entry: from(given.entry ?? PROJECT_DEFAULTS.entry),
28
+ generated: from(given.generated ?? PROJECT_DEFAULTS.generated)
25
29
  };
26
30
  }
31
+ /** The folders a service may live in: its kebab-case name, or the name itself. */
32
+ const serviceFolders = (name) => [kebabCase(name), name];
27
33
  function fileInfo(context) {
28
34
  const settings = brickSettings(context);
29
35
  const rel = posix$1(relative(settings.root, context.filename));
30
- const servicesDir = posix$1(relative(settings.root, resolve(settings.root, settings.services)));
31
- const generated = posix$1(relative(settings.root, resolve(settings.root, settings.generated)));
36
+ const { services: servicesDir, generated } = settings;
32
37
  const base = basename(rel);
33
38
  const inServices = rel.startsWith(`${servicesDir}/`);
34
39
  const parts = inServices ? rel.slice(servicesDir.length + 1).split("/") : [];
35
- const match = SUFFIX.exec(base);
40
+ const match = DEFINITION_FILE.exec(base);
36
41
  const segments = rel.split("/");
42
+ const ignored = TEST_FILE.test(base) || segments.includes("test") || segments.includes("tests") || segments.includes("__tests__") || segments.includes("node_modules") || rel.startsWith(`${generated}/`);
37
43
  return {
38
44
  settings,
39
45
  rel,
40
46
  base,
41
- servicesDir,
42
47
  inServices,
43
48
  service: parts.length > 1 ? parts[0] : void 0,
44
49
  rest: parts.slice(1),
45
50
  kind: match?.[2],
46
51
  stem: match?.[1],
47
- exempt: /\.(test|spec)\.[cm]?[jt]sx?$/.test(base) || segments.includes("test") || segments.includes("tests") || segments.includes("__tests__") || segments.includes("plugins") || segments.includes("node_modules") || rel.startsWith(`${generated}/`)
52
+ ignored,
53
+ exempt: ignored || segments.includes("plugins")
48
54
  };
49
55
  }
50
- function kebab(name) {
51
- return name.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/[_\s.]+/g, "-").toLowerCase();
52
- }
53
56
  /** A string literal's value, or a template literal's text when it has no expressions. */
54
57
  function stringValue(node) {
55
58
  if (node?.type === "Literal" && typeof node.value === "string") return node.value;
@@ -85,10 +88,10 @@ const DEFINE_FUNCTIONS = {
85
88
  defineTool: "tool",
86
89
  defineListener: "listener",
87
90
  definePlugin: "plugin",
91
+ defineResource: "resource",
88
92
  crud: "crud",
89
93
  sqliteTable: "table",
90
- pgTable: "table",
91
- mysqlTable: "table"
94
+ pgTable: "table"
92
95
  };
93
96
  const ATTACH_METHODS = {
94
97
  action: "action",
@@ -104,6 +107,7 @@ function definitionOf(call) {
104
107
  const callee = call.callee;
105
108
  if (callee.type === "Identifier" && DEFINE_FUNCTIONS[callee.name]) {
106
109
  const kind = DEFINE_FUNCTIONS[callee.name];
110
+ if (kind === "resource") return first?.type === "Identifier" ? attached(call, kind, first.name, second) : void 0;
107
111
  if (kind === "service" || kind === "table") {
108
112
  const name = stringValue(first);
109
113
  if (name === void 0) return void 0;
@@ -141,15 +145,18 @@ function definitionOf(call) {
141
145
  config: second
142
146
  };
143
147
  }
144
- if (first?.type !== "ObjectExpression") return void 0;
145
- const nameNode = getProperty(first, "name")?.value;
148
+ return attached(call, kind, owner, first);
149
+ }
150
+ function attached(call, kind, owner, config) {
151
+ if (config?.type !== "ObjectExpression") return void 0;
152
+ const nameNode = getProperty(config, "name")?.value;
146
153
  const name = stringValue(nameNode);
147
154
  if (kind === "resource" && name === void 0) return void 0;
148
155
  return {
149
156
  kind,
150
157
  call,
151
158
  owner,
152
- config: first,
159
+ config,
153
160
  name,
154
161
  nameNode
155
162
  };
@@ -193,7 +200,7 @@ function resolveImport(info, context, source) {
193
200
  if (!source.startsWith(".")) return void 0;
194
201
  return posix$1(relative(info.settings.root, resolve(dirname(context.filename), source)));
195
202
  }
196
- /** `name.method(...)` with a non-computed property. */
203
+ /** `name.method(...)` with a non-computed property, or a bare `fn(...)` (no `object`). */
197
204
  function memberCall(node) {
198
205
  if (node?.type !== "CallExpression") return void 0;
199
206
  const callee = node.callee;
@@ -204,37 +211,27 @@ function memberCall(node) {
204
211
  property: callee.property.name
205
212
  };
206
213
  }
214
+ // package.json
215
+ var version = "0.13.0";
207
216
  // src/lint/rules/checks.ts
208
- function rule$1(description, create, options = {}) {
209
- return {
210
- meta: {
211
- type: "problem",
212
- docs: { description },
213
- fixable: options.fixable,
214
- schema: options.schema ?? []
215
- },
216
- create
217
- };
218
- }
217
+ const MANIFEST_STEM = MANIFEST_FILE.replace(/\.ts$/, "");
218
+ /** This release's range, for the `brick` field example: `^0.12.0`. */
219
+ const BRICK_RANGE = `^${version.split(".").slice(0, 2).join(".")}.0`;
220
+ const rule$1 = (description, create, options) => defineRule("problem", description, create, options);
219
221
  /** Skip tests and generated files; local plugins are checked like app code. */
220
- function skip(context) {
221
- const info = fileInfo(context);
222
- return info.exempt && !info.rel.split("/").includes("plugins");
223
- }
222
+ const skip = (context) => fileInfo(context).ignored;
224
223
  const HANDLERS = [
225
224
  "action",
226
225
  "command",
227
226
  "tool"
228
227
  ];
229
- const BUILT_IN_ERRORS = /* @__PURE__ */ new Set([
230
- "BAD_REQUEST",
231
- "UNAUTHORIZED",
232
- "FORBIDDEN",
233
- "NOT_FOUND",
234
- "CONFLICT",
235
- "INTERNAL_SERVER_ERROR"
236
- ]);
237
- /** `error.NAME(...)`, the error helper handlers receive. */
228
+ /** What clients call: described in OpenAPI, MCP and the dashboard. */
229
+ const ENDPOINTS = [...HANDLERS, "socket"];
230
+ /** What gets the error helpers. */
231
+ const ERROR_KINDS = [...ENDPOINTS, "crud"];
232
+ /** What runs with a request or delivery context. */
233
+ const CTX_KINDS = [...ERROR_KINDS, "listener"];
234
+ const BUILT_IN_ERRORS = new Set(Object.keys(STANDARD_ERRORS));
238
235
  function errorHelper(node) {
239
236
  const call = memberCall(node);
240
237
  return call?.object === "error" ? call.property : void 0;
@@ -250,6 +247,7 @@ const WRITE_METHODS = /* @__PURE__ */ new Set([
250
247
  "update",
251
248
  "delete"
252
249
  ]);
250
+ const WRITE_CALL = new RegExp(`\\.(${[...WRITE_METHODS].join("|")})\\s*\\(`);
253
251
  const VERBS = new Set(`get list find search query count read load fetch check validate verify preview render export download
254
252
  create add insert import upload register invite book place submit send post publish issue open start schedule
255
253
  update set edit change rename move copy clone merge assign attach link mark toggle enable disable approve reject
@@ -275,15 +273,14 @@ const ROOM = /^[a-z][a-zA-Z0-9_-]*:./;
275
273
  const checkRules = {
276
274
  "no-server-in-client": rule$1("Browser code imports only @brickkit/core/client and the generated contract.", (context) => {
277
275
  const info = fileInfo(context);
278
- const web = info.settings.web.replace(/\/$/, "");
279
- if (!info.rel.startsWith(`${web}/`)) return {};
280
- const generated = info.settings.generated.replace(/\/$/, "");
276
+ if (!info.rel.startsWith(`web/`)) return {};
277
+ const { generated } = info.settings;
281
278
  const check = (node, source) => {
282
279
  if (typeof source !== "string") return;
283
280
  let allowed;
284
281
  if (source.startsWith(".")) {
285
282
  const path = resolveImport(info, context, source);
286
- allowed = path.startsWith(`${web}/`) || path.startsWith(`${generated}/`) && !path.endsWith("services.gen") && !path.endsWith("services.gen.ts");
283
+ allowed = path.startsWith(`web/`) || path.startsWith(`${generated}/`) && !path.endsWith(MANIFEST_STEM) && !path.endsWith("services.gen.ts");
287
284
  } else allowed = !/^(@brickkit\/|bun:|node:)/.test(source) || source === "@brickkit/core/client" || source === "@brickkit/core/tanstack-query";
288
285
  if (!allowed) context.report({
289
286
  node,
@@ -326,7 +323,7 @@ const checkRules = {
326
323
  }),
327
324
  "no-env-outside-secrets": rule$1("process.env and Bun.env are read only through defineSecret or config files.", (context) => {
328
325
  const info = fileInfo(context);
329
- if (info.exempt || /(^|\.)secrets\.[cm]?[jt]s$/.test(info.base) || /\.config\.[cm]?[jt]s$/.test(info.base)) return {};
326
+ if (info.ignored || /(^|\.)secrets\.[cm]?[jt]s$/.test(info.base) || /\.config\.[cm]?[jt]s$/.test(info.base)) return {};
330
327
  return { MemberExpression(node) {
331
328
  const object = node.object;
332
329
  const property = node.computed ? void 0 : node.property.name;
@@ -369,11 +366,7 @@ const checkRules = {
369
366
  return { CallExpression(node) {
370
367
  const name = errorHelper(node);
371
368
  if (!name || node.parent?.type !== "ExpressionStatement") return;
372
- if (!enclosingDefinition(node, [
373
- ...HANDLERS,
374
- "crud",
375
- "socket"
376
- ])) return;
369
+ if (!enclosingDefinition(node, ERROR_KINDS)) return;
377
370
  context.report({
378
371
  node,
379
372
  message: `Return the error: return error.${name}(...).`,
@@ -477,7 +470,7 @@ const checkRules = {
477
470
  const definition = definitionOf(node);
478
471
  if (definition?.kind !== "listener") return;
479
472
  const text = context.sourceCode.getText(definition.config);
480
- if (/\.(insert|update|delete)\s*\(/.test(text) && !/deliveryId|onConflictDo(Nothing|Update)/.test(text)) context.report({
473
+ if (WRITE_CALL.test(text) && !/deliveryId|onConflictDo(Nothing|Update)/.test(text)) context.report({
481
474
  node: definition.nameNode ?? node,
482
475
  message: "This listener writes without deliveryId or onConflictDoNothing; a redelivered event would write twice."
483
476
  });
@@ -493,7 +486,7 @@ const checkRules = {
493
486
  if (schemas?.type !== "ObjectExpression") continue;
494
487
  for (const property of schemas.properties) {
495
488
  const name = propertyName(property);
496
- if (name?.startsWith("$")) context.report({
489
+ if (name !== void 0 && isControlEvent(name)) context.report({
497
490
  node: property.key,
498
491
  message: `Socket ${key} event "${name}" starts with $, which is reserved for control messages.`
499
492
  });
@@ -631,12 +624,7 @@ const checkRules = {
631
624
  return { CallExpression(node) {
632
625
  const definition = definitionOf(node);
633
626
  if (!definition) return;
634
- if ([
635
- "action",
636
- "command",
637
- "tool",
638
- "socket"
639
- ].includes(definition.kind) && !getProperty(definition.config, "description")) context.report({
627
+ if (ENDPOINTS.includes(definition.kind) && !getProperty(definition.config, "description")) context.report({
640
628
  node: definition.nameNode ?? node,
641
629
  message: `Describe this ${definition.kind}: the description feeds OpenAPI, MCP and the dashboard.`
642
630
  });
@@ -700,12 +688,7 @@ const checkRules = {
700
688
  if (skip(context)) return {};
701
689
  return { CallExpression(node) {
702
690
  if (memberCall(node)?.object !== "console") return;
703
- if (!enclosingDefinition(node, [
704
- ...HANDLERS,
705
- "socket",
706
- "listener",
707
- "crud"
708
- ])) return;
691
+ if (!enclosingDefinition(node, CTX_KINDS)) return;
709
692
  context.report({
710
693
  node,
711
694
  message: "Log through ctx.logger, so the line carries the request and trace ids."
@@ -737,7 +720,7 @@ const checkRules = {
737
720
  });
738
721
  if (!stringValue(getProperty(config, "brick")?.value)) context.report({
739
722
  node: node.callee,
740
- message: "Declare the Brick versions this plugin supports: brick: \"^0.11.0\"."
723
+ message: `Declare the Brick versions this plugin supports: brick: "${BRICK_RANGE}".`
741
724
  });
742
725
  const options = getProperty(config, "options")?.value;
743
726
  if (!options) context.report({
@@ -763,17 +746,7 @@ const checkRules = {
763
746
  })
764
747
  };
765
748
  // src/lint/rules/layout.ts
766
- function rule(description, create, fixable) {
767
- return {
768
- meta: {
769
- type: "suggestion",
770
- docs: { description },
771
- fixable,
772
- schema: []
773
- },
774
- create
775
- };
776
- }
749
+ const rule = (description, create, fixable) => defineRule("suggestion", description, create, { fixable });
777
750
  /** Collect every definition in the file, then check them once the file is read. */
778
751
  function onDefinitions(check) {
779
752
  const definitions = [];
@@ -845,8 +818,8 @@ const rules = {
845
818
  message: `Move ${info.base} to ${where}.`
846
819
  });
847
820
  const kind = info.kind;
848
- if (!info.inServices || !info.service) return report(`${info.servicesDir}/<service>/, where it is registered`);
849
- const service = `${info.servicesDir}/${info.service}`;
821
+ if (!info.inServices || !info.service) return report(`${info.settings.services}/<service>/, where it is registered`);
822
+ const service = `${info.settings.services}/${info.service}`;
850
823
  const rest = info.rest;
851
824
  if (kind === "service" || kind === "events") {
852
825
  if (rest.length !== 1) report(`${service}/`);
@@ -875,11 +848,11 @@ const rules = {
875
848
  for (const definition of definitions) {
876
849
  if (definition.kind === "resource" && info.kind === "resource") {
877
850
  if (!folder || info.rest.length !== 3) continue;
878
- if (definition.name && kebab(definition.name) !== folder) context.report({
851
+ if (definition.name && kebabCase(definition.name) !== folder) context.report({
879
852
  node: definition.nameNode,
880
- message: `Resource "${definition.name}" lives in resources/${kebab(definition.name)}/, not resources/${folder}/.`
853
+ message: `Resource "${definition.name}" lives in resources/${kebabCase(definition.name)}/, not resources/${folder}/.`
881
854
  });
882
- const siblings = readdirSync(dirname(context.filename)).filter((file) => /\.resource\.[cm]?[jt]sx?$/.test(file));
855
+ const siblings = readdirSync(dirname(context.filename)).filter((file) => DEFINITION_FILE.exec(file)?.[2] === "resource");
883
856
  if (siblings.length > 1) context.report({
884
857
  node: definition.call,
885
858
  message: `resources/${folder}/ holds ${siblings.length} resources; give each its own folder.`
@@ -906,7 +879,7 @@ const rules = {
906
879
  return onDefinitions((definitions) => {
907
880
  for (const definition of definitions) {
908
881
  if (definition.kind !== info.kind || !definition.name) continue;
909
- const expected = kebab(definition.name.split(".").pop());
882
+ const expected = kebabCase(definition.name.split(".").pop());
910
883
  if (expected !== info.stem) context.report({
911
884
  node: definition.nameNode,
912
885
  message: `"${definition.name}" belongs in ${expected}.${info.kind}.ts, not ${info.base}.`
@@ -930,9 +903,9 @@ const rules = {
930
903
  const service = services[0];
931
904
  if (!service?.name || !info.inServices) return;
932
905
  const folder = info.rest.length === 1 ? info.service : void 0;
933
- if (folder !== kebab(service.name) && folder !== service.name) context.report({
906
+ if (!serviceFolders(service.name).includes(folder)) context.report({
934
907
  node: service.nameNode,
935
- message: `Service "${service.name}" lives in ${info.servicesDir}/${kebab(service.name)}/${kebab(service.name)}.service.ts.`
908
+ message: `Service "${service.name}" lives in ${info.settings.services}/${kebabCase(service.name)}/${kebabCase(service.name)}.service.ts.`
936
909
  });
937
910
  });
938
911
  }),
@@ -945,11 +918,11 @@ const rules = {
945
918
  if (!definition.owner) continue;
946
919
  const source = imports.get(definition.owner);
947
920
  const path = source && resolveImport(info, context, source);
948
- if (!path?.startsWith(`${info.servicesDir}/`)) continue;
949
- const owner = path.slice(info.servicesDir.length + 1).split("/")[0];
921
+ if (!path?.startsWith(`${info.settings.services}/`)) continue;
922
+ const owner = path.slice(info.settings.services.length + 1).split("/")[0];
950
923
  if (owner !== info.service) context.report({
951
924
  node: definition.call.callee,
952
- message: `This file is in ${info.service}/ but attaches to ${owner}; move it to ${info.servicesDir}/${owner}/.`
925
+ message: `This file is in ${info.service}/ but attaches to ${owner}; move it to ${info.settings.services}/${owner}/.`
953
926
  });
954
927
  }
955
928
  });
@@ -1055,12 +1028,37 @@ function resolveRules(presets = ["recommended"], overrides = {}) {
1055
1028
  if (name === "no-cross-service-tables" && severity !== "error") throw new Error(`Brick: brick/${ALWAYS_ERROR} is always an error and cannot be turned off`);
1056
1029
  resolved[`brick/${name}`] = severity;
1057
1030
  }
1031
+ resolved[`brick/${ALWAYS_ERROR}`] = "error";
1058
1032
  return resolved;
1059
1033
  }
1060
1034
  /** The file rules of a resolved rule set, as ESLint and oxlint take them. */
1061
1035
  function fileRules(resolved) {
1062
1036
  return Object.fromEntries(Object.entries(resolved).filter(([key]) => key.replace(/^brick\//, "") in rules));
1063
1037
  }
1064
- export { rules as a, resolveRules as i, PRESETS as n, fileRules as r, ALWAYS_ERROR as t };
1038
+ // src/lint/project.ts
1039
+ /** Rules, settings and ignores of a project, shared by brick lint and both linters. */
1040
+ function projectRules(project) {
1041
+ const lint = project.config.lint ?? {};
1042
+ let resolved;
1043
+ try {
1044
+ resolved = resolveRules(lint.presets, lint.rules);
1045
+ } catch (error) {
1046
+ throw new ConfigError(`brick.config.ts: lint.rules: ${error.message}`);
1047
+ }
1048
+ const from = (path) => relative(project.root, path).split(sep).join("/") || ".";
1049
+ const settings = {
1050
+ root: project.root,
1051
+ services: from(project.services),
1052
+ entry: from(project.entry),
1053
+ generated: from(project.generated)
1054
+ };
1055
+ return {
1056
+ resolved,
1057
+ rules: fileRules(resolved),
1058
+ settings,
1059
+ ignore: [...lint.ignore ?? [], `${settings.generated}/**`]
1060
+ };
1061
+ }
1062
+ export { rules as a, resolveRules as i, PRESETS as n, version as o, fileRules as r, serviceFolders as s, projectRules as t };
1065
1063
 
1066
- //# sourceMappingURL=presets.js.map
1064
+ //# sourceMappingURL=project.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project.js","names":["posix","rule"],"sources":["../src/lint/ast.ts","../package.json","../src/lint/rules/checks.ts","../src/lint/rules/layout.ts","../src/lint/presets.ts","../src/lint/project.ts"],"sourcesContent":["import { basename, dirname, relative, resolve, sep } from \"node:path\";\nimport { kebabCase } from \"@brickkit/core/client\";\nimport { PROJECT_DEFAULTS } from \"../config\";\nimport {\n DEFINITION_FILE,\n TEST_FILE,\n type DefinitionKind,\n} from \"../definitions\";\n\n// ESTree nodes as ESLint and oxlint hand them to rules. Kept loose on purpose:\n// the rules read a handful of fields and run under both linters.\n// oxlint-disable-next-line typescript/no-explicit-any\nexport type Node = any;\n\nexport interface RuleContext {\n filename: string;\n cwd?: string;\n settings?: { brick?: Partial<BrickSettings> };\n options?: unknown[];\n sourceCode: { getText(node?: Node): string };\n report(descriptor: {\n node: Node;\n message: string;\n fix?: (fixer: Fixer) => unknown;\n }): void;\n}\n\nexport interface Fixer {\n insertTextBefore(node: Node, text: string): unknown;\n insertTextAfter(node: Node, text: string): unknown;\n insertTextBeforeRange(range: [number, number], text: string): unknown;\n replaceText(node: Node, text: string): unknown;\n}\n\nexport interface Rule {\n meta: {\n type: \"problem\" | \"suggestion\" | \"layout\";\n docs: { description: string };\n fixable?: \"code\";\n schema: unknown[];\n };\n create(\n context: RuleContext,\n ): Record<string, ((node: Node) => void) | undefined>;\n}\n\nexport function defineRule(\n type: Rule[\"meta\"][\"type\"],\n description: string,\n create: Rule[\"create\"],\n options: { fixable?: \"code\"; schema?: unknown[] } = {},\n): Rule {\n return {\n meta: {\n type,\n docs: { description },\n fixable: options.fixable,\n schema: options.schema ?? [],\n },\n create,\n };\n}\n\n/** Paths from brick.config.ts, relative to `root`. Linters pass them in `settings.brick`. */\nexport interface BrickSettings {\n root: string;\n services: string;\n entry: string;\n generated: string;\n}\n\n/** Browser code folder, which may import only the client and the contract. */\nexport const WEB_DIR = \"web\";\n\nconst posix = (path: string) => path.split(sep).join(\"/\");\n\n/** The settings with Brick's default paths, each relative to the root without a trailing slash. */\nexport function brickSettings(context: RuleContext): BrickSettings {\n const given = context.settings?.brick ?? {};\n const root = given.root ?? context.cwd ?? process.cwd();\n const from = (path: string) => posix(relative(root, resolve(root, path)));\n return {\n root,\n services: from(given.services ?? PROJECT_DEFAULTS.services),\n entry: from(given.entry ?? PROJECT_DEFAULTS.entry),\n generated: from(given.generated ?? PROJECT_DEFAULTS.generated),\n };\n}\n\n/** The folders a service may live in: its kebab-case name, or the name itself. */\nexport const serviceFolders = (name: string) => [kebabCase(name), name];\n\nexport interface FileInfo {\n settings: BrickSettings;\n rel: string;\n base: string;\n inServices: boolean;\n /** Service folder name, for files under `<services>/<name>/`. */\n service?: string;\n /** Path segments after the service folder (the last one is the file). */\n rest: string[];\n /** Definition kind from the file suffix, and the name before it. */\n kind?: DefinitionKind;\n stem?: string;\n /** Tests, dependencies and generated files: no rule checks them. */\n ignored: boolean;\n /** Tests, local plugins and generated files are not app definitions. */\n exempt: boolean;\n}\n\nexport function fileInfo(context: RuleContext): FileInfo {\n const settings = brickSettings(context);\n const rel = posix(relative(settings.root, context.filename));\n const { services: servicesDir, generated } = settings;\n const base = basename(rel);\n const inServices = rel.startsWith(`${servicesDir}/`);\n const parts = inServices ? rel.slice(servicesDir.length + 1).split(\"/\") : [];\n const match = DEFINITION_FILE.exec(base);\n const segments = rel.split(\"/\");\n const ignored =\n TEST_FILE.test(base) ||\n segments.includes(\"test\") ||\n segments.includes(\"tests\") ||\n segments.includes(\"__tests__\") ||\n segments.includes(\"node_modules\") ||\n rel.startsWith(`${generated}/`);\n return {\n settings,\n rel,\n base,\n inServices,\n service: parts.length > 1 ? parts[0] : undefined,\n rest: parts.slice(1),\n kind: match?.[2] as DefinitionKind | undefined,\n stem: match?.[1],\n ignored,\n exempt: ignored || segments.includes(\"plugins\"),\n };\n}\n\n/** A string literal's value, or a template literal's text when it has no expressions. */\nexport function stringValue(node: Node): string | undefined {\n if (node?.type === \"Literal\" && typeof node.value === \"string\")\n return node.value;\n if (node?.type === \"TemplateLiteral\" && node.expressions.length === 0)\n return node.quasis[0]?.value.cooked ?? undefined;\n return undefined;\n}\n\nexport function propertyName(property: Node): string | undefined {\n if (property?.type !== \"Property\" || property.computed) return undefined;\n const key = property.key;\n if (key.type === \"Identifier\") return key.name;\n return typeof key.value === \"string\" ? key.value : undefined;\n}\n\nexport function getProperty(object: Node, name: string): Node | undefined {\n if (object?.type !== \"ObjectExpression\") return undefined;\n return object.properties.find(\n (property: Node) => propertyName(property) === name,\n );\n}\n\nexport function objectKeys(object: Node): string[] | undefined {\n if (object?.type !== \"ObjectExpression\") return undefined;\n const keys: string[] = [];\n for (const property of object.properties) {\n const name = propertyName(property);\n if (name === undefined) return undefined; // a spread or computed key: unknown keys\n keys.push(name);\n }\n return keys;\n}\n\n/** `t.Object(...)` or `Type.Object(...)`. */\nexport function isSchemaCall(node: Node, kind?: string): boolean {\n return (\n node?.type === \"CallExpression\" &&\n node.callee.type === \"MemberExpression\" &&\n !node.callee.computed &&\n node.callee.object.type === \"Identifier\" &&\n (node.callee.object.name === \"t\" || node.callee.object.name === \"Type\") &&\n (kind === undefined || node.callee.property.name === kind)\n );\n}\n\nexport interface Definition {\n kind: DefinitionKind | \"plugin\" | \"crud\";\n call: Node;\n /** The service or resource it attaches to (`orders` in `orders.action(...)`). */\n owner?: string;\n config?: Node;\n name?: string;\n nameNode?: Node;\n}\n\nexport const DEFINE_FUNCTIONS: Record<string, Definition[\"kind\"]> = {\n defineService: \"service\",\n defineAction: \"action\",\n defineTool: \"tool\",\n defineListener: \"listener\",\n definePlugin: \"plugin\",\n defineResource: \"resource\",\n crud: \"crud\",\n sqliteTable: \"table\",\n pgTable: \"table\",\n};\n\nconst ATTACH_METHODS: Record<string, Definition[\"kind\"]> = {\n action: \"action\",\n tool: \"tool\",\n socket: \"socket\",\n resource: \"resource\",\n command: \"command\",\n};\n\n/** What a call defines, matching the call shapes in the project structure. */\nexport function definitionOf(call: Node): Definition | undefined {\n if (call?.type !== \"CallExpression\") return undefined;\n const [first, second] = call.arguments;\n const callee = call.callee;\n if (callee.type === \"Identifier\" && DEFINE_FUNCTIONS[callee.name]) {\n const kind = DEFINE_FUNCTIONS[callee.name]!;\n // defineResource(service, config) is service.resource(config).\n if (kind === \"resource\")\n return first?.type === \"Identifier\"\n ? attached(call, kind, first.name, second)\n : undefined;\n if (kind === \"service\" || kind === \"table\") {\n const name = stringValue(first);\n if (name === undefined) return undefined;\n return { kind, call, name, nameNode: first, config: second };\n }\n if (first?.type !== \"ObjectExpression\") return undefined;\n const nameNode = getProperty(first, \"name\")?.value;\n return {\n kind,\n call,\n config: first,\n name: stringValue(nameNode),\n nameNode,\n };\n }\n if (\n callee.type !== \"MemberExpression\" ||\n callee.computed ||\n callee.object.type !== \"Identifier\"\n )\n return undefined;\n const kind = ATTACH_METHODS[callee.property.name];\n if (!kind) return undefined;\n const owner = callee.object.name;\n if (kind === \"command\") {\n const name = stringValue(first);\n if (name === undefined || second?.type !== \"ObjectExpression\")\n return undefined;\n return { kind, call, owner, name, nameNode: first, config: second };\n }\n return attached(call, kind, owner, first);\n}\n\nfunction attached(\n call: Node,\n kind: Definition[\"kind\"],\n owner: string,\n config: Node,\n): Definition | undefined {\n if (config?.type !== \"ObjectExpression\") return undefined;\n const nameNode = getProperty(config, \"name\")?.value;\n const name = stringValue(nameNode);\n // A resource needs its name and table; anything else called `.resource` is not one.\n if (kind === \"resource\" && name === undefined) return undefined;\n return { kind, call, owner, config, name, nameNode };\n}\n\n/** The nearest enclosing definition of one of `kinds`. */\nexport function enclosingDefinition(\n node: Node,\n kinds?: Definition[\"kind\"][],\n): Definition | undefined {\n for (let current = node.parent; current; current = current.parent) {\n const definition = definitionOf(current);\n if (definition && (!kinds || kinds.includes(definition.kind)))\n return definition;\n }\n return undefined;\n}\n\nexport function isFunction(node: Node): boolean {\n return (\n node?.type === \"FunctionDeclaration\" ||\n node?.type === \"FunctionExpression\" ||\n node?.type === \"ArrowFunctionExpression\"\n );\n}\n\nexport function enclosingFunction(node: Node): Node | undefined {\n for (let current = node.parent; current; current = current.parent)\n if (isFunction(current)) return current;\n return undefined;\n}\n\n/** Directives at the top of a function body or of the program. */\nexport function directivesOf(node: Node): string[] {\n const body =\n node?.type === \"Program\"\n ? node.body\n : node?.body?.type === \"BlockStatement\"\n ? node.body.body\n : [];\n const directives: string[] = [];\n for (const statement of body) {\n if (\n statement.type !== \"ExpressionStatement\" ||\n typeof statement.directive !== \"string\"\n )\n break;\n directives.push(statement.directive);\n }\n return directives;\n}\n\nexport function programOf(node: Node): Node {\n let current = node;\n while (current.parent) current = current.parent;\n return current;\n}\n\n/** Local name to import source, for the file's import declarations. */\nexport function importSources(program: Node): Map<string, string> {\n const sources = new Map<string, string>();\n for (const statement of program.body)\n if (statement.type === \"ImportDeclaration\")\n for (const specifier of statement.specifiers)\n sources.set(specifier.local.name, statement.source.value);\n return sources;\n}\n\n/** An import source resolved to a project-relative path; undefined for packages. */\nexport function resolveImport(\n info: FileInfo,\n context: RuleContext,\n source: string,\n): string | undefined {\n if (!source.startsWith(\".\")) return undefined;\n return posix(\n relative(info.settings.root, resolve(dirname(context.filename), source)),\n );\n}\n\n/** `name.method(...)` with a non-computed property, or a bare `fn(...)` (no `object`). */\nexport function memberCall(\n node: Node,\n): { object?: string; property: string } | undefined {\n if (node?.type !== \"CallExpression\") return undefined;\n const callee = node.callee;\n if (callee.type === \"Identifier\") return { property: callee.name };\n if (callee.type !== \"MemberExpression\" || callee.computed) return undefined;\n return {\n object:\n callee.object.type === \"Identifier\" ? callee.object.name : undefined,\n property: callee.property.name,\n };\n}\n","","import {\n defineRule,\n definitionOf,\n directivesOf,\n enclosingDefinition,\n enclosingFunction,\n fileInfo,\n getProperty,\n isFunction,\n isSchemaCall,\n memberCall,\n objectKeys,\n programOf,\n propertyName,\n resolveImport,\n stringValue,\n type Definition,\n type Node,\n type Rule,\n type RuleContext,\n WEB_DIR,\n} from \"../ast\";\nimport { isControlEvent, STANDARD_ERRORS } from \"@brickkit/core/client\";\nimport { MANIFEST_FILE } from \"../../definitions\";\nimport { version } from \"../../../package.json\";\n\nconst MANIFEST_STEM = MANIFEST_FILE.replace(/\\.ts$/, \"\");\n/** This release's range, for the `brick` field example: `^0.12.0`. */\nconst BRICK_RANGE = `^${version.split(\".\").slice(0, 2).join(\".\")}.0`;\n\nconst rule = (\n description: string,\n create: Rule[\"create\"],\n options?: { fixable?: \"code\"; schema?: unknown[] },\n) => defineRule(\"problem\", description, create, options);\n\n/** Skip tests and generated files; local plugins are checked like app code. */\nconst skip = (context: RuleContext) => fileInfo(context).ignored;\n\nconst HANDLERS: Definition[\"kind\"][] = [\"action\", \"command\", \"tool\"];\n/** What clients call: described in OpenAPI, MCP and the dashboard. */\nconst ENDPOINTS: Definition[\"kind\"][] = [...HANDLERS, \"socket\"];\n/** What gets the error helpers. */\nconst ERROR_KINDS: Definition[\"kind\"][] = [...ENDPOINTS, \"crud\"];\n/** What runs with a request or delivery context. */\nconst CTX_KINDS: Definition[\"kind\"][] = [...ERROR_KINDS, \"listener\"];\nconst BUILT_IN_ERRORS = new Set(Object.keys(STANDARD_ERRORS));\n\nfunction errorHelper(node: Node): string | undefined {\n const call = memberCall(node);\n return call?.object === \"error\" ? call.property : undefined;\n}\n\nfunction isEmit(node: Node): \"emitEvent\" | \"emit\" | undefined {\n const call = memberCall(node);\n if (!call) return undefined;\n if (call.property === \"emitEvent\" && call.object === undefined)\n return \"emitEvent\";\n if (call.property === \"emit\" && call.object && node.arguments.length >= 3)\n return \"emit\";\n return undefined;\n}\n\nconst WRITE_METHODS = new Set([\"insert\", \"update\", \"delete\"]);\nconst WRITE_CALL = new RegExp(`\\\\.(${[...WRITE_METHODS].join(\"|\")})\\\\s*\\\\(`);\n\n// Verbs an action name may start with (getUser, archive, importCsv).\nconst VERBS = new Set(\n `get list find search query count read load fetch check validate verify preview render export download\ncreate add insert import upload register invite book place submit send post publish issue open start schedule\nupdate set edit change rename move copy clone merge assign attach link mark toggle enable disable approve reject\naccept confirm complete cancel close finish stop end archive restore refund pay charge ship track sync refresh\nreset delete remove detach unlink clear purge run process handle compute calculate generate build apply sign\nlogin logout subscribe unsubscribe notify ping upsert transfer resend retry lock unlock save write report`.split(\n /\\s+/,\n ),\n);\nconst IRREGULAR_PAST = new Set(\n `sent paid built made sold bought won lost begun done held kept left met read run set shut spent taken given\nwritten chosen frozen broken spoken stolen hidden driven fallen forgotten known shown thrown drawn grown seen\nput cut hit quit split spread cast cost let upset rebuilt resent undone withdrawn`.split(\n /\\s+/,\n ),\n);\n/** definePlugin's parts that run while the plugin installs. */\nconst SETUP_PARTS = [\"app\", \"service\", \"resource\", \"tables\"];\nconst CONNECTION_CLASS = /(Client|Pool|Redis|Connection|Socket)$/;\nconst CONNECTION_CALL = /^(connect|createClient|createPool|createConnection)$/;\nconst isPastTense = (word: string) =>\n word.endsWith(\"ed\") || IRREGULAR_PAST.has(word);\nconst lastWord = (name: string) =>\n (name.match(/[A-Z]?[a-z0-9]+$/)?.[0] ?? name).toLowerCase();\nconst firstWord = (name: string) => name.match(/^[a-z0-9]+/)?.[0] ?? \"\";\nconst ROOM = /^[a-z][a-zA-Z0-9_-]*:./;\n\nexport const checkRules: Record<string, Rule> = {\n \"no-server-in-client\": rule(\n \"Browser code imports only @brickkit/core/client and the generated contract.\",\n (context) => {\n const info = fileInfo(context);\n if (!info.rel.startsWith(`${WEB_DIR}/`)) return {};\n const { generated } = info.settings;\n const check = (node: Node, source: unknown) => {\n if (typeof source !== \"string\") return;\n let allowed: boolean;\n if (source.startsWith(\".\")) {\n const path = resolveImport(info, context, source)!;\n allowed =\n path.startsWith(`${WEB_DIR}/`) ||\n (path.startsWith(`${generated}/`) &&\n !path.endsWith(MANIFEST_STEM) &&\n !path.endsWith(MANIFEST_FILE));\n } else\n allowed =\n !/^(@brickkit\\/|bun:|node:)/.test(source) ||\n source === \"@brickkit/core/client\" ||\n source === \"@brickkit/core/tanstack-query\";\n if (!allowed)\n context.report({\n node,\n message: `Browser code imports only @brickkit/core/client and the generated contract, not \"${source}\".`,\n });\n };\n return {\n ImportDeclaration: (node) => {\n if (node.importKind !== \"type\") check(node.source, node.source.value);\n },\n ExportNamedDeclaration: (node) =>\n node.source && check(node.source, node.source.value),\n ExportAllDeclaration: (node) => check(node.source, node.source.value),\n ImportExpression: (node) =>\n check(node.source, stringValue(node.source)),\n };\n },\n ),\n\n \"no-global-context\": rule(\n \"No module-level mutable singletons for dependencies (the setOrdersContext pattern); use deps.\",\n (context) => {\n if (skip(context)) return {};\n const mutable = new Set<string>();\n const reported = new Set<string>();\n return {\n Program(program: Node) {\n for (let statement of program.body) {\n if (statement.type === \"ExportNamedDeclaration\")\n statement = statement.declaration;\n if (\n statement?.type === \"VariableDeclaration\" &&\n statement.kind !== \"const\"\n )\n for (const declarator of statement.declarations)\n if (declarator.id.type === \"Identifier\")\n mutable.add(declarator.id.name);\n }\n },\n AssignmentExpression(node: Node) {\n const name =\n node.left.type === \"Identifier\" ? node.left.name : undefined;\n if (!name || !mutable.has(name) || reported.has(name)) return;\n if (!enclosingFunction(node)) return;\n reported.add(name);\n context.report({\n node,\n message: `Module-level \"${name}\" is set from a function, a global context. Declare it in the service's deps (port<T>()) and read ctx.deps, or useDeps() in listeners and workflow steps.`,\n });\n },\n };\n },\n ),\n\n \"no-env-outside-secrets\": rule(\n \"process.env and Bun.env are read only through defineSecret or config files.\",\n (context) => {\n const info = fileInfo(context);\n if (\n info.ignored ||\n /(^|\\.)secrets\\.[cm]?[jt]s$/.test(info.base) ||\n /\\.config\\.[cm]?[jt]s$/.test(info.base)\n )\n return {};\n return {\n MemberExpression(node: Node) {\n const object = node.object;\n const property = node.computed ? undefined : node.property.name;\n const env =\n (object.type === \"Identifier\" &&\n (object.name === \"process\" || object.name === \"Bun\") &&\n property === \"env\") ||\n (object.type === \"MetaProperty\" && property === \"env\");\n if (env)\n context.report({\n node,\n message:\n \"Read configuration through defineSecret() in secrets.ts, not from the environment directly.\",\n });\n },\n };\n },\n ),\n\n \"action-schemas\": rule(\n \"Every action, command and tool declares input and output.\",\n (context) => {\n if (skip(context)) return {};\n return {\n CallExpression(node: Node) {\n const definition = definitionOf(node);\n if (!definition || !HANDLERS.includes(definition.kind)) return;\n const missing = [\"input\", \"output\"].filter(\n (key) => !getProperty(definition.config, key),\n );\n if (missing.length)\n context.report({\n node: definition.nameNode ?? node,\n message: `${definition.kind} ${definition.name ? `\"${definition.name}\" ` : \"\"}declares no ${missing.join(\" or \")}.`,\n });\n },\n };\n },\n ),\n\n \"declared-errors\": rule(\n \"Every error.X() names an entry in that action's errors or a built-in error.\",\n (context) => {\n if (skip(context)) return {};\n return {\n CallExpression(node: Node) {\n const name = errorHelper(node);\n if (!name) return;\n const definition = enclosingDefinition(node, HANDLERS);\n if (!definition) return;\n const errors = getProperty(definition.config, \"errors\")?.value;\n const declared = errors ? objectKeys(errors) : [];\n if (declared === undefined) return; // errors built elsewhere: unknown\n if (!BUILT_IN_ERRORS.has(name) && !declared.includes(name))\n context.report({\n node: node.callee.property,\n message: `error.${name} is not in this ${definition.kind}'s errors or the built-in errors.`,\n });\n },\n };\n },\n ),\n\n \"return-error\": rule(\n \"Error helpers are returned (return error.NOT_FOUND()), so TypeScript narrows the value after them.\",\n (context) => {\n if (skip(context)) return {};\n return {\n CallExpression(node: Node) {\n const name = errorHelper(node);\n if (!name || node.parent?.type !== \"ExpressionStatement\") return;\n if (!enclosingDefinition(node, ERROR_KINDS)) return;\n context.report({\n node,\n message: `Return the error: return error.${name}(...).`,\n fix: (fixer) => fixer.insertTextBefore(node, \"return \"),\n });\n },\n };\n },\n { fixable: \"code\" },\n ),\n\n \"path-params-in-input\": rule(\n \"Each :param in path is a field of input.\",\n (context) => {\n if (skip(context)) return {};\n return {\n CallExpression(node: Node) {\n const definition = definitionOf(node);\n if (!definition || !HANDLERS.includes(definition.kind)) return;\n const pathNode = getProperty(definition.config, \"path\")?.value;\n const path = stringValue(pathNode);\n if (!path) return;\n const input = getProperty(definition.config, \"input\")?.value;\n const fields = isSchemaCall(input, \"Object\")\n ? objectKeys(input.arguments[0])\n : input\n ? undefined // a schema built elsewhere: fields unknown\n : [];\n if (!fields) return;\n const record = getProperty(definition.config, \"record\")?.value?.value;\n for (const [, param] of path.matchAll(/:([A-Za-z_$][\\w$]*)/g))\n if (\n !fields.includes(param!) &&\n !(record === true && param === \"id\")\n )\n context.report({\n node: pathNode,\n message: `Path parameter :${param} is not a field of input.`,\n });\n },\n };\n },\n ),\n\n \"get-is-read-only\": rule(\n \"GET actions don't insert, update, delete or emit.\",\n (context) => {\n if (skip(context)) return {};\n return {\n CallExpression(node: Node) {\n const call = memberCall(node);\n if (!call) return;\n // A write on the database or a transaction, not Map.delete and the like.\n const write =\n node.callee.type === \"MemberExpression\" &&\n WRITE_METHODS.has(call.property) &&\n /\\b(db|tx)\\b/.test(context.sourceCode.getText(node.callee.object));\n if (!write && !isEmit(node)) return;\n const definition = enclosingDefinition(node, HANDLERS);\n const method = stringValue(\n getProperty(definition?.config, \"method\")?.value,\n );\n if (method === \"GET\")\n context.report({\n node,\n message: `A GET ${definition!.kind} only reads; ${call.property}() writes. Use POST.`,\n });\n },\n };\n },\n ),\n\n \"emit-in-transaction\": rule(\n \"emitEvent or live.emit inside a transaction callback passes { tx } or { after: tx }.\",\n (context) => {\n if (skip(context)) return {};\n return {\n CallExpression(node: Node) {\n const kind = isEmit(node);\n if (!kind) return;\n let tx: string | undefined;\n let inside = false;\n for (\n let fn = enclosingFunction(node);\n fn;\n fn = enclosingFunction(fn)\n ) {\n const parent = fn.parent;\n if (\n parent?.type === \"CallExpression\" &&\n parent.arguments[0] === fn &&\n memberCall(parent)?.property === \"transaction\"\n ) {\n inside = true;\n if (fn.params[0]?.type === \"Identifier\") tx = fn.params[0].name;\n break;\n }\n }\n if (!inside) return;\n const options = node.arguments[3];\n const keys = objectKeys(options);\n if (\n options &&\n (!keys || keys.includes(\"tx\") || keys.includes(\"after\"))\n )\n return;\n const option = kind === \"emitEvent\" ? \"tx\" : \"after\";\n context.report({\n node,\n message: `Inside a transaction, pass { ${option}: ${tx ?? \"tx\"} } so the ${kind === \"emitEvent\" ? \"event is recorded in it\" : \"message is sent on commit\"}.`,\n fix:\n tx && !options && node.arguments.length === 3\n ? (fixer) =>\n fixer.insertTextAfter(\n node.arguments[2],\n `, { ${option}: ${tx} }`,\n )\n : undefined,\n });\n },\n };\n },\n { fixable: \"code\" },\n ),\n\n \"deterministic-workflow\": rule(\n \"No Date.now, Math.random, fetch or database access in a workflow function outside its steps.\",\n (context) => {\n if (skip(context)) return {};\n const inWorkflow = (node: Node) => {\n for (let fn = enclosingFunction(node); fn; fn = enclosingFunction(fn)) {\n const directives = directivesOf(fn);\n if (directives.includes(\"use step\")) return false;\n if (directives.includes(\"use workflow\")) return true;\n }\n return directivesOf(programOf(node)).includes(\"use workflow\");\n };\n const report = (node: Node, what: string) => {\n if (inWorkflow(node))\n context.report({\n node,\n message: `${what} in a workflow function is not replayed the same way; move it into a step.`,\n });\n };\n return {\n CallExpression(node: Node) {\n const call = memberCall(node);\n if (!call) return;\n if (call.object === \"Date\" && call.property === \"now\")\n report(node, \"Date.now()\");\n else if (call.object === \"Math\" && call.property === \"random\")\n report(node, \"Math.random()\");\n else if (call.object === undefined && call.property === \"fetch\")\n report(node, \"fetch()\");\n },\n NewExpression(node: Node) {\n if (node.callee.name === \"Date\" && node.arguments.length === 0)\n report(node, \"new Date()\");\n },\n MemberExpression(node: Node) {\n if (!node.computed && node.property.name === \"db\")\n report(node, \"Database access\");\n },\n };\n },\n ),\n\n \"idempotent-listener\": rule(\n \"Listener writes are keyed by deliveryId or use onConflictDoNothing, because delivery is at least once.\",\n (context) => {\n if (skip(context)) return {};\n return {\n CallExpression(node: Node) {\n const definition = definitionOf(node);\n if (definition?.kind !== \"listener\") return;\n const text = context.sourceCode.getText(definition.config);\n if (\n WRITE_CALL.test(text) &&\n !/deliveryId|onConflictDo(Nothing|Update)/.test(text)\n )\n context.report({\n node: definition.nameNode ?? node,\n message:\n \"This listener writes without deliveryId or onConflictDoNothing; a redelivered event would write twice.\",\n });\n },\n };\n },\n ),\n\n \"socket-schemas\": rule(\n \"Socket schemas have no format or transforms, and event names don't start with $.\",\n (context) => {\n if (skip(context)) return {};\n return {\n CallExpression(node: Node) {\n const definition = definitionOf(node);\n if (definition?.kind !== \"socket\") return;\n for (const key of [\"input\", \"output\"]) {\n const schemas = getProperty(definition.config, key)?.value;\n if (schemas?.type !== \"ObjectExpression\") continue;\n for (const property of schemas.properties) {\n const name = propertyName(property);\n if (name !== undefined && isControlEvent(name))\n context.report({\n node: property.key,\n message: `Socket ${key} event \"${name}\" starts with $, which is reserved for control messages.`,\n });\n // shortcut: a text search; a schema imported from another file is not checked.\n const text = context.sourceCode.getText(property.value);\n if (/\\bformat\\s*:|\\b(Transform|Decode|Encode)\\s*\\(/.test(text))\n context.report({\n node: property.value,\n message: `Socket ${key} \"${name}\" uses a format or transform, which sockets cannot check.`,\n });\n }\n }\n },\n };\n },\n ),\n\n \"no-unregistered-format\": rule(\n \"A TypeBox format is used only when it is registered with FormatRegistry.\",\n (context) => {\n if (skip(context)) return {};\n const options = (context.options?.[0] ?? {}) as { formats?: string[] };\n const registered = new Set(options.formats ?? []);\n const used: Node[] = [];\n return {\n CallExpression(node: Node) {\n const call = memberCall(node);\n if (call?.object === \"FormatRegistry\" && call.property === \"Set\") {\n const name = stringValue(node.arguments[0]);\n if (name) registered.add(name);\n }\n if (!isSchemaCall(node)) return;\n for (const argument of node.arguments) {\n const format = getProperty(argument, \"format\");\n if (stringValue(format?.value)) used.push(format.value);\n }\n },\n \"Program:exit\"() {\n for (const node of used)\n if (!registered.has(node.value))\n context.report({\n node,\n message: `Format \"${node.value}\" is not registered; call FormatRegistry.Set(\"${node.value}\", ...) or list it in this rule's formats option.`,\n });\n },\n };\n },\n {\n schema: [\n {\n type: \"object\",\n properties: { formats: { type: \"array\", items: { type: \"string\" } } },\n additionalProperties: false,\n },\n ],\n },\n ),\n\n \"no-floating-calls\": rule(\n \"Promises from service calls and emitEvent are awaited.\",\n (context) => {\n if (skip(context)) return {};\n const proxies = new Set<string>();\n const candidates: Node[] = [];\n return {\n VariableDeclarator(node: Node) {\n const call = memberCall(node.init);\n if (node.id.type === \"Identifier\" && call?.property === \"useService\")\n proxies.add(node.id.name);\n },\n ExpressionStatement(node: Node) {\n if (node.expression.type === \"CallExpression\")\n candidates.push(node.expression);\n },\n \"Program:exit\"() {\n for (const call of candidates) {\n const target = memberCall(call);\n const floating =\n (target?.property === \"emitEvent\" && !target.object) ||\n (target?.object !== undefined && proxies.has(target.object));\n if (!floating) continue;\n const async = enclosingFunction(call)?.async === true;\n context.report({\n node: call,\n message: `Await this call (or mark it with void): an unawaited promise loses its errors.`,\n fix: async\n ? (fixer) => fixer.insertTextBefore(call, \"await \")\n : undefined,\n });\n }\n },\n };\n },\n { fixable: \"code\" },\n ),\n\n \"explicit-access\": rule(\n \"Every action and CRUD resource sets access, and record actions and commands set `access`; nothing is public by omission.\",\n (context) => {\n if (skip(context)) return {};\n return {\n CallExpression(node: Node) {\n const definition = definitionOf(node);\n if (!definition) return;\n // Record actions and commands load a row, so they always need access.\n const record =\n definition.kind === \"command\" ||\n (definition.kind === \"action\" &&\n getProperty(definition.config, \"record\")?.value?.value === true);\n if (record && !getProperty(definition.config, \"access\"))\n context.report({\n node: definition.nameNode ?? node,\n message: `Set access on this ${definition.kind === \"command\" ? \"command\" : \"record action\"}: access: { scope } or \"public\"; it decides which rows it can load.`,\n });\n else if (\n definition.kind === \"action\" &&\n !getProperty(definition.config, \"authorize\") &&\n !getProperty(definition.config, \"access\")\n )\n context.report({\n node: definition.nameNode ?? node,\n message: `Set access on this action: authorize, or access: \"public\" when anyone may call it.`,\n });\n if (\n definition.kind === \"crud\" &&\n !getProperty(definition.config, \"access\")\n )\n context.report({\n node,\n message:\n 'Set access on this CRUD resource ({ authorize, scope } or \"public\").',\n });\n },\n };\n },\n ),\n\n \"socket-authorize\": rule(\"Sockets declare authorize and join.\", (context) => {\n if (skip(context)) return {};\n return {\n CallExpression(node: Node) {\n const definition = definitionOf(node);\n if (definition?.kind !== \"socket\") return;\n const missing = [\"authorize\", \"join\"].filter(\n (key) => !getProperty(definition.config, key),\n );\n if (missing.length)\n context.report({\n node: definition.nameNode ?? node,\n message: `Socket declares no ${missing.join(\" or \")}; add ${missing.length > 1 ? \"them\" : \"it\"}.`,\n });\n },\n };\n }),\n\n \"no-wildcard-origins\": rule(\n 'No \"*\" in allowedOrigins or trustedOrigins.',\n (context) => {\n if (skip(context)) return {};\n return {\n Property(node: Node) {\n const name = propertyName(node);\n if (name !== \"allowedOrigins\" && name !== \"trustedOrigins\") return;\n const values =\n node.value.type === \"ArrayExpression\"\n ? node.value.elements\n : [node.value];\n for (const value of values)\n if (stringValue(value) === \"*\")\n context.report({\n node: value,\n message: `\"*\" in ${name} lets any site in; list the origins.`,\n });\n },\n };\n },\n ),\n\n \"strict-input\": rule(\n \"Input objects set additionalProperties: false.\",\n (context) => {\n if (skip(context)) return {};\n return {\n CallExpression(node: Node) {\n const definition = definitionOf(node);\n if (!definition || !HANDLERS.includes(definition.kind)) return;\n const input = getProperty(definition.config, \"input\")?.value;\n if (!isSchemaCall(input, \"Object\")) return;\n const [fields, options] = input.arguments;\n const strict = getProperty(options, \"additionalProperties\")?.value;\n if (strict?.type === \"Literal\" && strict.value === false) return;\n if (options && options.type !== \"ObjectExpression\") return;\n context.report({\n node: input,\n message: \"Set additionalProperties: false on this input object.\",\n fix: strict\n ? undefined\n : !options\n ? (fixer) =>\n fixer.insertTextAfter(\n fields,\n \", { additionalProperties: false }\",\n )\n : options.properties.length === 0\n ? (fixer) =>\n fixer.replaceText(\n options,\n \"{ additionalProperties: false }\",\n )\n : (fixer) =>\n fixer.insertTextAfter(\n options.properties.at(-1),\n \", additionalProperties: false\",\n ),\n });\n },\n };\n },\n { fixable: \"code\" },\n ),\n\n \"description-required\": rule(\n \"Actions, commands, tools, sockets and events have a description, which feeds OpenAPI, MCP and the dashboard.\",\n (context) => {\n if (skip(context)) return {};\n return {\n CallExpression(node: Node) {\n const definition = definitionOf(node);\n if (!definition) return;\n if (\n ENDPOINTS.includes(definition.kind) &&\n !getProperty(definition.config, \"description\")\n )\n context.report({\n node: definition.nameNode ?? node,\n message: `Describe this ${definition.kind}: the description feeds OpenAPI, MCP and the dashboard.`,\n });\n const events =\n definition.kind === \"service\" || definition.kind === \"plugin\"\n ? getProperty(definition.config, \"events\")?.value\n : undefined;\n for (const event of events?.properties ?? []) {\n const schema = event.value;\n if (!isSchemaCall(schema)) continue;\n const described = schema.arguments.some((argument: Node) =>\n getProperty(argument, \"description\"),\n );\n if (!described)\n context.report({\n node: event.key,\n message: `Describe event \"${propertyName(event)}\" with { description } on its schema.`,\n });\n }\n },\n };\n },\n ),\n\n naming: rule(\n \"Actions are camelCase verbs (getUser), events are service.pastTense (orders.shipped), and rooms are prefix:value.\",\n (context) => {\n if (skip(context)) return {};\n const checkRoom = (node: Node) => {\n const text =\n node?.type === \"TemplateLiteral\"\n ? node.quasis[0].value.cooked + (node.expressions.length ? \"x\" : \"\")\n : stringValue(node);\n if (text !== undefined && !ROOM.test(text))\n context.report({\n node,\n message: `Room \"${text}\" should be prefix:value, such as doc:42 or user:7.`,\n });\n };\n return {\n CallExpression(node: Node) {\n const definition = definitionOf(node);\n if (\n (definition?.kind === \"action\" || definition?.kind === \"command\") &&\n definition.name\n ) {\n const name = definition.name;\n if (\n !/^[a-z][a-zA-Z0-9]*$/.test(name) ||\n !VERBS.has(firstWord(name))\n )\n context.report({\n node: definition.nameNode,\n message: `${definition.kind} \"${name}\" should be a camelCase verb, such as getUser or archive.`,\n });\n }\n if (definition?.kind === \"service\") {\n const events = getProperty(definition.config, \"events\")?.value;\n for (const name of objectKeys(events) ?? [])\n if (\n !/^[a-z][a-zA-Z0-9]*$/.test(name) ||\n !isPastTense(lastWord(name))\n )\n context.report({\n node: getProperty(events, name).key,\n message: `Event \"${name}\" should be camelCase past tense, such as shipped or itemAdded.`,\n });\n }\n if (definition?.kind === \"socket\") {\n const rooms = getProperty(definition.config, \"rooms\")?.value;\n const list = isFunction(rooms) ? rooms.body : rooms;\n if (list?.type === \"ArrayExpression\")\n for (const element of list.elements) checkRoom(element);\n }\n const kind = isEmit(node);\n if (kind === \"emitEvent\") {\n const name = stringValue(node.arguments[1]);\n if (\n name !== undefined &&\n (!/^[a-z][a-zA-Z0-9]*\\.[a-z][a-zA-Z0-9]*$/.test(name) ||\n !isPastTense(lastWord(name)))\n )\n context.report({\n node: node.arguments[1],\n message: `Event \"${name}\" should be service.pastTense, such as orders.shipped.`,\n });\n }\n if (kind === \"emit\") {\n const room = node.arguments[0];\n if (room.type === \"ArrayExpression\")\n room.elements.forEach(checkRoom);\n else checkRoom(room);\n }\n },\n };\n },\n ),\n\n \"no-console\": rule(\n \"Handlers log through the request logger, so lines carry the request and trace ids.\",\n (context) => {\n if (skip(context)) return {};\n return {\n CallExpression(node: Node) {\n if (memberCall(node)?.object !== \"console\") return;\n if (!enclosingDefinition(node, CTX_KINDS)) return;\n context.report({\n node,\n message:\n \"Log through ctx.logger, so the line carries the request and trace ids.\",\n });\n },\n };\n },\n ),\n\n \"plugin-manifest\": rule(\n 'definePlugin has a scoped name, a brick range and declared options with descriptions; its setup functions are synchronous and open no connections outside on(\"start\").',\n (context) => {\n if (skip(context)) return {};\n const connection = (node: Node) => {\n const opens =\n node.type === \"NewExpression\"\n ? node.callee.type === \"Identifier\" &&\n CONNECTION_CLASS.test(node.callee.name)\n : CONNECTION_CALL.test(memberCall(node)?.property ?? \"\");\n if (!opens) return;\n // Inside on(\"start\", ...) is the place; inside a setup part is not.\n for (let current = node.parent; current; current = current.parent) {\n const call = memberCall(current);\n if (\n call?.property === \"on\" &&\n stringValue(current.arguments[0]) === \"start\"\n )\n return;\n if (\n current.type === \"Property\" &&\n SETUP_PARTS.includes(propertyName(current) ?? \"\") &&\n definitionOf(current.parent?.parent)?.kind === \"plugin\"\n )\n return context.report({\n node,\n message:\n 'Open connections in on(\"start\") (and close them in on(\"stop\")), not while the plugin installs.',\n });\n }\n };\n return {\n NewExpression: connection,\n CallExpression(node: Node) {\n connection(node);\n const definition = definitionOf(node);\n if (definition?.kind !== \"plugin\") return;\n const config = definition.config;\n if (!definition.name || !/^@[^/\\s]+\\/[^/\\s]+$/.test(definition.name))\n context.report({\n node: definition.nameNode ?? node,\n message:\n 'Give the plugin a scoped package name, such as \"@acme/brick-comments\".',\n });\n if (!stringValue(getProperty(config, \"brick\")?.value))\n context.report({\n node: node.callee,\n message: `Declare the Brick versions this plugin supports: brick: \"${BRICK_RANGE}\".`,\n });\n const options = getProperty(config, \"options\")?.value;\n if (!options)\n context.report({\n node: node.callee,\n message:\n \"Declare the plugin's options as a TypeBox schema (options: t.Object({ ... })).\",\n });\n else if (\n isSchemaCall(options, \"Object\") &&\n options.arguments[0]?.type === \"ObjectExpression\"\n )\n for (const option of options.arguments[0].properties) {\n const schema = option.value;\n const settings = isSchemaCall(schema)\n ? schema.arguments.at(-1)\n : undefined;\n if (!getProperty(settings, \"description\"))\n context.report({\n node: option,\n message: `Describe option \"${propertyName(option) ?? \"?\"}\": add { description: \"...\" } to its schema.`,\n });\n }\n for (const key of [\"setup\", ...SETUP_PARTS]) {\n const setup = getProperty(config, key)?.value;\n if (isFunction(setup) && setup.async)\n context.report({\n node: setup,\n message: `${key} must be synchronous; open connections in on(\"start\").`,\n });\n }\n },\n };\n },\n ),\n};\n","import { readdirSync } from \"node:fs\";\nimport { dirname } from \"node:path\";\nimport { kebabCase } from \"@brickkit/core/client\";\nimport { DEFINITION_FILE } from \"../../definitions\";\nimport {\n defineRule,\n definitionOf,\n fileInfo,\n importSources,\n resolveImport,\n serviceFolders,\n type Definition,\n type Node,\n type Rule,\n} from \"../ast\";\n\nconst rule = (description: string, create: Rule[\"create\"], fixable?: \"code\") =>\n defineRule(\"suggestion\", description, create, { fixable });\n\n/** Collect every definition in the file, then check them once the file is read. */\nfunction onDefinitions(\n check: (definitions: Definition[], program: Node) => void,\n) {\n const definitions: Definition[] = [];\n return {\n CallExpression(node: Node) {\n const definition = definitionOf(node);\n if (definition) definitions.push(definition);\n },\n \"Program:exit\"(program: Node) {\n check(definitions, program);\n },\n };\n}\n\nconst SERVICE_FOLDERS: Partial<Record<string, string>> = {\n action: \"actions\",\n tool: \"tools\",\n socket: \"sockets\",\n listener: \"listeners\",\n workflow: \"workflows\",\n step: \"workflows\",\n table: \"tables\",\n};\n\nexport const layoutRules: Record<string, Rule> = {\n \"one-action-per-file\": rule(\n \"A *.action.ts file defines exactly one action, and actions are defined nowhere else.\",\n (context) => {\n const info = fileInfo(context);\n if (info.exempt) return {};\n return onDefinitions((definitions, program) => {\n const actions = definitions.filter((d) => d.kind === \"action\");\n if (info.kind !== \"action\") {\n for (const action of actions)\n context.report({\n node: action.call,\n message: `Define this action in its own *.action.ts file.`,\n });\n return;\n }\n if (actions.length === 0)\n context.report({\n node: program,\n message: `${info.base} defines no action; a *.action.ts file defines exactly one.`,\n });\n for (const extra of actions.slice(1))\n context.report({\n node: extra.call,\n message: `${info.base} already defines an action; move this one to its own *.action.ts file.`,\n });\n });\n },\n ),\n\n \"file-suffixes\": rule(\n \"Each kind of definition goes in a file with its suffix: .service, .action, .command, .tool, .socket, .listener, .workflow, .step, .resource, .table, .events.\",\n (context) => {\n const info = fileInfo(context);\n if (info.exempt) return {};\n return onDefinitions((definitions) => {\n for (const definition of definitions) {\n const kind = definition.kind;\n // Actions are one-action-per-file's; plugins and crud() have no file of their own.\n if (kind === \"action\" || kind === \"plugin\" || kind === \"crud\")\n continue;\n // A resource file holds its resource's child tables too.\n if (kind === \"table\" && info.kind === \"resource\") continue;\n if (info.kind !== kind)\n context.report({\n node: definition.call,\n message: `Define this ${kind} in a *.${kind}.ts file.`,\n });\n }\n });\n },\n ),\n\n \"kind-folders\": rule(\n \"Files sit in their kind's folder, as in the project structure.\",\n (context) => {\n const info = fileInfo(context);\n if (info.exempt || !info.kind) return {};\n return {\n Program(program: Node) {\n const report = (where: string) =>\n context.report({\n node: program,\n message: `Move ${info.base} to ${where}.`,\n });\n const kind = info.kind!;\n if (!info.inServices || !info.service)\n return report(\n `${info.settings.services}/<service>/, where it is registered`,\n );\n const service = `${info.settings.services}/${info.service}`;\n const rest = info.rest;\n if (kind === \"service\" || kind === \"events\") {\n if (rest.length !== 1) report(`${service}/`);\n return;\n }\n if (rest[0] === \"resources\") {\n const resource = `${service}/resources/${rest[1]}`;\n if ((kind === \"resource\" || kind === \"table\") && rest.length === 3)\n return;\n if (kind === \"action\" && rest.length === 4 && rest[2] === \"actions\")\n return;\n if (\n kind === \"command\" &&\n rest.length === 4 &&\n rest[2] === \"commands\"\n )\n return;\n if (kind === \"resource\" || kind === \"table\")\n return report(`${resource}/`);\n if (kind === \"action\" || kind === \"command\")\n return report(`${resource}/${kind}s/`);\n return report(`${service}/${SERVICE_FOLDERS[kind]}/`);\n }\n if (kind === \"command\" || kind === \"resource\")\n return report(`${service}/resources/<resource>/`);\n const folder = SERVICE_FOLDERS[kind];\n if (rest.length !== 2 || rest[0] !== folder)\n report(`${service}/${folder}/`);\n },\n };\n },\n ),\n\n \"resource-folder\": rule(\n \"Each .resource.ts is alone in resources/<name>/, and resource actions and commands attach to their own folder's resource.\",\n (context) => {\n const info = fileInfo(context);\n if (info.exempt || !info.inServices) return {};\n const inResource = info.rest[0] === \"resources\" && info.rest.length >= 3;\n const folder = inResource ? info.rest[1] : undefined;\n return onDefinitions((definitions, program) => {\n const imports = importSources(program);\n for (const definition of definitions) {\n if (definition.kind === \"resource\" && info.kind === \"resource\") {\n if (!folder || info.rest.length !== 3) continue; // kind-folders reports it\n if (definition.name && kebabCase(definition.name) !== folder)\n context.report({\n node: definition.nameNode,\n message: `Resource \"${definition.name}\" lives in resources/${kebabCase(definition.name)}/, not resources/${folder}/.`,\n });\n const siblings = readdirSync(dirname(context.filename)).filter(\n (file) => DEFINITION_FILE.exec(file)?.[2] === \"resource\",\n );\n if (siblings.length > 1)\n context.report({\n node: definition.call,\n message: `resources/${folder}/ holds ${siblings.length} resources; give each its own folder.`,\n });\n }\n if (\n definition.kind === \"command\" &&\n !(folder && info.rest[2] === \"commands\")\n )\n context.report({\n node: definition.call,\n message:\n \"Commands exist only inside a resource folder: resources/<name>/commands/.\",\n });\n if (\n folder &&\n (definition.kind === \"action\" || definition.kind === \"command\") &&\n definition.owner\n ) {\n const source = imports.get(definition.owner);\n const owner = source\n ?.split(\"/\")\n .pop()\n ?.replace(/\\.[cm]?[jt]sx?$/, \"\");\n if (source && owner !== `${folder}.resource`)\n context.report({\n node: definition.call.callee,\n message: `Files in resources/${folder}/ attach to the ${folder} resource (import it from \"../${folder}.resource\").`,\n });\n }\n }\n });\n },\n ),\n\n \"file-name-matches\": rule(\n \"The file name is the kebab-case of the definition's name, without its owner.\",\n (context) => {\n const info = fileInfo(context);\n if (info.exempt || !info.kind) return {};\n return onDefinitions((definitions) => {\n for (const definition of definitions) {\n if (definition.kind !== info.kind || !definition.name) continue;\n const expected = kebabCase(definition.name.split(\".\").pop()!);\n if (expected !== info.stem)\n context.report({\n node: definition.nameNode,\n message: `\"${definition.name}\" belongs in ${expected}.${info.kind}.ts, not ${info.base}.`,\n });\n }\n });\n },\n ),\n\n \"service-folder\": rule(\n \"One defineService per *.service.ts, inside services/<name>/, where the folder name is the service name.\",\n (context) => {\n const info = fileInfo(context);\n if (info.exempt || info.kind !== \"service\") return {};\n return onDefinitions((definitions, program) => {\n const services = definitions.filter((d) => d.kind === \"service\");\n if (services.length === 0)\n context.report({\n node: program,\n message: `${info.base} has no defineService(); a *.service.ts file defines exactly one.`,\n });\n for (const extra of services.slice(1))\n context.report({\n node: extra.call,\n message: `${info.base} already defines a service; give this one its own folder.`,\n });\n const service = services[0];\n if (!service?.name || !info.inServices) return;\n const folder = info.rest.length === 1 ? info.service : undefined;\n if (!serviceFolders(service.name).includes(folder!))\n context.report({\n node: service.nameNode,\n message: `Service \"${service.name}\" lives in ${info.settings.services}/${kebabCase(service.name)}/${kebabCase(service.name)}.service.ts.`,\n });\n });\n },\n ),\n\n \"colocate-in-service\": rule(\n \"Everything under services/<name>/ attaches to that service, or to one of its resources.\",\n (context) => {\n const info = fileInfo(context);\n if (info.exempt || !info.service) return {};\n return onDefinitions((definitions, program) => {\n const imports = importSources(program);\n for (const definition of definitions) {\n if (!definition.owner) continue;\n const source = imports.get(definition.owner);\n const path = source && resolveImport(info, context, source);\n if (!path?.startsWith(`${info.settings.services}/`)) continue;\n const owner = path\n .slice(info.settings.services.length + 1)\n .split(\"/\")[0];\n if (owner !== info.service)\n context.report({\n node: definition.call.callee,\n message: `This file is in ${info.service}/ but attaches to ${owner}; move it to ${info.settings.services}/${owner}/.`,\n });\n }\n });\n },\n ),\n\n \"workflow-directive\": rule(\n 'Workflow files use \"use workflow\", step files \"use step\", and the directives appear nowhere else.',\n (context) => {\n const info = fileInfo(context);\n if (info.exempt) return {};\n const found: Node[] = [];\n return {\n ExpressionStatement(node: Node) {\n if (\n node.directive === \"use workflow\" ||\n node.directive === \"use step\"\n )\n found.push(node);\n },\n \"Program:exit\"(program: Node) {\n const own =\n info.kind === \"workflow\"\n ? \"use workflow\"\n : info.kind === \"step\"\n ? \"use step\"\n : undefined;\n for (const node of found)\n if (node.directive !== own)\n context.report({\n node,\n message: `\"${node.directive}\" belongs in a *.${node.directive === \"use step\" ? \"step\" : \"workflow\"}.ts file.`,\n });\n if (own && !found.some((node) => node.directive === own))\n context.report({\n node: program,\n message: `${info.base} must start with \"${own}\".`,\n fix: (fixer) =>\n fixer.insertTextBeforeRange([0, 0], `\"${own}\";\\n\\n`),\n });\n },\n };\n },\n \"code\",\n ),\n};\n","import { checkRules } from \"./rules/checks\";\nimport { layoutRules } from \"./rules/layout\";\nimport type { LintPreset, LintSeverity } from \"../config\";\n\nexport type Severity = LintSeverity;\nexport type PresetName = LintPreset;\n\n/** Rules that check one file at a time, in ESLint, oxlint or brick lint. */\nexport const rules = { ...layoutRules, ...checkRules };\n\n/** Rules that need the loaded app; only `brick lint` runs them. */\nexport const APP_RULES = [\n \"single-app-entry\",\n \"no-cross-service-tables\",\n \"unique-names\",\n \"declared-events\",\n \"test-colocated\",\n] as const;\n\n/** Always an error: no preset or rule setting turns it down. */\nexport const ALWAYS_ERROR = \"no-cross-service-tables\";\n\nconst RECOMMENDED: Record<string, Severity> = {\n \"workflow-directive\": \"error\",\n \"no-cross-service-tables\": \"error\",\n \"unique-names\": \"error\",\n \"no-server-in-client\": \"error\",\n \"action-schemas\": \"error\",\n \"declared-errors\": \"error\",\n \"return-error\": \"error\",\n \"path-params-in-input\": \"error\",\n \"get-is-read-only\": \"error\",\n \"emit-in-transaction\": \"error\",\n \"declared-events\": \"error\",\n \"deterministic-workflow\": \"error\",\n \"idempotent-listener\": \"warn\",\n \"socket-schemas\": \"error\",\n \"no-unregistered-format\": \"error\",\n \"no-floating-calls\": \"error\",\n \"explicit-access\": \"error\",\n \"socket-authorize\": \"error\",\n \"no-wildcard-origins\": \"error\",\n};\n\n/** Every preset, with app rules, by bare rule name. */\nexport const PRESETS: Record<PresetName, Record<string, Severity>> = {\n recommended: RECOMMENDED,\n layout: {\n \"one-action-per-file\": \"error\",\n \"file-suffixes\": \"error\",\n \"kind-folders\": \"error\",\n \"resource-folder\": \"error\",\n \"file-name-matches\": \"error\",\n \"service-folder\": \"error\",\n \"colocate-in-service\": \"error\",\n \"single-app-entry\": \"error\",\n },\n strict: {\n ...RECOMMENDED,\n \"no-global-context\": \"error\",\n \"no-env-outside-secrets\": \"error\",\n \"strict-input\": \"error\",\n \"description-required\": \"error\",\n naming: \"error\",\n \"no-console\": \"error\",\n \"test-colocated\": \"error\",\n },\n plugin: {\n \"plugin-manifest\": \"error\",\n \"explicit-access\": \"error\",\n \"description-required\": \"error\",\n },\n};\n\nconst KNOWN = new Set<string>([...Object.keys(rules), ...APP_RULES]);\n\n/**\n * Severity of every rule, keyed `brick/<rule>`, from presets then per-rule\n * settings. Throws on an unknown rule, or on turning down no-cross-service-tables.\n */\nexport function resolveRules(\n presets: PresetName[] = [\"recommended\"],\n overrides: Record<string, Severity> = {},\n): Record<string, Severity> {\n const resolved: Record<string, Severity> = {};\n for (const preset of presets) {\n if (!PRESETS[preset]) throw new Error(`Brick: unknown preset \"${preset}\"`);\n for (const [name, severity] of Object.entries(PRESETS[preset]))\n resolved[`brick/${name}`] = severity;\n }\n for (const [key, severity] of Object.entries(overrides)) {\n const name = key.replace(/^brick\\//, \"\");\n if (!KNOWN.has(name)) throw new Error(`Brick: unknown rule \"${key}\"`);\n if (name === ALWAYS_ERROR && severity !== \"error\")\n throw new Error(\n `Brick: brick/${ALWAYS_ERROR} is always an error and cannot be turned off`,\n );\n resolved[`brick/${name}`] = severity;\n }\n resolved[`brick/${ALWAYS_ERROR}`] = \"error\";\n return resolved;\n}\n\n/** The file rules of a resolved rule set, as ESLint and oxlint take them. */\nexport function fileRules(\n resolved: Record<string, Severity>,\n): Record<string, Severity> {\n return Object.fromEntries(\n Object.entries(resolved).filter(\n ([key]) => key.replace(/^brick\\//, \"\") in rules,\n ),\n );\n}\n","import { relative, sep } from \"node:path\";\nimport type { BrickSettings } from \"./ast\";\nimport { ConfigError, type LoadedConfig } from \"../config\";\nimport { fileRules, resolveRules, type Severity } from \"./presets\";\n\n/** Rules, settings and ignores of a project, shared by brick lint and both linters. */\nexport function projectRules(project: LoadedConfig) {\n const lint = project.config.lint ?? {};\n let resolved: Record<string, Severity>;\n try {\n resolved = resolveRules(lint.presets, lint.rules);\n } catch (error) {\n throw new ConfigError(\n `brick.config.ts: lint.rules: ${(error as Error).message}`,\n );\n }\n const from = (path: string) =>\n relative(project.root, path).split(sep).join(\"/\") || \".\";\n const settings: BrickSettings = {\n root: project.root,\n services: from(project.services),\n entry: from(project.entry),\n generated: from(project.generated),\n };\n return {\n resolved,\n rules: fileRules(resolved),\n settings,\n ignore: [...(lint.ignore ?? []), `${settings.generated}/**`],\n };\n}\n"],"mappings":";;;;;;AA8CA,SAAgB,WACd,MACA,aACA,QACA,UAAoD,CAAC,GAC/C;CACN,OAAO;EACL,MAAM;GACJ;GACA,MAAM,EAAE,YAAY;GACpB,SAAS,QAAQ;GACjB,QAAQ,QAAQ,UAAU,CAAC;EAC7B;EACA;CACF;AACF;AAaA,MAAMA,WAAS,SAAiB,KAAK,MAAM,GAAG,CAAC,CAAC,KAAK,GAAG;;AAGxD,SAAgB,cAAc,SAAqC;CACjE,MAAM,QAAQ,QAAQ,UAAU,SAAS,CAAC;CAC1C,MAAM,OAAO,MAAM,QAAQ,QAAQ,OAAO,QAAQ,IAAI;CACtD,MAAM,QAAQ,SAAiBA,QAAM,SAAS,MAAM,QAAQ,MAAM,IAAI,CAAC,CAAC;CACxE,OAAO;EACL;EACA,UAAU,KAAK,MAAM,YAAY,iBAAiB,QAAQ;EAC1D,OAAO,KAAK,MAAM,SAAS,iBAAiB,KAAK;EACjD,WAAW,KAAK,MAAM,aAAa,iBAAiB,SAAS;CAC/D;AACF;;AAGA,MAA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