emdash 0.10.0 → 0.11.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/{apply-UsrFuO7l.mjs → apply-Ded_1vng.mjs} +36 -25
- package/dist/{apply-UsrFuO7l.mjs.map → apply-Ded_1vng.mjs.map} +1 -1
- package/dist/astro/index.d.mts +5 -5
- package/dist/astro/index.mjs +1 -1
- package/dist/astro/middleware/auth.d.mts +5 -5
- package/dist/astro/middleware/redirect.mjs +2 -2
- package/dist/astro/middleware.d.mts.map +1 -1
- package/dist/astro/middleware.mjs +83 -33
- package/dist/astro/middleware.mjs.map +1 -1
- package/dist/astro/types.d.mts +9 -7
- package/dist/astro/types.d.mts.map +1 -1
- package/dist/{byline-C3vnhIpU.mjs → byline-gFn1r0vA.mjs} +2 -2
- package/dist/{byline-C3vnhIpU.mjs.map → byline-gFn1r0vA.mjs.map} +1 -1
- package/dist/{bylines-esI7ioa9.mjs → bylines-DTFI8nDM.mjs} +4 -4
- package/dist/{bylines-esI7ioa9.mjs.map → bylines-DTFI8nDM.mjs.map} +1 -1
- package/dist/{cache-fTzxgMFJ.mjs → cache-BAJbeoZ8.mjs} +2 -2
- package/dist/{cache-fTzxgMFJ.mjs.map → cache-BAJbeoZ8.mjs.map} +1 -1
- package/dist/{chunks-Da2-b-oA.mjs → chunks-BK1oZS-l.mjs} +2 -2
- package/dist/{chunks-Da2-b-oA.mjs.map → chunks-BK1oZS-l.mjs.map} +1 -1
- package/dist/cli/index.mjs +102 -27
- package/dist/cli/index.mjs.map +1 -1
- package/dist/{content-C7G4QXkK.mjs → content-CERxPUN0.mjs} +2 -2
- package/dist/{content-C7G4QXkK.mjs.map → content-CERxPUN0.mjs.map} +1 -1
- package/dist/database/instrumentation.d.mts +6 -4
- package/dist/database/instrumentation.d.mts.map +1 -1
- package/dist/database/instrumentation.mjs +19 -7
- package/dist/database/instrumentation.mjs.map +1 -1
- package/dist/db/index.d.mts +2 -2
- package/dist/db/index.mjs +1 -1
- package/dist/{index-DjPMOfO0.d.mts → index-Cg-rC4Gj.d.mts} +32 -24
- package/dist/index-Cg-rC4Gj.d.mts.map +1 -0
- package/dist/index.d.mts +7 -7
- package/dist/index.mjs +19 -19
- package/dist/{load-sXRuM7Us.mjs → load-DR1VwFXR.mjs} +2 -2
- package/dist/{load-sXRuM7Us.mjs.map → load-DR1VwFXR.mjs.map} +1 -1
- package/dist/{loader-Bx2_9-5e.mjs → loader-ou_PXAjg.mjs} +2 -2
- package/dist/{loader-Bx2_9-5e.mjs.map → loader-ou_PXAjg.mjs.map} +1 -1
- package/dist/media/local-runtime.d.mts +5 -5
- package/dist/media/local-runtime.mjs +1 -1
- package/dist/{media-D8FbNsl0.mjs → media-1fFhub9c.mjs} +21 -9
- package/dist/media-1fFhub9c.mjs.map +1 -0
- package/dist/page/index.d.mts +2 -2
- package/dist/plugins/adapt-sandbox-entry.d.mts +5 -5
- package/dist/plugins/adapt-sandbox-entry.mjs +1 -1
- package/dist/{query-Bo-msrmu.mjs → query-8c_meo_K.mjs} +10 -10
- package/dist/{query-Bo-msrmu.mjs.map → query-8c_meo_K.mjs.map} +1 -1
- package/dist/{registry-Beb7wxFc.mjs → registry-Do34mz_P.mjs} +6 -5
- package/dist/registry-Do34mz_P.mjs.map +1 -0
- package/dist/{request-cache-C-tIpYIw.mjs → request-cache-D4I69LeL.mjs} +6 -2
- package/dist/request-cache-D4I69LeL.mjs.map +1 -0
- package/dist/request-context.d.mts +27 -1
- package/dist/request-context.d.mts.map +1 -1
- package/dist/request-context.mjs +16 -3
- package/dist/request-context.mjs.map +1 -1
- package/dist/{runner-DMnlIkh4.mjs → runner-DIcU2UCC.mjs} +174 -152
- package/dist/runner-DIcU2UCC.mjs.map +1 -0
- package/dist/{runner-Clwe4Mme.d.mts → runner-Iu3IZSDM.d.mts} +2 -2
- package/dist/{runner-Clwe4Mme.d.mts.map → runner-Iu3IZSDM.d.mts.map} +1 -1
- package/dist/runtime.d.mts +5 -5
- package/dist/runtime.mjs +1 -1
- package/dist/{search-DkN-BqsS.mjs → search-DuWhx4NG.mjs} +172 -30
- package/dist/search-DuWhx4NG.mjs.map +1 -0
- package/dist/seed/index.d.mts +2 -2
- package/dist/seed/index.mjs +10 -10
- package/dist/{taxonomies-CTtewrSQ.mjs → taxonomies-Bw76xAxo.mjs} +6 -6
- package/dist/{taxonomies-CTtewrSQ.mjs.map → taxonomies-Bw76xAxo.mjs.map} +1 -1
- package/dist/{taxonomy-DSxx2K2L.mjs → taxonomy-D6NvlKo8.mjs} +3 -3
- package/dist/{taxonomy-DSxx2K2L.mjs.map → taxonomy-D6NvlKo8.mjs.map} +1 -1
- package/dist/{types-Eg829jj9.mjs → types-56BKbld_.mjs} +1 -1
- package/dist/types-56BKbld_.mjs.map +1 -0
- package/dist/{types-Dtx1mSMX.d.mts → types-BQx6ZXpR.d.mts} +2 -1
- package/dist/types-BQx6ZXpR.d.mts.map +1 -0
- package/dist/types-DiI8NOG_.mjs +16 -0
- package/dist/types-DiI8NOG_.mjs.map +1 -0
- package/dist/{types-D19uBYWn.d.mts → types-IN5z_S3P.d.mts} +19 -98
- package/dist/types-IN5z_S3P.d.mts.map +1 -0
- package/dist/{types-Dl1fgFjn.d.mts → types-IZSZfEwv.d.mts} +4 -3
- package/dist/types-IZSZfEwv.d.mts.map +1 -0
- package/dist/{validate-DHGwADqO.d.mts → validate-CO3JjFV5.d.mts} +7 -3
- package/dist/validate-CO3JjFV5.d.mts.map +1 -0
- package/dist/{validate-CBIbxM3L.mjs → validate-UK4Ja1uo.mjs} +3 -3
- package/dist/{validate-CBIbxM3L.mjs.map → validate-UK4Ja1uo.mjs.map} +1 -1
- package/dist/{validation-B1NYiEos.mjs → validation-Vc5DQkJa.mjs} +4 -4
- package/dist/{validation-B1NYiEos.mjs.map → validation-Vc5DQkJa.mjs.map} +1 -1
- package/dist/version-Bg31I_Ff.mjs +7 -0
- package/dist/{version-CMD42IRC.mjs.map → version-Bg31I_Ff.mjs.map} +1 -1
- package/dist/{zod-generator-BNJDQBSZ.mjs → zod-generator-CHnJUP2l.mjs} +1 -1
- package/dist/{zod-generator-BNJDQBSZ.mjs.map → zod-generator-CHnJUP2l.mjs.map} +1 -1
- package/package.json +9 -8
- package/src/api/errors.ts +5 -0
- package/src/api/handlers/content.ts +9 -0
- package/src/api/handlers/media-allowlist.ts +40 -0
- package/src/api/handlers/media.ts +1 -1
- package/src/api/handlers/menus.ts +158 -28
- package/src/api/handlers/validate-media-fields.ts +125 -0
- package/src/api/schemas/media.ts +23 -3
- package/src/api/schemas/schema.ts +11 -2
- package/src/astro/middleware.ts +46 -11
- package/src/astro/routes/api/media/upload-url.ts +10 -4
- package/src/astro/routes/api/media.ts +12 -4
- package/src/astro/types.ts +5 -1
- package/src/auth/rate-limit.ts +3 -3
- package/src/cli/commands/bundle-utils.ts +81 -6
- package/src/cli/commands/bundle.ts +18 -15
- package/src/cli/commands/export-seed.ts +57 -3
- package/src/database/instrumentation.ts +22 -8
- package/src/database/migrations/016_api_tokens.ts +18 -3
- package/src/database/migrations/037_credential_algorithm.ts +18 -0
- package/src/database/migrations/runner.ts +2 -0
- package/src/database/repositories/media.ts +40 -10
- package/src/database/types.ts +2 -1
- package/src/emdash-runtime.ts +16 -3
- package/src/fields/file.ts +7 -6
- package/src/fields/image.ts +12 -11
- package/src/fields/types.ts +3 -0
- package/src/index.ts +1 -1
- package/src/mcp/server.ts +37 -8
- package/src/media/mime.ts +75 -0
- package/src/plugins/types.ts +81 -191
- package/src/request-cache.ts +6 -2
- package/src/request-context.ts +42 -2
- package/src/schema/registry.ts +5 -5
- package/src/schema/types.ts +3 -2
- package/src/seed/apply.ts +25 -8
- package/src/seed/types.ts +4 -0
- package/dist/index-DjPMOfO0.d.mts.map +0 -1
- package/dist/media-D8FbNsl0.mjs.map +0 -1
- package/dist/registry-Beb7wxFc.mjs.map +0 -1
- package/dist/request-cache-C-tIpYIw.mjs.map +0 -1
- package/dist/runner-DMnlIkh4.mjs.map +0 -1
- package/dist/search-DkN-BqsS.mjs.map +0 -1
- package/dist/types-CoO6mpV3.mjs +0 -68
- package/dist/types-CoO6mpV3.mjs.map +0 -1
- package/dist/types-D19uBYWn.d.mts.map +0 -1
- package/dist/types-Dl1fgFjn.d.mts.map +0 -1
- package/dist/types-Dtx1mSMX.d.mts.map +0 -1
- package/dist/types-Eg829jj9.mjs.map +0 -1
- package/dist/validate-DHGwADqO.d.mts.map +0 -1
- package/dist/version-CMD42IRC.mjs +0 -7
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import { r as runMigrations } from "../runner-
|
|
2
|
-
import { getRequestContext, runWithContext } from "../request-context.mjs";
|
|
1
|
+
import { r as runMigrations } from "../runner-DIcU2UCC.mjs";
|
|
2
|
+
import { createRequestMetrics, getRequestContext, runWithContext } from "../request-context.mjs";
|
|
3
3
|
import { createRecorder, flushRecorder, isInstrumentationEnabled, kyselyLogOption } from "../database/instrumentation.mjs";
|
|
4
4
|
import "../connection-2igzM-AT.mjs";
|
|
5
5
|
import { t as validateIdentifier } from "../validate-VPnKoIzW.mjs";
|
|
6
6
|
import { o as isSqlite } from "../dialect-helpers-BKCvISIQ.mjs";
|
|
7
7
|
import { i as setI18nConfig } from "../config-CVssduLe.mjs";
|
|
8
|
-
import { At as handleContentTranslations, Ct as handleContentGetIncludingTrashed, Dt as handleContentPublish, Et as handleContentPermanentDelete, G as sanitizeHeadersForSandbox, H as resolveExclusiveHooks, I as PluginRouteRegistry, K as getTrustedProxyHeaders, L as DEV_CONSOLE_EMAIL_PLUGIN_ID, Mt as handleContentUnschedule, Nt as handleContentUpdate, Ot as handleContentRestore, Pt as validateRev, R as devConsoleEmailDeliver, St as handleContentGet, Tt as handleContentListTrashed, U as CronExecutor, V as createHookPipeline, W as extractRequestMeta, X as after, _t as handleContentCountTrashed, bt as handleContentDiscardDraft, ct as handleMediaGet, dt as handleRevisionGet, ft as handleRevisionList, gt as handleContentCountScheduled, ht as handleContentCompare, it as PluginStateRepository, jt as handleContentUnpublish, kt as handleContentSchedule, lt as handleMediaList, ot as handleMediaCreate, pt as handleRevisionRestore, q as definePlugin, st as handleMediaDelete, tt as loadBundleFromR2, ut as handleMediaUpdate, vt as handleContentCreate, wt as handleContentList, xt as handleContentDuplicate, yt as handleContentDelete, z as EmailPipeline } from "../search-
|
|
9
|
-
import { r as RevisionRepository } from "../content-
|
|
8
|
+
import { At as handleContentTranslations, Ct as handleContentGetIncludingTrashed, Dt as handleContentPublish, Et as handleContentPermanentDelete, G as sanitizeHeadersForSandbox, H as resolveExclusiveHooks, I as PluginRouteRegistry, K as getTrustedProxyHeaders, L as DEV_CONSOLE_EMAIL_PLUGIN_ID, Mt as handleContentUnschedule, Nt as handleContentUpdate, Ot as handleContentRestore, Pt as validateRev, R as devConsoleEmailDeliver, St as handleContentGet, Tt as handleContentListTrashed, U as CronExecutor, V as createHookPipeline, W as extractRequestMeta, X as after, _t as handleContentCountTrashed, bt as handleContentDiscardDraft, ct as handleMediaGet, dt as handleRevisionGet, ft as handleRevisionList, gt as handleContentCountScheduled, ht as handleContentCompare, it as PluginStateRepository, jt as handleContentUnpublish, kt as handleContentSchedule, lt as handleMediaList, ot as handleMediaCreate, pt as handleRevisionRestore, q as definePlugin, st as handleMediaDelete, tt as loadBundleFromR2, ut as handleMediaUpdate, vt as handleContentCreate, wt as handleContentList, xt as handleContentDuplicate, yt as handleContentDelete, z as EmailPipeline } from "../search-DuWhx4NG.mjs";
|
|
9
|
+
import { r as RevisionRepository } from "../content-CERxPUN0.mjs";
|
|
10
10
|
import "../base64-MBPo9ozB.mjs";
|
|
11
11
|
import "../types-BIgulNsW.mjs";
|
|
12
|
-
import { t as MediaRepository } from "../media-
|
|
13
|
-
import "../taxonomy-
|
|
12
|
+
import { t as MediaRepository } from "../media-1fFhub9c.mjs";
|
|
13
|
+
import "../taxonomy-D6NvlKo8.mjs";
|
|
14
14
|
import { t as OptionsRepository } from "../options-nPxWnrya.mjs";
|
|
15
15
|
import "../redirect-C5H7VGIX.mjs";
|
|
16
|
-
import "../byline-
|
|
16
|
+
import "../byline-gFn1r0vA.mjs";
|
|
17
17
|
import { n as normalizeMediaValue } from "../placeholder-Ci0RLeCk.mjs";
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import "../apply-
|
|
23
|
-
import "../taxonomies-
|
|
18
|
+
import { n as requestCached } from "../request-cache-D4I69LeL.mjs";
|
|
19
|
+
import { r as hashString } from "../zod-generator-CHnJUP2l.mjs";
|
|
20
|
+
import { i as FTSManager, n as SchemaRegistry } from "../registry-Do34mz_P.mjs";
|
|
21
|
+
import { r as getDb } from "../loader-ou_PXAjg.mjs";
|
|
22
|
+
import "../apply-Ded_1vng.mjs";
|
|
23
|
+
import "../taxonomies-Bw76xAxo.mjs";
|
|
24
24
|
import { r as normalizeManifestRoute } from "../manifest-schema-CXAbd1vH.mjs";
|
|
25
|
-
import "../types-
|
|
25
|
+
import "../types-DiI8NOG_.mjs";
|
|
26
26
|
import "../error-DqnRMM5z.mjs";
|
|
27
|
-
import { a as invalidateUrlPatternCache } from "../query-
|
|
27
|
+
import { a as invalidateUrlPatternCache } from "../query-8c_meo_K.mjs";
|
|
28
28
|
import "../tokens-CyRDPVW2.mjs";
|
|
29
|
-
import "../bylines-
|
|
30
|
-
import "../load-
|
|
29
|
+
import "../bylines-DTFI8nDM.mjs";
|
|
30
|
+
import "../load-DR1VwFXR.mjs";
|
|
31
31
|
import "../index.mjs";
|
|
32
|
-
import { n as VERSION, t as COMMIT } from "../version-
|
|
32
|
+
import { n as VERSION, t as COMMIT } from "../version-Bg31I_Ff.mjs";
|
|
33
33
|
import { t as getAuthMode } from "../mode-YhqNVef_.mjs";
|
|
34
34
|
import { a as validateEncryptionKeyAtStartup } from "../secrets-CZ8rxLX3.mjs";
|
|
35
35
|
import { Kysely, sql } from "kysely";
|
|
@@ -801,9 +801,9 @@ var EmDashRuntime = class EmDashRuntime {
|
|
|
801
801
|
}
|
|
802
802
|
})();
|
|
803
803
|
if (collectionCount.count === 0 && !setupDone) {
|
|
804
|
-
const { applySeed } = await import("../apply-
|
|
805
|
-
const { loadSeed } = await import("../load-
|
|
806
|
-
const { validateSeed } = await import("../validate-
|
|
804
|
+
const { applySeed } = await import("../apply-Ded_1vng.mjs").then((n) => n.n);
|
|
805
|
+
const { loadSeed } = await import("../load-DR1VwFXR.mjs").then((n) => n.r);
|
|
806
|
+
const { validateSeed } = await import("../validate-UK4Ja1uo.mjs").then((n) => n.n);
|
|
807
807
|
const seed = await loadSeed();
|
|
808
808
|
if (validateSeed(seed).valid) {
|
|
809
809
|
await applySeed(db, seed, { onConflict: "skip" });
|
|
@@ -983,13 +983,14 @@ var EmDashRuntime = class EmDashRuntime {
|
|
|
983
983
|
label: field.label,
|
|
984
984
|
required: field.required
|
|
985
985
|
};
|
|
986
|
+
entry.id = field.id;
|
|
986
987
|
if (field.widget) entry.widget = field.widget;
|
|
987
988
|
if (field.options) entry.options = field.options;
|
|
988
989
|
if (field.validation?.options) entry.options = field.validation.options.map((v) => ({
|
|
989
990
|
value: v,
|
|
990
991
|
label: v.charAt(0).toUpperCase() + v.slice(1)
|
|
991
992
|
}));
|
|
992
|
-
if (field.type === "repeater" && field.validation) entry.validation = field.validation;
|
|
993
|
+
if ((field.type === "repeater" || field.type === "file" || field.type === "image") && field.validation) entry.validation = { ...field.validation };
|
|
993
994
|
fields[field.slug] = entry;
|
|
994
995
|
}
|
|
995
996
|
manifestCollections[collection.slug] = {
|
|
@@ -1188,7 +1189,7 @@ var EmDashRuntime = class EmDashRuntime {
|
|
|
1188
1189
|
if (this.hooks.hasHooks("content:beforeSave")) processedData = (await this.hooks.runContentBeforeSave(body.data, collection, true)).content;
|
|
1189
1190
|
processedData = await this.runSandboxedBeforeSave(processedData, collection, true);
|
|
1190
1191
|
processedData = await this.normalizeMediaFields(collection, processedData);
|
|
1191
|
-
const { validateContentData } = await import("../validation-
|
|
1192
|
+
const { validateContentData } = await import("../validation-Vc5DQkJa.mjs");
|
|
1192
1193
|
const validation = await validateContentData(this.db, collection, processedData, { partial: false });
|
|
1193
1194
|
if (!validation.ok) return {
|
|
1194
1195
|
success: false,
|
|
@@ -1204,7 +1205,7 @@ var EmDashRuntime = class EmDashRuntime {
|
|
|
1204
1205
|
return result;
|
|
1205
1206
|
}
|
|
1206
1207
|
async handleContentUpdate(collection, id, body) {
|
|
1207
|
-
const { ContentRepository } = await import("../content-
|
|
1208
|
+
const { ContentRepository } = await import("../content-CERxPUN0.mjs").then((n) => n.n);
|
|
1208
1209
|
const repo = new ContentRepository(this.db);
|
|
1209
1210
|
const resolvedItem = await repo.findByIdOrSlug(collection, id);
|
|
1210
1211
|
const resolvedId = resolvedItem?.id ?? id;
|
|
@@ -1231,7 +1232,7 @@ var EmDashRuntime = class EmDashRuntime {
|
|
|
1231
1232
|
if (this.hooks.hasHooks("content:beforeSave")) processedData = (await this.hooks.runContentBeforeSave(bodyWithoutRev.data, collection, false)).content;
|
|
1232
1233
|
processedData = await this.runSandboxedBeforeSave(processedData, collection, false);
|
|
1233
1234
|
processedData = await this.normalizeMediaFields(collection, processedData);
|
|
1234
|
-
const { validateContentData } = await import("../validation-
|
|
1235
|
+
const { validateContentData } = await import("../validation-Vc5DQkJa.mjs");
|
|
1235
1236
|
const validation = await validateContentData(this.db, collection, processedData, { partial: true });
|
|
1236
1237
|
if (!validation.ok) return {
|
|
1237
1238
|
success: false,
|
|
@@ -1873,6 +1874,49 @@ function finalizeResponse(response, serverTimings) {
|
|
|
1873
1874
|
}).join(", "));
|
|
1874
1875
|
return res;
|
|
1875
1876
|
}
|
|
1877
|
+
/**
|
|
1878
|
+
* Append always-on counters (db.*, cache.*) to the Server-Timing list.
|
|
1879
|
+
*
|
|
1880
|
+
* dur values for `count`, `hit`, `miss` are integer counts — Server-Timing
|
|
1881
|
+
* spec only models milliseconds, but browsers show whatever number is given,
|
|
1882
|
+
* which is the convention most projects use for non-time samples.
|
|
1883
|
+
*/
|
|
1884
|
+
function pushMetricsTimings(timings, metrics) {
|
|
1885
|
+
if (metrics.dbCount > 0) {
|
|
1886
|
+
timings.push({
|
|
1887
|
+
name: "db.total",
|
|
1888
|
+
dur: metrics.dbTotalMs,
|
|
1889
|
+
desc: "DB total"
|
|
1890
|
+
});
|
|
1891
|
+
timings.push({
|
|
1892
|
+
name: "db.count",
|
|
1893
|
+
dur: metrics.dbCount,
|
|
1894
|
+
desc: "Query count"
|
|
1895
|
+
});
|
|
1896
|
+
if (metrics.dbFirstOffset !== null) timings.push({
|
|
1897
|
+
name: "db.first",
|
|
1898
|
+
dur: metrics.dbFirstOffset,
|
|
1899
|
+
desc: "First query at"
|
|
1900
|
+
});
|
|
1901
|
+
if (metrics.dbLastOffset !== null) timings.push({
|
|
1902
|
+
name: "db.last",
|
|
1903
|
+
dur: metrics.dbLastOffset,
|
|
1904
|
+
desc: "Last query at"
|
|
1905
|
+
});
|
|
1906
|
+
}
|
|
1907
|
+
if (metrics.cacheHits + metrics.cacheMisses > 0) {
|
|
1908
|
+
timings.push({
|
|
1909
|
+
name: "cache.hit",
|
|
1910
|
+
dur: metrics.cacheHits,
|
|
1911
|
+
desc: "Cache hits"
|
|
1912
|
+
});
|
|
1913
|
+
timings.push({
|
|
1914
|
+
name: "cache.miss",
|
|
1915
|
+
dur: metrics.cacheMisses,
|
|
1916
|
+
desc: "Cache misses"
|
|
1917
|
+
});
|
|
1918
|
+
}
|
|
1919
|
+
}
|
|
1876
1920
|
/** Public routes that require the runtime (sitemap, robots.txt, etc.) */
|
|
1877
1921
|
const PUBLIC_RUNTIME_ROUTES = new Set(["/sitemap.xml", "/robots.txt"]);
|
|
1878
1922
|
const SITEMAP_COLLECTION_RE = /^\/sitemap-[a-z][a-z0-9_]*\.xml$/;
|
|
@@ -1893,6 +1937,7 @@ const onRequest = defineMiddleware(async (context, next) => {
|
|
|
1893
1937
|
if (virtualConfig.authProviders.some((p) => p.routes?.some((r) => r.pattern && url.pathname === r.pattern))) return finalizeResponse(await next());
|
|
1894
1938
|
}
|
|
1895
1939
|
const queryRecorder = isInstrumentationEnabled() ? createRecorder(url.pathname, request.method, request.headers.get("x-perf-phase") ?? "default") : void 0;
|
|
1940
|
+
const metrics = createRequestMetrics(performance.now());
|
|
1896
1941
|
const run = async () => {
|
|
1897
1942
|
const isEmDashRoute = url.pathname.startsWith("/_emdash");
|
|
1898
1943
|
const isPublicRuntimeRoute = PUBLIC_RUNTIME_ROUTES.has(url.pathname) || SITEMAP_COLLECTION_RE.test(url.pathname);
|
|
@@ -1908,7 +1953,7 @@ const onRequest = defineMiddleware(async (context, next) => {
|
|
|
1908
1953
|
if (!setupVerified) {
|
|
1909
1954
|
const t0 = performance.now();
|
|
1910
1955
|
try {
|
|
1911
|
-
const { getDb } = await import("../loader-
|
|
1956
|
+
const { getDb } = await import("../loader-ou_PXAjg.mjs").then((n) => n.i);
|
|
1912
1957
|
await (await getDb()).selectFrom("_emdash_migrations").selectAll().limit(1).execute();
|
|
1913
1958
|
setupVerified = true;
|
|
1914
1959
|
} catch {
|
|
@@ -1960,6 +2005,7 @@ const onRequest = defineMiddleware(async (context, next) => {
|
|
|
1960
2005
|
dur: performance.now() - mwStart,
|
|
1961
2006
|
desc: "Total middleware"
|
|
1962
2007
|
});
|
|
2008
|
+
pushMetricsTimings(timings, metrics);
|
|
1963
2009
|
return finalizeResponse(response, timings);
|
|
1964
2010
|
};
|
|
1965
2011
|
if (anonScoped) {
|
|
@@ -1969,7 +2015,8 @@ const onRequest = defineMiddleware(async (context, next) => {
|
|
|
1969
2015
|
db: anonScoped.db
|
|
1970
2016
|
} : {
|
|
1971
2017
|
editMode: false,
|
|
1972
|
-
db: anonScoped.db
|
|
2018
|
+
db: anonScoped.db,
|
|
2019
|
+
metrics
|
|
1973
2020
|
}, async () => {
|
|
1974
2021
|
const response = await runAnon();
|
|
1975
2022
|
anonScoped.commit();
|
|
@@ -2069,6 +2116,7 @@ const onRequest = defineMiddleware(async (context, next) => {
|
|
|
2069
2116
|
dur: performance.now() - mwStart,
|
|
2070
2117
|
desc: "Total middleware"
|
|
2071
2118
|
});
|
|
2119
|
+
pushMetricsTimings(timings, metrics);
|
|
2072
2120
|
return finalizeResponse(response, timings);
|
|
2073
2121
|
};
|
|
2074
2122
|
if (scoped) {
|
|
@@ -2078,7 +2126,8 @@ const onRequest = defineMiddleware(async (context, next) => {
|
|
|
2078
2126
|
db: scoped.db
|
|
2079
2127
|
} : {
|
|
2080
2128
|
editMode: false,
|
|
2081
|
-
db: scoped.db
|
|
2129
|
+
db: scoped.db,
|
|
2130
|
+
metrics
|
|
2082
2131
|
}, async () => {
|
|
2083
2132
|
const response = await renderAndFinalize();
|
|
2084
2133
|
scoped.commit();
|
|
@@ -2098,20 +2147,21 @@ const onRequest = defineMiddleware(async (context, next) => {
|
|
|
2098
2147
|
} : {
|
|
2099
2148
|
editMode,
|
|
2100
2149
|
db: playgroundDb,
|
|
2101
|
-
dbIsIsolated: true
|
|
2150
|
+
dbIsIsolated: true,
|
|
2151
|
+
metrics
|
|
2102
2152
|
}, doInit);
|
|
2103
2153
|
}
|
|
2104
2154
|
return doInit();
|
|
2105
2155
|
};
|
|
2106
|
-
|
|
2156
|
+
try {
|
|
2107
2157
|
return await runWithContext({
|
|
2108
2158
|
editMode: false,
|
|
2109
|
-
queryRecorder
|
|
2159
|
+
queryRecorder,
|
|
2160
|
+
metrics
|
|
2110
2161
|
}, run);
|
|
2111
2162
|
} finally {
|
|
2112
|
-
flushRecorder(queryRecorder);
|
|
2163
|
+
if (queryRecorder) flushRecorder(queryRecorder);
|
|
2113
2164
|
}
|
|
2114
|
-
return run();
|
|
2115
2165
|
});
|
|
2116
2166
|
|
|
2117
2167
|
//#endregion
|