@contello/astro 4.3.0 → 4.4.0
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/dist/index.cjs +34 -4
- package/dist/index.d.cts +2 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +32 -2
- package/dist/index.js.map +1 -1
- package/package.json +12 -12
package/dist/index.cjs
CHANGED
|
@@ -5,10 +5,14 @@ let _astroscope_node_boot = require("@astroscope/node/boot");
|
|
|
5
5
|
let _contello_media = require("@contello/media");
|
|
6
6
|
let _contello_store = require("@contello/store");
|
|
7
7
|
let _astroscope_node_log = require("@astroscope/node/log");
|
|
8
|
-
let astro_middleware = require("astro/middleware");
|
|
9
8
|
let _contello_opentelemetry = require("@contello/opentelemetry");
|
|
10
9
|
let _astroscope_node_excludes = require("@astroscope/node/excludes");
|
|
11
10
|
let _entwico_dash = require("@entwico/dash");
|
|
11
|
+
//#region src/middleware.ts
|
|
12
|
+
function defineMiddleware(handler) {
|
|
13
|
+
return handler;
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
12
16
|
//#region src/telemetry.ts
|
|
13
17
|
const { wrap } = (0, _contello_opentelemetry.createOperationTelemetry)("@contello/astro");
|
|
14
18
|
//#endregion
|
|
@@ -20,7 +24,7 @@ function createBoundAssetsMiddleware(contello, options) {
|
|
|
20
24
|
const filesPrefix = contello.media.filesPath;
|
|
21
25
|
const filesCacheControl = options?.files?.cacheControl;
|
|
22
26
|
const videoPrefix = contello.media.videosPath;
|
|
23
|
-
return
|
|
27
|
+
return defineMiddleware((ctx, next) => {
|
|
24
28
|
const { pathname } = ctx.url;
|
|
25
29
|
const isImage = pathname.startsWith(imagesPrefix);
|
|
26
30
|
const isFile = !isImage && pathname.startsWith(filesPrefix);
|
|
@@ -102,7 +106,7 @@ function markRequestRoute(route) {
|
|
|
102
106
|
} });
|
|
103
107
|
}
|
|
104
108
|
function createBoundRoutingMiddleware(contello, routes, exclude, resolveRoutePath) {
|
|
105
|
-
return
|
|
109
|
+
return defineMiddleware((ctx, next) => {
|
|
106
110
|
if ((0, _astroscope_node_excludes.shouldExclude)(ctx, exclude ?? _astroscope_node_excludes.RECOMMENDED_EXCLUDES)) return next();
|
|
107
111
|
if (!contello.isReady) {
|
|
108
112
|
console.warn(`[@contello/astro] not initialized, passing through: ${ctx.url.pathname}`);
|
|
@@ -115,7 +119,8 @@ function createBoundRoutingMiddleware(contello, routes, exclude, resolveRoutePat
|
|
|
115
119
|
rewritten: false
|
|
116
120
|
}, () => next());
|
|
117
121
|
const path = resolveRoutePath ? resolveRoutePath(ctx) : url.pathname;
|
|
118
|
-
|
|
122
|
+
const lookup = routes.getByPath(path);
|
|
123
|
+
return (0, _entwico_dash.maybeThen)(lookup, (route) => {
|
|
119
124
|
if (!route) return contello[runRequest]({
|
|
120
125
|
url,
|
|
121
126
|
route: void 0,
|
|
@@ -157,6 +162,31 @@ function createBoundRoutingMiddleware(contello, routes, exclude, resolveRoutePat
|
|
|
157
162
|
for (const { name, value } of route.customHeaders) headers.set(name, value);
|
|
158
163
|
return new Response(result.stream(), { headers });
|
|
159
164
|
}));
|
|
165
|
+
case "sitemap": return contello[runRequest]({
|
|
166
|
+
url,
|
|
167
|
+
route,
|
|
168
|
+
rewritten: false
|
|
169
|
+
}, () => wrap("route:sitemap", async () => {
|
|
170
|
+
const result = await contello.client.proxySitemap(route.sitemapId, {
|
|
171
|
+
source: url.searchParams.get("source") ?? void 0,
|
|
172
|
+
page: url.searchParams.get("page") ?? void 0,
|
|
173
|
+
acceptEncoding: ctx.request.headers.get("accept-encoding") ?? void 0,
|
|
174
|
+
ifNoneMatch: ctx.request.headers.get("if-none-match") ?? void 0
|
|
175
|
+
}, ctx.request.signal);
|
|
176
|
+
if (!(result.status === 304 || result.status >= 200 && result.status < 300)) {
|
|
177
|
+
await result.stream().cancel();
|
|
178
|
+
return new Response(null, {
|
|
179
|
+
status: result.status,
|
|
180
|
+
headers: customHeaders(route.customHeaders)
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
const headers = new Headers(result.headers);
|
|
184
|
+
for (const { name, value } of route.customHeaders) headers.set(name, value);
|
|
185
|
+
return new Response(result.status === 304 ? null : result.stream(), {
|
|
186
|
+
status: result.status,
|
|
187
|
+
headers
|
|
188
|
+
});
|
|
189
|
+
}));
|
|
160
190
|
case "entity": return contello[runRequest]({
|
|
161
191
|
url,
|
|
162
192
|
route,
|
package/dist/index.d.cts
CHANGED
|
@@ -4,7 +4,6 @@ import { Assets, AssetsOptions, AssetsSync, AssetsSyncOptions, BuiltInWrites, Co
|
|
|
4
4
|
import { ReadonlyDeep } from "@entwico/dash";
|
|
5
5
|
import { ExcludePattern } from "@astroscope/node/excludes";
|
|
6
6
|
import { APIContext } from "astro";
|
|
7
|
-
|
|
8
7
|
//#region src/assets-middleware.d.ts
|
|
9
8
|
type ContelloAssetsImagesOptions = {
|
|
10
9
|
cacheControl?: string | undefined;
|
|
@@ -58,7 +57,8 @@ type ContelloI18nOptions = {
|
|
|
58
57
|
type ContelloInitOptions = {
|
|
59
58
|
load?: Loadable[] | undefined;
|
|
60
59
|
i18n?: {
|
|
61
|
-
/** defaults to `true`, except in dev mode (detected via the @astroscope/node boot context) */
|
|
60
|
+
/** defaults to `true`, except in dev mode (detected via the @astroscope/node boot context) */
|
|
61
|
+
register?: boolean | undefined;
|
|
62
62
|
load?: boolean | undefined;
|
|
63
63
|
} | undefined;
|
|
64
64
|
};
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/assets-middleware.ts","../src/routing-middleware.ts","../src/contello.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/assets-middleware.ts","../src/routing-middleware.ts","../src/contello.ts"],"mappings":";;;;;;;KAMY;EACV;;KAGU;EACV;;KAGU,6BAA6B;KAE7B;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a,aAAa,UAAU,UAAU,aAAa,SAAS,OACtF,aAAa,MACb,UAAU,qBAAqB,aAAa,SAAS,OAAO,SAAS,SAAS,YAC7E,cAAc;EAIjB,iBACE,aAAa,cAAc,UAC3B;IAAkB;MAAe,cAAc,SAAS;IAAU;KAElE,aAAa,MACb,UAAU,kBAAkB,cAAc,SAAS,OAAO,SAAS,SAAS,YAC3E,WAAW,SAAS,mBAAmB,SAAS;EAOnD,qBACE,aAAa,cAAc,UAC3B;IAAkB;MAAe,cAAc,SAAS;IAAU;KAElE,aAAa,MACb,UAAU,sBAAsB,cAAc,SAAS,OAAO,SAAS,SAAS,YAC/E,eAAe,SAAS,mBAAmB,SAAS;EAOvD,qBACE,aAAa,cAAc,UAC3B;IAAkB;MAAe,cAAc,SAAS;IAAU;KAElE,aAAa,MACb,UAAU,sBAAsB,cAAc,SAAS,OAAO,SAAS,SAAS,YAC/E,eAAe;EAIlB,aAAa,UAAU,4BAA4B,OAAO,YAAY;EAItE,iBAAiB,UAAU,gCAAgC,WAAW,YAAY;EAIlF,iBAAiB,UAAU,gCAAgC;EAI3D,aAAa,UAAU,4BAA4B,OAAO,YAAY;EAItE,iBAAiB,UAAU,gCAAgC,WAAW,YAAY;EAIlF,iBAAiB,UAAU,gCAAgC;GAM1D,YAAY,GAAG,KAAK,wBAAwB,UAAU,IAAI;;iBAK7C,eAAe,gBAAgB,gCAC7C,SAAS,gBAAgB,WACxB,SAAS"}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,6 @@ import { ExcludePattern } from "@astroscope/node/excludes";
|
|
|
4
4
|
import { ReadonlyDeep } from "@entwico/dash";
|
|
5
5
|
import { ContelloClient, Schema, SourceDef } from "@contello/client";
|
|
6
6
|
import { APIContext } from "astro";
|
|
7
|
-
|
|
8
7
|
//#region src/assets-middleware.d.ts
|
|
9
8
|
type ContelloAssetsImagesOptions = {
|
|
10
9
|
cacheControl?: string | undefined;
|
|
@@ -58,7 +57,8 @@ type ContelloI18nOptions = {
|
|
|
58
57
|
type ContelloInitOptions = {
|
|
59
58
|
load?: Loadable[] | undefined;
|
|
60
59
|
i18n?: {
|
|
61
|
-
/** defaults to `true`, except in dev mode (detected via the @astroscope/node boot context) */
|
|
60
|
+
/** defaults to `true`, except in dev mode (detected via the @astroscope/node boot context) */
|
|
61
|
+
register?: boolean | undefined;
|
|
62
62
|
load?: boolean | undefined;
|
|
63
63
|
} | undefined;
|
|
64
64
|
};
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/assets-middleware.ts","../src/routing-middleware.ts","../src/contello.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/assets-middleware.ts","../src/routing-middleware.ts","../src/contello.ts"],"mappings":";;;;;;;KAMY;EACV;;KAGU;EACV;;KAGU,6BAA6B;KAE7B;EACV,SAAS;EACT,QAAQ;EACR,QAAQ;;;;KCTE,YAAY,SAAS,aAAa;;;;;;;;;;KAWlC,qBAAqB,KAAK;KAE1B;;;;;;;;EAQV,SAAS;EACT,UAAU;EACV,mBAAmB;;;;KCiBT;EACV,KAAK;EACL,OAAO,aAAa;EACpB;;KAGU;EACV;EACA;EACA,QAAQ;;KAGE;EACV,OAAO;EACP;;IAGI;IACA;;;KAKM;WACD;WACA;WACA;WACA;;KAGC,gBAAgB,gBAAgB,kCAAkC,mBAAmB;EAC/F,OAAO;EACP,QAAQ,QAAQ;;KAGb,YAAY,KAAK;EAAY,gBAAgB;MAAQ;cAE7C;KA2CR,SAAS,WAAW;EAAkB,cAAc;UAAY;KAChE,cAAc,WAAW,aAAa,qBAAqB,UAAU,SAAS;KAC9E,aAAa,WAAW,aAAa,wBAAwB,UAAU,SAAS;KAChF,cAAc,SAAS,QAAQ,oBAClC,QAAQ,cAAc,SAAS,OAAO;;KAGnC,mBAAmB,SAAS,QAAQ,oBACvC,QAAQ,cAAc,SAAS,OAAO;KAEnC,YAAY,WAAW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C;EAI3D,aAAa,UAAU,4BAA4B,OAAO,YAAY;EAItE,iBAAiB,UAAU,gCAAgC,WAAW,YAAY;EAIlF,iBAAiB,UAAU,gCAAgC;GAM1D,YAAY,GAAG,KAAK,wBAAwB,UAAU,IAAI;;iBAK7C,eAAe,gBAAgB,gCAC7C,SAAS,gBAAgB,WACxB,SAAS"}
|
package/dist/index.js
CHANGED
|
@@ -4,10 +4,14 @@ import { getBootContext } from "@astroscope/node/boot";
|
|
|
4
4
|
import { createMediaResolver } from "@contello/media";
|
|
5
5
|
import { createStore } from "@contello/store";
|
|
6
6
|
import { overrideRequestRoute } from "@astroscope/node/log";
|
|
7
|
-
import { defineMiddleware } from "astro/middleware";
|
|
8
7
|
import { createOperationTelemetry, updateActiveSpan } from "@contello/opentelemetry";
|
|
9
8
|
import { RECOMMENDED_EXCLUDES, shouldExclude } from "@astroscope/node/excludes";
|
|
10
9
|
import { maybeThen } from "@entwico/dash";
|
|
10
|
+
//#region src/middleware.ts
|
|
11
|
+
function defineMiddleware(handler) {
|
|
12
|
+
return handler;
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
11
15
|
//#region src/telemetry.ts
|
|
12
16
|
const { wrap } = createOperationTelemetry("@contello/astro");
|
|
13
17
|
//#endregion
|
|
@@ -114,7 +118,8 @@ function createBoundRoutingMiddleware(contello, routes, exclude, resolveRoutePat
|
|
|
114
118
|
rewritten: false
|
|
115
119
|
}, () => next());
|
|
116
120
|
const path = resolveRoutePath ? resolveRoutePath(ctx) : url.pathname;
|
|
117
|
-
|
|
121
|
+
const lookup = routes.getByPath(path);
|
|
122
|
+
return maybeThen(lookup, (route) => {
|
|
118
123
|
if (!route) return contello[runRequest]({
|
|
119
124
|
url,
|
|
120
125
|
route: void 0,
|
|
@@ -156,6 +161,31 @@ function createBoundRoutingMiddleware(contello, routes, exclude, resolveRoutePat
|
|
|
156
161
|
for (const { name, value } of route.customHeaders) headers.set(name, value);
|
|
157
162
|
return new Response(result.stream(), { headers });
|
|
158
163
|
}));
|
|
164
|
+
case "sitemap": return contello[runRequest]({
|
|
165
|
+
url,
|
|
166
|
+
route,
|
|
167
|
+
rewritten: false
|
|
168
|
+
}, () => wrap("route:sitemap", async () => {
|
|
169
|
+
const result = await contello.client.proxySitemap(route.sitemapId, {
|
|
170
|
+
source: url.searchParams.get("source") ?? void 0,
|
|
171
|
+
page: url.searchParams.get("page") ?? void 0,
|
|
172
|
+
acceptEncoding: ctx.request.headers.get("accept-encoding") ?? void 0,
|
|
173
|
+
ifNoneMatch: ctx.request.headers.get("if-none-match") ?? void 0
|
|
174
|
+
}, ctx.request.signal);
|
|
175
|
+
if (!(result.status === 304 || result.status >= 200 && result.status < 300)) {
|
|
176
|
+
await result.stream().cancel();
|
|
177
|
+
return new Response(null, {
|
|
178
|
+
status: result.status,
|
|
179
|
+
headers: customHeaders(route.customHeaders)
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
const headers = new Headers(result.headers);
|
|
183
|
+
for (const { name, value } of route.customHeaders) headers.set(name, value);
|
|
184
|
+
return new Response(result.status === 304 ? null : result.stream(), {
|
|
185
|
+
status: result.status,
|
|
186
|
+
headers
|
|
187
|
+
});
|
|
188
|
+
}));
|
|
159
189
|
case "entity": return contello[runRequest]({
|
|
160
190
|
url,
|
|
161
191
|
route,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/telemetry.ts","../src/assets-middleware.ts","../src/routing-middleware.ts","../src/contello.ts"],"sourcesContent":["import { createOperationTelemetry } from '@contello/opentelemetry';\n\nexport const { wrap } = createOperationTelemetry('@contello/astro');\n","import { overrideRequestRoute } from '@astroscope/node/log';\nimport type { ContelloClient } from '@contello/client';\nimport { defineMiddleware } from 'astro/middleware';\nimport type { Contello } from './contello';\nimport { wrap } from './telemetry';\n\nexport type ContelloAssetsImagesOptions = {\n cacheControl?: string | undefined;\n};\n\nexport type ContelloAssetsFilesOptions = {\n cacheControl?: string | undefined;\n};\n\nexport type ContelloAssetsVideoOptions = Record<string, never>;\n\nexport type ContelloAssetsMiddlewareOptions = {\n images?: ContelloAssetsImagesOptions | undefined;\n files?: ContelloAssetsFilesOptions | undefined;\n video?: ContelloAssetsVideoOptions | undefined;\n};\n\nconst DEFAULT_IMAGES_CACHE_CONTROL = 'public, max-age=31536000';\n\nexport function createBoundAssetsMiddleware(\n contello: Contello<any>,\n options: ContelloAssetsMiddlewareOptions | undefined,\n) {\n const imagesPrefix = contello.media.imagesPath;\n const imagesCacheControl = options?.images?.cacheControl ?? DEFAULT_IMAGES_CACHE_CONTROL;\n const filesPrefix = contello.media.filesPath;\n const filesCacheControl = options?.files?.cacheControl;\n const videoPrefix = contello.media.videosPath;\n\n return defineMiddleware((ctx, next) => {\n const { pathname } = ctx.url;\n const isImage = pathname.startsWith(imagesPrefix);\n const isFile = !isImage && pathname.startsWith(filesPrefix);\n const isVideo = !isImage && !isFile && pathname.startsWith(videoPrefix);\n\n if (!isImage && !isFile && !isVideo) {\n return next();\n }\n\n if (!contello.isReady) {\n console.warn(`[@contello/astro] not initialized, passing through: ${pathname}`);\n\n return next();\n }\n\n if (isImage) {\n return handleFile(\n contello.client,\n next,\n pathname.slice(imagesPrefix.length),\n imagesCacheControl,\n `${imagesPrefix}[file]`,\n );\n }\n\n if (isFile) {\n return handleFile(\n contello.client,\n next,\n pathname.slice(filesPrefix.length),\n filesCacheControl,\n `${filesPrefix}[file]`,\n );\n }\n\n return handleVideo(\n contello.client,\n next,\n pathname.slice(videoPrefix.length),\n ctx.request.signal,\n `${videoPrefix}[...path]`,\n );\n });\n}\n\nfunction handleFile(\n client: ContelloClient<any>,\n next: () => Response | Promise<Response>,\n rest: string,\n cacheControl: string | undefined,\n routeLabel: string,\n) {\n const dot = rest.indexOf('.');\n const fileId = dot === -1 ? rest : rest.slice(0, dot);\n\n if (!fileId) {\n return next();\n }\n\n overrideRequestRoute(routeLabel);\n\n return (async () => {\n try {\n const result = await wrap('assets:file', () => client.download(fileId));\n const headers = new Headers({ 'content-type': result.mimeType });\n\n if (cacheControl) {\n headers.set('cache-control', cacheControl);\n }\n\n if (result.size > 0) {\n headers.set('content-length', String(result.size));\n }\n\n return new Response(result.stream(), { headers });\n } catch {\n return new Response(null, { status: 404 });\n }\n })();\n}\n\nfunction handleVideo(\n client: ContelloClient<any>,\n next: () => Response | Promise<Response>,\n path: string,\n signal: AbortSignal,\n routeLabel: string,\n) {\n if (!path) {\n return next();\n }\n\n overrideRequestRoute(routeLabel);\n\n return (async () => {\n try {\n const result = await wrap('assets:hls', () => client.proxyHls(path, signal));\n\n return new Response(result.stream(), { status: result.status, headers: result.headers });\n } catch {\n return new Response('Upstream is down', { status: 502, headers: { 'content-type': 'text/plain' } });\n }\n })();\n}\n","import { type ExcludePattern, RECOMMENDED_EXCLUDES, shouldExclude } from '@astroscope/node/excludes';\nimport { overrideRequestRoute } from '@astroscope/node/log';\nimport { updateActiveSpan } from '@contello/opentelemetry';\nimport type { LazyRoutes, Routes, RoutesSync, StoreRoute, StoreRouteCustomHeader } from '@contello/store';\nimport { type MaybePromise, maybeThen } from '@entwico/dash';\nimport type { APIContext, ValidRedirectStatus } from 'astro';\nimport { defineMiddleware } from 'astro/middleware';\nimport { type Contello, runRequest } from './contello';\nimport { wrap } from './telemetry';\n\nexport type AnyRoutes = Routes | RoutesSync | LazyRoutes;\n\n/**\n * Derives the path used to look up a Contello route from the request context.\n *\n * @default `(ctx) => ctx.url.pathname`\n *\n * ```ts\n * resolveRoutePath: (ctx) => `/${ctx.url.hostname}${ctx.url.pathname}`\n * ```\n */\nexport type RoutePathResolver = (ctx: APIContext) => string;\n\nexport type ContelloRoutingMiddlewareOptions = {\n /**\n * Routes instance backing the middleware.\n *\n * Defaults to a `LazyRoutes` instance managed by contello (fetched on demand, no init-time load).\n * For eager routing, create a `RoutesSync` via `contello.defineRoutesSync()`, add it to\n * `contello.init({ load: [routes] })`, and pass that same instance here.\n */\n routes?: AnyRoutes | undefined;\n exclude?: ExcludePattern[] | undefined;\n resolveRoutePath?: RoutePathResolver | undefined;\n};\n\nfunction customHeaders(headers: readonly StoreRouteCustomHeader[]): Record<string, string> {\n const result: Record<string, string> = {};\n\n for (const h of headers) {\n result[h.name] = h.value;\n }\n\n return result;\n}\n\nconst VALID_REDIRECT_STATUSES = new Set([301, 302, 303, 307, 308]);\n\nfunction toRedirectStatus(status: number): ValidRedirectStatus {\n return (VALID_REDIRECT_STATUSES.has(status) ? status : 302) as ValidRedirectStatus;\n}\n\n/**\n * Astro's routing matches the 404 fallback for paths only contello knows how to\n * serve, so report what contello resolved: `overrideRequestRoute` corrects the\n * request log line, the request duration metric and the server span name\n * together, then record the contello-specific attributes on top.\n */\nfunction markRequestRoute(route: StoreRoute): void {\n overrideRequestRoute(\n route.type === 'entity' ? `/contello/entities/${route.model}/[id]` : `contello:route:${route.type}`,\n );\n\n updateActiveSpan({\n attributes: {\n 'contello.route.type': route.type,\n 'contello.route.path': route.path,\n ...(route.type === 'entity' && { 'contello.route.model': route.model }),\n },\n });\n}\n\nexport function createBoundRoutingMiddleware(\n contello: Contello<any>,\n routes: AnyRoutes,\n exclude: ExcludePattern[] | undefined,\n resolveRoutePath: RoutePathResolver | undefined,\n) {\n return defineMiddleware((ctx, next) => {\n if (shouldExclude(ctx, exclude ?? RECOMMENDED_EXCLUDES)) {\n return next();\n }\n\n if (!contello.isReady) {\n console.warn(`[@contello/astro] not initialized, passing through: ${ctx.url.pathname}`);\n\n return next();\n }\n\n const { url } = ctx;\n\n if (url.pathname.startsWith('/contello/entities/')) {\n return contello[runRequest]({ url, route: undefined, rewritten: false }, () => next());\n }\n\n const path = resolveRoutePath ? resolveRoutePath(ctx) : url.pathname;\n const lookup = routes.getByPath(path) as MaybePromise<StoreRoute | undefined>;\n\n return maybeThen(lookup, (route) => {\n if (!route) {\n return contello[runRequest]({ url, route: undefined, rewritten: false }, () => next());\n }\n\n markRequestRoute(route);\n\n switch (route.type) {\n case 'redirect': {\n return contello[runRequest]({ url, route, rewritten: false }, () =>\n wrap(\n 'route:redirect',\n () =>\n new Response(null, {\n status: toRedirectStatus(route.status),\n headers: {\n Location: route.location,\n ...customHeaders(route.customHeaders),\n },\n }),\n ),\n );\n }\n\n case 'text': {\n return contello[runRequest]({ url, route, rewritten: false }, () =>\n wrap(\n 'route:text',\n () =>\n new Response(route.content, {\n status: 200,\n headers: {\n 'Content-Type': route.mimeType,\n ...customHeaders(route.customHeaders),\n },\n }),\n ),\n );\n }\n\n case 'asset': {\n return contello[runRequest]({ url, route, rewritten: false }, () =>\n wrap('route:asset', async () => {\n const result = await contello.client.download(route.fileId);\n const headers = new Headers({ 'content-type': route.mimeType || result.mimeType });\n\n headers.set('content-disposition', route.contentDisposition);\n\n if (result.size > 0) {\n headers.set('content-length', String(result.size));\n }\n\n for (const { name, value } of route.customHeaders) {\n headers.set(name, value);\n }\n\n return new Response(result.stream(), { headers });\n }),\n );\n }\n\n case 'entity': {\n return contello[runRequest]({ url, route, rewritten: true }, () =>\n wrap(`route:entity:${route.model}`, async () => {\n const response = await next(`/contello/entities/${route.model}/${route.entityId}${url.search}`);\n\n for (const { name, value } of route.customHeaders) {\n response.headers.set(name, value);\n }\n\n return response;\n }),\n );\n }\n }\n });\n });\n}\n","import { AsyncLocalStorage } from 'node:async_hooks';\nimport { type RawTranslations, i18n } from '@astroscope/i18n';\nimport { getBootContext } from '@astroscope/node/boot';\nimport type { ContelloClient, Schema, SourceDef } from '@contello/client';\nimport { type MediaResolver, type MediaResolverOptions, createMediaResolver } from '@contello/media';\nimport {\n type Assets,\n type AssetsOptions,\n type AssetsSync,\n type AssetsSyncOptions,\n type BuiltInWrites,\n type Collection,\n type CollectionOptions,\n type CollectionSync,\n type CollectionSyncOptions,\n type CreateStoreOptions,\n type ExtractSourceResult,\n type ExtractSourceWrites,\n type I18nMessageRegistrationDefinition,\n type I18nMessages,\n type LazyAssets,\n type LazyAssetsOptions,\n type LazyCollection,\n type LazyCollectionOptions,\n type LazyRoutes,\n type LazyRoutesOptions,\n type Loadable,\n type ResolveSource,\n type Routes,\n type RoutesOptions,\n type RoutesSync,\n type RoutesSyncOptions,\n type Singleton,\n type SingletonOptions,\n type SingletonSync,\n type SingletonSyncOptions,\n type SourceKeysOf,\n type Store,\n type StoreRoute,\n type SyncCacheOptions,\n createStore,\n} from '@contello/store';\nimport type { ReadonlyDeep } from '@entwico/dash';\nimport { type ContelloAssetsMiddlewareOptions, createBoundAssetsMiddleware } from './assets-middleware';\nimport { type ContelloRoutingMiddlewareOptions, createBoundRoutingMiddleware } from './routing-middleware';\n\nconst DEFAULT_IMAGES_PREFIX = '/_contello/i/';\nconst DEFAULT_FILES_PREFIX = '/_contello/f/';\nconst DEFAULT_VIDEO_PREFIX = '/_contello/v/';\n\nexport type ContelloRequestContext = {\n url: URL;\n route: ReadonlyDeep<StoreRoute> | undefined;\n rewritten: boolean;\n};\n\nexport type ContelloI18nOptions = {\n collection: string;\n languages: string[];\n cache?: SyncCacheOptions | undefined;\n};\n\nexport type ContelloInitOptions = {\n load?: Loadable[] | undefined;\n i18n?:\n | {\n /** defaults to `true`, except in dev mode (detected via the @astroscope/node boot context) */\n register?: boolean | undefined;\n load?: boolean | undefined;\n }\n | undefined;\n};\n\nexport type ContelloMediaConfig = {\n readonly baseUrl: string;\n readonly imagesPath: string;\n readonly videosPath: string;\n readonly filesPath: string;\n};\n\nexport type ContelloOptions<TSchema extends Schema | undefined = undefined> = CreateStoreOptions<TSchema> & {\n i18n?: ContelloI18nOptions | undefined;\n media?: Partial<ContelloMediaConfig> | undefined;\n};\n\ntype HasFallback<O> = O extends { fallback: infer F } ? ([F] extends [undefined] ? false : true) : false;\n\nexport const runRequest = Symbol('@contello/astro/runRequest');\n\nfunction buildI18nRegistrations(): I18nMessageRegistrationDefinition[] {\n const manifest = i18n.getManifest();\n const defaultLanguage = i18n.getConfig().defaultLocale;\n\n return manifest.keys.map((extracted) => ({\n token: extracted.key,\n example: extracted.meta.fallback,\n description: extracted.meta.description ?? '',\n variables: Object.entries(extracted.meta.variables ?? {}).map(([name, def]) => ({\n name,\n description: def?.description ?? '',\n example: def?.fallback ?? '',\n })),\n initialTranslations: [{ language: defaultLanguage, message: extracted.meta.fallback }],\n }));\n}\n\nasync function applyTranslations(messages: I18nMessages): Promise<void> {\n const config = i18n.getConfig();\n const all = await messages.getAll();\n const byLocale = new Map<string, RawTranslations>();\n\n for (const locale of config.locales) {\n byLocale.set(locale, {});\n }\n\n for (const msg of all) {\n msg.translations.forEach((value, language) => {\n const raw = byLocale.get(language);\n\n if (raw) {\n raw[msg.token] = value;\n }\n });\n }\n\n for (const [locale, translations] of byLocale) {\n i18n.setTranslations(locale, translations);\n }\n}\n\ntype ModelsOf<TSchema> = TSchema extends { models: infer M } ? keyof M & string : string;\ntype CollectionArg<TSchema> = SourceKeysOf<TSchema, 'entity'> | SourceDef<ModelsOf<TSchema>, 'entity'>;\ntype SingletonArg<TSchema> = SourceKeysOf<TSchema, 'singleton'> | SourceDef<ModelsOf<TSchema>, 'singleton'>;\ntype CollectionRaw<TSchema, TArg> = ExtractSourceResult<\n Extract<ResolveSource<TSchema, TArg>, SourceDef<string, 'entity'>>\n>;\n/** The write-input shape the source carries — keeps the collection's write half through the proxy. */\ntype CollectionWritesOf<TSchema, TArg> = ExtractSourceWrites<\n Extract<ResolveSource<TSchema, TArg>, SourceDef<string, 'entity'>>\n>;\ntype RouteWrites<TSchema> = BuiltInWrites<TSchema, 'route'>;\ntype AssetWrites<TSchema> = BuiltInWrites<TSchema, 'asset'>;\ntype SingletonRaw<TSchema, TArg> = ExtractSourceResult<\n Extract<ResolveSource<TSchema, TArg>, SourceDef<string, 'singleton'>>\n>;\n\nexport class Contello<TSchema extends Schema | undefined = undefined> {\n private readonly _store: Store<TSchema>;\n private readonly _options: ContelloOptions<TSchema>;\n private _i18nMessages: I18nMessages | undefined;\n private _i18nUnsubscribe: (() => void) | undefined;\n private _initialized = false;\n private readonly _als = new AsyncLocalStorage<ContelloRequestContext>();\n private _autoLazyRoutes?: LazyRoutes;\n\n readonly media: ContelloMediaConfig;\n\n // --- middleware factories (arrow fields so destructuring works) ---\n\n createRoutingMiddleware = (options?: ContelloRoutingMiddlewareOptions | undefined) => {\n const routes = options?.routes ?? (this._autoLazyRoutes ??= this.defineLazyRoutes());\n\n return createBoundRoutingMiddleware(this, routes, options?.exclude, options?.resolveRoutePath);\n };\n\n createAssetsMiddleware = (options?: ContelloAssetsMiddlewareOptions | undefined) => {\n return createBoundAssetsMiddleware(this, options);\n };\n\n constructor(options: ContelloOptions<TSchema>) {\n this._options = options;\n this._store = createStore<TSchema>(options);\n\n this.media = {\n baseUrl: options.media?.baseUrl ?? '',\n imagesPath: options.media?.imagesPath ?? DEFAULT_IMAGES_PREFIX,\n videosPath: options.media?.videosPath ?? DEFAULT_VIDEO_PREFIX,\n filesPath: options.media?.filesPath ?? DEFAULT_FILES_PREFIX,\n };\n }\n\n // --- lifecycle ---\n\n async init(options?: ContelloInitOptions | undefined): Promise<void> {\n try {\n await this._store.init();\n\n if (this._options.i18n) {\n const { collection, languages, cache } = this._options.i18n;\n const dev = getBootContext()?.dev ?? false;\n const { register = !dev, load = true } = options?.i18n ?? {};\n\n this._i18nMessages = this._store.defineI18nMessages({ collection, cache });\n\n await i18n.configure({ locales: languages });\n\n if (register) {\n const registrations = buildI18nRegistrations();\n\n if (registrations.length > 0) {\n await this._i18nMessages.register(registrations);\n }\n }\n\n if (load) {\n await applyTranslations(this._i18nMessages);\n\n const messages = this._i18nMessages;\n const controller = new AbortController();\n\n this._i18nUnsubscribe = () => controller.abort();\n\n // background loop: re-apply translations on every refresh until destroy()\n void (async () => {\n for await (const _ of messages.refresh$) {\n if (controller.signal.aborted) {\n return;\n }\n\n await applyTranslations(messages);\n }\n })();\n }\n }\n\n await Promise.all((options?.load ?? []).map((l) => l.load()));\n\n this._initialized = true;\n } catch (error) {\n try {\n await this.destroy();\n } catch {\n // ignore teardown errors; the original init error is rethrown below\n }\n\n throw error;\n }\n }\n\n async destroy(): Promise<void> {\n this._initialized = false;\n\n this._i18nUnsubscribe?.();\n this._i18nUnsubscribe = undefined;\n\n await this._store.destroy();\n\n this._i18nMessages = undefined;\n }\n\n ping(): Promise<void> {\n return this._store.ping();\n }\n\n get isReady(): boolean {\n return this._initialized;\n }\n\n get client(): ContelloClient<TSchema> {\n return this._store.client;\n }\n\n get i18nMessages(): I18nMessages {\n if (!this._i18nMessages) {\n throw new Error('@contello/astro: .i18nMessages accessed before init() with i18n config');\n }\n\n return this._i18nMessages;\n }\n\n // --- ALS request context ---\n\n get request(): ContelloRequestContext {\n const ctx = this._als.getStore();\n\n if (!ctx) {\n throw new Error('@contello/astro: .request accessed outside of request context');\n }\n\n return ctx;\n }\n\n // --- media resolvers (on-demand) ---\n\n defineMediaResolver<O extends Partial<MediaResolverOptions>>(options?: O): MediaResolver<HasFallback<O>> {\n return createMediaResolver({\n ...this.media,\n ...options,\n }) as MediaResolver<HasFallback<O>>;\n }\n\n // --- store delegation ---\n\n defineSingleton<TArg extends SingletonArg<TSchema>, TMapped = SingletonRaw<TSchema, TArg>>(\n sourceOrKey: TArg,\n options?: SingletonOptions<SingletonRaw<TSchema, TArg>, TMapped, ModelsOf<TSchema>>,\n ): Singleton<TMapped> {\n return this._store.defineSingleton(sourceOrKey as any, options as any) as Singleton<TMapped>;\n }\n\n defineSingletonSync<TArg extends SingletonArg<TSchema>, TMapped = SingletonRaw<TSchema, TArg>>(\n sourceOrKey: TArg,\n options?: SingletonSyncOptions<SingletonRaw<TSchema, TArg>, TMapped, ModelsOf<TSchema>>,\n ): SingletonSync<TMapped> {\n return this._store.defineSingletonSync(sourceOrKey as any, options as any) as SingletonSync<TMapped>;\n }\n\n defineCollection<\n TArg extends CollectionArg<TSchema>,\n TMapped extends { id: string } = CollectionRaw<TSchema, TArg> & { id: string },\n >(\n sourceOrKey: TArg,\n options?: CollectionOptions<CollectionRaw<TSchema, TArg>, TMapped, ModelsOf<TSchema>>,\n ): Collection<TMapped, CollectionWritesOf<TSchema, TArg>> {\n return this._store.defineCollection(sourceOrKey as any, options as any) as Collection<\n TMapped,\n CollectionWritesOf<TSchema, TArg>\n >;\n }\n\n defineCollectionSync<\n TArg extends CollectionArg<TSchema>,\n TMapped extends { id: string } = CollectionRaw<TSchema, TArg> & { id: string },\n >(\n sourceOrKey: TArg,\n options?: CollectionSyncOptions<CollectionRaw<TSchema, TArg>, TMapped, ModelsOf<TSchema>>,\n ): CollectionSync<TMapped, CollectionWritesOf<TSchema, TArg>> {\n return this._store.defineCollectionSync(sourceOrKey as any, options as any) as CollectionSync<\n TMapped,\n CollectionWritesOf<TSchema, TArg>\n >;\n }\n\n defineLazyCollection<\n TArg extends CollectionArg<TSchema>,\n TMapped extends { id: string } = CollectionRaw<TSchema, TArg> & { id: string },\n >(\n sourceOrKey: TArg,\n options?: LazyCollectionOptions<CollectionRaw<TSchema, TArg>, TMapped, ModelsOf<TSchema>>,\n ): LazyCollection<TMapped> {\n return this._store.defineLazyCollection(sourceOrKey as any, options as any) as LazyCollection<TMapped>;\n }\n\n defineRoutes(options?: RoutesOptions | undefined): Routes<RouteWrites<TSchema>> {\n return this._store.defineRoutes(options);\n }\n\n defineRoutesSync(options?: RoutesSyncOptions | undefined): RoutesSync<RouteWrites<TSchema>> {\n return this._store.defineRoutesSync(options);\n }\n\n defineLazyRoutes(options?: LazyRoutesOptions | undefined): LazyRoutes {\n return this._store.defineLazyRoutes(options);\n }\n\n defineAssets(options?: AssetsOptions | undefined): Assets<AssetWrites<TSchema>> {\n return this._store.defineAssets(options);\n }\n\n defineAssetsSync(options?: AssetsSyncOptions | undefined): AssetsSync<AssetWrites<TSchema>> {\n return this._store.defineAssetsSync(options);\n }\n\n defineLazyAssets(options?: LazyAssetsOptions | undefined): LazyAssets {\n return this._store.defineLazyAssets(options);\n }\n\n // --- ALS run ---\n\n [runRequest]<T>(ctx: ContelloRequestContext, fn: () => T): T {\n return this._als.run(ctx, fn);\n }\n}\n\nexport function createContello<TSchema extends Schema | undefined = undefined>(\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ware.ts","../src/routing-middleware.ts","../src/contello.ts"],"sourcesContent":["import type { MiddlewareHandler } from 'astro';\n\n// a local identity instead of `astro/middleware`: a runtime import of astro's middleware entry pulls every module that\n// imports this package into astro's runtime module graph — in dev, astro invalidates that graph on any file change,\n// which re-evaluates boot-loaded singletons and makes @astroscope/node restart the server on every component edit\nexport function defineMiddleware(handler: MiddlewareHandler): MiddlewareHandler {\n return handler;\n}\n","import { createOperationTelemetry } from '@contello/opentelemetry';\n\nexport const { wrap } = createOperationTelemetry('@contello/astro');\n","import { overrideRequestRoute } from '@astroscope/node/log';\nimport type { ContelloClient } from '@contello/client';\nimport type { Contello } from './contello';\nimport { defineMiddleware } from './middleware';\nimport { wrap } from './telemetry';\n\nexport type ContelloAssetsImagesOptions = {\n cacheControl?: string | undefined;\n};\n\nexport type ContelloAssetsFilesOptions = {\n cacheControl?: string | undefined;\n};\n\nexport type ContelloAssetsVideoOptions = Record<string, never>;\n\nexport type ContelloAssetsMiddlewareOptions = {\n images?: ContelloAssetsImagesOptions | undefined;\n files?: ContelloAssetsFilesOptions | undefined;\n video?: ContelloAssetsVideoOptions | undefined;\n};\n\nconst DEFAULT_IMAGES_CACHE_CONTROL = 'public, max-age=31536000';\n\nexport function createBoundAssetsMiddleware(\n contello: Contello<any>,\n options: ContelloAssetsMiddlewareOptions | undefined,\n) {\n const imagesPrefix = contello.media.imagesPath;\n const imagesCacheControl = options?.images?.cacheControl ?? DEFAULT_IMAGES_CACHE_CONTROL;\n const filesPrefix = contello.media.filesPath;\n const filesCacheControl = options?.files?.cacheControl;\n const videoPrefix = contello.media.videosPath;\n\n return defineMiddleware((ctx, next) => {\n const { pathname } = ctx.url;\n const isImage = pathname.startsWith(imagesPrefix);\n const isFile = !isImage && pathname.startsWith(filesPrefix);\n const isVideo = !isImage && !isFile && pathname.startsWith(videoPrefix);\n\n if (!isImage && !isFile && !isVideo) {\n return next();\n }\n\n if (!contello.isReady) {\n console.warn(`[@contello/astro] not initialized, passing through: ${pathname}`);\n\n return next();\n }\n\n if (isImage) {\n return handleFile(\n contello.client,\n next,\n pathname.slice(imagesPrefix.length),\n imagesCacheControl,\n `${imagesPrefix}[file]`,\n );\n }\n\n if (isFile) {\n return handleFile(\n contello.client,\n next,\n pathname.slice(filesPrefix.length),\n filesCacheControl,\n `${filesPrefix}[file]`,\n );\n }\n\n return handleVideo(\n contello.client,\n next,\n pathname.slice(videoPrefix.length),\n ctx.request.signal,\n `${videoPrefix}[...path]`,\n );\n });\n}\n\nfunction handleFile(\n client: ContelloClient<any>,\n next: () => Response | Promise<Response>,\n rest: string,\n cacheControl: string | undefined,\n routeLabel: string,\n) {\n const dot = rest.indexOf('.');\n const fileId = dot === -1 ? rest : rest.slice(0, dot);\n\n if (!fileId) {\n return next();\n }\n\n overrideRequestRoute(routeLabel);\n\n return (async () => {\n try {\n const result = await wrap('assets:file', () => client.download(fileId));\n const headers = new Headers({ 'content-type': result.mimeType });\n\n if (cacheControl) {\n headers.set('cache-control', cacheControl);\n }\n\n if (result.size > 0) {\n headers.set('content-length', String(result.size));\n }\n\n return new Response(result.stream(), { headers });\n } catch {\n return new Response(null, { status: 404 });\n }\n })();\n}\n\nfunction handleVideo(\n client: ContelloClient<any>,\n next: () => Response | Promise<Response>,\n path: string,\n signal: AbortSignal,\n routeLabel: string,\n) {\n if (!path) {\n return next();\n }\n\n overrideRequestRoute(routeLabel);\n\n return (async () => {\n try {\n const result = await wrap('assets:hls', () => client.proxyHls(path, signal));\n\n return new Response(result.stream(), { status: result.status, headers: result.headers });\n } catch {\n return new Response('Upstream is down', { status: 502, headers: { 'content-type': 'text/plain' } });\n }\n })();\n}\n","import { type ExcludePattern, RECOMMENDED_EXCLUDES, shouldExclude } from '@astroscope/node/excludes';\nimport { overrideRequestRoute } from '@astroscope/node/log';\nimport { updateActiveSpan } from '@contello/opentelemetry';\nimport type { LazyRoutes, Routes, RoutesSync, StoreRoute, StoreRouteCustomHeader } from '@contello/store';\nimport { type MaybePromise, maybeThen } from '@entwico/dash';\nimport type { APIContext, ValidRedirectStatus } from 'astro';\nimport { type Contello, runRequest } from './contello';\nimport { defineMiddleware } from './middleware';\nimport { wrap } from './telemetry';\n\nexport type AnyRoutes = Routes | RoutesSync | LazyRoutes;\n\n/**\n * Derives the path used to look up a Contello route from the request context.\n *\n * @default `(ctx) => ctx.url.pathname`\n *\n * ```ts\n * resolveRoutePath: (ctx) => `/${ctx.url.hostname}${ctx.url.pathname}`\n * ```\n */\nexport type RoutePathResolver = (ctx: APIContext) => string;\n\nexport type ContelloRoutingMiddlewareOptions = {\n /**\n * Routes instance backing the middleware.\n *\n * Defaults to a `LazyRoutes` instance managed by contello (fetched on demand, no init-time load).\n * For eager routing, create a `RoutesSync` via `contello.defineRoutesSync()`, add it to\n * `contello.init({ load: [routes] })`, and pass that same instance here.\n */\n routes?: AnyRoutes | undefined;\n exclude?: ExcludePattern[] | undefined;\n resolveRoutePath?: RoutePathResolver | undefined;\n};\n\nfunction customHeaders(headers: readonly StoreRouteCustomHeader[]): Record<string, string> {\n const result: Record<string, string> = {};\n\n for (const h of headers) {\n result[h.name] = h.value;\n }\n\n return result;\n}\n\nconst VALID_REDIRECT_STATUSES = new Set([301, 302, 303, 307, 308]);\n\nfunction toRedirectStatus(status: number): ValidRedirectStatus {\n return (VALID_REDIRECT_STATUSES.has(status) ? status : 302) as ValidRedirectStatus;\n}\n\n/**\n * Astro's routing matches the 404 fallback for paths only contello knows how to\n * serve, so report what contello resolved: `overrideRequestRoute` corrects the\n * request log line, the request duration metric and the server span name\n * together, then record the contello-specific attributes on top.\n */\nfunction markRequestRoute(route: StoreRoute): void {\n overrideRequestRoute(\n route.type === 'entity' ? `/contello/entities/${route.model}/[id]` : `contello:route:${route.type}`,\n );\n\n updateActiveSpan({\n attributes: {\n 'contello.route.type': route.type,\n 'contello.route.path': route.path,\n ...(route.type === 'entity' && { 'contello.route.model': route.model }),\n },\n });\n}\n\nexport function createBoundRoutingMiddleware(\n contello: Contello<any>,\n routes: AnyRoutes,\n exclude: ExcludePattern[] | undefined,\n resolveRoutePath: RoutePathResolver | undefined,\n) {\n return defineMiddleware((ctx, next) => {\n if (shouldExclude(ctx, exclude ?? RECOMMENDED_EXCLUDES)) {\n return next();\n }\n\n if (!contello.isReady) {\n console.warn(`[@contello/astro] not initialized, passing through: ${ctx.url.pathname}`);\n\n return next();\n }\n\n const { url } = ctx;\n\n if (url.pathname.startsWith('/contello/entities/')) {\n return contello[runRequest]({ url, route: undefined, rewritten: false }, () => next());\n }\n\n const path = resolveRoutePath ? resolveRoutePath(ctx) : url.pathname;\n const lookup = routes.getByPath(path) as MaybePromise<StoreRoute | undefined>;\n\n return maybeThen(lookup, (route) => {\n if (!route) {\n return contello[runRequest]({ url, route: undefined, rewritten: false }, () => next());\n }\n\n markRequestRoute(route);\n\n switch (route.type) {\n case 'redirect': {\n return contello[runRequest]({ url, route, rewritten: false }, () =>\n wrap(\n 'route:redirect',\n () =>\n new Response(null, {\n status: toRedirectStatus(route.status),\n headers: {\n Location: route.location,\n ...customHeaders(route.customHeaders),\n },\n }),\n ),\n );\n }\n\n case 'text': {\n return contello[runRequest]({ url, route, rewritten: false }, () =>\n wrap(\n 'route:text',\n () =>\n new Response(route.content, {\n status: 200,\n headers: {\n 'Content-Type': route.mimeType,\n ...customHeaders(route.customHeaders),\n },\n }),\n ),\n );\n }\n\n case 'asset': {\n return contello[runRequest]({ url, route, rewritten: false }, () =>\n wrap('route:asset', async () => {\n const result = await contello.client.download(route.fileId);\n const headers = new Headers({ 'content-type': route.mimeType || result.mimeType });\n\n headers.set('content-disposition', route.contentDisposition);\n\n if (result.size > 0) {\n headers.set('content-length', String(result.size));\n }\n\n for (const { name, value } of route.customHeaders) {\n headers.set(name, value);\n }\n\n return new Response(result.stream(), { headers });\n }),\n );\n }\n\n case 'sitemap': {\n return contello[runRequest]({ url, route, rewritten: false }, () =>\n wrap('route:sitemap', async () => {\n const result = await contello.client.proxySitemap(\n route.sitemapId,\n {\n source: url.searchParams.get('source') ?? undefined,\n page: url.searchParams.get('page') ?? undefined,\n acceptEncoding: ctx.request.headers.get('accept-encoding') ?? undefined,\n ifNoneMatch: ctx.request.headers.get('if-none-match') ?? undefined,\n },\n ctx.request.signal,\n );\n\n const passthrough = result.status === 304 || (result.status >= 200 && result.status < 300);\n\n if (!passthrough) {\n // core's error format stays internal: same status, no body, none of the upstream headers\n await result.stream().cancel();\n\n return new Response(null, { status: result.status, headers: customHeaders(route.customHeaders) });\n }\n\n const headers = new Headers(result.headers);\n\n for (const { name, value } of route.customHeaders) {\n headers.set(name, value);\n }\n\n return new Response(result.status === 304 ? null : result.stream(), { status: result.status, headers });\n }),\n );\n }\n\n case 'entity': {\n return contello[runRequest]({ url, route, rewritten: true }, () =>\n wrap(`route:entity:${route.model}`, async () => {\n const response = await next(`/contello/entities/${route.model}/${route.entityId}${url.search}`);\n\n for (const { name, value } of route.customHeaders) {\n response.headers.set(name, value);\n }\n\n return response;\n }),\n );\n }\n }\n });\n });\n}\n","import { AsyncLocalStorage } from 'node:async_hooks';\nimport { type RawTranslations, i18n } from '@astroscope/i18n';\nimport { getBootContext } from '@astroscope/node/boot';\nimport type { ContelloClient, Schema, SourceDef } from '@contello/client';\nimport { type MediaResolver, type MediaResolverOptions, createMediaResolver } from '@contello/media';\nimport {\n type Assets,\n type AssetsOptions,\n type AssetsSync,\n type AssetsSyncOptions,\n type BuiltInWrites,\n type Collection,\n type CollectionOptions,\n type CollectionSync,\n type CollectionSyncOptions,\n type CreateStoreOptions,\n type ExtractSourceResult,\n type ExtractSourceWrites,\n type I18nMessageRegistrationDefinition,\n type I18nMessages,\n type LazyAssets,\n type LazyAssetsOptions,\n type LazyCollection,\n type LazyCollectionOptions,\n type LazyRoutes,\n type LazyRoutesOptions,\n type Loadable,\n type ResolveSource,\n type Routes,\n type RoutesOptions,\n type RoutesSync,\n type RoutesSyncOptions,\n type Singleton,\n type SingletonOptions,\n type SingletonSync,\n type SingletonSyncOptions,\n type SourceKeysOf,\n type Store,\n type StoreRoute,\n type SyncCacheOptions,\n createStore,\n} from '@contello/store';\nimport type { ReadonlyDeep } from '@entwico/dash';\nimport { type ContelloAssetsMiddlewareOptions, createBoundAssetsMiddleware } from './assets-middleware';\nimport { type ContelloRoutingMiddlewareOptions, createBoundRoutingMiddleware } from './routing-middleware';\n\nconst DEFAULT_IMAGES_PREFIX = '/_contello/i/';\nconst DEFAULT_FILES_PREFIX = '/_contello/f/';\nconst DEFAULT_VIDEO_PREFIX = '/_contello/v/';\n\nexport type ContelloRequestContext = {\n url: URL;\n route: ReadonlyDeep<StoreRoute> | undefined;\n rewritten: boolean;\n};\n\nexport type ContelloI18nOptions = {\n collection: string;\n languages: string[];\n cache?: SyncCacheOptions | undefined;\n};\n\nexport type ContelloInitOptions = {\n load?: Loadable[] | undefined;\n i18n?:\n | {\n /** defaults to `true`, except in dev mode (detected via the @astroscope/node boot context) */\n register?: boolean | undefined;\n load?: boolean | undefined;\n }\n | undefined;\n};\n\nexport type ContelloMediaConfig = {\n readonly baseUrl: string;\n readonly imagesPath: string;\n readonly videosPath: string;\n readonly filesPath: string;\n};\n\nexport type ContelloOptions<TSchema extends Schema | undefined = undefined> = CreateStoreOptions<TSchema> & {\n i18n?: ContelloI18nOptions | undefined;\n media?: Partial<ContelloMediaConfig> | undefined;\n};\n\ntype HasFallback<O> = O extends { fallback: infer F } ? ([F] extends [undefined] ? false : true) : false;\n\nexport const runRequest = Symbol('@contello/astro/runRequest');\n\nfunction buildI18nRegistrations(): I18nMessageRegistrationDefinition[] {\n const manifest = i18n.getManifest();\n const defaultLanguage = i18n.getConfig().defaultLocale;\n\n return manifest.keys.map((extracted) => ({\n token: extracted.key,\n example: extracted.meta.fallback,\n description: extracted.meta.description ?? '',\n variables: Object.entries(extracted.meta.variables ?? {}).map(([name, def]) => ({\n name,\n description: def?.description ?? '',\n example: def?.fallback ?? '',\n })),\n initialTranslations: [{ language: defaultLanguage, message: extracted.meta.fallback }],\n }));\n}\n\nasync function applyTranslations(messages: I18nMessages): Promise<void> {\n const config = i18n.getConfig();\n const all = await messages.getAll();\n const byLocale = new Map<string, RawTranslations>();\n\n for (const locale of config.locales) {\n byLocale.set(locale, {});\n }\n\n for (const msg of all) {\n msg.translations.forEach((value, language) => {\n const raw = byLocale.get(language);\n\n if (raw) {\n raw[msg.token] = value;\n }\n });\n }\n\n for (const [locale, translations] of byLocale) {\n i18n.setTranslations(locale, translations);\n }\n}\n\ntype ModelsOf<TSchema> = TSchema extends { models: infer M } ? keyof M & string : string;\ntype CollectionArg<TSchema> = SourceKeysOf<TSchema, 'entity'> | SourceDef<ModelsOf<TSchema>, 'entity'>;\ntype SingletonArg<TSchema> = SourceKeysOf<TSchema, 'singleton'> | SourceDef<ModelsOf<TSchema>, 'singleton'>;\ntype CollectionRaw<TSchema, TArg> = ExtractSourceResult<\n Extract<ResolveSource<TSchema, TArg>, SourceDef<string, 'entity'>>\n>;\n/** The write-input shape the source carries — keeps the collection's write half through the proxy. */\ntype CollectionWritesOf<TSchema, TArg> = ExtractSourceWrites<\n Extract<ResolveSource<TSchema, TArg>, SourceDef<string, 'entity'>>\n>;\ntype RouteWrites<TSchema> = BuiltInWrites<TSchema, 'route'>;\ntype AssetWrites<TSchema> = BuiltInWrites<TSchema, 'asset'>;\ntype SingletonRaw<TSchema, TArg> = ExtractSourceResult<\n Extract<ResolveSource<TSchema, TArg>, SourceDef<string, 'singleton'>>\n>;\n\nexport class Contello<TSchema extends Schema | undefined = undefined> {\n private readonly _store: Store<TSchema>;\n private readonly _options: ContelloOptions<TSchema>;\n private _i18nMessages: I18nMessages | undefined;\n private _i18nUnsubscribe: (() => void) | undefined;\n private _initialized = false;\n private readonly _als = new AsyncLocalStorage<ContelloRequestContext>();\n private _autoLazyRoutes?: LazyRoutes;\n\n readonly media: ContelloMediaConfig;\n\n // --- middleware factories (arrow fields so destructuring works) ---\n\n createRoutingMiddleware = (options?: ContelloRoutingMiddlewareOptions | undefined) => {\n const routes = options?.routes ?? (this._autoLazyRoutes ??= this.defineLazyRoutes());\n\n return createBoundRoutingMiddleware(this, routes, options?.exclude, options?.resolveRoutePath);\n };\n\n createAssetsMiddleware = (options?: ContelloAssetsMiddlewareOptions | undefined) => {\n return createBoundAssetsMiddleware(this, options);\n };\n\n constructor(options: ContelloOptions<TSchema>) {\n this._options = options;\n this._store = createStore<TSchema>(options);\n\n this.media = {\n baseUrl: options.media?.baseUrl ?? '',\n imagesPath: options.media?.imagesPath ?? DEFAULT_IMAGES_PREFIX,\n videosPath: options.media?.videosPath ?? DEFAULT_VIDEO_PREFIX,\n filesPath: options.media?.filesPath ?? DEFAULT_FILES_PREFIX,\n };\n }\n\n // --- lifecycle ---\n\n async init(options?: ContelloInitOptions | undefined): Promise<void> {\n try {\n await this._store.init();\n\n if (this._options.i18n) {\n const { collection, languages, cache } = this._options.i18n;\n const dev = getBootContext()?.dev ?? false;\n const { register = !dev, load = true } = options?.i18n ?? {};\n\n this._i18nMessages = this._store.defineI18nMessages({ collection, cache });\n\n await i18n.configure({ locales: languages });\n\n if (register) {\n const registrations = buildI18nRegistrations();\n\n if (registrations.length > 0) {\n await this._i18nMessages.register(registrations);\n }\n }\n\n if (load) {\n await applyTranslations(this._i18nMessages);\n\n const messages = this._i18nMessages;\n const controller = new AbortController();\n\n this._i18nUnsubscribe = () => controller.abort();\n\n // background loop: re-apply translations on every refresh until destroy()\n void (async () => {\n for await (const _ of messages.refresh$) {\n if (controller.signal.aborted) {\n return;\n }\n\n await applyTranslations(messages);\n }\n })();\n }\n }\n\n await Promise.all((options?.load ?? []).map((l) => l.load()));\n\n this._initialized = true;\n } catch (error) {\n try {\n await this.destroy();\n } catch {\n // ignore teardown errors; the original init error is rethrown below\n }\n\n throw error;\n }\n }\n\n async destroy(): Promise<void> {\n this._initialized = false;\n\n this._i18nUnsubscribe?.();\n this._i18nUnsubscribe = undefined;\n\n await this._store.destroy();\n\n this._i18nMessages = undefined;\n }\n\n ping(): Promise<void> {\n return this._store.ping();\n }\n\n get isReady(): boolean {\n return this._initialized;\n }\n\n get client(): ContelloClient<TSchema> {\n return this._store.client;\n }\n\n get i18nMessages(): I18nMessages {\n if (!this._i18nMessages) {\n throw new Error('@contello/astro: .i18nMessages accessed before init() with i18n config');\n }\n\n return this._i18nMessages;\n }\n\n // --- ALS request context ---\n\n get request(): ContelloRequestContext {\n const ctx = this._als.getStore();\n\n if (!ctx) {\n throw new Error('@contello/astro: .request accessed outside of request context');\n }\n\n return ctx;\n }\n\n // --- media resolvers (on-demand) ---\n\n defineMediaResolver<O extends Partial<MediaResolverOptions>>(options?: O): MediaResolver<HasFallback<O>> {\n return createMediaResolver({\n ...this.media,\n ...options,\n }) as MediaResolver<HasFallback<O>>;\n }\n\n // --- store delegation ---\n\n defineSingleton<TArg extends SingletonArg<TSchema>, TMapped = SingletonRaw<TSchema, TArg>>(\n sourceOrKey: TArg,\n options?: SingletonOptions<SingletonRaw<TSchema, TArg>, TMapped, ModelsOf<TSchema>>,\n ): Singleton<TMapped> {\n return this._store.defineSingleton(sourceOrKey as any, options as any) as Singleton<TMapped>;\n }\n\n defineSingletonSync<TArg extends SingletonArg<TSchema>, TMapped = SingletonRaw<TSchema, TArg>>(\n sourceOrKey: TArg,\n options?: SingletonSyncOptions<SingletonRaw<TSchema, TArg>, TMapped, ModelsOf<TSchema>>,\n ): SingletonSync<TMapped> {\n return this._store.defineSingletonSync(sourceOrKey as any, options as any) as SingletonSync<TMapped>;\n }\n\n defineCollection<\n TArg extends CollectionArg<TSchema>,\n TMapped extends { id: string } = CollectionRaw<TSchema, TArg> & { id: string },\n >(\n sourceOrKey: TArg,\n options?: CollectionOptions<CollectionRaw<TSchema, TArg>, TMapped, ModelsOf<TSchema>>,\n ): Collection<TMapped, CollectionWritesOf<TSchema, TArg>> {\n return this._store.defineCollection(sourceOrKey as any, options as any) as Collection<\n TMapped,\n CollectionWritesOf<TSchema, TArg>\n >;\n }\n\n defineCollectionSync<\n TArg extends CollectionArg<TSchema>,\n TMapped extends { id: string } = CollectionRaw<TSchema, TArg> & { id: string },\n >(\n sourceOrKey: TArg,\n options?: CollectionSyncOptions<CollectionRaw<TSchema, TArg>, TMapped, ModelsOf<TSchema>>,\n ): CollectionSync<TMapped, CollectionWritesOf<TSchema, TArg>> {\n return this._store.defineCollectionSync(sourceOrKey as any, options as any) as CollectionSync<\n TMapped,\n CollectionWritesOf<TSchema, TArg>\n >;\n }\n\n defineLazyCollection<\n TArg extends CollectionArg<TSchema>,\n TMapped extends { id: string } = CollectionRaw<TSchema, TArg> & { id: string },\n >(\n sourceOrKey: TArg,\n options?: LazyCollectionOptions<CollectionRaw<TSchema, TArg>, TMapped, ModelsOf<TSchema>>,\n ): LazyCollection<TMapped> {\n return this._store.defineLazyCollection(sourceOrKey as any, options as any) as LazyCollection<TMapped>;\n }\n\n defineRoutes(options?: RoutesOptions | undefined): Routes<RouteWrites<TSchema>> {\n return this._store.defineRoutes(options);\n }\n\n defineRoutesSync(options?: RoutesSyncOptions | undefined): RoutesSync<RouteWrites<TSchema>> {\n return this._store.defineRoutesSync(options);\n }\n\n defineLazyRoutes(options?: LazyRoutesOptions | undefined): LazyRoutes {\n return this._store.defineLazyRoutes(options);\n }\n\n defineAssets(options?: AssetsOptions | undefined): Assets<AssetWrites<TSchema>> {\n return this._store.defineAssets(options);\n }\n\n defineAssetsSync(options?: AssetsSyncOptions | undefined): AssetsSync<AssetWrites<TSchema>> {\n return this._store.defineAssetsSync(options);\n }\n\n defineLazyAssets(options?: LazyAssetsOptions | undefined): LazyAssets {\n return this._store.defineLazyAssets(options);\n }\n\n // --- ALS run ---\n\n [runRequest]<T>(ctx: ContelloRequestContext, fn: () => T): T {\n return this._als.run(ctx, fn);\n }\n}\n\nexport function createContello<TSchema extends Schema | undefined = undefined>(\n options: ContelloOptions<TSchema>,\n): Contello<TSchema> {\n return new Contello(options);\n}\n"],"mappings":";;;;;;;;;;AAKA,SAAgB,iBAAiB,SAA+C;CAC9E,OAAO;AACT;;;ACLA,MAAa,EAAE,SAAS,yBAAyB,iBAAiB;;;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4D;EAC5D,OAAO,KAAK,OAAO,qBAAqB,aAAoB,OAAc;CAI5E;CAEA,qBAIE,aACA,SACyB;EACzB,OAAO,KAAK,OAAO,qBAAqB,aAAoB,OAAc;CAC5E;CAEA,aAAa,SAAmE;EAC9E,OAAO,KAAK,OAAO,aAAa,OAAO;CACzC;CAEA,iBAAiB,SAA2E;EAC1F,OAAO,KAAK,OAAO,iBAAiB,OAAO;CAC7C;CAEA,iBAAiB,SAAqD;EACpE,OAAO,KAAK,OAAO,iBAAiB,OAAO;CAC7C;CAEA,aAAa,SAAmE;EAC9E,OAAO,KAAK,OAAO,aAAa,OAAO;CACzC;CAEA,iBAAiB,SAA2E;EAC1F,OAAO,KAAK,OAAO,iBAAiB,OAAO;CAC7C;CAEA,iBAAiB,SAAqD;EACpE,OAAO,KAAK,OAAO,iBAAiB,OAAO;CAC7C;CAIA,CAAC,YAAe,KAA6B,IAAgB;EAC3D,OAAO,KAAK,KAAK,IAAI,KAAK,EAAE;CAC9B;AACF;AAEA,SAAgB,eACd,SACmB;CACnB,OAAO,IAAI,SAAS,OAAO;AAC7B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contello/astro",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.0",
|
|
4
4
|
"description": "Astro integration for Contello CMS — route middleware and i18n bridge",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -11,16 +11,16 @@
|
|
|
11
11
|
"directory": "packages/astro"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@
|
|
15
|
-
"@
|
|
14
|
+
"@contello/opentelemetry": "^2.1.1",
|
|
15
|
+
"@entwico/dash": "^1.3.0"
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
18
|
"@astroscope/i18n": ">=1.0.0",
|
|
19
19
|
"@astroscope/node": ">=1.3.0",
|
|
20
|
-
"
|
|
21
|
-
"@contello/client": "^3.1.0",
|
|
20
|
+
"@contello/client": "^3.2.0",
|
|
22
21
|
"@contello/media": "^2.2.2",
|
|
23
|
-
"@contello/store": "^4.
|
|
22
|
+
"@contello/store": "^4.4.0",
|
|
23
|
+
"astro": "^6.0.0 || ^7.0.0"
|
|
24
24
|
},
|
|
25
25
|
"peerDependenciesMeta": {
|
|
26
26
|
"@astroscope/i18n": {
|
|
@@ -28,12 +28,12 @@
|
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@astroscope/i18n": "^
|
|
32
|
-
"@astroscope/node": "^
|
|
33
|
-
"
|
|
34
|
-
"@contello/
|
|
35
|
-
"@contello/
|
|
36
|
-
"
|
|
31
|
+
"@astroscope/i18n": "^2.0.0",
|
|
32
|
+
"@astroscope/node": "^2.0.0",
|
|
33
|
+
"@contello/client": "^3.2.0",
|
|
34
|
+
"@contello/media": "^2.2.2",
|
|
35
|
+
"@contello/store": "^4.4.0",
|
|
36
|
+
"astro": "^7.2.7"
|
|
37
37
|
},
|
|
38
38
|
"files": [
|
|
39
39
|
"dist"
|