astronaut-cms 1.0.0 → 1.1.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.
Files changed (85) hide show
  1. package/dist/admin/THIRD_PARTY_LICENSES.md +88 -40
  2. package/dist/admin/assets/assistant-DTlSNidc.js +235 -0
  3. package/dist/admin/assets/badge-BfN73-be.js +1 -0
  4. package/dist/admin/assets/changes-h1lmD7AA.js +1 -0
  5. package/dist/admin/assets/client-B4PWCmC4.js +5 -0
  6. package/dist/admin/assets/{collapsible-item-UaoJaaPw.js → collapsible-item-zlnNAUdM.js} +1 -1
  7. package/dist/admin/assets/{collapsible-B6P_J0Bg.js → collapsible-mcJ6G3X4.js} +1 -1
  8. package/dist/admin/assets/{collections._collection-BE1enDCq.js → collections._collection-D-rC9E9v.js} +1 -1
  9. package/dist/admin/assets/{collections._collection._entry-D3UksnCo.js → collections._collection._entry-UD8hLmC1.js} +33 -33
  10. package/dist/admin/assets/collections._collection.index-Cgc93hCD.js +1 -0
  11. package/dist/admin/assets/component-lookup-8lVQh8pl.js +4 -0
  12. package/dist/admin/assets/{copy-DezZzPMV.js → copy-DxuErr3x.js} +1 -1
  13. package/dist/admin/assets/{dist-UbA1s2kM.js → dist-DVv3ALC7.js} +1 -1
  14. package/dist/admin/assets/{dist-DzkcSBZl.js → dist-Dpyc1riS.js} +1 -1
  15. package/dist/admin/assets/editor-BauN0yXd.js +2 -0
  16. package/dist/admin/assets/{empty-DSBYiI_7.js → empty-DAOUBpWb.js} +1 -1
  17. package/dist/admin/assets/{entry-link-CQLN2Zpf.js → entry-link-DhcL6M5c.js} +19 -19
  18. package/dist/admin/assets/{error-banner-yskeRXe8.js → error-banner-CNWZU5u_.js} +93 -91
  19. package/dist/admin/assets/{field-BDK5tt3J.js → field-CbbZZGxO.js} +2 -2
  20. package/dist/admin/assets/{file-text-BzBif8ui.js → file-text-Ciz5Mr4S.js} +1 -1
  21. package/dist/admin/assets/{highlighted-body-JLMTFACH-CIQujGv2.js → highlighted-body-JLMTFACH-D1bycIV3.js} +1 -1
  22. package/dist/admin/assets/{lib-CMURo-7A.js → lib-CC_S4yjQ.js} +9 -9
  23. package/dist/admin/assets/{library-Cr3f75Es.js → library-Da82FNwp.js} +1 -1
  24. package/dist/admin/assets/{list-skeleton-BdTNfVXs.js → list-skeleton-BXLP4Fak.js} +1 -1
  25. package/dist/admin/assets/matchContext-BjW1F-Cq.js +2 -0
  26. package/dist/admin/assets/media-browser-DeKpWCUD.js +1 -0
  27. package/dist/admin/assets/media._library-DGnXJc0I.js +1 -0
  28. package/dist/admin/assets/mermaid-WFAXDIZX-CqFnahFh.js +1 -0
  29. package/dist/admin/assets/page-header-C2Uwa_yv.js +1 -0
  30. package/dist/admin/assets/pdf-BSEX-sd8.js +106 -0
  31. package/dist/admin/assets/{react-kbcsfQYH.js → react-CXnqG51l.js} +1 -1
  32. package/dist/admin/assets/{routes-CBt04sNR.js → routes-Bx9rPcHA.js} +1 -1
  33. package/dist/admin/assets/save-actions-DrVgh3KH.js +32 -0
  34. package/dist/admin/assets/{select-Bv2EoLhN.js → select-CMV39q80.js} +1 -1
  35. package/dist/admin/assets/separator-C9bNKNSU.js +3 -0
  36. package/dist/admin/assets/{skeleton-CKiqTaRh.js → skeleton-DTwTUSqm.js} +1 -1
  37. package/dist/admin/assets/syntax-DDPd1mQn.js +8 -0
  38. package/dist/admin/assets/{toggle-Y2UpJZyU.js → toggle-B6ASf-kL.js} +1 -1
  39. package/dist/admin/assets/{ui.module.css-WaO_77ml.js → ui.module.css-BdAmwQeM.js} +29 -29
  40. package/dist/admin/assets/{use-entries-B2lsaiK9.js → use-entries-CrNqaMfa.js} +1 -1
  41. package/dist/admin/assets/useSelector-Cs39W18m.js +1 -0
  42. package/dist/admin/bootstrap.js +1 -1
  43. package/dist/admin/editor.d.ts +1009 -1
  44. package/dist/admin/editor.js +1 -1
  45. package/dist/server/THIRD_PARTY_LICENSES.md +49 -0
  46. package/dist/server/assets.d.ts +28 -0
  47. package/dist/server/chunks/config-BsOYly9a.d.ts +1210 -0
  48. package/dist/server/chunks/{digest-BYzWNJea.js → digest-tkKu_Wj5.js} +3 -3
  49. package/dist/server/chunks/{entry-checks-CKMag1G4.js → entry-checks-3SxhoHwH.js} +1 -1
  50. package/dist/server/chunks/{types-DOR5XaJO.js → types-DkkewFTT.js} +32 -11
  51. package/dist/server/chunks/{types-DwA-C6Br.d.ts → types-Jew_-Qpp.d.ts} +8 -1
  52. package/dist/server/chunks/{user-config-DoypbpQf.js → user-config-CqNK-Ebs.js} +13 -4
  53. package/dist/server/config.d.ts +3 -3
  54. package/dist/server/config.js +5 -1
  55. package/dist/server/content.d.ts +10 -0
  56. package/dist/server/content.js +2 -8
  57. package/dist/server/endpoint.d.ts +5 -0
  58. package/dist/server/endpoint.js +28 -14
  59. package/dist/server/integration.d.ts +2 -2
  60. package/dist/server/integration.js +29 -16
  61. package/dist/server/internal.d.ts +39 -4
  62. package/dist/server/internal.js +2 -2
  63. package/dist/server/server-local.d.ts +1 -1
  64. package/dist/server/server-local.js +2 -2
  65. package/dist/styles/THIRD_PARTY_LICENSES.md +2 -2
  66. package/dist/styles/styles.css +2 -2
  67. package/package.json +4 -4
  68. package/dist/admin/assets/assistant-DkS355co.js +0 -201
  69. package/dist/admin/assets/badge-BXsOvOPX.js +0 -1
  70. package/dist/admin/assets/changes-Ba0G_GN1.js +0 -1
  71. package/dist/admin/assets/client-VKp75fDU.js +0 -5
  72. package/dist/admin/assets/collections._collection.index-BN5d8UIY.js +0 -1
  73. package/dist/admin/assets/component-lookup-CUCiK8Xh.js +0 -4
  74. package/dist/admin/assets/editor-FGqMznBK.js +0 -2
  75. package/dist/admin/assets/matchContext-Bq5Es9aD.js +0 -2
  76. package/dist/admin/assets/media-browser-9-CPTCks.js +0 -1
  77. package/dist/admin/assets/media._library-BfFaEZLR.js +0 -1
  78. package/dist/admin/assets/mermaid-WFAXDIZX-CJ3hhA0i.js +0 -1
  79. package/dist/admin/assets/page-header-B4nvAsVA.js +0 -1
  80. package/dist/admin/assets/pdf-DgessaF0.js +0 -106
  81. package/dist/admin/assets/save-actions-Cz0TkpcP.js +0 -32
  82. package/dist/admin/assets/separator-DlYj_PoQ.js +0 -3
  83. package/dist/admin/assets/syntax-BAXqRKRO.js +0 -8
  84. package/dist/admin/assets/useSelector-CWr3iU9K.js +0 -1
  85. package/dist/server/chunks/config-WQqG4mNH.d.ts +0 -193
@@ -1,8 +1,8 @@
1
1
  import { a as assertWithinSizeLimit, l as isLibraryFile, m as mediaPath, o as describeMediaRef, v as repoOnlyRefusal } from "./media-BhqUVVYY.js";
2
2
  import { n as stripMediaPrefix } from "./paths-CEW9fvg8.js";
3
3
  import { d as diagnostic, s as isRecord, u as ContentValidationError } from "./field-schema-CfdN75jT.js";
4
- import { _ as getFileExtension, b as serializeContent, c as globEntry, o as entryFilePath, p as singletonIds, r as asEntryFormat, v as parseContent, x as serializeMultiEntryFile, y as parseMultiEntryFile } from "./types-DOR5XaJO.js";
5
- import { a as libraryPathError, c as validateBody, d as activeVariant, f as errorMessage, s as validatePath, t as checkEntry, u as isAsset } from "./entry-checks-CKMag1G4.js";
4
+ import { _ as getFileExtension, b as serializeContent, c as globEntry, i as asEntryFormat, m as singletonIds, o as entryFilePath, v as parseContent, x as serializeMultiEntryFile, y as parseMultiEntryFile } from "./types-DkkewFTT.js";
5
+ import { a as libraryPathError, c as validateBody, d as activeVariant, f as errorMessage, s as validatePath, t as checkEntry, u as isAsset } from "./entry-checks-3SxhoHwH.js";
6
6
  import { join } from "pathe";
7
7
  import { TomlDate } from "smol-toml";
8
8
  // src/server/errors.ts
@@ -383,7 +383,7 @@ var StorageBase = class {
383
383
  * other order is the site's, so a rewrite would change nothing it renders.
384
384
  */
385
385
  async reorderEntries(collection, ids, expectedVersion) {
386
- if (this.schemas[collection]?.sort !== "file") throw new Error(`Collection is not sorted by file order: ${collection}`);
386
+ if (this.schemas[collection]?.sort.by !== "file") throw new Error(`Collection is not sorted by file order: ${collection}`);
387
387
  const { path, content } = await this.editFileCollection(collection, (entries) => new Map(new Set(ids).union(entries).values().filter((id) => entries.has(id)).map((id) => [id, entries.get(id)])));
388
388
  await this.persist(path, content, `Reorder ${collection}`, versioned(expectedVersion));
389
389
  }
@@ -1,6 +1,6 @@
1
1
  import { l as isLibraryFile } from "./media-BhqUVVYY.js";
2
2
  import { c as isRequired, d as diagnostic, l as objectShape, s as isRecord } from "./field-schema-CfdN75jT.js";
3
- import { c as globEntry, f as loaderPatterns, i as collectionBase, l as globEntryId } from "./types-DOR5XaJO.js";
3
+ import { a as collectionBase, c as globEntry, f as loaderPatterns, l as globEntryId } from "./types-DkkewFTT.js";
4
4
  import { r as findComponent, t as childComponents } from "./component-lookup-DAFg_Qg8.js";
5
5
  import { a as LINK_MESSAGE, c as containsLink, i as LINK_DESCRIPTION, l as isAllowedLink, n as anchorIds, o as PLAIN_TEXT_MESSAGE, r as checkAnchors, s as allowedLinks, t as ANCHOR_DESCRIPTION, u as isLinkLike } from "./anchors-DuZ1fokt.js";
6
6
  import { z } from "zod";
@@ -248,19 +248,40 @@ var ALL_FORMATS = [...CONTENT_FORMATS, ...DATA_FORMATS];
248
248
  function asEntryFormat(value) {
249
249
  return ALL_FORMATS.includes(value) ? value : null;
250
250
  }
251
+ /** Astro's own order, which a collection keeps unless `cms.config` names another. */
252
+ var DEFAULT_SORT = { by: "id" };
251
253
  var naturalCollator = new Intl.Collator(void 0, { numeric: true });
252
- /**
253
- * Compares two entry ids under `sort`. File order is no order of ids, so it
254
- * compares them as astro does, for whatever the file does not place.
255
- */
254
+ var compareAsAstro = (a, b) => a.localeCompare(b);
255
+ /** Compares two entry ids or folder names under `sort`, as astro does unless it is natural. */
256
256
  function compareIds(sort) {
257
- return sort === "natural" ? (a, b) => naturalCollator.compare(a, b) : (a, b) => a.localeCompare(b);
257
+ return sort.by === "natural" ? naturalCollator.compare : compareAsAstro;
258
+ }
259
+ /** A value as a sort compares it: a date by its time, a boolean as text, anything not scalar as missing. */
260
+ function sortKey(value) {
261
+ if (value instanceof Date) return value.getTime();
262
+ if (typeof value === "number" || typeof value === "string") return value;
263
+ return typeof value === "boolean" ? String(value) : void 0;
264
+ }
265
+ function compareKeys(a, b) {
266
+ if (a === void 0 || b === void 0) return Number(a === void 0) - Number(b === void 0);
267
+ return typeof a === "number" && typeof b === "number" ? a - b : naturalCollator.compare(String(a), String(b));
258
268
  }
259
- /** Entries by id under `sort`, or as given for file order, which the listing already is. */
260
- function sortByIds(entries, sort) {
261
- if (sort === "file") return [...entries];
262
- const compare = compareIds(sort);
263
- return entries.toSorted((a, b) => compare(a.id, b.id));
269
+ /**
270
+ * Entries in `sort` order. A field order compares what `value` reads off each
271
+ * entry, a file order the position in `fileOrder`, each with entries lacking
272
+ * one last and ties by id as astro orders them.
273
+ */
274
+ function orderEntries(entries, sort, value, fileOrder = []) {
275
+ if (sort.by === "id" || sort.by === "natural") {
276
+ const compare = compareIds(sort);
277
+ return entries.toSorted((a, b) => compare(a.id, b.id));
278
+ }
279
+ const rank = new Map(fileOrder.map((id, index) => [id, index]));
280
+ const key = (entry) => sort.by === "field" ? sortKey(value(entry, sort.field)) : rank.get(entry.id);
281
+ return entries.map((entry) => ({
282
+ entry,
283
+ key: key(entry)
284
+ })).sort((a, b) => compareKeys(a.key, b.key) || compareAsAstro(a.entry.id, b.entry.id)).map(({ entry }) => entry);
264
285
  }
265
286
  /** `derive` cached per manifest entry, which never changes once loaded. */
266
287
  function perCollection(derive) {
@@ -394,4 +415,4 @@ function entryFilePath(collection, id, format) {
394
415
  if (collection.loaderType === "file" && collection.loaderFileName) return collection.loaderFileName;
395
416
  return globRoots(collection).find((root) => root.file && getFileExtension(root.path) === format && globEntryId(collection, root.path) === id)?.path ?? join(collectionBase(collection), `${id}.${format}`);
396
417
  }
397
- export { getFileExtension as _, compareIds as a, serializeContent as b, globEntry as c, inGlobRoot as d, loaderPatterns as f, splitLocale as g, joinLocale as h, collectionBase as i, globEntryId as l, sortByIds as m, DATA_FORMATS as n, entryFilePath as o, singletonIds as p, asEntryFormat as r, findSingleton as s, ALL_FORMATS as t, globRoots as u, parseContent as v, serializeMultiEntryFile as x, parseMultiEntryFile as y };
418
+ export { getFileExtension as _, collectionBase as a, serializeContent as b, globEntry as c, inGlobRoot as d, loaderPatterns as f, splitLocale as g, joinLocale as h, asEntryFormat as i, globEntryId as l, singletonIds as m, DATA_FORMATS as n, entryFilePath as o, orderEntries as p, DEFAULT_SORT as r, findSingleton as s, ALL_FORMATS as t, globRoots as u, parseContent as v, serializeMultiEntryFile as x, parseMultiEntryFile as y };
@@ -140,8 +140,15 @@ type LoaderType = "glob" | "file";
140
140
  * - `natural`: by id, with digit runs compared as numbers (`2` before `10`).
141
141
  * - `file`: in the order the file of a `file()` collection holds them, which the
142
142
  * admin then lets editors change.
143
+ * - `field`: by the value of a top-level `field`, compared like `natural`,
144
+ * then by id, with entries lacking a value last.
143
145
  */
144
- type CollectionSort = "id" | "natural" | "file";
146
+ type CollectionSort = {
147
+ by: "id" | "natural" | "file";
148
+ } | {
149
+ by: "field";
150
+ field: string;
151
+ };
145
152
  /**
146
153
  * Fully-resolved description of one content collection, extracted from the
147
154
  * user's `content.config.ts` in Node and serialized into the admin bundle.
@@ -276,8 +276,17 @@ function processUserConfig(components, i18n) {
276
276
  };
277
277
  return walk(components ?? {});
278
278
  }
279
- /** The collections' icons by name, the one option the manifest cannot carry, being live components. */
280
- function processCollectionIcons(collections) {
281
- return Object.fromEntries(Object.entries(collections ?? {}).flatMap(([name, { icon }]) => icon ? [[name, icon]] : []));
279
+ /**
280
+ * Lowers `cms.config.ts` into its {@link UserModule}.
281
+ * The module is passed whole, so the bundler does not warn about the exports a site leaves out.
282
+ * The collections contribute their icons only, the one option the manifest
283
+ * cannot carry, being live components.
284
+ */
285
+ function processUserModule({ components, collections = {}, links = [] }, i18n) {
286
+ return {
287
+ components: processUserConfig(components, i18n),
288
+ collectionIcons: Object.fromEntries(Object.entries(collections).flatMap(([name, { icon }]) => icon ? [[name, icon]] : [])),
289
+ links
290
+ };
282
291
  }
283
- export { zodToFieldSchema as i, processUserConfig as n, propsResolver as r, processCollectionIcons as t };
292
+ export { zodToFieldSchema as i, processUserModule as n, propsResolver as r, processUserConfig as t };
@@ -1,3 +1,3 @@
1
- import { a as ComponentDefinition, c as defineCollection, d as anchorMarker, f as fileMarker, h as localizedMarker, i as CollectionRegistry, l as defineComponent, m as linkMarker, n as CollectionName, o as ComponentIcon, p as libraryImage, r as CollectionOptions, s as SchemaHelpers, t as ChildrenConfig, v as JsxEditor, y as JsxEditorProps } from "./chunks/config-WQqG4mNH.js";
2
- import { i as CollectionSort } from "./chunks/types-DwA-C6Br.js";
3
- export { ChildrenConfig, CollectionName, CollectionOptions, CollectionRegistry, type CollectionSort, ComponentDefinition, ComponentIcon, type JsxEditor, type JsxEditorProps, SchemaHelpers, anchorMarker as anchor, defineCollection, defineComponent, fileMarker as file, libraryImage, linkMarker as link, localizedMarker as localized };
1
+ import { _ as localizedMarker, a as ComponentDefinition, b as JsxEditor, c as SchemaHelpers, d as defineLink, g as linkMarker, h as libraryImage, i as CollectionRegistry, l as defineCollection, m as fileMarker, n as CollectionName, o as ComponentIcon, p as anchorMarker, r as CollectionOptions, s as LinkOptions, t as ChildrenConfig, u as defineComponent, x as JsxEditorProps } from "./chunks/config-BsOYly9a.js";
2
+ import { i as CollectionSort } from "./chunks/types-Jew_-Qpp.js";
3
+ export { ChildrenConfig, CollectionName, CollectionOptions, CollectionRegistry, type CollectionSort, ComponentDefinition, ComponentIcon, type JsxEditor, type JsxEditorProps, LinkOptions, SchemaHelpers, anchorMarker as anchor, defineCollection, defineComponent, defineLink, fileMarker as file, libraryImage, linkMarker as link, localizedMarker as localized };
@@ -8,6 +8,10 @@ import { a as localizedMarker, i as linkMarker, n as fileMarker, r as libraryIma
8
8
  function defineCollection(options) {
9
9
  return options;
10
10
  }
11
+ /** One entry of the `links` export of `cms.config`. */
12
+ function defineLink(options) {
13
+ return options;
14
+ }
11
15
  /**
12
16
  * One entry of the `components` export of `cms.config`. The integration renders
13
17
  * it in MDX through a generated wrapper, which `astronaut-cms:components` exports.
@@ -15,4 +19,4 @@ function defineCollection(options) {
15
19
  function defineComponent(def) {
16
20
  return def;
17
21
  }
18
- export { anchorMarker as anchor, defineCollection, defineComponent, fileMarker as file, libraryImage, linkMarker as link, localizedMarker as localized };
22
+ export { anchorMarker as anchor, defineCollection, defineComponent, defineLink, fileMarker as file, libraryImage, linkMarker as link, localizedMarker as localized };
@@ -1,8 +1,18 @@
1
+ /**
2
+ * Reading content in the site the way the admin edits it: entry order, and the
3
+ * language of localized collections and fields.
4
+ *
5
+ * Entry order is the same the admin shows. Astro's content store
6
+ * returns a collection sorted by id and keeps no trace of the order a `file()`
7
+ * collection's file holds, so a collection with a `sort` option is ordered here,
8
+ * from what the integration read off the content.
9
+ */
1
10
  import { CollectionEntry, CollectionKey } from "astro:content";
2
11
  /** What ordering reads off an entry of astro's `getCollection`. */
3
12
  interface SortableEntry {
4
13
  id: string;
5
14
  collection: string;
15
+ data: Readonly<Record<string, unknown>>;
6
16
  }
7
17
  /**
8
18
  * The entries of one collection, in the order its `sort` option names.
@@ -1,4 +1,4 @@
1
- import { a as compareIds, g as splitLocale, h as joinLocale, m as sortByIds } from "./chunks/types-DOR5XaJO.js";
1
+ import { g as splitLocale, h as joinLocale, p as orderEntries, r as DEFAULT_SORT } from "./chunks/types-DkkewFTT.js";
2
2
  import { getEntry } from "astro:content";
3
3
  import { contentI18n, fileOrder, sorts } from "virtual:astronaut-cms/content";
4
4
  // src/content/index.ts
@@ -11,7 +11,6 @@ import { contentI18n, fileOrder, sorts } from "virtual:astronaut-cms/content";
11
11
  * collection's file holds, so a collection with a `sort` option is ordered here,
12
12
  * from what the integration read off the content.
13
13
  */
14
- var ranks = new Map(Object.entries(fileOrder).map(([name, ids]) => [name, new Map(ids.map((id, index) => [id, index]))]));
15
14
  /**
16
15
  * The entries of one collection, in the order its `sort` option names.
17
16
  *
@@ -20,12 +19,7 @@ var ranks = new Map(Object.entries(fileOrder).map(([name, ids]) => [name, new Ma
20
19
  */
21
20
  function sortEntries(entries) {
22
21
  const collection = entries[0]?.collection ?? "";
23
- const sort = sorts[collection] ?? "id";
24
- const rank = ranks.get(collection);
25
- if (sort !== "file" || !rank) return sortByIds(entries, sort);
26
- const position = (entry) => rank.get(entry.id) ?? rank.size;
27
- const compare = compareIds(sort);
28
- return entries.toSorted((a, b) => position(a) - position(b) || compare(a.id, b.id));
22
+ return orderEntries(entries, sorts[collection] ?? DEFAULT_SORT, (entry, field) => entry.data[field], fileOrder[collection]);
29
23
  }
30
24
  function languages() {
31
25
  if (!contentI18n) throw new Error("astronaut-cms: localized content needs content languages, set `i18n` in astro.config.");
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Astro-route shell over the server in `handler.ts`: one
3
+ * injected route covering every CMS API path, so the integration injects one
4
+ * thing and the handler does the routing.
5
+ */
1
6
  import { APIRoute } from "astro";
2
7
  /**
3
8
  * The whole API for one request. `clientAddress` is the caller's address as the
@@ -1,11 +1,11 @@
1
1
  import { c as GITLAB_CLIENT_SECRET_ENV, i as API_LOGIN, n as API_BASE, r as API_CALLBACK, s as GITHUB_CLIENT_SECRET_ENV, u as PROVIDERS } from "./chunks/auth-DJP9ryVd.js";
2
2
  import { d as diagnostic, u as ContentValidationError } from "./chunks/field-schema-CfdN75jT.js";
3
3
  import { a as HARDENING_HEADERS, c as partialContent, d as readBytes, i as BodyTooLargeError, l as rangeHeader, s as parseByteRange, u as readBody } from "./chunks/component-lookup-DAFg_Qg8.js";
4
- import { _ as assertLibraryPath, a as fromBase64, b as checked, c as MergeConflictError, f as getErrorStatus, g as versioned, h as staleWrite, l as StaleWriteError, m as satisfies, o as memoized, r as BranchedStorage, s as validateReorder, t as changesetDigest, u as exists, v as ApiError, y as HttpError } from "./chunks/digest-BYzWNJea.js";
4
+ import { _ as assertLibraryPath, a as fromBase64, b as checked, c as MergeConflictError, f as getErrorStatus, g as versioned, h as staleWrite, l as StaleWriteError, m as satisfies, o as memoized, r as BranchedStorage, s as validateReorder, t as changesetDigest, u as exists, v as ApiError, y as HttpError } from "./chunks/digest-tkKu_Wj5.js";
5
5
  import { C as joinUrl, S as conformTrailingSlash, T as withoutTrailingSlash, _ as remoteMediaUrl, a as assertWithinSizeLimit, b as servedContentType, c as isActiveContentType, d as mediaContentType, f as mediaLibraries, g as parseMediaLibrary, i as S3_SESSION_TOKEN_ENV, l as isLibraryFile, m as mediaPath, n as S3_ACCESS_KEY_ID_ENV, p as mediaLibrary, r as S3_SECRET_ACCESS_KEY_ENV, s as encodeKeyPath, y as s3BaseUrl } from "./chunks/media-BhqUVVYY.js";
6
6
  import { a as gatewayAddress, i as NETLIFY_GATEWAY_ENV, n as xmlList, r as parseRepo, t as parseXml } from "./chunks/xml-D8qPILJU.js";
7
- import { c as validateBody, f as errorMessage, l as dataLeaves, o as mediaPathError, r as collectionEnum, u as isAsset } from "./chunks/entry-checks-CKMag1G4.js";
8
- import { d as inGlobRoot, t as ALL_FORMATS, u as globRoots } from "./chunks/types-DOR5XaJO.js";
7
+ import { c as validateBody, f as errorMessage, l as dataLeaves, o as mediaPathError, r as collectionEnum, u as isAsset } from "./chunks/entry-checks-3SxhoHwH.js";
8
+ import { d as inGlobRoot, p as orderEntries, r as DEFAULT_SORT, t as ALL_FORMATS, u as globRoots } from "./chunks/types-DkkewFTT.js";
9
9
  import { t as projectPath } from "./chunks/paths-CEW9fvg8.js";
10
10
  import { dirname, join } from "pathe";
11
11
  import { z } from "zod";
@@ -1497,6 +1497,16 @@ function describeReference(reference) {
1497
1497
  function referencesFor(index, { library, path }) {
1498
1498
  return index.find((file) => file.library === library && file.path === path)?.references ?? [];
1499
1499
  }
1500
+ // src/server/parallel.ts
1501
+ /** How many reads may be in flight at once, which keeps a provider's rate limit in reach. */
1502
+ var CONCURRENCY = 10;
1503
+ /** A worker pool: a fixed number of readers sharing one iterator, with no barriers. */
1504
+ async function inParallel(items, fn) {
1505
+ const cursor = items.values();
1506
+ await Promise.all(Array.from({ length: Math.min(CONCURRENCY, items.length) }, async () => {
1507
+ for (const item of cursor) await fn(item);
1508
+ }));
1509
+ }
1500
1510
  // src/server/references.ts
1501
1511
  /**
1502
1512
  * What reaches which library file.
@@ -1511,15 +1521,6 @@ function referencesFor(index, { library, path }) {
1511
1521
  * deletion is refused on. A precondition only the caller checks is caller
1512
1522
  * discipline; this one is a rule of the library.
1513
1523
  */
1514
- /** How many entry reads may be in flight at once. */
1515
- var CONCURRENCY = 10;
1516
- /** A worker pool: a fixed number of readers sharing one iterator, with no barriers. */
1517
- async function inParallel(items, fn) {
1518
- const cursor = items.values();
1519
- await Promise.all(Array.from({ length: Math.min(CONCURRENCY, items.length) }, async () => {
1520
- for (const item of cursor) await fn(item);
1521
- }));
1522
- }
1523
1524
  /**
1524
1525
  * Paths and object-store URLs a body mentions with no schema to declare them.
1525
1526
  * Only a match under a library counts, with an extension that library admits,
@@ -1691,8 +1692,21 @@ async function assertMovable(ctx, file, acknowledged) {
1691
1692
  await assertInLibrary(ctx, file);
1692
1693
  await assertReferencesAcknowledged(ctx, file, acknowledged);
1693
1694
  }
1695
+ /**
1696
+ * A collection's entries in its order, so no client sorts them again. A field
1697
+ * order needs every entry read, and a file() collection lists in file order.
1698
+ */
1699
+ async function listInOrder(ctx, collection) {
1700
+ const entries = await ctx.storage.listEntries(collection);
1701
+ const sort = client.collections[collection]?.sort ?? DEFAULT_SORT;
1702
+ const values = /* @__PURE__ */ new Map();
1703
+ if (sort.by === "field") await inParallel(entries, async (entry) => {
1704
+ values.set(entry.id, (await ctx.storage.readEntry(entry)).data[sort.field]);
1705
+ });
1706
+ return orderEntries(entries, sort, (entry) => values.get(entry.id), entries.map((entry) => entry.id));
1707
+ }
1694
1708
  var operations = {
1695
- listEntries: op(z.object({ collection }), (ctx, input) => ctx.storage.listEntries(input.collection)),
1709
+ listEntries: op(z.object({ collection }), (ctx, input) => listInOrder(ctx, input.collection)),
1696
1710
  getEntry: op(entryRef, (ctx, { collection, id }) => ctx.storage.getEntry(collection, id)),
1697
1711
  /**
1698
1712
  * Answers with the entry's new version rather than a bare acknowledgement, so
@@ -1751,7 +1765,7 @@ var operations = {
1751
1765
  await ctx.storage.discard();
1752
1766
  return ok;
1753
1767
  }),
1754
- listMedia: op(z.object({ library }), async (ctx, input) => ctx.media(input.library).listMedia()),
1768
+ listMedia: op(z.object({ library }), async (ctx, input) => (await ctx.media(input.library).listMedia()).toSorted((a, b) => a.path.localeCompare(b.path))),
1755
1769
  beginUpload: op(mediaFile.extend({
1756
1770
  size: z.number().int().nonnegative(),
1757
1771
  overwrite: z.boolean().default(false)
@@ -1,7 +1,7 @@
1
1
  import { c as StorageConfig, i as RepoMediaConfig, l as SupportedLocale, n as MediaConfig, o as S3EndpointMediaConfig, r as R2MediaConfig, s as S3MediaConfig, t as CmsConfig } from "./chunks/types-Dkx4Xovf.js";
2
- import { i as CollectionSort } from "./chunks/types-DwA-C6Br.js";
2
+ import { i as CollectionSort } from "./chunks/types-Jew_-Qpp.js";
3
3
  import { t as ContentI18n } from "./chunks/i18n-BPmx7ESy.js";
4
- import { a as ComponentDefinition, c as defineCollection, f as fileMarker, h as localizedMarker, l as defineComponent, p as libraryImage, r as CollectionOptions, s as SchemaHelpers, t as ChildrenConfig } from "./chunks/config-WQqG4mNH.js";
4
+ import { _ as localizedMarker, a as ComponentDefinition, c as SchemaHelpers, h as libraryImage, l as defineCollection, m as fileMarker, r as CollectionOptions, t as ChildrenConfig, u as defineComponent } from "./chunks/config-BsOYly9a.js";
5
5
  import { AstroIntegration } from "astro";
6
6
  export default function cms(config?: CmsConfig): AstroIntegration;
7
7
  export { type ChildrenConfig, type CmsConfig, type CollectionOptions, type CollectionSort, type ComponentDefinition, type ContentI18n, type MediaConfig, type R2MediaConfig, type RepoMediaConfig, type S3EndpointMediaConfig, type S3MediaConfig, type SchemaHelpers, type StorageConfig, type SupportedLocale, defineCollection, defineComponent, fileMarker as file, libraryImage, localizedMarker as localized };
@@ -1,13 +1,13 @@
1
1
  import { a as API_PATTERN, c as GITLAB_CLIENT_SECRET_ENV, d as SESSION_SECRET_ENV, l as LICENSES_PATH, n as API_BASE, r as API_CALLBACK, s as GITHUB_CLIENT_SECRET_ENV } from "./chunks/auth-DJP9ryVd.js";
2
2
  import { a as gatewayAddress, n as xmlList, o as gatewayEnv, r as parseRepo, t as parseXml } from "./chunks/xml-D8qPILJU.js";
3
3
  import { S as conformTrailingSlash, h as megabytes, i as S3_SESSION_TOKEN_ENV, l as isLibraryFile, m as mediaPath, n as S3_ACCESS_KEY_ID_ENV, r as S3_SECRET_ACCESS_KEY_ENV, u as libraryDirectories, v as repoOnlyRefusal, w as trimSlashes, y as s3BaseUrl } from "./chunks/media-BhqUVVYY.js";
4
- import { _ as getFileExtension, c as globEntry, n as DATA_FORMATS, s as findSingleton, u as globRoots, v as parseContent, y as parseMultiEntryFile } from "./chunks/types-DOR5XaJO.js";
4
+ import { _ as getFileExtension, c as globEntry, n as DATA_FORMATS, r as DEFAULT_SORT, s as findSingleton, u as globRoots, v as parseContent, y as parseMultiEntryFile } from "./chunks/types-DkkewFTT.js";
5
5
  import { n as componentEntries } from "./chunks/component-lookup-DAFg_Qg8.js";
6
- import { i as zodToFieldSchema, n as processUserConfig } from "./chunks/user-config-DoypbpQf.js";
6
+ import { i as zodToFieldSchema, t as processUserConfig } from "./chunks/user-config-CqNK-Ebs.js";
7
+ import { d as diagnostic, f as formatDiagnostic, l as objectShape } from "./chunks/field-schema-CfdN75jT.js";
7
8
  import { a as localizedMarker, n as fileMarker, r as libraryImage, s as repoImageMarker } from "./chunks/cms-markers-CUqrOnfA.js";
8
- import { a as libraryPathError, c as validateBody, f as errorMessage, i as collectionPatchSchema, n as collectionDataSchema, t as checkEntry, u as isAsset } from "./chunks/entry-checks-CKMag1G4.js";
9
+ import { a as libraryPathError, c as validateBody, f as errorMessage, i as collectionPatchSchema, n as collectionDataSchema, t as checkEntry, u as isAsset } from "./chunks/entry-checks-3SxhoHwH.js";
9
10
  import { n as isWithin } from "./chunks/paths-Dztx2eUw.js";
10
- import { d as diagnostic, f as formatDiagnostic } from "./chunks/field-schema-CfdN75jT.js";
11
11
  import { n as stripMediaPrefix } from "./chunks/paths-CEW9fvg8.js";
12
12
  import { defineCollection, defineComponent } from "./config.js";
13
13
  import { existsSync, globSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
@@ -179,7 +179,11 @@ export const components = ${JSON.stringify(options.components)};`,
179
179
  name: "astronaut-cms:optimize-deps",
180
180
  configEnvironment: (name) => ({ optimizeDeps: {
181
181
  exclude: ["astronaut-cms/licenses"],
182
- ...name !== "client" && { include: ["astronaut-cms/endpoint", "astronaut-cms/internal"] }
182
+ ...name !== "client" && { include: [
183
+ "astronaut-cms/assets",
184
+ "astronaut-cms/endpoint",
185
+ "astronaut-cms/internal"
186
+ ] }
183
187
  } })
184
188
  }
185
189
  ];
@@ -207,8 +211,8 @@ function generateContentModule({ collections, contentI18n }, rootDir, watch) {
207
211
  const sorts = {};
208
212
  const fileOrder = {};
209
213
  for (const { name, sort, loaderFileName } of Object.values(collections)) {
210
- if (sort !== "id") sorts[name] = sort;
211
- if (sort !== "file" || !loaderFileName) continue;
214
+ if (sort.by !== "id") sorts[name] = sort;
215
+ if (sort.by !== "file" || !loaderFileName) continue;
212
216
  const path = join(rootDir, loaderFileName);
213
217
  watch(path);
214
218
  fileOrder[name] = existsSync(path) ? [...parseMultiEntryFile(readFileSync(path, "utf-8"), getFileExtension(path)).entries.keys()] : [];
@@ -219,12 +223,10 @@ export const fileOrder = ${JSON.stringify(fileOrder)};
219
223
  export const contentI18n = ${JSON.stringify(contentI18n)};`;
220
224
  }
221
225
  function generateUserConfigModule(configPath, { contentI18n }) {
222
- if (!configPath) return "export const components = {};\nexport const collectionIcons = {};";
223
226
  return `\
224
- import * as config from ${JSON.stringify(configPath)};
225
- import { processCollectionIcons, processUserConfig } from "astronaut-cms/internal";
226
- export const components = processUserConfig(config.components, ${JSON.stringify(contentI18n)});
227
- export const collectionIcons = processCollectionIcons(config.collections);`;
227
+ ${configPath ? `import * as config from ${JSON.stringify(configPath)};` : "const config = {};"}
228
+ import { processUserModule } from "astronaut-cms/internal";
229
+ export const { components, collectionIcons, links } = processUserModule(config, ${JSON.stringify(contentI18n)});`;
228
230
  }
229
231
  // src/integration/dev-middleware.ts
230
232
  var SUPPRESS_WINDOW_MS = 5e3;
@@ -379,23 +381,34 @@ async function loadCollections(load, rootDir, contentConfigPath, i18n, warn) {
379
381
  schema: rawSchema == null ? null : zodToFieldSchema(rawSchema, i18n),
380
382
  ...source,
381
383
  loaderFileName: rootRelative(rootDir, loader?.__cmsFileName),
382
- sort: "id",
384
+ sort: DEFAULT_SORT,
383
385
  singleton: findSingleton(source, i18n)
384
386
  };
385
387
  }
386
388
  return manifest;
387
389
  }
390
+ var SORTABLE_TYPES = /* @__PURE__ */ new Set([
391
+ "string",
392
+ "number",
393
+ "boolean",
394
+ "date",
395
+ "enum",
396
+ "literal",
397
+ "reference"
398
+ ]);
388
399
  /**
389
400
  * The content config's collections with the options `cms.config` gives them.
390
- * An option naming no collection, or a file order for entries that are separate
391
- * files, is a mistake the site would otherwise never notice.
401
+ * An option naming no collection, a file order for entries that are separate
402
+ * files, or a field order by no comparable field, is a mistake the site would
403
+ * otherwise never notice.
392
404
  */
393
405
  function withOptions(manifest, options) {
394
406
  const resolved = { ...manifest };
395
407
  for (const [name, { sort, label, description }] of Object.entries(options)) {
396
408
  const collection = resolved[name];
397
409
  if (!collection) throw new Error(`cms.config collections: "${name}" is not a collection of the content config.`);
398
- if (sort === "file" && collection.loaderType !== "file") throw new Error(`cms.config collections: "${name}" cannot sort by "file", which needs a file() collection. The entries of a glob() collection are separate files.`);
410
+ if (sort?.by === "file" && collection.loaderType !== "file") throw new Error(`cms.config collections: "${name}" cannot sort by file, which needs a file() collection. The entries of a glob() collection are separate files.`);
411
+ if (sort?.by === "field" && !SORTABLE_TYPES.has(objectShape(collection.schema)?.[sort.field]?.type)) throw new Error(`cms.config collections: "${name}" cannot sort by "${sort.field}", which needs a top-level field of type ${[...SORTABLE_TYPES].join(", ")}.`);
399
412
  resolved[name] = {
400
413
  ...collection,
401
414
  sort: sort ?? collection.sort,
@@ -1,5 +1,23 @@
1
- import { m as DescribedComponent, t as AssertNever } from "./chunks/types-DwA-C6Br.js";
2
- import { _ as EditorExports, a as ComponentDefinition, g as referenceMarker, o as ComponentIcon, r as CollectionOptions, u as ImageResolver, v as JsxEditor } from "./chunks/config-WQqG4mNH.js";
1
+ /**
2
+ * Machine-only entry points, exported as the single `astronaut-cms/internal`
3
+ * scope. Not part of the public API: these are reached only by generated code
4
+ * and build-time aliasing.
5
+ *
6
+ * - `loader-stubs`: aliased in for `astro:content` / `astro/loaders` when
7
+ * the integration loads the user's content config in Node.
8
+ * - `editor-stubs`: aliased in for `astronaut-cms/editor` wherever the
9
+ * user's `cms.config.ts` loads outside the admin, where its editors never run.
10
+ * - `user-config`: the `cms.config.ts` normalizer, run in Node by the
11
+ * integration and in the admin by the generated
12
+ * `virtual:astronaut-cms/user-config` module.
13
+ * - `propsResolver` and `InferComponentProps`: what the generated component
14
+ * wrappers and their declarations read.
15
+ * - `http` and `auth`: the response hardening and the root element id the
16
+ * injected routes, the admin page and the admin share, reached from
17
+ * `admin.astro`, which can only import package entry points.
18
+ */
19
+ import { m as DescribedComponent, t as AssertNever } from "./chunks/types-Jew_-Qpp.js";
20
+ import { a as ComponentDefinition, b as JsxEditor, f as ImageResolver, o as ComponentIcon, r as CollectionOptions, s as LinkOptions, v as referenceMarker, y as EditorExports } from "./chunks/config-BsOYly9a.js";
3
21
  import { t as ContentI18n } from "./chunks/i18n-BPmx7ESy.js";
4
22
  import { n as HARDENING_HEADERS } from "./chunks/http-BnsNh57m.js";
5
23
  import { z, z as z$1 } from "zod";
@@ -30,14 +48,31 @@ export interface ClientComponentDef extends DescribedComponent {
30
48
  editor: JsxEditor | null;
31
49
  }
32
50
  export type ComponentManifest = Record<string, ClientComponentDef>;
51
+ /** The exports of `cms.config.ts`, each optional. */
52
+ export interface CmsConfigModule {
53
+ components?: Record<string, ComponentDefinition>;
54
+ collections?: Record<string, CollectionOptions>;
55
+ links?: LinkOptions[];
56
+ }
33
57
  /**
34
58
  * An MDX body refers to a component by its name alone, so one name may stand
35
59
  * for one definition only. A child set may reuse a definition under the same name.
36
60
  * `i18n` lays out the `localized()` props, see {@link zodToFieldSchema}.
37
61
  */
38
62
  export declare function processUserConfig(components: Record<string, ComponentDefinition> | undefined, i18n: ContentI18n | null): ComponentManifest;
39
- /** The collections' icons by name, the one option the manifest cannot carry, being live components. */
40
- export declare function processCollectionIcons(collections: Record<string, CollectionOptions> | undefined): Record<string, ComponentIcon>;
63
+ /** The admin's view of `cms.config.ts`, as `virtual:astronaut-cms/user-config` exports it. */
64
+ export interface UserModule {
65
+ components: ComponentManifest;
66
+ collectionIcons: Record<string, ComponentIcon>;
67
+ links: LinkOptions[];
68
+ }
69
+ /**
70
+ * Lowers `cms.config.ts` into its {@link UserModule}.
71
+ * The module is passed whole, so the bundler does not warn about the exports a site leaves out.
72
+ * The collections contribute their icons only, the one option the manifest
73
+ * cannot carry, being live components.
74
+ */
75
+ export declare function processUserModule({ components, collections, links }: CmsConfigModule, i18n: ContentI18n | null): UserModule;
41
76
  /**
42
77
  * Parses a component's attributes by its name, so every `.default()` and
43
78
  * transform applies, and keeps any attribute the schema does not declare, such
@@ -1,5 +1,5 @@
1
1
  import { o as referenceMarker } from "./chunks/cms-markers-CUqrOnfA.js";
2
- import { n as processUserConfig, r as propsResolver, t as processCollectionIcons } from "./chunks/user-config-DoypbpQf.js";
2
+ import { n as processUserModule, r as propsResolver, t as processUserConfig } from "./chunks/user-config-CqNK-Ebs.js";
3
3
  import { a as HARDENING_HEADERS } from "./chunks/component-lookup-DAFg_Qg8.js";
4
4
  import { t as ADMIN_ROOT_ID } from "./chunks/auth-DJP9ryVd.js";
5
5
  import { z } from "zod";
@@ -27,4 +27,4 @@ var adminOnly = () => {
27
27
  var NestedLexicalEditor = adminOnly;
28
28
  var useMdastNodeUpdater = adminOnly;
29
29
  var useLexicalNodeRemove = adminOnly;
30
- export { ADMIN_ROOT_ID, HARDENING_HEADERS, NestedLexicalEditor, defineCollection, file, glob, processCollectionIcons, processUserConfig, propsResolver, referenceMarker as reference, useLexicalNodeRemove, useMdastNodeUpdater, z };
30
+ export { ADMIN_ROOT_ID, HARDENING_HEADERS, NestedLexicalEditor, defineCollection, file, glob, processUserConfig, processUserModule, propsResolver, referenceMarker as reference, useLexicalNodeRemove, useMdastNodeUpdater, z };
@@ -1,4 +1,4 @@
1
- import { a as EntryContent, c as FileChange, d as SaveEntryRequest, f as TrashedFile, l as FileCollectionInfo, n as CollectionManifest, o as EntryFormat, p as ComponentSchemaMap, r as CollectionManifestEntry, s as EntryMeta, u as MediaFile } from "./chunks/types-DwA-C6Br.js";
1
+ import { a as EntryContent, c as FileChange, d as SaveEntryRequest, f as TrashedFile, l as FileCollectionInfo, n as CollectionManifest, o as EntryFormat, p as ComponentSchemaMap, r as CollectionManifestEntry, s as EntryMeta, u as MediaFile } from "./chunks/types-Jew_-Qpp.js";
2
2
  import { r as PartialContent, t as ByteRange } from "./chunks/http-BnsNh57m.js";
3
3
  import { a as ResolvedImageOptimization } from "./chunks/types-Dkx4Xovf.js";
4
4
  import "yaml";
@@ -1,5 +1,5 @@
1
- import { u as globRoots } from "./chunks/types-DOR5XaJO.js";
2
- import { d as getErrorCode, h as staleWrite, i as StorageBase, n as sha256, p as isNotFound } from "./chunks/digest-BYzWNJea.js";
1
+ import { u as globRoots } from "./chunks/types-DkkewFTT.js";
2
+ import { d as getErrorCode, h as staleWrite, i as StorageBase, n as sha256, p as isNotFound } from "./chunks/digest-tkKu_Wj5.js";
3
3
  import { n as isWithin, t as assertWithinBase } from "./chunks/paths-Dztx2eUw.js";
4
4
  import { c as partialContent } from "./chunks/component-lookup-DAFg_Qg8.js";
5
5
  import { u as libraryDirectories } from "./chunks/media-BhqUVVYY.js";
@@ -96,7 +96,7 @@ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
96
96
  FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
97
97
  OTHER DEALINGS IN THE FONT SOFTWARE.
98
98
 
99
- ## @mdxeditor/editor - 4.3.4 (MIT)
99
+ ## @mdxeditor/editor - 4.5.0 (MIT)
100
100
 
101
101
  MIT License
102
102
 
@@ -144,7 +144,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
144
144
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
145
145
  SOFTWARE.
146
146
 
147
- ## tailwindcss - 4.3.3 (MIT)
147
+ ## tailwindcss - 4.3.5 (MIT)
148
148
 
149
149
  MIT License
150
150