canopycms 0.3.2 → 0.4.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 +83 -41
- package/dist/ai/generate.js +11 -4
- package/dist/ai/types.d.ts +3 -2
- package/dist/cli/cli.js +46 -29
- package/dist/cli/generate-ai-content.js +47 -30
- package/dist/config/types.d.ts +8 -8
- package/dist/content-store.d.ts +5 -4
- package/dist/content-store.js +12 -7
- package/dist/editor/fields/gfm-autolink-literal.d.ts +11 -0
- package/dist/editor/fields/gfm-autolink-literal.js +45 -0
- package/dist/editor/fields/markdown-fidelity-visitors.d.ts +2 -3
- package/dist/editor/fields/markdown-fidelity-visitors.js +88 -3
- package/dist/entry-schema.d.ts +16 -6
- package/dist/entry-schema.js +3 -1
- package/dist/utils/body-field.d.ts +9 -1
- package/dist/utils/body-field.js +18 -1
- package/dist/utils/markdown-body-splice.js +3 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -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.4.0`, built from [`184d5c6`](https://github.com/safeinsights/canopycms/tree/184d5c62b8158d1fdcfbd85430f17f90aceec00c).
|
|
9
9
|
|
|
10
|
-
Its entries are [0.
|
|
10
|
+
Its entries are [0.4.0](#040), 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/184d5c62b8158d1fdcfbd85430f17f90aceec00c/.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,48 @@ entries under **Released**.
|
|
|
62
62
|
|
|
63
63
|
## Released
|
|
64
64
|
|
|
65
|
+
### 0.4.0
|
|
66
|
+
|
|
67
|
+
#### Link-only references to json/yaml entries leave out the body — **behaviour change (resolved data and types)**
|
|
68
|
+
|
|
69
|
+
<!-- changeset: link-only-references-omit-data-body -->
|
|
70
|
+
|
|
71
|
+
_First in 0.4.0._
|
|
72
|
+
|
|
73
|
+
**What changed.** A reference field without `includeBody: true` now resolves a json or yaml
|
|
74
|
+
target without that target's `isBody` field, as it already resolved an md/mdx target without its
|
|
75
|
+
body. A long body is no longer copied into every entry that merely links to it. A field that is
|
|
76
|
+
only named `body`, with no `isBody`, is ordinary data and still resolves. The live-preview resolve
|
|
77
|
+
endpoint and the AI export's `referenceLink` target follow the same rule, and `referenceLink`
|
|
78
|
+
now receives a json/yaml target's `isBody` field as `context.body`. Live preview resolves every
|
|
79
|
+
reference link-only, so an `includeBody: true` reference to a json/yaml target now previews
|
|
80
|
+
without its body, as one to an md/mdx target already did.
|
|
81
|
+
|
|
82
|
+
With `resolvedSchema`, the target's `isBody` field is now optional in the resolved type unless
|
|
83
|
+
the reference sets `includeBody: true`. This applies to md/mdx targets too, which already
|
|
84
|
+
resolved without it.
|
|
85
|
+
|
|
86
|
+
**To adopt.** Where a reference renders its target's prose, set `includeBody: true` on that
|
|
87
|
+
reference field. Code that reads the body from a link-only reference's resolved type now sees
|
|
88
|
+
`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).
|
|
90
|
+
|
|
91
|
+
### 0.3.3
|
|
92
|
+
|
|
93
|
+
#### Bare URLs in a markdown body survive a save
|
|
94
|
+
|
|
95
|
+
<!-- changeset: bare-urls-keep-their-text -->
|
|
96
|
+
|
|
97
|
+
_First in 0.3.3._
|
|
98
|
+
|
|
99
|
+
**What changed.** The rich-text editor reads a bare URL (`www.example.org`, `https://example.org`
|
|
100
|
+
or an email address) as GFM does. Opening an entry no longer marks it modified, and saving a
|
|
101
|
+
frontmatter change keeps the body byte for byte. Before, every bare URL was rewritten as an
|
|
102
|
+
explicit link, and a sentence's period went into the href (`[www.example.org.](https://www.example.org.)`).
|
|
103
|
+
A URL typed in the editor is saved with the trailing punctuation GFM leaves out of a link
|
|
104
|
+
(`.`, `,`, `:`, `;`, `!`, `?`, `*`, `_`, `~`, an unbalanced `)`) outside it. Editing a bare URL's
|
|
105
|
+
text updates its href; a bare URL given a label keeps its link.
|
|
106
|
+
|
|
65
107
|
### 0.3.2
|
|
66
108
|
|
|
67
109
|
#### The content panel's header lines up with the entry header
|
|
@@ -455,7 +497,7 @@ URL.
|
|
|
455
497
|
2. For a branch preview: wrap views with `withCanopyPreview` in a `'use client'` module, add
|
|
456
498
|
`app/preview/[[...path]]/page.server.tsx`, set `editor.previewPrefix: '/preview'`, and serve that
|
|
457
499
|
route with `frame-ancestors 'self'`, not `X-Frame-Options: DENY` (see
|
|
458
|
-
[Live Preview](https://github.com/safeinsights/canopycms/blob/
|
|
500
|
+
[Live Preview](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/README.md#live-preview)).
|
|
459
501
|
3. A test reading view content from the route's server HTML must load the page in a browser.
|
|
460
502
|
Server output rendered during a preview request carries the signed-in asset prefix; keep it out
|
|
461
503
|
of cross-request caches (`unstable_cache`, module memos).
|
|
@@ -470,7 +512,7 @@ kept site styles ahead of Mantine's in the preview.
|
|
|
470
512
|
server components. A string path marks the form's spelling (`'a.0.b'` marks `a[0].b`), and an empty
|
|
471
513
|
path marks nothing. The editor counts and logs marks naming no field. `createEntrySchemaRegistry`
|
|
472
514
|
refuses a field name that is empty, all digits or contains `.`, `[` or `]`. See
|
|
473
|
-
[Live Preview](https://github.com/safeinsights/canopycms/blob/
|
|
515
|
+
[Live Preview](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/README.md#live-preview).
|
|
474
516
|
|
|
475
517
|
**To adopt.** Fix each path that stops compiling; the error lists valid ones. Rewrite computed paths
|
|
476
518
|
as literal segments, or type that component's prop as plain `FieldProps`. Pass `fieldProps` as
|
|
@@ -552,7 +594,7 @@ or a failed render) renders as its plain text, with no URL; any other form of th
|
|
|
552
594
|
fields are nested or renamed, pass the AI config's `seo` the same object you pass
|
|
553
595
|
`createNextCanopyContext({ seo })`, so the sitemap and AI content read the flag from the same
|
|
554
596
|
place. A field that links to a hidden section by plain URL needs a field transform; the README
|
|
555
|
-
shows [the recipe](https://github.com/safeinsights/canopycms/blob/
|
|
597
|
+
shows [the recipe](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/README.md#ai-content-configuration).
|
|
556
598
|
|
|
557
599
|
**Now deletable.** An `exclude.where` that re-read the `noindex` flag by hand.
|
|
558
600
|
|
|
@@ -574,7 +616,7 @@ A `markdown` field with `renderAs: 'mdx'` is checked as MDX, and `mdxAllow` narr
|
|
|
574
616
|
field or site-wide. New: field options `renderAs`, `mdxAllow`; config key `mdxAllow`; type
|
|
575
617
|
`MdxAllowlist`. (int.110) A component prop allowance can be `'string'` (or
|
|
576
618
|
`{ type: 'string', maxLength }`): a quoted value only, never bare or `{…}`. See
|
|
577
|
-
[MDX content cannot run code](https://github.com/safeinsights/canopycms/blob/
|
|
619
|
+
[MDX content cannot run code](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/README.md#mdx-content-cannot-run-code).
|
|
578
620
|
|
|
579
621
|
**To adopt.** Set `renderAs: 'mdx'` on each `markdown` field your site compiles as MDX, and
|
|
580
622
|
`mdxAllow` to what your renderer takes. Set `executable: true` only on a field whose editors you
|
|
@@ -711,7 +753,7 @@ a format check.
|
|
|
711
753
|
|
|
712
754
|
- (int.93) Submit commits gain an `Edited-by: Name (id)` trailer; PR bodies gain a section that
|
|
713
755
|
re-submits replace, keeping human text. Options: `gitEditedByTrailers`, `gitCoAuthoredByTrailers`
|
|
714
|
-
([reference](https://github.com/safeinsights/canopycms/blob/
|
|
756
|
+
([reference](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/README.md#definecanopyconfig-options)).
|
|
715
757
|
- (int.110) Submit-commit trailers name every user who saved since the last submit commit, and
|
|
716
758
|
the PR-body section every user who edited the branch, not only the submitter; settings commits
|
|
717
759
|
(permissions, groups) carry the acting user's trailer.
|
|
@@ -735,7 +777,7 @@ saves only push the branch, and no failing PR task lands in System health.
|
|
|
735
777
|
that entry type goes unavailable: the editor says so, and its entries answer 503 with
|
|
736
778
|
`code: 'SCHEMA_UNAVAILABLE'`. Builds, static deploys and `generate-ai-content` still fail. The
|
|
737
779
|
worker holds the base branch for up to 30 minutes while that lasts; see
|
|
738
|
-
[New schemas wait for the editor deploy](https://github.com/safeinsights/canopycms/blob/
|
|
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).
|
|
739
781
|
Public types gain optional `unavailable` on `EntryTypeConfig` and `FlatSchemaItem`, optional
|
|
740
782
|
`ApiResponse.code`, and a required `SchemaResolutionResult.issues`.
|
|
741
783
|
|
|
@@ -773,7 +815,7 @@ hang until the drain heartbeat lets termination continue. Its in-flight task is
|
|
|
773
815
|
new stack needs no steps.
|
|
774
816
|
|
|
775
817
|
**What changed.** (int.109) Detailed in
|
|
776
|
-
[The worker instance](https://github.com/safeinsights/canopycms/blob/
|
|
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
|
|
777
819
|
bundle is one file whose sha256 user data checks, readable as that one object; a file-system policy
|
|
778
820
|
refusing clients without TLS or IAM, replacing the worker's
|
|
779
821
|
`AmazonElasticFileSystemClientReadWriteAccess`; an encrypted gp3 root volume; a boot-time upgrade to
|
|
@@ -827,10 +869,10 @@ failure and exits non-zero on `selfStopped`, with a code outside `RestartPrevent
|
|
|
827
869
|
with its hash, as `worker/dist/index.js` and `index.js.sha256`. The default, `'asset'`, is
|
|
828
870
|
unchanged.
|
|
829
871
|
- `CanopyCmsService` alarms when the worker logs no git sync for 30 minutes. See
|
|
830
|
-
[Worker-down alarm](https://github.com/safeinsights/canopycms/blob/
|
|
872
|
+
[Worker-down alarm](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/docs/deploying-to-aws.md#worker-down-alarm).
|
|
831
873
|
|
|
832
874
|
**To adopt.** Optional. For parameter-only change sets, see
|
|
833
|
-
[Rolling the worker from CI](https://github.com/safeinsights/canopycms/blob/
|
|
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
|
|
834
876
|
`alarmTopic`.
|
|
835
877
|
|
|
836
878
|
**Now deletable.** A manual `cdk deploy` after each canopycms bump whose only purpose is moving the
|
|
@@ -841,7 +883,7 @@ worker, and a hand-built alarm on the worker log group.
|
|
|
841
883
|
**What changed.** (int.112) The boot's `dnf upgrade` could be OOM-killed on every retry. A 1 GiB
|
|
842
884
|
swap file now goes on first; an upgrade that still fails starts the worker unpatched and notifies
|
|
843
885
|
`alarmTopic` if set; a retried step names itself when it gives up. See
|
|
844
|
-
[The worker instance](https://github.com/safeinsights/canopycms/blob/
|
|
886
|
+
[The worker instance](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/docs/deploying-to-aws.md#the-worker-instance).
|
|
845
887
|
|
|
846
888
|
**To adopt.** Deploy, which replaces the worker instance. The bundle needs none of this, so it is
|
|
847
889
|
not Template first and the worker contract stays at 1.
|
|
@@ -907,7 +949,7 @@ and operations may reuse GitHub fetches under 30 seconds old.
|
|
|
907
949
|
|
|
908
950
|
**To adopt.** Nothing. Seeding `remote.git` stages a copy of the repository beside the gateway's
|
|
909
951
|
mirror, so the root volume needs room for two
|
|
910
|
-
([details](https://github.com/safeinsights/canopycms/blob/
|
|
952
|
+
([details](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/docs/deploying-to-aws.md#the-worker-instance)).
|
|
911
953
|
|
|
912
954
|
#### The worker follows a rebased or deleted GitHub branch
|
|
913
955
|
|
|
@@ -929,7 +971,7 @@ changes the template too (the fallback bundle's key and hash), so only the contr
|
|
|
929
971
|
bundle-only roll is safe.
|
|
930
972
|
|
|
931
973
|
**To adopt.** Parameter mode: gate bundle-only rolls on the contract
|
|
932
|
-
([recipe](https://github.com/safeinsights/canopycms/blob/
|
|
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
|
|
933
975
|
`WorkerContract` output, so `cdk deploy` the template once, which adds it. A hand-installed unit
|
|
934
976
|
copies its `Environment=CANOPYCMS_WORKER_CONTRACT=` line from `worker/canopy-worker.service`.
|
|
935
977
|
|
|
@@ -946,8 +988,8 @@ units from the bundle's contract: 2 gets the split, an older bundle the single u
|
|
|
946
988
|
template, then roll the bundle; on an older template it stops with `template too old for this
|
|
947
989
|
bundle`. Inspect EFS only through `sudo /opt/canopy-worker/canopy-inspect <command>`, never from a root shell. A hand install
|
|
948
990
|
takes `worker/`'s three units and `gateway.env.example`
|
|
949
|
-
([steps](https://github.com/safeinsights/canopycms/blob/
|
|
950
|
-
[checklist](https://github.com/safeinsights/canopycms/blob/
|
|
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).
|
|
951
993
|
|
|
952
994
|
#### `canopycms-cdk`: `CanopyCmsService.attachTo`, and editor response headers — **behaviour change if you frame the CMS**
|
|
953
995
|
|
|
@@ -958,7 +1000,7 @@ response headers policy. `CanopyCmsDistribution` sends the same headers: `frame-
|
|
|
958
1000
|
`X-Frame-Options: SAMEORIGIN`, `nosniff`, HSTS and `X-Robots-Tag: noindex`. Unless your app sends
|
|
959
1001
|
its own framing headers, no other origin can frame the editor or any page the CMS domain serves. Every such page is
|
|
960
1002
|
marked `noindex`. The editor's default preview is same-origin and unaffected. See
|
|
961
|
-
[Serving the editor from a distribution you already own](https://github.com/safeinsights/canopycms/blob/
|
|
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).
|
|
962
1004
|
|
|
963
1005
|
**To adopt.** If you wired the Function URL into your own distribution by hand, delete those
|
|
964
1006
|
behaviors and call `attachTo`, passing your CMS build's `assetPrefix` as `editorAssetPrefix` and a
|
|
@@ -1134,7 +1176,7 @@ one the exclusions leave out. A throw or any other return is logged and treated
|
|
|
1134
1176
|
**To adopt.** If your site's routes, sitemap or bylines decide that some entries have no page,
|
|
1135
1177
|
apply the same rule here, for example `referenceLink: (target, { body }) =>
|
|
1136
1178
|
!body?.trim() ? false : undefined` in `defineAIContentConfig` from `canopycms/ai`. See
|
|
1137
|
-
[AI Content Configuration](https://github.com/safeinsights/canopycms/blob/
|
|
1179
|
+
[AI Content Configuration](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/README.md#ai-content-configuration).
|
|
1138
1180
|
|
|
1139
1181
|
**Now deletable.** A `fieldTransforms` entry that re-renders a reference field only to drop or
|
|
1140
1182
|
change its link.
|
|
@@ -1209,7 +1251,7 @@ _First in int.115._
|
|
|
1209
1251
|
entry the base branch also changed, the "updated on the base branch" notice and the branch's
|
|
1210
1252
|
conflict count now stay until the branch merges, so a reviewer still sees which entries replaced a
|
|
1211
1253
|
base change. They used to clear on the next sync, about five minutes later. README's new [Drafts
|
|
1212
|
-
and Unpublishing](https://github.com/safeinsights/canopycms/blob/
|
|
1254
|
+
and Unpublishing](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/README.md#drafts-and-unpublishing) section covers long-lived branches and
|
|
1213
1255
|
unpublishing.
|
|
1214
1256
|
|
|
1215
1257
|
#### The editor calls the content drawer "All content"
|
|
@@ -1521,7 +1563,7 @@ editor carries an unsaved draft of a stamped entry onto its stamped version.
|
|
|
1521
1563
|
The flag is refused off a top-level `datetime`, on `list: true`, and with `required: true`.
|
|
1522
1564
|
|
|
1523
1565
|
**To adopt.** Add `stampOnPublish: true` to the date field your site sorts or labels by, such as
|
|
1524
|
-
`{ name: 'publishedAt', type: 'datetime', stampOnPublish: true }`. See [Stamping a publication date](https://github.com/safeinsights/canopycms/blob/
|
|
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).
|
|
1525
1567
|
|
|
1526
1568
|
**Now deletable.** A build step or hook that writes a missing publication date into new entries.
|
|
1527
1569
|
|
|
@@ -1568,7 +1610,7 @@ preview/form divider is now keyboard-resizable within the same 15–85% the spli
|
|
|
1568
1610
|
stored at, and `react-split-pane` is no longer a dependency.
|
|
1569
1611
|
`EditorPanes`, `EditorPanesProps`, the `PaneLayout` type and the `SPLIT_PERCENT_*` and `DEFAULT_*_SPLIT_PERCENT` constants are
|
|
1570
1612
|
no longer exported from `canopycms/client`. See
|
|
1571
|
-
[Your root layout](https://github.com/safeinsights/canopycms/blob/
|
|
1613
|
+
[Your root layout](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/README.md#editor-customization).
|
|
1572
1614
|
|
|
1573
1615
|
**To adopt.** Nothing, unless you import `EditorPanes` or those constants: render `CanopyEditor`
|
|
1574
1616
|
instead, which lays out its own panes. Hiding your site chrome on the editor route is now
|
|
@@ -1679,7 +1721,7 @@ never ended. `canopycms-auth-clerk` skips it while the editor is mounted, and ex
|
|
|
1679
1721
|
**To adopt.** Nothing for the editor, if your edit page uses `useClerkAuthConfig()` or
|
|
1680
1722
|
`ClerkSignIn`. If your CMS build renders `<SignIn>`, `UserButton` or `OrganizationSwitcher` on your
|
|
1681
1723
|
own pages, mount the hook as in
|
|
1682
|
-
[Clerk components on your own pages](https://github.com/safeinsights/canopycms/blob/
|
|
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).
|
|
1683
1725
|
Your own Server Actions in the CMS build still 403 behind OAC.
|
|
1684
1726
|
|
|
1685
1727
|
**Now deletable.** Any local patch of `window.__internal_onBeforeSetActive` (or 6.x's
|
|
@@ -1720,12 +1762,12 @@ fast naming the ARN, the field and the keys present, never a value.
|
|
|
1720
1762
|
**To adopt.** Nothing, unless one of those secrets holds a JSON document: then set the matching
|
|
1721
1763
|
prop. The scaffolded stack fills them from the repository _variables_
|
|
1722
1764
|
`CANOPY_GITHUB_TOKEN_SECRET_JSON_FIELD` and `CLERK_SECRET_KEY_SECRET_JSON_FIELD`
|
|
1723
|
-
([why the prefix](https://github.com/safeinsights/canopycms/blob/
|
|
1765
|
+
([why the prefix](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/docs/deploying-to-aws.md#repository-secrets-and-variables)); a stack scaffolded earlier
|
|
1724
1766
|
adds the props to `infrastructure/bin/app.ts` and `infrastructure/lib/cms-stack.ts` and the two `env`
|
|
1725
1767
|
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
|
|
1726
1768
|
(also in `secretsArns`). Don't use CDK's `secretValueFromJson`: it resolves the plaintext into the deployed
|
|
1727
1769
|
resource's configuration, readable by anyone who can describe it. Only `CLERK_SECRET_KEY` goes through Secrets Manager; `CLERK_JWT_KEY` and the publishable
|
|
1728
|
-
key are public material ([Security Model](https://github.com/safeinsights/canopycms/blob/
|
|
1770
|
+
key are public material ([Security Model](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/docs/deploying-to-aws.md#security-model)).
|
|
1729
1771
|
|
|
1730
1772
|
**Now deletable.** A wrapper that fetches the secret, parses it and re-exports one field into the
|
|
1731
1773
|
worker's environment, such as a `jq` step in user data or a wrapper entrypoint around
|
|
@@ -1737,7 +1779,7 @@ worker's environment, such as a `jq` step in user data or a wrapper entrypoint a
|
|
|
1737
1779
|
`githubToken` is not deprecated and stays the documented default; `canopycms` neither depends on
|
|
1738
1780
|
nor imports `@octokit/auth-app`. Register one App per site, not one shared across repositories:
|
|
1739
1781
|
anyone holding an App's key can mint a token for any of its installations
|
|
1740
|
-
([why](https://github.com/safeinsights/canopycms/blob/
|
|
1782
|
+
([why](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/ARCHITECTURE.md#why-one-github-app-per-site-not-one-shared-across-an-organisation)).
|
|
1741
1783
|
|
|
1742
1784
|
**To adopt with `canopycms-cdk`** (existing stacks need no edit). `CanopyCmsServiceProps` takes
|
|
1743
1785
|
`githubAppId`, `githubAppInstallationId`, `githubAppPrivateKeySecretArn` and
|
|
@@ -1750,7 +1792,7 @@ anyone holding an App's key can mint a token for any of its installations
|
|
|
1750
1792
|
`verify` checks an existing installation's permissions: run it, since an App missing a
|
|
1751
1793
|
permission only shows up later, as `sync-failed`. `create` needs an interactive terminal and
|
|
1752
1794
|
never edits an existing JSON secret (create one and point the JSON-field prop at it)
|
|
1753
|
-
([details](https://github.com/safeinsights/canopycms/blob/
|
|
1795
|
+
([details](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/docs/deploying-to-aws.md#register-it-with-canopycms-init-github-app)).
|
|
1754
1796
|
2. Set the three props and **remove `githubTokenSecretArn`** (with its JSON field). A partial set
|
|
1755
1797
|
of the three is refused at synth, and so is an App alongside a token.
|
|
1756
1798
|
3. In the generated workflow, store them as `CANOPY_GITHUB_APP_ID`,
|
|
@@ -1761,7 +1803,7 @@ anyone holding an App's key can mint a token for any of its installations
|
|
|
1761
1803
|
|
|
1762
1804
|
The private key is ARN-only; passing the key itself is refused at synth. Its ARN joins the worker's
|
|
1763
1805
|
IAM policy automatically, so you need not add it to `secretsArns`. See
|
|
1764
|
-
[Authenticating as a GitHub App](https://github.com/safeinsights/canopycms/blob/
|
|
1806
|
+
[Authenticating as a GitHub App](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/docs/deploying-to-aws.md#authenticating-as-a-github-app).
|
|
1765
1807
|
|
|
1766
1808
|
```bash
|
|
1767
1809
|
canopycms init-github-app create -- \
|
|
@@ -1809,7 +1851,7 @@ downloads the `.pem` from the App's settings page.
|
|
|
1809
1851
|
|
|
1810
1852
|
**What changed.** The worker re-reads a Secrets Manager secret (the GitHub token or the Clerk secret
|
|
1811
1853
|
key) when the operation using it fails. Timings, costs and the store-before-revoke order are in
|
|
1812
|
-
[Rotating a secret](https://github.com/safeinsights/canopycms/blob/
|
|
1854
|
+
[Rotating a secret](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/docs/deploying-to-aws.md#rotating-a-secret).
|
|
1813
1855
|
|
|
1814
1856
|
**To adopt.** Nothing for credentials from `*_SECRET_ARN`, which is every scaffolded deployment. A
|
|
1815
1857
|
GitHub App private key is still read only at boot: store the new key, replace the instance, and
|
|
@@ -1863,12 +1905,12 @@ also check the bucket policy for its grant.
|
|
|
1863
1905
|
5. `withCanopy()` adds sharp's libvips to Next's file tracing (not for a static export) and, on
|
|
1864
1906
|
Next 16 and later, sets `turbopack: {}` when your config has neither `turbopack` nor your own
|
|
1865
1907
|
`webpack` and it can read your Next version. A webpack build still fails its image transforms
|
|
1866
|
-
([Dual Build Support](https://github.com/safeinsights/canopycms/blob/
|
|
1908
|
+
([Dual Build Support](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/docs/deploying-to-aws.md#dual-build-support)).
|
|
1867
1909
|
|
|
1868
1910
|
**Breaking:** a stack setting `platform` on `fromImageAsset` without `architecture` gets an arm64
|
|
1869
1911
|
function while `platform` still decides the image, so `Platform.LINUX_AMD64` builds an image the
|
|
1870
1912
|
function cannot run. A stack setting neither moves to arm64 with a matching image, built under QEMU
|
|
1871
|
-
on an x86 host ([Where the image is built](https://github.com/safeinsights/canopycms/blob/
|
|
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)).
|
|
1872
1914
|
|
|
1873
1915
|
**To adopt.**
|
|
1874
1916
|
|
|
@@ -1897,7 +1939,7 @@ reason; `platform` on `fromImageAsset`; and, with `withCanopy()`, a hand-written
|
|
|
1897
1939
|
|
|
1898
1940
|
**What changed.** `media.uploadUrl` (s3 adapter; an absolute http(s) URL or a site-relative path)
|
|
1899
1941
|
replaces the `url` that `beginUpload()` returns, leaving the presign's `fields` untouched, so
|
|
1900
|
-
uploads can be same-origin. See [Media Configuration](https://github.com/safeinsights/canopycms/blob/
|
|
1942
|
+
uploads can be same-origin. See [Media Configuration](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/README.md#media-configuration) for the
|
|
1901
1943
|
CloudFront behavior it expects.
|
|
1902
1944
|
|
|
1903
1945
|
**To adopt.** Optional. Set it from an environment variable: a site-relative value works only where
|
|
@@ -1922,7 +1964,7 @@ needs `lazyPublicTransforms: true`) let you pass a deterministically named role,
|
|
|
1922
1964
|
bucket's stack computes `arn:aws:iam::<account>:role/<name>` from literals instead of a
|
|
1923
1965
|
`Fn::GetStackOutput` reference only the CDK CLI resolves. The constructs re-attach
|
|
1924
1966
|
`AWSLambdaBasicExecutionRole` (and the VPC policy) that `lambda.Function` drops from a role you
|
|
1925
|
-
pass. See [Cross-account asset bucket](https://github.com/safeinsights/canopycms/blob/
|
|
1967
|
+
pass. See [Cross-account asset bucket](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/docs/deploying-to-aws.md#cross-account-asset-bucket).
|
|
1926
1968
|
|
|
1927
1969
|
**To adopt.** Optional:
|
|
1928
1970
|
|
|
@@ -2032,7 +2074,7 @@ public JWKS PEM, used only to verify signatures.
|
|
|
2032
2074
|
to variables (Settings → Secrets and variables → Actions → Variables); `bin/app.ts` refuses the
|
|
2033
2075
|
deploy at synth while it is unset. Check that `bin/app.ts` passes `CLERK_SECRET_KEY` as
|
|
2034
2076
|
`clerkSecretKeySecretArn` (read by the worker), never in the Lambda's `environment`, unless you keep
|
|
2035
|
-
`clerkMiddleware` ([Security Model](https://github.com/safeinsights/canopycms/blob/
|
|
2077
|
+
`clerkMiddleware` ([Security Model](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/docs/deploying-to-aws.md#security-model)).
|
|
2036
2078
|
|
|
2037
2079
|
#### `readByUrlPath` answers only where `listEntries` publishes — **breaking (routing)**
|
|
2038
2080
|
|
|
@@ -2131,7 +2173,7 @@ basePath: process.env.NEXT_PUBLIC_BASE_PATH,
|
|
|
2131
2173
|
Then pass `baseUrl` to `assetUrl` only if Next serves `/assets` (local adapter, `next dev`, S3 with
|
|
2132
2174
|
no distribution): `assetUrl(image, { width: 960, baseUrl: BASE_PATH })`. Assets on CloudFront via
|
|
2133
2175
|
`AssetSupport` stay at the distribution root; pass no `baseUrl` (mount table under "Where `/assets`
|
|
2134
|
-
is mounted" in [Media Configuration](https://github.com/safeinsights/canopycms/blob/
|
|
2176
|
+
is mounted" in [Media Configuration](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/README.md#media-configuration)). Two traps:
|
|
2135
2177
|
|
|
2136
2178
|
- Don't pass a deployment `basePath` to `contentStaticParams({ basePath })`; that option filters by
|
|
2137
2179
|
a nested route prefix and emits zero params, building green.
|
|
@@ -2290,7 +2332,7 @@ Under `exactOptionalPropertyTypes: true`, omit keys instead of assigning `undefi
|
|
|
2290
2332
|
`withTrailingSlash` and `isAbsoluteUrl` from `canopycms/server`; `defineSeoFieldGroup()` from
|
|
2291
2333
|
`canopycms`; `generateContentSitemap` and `entryToMetadata` from `canopycms-next`, bound on
|
|
2292
2334
|
`createNextCanopyContext`'s result. See
|
|
2293
|
-
[Sitemap and SEO Metadata](https://github.com/safeinsights/canopycms/blob/
|
|
2335
|
+
[Sitemap and SEO Metadata](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/README.md#sitemap-and-seo-metadata). Every routable entry type is in
|
|
2294
2336
|
the sitemap unless `exclude`d or `noindex`; one `noindex` predicate drives both robots metadata and
|
|
2295
2337
|
sitemap exclusion. `trailingSlash` is never inferred. `lastModified` defaults to `updatedAt`, a
|
|
2296
2338
|
filesystem mtime. An empty SEO field counts as unset. `siteUrl` must be absolute, colliding URLs are
|
|
@@ -2347,7 +2389,7 @@ underscore-prefixed files are skipped.
|
|
|
2347
2389
|
|
|
2348
2390
|
**What changed.** New scaffolds write `defaultBranchAccess: 'deny'` and
|
|
2349
2391
|
`defaultPathAccess: { read: 'allow' }`
|
|
2350
|
-
([Public read on server deployments](https://github.com/safeinsights/canopycms/blob/
|
|
2392
|
+
([Public read on server deployments](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/README.md#public-read-on-server-deployments)).
|
|
2351
2393
|
|
|
2352
2394
|
**To adopt.** An older scaffold's `defaultBranchAccess: 'allow'` is wider than recommended;
|
|
2353
2395
|
consider `'deny'`. If you deleted `defaultPathAccess: { read: 'allow' }`, anonymous visitors get no content until you
|
|
@@ -2400,7 +2442,7 @@ re-checked an entry's type (a `switch` on `meta.entryType` can merge them into o
|
|
|
2400
2442
|
**What changed.** `BlockComponentRegistry<Blocks>` (types only, from `canopycms`; `BlockValueOf<Blocks, 'hero'>`
|
|
2401
2443
|
gives one template's value type) requires exactly
|
|
2402
2444
|
one component per block template name when written as an object literal. See
|
|
2403
|
-
[Block Component Registries](https://github.com/safeinsights/canopycms/blob/
|
|
2445
|
+
[Block Component Registries](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/README.md#block-component-registries) and
|
|
2404
2446
|
`apps/example1/app/components/PostView.tsx`.
|
|
2405
2447
|
|
|
2406
2448
|
```ts
|
|
@@ -2422,7 +2464,7 @@ templates against the schema.
|
|
|
2422
2464
|
|
|
2423
2465
|
**What changed.** Spreading a `const` field array into several schemas, and nesting
|
|
2424
2466
|
`defineInlineFieldGroup()` inside a block template, are documented
|
|
2425
|
-
([Reusable Field Fragments](https://github.com/safeinsights/canopycms/blob/
|
|
2467
|
+
([Reusable Field Fragments](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/README.md#reusable-field-fragments)); `defineFieldFragment()` is an
|
|
2426
2468
|
identity helper for them.
|
|
2427
2469
|
|
|
2428
2470
|
```ts
|
|
@@ -2441,7 +2483,7 @@ field by composing from the same `const` field object.
|
|
|
2441
2483
|
A block template holding a `reference` field is a shared block; `read()`/`readByUrlPath()` resolve
|
|
2442
2484
|
it, and listings do with
|
|
2443
2485
|
[`resolveReferences`](#listings-resolve-references-and-a-resolved-reference-carries-urlpath-and-optionally-its-body-16--breaking-type-level)
|
|
2444
|
-
(0.0.64). See [Shared / Referenced Blocks](https://github.com/safeinsights/canopycms/blob/
|
|
2486
|
+
(0.0.64). See [Shared / Referenced Blocks](https://github.com/safeinsights/canopycms/blob/184d5c62b8158d1fdcfbd85430f17f90aceec00c/README.md#shared--referenced-blocks).
|
|
2445
2487
|
|
|
2446
2488
|
**Now deletable.** A second `read()` in page code to unwrap a shared block's reference.
|
|
2447
2489
|
|
|
@@ -2463,7 +2505,7 @@ Not retro-documented, apart from these:
|
|
|
2463
2505
|
|
|
2464
2506
|
#### The registry is keyed by entry-type name (0.0.42)
|
|
2465
2507
|
|
|
2466
|
-
**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/
|
|
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.
|
|
2467
2509
|
|
|
2468
2510
|
**To adopt.**
|
|
2469
2511
|
|
package/dist/ai/generate.js
CHANGED
|
@@ -9,6 +9,7 @@ import path from 'node:path';
|
|
|
9
9
|
import fs from 'node:fs/promises';
|
|
10
10
|
import { minimatch } from 'minimatch';
|
|
11
11
|
import { isDataOnlyFormat } from '../utils/format.js';
|
|
12
|
+
import { findExplicitBodyFieldName, linkOnlyReferenceData } from '../utils/body-field.js';
|
|
12
13
|
import { extractEntryTypeFromFilename, extractIdFromFilename, } from '../content-id-index.js';
|
|
13
14
|
import { hasTraversalSequence } from '../paths/index.js';
|
|
14
15
|
import { getErrorMessage, isNodeError } from '../utils/error.js';
|
|
@@ -76,19 +77,24 @@ export async function generateAIContent(options) {
|
|
|
76
77
|
pendingById.set(pending.contentId, pending);
|
|
77
78
|
}
|
|
78
79
|
// The target as `resolveReferenceTarget` would give it, built from this export's own read, so
|
|
79
|
-
// an entry outside the export set is never offered and a target cannot change mid-run
|
|
80
|
+
// an entry outside the export set is never offered and a target cannot change mid-run. A
|
|
81
|
+
// json/yaml target's `isBody` field is its body here, as an md/mdx target's body is
|
|
80
82
|
const subjectOf = (id) => {
|
|
81
83
|
const pending = pendingById.get(id);
|
|
82
84
|
if (!pending || !exported.has(id))
|
|
83
85
|
return undefined;
|
|
84
|
-
const {
|
|
85
|
-
const
|
|
86
|
+
const { format } = pending;
|
|
87
|
+
const { slug, fields } = pending.entry;
|
|
88
|
+
const storedData = structuredClone(pending.storedData);
|
|
89
|
+
const target = buildResolvedReference(linkOnlyReferenceData(storedData, format, fields), {
|
|
86
90
|
id,
|
|
87
91
|
slug,
|
|
88
92
|
collection: pending.collectionPath,
|
|
89
93
|
urlPath: computeEntryUrl(pending.collectionPath, slug, contentRoot),
|
|
90
94
|
});
|
|
91
|
-
|
|
95
|
+
const dataBodyField = isDataOnlyFormat(format) ? findExplicitBodyFieldName(fields) : undefined;
|
|
96
|
+
const dataBody = dataBodyField === undefined ? undefined : storedData[dataBodyField];
|
|
97
|
+
return { target, body: pending.body ?? (typeof dataBody === 'string' ? dataBody : undefined) };
|
|
92
98
|
};
|
|
93
99
|
const linkFor = config?.referenceLink
|
|
94
100
|
? await decideReferenceLinks(config.referenceLink, allPending, subjectOf, entryLinkUrl)
|
|
@@ -254,6 +260,7 @@ async function collectEntries(read, collection, cleanPath) {
|
|
|
254
260
|
entry: aiEntry,
|
|
255
261
|
body,
|
|
256
262
|
storedData,
|
|
263
|
+
format: doc.format,
|
|
257
264
|
linkedIds: [],
|
|
258
265
|
contentId: extractIdFromFilename(path.basename(listEntry.relativePath)),
|
|
259
266
|
absolutePath: doc.absolutePath,
|
package/dist/ai/types.d.ts
CHANGED
|
@@ -208,8 +208,9 @@ export type EntryTransforms = Record<string, EntryTransformFn>;
|
|
|
208
208
|
/** What {@link AIReferenceLinkFn} knows about a target beyond its data. */
|
|
209
209
|
export interface AIReferenceLinkContext {
|
|
210
210
|
/**
|
|
211
|
-
* The target's
|
|
212
|
-
*
|
|
211
|
+
* The target's body as stored: an md/mdx entry's body, or a json/yaml entry's `isBody` field,
|
|
212
|
+
* which the target leaves out as a link-only reference does. `undefined` when it has none. It
|
|
213
|
+
* only informs this decision: none of it reaches the entries that link to the target.
|
|
213
214
|
*/
|
|
214
215
|
body: string | undefined;
|
|
215
216
|
/**
|