@leyyo/env 1.0.6 → 1.0.8
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/dist/core/env-core.impl.js +6 -0
- package/dist/core/env-core.impl.js.map +1 -1
- package/dist/core/index.types.d.ts +2 -0
- package/dist/field/env-field.impl.d.ts +38 -17
- package/dist/field/env-field.impl.js +134 -40
- package/dist/field/env-field.impl.js.map +1 -1
- package/dist/field/index.types.d.ts +101 -15
- package/dist/scope/env-scope.impl.d.ts +12 -3
- package/dist/scope/env-scope.impl.js +63 -9
- package/dist/scope/env-scope.impl.js.map +1 -1
- package/dist/scope/index.types.d.ts +10 -1
- package/package.json +3 -2
|
@@ -53,6 +53,12 @@ class EnvCoreImpl {
|
|
|
53
53
|
Array.from(this._scopes.values())
|
|
54
54
|
.forEach(ins => ins.$run());
|
|
55
55
|
}
|
|
56
|
+
print() {
|
|
57
|
+
const result = [];
|
|
58
|
+
Array.from(this._scopes.values())
|
|
59
|
+
.forEach(ins => result.push(...ins.$print()));
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
56
62
|
$addKey(key, scope) {
|
|
57
63
|
if (!this._keys.has(key)) {
|
|
58
64
|
this._keys.set(key, [scope]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env-core.impl.js","sourceRoot":"","sources":["../../src/core/env-core.impl.ts"],"names":[],"mappings":";;;AAAA,0CAAgC;AAChC,4DAAqD;AACrD,0CAAwD;
|
|
1
|
+
{"version":3,"file":"env-core.impl.js","sourceRoot":"","sources":["../../src/core/env-core.impl.ts"],"names":[],"mappings":";;;AAAA,0CAAgC;AAChC,4DAAqD;AACrD,0CAAwD;AAMxD,MAAM,KAAK,GAAG,GAAG,cAAG,UAAU,CAAC;AAC/B,MAAM,WAAW;IAKb;QAJQ,YAAO,GAAG,cAAK,CAAC,MAAM,CAAmB,cAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,8BAA8B;QACvF,UAAK,GA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,KAAK,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;oBACvD,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;oBACpC,IAAI,GAAG,EAAE,CAAC;wBACN,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;oBAC3B,CAAC;gBACL,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;CACJ;AAEY,QAAA,OAAO,GAAY,IAAI,WAAW,EAAE,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { EnvScope } from "../scope";
|
|
2
|
+
import type { EnvFieldPrint } from "../field";
|
|
2
3
|
export type EnvBase = Object;
|
|
3
4
|
export interface EnvCore {
|
|
4
5
|
scope<E extends EnvBase = EnvBase>(name: string): EnvScope<E>;
|
|
@@ -8,6 +9,7 @@ export interface EnvCore {
|
|
|
8
9
|
get keys(): Record<string, string[]>;
|
|
9
10
|
get scopes(): string[];
|
|
10
11
|
run(): void;
|
|
12
|
+
print(): EnvFieldPrint[];
|
|
11
13
|
$addKey(key: string, scope: string): void;
|
|
12
14
|
$fromOta(values: EnvBase): void;
|
|
13
15
|
}
|
|
@@ -1,44 +1,65 @@
|
|
|
1
1
|
import { EnumMap } from "@leyyo/common";
|
|
2
|
-
import type { EnvField, EnvFieldAssertLambda, EnvFieldCastLambda,
|
|
2
|
+
import type { EnvField, EnvFieldArray, EnvFieldAssertLambda, EnvFieldBoolean, EnvFieldCastLambda, EnvFieldFloat, EnvFieldInteger, EnvFieldOnChange, EnvFieldPrint, EnvFieldSecret, EnvFieldString } from "./index.types";
|
|
3
3
|
import type { EnvScope } from "../scope";
|
|
4
4
|
import type { EnvBase } from "../core";
|
|
5
5
|
import type { KeyValue } from "@leyyo/common/dist/shared";
|
|
6
|
-
import { EnumLiteral } from "@leyyo/common/dist/shared/index.types";
|
|
6
|
+
import type { EnumLiteral } from "@leyyo/common/dist/shared/index.types";
|
|
7
7
|
export declare class EnvFieldImpl<E extends EnvBase = EnvBase, Z extends keyof E = keyof E> implements EnvField<E, Z> {
|
|
8
8
|
readonly scope: EnvScope<E>;
|
|
9
9
|
readonly name: Z;
|
|
10
10
|
private readonly _field;
|
|
11
|
-
private readonly _where;
|
|
12
11
|
private _assert;
|
|
13
12
|
private _cast;
|
|
14
13
|
private _def;
|
|
15
14
|
private _required;
|
|
15
|
+
private _secret;
|
|
16
|
+
private _aliases;
|
|
16
17
|
private _array;
|
|
17
|
-
private _otaFn;
|
|
18
18
|
private _initialized;
|
|
19
19
|
private _type;
|
|
20
20
|
private _enumKeys;
|
|
21
|
+
private _onOta;
|
|
22
|
+
private _onChange;
|
|
23
|
+
private _onSet;
|
|
21
24
|
private static _lambdaMap;
|
|
22
25
|
constructor(scope: EnvScope<E>, name: Z);
|
|
23
26
|
private _devOne;
|
|
24
27
|
private _devMore;
|
|
25
28
|
private _initialize;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
private get _fromDef();
|
|
30
|
+
/** {@inheritDoc} */
|
|
31
|
+
string(_opt?: EnvFieldString): this;
|
|
32
|
+
/** {@inheritDoc} */
|
|
33
|
+
text(_opt?: EnvFieldString): this;
|
|
34
|
+
/** {@inheritDoc} */
|
|
35
|
+
float(_opt?: EnvFieldFloat): this;
|
|
36
|
+
/** {@inheritDoc} */
|
|
37
|
+
integer(_opt?: EnvFieldInteger): this;
|
|
38
|
+
/** {@inheritDoc} */
|
|
39
|
+
boolean(_opt?: EnvFieldBoolean): this;
|
|
40
|
+
/** {@inheritDoc} */
|
|
31
41
|
literal<L extends KeyValue = string>(keys: EnumLiteral<L>): this;
|
|
42
|
+
/** {@inheritDoc} */
|
|
32
43
|
enumeration<L extends KeyValue = string>(map: EnumMap<L>): this;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
44
|
+
/** {@inheritDoc} */
|
|
45
|
+
def(value: E[Z]): this;
|
|
46
|
+
/** {@inheritDoc} */
|
|
47
|
+
required(): this;
|
|
48
|
+
/** {@inheritDoc} */
|
|
49
|
+
array(_opt?: EnvFieldArray): this;
|
|
50
|
+
secret(_opt?: EnvFieldSecret): this;
|
|
51
|
+
/** {@inheritDoc} */
|
|
52
|
+
onOta(fn?: EnvFieldOnChange<E, Z>): this;
|
|
53
|
+
onChange(fn: EnvFieldOnChange<E, Z>): this;
|
|
54
|
+
onSet(fn: EnvFieldOnChange<E, Z>): this;
|
|
55
|
+
/** {@inheritDoc} */
|
|
56
|
+
alias(...keys: string[]): this;
|
|
57
|
+
/** {@inheritDoc} */
|
|
38
58
|
end(): EnvScope<E>;
|
|
39
59
|
$cast(fn: EnvFieldCastLambda<E, Z>): this;
|
|
40
60
|
$assert(fn: EnvFieldAssertLambda): this;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
$
|
|
61
|
+
$print(): EnvFieldPrint;
|
|
62
|
+
private get _plainValue();
|
|
63
|
+
$run(): boolean;
|
|
64
|
+
$fromOta(value: unknown): boolean;
|
|
44
65
|
}
|
|
@@ -2,18 +2,20 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EnvFieldImpl = void 0;
|
|
4
4
|
const common_1 = require("@leyyo/common");
|
|
5
|
+
const error_enveloper_1 = require("@leyyo/error-enveloper");
|
|
6
|
+
const internal_1 = require("../internal");
|
|
7
|
+
const WHERE = `${internal_1.FQN}.EnvFieldImpl`;
|
|
5
8
|
class EnvFieldImpl {
|
|
6
9
|
constructor(scope, name) {
|
|
7
10
|
this.scope = scope;
|
|
8
11
|
this.name = name;
|
|
9
12
|
this._field = this.name;
|
|
10
|
-
this._where = this.scope.name;
|
|
11
13
|
}
|
|
12
14
|
_devOne() {
|
|
13
|
-
return { field: this._field, where: this.
|
|
15
|
+
return { field: this._field, where: WHERE, scope: this.scope.name };
|
|
14
16
|
}
|
|
15
17
|
_devMore(index) {
|
|
16
|
-
return { field: `${this._field}[${index}]`, where: this.
|
|
18
|
+
return { field: `${this._field}[${index}]`, where: WHERE, scope: this.scope.name };
|
|
17
19
|
}
|
|
18
20
|
_initialize() {
|
|
19
21
|
if (this._initialized) {
|
|
@@ -72,63 +74,119 @@ class EnvFieldImpl {
|
|
|
72
74
|
break;
|
|
73
75
|
}
|
|
74
76
|
}
|
|
77
|
+
get _fromDef() {
|
|
78
|
+
var _a;
|
|
79
|
+
if (this._array) {
|
|
80
|
+
if (common_1.$is.empty(this._def)) {
|
|
81
|
+
return [];
|
|
82
|
+
}
|
|
83
|
+
else if (Array.isArray(this._def)) {
|
|
84
|
+
return this._def;
|
|
85
|
+
}
|
|
86
|
+
return [this._def];
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
return (_a = this._def) !== null && _a !== void 0 ? _a : undefined;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
75
92
|
// region type
|
|
76
|
-
|
|
93
|
+
/** {@inheritDoc} */
|
|
94
|
+
string(_opt) {
|
|
77
95
|
this._type = 'string';
|
|
78
96
|
return this;
|
|
79
97
|
}
|
|
80
|
-
|
|
98
|
+
/** {@inheritDoc} */
|
|
99
|
+
text(_opt) {
|
|
81
100
|
this._type = 'string';
|
|
82
101
|
return this;
|
|
83
102
|
}
|
|
84
|
-
|
|
103
|
+
/** {@inheritDoc} */
|
|
104
|
+
float(_opt) {
|
|
85
105
|
this._type = 'float';
|
|
86
106
|
return this;
|
|
87
107
|
}
|
|
88
|
-
|
|
108
|
+
/** {@inheritDoc} */
|
|
109
|
+
integer(_opt) {
|
|
89
110
|
this._type = 'integer';
|
|
90
111
|
return this;
|
|
91
112
|
}
|
|
92
|
-
|
|
113
|
+
/** {@inheritDoc} */
|
|
114
|
+
boolean(_opt) {
|
|
93
115
|
this._type = 'boolean';
|
|
94
116
|
return this;
|
|
95
117
|
}
|
|
118
|
+
/** {@inheritDoc} */
|
|
96
119
|
literal(keys) {
|
|
97
120
|
this._type = 'literal';
|
|
98
121
|
this._enumKeys = keys;
|
|
99
122
|
return this;
|
|
100
123
|
}
|
|
124
|
+
/** {@inheritDoc} */
|
|
101
125
|
enumeration(map) {
|
|
102
126
|
this._type = 'enumeration';
|
|
103
127
|
this._enumKeys = map;
|
|
104
128
|
return this;
|
|
105
129
|
}
|
|
106
|
-
// endregion
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
130
|
+
// endregion type
|
|
131
|
+
/** {@inheritDoc} */
|
|
132
|
+
def(value) {
|
|
133
|
+
if (!common_1.$is.empty(value)) {
|
|
134
|
+
if (this._array) {
|
|
135
|
+
this._def = Array.isArray(value) ? value : [value];
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
this._def = value;
|
|
139
|
+
}
|
|
110
140
|
}
|
|
111
141
|
return this;
|
|
112
142
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
return this;
|
|
116
|
-
}
|
|
117
|
-
get required() {
|
|
143
|
+
/** {@inheritDoc} */
|
|
144
|
+
required() {
|
|
118
145
|
this._required = true;
|
|
119
146
|
return this;
|
|
120
147
|
}
|
|
121
|
-
|
|
148
|
+
/** {@inheritDoc} */
|
|
149
|
+
array(_opt) {
|
|
122
150
|
this._array = true;
|
|
123
151
|
return this;
|
|
124
152
|
}
|
|
125
|
-
|
|
153
|
+
secret(_opt) {
|
|
154
|
+
this._secret = true;
|
|
155
|
+
return this;
|
|
156
|
+
}
|
|
157
|
+
/** {@inheritDoc} */
|
|
158
|
+
onOta(fn) {
|
|
126
159
|
this.scope.$addOta(this.name);
|
|
127
|
-
|
|
128
|
-
|
|
160
|
+
common_1.$assert.func(fn, { field: this._field, where: WHERE, scope: this.scope.name, method: 'ota' });
|
|
161
|
+
this._onOta = fn;
|
|
162
|
+
return this;
|
|
163
|
+
}
|
|
164
|
+
onChange(fn) {
|
|
165
|
+
common_1.$assert.func(fn, { field: this._field, where: WHERE, scope: this.scope.name, method: 'onChange' });
|
|
166
|
+
this._onChange = fn;
|
|
167
|
+
return this;
|
|
168
|
+
}
|
|
169
|
+
onSet(fn) {
|
|
170
|
+
common_1.$assert.func(fn, { field: this._field, where: WHERE, scope: this.scope.name, method: 'onSet' });
|
|
171
|
+
this._onSet = fn;
|
|
172
|
+
return this;
|
|
173
|
+
}
|
|
174
|
+
/** {@inheritDoc} */
|
|
175
|
+
alias(...keys) {
|
|
176
|
+
common_1.$assert.textArray(keys, { field: this._field, method: 'aliases', where: WHERE, scope: this.scope.name });
|
|
177
|
+
if (keys.length > 0) {
|
|
178
|
+
if (!this._aliases) {
|
|
179
|
+
this._aliases = [];
|
|
180
|
+
}
|
|
181
|
+
keys.forEach(key => {
|
|
182
|
+
if (!this._aliases.includes(key)) {
|
|
183
|
+
this._aliases.push(key);
|
|
184
|
+
}
|
|
185
|
+
});
|
|
129
186
|
}
|
|
130
187
|
return this;
|
|
131
188
|
}
|
|
189
|
+
/** {@inheritDoc} */
|
|
132
190
|
end() {
|
|
133
191
|
return this.scope;
|
|
134
192
|
}
|
|
@@ -140,23 +198,48 @@ class EnvFieldImpl {
|
|
|
140
198
|
this._assert = fn;
|
|
141
199
|
return this;
|
|
142
200
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
if (this.
|
|
146
|
-
|
|
147
|
-
return [];
|
|
148
|
-
}
|
|
149
|
-
else if (Array.isArray(this._def)) {
|
|
150
|
-
return this._def;
|
|
151
|
-
}
|
|
152
|
-
return [this._def];
|
|
201
|
+
$print() {
|
|
202
|
+
const result = { key: this._field, scope: this.scope.name, type: this._type };
|
|
203
|
+
if (!this._secret) {
|
|
204
|
+
result.value = process.env[this._field];
|
|
153
205
|
}
|
|
154
206
|
else {
|
|
155
|
-
|
|
207
|
+
result.value = '<secret>';
|
|
208
|
+
}
|
|
209
|
+
const tags = [];
|
|
210
|
+
if (this._array) {
|
|
211
|
+
tags.push('array');
|
|
212
|
+
}
|
|
213
|
+
if (this._required) {
|
|
214
|
+
tags.push('required');
|
|
156
215
|
}
|
|
216
|
+
if (this._secret) {
|
|
217
|
+
tags.push('secret');
|
|
218
|
+
}
|
|
219
|
+
if (this._onOta) {
|
|
220
|
+
tags.push('ota');
|
|
221
|
+
}
|
|
222
|
+
if (tags.length) {
|
|
223
|
+
result.tags = tags;
|
|
224
|
+
}
|
|
225
|
+
if (this._aliases) {
|
|
226
|
+
result.aliases = this._aliases;
|
|
227
|
+
}
|
|
228
|
+
return result;
|
|
229
|
+
}
|
|
230
|
+
get _plainValue() {
|
|
231
|
+
const value = process.env[this._field];
|
|
232
|
+
if (this._array) {
|
|
233
|
+
if (Array.isArray(value)) {
|
|
234
|
+
return value.join('^~|');
|
|
235
|
+
}
|
|
236
|
+
return '';
|
|
237
|
+
}
|
|
238
|
+
return common_1.$is.empty(value) ? '' : value;
|
|
157
239
|
}
|
|
158
240
|
$run() {
|
|
159
241
|
this._initialize();
|
|
242
|
+
const old = this._plainValue;
|
|
160
243
|
if (common_1.$is.empty(process.env[this._field])) {
|
|
161
244
|
process.env[this._field] = this._fromDef;
|
|
162
245
|
}
|
|
@@ -169,18 +252,29 @@ class EnvFieldImpl {
|
|
|
169
252
|
if (typeof this._assert === 'function') {
|
|
170
253
|
this._assert(process.env[this._field]);
|
|
171
254
|
}
|
|
255
|
+
this.scope.$clear();
|
|
256
|
+
const current = this._plainValue;
|
|
257
|
+
if (this._onChange && current !== old) {
|
|
258
|
+
error_enveloper_1.errorEnveloper.handle(() => this._onChange(current, this.name, this.scope.raw), (e) => console.log(`OnChange Error: ${e.message}, where: ${WHERE}, scope: ${this.scope.name}, field: ${this._field}`));
|
|
259
|
+
}
|
|
260
|
+
if (this._onSet) {
|
|
261
|
+
error_enveloper_1.errorEnveloper.handle(() => this._onSet(current, this.name, this.scope.raw), (e) => console.log(`OnSet Error: ${e.message}, where: ${WHERE}, scope: ${this.scope.name}, field: ${this._field}`));
|
|
262
|
+
}
|
|
263
|
+
return current !== old;
|
|
172
264
|
}
|
|
173
265
|
$fromOta(value) {
|
|
174
266
|
process.env[this._field] = value;
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
267
|
+
let changed = false;
|
|
268
|
+
try {
|
|
269
|
+
changed = this.$run();
|
|
270
|
+
}
|
|
271
|
+
catch (e) {
|
|
272
|
+
console.log(`Ota Run Error: ${e.message}, where: ${WHERE}, scope: ${this.scope.name}, field: ${this._field}`);
|
|
273
|
+
}
|
|
274
|
+
if (changed && this._onOta) {
|
|
275
|
+
error_enveloper_1.errorEnveloper.handle(() => this._onOta(process.env[this._field], this.name, this.scope.raw), (e) => console.log(`OnOta Error: ${e.message}, where: ${WHERE}, scope: ${this.scope.name}, field: ${this._field}`));
|
|
183
276
|
}
|
|
277
|
+
return changed;
|
|
184
278
|
}
|
|
185
279
|
}
|
|
186
280
|
exports.EnvFieldImpl = EnvFieldImpl;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env-field.impl.js","sourceRoot":"","sources":["../../src/field/env-field.impl.ts"],"names":[],"mappings":";;;AAAA,0CAAiE;AAiBjE,MAAa,YAAY;IAuBrB,YAAqB,KAAkB,EAAW,IAAO;QAApC,UAAK,GAAL,KAAK,CAAa;QAAW,SAAI,GAAJ,IAAI,CAAG;QACrD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,IAAc,CAAC;QAClC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;IAClC,CAAC;IAEO,OAAO;QACX,OAAO,EAAC,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,EAAC,CAAC;IACpD,CAAC;IAEO,QAAQ,CAAC,KAAa;QAC1B,OAAO,EAAC,KAAK,EAAE,GAAG,IAAI,CAAC,MAAM,IAAI,KAAK,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,EAAC,CAAC;IACnE,CAAC;IAEO,W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G,EAAE,QAAQ,CAAC,CAAoC;IACnG,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,EAAE,CAAC,YAAG,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAoC;IACrG,OAAO,EAAE,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,EAAE,CAAC,YAAG,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAoC;IACzG,OAAO,EAAE,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,EAAE,CAAC,YAAG,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAqC;IAC1G,OAAO,EAAE,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,EAAE,CAAC,YAAG,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAqC;IACjI,WAAW,EAAE,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,EAAE,CAAC,YAAG,CAAC,WAAW,CAAC,KAAK,EAAE,GAAc,EAAE,GAAG,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAqC;CACrJ,CAAC"}
|
|
@@ -1,33 +1,119 @@
|
|
|
1
1
|
import type { EnvScope } from "../scope";
|
|
2
2
|
import type { EnvBase } from "../core";
|
|
3
|
-
import { DevOpt, EnumMap, KeyValue } from "@leyyo/common";
|
|
4
|
-
import { EnumLiteral } from "@leyyo/common/dist/shared/index.types";
|
|
3
|
+
import type { DevOpt, EnumMap, KeyValue } from "@leyyo/common";
|
|
4
|
+
import type { EnumLiteral } from "@leyyo/common/dist/shared/index.types";
|
|
5
5
|
export type EnvFieldCastLambda<E extends EnvBase = EnvBase, Z extends keyof E = keyof E> = (v: unknown) => E[Z];
|
|
6
6
|
export type EnvFieldAssertLambda = (v: unknown) => void;
|
|
7
7
|
export type EnvFieldType = 'string' | 'text' | 'float' | 'integer' | 'boolean' | 'literal' | 'enumeration';
|
|
8
|
-
export
|
|
8
|
+
export interface EnvFieldArray {
|
|
9
|
+
char?: ',' | ';' | '/' | '|' | string;
|
|
10
|
+
min?: number;
|
|
11
|
+
max?: number;
|
|
12
|
+
unique?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface EnvFieldSecret {
|
|
15
|
+
type?: EnvFieldSecretType;
|
|
16
|
+
}
|
|
17
|
+
export type EnvFieldSecretType = 'password' | 'token' | 'private-key' | 'public-key' | 'api-key' | 'host';
|
|
18
|
+
export interface EnvFieldString {
|
|
19
|
+
min?: number;
|
|
20
|
+
max?: number;
|
|
21
|
+
pattern?: string | RegExp;
|
|
22
|
+
}
|
|
23
|
+
export interface EnvFieldFloat {
|
|
24
|
+
min?: number;
|
|
25
|
+
max?: number;
|
|
26
|
+
}
|
|
27
|
+
export interface EnvFieldInteger {
|
|
28
|
+
min?: number;
|
|
29
|
+
max?: number;
|
|
30
|
+
modulus?: number;
|
|
31
|
+
}
|
|
32
|
+
export interface EnvFieldBoolean {
|
|
33
|
+
yes?: string[];
|
|
34
|
+
no?: string[];
|
|
35
|
+
}
|
|
36
|
+
export type EnvFieldPrintTag = 'required' | 'array' | 'secret' | 'ota';
|
|
37
|
+
export interface EnvFieldPrint {
|
|
38
|
+
scope: string;
|
|
39
|
+
key: string;
|
|
40
|
+
value?: any;
|
|
41
|
+
type: EnvFieldType;
|
|
42
|
+
tags?: EnvFieldPrintTag[];
|
|
43
|
+
aliases?: string[];
|
|
44
|
+
}
|
|
9
45
|
export interface EnvField<E extends EnvBase = EnvBase, Z extends keyof E = keyof E> {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
46
|
+
/**
|
|
47
|
+
* Key is required
|
|
48
|
+
* */
|
|
49
|
+
required(): this;
|
|
50
|
+
/**
|
|
51
|
+
* Key is array, so value is split by char
|
|
52
|
+
* */
|
|
53
|
+
array(opt?: EnvFieldArray): this;
|
|
54
|
+
/**
|
|
55
|
+
* Key is secret value
|
|
56
|
+
* */
|
|
57
|
+
secret(opt?: EnvFieldSecret): this;
|
|
58
|
+
/**
|
|
59
|
+
* Set default value
|
|
60
|
+
* */
|
|
61
|
+
def(value: E[Z]): this;
|
|
62
|
+
/**
|
|
63
|
+
* Value may have another aliases
|
|
64
|
+
* */
|
|
65
|
+
alias(...keys: string[]): this;
|
|
66
|
+
/**
|
|
67
|
+
* Value is string (can be empty)
|
|
68
|
+
* */
|
|
69
|
+
string(opt?: EnvFieldString): this;
|
|
70
|
+
/**
|
|
71
|
+
* Value is text (can not be empty)
|
|
72
|
+
* */
|
|
73
|
+
text(opt?: EnvFieldString): this;
|
|
74
|
+
/**
|
|
75
|
+
* Value is float
|
|
76
|
+
* */
|
|
77
|
+
float(opt?: EnvFieldFloat): this;
|
|
78
|
+
/**
|
|
79
|
+
* Value is integer
|
|
80
|
+
* */
|
|
81
|
+
integer(opt?: EnvFieldInteger): this;
|
|
82
|
+
/**
|
|
83
|
+
* Value is boolean
|
|
84
|
+
* */
|
|
85
|
+
boolean(opt?: EnvFieldBoolean): this;
|
|
86
|
+
/**
|
|
87
|
+
* Value is literal
|
|
88
|
+
* */
|
|
17
89
|
literal<L extends KeyValue = string>(keys: EnumLiteral<L>): this;
|
|
90
|
+
/**
|
|
91
|
+
* Value is enumeration
|
|
92
|
+
* */
|
|
18
93
|
enumeration<L extends KeyValue = string>(map: EnumMap<L>): this;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
94
|
+
/**
|
|
95
|
+
* Value has ota for remote configuration
|
|
96
|
+
* */
|
|
97
|
+
onOta(fn?: EnvFieldOnChange<E, Z>): this;
|
|
98
|
+
onChange(fn: EnvFieldOnChange<E, Z>): this;
|
|
99
|
+
onSet(fn: EnvFieldOnChange<E, Z>): this;
|
|
100
|
+
/**
|
|
101
|
+
* Go back to scope
|
|
102
|
+
* */
|
|
22
103
|
end(): EnvScope<E>;
|
|
104
|
+
/**
|
|
105
|
+
* Scope
|
|
106
|
+
* */
|
|
23
107
|
get scope(): EnvScope<E>;
|
|
24
|
-
$run():
|
|
25
|
-
$
|
|
108
|
+
$run(): boolean;
|
|
109
|
+
$print(): EnvFieldPrint;
|
|
110
|
+
$fromOta(value: unknown): boolean;
|
|
26
111
|
$cast(fn: EnvFieldCastLambda<E, Z>): this;
|
|
27
112
|
$assert(fn: EnvFieldAssertLambda): this;
|
|
28
113
|
}
|
|
29
114
|
export type EnvFieldCastBasicLambda<T> = (value: unknown, opt: DevOpt, required: boolean) => T | undefined;
|
|
30
115
|
export type EnvFieldCastEnumLambda<T extends KeyValue> = (value: unknown, keys: unknown, opt: DevOpt, required: boolean) => T | undefined;
|
|
116
|
+
export type EnvFieldOnChange<E extends EnvBase = EnvBase, Z extends keyof E = keyof E> = (value: E[Z] | undefined, field?: Z, all?: E) => void;
|
|
31
117
|
export interface EnvFieldLambdaItem {
|
|
32
118
|
string: EnvFieldCastBasicLambda<string>;
|
|
33
119
|
text: EnvFieldCastBasicLambda<string>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { EnvBase, EnvCore } from "../core";
|
|
2
|
-
import type { EnvField } from "../field";
|
|
3
|
-
import type { EnvScope } from "./index.types";
|
|
2
|
+
import type { EnvField, EnvFieldPrint } from "../field";
|
|
3
|
+
import type { EnvScope, EnvScopeOnChange, EnvScopeOtaLambda } from "./index.types";
|
|
4
4
|
export declare class EnvScopeImpl<E extends EnvBase = EnvBase> implements EnvScope<E> {
|
|
5
5
|
readonly core: EnvCore;
|
|
6
6
|
readonly name: string;
|
|
@@ -8,15 +8,24 @@ export declare class EnvScopeImpl<E extends EnvBase = EnvBase> implements EnvSco
|
|
|
8
8
|
private _run;
|
|
9
9
|
private readonly _fields;
|
|
10
10
|
private readonly _otaList;
|
|
11
|
+
private _onOta;
|
|
12
|
+
private _onChange;
|
|
13
|
+
private _onSet;
|
|
11
14
|
constructor(core: EnvCore, name: string);
|
|
12
15
|
field<Z extends keyof E = keyof E>(name: Z): EnvField<E, Z>;
|
|
13
16
|
get<Z extends keyof E = keyof E>(name: Z): EnvField<E, Z>;
|
|
14
17
|
has<Z extends keyof E = keyof E>(field: Z): boolean;
|
|
15
|
-
uses(scope: string): this;
|
|
18
|
+
uses<E2 extends EnvBase = EnvBase>(scope: string | EnvScope<E2>): this;
|
|
19
|
+
onChange(fn: EnvScopeOnChange<E>): EnvScope<E>;
|
|
20
|
+
onSet(fn: EnvScopeOnChange<E>): EnvScope<E>;
|
|
21
|
+
onOta(fn: EnvScopeOtaLambda<E>): EnvScope<E>;
|
|
16
22
|
run(): void;
|
|
23
|
+
print(): EnvFieldPrint[];
|
|
17
24
|
get raw(): E;
|
|
25
|
+
$print(): EnvFieldPrint[];
|
|
18
26
|
$run(): void;
|
|
19
27
|
$refresh(): void;
|
|
28
|
+
$clear(): void;
|
|
20
29
|
$addOta(name: keyof E): void;
|
|
21
30
|
$fromOta(values: Partial<E>): void;
|
|
22
31
|
}
|
|
@@ -4,6 +4,7 @@ exports.EnvScopeImpl = void 0;
|
|
|
4
4
|
const internal_1 = require("../internal");
|
|
5
5
|
const common_1 = require("@leyyo/common");
|
|
6
6
|
const env_field_impl_1 = require("../field/env-field.impl");
|
|
7
|
+
const error_enveloper_1 = require("@leyyo/error-enveloper");
|
|
7
8
|
const WHERE = `${internal_1.FQN}.EnvScopeImpl`;
|
|
8
9
|
class EnvScopeImpl {
|
|
9
10
|
constructor(core, name) {
|
|
@@ -14,10 +15,10 @@ class EnvScopeImpl {
|
|
|
14
15
|
}
|
|
15
16
|
field(name) {
|
|
16
17
|
common_1.$assert.text(name, () => {
|
|
17
|
-
return {
|
|
18
|
+
return { where: WHERE, scope: this.name, method: 'field' };
|
|
18
19
|
});
|
|
19
20
|
if (this._fields.has(name)) {
|
|
20
|
-
throw common_1.$dev.developerError2(internal_1.FQN, 701, { message: 'Field is duplicated',
|
|
21
|
+
throw common_1.$dev.developerError2(internal_1.FQN, 701, { message: 'Field is duplicated', where: WHERE, scope: this.name, method: 'field', field: name });
|
|
21
22
|
}
|
|
22
23
|
const ins = new env_field_impl_1.EnvFieldImpl(this, name);
|
|
23
24
|
this._fields.set(name, ins);
|
|
@@ -26,28 +27,57 @@ class EnvScopeImpl {
|
|
|
26
27
|
}
|
|
27
28
|
get(name) {
|
|
28
29
|
common_1.$assert.text(name, () => {
|
|
29
|
-
return {
|
|
30
|
+
return { where: WHERE, scope: this.name, method: 'get' };
|
|
30
31
|
});
|
|
31
32
|
if (!this._fields.has(name)) {
|
|
32
|
-
throw common_1.$dev.developerError2(internal_1.FQN, 701, { message: 'Field could not found',
|
|
33
|
+
throw common_1.$dev.developerError2(internal_1.FQN, 701, { message: 'Field could not found', where: WHERE, scope: this.name, method: 'get', field: name });
|
|
33
34
|
}
|
|
34
35
|
return this._fields.get(name);
|
|
35
36
|
}
|
|
36
37
|
has(field) {
|
|
37
38
|
common_1.$assert.text(field, () => {
|
|
38
|
-
return {
|
|
39
|
+
return { where: WHERE, scope: this.name, method: 'has' };
|
|
39
40
|
});
|
|
40
41
|
return this._fields.has(field);
|
|
41
42
|
}
|
|
42
43
|
uses(scope) {
|
|
43
|
-
if (
|
|
44
|
-
this.core.
|
|
44
|
+
if (typeof scope === 'string') {
|
|
45
|
+
if (this.core.has(scope)) {
|
|
46
|
+
this.core.get(scope).$run();
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
console.warn(`Not found scope: ${scope}`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
else if (common_1.$is.object(scope) && scope instanceof env_field_impl_1.EnvFieldImpl) {
|
|
53
|
+
scope.$run();
|
|
45
54
|
}
|
|
55
|
+
else {
|
|
56
|
+
console.warn(`Invalid scope type: ${typeof scope}`);
|
|
57
|
+
}
|
|
58
|
+
return this;
|
|
59
|
+
}
|
|
60
|
+
onChange(fn) {
|
|
61
|
+
common_1.$assert.func(fn, { where: WHERE, scope: this.name, method: 'onChange' });
|
|
62
|
+
this._onChange = fn;
|
|
63
|
+
return this;
|
|
64
|
+
}
|
|
65
|
+
onSet(fn) {
|
|
66
|
+
common_1.$assert.func(fn, { where: WHERE, scope: this.name, method: 'onSet' });
|
|
67
|
+
this._onSet = fn;
|
|
68
|
+
return this;
|
|
69
|
+
}
|
|
70
|
+
onOta(fn) {
|
|
71
|
+
common_1.$assert.func(fn, { where: WHERE, scope: this.name, method: 'onOta' });
|
|
72
|
+
this._onOta = fn;
|
|
46
73
|
return this;
|
|
47
74
|
}
|
|
48
75
|
run() {
|
|
49
76
|
this.core.run();
|
|
50
77
|
}
|
|
78
|
+
print() {
|
|
79
|
+
return this.core.print();
|
|
80
|
+
}
|
|
51
81
|
get raw() {
|
|
52
82
|
if (this._raw !== undefined) {
|
|
53
83
|
return this._raw;
|
|
@@ -59,18 +89,36 @@ class EnvScopeImpl {
|
|
|
59
89
|
});
|
|
60
90
|
return this._raw;
|
|
61
91
|
}
|
|
92
|
+
$print() {
|
|
93
|
+
return Array.from(this._fields.values())
|
|
94
|
+
.map(field => field.$print());
|
|
95
|
+
}
|
|
62
96
|
$run() {
|
|
63
97
|
if (this._run) {
|
|
64
98
|
return;
|
|
65
99
|
}
|
|
66
100
|
this._run = true;
|
|
101
|
+
let changedAny = false;
|
|
67
102
|
Array.from(this._fields.values())
|
|
68
|
-
.forEach(ins =>
|
|
103
|
+
.forEach(ins => {
|
|
104
|
+
if (ins.$run()) {
|
|
105
|
+
changedAny = true;
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
if (changedAny && this._onChange) {
|
|
109
|
+
error_enveloper_1.errorEnveloper.handle(() => this._onChange(this.raw), (e) => console.log(`OnChange Error: ${e.message}, where: ${WHERE}, scope: ${this.name}`));
|
|
110
|
+
}
|
|
111
|
+
if (this._onSet) {
|
|
112
|
+
error_enveloper_1.errorEnveloper.handle(() => this._onSet(this.raw), (e) => console.log(`OnSet Error: ${e.message}, where: ${WHERE}, scope: ${this.name}`));
|
|
113
|
+
}
|
|
69
114
|
}
|
|
70
115
|
$refresh() {
|
|
71
116
|
this._run = false;
|
|
72
117
|
this._raw = undefined;
|
|
73
118
|
}
|
|
119
|
+
$clear() {
|
|
120
|
+
this._raw = undefined;
|
|
121
|
+
}
|
|
74
122
|
$addOta(name) {
|
|
75
123
|
if (!this._otaList.includes(name)) {
|
|
76
124
|
this._otaList.push(name);
|
|
@@ -79,12 +127,18 @@ class EnvScopeImpl {
|
|
|
79
127
|
$fromOta(values) {
|
|
80
128
|
this.$refresh();
|
|
81
129
|
if (common_1.$is.bareObject(values)) {
|
|
130
|
+
let changedAny = false;
|
|
82
131
|
for (const [name, value] of Object.entries(values)) {
|
|
83
132
|
const ins = this._fields.get(name);
|
|
84
133
|
if (ins) {
|
|
85
|
-
ins.$fromOta(value)
|
|
134
|
+
if (ins.$fromOta(value)) {
|
|
135
|
+
changedAny = true;
|
|
136
|
+
}
|
|
86
137
|
}
|
|
87
138
|
}
|
|
139
|
+
if (changedAny && this._onOta) {
|
|
140
|
+
error_enveloper_1.errorEnveloper.handle(() => this._onOta(this.raw), (e) => console.log(`OnOta Error: ${e.message}, where: ${WHERE}, scope: ${this.name}`));
|
|
141
|
+
}
|
|
88
142
|
}
|
|
89
143
|
}
|
|
90
144
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env-scope.impl.js","sourceRoot":"","sources":["../../src/scope/env-scope.impl.ts"],"names":[],"mappings":";;;AAAA,0CAAgC;AAChC,0CAAwD;AACxD,4DAAqD;
|
|
1
|
+
{"version":3,"file":"env-scope.impl.js","sourceRoot":"","sources":["../../src/scope/env-scope.impl.ts"],"names":[],"mappings":";;;AAAA,0CAAgC;AAChC,0CAAwD;AACxD,4DAAqD;AACrD,4DAAsD;AAMtD,MAAM,KAAK,GAAG,GAAG,cAAG,eAAe,CAAC;AAEpC,MAAa,YAAY;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AY,IAAI,CAAC,IAAI,EAAE,CAAC,CACxF,CAAC;YACN,CAAC;QACL,CAAC;IACL,CAAC;CACJ;AAzJD,oCAyJC"}
|
|
@@ -1,16 +1,25 @@
|
|
|
1
|
-
import type { EnvField } from "../field";
|
|
1
|
+
import type { EnvField, EnvFieldPrint } from "../field";
|
|
2
2
|
import type { EnvBase, EnvCore } from "../core";
|
|
3
3
|
export interface EnvScope<E extends EnvBase = EnvBase> {
|
|
4
4
|
field<Z extends keyof E = keyof E>(field: Z): EnvField<E, Z>;
|
|
5
5
|
get<Z extends keyof E = keyof E>(field: Z): EnvField<E, Z>;
|
|
6
6
|
has<Z extends keyof E = keyof E>(field: Z): boolean;
|
|
7
7
|
uses(scope: string): this;
|
|
8
|
+
uses<E2 extends EnvBase = EnvBase>(scope: EnvScope<E2>): this;
|
|
9
|
+
onChange(fn: EnvScopeOnChange<E>): EnvScope<E>;
|
|
10
|
+
onSet(fn: EnvScopeOnChange<E>): EnvScope<E>;
|
|
11
|
+
onOta(fn: EnvScopeOtaLambda<E>): EnvScope<E>;
|
|
8
12
|
run(): void;
|
|
13
|
+
print(): EnvFieldPrint[];
|
|
9
14
|
get raw(): E;
|
|
10
15
|
get name(): string;
|
|
11
16
|
get core(): EnvCore;
|
|
12
17
|
$run(): void;
|
|
18
|
+
$print(): EnvFieldPrint[];
|
|
13
19
|
$refresh(): void;
|
|
20
|
+
$clear(): void;
|
|
14
21
|
$fromOta(values: Partial<E>): void;
|
|
15
22
|
$addOta(name: keyof E): void;
|
|
16
23
|
}
|
|
24
|
+
export type EnvScopeOnChange<E extends EnvBase = EnvBase> = (data: E) => void;
|
|
25
|
+
export type EnvScopeOtaLambda<E extends EnvBase = EnvBase> = (data: E) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leyyo/env",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "Environment library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"env",
|
|
@@ -51,6 +51,7 @@
|
|
|
51
51
|
"typescript": "^5.7.3"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@leyyo/common": "^1.0.13"
|
|
54
|
+
"@leyyo/common": "^1.0.13",
|
|
55
|
+
"@leyyo/error-enveloper": "^1.0.3"
|
|
55
56
|
}
|
|
56
57
|
}
|