@stacksjs/actions 0.70.257 → 0.70.259

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 (142) hide show
  1. package/dist/action.js +1 -80
  2. package/dist/actions.js +1 -2
  3. package/dist/add.js +1 -20
  4. package/dist/ai/request-model-access.js +1 -10
  5. package/dist/auth/client.js +2 -44
  6. package/dist/auth/prune.js +1 -35
  7. package/dist/auth/setup.js +33 -153
  8. package/dist/auth/token.js +1 -10
  9. package/dist/blog-admin.js +3 -151
  10. package/dist/blog.js +33 -271
  11. package/dist/build/cli.js +1 -6
  12. package/dist/build/component-library.js +1 -36
  13. package/dist/build/component-libs.js +1 -2
  14. package/dist/build/core.js +1 -55
  15. package/dist/build/desktop.js +4 -61
  16. package/dist/build/dmg.js +4 -68
  17. package/dist/build/docs.js +1 -5
  18. package/dist/build/frontend-static.js +6 -122
  19. package/dist/build/server.js +1 -6
  20. package/dist/build/stacks.js +1 -8
  21. package/dist/build/views.js +1 -16
  22. package/dist/build-web-component-lib.js +1 -2
  23. package/dist/build.js +1 -57
  24. package/dist/bump.js +9 -210
  25. package/dist/changelog.js +1 -27
  26. package/dist/check/ports.js +1 -16
  27. package/dist/clean.js +1 -4
  28. package/dist/commit.js +1 -12
  29. package/dist/copy-types.js +1 -9
  30. package/dist/database/seed.js +1 -26
  31. package/dist/deploy/create-receipt-rule.js +1 -36
  32. package/dist/deploy/index.js +29 -1306
  33. package/dist/dev/api.js +3 -94
  34. package/dist/dev/components.js +1 -7
  35. package/dist/dev/csrf.js +1 -28
  36. package/dist/dev/dashboard-request-routing.js +1 -10
  37. package/dist/dev/dashboard-utils.js +1 -380
  38. package/dist/dev/dashboard.js +7 -422
  39. package/dist/dev/desktop.js +1 -1
  40. package/dist/dev/docs.js +1 -24
  41. package/dist/dev/exit-with-parent.d.ts +6 -0
  42. package/dist/dev/exit-with-parent.js +1 -0
  43. package/dist/dev/index.js +1 -29
  44. package/dist/dev/migrate-watcher.js +1 -74
  45. package/dist/dev/system-tray.js +2 -172
  46. package/dist/dev/views.js +1 -169
  47. package/dist/discover-packages.js +1 -32
  48. package/dist/domains/add.js +1 -61
  49. package/dist/domains/purchase.js +1 -66
  50. package/dist/domains/remove.js +1 -24
  51. package/dist/examples.js +1 -34
  52. package/dist/find-projects.js +1 -16
  53. package/dist/fresh.js +1 -17
  54. package/dist/generate/action-types.js +3 -9
  55. package/dist/generate/component-meta.js +1 -9
  56. package/dist/generate/custom-cli-file.js +2 -20
  57. package/dist/generate/env-files.js +5 -46
  58. package/dist/generate/ide-helpers.js +1 -8
  59. package/dist/generate/images.js +1 -26
  60. package/dist/generate/index.js +1 -166
  61. package/dist/generate/lib-entries.js +1 -16
  62. package/dist/generate/pantry-file.js +1 -46
  63. package/dist/generate/symlink-core.js +1 -2
  64. package/dist/generate/types.js +1 -3
  65. package/dist/generate/vschema.js +2 -47
  66. package/dist/generate/vscode-custom-data.js +1 -9
  67. package/dist/helpers/api-host.js +1 -7
  68. package/dist/helpers/component-meta.js +5 -295
  69. package/dist/helpers/index.js +1 -1
  70. package/dist/helpers/lib-entries.js +3 -73
  71. package/dist/helpers/package-json.js +2 -34
  72. package/dist/helpers/utils.js +1 -130
  73. package/dist/helpers/vscode-custom-data.js +3 -57
  74. package/dist/index.d.ts +4 -0
  75. package/dist/index.js +1 -50
  76. package/dist/key-generate.js +1 -24
  77. package/dist/lint/fix.js +1 -4
  78. package/dist/lint/index.js +1 -4
  79. package/dist/lint/lint.js +1 -34
  80. package/dist/lint/stx-gate.d.ts +36 -0
  81. package/dist/lint/stx-gate.js +3 -0
  82. package/dist/make-command.js +4 -55
  83. package/dist/make-job.js +3 -29
  84. package/dist/make-policy.js +4 -53
  85. package/dist/make-resource.js +3 -33
  86. package/dist/make.js +7 -323
  87. package/dist/migrate/database.js +1 -16
  88. package/dist/migrate/fresh.js +1 -36
  89. package/dist/prepublish.js +1 -16
  90. package/dist/queue/clear.js +1 -42
  91. package/dist/queue/dlq-purge.js +1 -28
  92. package/dist/queue/dlq-retry.js +1 -35
  93. package/dist/queue/dlq.js +4 -55
  94. package/dist/queue/failed.js +4 -69
  95. package/dist/queue/flush.js +2 -49
  96. package/dist/queue/inspect.js +7 -154
  97. package/dist/queue/list.js +4 -69
  98. package/dist/queue/monitor.js +5 -94
  99. package/dist/queue/pause.js +1 -28
  100. package/dist/queue/quarantine.js +2 -42
  101. package/dist/queue/resume.js +1 -27
  102. package/dist/queue/retry.js +1 -41
  103. package/dist/queue/schedule-list.js +4 -33
  104. package/dist/queue/schedule.js +1 -12
  105. package/dist/queue/status.js +4 -68
  106. package/dist/queue/table.js +1 -10
  107. package/dist/queue/unquarantine.js +1 -27
  108. package/dist/queue/work.js +1 -57
  109. package/dist/release-preflight.js +3 -61
  110. package/dist/release.js +1 -29
  111. package/dist/route/list.js +2 -78
  112. package/dist/run-action.js +1 -1
  113. package/dist/saas/setup.js +1 -9
  114. package/dist/scaffold-crud.js +12 -137
  115. package/dist/schedule/run.js +1 -7
  116. package/dist/search/flush.js +1 -10
  117. package/dist/search/import.js +1 -10
  118. package/dist/search/settings-list.js +1 -10
  119. package/dist/search/settings.js +1 -9
  120. package/dist/serve/api.js +1 -37
  121. package/dist/setup/index.js +1 -1
  122. package/dist/setup/ssl.js +2 -268
  123. package/dist/stacks.js +1 -316
  124. package/dist/templates.js +20 -40
  125. package/dist/test/feature.js +1 -2
  126. package/dist/test/index.js +1 -2
  127. package/dist/test/runner.js +1 -38
  128. package/dist/test/runner.test.js +1 -29
  129. package/dist/test/ui.js +1 -2
  130. package/dist/test/unit.js +1 -2
  131. package/dist/typecheck.js +1 -4
  132. package/dist/types.js +1 -16
  133. package/dist/upgrade/binary.js +1 -29
  134. package/dist/upgrade/framework-hooks.js +1 -40
  135. package/dist/upgrade/framework-utils.js +2 -259
  136. package/dist/upgrade/framework.js +11 -484
  137. package/dist/upgrade/index.js +1 -17
  138. package/dist/upgrade/package-project.js +1 -150
  139. package/dist/upgrade/packages.js +17 -243
  140. package/dist/upgrade/shell.js +3 -40
  141. package/dist/upgrade.js +1 -38
  142. package/package.json +19 -19
package/dist/dev/api.js CHANGED
@@ -1,96 +1,5 @@
1
- import { existsSync } from "node:fs";
2
- import process from "node:process";
3
- import { parseOptions } from "@stacksjs/cli";
4
- import { config, overridesReady } from "@stacksjs/config";
5
- import { path } from "@stacksjs/path";
6
- import { route } from "@stacksjs/router";
7
- import { generateAutoImportFiles, generateServerAutoImportTypes, injectGlobalAutoImports } from "@stacksjs/server";
8
- import { resolveApiHost } from "../helpers/api-host";
9
- const _options = parseOptions();
10
- await generateServerAutoImportTypes();
11
- await overridesReady;
12
- const port = Number(process.env.PORT_API) || config.ports?.api || 3008, hostname = resolveApiHost(), modelsIndex = path.storagePath("framework/auto-imports/models.ts");
13
- if (!existsSync(modelsIndex))
14
- await generateAutoImportFiles();
15
- await injectGlobalAutoImports();
16
- try {
17
- const typesenseDev = path.appPath("Lib/typesense-dev.ts");
18
- if (existsSync(typesenseDev)) {
19
- const mod = await import(typesenseDev);
20
- if (typeof mod.ensureTypesenseRunning === "function")
21
- await mod.ensureTypesenseRunning();
22
- }
23
- } catch (err) {
24
- const { log } = await import("@stacksjs/cli");
25
- log.warn(`[api:dev] search engine bootstrap skipped: ${err.message}`);
26
- }
27
- try {
28
- const listenerPath = path.appPath("Listener.ts");
29
- if (existsSync(listenerPath)) {
30
- const listener = await import(listenerPath);
31
- if (typeof listener.handleEvents === "function")
32
- await listener.handleEvents();
33
- }
34
- } catch (err) {
35
- const { log } = await import("@stacksjs/cli");
36
- log.warn(`[api:dev] failed to bootstrap event listeners \u2014 dispatched events will be ignored: ${err.message}`);
37
- }
38
- try {
39
- const { startModelMigrationWatcher } = await import("./migrate-watcher");
40
- startModelMigrationWatcher();
41
- } catch (err) {
42
- const { log } = await import("@stacksjs/cli");
43
- log.debug(`[api:dev] auto-migrate watcher not started: ${err.message}`);
44
- }
45
- function resolveDefaultsCorsPath() {
46
- const vendored = path.frameworkPath("defaults/app/Middleware/Cors.ts");
47
- if (existsSync(vendored))
48
- return vendored;
49
- try {
50
- return `${Bun.resolveSync("@stacksjs/defaults/package.json", process.cwd()).replace(/package\.json$/, "")}app/Middleware/Cors.ts`;
51
- } catch {
52
- return vendored;
53
- }
54
- }
55
- const corsMod = await import(resolveDefaultsCorsPath()), corsMiddleware = corsMod.default;
56
- route.use(corsMiddleware.toRouterHandler());
57
- const SAFE_REQUEST_ID = /^[a-zA-Z0-9._-]{8,128}$/;
58
- route.use(async (request, next) => {
59
- const inbound = request?.headers?.get?.("x-request-id") || request?.headers?.get?.("X-Request-ID") || "", id = typeof inbound === "string" && SAFE_REQUEST_ID.test(inbound) ? inbound : crypto.randomUUID();
60
- request._requestId = id;
61
- request._startNs = process.hrtime.bigint();
62
- const response = await next();
63
- if (response && response.status === 404 && (response.headers.get("content-type") || "").includes("json"))
64
- try {
65
- const body = await response.clone().json();
66
- if (body && (body.message === "Not Found" || body.error === "Not Found")) {
67
- const url = new URL(request.url), enriched = {
68
- ...body,
69
- path: url.pathname,
70
- method: request.method,
71
- request_id: id
72
- }, headers = new Headers(response.headers);
73
- headers.set("X-Request-ID", id);
74
- return new Response(JSON.stringify(enriched), { status: 404, headers });
75
- }
76
- } catch {}
77
- return response;
78
- });
79
- await route.importRoutes();
80
- try {
81
- await route.serve({
82
- port,
83
- hostname
84
- });
85
- console.log(`
1
+ import{existsSync}from"node:fs";import process from"node:process";import{parseOptions}from"@stacksjs/cli";import{config,overridesReady}from"@stacksjs/config";import{path}from"@stacksjs/path";import{route}from"@stacksjs/router";import{autoImportsAreStale,generateAutoImportFiles,generateServerAutoImportTypes,injectGlobalAutoImports}from"@stacksjs/server";import{resolveApiHost}from"../helpers/api-host";import{exitWithParent}from"./exit-with-parent";const _options=parseOptions();exitWithParent();await generateServerAutoImportTypes();await overridesReady;const port=Number(process.env.PORT_API)||config.ports?.api||3008,hostname=resolveApiHost(),modelsIndex=path.storagePath("framework/auto-imports/models.ts");if(!existsSync(modelsIndex)||autoImportsAreStale())await generateAutoImportFiles();await injectGlobalAutoImports();try{const typesenseDev=path.appPath("Lib/typesense-dev.ts");if(existsSync(typesenseDev)){const mod=await import(typesenseDev);if(typeof mod.ensureTypesenseRunning==="function")await mod.ensureTypesenseRunning()}}catch(err){const{log}=await import("@stacksjs/cli");log.warn(`[api:dev] search engine bootstrap skipped: ${err.message}`)}try{const listenerPath=path.appPath("Listener.ts");if(existsSync(listenerPath)){const listener=await import(listenerPath);if(typeof listener.handleEvents==="function")await listener.handleEvents()}}catch(err){const{log}=await import("@stacksjs/cli");log.warn(`[api:dev] failed to bootstrap event listeners \u2014 dispatched events will be ignored: ${err.message}`)}try{const{startModelMigrationWatcher}=await import("./migrate-watcher");startModelMigrationWatcher()}catch(err){const{log}=await import("@stacksjs/cli");log.debug(`[api:dev] auto-migrate watcher not started: ${err.message}`)}function resolveDefaultsCorsPath(){const vendored=path.frameworkPath("defaults/app/Middleware/Cors.ts");if(existsSync(vendored))return vendored;try{return`${Bun.resolveSync("@stacksjs/defaults/package.json",process.cwd()).replace(/package\.json$/,"")}app/Middleware/Cors.ts`}catch{return vendored}}const corsMod=await import(resolveDefaultsCorsPath()),corsMiddleware=corsMod.default;route.use(corsMiddleware.toRouterHandler());const SAFE_REQUEST_ID=/^[a-zA-Z0-9._-]{8,128}$/;route.use(async(request,next)=>{const inbound=request?.headers?.get?.("x-request-id")||request?.headers?.get?.("X-Request-ID")||"",id=typeof inbound==="string"&&SAFE_REQUEST_ID.test(inbound)?inbound:crypto.randomUUID();request._requestId=id;request._startNs=process.hrtime.bigint();const response=await next();if(response&&response.status===404&&(response.headers.get("content-type")||"").includes("json"))try{const body=await response.clone().json();if(body&&(body.message==="Not Found"||body.error==="Not Found")){const url=new URL(request.url),enriched={...body,path:url.pathname,method:request.method,request_id:id},headers=new Headers(response.headers);headers.set("X-Request-ID",id);return new Response(JSON.stringify(enriched),{status:404,headers})}}catch{}return response});await route.importRoutes();try{await route.serve({port,hostname});console.log(`
86
2
  \u279C API server ready: http://${hostname}:${port}
87
- `);
88
- } catch (err) {
89
- if ((err?.code || err?.errno) === "EADDRINUSE" || String(err?.message || "").includes("EADDRINUSE")) {
90
- console.error(`
3
+ `)}catch(err){if((err?.code||err?.errno)==="EADDRINUSE"||String(err?.message||"").includes("EADDRINUSE")){console.error(`
91
4
  [dev/api] Port ${port} is already in use. Kill the other process and re-run \`./buddy dev\`, or set PORT_API to another port.
92
- `);
93
- process.exit(1);
94
- }
95
- throw err;
96
- }
5
+ `);process.exit(1)}throw err}
@@ -1,7 +1 @@
1
- import { parseOptions, runCommand } from "@stacksjs/cli";
2
- import { libsPath } from "@stacksjs/path";
3
- const options = parseOptions();
4
- await runCommand("bun run dev", {
5
- ...options,
6
- cwd: libsPath("components/stx")
7
- });
1
+ import{parseOptions,runCommand}from"@stacksjs/cli";import{libsPath}from"@stacksjs/path";const options=parseOptions();await runCommand("bun run dev",{...options,cwd:libsPath("components/stx")});
package/dist/dev/csrf.js CHANGED
@@ -1,28 +1 @@
1
- import { existsSync } from "node:fs";
2
- import { projectPath } from "@stacksjs/path";
3
- export function resolveCsrfMiddlewarePath() {
4
- const relativePath = "app/Middleware/Csrf.ts", vendoredPath = projectPath(`storage/framework/defaults/${relativePath}`);
5
- if (existsSync(vendoredPath))
6
- return vendoredPath;
7
- try {
8
- const packageJson = Bun.resolveSync("@stacksjs/defaults/package.json", process.cwd());
9
- return `${packageJson.slice(0, packageJson.lastIndexOf("/"))}/${relativePath}`;
10
- } catch {
11
- return vendoredPath;
12
- }
13
- }
14
- export async function seedCsrfPageResponse(request, response) {
15
- const method = request.method.toUpperCase();
16
- if (method !== "GET" && method !== "HEAD")
17
- return;
18
- if (!(response.headers.get("content-type") || "").toLowerCase().includes("text/html"))
19
- return;
20
- try {
21
- const { seedCsrfCookieIfMissing } = await import(resolveCsrfMiddlewarePath());
22
- return seedCsrfCookieIfMissing(request, response);
23
- } catch {}
24
- }
25
- export async function validateDevCsrfRequest(request) {
26
- const { validateCsrfRequest } = await import(resolveCsrfMiddlewarePath());
27
- await validateCsrfRequest(request);
28
- }
1
+ import{existsSync}from"node:fs";import{projectPath}from"@stacksjs/path";export function resolveCsrfMiddlewarePath(){const relativePath="app/Middleware/Csrf.ts",vendoredPath=projectPath(`storage/framework/defaults/${relativePath}`);if(existsSync(vendoredPath))return vendoredPath;try{const packageJson=Bun.resolveSync("@stacksjs/defaults/package.json",process.cwd());return`${packageJson.slice(0,packageJson.lastIndexOf("/"))}/${relativePath}`}catch{return vendoredPath}}export async function seedCsrfPageResponse(request,response){const method=request.method.toUpperCase();if(method!=="GET"&&method!=="HEAD")return;if(!(response.headers.get("content-type")||"").toLowerCase().includes("text/html"))return;try{const{seedCsrfCookieIfMissing}=await import(resolveCsrfMiddlewarePath());return seedCsrfCookieIfMissing(request,response)}catch{}}export async function validateDevCsrfRequest(request){const{validateCsrfRequest}=await import(resolveCsrfMiddlewarePath());await validateCsrfRequest(request)}
@@ -1,10 +1 @@
1
- export function shouldDelegateDashboardRequest(pathname, method) {
2
- if (pathname.startsWith("/api/config/") || pathname.startsWith("/__deps/"))
3
- return !1;
4
- if (pathname.startsWith("/api/"))
5
- return !0;
6
- if (pathname.startsWith("/auth/") || pathname === "/me")
7
- return !0;
8
- const normalizedMethod = method.toUpperCase();
9
- return normalizedMethod !== "GET" && normalizedMethod !== "HEAD";
10
- }
1
+ export function shouldDelegateDashboardRequest(pathname,method){if(pathname.startsWith("/api/config/")||pathname.startsWith("/__deps/"))return!1;if(pathname.startsWith("/api/"))return!0;if(pathname.startsWith("/auth/")||pathname==="/me")return!0;const normalizedMethod=method.toUpperCase();return normalizedMethod!=="GET"&&normalizedMethod!=="HEAD"}
@@ -1,380 +1 @@
1
- import { Glob } from "bun";
2
- import { existsSync } from "node:fs";
3
- import path from "node:path";
4
- import { pathToFileURL } from "node:url";
5
- export const iconMap = {
6
- user: "person.fill",
7
- team: "person.2.fill",
8
- subscriber: "envelope.open.fill",
9
- subscriberemail: "envelope.fill",
10
- post: "doc.text.fill",
11
- page: "doc.fill",
12
- product: "cube.box.fill",
13
- productvariant: "cube.fill",
14
- productunit: "scalemass.fill",
15
- order: "list.clipboard.fill",
16
- orderitem: "list.bullet.clipboard.fill",
17
- customer: "person.crop.circle.fill",
18
- payment: "creditcard.fill",
19
- paymentmethod: "creditcard.and.123",
20
- paymentproduct: "creditcard.fill",
21
- paymenttransaction: "creditcard.fill",
22
- category: "tag.fill",
23
- tag: "tag",
24
- comment: "bubble.left.fill",
25
- author: "person.text.rectangle.fill",
26
- notification: "bell.fill",
27
- job: "briefcase.fill",
28
- log: "list.bullet.rectangle.portrait.fill",
29
- campaign: "megaphone.fill",
30
- review: "star.fill",
31
- coupon: "ticket.fill",
32
- giftcard: "giftcard.fill",
33
- cart: "cart.fill",
34
- cartitem: "cart.badge.plus",
35
- taxrate: "percent",
36
- transaction: "arrow.left.arrow.right.circle.fill",
37
- subscription: "repeat.circle.fill",
38
- emaillist: "envelope.badge.person.crop",
39
- socialpost: "bubble.left.and.bubble.right.fill",
40
- manufacturer: "building.2.fill",
41
- shippingmethod: "shippingbox.fill",
42
- shippingzone: "map.fill",
43
- shippingrate: "dollarsign.circle.fill",
44
- deliveryroute: "map.fill",
45
- driver: "car.fill",
46
- digitaldelivery: "arrow.down.doc.fill",
47
- licensekey: "key.fill",
48
- loyaltypoint: "star.circle.fill",
49
- loyaltyreward: "gift.fill",
50
- printdevice: "printer.fill",
51
- receipt: "doc.text.fill",
52
- waitlistproduct: "clock.fill",
53
- waitlistrestaurant: "clock.badge.checkmark.fill",
54
- websocket: "antenna.radiowaves.left.and.right",
55
- default: "tablecells.fill"
56
- }, excludeModels = new Set(["activity", "request", "error", "failedjob"]), dedicatedPages = new Set(["user", "team", "subscriber", "post", "page", "product", "order", "customer", "payment", "coupon", "category", "tag", "comment", "author", "notification", "job", "campaign", "review", "gift-card"]);
57
- const ROOT_MODEL_CATEGORY = {
58
- user: "data",
59
- team: "data",
60
- subscriber: "data",
61
- activity: "data",
62
- campaign: "marketing",
63
- emaillist: "marketing",
64
- socialpost: "marketing",
65
- subscriberemail: "marketing",
66
- comment: "content",
67
- tag: "content",
68
- paymentmethod: "commerce",
69
- paymentproduct: "commerce",
70
- paymenttransaction: "commerce",
71
- subscription: "commerce",
72
- deployment: "system",
73
- error: "system",
74
- failedjob: "system",
75
- job: "system",
76
- log: "system",
77
- notification: "system",
78
- release: "system",
79
- request: "system"
80
- };
81
- export function modelNameToId(name) {
82
- return name.replace(/([A-Z])/g, "-$1").toLowerCase().replace(/^-/, "");
83
- }
84
- export function getModelIcon(name) {
85
- return iconMap[name.toLowerCase()] || iconMap.default || "database";
86
- }
87
- function categorizeModel(relativePath, modelId, defaultCategory) {
88
- if (defaultCategory)
89
- return defaultCategory;
90
- const firstSeg = relativePath.includes("/") ? (relativePath.split("/")[0] ?? "").toLowerCase() : "";
91
- if (firstSeg === "commerce")
92
- return "commerce";
93
- if (firstSeg === "content")
94
- return "content";
95
- if (firstSeg === "realtime")
96
- return "system";
97
- return ROOT_MODEL_CATEGORY[modelId.replace(/-/g, "")] ?? "data";
98
- }
99
- async function readModelDashboardConfig(absolutePath) {
100
- try {
101
- const mod = await import(pathToFileURL(absolutePath).href);
102
- return (mod.default ?? mod).dashboard;
103
- } catch (error) {
104
- throw Error(`Could not discover dashboard model ${absolutePath}: ${error instanceof Error ? error.message : String(error)}`);
105
- }
106
- }
107
- export async function scanModelsDir(dir, seenNames, models, defaultCategory) {
108
- if (!existsSync(dir))
109
- return;
110
- const glob = new Glob("**/*.ts");
111
- for await (const file of glob.scan({ cwd: dir })) {
112
- if (file.includes("README") || file.includes(".d.ts"))
113
- continue;
114
- const name = file.replace(/\.ts$/, "").split("/").pop() || "", nameLower = name.toLowerCase();
115
- if (name && !seenNames.has(nameLower) && !excludeModels.has(nameLower)) {
116
- seenNames.add(nameLower);
117
- const id = modelNameToId(name), absolutePath = path.resolve(dir, file), dashboard = await readModelDashboardConfig(absolutePath);
118
- models.push({
119
- name,
120
- icon: dashboard?.icon ?? getModelIcon(name),
121
- id,
122
- category: categorizeModel(file, id, defaultCategory),
123
- dashboard
124
- });
125
- }
126
- }
127
- }
128
- export async function discoverModels(userModelsPath, defaultModelsPath) {
129
- const models = [], seenNames = new Set;
130
- await scanModelsDir(userModelsPath, seenNames, models, "userland");
131
- await scanModelsDir(defaultModelsPath, seenNames, models);
132
- return models.sort((a, b) => a.name.localeCompare(b.name));
133
- }
134
- export function buildManifest(models) {
135
- return models.map((m) => {
136
- const row = {
137
- id: m.id,
138
- name: m.name,
139
- icon: m.icon,
140
- hasDedicatedPage: dedicatedPages.has(m.id),
141
- category: m.category ?? "data"
142
- };
143
- if (m.dashboard)
144
- row.dashboard = m.dashboard;
145
- return row;
146
- });
147
- }
148
- export async function isPortAvailable(port) {
149
- try {
150
- Bun.serve({ port, fetch: () => new Response }).stop(!0);
151
- return !0;
152
- } catch {
153
- return !1;
154
- }
155
- }
156
- export async function findAvailablePort(preferred, maxAttempts = 20) {
157
- for (let i = 0;i < maxAttempts; i++) {
158
- const port = preferred + i;
159
- if (await isPortAvailable(port))
160
- return port;
161
- }
162
- return preferred;
163
- }
164
- export async function waitForServer(port, maxWait = 500) {
165
- const start = Date.now();
166
- while (Date.now() - start < maxWait) {
167
- try {
168
- const res = await fetch(`http://localhost:${port}/`, { method: "HEAD" });
169
- if (res.ok || res.status === 404)
170
- return !0;
171
- } catch {}
172
- await new Promise((resolve) => setTimeout(resolve, 25));
173
- }
174
- return !1;
175
- }
176
- function effectiveCategory(m) {
177
- if (m.dashboard?.enabled === !1)
178
- return;
179
- if (m.dashboard?.section)
180
- return m.dashboard.section;
181
- return m.category ?? "data";
182
- }
183
- function categoryRows(baseRoute, models, category, dedicated) {
184
- return models.filter((m) => effectiveCategory(m) === category).filter((m) => !dedicatedPages.has(m.id) && !dedicated.has(m.id)).map((m) => ({
185
- id: `model-${m.id}`,
186
- label: m.dashboard?.label ?? m.name,
187
- icon: m.icon,
188
- url: `${baseRoute}/models/${m.id}`,
189
- ...m.dashboard?.roles && m.dashboard.roles.length > 0 ? { roles: m.dashboard.roles } : {}
190
- }));
191
- }
192
- export function buildSidebarConfig(baseRoute, discoveredModels, toggles = {}) {
193
- const enabled = {
194
- library: toggles.library ?? !0,
195
- content: toggles.content ?? !0,
196
- commerce: toggles.commerce ?? !0,
197
- marketing: toggles.marketing ?? !0,
198
- analytics: toggles.analytics ?? !0,
199
- management: toggles.management ?? !0,
200
- utilities: toggles.utilities ?? !0
201
- }, dataRow = {
202
- dashboard: toggles.data?.dashboard ?? !0,
203
- activity: toggles.data?.activity ?? !0,
204
- users: toggles.data?.users ?? !0,
205
- teams: toggles.data?.teams ?? !0,
206
- subscribers: toggles.data?.subscribers ?? !0,
207
- allModels: toggles.data?.allModels ?? !0
208
- }, sections = [], homeItems = [
209
- { id: "home", label: "Dashboard", icon: "house.fill", url: `${baseRoute}/` },
210
- { id: "dependencies", label: "Dependencies", icon: "shippingbox.fill", url: `${baseRoute}/dependencies` },
211
- { id: "health", label: "Health", icon: "heart.text.square.fill", url: `${baseRoute}/health` }
212
- ];
213
- if (toggles.ci)
214
- homeItems.push({ id: "ci", label: "CI", icon: "checkmark.seal.fill", url: `${baseRoute}/ci` });
215
- sections.push({
216
- id: "home",
217
- title: "Home",
218
- items: homeItems
219
- });
220
- if (enabled.library)
221
- sections.push({
222
- id: "library",
223
- title: "Library",
224
- items: [
225
- { id: "functions", label: "Functions", icon: "function", url: `${baseRoute}/functions` },
226
- { id: "packages", label: "Packages", icon: "shippingbox.fill", url: `${baseRoute}/packages` }
227
- ]
228
- });
229
- if (enabled.content)
230
- sections.push({
231
- id: "content",
232
- title: "Content",
233
- items: [
234
- { id: "content-dashboard", label: "Dashboard", icon: "gauge.with.dots.needle.33percent", url: `${baseRoute}/content/dashboard` },
235
- { id: "files", label: "Files", icon: "folder.fill", url: `${baseRoute}/content/files` },
236
- { id: "pages", label: "Pages", icon: "doc.fill", url: `${baseRoute}/content/pages` },
237
- { id: "posts", label: "Posts", icon: "text.bubble.fill", url: `${baseRoute}/content/posts` },
238
- { id: "categories", label: "Categories", icon: "tag.fill", url: `${baseRoute}/content/categories` },
239
- { id: "tags", label: "Tags", icon: "tag", url: `${baseRoute}/content/tags` },
240
- { id: "comments", label: "Comments", icon: "bubble.left.fill", url: `${baseRoute}/content/comments` },
241
- { id: "authors", label: "Authors", icon: "person.text.rectangle.fill", url: `${baseRoute}/content/authors` },
242
- { id: "seo", label: "SEO", icon: "magnifyingglass", url: `${baseRoute}/content/seo` },
243
- ...categoryRows(baseRoute, discoveredModels, "content", new Set([
244
- "page",
245
- "post",
246
- "category",
247
- "tag",
248
- "comment",
249
- "author"
250
- ]))
251
- ]
252
- });
253
- sections.push({
254
- id: "app",
255
- title: "App",
256
- items: [
257
- { id: "deployments", label: "Deployments", icon: "rocket.fill", url: `${baseRoute}/deployments` },
258
- { id: "requests", label: "Requests", icon: "arrow.left.arrow.right", url: `${baseRoute}/requests` },
259
- { id: "realtime", label: "Realtime", icon: "link", url: `${baseRoute}/realtime` },
260
- { id: "actions", label: "Actions", icon: "bolt.fill", url: `${baseRoute}/actions` },
261
- { id: "commands", label: "Commands", icon: "terminal.fill", url: `${baseRoute}/commands` },
262
- { id: "queue", label: "Queue", icon: "list.bullet.rectangle.fill", url: `${baseRoute}/queue` },
263
- { id: "jobs", label: "Jobs", icon: "briefcase.fill", url: `${baseRoute}/jobs` },
264
- { id: "inbox", label: "Inbox", icon: "tray.full.fill", url: `${baseRoute}/inbox` },
265
- { id: "queries", label: "Queries", icon: "magnifyingglass.circle.fill", url: `${baseRoute}/queries` },
266
- { id: "notifications", label: "Notifications", icon: "bell.fill", url: `${baseRoute}/notifications/dashboard` },
267
- ...categoryRows(baseRoute, discoveredModels, "system", new Set)
268
- ]
269
- });
270
- const dataItems = [];
271
- if (dataRow.dashboard)
272
- dataItems.push({ id: "data-dashboard", label: "Dashboard", icon: "gauge.with.dots.needle.33percent", url: `${baseRoute}/data/dashboard` });
273
- if (dataRow.activity)
274
- dataItems.push({ id: "activity", label: "Activity", icon: "waveform.path.ecg", url: `${baseRoute}/data/activity` });
275
- if (dataRow.users)
276
- dataItems.push({ id: "users", label: "Users", icon: "person.crop.circle.fill", url: `${baseRoute}/data/users` });
277
- if (dataRow.teams)
278
- dataItems.push({ id: "teams", label: "Teams", icon: "person.3.fill", url: `${baseRoute}/data/teams` });
279
- if (dataRow.subscribers)
280
- dataItems.push({ id: "subscribers", label: "Subscribers", icon: "envelope.fill", url: `${baseRoute}/data/subscribers` });
281
- if (dataRow.allModels)
282
- dataItems.push({ id: "data-models", label: "All Models", icon: "square.grid.2x2.fill", url: `${baseRoute}/models` });
283
- const dynamicRows = discoveredModels.filter((m) => {
284
- const eff = effectiveCategory(m);
285
- return eff === "userland" || eff === "data";
286
- }).filter((m) => !dedicatedPages.has(m.id)).map((model) => ({
287
- id: `model-${model.id}`,
288
- label: model.dashboard?.label ?? model.name,
289
- icon: model.icon,
290
- url: `${baseRoute}/models/${model.id}`,
291
- ...model.dashboard?.roles && model.dashboard.roles.length > 0 ? { roles: model.dashboard.roles } : {}
292
- }));
293
- sections.push({
294
- id: "data",
295
- title: "Data",
296
- items: [...dataItems, ...dynamicRows]
297
- });
298
- if (enabled.commerce)
299
- sections.push({
300
- id: "commerce",
301
- title: "Commerce",
302
- items: [
303
- { id: "commerce-dashboard", label: "Dashboard", icon: "gauge.with.dots.needle.33percent", url: `${baseRoute}/commerce/dashboard` },
304
- { id: "customers", label: "Customers", icon: "person.crop.circle.fill", url: `${baseRoute}/commerce/customers` },
305
- { id: "orders", label: "Orders", icon: "list.clipboard.fill", url: `${baseRoute}/commerce/orders` },
306
- { id: "products", label: "Products", icon: "cube.box.fill", url: `${baseRoute}/commerce/products` },
307
- { id: "coupons", label: "Coupons", icon: "ticket.fill", url: `${baseRoute}/commerce/coupons` },
308
- { id: "gift-cards", label: "Gift Cards", icon: "giftcard.fill", url: `${baseRoute}/commerce/gift-cards` },
309
- { id: "payments", label: "Payments", icon: "creditcard.fill", url: `${baseRoute}/commerce/payments` },
310
- { id: "delivery", label: "Delivery", icon: "truck.box.fill", url: `${baseRoute}/commerce/delivery` },
311
- { id: "taxes", label: "Taxes", icon: "percent", url: `${baseRoute}/commerce/taxes` },
312
- ...categoryRows(baseRoute, discoveredModels, "commerce", new Set([
313
- "customer",
314
- "order",
315
- "product",
316
- "coupon",
317
- "gift-card",
318
- "payment",
319
- "review",
320
- "category"
321
- ]))
322
- ]
323
- });
324
- if (enabled.marketing)
325
- sections.push({
326
- id: "marketing",
327
- title: "Marketing",
328
- items: [
329
- { id: "lists", label: "Lists", icon: "list.bullet", url: `${baseRoute}/marketing/lists` },
330
- { id: "social-posts", label: "Social Posts", icon: "clock.fill", url: `${baseRoute}/marketing/social-posts` },
331
- { id: "campaigns", label: "Campaigns", icon: "megaphone.fill", url: `${baseRoute}/marketing/campaigns` },
332
- { id: "marketing-reviews", label: "Reviews", icon: "star.fill", url: `${baseRoute}/marketing/reviews` },
333
- ...categoryRows(baseRoute, discoveredModels, "marketing", new Set(["campaign"]))
334
- ]
335
- });
336
- if (enabled.analytics)
337
- sections.push({
338
- id: "analytics",
339
- title: "Analytics",
340
- items: [
341
- { id: "analytics-web", label: "Web", icon: "globe", url: `${baseRoute}/analytics/web` },
342
- { id: "analytics-blog", label: "Blog", icon: "doc.text.fill", url: `${baseRoute}/analytics/blog` },
343
- { id: "analytics-commerce", label: "Commerce", icon: "cart.fill", url: `${baseRoute}/analytics/commerce/web` },
344
- { id: "analytics-marketing", label: "Marketing", icon: "megaphone.fill", url: `${baseRoute}/analytics/marketing` }
345
- ]
346
- });
347
- if (enabled.management)
348
- sections.push({
349
- id: "management",
350
- title: "Management",
351
- items: [
352
- { id: "cloud", label: "Cloud", icon: "cloud.fill", url: `${baseRoute}/cloud` },
353
- { id: "servers", label: "Servers", icon: "server.rack", url: `${baseRoute}/servers` },
354
- { id: "serverless", label: "Serverless", icon: "bolt.horizontal.circle.fill", url: `${baseRoute}/serverless` },
355
- { id: "dns", label: "DNS", icon: "network", url: `${baseRoute}/dns` },
356
- { id: "mailboxes", label: "Mailboxes", icon: "tray.full.fill", url: `${baseRoute}/mailboxes` },
357
- { id: "logs", label: "Logs", icon: "list.bullet.rectangle.portrait.fill", url: `${baseRoute}/logs` },
358
- { id: "kanban", label: "Kanban", icon: "rectangle.stack.fill", url: `${baseRoute}/kanban`, roles: ["admin", "dev"] }
359
- ]
360
- });
361
- if (enabled.utilities)
362
- sections.push({
363
- id: "utilities",
364
- title: "Utilities",
365
- items: [
366
- { id: "buddy", label: "AI Buddy", icon: "bubble.left.and.bubble.right.fill", url: `${baseRoute}/buddy` },
367
- { id: "environment", label: "Environment", icon: "key.fill", url: `${baseRoute}/environment` },
368
- { id: "access-tokens", label: "Access Tokens", icon: "key.horizontal.fill", url: `${baseRoute}/access-tokens` },
369
- { id: "settings", label: "Settings", icon: "gear", url: `${baseRoute}/settings/billing` }
370
- ]
371
- });
372
- return {
373
- sections,
374
- minWidth: 200,
375
- maxWidth: 280
376
- };
377
- }
378
- export function buildDashboardUrl(port) {
379
- return `http://localhost:${port}/?native-sidebar=1`;
380
- }
1
+ import{Glob}from"bun";import{existsSync}from"node:fs";import path from"node:path";import{pathToFileURL}from"node:url";export const iconMap={user:"person.fill",team:"person.2.fill",subscriber:"envelope.open.fill",subscriberemail:"envelope.fill",post:"doc.text.fill",page:"doc.fill",product:"cube.box.fill",productvariant:"cube.fill",productunit:"scalemass.fill",order:"list.clipboard.fill",orderitem:"list.bullet.clipboard.fill",customer:"person.crop.circle.fill",payment:"creditcard.fill",paymentmethod:"creditcard.and.123",paymentproduct:"creditcard.fill",paymenttransaction:"creditcard.fill",category:"tag.fill",tag:"tag",comment:"bubble.left.fill",author:"person.text.rectangle.fill",notification:"bell.fill",job:"briefcase.fill",log:"list.bullet.rectangle.portrait.fill",campaign:"megaphone.fill",review:"star.fill",coupon:"ticket.fill",giftcard:"giftcard.fill",cart:"cart.fill",cartitem:"cart.badge.plus",taxrate:"percent",transaction:"arrow.left.arrow.right.circle.fill",subscription:"repeat.circle.fill",emaillist:"envelope.badge.person.crop",socialpost:"bubble.left.and.bubble.right.fill",manufacturer:"building.2.fill",shippingmethod:"shippingbox.fill",shippingzone:"map.fill",shippingrate:"dollarsign.circle.fill",deliveryroute:"map.fill",driver:"car.fill",digitaldelivery:"arrow.down.doc.fill",licensekey:"key.fill",loyaltypoint:"star.circle.fill",loyaltyreward:"gift.fill",printdevice:"printer.fill",receipt:"doc.text.fill",waitlistproduct:"clock.fill",waitlistrestaurant:"clock.badge.checkmark.fill",websocket:"antenna.radiowaves.left.and.right",default:"tablecells.fill"},excludeModels=new Set(["activity","request","error","failedjob"]),dedicatedPages=new Set(["user","team","subscriber","post","page","product","order","customer","payment","coupon","category","tag","comment","author","notification","job","campaign","review","gift-card"]);const ROOT_MODEL_CATEGORY={user:"data",team:"data",subscriber:"data",activity:"data",campaign:"marketing",emaillist:"marketing",socialpost:"marketing",subscriberemail:"marketing",comment:"content",tag:"content",paymentmethod:"commerce",paymentproduct:"commerce",paymenttransaction:"commerce",subscription:"commerce",deployment:"system",error:"system",failedjob:"system",job:"system",log:"system",notification:"system",release:"system",request:"system"};export function modelNameToId(name){return name.replace(/([A-Z])/g,"-$1").toLowerCase().replace(/^-/,"")}export function getModelIcon(name){return iconMap[name.toLowerCase()]||iconMap.default||"database"}function categorizeModel(relativePath,modelId,defaultCategory){if(defaultCategory)return defaultCategory;const firstSeg=relativePath.includes("/")?(relativePath.split("/")[0]??"").toLowerCase():"";if(firstSeg==="commerce")return"commerce";if(firstSeg==="content")return"content";if(firstSeg==="realtime")return"system";return ROOT_MODEL_CATEGORY[modelId.replace(/-/g,"")]??"data"}async function readModelDashboardConfig(absolutePath){try{const mod=await import(pathToFileURL(absolutePath).href);return(mod.default??mod).dashboard}catch(error){throw Error(`Could not discover dashboard model ${absolutePath}: ${error instanceof Error?error.message:String(error)}`)}}export async function scanModelsDir(dir,seenNames,models,defaultCategory){if(!existsSync(dir))return;const glob=new Glob("**/*.ts");for await(const file of glob.scan({cwd:dir})){if(file.includes("README")||file.includes(".d.ts"))continue;const name=file.replace(/\.ts$/,"").split("/").pop()||"",nameLower=name.toLowerCase();if(name&&!seenNames.has(nameLower)&&!excludeModels.has(nameLower)){seenNames.add(nameLower);const id=modelNameToId(name),absolutePath=path.resolve(dir,file),dashboard=await readModelDashboardConfig(absolutePath);models.push({name,icon:dashboard?.icon??getModelIcon(name),id,category:categorizeModel(file,id,defaultCategory),dashboard})}}}export async function discoverModels(userModelsPath,defaultModelsPath){const models=[],seenNames=new Set;await scanModelsDir(userModelsPath,seenNames,models,"userland");await scanModelsDir(defaultModelsPath,seenNames,models);return models.sort((a,b)=>a.name.localeCompare(b.name))}export function buildManifest(models){return models.map((m)=>{const row={id:m.id,name:m.name,icon:m.icon,hasDedicatedPage:dedicatedPages.has(m.id),category:m.category??"data"};if(m.dashboard)row.dashboard=m.dashboard;return row})}export async function isPortAvailable(port){try{Bun.serve({port,fetch:()=>new Response}).stop(!0);return!0}catch{return!1}}export async function findAvailablePort(preferred,maxAttempts=20){for(let i=0;i<maxAttempts;i++){const port=preferred+i;if(await isPortAvailable(port))return port}return preferred}export async function waitForServer(port,maxWait=500){const start=Date.now();while(Date.now()-start<maxWait){try{const res=await fetch(`http://localhost:${port}/`,{method:"HEAD"});if(res.ok||res.status===404)return!0}catch{}await new Promise((resolve)=>setTimeout(resolve,25))}return!1}function effectiveCategory(m){if(m.dashboard?.enabled===!1)return;if(m.dashboard?.section)return m.dashboard.section;return m.category??"data"}function categoryRows(baseRoute,models,category,dedicated){return models.filter((m)=>effectiveCategory(m)===category).filter((m)=>!dedicatedPages.has(m.id)&&!dedicated.has(m.id)).map((m)=>({id:`model-${m.id}`,label:m.dashboard?.label??m.name,icon:m.icon,url:`${baseRoute}/models/${m.id}`,...m.dashboard?.roles&&m.dashboard.roles.length>0?{roles:m.dashboard.roles}:{}}))}export function buildSidebarConfig(baseRoute,discoveredModels,toggles={}){const enabled={library:toggles.library??!0,content:toggles.content??!0,commerce:toggles.commerce??!0,marketing:toggles.marketing??!0,analytics:toggles.analytics??!0,management:toggles.management??!0,utilities:toggles.utilities??!0},dataRow={dashboard:toggles.data?.dashboard??!0,activity:toggles.data?.activity??!0,users:toggles.data?.users??!0,teams:toggles.data?.teams??!0,subscribers:toggles.data?.subscribers??!0,allModels:toggles.data?.allModels??!0},sections=[],homeItems=[{id:"home",label:"Dashboard",icon:"house.fill",url:`${baseRoute}/`},{id:"dependencies",label:"Dependencies",icon:"shippingbox.fill",url:`${baseRoute}/dependencies`},{id:"health",label:"Health",icon:"heart.text.square.fill",url:`${baseRoute}/health`}];if(toggles.ci)homeItems.push({id:"ci",label:"CI",icon:"checkmark.seal.fill",url:`${baseRoute}/ci`});sections.push({id:"home",title:"Home",items:homeItems});if(enabled.library)sections.push({id:"library",title:"Library",items:[{id:"functions",label:"Functions",icon:"function",url:`${baseRoute}/functions`},{id:"packages",label:"Packages",icon:"shippingbox.fill",url:`${baseRoute}/packages`}]});if(enabled.content)sections.push({id:"content",title:"Content",items:[{id:"content-dashboard",label:"Dashboard",icon:"gauge.with.dots.needle.33percent",url:`${baseRoute}/content/dashboard`},{id:"files",label:"Files",icon:"folder.fill",url:`${baseRoute}/content/files`},{id:"pages",label:"Pages",icon:"doc.fill",url:`${baseRoute}/content/pages`},{id:"posts",label:"Posts",icon:"text.bubble.fill",url:`${baseRoute}/content/posts`},{id:"categories",label:"Categories",icon:"tag.fill",url:`${baseRoute}/content/categories`},{id:"tags",label:"Tags",icon:"tag",url:`${baseRoute}/content/tags`},{id:"comments",label:"Comments",icon:"bubble.left.fill",url:`${baseRoute}/content/comments`},{id:"authors",label:"Authors",icon:"person.text.rectangle.fill",url:`${baseRoute}/content/authors`},{id:"seo",label:"SEO",icon:"magnifyingglass",url:`${baseRoute}/content/seo`},...categoryRows(baseRoute,discoveredModels,"content",new Set(["page","post","category","tag","comment","author"]))]});sections.push({id:"app",title:"App",items:[{id:"deployments",label:"Deployments",icon:"rocket.fill",url:`${baseRoute}/deployments`},{id:"requests",label:"Requests",icon:"arrow.left.arrow.right",url:`${baseRoute}/requests`},{id:"realtime",label:"Realtime",icon:"link",url:`${baseRoute}/realtime`},{id:"actions",label:"Actions",icon:"bolt.fill",url:`${baseRoute}/actions`},{id:"commands",label:"Commands",icon:"terminal.fill",url:`${baseRoute}/commands`},{id:"queue",label:"Queue",icon:"list.bullet.rectangle.fill",url:`${baseRoute}/queue`},{id:"jobs",label:"Jobs",icon:"briefcase.fill",url:`${baseRoute}/jobs`},{id:"inbox",label:"Inbox",icon:"tray.full.fill",url:`${baseRoute}/inbox`},{id:"queries",label:"Queries",icon:"magnifyingglass.circle.fill",url:`${baseRoute}/queries`},{id:"notifications",label:"Notifications",icon:"bell.fill",url:`${baseRoute}/notifications/dashboard`},...categoryRows(baseRoute,discoveredModels,"system",new Set)]});const dataItems=[];if(dataRow.dashboard)dataItems.push({id:"data-dashboard",label:"Dashboard",icon:"gauge.with.dots.needle.33percent",url:`${baseRoute}/data/dashboard`});if(dataRow.activity)dataItems.push({id:"activity",label:"Activity",icon:"waveform.path.ecg",url:`${baseRoute}/data/activity`});if(dataRow.users)dataItems.push({id:"users",label:"Users",icon:"person.crop.circle.fill",url:`${baseRoute}/data/users`});if(dataRow.teams)dataItems.push({id:"teams",label:"Teams",icon:"person.3.fill",url:`${baseRoute}/data/teams`});if(dataRow.subscribers)dataItems.push({id:"subscribers",label:"Subscribers",icon:"envelope.fill",url:`${baseRoute}/data/subscribers`});if(dataRow.allModels)dataItems.push({id:"data-models",label:"All Models",icon:"square.grid.2x2.fill",url:`${baseRoute}/models`});const dynamicRows=discoveredModels.filter((m)=>{const eff=effectiveCategory(m);return eff==="userland"||eff==="data"}).filter((m)=>!dedicatedPages.has(m.id)).map((model)=>({id:`model-${model.id}`,label:model.dashboard?.label??model.name,icon:model.icon,url:`${baseRoute}/models/${model.id}`,...model.dashboard?.roles&&model.dashboard.roles.length>0?{roles:model.dashboard.roles}:{}}));sections.push({id:"data",title:"Data",items:[...dataItems,...dynamicRows]});if(enabled.commerce)sections.push({id:"commerce",title:"Commerce",items:[{id:"commerce-dashboard",label:"Dashboard",icon:"gauge.with.dots.needle.33percent",url:`${baseRoute}/commerce/dashboard`},{id:"customers",label:"Customers",icon:"person.crop.circle.fill",url:`${baseRoute}/commerce/customers`},{id:"orders",label:"Orders",icon:"list.clipboard.fill",url:`${baseRoute}/commerce/orders`},{id:"products",label:"Products",icon:"cube.box.fill",url:`${baseRoute}/commerce/products`},{id:"coupons",label:"Coupons",icon:"ticket.fill",url:`${baseRoute}/commerce/coupons`},{id:"gift-cards",label:"Gift Cards",icon:"giftcard.fill",url:`${baseRoute}/commerce/gift-cards`},{id:"payments",label:"Payments",icon:"creditcard.fill",url:`${baseRoute}/commerce/payments`},{id:"delivery",label:"Delivery",icon:"truck.box.fill",url:`${baseRoute}/commerce/delivery`},{id:"taxes",label:"Taxes",icon:"percent",url:`${baseRoute}/commerce/taxes`},...categoryRows(baseRoute,discoveredModels,"commerce",new Set(["customer","order","product","coupon","gift-card","payment","review","category"]))]});if(enabled.marketing)sections.push({id:"marketing",title:"Marketing",items:[{id:"lists",label:"Lists",icon:"list.bullet",url:`${baseRoute}/marketing/lists`},{id:"social-posts",label:"Social Posts",icon:"clock.fill",url:`${baseRoute}/marketing/social-posts`},{id:"campaigns",label:"Campaigns",icon:"megaphone.fill",url:`${baseRoute}/marketing/campaigns`},{id:"marketing-reviews",label:"Reviews",icon:"star.fill",url:`${baseRoute}/marketing/reviews`},...categoryRows(baseRoute,discoveredModels,"marketing",new Set(["campaign"]))]});if(enabled.analytics)sections.push({id:"analytics",title:"Analytics",items:[{id:"analytics-web",label:"Web",icon:"globe",url:`${baseRoute}/analytics/web`},{id:"analytics-blog",label:"Blog",icon:"doc.text.fill",url:`${baseRoute}/analytics/blog`},{id:"analytics-commerce",label:"Commerce",icon:"cart.fill",url:`${baseRoute}/analytics/commerce/web`},{id:"analytics-marketing",label:"Marketing",icon:"megaphone.fill",url:`${baseRoute}/analytics/marketing`}]});if(enabled.management)sections.push({id:"management",title:"Management",items:[{id:"cloud",label:"Cloud",icon:"cloud.fill",url:`${baseRoute}/cloud`},{id:"servers",label:"Servers",icon:"server.rack",url:`${baseRoute}/servers`},{id:"serverless",label:"Serverless",icon:"bolt.horizontal.circle.fill",url:`${baseRoute}/serverless`},{id:"dns",label:"DNS",icon:"network",url:`${baseRoute}/dns`},{id:"mailboxes",label:"Mailboxes",icon:"tray.full.fill",url:`${baseRoute}/mailboxes`},{id:"logs",label:"Logs",icon:"list.bullet.rectangle.portrait.fill",url:`${baseRoute}/logs`},{id:"kanban",label:"Kanban",icon:"rectangle.stack.fill",url:`${baseRoute}/kanban`,roles:["admin","dev"]}]});if(enabled.utilities)sections.push({id:"utilities",title:"Utilities",items:[{id:"buddy",label:"AI Buddy",icon:"bubble.left.and.bubble.right.fill",url:`${baseRoute}/buddy`},{id:"environment",label:"Environment",icon:"key.fill",url:`${baseRoute}/environment`},{id:"access-tokens",label:"Access Tokens",icon:"key.horizontal.fill",url:`${baseRoute}/access-tokens`},{id:"settings",label:"Settings",icon:"gear",url:`${baseRoute}/settings/billing`}]});return{sections,minWidth:200,maxWidth:280}}export function buildDashboardUrl(port){return`http://localhost:${port}/?native-sidebar=1`}