@contello/astro 4.4.0 → 5.0.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/assets-middleware-entrypoint.d.ts +4 -0
- package/dist/assets-middleware-entrypoint.d.ts.map +1 -0
- package/dist/assets-middleware-entrypoint.js +7 -0
- package/dist/assets-middleware-entrypoint.js.map +1 -0
- package/dist/index.cjs +150 -17
- package/dist/index.d.cts +90 -13
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +90 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +122 -17
- package/dist/index.js.map +1 -1
- package/dist/routing-middleware-entrypoint.d.ts +4 -0
- package/dist/routing-middleware-entrypoint.d.ts.map +1 -0
- package/dist/routing-middleware-entrypoint.js +8 -0
- package/dist/routing-middleware-entrypoint.js.map +1 -0
- package/package.json +28 -14
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assets-middleware-entrypoint.d.ts","names":[],"sources":["../src/assets-middleware-entrypoint.ts"],"mappings":";qBAEa"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assets-middleware-entrypoint.js","names":[],"sources":["../src/assets-middleware-entrypoint.ts"],"sourcesContent":["import { contello } from 'virtual:@contello/astro/instance';\n\nexport const onRequest = contello.createAssetsMiddleware();\n"],"mappings":";;AAEA,MAAa,YAAY,SAAS,uBAAuB"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,13 +1,97 @@
|
|
|
1
|
-
Object.
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
+
});
|
|
5
|
+
//#region \0rolldown/runtime.js
|
|
6
|
+
var __create = Object.create;
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
9
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
10
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
11
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
14
|
+
key = keys[i];
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: ((k) => from[k]).bind(null, key),
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
//#endregion
|
|
27
|
+
let node_fs = require("node:fs");
|
|
28
|
+
node_fs = __toESM(node_fs, 1);
|
|
29
|
+
let node_path = require("node:path");
|
|
30
|
+
node_path = __toESM(node_path, 1);
|
|
31
|
+
let node_url = require("node:url");
|
|
32
|
+
let _astroscope_node_excludes = require("@astroscope/node/excludes");
|
|
2
33
|
let node_async_hooks = require("node:async_hooks");
|
|
3
34
|
let _astroscope_i18n = require("@astroscope/i18n");
|
|
4
35
|
let _astroscope_node_boot = require("@astroscope/node/boot");
|
|
36
|
+
let _astroscope_node_health = require("@astroscope/node/health");
|
|
5
37
|
let _contello_media = require("@contello/media");
|
|
6
38
|
let _contello_store = require("@contello/store");
|
|
7
39
|
let _astroscope_node_log = require("@astroscope/node/log");
|
|
8
40
|
let _contello_opentelemetry = require("@contello/opentelemetry");
|
|
9
|
-
let _astroscope_node_excludes = require("@astroscope/node/excludes");
|
|
10
41
|
let _entwico_dash = require("@entwico/dash");
|
|
42
|
+
const RESOLVED_CONFIG_VIRTUAL_MODULE_ID = `\0virtual:@contello/astro/config`;
|
|
43
|
+
/**
|
|
44
|
+
* Resolves the instance id straight to the project's module, so the injected
|
|
45
|
+
* middlewares and the project's own imports share one `Contello` instance, and
|
|
46
|
+
* serves the serializable integration options as a config module.
|
|
47
|
+
*/
|
|
48
|
+
function contelloVitePlugin(options) {
|
|
49
|
+
return {
|
|
50
|
+
name: "@contello/astro",
|
|
51
|
+
resolveId(id) {
|
|
52
|
+
if (id === "virtual:@contello/astro/instance") return options.entry;
|
|
53
|
+
if (id === "virtual:@contello/astro/config") return RESOLVED_CONFIG_VIRTUAL_MODULE_ID;
|
|
54
|
+
},
|
|
55
|
+
load(id) {
|
|
56
|
+
if (id === RESOLVED_CONFIG_VIRTUAL_MODULE_ID) return `export const exclude = ${options.exclude ? (0, _astroscope_node_excludes.serializeExcludePatterns)(options.exclude) : "null"};`;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
61
|
+
//#region src/integration.ts
|
|
62
|
+
const DEFAULT_ENTRY = "src/server/contello.ts";
|
|
63
|
+
/**
|
|
64
|
+
* Astro integration for Contello.
|
|
65
|
+
*
|
|
66
|
+
* Injects the assets middleware ahead of the project's own middleware and the routing
|
|
67
|
+
* middleware after it, both bound to the project's `contello` instance, which the
|
|
68
|
+
* integration resolves from `src/server/contello.ts` (or `entry`). Runtime options
|
|
69
|
+
* (`resolveRoutePath`, assets cache control, the routes instance) live on the instance,
|
|
70
|
+
* only serializable ones belong here.
|
|
71
|
+
*/
|
|
72
|
+
function contelloIntegration(options = {}) {
|
|
73
|
+
const { entry = DEFAULT_ENTRY, assets = "pre", routing = "post", exclude = null } = options;
|
|
74
|
+
return {
|
|
75
|
+
name: "@contello/astro",
|
|
76
|
+
hooks: { "astro:config:setup": ({ config, updateConfig, addMiddleware }) => {
|
|
77
|
+
const entryPath = node_path.default.resolve((0, node_url.fileURLToPath)(config.root), entry);
|
|
78
|
+
if (!node_fs.default.existsSync(entryPath)) throw new Error(`@contello/astro: instance module ${entry} not found — export \`contello = createContello(...)\` from it or point the integration's \`entry\` option at it`);
|
|
79
|
+
if (assets) addMiddleware({
|
|
80
|
+
order: assets,
|
|
81
|
+
entrypoint: "@contello/astro/assets-middleware"
|
|
82
|
+
});
|
|
83
|
+
if (routing) addMiddleware({
|
|
84
|
+
order: routing,
|
|
85
|
+
entrypoint: "@contello/astro/routing-middleware"
|
|
86
|
+
});
|
|
87
|
+
updateConfig({ vite: { plugins: [contelloVitePlugin({
|
|
88
|
+
entry: entryPath,
|
|
89
|
+
exclude
|
|
90
|
+
})] } });
|
|
91
|
+
} }
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
//#endregion
|
|
11
95
|
//#region src/middleware.ts
|
|
12
96
|
function defineMiddleware(handler) {
|
|
13
97
|
return handler;
|
|
@@ -18,11 +102,13 @@ const { wrap } = (0, _contello_opentelemetry.createOperationTelemetry)("@contell
|
|
|
18
102
|
//#endregion
|
|
19
103
|
//#region src/assets-middleware.ts
|
|
20
104
|
const DEFAULT_IMAGES_CACHE_CONTROL = "public, max-age=31536000";
|
|
105
|
+
/**
|
|
106
|
+
* `options` is read per request: the integration creates the middleware before `init()`
|
|
107
|
+
* brings the project's assets options; `false` disables the middleware (`init({ assets: false })`).
|
|
108
|
+
*/
|
|
21
109
|
function createBoundAssetsMiddleware(contello, options) {
|
|
22
110
|
const imagesPrefix = contello.media.imagesPath;
|
|
23
|
-
const imagesCacheControl = options?.images?.cacheControl ?? DEFAULT_IMAGES_CACHE_CONTROL;
|
|
24
111
|
const filesPrefix = contello.media.filesPath;
|
|
25
|
-
const filesCacheControl = options?.files?.cacheControl;
|
|
26
112
|
const videoPrefix = contello.media.videosPath;
|
|
27
113
|
return defineMiddleware((ctx, next) => {
|
|
28
114
|
const { pathname } = ctx.url;
|
|
@@ -30,12 +116,14 @@ function createBoundAssetsMiddleware(contello, options) {
|
|
|
30
116
|
const isFile = !isImage && pathname.startsWith(filesPrefix);
|
|
31
117
|
const isVideo = !isImage && !isFile && pathname.startsWith(videoPrefix);
|
|
32
118
|
if (!isImage && !isFile && !isVideo) return next();
|
|
119
|
+
const current = options();
|
|
120
|
+
if (current === false) return next();
|
|
33
121
|
if (!contello.isReady) {
|
|
34
122
|
console.warn(`[@contello/astro] not initialized, passing through: ${pathname}`);
|
|
35
123
|
return next();
|
|
36
124
|
}
|
|
37
|
-
if (isImage) return handleFile(contello.client, next, pathname.slice(imagesPrefix.length),
|
|
38
|
-
if (isFile) return handleFile(contello.client, next, pathname.slice(filesPrefix.length),
|
|
125
|
+
if (isImage) return handleFile(contello.client, next, pathname.slice(imagesPrefix.length), current?.images?.cacheControl ?? DEFAULT_IMAGES_CACHE_CONTROL, `${imagesPrefix}[file]`);
|
|
126
|
+
if (isFile) return handleFile(contello.client, next, pathname.slice(filesPrefix.length), current?.files?.cacheControl, `${filesPrefix}[file]`);
|
|
39
127
|
return handleVideo(contello.client, next, pathname.slice(videoPrefix.length), ctx.request.signal, `${videoPrefix}[...path]`);
|
|
40
128
|
});
|
|
41
129
|
}
|
|
@@ -112,6 +200,8 @@ function createBoundRoutingMiddleware(contello, routes, exclude, resolveRoutePat
|
|
|
112
200
|
console.warn(`[@contello/astro] not initialized, passing through: ${ctx.url.pathname}`);
|
|
113
201
|
return next();
|
|
114
202
|
}
|
|
203
|
+
const current = routes();
|
|
204
|
+
if (!current) return next();
|
|
115
205
|
const { url } = ctx;
|
|
116
206
|
if (url.pathname.startsWith("/contello/entities/")) return contello[runRequest]({
|
|
117
207
|
url,
|
|
@@ -119,7 +209,7 @@ function createBoundRoutingMiddleware(contello, routes, exclude, resolveRoutePat
|
|
|
119
209
|
rewritten: false
|
|
120
210
|
}, () => next());
|
|
121
211
|
const path = resolveRoutePath ? resolveRoutePath(ctx) : url.pathname;
|
|
122
|
-
const lookup =
|
|
212
|
+
const lookup = current.getByPath(path);
|
|
123
213
|
return (0, _entwico_dash.maybeThen)(lookup, (route) => {
|
|
124
214
|
if (!route) return contello[runRequest]({
|
|
125
215
|
url,
|
|
@@ -205,8 +295,11 @@ function createBoundRoutingMiddleware(contello, routes, exclude, resolveRoutePat
|
|
|
205
295
|
const DEFAULT_IMAGES_PREFIX = "/_contello/i/";
|
|
206
296
|
const DEFAULT_FILES_PREFIX = "/_contello/f/";
|
|
207
297
|
const DEFAULT_VIDEO_PREFIX = "/_contello/v/";
|
|
298
|
+
function isLoadable(value) {
|
|
299
|
+
return typeof value.load === "function";
|
|
300
|
+
}
|
|
208
301
|
const runRequest = Symbol("@contello/astro/runRequest");
|
|
209
|
-
function
|
|
302
|
+
function createI18nRegistrations() {
|
|
210
303
|
const manifest = _astroscope_i18n.i18n.getManifest();
|
|
211
304
|
const defaultLanguage = _astroscope_i18n.i18n.getConfig().defaultLocale;
|
|
212
305
|
return manifest.keys.map((extracted) => ({
|
|
@@ -242,14 +335,20 @@ var Contello = class {
|
|
|
242
335
|
_i18nUnsubscribe;
|
|
243
336
|
_initialized = false;
|
|
244
337
|
_als = new node_async_hooks.AsyncLocalStorage();
|
|
245
|
-
|
|
338
|
+
_routes;
|
|
339
|
+
_initOptions;
|
|
340
|
+
_unregisterHealthCheck;
|
|
246
341
|
media;
|
|
247
342
|
createRoutingMiddleware = (options) => {
|
|
248
|
-
const routes = options?.routes ?? (this.
|
|
249
|
-
|
|
343
|
+
const routes = () => options?.routes ?? (this._initOptions?.routes === false ? void 0 : this.routes);
|
|
344
|
+
const resolveRoutePath = (ctx) => {
|
|
345
|
+
const resolver = options?.resolveRoutePath ?? this._initOptions?.routing?.resolveRoutePath;
|
|
346
|
+
return resolver ? resolver(ctx) : ctx.url.pathname;
|
|
347
|
+
};
|
|
348
|
+
return createBoundRoutingMiddleware(this, routes, options?.exclude, resolveRoutePath);
|
|
250
349
|
};
|
|
251
350
|
createAssetsMiddleware = (options) => {
|
|
252
|
-
return createBoundAssetsMiddleware(this, options);
|
|
351
|
+
return createBoundAssetsMiddleware(this, () => options ?? this._initOptions?.assets);
|
|
253
352
|
};
|
|
254
353
|
constructor(options) {
|
|
255
354
|
this._options = options;
|
|
@@ -261,20 +360,42 @@ var Contello = class {
|
|
|
261
360
|
filesPath: options.media?.filesPath ?? DEFAULT_FILES_PREFIX
|
|
262
361
|
};
|
|
263
362
|
}
|
|
363
|
+
createRoutes(routes) {
|
|
364
|
+
switch (routes) {
|
|
365
|
+
case false: return;
|
|
366
|
+
case "sync": return this.defineRoutesSync();
|
|
367
|
+
case "lazy": return this.defineLazyRoutes();
|
|
368
|
+
default: return routes;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
registerHealthCheck(health) {
|
|
372
|
+
if (health === false) return;
|
|
373
|
+
this._unregisterHealthCheck?.();
|
|
374
|
+
this._unregisterHealthCheck = (0, _astroscope_node_health.registerHealthCheck)({
|
|
375
|
+
name: health?.name ?? "contello",
|
|
376
|
+
check: () => this.ping(),
|
|
377
|
+
optional: health?.optional,
|
|
378
|
+
timeout: health?.timeout
|
|
379
|
+
});
|
|
380
|
+
}
|
|
264
381
|
async init(options) {
|
|
265
382
|
try {
|
|
383
|
+
this._initOptions = options;
|
|
384
|
+
this.registerHealthCheck(options.health);
|
|
266
385
|
await this._store.init();
|
|
386
|
+
this._routes = this.createRoutes(options.routes);
|
|
267
387
|
if (this._options.i18n) {
|
|
268
|
-
|
|
388
|
+
if (!options.i18n) throw new Error("@contello/astro: init() needs the i18n option (locales, locale resolver) for the configured i18n collection");
|
|
389
|
+
const { collection, cache } = this._options.i18n;
|
|
269
390
|
const dev = (0, _astroscope_node_boot.getBootContext)()?.dev ?? false;
|
|
270
|
-
const { register = !dev, load = true } = options
|
|
391
|
+
const { register = !dev, load = true, ...i18nConfig } = options.i18n;
|
|
271
392
|
this._i18nMessages = this._store.defineI18nMessages({
|
|
272
393
|
collection,
|
|
273
394
|
cache
|
|
274
395
|
});
|
|
275
|
-
await _astroscope_i18n.i18n.configure(
|
|
396
|
+
await _astroscope_i18n.i18n.configure(i18nConfig);
|
|
276
397
|
if (register) {
|
|
277
|
-
const registrations =
|
|
398
|
+
const registrations = createI18nRegistrations();
|
|
278
399
|
if (registrations.length > 0) await this._i18nMessages.register(registrations);
|
|
279
400
|
}
|
|
280
401
|
if (load) {
|
|
@@ -290,7 +411,9 @@ var Contello = class {
|
|
|
290
411
|
})();
|
|
291
412
|
}
|
|
292
413
|
}
|
|
293
|
-
|
|
414
|
+
const routes = this._routes;
|
|
415
|
+
const loadables = [...options.load ?? [], ...routes && isLoadable(routes) ? [routes] : []];
|
|
416
|
+
await Promise.all(loadables.map((l) => l.load()));
|
|
294
417
|
this._initialized = true;
|
|
295
418
|
} catch (error) {
|
|
296
419
|
try {
|
|
@@ -303,8 +426,12 @@ var Contello = class {
|
|
|
303
426
|
this._initialized = false;
|
|
304
427
|
this._i18nUnsubscribe?.();
|
|
305
428
|
this._i18nUnsubscribe = void 0;
|
|
429
|
+
this._unregisterHealthCheck?.();
|
|
430
|
+
this._unregisterHealthCheck = void 0;
|
|
306
431
|
await this._store.destroy();
|
|
307
432
|
this._i18nMessages = void 0;
|
|
433
|
+
this._routes = void 0;
|
|
434
|
+
this._initOptions = void 0;
|
|
308
435
|
}
|
|
309
436
|
ping() {
|
|
310
437
|
return this._store.ping();
|
|
@@ -315,6 +442,11 @@ var Contello = class {
|
|
|
315
442
|
get client() {
|
|
316
443
|
return this._store.client;
|
|
317
444
|
}
|
|
445
|
+
/** the routes backing the routing middleware, created by `init()` from its `routes` option */
|
|
446
|
+
get routes() {
|
|
447
|
+
if (!this._routes) throw new Error("@contello/astro: .routes accessed before init() or with routes disabled");
|
|
448
|
+
return this._routes;
|
|
449
|
+
}
|
|
318
450
|
get i18nMessages() {
|
|
319
451
|
if (!this._i18nMessages) throw new Error("@contello/astro: .i18nMessages accessed before init() with i18n config");
|
|
320
452
|
return this._i18nMessages;
|
|
@@ -373,3 +505,4 @@ function createContello(options) {
|
|
|
373
505
|
//#endregion
|
|
374
506
|
exports.Contello = Contello;
|
|
375
507
|
exports.createContello = createContello;
|
|
508
|
+
exports.default = contelloIntegration;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,48 @@
|
|
|
1
|
+
import { ExcludePattern } from "@astroscope/node/excludes";
|
|
2
|
+
import { APIContext, AstroIntegration } from "astro";
|
|
3
|
+
import { I18nConfig } from "@astroscope/i18n";
|
|
1
4
|
import { ContelloClient, Schema, SourceDef } from "@contello/client";
|
|
2
5
|
import { MediaResolver, MediaResolverOptions } from "@contello/media";
|
|
3
6
|
import { Assets, AssetsOptions, AssetsSync, AssetsSyncOptions, BuiltInWrites, Collection, CollectionOptions, CollectionSync, CollectionSyncOptions, CreateStoreOptions, ExtractSourceResult, ExtractSourceWrites, I18nMessages, LazyAssets, LazyAssetsOptions, LazyCollection, LazyCollectionOptions, LazyRoutes, LazyRoutesOptions, Loadable, ResolveSource, Routes, RoutesOptions, RoutesSync, RoutesSyncOptions, Singleton, SingletonOptions, SingletonSync, SingletonSyncOptions, SourceKeysOf, StoreRoute, SyncCacheOptions } from "@contello/store";
|
|
4
7
|
import { ReadonlyDeep } from "@entwico/dash";
|
|
5
|
-
|
|
6
|
-
|
|
8
|
+
//#region src/integration.d.ts
|
|
9
|
+
type ContelloIntegrationOptions = {
|
|
10
|
+
/**
|
|
11
|
+
* Module exporting the `contello` instance (`export const contello = createContello(...)`),
|
|
12
|
+
* relative to the project root.
|
|
13
|
+
* @default 'src/server/contello.ts'
|
|
14
|
+
*/
|
|
15
|
+
entry?: string | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Where the assets middleware (`/_contello/i/`, `/_contello/f/`, `/_contello/v/`) is injected;
|
|
18
|
+
* `false` leaves it to the project (`contello.createAssetsMiddleware()`).
|
|
19
|
+
* @default 'pre'
|
|
20
|
+
*/
|
|
21
|
+
assets?: 'pre' | false | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Where the routing middleware is injected; `false` leaves it to the project
|
|
24
|
+
* (`contello.createRoutingMiddleware()`). Post middlewares run in `integrations` order, so list
|
|
25
|
+
* `contello()` before integrations whose middleware depends on the resolved route, e.g. `@astroscope/wormhole`.
|
|
26
|
+
* @default 'post'
|
|
27
|
+
*/
|
|
28
|
+
routing?: 'post' | false | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Paths the routing middleware skips.
|
|
31
|
+
* @default RECOMMENDED_EXCLUDES from `@astroscope/node/excludes`
|
|
32
|
+
*/
|
|
33
|
+
exclude?: ExcludePattern[] | undefined;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Astro integration for Contello.
|
|
37
|
+
*
|
|
38
|
+
* Injects the assets middleware ahead of the project's own middleware and the routing
|
|
39
|
+
* middleware after it, both bound to the project's `contello` instance, which the
|
|
40
|
+
* integration resolves from `src/server/contello.ts` (or `entry`). Runtime options
|
|
41
|
+
* (`resolveRoutePath`, assets cache control, the routes instance) live on the instance,
|
|
42
|
+
* only serializable ones belong here.
|
|
43
|
+
*/
|
|
44
|
+
export default function contelloIntegration(options?: ContelloIntegrationOptions): AstroIntegration;
|
|
45
|
+
//#endregion
|
|
7
46
|
//#region src/assets-middleware.d.ts
|
|
8
47
|
type ContelloAssetsImagesOptions = {
|
|
9
48
|
cacheControl?: string | undefined;
|
|
@@ -49,18 +88,50 @@ type ContelloRequestContext = {
|
|
|
49
88
|
route: ReadonlyDeep<StoreRoute> | undefined;
|
|
50
89
|
rewritten: boolean;
|
|
51
90
|
};
|
|
91
|
+
/** The Contello i18n message collection bridged to `@astroscope/i18n`; `init()` takes the runtime side. */
|
|
52
92
|
type ContelloI18nOptions = {
|
|
53
93
|
collection: string;
|
|
54
|
-
languages: string[];
|
|
55
94
|
cache?: SyncCacheOptions | undefined;
|
|
56
95
|
};
|
|
96
|
+
/**
|
|
97
|
+
* The `@astroscope/i18n` config `init()` passes to `i18n.configure()` before it pushes the
|
|
98
|
+
* collection's translations, plus what to do with the extracted keys.
|
|
99
|
+
*/
|
|
100
|
+
type ContelloInitI18nOptions = I18nConfig & {
|
|
101
|
+
/**
|
|
102
|
+
* Register the extracted keys in the collection; defaults to `true`, except in dev mode (detected via the
|
|
103
|
+
* @astroscope/node boot context).
|
|
104
|
+
*/
|
|
105
|
+
register?: boolean | undefined;
|
|
106
|
+
/** push the collection's translations and follow its refreshes; defaults to `true` */
|
|
107
|
+
load?: boolean | undefined;
|
|
108
|
+
};
|
|
109
|
+
type ContelloRoutingOptions = {
|
|
110
|
+
resolveRoutePath?: RoutePathResolver | undefined;
|
|
111
|
+
};
|
|
112
|
+
/** The readiness check `init()` registers with `@astroscope/node/health`; `false` registers none. */
|
|
113
|
+
type ContelloHealthOptions = {
|
|
114
|
+
/** @default 'contello' */
|
|
115
|
+
name?: string | undefined;
|
|
116
|
+
optional?: boolean | undefined;
|
|
117
|
+
timeout?: number | undefined;
|
|
118
|
+
};
|
|
57
119
|
type ContelloInitOptions = {
|
|
58
120
|
load?: Loadable[] | undefined;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
121
|
+
/**
|
|
122
|
+
* Routes backing the routing middleware: `'sync'` creates and loads a `RoutesSync` (eager, synchronous
|
|
123
|
+
* lookups), `'lazy'` creates a `LazyRoutes` (fetched on demand), or an instance the project defined
|
|
124
|
+
* itself, loaded by `init()` when it is loadable. Reachable as `contello.routes` after `init()`.
|
|
125
|
+
* `false` for a project without Contello routes: the routing middleware passes through.
|
|
126
|
+
*/
|
|
127
|
+
routes: 'sync' | 'lazy' | AnyRoutes | false;
|
|
128
|
+
/** required when `createContello` got an `i18n` collection */
|
|
129
|
+
i18n?: ContelloInitI18nOptions | undefined;
|
|
130
|
+
/** defaults for the routing middleware, used by the integration-injected one */
|
|
131
|
+
routing?: ContelloRoutingOptions | undefined;
|
|
132
|
+
/** defaults for the assets middleware, used by the integration-injected one; `false` makes it pass through */
|
|
133
|
+
assets?: ContelloAssetsMiddlewareOptions | false | undefined;
|
|
134
|
+
health?: ContelloHealthOptions | false | undefined;
|
|
64
135
|
};
|
|
65
136
|
type ContelloMediaConfig = {
|
|
66
137
|
readonly baseUrl: string;
|
|
@@ -87,23 +158,29 @@ type CollectionWritesOf<TSchema, TArg> = ExtractSourceWrites<Extract<ResolveSour
|
|
|
87
158
|
type RouteWrites<TSchema> = BuiltInWrites<TSchema, 'route'>;
|
|
88
159
|
type AssetWrites<TSchema> = BuiltInWrites<TSchema, 'asset'>;
|
|
89
160
|
type SingletonRaw<TSchema, TArg> = ExtractSourceResult<Extract<ResolveSource<TSchema, TArg>, SourceDef<string, 'singleton'>>>;
|
|
90
|
-
declare class Contello<TSchema extends Schema | undefined = undefined> {
|
|
161
|
+
export declare class Contello<TSchema extends Schema | undefined = undefined> {
|
|
91
162
|
private readonly _store;
|
|
92
163
|
private readonly _options;
|
|
93
164
|
private _i18nMessages;
|
|
94
165
|
private _i18nUnsubscribe;
|
|
95
166
|
private _initialized;
|
|
96
167
|
private readonly _als;
|
|
97
|
-
private
|
|
168
|
+
private _routes;
|
|
169
|
+
private _initOptions;
|
|
170
|
+
private _unregisterHealthCheck;
|
|
98
171
|
readonly media: ContelloMediaConfig;
|
|
99
172
|
createRoutingMiddleware: (options?: ContelloRoutingMiddlewareOptions | undefined) => import("astro").MiddlewareHandler;
|
|
100
173
|
createAssetsMiddleware: (options?: ContelloAssetsMiddlewareOptions | undefined) => import("astro").MiddlewareHandler;
|
|
101
174
|
constructor(options: ContelloOptions<TSchema>);
|
|
102
|
-
|
|
175
|
+
private createRoutes;
|
|
176
|
+
private registerHealthCheck;
|
|
177
|
+
init(options: ContelloInitOptions): Promise<void>;
|
|
103
178
|
destroy(): Promise<void>;
|
|
104
179
|
ping(): Promise<void>;
|
|
105
180
|
get isReady(): boolean;
|
|
106
181
|
get client(): ContelloClient<TSchema>;
|
|
182
|
+
/** the routes backing the routing middleware, created by `init()` from its `routes` option */
|
|
183
|
+
get routes(): AnyRoutes;
|
|
107
184
|
get i18nMessages(): I18nMessages;
|
|
108
185
|
get request(): ContelloRequestContext;
|
|
109
186
|
defineMediaResolver<O extends Partial<MediaResolverOptions>>(options?: O): MediaResolver<HasFallback<O>>;
|
|
@@ -132,7 +209,7 @@ declare class Contello<TSchema extends Schema | undefined = undefined> {
|
|
|
132
209
|
defineLazyAssets(options?: LazyAssetsOptions | undefined): LazyAssets;
|
|
133
210
|
[runRequest]<T>(ctx: ContelloRequestContext, fn: () => T): T;
|
|
134
211
|
}
|
|
135
|
-
declare function createContello<TSchema extends Schema | undefined = undefined>(options: ContelloOptions<TSchema>): Contello<TSchema>;
|
|
212
|
+
export declare function createContello<TSchema extends Schema | undefined = undefined>(options: ContelloOptions<TSchema>): Contello<TSchema>;
|
|
136
213
|
//#endregion
|
|
137
|
-
export {
|
|
214
|
+
export type { AnyRoutes, ContelloAssetsFilesOptions, ContelloAssetsImagesOptions, ContelloAssetsMiddlewareOptions, ContelloAssetsVideoOptions, ContelloHealthOptions, ContelloI18nOptions, ContelloInitI18nOptions, ContelloInitOptions, ContelloIntegrationOptions, ContelloOptions, ContelloRequestContext, ContelloRoutingMiddlewareOptions, ContelloRoutingOptions, RoutePathResolver };
|
|
138
215
|
//# sourceMappingURL=index.d.cts.map
|
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/integration.ts","../src/assets-middleware.ts","../src/routing-middleware.ts","../src/contello.ts"],"mappings":";;;;;;;;KASY;;;;;;EAMV;;;;;;EAMA;;;;;;;EAOA;;;;;EAKA,UAAU;;;;;;;;;;;wBAYY,oBAAoB,UAAS,6BAAkC;;;KCvC3E;EACV;;KAGU;EACV;;KAGU,6BAA6B;KAE7B;EACV,SAAS;EACT,QAAQ;EACR,QAAQ;;;;KCTE,YAAY,SAAS,aAAa;;;;;;;;;;KAWlC,qBAAqB,KAAK;KAE1B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AU,iBAAiB,aAAa,SAAS,OAAO,SAAS,SAAS,YACzE,UAAU;EAIb,oBAAoB,aAAa,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;;wBAK7C,eAAe,gBAAgB,gCAC7C,SAAS,gBAAgB,WACxB,SAAS"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,48 @@
|
|
|
1
|
+
import { ExcludePattern } from "@astroscope/node/excludes";
|
|
2
|
+
import { I18nConfig } from "@astroscope/i18n";
|
|
1
3
|
import { MediaResolver, MediaResolverOptions } from "@contello/media";
|
|
2
4
|
import { Assets, AssetsOptions, AssetsSync, AssetsSyncOptions, BuiltInWrites, Collection, CollectionOptions, CollectionSync, CollectionSyncOptions, CreateStoreOptions, ExtractSourceResult, ExtractSourceWrites, I18nMessages, LazyAssets, LazyAssetsOptions, LazyCollection, LazyCollectionOptions, LazyRoutes, LazyRoutesOptions, Loadable, ResolveSource, Routes, RoutesOptions, RoutesSync, RoutesSyncOptions, Singleton, SingletonOptions, SingletonSync, SingletonSyncOptions, SourceKeysOf, StoreRoute, SyncCacheOptions } from "@contello/store";
|
|
3
|
-
import { ExcludePattern } from "@astroscope/node/excludes";
|
|
4
5
|
import { ReadonlyDeep } from "@entwico/dash";
|
|
6
|
+
import { APIContext, AstroIntegration } from "astro";
|
|
5
7
|
import { ContelloClient, Schema, SourceDef } from "@contello/client";
|
|
6
|
-
|
|
8
|
+
//#region src/integration.d.ts
|
|
9
|
+
type ContelloIntegrationOptions = {
|
|
10
|
+
/**
|
|
11
|
+
* Module exporting the `contello` instance (`export const contello = createContello(...)`),
|
|
12
|
+
* relative to the project root.
|
|
13
|
+
* @default 'src/server/contello.ts'
|
|
14
|
+
*/
|
|
15
|
+
entry?: string | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Where the assets middleware (`/_contello/i/`, `/_contello/f/`, `/_contello/v/`) is injected;
|
|
18
|
+
* `false` leaves it to the project (`contello.createAssetsMiddleware()`).
|
|
19
|
+
* @default 'pre'
|
|
20
|
+
*/
|
|
21
|
+
assets?: 'pre' | false | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Where the routing middleware is injected; `false` leaves it to the project
|
|
24
|
+
* (`contello.createRoutingMiddleware()`). Post middlewares run in `integrations` order, so list
|
|
25
|
+
* `contello()` before integrations whose middleware depends on the resolved route, e.g. `@astroscope/wormhole`.
|
|
26
|
+
* @default 'post'
|
|
27
|
+
*/
|
|
28
|
+
routing?: 'post' | false | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Paths the routing middleware skips.
|
|
31
|
+
* @default RECOMMENDED_EXCLUDES from `@astroscope/node/excludes`
|
|
32
|
+
*/
|
|
33
|
+
exclude?: ExcludePattern[] | undefined;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Astro integration for Contello.
|
|
37
|
+
*
|
|
38
|
+
* Injects the assets middleware ahead of the project's own middleware and the routing
|
|
39
|
+
* middleware after it, both bound to the project's `contello` instance, which the
|
|
40
|
+
* integration resolves from `src/server/contello.ts` (or `entry`). Runtime options
|
|
41
|
+
* (`resolveRoutePath`, assets cache control, the routes instance) live on the instance,
|
|
42
|
+
* only serializable ones belong here.
|
|
43
|
+
*/
|
|
44
|
+
export default function contelloIntegration(options?: ContelloIntegrationOptions): AstroIntegration;
|
|
45
|
+
//#endregion
|
|
7
46
|
//#region src/assets-middleware.d.ts
|
|
8
47
|
type ContelloAssetsImagesOptions = {
|
|
9
48
|
cacheControl?: string | undefined;
|
|
@@ -49,18 +88,50 @@ type ContelloRequestContext = {
|
|
|
49
88
|
route: ReadonlyDeep<StoreRoute> | undefined;
|
|
50
89
|
rewritten: boolean;
|
|
51
90
|
};
|
|
91
|
+
/** The Contello i18n message collection bridged to `@astroscope/i18n`; `init()` takes the runtime side. */
|
|
52
92
|
type ContelloI18nOptions = {
|
|
53
93
|
collection: string;
|
|
54
|
-
languages: string[];
|
|
55
94
|
cache?: SyncCacheOptions | undefined;
|
|
56
95
|
};
|
|
96
|
+
/**
|
|
97
|
+
* The `@astroscope/i18n` config `init()` passes to `i18n.configure()` before it pushes the
|
|
98
|
+
* collection's translations, plus what to do with the extracted keys.
|
|
99
|
+
*/
|
|
100
|
+
type ContelloInitI18nOptions = I18nConfig & {
|
|
101
|
+
/**
|
|
102
|
+
* Register the extracted keys in the collection; defaults to `true`, except in dev mode (detected via the
|
|
103
|
+
* @astroscope/node boot context).
|
|
104
|
+
*/
|
|
105
|
+
register?: boolean | undefined;
|
|
106
|
+
/** push the collection's translations and follow its refreshes; defaults to `true` */
|
|
107
|
+
load?: boolean | undefined;
|
|
108
|
+
};
|
|
109
|
+
type ContelloRoutingOptions = {
|
|
110
|
+
resolveRoutePath?: RoutePathResolver | undefined;
|
|
111
|
+
};
|
|
112
|
+
/** The readiness check `init()` registers with `@astroscope/node/health`; `false` registers none. */
|
|
113
|
+
type ContelloHealthOptions = {
|
|
114
|
+
/** @default 'contello' */
|
|
115
|
+
name?: string | undefined;
|
|
116
|
+
optional?: boolean | undefined;
|
|
117
|
+
timeout?: number | undefined;
|
|
118
|
+
};
|
|
57
119
|
type ContelloInitOptions = {
|
|
58
120
|
load?: Loadable[] | undefined;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
121
|
+
/**
|
|
122
|
+
* Routes backing the routing middleware: `'sync'` creates and loads a `RoutesSync` (eager, synchronous
|
|
123
|
+
* lookups), `'lazy'` creates a `LazyRoutes` (fetched on demand), or an instance the project defined
|
|
124
|
+
* itself, loaded by `init()` when it is loadable. Reachable as `contello.routes` after `init()`.
|
|
125
|
+
* `false` for a project without Contello routes: the routing middleware passes through.
|
|
126
|
+
*/
|
|
127
|
+
routes: 'sync' | 'lazy' | AnyRoutes | false;
|
|
128
|
+
/** required when `createContello` got an `i18n` collection */
|
|
129
|
+
i18n?: ContelloInitI18nOptions | undefined;
|
|
130
|
+
/** defaults for the routing middleware, used by the integration-injected one */
|
|
131
|
+
routing?: ContelloRoutingOptions | undefined;
|
|
132
|
+
/** defaults for the assets middleware, used by the integration-injected one; `false` makes it pass through */
|
|
133
|
+
assets?: ContelloAssetsMiddlewareOptions | false | undefined;
|
|
134
|
+
health?: ContelloHealthOptions | false | undefined;
|
|
64
135
|
};
|
|
65
136
|
type ContelloMediaConfig = {
|
|
66
137
|
readonly baseUrl: string;
|
|
@@ -87,23 +158,29 @@ type CollectionWritesOf<TSchema, TArg> = ExtractSourceWrites<Extract<ResolveSour
|
|
|
87
158
|
type RouteWrites<TSchema> = BuiltInWrites<TSchema, 'route'>;
|
|
88
159
|
type AssetWrites<TSchema> = BuiltInWrites<TSchema, 'asset'>;
|
|
89
160
|
type SingletonRaw<TSchema, TArg> = ExtractSourceResult<Extract<ResolveSource<TSchema, TArg>, SourceDef<string, 'singleton'>>>;
|
|
90
|
-
declare class Contello<TSchema extends Schema | undefined = undefined> {
|
|
161
|
+
export declare class Contello<TSchema extends Schema | undefined = undefined> {
|
|
91
162
|
private readonly _store;
|
|
92
163
|
private readonly _options;
|
|
93
164
|
private _i18nMessages;
|
|
94
165
|
private _i18nUnsubscribe;
|
|
95
166
|
private _initialized;
|
|
96
167
|
private readonly _als;
|
|
97
|
-
private
|
|
168
|
+
private _routes;
|
|
169
|
+
private _initOptions;
|
|
170
|
+
private _unregisterHealthCheck;
|
|
98
171
|
readonly media: ContelloMediaConfig;
|
|
99
172
|
createRoutingMiddleware: (options?: ContelloRoutingMiddlewareOptions | undefined) => import("astro").MiddlewareHandler;
|
|
100
173
|
createAssetsMiddleware: (options?: ContelloAssetsMiddlewareOptions | undefined) => import("astro").MiddlewareHandler;
|
|
101
174
|
constructor(options: ContelloOptions<TSchema>);
|
|
102
|
-
|
|
175
|
+
private createRoutes;
|
|
176
|
+
private registerHealthCheck;
|
|
177
|
+
init(options: ContelloInitOptions): Promise<void>;
|
|
103
178
|
destroy(): Promise<void>;
|
|
104
179
|
ping(): Promise<void>;
|
|
105
180
|
get isReady(): boolean;
|
|
106
181
|
get client(): ContelloClient<TSchema>;
|
|
182
|
+
/** the routes backing the routing middleware, created by `init()` from its `routes` option */
|
|
183
|
+
get routes(): AnyRoutes;
|
|
107
184
|
get i18nMessages(): I18nMessages;
|
|
108
185
|
get request(): ContelloRequestContext;
|
|
109
186
|
defineMediaResolver<O extends Partial<MediaResolverOptions>>(options?: O): MediaResolver<HasFallback<O>>;
|
|
@@ -132,7 +209,7 @@ declare class Contello<TSchema extends Schema | undefined = undefined> {
|
|
|
132
209
|
defineLazyAssets(options?: LazyAssetsOptions | undefined): LazyAssets;
|
|
133
210
|
[runRequest]<T>(ctx: ContelloRequestContext, fn: () => T): T;
|
|
134
211
|
}
|
|
135
|
-
declare function createContello<TSchema extends Schema | undefined = undefined>(options: ContelloOptions<TSchema>): Contello<TSchema>;
|
|
212
|
+
export declare function createContello<TSchema extends Schema | undefined = undefined>(options: ContelloOptions<TSchema>): Contello<TSchema>;
|
|
136
213
|
//#endregion
|
|
137
|
-
export {
|
|
214
|
+
export type { AnyRoutes, ContelloAssetsFilesOptions, ContelloAssetsImagesOptions, ContelloAssetsMiddlewareOptions, ContelloAssetsVideoOptions, ContelloHealthOptions, ContelloI18nOptions, ContelloInitI18nOptions, ContelloInitOptions, ContelloIntegrationOptions, ContelloOptions, ContelloRequestContext, ContelloRoutingMiddlewareOptions, ContelloRoutingOptions, RoutePathResolver };
|
|
138
215
|
//# sourceMappingURL=index.d.ts.map
|
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/integration.ts","../src/assets-middleware.ts","../src/routing-middleware.ts","../src/contello.ts"],"mappings":";;;;;;;;KASY;;;;;;EAMV;;;;;;EAMA;;;;;;;EAOA;;;;;EAKA,UAAU;;;;;;;;;;;wBAYY,oBAAoB,UAAS,6BAAkC;;;KCvC3E;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;;;;KCuBT;EACV,KAAK;EACL,OAAO,aAAa;EACpB;;;KAIU;EACV;EACA,QAAQ;;;;;;KAOE,0BAA0B;;;;;EAKpC;;EAEA;;KAGU;EACV,mBAAmB;;;KAIT;;EAEV;EACA;EACA;;KAGU;EACV,OAAO;;;;;;;EAOP,0BAA0B;;EAE1B,OAAO;;EAEP,UAAU;;EAEV,SAAS;EACT,SAAS;;KAGC;WACD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,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;;wBAK7C,eAAe,gBAAgB,gCAC7C,SAAS,gBAAgB,WACxB,SAAS"}
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,69 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { RECOMMENDED_EXCLUDES, serializeExcludePatterns, shouldExclude } from "@astroscope/node/excludes";
|
|
1
5
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
6
|
import { i18n } from "@astroscope/i18n";
|
|
3
7
|
import { getBootContext } from "@astroscope/node/boot";
|
|
8
|
+
import { registerHealthCheck } from "@astroscope/node/health";
|
|
4
9
|
import { createMediaResolver } from "@contello/media";
|
|
5
10
|
import { createStore } from "@contello/store";
|
|
6
11
|
import { overrideRequestRoute } from "@astroscope/node/log";
|
|
7
12
|
import { createOperationTelemetry, updateActiveSpan } from "@contello/opentelemetry";
|
|
8
|
-
import { RECOMMENDED_EXCLUDES, shouldExclude } from "@astroscope/node/excludes";
|
|
9
13
|
import { maybeThen } from "@entwico/dash";
|
|
14
|
+
const RESOLVED_CONFIG_VIRTUAL_MODULE_ID = `\0virtual:@contello/astro/config`;
|
|
15
|
+
/**
|
|
16
|
+
* Resolves the instance id straight to the project's module, so the injected
|
|
17
|
+
* middlewares and the project's own imports share one `Contello` instance, and
|
|
18
|
+
* serves the serializable integration options as a config module.
|
|
19
|
+
*/
|
|
20
|
+
function contelloVitePlugin(options) {
|
|
21
|
+
return {
|
|
22
|
+
name: "@contello/astro",
|
|
23
|
+
resolveId(id) {
|
|
24
|
+
if (id === "virtual:@contello/astro/instance") return options.entry;
|
|
25
|
+
if (id === "virtual:@contello/astro/config") return RESOLVED_CONFIG_VIRTUAL_MODULE_ID;
|
|
26
|
+
},
|
|
27
|
+
load(id) {
|
|
28
|
+
if (id === RESOLVED_CONFIG_VIRTUAL_MODULE_ID) return `export const exclude = ${options.exclude ? serializeExcludePatterns(options.exclude) : "null"};`;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region src/integration.ts
|
|
34
|
+
const DEFAULT_ENTRY = "src/server/contello.ts";
|
|
35
|
+
/**
|
|
36
|
+
* Astro integration for Contello.
|
|
37
|
+
*
|
|
38
|
+
* Injects the assets middleware ahead of the project's own middleware and the routing
|
|
39
|
+
* middleware after it, both bound to the project's `contello` instance, which the
|
|
40
|
+
* integration resolves from `src/server/contello.ts` (or `entry`). Runtime options
|
|
41
|
+
* (`resolveRoutePath`, assets cache control, the routes instance) live on the instance,
|
|
42
|
+
* only serializable ones belong here.
|
|
43
|
+
*/
|
|
44
|
+
function contelloIntegration(options = {}) {
|
|
45
|
+
const { entry = DEFAULT_ENTRY, assets = "pre", routing = "post", exclude = null } = options;
|
|
46
|
+
return {
|
|
47
|
+
name: "@contello/astro",
|
|
48
|
+
hooks: { "astro:config:setup": ({ config, updateConfig, addMiddleware }) => {
|
|
49
|
+
const entryPath = path.resolve(fileURLToPath(config.root), entry);
|
|
50
|
+
if (!fs.existsSync(entryPath)) throw new Error(`@contello/astro: instance module ${entry} not found — export \`contello = createContello(...)\` from it or point the integration's \`entry\` option at it`);
|
|
51
|
+
if (assets) addMiddleware({
|
|
52
|
+
order: assets,
|
|
53
|
+
entrypoint: "@contello/astro/assets-middleware"
|
|
54
|
+
});
|
|
55
|
+
if (routing) addMiddleware({
|
|
56
|
+
order: routing,
|
|
57
|
+
entrypoint: "@contello/astro/routing-middleware"
|
|
58
|
+
});
|
|
59
|
+
updateConfig({ vite: { plugins: [contelloVitePlugin({
|
|
60
|
+
entry: entryPath,
|
|
61
|
+
exclude
|
|
62
|
+
})] } });
|
|
63
|
+
} }
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
//#endregion
|
|
10
67
|
//#region src/middleware.ts
|
|
11
68
|
function defineMiddleware(handler) {
|
|
12
69
|
return handler;
|
|
@@ -17,11 +74,13 @@ const { wrap } = createOperationTelemetry("@contello/astro");
|
|
|
17
74
|
//#endregion
|
|
18
75
|
//#region src/assets-middleware.ts
|
|
19
76
|
const DEFAULT_IMAGES_CACHE_CONTROL = "public, max-age=31536000";
|
|
77
|
+
/**
|
|
78
|
+
* `options` is read per request: the integration creates the middleware before `init()`
|
|
79
|
+
* brings the project's assets options; `false` disables the middleware (`init({ assets: false })`).
|
|
80
|
+
*/
|
|
20
81
|
function createBoundAssetsMiddleware(contello, options) {
|
|
21
82
|
const imagesPrefix = contello.media.imagesPath;
|
|
22
|
-
const imagesCacheControl = options?.images?.cacheControl ?? DEFAULT_IMAGES_CACHE_CONTROL;
|
|
23
83
|
const filesPrefix = contello.media.filesPath;
|
|
24
|
-
const filesCacheControl = options?.files?.cacheControl;
|
|
25
84
|
const videoPrefix = contello.media.videosPath;
|
|
26
85
|
return defineMiddleware((ctx, next) => {
|
|
27
86
|
const { pathname } = ctx.url;
|
|
@@ -29,12 +88,14 @@ function createBoundAssetsMiddleware(contello, options) {
|
|
|
29
88
|
const isFile = !isImage && pathname.startsWith(filesPrefix);
|
|
30
89
|
const isVideo = !isImage && !isFile && pathname.startsWith(videoPrefix);
|
|
31
90
|
if (!isImage && !isFile && !isVideo) return next();
|
|
91
|
+
const current = options();
|
|
92
|
+
if (current === false) return next();
|
|
32
93
|
if (!contello.isReady) {
|
|
33
94
|
console.warn(`[@contello/astro] not initialized, passing through: ${pathname}`);
|
|
34
95
|
return next();
|
|
35
96
|
}
|
|
36
|
-
if (isImage) return handleFile(contello.client, next, pathname.slice(imagesPrefix.length),
|
|
37
|
-
if (isFile) return handleFile(contello.client, next, pathname.slice(filesPrefix.length),
|
|
97
|
+
if (isImage) return handleFile(contello.client, next, pathname.slice(imagesPrefix.length), current?.images?.cacheControl ?? DEFAULT_IMAGES_CACHE_CONTROL, `${imagesPrefix}[file]`);
|
|
98
|
+
if (isFile) return handleFile(contello.client, next, pathname.slice(filesPrefix.length), current?.files?.cacheControl, `${filesPrefix}[file]`);
|
|
38
99
|
return handleVideo(contello.client, next, pathname.slice(videoPrefix.length), ctx.request.signal, `${videoPrefix}[...path]`);
|
|
39
100
|
});
|
|
40
101
|
}
|
|
@@ -111,6 +172,8 @@ function createBoundRoutingMiddleware(contello, routes, exclude, resolveRoutePat
|
|
|
111
172
|
console.warn(`[@contello/astro] not initialized, passing through: ${ctx.url.pathname}`);
|
|
112
173
|
return next();
|
|
113
174
|
}
|
|
175
|
+
const current = routes();
|
|
176
|
+
if (!current) return next();
|
|
114
177
|
const { url } = ctx;
|
|
115
178
|
if (url.pathname.startsWith("/contello/entities/")) return contello[runRequest]({
|
|
116
179
|
url,
|
|
@@ -118,7 +181,7 @@ function createBoundRoutingMiddleware(contello, routes, exclude, resolveRoutePat
|
|
|
118
181
|
rewritten: false
|
|
119
182
|
}, () => next());
|
|
120
183
|
const path = resolveRoutePath ? resolveRoutePath(ctx) : url.pathname;
|
|
121
|
-
const lookup =
|
|
184
|
+
const lookup = current.getByPath(path);
|
|
122
185
|
return maybeThen(lookup, (route) => {
|
|
123
186
|
if (!route) return contello[runRequest]({
|
|
124
187
|
url,
|
|
@@ -204,8 +267,11 @@ function createBoundRoutingMiddleware(contello, routes, exclude, resolveRoutePat
|
|
|
204
267
|
const DEFAULT_IMAGES_PREFIX = "/_contello/i/";
|
|
205
268
|
const DEFAULT_FILES_PREFIX = "/_contello/f/";
|
|
206
269
|
const DEFAULT_VIDEO_PREFIX = "/_contello/v/";
|
|
270
|
+
function isLoadable(value) {
|
|
271
|
+
return typeof value.load === "function";
|
|
272
|
+
}
|
|
207
273
|
const runRequest = Symbol("@contello/astro/runRequest");
|
|
208
|
-
function
|
|
274
|
+
function createI18nRegistrations() {
|
|
209
275
|
const manifest = i18n.getManifest();
|
|
210
276
|
const defaultLanguage = i18n.getConfig().defaultLocale;
|
|
211
277
|
return manifest.keys.map((extracted) => ({
|
|
@@ -241,14 +307,20 @@ var Contello = class {
|
|
|
241
307
|
_i18nUnsubscribe;
|
|
242
308
|
_initialized = false;
|
|
243
309
|
_als = new AsyncLocalStorage();
|
|
244
|
-
|
|
310
|
+
_routes;
|
|
311
|
+
_initOptions;
|
|
312
|
+
_unregisterHealthCheck;
|
|
245
313
|
media;
|
|
246
314
|
createRoutingMiddleware = (options) => {
|
|
247
|
-
const routes = options?.routes ?? (this.
|
|
248
|
-
|
|
315
|
+
const routes = () => options?.routes ?? (this._initOptions?.routes === false ? void 0 : this.routes);
|
|
316
|
+
const resolveRoutePath = (ctx) => {
|
|
317
|
+
const resolver = options?.resolveRoutePath ?? this._initOptions?.routing?.resolveRoutePath;
|
|
318
|
+
return resolver ? resolver(ctx) : ctx.url.pathname;
|
|
319
|
+
};
|
|
320
|
+
return createBoundRoutingMiddleware(this, routes, options?.exclude, resolveRoutePath);
|
|
249
321
|
};
|
|
250
322
|
createAssetsMiddleware = (options) => {
|
|
251
|
-
return createBoundAssetsMiddleware(this, options);
|
|
323
|
+
return createBoundAssetsMiddleware(this, () => options ?? this._initOptions?.assets);
|
|
252
324
|
};
|
|
253
325
|
constructor(options) {
|
|
254
326
|
this._options = options;
|
|
@@ -260,20 +332,42 @@ var Contello = class {
|
|
|
260
332
|
filesPath: options.media?.filesPath ?? DEFAULT_FILES_PREFIX
|
|
261
333
|
};
|
|
262
334
|
}
|
|
335
|
+
createRoutes(routes) {
|
|
336
|
+
switch (routes) {
|
|
337
|
+
case false: return;
|
|
338
|
+
case "sync": return this.defineRoutesSync();
|
|
339
|
+
case "lazy": return this.defineLazyRoutes();
|
|
340
|
+
default: return routes;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
registerHealthCheck(health) {
|
|
344
|
+
if (health === false) return;
|
|
345
|
+
this._unregisterHealthCheck?.();
|
|
346
|
+
this._unregisterHealthCheck = registerHealthCheck({
|
|
347
|
+
name: health?.name ?? "contello",
|
|
348
|
+
check: () => this.ping(),
|
|
349
|
+
optional: health?.optional,
|
|
350
|
+
timeout: health?.timeout
|
|
351
|
+
});
|
|
352
|
+
}
|
|
263
353
|
async init(options) {
|
|
264
354
|
try {
|
|
355
|
+
this._initOptions = options;
|
|
356
|
+
this.registerHealthCheck(options.health);
|
|
265
357
|
await this._store.init();
|
|
358
|
+
this._routes = this.createRoutes(options.routes);
|
|
266
359
|
if (this._options.i18n) {
|
|
267
|
-
|
|
360
|
+
if (!options.i18n) throw new Error("@contello/astro: init() needs the i18n option (locales, locale resolver) for the configured i18n collection");
|
|
361
|
+
const { collection, cache } = this._options.i18n;
|
|
268
362
|
const dev = getBootContext()?.dev ?? false;
|
|
269
|
-
const { register = !dev, load = true } = options
|
|
363
|
+
const { register = !dev, load = true, ...i18nConfig } = options.i18n;
|
|
270
364
|
this._i18nMessages = this._store.defineI18nMessages({
|
|
271
365
|
collection,
|
|
272
366
|
cache
|
|
273
367
|
});
|
|
274
|
-
await i18n.configure(
|
|
368
|
+
await i18n.configure(i18nConfig);
|
|
275
369
|
if (register) {
|
|
276
|
-
const registrations =
|
|
370
|
+
const registrations = createI18nRegistrations();
|
|
277
371
|
if (registrations.length > 0) await this._i18nMessages.register(registrations);
|
|
278
372
|
}
|
|
279
373
|
if (load) {
|
|
@@ -289,7 +383,9 @@ var Contello = class {
|
|
|
289
383
|
})();
|
|
290
384
|
}
|
|
291
385
|
}
|
|
292
|
-
|
|
386
|
+
const routes = this._routes;
|
|
387
|
+
const loadables = [...options.load ?? [], ...routes && isLoadable(routes) ? [routes] : []];
|
|
388
|
+
await Promise.all(loadables.map((l) => l.load()));
|
|
293
389
|
this._initialized = true;
|
|
294
390
|
} catch (error) {
|
|
295
391
|
try {
|
|
@@ -302,8 +398,12 @@ var Contello = class {
|
|
|
302
398
|
this._initialized = false;
|
|
303
399
|
this._i18nUnsubscribe?.();
|
|
304
400
|
this._i18nUnsubscribe = void 0;
|
|
401
|
+
this._unregisterHealthCheck?.();
|
|
402
|
+
this._unregisterHealthCheck = void 0;
|
|
305
403
|
await this._store.destroy();
|
|
306
404
|
this._i18nMessages = void 0;
|
|
405
|
+
this._routes = void 0;
|
|
406
|
+
this._initOptions = void 0;
|
|
307
407
|
}
|
|
308
408
|
ping() {
|
|
309
409
|
return this._store.ping();
|
|
@@ -314,6 +414,11 @@ var Contello = class {
|
|
|
314
414
|
get client() {
|
|
315
415
|
return this._store.client;
|
|
316
416
|
}
|
|
417
|
+
/** the routes backing the routing middleware, created by `init()` from its `routes` option */
|
|
418
|
+
get routes() {
|
|
419
|
+
if (!this._routes) throw new Error("@contello/astro: .routes accessed before init() or with routes disabled");
|
|
420
|
+
return this._routes;
|
|
421
|
+
}
|
|
317
422
|
get i18nMessages() {
|
|
318
423
|
if (!this._i18nMessages) throw new Error("@contello/astro: .i18nMessages accessed before init() with i18n config");
|
|
319
424
|
return this._i18nMessages;
|
|
@@ -370,6 +475,6 @@ function createContello(options) {
|
|
|
370
475
|
return new Contello(options);
|
|
371
476
|
}
|
|
372
477
|
//#endregion
|
|
373
|
-
export { Contello, createContello };
|
|
478
|
+
export { Contello, createContello, contelloIntegration as default };
|
|
374
479
|
|
|
375
480
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/middleware.ts","../src/telemetry.ts","../src/assets-middleware.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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,aAAoB,OAAc;CAC3E;CAEA,iBAIE,aACA,SACwD;EACxD,OAAO,KAAK,OAAO,iBAAiB,aAAoB,OAAc;CAIxE;CAEA,qBAIE,aACA,SAC4D;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"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/vite-plugin.ts","../src/integration.ts","../src/middleware.ts","../src/telemetry.ts","../src/assets-middleware.ts","../src/routing-middleware.ts","../src/contello.ts"],"sourcesContent":["import { type ExcludePattern, serializeExcludePatterns } from '@astroscope/node/excludes';\nimport type { Plugin } from 'vite';\n\nexport const INSTANCE_VIRTUAL_MODULE_ID = 'virtual:@contello/astro/instance';\nexport const CONFIG_VIRTUAL_MODULE_ID = 'virtual:@contello/astro/config';\n\nconst RESOLVED_CONFIG_VIRTUAL_MODULE_ID = `\\0${CONFIG_VIRTUAL_MODULE_ID}`;\n\nexport type ContelloVitePluginOptions = {\n /** absolute path of the module exporting the `contello` instance */\n entry: string;\n /** routing exclude patterns, null for the middleware default */\n exclude: ExcludePattern[] | null;\n};\n\n/**\n * Resolves the instance id straight to the project's module, so the injected\n * middlewares and the project's own imports share one `Contello` instance, and\n * serves the serializable integration options as a config module.\n */\nexport function contelloVitePlugin(options: ContelloVitePluginOptions): Plugin {\n return {\n name: '@contello/astro',\n\n resolveId(id) {\n if (id === INSTANCE_VIRTUAL_MODULE_ID) {\n return options.entry;\n }\n\n if (id === CONFIG_VIRTUAL_MODULE_ID) {\n return RESOLVED_CONFIG_VIRTUAL_MODULE_ID;\n }\n },\n\n load(id) {\n if (id === RESOLVED_CONFIG_VIRTUAL_MODULE_ID) {\n // exclude patterns may contain RegExp — serialized as code, not JSON\n return `export const exclude = ${options.exclude ? serializeExcludePatterns(options.exclude) : 'null'};`;\n }\n },\n };\n}\n","import fs from 'node:fs';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport type { ExcludePattern } from '@astroscope/node/excludes';\nimport type { AstroIntegration } from 'astro';\nimport { contelloVitePlugin } from './vite-plugin';\n\nconst DEFAULT_ENTRY = 'src/server/contello.ts';\n\nexport type ContelloIntegrationOptions = {\n /**\n * Module exporting the `contello` instance (`export const contello = createContello(...)`),\n * relative to the project root.\n * @default 'src/server/contello.ts'\n */\n entry?: string | undefined;\n /**\n * Where the assets middleware (`/_contello/i/`, `/_contello/f/`, `/_contello/v/`) is injected;\n * `false` leaves it to the project (`contello.createAssetsMiddleware()`).\n * @default 'pre'\n */\n assets?: 'pre' | false | undefined;\n /**\n * Where the routing middleware is injected; `false` leaves it to the project\n * (`contello.createRoutingMiddleware()`). Post middlewares run in `integrations` order, so list\n * `contello()` before integrations whose middleware depends on the resolved route, e.g. `@astroscope/wormhole`.\n * @default 'post'\n */\n routing?: 'post' | false | undefined;\n /**\n * Paths the routing middleware skips.\n * @default RECOMMENDED_EXCLUDES from `@astroscope/node/excludes`\n */\n exclude?: ExcludePattern[] | undefined;\n};\n\n/**\n * Astro integration for Contello.\n *\n * Injects the assets middleware ahead of the project's own middleware and the routing\n * middleware after it, both bound to the project's `contello` instance, which the\n * integration resolves from `src/server/contello.ts` (or `entry`). Runtime options\n * (`resolveRoutePath`, assets cache control, the routes instance) live on the instance,\n * only serializable ones belong here.\n */\nexport default function contelloIntegration(options: ContelloIntegrationOptions = {}): AstroIntegration {\n const { entry = DEFAULT_ENTRY, assets = 'pre', routing = 'post', exclude = null } = options;\n\n return {\n name: '@contello/astro',\n hooks: {\n 'astro:config:setup': ({ config, updateConfig, addMiddleware }) => {\n const entryPath = path.resolve(fileURLToPath(config.root), entry);\n\n if (!fs.existsSync(entryPath)) {\n throw new Error(\n `@contello/astro: instance module ${entry} not found — ` +\n 'export `contello = createContello(...)` from it or point the integration\\'s `entry` option at it',\n );\n }\n\n if (assets) {\n addMiddleware({ order: assets, entrypoint: '@contello/astro/assets-middleware' });\n }\n\n if (routing) {\n addMiddleware({ order: routing, entrypoint: '@contello/astro/routing-middleware' });\n }\n\n updateConfig({\n vite: {\n plugins: [contelloVitePlugin({ entry: entryPath, exclude })],\n },\n });\n },\n },\n };\n}\n","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\n/**\n * `options` is read per request: the integration creates the middleware before `init()`\n * brings the project's assets options; `false` disables the middleware (`init({ assets: false })`).\n */\nexport function createBoundAssetsMiddleware(\n contello: Contello<any>,\n options: () => ContelloAssetsMiddlewareOptions | false | undefined,\n) {\n const imagesPrefix = contello.media.imagesPath;\n const filesPrefix = contello.media.filesPath;\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 const current = options();\n\n if (current === false) {\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 current?.images?.cacheControl ?? DEFAULT_IMAGES_CACHE_CONTROL,\n `${imagesPrefix}[file]`,\n );\n }\n\n if (isFile) {\n return handleFile(\n contello.client,\n next,\n pathname.slice(filesPrefix.length),\n current?.files?.cacheControl,\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 | undefined,\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 // undefined: the project disabled routing (`init({ routes: false })`)\n const current = routes();\n\n if (!current) {\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 = current.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](\n { url, route, rewritten: false },\n () => wrap(\n 'route:redirect',\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](\n { url, route, rewritten: false },\n () => wrap(\n 'route:text',\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](\n { 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](\n { 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](\n { 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 I18nConfig, type RawTranslations, i18n } from '@astroscope/i18n';\nimport { getBootContext } from '@astroscope/node/boot';\nimport { registerHealthCheck } from '@astroscope/node/health';\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 {\n type AnyRoutes,\n type ContelloRoutingMiddlewareOptions,\n type RoutePathResolver,\n createBoundRoutingMiddleware,\n} 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\n/** The Contello i18n message collection bridged to `@astroscope/i18n`; `init()` takes the runtime side. */\nexport type ContelloI18nOptions = {\n collection: string;\n cache?: SyncCacheOptions | undefined;\n};\n\n/**\n * The `@astroscope/i18n` config `init()` passes to `i18n.configure()` before it pushes the\n * collection's translations, plus what to do with the extracted keys.\n */\nexport type ContelloInitI18nOptions = I18nConfig & {\n /**\n * Register the extracted keys in the collection; defaults to `true`, except in dev mode (detected via the\n * @astroscope/node boot context).\n */\n register?: boolean | undefined;\n /** push the collection's translations and follow its refreshes; defaults to `true` */\n load?: boolean | undefined;\n};\n\nexport type ContelloRoutingOptions = {\n resolveRoutePath?: RoutePathResolver | undefined;\n};\n\n/** The readiness check `init()` registers with `@astroscope/node/health`; `false` registers none. */\nexport type ContelloHealthOptions = {\n /** @default 'contello' */\n name?: string | undefined;\n optional?: boolean | undefined;\n timeout?: number | undefined;\n};\n\nexport type ContelloInitOptions = {\n load?: Loadable[] | undefined;\n /**\n * Routes backing the routing middleware: `'sync'` creates and loads a `RoutesSync` (eager, synchronous\n * lookups), `'lazy'` creates a `LazyRoutes` (fetched on demand), or an instance the project defined\n * itself, loaded by `init()` when it is loadable. Reachable as `contello.routes` after `init()`.\n * `false` for a project without Contello routes: the routing middleware passes through.\n */\n routes: 'sync' | 'lazy' | AnyRoutes | false;\n /** required when `createContello` got an `i18n` collection */\n i18n?: ContelloInitI18nOptions | undefined;\n /** defaults for the routing middleware, used by the integration-injected one */\n routing?: ContelloRoutingOptions | undefined;\n /** defaults for the assets middleware, used by the integration-injected one; `false` makes it pass through */\n assets?: ContelloAssetsMiddlewareOptions | false | undefined;\n health?: ContelloHealthOptions | false | 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\nfunction isLoadable(value: object): value is Loadable {\n return typeof (value as Partial<Loadable>).load === 'function';\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 createI18nRegistrations(): 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 _routes: AnyRoutes | undefined;\n private _initOptions: ContelloInitOptions | undefined;\n private _unregisterHealthCheck: (() => void) | undefined;\n\n readonly media: ContelloMediaConfig;\n\n // --- middleware factories (arrow fields so destructuring works) ---\n\n createRoutingMiddleware = (options?: ContelloRoutingMiddlewareOptions | undefined) => {\n // resolved per request: the integration creates the middleware before init() brings the routes and options\n const routes = () => options?.routes ?? (this._initOptions?.routes === false ? undefined : this.routes);\n const resolveRoutePath: RoutePathResolver = (ctx) => {\n const resolver = options?.resolveRoutePath ?? this._initOptions?.routing?.resolveRoutePath;\n\n return resolver ? resolver(ctx) : ctx.url.pathname;\n };\n\n return createBoundRoutingMiddleware(this, routes, options?.exclude, resolveRoutePath);\n };\n\n createAssetsMiddleware = (options?: ContelloAssetsMiddlewareOptions | undefined) => {\n return createBoundAssetsMiddleware(this, () => options ?? this._initOptions?.assets);\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 private createRoutes(routes: ContelloInitOptions['routes']): AnyRoutes | undefined {\n switch (routes) {\n case false: {\n return undefined;\n }\n\n case 'sync': {\n return this.defineRoutesSync();\n }\n\n case 'lazy': {\n return this.defineLazyRoutes();\n }\n\n default: {\n return routes;\n }\n }\n }\n\n private registerHealthCheck(health: ContelloHealthOptions | false | undefined): void {\n if (health === false) {\n return;\n }\n\n this._unregisterHealthCheck?.();\n this._unregisterHealthCheck = registerHealthCheck({\n name: health?.name ?? 'contello',\n check: () => this.ping(),\n optional: health?.optional,\n timeout: health?.timeout,\n });\n }\n\n async init(options: ContelloInitOptions): Promise<void> {\n try {\n this._initOptions = options;\n\n this.registerHealthCheck(options.health);\n\n await this._store.init();\n\n this._routes = this.createRoutes(options.routes);\n\n if (this._options.i18n) {\n if (!options.i18n) {\n throw new Error('@contello/astro: init() needs the i18n option (locales, locale resolver) for the configured i18n collection');\n }\n\n const { collection, cache } = this._options.i18n;\n const dev = getBootContext()?.dev ?? false;\n const { register = !dev, load = true, ...i18nConfig } = options.i18n;\n\n this._i18nMessages = this._store.defineI18nMessages({ collection, cache });\n\n await i18n.configure(i18nConfig);\n\n if (register) {\n const registrations = createI18nRegistrations();\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 const routes = this._routes;\n const loadables = [...(options.load ?? []), ...(routes && isLoadable(routes) ? [routes] : [])];\n\n await Promise.all(loadables.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 this._unregisterHealthCheck?.();\n this._unregisterHealthCheck = undefined;\n\n await this._store.destroy();\n\n this._i18nMessages = undefined;\n this._routes = undefined;\n this._initOptions = 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 /** the routes backing the routing middleware, created by `init()` from its `routes` option */\n get routes(): AnyRoutes {\n if (!this._routes) {\n throw new Error('@contello/astro: .routes accessed before init() or with routes disabled');\n }\n\n return this._routes;\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":";;;;;;;;;;;;;AAMA,MAAM,oCAAoC;;;;;;AAc1C,SAAgB,mBAAmB,SAA4C;CAC7E,OAAO;EACL,MAAM;EAEN,UAAU,IAAI;GACZ,IAAI,OAAA,oCACF,OAAO,QAAQ;GAGjB,IAAI,OAAA,kCACF,OAAO;EAEX;EAEA,KAAK,IAAI;GACP,IAAI,OAAO,mCAET,OAAO,0BAA0B,QAAQ,UAAU,yBAAyB,QAAQ,OAAO,IAAI,OAAO;EAE1G;CACF;AACF;;;AClCA,MAAM,gBAAgB;;;;;;;;;;AAsCtB,SAAwB,oBAAoB,UAAsC,CAAC,GAAqB;CACtG,MAAM,EAAE,QAAQ,eAAe,SAAS,OAAO,UAAU,QAAQ,UAAU,SAAS;CAEpF,OAAO;EACL,MAAM;EACN,OAAO,EACL,uBAAuB,EAAE,QAAQ,cAAc,oBAAoB;GACjE,MAAM,YAAY,KAAK,QAAQ,cAAc,OAAO,IAAI,GAAG,KAAK;GAEhE,IAAI,CAAC,GAAG,WAAW,SAAS,GAC1B,MAAM,IAAI,MACR,oCAAoC,MAAM,iHAE5C;GAGF,IAAI,QACF,cAAc;IAAE,OAAO;IAAQ,YAAY;GAAoC,CAAC;GAGlF,IAAI,SACF,cAAc;IAAE,OAAO;IAAS,YAAY;GAAqC,CAAC;GAGpF,aAAa,EACX,MAAM,EACJ,SAAS,CAAC,mBAAmB;IAAE,OAAO;IAAW;GAAQ,CAAC,CAAC,EAC7D,EACF,CAAC;EACH,EACF;CACF;AACF;;;ACxEA,SAAgB,iBAAiB,SAA+C;CAC9E,OAAO;AACT;;;ACLA,MAAa,EAAE,SAAS,yBAAyB,iBAAiB;;;ACoBlE,MAAM,+BAA+B;;;;;AAMrC,SAAgB,4BACd,UACA,SACA;CACA,MAAM,e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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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routing-middleware-entrypoint.d.ts","names":[],"sources":["../src/routing-middleware-entrypoint.ts"],"mappings":";qBAGa"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { contello } from "virtual:@contello/astro/instance";
|
|
2
|
+
import { exclude } from "virtual:@contello/astro/config";
|
|
3
|
+
//#region src/routing-middleware-entrypoint.ts
|
|
4
|
+
const onRequest = contello.createRoutingMiddleware({ exclude: exclude ?? void 0 });
|
|
5
|
+
//#endregion
|
|
6
|
+
export { onRequest };
|
|
7
|
+
|
|
8
|
+
//# sourceMappingURL=routing-middleware-entrypoint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routing-middleware-entrypoint.js","names":[],"sources":["../src/routing-middleware-entrypoint.ts"],"sourcesContent":["import { exclude } from 'virtual:@contello/astro/config';\nimport { contello } from 'virtual:@contello/astro/instance';\n\nexport const onRequest = contello.createRoutingMiddleware({ exclude: exclude ?? undefined });\n"],"mappings":";;;AAGA,MAAa,YAAY,SAAS,wBAAwB,EAAE,SAAS,WAAW,KAAA,EAAU,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contello/astro",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Astro integration for Contello CMS —
|
|
3
|
+
"version": "5.0.0",
|
|
4
|
+
"description": "Astro integration for Contello CMS — assets and routing middlewares, i18n bridge",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"astro",
|
|
7
|
+
"astro-integration",
|
|
8
|
+
"contello",
|
|
9
|
+
"cms"
|
|
10
|
+
],
|
|
5
11
|
"type": "module",
|
|
6
12
|
"license": "MIT",
|
|
7
13
|
"author": "admin@entwico.com",
|
|
@@ -11,15 +17,15 @@
|
|
|
11
17
|
"directory": "packages/astro"
|
|
12
18
|
},
|
|
13
19
|
"dependencies": {
|
|
14
|
-
"@contello/opentelemetry": "^2.1.
|
|
20
|
+
"@contello/opentelemetry": "^2.1.2",
|
|
15
21
|
"@entwico/dash": "^1.3.0"
|
|
16
22
|
},
|
|
17
23
|
"peerDependencies": {
|
|
18
|
-
"@astroscope/i18n": "
|
|
19
|
-
"@astroscope/node": "
|
|
20
|
-
"@contello/client": "^3.
|
|
21
|
-
"@contello/media": "^2.2.
|
|
22
|
-
"@contello/store": "^4.4.
|
|
24
|
+
"@astroscope/i18n": "^3.0.0",
|
|
25
|
+
"@astroscope/node": "^4.1.0",
|
|
26
|
+
"@contello/client": "^3.3.0",
|
|
27
|
+
"@contello/media": "^2.2.3",
|
|
28
|
+
"@contello/store": "^4.4.1",
|
|
23
29
|
"astro": "^6.0.0 || ^7.0.0"
|
|
24
30
|
},
|
|
25
31
|
"peerDependenciesMeta": {
|
|
@@ -28,21 +34,29 @@
|
|
|
28
34
|
}
|
|
29
35
|
},
|
|
30
36
|
"devDependencies": {
|
|
31
|
-
"@astroscope/i18n": "^
|
|
32
|
-
"@astroscope/node": "^
|
|
33
|
-
"@contello/client": "^3.
|
|
34
|
-
"@contello/media": "^2.2.
|
|
35
|
-
"@contello/store": "^4.4.
|
|
36
|
-
"astro": "^7.
|
|
37
|
+
"@astroscope/i18n": "^3.0.0",
|
|
38
|
+
"@astroscope/node": "^4.1.0",
|
|
39
|
+
"@contello/client": "^3.3.0",
|
|
40
|
+
"@contello/media": "^2.2.3",
|
|
41
|
+
"@contello/store": "^4.4.1",
|
|
42
|
+
"astro": "^7.3.8",
|
|
43
|
+
"vite": "^8.2.2"
|
|
37
44
|
},
|
|
38
45
|
"files": [
|
|
39
46
|
"dist"
|
|
40
47
|
],
|
|
48
|
+
"sideEffects": false,
|
|
41
49
|
"types": "./dist/index.d.ts",
|
|
42
50
|
"exports": {
|
|
43
51
|
".": {
|
|
44
52
|
"import": "./dist/index.js",
|
|
45
53
|
"require": "./dist/index.cjs"
|
|
54
|
+
},
|
|
55
|
+
"./assets-middleware": {
|
|
56
|
+
"import": "./dist/assets-middleware-entrypoint.js"
|
|
57
|
+
},
|
|
58
|
+
"./routing-middleware": {
|
|
59
|
+
"import": "./dist/routing-middleware-entrypoint.js"
|
|
46
60
|
}
|
|
47
61
|
},
|
|
48
62
|
"publishConfig": {
|