create-zerotal 1.1.0 → 1.3.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.
- package/CHANGELOG.md +10 -0
- package/package.json +1 -1
- package/src/scaffold.ts +1 -1
- package/templates/admin/app/models/Product.ts +2 -2
- package/templates/admin/app/models/Setting.ts +2 -2
- package/templates/admin/app/models/User.ts +2 -2
- package/templates/api/app/models/User.ts +2 -2
- package/templates/flow/app/models/User.ts +3 -3
- package/templates/flow/tests/smoke.test.ts.tmpl +1 -1
- package/templates/react/app/models/User.ts +3 -3
- package/templates/vue/app/models/User.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,16 @@ follows the Zerotal monorepo's unified versioning.
|
|
|
8
8
|
|
|
9
9
|
## [Unreleased]
|
|
10
10
|
|
|
11
|
+
## [1.3.0] — 2026-08-09
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
|
|
15
|
+
- **Scaffolded models use the new composition idiom.** Templates now generate
|
|
16
|
+
`class User extends Model.using(Authenticatable)` instead of
|
|
17
|
+
`class User extends BaseModelWith(Authenticatable)`, and plain models extend `Model` rather than
|
|
18
|
+
`BaseModel` — following the base-class rename in `@zerotal/orm`. Affects the `admin`, `api`,
|
|
19
|
+
`flow`, `react` and `vue` templates.
|
|
20
|
+
|
|
11
21
|
## [1.1.0] — 2026-08-08
|
|
12
22
|
|
|
13
23
|
### Fixed
|
package/package.json
CHANGED
package/src/scaffold.ts
CHANGED
|
@@ -13,7 +13,7 @@ export type Template = 'minimal' | 'api' | 'admin' | 'flow' | 'react' | 'vue';
|
|
|
13
13
|
// "^1.1.0" found for specifier "zerotal"` — the first thing anyone trying the
|
|
14
14
|
// framework saw. `scaffold.test.ts` now asserts the two agree, so CI fails rather
|
|
15
15
|
// than the user's install.
|
|
16
|
-
export const ZT_VERSION = '^1.
|
|
16
|
+
export const ZT_VERSION = '^1.3.0';
|
|
17
17
|
|
|
18
18
|
export interface ScaffoldOptions {
|
|
19
19
|
name: string;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Model, column, table } from "zerotal/orm";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Something the shop sells. Soft-deleted, so a discontinued product can be
|
|
5
5
|
* restored rather than lost.
|
|
6
6
|
*/
|
|
7
7
|
@table("products")
|
|
8
|
-
export class Product extends
|
|
8
|
+
export class Product extends Model {
|
|
9
9
|
static override softDeletes = true;
|
|
10
10
|
static override fillable = ["name", "sku", "description", "price", "stock", "status", "featured"];
|
|
11
11
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Model, column, table } from "zerotal/orm";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Site-wide configuration — exactly one row, edited through a singular resource
|
|
5
5
|
* rather than a list. See `app/admin/SettingsResource.ts`.
|
|
6
6
|
*/
|
|
7
7
|
@table("settings")
|
|
8
|
-
export class Setting extends
|
|
8
|
+
export class Setting extends Model {
|
|
9
9
|
static override fillable = ["siteName", "supportEmail", "ordersOpen"];
|
|
10
10
|
|
|
11
11
|
@column() siteName!: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Model, column, table } from "zerotal/orm";
|
|
2
2
|
import { Authenticatable } from "zerotal/auth";
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -6,7 +6,7 @@ import { Authenticatable } from "zerotal/auth";
|
|
|
6
6
|
* belong to a user.
|
|
7
7
|
*/
|
|
8
8
|
@table("users")
|
|
9
|
-
export class User extends
|
|
9
|
+
export class User extends Model.using(Authenticatable) {
|
|
10
10
|
static override hidden = ["password"];
|
|
11
11
|
static override fillable = ["name", "email", "password", "roles", "avatarUrl"];
|
|
12
12
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Model, column, table } from 'zerotal/orm';
|
|
2
2
|
|
|
3
3
|
@table('users')
|
|
4
|
-
export class User extends
|
|
4
|
+
export class User extends Model {
|
|
5
5
|
// Models guard every attribute by default. List the columns that may be
|
|
6
6
|
// mass-assigned from user input — note `role` is deliberately excluded so a
|
|
7
7
|
// request body cannot escalate privileges via `User.create(ctx.body())`.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Model, column, table } from "zerotal/orm";
|
|
2
2
|
import { Authenticatable } from "zerotal/auth";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* `
|
|
5
|
+
* `Model.using(Authenticatable)`, not a plain `Model`.
|
|
6
6
|
*
|
|
7
7
|
* The mixin is what brands the class so `authUserModel()` can find it. Without
|
|
8
8
|
* the brand nothing errors and nothing warns — the model saves, queries and
|
|
@@ -14,7 +14,7 @@ import { Authenticatable } from "zerotal/auth";
|
|
|
14
14
|
* reads, and registers the `rememberToken` column that "remember me" needs.
|
|
15
15
|
*/
|
|
16
16
|
@table("users")
|
|
17
|
-
export class User extends
|
|
17
|
+
export class User extends Model.using(Authenticatable) {
|
|
18
18
|
// Models guard every attribute by default. Only these may be mass-assigned
|
|
19
19
|
// from a request body — `role` is deliberately absent, so no amount of extra
|
|
20
20
|
// fields in a form post can promote the account that submitted it.
|
|
@@ -111,7 +111,7 @@ describe('auth', () => {
|
|
|
111
111
|
|
|
112
112
|
test('the User model is resolvable by the auth layer', () => {
|
|
113
113
|
// The root cause, asserted directly: `Auth.attempt` finds the user model
|
|
114
|
-
// through this brand, so a plain `
|
|
114
|
+
// through this brand, so a plain `Model` makes every login fail.
|
|
115
115
|
expect(isAuthenticatable(User)).toBe(true);
|
|
116
116
|
});
|
|
117
117
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Model, column, table } from "zerotal/orm";
|
|
2
2
|
import { Authenticatable } from "zerotal/auth";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* `
|
|
5
|
+
* `Model.using(Authenticatable)`, not a plain `Model`.
|
|
6
6
|
*
|
|
7
7
|
* The mixin is what brands the class so `authUserModel()` can find it. Without
|
|
8
8
|
* the brand nothing errors and nothing warns — the model saves, queries and
|
|
@@ -14,7 +14,7 @@ import { Authenticatable } from "zerotal/auth";
|
|
|
14
14
|
* reads, and registers the `rememberToken` column that "remember me" needs.
|
|
15
15
|
*/
|
|
16
16
|
@table("users")
|
|
17
|
-
export class User extends
|
|
17
|
+
export class User extends Model.using(Authenticatable) {
|
|
18
18
|
// Models guard every attribute by default. Only these may be mass-assigned
|
|
19
19
|
// from a request body — `role` is deliberately absent, so no amount of extra
|
|
20
20
|
// fields in a form post can promote the account that submitted it.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Model, column, table } from "zerotal/orm";
|
|
2
2
|
|
|
3
3
|
@table("users")
|
|
4
|
-
export class User extends
|
|
4
|
+
export class User extends Model {
|
|
5
5
|
// Models guard every attribute by default. Only these may be mass-assigned
|
|
6
6
|
// from a request body — `role` is deliberately absent, so no amount of extra
|
|
7
7
|
// fields in a form post can promote the account that submitted it.
|