@delmaredigital/payload-puck 0.9.1 → 0.9.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/dist/plugin/collections/Pages.js +19 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -13,6 +13,16 @@ const defaultWriteAccess = ({ req })=>Boolean(req.user);
|
|
|
13
13
|
* Generates a Pages collection configuration for Puck
|
|
14
14
|
*/ export function generatePagesCollection(slug, options) {
|
|
15
15
|
const { collectionOverrides = {}, access = {}, layouts = DEFAULT_LAYOUTS, additionalFields = [] } = options;
|
|
16
|
+
// These keys are merged explicitly in the config below; only the remaining
|
|
17
|
+
// override keys are spread verbatim.
|
|
18
|
+
const MERGED_OVERRIDE_KEYS = new Set([
|
|
19
|
+
'access',
|
|
20
|
+
'admin',
|
|
21
|
+
'hooks',
|
|
22
|
+
'versions',
|
|
23
|
+
'fields'
|
|
24
|
+
]);
|
|
25
|
+
const restOverrides = Object.fromEntries(Object.entries(collectionOverrides).filter(([key])=>!MERGED_OVERRIDE_KEYS.has(key)));
|
|
16
26
|
const baseFields = [
|
|
17
27
|
// Core Fields (title and slug with duplication hooks - unique to collection generation)
|
|
18
28
|
{
|
|
@@ -100,6 +110,9 @@ const defaultWriteAccess = ({ req })=>Boolean(req.user);
|
|
|
100
110
|
create: access.create ?? defaultWriteAccess,
|
|
101
111
|
update: access.update ?? defaultWriteAccess,
|
|
102
112
|
delete: access.delete ?? defaultWriteAccess,
|
|
113
|
+
...access.readVersions ? {
|
|
114
|
+
readVersions: access.readVersions
|
|
115
|
+
} : {},
|
|
103
116
|
...collectionOverrides.access ?? {}
|
|
104
117
|
},
|
|
105
118
|
hooks: {
|
|
@@ -128,7 +141,12 @@ const defaultWriteAccess = ({ req })=>Boolean(req.user);
|
|
|
128
141
|
drafts: true
|
|
129
142
|
},
|
|
130
143
|
fields: baseFields,
|
|
131
|
-
|
|
144
|
+
// Everything merged above (admin, access, hooks, versions, fields) must not
|
|
145
|
+
// be clobbered by a shallow spread of the overrides: passing
|
|
146
|
+
// `collectionOverrides: { access: { readVersions } }` used to replace the
|
|
147
|
+
// whole access object and silently hand read/create/update/delete back to
|
|
148
|
+
// Payload's defaults.
|
|
149
|
+
...restOverrides,
|
|
132
150
|
// Ensure fields aren't overwritten by collectionOverrides
|
|
133
151
|
...collectionOverrides.fields && {
|
|
134
152
|
fields: [
|
package/dist/types/index.d.ts
CHANGED
|
@@ -57,12 +57,14 @@ export interface PuckPluginOptions {
|
|
|
57
57
|
* Defaults: `read` allows everyone; `create`, `update` and `delete` require
|
|
58
58
|
* an authenticated Payload user (`({ req }) => Boolean(req.user)`). Pass your
|
|
59
59
|
* own functions to tighten this, e.g. `update: ({ req }) => req.user?.role === 'admin'`.
|
|
60
|
+
* `readVersions` is optional and falls back to Payload's default when unset.
|
|
60
61
|
*/
|
|
61
62
|
access?: {
|
|
62
63
|
read?: Access;
|
|
63
64
|
create?: Access;
|
|
64
65
|
update?: Access;
|
|
65
66
|
delete?: Access;
|
|
67
|
+
readVersions?: Access;
|
|
66
68
|
};
|
|
67
69
|
/**
|
|
68
70
|
* Page layout configuration
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.9.
|
|
1
|
+
export declare const VERSION = "0.9.2";
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Auto-generated by scripts/generate-version.js - do not edit manually
|
|
2
|
-
export const VERSION = '0.9.
|
|
2
|
+
export const VERSION = '0.9.2';
|