@ainsleydev/payload-helper 0.0.19 → 0.0.21
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/collections/Media.js +0 -28
- package/dist/collections/Media.js.map +1 -1
- package/dist/index.js +20 -2
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +1 -0
- package/dist/types.js +7 -0
- package/dist/types.js.map +1 -1
- package/package.json +1 -2
|
@@ -160,34 +160,6 @@ import * as mime from 'mime-types';
|
|
|
160
160
|
quality: 80
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
|
-
},
|
|
164
|
-
// Desktop Sizes
|
|
165
|
-
{
|
|
166
|
-
name: 'desktop',
|
|
167
|
-
width: 1200,
|
|
168
|
-
height: undefined
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
name: 'desktop_webp',
|
|
172
|
-
width: 1200,
|
|
173
|
-
height: undefined,
|
|
174
|
-
formatOptions: {
|
|
175
|
-
format: 'webp',
|
|
176
|
-
options: {
|
|
177
|
-
quality: 80
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
},
|
|
181
|
-
{
|
|
182
|
-
name: 'desktop_avif',
|
|
183
|
-
width: 1200,
|
|
184
|
-
height: undefined,
|
|
185
|
-
formatOptions: {
|
|
186
|
-
format: 'avif',
|
|
187
|
-
options: {
|
|
188
|
-
quality: 80
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
163
|
}
|
|
192
164
|
]
|
|
193
165
|
}
|
|
@@ -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';\n\n/**\n * Media Collection Configuration\n * Additional fields will be appended to the media collection.\n */\nexport const Media = (additionalFields?: Field[]): CollectionConfig => {\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...(additionalFields ? additionalFields : []),\n\t\t],\n\t\tupload: {\n\t\t\tstaticDir: 'media',\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: [\n\t\t\t\t// Original Size (for WebP & Avif)\n\t\t\t\t{\n\t\t\t\t\tname: 'webp',\n\t\t\t\t\twidth: undefined,\n\t\t\t\t\theight: undefined,\n\t\t\t\t\tformatOptions: {\n\t\t\t\t\t\tformat: 'webp',\n\t\t\t\t\t\toptions: {\n\t\t\t\t\t\t\tquality: 80,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: 'avif',\n\t\t\t\t\twidth: undefined,\n\t\t\t\t\theight: undefined,\n\t\t\t\t\tformatOptions: {\n\t\t\t\t\t\tformat: 'avif',\n\t\t\t\t\t\toptions: {\n\t\t\t\t\t\t\tquality: 80,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t// Thumbnail Sizes\n\t\t\t\t{\n\t\t\t\t\tname: 'thumbnail',\n\t\t\t\t\twidth: 200,\n\t\t\t\t\theight: undefined,\n\t\t\t\t\tposition: 'centre',\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: 'thumbnail_webp',\n\t\t\t\t\twidth: 200,\n\t\t\t\t\theight: undefined,\n\t\t\t\t\tposition: 'centre',\n\t\t\t\t\tformatOptions: {\n\t\t\t\t\t\tformat: 'webp',\n\t\t\t\t\t\toptions: {\n\t\t\t\t\t\t\tquality: 80,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: 'thumbnail_avif',\n\t\t\t\t\twidth: 200,\n\t\t\t\t\theight: undefined,\n\t\t\t\t\tposition: 'centre',\n\t\t\t\t\tformatOptions: {\n\t\t\t\t\t\tformat: 'avif',\n\t\t\t\t\t\toptions: {\n\t\t\t\t\t\t\tquality: 80,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t// Mobile Sizes\n\t\t\t\t{\n\t\t\t\t\tname: 'mobile',\n\t\t\t\t\twidth: 500,\n\t\t\t\t\theight: undefined,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: 'mobile_webp',\n\t\t\t\t\twidth: 500,\n\t\t\t\t\theight: undefined,\n\t\t\t\t\tformatOptions: {\n\t\t\t\t\t\tformat: 'webp',\n\t\t\t\t\t\toptions: {\n\t\t\t\t\t\t\tquality: 80,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: 'mobile_avif',\n\t\t\t\t\twidth: 500,\n\t\t\t\t\theight: undefined,\n\t\t\t\t\tformatOptions: {\n\t\t\t\t\t\tformat: 'avif',\n\t\t\t\t\t\toptions: {\n\t\t\t\t\t\t\tquality: 80,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t// Tablet Sizes\n\t\t\t\t{\n\t\t\t\t\tname: 'tablet',\n\t\t\t\t\twidth: 800,\n\t\t\t\t\theight: undefined,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: 'tablet_webp',\n\t\t\t\t\twidth: 800,\n\t\t\t\t\theight: undefined,\n\t\t\t\t\tformatOptions: {\n\t\t\t\t\t\tformat: 'webp',\n\t\t\t\t\t\toptions: {\n\t\t\t\t\t\t\tquality: 80,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: 'tablet_avif',\n\t\t\t\t\twidth: 800,\n\t\t\t\t\theight: undefined,\n\t\t\t\t\tformatOptions: {\n\t\t\t\t\t\tformat: 'avif',\n\t\t\t\t\t\toptions: {\n\t\t\t\t\t\t\tquality: 80,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t// Desktop Sizes\n\t\t\t\t{\n\t\t\t\t\tname: 'desktop',\n\t\t\t\t\twidth: 1200,\n\t\t\t\t\theight: undefined,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: 'desktop_webp',\n\t\t\t\t\twidth: 1200,\n\t\t\t\t\theight: undefined,\n\t\t\t\t\tformatOptions: {\n\t\t\t\t\t\tformat: 'webp',\n\t\t\t\t\t\toptions: {\n\t\t\t\t\t\t\tquality: 80,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: 'desktop_avif',\n\t\t\t\t\twidth: 1200,\n\t\t\t\t\theight: undefined,\n\t\t\t\t\tformatOptions: {\n\t\t\t\t\t\tformat: 'avif',\n\t\t\t\t\t\toptions: {\n\t\t\t\t\t\t\tquality: 80,\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},\n\t};\n};\n"],"names":["lexicalEditor","mime","Media","additionalFields","slug","access","read","fields","name","type","required","editor","features","defaultFeatures","filter","feature","key","upload","staticDir","handlers","req","args","logger","payload","params","collection","filename","contentType","lookup","error","headers","Headers","set","responseHeaders","imageSizes","width","undefined","height","formatOptions","format","options","quality","position"],"mappings":"AAAA,SAASA,aAAa,QAAQ,+BAA+B;AAC7D,YAAYC,UAAU,aAAa;AAGnC;;;CAGC,GACD,OAAO,MAAMC,QAAQ,CAACC;IACrB,OAAO;QACNC,MAAM;QACNC,QAAQ;YACPC,MAAM,IAAM;QACb;QACAC,QAAQ;YACP;gBACCC,MAAM;gBACNC,MAAM;gBACNC,UAAU;YACX;YACA;gBACCF,MAAM;gBACNC,MAAM;gBACNC,UAAU;gBACVC,QAAQX,cAAc;oBACrBY,UAAU,CAAC,EAAEC,eAAe,EAAE;wBAC7B,OAAOA,gBAAgBC,MAAM,CAAC,CAACC;4BAC9B,OAAOA,QAAQC,GAAG,KAAK,eAAeD,QAAQC,GAAG,KAAK;wBACvD;oBACD;gBACD;YACD;eACIb,mBAAmBA,mBAAmB,EAAE;SAC5C;QACDc,QAAQ;YACPC,WAAW;YACXC,UAAU;gBACT,OAAOC,KAAqBC;oBAC3B,MAAMC,SAASF,IAAIG,OAAO,CAACD,MAAM;oBACjC,MAAM,EAAEE,MAAM,EAAE,GAAGH;oBACnB,MAAM,EAAEI,UAAU,EAAEC,QAAQ,EAAE,GAAGF;oBAEjC,IAAIC,eAAe,SAAS;wBAC3B;oBACD;oBAEA,MAAME,cAAc1B,KAAK2B,MAAM,CAACF;oBAChC,IAAI,CAACC,aAAa;wBACjBL,OAAOO,KAAK,CAAC,CAAC,mCAAmC,EAAEH,SAAS,CAAC;wBAC7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AQ;wBACRC,SAAS;4BACRC,SAAS;wBACV;oBACD;gBACD;gBACA;oBACCjC,MAAM;oBACN2B,OAAO;oBACPE,QAAQD;oBACRE,eAAe;wBACdC,QAAQ;wBACRC,SAAS;4BACRC,SAAS;wBACV;oBACD;gBACD;
|
|
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';\n\n/**\n * Media Collection Configuration\n * Additional fields will be appended to the media collection.\n */\nexport const Media = (additionalFields?: Field[]): CollectionConfig => {\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...(additionalFields ? additionalFields : []),\n\t\t],\n\t\tupload: {\n\t\t\tstaticDir: 'media',\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: [\n\t\t\t\t// Original Size (for WebP & Avif)\n\t\t\t\t{\n\t\t\t\t\tname: 'webp',\n\t\t\t\t\twidth: undefined,\n\t\t\t\t\theight: undefined,\n\t\t\t\t\tformatOptions: {\n\t\t\t\t\t\tformat: 'webp',\n\t\t\t\t\t\toptions: {\n\t\t\t\t\t\t\tquality: 80,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: 'avif',\n\t\t\t\t\twidth: undefined,\n\t\t\t\t\theight: undefined,\n\t\t\t\t\tformatOptions: {\n\t\t\t\t\t\tformat: 'avif',\n\t\t\t\t\t\toptions: {\n\t\t\t\t\t\t\tquality: 80,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t// Thumbnail Sizes\n\t\t\t\t{\n\t\t\t\t\tname: 'thumbnail',\n\t\t\t\t\twidth: 200,\n\t\t\t\t\theight: undefined,\n\t\t\t\t\tposition: 'centre',\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: 'thumbnail_webp',\n\t\t\t\t\twidth: 200,\n\t\t\t\t\theight: undefined,\n\t\t\t\t\tposition: 'centre',\n\t\t\t\t\tformatOptions: {\n\t\t\t\t\t\tformat: 'webp',\n\t\t\t\t\t\toptions: {\n\t\t\t\t\t\t\tquality: 80,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: 'thumbnail_avif',\n\t\t\t\t\twidth: 200,\n\t\t\t\t\theight: undefined,\n\t\t\t\t\tposition: 'centre',\n\t\t\t\t\tformatOptions: {\n\t\t\t\t\t\tformat: 'avif',\n\t\t\t\t\t\toptions: {\n\t\t\t\t\t\t\tquality: 80,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t// Mobile Sizes\n\t\t\t\t{\n\t\t\t\t\tname: 'mobile',\n\t\t\t\t\twidth: 500,\n\t\t\t\t\theight: undefined,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: 'mobile_webp',\n\t\t\t\t\twidth: 500,\n\t\t\t\t\theight: undefined,\n\t\t\t\t\tformatOptions: {\n\t\t\t\t\t\tformat: 'webp',\n\t\t\t\t\t\toptions: {\n\t\t\t\t\t\t\tquality: 80,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: 'mobile_avif',\n\t\t\t\t\twidth: 500,\n\t\t\t\t\theight: undefined,\n\t\t\t\t\tformatOptions: {\n\t\t\t\t\t\tformat: 'avif',\n\t\t\t\t\t\toptions: {\n\t\t\t\t\t\t\tquality: 80,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t// Tablet Sizes\n\t\t\t\t{\n\t\t\t\t\tname: 'tablet',\n\t\t\t\t\twidth: 800,\n\t\t\t\t\theight: undefined,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: 'tablet_webp',\n\t\t\t\t\twidth: 800,\n\t\t\t\t\theight: undefined,\n\t\t\t\t\tformatOptions: {\n\t\t\t\t\t\tformat: 'webp',\n\t\t\t\t\t\toptions: {\n\t\t\t\t\t\t\tquality: 80,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: 'tablet_avif',\n\t\t\t\t\twidth: 800,\n\t\t\t\t\theight: undefined,\n\t\t\t\t\tformatOptions: {\n\t\t\t\t\t\tformat: 'avif',\n\t\t\t\t\t\toptions: {\n\t\t\t\t\t\t\tquality: 80,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t// Desktop Sizes\n\t\t\t\t// {\n\t\t\t\t// \tname: 'desktop',\n\t\t\t\t// \twidth: 1200,\n\t\t\t\t// \theight: undefined,\n\t\t\t\t// },\n\t\t\t\t// {\n\t\t\t\t// \tname: 'desktop_webp',\n\t\t\t\t// \twidth: 1200,\n\t\t\t\t// \theight: undefined,\n\t\t\t\t// \tformatOptions: {\n\t\t\t\t// \t\tformat: 'webp',\n\t\t\t\t// \t\toptions: {\n\t\t\t\t// \t\t\tquality: 80,\n\t\t\t\t// \t\t},\n\t\t\t\t// \t},\n\t\t\t\t// },\n\t\t\t\t// {\n\t\t\t\t// \tname: 'desktop_avif',\n\t\t\t\t// \twidth: 1200,\n\t\t\t\t// \theight: undefined,\n\t\t\t\t// \tformatOptions: {\n\t\t\t\t// \t\tformat: 'avif',\n\t\t\t\t// \t\toptions: {\n\t\t\t\t// \t\t\tquality: 80,\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},\n\t};\n};\n"],"names":["lexicalEditor","mime","Media","additionalFields","slug","access","read","fields","name","type","required","editor","features","defaultFeatures","filter","feature","key","upload","staticDir","handlers","req","args","logger","payload","params","collection","filename","contentType","lookup","error","headers","Headers","set","responseHeaders","imageSizes","width","undefined","height","formatOptions","format","options","quality","position"],"mappings":"AAAA,SAASA,aAAa,QAAQ,+BAA+B;AAC7D,YAAYC,UAAU,aAAa;AAGnC;;;CAGC,GACD,OAAO,MAAMC,QAAQ,CAACC;IACrB,OAAO;QACNC,MAAM;QACNC,QAAQ;YACPC,MAAM,IAAM;QACb;QACAC,QAAQ;YACP;gBACCC,MAAM;gBACNC,MAAM;gBACNC,UAAU;YACX;YACA;gBACCF,MAAM;gBACNC,MAAM;gBACNC,UAAU;gBACVC,QAAQX,cAAc;oBACrBY,UAAU,CAAC,EAAEC,eAAe,EAAE;wBAC7B,OAAOA,gBAAgBC,MAAM,CAAC,CAACC;4BAC9B,OAAOA,QAA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BACRC,SAAS;wBACV;oBACD;gBACD;gBACA,eAAe;gBACf;oBACCjC,MAAM;oBACN2B,OAAO;oBACPE,QAAQD;gBACT;gBACA;oBACC5B,MAAM;oBACN2B,OAAO;oBACPE,QAAQD;oBACRE,eAAe;wBACdC,QAAQ;wBACRC,SAAS;4BACRC,SAAS;wBACV;oBACD;gBACD;gBACA;oBACCjC,MAAM;oBACN2B,OAAO;oBACPE,QAAQD;oBACRE,eAAe;wBACdC,QAAQ;wBACRC,SAAS;4BACRC,SAAS;wBACV;oBACD;gBACD;gBACA,eAAe;gBACf;oBACCjC,MAAM;oBACN2B,OAAO;oBACPE,QAAQD;gBACT;gBACA;oBACC5B,MAAM;oBACN2B,OAAO;oBACPE,QAAQD;oBACRE,eAAe;wBACdC,QAAQ;wBACRC,SAAS;4BACRC,SAAS;wBACV;oBACD;gBACD;gBACA;oBACCjC,MAAM;oBACN2B,OAAO;oBACPE,QAAQD;oBACRE,eAAe;wBACdC,QAAQ;wBACRC,SAAS;4BACRC,SAAS;wBACV;oBACD;gBACD;aA6BA;QACF;IACD;AACD,EAAE"}
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,23 @@
|
|
|
1
1
|
import { cacheHookCollections, cacheHookGlobals } from './plugin/hooks.js';
|
|
2
2
|
import { fieldMapper, schemas } from './plugin/schema.js';
|
|
3
3
|
import env from './util/env.js';
|
|
4
|
-
// export const test = (pluginOptions: PayloadHelperPluginConfig) =>
|
|
5
|
-
//
|
|
4
|
+
// export const test = (pluginOptions: PayloadHelperPluginConfig): Plugin[] => {
|
|
5
|
+
// return [
|
|
6
|
+
// seoPlugin({
|
|
7
|
+
// collections: pluginOptions?.seo?.collections,
|
|
8
|
+
// globals: pluginOptions?.seo?.globals,
|
|
9
|
+
// fields: [...SEOFields, pluginOptions.seo?.fields],
|
|
10
|
+
// tabbedUI: true,
|
|
11
|
+
// uploadsCollection: 'media',
|
|
12
|
+
// generateTitle: pluginOptions?.seo?.generateTitle ?
|
|
13
|
+
// pluginOptions?.seo?.generateTitle :
|
|
14
|
+
// ({ doc }) => `${pluginOptions.siteName} — ${doc?.title?.value ?? ''}`,
|
|
15
|
+
// generateDescription: pluginOptions?.seo?.generateDescription ?
|
|
16
|
+
// pluginOptions?.seo?.generateDescription :
|
|
17
|
+
// ({ doc }) => doc?.excerpt?.value,
|
|
18
|
+
// }),
|
|
19
|
+
// ];
|
|
20
|
+
// };
|
|
6
21
|
/**
|
|
7
22
|
* Payload Helper Plugin for websites at ainsley.dev
|
|
8
23
|
*
|
|
@@ -24,6 +39,9 @@ import env from './util/env.js';
|
|
|
24
39
|
incomingConfig.typescript.outputFile = './src/types/payload.ts';
|
|
25
40
|
// Map collections & add hooks
|
|
26
41
|
incomingConfig.collections = (incomingConfig.collections || []).map((collection)=>{
|
|
42
|
+
if (collection.upload) {
|
|
43
|
+
return collection;
|
|
44
|
+
}
|
|
27
45
|
return {
|
|
28
46
|
...collection,
|
|
29
47
|
hooks: {
|
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)
|
|
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\tconst genGoLang = env.bool('GEN_GOLANG', false);\n\t\tif (genGoLang) {\n\t\t\tincomingConfig.typescript = {\n\t\t\t\t...incomingConfig.typescript,\n\t\t\t\tschema: schemas,\n\t\t\t};\n\t\t\t// biome-ignore lint/style/noParameterAssign: Need to change field mapper.\n\t\t\tincomingConfig = fieldMapper(incomingConfig);\n\t\t}\n\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) {\n\t\t\t\t\treturn collection;\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\t...collection,\n\t\t\t\t\thooks: {\n\t\t\t\t\t\tafterChange: [\n\t\t\t\t\t\t\tcacheHookCollections({\n\t\t\t\t\t\t\t\tserver: pluginOptions.webServer,\n\t\t\t\t\t\t\t\tslug: collection.slug,\n\t\t\t\t\t\t\t\tfields: collection.fields,\n\t\t\t\t\t\t\t\tisCollection: true,\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};\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\treturn {\n\t\t\t\t...global,\n\t\t\t\thooks: {\n\t\t\t\t\tafterChange: [\n\t\t\t\t\t\tcacheHookGlobals({\n\t\t\t\t\t\t\tserver: pluginOptions.webServer,\n\t\t\t\t\t\t\tslug: global.slug,\n\t\t\t\t\t\t\tfields: global.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\t\t\t};\n\t\t});\n\n\t\treturn incomingConfig;\n\t};\n"],"names":["cacheHookCollections","cacheHookGlobals","fieldMapper","schemas","env","payloadHelper","pluginOptions","incomingConfig","genGoLang","bool","typescript","schema","outputFile","collections","map","collection","upload","hooks","afterChange","server","webServer","slug","fields","isCollection","globals","global"],"mappings":"AACA,SAASA,oBAAoB,EAAEC,gBAAgB,QAAQ,oBAAoB;AAC3E,SAASC,WAAW,EAAEC,OAAO,QAAQ,qBAAqB;AAE1D,OAAOC,SAAS,gBAAgB;AAEhC,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,MAAMC,YAAYJ,IAAIK,IAAI,CAAC,cAAc;QACzC,IAAID,WAAW;YACdD,eAAeG,UAAU,GAAG;gBAC3B,GAAGH,eAAeG,UAAU;gBAC5BC,QAAQR;YACT;YACA,0EAA0E;YAC1EI,iBAAiBL,YAAYK;QAC9B;QAEA,wBAAwB;QAExB,oCAAoC;QACpCA,eAAeG,UAAU,GAAGH,eAAeG,UAAU,IAAI,CAAC;QAC1DH,eAAeG,UAAU,CAACE,UAAU,GAAG;QAEvC,8BAA8B;QAC9BL,eAAeM,WAAW,GAAG,AAACN,CAAAA,eAAeM,WAAW,IAAI,EAAE,AAAD,EAAGC,GAAG,CAClE,CAACC;YACA,IAAIA,WAAWC,MAAM,EAAE;gBACtB,OAAOD;YACR;YACA,OAAO;gBACN,GAAGA,UAAU;gBACbE,OAAO;oBACNC,aAAa;wBACZlB,qBAAqB;4BACpBmB,QAAQb,cAAcc,SAAS;4BAC/BC,MAAMN,WAAWM,IAAI;4BACrBC,QAAQP,WAAWO,MAAM;4BACzBC,cAAc;wBACf;qBACA;gBACF;YACD;QACD;QAGD,0BAA0B;QAC1BhB,eAAeiB,OAAO,GAAG,AAACjB,CAAAA,eAAeiB,OAAO,IAAI,EAAE,AAAD,EAAGV,GAAG,CAAC,CAACW;YAC5D,OAAO;gBACN,GAAGA,MAAM;gBACTR,OAAO;oBACNC,aAAa;wBACZjB,iBAAiB;4BAChBkB,QAAQb,cAAcc,SAAS;4BAC/BC,MAAMI,OAAOJ,IAAI;4BACjBC,QAAQG,OAAOH,MAAM;4BACrBC,cAAc;wBACf;qBACA;gBACF;YACD;QACD;QAEA,OAAOhB;IACR,EAAE"}
|
package/dist/types.d.ts
CHANGED
package/dist/types.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
// import type { SEOPluginConfig } from "@payloadcms/plugin-seo/types";
|
|
2
|
+
// export type SEOConfig = Omit<SEOPluginConfig, 'uploadsCollection' | 'tabbedUI'>;
|
|
3
|
+
//
|
|
4
|
+
// export type S3Config = {
|
|
5
|
+
// enabled: boolean;
|
|
6
|
+
// bucket: string
|
|
7
|
+
// config: AWS.S3ClientConfig;
|
|
8
|
+
// }
|
|
2
9
|
export { };
|
|
3
10
|
|
|
4
11
|
//# sourceMappingURL=types.js.map
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["// import type { SEOPluginConfig } from \"@payloadcms/plugin-seo/types\";\nimport type { GlobalConfig, Tab } from 'payload';\n\nexport type SettingsConfig = {\n\tadditionalTabs?: Tab[];\n\toverride: (args: {\n\t\tconfig: GlobalConfig;\n\t}) => GlobalConfig;\n};\n\nexport type WebServerConfig = {\n\tapiKey?: string;\n\tbaseURL: string;\n\tcacheEndpoint: string;\n};\n\
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["// import type { SEOPluginConfig } from \"@payloadcms/plugin-seo/types\";\nimport type { GlobalConfig, Tab, TextareaField, TextField, UploadField } from 'payload';\n// import type {SEOPluginConfig} from \"@payloadcms/plugin-seo/dist/types.js\";\n\n\nexport type SettingsConfig = {\n\tadditionalTabs?: Tab[];\n\toverride: (args: {\n\t\tconfig: GlobalConfig;\n\t}) => GlobalConfig;\n};\n\nexport type WebServerConfig = {\n\tapiKey?: string;\n\tbaseURL: string;\n\tcacheEndpoint: string;\n};\n\n// export type SEOConfig = Omit<SEOPluginConfig, 'uploadsCollection' | 'tabbedUI'>;\n//\n// export type S3Config = {\n// \tenabled: boolean;\n// \tbucket: string\n// \tconfig: AWS.S3ClientConfig;\n// }\n\nexport type PayloadHelperPluginConfig = {\n\tsiteName: string;\n\tsettings?: SettingsConfig;\n\t// seo?: SEOConfig;\n\twebServer?: WebServerConfig;\n};\n"],"names":[],"mappings":"AAAA,uEAAuE;AAkBvE,mFAAmF;AACnF,EAAE;AACF,2BAA2B;AAC3B,qBAAqB;AACrB,kBAAkB;AAClB,+BAA+B;AAC/B,IAAI;AAEJ,WAKE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ainsleydev/payload-helper",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.21",
|
|
4
4
|
"description": "Payload CMS utilities, collections and global types for ainsley.dev builds",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -37,7 +37,6 @@
|
|
|
37
37
|
"@nouance/payload-better-fields-plugin": "^1.4.1",
|
|
38
38
|
"@payloadcms/db-sqlite": "3.0.0-beta.76",
|
|
39
39
|
"@payloadcms/richtext-lexical": "3.0.0-beta.76",
|
|
40
|
-
"@payloadcms/storage-s3": "3.0.0-beta.76",
|
|
41
40
|
"@payloadcms/plugin-form-builder": "3.0.0-beta.76",
|
|
42
41
|
"@payloadcms/plugin-seo": "3.0.0-beta.76",
|
|
43
42
|
"@types/json-schema": "^7.0.15",
|