@stacksjs/defaults 0.75.552 → 0.75.555
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-dashboard/SKILL.md +347 -14
- package/ai/skills/stacks-desktop/SKILL.md +19 -0
- package/ai/skills/stacks-models/SKILL.md +19 -0
- package/ai/skills/stacks-native/CATALOG.md +5 -5
- package/app/Actions/Dashboard/Content/file-manager.ts +9 -3
- package/app/Actions/Dashboard/Data/SubscriberIndexAction.ts +6 -3
- package/app/Actions/Dashboard/Data/TeamIndexAction.ts +6 -3
- package/app/Actions/Dashboard/Data/UserIndexAction.ts +6 -3
- package/app/Actions/Dashboard/Data/data-records.ts +12 -0
- package/app/Actions/Dashboard/Models/ModelActionRunAction.ts +77 -0
- package/app/Actions/Dashboard/Models/ModelMarkdownAction.ts +42 -0
- package/app/Actions/Dashboard/Models/ModelShowAction.ts +63 -21
- package/app/Actions/Dashboard/Models/ModelUploadAction.ts +83 -0
- package/app/Actions/Dashboard/Models/model-actions.ts +393 -0
- package/app/Actions/Dashboard/Models/model-fields.ts +198 -0
- package/app/Actions/Dashboard/Models/model-forms.ts +36 -0
- package/app/Actions/Dashboard/Models/model-related.ts +62 -11
- package/app/Actions/Dashboard/Models/model-upload.ts +81 -0
- package/app/Actions/Dashboard/Models/model-write.ts +92 -5
- package/app/Actions/Dashboard/Users/UserPasswordResetAction.ts +50 -0
- package/app/Actions/Desktop/UpdateArtifactAction.ts +37 -0
- package/app/Models/CardAttachment.ts +5 -0
- package/app/Models/Deployment.ts +5 -0
- package/app/Models/QueryLog.ts +5 -0
- package/app/Models/Request.ts +4 -0
- package/app/Models/Team.ts +4 -0
- package/app/Models/User.ts +18 -0
- package/functions/dashboard-markdown.ts +132 -0
- package/functions/dashboard-model-bulk.ts +224 -0
- package/functions/dashboard-model-format.ts +201 -0
- package/functions/dashboard-model-record.test.ts +53 -30
- package/functions/dashboard-model-record.ts +267 -19
- package/functions/data.ts +9 -0
- package/ide/vscode/package.json +1 -1
- package/package.json +3 -3
- package/resources/components/Dashboard/Data/ActivityLog.stx +212 -0
- package/resources/components/Dashboard/Data/DataModelRecords.stx +89 -0
- package/resources/components/Dashboard/Models/ModelActionForm.stx +85 -0
- package/resources/components/Dashboard/Models/ModelBadge.stx +22 -0
- package/resources/components/Dashboard/Models/ModelFieldInputs.stx +43 -9
- package/resources/components/Dashboard/Models/ModelMarkdownInput.stx +139 -0
- package/resources/components/Dashboard/Models/ModelRecordActions.stx +32 -1
- package/resources/components/Dashboard/Models/ModelRecordCreate.stx +1 -1
- package/resources/components/Dashboard/Models/ModelRecordDetail.stx +114 -7
- package/resources/components/Dashboard/Models/ModelRecordEdit.stx +1 -1
- package/resources/components/Dashboard/Models/ModelRecordsDashboard.stx +387 -20
- package/resources/components/Dashboard/Models/ModelRelatedPanels.stx +197 -27
- package/resources/components/Dashboard/Models/ModelRelationPicker.stx +3 -0
- package/resources/components/Dashboard/Models/ModelUploadInput.stx +97 -0
- package/routes/dashboard-api.ts +9 -0
- package/routes/desktop-updates.ts +7 -0
- package/views/dashboard/data/activity/index.stx +1 -1
- package/views/dashboard/data/subscribers.stx +1 -3
- package/views/dashboard/data/teams.stx +1 -3
- package/views/dashboard/data/users.stx +1 -3
- package/resources/components/Dashboard/Data/DataRecords.stx +0 -427
|
@@ -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 756 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
|
|
@@ -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 426 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, 426 components, and a multi-section layout.
|
|
12
12
|
|
|
13
13
|
## Key Paths
|
|
14
14
|
- Dashboard components: `storage/framework/defaults/resources/components/Dashboard/`
|
|
@@ -210,10 +210,10 @@ against `taggables`, which is a different table from `tags`.
|
|
|
210
210
|
|
|
211
211
|
### Data Management
|
|
212
212
|
- `/data/dashboard` - data overview
|
|
213
|
-
- `/data/users` -
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
- `/data/activity` - persisted activity
|
|
213
|
+
- `/data/users`, `/data/subscribers`, `/data/teams` - the model's own list
|
|
214
|
+
under the page's title and stats (see "Users, Teams and Subscribers are the
|
|
215
|
+
model's list")
|
|
216
|
+
- `/data/activity` - persisted activity, read-only (`Data/ActivityLog.stx`)
|
|
217
217
|
- `/models`, `/models/{model}` - generic model registry and explorer
|
|
218
218
|
- `/notifications/dashboard`, `/notifications/history` - notification operations
|
|
219
219
|
|
|
@@ -799,6 +799,128 @@ not "Team ID"). The list endpoint returns the names with the rows
|
|
|
799
799
|
(`relationNames`), one lookup per related model per page, and a record's page
|
|
800
800
|
uses the same ones.
|
|
801
801
|
|
|
802
|
+
### A model says how a field is called, shown and asked for
|
|
803
|
+
|
|
804
|
+
An attribute says what a field is. It cannot say that `amount` is money and
|
|
805
|
+
`sizeBytes` is a size (both are numbers), or that `created_at` is called
|
|
806
|
+
"Joined" here. `dashboard.fields` is where the model says so, one field at a
|
|
807
|
+
time; everything it leaves out stays derived.
|
|
808
|
+
|
|
809
|
+
```ts
|
|
810
|
+
dashboard: {
|
|
811
|
+
fields: {
|
|
812
|
+
createdAt: { label: 'Joined' },
|
|
813
|
+
amount: { format: 'money', currencyField: 'currency' },
|
|
814
|
+
sizeBytes: { label: 'Size', format: 'bytes' },
|
|
815
|
+
duration: { format: 'duration', unit: 's' },
|
|
816
|
+
notes: { input: 'longtext', help: 'Shown to the customer on their receipt.' },
|
|
817
|
+
},
|
|
818
|
+
}
|
|
819
|
+
```
|
|
820
|
+
|
|
821
|
+
A name is an attribute (`createdAt`), its column (`created_at`), or a
|
|
822
|
+
`belongsTo` (`team` for `team_id`), as in `dashboard.columns`.
|
|
823
|
+
|
|
824
|
+
- `label` is what the field is called on every page that names it: the
|
|
825
|
+
list's heading, the record's label, the form's input, a panel's column and
|
|
826
|
+
the messages about it ("Order number is required."). One function,
|
|
827
|
+
`modelColumnLabel`, resolves it, so the pages cannot disagree. Left out, it
|
|
828
|
+
is the record a relation points at ("Team"), else the name in words, with a
|
|
829
|
+
moment read as what happened: "Created", "Email Verified", "Last Updated".
|
|
830
|
+
- `format` is how the stored value reads in a list, on the record's page and
|
|
831
|
+
in a panel:
|
|
832
|
+
|
|
833
|
+
| Format | Stored | Reads as |
|
|
834
|
+
|---|---|---|
|
|
835
|
+
| `money` | minor units, in `currency` or the row's `currencyField` | `$12.00` |
|
|
836
|
+
| `number` | a number | `12,500` |
|
|
837
|
+
| `percent` | the share, 0 to 100 | `42.5%` |
|
|
838
|
+
| `bytes` | a byte count | `1.5 KB` |
|
|
839
|
+
| `duration` | milliseconds, or seconds with `unit: 's'` | `1 min 23 s` |
|
|
840
|
+
| `date`, `datetime` | a day, or a moment | in the viewer's locale and zone |
|
|
841
|
+
| `badge` | a status-like word | a pill |
|
|
842
|
+
| `link` | a web or mail address | a link in a new tab |
|
|
843
|
+
| `image` | a web address or a path on the site | a thumbnail |
|
|
844
|
+
| `code` | an identifier, a token, SQL | a code font |
|
|
845
|
+
| `text` | anything | as stored, undressed |
|
|
846
|
+
|
|
847
|
+
Amounts line up on the right. A value the format cannot read is shown as
|
|
848
|
+
stored, and a `link` or `image` only ever leads to an `http(s)` or mail
|
|
849
|
+
address, or a path on the site.
|
|
850
|
+
- `help` is a sentence under the field's input in the create and edit forms.
|
|
851
|
+
- `input` picks the input a field of text gets: `text`, `longtext`, `email`,
|
|
852
|
+
`url`, `markdown` or `upload` (both below). Only for text: what a value is
|
|
853
|
+
stays the validation rule's to say, so a number cannot be asked for as
|
|
854
|
+
prose.
|
|
855
|
+
|
|
856
|
+
It changes how a field reads, never what may be read or written: a `hidden`
|
|
857
|
+
attribute stays hidden, and a field that is not `fillable` stays out of the
|
|
858
|
+
forms. A setting that cannot be read is dropped on its own (a misspelled
|
|
859
|
+
format does not cost the field its heading) and logged once by name
|
|
860
|
+
(`[dashboard] Order dashboard.fields: 'total' asks for a format the dashboard
|
|
861
|
+
does not have: 'cash'...`).
|
|
862
|
+
|
|
863
|
+
Formatting happens in the browser (`functions/dashboard-model-format.ts`),
|
|
864
|
+
since it follows the viewer's locale and time zone; the list endpoint sends
|
|
865
|
+
each column's `label` and `format` in `columnMeta`.
|
|
866
|
+
|
|
867
|
+
The shipped models whose stored unit is certain describe theirs: request and
|
|
868
|
+
query durations, a deployment's duration (seconds) and address, an
|
|
869
|
+
attachment's size, a user's avatar. `tests/unit/dashboard-model-field-overrides.test.ts`
|
|
870
|
+
checks that every shipped entry names a real field.
|
|
871
|
+
|
|
872
|
+
Not offered yet: wording for single enum values.
|
|
873
|
+
|
|
874
|
+
### A field asked for as an uploaded file
|
|
875
|
+
|
|
876
|
+
```ts
|
|
877
|
+
fields: { avatar: { input: 'upload', accept: 'image/*' } }
|
|
878
|
+
```
|
|
879
|
+
|
|
880
|
+
A file chooser (`Dashboard/Models/ModelUploadInput`) whose value is the
|
|
881
|
+
address the chosen file was stored at. Choosing a file stores it at once;
|
|
882
|
+
the address is saved with the rest of the form, so nothing about a record
|
|
883
|
+
changes until then. What the field holds is shown (a thumbnail when it is a
|
|
884
|
+
picture) and can be replaced or removed. Removing empties the field; it does
|
|
885
|
+
not delete the file.
|
|
886
|
+
|
|
887
|
+
- `POST /api/dashboard/models/{slug}/uploads` (multipart `file` and `field`)
|
|
888
|
+
only takes a file for a field the model asks for as `upload`, on a model
|
|
889
|
+
the dashboard may write, up to 10 MB.
|
|
890
|
+
- It is kept on the `public` disk under `uploads/<table>/<column>/` with a
|
|
891
|
+
generated name, through the pipeline the Files page uses, so it is listed
|
|
892
|
+
there with its preview. That pipeline needs the `storage_items` and
|
|
893
|
+
`storage_item_tasks` tables.
|
|
894
|
+
- `accept` is spelled as a file input spells it (`image/*`, `image/png`,
|
|
895
|
+
`.pdf`, or several). The chooser offers those, and the server holds to
|
|
896
|
+
them by what the file's bytes say it is (`uploadAccepts` in
|
|
897
|
+
`model-upload.ts`), not what it was sent as: a script sent as `photo.png`
|
|
898
|
+
is not an image. An SVG is taken only where it is named.
|
|
899
|
+
- Without a `format`, a field that only takes images is shown as a picture
|
|
900
|
+
and any other upload as a link.
|
|
901
|
+
|
|
902
|
+
### A field asked for as Markdown
|
|
903
|
+
|
|
904
|
+
```ts
|
|
905
|
+
fields: { body: { input: 'markdown' } }
|
|
906
|
+
```
|
|
907
|
+
|
|
908
|
+
An editor (`Dashboard/Models/ModelMarkdownInput`) with a toolbar for the
|
|
909
|
+
common marks (bold, italic, heading, link, lists, quote, code) and a preview.
|
|
910
|
+
A button wraps what is selected, or marks the lines it touches, and comes
|
|
911
|
+
off again when pressed twice (`applyMarkdown` in
|
|
912
|
+
`functions/dashboard-markdown.ts`). The stored value is the Markdown itself.
|
|
913
|
+
|
|
914
|
+
The preview is rendered by the server (`POST /api/dashboard/markdown`: Bun's
|
|
915
|
+
Markdown parser, the one Stacks content is rendered with, then
|
|
916
|
+
`@stacksjs/sanitizer`) and shown in a sandboxed frame with a policy that
|
|
917
|
+
forbids script, as captured email is. It is never bound into the page.
|
|
918
|
+
|
|
919
|
+
This is Markdown, not a what-you-see-is-what-you-get HTML editor: there is no
|
|
920
|
+
editing engine in the stack. A record's page shows the Markdown as written,
|
|
921
|
+
with its line breaks; it is not rendered there. An action's input can be
|
|
922
|
+
asked for as `markdown` too, and never as `upload`.
|
|
923
|
+
|
|
802
924
|
### A record's page lists who points at it
|
|
803
925
|
|
|
804
926
|
For each `hasMany` and `hasOne` a model declares, its record page shows a
|
|
@@ -816,9 +938,36 @@ Either way the link back to the page's own record is left out.
|
|
|
816
938
|
- "View all" opens the related model's list narrowed to this record
|
|
817
939
|
(`/models/team-member?filters={"team_id":"3"}`); the list arrives with its
|
|
818
940
|
filter row open.
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
941
|
+
|
|
942
|
+
Where the related model lets the dashboard write its rows (its
|
|
943
|
+
`dashboard.writes`, else its `useApi` routes, as for its own pages), the
|
|
944
|
+
panel is where they are managed. Nothing is declared for it.
|
|
945
|
+
|
|
946
|
+
- "Add" opens a form over the page with this record already chosen, and the
|
|
947
|
+
new row appears in the panel. It is offered when that model can be created
|
|
948
|
+
from the dashboard, and for a `hasOne` only while there is none.
|
|
949
|
+
- The pencil opens the same form with the row's values, and sends only what
|
|
950
|
+
changed.
|
|
951
|
+
- The trash asks first, then deletes the row.
|
|
952
|
+
|
|
953
|
+
The form asks for the related model's own fields the way its create and edit
|
|
954
|
+
pages do (`modelFormFields`: labels, help and inputs from `dashboard.fields`,
|
|
955
|
+
a picker for each relation the dashboard can reach), without the link back
|
|
956
|
+
to this record. The panel carries them as `fields`, and each listed row's
|
|
957
|
+
stored values as `values`; `canUpdate` and `canDestroy` say which buttons a
|
|
958
|
+
row gets. A refused write is shown in the form, under its field.
|
|
959
|
+
|
|
960
|
+
Each save is one write through the related model, on the endpoints its own
|
|
961
|
+
pages use (`POST`, `PATCH` and `DELETE /api/dashboard/models/{slug}`), so
|
|
962
|
+
casts, observers, validation and soft deletes apply and nothing new is
|
|
963
|
+
opened. The panels are read again afterwards.
|
|
964
|
+
|
|
965
|
+
There is no form that saves a record and its rows together, all or nothing.
|
|
966
|
+
A write made through a model takes no part in `transaction()`
|
|
967
|
+
(stacksjs/stacks#3269), so a combined save could leave the record changed
|
|
968
|
+
and a row not. Until the model layer joins a transaction, an operation that
|
|
969
|
+
must be atomic across models belongs in an action that writes through the
|
|
970
|
+
transaction's own handle.
|
|
822
971
|
|
|
823
972
|
The link between the two models is the foreign key the declaration names,
|
|
824
973
|
else the related model's own `belongsTo`, else the conventional
|
|
@@ -831,6 +980,145 @@ the value breaks, or a `unique` value another row holds). A delete the
|
|
|
831
980
|
database refuses because other records point at the row is reported as that,
|
|
832
981
|
and an account cannot delete itself.
|
|
833
982
|
|
|
983
|
+
### A model names its own actions
|
|
984
|
+
|
|
985
|
+
Everything above is derived from what a model is. A button that does
|
|
986
|
+
something ("Mark as shipped") is behaviour, so the model does not describe
|
|
987
|
+
it: it names it, and an action under `app/Actions` does the work.
|
|
988
|
+
|
|
989
|
+
```ts
|
|
990
|
+
dashboard: {
|
|
991
|
+
actions: [
|
|
992
|
+
{
|
|
993
|
+
name: 'ship', // its place in the URL
|
|
994
|
+
label: 'Mark as shipped', // else the name in words
|
|
995
|
+
action: 'Actions/Orders/ShipOrderAction', // as a route names one
|
|
996
|
+
icon: 'i-hugeicons-truck-delivery', // else a bolt
|
|
997
|
+
confirm: 'The customer is emailed a tracking link.',
|
|
998
|
+
when: { status: ['paid', 'packed'], shippedAt: null },
|
|
999
|
+
},
|
|
1000
|
+
],
|
|
1001
|
+
}
|
|
1002
|
+
```
|
|
1003
|
+
|
|
1004
|
+
- Each entry is a button on the record's page and an icon in its row of the
|
|
1005
|
+
model's list. `on: ['record']` or `on: ['row']` keeps it to one, and
|
|
1006
|
+
`'bulk'` offers it for the rows selected in the list (below).
|
|
1007
|
+
- `when` names the records it is for: each field with the value, or list of
|
|
1008
|
+
values, a record must hold (`null` is "nothing stored"). A field may be one
|
|
1009
|
+
the dashboard hides. The server decides which rows are sent which action
|
|
1010
|
+
(`rowActions`, by row id) and checks again before running one, so asking
|
|
1011
|
+
for a hidden button is refused with a 409.
|
|
1012
|
+
- `confirm` asks first, in the sentence given. `destructive: true` draws the
|
|
1013
|
+
button and its confirmation in red.
|
|
1014
|
+
- An erased account is offered none.
|
|
1015
|
+
|
|
1016
|
+
`POST /api/dashboard/models/{model}/{id}/actions/{name}` runs the action **as
|
|
1017
|
+
its own route would** (`resolveActionHandler` in `@stacksjs/router`): the
|
|
1018
|
+
record's id is the `id` route parameter, so an action already served at
|
|
1019
|
+
`/orders/{id}/ship` needs nothing changed, and its `validations`, `authorize`
|
|
1020
|
+
and `before` all apply. The action needs no route of its own.
|
|
1021
|
+
|
|
1022
|
+
What it answers is what the operator is told:
|
|
1023
|
+
|
|
1024
|
+
- a refusal, returned or thrown with any status from 400 up, is shown with
|
|
1025
|
+
its `message`;
|
|
1026
|
+
- a success may carry `message`, shown as the confirmation, and `redirect`, a
|
|
1027
|
+
dashboard path to open (`/models/order/31`). Without a redirect the page
|
|
1028
|
+
reads the record again, since what it is offered may have changed.
|
|
1029
|
+
|
|
1030
|
+
A declaration that cannot be read, or whose action cannot be loaded, is left
|
|
1031
|
+
out and logged once by name (`[dashboard] Order dashboard.actions: 'ship'
|
|
1032
|
+
names Actions/Orders/ShipOrderAction, which could not be loaded...`). A
|
|
1033
|
+
handler string is not checked by the compiler, so this is checked when the
|
|
1034
|
+
list is drawn, not when someone presses the button.
|
|
1035
|
+
|
|
1036
|
+
`User` ships one, on its record page only: "Send password reset"
|
|
1037
|
+
(`Actions/Dashboard/Users/UserPasswordResetAction`), which mails the account's
|
|
1038
|
+
holder the "Forgot password" link. Remove the entry to turn it off.
|
|
1039
|
+
|
|
1040
|
+
Not offered on the hand-built Users, Teams and Subscribers lists, whose rows
|
|
1041
|
+
lead to the record page where the buttons are.
|
|
1042
|
+
|
|
1043
|
+
### An action that takes input is asked for it
|
|
1044
|
+
|
|
1045
|
+
An action says what it takes in its own `validations`, and the dashboard
|
|
1046
|
+
asks: pressing a button whose action validates anything opens a form over
|
|
1047
|
+
the page (`Dashboard/Models/ModelActionForm`), not a confirmation.
|
|
1048
|
+
|
|
1049
|
+
```ts
|
|
1050
|
+
// app/Actions/Orders/RefundOrderAction.ts
|
|
1051
|
+
validations: {
|
|
1052
|
+
reason: { rule: schema.string().required().min(3), message: 'Say why.' },
|
|
1053
|
+
restock: { rule: schema.boolean() },
|
|
1054
|
+
method: { rule: schema.enum(['card', 'credit']).required() },
|
|
1055
|
+
}
|
|
1056
|
+
```
|
|
1057
|
+
|
|
1058
|
+
- One input per validation, in the control its rule calls for (text, a
|
|
1059
|
+
number box, a select for an enum, a checkbox, a date), required where the
|
|
1060
|
+
rule is. Route parameters such as `id` are never asked for.
|
|
1061
|
+
- The form is the confirmation: the model's `confirm` sentence sits above
|
|
1062
|
+
the inputs, and nothing runs until it is submitted.
|
|
1063
|
+
- What was typed is sent as the JSON body, as the action's own route would
|
|
1064
|
+
receive it, each value the type its rule expects. The action validates it
|
|
1065
|
+
as it always does; nothing is checked twice in two places.
|
|
1066
|
+
- A refusal comes back in the form: under its field for a validation
|
|
1067
|
+
message, at the top for anything else ("Already refunded.").
|
|
1068
|
+
- For a selection the form is asked once and its answers go to every
|
|
1069
|
+
record. If the first record refuses the input itself, nothing has run and
|
|
1070
|
+
the form says why.
|
|
1071
|
+
|
|
1072
|
+
The model can say how a field is asked, in the vocabulary `dashboard.fields`
|
|
1073
|
+
uses (`label`, `help`, and `input` for a field of text):
|
|
1074
|
+
|
|
1075
|
+
```ts
|
|
1076
|
+
actions: [{
|
|
1077
|
+
name: 'refund',
|
|
1078
|
+
action: 'Actions/Orders/RefundOrderAction',
|
|
1079
|
+
fields: { reason: { label: 'Reason for the refund', input: 'longtext', help: 'Shown to the customer.' } },
|
|
1080
|
+
}]
|
|
1081
|
+
```
|
|
1082
|
+
|
|
1083
|
+
An action that requires what a form cannot give (a list, a structure, a
|
|
1084
|
+
file, a password) is left out and logged by name; an optional one of those
|
|
1085
|
+
is simply not asked for. `resolveActionValidations()` in `@stacksjs/router`
|
|
1086
|
+
is how the dashboard reads what an action takes.
|
|
1087
|
+
|
|
1088
|
+
### Rows are selected and acted on together
|
|
1089
|
+
|
|
1090
|
+
A model's list has a tick box on each row, and one in the heading for every
|
|
1091
|
+
row on the page, whenever there is something to do with a selection:
|
|
1092
|
+
|
|
1093
|
+
- **Delete**, where the model lets the dashboard delete its rows. Nothing is
|
|
1094
|
+
declared.
|
|
1095
|
+
- **The model's own actions** that name `'bulk'` under `on`, alone or beside
|
|
1096
|
+
`record` and `row`. Acting on many records is asked for by name; left out,
|
|
1097
|
+
an action is offered one record at a time.
|
|
1098
|
+
|
|
1099
|
+
With rows ticked, a bar above the table says how many and offers each of
|
|
1100
|
+
those. Every one asks first, whatever a single press does, and the
|
|
1101
|
+
confirmation says how many of the selection it applies to: a row an action's
|
|
1102
|
+
`when` rules out, or an account already anonymized, is left alone and
|
|
1103
|
+
counted. An action that applies to none of the selection cannot be pressed.
|
|
1104
|
+
|
|
1105
|
+
A selection is acted on **one record at a time**, each through the endpoint a
|
|
1106
|
+
single row uses (`functions/dashboard-model-bulk.ts`). So an action needs
|
|
1107
|
+
nothing changed to be offered in bulk, every guard a single press has
|
|
1108
|
+
applies to each record (`when`, `authorize`, `validations`, the self-delete
|
|
1109
|
+
guard, anonymizing a user others refer to), and the page shows how far it
|
|
1110
|
+
has got.
|
|
1111
|
+
|
|
1112
|
+
It is not all or nothing, and does not claim to be: a write through a model
|
|
1113
|
+
takes no part in a transaction (stacksjs/stacks#3269). The toast says what
|
|
1114
|
+
happened: how many were done and, for the rest, which and why ("Order 8:
|
|
1115
|
+
Already shipped."). A refusal about the record (any 4xx) goes on to the
|
|
1116
|
+
next. A failure that is not (a 5xx, no answer at all) stops the run and says
|
|
1117
|
+
where, so a broken backend is not pressed once per row.
|
|
1118
|
+
|
|
1119
|
+
A selection is the rows on the page; it is dropped when the list is read
|
|
1120
|
+
again. Selecting every match across pages is not offered.
|
|
1121
|
+
|
|
834
1122
|
### A user other records refer to is anonymized, not refused
|
|
835
1123
|
|
|
836
1124
|
Many tables point at `users`, so anyone who has signed in, joined a team or
|
|
@@ -850,17 +1138,62 @@ confirmation says this before the button is pressed; the response carries
|
|
|
850
1138
|
nothing refers to is still simply deleted. Every other model is still refused
|
|
851
1139
|
with the reason.
|
|
852
1140
|
|
|
853
|
-
An anonymized account is stored as `[erased]` / `erased-<id>`.
|
|
854
|
-
shows
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
1141
|
+
An anonymized account is stored as `[erased]` / `erased-<id>`. A list never
|
|
1142
|
+
shows those placeholders: the first erased column of the row reads
|
|
1143
|
+
"Anonymized user" and the others "Removed", and its own page carries a note.
|
|
1144
|
+
The list endpoint sends `anonymizedIds` (from `anonymizedRows('User', rows)`
|
|
1145
|
+
in `@stacksjs/orm`, which asks the erasure plan whether a row's personal
|
|
1146
|
+
columns hold what erasure writes) and, when there are any, `anonymizedColumns`
|
|
1147
|
+
(from `personalColumns('User')`, narrowed to the columns the list is sent, so
|
|
1148
|
+
a hidden password is never named). An anonymized account can be viewed and nothing else: its row
|
|
858
1149
|
loses the pencil and trash (the table's per-row `when`), its page has no Edit
|
|
859
1150
|
or Delete, and its edit address explains why there is no form. That is the
|
|
860
1151
|
dashboard's choice of what to offer, not a rule of the endpoints: deleting
|
|
861
1152
|
one again changes nothing, and a row given a real name and email again is an
|
|
862
1153
|
account again.
|
|
863
1154
|
|
|
1155
|
+
### Users, Teams and Subscribers are the model's list
|
|
1156
|
+
|
|
1157
|
+
`/data/users`, `/data/teams` and `/data/subscribers` used to be a second,
|
|
1158
|
+
hand-built list of a model that already had one, and the two drifted: row
|
|
1159
|
+
actions, selection, bulk actions, action forms, column choice and filters
|
|
1160
|
+
existed on `/models/{model}` and not where the sidebar leads, and the
|
|
1161
|
+
hand-built pages read only the newest 100 rows. They are now
|
|
1162
|
+
`Data/DataModelRecords.stx` (`mode="users|teams|subscribers"`), which hosts
|
|
1163
|
+
`Models/ModelRecordsDashboard.stx` (stacksjs/stacks#3277). Change the columns,
|
|
1164
|
+
labels, formats and actions on the model's `dashboard` block, not on the page.
|
|
1165
|
+
|
|
1166
|
+
The list takes four props when it is hosted: `model` (the slug, instead of the
|
|
1167
|
+
last part of the address), `heading`, `description`, and `home` (where its
|
|
1168
|
+
create, invite, view and edit links lead, so `/data/users/7` and not
|
|
1169
|
+
`/models/user/7`). It has a `summary` slot above the search, where the page
|
|
1170
|
+
puts its stat cards, and it emits `changed` after a delete, a bulk run that
|
|
1171
|
+
did something, or one of the model's actions, so the page reads its numbers
|
|
1172
|
+
again. The numbers come from the page's old endpoint asked for them alone:
|
|
1173
|
+
`GET /api/dashboard/users?only=stats` reads no rows (`statsOnly(request)` in
|
|
1174
|
+
`Data/data-records.ts`; `fetchDashboardStats(mode)` on the client).
|
|
1175
|
+
|
|
1176
|
+
Two stx behaviours shape this, and both fail silently:
|
|
1177
|
+
|
|
1178
|
+
- A prop bound by a parent client component is empty while the child is being
|
|
1179
|
+
set up and bound by the time it is mounted. The list's first load is in
|
|
1180
|
+
`onMount`; loaded sooner, it asked for a model named after the host's own
|
|
1181
|
+
address ("No ORM model named Users").
|
|
1182
|
+
- What a page puts in another component's slot is read against that
|
|
1183
|
+
component's names first. A `page` in the hosting page was the list's page
|
|
1184
|
+
number and the first card read "Total undefined". The hosting page's names
|
|
1185
|
+
are deliberately its own (`recordsPage`, `pageStats`, `loadPageStats`);
|
|
1186
|
+
`tests/unit/dashboard-data-pages.test.ts` fails if one collides.
|
|
1187
|
+
|
|
1188
|
+
A status-like column (`status`, `role`, `state`, ... : `MODEL_BADGE_COLUMNS`)
|
|
1189
|
+
is a pill in a list as it is on a record's page, both drawn by
|
|
1190
|
+
`Models/ModelBadge.stx`. `modelBadgeTone(word)` colours it only when the word
|
|
1191
|
+
says so: active, paid, published are positive; inactive, failed, cancelled
|
|
1192
|
+
negative; pending, draft, queued pending; anything else (a role, a plan)
|
|
1193
|
+
neutral. A field's own `format` still comes first (`modelCellDisplay`).
|
|
1194
|
+
|
|
1195
|
+
The Activity log is not a list of editable records and stays its own page.
|
|
1196
|
+
|
|
864
1197
|
### Users are invited, not typed in
|
|
865
1198
|
|
|
866
1199
|
`User.password` is required and hidden, so no form can supply it, and a
|
|
@@ -492,6 +492,25 @@ The server side is one default action, `Actions/Desktop/UpdateFeedAction`, mount
|
|
|
492
492
|
(204 when `?current=` is already that version, 404 when nothing was published). Override the action in
|
|
493
493
|
`app/Actions/Desktop/UpdateFeedAction.ts`, or mount it elsewhere in `routes/api.ts`.
|
|
494
494
|
|
|
495
|
+
The artifacts are served by a second default action beside it, `Actions/Desktop/UpdateArtifactAction`, at
|
|
496
|
+
`/api/updates/files/{channel}/{target}/{version}/{file}` (`target` is `<platform>-<arch>`). A release writes
|
|
497
|
+
that URL into the manifest and release.json, derived from `feedUrl`:
|
|
498
|
+
|
|
499
|
+
```
|
|
500
|
+
https://fettler.org/api/updates/files/stable/darwin-arm64/0.4.0/Fettler-0.4.0-arm64.zip
|
|
501
|
+
```
|
|
502
|
+
|
|
503
|
+
So a release on any disk can be downloaded with no further config, the default private local disk included
|
|
504
|
+
(nothing else serves `storage/app` over HTTP). The action streams from the disk with `content-length` and byte
|
|
505
|
+
ranges, and only ever reads a key of the artifact shape under `updates.prefix`. Set `updates.artifactBaseUrl`
|
|
506
|
+
only when a bucket or CDN serves the disk itself: artifacts are then downloaded from
|
|
507
|
+
`<artifactBaseUrl>/<prefix>/<channel>/<platform>-<arch>/<version>/<file>` and the route is not used.
|
|
508
|
+
|
|
509
|
+
The released artifacts must be on the disk the deployed server reads. With the local disk that means
|
|
510
|
+
releasing on the server, or copying `storage/app/<prefix>` to it. `release:desktop` refuses an artifact URL on
|
|
511
|
+
a loopback, `.localhost`, `.test` or `.local` host, since no installed app could download it;
|
|
512
|
+
`DESKTOP_RELEASE_ALLOW_LOCAL_URL=1` lets one through to rehearse against a local server.
|
|
513
|
+
|
|
495
514
|
In the app, the launcher checks once the window is up and every `updates.checkEveryHours` (default 24). The page
|
|
496
515
|
drives it at `/__desktop/update` (cookie required): `GET` is the status, `POST { action: 'check' }` asks the feed,
|
|
497
516
|
and `POST { action: 'install', acknowledge? }` installs. Installing verifies the manifest signature, the size and
|
|
@@ -142,6 +142,25 @@ API offers neither, and `store` for it means an emailed invitation, since no
|
|
|
142
142
|
form can supply a password. It opens nothing on the generated API. See
|
|
143
143
|
`stacks-dashboard`.
|
|
144
144
|
|
|
145
|
+
`dashboard: { fields: { amount: { label: 'Total', format: 'money' } } }` says
|
|
146
|
+
how one field is called, shown and asked for where the attribute cannot: a
|
|
147
|
+
`label`, a `format` (`money`, `number`, `percent`, `bytes`, `duration`, `date`,
|
|
148
|
+
`datetime`, `badge`, `link`, `image`, `code`, `text`), `help` under its input,
|
|
149
|
+
and for a field of text the `input` it gets (`text`, `longtext`, `email`,
|
|
150
|
+
`url`, `markdown` for an editor with a preview, `upload` for a file chooser
|
|
151
|
+
that stores the file and keeps its address, with `accept` for the kinds it
|
|
152
|
+
takes). It changes how a field reads, never what may be read or written. See
|
|
153
|
+
`stacks-dashboard`.
|
|
154
|
+
|
|
155
|
+
`dashboard: { actions: [{ name: 'ship', action: 'Actions/Orders/ShipOrderAction' }] }`
|
|
156
|
+
names what an operator can do to a record beyond editing it: each entry is a
|
|
157
|
+
button that runs an action of the app's on that record, with an optional
|
|
158
|
+
`label`, `icon`, `confirm` sentence, `destructive` flag, `on` (`record`,
|
|
159
|
+
`row`, `bulk` for a selection) and `when` (the field values a record must
|
|
160
|
+
hold). An action that takes input is asked for it in a form built from its
|
|
161
|
+
own `validations`; `fields` refines how each is asked. The model names the
|
|
162
|
+
behaviour and the action does it. See `stacks-dashboard`.
|
|
163
|
+
|
|
145
164
|
`useApi` is an API capability, not a dashboard-view generator. Its generated
|
|
146
165
|
routes are registered from the merged model registry. Framework defaults are
|
|
147
166
|
loaded first, then recursive `app/Models/` definitions override matching model
|
|
@@ -21,7 +21,7 @@ Browser runtime bindings are documented separately in `stacks-auto-imports`.
|
|
|
21
21
|
| `@stacksjs/auth` | [`stacks-auth`](../stacks-auth/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/auth/src/index.ts) | 132 |
|
|
22
22
|
| `@stacksjs/browser` | [`stacks-browser`](../stacks-browser/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/browser/src/index.ts) | 10 |
|
|
23
23
|
| `@stacksjs/browser-extension` | [`stacks-browser-extension`](../stacks-browser-extension/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/browser-extension/src/index.ts) | 9 |
|
|
24
|
-
| `@stacksjs/buddy` | [`stacks-buddy`](../stacks-buddy/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/buddy/src/index.ts) |
|
|
24
|
+
| `@stacksjs/buddy` | [`stacks-buddy`](../stacks-buddy/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/buddy/src/index.ts) | 192 |
|
|
25
25
|
| `@stacksjs/build` | [`stacks-build`](../stacks-build/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/build/src/index.ts) | 7 |
|
|
26
26
|
| `@stacksjs/cache` | [`stacks-cache`](../stacks-cache/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/cache/src/index.ts) | 24 |
|
|
27
27
|
| `@stacksjs/calendar-api` | [`stacks-calendar`](../stacks-calendar/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/calendar-api/src/index.ts) | 5 |
|
|
@@ -76,7 +76,7 @@ Browser runtime bindings are documented separately in `stacks-auto-imports`.
|
|
|
76
76
|
| `@stacksjs/realtime` | [`stacks-realtime`](../stacks-realtime/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/realtime/src/index.ts) | 13 |
|
|
77
77
|
| `@stacksjs/registry` | [`stacks-registry`](../stacks-registry/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/registry/src/index.ts) | 1 |
|
|
78
78
|
| `@stacksjs/repl` | [`stacks-repl`](../stacks-repl/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/repl/src/index.ts) | 2 |
|
|
79
|
-
| `@stacksjs/router` | [`stacks-router`](../stacks-router/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/router/src/index.ts) |
|
|
79
|
+
| `@stacksjs/router` | [`stacks-router`](../stacks-router/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/router/src/index.ts) | 104 |
|
|
80
80
|
| `@stacksjs/scheduler` | [`stacks-scheduler`](../stacks-scheduler/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/scheduler/src/index.ts) | 19 |
|
|
81
81
|
| `@stacksjs/search-engine` | [`stacks-search-engine`](../stacks-search-engine/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/search-engine/src/index.ts) | 11 |
|
|
82
82
|
| `@stacksjs/security` | [`stacks-security`](../stacks-security/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/security/src/index.ts) | 12 |
|
|
@@ -220,7 +220,7 @@ Read the entrypoint and package export map for re-exported or type-only surfaces
|
|
|
220
220
|
|
|
221
221
|
Local source modules: [src/commands/index.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/buddy/src/commands/index.ts).
|
|
222
222
|
|
|
223
|
-
Evidence directory: [
|
|
223
|
+
Evidence directory: [192 retained tests](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/buddy/tests). These files are evidence pointers, not a claim that all tests were run for this catalog.
|
|
224
224
|
|
|
225
225
|
### @stacksjs/build
|
|
226
226
|
|
|
@@ -742,11 +742,11 @@ Evidence directory: [2 retained tests](https://github.com/stacksjs/stacks/blob/m
|
|
|
742
742
|
|
|
743
743
|
Guidance: [`stacks-router`](../stacks-router/SKILL.md). Source: [storage/framework/core/router/src/index.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/router/src/index.ts).
|
|
744
744
|
|
|
745
|
-
Declared runtime exports: `DASHBOARD_ROUTE_GROUPS`, `DEFAULT_ROUTE_BUNDLE_FEATURES`, `DEFAULT_ROUTE_REGISTRY`, `DatabaseSessionStore`, `EncryptedSessionStore`, `FileSessionStore`, `JSON_CONTENT_TYPE`, `MemorySessionStore`, `Middleware`, `PathParamError`, `RedisSessionStore`, `RequestBodyError`, `appRouteRegistry`, `assertRouteMiddlewareResolvable`, `bundleMounts`, `cacheRedisConnection`, `cacheRequestQuery`, `checkApplicationHealth`, `clearCsrfModuleCache`, `clearCurrentRequest`, `clearMiddlewareCache`, `clearRateLimit`, `clearRouteModelBindings`, `clearTrackedQueries`, `clientAddress`, `configureViewDirectories`, `createErrorResponse`, `createMiddlewareErrorResponse`, `createNotFoundResponse`, `createSessionStore`, `createStacksRouter`, `createStacksSessionStore`, `createTypedRouter`, `createValidationErrorResponse`, `dashboardGroupMiddleware`, `defineMiddleware`, `defineRouteModelBinding`, `describeUnknownDashboardGroups`, `disableViewRouting`, `enhanceRequest`, `fallbackStorage`, `findUnresolvableRouteMiddleware`, `getCurrentRequest`, `getQueryShapeCounts`, `getTraceId`, `installMiddlewareHotReload`, `isApiRequest`, `isRouterAction`, `listNamedRoutes`, `listRedirectRoutes`, `listRegisteredRoutes`, `listRootMountedAppRoutes`, `loadMiddlewareHandlers`, `loadRoutes`, `mountedDefaultRouteBundles`, `parseJsonText`, `provideActions`, `rateLimit`, `rateLimitScale`, `rateLimitStatus`, `readJsonBody`, `readTextBody`, `request`, `resetBootHooks`, `resetRateLimiters`, `resetSharedRateLimitStorage`, `resetShutdownHooks`, `resolveDashboardAccess`, `resolveRouteModel`, `route`, `routeModelBindings`, `routeParams`, `runBootHooks`, `runHealthProbes`, `runShutdownHooks`, `runWithRequest`, `safePathParam`, `sanitizePathParam`, `scaledLimit`, `serve`, `serverResponse`, `setCurrentRequest`, `setRouteModelFallback`, `sharedRateLimitStorage`, `signUrl`, `signedUrl`, `stream`, `trackQuery`, `trustedProxies`, `url`, `useRateLimitStorage`, `verifySignedUrl`, `verifySignedUrlMiddleware`, `warnOnMultipleRouterInstances`, `withRouteAdmission`, `withTraceId`, `wrapAction`.
|
|
745
|
+
Declared runtime exports: `DASHBOARD_ROUTE_GROUPS`, `DEFAULT_ROUTE_BUNDLE_FEATURES`, `DEFAULT_ROUTE_REGISTRY`, `DatabaseSessionStore`, `EncryptedSessionStore`, `FileSessionStore`, `JSON_CONTENT_TYPE`, `MemorySessionStore`, `Middleware`, `PathParamError`, `RedisSessionStore`, `RequestBodyError`, `appRouteRegistry`, `assertRouteMiddlewareResolvable`, `bundleMounts`, `cacheRedisConnection`, `cacheRequestQuery`, `checkApplicationHealth`, `clearCsrfModuleCache`, `clearCurrentRequest`, `clearMiddlewareCache`, `clearRateLimit`, `clearRouteModelBindings`, `clearTrackedQueries`, `clientAddress`, `configureViewDirectories`, `createErrorResponse`, `createMiddlewareErrorResponse`, `createNotFoundResponse`, `createSessionStore`, `createStacksRouter`, `createStacksSessionStore`, `createTypedRouter`, `createValidationErrorResponse`, `dashboardGroupMiddleware`, `defineMiddleware`, `defineRouteModelBinding`, `describeUnknownDashboardGroups`, `disableViewRouting`, `enhanceRequest`, `fallbackStorage`, `findUnresolvableRouteMiddleware`, `getCurrentRequest`, `getQueryShapeCounts`, `getTraceId`, `installMiddlewareHotReload`, `isApiRequest`, `isRouterAction`, `listNamedRoutes`, `listRedirectRoutes`, `listRegisteredRoutes`, `listRootMountedAppRoutes`, `loadMiddlewareHandlers`, `loadRoutes`, `mountedDefaultRouteBundles`, `parseJsonText`, `provideActions`, `rateLimit`, `rateLimitScale`, `rateLimitStatus`, `readJsonBody`, `readTextBody`, `request`, `resetBootHooks`, `resetRateLimiters`, `resetSharedRateLimitStorage`, `resetShutdownHooks`, `resolveActionHandler`, `resolveActionValidations`, `resolveDashboardAccess`, `resolveRouteModel`, `route`, `routeModelBindings`, `routeParams`, `runBootHooks`, `runHealthProbes`, `runShutdownHooks`, `runWithRequest`, `safePathParam`, `sanitizePathParam`, `scaledLimit`, `serve`, `serverResponse`, `setCurrentRequest`, `setRouteModelFallback`, `sharedRateLimitStorage`, `signUrl`, `signedUrl`, `stream`, `trackQuery`, `trustedProxies`, `url`, `useRateLimitStorage`, `verifySignedUrl`, `verifySignedUrlMiddleware`, `warnOnMultipleRouterInstances`, `withRouteAdmission`, `withTraceId`, `wrapAction`.
|
|
746
746
|
|
|
747
747
|
Local source modules: [src/api-shape.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/router/src/api-shape.ts), [src/body.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/router/src/body.ts), [src/dashboard-access.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/router/src/dashboard-access.ts), [src/encrypted-session-store.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/router/src/encrypted-session-store.ts), [src/error-handler.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/router/src/error-handler.ts), [src/health.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/router/src/health.ts), [src/json.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/router/src/json.ts), [src/middleware.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/router/src/middleware.ts), [src/path-sanitize.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/router/src/path-sanitize.ts), [src/rate-limit.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/router/src/rate-limit.ts), [src/request-augmentation.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/router/src/request-augmentation.ts), [src/request-context.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/router/src/request-context.ts), [src/route-loader.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/router/src/route-loader.ts), [src/route-model-binding.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/router/src/route-model-binding.ts), [src/security-settings.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/router/src/security-settings.ts), [src/session-factory.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/router/src/session-factory.ts), [src/signed-url.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/router/src/signed-url.ts), [src/stacks-router.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/router/src/stacks-router.ts), [src/typed-router.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/router/src/typed-router.ts).
|
|
748
748
|
|
|
749
|
-
Evidence directory: [
|
|
749
|
+
Evidence directory: [104 retained tests](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/router/tests). These files are evidence pointers, not a claim that all tests were run for this catalog.
|
|
750
750
|
|
|
751
751
|
### @stacksjs/scheduler
|
|
752
752
|
|
|
@@ -2,7 +2,7 @@ import type { ResponseStatus } from '@stacksjs/bun-router'
|
|
|
2
2
|
import { statfs } from 'node:fs/promises'
|
|
3
3
|
import { posix } from 'node:path'
|
|
4
4
|
import type { JobName } from '@stacksjs/queue'
|
|
5
|
-
import type { StorageAdapter, StorageManager, UploadedFileLike, Visibility } from '@stacksjs/storage'
|
|
5
|
+
import type { FilenameStrategy, StorageAdapter, StorageManager, UploadedFileLike, Visibility } from '@stacksjs/storage'
|
|
6
6
|
import { Storage } from '@stacksjs/storage'
|
|
7
7
|
import type { StorageItemMetadata, StorageItemTask, StorageMetadataStore, StorageTaskKind, StorageTaskState } from './file-metadata'
|
|
8
8
|
import {
|
|
@@ -1108,7 +1108,13 @@ export async function reprocessDashboardFile(
|
|
|
1108
1108
|
}
|
|
1109
1109
|
|
|
1110
1110
|
export async function uploadDashboardFiles(
|
|
1111
|
-
|
|
1111
|
+
/**
|
|
1112
|
+
* `filename` is how each stored name is chosen. The Files page keeps the
|
|
1113
|
+
* name a file arrived with, so a folder reads as it was uploaded, and
|
|
1114
|
+
* refuses a duplicate. An upload that only ever needs an address (a model
|
|
1115
|
+
* field's file) asks for a generated one, which cannot collide.
|
|
1116
|
+
*/
|
|
1117
|
+
input: { disk?: string, path?: string, files: UploadedFileLike[], filename?: FilenameStrategy },
|
|
1112
1118
|
manager: Manager = Storage,
|
|
1113
1119
|
store: StorageMetadataStore = databaseMetadataStore,
|
|
1114
1120
|
dispatch: TaskDispatcher = queueDispatcher,
|
|
@@ -1122,7 +1128,7 @@ export async function uploadDashboardFiles(
|
|
|
1122
1128
|
const result = await manager.put(file, {
|
|
1123
1129
|
disk: selected.name,
|
|
1124
1130
|
dir: directory,
|
|
1125
|
-
filename: 'original',
|
|
1131
|
+
filename: input.filename ?? 'original',
|
|
1126
1132
|
overwrite: false,
|
|
1127
1133
|
})
|
|
1128
1134
|
uploaded.push({ path: result.path, url: result.url, size: result.size, tasks: [] })
|
|
@@ -1,17 +1,20 @@
|
|
|
1
|
+
import type { RequestInstance } from '@stacksjs/types'
|
|
1
2
|
import { Action } from '@stacksjs/actions/runtime'
|
|
2
3
|
import { Subscriber } from '@stacksjs/orm'
|
|
3
4
|
import { safeGet } from '../../../../resources/functions/dashboard/data'
|
|
4
5
|
import { dashboardOperationalError } from '../dashboard-response'
|
|
5
|
-
import { dateValue, daysAgoIso, numberValue, textValue } from './data-records'
|
|
6
|
+
import { dateValue, daysAgoIso, numberValue, statsOnly, textValue } from './data-records'
|
|
6
7
|
|
|
7
8
|
export default new Action({
|
|
8
9
|
name: 'SubscriberIndexAction',
|
|
9
10
|
description: 'Returns subscribers and native subscription statistics for the dashboard.',
|
|
10
11
|
method: 'GET',
|
|
11
12
|
apiResponse: true,
|
|
12
|
-
async handle() {
|
|
13
|
+
async handle(request: RequestInstance) {
|
|
13
14
|
try {
|
|
14
|
-
|
|
15
|
+
// The page that shows these numbers lists its rows through the model
|
|
16
|
+
// browser, and asks here for the numbers alone.
|
|
17
|
+
const rows = statsOnly(request) ? [] : await Subscriber.orderByDesc('created_at').limit(100).get()
|
|
15
18
|
const subscribers = rows.map(row => ({
|
|
16
19
|
id: numberValue(safeGet(row, 'id', 0)),
|
|
17
20
|
email: textValue(safeGet(row, 'email')),
|
|
@@ -1,17 +1,20 @@
|
|
|
1
|
+
import type { RequestInstance } from '@stacksjs/types'
|
|
1
2
|
import { Action } from '@stacksjs/actions/runtime'
|
|
2
3
|
import { Team } from '@stacksjs/orm'
|
|
3
4
|
import { safeGet } from '../../../../resources/functions/dashboard/data'
|
|
4
5
|
import { dashboardOperationalError } from '../dashboard-response'
|
|
5
|
-
import { dateValue, daysAgoIso, numberValue, textValue } from './data-records'
|
|
6
|
+
import { dateValue, daysAgoIso, numberValue, statsOnly, textValue } from './data-records'
|
|
6
7
|
|
|
7
8
|
export default new Action({
|
|
8
9
|
name: 'TeamIndexAction',
|
|
9
10
|
description: 'Returns teams and native team statistics for the dashboard.',
|
|
10
11
|
method: 'GET',
|
|
11
12
|
apiResponse: true,
|
|
12
|
-
async handle() {
|
|
13
|
+
async handle(request: RequestInstance) {
|
|
13
14
|
try {
|
|
14
|
-
|
|
15
|
+
// The page that shows these numbers lists its rows through the model
|
|
16
|
+
// browser, and asks here for the numbers alone.
|
|
17
|
+
const rows = statsOnly(request) ? [] : await Team.orderByDesc('created_at').limit(100).get()
|
|
15
18
|
const teams = rows.map(row => ({
|
|
16
19
|
id: numberValue(safeGet(row, 'id', 0)),
|
|
17
20
|
name: textValue(safeGet(row, 'name'), 'Unnamed team'),
|
|
@@ -1,17 +1,20 @@
|
|
|
1
|
+
import type { RequestInstance } from '@stacksjs/types'
|
|
1
2
|
import { Action } from '@stacksjs/actions/runtime'
|
|
2
3
|
import { anonymizedRows, GDPR_SUBJECT_MODEL, User } from '@stacksjs/orm'
|
|
3
4
|
import { safeGet } from '../../../../resources/functions/dashboard/data'
|
|
4
5
|
import { dashboardOperationalError } from '../dashboard-response'
|
|
5
|
-
import { dateValue, daysAgoIso, numberValue, textValue } from './data-records'
|
|
6
|
+
import { dateValue, daysAgoIso, numberValue, statsOnly, textValue } from './data-records'
|
|
6
7
|
|
|
7
8
|
export default new Action({
|
|
8
9
|
name: 'UserIndexAction',
|
|
9
10
|
description: 'Returns a safe projection of users and native registration statistics.',
|
|
10
11
|
method: 'GET',
|
|
11
12
|
apiResponse: true,
|
|
12
|
-
async handle() {
|
|
13
|
+
async handle(request: RequestInstance) {
|
|
13
14
|
try {
|
|
14
|
-
|
|
15
|
+
// The page that shows these numbers lists its rows through the model
|
|
16
|
+
// browser, and asks here for the numbers alone.
|
|
17
|
+
const rows = statsOnly(request) ? [] : await User.orderByDesc('created_at').limit(100).get()
|
|
15
18
|
// An account erased under the app's data-subject rules stays in the
|
|
16
19
|
// table with its personal details replaced. Listed as it is stored it
|
|
17
20
|
// reads "[erased] / erased-13", which looks like corrupt data, so each
|