@ainsleydev/payload-helper 0.0.7 → 0.0.8

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.
Files changed (66) hide show
  1. package/package.json +2 -2
  2. package/dist/cli/bin.d.ts +0 -2
  3. package/dist/cli/bin.js +0 -17
  4. package/dist/cli/bin.js.map +0 -1
  5. package/dist/cli/types.d.ts +0 -4
  6. package/dist/cli/types.js +0 -34
  7. package/dist/cli/types.js.map +0 -1
  8. package/dist/collections/Media.d.ts +0 -10
  9. package/dist/collections/Media.js +0 -150
  10. package/dist/collections/Media.js.map +0 -1
  11. package/dist/collections/Redirects.d.ts +0 -10
  12. package/dist/collections/Redirects.js +0 -72
  13. package/dist/collections/Redirects.js.map +0 -1
  14. package/dist/common/SEO.d.ts +0 -6
  15. package/dist/common/SEO.js +0 -45
  16. package/dist/common/SEO.js.map +0 -1
  17. package/dist/endpoints/slug.d.ts +0 -7
  18. package/dist/endpoints/slug.js +0 -39
  19. package/dist/endpoints/slug.js.map +0 -1
  20. package/dist/globals/Navigation.d.ts +0 -28
  21. package/dist/globals/Navigation.js +0 -138
  22. package/dist/globals/Navigation.js.map +0 -1
  23. package/dist/globals/Settings.d.ts +0 -10
  24. package/dist/globals/Settings.js +0 -346
  25. package/dist/globals/Settings.js.map +0 -1
  26. package/dist/globals/countries.d.ts +0 -1
  27. package/dist/globals/countries.js +0 -198
  28. package/dist/globals/countries.js.map +0 -1
  29. package/dist/globals/locales.d.ts +0 -7
  30. package/dist/globals/locales.js +0 -2664
  31. package/dist/globals/locales.js.map +0 -1
  32. package/dist/index.d.ts +0 -9
  33. package/dist/index.js +0 -22
  34. package/dist/index.js.map +0 -1
  35. package/dist/plugin/schema.d.ts +0 -21
  36. package/dist/plugin/schema.js +0 -239
  37. package/dist/plugin/schema.js.map +0 -1
  38. package/dist/seed/down.d.ts +0 -13
  39. package/dist/seed/down.js +0 -35
  40. package/dist/seed/down.js.map +0 -1
  41. package/dist/seed/seed.d.ts +0 -31
  42. package/dist/seed/seed.js +0 -58
  43. package/dist/seed/seed.js.map +0 -1
  44. package/dist/seed/types.d.ts +0 -125
  45. package/dist/seed/types.js +0 -3
  46. package/dist/seed/types.js.map +0 -1
  47. package/dist/seed/up.d.ts +0 -23
  48. package/dist/seed/up.js +0 -55
  49. package/dist/seed/up.js.map +0 -1
  50. package/dist/types.d.ts +0 -10
  51. package/dist/types.js +0 -4
  52. package/dist/types.js.map +0 -1
  53. package/dist/util/env.d.ts +0 -12
  54. package/dist/util/env.js +0 -75
  55. package/dist/util/env.js.map +0 -1
  56. package/dist/util/fields.d.ts +0 -7
  57. package/dist/util/fields.js +0 -12
  58. package/dist/util/fields.js.map +0 -1
  59. package/dist/util/lexical.d.ts +0 -15
  60. package/dist/util/lexical.js +0 -87
  61. package/dist/util/lexical.js.map +0 -1
  62. package/dist/util/lexical.test.js +0 -21
  63. package/dist/util/lexical.test.js.map +0 -1
  64. package/dist/util/validation.d.ts +0 -2
  65. package/dist/util/validation.js +0 -23
  66. package/dist/util/validation.js.map +0 -1
package/dist/seed/seed.js DELETED
@@ -1,58 +0,0 @@
1
- import dotenv from 'dotenv';
2
- import { commitTransaction, getPayload, initTransaction, killTransaction } from 'payload';
3
- import { importConfig } from 'payload/node';
4
- import { down } from './down.js';
5
- import { up } from './up.js';
6
- export var DBAdapter;
7
- (function(DBAdapter) {
8
- DBAdapter["Postgres"] = "postgres";
9
- })(DBAdapter || (DBAdapter = {}));
10
- /**
11
- * Seeds the database with initial data.
12
- *
13
- * @param opts - The options for seeding.
14
- * @returns A promise that resolves when the seeding is complete.
15
- */ export const seed = (opts)=>{
16
- const fn = async ()=>{
17
- dotenv.config({
18
- path: opts.envPath
19
- });
20
- for (const fn of [
21
- down,
22
- up
23
- ]){
24
- if (fn === down) {
25
- process.env.PAYLOAD_DROP_DATABASE = 'true';
26
- } else {
27
- delete process.env.PAYLOAD_DROP_DATABASE; // Ensure it is not set for other functions
28
- }
29
- const config = await importConfig(opts.configPath);
30
- const payload = await getPayload({
31
- config
32
- });
33
- const req = {
34
- payload
35
- };
36
- await initTransaction(req);
37
- try {
38
- await fn({
39
- payload,
40
- req,
41
- seeder: opts.seeder
42
- });
43
- payload.logger.info('Seed complete');
44
- await commitTransaction(req);
45
- } catch (err) {
46
- const message = err instanceof Error ? err.message : 'Unknown error';
47
- payload.logger.error(`Seed failed: ${message}`);
48
- await killTransaction(req);
49
- }
50
- }
51
- };
52
- fn().then(()=>process.exit(0)).catch((e)=>{
53
- console.error(e);
54
- process.exit(1);
55
- });
56
- };
57
-
58
- //# sourceMappingURL=seed.js.map
@@ -1 +0,0 @@
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\ttype Payload,\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().then(() => process.exit(0)).catch((e) => {\n\t\tconsole.error(e);\n\t\tprocess.exit(1);\n\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,SAECC,iBAAiB,EACjBC,UAAU,EACVC,eAAe,EACfC,eAAe,QAET,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,KAAKiB,IAAI,CAAC,IAAMb,QAAQc,IAAI,CAAC,IAAIC,KAAK,CAAC,CAACC;QACvCC,QAAQL,KAAK,CAACI;QACdhB,QAAQc,IAAI,CAAC;IACd;AACD,EAAE"}
@@ -1,125 +0,0 @@
1
- export interface MediaSeed {
2
- path: string;
3
- alt: string;
4
- caption?: string;
5
- }
6
- export interface Media {
7
- id: number;
8
- alt: string;
9
- caption?: {
10
- root: {
11
- type: string;
12
- children: {
13
- type: string;
14
- version: number;
15
- [k: string]: unknown;
16
- }[];
17
- direction: ('ltr' | 'rtl') | null;
18
- format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | '';
19
- indent: number;
20
- version: number;
21
- };
22
- [k: string]: unknown;
23
- } | null;
24
- updatedAt: string;
25
- createdAt: string;
26
- url?: string | null;
27
- thumbnailURL?: string | null;
28
- filename?: string | null;
29
- mimeType?: string | null;
30
- filesize?: number | null;
31
- width?: number | null;
32
- height?: number | null;
33
- focalX?: number | null;
34
- focalY?: number | null;
35
- sizes?: {
36
- webp?: {
37
- url?: string | null;
38
- width?: number | null;
39
- height?: number | null;
40
- mimeType?: string | null;
41
- filesize?: number | null;
42
- filename?: string | null;
43
- };
44
- avif?: {
45
- url?: string | null;
46
- width?: number | null;
47
- height?: number | null;
48
- mimeType?: string | null;
49
- filesize?: number | null;
50
- filename?: string | null;
51
- };
52
- thumbnail?: {
53
- url?: string | null;
54
- width?: number | null;
55
- height?: number | null;
56
- mimeType?: string | null;
57
- filesize?: number | null;
58
- filename?: string | null;
59
- };
60
- thumbnail_webp?: {
61
- url?: string | null;
62
- width?: number | null;
63
- height?: number | null;
64
- mimeType?: string | null;
65
- filesize?: number | null;
66
- filename?: string | null;
67
- };
68
- thumbnail_avif?: {
69
- url?: string | null;
70
- width?: number | null;
71
- height?: number | null;
72
- mimeType?: string | null;
73
- filesize?: number | null;
74
- filename?: string | null;
75
- };
76
- mobile?: {
77
- url?: string | null;
78
- width?: number | null;
79
- height?: number | null;
80
- mimeType?: string | null;
81
- filesize?: number | null;
82
- filename?: string | null;
83
- };
84
- mobile_webp?: {
85
- url?: string | null;
86
- width?: number | null;
87
- height?: number | null;
88
- mimeType?: string | null;
89
- filesize?: number | null;
90
- filename?: string | null;
91
- };
92
- mobile_avif?: {
93
- url?: string | null;
94
- width?: number | null;
95
- height?: number | null;
96
- mimeType?: string | null;
97
- filesize?: number | null;
98
- filename?: string | null;
99
- };
100
- tablet?: {
101
- url?: string | null;
102
- width?: number | null;
103
- height?: number | null;
104
- mimeType?: string | null;
105
- filesize?: number | null;
106
- filename?: string | null;
107
- };
108
- tablet_webp?: {
109
- url?: string | null;
110
- width?: number | null;
111
- height?: number | null;
112
- mimeType?: string | null;
113
- filesize?: number | null;
114
- filename?: string | null;
115
- };
116
- tablet_avif?: {
117
- url?: string | null;
118
- width?: number | null;
119
- height?: number | null;
120
- mimeType?: string | null;
121
- filesize?: number | null;
122
- filename?: string | null;
123
- };
124
- };
125
- }
@@ -1,3 +0,0 @@
1
- export { };
2
-
3
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/seed/types.ts"],"sourcesContent":["export interface MediaSeed {\n\tpath: string;\n\talt: string;\n\tcaption?: string;\n}\n\nexport interface Media {\n\tid: number;\n\talt: string;\n\tcaption?: {\n\t\troot: {\n\t\t\ttype: string;\n\t\t\tchildren: {\n\t\t\t\ttype: string;\n\t\t\t\tversion: number;\n\t\t\t\t[k: string]: unknown;\n\t\t\t}[];\n\t\t\tdirection: ('ltr' | 'rtl') | null;\n\t\t\tformat: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | '';\n\t\t\tindent: number;\n\t\t\tversion: number;\n\t\t};\n\t\t[k: string]: unknown;\n\t} | null;\n\tupdatedAt: string;\n\tcreatedAt: string;\n\turl?: string | null;\n\tthumbnailURL?: string | null;\n\tfilename?: string | null;\n\tmimeType?: string | null;\n\tfilesize?: number | null;\n\twidth?: number | null;\n\theight?: number | null;\n\tfocalX?: number | null;\n\tfocalY?: number | null;\n\tsizes?: {\n\t\twebp?: {\n\t\t\turl?: string | null;\n\t\t\twidth?: number | null;\n\t\t\theight?: number | null;\n\t\t\tmimeType?: string | null;\n\t\t\tfilesize?: number | null;\n\t\t\tfilename?: string | null;\n\t\t};\n\t\tavif?: {\n\t\t\turl?: string | null;\n\t\t\twidth?: number | null;\n\t\t\theight?: number | null;\n\t\t\tmimeType?: string | null;\n\t\t\tfilesize?: number | null;\n\t\t\tfilename?: string | null;\n\t\t};\n\t\tthumbnail?: {\n\t\t\turl?: string | null;\n\t\t\twidth?: number | null;\n\t\t\theight?: number | null;\n\t\t\tmimeType?: string | null;\n\t\t\tfilesize?: number | null;\n\t\t\tfilename?: string | null;\n\t\t};\n\t\tthumbnail_webp?: {\n\t\t\turl?: string | null;\n\t\t\twidth?: number | null;\n\t\t\theight?: number | null;\n\t\t\tmimeType?: string | null;\n\t\t\tfilesize?: number | null;\n\t\t\tfilename?: string | null;\n\t\t};\n\t\tthumbnail_avif?: {\n\t\t\turl?: string | null;\n\t\t\twidth?: number | null;\n\t\t\theight?: number | null;\n\t\t\tmimeType?: string | null;\n\t\t\tfilesize?: number | null;\n\t\t\tfilename?: string | null;\n\t\t};\n\t\tmobile?: {\n\t\t\turl?: string | null;\n\t\t\twidth?: number | null;\n\t\t\theight?: number | null;\n\t\t\tmimeType?: string | null;\n\t\t\tfilesize?: number | null;\n\t\t\tfilename?: string | null;\n\t\t};\n\t\tmobile_webp?: {\n\t\t\turl?: string | null;\n\t\t\twidth?: number | null;\n\t\t\theight?: number | null;\n\t\t\tmimeType?: string | null;\n\t\t\tfilesize?: number | null;\n\t\t\tfilename?: string | null;\n\t\t};\n\t\tmobile_avif?: {\n\t\t\turl?: string | null;\n\t\t\twidth?: number | null;\n\t\t\theight?: number | null;\n\t\t\tmimeType?: string | null;\n\t\t\tfilesize?: number | null;\n\t\t\tfilename?: string | null;\n\t\t};\n\t\ttablet?: {\n\t\t\turl?: string | null;\n\t\t\twidth?: number | null;\n\t\t\theight?: number | null;\n\t\t\tmimeType?: string | null;\n\t\t\tfilesize?: number | null;\n\t\t\tfilename?: string | null;\n\t\t};\n\t\ttablet_webp?: {\n\t\t\turl?: string | null;\n\t\t\twidth?: number | null;\n\t\t\theight?: number | null;\n\t\t\tmimeType?: string | null;\n\t\t\tfilesize?: number | null;\n\t\t\tfilename?: string | null;\n\t\t};\n\t\ttablet_avif?: {\n\t\t\turl?: string | null;\n\t\t\twidth?: number | null;\n\t\t\theight?: number | null;\n\t\t\tmimeType?: string | null;\n\t\t\tfilesize?: number | null;\n\t\t\tfilename?: string | null;\n\t\t};\n\t};\n}\n"],"names":[],"mappings":"AAMA,WAuHC"}
package/dist/seed/up.d.ts DELETED
@@ -1,23 +0,0 @@
1
- import type { Payload, PayloadRequest } from 'payload';
2
- import type { Media, MediaSeed } from './types.js';
3
- import type { Seeder } from "./seed.js";
4
- /**
5
- *
6
- * @param req
7
- * @param payload
8
- * @param dirname
9
- * @param media
10
- */
11
- export declare const uploadMedia: (req: PayloadRequest, payload: Payload, dirname: string, media: MediaSeed) => Promise<Media>;
12
- /**
13
- * Up script to create tables and seed data.
14
- *
15
- * @param payload
16
- * @param req
17
- * @param seeder
18
- */
19
- export declare const up: ({ payload, req, seeder, }: {
20
- payload: Payload;
21
- req: PayloadRequest;
22
- seeder: Seeder;
23
- }) => Promise<void>;
package/dist/seed/up.js DELETED
@@ -1,55 +0,0 @@
1
- import path from 'node:path';
2
- import { getFileByPath } from 'payload';
3
- import { htmlToLexical } from '../util/lexical.js';
4
- /**
5
- *
6
- * @param req
7
- * @param payload
8
- * @param dirname
9
- * @param media
10
- */ export const uploadMedia = async (req, payload, dirname, media)=>{
11
- try {
12
- const image = await getFileByPath(path.resolve(dirname, media.path));
13
- const caption = media.caption ? await htmlToLexical(media.caption) : null;
14
- return await payload.create({
15
- collection: 'media',
16
- file: image,
17
- data: {
18
- alt: media.alt,
19
- caption: caption
20
- },
21
- req
22
- });
23
- } catch (error) {
24
- payload.logger.error(`Uploading media: ${error}`);
25
- throw error;
26
- }
27
- };
28
- /**
29
- * Up script to create tables and seed data.
30
- *
31
- * @param payload
32
- * @param req
33
- * @param seeder
34
- */ export const up = async ({ payload, req, seeder })=>{
35
- payload.logger.info('Running up script');
36
- await payload.init({
37
- config: payload.config
38
- });
39
- // Creating new tables
40
- payload.logger.info('Creating indexes...');
41
- try {
42
- if (payload.db.init) {
43
- await payload.db.init();
44
- }
45
- } catch (error) {
46
- payload.logger.error(`Creating database: ${error}`);
47
- return;
48
- }
49
- await seeder({
50
- payload,
51
- req
52
- });
53
- };
54
-
55
- //# sourceMappingURL=up.js.map
@@ -1 +0,0 @@
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 type { Media, MediaSeed } from './types.js';\nimport { htmlToLexical } from '../util/lexical.js';\nimport type {Seeder} from \"./seed.js\";\n\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;AAExC,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/types.d.ts DELETED
@@ -1,10 +0,0 @@
1
- import type { GlobalConfig, Tab } from 'payload';
2
- export type SettingsConfig = {
3
- additionalTabs?: Tab[];
4
- override: (args: {
5
- config: GlobalConfig;
6
- }) => GlobalConfig;
7
- };
8
- export type PayloadHelperPluginConfig = {
9
- settings?: SettingsConfig;
10
- };
package/dist/types.js DELETED
@@ -1,4 +0,0 @@
1
- // import type { SEOPluginConfig } from "@payloadcms/plugin-seo/types";
2
- export { };
3
-
4
- //# sourceMappingURL=types.js.map
package/dist/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/types.ts"],"sourcesContent":["// import type { SEOPluginConfig } from \"@payloadcms/plugin-seo/types\";\nimport type { GlobalConfig, Tab } from 'payload';\n\nexport type SettingsConfig = {\n\tadditionalTabs?: Tab[];\n\toverride: (args: {\n\t\tconfig: GlobalConfig;\n\t}) => GlobalConfig;\n};\nexport type PayloadHelperPluginConfig = {\n\tsettings?: SettingsConfig;\n\t// seo?: (args: {\n\t// \tconfig: SEOPluginConfig;\n\t// }) => SEOPluginConfig;\n};\n"],"names":[],"mappings":"AAAA,uEAAuE;AASvE,WAKE"}
@@ -1,12 +0,0 @@
1
- declare function envFn<T>(key: string, defaultValue: T): string | T;
2
- declare const env: typeof envFn & {
3
- isProduction: boolean;
4
- int(key: string, defaultValue?: number): number | undefined;
5
- float(key: string, defaultValue?: number): number | undefined;
6
- bool(key: string, defaultValue?: boolean): boolean | undefined;
7
- json(key: string, defaultValue?: object): any;
8
- array(key: string, defaultValue?: string[]): string[] | undefined;
9
- date(key: string, defaultValue?: Date): Date | undefined;
10
- oneOf(key: string, expectedValues?: unknown[], defaultValue?: unknown): unknown;
11
- };
12
- export default env;
package/dist/util/env.js DELETED
@@ -1,75 +0,0 @@
1
- function hasKey(key) {
2
- return Object.prototype.hasOwnProperty.call(process.env, key);
3
- }
4
- function envFn(key, defaultValue) {
5
- return hasKey(key) ? process.env[key] : defaultValue;
6
- }
7
- function getKey(key) {
8
- return process.env[key] ?? '';
9
- }
10
- const utils = {
11
- isProduction: getKey('NODE_ENV') === 'production',
12
- int (key, defaultValue) {
13
- if (!hasKey(key)) {
14
- return defaultValue;
15
- }
16
- return parseInt(getKey(key), 10);
17
- },
18
- float (key, defaultValue) {
19
- if (!hasKey(key)) {
20
- return defaultValue;
21
- }
22
- return parseFloat(getKey(key));
23
- },
24
- bool (key, defaultValue) {
25
- if (!hasKey(key)) {
26
- return defaultValue;
27
- }
28
- return getKey(key) === 'true';
29
- },
30
- json (key, defaultValue) {
31
- if (!hasKey(key)) {
32
- return defaultValue;
33
- }
34
- try {
35
- return JSON.parse(getKey(key));
36
- } catch (error) {
37
- if (error instanceof Error) {
38
- throw new Error(`Invalid json environment variable ${key}: ${error.message}`);
39
- }
40
- throw error;
41
- }
42
- },
43
- array (key, defaultValue) {
44
- if (!hasKey(key)) {
45
- return defaultValue;
46
- }
47
- let value = getKey(key);
48
- if (value.startsWith('[') && value.endsWith(']')) {
49
- value = value.substring(1, value.length - 1);
50
- }
51
- return value.split(',').map((v)=>{
52
- return v.trim().replace(/^"(.*)"$/, '$1');
53
- });
54
- },
55
- date (key, defaultValue) {
56
- if (!hasKey(key)) {
57
- return defaultValue;
58
- }
59
- return new Date(getKey(key));
60
- },
61
- oneOf (key, expectedValues, defaultValue) {
62
- if (!expectedValues) {
63
- throw new Error(`env.oneOf requires expectedValues`);
64
- }
65
- if (defaultValue && !expectedValues.includes(defaultValue)) {
66
- throw new Error(`env.oneOf requires defaultValue to be included in expectedValues`);
67
- }
68
- const rawValue = envFn(key, defaultValue);
69
- return expectedValues.includes(rawValue) ? rawValue : defaultValue;
70
- }
71
- };
72
- const env = Object.assign(envFn, utils);
73
- export default env;
74
-
75
- //# sourceMappingURL=env.js.map
@@ -1 +0,0 @@
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(`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","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,SAASJ,OAAOT,MAAM;IAC9B;IAEAc,OAAMd,GAAW,EAAEQ,YAAqB;QACvC,IAAI,CAACT,OAAOC,MAAM;YACjB,OAAOQ;QACR;QAEA,OAAOO,WAAWN,OAAOT;IAC1B;IAEAgB,MAAKhB,GAAW,EAAEQ,YAAsB;QACvC,IAAI,CAACT,OAAOC,MAAM;YACjB,OAAOQ;QACR;QAEA,OAAOC,OAAOT,SAAS;IACxB;IAEAiB,MAAKjB,GAAW,EAAEQ,YAAqB;QACtC,IAAI,CAACT,OAAOC,MAAM;YACjB,OAAOQ;QACR;QAEA,IAAI;YACH,OAAOU,KAAKC,KAAK,CAACV,OAAOT;QAC1B,EAAE,OAAOoB,OAAO;YACf,IAAIA,iBAAiBC,OAAO;gBAC3B,MAAM,IAAIA,MAAM,CAAC,kCAAkC,EAAErB,IAAI,EAAE,EAAEoB,MAAME,OAAO,CAAC,CAAC;YAC7E;YAEA,MAAMF;QACP;IACD;IAEAG,OAAMvB,GAAW,EAAEQ,YAAuB;QACzC,IAAI,CAACT,OAAOC,MAAM;YACjB,OAAOQ;QACR;QAEA,IAAIgB,QAAQf,OAAOT;QAEnB,IAAIwB,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,MAAKlC,GAAW,EAAEQ,YAAmB;QACpC,IAAI,CAACT,OAAOC,MAAM;YACjB,OAAOQ;QACR;QAEA,OAAO,IAAI2B,KAAK1B,OAAOT;IACxB;IAEAoC,OAAMpC,GAAW,EAAEqC,cAA0B,EAAE7B,YAAsB;QACpE,IAAI,CAAC6B,gBAAgB;YACpB,MAAM,IAAIhB,MAAM,CAAC,iCAAiC,CAAC;QACpD;QAEA,IAAIb,gBAAgB,CAAC6B,eAAeC,QAAQ,CAAC9B,eAAe;YAC3D,MAAM,IAAIa,MAAM,CAAC,gEAAgE,CAAC;QACnF;QAEA,MAAMkB,WAAWhC,MAAMP,KAAKQ;QAC5B,OAAO6B,eAAeC,QAAQ,CAACC,YAAYA,WAAW/B;IACvD;AACD;AAEA,MAAMF,MAAML,OAAOuC,MAAM,CAACjC,OAAOG;AAEjC,eAAeJ,IAAI"}
@@ -1,7 +0,0 @@
1
- import { Field } from 'payload';
2
- /**
3
- * Determines if a Payload field has a name property.
4
- *
5
- * @param field
6
- */
7
- export declare const fieldHasName: (field: Field) => boolean;
@@ -1,12 +0,0 @@
1
- /**
2
- * Determines if a Payload field has a name property.
3
- *
4
- * @param field
5
- */ export const fieldHasName = (field)=>{
6
- if (field.type === 'ui') {
7
- return false;
8
- }
9
- return field.type !== 'tabs' && field.type !== 'row' && field.type !== 'collapsible';
10
- };
11
-
12
- //# sourceMappingURL=fields.js.map
@@ -1 +0,0 @@
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,15 +0,0 @@
1
- import type { SerializedEditorState } from 'lexical';
2
- /**
3
- * Converts an HTML string to a Lexical editor state.
4
- *
5
- * @param {string} html - The HTML string to convert.
6
- * @returns {SerializedEditorState} The serialized editor state.
7
- */
8
- export declare const htmlToLexical: (html: string) => SerializedEditorState;
9
- /**
10
- * Converts a Lexical editor state to an HTML string.
11
- *
12
- * @param {SerializedEditorState} json - The serialized editor state to convert.
13
- * @returns {string} The HTML string.
14
- */
15
- export declare const lexicalToHtml: (json: SerializedEditorState) => string;
@@ -1,87 +0,0 @@
1
- import { createHeadlessEditor } from '@lexical/headless';
2
- import { $generateNodesFromDOM, $generateHtmlFromNodes } from '@lexical/html';
3
- import { $getRoot, $getSelection } from 'lexical';
4
- import { JSDOM } from 'jsdom';
5
- import { getPayload } from "payload";
6
- import { buildConfig } from 'payload';
7
- import { sqliteAdapter } from '@payloadcms/db-sqlite';
8
- import { defaultEditorConfig, getEnabledNodes, lexicalEditor, sanitizeServerEditorConfig } from '@payloadcms/richtext-lexical';
9
- const loadEditor = async ()=>{
10
- const config = {
11
- secret: "testing",
12
- editor: lexicalEditor({
13
- admin: {
14
- hideGutter: false
15
- }
16
- }),
17
- db: sqliteAdapter({
18
- client: {
19
- url: 'file:./local.db'
20
- }
21
- })
22
- };
23
- const instance = await getPayload({
24
- config: buildConfig(config)
25
- });
26
- const editorConfig = await sanitizeServerEditorConfig(defaultEditorConfig, instance.config);
27
- return createHeadlessEditor({
28
- nodes: getEnabledNodes({
29
- editorConfig
30
- })
31
- });
32
- };
33
- /**
34
- * Converts an HTML string to a Lexical editor state.
35
- *
36
- * @param {string} html - The HTML string to convert.
37
- * @returns {SerializedEditorState} The serialized editor state.
38
- */ export const htmlToLexical = (html)=>{
39
- let state = {};
40
- loadEditor().then((editor)=>{
41
- editor.update(()=>{
42
- // In a headless environment you can use a package such as JSDom to parse the HTML string.
43
- const dom = new JSDOM(`<!DOCTYPE html><body>${html}</body>`);
44
- // Once you have the DOM instance it's easy to generate LexicalNodes.
45
- const nodes = $generateNodesFromDOM(editor, dom.window.document);
46
- // Select the root
47
- $getRoot().select();
48
- // Insert them at a selection.
49
- const selection = $getSelection();
50
- if (selection) selection.insertNodes(nodes);
51
- }, {
52
- discrete: true
53
- });
54
- state = editor.getEditorState().toJSON();
55
- });
56
- return state;
57
- };
58
- /**
59
- * Converts a Lexical editor state to an HTML string.
60
- *
61
- * @param {SerializedEditorState} json - The serialized editor state to convert.
62
- * @returns {string} The HTML string.
63
- */ export const lexicalToHtml = (json)=>{
64
- const editor = createHeadlessEditor({
65
- nodes: [],
66
- onError: (error)=>{
67
- console.error(error);
68
- }
69
- });
70
- // Initialize a JSDOM instance
71
- const dom = new JSDOM('');
72
- // @ts-ignore
73
- globalThis.window = dom.window;
74
- globalThis.document = dom.window.document;
75
- editor.update(()=>{
76
- const editorState = editor.parseEditorState(json);
77
- editor.setEditorState(editorState);
78
- });
79
- // Convert the editor state to HTML
80
- let html = '';
81
- editor.getEditorState().read(()=>{
82
- html = $generateHtmlFromNodes(editor);
83
- });
84
- return html;
85
- };
86
-
87
- //# sourceMappingURL=lexical.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/util/lexical.ts"],"sourcesContent":["import { createHeadlessEditor } from '@lexical/headless';\nimport { $generateNodesFromDOM, $generateHtmlFromNodes } from '@lexical/html';\nimport {$getRoot, $getSelection, LexicalEditor} from 'lexical';\nimport { JSDOM } from 'jsdom';\nimport type { SerializedEditorState } from 'lexical';\nimport {getPayload, SanitizedConfig} from \"payload\";\nimport { Payload, buildConfig } from 'payload';\nimport { sqliteAdapter } from '@payloadcms/db-sqlite';\nimport {\n\tdefaultEditorConfig,\n\tgetEnabledNodes, lexicalEditor,\n\tsanitizeServerEditorConfig,\n} from '@payloadcms/richtext-lexical';\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(\n\t\tdefaultEditorConfig,\n\t\tinstance.config,\n\t);\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\tlet state = {};\n\n\tloadEditor().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\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\n\t\t\t\t// Select the root\n\t\t\t\t$getRoot().select();\n\n\t\t\t\t// Insert them at a selection.\n\t\t\t\tconst selection = $getSelection();\n\n\t\t\t\tif (selection) selection.insertNodes(nodes);\n\t\t\t},\n\t\t\t{ discrete: true },\n\t\t);\n\n\t\tstate = editor.getEditorState().toJSON();\n\t});\n\n\treturn 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","$generateNodesFromDOM","$generateHtmlFromNodes","$getRoot","$getSelection","JSDOM","getPayload","buildConfig","sqliteAdapter","defaultEditorConfig","getEnabledNodes","lexicalEditor","sanitizeServerEditorConfig","loadEditor","config","secret","editor","admin","hideGutter","db","client","url","instance","editorConfig","nodes","htmlToLexical","html","state","then","update","dom","window","document","select","selection","insertNodes","discrete","getEditorState","toJSON","lexicalToHtml","json","onError","error","console","globalThis","editorState","parseEditorState","setEditorState","read"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,oBAAoB;AACzD,SAASC,qBAAqB,EAAEC,sBAAsB,QAAQ,gBAAgB;AAC9E,SAAQC,QAAQ,EAAEC,aAAa,QAAsB,UAAU;AAC/D,SAASC,KAAK,QAAQ,QAAQ;AAE9B,SAAQC,UAAU,QAAwB,UAAU;AACpD,SAAkBC,WAAW,QAAQ,UAAU;AAC/C,SAASC,aAAa,QAAQ,wBAAwB;AACtD,SACCC,mBAAmB,EACnBC,eAAe,EAAEC,aAAa,EAC9BC,0BAA0B,QACpB,+BAA+B;AAEtC,MAAMC,aAAa;IAClB,MAAMC,SAAS;QACdC,QAAQ;QACRC,QAAQL,cAAc;YACrBM,OAAO;gBACNC,YAAY;YACb;QACD;QACAC,IAAIX,cAAc;YACjBY,QAAQ;gBACPC,KAAK;YACN;QACD;IACD;IAEA,MAAMC,WAAW,MAAMhB,WAAW;QACjCQ,QAAQP,YAAYO;IACrB;IAEA,MAAMS,eAAe,MAAMX,2BAC1BH,qBACAa,SAASR,MAAM;IAGhB,OAAOd,qBAAqB;QAC3BwB,OAAOd,gBAAgB;YACtBa;QACD;IACD;AACD;AAEA;;;;;CAKC,GACD,OAAO,MAAME,gBAAgB,CAACC;IAC7B,IAAIC,QAAQ,CAAC;IAEbd,aAAae,IAAI,CAACZ,CAAAA;QACjBA,OAAOa,MAAM,CACZ;YACC,0FAA0F;YAC1F,MAAMC,MAAM,IAAIzB,MAAM,CAAC,qBAAqB,EAAEqB,KAAK,OAAO,CAAC;YAE3D,qEAAqE;YACrE,MAAMF,QAAQvB,sBAAsBe,QAAQc,IAAIC,MAAM,CAACC,QAAQ;YAE/D,kBAAkB;YAClB7B,WAAW8B,MAAM;YAEjB,8BAA8B;YAC9B,MAAMC,YAAY9B;YAElB,IAAI8B,WAAWA,UAAUC,WAAW,CAACX;QACtC,GACA;YAAEY,UAAU;QAAK;QAGlBT,QAAQX,OAAOqB,cAAc,GAAGC,MAAM;IACvC;IAEA,OAAOX;AACR,EAAE;AAEF;;;;;CAKC,GACD,OAAO,MAAMY,gBAAgB,CAACC;IAC7B,MAAMxB,SAAShB,qBAAqB;QACnCwB,OAAO,EAAE;QACTiB,SAAS,CAACC;YACTC,QAAQD,KAAK,CAACA;QACf;IACD;IAEA,8BAA8B;IAC9B,MAAMZ,MAAM,IAAIzB,MAAM;IAEtB,aAAa;IACbuC,WAAWb,MAAM,GAAGD,IAAIC,MAAM;IAC9Ba,WAAWZ,QAAQ,GAAGF,IAAIC,MAAM,CAACC,QAAQ;IAEzChB,OAAOa,MAAM,CAAC;QACb,MAAMgB,cAAc7B,OAAO8B,gBAAgB,CAACN;QAC5CxB,OAAO+B,cAAc,CAACF;IACvB;IAEA,mCAAmC;IACnC,IAAInB,OAAO;IACXV,OAAOqB,cAAc,GAAGW,IAAI,CAAC;QAC5BtB,OAAOxB,uBAAuBc;IAC/B;IAEA,OAAOU;AACR,EAAE"}
@@ -1,21 +0,0 @@
1
- import { htmlToLexical } from './lexical';
2
- describe('htmlToLexical', ()=>{
3
- it('should convert an HTML string to a Lexical editor state', ()=>{
4
- const html = '<p>Hello, world!</p>';
5
- const editorState = htmlToLexical(html);
6
- expect(editorState).toEqual({
7
- nodes: [
8
- {
9
- type: 'paragraph',
10
- children: [
11
- {
12
- text: 'Hello, world!'
13
- }
14
- ]
15
- }
16
- ]
17
- });
18
- });
19
- });
20
-
21
- //# sourceMappingURL=lexical.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/util/lexical.test.ts"],"sourcesContent":["import { htmlToLexical } from './lexical';\n\ndescribe('htmlToLexical', () => {\n\tit('should convert an HTML string to a Lexical editor state', () => {\n\t\tconst html = '<p>Hello, world!</p>';\n\t\tconst editorState = htmlToLexical(html);\n\n\t\texpect(editorState).toEqual({\n\t\t\tnodes: [\n\t\t\t\t{\n\t\t\t\t\ttype: 'paragraph',\n\t\t\t\t\tchildren: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttext: 'Hello, world!',\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t],\n\t\t});\n\t});\n});\n"],"names":["htmlToLexical","describe","it","html","editorState","expect","toEqual","nodes","type","children","text"],"mappings":"AAAA,SAASA,aAAa,QAAQ,YAAY;AAE1CC,SAAS,iBAAiB;IACzBC,GAAG,2DAA2D;QAC7D,MAAMC,OAAO;QACb,MAAMC,cAAcJ,cAAcG;QAElCE,OAAOD,aAAaE,OAAO,CAAC;YAC3BC,OAAO;gBACN;oBACCC,MAAM;oBACNC,UAAU;wBACT;4BACCC,MAAM;wBACP;qBACA;gBACF;aACA;QACF;IACD;AACD"}
@@ -1,2 +0,0 @@
1
- export declare const validateURL: (value: string) => Promise<true | "Please enter a valid URL">;
2
- export declare const validatePostcode: (value: string) => Promise<true | "Invalid postcode format">;
@@ -1,23 +0,0 @@
1
- export const validateURL = async (value)=>{
2
- if (!value) {
3
- return true;
4
- }
5
- try {
6
- new URL(value);
7
- return true;
8
- } catch (error) {
9
- return 'Please enter a valid URL';
10
- }
11
- };
12
- export const validatePostcode = async (value)=>{
13
- if (!value) {
14
- return true;
15
- }
16
- const postcodeRegex = /^[A-Z]{1,2}\d[A-Z\d]? ?\d[A-Z]{2}$/i;
17
- if (!postcodeRegex.test(value)) {
18
- return 'Invalid postcode format';
19
- }
20
- return true;
21
- };
22
-
23
- //# sourceMappingURL=validation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/util/validation.ts"],"sourcesContent":["export const validateURL = async (value: string) => {\n\tif (!value) {\n\t\treturn true;\n\t}\n\ttry {\n\t\tnew URL(value);\n\t\treturn true;\n\t} catch (error) {\n\t\treturn 'Please enter a valid URL';\n\t}\n};\n\nexport const validatePostcode = async (value: string) => {\n\tif (!value) {\n\t\treturn true;\n\t}\n\tconst postcodeRegex = /^[A-Z]{1,2}\\d[A-Z\\d]? ?\\d[A-Z]{2}$/i;\n\tif (!postcodeRegex.test(value)) {\n\t\treturn 'Invalid postcode format';\n\t}\n\treturn true;\n};\n"],"names":["validateURL","value","URL","error","validatePostcode","postcodeRegex","test"],"mappings":"AAAA,OAAO,MAAMA,cAAc,OAAOC;IACjC,IAAI,CAACA,OAAO;QACX,OAAO;IACR;IACA,IAAI;QACH,IAAIC,IAAID;QACR,OAAO;IACR,EAAE,OAAOE,OAAO;QACf,OAAO;IACR;AACD,EAAE;AAEF,OAAO,MAAMC,mBAAmB,OAAOH;IACtC,IAAI,CAACA,OAAO;QACX,OAAO;IACR;IACA,MAAMI,gBAAgB;IACtB,IAAI,CAACA,cAAcC,IAAI,CAACL,QAAQ;QAC/B,OAAO;IACR;IACA,OAAO;AACR,EAAE"}