@getstrata/cli 2.2.46 → 2.2.47

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @getstrata/cli changelog
2
2
 
3
+ ## 2.2.47
4
+
5
+ - Keep companion module API routes under API_PREFIX and HTML routes separate; render through the public namespaced ViewRenderer with layout data and HTMX handling. Plain module paths remain unchanged.
6
+ - Generate services against current ORM updateByIdOrThrow/deleteById APIs with explicit HTTP not-found mapping.
7
+ - Exercise installed CLI scaffolding, generated-app typechecking, API-only OpenAPI, permission boundaries and real scoped CRUD across SQLite, MySQL and PostgreSQL.
8
+
3
9
  ## 2.2.46
4
10
 
5
11
  - Align published runtime and starter dependency pins with the 2.2.46 generated-app contracts.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getstrata/cli",
3
- "version": "2.2.46",
3
+ "version": "2.2.47",
4
4
  "description": "Strata CLI: framework commands for Bun apps (dev, start, migrate, run)",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -54,8 +54,8 @@
54
54
  ],
55
55
  "scripts": {},
56
56
  "peerDependencies": {
57
- "@getstrata/bootstrap": "^2.2.46",
58
- "@getstrata/core": "^2.2.46"
57
+ "@getstrata/bootstrap": "^2.2.47",
58
+ "@getstrata/core": "^2.2.47"
59
59
  },
60
60
  "publishConfig": {
61
61
  "access": "public"
@@ -87,7 +87,8 @@ export default ${moduleName}Repository;
87
87
  ],
88
88
  [
89
89
  "service.ts",
90
- `import ${moduleName}Repository from "./repository";
90
+ `import { NotFoundError } from "@getstrata/core/errors/http";
91
+ import ${moduleName}Repository from "./repository";
91
92
  import type { ${moduleName}Record } from "./types";
92
93
  import type { PaginatedResult } from "@getstrata/core/pagination";
93
94
 
@@ -102,7 +103,7 @@ class ${moduleName}Service {
102
103
  }
103
104
 
104
105
  findByIdOrThrow(id: number): Promise<${moduleName}Record> {
105
- return this.repository.findByIdOrThrow(id);
106
+ return this.repository.findByIdOrThrow(id, () => new NotFoundError("${moduleName} not found."));
106
107
  }
107
108
 
108
109
  create(input: { name: string }): Promise<${moduleName}Record> {
@@ -110,11 +111,13 @@ class ${moduleName}Service {
110
111
  }
111
112
 
112
113
  update(id: number, input: { name?: string }): Promise<${moduleName}Record> {
113
- return this.repository.update(id, input);
114
+ return this.repository.updateByIdOrThrow(id, input, () => new NotFoundError("${moduleName} not found."));
114
115
  }
115
116
 
116
- delete(id: number): Promise<void> {
117
- return this.repository.delete(id);
117
+ async delete(id: number): Promise<void> {
118
+ if (!(await this.repository.deleteById(id))) {
119
+ throw new NotFoundError("${moduleName} not found.");
120
+ }
118
121
  }
119
122
  }
120
123
 
@@ -400,7 +403,7 @@ export default ${moduleName}Controller;
400
403
  `import type { HttpKernel } from "@getstrata/bootstrap/httpKernel";
401
404
  import type { AppDependencies, CachedJson } from "@getstrata/core/contracts/di";
402
405
  import type { RouteHandler } from "@getstrata/core/http/middleware";
403
- import ${moduleName}Controller from "./controller";
406
+ ${withWeb ? 'import { apiPrefix } from "@getstrata/core/runtime/appKeyPrefix";\n' : ""}import ${moduleName}Controller from "./controller";
404
407
 
405
408
  function create${moduleName}Routes(
406
409
  dependencies: AppDependencies,
@@ -408,16 +411,17 @@ function create${moduleName}Routes(
408
411
  kernel: HttpKernel,
409
412
  ) {
410
413
  const controller = new ${moduleName}Controller(dependencies, cachedJson);
414
+ ${withWeb ? ` const apiBase = \`\${apiPrefix()}/${pluralSlug}\`;\n` : ""}
411
415
 
412
416
  return {
413
- "/${pluralSlug}": {
417
+ ${withWeb ? "[apiBase]" : `"/${pluralSlug}"`}: {
414
418
  GET: controller.index,
415
419
  POST: kernel.wrapAbility(
416
420
  "${pluralSlug}:create",
417
421
  controller.store as unknown as RouteHandler,
418
422
  ),
419
423
  },
420
- "/${pluralSlug}/:id": {
424
+ ${withWeb ? `[\`\${apiBase}/:id\`]` : `"/${pluralSlug}/:id"`}: {
421
425
  GET: controller.show,
422
426
  PATCH: kernel.wrapAbility(
423
427
  "${pluralSlug}:update",
@@ -519,10 +523,8 @@ export type { ${moduleName}Record } from "./types";
519
523
  join(directory, "webController.ts"),
520
524
  `import type { AppDependencies } from "@getstrata/core/contracts/di";
521
525
  import { resolveService } from "@getstrata/core/contracts/di";
522
- import { CORE_VIEW_TOKEN } from "@getstrata/bootstrap/providers/view";
523
526
  import { withErrorHandling } from "@getstrata/core/http/response";
524
- import type { ViewEngine } from "@getstrata/core/view";
525
- import { htmlResponse } from "@getstrata/core/view";
527
+ import { CORE_VIEW_RENDERER_TOKEN, type NamespacedViewRenderer } from "@getstrata/core/view";
526
528
  import { ${moduleIdentifier}ServiceToken } from "./provider";
527
529
  import { parse${moduleName}ListQuery } from "./requests";
528
530
  import type ${moduleName}Service from "./service";
@@ -534,20 +536,19 @@ class ${moduleName}WebController {
534
536
  return resolveService(this.dependencies, ${moduleIdentifier}ServiceToken);
535
537
  }
536
538
 
537
- private get view(): ViewEngine {
538
- return resolveService(this.dependencies, CORE_VIEW_TOKEN);
539
+ private get views(): NamespacedViewRenderer {
540
+ return resolveService(this.dependencies, CORE_VIEW_RENDERER_TOKEN).namespace("${pluralSlug}");
539
541
  }
540
542
 
541
543
  readonly index = withErrorHandling(async (request?: Request) => {
542
544
  const query = parse${moduleName}ListQuery(request);
543
545
  const result = await this.service.paginate(query);
544
546
 
545
- return htmlResponse(
546
- await this.view.render("${pluralSlug}/index", {
547
- title: "${moduleName}s",
547
+ return this.views.renderHtmx("index.eta", {
548
+ layout: { title: "${moduleName}s" },
548
549
  records: result.data,
549
550
  meta: result.meta,
550
- }),
551
+ }, { request },
551
552
  );
552
553
  });
553
554
  }
@@ -584,6 +585,7 @@ export { create${moduleName}WebRoutes };
584
585
  ? createdViewsDirectory.slice(process.cwd().length + 1)
585
586
  : createdViewsDirectory;
586
587
  console.log(`Created web view scaffold in: ${relativeViews}/`);
588
+ console.log(`API routes use API_PREFIX (default /api/v1); HTML collection: /${pluralSlug}`);
587
589
  }
588
590
  console.log(`Module will be auto-discovered from the app modules directory (${moduleSlug}/)`);
589
591
  console.log(`Next: strata make:migration create_${moduleSlug} && strata migrate`);