@happyvertical/smrt-core 0.45.2 → 0.46.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 (70) hide show
  1. package/AGENTS.md +1 -0
  2. package/agents/generators.md +0 -1
  3. package/dist/browser.d.ts +2 -1
  4. package/dist/browser.d.ts.map +1 -1
  5. package/dist/embedded-write-queue.d.ts.map +1 -1
  6. package/dist/embedded-write-queue.js +20 -1
  7. package/dist/embedded-write-queue.js.map +1 -1
  8. package/dist/generators/custom-action.d.ts +71 -39
  9. package/dist/generators/custom-action.d.ts.map +1 -1
  10. package/dist/generators/custom-action.js +71 -39
  11. package/dist/generators/custom-action.js.map +1 -1
  12. package/dist/generators/index.d.ts +0 -2
  13. package/dist/generators/index.d.ts.map +1 -1
  14. package/dist/generators/index.js +2 -3
  15. package/dist/generators/mcp.d.ts.map +1 -1
  16. package/dist/generators/mcp.js +1 -1
  17. package/dist/generators/mcp.js.map +1 -1
  18. package/dist/generators/tenant-gate.d.ts +33 -9
  19. package/dist/generators/tenant-gate.d.ts.map +1 -1
  20. package/dist/generators/tenant-gate.js +2 -1
  21. package/dist/generators/tenant-gate.js.map +1 -1
  22. package/dist/generators.js +2 -3
  23. package/dist/index.d.ts +3 -1
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +3 -3
  26. package/dist/knowledge.js +28 -16
  27. package/dist/knowledge.js.map +1 -1
  28. package/dist/manifest/static-manifest.js +1 -1
  29. package/dist/manifest/static-manifest.js.map +1 -1
  30. package/dist/manifest/store.js +1 -1
  31. package/dist/manifest.json +1 -1
  32. package/dist/migrations/framework-base-tables.d.ts +148 -0
  33. package/dist/migrations/framework-base-tables.d.ts.map +1 -0
  34. package/dist/migrations/framework-base-tables.js +419 -0
  35. package/dist/migrations/framework-base-tables.js.map +1 -0
  36. package/dist/migrations/index.d.ts +1 -0
  37. package/dist/migrations/index.d.ts.map +1 -1
  38. package/dist/migrations/index.js +2 -1
  39. package/dist/migrations.js +2 -1
  40. package/dist/postgres-permissions.d.ts +40 -0
  41. package/dist/postgres-permissions.d.ts.map +1 -0
  42. package/dist/postgres-permissions.js +353 -0
  43. package/dist/postgres-permissions.js.map +1 -0
  44. package/dist/registry/framework-base-classes.d.ts.map +1 -1
  45. package/dist/registry/framework-base-classes.js +4 -1
  46. package/dist/registry/framework-base-classes.js.map +1 -1
  47. package/dist/scripts/create-wrappers.js +0 -5
  48. package/dist/smrt-knowledge.json +7 -8
  49. package/dist/testing/database.d.ts +6 -1
  50. package/dist/testing/database.d.ts.map +1 -1
  51. package/dist/testing/database.js +9 -1
  52. package/dist/testing/database.js.map +1 -1
  53. package/dist/vite-plugin/api-client-entries.d.ts.map +1 -1
  54. package/dist/vite-plugin/api-client-entries.js +16 -14
  55. package/dist/vite-plugin/api-client-entries.js.map +1 -1
  56. package/dist/vite-plugin/index.d.ts.map +1 -1
  57. package/dist/vite-plugin/index.js +2 -166
  58. package/dist/vite-plugin/index.js.map +1 -1
  59. package/dist/vite-plugin/sveltekit-generator.d.ts +3 -2
  60. package/dist/vite-plugin/sveltekit-generator.d.ts.map +1 -1
  61. package/dist/vite-plugin/sveltekit-generator.js +20 -24
  62. package/dist/vite-plugin/sveltekit-generator.js.map +1 -1
  63. package/dist/vite-plugin/templates/default-ui.ts +22 -1
  64. package/dist/vite-plugin/web-collections.d.ts.map +1 -1
  65. package/dist/vite-plugin/web-collections.js.map +1 -1
  66. package/package.json +4 -9
  67. package/dist/generators/cli.d.ts +0 -155
  68. package/dist/generators/cli.d.ts.map +0 -1
  69. package/dist/generators/cli.js +0 -473
  70. package/dist/generators/cli.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { MAX_LIST_LIMIT, buildDefaultListOrderBy } from "../query-bounds.js";
2
- import { resolveCustomActionMetadata, resolveCustomActionNames } from "../generators/custom-action.js";
2
+ import { CRUD_OPERATIONS, isCrudOperation, resolveCustomActionMetadata, resolveCustomActionNames } from "../generators/custom-action.js";
3
3
  import { isFrameworkBaseClass } from "../registry/framework-base-classes.js";
4
4
  import { generateConditionalGetRouteHelper } from "../generators/conditional-get.js";
5
5
  import { AUTO_GENERATED_ROUTE_HEADER } from "./route-header.js";
@@ -16,13 +16,6 @@ import { isAbsolute, join, relative, sep } from "node:path";
16
16
  * Generates real TypeScript files in src/routes/api/ based on discovered SMRT objects
17
17
  */
18
18
  var BIOME_LINE_WIDTH = 80;
19
- var STANDARD_API_ACTIONS = [
20
- "list",
21
- "get",
22
- "create",
23
- "update",
24
- "delete"
25
- ];
26
19
  var GITIGNORE_MANAGED_BLOCK_START = "# BEGIN SMRT auto-generated routes (Vite plugin)";
27
20
  var GITIGNORE_MANAGED_BLOCK_END = "# END SMRT auto-generated routes (Vite plugin)";
28
21
  var LEGACY_GITIGNORE_HEADER = "# SMRT auto-generated routes (from Vite plugin)";
@@ -1169,7 +1162,7 @@ async function generateRoutesForObject(projectRoot, className, objectDef, manife
1169
1162
  const itemRoute = generateItemRouteTemplate(projectRoot, className, objectDef, manifest, includedActions, options, join(routeDir, "[id]"));
1170
1163
  generatedRoutePaths.push(writeRoute(join(routeDir, "[id]"), "+server.ts", itemRoute));
1171
1164
  }
1172
- const customActions = Object.entries(objectDef.methods).filter(([name, method]) => !STANDARD_API_ACTIONS.includes(name) && method.isPublic && shouldIncludeInApi(name, apiConfig));
1165
+ const customActions = Object.entries(objectDef.methods).filter(([name, method]) => !isCrudOperation(name) && method.isPublic && shouldIncludeInApi(name, apiConfig));
1173
1166
  const actionSpecs = [];
1174
1167
  for (const [actionName, actionDef] of customActions) {
1175
1168
  const routeConfig = resolveApiActionRouteConfig(actionName, actionDef, apiConfig, { kebabRoutes: options.kebabRoutes });
@@ -1207,7 +1200,7 @@ async function generateCollectionRoutesForObject(projectRoot, className, objectD
1207
1200
  const routeDir = join(projectRoot, options.routesDir, objectDef.collection);
1208
1201
  const lookupClassName = findItemClassRegistryKey(className, objectDef, manifest);
1209
1202
  const lookupObjectDef = findObjectDefByRegistryKey(manifest, lookupClassName);
1210
- const customActions = Object.entries(objectDef.methods).filter(([name, method]) => !STANDARD_API_ACTIONS.includes(name) && method.isPublic && shouldIncludeInApi(name, apiConfig));
1203
+ const customActions = Object.entries(objectDef.methods).filter(([name, method]) => !isCrudOperation(name) && method.isPublic && shouldIncludeInApi(name, apiConfig));
1211
1204
  if (customActions.length === 0) return generatedRoutePaths;
1212
1205
  const actionSpecs = [];
1213
1206
  for (const [actionName, actionDef] of customActions) {
@@ -1242,10 +1235,10 @@ async function generateCollectionRoutesForObject(projectRoot, className, objectD
1242
1235
  */
1243
1236
  function resolveStandardCrudActions(apiConfig) {
1244
1237
  if (apiConfig === false) return [];
1245
- if (apiConfig === true || apiConfig === void 0) return [...STANDARD_API_ACTIONS];
1246
- if (typeof apiConfig !== "object") return [...STANDARD_API_ACTIONS];
1238
+ if (apiConfig === true || apiConfig === void 0) return [...CRUD_OPERATIONS];
1239
+ if (typeof apiConfig !== "object" || apiConfig === null) return [...CRUD_OPERATIONS];
1247
1240
  const config = apiConfig;
1248
- let crud = config.include ? config.include.filter((a) => STANDARD_API_ACTIONS.includes(a)) : [...STANDARD_API_ACTIONS];
1241
+ let crud = Array.isArray(config.include) ? config.include.filter((a) => isCrudOperation(a)) : [...CRUD_OPERATIONS];
1249
1242
  if (Array.isArray(config.exclude)) {
1250
1243
  const exclude = config.exclude;
1251
1244
  crud = crud.filter((a) => !exclude.includes(a));
@@ -1282,7 +1275,7 @@ function resolveApiActionSet(objectDef, manifest) {
1282
1275
  const objectIsCollectionClass = manifest ? isCollectionManifestClass(manifest, objectDef) : isCollectionClass(objectDef);
1283
1276
  const actions = objectIsCollectionClass ? /* @__PURE__ */ new Set() : new Set(resolveStandardCrudActions(apiConfig));
1284
1277
  for (const [name, method] of Object.entries(objectDef.methods || {})) {
1285
- if (STANDARD_API_ACTIONS.includes(name)) continue;
1278
+ if (isCrudOperation(name)) continue;
1286
1279
  if (!method.isPublic) continue;
1287
1280
  if (!shouldIncludeInApi(name, apiConfig)) continue;
1288
1281
  const scope = resolveCustomActionMetadata({
@@ -1317,9 +1310,11 @@ function resolveApiActionSet(objectDef, manifest) {
1317
1310
  *
1318
1311
  * **Bare `cli: true`/`cli: {}`** (#2638, the new case this lint now
1319
1312
  * inspects): every public custom method minus exclude, exactly the "every
1320
- * public method minus exclude" resolution `CLIGenerator.listCommands()`
1321
- * already applies (via `resolveCustomActionNames`, reused not
1322
- * reimplemented) -- lifecycle methods excluded, same as everywhere else.
1313
+ * public method minus exclude" resolution this function shares with
1314
+ * `packages/core/src/generators/custom-action.ts`'s `resolveCustomActionNames`
1315
+ * -- lifecycle methods excluded, same as everywhere else. (Pre-#2664, core's
1316
+ * now-retired `CLIGenerator.listCommands()` applied the same resolution via
1317
+ * that helper too.)
1323
1318
  * CRUD verbs are NOT checked in this branch: a class that closes its API
1324
1319
  * entirely (`api: false`) while keeping a default-open, CLI/MCP-only admin
1325
1320
  * surface (`cli: true`/omitted) is a common, intentional combination (see
@@ -1332,13 +1327,13 @@ function resolveApiActionSet(objectDef, manifest) {
1332
1327
  function resolveCliActionSet(objectDef) {
1333
1328
  const cliConfig = objectDef.decoratorConfig?.cli;
1334
1329
  if (cliConfig === false) return /* @__PURE__ */ new Set();
1335
- const included = typeof cliConfig === "object" ? cliConfig.include : void 0;
1336
- const excluded = typeof cliConfig === "object" && Array.isArray(cliConfig.exclude) ? cliConfig.exclude : [];
1330
+ const included = typeof cliConfig === "object" && cliConfig !== null ? cliConfig.include : void 0;
1331
+ const excluded = typeof cliConfig === "object" && cliConfig !== null && Array.isArray(cliConfig.exclude) ? cliConfig.exclude : [];
1337
1332
  if (included) return new Set(included.filter((cmd) => !excluded.includes(cmd)));
1338
1333
  return resolveCustomActionNames(Object.entries(objectDef.methods || {}), {
1339
1334
  include: void 0,
1340
1335
  exclude: excluded
1341
- }, STANDARD_API_ACTIONS);
1336
+ }, CRUD_OPERATIONS);
1342
1337
  }
1343
1338
  /**
1344
1339
  * Inspect a manifest and return classes whose effective CLI command set —
@@ -1356,7 +1351,7 @@ function findCliApiCoherenceViolations(manifest) {
1356
1351
  for (const [className, objectDef] of Object.entries(manifest.objects)) {
1357
1352
  const cliConfig = objectDef.decoratorConfig?.cli;
1358
1353
  if (cliConfig === false) continue;
1359
- if (typeof cliConfig === "object" && cliConfig.skipApiCheck) continue;
1354
+ if (typeof cliConfig === "object" && cliConfig !== null && cliConfig.skipApiCheck) continue;
1360
1355
  const effectiveCliCommands = resolveCliActionSet(objectDef);
1361
1356
  if (effectiveCliCommands.size === 0) continue;
1362
1357
  const apiActionSet = resolveApiActionSet(objectDef, manifest);
@@ -1377,8 +1372,9 @@ function findCliApiCoherenceViolations(manifest) {
1377
1372
  * This is deliberately narrower than `findCliApiCoherenceViolations` above.
1378
1373
  * That function is now fully correct for the broader `cli: true`/`cli: {}`
1379
1374
  * default surface too (#2638: same "every public method minus exclude"
1380
- * resolution `listCommands()` uses, so a bare `cli: true` is inspected the
1381
- * same as an explicit `include`). But `smrtPlugin()`'s default
1375
+ * resolution core's now-retired `CLIGenerator.listCommands()` used (#2664),
1376
+ * so a bare `cli: true` is inspected the same as an explicit `include`).
1377
+ * But `smrtPlugin()`'s default
1382
1378
  * `validateCliApiCoherence: true` calls this THROWING gate unconditionally
1383
1379
  * from every consuming package's own build (`configResolved`,
1384
1380
  * `vite-plugin/index.ts`) -- and a full-monorepo build during #2638
@@ -1400,7 +1396,7 @@ function findCliApiCoherenceViolations(manifest) {
1400
1396
  function validateCliIncludeAgainstApi(manifest) {
1401
1397
  const violations = findCliApiCoherenceViolations(manifest).filter(({ className }) => {
1402
1398
  const cliConfig = manifest.objects[className]?.decoratorConfig?.cli;
1403
- return typeof cliConfig === "object" && Array.isArray(cliConfig.include) && cliConfig.include.length > 0;
1399
+ return typeof cliConfig === "object" && cliConfig !== null && Array.isArray(cliConfig.include) && cliConfig.include.length > 0;
1404
1400
  });
1405
1401
  if (violations.length === 0) return;
1406
1402
  const messages = violations.flatMap(({ className, unreachable }) => unreachable.map((action) => `[smrt] ${className}.${action} is exposed as a CLI command but is not exposed via the api.\n Either:\n - Add '${action}' to api.include, or\n - Remove '${action}' from cli.include / add it to cli.exclude.\n The CLI invokes methods over HTTP; methods without API routes are unreachable.\n If this CLI is intentionally invoked in-process (no HTTP), set\n \`cli: { skipApiCheck: true }\` on the @smrt() decorator to acknowledge.`));