@lanya-studio/vault-config-validator 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.
package/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # vault-config-validator
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Building
6
+
7
+ Run `nx build vault-config-validator` to build the library.
@@ -0,0 +1,3 @@
1
+ export * from './lib/errors';
2
+ export * from './lib/parse-and-validate-vault-config';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,uCAAuC,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,43 @@
1
+ // packages/vault-config-validator/src/lib/errors.ts
2
+ var VaultConfigNotFoundError = class extends Error {
3
+ configKey;
4
+ constructor(configKey) {
5
+ const message = `Vault config not found: ${configKey}`;
6
+ super(message);
7
+ this.name = "VaultConfigNotFoundError";
8
+ Object.setPrototypeOf(this, new.target.prototype);
9
+ this.configKey = configKey;
10
+ }
11
+ };
12
+ var VaultConfigValidationError = class extends Error {
13
+ configKey;
14
+ validationErrors;
15
+ constructor(configKey, validationErrors) {
16
+ super(`Vault config validation failed for ${configKey}: ${validationErrors.join(", ")}`);
17
+ this.name = "VaultConfigValidationError";
18
+ Object.setPrototypeOf(this, new.target.prototype);
19
+ this.configKey = configKey;
20
+ this.validationErrors = validationErrors;
21
+ }
22
+ };
23
+
24
+ // packages/vault-config-validator/src/lib/parse-and-validate-vault-config.ts
25
+ import { plainToInstance } from "class-transformer";
26
+ import { validate } from "class-validator";
27
+ var parseAndValidateVaultConfig = async (vaultService, vaultKey, configClass) => {
28
+ const input = await vaultService.get(vaultKey);
29
+ if (!input) {
30
+ throw new VaultConfigNotFoundError(vaultKey);
31
+ }
32
+ const preferences = plainToInstance(configClass, input);
33
+ const errors = await validate(preferences);
34
+ if (errors.length > 0) {
35
+ throw new VaultConfigValidationError(vaultKey, errors);
36
+ }
37
+ return preferences;
38
+ };
39
+ export {
40
+ VaultConfigNotFoundError,
41
+ VaultConfigValidationError,
42
+ parseAndValidateVaultConfig
43
+ };
@@ -0,0 +1,11 @@
1
+ import { ValidationError } from "class-validator";
2
+ export declare class VaultConfigNotFoundError extends Error {
3
+ readonly configKey: string;
4
+ constructor(configKey: string);
5
+ }
6
+ export declare class VaultConfigValidationError extends Error {
7
+ readonly configKey: string;
8
+ readonly validationErrors: ValidationError[];
9
+ constructor(configKey: string, validationErrors: ValidationError[]);
10
+ }
11
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/lib/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,qBAAa,wBAAyB,SAAQ,KAAK;IACjD,SAAgB,SAAS,EAAE,MAAM,CAAC;gBAEtB,SAAS,EAAE,MAAM;CAQ9B;AAED,qBAAa,0BAA2B,SAAQ,KAAK;IACnD,SAAgB,SAAS,EAAE,MAAM,CAAC;IAClC,SAAgB,gBAAgB,EAAE,eAAe,EAAE,CAAC;gBAExC,SAAS,EAAE,MAAM,EAAE,gBAAgB,EAAE,eAAe,EAAE;CAQnE"}
@@ -0,0 +1,3 @@
1
+ import { VaultService } from '@rytass/secret-adapter-vault-nestjs';
2
+ export declare const parseAndValidateVaultConfig: <T extends object>(vaultService: VaultService, vaultKey: string, configClass: new () => T) => Promise<T>;
3
+ //# sourceMappingURL=parse-and-validate-vault-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-and-validate-vault-config.d.ts","sourceRoot":"","sources":["../../src/lib/parse-and-validate-vault-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAKnE,eAAO,MAAM,2BAA2B,GAAU,CAAC,SAAS,MAAM,EAChE,cAAc,YAAY,EAC1B,UAAU,MAAM,EAChB,aAAa,UAAU,CAAC,KACvB,OAAO,CAAC,CAAC,CAcX,CAAC"}
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@lanya-studio/vault-config-validator",
3
+ "version": "0.0.1",
4
+ "type": "module",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "publishConfig": {
9
+ "access": "public"
10
+ },
11
+ "exports": {
12
+ "./package.json": "./package.json",
13
+ ".": {
14
+ "@packages/source": "./src/index.ts",
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.js",
17
+ "default": "./dist/index.js"
18
+ }
19
+ },
20
+ "files": [
21
+ "dist",
22
+ "!**/*.tsbuildinfo"
23
+ ],
24
+ "nx": {
25
+ "targets": {
26
+ "build": {
27
+ "executor": "@nx/esbuild:esbuild",
28
+ "outputs": [
29
+ "{options.outputPath}"
30
+ ],
31
+ "options": {
32
+ "outputPath": "packages/vault-config-validator/dist",
33
+ "main": "packages/vault-config-validator/src/index.ts",
34
+ "tsConfig": "packages/vault-config-validator/tsconfig.lib.json",
35
+ "format": [
36
+ "esm"
37
+ ],
38
+ "declarationRootDir": "packages/vault-config-validator/src"
39
+ }
40
+ }
41
+ }
42
+ },
43
+ "dependencies": {
44
+ "@rytass/secret-adapter-vault-nestjs": "^0.4.4",
45
+ "class-transformer": "^0.5.1",
46
+ "class-validator": "^0.14.2"
47
+ }
48
+ }