@stacksjs/defaults 0.74.43 → 0.74.46
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/ai/skills/stacks-auto-imports/SKILL.md +1 -1
- package/ai/skills/stacks-composables/SKILL.md +48 -44
- package/ai/skills/stacks-models/SKILL.md +2 -2
- package/ai/skills/stacks-orm/SKILL.md +2 -2
- package/app/Models/Content/Categorizable.ts +55 -0
- package/app/Models/Content/Post.ts +1 -1
- package/ide/vscode/package.json +1 -1
- package/package.json +2 -2
|
@@ -66,7 +66,7 @@ globalThis.toggleDark = toggleDark
|
|
|
66
66
|
- **Custom Functions**: From `resources/functions/` (counter, dark mode, GPX, geo utilities)
|
|
67
67
|
|
|
68
68
|
### Server Auto-Imports (100+)
|
|
69
|
-
- **All ORM Models**: User, Post, Author, Product, Order, Payment, Customer, etc. (
|
|
69
|
+
- **All ORM Models**: User, Post, Author, Product, Order, Payment, Customer, etc. (103 models)
|
|
70
70
|
- **Request Models**: UserRequest, PostRequest, OrderRequest, etc.
|
|
71
71
|
- **Actions**: Action types and helpers
|
|
72
72
|
- **Schema**: validation schema builder
|
|
@@ -8,54 +8,56 @@ allowed-tools: Read Edit Write Bash Grep Glob
|
|
|
8
8
|
|
|
9
9
|
# Stacks Composables
|
|
10
10
|
|
|
11
|
-
154 reactive composables for STX templates. **
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
`
|
|
39
|
-
`useDateFormat`, `useFetch`, `useFloor`, `useForm`, `useGitStore`, `useMax`,
|
|
40
|
-
`useMin`, `useNow`, `useOnline`, `usePaymentStore`, `usePrecision`,
|
|
41
|
-
`usePreferredDark`, `useQueueStore`, `useRound`, `useScrollLock`, `useStorage`,
|
|
42
|
-
`useSum`, `useTimeoutFn`, `useToggle`, `useTrunc`, `useUserStore`.
|
|
11
|
+
154 reactive composables for STX templates. **A fixed set of them is available
|
|
12
|
+
bare**, listed below; everything else needs an explicit import from
|
|
13
|
+
`@stacksjs/composables`.
|
|
14
|
+
|
|
15
|
+
The stx runtime decides this, not `browser-auto-imports.json`. That manifest
|
|
16
|
+
feeds an ambient `.d.ts` and nothing reads it at build time, so it says what the
|
|
17
|
+
compiler accepts and not what the browser has; the two disagree in both
|
|
18
|
+
directions (stacksjs/stacks#2585).
|
|
19
|
+
|
|
20
|
+
This page said "All are auto-imported in STX templates", which is the mistake
|
|
21
|
+
`AGENTS.md` carries a scar about under "200+ composables": an agent reaching for
|
|
22
|
+
a name on that authority writes a template that does not run, and reads the
|
|
23
|
+
failure as a framework bug.
|
|
24
|
+
|
|
25
|
+
## What you can write bare in a template
|
|
26
|
+
|
|
27
|
+
<!-- auto-imported:begin - checked against the stx runtime by
|
|
28
|
+
core/composables/tests/skill-runtime-globals.test.ts. These are the names
|
|
29
|
+
`getCachedSignalsRuntime()` attaches to `window`, which is what decides
|
|
30
|
+
whether a bare call resolves in a template. Do not derive this list from
|
|
31
|
+
`browser-auto-imports.json`: that manifest is compile-time only, and 22 of
|
|
32
|
+
the 27 `use*` it declares are absent from the runtime. -->
|
|
33
|
+
|
|
34
|
+
`useAsync`, `useClickOutside`, `useColorMode`, `useCounter`, `useDark`,
|
|
35
|
+
`useDebounce`, `useDebouncedValue`, `useEventListener`, `useFetch`, `useFocus`,
|
|
36
|
+
`useHead`, `useInterval`, `useLocalStorage`, `useMutation`, `useQuery`,
|
|
37
|
+
`useRef`, `useRoute`, `useSearchParams`, `useSeoMeta`, `useSessionStorage`,
|
|
38
|
+
`useStore`, `useThrottle`, `useTimeout`, `useToggle`, `useWebSocket`.
|
|
43
39
|
|
|
44
40
|
<!-- auto-imported:end -->
|
|
45
41
|
|
|
46
|
-
|
|
42
|
+
Everything else needs an explicit import, and that is most of what the sections
|
|
43
|
+
below list:
|
|
47
44
|
|
|
48
45
|
```ts
|
|
49
|
-
import {
|
|
46
|
+
import { useStorage } from '@stacksjs/composables'
|
|
50
47
|
```
|
|
51
48
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
49
|
+
**`buddy typecheck` will not tell you which is which, and currently disagrees
|
|
50
|
+
with the browser in both directions** (stacksjs/stacks#2585).
|
|
51
|
+
`storage/framework/browser-auto-imports.json` feeds an ambient `.d.ts`, so the
|
|
52
|
+
compiler accepts every name it declares - and only five of its 27 `use*` are in
|
|
53
|
+
the runtime. `useStorage`, `useNow`, `useDateFormat`, `useForm` and the `use*Store`
|
|
54
|
+
composables typecheck and then throw a ReferenceError during setup, which takes
|
|
55
|
+
the page down rather than failing the one call. In the other direction
|
|
56
|
+
`useLocalStorage`, `useColorMode`, `useCounter` and `useMediaQuery` all work in
|
|
57
|
+
a template and `tsc` rejects them.
|
|
58
|
+
|
|
59
|
+
The list above is the runtime's, so it is the one that predicts whether the page
|
|
60
|
+
loads.
|
|
59
61
|
|
|
60
62
|
## Key Path
|
|
61
63
|
- Core package: `storage/framework/core/composables/src/`
|
|
@@ -200,9 +202,11 @@ isRef(val) // type guard
|
|
|
200
202
|
- `and`, `or`, `logicNot`, `logicOr`
|
|
201
203
|
|
|
202
204
|
## Gotchas
|
|
203
|
-
- Only
|
|
204
|
-
`
|
|
205
|
-
|
|
205
|
+
- Only the names listed above are available bare in an STX template, and they
|
|
206
|
+
come from the stx runtime, not from `browser-auto-imports.json` - that
|
|
207
|
+
manifest is compile-time only and disagrees with the runtime in both
|
|
208
|
+
directions (stacksjs/stacks#2585). Everything else needs
|
|
209
|
+
`import { … } from '@stacksjs/composables'`
|
|
206
210
|
- NEVER use vanilla JS (`var`, `document.*`, `window.*`) in STX `<script>` tags
|
|
207
211
|
- Only use stx-compatible code: signals, composables, directives
|
|
208
212
|
- Auto-imports defined in `storage/framework/browser-auto-imports.json`
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: stacks-models
|
|
3
|
-
description: Use when working with data models in Stacks - the defineModel() API, model attributes with validation and factories, relationships (hasOne/hasMany/belongsTo/belongsToMany), traits (useAuth, useUuid, useTimestamps, useSearch, useApi, billable, taggable, categorizable, commentable, likeable, observe), computed properties (get/set), model generation, and the
|
|
3
|
+
description: Use when working with data models in Stacks - the defineModel() API, model attributes with validation and factories, relationships (hasOne/hasMany/belongsTo/belongsToMany), traits (useAuth, useUuid, useTimestamps, useSearch, useApi, billable, taggable, categorizable, commentable, likeable, observe), computed properties (get/set), model generation, and the 103 built-in framework models. Covers model definitions and storage/framework/defaults/app/Models/.
|
|
4
4
|
license: MIT
|
|
5
5
|
compatibility: Bun >= 1.3.0, TypeScript, SQLite >= 3.47.2
|
|
6
6
|
allowed-tools: Read Edit Write Bash Grep Glob
|
|
@@ -265,7 +265,7 @@ pass `--allow-protected` to override.
|
|
|
265
265
|
## Built-in models by category
|
|
266
266
|
|
|
267
267
|
The ones below are worth knowing by name. They are a selection, not the set:
|
|
268
|
-
`storage/framework/defaults/app/Models/` holds
|
|
268
|
+
`storage/framework/defaults/app/Models/` holds 103, and that directory is the
|
|
269
269
|
authority. This section said "All 62 built-in models by category" while
|
|
270
270
|
listing fewer than that against 102 on disk, so an agent reading to the end
|
|
271
271
|
had no way to tell it was short.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: stacks-orm
|
|
3
|
-
description: Use when working with the Stacks ORM - defining models with defineModel(), model relationships (hasOne, hasMany, belongsTo, belongsToMany, morphOne, hasManyThrough), attributes, traits, factories, computed properties, query building, transactions, or the
|
|
3
|
+
description: Use when working with the Stacks ORM - defining models with defineModel(), model relationships (hasOne, hasMany, belongsTo, belongsToMany, morphOne, hasManyThrough), attributes, traits, factories, computed properties, query building, transactions, or the 103 built-in models. Covers @stacksjs/orm, storage/framework/orm/, and storage/framework/defaults/app/Models/.
|
|
4
4
|
license: MIT
|
|
5
5
|
compatibility: Bun >= 1.3.0, TypeScript, SQLite >= 3.47.2
|
|
6
6
|
allowed-tools: Read Edit Write Bash Grep Glob
|
|
@@ -11,7 +11,7 @@ allowed-tools: Read Edit Write Bash Grep Glob
|
|
|
11
11
|
## Key Paths
|
|
12
12
|
- Core ORM package: `storage/framework/core/orm/src/`
|
|
13
13
|
- ORM implementation: `storage/framework/orm/`
|
|
14
|
-
- Model definitions: `storage/framework/defaults/app/Models/` (
|
|
14
|
+
- Model definitions: `storage/framework/defaults/app/Models/` (103 models)
|
|
15
15
|
- Application models: `app/Models/`
|
|
16
16
|
- Default model templates: `storage/framework/defaults/app/Models/`
|
|
17
17
|
- ORM type globals: `storage/framework/types/orm-globals.d.ts`
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { defineModel } from '@stacksjs/orm'
|
|
2
|
+
import { schema } from '@stacksjs/validation'
|
|
3
|
+
|
|
4
|
+
// The CMS catalogue already exists in categorizables. Commerce's Category
|
|
5
|
+
// model owns a different table and its IDs cannot be used by this pivot.
|
|
6
|
+
export default defineModel({
|
|
7
|
+
name: 'Categorizable',
|
|
8
|
+
table: 'categorizables',
|
|
9
|
+
primaryKey: 'id',
|
|
10
|
+
autoIncrement: true,
|
|
11
|
+
ownership: false,
|
|
12
|
+
traits: { useTimestamps: true },
|
|
13
|
+
indexes: [
|
|
14
|
+
{ name: 'categorizables_type_slug_unique', columns: ['categorizable_type', 'slug'], unique: true },
|
|
15
|
+
{ name: 'categorizables_owner_slug_unique', columns: ['categorizable_type', 'categorizable_id', 'slug'], unique: true },
|
|
16
|
+
],
|
|
17
|
+
attributes: {
|
|
18
|
+
name: {
|
|
19
|
+
required: true,
|
|
20
|
+
fillable: true,
|
|
21
|
+
validation: { rule: schema.string() },
|
|
22
|
+
},
|
|
23
|
+
slug: {
|
|
24
|
+
required: true,
|
|
25
|
+
fillable: true,
|
|
26
|
+
validation: { rule: schema.string() },
|
|
27
|
+
},
|
|
28
|
+
description: {
|
|
29
|
+
required: false,
|
|
30
|
+
nullable: true,
|
|
31
|
+
fillable: true,
|
|
32
|
+
validation: { rule: schema.string() },
|
|
33
|
+
},
|
|
34
|
+
isActive: {
|
|
35
|
+
required: true,
|
|
36
|
+
fillable: true,
|
|
37
|
+
default: true,
|
|
38
|
+
validation: { rule: schema.boolean() },
|
|
39
|
+
},
|
|
40
|
+
categorizableId: {
|
|
41
|
+
// Runtime trait-table setup adds this column to older catalogues.
|
|
42
|
+
// Zero denotes a catalogue entry with no individual owner.
|
|
43
|
+
type: 'integer',
|
|
44
|
+
required: true,
|
|
45
|
+
fillable: true,
|
|
46
|
+
default: 0,
|
|
47
|
+
validation: { rule: schema.number().integer().min(0) },
|
|
48
|
+
},
|
|
49
|
+
categorizableType: {
|
|
50
|
+
required: true,
|
|
51
|
+
fillable: true,
|
|
52
|
+
validation: { rule: schema.string() },
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
} as const)
|
package/ide/vscode/package.json
CHANGED
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@stacksjs/defaults",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"sideEffects": false,
|
|
5
|
-
"version": "0.74.
|
|
5
|
+
"version": "0.74.46",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "git+https://github.com/stacksjs/stacks.git",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"@iconify-json/f7": "^1.2.2",
|
|
57
57
|
"@iconify-json/hugeicons": "^1.2.27",
|
|
58
|
-
"@stacksjs/mobile": "^0.74.
|
|
58
|
+
"@stacksjs/mobile": "^0.74.46",
|
|
59
59
|
"@stacksjs/sanitizer": "^0.2.113",
|
|
60
60
|
"ts-qr-codes": "^0.1.8"
|
|
61
61
|
}
|