@stacksjs/defaults 0.75.569 → 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 +50 -0
- package/ai/skills/stacks-http/SKILL.md +33 -2
- package/ai/skills/stacks-native/CATALOG.md +8 -8
- package/ai/skills/stacks-orm/SKILL.md +20 -10
- package/ai/skills/stacks-query-builder/SKILL.md +7 -0
- package/app/Actions/Dashboard/Commerce/commerce-sql.ts +1 -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/Content/comment-list.ts +2 -2
- package/app/Actions/Dashboard/Content/page-list.ts +2 -2
- package/app/Actions/Dashboard/Content/post-list.ts +2 -2
- package/app/Actions/Dashboard/Infrastructure/InsightsAction.ts +24 -19
- package/app/Actions/Dashboard/Infrastructure/log-provider.ts +4 -4
- package/app/Actions/Dashboard/Jobs/job-list.ts +1 -1
- package/app/Actions/Dashboard/Kanban/BoardShowAction.ts +2 -2
- package/app/Actions/Dashboard/Kanban/CardShowAction.ts +3 -3
- package/app/Actions/Dashboard/Kanban/card-attachments.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/Actions/Dashboard/Notifications/NotificationDeliveryOverviewAction.ts +1 -1
- package/app/Actions/Dashboard/Queries/query-list.ts +1 -1
- package/app/Actions/Dashboard/Queue/queue-stats.ts +2 -2
- package/app/Actions/Dashboard/named-search.ts +1 -1
- 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
|
|
@@ -87,6 +87,56 @@ const users = await db.selectFrom('users').where('active', '=', true).get()
|
|
|
87
87
|
|
|
88
88
|
`initializeDbConfig(config)` can be called to update the backing config at runtime.
|
|
89
89
|
|
|
90
|
+
### Values, not promises
|
|
91
|
+
|
|
92
|
+
A `db` call answers where it is written, on SQLite, MySQL and Postgres:
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
const users = db.selectFrom('users').where('active', '=', true).get() // the rows
|
|
96
|
+
const newest = db.selectFrom('users').orderBy('created_at', 'desc').first() // the row, or undefined
|
|
97
|
+
const changed = db.updateTable('users').set({ active: false }).where('id', '=', 7).execute() // 1
|
|
98
|
+
|
|
99
|
+
const orderId = db.transaction((tx) => {
|
|
100
|
+
const order = tx.insertInto('orders').values({ customer_id: 7 }).returning('id').first()
|
|
101
|
+
tx.insertInto('order_lines').values({ order_id: order.id, sku: 'A-1' }).execute()
|
|
102
|
+
return order.id
|
|
103
|
+
}) // committed by this line; a throw has rolled back and rethrown
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
- `await` in front of any of them still works (`await` on a value is that
|
|
107
|
+
value), so existing code is correct as it stands.
|
|
108
|
+
- A failure is thrown where the call stands: `try`/`catch`, not `.catch()` or
|
|
109
|
+
`.then()`. In a test, `expect(() => db.selectFrom('missing').get()).toThrow()`,
|
|
110
|
+
not `await expect(...).rejects`.
|
|
111
|
+
- A query runs where it is written. To start several and judge each on its own
|
|
112
|
+
later, hand them over unstarted: `inspect(() => db.selectFrom(...).get())`.
|
|
113
|
+
- `db.unsafe(sql, params)` and `db.file(path)` build a statement. `.execute()`
|
|
114
|
+
runs it and returns its rows; awaiting the statement resolves to the same
|
|
115
|
+
rows. Nothing runs until one of the two happens.
|
|
116
|
+
- A transaction callback that is `async` is waited for, and the transaction is
|
|
117
|
+
then a promise, as is the callback of `chunk()`. Write the callback without
|
|
118
|
+
`async` when everything in it is a query.
|
|
119
|
+
- While a transaction with an `async` callback is open it holds its locks
|
|
120
|
+
across each `await`, and the code that commits it needs the thread. A
|
|
121
|
+
statement elsewhere in the process that needs one of those locks (or a
|
|
122
|
+
pooled connection, when they are all held) is therefore not waited for in
|
|
123
|
+
place: that one call answers with a promise, which resolves once the
|
|
124
|
+
transaction has finished. It is how `withLockedRow` and `rowToken` can
|
|
125
|
+
contend for one row. A statement that needs nothing held still answers in
|
|
126
|
+
place, and with synchronous callbacks nothing is ever held.
|
|
127
|
+
- Inside a transaction callback `db.` is the transaction: a `db.selectFrom(...)`
|
|
128
|
+
there runs on the transaction's connection, as `tx.selectFrom(...)` does. A
|
|
129
|
+
model call does not (see Gotchas).
|
|
130
|
+
- On SQLite there is one connection. A transaction whose callback is `async`
|
|
131
|
+
holds it until it settles, so a transaction that starts meanwhile queues
|
|
132
|
+
behind it and is a promise whatever its own callback does. With only
|
|
133
|
+
synchronous callbacks that cannot happen.
|
|
134
|
+
- MySQL and Postgres run on a worker thread the caller waits on, sharing one
|
|
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`
|
|
138
|
+
gives promises back for both; every call then has to be awaited.
|
|
139
|
+
|
|
90
140
|
For reads which cannot tolerate replication lag, use `db.primary.selectFrom(...)`.
|
|
91
141
|
It stays on the primary when automatic replica routing is enabled, and uses the
|
|
92
142
|
active transaction connection inside a transaction. It does not mark the request
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: stacks-http
|
|
3
|
-
description: Use when choosing HTTP status constants, bounded fetch, outbound Httx requests, transport fakes, retry/circuit behavior, or the boundary with reactive browser fetching. Covers @stacksjs/http and @stacksjs/httx.
|
|
3
|
+
description: Use when choosing HTTP status constants, bounded fetch, sanitized transfer observations, caller-read progress diagnostics, outbound Httx requests, transport fakes, retry/circuit behavior, or the boundary with reactive browser fetching. Covers @stacksjs/http and @stacksjs/httx.
|
|
4
4
|
license: MIT
|
|
5
5
|
compatibility: Bun >= 1.3.0, TypeScript
|
|
6
6
|
allowed-tools: Read Edit Write Bash Grep Glob
|
|
@@ -43,6 +43,35 @@ body or a Request with a body is sent once, returning its original response;
|
|
|
43
43
|
use a URL plus buffered bytes for retryable uploads. The budget ends when final
|
|
44
44
|
response headers arrive, so the caller still owns subsequent body consumption.
|
|
45
45
|
|
|
46
|
+
## Transfer observations
|
|
47
|
+
|
|
48
|
+
Use `fetchWithBudget`'s optional `observer.onAttempt` and `observer.onResponse`
|
|
49
|
+
for actual request-attempt and selected-response metadata. Callbacks preserve
|
|
50
|
+
their receiver, are never awaited, and isolate getter/call/promise failures.
|
|
51
|
+
Their immutable records retain HTTP(S) origins, attempt, status and a strictly
|
|
52
|
+
parsed optional Content-Length. They exclude URL credentials/path/query/fragment,
|
|
53
|
+
arbitrary headers and body content. Oversized or invalid metadata is omitted.
|
|
54
|
+
|
|
55
|
+
Use `createHttpTransferObservation()` for a fixed diagnostic report. Pass its
|
|
56
|
+
`observer` to the native request, feed `received(byteLength)` from the caller's
|
|
57
|
+
same existing nonempty-chunk read loop, then `finish(reason)` from the caller's
|
|
58
|
+
actual terminal outcome. The native collector adds no request, timer or body
|
|
59
|
+
reader and changes no transfer, retry, cancellation, hash or publication policy.
|
|
60
|
+
Keep the caller's body deadline and inactivity controller active after headers.
|
|
61
|
+
|
|
62
|
+
Reports contain copied metadata, byte/chunk totals and monotonic header/byte/gap
|
|
63
|
+
timings. Retention is 12 ten-second buckets; observations after 120000 ms merge
|
|
64
|
+
into the last bucket with `coalesced`. This boundary is not a download deadline.
|
|
65
|
+
Invalid observations are flagged, counters saturate rather than wrap, and
|
|
66
|
+
`finish` returns an idempotent deeply frozen snapshot. Counts describe what the
|
|
67
|
+
caller reports, not an independent measurement of socket traffic.
|
|
68
|
+
|
|
69
|
+
Read the [HTTP package README](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/http/README.md)
|
|
70
|
+
for the complete caller-owned read example, metadata bounds, terminal reasons
|
|
71
|
+
and evidence limits. Real loopback cases cover requests and caller reads;
|
|
72
|
+
worked clock cases cover aggregation. Neither establishes remote throughput or
|
|
73
|
+
an application's original-content acquisition acceptance.
|
|
74
|
+
|
|
46
75
|
## Httx client and fluent requests
|
|
47
76
|
|
|
48
77
|
The separate `@stacksjs/httx` dependency exports HttxClient, the httx facade,
|
|
@@ -86,4 +115,6 @@ buddy http makes an outbound diagnostic request; use its help for options.
|
|
|
86
115
|
Source: `storage/framework/core/http/src/index.ts` and
|
|
87
116
|
`core/buddy/src/commands/http.ts`. Httx's public contract is the installed
|
|
88
117
|
dependency's package exports/declarations. Retained local status/helper tests
|
|
89
|
-
are in `core/http/tests/http.test.ts
|
|
118
|
+
are in `core/http/tests/http.test.ts`, `fetch-budget.test.ts`,
|
|
119
|
+
`retry-after.test.ts` and `transfer-observation.test.ts`; they do not prove a
|
|
120
|
+
remote provider SLA or published-package consumer acceptance.
|
|
@@ -35,7 +35,7 @@ Browser runtime bindings are documented separately in `stacks-auto-imports`.
|
|
|
35
35
|
| `@stacksjs/composables` | [`stacks-composables`](../stacks-composables/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/composables/src/index.ts) | 18 |
|
|
36
36
|
| `@stacksjs/config` | [`stacks-config`](../stacks-config/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/config/src/index.ts) | 16 |
|
|
37
37
|
| `@stacksjs/cron` | [`stacks-cron`](../stacks-cron/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/cron/src/index.ts) | 6 |
|
|
38
|
-
| `@stacksjs/database` | [`stacks-database`](../stacks-database/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/index.ts) |
|
|
38
|
+
| `@stacksjs/database` | [`stacks-database`](../stacks-database/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/index.ts) | 146 |
|
|
39
39
|
| `@stacksjs/datetime` | [`stacks-datetime`](../stacks-datetime/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/datetime/src/index.ts) | 22 |
|
|
40
40
|
| `@stacksjs/defaults` | [`stacks-build`](../stacks-build/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/defaults/package.json) | 3 |
|
|
41
41
|
| `@stacksjs/deploy` | [`stacks-deploy`](../stacks-deploy/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/deploy/package.json) | 1 |
|
|
@@ -56,7 +56,7 @@ Browser runtime bindings are documented separately in `stacks-auto-imports`.
|
|
|
56
56
|
| `@stacksjs/github` | [`stacks-git`](../stacks-git/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/github/src/index.ts) | 8 |
|
|
57
57
|
| `@stacksjs/health` | [`stacks-health`](../stacks-health/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/health/src/index.ts) | 2 |
|
|
58
58
|
| `@stacksjs/hq` | [`stacks-hq`](../stacks-hq/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/hq/src/index.ts) | 8 |
|
|
59
|
-
| `@stacksjs/http` | [`stacks-http`](../stacks-http/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/http/src/index.ts) |
|
|
59
|
+
| `@stacksjs/http` | [`stacks-http`](../stacks-http/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/http/src/index.ts) | 4 |
|
|
60
60
|
| `@stacksjs/i18n` | [`stacks-i18n`](../stacks-i18n/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/i18n/src/index.ts) | 5 |
|
|
61
61
|
| `@stacksjs/image` | [`stacks-image`](../stacks-image/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/image/src/index.ts) | 4 |
|
|
62
62
|
| `@stacksjs/lint` | [`stacks-lint`](../stacks-lint/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/lint/src/index.ts) | 3 |
|
|
@@ -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 |
|
|
@@ -358,7 +358,7 @@ Declared runtime exports: `Database`, `EntityQueryBuilder`, `__flushAfterCommitN
|
|
|
358
358
|
|
|
359
359
|
Local source modules: [src/affected-rows.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/affected-rows.ts), [src/auth-tables.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/auth-tables.ts), [src/custom/index.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/custom/index.ts), [src/database.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/database.ts), [src/datetime-columns.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/datetime-columns.ts), [src/ddl-constraints.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/ddl-constraints.ts), [src/defaults.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/defaults.ts), [src/dialect.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/dialect.ts), [src/driver-config.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/driver-config.ts), [src/drivers/dynamodb.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/drivers/dynamodb.ts), [src/drivers/index.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/drivers/index.ts), [src/ensure-database.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/ensure-database.ts), [src/erd.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/erd.ts), [src/fk-audit.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/fk-audit.ts), [src/framework-renames.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/framework-renames.ts), [src/framework-route-admission.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/framework-route-admission.ts), [src/hand-written-migrations.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/hand-written-migrations.ts), [src/ignored-migrations.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/ignored-migrations.ts), [src/index-shape.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/index-shape.ts), [src/managed-columns.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/managed-columns.ts), [src/migration-dialect.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/migration-dialect.ts), [src/migration-ledger.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/migration-ledger.ts), [src/migration-names.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/migration-names.ts), [src/migration-path.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/migration-path.ts), [src/migrations.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/migrations.ts), [src/model-sources.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/model-sources.ts), [src/notification-tables.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/notification-tables.ts), [src/package-migrations.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/package-migrations.ts), [src/package-models.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/package-models.ts), [src/query-logger.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/query-logger.ts), [src/rbac-tables.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/rbac-tables.ts), [src/relation-columns.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/relation-columns.ts), [src/replicas.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/replicas.ts), [src/row-lease.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/row-lease.ts), [src/row-lock.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/row-lock.ts), [src/safe-migrations.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/safe-migrations.ts), [src/schema-align.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/schema-align.ts), [src/schema-drift.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/schema-drift.ts), [src/seeder.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/seeder.ts), [src/shadowed-models.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/shadowed-models.ts), [src/sql-helpers.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/sql-helpers.ts), [src/table-exists.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/table-exists.ts), [src/trait-tables.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/trait-tables.ts), [src/transaction-context.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/transaction-context.ts), [src/transaction-options.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/transaction-options.ts), [src/types.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/types.ts), [src/unique-audit.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/unique-audit.ts), [src/utc-defaults.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/utc-defaults.ts), [src/utils.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/utils.ts), [src/uuid-columns.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/uuid-columns.ts), [src/vschema.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/src/vschema.ts).
|
|
360
360
|
|
|
361
|
-
Evidence directory: [
|
|
361
|
+
Evidence directory: [146 retained tests](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/database/tests). These files are evidence pointers, not a claim that all tests were run for this catalog.
|
|
362
362
|
|
|
363
363
|
### @stacksjs/datetime
|
|
364
364
|
|
|
@@ -554,11 +554,11 @@ Evidence directory: [8 retained tests](https://github.com/stacksjs/stacks/blob/m
|
|
|
554
554
|
|
|
555
555
|
Guidance: [`stacks-http`](../stacks-http/SKILL.md). Source: [storage/framework/core/http/src/index.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/http/src/index.ts).
|
|
556
556
|
|
|
557
|
-
Declared runtime exports: `Response`, `fetchWithBudget`, `retryAfterMilliseconds`.
|
|
557
|
+
Declared runtime exports: `Response`, `createHttpTransferObservation`, `fetchWithBudget`, `retryAfterMilliseconds`.
|
|
558
558
|
|
|
559
|
-
Local source modules: [src/retry-after.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/http/src/retry-after.ts).
|
|
559
|
+
Local source modules: [src/retry-after.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/http/src/retry-after.ts), [src/transfer-observation.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/http/src/transfer-observation.ts).
|
|
560
560
|
|
|
561
|
-
Evidence directory: [
|
|
561
|
+
Evidence directory: [4 retained tests](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/http/tests). These files are evidence pointers, not a claim that all tests were run for this catalog.
|
|
562
562
|
|
|
563
563
|
### @stacksjs/i18n
|
|
564
564
|
|
|
@@ -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,19 +62,29 @@ 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
|
-
- **
|
|
69
|
-
`transaction()`
|
|
72
|
+
- **The `db` query builder too.** `db.selectFrom(...).get()` is the rows and
|
|
73
|
+
`transaction(tx => ...)` is done when it returns, on the same rule (see
|
|
74
|
+
`stacks-database`, "Values, not promises").
|
|
70
75
|
- **Inside `db.transaction()`, write through `tx`, not through a model.** A
|
|
71
|
-
model call runs on its own connection
|
|
72
|
-
waits for
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
default, `0` for no limit)
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
model call runs on its own connection. One that needs a row the open
|
|
77
|
+
transaction has locked waits for that transaction to finish, and if the
|
|
78
|
+
transaction's own callback is what is waiting for the model call, neither
|
|
79
|
+
can: it fails with `StatementTimeoutError` after `models.timeoutMs` (30
|
|
80
|
+
seconds by default, `0` for no limit). Postgres cancels the abandoned
|
|
81
|
+
statement; MySQL cannot, so there it may still be applied once the lock is
|
|
82
|
+
gone.
|
|
83
|
+
- **The one model call that is a promise.** While a transaction with an
|
|
84
|
+
`async` callback is open in the process, a model call that needs a lock it
|
|
85
|
+
holds answers with a promise instead of waiting on the thread the commit
|
|
86
|
+
needs (see `stacks-database`, "Values, not promises"). Any other call is
|
|
87
|
+
still a value.
|
|
78
88
|
|
|
79
89
|
### Writes: in place, with the work around them
|
|
80
90
|
|