@itgorillaz/configify 3.0.0-alpha.0 → 3.0.0-alpha.2

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 (103) hide show
  1. package/index.d.ts +3 -1
  2. package/index.js +20 -6
  3. package/package.json +1 -1
  4. package/.prettierrc +0 -4
  5. package/LICENSE +0 -21
  6. package/README.md +0 -319
  7. package/dist/index.d.ts +0 -3
  8. package/dist/index.js +0 -20
  9. package/index.ts +0 -1
  10. package/nest-cli.json +0 -8
  11. package/src/configify.module.ts +0 -223
  12. package/src/configuration/configuration-options.interface.ts +0 -43
  13. package/src/configuration/configuration-parser.interface.ts +0 -15
  14. package/src/configuration/configuration-providers.interface.ts +0 -9
  15. package/src/configuration/configuration.registry.ts +0 -70
  16. package/src/configuration/index.ts +0 -6
  17. package/src/configuration/parsers/configuration-parser.factory.ts +0 -53
  18. package/src/configuration/parsers/dotenv-configuration.parser.ts +0 -18
  19. package/src/configuration/parsers/index.ts +0 -4
  20. package/src/configuration/parsers/json-configuration.parser.ts +0 -17
  21. package/src/configuration/parsers/yaml-configuration.parser.ts +0 -18
  22. package/src/configuration/resolvers/aws/aws-secrets-resolver.factory.ts +0 -32
  23. package/src/configuration/resolvers/aws/index.ts +0 -3
  24. package/src/configuration/resolvers/aws/parameter-store-configuration.resolver.ts +0 -115
  25. package/src/configuration/resolvers/aws/secrets-manager-configuration.resolver.ts +0 -117
  26. package/src/configuration/resolvers/configuration-resolver.interface.ts +0 -11
  27. package/src/configuration/resolvers/index.ts +0 -2
  28. package/src/configuration/resolvers/resolved-value.interface.ts +0 -10
  29. package/src/decorators/configuration.decorator.ts +0 -26
  30. package/src/decorators/index.ts +0 -2
  31. package/src/decorators/value.decorator.ts +0 -57
  32. package/src/index.ts +0 -3
  33. package/src/interpolation/variables.ts +0 -107
  34. package/tsconfig.build.json +0 -11
  35. package/tsconfig.build.tsbuildinfo +0 -1
  36. package/tsconfig.json +0 -23
  37. /package/{dist/configify.module.d.ts → configify.module.d.ts} +0 -0
  38. /package/{dist/configify.module.js → configify.module.js} +0 -0
  39. /package/{dist/configify.module.js.map → configify.module.js.map} +0 -0
  40. /package/{dist/configuration → configuration}/configuration-options.interface.d.ts +0 -0
  41. /package/{dist/configuration → configuration}/configuration-options.interface.js +0 -0
  42. /package/{dist/configuration → configuration}/configuration-options.interface.js.map +0 -0
  43. /package/{dist/configuration → configuration}/configuration-parser.interface.d.ts +0 -0
  44. /package/{dist/configuration → configuration}/configuration-parser.interface.js +0 -0
  45. /package/{dist/configuration → configuration}/configuration-parser.interface.js.map +0 -0
  46. /package/{dist/configuration → configuration}/configuration-providers.interface.d.ts +0 -0
  47. /package/{dist/configuration → configuration}/configuration-providers.interface.js +0 -0
  48. /package/{dist/configuration → configuration}/configuration-providers.interface.js.map +0 -0
  49. /package/{dist/configuration → configuration}/configuration.registry.d.ts +0 -0
  50. /package/{dist/configuration → configuration}/configuration.registry.js +0 -0
  51. /package/{dist/configuration → configuration}/configuration.registry.js.map +0 -0
  52. /package/{dist/configuration → configuration}/index.d.ts +0 -0
  53. /package/{dist/configuration → configuration}/index.js +0 -0
  54. /package/{dist/configuration → configuration}/index.js.map +0 -0
  55. /package/{dist/configuration → configuration}/parsers/configuration-parser.factory.d.ts +0 -0
  56. /package/{dist/configuration → configuration}/parsers/configuration-parser.factory.js +0 -0
  57. /package/{dist/configuration → configuration}/parsers/configuration-parser.factory.js.map +0 -0
  58. /package/{dist/configuration → configuration}/parsers/dotenv-configuration.parser.d.ts +0 -0
  59. /package/{dist/configuration → configuration}/parsers/dotenv-configuration.parser.js +0 -0
  60. /package/{dist/configuration → configuration}/parsers/dotenv-configuration.parser.js.map +0 -0
  61. /package/{dist/configuration → configuration}/parsers/index.d.ts +0 -0
  62. /package/{dist/configuration → configuration}/parsers/index.js +0 -0
  63. /package/{dist/configuration → configuration}/parsers/index.js.map +0 -0
  64. /package/{dist/configuration → configuration}/parsers/json-configuration.parser.d.ts +0 -0
  65. /package/{dist/configuration → configuration}/parsers/json-configuration.parser.js +0 -0
  66. /package/{dist/configuration → configuration}/parsers/json-configuration.parser.js.map +0 -0
  67. /package/{dist/configuration → configuration}/parsers/yaml-configuration.parser.d.ts +0 -0
  68. /package/{dist/configuration → configuration}/parsers/yaml-configuration.parser.js +0 -0
  69. /package/{dist/configuration → configuration}/parsers/yaml-configuration.parser.js.map +0 -0
  70. /package/{dist/configuration → configuration}/resolvers/aws/aws-secrets-resolver.factory.d.ts +0 -0
  71. /package/{dist/configuration → configuration}/resolvers/aws/aws-secrets-resolver.factory.js +0 -0
  72. /package/{dist/configuration → configuration}/resolvers/aws/aws-secrets-resolver.factory.js.map +0 -0
  73. /package/{dist/configuration → configuration}/resolvers/aws/index.d.ts +0 -0
  74. /package/{dist/configuration → configuration}/resolvers/aws/index.js +0 -0
  75. /package/{dist/configuration → configuration}/resolvers/aws/index.js.map +0 -0
  76. /package/{dist/configuration → configuration}/resolvers/aws/parameter-store-configuration.resolver.d.ts +0 -0
  77. /package/{dist/configuration → configuration}/resolvers/aws/parameter-store-configuration.resolver.js +0 -0
  78. /package/{dist/configuration → configuration}/resolvers/aws/parameter-store-configuration.resolver.js.map +0 -0
  79. /package/{dist/configuration → configuration}/resolvers/aws/secrets-manager-configuration.resolver.d.ts +0 -0
  80. /package/{dist/configuration → configuration}/resolvers/aws/secrets-manager-configuration.resolver.js +0 -0
  81. /package/{dist/configuration → configuration}/resolvers/aws/secrets-manager-configuration.resolver.js.map +0 -0
  82. /package/{dist/configuration → configuration}/resolvers/configuration-resolver.interface.d.ts +0 -0
  83. /package/{dist/configuration → configuration}/resolvers/configuration-resolver.interface.js +0 -0
  84. /package/{dist/configuration → configuration}/resolvers/configuration-resolver.interface.js.map +0 -0
  85. /package/{dist/configuration → configuration}/resolvers/index.d.ts +0 -0
  86. /package/{dist/configuration → configuration}/resolvers/index.js +0 -0
  87. /package/{dist/configuration → configuration}/resolvers/index.js.map +0 -0
  88. /package/{dist/configuration → configuration}/resolvers/resolved-value.interface.d.ts +0 -0
  89. /package/{dist/configuration → configuration}/resolvers/resolved-value.interface.js +0 -0
  90. /package/{dist/configuration → configuration}/resolvers/resolved-value.interface.js.map +0 -0
  91. /package/{dist/decorators → decorators}/configuration.decorator.d.ts +0 -0
  92. /package/{dist/decorators → decorators}/configuration.decorator.js +0 -0
  93. /package/{dist/decorators → decorators}/configuration.decorator.js.map +0 -0
  94. /package/{dist/decorators → decorators}/index.d.ts +0 -0
  95. /package/{dist/decorators → decorators}/index.js +0 -0
  96. /package/{dist/decorators → decorators}/index.js.map +0 -0
  97. /package/{dist/decorators → decorators}/value.decorator.d.ts +0 -0
  98. /package/{dist/decorators → decorators}/value.decorator.js +0 -0
  99. /package/{dist/decorators → decorators}/value.decorator.js.map +0 -0
  100. /package/{dist/index.js.map → index.js.map} +0 -0
  101. /package/{dist/interpolation → interpolation}/variables.d.ts +0 -0
  102. /package/{dist/interpolation → interpolation}/variables.js +0 -0
  103. /package/{dist/interpolation → interpolation}/variables.js.map +0 -0
@@ -1,15 +0,0 @@
1
- /**
2
- * The configuration parser interface.
3
- * This interface is implemented by all
4
- * the supported configuration parsers.
5
- */
6
- export interface ConfigurationParser {
7
- /**
8
- * Reads a file and assign its values
9
- * to an object representation;
10
- *
11
- * @param {string} file the configuration file path
12
- * @returns {Record<string, any>} the object representation of the configuration file
13
- */
14
- parse(file: string): Record<string, any>;
15
- }
@@ -1,9 +0,0 @@
1
- import { Provider } from '@nestjs/common';
2
-
3
- /**
4
- * The configuration providers interface
5
- */
6
- export interface ConfigurationProviders {
7
- exports: any[];
8
- providers: Provider[];
9
- }
@@ -1,70 +0,0 @@
1
- import {
2
- ValueDecoratedKey,
3
- VALUE_METADATA,
4
- VALUE_PROPERTIES_METADATA,
5
- } from '../decorators';
6
-
7
- /**
8
- * The configuration registry.
9
- *
10
- * The registry keeps track of all classes decorated
11
- * with Configuration decorator.
12
- */
13
- export class ConfigurationRegistry {
14
- private static readonly registry: Array<unknown> = [];
15
-
16
- /**
17
- * Registers a type.
18
- *
19
- * @param {any} type the class type
20
- */
21
- static registerTarget(type: any): void {
22
- this.registry.push(type);
23
- }
24
-
25
- /**
26
- * Registers a class attribute.
27
- *
28
- * @param {any} target the class target
29
- * @param {string} attribute the attribute name
30
- */
31
- static registerAttribute(target: any, attribute: string | symbol): void {
32
- (
33
- target[VALUE_PROPERTIES_METADATA] ||
34
- (target[VALUE_PROPERTIES_METADATA] = [])
35
- ).push(attribute);
36
- }
37
-
38
- /**
39
- * Returns the configuration registry.
40
- *
41
- * @returns {any[]} the configuration registry
42
- */
43
- static getRegistry(): any[] {
44
- return this.registry;
45
- }
46
-
47
- /**
48
- * Returns the class attribute names decorated with Decorated decorator
49
- *
50
- * @param {any} target the instance target;
51
- * @returns {string[]} the list of attribute names
52
- */
53
- static getValueDecoratedAttributes(target: any): string[] {
54
- return target[VALUE_PROPERTIES_METADATA];
55
- }
56
-
57
- /**
58
- * Returns the value of the decorated key.
59
- *
60
- * @param {any} instance the target instance
61
- * @param {string} attribute the attribute name
62
- * @returns {ValueDecoratedKey} the value decorated key
63
- */
64
- static getValueDecoratedKey(
65
- instance: any,
66
- attribute: string,
67
- ): ValueDecoratedKey {
68
- return Reflect.getMetadata(VALUE_METADATA, instance, attribute);
69
- }
70
- }
@@ -1,6 +0,0 @@
1
- export * from './configuration-options.interface';
2
- export * from './configuration-parser.interface';
3
- export * from './configuration-providers.interface';
4
- export * from './configuration.registry';
5
- export * from './parsers';
6
- export * from './resolvers';
@@ -1,53 +0,0 @@
1
- import { ConfigurationParser } from '../configuration-parser.interface';
2
- import { DotEnvConfigurationParser } from './dotenv-configuration.parser';
3
- import { JsonConfigurationParser } from './json-configuration.parser';
4
- import { YamlConfigurationParser } from './yaml-configuration.parser';
5
-
6
- /**
7
- * The configuration parser factory.
8
- * This factory class contains all the supported
9
- * file configuration parsers.
10
- */
11
- export class ConfigurationParserFactory {
12
- /**
13
- * The supported file configuration parsers
14
- */
15
- private static readonly parsers: Record<string, ConfigurationParser> = {
16
- env: new DotEnvConfigurationParser(),
17
- yml: new YamlConfigurationParser(),
18
- yaml: new YamlConfigurationParser(),
19
- json: new JsonConfigurationParser(),
20
- };
21
-
22
- /**
23
- * Gets the file configuration parser based
24
- * on the file extension.
25
- * @param {string} file the configuration file name
26
- * @returns {ConfigurationParser} the configuration parser
27
- */
28
- static getParser(file: string): ConfigurationParser {
29
- const ext = this.getFileExt(file) as keyof typeof this.parsers;
30
- return this.parsers[ext];
31
- }
32
-
33
- /**
34
- * Checks if the given file has a parser registered.
35
- *
36
- * @param {string} file the configuration file name
37
- * @returns {boolean} true if a parser is found, false otherwise
38
- */
39
- static supports(file: string): boolean {
40
- const ext = this.getFileExt(file);
41
- return ext ? this.parsers.hasOwnProperty(ext) : false;
42
- }
43
-
44
- /**
45
- * Returns the file extension.
46
- *
47
- * @param {string} file the file name
48
- * @returns {string} the file extension
49
- */
50
- private static getFileExt(file: string): string | undefined {
51
- return file.split('.').pop();
52
- }
53
- }
@@ -1,18 +0,0 @@
1
- import * as dotenv from 'dotenv';
2
- import * as fs from 'fs';
3
- import { ConfigurationParser } from '../configuration-parser.interface';
4
-
5
- /**
6
- * Dotenv configuration parser.
7
- */
8
- export class DotEnvConfigurationParser implements ConfigurationParser {
9
- /**
10
- * Reads the configuration file and assign
11
- * its contents to an object.
12
- * @param {string} file the configuration file
13
- * @returns {Record<string, any>} an object representation of the configuration file
14
- */
15
- public parse(file: string): Record<string, any> {
16
- return dotenv.parse(fs.readFileSync(file));
17
- }
18
- }
@@ -1,4 +0,0 @@
1
- export * from './configuration-parser.factory';
2
- export * from './dotenv-configuration.parser';
3
- export * from './json-configuration.parser';
4
- export * from './yaml-configuration.parser';
@@ -1,17 +0,0 @@
1
- import * as fs from 'fs';
2
- import { ConfigurationParser } from '../configuration-parser.interface';
3
-
4
- /**
5
- * JSON configuration parser
6
- */
7
- export class JsonConfigurationParser implements ConfigurationParser {
8
- /**
9
- * Reads the configuration file and assign
10
- * its contents to an object.
11
- * @param {string} file the configuration file
12
- * @returns {Record<string, any>} an object representation of the configuration file
13
- */
14
- public parse(file: string): Record<string, any> {
15
- return JSON.parse(fs.readFileSync(file, 'utf-8'));
16
- }
17
- }
@@ -1,18 +0,0 @@
1
- import * as fs from 'fs';
2
- import * as yaml from 'js-yaml';
3
- import { ConfigurationParser } from '../configuration-parser.interface';
4
-
5
- /**
6
- * YAML configuration parser
7
- */
8
- export class YamlConfigurationParser implements ConfigurationParser {
9
- /**
10
- * Reads the configuration file and assign
11
- * its contents to an object.
12
- * @param {string} file the configuration file
13
- * @returns {Record<string, any>} an object representation of the configuration file
14
- */
15
- public parse(file: string): Record<string, any> {
16
- return yaml.load(fs.readFileSync(file, 'utf-8')) as Record<string, any>;
17
- }
18
- }
@@ -1,32 +0,0 @@
1
- import { SecretsManagerClient } from '@aws-sdk/client-secrets-manager';
2
- import { SSMClient } from '@aws-sdk/client-ssm';
3
- import { ConfigurationResolver } from '../configuration-resolver.interface';
4
- import { AwsParameterStoreConfigurationResolver } from './parameter-store-configuration.resolver';
5
- import { AwsSecretsManagerConfigurationResolver } from './secrets-manager-configuration.resolver';
6
-
7
- /**
8
- * The AWS secrets resolver factory.
9
- * This class provides the default secrets resolvers for the module.
10
- * The default secrets resolvers are:
11
- * - Parameter Store
12
- * - Secrets Manager
13
- */
14
- export class AwsSecretsResolverFactory {
15
- /**
16
- * The default parameter store secrets resolver
17
- * @returns {ConfigurationResolver} the default parameter store secrets resolver
18
- */
19
- static defaultParameterStoreResolver(): ConfigurationResolver {
20
- return new AwsParameterStoreConfigurationResolver(new SSMClient());
21
- }
22
-
23
- /**
24
- * The default secrets manager secrets resolver
25
- * @returns {ConfigurationResolver} the default secrets manager secrets resolver
26
- */
27
- static defaultSecretsManagerResolver(): ConfigurationResolver {
28
- return new AwsSecretsManagerConfigurationResolver(
29
- new SecretsManagerClient(),
30
- );
31
- }
32
- }
@@ -1,3 +0,0 @@
1
- export * from './aws-secrets-resolver.factory';
2
- export * from './parameter-store-configuration.resolver';
3
- export * from './secrets-manager-configuration.resolver';
@@ -1,115 +0,0 @@
1
- import { GetParameterCommand, SSMClient } from '@aws-sdk/client-ssm';
2
- import { ConfigurationResolver } from '../configuration-resolver.interface';
3
- import { ResolvedValue } from '../resolved-value.interface';
4
-
5
- /**
6
- * AWS Parameter Store configuration resolver.
7
- */
8
- export class AwsParameterStoreConfigurationResolver
9
- implements ConfigurationResolver
10
- {
11
- private readonly AWS_PARAMETER_STORE_YAML_KEY = 'aws-parameter-store';
12
- private readonly AWS_PARAMETER_STORE_ENV_PREFIX = 'AWS_PARAMETER_STORE';
13
-
14
- /**
15
- * Creates a new instance of parameter store configuration resolver
16
- *
17
- * @param {SSMClient} ssm systems manager client
18
- */
19
- constructor(private readonly ssm: SSMClient) {}
20
-
21
- /**
22
- * Fetches parameters and assign it to an object representation
23
- * of the configuration.
24
- *
25
- * @param {Record<string, any>} config the configuration object
26
- * @returns {Record<string, any>} the cofiguration with secret values assigned
27
- * @throws {Error} if unable to fetch the secret
28
- */
29
- async resolve(config: Record<string, any>): Promise<Record<string, any>> {
30
- const parameters = this.filterConfiguration(config);
31
- const promises = this.buildBulkRequest(parameters);
32
-
33
- const results = await Promise.all(promises);
34
-
35
- const errors = results.filter((r) => !r.success);
36
- if (errors && errors.length) {
37
- throw new Error(
38
- `Unable to resolve parameter:\n${errors
39
- .map((e) => `${e.key}: ${e.id} - ${e.error?.message}`)
40
- .join('\n')}`,
41
- );
42
- }
43
-
44
- for (const result of results) {
45
- config[result.key] = result.value;
46
- }
47
-
48
- return config;
49
- }
50
-
51
- /**
52
- * Filters the configuration object by aws parameters store keys.
53
- *
54
- * @param {Record<string, any>} config the configuration object
55
- * @returns {Record<string, any>} the filtered object
56
- */
57
- private filterConfiguration(
58
- config: Record<string, any>,
59
- ): Record<string, any> {
60
- return Object.fromEntries(
61
- Object.entries(config).filter(
62
- ([key]) =>
63
- key.startsWith(this.AWS_PARAMETER_STORE_YAML_KEY) ||
64
- key.startsWith(this.AWS_PARAMETER_STORE_ENV_PREFIX),
65
- ),
66
- );
67
- }
68
-
69
- /**
70
- * Resolves parameter values.
71
- *
72
- * @param {string} key the object key
73
- * @param {string} id the secret id
74
- * @returns
75
- */
76
- private async resolveSecretValue(
77
- key: string,
78
- id: string,
79
- ): Promise<ResolvedValue> {
80
- try {
81
- const payload = { Name: id, WithDecryption: true };
82
- const command = new GetParameterCommand(payload);
83
- const response = await this.ssm.send(command);
84
- return {
85
- id,
86
- key,
87
- value: response.Parameter?.Value,
88
- success: true,
89
- };
90
- } catch (e) {
91
- return {
92
- id,
93
- key,
94
- error: e as Error,
95
- success: false,
96
- };
97
- }
98
- }
99
-
100
- /**
101
- * Creates a list of promises to get parameter values.
102
- *
103
- * @param {Record<string, any>} config the configuration object
104
- * @returns {Promise<ResolvedValue>[]} the get parameter value promises
105
- */
106
- private buildBulkRequest(
107
- config: Record<string, any>,
108
- ): Promise<ResolvedValue>[] {
109
- const promises: Promise<ResolvedValue>[] = [];
110
- for (const [key, value] of Object.entries(config)) {
111
- promises.push(this.resolveSecretValue(key, value));
112
- }
113
- return promises;
114
- }
115
- }
@@ -1,117 +0,0 @@
1
- import {
2
- GetSecretValueCommand,
3
- SecretsManagerClient,
4
- } from '@aws-sdk/client-secrets-manager';
5
- import { ConfigurationResolver } from '../configuration-resolver.interface';
6
- import { ResolvedValue } from '../resolved-value.interface';
7
-
8
- /**
9
- * AWS Secrets Manager configuration resolver.
10
- */
11
- export class AwsSecretsManagerConfigurationResolver
12
- implements ConfigurationResolver
13
- {
14
- private readonly AWS_SECRETS_AMANGER_YAML_KEY = 'aws-secrets-manager';
15
- private readonly AWS_SECRETS_MANAGER_ENV_PREFIX = 'AWS_SECRETS_MANAGER';
16
-
17
- /**
18
- * Creates a new instance of secrets manager configuration resolver
19
- *
20
- * @param {SecretsManagerClient} secretsManager secrets manager client
21
- */
22
- constructor(private readonly secretsManager: SecretsManagerClient) {}
23
-
24
- /**
25
- * Fetches secrets and assign it to an object representation
26
- * of the configuration.
27
- *
28
- * @param {Record<string, any>} config the configuration object
29
- * @returns {Record<string, any>} the cofiguration with secret values assigned
30
- * @throws {Error} if unable to fetch the secret
31
- */
32
- async resolve(config: Record<string, any>): Promise<Record<string, any>> {
33
- const secrets = this.filterConfiguration(config);
34
- const promises = this.buildBulkRequest(secrets);
35
-
36
- const results = await Promise.all(promises);
37
-
38
- const errors = results.filter((r) => !r.success);
39
- if (errors && errors.length) {
40
- throw new Error(
41
- `Unable to resolve secrets:\n${errors
42
- .map((e) => `${e.key}: ${e.id} - ${e.error?.message}`)
43
- .join('\n')}`,
44
- );
45
- }
46
-
47
- for (const result of results) {
48
- config[result.key] = result.value;
49
- }
50
-
51
- return config;
52
- }
53
-
54
- /**
55
- * Filters the configuration object by aws secrets manager keys.
56
- *
57
- * @param {Record<string, any>} config the configuration object
58
- * @returns {Record<string, any>} the filtered object
59
- */
60
- private filterConfiguration(
61
- config: Record<string, any>,
62
- ): Record<string, any> {
63
- return Object.fromEntries(
64
- Object.entries(config).filter(
65
- ([key]) =>
66
- key.startsWith(this.AWS_SECRETS_AMANGER_YAML_KEY) ||
67
- key.startsWith(this.AWS_SECRETS_MANAGER_ENV_PREFIX),
68
- ),
69
- );
70
- }
71
-
72
- /**
73
- * Resolves secret values.
74
- *
75
- * @param {string} key the object key
76
- * @param {string} id the secret id
77
- * @returns
78
- */
79
- private async resolveSecretValue(
80
- key: string,
81
- id: string,
82
- ): Promise<ResolvedValue> {
83
- try {
84
- const command = new GetSecretValueCommand({ SecretId: id });
85
- const response = await this.secretsManager.send(command);
86
- return {
87
- id,
88
- key,
89
- value: response.SecretString,
90
- success: true,
91
- };
92
- } catch (e) {
93
- return {
94
- id,
95
- key,
96
- error: e as Error,
97
- success: false,
98
- };
99
- }
100
- }
101
-
102
- /**
103
- * Creates a list of promises to get secret values.
104
- *
105
- * @param {Record<string, any>} config the configuration object
106
- * @returns {Promise<ResolvedValue>[]} the get secret value promises
107
- */
108
- private buildBulkRequest(
109
- config: Record<string, any>,
110
- ): Promise<ResolvedValue>[] {
111
- const promises: Promise<ResolvedValue>[] = [];
112
- for (const [key, value] of Object.entries(config)) {
113
- promises.push(this.resolveSecretValue(key, value));
114
- }
115
- return promises;
116
- }
117
- }
@@ -1,11 +0,0 @@
1
- /**
2
- * The configuration resolver interface
3
- */
4
- export interface ConfigurationResolver {
5
- /**
6
- * Resolves a remote configuration
7
- *
8
- * @param {Record<string, any>} configuration the configuration obejct
9
- */
10
- resolve(configuration: Record<string, any>): Promise<Record<string, any>>;
11
- }
@@ -1,2 +0,0 @@
1
- export * from './configuration-resolver.interface';
2
- export * from './resolved-value.interface';
@@ -1,10 +0,0 @@
1
- /**
2
- * The resolved value interface
3
- */
4
- export interface ResolvedValue {
5
- id: string;
6
- success: boolean;
7
- key: string;
8
- value?: string;
9
- error?: Error;
10
- }
@@ -1,26 +0,0 @@
1
- import { ConfigurationRegistry } from '../configuration/configuration.registry';
2
-
3
- /**
4
- * The configuration metadata
5
- */
6
- export const CONFIGURATION_METADATA = Symbol.for('__configuration__');
7
-
8
- /**
9
- * The configuration decorator.
10
- *
11
- * Decorating a class with this decorator will make it
12
- * visible for the module to manage its instance and assign
13
- * values to the class attributes based on configuration files.
14
- *
15
- * @returns {ClassDecorator} the class decorator
16
- */
17
- export const Configuration = (): ClassDecorator => {
18
- return (target: object) => {
19
- ConfigurationRegistry.registerTarget(target);
20
- Reflect.defineMetadata(
21
- CONFIGURATION_METADATA,
22
- target.constructor.name,
23
- target,
24
- );
25
- };
26
- };
@@ -1,2 +0,0 @@
1
- export * from './configuration.decorator';
2
- export * from './value.decorator';
@@ -1,57 +0,0 @@
1
- import { ConfigurationRegistry } from '../configuration/configuration.registry';
2
-
3
- /**
4
- * The value metadata.
5
- */
6
- export const VALUE_METADATA = Symbol.for('__value__');
7
-
8
- /**
9
- * The value properties metadata.
10
- */
11
- export const VALUE_PROPERTIES_METADATA = Symbol.for('__properties__');
12
-
13
- /**
14
- * The value options.
15
- * Allows custom parsing to configuration values
16
- */
17
- export interface ValueOptions {
18
- /**
19
- * Parses the configuration value.
20
- * @param value
21
- * @returns parsed value
22
- */
23
- parse?: (value: any) => unknown;
24
-
25
- /**
26
- * Sets a default value if the configuration key is not found.
27
- */
28
- default?: any;
29
- }
30
-
31
- /**
32
- * The value decorated key interface.
33
- */
34
- export interface ValueDecoratedKey {
35
- key: string;
36
- options?: ValueOptions;
37
- }
38
-
39
- /**
40
- * The value decorator.
41
- *
42
- * This decorator defines which configuration key should
43
- * be assined to the class attribute.
44
- *
45
- * @param {string} key the configuration key
46
- * @param {ValueOptions} options custom options
47
- * @returns {PropertyDecorator} the property decorator
48
- */
49
- export const Value = (
50
- key: string,
51
- options?: ValueOptions,
52
- ): PropertyDecorator => {
53
- return (target: object, property: string | symbol) => {
54
- ConfigurationRegistry.registerAttribute(target, property);
55
- Reflect.defineMetadata(VALUE_METADATA, { key, options }, target, property);
56
- };
57
- };
package/src/index.ts DELETED
@@ -1,3 +0,0 @@
1
- export * from './configify.module';
2
- export * from './configuration';
3
- export * from './decorators';