@stacksjs/defaults 0.75.571 → 0.75.572
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-actions/SKILL.md +1 -1
- package/ai/skills/stacks-cms/SKILL.md +1 -1
- package/ai/skills/stacks-dashboard/SKILL.md +283 -12
- package/ai/skills/stacks-database/SKILL.md +3 -1
- package/ai/skills/stacks-native/CATALOG.md +2 -2
- package/ai/skills/stacks-orm/SKILL.md +5 -1
- package/app/Actions/Dashboard/Content/CommentUpdateAction.ts +1 -1
- package/app/Actions/Dashboard/Content/PostStoreAction.ts +1 -1
- package/app/Actions/Dashboard/Content/PostUpdateAction.ts +1 -1
- package/app/Actions/Dashboard/Marketing/marketing-list-records.test.ts +2 -2
- package/app/Actions/Dashboard/Marketing/marketing-list-records.ts +4 -4
- package/app/Actions/Dashboard/Models/ModelShowAction.ts +42 -43
- package/app/Actions/Dashboard/Models/ModelUpdateAction.ts +17 -3
- package/app/Actions/Dashboard/Models/model-filters.ts +429 -0
- package/app/Actions/Dashboard/Models/model-switches.ts +159 -0
- package/app/Actions/Dashboard/Models/model-write.ts +6 -0
- package/app/Models/Comment.ts +3 -3
- package/app/Models/Content/Post.ts +3 -3
- package/app/Models/EmailList.ts +8 -6
- package/app/Models/Subscriber.ts +2 -0
- package/app/Models/Team.ts +2 -0
- package/app/Models/User.ts +3 -0
- package/functions/dashboard-model-filters.ts +219 -0
- package/functions/dashboard-model-record.ts +42 -8
- package/ide/vscode/package.json +1 -1
- package/package.json +3 -3
- package/resources/components/Dashboard/Commerce/CommerceCategoryDialog.stx +3 -1
- package/resources/components/Dashboard/Commerce/CommerceCouponDialog.stx +3 -1
- package/resources/components/Dashboard/Commerce/CommerceGiftCardDialog.stx +9 -3
- package/resources/components/Dashboard/Commerce/CommerceManufacturerDialog.stx +3 -4
- package/resources/components/Dashboard/Commerce/CommerceProductDialog.stx +3 -1
- package/resources/components/Dashboard/Commerce/CommerceReviewEditDialog.stx +6 -8
- package/resources/components/Dashboard/Commerce/CommerceTaxDialog.stx +6 -14
- package/resources/components/Dashboard/Commerce/CommerceUnitDialog.stx +3 -7
- package/resources/components/Dashboard/Commerce/Delivery/DigitalDeliveryDialog.stx +6 -2
- package/resources/components/Dashboard/Content/BlogPostEditorDialog.stx +2 -8
- package/resources/components/Dashboard/Content/PageEditorDialog.stx +3 -7
- package/resources/components/Dashboard/Content/PostEditorDialog.stx +3 -4
- package/resources/components/Dashboard/Data/DataModelRecords.stx +12 -75
- package/resources/components/Dashboard/Data/DataStatCards.stx +110 -0
- package/resources/components/Dashboard/Email/InboxSettingsDashboard.stx +20 -36
- package/resources/components/Dashboard/Marketing/MarketingListDialog.stx +7 -14
- package/resources/components/Dashboard/Marketing/MarketingListsDashboard.stx +3 -2
- package/resources/components/Dashboard/Models/ModelFieldInputs.stx +10 -13
- package/resources/components/Dashboard/Models/ModelFilterPanel.stx +166 -0
- package/resources/components/Dashboard/Models/ModelRecordDetail.stx +18 -0
- package/resources/components/Dashboard/Models/ModelRecordEdit.stx +3 -2
- package/resources/components/Dashboard/Models/ModelRecordsDashboard.stx +96 -29
- package/resources/components/Dashboard/Models/ModelRegion.stx +25 -0
- package/resources/components/Dashboard/Models/ModelRegionFor.stx +31 -0
- package/resources/components/Dashboard/Operations/RecoveryDestinationDialog.stx +2 -2
- package/resources/components/Dashboard/Operations/RecoveryPolicyDialog.stx +3 -1
- package/resources/components/Dashboard/Operations/RecoveryRestoreDialog.stx +3 -1
- package/resources/components/Dashboard/Settings/AppearanceSettingsDashboard.stx +11 -14
- package/resources/components/Dashboard/Settings/SettingsDashboard.stx +6 -9
- package/resources/components/Dashboard/UI/Toggle.stx +16 -12
- package/resources/functions/dashboard/regions.ts +113 -0
- package/resources/functions/dashboard/sidebar.ts +2 -0
- package/views/dashboard/composables/useModelList.ts +52 -0
- package/views/dashboard/composables/useModelRecord.ts +46 -0
- package/views/dashboard/stores/model-page.ts +105 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: stacks-actions
|
|
3
|
-
description: Use when working with Stacks server actions - creating actions in app/Actions/, auto-generated API actions from the useApi model trait, the
|
|
3
|
+
description: Use when working with Stacks server actions - creating actions in app/Actions/, auto-generated API actions from the useApi model trait, the 758 default framework actions (auth, dashboard, commerce, content, deployment, jobs), action request/response handling, or action registration. Covers @stacksjs/actions and storage/framework/defaults/app/Actions/.
|
|
4
4
|
license: MIT
|
|
5
5
|
compatibility: Bun >= 1.3.0, TypeScript
|
|
6
6
|
allowed-tools: Read Edit Write Bash Grep Glob
|
|
@@ -75,7 +75,7 @@ interface CmsNamespace {
|
|
|
75
75
|
| views | number | - | 0 |
|
|
76
76
|
| publishedAt | timestamp | optional | - |
|
|
77
77
|
| status | enum | published/draft/archived | draft |
|
|
78
|
-
| isFeatured |
|
|
78
|
+
| isFeatured | boolean | yes or no | - |
|
|
79
79
|
|
|
80
80
|
### Author
|
|
81
81
|
- **Table**: `authors`, **Relationships**: `hasMany(['Post'])`, `belongsTo(['User'])`
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: stacks-dashboard
|
|
3
|
-
description: Use when building or customizing the Stacks admin dashboard, including dashboard pages, model management views, analytics widgets, commerce dashboards, content management, settings panels, deployment monitoring, job/queue management, or the
|
|
3
|
+
description: Use when building or customizing the Stacks admin dashboard, including dashboard pages, model management views, analytics widgets, commerce dashboards, content management, settings panels, deployment monitoring, job/queue management, or the 431 built-in dashboard components. Covers the dashboard system at storage/framework/defaults/.
|
|
4
4
|
license: MIT
|
|
5
5
|
compatibility: Bun >= 1.3.0, TypeScript
|
|
6
6
|
allowed-tools: Read Edit Write Bash Grep Glob
|
|
@@ -8,7 +8,7 @@ allowed-tools: Read Edit Write Bash Grep Glob
|
|
|
8
8
|
|
|
9
9
|
# Stacks Dashboard
|
|
10
10
|
|
|
11
|
-
The Stacks admin dashboard provides a full-featured admin panel with 100+ route views,
|
|
11
|
+
The Stacks admin dashboard provides a full-featured admin panel with 100+ route views, 431 components, and a multi-section layout.
|
|
12
12
|
|
|
13
13
|
## Key Paths
|
|
14
14
|
- Dashboard components: `storage/framework/defaults/resources/components/Dashboard/`
|
|
@@ -600,6 +600,41 @@ Keep semantic controls such as tabs, switches, pagination state, window
|
|
|
600
600
|
controls, dialog backdrops, and table row menus in their dedicated components.
|
|
601
601
|
They are controls, not alternate action-button styles.
|
|
602
602
|
|
|
603
|
+
### On/off settings are the switch
|
|
604
|
+
|
|
605
|
+
An on/off setting is `Dashboard/UI/Toggle.stx`, in a model's form and in every
|
|
606
|
+
hand-built page and dialog (stacksjs/stacks#3297, #3301). Do not write a
|
|
607
|
+
checkbox for one.
|
|
608
|
+
|
|
609
|
+
```html
|
|
610
|
+
<div class="p-3 border border-gray-200 rounded-lg dark:border-neutral-700">
|
|
611
|
+
<Toggle v-model:checked="isActive" label="Enabled for redemption" description="Availability is stored separately from lifecycle status." labelPosition="left" />
|
|
612
|
+
</div>
|
|
613
|
+
```
|
|
614
|
+
|
|
615
|
+
- `v-model:checked` takes a signal or a key of a reactive object
|
|
616
|
+
(`v-model:checked="drafts[field.key]"`). Where the state is read through a
|
|
617
|
+
function (`isVisible(section.id)`), bind `:checked` and take
|
|
618
|
+
`@update:checked`, which carries the new boolean.
|
|
619
|
+
- `labelPosition="left"` puts the name on the left and the switch on the
|
|
620
|
+
right, the settings-row look. Without it the switch leads, which suits a
|
|
621
|
+
short option in a row of options.
|
|
622
|
+
- `error` shows a refused save's message in place of the description, and
|
|
623
|
+
`disabled` dims only the track, so a reason under a switch that cannot be
|
|
624
|
+
turned stays readable.
|
|
625
|
+
- **Give it a box of its own inside a `space-y-*` stack.** That utility puts
|
|
626
|
+
its margin on the component's scope wrapper, which makes no box, so a
|
|
627
|
+
switch that is a direct child loses its spacing. Wrap it in a `div`, or use
|
|
628
|
+
`flex flex-col gap-*` on the parent. The dev server says so when it sees it.
|
|
629
|
+
- A label that has quotation marks of its own goes in a constant and is bound
|
|
630
|
+
with `:label`.
|
|
631
|
+
|
|
632
|
+
A native checkbox is still right for what is not an on/off setting: picking
|
|
633
|
+
rows, several of many (a post's tags, a token's scopes), an instruction for
|
|
634
|
+
this save only ("Clear stored password"), an acknowledgement, and "remember
|
|
635
|
+
me" or the terms on the sign-in forms. `tests/unit/dashboard-switch-contract.test.ts`
|
|
636
|
+
lists every one by file with its reason and fails on any other.
|
|
637
|
+
|
|
603
638
|
### Sidebar-aware overlays
|
|
604
639
|
|
|
605
640
|
The desktop sidebar is fixed and publishes its current width through
|
|
@@ -752,7 +787,7 @@ forms draw them with one component, `Dashboard/Models/ModelFieldInputs`:
|
|
|
752
787
|
| Rule | Control | Stored as |
|
|
753
788
|
|---|---|---|
|
|
754
789
|
| `enum` | select of its allowed values | the value |
|
|
755
|
-
| `boolean` |
|
|
790
|
+
| `boolean` | switch (`Dashboard/UI/Toggle`) | true or false |
|
|
756
791
|
| `number`, `integer`, `float`, `unix` | number box | a number |
|
|
757
792
|
| `date` | date picker | the calendar day |
|
|
758
793
|
| `timestamp`, `timestampTz`, `datetime` | date and time, in the visitor's zone | UTC `YYYY-MM-DD HH:MM:SS` (ISO for `timestampTz`) |
|
|
@@ -822,6 +857,205 @@ not "Team ID"). The list endpoint returns the names with the rows
|
|
|
822
857
|
(`relationNames`), one lookup per related model per page, and a record's page
|
|
823
858
|
uses the same ones.
|
|
824
859
|
|
|
860
|
+
### Changing a page: declare, extend, replace
|
|
861
|
+
|
|
862
|
+
Three ways, cheapest first. Reach for the next one only when the one before
|
|
863
|
+
cannot say it.
|
|
864
|
+
|
|
865
|
+
1. **Declare.** The model's `dashboard` block: `columns`, `fields`,
|
|
866
|
+
`filters`, `actions`, `writes`. The dashboard already knows how to draw
|
|
867
|
+
these, and they survive every upgrade.
|
|
868
|
+
2. **Extend.** `dashboard.regions` places a component of the app's own at a
|
|
869
|
+
named place on the framework's page. The page stays the framework's.
|
|
870
|
+
3. **Replace.** A file of the same name under the app's
|
|
871
|
+
`resources/views/dashboard/` or `resources/components/Dashboard/` wins
|
|
872
|
+
over the framework's. The app owns that file from then on and gets no
|
|
873
|
+
updates to it.
|
|
874
|
+
|
|
875
|
+
### A model places its own component on a page
|
|
876
|
+
|
|
877
|
+
```ts
|
|
878
|
+
// app/Models/Order.ts
|
|
879
|
+
dashboard: {
|
|
880
|
+
regions: { recordTop: 'OrderTimeline', listBottom: 'OrderTotals' },
|
|
881
|
+
}
|
|
882
|
+
```
|
|
883
|
+
|
|
884
|
+
| Place | Where |
|
|
885
|
+
|---|---|
|
|
886
|
+
| `listTop` | on the model's list, under its title and above its search |
|
|
887
|
+
| `listBottom` | on the model's list, under its table |
|
|
888
|
+
| `recordTop` | on a record's page, under its title and above its fields |
|
|
889
|
+
| `recordBottom` | on a record's page, under the panels of who points at it |
|
|
890
|
+
|
|
891
|
+
Each names one component by the name its file has, under the app's
|
|
892
|
+
`resources/components/Dashboard/` (any folder inside it):
|
|
893
|
+
`resources/components/Dashboard/Orders/OrderTimeline.stx`. No build step and
|
|
894
|
+
no registration. One per place; a component that needs several things
|
|
895
|
+
composes them. It applies on `/models/{model}` and its record pages, and on
|
|
896
|
+
the Users, Teams and Subscribers pages that host the list.
|
|
897
|
+
|
|
898
|
+
A shipped model does the same with a shipped component, which is the one
|
|
899
|
+
place this framework uses a region of its own: `User`, `Team` and
|
|
900
|
+
`Subscriber` each put `Data/DataStatCards.stx`, their row of numbers, at
|
|
901
|
+
`listTop` (stacksjs/stacks#3299). In this repository a region's component
|
|
902
|
+
lives under `storage/framework/defaults/resources/components/Dashboard/`,
|
|
903
|
+
never in the root `resources/`.
|
|
904
|
+
|
|
905
|
+
The component is handed `model` (the slug) and `region` as plain props.
|
|
906
|
+
What the page loads it reads as signals:
|
|
907
|
+
|
|
908
|
+
```html
|
|
909
|
+
<script client>
|
|
910
|
+
import { useModelRecord } from '@stacksjs/defaults/views/dashboard/composables/useModelRecord'
|
|
911
|
+
|
|
912
|
+
const { record, reload } = useModelRecord()
|
|
913
|
+
const shipped = derived(() => record()?.status === 'shipped')
|
|
914
|
+
</script>
|
|
915
|
+
|
|
916
|
+
<Card :if="record()">
|
|
917
|
+
<p :text="shipped() ? 'Shipped' : 'Not shipped yet'"></p>
|
|
918
|
+
</Card>
|
|
919
|
+
```
|
|
920
|
+
|
|
921
|
+
- `useModelRecord()`: `record()` is the row's values by column, null until
|
|
922
|
+
it has loaded; `details()` is everything the page was told (column
|
|
923
|
+
labels, the records it points at by name, what may be done); `model()`,
|
|
924
|
+
`id()`; `reload()` asks the page to read the record again.
|
|
925
|
+
- `useModelList()`: `rows()`, `total()`, `search()`, `filters()`,
|
|
926
|
+
`model()`, `reload()`. It follows the list as it is searched, narrowed and
|
|
927
|
+
paged. `changes()` goes up each time the list changes a record (a delete,
|
|
928
|
+
a bulk run that did something, one of the model's actions) and not when it
|
|
929
|
+
is searched or paged: watch it to read numbers of your own again.
|
|
930
|
+
|
|
931
|
+
**Start in `onMount`, stop in `onDestroy`.** A placed component's script
|
|
932
|
+
runs on every model page that has its place, whether or not the component is
|
|
933
|
+
put on that page. Only `onMount` and `onDestroy` belong to the page it is
|
|
934
|
+
actually on. So:
|
|
935
|
+
|
|
936
|
+
```html
|
|
937
|
+
<script client>
|
|
938
|
+
import { useModelList } from '@stacksjs/defaults/views/dashboard/composables/useModelList'
|
|
939
|
+
|
|
940
|
+
const { changes } = useModelList()
|
|
941
|
+
let stop: (() => void) | null = null
|
|
942
|
+
|
|
943
|
+
onMount(() => {
|
|
944
|
+
void load()
|
|
945
|
+
let seen = changes()
|
|
946
|
+
stop = effect(() => {
|
|
947
|
+
if (changes() === seen)
|
|
948
|
+
return
|
|
949
|
+
seen = changes()
|
|
950
|
+
void load()
|
|
951
|
+
})
|
|
952
|
+
})
|
|
953
|
+
onDestroy(() => stop?.())
|
|
954
|
+
</script>
|
|
955
|
+
```
|
|
956
|
+
|
|
957
|
+
An `effect` or a request at the top of the script runs for other models'
|
|
958
|
+
pages too and is never stopped: the stat cards, written that way, asked for
|
|
959
|
+
users' and subscribers' numbers each time a team was deleted, once more for
|
|
960
|
+
every page visited (stacksjs/stx#2189). `state`, `derived` and functions at
|
|
961
|
+
the top are fine; they do nothing until read.
|
|
962
|
+
|
|
963
|
+
How it works, and what follows from it:
|
|
964
|
+
|
|
965
|
+
- A dashboard page is the same document at every address: stx draws a view
|
|
966
|
+
that has no script of its own once and serves that to all of them, and the
|
|
967
|
+
page reads its address in the browser. So the server cannot draw "this
|
|
968
|
+
model's component". `Models/ModelRegion.stx` draws the component of
|
|
969
|
+
**every** model that places one at that place
|
|
970
|
+
(`dashboardRegionEntries(place)`), each inside a `ModelRegionFor`, and
|
|
971
|
+
that puts on the page only the one whose model the page is showing. A
|
|
972
|
+
component written for orders is never shown or mounted on a team's page.
|
|
973
|
+
Its script is still set up there, which is why its work starts in
|
|
974
|
+
`onMount` (above).
|
|
975
|
+
- So do not read `params` in a view or a component to decide what to draw:
|
|
976
|
+
it holds the first address that was asked for.
|
|
977
|
+
- The page says which model it is showing through `stores/model-page.ts`,
|
|
978
|
+
before it loads anything, and clears its own when it goes. That is also
|
|
979
|
+
what the composables read, so a component never shows the record of the
|
|
980
|
+
page before.
|
|
981
|
+
- **Props are fixed when the page is drawn**: `model` and `region` only. The
|
|
982
|
+
record's id, like everything else that differs by address, comes from the
|
|
983
|
+
composables (`useModelRecord().id()`).
|
|
984
|
+
- `ModelRegionFor` draws the component in its own template, in the open and
|
|
985
|
+
close form. stx leaves `<component :is>` undrawn inside another
|
|
986
|
+
component's slot, and hands the self-closing form no props.
|
|
987
|
+
- What a model declared reaches the server through the manifest the
|
|
988
|
+
dashboard is started with. The dev server restarts itself when a model
|
|
989
|
+
changes.
|
|
990
|
+
- A place or a name that cannot be used is left out and logged once
|
|
991
|
+
(`[dashboard] Order dashboard.regions: 'sidebar' is not a place...`). A
|
|
992
|
+
name is only ever a component's (`OrderTimeline`), never a path.
|
|
993
|
+
|
|
994
|
+
`tests/unit/dashboard-model-regions.test.ts` renders the shipped wrapper
|
|
995
|
+
through stx and holds stx to what this depends on, so a change there fails a
|
|
996
|
+
test and not an app's page. It also holds every shipped model's region to a
|
|
997
|
+
shipped component that exists and starts its work in `onMount`.
|
|
998
|
+
|
|
999
|
+
### A list's filters and sort are derived, not declared
|
|
1000
|
+
|
|
1001
|
+
Nothing declares a filter. `Models/model-filters.ts` reads which filters a
|
|
1002
|
+
list offers from what the model already says:
|
|
1003
|
+
|
|
1004
|
+
| Signal | Where | Decides |
|
|
1005
|
+
|---|---|---|
|
|
1006
|
+
| What the field is | its validation rule | whether it is a filter, and its control |
|
|
1007
|
+
| What results are narrowed by | `traits.useSearch.filterable` | offered first; a number or a line of text is only a filter when named here |
|
|
1008
|
+
| What is private | `hidden` | never offered, and never sortable |
|
|
1009
|
+
|
|
1010
|
+
| Field | Asked for as |
|
|
1011
|
+
|---|---|
|
|
1012
|
+
| A few allowed values (`schema.enum`) | pick any of them |
|
|
1013
|
+
| Yes or no (`schema.boolean`) | Yes / No |
|
|
1014
|
+
| `belongsTo` | the record picker the forms use |
|
|
1015
|
+
| A date or a moment | two days, and Today / Last 7 days / This month |
|
|
1016
|
+
| A number the model names | at least / at most |
|
|
1017
|
+
| Text the model names | chosen from the values the table holds when there are 20 or fewer (`withStoredChoices`, remembered for 30 seconds), else an exact value |
|
|
1018
|
+
|
|
1019
|
+
Prose and structures are searched, not filtered. A filter is what the model
|
|
1020
|
+
says the field is, never a guess from its name: a yes-or-no declared
|
|
1021
|
+
`schema.number()` is a number range until the model says `schema.boolean()`.
|
|
1022
|
+
|
|
1023
|
+
```ts
|
|
1024
|
+
dashboard: { filters: ['status', 'team', 'createdAt'] }
|
|
1025
|
+
```
|
|
1026
|
+
|
|
1027
|
+
names and orders them instead, in the vocabulary `dashboard.columns` uses (an
|
|
1028
|
+
attribute, a column, or a `belongsTo`). An empty list means no filters. A
|
|
1029
|
+
name that cannot be used is left out and logged once.
|
|
1030
|
+
|
|
1031
|
+
On the page (`Models/ModelFilterPanel.stx`) the Filter button opens a panel
|
|
1032
|
+
of those controls. What narrows the list is always shown as chips ("Channel:
|
|
1033
|
+
Email, SMS"), each with a clear button, and is written to the address
|
|
1034
|
+
(`modelListAddress`), so a narrowed list can be sent to someone.
|
|
1035
|
+
|
|
1036
|
+
On the wire, `filters` is a JSON object by column:
|
|
1037
|
+
|
|
1038
|
+
| Value | Means | For |
|
|
1039
|
+
|---|---|---|
|
|
1040
|
+
| `"3"` | exactly this | any column the page is sent (what a record's panel links with) |
|
|
1041
|
+
| `{ "in": ["a", "b"] }` | any of these | a choice, a relation, named text |
|
|
1042
|
+
| `{ "from": "...", "to": "..." }` | from, up to | a date (days, both included) or a moment (instants, end not included) |
|
|
1043
|
+
| `{ "min": 1, "max": 9 }` | between | a number the model names |
|
|
1044
|
+
|
|
1045
|
+
Each is checked against the field's kind and refused with a 422 in words
|
|
1046
|
+
before the database is asked ("Channel is not a date, so it has no range of
|
|
1047
|
+
days."). For a moment the page sends where the viewer's first day starts and
|
|
1048
|
+
where the day after their last one does (`modelFilterRange`), so "the 5th" is
|
|
1049
|
+
the viewer's 5th.
|
|
1050
|
+
|
|
1051
|
+
The response carries `filterable` (the filters) and `sortable` (the columns a
|
|
1052
|
+
heading orders by). Any stored value can be sorted. Prose, structures and
|
|
1053
|
+
columns that point at another record cannot: the cell shows that record's
|
|
1054
|
+
name, and ordering by its id would look random. Their headings are plain.
|
|
1055
|
+
|
|
1056
|
+
Not built: filters that are not one column ("Overdue"), saved views, and
|
|
1057
|
+
ordering a relation column by the related record's name.
|
|
1058
|
+
|
|
825
1059
|
### A model says how a field is called, shown and asked for
|
|
826
1060
|
|
|
827
1061
|
An attribute says what a field is. It cannot say that `amount` is money and
|
|
@@ -1218,12 +1452,19 @@ labels, formats and actions on the model's `dashboard` block, not on the page.
|
|
|
1218
1452
|
The list takes four props when it is hosted: `model` (the slug, instead of the
|
|
1219
1453
|
last part of the address), `heading`, `description`, and `home` (where its
|
|
1220
1454
|
create, invite, view and edit links lead, so `/data/users/7` and not
|
|
1221
|
-
`/models/user/7`).
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
`
|
|
1226
|
-
`
|
|
1455
|
+
`/models/user/7`). The hosting page adds nothing else.
|
|
1456
|
+
|
|
1457
|
+
The row of numbers above each list is the model's, not the page's: `User`,
|
|
1458
|
+
`Team` and `Subscriber` place `Data/DataStatCards.stx` at
|
|
1459
|
+
`dashboard.regions.listTop`, so the numbers are on `/data/users` and on
|
|
1460
|
+
`/models/user` alike (stacksjs/stacks#3299). They used to be written into
|
|
1461
|
+
the hosting page and handed to the list through a `summary` slot, which is
|
|
1462
|
+
gone. After a delete, a bulk run that did something, or one of the model's
|
|
1463
|
+
actions, the list tells the page store (`modelPageStore.listChanged`) and the
|
|
1464
|
+
cards read their numbers again. The numbers come from the page's old endpoint
|
|
1465
|
+
asked for them alone: `GET /api/dashboard/users?only=stats` reads no rows
|
|
1466
|
+
(`statsOnly(request)` in `Data/data-records.ts`; `fetchDashboardStats(mode)`
|
|
1467
|
+
on the client).
|
|
1227
1468
|
|
|
1228
1469
|
Two stx behaviours shape this, and both fail silently:
|
|
1229
1470
|
|
|
@@ -1233,9 +1474,9 @@ Two stx behaviours shape this, and both fail silently:
|
|
|
1233
1474
|
address ("No ORM model named Users").
|
|
1234
1475
|
- What a page puts in another component's slot is read against that
|
|
1235
1476
|
component's names first. A `page` in the hosting page was the list's page
|
|
1236
|
-
number and the first card read "Total undefined". The hosting page
|
|
1237
|
-
|
|
1238
|
-
`tests/unit/dashboard-data-pages.test.ts` fails if
|
|
1477
|
+
number and the first stat card read "Total undefined". The hosting page
|
|
1478
|
+
now puts nothing in a slot of the list, and
|
|
1479
|
+
`tests/unit/dashboard-data-pages.test.ts` fails if it does again.
|
|
1239
1480
|
|
|
1240
1481
|
A status-like column (`status`, `role`, `state`, ... : `MODEL_BADGE_COLUMNS`)
|
|
1241
1482
|
is a pill in a list as it is on a record's page, both drawn by
|
|
@@ -1289,6 +1530,36 @@ is not refused as a duplicate. An address that already has an account is
|
|
|
1289
1530
|
refused on the email field. Drop `store` from `dashboard.writes` to turn
|
|
1290
1531
|
inviting off.
|
|
1291
1532
|
|
|
1533
|
+
### An account's confirmed email and two-factor are switches
|
|
1534
|
+
|
|
1535
|
+
A form asks for a model's own attributes. Whether an account's email is
|
|
1536
|
+
confirmed and whether it signs in with two-factor are not attributes: the
|
|
1537
|
+
`useAuth` trait owns those columns. They used to sit in the edit form's
|
|
1538
|
+
read-only panel, so confirming an address or letting someone back in who lost
|
|
1539
|
+
their device took a database console (stacksjs/stacks#3298).
|
|
1540
|
+
|
|
1541
|
+
On `User`'s edit form they are switches, saved with the rest of the form:
|
|
1542
|
+
|
|
1543
|
+
| Switch | On | Off |
|
|
1544
|
+
|---|---|---|
|
|
1545
|
+
| Email Verified | `setEmailVerified(id, true)` stamps the address as confirmed now | clears it |
|
|
1546
|
+
| Two Factor Enabled | never from here: only the account holder can enroll an authenticator | `disableTwoFactor(id)` removes the secret, the recovery codes and any open challenge |
|
|
1547
|
+
|
|
1548
|
+
The rules, all in `Actions/Dashboard/Models/model-switches.ts`:
|
|
1549
|
+
|
|
1550
|
+
- A switch is changed by the auth package's function, never by writing its
|
|
1551
|
+
column. That is the reason it is not a plain boolean field.
|
|
1552
|
+
- A switch that turns one way only is shown disabled while it cannot be
|
|
1553
|
+
turned, with the reason under it, and the server refuses the direction too.
|
|
1554
|
+
A refused switch refuses the whole save: nothing else is written.
|
|
1555
|
+
- A value that is not a yes or a no is refused, not read as "off".
|
|
1556
|
+
- They ride on the model's `update` permission, like every field of the form.
|
|
1557
|
+
- The create form has none: a new account has nothing to turn.
|
|
1558
|
+
|
|
1559
|
+
They are derived from the trait, not declared. A model cannot yet add a
|
|
1560
|
+
switch of its own for a column its own code keeps; do not fake one with a
|
|
1561
|
+
fillable boolean when changing the value needs more than writing it.
|
|
1562
|
+
|
|
1292
1563
|
## Application observability
|
|
1293
1564
|
|
|
1294
1565
|
HTTP capture is opt-in through `config/server.ts: captureRequests: true` (or
|
|
@@ -132,7 +132,9 @@ const orderId = db.transaction((tx) => {
|
|
|
132
132
|
behind it and is a promise whatever its own callback does. With only
|
|
133
133
|
synchronous callbacks that cannot happen.
|
|
134
134
|
- MySQL and Postgres run on a worker thread the caller waits on, sharing one
|
|
135
|
-
pool with the models.
|
|
135
|
+
pool with the models. On [stacksjs/bun](https://github.com/stacksjs/bun),
|
|
136
|
+
whose drivers can wait for a statement themselves, the pool is on the calling
|
|
137
|
+
thread and there is no worker; nothing else differs. `models: { execution: 'async' }` in `config/query-builder.ts`
|
|
136
138
|
gives promises back for both; every call then has to be awaited.
|
|
137
139
|
|
|
138
140
|
For reads which cannot tolerate replication lag, use `db.primary.selectFrom(...)`.
|
|
@@ -92,7 +92,7 @@ Browser runtime bindings are documented separately in `stacks-auto-imports`.
|
|
|
92
92
|
| `@stacksjs/testing` | [`stacks-testing`](../stacks-testing/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/testing/src/index.ts) | 24 |
|
|
93
93
|
| `@stacksjs/tinker` | [`stacks-repl`](../stacks-repl/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/tinker/src/index.ts) | 4 |
|
|
94
94
|
| `@stacksjs/tunnel` | [`stacks-tunnel`](../stacks-tunnel/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/tunnel/src/index.ts) | 1 |
|
|
95
|
-
| `@stacksjs/types` | [`stacks-types`](../stacks-types/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/index.ts) |
|
|
95
|
+
| `@stacksjs/types` | [`stacks-types`](../stacks-types/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/index.ts) | 3 |
|
|
96
96
|
| `@stacksjs/ui` | [`stacks-ui`](../stacks-ui/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ui/src/index.ts) | 6 |
|
|
97
97
|
| `@stacksjs/utils` | [`stacks-utils`](../stacks-utils/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/utils/src/index.ts) | 28 |
|
|
98
98
|
| `@stacksjs/validation` | [`stacks-validation`](../stacks-validation/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/validation/src/index.ts) | 26 |
|
|
@@ -904,7 +904,7 @@ Read the entrypoint and package export map for re-exported or type-only surfaces
|
|
|
904
904
|
|
|
905
905
|
Local source modules: [src/ai.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/ai.ts), [src/analytics.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/analytics.ts), [src/api.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/api.ts), [src/app.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/app.ts), [src/auction.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/auction.ts), [src/auth.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/auth.ts), [src/auto-imports.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/auto-imports.ts), [src/binary.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/binary.ts), [src/cache.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/cache.ts), [src/cdn.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/cdn.ts), [src/chat.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/chat.ts), [src/cli.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/cli.ts), [src/cloud.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/cloud.ts), [src/cms.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/cms.ts), [src/commands.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/commands.ts), [src/commerce.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/commerce.ts), [src/components.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/components.ts), [src/configure.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/configure.ts), [src/cors.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/cors.ts), [src/cron-jobs.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/cron-jobs.ts), [src/dashboard.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/dashboard.ts), [src/database.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/database.ts), [src/dependencies.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/dependencies.ts), [src/deploy.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/deploy.ts), [src/desktop.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/desktop.ts), [src/dns.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/dns.ts), [src/docs.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/docs.ts), [src/email.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/email.ts), [src/errors.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/errors.ts), [src/events.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/events.ts), [src/exit-code.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/exit-code.ts), [src/feature-flags.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/feature-flags.ts), [src/file-systems.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/file-systems.ts), [src/forms.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/forms.ts), [src/git.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/git.ts), [src/hashing.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/hashing.ts), [src/helpers.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/helpers.ts), [src/i18n.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/i18n.ts), [src/images.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/images.ts), [src/library.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/library.ts), [src/lint.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/lint.ts), [src/logging.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/logging.ts), [src/manifest.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/manifest.ts), [src/marketing.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/marketing.ts), [src/mobile.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/mobile.ts), [src/model-dashboard-augmentation.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/model-dashboard-augmentation.ts), [src/model-names.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/model-names.ts), [src/model.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/model.ts), [src/monitoring.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/monitoring.ts), [src/notifications.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/notifications.ts), [src/oauth.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/oauth.ts), [src/pages.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/pages.ts), [src/payments.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/payments.ts), [src/phone.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/phone.ts), [src/ports.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/ports.ts), [src/promise.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/promise.ts), [src/push.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/push.ts), [src/queue.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/queue.ts), [src/reactivity.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/reactivity.ts), [src/realtime.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/realtime.ts), [src/request.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/request.ts), [src/response.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/response.ts), [src/router.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/router.ts), [src/saas.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/saas.ts), [src/scheduler.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/scheduler.ts), [src/search-engine.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/search-engine.ts), [src/security.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/security.ts), [src/seo.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/seo.ts), [src/server.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/server.ts), [src/services.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/services.ts), [src/settings-config.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/settings-config.ts), [src/sites.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/sites.ts), [src/sms.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/sms.ts), [src/socials.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/socials.ts), [src/stack-extensions.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/stack-extensions.ts), [src/stacks.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/stacks.ts), [src/storage.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/storage.ts), [src/table-names.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/table-names.ts), [src/tables.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/tables.ts), [src/team.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/team.ts), [src/ui.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/ui.ts), [src/utils.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/utils.ts).
|
|
906
906
|
|
|
907
|
-
Evidence directory: [
|
|
907
|
+
Evidence directory: [3 retained tests](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/tests). These files are evidence pointers, not a claim that all tests were run for this catalog.
|
|
908
908
|
|
|
909
909
|
### @stacksjs/ui
|
|
910
910
|
|
|
@@ -62,7 +62,11 @@ for (const post of Post.where('published', true).get()) titles.push(post.title)
|
|
|
62
62
|
- **How.** SQLite runs a query in place. MySQL and Postgres run on Bun's
|
|
63
63
|
driver, held by a worker thread the caller waits on, so nothing else runs on
|
|
64
64
|
the calling thread while a query is in flight (the cost `bun:sqlite` always
|
|
65
|
-
had).
|
|
65
|
+
had). On a Bun whose drivers can wait for a statement themselves
|
|
66
|
+
([stacksjs/bun](https://github.com/stacksjs/bun)) there is no worker: the
|
|
67
|
+
connection stays on the calling thread. The runtime is looked at when the
|
|
68
|
+
connection opens, the rules are the same either way, and
|
|
69
|
+
`models: { transport: 'worker' }` keeps the worker. `models: { execution: 'async' }` in `config/query-builder.ts` makes MySQL and
|
|
66
70
|
Postgres calls promises again for an app that needs the event loop free
|
|
67
71
|
during queries; every call then has to be awaited.
|
|
68
72
|
- **The `db` query builder too.** `db.selectFrom(...).get()` is the rows and
|
|
@@ -44,7 +44,7 @@ export default new Action({
|
|
|
44
44
|
poster: payload.poster,
|
|
45
45
|
status: payload.status,
|
|
46
46
|
author_id: payload.authorId,
|
|
47
|
-
is_featured: payload.featured
|
|
47
|
+
is_featured: Boolean(payload.featured),
|
|
48
48
|
views: 0,
|
|
49
49
|
published_at: publishedAtFor(payload.status, null, now),
|
|
50
50
|
created_at: now,
|
|
@@ -54,7 +54,7 @@ export default new Action({
|
|
|
54
54
|
poster: payload.poster,
|
|
55
55
|
status: payload.status,
|
|
56
56
|
author_id: payload.authorId,
|
|
57
|
-
is_featured: payload.featured
|
|
57
|
+
is_featured: Boolean(payload.featured),
|
|
58
58
|
published_at: publishedAtFor(payload.status, existing.published_at, timestamp()),
|
|
59
59
|
updated_at: timestamp(),
|
|
60
60
|
} as any)
|
|
@@ -145,8 +145,8 @@ export function marketingListWriteData(input: Record<string, unknown>): {
|
|
|
145
145
|
slug: string
|
|
146
146
|
description: string
|
|
147
147
|
status: MarketingListStatus
|
|
148
|
-
isPublic:
|
|
149
|
-
doubleOptIn:
|
|
148
|
+
isPublic: boolean
|
|
149
|
+
doubleOptIn: boolean
|
|
150
150
|
} {
|
|
151
151
|
const name = text(input.name).trim()
|
|
152
152
|
const slug = slugifyMarketingList(text(input.slug).trim() || name)
|
|
@@ -155,8 +155,8 @@ export function marketingListWriteData(input: Record<string, unknown>): {
|
|
|
155
155
|
slug,
|
|
156
156
|
description: text(input.description).trim(),
|
|
157
157
|
status: status(input.status),
|
|
158
|
-
isPublic: boolean(input.isPublic ?? input.is_public)
|
|
159
|
-
doubleOptIn: boolean(input.doubleOptIn ?? input.double_opt_in)
|
|
158
|
+
isPublic: boolean(input.isPublic ?? input.is_public),
|
|
159
|
+
doubleOptIn: boolean(input.doubleOptIn ?? input.double_opt_in),
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
|