@ainsleydev/payload-helper 0.0.3 → 0.0.4

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 (49) hide show
  1. package/bin.js +7 -0
  2. package/dist/cli/bin.d.ts +2 -0
  3. package/dist/cli/bin.js +17 -0
  4. package/dist/cli/bin.js.map +1 -0
  5. package/dist/cli/types.d.ts +4 -0
  6. package/dist/cli/types.js +35 -0
  7. package/dist/cli/types.js.map +1 -0
  8. package/dist/collections/Media.js +156 -0
  9. package/dist/collections/Media.js.map +1 -0
  10. package/dist/collections/Redirects.js +72 -0
  11. package/dist/collections/Redirects.js.map +1 -0
  12. package/dist/common/SEO.js +45 -0
  13. package/dist/common/SEO.js.map +1 -0
  14. package/dist/endpoints/slug.js +39 -0
  15. package/dist/endpoints/slug.js.map +1 -0
  16. package/dist/globals/Navigation.js +138 -0
  17. package/dist/globals/Navigation.js.map +1 -0
  18. package/dist/globals/Settings.js +346 -0
  19. package/dist/globals/Settings.js.map +1 -0
  20. package/dist/globals/countries.js +198 -0
  21. package/dist/globals/countries.js.map +1 -0
  22. package/dist/globals/locales.js +2664 -0
  23. package/dist/globals/locales.js.map +1 -0
  24. package/dist/index.js +23 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/plugin/schema.js +239 -0
  27. package/dist/plugin/schema.js.map +1 -0
  28. package/dist/util/env.js +75 -0
  29. package/dist/util/env.js.map +1 -0
  30. package/dist/util/fields.js +12 -0
  31. package/dist/util/fields.js.map +1 -0
  32. package/dist/util/validation.js +23 -0
  33. package/dist/util/validation.js.map +1 -0
  34. package/package.json +42 -10
  35. package/eslint.config.mjs +0 -4
  36. package/src/collections/Media.ts +0 -154
  37. package/src/collections/Redirects.ts +0 -56
  38. package/src/common/SEO.ts +0 -45
  39. package/src/endpoints/slug.ts +0 -32
  40. package/src/gen/schema.ts +0 -584
  41. package/src/globals/Navigation.ts +0 -165
  42. package/src/globals/Settings.ts +0 -356
  43. package/src/globals/countries.ts +0 -196
  44. package/src/globals/locales.ts +0 -2668
  45. package/src/scripts/.gitkeep +0 -0
  46. package/src/seed/.gitkeep +0 -0
  47. package/src/util/env.ts +0 -96
  48. package/src/util/validation.ts +0 -22
  49. package/tsconfig.json +0 -19
File without changes
package/src/seed/.gitkeep DELETED
File without changes
package/src/util/env.ts DELETED
@@ -1,96 +0,0 @@
1
- function hasKey(key: string): boolean {
2
- return Object.prototype.hasOwnProperty.call(process.env, key);
3
- }
4
-
5
- function envFn<T>(key: string, defaultValue?: T): string | T | undefined {
6
- return hasKey(key) ? process.env[key] : defaultValue;
7
- }
8
-
9
- function getKey(key: string): string {
10
- return process.env[key] ?? '';
11
- }
12
-
13
- const utils = {
14
- isProduction: getKey('NODE_ENV') === 'production',
15
-
16
- int(key: string, defaultValue?: number): number | undefined {
17
- if (!hasKey(key)) {
18
- return defaultValue;
19
- }
20
-
21
- return parseInt(getKey(key), 10);
22
- },
23
-
24
- float(key: string, defaultValue?: number): number | undefined {
25
- if (!hasKey(key)) {
26
- return defaultValue;
27
- }
28
-
29
- return parseFloat(getKey(key));
30
- },
31
-
32
- bool(key: string, defaultValue?: boolean): boolean | undefined {
33
- if (!hasKey(key)) {
34
- return defaultValue;
35
- }
36
-
37
- return getKey(key) === 'true';
38
- },
39
-
40
- json(key: string, defaultValue?: object) {
41
- if (!hasKey(key)) {
42
- return defaultValue;
43
- }
44
-
45
- try {
46
- return JSON.parse(getKey(key));
47
- } catch (error) {
48
- if (error instanceof Error) {
49
- throw new Error(`Invalid json environment variable ${key}: ${error.message}`);
50
- }
51
-
52
- throw error;
53
- }
54
- },
55
-
56
- array(key: string, defaultValue?: string[]): string[] | undefined {
57
- if (!hasKey(key)) {
58
- return defaultValue;
59
- }
60
-
61
- let value = getKey(key);
62
-
63
- if (value.startsWith('[') && value.endsWith(']')) {
64
- value = value.substring(1, value.length - 1);
65
- }
66
-
67
- return value.split(',').map((v) => {
68
- return v.trim().replace(/^"(.*)"$/, '$1');
69
- });
70
- },
71
-
72
- date(key: string, defaultValue?: Date): Date | undefined {
73
- if (!hasKey(key)) {
74
- return defaultValue;
75
- }
76
-
77
- return new Date(getKey(key));
78
- },
79
-
80
- oneOf(key: string, expectedValues?: unknown[], defaultValue?: unknown) {
81
- if (!expectedValues) {
82
- throw new Error(`env.oneOf requires expectedValues`);
83
- }
84
-
85
- if (defaultValue && !expectedValues.includes(defaultValue)) {
86
- throw new Error(`env.oneOf requires defaultValue to be included in expectedValues`);
87
- }
88
-
89
- const rawValue = envFn(key, defaultValue);
90
- return expectedValues.includes(rawValue) ? rawValue : defaultValue;
91
- },
92
- };
93
-
94
- const env = Object.assign(envFn, utils);
95
-
96
- export default env;
@@ -1,22 +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
-
13
- export const validatePostcode = async (value) => {
14
- if (!value) {
15
- return true;
16
- }
17
- const postcodeRegex = /^[A-Z]{1,2}\d[A-Z\d]? ?\d[A-Z]{2}$/i;
18
- if (!postcodeRegex.test(value)) {
19
- return 'Invalid postcode format';
20
- }
21
- return true;
22
- };
package/tsconfig.json DELETED
@@ -1,19 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es5",
4
- "lib": ["dom", "dom.iterable", "esnext"],
5
- "allowJs": true,
6
- "strict": false,
7
- "esModuleInterop": true,
8
- "skipLibCheck": true,
9
- "outDir": "./dist",
10
- "rootDir": "./src",
11
- "jsx": "react"
12
- },
13
- "include": ["src"],
14
- "exclude": ["node_modules", "dist", "build"],
15
- "ts-node": {
16
- "transpileOnly": true,
17
- "swc": true
18
- }
19
- }