@ainsleydev/payload-helper 0.0.7 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/bin.js +1 -1
- package/dist/cli/bin.js.map +1 -1
- package/dist/common/SEO.d.ts +1 -1
- package/dist/common/SEO.js.map +1 -1
- package/dist/endpoints/slug.d.ts +1 -1
- package/dist/endpoints/slug.js +3 -4
- package/dist/endpoints/slug.js.map +1 -1
- package/dist/globals/Navigation.d.ts +1 -1
- package/dist/globals/Navigation.js.map +1 -1
- package/dist/globals/Settings.js +1 -1
- package/dist/globals/Settings.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/seed/down.js.map +1 -1
- package/dist/seed/seed.d.ts +1 -1
- package/dist/seed/seed.js.map +1 -1
- package/dist/seed/up.d.ts +1 -1
- package/dist/seed/up.js.map +1 -1
- package/dist/util/env.js +4 -4
- package/dist/util/env.js.map +1 -1
- package/dist/util/fields.d.ts +1 -1
- package/dist/util/fields.js.map +1 -1
- package/dist/util/lexical.js +51 -23
- package/dist/util/lexical.js.map +1 -1
- package/package.json +2 -2
package/dist/cli/bin.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import chalk from 'chalk';
|
|
2
3
|
import { Command } from 'commander';
|
|
3
4
|
import { generateTypes } from './types.js';
|
|
4
|
-
import chalk from 'chalk';
|
|
5
5
|
const program = new Command();
|
|
6
6
|
program.command('generate-types').description('Generate JSON schema types for Payload CMS').action(async ()=>{
|
|
7
7
|
try {
|
package/dist/cli/bin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cli/bin.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { Command } from 'commander';\nimport { generateTypes } from './types.js';\
|
|
1
|
+
{"version":3,"sources":["../../src/cli/bin.ts"],"sourcesContent":["#!/usr/bin/env node\nimport chalk from 'chalk';\nimport { Command } from 'commander';\nimport { generateTypes } from './types.js';\n\nconst program = new Command();\n\nprogram\n\t.command('generate-types')\n\t.description('Generate JSON schema types for Payload CMS')\n\t.action(async () => {\n\t\ttry {\n\t\t\tawait generateTypes('');\n\t\t} catch (error) {\n\t\t\tconsole.log(chalk.red(error));\n\t\t}\n\t});\n\nexport const bin = async () => {\n\tawait program.parseAsync(process.argv);\n};\n"],"names":["chalk","Command","generateTypes","program","command","description","action","error","console","log","red","bin","parseAsync","process","argv"],"mappings":";AACA,OAAOA,WAAW,QAAQ;AAC1B,SAASC,OAAO,QAAQ,YAAY;AACpC,SAASC,aAAa,QAAQ,aAAa;AAE3C,MAAMC,UAAU,IAAIF;AAEpBE,QACEC,OAAO,CAAC,kBACRC,WAAW,CAAC,8CACZC,MAAM,CAAC;IACP,IAAI;QACH,MAAMJ,cAAc;IACrB,EAAE,OAAOK,OAAO;QACfC,QAAQC,GAAG,CAACT,MAAMU,GAAG,CAACH;IACvB;AACD;AAED,OAAO,MAAMI,MAAM;IAClB,MAAMR,QAAQS,UAAU,CAACC,QAAQC,IAAI;AACtC,EAAE"}
|
package/dist/common/SEO.d.ts
CHANGED
package/dist/common/SEO.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/common/SEO.ts"],"sourcesContent":["import { Field } from 'payload';\n// @ts-ignore\nimport { validateURL } from '../util/validation';\n\n/**\n * SEO Fields define the additional fields that appear\n * within the Payload SEO plugin.\n */\nexport const SEOFields: Field[] = [\n\t{\n\t\ttype: 'row',\n\t\tfields: [\n\t\t\t{\n\t\t\t\tname: 'private',\n\t\t\t\ttype: 'checkbox',\n\t\t\t\tlabel: 'Private',\n\t\t\t\tdefaultValue: false,\n\t\t\t\tadmin: {\n\t\t\t\t\twidth: '50%',\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t'Enable private mode to prevent robots from crawling the page or website. When enabled it will output <meta name=\"robots\" content=\"noindex\" /> on the frontend.',\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'canonicalURL',\n\t\t\t\ttype: 'text',\n\t\t\t\tlabel: 'Canonical',\n\t\t\t\tadmin: {\n\t\t\t\t\twidth: '50%',\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t'A canonical URL is the version of a webpage chosen by search engines like Google as the main version when there are duplicates.',\n\t\t\t\t},\n\t\t\t\tvalidate: validateURL,\n\t\t\t},\n\t\t],\n\t},\n\t{\n\t\tname: 'structuredData',\n\t\ttype: 'json',\n\t\tlabel: 'Structured Data',\n\t\t// typescriptSchema: [\n\t\t// \t() => ({...addGoJSONSchema('[]byte', false)}),\n\t\t// ],\n\t\tadmin: {\n\t\t\tdescription:\n\t\t\t\t'Structured data is a standardized format for providing information about a page and classifying the page content. The site Schema.org contains a standardised list of markup that the major search engines — Google, Bing, Yahoo and Yandex — have collectively agreed to support.',\n\t\t},\n\t},\n];\n"],"names":["validateURL","SEOFields","type","fields","name","label","defaultValue","admin","width","description","validate"],"mappings":"AACA,aAAa;AACb,SAASA,WAAW,QAAQ,qBAAqB;AAEjD;;;CAGC,GACD,OAAO,MAAMC,YAAqB;IACjC;QACCC,MAAM;QACNC,QAAQ;YACP;gBACCC,MAAM;gBACNF,MAAM;gBACNG,OAAO;gBACPC,cAAc;gBACdC,OAAO;oBACNC,OAAO;oBACPC,aACC;gBACF;YACD;YACA;gBACCL,MAAM;gBACNF,MAAM;gBACNG,OAAO;gBACPE,OAAO;oBACNC,OAAO;oBACPC,aACC;gBACF;gBACAC,UAAUV;YACX;SACA;IACF;IACA;QACCI,MAAM;QACNF,MAAM;QACNG,OAAO;QACP,sBAAsB;QACtB,kDAAkD;QAClD,KAAK;QACLE,OAAO;YACNE,aACC;QACF;IACD;CACA,CAAC"}
|
|
1
|
+
{"version":3,"sources":["../../src/common/SEO.ts"],"sourcesContent":["import type { Field } from 'payload';\n// @ts-ignore\nimport { validateURL } from '../util/validation';\n\n/**\n * SEO Fields define the additional fields that appear\n * within the Payload SEO plugin.\n */\nexport const SEOFields: Field[] = [\n\t{\n\t\ttype: 'row',\n\t\tfields: [\n\t\t\t{\n\t\t\t\tname: 'private',\n\t\t\t\ttype: 'checkbox',\n\t\t\t\tlabel: 'Private',\n\t\t\t\tdefaultValue: false,\n\t\t\t\tadmin: {\n\t\t\t\t\twidth: '50%',\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t'Enable private mode to prevent robots from crawling the page or website. When enabled it will output <meta name=\"robots\" content=\"noindex\" /> on the frontend.',\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'canonicalURL',\n\t\t\t\ttype: 'text',\n\t\t\t\tlabel: 'Canonical',\n\t\t\t\tadmin: {\n\t\t\t\t\twidth: '50%',\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t'A canonical URL is the version of a webpage chosen by search engines like Google as the main version when there are duplicates.',\n\t\t\t\t},\n\t\t\t\tvalidate: validateURL,\n\t\t\t},\n\t\t],\n\t},\n\t{\n\t\tname: 'structuredData',\n\t\ttype: 'json',\n\t\tlabel: 'Structured Data',\n\t\t// typescriptSchema: [\n\t\t// \t() => ({...addGoJSONSchema('[]byte', false)}),\n\t\t// ],\n\t\tadmin: {\n\t\t\tdescription:\n\t\t\t\t'Structured data is a standardized format for providing information about a page and classifying the page content. The site Schema.org contains a standardised list of markup that the major search engines — Google, Bing, Yahoo and Yandex — have collectively agreed to support.',\n\t\t},\n\t},\n];\n"],"names":["validateURL","SEOFields","type","fields","name","label","defaultValue","admin","width","description","validate"],"mappings":"AACA,aAAa;AACb,SAASA,WAAW,QAAQ,qBAAqB;AAEjD;;;CAGC,GACD,OAAO,MAAMC,YAAqB;IACjC;QACCC,MAAM;QACNC,QAAQ;YACP;gBACCC,MAAM;gBACNF,MAAM;gBACNG,OAAO;gBACPC,cAAc;gBACdC,OAAO;oBACNC,OAAO;oBACPC,aACC;gBACF;YACD;YACA;gBACCL,MAAM;gBACNF,MAAM;gBACNG,OAAO;gBACPE,OAAO;oBACNC,OAAO;oBACPC,aACC;gBACF;gBACAC,UAAUV;YACX;SACA;IACF;IACA;QACCI,MAAM;QACNF,MAAM;QACNG,OAAO;QACP,sBAAsB;QACtB,kDAAkD;QAClD,KAAK;QACLE,OAAO;YACNE,aACC;QACF;IACD;CACA,CAAC"}
|
package/dist/endpoints/slug.d.ts
CHANGED
package/dist/endpoints/slug.js
CHANGED
|
@@ -20,11 +20,10 @@
|
|
|
20
20
|
}), {
|
|
21
21
|
status: 404
|
|
22
22
|
});
|
|
23
|
-
} else {
|
|
24
|
-
return new Response(JSON.stringify(data.docs[0]), {
|
|
25
|
-
status: 200
|
|
26
|
-
});
|
|
27
23
|
}
|
|
24
|
+
return new Response(JSON.stringify(data.docs[0]), {
|
|
25
|
+
status: 200
|
|
26
|
+
});
|
|
28
27
|
} catch (error) {
|
|
29
28
|
console.error('Error occurred while fetching document:', error);
|
|
30
29
|
return new Response(JSON.stringify({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/endpoints/slug.ts"],"sourcesContent":["import { PayloadHandler, PayloadRequest } from 'payload';\n\n/**\n * Find a document in the given collection by its slug.\n *\n * @param collection\n */\nexport const findBySlug = (collection: string): PayloadHandler => {\n\treturn async (req: PayloadRequest): Promise<Response> => {\n\t\ttry {\n\t\t\tconst data = await req.payload.find({\n\t\t\t\tcollection,\n\t\t\t\twhere: {\n\t\t\t\t\tslug: {\n\t\t\t\t\t\tequals: req?.routeParams?.slug ?? '',\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tlimit: 1,\n\t\t\t});\n\t\t\tif (data.docs.length === 0) {\n\t\t\t\treturn new Response(JSON.stringify({ error: 'not found' }), { status: 404 });\n\t\t\t}
|
|
1
|
+
{"version":3,"sources":["../../src/endpoints/slug.ts"],"sourcesContent":["import type { PayloadHandler, PayloadRequest } from 'payload';\n\n/**\n * Find a document in the given collection by its slug.\n *\n * @param collection\n */\nexport const findBySlug = (collection: string): PayloadHandler => {\n\treturn async (req: PayloadRequest): Promise<Response> => {\n\t\ttry {\n\t\t\tconst data = await req.payload.find({\n\t\t\t\tcollection,\n\t\t\t\twhere: {\n\t\t\t\t\tslug: {\n\t\t\t\t\t\tequals: req?.routeParams?.slug ?? '',\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tlimit: 1,\n\t\t\t});\n\t\t\tif (data.docs.length === 0) {\n\t\t\t\treturn new Response(JSON.stringify({ error: 'not found' }), { status: 404 });\n\t\t\t}\n\t\t\treturn new Response(JSON.stringify(data.docs[0]), { status: 200 });\n\t\t} catch (error) {\n\t\t\tconsole.error('Error occurred while fetching document:', error);\n\t\t\treturn new Response(JSON.stringify({ error: 'Internal server error' }), {\n\t\t\t\tstatus: 500,\n\t\t\t});\n\t\t}\n\t};\n};\n"],"names":["findBySlug","collection","req","data","payload","find","where","slug","equals","routeParams","limit","docs","length","Response","JSON","stringify","error","status","console"],"mappings":"AAEA;;;;CAIC,GACD,OAAO,MAAMA,aAAa,CAACC;IAC1B,OAAO,OAAOC;QACb,IAAI;YACH,MAAMC,OAAO,MAAMD,IAAIE,OAAO,CAACC,IAAI,CAAC;gBACnCJ;gBACAK,OAAO;oBACNC,MAAM;wBACLC,QAAQN,KAAKO,aAAaF,QAAQ;oBACnC;gBACD;gBACAG,OAAO;YACR;YACA,IAAIP,KAAKQ,IAAI,CAACC,MAAM,KAAK,GAAG;gBAC3B,OAAO,IAAIC,SAASC,KAAKC,SAAS,CAAC;oBAAEC,OAAO;gBAAY,IAAI;oBAAEC,QAAQ;gBAAI;YAC3E;YACA,OAAO,IAAIJ,SAASC,KAAKC,SAAS,CAACZ,KAAKQ,IAAI,CAAC,EAAE,GAAG;gBAAEM,QAAQ;YAAI;QACjE,EAAE,OAAOD,OAAO;YACfE,QAAQF,KAAK,CAAC,2CAA2CA;YACzD,OAAO,IAAIH,SAASC,KAAKC,SAAS,CAAC;gBAAEC,OAAO;YAAwB,IAAI;gBACvEC,QAAQ;YACT;QACD;IACD;AACD,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/globals/Navigation.ts"],"sourcesContent":["import type {
|
|
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;QACtB,OAAO,EAAE;IACV;IAEA,wDAAwD;IACxD,IAAID,QAAQC,WAAW,GAAG;QACzB,OAAO;YACN;gBACCE,MAAM;gBACNC,MAAM;gBACNC,OAAO,CAAC,eAAe,EAAEL,QAAQ,EAAE,CAAC;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;gBACNC,MAAM;gBACNC,OAAO;gBACPE,UAAU;gBACVC,OAAO;oBACNC,OAAO;gBACR;YACD;YACA;gBACCN,MAAM;gBACNC,MAAM;gBACNC,OAAO;gBACPE,UAAU;gBACVC,OAAO;oBACNC,OAAO;gBACR;YACD;SACA;IACF;CACA;AAED;;;;;;CAMC,GACD,OAAO,MAAMC,aAAa,CAACC;IAC1B,MAAMC,OAAc;QACnB;YACCP,OAAO;YACPH,QAAQ;gBACP;oBACCC,MAAM;oBACNC,MAAM;oBACNC,OAAO;oBACPQ,eAAe;oBACfC,SAAS;oBACTC,QAAQ;wBACPC,UAAU;wBACVC,QAAQ;oBACT;oBACAT,OAAO;wBACNU,eAAe;wBACfC,YAAY;oBACb;oBACAjB,QAAQ;2BACJI;2BACCK,QAAQS,QAAQnB,WACjBF,iBAAiB,GAAGY,OAAOS,MAAM,CAACnB,QAAQ,EAAEK,aAC5C,EAAE;2BACDK,QAAQS,QAAQC,mBAAmBV,OAAOS,MAAM,CAACC,gBAAgB,GAAG,EAAE;qBAC1E;gBACF;aACA;QACF;KACA;IAED,IAAIV,QAAQW,eAAe;QAC1BV,KAAKW,IAAI,CAAC;YACTlB,OAAO;YACPH,QAAQ;gBACP;oBACCC,MAAM;oBACNC,MAAM;oBACNC,OAAO;oBACPQ,eAAe;oBACfC,SAAS;oBACTC,QAAQ;wBACPC,UAAU;wBACVC,QAAQ;oBACT;oBACAT,OAAO;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"}
|
package/dist/globals/Settings.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { validatePostcode, validateURL } from '../util/validation.js';
|
|
2
|
-
import { languages } from './locales.js';
|
|
3
2
|
import { countries } from './countries.js';
|
|
3
|
+
import { languages } from './locales.js';
|
|
4
4
|
/**
|
|
5
5
|
* Settings Global Configuration
|
|
6
6
|
* Additional tabs will be appended to the settings page.
|
|
@@ -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 { languages } from './locales.js';\nimport { countries } from './countries.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","languages","countries","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,eAAe;AACzC,SAASC,SAAS,QAAQ,iBAAiB;AAE3C;;;;;;;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,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,UAAUjC;gDACVkB,OAAO;oDACNC,OAAO;gDACR;4CACD;4CACA;gDACCT,MAAM;gDACNI,MAAM;gDACNE,OAAO;gDACPK,SAASlB,UAAUmB,GAAG,CAAC,CAACY;oDACvB,OAAO;wDACNlB,OAAOkB;wDACPV,OAAOU;oDACR;gDACD;gDACAhB,OAAO;oDACNC,OAAO;gDACR;4CACD;yCACA;oCACF;iCACA;4BACF;4BACA;gCACCL,MAAM;gCACNJ,MAAM;gCACNM,OAAO;gCACPE,OAAO;oCACNc,YAAY;oCACZf,aAAa;gCACd;gCACAJ,QAAQ;oCACP;wCACCC,MAAM;wCACND,QAAQ;4CACP;gDACCH,MAAM;gDACNI,MAAM;gDACNE,OAAO;gDACPiB,UAAUhC;gDACViB,OAAO;oDACNC,OAAO;gDACR;4CACD;4CACA;gDACCT,MAAM;gDACNI,MAAM;gDACNE,OAAO;gDACPiB,UAAUhC;gDACViB,OAAO;oDACNC,OAAO;gDACR;4CACD;4CACA;gDACCT,MAAM;gDACNI,MAAM;gDACNE,OAAO;gDACPiB,UAAUhC;gDACViB,OAAO;oDACNC,OAAO;gDACR;4CACD;4CACA;gDACCT,MAAM;gDACNI,MAAM;gDACNE,OAAO;gDACPiB,UAAUhC;gDACViB,OAAO;oDACNC,OAAO;gDACR;4CACD;4CACA;gDACCT,MAAM;gDACNI,MAAM;gDACNE,OAAO;gDACPiB,UAAUhC;gDACViB,OAAO;oDACNC,OAAO;gDACR;4CACD;4CACA;gDACCT,MAAM;gDACNI,MAAM;gDACNE,OAAO;gDACPiB,UAAUhC;gDACViB,OAAO;oDACNC,OAAO;gDACR;4CACD;yCACA;oCACF;iCACA;4BACF;yBACA;oBACF;oBACA;wBACCH,OAAO;wBACPH,QAAQ;4BACP;gCACCH,MAAM;gCACNI,MAAM;gCACND,QAAQ;oCACP;wCACCH,MAAM;wCACNI,MAAM;wCACNE,OAAO;wCACPE,OAAO;4CACND,aACC;wCACF;oCACD;oCACA;wCACCP,MAAM;wCACNI,MAAM;wCACNE,OAAO;wCACPE,OAAO;4CACND,aAAa;wCACd;oCACD;oCACA;wCACCP,MAAM;wCACNI,MAAM;wCACNE,OAAO;wCACPE,OAAO;4CACND,aACC;wCACF;oCACD;iCACA;4BACF;yBACA;oBACF;uBACIZ,iBAAiBA,iBAAiB,EAAE;iBACxC;YACF;SACA;IACF;AACD,EAAE"}
|
|
1
|
+
{"version":3,"sources":["../../src/globals/Settings.ts"],"sourcesContent":["import type { GlobalConfig, GroupField, Tab, UploadField } from 'payload';\nimport { validatePostcode, validateURL } from '../util/validation.js';\nimport { countries } from './countries.js';\nimport { languages } from './locales.js';\n\n/**\n * Settings Global Configuration\n * Additional tabs will be appended to the settings page.\n * TODO, type error in here somewhere.\n *\n * @param additionalTabs\n * @constructor\n */\nexport const Settings = (additionalTabs: Tab[]): GlobalConfig => {\n\treturn {\n\t\tslug: 'settings',\n\t\ttypescript: {\n\t\t\tinterface: 'Settings',\n\t\t},\n\t\tgraphQL: {\n\t\t\tname: 'Settings',\n\t\t},\n\t\taccess: {\n\t\t\tread: () => true,\n\t\t},\n\t\tfields: [\n\t\t\t{\n\t\t\t\ttype: 'tabs',\n\t\t\t\ttabs: [\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: 'Global',\n\t\t\t\t\t\tdescription: 'Configure global settings for the website.',\n\t\t\t\t\t\tfields: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: 'row',\n\t\t\t\t\t\t\t\tfields: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tname: 'siteName',\n\t\t\t\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\t\t\t\tlabel: 'Site Name',\n\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t\t\t\t'Add a site name for the website, this will be outputted in the Open Graph schema as well as a suffix for the meta title.',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tname: 'locale',\n\t\t\t\t\t\t\t\t\t\ttype: 'select',\n\t\t\t\t\t\t\t\t\t\tlabel: 'Locale',\n\t\t\t\t\t\t\t\t\t\tdefaultValue: 'en_GB',\n\t\t\t\t\t\t\t\t\t\toptions: languages.map((l) => {\n\t\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: l.name,\n\t\t\t\t\t\t\t\t\t\t\t\tvalue: l.code,\n\t\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t\t\t\t'Add a locale for the website, this will be outputted in the Open Graph schema and the top level HTML tag. Defaults to en_GB.',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\ttypescriptSchema: [\n\t\t\t\t\t\t\t\t\t\t\t() => ({\n\t\t\t\t\t\t\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: 'tagLine',\n\t\t\t\t\t\t\t\ttype: 'textarea',\n\t\t\t\t\t\t\t\tlabel: 'Tag Line',\n\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\tdescription: 'In a few words, explain what this site is about',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: 'logo',\n\t\t\t\t\t\t\t\ttype: 'upload',\n\t\t\t\t\t\t\t\trelationTo: 'media',\n\t\t\t\t\t\t\t\tfilterOptions: {\n\t\t\t\t\t\t\t\t\tmimeType: {\n\t\t\t\t\t\t\t\t\t\tcontains: 'image',\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t\t'Add a logo for the website that will be displayed in the header & across the website.',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t} as UploadField,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: 'robots',\n\t\t\t\t\t\t\t\ttype: 'textarea',\n\t\t\t\t\t\t\t\tlabel: 'Robots.txt',\n\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t\t'Robots.txt is a text file webmasters create to instruct web robots (typically search engine robots) how to crawl pages on their website.',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: 'Code Injection',\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'Code injection allows you to inject a small snippet of HTML into your site. It can be a css override, analytics of a block javascript.',\n\t\t\t\t\t\tfields: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: 'codeInjection',\n\t\t\t\t\t\t\t\ttype: 'group',\n\t\t\t\t\t\t\t\tfields: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tname: 'head',\n\t\t\t\t\t\t\t\t\t\ttype: 'code',\n\t\t\t\t\t\t\t\t\t\tlabel: 'Head',\n\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\tlanguage: 'html',\n\t\t\t\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t\t\t\t'Outputs code within the <head> of the website.',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tname: 'footer',\n\t\t\t\t\t\t\t\t\t\ttype: 'code',\n\t\t\t\t\t\t\t\t\t\tlabel: 'Footer',\n\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\tlanguage: 'html',\n\t\t\t\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t\t\t\t'Outputs code in the footer of the website.',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: 'Contact Details',\n\t\t\t\t\t\tfields: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: 'contact',\n\t\t\t\t\t\t\t\ttype: 'group',\n\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\thideGutter: true,\n\t\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t\t'Add global contact details for the website that will be used in schema & contact pages.',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tfields: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttype: 'row',\n\t\t\t\t\t\t\t\t\t\tfields: [\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tname: 'email',\n\t\t\t\t\t\t\t\t\t\t\t\ttype: 'email',\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: 'Email',\n\t\t\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tname: 'telephone',\n\t\t\t\t\t\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: 'Telephone',\n\t\t\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t} as GroupField,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: 'group',\n\t\t\t\t\t\t\t\tname: 'address',\n\t\t\t\t\t\t\t\tlabel: 'Address',\n\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\thideGutter: true,\n\t\t\t\t\t\t\t\t\tdescription: 'Add an address for the website.',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tfields: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttype: 'row',\n\t\t\t\t\t\t\t\t\t\tfields: [\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tname: 'line1',\n\t\t\t\t\t\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: 'Line 1',\n\t\t\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tname: 'line2',\n\t\t\t\t\t\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: 'Line 2',\n\t\t\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tname: 'city',\n\t\t\t\t\t\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: 'City',\n\t\t\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tname: 'county',\n\t\t\t\t\t\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: 'County',\n\t\t\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tname: 'postcode',\n\t\t\t\t\t\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: 'Postcode',\n\t\t\t\t\t\t\t\t\t\t\t\tvalidate: validatePostcode,\n\t\t\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tname: 'country',\n\t\t\t\t\t\t\t\t\t\t\t\ttype: 'select',\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: 'Country',\n\t\t\t\t\t\t\t\t\t\t\t\toptions: countries.map((c) => {\n\t\t\t\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tlabel: c,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tvalue: c,\n\t\t\t\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t} as GroupField,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: 'group',\n\t\t\t\t\t\t\t\tname: 'social',\n\t\t\t\t\t\t\t\tlabel: 'Social Links',\n\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\thideGutter: true,\n\t\t\t\t\t\t\t\t\tdescription: 'Add social links for the website.',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tfields: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttype: 'row',\n\t\t\t\t\t\t\t\t\t\tfields: [\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tname: 'linkedIn',\n\t\t\t\t\t\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: 'LinkedIn',\n\t\t\t\t\t\t\t\t\t\t\t\tvalidate: validateURL,\n\t\t\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tname: 'x',\n\t\t\t\t\t\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: 'X',\n\t\t\t\t\t\t\t\t\t\t\t\tvalidate: validateURL,\n\t\t\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tname: 'facebook',\n\t\t\t\t\t\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: 'Facebook',\n\t\t\t\t\t\t\t\t\t\t\t\tvalidate: validateURL,\n\t\t\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tname: 'instagram',\n\t\t\t\t\t\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: 'Instagram',\n\t\t\t\t\t\t\t\t\t\t\t\tvalidate: validateURL,\n\t\t\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tname: 'youtube',\n\t\t\t\t\t\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: 'Youtube',\n\t\t\t\t\t\t\t\t\t\t\t\tvalidate: validateURL,\n\t\t\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tname: 'tiktok',\n\t\t\t\t\t\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: 'TikTok',\n\t\t\t\t\t\t\t\t\t\t\t\tvalidate: validateURL,\n\t\t\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t} as GroupField,\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: 'Maintenance',\n\t\t\t\t\t\tfields: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: 'maintenance',\n\t\t\t\t\t\t\t\ttype: 'group',\n\t\t\t\t\t\t\t\tfields: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tname: 'enabled',\n\t\t\t\t\t\t\t\t\t\ttype: 'checkbox',\n\t\t\t\t\t\t\t\t\t\tlabel: 'Enable',\n\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t\t\t\t'Enable maintenance mode for the site, this will use a maintenance page template and not include any of the sites functioanlity.',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tname: 'title',\n\t\t\t\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\t\t\t\tlabel: 'Title',\n\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\tdescription: 'Add a title for the maintenance page.',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tname: 'content',\n\t\t\t\t\t\t\t\t\t\ttype: 'textarea',\n\t\t\t\t\t\t\t\t\t\tlabel: 'Content',\n\t\t\t\t\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t\t\t\t'Add content for the maintenance page, it will appear beneath the title.',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\t...(additionalTabs ? additionalTabs : []),\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n};\n"],"names":["validatePostcode","validateURL","countries","languages","Settings","additionalTabs","slug","typescript","interface","graphQL","name","access","read","fields","type","tabs","label","description","admin","width","defaultValue","options","map","l","value","code","typescriptSchema","relationTo","filterOptions","mimeType","contains","language","hideGutter","validate","c"],"mappings":"AACA,SAASA,gBAAgB,EAAEC,WAAW,QAAQ,wBAAwB;AACtE,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,SAAS,QAAQ,eAAe;AAEzC;;;;;;;CAOC,GACD,OAAO,MAAMC,WAAW,CAACC;IACxB,OAAO;QACNC,MAAM;QACNC,YAAY;YACXC,WAAW;QACZ;QACAC,SAAS;YACRC,MAAM;QACP;QACAC,QAAQ;YACPC,MAAM,IAAM;QACb;QACAC,QAAQ;YACP;gBACCC,MAAM;gBACNC,MAAM;oBACL;wBACCC,OAAO;wBACPC,aAAa;wBACbJ,QAAQ;4BACP;gCACCC,MAAM;gCACND,QAAQ;oCACP;wCACCH,MAAM;wCACNI,MAAM;wCACNE,OAAO;wCACPE,OAAO;4CACNC,OAAO;4CACPF,aACC;wCACF;oCACD;oCACA;wCACCP,MAAM;wCACNI,MAAM;wCACNE,OAAO;wCACPI,cAAc;wCACdC,SAASlB,UAAUmB,GAAG,CAAC,CAACC;4CACvB,OAAO;gDACNP,OAAOO,EAAEb,IAAI;gDACbc,OAAOD,EAAEE,IAAI;4CACd;wCACD;wCACAP,OAAO;4CACNC,OAAO;4CACPF,aACC;wCACF;wCACAS,kBAAkB;4CACjB,IAAO,CAAA;oDACNZ,MAAM;gDACP,CAAA;yCACA;oCACF;iCACA;4BACF;4BACA;gCACCJ,MAAM;gCACNI,MAAM;gCACNE,OAAO;gCACPE,OAAO;oCACND,aAAa;gCACd;4BACD;4BACA;gCACCP,MAAM;gCACNI,MAAM;gCACNa,YAAY;gCACZC,eAAe;oCACdC,UAAU;wCACTC,UAAU;oCACX;gCACD;gCACAZ,OAAO;oCACND,aACC;gCACF;4BACD;4BACA;gCACCP,MAAM;gCACNI,MAAM;gCACNE,OAAO;gCACPE,OAAO;oCACND,aACC;gCACF;4BACD;yBACA;oBACF;oBACA;wBACCD,OAAO;wBACPC,aACC;wBACDJ,QAAQ;4BACP;gCACCH,MAAM;gCACNI,MAAM;gCACND,QAAQ;oCACP;wCACCH,MAAM;wCACNI,MAAM;wCACNE,OAAO;wCACPE,OAAO;4CACNa,UAAU;4CACVd,aACC;wCACF;oCACD;oCACA;wCACCP,MAAM;wCACNI,MAAM;wCACNE,OAAO;wCACPE,OAAO;4CACNa,UAAU;4CACVd,aACC;wCACF;oCACD;iCACA;4BACF;yBACA;oBACF;oBACA;wBACCD,OAAO;wBACPH,QAAQ;4BACP;gCACCH,MAAM;gCACNI,MAAM;gCACNI,OAAO;oCACNc,YAAY;oCACZf,aACC;gCACF;gCACAJ,QAAQ;oCACP;wCACCC,MAAM;wCACND,QAAQ;4CACP;gDACCH,MAAM;gDACNI,MAAM;gDACNE,OAAO;gDACPE,OAAO;oDACNC,OAAO;gDACR;4CACD;4CACA;gDACCT,MAAM;gDACNI,MAAM;gDACNE,OAAO;gDACPE,OAAO;oDACNC,OAAO;gDACR;4CACD;yCACA;oCACF;iCACA;4BACF;4BACA;gCACCL,MAAM;gCACNJ,MAAM;gCACNM,OAAO;gCACPE,OAAO;oCACNc,YAAY;oCACZf,aAAa;gCACd;gCACAJ,QAAQ;oCACP;wCACCC,MAAM;wCACND,QAAQ;4CACP;gDACCH,MAAM;gDACNI,MAAM;gDACNE,OAAO;gDACPE,OAAO;oDACNC,OAAO;gDACR;4CACD;4CACA;gDACCT,MAAM;gDACNI,MAAM;gDACNE,OAAO;gDACPE,OAAO;oDACNC,OAAO;gDACR;4CACD;4CACA;gDACCT,MAAM;gDACNI,MAAM;gDACNE,OAAO;gDACPE,OAAO;oDACNC,OAAO;gDACR;4CACD;4CACA;gDACCT,MAAM;gDACNI,MAAM;gDACNE,OAAO;gDACPE,OAAO;oDACNC,OAAO;gDACR;4CACD;4CACA;gDACCT,MAAM;gDACNI,MAAM;gDACNE,OAAO;gDACPiB,UAAUjC;gDACVkB,OAAO;oDACNC,OAAO;gDACR;4CACD;4CACA;gDACCT,MAAM;gDACNI,MAAM;gDACNE,OAAO;gDACPK,SAASnB,UAAUoB,GAAG,CAAC,CAACY;oDACvB,OAAO;wDACNlB,OAAOkB;wDACPV,OAAOU;oDACR;gDACD;gDACAhB,OAAO;oDACNC,OAAO;gDACR;4CACD;yCACA;oCACF;iCACA;4BACF;4BACA;gCACCL,MAAM;gCACNJ,MAAM;gCACNM,OAAO;gCACPE,OAAO;oCACNc,YAAY;oCACZf,aAAa;gCACd;gCACAJ,QAAQ;oCACP;wCACCC,MAAM;wCACND,QAAQ;4CACP;gDACCH,MAAM;gDACNI,MAAM;gDACNE,OAAO;gDACPiB,UAAUhC;gDACViB,OAAO;oDACNC,OAAO;gDACR;4CACD;4CACA;gDACCT,MAAM;gDACNI,MAAM;gDACNE,OAAO;gDACPiB,UAAUhC;gDACViB,OAAO;oDACNC,OAAO;gDACR;4CACD;4CACA;gDACCT,MAAM;gDACNI,MAAM;gDACNE,OAAO;gDACPiB,UAAUhC;gDACViB,OAAO;oDACNC,OAAO;gDACR;4CACD;4CACA;gDACCT,MAAM;gDACNI,MAAM;gDACNE,OAAO;gDACPiB,UAAUhC;gDACViB,OAAO;oDACNC,OAAO;gDACR;4CACD;4CACA;gDACCT,MAAM;gDACNI,MAAM;gDACNE,OAAO;gDACPiB,UAAUhC;gDACViB,OAAO;oDACNC,OAAO;gDACR;4CACD;4CACA;gDACCT,MAAM;gDACNI,MAAM;gDACNE,OAAO;gDACPiB,UAAUhC;gDACViB,OAAO;oDACNC,OAAO;gDACR;4CACD;yCACA;oCACF;iCACA;4BACF;yBACA;oBACF;oBACA;wBACCH,OAAO;wBACPH,QAAQ;4BACP;gCACCH,MAAM;gCACNI,MAAM;gCACND,QAAQ;oCACP;wCACCH,MAAM;wCACNI,MAAM;wCACNE,OAAO;wCACPE,OAAO;4CACND,aACC;wCACF;oCACD;oCACA;wCACCP,MAAM;wCACNI,MAAM;wCACNE,OAAO;wCACPE,OAAO;4CACND,aAAa;wCACd;oCACD;oCACA;wCACCP,MAAM;wCACNI,MAAM;wCACNE,OAAO;wCACPE,OAAO;4CACND,aACC;wCACF;oCACD;iCACA;4BACF;yBACA;oBACF;uBACIZ,iBAAiBA,iBAAiB,EAAE;iBACxC;YACF;SACA;IACF;AACD,EAAE"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -12,6 +12,7 @@ import env from './util/env.js';
|
|
|
12
12
|
...incomingConfig.typescript,
|
|
13
13
|
schema: schemas
|
|
14
14
|
};
|
|
15
|
+
// biome-ignore lint/style/noParameterAssign: Need to change field mapper.
|
|
15
16
|
incomingConfig = fieldMapper(incomingConfig);
|
|
16
17
|
}
|
|
17
18
|
incomingConfig.typescript = incomingConfig.typescript || {};
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Config } from 'payload';\nimport { fieldMapper, schemas } from './plugin/schema.js';\nimport
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Config } from 'payload';\nimport { fieldMapper, schemas } from './plugin/schema.js';\nimport type { PayloadHelperPluginConfig } from './types.js';\nimport env from './util/env.js';\n\n/**\n * Payload Helper Plugin for websites at ainsley.dev\n *\n * @constructor\n * @param pluginOptions\n */\nexport const payloadHelper =\n\t(pluginOptions: PayloadHelperPluginConfig) =>\n\t(incomingConfig: Config): Config => {\n\t\tconst genGoLang = env.bool('GEN_GOLANG', false);\n\t\tif (genGoLang) {\n\t\t\tincomingConfig.typescript = {\n\t\t\t\t...incomingConfig.typescript,\n\t\t\t\tschema: schemas,\n\t\t\t};\n\t\t\t// biome-ignore lint/style/noParameterAssign: Need to change field mapper.\n\t\t\tincomingConfig = fieldMapper(incomingConfig);\n\t\t}\n\n\t\tincomingConfig.typescript = incomingConfig.typescript || {};\n\t\tincomingConfig.typescript.outputFile = './src/types/payload.ts';\n\n\t\treturn incomingConfig;\n\t};\n"],"names":["fieldMapper","schemas","env","payloadHelper","pluginOptions","incomingConfig","genGoLang","bool","typescript","schema","outputFile"],"mappings":"AACA,SAASA,WAAW,EAAEC,OAAO,QAAQ,qBAAqB;AAE1D,OAAOC,SAAS,gBAAgB;AAEhC;;;;;CAKC,GACD,OAAO,MAAMC,gBACZ,CAACC,gBACD,CAACC;QACA,MAAMC,YAAYJ,IAAIK,IAAI,CAAC,cAAc;QACzC,IAAID,WAAW;YACdD,eAAeG,UAAU,GAAG;gBAC3B,GAAGH,eAAeG,UAAU;gBAC5BC,QAAQR;YACT;YACA,0EAA0E;YAC1EI,iBAAiBL,YAAYK;QAC9B;QAEAA,eAAeG,UAAU,GAAGH,eAAeG,UAAU,IAAI,CAAC;QAC1DH,eAAeG,UAAU,CAACE,UAAU,GAAG;QAEvC,OAAOL;IACR,EAAE"}
|
package/dist/seed/down.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/seed/down.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport
|
|
1
|
+
{"version":3,"sources":["../../src/seed/down.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport type { Payload, PayloadRequest } from 'payload';\nimport env from '../util/env.js';\nimport type { Seeder } from './seed.js';\n\nconst filename = fileURLToPath(import.meta.url);\nconst dirname = path.dirname(filename);\n\nconst postgresDrop = async (payload: Payload): Promise<void> => {\n\t// @ts-expect-error\n\tconst db = payload.db.pool;\n\tconst client = await db.connect();\n\tawait client.query('drop schema public cascade; create schema public;');\n};\n\nconst sqlDrop = async (payload: Payload): Promise<void> => {};\n\n/**\n * Down script to remove all media and drop all tables.\n *\n * @param payload\n * @param req\n */\nexport const down = async ({\n\tpayload,\n}: {\n\tpayload: Payload;\n\treq: PayloadRequest;\n\tseeder: Seeder;\n}): Promise<void> => {\n\tpayload.logger.info('Running down script');\n\n\t// Clearing local media\n\tif (!env.isProduction) {\n\t\tpayload.logger.info('Clearing media...');\n\t\tconst mediaDir = path.resolve(dirname, '../../media');\n\t\tif (fs.existsSync(mediaDir)) {\n\t\t\tfs.rmSync(mediaDir, { recursive: true, force: true });\n\t\t}\n\t}\n\n\tpayload.logger.info('Dropping tables in database...');\n};\n"],"names":["fs","path","fileURLToPath","env","filename","url","dirname","postgresDrop","payload","db","pool","client","connect","query","sqlDrop","down","logger","info","isProduction","mediaDir","resolve","existsSync","rmSync","recursive","force"],"mappings":"AAAA,OAAOA,QAAQ,UAAU;AACzB,OAAOC,UAAU,YAAY;AAC7B,SAASC,aAAa,QAAQ,WAAW;AAEzC,OAAOC,SAAS,iBAAiB;AAGjC,MAAMC,WAAWF,cAAc,YAAYG,GAAG;AAC9C,MAAMC,UAAUL,KAAKK,OAAO,CAACF;AAE7B,MAAMG,eAAe,OAAOC;IAC3B,mBAAmB;IACnB,MAAMC,KAAKD,QAAQC,EAAE,CAACC,IAAI;IAC1B,MAAMC,SAAS,MAAMF,GAAGG,OAAO;IAC/B,MAAMD,OAAOE,KAAK,CAAC;AACpB;AAEA,MAAMC,UAAU,OAAON,WAAqC;AAE5D;;;;;CAKC,GACD,OAAO,MAAMO,OAAO,OAAO,EAC1BP,OAAO,EAKP;IACAA,QAAQQ,MAAM,CAACC,IAAI,CAAC;IAEpB,uBAAuB;IACvB,IAAI,CAACd,IAAIe,YAAY,EAAE;QACtBV,QAAQQ,MAAM,CAACC,IAAI,CAAC;QACpB,MAAME,WAAWlB,KAAKmB,OAAO,CAACd,SAAS;QACvC,IAAIN,GAAGqB,UAAU,CAACF,WAAW;YAC5BnB,GAAGsB,MAAM,CAACH,UAAU;gBAAEI,WAAW;gBAAMC,OAAO;YAAK;QACpD;IACD;IAEAhB,QAAQQ,MAAM,CAACC,IAAI,CAAC;AACrB,EAAE"}
|
package/dist/seed/seed.d.ts
CHANGED
package/dist/seed/seed.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/seed/seed.ts"],"sourcesContent":["import dotenv from 'dotenv';\nimport {\n\ttype PayloadRequest,\n\tcommitTransaction,\n\tgetPayload,\n\tinitTransaction,\n\tkillTransaction,\n
|
|
1
|
+
{"version":3,"sources":["../../src/seed/seed.ts"],"sourcesContent":["import dotenv from 'dotenv';\nimport {\n\ttype Payload,\n\ttype PayloadRequest,\n\tcommitTransaction,\n\tgetPayload,\n\tinitTransaction,\n\tkillTransaction,\n} from 'payload';\nimport { importConfig } from 'payload/node';\nimport { down } from './down.js';\nimport { up } from './up.js';\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\tenvPath: string;\n\tconfigPath: string;\n\tdbAdapter: DBAdapter;\n\tseeder: Seeder;\n};\n\n/**\n * The database adapter to use, which will remove and recreate the database.\n */\nexport enum DBAdapter {\n\tPostgres = 'postgres',\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: SeedOptions) => {\n\tconst fn = async () => {\n\t\tdotenv.config({\n\t\t\tpath: opts.envPath,\n\t\t});\n\n\t\tfor (const fn of [down, up]) {\n\t\t\tif (fn === down) {\n\t\t\t\tprocess.env.PAYLOAD_DROP_DATABASE = 'true';\n\t\t\t} else {\n\t\t\t\tdelete process.env.PAYLOAD_DROP_DATABASE; // Ensure it is not set for other functions\n\t\t\t}\n\n\t\t\tconst config = await importConfig(opts.configPath);\n\t\t\tconst payload = await getPayload({ config });\n\t\t\tconst req = { payload } as PayloadRequest;\n\n\t\t\tawait initTransaction(req);\n\n\t\t\ttry {\n\t\t\t\tawait fn({ payload, req, seeder: opts.seeder });\n\t\t\t\tpayload.logger.info('Seed complete');\n\t\t\t\tawait commitTransaction(req);\n\t\t\t} catch (err) {\n\t\t\t\tconst message = err instanceof Error ? err.message : 'Unknown error';\n\t\t\t\tpayload.logger.error(`Seed failed: ${message}`);\n\t\t\t\tawait killTransaction(req);\n\t\t\t}\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":["dotenv","commitTransaction","getPayload","initTransaction","killTransaction","importConfig","down","up","DBAdapter","seed","opts","fn","config","path","envPath","process","env","PAYLOAD_DROP_DATABASE","configPath","payload","req","seeder","logger","info","err","message","Error","error","then","exit","catch","e","console"],"mappings":"AAAA,OAAOA,YAAY,SAAS;AAC5B,SAGCC,iBAAiB,EACjBC,UAAU,EACVC,eAAe,EACfC,eAAe,QACT,UAAU;AACjB,SAASC,YAAY,QAAQ,eAAe;AAC5C,SAASC,IAAI,QAAQ,YAAY;AACjC,SAASC,EAAE,QAAQ,UAAU;;UAqBjBC;;GAAAA,cAAAA;AAIZ;;;;;CAKC,GACD,OAAO,MAAMC,OAAO,CAACC;IACpB,MAAMC,KAAK;QACVX,OAAOY,MAAM,CAAC;YACbC,MAAMH,KAAKI,OAAO;QACnB;QAEA,KAAK,MAAMH,MAAM;YAACL;YAAMC;SAAG,CAAE;YAC5B,IAAII,OAAOL,MAAM;gBAChBS,QAAQC,GAAG,CAACC,qBAAqB,GAAG;YACrC,OAAO;gBACN,OAAOF,QAAQC,GAAG,CAACC,qBAAqB,EAAE,2CAA2C;YACtF;YAEA,MAAML,SAAS,MAAMP,aAAaK,KAAKQ,UAAU;YACjD,MAAMC,UAAU,MAAMjB,WAAW;gBAAEU;YAAO;YAC1C,MAAMQ,MAAM;gBAAED;YAAQ;YAEtB,MAAMhB,gBAAgBiB;YAEtB,IAAI;gBACH,MAAMT,GAAG;oBAAEQ;oBAASC;oBAAKC,QAAQX,KAAKW,MAAM;gBAAC;gBAC7CF,QAAQG,MAAM,CAACC,IAAI,CAAC;gBACpB,MAAMtB,kBAAkBmB;YACzB,EAAE,OAAOI,KAAK;gBACb,MAAMC,UAAUD,eAAeE,QAAQF,IAAIC,OAAO,GAAG;gBACrDN,QAAQG,MAAM,CAACK,KAAK,CAAC,CAAC,aAAa,EAAEF,QAAQ,CAAC;gBAC9C,MAAMrB,gBAAgBgB;YACvB;QACD;IACD;IAEAT,KACEiB,IAAI,CAAC,IAAMb,QAAQc,IAAI,CAAC,IACxBC,KAAK,CAAC,CAACC;QACPC,QAAQL,KAAK,CAACI;QACdhB,QAAQc,IAAI,CAAC;IACd;AACF,EAAE"}
|
package/dist/seed/up.d.ts
CHANGED
package/dist/seed/up.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/seed/up.ts"],"sourcesContent":["import path from 'node:path';\nimport type { Payload, PayloadRequest } from 'payload';\nimport { getFileByPath } from 'payload';\nimport
|
|
1
|
+
{"version":3,"sources":["../../src/seed/up.ts"],"sourcesContent":["import path from 'node:path';\nimport type { Payload, PayloadRequest } from 'payload';\nimport { getFileByPath } from 'payload';\nimport { htmlToLexical } from '../util/lexical.js';\nimport type { Seeder } from './seed.js';\nimport type { Media, MediaSeed } from './types.js';\n\n/**\n *\n * @param req\n * @param payload\n * @param dirname\n * @param media\n */\nexport const uploadMedia = async (\n\treq: PayloadRequest,\n\tpayload: Payload,\n\tdirname: string,\n\tmedia: MediaSeed,\n): Promise<Media> => {\n\ttry {\n\t\tconst image = await getFileByPath(path.resolve(dirname, media.path));\n\t\tconst caption = media.caption ? await htmlToLexical(media.caption) : null;\n\n\t\treturn (await payload.create({\n\t\t\tcollection: 'media',\n\t\t\tfile: image,\n\t\t\tdata: {\n\t\t\t\talt: media.alt,\n\t\t\t\tcaption: caption,\n\t\t\t},\n\t\t\treq,\n\t\t})) as unknown as Media;\n\t} catch (error) {\n\t\tpayload.logger.error(`Uploading media: ${error}`);\n\t\tthrow error;\n\t}\n};\n\n/**\n * Up script to create tables and seed data.\n *\n * @param payload\n * @param req\n * @param seeder\n */\nexport const up = async ({\n\tpayload,\n\treq,\n\tseeder,\n}: {\n\tpayload: Payload;\n\treq: PayloadRequest;\n\tseeder: Seeder;\n}): Promise<void> => {\n\tpayload.logger.info('Running up script');\n\n\tawait payload.init({\n\t\tconfig: payload.config,\n\t});\n\n\t// Creating new tables\n\tpayload.logger.info('Creating indexes...');\n\ttry {\n\t\tif (payload.db.init) {\n\t\t\tawait payload.db.init();\n\t\t}\n\t} catch (error) {\n\t\tpayload.logger.error(`Creating database: ${error}`);\n\t\treturn;\n\t}\n\n\tawait seeder({ payload, req });\n};\n"],"names":["path","getFileByPath","htmlToLexical","uploadMedia","req","payload","dirname","media","image","resolve","caption","create","collection","file","data","alt","error","logger","up","seeder","info","init","config","db"],"mappings":"AAAA,OAAOA,UAAU,YAAY;AAE7B,SAASC,aAAa,QAAQ,UAAU;AACxC,SAASC,aAAa,QAAQ,qBAAqB;AAInD;;;;;;CAMC,GACD,OAAO,MAAMC,cAAc,OAC1BC,KACAC,SACAC,SACAC;IAEA,IAAI;QACH,MAAMC,QAAQ,MAAMP,cAAcD,KAAKS,OAAO,CAACH,SAASC,MAAMP,IAAI;QAClE,MAAMU,UAAUH,MAAMG,OAAO,GAAG,MAAMR,cAAcK,MAAMG,OAAO,IAAI;QAErE,OAAQ,MAAML,QAAQM,MAAM,CAAC;YAC5BC,YAAY;YACZC,MAAML;YACNM,MAAM;gBACLC,KAAKR,MAAMQ,GAAG;gBACdL,SAASA;YACV;YACAN;QACD;IACD,EAAE,OAAOY,OAAO;QACfX,QAAQY,MAAM,CAACD,KAAK,CAAC,CAAC,iBAAiB,EAAEA,MAAM,CAAC;QAChD,MAAMA;IACP;AACD,EAAE;AAEF;;;;;;CAMC,GACD,OAAO,MAAME,KAAK,OAAO,EACxBb,OAAO,EACPD,GAAG,EACHe,MAAM,EAKN;IACAd,QAAQY,MAAM,CAACG,IAAI,CAAC;IAEpB,MAAMf,QAAQgB,IAAI,CAAC;QAClBC,QAAQjB,QAAQiB,MAAM;IACvB;IAEA,sBAAsB;IACtBjB,QAAQY,MAAM,CAACG,IAAI,CAAC;IACpB,IAAI;QACH,IAAIf,QAAQkB,EAAE,CAACF,IAAI,EAAE;YACpB,MAAMhB,QAAQkB,EAAE,CAACF,IAAI;QACtB;IACD,EAAE,OAAOL,OAAO;QACfX,QAAQY,MAAM,CAACD,KAAK,CAAC,CAAC,mBAAmB,EAAEA,MAAM,CAAC;QAClD;IACD;IAEA,MAAMG,OAAO;QAAEd;QAASD;IAAI;AAC7B,EAAE"}
|
package/dist/util/env.js
CHANGED
|
@@ -13,13 +13,13 @@ const utils = {
|
|
|
13
13
|
if (!hasKey(key)) {
|
|
14
14
|
return defaultValue;
|
|
15
15
|
}
|
|
16
|
-
return parseInt(getKey(key), 10);
|
|
16
|
+
return Number.parseInt(getKey(key), 10);
|
|
17
17
|
},
|
|
18
18
|
float (key, defaultValue) {
|
|
19
19
|
if (!hasKey(key)) {
|
|
20
20
|
return defaultValue;
|
|
21
21
|
}
|
|
22
|
-
return parseFloat(getKey(key));
|
|
22
|
+
return Number.parseFloat(getKey(key));
|
|
23
23
|
},
|
|
24
24
|
bool (key, defaultValue) {
|
|
25
25
|
if (!hasKey(key)) {
|
|
@@ -60,10 +60,10 @@ const utils = {
|
|
|
60
60
|
},
|
|
61
61
|
oneOf (key, expectedValues, defaultValue) {
|
|
62
62
|
if (!expectedValues) {
|
|
63
|
-
throw new Error(
|
|
63
|
+
throw new Error('env.oneOf requires expectedValues');
|
|
64
64
|
}
|
|
65
65
|
if (defaultValue && !expectedValues.includes(defaultValue)) {
|
|
66
|
-
throw new Error(
|
|
66
|
+
throw new Error('env.oneOf requires defaultValue to be included in expectedValues');
|
|
67
67
|
}
|
|
68
68
|
const rawValue = envFn(key, defaultValue);
|
|
69
69
|
return expectedValues.includes(rawValue) ? rawValue : defaultValue;
|
package/dist/util/env.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/util/env.ts"],"sourcesContent":["function hasKey(key: string): boolean {\n\treturn Object.prototype.hasOwnProperty.call(process.env, key);\n}\n\nfunction envFn<T>(key: string, defaultValue: T): string | T {\n\treturn hasKey(key) ? (process.env[key] as string) : defaultValue;\n}\n\nfunction getKey(key: string): string {\n\treturn process.env[key] ?? '';\n}\n\nconst utils = {\n\tisProduction: getKey('NODE_ENV') === 'production',\n\n\tint(key: string, defaultValue?: number): number | undefined {\n\t\tif (!hasKey(key)) {\n\t\t\treturn defaultValue;\n\t\t}\n\n\t\treturn parseInt(getKey(key), 10);\n\t},\n\n\tfloat(key: string, defaultValue?: number): number | undefined {\n\t\tif (!hasKey(key)) {\n\t\t\treturn defaultValue;\n\t\t}\n\n\t\treturn parseFloat(getKey(key));\n\t},\n\n\tbool(key: string, defaultValue?: boolean): boolean | undefined {\n\t\tif (!hasKey(key)) {\n\t\t\treturn defaultValue;\n\t\t}\n\n\t\treturn getKey(key) === 'true';\n\t},\n\n\tjson(key: string, defaultValue?: object) {\n\t\tif (!hasKey(key)) {\n\t\t\treturn defaultValue;\n\t\t}\n\n\t\ttry {\n\t\t\treturn JSON.parse(getKey(key));\n\t\t} catch (error) {\n\t\t\tif (error instanceof Error) {\n\t\t\t\tthrow new Error(`Invalid json environment variable ${key}: ${error.message}`);\n\t\t\t}\n\n\t\t\tthrow error;\n\t\t}\n\t},\n\n\tarray(key: string, defaultValue?: string[]): string[] | undefined {\n\t\tif (!hasKey(key)) {\n\t\t\treturn defaultValue;\n\t\t}\n\n\t\tlet value = getKey(key);\n\n\t\tif (value.startsWith('[') && value.endsWith(']')) {\n\t\t\tvalue = value.substring(1, value.length - 1);\n\t\t}\n\n\t\treturn value.split(',').map((v) => {\n\t\t\treturn v.trim().replace(/^\"(.*)\"$/, '$1');\n\t\t});\n\t},\n\n\tdate(key: string, defaultValue?: Date): Date | undefined {\n\t\tif (!hasKey(key)) {\n\t\t\treturn defaultValue;\n\t\t}\n\n\t\treturn new Date(getKey(key));\n\t},\n\n\toneOf(key: string, expectedValues?: unknown[], defaultValue?: unknown) {\n\t\tif (!expectedValues) {\n\t\t\tthrow new Error(
|
|
1
|
+
{"version":3,"sources":["../../src/util/env.ts"],"sourcesContent":["function hasKey(key: string): boolean {\n\treturn Object.prototype.hasOwnProperty.call(process.env, key);\n}\n\nfunction envFn<T>(key: string, defaultValue: T): string | T {\n\treturn hasKey(key) ? (process.env[key] as string) : defaultValue;\n}\n\nfunction getKey(key: string): string {\n\treturn process.env[key] ?? '';\n}\n\nconst utils = {\n\tisProduction: getKey('NODE_ENV') === 'production',\n\n\tint(key: string, defaultValue?: number): number | undefined {\n\t\tif (!hasKey(key)) {\n\t\t\treturn defaultValue;\n\t\t}\n\n\t\treturn Number.parseInt(getKey(key), 10);\n\t},\n\n\tfloat(key: string, defaultValue?: number): number | undefined {\n\t\tif (!hasKey(key)) {\n\t\t\treturn defaultValue;\n\t\t}\n\n\t\treturn Number.parseFloat(getKey(key));\n\t},\n\n\tbool(key: string, defaultValue?: boolean): boolean | undefined {\n\t\tif (!hasKey(key)) {\n\t\t\treturn defaultValue;\n\t\t}\n\n\t\treturn getKey(key) === 'true';\n\t},\n\n\tjson(key: string, defaultValue?: object) {\n\t\tif (!hasKey(key)) {\n\t\t\treturn defaultValue;\n\t\t}\n\n\t\ttry {\n\t\t\treturn JSON.parse(getKey(key));\n\t\t} catch (error) {\n\t\t\tif (error instanceof Error) {\n\t\t\t\tthrow new Error(`Invalid json environment variable ${key}: ${error.message}`);\n\t\t\t}\n\n\t\t\tthrow error;\n\t\t}\n\t},\n\n\tarray(key: string, defaultValue?: string[]): string[] | undefined {\n\t\tif (!hasKey(key)) {\n\t\t\treturn defaultValue;\n\t\t}\n\n\t\tlet value = getKey(key);\n\n\t\tif (value.startsWith('[') && value.endsWith(']')) {\n\t\t\tvalue = value.substring(1, value.length - 1);\n\t\t}\n\n\t\treturn value.split(',').map((v) => {\n\t\t\treturn v.trim().replace(/^\"(.*)\"$/, '$1');\n\t\t});\n\t},\n\n\tdate(key: string, defaultValue?: Date): Date | undefined {\n\t\tif (!hasKey(key)) {\n\t\t\treturn defaultValue;\n\t\t}\n\n\t\treturn new Date(getKey(key));\n\t},\n\n\toneOf(key: string, expectedValues?: unknown[], defaultValue?: unknown) {\n\t\tif (!expectedValues) {\n\t\t\tthrow new Error('env.oneOf requires expectedValues');\n\t\t}\n\n\t\tif (defaultValue && !expectedValues.includes(defaultValue)) {\n\t\t\tthrow new Error('env.oneOf requires defaultValue to be included in expectedValues');\n\t\t}\n\n\t\tconst rawValue = envFn(key, defaultValue);\n\t\treturn expectedValues.includes(rawValue) ? rawValue : defaultValue;\n\t},\n};\n\nconst env = Object.assign(envFn, utils);\n\nexport default env;\n"],"names":["hasKey","key","Object","prototype","hasOwnProperty","call","process","env","envFn","defaultValue","getKey","utils","isProduction","int","Number","parseInt","float","parseFloat","bool","json","JSON","parse","error","Error","message","array","value","startsWith","endsWith","substring","length","split","map","v","trim","replace","date","Date","oneOf","expectedValues","includes","rawValue","assign"],"mappings":"AAAA,SAASA,OAAOC,GAAW;IAC1B,OAAOC,OAAOC,SAAS,CAACC,cAAc,CAACC,IAAI,CAACC,QAAQC,GAAG,EAAEN;AAC1D;AAEA,SAASO,MAASP,GAAW,EAAEQ,YAAe;IAC7C,OAAOT,OAAOC,OAAQK,QAAQC,GAAG,CAACN,IAAI,GAAcQ;AACrD;AAEA,SAASC,OAAOT,GAAW;IAC1B,OAAOK,QAAQC,GAAG,CAACN,IAAI,IAAI;AAC5B;AAEA,MAAMU,QAAQ;IACbC,cAAcF,OAAO,gBAAgB;IAErCG,KAAIZ,GAAW,EAAEQ,YAAqB;QACrC,IAAI,CAACT,OAAOC,MAAM;YACjB,OAAOQ;QACR;QAEA,OAAOK,OAAOC,QAAQ,CAACL,OAAOT,MAAM;IACrC;IAEAe,OAAMf,GAAW,EAAEQ,YAAqB;QACvC,IAAI,CAACT,OAAOC,MAAM;YACjB,OAAOQ;QACR;QAEA,OAAOK,OAAOG,UAAU,CAACP,OAAOT;IACjC;IAEAiB,MAAKjB,GAAW,EAAEQ,YAAsB;QACvC,IAAI,CAACT,OAAOC,MAAM;YACjB,OAAOQ;QACR;QAEA,OAAOC,OAAOT,SAAS;IACxB;IAEAkB,MAAKlB,GAAW,EAAEQ,YAAqB;QACtC,IAAI,CAACT,OAAOC,MAAM;YACjB,OAAOQ;QACR;QAEA,IAAI;YACH,OAAOW,KAAKC,KAAK,CAACX,OAAOT;QAC1B,EAAE,OAAOqB,OAAO;YACf,IAAIA,iBAAiBC,OAAO;gBAC3B,MAAM,IAAIA,MAAM,CAAC,kCAAkC,EAAEtB,IAAI,EAAE,EAAEqB,MAAME,OAAO,CAAC,CAAC;YAC7E;YAEA,MAAMF;QACP;IACD;IAEAG,OAAMxB,GAAW,EAAEQ,YAAuB;QACzC,IAAI,CAACT,OAAOC,MAAM;YACjB,OAAOQ;QACR;QAEA,IAAIiB,QAAQhB,OAAOT;QAEnB,IAAIyB,MAAMC,UAAU,CAAC,QAAQD,MAAME,QAAQ,CAAC,MAAM;YACjDF,QAAQA,MAAMG,SAAS,CAAC,GAAGH,MAAMI,MAAM,GAAG;QAC3C;QAEA,OAAOJ,MAAMK,KAAK,CAAC,KAAKC,GAAG,CAAC,CAACC;YAC5B,OAAOA,EAAEC,IAAI,GAAGC,OAAO,CAAC,YAAY;QACrC;IACD;IAEAC,MAAKnC,GAAW,EAAEQ,YAAmB;QACpC,IAAI,CAACT,OAAOC,MAAM;YACjB,OAAOQ;QACR;QAEA,OAAO,IAAI4B,KAAK3B,OAAOT;IACxB;IAEAqC,OAAMrC,GAAW,EAAEsC,cAA0B,EAAE9B,YAAsB;QACpE,IAAI,CAAC8B,gBAAgB;YACpB,MAAM,IAAIhB,MAAM;QACjB;QAEA,IAAId,gBAAgB,CAAC8B,eAAeC,QAAQ,CAAC/B,eAAe;YAC3D,MAAM,IAAIc,MAAM;QACjB;QAEA,MAAMkB,WAAWjC,MAAMP,KAAKQ;QAC5B,OAAO8B,eAAeC,QAAQ,CAACC,YAAYA,WAAWhC;IACvD;AACD;AAEA,MAAMF,MAAML,OAAOwC,MAAM,CAAClC,OAAOG;AAEjC,eAAeJ,IAAI"}
|
package/dist/util/fields.d.ts
CHANGED
package/dist/util/fields.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/util/fields.ts"],"sourcesContent":["import { Field } from 'payload';\n\n/**\n * Determines if a Payload field has a name property.\n *\n * @param field\n */\nexport const fieldHasName = (field: Field): boolean => {\n\tif (field.type === 'ui') {\n\t\treturn false;\n\t}\n\treturn field.type !== 'tabs' && field.type !== 'row' && field.type !== 'collapsible';\n};\n"],"names":["fieldHasName","field","type"],"mappings":"AAEA;;;;CAIC,GACD,OAAO,MAAMA,eAAe,CAACC;IAC5B,IAAIA,MAAMC,IAAI,KAAK,MAAM;QACxB,OAAO;IACR;IACA,OAAOD,MAAMC,IAAI,KAAK,UAAUD,MAAMC,IAAI,KAAK,SAASD,MAAMC,IAAI,KAAK;AACxE,EAAE"}
|
|
1
|
+
{"version":3,"sources":["../../src/util/fields.ts"],"sourcesContent":["import type { Field } from 'payload';\n\n/**\n * Determines if a Payload field has a name property.\n *\n * @param field\n */\nexport const fieldHasName = (field: Field): boolean => {\n\tif (field.type === 'ui') {\n\t\treturn false;\n\t}\n\treturn field.type !== 'tabs' && field.type !== 'row' && field.type !== 'collapsible';\n};\n"],"names":["fieldHasName","field","type"],"mappings":"AAEA;;;;CAIC,GACD,OAAO,MAAMA,eAAe,CAACC;IAC5B,IAAIA,MAAMC,IAAI,KAAK,MAAM;QACxB,OAAO;IACR;IACA,OAAOD,MAAMC,IAAI,KAAK,UAAUD,MAAMC,IAAI,KAAK,SAASD,MAAMC,IAAI,KAAK;AACxE,EAAE"}
|
package/dist/util/lexical.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { createHeadlessEditor } from '@lexical/headless';
|
|
2
|
-
import { $
|
|
3
|
-
import { $getRoot, $getSelection } from 'lexical';
|
|
4
|
-
import { JSDOM } from 'jsdom';
|
|
5
|
-
import { getPayload } from "payload";
|
|
6
|
-
import { buildConfig } from 'payload';
|
|
2
|
+
import { $generateHtmlFromNodes, $generateNodesFromDOM } from '@lexical/html';
|
|
7
3
|
import { sqliteAdapter } from '@payloadcms/db-sqlite';
|
|
8
4
|
import { defaultEditorConfig, getEnabledNodes, lexicalEditor, sanitizeServerEditorConfig } from '@payloadcms/richtext-lexical';
|
|
5
|
+
import { JSDOM } from 'jsdom';
|
|
6
|
+
import { $getRoot, $getSelection } from 'lexical';
|
|
7
|
+
import { buildConfig, getPayload } from 'payload';
|
|
9
8
|
const loadEditor = async ()=>{
|
|
10
9
|
const config = {
|
|
11
|
-
secret:
|
|
10
|
+
secret: 'testing',
|
|
12
11
|
editor: lexicalEditor({
|
|
13
12
|
admin: {
|
|
14
13
|
hideGutter: false
|
|
@@ -36,24 +35,53 @@ const loadEditor = async ()=>{
|
|
|
36
35
|
* @param {string} html - The HTML string to convert.
|
|
37
36
|
* @returns {SerializedEditorState} The serialized editor state.
|
|
38
37
|
*/ export const htmlToLexical = (html)=>{
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
38
|
+
const editor = createHeadlessEditor({
|
|
39
|
+
nodes: [],
|
|
40
|
+
onError: (error)=>{
|
|
41
|
+
console.error(error);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
editor.update(()=>{
|
|
45
|
+
// In a headless environment you can use a package such as JSDom to parse the HTML string.
|
|
46
|
+
const dom = new JSDOM(`<!DOCTYPE html><body>${html}</body>`);
|
|
47
|
+
// Once you have the DOM instance it's easy to generate LexicalNodes.
|
|
48
|
+
const nodes = $generateNodesFromDOM(editor, dom.window.document);
|
|
49
|
+
// Select the root
|
|
50
|
+
$getRoot().select();
|
|
51
|
+
// Insert them at a selection.
|
|
52
|
+
const selection = $getSelection();
|
|
53
|
+
console.log('Generated nodes: ', nodes);
|
|
54
|
+
if (selection) selection.insertNodes(nodes);
|
|
55
|
+
}, {
|
|
56
|
+
discrete: true
|
|
55
57
|
});
|
|
56
|
-
return
|
|
58
|
+
return editor.getEditorState().toJSON();
|
|
59
|
+
// let state = {};
|
|
60
|
+
//
|
|
61
|
+
// loadEditor().then((editor) => {
|
|
62
|
+
// editor.update(
|
|
63
|
+
// () => {
|
|
64
|
+
// // In a headless environment you can use a package such as JSDom to parse the HTML string.
|
|
65
|
+
// const dom = new JSDOM(`<!DOCTYPE html><body>${html}</body>`);
|
|
66
|
+
//
|
|
67
|
+
// // Once you have the DOM instance it's easy to generate LexicalNodes.
|
|
68
|
+
// const nodes = $generateNodesFromDOM(editor, dom.window.document);
|
|
69
|
+
//
|
|
70
|
+
// // Select the root
|
|
71
|
+
// $getRoot().select();
|
|
72
|
+
//
|
|
73
|
+
// // Insert them at a selection.
|
|
74
|
+
// const selection = $getSelection();
|
|
75
|
+
//
|
|
76
|
+
// if (selection) selection.insertNodes(nodes);
|
|
77
|
+
// },
|
|
78
|
+
// { discrete: true },
|
|
79
|
+
// );
|
|
80
|
+
//
|
|
81
|
+
// state = editor.getEditorState().toJSON();
|
|
82
|
+
// });
|
|
83
|
+
//
|
|
84
|
+
// return state as SerializedEditorState;
|
|
57
85
|
};
|
|
58
86
|
/**
|
|
59
87
|
* Converts a Lexical editor state to an HTML string.
|
package/dist/util/lexical.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/util/lexical.ts"],"sourcesContent":["import { createHeadlessEditor } from '@lexical/headless';\nimport { $
|
|
1
|
+
{"version":3,"sources":["../../src/util/lexical.ts"],"sourcesContent":["import { createHeadlessEditor } from '@lexical/headless';\nimport { $generateHtmlFromNodes, $generateNodesFromDOM } from '@lexical/html';\nimport { sqliteAdapter } from '@payloadcms/db-sqlite';\nimport {\n\tdefaultEditorConfig,\n\tgetEnabledNodes,\n\tlexicalEditor,\n\tsanitizeServerEditorConfig,\n} from '@payloadcms/richtext-lexical';\nimport { JSDOM } from 'jsdom';\nimport { $getRoot, $getSelection, type LexicalEditor } from 'lexical';\nimport type { SerializedEditorState } from 'lexical';\nimport { buildConfig, getPayload } from 'payload';\nimport { importWithoutClientFiles } from 'payload/node';\n\nconst loadEditor = async (): Promise<LexicalEditor> => {\n\tconst config = {\n\t\tsecret: 'testing',\n\t\teditor: lexicalEditor({\n\t\t\tadmin: {\n\t\t\t\thideGutter: false,\n\t\t\t},\n\t\t}),\n\t\tdb: sqliteAdapter({\n\t\t\tclient: {\n\t\t\t\turl: 'file:./local.db',\n\t\t\t},\n\t\t}),\n\t};\n\n\tconst instance = await getPayload({\n\t\tconfig: buildConfig(config),\n\t});\n\n\tconst editorConfig = await sanitizeServerEditorConfig(defaultEditorConfig, instance.config);\n\n\treturn createHeadlessEditor({\n\t\tnodes: getEnabledNodes({\n\t\t\teditorConfig,\n\t\t}),\n\t});\n};\n\n/**\n * Converts an HTML string to a Lexical editor state.\n *\n * @param {string} html - The HTML string to convert.\n * @returns {SerializedEditorState} The serialized editor state.\n */\nexport const htmlToLexical = (html: string): SerializedEditorState => {\n\tconst editor = createHeadlessEditor({\n\t\tnodes: [],\n\t\tonError: (error) => {\n\t\t\tconsole.error(error);\n\t\t},\n\t});\n\n\teditor.update(\n\t\t() => {\n\t\t\t// In a headless environment you can use a package such as JSDom to parse the HTML string.\n\t\t\tconst dom = new JSDOM(`<!DOCTYPE html><body>${html}</body>`);\n\n\t\t\t// Once you have the DOM instance it's easy to generate LexicalNodes.\n\t\t\tconst nodes = $generateNodesFromDOM(editor, dom.window.document);\n\n\t\t\t// Select the root\n\t\t\t$getRoot().select();\n\n\t\t\t// Insert them at a selection.\n\t\t\tconst selection = $getSelection();\n\n\t\t\tconsole.log('Generated nodes: ', nodes);\n\n\t\t\tif (selection) selection.insertNodes(nodes);\n\t\t},\n\t\t{ discrete: true },\n\t);\n\n\treturn editor.getEditorState().toJSON();\n\n\t// let state = {};\n\t//\n\t// loadEditor().then((editor) => {\n\t// \teditor.update(\n\t// \t\t() => {\n\t// \t\t\t// In a headless environment you can use a package such as JSDom to parse the HTML string.\n\t// \t\t\tconst dom = new JSDOM(`<!DOCTYPE html><body>${html}</body>`);\n\t//\n\t// \t\t\t// Once you have the DOM instance it's easy to generate LexicalNodes.\n\t// \t\t\tconst nodes = $generateNodesFromDOM(editor, dom.window.document);\n\t//\n\t// \t\t\t// Select the root\n\t// \t\t\t$getRoot().select();\n\t//\n\t// \t\t\t// Insert them at a selection.\n\t// \t\t\tconst selection = $getSelection();\n\t//\n\t// \t\t\tif (selection) selection.insertNodes(nodes);\n\t// \t\t},\n\t// \t\t{ discrete: true },\n\t// \t);\n\t//\n\t// \tstate = editor.getEditorState().toJSON();\n\t// });\n\t//\n\t// return state as SerializedEditorState;\n};\n\n/**\n * Converts a Lexical editor state to an HTML string.\n *\n * @param {SerializedEditorState} json - The serialized editor state to convert.\n * @returns {string} The HTML string.\n */\nexport const lexicalToHtml = (json: SerializedEditorState): string => {\n\tconst editor = createHeadlessEditor({\n\t\tnodes: [],\n\t\tonError: (error) => {\n\t\t\tconsole.error(error);\n\t\t},\n\t});\n\n\t// Initialize a JSDOM instance\n\tconst dom = new JSDOM('');\n\n\t// @ts-ignore\n\tglobalThis.window = dom.window;\n\tglobalThis.document = dom.window.document;\n\n\teditor.update(() => {\n\t\tconst editorState = editor.parseEditorState(json);\n\t\teditor.setEditorState(editorState);\n\t});\n\n\t// Convert the editor state to HTML\n\tlet html = '';\n\teditor.getEditorState().read(() => {\n\t\thtml = $generateHtmlFromNodes(editor);\n\t});\n\n\treturn html;\n};\n"],"names":["createHeadlessEditor","$generateHtmlFromNodes","$generateNodesFromDOM","sqliteAdapter","defaultEditorConfig","getEnabledNodes","lexicalEditor","sanitizeServerEditorConfig","JSDOM","$getRoot","$getSelection","buildConfig","getPayload","loadEditor","config","secret","editor","admin","hideGutter","db","client","url","instance","editorConfig","nodes","htmlToLexical","html","onError","error","console","update","dom","window","document","select","selection","log","insertNodes","discrete","getEditorState","toJSON","lexicalToHtml","json","globalThis","editorState","parseEditorState","setEditorState","read"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,oBAAoB;AACzD,SAASC,sBAAsB,EAAEC,qBAAqB,QAAQ,gBAAgB;AAC9E,SAASC,aAAa,QAAQ,wBAAwB;AACtD,SACCC,mBAAmB,EACnBC,eAAe,EACfC,aAAa,EACbC,0BAA0B,QACpB,+BAA+B;AACtC,SAASC,KAAK,QAAQ,QAAQ;AAC9B,SAASC,QAAQ,EAAEC,aAAa,QAA4B,UAAU;AAEtE,SAASC,WAAW,EAAEC,UAAU,QAAQ,UAAU;AAGlD,MAAMC,aAAa;IAClB,MAAMC,SAAS;QACdC,QAAQ;QACRC,QAAQV,cAAc;YACrBW,OAAO;gBACNC,YAAY;YACb;QACD;QACAC,IAAIhB,cAAc;YACjBiB,QAAQ;gBACPC,KAAK;YACN;QACD;IACD;IAEA,MAAMC,WAAW,MAAMV,WAAW;QACjCE,QAAQH,YAAYG;IACrB;IAEA,MAAMS,eAAe,MAAMhB,2BAA2BH,qBAAqBkB,SAASR,MAAM;IAE1F,OAAOd,qBAAqB;QAC3BwB,OAAOnB,gBAAgB;YACtBkB;QACD;IACD;AACD;AAEA;;;;;CAKC,GACD,OAAO,MAAME,gBAAgB,CAACC;IAC7B,MAAMV,SAAShB,qBAAqB;QACnCwB,OAAO,EAAE;QACTG,SAAS,CAACC;YACTC,QAAQD,KAAK,CAACA;QACf;IACD;IAEAZ,OAAOc,MAAM,CACZ;QACC,0FAA0F;QAC1F,MAAMC,MAAM,IAAIvB,MAAM,CAAC,qBAAqB,EAAEkB,KAAK,OAAO,CAAC;QAE3D,qEAAqE;QACrE,MAAMF,QAAQtB,sBAAsBc,QAAQe,IAAIC,MAAM,CAACC,QAAQ;QAE/D,kBAAkB;QAClBxB,WAAWyB,MAAM;QAEjB,8BAA8B;QAC9B,MAAMC,YAAYzB;QAElBmB,QAAQO,GAAG,CAAC,qBAAqBZ;QAEjC,IAAIW,WAAWA,UAAUE,WAAW,CAACb;IACtC,GACA;QAAEc,UAAU;IAAK;IAGlB,OAAOtB,OAAOuB,cAAc,GAAGC,MAAM;AAErC,kBAAkB;AAClB,EAAE;AACF,kCAAkC;AAClC,kBAAkB;AAClB,YAAY;AACZ,gGAAgG;AAChG,mEAAmE;AACnE,EAAE;AACF,2EAA2E;AAC3E,uEAAuE;AACvE,EAAE;AACF,wBAAwB;AACxB,0BAA0B;AAC1B,EAAE;AACF,oCAAoC;AACpC,wCAAwC;AACxC,EAAE;AACF,kDAAkD;AAClD,OAAO;AACP,wBAAwB;AACxB,MAAM;AACN,EAAE;AACF,6CAA6C;AAC7C,MAAM;AACN,EAAE;AACF,yCAAyC;AAC1C,EAAE;AAEF;;;;;CAKC,GACD,OAAO,MAAMC,gBAAgB,CAACC;IAC7B,MAAM1B,SAAShB,qBAAqB;QACnCwB,OAAO,EAAE;QACTG,SAAS,CAACC;YACTC,QAAQD,KAAK,CAACA;QACf;IACD;IAEA,8BAA8B;IAC9B,MAAMG,MAAM,IAAIvB,MAAM;IAEtB,aAAa;IACbmC,WAAWX,MAAM,GAAGD,IAAIC,MAAM;IAC9BW,WAAWV,QAAQ,GAAGF,IAAIC,MAAM,CAACC,QAAQ;IAEzCjB,OAAOc,MAAM,CAAC;QACb,MAAMc,cAAc5B,OAAO6B,gBAAgB,CAACH;QAC5C1B,OAAO8B,cAAc,CAACF;IACvB;IAEA,mCAAmC;IACnC,IAAIlB,OAAO;IACXV,OAAOuB,cAAc,GAAGQ,IAAI,CAAC;QAC5BrB,OAAOzB,uBAAuBe;IAC/B;IAEA,OAAOU;AACR,EAAE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ainsleydev/payload-helper",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"description": "Payload CMS utilities, collections and global types for ainsley.dev builds",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"build:types": "tsc --emitDeclarationOnly --outDir dist",
|
|
24
24
|
"format": "biome format --write . --apply-unsafe --organise-imports",
|
|
25
25
|
"lint": "biome lint --write .",
|
|
26
|
-
"release": "npm publish --access public",
|
|
26
|
+
"release": "pnpm build && npm publish --access public",
|
|
27
27
|
"clean": "rimraf {dist,*.tsbuildinfo}",
|
|
28
28
|
"test": "jest"
|
|
29
29
|
},
|