emdash 0.10.0 → 0.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/dist/{apply-UsrFuO7l.mjs → apply-Ded_1vng.mjs} +36 -25
  2. package/dist/{apply-UsrFuO7l.mjs.map → apply-Ded_1vng.mjs.map} +1 -1
  3. package/dist/astro/index.d.mts +5 -5
  4. package/dist/astro/index.mjs +1 -1
  5. package/dist/astro/middleware/auth.d.mts +5 -5
  6. package/dist/astro/middleware/redirect.mjs +2 -2
  7. package/dist/astro/middleware.d.mts.map +1 -1
  8. package/dist/astro/middleware.mjs +83 -33
  9. package/dist/astro/middleware.mjs.map +1 -1
  10. package/dist/astro/types.d.mts +10 -7
  11. package/dist/astro/types.d.mts.map +1 -1
  12. package/dist/{byline-C3vnhIpU.mjs → byline-gFn1r0vA.mjs} +2 -2
  13. package/dist/{byline-C3vnhIpU.mjs.map → byline-gFn1r0vA.mjs.map} +1 -1
  14. package/dist/{bylines-esI7ioa9.mjs → bylines-DTFI8nDM.mjs} +4 -4
  15. package/dist/{bylines-esI7ioa9.mjs.map → bylines-DTFI8nDM.mjs.map} +1 -1
  16. package/dist/{cache-fTzxgMFJ.mjs → cache-BAJbeoZ8.mjs} +2 -2
  17. package/dist/{cache-fTzxgMFJ.mjs.map → cache-BAJbeoZ8.mjs.map} +1 -1
  18. package/dist/{chunks-Da2-b-oA.mjs → chunks-BK1oZS-l.mjs} +2 -2
  19. package/dist/{chunks-Da2-b-oA.mjs.map → chunks-BK1oZS-l.mjs.map} +1 -1
  20. package/dist/cli/index.mjs +102 -27
  21. package/dist/cli/index.mjs.map +1 -1
  22. package/dist/{content-C7G4QXkK.mjs → content-CERxPUN0.mjs} +2 -2
  23. package/dist/{content-C7G4QXkK.mjs.map → content-CERxPUN0.mjs.map} +1 -1
  24. package/dist/database/instrumentation.d.mts +6 -4
  25. package/dist/database/instrumentation.d.mts.map +1 -1
  26. package/dist/database/instrumentation.mjs +19 -7
  27. package/dist/database/instrumentation.mjs.map +1 -1
  28. package/dist/db/index.d.mts +2 -2
  29. package/dist/db/index.mjs +1 -1
  30. package/dist/{index-DjPMOfO0.d.mts → index-BogfvE-z.d.mts} +32 -24
  31. package/dist/index-BogfvE-z.d.mts.map +1 -0
  32. package/dist/index.d.mts +7 -7
  33. package/dist/index.mjs +19 -19
  34. package/dist/{load-sXRuM7Us.mjs → load-DR1VwFXR.mjs} +2 -2
  35. package/dist/{load-sXRuM7Us.mjs.map → load-DR1VwFXR.mjs.map} +1 -1
  36. package/dist/{loader-Bx2_9-5e.mjs → loader-ou_PXAjg.mjs} +2 -2
  37. package/dist/{loader-Bx2_9-5e.mjs.map → loader-ou_PXAjg.mjs.map} +1 -1
  38. package/dist/media/local-runtime.d.mts +5 -5
  39. package/dist/media/local-runtime.mjs +1 -1
  40. package/dist/{media-D8FbNsl0.mjs → media-1fFhub9c.mjs} +21 -9
  41. package/dist/media-1fFhub9c.mjs.map +1 -0
  42. package/dist/page/index.d.mts +2 -2
  43. package/dist/plugins/adapt-sandbox-entry.d.mts +5 -5
  44. package/dist/plugins/adapt-sandbox-entry.mjs +1 -1
  45. package/dist/{query-Bo-msrmu.mjs → query-8c_meo_K.mjs} +10 -10
  46. package/dist/{query-Bo-msrmu.mjs.map → query-8c_meo_K.mjs.map} +1 -1
  47. package/dist/{registry-Beb7wxFc.mjs → registry-Do34mz_P.mjs} +6 -5
  48. package/dist/registry-Do34mz_P.mjs.map +1 -0
  49. package/dist/{request-cache-C-tIpYIw.mjs → request-cache-D4I69LeL.mjs} +6 -2
  50. package/dist/request-cache-D4I69LeL.mjs.map +1 -0
  51. package/dist/request-context.d.mts +27 -1
  52. package/dist/request-context.d.mts.map +1 -1
  53. package/dist/request-context.mjs +16 -3
  54. package/dist/request-context.mjs.map +1 -1
  55. package/dist/{runner-DMnlIkh4.mjs → runner-DIcU2UCC.mjs} +174 -152
  56. package/dist/runner-DIcU2UCC.mjs.map +1 -0
  57. package/dist/{runner-Clwe4Mme.d.mts → runner-Iu3IZSDM.d.mts} +2 -2
  58. package/dist/{runner-Clwe4Mme.d.mts.map → runner-Iu3IZSDM.d.mts.map} +1 -1
  59. package/dist/runtime.d.mts +5 -5
  60. package/dist/runtime.mjs +1 -1
  61. package/dist/{search-DkN-BqsS.mjs → search-DuWhx4NG.mjs} +172 -30
  62. package/dist/search-DuWhx4NG.mjs.map +1 -0
  63. package/dist/seed/index.d.mts +2 -2
  64. package/dist/seed/index.mjs +10 -10
  65. package/dist/{taxonomies-CTtewrSQ.mjs → taxonomies-Bw76xAxo.mjs} +6 -6
  66. package/dist/{taxonomies-CTtewrSQ.mjs.map → taxonomies-Bw76xAxo.mjs.map} +1 -1
  67. package/dist/{taxonomy-DSxx2K2L.mjs → taxonomy-D6NvlKo8.mjs} +3 -3
  68. package/dist/{taxonomy-DSxx2K2L.mjs.map → taxonomy-D6NvlKo8.mjs.map} +1 -1
  69. package/dist/{types-Eg829jj9.mjs → types-56BKbld_.mjs} +1 -1
  70. package/dist/types-56BKbld_.mjs.map +1 -0
  71. package/dist/{types-Dtx1mSMX.d.mts → types-BQx6ZXpR.d.mts} +2 -1
  72. package/dist/types-BQx6ZXpR.d.mts.map +1 -0
  73. package/dist/{types-Dl1fgFjn.d.mts → types-BTe41zL6.d.mts} +4 -3
  74. package/dist/types-BTe41zL6.d.mts.map +1 -0
  75. package/dist/types-DiI8NOG_.mjs +16 -0
  76. package/dist/types-DiI8NOG_.mjs.map +1 -0
  77. package/dist/{types-D19uBYWn.d.mts → types-IjUrQMVe.d.mts} +21 -245
  78. package/dist/types-IjUrQMVe.d.mts.map +1 -0
  79. package/dist/{validate-DHGwADqO.d.mts → validate-CcVQQpmH.d.mts} +7 -3
  80. package/dist/validate-CcVQQpmH.d.mts.map +1 -0
  81. package/dist/{validate-CBIbxM3L.mjs → validate-UK4Ja1uo.mjs} +3 -3
  82. package/dist/{validate-CBIbxM3L.mjs.map → validate-UK4Ja1uo.mjs.map} +1 -1
  83. package/dist/{validation-B1NYiEos.mjs → validation-Vc5DQkJa.mjs} +4 -4
  84. package/dist/{validation-B1NYiEos.mjs.map → validation-Vc5DQkJa.mjs.map} +1 -1
  85. package/dist/version-JjSqv90m.mjs +7 -0
  86. package/dist/{version-CMD42IRC.mjs.map → version-JjSqv90m.mjs.map} +1 -1
  87. package/dist/{zod-generator-BNJDQBSZ.mjs → zod-generator-CHnJUP2l.mjs} +1 -1
  88. package/dist/{zod-generator-BNJDQBSZ.mjs.map → zod-generator-CHnJUP2l.mjs.map} +1 -1
  89. package/package.json +9 -8
  90. package/src/api/errors.ts +5 -0
  91. package/src/api/handlers/content.ts +9 -0
  92. package/src/api/handlers/media-allowlist.ts +40 -0
  93. package/src/api/handlers/media.ts +1 -1
  94. package/src/api/handlers/menus.ts +158 -28
  95. package/src/api/handlers/validate-media-fields.ts +125 -0
  96. package/src/api/schemas/media.ts +23 -3
  97. package/src/api/schemas/schema.ts +11 -2
  98. package/src/astro/middleware.ts +46 -11
  99. package/src/astro/routes/api/content/[collection]/[id]/discard-draft.ts +1 -1
  100. package/src/astro/routes/api/content/[collection]/[id]/duplicate.ts +1 -1
  101. package/src/astro/routes/api/content/[collection]/[id]/permanent.ts +1 -1
  102. package/src/astro/routes/api/content/[collection]/[id]/publish.ts +1 -1
  103. package/src/astro/routes/api/content/[collection]/[id]/restore.ts +1 -1
  104. package/src/astro/routes/api/content/[collection]/[id]/schedule.ts +2 -2
  105. package/src/astro/routes/api/content/[collection]/[id]/unpublish.ts +1 -1
  106. package/src/astro/routes/api/content/[collection]/[id].ts +2 -2
  107. package/src/astro/routes/api/content/[collection]/index.ts +1 -1
  108. package/src/astro/routes/api/media/upload-url.ts +10 -4
  109. package/src/astro/routes/api/media.ts +12 -4
  110. package/src/astro/types.ts +5 -1
  111. package/src/auth/rate-limit.ts +3 -3
  112. package/src/cli/commands/bundle-utils.ts +81 -6
  113. package/src/cli/commands/bundle.ts +18 -15
  114. package/src/cli/commands/export-seed.ts +57 -3
  115. package/src/database/instrumentation.ts +22 -8
  116. package/src/database/migrations/016_api_tokens.ts +18 -3
  117. package/src/database/migrations/037_credential_algorithm.ts +18 -0
  118. package/src/database/migrations/runner.ts +2 -0
  119. package/src/database/repositories/media.ts +40 -10
  120. package/src/database/types.ts +2 -1
  121. package/src/emdash-runtime.ts +16 -3
  122. package/src/fields/file.ts +7 -6
  123. package/src/fields/image.ts +12 -11
  124. package/src/fields/types.ts +3 -0
  125. package/src/index.ts +1 -1
  126. package/src/mcp/server.ts +37 -8
  127. package/src/media/mime.ts +75 -0
  128. package/src/plugins/types.ts +81 -191
  129. package/src/request-cache.ts +6 -2
  130. package/src/request-context.ts +42 -2
  131. package/src/schema/registry.ts +5 -5
  132. package/src/schema/types.ts +3 -2
  133. package/src/seed/apply.ts +25 -8
  134. package/src/seed/types.ts +4 -0
  135. package/dist/index-DjPMOfO0.d.mts.map +0 -1
  136. package/dist/media-D8FbNsl0.mjs.map +0 -1
  137. package/dist/registry-Beb7wxFc.mjs.map +0 -1
  138. package/dist/request-cache-C-tIpYIw.mjs.map +0 -1
  139. package/dist/runner-DMnlIkh4.mjs.map +0 -1
  140. package/dist/search-DkN-BqsS.mjs.map +0 -1
  141. package/dist/types-CoO6mpV3.mjs +0 -68
  142. package/dist/types-CoO6mpV3.mjs.map +0 -1
  143. package/dist/types-D19uBYWn.d.mts.map +0 -1
  144. package/dist/types-Dl1fgFjn.d.mts.map +0 -1
  145. package/dist/types-Dtx1mSMX.d.mts.map +0 -1
  146. package/dist/types-Eg829jj9.mjs.map +0 -1
  147. package/dist/validate-DHGwADqO.d.mts.map +0 -1
  148. package/dist/version-CMD42IRC.mjs +0 -7
@@ -1,16 +1,16 @@
1
- import { i as __exportAll } from "./runner-DMnlIkh4.mjs";
1
+ import { i as __exportAll } from "./runner-DIcU2UCC.mjs";
2
2
  import { n as getI18nConfig } from "./config-CVssduLe.mjs";
3
- import { r as RevisionRepository, t as ContentRepository } from "./content-C7G4QXkK.mjs";
4
- import { t as MediaRepository } from "./media-D8FbNsl0.mjs";
5
- import { t as TaxonomyRepository } from "./taxonomy-DSxx2K2L.mjs";
3
+ import { r as RevisionRepository, t as ContentRepository } from "./content-CERxPUN0.mjs";
4
+ import { t as MediaRepository } from "./media-1fFhub9c.mjs";
5
+ import { t as TaxonomyRepository } from "./taxonomy-D6NvlKo8.mjs";
6
6
  import { t as OptionsRepository } from "./options-nPxWnrya.mjs";
7
7
  import { t as withTransaction } from "./transaction-D44LBXvU.mjs";
8
8
  import { t as RedirectRepository } from "./redirect-C5H7VGIX.mjs";
9
- import { t as BylineRepository } from "./byline-C3vnhIpU.mjs";
10
- import { i as FTSManager, n as SchemaRegistry } from "./registry-Beb7wxFc.mjs";
11
- import { r as getDb } from "./loader-Bx2_9-5e.mjs";
12
- import { n as requestCached, t as peekRequestCache } from "./request-cache-C-tIpYIw.mjs";
13
- import { t as validateSeed } from "./validate-CBIbxM3L.mjs";
9
+ import { t as BylineRepository } from "./byline-gFn1r0vA.mjs";
10
+ import { n as requestCached, t as peekRequestCache } from "./request-cache-D4I69LeL.mjs";
11
+ import { i as FTSManager, n as SchemaRegistry } from "./registry-Do34mz_P.mjs";
12
+ import { r as getDb } from "./loader-ou_PXAjg.mjs";
13
+ import { t as validateSeed } from "./validate-UK4Ja1uo.mjs";
14
14
  import { ulid } from "ulidx";
15
15
  import { imageSize } from "image-size";
16
16
  import mime from "mime/lite";
@@ -908,6 +908,7 @@ async function applySeed(db, seed, options = {}) {
908
908
  }
909
909
  if (seed.menus) {
910
910
  const menuSeedIdMap = /* @__PURE__ */ new Map();
911
+ const itemSeedIdMap = /* @__PURE__ */ new Map();
911
912
  const fallbackLocale = getI18nConfig()?.defaultLocale ?? "en";
912
913
  for (const menu of seed.menus) {
913
914
  const locale = menu.locale ?? fallbackLocale;
@@ -941,7 +942,7 @@ async function applySeed(db, seed, options = {}) {
941
942
  id: menuId,
942
943
  translationGroup
943
944
  });
944
- const itemCount = await applyMenuItems(db, menuId, locale, menu.items, null, 0, seedIdMap);
945
+ const itemCount = await applyMenuItems(db, menuId, locale, menu.items, null, 0, seedIdMap, itemSeedIdMap);
945
946
  result.menus.items += itemCount;
946
947
  }
947
948
  }
@@ -1042,9 +1043,9 @@ async function applySeed(db, seed, options = {}) {
1042
1043
  }
1043
1044
  }
1044
1045
  }
1045
- const { invalidateBylineCache } = await import("./bylines-esI7ioa9.mjs").then((n) => n.t);
1046
- const { invalidateRedirectCache } = await import("./cache-fTzxgMFJ.mjs").then((n) => n.t);
1047
- const { invalidateUrlPatternCache } = await import("./query-Bo-msrmu.mjs").then((n) => n.o);
1046
+ const { invalidateBylineCache } = await import("./bylines-DTFI8nDM.mjs").then((n) => n.t);
1047
+ const { invalidateRedirectCache } = await import("./cache-BAJbeoZ8.mjs").then((n) => n.t);
1048
+ const { invalidateUrlPatternCache } = await import("./query-8c_meo_K.mjs").then((n) => n.o);
1048
1049
  invalidateBylineCache();
1049
1050
  invalidateRedirectCache();
1050
1051
  invalidateUrlPatternCache();
@@ -1128,7 +1129,7 @@ async function applyContentTaxonomies(db, collectionSlug, contentId, entry, isUp
1128
1129
  if (isUpdate) await db.deleteFrom("content_taxonomies").where("collection", "=", collectionSlug).where("entry_id", "=", contentId).execute();
1129
1130
  if (!entry.taxonomies) {
1130
1131
  if (isUpdate) {
1131
- const { invalidateTermCache } = await import("./taxonomies-CTtewrSQ.mjs").then((n) => n.u);
1132
+ const { invalidateTermCache } = await import("./taxonomies-Bw76xAxo.mjs").then((n) => n.u);
1132
1133
  invalidateTermCache();
1133
1134
  }
1134
1135
  return;
@@ -1140,23 +1141,23 @@ async function applyContentTaxonomies(db, collectionSlug, contentId, entry, isUp
1140
1141
  if (term) await termRepo.attachToEntry(collectionSlug, contentId, term.id);
1141
1142
  }
1142
1143
  }
1143
- const { invalidateTermCache } = await import("./taxonomies-CTtewrSQ.mjs").then((n) => n.u);
1144
+ const { invalidateTermCache } = await import("./taxonomies-Bw76xAxo.mjs").then((n) => n.u);
1144
1145
  invalidateTermCache();
1145
1146
  }
1146
1147
  /**
1147
1148
  * Apply menu items recursively.
1148
1149
  *
1149
- * Each item gets a fresh `translation_group` (= its own id). The seed format's
1150
- * `SeedMenuItem` has no `id`/`translationOf` fields, so we can't express the
1151
- * cross-locale "same nav entry" link here items diverge across locales on
1152
- * re-apply. Runtime navigation still resolves correctly because `reference_id`
1153
- * already holds the content's translation_group.
1150
+ * When a `SeedMenuItem` carries `id`/`translationOf`, the import resolves the
1151
+ * source item's `translation_group` so cross-locale "same nav entry" links
1152
+ * survive export apply. Items without `translationOf` get a fresh group
1153
+ * (= their own id).
1154
1154
  */
1155
- async function applyMenuItems(db, menuId, locale, items, parentId, startOrder, seedIdMap) {
1155
+ async function applyMenuItems(db, menuId, locale, items, parentId, startOrder, seedIdMap, itemSeedIdMap) {
1156
1156
  let count = 0;
1157
1157
  let order = startOrder;
1158
1158
  for (const item of items) {
1159
1159
  const itemId = ulid();
1160
+ const itemLocale = item.locale ?? locale;
1160
1161
  let referenceId = null;
1161
1162
  let referenceCollection = null;
1162
1163
  if (item.type === "page" || item.type === "post") {
@@ -1165,6 +1166,12 @@ async function applyMenuItems(db, menuId, locale, items, parentId, startOrder, s
1165
1166
  referenceCollection = item.collection || `${item.type}s`;
1166
1167
  }
1167
1168
  }
1169
+ let translationGroup = itemId;
1170
+ if (item.translationOf) {
1171
+ const source = itemSeedIdMap.get(item.translationOf);
1172
+ if (source) translationGroup = source.translationGroup;
1173
+ else console.warn(`menu item "${item.label ?? item.url ?? item.ref ?? "(unlabeled)"}" (${itemLocale}): translationOf "${item.translationOf}" not found yet; minting a fresh group.`);
1174
+ }
1168
1175
  await db.insertInto("_emdash_menu_items").values({
1169
1176
  id: itemId,
1170
1177
  menu_id: menuId,
@@ -1179,13 +1186,17 @@ async function applyMenuItems(db, menuId, locale, items, parentId, startOrder, s
1179
1186
  target: item.target ?? null,
1180
1187
  css_classes: item.cssClasses ?? null,
1181
1188
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
1182
- locale,
1183
- translation_group: itemId
1189
+ locale: itemLocale,
1190
+ translation_group: translationGroup
1184
1191
  }).execute();
1192
+ if (item.id) itemSeedIdMap.set(item.id, {
1193
+ id: itemId,
1194
+ translationGroup
1195
+ });
1185
1196
  count++;
1186
1197
  order++;
1187
1198
  if (item.children && item.children.length > 0) {
1188
- const childCount = await applyMenuItems(db, menuId, locale, item.children, itemId, 0, seedIdMap);
1199
+ const childCount = await applyMenuItems(db, menuId, itemLocale, item.children, itemId, 0, seedIdMap, itemSeedIdMap);
1189
1200
  count += childCount;
1190
1201
  }
1191
1202
  }
@@ -1377,4 +1388,4 @@ function getImageDimensions(buffer) {
1377
1388
 
1378
1389
  //#endregion
1379
1390
  export { ssrfSafeFetch as a, getPluginSetting as c, getSiteSettings as d, setSiteSettings as f, resolveAndValidateExternalUrl as i, getPluginSettings as l, apply_exports as n, stripCredentialHeaders as o, SsrfError as r, validateExternalUrl as s, applySeed as t, getSiteSetting as u };
1380
- //# sourceMappingURL=apply-UsrFuO7l.mjs.map
1391
+ //# sourceMappingURL=apply-Ded_1vng.mjs.map