podverse-helpers 5.1.26-alpha.0 → 5.1.28-alpha.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.
- package/dist/dtos/account/accountDataExport.d.ts +119 -0
- package/dist/dtos/account/accountDataExport.d.ts.map +1 -0
- package/dist/dtos/account/accountDataExport.js +2 -0
- package/dist/dtos/index.d.ts +1 -0
- package/dist/dtos/index.d.ts.map +1 -1
- package/dist/dtos/index.js +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/lib/accountMembership.d.ts +15 -0
- package/dist/lib/accountMembership.d.ts.map +1 -1
- package/dist/lib/accountMembership.js +20 -0
- package/dist/lib/constants/index.d.ts +3 -0
- package/dist/lib/constants/index.d.ts.map +1 -0
- package/dist/lib/constants/index.js +18 -0
- package/dist/lib/constants/locales.d.ts +10 -0
- package/dist/lib/constants/locales.d.ts.map +1 -0
- package/dist/lib/constants/locales.js +12 -0
- package/dist/lib/constants/serverEnv.d.ts +11 -0
- package/dist/lib/constants/serverEnv.d.ts.map +1 -0
- package/dist/lib/constants/serverEnv.js +15 -0
- package/dist/lib/i18n/timeFormatter.d.ts.map +1 -1
- package/dist/lib/i18n/timeFormatter.js +2 -2
- package/dist/lib/requests/_request.d.ts.map +1 -1
- package/dist/lib/requests/_request.js +7 -4
- package/dist/lib/requests/api/_request.d.ts +38 -1
- package/dist/lib/requests/api/_request.d.ts.map +1 -1
- package/dist/lib/requests/api/_request.js +102 -3
- package/dist/lib/requests/api/account/account.d.ts +26 -1
- package/dist/lib/requests/api/account/account.d.ts.map +1 -1
- package/dist/lib/requests/api/account/account.js +147 -3
- package/dist/lib/requests/api/account/follow/account.d.ts +8 -0
- package/dist/lib/requests/api/account/follow/account.d.ts.map +1 -1
- package/dist/lib/requests/api/account/follow/account.js +39 -0
- package/dist/lib/requests/api/profile/profile.d.ts +16 -0
- package/dist/lib/requests/api/profile/profile.d.ts.map +1 -0
- package/dist/lib/requests/api/profile/profile.js +117 -0
- package/dist/lib/requests/api/queryParams.d.ts +14 -0
- package/dist/lib/requests/api/queryParams.d.ts.map +1 -1
- package/dist/lib/sharableStatus.d.ts +1 -0
- package/dist/lib/sharableStatus.d.ts.map +1 -1
- package/dist/lib/sharableStatus.js +11 -0
- package/dist/lib/validation/configValidation.d.ts +121 -0
- package/dist/lib/validation/configValidation.d.ts.map +1 -0
- package/dist/lib/validation/configValidation.js +204 -0
- package/dist/lib/validation/index.d.ts +2 -0
- package/dist/lib/validation/index.d.ts.map +1 -1
- package/dist/lib/validation/index.js +2 -0
- package/dist/lib/validation/startupValidation.d.ts +116 -0
- package/dist/lib/validation/startupValidation.d.ts.map +1 -0
- package/dist/lib/validation/startupValidation.js +497 -0
- package/dist/lib/validation/url.d.ts +36 -0
- package/dist/lib/validation/url.d.ts.map +1 -1
- package/dist/lib/validation/url.js +113 -0
- package/package.json +1 -4
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SharableStatusEnum = void 0;
|
|
4
|
+
exports.getSharableStatusIdsForProfileType = getSharableStatusIdsForProfileType;
|
|
4
5
|
var SharableStatusEnum;
|
|
5
6
|
(function (SharableStatusEnum) {
|
|
6
7
|
SharableStatusEnum[SharableStatusEnum["Public"] = 1] = "Public";
|
|
7
8
|
SharableStatusEnum[SharableStatusEnum["Unlisted"] = 2] = "Unlisted";
|
|
8
9
|
SharableStatusEnum[SharableStatusEnum["Private"] = 3] = "Private";
|
|
9
10
|
})(SharableStatusEnum || (exports.SharableStatusEnum = SharableStatusEnum = {}));
|
|
11
|
+
function getSharableStatusIdsForProfileType(type) {
|
|
12
|
+
switch (type) {
|
|
13
|
+
case 'global':
|
|
14
|
+
return [SharableStatusEnum.Public];
|
|
15
|
+
case 'subscribed':
|
|
16
|
+
return [SharableStatusEnum.Public, SharableStatusEnum.Unlisted];
|
|
17
|
+
default:
|
|
18
|
+
return [SharableStatusEnum.Public];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration validation utilities for podverse modules.
|
|
3
|
+
*
|
|
4
|
+
* These functions validate configuration objects that are passed to module factories.
|
|
5
|
+
* They should be called at app startup BEFORE creating module contexts.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const ormConfig: ORMConfig = { database: {...}, log: {...}, defaults: {...} };
|
|
10
|
+
* validateORMConfig(ormConfig); // Throws if invalid
|
|
11
|
+
* const ormContext = createORMContext(ormConfig);
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export type ConfigValidationError = {
|
|
15
|
+
field: string;
|
|
16
|
+
message: string;
|
|
17
|
+
required: boolean;
|
|
18
|
+
};
|
|
19
|
+
export type ConfigValidationResult = {
|
|
20
|
+
valid: boolean;
|
|
21
|
+
errors: ConfigValidationError[];
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Validates ORM configuration
|
|
25
|
+
*/
|
|
26
|
+
export type ORMConfig = {
|
|
27
|
+
nodeEnv?: string;
|
|
28
|
+
database: {
|
|
29
|
+
host: string;
|
|
30
|
+
port: number;
|
|
31
|
+
read_username: string;
|
|
32
|
+
read_password: string;
|
|
33
|
+
read_write_username: string;
|
|
34
|
+
read_write_password: string;
|
|
35
|
+
database: string;
|
|
36
|
+
ssl_connection: boolean;
|
|
37
|
+
};
|
|
38
|
+
log: {
|
|
39
|
+
level: string;
|
|
40
|
+
dir?: string;
|
|
41
|
+
timer?: boolean;
|
|
42
|
+
};
|
|
43
|
+
defaults: {
|
|
44
|
+
account: {
|
|
45
|
+
settings: {
|
|
46
|
+
locale: string;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
export declare function validateORMConfig(config: ORMConfig): ConfigValidationResult;
|
|
52
|
+
/**
|
|
53
|
+
* Validates Notifications configuration
|
|
54
|
+
*/
|
|
55
|
+
export type NotificationsConfig = {
|
|
56
|
+
brandName: string;
|
|
57
|
+
web: {
|
|
58
|
+
protocol: string;
|
|
59
|
+
host: string;
|
|
60
|
+
icon_image_path: string;
|
|
61
|
+
};
|
|
62
|
+
webpush: {
|
|
63
|
+
enabled: boolean;
|
|
64
|
+
vapid_public_key: string;
|
|
65
|
+
vapid_private_key: string;
|
|
66
|
+
vapid_subject: string;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
export declare function validateNotificationsConfig(config: NotificationsConfig): ConfigValidationResult;
|
|
70
|
+
/**
|
|
71
|
+
* Validates External Services configuration
|
|
72
|
+
*/
|
|
73
|
+
export type ExternalServicesConfig = {
|
|
74
|
+
firebase: {
|
|
75
|
+
notifications_enabled: boolean;
|
|
76
|
+
admin_json_key_path: string;
|
|
77
|
+
};
|
|
78
|
+
web: {
|
|
79
|
+
protocol: string;
|
|
80
|
+
host: string;
|
|
81
|
+
icon_image_url: string;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
export declare function validateExternalServicesConfig(config: ExternalServicesConfig): ConfigValidationResult;
|
|
85
|
+
/**
|
|
86
|
+
* Validates Parser configuration
|
|
87
|
+
*/
|
|
88
|
+
export type ParserConfig = {
|
|
89
|
+
userAgent: string;
|
|
90
|
+
log: {
|
|
91
|
+
level: string;
|
|
92
|
+
dir?: string;
|
|
93
|
+
timer?: boolean;
|
|
94
|
+
};
|
|
95
|
+
firebase: {
|
|
96
|
+
notifications_enabled: boolean;
|
|
97
|
+
authJsonPath?: string;
|
|
98
|
+
};
|
|
99
|
+
podcastIndex: {
|
|
100
|
+
authKey: string;
|
|
101
|
+
baseUrl: string;
|
|
102
|
+
secretKey: string;
|
|
103
|
+
rateLimitDelay?: number;
|
|
104
|
+
};
|
|
105
|
+
parser: {
|
|
106
|
+
addRemoteItemsToMQ: boolean;
|
|
107
|
+
};
|
|
108
|
+
defaults: {
|
|
109
|
+
account: {
|
|
110
|
+
settings: {
|
|
111
|
+
locale: string;
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
export declare function validateParserConfig(config: ParserConfig): ConfigValidationResult;
|
|
117
|
+
/**
|
|
118
|
+
* Helper function to throw an error if validation fails
|
|
119
|
+
*/
|
|
120
|
+
export declare function assertConfigValid(result: ConfigValidationResult, configName: string): void;
|
|
121
|
+
//# sourceMappingURL=configValidation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configValidation.d.ts","sourceRoot":"","sources":["../../../src/lib/validation/configValidation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,MAAM,qBAAqB,GAAG;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,qBAAqB,EAAE,CAAC;CACjC,CAAC;AAMF;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE;QACR,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,aAAa,EAAE,MAAM,CAAC;QACtB,aAAa,EAAE,MAAM,CAAC;QACtB,mBAAmB,EAAE,MAAM,CAAC;QAC5B,mBAAmB,EAAE,MAAM,CAAC;QAC5B,QAAQ,EAAE,MAAM,CAAC;QACjB,cAAc,EAAE,OAAO,CAAC;KACzB,CAAC;IACF,GAAG,EAAE;QACH,KAAK,EAAE,MAAM,CAAC;QACd,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB,CAAC;IACF,QAAQ,EAAE;QACR,OAAO,EAAE;YACP,QA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AY,EAAE;QACZ,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,CAAC;IACF,MAAM,EAAE;QACN,kBAAkB,EAAE,OAAO,CAAC;KAC7B,CAAC;IACF,QAAQ,EAAE;QACR,OAAO,EAAE;YACP,QAAQ,EAAE;gBACR,MAAM,EAAE,MAAM,CAAC;aAChB,CAAC;SACH,CAAC;KACH,CAAC;CACH,CAAC;AAEF,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,YAAY,GAAG,sBAAsB,CAoDjF;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CAK1F"}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Configuration validation utilities for podverse modules.
|
|
4
|
+
*
|
|
5
|
+
* These functions validate configuration objects that are passed to module factories.
|
|
6
|
+
* They should be called at app startup BEFORE creating module contexts.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const ormConfig: ORMConfig = { database: {...}, log: {...}, defaults: {...} };
|
|
11
|
+
* validateORMConfig(ormConfig); // Throws if invalid
|
|
12
|
+
* const ormContext = createORMContext(ormConfig);
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.validateORMConfig = validateORMConfig;
|
|
17
|
+
exports.validateNotificationsConfig = validateNotificationsConfig;
|
|
18
|
+
exports.validateExternalServicesConfig = validateExternalServicesConfig;
|
|
19
|
+
exports.validateParserConfig = validateParserConfig;
|
|
20
|
+
exports.assertConfigValid = assertConfigValid;
|
|
21
|
+
function createError(field, message, required = true) {
|
|
22
|
+
return { field, message, required };
|
|
23
|
+
}
|
|
24
|
+
function validateORMConfig(config) {
|
|
25
|
+
var _a, _b;
|
|
26
|
+
const errors = [];
|
|
27
|
+
// Database config validation
|
|
28
|
+
if (!config.database) {
|
|
29
|
+
errors.push(createError('database', 'Database configuration is required'));
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
if (!config.database.host || config.database.host.trim() === '') {
|
|
33
|
+
errors.push(createError('database.host', 'Database host is required'));
|
|
34
|
+
}
|
|
35
|
+
if (!config.database.port || config.database.port <= 0) {
|
|
36
|
+
errors.push(createError('database.port', 'Database port must be a positive number'));
|
|
37
|
+
}
|
|
38
|
+
if (!config.database.read_username || config.database.read_username.trim() === '') {
|
|
39
|
+
errors.push(createError('database.read_username', 'Database read username is required'));
|
|
40
|
+
}
|
|
41
|
+
if (!config.database.read_password) {
|
|
42
|
+
errors.push(createError('database.read_password', 'Database read password is required'));
|
|
43
|
+
}
|
|
44
|
+
if (!config.database.read_write_username || config.database.read_write_username.trim() === '') {
|
|
45
|
+
errors.push(createError('database.read_write_username', 'Database read-write username is required'));
|
|
46
|
+
}
|
|
47
|
+
if (!config.database.read_write_password) {
|
|
48
|
+
errors.push(createError('database.read_write_password', 'Database read-write password is required'));
|
|
49
|
+
}
|
|
50
|
+
if (!config.database.database || config.database.database.trim() === '') {
|
|
51
|
+
errors.push(createError('database.database', 'Database name is required'));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
// Log config validation
|
|
55
|
+
if (!config.log) {
|
|
56
|
+
errors.push(createError('log', 'Log configuration is required'));
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
if (!config.log.level || config.log.level.trim() === '') {
|
|
60
|
+
errors.push(createError('log.level', 'Log level is required'));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
// Defaults validation
|
|
64
|
+
if (!config.defaults) {
|
|
65
|
+
errors.push(createError('defaults', 'Defaults configuration is required'));
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
if (!((_b = (_a = config.defaults.account) === null || _a === void 0 ? void 0 : _a.settings) === null || _b === void 0 ? void 0 : _b.locale)) {
|
|
69
|
+
errors.push(createError('defaults.account.settings.locale', 'Default account locale is required'));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
valid: errors.length === 0,
|
|
74
|
+
errors
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function validateNotificationsConfig(config) {
|
|
78
|
+
var _a;
|
|
79
|
+
const errors = [];
|
|
80
|
+
// Brand name validation
|
|
81
|
+
if (!config.brandName || config.brandName.trim() === '') {
|
|
82
|
+
errors.push(createError('brandName', 'Brand name is required'));
|
|
83
|
+
}
|
|
84
|
+
// Web config validation
|
|
85
|
+
if (!config.web) {
|
|
86
|
+
errors.push(createError('web', 'Web configuration is required'));
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
if (!config.web.protocol || config.web.protocol.trim() === '') {
|
|
90
|
+
errors.push(createError('web.protocol', 'Web protocol is required'));
|
|
91
|
+
}
|
|
92
|
+
if (!config.web.host || config.web.host.trim() === '') {
|
|
93
|
+
errors.push(createError('web.host', 'Web host is required'));
|
|
94
|
+
}
|
|
95
|
+
if (!config.web.icon_image_path || config.web.icon_image_path.trim() === '') {
|
|
96
|
+
errors.push(createError('web.icon_image_path', 'Web icon image path is required'));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
// WebPush config validation (only required fields if enabled)
|
|
100
|
+
if ((_a = config.webpush) === null || _a === void 0 ? void 0 : _a.enabled) {
|
|
101
|
+
if (!config.webpush.vapid_public_key || config.webpush.vapid_public_key.trim() === '') {
|
|
102
|
+
errors.push(createError('webpush.vapid_public_key', 'VAPID public key is required when WebPush is enabled'));
|
|
103
|
+
}
|
|
104
|
+
if (!config.webpush.vapid_private_key || config.webpush.vapid_private_key.trim() === '') {
|
|
105
|
+
errors.push(createError('webpush.vapid_private_key', 'VAPID private key is required when WebPush is enabled'));
|
|
106
|
+
}
|
|
107
|
+
if (!config.webpush.vapid_subject || config.webpush.vapid_subject.trim() === '') {
|
|
108
|
+
errors.push(createError('webpush.vapid_subject', 'VAPID subject is required when WebPush is enabled'));
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return {
|
|
112
|
+
valid: errors.length === 0,
|
|
113
|
+
errors
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
function validateExternalServicesConfig(config) {
|
|
117
|
+
var _a;
|
|
118
|
+
const errors = [];
|
|
119
|
+
// Firebase config validation (only required fields if enabled)
|
|
120
|
+
if ((_a = config.firebase) === null || _a === void 0 ? void 0 : _a.notifications_enabled) {
|
|
121
|
+
if (!config.firebase.admin_json_key_path || config.firebase.admin_json_key_path.trim() === '') {
|
|
122
|
+
errors.push(createError('firebase.admin_json_key_path', 'Firebase admin JSON key path is required when Firebase is enabled'));
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
// Web config validation
|
|
126
|
+
if (!config.web) {
|
|
127
|
+
errors.push(createError('web', 'Web configuration is required'));
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
if (!config.web.protocol || config.web.protocol.trim() === '') {
|
|
131
|
+
errors.push(createError('web.protocol', 'Web protocol is required'));
|
|
132
|
+
}
|
|
133
|
+
if (!config.web.host || config.web.host.trim() === '') {
|
|
134
|
+
errors.push(createError('web.host', 'Web host is required'));
|
|
135
|
+
}
|
|
136
|
+
if (!config.web.icon_image_url || config.web.icon_image_url.trim() === '') {
|
|
137
|
+
errors.push(createError('web.icon_image_url', 'Web icon image URL is required'));
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return {
|
|
141
|
+
valid: errors.length === 0,
|
|
142
|
+
errors
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
function validateParserConfig(config) {
|
|
146
|
+
var _a, _b, _c;
|
|
147
|
+
const errors = [];
|
|
148
|
+
// User agent validation
|
|
149
|
+
if (!config.userAgent || config.userAgent.trim() === '') {
|
|
150
|
+
errors.push(createError('userAgent', 'User agent is required'));
|
|
151
|
+
}
|
|
152
|
+
// Log config validation
|
|
153
|
+
if (!config.log) {
|
|
154
|
+
errors.push(createError('log', 'Log configuration is required'));
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
if (!config.log.level || config.log.level.trim() === '') {
|
|
158
|
+
errors.push(createError('log.level', 'Log level is required'));
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
// Firebase config validation (only required fields if enabled)
|
|
162
|
+
if ((_a = config.firebase) === null || _a === void 0 ? void 0 : _a.notifications_enabled) {
|
|
163
|
+
if (!config.firebase.authJsonPath || config.firebase.authJsonPath.trim() === '') {
|
|
164
|
+
errors.push(createError('firebase.authJsonPath', 'Firebase auth JSON path is required when Firebase is enabled'));
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
// Podcast Index config validation
|
|
168
|
+
if (!config.podcastIndex) {
|
|
169
|
+
errors.push(createError('podcastIndex', 'Podcast Index configuration is required'));
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
if (!config.podcastIndex.authKey || config.podcastIndex.authKey.trim() === '') {
|
|
173
|
+
errors.push(createError('podcastIndex.authKey', 'Podcast Index auth key is required'));
|
|
174
|
+
}
|
|
175
|
+
if (!config.podcastIndex.baseUrl || config.podcastIndex.baseUrl.trim() === '') {
|
|
176
|
+
errors.push(createError('podcastIndex.baseUrl', 'Podcast Index base URL is required'));
|
|
177
|
+
}
|
|
178
|
+
if (!config.podcastIndex.secretKey || config.podcastIndex.secretKey.trim() === '') {
|
|
179
|
+
errors.push(createError('podcastIndex.secretKey', 'Podcast Index secret key is required'));
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
// Defaults validation
|
|
183
|
+
if (!config.defaults) {
|
|
184
|
+
errors.push(createError('defaults', 'Defaults configuration is required'));
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
if (!((_c = (_b = config.defaults.account) === null || _b === void 0 ? void 0 : _b.settings) === null || _c === void 0 ? void 0 : _c.locale)) {
|
|
188
|
+
errors.push(createError('defaults.account.settings.locale', 'Default account locale is required'));
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return {
|
|
192
|
+
valid: errors.length === 0,
|
|
193
|
+
errors
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Helper function to throw an error if validation fails
|
|
198
|
+
*/
|
|
199
|
+
function assertConfigValid(result, configName) {
|
|
200
|
+
if (!result.valid) {
|
|
201
|
+
const errorMessages = result.errors.map(e => ` - ${e.field}: ${e.message}`).join('\n');
|
|
202
|
+
throw new Error(`FATAL: ${configName} validation failed:\n${errorMessages}`);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
export * from './configValidation';
|
|
1
2
|
export * from './databaseConstants';
|
|
2
3
|
export * from './email';
|
|
3
4
|
export * from './password';
|
|
4
5
|
export * from './signUpValidation';
|
|
6
|
+
export * from './startupValidation';
|
|
5
7
|
export * from './url';
|
|
6
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/validation/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,OAAO,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/validation/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,OAAO,CAAC"}
|
|
@@ -14,8 +14,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./configValidation"), exports);
|
|
17
18
|
__exportStar(require("./databaseConstants"), exports);
|
|
18
19
|
__exportStar(require("./email"), exports);
|
|
19
20
|
__exportStar(require("./password"), exports);
|
|
20
21
|
__exportStar(require("./signUpValidation"), exports);
|
|
22
|
+
__exportStar(require("./startupValidation"), exports);
|
|
21
23
|
__exportStar(require("./url"), exports);
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types and functions for validating environment variables at application startup.
|
|
3
|
+
* These utilities can be used across different projects to validate required and optional environment variables.
|
|
4
|
+
*/
|
|
5
|
+
export type ValidationResult = {
|
|
6
|
+
name: string;
|
|
7
|
+
isSet: boolean;
|
|
8
|
+
isValid: boolean;
|
|
9
|
+
isRequired: boolean;
|
|
10
|
+
message: string;
|
|
11
|
+
category: string;
|
|
12
|
+
};
|
|
13
|
+
export type ValidationSummary = {
|
|
14
|
+
total: number;
|
|
15
|
+
passed: number;
|
|
16
|
+
failed: number;
|
|
17
|
+
requiredMissing: number;
|
|
18
|
+
skipped: number;
|
|
19
|
+
defaultsUsed: number;
|
|
20
|
+
results: ValidationResult[];
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Validates a required environment variable
|
|
24
|
+
* @param varName - The name of the environment variable to validate
|
|
25
|
+
* @param category - The category/group this variable belongs to (for display purposes)
|
|
26
|
+
* @returns ValidationResult indicating whether the variable is set and valid
|
|
27
|
+
*/
|
|
28
|
+
export declare function validateRequired(varName: string, category: string): ValidationResult;
|
|
29
|
+
/**
|
|
30
|
+
* Validates an optional environment variable
|
|
31
|
+
* @param varName - The name of the environment variable to validate
|
|
32
|
+
* @param category - The category/group this variable belongs to (for display purposes)
|
|
33
|
+
* @param defaultMessage - Optional message to display when variable is not set (defaults to "Skipped")
|
|
34
|
+
* @returns ValidationResult indicating whether the variable is set and valid (optional vars are always valid even if not set)
|
|
35
|
+
*/
|
|
36
|
+
export declare function validateOptional(varName: string, category: string, defaultMessage?: string): ValidationResult;
|
|
37
|
+
/**
|
|
38
|
+
* Validates a conditionally optional environment variable (only logs if set but not needed)
|
|
39
|
+
* Returns null if variable is not set (so it won't be included in results)
|
|
40
|
+
* @param varName - The name of the environment variable to validate
|
|
41
|
+
* @param category - The category/group this variable belongs to (for display purposes)
|
|
42
|
+
* @returns ValidationResult if variable is set, null otherwise
|
|
43
|
+
*/
|
|
44
|
+
export declare function validateConditionalOptional(varName: string, category: string): ValidationResult | null;
|
|
45
|
+
/**
|
|
46
|
+
* Generates a validation error message for variables that accept "all-available" or comma-delimited list
|
|
47
|
+
* @param validValues - Array of valid values that can be used in the comma-delimited list
|
|
48
|
+
* @returns Error message string
|
|
49
|
+
*/
|
|
50
|
+
export declare function getAllAvailableOrListMessage(validValues: string[]): string;
|
|
51
|
+
/**
|
|
52
|
+
* Displays validation results silently - only logs failures.
|
|
53
|
+
* This is intended for modules (not apps) that should not show validation output unless there are errors.
|
|
54
|
+
* @param summary - The validation summary to display
|
|
55
|
+
*/
|
|
56
|
+
export declare function displayValidationResultsSilent(summary: ValidationSummary): void;
|
|
57
|
+
/**
|
|
58
|
+
* Validates a single locale value against supported locales
|
|
59
|
+
* @param varName - The name of the environment variable to validate
|
|
60
|
+
* @param category - The category/group this variable belongs to (for display purposes)
|
|
61
|
+
* @param isRequired - Whether the variable is required (default: true)
|
|
62
|
+
* @returns ValidationResult indicating whether the locale is valid
|
|
63
|
+
*/
|
|
64
|
+
export declare function validateLocale(varName: string, category: string, isRequired?: boolean): ValidationResult;
|
|
65
|
+
/**
|
|
66
|
+
* Validates NEXT_PUBLIC_FEATURES_SUPPORTED_LOCALES
|
|
67
|
+
* Must be "all-available" or comma-delimited list of valid locales
|
|
68
|
+
* @param varName - The name of the environment variable to validate (defaults to 'NEXT_PUBLIC_FEATURES_SUPPORTED_LOCALES')
|
|
69
|
+
* @param category - The category/group this variable belongs to (for display purposes)
|
|
70
|
+
* @returns ValidationResult indicating whether the supported locales list is valid
|
|
71
|
+
*/
|
|
72
|
+
export declare function validateSupportedLocalesList(varName: string | undefined, category: string): ValidationResult;
|
|
73
|
+
/**
|
|
74
|
+
* Validates an optional environment variable - if set, must not be empty
|
|
75
|
+
* @param varName - The name of the environment variable to validate
|
|
76
|
+
* @param category - The category/group this variable belongs to (for display purposes)
|
|
77
|
+
* @returns ValidationResult indicating whether the variable is valid (optional, but if set must not be empty)
|
|
78
|
+
*/
|
|
79
|
+
export declare function validateOptionalNonEmpty(varName: string, category: string): ValidationResult;
|
|
80
|
+
/**
|
|
81
|
+
* Validates a boolean environment variable - must be "true" or "false" if set
|
|
82
|
+
* @param varName - The name of the environment variable to validate
|
|
83
|
+
* @param category - The category/group this variable belongs to (for display purposes)
|
|
84
|
+
* @param isRequired - Whether the variable is required (default: false)
|
|
85
|
+
* @param defaultValue - Optional default value message if not set (e.g., "Use Default (false)")
|
|
86
|
+
* @returns ValidationResult indicating whether the boolean value is valid
|
|
87
|
+
*/
|
|
88
|
+
export declare function validateBoolean(varName: string, category: string, isRequired?: boolean, defaultValue?: string): ValidationResult;
|
|
89
|
+
/**
|
|
90
|
+
* Validates WEB_PROTOCOL - must be "http" or "https" if set
|
|
91
|
+
* @param varName - The name of the environment variable to validate (defaults to 'WEB_PROTOCOL')
|
|
92
|
+
* @param category - The category/group this variable belongs to (for display purposes)
|
|
93
|
+
* @param isRequired - Whether the variable is required (default: false)
|
|
94
|
+
* @returns ValidationResult indicating whether the protocol is valid
|
|
95
|
+
*/
|
|
96
|
+
export declare function validateWebProtocol(varName: string | undefined, category: string, isRequired?: boolean): ValidationResult;
|
|
97
|
+
/**
|
|
98
|
+
* Validates LOG_LEVEL - must be a valid winston log level
|
|
99
|
+
* @param varName - The name of the environment variable to validate (defaults to 'LOG_LEVEL')
|
|
100
|
+
* @param category - The category/group this variable belongs to (for display purposes)
|
|
101
|
+
* @param isRequired - Whether the variable is required (default: true)
|
|
102
|
+
* @param validLevels - Optional array of valid log levels (defaults to winston levels)
|
|
103
|
+
* @returns ValidationResult indicating whether the log level is valid
|
|
104
|
+
*/
|
|
105
|
+
export declare function validateLogLevel(varName: string | undefined, category: string, isRequired?: boolean, validLevels?: string[]): ValidationResult;
|
|
106
|
+
/**
|
|
107
|
+
* Validates a positive number environment variable
|
|
108
|
+
* @param varName - The name of the environment variable to validate
|
|
109
|
+
* @param category - The category/group this variable belongs to (for display purposes)
|
|
110
|
+
* @param isRequired - Whether the variable is required (default: false)
|
|
111
|
+
* @param min - Optional minimum value (default: 1)
|
|
112
|
+
* @param max - Optional maximum value (no limit if not specified)
|
|
113
|
+
* @returns ValidationResult indicating whether the number is valid
|
|
114
|
+
*/
|
|
115
|
+
export declare function validatePositiveNumber(varName: string, category: string, isRequired?: boolean, min?: number, max?: number): ValidationResult;
|
|
116
|
+
//# sourceMappingURL=startupValidation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"startupValidation.d.ts","sourceRoot":"","sources":["../../../src/lib/validation/startupValidation.ts"],"names":[],"mappings":"AAEA;;;GAGG;AAEH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,gBAAgB,EAAE,CAAC;CAC7B,CAAC;A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