@ainsleydev/payload-helper 0.0.39 → 0.1.0

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 (39) hide show
  1. package/README.md +163 -0
  2. package/dist/admin/components/Icon.d.ts +16 -0
  3. package/dist/admin/components/Icon.js +26 -0
  4. package/dist/admin/components/Icon.js.map +1 -0
  5. package/dist/cli/bin.js +20 -0
  6. package/dist/cli/bin.js.map +1 -1
  7. package/dist/cli/commands/preview-emails.d.ts +5 -0
  8. package/dist/cli/commands/preview-emails.js +123 -0
  9. package/dist/cli/commands/preview-emails.js.map +1 -0
  10. package/dist/email/ForgotPasswordEmail.d.ts +38 -0
  11. package/dist/email/ForgotPasswordEmail.js +61 -0
  12. package/dist/email/ForgotPasswordEmail.js.map +1 -0
  13. package/dist/email/ForgotPasswordEmail.test.d.ts +1 -0
  14. package/dist/email/ForgotPasswordEmail.test.js +202 -0
  15. package/dist/email/ForgotPasswordEmail.test.js.map +1 -0
  16. package/dist/email/VerifyAccountEmail.d.ts +38 -0
  17. package/dist/email/VerifyAccountEmail.js +61 -0
  18. package/dist/email/VerifyAccountEmail.js.map +1 -0
  19. package/dist/email/VerifyAccountEmail.test.d.ts +1 -0
  20. package/dist/email/VerifyAccountEmail.test.js +212 -0
  21. package/dist/email/VerifyAccountEmail.test.js.map +1 -0
  22. package/dist/index.d.ts +7 -1
  23. package/dist/index.js +21 -4
  24. package/dist/index.js.map +1 -1
  25. package/dist/plugin/admin.d.ts +10 -0
  26. package/dist/plugin/admin.js +50 -0
  27. package/dist/plugin/admin.js.map +1 -0
  28. package/dist/plugin/email.d.ts +10 -0
  29. package/dist/plugin/email.js +98 -0
  30. package/dist/plugin/email.js.map +1 -0
  31. package/dist/plugin/email.test.js +265 -0
  32. package/dist/plugin/email.test.js.map +1 -0
  33. package/dist/types.d.ts +147 -1
  34. package/dist/types.js +3 -1
  35. package/dist/types.js.map +1 -1
  36. package/package.json +28 -15
  37. package/dist/plugin/logo.d.ts +0 -6
  38. package/dist/plugin/logo.js +0 -26
  39. package/dist/plugin/logo.js.map +0 -1
package/dist/types.d.ts CHANGED
@@ -1,26 +1,172 @@
1
+ import type { PartialEmailTheme } from '@ainsleydev/email-templates';
1
2
  import type { GlobalConfig, Tab } from 'payload';
3
+ /**
4
+ * Configuration for the Settings global.
5
+ */
2
6
  export type SettingsConfig = {
7
+ /**
8
+ * Additional tabs to add to the Settings global.
9
+ */
3
10
  additionalTabs?: Tab[];
11
+ /**
12
+ * Function to override the entire Settings global configuration.
13
+ */
4
14
  override: (args: {
5
15
  config: GlobalConfig;
6
16
  }) => GlobalConfig;
7
17
  };
18
+ /**
19
+ * Configuration for web server cache invalidation.
20
+ */
8
21
  export type WebServerConfig = {
22
+ /**
23
+ * Optional API key for authenticating cache invalidation requests.
24
+ */
9
25
  apiKey?: string;
26
+ /**
27
+ * Base URL of the web server.
28
+ */
10
29
  baseURL: string;
30
+ /**
31
+ * Endpoint path for cache invalidation.
32
+ */
11
33
  cacheEndpoint: string;
12
34
  };
35
+ /**
36
+ * Configuration for the admin panel logo.
37
+ */
13
38
  export type AdminLogoConfig = {
39
+ /**
40
+ * Path to the logo image file.
41
+ */
14
42
  path: string;
43
+ /**
44
+ * Optional path to the dark mode logo image file.
45
+ */
15
46
  darkModePath?: string;
47
+ /**
48
+ * Optional width of the logo in pixels.
49
+ */
16
50
  width?: number;
51
+ /**
52
+ * Optional height of the logo in pixels.
53
+ */
17
54
  height?: number;
55
+ /**
56
+ * Optional alt text for the logo image.
57
+ */
18
58
  alt?: string;
59
+ /**
60
+ * Optional CSS class name for the logo.
61
+ */
19
62
  className?: string;
20
63
  };
64
+ /**
65
+ * Configuration for the admin panel icon/favicon.
66
+ */
67
+ export type AdminIconConfig = {
68
+ /**
69
+ * Path to the icon image file.
70
+ */
71
+ path: string;
72
+ /**
73
+ * Optional path to the dark mode icon image file.
74
+ */
75
+ darkModePath?: string;
76
+ /**
77
+ * Optional width of the icon in pixels.
78
+ */
79
+ width?: number;
80
+ /**
81
+ * Optional height of the icon in pixels.
82
+ */
83
+ height?: number;
84
+ /**
85
+ * Optional alt text for the icon image.
86
+ */
87
+ alt?: string;
88
+ /**
89
+ * Optional CSS class name for the icon.
90
+ */
91
+ className?: string;
92
+ };
93
+ /**
94
+ * Configuration for admin panel customization.
95
+ */
96
+ export type AdminConfig = {
97
+ /**
98
+ * Optional logo configuration for the admin panel.
99
+ */
100
+ logo?: AdminLogoConfig;
101
+ /**
102
+ * Optional icon/favicon configuration for the admin panel.
103
+ */
104
+ icon?: AdminIconConfig;
105
+ };
106
+ /**
107
+ * Content overrides for customizing email template text.
108
+ */
109
+ export type EmailContentOverrides = {
110
+ /**
111
+ * Optional preview text shown in email clients before opening.
112
+ */
113
+ previewText?: string;
114
+ /**
115
+ * Optional heading text displayed at the top of the email.
116
+ */
117
+ heading?: string;
118
+ /**
119
+ * Optional body text content of the email.
120
+ */
121
+ bodyText?: string;
122
+ /**
123
+ * Optional button text for the call-to-action button.
124
+ */
125
+ buttonText?: string;
126
+ };
127
+ /**
128
+ * Configuration for email templates used in authentication flows.
129
+ */
130
+ export type EmailConfig = {
131
+ /**
132
+ * Optional front-end URL override for email links. If not provided, uses Payload's serverUrl.
133
+ */
134
+ frontEndUrl?: string;
135
+ /**
136
+ * Optional theme customization for email templates (colors, branding, etc.).
137
+ */
138
+ theme?: PartialEmailTheme;
139
+ /**
140
+ * Optional content overrides for the forgot password email template.
141
+ */
142
+ forgotPassword?: EmailContentOverrides;
143
+ /**
144
+ * Optional content overrides for the verify account email template.
145
+ */
146
+ verifyAccount?: EmailContentOverrides;
147
+ };
148
+ /**
149
+ * Main configuration object for the Payload Helper plugin.
150
+ */
21
151
  export type PayloadHelperPluginConfig = {
152
+ /**
153
+ * The name of the site, used throughout the admin panel and emails.
154
+ */
22
155
  siteName: string;
156
+ /**
157
+ * Optional settings global configuration.
158
+ */
23
159
  settings?: SettingsConfig;
160
+ /**
161
+ * Optional web server configuration for cache invalidation.
162
+ */
24
163
  webServer?: WebServerConfig;
25
- adminLogo?: AdminLogoConfig;
164
+ /**
165
+ * Optional admin panel customization (logo, icon).
166
+ */
167
+ admin?: AdminConfig;
168
+ /**
169
+ * Optional email template configuration for authentication emails.
170
+ */
171
+ email?: EmailConfig;
26
172
  };
package/dist/types.js CHANGED
@@ -1,4 +1,6 @@
1
1
  // import type { SEOPluginConfig } from "@payloadcms/plugin-seo/types";
2
- export { };
2
+ /**
3
+ * Main configuration object for the Payload Helper plugin.
4
+ */ export { };
3
5
 
4
6
  //# sourceMappingURL=types.js.map
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts"],"sourcesContent":["// import type { SEOPluginConfig } from \"@payloadcms/plugin-seo/types\";\nimport type { GlobalConfig, Tab, TextField, TextareaField, UploadField } from 'payload';\n// import type {SEOPluginConfig} from \"@payloadcms/plugin-seo/dist/types.js\";\n\nexport type SettingsConfig = {\n\tadditionalTabs?: Tab[];\n\toverride: (args: {\n\t\tconfig: GlobalConfig;\n\t}) => GlobalConfig;\n};\n\nexport type WebServerConfig = {\n\tapiKey?: string;\n\tbaseURL: string;\n\tcacheEndpoint: string;\n};\n\n// export type SEOConfig = Omit<SEOPluginConfig, 'uploadsCollection' | 'tabbedUI'>;\n//\n// export type S3Config = {\n// \tenabled: boolean;\n// \tbucket: string\n// \tconfig: AWS.S3ClientConfig;\n// }\n\nexport type AdminLogoConfig = {\n\tpath: string;\n\tdarkModePath?: string;\n\twidth?: number;\n\theight?: number;\n\talt?: string;\n\tclassName?: string;\n};\n\nexport type PayloadHelperPluginConfig = {\n\tsiteName: string;\n\tsettings?: SettingsConfig;\n\t// seo?: SEOConfig;\n\twebServer?: WebServerConfig;\n\tadminLogo?: AdminLogoConfig;\n};\n"],"names":[],"mappings":"AAAA,uEAAuE;AAkCvE,WAME"}
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["// import type { SEOPluginConfig } from \"@payloadcms/plugin-seo/types\";\nimport type { PartialEmailTheme } from '@ainsleydev/email-templates';\nimport type { GlobalConfig, Tab, TextField, TextareaField, UploadField } from 'payload';\n// import type {SEOPluginConfig} from \"@payloadcms/plugin-seo/dist/types.js\";\n\n/**\n * Configuration for the Settings global.\n */\nexport type SettingsConfig = {\n\t/**\n\t * Additional tabs to add to the Settings global.\n\t */\n\tadditionalTabs?: Tab[];\n\t/**\n\t * Function to override the entire Settings global configuration.\n\t */\n\toverride: (args: {\n\t\tconfig: GlobalConfig;\n\t}) => GlobalConfig;\n};\n\n/**\n * Configuration for web server cache invalidation.\n */\nexport type WebServerConfig = {\n\t/**\n\t * Optional API key for authenticating cache invalidation requests.\n\t */\n\tapiKey?: string;\n\t/**\n\t * Base URL of the web server.\n\t */\n\tbaseURL: string;\n\t/**\n\t * Endpoint path for cache invalidation.\n\t */\n\tcacheEndpoint: string;\n};\n\n// export type SEOConfig = Omit<SEOPluginConfig, 'uploadsCollection' | 'tabbedUI'>;\n//\n// export type S3Config = {\n// \tenabled: boolean;\n// \tbucket: string\n// \tconfig: AWS.S3ClientConfig;\n// }\n\n/**\n * Configuration for the admin panel logo.\n */\nexport type AdminLogoConfig = {\n\t/**\n\t * Path to the logo image file.\n\t */\n\tpath: string;\n\t/**\n\t * Optional path to the dark mode logo image file.\n\t */\n\tdarkModePath?: string;\n\t/**\n\t * Optional width of the logo in pixels.\n\t */\n\twidth?: number;\n\t/**\n\t * Optional height of the logo in pixels.\n\t */\n\theight?: number;\n\t/**\n\t * Optional alt text for the logo image.\n\t */\n\talt?: string;\n\t/**\n\t * Optional CSS class name for the logo.\n\t */\n\tclassName?: string;\n};\n\n/**\n * Configuration for the admin panel icon/favicon.\n */\nexport type AdminIconConfig = {\n\t/**\n\t * Path to the icon image file.\n\t */\n\tpath: string;\n\t/**\n\t * Optional path to the dark mode icon image file.\n\t */\n\tdarkModePath?: string;\n\t/**\n\t * Optional width of the icon in pixels.\n\t */\n\twidth?: number;\n\t/**\n\t * Optional height of the icon in pixels.\n\t */\n\theight?: number;\n\t/**\n\t * Optional alt text for the icon image.\n\t */\n\talt?: string;\n\t/**\n\t * Optional CSS class name for the icon.\n\t */\n\tclassName?: string;\n};\n\n/**\n * Configuration for admin panel customization.\n */\nexport type AdminConfig = {\n\t/**\n\t * Optional logo configuration for the admin panel.\n\t */\n\tlogo?: AdminLogoConfig;\n\t/**\n\t * Optional icon/favicon configuration for the admin panel.\n\t */\n\ticon?: AdminIconConfig;\n};\n\n/**\n * Content overrides for customizing email template text.\n */\nexport type EmailContentOverrides = {\n\t/**\n\t * Optional preview text shown in email clients before opening.\n\t */\n\tpreviewText?: string;\n\t/**\n\t * Optional heading text displayed at the top of the email.\n\t */\n\theading?: string;\n\t/**\n\t * Optional body text content of the email.\n\t */\n\tbodyText?: string;\n\t/**\n\t * Optional button text for the call-to-action button.\n\t */\n\tbuttonText?: string;\n};\n\n/**\n * Configuration for email templates used in authentication flows.\n */\nexport type EmailConfig = {\n\t/**\n\t * Optional front-end URL override for email links. If not provided, uses Payload's serverUrl.\n\t */\n\tfrontEndUrl?: string;\n\n\t/**\n\t * Optional theme customization for email templates (colors, branding, etc.).\n\t */\n\ttheme?: PartialEmailTheme;\n\n\t/**\n\t * Optional content overrides for the forgot password email template.\n\t */\n\tforgotPassword?: EmailContentOverrides;\n\n\t/**\n\t * Optional content overrides for the verify account email template.\n\t */\n\tverifyAccount?: EmailContentOverrides;\n};\n\n/**\n * Main configuration object for the Payload Helper plugin.\n */\nexport type PayloadHelperPluginConfig = {\n\t/**\n\t * The name of the site, used throughout the admin panel and emails.\n\t */\n\tsiteName: string;\n\t/**\n\t * Optional settings global configuration.\n\t */\n\tsettings?: SettingsConfig;\n\t// seo?: SEOConfig;\n\t/**\n\t * Optional web server configuration for cache invalidation.\n\t */\n\twebServer?: WebServerConfig;\n\t/**\n\t * Optional admin panel customization (logo, icon).\n\t */\n\tadmin?: AdminConfig;\n\t/**\n\t * Optional email template configuration for authentication emails.\n\t */\n\temail?: EmailConfig;\n};\n"],"names":[],"mappings":"AAAA,uEAAuE;AAwKvE;;CAEC,GACD,WAsBE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ainsleydev/payload-helper",
3
- "version": "0.0.39",
3
+ "version": "0.1.0",
4
4
  "description": "Payload CMS utilities, collections and global types for ainsley.dev builds",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -23,6 +23,19 @@
23
23
  },
24
24
  "main": "./dist/index.js",
25
25
  "types": "./dist/index.d.ts",
26
+ "exports": {
27
+ ".": {
28
+ "types": "./dist/index.d.ts",
29
+ "import": "./dist/index.js",
30
+ "default": "./dist/index.js"
31
+ },
32
+ "./dist/admin/components/*": {
33
+ "types": "./dist/admin/components/*.d.ts",
34
+ "import": "./dist/admin/components/*.js",
35
+ "default": "./dist/admin/components/*.js"
36
+ },
37
+ "./package.json": "./package.json"
38
+ },
26
39
  "bin": {
27
40
  "payload-helper": "bin.js"
28
41
  },
@@ -39,19 +52,20 @@
39
52
  "dependencies": {
40
53
  "@lexical/headless": "0.38.2",
41
54
  "@lexical/html": "0.38.2",
42
- "@nouance/payload-better-fields-plugin": "^1.4.1",
55
+ "@nouance/payload-better-fields-plugin": "^2.0.2",
43
56
  "@payloadcms/db-sqlite": "3.63.0",
44
57
  "@payloadcms/plugin-form-builder": "3.63.0",
45
58
  "@payloadcms/plugin-seo": "3.63.0",
46
59
  "@payloadcms/richtext-lexical": "3.63.0",
47
60
  "@types/json-schema": "^7.0.15",
48
61
  "chalk": "^5.3.0",
49
- "commander": "^12.1.0",
62
+ "commander": "^14.0.2",
50
63
  "dotenv": "^16.4.5",
51
- "jsdom": "^24.1.1",
52
- "lexical": "0.28.0",
53
- "mime-types": "^2.1.35",
54
- "payload": "3.63.0"
64
+ "jsdom": "^27.2.0",
65
+ "lexical": "0.38.2",
66
+ "mime-types": "^3.0.1",
67
+ "payload": "3.63.0",
68
+ "@ainsleydev/email-templates": "0.0.3"
55
69
  },
56
70
  "peerDependencies": {
57
71
  "@payloadcms/ui": "3.x",
@@ -59,23 +73,22 @@
59
73
  "react": "^18.0.0 || ^19.0.0"
60
74
  },
61
75
  "devDependencies": {
62
- "@jest/globals": "^29.7.0",
63
76
  "@payloadcms/ui": "3.63.0",
64
77
  "@swc/cli": "^0.7.8",
65
78
  "@swc/core": "^1.7.2",
66
- "@types/jest": "^29.5.12",
67
- "@types/jsdom": "^21.1.7",
68
- "@types/mime-types": "^2.1.4",
79
+ "@types/jest": "^30.0.0",
80
+ "@types/jsdom": "^27.0.0",
81
+ "@types/mime-types": "^3.0.1",
69
82
  "@types/node": "^24.10.1",
70
83
  "@types/react": "^18.3.26",
71
- "jest": "^29.7.0",
84
+ "jest": "^30.2.0",
72
85
  "json-schema": "^0.4.0",
73
86
  "next": "^16.0.1",
74
87
  "react": "^19.2.0",
75
88
  "rimraf": "6.1.0",
76
- "ts-jest": "^29.2.3",
77
89
  "ts-node": "^10.9.2",
78
90
  "typescript": "^5.5.4",
91
+ "vitest": "^2.0.5",
79
92
  "@ainsleydev/eslint-config": "0.0.9"
80
93
  },
81
94
  "engines": {
@@ -86,9 +99,9 @@
86
99
  "build": "pnpm clean && pnpm build:types && pnpm build:swc",
87
100
  "build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
88
101
  "build:types": "tsc --emitDeclarationOnly --outDir dist",
89
- "format": "biome format --write . --apply-unsafe --organise-imports",
102
+ "format": "biome check --write --unsafe .",
90
103
  "lint": "biome lint --write .",
91
104
  "clean": "rimraf {dist,*.tsbuildinfo}",
92
- "test": "jest --passWithNoTests"
105
+ "test": "vitest run"
93
106
  }
94
107
  }
@@ -1,6 +0,0 @@
1
- import type { Config } from 'payload';
2
- import type { AdminLogoConfig } from '../types.js';
3
- /**
4
- * Injects the admin Logo component into the Payload config.
5
- */
6
- export declare const injectAdminLogo: (config: Config, logoConfig: AdminLogoConfig, siteName: string) => Config;
@@ -1,26 +0,0 @@
1
- /**
2
- * Injects the admin Logo component into the Payload config.
3
- */ export const injectAdminLogo = (config, logoConfig, siteName)=>({
4
- ...config,
5
- admin: {
6
- ...config.admin,
7
- components: {
8
- ...config.admin?.components,
9
- graphics: {
10
- ...config.admin?.components?.graphics,
11
- Logo: {
12
- path: '@ainsleydev/payload-helper/dist/admin/components/Logo',
13
- exportName: 'Logo',
14
- clientProps: {
15
- config: {
16
- ...logoConfig,
17
- alt: logoConfig.alt || siteName
18
- }
19
- }
20
- }
21
- }
22
- }
23
- }
24
- });
25
-
26
- //# sourceMappingURL=logo.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/plugin/logo.ts"],"sourcesContent":["import type { Config } from 'payload';\nimport type { AdminLogoConfig } from '../types.js';\n\n/**\n * Injects the admin Logo component into the Payload config.\n */\nexport const injectAdminLogo = (\n\tconfig: Config,\n\tlogoConfig: AdminLogoConfig,\n\tsiteName: string,\n): Config => ({\n\t...config,\n\tadmin: {\n\t\t...config.admin,\n\t\tcomponents: {\n\t\t\t...config.admin?.components,\n\t\t\tgraphics: {\n\t\t\t\t...config.admin?.components?.graphics,\n\t\t\t\tLogo: {\n\t\t\t\t\tpath: '@ainsleydev/payload-helper/dist/admin/components/Logo',\n\t\t\t\t\texportName: 'Logo',\n\t\t\t\t\tclientProps: {\n\t\t\t\t\t\tconfig: {\n\t\t\t\t\t\t\t...logoConfig,\n\t\t\t\t\t\t\talt: logoConfig.alt || siteName,\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":["injectAdminLogo","config","logoConfig","siteName","admin","components","graphics","Logo","path","exportName","clientProps","alt"],"mappings":"AAGA;;CAEC,GACD,OAAO,MAAMA,kBAAkB,CAC9BC,QACAC,YACAC,WACa,CAAA;QACb,GAAGF,MAAM;QACTG,OAAO;YACN,GAAGH,OAAOG,KAAK;YACfC,YAAY;gBACX,GAAGJ,OAAOG,KAAK,EAAEC,UAAU;gBAC3BC,UAAU;oBACT,GAAGL,OAAOG,KAAK,EAAEC,YAAYC,QAAQ;oBACrCC,MAAM;wBACLC,MAAM;wBACNC,YAAY;wBACZC,aAAa;4BACZT,QAAQ;gCACP,GAAGC,UAAU;gCACbS,KAAKT,WAAWS,GAAG,IAAIR;4BACxB;wBACD;oBACD;gBACD;YACD;QACD;IACD,CAAA,EAAG"}