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.
Files changed (96) hide show
  1. package/LICENSE +9 -0
  2. package/README.md +89 -0
  3. package/dist/adapters-BlzWJG82.d.mts +106 -0
  4. package/dist/apply-CAPvMfoU.mjs +1339 -0
  5. package/dist/astro/index.d.mts +50 -0
  6. package/dist/astro/index.mjs +1326 -0
  7. package/dist/astro/middleware/auth.d.mts +30 -0
  8. package/dist/astro/middleware/auth.mjs +708 -0
  9. package/dist/astro/middleware/redirect.d.mts +21 -0
  10. package/dist/astro/middleware/redirect.mjs +62 -0
  11. package/dist/astro/middleware/request-context.d.mts +17 -0
  12. package/dist/astro/middleware/request-context.mjs +1371 -0
  13. package/dist/astro/middleware/setup.d.mts +19 -0
  14. package/dist/astro/middleware/setup.mjs +46 -0
  15. package/dist/astro/middleware.d.mts +12 -0
  16. package/dist/astro/middleware.mjs +1716 -0
  17. package/dist/astro/types.d.mts +269 -0
  18. package/dist/astro/types.mjs +1 -0
  19. package/dist/base64-F8-DUraK.mjs +58 -0
  20. package/dist/byline-DeWCMU_i.mjs +234 -0
  21. package/dist/bylines-DyqBV9EQ.mjs +137 -0
  22. package/dist/chunk-ClPoSABd.mjs +21 -0
  23. package/dist/cli/index.d.mts +1 -0
  24. package/dist/cli/index.mjs +3987 -0
  25. package/dist/client/external-auth-headers.d.mts +38 -0
  26. package/dist/client/external-auth-headers.mjs +101 -0
  27. package/dist/client/index.d.mts +397 -0
  28. package/dist/client/index.mjs +345 -0
  29. package/dist/config-Cq8H0SfX.mjs +46 -0
  30. package/dist/connection-C9pxzuag.mjs +52 -0
  31. package/dist/content-zSgdNmnt.mjs +836 -0
  32. package/dist/db/index.d.mts +4 -0
  33. package/dist/db/index.mjs +62 -0
  34. package/dist/db/libsql.d.mts +10 -0
  35. package/dist/db/libsql.mjs +21 -0
  36. package/dist/db/postgres.d.mts +10 -0
  37. package/dist/db/postgres.mjs +29 -0
  38. package/dist/db/sqlite.d.mts +10 -0
  39. package/dist/db/sqlite.mjs +15 -0
  40. package/dist/default-WYlzADZL.mjs +80 -0
  41. package/dist/dialect-helpers-B9uSp2GJ.mjs +89 -0
  42. package/dist/error-DrxtnGPg.mjs +26 -0
  43. package/dist/index-C-jx21qs.d.mts +4771 -0
  44. package/dist/index.d.mts +16 -0
  45. package/dist/index.mjs +30 -0
  46. package/dist/load-C6FCD1FU.mjs +27 -0
  47. package/dist/loader-qKmo0wAY.mjs +446 -0
  48. package/dist/manifest-schema-CTSEyIJ3.mjs +186 -0
  49. package/dist/media/index.d.mts +25 -0
  50. package/dist/media/index.mjs +54 -0
  51. package/dist/media/local-runtime.d.mts +38 -0
  52. package/dist/media/local-runtime.mjs +132 -0
  53. package/dist/media-DMTr80Gv.mjs +199 -0
  54. package/dist/mode-BlyYtIFO.mjs +22 -0
  55. package/dist/page/index.d.mts +148 -0
  56. package/dist/page/index.mjs +419 -0
  57. package/dist/placeholder-B3knXwNc.mjs +267 -0
  58. package/dist/placeholder-bOx1xCTY.d.mts +283 -0
  59. package/dist/plugin-utils.d.mts +57 -0
  60. package/dist/plugin-utils.mjs +77 -0
  61. package/dist/plugins/adapt-sandbox-entry.d.mts +21 -0
  62. package/dist/plugins/adapt-sandbox-entry.mjs +112 -0
  63. package/dist/query-BiaPl_g2.mjs +459 -0
  64. package/dist/redirect-JPqLAbxa.mjs +328 -0
  65. package/dist/registry-DSd1GWB8.mjs +851 -0
  66. package/dist/request-context.d.mts +49 -0
  67. package/dist/request-context.mjs +42 -0
  68. package/dist/runner-B5l1JfOj.d.mts +26 -0
  69. package/dist/runner-BGUGywgG.mjs +1529 -0
  70. package/dist/runtime.d.mts +25 -0
  71. package/dist/runtime.mjs +41 -0
  72. package/dist/search-BNruJHDL.mjs +11054 -0
  73. package/dist/seed/index.d.mts +3 -0
  74. package/dist/seed/index.mjs +15 -0
  75. package/dist/seo/index.d.mts +69 -0
  76. package/dist/seo/index.mjs +69 -0
  77. package/dist/storage/local.d.mts +38 -0
  78. package/dist/storage/local.mjs +165 -0
  79. package/dist/storage/s3.d.mts +31 -0
  80. package/dist/storage/s3.mjs +174 -0
  81. package/dist/tokens-4vgYuXsZ.mjs +170 -0
  82. package/dist/transport-C5FYnid7.mjs +417 -0
  83. package/dist/transport-gIL-e43D.d.mts +41 -0
  84. package/dist/types-BawVha09.mjs +30 -0
  85. package/dist/types-BgQeVaPj.d.mts +192 -0
  86. package/dist/types-CLLdsG3g.d.mts +103 -0
  87. package/dist/types-D38djUXv.d.mts +1196 -0
  88. package/dist/types-DShnjzb6.mjs +15 -0
  89. package/dist/types-DkvMXalq.d.mts +425 -0
  90. package/dist/types-DuNbGKjF.mjs +74 -0
  91. package/dist/types-ju-_ORz7.d.mts +182 -0
  92. package/dist/validate-CXnRKfJK.mjs +327 -0
  93. package/dist/validate-CqRJb_xU.mjs +96 -0
  94. package/dist/validate-DVKJJ-M_.d.mts +377 -0
  95. package/locals.d.ts +47 -0
  96. package/package.json +313 -0
@@ -0,0 +1,21 @@
1
+ import * as astro from "astro";
2
+
3
+ //#region src/astro/middleware/redirect.d.ts
4
+ /**
5
+ * Redirect middleware
6
+ *
7
+ * Intercepts incoming requests and checks for matching redirect rules.
8
+ * Runs after runtime init (needs db) but before setup/auth (should handle
9
+ * ALL routes, including public ones, and should be fast).
10
+ *
11
+ * Skip paths:
12
+ * - /_dineway/* (admin UI, API routes, auth endpoints)
13
+ * - /_image (Astro image optimization)
14
+ * - Static assets (files with extensions)
15
+ *
16
+ * 404 logging happens post-response: if next() returns 404 and the path
17
+ * wasn't already matched by a redirect, log it.
18
+ */
19
+ declare const onRequest: astro.MiddlewareHandler;
20
+ //#endregion
21
+ export { onRequest };
@@ -0,0 +1,62 @@
1
+ import "../../dialect-helpers-B9uSp2GJ.mjs";
2
+ import "../../base64-F8-DUraK.mjs";
3
+ import "../../types-BawVha09.mjs";
4
+ import { t as RedirectRepository } from "../../redirect-JPqLAbxa.mjs";
5
+ import { defineMiddleware } from "astro:middleware";
6
+
7
+ //#region src/astro/middleware/redirect.ts
8
+ /**
9
+ * Redirect middleware
10
+ *
11
+ * Intercepts incoming requests and checks for matching redirect rules.
12
+ * Runs after runtime init (needs db) but before setup/auth (should handle
13
+ * ALL routes, including public ones, and should be fast).
14
+ *
15
+ * Skip paths:
16
+ * - /_dineway/* (admin UI, API routes, auth endpoints)
17
+ * - /_image (Astro image optimization)
18
+ * - Static assets (files with extensions)
19
+ *
20
+ * 404 logging happens post-response: if next() returns 404 and the path
21
+ * wasn't already matched by a redirect, log it.
22
+ */
23
+ /** Paths that should never be intercepted by redirects */
24
+ const SKIP_PREFIXES = ["/_dineway", "/_image"];
25
+ /** Static asset extensions -- don't redirect file requests */
26
+ const ASSET_EXTENSION = /\.\w{1,10}$/;
27
+ function isRedirectCode(code) {
28
+ return code === 301 || code === 302 || code === 303 || code === 307 || code === 308;
29
+ }
30
+ const onRequest = defineMiddleware(async (context, next) => {
31
+ const { pathname } = context.url;
32
+ if (SKIP_PREFIXES.some((prefix) => pathname.startsWith(prefix))) return next();
33
+ if (ASSET_EXTENSION.test(pathname)) return next();
34
+ const { dineway } = context.locals;
35
+ if (!dineway?.db) return next();
36
+ try {
37
+ const repo = new RedirectRepository(dineway.db);
38
+ const match = await repo.matchPath(pathname);
39
+ if (match) {
40
+ if (match.resolvedDestination.startsWith("//") || match.resolvedDestination.startsWith("/\\")) return next();
41
+ repo.recordHit(match.redirect.id).catch(() => {});
42
+ const code = isRedirectCode(match.redirect.type) ? match.redirect.type : 301;
43
+ return context.redirect(match.resolvedDestination, code);
44
+ }
45
+ const response = await next();
46
+ if (response.status === 404) {
47
+ const referrer = context.request.headers.get("referer") ?? null;
48
+ const userAgent = context.request.headers.get("user-agent") ?? null;
49
+ repo.log404({
50
+ path: pathname,
51
+ referrer,
52
+ userAgent
53
+ }).catch(() => {});
54
+ }
55
+ return response;
56
+ } catch {
57
+ return next();
58
+ }
59
+ });
60
+
61
+ //#endregion
62
+ export { onRequest };
@@ -0,0 +1,17 @@
1
+ import * as astro from "astro";
2
+
3
+ //#region src/astro/middleware/request-context.d.ts
4
+ /**
5
+ * Dineway Request Context Middleware
6
+ *
7
+ * Sets up AsyncLocalStorage-based request context for query functions.
8
+ * Skips ALS entirely for logged-out users with no CMS signals (fast path).
9
+ *
10
+ * Handles:
11
+ * - Preview tokens: _preview query param with signed HMAC token
12
+ * - Edit mode: dineway-edit-mode cookie (for visual editing)
13
+ * - Toolbar injection: floating pill for authenticated editors
14
+ */
15
+ declare const onRequest: astro.MiddlewareHandler;
16
+ //#endregion
17
+ export { onRequest as default, onRequest };