@stacksjs/defaults 0.75.557 → 0.75.559

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.
Files changed (40) hide show
  1. package/ai/skills/stacks-dashboard/SKILL.md +61 -9
  2. package/ai/skills/stacks-desktop/SKILL.md +15 -4
  3. package/ai/skills/stacks-migrations/SKILL.md +10 -0
  4. package/ai/skills/stacks-native/CATALOG.md +3 -3
  5. package/app/Actions/Dashboard/Models/GetModels.ts +4 -3
  6. package/app/Actions/Dashboard/Models/ModelsIndexAction.ts +6 -4
  7. package/app/Actions/Dashboard/Search/GlobalSearchAction.ts +3 -4
  8. package/app/Actions/Dashboard/Search/SearchEngineIndexAction.ts +4 -4
  9. package/app/Models/Board.ts +4 -0
  10. package/app/Models/Campaign.ts +24 -0
  11. package/app/Models/Card.ts +4 -0
  12. package/app/Models/CardComment.ts +7 -1
  13. package/app/Models/Comment.ts +8 -0
  14. package/app/Models/Content/Author.ts +6 -0
  15. package/app/Models/Content/Page.ts +7 -0
  16. package/app/Models/Content/Post.ts +12 -0
  17. package/app/Models/EmailList.ts +4 -0
  18. package/app/Models/FailedJob.ts +11 -0
  19. package/app/Models/MailPreference.ts +4 -0
  20. package/app/Models/NotificationDelivery.ts +12 -0
  21. package/app/Models/SocialPost.ts +6 -0
  22. package/app/Models/Tag.ts +7 -0
  23. package/app/Models/Team.ts +1 -0
  24. package/app/Models/User.ts +2 -1
  25. package/app/Models/commerce/AuctionItem.ts +4 -0
  26. package/app/Models/commerce/Cart.ts +4 -0
  27. package/app/Models/commerce/Category.ts +4 -0
  28. package/app/Models/commerce/Customer.ts +4 -0
  29. package/app/Models/commerce/DeliveryStop.ts +4 -0
  30. package/app/Models/commerce/LoyaltyReward.ts +6 -0
  31. package/app/Models/commerce/Manufacturer.ts +4 -0
  32. package/app/Models/commerce/Product.ts +4 -0
  33. package/app/Models/commerce/ProductUnit.ts +4 -0
  34. package/app/Models/commerce/Review.ts +4 -0
  35. package/app/Models/commerce/ShippingMethod.ts +4 -0
  36. package/app/Models/commerce/WaitlistProduct.ts +4 -0
  37. package/app/Notifications/Welcome.ts +1 -1
  38. package/ide/vscode/package.json +1 -1
  39. package/package.json +3 -3
  40. package/resources/functions/dashboard/model-access.ts +22 -4
@@ -692,6 +692,29 @@ or separate routes generated by `useApi`. Configure `security.api.models` or
692
692
  new boundary does not provide row ownership or permission checks for models
693
693
  that remain exposed.
694
694
 
695
+ ### Asking which models exist
696
+
697
+ Dashboard code asks through `resolveDashboardModel(name, candidate?, sources?)`
698
+ and `dashboardModelSources()` in `resources/functions/dashboard/model-access.ts`,
699
+ which read directory listings only (`listModelSources` from
700
+ `@stacksjs/database/model-sources`). Anything that resolves many models reads
701
+ the list once and hands it to each resolve:
702
+
703
+ ```ts
704
+ const sources = dashboardModelSources()
705
+ for (const source of sources) {
706
+ const Model = await resolveDashboardModel(source.name, (await import(source.file)).default, sources)
707
+ }
708
+ ```
709
+
710
+ Never call `resolveModelSources()` while serving a request. It is the
711
+ migration generator's entry point: when framework defaults are merged in it
712
+ deletes and rebuilds its staging directory (a symlink per model) on every
713
+ call, about 11ms of blocking file writes. The models overview once asked it
714
+ per model and took 1.6s; it answers in about 6ms now.
715
+ `tests/unit/dashboard-model-sources.test.ts` fails if a dashboard Action or
716
+ function uses it.
717
+
695
718
  ## What the dashboard may write to a model
696
719
 
697
720
  Every record has a page to view it (`/models/{slug}/{id}`), and where the
@@ -864,10 +887,31 @@ Formatting happens in the browser (`functions/dashboard-model-format.ts`),
864
887
  since it follows the viewer's locale and time zone; the list endpoint sends
865
888
  each column's `label` and `format` in `columnMeta`.
866
889
 
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.
890
+ The shipped models say so wherever the answer is certain
891
+ (`tests/unit/dashboard-shipped-declarations.test.ts` holds each kind to its
892
+ rule):
893
+
894
+ - **Units and addresses**: request and query durations, a deployment's
895
+ duration (seconds) and address, an attachment's size.
896
+ - **A picture chosen as a file** (`input: 'upload', accept: 'image/*'`): a
897
+ user's, an author's and a customer's `avatar`, a post's `poster`.
898
+ - **A picture shown as one** (`format: 'image'`): the `imageUrl` of a
899
+ product, category, auction lot, loyalty reward and social post. These stay
900
+ an address that is typed or pasted. A chooser would take away pointing at
901
+ a picture kept elsewhere, so a field named for an address is not made an
902
+ upload.
903
+ - **A web address box** (`input: 'url'`): a post's `canonicalUrl` and a social
904
+ post's `imageUrl`, the two whose own rule already refuses anything else.
905
+ The box refuses a path such as `/about` before the form is sent, so it is
906
+ never put on a field that may hold one (a menu item's `url`).
907
+ - **Prose** (`input: 'longtext'`): descriptions, notes, bios, excerpts, meta
908
+ descriptions, comment and card bodies, a post's `content`: 23 fields that
909
+ were one line because their attribute is a plain string.
910
+
911
+ Nothing shipped is asked for as Markdown yet. A post's `content` is written
912
+ in Markdown, but the page the CMS builds from it renders only part of it (no
913
+ italics, quotes or numbered lists), and the editor's preview would show what
914
+ the published page does not.
871
915
 
872
916
  Not offered yet: wording for single enum values.
873
917
 
@@ -1033,12 +1077,20 @@ names Actions/Orders/ShipOrderAction, which could not be loaded...`). A
1033
1077
  handler string is not checked by the compiler, so this is checked when the
1034
1078
  list is drawn, not when someone presses the button.
1035
1079
 
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.
1080
+ Five ship, each an action the framework already had, and each asks first.
1081
+ Remove an entry to turn it off.
1082
+
1083
+ | Model | Button | Offered to | Where |
1084
+ |---|---|---|---|
1085
+ | `User` | Send password reset | every account | its page |
1086
+ | `FailedJob` | Retry | every failed job | row, page, selection |
1087
+ | `NotificationDelivery` | Send again | a failed email or text message | row, page |
1088
+ | `Campaign` | Send now | an email campaign that is a draft, scheduled, paused or failed | its page |
1089
+ | `Campaign` | Cancel delivery | an email campaign that is scheduled or sending | its page |
1039
1090
 
1040
- Not offered on the hand-built Users, Teams and Subscribers lists, whose rows
1041
- lead to the record page where the buttons are.
1091
+ A campaign's two are on its own page only: sending reaches every subscriber
1092
+ on a list, so it is not an icon in a table row. What an action refuses is
1093
+ what the operator is told ("Email campaigns require an email list.").
1042
1094
 
1043
1095
  ### An action that takes input is asked for it
1044
1096
 
@@ -452,9 +452,17 @@ Bun cross-compiles the agent for any target from any machine (`--target=bun-wind
452
452
  Windows and Linux executables. It does not produce their installers. `craft-package.json` is the input to Craft's
453
453
  `packageApp`, with paths relative to its own folder; `--package` runs it when the machine matches the target.
454
454
 
455
- Each target needs that platform's Craft web view binary: this machine's comes from `CRAFT_BIN` or `craft` on PATH,
456
- every other from `webview.runtime['<target>']` or `CRAFT_BIN_<PLATFORM>_<ARCH>` (Craft publishes
457
- `craft-<os>-<arch>.zip` with each release). On Linux the runtime is compiled into the agent and unpacked to the data
455
+ Each target needs that platform's Craft web view binary. In order: `webview.runtime['<target>']` or
456
+ `CRAFT_BIN_<PLATFORM>_<ARCH>` when one is set; this machine's own Craft (`CRAFT_BIN` or `craft` on PATH) for this
457
+ machine's target; else the build fetches it. Craft publishes `craft-<os>-<arch>.zip` with each release, and
458
+ `build:desktop --target ...` downloads the one for the installed `craft-native` version, checks its size and SHA-256
459
+ against that release's `release-manifest.json`, and keeps it unpacked in `storage/framework/desktop/runtimes/<target>/`
460
+ (gitignored; a later build reuses it and a new Craft version replaces it). An app needs no script of its own for
461
+ this. Craft publishes runtimes for `darwin-arm64`, `darwin-x64`, `linux-x64` and `win32-x64`; the arm64 Linux and
462
+ Windows targets still need a runtime named in the config. `DESKTOP_RUNTIME_FETCH=0` keeps a build off the network.
463
+
464
+ On Windows, `WebView2Loader.dll` is copied into the app from beside the runtime (Craft's archive ships it there)
465
+ unless `windows.additionalFiles` already names one. On Linux the runtime is compiled into the agent and unpacked to the data
458
466
  directory on first launch, because Craft's Linux packagers take one binary.
459
467
 
460
468
  ### Updates
@@ -485,7 +493,10 @@ serves. Then per target:
485
493
 
486
494
  Artifacts and manifests go through `@stacksjs/storage` to `updates.disk` under `updates.prefix`
487
495
  (`desktop-updates/<channel>/<platform>-<arch>/latest.json`, artifacts under `<version>/`), plus a `release.json`
488
- a download page can read.
496
+ a download page can read. A release is often made in several runs, the Mac from a Mac and then
497
+ `release:desktop --target linux-x64 --skip-build` for installers built elsewhere: a run for the same version and
498
+ channel adds its targets to `release.json` and replaces only the ones it published again. A new version starts a
499
+ new record.
489
500
 
490
501
  The server side is one default action, `Actions/Desktop/UpdateFeedAction`, mounted at
491
502
  `/api/updates/{platform}/{arch}` whenever `webview.updates` is configured. It serves the stored manifest as is
@@ -209,6 +209,16 @@ are excluded. Removing a feature from generation is not permission to drop its
209
209
  live data. MySQL/PostgreSQL/Vitess/Turso require their own SQL and evidence
210
210
  checks; never run SQLite SQL on a different provider because its filename exists.
211
211
 
212
+ Two functions answer "which models are in this app's schema", by the same
213
+ rules. `resolveModelSources()` is the generator's: it also stages the models
214
+ into one flat directory, deleting and rebuilding it on every call when the
215
+ framework defaults are merged in. Only generating migrations may call it.
216
+ Anything that just needs the list (a dashboard request, search indexing,
217
+ `generate:erd`, `generate:vschema`, starting the dev dashboard) calls
218
+ `listModelSources()`, which reads directory listings and writes nothing.
219
+ `tests/unit/dashboard-model-sources.test.ts` fails if another package calls
220
+ the generator's.
221
+
212
222
  Source: `core/database/src/{migrations,model-sources,migration-ledger,
213
223
  safe-migrations,schema-drift,fk-audit,unique-audit}.ts`, `config/query-builder.ts`,
214
224
  and their retained database tests.
@@ -39,7 +39,7 @@ Browser runtime bindings are documented separately in `stacks-auto-imports`.
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 |
42
- | `@stacksjs/desktop-build` | [`stacks-desktop`](../stacks-desktop/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/index.ts) | 20 |
42
+ | `@stacksjs/desktop-build` | [`stacks-desktop`](../stacks-desktop/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/index.ts) | 21 |
43
43
  | `@stacksjs/development` | [`stacks-development`](../stacks-development/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/development/package.json) | 1 |
44
44
  | `@stacksjs/dns` | [`stacks-dns`](../stacks-dns/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/dns/src/index.ts) | 4 |
45
45
  | `@stacksjs/docs` | [`stacks-docs`](../stacks-docs/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/docs/src/index.ts) | 3 |
@@ -392,9 +392,9 @@ Guidance: [`stacks-desktop`](../stacks-desktop/SKILL.md). Source: [storage/frame
392
392
 
393
393
  Declared runtime exports: `BUN_EXECUTABLE_MARKER`, `RESERVED_PLIST_KEYS`, `USERLAND_LAUNCHER`, `bundleDirectoryFor`, `codesignArgs`, `craftDevCommand`, `createUpdateManifestUrl`, `describeRuntimeDuplication`, `desktopAppVersion`, `desktopLauncherCompileArgs`, `developerIdProblem`, `dmgVolumeName`, `hasUserlandDesktopLauncher`, `isMachO`, `looksLikeBunExecutable`, `notarizationOutcome`, `notarytoolAuthArgs`, `openDevWindow`, `plistValue`, `renderInfoPlist`, `renderUserlandPlistEntries`, `resolveCraftBinary`, `resolveCraftExecutable`, `resolveDesktopLauncher`, `resolveDevWindowUrl`, `resolveDmgPackaging`, `xmlEscape`.
394
394
 
395
- Local source modules: [src/agent-launcher.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/agent-launcher.ts), [src/agent.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/agent.ts), [src/invites.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/invites.ts), [src/macos-app.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/macos-app.ts), [src/macos-bundle.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/macos-bundle.ts), [src/support.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/support.ts), [src/update-feed.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/update-feed.ts), [src/update-install.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/update-install.ts), [src/update-signing.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/update-signing.ts), [src/updater.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/updater.ts), [src/webview-agent.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/webview-agent.ts), [src/webview-app.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/webview-app.ts), [src/webview-launcher.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/webview-launcher.ts).
395
+ Local source modules: [src/agent-launcher.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/agent-launcher.ts), [src/agent.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/agent.ts), [src/craft-runtime.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/craft-runtime.ts), [src/invites.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/invites.ts), [src/macos-app.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/macos-app.ts), [src/macos-bundle.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/macos-bundle.ts), [src/support.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/support.ts), [src/update-feed.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/update-feed.ts), [src/update-install.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/update-install.ts), [src/update-signing.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/update-signing.ts), [src/updater.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/updater.ts), [src/webview-agent.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/webview-agent.ts), [src/webview-app.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/webview-app.ts), [src/webview-launcher.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/src/webview-launcher.ts).
396
396
 
397
- Evidence directory: [20 retained tests](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/tests). These files are evidence pointers, not a claim that all tests were run for this catalog.
397
+ Evidence directory: [21 retained tests](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/desktop/tests). These files are evidence pointers, not a claim that all tests were run for this catalog.
398
398
 
399
399
  ### @stacksjs/development
400
400
 
@@ -3,7 +3,7 @@ import { Glob } from 'bun'
3
3
  import { Action } from '@stacksjs/actions/runtime'
4
4
  import { path } from '@stacksjs/path'
5
5
  import { countRows } from '../../../../resources/functions/dashboard/data'
6
- import { resolveDashboardModel } from '../../../../resources/functions/dashboard/model-access'
6
+ import { dashboardModelSources, resolveDashboardModel } from '../../../../resources/functions/dashboard/model-access'
7
7
  import { dashboardOperationalError } from '../dashboard-response'
8
8
 
9
9
  export default new Action({
@@ -16,10 +16,11 @@ export default new Action({
16
16
  const glob = new Glob('**/*.ts')
17
17
  const scanOptions = { cwd: path.userModelsPath(), onlyFiles: true }
18
18
  const displayModels: Model[] = []
19
+ const sources = dashboardModelSources()
19
20
 
20
21
  for await (const file of glob.scan(scanOptions)) {
21
22
  const candidate = (await import(path.userModelsPath(file))).default as Model
22
- const model = await resolveDashboardModel(candidate.name || '', candidate)
23
+ const model = await resolveDashboardModel(candidate.name || '', candidate, sources)
23
24
  if (!model) continue
24
25
  if (model.dashboard?.highlight !== undefined && model.dashboard?.highlight !== false)
25
26
  displayModels.push(model)
@@ -29,7 +30,7 @@ export default new Action({
29
30
  // If no models should be highlighted, return up to 8 accessible models.
30
31
  for await (const file of glob.scan(scanOptions)) {
31
32
  const candidate = (await import(path.userModelsPath(file))).default as Model
32
- const model = await resolveDashboardModel(candidate.name || '', candidate)
33
+ const model = await resolveDashboardModel(candidate.name || '', candidate, sources)
33
34
  if (!model) continue
34
35
  displayModels.push(model)
35
36
  }
@@ -1,9 +1,8 @@
1
1
  import { Action } from '@stacksjs/actions/runtime'
2
2
  import { overridesReady } from '@stacksjs/config'
3
- import { resolveModelSources } from '@stacksjs/database/model-sources'
4
3
  import { countRows } from '../../../../resources/functions/dashboard/data'
5
4
  import { dashboardOperationalError, dashboardOperationalIssue } from '../dashboard-response'
6
- import { resolveDashboardModel } from '../../../../resources/functions/dashboard/model-access'
5
+ import { dashboardModelSources, resolveDashboardModel } from '../../../../resources/functions/dashboard/model-access'
7
6
  import { resolveDashboardIcon } from '../../../../resources/functions/dashboard/sidebar'
8
7
  import { isUnmigratedTable } from './model-migration'
9
8
  import { modelApiConfiguration } from './model-api'
@@ -110,8 +109,11 @@ export default new Action({
110
109
  async handle() {
111
110
  await overridesReady
112
111
  let merged: DiscoveredModel[]
112
+ // Listed once, and handed to every resolve below.
113
+ let sources: ReturnType<typeof dashboardModelSources>
113
114
  try {
114
- merged = (resolveModelSources()?.models ?? []).map(model => ({
115
+ sources = dashboardModelSources()
116
+ merged = sources.map(model => ({
115
117
  name: model.name,
116
118
  file: model.file,
117
119
  source: model.origin === 'framework' ? 'framework' : 'userland',
@@ -125,7 +127,7 @@ export default new Action({
125
127
  let Model: any
126
128
  try {
127
129
  const module = await import(m.file)
128
- Model = await resolveDashboardModel(m.name, module.default ?? module)
130
+ Model = await resolveDashboardModel(m.name, module.default ?? module, sources)
129
131
  if (!Model) return null
130
132
  }
131
133
  catch (error) {
@@ -2,9 +2,8 @@ import type { RequestInstance } from '@stacksjs/types'
2
2
  import { Action } from '@stacksjs/actions/runtime'
3
3
  import { getDatabaseDialect, sqlHelpers } from '@stacksjs/database/runtime'
4
4
  import { overridesReady } from '@stacksjs/config'
5
- import { resolveModelSources } from '@stacksjs/database/model-sources'
6
5
  import { hiddenModelColumns } from '../../../../resources/functions/dashboard/model-columns'
7
- import { resolveDashboardModel } from '../../../../resources/functions/dashboard/model-access'
6
+ import { dashboardModelSources, resolveDashboardModel } from '../../../../resources/functions/dashboard/model-access'
8
7
  import { dashboardOperationalError, dashboardOperationalIssue } from '../dashboard-response'
9
8
 
10
9
  interface SearchableModel {
@@ -87,13 +86,13 @@ function iconForModel(name: string): string {
87
86
 
88
87
  async function loadSearchableModels(): Promise<SearchableModel[]> {
89
88
  await overridesReady
90
- const sources = resolveModelSources()?.models ?? []
89
+ const sources = dashboardModelSources()
91
90
 
92
91
  const models: SearchableModel[] = []
93
92
  for (const { name: fallbackName, file } of sources) {
94
93
  try {
95
94
  const module = await import(file)
96
- const definition = await resolveDashboardModel(fallbackName, module.default ?? module)
95
+ const definition = await resolveDashboardModel(fallbackName, module.default ?? module, sources)
97
96
  if (!definition) continue
98
97
  const name = String(definition.name || fallbackName)
99
98
  const search = definition.traits?.useSearch
@@ -1,8 +1,7 @@
1
1
  import { Action } from '@stacksjs/actions/runtime'
2
2
  import { overridesReady, searchEngine } from '@stacksjs/config'
3
- import { resolveModelSources } from '@stacksjs/database/model-sources'
4
3
  import { searchIndexName, settingsFromSearchTrait, useSearchEngine } from '@stacksjs/search-engine'
5
- import { resolveDashboardModel } from '../../../../resources/functions/dashboard/model-access'
4
+ import { dashboardModelSources, resolveDashboardModel } from '../../../../resources/functions/dashboard/model-access'
6
5
  import { dashboardOperationalError, dashboardOperationalIssue } from '../dashboard-response'
7
6
 
8
7
  export default new Action({
@@ -13,9 +12,10 @@ export default new Action({
13
12
  try {
14
13
  await overridesReady
15
14
  const models = []
16
- for (const source of resolveModelSources()?.models ?? []) {
15
+ const sources = dashboardModelSources()
16
+ for (const source of sources) {
17
17
  const module = await import(source.file)
18
- const Model = await resolveDashboardModel(source.name, module.default ?? module)
18
+ const Model = await resolveDashboardModel(source.name, module.default ?? module, sources)
19
19
  const trait = Model?.traits?.useSearch
20
20
  if (!trait) continue
21
21
  const settings = settingsFromSearchTrait(typeof trait === 'object' ? trait : {})
@@ -116,5 +116,9 @@ export default defineModel({
116
116
  dashboard: {
117
117
  columns: ['name', 'team', 'archived', 'createdAt'],
118
118
  enabled: false,
119
+ // Prose, asked for in a box with room for it.
120
+ fields: {
121
+ description: { input: 'longtext' },
122
+ },
119
123
  },
120
124
  } as const)
@@ -326,5 +326,29 @@ export default defineModel({
326
326
 
327
327
  dashboard: {
328
328
  columns: ['name', 'type', 'status', 'emailList', 'scheduledAt', 'sentCount'],
329
+ // Delivery is for email campaigns, in the states the newsletter engine
330
+ // takes each from. Sending is on the campaign's own page only: it reaches
331
+ // every subscriber on the list, so it is not an icon in a table row.
332
+ actions: [
333
+ {
334
+ name: 'send',
335
+ label: 'Send now',
336
+ action: 'Actions/Dashboard/Marketing/CampaignSendAction',
337
+ icon: 'i-hugeicons-sent',
338
+ confirm: 'It is queued for delivery to every active subscriber on its list.',
339
+ on: ['record'],
340
+ when: { type: 'email', status: ['draft', 'scheduled', 'paused', 'failed'] },
341
+ },
342
+ {
343
+ name: 'cancel',
344
+ label: 'Cancel delivery',
345
+ action: 'Actions/Dashboard/Marketing/CampaignCancelAction',
346
+ icon: 'i-hugeicons-cancel-circle',
347
+ confirm: 'Messages that have not gone out yet are not sent. Ones already sent cannot be recalled.',
348
+ destructive: true,
349
+ on: ['record'],
350
+ when: { type: 'email', status: ['scheduled', 'sending'] },
351
+ },
352
+ ],
329
353
  },
330
354
  } as const)
@@ -117,5 +117,9 @@ export default defineModel({
117
117
  dashboard: {
118
118
  columns: ['title', 'board', 'boardColumn', 'user', 'dueDate', 'archived'],
119
119
  enabled: false,
120
+ // Prose, asked for in a box with room for it.
121
+ fields: {
122
+ description: { input: 'longtext' },
123
+ },
120
124
  },
121
125
  } as const)
@@ -63,5 +63,11 @@ export default defineModel({
63
63
  },
64
64
  },
65
65
 
66
- dashboard: { enabled: false },
66
+ dashboard: {
67
+ enabled: false,
68
+ // Prose, asked for in a box with room for it.
69
+ fields: {
70
+ body: { input: 'longtext' },
71
+ },
72
+ },
67
73
  } as const)
@@ -111,4 +111,12 @@ export default defineModel({
111
111
  factory: faker => faker.number.int({ min: 0, max: 1 }),
112
112
  },
113
113
  },
114
+
115
+ dashboard: {
116
+ // Prose, asked for in a box with room for it.
117
+ fields: {
118
+ content: { input: 'longtext' },
119
+ body: { input: 'longtext' },
120
+ },
121
+ },
114
122
  } as const)
@@ -113,5 +113,11 @@ export default defineModel({
113
113
  },
114
114
  dashboard: {
115
115
  highlight: true,
116
+ // Chosen as a file. Its address is what is stored, as before.
117
+ // Prose, asked for in a box with room for it.
118
+ fields: {
119
+ avatar: { input: 'upload', accept: 'image/*' },
120
+ bio: { input: 'longtext' },
121
+ },
116
122
  },
117
123
  } as const)
@@ -206,4 +206,11 @@ export default defineModel({
206
206
  factory: faker => faker.number.int({ min: 0, max: 100 }),
207
207
  },
208
208
  },
209
+
210
+ dashboard: {
211
+ // Prose, asked for in a box with room for it.
212
+ fields: {
213
+ metaDescription: { input: 'longtext' },
214
+ },
215
+ },
209
216
  } as const)
@@ -235,4 +235,16 @@ export default defineModel({
235
235
  factory: faker => faker.number.int({ min: 0, max: 1 }),
236
236
  },
237
237
  },
238
+
239
+ dashboard: {
240
+ // Chosen as a file. Its address is what is stored, as before.
241
+ // Prose, asked for in a box with room for it.
242
+ fields: {
243
+ poster: { input: 'upload', accept: 'image/*' },
244
+ content: { input: 'longtext' },
245
+ excerpt: { input: 'longtext' },
246
+ metaDescription: { input: 'longtext' },
247
+ canonicalUrl: { input: 'url', format: 'link' },
248
+ },
249
+ },
238
250
  } as const)
@@ -140,5 +140,9 @@ export default defineModel({
140
140
 
141
141
  dashboard: {
142
142
  columns: ['name', 'status', 'subscriberCount', 'activeCount', 'isPublic', 'createdAt'],
143
+ // Prose, asked for in a box with room for it.
144
+ fields: {
145
+ description: { input: 'longtext' },
146
+ },
143
147
  },
144
148
  } as const)
@@ -89,5 +89,16 @@ export default defineModel({
89
89
 
90
90
  dashboard: {
91
91
  columns: ['queue', 'connection', 'exception', 'attempts', 'failedAt'],
92
+ // A failed job can be run again from its row or its page, one or many.
93
+ actions: [
94
+ {
95
+ name: 'retry',
96
+ label: 'Retry',
97
+ action: 'Actions/Dashboard/Jobs/JobRetryAction',
98
+ icon: 'i-hugeicons-refresh',
99
+ confirm: 'It is put back on its queue to run again.',
100
+ on: ['record', 'row', 'bulk'],
101
+ },
102
+ ],
92
103
  },
93
104
  } as const)
@@ -218,5 +218,9 @@ export default defineModel({
218
218
 
219
219
  dashboard: {
220
220
  columns: ['mailbox', 'accountName', 'theme', 'language', 'displayDensity'],
221
+ // Prose, asked for in a box with room for it.
222
+ fields: {
223
+ vacationMessage: { input: 'longtext' },
224
+ },
221
225
  },
222
226
  } as const)
@@ -110,5 +110,17 @@ export default defineModel({
110
110
 
111
111
  dashboard: {
112
112
  columns: ['recipient', 'channel', 'subject', 'status', 'sentAt'],
113
+ // Only a failed email or text message can be sent again: the action
114
+ // refuses the rest, so they are not offered it.
115
+ actions: [
116
+ {
117
+ name: 'retry',
118
+ label: 'Send again',
119
+ action: 'Actions/Dashboard/Notifications/NotificationDeliveryRetryAction',
120
+ icon: 'i-hugeicons-mail-send-01',
121
+ confirm: 'The same message is sent to the same recipient again.',
122
+ when: { status: 'failed', channel: ['email', 'sms'] },
123
+ },
124
+ ],
113
125
  },
114
126
  } as const)
@@ -146,5 +146,11 @@ export default defineModel({
146
146
 
147
147
  dashboard: {
148
148
  columns: ['content', 'platform', 'status', 'scheduledAt', 'publishedAt', 'likes'],
149
+ // Prose, asked for in a box with room for it.
150
+ // An address that leads to a picture: shown as one.
151
+ fields: {
152
+ content: { input: 'longtext' },
153
+ imageUrl: { input: 'url', format: 'image' },
154
+ },
149
155
  },
150
156
  } as const)
package/app/Models/Tag.ts CHANGED
@@ -108,4 +108,11 @@ export default defineModel({
108
108
  factory: faker => faker.helpers.arrayElement(['blue', 'green', 'red', 'purple', 'yellow', 'orange', 'pink', 'gray']),
109
109
  },
110
110
  },
111
+
112
+ dashboard: {
113
+ // Prose, asked for in a box with room for it.
114
+ fields: {
115
+ description: { input: 'longtext' },
116
+ },
117
+ },
111
118
  } as const)
@@ -79,6 +79,7 @@ export default defineModel({
79
79
  // A count of members is called what it counts.
80
80
  fields: {
81
81
  memberCount: { label: 'Members' },
82
+ description: { input: 'longtext' },
82
83
  },
83
84
  highlight: true,
84
85
  },
@@ -165,7 +165,8 @@ export default defineModel({
165
165
  columns: ['name', 'email', 'emailVerifiedAt', 'createdAt'],
166
166
  // An avatar is a picture, not the address of one.
167
167
  fields: {
168
- avatar: { format: 'image' },
168
+ // Chosen as a file, and shown as the picture it is.
169
+ avatar: { format: 'image', input: 'upload', accept: 'image/*' },
169
170
  },
170
171
  // Operators add, edit and remove accounts from the dashboard. Not through
171
172
  // `useApi` above: a generated PATCH would let any signed-in caller change
@@ -207,5 +207,9 @@ export default defineModel({
207
207
  dashboard: {
208
208
  icon: 'i-hugeicons-package',
209
209
  label: 'Lots',
210
+ // An address that leads to a picture: shown as one.
211
+ fields: {
212
+ imageUrl: { format: 'image' },
213
+ },
210
214
  },
211
215
  } as const)
@@ -225,5 +225,9 @@ export default defineModel({
225
225
 
226
226
  dashboard: {
227
227
  highlight: true,
228
+ // Prose, asked for in a box with room for it.
229
+ fields: {
230
+ notes: { input: 'longtext' },
231
+ },
228
232
  },
229
233
  } as const)
@@ -122,5 +122,9 @@ export default defineModel({
122
122
 
123
123
  dashboard: {
124
124
  highlight: true,
125
+ // An address that leads to a picture: shown as one.
126
+ fields: {
127
+ imageUrl: { format: 'image' },
128
+ },
125
129
  },
126
130
  } as const)
@@ -134,5 +134,9 @@ export default defineModel({
134
134
 
135
135
  dashboard: {
136
136
  highlight: true,
137
+ // Chosen as a file. Its address is what is stored, as before.
138
+ fields: {
139
+ avatar: { input: 'upload', accept: 'image/*' },
140
+ },
137
141
  },
138
142
  } as const)
@@ -197,5 +197,9 @@ export default defineModel({
197
197
 
198
198
  dashboard: {
199
199
  highlight: true,
200
+ // Prose, asked for in a box with room for it.
201
+ fields: {
202
+ notes: { input: 'longtext' },
203
+ },
200
204
  },
201
205
  } as const)
@@ -133,5 +133,11 @@ export default defineModel({
133
133
 
134
134
  dashboard: {
135
135
  highlight: true,
136
+ // Prose, asked for in a box with room for it.
137
+ // An address that leads to a picture: shown as one.
138
+ fields: {
139
+ imageUrl: { format: 'image' },
140
+ description: { input: 'longtext' },
141
+ },
136
142
  },
137
143
  } as const)
@@ -92,5 +92,9 @@ export default defineModel({
92
92
 
93
93
  dashboard: {
94
94
  highlight: true,
95
+ // Prose, asked for in a box with room for it.
96
+ fields: {
97
+ description: { input: 'longtext' },
98
+ },
95
99
  },
96
100
  } as const)
@@ -170,5 +170,9 @@ export default defineModel({
170
170
 
171
171
  dashboard: {
172
172
  highlight: true,
173
+ // An address that leads to a picture: shown as one.
174
+ fields: {
175
+ imageUrl: { format: 'image' },
176
+ },
173
177
  },
174
178
  } as const)
@@ -115,5 +115,9 @@ export default defineModel({
115
115
 
116
116
  dashboard: {
117
117
  highlight: true,
118
+ // Prose, asked for in a box with room for it.
119
+ fields: {
120
+ description: { input: 'longtext' },
121
+ },
118
122
  },
119
123
  } as const)
@@ -174,5 +174,9 @@ export default defineModel({
174
174
 
175
175
  dashboard: {
176
176
  highlight: true,
177
+ // Prose, asked for in a box with room for it.
178
+ fields: {
179
+ content: { input: 'longtext' },
180
+ },
177
181
  },
178
182
  } as const)
@@ -104,5 +104,9 @@ export default defineModel({
104
104
 
105
105
  dashboard: {
106
106
  highlight: true,
107
+ // Prose, asked for in a box with room for it.
108
+ fields: {
109
+ description: { input: 'longtext' },
110
+ },
107
111
  },
108
112
  } as const)
@@ -157,5 +157,9 @@ export default defineModel({
157
157
 
158
158
  dashboard: {
159
159
  highlight: true,
160
+ // Prose, asked for in a box with room for it.
161
+ fields: {
162
+ notes: { input: 'longtext' },
163
+ },
160
164
  },
161
165
  } as const)
@@ -5,7 +5,7 @@ import { log } from '@stacksjs/logging'
5
5
  export default new Email({
6
6
  // or Sms or Push or Webhook or Chat
7
7
  name: 'welcome', // optional, defaults to the file name
8
- subject: 'Welcome to Stacks', // optional, but recommended
8
+ subject: `Welcome to ${config.app.name || 'our app'}`, // optional, but recommended
9
9
  to: 'some@email.com', // optional, has to be defined here or set when sending
10
10
  from: config.email.from, // optional, defaults to the config value
11
11
  template: 'Welcome', // resources/emails/Welcome.stx
@@ -2,7 +2,7 @@
2
2
  "publisher": "Stacks",
3
3
  "name": "vscode-stacks",
4
4
  "displayName": "Stacks",
5
- "version": "0.75.557",
5
+ "version": "0.75.559",
6
6
  "description": "Stacks, built into VS Code: stx templates, pickier linting and formatting, encrypted env files, the dev server preview and every buddy command. No other extensions required.",
7
7
  "license": "MIT",
8
8
  "funding": "https://github.com/sponsors/chrisbbreuer",
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@stacksjs/defaults",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.75.557",
5
+ "version": "0.75.559",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "git+https://github.com/stacksjs/stacks.git",
@@ -45,10 +45,10 @@
45
45
  "dependencies": {
46
46
  "@iconify-json/f7": "^1.2.2",
47
47
  "@iconify-json/hugeicons": "^1.2.35",
48
- "@stacksjs/mobile": "0.75.557",
48
+ "@stacksjs/mobile": "0.75.559",
49
49
  "@stacksjs/sanitizer": "^0.2.864",
50
50
  "@stacksjs/stx": "^0.2.864",
51
- "@stacksjs/strings": "0.75.557",
51
+ "@stacksjs/strings": "0.75.559",
52
52
  "@xterm/addon-fit": "^0.11.0",
53
53
  "@xterm/xterm": "^6.0.0",
54
54
  "ts-qr-codes": "^0.1.8"
@@ -1,6 +1,7 @@
1
1
  /** Server-side exposure boundary for the generic dashboard model surfaces. */
2
2
  import type { DashboardModelOptions } from '@stacksjs/types'
3
- import { resolveModelSources } from '@stacksjs/database/model-sources'
3
+ import type { ModelSource } from '@stacksjs/database/model-sources'
4
+ import { listModelSources } from '@stacksjs/database/model-sources'
4
5
  import { loadModelIfExists } from './data'
5
6
 
6
7
  /** Omission preserves the existing dashboard exposure. `enabled` only controls navigation. */
@@ -8,11 +9,28 @@ export function hasDashboardModelAccess(Model: { dashboard?: DashboardModelOptio
8
9
  return Model?.dashboard?.access !== false
9
10
  }
10
11
 
11
- /** Resolve the native model, then exclude it before callers inspect metadata or query rows. */
12
- export async function resolveDashboardModel(name: string, candidate?: any): Promise<any | null> {
12
+ /**
13
+ * The models in the app's schema, for {@link resolveDashboardModel}. Read
14
+ * once by a caller that resolves many models and handed to each call, so a
15
+ * page of 110 models lists the model directories once and not 110 times.
16
+ */
17
+ export function dashboardModelSources(): ModelSource[] {
18
+ return listModelSources() ?? []
19
+ }
20
+
21
+ /**
22
+ * Resolve the native model, then exclude it before callers inspect metadata or query rows.
23
+ *
24
+ * `sources` is {@link dashboardModelSources}, from a caller that already has
25
+ * it. Without it the directories are listed here: reads only. This used to
26
+ * ask the migration generator's `resolveModelSources`, which rebuilds its
27
+ * staging directory on every call, about 11ms of blocking file writes per
28
+ * model resolved.
29
+ */
30
+ export async function resolveDashboardModel(name: string, candidate?: any, sources: readonly ModelSource[] = dashboardModelSources()): Promise<any | null> {
13
31
  // App-owned definitions retain their native ORM and dashboard access even
14
32
  // when a same-named framework feature exports a disabled proxy.
15
- const source = resolveModelSources()?.models.find(model => model.name === name)
33
+ const source = sources.find(model => model.name === name)
16
34
  if (source && source.origin !== 'framework') {
17
35
  const Model = candidate ?? await loadModelIfExists(name)
18
36
  return Model && hasDashboardModelAccess(Model) ? Model : null