canopycms 0.4.0 → 0.6.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 (69) hide show
  1. package/CHANGELOG.md +78 -42
  2. package/dist/ai/generate.d.ts +3 -0
  3. package/dist/ai/generate.js +12 -29
  4. package/dist/ai/handler.js +1 -0
  5. package/dist/ai/types.d.ts +3 -9
  6. package/dist/api/reference-options.d.ts +2 -5
  7. package/dist/api/reference-options.js +21 -2
  8. package/dist/api/schema.d.ts +4 -4
  9. package/dist/build/generate-ai-content.js +1 -0
  10. package/dist/cli/cli.js +136 -39
  11. package/dist/cli/generate-ai-content.js +75 -32
  12. package/dist/cli/init.js +34 -5
  13. package/dist/cli/template-files/cms-stack.ts.template +3 -0
  14. package/dist/cli/templates.js +5 -1
  15. package/dist/config/index.d.ts +1 -1
  16. package/dist/config/schemas/config.d.ts +74 -0
  17. package/dist/config/schemas/config.js +21 -0
  18. package/dist/config/schemas/field.d.ts +30 -0
  19. package/dist/config/schemas/field.js +22 -0
  20. package/dist/config/types.d.ts +39 -0
  21. package/dist/config/validation.d.ts +6 -0
  22. package/dist/config/validation.js +33 -0
  23. package/dist/editor/FormRenderer.js +15 -13
  24. package/dist/editor/copy.d.ts +5 -0
  25. package/dist/editor/copy.js +5 -0
  26. package/dist/editor/fields/BlockField.d.ts +2 -0
  27. package/dist/editor/fields/BlockField.js +15 -8
  28. package/dist/editor/fields/ItemList.d.ts +21 -3
  29. package/dist/editor/fields/ItemList.js +16 -8
  30. package/dist/editor/fields/NumberListField.d.ts +2 -0
  31. package/dist/editor/fields/NumberListField.js +6 -2
  32. package/dist/editor/fields/ObjectListField.js +9 -3
  33. package/dist/editor/fields/ReferenceField.d.ts +6 -7
  34. package/dist/editor/fields/ReferenceField.js +28 -122
  35. package/dist/editor/fields/ReferenceListField.d.ts +41 -0
  36. package/dist/editor/fields/ReferenceListField.js +139 -0
  37. package/dist/editor/fields/SelectField.d.ts +2 -0
  38. package/dist/editor/fields/SelectField.js +6 -3
  39. package/dist/editor/fields/StringListField.d.ts +10 -1
  40. package/dist/editor/fields/StringListField.js +18 -8
  41. package/dist/editor/fields/item-expansion.d.ts +7 -3
  42. package/dist/editor/fields/item-expansion.js +6 -4
  43. package/dist/editor/fields/list-item-keys.d.ts +6 -5
  44. package/dist/editor/fields/list-item-keys.js +45 -13
  45. package/dist/editor/fields/reference-noindex.d.ts +37 -0
  46. package/dist/editor/fields/reference-noindex.js +48 -0
  47. package/dist/editor/fields/use-reference-options.d.ts +36 -0
  48. package/dist/editor/fields/use-reference-options.js +121 -0
  49. package/dist/editor/form-outline.d.ts +2 -2
  50. package/dist/editor/form-outline.js +4 -2
  51. package/dist/editor/theme.js +5 -0
  52. package/dist/entry-schema-registry.d.ts +1 -1
  53. package/dist/entry-schema-registry.js +3 -2
  54. package/dist/entry-schema.d.ts +5 -3
  55. package/dist/entry-schema.js +2 -1
  56. package/dist/reference-resolver.d.ts +18 -1
  57. package/dist/reference-resolver.js +175 -8
  58. package/dist/schema/schema-store.d.ts +2 -2
  59. package/dist/static/index.d.ts +8 -4
  60. package/dist/static/index.js +38 -13
  61. package/dist/static/seo.d.ts +7 -5
  62. package/dist/static/seo.js +13 -6
  63. package/dist/validation/entry-validator.d.ts +5 -0
  64. package/dist/validation/entry-validator.js +12 -0
  65. package/dist/version.d.ts +1 -1
  66. package/dist/version.js +1 -1
  67. package/dist/worker/github-gateway-http.js +2 -2
  68. package/dist/worker/github-gateway.js +2 -2
  69. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -5,9 +5,9 @@ packages release together, at one version.
5
5
 
6
6
  ## This build
7
7
 
8
- Version `0.4.0`, built from [`184d5c6`](https://github.com/safeinsights/canopycms/tree/184d5c62b8158d1fdcfbd85430f17f90aceec00c).
8
+ Version `0.6.0`, built from [`83be4af`](https://github.com/safeinsights/canopycms/tree/83be4af22312c30e8b89a5f14a7eb51d2af2944e).
9
9
 
10
- Its entries are [0.4.0](#040), under **Released**.
10
+ Its entries are [0.6.0](#060), under **Released**.
11
11
 
12
12
  If you upgraded from a build on another branch, compare the `<!-- changeset: … -->` slugs in your previous build's `CHANGELOG.md` (`npm pack canopycms@<old>` fetches it) with this one's: entries whose slug your old file lacks are new to you.
13
13
 
@@ -24,7 +24,7 @@ Each entry has up to three parts:
24
24
  `node_modules/canopycms/CHANGELOG.md`, assembled for that build: its **This build** section lists
25
25
  what is new since the previous int on the same branch, or on a stable release links its entries, and its links point at the commit the build
26
26
  came from. The copy in the repository holds released history and the entries from before changesets;
27
- every entry written since is a file in [`.changeset/`](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/.changeset/README.md) until a stable release
27
+ every entry written since is a file in [`.changeset/`](https://github.com/safeinsights/canopycms/blob/83be4af22312c30e8b89a5f14a7eb51d2af2944e/.changeset/README.md) until a stable release
28
28
  moves it here.
29
29
 
30
30
  **Find your starting point.** From a stable pin, start at the first version under **Released**
@@ -62,6 +62,42 @@ entries under **Released**.
62
62
 
63
63
  ## Released
64
64
 
65
+ ### 0.6.0
66
+
67
+ #### Clerk organizations-as-groups is a deployment setting, and survives a Clerk instance without Organizations — **behaviour change**
68
+
69
+ <!-- changeset: clerk-orgs-as-groups -->
70
+
71
+ _First in 0.6.0._
72
+
73
+ **What changed.** `CanopyCmsService` takes `clerkOrganizationsAsGroups` (default `true`, unchanged), which the worker honours; in a deployment it, not the plugin's `useOrganizationsAsGroups`, decides the groups. When Clerk refuses the organization list with a 403 (Organizations disabled), the refresh now writes users with no groups and logs a warning, instead of failing whole; any other failure still keeps the last snapshot. Memberships are fetched instance-wide rather than per user. The scaffolds write `false` explicitly: `useOrganizationsAsGroups` in `canopycms init`'s `canopy.ts`, and `clerkOrganizationsAsGroups` in `canopycms init-deploy aws`'s CDK stack.
74
+
75
+ **To adopt.** On a Clerk instance without Organizations, set `clerkOrganizationsAsGroups: false` on `CanopyCmsService` and `useOrganizationsAsGroups: false` in `createClerkAuthPlugin`. See [Deploying to AWS](https://github.com/safeinsights/canopycms/blob/83be4af22312c30e8b89a5f14a7eb51d2af2944e/docs/deploying-to-aws.md).
76
+
77
+ ### 0.5.0
78
+
79
+ #### Reorderable list references, and `maxItems` on list fields — **behaviour change: a build fails on a list over its cap**
80
+
81
+ <!-- changeset: reference-list-reorder-and-max-items -->
82
+
83
+ _First in 0.5.0._
84
+
85
+ **What changed.** A `type: 'reference', list: true` field now edits as rows in stored order, like an `object` list: drag a row or use its "…" menu to move or remove it, open a row to swap its entry in place, and pick from Add under the rows to append. Neither control offers an entry the list already holds. Any `list: true` field, and any `block` field, takes `maxItems`. The editor stops adding at the cap and says why, a save over it is refused, and a production build fails on an entry over it, naming the entry, field, count and cap. Adding `maxItems` to a list that already holds more therefore fails the build until an editor removes the extra items. `maxItems` on a field that holds no items is refused when the entry schema registry is created.
86
+
87
+ **To adopt.** Set `maxItems: 3` on the list field in its entry schema. See [Field Types](https://github.com/safeinsights/canopycms/blob/83be4af22312c30e8b89a5f14a7eb51d2af2944e/README.md#field-types).
88
+
89
+ #### SEO field location moves into config; reference pickers mark hidden entries and take a sort order — **breaking: `createNextCanopyContext({ seo })` and `AIContentConfig.seo` are removed**
90
+
91
+ <!-- changeset: seo-config-hidden-picks-option-sort -->
92
+
93
+ _First in 0.5.0._
94
+
95
+ **What changed.** `defineCanopyConfig` takes `seo: { group?, fields? }`, the one place every surface reads an entry's `noindex` flag: the sitemap and `entryToMetadata` that `createNextCanopyContext` returns, AI content and the editor's reference picker. A per-call `seo`/`group`/`fields` still overrides it. The free `generateContentSitemap` takes `seo` as an argument and refuses to run without it when the config sets one; `createNextCanopyContext` and the AI content config refuse a leftover `seo`. A reference picker now badges an entry hidden from search as "Hidden from search", and picking one adds a note naming the setting on that entry's form, since a page listing only indexed entries won't show it. A reference field takes `optionSort`: `'label'` (the default), `'collection'`, or `{ field, direction }`. Point `field` at an ISO date, since strings compare as text.
96
+
97
+ **To adopt.** Move `seo` from `createNextCanopyContext({ seo })` and from `defineAIContentConfig({ seo })` into `defineCanopyConfig({ seo })`. See [Sitemap and SEO Metadata](https://github.com/safeinsights/canopycms/blob/83be4af22312c30e8b89a5f14a7eb51d2af2944e/README.md#sitemap-and-seo-metadata) and [How References Work in the Editor](https://github.com/safeinsights/canopycms/blob/83be4af22312c30e8b89a5f14a7eb51d2af2944e/README.md#how-references-work-in-the-editor).
98
+
99
+ **Now deletable.** A shared `seo` constant passed separately to the Next context and the AI content config.
100
+
65
101
  ### 0.4.0
66
102
 
67
103
  #### Link-only references to json/yaml entries leave out the body — **behaviour change (resolved data and types)**
@@ -86,7 +122,7 @@ resolved without it.
86
122
  **To adopt.** Where a reference renders its target's prose, set `includeBody: true` on that
87
123
  reference field. Code that reads the body from a link-only reference's resolved type now sees
88
124
  `string | undefined`; either set `includeBody: true` or handle the missing value. See
89
- [Resolving References in a Listing](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/README.md#resolving-references-in-a-listing).
125
+ [Resolving References in a Listing](https://github.com/safeinsights/canopycms/blob/83be4af22312c30e8b89a5f14a7eb51d2af2944e/README.md#resolving-references-in-a-listing).
90
126
 
91
127
  ### 0.3.3
92
128
 
@@ -497,7 +533,7 @@ URL.
497
533
  2. For a branch preview: wrap views with `withCanopyPreview` in a `'use client'` module, add
498
534
  `app/preview/[[...path]]/page.server.tsx`, set `editor.previewPrefix: '/preview'`, and serve that
499
535
  route with `frame-ancestors 'self'`, not `X-Frame-Options: DENY` (see
500
- [Live Preview](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/README.md#live-preview)).
536
+ [Live Preview](https://github.com/safeinsights/canopycms/blob/83be4af22312c30e8b89a5f14a7eb51d2af2944e/README.md#live-preview)).
501
537
  3. A test reading view content from the route's server HTML must load the page in a browser.
502
538
  Server output rendered during a preview request carries the signed-in asset prefix; keep it out
503
539
  of cross-request caches (`unstable_cache`, module memos).
@@ -512,7 +548,7 @@ kept site styles ahead of Mantine's in the preview.
512
548
  server components. A string path marks the form's spelling (`'a.0.b'` marks `a[0].b`), and an empty
513
549
  path marks nothing. The editor counts and logs marks naming no field. `createEntrySchemaRegistry`
514
550
  refuses a field name that is empty, all digits or contains `.`, `[` or `]`. See
515
- [Live Preview](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/README.md#live-preview).
551
+ [Live Preview](https://github.com/safeinsights/canopycms/blob/83be4af22312c30e8b89a5f14a7eb51d2af2944e/README.md#live-preview).
516
552
 
517
553
  **To adopt.** Fix each path that stops compiling; the error lists valid ones. Rewrite computed paths
518
554
  as literal segments, or type that component's prop as plain `FieldProps`. Pass `fieldProps` as
@@ -594,7 +630,7 @@ or a failed render) renders as its plain text, with no URL; any other form of th
594
630
  fields are nested or renamed, pass the AI config's `seo` the same object you pass
595
631
  `createNextCanopyContext({ seo })`, so the sitemap and AI content read the flag from the same
596
632
  place. A field that links to a hidden section by plain URL needs a field transform; the README
597
- shows [the recipe](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/README.md#ai-content-configuration).
633
+ shows [the recipe](https://github.com/safeinsights/canopycms/blob/83be4af22312c30e8b89a5f14a7eb51d2af2944e/README.md#ai-content-configuration).
598
634
 
599
635
  **Now deletable.** An `exclude.where` that re-read the `noindex` flag by hand.
600
636
 
@@ -616,7 +652,7 @@ A `markdown` field with `renderAs: 'mdx'` is checked as MDX, and `mdxAllow` narr
616
652
  field or site-wide. New: field options `renderAs`, `mdxAllow`; config key `mdxAllow`; type
617
653
  `MdxAllowlist`. (int.110) A component prop allowance can be `'string'` (or
618
654
  `{ type: 'string', maxLength }`): a quoted value only, never bare or `{…}`. See
619
- [MDX content cannot run code](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/README.md#mdx-content-cannot-run-code).
655
+ [MDX content cannot run code](https://github.com/safeinsights/canopycms/blob/83be4af22312c30e8b89a5f14a7eb51d2af2944e/README.md#mdx-content-cannot-run-code).
620
656
 
621
657
  **To adopt.** Set `renderAs: 'mdx'` on each `markdown` field your site compiles as MDX, and
622
658
  `mdxAllow` to what your renderer takes. Set `executable: true` only on a field whose editors you
@@ -753,7 +789,7 @@ a format check.
753
789
 
754
790
  - (int.93) Submit commits gain an `Edited-by: Name (id)` trailer; PR bodies gain a section that
755
791
  re-submits replace, keeping human text. Options: `gitEditedByTrailers`, `gitCoAuthoredByTrailers`
756
- ([reference](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/README.md#definecanopyconfig-options)).
792
+ ([reference](https://github.com/safeinsights/canopycms/blob/83be4af22312c30e8b89a5f14a7eb51d2af2944e/README.md#definecanopyconfig-options)).
757
793
  - (int.110) Submit-commit trailers name every user who saved since the last submit commit, and
758
794
  the PR-body section every user who edited the branch, not only the submitter; settings commits
759
795
  (permissions, groups) carry the acting user's trailer.
@@ -777,7 +813,7 @@ saves only push the branch, and no failing PR task lands in System health.
777
813
  that entry type goes unavailable: the editor says so, and its entries answer 503 with
778
814
  `code: 'SCHEMA_UNAVAILABLE'`. Builds, static deploys and `generate-ai-content` still fail. The
779
815
  worker holds the base branch for up to 30 minutes while that lasts; see
780
- [New schemas wait for the editor deploy](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/docs/deploying-to-aws.md#new-schemas-wait-for-the-editor-deploy).
816
+ [New schemas wait for the editor deploy](https://github.com/safeinsights/canopycms/blob/83be4af22312c30e8b89a5f14a7eb51d2af2944e/docs/deploying-to-aws.md#new-schemas-wait-for-the-editor-deploy).
781
817
  Public types gain optional `unavailable` on `EntryTypeConfig` and `FlatSchemaItem`, optional
782
818
  `ApiResponse.code`, and a required `SchemaResolutionResult.issues`.
783
819
 
@@ -815,7 +851,7 @@ hang until the drain heartbeat lets termination continue. Its in-flight task is
815
851
  new stack needs no steps.
816
852
 
817
853
  **What changed.** (int.109) Detailed in
818
- [The worker instance](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/docs/deploying-to-aws.md#the-worker-instance): IMDSv2 with a hop limit of 1; the
854
+ [The worker instance](https://github.com/safeinsights/canopycms/blob/83be4af22312c30e8b89a5f14a7eb51d2af2944e/docs/deploying-to-aws.md#the-worker-instance): IMDSv2 with a hop limit of 1; the
819
855
  bundle is one file whose sha256 user data checks, readable as that one object; a file-system policy
820
856
  refusing clients without TLS or IAM, replacing the worker's
821
857
  `AmazonElasticFileSystemClientReadWriteAccess`; an encrypted gp3 root volume; a boot-time upgrade to
@@ -869,10 +905,10 @@ failure and exits non-zero on `selfStopped`, with a code outside `RestartPrevent
869
905
  with its hash, as `worker/dist/index.js` and `index.js.sha256`. The default, `'asset'`, is
870
906
  unchanged.
871
907
  - `CanopyCmsService` alarms when the worker logs no git sync for 30 minutes. See
872
- [Worker-down alarm](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/docs/deploying-to-aws.md#worker-down-alarm).
908
+ [Worker-down alarm](https://github.com/safeinsights/canopycms/blob/83be4af22312c30e8b89a5f14a7eb51d2af2944e/docs/deploying-to-aws.md#worker-down-alarm).
873
909
 
874
910
  **To adopt.** Optional. For parameter-only change sets, see
875
- [Rolling the worker from CI](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/docs/deploying-to-aws.md#rolling-the-worker-from-ci). For the alarm, pass
911
+ [Rolling the worker from CI](https://github.com/safeinsights/canopycms/blob/83be4af22312c30e8b89a5f14a7eb51d2af2944e/docs/deploying-to-aws.md#rolling-the-worker-from-ci). For the alarm, pass
876
912
  `alarmTopic`.
877
913
 
878
914
  **Now deletable.** A manual `cdk deploy` after each canopycms bump whose only purpose is moving the
@@ -883,7 +919,7 @@ worker, and a hand-built alarm on the worker log group.
883
919
  **What changed.** (int.112) The boot's `dnf upgrade` could be OOM-killed on every retry. A 1 GiB
884
920
  swap file now goes on first; an upgrade that still fails starts the worker unpatched and notifies
885
921
  `alarmTopic` if set; a retried step names itself when it gives up. See
886
- [The worker instance](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/docs/deploying-to-aws.md#the-worker-instance).
922
+ [The worker instance](https://github.com/safeinsights/canopycms/blob/83be4af22312c30e8b89a5f14a7eb51d2af2944e/docs/deploying-to-aws.md#the-worker-instance).
887
923
 
888
924
  **To adopt.** Deploy, which replaces the worker instance. The bundle needs none of this, so it is
889
925
  not Template first and the worker contract stays at 1.
@@ -949,7 +985,7 @@ and operations may reuse GitHub fetches under 30 seconds old.
949
985
 
950
986
  **To adopt.** Nothing. Seeding `remote.git` stages a copy of the repository beside the gateway's
951
987
  mirror, so the root volume needs room for two
952
- ([details](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/docs/deploying-to-aws.md#the-worker-instance)).
988
+ ([details](https://github.com/safeinsights/canopycms/blob/83be4af22312c30e8b89a5f14a7eb51d2af2944e/docs/deploying-to-aws.md#the-worker-instance)).
953
989
 
954
990
  #### The worker follows a rebased or deleted GitHub branch
955
991
 
@@ -971,7 +1007,7 @@ changes the template too (the fallback bundle's key and hash), so only the contr
971
1007
  bundle-only roll is safe.
972
1008
 
973
1009
  **To adopt.** Parameter mode: gate bundle-only rolls on the contract
974
- ([recipe](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/docs/deploying-to-aws.md#rolling-the-worker-from-ci)). The gate refuses a stack without the
1010
+ ([recipe](https://github.com/safeinsights/canopycms/blob/83be4af22312c30e8b89a5f14a7eb51d2af2944e/docs/deploying-to-aws.md#rolling-the-worker-from-ci)). The gate refuses a stack without the
975
1011
  `WorkerContract` output, so `cdk deploy` the template once, which adds it. A hand-installed unit
976
1012
  copies its `Environment=CANOPYCMS_WORKER_CONTRACT=` line from `worker/canopy-worker.service`.
977
1013
 
@@ -988,8 +1024,8 @@ units from the bundle's contract: 2 gets the split, an older bundle the single u
988
1024
  template, then roll the bundle; on an older template it stops with `template too old for this
989
1025
  bundle`. Inspect EFS only through `sudo /opt/canopy-worker/canopy-inspect <command>`, never from a root shell. A hand install
990
1026
  takes `worker/`'s three units and `gateway.env.example`
991
- ([steps](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/docs/deploying-to-aws.md#installing-the-units-by-hand)). After the first deploy, run the
992
- [checklist](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/docs/deploying-to-aws.md#first-deploy-checklist).
1027
+ ([steps](https://github.com/safeinsights/canopycms/blob/83be4af22312c30e8b89a5f14a7eb51d2af2944e/docs/deploying-to-aws.md#installing-the-units-by-hand)). After the first deploy, run the
1028
+ [checklist](https://github.com/safeinsights/canopycms/blob/83be4af22312c30e8b89a5f14a7eb51d2af2944e/docs/deploying-to-aws.md#first-deploy-checklist).
993
1029
 
994
1030
  #### `canopycms-cdk`: `CanopyCmsService.attachTo`, and editor response headers — **behaviour change if you frame the CMS**
995
1031
 
@@ -1000,7 +1036,7 @@ response headers policy. `CanopyCmsDistribution` sends the same headers: `frame-
1000
1036
  `X-Frame-Options: SAMEORIGIN`, `nosniff`, HSTS and `X-Robots-Tag: noindex`. Unless your app sends
1001
1037
  its own framing headers, no other origin can frame the editor or any page the CMS domain serves. Every such page is
1002
1038
  marked `noindex`. The editor's default preview is same-origin and unaffected. See
1003
- [Serving the editor from a distribution you already own](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/docs/deploying-to-aws.md#serving-the-editor-from-a-distribution-you-already-own).
1039
+ [Serving the editor from a distribution you already own](https://github.com/safeinsights/canopycms/blob/83be4af22312c30e8b89a5f14a7eb51d2af2944e/docs/deploying-to-aws.md#serving-the-editor-from-a-distribution-you-already-own).
1004
1040
 
1005
1041
  **To adopt.** If you wired the Function URL into your own distribution by hand, delete those
1006
1042
  behaviors and call `attachTo`, passing your CMS build's `assetPrefix` as `editorAssetPrefix` and a
@@ -1176,7 +1212,7 @@ one the exclusions leave out. A throw or any other return is logged and treated
1176
1212
  **To adopt.** If your site's routes, sitemap or bylines decide that some entries have no page,
1177
1213
  apply the same rule here, for example `referenceLink: (target, { body }) =>
1178
1214
  !body?.trim() ? false : undefined` in `defineAIContentConfig` from `canopycms/ai`. See
1179
- [AI Content Configuration](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/README.md#ai-content-configuration).
1215
+ [AI Content Configuration](https://github.com/safeinsights/canopycms/blob/83be4af22312c30e8b89a5f14a7eb51d2af2944e/README.md#ai-content-configuration).
1180
1216
 
1181
1217
  **Now deletable.** A `fieldTransforms` entry that re-renders a reference field only to drop or
1182
1218
  change its link.
@@ -1251,7 +1287,7 @@ _First in int.115._
1251
1287
  entry the base branch also changed, the "updated on the base branch" notice and the branch's
1252
1288
  conflict count now stay until the branch merges, so a reviewer still sees which entries replaced a
1253
1289
  base change. They used to clear on the next sync, about five minutes later. README's new [Drafts
1254
- and Unpublishing](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/README.md#drafts-and-unpublishing) section covers long-lived branches and
1290
+ and Unpublishing](https://github.com/safeinsights/canopycms/blob/83be4af22312c30e8b89a5f14a7eb51d2af2944e/README.md#drafts-and-unpublishing) section covers long-lived branches and
1255
1291
  unpublishing.
1256
1292
 
1257
1293
  #### The editor calls the content drawer "All content"
@@ -1563,7 +1599,7 @@ editor carries an unsaved draft of a stamped entry onto its stamped version.
1563
1599
  The flag is refused off a top-level `datetime`, on `list: true`, and with `required: true`.
1564
1600
 
1565
1601
  **To adopt.** Add `stampOnPublish: true` to the date field your site sorts or labels by, such as
1566
- `{ name: 'publishedAt', type: 'datetime', stampOnPublish: true }`. See [Stamping a publication date](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/README.md#stamping-a-publication-date).
1602
+ `{ name: 'publishedAt', type: 'datetime', stampOnPublish: true }`. See [Stamping a publication date](https://github.com/safeinsights/canopycms/blob/83be4af22312c30e8b89a5f14a7eb51d2af2944e/README.md#stamping-a-publication-date).
1567
1603
 
1568
1604
  **Now deletable.** A build step or hook that writes a missing publication date into new entries.
1569
1605
 
@@ -1610,7 +1646,7 @@ preview/form divider is now keyboard-resizable within the same 15–85% the spli
1610
1646
  stored at, and `react-split-pane` is no longer a dependency.
1611
1647
  `EditorPanes`, `EditorPanesProps`, the `PaneLayout` type and the `SPLIT_PERCENT_*` and `DEFAULT_*_SPLIT_PERCENT` constants are
1612
1648
  no longer exported from `canopycms/client`. See
1613
- [Your root layout](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/README.md#editor-customization).
1649
+ [Your root layout](https://github.com/safeinsights/canopycms/blob/83be4af22312c30e8b89a5f14a7eb51d2af2944e/README.md#editor-customization).
1614
1650
 
1615
1651
  **To adopt.** Nothing, unless you import `EditorPanes` or those constants: render `CanopyEditor`
1616
1652
  instead, which lays out its own panes. Hiding your site chrome on the editor route is now
@@ -1721,7 +1757,7 @@ never ended. `canopycms-auth-clerk` skips it while the editor is mounted, and ex
1721
1757
  **To adopt.** Nothing for the editor, if your edit page uses `useClerkAuthConfig()` or
1722
1758
  `ClerkSignIn`. If your CMS build renders `<SignIn>`, `UserButton` or `OrganizationSwitcher` on your
1723
1759
  own pages, mount the hook as in
1724
- [Clerk components on your own pages](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/packages/canopycms-auth-clerk/README.md#clerk-components-on-your-own-pages).
1760
+ [Clerk components on your own pages](https://github.com/safeinsights/canopycms/blob/83be4af22312c30e8b89a5f14a7eb51d2af2944e/packages/canopycms-auth-clerk/README.md#clerk-components-on-your-own-pages).
1725
1761
  Your own Server Actions in the CMS build still 403 behind OAC.
1726
1762
 
1727
1763
  **Now deletable.** Any local patch of `window.__internal_onBeforeSetActive` (or 6.x's
@@ -1762,12 +1798,12 @@ fast naming the ARN, the field and the keys present, never a value.
1762
1798
  **To adopt.** Nothing, unless one of those secrets holds a JSON document: then set the matching
1763
1799
  prop. The scaffolded stack fills them from the repository _variables_
1764
1800
  `CANOPY_GITHUB_TOKEN_SECRET_JSON_FIELD` and `CLERK_SECRET_KEY_SECRET_JSON_FIELD`
1765
- ([why the prefix](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/docs/deploying-to-aws.md#repository-secrets-and-variables)); a stack scaffolded earlier
1801
+ ([why the prefix](https://github.com/safeinsights/canopycms/blob/83be4af22312c30e8b89a5f14a7eb51d2af2944e/docs/deploying-to-aws.md#repository-secrets-and-variables)); a stack scaffolded earlier
1766
1802
  adds the props to `infrastructure/bin/app.ts` and `infrastructure/lib/cms-stack.ts` and the two `env`
1767
1803
  lines to `.github/workflows/deploy-cms.yml`, or re-runs the generator and diffs. `cdk synth` refuses a `…JsonField` prop without its `…SecretArn`, and an ARN carrying the ECS `:KEY::` suffix
1768
1804
  (also in `secretsArns`). Don't use CDK's `secretValueFromJson`: it resolves the plaintext into the deployed
1769
1805
  resource's configuration, readable by anyone who can describe it. Only `CLERK_SECRET_KEY` goes through Secrets Manager; `CLERK_JWT_KEY` and the publishable
1770
- key are public material ([Security Model](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/docs/deploying-to-aws.md#security-model)).
1806
+ key are public material ([Security Model](https://github.com/safeinsights/canopycms/blob/83be4af22312c30e8b89a5f14a7eb51d2af2944e/docs/deploying-to-aws.md#security-model)).
1771
1807
 
1772
1808
  **Now deletable.** A wrapper that fetches the secret, parses it and re-exports one field into the
1773
1809
  worker's environment, such as a `jq` step in user data or a wrapper entrypoint around
@@ -1779,7 +1815,7 @@ worker's environment, such as a `jq` step in user data or a wrapper entrypoint a
1779
1815
  `githubToken` is not deprecated and stays the documented default; `canopycms` neither depends on
1780
1816
  nor imports `@octokit/auth-app`. Register one App per site, not one shared across repositories:
1781
1817
  anyone holding an App's key can mint a token for any of its installations
1782
- ([why](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/ARCHITECTURE.md#why-one-github-app-per-site-not-one-shared-across-an-organisation)).
1818
+ ([why](https://github.com/safeinsights/canopycms/blob/83be4af22312c30e8b89a5f14a7eb51d2af2944e/ARCHITECTURE.md#why-one-github-app-per-site-not-one-shared-across-an-organisation)).
1783
1819
 
1784
1820
  **To adopt with `canopycms-cdk`** (existing stacks need no edit). `CanopyCmsServiceProps` takes
1785
1821
  `githubAppId`, `githubAppInstallationId`, `githubAppPrivateKeySecretArn` and
@@ -1792,7 +1828,7 @@ anyone holding an App's key can mint a token for any of its installations
1792
1828
  `verify` checks an existing installation's permissions: run it, since an App missing a
1793
1829
  permission only shows up later, as `sync-failed`. `create` needs an interactive terminal and
1794
1830
  never edits an existing JSON secret (create one and point the JSON-field prop at it)
1795
- ([details](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/docs/deploying-to-aws.md#register-it-with-canopycms-init-github-app)).
1831
+ ([details](https://github.com/safeinsights/canopycms/blob/83be4af22312c30e8b89a5f14a7eb51d2af2944e/docs/deploying-to-aws.md#register-it-with-canopycms-init-github-app)).
1796
1832
  2. Set the three props and **remove `githubTokenSecretArn`** (with its JSON field). A partial set
1797
1833
  of the three is refused at synth, and so is an App alongside a token.
1798
1834
  3. In the generated workflow, store them as `CANOPY_GITHUB_APP_ID`,
@@ -1803,7 +1839,7 @@ anyone holding an App's key can mint a token for any of its installations
1803
1839
 
1804
1840
  The private key is ARN-only; passing the key itself is refused at synth. Its ARN joins the worker's
1805
1841
  IAM policy automatically, so you need not add it to `secretsArns`. See
1806
- [Authenticating as a GitHub App](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/docs/deploying-to-aws.md#authenticating-as-a-github-app).
1842
+ [Authenticating as a GitHub App](https://github.com/safeinsights/canopycms/blob/83be4af22312c30e8b89a5f14a7eb51d2af2944e/docs/deploying-to-aws.md#authenticating-as-a-github-app).
1807
1843
 
1808
1844
  ```bash
1809
1845
  canopycms init-github-app create -- \
@@ -1851,7 +1887,7 @@ downloads the `.pem` from the App's settings page.
1851
1887
 
1852
1888
  **What changed.** The worker re-reads a Secrets Manager secret (the GitHub token or the Clerk secret
1853
1889
  key) when the operation using it fails. Timings, costs and the store-before-revoke order are in
1854
- [Rotating a secret](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/docs/deploying-to-aws.md#rotating-a-secret).
1890
+ [Rotating a secret](https://github.com/safeinsights/canopycms/blob/83be4af22312c30e8b89a5f14a7eb51d2af2944e/docs/deploying-to-aws.md#rotating-a-secret).
1855
1891
 
1856
1892
  **To adopt.** Nothing for credentials from `*_SECRET_ARN`, which is every scaffolded deployment. A
1857
1893
  GitHub App private key is still read only at boot: store the new key, replace the instance, and
@@ -1905,12 +1941,12 @@ also check the bucket policy for its grant.
1905
1941
  5. `withCanopy()` adds sharp's libvips to Next's file tracing (not for a static export) and, on
1906
1942
  Next 16 and later, sets `turbopack: {}` when your config has neither `turbopack` nor your own
1907
1943
  `webpack` and it can read your Next version. A webpack build still fails its image transforms
1908
- ([Dual Build Support](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/docs/deploying-to-aws.md#dual-build-support)).
1944
+ ([Dual Build Support](https://github.com/safeinsights/canopycms/blob/83be4af22312c30e8b89a5f14a7eb51d2af2944e/docs/deploying-to-aws.md#dual-build-support)).
1909
1945
 
1910
1946
  **Breaking:** a stack setting `platform` on `fromImageAsset` without `architecture` gets an arm64
1911
1947
  function while `platform` still decides the image, so `Platform.LINUX_AMD64` builds an image the
1912
1948
  function cannot run. A stack setting neither moves to arm64 with a matching image, built under QEMU
1913
- on an x86 host ([Where the image is built](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/docs/deploying-to-aws.md#where-the-image-is-built)).
1949
+ on an x86 host ([Where the image is built](https://github.com/safeinsights/canopycms/blob/83be4af22312c30e8b89a5f14a7eb51d2af2944e/docs/deploying-to-aws.md#where-the-image-is-built)).
1914
1950
 
1915
1951
  **To adopt.**
1916
1952
 
@@ -1939,7 +1975,7 @@ reason; `platform` on `fromImageAsset`; and, with `withCanopy()`, a hand-written
1939
1975
 
1940
1976
  **What changed.** `media.uploadUrl` (s3 adapter; an absolute http(s) URL or a site-relative path)
1941
1977
  replaces the `url` that `beginUpload()` returns, leaving the presign's `fields` untouched, so
1942
- uploads can be same-origin. See [Media Configuration](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/README.md#media-configuration) for the
1978
+ uploads can be same-origin. See [Media Configuration](https://github.com/safeinsights/canopycms/blob/83be4af22312c30e8b89a5f14a7eb51d2af2944e/README.md#media-configuration) for the
1943
1979
  CloudFront behavior it expects.
1944
1980
 
1945
1981
  **To adopt.** Optional. Set it from an environment variable: a site-relative value works only where
@@ -1964,7 +2000,7 @@ needs `lazyPublicTransforms: true`) let you pass a deterministically named role,
1964
2000
  bucket's stack computes `arn:aws:iam::<account>:role/<name>` from literals instead of a
1965
2001
  `Fn::GetStackOutput` reference only the CDK CLI resolves. The constructs re-attach
1966
2002
  `AWSLambdaBasicExecutionRole` (and the VPC policy) that `lambda.Function` drops from a role you
1967
- pass. See [Cross-account asset bucket](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/docs/deploying-to-aws.md#cross-account-asset-bucket).
2003
+ pass. See [Cross-account asset bucket](https://github.com/safeinsights/canopycms/blob/83be4af22312c30e8b89a5f14a7eb51d2af2944e/docs/deploying-to-aws.md#cross-account-asset-bucket).
1968
2004
 
1969
2005
  **To adopt.** Optional:
1970
2006
 
@@ -2074,7 +2110,7 @@ public JWKS PEM, used only to verify signatures.
2074
2110
  to variables (Settings → Secrets and variables → Actions → Variables); `bin/app.ts` refuses the
2075
2111
  deploy at synth while it is unset. Check that `bin/app.ts` passes `CLERK_SECRET_KEY` as
2076
2112
  `clerkSecretKeySecretArn` (read by the worker), never in the Lambda's `environment`, unless you keep
2077
- `clerkMiddleware` ([Security Model](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/docs/deploying-to-aws.md#security-model)).
2113
+ `clerkMiddleware` ([Security Model](https://github.com/safeinsights/canopycms/blob/83be4af22312c30e8b89a5f14a7eb51d2af2944e/docs/deploying-to-aws.md#security-model)).
2078
2114
 
2079
2115
  #### `readByUrlPath` answers only where `listEntries` publishes — **breaking (routing)**
2080
2116
 
@@ -2173,7 +2209,7 @@ basePath: process.env.NEXT_PUBLIC_BASE_PATH,
2173
2209
  Then pass `baseUrl` to `assetUrl` only if Next serves `/assets` (local adapter, `next dev`, S3 with
2174
2210
  no distribution): `assetUrl(image, { width: 960, baseUrl: BASE_PATH })`. Assets on CloudFront via
2175
2211
  `AssetSupport` stay at the distribution root; pass no `baseUrl` (mount table under "Where `/assets`
2176
- is mounted" in [Media Configuration](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/README.md#media-configuration)). Two traps:
2212
+ is mounted" in [Media Configuration](https://github.com/safeinsights/canopycms/blob/83be4af22312c30e8b89a5f14a7eb51d2af2944e/README.md#media-configuration)). Two traps:
2177
2213
 
2178
2214
  - Don't pass a deployment `basePath` to `contentStaticParams({ basePath })`; that option filters by
2179
2215
  a nested route prefix and emits zero params, building green.
@@ -2332,7 +2368,7 @@ Under `exactOptionalPropertyTypes: true`, omit keys instead of assigning `undefi
2332
2368
  `withTrailingSlash` and `isAbsoluteUrl` from `canopycms/server`; `defineSeoFieldGroup()` from
2333
2369
  `canopycms`; `generateContentSitemap` and `entryToMetadata` from `canopycms-next`, bound on
2334
2370
  `createNextCanopyContext`'s result. See
2335
- [Sitemap and SEO Metadata](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/README.md#sitemap-and-seo-metadata). Every routable entry type is in
2371
+ [Sitemap and SEO Metadata](https://github.com/safeinsights/canopycms/blob/83be4af22312c30e8b89a5f14a7eb51d2af2944e/README.md#sitemap-and-seo-metadata). Every routable entry type is in
2336
2372
  the sitemap unless `exclude`d or `noindex`; one `noindex` predicate drives both robots metadata and
2337
2373
  sitemap exclusion. `trailingSlash` is never inferred. `lastModified` defaults to `updatedAt`, a
2338
2374
  filesystem mtime. An empty SEO field counts as unset. `siteUrl` must be absolute, colliding URLs are
@@ -2389,7 +2425,7 @@ underscore-prefixed files are skipped.
2389
2425
 
2390
2426
  **What changed.** New scaffolds write `defaultBranchAccess: 'deny'` and
2391
2427
  `defaultPathAccess: { read: 'allow' }`
2392
- ([Public read on server deployments](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/README.md#public-read-on-server-deployments)).
2428
+ ([Public read on server deployments](https://github.com/safeinsights/canopycms/blob/83be4af22312c30e8b89a5f14a7eb51d2af2944e/README.md#public-read-on-server-deployments)).
2393
2429
 
2394
2430
  **To adopt.** An older scaffold's `defaultBranchAccess: 'allow'` is wider than recommended;
2395
2431
  consider `'deny'`. If you deleted `defaultPathAccess: { read: 'allow' }`, anonymous visitors get no content until you
@@ -2442,7 +2478,7 @@ re-checked an entry's type (a `switch` on `meta.entryType` can merge them into o
2442
2478
  **What changed.** `BlockComponentRegistry<Blocks>` (types only, from `canopycms`; `BlockValueOf<Blocks, 'hero'>`
2443
2479
  gives one template's value type) requires exactly
2444
2480
  one component per block template name when written as an object literal. See
2445
- [Block Component Registries](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/README.md#block-component-registries) and
2481
+ [Block Component Registries](https://github.com/safeinsights/canopycms/blob/83be4af22312c30e8b89a5f14a7eb51d2af2944e/README.md#block-component-registries) and
2446
2482
  `apps/example1/app/components/PostView.tsx`.
2447
2483
 
2448
2484
  ```ts
@@ -2464,7 +2500,7 @@ templates against the schema.
2464
2500
 
2465
2501
  **What changed.** Spreading a `const` field array into several schemas, and nesting
2466
2502
  `defineInlineFieldGroup()` inside a block template, are documented
2467
- ([Reusable Field Fragments](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/README.md#reusable-field-fragments)); `defineFieldFragment()` is an
2503
+ ([Reusable Field Fragments](https://github.com/safeinsights/canopycms/blob/83be4af22312c30e8b89a5f14a7eb51d2af2944e/README.md#reusable-field-fragments)); `defineFieldFragment()` is an
2468
2504
  identity helper for them.
2469
2505
 
2470
2506
  ```ts
@@ -2483,7 +2519,7 @@ field by composing from the same `const` field object.
2483
2519
  A block template holding a `reference` field is a shared block; `read()`/`readByUrlPath()` resolve
2484
2520
  it, and listings do with
2485
2521
  [`resolveReferences`](#listings-resolve-references-and-a-resolved-reference-carries-urlpath-and-optionally-its-body-16--breaking-type-level)
2486
- (0.0.64). See [Shared / Referenced Blocks](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/README.md#shared--referenced-blocks).
2522
+ (0.0.64). See [Shared / Referenced Blocks](https://github.com/safeinsights/canopycms/blob/83be4af22312c30e8b89a5f14a7eb51d2af2944e/README.md#shared--referenced-blocks).
2487
2523
 
2488
2524
  **Now deletable.** A second `read()` in page code to unwrap a shared block's reference.
2489
2525
 
@@ -2505,7 +2541,7 @@ Not retro-documented, apart from these:
2505
2541
 
2506
2542
  #### The registry is keyed by entry-type name (0.0.42)
2507
2543
 
2508
- **What changed.** `createEntrySchemaRegistry` keys are the entry-type names that `.collection.json` files name in `entry.schema`, and `EntryTypesFromRegistry` derives the typed entry-type map from them. Schema-variable keys (`{ postSchema }`) still work but derive nothing; [README's registry convention](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/README.md#convention-why-key-the-registry-by-entry-type-name) says when to keep them.
2544
+ **What changed.** `createEntrySchemaRegistry` keys are the entry-type names that `.collection.json` files name in `entry.schema`, and `EntryTypesFromRegistry` derives the typed entry-type map from them. Schema-variable keys (`{ postSchema }`) still work but derive nothing; [README's registry convention](https://github.com/safeinsights/canopycms/blob/83be4af22312c30e8b89a5f14a7eb51d2af2944e/README.md#convention-why-key-the-registry-by-entry-type-name) says when to keep them.
2509
2545
 
2510
2546
  **To adopt.**
2511
2547
 
@@ -8,6 +8,7 @@
8
8
  import type { ContentStore } from '../content-store.js';
9
9
  import type { FlatSchemaItem } from '../config/index.js';
10
10
  import { type EntryLinkUrlResolver } from '../entry-link-resolver.js';
11
+ import { type SeoFieldLocation } from '../static/seo.js';
11
12
  import type { AIContentConfig, AIManifest } from './types.js';
12
13
  export interface GenerateOptions {
13
14
  store: ContentStore;
@@ -17,6 +18,8 @@ export interface GenerateOptions {
17
18
  config?: AIContentConfig;
18
19
  /** Custom URL resolver for entry links. */
19
20
  entryLinkUrl?: EntryLinkUrlResolver;
21
+ /** Where entries keep their SEO fields: `CanopyConfig.seo`. Drives the `noindex` read. */
22
+ seo?: SeoFieldLocation;
20
23
  /**
21
24
  * ISO-8601 timestamp to record as the manifest's `generated`. Defaults to now.
22
25
  *
@@ -18,7 +18,7 @@ import { entryToMarkdown, frontmatterTitle } from './json-to-markdown.js';
18
18
  import { createReferenceRendering, createReferenceTargetResolver, decideReferenceLinks, maskUnexportedTargets, resolveReferenceFields, } from './references.js';
19
19
  import { resolveEntryLinksInText } from '../entry-link-resolver.js';
20
20
  import { computeEntryUrl } from '../utils/entry-url.js';
21
- import { DEFAULT_SEO_FIELD_NAMES, isNoindexEntry } from '../static/seo.js';
21
+ import { isNoindexEntry } from '../static/seo.js';
22
22
  /**
23
23
  * Generate all AI content from the content store.
24
24
  *
@@ -32,7 +32,7 @@ import { DEFAULT_SEO_FIELD_NAMES, isNoindexEntry } from '../static/seo.js';
32
32
  * rendered, in rounds that repeat while a render fails (see the loop below).
33
33
  */
34
34
  export async function generateAIContent(options) {
35
- const { store, flatSchema, contentRoot, config, entryLinkUrl, generatedAt, buildId } = options;
35
+ const { store, flatSchema, contentRoot, config, entryLinkUrl, seo, generatedAt, buildId } = options;
36
36
  assertValidNoindexConfig(config);
37
37
  assertValidReferenceLink(config);
38
38
  const files = new Map();
@@ -43,6 +43,7 @@ export async function generateAIContent(options) {
43
43
  config,
44
44
  idIndex,
45
45
  entryLinkUrl,
46
+ seo,
46
47
  resolveTarget: createReferenceTargetResolver(store),
47
48
  };
48
49
  const collections = flatSchema.filter((item) => item.type === 'collection');
@@ -225,7 +226,7 @@ async function collectCollection(read, collection, flatSchema) {
225
226
  }
226
227
  /** Read, resolve and filter the entries directly in `collection` (not its subcollections). */
227
228
  async function collectEntries(read, collection, cleanPath) {
228
- const { store, contentRoot, config, idIndex, entryLinkUrl, resolveTarget } = read;
229
+ const { store, contentRoot, config, idIndex, entryLinkUrl, seo, resolveTarget } = read;
229
230
  const skipNoindex = config?.exclude?.noindex !== false;
230
231
  const pending = [];
231
232
  const listed = await store.getCollectionEntryPaths(collection.logicalPath);
@@ -245,7 +246,7 @@ async function collectEntries(read, collection, cleanPath) {
245
246
  resolveReferences: false,
246
247
  });
247
248
  // AI content advertises an entry, so `noindex` leaves it out here as it does the sitemap.
248
- if (skipNoindex && isNoindexEntry(doc.data, config?.seo))
249
+ if (skipNoindex && isNoindexEntry(doc.data, seo))
249
250
  continue;
250
251
  const storedData = doc.data;
251
252
  doc.data = await resolveReferenceFields(doc.data, entryTypeConfig.schema, resolveTarget);
@@ -317,37 +318,19 @@ function assertValidReferenceLink(config) {
317
318
  }
318
319
  }
319
320
  /**
320
- * Refuse an `exclude.noindex` or `seo` the noindex gate would misread. A non-boolean
321
- * `noindex: 'false'` would leave the gate on while the adopter believes it is off, and a
322
- * misshapen `seo` reads the flag from a field no entry sets, so every noindex entry ships.
321
+ * Refuse a non-boolean `exclude.noindex`: `noindex: 'false'` would leave the gate on while the
322
+ * adopter believes it is off. Refuse `seo` too: the location is `CanopyConfig.seo`, and an AI
323
+ * config loaded without type checking would otherwise drop it silently and ship every noindex
324
+ * entry. `CanopyConfig.seo`'s shape is checked by the config schema.
323
325
  */
324
326
  function assertValidNoindexConfig(config) {
325
327
  const noindex = config?.exclude?.noindex;
326
328
  if (noindex !== undefined && typeof noindex !== 'boolean') {
327
329
  throw new Error(`AI content config: exclude.noindex must be a boolean, got ${typeof noindex}`);
328
330
  }
329
- const seo = config?.seo;
330
- if (seo === undefined)
331
- return;
332
- if (typeof seo !== 'object' || seo === null || Array.isArray(seo)) {
333
- throw new Error('AI content config: seo must be an object of { group?, fields? }');
334
- }
335
- const { group, fields } = seo;
336
- if (group !== undefined && typeof group !== 'string') {
337
- throw new Error('AI content config: seo.group must be a string');
338
- }
339
- if (fields === undefined)
340
- return;
341
- if (typeof fields !== 'object' ||
342
- fields === null ||
343
- Array.isArray(fields) ||
344
- Object.values(fields).some((name) => typeof name !== 'string')) {
345
- throw new Error('AI content config: seo.fields must map SEO fields to field-name strings');
346
- }
347
- // An unknown key (`noIndex`) would leave the gate reading the default field name
348
- const unknown = Object.keys(fields).filter((key) => !(key in DEFAULT_SEO_FIELD_NAMES));
349
- if (unknown.length > 0) {
350
- throw new Error(`AI content config: unknown seo.fields key(s): ${unknown.join(', ')}`);
331
+ if (config && 'seo' in config) {
332
+ throw new Error('AI content config: seo is not an AI content option. Set it once as seo in defineCanopyConfig, ' +
333
+ 'where the sitemap, page metadata and AI content all read it.');
351
334
  }
352
335
  }
353
336
  function stripContentRoot(logicalPath, contentRoot) {
@@ -43,6 +43,7 @@ export function createAIContentHandler(options) {
43
43
  contentRoot: contentRootName,
44
44
  config: aiConfig,
45
45
  entryLinkUrl: config.entryLinkUrl,
46
+ seo: config.seo,
46
47
  });
47
48
  cachedResult = result;
48
49
  return result;
@@ -6,7 +6,6 @@
6
6
  */
7
7
  import type { FieldConfig } from '../config/index.js';
8
8
  import type { MissingReference, ResolvedReferenceMeta } from '../entry-schema.js';
9
- import type { SeoFieldLocation } from '../static/seo.js';
10
9
  /** A reference whose target this export shows: the target's own data plus where it lives. */
11
10
  export type AIResolvedReference = Record<string, unknown> & ResolvedReferenceMeta & {
12
11
  unavailable?: undefined;
@@ -62,9 +61,9 @@ export interface ExcludeConfig {
62
61
  /** Custom predicate — return true to exclude the entry */
63
62
  where?: (entry: AIEntryMeta) => boolean;
64
63
  /**
65
- * Leave out entries marked `noindex`, read through `isNoindexEntry` at
66
- * {@link AIContentConfig.seo}, the predicate the sitemap and robots metadata use. Default
67
- * `true`; `false` exports them.
64
+ * Leave out entries marked `noindex`, read through `isNoindexEntry` at `config.seo`, the
65
+ * predicate and location the sitemap and robots metadata use. Default `true`; `false` exports
66
+ * them.
68
67
  */
69
68
  noindex?: boolean;
70
69
  }
@@ -247,11 +246,6 @@ export interface AIContentConfig {
247
246
  mountPath?: string;
248
247
  /** Opt-out exclusions — content to skip */
249
248
  exclude?: ExcludeConfig;
250
- /**
251
- * Where entries keep their SEO fields, when not the flat defaults. Drives the `noindex` read,
252
- * so pass the same object as `createNextCanopyContext({ seo })`, or the two can disagree.
253
- */
254
- seo?: SeoFieldLocation;
255
249
  /** Custom bundles — filtered content subsets */
256
250
  bundles?: BundleConfig[];
257
251
  /** Per-entry-type, per-field markdown overrides */
@@ -1,11 +1,8 @@
1
1
  import { z } from 'zod';
2
2
  import type { ApiResponse } from './types.js';
3
+ import { type ReferenceOption } from '../reference-resolver.js';
3
4
  export type ReferenceOptionsResponse = ApiResponse<{
4
- options: Array<{
5
- id: string;
6
- label: string;
7
- collection: string;
8
- }>;
5
+ options: ReferenceOption[];
9
6
  }>;
10
7
  /**
11
8
  * Exported routes for router registration
@@ -2,6 +2,7 @@ import { z } from 'zod';
2
2
  import { ContentStore } from '../content-store.js';
3
3
  import { defineEndpoint } from './route-builder.js';
4
4
  import { ReferenceResolver } from '../reference-resolver.js';
5
+ import { referenceSortFieldSchema } from '../config/schemas/field.js';
5
6
  import { parseLogicalPath } from '../paths/index.js';
6
7
  import { branchNameSchema } from './validators.js';
7
8
  const getReferenceOptionsParamsSchema = z.object({
@@ -16,9 +17,18 @@ const getReferenceOptionsHandler = async (gc, ctx, req, _params) => {
16
17
  entryTypes: z.string().optional(),
17
18
  displayField: z.string().optional(),
18
19
  search: z.string().optional(),
20
+ sort: z.enum(['label', 'collection', 'field']).optional(),
21
+ sortField: referenceSortFieldSchema.optional(),
22
+ sortDir: z.enum(['asc', 'desc']).optional(),
19
23
  })
20
24
  .refine((data) => data.collections || data.entryTypes, {
21
25
  message: 'At least one of "collections" or "entryTypes" query parameters is required',
26
+ })
27
+ .refine((data) => (data.sort === 'field') === (data.sortField !== undefined), {
28
+ message: '"sortField" is required with sort=field, and only allowed with it',
29
+ })
30
+ .refine((data) => data.sortDir === undefined || data.sort === 'field', {
31
+ message: '"sortDir" is only allowed with sort=field',
22
32
  });
23
33
  const queryResult = querySchema.safeParse(req.query ?? {});
24
34
  if (!queryResult.success) {
@@ -32,6 +42,13 @@ const getReferenceOptionsHandler = async (gc, ctx, req, _params) => {
32
42
  const entryTypesParam = queryResult.data.entryTypes;
33
43
  const displayField = queryResult.data.displayField || 'title';
34
44
  const search = queryResult.data.search;
45
+ // The refinements above pair sortField with sort=field, so sortField alone decides.
46
+ const { sort: sortParam, sortField, sortDir } = queryResult.data;
47
+ const sort = sortField !== undefined
48
+ ? { field: sortField, direction: sortDir }
49
+ : sortParam === 'field'
50
+ ? undefined
51
+ : sortParam;
35
52
  const flatSchema = branchContext.flatSchema;
36
53
  const store = new ContentStore(branchContext.branchRoot, flatSchema, {
37
54
  contentRootName: ctx.services.config.contentRoot || 'content',
@@ -70,7 +87,7 @@ const getReferenceOptionsHandler = async (gc, ctx, req, _params) => {
70
87
  // for an option the caller isn't allowed to see.
71
88
  const checkAccess = await ctx.services.createContentAccessChecker(branchContext, branchContext.branchRoot, req.user);
72
89
  const resolver = new ReferenceResolver(store, idIndex);
73
- const options = await resolver.loadReferenceOptions(collections, displayField, search, entryTypes, (logicalPath) => checkAccess(logicalPath, 'read').allowed);
90
+ const options = await resolver.loadReferenceOptions(collections, displayField, search, entryTypes, (logicalPath) => checkAccess(logicalPath, 'read').allowed, { seo: ctx.services.config.seo, sort });
74
91
  return {
75
92
  ok: true,
76
93
  status: 200,
@@ -81,7 +98,9 @@ const getReferenceOptionsHandler = async (gc, ctx, req, _params) => {
81
98
  * Get reference options for a field
82
99
  * GET /:branch/reference-options
83
100
  * Query params: collections (comma-separated, optional), entryTypes (comma-separated, optional),
84
- * displayField, search. At least one of collections or entryTypes is required.
101
+ * displayField, search. At least one of collections or entryTypes is required. `sort` is
102
+ * label (default), collection or field; field takes `sortField` (a dotted path) and `sortDir`
103
+ * (asc, the default, or desc). See `ReferenceOptionSort`.
85
104
  */
86
105
  const getReferenceOptions = defineEndpoint({
87
106
  namespace: 'content',