@ainsleydev/payload-helper 0.0.31 → 0.0.33

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.
@@ -1 +1 @@
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
+ {"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.command('generate-types').description('Generate JSON schema types for Payload CMS');\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,QAAQC,OAAO,CAAC,kBAAkBC,WAAW,CAAC;AAE9C,OAAO,MAAMC,MAAM;IAClB,MAAMH,QAAQI,UAAU,CAACC,QAAQC,IAAI;AACtC,EAAE"}
@@ -1,5 +1,5 @@
1
1
  import type { CollectionConfig, Field, UploadConfig } from 'payload';
2
- import type { ImageSize } from "payload";
2
+ import type { ImageSize } from 'payload';
3
3
  export interface MediaArgs {
4
4
  includeAvif?: boolean;
5
5
  additionalFields?: Field[];
@@ -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, 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: 'tablet',\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;QACPE,QAAQD;QACRE,eAAe;YACdC,QAAQ;YACRC,SAAS;gBACRC,SAAS;YACV;QACD;IACD;IACA;QACCP,MAAM;QACNC,OAAO;QACPE,QAAQD;IAC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A;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,UAAU;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"}
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 type { ImageSize } from 'payload';\nimport env from '../util/env.js';\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: 'tablet',\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;AAGnC,OAAOC,SAAS,iBAAiB;AAQjC,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;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;QACPE,QAAQD;QACRE,eAAe;YACdC,QAAQ;YACRC,SAAS;gBACRC,SAAS;YACV;QACD;IACD;CACA,CAAC;AAEF,OAAO,MAAME,qBAAqB;IACjC,OAAO;WACHV;QACH;YACCC,MAAM;YACNC,OAAOC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,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,UAAU;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"}
@@ -31,24 +31,35 @@
31
31
  type: 'row',
32
32
  fields: [
33
33
  {
34
- name: 'title',
34
+ name: 'label',
35
+ label: 'Label',
35
36
  type: 'text',
36
- label: 'Title',
37
37
  required: true,
38
38
  admin: {
39
- width: '50%'
39
+ width: '50%',
40
+ description: 'Enter the text that will appear as a label for the link.'
40
41
  }
41
42
  },
42
43
  {
43
44
  name: 'url',
44
- type: 'text',
45
45
  label: 'URL',
46
+ type: 'text',
46
47
  required: true,
47
48
  admin: {
48
- width: '50%'
49
+ width: '50%',
50
+ description: 'Enter a URL where the link will direct too.'
49
51
  }
50
52
  }
51
53
  ]
54
+ },
55
+ {
56
+ name: 'newTab',
57
+ label: 'Open in a new tab?',
58
+ type: 'checkbox',
59
+ defaultValue: false,
60
+ admin: {
61
+ description: 'Check this box if you would like the link to open in a new tab.'
62
+ }
52
63
  }
53
64
  ];
54
65
  /**
@@ -61,11 +72,12 @@
61
72
  const tabs = [
62
73
  {
63
74
  label: 'Header',
75
+ name: 'header',
64
76
  fields: [
65
77
  {
66
- name: 'header',
67
- type: 'array',
78
+ name: 'items',
68
79
  label: 'Items',
80
+ type: 'array',
69
81
  interfaceName: 'NavigationHeaderLinks',
70
82
  maxRows: 8,
71
83
  labels: {
@@ -88,11 +100,12 @@
88
100
  if (config?.includeFooter) {
89
101
  tabs.push({
90
102
  label: 'Footer',
103
+ name: 'footer',
91
104
  fields: [
92
105
  {
93
- name: 'footer',
94
- type: 'array',
106
+ name: 'items',
95
107
  label: 'Items',
108
+ type: 'array',
96
109
  interfaceName: 'NavigationFooterLinks',
97
110
  maxRows: 8,
98
111
  labels: {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/globals/Navigation.ts"],"sourcesContent":["import type { ArrayField, Field, GlobalConfig, Tab } from 'payload';\n\n/**\n * Navigation Configuration for the header and footer\n * nav links.\n */\ninterface NavigationConfig {\n\tincludeFooter?: boolean;\n\theader?: NavigationMenuConfig;\n\tfooter?: NavigationMenuConfig;\n\tadditionalTabs?: Tab[];\n}\n\n/**\n * Navigation Menu Configuration defines the config for an\n * individual navigation menu, i.e Header or Footer.\n */\ninterface NavigationMenuConfig {\n\tmaxDepth?: number;\n\tadditionalFields?: Field[];\n}\n\n/**\n * Function to generate children structure recursively.\n *\n * @param depth Current depth\n * @param maxDepth Maximum depth to generate children\n * @param fields Fields to include at each level\n */\nconst generateChildren = (depth: number, maxDepth: number, fields: Field[]): Field[] => {\n\tif (depth >= maxDepth) {\n\t\treturn [];\n\t}\n\n\t// Only generate children if depth is less than maxDepth\n\tif (depth < maxDepth - 1) {\n\t\treturn [\n\t\t\t{\n\t\t\t\tname: 'children',\n\t\t\t\ttype: 'array',\n\t\t\t\tlabel: `Children Level ${depth + 1}`,\n\t\t\t\tfields: [...fields, ...generateChildren(depth + 1, maxDepth, fields)],\n\t\t\t},\n\t\t];\n\t}\n\n\treturn [];\n};\n\n/**\n * The default navigation field links.\n */\nconst navFields: Field[] = [\n\t{\n\t\ttype: 'row',\n\t\tfields: [\n\t\t\t{\n\t\t\t\tname: 'title',\n\t\t\t\ttype: 'text',\n\t\t\t\tlabel: 'Title',\n\t\t\t\trequired: true,\n\t\t\t\tadmin: {\n\t\t\t\t\twidth: '50%',\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'url',\n\t\t\t\ttype: 'text',\n\t\t\t\tlabel: 'URL',\n\t\t\t\trequired: true,\n\t\t\t\tadmin: {\n\t\t\t\t\twidth: '50%',\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t},\n];\n\n/**\n * Navigation Global Configuration\n * Additional fields will be appended to each navigation item.\n *\n * @constructor\n * @param config\n */\nexport const Navigation = (config?: NavigationConfig): GlobalConfig => {\n\tconst tabs: Tab[] = [\n\t\t{\n\t\t\tlabel: 'Header',\n\t\t\tfields: [\n\t\t\t\t{\n\t\t\t\t\tname: 'header',\n\t\t\t\t\ttype: 'array',\n\t\t\t\t\tlabel: 'Items',\n\t\t\t\t\tinterfaceName: 'NavigationHeaderLinks',\n\t\t\t\t\tmaxRows: 8,\n\t\t\t\t\tlabels: {\n\t\t\t\t\t\tsingular: 'Link',\n\t\t\t\t\t\tplural: 'Links',\n\t\t\t\t\t},\n\t\t\t\t\tadmin: {\n\t\t\t\t\t\tinitCollapsed: true,\n\t\t\t\t\t\tisSortable: true,\n\t\t\t\t\t},\n\t\t\t\t\tfields: [\n\t\t\t\t\t\t...navFields,\n\t\t\t\t\t\t...(config?.header?.maxDepth\n\t\t\t\t\t\t\t? generateChildren(0, config.header.maxDepth, navFields)\n\t\t\t\t\t\t\t: []),\n\t\t\t\t\t\t...(config?.header?.additionalFields ? config.header.additionalFields : []),\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t],\n\t\t} as ArrayField,\n\t];\n\n\tif (config?.includeFooter) {\n\t\ttabs.push({\n\t\t\tlabel: 'Footer',\n\t\t\tfields: [\n\t\t\t\t{\n\t\t\t\t\tname: 'footer',\n\t\t\t\t\ttype: 'array',\n\t\t\t\t\tlabel: 'Items',\n\t\t\t\t\tinterfaceName: 'NavigationFooterLinks',\n\t\t\t\t\tmaxRows: 8,\n\t\t\t\t\tlabels: {\n\t\t\t\t\t\tsingular: 'Link',\n\t\t\t\t\t\tplural: 'Links',\n\t\t\t\t\t},\n\t\t\t\t\tadmin: {\n\t\t\t\t\t\tinitCollapsed: true,\n\t\t\t\t\t\tisSortable: true,\n\t\t\t\t\t},\n\t\t\t\t\tfields: [\n\t\t\t\t\t\t...navFields,\n\t\t\t\t\t\t...(config?.footer?.maxDepth\n\t\t\t\t\t\t\t? generateChildren(0, config.footer.maxDepth, navFields)\n\t\t\t\t\t\t\t: []),\n\t\t\t\t\t\t...(config?.footer?.additionalFields ? config.footer.additionalFields : []),\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t],\n\t\t} as ArrayField);\n\t}\n\n\treturn {\n\t\tslug: 'navigation',\n\t\ttypescript: {\n\t\t\tinterface: 'Navigation',\n\t\t},\n\t\tgraphQL: {\n\t\t\tname: 'Navigation',\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: [...tabs, ...(config?.additionalTabs ? config.additionalTabs : [])],\n\t\t\t},\n\t\t],\n\t};\n};\n"],"names":["generateChildren","depth","maxDepth","fields","name","type","label","navFields","required","admin","width","Navigation","config","tabs","interfaceName","maxRows","labels","singular","plural","initCollapsed","isSortable","header","additionalFields","includeFooter","push","footer","slug","typescript","interface","graphQL","access","read","additionalTabs"],"mappings":"AAsBA;;;;;;CAMC,GACD,MAAMA,mBAAmB,CAACC,OAAeC,UAAkBC;IAC1D,IAAIF,SAASC,UAAU;QAC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wBACNU,eAAe;wBACfC,YAAY;oBACb;oBACAjB,QAAQ;2BACJI;2BACCK,QAAQa,QAAQvB,WACjBF,iBAAiB,GAAGY,OAAOa,MAAM,CAACvB,QAAQ,EAAEK,aAC5C,EAAE;2BACDK,QAAQa,QAAQH,mBAAmBV,OAAOa,MAAM,CAACH,gBAAgB,GAAG,EAAE;qBAC1E;gBACF;aACA;QACF;IACD;IAEA,OAAO;QACNI,MAAM;QACNC,YAAY;YACXC,WAAW;QACZ;QACAC,SAAS;YACRzB,MAAM;QACP;QACA0B,QAAQ;YACPC,MAAM,IAAM;QACb;QACA5B,QAAQ;YACP;gBACCE,MAAM;gBACNQ,MAAM;uBAAIA;uBAAUD,QAAQoB,iBAAiBpB,OAAOoB,cAAc,GAAG,EAAE;iBAAE;YAC1E;SACA;IACF;AACD,EAAE"}
1
+ {"version":3,"sources":["../../src/globals/Navigation.ts"],"sourcesContent":["import type { ArrayField, Field, GlobalConfig, Tab } from 'payload';\n\n/**\n * Navigation Configuration for the header and footer\n * nav links.\n */\ninterface NavigationConfig {\n\tincludeFooter?: boolean;\n\theader?: NavigationMenuConfig;\n\tfooter?: NavigationMenuConfig;\n\tadditionalTabs?: Tab[];\n}\n\n/**\n * Navigation Menu Configuration defines the config for an\n * individual navigation menu, i.e Header or Footer.\n */\ninterface NavigationMenuConfig {\n\tmaxDepth?: number;\n\tadditionalFields?: Field[];\n}\n\n/**\n * Function to generate children structure recursively.\n *\n * @param depth Current depth\n * @param maxDepth Maximum depth to generate children\n * @param fields Fields to include at each level\n */\nconst generateChildren = (depth: number, maxDepth: number, fields: Field[]): Field[] => {\n\tif (depth >= maxDepth) {\n\t\treturn [];\n\t}\n\n\t// Only generate children if depth is less than maxDepth\n\tif (depth < maxDepth - 1) {\n\t\treturn [\n\t\t\t{\n\t\t\t\tname: 'children',\n\t\t\t\ttype: 'array',\n\t\t\t\tlabel: `Children Level ${depth + 1}`,\n\t\t\t\tfields: [...fields, ...generateChildren(depth + 1, maxDepth, fields)],\n\t\t\t},\n\t\t];\n\t}\n\n\treturn [];\n};\n\n/**\n * The default navigation field links.\n */\nconst navFields: Field[] = [\n\t{\n\t\ttype: 'row',\n\t\tfields: [\n\t\t\t{\n\t\t\t\tname: 'label',\n\t\t\t\tlabel: 'Label',\n\t\t\t\ttype: 'text',\n\t\t\t\trequired: true,\n\t\t\t\tadmin: {\n\t\t\t\t\twidth: '50%',\n\t\t\t\t\tdescription: 'Enter the text that will appear as a label for the link.',\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'url',\n\t\t\t\tlabel: 'URL',\n\t\t\t\ttype: 'text',\n\t\t\t\trequired: true,\n\t\t\t\tadmin: {\n\t\t\t\t\twidth: '50%',\n\t\t\t\t\tdescription: 'Enter a URL where the link will direct too.',\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t},\n\t{\n\t\tname: 'newTab',\n\t\tlabel: 'Open in a new tab?',\n\t\ttype: 'checkbox',\n\t\tdefaultValue: false,\n\t\tadmin: {\n\t\t\tdescription: 'Check this box if you would like the link to open in a new tab.',\n\t\t},\n\t},\n];\n\n/**\n * Navigation Global Configuration\n * Additional fields will be appended to each navigation item.\n *\n * @constructor\n * @param config\n */\nexport const Navigation = (config?: NavigationConfig): GlobalConfig => {\n\tconst tabs: Tab[] = [\n\t\t{\n\t\t\tlabel: 'Header',\n\t\t\tname: 'header',\n\t\t\tfields: [\n\t\t\t\t{\n\t\t\t\t\tname: 'items',\n\t\t\t\t\tlabel: 'Items',\n\t\t\t\t\ttype: 'array',\n\t\t\t\t\tinterfaceName: 'NavigationHeaderLinks',\n\t\t\t\t\tmaxRows: 8,\n\t\t\t\t\tlabels: {\n\t\t\t\t\t\tsingular: 'Link',\n\t\t\t\t\t\tplural: 'Links',\n\t\t\t\t\t},\n\t\t\t\t\tadmin: {\n\t\t\t\t\t\tinitCollapsed: true,\n\t\t\t\t\t\tisSortable: true,\n\t\t\t\t\t},\n\t\t\t\t\tfields: [\n\t\t\t\t\t\t...navFields,\n\t\t\t\t\t\t...(config?.header?.maxDepth\n\t\t\t\t\t\t\t? generateChildren(0, config.header.maxDepth, navFields)\n\t\t\t\t\t\t\t: []),\n\t\t\t\t\t\t...(config?.header?.additionalFields ? config.header.additionalFields : []),\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t],\n\t\t} as ArrayField,\n\t];\n\n\tif (config?.includeFooter) {\n\t\ttabs.push({\n\t\t\tlabel: 'Footer',\n\t\t\tname: 'footer',\n\t\t\tfields: [\n\t\t\t\t{\n\t\t\t\t\tname: 'items',\n\t\t\t\t\tlabel: 'Items',\n\t\t\t\t\ttype: 'array',\n\t\t\t\t\tinterfaceName: 'NavigationFooterLinks',\n\t\t\t\t\tmaxRows: 8,\n\t\t\t\t\tlabels: {\n\t\t\t\t\t\tsingular: 'Link',\n\t\t\t\t\t\tplural: 'Links',\n\t\t\t\t\t},\n\t\t\t\t\tadmin: {\n\t\t\t\t\t\tinitCollapsed: true,\n\t\t\t\t\t\tisSortable: true,\n\t\t\t\t\t},\n\t\t\t\t\tfields: [\n\t\t\t\t\t\t...navFields,\n\t\t\t\t\t\t...(config?.footer?.maxDepth\n\t\t\t\t\t\t\t? generateChildren(0, config.footer.maxDepth, navFields)\n\t\t\t\t\t\t\t: []),\n\t\t\t\t\t\t...(config?.footer?.additionalFields ? config.footer.additionalFields : []),\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t],\n\t\t} as ArrayField);\n\t}\n\n\treturn {\n\t\tslug: 'navigation',\n\t\ttypescript: {\n\t\t\tinterface: 'Navigation',\n\t\t},\n\t\tgraphQL: {\n\t\t\tname: 'Navigation',\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: [...tabs, ...(config?.additionalTabs ? config.additionalTabs : [])],\n\t\t\t},\n\t\t],\n\t};\n};\n"],"names":["generateChildren","depth","maxDepth","fields","name","type","label","navFields","required","admin","width","description","defaultValue","Navigation","config","tabs","interfaceName","maxRows","labels","singular","plural","initCollapsed","isSortable","header","additionalFields","includeFooter","push","footer","slug","typescript","interface","graphQL","access","read","additionalTabs"],"mappings":"AAsBA;;;;;;CAMC,GACD,MAAMA,mBAAmB,CAACC,OAAeC,UAAkBC;IAC1D,IAAIF,SAASC,UAAU;QACtB,OAAO,EAAE;IACV;IAEA,wDAAwD;IACxD,IAAID,QAAQC,WAAW,GAAG;QACzB,OAAO;YACN;gBACCE,MAAM;gBACNC,MAAM;gBACNC,OAAO,CAAC,eAAe,EAAEL,QAAQ,GAAG;gBACpCE,QAAQ;uBAAIA;uBAAWH,iBAAiBC,QAAQ,GAAGC,UAAUC;iBAAQ;YACtE;SACA;IACF;IAEA,OAAO,EAAE;AACV;AAEA;;CAEC,GACD,MAAMI,YAAqB;IAC1B;QACCF,MAAM;QACNF,QAAQ;YACP;gBACCC,MAAM;gBACNE,OAAO;gBACPD,MAAM;gBACNG,UAAU;gBACVC,OAAO;oBACNC,OAAO;oBACPC,aAAa;gBACd;YACD;YACA;gBACCP,MAAM;gBACNE,OAAO;gBACPD,MAAM;gBACNG,UAAU;gBACVC,OAAO;oBACNC,OAAO;oBACPC,aAAa;gBACd;YACD;SACA;IACF;IACA;QACCP,MAAM;QACNE,OAAO;QACPD,MAAM;QACNO,cAAc;QACdH,OAAO;YACNE,aAAa;QACd;IACD;CACA;AAED;;;;;;CAMC,GACD,OAAO,MAAME,aAAa,CAACC;IAC1B,MAAMC,OAAc;QACnB;YACCT,OAAO;YACPF,MAAM;YACND,QAAQ;gBACP;oBACCC,MAAM;oBACNE,OAAO;oBACPD,MAAM;oBACNW,eAAe;oBACfC,SAAS;oBACTC,QAAQ;wBACPC,UAAU;wBACVC,QAAQ;oBACT;oBACAX,OAAO;wBACNY,eAAe;wBACfC,YAAY;oBACb;oBACAnB,QAAQ;2BACJI;2BACCO,QAAQS,QAAQrB,WACjBF,iBAAiB,GAAGc,OAAOS,MAAM,CAACrB,QAAQ,EAAEK,aAC5C,EAAE;2BACDO,QAAQS,QAAQC,mBAAmBV,OAAOS,MAAM,CAACC,gBAAgB,GAAG,EAAE;qBAC1E;gBACF;aACA;QACF;KACA;IAED,IAAIV,QAAQW,eAAe;QAC1BV,KAAKW,IAAI,CAAC;YACTpB,OAAO;YACPF,MAAM;YACND,QAAQ;gBACP;oBACCC,MAAM;oBACNE,OAAO;oBACPD,MAAM;oBACNW,eAAe;oBACfC,SAAS;oBACTC,QAAQ;wBACPC,UAAU;wBACVC,QAAQ;oBACT;oBACAX,OAAO;wBACNY,eAAe;wBACfC,YAAY;oBACb;oBACAnB,QAAQ;2BACJI;2BACCO,QAAQa,QAAQzB,WACjBF,iBAAiB,GAAGc,OAAOa,MAAM,CAACzB,QAAQ,EAAEK,aAC5C,EAAE;2BACDO,QAAQa,QAAQH,mBAAmBV,OAAOa,MAAM,CAACH,gBAAgB,GAAG,EAAE;qBAC1E;gBACF;aACA;QACF;IACD;IAEA,OAAO;QACNI,MAAM;QACNC,YAAY;YACXC,WAAW;QACZ;QACAC,SAAS;YACR3B,MAAM;QACP;QACA4B,QAAQ;YACPC,MAAM,IAAM;QACb;QACA9B,QAAQ;YACP;gBACCE,MAAM;gBACNU,MAAM;uBAAIA;uBAAUD,QAAQoB,iBAAiBpB,OAAOoB,cAAc,GAAG,EAAE;iBAAE;YAC1E;SACA;IACF;AACD,EAAE"}
@@ -1,10 +1,13 @@
1
- import type { GlobalConfig, Tab } from 'payload';
1
+ import { type GlobalConfig, type Tab } from 'payload';
2
+ /**
3
+ * Any additional overrides/tabs for the settings global.
4
+ */
5
+ export type SettingsArgs = {
6
+ overrides?: Partial<Omit<GlobalConfig, 'slug' | 'fields'>>;
7
+ additionalTabs?: Tab[];
8
+ };
2
9
  /**
3
10
  * Settings Global Configuration
4
11
  * Additional tabs will be appended to the settings page.
5
- * TODO, type error in here somewhere.
6
- *
7
- * @param additionalTabs
8
- * @constructor
9
12
  */
10
- export declare const Settings: (additionalTabs?: Tab[]) => GlobalConfig;
13
+ export declare const Settings: (args?: SettingsArgs) => GlobalConfig;
@@ -1,15 +1,12 @@
1
+ import { deepMerge } from 'payload';
1
2
  import { validatePostcode, validateURL } from '../util/validation.js';
2
3
  import { countries } from './countries.js';
3
4
  import { languages } from './locales.js';
4
5
  /**
5
6
  * Settings Global Configuration
6
7
  * Additional tabs will be appended to the settings page.
7
- * TODO, type error in here somewhere.
8
- *
9
- * @param additionalTabs
10
- * @constructor
11
- */ export const Settings = (additionalTabs)=>{
12
- return {
8
+ */ export const Settings = (args)=>{
9
+ const defaultConfig = {
13
10
  slug: 'settings',
14
11
  typescript: {
15
12
  interface: 'Settings'
@@ -336,11 +333,12 @@ import { languages } from './locales.js';
336
333
  }
337
334
  ]
338
335
  },
339
- ...additionalTabs ? additionalTabs : []
336
+ ...args?.additionalTabs ?? []
340
337
  ]
341
338
  }
342
339
  ]
343
340
  };
341
+ return deepMerge(defaultConfig, args?.overrides || {});
344
342
  };
345
343
 
346
344
  //# sourceMappingURL=Settings.js.map
@@ -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, type GroupField, type Tab, type UploadField, deepMerge } from 'payload';\nimport { validatePostcode, validateURL } from '../util/validation.js';\nimport { countries } from './countries.js';\nimport { languages } from './locales.js';\n\n/**\n * Any additional overrides/tabs for the settings global.\n */\nexport type SettingsArgs = {\n\toverrides?: Partial<Omit<GlobalConfig, 'slug' | 'fields'>>;\n\tadditionalTabs?: Tab[];\n};\n\n/**\n * Settings Global Configuration\n * Additional tabs will be appended to the settings page.\n */\nexport const Settings = (args?: SettingsArgs): GlobalConfig => {\n\tconst defaultConfig = {\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' as const,\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...(args?.additionalTabs ?? []),\n\t\t\t\t] as Tab[],\n\t\t\t},\n\t\t],\n\t};\n\n\treturn deepMerge(defaultConfig, args?.overrides || {});\n};\n"],"names":["deepMerge","validatePostcode","validateURL","countries","languages","Settings","args","defaultConfig","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","additionalTabs","overrides"],"mappings":"AAAA,SAAyEA,SAAS,QAAQ,UAAU;AACpG,SAASC,gBAAgB,EAAEC,WAAW,QAAQ,wBAAwB;AACtE,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,SAAS,QAAQ,eAAe;AAUzC;;;CAGC,GACD,OAAO,MAAMC,WAAW,CAACC;IACxB,MAAMC,gBAAgB;QACrBC,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,SAASnB,UAAUoB,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,UAAUlC;gDACVmB,OAAO;oDACNC,OAAO;gDACR;4CACD;4CACA;gDACCT,MAAM;gDACNI,MAAM;gDACNE,OAAO;gDACPK,SAASpB,UAAUqB,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,UAAUjC;gDACVkB,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;gDACPiB,UAAUjC;gDACVkB,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;gDACPiB,UAAUjC;gDACVkB,OAAO;oDACNC,OAAO;gDACR;4CACD;4CACA;gDACCT,MAAM;gDACNI,MAAM;gDACNE,OAAO;gDACPiB,UAAUjC;gDACVkB,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;uBACIb,MAAM+B,kBAAkB,EAAE;iBAC9B;YACF;SACA;IACF;IAEA,OAAOrC,UAAUO,eAAeD,MAAMgC,aAAa,CAAC;AACrD,EAAE"}
@@ -111,7 +111,8 @@
111
111
  case 'row':
112
112
  case 'collapsible':
113
113
  {
114
- if (field.type === 'group' && field.name === 'meta') {
114
+ // @ts-ignore
115
+ if (field.type === 'group' && field?.name === 'meta') {
115
116
  field.typescriptSchema = [
116
117
  ()=>({
117
118
  ...addGoJSONSchema('payload.SettingsMeta', true)
@@ -129,7 +130,8 @@
129
130
  if (field.type !== 'tabs' && field.type !== 'row' && field.type !== 'collapsible') {
130
131
  field.typescriptSchema.push(({ jsonSchema })=>{
131
132
  const payload = {
132
- name: field.name,
133
+ // @ts-ignore
134
+ name: field?.name,
133
135
  type: field.type,
134
136
  label: field.label
135
137
  };
@@ -1 +1 @@
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\tconst isArray = field.hasMany; // Assuming `hasMany` indicates an array of uploads\n\t\t\t\t\tfield.typescriptSchema = [\n\t\t\t\t\t\t() => ({\n\t\t\t\t\t\t\t...(isArray\n\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\ttype: 'array',\n\t\t\t\t\t\t\t\t\t\titems: {\n\t\t\t\t\t\t\t\t\t\t\t...addGoJSONSchema(\n\t\t\t\t\t\t\t\t\t\t\t\t'payload.Media',\n\t\t\t\t\t\t\t\t\t\t\t\tfield.required === true,\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: { ...addGoJSONSchema('payload.Media', field.required === true) }),\n\t\t\t\t\t\t}),\n\t\t\t\t\t];\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'point':\n\t\t\t\tfield.typescriptSchema = [\n\t\t\t\t\t() => ({\n\t\t\t\t\t\t...addGoJSONSchema('payload.Point', 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\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 || field.custom?.webkitUseSchema)) {\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\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 = (\n\topts: SchemaOptions,\n): 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\n\t\t// I don't know why but Payload duplicates types and adds Select?\n\n\t\tfor (const key in jsonSchema.definitions) {\n\t\t\tif (key.endsWith('select') || key.endsWith('Select')) {\n\t\t\t\tdelete jsonSchema.definitions[key];\n\t\t\t}\n\t\t}\n\n\t\tfor (const key in jsonSchema.properties) {\n\t\t\tif (key.endsWith('select') || key.endsWith('Select')) {\n\t\t\t\tdelete jsonSchema.properties[key];\n\t\t\t}\n\t\t}\n\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","isArray","hasMany","items","required","tabs","tab","relationTo","name","assignRelationships","custom","webkitUseSchema","Array","push","payload","label","collections","collection","globals","global","index","schemas","media","auth","redirects","endsWith","settings","forms","updateRelationship","$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;QACNC,cAAc;YACbC,SAAS;gBAAC;aAAoD;YAC9DF,UAAUA;YACVD,MAAMA;QACP;IACD;AACD,EAAE;AAEF;;;;;;CAMC,GACD,OAAO,MAAMI,cAAc,CAACC,QAAyBC;IACpD,MA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BACrBhD,SAAS+C,IAAI,GAAG,CAAC,cAAc,EAAE/C,SAASgC,OAAO,CAACP,UAAU,EAAE;gBAC/D;gBAEA,MAAMwB,QAAQjB,QAAQ7B,IAAI;gBAC1B,IACC8C,UAAU,WACVA,UAAU,SACVA,UAAU,iBACVA,UAAU,SACT;oBACD,IAAIjD,SAASF,UAAU,EAAE;wBACxB,IAAK,MAAMoD,KAAKlD,SAASF,UAAU,CAAE;4BACpCgD,mBAAmB9C,SAASF,UAAU,CAACoD,EAAE;wBAC1C;oBACD;oBACA;gBACD;YACD;YAEA7D,yBAAyBC,YAAY,CAAC,EAAEU,QAAQ,EAAE;gBACjD8C,mBAAmB9C;YACpB;YACA,OAAOV;QACR;QACA;;;EAGC,GACD,CAAC,EAAEA,UAAU,EAAE;YACdD,yBAAyBC,YAAY,CAAC,EAAEU,QAAQ,EAAEC,GAAG,EAAE;gBACtD,IAAIA,QAAQ,aAAa;oBACxBD,SAASG,IAAI,GAAG;oBAChB,OAAOH,SAASmD,KAAK;gBACtB;YACD;YACA,OAAO7D;QACR;QACA;;;EAGC,GACD,CAAC,EAAEA,UAAU,EAAE;YACdD,yBAAyBC,YAAY,CAAC,EAAEU,QAAQ,EAAEC,GAAG,EAAE;gBACtD,MAAM+B,UAAUhC,SAASgC,OAAO;gBAChC,IAAIA,WAAWA,QAAQ7B,IAAI,KAAK,kBAAkB6B,QAAQN,IAAI,KAAK,QAAQ;oBAC1E,OAAO1B,SAAS+C,IAAI;gBACrB;YACD;YACA,OAAOzD;QACR;KACA,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\tconst isArray = field.hasMany; // Assuming `hasMany` indicates an array of uploads\n\t\t\t\t\tfield.typescriptSchema = [\n\t\t\t\t\t\t() => ({\n\t\t\t\t\t\t\t...(isArray\n\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\ttype: 'array',\n\t\t\t\t\t\t\t\t\t\titems: {\n\t\t\t\t\t\t\t\t\t\t\t...addGoJSONSchema(\n\t\t\t\t\t\t\t\t\t\t\t\t'payload.Media',\n\t\t\t\t\t\t\t\t\t\t\t\tfield.required === true,\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: { ...addGoJSONSchema('payload.Media', field.required === true) }),\n\t\t\t\t\t\t}),\n\t\t\t\t\t];\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'point':\n\t\t\t\tfield.typescriptSchema = [\n\t\t\t\t\t() => ({\n\t\t\t\t\t\t...addGoJSONSchema('payload.Point', 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\n\t\t\tcase 'group':\n\t\t\tcase 'array':\n\t\t\tcase 'row':\n\t\t\tcase 'collapsible': {\n\t\t\t\t// @ts-ignore\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 || field.custom?.webkitUseSchema)) {\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\t// @ts-ignore\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\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 = (\n\topts: SchemaOptions,\n): 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\n\t\t// I don't know why but Payload duplicates types and adds Select?\n\n\t\tfor (const key in jsonSchema.definitions) {\n\t\t\tif (key.endsWith('select') || key.endsWith('Select')) {\n\t\t\t\tdelete jsonSchema.definitions[key];\n\t\t\t}\n\t\t}\n\n\t\tfor (const key in jsonSchema.properties) {\n\t\t\tif (key.endsWith('select') || key.endsWith('Select')) {\n\t\t\t\tdelete jsonSchema.properties[key];\n\t\t\t}\n\t\t}\n\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","isArray","hasMany","items","required","tabs","tab","relationTo","name","assignRelationships","custom","webkitUseSchema","Array","push","payload","label","collections","collection","globals","global","index","schemas","media","auth","redirects","endsWith","settings","forms","updateRelationship","$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;QACNC,cAAc;YACbC,SAAS;gBAAC;aAAoD;YAC9DF,UAAUA;YACVD,MAAMA;QACP;IACD;AACD,EAAE;AAEF;;;;;;CAMC,GACD,OAAO,MAAMI,cAAc,CAACC,QAAyBC;IACpD,MAAMC,SAAS,CAACC;QACf,OAAQA,MAAMR,IAAI;YACjB,KAAK;gBACJQ,MAAMC,gBAAgB,GAAG;oBAAC,IAAO,CAAA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AEA,MAAMwB,QAAQjB,QAAQ7B,IAAI;gBAC1B,IACC8C,UAAU,WACVA,UAAU,SACVA,UAAU,iBACVA,UAAU,SACT;oBACD,IAAIjD,SAASF,UAAU,EAAE;wBACxB,IAAK,MAAMoD,KAAKlD,SAASF,UAAU,CAAE;4BACpCgD,mBAAmB9C,SAASF,UAAU,CAACoD,EAAE;wBAC1C;oBACD;oBACA;gBACD;YACD;YAEA7D,yBAAyBC,YAAY,CAAC,EAAEU,QAAQ,EAAE;gBACjD8C,mBAAmB9C;YACpB;YACA,OAAOV;QACR;QACA;;;EAGC,GACD,CAAC,EAAEA,UAAU,EAAE;YACdD,yBAAyBC,YAAY,CAAC,EAAEU,QAAQ,EAAEC,GAAG,EAAE;gBACtD,IAAIA,QAAQ,aAAa;oBACxBD,SAASG,IAAI,GAAG;oBAChB,OAAOH,SAASmD,KAAK;gBACtB;YACD;YACA,OAAO7D;QACR;QACA;;;EAGC,GACD,CAAC,EAAEA,UAAU,EAAE;YACdD,yBAAyBC,YAAY,CAAC,EAAEU,QAAQ,EAAEC,GAAG,EAAE;gBACtD,MAAM+B,UAAUhC,SAASgC,OAAO;gBAChC,IAAIA,WAAWA,QAAQ7B,IAAI,KAAK,kBAAkB6B,QAAQN,IAAI,KAAK,QAAQ;oBAC1E,OAAO1B,SAAS+C,IAAI;gBACrB;YACD;YACA,OAAOzD;QACR;KACA,CAAC"}
package/dist/seed/seed.js CHANGED
@@ -1,8 +1,8 @@
1
- import { commitTransaction, getPayload, initTransaction, killTransaction } from 'payload';
2
- import env from '../util/env.js';
3
- import path from 'node:path';
4
1
  import fs from 'node:fs';
2
+ import path from 'node:path';
5
3
  import { fileURLToPath } from 'node:url';
4
+ import { commitTransaction, getPayload, initTransaction, killTransaction } from 'payload';
5
+ import env from '../util/env.js';
6
6
  const filename = fileURLToPath(import.meta.url);
7
7
  const dirname = path.dirname(filename);
8
8
  /**
@@ -1 +1 @@
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,UAAU;AACzB,SAASC,aAAa,QAAQ,WAAW;AAEzC,MAAMC,WAAWD,cAAc,YAAYE,GAAG;AAC9C,MAAMC,UAAUL,KAAKK,OAAO,CAACF;AAgB7B;;;;;CAKC,GACD,OAAO,MAAMG,OAAO,CAACC;IAIpB,MAAMC,KAAK;QACVC,QAAQV,GAAG,CAACW,qBAAqB,GAAG;QAEpC,MAAMC,UAAU,MAAMf,WAAW;YAChCgB,QAAQL,KAAKK,MAAM;QACpB;QACA,MAAMC,MAAM;YAAEF;QAAQ;QAEtB,MAAMd,gBAAgBgB;QAEtB,OAAOJ,QAAQV,GAAG,CAACW,qBAAqB;QAExC,IAAI;YACH,sBAAsB;YACtBC,QAAQG,MAAM,CAACC,IAAI,CAAC;YACpB,IAAI;gBACH,IAAIJ,QAAQK,EAAE,CAACC,IAAI,EAAE;oBACpB,MAAMN,QAAQK,EAAE,CAACC,IAAI;gBACtB;YACD,EAAE,OAAOC,OAAO;gBACfP,QAAQG,MAAM,CAACI,KAAK,CAAC,CAAC,mBAAmB,EAAEA,OAAO;gBAClD;YACD;YAEAP,QAAQG,MAAM,CAACC,IAAI,CAAC;YACpB,MAAMJ,QAAQK,EAAE,CAACG,OAAO;YAExB,uBAAuB;YACvB,IAAI,CAACpB,IAAIqB,YAAY,EAAE;gBACtBT,QAAQG,MAAM,CAACC,IAAI,CAAC;gBACpB,MAAMM,WAAWrB,KAAKsB,OAAO,CAACjB,SAAS;gBACvC,IAAIJ,GAAGsB,UAAU,CAACF,WAAW;oBAC5BpB,GAAGuB,MAAM,CAACH,UAAU;wBAAEI,WAAW;wBAAMC,OAAO;oBAAK;gBACpD;YACD;YAEA,+BAA+B;YAC/B,MAAMnB,KAAKoB,MAAM,CAAC;gBAAEhB;gBAASE;YAAI;YAEjC,MAAMlB,kBAAkBkB;YAExBF,QAAQG,MAAM,CAACC,IAAI,CAAC;QACrB,EAAE,OAAOa,KAAK;YACb,MAAMC,UAAUD,eAAeE,QAAQF,IAAIC,OAAO,GAAG;YACrDlB,QAAQG,MAAM,CAACI,KAAK,CAAC,CAAC,aAAa,EAAEW,SAAS;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"}
1
+ {"version":3,"sources":["../../src/seed/seed.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport {\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';\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":["fs","path","fileURLToPath","commitTransaction","getPayload","initTransaction","killTransaction","env","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,OAAOA,QAAQ,UAAU;AACzB,OAAOC,UAAU,YAAY;AAC7B,SAASC,aAAa,QAAQ,WAAW;AACzC,SAICC,iBAAiB,EACjBC,UAAU,EACVC,eAAe,EACfC,eAAe,QACT,UAAU;AACjB,OAAOC,SAAS,iBAAiB;AAEjC,MAAMC,WAAWN,cAAc,YAAYO,GAAG;AAC9C,MAAMC,UAAUT,KAAKS,OAAO,CAACF;AAgB7B;;;;;CAKC,GACD,OAAO,MAAMG,OAAO,CAACC;IAIpB,MAAMC,KAAK;QACVC,QAAQP,GAAG,CAACQ,qBAAqB,GAAG;QAEpC,MAAMC,UAAU,MAAMZ,WAAW;YAChCa,QAAQL,KAAKK,MAAM;QACpB;QACA,MAAMC,MAAM;YAAEF;QAAQ;QAEtB,MAAMX,gBAAgBa;QAEtB,OAAOJ,QAAQP,GAAG,CAACQ,qBAAqB;QAExC,IAAI;YACH,sBAAsB;YACtBC,QAAQG,MAAM,CAACC,IAAI,CAAC;YACpB,IAAI;gBACH,IAAIJ,QAAQK,EAAE,CAACC,IAAI,EAAE;oBACpB,MAAMN,QAAQK,EAAE,CAACC,IAAI;gBACtB;YACD,EAAE,OAAOC,OAAO;gBACfP,QAAQG,MAAM,CAACI,KAAK,CAAC,CAAC,mBAAmB,EAAEA,OAAO;gBAClD;YACD;YAEAP,QAAQG,MAAM,CAACC,IAAI,CAAC;YACpB,MAAMJ,QAAQK,EAAE,CAACG,OAAO;YAExB,uBAAuB;YACvB,IAAI,CAACjB,IAAIkB,YAAY,EAAE;gBACtBT,QAAQG,MAAM,CAACC,IAAI,CAAC;gBACpB,MAAMM,WAAWzB,KAAK0B,OAAO,CAACjB,SAAS;gBACvC,IAAIV,GAAG4B,UAAU,CAACF,WAAW;oBAC5B1B,GAAG6B,MAAM,CAACH,UAAU;wBAAEI,WAAW;wBAAMC,OAAO;oBAAK;gBACpD;YACD;YAEA,+BAA+B;YAC/B,MAAMnB,KAAKoB,MAAM,CAAC;gBAAEhB;gBAASE;YAAI;YAEjC,MAAMf,kBAAkBe;YAExBF,QAAQG,MAAM,CAACC,IAAI,CAAC;QACrB,EAAE,OAAOa,KAAK;YACb,MAAMC,UAAUD,eAAeE,QAAQF,IAAIC,OAAO,GAAG;YACrDlB,QAAQG,MAAM,CAACI,KAAK,CAAC,CAAC,aAAa,EAAEW,SAAS;YAC9C,MAAM5B,gBAAgBY;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/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, 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"}
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["// import type { SEOPluginConfig } from \"@payloadcms/plugin-seo/types\";\nimport type { GlobalConfig, Tab, TextField, TextareaField, UploadField } from 'payload';\n// import type {SEOPluginConfig} from \"@payloadcms/plugin-seo/dist/types.js\";\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;AAiBvE,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.31",
3
+ "version": "0.0.33",
4
4
  "description": "Payload CMS utilities, collections and global types for ainsley.dev builds",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -32,11 +32,11 @@
32
32
  },
33
33
  "files": ["dist", "bin.js", "types.js", "types.ts", "types.d.ts"],
34
34
  "dependencies": {
35
- "payload": "3.35.1",
36
- "@payloadcms/db-sqlite": "3.35.1",
37
- "@payloadcms/richtext-lexical": "3.35.1",
38
- "@payloadcms/plugin-form-builder": "3.35.1",
39
- "@payloadcms/plugin-seo": "3.35.1",
35
+ "payload": "3.56.0",
36
+ "@payloadcms/db-sqlite": "3.56.0",
37
+ "@payloadcms/richtext-lexical": "3.56.0",
38
+ "@payloadcms/plugin-form-builder": "3.56.0",
39
+ "@payloadcms/plugin-seo": "3.56.0",
40
40
  "@lexical/headless": "0.28.0",
41
41
  "@lexical/html": "0.28.0",
42
42
  "@nouance/payload-better-fields-plugin": "^1.4.1",