dineway 0.1.3
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/LICENSE +9 -0
- package/README.md +89 -0
- package/dist/adapters-BlzWJG82.d.mts +106 -0
- package/dist/apply-CAPvMfoU.mjs +1339 -0
- package/dist/astro/index.d.mts +50 -0
- package/dist/astro/index.mjs +1326 -0
- package/dist/astro/middleware/auth.d.mts +30 -0
- package/dist/astro/middleware/auth.mjs +708 -0
- package/dist/astro/middleware/redirect.d.mts +21 -0
- package/dist/astro/middleware/redirect.mjs +62 -0
- package/dist/astro/middleware/request-context.d.mts +17 -0
- package/dist/astro/middleware/request-context.mjs +1371 -0
- package/dist/astro/middleware/setup.d.mts +19 -0
- package/dist/astro/middleware/setup.mjs +46 -0
- package/dist/astro/middleware.d.mts +12 -0
- package/dist/astro/middleware.mjs +1716 -0
- package/dist/astro/types.d.mts +269 -0
- package/dist/astro/types.mjs +1 -0
- package/dist/base64-F8-DUraK.mjs +58 -0
- package/dist/byline-DeWCMU_i.mjs +234 -0
- package/dist/bylines-DyqBV9EQ.mjs +137 -0
- package/dist/chunk-ClPoSABd.mjs +21 -0
- package/dist/cli/index.d.mts +1 -0
- package/dist/cli/index.mjs +3987 -0
- package/dist/client/external-auth-headers.d.mts +38 -0
- package/dist/client/external-auth-headers.mjs +101 -0
- package/dist/client/index.d.mts +397 -0
- package/dist/client/index.mjs +345 -0
- package/dist/config-Cq8H0SfX.mjs +46 -0
- package/dist/connection-C9pxzuag.mjs +52 -0
- package/dist/content-zSgdNmnt.mjs +836 -0
- package/dist/db/index.d.mts +4 -0
- package/dist/db/index.mjs +62 -0
- package/dist/db/libsql.d.mts +10 -0
- package/dist/db/libsql.mjs +21 -0
- package/dist/db/postgres.d.mts +10 -0
- package/dist/db/postgres.mjs +29 -0
- package/dist/db/sqlite.d.mts +10 -0
- package/dist/db/sqlite.mjs +15 -0
- package/dist/default-WYlzADZL.mjs +80 -0
- package/dist/dialect-helpers-B9uSp2GJ.mjs +89 -0
- package/dist/error-DrxtnGPg.mjs +26 -0
- package/dist/index-C-jx21qs.d.mts +4771 -0
- package/dist/index.d.mts +16 -0
- package/dist/index.mjs +30 -0
- package/dist/load-C6FCD1FU.mjs +27 -0
- package/dist/loader-qKmo0wAY.mjs +446 -0
- package/dist/manifest-schema-CTSEyIJ3.mjs +186 -0
- package/dist/media/index.d.mts +25 -0
- package/dist/media/index.mjs +54 -0
- package/dist/media/local-runtime.d.mts +38 -0
- package/dist/media/local-runtime.mjs +132 -0
- package/dist/media-DMTr80Gv.mjs +199 -0
- package/dist/mode-BlyYtIFO.mjs +22 -0
- package/dist/page/index.d.mts +148 -0
- package/dist/page/index.mjs +419 -0
- package/dist/placeholder-B3knXwNc.mjs +267 -0
- package/dist/placeholder-bOx1xCTY.d.mts +283 -0
- package/dist/plugin-utils.d.mts +57 -0
- package/dist/plugin-utils.mjs +77 -0
- package/dist/plugins/adapt-sandbox-entry.d.mts +21 -0
- package/dist/plugins/adapt-sandbox-entry.mjs +112 -0
- package/dist/query-BiaPl_g2.mjs +459 -0
- package/dist/redirect-JPqLAbxa.mjs +328 -0
- package/dist/registry-DSd1GWB8.mjs +851 -0
- package/dist/request-context.d.mts +49 -0
- package/dist/request-context.mjs +42 -0
- package/dist/runner-B5l1JfOj.d.mts +26 -0
- package/dist/runner-BGUGywgG.mjs +1529 -0
- package/dist/runtime.d.mts +25 -0
- package/dist/runtime.mjs +41 -0
- package/dist/search-BNruJHDL.mjs +11054 -0
- package/dist/seed/index.d.mts +3 -0
- package/dist/seed/index.mjs +15 -0
- package/dist/seo/index.d.mts +69 -0
- package/dist/seo/index.mjs +69 -0
- package/dist/storage/local.d.mts +38 -0
- package/dist/storage/local.mjs +165 -0
- package/dist/storage/s3.d.mts +31 -0
- package/dist/storage/s3.mjs +174 -0
- package/dist/tokens-4vgYuXsZ.mjs +170 -0
- package/dist/transport-C5FYnid7.mjs +417 -0
- package/dist/transport-gIL-e43D.d.mts +41 -0
- package/dist/types-BawVha09.mjs +30 -0
- package/dist/types-BgQeVaPj.d.mts +192 -0
- package/dist/types-CLLdsG3g.d.mts +103 -0
- package/dist/types-D38djUXv.d.mts +1196 -0
- package/dist/types-DShnjzb6.mjs +15 -0
- package/dist/types-DkvMXalq.d.mts +425 -0
- package/dist/types-DuNbGKjF.mjs +74 -0
- package/dist/types-ju-_ORz7.d.mts +182 -0
- package/dist/validate-CXnRKfJK.mjs +327 -0
- package/dist/validate-CqRJb_xU.mjs +96 -0
- package/dist/validate-DVKJJ-M_.d.mts +377 -0
- package/locals.d.ts +47 -0
- package/package.json +313 -0
|
@@ -0,0 +1,1326 @@
|
|
|
1
|
+
import { t as defaultSeed } from "../default-WYlzADZL.mjs";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
4
|
+
import { dirname, resolve } from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
|
|
7
|
+
//#region src/astro/storage/adapters.ts
|
|
8
|
+
/**
|
|
9
|
+
* S3-compatible storage adapter
|
|
10
|
+
*
|
|
11
|
+
* Works with AWS S3, MinIO, and other S3-compatible object stores.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* storage: s3({
|
|
16
|
+
* endpoint: process.env.S3_ENDPOINT!,
|
|
17
|
+
* bucket: "media",
|
|
18
|
+
* accessKeyId: process.env.S3_ACCESS_KEY_ID!,
|
|
19
|
+
* secretAccessKey: process.env.S3_SECRET_ACCESS_KEY!,
|
|
20
|
+
* publicUrl: "https://cdn.example.com", // optional CDN
|
|
21
|
+
* })
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
function s3(config) {
|
|
25
|
+
return {
|
|
26
|
+
entrypoint: "dineway/storage/s3",
|
|
27
|
+
config
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Local filesystem storage adapter
|
|
32
|
+
*
|
|
33
|
+
* For development and testing. Stores files in a local directory.
|
|
34
|
+
* Does NOT support signed upload URLs.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* storage: local({
|
|
39
|
+
* directory: "./uploads",
|
|
40
|
+
* baseUrl: "/_dineway/api/media/file",
|
|
41
|
+
* })
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
function local(config) {
|
|
45
|
+
return {
|
|
46
|
+
entrypoint: "dineway/storage/local",
|
|
47
|
+
config
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/astro/integration/routes.ts
|
|
53
|
+
/**
|
|
54
|
+
* Route Injection
|
|
55
|
+
*
|
|
56
|
+
* Defines and injects all Dineway routes into the Astro application.
|
|
57
|
+
*/
|
|
58
|
+
/**
|
|
59
|
+
* Resolve path to a route file in the package
|
|
60
|
+
* Uses Node.js APIs - only call at build time
|
|
61
|
+
*/
|
|
62
|
+
function resolveRoute(route) {
|
|
63
|
+
const require = createRequire(import.meta.url);
|
|
64
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
65
|
+
try {
|
|
66
|
+
return require.resolve(`dineway/routes/${route}`);
|
|
67
|
+
} catch {
|
|
68
|
+
return resolve(__dirname, "../routes", route);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Injects all core Dineway routes.
|
|
73
|
+
*/
|
|
74
|
+
function injectCoreRoutes(injectRoute) {
|
|
75
|
+
injectRoute({
|
|
76
|
+
pattern: "/_dineway/admin/[...path]",
|
|
77
|
+
entrypoint: resolveRoute("admin.astro")
|
|
78
|
+
});
|
|
79
|
+
injectRoute({
|
|
80
|
+
pattern: "/_dineway/api/manifest",
|
|
81
|
+
entrypoint: resolveRoute("api/manifest.ts")
|
|
82
|
+
});
|
|
83
|
+
injectRoute({
|
|
84
|
+
pattern: "/_dineway/api/dashboard",
|
|
85
|
+
entrypoint: resolveRoute("api/dashboard.ts")
|
|
86
|
+
});
|
|
87
|
+
injectRoute({
|
|
88
|
+
pattern: "/_dineway/api/content/[collection]",
|
|
89
|
+
entrypoint: resolveRoute("api/content/[collection]/index.ts")
|
|
90
|
+
});
|
|
91
|
+
injectRoute({
|
|
92
|
+
pattern: "/_dineway/api/content/[collection]/[id]",
|
|
93
|
+
entrypoint: resolveRoute("api/content/[collection]/[id].ts")
|
|
94
|
+
});
|
|
95
|
+
injectRoute({
|
|
96
|
+
pattern: "/_dineway/api/content/[collection]/[id]/revisions",
|
|
97
|
+
entrypoint: resolveRoute("api/content/[collection]/[id]/revisions.ts")
|
|
98
|
+
});
|
|
99
|
+
injectRoute({
|
|
100
|
+
pattern: "/_dineway/api/content/[collection]/[id]/preview-url",
|
|
101
|
+
entrypoint: resolveRoute("api/content/[collection]/[id]/preview-url.ts")
|
|
102
|
+
});
|
|
103
|
+
injectRoute({
|
|
104
|
+
pattern: "/_dineway/api/content/[collection]/trash",
|
|
105
|
+
entrypoint: resolveRoute("api/content/[collection]/trash.ts")
|
|
106
|
+
});
|
|
107
|
+
injectRoute({
|
|
108
|
+
pattern: "/_dineway/api/content/[collection]/[id]/restore",
|
|
109
|
+
entrypoint: resolveRoute("api/content/[collection]/[id]/restore.ts")
|
|
110
|
+
});
|
|
111
|
+
injectRoute({
|
|
112
|
+
pattern: "/_dineway/api/content/[collection]/[id]/permanent",
|
|
113
|
+
entrypoint: resolveRoute("api/content/[collection]/[id]/permanent.ts")
|
|
114
|
+
});
|
|
115
|
+
injectRoute({
|
|
116
|
+
pattern: "/_dineway/api/content/[collection]/[id]/duplicate",
|
|
117
|
+
entrypoint: resolveRoute("api/content/[collection]/[id]/duplicate.ts")
|
|
118
|
+
});
|
|
119
|
+
injectRoute({
|
|
120
|
+
pattern: "/_dineway/api/content/[collection]/[id]/publish",
|
|
121
|
+
entrypoint: resolveRoute("api/content/[collection]/[id]/publish.ts")
|
|
122
|
+
});
|
|
123
|
+
injectRoute({
|
|
124
|
+
pattern: "/_dineway/api/content/[collection]/[id]/unpublish",
|
|
125
|
+
entrypoint: resolveRoute("api/content/[collection]/[id]/unpublish.ts")
|
|
126
|
+
});
|
|
127
|
+
injectRoute({
|
|
128
|
+
pattern: "/_dineway/api/content/[collection]/[id]/discard-draft",
|
|
129
|
+
entrypoint: resolveRoute("api/content/[collection]/[id]/discard-draft.ts")
|
|
130
|
+
});
|
|
131
|
+
injectRoute({
|
|
132
|
+
pattern: "/_dineway/api/content/[collection]/[id]/compare",
|
|
133
|
+
entrypoint: resolveRoute("api/content/[collection]/[id]/compare.ts")
|
|
134
|
+
});
|
|
135
|
+
injectRoute({
|
|
136
|
+
pattern: "/_dineway/api/content/[collection]/[id]/translations",
|
|
137
|
+
entrypoint: resolveRoute("api/content/[collection]/[id]/translations.ts")
|
|
138
|
+
});
|
|
139
|
+
injectRoute({
|
|
140
|
+
pattern: "/_dineway/api/content/[collection]/[id]/schedule",
|
|
141
|
+
entrypoint: resolveRoute("api/content/[collection]/[id]/schedule.ts")
|
|
142
|
+
});
|
|
143
|
+
injectRoute({
|
|
144
|
+
pattern: "/_dineway/api/revisions/[revisionId]",
|
|
145
|
+
entrypoint: resolveRoute("api/revisions/[revisionId]/index.ts")
|
|
146
|
+
});
|
|
147
|
+
injectRoute({
|
|
148
|
+
pattern: "/_dineway/api/revisions/[revisionId]/restore",
|
|
149
|
+
entrypoint: resolveRoute("api/revisions/[revisionId]/restore.ts")
|
|
150
|
+
});
|
|
151
|
+
injectRoute({
|
|
152
|
+
pattern: "/_dineway/api/media",
|
|
153
|
+
entrypoint: resolveRoute("api/media.ts")
|
|
154
|
+
});
|
|
155
|
+
injectRoute({
|
|
156
|
+
pattern: "/_dineway/api/media/upload-url",
|
|
157
|
+
entrypoint: resolveRoute("api/media/upload-url.ts")
|
|
158
|
+
});
|
|
159
|
+
injectRoute({
|
|
160
|
+
pattern: "/_dineway/api/media/file/[...key]",
|
|
161
|
+
entrypoint: resolveRoute("api/media/file/[...key].ts")
|
|
162
|
+
});
|
|
163
|
+
injectRoute({
|
|
164
|
+
pattern: "/_dineway/api/media/[id]",
|
|
165
|
+
entrypoint: resolveRoute("api/media/[id].ts")
|
|
166
|
+
});
|
|
167
|
+
injectRoute({
|
|
168
|
+
pattern: "/_dineway/api/media/[id]/confirm",
|
|
169
|
+
entrypoint: resolveRoute("api/media/[id]/confirm.ts")
|
|
170
|
+
});
|
|
171
|
+
injectRoute({
|
|
172
|
+
pattern: "/_dineway/api/media/providers",
|
|
173
|
+
entrypoint: resolveRoute("api/media/providers/index.ts")
|
|
174
|
+
});
|
|
175
|
+
injectRoute({
|
|
176
|
+
pattern: "/_dineway/api/media/providers/[providerId]",
|
|
177
|
+
entrypoint: resolveRoute("api/media/providers/[providerId]/index.ts")
|
|
178
|
+
});
|
|
179
|
+
injectRoute({
|
|
180
|
+
pattern: "/_dineway/api/media/providers/[providerId]/[itemId]",
|
|
181
|
+
entrypoint: resolveRoute("api/media/providers/[providerId]/[itemId].ts")
|
|
182
|
+
});
|
|
183
|
+
injectRoute({
|
|
184
|
+
pattern: "/_dineway/api/import/probe",
|
|
185
|
+
entrypoint: resolveRoute("api/import/probe.ts")
|
|
186
|
+
});
|
|
187
|
+
injectRoute({
|
|
188
|
+
pattern: "/_dineway/api/import/wordpress/analyze",
|
|
189
|
+
entrypoint: resolveRoute("api/import/wordpress/analyze.ts")
|
|
190
|
+
});
|
|
191
|
+
injectRoute({
|
|
192
|
+
pattern: "/_dineway/api/import/wordpress/prepare",
|
|
193
|
+
entrypoint: resolveRoute("api/import/wordpress/prepare.ts")
|
|
194
|
+
});
|
|
195
|
+
injectRoute({
|
|
196
|
+
pattern: "/_dineway/api/import/wordpress/execute",
|
|
197
|
+
entrypoint: resolveRoute("api/import/wordpress/execute.ts")
|
|
198
|
+
});
|
|
199
|
+
injectRoute({
|
|
200
|
+
pattern: "/_dineway/api/import/wordpress/media",
|
|
201
|
+
entrypoint: resolveRoute("api/import/wordpress/media.ts")
|
|
202
|
+
});
|
|
203
|
+
injectRoute({
|
|
204
|
+
pattern: "/_dineway/api/import/wordpress/rewrite-urls",
|
|
205
|
+
entrypoint: resolveRoute("api/import/wordpress/rewrite-urls.ts")
|
|
206
|
+
});
|
|
207
|
+
injectRoute({
|
|
208
|
+
pattern: "/_dineway/api/import/wordpress-plugin/analyze",
|
|
209
|
+
entrypoint: resolveRoute("api/import/wordpress-plugin/analyze.ts")
|
|
210
|
+
});
|
|
211
|
+
injectRoute({
|
|
212
|
+
pattern: "/_dineway/api/import/wordpress-plugin/execute",
|
|
213
|
+
entrypoint: resolveRoute("api/import/wordpress-plugin/execute.ts")
|
|
214
|
+
});
|
|
215
|
+
injectRoute({
|
|
216
|
+
pattern: "/_dineway/api/import/wordpress-plugin/callback",
|
|
217
|
+
entrypoint: resolveRoute("api/import/wordpress-plugin/callback.ts")
|
|
218
|
+
});
|
|
219
|
+
injectRoute({
|
|
220
|
+
pattern: "/_dineway/api/schema",
|
|
221
|
+
entrypoint: resolveRoute("api/schema/index.ts")
|
|
222
|
+
});
|
|
223
|
+
injectRoute({
|
|
224
|
+
pattern: "/_dineway/api/typegen",
|
|
225
|
+
entrypoint: resolveRoute("api/typegen.ts")
|
|
226
|
+
});
|
|
227
|
+
injectRoute({
|
|
228
|
+
pattern: "/_dineway/api/schema/collections",
|
|
229
|
+
entrypoint: resolveRoute("api/schema/collections/index.ts")
|
|
230
|
+
});
|
|
231
|
+
injectRoute({
|
|
232
|
+
pattern: "/_dineway/api/schema/collections/[slug]",
|
|
233
|
+
entrypoint: resolveRoute("api/schema/collections/[slug]/index.ts")
|
|
234
|
+
});
|
|
235
|
+
injectRoute({
|
|
236
|
+
pattern: "/_dineway/api/schema/collections/[slug]/fields",
|
|
237
|
+
entrypoint: resolveRoute("api/schema/collections/[slug]/fields/index.ts")
|
|
238
|
+
});
|
|
239
|
+
injectRoute({
|
|
240
|
+
pattern: "/_dineway/api/schema/collections/[slug]/fields/reorder",
|
|
241
|
+
entrypoint: resolveRoute("api/schema/collections/[slug]/fields/reorder.ts")
|
|
242
|
+
});
|
|
243
|
+
injectRoute({
|
|
244
|
+
pattern: "/_dineway/api/schema/collections/[slug]/fields/[fieldSlug]",
|
|
245
|
+
entrypoint: resolveRoute("api/schema/collections/[slug]/fields/[fieldSlug].ts")
|
|
246
|
+
});
|
|
247
|
+
injectRoute({
|
|
248
|
+
pattern: "/_dineway/api/schema/orphans",
|
|
249
|
+
entrypoint: resolveRoute("api/schema/orphans/index.ts")
|
|
250
|
+
});
|
|
251
|
+
injectRoute({
|
|
252
|
+
pattern: "/_dineway/api/schema/orphans/[slug]",
|
|
253
|
+
entrypoint: resolveRoute("api/schema/orphans/[slug].ts")
|
|
254
|
+
});
|
|
255
|
+
injectRoute({
|
|
256
|
+
pattern: "/_dineway/api/settings",
|
|
257
|
+
entrypoint: resolveRoute("api/settings.ts")
|
|
258
|
+
});
|
|
259
|
+
injectRoute({
|
|
260
|
+
pattern: "/_dineway/api/settings/email",
|
|
261
|
+
entrypoint: resolveRoute("api/settings/email.ts")
|
|
262
|
+
});
|
|
263
|
+
injectRoute({
|
|
264
|
+
pattern: "/_dineway/api/snapshot",
|
|
265
|
+
entrypoint: resolveRoute("api/snapshot.ts")
|
|
266
|
+
});
|
|
267
|
+
injectRoute({
|
|
268
|
+
pattern: "/_dineway/api/taxonomies",
|
|
269
|
+
entrypoint: resolveRoute("api/taxonomies/index.ts")
|
|
270
|
+
});
|
|
271
|
+
injectRoute({
|
|
272
|
+
pattern: "/_dineway/api/taxonomies/[name]/terms",
|
|
273
|
+
entrypoint: resolveRoute("api/taxonomies/[name]/terms/index.ts")
|
|
274
|
+
});
|
|
275
|
+
injectRoute({
|
|
276
|
+
pattern: "/_dineway/api/taxonomies/[name]/terms/[slug]",
|
|
277
|
+
entrypoint: resolveRoute("api/taxonomies/[name]/terms/[slug].ts")
|
|
278
|
+
});
|
|
279
|
+
injectRoute({
|
|
280
|
+
pattern: "/_dineway/api/content/[collection]/[id]/terms/[taxonomy]",
|
|
281
|
+
entrypoint: resolveRoute("api/content/[collection]/[id]/terms/[taxonomy].ts")
|
|
282
|
+
});
|
|
283
|
+
injectRoute({
|
|
284
|
+
pattern: "/_dineway/api/admin/plugins",
|
|
285
|
+
entrypoint: resolveRoute("api/admin/plugins/index.ts")
|
|
286
|
+
});
|
|
287
|
+
injectRoute({
|
|
288
|
+
pattern: "/_dineway/api/admin/plugins/[id]",
|
|
289
|
+
entrypoint: resolveRoute("api/admin/plugins/[id]/index.ts")
|
|
290
|
+
});
|
|
291
|
+
injectRoute({
|
|
292
|
+
pattern: "/_dineway/api/admin/plugins/[id]/enable",
|
|
293
|
+
entrypoint: resolveRoute("api/admin/plugins/[id]/enable.ts")
|
|
294
|
+
});
|
|
295
|
+
injectRoute({
|
|
296
|
+
pattern: "/_dineway/api/admin/plugins/[id]/disable",
|
|
297
|
+
entrypoint: resolveRoute("api/admin/plugins/[id]/disable.ts")
|
|
298
|
+
});
|
|
299
|
+
injectRoute({
|
|
300
|
+
pattern: "/_dineway/api/admin/plugins/marketplace",
|
|
301
|
+
entrypoint: resolveRoute("api/admin/plugins/marketplace/index.ts")
|
|
302
|
+
});
|
|
303
|
+
injectRoute({
|
|
304
|
+
pattern: "/_dineway/api/admin/plugins/marketplace/[id]",
|
|
305
|
+
entrypoint: resolveRoute("api/admin/plugins/marketplace/[id]/index.ts")
|
|
306
|
+
});
|
|
307
|
+
injectRoute({
|
|
308
|
+
pattern: "/_dineway/api/admin/plugins/marketplace/[id]/icon",
|
|
309
|
+
entrypoint: resolveRoute("api/admin/plugins/marketplace/[id]/icon.ts")
|
|
310
|
+
});
|
|
311
|
+
injectRoute({
|
|
312
|
+
pattern: "/_dineway/api/admin/plugins/marketplace/[id]/install",
|
|
313
|
+
entrypoint: resolveRoute("api/admin/plugins/marketplace/[id]/install.ts")
|
|
314
|
+
});
|
|
315
|
+
injectRoute({
|
|
316
|
+
pattern: "/_dineway/api/admin/plugins/[id]/update",
|
|
317
|
+
entrypoint: resolveRoute("api/admin/plugins/[id]/update.ts")
|
|
318
|
+
});
|
|
319
|
+
injectRoute({
|
|
320
|
+
pattern: "/_dineway/api/admin/plugins/[id]/uninstall",
|
|
321
|
+
entrypoint: resolveRoute("api/admin/plugins/[id]/uninstall.ts")
|
|
322
|
+
});
|
|
323
|
+
injectRoute({
|
|
324
|
+
pattern: "/_dineway/api/admin/plugins/updates",
|
|
325
|
+
entrypoint: resolveRoute("api/admin/plugins/updates.ts")
|
|
326
|
+
});
|
|
327
|
+
injectRoute({
|
|
328
|
+
pattern: "/_dineway/api/admin/hooks/exclusive",
|
|
329
|
+
entrypoint: resolveRoute("api/admin/hooks/exclusive/index.ts")
|
|
330
|
+
});
|
|
331
|
+
injectRoute({
|
|
332
|
+
pattern: "/_dineway/api/admin/hooks/exclusive/[hookName]",
|
|
333
|
+
entrypoint: resolveRoute("api/admin/hooks/exclusive/[hookName].ts")
|
|
334
|
+
});
|
|
335
|
+
injectRoute({
|
|
336
|
+
pattern: "/_dineway/api/admin/themes/marketplace",
|
|
337
|
+
entrypoint: resolveRoute("api/admin/themes/marketplace/index.ts")
|
|
338
|
+
});
|
|
339
|
+
injectRoute({
|
|
340
|
+
pattern: "/_dineway/api/admin/themes/marketplace/[id]",
|
|
341
|
+
entrypoint: resolveRoute("api/admin/themes/marketplace/[id]/index.ts")
|
|
342
|
+
});
|
|
343
|
+
injectRoute({
|
|
344
|
+
pattern: "/_dineway/api/admin/themes/marketplace/[id]/thumbnail",
|
|
345
|
+
entrypoint: resolveRoute("api/admin/themes/marketplace/[id]/thumbnail.ts")
|
|
346
|
+
});
|
|
347
|
+
injectRoute({
|
|
348
|
+
pattern: "/_dineway/api/themes/preview",
|
|
349
|
+
entrypoint: resolveRoute("api/themes/preview.ts")
|
|
350
|
+
});
|
|
351
|
+
injectRoute({
|
|
352
|
+
pattern: "/_dineway/api/admin/users",
|
|
353
|
+
entrypoint: resolveRoute("api/admin/users/index.ts")
|
|
354
|
+
});
|
|
355
|
+
injectRoute({
|
|
356
|
+
pattern: "/_dineway/api/admin/bylines",
|
|
357
|
+
entrypoint: resolveRoute("api/admin/bylines/index.ts")
|
|
358
|
+
});
|
|
359
|
+
injectRoute({
|
|
360
|
+
pattern: "/_dineway/api/admin/bylines/[id]",
|
|
361
|
+
entrypoint: resolveRoute("api/admin/bylines/[id]/index.ts")
|
|
362
|
+
});
|
|
363
|
+
injectRoute({
|
|
364
|
+
pattern: "/_dineway/api/admin/users/[id]",
|
|
365
|
+
entrypoint: resolveRoute("api/admin/users/[id]/index.ts")
|
|
366
|
+
});
|
|
367
|
+
injectRoute({
|
|
368
|
+
pattern: "/_dineway/api/admin/users/[id]/disable",
|
|
369
|
+
entrypoint: resolveRoute("api/admin/users/[id]/disable.ts")
|
|
370
|
+
});
|
|
371
|
+
injectRoute({
|
|
372
|
+
pattern: "/_dineway/api/admin/users/[id]/enable",
|
|
373
|
+
entrypoint: resolveRoute("api/admin/users/[id]/enable.ts")
|
|
374
|
+
});
|
|
375
|
+
injectRoute({
|
|
376
|
+
pattern: "/_dineway/api/admin/users/[id]/send-recovery",
|
|
377
|
+
entrypoint: resolveRoute("api/admin/users/[id]/send-recovery.ts")
|
|
378
|
+
});
|
|
379
|
+
injectRoute({
|
|
380
|
+
pattern: "/_dineway/api/admin/api-tokens",
|
|
381
|
+
entrypoint: resolveRoute("api/admin/api-tokens/index.ts")
|
|
382
|
+
});
|
|
383
|
+
injectRoute({
|
|
384
|
+
pattern: "/_dineway/api/admin/api-tokens/[id]",
|
|
385
|
+
entrypoint: resolveRoute("api/admin/api-tokens/[id].ts")
|
|
386
|
+
});
|
|
387
|
+
injectRoute({
|
|
388
|
+
pattern: "/_dineway/api/admin/oauth-clients",
|
|
389
|
+
entrypoint: resolveRoute("api/admin/oauth-clients/index.ts")
|
|
390
|
+
});
|
|
391
|
+
injectRoute({
|
|
392
|
+
pattern: "/_dineway/api/admin/oauth-clients/[id]",
|
|
393
|
+
entrypoint: resolveRoute("api/admin/oauth-clients/[id].ts")
|
|
394
|
+
});
|
|
395
|
+
injectRoute({
|
|
396
|
+
pattern: "/_dineway/api/oauth/device/code",
|
|
397
|
+
entrypoint: resolveRoute("api/oauth/device/code.ts")
|
|
398
|
+
});
|
|
399
|
+
injectRoute({
|
|
400
|
+
pattern: "/_dineway/api/oauth/device/token",
|
|
401
|
+
entrypoint: resolveRoute("api/oauth/device/token.ts")
|
|
402
|
+
});
|
|
403
|
+
injectRoute({
|
|
404
|
+
pattern: "/_dineway/api/oauth/device/authorize",
|
|
405
|
+
entrypoint: resolveRoute("api/oauth/device/authorize.ts")
|
|
406
|
+
});
|
|
407
|
+
injectRoute({
|
|
408
|
+
pattern: "/_dineway/api/oauth/token/refresh",
|
|
409
|
+
entrypoint: resolveRoute("api/oauth/token/refresh.ts")
|
|
410
|
+
});
|
|
411
|
+
injectRoute({
|
|
412
|
+
pattern: "/_dineway/api/oauth/token/revoke",
|
|
413
|
+
entrypoint: resolveRoute("api/oauth/token/revoke.ts")
|
|
414
|
+
});
|
|
415
|
+
injectRoute({
|
|
416
|
+
pattern: "/_dineway/.well-known/auth",
|
|
417
|
+
entrypoint: resolveRoute("api/well-known/auth.ts")
|
|
418
|
+
});
|
|
419
|
+
injectRoute({
|
|
420
|
+
pattern: "/_dineway/api/oauth/token",
|
|
421
|
+
entrypoint: resolveRoute("api/oauth/token.ts")
|
|
422
|
+
});
|
|
423
|
+
injectRoute({
|
|
424
|
+
pattern: "/_dineway/oauth/authorize",
|
|
425
|
+
entrypoint: resolveRoute("api/oauth/authorize.ts")
|
|
426
|
+
});
|
|
427
|
+
injectRoute({
|
|
428
|
+
pattern: "/.well-known/oauth-protected-resource",
|
|
429
|
+
entrypoint: resolveRoute("api/well-known/oauth-protected-resource.ts")
|
|
430
|
+
});
|
|
431
|
+
injectRoute({
|
|
432
|
+
pattern: "/_dineway/.well-known/oauth-authorization-server",
|
|
433
|
+
entrypoint: resolveRoute("api/well-known/oauth-authorization-server.ts")
|
|
434
|
+
});
|
|
435
|
+
injectRoute({
|
|
436
|
+
pattern: "/_dineway/api/plugins/[pluginId]/[...path]",
|
|
437
|
+
entrypoint: resolveRoute("api/plugins/[pluginId]/[...path].ts")
|
|
438
|
+
});
|
|
439
|
+
injectRoute({
|
|
440
|
+
pattern: "/_dineway/api/menus",
|
|
441
|
+
entrypoint: resolveRoute("api/menus/index.ts")
|
|
442
|
+
});
|
|
443
|
+
injectRoute({
|
|
444
|
+
pattern: "/_dineway/api/menus/[name]",
|
|
445
|
+
entrypoint: resolveRoute("api/menus/[name].ts")
|
|
446
|
+
});
|
|
447
|
+
injectRoute({
|
|
448
|
+
pattern: "/_dineway/api/menus/[name]/items",
|
|
449
|
+
entrypoint: resolveRoute("api/menus/[name]/items.ts")
|
|
450
|
+
});
|
|
451
|
+
injectRoute({
|
|
452
|
+
pattern: "/_dineway/api/menus/[name]/reorder",
|
|
453
|
+
entrypoint: resolveRoute("api/menus/[name]/reorder.ts")
|
|
454
|
+
});
|
|
455
|
+
injectRoute({
|
|
456
|
+
pattern: "/_dineway/api/widget-areas",
|
|
457
|
+
entrypoint: resolveRoute("api/widget-areas/index.ts")
|
|
458
|
+
});
|
|
459
|
+
injectRoute({
|
|
460
|
+
pattern: "/_dineway/api/widget-components",
|
|
461
|
+
entrypoint: resolveRoute("api/widget-components.ts")
|
|
462
|
+
});
|
|
463
|
+
injectRoute({
|
|
464
|
+
pattern: "/_dineway/api/widget-areas/[name]",
|
|
465
|
+
entrypoint: resolveRoute("api/widget-areas/[name].ts")
|
|
466
|
+
});
|
|
467
|
+
injectRoute({
|
|
468
|
+
pattern: "/_dineway/api/widget-areas/[name]/widgets",
|
|
469
|
+
entrypoint: resolveRoute("api/widget-areas/[name]/widgets.ts")
|
|
470
|
+
});
|
|
471
|
+
injectRoute({
|
|
472
|
+
pattern: "/_dineway/api/widget-areas/[name]/widgets/[id]",
|
|
473
|
+
entrypoint: resolveRoute("api/widget-areas/[name]/widgets/[id].ts")
|
|
474
|
+
});
|
|
475
|
+
injectRoute({
|
|
476
|
+
pattern: "/_dineway/api/widget-areas/[name]/reorder",
|
|
477
|
+
entrypoint: resolveRoute("api/widget-areas/[name]/reorder.ts")
|
|
478
|
+
});
|
|
479
|
+
injectRoute({
|
|
480
|
+
pattern: "/_dineway/api/sections",
|
|
481
|
+
entrypoint: resolveRoute("api/sections/index.ts")
|
|
482
|
+
});
|
|
483
|
+
injectRoute({
|
|
484
|
+
pattern: "/_dineway/api/sections/[slug]",
|
|
485
|
+
entrypoint: resolveRoute("api/sections/[slug].ts")
|
|
486
|
+
});
|
|
487
|
+
injectRoute({
|
|
488
|
+
pattern: "/_dineway/api/redirects",
|
|
489
|
+
entrypoint: resolveRoute("api/redirects/index.ts")
|
|
490
|
+
});
|
|
491
|
+
injectRoute({
|
|
492
|
+
pattern: "/_dineway/api/redirects/404s/summary",
|
|
493
|
+
entrypoint: resolveRoute("api/redirects/404s/summary.ts")
|
|
494
|
+
});
|
|
495
|
+
injectRoute({
|
|
496
|
+
pattern: "/_dineway/api/redirects/404s",
|
|
497
|
+
entrypoint: resolveRoute("api/redirects/404s/index.ts")
|
|
498
|
+
});
|
|
499
|
+
injectRoute({
|
|
500
|
+
pattern: "/_dineway/api/redirects/[id]",
|
|
501
|
+
entrypoint: resolveRoute("api/redirects/[id].ts")
|
|
502
|
+
});
|
|
503
|
+
injectRoute({
|
|
504
|
+
pattern: "/_dineway/api/search",
|
|
505
|
+
entrypoint: resolveRoute("api/search/index.ts")
|
|
506
|
+
});
|
|
507
|
+
injectRoute({
|
|
508
|
+
pattern: "/_dineway/api/search/suggest",
|
|
509
|
+
entrypoint: resolveRoute("api/search/suggest.ts")
|
|
510
|
+
});
|
|
511
|
+
injectRoute({
|
|
512
|
+
pattern: "/_dineway/api/search/stats",
|
|
513
|
+
entrypoint: resolveRoute("api/search/stats.ts")
|
|
514
|
+
});
|
|
515
|
+
injectRoute({
|
|
516
|
+
pattern: "/_dineway/api/search/rebuild",
|
|
517
|
+
entrypoint: resolveRoute("api/search/rebuild.ts")
|
|
518
|
+
});
|
|
519
|
+
injectRoute({
|
|
520
|
+
pattern: "/_dineway/api/search/enable",
|
|
521
|
+
entrypoint: resolveRoute("api/search/enable.ts")
|
|
522
|
+
});
|
|
523
|
+
injectRoute({
|
|
524
|
+
pattern: "/_dineway/api/comments/[collection]/[contentId]",
|
|
525
|
+
entrypoint: resolveRoute("api/comments/[collection]/[contentId]/index.ts")
|
|
526
|
+
});
|
|
527
|
+
injectRoute({
|
|
528
|
+
pattern: "/_dineway/api/admin/comments",
|
|
529
|
+
entrypoint: resolveRoute("api/admin/comments/index.ts")
|
|
530
|
+
});
|
|
531
|
+
injectRoute({
|
|
532
|
+
pattern: "/_dineway/api/admin/comments/counts",
|
|
533
|
+
entrypoint: resolveRoute("api/admin/comments/counts.ts")
|
|
534
|
+
});
|
|
535
|
+
injectRoute({
|
|
536
|
+
pattern: "/_dineway/api/admin/comments/bulk",
|
|
537
|
+
entrypoint: resolveRoute("api/admin/comments/bulk.ts")
|
|
538
|
+
});
|
|
539
|
+
injectRoute({
|
|
540
|
+
pattern: "/_dineway/api/admin/comments/[id]/status",
|
|
541
|
+
entrypoint: resolveRoute("api/admin/comments/[id]/status.ts")
|
|
542
|
+
});
|
|
543
|
+
injectRoute({
|
|
544
|
+
pattern: "/_dineway/api/admin/comments/[id]",
|
|
545
|
+
entrypoint: resolveRoute("api/admin/comments/[id].ts")
|
|
546
|
+
});
|
|
547
|
+
injectRoute({
|
|
548
|
+
pattern: "/sitemap.xml",
|
|
549
|
+
entrypoint: resolveRoute("sitemap.xml.ts")
|
|
550
|
+
});
|
|
551
|
+
injectRoute({
|
|
552
|
+
pattern: "/sitemap-[collection].xml",
|
|
553
|
+
entrypoint: resolveRoute("sitemap-[collection].xml.ts")
|
|
554
|
+
});
|
|
555
|
+
injectRoute({
|
|
556
|
+
pattern: "/robots.txt",
|
|
557
|
+
entrypoint: resolveRoute("robots.txt.ts")
|
|
558
|
+
});
|
|
559
|
+
injectRoute({
|
|
560
|
+
pattern: "/_dineway/api/setup/status",
|
|
561
|
+
entrypoint: resolveRoute("api/setup/status.ts")
|
|
562
|
+
});
|
|
563
|
+
injectRoute({
|
|
564
|
+
pattern: "/_dineway/api/setup",
|
|
565
|
+
entrypoint: resolveRoute("api/setup/index.ts")
|
|
566
|
+
});
|
|
567
|
+
injectRoute({
|
|
568
|
+
pattern: "/_dineway/api/setup/admin",
|
|
569
|
+
entrypoint: resolveRoute("api/setup/admin.ts")
|
|
570
|
+
});
|
|
571
|
+
injectRoute({
|
|
572
|
+
pattern: "/_dineway/api/setup/admin/verify",
|
|
573
|
+
entrypoint: resolveRoute("api/setup/admin-verify.ts")
|
|
574
|
+
});
|
|
575
|
+
injectRoute({
|
|
576
|
+
pattern: "/_dineway/api/setup/dev-bypass",
|
|
577
|
+
entrypoint: resolveRoute("api/setup/dev-bypass.ts")
|
|
578
|
+
});
|
|
579
|
+
injectRoute({
|
|
580
|
+
pattern: "/_dineway/api/setup/dev-reset",
|
|
581
|
+
entrypoint: resolveRoute("api/setup/dev-reset.ts")
|
|
582
|
+
});
|
|
583
|
+
injectRoute({
|
|
584
|
+
pattern: "/_dineway/api/auth/me",
|
|
585
|
+
entrypoint: resolveRoute("api/auth/me.ts")
|
|
586
|
+
});
|
|
587
|
+
injectRoute({
|
|
588
|
+
pattern: "/_dineway/api/auth/logout",
|
|
589
|
+
entrypoint: resolveRoute("api/auth/logout.ts")
|
|
590
|
+
});
|
|
591
|
+
}
|
|
592
|
+
/**
|
|
593
|
+
* Injects the MCP (Model Context Protocol) server route.
|
|
594
|
+
* Only injected when `mcp: true` is set in the Dineway config.
|
|
595
|
+
*/
|
|
596
|
+
function injectMcpRoute(injectRoute) {
|
|
597
|
+
injectRoute({
|
|
598
|
+
pattern: "/_dineway/api/mcp",
|
|
599
|
+
entrypoint: resolveRoute("api/mcp.ts")
|
|
600
|
+
});
|
|
601
|
+
}
|
|
602
|
+
/**
|
|
603
|
+
* Injects passkey/oauth/magic-link auth routes.
|
|
604
|
+
* Only used when NOT using external auth.
|
|
605
|
+
*/
|
|
606
|
+
function injectBuiltinAuthRoutes(injectRoute) {
|
|
607
|
+
injectRoute({
|
|
608
|
+
pattern: "/_dineway/api/auth/passkey/options",
|
|
609
|
+
entrypoint: resolveRoute("api/auth/passkey/options.ts")
|
|
610
|
+
});
|
|
611
|
+
injectRoute({
|
|
612
|
+
pattern: "/_dineway/api/auth/passkey/verify",
|
|
613
|
+
entrypoint: resolveRoute("api/auth/passkey/verify.ts")
|
|
614
|
+
});
|
|
615
|
+
injectRoute({
|
|
616
|
+
pattern: "/_dineway/api/auth/passkey",
|
|
617
|
+
entrypoint: resolveRoute("api/auth/passkey/index.ts")
|
|
618
|
+
});
|
|
619
|
+
injectRoute({
|
|
620
|
+
pattern: "/_dineway/api/auth/passkey/register/options",
|
|
621
|
+
entrypoint: resolveRoute("api/auth/passkey/register/options.ts")
|
|
622
|
+
});
|
|
623
|
+
injectRoute({
|
|
624
|
+
pattern: "/_dineway/api/auth/passkey/register/verify",
|
|
625
|
+
entrypoint: resolveRoute("api/auth/passkey/register/verify.ts")
|
|
626
|
+
});
|
|
627
|
+
injectRoute({
|
|
628
|
+
pattern: "/_dineway/api/auth/passkey/[id]",
|
|
629
|
+
entrypoint: resolveRoute("api/auth/passkey/[id].ts")
|
|
630
|
+
});
|
|
631
|
+
injectRoute({
|
|
632
|
+
pattern: "/_dineway/api/auth/dev-bypass",
|
|
633
|
+
entrypoint: resolveRoute("api/auth/dev-bypass.ts")
|
|
634
|
+
});
|
|
635
|
+
injectRoute({
|
|
636
|
+
pattern: "/_dineway/api/auth/invite",
|
|
637
|
+
entrypoint: resolveRoute("api/auth/invite/index.ts")
|
|
638
|
+
});
|
|
639
|
+
injectRoute({
|
|
640
|
+
pattern: "/_dineway/api/auth/invite/accept",
|
|
641
|
+
entrypoint: resolveRoute("api/auth/invite/accept.ts")
|
|
642
|
+
});
|
|
643
|
+
injectRoute({
|
|
644
|
+
pattern: "/_dineway/api/auth/invite/complete",
|
|
645
|
+
entrypoint: resolveRoute("api/auth/invite/complete.ts")
|
|
646
|
+
});
|
|
647
|
+
injectRoute({
|
|
648
|
+
pattern: "/_dineway/api/auth/magic-link/send",
|
|
649
|
+
entrypoint: resolveRoute("api/auth/magic-link/send.ts")
|
|
650
|
+
});
|
|
651
|
+
injectRoute({
|
|
652
|
+
pattern: "/_dineway/api/auth/magic-link/verify",
|
|
653
|
+
entrypoint: resolveRoute("api/auth/magic-link/verify.ts")
|
|
654
|
+
});
|
|
655
|
+
injectRoute({
|
|
656
|
+
pattern: "/_dineway/api/auth/oauth/[provider]",
|
|
657
|
+
entrypoint: resolveRoute("api/auth/oauth/[provider].ts")
|
|
658
|
+
});
|
|
659
|
+
injectRoute({
|
|
660
|
+
pattern: "/_dineway/api/auth/oauth/[provider]/callback",
|
|
661
|
+
entrypoint: resolveRoute("api/auth/oauth/[provider]/callback.ts")
|
|
662
|
+
});
|
|
663
|
+
injectRoute({
|
|
664
|
+
pattern: "/_dineway/api/auth/signup/request",
|
|
665
|
+
entrypoint: resolveRoute("api/auth/signup/request.ts")
|
|
666
|
+
});
|
|
667
|
+
injectRoute({
|
|
668
|
+
pattern: "/_dineway/api/auth/signup/verify",
|
|
669
|
+
entrypoint: resolveRoute("api/auth/signup/verify.ts")
|
|
670
|
+
});
|
|
671
|
+
injectRoute({
|
|
672
|
+
pattern: "/_dineway/api/auth/signup/complete",
|
|
673
|
+
entrypoint: resolveRoute("api/auth/signup/complete.ts")
|
|
674
|
+
});
|
|
675
|
+
injectRoute({
|
|
676
|
+
pattern: "/_dineway/api/admin/allowed-domains",
|
|
677
|
+
entrypoint: resolveRoute("api/admin/allowed-domains/index.ts")
|
|
678
|
+
});
|
|
679
|
+
injectRoute({
|
|
680
|
+
pattern: "/_dineway/api/admin/allowed-domains/[domain]",
|
|
681
|
+
entrypoint: resolveRoute("api/admin/allowed-domains/[domain].ts")
|
|
682
|
+
});
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
//#endregion
|
|
686
|
+
//#region src/astro/integration/virtual-modules.ts
|
|
687
|
+
/**
|
|
688
|
+
* Virtual Module Generators
|
|
689
|
+
*
|
|
690
|
+
* Functions that generate virtual module content for Vite.
|
|
691
|
+
* These modules statically import configured dependencies
|
|
692
|
+
* so Vite can properly resolve and bundle them.
|
|
693
|
+
*/
|
|
694
|
+
const TS_SOURCE_EXT_RE = /^\.(ts|tsx|mts|cts|jsx)$/;
|
|
695
|
+
/** Pattern to remove scoped package prefix from plugin ID */
|
|
696
|
+
const SCOPED_PREFIX_PATTERN = /^@[^/]+\/plugin-/;
|
|
697
|
+
/** Pattern to remove dineway-plugin- prefix from plugin ID */
|
|
698
|
+
const DINEWAY_PREFIX_PATTERN = /^dineway-plugin-/;
|
|
699
|
+
const VIRTUAL_CONFIG_ID = "virtual:dineway/config";
|
|
700
|
+
const RESOLVED_VIRTUAL_CONFIG_ID = "\0" + VIRTUAL_CONFIG_ID;
|
|
701
|
+
const VIRTUAL_DIALECT_ID = "virtual:dineway/dialect";
|
|
702
|
+
const RESOLVED_VIRTUAL_DIALECT_ID = "\0" + VIRTUAL_DIALECT_ID;
|
|
703
|
+
const VIRTUAL_STORAGE_ID = "virtual:dineway/storage";
|
|
704
|
+
const RESOLVED_VIRTUAL_STORAGE_ID = "\0" + VIRTUAL_STORAGE_ID;
|
|
705
|
+
const VIRTUAL_ADMIN_REGISTRY_ID = "virtual:dineway/admin-registry";
|
|
706
|
+
const RESOLVED_VIRTUAL_ADMIN_REGISTRY_ID = "\0" + VIRTUAL_ADMIN_REGISTRY_ID;
|
|
707
|
+
const VIRTUAL_PLUGINS_ID = "virtual:dineway/plugins";
|
|
708
|
+
const RESOLVED_VIRTUAL_PLUGINS_ID = "\0" + VIRTUAL_PLUGINS_ID;
|
|
709
|
+
const VIRTUAL_SANDBOX_RUNNER_ID = "virtual:dineway/sandbox-runner";
|
|
710
|
+
const RESOLVED_VIRTUAL_SANDBOX_RUNNER_ID = "\0" + VIRTUAL_SANDBOX_RUNNER_ID;
|
|
711
|
+
const VIRTUAL_SANDBOXED_PLUGINS_ID = "virtual:dineway/sandboxed-plugins";
|
|
712
|
+
const RESOLVED_VIRTUAL_SANDBOXED_PLUGINS_ID = "\0" + VIRTUAL_SANDBOXED_PLUGINS_ID;
|
|
713
|
+
const VIRTUAL_AUTH_ID = "virtual:dineway/auth";
|
|
714
|
+
const RESOLVED_VIRTUAL_AUTH_ID = "\0" + VIRTUAL_AUTH_ID;
|
|
715
|
+
const VIRTUAL_MEDIA_PROVIDERS_ID = "virtual:dineway/media-providers";
|
|
716
|
+
const RESOLVED_VIRTUAL_MEDIA_PROVIDERS_ID = "\0" + VIRTUAL_MEDIA_PROVIDERS_ID;
|
|
717
|
+
const VIRTUAL_BLOCK_COMPONENTS_ID = "virtual:dineway/block-components";
|
|
718
|
+
const RESOLVED_VIRTUAL_BLOCK_COMPONENTS_ID = "\0" + VIRTUAL_BLOCK_COMPONENTS_ID;
|
|
719
|
+
const VIRTUAL_SEED_ID = "virtual:dineway/seed";
|
|
720
|
+
const RESOLVED_VIRTUAL_SEED_ID = "\0" + VIRTUAL_SEED_ID;
|
|
721
|
+
/**
|
|
722
|
+
* Generates the config virtual module.
|
|
723
|
+
*/
|
|
724
|
+
function generateConfigModule(serializableConfig) {
|
|
725
|
+
return `export default ${JSON.stringify(serializableConfig)};`;
|
|
726
|
+
}
|
|
727
|
+
/**
|
|
728
|
+
* Generates the dialect virtual module.
|
|
729
|
+
* Statically imports the configured database dialect and exports the dialect type.
|
|
730
|
+
*/
|
|
731
|
+
function generateDialectModule(dbEntrypoint, dbType, _dbConfig) {
|
|
732
|
+
if (!dbEntrypoint) return [`export const createDialect = undefined;`, `export const dialectType = "sqlite";`].join("\n");
|
|
733
|
+
const type = dbType ?? "sqlite";
|
|
734
|
+
return `
|
|
735
|
+
import { createDialect as _createDialect } from "${dbEntrypoint}";
|
|
736
|
+
export const createDialect = _createDialect;
|
|
737
|
+
export const dialectType = ${JSON.stringify(type)};
|
|
738
|
+
`;
|
|
739
|
+
}
|
|
740
|
+
/**
|
|
741
|
+
* Generates the storage virtual module.
|
|
742
|
+
* Statically imports the configured storage adapter.
|
|
743
|
+
*/
|
|
744
|
+
function generateStorageModule(storageEntrypoint) {
|
|
745
|
+
if (!storageEntrypoint) return `export const createStorage = undefined;`;
|
|
746
|
+
return `
|
|
747
|
+
import { createStorage as _createStorage } from "${storageEntrypoint}";
|
|
748
|
+
export const createStorage = _createStorage;
|
|
749
|
+
`;
|
|
750
|
+
}
|
|
751
|
+
/**
|
|
752
|
+
* Generates the auth virtual module.
|
|
753
|
+
* Statically imports the configured auth provider.
|
|
754
|
+
*/
|
|
755
|
+
function generateAuthModule(authEntrypoint) {
|
|
756
|
+
if (!authEntrypoint) return `export const authenticate = undefined;`;
|
|
757
|
+
return `
|
|
758
|
+
import { authenticate as _authenticate } from "${authEntrypoint}";
|
|
759
|
+
export const authenticate = _authenticate;
|
|
760
|
+
`;
|
|
761
|
+
}
|
|
762
|
+
/**
|
|
763
|
+
* Generates the plugins module.
|
|
764
|
+
* Imports and instantiates all plugins at runtime.
|
|
765
|
+
*
|
|
766
|
+
* Handles two plugin formats:
|
|
767
|
+
* - **Native**: imports `createPlugin` and calls it with options
|
|
768
|
+
* - **Standard**: imports the default export and wraps it with `adaptSandboxEntry`
|
|
769
|
+
*
|
|
770
|
+
* The format is determined by `descriptor.format`:
|
|
771
|
+
* - `"standard"` -- uses adaptSandboxEntry
|
|
772
|
+
* - `"native"` or undefined -- uses createPlugin
|
|
773
|
+
*
|
|
774
|
+
* This keeps plugin resolution explicit in bundled server runtimes instead of
|
|
775
|
+
* relying on globals captured at build time.
|
|
776
|
+
*/
|
|
777
|
+
function generatePluginsModule(descriptors) {
|
|
778
|
+
if (descriptors.length === 0) return `export const plugins = [];`;
|
|
779
|
+
const imports = [];
|
|
780
|
+
const instantiations = [];
|
|
781
|
+
let needsAdapter = false;
|
|
782
|
+
descriptors.forEach((descriptor, index) => {
|
|
783
|
+
if (descriptor.format === "standard") {
|
|
784
|
+
needsAdapter = true;
|
|
785
|
+
const varName = `pluginDef${index}`;
|
|
786
|
+
imports.push(`import ${varName} from "${descriptor.entrypoint}";`);
|
|
787
|
+
instantiations.push(`adaptSandboxEntry(${varName}, ${JSON.stringify({
|
|
788
|
+
id: descriptor.id,
|
|
789
|
+
version: descriptor.version,
|
|
790
|
+
capabilities: descriptor.capabilities,
|
|
791
|
+
allowedHosts: descriptor.allowedHosts,
|
|
792
|
+
storage: descriptor.storage,
|
|
793
|
+
adminPages: descriptor.adminPages,
|
|
794
|
+
adminWidgets: descriptor.adminWidgets
|
|
795
|
+
})})`);
|
|
796
|
+
} else {
|
|
797
|
+
const varName = `createPlugin${index}`;
|
|
798
|
+
imports.push(`import { createPlugin as ${varName} } from "${descriptor.entrypoint}";`);
|
|
799
|
+
instantiations.push(`${varName}(${JSON.stringify(descriptor.options ?? {})})`);
|
|
800
|
+
}
|
|
801
|
+
});
|
|
802
|
+
return `
|
|
803
|
+
// Auto-generated plugins module
|
|
804
|
+
// Imports and instantiates all configured plugins at runtime
|
|
805
|
+
|
|
806
|
+
${needsAdapter ? `import { adaptSandboxEntry } from "dineway/plugins/adapt-sandbox-entry";\n` : ""}${imports.join("\n")}
|
|
807
|
+
|
|
808
|
+
/** Resolved plugins array */
|
|
809
|
+
export const plugins = [
|
|
810
|
+
${instantiations.join(",\n ")}
|
|
811
|
+
];
|
|
812
|
+
`;
|
|
813
|
+
}
|
|
814
|
+
/**
|
|
815
|
+
* Generates the admin registry module.
|
|
816
|
+
* Uses adminEntry from plugin descriptors to statically import admin modules.
|
|
817
|
+
*/
|
|
818
|
+
function generateAdminRegistryModule(descriptors) {
|
|
819
|
+
const adminDescriptors = descriptors.filter((d) => d.adminEntry);
|
|
820
|
+
if (adminDescriptors.length === 0) return `export const pluginAdmins = {};`;
|
|
821
|
+
const imports = [];
|
|
822
|
+
const entries = [];
|
|
823
|
+
adminDescriptors.forEach((descriptor, index) => {
|
|
824
|
+
const varName = `admin${index}`;
|
|
825
|
+
const pluginId = descriptor.id ?? descriptor.entrypoint.replace(SCOPED_PREFIX_PATTERN, "").replace(DINEWAY_PREFIX_PATTERN, "");
|
|
826
|
+
imports.push(`import * as ${varName} from "${descriptor.adminEntry}";`);
|
|
827
|
+
entries.push(` "${pluginId}": ${varName},`);
|
|
828
|
+
});
|
|
829
|
+
return `
|
|
830
|
+
// Auto-generated plugin admin registry
|
|
831
|
+
${imports.join("\n")}
|
|
832
|
+
|
|
833
|
+
export const pluginAdmins = {
|
|
834
|
+
${entries.join("\n")}
|
|
835
|
+
};
|
|
836
|
+
`;
|
|
837
|
+
}
|
|
838
|
+
/**
|
|
839
|
+
* Generates the sandbox runner module.
|
|
840
|
+
* Imports the configured sandbox runner factory or provides a noop default.
|
|
841
|
+
*/
|
|
842
|
+
function generateSandboxRunnerModule(sandboxRunner) {
|
|
843
|
+
if (!sandboxRunner) return `
|
|
844
|
+
// Auto-generated sandbox runner module (default Node runner)
|
|
845
|
+
import { createNodeSandboxRunner } from "dineway";
|
|
846
|
+
|
|
847
|
+
export const createSandboxRunner = createNodeSandboxRunner;
|
|
848
|
+
export const sandboxEnabled = true;
|
|
849
|
+
`;
|
|
850
|
+
return `
|
|
851
|
+
// Auto-generated sandbox runner module
|
|
852
|
+
import { createSandboxRunner as _createSandboxRunner } from "${sandboxRunner}";
|
|
853
|
+
|
|
854
|
+
export const createSandboxRunner = _createSandboxRunner;
|
|
855
|
+
export const sandboxEnabled = true;
|
|
856
|
+
`;
|
|
857
|
+
}
|
|
858
|
+
/**
|
|
859
|
+
* Generates the media providers module.
|
|
860
|
+
* Imports and instantiates configured media providers at runtime.
|
|
861
|
+
*/
|
|
862
|
+
function generateMediaProvidersModule(descriptors) {
|
|
863
|
+
const localDisabled = descriptors.some((d) => d.id === "local" && d.config.enabled === false);
|
|
864
|
+
const imports = [];
|
|
865
|
+
const entries = [];
|
|
866
|
+
if (!localDisabled) {
|
|
867
|
+
imports.push(`import { createMediaProvider as createLocalProvider } from "dineway/media/local-runtime";`);
|
|
868
|
+
entries.push(`{
|
|
869
|
+
id: "local",
|
|
870
|
+
name: "Library",
|
|
871
|
+
icon: "folder",
|
|
872
|
+
capabilities: { browse: true, search: false, upload: true, delete: true },
|
|
873
|
+
createProvider: (ctx) => createLocalProvider({ ...ctx, enabled: true }),
|
|
874
|
+
}`);
|
|
875
|
+
}
|
|
876
|
+
descriptors.filter((d) => d.id !== "local" || d.config.enabled !== false).filter((d) => d.id !== "local").forEach((descriptor, index) => {
|
|
877
|
+
const varName = `createProvider${index}`;
|
|
878
|
+
imports.push(`import { createMediaProvider as ${varName} } from "${descriptor.entrypoint}";`);
|
|
879
|
+
entries.push(`{
|
|
880
|
+
id: ${JSON.stringify(descriptor.id)},
|
|
881
|
+
name: ${JSON.stringify(descriptor.name)},
|
|
882
|
+
icon: ${JSON.stringify(descriptor.icon)},
|
|
883
|
+
capabilities: ${JSON.stringify(descriptor.capabilities)},
|
|
884
|
+
createProvider: (ctx) => ${varName}({ ...${JSON.stringify(descriptor.config)}, ...ctx }),
|
|
885
|
+
}`);
|
|
886
|
+
});
|
|
887
|
+
return `
|
|
888
|
+
// Auto-generated media providers module
|
|
889
|
+
${imports.join("\n")}
|
|
890
|
+
|
|
891
|
+
/** Media provider descriptors with factory functions */
|
|
892
|
+
export const mediaProviders = [
|
|
893
|
+
${entries.join(",\n ")}
|
|
894
|
+
];
|
|
895
|
+
`;
|
|
896
|
+
}
|
|
897
|
+
/**
|
|
898
|
+
* Generates the block components module.
|
|
899
|
+
* Collects and merges `blockComponents` exports from plugin component entries.
|
|
900
|
+
*/
|
|
901
|
+
function generateBlockComponentsModule(descriptors) {
|
|
902
|
+
const withComponents = descriptors.filter((d) => d.componentsEntry);
|
|
903
|
+
if (withComponents.length === 0) return `export const pluginBlockComponents = {};`;
|
|
904
|
+
const imports = [];
|
|
905
|
+
const spreads = [];
|
|
906
|
+
withComponents.forEach((d, i) => {
|
|
907
|
+
imports.push(`import { blockComponents as bc${i} } from "${d.componentsEntry}";`);
|
|
908
|
+
spreads.push(`...bc${i}`);
|
|
909
|
+
});
|
|
910
|
+
return `${imports.join("\n")}\nexport const pluginBlockComponents = { ${spreads.join(", ")} };`;
|
|
911
|
+
}
|
|
912
|
+
/**
|
|
913
|
+
* Generates the seed virtual module.
|
|
914
|
+
* Reads the user's seed file at build time (in Node context) and embeds it,
|
|
915
|
+
* so the runtime doesn't need filesystem access during request handling.
|
|
916
|
+
*
|
|
917
|
+
* Exports `userSeed` (user's seed or null) and `seed` (user's seed or default).
|
|
918
|
+
*/
|
|
919
|
+
function generateSeedModule(projectRoot) {
|
|
920
|
+
let userSeedJson = null;
|
|
921
|
+
try {
|
|
922
|
+
const content = readFileSync(resolve(projectRoot, ".dineway", "seed.json"), "utf-8");
|
|
923
|
+
JSON.parse(content);
|
|
924
|
+
userSeedJson = content;
|
|
925
|
+
} catch {}
|
|
926
|
+
if (!userSeedJson) try {
|
|
927
|
+
const pkgContent = readFileSync(resolve(projectRoot, "package.json"), "utf-8");
|
|
928
|
+
const pkg = JSON.parse(pkgContent);
|
|
929
|
+
if (pkg.dineway?.seed) {
|
|
930
|
+
const content = readFileSync(resolve(projectRoot, pkg.dineway.seed), "utf-8");
|
|
931
|
+
JSON.parse(content);
|
|
932
|
+
userSeedJson = content;
|
|
933
|
+
}
|
|
934
|
+
} catch {}
|
|
935
|
+
if (userSeedJson) return [`export const userSeed = ${userSeedJson};`, `export const seed = userSeed;`].join("\n");
|
|
936
|
+
return [`export const userSeed = null;`, `export const seed = ${JSON.stringify(defaultSeed)};`].join("\n");
|
|
937
|
+
}
|
|
938
|
+
/**
|
|
939
|
+
* Resolve a module specifier from the project's context.
|
|
940
|
+
* Uses Node.js require.resolve with the project root as base.
|
|
941
|
+
*/
|
|
942
|
+
function resolveModulePathFromProject(specifier, projectRoot) {
|
|
943
|
+
return createRequire(resolve(projectRoot, "package.json")).resolve(specifier);
|
|
944
|
+
}
|
|
945
|
+
/**
|
|
946
|
+
* Generates the sandboxed plugins module.
|
|
947
|
+
* Resolves plugin entrypoints to files, reads them, and embeds the code.
|
|
948
|
+
*
|
|
949
|
+
* At runtime, middleware uses SandboxRunner to load these into isolates.
|
|
950
|
+
*/
|
|
951
|
+
function generateSandboxedPluginsModule(sandboxed, projectRoot) {
|
|
952
|
+
if (sandboxed.length === 0) return `
|
|
953
|
+
// No sandboxed plugins configured
|
|
954
|
+
export const sandboxedPlugins = [];
|
|
955
|
+
`;
|
|
956
|
+
const pluginEntries = [];
|
|
957
|
+
for (const descriptor of sandboxed) {
|
|
958
|
+
const bundleSpecifier = descriptor.entrypoint;
|
|
959
|
+
const filePath = resolveModulePathFromProject(bundleSpecifier, projectRoot);
|
|
960
|
+
const ext = filePath.slice(filePath.lastIndexOf("."));
|
|
961
|
+
if (TS_SOURCE_EXT_RE.test(ext)) throw new Error(`Sandboxed plugin "${descriptor.id}" entrypoint "${bundleSpecifier}" resolves to unbuilt source (${filePath}). Sandbox entries must be pre-built JavaScript. Ensure the plugin's package.json exports point to built files (e.g. dist/*.mjs) and run the plugin's build step before building the site.`);
|
|
962
|
+
const code = readFileSync(filePath, "utf-8");
|
|
963
|
+
pluginEntries.push(`{
|
|
964
|
+
id: ${JSON.stringify(descriptor.id)},
|
|
965
|
+
version: ${JSON.stringify(descriptor.version)},
|
|
966
|
+
options: ${JSON.stringify(descriptor.options ?? {})},
|
|
967
|
+
capabilities: ${JSON.stringify(descriptor.capabilities ?? [])},
|
|
968
|
+
allowedHosts: ${JSON.stringify(descriptor.allowedHosts ?? [])},
|
|
969
|
+
storage: ${JSON.stringify(descriptor.storage ?? {})},
|
|
970
|
+
adminPages: ${JSON.stringify(descriptor.adminPages ?? [])},
|
|
971
|
+
adminWidgets: ${JSON.stringify(descriptor.adminWidgets ?? [])},
|
|
972
|
+
adminEntry: ${JSON.stringify(descriptor.adminEntry)},
|
|
973
|
+
// Code read from: ${filePath}
|
|
974
|
+
code: ${JSON.stringify(code)},
|
|
975
|
+
}`);
|
|
976
|
+
}
|
|
977
|
+
return `
|
|
978
|
+
// Auto-generated sandboxed plugins module
|
|
979
|
+
// Plugin code is embedded at build time
|
|
980
|
+
|
|
981
|
+
/**
|
|
982
|
+
* Sandboxed plugin entries with embedded code.
|
|
983
|
+
* Loaded at runtime via SandboxRunner.
|
|
984
|
+
*/
|
|
985
|
+
export const sandboxedPlugins = [
|
|
986
|
+
${pluginEntries.join(",\n ")}
|
|
987
|
+
];
|
|
988
|
+
`;
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
//#endregion
|
|
992
|
+
//#region src/astro/integration/vite-config.ts
|
|
993
|
+
/**
|
|
994
|
+
* Vite Plugin Configuration
|
|
995
|
+
*
|
|
996
|
+
* Defines the Vite plugin that handles virtual modules and other
|
|
997
|
+
* Vite-specific configuration for Dineway.
|
|
998
|
+
*/
|
|
999
|
+
const LOCALE_MESSAGES_RE = /[/\\]([a-z]{2}(?:-[A-Z]{2})?)[/\\]messages\.mjs$/;
|
|
1000
|
+
/**
|
|
1001
|
+
* Vite plugin that compiles Lingui macros in admin source files.
|
|
1002
|
+
* Only active in dev mode when the admin package is aliased to source for HMR.
|
|
1003
|
+
* @babel/core is dynamically imported from admin's devDependencies —
|
|
1004
|
+
* not declared by core, never ships to end users.
|
|
1005
|
+
*/
|
|
1006
|
+
function linguiMacroPlugin(adminSourcePath, adminDistPath) {
|
|
1007
|
+
const babelCorePath = createRequire(resolve(adminDistPath, "index.js")).resolve("@babel/core");
|
|
1008
|
+
return {
|
|
1009
|
+
name: "dineway-lingui-macro",
|
|
1010
|
+
enforce: "pre",
|
|
1011
|
+
resolveId(id, importer) {
|
|
1012
|
+
if (!importer?.startsWith(adminSourcePath)) return;
|
|
1013
|
+
const match = id.match(LOCALE_MESSAGES_RE);
|
|
1014
|
+
if (match?.[1]) return resolve(adminDistPath, "locales", match[1], "messages.mjs");
|
|
1015
|
+
},
|
|
1016
|
+
async transform(code, id) {
|
|
1017
|
+
if (!id.startsWith(adminSourcePath) || !code.includes("@lingui")) return;
|
|
1018
|
+
const { transformAsync } = await import(babelCorePath);
|
|
1019
|
+
const result = await transformAsync(code, {
|
|
1020
|
+
filename: id,
|
|
1021
|
+
plugins: ["@lingui/babel-plugin-lingui-macro"],
|
|
1022
|
+
parserOpts: { plugins: ["jsx", "typescript"] }
|
|
1023
|
+
});
|
|
1024
|
+
if (!result?.code) return;
|
|
1025
|
+
return {
|
|
1026
|
+
code: result.code,
|
|
1027
|
+
map: result.map ?? void 0
|
|
1028
|
+
};
|
|
1029
|
+
}
|
|
1030
|
+
};
|
|
1031
|
+
}
|
|
1032
|
+
/**
|
|
1033
|
+
* Resolve path to the admin package dist directory.
|
|
1034
|
+
* Used for Vite alias to ensure the package is found in pnpm's isolated node_modules.
|
|
1035
|
+
*/
|
|
1036
|
+
function resolveAdminDist() {
|
|
1037
|
+
return dirname(createRequire(import.meta.url).resolve("@dineway-ai/admin"));
|
|
1038
|
+
}
|
|
1039
|
+
/**
|
|
1040
|
+
* Resolve path to the admin package source directory.
|
|
1041
|
+
* In dev mode, we alias @dineway-ai/admin to the source so Vite processes it
|
|
1042
|
+
* directly — giving instant HMR instead of requiring a rebuild + restart.
|
|
1043
|
+
*/
|
|
1044
|
+
function resolveAdminSource() {
|
|
1045
|
+
const packageRoot = resolve(dirname(createRequire(import.meta.url).resolve("@dineway-ai/admin")), "..");
|
|
1046
|
+
const srcEntry = resolve(packageRoot, "src", "index.ts");
|
|
1047
|
+
try {
|
|
1048
|
+
if (existsSync(srcEntry)) return resolve(packageRoot, "src");
|
|
1049
|
+
} catch {}
|
|
1050
|
+
}
|
|
1051
|
+
/**
|
|
1052
|
+
* Creates the Dineway virtual modules Vite plugin.
|
|
1053
|
+
*/
|
|
1054
|
+
function createVirtualModulesPlugin(options) {
|
|
1055
|
+
const { serializableConfig, resolvedConfig, pluginDescriptors, astroConfig } = options;
|
|
1056
|
+
return {
|
|
1057
|
+
name: "dineway-virtual-modules",
|
|
1058
|
+
resolveId(id) {
|
|
1059
|
+
if (id === VIRTUAL_CONFIG_ID) return RESOLVED_VIRTUAL_CONFIG_ID;
|
|
1060
|
+
if (id === VIRTUAL_DIALECT_ID) return RESOLVED_VIRTUAL_DIALECT_ID;
|
|
1061
|
+
if (id === VIRTUAL_STORAGE_ID) return RESOLVED_VIRTUAL_STORAGE_ID;
|
|
1062
|
+
if (id === VIRTUAL_ADMIN_REGISTRY_ID) return RESOLVED_VIRTUAL_ADMIN_REGISTRY_ID;
|
|
1063
|
+
if (id === VIRTUAL_PLUGINS_ID) return RESOLVED_VIRTUAL_PLUGINS_ID;
|
|
1064
|
+
if (id === VIRTUAL_SANDBOX_RUNNER_ID) return RESOLVED_VIRTUAL_SANDBOX_RUNNER_ID;
|
|
1065
|
+
if (id === VIRTUAL_SANDBOXED_PLUGINS_ID) return RESOLVED_VIRTUAL_SANDBOXED_PLUGINS_ID;
|
|
1066
|
+
if (id === VIRTUAL_AUTH_ID) return RESOLVED_VIRTUAL_AUTH_ID;
|
|
1067
|
+
if (id === VIRTUAL_MEDIA_PROVIDERS_ID) return RESOLVED_VIRTUAL_MEDIA_PROVIDERS_ID;
|
|
1068
|
+
if (id === VIRTUAL_BLOCK_COMPONENTS_ID) return RESOLVED_VIRTUAL_BLOCK_COMPONENTS_ID;
|
|
1069
|
+
if (id === VIRTUAL_SEED_ID) return RESOLVED_VIRTUAL_SEED_ID;
|
|
1070
|
+
},
|
|
1071
|
+
load(id) {
|
|
1072
|
+
if (id === RESOLVED_VIRTUAL_CONFIG_ID) return generateConfigModule(serializableConfig);
|
|
1073
|
+
if (id === RESOLVED_VIRTUAL_DIALECT_ID) return generateDialectModule(resolvedConfig.database?.entrypoint, resolvedConfig.database?.type, resolvedConfig.database?.config);
|
|
1074
|
+
if (id === RESOLVED_VIRTUAL_STORAGE_ID) return generateStorageModule(resolvedConfig.storage?.entrypoint);
|
|
1075
|
+
if (id === RESOLVED_VIRTUAL_PLUGINS_ID) return generatePluginsModule(pluginDescriptors);
|
|
1076
|
+
if (id === RESOLVED_VIRTUAL_ADMIN_REGISTRY_ID) return generateAdminRegistryModule([...pluginDescriptors, ...resolvedConfig.sandboxed ?? []]);
|
|
1077
|
+
if (id === RESOLVED_VIRTUAL_SANDBOX_RUNNER_ID) return generateSandboxRunnerModule(resolvedConfig.sandboxRunner);
|
|
1078
|
+
if (id === RESOLVED_VIRTUAL_SANDBOXED_PLUGINS_ID) {
|
|
1079
|
+
const projectRoot = fileURLToPath(astroConfig.root);
|
|
1080
|
+
return generateSandboxedPluginsModule(resolvedConfig.sandboxed ?? [], projectRoot);
|
|
1081
|
+
}
|
|
1082
|
+
if (id === RESOLVED_VIRTUAL_AUTH_ID) {
|
|
1083
|
+
const authDescriptor = resolvedConfig.auth;
|
|
1084
|
+
if (!authDescriptor || !("entrypoint" in authDescriptor)) return generateAuthModule(void 0);
|
|
1085
|
+
return generateAuthModule(authDescriptor.entrypoint);
|
|
1086
|
+
}
|
|
1087
|
+
if (id === RESOLVED_VIRTUAL_MEDIA_PROVIDERS_ID) return generateMediaProvidersModule(resolvedConfig.mediaProviders ?? []);
|
|
1088
|
+
if (id === RESOLVED_VIRTUAL_BLOCK_COMPONENTS_ID) return generateBlockComponentsModule(pluginDescriptors);
|
|
1089
|
+
if (id === RESOLVED_VIRTUAL_SEED_ID) return generateSeedModule(fileURLToPath(astroConfig.root));
|
|
1090
|
+
}
|
|
1091
|
+
};
|
|
1092
|
+
}
|
|
1093
|
+
/**
|
|
1094
|
+
* Modules that contain native Node.js addons or Node-only code.
|
|
1095
|
+
* These must be external in SSR to avoid bundling failures on Node.
|
|
1096
|
+
*/
|
|
1097
|
+
const NODE_NATIVE_EXTERNALS = [
|
|
1098
|
+
"better-sqlite3",
|
|
1099
|
+
"bindings",
|
|
1100
|
+
"file-uri-to-path",
|
|
1101
|
+
"@libsql/kysely-libsql",
|
|
1102
|
+
"pg"
|
|
1103
|
+
];
|
|
1104
|
+
/**
|
|
1105
|
+
* Creates the Vite config update for Dineway.
|
|
1106
|
+
*/
|
|
1107
|
+
function createViteConfig(options, command) {
|
|
1108
|
+
const adminDistPath = resolveAdminDist();
|
|
1109
|
+
const adminSourcePath = command === "dev" ? resolveAdminSource() : void 0;
|
|
1110
|
+
const useSource = adminSourcePath !== void 0;
|
|
1111
|
+
const devPlugins = adminSourcePath ? [linguiMacroPlugin(adminSourcePath, adminDistPath)] : [];
|
|
1112
|
+
return {
|
|
1113
|
+
resolve: {
|
|
1114
|
+
dedupe: [
|
|
1115
|
+
"@dineway-ai/admin",
|
|
1116
|
+
"react",
|
|
1117
|
+
"react-dom"
|
|
1118
|
+
],
|
|
1119
|
+
alias: [
|
|
1120
|
+
{
|
|
1121
|
+
find: "@dineway-ai/admin/styles.css",
|
|
1122
|
+
replacement: resolve(adminDistPath, "styles.css")
|
|
1123
|
+
},
|
|
1124
|
+
{
|
|
1125
|
+
find: "@dineway-ai/admin/locales/*",
|
|
1126
|
+
replacement: resolve(adminDistPath, "locales", "*")
|
|
1127
|
+
},
|
|
1128
|
+
{
|
|
1129
|
+
find: "@dineway-ai/admin",
|
|
1130
|
+
replacement: useSource ? adminSourcePath : adminDistPath
|
|
1131
|
+
}
|
|
1132
|
+
]
|
|
1133
|
+
},
|
|
1134
|
+
plugins: [createVirtualModulesPlugin(options), ...useSource ? devPlugins : []],
|
|
1135
|
+
ssr: {
|
|
1136
|
+
external: NODE_NATIVE_EXTERNALS,
|
|
1137
|
+
noExternal: ["dineway", "@dineway-ai/admin"]
|
|
1138
|
+
},
|
|
1139
|
+
optimizeDeps: {
|
|
1140
|
+
include: useSource ? ["@astrojs/react/client.js"] : ["@dineway-ai/admin", "@astrojs/react/client.js"],
|
|
1141
|
+
exclude: [...NODE_NATIVE_EXTERNALS, "virtual:dineway"]
|
|
1142
|
+
}
|
|
1143
|
+
};
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
//#endregion
|
|
1147
|
+
//#region src/astro/integration/runtime.ts
|
|
1148
|
+
/**
|
|
1149
|
+
* Get stored config from global
|
|
1150
|
+
* This is set by the virtual module at build time
|
|
1151
|
+
*/
|
|
1152
|
+
function getStoredConfig() {
|
|
1153
|
+
return globalThis.__dinewayConfig || null;
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
//#endregion
|
|
1157
|
+
//#region src/astro/integration/index.ts
|
|
1158
|
+
/** Default storage: Local filesystem in .dineway directory */
|
|
1159
|
+
const DEFAULT_STORAGE = local({
|
|
1160
|
+
directory: "./.dineway/uploads",
|
|
1161
|
+
baseUrl: "/_dineway/api/media/file"
|
|
1162
|
+
});
|
|
1163
|
+
const dim = (s) => `\x1b[2m${s}\x1b[22m`;
|
|
1164
|
+
const bold = (s) => `\x1b[1m${s}\x1b[22m`;
|
|
1165
|
+
const cyan = (s) => `\x1b[36m${s}\x1b[39m`;
|
|
1166
|
+
/** Print the Dineway startup banner */
|
|
1167
|
+
function printBanner(_logger) {
|
|
1168
|
+
const banner = `
|
|
1169
|
+
|
|
1170
|
+
${bold(cyan("— D I N E W A Y —"))}
|
|
1171
|
+
`;
|
|
1172
|
+
console.log(banner);
|
|
1173
|
+
}
|
|
1174
|
+
/** Print route injection summary */
|
|
1175
|
+
function printRoutesSummary(_logger) {
|
|
1176
|
+
console.log(`\n ${dim("›")} Admin UI ${cyan("/_dineway/admin")}`);
|
|
1177
|
+
console.log(` ${dim("›")} API ${cyan("/_dineway/api/*")}`);
|
|
1178
|
+
console.log("");
|
|
1179
|
+
}
|
|
1180
|
+
/**
|
|
1181
|
+
* Create the Dineway Astro integration
|
|
1182
|
+
*/
|
|
1183
|
+
function dineway(config = {}) {
|
|
1184
|
+
const resolvedConfig = {
|
|
1185
|
+
...config,
|
|
1186
|
+
storage: config.storage ?? DEFAULT_STORAGE
|
|
1187
|
+
};
|
|
1188
|
+
if (resolvedConfig.marketplace) {
|
|
1189
|
+
const url = resolvedConfig.marketplace;
|
|
1190
|
+
try {
|
|
1191
|
+
const parsed = new URL(url);
|
|
1192
|
+
const isLocalhost = parsed.hostname === "localhost" || parsed.hostname === "127.0.0.1";
|
|
1193
|
+
if (parsed.protocol !== "https:" && !isLocalhost) throw new Error(`Marketplace URL must use HTTPS (got ${parsed.protocol}). Only localhost URLs are allowed over HTTP.`);
|
|
1194
|
+
} catch (e) {
|
|
1195
|
+
if (e instanceof TypeError) throw new Error(`Invalid marketplace URL: "${url}"`, { cause: e });
|
|
1196
|
+
throw e;
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
if (resolvedConfig.siteUrl) {
|
|
1200
|
+
const raw = resolvedConfig.siteUrl;
|
|
1201
|
+
try {
|
|
1202
|
+
const parsed = new URL(raw);
|
|
1203
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") throw new Error(`siteUrl must be http or https (got ${parsed.protocol})`);
|
|
1204
|
+
resolvedConfig.siteUrl = parsed.origin;
|
|
1205
|
+
} catch (e) {
|
|
1206
|
+
if (e instanceof TypeError) throw new Error(`Invalid siteUrl: "${raw}"`, { cause: e });
|
|
1207
|
+
throw e;
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
const pluginDescriptors = resolvedConfig.plugins ?? [];
|
|
1211
|
+
const sandboxedDescriptors = resolvedConfig.sandboxed ?? [];
|
|
1212
|
+
for (const descriptor of [...pluginDescriptors, ...sandboxedDescriptors]) if (descriptor.format === "standard") {
|
|
1213
|
+
if (descriptor.adminEntry) throw new Error(`Plugin "${descriptor.id}" is standard format but declares adminEntry. Standard plugins use Block Kit for admin UI, not React components. Remove adminEntry or change format to "native".`);
|
|
1214
|
+
if (descriptor.componentsEntry) throw new Error(`Plugin "${descriptor.id}" is standard format but declares componentsEntry. Portable Text block components require native format. Remove componentsEntry or change format to "native".`);
|
|
1215
|
+
}
|
|
1216
|
+
for (const descriptor of sandboxedDescriptors) if (descriptor.format !== "standard") throw new Error(`Plugin "${descriptor.id}" uses the native format and cannot be placed in \`sandboxed: []\`. Native plugins can only run in \`plugins: []\`. To sandbox this plugin, convert it to the standard format.`);
|
|
1217
|
+
const serializableConfig = {
|
|
1218
|
+
database: resolvedConfig.database,
|
|
1219
|
+
storage: resolvedConfig.storage,
|
|
1220
|
+
auth: resolvedConfig.auth,
|
|
1221
|
+
marketplace: resolvedConfig.marketplace,
|
|
1222
|
+
siteUrl: resolvedConfig.siteUrl
|
|
1223
|
+
};
|
|
1224
|
+
const useExternalAuth = !!(resolvedConfig.auth && "entrypoint" in resolvedConfig.auth);
|
|
1225
|
+
return {
|
|
1226
|
+
name: "dineway",
|
|
1227
|
+
hooks: {
|
|
1228
|
+
"astro:config:setup": ({ injectRoute, addMiddleware, logger, updateConfig, config: astroConfig, command }) => {
|
|
1229
|
+
printBanner(logger);
|
|
1230
|
+
if (astroConfig.i18n) {
|
|
1231
|
+
const routing = astroConfig.i18n.routing;
|
|
1232
|
+
serializableConfig.i18n = {
|
|
1233
|
+
defaultLocale: astroConfig.i18n.defaultLocale,
|
|
1234
|
+
locales: astroConfig.i18n.locales.map((l) => typeof l === "string" ? l : l.path),
|
|
1235
|
+
fallback: astroConfig.i18n.fallback,
|
|
1236
|
+
prefixDefaultLocale: typeof routing === "object" ? routing.prefixDefaultLocale ?? false : false
|
|
1237
|
+
};
|
|
1238
|
+
}
|
|
1239
|
+
updateConfig({
|
|
1240
|
+
security: {
|
|
1241
|
+
checkOrigin: false,
|
|
1242
|
+
...resolvedConfig.siteUrl ? { allowedDomains: [{ hostname: new URL(resolvedConfig.siteUrl).hostname }] } : {}
|
|
1243
|
+
},
|
|
1244
|
+
vite: createViteConfig({
|
|
1245
|
+
serializableConfig,
|
|
1246
|
+
resolvedConfig,
|
|
1247
|
+
pluginDescriptors,
|
|
1248
|
+
astroConfig
|
|
1249
|
+
}, command)
|
|
1250
|
+
});
|
|
1251
|
+
injectCoreRoutes(injectRoute);
|
|
1252
|
+
if (!useExternalAuth) injectBuiltinAuthRoutes(injectRoute);
|
|
1253
|
+
if (resolvedConfig.mcp) {
|
|
1254
|
+
injectMcpRoute(injectRoute);
|
|
1255
|
+
logger.info("MCP server enabled at /_dineway/api/mcp");
|
|
1256
|
+
}
|
|
1257
|
+
if (resolvedConfig.playground) addMiddleware({
|
|
1258
|
+
entrypoint: resolvedConfig.playground.middlewareEntrypoint,
|
|
1259
|
+
order: "pre"
|
|
1260
|
+
});
|
|
1261
|
+
addMiddleware({
|
|
1262
|
+
entrypoint: "dineway/middleware",
|
|
1263
|
+
order: "pre"
|
|
1264
|
+
});
|
|
1265
|
+
addMiddleware({
|
|
1266
|
+
entrypoint: "dineway/middleware/redirect",
|
|
1267
|
+
order: "pre"
|
|
1268
|
+
});
|
|
1269
|
+
if (!resolvedConfig.playground) {
|
|
1270
|
+
addMiddleware({
|
|
1271
|
+
entrypoint: "dineway/middleware/setup",
|
|
1272
|
+
order: "pre"
|
|
1273
|
+
});
|
|
1274
|
+
addMiddleware({
|
|
1275
|
+
entrypoint: "dineway/middleware/auth",
|
|
1276
|
+
order: "pre"
|
|
1277
|
+
});
|
|
1278
|
+
}
|
|
1279
|
+
addMiddleware({
|
|
1280
|
+
entrypoint: "dineway/middleware/request-context",
|
|
1281
|
+
order: "pre"
|
|
1282
|
+
});
|
|
1283
|
+
printRoutesSummary(logger);
|
|
1284
|
+
},
|
|
1285
|
+
"astro:server:setup": ({ server, logger }) => {
|
|
1286
|
+
server.httpServer?.once("listening", async () => {
|
|
1287
|
+
const { writeFile, readFile } = await import("node:fs/promises");
|
|
1288
|
+
const { resolve } = await import("node:path");
|
|
1289
|
+
const address = server.httpServer?.address();
|
|
1290
|
+
if (!address || typeof address === "string") return;
|
|
1291
|
+
const typegenUrl = `http://localhost:${address.port}/_dineway/api/typegen`;
|
|
1292
|
+
const outputPath = resolve(process.cwd(), "dineway-env.d.ts");
|
|
1293
|
+
try {
|
|
1294
|
+
const response = await fetch(typegenUrl, {
|
|
1295
|
+
method: "POST",
|
|
1296
|
+
headers: { "Content-Type": "application/json" }
|
|
1297
|
+
});
|
|
1298
|
+
if (!response.ok) {
|
|
1299
|
+
const body = await response.text().catch(() => "");
|
|
1300
|
+
logger.warn(`Typegen failed: ${response.status} ${body.slice(0, 200)}`);
|
|
1301
|
+
return;
|
|
1302
|
+
}
|
|
1303
|
+
const { data: result } = await response.json();
|
|
1304
|
+
let needsWrite = true;
|
|
1305
|
+
try {
|
|
1306
|
+
if (await readFile(outputPath, "utf-8") === result.types) needsWrite = false;
|
|
1307
|
+
} catch {}
|
|
1308
|
+
if (needsWrite) {
|
|
1309
|
+
await writeFile(outputPath, result.types, "utf-8");
|
|
1310
|
+
logger.info(`Generated dineway-env.d.ts (${result.collections} collections)`);
|
|
1311
|
+
}
|
|
1312
|
+
} catch (error) {
|
|
1313
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
1314
|
+
logger.warn(`Typegen failed: ${msg}`);
|
|
1315
|
+
}
|
|
1316
|
+
});
|
|
1317
|
+
},
|
|
1318
|
+
"astro:build:done": ({ logger }) => {
|
|
1319
|
+
logger.info("Build complete");
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
};
|
|
1323
|
+
}
|
|
1324
|
+
|
|
1325
|
+
//#endregion
|
|
1326
|
+
export { dineway as default, getStoredConfig, local, s3 };
|