@luolapeikko/core-env-secretspec 0.0.3
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 +34 -0
- package/dist/index.cjs +30 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +20 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +20 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +29 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +53 -0
package/README.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# @luolapeikko/core-env-secretspec
|
|
2
|
+
|
|
3
|
+
SecretSpec loader for EnvKit
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- SecretSpec environment variables loader
|
|
8
|
+
|
|
9
|
+
## Example
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
type EnvMap = {
|
|
13
|
+
API_SERVER: string;
|
|
14
|
+
FEATURE_FLAG: boolean;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const secretSpecLoader = new SecretSpecConfigLoader(); // {provider?: string; profile?: string; reason?: string; path?: string;} | {disabled?: boolean}
|
|
18
|
+
|
|
19
|
+
const baseEnv = new EnvKit<EnvMap>(
|
|
20
|
+
{
|
|
21
|
+
API_SERVER: {
|
|
22
|
+
notFoundError: true,
|
|
23
|
+
parser: KeyParser.String(),
|
|
24
|
+
},
|
|
25
|
+
FEATURE_FLAG: {
|
|
26
|
+
parser: KeyParser.Boolean(),
|
|
27
|
+
defaultValue: false,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
[secretSpecLoader],
|
|
31
|
+
);
|
|
32
|
+
const apiServer: string = (await baseEnv.get("API_SERVER")).unwrap();
|
|
33
|
+
const featureFlag: boolean = (await baseEnv.get("FEATURE_FLAG")).unwrap();
|
|
34
|
+
```
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let _luolapeikko_core_env = require("@luolapeikko/core-env");
|
|
3
|
+
let _luolapeikko_result_option = require("@luolapeikko/result-option");
|
|
4
|
+
let secretspec = require("secretspec");
|
|
5
|
+
//#region src/index.ts
|
|
6
|
+
var SecretSpecConfigLoader = class extends _luolapeikko_core_env.AbstractBaseLoader {
|
|
7
|
+
loaderType = "secretspec";
|
|
8
|
+
resolved;
|
|
9
|
+
defaultOptions = { disabled: false };
|
|
10
|
+
constructor(options = {}, override) {
|
|
11
|
+
super(override);
|
|
12
|
+
let builder = secretspec.SecretSpec.builder();
|
|
13
|
+
if (options.path) builder = builder.withPath(options.path);
|
|
14
|
+
if (options.provider) builder = builder.withProvider(options.provider);
|
|
15
|
+
if (options.profile) builder = builder.withProfile(options.profile);
|
|
16
|
+
if (options.reason) builder = builder.withReason(options.reason);
|
|
17
|
+
this.resolved = builder.load();
|
|
18
|
+
}
|
|
19
|
+
getRawValue(lookupKey) {
|
|
20
|
+
const resolvedValue = this.resolved.secrets[lookupKey];
|
|
21
|
+
return (0, _luolapeikko_result_option.Ok)({
|
|
22
|
+
path: `secretspec[profiles.${this.resolved.profile}] ${lookupKey}`,
|
|
23
|
+
value: resolvedValue.value ?? void 0
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
//#endregion
|
|
28
|
+
exports.SecretSpecConfigLoader = SecretSpecConfigLoader;
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["AbstractBaseLoader","SecretSpec"],"sources":["../src/index.ts"],"sourcesContent":["import {AbstractBaseLoader, type IAbstractBaseLoaderProps, type LoaderValueResult, type OverrideKeyMap} from '@luolapeikko/core-env';\nimport {type IResult, Ok} from '@luolapeikko/result-option';\nimport {type Resolved, SecretSpec} from 'secretspec';\n\nexport type SecretSpecConfigLoaderProps = IAbstractBaseLoaderProps & {\n\tprovider?: string;\n\tprofile?: string;\n\treason?: string;\n\tpath?: string;\n};\n\nexport class SecretSpecConfigLoader<OverrideMap extends OverrideKeyMap = OverrideKeyMap> extends AbstractBaseLoader<IAbstractBaseLoaderProps, OverrideMap> {\n\tpublic readonly loaderType = 'secretspec';\n\tprivate readonly resolved: Resolved;\n\n\tpublic override defaultOptions: IAbstractBaseLoaderProps = {\n\t\tdisabled: false,\n\t};\n\n\tpublic constructor(options: SecretSpecConfigLoaderProps = {}, override?: Partial<OverrideMap>) {\n\t\tsuper(override);\n\t\tlet builder = SecretSpec.builder();\n\t\tif (options.path) {\n\t\t\tbuilder = builder.withPath(options.path);\n\t\t}\n\t\tif (options.provider) {\n\t\t\tbuilder = builder.withProvider(options.provider);\n\t\t}\n\t\tif (options.profile) {\n\t\t\tbuilder = builder.withProfile(options.profile);\n\t\t}\n\t\tif (options.reason) {\n\t\t\tbuilder = builder.withReason(options.reason);\n\t\t}\n\t\tthis.resolved = builder.load();\n\t}\n\n\tprotected getRawValue(lookupKey: string): IResult<LoaderValueResult, Error> {\n\t\tconst resolvedValue = this.resolved.secrets[lookupKey];\n\t\treturn Ok({path: `secretspec[profiles.${this.resolved.profile}] ${lookupKey}`, value: resolvedValue.value ?? undefined});\n\t}\n}\n"],"mappings":";;;;;AAWA,IAAa,yBAAb,cAAiGA,sBAAAA,mBAA0D;CAC1J,aAA6B;CAC7B;CAEA,iBAA2D,EAC1D,UAAU,MACX;CAEA,YAAmB,UAAuC,CAAC,GAAG,UAAiC;EAC9F,MAAM,QAAQ;EACd,IAAI,UAAUC,WAAAA,WAAW,QAAQ;EACjC,IAAI,QAAQ,MACX,UAAU,QAAQ,SAAS,QAAQ,IAAI;EAExC,IAAI,QAAQ,UACX,UAAU,QAAQ,aAAa,QAAQ,QAAQ;EAEhD,IAAI,QAAQ,SACX,UAAU,QAAQ,YAAY,QAAQ,OAAO;EAE9C,IAAI,QAAQ,QACX,UAAU,QAAQ,WAAW,QAAQ,MAAM;EAE5C,KAAK,WAAW,QAAQ,KAAK;CAC9B;CAEA,YAAsB,WAAsD;EAC3E,MAAM,gBAAgB,KAAK,SAAS,QAAQ;EAC5C,QAAA,GAAA,2BAAA,GAAA,CAAU;GAAC,MAAM,uBAAuB,KAAK,SAAS,QAAQ,IAAI;GAAa,OAAO,cAAc,SAAS,KAAA;EAAS,CAAC;CACxH;AACD"}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AbstractBaseLoader, IAbstractBaseLoaderProps, LoaderValueResult, OverrideKeyMap } from "@luolapeikko/core-env";
|
|
2
|
+
import { IResult } from "@luolapeikko/result-option";
|
|
3
|
+
|
|
4
|
+
//#region src/index.d.ts
|
|
5
|
+
type SecretSpecConfigLoaderProps = IAbstractBaseLoaderProps & {
|
|
6
|
+
provider?: string;
|
|
7
|
+
profile?: string;
|
|
8
|
+
reason?: string;
|
|
9
|
+
path?: string;
|
|
10
|
+
};
|
|
11
|
+
declare class SecretSpecConfigLoader<OverrideMap extends OverrideKeyMap = OverrideKeyMap> extends AbstractBaseLoader<IAbstractBaseLoaderProps, OverrideMap> {
|
|
12
|
+
readonly loaderType = "secretspec";
|
|
13
|
+
private readonly resolved;
|
|
14
|
+
override defaultOptions: IAbstractBaseLoaderProps;
|
|
15
|
+
constructor(options?: SecretSpecConfigLoaderProps, override?: Partial<OverrideMap>);
|
|
16
|
+
protected getRawValue(lookupKey: string): IResult<LoaderValueResult, Error>;
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { SecretSpecConfigLoader, SecretSpecConfigLoaderProps };
|
|
20
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;;KAIY,2BAAA,GAA8B,wBAAA;EACzC,QAAA;EACA,OAAA;EACA,MAAA;EACA,IAAA;AAAA;AAAA,cAGY,sBAAA,qBAA2C,cAAA,GAAiB,cAAA,UAAwB,kBAAA,CAAmB,wBAAA,EAA0B,WAAA;EAAA,SAC7H,UAAA;EAAA,iBACC,QAAA;EAAA,SAED,cAAA,EAAgB,wBAAA;EAIhC,WAAA,CAAmB,OAAA,GAAS,2BAAA,EAAkC,QAAA,GAAW,OAAA,CAAQ,WAAA;EAAA,UAkBvE,WAAA,CAAY,SAAA,WAAoB,OAAA,CAAQ,iBAAA,EAAmB,KAAA;AAAA"}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AbstractBaseLoader, IAbstractBaseLoaderProps, LoaderValueResult, OverrideKeyMap } from "@luolapeikko/core-env";
|
|
2
|
+
import { IResult } from "@luolapeikko/result-option";
|
|
3
|
+
|
|
4
|
+
//#region src/index.d.ts
|
|
5
|
+
type SecretSpecConfigLoaderProps = IAbstractBaseLoaderProps & {
|
|
6
|
+
provider?: string;
|
|
7
|
+
profile?: string;
|
|
8
|
+
reason?: string;
|
|
9
|
+
path?: string;
|
|
10
|
+
};
|
|
11
|
+
declare class SecretSpecConfigLoader<OverrideMap extends OverrideKeyMap = OverrideKeyMap> extends AbstractBaseLoader<IAbstractBaseLoaderProps, OverrideMap> {
|
|
12
|
+
readonly loaderType = "secretspec";
|
|
13
|
+
private readonly resolved;
|
|
14
|
+
override defaultOptions: IAbstractBaseLoaderProps;
|
|
15
|
+
constructor(options?: SecretSpecConfigLoaderProps, override?: Partial<OverrideMap>);
|
|
16
|
+
protected getRawValue(lookupKey: string): IResult<LoaderValueResult, Error>;
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { SecretSpecConfigLoader, SecretSpecConfigLoaderProps };
|
|
20
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;KAIY,2BAAA,GAA8B,wBAAA;EACzC,QAAA;EACA,OAAA;EACA,MAAA;EACA,IAAA;AAAA;AAAA,cAGY,sBAAA,qBAA2C,cAAA,GAAiB,cAAA,UAAwB,kBAAA,CAAmB,wBAAA,EAA0B,WAAA;EAAA,SAC7H,UAAA;EAAA,iBACC,QAAA;EAAA,SAED,cAAA,EAAgB,wBAAA;EAIhC,WAAA,CAAmB,OAAA,GAAS,2BAAA,EAAkC,QAAA,GAAW,OAAA,CAAQ,WAAA;EAAA,UAkBvE,WAAA,CAAY,SAAA,WAAoB,OAAA,CAAQ,iBAAA,EAAmB,KAAA;AAAA"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { AbstractBaseLoader } from "@luolapeikko/core-env";
|
|
2
|
+
import { Ok } from "@luolapeikko/result-option";
|
|
3
|
+
import { SecretSpec } from "secretspec";
|
|
4
|
+
//#region src/index.ts
|
|
5
|
+
var SecretSpecConfigLoader = class extends AbstractBaseLoader {
|
|
6
|
+
loaderType = "secretspec";
|
|
7
|
+
resolved;
|
|
8
|
+
defaultOptions = { disabled: false };
|
|
9
|
+
constructor(options = {}, override) {
|
|
10
|
+
super(override);
|
|
11
|
+
let builder = SecretSpec.builder();
|
|
12
|
+
if (options.path) builder = builder.withPath(options.path);
|
|
13
|
+
if (options.provider) builder = builder.withProvider(options.provider);
|
|
14
|
+
if (options.profile) builder = builder.withProfile(options.profile);
|
|
15
|
+
if (options.reason) builder = builder.withReason(options.reason);
|
|
16
|
+
this.resolved = builder.load();
|
|
17
|
+
}
|
|
18
|
+
getRawValue(lookupKey) {
|
|
19
|
+
const resolvedValue = this.resolved.secrets[lookupKey];
|
|
20
|
+
return Ok({
|
|
21
|
+
path: `secretspec[profiles.${this.resolved.profile}] ${lookupKey}`,
|
|
22
|
+
value: resolvedValue.value ?? void 0
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
//#endregion
|
|
27
|
+
export { SecretSpecConfigLoader };
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import {AbstractBaseLoader, type IAbstractBaseLoaderProps, type LoaderValueResult, type OverrideKeyMap} from '@luolapeikko/core-env';\nimport {type IResult, Ok} from '@luolapeikko/result-option';\nimport {type Resolved, SecretSpec} from 'secretspec';\n\nexport type SecretSpecConfigLoaderProps = IAbstractBaseLoaderProps & {\n\tprovider?: string;\n\tprofile?: string;\n\treason?: string;\n\tpath?: string;\n};\n\nexport class SecretSpecConfigLoader<OverrideMap extends OverrideKeyMap = OverrideKeyMap> extends AbstractBaseLoader<IAbstractBaseLoaderProps, OverrideMap> {\n\tpublic readonly loaderType = 'secretspec';\n\tprivate readonly resolved: Resolved;\n\n\tpublic override defaultOptions: IAbstractBaseLoaderProps = {\n\t\tdisabled: false,\n\t};\n\n\tpublic constructor(options: SecretSpecConfigLoaderProps = {}, override?: Partial<OverrideMap>) {\n\t\tsuper(override);\n\t\tlet builder = SecretSpec.builder();\n\t\tif (options.path) {\n\t\t\tbuilder = builder.withPath(options.path);\n\t\t}\n\t\tif (options.provider) {\n\t\t\tbuilder = builder.withProvider(options.provider);\n\t\t}\n\t\tif (options.profile) {\n\t\t\tbuilder = builder.withProfile(options.profile);\n\t\t}\n\t\tif (options.reason) {\n\t\t\tbuilder = builder.withReason(options.reason);\n\t\t}\n\t\tthis.resolved = builder.load();\n\t}\n\n\tprotected getRawValue(lookupKey: string): IResult<LoaderValueResult, Error> {\n\t\tconst resolvedValue = this.resolved.secrets[lookupKey];\n\t\treturn Ok({path: `secretspec[profiles.${this.resolved.profile}] ${lookupKey}`, value: resolvedValue.value ?? undefined});\n\t}\n}\n"],"mappings":";;;;AAWA,IAAa,yBAAb,cAAiG,mBAA0D;CAC1J,aAA6B;CAC7B;CAEA,iBAA2D,EAC1D,UAAU,MACX;CAEA,YAAmB,UAAuC,CAAC,GAAG,UAAiC;EAC9F,MAAM,QAAQ;EACd,IAAI,UAAU,WAAW,QAAQ;EACjC,IAAI,QAAQ,MACX,UAAU,QAAQ,SAAS,QAAQ,IAAI;EAExC,IAAI,QAAQ,UACX,UAAU,QAAQ,aAAa,QAAQ,QAAQ;EAEhD,IAAI,QAAQ,SACX,UAAU,QAAQ,YAAY,QAAQ,OAAO;EAE9C,IAAI,QAAQ,QACX,UAAU,QAAQ,WAAW,QAAQ,MAAM;EAE5C,KAAK,WAAW,QAAQ,KAAK;CAC9B;CAEA,YAAsB,WAAsD;EAC3E,MAAM,gBAAgB,KAAK,SAAS,QAAQ;EAC5C,OAAO,GAAG;GAAC,MAAM,uBAAuB,KAAK,SAAS,QAAQ,IAAI;GAAa,OAAO,cAAc,SAAS,KAAA;EAAS,CAAC;CACxH;AACD"}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@luolapeikko/core-env-secretspec",
|
|
3
|
+
"version": "0.0.3",
|
|
4
|
+
"description": "SecretSpec loader for EnvKit",
|
|
5
|
+
"main": "./dist/index.cjs",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"types": "./dist/index.d.cts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": {
|
|
11
|
+
"types": "./dist/index.d.mts",
|
|
12
|
+
"default": "./dist/index.mjs"
|
|
13
|
+
},
|
|
14
|
+
"require": {
|
|
15
|
+
"types": "./dist/index.d.cts",
|
|
16
|
+
"default": "./dist/index.cjs"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist"
|
|
22
|
+
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "tsdown src/index.ts --sourcemap --format cjs,esm --dts --clean -c tsconfig.build.json",
|
|
25
|
+
"validate": "tsc --noEmit"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"env",
|
|
29
|
+
"environment",
|
|
30
|
+
"variables",
|
|
31
|
+
"config",
|
|
32
|
+
"configuration",
|
|
33
|
+
"loader",
|
|
34
|
+
"parser",
|
|
35
|
+
"typescript",
|
|
36
|
+
"schema",
|
|
37
|
+
"validation",
|
|
38
|
+
"envkit",
|
|
39
|
+
"SecretSpec"
|
|
40
|
+
],
|
|
41
|
+
"author": "mharj",
|
|
42
|
+
"license": "LGPL-2.1-only",
|
|
43
|
+
"repository": "github:luolapeikko/core-env",
|
|
44
|
+
"packageManager": "pnpm@10.17.1",
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@luolapeikko/core-env": "workspace:*"
|
|
47
|
+
},
|
|
48
|
+
"peerDependencies": {
|
|
49
|
+
"@luolapeikko/core-env": ">=0.0.3",
|
|
50
|
+
"@luolapeikko/result-option": ">= 2.1.1",
|
|
51
|
+
"secretspec": ">= 0.14.0"
|
|
52
|
+
}
|
|
53
|
+
}
|