tydantic-settings 0.0.1

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 (59) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +742 -0
  3. package/dist/core/computed.d.ts +16 -0
  4. package/dist/core/computed.d.ts.map +1 -0
  5. package/dist/core/computed.js +33 -0
  6. package/dist/core/computed.js.map +1 -0
  7. package/dist/core/defaults.d.ts +9 -0
  8. package/dist/core/defaults.d.ts.map +1 -0
  9. package/dist/core/defaults.js +39 -0
  10. package/dist/core/defaults.js.map +1 -0
  11. package/dist/core/index.d.ts +6 -0
  12. package/dist/core/index.d.ts.map +1 -0
  13. package/dist/core/index.js +17 -0
  14. package/dist/core/index.js.map +1 -0
  15. package/dist/core/nested-bundles.d.ts +15 -0
  16. package/dist/core/nested-bundles.d.ts.map +1 -0
  17. package/dist/core/nested-bundles.js +68 -0
  18. package/dist/core/nested-bundles.js.map +1 -0
  19. package/dist/core/pipeline.d.ts +27 -0
  20. package/dist/core/pipeline.d.ts.map +1 -0
  21. package/dist/core/pipeline.js +137 -0
  22. package/dist/core/pipeline.js.map +1 -0
  23. package/dist/core/unflatten.d.ts +8 -0
  24. package/dist/core/unflatten.d.ts.map +1 -0
  25. package/dist/core/unflatten.js +25 -0
  26. package/dist/core/unflatten.js.map +1 -0
  27. package/dist/index.d.ts +6 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +25 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/resolvers/aws.d.ts +19 -0
  32. package/dist/resolvers/aws.d.ts.map +1 -0
  33. package/dist/resolvers/aws.js +107 -0
  34. package/dist/resolvers/aws.js.map +1 -0
  35. package/dist/resolvers/dotenv.d.ts +35 -0
  36. package/dist/resolvers/dotenv.d.ts.map +1 -0
  37. package/dist/resolvers/dotenv.js +43 -0
  38. package/dist/resolvers/dotenv.js.map +1 -0
  39. package/dist/resolvers/environment.d.ts +77 -0
  40. package/dist/resolvers/environment.d.ts.map +1 -0
  41. package/dist/resolvers/environment.js +109 -0
  42. package/dist/resolvers/environment.js.map +1 -0
  43. package/dist/resolvers/index.d.ts +5 -0
  44. package/dist/resolvers/index.d.ts.map +1 -0
  45. package/dist/resolvers/index.js +15 -0
  46. package/dist/resolvers/index.js.map +1 -0
  47. package/dist/settings.d.ts +211 -0
  48. package/dist/settings.d.ts.map +1 -0
  49. package/dist/settings.js +162 -0
  50. package/dist/settings.js.map +1 -0
  51. package/dist/types.d.ts +89 -0
  52. package/dist/types.d.ts.map +1 -0
  53. package/dist/types.js +3 -0
  54. package/dist/types.js.map +1 -0
  55. package/dist/utils.d.ts +15 -0
  56. package/dist/utils.d.ts.map +1 -0
  57. package/dist/utils.js +44 -0
  58. package/dist/utils.js.map +1 -0
  59. package/package.json +64 -0
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.fromAwsSecretsManager = fromAwsSecretsManager;
37
+ const utils_1 = require("../utils");
38
+ /**
39
+ * Creates a resolver that fetches a JSON secret from AWS Secrets Manager.
40
+ *
41
+ * Requires `@aws-sdk/client-secrets-manager` to be installed:
42
+ * ```
43
+ * npm install @aws-sdk/client-secrets-manager
44
+ * ```
45
+ *
46
+ * @param secretId A single secret ID or an array of secret IDs (or ARNs).
47
+ * @param region The AWS region where the secret is stored.
48
+ * @param options Configuration options for the resolver.
49
+ * @param options.caseSensitive Whether to perform a case-sensitive match for keys in the secret. Defaults to `false`.
50
+ */
51
+ function fromAwsSecretsManager(secretId, region, options) {
52
+ const caseSensitive = options?.caseSensitive ?? false;
53
+ const separator = options?.nestingSeparator;
54
+ return async (schema) => {
55
+ // Dynamically import the AWS SDK — only loaded when this resolver is actually called
56
+ let awsSdk;
57
+ try {
58
+ awsSdk = await Promise.resolve().then(() => __importStar(require('@aws-sdk/client-secrets-manager')));
59
+ }
60
+ catch {
61
+ throw new Error('The "@aws-sdk/client-secrets-manager" package is required to use fromAwsSecretsManager(). ' +
62
+ 'Install it with: npm install @aws-sdk/client-secrets-manager');
63
+ }
64
+ console.log('Fetching configuration from AWS Secrets Manager');
65
+ const secretIds = Array.isArray(secretId) ? secretId : [secretId];
66
+ if (secretIds.length === 0 || !secretIds[0]) {
67
+ return {};
68
+ }
69
+ const client = new awsSdk.SecretsManagerClient({ region });
70
+ // Fetch all secrets in parallel for better performance
71
+ const secretPromises = secretIds.map(async (id) => {
72
+ const command = new awsSdk.GetSecretValueCommand({ SecretId: id });
73
+ try {
74
+ const response = await client.send(command);
75
+ if (response.SecretString) {
76
+ return JSON.parse(response.SecretString);
77
+ }
78
+ }
79
+ catch (error) {
80
+ console.warn(`Could not fetch secret '${id}' from AWS Secrets Manager.`, error);
81
+ }
82
+ return {};
83
+ });
84
+ const resolvedSecrets = await Promise.all(secretPromises);
85
+ // Merge the secrets together, with later secrets in the array overwriting earlier ones.
86
+ const mergedSecrets = resolvedSecrets.reduce((acc, current) => ({ ...acc, ...current }), {});
87
+ if (caseSensitive) {
88
+ return mergedSecrets;
89
+ }
90
+ // Case-insensitive matching
91
+ const config = {};
92
+ const schemaKeys = Object.keys(schema.properties);
93
+ const secretKeys = Object.keys(mergedSecrets);
94
+ for (const secretKey of secretKeys) {
95
+ const normalizedSecretKey = (0, utils_1.normalizeKey)(secretKey);
96
+ const normalizedSchemaKey = separator
97
+ ? (0, utils_1.normalizeKey)(secretKey.split(separator)[0])
98
+ : normalizedSecretKey;
99
+ if (schemaKeys.some(sk => (0, utils_1.normalizeKey)(sk) === normalizedSchemaKey)) {
100
+ config[secretKey.toUpperCase()] = mergedSecrets[secretKey];
101
+ }
102
+ }
103
+ console.log('Successfully fetched configuration from AWS Secrets Manager');
104
+ return config;
105
+ };
106
+ }
107
+ //# sourceMappingURL=aws.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aws.js","sourceRoot":"","sources":["../../src/resolvers/aws.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,sDAoEC;AApFD,oCAAwC;AAGxC;;;;;;;;;;;;GAYG;AACH,SAAgB,qBAAqB,CACnC,QAA2B,EAC3B,MAAc,EACd,OAAgE;IAEhE,MAAM,aAAa,GAAG,OAAO,EAAE,aAAa,IAAI,KAAK,CAAC;IACtD,MAAM,SAAS,GAAG,OAAO,EAAE,gBAAgB,CAAC;IAE5C,OAAO,KAAK,EAAE,MAAe,EAAE,EAAE;QAC/B,qFAAqF;QACrF,IAAI,MAAwD,CAAC;QAC7D,IAAI,CAAC;YACH,MAAM,GAAG,wDAAa,iCAAiC,GAAC,CAAC;QAC3D,CAAC;QAAC,MAAM,CAAC;Y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E,CAAC,CAAC,EAAE,GAAG,GAAG,EAAE,GAAG,OAAO,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QAE7F,IAAI,aAAa,EAAE,CAAC;YAClB,OAAO,aAAa,CAAC;QACvB,CAAC;QAED,4BAA4B;QAC5B,MAAM,MAAM,GAAqC,EAAE,CAAC;QACpD,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAE,MAAkB,CAAC,UAAU,CAAC,CAAC;QAC/D,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAE9C,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;YACnC,MAAM,mBAAmB,GAAG,IAAA,oBAAY,EAAC,SAAS,CAAC,CAAC;YACpD,MAAM,mBAAmB,GAAG,SAAS;gBACnC,CAAC,CAAC,IAAA,oBAAY,EAAC,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC7C,CAAC,CAAC,mBAAmB,CAAC;YACxB,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,IAAA,oBAAY,EAAC,EAAE,CAAC,KAAK,mBAAmB,CAAC,EAAE,CAAC;gBACpE,MAAM,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC;YAC7D,CAAC;QACH,CAAC;QACD,OAAO,CAAC,GAAG,CAAC,6DAA6D,CAAC,CAAC;QAC3E,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,35 @@
1
+ import { SettingsResolver, SyncSettingsResolver } from '../types';
2
+ import { EnvironmentResolverOptions } from './environment';
3
+ /**
4
+ * Options for dotenv resolvers.
5
+ */
6
+ export interface DotenvResolverOptions extends EnvironmentResolverOptions {
7
+ /** Path to the .env file */
8
+ path?: string;
9
+ }
10
+ /**
11
+ * Creates an async resolver that reads configuration from a .env file.
12
+ * It uses the `dotenv` package to load the file into `process.env` first.
13
+ *
14
+ * @param options Resolver options
15
+ * @param options.path Path to the .env file
16
+ * @param options.nestingSeparator Optional separator for nested keys (e.g., '__').
17
+ * If not specified, inherits from defineConfig's nestingSeparator.
18
+ * @param options.caseSensitive Whether to match keys case-sensitively. Defaults to false.
19
+ * @param options.prefix Optional prefix to filter and strip from environment variables.
20
+ * @returns An async resolver function
21
+ */
22
+ export declare function fromDotenv(options?: DotenvResolverOptions): SettingsResolver;
23
+ /**
24
+ * Creates a synchronous resolver that reads from a .env file.
25
+ *
26
+ * @param options Resolver options
27
+ * @param options.path Path to the .env file
28
+ * @param options.nestingSeparator Optional separator for nested keys (e.g., '__').
29
+ * If not specified, inherits from defineConfigSync's nestingSeparator.
30
+ * @param options.caseSensitive Whether to match keys case-sensitively. Defaults to false.
31
+ * @param options.prefix Optional prefix to filter and strip from environment variables.
32
+ * @returns A sync resolver function
33
+ */
34
+ export declare function fromDotenvSync(options?: DotenvResolverOptions): SyncSettingsResolver;
35
+ //# sourceMappingURL=dotenv.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dotenv.d.ts","sourceRoot":"","sources":["../../src/resolvers/dotenv.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAmB,MAAM,UAAU,CAAC;AACnF,OAAO,EAAwC,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAEjG;;GAEG;AACH,MAAM,WAAW,qBAAsB,SAAQ,0BAA0B;IACvE,4BAA4B;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CAAC,OAAO,CAAC,EAAE,qBAAqB,GAAG,gBAAgB,CAM5E;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,OAAO,CAAC,EAAE,qBAAqB,GAAG,oBAAoB,CAKpF"}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fromDotenv = fromDotenv;
4
+ exports.fromDotenvSync = fromDotenvSync;
5
+ const dotenv_1 = require("dotenv");
6
+ const environment_1 = require("./environment");
7
+ /**
8
+ * Creates an async resolver that reads configuration from a .env file.
9
+ * It uses the `dotenv` package to load the file into `process.env` first.
10
+ *
11
+ * @param options Resolver options
12
+ * @param options.path Path to the .env file
13
+ * @param options.nestingSeparator Optional separator for nested keys (e.g., '__').
14
+ * If not specified, inherits from defineConfig's nestingSeparator.
15
+ * @param options.caseSensitive Whether to match keys case-sensitively. Defaults to false.
16
+ * @param options.prefix Optional prefix to filter and strip from environment variables.
17
+ * @returns An async resolver function
18
+ */
19
+ function fromDotenv(options) {
20
+ return async (schema, context) => {
21
+ (0, dotenv_1.config)({ path: options?.path }); // Load .env file into process.env
22
+ // Then, delegate to the environment resolver to pick the values.
23
+ return (0, environment_1.fromEnvironment)(options)(schema, context);
24
+ };
25
+ }
26
+ /**
27
+ * Creates a synchronous resolver that reads from a .env file.
28
+ *
29
+ * @param options Resolver options
30
+ * @param options.path Path to the .env file
31
+ * @param options.nestingSeparator Optional separator for nested keys (e.g., '__').
32
+ * If not specified, inherits from defineConfigSync's nestingSeparator.
33
+ * @param options.caseSensitive Whether to match keys case-sensitively. Defaults to false.
34
+ * @param options.prefix Optional prefix to filter and strip from environment variables.
35
+ * @returns A sync resolver function
36
+ */
37
+ function fromDotenvSync(options) {
38
+ return (schema, context) => {
39
+ (0, dotenv_1.config)({ path: options?.path });
40
+ return (0, environment_1.fromEnvironmentSync)(options)(schema, context);
41
+ };
42
+ }
43
+ //# sourceMappingURL=dotenv.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dotenv.js","sourceRoot":"","sources":["../../src/resolvers/dotenv.ts"],"names":[],"mappings":";;AAyBA,gCAMC;AAaD,wCAKC;AAhDD,mCAAgD;AAEhD,+CAAiG;AAUjG;;;;;;;;;;;GAWG;AACH,SAAgB,UAAU,CAAC,OAA+B;IACxD,OAAO,KAAK,EAAE,MAAe,EAAE,OAAyB,EAAE,EAAE;QAC1D,IAAA,eAAY,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,kCAAkC;QACzE,iEAAiE;QACjE,OAAO,IAAA,6BAAe,EAAC,OAAO,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnD,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,cAAc,CAAC,OAA+B;IAC5D,OAAO,CAAC,MAAe,EAAE,OAAyB,EAAE,EAAE;QACpD,IAAA,eAAY,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QACtC,OAAO,IAAA,iCAAmB,EAAC,OAAO,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvD,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,77 @@
1
+ import { SettingsResolver, SyncSettingsResolver } from '../types';
2
+ /**
3
+ * Options for environment variable resolvers.
4
+ */
5
+ export interface EnvironmentResolverOptions {
6
+ /** Optional separator for nested keys (e.g., '__'). Inherited from defineConfig if not specified. */
7
+ nestingSeparator?: string;
8
+ /** Whether to match keys case-sensitively. Defaults to false. */
9
+ caseSensitive?: boolean;
10
+ /**
11
+ * Optional prefix to filter and strip from environment variables.
12
+ * Only variables starting with this prefix will be resolved.
13
+ * The prefix is stripped from the key in the result.
14
+ *
15
+ * @example
16
+ * // With prefix: 'DATABASE__'
17
+ * // DATABASE__HOST=localhost -> { HOST: 'localhost' }
18
+ * // DATABASE__PORT=5432 -> { PORT: '5432' }
19
+ * // OTHER_VAR=value -> (ignored)
20
+ */
21
+ prefix?: string;
22
+ }
23
+ /**
24
+ * Creates an async resolver that reads from environment variables.
25
+ *
26
+ * @param options Resolver options
27
+ * @param options.nestingSeparator Optional separator for nested keys (e.g., '__').
28
+ * If not specified, inherits from defineConfig's nestingSeparator.
29
+ * @param options.caseSensitive Whether to match keys case-sensitively. Defaults to false.
30
+ * @param options.prefix Optional prefix to filter and strip from environment variables.
31
+ * @returns An async resolver function
32
+ *
33
+ * @example
34
+ * ```typescript
35
+ * // Inherits separator from defineConfig
36
+ * export const { getConfig } = defineConfig(AppConfig, {
37
+ * nestingSeparator: '__',
38
+ * resolvers: [fromEnvironment(), fromDotenv()] // Both inherit '__'
39
+ * });
40
+ *
41
+ * // With prefix - only reads DATABASE__* variables, strips prefix
42
+ * // DATABASE__HOST=localhost -> config.host = 'localhost'
43
+ * export const { getConfig } = defineConfig(DatabaseConfig, {
44
+ * nestingSeparator: '__',
45
+ * resolvers: [fromEnvironment({ prefix: 'DATABASE__' })]
46
+ * });
47
+ * ```
48
+ */
49
+ export declare function fromEnvironment(options?: EnvironmentResolverOptions): SettingsResolver;
50
+ /**
51
+ * Creates a synchronous resolver that reads from environment variables.
52
+ *
53
+ * @param options Resolver options
54
+ * @param options.nestingSeparator Optional separator for nested keys (e.g., '__').
55
+ * If not specified, inherits from defineConfigSync's nestingSeparator.
56
+ * @param options.caseSensitive Whether to match keys case-sensitively. Defaults to false.
57
+ * @param options.prefix Optional prefix to filter and strip from environment variables.
58
+ * @returns A sync resolver function
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * // Inherits separator from defineConfigSync
63
+ * export const { getConfig } = defineConfigSync(AppConfig, {
64
+ * nestingSeparator: '__',
65
+ * resolvers: [fromEnvironmentSync(), fromDotenvSync()] // Both inherit '__'
66
+ * });
67
+ *
68
+ * // With prefix - only reads DATABASE__* variables, strips prefix
69
+ * // DATABASE__HOST=localhost -> config.host = 'localhost'
70
+ * export const { getConfig } = defineConfigSync(DatabaseConfig, {
71
+ * nestingSeparator: '__',
72
+ * resolvers: [fromEnvironmentSync({ prefix: 'DATABASE__' })]
73
+ * });
74
+ * ```
75
+ */
76
+ export declare function fromEnvironmentSync(options?: EnvironmentResolverOptions): SyncSettingsResolver;
77
+ //# sourceMappingURL=environment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../../src/resolvers/environment.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAmB,MAAM,UAAU,CAAC;AAEnF;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,qGAAqG;IACrG,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iEAAiE;IACjE,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;;;;;;;OAUG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAyDD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,eAAe,CAAC,OAAO,CAAC,EAAE,0BAA0B,GAAG,gBAAgB,CAGtF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,CAAC,EAAE,0BAA0B,GAAG,oBAAoB,CAG9F"}
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fromEnvironment = fromEnvironment;
4
+ exports.fromEnvironmentSync = fromEnvironmentSync;
5
+ const utils_1 = require("../utils");
6
+ /**
7
+ * Core environment variable resolution logic.
8
+ * Shared by sync and async versions.
9
+ */
10
+ function resolveFromEnvironment(schema, options, context) {
11
+ const caseSensitive = options?.caseSensitive ?? false;
12
+ // Use resolver's own separator, or inherit from context
13
+ const separator = options?.nestingSeparator ?? context?.nestingSeparator;
14
+ const prefix = options?.prefix;
15
+ const config = {};
16
+ const schemaKeys = Object.keys(schema.properties);
17
+ for (const envKey in process.env) {
18
+ const envValue = process.env[envKey];
19
+ if (envValue === undefined)
20
+ continue;
21
+ // If prefix is specified, only process keys that start with it
22
+ if (prefix) {
23
+ const prefixMatch = caseSensitive
24
+ ? envKey.startsWith(prefix)
25
+ : envKey.toUpperCase().startsWith(prefix.toUpperCase());
26
+ if (!prefixMatch)
27
+ continue;
28
+ // Strip the prefix from the key
29
+ const strippedKey = envKey.slice(prefix.length);
30
+ config[strippedKey] = envValue;
31
+ continue;
32
+ }
33
+ if (caseSensitive) {
34
+ // If case-sensitive, only look for exact matches in the top-level schema keys.
35
+ if (schemaKeys.includes(envKey)) {
36
+ config[envKey] = envValue;
37
+ }
38
+ continue;
39
+ }
40
+ // Case-insensitive and nesting-aware matching.
41
+ const normalizedEnvKey = (0, utils_1.normalizeKey)(envKey);
42
+ const normalizedSchemaKey = separator
43
+ ? (0, utils_1.normalizeKey)(envKey.split(separator)[0])
44
+ : normalizedEnvKey;
45
+ if (schemaKeys.some(sk => (0, utils_1.normalizeKey)(sk) === normalizedSchemaKey)) {
46
+ config[envKey] = envValue;
47
+ }
48
+ }
49
+ return config;
50
+ }
51
+ /**
52
+ * Creates an async resolver that reads from environment variables.
53
+ *
54
+ * @param options Resolver options
55
+ * @param options.nestingSeparator Optional separator for nested keys (e.g., '__').
56
+ * If not specified, inherits from defineConfig's nestingSeparator.
57
+ * @param options.caseSensitive Whether to match keys case-sensitively. Defaults to false.
58
+ * @param options.prefix Optional prefix to filter and strip from environment variables.
59
+ * @returns An async resolver function
60
+ *
61
+ * @example
62
+ * ```typescript
63
+ * // Inherits separator from defineConfig
64
+ * export const { getConfig } = defineConfig(AppConfig, {
65
+ * nestingSeparator: '__',
66
+ * resolvers: [fromEnvironment(), fromDotenv()] // Both inherit '__'
67
+ * });
68
+ *
69
+ * // With prefix - only reads DATABASE__* variables, strips prefix
70
+ * // DATABASE__HOST=localhost -> config.host = 'localhost'
71
+ * export const { getConfig } = defineConfig(DatabaseConfig, {
72
+ * nestingSeparator: '__',
73
+ * resolvers: [fromEnvironment({ prefix: 'DATABASE__' })]
74
+ * });
75
+ * ```
76
+ */
77
+ function fromEnvironment(options) {
78
+ return (schema, context) => Promise.resolve(resolveFromEnvironment(schema, options, context));
79
+ }
80
+ /**
81
+ * Creates a synchronous resolver that reads from environment variables.
82
+ *
83
+ * @param options Resolver options
84
+ * @param options.nestingSeparator Optional separator for nested keys (e.g., '__').
85
+ * If not specified, inherits from defineConfigSync's nestingSeparator.
86
+ * @param options.caseSensitive Whether to match keys case-sensitively. Defaults to false.
87
+ * @param options.prefix Optional prefix to filter and strip from environment variables.
88
+ * @returns A sync resolver function
89
+ *
90
+ * @example
91
+ * ```typescript
92
+ * // Inherits separator from defineConfigSync
93
+ * export const { getConfig } = defineConfigSync(AppConfig, {
94
+ * nestingSeparator: '__',
95
+ * resolvers: [fromEnvironmentSync(), fromDotenvSync()] // Both inherit '__'
96
+ * });
97
+ *
98
+ * // With prefix - only reads DATABASE__* variables, strips prefix
99
+ * // DATABASE__HOST=localhost -> config.host = 'localhost'
100
+ * export const { getConfig } = defineConfigSync(DatabaseConfig, {
101
+ * nestingSeparator: '__',
102
+ * resolvers: [fromEnvironmentSync({ prefix: 'DATABASE__' })]
103
+ * });
104
+ * ```
105
+ */
106
+ function fromEnvironmentSync(options) {
107
+ return (schema, context) => resolveFromEnvironment(schema, options, context);
108
+ }
109
+ //# sourceMappingURL=environment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"environment.js","sourceRoot":"","sources":["../../src/resolvers/environment.ts"],"names":[],"mappings":";;AA2GA,0CAGC;AA4BD,kDAGC;AA5ID,oCAAwC;AAyBxC;;;GAGG;AACH,SAAS,sBAAsB,CAC7B,MAAe,EACf,OAAoC,EACpC,OAAyB;IAEzB,MAAM,aAAa,GAAG,OAAO,EAAE,aAAa,IAAI,KAAK,CAAC;IACtD,wDAAwD;IACxD,MAAM,SAAS,GAAG,OAAO,EAAE,gBAAgB,IAAI,OAAO,EAAE,gBAAgB,CAAC;IACzE,MAAM,MAAM,GAAG,OAAO,EAAE,MAAM,CAAC;IAC/B,MAAM,MAAM,GAAqC,EAAE,CAAC;IACpD,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAE,MAAkB,CAAC,UAAU,CAAC,CAAC;IAE/D,KAAK,MAAM,MAAM,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QACjC,MAAM,QAAQ,GAA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ACH,SAAgB,eAAe,CAAC,OAAoC;IAClE,OAAO,CAAC,MAAe,EAAE,OAAyB,EAAE,EAAE,CACpD,OAAO,CAAC,OAAO,CAAC,sBAAsB,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;AACtE,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,SAAgB,mBAAmB,CAAC,OAAoC;IACtE,OAAO,CAAC,MAAe,EAAE,OAAyB,EAAE,EAAE,CACpD,sBAAsB,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AACrD,CAAC"}
@@ -0,0 +1,5 @@
1
+ export type { SettingsResolver, SyncSettingsResolver } from '../types';
2
+ export { fromEnvironment, fromEnvironmentSync, type EnvironmentResolverOptions, } from './environment';
3
+ export { fromDotenv, fromDotenvSync, type DotenvResolverOptions } from './dotenv';
4
+ export { fromAwsSecretsManager } from './aws';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/resolvers/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAGvE,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,KAAK,0BAA0B,GAChC,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,KAAK,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAGlF,OAAO,EAAE,qBAAqB,EAAE,MAAM,OAAO,CAAC"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fromAwsSecretsManager = exports.fromDotenvSync = exports.fromDotenv = exports.fromEnvironmentSync = exports.fromEnvironment = void 0;
4
+ // Environment resolvers (sync + async)
5
+ var environment_1 = require("./environment");
6
+ Object.defineProperty(exports, "fromEnvironment", { enumerable: true, get: function () { return environment_1.fromEnvironment; } });
7
+ Object.defineProperty(exports, "fromEnvironmentSync", { enumerable: true, get: function () { return environment_1.fromEnvironmentSync; } });
8
+ // Dotenv resolvers (sync + async)
9
+ var dotenv_1 = require("./dotenv");
10
+ Object.defineProperty(exports, "fromDotenv", { enumerable: true, get: function () { return dotenv_1.fromDotenv; } });
11
+ Object.defineProperty(exports, "fromDotenvSync", { enumerable: true, get: function () { return dotenv_1.fromDotenvSync; } });
12
+ // AWS Secrets Manager resolver (async only)
13
+ var aws_1 = require("./aws");
14
+ Object.defineProperty(exports, "fromAwsSecretsManager", { enumerable: true, get: function () { return aws_1.fromAwsSecretsManager; } });
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/resolvers/index.ts"],"names":[],"mappings":";;;AAGA,uCAAuC;AACvC,6CAIuB;AAHrB,8GAAA,eAAe,OAAA;AACf,kHAAA,mBAAmB,OAAA;AAIrB,kCAAkC;AAClC,mCAAkF;AAAzE,oGAAA,UAAU,OAAA;AAAE,wGAAA,cAAc,OAAA;AAEnC,4CAA4C;AAC5C,6BAA8C;AAArC,4GAAA,qBAAqB,OAAA"}
@@ -0,0 +1,211 @@
1
+ import { TObject, TSchema, Static } from '@sinclair/typebox';
2
+ import { ProcessConfigOptions } from './core/pipeline';
3
+ import { SchemaWithComputed, InferPropertiesType, InferConfigType, DeepReadonly, SettingsResolver, SyncSettingsResolver } from './types';
4
+ /**
5
+ * Creates a validated, type-safe configuration object from a TypeBox schema
6
+ * or SchemaWithComputed bundle and a prioritized list of async resolvers.
7
+ *
8
+ * @param schemaOrBundle The TypeBox schema or SchemaWithComputed bundle defining the configuration.
9
+ * @param resolvers An array of async resolver functions, ordered from highest to lowest priority.
10
+ * @param options Configuration options for the settings creation.
11
+ * @param options.nestingSeparator Optional separator for nested keys (e.g., '__').
12
+ * @param options.coerce Whether to coerce types (e.g., convert string "123" to number 123). Defaults to true.
13
+ * @param options.computed Optional map of computed properties to add after validation (auto-extracted from bundle).
14
+ * @returns A promise that resolves to the validated configuration object.
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * // With raw schema
19
+ * const config = await createSettings(
20
+ * AppSchema,
21
+ * [fromEnvironment({ nestingSeparator: '__' })],
22
+ * { nestingSeparator: '__', computed: { ... } }
23
+ * );
24
+ *
25
+ * // With bundle (computed auto-extracted)
26
+ * const config = await createSettings(
27
+ * AppConfig, // SchemaWithComputed bundle
28
+ * [fromEnvironment({ nestingSeparator: '__' })],
29
+ * { nestingSeparator: '__' }
30
+ * );
31
+ * ```
32
+ */
33
+ export declare function createSettings<TBundle extends SchemaWithComputed>(bundle: TBundle, resolvers: SettingsResolver[], options?: Omit<ProcessConfigOptions<InferConfigType<TBundle>>, 'computed'>): Promise<DeepReadonly<InferConfigType<TBundle>>>;
34
+ export declare function createSettings<T extends TSchema>(schema: T, resolvers: SettingsResolver[], options?: ProcessConfigOptions<Static<T>>): Promise<DeepReadonly<Static<T>>>;
35
+ /**
36
+ * Creates a validated, type-safe configuration object from a TypeBox schema
37
+ * or SchemaWithComputed bundle and a prioritized list of synchronous resolvers.
38
+ *
39
+ * This is the synchronous counterpart to `createSettings`. Use this when all
40
+ * your configuration sources are synchronous (e.g., environment variables,
41
+ * in-memory objects).
42
+ *
43
+ * @param schemaOrBundle The TypeBox schema or SchemaWithComputed bundle defining the configuration.
44
+ * @param resolvers An array of sync resolver functions, ordered from highest to lowest priority.
45
+ * @param options Configuration options for the settings creation.
46
+ * @param options.nestingSeparator Optional separator for nested keys (e.g., '__').
47
+ * @param options.coerce Whether to coerce types (e.g., convert string "123" to number 123). Defaults to true.
48
+ * @param options.computed Optional map of computed properties to add after validation (auto-extracted from bundle).
49
+ * @returns The validated configuration object.
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * // With raw schema
54
+ * const config = createSyncSettings(
55
+ * AppSchema,
56
+ * [fromEnvironmentSync({ nestingSeparator: '__' })],
57
+ * { nestingSeparator: '__', computed: { ... } }
58
+ * );
59
+ *
60
+ * // With bundle (computed auto-extracted)
61
+ * const config = createSyncSettings(
62
+ * AppConfig, // SchemaWithComputed bundle
63
+ * [fromEnvironmentSync({ nestingSeparator: '__' })],
64
+ * { nestingSeparator: '__' }
65
+ * );
66
+ * ```
67
+ */
68
+ export declare function createSyncSettings<TBundle extends SchemaWithComputed>(bundle: TBundle, resolvers: SyncSettingsResolver[], options?: Omit<ProcessConfigOptions<InferConfigType<TBundle>>, 'computed'>): DeepReadonly<InferConfigType<TBundle>>;
69
+ export declare function createSyncSettings<T extends TSchema>(schema: T, resolvers: SyncSettingsResolver[], options?: ProcessConfigOptions<Static<T>>): DeepReadonly<Static<T>>;
70
+ type EmptyComputed = Record<string, never>;
71
+ /**
72
+ * Creates a TypeBox object schema for configuration, with optional computed properties.
73
+ *
74
+ * **Overloaded API**:
75
+ * - `Settings(props)` → returns plain TypeBox schema
76
+ * - `Settings(props, computedProps)` → returns SchemaWithComputed bundle
77
+ *
78
+ * **Automatic Nesting**: When nested properties are SchemaWithComputed bundles,
79
+ * their computed properties are automatically scoped and merged.
80
+ *
81
+ * @example
82
+ * // Simple schema without computed properties
83
+ * const SimpleConfig = Settings({
84
+ * host: Settings.String({ default: 'localhost' }),
85
+ * port: Settings.Number({ default: 3000 })
86
+ * });
87
+ *
88
+ * @example
89
+ * // Library defines config with computed properties
90
+ * export const DatabaseConfig = Settings(
91
+ * {
92
+ * host: Settings.String({ default: 'localhost' }),
93
+ * port: Settings.Number({ default: 5432 }),
94
+ * },
95
+ * {
96
+ * url: cfg => `postgresql://${cfg.host}:${cfg.port}`
97
+ * }
98
+ * );
99
+ *
100
+ * @example
101
+ * // App nests library configs - computed properties come along automatically!
102
+ * const AppConfig = Settings(
103
+ * {
104
+ * environment: Settings.String({ default: 'development' }),
105
+ * database: DatabaseConfig // Pass the bundle, computed props come along
106
+ * },
107
+ * {
108
+ * isDev: cfg => cfg.environment === 'development'
109
+ * }
110
+ * );
111
+ *
112
+ * // Result:
113
+ * // config.environment - from schema
114
+ * // config.database.host - from DatabaseConfig schema
115
+ * // config.database.url - from DatabaseConfig computed (auto-scoped!)
116
+ * // config.isDev - from app-level computed
117
+ */
118
+ export declare function Settings<T extends Record<string, TSchema | SchemaWithComputed<any, any>>>(properties: T): SchemaWithComputed<TObject, EmptyComputed, InferPropertiesType<T>>;
119
+ export declare function Settings<T extends Record<string, TSchema | SchemaWithComputed<any, any>>, TComputed extends Record<string, (config: any) => any>>(properties: T, computed: TComputed): SchemaWithComputed<TObject, TComputed, InferPropertiesType<T>>;
120
+ export declare namespace Settings {
121
+ var String: (options?: import("@sinclair/typebox").StringOptions) => import("@sinclair/typebox").TString;
122
+ var Number: (options?: import("@sinclair/typebox").NumberOptions) => import("@sinclair/typebox").TNumber;
123
+ var Boolean: (options?: import("@sinclair/typebox").SchemaOptions) => import("@sinclair/typebox").TBoolean;
124
+ var Enum: <V extends import("@sinclair/typebox").TEnumValue, T extends Record<import("@sinclair/typebox").TEnumKey, V>>(item: T, options?: import("@sinclair/typebox").SchemaOptions) => import("@sinclair/typebox").TEnum<T>;
125
+ var Optional: {
126
+ <Type extends import("@sinclair/typebox").TMappedResult, Flag extends boolean>(type: Type, enable: Flag): import("@sinclair/typebox").TOptionalFromMappedResult<Type, Flag>;
127
+ <Type extends TSchema, Flag extends boolean>(type: Type, enable: Flag): import("@sinclair/typebox").TOptionalWithFlag<Type, Flag>;
128
+ <Type extends import("@sinclair/typebox").TMappedResult>(type: Type): import("@sinclair/typebox").TOptionalFromMappedResult<Type, true>;
129
+ <Type extends TSchema>(type: Type): import("@sinclair/typebox").TOptionalWithFlag<Type, true>;
130
+ };
131
+ var Array: <Type extends TSchema>(items: Type, options?: import("@sinclair/typebox").ArrayOptions) => import("@sinclair/typebox").TArray<Type>;
132
+ var Object: <T extends import("@sinclair/typebox").TProperties>(properties: T, options?: import("@sinclair/typebox").ObjectOptions) => TObject<T>;
133
+ var Literal: <LiteralValue extends import("@sinclair/typebox").TLiteralValue>(literalValue: LiteralValue, options?: import("@sinclair/typebox").SchemaOptions) => import("@sinclair/typebox").TLiteral<LiteralValue>;
134
+ var Union: <Types extends TSchema[]>(types: [...Types], options?: import("@sinclair/typebox").SchemaOptions) => import("@sinclair/typebox").Union<Types>;
135
+ }
136
+ /**
137
+ * Options for defineConfig and defineConfigSync.
138
+ */
139
+ export interface DefineConfigOptions<TResolver = SettingsResolver> {
140
+ /** Separator for nested keys (e.g., '__' for DATABASE__HOST) */
141
+ nestingSeparator?: string;
142
+ /** Resolvers to use for loading configuration */
143
+ resolvers: TResolver[];
144
+ }
145
+ /**
146
+ * Creates a singleton configuration factory with automatic schema/computed extraction.
147
+ *
148
+ * This is the recommended way to define application configuration:
149
+ * - Encapsulates singleton caching pattern
150
+ * - Automatically extracts schema and computed from bundle
151
+ * - Separator inheritance: resolvers inherit `nestingSeparator` from options
152
+ *
153
+ * @param bundle The SchemaWithComputed bundle defining the configuration
154
+ * @param options Configuration options including required resolvers
155
+ * @returns Object with getConfig() and resetConfig() functions
156
+ *
157
+ * @example
158
+ * ```typescript
159
+ * // Resolvers inherit nestingSeparator automatically
160
+ * export const { getConfig, resetConfig } = defineConfig(AppConfig, {
161
+ * nestingSeparator: '__',
162
+ * resolvers: [fromEnvironment(), fromDotenv()] // Both inherit '__'
163
+ * });
164
+ *
165
+ * // Or override per-resolver if needed
166
+ * export const { getConfig } = defineConfig(AppConfig, {
167
+ * nestingSeparator: '__',
168
+ * resolvers: [
169
+ * fromEnvironment(), // Inherits '__'
170
+ * fromDotenv({ nestingSeparator: '--' }) // Uses '--' instead
171
+ * ]
172
+ * });
173
+ *
174
+ * // Usage
175
+ * const config = await getConfig();
176
+ * console.log(config.database.url);
177
+ * ```
178
+ */
179
+ export declare function defineConfig<TBundle extends SchemaWithComputed>(bundle: TBundle, options: DefineConfigOptions): {
180
+ getConfig: () => Promise<DeepReadonly<InferConfigType<TBundle>>>;
181
+ resetConfig: () => void;
182
+ };
183
+ /**
184
+ * Creates a synchronous singleton configuration factory.
185
+ *
186
+ * Use this for CLI tools (like Prisma migrations) that need configuration
187
+ * at module load time before async operations are available.
188
+ *
189
+ * @param bundle The SchemaWithComputed bundle defining the configuration
190
+ * @param options Configuration options including required resolvers
191
+ * @returns Object with getConfig() and resetConfig() functions
192
+ *
193
+ * @example
194
+ * ```typescript
195
+ * // Resolvers inherit nestingSeparator automatically
196
+ * export const { getConfig, resetConfig } = defineConfigSync(AppConfig, {
197
+ * nestingSeparator: '__',
198
+ * resolvers: [fromEnvironmentSync(), fromDotenvSync()] // Both inherit '__'
199
+ * });
200
+ *
201
+ * // Usage (synchronous!)
202
+ * const config = getConfig();
203
+ * console.log(config.database.url);
204
+ * ```
205
+ */
206
+ export declare function defineConfigSync<TBundle extends SchemaWithComputed>(bundle: TBundle, options: DefineConfigOptions<SyncSettingsResolver>): {
207
+ getConfig: () => DeepReadonly<InferConfigType<TBundle>>;
208
+ resetConfig: () => void;
209
+ };
210
+ export {};
211
+ //# sourceMappingURL=settings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAA+C,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAEpG,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,oBAAoB,EACrB,MAAM,SAAS,CAAC;AAMjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,wBAAsB,cAAc,CAAC,OAAO,SAAS,kBAAkB,EACrE,MAAM,EAAE,OAAO,EACf,SAAS,EAAE,gBAAgB,EAAE,EAC7B,OAAO,CAAC,EAAE,IAAI,CAAC,oBAAoB,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,EAAE,UAAU,CAAC,GACzE,OAAO,CAAC,YAAY,CAAC,eAAe,CAA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