@ainsleydev/payload-helper 0.0.15 → 0.0.17
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.d.ts +0 -4
- package/dist/collections/Media.js +30 -11
- package/dist/collections/Media.js.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/package.json +9 -4
|
@@ -2,9 +2,5 @@ import type { CollectionConfig, Field } from 'payload';
|
|
|
2
2
|
/**
|
|
3
3
|
* Media Collection Configuration
|
|
4
4
|
* Additional fields will be appended to the media collection.
|
|
5
|
-
*
|
|
6
|
-
* @constructor
|
|
7
|
-
* @param editor
|
|
8
|
-
* @param additionalFields
|
|
9
5
|
*/
|
|
10
6
|
export declare const Media: (additionalFields?: Field[]) => CollectionConfig;
|
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
// LexicalEditorProps,
|
|
4
|
-
// } from '@payloadcms/richtext-lexical';
|
|
1
|
+
import { lexicalEditor } from '@payloadcms/richtext-lexical';
|
|
2
|
+
import * as mime from 'mime-types';
|
|
5
3
|
/**
|
|
6
4
|
* Media Collection Configuration
|
|
7
5
|
* Additional fields will be appended to the media collection.
|
|
8
|
-
|
|
9
|
-
* @constructor
|
|
10
|
-
* @param editor
|
|
11
|
-
* @param additionalFields
|
|
12
|
-
*/ export const Media = (//editor?: (props?: LexicalEditorProps) => LexicalRichTextAdapterProvider,
|
|
13
|
-
additionalFields)=>{
|
|
6
|
+
*/ export const Media = (additionalFields)=>{
|
|
14
7
|
return {
|
|
15
8
|
slug: 'media',
|
|
16
9
|
access: {
|
|
@@ -25,12 +18,38 @@ additionalFields)=>{
|
|
|
25
18
|
{
|
|
26
19
|
name: 'caption',
|
|
27
20
|
type: 'richText',
|
|
28
|
-
required: false
|
|
21
|
+
required: false,
|
|
22
|
+
editor: lexicalEditor({
|
|
23
|
+
features: ({ defaultFeatures })=>{
|
|
24
|
+
return defaultFeatures.filter((feature)=>{
|
|
25
|
+
return feature.key === 'paragraph' || feature.key === 'link';
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
})
|
|
29
29
|
},
|
|
30
30
|
...additionalFields ? additionalFields : []
|
|
31
31
|
],
|
|
32
32
|
upload: {
|
|
33
33
|
staticDir: 'media',
|
|
34
|
+
handlers: [
|
|
35
|
+
async (req, args)=>{
|
|
36
|
+
const logger = req.payload.logger;
|
|
37
|
+
const { params } = args;
|
|
38
|
+
const { collection, filename } = params;
|
|
39
|
+
if (collection !== 'media') {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const contentType = mime.lookup(filename);
|
|
43
|
+
if (!contentType) {
|
|
44
|
+
logger.error(`Unable to find mime type for file: ${filename}`);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const headers = new Headers();
|
|
48
|
+
headers.set('Content-Type', contentType);
|
|
49
|
+
headers.set('Cache-Control', 'public, max-age=31536000');
|
|
50
|
+
req.responseHeaders = headers;
|
|
51
|
+
}
|
|
52
|
+
],
|
|
34
53
|
imageSizes: [
|
|
35
54
|
// Original Size (for WebP & Avif)
|
|
36
55
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/collections/Media.ts"],"sourcesContent":["import
|
|
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: 400,\n\t\t\t\t\theight: 300,\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: 400,\n\t\t\t\t\theight: 300,\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: 400,\n\t\t\t\t\theight: 300,\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: 768,\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: 768,\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: 768,\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: 1024,\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: 1024,\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: 1024,\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: 1440,\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: 1440,\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: 1440,\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":"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"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
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
|
+
// (incomingConfig: Config): Config => {
|
|
4
6
|
/**
|
|
5
7
|
* Payload Helper Plugin for websites at ainsley.dev
|
|
6
8
|
*
|
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/**\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\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","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;;;;;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,OAAO;gBACN,GAAGA,UAAU;gBACbC,OAAO;oBACNC,aAAa;wBACZjB,qBAAqB;4BACpBkB,QAAQZ,cAAca,SAAS;4BAC/BC,MAAML,WAAWK,IAAI;4BACrBC,QAAQN,WAAWM,MAAM;4BACzBC,cAAc;wBACf;qBACA;gBACF;YACD;QACD;QAGD,0BAA0B;QAC1Bf,eAAegB,OAAO,GAAG,AAAChB,CAAAA,eAAegB,OAAO,IAAI,EAAE,AAAD,EAAGT,GAAG,CAAC,CAACU;YAC5D,OAAO;gBACN,GAAGA,MAAM;gBACTR,OAAO;oBACNC,aAAa;wBACZhB,iBAAiB;4BAChBiB,QAAQZ,cAAca,SAAS;4BAC/BC,MAAMI,OAAOJ,IAAI;4BACjBC,QAAQG,OAAOH,MAAM;4BACrBC,cAAc;wBACf;qBACA;gBACF;YACD;QACD;QAEA,OAAOf;IACR,EAAE"}
|
|
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) =>\n// \t(incomingConfig: Config): Config => {\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\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","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,oEAAoE;AACpE,yCAAyC;AAEzC;;;;;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,OAAO;gBACN,GAAGA,UAAU;gBACbC,OAAO;oBACNC,aAAa;wBACZjB,qBAAqB;4BACpBkB,QAAQZ,cAAca,SAAS;4BAC/BC,MAAML,WAAWK,IAAI;4BACrBC,QAAQN,WAAWM,MAAM;4BACzBC,cAAc;wBACf;qBACA;gBACF;YACD;QACD;QAGD,0BAA0B;QAC1Bf,eAAegB,OAAO,GAAG,AAAChB,CAAAA,eAAegB,OAAO,IAAI,EAAE,AAAD,EAAGT,GAAG,CAAC,CAACU;YAC5D,OAAO;gBACN,GAAGA,MAAM;gBACTR,OAAO;oBACNC,aAAa;wBACZhB,iBAAiB;4BAChBiB,QAAQZ,cAAca,SAAS;4BAC/BC,MAAMI,OAAOJ,IAAI;4BACjBC,QAAQG,OAAOH,MAAM;4BACrBC,cAAc;wBACf;qBACA;gBACF;YACD;QACD;QAEA,OAAOf;IACR,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.17",
|
|
4
4
|
"description": "Payload CMS utilities, collections and global types for ainsley.dev builds",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -35,15 +35,19 @@
|
|
|
35
35
|
"@lexical/headless": "^0.16.1",
|
|
36
36
|
"@lexical/html": "^0.16.1",
|
|
37
37
|
"@nouance/payload-better-fields-plugin": "^1.4.1",
|
|
38
|
-
"@payloadcms/db-sqlite": "3.0.0-
|
|
39
|
-
"@payloadcms/richtext-lexical": "3.0.0-beta.
|
|
38
|
+
"@payloadcms/db-sqlite": "3.0.0-beta.76",
|
|
39
|
+
"@payloadcms/richtext-lexical": "3.0.0-beta.76",
|
|
40
|
+
"@payloadcms/storage-s3": "3.0.0-beta.76",
|
|
41
|
+
"@payloadcms/plugin-form-builder": "3.0.0-beta.76",
|
|
42
|
+
"@payloadcms/plugin-seo": "3.0.0-beta.76",
|
|
40
43
|
"@types/json-schema": "^7.0.15",
|
|
41
44
|
"chalk": "^5.3.0",
|
|
42
45
|
"commander": "^12.1.0",
|
|
43
46
|
"dotenv": "^16.4.5",
|
|
44
47
|
"jsdom": "^24.1.1",
|
|
45
48
|
"lexical": "^0.16.1",
|
|
46
|
-
"
|
|
49
|
+
"mime-types": "^2.1.35",
|
|
50
|
+
"payload": "3.0.0-beta.76"
|
|
47
51
|
},
|
|
48
52
|
"devDependencies": {
|
|
49
53
|
"@ainsleydev/eslint-config": "workspace:*",
|
|
@@ -52,6 +56,7 @@
|
|
|
52
56
|
"@swc/core": "^1.7.2",
|
|
53
57
|
"@types/jest": "^29.5.12",
|
|
54
58
|
"@types/jsdom": "^21.1.7",
|
|
59
|
+
"@types/mime-types": "^2.1.4",
|
|
55
60
|
"jest": "^29.7.0",
|
|
56
61
|
"json-schema": "^0.4.0",
|
|
57
62
|
"rimraf": "3.0.2",
|