@forumone/throughline-publishing 0.3.0 → 0.3.2
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 +34 -0
- package/README.md +47 -1
- package/dist/admin/PublishButton.d.ts.map +1 -1
- package/dist/admin/PublishButton.js +21 -4
- package/dist/admin/PublishButton.js.map +1 -1
- package/dist/admin/UnpublishButton.d.ts.map +1 -1
- package/dist/admin/UnpublishButton.js +10 -1
- package/dist/admin/UnpublishButton.js.map +1 -1
- package/dist/admin/publishing-client.d.ts +2 -0
- package/dist/admin/publishing-client.d.ts.map +1 -1
- package/dist/admin/publishing-client.js.map +1 -1
- package/dist/checks/alt-text.d.ts +8 -2
- package/dist/checks/alt-text.d.ts.map +1 -1
- package/dist/checks/alt-text.js +13 -3
- package/dist/checks/alt-text.js.map +1 -1
- package/dist/events.d.ts +16 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +30 -0
- package/dist/events.js.map +1 -0
- package/dist/hooks/block-status-writes.d.ts +11 -2
- package/dist/hooks/block-status-writes.d.ts.map +1 -1
- package/dist/hooks/block-status-writes.js +24 -3
- package/dist/hooks/block-status-writes.js.map +1 -1
- package/dist/hooks/draft-writes.d.ts +32 -0
- package/dist/hooks/draft-writes.d.ts.map +1 -0
- package/dist/hooks/draft-writes.js +76 -0
- package/dist/hooks/draft-writes.js.map +1 -0
- package/dist/options.d.ts +9 -0
- package/dist/options.d.ts.map +1 -1
- package/dist/options.js.map +1 -1
- package/dist/pipeline/index.d.ts.map +1 -1
- package/dist/pipeline/index.js +9 -1
- package/dist/pipeline/index.js.map +1 -1
- package/dist/pipeline/steps/accessibility.d.ts +4 -0
- package/dist/pipeline/steps/accessibility.d.ts.map +1 -1
- package/dist/pipeline/steps/accessibility.js +6 -1
- package/dist/pipeline/steps/accessibility.js.map +1 -1
- package/dist/pipeline/steps/execute.d.ts +4 -0
- package/dist/pipeline/steps/execute.d.ts.map +1 -1
- package/dist/pipeline/steps/execute.js +9 -2
- package/dist/pipeline/steps/execute.js.map +1 -1
- package/dist/pipeline/types.d.ts +7 -0
- package/dist/pipeline/types.d.ts.map +1 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +10 -2
- package/dist/plugin.js.map +1 -1
- package/dist/service.d.ts +8 -1
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +23 -3
- package/dist/service.js.map +1 -1
- package/dist/tools/rollback.d.ts.map +1 -1
- package/dist/tools/rollback.js +5 -1
- package/dist/tools/rollback.js.map +1 -1
- package/dist/tools/schedule-publish.d.ts.map +1 -1
- package/dist/tools/schedule-publish.js +9 -2
- package/dist/tools/schedule-publish.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# @forumone/throughline-publishing
|
|
2
2
|
|
|
3
|
+
## 0.3.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 4eeb721: Fix published documents being uneditable: allow draft writes through the trust boundary.
|
|
8
|
+
|
|
9
|
+
Editing an already-published document failed with `Direct writes to _status are not allowed` — from both the plugin's own Publish button and Payload's native Save Draft, which discarded the editor's work. Only first publishes worked, because an unmodified document skips the draft save.
|
|
10
|
+
|
|
11
|
+
Payload sets `data._status = 'draft'` on every `draft: true` update _before_ `beforeChange` runs, whether or not the caller supplied it. By the time the hook saw the write, saving a draft of a published document was indistinguishable from unpublishing it: `data._status` was `'draft'` and `originalDoc._status` was `'published'` in both cases. A draft save writes a version and leaves the live document alone, so it should never have been blocked.
|
|
12
|
+
|
|
13
|
+
The plugin now installs a `beforeOperation` hook that records the operation's own `draft` argument, which `beforeChange` reads to tell the two apart. That argument is visible identically on the Local API, REST and GraphQL, unlike `req.query.draft`, which is only populated on the REST path.
|
|
14
|
+
|
|
15
|
+
A `draft: true` request that sets `_status: 'published'` is still blocked — Payload's own `isSavingDraft` excludes it, so it is a real publish and belongs in the pipeline. Genuine unpublishes and direct publishes are unchanged. Installing the status-write hook without the recorder fails closed.
|
|
16
|
+
|
|
17
|
+
- 4eeb721: Fix two defects reported against 0.3.0.
|
|
18
|
+
|
|
19
|
+
**The `alt-text` check false-positived on Payload upload derivatives.** `walkForImages` descended into a populated upload's `sizes` map, and every generated size carries `filename` and `mimeType` but never `alt` — that lives on the parent document. Each configured `imageSize` therefore produced one false failure, and any page carrying a sized image could not be published. The walk now skips `sizes` on an object that is itself an image; alt text is checked once, on the parent. A parent with missing or empty alt still fails, at the parent's path, and a host with no `imageSizes` is unaffected.
|
|
20
|
+
|
|
21
|
+
**A failed Inngest emission failed a publish that had already succeeded.** The event is sent after the document is written, so a transport failure (an invalid `INNGEST_EVENT_KEY`, say) returned 500 for a document that was published — and lost the audit record for it. Publish, unpublish, rollback and `schedule_publish` now report success and carry the emission failure as a `warnings` array on the result. The admin renders it as a warning toast on an otherwise successful publish.
|
|
22
|
+
|
|
23
|
+
Also adds `disableAccessibilityChecks`, naming built-in checks to skip. `accessibilityChecks` only appends, so previously a built-in that misfired on a host's content shape blocked every publish until the plugin shipped a fix.
|
|
24
|
+
|
|
25
|
+
## 0.3.1
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- fc5c236: Fix two defects reported against 0.3.0.
|
|
30
|
+
|
|
31
|
+
**The `alt-text` check false-positived on Payload upload derivatives.** `walkForImages` descended into a populated upload's `sizes` map, and every generated size carries `filename` and `mimeType` but never `alt` — that lives on the parent document. Each configured `imageSize` therefore produced one false failure, and any page carrying a sized image could not be published. The walk now skips `sizes` on an object that is itself an image; alt text is checked once, on the parent. A parent with missing or empty alt still fails, at the parent's path, and a host with no `imageSizes` is unaffected.
|
|
32
|
+
|
|
33
|
+
**A failed Inngest emission failed a publish that had already succeeded.** The event is sent after the document is written, so a transport failure (an invalid `INNGEST_EVENT_KEY`, say) returned 500 for a document that was published — and lost the audit record for it. Publish, unpublish, rollback and `schedule_publish` now report success and carry the emission failure as a `warnings` array on the result. The admin renders it as a warning toast on an otherwise successful publish.
|
|
34
|
+
|
|
35
|
+
Also adds `disableAccessibilityChecks`, naming built-in checks to skip. `accessibilityChecks` only appends, so previously a built-in that misfired on a host's content shape blocked every publish until the plugin shipped a fix.
|
|
36
|
+
|
|
3
37
|
## 0.3.0
|
|
4
38
|
|
|
5
39
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -96,6 +96,25 @@ if (!result.published) {
|
|
|
96
96
|
|
|
97
97
|
All three run the same pipeline the admin and MCP paths use, so host code cannot drift from the plugin's policy. `getPublishStatus` runs every check except the write and mutates nothing.
|
|
98
98
|
|
|
99
|
+
## What the trust boundary blocks
|
|
100
|
+
|
|
101
|
+
The plugin installs two hooks on every configured collection, and they work as a pair:
|
|
102
|
+
|
|
103
|
+
- `beforeOperation` records whether the update in flight is a draft write.
|
|
104
|
+
- `beforeChange` rejects writes that change the **live** document's `_status`.
|
|
105
|
+
|
|
106
|
+
| Write | Result |
|
|
107
|
+
|---|---|
|
|
108
|
+
| `draft: true` on a draft or published document | **allowed** — writes a version, live status unchanged |
|
|
109
|
+
| `draft: false`, `_status: 'published'` | **blocked** — publish through the pipeline |
|
|
110
|
+
| `draft: false`, `_status: 'draft'` on a published document | **blocked** — unpublish through the pipeline |
|
|
111
|
+
| `draft: true` with `_status: 'published'` | **blocked** — Payload treats this as a publish, not a draft save |
|
|
112
|
+
| Any write carrying `bypassPublishingServer` | **allowed** |
|
|
113
|
+
|
|
114
|
+
Draft saves have to be allowed explicitly because Payload sets `data._status = 'draft'` on every `draft: true` update before `beforeChange` runs, whether or not the caller supplied it — so at that point a draft save of a published document and an unpublish look identical. The `draft` flag is read from the operation's own arguments in `beforeOperation`, which sees it the same way on the Local API, REST and GraphQL. (`req.query.draft` is only populated on the REST path, so keying on the request would cover the admin and silently miss scripts.)
|
|
115
|
+
|
|
116
|
+
If you install `createBlockStatusWritesHook` yourself without the recorder, it fails closed: every status change is blocked.
|
|
117
|
+
|
|
99
118
|
## Bypassing the pipeline
|
|
100
119
|
|
|
101
120
|
`bypassPublishingServer: true` in the Payload request context is the only way to write `_status` without the pipeline. It is intended for seed scripts and migrations:
|
|
@@ -113,9 +132,21 @@ It skips composition, accessibility, required-field, embargo, and approval check
|
|
|
113
132
|
|
|
114
133
|
> **Note:** the hook guards `update` only. `payload.create({ data: { _status: 'published' } })` is not intercepted, so a create can publish without the pipeline. Save as a draft and publish in a second step if that matters to you.
|
|
115
134
|
|
|
135
|
+
## Warnings
|
|
136
|
+
|
|
137
|
+
A publish or unpublish writes the document first, then emits its Inngest event. The event is a consequence of the write, not a step in it — so if the emission fails, the action still reports success and carries a warning:
|
|
138
|
+
|
|
139
|
+
```jsonc
|
|
140
|
+
{ "published": true, "publishedAt": "…", "warnings": ["The content/page.published event could not be sent, …"] }
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
The admin shows these as a warning toast on an otherwise successful publish. Reporting failure for a write that landed would tell an editor their change isn't live when it is, and the obvious response to that is to publish again over live content.
|
|
144
|
+
|
|
145
|
+
`rollback` and `schedule_publish` behave the same way.
|
|
146
|
+
|
|
116
147
|
## Custom accessibility checks
|
|
117
148
|
|
|
118
|
-
The built-in checks (alt
|
|
149
|
+
The built-in checks (`alt-text`, `heading-hierarchy`, `link-labels`) are exported from `@forumone/throughline-publishing/checks`. Add your own via `accessibilityChecks`:
|
|
119
150
|
|
|
120
151
|
```ts
|
|
121
152
|
publishingPlugin({
|
|
@@ -129,3 +160,18 @@ publishingPlugin({
|
|
|
129
160
|
],
|
|
130
161
|
})
|
|
131
162
|
```
|
|
163
|
+
|
|
164
|
+
`accessibilityChecks` appends. To switch a built-in off — because it misfires on your content shape, or you want to replace it — name it in `disableAccessibilityChecks`:
|
|
165
|
+
|
|
166
|
+
```ts
|
|
167
|
+
publishingPlugin({
|
|
168
|
+
inngest,
|
|
169
|
+
collections: [{ slug: 'pages' }],
|
|
170
|
+
disableAccessibilityChecks: ['alt-text'],
|
|
171
|
+
accessibilityChecks: [myOwnAltTextCheck],
|
|
172
|
+
})
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### A note on uploads
|
|
176
|
+
|
|
177
|
+
The `alt-text` check walks the document for image-shaped objects but does **not** descend into a populated upload's `sizes` map. Payload's generated derivatives carry `filename` and `mimeType` but never `alt` — that lives on the parent document — so treating them as images would report one false failure per configured `imageSize`. Alt text is checked once, on the parent.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PublishButton.d.ts","sourceRoot":"","sources":["../../src/admin/PublishButton.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAgC,MAAM,OAAO,CAAA;AAYpD,MAAM,WAAW,6BAA6B;IAC5C,4EAA4E;IAC5E,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,+EAA+E;IAC/E,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAC1B;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAAC,KAAK,GAAE,6BAAkC,GAAG,KAAK,CAAC,SAAS,
|
|
1
|
+
{"version":3,"file":"PublishButton.d.ts","sourceRoot":"","sources":["../../src/admin/PublishButton.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAgC,MAAM,OAAO,CAAA;AAYpD,MAAM,WAAW,6BAA6B;IAC5C,4EAA4E;IAC5E,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,+EAA+E;IAC/E,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAC1B;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAAC,KAAK,GAAE,6BAAkC,GAAG,KAAK,CAAC,SAAS,CA4IxF"}
|
|
@@ -33,9 +33,14 @@ export function PublishButton(props = {}) {
|
|
|
33
33
|
return;
|
|
34
34
|
setPublishing(true);
|
|
35
35
|
try {
|
|
36
|
-
// Persist pending edits first.
|
|
37
|
-
//
|
|
38
|
-
//
|
|
36
|
+
// Persist pending edits first, as a draft. Payload writes those to the
|
|
37
|
+
// versions table and leaves the published document alone, so the trust
|
|
38
|
+
// boundary lets them through; the pipeline then evaluates what was
|
|
39
|
+
// actually saved rather than what is on screen.
|
|
40
|
+
//
|
|
41
|
+
// `?draft=true` is what makes this a draft write. The `_status`
|
|
42
|
+
// override only pins the intent when form state carries a `_status` of
|
|
43
|
+
// its own, and mirrors what Payload's native Save Draft sends.
|
|
39
44
|
if (modified) {
|
|
40
45
|
const saved = await submit({
|
|
41
46
|
action: `${serverURL}${api}/${collectionSlug}/${id}?draft=true&depth=0`,
|
|
@@ -79,7 +84,19 @@ export function PublishButton(props = {}) {
|
|
|
79
84
|
setHasPublishedDoc(true);
|
|
80
85
|
setUnpublishedVersionCount(0);
|
|
81
86
|
setMostRecentVersionIsAutosaved(false);
|
|
82
|
-
|
|
87
|
+
// The document is live either way. A warning means something
|
|
88
|
+
// downstream of the publish didn't happen, which is worth saying
|
|
89
|
+
// without implying the publish failed.
|
|
90
|
+
const warnings = result.body.warnings ?? [];
|
|
91
|
+
if (warnings.length > 0) {
|
|
92
|
+
toast.warning(t('version:published'), {
|
|
93
|
+
description: warnings.join('\n'),
|
|
94
|
+
duration: 10_000,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
toast.success(t('version:published'));
|
|
99
|
+
}
|
|
83
100
|
}
|
|
84
101
|
finally {
|
|
85
102
|
setPublishing(false);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PublishButton.js","sourceRoot":"","sources":["../../src/admin/PublishButton.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAc,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACpD,OAAO,EACL,UAAU,EACV,KAAK,EACL,SAAS,EACT,eAAe,EACf,OAAO,EACP,eAAe,EACf,cAAc,GACf,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAS9E;;;;;;;;;;;;;;GAcG;AACH,MAAM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OAAO,EAAE,GAAG,EAAE;YACZ,KAAK,OAAO,EAAE,CAAA;QAChB,CAAC,EACD,IAAI,EAAC,QAAQ,EACb,IAAI,EAAC,QAAQ,YAEZ,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,wBAAwB,CAAC,GACxD,CACd,CAAA;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnpublishButton.d.ts","sourceRoot":"","sources":["../../src/admin/UnpublishButton.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAgC,MAAM,OAAO,CAAA;AAapD,MAAM,WAAW,+BAA+B;IAC9C,4EAA4E;IAC5E,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,KAAK,GAAE,+BAAoC,GAC1C,KAAK,CAAC,SAAS,
|
|
1
|
+
{"version":3,"file":"UnpublishButton.d.ts","sourceRoot":"","sources":["../../src/admin/UnpublishButton.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAgC,MAAM,OAAO,CAAA;AAapD,MAAM,WAAW,+BAA+B;IAC9C,4EAA4E;IAC5E,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,KAAK,GAAE,+BAAoC,GAC1C,KAAK,CAAC,SAAS,CA4GjB"}
|
|
@@ -48,7 +48,16 @@ export function UnpublishButton(props = {}) {
|
|
|
48
48
|
setUnpublishedVersionCount(1);
|
|
49
49
|
setMostRecentVersionIsAutosaved(false);
|
|
50
50
|
setHasPublishedDoc(false);
|
|
51
|
-
|
|
51
|
+
const warnings = result.body.warnings ?? [];
|
|
52
|
+
if (warnings.length > 0) {
|
|
53
|
+
toast.warning(t('version:unpublishedSuccessfully'), {
|
|
54
|
+
description: warnings.join('\n'),
|
|
55
|
+
duration: 10_000,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
toast.success(t('version:unpublishedSuccessfully'));
|
|
60
|
+
}
|
|
52
61
|
}
|
|
53
62
|
finally {
|
|
54
63
|
setUnpublishing(false);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnpublishButton.js","sourceRoot":"","sources":["../../src/admin/UnpublishButton.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACpD,OAAO,EACL,iBAAiB,EACjB,SAAS,EACT,KAAK,EACL,SAAS,EACT,eAAe,EACf,OAAO,EACP,QAAQ,EACR,cAAc,GACf,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AAO/D;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAC7B,QAAyC,EAAE;IAE3C,MAAM,WAAW,GAAG,KAAK,CAAC,WAAW,IAAI,aAAa,CAAA;IAEtD,MAAM,EACJ,cAAc,EACd,IAAI,EACJ,eAAe,EACf,oBAAoB,EACpB,EAAE,EACF,qBAAqB,EACrB,SAAS,EACT,kBAAkB,EAClB,+BAA+B,EAC/B,0BAA0B,GAC3B,GAAG,eAAe,EAAE,CAAA;IAErB,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE,CAAA;IAC9B,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,CAAA;IAC3B,MAAM,EAAE,CAAC,EAAE,GAAG,cAAc,EAAE,CAAA;IAC9B,MAAM,EAAE,WAAW,EAAE,GAAG,QAAQ,EAAE,CAAA;IAClC,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;IAEvD,MAAM,SAAS,GAAG,iCAAiC,EAAE,EAAE,CAAA;IACvD,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC,MAAM,CAAA;IAC7B,MAA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QAClB,+BAA+B;QAC/B,0BAA0B;QAC1B,CAAC;QACD,YAAY;KACb,CAAC,CAAA;IAEF,IAAI,CAAC,oBAAoB,IAAI,CAAC,eAAe,IAAI,SAAS;QAAE,OAAO,IAAI,CAAA;IACvE,IAAI,EAAE,KAAK,SAAS,IAAI,EAAE,KAAK,IAAI,IAAI,CAAC,cAAc;QAAE,OAAO,IAAI,CAAA;IAEnE,OAAO,CACL,MAAC,KAAK,CAAC,QAAQ,eACb,KAAC,SAAS,CAAC,MAAM,IACf,EAAE,EAAC,kBAAkB,EACrB,OAAO,EAAE,GAAG,EAAE;oBACZ,WAAW,CAAC,SAAS,CAAC,CAAA;gBACxB,CAAC,YAEA,CAAC,CAAC,mBAAmB,CAAC,GACN,EACnB,KAAC,iBAAiB,IAChB,IAAI,EAAE,CAAC,CAAC,0BAA0B,CAAC,EACnC,eAAe,EAAE,CAAC,CAAC,sBAAsB,CAAC,EAC1C,OAAO,EAAE,CAAC,CAAC,0BAA0B,CAAC,EACtC,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,GAAG,EAAE;oBACd,KAAK,SAAS,EAAE,CAAA;gBAClB,CAAC,GACD,IACa,CAClB,CAAA;AACH,CAAC"}
|
|
@@ -17,6 +17,8 @@ export interface PublishingResponse {
|
|
|
17
17
|
code?: string;
|
|
18
18
|
issues?: PublishingIssue[];
|
|
19
19
|
suggestion?: string;
|
|
20
|
+
/** Non-fatal problems on an action that otherwise succeeded. */
|
|
21
|
+
warnings?: string[];
|
|
20
22
|
error?: string;
|
|
21
23
|
}
|
|
22
24
|
export interface CallPublishingEndpointArgs {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publishing-client.d.ts","sourceRoot":"","sources":["../../src/admin/publishing-client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,eAAe;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,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
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publishing-client.js","sourceRoot":"","sources":["../../src/admin/publishing-client.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"publishing-client.js","sourceRoot":"","sources":["../../src/admin/publishing-client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAoCH;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,IAAgC;IAEhC,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,MAAM,EAAE,CAAA;IAEjF,IAAI,QAAkB,CAAA;IACtB,IAAI,CAAC;QACH,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;YAC1B,MAAM,EAAE,MAAM;YACd,WAAW,EAAE,SAAS;YACtB,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;YAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC;SACnE,CAAC,CAAA;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,wCAAwC,EAAE,CAAA;IACzE,CAAC;IAED,IAAI,IAAwB,CAAA;IAC5B,IAAI,CAAC;QACH,IAAI,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAuB,CAAA;IACtD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,8BAA8B,QAAQ,CAAC,MAAM,GAAG,EAAE,CAAA;IACjF,CAAC;IAED,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,OAAO;YACL,EAAE,EAAE,KAAK;YACT,OAAO,EAAE,IAAI,CAAC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ACjD,CAAC"}
|
|
@@ -4,8 +4,14 @@ import type { AccessibilityCheck } from '../options.js';
|
|
|
4
4
|
* a `url` or `filename` property whose `mimeType`, if present, starts with
|
|
5
5
|
* `image/`). Flags any whose `alt` is missing or empty.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
7
|
+
* Skips an upload's `sizes` map: Payload's generated derivatives carry
|
|
8
|
+
* `filename` and `mimeType` but never `alt`, which lives on the parent
|
|
9
|
+
* document. They are renditions of an image already checked, not images in
|
|
10
|
+
* their own right — walking into them reports one false failure per
|
|
11
|
+
* configured `imageSize`.
|
|
12
|
+
*
|
|
13
|
+
* Heuristic, not exhaustive. A host can add checks via `accessibilityChecks`
|
|
14
|
+
* and switch a built-in off via `disableAccessibilityChecks`.
|
|
9
15
|
*/
|
|
10
16
|
export declare const altTextCheck: AccessibilityCheck;
|
|
11
17
|
//# sourceMappingURL=alt-text.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alt-text.d.ts","sourceRoot":"","sources":["../../src/checks/alt-text.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAsB,MAAM,eAAe,CAAA;AAE3E
|
|
1
|
+
{"version":3,"file":"alt-text.d.ts","sourceRoot":"","sources":["../../src/checks/alt-text.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAsB,MAAM,eAAe,CAAA;AAE3E;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,YAAY,EAAE,kBAgB1B,CAAA"}
|
package/dist/checks/alt-text.js
CHANGED
|
@@ -3,8 +3,14 @@
|
|
|
3
3
|
* a `url` or `filename` property whose `mimeType`, if present, starts with
|
|
4
4
|
* `image/`). Flags any whose `alt` is missing or empty.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* Skips an upload's `sizes` map: Payload's generated derivatives carry
|
|
7
|
+
* `filename` and `mimeType` but never `alt`, which lives on the parent
|
|
8
|
+
* document. They are renditions of an image already checked, not images in
|
|
9
|
+
* their own right — walking into them reports one false failure per
|
|
10
|
+
* configured `imageSize`.
|
|
11
|
+
*
|
|
12
|
+
* Heuristic, not exhaustive. A host can add checks via `accessibilityChecks`
|
|
13
|
+
* and switch a built-in off via `disableAccessibilityChecks`.
|
|
8
14
|
*/
|
|
9
15
|
export const altTextCheck = {
|
|
10
16
|
name: 'alt-text',
|
|
@@ -33,10 +39,14 @@ function walkForImages(value, visit, path = '') {
|
|
|
33
39
|
return;
|
|
34
40
|
}
|
|
35
41
|
const obj = value;
|
|
36
|
-
|
|
42
|
+
const isImage = looksLikeImage(obj);
|
|
43
|
+
if (isImage) {
|
|
37
44
|
visit(obj, path || '(root)');
|
|
38
45
|
}
|
|
39
46
|
for (const key of Object.keys(obj)) {
|
|
47
|
+
// An image's own derivatives are not separate images.
|
|
48
|
+
if (isImage && key === 'sizes')
|
|
49
|
+
continue;
|
|
40
50
|
walkForImages(obj[key], visit, path ? `${path}.${key}` : key);
|
|
41
51
|
}
|
|
42
52
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alt-text.js","sourceRoot":"","sources":["../../src/checks/alt-text.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"alt-text.js","sourceRoot":"","sources":["../../src/checks/alt-text.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,YAAY,GAAuB;IAC9C,IAAI,EAAE,UAAU;IAChB,GAAG,CAAC,GAAG;QACL,MAAM,MAAM,GAAyB,EAAE,CAAA;QACvC,aAAa,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;YACjC,MAAM,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,CAAA;YACxB,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;gBACjD,MAAM,CAAC,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AqB;IACrB,MAAM,IAAI,GAAG,GAAG,CAAC,UAAU,CAAC,CAAA;IAC5B,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;IAC9D,OAAO,OAAO,GAAG,CAAC,UAAU,CAAC,KAAK,QAAQ,CAAA;AAC5C,CAAC"}
|
package/dist/events.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Inngest } from 'inngest';
|
|
2
|
+
type EventPayload = Parameters<Inngest['send']>[0];
|
|
3
|
+
/**
|
|
4
|
+
* Emits an Inngest event without letting a transport failure fail the action
|
|
5
|
+
* that already completed. Returns a warning message on failure, `null` on
|
|
6
|
+
* success.
|
|
7
|
+
*
|
|
8
|
+
* Publishing writes the document first and emits afterwards. The event is a
|
|
9
|
+
* consequence of the write, not a step in it — if the emission fails the
|
|
10
|
+
* document is still published. Throwing here would tell an editor their
|
|
11
|
+
* change didn't go live when it did, and the obvious response to that is to
|
|
12
|
+
* click Publish again on content that is already live.
|
|
13
|
+
*/
|
|
14
|
+
export declare function sendEventSafely(inngest: Inngest, event: EventPayload): Promise<string | null>;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAEtC,KAAK,YAAY,GAAG,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAElD;;;;;;;;;;GAUG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,YAAY,GAClB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAQxB"}
|
package/dist/events.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Emits an Inngest event without letting a transport failure fail the action
|
|
3
|
+
* that already completed. Returns a warning message on failure, `null` on
|
|
4
|
+
* success.
|
|
5
|
+
*
|
|
6
|
+
* Publishing writes the document first and emits afterwards. The event is a
|
|
7
|
+
* consequence of the write, not a step in it — if the emission fails the
|
|
8
|
+
* document is still published. Throwing here would tell an editor their
|
|
9
|
+
* change didn't go live when it did, and the obvious response to that is to
|
|
10
|
+
* click Publish again on content that is already live.
|
|
11
|
+
*/
|
|
12
|
+
export async function sendEventSafely(inngest, event) {
|
|
13
|
+
try {
|
|
14
|
+
await inngest.send(event);
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
const name = eventName(event);
|
|
19
|
+
return `The ${name} event could not be sent, so revalidation and integrations may not have run: ${describeError(error)}`;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function eventName(event) {
|
|
23
|
+
if (Array.isArray(event))
|
|
24
|
+
return event[0]?.name ?? 'publishing';
|
|
25
|
+
return event.name ?? 'publishing';
|
|
26
|
+
}
|
|
27
|
+
function describeError(error) {
|
|
28
|
+
return error instanceof Error ? error.message : String(error);
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,OAAgB,EAChB,KAAmB;IAEnB,IAAI,CAAC;QACH,MAAM,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACzB,OAAO,IAAI,CAAA;IACb,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,GAAG,SAAS,CAAC,KAAK,CAAC,CAAA;QAC7B,OAAO,OAAO,IAAI,gFAAgF,aAAa,CAAC,KAAK,CAAC,EAAE,CAAA;IAC1H,CAAC;AACH,CAAC;AAED,SAAS,SAAS,CAAC,KAAmB;IACpC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,IAAI,YAAY,CAAA;IAC/D,OAAQ,KAA2B,CAAC,IAAI,IAAI,YAAY,CAAA;AAC1D,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AAC/D,CAAC"}
|
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
import type { CollectionBeforeChangeHook } from 'payload';
|
|
2
2
|
/**
|
|
3
3
|
* The trust boundary. This `beforeChange` hook rejects every update that
|
|
4
|
-
*
|
|
5
|
-
* `bypassPublishingServer` context flag (set by the pipeline's
|
|
4
|
+
* changes the live document's `_status` unless the request explicitly
|
|
5
|
+
* carries the `bypassPublishingServer` context flag (set by the pipeline's
|
|
6
|
+
* `executeStep`).
|
|
6
7
|
*
|
|
7
8
|
* Without this hook, the Payload MCP could let Claude flip a document to
|
|
8
9
|
* `published` directly, sidestepping every check the publishing server
|
|
9
10
|
* exists to enforce. With it, the only sanctioned path is the pipeline.
|
|
10
11
|
*
|
|
12
|
+
* Draft writes pass through. A `draft: true` update writes a new row in the
|
|
13
|
+
* versions table and leaves the published document alone, so it changes no
|
|
14
|
+
* live status — but Payload injects `data._status = 'draft'` into every such
|
|
15
|
+
* update before this hook runs, which made saving a draft of a published
|
|
16
|
+
* document indistinguishable from unpublishing it. `createRecordDraftWritesHook`
|
|
17
|
+
* captures the operation's real `draft` flag so the two can be told apart;
|
|
18
|
+
* both hooks must be installed together.
|
|
19
|
+
*
|
|
11
20
|
* Throws `APIError` rather than `Error` so Payload returns 400 with the
|
|
12
21
|
* message intact instead of swallowing it into a 500 and a generic
|
|
13
22
|
* "Something went wrong" toast.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block-status-writes.d.ts","sourceRoot":"","sources":["../../src/hooks/block-status-writes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"block-status-writes.d.ts","sourceRoot":"","sources":["../../src/hooks/block-status-writes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAA;AAGzD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,2BAA2B,IAAI,0BAA0B,CAoCxE"}
|
|
@@ -1,19 +1,29 @@
|
|
|
1
1
|
import { APIError } from 'payload';
|
|
2
|
+
import { isDraftWrite } from './draft-writes.js';
|
|
2
3
|
/**
|
|
3
4
|
* The trust boundary. This `beforeChange` hook rejects every update that
|
|
4
|
-
*
|
|
5
|
-
* `bypassPublishingServer` context flag (set by the pipeline's
|
|
5
|
+
* changes the live document's `_status` unless the request explicitly
|
|
6
|
+
* carries the `bypassPublishingServer` context flag (set by the pipeline's
|
|
7
|
+
* `executeStep`).
|
|
6
8
|
*
|
|
7
9
|
* Without this hook, the Payload MCP could let Claude flip a document to
|
|
8
10
|
* `published` directly, sidestepping every check the publishing server
|
|
9
11
|
* exists to enforce. With it, the only sanctioned path is the pipeline.
|
|
10
12
|
*
|
|
13
|
+
* Draft writes pass through. A `draft: true` update writes a new row in the
|
|
14
|
+
* versions table and leaves the published document alone, so it changes no
|
|
15
|
+
* live status — but Payload injects `data._status = 'draft'` into every such
|
|
16
|
+
* update before this hook runs, which made saving a draft of a published
|
|
17
|
+
* document indistinguishable from unpublishing it. `createRecordDraftWritesHook`
|
|
18
|
+
* captures the operation's real `draft` flag so the two can be told apart;
|
|
19
|
+
* both hooks must be installed together.
|
|
20
|
+
*
|
|
11
21
|
* Throws `APIError` rather than `Error` so Payload returns 400 with the
|
|
12
22
|
* message intact instead of swallowing it into a 500 and a generic
|
|
13
23
|
* "Something went wrong" toast.
|
|
14
24
|
*/
|
|
15
25
|
export function createBlockStatusWritesHook() {
|
|
16
|
-
return ({ data, originalDoc, operation, context, req }) => {
|
|
26
|
+
return ({ collection, data, originalDoc, operation, context, req }) => {
|
|
17
27
|
if (operation !== 'update')
|
|
18
28
|
return data;
|
|
19
29
|
if (!hasStatusChange(data))
|
|
@@ -27,6 +37,17 @@ export function createBlockStatusWritesHook() {
|
|
|
27
37
|
}
|
|
28
38
|
if (isBypassed(context) || isBypassed(req?.context))
|
|
29
39
|
return data;
|
|
40
|
+
// A draft save touches a version, not the live document.
|
|
41
|
+
//
|
|
42
|
+
// Mirror Payload's own `isSavingDraft`, which requires the incoming
|
|
43
|
+
// status to be something other than `published`. A request that asks for
|
|
44
|
+
// `draft: true` while setting `_status: 'published'` is a real publish —
|
|
45
|
+
// Payload treats it as one — so it stays blocked. Without this, `draft`
|
|
46
|
+
// would be a way to publish around the pipeline.
|
|
47
|
+
if (data['_status'] !== 'published' &&
|
|
48
|
+
isDraftWrite(req, collection?.slug, originalDoc?.id)) {
|
|
49
|
+
return data;
|
|
50
|
+
}
|
|
30
51
|
throw new APIError('Direct writes to `_status` are not allowed. Use the publishing server (publish / unpublish / rollback) so the policy pipeline runs.', 400);
|
|
31
52
|
};
|
|
32
53
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block-status-writes.js","sourceRoot":"","sources":["../../src/hooks/block-status-writes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"block-status-writes.js","sourceRoot":"","sources":["../../src/hooks/block-status-writes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAElC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAEhD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,2BAA2B;IACzC,OAAO,CAAC,EAAE,UAAU,EA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 'payload';
|
|
2
|
+
/**
|
|
3
|
+
* Records whether the update in flight is a draft write, so the
|
|
4
|
+
* status-write hook can tell a draft save apart from an unpublish.
|
|
5
|
+
*
|
|
6
|
+
* It has to be recorded here because `beforeChange` cannot work it out:
|
|
7
|
+
* Payload sets `data._status = 'draft'` for any `draft: true` update
|
|
8
|
+
* *before* calling the hook, whether or not the caller supplied it —
|
|
9
|
+
*
|
|
10
|
+
* const isSavingDraft = Boolean(draftArg && hasDraftsEnabled(config))
|
|
11
|
+
* && data._status !== 'published' && !publishAllLocales
|
|
12
|
+
* if (isSavingDraft) { data._status = 'draft' }
|
|
13
|
+
*
|
|
14
|
+
* so by the time `beforeChange` runs, saving a draft of a published
|
|
15
|
+
* document and unpublishing it look identical: `data._status` is `'draft'`
|
|
16
|
+
* and `originalDoc._status` is `'published'` in both cases.
|
|
17
|
+
*
|
|
18
|
+
* `beforeOperation` is the one place that sees the operation's own `draft`
|
|
19
|
+
* argument, and it sees it identically on the Local API, REST and GraphQL —
|
|
20
|
+
* unlike `req.query.draft`, which is only populated on the REST path.
|
|
21
|
+
* `beforeOperation` shares `req.context` with `beforeChange`, which is how
|
|
22
|
+
* the flag gets across.
|
|
23
|
+
*/
|
|
24
|
+
export declare function createRecordDraftWritesHook(): CollectionBeforeOperationHook;
|
|
25
|
+
/**
|
|
26
|
+
* Whether the update in flight on this document is a draft write.
|
|
27
|
+
*
|
|
28
|
+
* Defaults to `false` when nothing was recorded, so a caller that installs
|
|
29
|
+
* the status-write hook without this one keeps the stricter behaviour.
|
|
30
|
+
*/
|
|
31
|
+
export declare function isDraftWrite(req: Pick<PayloadRequest, 'context'> | undefined, collectionSlug: string | undefined, id: unknown): boolean;
|
|
32
|
+
//# sourceMappingURL=draft-writes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"draft-writes.d.ts","sourceRoot":"","sources":["../../src/hooks/draft-writes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,6BAA6B,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAM5E;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,2BAA2B,IAAI,6BAA6B,CAW3E;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,GAAG,EAAE,IAAI,CAAC,cAAc,EAAE,SAAS,CAAC,GAAG,SAAS,EAChD,cAAc,EAAE,MAAM,GAAG,SAAS,EAClC,EAAE,EAAE,OAAO,GACV,OAAO,CAcT"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
const DRAFT_WRITES_KEY = '__throughlinePublishingDraftWrites';
|
|
2
|
+
/**
|
|
3
|
+
* Records whether the update in flight is a draft write, so the
|
|
4
|
+
* status-write hook can tell a draft save apart from an unpublish.
|
|
5
|
+
*
|
|
6
|
+
* It has to be recorded here because `beforeChange` cannot work it out:
|
|
7
|
+
* Payload sets `data._status = 'draft'` for any `draft: true` update
|
|
8
|
+
* *before* calling the hook, whether or not the caller supplied it —
|
|
9
|
+
*
|
|
10
|
+
* const isSavingDraft = Boolean(draftArg && hasDraftsEnabled(config))
|
|
11
|
+
* && data._status !== 'published' && !publishAllLocales
|
|
12
|
+
* if (isSavingDraft) { data._status = 'draft' }
|
|
13
|
+
*
|
|
14
|
+
* so by the time `beforeChange` runs, saving a draft of a published
|
|
15
|
+
* document and unpublishing it look identical: `data._status` is `'draft'`
|
|
16
|
+
* and `originalDoc._status` is `'published'` in both cases.
|
|
17
|
+
*
|
|
18
|
+
* `beforeOperation` is the one place that sees the operation's own `draft`
|
|
19
|
+
* argument, and it sees it identically on the Local API, REST and GraphQL —
|
|
20
|
+
* unlike `req.query.draft`, which is only populated on the REST path.
|
|
21
|
+
* `beforeOperation` shares `req.context` with `beforeChange`, which is how
|
|
22
|
+
* the flag gets across.
|
|
23
|
+
*/
|
|
24
|
+
export function createRecordDraftWritesHook() {
|
|
25
|
+
return ({ args, operation, req }) => {
|
|
26
|
+
// `update` and `updateByID` both arrive as the `update` hook operation.
|
|
27
|
+
if (operation !== 'update')
|
|
28
|
+
return;
|
|
29
|
+
const updateArgs = args;
|
|
30
|
+
const slug = collectionSlug(args);
|
|
31
|
+
if (!slug)
|
|
32
|
+
return;
|
|
33
|
+
registry(req)[draftWriteKey(slug, updateArgs.id)] = updateArgs.draft === true;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Whether the update in flight on this document is a draft write.
|
|
38
|
+
*
|
|
39
|
+
* Defaults to `false` when nothing was recorded, so a caller that installs
|
|
40
|
+
* the status-write hook without this one keeps the stricter behaviour.
|
|
41
|
+
*/
|
|
42
|
+
export function isDraftWrite(req, collectionSlug, id) {
|
|
43
|
+
if (!req || !collectionSlug)
|
|
44
|
+
return false;
|
|
45
|
+
const entries = req.context?.[DRAFT_WRITES_KEY];
|
|
46
|
+
if (!entries)
|
|
47
|
+
return false;
|
|
48
|
+
// Keyed per document so a nested write to a different document during the
|
|
49
|
+
// same request cannot be mistaken for this one.
|
|
50
|
+
const scoped = entries[draftWriteKey(collectionSlug, id)];
|
|
51
|
+
if (scoped !== undefined)
|
|
52
|
+
return scoped;
|
|
53
|
+
// Bulk updates match by `where` and carry no id.
|
|
54
|
+
return entries[draftWriteKey(collectionSlug, undefined)] === true;
|
|
55
|
+
}
|
|
56
|
+
function draftWriteKey(collectionSlug, id) {
|
|
57
|
+
return `${collectionSlug}:${id === undefined || id === null ? '*' : String(id)}`;
|
|
58
|
+
}
|
|
59
|
+
function collectionSlug(args) {
|
|
60
|
+
const slug = args?.collection?.config
|
|
61
|
+
?.slug;
|
|
62
|
+
return typeof slug === 'string' ? slug : undefined;
|
|
63
|
+
}
|
|
64
|
+
function registry(req) {
|
|
65
|
+
// Payload always assigns `req.context`, but attach it if absent rather
|
|
66
|
+
// than writing the flag to an object nothing else can see.
|
|
67
|
+
if (!req.context) {
|
|
68
|
+
req.context = {};
|
|
69
|
+
}
|
|
70
|
+
const context = req.context;
|
|
71
|
+
if (!context[DRAFT_WRITES_KEY]) {
|
|
72
|
+
context[DRAFT_WRITES_KEY] = {};
|
|
73
|
+
}
|
|
74
|
+
return context[DRAFT_WRITES_KEY];
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=draft-writes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"draft-writes.js","sourceRoot":"","sources":["../../src/hooks/draft-writes.ts"],"names":[],"mappings":"AAEA,MAAM,gBAAgB,GAAG,oCAAoC,CAAA;AAI7D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,2BAA2B;IACzC,OAAO,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,EAAE,EAAE;QAClC,wEAAwE;QACxE,IAAI,SAAS,KAAK,QAAQ;YAAE,OAAM;QAElC,MAAM,UAAU,GAAG,IAAiD,CAAA;QACpE,MAAM,IAAI,GAAG,cAAc,CAAC,IAAI,CAAC,CAAA;QACjC,IAAI,CAAC,IAAI;YAAE,OAAM;QAEjB,QAAQ,CAAC,GAAG,CAAC,CAAC,aAAa,CAAC,IAAI,EAAE,UAAU,CAAC,EAAE,CAAC,CAAC,GAAG,UAAU,CAAC,KAAK,KAAK,IAAI,CAAA;IAC/E,CAAC,CAAA;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAC1B,GAAgD,EAChD,cAAkC,EAClC,EAAW;IAEX,IAAI,CAAC,GAAG,IAAI,CAAC,cAAc;QAAE,OAAO,KAAK,CAAA;IACzC,MAAM,OAAO,GAAI,GAAG,CAAC,OAA+C,EAAE,CACpE,gBAAgB,CACiB,CAAA;IACnC,IAAI,CAAC,OAAO;QAAE,OAAO,KAAK,CAAA;IAE1B,0EAA0E;IAC1E,gDAAgD;IAChD,MAAM,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,CAAA;IACzD,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,MAAM,CAAA;IAEvC,iDAAiD;IACjD,OAAO,OAAO,CAAC,aAAa,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC,KAAK,IAAI,CAAA;AACnE,CAAC;AAED,SAAS,aAAa,CAAC,cAAsB,EAAE,EAAW;IACxD,OAAO,GAAG,cAAc,IAAI,EAAE,KAAK,SAAS,IAAI,EAAE,KAAK,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAA;AAClF,CAAC;AAED,SAAS,cAAc,CAAC,IAAa;IACnC,MAAM,IAAI,GAAI,IAAyD,EAAE,UAAU,EAAE,MAAM;QACzF,EAAE,IAAI,CAAA;IACR,OAAO,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAA;AACpD,CAAC;AAED,SAAS,QAAQ,CAAC,GAAmB;IACnC,uEAAuE;IACvE,2DAA2D;IAC3D,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;QACjB,GAAG,CAAC,OAAO,GAAG,EAA+B,CAAA;IAC/C,CAAC;IACD,MAAM,OAAO,GAAG,GAAG,CAAC,OAA6C,CAAA;IACjE,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC;QAC/B,OAAO,CAAC,gBAAgB,CAAC,GAAG,EAA+B,CAAA;IAC7D,CAAC;IACD,OAAO,OAAO,CAAC,gBAAgB,CAAuB,CAAA;AACxD,CAAC"}
|
package/dist/options.d.ts
CHANGED
|
@@ -45,6 +45,15 @@ export interface PublishingPluginOptions extends BaseCorePluginOptions {
|
|
|
45
45
|
collections: PublishableCollection[];
|
|
46
46
|
/** Optional: extra accessibility checks beyond the built-ins. */
|
|
47
47
|
accessibilityChecks?: AccessibilityCheck[];
|
|
48
|
+
/**
|
|
49
|
+
* Optional: names of built-in accessibility checks to skip —
|
|
50
|
+
* `'alt-text'`, `'heading-hierarchy'`, `'link-labels'`.
|
|
51
|
+
*
|
|
52
|
+
* `accessibilityChecks` only appends, so without this a built-in that
|
|
53
|
+
* misfires on a host's content shape blocks every publish until the
|
|
54
|
+
* plugin ships a fix. Switch one off here and supply your own.
|
|
55
|
+
*/
|
|
56
|
+
disableAccessibilityChecks?: string[];
|
|
48
57
|
/** Optional: resolver consulted when a document's policy requires approval. */
|
|
49
58
|
approvalResolver?: ApprovalResolver;
|
|
50
59
|
/** Required: Inngest client used to fire publishing events. */
|
package/dist/options.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAEtC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAA;AAElF,MAAM,WAAW,qBAAqB;IACpC,wEAAwE;IACxE,IAAI,EAAE,MAAM,CAAA;IACZ,kFAAkF;IAClF,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,oFAAoF;IACpF,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,mGAAmG;IACnG,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,sEAAsE;IACtE,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,uFAAuF;IACvF,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,0EAA0E;IAC1E,cAAc,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAC1D;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAA;CAC9B;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAA;IAC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