@stacksjs/types 0.75.95 → 0.75.96

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.
@@ -1,19 +1,7 @@
1
- /**
2
- * **Dashboard Options**
3
- *
4
- * Controls which sections render in the `buddy dev --dashboard` sidebar.
5
- * Every section defaults to enabled — set a flag to `false` in
6
- * `config/dashboard.ts` to hide it (for example, projects that don't
7
- * use commerce features set `commerce.enabled: false`).
8
- *
9
- * The `data` section is always visible (it's where every project's
10
- * userland models live). It exposes per-row toggles for the basic
11
- * built-in rows so a project can drop, say, the newsletter Subscribers
12
- * row when there's no newsletter without losing the model viewer.
13
- */
14
1
  export declare interface DashboardOptions {
15
2
  enabled?: boolean
16
3
  env?: string[]
4
+ access?: Partial<Record<DashboardRouteGroup, string[]>>
17
5
  nav?: Array<{
18
6
  title: string
19
7
  items: Array<{
@@ -130,10 +118,13 @@ export declare interface DashboardProviderOptions {
130
118
  * the path-based auto-categorisation (commerce/, Content/, etc.).
131
119
  * 3. `dashboard.label` / `dashboard.icon` → display overrides; fall back
132
120
  * to the model name and `iconMap` lookup.
133
- * 4. `dashboard.roles` → role-gates the sidebar row. The server-side
134
- * sidebar builder emits the row with role metadata; the client filters
135
- * it out for users who lack a matching role. Permissive default
136
- * (unauthenticated viewers see everything — see `useRole.ts`).
121
+ * 4. `dashboard.roles` → role-gates the sidebar row AND the API the
122
+ * `useApi` trait generates. The sidebar builder emits the row with role
123
+ * metadata and the client filters it out for users who lack a matching
124
+ * role, permissively by default (unauthenticated viewers see everything -
125
+ * see `useRole.ts`); the route generator appends `role:<the list>` to the
126
+ * resolved middleware, which `dashboard.enforce: false` opts out of
127
+ * (stacksjs/stacks#2883).
137
128
  */
138
129
  export declare interface DashboardModelOptions {
139
130
  enabled?: boolean
@@ -152,8 +143,55 @@ export declare interface DashboardModelOptions {
152
143
  | 'data'
153
144
  | 'app'
154
145
  roles?: string[]
146
+ enforce?: boolean
155
147
  description?: string
156
148
  }
149
+ /**
150
+ * **Dashboard Options**
151
+ *
152
+ * Controls which sections render in the `buddy dev --dashboard` sidebar.
153
+ * Every section defaults to enabled — set a flag to `false` in
154
+ * `config/dashboard.ts` to hide it (for example, projects that don't
155
+ * use commerce features set `commerce.enabled: false`).
156
+ *
157
+ * The `data` section is always visible (it's where every project's
158
+ * userland models live). It exposes per-row toggles for the basic
159
+ * built-in rows so a project can drop, say, the newsletter Subscribers
160
+ * row when there's no newsletter without losing the model viewer.
161
+ */
162
+ /**
163
+ * The framework's own dashboard route groups, by the prefix each one registers.
164
+ *
165
+ * Mirrors `DASHBOARD_ROUTE_GROUPS` in `@stacksjs/router`, which is the runtime
166
+ * source of truth; `core/router/tests/dashboard-access.test.ts` pins this
167
+ * union, that list and the prefixes `defaults/routes/dashboard.ts` actually
168
+ * registers against each other, because three copies of one list is a mirror
169
+ * and mirrors drift.
170
+ */
171
+ export type DashboardRouteGroup = | '/ai'
172
+ | '/api/analytics'
173
+ | '/api/commerce'
174
+ | '/api/data'
175
+ | '/api/marketing'
176
+ | '/api/monitoring'
177
+ | '/api/notifications'
178
+ | '/api/queries'
179
+ | '/api/settings'
180
+ | '/cms'
181
+ | '/dashboard'
182
+ | '/dashboard/cms'
183
+ | '/dashboard/commerce'
184
+ | '/deployments'
185
+ | '/infrastructure'
186
+ | '/jobs'
187
+ | '/library'
188
+ | '/models'
189
+ | '/payments'
190
+ | '/queue'
191
+ | '/queues'
192
+ | '/realtime'
193
+ | '/releases'
194
+ | '/voide';
157
195
  /**
158
196
  * The backends a dashboard section can read from.
159
197
  *
package/dist/model.d.ts CHANGED
@@ -330,19 +330,30 @@ export type SocialOptions = SocialProviders[];
330
330
  * Omit it and both reads and writes get `auth` — an undeclared read route is
331
331
  * how a customer list leaks (stacksjs/stacks#2224). A flat list applies to
332
332
  * both sides; the split form states them separately, which is the only way to
333
- * express the common "public catalog, authenticated writes" shape:
333
+ * express the common "public catalog, authenticated writes" shape; and an
334
+ * ability name overrides the side it belongs to, which is the only way to say
335
+ * "may create, may not delete" (stacksjs/stacks#2883):
334
336
  *
335
337
  * ```ts
336
338
  * middleware: ['auth'] // both sides
337
339
  * middleware: [] // both sides public (warns at boot)
338
340
  * middleware: { read: [], write: ['auth'] } // public reads, guarded writes
341
+ * middleware: { destroy: ['auth', 'role:admin'] } // only deletes need the role
342
+ * middleware: { write: ['auth'], destroy: ['auth', 'role:admin'] } // both at once
339
343
  * ```
340
344
  *
341
- * An omitted side of the split form falls back to `auth`, not to public.
345
+ * `read` covers `index` and `show`, `write` covers `store`, `update` and
346
+ * `destroy`, and `destroy` covers bulk-delete along with the single delete.
347
+ * An omitted side falls back to `auth` rather than to public, and so does an
348
+ * ability whose side is omitted too - declaring one ability never widens
349
+ * another.
342
350
  */
343
351
  export type ApiMiddleware = | string
344
352
  | string[]
345
- | { read?: string | string[], write?: string | string[] }
353
+ | (
354
+ { read?: string | string[], write?: string | string[] }
355
+ & { [ability in ApiRoutes]?: string | string[] }
356
+ );
346
357
  declare type ApiOptions = DeepPartial<ApiSettings>;
347
358
  /*
348
359
  * GDPR declarations (stacksjs/stacks#365): `personal` on an attribute and
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/types",
3
3
  "type": "module",
4
- "version": "0.75.95",
4
+ "version": "0.75.96",
5
5
  "description": "The Stacks framework types.",
6
6
  "author": "Chris Breuer",
7
7
  "contributors": [
@@ -58,9 +58,9 @@
58
58
  "dependencies": {
59
59
  "@stacksjs/bunpress": "^0.2.15",
60
60
  "@stacksjs/clapp": "^0.2.12",
61
- "@stacksjs/events": "0.75.95",
62
- "@stacksjs/strings": "0.75.95",
63
- "@stacksjs/stx": "^0.2.395",
61
+ "@stacksjs/events": "0.75.96",
62
+ "@stacksjs/strings": "0.75.96",
63
+ "@stacksjs/stx": "^0.2.406",
64
64
  "@stacksjs/ts-validation": "^0.5.6",
65
65
  "bun-query-builder": "^0.3.5"
66
66
  },
@@ -73,7 +73,7 @@
73
73
  }
74
74
  },
75
75
  "devDependencies": {
76
- "@stacksjs/validation": "0.75.95",
76
+ "@stacksjs/validation": "0.75.96",
77
77
  "better-dx": "^0.2.24",
78
78
  "meilisearch": "^0.62.0"
79
79
  },