@ainsleydev/payload-helper 0.0.3 → 0.0.5
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/bin.js +7 -0
- package/dist/cli/bin.d.ts +2 -0
- package/dist/cli/bin.js +17 -0
- package/dist/cli/bin.js.map +1 -0
- package/dist/cli/types.d.ts +4 -0
- package/dist/cli/types.js +34 -0
- package/dist/cli/types.js.map +1 -0
- package/dist/collections/Media.js +150 -0
- package/dist/collections/Media.js.map +1 -0
- package/dist/collections/Redirects.js +72 -0
- package/dist/collections/Redirects.js.map +1 -0
- package/dist/common/SEO.js +45 -0
- package/dist/common/SEO.js.map +1 -0
- package/dist/endpoints/slug.js +39 -0
- package/dist/endpoints/slug.js.map +1 -0
- package/dist/globals/Navigation.js +138 -0
- package/dist/globals/Navigation.js.map +1 -0
- package/dist/globals/Settings.js +346 -0
- package/dist/globals/Settings.js.map +1 -0
- package/dist/globals/countries.js +198 -0
- package/dist/globals/countries.js.map +1 -0
- package/dist/globals/locales.js +2664 -0
- package/dist/globals/locales.js.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/jest.config.js +27 -0
- package/dist/jest.config.js.map +1 -0
- package/dist/plugin/schema.js +239 -0
- package/dist/plugin/schema.js.map +1 -0
- package/dist/util/env.js +75 -0
- package/dist/util/env.js.map +1 -0
- package/dist/util/fields.js +12 -0
- package/dist/util/fields.js.map +1 -0
- package/dist/util/lexical.js +53 -0
- package/dist/util/lexical.js.map +1 -0
- package/dist/util/lexical.test.js +21 -0
- package/dist/util/lexical.test.js.map +1 -0
- package/dist/util/validation.js +23 -0
- package/dist/util/validation.js.map +1 -0
- package/package.json +42 -10
- package/eslint.config.mjs +0 -4
- package/src/collections/Media.ts +0 -154
- package/src/collections/Redirects.ts +0 -56
- package/src/common/SEO.ts +0 -45
- package/src/endpoints/slug.ts +0 -32
- package/src/gen/schema.ts +0 -584
- package/src/globals/Navigation.ts +0 -165
- package/src/globals/Settings.ts +0 -356
- package/src/globals/countries.ts +0 -196
- package/src/globals/locales.ts +0 -2668
- package/src/scripts/.gitkeep +0 -0
- package/src/seed/.gitkeep +0 -0
- package/src/util/env.ts +0 -96
- package/src/util/validation.ts +0 -22
- package/tsconfig.json +0 -19
package/src/scripts/.gitkeep
DELETED
|
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;
|
package/src/util/validation.ts
DELETED
|
@@ -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
|
-
}
|