@jsnw/srv-utils 1.3.2 → 2.0.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 (36) hide show
  1. package/README.md +0 -10
  2. package/dist/index.cjs +348 -0
  3. package/dist/index.d.cts +167 -0
  4. package/package.json +22 -28
  5. package/dist/config/config-loader.js +0 -179
  6. package/dist/config/config-loader.types.js +0 -2
  7. package/dist/config/index.js +0 -7
  8. package/dist/config/predefined-schemas/connection.schema.js +0 -10
  9. package/dist/config/predefined-schemas/index.js +0 -17
  10. package/dist/config/predefined-schemas/mongodb-connection.schema.js +0 -15
  11. package/dist/config/predefined-schemas/mysql-connection.schema.js +0 -8
  12. package/dist/config/predefined-schemas/rabbit-connection.schema.js +0 -8
  13. package/dist/config/predefined-schemas/redis-connection.schema.js +0 -9
  14. package/dist/config/predefined-schemas/timestring.schema.js +0 -14
  15. package/dist/create-random-string.js +0 -21
  16. package/dist/file-exists.js +0 -34
  17. package/dist/getRootPackageDirname.js +0 -32
  18. package/dist/index.js +0 -17
  19. package/dist/types/config/config-loader.d.ts +0 -52
  20. package/dist/types/config/config-loader.types.d.ts +0 -4
  21. package/dist/types/config/index.d.ts +0 -3
  22. package/dist/types/config/predefined-schemas/connection.schema.d.ts +0 -7
  23. package/dist/types/config/predefined-schemas/index.d.ts +0 -57
  24. package/dist/types/config/predefined-schemas/mongodb-connection.schema.d.ts +0 -27
  25. package/dist/types/config/predefined-schemas/mysql-connection.schema.d.ts +0 -8
  26. package/dist/types/config/predefined-schemas/rabbit-connection.schema.d.ts +0 -8
  27. package/dist/types/config/predefined-schemas/redis-connection.schema.d.ts +0 -9
  28. package/dist/types/config/predefined-schemas/timestring.schema.d.ts +0 -2
  29. package/dist/types/create-random-string.d.ts +0 -5
  30. package/dist/types/file-exists.d.ts +0 -12
  31. package/dist/types/getRootPackageDirname.d.ts +0 -4
  32. package/dist/types/index.d.ts +0 -6
  33. package/dist/types/useTsconfigPaths.d.ts +0 -9
  34. package/dist/types/withNest.d.ts +0 -20
  35. package/dist/useTsconfigPaths.js +0 -34
  36. package/dist/withNest.js +0 -84
@@ -1,179 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ConfigLoader = void 0;
4
- const node_path_1 = require("node:path");
5
- const node_fs_1 = require("node:fs");
6
- const zod_1 = require("zod");
7
- const yaml_1 = require("yaml");
8
- const file_exists_1 = require("../file-exists");
9
- const getRootPackageDirname_1 = require("../getRootPackageDirname");
10
- const PKG_ROOT_REGEX = /^%pkgroot(?:[\/\\]|$)/i;
11
- const ENV_VAR_REGEX = /^%env:(?<var_name>[A-Za-z0-9_]+)(?:[\/\\]|$)/i;
12
- class ConfigLoader {
13
- static _instance;
14
- /**
15
- * @returns {ConfigLoader}
16
- */
17
- static instance() {
18
- if (!ConfigLoader._instance)
19
- ConfigLoader._instance = new ConfigLoader();
20
- return ConfigLoader._instance;
21
- }
22
- /**
23
- * @template {z.ZodObject} S
24
- * @template {object} P
25
- * @param {string} path You can use %pkgroot prefix for automatic project root resolution by AppConfigLoader.
26
- * Also, you can use %env:ENV_VARIABLE to resolve config path based on environment variable
27
- * Example 1: %pkgroot/config.yml
28
- * Example 2: %env:CONFIG_PATH/config.yml
29
- * @param {S} schema
30
- * @param {P} [addProps]
31
- * @returns {ResolvedConfig<S, P>}
32
- */
33
- static loadConfig(path, schema, addProps) {
34
- const loader = ConfigLoader.instance();
35
- const [yaml, loadError] = loader.loadYamlFile(path);
36
- if (loadError) {
37
- console.error(loadError.message);
38
- process.exit(1);
39
- }
40
- const [processedYaml, directiveErrors] = loader.processDirectives((0, node_path_1.dirname)(loader.resolveFilePath(path)), yaml);
41
- if (directiveErrors && directiveErrors.length > 0) {
42
- for (const err of directiveErrors)
43
- console.error(`directive error: ${err.message}`);
44
- process.exit(1);
45
- }
46
- const [validatedYaml, validateError] = loader.validateYaml(processedYaml, schema);
47
- if (validateError) {
48
- console.error(validateError.message);
49
- process.exit(1);
50
- }
51
- //@ts-expect-error
52
- validatedYaml['isDev'] = (process?.env?.APP_CONTEXT
53
- ?? process?.env?.APPLICATION_CONTEXT
54
- ?? process?.env?.NODE_ENV
55
- ?? '').toLowerCase() !== 'production';
56
- return {
57
- ...validatedYaml,
58
- ...(addProps ?? {})
59
- };
60
- }
61
- constructor() { }
62
- /**
63
- * @param {string} path
64
- * @returns {ErrorResult<any, Error>}
65
- * @protected
66
- */
67
- loadYamlFile(path) {
68
- path = this.resolveFilePath(path);
69
- if (!(0, file_exists_1.fileExistsSync)(path))
70
- return [null, new Error(`YAML file does not exists at path: ${path}`)];
71
- let data = undefined, parsedYml = undefined;
72
- try {
73
- data = (0, node_fs_1.readFileSync)(path, 'utf-8');
74
- }
75
- catch (e) {
76
- return [null, new Error(`Failed to read config file at path: ${path}`)];
77
- }
78
- try {
79
- parsedYml = (0, yaml_1.parse)(data, { prettyErrors: true });
80
- }
81
- catch (e) {
82
- return [null, new Error(`Failed to parse YAML file at path: ${path}`)];
83
- }
84
- return [parsedYml, null];
85
- }
86
- /**
87
- * @template {z.ZodTypeAny} T
88
- * @param data
89
- * @param {T} schema
90
- * @returns {ErrorResult<output<T>, Error>}
91
- * @protected
92
- */
93
- validateYaml(data, schema) {
94
- const { data: parsed, error, success } = schema.safeParse(data);
95
- if (!success) {
96
- if (error && error instanceof zod_1.ZodError)
97
- return [null, new Error(`Failed to validate yaml (#1). Error message: ${zod_1.z.prettifyError(error)}`)];
98
- return [null, new Error(`Failed to validate yaml (#2)`)];
99
- }
100
- return [parsed, null];
101
- }
102
- /**
103
- * @param {string} mainYamlDirname
104
- * @param yaml
105
- * @returns {ErrorResult<any, Error[]>}
106
- * @protected
107
- */
108
- processDirectives(mainYamlDirname, yaml) {
109
- if (typeof yaml !== 'object')
110
- return yaml;
111
- const nodesToVisit = [yaml], errors = [];
112
- for (let i = 0; i < nodesToVisit.length; i++) {
113
- const node = nodesToVisit[i];
114
- if (typeof node !== 'object' || Array.isArray(node))
115
- continue;
116
- const nodeFields = Object.keys(node);
117
- for (const field of nodeFields) {
118
- if (field === '$include') {
119
- const $includePaths = [];
120
- if (typeof node['$include'] === 'string') {
121
- $includePaths.push(node['$include']);
122
- }
123
- else if (Array.isArray(node['$include'])) {
124
- $includePaths.push(...(node['$include']
125
- .filter(v => v && typeof v === 'string' && v.trim() !== '')));
126
- }
127
- delete node['$include'];
128
- for (const path of $includePaths) {
129
- const [loadedYaml, loadError] = this.loadYamlFile(this.resolveIncludePath(mainYamlDirname, path));
130
- if (loadError) {
131
- errors.push(loadError);
132
- }
133
- else {
134
- for (const [k, v] of Object.entries(loadedYaml))
135
- node[k] = v;
136
- }
137
- }
138
- }
139
- else {
140
- if (typeof node[field] === 'string' && /^\s*\$[A-Z0-9_]+$/.test(node[field]))
141
- node[field] = process.env?.[node[field].trim().slice(1)] ?? '';
142
- }
143
- }
144
- for (const k of Object.keys(node)) {
145
- if (Object.hasOwn(node, k) && typeof node[k] === 'object' && !Array.isArray(node[k]))
146
- nodesToVisit.push(node[k]);
147
- }
148
- }
149
- return [yaml, errors];
150
- }
151
- //region Utils
152
- resolveFilePath(path) {
153
- const initialPath = path;
154
- while (ENV_VAR_REGEX.test(path)) {
155
- const m = path.match(ENV_VAR_REGEX);
156
- if (m.groups?.['var_name']) {
157
- if (process.env?.[m.groups['var_name']]) {
158
- path = path.replace(ENV_VAR_REGEX, process.env[m.groups['var_name']].replace(/[\/\\]+$/, '') + node_path_1.sep);
159
- }
160
- else {
161
- throw new Error(`Failed to resolve path: "${initialPath}"`);
162
- }
163
- }
164
- }
165
- if (PKG_ROOT_REGEX.test(path))
166
- path = path.replace(PKG_ROOT_REGEX, (0, getRootPackageDirname_1.getRootPackageDirnameSync)() + node_path_1.sep);
167
- return (0, node_path_1.resolve)(path);
168
- }
169
- /**
170
- * @param {string} fromDirname
171
- * @param {string} toPath
172
- * @returns {string}
173
- * @private
174
- */
175
- resolveIncludePath(fromDirname, toPath) {
176
- return (0, node_path_1.resolve)(this.resolveFilePath(fromDirname), toPath);
177
- }
178
- }
179
- exports.ConfigLoader = ConfigLoader;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.configSchemas = exports.ConfigLoader = void 0;
4
- var config_loader_1 = require("./config-loader");
5
- Object.defineProperty(exports, "ConfigLoader", { enumerable: true, get: function () { return config_loader_1.ConfigLoader; } });
6
- var predefined_schemas_1 = require("./predefined-schemas");
7
- Object.defineProperty(exports, "configSchemas", { enumerable: true, get: function () { return predefined_schemas_1.configSchemas; } });
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.connectionSchema = void 0;
4
- const zod_1 = require("zod");
5
- exports.connectionSchema = zod_1.z.object({
6
- host: zod_1.z.string().nonempty(),
7
- port: zod_1.z.coerce.number().min(1).max(65535),
8
- user: zod_1.z.string(),
9
- pass: zod_1.z.string()
10
- });
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.configSchemas = void 0;
4
- const timestring_schema_1 = require("./timestring.schema");
5
- const connection_schema_1 = require("./connection.schema");
6
- const mongodb_connection_schema_1 = require("./mongodb-connection.schema");
7
- const mysql_connection_schema_1 = require("./mysql-connection.schema");
8
- const redis_connection_schema_1 = require("./redis-connection.schema");
9
- const rabbit_connection_schema_1 = require("./rabbit-connection.schema");
10
- exports.configSchemas = {
11
- timeString: timestring_schema_1.timeStringSchema,
12
- connection: connection_schema_1.connectionSchema,
13
- mongodbConnection: mongodb_connection_schema_1.mongodbConnectionSchema,
14
- mysqlConnection: mysql_connection_schema_1.mysqlConnectionSchema,
15
- redisConnection: redis_connection_schema_1.redisConnectionSchema,
16
- rabbitConnection: rabbit_connection_schema_1.rabbitConnectionSchema
17
- };
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mongodbConnectionSchema = void 0;
4
- const zod_1 = require("zod");
5
- const connection_schema_1 = require("./connection.schema");
6
- const timestring_schema_1 = require("./timestring.schema");
7
- exports.mongodbConnectionSchema = connection_schema_1.connectionSchema.extend({
8
- db: zod_1.z.string().nonempty(),
9
- authDb: zod_1.z.string().optional(),
10
- connectTimeout: timestring_schema_1.timeStringSchema.default(5_000)
11
- }).transform(v => ({
12
- ...v,
13
- authDb: v.authDb || v.db,
14
- dsn: `mongodb://${v.host}:${v.port}/${v.db}`
15
- }));
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mysqlConnectionSchema = void 0;
4
- const zod_1 = require("zod");
5
- const connection_schema_1 = require("./connection.schema");
6
- exports.mysqlConnectionSchema = connection_schema_1.connectionSchema.extend({
7
- dbname: zod_1.z.string().nonempty()
8
- });
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.rabbitConnectionSchema = void 0;
4
- const zod_1 = require("zod");
5
- const connection_schema_1 = require("./connection.schema");
6
- exports.rabbitConnectionSchema = connection_schema_1.connectionSchema.extend({
7
- vhost: zod_1.z.string().default('/')
8
- });
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.redisConnectionSchema = void 0;
4
- const zod_1 = require("zod");
5
- const connection_schema_1 = require("./connection.schema");
6
- exports.redisConnectionSchema = connection_schema_1.connectionSchema.extend({
7
- db: zod_1.z.number().min(0).default(0),
8
- keyPrefix: zod_1.z.string().default('')
9
- });
@@ -1,14 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.timeStringSchema = void 0;
7
- const zod_1 = require("zod");
8
- const ms_1 = __importDefault(require("ms"));
9
- const TIMESTRING_UNIT = ['Years', 'Year', 'Yrs', 'Yr', 'Y', 'Weeks', 'Week', 'W', 'Days', 'Day', 'D', 'Hours', 'Hour', 'Hrs', 'Hr', 'H', 'Minutes', 'Minute', 'Mins', 'Min', 'M', 'Seconds', 'Second', 'Secs', 'Sec', 's', 'Milliseconds', 'Millisecond', 'Msecs', 'Msec', 'Ms'];
10
- const TIMESTRING_REGEX = new RegExp(`\\d+\\s*(?:${TIMESTRING_UNIT.map(unit => unit.toLowerCase()).join('|')})`, 'i');
11
- exports.timeStringSchema = zod_1.z.string()
12
- .nonempty()
13
- .regex(TIMESTRING_REGEX)
14
- .transform(v => (0, ms_1.default)(v));
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createRandomString = createRandomString;
4
- const node_crypto_1 = require("node:crypto");
5
- /**
6
- * @param {number} length The length of the string
7
- * @return {Promise<string>}
8
- */
9
- function createRandomString(length) {
10
- if (length <= 0)
11
- return Promise.resolve('');
12
- return new Promise((resolve, reject) => {
13
- const bytesLength = Math.ceil(length / 2);
14
- (0, node_crypto_1.randomBytes)(bytesLength, (err, buff) => {
15
- if (err)
16
- return reject(err);
17
- const hexString = buff.toString('hex').slice(0, length);
18
- return resolve(hexString);
19
- });
20
- });
21
- }
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fileExists = fileExists;
4
- exports.fileExistsSync = fileExistsSync;
5
- const promises_1 = require("node:fs/promises");
6
- const node_fs_1 = require("node:fs");
7
- /**
8
- * @param {string} path
9
- * @param {number} [mode]
10
- * @returns {boolean}
11
- */
12
- async function fileExists(path, mode = node_fs_1.constants.F_OK | node_fs_1.constants.R_OK) {
13
- try {
14
- await (0, promises_1.access)(path, mode);
15
- return true;
16
- }
17
- catch (e) {
18
- return false;
19
- }
20
- }
21
- /**
22
- * @param {string} path
23
- * @param {number} [mode]
24
- * @returns {boolean}
25
- */
26
- function fileExistsSync(path, mode = node_fs_1.constants.F_OK | node_fs_1.constants.R_OK) {
27
- try {
28
- (0, node_fs_1.accessSync)(path, mode);
29
- return true;
30
- }
31
- catch (e) {
32
- return false;
33
- }
34
- }
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getRootPackageDirnameSync = getRootPackageDirnameSync;
4
- const node_path_1 = require("node:path");
5
- const node_fs_1 = require("node:fs");
6
- let cachedRootPackageDirname = null;
7
- /**
8
- * @returns {string}
9
- */
10
- function getRootPackageDirnameSync() {
11
- if (cachedRootPackageDirname !== null)
12
- return cachedRootPackageDirname;
13
- let path = (0, node_path_1.resolve)(__dirname, '..'), lastValidPath = path;
14
- if (/[\\\/]node_modules[\\\/]/i.test(path)) {
15
- const pieces = path.split(/[\\\/]node_modules[\\\/]/i);
16
- if (pieces.length > 0)
17
- path = pieces[0];
18
- }
19
- while (true) {
20
- const packageJsonPath = (0, node_path_1.resolve)(path, 'package.json');
21
- try {
22
- (0, node_fs_1.accessSync)(packageJsonPath, node_fs_1.constants.F_OK | node_fs_1.constants.R_OK);
23
- }
24
- catch (e) {
25
- break;
26
- }
27
- lastValidPath = path;
28
- path = (0, node_path_1.resolve)(path, '..');
29
- }
30
- cachedRootPackageDirname = lastValidPath;
31
- return lastValidPath;
32
- }
package/dist/index.js DELETED
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createRandomString = exports.withNest = exports.configSchemas = exports.ConfigLoader = exports.getRootPackageDirnameSync = exports.useTsconfigPaths = exports.fileExistsSync = exports.fileExists = void 0;
4
- var file_exists_1 = require("./file-exists");
5
- Object.defineProperty(exports, "fileExists", { enumerable: true, get: function () { return file_exists_1.fileExists; } });
6
- Object.defineProperty(exports, "fileExistsSync", { enumerable: true, get: function () { return file_exists_1.fileExistsSync; } });
7
- var useTsconfigPaths_1 = require("./useTsconfigPaths");
8
- Object.defineProperty(exports, "useTsconfigPaths", { enumerable: true, get: function () { return useTsconfigPaths_1.useTsconfigPaths; } });
9
- var getRootPackageDirname_1 = require("./getRootPackageDirname");
10
- Object.defineProperty(exports, "getRootPackageDirnameSync", { enumerable: true, get: function () { return getRootPackageDirname_1.getRootPackageDirnameSync; } });
11
- var config_1 = require("./config");
12
- Object.defineProperty(exports, "ConfigLoader", { enumerable: true, get: function () { return config_1.ConfigLoader; } });
13
- Object.defineProperty(exports, "configSchemas", { enumerable: true, get: function () { return config_1.configSchemas; } });
14
- var withNest_1 = require("./withNest");
15
- Object.defineProperty(exports, "withNest", { enumerable: true, get: function () { return withNest_1.withNest; } });
16
- var create_random_string_1 = require("./create-random-string");
17
- Object.defineProperty(exports, "createRandomString", { enumerable: true, get: function () { return create_random_string_1.createRandomString; } });
@@ -1,52 +0,0 @@
1
- import { z } from 'zod';
2
- import { type ErrorResult } from '@jsnw/common-utils';
3
- import { ResolvedConfig } from './config-loader.types';
4
- export declare class ConfigLoader {
5
- private static _instance;
6
- /**
7
- * @returns {ConfigLoader}
8
- */
9
- static instance(): ConfigLoader;
10
- /**
11
- * @template {z.ZodObject} S
12
- * @template {object} P
13
- * @param {string} path You can use %pkgroot prefix for automatic project root resolution by AppConfigLoader.
14
- * Also, you can use %env:ENV_VARIABLE to resolve config path based on environment variable
15
- * Example 1: %pkgroot/config.yml
16
- * Example 2: %env:CONFIG_PATH/config.yml
17
- * @param {S} schema
18
- * @param {P} [addProps]
19
- * @returns {ResolvedConfig<S, P>}
20
- */
21
- static loadConfig<S extends z.ZodObject, P extends object | undefined = undefined>(path: string, schema: S, addProps?: P): ResolvedConfig<S, P>;
22
- private constructor();
23
- /**
24
- * @param {string} path
25
- * @returns {ErrorResult<any, Error>}
26
- * @protected
27
- */
28
- protected loadYamlFile(path: string): ErrorResult<any, Error>;
29
- /**
30
- * @template {z.ZodTypeAny} T
31
- * @param data
32
- * @param {T} schema
33
- * @returns {ErrorResult<output<T>, Error>}
34
- * @protected
35
- */
36
- protected validateYaml<T extends z.ZodTypeAny>(data: any, schema: T): ErrorResult<z.infer<T>, Error>;
37
- /**
38
- * @param {string} mainYamlDirname
39
- * @param yaml
40
- * @returns {ErrorResult<any, Error[]>}
41
- * @protected
42
- */
43
- protected processDirectives(mainYamlDirname: string, yaml: any): ErrorResult<any, Error[]>;
44
- private resolveFilePath;
45
- /**
46
- * @param {string} fromDirname
47
- * @param {string} toPath
48
- * @returns {string}
49
- * @private
50
- */
51
- private resolveIncludePath;
52
- }
@@ -1,4 +0,0 @@
1
- import { z } from 'zod';
2
- export type ResolvedConfig<T extends z.ZodObject, P extends object | undefined = undefined> = z.output<T> & {
3
- isDev: boolean;
4
- } & (P extends undefined ? {} : P);
@@ -1,3 +0,0 @@
1
- export { ConfigLoader } from './config-loader';
2
- export type { ResolvedConfig } from './config-loader.types';
3
- export { configSchemas } from './predefined-schemas';
@@ -1,7 +0,0 @@
1
- import { z } from 'zod';
2
- export declare const connectionSchema: z.ZodObject<{
3
- host: z.ZodString;
4
- port: z.ZodCoercedNumber<unknown>;
5
- user: z.ZodString;
6
- pass: z.ZodString;
7
- }, z.core.$strip>;
@@ -1,57 +0,0 @@
1
- export declare const configSchemas: {
2
- timeString: import("zod").ZodPipe<import("zod").ZodString, import("zod").ZodTransform<number, string>>;
3
- connection: import("zod").ZodObject<{
4
- host: import("zod").ZodString;
5
- port: import("zod").ZodCoercedNumber<unknown>;
6
- user: import("zod").ZodString;
7
- pass: import("zod").ZodString;
8
- }, import("zod/v4/core").$strip>;
9
- mongodbConnection: import("zod").ZodPipe<import("zod").ZodObject<{
10
- host: import("zod").ZodString;
11
- port: import("zod").ZodCoercedNumber<unknown>;
12
- user: import("zod").ZodString;
13
- pass: import("zod").ZodString;
14
- db: import("zod").ZodString;
15
- authDb: import("zod").ZodOptional<import("zod").ZodString>;
16
- connectTimeout: import("zod").ZodDefault<import("zod").ZodPipe<import("zod").ZodString, import("zod").ZodTransform<number, string>>>;
17
- }, import("zod/v4/core").$strip>, import("zod").ZodTransform<{
18
- authDb: string;
19
- dsn: string;
20
- host: string;
21
- port: number;
22
- user: string;
23
- pass: string;
24
- db: string;
25
- connectTimeout: number;
26
- }, {
27
- host: string;
28
- port: number;
29
- user: string;
30
- pass: string;
31
- db: string;
32
- connectTimeout: number;
33
- authDb?: string;
34
- }>>;
35
- mysqlConnection: import("zod").ZodObject<{
36
- host: import("zod").ZodString;
37
- port: import("zod").ZodCoercedNumber<unknown>;
38
- user: import("zod").ZodString;
39
- pass: import("zod").ZodString;
40
- dbname: import("zod").ZodString;
41
- }, import("zod/v4/core").$strip>;
42
- redisConnection: import("zod").ZodObject<{
43
- host: import("zod").ZodString;
44
- port: import("zod").ZodCoercedNumber<unknown>;
45
- user: import("zod").ZodString;
46
- pass: import("zod").ZodString;
47
- db: import("zod").ZodDefault<import("zod").ZodNumber>;
48
- keyPrefix: import("zod").ZodDefault<import("zod").ZodString>;
49
- }, import("zod/v4/core").$strip>;
50
- rabbitConnection: import("zod").ZodObject<{
51
- host: import("zod").ZodString;
52
- port: import("zod").ZodCoercedNumber<unknown>;
53
- user: import("zod").ZodString;
54
- pass: import("zod").ZodString;
55
- vhost: import("zod").ZodDefault<import("zod").ZodString>;
56
- }, import("zod/v4/core").$strip>;
57
- };
@@ -1,27 +0,0 @@
1
- import { z } from 'zod';
2
- export declare const mongodbConnectionSchema: z.ZodPipe<z.ZodObject<{
3
- host: z.ZodString;
4
- port: z.ZodCoercedNumber<unknown>;
5
- user: z.ZodString;
6
- pass: z.ZodString;
7
- db: z.ZodString;
8
- authDb: z.ZodOptional<z.ZodString>;
9
- connectTimeout: z.ZodDefault<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>>;
10
- }, z.core.$strip>, z.ZodTransform<{
11
- authDb: string;
12
- dsn: string;
13
- host: string;
14
- port: number;
15
- user: string;
16
- pass: string;
17
- db: string;
18
- connectTimeout: number;
19
- }, {
20
- host: string;
21
- port: number;
22
- user: string;
23
- pass: string;
24
- db: string;
25
- connectTimeout: number;
26
- authDb?: string;
27
- }>>;
@@ -1,8 +0,0 @@
1
- import { z } from 'zod';
2
- export declare const mysqlConnectionSchema: z.ZodObject<{
3
- host: z.ZodString;
4
- port: z.ZodCoercedNumber<unknown>;
5
- user: z.ZodString;
6
- pass: z.ZodString;
7
- dbname: z.ZodString;
8
- }, z.core.$strip>;
@@ -1,8 +0,0 @@
1
- import { z } from 'zod';
2
- export declare const rabbitConnectionSchema: z.ZodObject<{
3
- host: z.ZodString;
4
- port: z.ZodCoercedNumber<unknown>;
5
- user: z.ZodString;
6
- pass: z.ZodString;
7
- vhost: z.ZodDefault<z.ZodString>;
8
- }, z.core.$strip>;
@@ -1,9 +0,0 @@
1
- import { z } from 'zod';
2
- export declare const redisConnectionSchema: z.ZodObject<{
3
- host: z.ZodString;
4
- port: z.ZodCoercedNumber<unknown>;
5
- user: z.ZodString;
6
- pass: z.ZodString;
7
- db: z.ZodDefault<z.ZodNumber>;
8
- keyPrefix: z.ZodDefault<z.ZodString>;
9
- }, z.core.$strip>;
@@ -1,2 +0,0 @@
1
- import { z } from 'zod';
2
- export declare const timeStringSchema: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
@@ -1,5 +0,0 @@
1
- /**
2
- * @param {number} length The length of the string
3
- * @return {Promise<string>}
4
- */
5
- export declare function createRandomString(length: number): Promise<string>;
@@ -1,12 +0,0 @@
1
- /**
2
- * @param {string} path
3
- * @param {number} [mode]
4
- * @returns {boolean}
5
- */
6
- export declare function fileExists(path: string, mode?: number): Promise<boolean>;
7
- /**
8
- * @param {string} path
9
- * @param {number} [mode]
10
- * @returns {boolean}
11
- */
12
- export declare function fileExistsSync(path: string, mode?: number): boolean;
@@ -1,4 +0,0 @@
1
- /**
2
- * @returns {string}
3
- */
4
- export declare function getRootPackageDirnameSync(): string;
@@ -1,6 +0,0 @@
1
- export { fileExists, fileExistsSync } from './file-exists';
2
- export { useTsconfigPaths } from './useTsconfigPaths';
3
- export { getRootPackageDirnameSync } from './getRootPackageDirname';
4
- export { ConfigLoader, configSchemas, type ResolvedConfig } from './config';
5
- export { withNest } from './withNest';
6
- export { createRandomString } from './create-random-string';
@@ -1,9 +0,0 @@
1
- type UseTsconfigPathsOptions = {
2
- basePath?: string;
3
- tsconfigPath: string;
4
- };
5
- /**
6
- * @param {UseTsconfigPathsOptions} options
7
- */
8
- export declare function useTsconfigPaths({ basePath, tsconfigPath }: UseTsconfigPathsOptions): void;
9
- export {};
@@ -1,20 +0,0 @@
1
- import type { INestApplicationContext } from '@nestjs/common';
2
- type WithNestFn = (app: INestApplicationContext, preventClosing: () => void) => Promise<void>;
3
- /**
4
- * Executes a given function within the context of a NestJS application.
5
- *
6
- * This asynchronous function initializes a NestJS application context using the specified
7
- * module class and then executes the provided function `fn` with the application instance.
8
- * The application context is automatically closed upon completion of the function execution,
9
- * unless the function execution requests otherwise by invoking a callback.
10
- *
11
- * @param {any} moduleCls - The module class to be used for creating the NestJS application context.
12
- * @param {WithNestFn} fn - The function to be executed with the NestJS application context.
13
- * It receives the application instance and a callback to prevent
14
- * automatic application context closure.
15
- * @returns {Promise<void>} A promise that resolves when the function execution is complete.
16
- * @throws - Will throw an error if the `@nestjs/core` and/or `@nestjs/common` library is not found.
17
- * @throws - Will propagate any error thrown by the executed function `fn`.
18
- */
19
- export declare function withNest(moduleCls: any, fn: WithNestFn): Promise<void>;
20
- export {};