@stacksjs/defaults 0.75.556 → 0.75.558
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-dashboard/SKILL.md +88 -11
- package/ai/skills/stacks-desktop/SKILL.md +15 -4
- package/ai/skills/stacks-migrations/SKILL.md +10 -0
- package/ai/skills/stacks-native/CATALOG.md +3 -3
- package/app/Actions/Dashboard/Models/GetModels.ts +4 -3
- package/app/Actions/Dashboard/Models/ModelsIndexAction.ts +6 -4
- package/app/Actions/Dashboard/Search/GlobalSearchAction.ts +3 -4
- package/app/Actions/Dashboard/Search/SearchEngineIndexAction.ts +4 -4
- package/app/Models/Board.ts +4 -0
- package/app/Models/Campaign.ts +24 -0
- package/app/Models/Card.ts +4 -0
- package/app/Models/CardComment.ts +7 -1
- package/app/Models/Comment.ts +8 -0
- package/app/Models/Content/Author.ts +6 -0
- package/app/Models/Content/Page.ts +7 -0
- package/app/Models/Content/Post.ts +12 -0
- package/app/Models/EmailList.ts +4 -0
- package/app/Models/FailedJob.ts +11 -0
- package/app/Models/MailPreference.ts +4 -0
- package/app/Models/NotificationDelivery.ts +12 -0
- package/app/Models/SocialPost.ts +6 -0
- package/app/Models/Tag.ts +7 -0
- package/app/Models/Team.ts +1 -0
- package/app/Models/User.ts +2 -1
- package/app/Models/commerce/AuctionItem.ts +4 -0
- package/app/Models/commerce/Cart.ts +4 -0
- package/app/Models/commerce/Category.ts +4 -0
- package/app/Models/commerce/Customer.ts +4 -0
- package/app/Models/commerce/DeliveryStop.ts +4 -0
- package/app/Models/commerce/LoyaltyReward.ts +6 -0
- package/app/Models/commerce/Manufacturer.ts +4 -0
- package/app/Models/commerce/Product.ts +4 -0
- package/app/Models/commerce/ProductUnit.ts +4 -0
- package/app/Models/commerce/Review.ts +4 -0
- package/app/Models/commerce/ShippingMethod.ts +4 -0
- package/app/Models/commerce/WaitlistProduct.ts +4 -0
- package/app/Notifications/Welcome.ts +1 -1
- package/functions/dashboard-loading.ts +36 -0
- package/functions/dashboard-model-record.ts +11 -0
- package/ide/vscode/package.json +1 -1
- package/package.json +5 -5
- package/resources/components/Dashboard/Data/DataModelRecords.stx +6 -3
- package/resources/components/Dashboard/Models/ModelRecordCreate.stx +9 -6
- package/resources/components/Dashboard/Models/ModelRecordDetail.stx +17 -10
- package/resources/components/Dashboard/Models/ModelRecordEdit.stx +9 -6
- package/resources/components/Dashboard/Models/ModelRecordsDashboard.stx +38 -25
- package/resources/components/Dashboard/Models/ModelsOverview.stx +30 -11
- package/resources/components/Dashboard/UI/QuietLoader.stx +24 -0
- package/resources/functions/dashboard/model-access.ts +22 -4
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script client>
|
|
2
2
|
import { dashboardApi } from '../../../../functions/dashboard-api'
|
|
3
|
+
import { dashboardLoaderTimer, dashboardReloadingClass } from '../../../../functions/dashboard-loading'
|
|
3
4
|
|
|
4
5
|
interface ModelRow {
|
|
5
6
|
name: string
|
|
@@ -41,6 +42,12 @@ const unavailableModels = state(0)
|
|
|
41
42
|
const unmigratedModels = state(0)
|
|
42
43
|
const categoryGroups = state<ModelGroup[]>([])
|
|
43
44
|
const loading = state(true)
|
|
45
|
+
// Whether the registry has been read. Until it has (and after a read that
|
|
46
|
+
// failed) nothing is known about it: the cards say "-" and not 0, and no
|
|
47
|
+
// count of matching models is given.
|
|
48
|
+
const known = state(false)
|
|
49
|
+
// Set once a request has taken long enough to say so (dashboard-loading.ts).
|
|
50
|
+
const slow = state(false)
|
|
44
51
|
const loadError = state('')
|
|
45
52
|
const search = state('')
|
|
46
53
|
const selectedCategory = state('all')
|
|
@@ -73,9 +80,20 @@ const visibleGroups = derived(() => {
|
|
|
73
80
|
|
|
74
81
|
const visibleModelCount = derived(() => visibleGroups().reduce((total, group) => total + group.models.length, 0))
|
|
75
82
|
|
|
83
|
+
/** A card's number, or "-" while it is not known. */
|
|
84
|
+
function registryCount(value: number): string {
|
|
85
|
+
return known() ? value.toLocaleString() : '-'
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const matchingLabel = derived(() => known() ? `${visibleModelCount()} matching ${visibleModelCount() === 1 ? 'model' : 'models'}` : '')
|
|
89
|
+
// Refreshing keeps the models that are there, dimmed, until the answer swaps them.
|
|
90
|
+
const refreshing = derived(() => loading() && known())
|
|
91
|
+
const groupsClass = derived(() => dashboardReloadingClass(loading(), 'p-5 space-y-7'))
|
|
92
|
+
|
|
76
93
|
async function loadModels(): Promise<void> {
|
|
77
94
|
loading.set(true)
|
|
78
95
|
loadError.set('')
|
|
96
|
+
const settle = dashboardLoaderTimer(slow)
|
|
79
97
|
try {
|
|
80
98
|
const response = await dashboardApi<ModelsResponse>('/api/dashboard/models')
|
|
81
99
|
totalModels.set(response.totalModels || 0)
|
|
@@ -84,8 +102,10 @@ async function loadModels(): Promise<void> {
|
|
|
84
102
|
unavailableModels.set(response.unavailableModels || 0)
|
|
85
103
|
unmigratedModels.set(response.unmigratedModels || 0)
|
|
86
104
|
categoryGroups.set(response.categoryGroups || [])
|
|
105
|
+
known.set(true)
|
|
87
106
|
}
|
|
88
107
|
catch (error) {
|
|
108
|
+
known.set(false)
|
|
89
109
|
totalModels.set(0)
|
|
90
110
|
totalRecords.set(0)
|
|
91
111
|
userlandCount.set(0)
|
|
@@ -95,6 +115,7 @@ async function loadModels(): Promise<void> {
|
|
|
95
115
|
loadError.set(error instanceof Error ? error.message : 'Models could not be loaded.')
|
|
96
116
|
}
|
|
97
117
|
finally {
|
|
118
|
+
settle()
|
|
98
119
|
loading.set(false)
|
|
99
120
|
}
|
|
100
121
|
}
|
|
@@ -110,21 +131,21 @@ onMount(() => {
|
|
|
110
131
|
<h1 class="font-bold text-2xl text-neutral-900 tracking-tight dark:text-white">{{ title() }}</h1>
|
|
111
132
|
<p class="mt-1 max-w-3xl text-neutral-500 text-sm dark:text-neutral-400">{{ description() }}</p>
|
|
112
133
|
</div>
|
|
113
|
-
<Button variant="secondary" :loading="loading()" @click="loadModels">
|
|
114
|
-
<span :if="!
|
|
134
|
+
<Button variant="secondary" :loading="refreshing()" :disabled="loading()" @click="loadModels">
|
|
135
|
+
<span :if="!refreshing()" class="h-4 w-4 i-hugeicons-refresh"></span>
|
|
115
136
|
Refresh
|
|
116
137
|
</Button>
|
|
117
138
|
</header>
|
|
118
139
|
|
|
119
140
|
<div class="grid gap-4 grid-cols-1 sm:grid-cols-3">
|
|
120
141
|
<StatsCard title="Total Models" icon="i-hugeicons-database" iconBg="primary">
|
|
121
|
-
<template #value>{{ totalModels() }}</template>
|
|
142
|
+
<template #value>{{ registryCount(totalModels()) }}</template>
|
|
122
143
|
</StatsCard>
|
|
123
144
|
<StatsCard title="Total Records" icon="i-hugeicons-table-rows-split" iconBg="success">
|
|
124
|
-
<template #value>{{ totalRecords()
|
|
145
|
+
<template #value>{{ registryCount(totalRecords()) }}</template>
|
|
125
146
|
</StatsCard>
|
|
126
147
|
<StatsCard title="App Overrides" icon="i-hugeicons-folder-02" iconBg="info">
|
|
127
|
-
<template #value>{{ userlandCount() }}</template>
|
|
148
|
+
<template #value>{{ registryCount(userlandCount()) }}</template>
|
|
128
149
|
</StatsCard>
|
|
129
150
|
</div>
|
|
130
151
|
|
|
@@ -147,7 +168,7 @@ onMount(() => {
|
|
|
147
168
|
<div class="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between p-5 border-b border-neutral-200 dark:border-neutral-700">
|
|
148
169
|
<div>
|
|
149
170
|
<h2 class="font-semibold text-neutral-900 dark:text-white">Model Registry</h2>
|
|
150
|
-
<p class="mt-1 text-neutral-500 text-xs dark:text-neutral-400"
|
|
171
|
+
<p class="mt-1 min-h-4 text-neutral-500 text-xs dark:text-neutral-400" :text="matchingLabel()"></p>
|
|
151
172
|
</div>
|
|
152
173
|
<div class="flex flex-col gap-2 sm:flex-row w-full sm:w-auto">
|
|
153
174
|
<label class="block relative w-full sm:w-64">
|
|
@@ -165,11 +186,9 @@ onMount(() => {
|
|
|
165
186
|
</div>
|
|
166
187
|
</div>
|
|
167
188
|
|
|
168
|
-
<
|
|
169
|
-
<div :for="index in [1, 2, 3, 4, 5, 6]" class="h-40 bg-neutral-100 dark:bg-neutral-800 rounded-xl animate-pulse"></div>
|
|
170
|
-
</div>
|
|
189
|
+
<QuietLoader :if="loading() && !known()" :slow="slow()" label="Loading models" :framed="false" />
|
|
171
190
|
|
|
172
|
-
<div :if="
|
|
191
|
+
<div :if="known() && visibleModelCount() === 0">
|
|
173
192
|
<EmptyState
|
|
174
193
|
icon="i-hugeicons-database-01"
|
|
175
194
|
:title="totalModels() === 0 ? 'No models were discovered' : 'No models match these filters'"
|
|
@@ -177,7 +196,7 @@ onMount(() => {
|
|
|
177
196
|
/>
|
|
178
197
|
</div>
|
|
179
198
|
|
|
180
|
-
<div :if="
|
|
199
|
+
<div :if="known() && visibleModelCount() > 0" :class="groupsClass()" :aria-busy="loading() ? 'true' : null" data-model-groups>
|
|
181
200
|
<section :for="group in visibleGroups()" class="space-y-3">
|
|
182
201
|
<div class="flex items-baseline justify-between">
|
|
183
202
|
<h3 class="font-semibold text-neutral-900 dark:text-white">{{ group.label }}</h3>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<script client>
|
|
2
|
+
// Where a page's content will be, before its first answer. An empty panel of
|
|
3
|
+
// about the content's size, so the page does not jump twice, that says what
|
|
4
|
+
// it is waiting for only once that has taken long enough to notice
|
|
5
|
+
// (`dashboardLoaderTimer`). A page that answers at once never shows a loader.
|
|
6
|
+
//
|
|
7
|
+
// Not a skeleton: nothing is known yet, so there is nothing to draw the
|
|
8
|
+
// shape of.
|
|
9
|
+
const slow = useReactiveProp('slow', false)
|
|
10
|
+
const label = useReactiveProp('label', 'Loading')
|
|
11
|
+
// Off inside something that already has an edge, such as a card.
|
|
12
|
+
const framed = useReactiveProp('framed', true)
|
|
13
|
+
|
|
14
|
+
const panelClass = derived(() => framed()
|
|
15
|
+
? 'flex items-center justify-center h-64 bg-white dark:bg-neutral-900 border border-black/8 rounded-xl dark:border-white/10'
|
|
16
|
+
: 'flex items-center justify-center h-64')
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<div role="status" aria-live="polite" data-quiet-loader :class="panelClass()">
|
|
20
|
+
<p :if="slow()" class="flex gap-2 items-center text-[13px] text-neutral-500 dark:text-neutral-400">
|
|
21
|
+
<span aria-hidden="true" class="h-4 w-4 animate-spin i-hugeicons-loading-03"></span>
|
|
22
|
+
<span :text="label()"></span>
|
|
23
|
+
</p>
|
|
24
|
+
</div>
|
|
@@ -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 {
|
|
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
|
-
/**
|
|
12
|
-
|
|
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 =
|
|
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
|