canopycms 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +66 -42
- package/dist/ai/generate.d.ts +3 -0
- package/dist/ai/generate.js +12 -29
- package/dist/ai/handler.js +1 -0
- package/dist/ai/types.d.ts +3 -9
- package/dist/api/reference-options.d.ts +2 -5
- package/dist/api/reference-options.js +21 -2
- package/dist/api/schema.d.ts +4 -4
- package/dist/build/generate-ai-content.js +1 -0
- package/dist/cli/cli.js +131 -38
- package/dist/cli/generate-ai-content.js +75 -32
- package/dist/cli/init.js +29 -4
- package/dist/config/index.d.ts +1 -1
- package/dist/config/schemas/config.d.ts +74 -0
- package/dist/config/schemas/config.js +21 -0
- package/dist/config/schemas/field.d.ts +30 -0
- package/dist/config/schemas/field.js +22 -0
- package/dist/config/types.d.ts +39 -0
- package/dist/config/validation.d.ts +6 -0
- package/dist/config/validation.js +33 -0
- package/dist/editor/FormRenderer.js +15 -13
- package/dist/editor/copy.d.ts +5 -0
- package/dist/editor/copy.js +5 -0
- package/dist/editor/fields/BlockField.d.ts +2 -0
- package/dist/editor/fields/BlockField.js +15 -8
- package/dist/editor/fields/ItemList.d.ts +21 -3
- package/dist/editor/fields/ItemList.js +16 -8
- package/dist/editor/fields/NumberListField.d.ts +2 -0
- package/dist/editor/fields/NumberListField.js +6 -2
- package/dist/editor/fields/ObjectListField.js +9 -3
- package/dist/editor/fields/ReferenceField.d.ts +6 -7
- package/dist/editor/fields/ReferenceField.js +28 -122
- package/dist/editor/fields/ReferenceListField.d.ts +41 -0
- package/dist/editor/fields/ReferenceListField.js +139 -0
- package/dist/editor/fields/SelectField.d.ts +2 -0
- package/dist/editor/fields/SelectField.js +6 -3
- package/dist/editor/fields/StringListField.d.ts +10 -1
- package/dist/editor/fields/StringListField.js +18 -8
- package/dist/editor/fields/item-expansion.d.ts +7 -3
- package/dist/editor/fields/item-expansion.js +6 -4
- package/dist/editor/fields/list-item-keys.d.ts +6 -5
- package/dist/editor/fields/list-item-keys.js +45 -13
- package/dist/editor/fields/reference-noindex.d.ts +37 -0
- package/dist/editor/fields/reference-noindex.js +48 -0
- package/dist/editor/fields/use-reference-options.d.ts +36 -0
- package/dist/editor/fields/use-reference-options.js +121 -0
- package/dist/editor/form-outline.d.ts +2 -2
- package/dist/editor/form-outline.js +4 -2
- package/dist/editor/theme.js +5 -0
- package/dist/entry-schema-registry.d.ts +1 -1
- package/dist/entry-schema-registry.js +3 -2
- package/dist/entry-schema.d.ts +5 -3
- package/dist/entry-schema.js +2 -1
- package/dist/reference-resolver.d.ts +18 -1
- package/dist/reference-resolver.js +175 -8
- package/dist/schema/schema-store.d.ts +2 -2
- package/dist/static/index.d.ts +8 -4
- package/dist/static/index.js +38 -13
- package/dist/static/seo.d.ts +7 -5
- package/dist/static/seo.js +13 -6
- package/dist/validation/entry-validator.d.ts +5 -0
- package/dist/validation/entry-validator.js +12 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- 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.
|
|
8
|
+
Version `0.5.0`, built from [`3576327`](https://github.com/safeinsights/canopycms/tree/3576327ebf2ba4ab163b234d3f1e36318ff1c37f).
|
|
9
9
|
|
|
10
|
-
Its entries are [0.
|
|
10
|
+
Its entries are [0.5.0](#050), 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/
|
|
27
|
+
every entry written since is a file in [`.changeset/`](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/.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,30 @@ entries under **Released**.
|
|
|
62
62
|
|
|
63
63
|
## Released
|
|
64
64
|
|
|
65
|
+
### 0.5.0
|
|
66
|
+
|
|
67
|
+
#### Reorderable list references, and `maxItems` on list fields — **behaviour change: a build fails on a list over its cap**
|
|
68
|
+
|
|
69
|
+
<!-- changeset: reference-list-reorder-and-max-items -->
|
|
70
|
+
|
|
71
|
+
_First in 0.5.0._
|
|
72
|
+
|
|
73
|
+
**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.
|
|
74
|
+
|
|
75
|
+
**To adopt.** Set `maxItems: 3` on the list field in its entry schema. See [Field Types](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/README.md#field-types).
|
|
76
|
+
|
|
77
|
+
#### SEO field location moves into config; reference pickers mark hidden entries and take a sort order — **breaking: `createNextCanopyContext({ seo })` and `AIContentConfig.seo` are removed**
|
|
78
|
+
|
|
79
|
+
<!-- changeset: seo-config-hidden-picks-option-sort -->
|
|
80
|
+
|
|
81
|
+
_First in 0.5.0._
|
|
82
|
+
|
|
83
|
+
**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.
|
|
84
|
+
|
|
85
|
+
**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/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/README.md#sitemap-and-seo-metadata) and [How References Work in the Editor](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/README.md#how-references-work-in-the-editor).
|
|
86
|
+
|
|
87
|
+
**Now deletable.** A shared `seo` constant passed separately to the Next context and the AI content config.
|
|
88
|
+
|
|
65
89
|
### 0.4.0
|
|
66
90
|
|
|
67
91
|
#### Link-only references to json/yaml entries leave out the body — **behaviour change (resolved data and types)**
|
|
@@ -86,7 +110,7 @@ resolved without it.
|
|
|
86
110
|
**To adopt.** Where a reference renders its target's prose, set `includeBody: true` on that
|
|
87
111
|
reference field. Code that reads the body from a link-only reference's resolved type now sees
|
|
88
112
|
`string | undefined`; either set `includeBody: true` or handle the missing value. See
|
|
89
|
-
[Resolving References in a Listing](https://github.com/safeinsights/canopycms/blob/
|
|
113
|
+
[Resolving References in a Listing](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/README.md#resolving-references-in-a-listing).
|
|
90
114
|
|
|
91
115
|
### 0.3.3
|
|
92
116
|
|
|
@@ -497,7 +521,7 @@ URL.
|
|
|
497
521
|
2. For a branch preview: wrap views with `withCanopyPreview` in a `'use client'` module, add
|
|
498
522
|
`app/preview/[[...path]]/page.server.tsx`, set `editor.previewPrefix: '/preview'`, and serve that
|
|
499
523
|
route with `frame-ancestors 'self'`, not `X-Frame-Options: DENY` (see
|
|
500
|
-
[Live Preview](https://github.com/safeinsights/canopycms/blob/
|
|
524
|
+
[Live Preview](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/README.md#live-preview)).
|
|
501
525
|
3. A test reading view content from the route's server HTML must load the page in a browser.
|
|
502
526
|
Server output rendered during a preview request carries the signed-in asset prefix; keep it out
|
|
503
527
|
of cross-request caches (`unstable_cache`, module memos).
|
|
@@ -512,7 +536,7 @@ kept site styles ahead of Mantine's in the preview.
|
|
|
512
536
|
server components. A string path marks the form's spelling (`'a.0.b'` marks `a[0].b`), and an empty
|
|
513
537
|
path marks nothing. The editor counts and logs marks naming no field. `createEntrySchemaRegistry`
|
|
514
538
|
refuses a field name that is empty, all digits or contains `.`, `[` or `]`. See
|
|
515
|
-
[Live Preview](https://github.com/safeinsights/canopycms/blob/
|
|
539
|
+
[Live Preview](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/README.md#live-preview).
|
|
516
540
|
|
|
517
541
|
**To adopt.** Fix each path that stops compiling; the error lists valid ones. Rewrite computed paths
|
|
518
542
|
as literal segments, or type that component's prop as plain `FieldProps`. Pass `fieldProps` as
|
|
@@ -594,7 +618,7 @@ or a failed render) renders as its plain text, with no URL; any other form of th
|
|
|
594
618
|
fields are nested or renamed, pass the AI config's `seo` the same object you pass
|
|
595
619
|
`createNextCanopyContext({ seo })`, so the sitemap and AI content read the flag from the same
|
|
596
620
|
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/
|
|
621
|
+
shows [the recipe](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/README.md#ai-content-configuration).
|
|
598
622
|
|
|
599
623
|
**Now deletable.** An `exclude.where` that re-read the `noindex` flag by hand.
|
|
600
624
|
|
|
@@ -616,7 +640,7 @@ A `markdown` field with `renderAs: 'mdx'` is checked as MDX, and `mdxAllow` narr
|
|
|
616
640
|
field or site-wide. New: field options `renderAs`, `mdxAllow`; config key `mdxAllow`; type
|
|
617
641
|
`MdxAllowlist`. (int.110) A component prop allowance can be `'string'` (or
|
|
618
642
|
`{ type: 'string', maxLength }`): a quoted value only, never bare or `{…}`. See
|
|
619
|
-
[MDX content cannot run code](https://github.com/safeinsights/canopycms/blob/
|
|
643
|
+
[MDX content cannot run code](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/README.md#mdx-content-cannot-run-code).
|
|
620
644
|
|
|
621
645
|
**To adopt.** Set `renderAs: 'mdx'` on each `markdown` field your site compiles as MDX, and
|
|
622
646
|
`mdxAllow` to what your renderer takes. Set `executable: true` only on a field whose editors you
|
|
@@ -753,7 +777,7 @@ a format check.
|
|
|
753
777
|
|
|
754
778
|
- (int.93) Submit commits gain an `Edited-by: Name (id)` trailer; PR bodies gain a section that
|
|
755
779
|
re-submits replace, keeping human text. Options: `gitEditedByTrailers`, `gitCoAuthoredByTrailers`
|
|
756
|
-
([reference](https://github.com/safeinsights/canopycms/blob/
|
|
780
|
+
([reference](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/README.md#definecanopyconfig-options)).
|
|
757
781
|
- (int.110) Submit-commit trailers name every user who saved since the last submit commit, and
|
|
758
782
|
the PR-body section every user who edited the branch, not only the submitter; settings commits
|
|
759
783
|
(permissions, groups) carry the acting user's trailer.
|
|
@@ -777,7 +801,7 @@ saves only push the branch, and no failing PR task lands in System health.
|
|
|
777
801
|
that entry type goes unavailable: the editor says so, and its entries answer 503 with
|
|
778
802
|
`code: 'SCHEMA_UNAVAILABLE'`. Builds, static deploys and `generate-ai-content` still fail. The
|
|
779
803
|
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/
|
|
804
|
+
[New schemas wait for the editor deploy](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/docs/deploying-to-aws.md#new-schemas-wait-for-the-editor-deploy).
|
|
781
805
|
Public types gain optional `unavailable` on `EntryTypeConfig` and `FlatSchemaItem`, optional
|
|
782
806
|
`ApiResponse.code`, and a required `SchemaResolutionResult.issues`.
|
|
783
807
|
|
|
@@ -815,7 +839,7 @@ hang until the drain heartbeat lets termination continue. Its in-flight task is
|
|
|
815
839
|
new stack needs no steps.
|
|
816
840
|
|
|
817
841
|
**What changed.** (int.109) Detailed in
|
|
818
|
-
[The worker instance](https://github.com/safeinsights/canopycms/blob/
|
|
842
|
+
[The worker instance](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/docs/deploying-to-aws.md#the-worker-instance): IMDSv2 with a hop limit of 1; the
|
|
819
843
|
bundle is one file whose sha256 user data checks, readable as that one object; a file-system policy
|
|
820
844
|
refusing clients without TLS or IAM, replacing the worker's
|
|
821
845
|
`AmazonElasticFileSystemClientReadWriteAccess`; an encrypted gp3 root volume; a boot-time upgrade to
|
|
@@ -869,10 +893,10 @@ failure and exits non-zero on `selfStopped`, with a code outside `RestartPrevent
|
|
|
869
893
|
with its hash, as `worker/dist/index.js` and `index.js.sha256`. The default, `'asset'`, is
|
|
870
894
|
unchanged.
|
|
871
895
|
- `CanopyCmsService` alarms when the worker logs no git sync for 30 minutes. See
|
|
872
|
-
[Worker-down alarm](https://github.com/safeinsights/canopycms/blob/
|
|
896
|
+
[Worker-down alarm](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/docs/deploying-to-aws.md#worker-down-alarm).
|
|
873
897
|
|
|
874
898
|
**To adopt.** Optional. For parameter-only change sets, see
|
|
875
|
-
[Rolling the worker from CI](https://github.com/safeinsights/canopycms/blob/
|
|
899
|
+
[Rolling the worker from CI](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/docs/deploying-to-aws.md#rolling-the-worker-from-ci). For the alarm, pass
|
|
876
900
|
`alarmTopic`.
|
|
877
901
|
|
|
878
902
|
**Now deletable.** A manual `cdk deploy` after each canopycms bump whose only purpose is moving the
|
|
@@ -883,7 +907,7 @@ worker, and a hand-built alarm on the worker log group.
|
|
|
883
907
|
**What changed.** (int.112) The boot's `dnf upgrade` could be OOM-killed on every retry. A 1 GiB
|
|
884
908
|
swap file now goes on first; an upgrade that still fails starts the worker unpatched and notifies
|
|
885
909
|
`alarmTopic` if set; a retried step names itself when it gives up. See
|
|
886
|
-
[The worker instance](https://github.com/safeinsights/canopycms/blob/
|
|
910
|
+
[The worker instance](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/docs/deploying-to-aws.md#the-worker-instance).
|
|
887
911
|
|
|
888
912
|
**To adopt.** Deploy, which replaces the worker instance. The bundle needs none of this, so it is
|
|
889
913
|
not Template first and the worker contract stays at 1.
|
|
@@ -949,7 +973,7 @@ and operations may reuse GitHub fetches under 30 seconds old.
|
|
|
949
973
|
|
|
950
974
|
**To adopt.** Nothing. Seeding `remote.git` stages a copy of the repository beside the gateway's
|
|
951
975
|
mirror, so the root volume needs room for two
|
|
952
|
-
([details](https://github.com/safeinsights/canopycms/blob/
|
|
976
|
+
([details](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/docs/deploying-to-aws.md#the-worker-instance)).
|
|
953
977
|
|
|
954
978
|
#### The worker follows a rebased or deleted GitHub branch
|
|
955
979
|
|
|
@@ -971,7 +995,7 @@ changes the template too (the fallback bundle's key and hash), so only the contr
|
|
|
971
995
|
bundle-only roll is safe.
|
|
972
996
|
|
|
973
997
|
**To adopt.** Parameter mode: gate bundle-only rolls on the contract
|
|
974
|
-
([recipe](https://github.com/safeinsights/canopycms/blob/
|
|
998
|
+
([recipe](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/docs/deploying-to-aws.md#rolling-the-worker-from-ci)). The gate refuses a stack without the
|
|
975
999
|
`WorkerContract` output, so `cdk deploy` the template once, which adds it. A hand-installed unit
|
|
976
1000
|
copies its `Environment=CANOPYCMS_WORKER_CONTRACT=` line from `worker/canopy-worker.service`.
|
|
977
1001
|
|
|
@@ -988,8 +1012,8 @@ units from the bundle's contract: 2 gets the split, an older bundle the single u
|
|
|
988
1012
|
template, then roll the bundle; on an older template it stops with `template too old for this
|
|
989
1013
|
bundle`. Inspect EFS only through `sudo /opt/canopy-worker/canopy-inspect <command>`, never from a root shell. A hand install
|
|
990
1014
|
takes `worker/`'s three units and `gateway.env.example`
|
|
991
|
-
([steps](https://github.com/safeinsights/canopycms/blob/
|
|
992
|
-
[checklist](https://github.com/safeinsights/canopycms/blob/
|
|
1015
|
+
([steps](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/docs/deploying-to-aws.md#installing-the-units-by-hand)). After the first deploy, run the
|
|
1016
|
+
[checklist](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/docs/deploying-to-aws.md#first-deploy-checklist).
|
|
993
1017
|
|
|
994
1018
|
#### `canopycms-cdk`: `CanopyCmsService.attachTo`, and editor response headers — **behaviour change if you frame the CMS**
|
|
995
1019
|
|
|
@@ -1000,7 +1024,7 @@ response headers policy. `CanopyCmsDistribution` sends the same headers: `frame-
|
|
|
1000
1024
|
`X-Frame-Options: SAMEORIGIN`, `nosniff`, HSTS and `X-Robots-Tag: noindex`. Unless your app sends
|
|
1001
1025
|
its own framing headers, no other origin can frame the editor or any page the CMS domain serves. Every such page is
|
|
1002
1026
|
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/
|
|
1027
|
+
[Serving the editor from a distribution you already own](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/docs/deploying-to-aws.md#serving-the-editor-from-a-distribution-you-already-own).
|
|
1004
1028
|
|
|
1005
1029
|
**To adopt.** If you wired the Function URL into your own distribution by hand, delete those
|
|
1006
1030
|
behaviors and call `attachTo`, passing your CMS build's `assetPrefix` as `editorAssetPrefix` and a
|
|
@@ -1176,7 +1200,7 @@ one the exclusions leave out. A throw or any other return is logged and treated
|
|
|
1176
1200
|
**To adopt.** If your site's routes, sitemap or bylines decide that some entries have no page,
|
|
1177
1201
|
apply the same rule here, for example `referenceLink: (target, { body }) =>
|
|
1178
1202
|
!body?.trim() ? false : undefined` in `defineAIContentConfig` from `canopycms/ai`. See
|
|
1179
|
-
[AI Content Configuration](https://github.com/safeinsights/canopycms/blob/
|
|
1203
|
+
[AI Content Configuration](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/README.md#ai-content-configuration).
|
|
1180
1204
|
|
|
1181
1205
|
**Now deletable.** A `fieldTransforms` entry that re-renders a reference field only to drop or
|
|
1182
1206
|
change its link.
|
|
@@ -1251,7 +1275,7 @@ _First in int.115._
|
|
|
1251
1275
|
entry the base branch also changed, the "updated on the base branch" notice and the branch's
|
|
1252
1276
|
conflict count now stay until the branch merges, so a reviewer still sees which entries replaced a
|
|
1253
1277
|
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/
|
|
1278
|
+
and Unpublishing](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/README.md#drafts-and-unpublishing) section covers long-lived branches and
|
|
1255
1279
|
unpublishing.
|
|
1256
1280
|
|
|
1257
1281
|
#### The editor calls the content drawer "All content"
|
|
@@ -1563,7 +1587,7 @@ editor carries an unsaved draft of a stamped entry onto its stamped version.
|
|
|
1563
1587
|
The flag is refused off a top-level `datetime`, on `list: true`, and with `required: true`.
|
|
1564
1588
|
|
|
1565
1589
|
**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/
|
|
1590
|
+
`{ name: 'publishedAt', type: 'datetime', stampOnPublish: true }`. See [Stamping a publication date](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/README.md#stamping-a-publication-date).
|
|
1567
1591
|
|
|
1568
1592
|
**Now deletable.** A build step or hook that writes a missing publication date into new entries.
|
|
1569
1593
|
|
|
@@ -1610,7 +1634,7 @@ preview/form divider is now keyboard-resizable within the same 15–85% the spli
|
|
|
1610
1634
|
stored at, and `react-split-pane` is no longer a dependency.
|
|
1611
1635
|
`EditorPanes`, `EditorPanesProps`, the `PaneLayout` type and the `SPLIT_PERCENT_*` and `DEFAULT_*_SPLIT_PERCENT` constants are
|
|
1612
1636
|
no longer exported from `canopycms/client`. See
|
|
1613
|
-
[Your root layout](https://github.com/safeinsights/canopycms/blob/
|
|
1637
|
+
[Your root layout](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/README.md#editor-customization).
|
|
1614
1638
|
|
|
1615
1639
|
**To adopt.** Nothing, unless you import `EditorPanes` or those constants: render `CanopyEditor`
|
|
1616
1640
|
instead, which lays out its own panes. Hiding your site chrome on the editor route is now
|
|
@@ -1721,7 +1745,7 @@ never ended. `canopycms-auth-clerk` skips it while the editor is mounted, and ex
|
|
|
1721
1745
|
**To adopt.** Nothing for the editor, if your edit page uses `useClerkAuthConfig()` or
|
|
1722
1746
|
`ClerkSignIn`. If your CMS build renders `<SignIn>`, `UserButton` or `OrganizationSwitcher` on your
|
|
1723
1747
|
own pages, mount the hook as in
|
|
1724
|
-
[Clerk components on your own pages](https://github.com/safeinsights/canopycms/blob/
|
|
1748
|
+
[Clerk components on your own pages](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/packages/canopycms-auth-clerk/README.md#clerk-components-on-your-own-pages).
|
|
1725
1749
|
Your own Server Actions in the CMS build still 403 behind OAC.
|
|
1726
1750
|
|
|
1727
1751
|
**Now deletable.** Any local patch of `window.__internal_onBeforeSetActive` (or 6.x's
|
|
@@ -1762,12 +1786,12 @@ fast naming the ARN, the field and the keys present, never a value.
|
|
|
1762
1786
|
**To adopt.** Nothing, unless one of those secrets holds a JSON document: then set the matching
|
|
1763
1787
|
prop. The scaffolded stack fills them from the repository _variables_
|
|
1764
1788
|
`CANOPY_GITHUB_TOKEN_SECRET_JSON_FIELD` and `CLERK_SECRET_KEY_SECRET_JSON_FIELD`
|
|
1765
|
-
([why the prefix](https://github.com/safeinsights/canopycms/blob/
|
|
1789
|
+
([why the prefix](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/docs/deploying-to-aws.md#repository-secrets-and-variables)); a stack scaffolded earlier
|
|
1766
1790
|
adds the props to `infrastructure/bin/app.ts` and `infrastructure/lib/cms-stack.ts` and the two `env`
|
|
1767
1791
|
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
1792
|
(also in `secretsArns`). Don't use CDK's `secretValueFromJson`: it resolves the plaintext into the deployed
|
|
1769
1793
|
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/
|
|
1794
|
+
key are public material ([Security Model](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/docs/deploying-to-aws.md#security-model)).
|
|
1771
1795
|
|
|
1772
1796
|
**Now deletable.** A wrapper that fetches the secret, parses it and re-exports one field into the
|
|
1773
1797
|
worker's environment, such as a `jq` step in user data or a wrapper entrypoint around
|
|
@@ -1779,7 +1803,7 @@ worker's environment, such as a `jq` step in user data or a wrapper entrypoint a
|
|
|
1779
1803
|
`githubToken` is not deprecated and stays the documented default; `canopycms` neither depends on
|
|
1780
1804
|
nor imports `@octokit/auth-app`. Register one App per site, not one shared across repositories:
|
|
1781
1805
|
anyone holding an App's key can mint a token for any of its installations
|
|
1782
|
-
([why](https://github.com/safeinsights/canopycms/blob/
|
|
1806
|
+
([why](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/ARCHITECTURE.md#why-one-github-app-per-site-not-one-shared-across-an-organisation)).
|
|
1783
1807
|
|
|
1784
1808
|
**To adopt with `canopycms-cdk`** (existing stacks need no edit). `CanopyCmsServiceProps` takes
|
|
1785
1809
|
`githubAppId`, `githubAppInstallationId`, `githubAppPrivateKeySecretArn` and
|
|
@@ -1792,7 +1816,7 @@ anyone holding an App's key can mint a token for any of its installations
|
|
|
1792
1816
|
`verify` checks an existing installation's permissions: run it, since an App missing a
|
|
1793
1817
|
permission only shows up later, as `sync-failed`. `create` needs an interactive terminal and
|
|
1794
1818
|
never edits an existing JSON secret (create one and point the JSON-field prop at it)
|
|
1795
|
-
([details](https://github.com/safeinsights/canopycms/blob/
|
|
1819
|
+
([details](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/docs/deploying-to-aws.md#register-it-with-canopycms-init-github-app)).
|
|
1796
1820
|
2. Set the three props and **remove `githubTokenSecretArn`** (with its JSON field). A partial set
|
|
1797
1821
|
of the three is refused at synth, and so is an App alongside a token.
|
|
1798
1822
|
3. In the generated workflow, store them as `CANOPY_GITHUB_APP_ID`,
|
|
@@ -1803,7 +1827,7 @@ anyone holding an App's key can mint a token for any of its installations
|
|
|
1803
1827
|
|
|
1804
1828
|
The private key is ARN-only; passing the key itself is refused at synth. Its ARN joins the worker's
|
|
1805
1829
|
IAM policy automatically, so you need not add it to `secretsArns`. See
|
|
1806
|
-
[Authenticating as a GitHub App](https://github.com/safeinsights/canopycms/blob/
|
|
1830
|
+
[Authenticating as a GitHub App](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/docs/deploying-to-aws.md#authenticating-as-a-github-app).
|
|
1807
1831
|
|
|
1808
1832
|
```bash
|
|
1809
1833
|
canopycms init-github-app create -- \
|
|
@@ -1851,7 +1875,7 @@ downloads the `.pem` from the App's settings page.
|
|
|
1851
1875
|
|
|
1852
1876
|
**What changed.** The worker re-reads a Secrets Manager secret (the GitHub token or the Clerk secret
|
|
1853
1877
|
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/
|
|
1878
|
+
[Rotating a secret](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/docs/deploying-to-aws.md#rotating-a-secret).
|
|
1855
1879
|
|
|
1856
1880
|
**To adopt.** Nothing for credentials from `*_SECRET_ARN`, which is every scaffolded deployment. A
|
|
1857
1881
|
GitHub App private key is still read only at boot: store the new key, replace the instance, and
|
|
@@ -1905,12 +1929,12 @@ also check the bucket policy for its grant.
|
|
|
1905
1929
|
5. `withCanopy()` adds sharp's libvips to Next's file tracing (not for a static export) and, on
|
|
1906
1930
|
Next 16 and later, sets `turbopack: {}` when your config has neither `turbopack` nor your own
|
|
1907
1931
|
`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/
|
|
1932
|
+
([Dual Build Support](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/docs/deploying-to-aws.md#dual-build-support)).
|
|
1909
1933
|
|
|
1910
1934
|
**Breaking:** a stack setting `platform` on `fromImageAsset` without `architecture` gets an arm64
|
|
1911
1935
|
function while `platform` still decides the image, so `Platform.LINUX_AMD64` builds an image the
|
|
1912
1936
|
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/
|
|
1937
|
+
on an x86 host ([Where the image is built](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/docs/deploying-to-aws.md#where-the-image-is-built)).
|
|
1914
1938
|
|
|
1915
1939
|
**To adopt.**
|
|
1916
1940
|
|
|
@@ -1939,7 +1963,7 @@ reason; `platform` on `fromImageAsset`; and, with `withCanopy()`, a hand-written
|
|
|
1939
1963
|
|
|
1940
1964
|
**What changed.** `media.uploadUrl` (s3 adapter; an absolute http(s) URL or a site-relative path)
|
|
1941
1965
|
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/
|
|
1966
|
+
uploads can be same-origin. See [Media Configuration](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/README.md#media-configuration) for the
|
|
1943
1967
|
CloudFront behavior it expects.
|
|
1944
1968
|
|
|
1945
1969
|
**To adopt.** Optional. Set it from an environment variable: a site-relative value works only where
|
|
@@ -1964,7 +1988,7 @@ needs `lazyPublicTransforms: true`) let you pass a deterministically named role,
|
|
|
1964
1988
|
bucket's stack computes `arn:aws:iam::<account>:role/<name>` from literals instead of a
|
|
1965
1989
|
`Fn::GetStackOutput` reference only the CDK CLI resolves. The constructs re-attach
|
|
1966
1990
|
`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/
|
|
1991
|
+
pass. See [Cross-account asset bucket](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/docs/deploying-to-aws.md#cross-account-asset-bucket).
|
|
1968
1992
|
|
|
1969
1993
|
**To adopt.** Optional:
|
|
1970
1994
|
|
|
@@ -2074,7 +2098,7 @@ public JWKS PEM, used only to verify signatures.
|
|
|
2074
2098
|
to variables (Settings → Secrets and variables → Actions → Variables); `bin/app.ts` refuses the
|
|
2075
2099
|
deploy at synth while it is unset. Check that `bin/app.ts` passes `CLERK_SECRET_KEY` as
|
|
2076
2100
|
`clerkSecretKeySecretArn` (read by the worker), never in the Lambda's `environment`, unless you keep
|
|
2077
|
-
`clerkMiddleware` ([Security Model](https://github.com/safeinsights/canopycms/blob/
|
|
2101
|
+
`clerkMiddleware` ([Security Model](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/docs/deploying-to-aws.md#security-model)).
|
|
2078
2102
|
|
|
2079
2103
|
#### `readByUrlPath` answers only where `listEntries` publishes — **breaking (routing)**
|
|
2080
2104
|
|
|
@@ -2173,7 +2197,7 @@ basePath: process.env.NEXT_PUBLIC_BASE_PATH,
|
|
|
2173
2197
|
Then pass `baseUrl` to `assetUrl` only if Next serves `/assets` (local adapter, `next dev`, S3 with
|
|
2174
2198
|
no distribution): `assetUrl(image, { width: 960, baseUrl: BASE_PATH })`. Assets on CloudFront via
|
|
2175
2199
|
`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/
|
|
2200
|
+
is mounted" in [Media Configuration](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/README.md#media-configuration)). Two traps:
|
|
2177
2201
|
|
|
2178
2202
|
- Don't pass a deployment `basePath` to `contentStaticParams({ basePath })`; that option filters by
|
|
2179
2203
|
a nested route prefix and emits zero params, building green.
|
|
@@ -2332,7 +2356,7 @@ Under `exactOptionalPropertyTypes: true`, omit keys instead of assigning `undefi
|
|
|
2332
2356
|
`withTrailingSlash` and `isAbsoluteUrl` from `canopycms/server`; `defineSeoFieldGroup()` from
|
|
2333
2357
|
`canopycms`; `generateContentSitemap` and `entryToMetadata` from `canopycms-next`, bound on
|
|
2334
2358
|
`createNextCanopyContext`'s result. See
|
|
2335
|
-
[Sitemap and SEO Metadata](https://github.com/safeinsights/canopycms/blob/
|
|
2359
|
+
[Sitemap and SEO Metadata](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/README.md#sitemap-and-seo-metadata). Every routable entry type is in
|
|
2336
2360
|
the sitemap unless `exclude`d or `noindex`; one `noindex` predicate drives both robots metadata and
|
|
2337
2361
|
sitemap exclusion. `trailingSlash` is never inferred. `lastModified` defaults to `updatedAt`, a
|
|
2338
2362
|
filesystem mtime. An empty SEO field counts as unset. `siteUrl` must be absolute, colliding URLs are
|
|
@@ -2389,7 +2413,7 @@ underscore-prefixed files are skipped.
|
|
|
2389
2413
|
|
|
2390
2414
|
**What changed.** New scaffolds write `defaultBranchAccess: 'deny'` and
|
|
2391
2415
|
`defaultPathAccess: { read: 'allow' }`
|
|
2392
|
-
([Public read on server deployments](https://github.com/safeinsights/canopycms/blob/
|
|
2416
|
+
([Public read on server deployments](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/README.md#public-read-on-server-deployments)).
|
|
2393
2417
|
|
|
2394
2418
|
**To adopt.** An older scaffold's `defaultBranchAccess: 'allow'` is wider than recommended;
|
|
2395
2419
|
consider `'deny'`. If you deleted `defaultPathAccess: { read: 'allow' }`, anonymous visitors get no content until you
|
|
@@ -2442,7 +2466,7 @@ re-checked an entry's type (a `switch` on `meta.entryType` can merge them into o
|
|
|
2442
2466
|
**What changed.** `BlockComponentRegistry<Blocks>` (types only, from `canopycms`; `BlockValueOf<Blocks, 'hero'>`
|
|
2443
2467
|
gives one template's value type) requires exactly
|
|
2444
2468
|
one component per block template name when written as an object literal. See
|
|
2445
|
-
[Block Component Registries](https://github.com/safeinsights/canopycms/blob/
|
|
2469
|
+
[Block Component Registries](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/README.md#block-component-registries) and
|
|
2446
2470
|
`apps/example1/app/components/PostView.tsx`.
|
|
2447
2471
|
|
|
2448
2472
|
```ts
|
|
@@ -2464,7 +2488,7 @@ templates against the schema.
|
|
|
2464
2488
|
|
|
2465
2489
|
**What changed.** Spreading a `const` field array into several schemas, and nesting
|
|
2466
2490
|
`defineInlineFieldGroup()` inside a block template, are documented
|
|
2467
|
-
([Reusable Field Fragments](https://github.com/safeinsights/canopycms/blob/
|
|
2491
|
+
([Reusable Field Fragments](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/README.md#reusable-field-fragments)); `defineFieldFragment()` is an
|
|
2468
2492
|
identity helper for them.
|
|
2469
2493
|
|
|
2470
2494
|
```ts
|
|
@@ -2483,7 +2507,7 @@ field by composing from the same `const` field object.
|
|
|
2483
2507
|
A block template holding a `reference` field is a shared block; `read()`/`readByUrlPath()` resolve
|
|
2484
2508
|
it, and listings do with
|
|
2485
2509
|
[`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/
|
|
2510
|
+
(0.0.64). See [Shared / Referenced Blocks](https://github.com/safeinsights/canopycms/blob/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/README.md#shared--referenced-blocks).
|
|
2487
2511
|
|
|
2488
2512
|
**Now deletable.** A second `read()` in page code to unwrap a shared block's reference.
|
|
2489
2513
|
|
|
@@ -2505,7 +2529,7 @@ Not retro-documented, apart from these:
|
|
|
2505
2529
|
|
|
2506
2530
|
#### The registry is keyed by entry-type name (0.0.42)
|
|
2507
2531
|
|
|
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/
|
|
2532
|
+
**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/3576327ebf2ba4ab163b234d3f1e36318ff1c37f/README.md#convention-why-key-the-registry-by-entry-type-name) says when to keep them.
|
|
2509
2533
|
|
|
2510
2534
|
**To adopt.**
|
|
2511
2535
|
|
package/dist/ai/generate.d.ts
CHANGED
|
@@ -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
|
*
|
package/dist/ai/generate.js
CHANGED
|
@@ -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 {
|
|
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,
|
|
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
|
|
321
|
-
*
|
|
322
|
-
*
|
|
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
|
-
|
|
330
|
-
|
|
331
|
-
|
|
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) {
|
package/dist/ai/handler.js
CHANGED
package/dist/ai/types.d.ts
CHANGED
|
@@ -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
|
-
*
|
|
67
|
-
*
|
|
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:
|
|
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',
|