@ainsleydev/payload-helper 0.0.22 → 0.0.24
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/cli/bin.js +1 -9
- package/dist/cli/bin.js.map +1 -1
- package/dist/collections/Media.d.ts +10 -6
- package/dist/collections/Media.js +166 -133
- package/dist/collections/Media.js.map +1 -1
- package/dist/gen/types.d.ts +6 -0
- package/dist/{cli → gen}/types.js +9 -16
- package/dist/gen/types.js.map +1 -0
- package/dist/globals/Settings.d.ts +1 -1
- package/dist/globals/Settings.js.map +1 -1
- package/dist/index.js +29 -32
- package/dist/index.js.map +1 -1
- package/dist/plugin/schema.d.ts +10 -3
- package/dist/plugin/schema.js +103 -97
- package/dist/plugin/schema.js.map +1 -1
- package/dist/seed/seed.d.ts +6 -11
- package/dist/seed/seed.js +7 -24
- package/dist/seed/seed.js.map +1 -1
- package/package.json +22 -10
- package/dist/cli/types.d.ts +0 -4
- package/dist/cli/types.js.map +0 -1
package/dist/cli/bin.js
CHANGED
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import chalk from 'chalk';
|
|
3
2
|
import { Command } from 'commander';
|
|
4
|
-
import { generateTypes } from './types.js';
|
|
5
3
|
const program = new Command();
|
|
6
|
-
program.command('generate-types').description('Generate JSON schema types for Payload CMS')
|
|
7
|
-
try {
|
|
8
|
-
await generateTypes('');
|
|
9
|
-
} catch (error) {
|
|
10
|
-
console.log(chalk.red(error));
|
|
11
|
-
}
|
|
12
|
-
});
|
|
4
|
+
program.command('generate-types').description('Generate JSON schema types for Payload CMS');
|
|
13
5
|
export const bin = async ()=>{
|
|
14
6
|
await program.parseAsync(process.argv);
|
|
15
7
|
};
|
package/dist/cli/bin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cli/bin.ts"],"sourcesContent":["#!/usr/bin/env node\nimport chalk from 'chalk';\nimport { Command } from 'commander';\
|
|
1
|
+
{"version":3,"sources":["../../src/cli/bin.ts"],"sourcesContent":["#!/usr/bin/env node\nimport chalk from 'chalk';\nimport { Command } from 'commander';\n\nconst program = new Command();\n\nprogram\n\t.command('generate-types')\n\t.description('Generate JSON schema types for Payload CMS')\n\n\nexport const bin = async () => {\n\tawait program.parseAsync(process.argv);\n};\n"],"names":["Command","program","command","description","bin","parseAsync","process","argv"],"mappings":";AAEA,SAASA,OAAO,QAAQ,YAAY;AAEpC,MAAMC,UAAU,IAAID;AAEpBC,QACEC,OAAO,CAAC,kBACRC,WAAW,CAAC;AAGd,OAAO,MAAMC,MAAM;IAClB,MAAMH,QAAQI,UAAU,CAACC,QAAQC,IAAI;AACtC,EAAE"}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import type { CollectionConfig, Field } from 'payload';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import type { CollectionConfig, Field, UploadConfig } from 'payload';
|
|
2
|
+
import type { ImageSize } from "payload";
|
|
3
|
+
export interface MediaArgs {
|
|
4
|
+
includeAvif?: boolean;
|
|
5
|
+
additionalFields?: Field[];
|
|
6
|
+
uploadOverrides?: Partial<UploadConfig>;
|
|
7
|
+
}
|
|
8
|
+
export declare const imageSizes: ImageSize[];
|
|
9
|
+
export declare const imageSizesWithAvif: () => ImageSize[];
|
|
10
|
+
export declare const Media: (args?: MediaArgs) => CollectionConfig;
|
|
@@ -1,9 +1,167 @@
|
|
|
1
1
|
import { lexicalEditor } from '@payloadcms/richtext-lexical';
|
|
2
2
|
import * as mime from 'mime-types';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import env from '../util/env.js';
|
|
4
|
+
export const imageSizes = [
|
|
5
|
+
{
|
|
6
|
+
name: 'webp',
|
|
7
|
+
width: undefined,
|
|
8
|
+
height: undefined,
|
|
9
|
+
formatOptions: {
|
|
10
|
+
format: 'webp',
|
|
11
|
+
options: {
|
|
12
|
+
quality: 80
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
name: 'thumbnail',
|
|
18
|
+
width: 200,
|
|
19
|
+
height: undefined,
|
|
20
|
+
position: 'centre'
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: 'thumbnail_webp',
|
|
24
|
+
width: 200,
|
|
25
|
+
height: undefined,
|
|
26
|
+
position: 'centre',
|
|
27
|
+
formatOptions: {
|
|
28
|
+
format: 'webp',
|
|
29
|
+
options: {
|
|
30
|
+
quality: 80
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: 'mobile',
|
|
36
|
+
width: 500,
|
|
37
|
+
height: undefined
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: 'mobile_webp',
|
|
41
|
+
width: 500,
|
|
42
|
+
height: undefined,
|
|
43
|
+
formatOptions: {
|
|
44
|
+
format: 'webp',
|
|
45
|
+
options: {
|
|
46
|
+
quality: 80
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: 'tablet',
|
|
52
|
+
width: 800,
|
|
53
|
+
height: undefined
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: 'tablet_webp',
|
|
57
|
+
width: 800,
|
|
58
|
+
height: undefined,
|
|
59
|
+
formatOptions: {
|
|
60
|
+
format: 'webp',
|
|
61
|
+
options: {
|
|
62
|
+
quality: 80
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: 'desktop',
|
|
68
|
+
width: 1200,
|
|
69
|
+
height: undefined
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: 'desktop_webp',
|
|
73
|
+
width: 1200,
|
|
74
|
+
height: undefined,
|
|
75
|
+
formatOptions: {
|
|
76
|
+
format: 'webp',
|
|
77
|
+
options: {
|
|
78
|
+
quality: 80
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
];
|
|
83
|
+
export const imageSizesWithAvif = ()=>{
|
|
84
|
+
return [
|
|
85
|
+
...imageSizes,
|
|
86
|
+
{
|
|
87
|
+
name: 'avif',
|
|
88
|
+
width: undefined,
|
|
89
|
+
height: undefined,
|
|
90
|
+
formatOptions: {
|
|
91
|
+
format: 'avif',
|
|
92
|
+
options: {
|
|
93
|
+
quality: 60,
|
|
94
|
+
effort: 1,
|
|
95
|
+
chromaSubsampling: '4:4:4',
|
|
96
|
+
bitdepth: 8,
|
|
97
|
+
lossless: false
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
name: 'thumbnail_avif',
|
|
103
|
+
width: 200,
|
|
104
|
+
height: undefined,
|
|
105
|
+
position: 'centre',
|
|
106
|
+
formatOptions: {
|
|
107
|
+
format: 'avif',
|
|
108
|
+
options: {
|
|
109
|
+
quality: 60,
|
|
110
|
+
effort: 1,
|
|
111
|
+
chromaSubsampling: '4:4:4',
|
|
112
|
+
bitdepth: 8,
|
|
113
|
+
lossless: false
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
name: 'mobile_avif',
|
|
119
|
+
width: 500,
|
|
120
|
+
height: undefined,
|
|
121
|
+
formatOptions: {
|
|
122
|
+
format: 'avif',
|
|
123
|
+
options: {
|
|
124
|
+
quality: 60,
|
|
125
|
+
effort: 1,
|
|
126
|
+
chromaSubsampling: '4:4:4',
|
|
127
|
+
bitdepth: 8,
|
|
128
|
+
lossless: false
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
name: 'tablet_avif',
|
|
134
|
+
width: 800,
|
|
135
|
+
height: undefined,
|
|
136
|
+
formatOptions: {
|
|
137
|
+
format: 'avif',
|
|
138
|
+
options: {
|
|
139
|
+
quality: 60,
|
|
140
|
+
effort: 1,
|
|
141
|
+
chromaSubsampling: '4:4:4',
|
|
142
|
+
bitdepth: 8,
|
|
143
|
+
lossless: false
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
name: 'desktop_avif',
|
|
149
|
+
width: 1200,
|
|
150
|
+
height: undefined,
|
|
151
|
+
formatOptions: {
|
|
152
|
+
format: 'avif',
|
|
153
|
+
options: {
|
|
154
|
+
quality: 80
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
];
|
|
159
|
+
};
|
|
160
|
+
export const Media = (args = {})=>{
|
|
161
|
+
let sizes = imageSizes;
|
|
162
|
+
if (args.includeAvif) {
|
|
163
|
+
sizes = imageSizesWithAvif();
|
|
164
|
+
}
|
|
7
165
|
return {
|
|
8
166
|
slug: 'media',
|
|
9
167
|
access: {
|
|
@@ -27,11 +185,12 @@ import * as mime from 'mime-types';
|
|
|
27
185
|
}
|
|
28
186
|
})
|
|
29
187
|
},
|
|
30
|
-
...additionalFields ? additionalFields : []
|
|
188
|
+
...args.additionalFields ? args.additionalFields : []
|
|
31
189
|
],
|
|
32
190
|
upload: {
|
|
33
191
|
staticDir: 'media',
|
|
34
192
|
adminThumbnail: 'thumbnail',
|
|
193
|
+
disableLocalStorage: env.isProduction,
|
|
35
194
|
handlers: [
|
|
36
195
|
async (req, args)=>{
|
|
37
196
|
const logger = req.payload.logger;
|
|
@@ -51,134 +210,8 @@ import * as mime from 'mime-types';
|
|
|
51
210
|
req.responseHeaders = headers;
|
|
52
211
|
}
|
|
53
212
|
],
|
|
54
|
-
imageSizes:
|
|
55
|
-
|
|
56
|
-
{
|
|
57
|
-
name: 'webp',
|
|
58
|
-
width: undefined,
|
|
59
|
-
height: undefined,
|
|
60
|
-
formatOptions: {
|
|
61
|
-
format: 'webp',
|
|
62
|
-
options: {
|
|
63
|
-
quality: 80
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
name: 'avif',
|
|
69
|
-
width: undefined,
|
|
70
|
-
height: undefined,
|
|
71
|
-
formatOptions: {
|
|
72
|
-
format: 'avif',
|
|
73
|
-
options: {
|
|
74
|
-
quality: 60,
|
|
75
|
-
effort: 1,
|
|
76
|
-
chromaSubsampling: '4:4:4',
|
|
77
|
-
bitdepth: 8,
|
|
78
|
-
lossless: false
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
|
-
// Thumbnail Sizes
|
|
83
|
-
{
|
|
84
|
-
name: 'thumbnail',
|
|
85
|
-
width: 200,
|
|
86
|
-
height: undefined,
|
|
87
|
-
position: 'centre'
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
name: 'thumbnail_webp',
|
|
91
|
-
width: 200,
|
|
92
|
-
height: undefined,
|
|
93
|
-
position: 'centre',
|
|
94
|
-
formatOptions: {
|
|
95
|
-
format: 'webp',
|
|
96
|
-
options: {
|
|
97
|
-
quality: 80
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
name: 'thumbnail_avif',
|
|
103
|
-
width: 200,
|
|
104
|
-
height: undefined,
|
|
105
|
-
position: 'centre',
|
|
106
|
-
formatOptions: {
|
|
107
|
-
format: 'avif',
|
|
108
|
-
options: {
|
|
109
|
-
quality: 60,
|
|
110
|
-
effort: 1,
|
|
111
|
-
chromaSubsampling: '4:4:4',
|
|
112
|
-
bitdepth: 8,
|
|
113
|
-
lossless: false
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
},
|
|
117
|
-
// Mobile Sizes
|
|
118
|
-
{
|
|
119
|
-
name: 'mobile',
|
|
120
|
-
width: 500,
|
|
121
|
-
height: undefined
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
name: 'mobile_webp',
|
|
125
|
-
width: 500,
|
|
126
|
-
height: undefined,
|
|
127
|
-
formatOptions: {
|
|
128
|
-
format: 'webp',
|
|
129
|
-
options: {
|
|
130
|
-
quality: 80
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
{
|
|
135
|
-
name: 'mobile_avif',
|
|
136
|
-
width: 500,
|
|
137
|
-
height: undefined,
|
|
138
|
-
formatOptions: {
|
|
139
|
-
format: 'avif',
|
|
140
|
-
options: {
|
|
141
|
-
quality: 60,
|
|
142
|
-
effort: 1,
|
|
143
|
-
chromaSubsampling: '4:4:4',
|
|
144
|
-
bitdepth: 8,
|
|
145
|
-
lossless: false
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
},
|
|
149
|
-
// Tablet Sizes
|
|
150
|
-
{
|
|
151
|
-
name: 'tablet',
|
|
152
|
-
width: 800,
|
|
153
|
-
height: undefined
|
|
154
|
-
},
|
|
155
|
-
{
|
|
156
|
-
name: 'tablet_webp',
|
|
157
|
-
width: 800,
|
|
158
|
-
height: undefined,
|
|
159
|
-
formatOptions: {
|
|
160
|
-
format: 'webp',
|
|
161
|
-
options: {
|
|
162
|
-
quality: 80
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
},
|
|
166
|
-
{
|
|
167
|
-
name: 'tablet_avif',
|
|
168
|
-
width: 800,
|
|
169
|
-
height: undefined,
|
|
170
|
-
formatOptions: {
|
|
171
|
-
format: 'avif',
|
|
172
|
-
options: {
|
|
173
|
-
quality: 60,
|
|
174
|
-
effort: 1,
|
|
175
|
-
chromaSubsampling: '4:4:4',
|
|
176
|
-
bitdepth: 8,
|
|
177
|
-
lossless: false
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
]
|
|
213
|
+
imageSizes: sizes,
|
|
214
|
+
...args.uploadOverrides ? args.uploadOverrides : {}
|
|
182
215
|
}
|
|
183
216
|
};
|
|
184
217
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/collections/Media.ts"],"sourcesContent":["import { lexicalEditor } from '@payloadcms/richtext-lexical';\nimport * as mime from 'mime-types';\nimport type { CollectionConfig, Field, PayloadRequest } from 'payload';\
|
|
1
|
+
{"version":3,"sources":["../../src/collections/Media.ts"],"sourcesContent":["import { lexicalEditor } from '@payloadcms/richtext-lexical';\nimport * as mime from 'mime-types';\nimport type { CollectionConfig, Field, PayloadRequest, UploadConfig } from 'payload';\nimport env from '../util/env.js';\nimport type { ImageSize } from \"payload\";\n\nexport interface MediaArgs {\n\tincludeAvif?: boolean\n\tadditionalFields?: Field[],\n\tuploadOverrides?: Partial<UploadConfig>\n}\n\nexport const imageSizes: ImageSize[] = [\n\t{\n\t\tname: 'webp',\n\t\twidth: undefined,\n\t\theight: undefined,\n\t\tformatOptions: {\n\t\t\tformat: 'webp',\n\t\t\toptions: {\n\t\t\t\tquality: 80,\n\t\t\t},\n\t\t},\n\t},\n\t{\n\t\tname: 'thumbnail',\n\t\twidth: 200,\n\t\theight: undefined,\n\t\tposition: 'centre',\n\t},\n\t{\n\t\tname: 'thumbnail_webp',\n\t\twidth: 200,\n\t\theight: undefined,\n\t\tposition: 'centre',\n\t\tformatOptions: {\n\t\t\tformat: 'webp',\n\t\t\toptions: {\n\t\t\t\tquality: 80,\n\t\t\t},\n\t\t},\n\t},\n\t{\n\t\tname: 'mobile',\n\t\twidth: 500,\n\t\theight: undefined,\n\t},\n\t{\n\t\tname: 'mobile_webp',\n\t\twidth: 500,\n\t\theight: undefined,\n\t\tformatOptions: {\n\t\t\tformat: 'webp',\n\t\t\toptions: {\n\t\t\t\tquality: 80,\n\t\t\t},\n\t\t},\n\t},\n\t{\n\t\tname: 'tablet',\n\t\twidth: 800,\n\t\theight: undefined,\n\t},\n\t{\n\t\tname: 'tablet_webp',\n\t\twidth: 800,\n\t\theight: undefined,\n\t\tformatOptions: {\n\t\t\tformat: 'webp',\n\t\t\toptions: {\n\t\t\t\tquality: 80,\n\t\t\t},\n\t\t},\n\t},\n\t{\n\t\tname: 'desktop',\n\t\twidth: 1200,\n\t\theight: undefined,\n\t},\n\t{\n\t\tname: 'desktop_webp',\n\t\twidth: 1200,\n\t\theight: undefined,\n\t\tformatOptions: {\n\t\t\tformat: 'webp',\n\t\t\toptions: {\n\t\t\t\tquality: 80,\n\t\t\t},\n\t\t},\n\t},\n];\n\nexport const imageSizesWithAvif = (): ImageSize[] => {\n\treturn [\n\t\t...imageSizes,\n\t\t{\n\t\t\tname: 'avif',\n\t\t\twidth: undefined,\n\t\t\theight: undefined,\n\t\t\tformatOptions: {\n\t\t\t\tformat: 'avif',\n\t\t\t\toptions: {\n\t\t\t\t\tquality: 60,\n\t\t\t\t\teffort: 1,\n\t\t\t\t\tchromaSubsampling: '4:4:4',\n\t\t\t\t\tbitdepth: 8,\n\t\t\t\t\tlossless: false,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: 'thumbnail_avif',\n\t\t\twidth: 200,\n\t\t\theight: undefined,\n\t\t\tposition: 'centre',\n\t\t\tformatOptions: {\n\t\t\t\tformat: 'avif',\n\t\t\t\toptions: {\n\t\t\t\t\tquality: 60,\n\t\t\t\t\teffort: 1,\n\t\t\t\t\tchromaSubsampling: '4:4:4',\n\t\t\t\t\tbitdepth: 8,\n\t\t\t\t\tlossless: false,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: 'mobile_avif',\n\t\t\twidth: 500,\n\t\t\theight: undefined,\n\t\t\tformatOptions: {\n\t\t\t\tformat: 'avif',\n\t\t\t\toptions: {\n\t\t\t\t\tquality: 60,\n\t\t\t\t\teffort: 1,\n\t\t\t\t\tchromaSubsampling: '4:4:4',\n\t\t\t\t\tbitdepth: 8,\n\t\t\t\t\tlossless: false,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: 'tablet_avif',\n\t\t\twidth: 800,\n\t\t\theight: undefined,\n\t\t\tformatOptions: {\n\t\t\t\tformat: 'avif',\n\t\t\t\toptions: {\n\t\t\t\t\tquality: 60,\n\t\t\t\t\teffort: 1,\n\t\t\t\t\tchromaSubsampling: '4:4:4',\n\t\t\t\t\tbitdepth: 8,\n\t\t\t\t\tlossless: false,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: 'desktop_avif',\n\t\t\twidth: 1200,\n\t\t\theight: undefined,\n\t\t\tformatOptions: {\n\t\t\t\tformat: 'avif',\n\t\t\t\toptions: {\n\t\t\t\t\tquality: 80,\n\t\t\t\t},\n\t\t\t},\n\t\t}\n\t]\n}\n\nexport const Media = (args: MediaArgs = {}): CollectionConfig => {\n\tlet sizes = imageSizes;\n\tif (args.includeAvif) {\n\t\tsizes = imageSizesWithAvif();\n\t}\n\n\treturn {\n\t\tslug: 'media',\n\t\taccess: {\n\t\t\tread: () => true,\n\t\t},\n\t\tfields: [\n\t\t\t{\n\t\t\t\tname: 'alt',\n\t\t\t\ttype: 'text',\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'caption',\n\t\t\t\ttype: 'richText',\n\t\t\t\trequired: false,\n\t\t\t\teditor: lexicalEditor({\n\t\t\t\t\tfeatures: ({ defaultFeatures }) => {\n\t\t\t\t\t\treturn defaultFeatures.filter((feature) => {\n\t\t\t\t\t\t\treturn feature.key === 'paragraph' || feature.key === 'link';\n\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t\t},\n\t\t\t...(args.additionalFields ? args.additionalFields : []),\n\t\t],\n\t\tupload: {\n\t\t\tstaticDir: 'media',\n\t\t\tadminThumbnail: 'thumbnail',\n\t\t\tdisableLocalStorage: env.isProduction,\n\t\t\thandlers: [\n\t\t\t\tasync (req: PayloadRequest, args) => {\n\t\t\t\t\tconst logger = req.payload.logger;\n\t\t\t\t\tconst { params } = args;\n\t\t\t\t\tconst { collection, filename } = params;\n\n\t\t\t\t\tif (collection !== 'media') {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst contentType = mime.lookup(filename);\n\t\t\t\t\tif (!contentType) {\n\t\t\t\t\t\tlogger.error(`Unable to find mime type for file: ${filename}`);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst headers = new Headers();\n\t\t\t\t\theaders.set('Content-Type', contentType);\n\t\t\t\t\theaders.set('Cache-Control', 'public, max-age=31536000');\n\n\t\t\t\t\treq.responseHeaders = headers;\n\t\t\t\t},\n\t\t\t],\n\t\t\timageSizes: sizes,\n\t\t\t...(args.uploadOverrides ? args.uploadOverrides : {}),\n\t\t},\n\t};\n};\n"],"names":["lexicalEditor","mime","env","imageSizes","name","width","undefined","height","formatOptions","format","options","quality","position","imageSizesWithAvif","effort","chromaSubsampling","bitdepth","lossless","Media","args","sizes","includeAvif","slug","access","read","fields","type","required","editor","features","defaultFeatures","filter","feature","key","additionalFields","upload","staticDir","adminThumbnail","disableLocalStorage","isProduction","handlers","req","logger","payload","params","collection","filename","contentType","lookup","error","headers","Headers","set","responseHeaders","uploadOverrides"],"mappings":"AAAA,SAASA,aAAa,QAAQ,+BAA+B;AAC7D,YAAYC,UAAU,aAAa;AAEnC,OAAOC,SAAS,iBAAiB;AASjC,OAAO,MAAMC,aAA0B;IACtC;QACCC,MAAM;QACNC,OAAOC;QACPC,QAAQD;QACRE,eAAe;YACdC,QAAQ;YACRC,SAAS;gBACRC,SAAS;YACV;QACD;IACD;IACA;QACCP,MAAM;QACNC,OAAO;QACPE,QAAQD;QACRM,UAAU;IACX;IACA;QACCR,MAAM;QACNC,OAAO;QACPE,QAAQD;QACRM,UAAU;QACVJ,eAAe;YACdC,QAAQ;YACRC,SAAS;gBACRC,SAAS;YACV;QACD;IACD;IACA;QACCP,MAAM;QACNC,OAAO;QACPE,QAAQD;IACT;IACA;QACCF,MAAM;QACNC,OAAO;QACPE,QAAQD;QACRE,eAAe;YACdC,QAAQ;YACRC,SAAS;gBACRC,SAAS;YACV;QACD;IACD;IACA;QACCP,MAAM;QACNC,OAAO;QACPE,QAAQD;IACT;IACA;QACCF,MAAM;QACNC,OAAO;Q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OAAO;QACNS,MAAM;QACNC,QAAQ;YACPC,MAAM,IAAM;QACb;QACAC,QAAQ;YACP;gBACCrB,MAAM;gBACNsB,MAAM;gBACNC,UAAU;YACX;YACA;gBACCvB,MAAM;gBACNsB,MAAM;gBACNC,UAAU;gBACVC,QAAQ5B,cAAc;oBACrB6B,UAAU,CAAC,EAAEC,eAAe,EAAE;wBAC7B,OAAOA,gBAAgBC,MAAM,CAAC,CAACC;4BAC9B,OAAOA,QAAQC,GAAG,KAAK,eAAeD,QAAQC,GAAG,KAAK;wBACvD;oBACD;gBACD;YACD;eACId,KAAKe,gBAAgB,GAAGf,KAAKe,gBAAgB,GAAG,EAAE;SACtD;QACDC,QAAQ;YACPC,WAAW;YACXC,gBAAgB;YAChBC,qBAAqBpC,IAAIqC,YAAY;YACrCC,UAAU;gBACT,OAAOC,KAAqBtB;oBAC3B,MAAMuB,SAASD,IAAIE,OAAO,CAACD,MAAM;oBACjC,MAAM,EAAEE,MAAM,EAAE,GAAGzB;oBACnB,MAAM,EAAE0B,UAAU,EAAEC,QAAQ,EAAE,GAAGF;oBAEjC,IAAIC,eAAe,SAAS;wBAC3B;oBACD;oBAEA,MAAME,cAAc9C,KAAK+C,MAAM,CAACF;oBAChC,IAAI,CAACC,aAAa;wBACjBL,OAAOO,KAAK,CAAC,CAAC,mCAAmC,EAAEH,SAAS,CAAC;wBAC7D;oBACD;oBAEA,MAAMI,UAAU,IAAIC;oBACpBD,QAAQE,GAAG,CAAC,gBAAgBL;oBAC5BG,QAAQE,GAAG,CAAC,iBAAiB;oBAE7BX,IAAIY,eAAe,GAAGH;gBACvB;aACA;YACD/C,YAAYiB;YACZ,GAAID,KAAKmC,eAAe,GAAGnC,KAAKmC,eAAe,GAAG,CAAC,CAAC;QACrD;IACD;AACD,EAAE"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type SanitizedConfig } from 'payload';
|
|
2
|
+
import { type SchemaOptions } from '../plugin/schema.js';
|
|
3
|
+
/**
|
|
4
|
+
* Creates JSON schema types of Payloads Collections & Globals
|
|
5
|
+
*/
|
|
6
|
+
export declare function generateTypes(config: SanitizedConfig, opts: SchemaOptions): Promise<void>;
|
|
@@ -1,28 +1,21 @@
|
|
|
1
1
|
import * as fs from 'node:fs';
|
|
2
2
|
import { configToJSONSchema, getPayload } from 'payload';
|
|
3
|
-
import {
|
|
3
|
+
import { fieldMapper, schemas } from '../plugin/schema.js';
|
|
4
4
|
/**
|
|
5
5
|
* Creates JSON schema types of Payloads Collections & Globals
|
|
6
|
-
*/ export async function generateTypes(
|
|
6
|
+
*/ export async function generateTypes(config, opts) {
|
|
7
7
|
console.log('Compiling JSON types for Collections and Globals...');
|
|
8
|
-
let configPath = '';
|
|
9
|
-
try {
|
|
10
|
-
configPath = findConfig();
|
|
11
|
-
} catch (e) {
|
|
12
|
-
console.log(`Error finding config: ${e}`);
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
// Set the environment variable to generate Golang types.
|
|
16
|
-
process.env.GEN_GOLANG = 'true';
|
|
17
|
-
const config = await importConfig(configPath);
|
|
18
8
|
const outputFile = (process.env.PAYLOAD_TS_OUTPUT_PATH || config.typescript.outputFile).replace('.ts', '.json');
|
|
9
|
+
config.typescript = {
|
|
10
|
+
...config.typescript,
|
|
11
|
+
schema: schemas(opts)
|
|
12
|
+
};
|
|
13
|
+
// biome-ignore lint/style/noParameterAssign: Need to change field mapper.
|
|
14
|
+
config = fieldMapper(config, opts);
|
|
19
15
|
const payload = await getPayload({
|
|
20
16
|
config,
|
|
21
17
|
disableDBConnect: true,
|
|
22
|
-
disableOnInit: true
|
|
23
|
-
// @ts-ignore
|
|
24
|
-
local: true,
|
|
25
|
-
secret: '--unused--'
|
|
18
|
+
disableOnInit: true
|
|
26
19
|
});
|
|
27
20
|
const jsonSchema = configToJSONSchema(payload.config, payload.db.defaultIDType);
|
|
28
21
|
const prettyJSON = JSON.stringify(jsonSchema, null, 4);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/gen/types.ts"],"sourcesContent":["import * as fs from 'node:fs';\nimport { configToJSONSchema, getPayload, type SanitizedConfig } from 'payload';\nimport { fieldMapper, type SchemaOptions, schemas } from '../plugin/schema.js';\n\n/**\n * Creates JSON schema types of Payloads Collections & Globals\n */\nexport async function generateTypes(config: SanitizedConfig, opts: SchemaOptions): Promise<void> {\n\tconsole.log('Compiling JSON types for Collections and Globals...');\n\n\tconst outputFile = (process.env.PAYLOAD_TS_OUTPUT_PATH || config.typescript.outputFile).replace(\n\t\t'.ts',\n\t\t'.json',\n\t);\n\n\tconfig.typescript = {\n\t\t...config.typescript,\n\t\tschema: schemas(opts)\n\t};\n\n\t// biome-ignore lint/style/noParameterAssign: Need to change field mapper.\n\tconfig = fieldMapper(config, opts);\n\n\tconst payload = await getPayload({\n\t\tconfig,\n\t\tdisableDBConnect: true,\n\t\tdisableOnInit: true,\n\t});\n\n\tconst jsonSchema = configToJSONSchema(payload.config, payload.db.defaultIDType);\n\tconst prettyJSON = JSON.stringify(jsonSchema, null, 4);\n\n\tfs.writeFileSync(outputFile, prettyJSON);\n\n\tconsole.log(`JSON types written to: ${outputFile}`);\n\n\tdelete process.env.GEN_GOLANG;\n}\n"],"names":["fs","configToJSONSchema","getPayload","fieldMapper","schemas","generateTypes","config","opts","console","log","outputFile","process","env","PAYLOAD_TS_OUTPUT_PATH","typescript","replace","schema","payload","disableDBConnect","disableOnInit","jsonSchema","db","defaultIDType","prettyJSON","JSON","stringify","writeFileSync","GEN_GOLANG"],"mappings":"AAAA,YAAYA,QAAQ,UAAU;AAC9B,SAASC,kBAAkB,EAAEC,UAAU,QAA8B,UAAU;AAC/E,SAASC,WAAW,EAAsBC,OAAO,QAAQ,sBAAsB;AAE/E;;CAEC,GACD,OAAO,eAAeC,cAAcC,MAAuB,EAAEC,IAAmB;IAC/EC,QAAQC,GAAG,CAAC;IAEZ,MAAMC,aAAa,AAACC,CAAAA,QAAQC,GAAG,CAACC,sBAAsB,IAAIP,OAAOQ,UAAU,CAACJ,UAAU,AAAD,EAAGK,OAAO,CAC9F,OACA;IAGDT,OAAOQ,UAAU,GAAG;QACnB,GAAGR,OAAOQ,UAAU;QACpBE,QAAQZ,QAAQG;IACjB;IAEA,0EAA0E;IAC1ED,SAASH,YAAYG,QAAQC;IAE7B,MAAMU,UAAU,MAAMf,WAAW;QAChCI;QACAY,kBAAkB;QAClBC,eAAe;IAChB;IAEA,MAAMC,aAAanB,mBAAmBgB,QAAQX,MAAM,EAAEW,QAAQI,EAAE,CAACC,aAAa;IAC9E,MAAMC,aAAaC,KAAKC,SAAS,CAACL,YAAY,MAAM;IAEpDpB,GAAG0B,aAAa,CAAChB,YAAYa;IAE7Bf,QAAQC,GAAG,CAAC,CAAC,uBAAuB,EAAEC,WAAW,CAAC;IAElD,OAAOC,QAAQC,GAAG,CAACe,UAAU;AAC9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/globals/Settings.ts"],"sourcesContent":["import type { GlobalConfig, GroupField, Tab, UploadField } from 'payload';\nimport { validatePostcode, validateURL } from '../util/validation.js';\nimport { countries } from './countries.js';\nimport { languages } from './locales.js';\n\n/**\n * Settings Global Configuration\n * Additional tabs will be appended to the settings page.\n * TODO, type error in here somewhere.\n *\n * @param additionalTabs\n * @constructor\n */\nexport const Settings = (additionalTabs: Tab[]): GlobalConfig => {\n\treturn {\n\t\tslug: 'settings',\n\t\ttypescript: {\n\t\t\tinterface: 'Settings',\n\t\t},\n\t\tgraphQL: {\n\t\t\tname: 'Settings',\n\t\t},\n\t\taccess: {\n\t\t\tread: () => true,\n\t\t},\n\t\tfields: [\n\t\t\t{\n\t\t\t\ttype: 'tabs',\n\t\t\t\ttabs: [\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: 'Global',\n\t\t\t\t\t\tdescription: 'Configure global settings for the website.',\n\t\t\t\t\t\tfields: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: 'row',\n\t\t\t\t\t\t\t\tfields: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tname: 'siteName',\n\t\t\t\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\t\t\t\tlabel: 'Site Name',\n\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t\t\t\t'Add a site name for the website, this will be outputted in the Open Graph schema as well as a suffix for the meta title.',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tname: 'locale',\n\t\t\t\t\t\t\t\t\t\ttype: 'select',\n\t\t\t\t\t\t\t\t\t\tlabel: 'Locale',\n\t\t\t\t\t\t\t\t\t\tdefaultValue: 'en_GB',\n\t\t\t\t\t\t\t\t\t\toptions: languages.map((l) => {\n\t\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: l.name,\n\t\t\t\t\t\t\t\t\t\t\t\tvalue: l.code,\n\t\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t\t\t\t'Add a locale for the website, this will be outputted in the Open Graph schema and the top level HTML tag. Defaults to en_GB.',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\ttypescriptSchema: [\n\t\t\t\t\t\t\t\t\t\t\t() => ({\n\t\t\t\t\t\t\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: 'tagLine',\n\t\t\t\t\t\t\t\ttype: 'textarea',\n\t\t\t\t\t\t\t\tlabel: 'Tag Line',\n\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\tdescription: 'In a few words, explain what this site is about',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: 'logo',\n\t\t\t\t\t\t\t\ttype: 'upload',\n\t\t\t\t\t\t\t\trelationTo: 'media',\n\t\t\t\t\t\t\t\tfilterOptions: {\n\t\t\t\t\t\t\t\t\tmimeType: {\n\t\t\t\t\t\t\t\t\t\tcontains: 'image',\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t\t'Add a logo for the website that will be displayed in the header & across the website.',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t} as UploadField,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: 'robots',\n\t\t\t\t\t\t\t\ttype: 'textarea',\n\t\t\t\t\t\t\t\tlabel: 'Robots.txt',\n\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t\t'Robots.txt is a text file webmasters create to instruct web robots (typically search engine robots) how to crawl pages on their website.',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: 'Code Injection',\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'Code injection allows you to inject a small snippet of HTML into your site. It can be a css override, analytics of a block javascript.',\n\t\t\t\t\t\tfields: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: 'codeInjection',\n\t\t\t\t\t\t\t\ttype: 'group',\n\t\t\t\t\t\t\t\tfields: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tname: 'head',\n\t\t\t\t\t\t\t\t\t\ttype: 'code',\n\t\t\t\t\t\t\t\t\t\tlabel: 'Head',\n\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\tlanguage: 'html',\n\t\t\t\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t\t\t\t'Outputs code within the <head> of the website.',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tname: 'footer',\n\t\t\t\t\t\t\t\t\t\ttype: 'code',\n\t\t\t\t\t\t\t\t\t\tlabel: 'Footer',\n\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\tlanguage: 'html',\n\t\t\t\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t\t\t\t'Outputs code in the footer of the website.',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: 'Contact Details',\n\t\t\t\t\t\tfields: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: 'contact',\n\t\t\t\t\t\t\t\ttype: 'group',\n\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\thideGutter: true,\n\t\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t\t'Add global contact details for the website that will be used in schema & contact pages.',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tfields: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttype: 'row',\n\t\t\t\t\t\t\t\t\t\tfields: [\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tname: 'email',\n\t\t\t\t\t\t\t\t\t\t\t\ttype: 'email',\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: 'Email',\n\t\t\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tname: 'telephone',\n\t\t\t\t\t\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: 'Telephone',\n\t\t\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t} as GroupField,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: 'group',\n\t\t\t\t\t\t\t\tname: 'address',\n\t\t\t\t\t\t\t\tlabel: 'Address',\n\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\thideGutter: true,\n\t\t\t\t\t\t\t\t\tdescription: 'Add an address for the website.',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tfields: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttype: 'row',\n\t\t\t\t\t\t\t\t\t\tfields: [\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tname: 'line1',\n\t\t\t\t\t\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: 'Line 1',\n\t\t\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tname: 'line2',\n\t\t\t\t\t\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: 'Line 2',\n\t\t\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tname: 'city',\n\t\t\t\t\t\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: 'City',\n\t\t\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tname: 'county',\n\t\t\t\t\t\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: 'County',\n\t\t\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tname: 'postcode',\n\t\t\t\t\t\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: 'Postcode',\n\t\t\t\t\t\t\t\t\t\t\t\tvalidate: validatePostcode,\n\t\t\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tname: 'country',\n\t\t\t\t\t\t\t\t\t\t\t\ttype: 'select',\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: 'Country',\n\t\t\t\t\t\t\t\t\t\t\t\toptions: countries.map((c) => {\n\t\t\t\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tlabel: c,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tvalue: c,\n\t\t\t\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t} as GroupField,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: 'group',\n\t\t\t\t\t\t\t\tname: 'social',\n\t\t\t\t\t\t\t\tlabel: 'Social Links',\n\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\thideGutter: true,\n\t\t\t\t\t\t\t\t\tdescription: 'Add social links for the website.',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tfields: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttype: 'row',\n\t\t\t\t\t\t\t\t\t\tfields: [\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tname: 'linkedIn',\n\t\t\t\t\t\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: 'LinkedIn',\n\t\t\t\t\t\t\t\t\t\t\t\tvalidate: validateURL,\n\t\t\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tname: 'x',\n\t\t\t\t\t\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: 'X',\n\t\t\t\t\t\t\t\t\t\t\t\tvalidate: validateURL,\n\t\t\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tname: 'facebook',\n\t\t\t\t\t\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: 'Facebook',\n\t\t\t\t\t\t\t\t\t\t\t\tvalidate: validateURL,\n\t\t\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tname: 'instagram',\n\t\t\t\t\t\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: 'Instagram',\n\t\t\t\t\t\t\t\t\t\t\t\tvalidate: validateURL,\n\t\t\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tname: 'youtube',\n\t\t\t\t\t\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: 'Youtube',\n\t\t\t\t\t\t\t\t\t\t\t\tvalidate: validateURL,\n\t\t\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tname: 'tiktok',\n\t\t\t\t\t\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: 'TikTok',\n\t\t\t\t\t\t\t\t\t\t\t\tvalidate: validateURL,\n\t\t\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t} as GroupField,\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: 'Maintenance',\n\t\t\t\t\t\tfields: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: 'maintenance',\n\t\t\t\t\t\t\t\ttype: 'group',\n\t\t\t\t\t\t\t\tfields: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tname: 'enabled',\n\t\t\t\t\t\t\t\t\t\ttype: 'checkbox',\n\t\t\t\t\t\t\t\t\t\tlabel: 'Enable',\n\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t\t\t\t'Enable maintenance mode for the site, this will use a maintenance page template and not include any of the sites functioanlity.',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tname: 'title',\n\t\t\t\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\t\t\t\tlabel: 'Title',\n\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\tdescription: 'Add a title for the maintenance page.',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tname: 'content',\n\t\t\t\t\t\t\t\t\t\ttype: 'textarea',\n\t\t\t\t\t\t\t\t\t\tlabel: 'Content',\n\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t\t\t\t'Add content for the maintenance page, it will appear beneath the title.',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\t...(additionalTabs ? additionalTabs : []),\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n};\n"],"names":["validatePostcode","validateURL","countries","languages","Settings","additionalTabs","slug","typescript","interface","graphQL","name","access","read","fields","type","tabs","label","description","admin","width","defaultValue","options","map","l","value","code","typescriptSchema","relationTo","filterOptions","mimeType","contains","language","hideGutter","validate","c"],"mappings":"AACA,SAASA,gBAAgB,EAAEC,WAAW,QAAQ,wBAAwB;AACtE,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,SAAS,QAAQ,eAAe;AAEzC;;;;;;;CAOC,GACD,OAAO,MAAMC,WAAW,CAACC;IACxB,OAAO;QACNC,MAAM;QACNC,YAAY;YACXC,WAAW;QACZ;QACAC,SAAS;YACRC,MAAM;QACP;QACAC,QAAQ;YACPC,MAAM,IAAM;QACb;QACAC,QAAQ;YACP;gBACCC,MAAM;gBACNC,MAAM;oBACL;wBACCC,OAAO;wBACPC,aAAa;wBACbJ,QAAQ;4BACP;gCACCC,MAAM;gCACND,QAAQ;oCACP;wCACCH,MAAM;wCACNI,MAAM;wCACNE,OAAO;wCACPE,OAAO;4CACNC,OAAO;4CACPF,aACC;wCACF;oCACD;oCACA;wCACCP,MAAM;wCACNI,MAAM;wCACNE,OAAO;wCACPI,cAAc;wCACdC,SAASlB,UAAUmB,GAAG,CAAC,CAACC;4CACvB,OAAO;gDACNP,OAAOO,EAAEb,IAAI;gDACbc,OAAOD,EAAEE,IAAI;4CACd;wCACD;wCACAP,OAAO;4CACNC,OAAO;4CACPF,aACC;wCACF;wCACAS,kBAAkB;4CACjB,IAAO,CAAA;oDACNZ,MAAM;gDACP,CAAA;yCACA;oCACF;iCACA;4BACF;4BACA;gCACCJ,MAAM;gCACNI,MAAM;gCACNE,OAAO;gCACPE,OAAO;oCACND,aAAa;gCACd;4BACD;4BACA;gCACCP,MAAM;gCACNI,MAAM;gCACNa,YAAY;gCACZC,eAAe;oCACdC,UAAU;wCACTC,UAAU;oCACX;gCACD;gCACAZ,OAAO;oCACND,aACC;gCACF;4BACD;4BACA;gCACCP,MAAM;gCACNI,MAAM;gCACNE,OAAO;gCACPE,OAAO;oCACND,aACC;gCACF;4BACD;yBACA;oBACF;oBACA;wBACCD,OAAO;wBACPC,aACC;wBACDJ,QAAQ;4BACP;gCACCH,MAAM;gCACNI,MAAM;gCACND,QAAQ;oCACP;wCACCH,MAAM;wCACNI,MAAM;wCACNE,OAAO;wCACPE,OAAO;4CACNa,UAAU;4CACVd,aACC;wCACF;oCACD;oCACA;wCACCP,MAAM;wCACNI,MAAM;wCACNE,OAAO;wCACPE,OAAO;4CACNa,UAAU;4CACVd,aACC;wCACF;oCACD;iCACA;4BACF;yBACA;oBACF;oBACA;wBACCD,OAAO;wBACPH,QAAQ;4BACP;gCACCH,MAAM;gCACNI,MAAM;gCACNI,OAAO;oCACNc,YAAY;oCACZf,aACC;gCACF;gCACAJ,QAAQ;oCACP;wCACCC,MAAM;wCACND,QAAQ;4CACP;gDACCH,MAAM;gDACNI,MAAM;gDACNE,OAAO;gDACPE,OAAO;oDACNC,OAAO;gDACR;4CACD;4CACA;gDACCT,MAAM;gDACNI,MAAM;gDACNE,OAAO;gDACPE,OAAO;oDACNC,OAAO;gDACR;4CACD;yCACA;oCACF;iCACA;4BACF;4BACA;gCACCL,MAAM;gCACNJ,MAAM;gCACNM,OAAO;gCACPE,OAAO;oCACNc,YAAY;oCACZf,aAAa;gCACd;gCACAJ,QAAQ;oCACP;wCACCC,MAAM;wCACND,QAAQ;4CACP;gDACCH,MAAM;gDACNI,MAAM;gDACNE,OAAO;gDACPE,OAAO;oDACNC,OAAO;gDACR;4CACD;4CACA;gDACCT,MAAM;gDACNI,MAAM;gDACNE,OAAO;gDACPE,OAAO;oDACNC,OAAO;gDACR;4CACD;4CACA;gDACCT,MAAM;gDACNI,MAAM;gDACNE,OAAO;gDACPE,OAAO;oDACNC,OAAO;gDACR;4CACD;4CACA;gDACCT,MAAM;gDACNI,MAAM;gDACNE,OAAO;gDACPE,OAAO;oDACNC,OAAO;gDACR;4CACD;4CACA;gDACCT,MAAM;gDACNI,MAAM;gDACNE,OAAO;gDACPiB,UAAUjC;gDACVkB,OAAO;oDACNC,OAAO;gDACR;4CACD;4CACA;gDACCT,MAAM;gDACNI,MAAM;gDACNE,OAAO;gDACPK,SAASnB,UAAUoB,GAAG,CAAC,CAACY;oDACvB,OAAO;wDACNlB,OAAOkB;wDACPV,OAAOU;oDACR;gDACD;gDACAhB,OAAO;oDACNC,OAAO;gDACR;4CACD;yCACA;oCACF;iCACA;4BACF;4BACA;gCACCL,MAAM;gCACNJ,MAAM;gCACNM,OAAO;gCACPE,OAAO;oCACNc,YAAY;oCACZf,aAAa;gCACd;gCACAJ,QAAQ;oCACP;wCACCC,MAAM;wCACND,QAAQ;4CACP;gDACCH,MAAM;gDACNI,MAAM;gDACNE,OAAO;gDACPiB,UAAUhC;gDACViB,OAAO;oDACNC,OAAO;gDACR;4CACD;4CACA;gDACCT,MAAM;gDACNI,MAAM;gDACNE,OAAO;gDACPiB,UAAUhC;gDACViB,OAAO;oDACNC,OAAO;gDACR;4CACD;4CACA;gDACCT,MAAM;gDACNI,MAAM;gDACNE,OAAO;gDACPiB,UAAUhC;gDACViB,OAAO;oDACNC,OAAO;gDACR;4CACD;4CACA;gDACCT,MAAM;gDACNI,MAAM;gDACNE,OAAO;gDACPiB,UAAUhC;gDACViB,OAAO;oDACNC,OAAO;gDACR;4CACD;4CACA;gDACCT,MAAM;gDACNI,MAAM;gDACNE,OAAO;gDACPiB,UAAUhC;gDACViB,OAAO;oDACNC,OAAO;gDACR;4CACD;4CACA;gDACCT,MAAM;gDACNI,MAAM;gDACNE,OAAO;gDACPiB,UAAUhC;gDACViB,OAAO;oDACNC,OAAO;gDACR;4CACD;yCACA;oCACF;iCACA;4BACF;yBACA;oBACF;oBACA;wBACCH,OAAO;wBACPH,QAAQ;4BACP;gCACCH,MAAM;gCACNI,MAAM;gCACND,QAAQ;oCACP;wCACCH,MAAM;wCACNI,MAAM;wCACNE,OAAO;wCACPE,OAAO;4CACND,aACC;wCACF;oCACD;oCACA;wCACCP,MAAM;wCACNI,MAAM;wCACNE,OAAO;wCACPE,OAAO;4CACND,aAAa;wCACd;oCACD;oCACA;wCACCP,MAAM;wCACNI,MAAM;wCACNE,OAAO;wCACPE,OAAO;4CACND,aACC;wCACF;oCACD;iCACA;4BACF;yBACA;oBACF;uBACIZ,iBAAiBA,iBAAiB,EAAE;iBACxC;YACF;SACA;IACF;AACD,EAAE"}
|
|
1
|
+
{"version":3,"sources":["../../src/globals/Settings.ts"],"sourcesContent":["import type { GlobalConfig, GroupField, Tab, UploadField } from 'payload';\nimport { validatePostcode, validateURL } from '../util/validation.js';\nimport { countries } from './countries.js';\nimport { languages } from './locales.js';\n\n/**\n * Settings Global Configuration\n * Additional tabs will be appended to the settings page.\n * TODO, type error in here somewhere.\n *\n * @param additionalTabs\n * @constructor\n */\nexport const Settings = (additionalTabs?: Tab[]): GlobalConfig => {\n\treturn {\n\t\tslug: 'settings',\n\t\ttypescript: {\n\t\t\tinterface: 'Settings',\n\t\t},\n\t\tgraphQL: {\n\t\t\tname: 'Settings',\n\t\t},\n\t\taccess: {\n\t\t\tread: () => true,\n\t\t},\n\t\tfields: [\n\t\t\t{\n\t\t\t\ttype: 'tabs',\n\t\t\t\ttabs: [\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: 'Global',\n\t\t\t\t\t\tdescription: 'Configure global settings for the website.',\n\t\t\t\t\t\tfields: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: 'row',\n\t\t\t\t\t\t\t\tfields: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tname: 'siteName',\n\t\t\t\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\t\t\t\tlabel: 'Site Name',\n\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t\t\t\t'Add a site name for the website, this will be outputted in the Open Graph schema as well as a suffix for the meta title.',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tname: 'locale',\n\t\t\t\t\t\t\t\t\t\ttype: 'select',\n\t\t\t\t\t\t\t\t\t\tlabel: 'Locale',\n\t\t\t\t\t\t\t\t\t\tdefaultValue: 'en_GB',\n\t\t\t\t\t\t\t\t\t\toptions: languages.map((l) => {\n\t\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: l.name,\n\t\t\t\t\t\t\t\t\t\t\t\tvalue: l.code,\n\t\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t\t\t\t'Add a locale for the website, this will be outputted in the Open Graph schema and the top level HTML tag. Defaults to en_GB.',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\ttypescriptSchema: [\n\t\t\t\t\t\t\t\t\t\t\t() => ({\n\t\t\t\t\t\t\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: 'tagLine',\n\t\t\t\t\t\t\t\ttype: 'textarea',\n\t\t\t\t\t\t\t\tlabel: 'Tag Line',\n\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\tdescription: 'In a few words, explain what this site is about',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: 'logo',\n\t\t\t\t\t\t\t\ttype: 'upload',\n\t\t\t\t\t\t\t\trelationTo: 'media',\n\t\t\t\t\t\t\t\tfilterOptions: {\n\t\t\t\t\t\t\t\t\tmimeType: {\n\t\t\t\t\t\t\t\t\t\tcontains: 'image',\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t\t'Add a logo for the website that will be displayed in the header & across the website.',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t} as UploadField,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: 'robots',\n\t\t\t\t\t\t\t\ttype: 'textarea',\n\t\t\t\t\t\t\t\tlabel: 'Robots.txt',\n\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t\t'Robots.txt is a text file webmasters create to instruct web robots (typically search engine robots) how to crawl pages on their website.',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: 'Code Injection',\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'Code injection allows you to inject a small snippet of HTML into your site. It can be a css override, analytics of a block javascript.',\n\t\t\t\t\t\tfields: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: 'codeInjection',\n\t\t\t\t\t\t\t\ttype: 'group',\n\t\t\t\t\t\t\t\tfields: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tname: 'head',\n\t\t\t\t\t\t\t\t\t\ttype: 'code',\n\t\t\t\t\t\t\t\t\t\tlabel: 'Head',\n\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\tlanguage: 'html',\n\t\t\t\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t\t\t\t'Outputs code within the <head> of the website.',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tname: 'footer',\n\t\t\t\t\t\t\t\t\t\ttype: 'code',\n\t\t\t\t\t\t\t\t\t\tlabel: 'Footer',\n\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\tlanguage: 'html',\n\t\t\t\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t\t\t\t'Outputs code in the footer of the website.',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: 'Contact Details',\n\t\t\t\t\t\tfields: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: 'contact',\n\t\t\t\t\t\t\t\ttype: 'group',\n\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\thideGutter: true,\n\t\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t\t'Add global contact details for the website that will be used in schema & contact pages.',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tfields: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttype: 'row',\n\t\t\t\t\t\t\t\t\t\tfields: [\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tname: 'email',\n\t\t\t\t\t\t\t\t\t\t\t\ttype: 'email',\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: 'Email',\n\t\t\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tname: 'telephone',\n\t\t\t\t\t\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: 'Telephone',\n\t\t\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t} as GroupField,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: 'group',\n\t\t\t\t\t\t\t\tname: 'address',\n\t\t\t\t\t\t\t\tlabel: 'Address',\n\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\thideGutter: true,\n\t\t\t\t\t\t\t\t\tdescription: 'Add an address for the website.',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tfields: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttype: 'row',\n\t\t\t\t\t\t\t\t\t\tfields: [\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tname: 'line1',\n\t\t\t\t\t\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: 'Line 1',\n\t\t\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tname: 'line2',\n\t\t\t\t\t\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: 'Line 2',\n\t\t\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tname: 'city',\n\t\t\t\t\t\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: 'City',\n\t\t\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tname: 'county',\n\t\t\t\t\t\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: 'County',\n\t\t\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tname: 'postcode',\n\t\t\t\t\t\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: 'Postcode',\n\t\t\t\t\t\t\t\t\t\t\t\tvalidate: validatePostcode,\n\t\t\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tname: 'country',\n\t\t\t\t\t\t\t\t\t\t\t\ttype: 'select',\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: 'Country',\n\t\t\t\t\t\t\t\t\t\t\t\toptions: countries.map((c) => {\n\t\t\t\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tlabel: c,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tvalue: c,\n\t\t\t\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t} as GroupField,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: 'group',\n\t\t\t\t\t\t\t\tname: 'social',\n\t\t\t\t\t\t\t\tlabel: 'Social Links',\n\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\thideGutter: true,\n\t\t\t\t\t\t\t\t\tdescription: 'Add social links for the website.',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tfields: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttype: 'row',\n\t\t\t\t\t\t\t\t\t\tfields: [\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tname: 'linkedIn',\n\t\t\t\t\t\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: 'LinkedIn',\n\t\t\t\t\t\t\t\t\t\t\t\tvalidate: validateURL,\n\t\t\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tname: 'x',\n\t\t\t\t\t\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: 'X',\n\t\t\t\t\t\t\t\t\t\t\t\tvalidate: validateURL,\n\t\t\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tname: 'facebook',\n\t\t\t\t\t\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: 'Facebook',\n\t\t\t\t\t\t\t\t\t\t\t\tvalidate: validateURL,\n\t\t\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tname: 'instagram',\n\t\t\t\t\t\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: 'Instagram',\n\t\t\t\t\t\t\t\t\t\t\t\tvalidate: validateURL,\n\t\t\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tname: 'youtube',\n\t\t\t\t\t\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: 'Youtube',\n\t\t\t\t\t\t\t\t\t\t\t\tvalidate: validateURL,\n\t\t\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tname: 'tiktok',\n\t\t\t\t\t\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: 'TikTok',\n\t\t\t\t\t\t\t\t\t\t\t\tvalidate: validateURL,\n\t\t\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t} as GroupField,\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: 'Maintenance',\n\t\t\t\t\t\tfields: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: 'maintenance',\n\t\t\t\t\t\t\t\ttype: 'group',\n\t\t\t\t\t\t\t\tfields: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tname: 'enabled',\n\t\t\t\t\t\t\t\t\t\ttype: 'checkbox',\n\t\t\t\t\t\t\t\t\t\tlabel: 'Enable',\n\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t\t\t\t'Enable maintenance mode for the site, this will use a maintenance page template and not include any of the sites functioanlity.',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tname: 'title',\n\t\t\t\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\t\t\t\tlabel: 'Title',\n\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\tdescription: 'Add a title for the maintenance page.',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tname: 'content',\n\t\t\t\t\t\t\t\t\t\ttype: 'textarea',\n\t\t\t\t\t\t\t\t\t\tlabel: 'Content',\n\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t\t\t\t'Add content for the maintenance page, it will appear beneath the title.',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\t...(additionalTabs ? additionalTabs : []),\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n};\n"],"names":["validatePostcode","validateURL","countries","languages","Settings","additionalTabs","slug","typescript","interface","graphQL","name","access","read","fields","type","tabs","label","description","admin","width","defaultValue","options","map","l","value","code","typescriptSchema","relationTo","filterOptions","mimeType","contains","language","hideGutter","validate","c"],"mappings":"AACA,SAASA,gBAAgB,EAAEC,WAAW,QAAQ,wBAAwB;AACtE,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,SAAS,QAAQ,eAAe;AAEzC;;;;;;;CAOC,GACD,OAAO,MAAMC,WAAW,CAACC;IACxB,OAAO;QACNC,MAAM;QACNC,YAAY;YACXC,WAAW;QACZ;QACAC,SAAS;YACRC,MAAM;QACP;QACAC,QAAQ;YACPC,MAAM,IAAM;QACb;QACAC,QAAQ;YACP;gBACCC,MAAM;gBACNC,MAAM;oBACL;wBACCC,OAAO;wBACPC,aAAa;wBACbJ,QAAQ;4BACP;gCACCC,MAAM;gCACND,QAAQ;oCACP;wCACCH,MAAM;wCACNI,MAAM;wCACNE,OAAO;wCACPE,OAAO;4CACNC,OAAO;4CACPF,aACC;wCACF;oCACD;oCACA;wCACCP,MAAM;wCACNI,MAAM;wCACNE,OAAO;wCACPI,cAAc;wCACdC,SAASlB,UAAUmB,GAAG,CAAC,CAACC;4CACvB,OAAO;gDACNP,OAAOO,EAAEb,IAAI;gDACbc,OAAOD,EAAEE,IAAI;4CACd;wCACD;wCACAP,OAAO;4CACNC,OAAO;4CACPF,aACC;wCACF;wCACAS,kBAAkB;4CACjB,IAAO,CAAA;oDACNZ,MAAM;gDACP,CAAA;yCACA;oCACF;iCACA;4BACF;4BACA;gCACCJ,MAAM;gCACNI,MAAM;gCACNE,OAAO;gCACPE,OAAO;oCACND,aAAa;gCACd;4BACD;4BACA;gCACCP,MAAM;gCACNI,MAAM;gCACNa,YAAY;gCACZC,eAAe;oCACdC,UAAU;wCACTC,UAAU;oCACX;gCACD;gCACAZ,OAAO;oCACND,aACC;gCACF;4BACD;4BACA;gCACCP,MAAM;gCACNI,MAAM;gCACNE,OAAO;gCACPE,OAAO;oCACND,aACC;gCACF;4BACD;yBACA;oBACF;oBACA;wBACCD,OAAO;wBACPC,aACC;wBACDJ,QAAQ;4BACP;gCACCH,MAAM;gCACNI,MAAM;gCACND,QAAQ;oCACP;wCACCH,MAAM;wCACNI,MAAM;wCACNE,OAAO;wCACPE,OAAO;4CACNa,UAAU;4CACVd,aACC;wCACF;oCACD;oCACA;wCACCP,MAAM;wCACNI,MAAM;wCACNE,OAAO;wCACPE,OAAO;4CACNa,UAAU;4CACVd,aACC;wCACF;oCACD;iCACA;4BACF;yBACA;oBACF;oBACA;wBACCD,OAAO;wBACPH,QAAQ;4BACP;gCACCH,MAAM;gCACNI,MAAM;gCACNI,OAAO;oCACNc,YAAY;oCACZf,aACC;gCACF;gCACAJ,QAAQ;oCACP;wCACCC,MAAM;wCACND,QAAQ;4CACP;gDACCH,MAAM;gDACNI,MAAM;gDACNE,OAAO;gDACPE,OAAO;oDACNC,OAAO;gDACR;4CACD;4CACA;gDACCT,MAAM;gDACNI,MAAM;gDACNE,OAAO;gDACPE,OAAO;oDACNC,OAAO;gDACR;4CACD;yCACA;oCACF;iCACA;4BACF;4BACA;gCACCL,MAAM;gCACNJ,MAAM;gCACNM,OAAO;gCACPE,OAAO;oCACNc,YAAY;oCACZf,aAAa;gCACd;gCACAJ,QAAQ;oCACP;wCACCC,MAAM;wCACND,QAAQ;4CACP;gDACCH,MAAM;gDACNI,MAAM;gDACNE,OAAO;gDACPE,OAAO;oDACNC,OAAO;gDACR;4CACD;4CACA;gDACCT,MAAM;gDACNI,MAAM;gDACNE,OAAO;gDACPE,OAAO;oDACNC,OAAO;gDACR;4CACD;4CACA;gDACCT,MAAM;gDACNI,MAAM;gDACNE,OAAO;gDACPE,OAAO;oDACNC,OAAO;gDACR;4CACD;4CACA;gDACCT,MAAM;gDACNI,MAAM;gDACNE,OAAO;gDACPE,OAAO;oDACNC,OAAO;gDACR;4CACD;4CACA;gDACCT,MAAM;gDACNI,MAAM;gDACNE,OAAO;gDACPiB,UAAUjC;gDACVkB,OAAO;oDACNC,OAAO;gDACR;4CACD;4CACA;gDACCT,MAAM;gDACNI,MAAM;gDACNE,OAAO;gDACPK,SAASnB,UAAUoB,GAAG,CAAC,CAACY;oDACvB,OAAO;wDACNlB,OAAOkB;wDACPV,OAAOU;oDACR;gDACD;gDACAhB,OAAO;oDACNC,OAAO;gDACR;4CACD;yCACA;oCACF;iCACA;4BACF;4BACA;gCACCL,MAAM;gCACNJ,MAAM;gCACNM,OAAO;gCACPE,OAAO;oCACNc,YAAY;oCACZf,aAAa;gCACd;gCACAJ,QAAQ;oCACP;wCACCC,MAAM;wCACND,QAAQ;4CACP;gDACCH,MAAM;gDACNI,MAAM;gDACNE,OAAO;gDACPiB,UAAUhC;gDACViB,OAAO;oDACNC,OAAO;gDACR;4CACD;4CACA;gDACCT,MAAM;gDACNI,MAAM;gDACNE,OAAO;gDACPiB,UAAUhC;gDACViB,OAAO;oDACNC,OAAO;gDACR;4CACD;4CACA;gDACCT,MAAM;gDACNI,MAAM;gDACNE,OAAO;gDACPiB,UAAUhC;gDACViB,OAAO;oDACNC,OAAO;gDACR;4CACD;4CACA;gDACCT,MAAM;gDACNI,MAAM;gDACNE,OAAO;gDACPiB,UAAUhC;gDACViB,OAAO;oDACNC,OAAO;gDACR;4CACD;4CACA;gDACCT,MAAM;gDACNI,MAAM;gDACNE,OAAO;gDACPiB,UAAUhC;gDACViB,OAAO;oDACNC,OAAO;gDACR;4CACD;4CACA;gDACCT,MAAM;gDACNI,MAAM;gDACNE,OAAO;gDACPiB,UAAUhC;gDACViB,OAAO;oDACNC,OAAO;gDACR;4CACD;yCACA;oCACF;iCACA;4BACF;yBACA;oBACF;oBACA;wBACCH,OAAO;wBACPH,QAAQ;4BACP;gCACCH,MAAM;gCACNI,MAAM;gCACND,QAAQ;oCACP;wCACCH,MAAM;wCACNI,MAAM;wCACNE,OAAO;wCACPE,OAAO;4CACND,aACC;wCACF;oCACD;oCACA;wCACCP,MAAM;wCACNI,MAAM;wCACNE,OAAO;wCACPE,OAAO;4CACND,aAAa;wCACd;oCACD;oCACA;wCACCP,MAAM;wCACNI,MAAM;wCACNE,OAAO;wCACPE,OAAO;4CACND,aACC;wCACF;oCACD;iCACA;4BACF;yBACA;oBACF;uBACIZ,iBAAiBA,iBAAiB,EAAE;iBACxC;YACF;SACA;IACF;AACD,EAAE"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { cacheHookCollections, cacheHookGlobals } from './plugin/hooks.js';
|
|
2
|
-
import { fieldMapper, schemas } from './plugin/schema.js';
|
|
3
|
-
import env from './util/env.js';
|
|
4
2
|
// export const test = (pluginOptions: PayloadHelperPluginConfig): Plugin[] => {
|
|
5
3
|
// return [
|
|
6
4
|
// seoPlugin({
|
|
@@ -24,52 +22,51 @@ import env from './util/env.js';
|
|
|
24
22
|
* @constructor
|
|
25
23
|
* @param pluginOptions
|
|
26
24
|
*/ export const payloadHelper = (pluginOptions)=>(incomingConfig)=>{
|
|
27
|
-
const genGoLang = env.bool('GEN_GOLANG', false);
|
|
28
|
-
if (genGoLang) {
|
|
29
|
-
incomingConfig.typescript = {
|
|
30
|
-
...incomingConfig.typescript,
|
|
31
|
-
schema: schemas
|
|
32
|
-
};
|
|
33
|
-
// biome-ignore lint/style/noParameterAssign: Need to change field mapper.
|
|
34
|
-
incomingConfig = fieldMapper(incomingConfig);
|
|
35
|
-
}
|
|
36
25
|
// TODO: Validate Config
|
|
37
26
|
// Update typescript generation file
|
|
38
27
|
incomingConfig.typescript = incomingConfig.typescript || {};
|
|
39
28
|
incomingConfig.typescript.outputFile = './src/types/payload.ts';
|
|
40
29
|
// Map collections & add hooks
|
|
41
30
|
incomingConfig.collections = (incomingConfig.collections || []).map((collection)=>{
|
|
42
|
-
if (collection.upload) {
|
|
31
|
+
if (collection.upload !== undefined && collection.upload !== true) {
|
|
43
32
|
return collection;
|
|
44
33
|
}
|
|
34
|
+
const hooks = collection.hooks || {};
|
|
35
|
+
// Add afterChange hook only if webServer is defined
|
|
36
|
+
if (pluginOptions.webServer) {
|
|
37
|
+
hooks.afterChange = [
|
|
38
|
+
...hooks.afterChange || [],
|
|
39
|
+
cacheHookCollections({
|
|
40
|
+
server: pluginOptions.webServer,
|
|
41
|
+
slug: collection.slug,
|
|
42
|
+
fields: collection.fields,
|
|
43
|
+
isCollection: true
|
|
44
|
+
})
|
|
45
|
+
];
|
|
46
|
+
}
|
|
45
47
|
return {
|
|
46
48
|
...collection,
|
|
47
|
-
hooks
|
|
48
|
-
afterChange: [
|
|
49
|
-
cacheHookCollections({
|
|
50
|
-
server: pluginOptions.webServer,
|
|
51
|
-
slug: collection.slug,
|
|
52
|
-
fields: collection.fields,
|
|
53
|
-
isCollection: true
|
|
54
|
-
})
|
|
55
|
-
]
|
|
56
|
-
}
|
|
49
|
+
hooks
|
|
57
50
|
};
|
|
58
51
|
});
|
|
59
52
|
// Map globals & add hooks
|
|
60
53
|
incomingConfig.globals = (incomingConfig.globals || []).map((global)=>{
|
|
54
|
+
const hooks = global.hooks || {};
|
|
55
|
+
// Add afterChange hook only if webServer is defined
|
|
56
|
+
if (pluginOptions.webServer) {
|
|
57
|
+
hooks.afterChange = [
|
|
58
|
+
...hooks.afterChange || [],
|
|
59
|
+
cacheHookGlobals({
|
|
60
|
+
server: pluginOptions.webServer,
|
|
61
|
+
slug: global.slug,
|
|
62
|
+
fields: global.fields,
|
|
63
|
+
isCollection: true
|
|
64
|
+
})
|
|
65
|
+
];
|
|
66
|
+
}
|
|
61
67
|
return {
|
|
62
68
|
...global,
|
|
63
|
-
hooks
|
|
64
|
-
afterChange: [
|
|
65
|
-
cacheHookGlobals({
|
|
66
|
-
server: pluginOptions.webServer,
|
|
67
|
-
slug: global.slug,
|
|
68
|
-
fields: global.fields,
|
|
69
|
-
isCollection: true
|
|
70
|
-
})
|
|
71
|
-
]
|
|
72
|
-
}
|
|
69
|
+
hooks
|
|
73
70
|
};
|
|
74
71
|
});
|
|
75
72
|
return incomingConfig;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { CollectionConfig, Config } from 'payload';\nimport { cacheHookCollections, cacheHookGlobals } from './plugin/hooks.js';\nimport { fieldMapper, schemas } from './plugin/schema.js';\nimport type { PayloadHelperPluginConfig } from './types.js';\nimport env from './util/env.js';\n\n// export const test = (pluginOptions: PayloadHelperPluginConfig): Plugin[] => {\n// \treturn [\n// \t\tseoPlugin({\n// \t\t\tcollections: pluginOptions?.seo?.collections,\n// \t\t\tglobals: pluginOptions?.seo?.globals,\n// \t\t\tfields: [...SEOFields, pluginOptions.seo?.fields],\n// \t\t\ttabbedUI: true,\n// \t\t\tuploadsCollection: 'media',\n// \t\t\tgenerateTitle: pluginOptions?.seo?.generateTitle ?\n// \t\t\t\tpluginOptions?.seo?.generateTitle :\n// \t\t\t\t({ doc }) => `${pluginOptions.siteName} — ${doc?.title?.value ?? ''}`,\n// \t\t\tgenerateDescription: pluginOptions?.seo?.generateDescription ?\n// \t\t\t\tpluginOptions?.seo?.generateDescription :\n// \t\t\t\t({ doc }) => doc?.excerpt?.value,\n// \t\t}),\n// \t];\n// };\n\n/**\n * Payload Helper Plugin for websites at ainsley.dev\n *\n * @constructor\n * @param pluginOptions\n */\nexport const payloadHelper =\n\t(pluginOptions: PayloadHelperPluginConfig) =>\n\t(incomingConfig: Config): Config => {\n\t\
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { CollectionConfig, Config } from 'payload';\nimport { cacheHookCollections, cacheHookGlobals } from './plugin/hooks.js';\nimport { fieldMapper, schemas } from './plugin/schema.js';\nimport type { PayloadHelperPluginConfig } from './types.js';\nimport env from './util/env.js';\n\n// export const test = (pluginOptions: PayloadHelperPluginConfig): Plugin[] => {\n// \treturn [\n// \t\tseoPlugin({\n// \t\t\tcollections: pluginOptions?.seo?.collections,\n// \t\t\tglobals: pluginOptions?.seo?.globals,\n// \t\t\tfields: [...SEOFields, pluginOptions.seo?.fields],\n// \t\t\ttabbedUI: true,\n// \t\t\tuploadsCollection: 'media',\n// \t\t\tgenerateTitle: pluginOptions?.seo?.generateTitle ?\n// \t\t\t\tpluginOptions?.seo?.generateTitle :\n// \t\t\t\t({ doc }) => `${pluginOptions.siteName} — ${doc?.title?.value ?? ''}`,\n// \t\t\tgenerateDescription: pluginOptions?.seo?.generateDescription ?\n// \t\t\t\tpluginOptions?.seo?.generateDescription :\n// \t\t\t\t({ doc }) => doc?.excerpt?.value,\n// \t\t}),\n// \t];\n// };\n\n/**\n * Payload Helper Plugin for websites at ainsley.dev\n *\n * @constructor\n * @param pluginOptions\n */\nexport const payloadHelper =\n\t(pluginOptions: PayloadHelperPluginConfig) =>\n\t(incomingConfig: Config): Config => {\n\t\t// TODO: Validate Config\n\n\t\t// Update typescript generation file\n\t\tincomingConfig.typescript = incomingConfig.typescript || {};\n\t\tincomingConfig.typescript.outputFile = './src/types/payload.ts';\n\n\t\t// Map collections & add hooks\n\t\tincomingConfig.collections = (incomingConfig.collections || []).map(\n\t\t\t(collection): CollectionConfig => {\n\t\t\t\tif (collection.upload !== undefined && collection.upload !== true) {\n\t\t\t\t\treturn collection;\n\t\t\t\t}\n\n\t\t\t\tconst hooks = collection.hooks || {};\n\n\t\t\t\t// Add afterChange hook only if webServer is defined\n\t\t\t\tif (pluginOptions.webServer) {\n\t\t\t\t\thooks.afterChange = [\n\t\t\t\t\t\t...(hooks.afterChange || []),\n\t\t\t\t\t\tcacheHookCollections({\n\t\t\t\t\t\t\tserver: pluginOptions.webServer,\n\t\t\t\t\t\t\tslug: collection.slug,\n\t\t\t\t\t\t\tfields: collection.fields,\n\t\t\t\t\t\t\tisCollection: true,\n\t\t\t\t\t\t}),\n\t\t\t\t\t];\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\t...collection,\n\t\t\t\t\thooks,\n\t\t\t\t};\n\t\t\t},\n\t\t);\n\n\t\t// Map globals & add hooks\n\t\tincomingConfig.globals = (incomingConfig.globals || []).map((global) => {\n\t\t\tconst hooks = global.hooks || {};\n\n\t\t\t// Add afterChange hook only if webServer is defined\n\t\t\tif (pluginOptions.webServer) {\n\t\t\t\thooks.afterChange = [\n\t\t\t\t\t...(hooks.afterChange || []),\n\t\t\t\t\tcacheHookGlobals({\n\t\t\t\t\t\tserver: pluginOptions.webServer,\n\t\t\t\t\t\tslug: global.slug,\n\t\t\t\t\t\tfields: global.fields,\n\t\t\t\t\t\tisCollection: true,\n\t\t\t\t\t}),\n\t\t\t\t];\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\t...global,\n\t\t\t\thooks,\n\t\t\t};\n\t\t});\n\n\t\treturn incomingConfig;\n\t};\n"],"names":["cacheHookCollections","cacheHookGlobals","payloadHelper","pluginOptions","incomingConfig","typescript","outputFile","collections","map","collection","upload","undefined","hooks","webServer","afterChange","server","slug","fields","isCollection","globals","global"],"mappings":"AACA,SAASA,oBAAoB,EAAEC,gBAAgB,QAAQ,oBAAoB;AAK3E,gFAAgF;AAChF,YAAY;AACZ,gBAAgB;AAChB,mDAAmD;AACnD,2CAA2C;AAC3C,wDAAwD;AACxD,qBAAqB;AACrB,iCAAiC;AACjC,wDAAwD;AACxD,0CAA0C;AAC1C,6EAA6E;AAC7E,oEAAoE;AACpE,gDAAgD;AAChD,wCAAwC;AACxC,QAAQ;AACR,MAAM;AACN,KAAK;AAEL;;;;;CAKC,GACD,OAAO,MAAMC,gBACZ,CAACC,gBACD,CAACC;QACA,wBAAwB;QAExB,oCAAoC;QACpCA,eAAeC,UAAU,GAAGD,eAAeC,UAAU,IAAI,CAAC;QAC1DD,eAAeC,UAAU,CAACC,UAAU,GAAG;QAEvC,8BAA8B;QAC9BF,eAAeG,WAAW,GAAG,AAACH,CAAAA,eAAeG,WAAW,IAAI,EAAE,AAAD,EAAGC,GAAG,CAClE,CAACC;YACA,IAAIA,WAAWC,MAAM,KAAKC,aAAaF,WAAWC,MAAM,KAAK,MAAM;gBAClE,OAAOD;YACR;YAEA,MAAMG,QAAQH,WAAWG,KAAK,IAAI,CAAC;YAEnC,oDAAoD;YACpD,IAAIT,cAAcU,SAAS,EAAE;gBAC5BD,MAAME,WAAW,GAAG;uBACfF,MAAME,WAAW,IAAI,EAAE;oBAC3Bd,qBAAqB;wBACpBe,QAAQZ,cAAcU,SAAS;wBAC/BG,MAAMP,WAAWO,IAAI;wBACrBC,QAAQR,WAAWQ,MAAM;wBACzBC,cAAc;oBACf;iBACA;YACF;YAEA,OAAO;gBACN,GAAGT,UAAU;gBACbG;YACD;QACD;QAGD,0BAA0B;QAC1BR,eAAee,OAAO,GAAG,AAACf,CAAAA,eAAee,OAAO,IAAI,EAAE,AAAD,EAAGX,GAAG,CAAC,CAACY;YAC5D,MAAMR,QAAQQ,OAAOR,KAAK,IAAI,CAAC;YAE/B,oDAAoD;YACpD,IAAIT,cAAcU,SAAS,EAAE;gBAC5BD,MAAME,WAAW,GAAG;uBACfF,MAAME,WAAW,IAAI,EAAE;oBAC3Bb,iBAAiB;wBAChBc,QAAQZ,cAAcU,SAAS;wBAC/BG,MAAMI,OAAOJ,IAAI;wBACjBC,QAAQG,OAAOH,MAAM;wBACrBC,cAAc;oBACf;iBACA;YACF;YAEA,OAAO;gBACN,GAAGE,MAAM;gBACTR;YACD;QACD;QAEA,OAAOR;IACR,EAAE"}
|
package/dist/plugin/schema.d.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import type { JSONSchema4 } from 'json-schema';
|
|
2
|
-
import type {
|
|
2
|
+
import type { SanitizedConfig } from 'payload';
|
|
3
|
+
/**
|
|
4
|
+
* General Options for Generating Schema
|
|
5
|
+
*/
|
|
6
|
+
export interface SchemaOptions {
|
|
7
|
+
useWebKitMedia?: boolean;
|
|
8
|
+
assignRelationships?: boolean;
|
|
9
|
+
}
|
|
3
10
|
/**
|
|
4
11
|
* Adds the necessary GoLang type conversions as a helper func.
|
|
5
12
|
*/
|
|
@@ -11,11 +18,11 @@ export declare const addGoJSONSchema: (type: string, nillable: boolean) => Recor
|
|
|
11
18
|
*
|
|
12
19
|
* @param config
|
|
13
20
|
*/
|
|
14
|
-
export declare const fieldMapper: (config:
|
|
21
|
+
export declare const fieldMapper: (config: SanitizedConfig, opts: SchemaOptions) => SanitizedConfig;
|
|
15
22
|
/**
|
|
16
23
|
* Adjusts the JSON schema to include the necessary GoLang schema
|
|
17
24
|
*
|
|
18
25
|
*/
|
|
19
|
-
export declare const schemas: Array<(args: {
|
|
26
|
+
export declare const schemas: (opts: SchemaOptions) => Array<(args: {
|
|
20
27
|
jsonSchema: JSONSchema4;
|
|
21
28
|
}) => JSONSchema4>;
|
package/dist/plugin/schema.js
CHANGED
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
* to include the necessary GoLang schema.
|
|
37
37
|
*
|
|
38
38
|
* @param config
|
|
39
|
-
*/ export const fieldMapper = (config)=>{
|
|
39
|
+
*/ export const fieldMapper = (config, opts)=>{
|
|
40
40
|
const mapper = (field)=>{
|
|
41
41
|
switch(field.type){
|
|
42
42
|
case 'blocks':
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
case 'json':
|
|
53
53
|
field.typescriptSchema = [
|
|
54
54
|
()=>({
|
|
55
|
-
...addGoJSONSchema('
|
|
55
|
+
...addGoJSONSchema('payload.JSON', false)
|
|
56
56
|
})
|
|
57
57
|
];
|
|
58
58
|
break;
|
|
@@ -65,11 +65,13 @@
|
|
|
65
65
|
];
|
|
66
66
|
break;
|
|
67
67
|
case 'upload':
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
68
|
+
if (opts.useWebKitMedia) {
|
|
69
|
+
field.typescriptSchema = [
|
|
70
|
+
()=>({
|
|
71
|
+
...addGoJSONSchema('payload.Media', field.required === true)
|
|
72
|
+
})
|
|
73
|
+
];
|
|
74
|
+
}
|
|
73
75
|
break;
|
|
74
76
|
case 'tabs':
|
|
75
77
|
{
|
|
@@ -105,7 +107,7 @@
|
|
|
105
107
|
break;
|
|
106
108
|
}
|
|
107
109
|
}
|
|
108
|
-
if (field.type !== 'ui') {
|
|
110
|
+
if (field.type !== 'ui' && opts.assignRelationships) {
|
|
109
111
|
if (!Array.isArray(field.typescriptSchema)) {
|
|
110
112
|
field.typescriptSchema = [];
|
|
111
113
|
}
|
|
@@ -144,111 +146,115 @@
|
|
|
144
146
|
/**
|
|
145
147
|
* Adjusts the JSON schema to include the necessary GoLang schema
|
|
146
148
|
*
|
|
147
|
-
*/ export const schemas = [
|
|
148
|
-
|
|
149
|
+
*/ export const schemas = (opts)=>[
|
|
150
|
+
/**
|
|
149
151
|
* Removes the auth & uneeded definitions from the schema.
|
|
150
152
|
*/ ({ jsonSchema })=>{
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
153
|
+
if (!jsonSchema.properties) {
|
|
154
|
+
jsonSchema.properties = {};
|
|
155
|
+
}
|
|
156
|
+
if (!jsonSchema.definitions) {
|
|
157
|
+
jsonSchema.definitions = {};
|
|
158
|
+
}
|
|
159
|
+
if (opts.useWebKitMedia) {
|
|
160
|
+
delete jsonSchema.definitions.media;
|
|
161
|
+
delete jsonSchema.properties?.collections?.properties?.media;
|
|
162
|
+
}
|
|
163
|
+
delete jsonSchema.properties.auth;
|
|
164
|
+
delete jsonSchema.definitions['payload-locked-documents'];
|
|
165
|
+
delete jsonSchema.properties?.collections?.properties?.['payload-locked-documents'];
|
|
166
|
+
delete jsonSchema.definitions.redirects;
|
|
167
|
+
delete jsonSchema.properties?.collections?.properties?.redirects;
|
|
168
|
+
return jsonSchema;
|
|
169
|
+
},
|
|
170
|
+
/**
|
|
165
171
|
* Adds the settings and media definitions to the schema
|
|
166
172
|
*/ ({ jsonSchema })=>{
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
173
|
+
if (!jsonSchema.definitions) {
|
|
174
|
+
jsonSchema.definitions = {};
|
|
175
|
+
}
|
|
176
|
+
if ('settings' in jsonSchema.definitions) {
|
|
177
|
+
jsonSchema.definitions.settings = {
|
|
178
|
+
type: 'object',
|
|
179
|
+
fields: [],
|
|
180
|
+
...addGoJSONSchema('payload.Settings', false)
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
if ('forms' in jsonSchema.definitions) {
|
|
184
|
+
jsonSchema.definitions.forms = {
|
|
185
|
+
type: 'object',
|
|
186
|
+
...addGoJSONSchema('payload.Form', false),
|
|
187
|
+
fields: []
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
if ('form-submissions' in jsonSchema.definitions) {
|
|
191
|
+
jsonSchema.definitions['form-submissions'] = {
|
|
192
|
+
type: 'object',
|
|
193
|
+
...addGoJSONSchema('payload.FormSubmission', false),
|
|
194
|
+
fields: []
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
return jsonSchema;
|
|
198
|
+
},
|
|
199
|
+
/**
|
|
194
200
|
* Updates the JSON schema so that it doesn't feature oneOf, so Go doesn't
|
|
195
201
|
* output it as an interface{}.
|
|
196
202
|
*/ ({ jsonSchema })=>{
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
if (payload.type === 'relationship') {
|
|
203
|
-
if (payload.hasMany) {
|
|
204
|
-
property.type = 'array';
|
|
205
|
-
property.items = {
|
|
206
|
-
$ref: `#/definitions/${payload.relationTo}`
|
|
207
|
-
};
|
|
203
|
+
const updateRelationship = (property)=>{
|
|
204
|
+
const payload = property.payload;
|
|
205
|
+
if (!payload) {
|
|
208
206
|
return;
|
|
209
207
|
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
updateRelationship(property.properties[k]);
|
|
208
|
+
if (payload.type === 'relationship') {
|
|
209
|
+
if (payload.hasMany) {
|
|
210
|
+
property.type = 'array';
|
|
211
|
+
property.items = {
|
|
212
|
+
$ref: `#/definitions/${payload.relationTo}`
|
|
213
|
+
};
|
|
214
|
+
return;
|
|
218
215
|
}
|
|
216
|
+
delete property.oneOf;
|
|
217
|
+
property.$ref = `#/definitions/${property.payload.relationTo}`;
|
|
219
218
|
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
219
|
+
const pType = payload.type;
|
|
220
|
+
if (pType === 'group' || pType === 'row' || pType === 'collapsible' || pType === 'array') {
|
|
221
|
+
if (property.properties) {
|
|
222
|
+
for(const k in property.properties){
|
|
223
|
+
updateRelationship(property.properties[k]);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
loopJSONSchemaProperties(jsonSchema, ({ property })=>{
|
|
230
|
+
updateRelationship(property);
|
|
231
|
+
});
|
|
232
|
+
return jsonSchema;
|
|
233
|
+
},
|
|
234
|
+
/**
|
|
229
235
|
* Changes blockType to a string so it's not an *interface{} when
|
|
230
236
|
* comparing block types in Go.
|
|
231
237
|
*/ ({ jsonSchema })=>{
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
238
|
+
loopJSONSchemaProperties(jsonSchema, ({ property, key })=>{
|
|
239
|
+
if (key === 'blockType') {
|
|
240
|
+
property.type = 'string';
|
|
241
|
+
delete property.const;
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
return jsonSchema;
|
|
245
|
+
},
|
|
246
|
+
/**
|
|
241
247
|
* Changes blockType to a string so it's not an *interface{} when
|
|
242
248
|
* comparing block types in Go.
|
|
243
249
|
*/ ({ jsonSchema })=>{
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
];
|
|
250
|
+
loopJSONSchemaProperties(jsonSchema, ({ property, key })=>{
|
|
251
|
+
const payload = property.payload;
|
|
252
|
+
if (payload && payload.type === 'relationship' && payload.name === 'form') {
|
|
253
|
+
delete property.$ref;
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
return jsonSchema;
|
|
257
|
+
}
|
|
258
|
+
];
|
|
253
259
|
|
|
254
260
|
//# sourceMappingURL=schema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/plugin/schema.ts"],"sourcesContent":["import type { JSONSchema4 } from 'json-schema';\nimport type { Config, Field } from 'payload';\n\n/**\n * This function iterates over properties in JSON schema definitions,\n * passing each property and its key to a callback function.\n */\nconst loopJSONSchemaProperties = (\n\tjsonSchema: JSONSchema4,\n\tcallback: (args: { key: string; property: JSONSchema4 }) => void,\n): JSONSchema4 => {\n\tif (!jsonSchema.definitions) {\n\t\treturn jsonSchema;\n\t}\n\tObject.entries(jsonSchema.definitions).forEach(([definitionKey, definition]) => {\n\t\tif (definition.properties) {\n\t\t\tObject.entries(definition.properties).forEach(([propertyKey, property]) => {\n\t\t\t\tcallback({ key: propertyKey, property });\n\t\t\t});\n\t\t}\n\t});\n\treturn jsonSchema;\n};\n\n/**\n * Adds the necessary GoLang type conversions as a helper func.\n */\nexport const addGoJSONSchema = (type: string, nillable: boolean): Record<string, unknown> => {\n\treturn {\n\t\tgoJSONSchema: {\n\t\t\timports: ['github.com/ainsleydev/webkit/pkg/adapters/payload'],\n\t\t\tnillable: nillable,\n\t\t\ttype: type,\n\t\t},\n\t};\n};\n\n/**\n * Iterates over all the fields within the config, for both collections\n * and globals, and transforms the JSON schema\n * to include the necessary GoLang schema.\n *\n * @param config\n */\nexport const fieldMapper = (config: Config) => {\n\tconst mapper = (field: Field): Field => {\n\t\tswitch (field.type) {\n\t\t\tcase 'blocks':\n\t\t\t\tfield.typescriptSchema = [() => ({ ...addGoJSONSchema('payload.Blocks', false) })];\n\t\t\t\tfield.blocks.forEach((block) => {\n\t\t\t\t\tblock.fields = block.fields.map((f) => mapper(f));\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\tcase 'json':\n\t\t\t\tfield.typescriptSchema = [() => ({ ...addGoJSONSchema('[]byte', false) })];\n\t\t\t\tbreak;\n\t\t\tcase 'richText':\n\t\t\t\tfield.typescriptSchema = [\n\t\t\t\t\t() => ({\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\t...addGoJSONSchema('payload.RichText', false),\n\t\t\t\t\t}),\n\t\t\t\t];\n\t\t\t\tbreak;\n\t\t\tcase 'upload':\n\t\t\t\tfield.typescriptSchema = [\n\t\t\t\t\t() => ({ ...addGoJSONSchema('payload.Media', field.required === true) }),\n\t\t\t\t];\n\t\t\t\tbreak;\n\t\t\tcase 'tabs': {\n\t\t\t\tfield.tabs.forEach((tab) => {\n\t\t\t\t\ttab.fields = tab.fields.map((f) => mapper(f));\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'relationship': {\n\t\t\t\tif (field.relationTo === 'forms') {\n\t\t\t\t\tfield.typescriptSchema = [\n\t\t\t\t\t\t() => ({ ...addGoJSONSchema('payload.Form', field.required === true) }),\n\t\t\t\t\t];\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'group':\n\t\t\tcase 'array':\n\t\t\tcase 'row':\n\t\t\tcase 'collapsible': {\n\t\t\t\tif (field.type === 'group' && field.name === 'meta') {\n\t\t\t\t\tfield.typescriptSchema = [\n\t\t\t\t\t\t() => ({ ...addGoJSONSchema('payload.SettingsMeta', true) }),\n\t\t\t\t\t];\n\t\t\t\t}\n\t\t\t\tfield.fields = field.fields.map((f) => mapper(f));\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// SEE: https://github.com/ainsleydev/webkit/blob/cdfa078605bec4ee92f2424f69271a0bf6b71366/packages/payload-helper/src/gen/schema.ts#L235\n\t\t}\n\n\t\tif (field.type !== 'ui') {\n\t\t\tif (!Array.isArray(field.typescriptSchema)) {\n\t\t\t\tfield.typescriptSchema = [];\n\t\t\t}\n\n\t\t\tif (field.type !== 'tabs' && field.type !== 'row' && field.type !== 'collapsible') {\n\t\t\t\tfield.typescriptSchema.push(({ jsonSchema }) => {\n\t\t\t\t\tconst payload = {\n\t\t\t\t\t\tname: field.name,\n\t\t\t\t\t\ttype: field.type,\n\t\t\t\t\t\tlabel: field.label,\n\t\t\t\t\t} as Record<string, unknown>;\n\n\t\t\t\t\tif (field.type === 'relationship') {\n\t\t\t\t\t\tpayload.hasMany = field.hasMany;\n\t\t\t\t\t\tpayload.relationTo = field.relationTo;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...jsonSchema,\n\t\t\t\t\t\tpayload,\n\t\t\t\t\t};\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn field;\n\t};\n\n\tif (config.collections) {\n\t\tconfig.collections.forEach((collection) => {\n\t\t\tcollection.fields = collection.fields.map((field) => mapper(field));\n\t\t});\n\t}\n\n\tif (config.globals) {\n\t\tconfig.globals.forEach((global, index) => {\n\t\t\tglobal.fields = global.fields.map((field) => mapper(field));\n\t\t});\n\t}\n\n\treturn config;\n};\n\n/**\n * Adjusts the JSON schema to include the necessary GoLang schema\n *\n */\nexport const schemas: Array<(args: { jsonSchema: JSONSchema4 }) => JSONSchema4> = [\n\t/**\n\t * Removes the auth & uneeded definitions from the schema.\n\t */\n\t({ jsonSchema }): JSONSchema4 => {\n\t\tif (!jsonSchema.properties) {\n\t\t\tjsonSchema.properties = {};\n\t\t}\n\t\tif (!jsonSchema.definitions) {\n\t\t\tjsonSchema.definitions = {};\n\t\t}\n\t\tdelete jsonSchema.properties.auth;\n\t\tdelete jsonSchema.definitions.media;\n\t\tdelete jsonSchema.properties?.collections?.properties?.media;\n\t\tdelete jsonSchema.definitions.redirects;\n\t\tdelete jsonSchema.properties?.collections?.properties?.redirects;\n\t\treturn jsonSchema;\n\t},\n\t/**\n\t * Adds the settings and media definitions to the schema\n\t */\n\t({ jsonSchema }): JSONSchema4 => {\n\t\tif (!jsonSchema.definitions) {\n\t\t\tjsonSchema.definitions = {};\n\t\t}\n\n\t\tif ('settings' in jsonSchema.definitions) {\n\t\t\tjsonSchema.definitions.settings = {\n\t\t\t\ttype: 'object',\n\t\t\t\tfields: [],\n\t\t\t\t...addGoJSONSchema('payload.Settings', false),\n\t\t\t};\n\t\t}\n\n\t\tif ('forms' in jsonSchema.definitions) {\n\t\t\tjsonSchema.definitions.forms = {\n\t\t\t\ttype: 'object',\n\t\t\t\t...addGoJSONSchema('payload.Form', false),\n\t\t\t\tfields: [],\n\t\t\t};\n\t\t}\n\n\t\tif ('form-submissions' in jsonSchema.definitions) {\n\t\t\tjsonSchema.definitions['form-submissions'] = {\n\t\t\t\ttype: 'object',\n\t\t\t\t...addGoJSONSchema('payload.FormSubmission', false),\n\t\t\t\tfields: [],\n\t\t\t};\n\t\t}\n\n\t\treturn jsonSchema;\n\t},\n\t/**\n\t * Updates the JSON schema so that it doesn't feature oneOf, so Go doesn't\n\t * output it as an interface{}.\n\t */\n\t({ jsonSchema }): JSONSchema4 => {\n\t\tconst updateRelationship = (property: JSONSchema4) => {\n\t\t\tconst payload = property.payload;\n\t\t\tif (!payload) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (payload.type === 'relationship') {\n\t\t\t\tif (payload.hasMany) {\n\t\t\t\t\tproperty.type = 'array';\n\t\t\t\t\tproperty.items = {\n\t\t\t\t\t\t$ref: `#/definitions/${payload.relationTo}`,\n\t\t\t\t\t};\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tdelete property.oneOf;\n\t\t\t\tproperty.$ref = `#/definitions/${property.payload.relationTo}`;\n\t\t\t}\n\n\t\t\tconst pType = payload.type;\n\t\t\tif (\n\t\t\t\tpType === 'group' ||\n\t\t\t\tpType === 'row' ||\n\t\t\t\tpType === 'collapsible' ||\n\t\t\t\tpType === 'array'\n\t\t\t) {\n\t\t\t\tif (property.properties) {\n\t\t\t\t\tfor (const k in property.properties) {\n\t\t\t\t\t\tupdateRelationship(property.properties[k]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t};\n\n\t\tloopJSONSchemaProperties(jsonSchema, ({ property }) => {\n\t\t\tupdateRelationship(property);\n\t\t});\n\t\treturn jsonSchema;\n\t},\n\t/**\n\t * Changes blockType to a string so it's not an *interface{} when\n\t * comparing block types in Go.\n\t */\n\t({ jsonSchema }): JSONSchema4 => {\n\t\tloopJSONSchemaProperties(jsonSchema, ({ property, key }) => {\n\t\t\tif (key === 'blockType') {\n\t\t\t\tproperty.type = 'string';\n\t\t\t\tdelete property.const;\n\t\t\t}\n\t\t});\n\t\treturn jsonSchema;\n\t},\n\t/**\n\t * Changes blockType to a string so it's not an *interface{} when\n\t * comparing block types in Go.\n\t */\n\t({ jsonSchema }): JSONSchema4 => {\n\t\tloopJSONSchemaProperties(jsonSchema, ({ property, key }) => {\n\t\t\tconst payload = property.payload;\n\t\t\tif (payload && payload.type === 'relationship' && payload.name === 'form') {\n\t\t\t\tdelete property.$ref;\n\t\t\t}\n\t\t});\n\t\treturn jsonSchema;\n\t},\n];\n"],"names":["loopJSONSchemaProperties","jsonSchema","callback","definitions","Object","entries","forEach","definitionKey","definition","properties","propertyKey","property","key","addGoJSONSchema","type","nillable","goJSONSchema","imports","fieldMapper","config","mapper","field","typescriptSchema","blocks","block","fields","map","f","required","tabs","tab","relationTo","name","Array","isArray","push","payload","label","hasMany","collections","collection","globals","global","index","schemas","auth","media","redirects","settings","forms","updateRelationship","items","$ref","oneOf","pType","k","const"],"mappings":"AAGA;;;CAGC,GACD,MAAMA,2BAA2B,CAChCC,YACAC;IAEA,IAAI,CAACD,WAAWE,WAAW,EAAE;QAC5B,OAAOF;IACR;IACAG,OAAOC,OAAO,CAACJ,WAAWE,WAAW,EAAEG,OAAO,CAAC,CAAC,CAACC,eAAeC,WAAW;QAC1E,IAAIA,WAAWC,UAAU,EAAE;YAC1BL,OAAOC,OAAO,CAACG,WAAWC,UAAU,EAAEH,OAAO,CAAC,CAAC,CAACI,aAAaC,SAAS;gBACrET,SAAS;oBAAEU,KAAKF;oBAAaC;gBAAS;YACvC;QACD;IACD;IACA,OAAOV;AACR;AAEA;;CAEC,GACD,OAAO,MAAMY,kBAAkB,CAACC,MAAcC;IAC7C,OAAO;QACNC,cAAc;YACbC,SAAS;gBAAC;aAAoD;YAC9DF,UAAUA;YACVD,MAAMA;QACP;IACD;AACD,EAAE;AAEF;;;;;;CAMC,GACD,OAAO,MAAMI,cAAc,CAACC;IAC3B,MAAMC,SAAS,CAACC;QACf,OAAQA,MAAMP,IAAI;YACjB,KAAK;gBACJO,MAAMC,gBAAgB,GAAG;oBAAC,IAAO,CAAA;4BAAE,GAAGT,gBAAgB,kBAAkB,MAAM;wBAAC,CAAA;iBAAG;gBAClFQ,MAAME,MAAM,CAACjB,OAAO,CAAC,CAACkB;oBACrBA,MAAMC,MAAM,GAAGD,MAAMC,MAAM,CAACC,GAAG,CAAC,CAACC,IAAMP,OAAOO;gBAC/C;gBAC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c,EAAEzC,SAASyB,OAAO,CAACL,UAAU,CAAC,CAAC;YAC/D;YAEA,MAAMuB,QAAQlB,QAAQtB,IAAI;YAC1B,IACCwC,UAAU,WACVA,UAAU,SACVA,UAAU,iBACVA,UAAU,SACT;gBACD,IAAI3C,SAASF,UAAU,EAAE;oBACxB,IAAK,MAAM8C,KAAK5C,SAASF,UAAU,CAAE;wBACpCyC,mBAAmBvC,SAASF,UAAU,CAAC8C,EAAE;oBAC1C;gBACD;gBACA;YACD;QACD;QAEAvD,yBAAyBC,YAAY,CAAC,EAAEU,QAAQ,EAAE;YACjDuC,mBAAmBvC;QACpB;QACA,OAAOV;IACR;IACA;;;EAGC,GACD,CAAC,EAAEA,UAAU,EAAE;QACdD,yBAAyBC,YAAY,CAAC,EAAEU,QAAQ,EAAEC,GAAG,EAAE;YACtD,IAAIA,QAAQ,aAAa;gBACxBD,SAASG,IAAI,GAAG;gBAChB,OAAOH,SAAS6C,KAAK;YACtB;QACD;QACA,OAAOvD;IACR;IACA;;;EAGC,GACD,CAAC,EAAEA,UAAU,EAAE;QACdD,yBAAyBC,YAAY,CAAC,EAAEU,QAAQ,EAAEC,GAAG,EAAE;YACtD,MAAMwB,UAAUzB,SAASyB,OAAO;YAChC,IAAIA,WAAWA,QAAQtB,IAAI,KAAK,kBAAkBsB,QAAQJ,IAAI,KAAK,QAAQ;gBAC1E,OAAOrB,SAASyC,IAAI;YACrB;QACD;QACA,OAAOnD;IACR;CACA,CAAC"}
|
|
1
|
+
{"version":3,"sources":["../../src/plugin/schema.ts"],"sourcesContent":["import type { JSONSchema4 } from 'json-schema';\nimport type { Config, Field, SanitizedConfig } from 'payload';\n\n/**\n * General Options for Generating Schema\n */\nexport interface SchemaOptions {\n\tuseWebKitMedia?: boolean;\n\tassignRelationships?: boolean;\n}\n\n/**\n * This function iterates over properties in JSON schema definitions,\n * passing each property and its key to a callback function.\n */\nconst loopJSONSchemaProperties = (\n\tjsonSchema: JSONSchema4,\n\tcallback: (args: { key: string; property: JSONSchema4 }) => void,\n): JSONSchema4 => {\n\tif (!jsonSchema.definitions) {\n\t\treturn jsonSchema;\n\t}\n\tObject.entries(jsonSchema.definitions).forEach(([definitionKey, definition]) => {\n\t\tif (definition.properties) {\n\t\t\tObject.entries(definition.properties).forEach(([propertyKey, property]) => {\n\t\t\t\tcallback({ key: propertyKey, property });\n\t\t\t});\n\t\t}\n\t});\n\treturn jsonSchema;\n};\n\n/**\n * Adds the necessary GoLang type conversions as a helper func.\n */\nexport const addGoJSONSchema = (type: string, nillable: boolean): Record<string, unknown> => {\n\treturn {\n\t\tgoJSONSchema: {\n\t\t\timports: ['github.com/ainsleydev/webkit/pkg/adapters/payload'],\n\t\t\tnillable: nillable,\n\t\t\ttype: type,\n\t\t},\n\t};\n};\n\n/**\n * Iterates over all the fields within the config, for both collections\n * and globals, and transforms the JSON schema\n * to include the necessary GoLang schema.\n *\n * @param config\n */\nexport const fieldMapper = (config: SanitizedConfig, opts: SchemaOptions) => {\n\tconst mapper = (field: Field): Field => {\n\t\tswitch (field.type) {\n\t\t\tcase 'blocks':\n\t\t\t\tfield.typescriptSchema = [() => ({ ...addGoJSONSchema('payload.Blocks', false) })];\n\t\t\t\tfield.blocks.forEach((block) => {\n\t\t\t\t\tblock.fields = block.fields.map((f) => mapper(f));\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\tcase 'json':\n\t\t\t\tfield.typescriptSchema = [() => ({ ...addGoJSONSchema('payload.JSON', false) })];\n\t\t\t\tbreak;\n\t\t\tcase 'richText':\n\t\t\t\tfield.typescriptSchema = [\n\t\t\t\t\t() => ({\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\t...addGoJSONSchema('payload.RichText', false),\n\t\t\t\t\t}),\n\t\t\t\t];\n\t\t\t\tbreak;\n\t\t\tcase 'upload':\n\t\t\t\tif (opts.useWebKitMedia) {\n\t\t\t\t\tfield.typescriptSchema = [\n\t\t\t\t\t\t() => ({ ...addGoJSONSchema('payload.Media', field.required === true) }),\n\t\t\t\t\t];\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'tabs': {\n\t\t\t\tfield.tabs.forEach((tab) => {\n\t\t\t\t\ttab.fields = tab.fields.map((f) => mapper(f));\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'relationship': {\n\t\t\t\tif (field.relationTo === 'forms') {\n\t\t\t\t\tfield.typescriptSchema = [\n\t\t\t\t\t\t() => ({ ...addGoJSONSchema('payload.Form', field.required === true) }),\n\t\t\t\t\t];\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'group':\n\t\t\tcase 'array':\n\t\t\tcase 'row':\n\t\t\tcase 'collapsible': {\n\t\t\t\tif (field.type === 'group' && field.name === 'meta') {\n\t\t\t\t\tfield.typescriptSchema = [\n\t\t\t\t\t\t() => ({ ...addGoJSONSchema('payload.SettingsMeta', true) }),\n\t\t\t\t\t];\n\t\t\t\t}\n\t\t\t\tfield.fields = field.fields.map((f) => mapper(f));\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// SEE: https://github.com/ainsleydev/webkit/blob/cdfa078605bec4ee92f2424f69271a0bf6b71366/packages/payload-helper/src/gen/schema.ts#L235\n\t\t}\n\n\t\tif (field.type !== 'ui' && opts.assignRelationships) {\n\t\t\tif (!Array.isArray(field.typescriptSchema)) {\n\t\t\t\tfield.typescriptSchema = [];\n\t\t\t}\n\n\t\t\tif (field.type !== 'tabs' && field.type !== 'row' && field.type !== 'collapsible') {\n\t\t\t\tfield.typescriptSchema.push(({ jsonSchema }) => {\n\t\t\t\t\tconst payload = {\n\t\t\t\t\t\tname: field.name,\n\t\t\t\t\t\ttype: field.type,\n\t\t\t\t\t\tlabel: field.label,\n\t\t\t\t\t} as Record<string, unknown>;\n\n\t\t\t\t\tif (field.type === 'relationship') {\n\t\t\t\t\t\tpayload.hasMany = field.hasMany;\n\t\t\t\t\t\tpayload.relationTo = field.relationTo;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...jsonSchema,\n\t\t\t\t\t\tpayload,\n\t\t\t\t\t};\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn field;\n\t};\n\n\tif (config.collections) {\n\t\tconfig.collections.forEach((collection) => {\n\t\t\tcollection.fields = collection.fields.map((field) => mapper(field));\n\t\t});\n\t}\n\n\tif (config.globals) {\n\t\tconfig.globals.forEach((global, index) => {\n\t\t\tglobal.fields = global.fields.map((field) => mapper(field));\n\t\t});\n\t}\n\n\treturn config;\n};\n\n/**\n * Adjusts the JSON schema to include the necessary GoLang schema\n *\n */\nexport const schemas = (opts: SchemaOptions): Array<(args: { jsonSchema: JSONSchema4 }) => JSONSchema4> => [\n\t/**\n\t * Removes the auth & uneeded definitions from the schema.\n\t */\n\t({ jsonSchema }): JSONSchema4 => {\n\t\tif (!jsonSchema.properties) {\n\t\t\tjsonSchema.properties = {};\n\t\t}\n\t\tif (!jsonSchema.definitions) {\n\t\t\tjsonSchema.definitions = {};\n\t\t}\n\n\t\tif (opts.useWebKitMedia) {\n\t\t\tdelete jsonSchema.definitions.media;\n\t\t\tdelete jsonSchema.properties?.collections?.properties?.media;\n\t\t}\n\n\t\tdelete jsonSchema.properties.auth;\n\t\tdelete jsonSchema.definitions['payload-locked-documents'];\n\t\tdelete jsonSchema.properties?.collections?.properties?.['payload-locked-documents'];\n\t\tdelete jsonSchema.definitions.redirects;\n\t\tdelete jsonSchema.properties?.collections?.properties?.redirects;\n\t\treturn jsonSchema;\n\t},\n\t/**\n\t * Adds the settings and media definitions to the schema\n\t */\n\t({ jsonSchema }): JSONSchema4 => {\n\t\tif (!jsonSchema.definitions) {\n\t\t\tjsonSchema.definitions = {};\n\t\t}\n\n\t\tif ('settings' in jsonSchema.definitions) {\n\t\t\tjsonSchema.definitions.settings = {\n\t\t\t\ttype: 'object',\n\t\t\t\tfields: [],\n\t\t\t\t...addGoJSONSchema('payload.Settings', false),\n\t\t\t};\n\t\t}\n\n\t\tif ('forms' in jsonSchema.definitions) {\n\t\t\tjsonSchema.definitions.forms = {\n\t\t\t\ttype: 'object',\n\t\t\t\t...addGoJSONSchema('payload.Form', false),\n\t\t\t\tfields: [],\n\t\t\t};\n\t\t}\n\n\t\tif ('form-submissions' in jsonSchema.definitions) {\n\t\t\tjsonSchema.definitions['form-submissions'] = {\n\t\t\t\ttype: 'object',\n\t\t\t\t...addGoJSONSchema('payload.FormSubmission', false),\n\t\t\t\tfields: [],\n\t\t\t};\n\t\t}\n\n\t\treturn jsonSchema;\n\t},\n\t/**\n\t * Updates the JSON schema so that it doesn't feature oneOf, so Go doesn't\n\t * output it as an interface{}.\n\t */\n\t({ jsonSchema }): JSONSchema4 => {\n\t\tconst updateRelationship = (property: JSONSchema4) => {\n\t\t\tconst payload = property.payload;\n\t\t\tif (!payload) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (payload.type === 'relationship') {\n\t\t\t\tif (payload.hasMany) {\n\t\t\t\t\tproperty.type = 'array';\n\t\t\t\t\tproperty.items = {\n\t\t\t\t\t\t$ref: `#/definitions/${payload.relationTo}`,\n\t\t\t\t\t};\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tdelete property.oneOf;\n\t\t\t\tproperty.$ref = `#/definitions/${property.payload.relationTo}`;\n\t\t\t}\n\n\t\t\tconst pType = payload.type;\n\t\t\tif (\n\t\t\t\tpType === 'group' ||\n\t\t\t\tpType === 'row' ||\n\t\t\t\tpType === 'collapsible' ||\n\t\t\t\tpType === 'array'\n\t\t\t) {\n\t\t\t\tif (property.properties) {\n\t\t\t\t\tfor (const k in property.properties) {\n\t\t\t\t\t\tupdateRelationship(property.properties[k]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t};\n\n\t\tloopJSONSchemaProperties(jsonSchema, ({ property }) => {\n\t\t\tupdateRelationship(property);\n\t\t});\n\t\treturn jsonSchema;\n\t},\n\t/**\n\t * Changes blockType to a string so it's not an *interface{} when\n\t * comparing block types in Go.\n\t */\n\t({ jsonSchema }): JSONSchema4 => {\n\t\tloopJSONSchemaProperties(jsonSchema, ({ property, key }) => {\n\t\t\tif (key === 'blockType') {\n\t\t\t\tproperty.type = 'string';\n\t\t\t\tdelete property.const;\n\t\t\t}\n\t\t});\n\t\treturn jsonSchema;\n\t},\n\t/**\n\t * Changes blockType to a string so it's not an *interface{} when\n\t * comparing block types in Go.\n\t */\n\t({ jsonSchema }): JSONSchema4 => {\n\t\tloopJSONSchemaProperties(jsonSchema, ({ property, key }) => {\n\t\t\tconst payload = property.payload;\n\t\t\tif (payload && payload.type === 'relationship' && payload.name === 'form') {\n\t\t\t\tdelete property.$ref;\n\t\t\t}\n\t\t});\n\t\treturn jsonSchema;\n\t},\n];\n"],"names":["loopJSONSchemaProperties","jsonSchema","callback","definitions","Object","entries","forEach","definitionKey","definition","properties","propertyKey","property","key","addGoJSONSchema","type","nillable","goJSONSchema","imports","fieldMapper","config","opts","mapper","field","typescriptSchema","blocks","block","fields","map","f","useWebKitMedia","required","tabs","tab","relationTo","name","assignRelationships","Array","isArray","push","payload","label","hasMany","collections","collection","globals","global","index","schemas","media","auth","redirects","settings","forms","updateRelationship","items","$ref","oneOf","pType","k","const"],"mappings":"AAWA;;;CAGC,GACD,MAAMA,2BAA2B,CAChCC,YACAC;IAEA,IAAI,CAACD,WAAWE,WAAW,EAAE;QAC5B,OAAOF;IACR;IACAG,OAAOC,OAAO,CAACJ,WAAWE,WAAW,EAAEG,OAAO,CAAC,CAAC,CAACC,eAAeC,WAAW;QAC1E,IAAIA,WAAWC,UAAU,EAAE;YAC1BL,OAAOC,OAAO,CAACG,WAAWC,UAAU,EAAEH,OAAO,CAAC,CAAC,CAACI,aAAaC,SAAS;gBACrET,SAAS;oBAAEU,KAAKF;oBAAaC;gBAAS;YACvC;QACD;IACD;IACA,OAAOV;AACR;AAEA;;CAEC,GACD,OAAO,MAAMY,kBAAkB,CAACC,MAAcC;IAC7C,OAAO;QACN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,QAAQ,aAAa;oBACxBD,SAASG,IAAI,GAAG;oBAChB,OAAOH,SAASgD,KAAK;gBACtB;YACD;YACA,OAAO1D;QACR;QACA;;;EAGC,GACD,CAAC,EAAEA,UAAU,EAAE;YACdD,yBAAyBC,YAAY,CAAC,EAAEU,QAAQ,EAAEC,GAAG,EAAE;gBACtD,MAAM2B,UAAU5B,SAAS4B,OAAO;gBAChC,IAAIA,WAAWA,QAAQzB,IAAI,KAAK,kBAAkByB,QAAQL,IAAI,KAAK,QAAQ;oBAC1E,OAAOvB,SAAS4C,IAAI;gBACrB;YACD;YACA,OAAOtD;QACR;KACA,CAAC"}
|
package/dist/seed/seed.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Payload, type PayloadRequest } from 'payload';
|
|
1
|
+
import { type Payload, type PayloadRequest, type SanitizedConfig } from 'payload';
|
|
2
2
|
/**
|
|
3
3
|
* A function that seeds the database with initial data.
|
|
4
4
|
*/
|
|
@@ -11,21 +11,16 @@ export type Seeder = (args: {
|
|
|
11
11
|
* Note: You must use path.resolve for the paths, i.e. path.resolve(__dirname, 'path/to/file')
|
|
12
12
|
*/
|
|
13
13
|
export type SeedOptions = {
|
|
14
|
-
|
|
15
|
-
configPath: string;
|
|
16
|
-
dbAdapter: DBAdapter;
|
|
14
|
+
config: SanitizedConfig;
|
|
17
15
|
seeder: Seeder;
|
|
18
16
|
};
|
|
19
|
-
/**
|
|
20
|
-
* The database adapter to use, which will remove and recreate the database.
|
|
21
|
-
*/
|
|
22
|
-
export declare enum DBAdapter {
|
|
23
|
-
Postgres = "postgres"
|
|
24
|
-
}
|
|
25
17
|
/**
|
|
26
18
|
* Seeds the database with initial data.
|
|
27
19
|
*
|
|
28
20
|
* @param opts - The options for seeding.
|
|
29
21
|
* @returns A promise that resolves when the seeding is complete.
|
|
30
22
|
*/
|
|
31
|
-
export declare const seed: (opts:
|
|
23
|
+
export declare const seed: (opts: {
|
|
24
|
+
seeder: Seeder;
|
|
25
|
+
config: SanitizedConfig;
|
|
26
|
+
}) => void;
|
package/dist/seed/seed.js
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
import dotenv from 'dotenv';
|
|
2
1
|
import { commitTransaction, getPayload, initTransaction, killTransaction } from 'payload';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { fileURLToPath } from "node:url";
|
|
2
|
+
import env from '../util/env.js';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
8
6
|
const filename = fileURLToPath(import.meta.url);
|
|
9
7
|
const dirname = path.dirname(filename);
|
|
10
|
-
export var DBAdapter;
|
|
11
|
-
(function(DBAdapter) {
|
|
12
|
-
DBAdapter["Postgres"] = "postgres";
|
|
13
|
-
})(DBAdapter || (DBAdapter = {}));
|
|
14
8
|
/**
|
|
15
9
|
* Seeds the database with initial data.
|
|
16
10
|
*
|
|
@@ -18,13 +12,9 @@ export var DBAdapter;
|
|
|
18
12
|
* @returns A promise that resolves when the seeding is complete.
|
|
19
13
|
*/ export const seed = (opts)=>{
|
|
20
14
|
const fn = async ()=>{
|
|
21
|
-
dotenv.config({
|
|
22
|
-
path: opts.envPath
|
|
23
|
-
});
|
|
24
15
|
process.env.PAYLOAD_DROP_DATABASE = 'true';
|
|
25
|
-
const config = await importConfig(opts.configPath);
|
|
26
16
|
const payload = await getPayload({
|
|
27
|
-
config
|
|
17
|
+
config: opts.config
|
|
28
18
|
});
|
|
29
19
|
const req = {
|
|
30
20
|
payload
|
|
@@ -32,11 +22,6 @@ export var DBAdapter;
|
|
|
32
22
|
await initTransaction(req);
|
|
33
23
|
delete process.env.PAYLOAD_DROP_DATABASE;
|
|
34
24
|
try {
|
|
35
|
-
// Init
|
|
36
|
-
payload.logger.info("Initialising Payload...");
|
|
37
|
-
await payload.init({
|
|
38
|
-
config: payload.config
|
|
39
|
-
});
|
|
40
25
|
// Creating new tables
|
|
41
26
|
payload.logger.info('Creating indexes...');
|
|
42
27
|
try {
|
|
@@ -47,10 +32,8 @@ export var DBAdapter;
|
|
|
47
32
|
payload.logger.error(`Creating database: ${error}`);
|
|
48
33
|
return;
|
|
49
34
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
await payload.db.migrate();
|
|
53
|
-
}
|
|
35
|
+
payload.logger.info('Migrating DB...');
|
|
36
|
+
await payload.db.migrate();
|
|
54
37
|
// Clearing local media
|
|
55
38
|
if (!env.isProduction) {
|
|
56
39
|
payload.logger.info('Clearing media...');
|
package/dist/seed/seed.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/seed/seed.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["../../src/seed/seed.ts"],"sourcesContent":["import {\n\ttype Payload,\n\ttype PayloadRequest,\n\ttype SanitizedConfig,\n\tcommitTransaction,\n\tgetPayload,\n\tinitTransaction,\n\tkillTransaction,\n} from 'payload';\nimport env from '../util/env.js';\nimport path from 'node:path';\nimport fs from 'node:fs';\nimport { fileURLToPath } from 'node:url';\n\nconst filename = fileURLToPath(import.meta.url);\nconst dirname = path.dirname(filename);\n\n/**\n * A function that seeds the database with initial data.\n */\nexport type Seeder = (args: { payload: Payload; req: PayloadRequest }) => Promise<void>;\n\n/**\n * Options for the seed function.\n * Note: You must use path.resolve for the paths, i.e. path.resolve(__dirname, 'path/to/file')\n */\nexport type SeedOptions = {\n\tconfig: SanitizedConfig;\n\tseeder: Seeder;\n};\n\n/**\n * Seeds the database with initial data.\n *\n * @param opts - The options for seeding.\n * @returns A promise that resolves when the seeding is complete.\n */\nexport const seed = (opts: {\n\tseeder: Seeder,\n\tconfig: SanitizedConfig;\n}) => {\n\tconst fn = async () => {\n\t\tprocess.env.PAYLOAD_DROP_DATABASE = 'true';\n\n\t\tconst payload = await getPayload({\n\t\t\tconfig: opts.config,\n\t\t});\n\t\tconst req = { payload } as PayloadRequest;\n\n\t\tawait initTransaction(req);\n\n\t\tdelete process.env.PAYLOAD_DROP_DATABASE;\n\n\t\ttry {\n\t\t\t// Creating new tables\n\t\t\tpayload.logger.info('Creating indexes...');\n\t\t\ttry {\n\t\t\t\tif (payload.db.init) {\n\t\t\t\t\tawait payload.db.init();\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tpayload.logger.error(`Creating database: ${error}`);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tpayload.logger.info('Migrating DB...');\n\t\t\tawait payload.db.migrate();\n\n\t\t\t// Clearing local media\n\t\t\tif (!env.isProduction) {\n\t\t\t\tpayload.logger.info('Clearing media...');\n\t\t\t\tconst mediaDir = path.resolve(dirname, '../../media');\n\t\t\t\tif (fs.existsSync(mediaDir)) {\n\t\t\t\t\tfs.rmSync(mediaDir, { recursive: true, force: true });\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Run user defined seed script\n\t\t\tawait opts.seeder({ payload, req });\n\n\t\t\tawait commitTransaction(req);\n\n\t\t\tpayload.logger.info('Seed complete');\n\t\t} catch (err) {\n\t\t\tconst message = err instanceof Error ? err.message : 'Unknown error';\n\t\t\tpayload.logger.error(`Seed failed: ${message}`);\n\t\t\tawait killTransaction(req);\n\t\t}\n\t};\n\n\tfn()\n\t\t.then(() => process.exit(0))\n\t\t.catch((e) => {\n\t\t\tconsole.error(e);\n\t\t\tprocess.exit(1);\n\t\t});\n};\n"],"names":["commitTransaction","getPayload","initTransaction","killTransaction","env","path","fs","fileURLToPath","filename","url","dirname","seed","opts","fn","process","PAYLOAD_DROP_DATABASE","payload","config","req","logger","info","db","init","error","migrate","isProduction","mediaDir","resolve","existsSync","rmSync","recursive","force","seeder","err","message","Error","then","exit","catch","e","console"],"mappings":"AAAA,SAICA,iBAAiB,EACjBC,UAAU,EACVC,eAAe,EACfC,eAAe,QACT,UAAU;AACjB,OAAOC,SAAS,iBAAiB;AACjC,OAAOC,UAAU,YAAY;AAC7B,OAAOC,QAAQ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AAO,GAAG;YACrDlB,QAAQG,MAAM,CAACI,KAAK,CAAC,CAAC,aAAa,EAAEW,QAAQ,CAAC;YAC9C,MAAM/B,gBAAgBe;QACvB;IACD;IAEAL,KACEuB,IAAI,CAAC,IAAMtB,QAAQuB,IAAI,CAAC,IACxBC,KAAK,CAAC,CAACC;QACPC,QAAQjB,KAAK,CAACgB;QACdzB,QAAQuB,IAAI,CAAC;IACd;AACF,EAAE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ainsleydev/payload-helper",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.24",
|
|
4
4
|
"description": "Payload CMS utilities, collections and global types for ainsley.dev builds",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -32,21 +32,21 @@
|
|
|
32
32
|
},
|
|
33
33
|
"files": ["dist", "bin.js", "types.js", "types.ts", "types.d.ts"],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@lexical/headless": "^0.
|
|
36
|
-
"@lexical/html": "^0.
|
|
35
|
+
"@lexical/headless": "^0.18.0",
|
|
36
|
+
"@lexical/html": "^0.18.0",
|
|
37
37
|
"@nouance/payload-better-fields-plugin": "^1.4.1",
|
|
38
|
-
"@payloadcms/db-sqlite": "3.0.0-beta.
|
|
39
|
-
"@payloadcms/richtext-lexical": "3.0.0-beta.
|
|
40
|
-
"@payloadcms/plugin-form-builder": "3.0.0-beta.
|
|
41
|
-
"@payloadcms/plugin-seo": "3.0.0-beta.
|
|
38
|
+
"@payloadcms/db-sqlite": "3.0.0-beta.116",
|
|
39
|
+
"@payloadcms/richtext-lexical": "3.0.0-beta.116",
|
|
40
|
+
"@payloadcms/plugin-form-builder": "3.0.0-beta.116",
|
|
41
|
+
"@payloadcms/plugin-seo": "3.0.0-beta.116",
|
|
42
42
|
"@types/json-schema": "^7.0.15",
|
|
43
43
|
"chalk": "^5.3.0",
|
|
44
44
|
"commander": "^12.1.0",
|
|
45
45
|
"dotenv": "^16.4.5",
|
|
46
46
|
"jsdom": "^24.1.1",
|
|
47
|
-
"lexical": "^0.
|
|
47
|
+
"lexical": "^0.18.0",
|
|
48
48
|
"mime-types": "^2.1.35",
|
|
49
|
-
"payload": "3.0.0-beta.
|
|
49
|
+
"payload": "3.0.0-beta.116"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@ainsleydev/eslint-config": "workspace:*",
|
|
@@ -61,10 +61,22 @@
|
|
|
61
61
|
"rimraf": "3.0.2",
|
|
62
62
|
"ts-jest": "^29.2.3",
|
|
63
63
|
"ts-node": "^10.9.2",
|
|
64
|
-
"typescript": "^5.5.4"
|
|
64
|
+
"typescript": "^5.5.4",
|
|
65
|
+
"react": "19.0.0-rc-3edc000d-20240926",
|
|
66
|
+
"react-dom": "19.0.0-rc-3edc000d-20240926"
|
|
65
67
|
},
|
|
66
68
|
"engines": {
|
|
67
69
|
"node": ">=18",
|
|
68
70
|
"pnpm": ">=9"
|
|
71
|
+
},
|
|
72
|
+
"pnpm": {
|
|
73
|
+
"overrides": {
|
|
74
|
+
"@types/react": "npm:types-react@19.0.0-rc.1",
|
|
75
|
+
"@types/react-dom": "npm:types-react-dom@19.0.0-rc.1"
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
"overrides": {
|
|
79
|
+
"@types/react": "npm:types-react@19.0.0-rc.1",
|
|
80
|
+
"@types/react-dom": "npm:types-react-dom@19.0.0-rc.1"
|
|
69
81
|
}
|
|
70
82
|
}
|
package/dist/cli/types.d.ts
DELETED
package/dist/cli/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cli/types.ts"],"sourcesContent":["import * as fs from 'node:fs';\nimport { configToJSONSchema, getPayload } from 'payload';\nimport { findConfig, importConfig } from 'payload/node';\n\n/**\n * Creates JSON schema types of Payloads Collections & Globals\n */\nexport async function generateTypes(outFile: string): Promise<void> {\n\tconsole.log('Compiling JSON types for Collections and Globals...');\n\n\tlet configPath = '';\n\ttry {\n\t\tconfigPath = findConfig();\n\t} catch (e) {\n\t\tconsole.log(`Error finding config: ${e}`);\n\t\treturn;\n\t}\n\n\t// Set the environment variable to generate Golang types.\n\tprocess.env.GEN_GOLANG = 'true';\n\n\tconst config = await importConfig(configPath);\n\tconst outputFile = (process.env.PAYLOAD_TS_OUTPUT_PATH || config.typescript.outputFile).replace(\n\t\t'.ts',\n\t\t'.json',\n\t);\n\n\tconst payload = await getPayload({\n\t\tconfig,\n\t\tdisableDBConnect: true,\n\t\tdisableOnInit: true,\n\t\t// @ts-ignore\n\t\tlocal: true,\n\t\tsecret: '--unused--',\n\t});\n\n\tconst jsonSchema = configToJSONSchema(payload.config, payload.db.defaultIDType);\n\tconst prettyJSON = JSON.stringify(jsonSchema, null, 4);\n\n\tfs.writeFileSync(outputFile, prettyJSON);\n\n\tconsole.log(`JSON types written to: ${outputFile}`);\n\n\tdelete process.env.GEN_GOLANG;\n}\n"],"names":["fs","configToJSONSchema","getPayload","findConfig","importConfig","generateTypes","outFile","console","log","configPath","e","process","env","GEN_GOLANG","config","outputFile","PAYLOAD_TS_OUTPUT_PATH","typescript","replace","payload","disableDBConnect","disableOnInit","local","secret","jsonSchema","db","defaultIDType","prettyJSON","JSON","stringify","writeFileSync"],"mappings":"AAAA,YAAYA,QAAQ,UAAU;AAC9B,SAASC,kBAAkB,EAAEC,UAAU,QAAQ,UAAU;AACzD,SAASC,UAAU,EAAEC,YAAY,QAAQ,eAAe;AAExD;;CAEC,GACD,OAAO,eAAeC,cAAcC,OAAe;IAClDC,QAAQC,GAAG,CAAC;IAEZ,IAAIC,aAAa;IACjB,IAAI;QACHA,aAAaN;IACd,EAAE,OAAOO,GAAG;QACXH,QAAQC,GAAG,CAAC,CAAC,sBAAsB,EAAEE,EAAE,CAAC;QACxC;IACD;IAEA,yDAAyD;IACzDC,QAAQC,GAAG,CAACC,UAAU,GAAG;IAEzB,MAAMC,SAAS,MAAMV,aAAaK;IAClC,MAAMM,aAAa,AAACJ,CAAAA,QAAQC,GAAG,CAACI,sBAAsB,IAAIF,OAAOG,UAAU,CAACF,UAAU,AAAD,EAAGG,OAAO,CAC9F,OACA;IAGD,MAAMC,UAAU,MAAMjB,WAAW;QAChCY;QACAM,kBAAkB;QAClBC,eAAe;QACf,aAAa;QACbC,OAAO;QACPC,QAAQ;IACT;IAEA,MAAMC,aAAavB,mBAAmBkB,QAAQL,MAAM,EAAEK,QAAQM,EAAE,CAACC,aAAa;IAC9E,MAAMC,aAAaC,KAAKC,SAAS,CAACL,YAAY,MAAM;IAEpDxB,GAAG8B,aAAa,CAACf,YAAYY;IAE7BpB,QAAQC,GAAG,CAAC,CAAC,uBAAuB,EAAEO,WAAW,CAAC;IAElD,OAAOJ,QAAQC,GAAG,CAACC,UAAU;AAC9B"}
|