@leyyo/env 1.3.11 → 1.3.12
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 +25 -16
- package/dist/core/index.d.ts +3 -3
- package/dist/core/index.js +3 -3
- package/dist/field/env-field.impl.js +87 -72
- package/dist/field/index.d.ts +1 -1
- package/dist/field/index.js +1 -1
- package/dist/field/index.types.d.ts +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.foretell.d.ts +1 -1
- package/dist/index.foretell.js +2 -2
- package/dist/index.js +5 -5
- package/dist/index.loader.js +3 -3
- package/dist/internal.d.ts +1 -1
- package/dist/internal.js +3 -2
- package/dist/scope/env-scope.impl.js +62 -41
- package/dist/scope/index.d.ts +1 -1
- package/dist/scope/index.js +1 -1
- package/dist/scope/index.types.d.ts +3 -3
- package/dist/server.js +1 -1
- package/package.json +23 -23
|
@@ -20,17 +20,20 @@ class EnvCoreImpl {
|
|
|
20
20
|
* */
|
|
21
21
|
_keys = repoCommon.newMap(`${FQN}.keys`); // field name x scope name[]
|
|
22
22
|
// endregion property
|
|
23
|
-
constructor() {
|
|
24
|
-
}
|
|
23
|
+
constructor() { }
|
|
25
24
|
// region configure
|
|
26
25
|
/** @inheritDoc */
|
|
27
26
|
scope(name, prefix) {
|
|
28
|
-
assertText(name, () => optFn({ field:
|
|
27
|
+
assertText(name, () => optFn({ field: "name", where: WHERE, method: "scope" }));
|
|
29
28
|
if (this._scopes.has(name)) {
|
|
30
|
-
|
|
29
|
+
new EnvironmentError("scope.duplicated", `Scope[${name}] is duplicated`, {
|
|
30
|
+
value: name,
|
|
31
|
+
where: WHERE,
|
|
32
|
+
method: "scope",
|
|
33
|
+
}).log();
|
|
31
34
|
}
|
|
32
35
|
if (prefix) {
|
|
33
|
-
assertText(prefix, () => optFn({ where: WHERE, scope: name, method:
|
|
36
|
+
assertText(prefix, () => optFn({ where: WHERE, scope: name, method: "scope", field: "prefix" }));
|
|
34
37
|
}
|
|
35
38
|
else {
|
|
36
39
|
prefix = undefined;
|
|
@@ -43,29 +46,37 @@ class EnvCoreImpl {
|
|
|
43
46
|
// region runtime
|
|
44
47
|
/** @inheritDoc */
|
|
45
48
|
getScope(name) {
|
|
46
|
-
assertText(name, () => optFn({ field:
|
|
49
|
+
assertText(name, () => optFn({ field: "scope", where: WHERE, method: "getScope" }));
|
|
47
50
|
if (!this._scopes.has(name)) {
|
|
48
|
-
|
|
51
|
+
new EnvironmentError("scope.not.found", `Scope[${name}] could not found`, {
|
|
52
|
+
value: name,
|
|
53
|
+
where: WHERE,
|
|
54
|
+
method: "getScope",
|
|
55
|
+
}).log();
|
|
49
56
|
}
|
|
50
57
|
return this._scopes.get(name);
|
|
51
58
|
}
|
|
52
59
|
/** @inheritDoc */
|
|
53
60
|
hasScope(name) {
|
|
54
|
-
assertText(name, () => optFn({ field:
|
|
61
|
+
assertText(name, () => optFn({ field: "scope", where: WHERE, method: "hasScope" }));
|
|
55
62
|
return this._scopes.has(name);
|
|
56
63
|
}
|
|
57
64
|
/** @inheritDoc */
|
|
58
65
|
getKey(key) {
|
|
59
|
-
assertText(key, () => optFn({ field:
|
|
66
|
+
assertText(key, () => optFn({ field: "key", where: WHERE, method: "getKey" }));
|
|
60
67
|
if (!this._keys.has(key)) {
|
|
61
|
-
throw new EnvironmentError(
|
|
68
|
+
throw new EnvironmentError("field.not.found", `Key[${key}] could not found`, {
|
|
69
|
+
value: key,
|
|
70
|
+
where: WHERE,
|
|
71
|
+
method: "getKey",
|
|
72
|
+
});
|
|
62
73
|
}
|
|
63
74
|
return this._keys.get(key);
|
|
64
75
|
}
|
|
65
76
|
/** @inheritDoc */
|
|
66
77
|
hasKey(key) {
|
|
67
78
|
assertText(key, () => {
|
|
68
|
-
return { field: key, where: WHERE, method:
|
|
79
|
+
return { field: key, where: WHERE, method: "hasKey" };
|
|
69
80
|
});
|
|
70
81
|
return this._keys.has(key);
|
|
71
82
|
}
|
|
@@ -87,14 +98,12 @@ class EnvCoreImpl {
|
|
|
87
98
|
}
|
|
88
99
|
/** @inheritDoc */
|
|
89
100
|
read() {
|
|
90
|
-
Array.from(this._scopes.values())
|
|
91
|
-
.forEach(ins => ins.$secure.$read());
|
|
101
|
+
Array.from(this._scopes.values()).forEach((ins) => ins.$secure.$read());
|
|
92
102
|
}
|
|
93
103
|
/** @inheritDoc */
|
|
94
104
|
print(asObject) {
|
|
95
105
|
const result = [];
|
|
96
|
-
Array.from(this._scopes.values())
|
|
97
|
-
.forEach(ins => result.push(ins.$secure.$print()));
|
|
106
|
+
Array.from(this._scopes.values()).forEach((ins) => result.push(ins.$secure.$print()));
|
|
98
107
|
if (asObject) {
|
|
99
108
|
return result;
|
|
100
109
|
}
|
|
@@ -130,7 +139,7 @@ class EnvCoreImpl {
|
|
|
130
139
|
$addKey(key, field, alternative) {
|
|
131
140
|
if (this._keys.has(key)) {
|
|
132
141
|
const existing = this._keys.get(key);
|
|
133
|
-
|
|
142
|
+
new EnvironmentError(`Key[${key}] is duplicated! existing: ${existing.field.scope.name}${existing.alternative ?? ""}, new: ${field.scope.name}${alternative ?? ""}`);
|
|
134
143
|
}
|
|
135
144
|
this._keys.set(key, { field, alternative });
|
|
136
145
|
}
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
1
|
+
export * from "./index.types.js";
|
|
2
|
+
export * from "./env-core.impl.js";
|
|
3
|
+
export * from "./environment.error.js";
|
package/dist/core/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
1
|
+
export * from "./index.types.js";
|
|
2
|
+
export * from "./env-core.impl.js";
|
|
3
|
+
export * from "./environment.error.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FQN } from "../internal.js";
|
|
2
|
-
import { isEmpty, logCommon, secureJson, setFqn } from "@leyyo/common";
|
|
3
|
-
import { toBooleanValue, toDelimitedValue, toEnumValue, toIntegerValue, toLiteralValue, toNumberValue, toStringValue, toTextValue } from "@leyyo/type";
|
|
4
|
-
import { assertArray, assertBoolean, assertFilledArray, assertFilledObject, assertFunction, assertText } from "@leyyo/assert";
|
|
2
|
+
import { isEmpty, logCommon, secureJson, setFqn, } from "@leyyo/common";
|
|
3
|
+
import { toBooleanValue, toDelimitedValue, toEnumValue, toIntegerValue, toLiteralValue, toNumberValue, toStringValue, toTextValue, } from "@leyyo/type";
|
|
4
|
+
import { assertArray, assertBoolean, assertFilledArray, assertFilledObject, assertFunction, assertText, } from "@leyyo/assert";
|
|
5
5
|
import { enveloper } from "@leyyo/enveloper";
|
|
6
6
|
const WHERE = `${FQN}.EnvFieldImpl`;
|
|
7
7
|
const ENV = {};
|
|
@@ -34,8 +34,8 @@ export class EnvFieldImpl {
|
|
|
34
34
|
constructor(scope, name) {
|
|
35
35
|
this.scope = scope;
|
|
36
36
|
this.name = name;
|
|
37
|
-
const prefix = scope.prefix ? `${scope.prefix}_` :
|
|
38
|
-
const variation = scope.variation ? `_${scope.variation}` :
|
|
37
|
+
const prefix = scope.prefix ? `${scope.prefix}_` : "";
|
|
38
|
+
const variation = scope.variation ? `_${scope.variation}` : "";
|
|
39
39
|
this.full = `${prefix}${name}${variation}`;
|
|
40
40
|
this._off = false;
|
|
41
41
|
}
|
|
@@ -60,43 +60,43 @@ export class EnvFieldImpl {
|
|
|
60
60
|
let to1;
|
|
61
61
|
const nullable = !this._findRequired;
|
|
62
62
|
switch (this._type) {
|
|
63
|
-
case
|
|
63
|
+
case "string":
|
|
64
64
|
to1 = toStringValue;
|
|
65
65
|
break;
|
|
66
|
-
case
|
|
66
|
+
case "text":
|
|
67
67
|
to1 = toTextValue;
|
|
68
68
|
break;
|
|
69
|
-
case
|
|
69
|
+
case "integer":
|
|
70
70
|
to1 = toIntegerValue;
|
|
71
71
|
break;
|
|
72
|
-
case
|
|
72
|
+
case "float":
|
|
73
73
|
to1 = toNumberValue;
|
|
74
74
|
break;
|
|
75
|
-
case
|
|
75
|
+
case "boolean":
|
|
76
76
|
to1 = toBooleanValue;
|
|
77
77
|
break;
|
|
78
|
-
case
|
|
78
|
+
case "literal":
|
|
79
79
|
to1 = toLiteralValue;
|
|
80
80
|
break;
|
|
81
|
-
case
|
|
81
|
+
case "enumeration":
|
|
82
82
|
to1 = toEnumValue;
|
|
83
83
|
break;
|
|
84
84
|
}
|
|
85
85
|
const opt = { ...this._devOne, nullable };
|
|
86
|
-
if (this._type ===
|
|
86
|
+
if (this._type === "literal") {
|
|
87
87
|
let items;
|
|
88
88
|
if (this._literalFn) {
|
|
89
|
-
items = enveloper.swallow(() => this._literalFn(this.scope.valueShort, this.name, this.scope.name), [
|
|
89
|
+
items = enveloper.swallow(() => this._literalFn(this.scope.valueShort, this.name, this.scope.name), ["none"]);
|
|
90
90
|
}
|
|
91
91
|
else {
|
|
92
92
|
items = this._typeOpt;
|
|
93
93
|
}
|
|
94
94
|
opt.literal = items;
|
|
95
95
|
}
|
|
96
|
-
else if (this._type ===
|
|
96
|
+
else if (this._type === "enumeration") {
|
|
97
97
|
let map;
|
|
98
98
|
if (this._enumFn) {
|
|
99
|
-
map = enveloper.swallow(() => this._enumFn(this.scope.valueShort, this.name, this.scope.name), { none:
|
|
99
|
+
map = enveloper.swallow(() => this._enumFn(this.scope.valueShort, this.name, this.scope.name), { none: "none" });
|
|
100
100
|
}
|
|
101
101
|
else {
|
|
102
102
|
map = this._typeOpt;
|
|
@@ -108,7 +108,7 @@ export class EnvFieldImpl {
|
|
|
108
108
|
this.$cast((v, _o) => toDelimitedValue(v, opt));
|
|
109
109
|
}
|
|
110
110
|
else {
|
|
111
|
-
this.$cast(v => to1(v, opt));
|
|
111
|
+
this.$cast((v) => to1(v, opt));
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
get _fromDef() {
|
|
@@ -136,20 +136,20 @@ export class EnvFieldImpl {
|
|
|
136
136
|
const value = this.value;
|
|
137
137
|
if (this._array) {
|
|
138
138
|
if (Array.isArray(value)) {
|
|
139
|
-
return value.join(
|
|
139
|
+
return value.join("^~|");
|
|
140
140
|
}
|
|
141
|
-
return
|
|
141
|
+
return "";
|
|
142
142
|
}
|
|
143
|
-
return isEmpty(value) ?
|
|
143
|
+
return isEmpty(value) ? "" : value;
|
|
144
144
|
}
|
|
145
145
|
// endregion private
|
|
146
146
|
// region configure
|
|
147
147
|
off(p1 = true) {
|
|
148
|
-
if (typeof p1 ===
|
|
148
|
+
if (typeof p1 === "function") {
|
|
149
149
|
this._offFn = p1;
|
|
150
150
|
}
|
|
151
151
|
else {
|
|
152
|
-
const opt = { field: this._f, method:
|
|
152
|
+
const opt = { field: this._f, method: "off", where: WHERE, scope: this.scope.name };
|
|
153
153
|
assertBoolean(p1, opt);
|
|
154
154
|
this._off = p1;
|
|
155
155
|
}
|
|
@@ -157,11 +157,11 @@ export class EnvFieldImpl {
|
|
|
157
157
|
}
|
|
158
158
|
/** {@inheritDoc} */
|
|
159
159
|
required(p1) {
|
|
160
|
-
if (typeof p1 ==
|
|
160
|
+
if (typeof p1 == "function") {
|
|
161
161
|
this._requiredFn = p1;
|
|
162
162
|
return this;
|
|
163
163
|
}
|
|
164
|
-
if (typeof p1 ===
|
|
164
|
+
if (typeof p1 === "boolean") {
|
|
165
165
|
this._required = p1;
|
|
166
166
|
}
|
|
167
167
|
else {
|
|
@@ -180,14 +180,14 @@ export class EnvFieldImpl {
|
|
|
180
180
|
return this;
|
|
181
181
|
}
|
|
182
182
|
clone(name) {
|
|
183
|
-
const opt = { field: this._f, method:
|
|
183
|
+
const opt = { field: this._f, method: "clone", where: WHERE, scope: this.scope.name };
|
|
184
184
|
assertText(name, opt);
|
|
185
185
|
if (name === this._f) {
|
|
186
|
-
logger.warn(
|
|
186
|
+
logger.warn("Same field", opt);
|
|
187
187
|
this._clone = undefined;
|
|
188
188
|
}
|
|
189
189
|
else if (this._aliases && this._aliases.includes(name)) {
|
|
190
|
-
logger.warn(
|
|
190
|
+
logger.warn("Alias field", opt);
|
|
191
191
|
this._clone = undefined;
|
|
192
192
|
}
|
|
193
193
|
else {
|
|
@@ -200,7 +200,7 @@ export class EnvFieldImpl {
|
|
|
200
200
|
this._def = undefined;
|
|
201
201
|
this._defFn = undefined;
|
|
202
202
|
if (!isEmpty(value)) {
|
|
203
|
-
if (typeof value ===
|
|
203
|
+
if (typeof value === "function") {
|
|
204
204
|
this._defFn = value;
|
|
205
205
|
}
|
|
206
206
|
else if (this._array) {
|
|
@@ -214,17 +214,17 @@ export class EnvFieldImpl {
|
|
|
214
214
|
}
|
|
215
215
|
/** {@inheritDoc} */
|
|
216
216
|
alias(...keys) {
|
|
217
|
-
const opt = { field: this._f, method:
|
|
217
|
+
const opt = { field: this._f, method: "aliases", where: WHERE, scope: this.scope.name };
|
|
218
218
|
assertArray(keys, opt);
|
|
219
219
|
if (keys.length > 0) {
|
|
220
220
|
keys.forEach((key, index) => {
|
|
221
221
|
const opt2 = { ...opt, field: `${this._f}[${index}]` };
|
|
222
222
|
assertText(key, opt2);
|
|
223
223
|
if (key === this._f) {
|
|
224
|
-
logger.warn(
|
|
224
|
+
logger.warn("Same alias", opt2);
|
|
225
225
|
}
|
|
226
226
|
else if (key === this._clone) {
|
|
227
|
-
logger.warn(
|
|
227
|
+
logger.warn("Cloned alias", opt2);
|
|
228
228
|
}
|
|
229
229
|
else {
|
|
230
230
|
if (!this._aliases) {
|
|
@@ -235,7 +235,7 @@ export class EnvFieldImpl {
|
|
|
235
235
|
this.scope.core.$secure.$addKey(key, this, key);
|
|
236
236
|
}
|
|
237
237
|
else {
|
|
238
|
-
logger.warn(
|
|
238
|
+
logger.warn("Duplicated alias", opt2);
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
241
|
});
|
|
@@ -244,58 +244,68 @@ export class EnvFieldImpl {
|
|
|
244
244
|
}
|
|
245
245
|
/** {@inheritDoc} */
|
|
246
246
|
string() {
|
|
247
|
-
this._type =
|
|
247
|
+
this._type = "string";
|
|
248
248
|
this._typeOpt = undefined;
|
|
249
249
|
return this;
|
|
250
250
|
}
|
|
251
251
|
/** {@inheritDoc} */
|
|
252
252
|
text() {
|
|
253
|
-
this._type =
|
|
253
|
+
this._type = "string";
|
|
254
254
|
this._typeOpt = undefined;
|
|
255
255
|
return this;
|
|
256
256
|
}
|
|
257
257
|
/** {@inheritDoc} */
|
|
258
258
|
float() {
|
|
259
|
-
this._type =
|
|
259
|
+
this._type = "float";
|
|
260
260
|
this._typeOpt = undefined;
|
|
261
261
|
return this;
|
|
262
262
|
}
|
|
263
263
|
/** {@inheritDoc} */
|
|
264
264
|
integer() {
|
|
265
|
-
this._type =
|
|
265
|
+
this._type = "integer";
|
|
266
266
|
this._typeOpt = undefined;
|
|
267
267
|
return this;
|
|
268
268
|
}
|
|
269
269
|
/** {@inheritDoc} */
|
|
270
270
|
boolean() {
|
|
271
|
-
this._type =
|
|
271
|
+
this._type = "boolean";
|
|
272
272
|
this._typeOpt = undefined;
|
|
273
273
|
return this;
|
|
274
274
|
}
|
|
275
275
|
/** {@inheritDoc} */
|
|
276
276
|
literal(p1) {
|
|
277
|
-
this._type =
|
|
277
|
+
this._type = "literal";
|
|
278
278
|
this._literalFn = undefined;
|
|
279
279
|
this._typeOpt = undefined;
|
|
280
280
|
if (typeof p1 === "function") {
|
|
281
281
|
this._literalFn = p1;
|
|
282
282
|
}
|
|
283
283
|
else {
|
|
284
|
-
assertFilledArray(p1, {
|
|
284
|
+
assertFilledArray(p1, {
|
|
285
|
+
field: this._f,
|
|
286
|
+
method: "literal",
|
|
287
|
+
where: WHERE,
|
|
288
|
+
scope: this.scope.name,
|
|
289
|
+
});
|
|
285
290
|
this._typeOpt = p1;
|
|
286
291
|
}
|
|
287
292
|
return this;
|
|
288
293
|
}
|
|
289
294
|
/** {@inheritDoc} */
|
|
290
295
|
enumeration(p1) {
|
|
291
|
-
this._type =
|
|
296
|
+
this._type = "enumeration";
|
|
292
297
|
this._enumFn = undefined;
|
|
293
298
|
this._typeOpt = undefined;
|
|
294
299
|
if (typeof p1 === "function") {
|
|
295
300
|
this._enumFn = p1;
|
|
296
301
|
}
|
|
297
302
|
else {
|
|
298
|
-
assertFilledObject(p1, {
|
|
303
|
+
assertFilledObject(p1, {
|
|
304
|
+
field: this._f,
|
|
305
|
+
method: "enumeration",
|
|
306
|
+
where: WHERE,
|
|
307
|
+
scope: this.scope.name,
|
|
308
|
+
});
|
|
299
309
|
this._typeOpt = p1;
|
|
300
310
|
}
|
|
301
311
|
return this;
|
|
@@ -303,13 +313,18 @@ export class EnvFieldImpl {
|
|
|
303
313
|
/** {@inheritDoc} */
|
|
304
314
|
onOta(fn) {
|
|
305
315
|
this.scope.$secure.$addOta(this.name);
|
|
306
|
-
assertFunction(fn, { field: this._f, where: WHERE, scope: this.scope.name, method:
|
|
316
|
+
assertFunction(fn, { field: this._f, where: WHERE, scope: this.scope.name, method: "ota" });
|
|
307
317
|
this._onOta = fn;
|
|
308
318
|
return this;
|
|
309
319
|
}
|
|
310
320
|
/** {@inheritDoc} */
|
|
311
321
|
onChange(fn) {
|
|
312
|
-
assertFunction(fn, {
|
|
322
|
+
assertFunction(fn, {
|
|
323
|
+
field: this._f,
|
|
324
|
+
where: WHERE,
|
|
325
|
+
scope: this.scope.name,
|
|
326
|
+
method: "onChange",
|
|
327
|
+
});
|
|
313
328
|
if (!Array.isArray(this._onChangeList)) {
|
|
314
329
|
this._onChangeList = [];
|
|
315
330
|
}
|
|
@@ -318,19 +333,19 @@ export class EnvFieldImpl {
|
|
|
318
333
|
}
|
|
319
334
|
/** {@inheritDoc} */
|
|
320
335
|
onSet(fn) {
|
|
321
|
-
assertFunction(fn, { field: this._f, where: WHERE, scope: this.scope.name, method:
|
|
336
|
+
assertFunction(fn, { field: this._f, where: WHERE, scope: this.scope.name, method: "onSet" });
|
|
322
337
|
this._onSet = fn;
|
|
323
338
|
return this;
|
|
324
339
|
}
|
|
325
340
|
/** {@inheritDoc} */
|
|
326
341
|
cast(fn) {
|
|
327
|
-
assertFunction(fn, { field: this._f, method:
|
|
342
|
+
assertFunction(fn, { field: this._f, method: "cast", where: WHERE, scope: this.scope.name });
|
|
328
343
|
this.$cast(fn);
|
|
329
344
|
return this;
|
|
330
345
|
}
|
|
331
346
|
/** {@inheritDoc} */
|
|
332
347
|
assert(fn) {
|
|
333
|
-
assertFunction(fn, { field: this._f, method:
|
|
348
|
+
assertFunction(fn, { field: this._f, method: "cast", where: WHERE, scope: this.scope.name });
|
|
334
349
|
this.$assert(fn);
|
|
335
350
|
return this;
|
|
336
351
|
}
|
|
@@ -358,9 +373,9 @@ export class EnvFieldImpl {
|
|
|
358
373
|
case "object":
|
|
359
374
|
return secureJson(value);
|
|
360
375
|
case "function":
|
|
361
|
-
return `[fnc]${value.name ??
|
|
376
|
+
return `[fnc]${value.name ?? "~lambda~"}[${value.length}]`;
|
|
362
377
|
case "symbol":
|
|
363
|
-
return `[sym]${value.description ??
|
|
378
|
+
return `[sym]${value.description ?? "~symbol~"}]`;
|
|
364
379
|
default:
|
|
365
380
|
return undefined;
|
|
366
381
|
}
|
|
@@ -375,43 +390,43 @@ export class EnvFieldImpl {
|
|
|
375
390
|
}
|
|
376
391
|
}
|
|
377
392
|
else {
|
|
378
|
-
result.value =
|
|
393
|
+
result.value = "<secret>";
|
|
379
394
|
}
|
|
380
395
|
const opt = {};
|
|
381
396
|
if (this._required) {
|
|
382
397
|
if (this._requiredFn) {
|
|
383
|
-
opt[
|
|
398
|
+
opt["required"] = ["conditional", this._findRequired];
|
|
384
399
|
}
|
|
385
400
|
else {
|
|
386
|
-
opt[
|
|
401
|
+
opt["required"] = true;
|
|
387
402
|
}
|
|
388
403
|
}
|
|
389
404
|
if (this._typeOpt !== undefined) {
|
|
390
405
|
opt[this._type] = true;
|
|
391
406
|
}
|
|
392
407
|
if (this._def !== undefined && !this._secret) {
|
|
393
|
-
opt[
|
|
408
|
+
opt["def"] = this._printValue(this._fromDef);
|
|
394
409
|
}
|
|
395
410
|
if (this._clone !== undefined) {
|
|
396
|
-
opt[
|
|
411
|
+
opt["clone"] = this._clone;
|
|
397
412
|
}
|
|
398
413
|
if (this._secret) {
|
|
399
|
-
opt[
|
|
414
|
+
opt["secret"] = true;
|
|
400
415
|
}
|
|
401
416
|
if (this._aliases !== undefined) {
|
|
402
|
-
opt[
|
|
417
|
+
opt["aliases"] = this._printValue(this._aliases);
|
|
403
418
|
}
|
|
404
419
|
if (this._array) {
|
|
405
|
-
opt[
|
|
420
|
+
opt["array"] = true;
|
|
406
421
|
}
|
|
407
422
|
if (this._onOta) {
|
|
408
|
-
opt[
|
|
423
|
+
opt["onOta"] = 1;
|
|
409
424
|
}
|
|
410
425
|
if (this._onSet) {
|
|
411
|
-
opt[
|
|
426
|
+
opt["onSet"] = 1;
|
|
412
427
|
}
|
|
413
428
|
if (this._onChangeList) {
|
|
414
|
-
opt[
|
|
429
|
+
opt["onChange"] = this._onChangeList.length;
|
|
415
430
|
}
|
|
416
431
|
if (Object.keys(opt).length) {
|
|
417
432
|
result.opt = opt;
|
|
@@ -462,21 +477,21 @@ export class EnvFieldImpl {
|
|
|
462
477
|
const current = this._plainValue;
|
|
463
478
|
if (this._onChangeList && current !== old) {
|
|
464
479
|
this._onChangeList.forEach((fn, index) => {
|
|
465
|
-
enveloper.handle(() => fn(this.scope.valueShort, this.name, this.scope.name), (e) => logger.warn(
|
|
480
|
+
enveloper.handle(() => fn(this.scope.valueShort, this.name, this.scope.name), (e) => logger.warn("On Change error", {
|
|
466
481
|
caused: { name: e.name, message: e.message },
|
|
467
482
|
where: WHERE,
|
|
468
483
|
scope: this.scope.name,
|
|
469
484
|
field: this._f,
|
|
470
|
-
index
|
|
485
|
+
index,
|
|
471
486
|
}));
|
|
472
487
|
});
|
|
473
488
|
}
|
|
474
489
|
if (this._onSet) {
|
|
475
|
-
enveloper.handle(() => this._onSet(this.scope.valueShort, this.name, this.scope.name), (e) => logger.warn(
|
|
490
|
+
enveloper.handle(() => this._onSet(this.scope.valueShort, this.name, this.scope.name), (e) => logger.warn("On set error", {
|
|
476
491
|
caused: { name: e.name, message: e.message },
|
|
477
492
|
where: WHERE,
|
|
478
493
|
scope: this.scope.name,
|
|
479
|
-
field: this._f
|
|
494
|
+
field: this._f,
|
|
480
495
|
}));
|
|
481
496
|
}
|
|
482
497
|
return current !== old;
|
|
@@ -487,20 +502,20 @@ export class EnvFieldImpl {
|
|
|
487
502
|
let changed = false;
|
|
488
503
|
enveloper.handle(() => {
|
|
489
504
|
changed = this.read();
|
|
490
|
-
}, e => {
|
|
491
|
-
logger.warn(
|
|
505
|
+
}, (e) => {
|
|
506
|
+
logger.warn("Ota run error", {
|
|
492
507
|
caused: { name: e.name, message: e.message },
|
|
493
508
|
where: WHERE,
|
|
494
509
|
scope: this.scope.name,
|
|
495
|
-
field: this._f
|
|
510
|
+
field: this._f,
|
|
496
511
|
});
|
|
497
512
|
});
|
|
498
513
|
if (changed && this._onOta) {
|
|
499
|
-
enveloper.handle(() => this._onOta(this.scope.valueShort, this.name, this.scope.name), e => logger.warn(
|
|
514
|
+
enveloper.handle(() => this._onOta(this.scope.valueShort, this.name, this.scope.name), (e) => logger.warn("Ota error", {
|
|
500
515
|
caused: { name: e.name, message: e.message },
|
|
501
516
|
where: WHERE,
|
|
502
517
|
scope: this.scope.name,
|
|
503
|
-
field: this._f
|
|
518
|
+
field: this._f,
|
|
504
519
|
}));
|
|
505
520
|
}
|
|
506
521
|
return changed;
|
|
@@ -543,14 +558,14 @@ export class EnvFieldImpl {
|
|
|
543
558
|
try {
|
|
544
559
|
for (const [k, v] of Object.entries(process.env)) {
|
|
545
560
|
// ignore empty string
|
|
546
|
-
if (typeof v !==
|
|
547
|
-
if (v ===
|
|
561
|
+
if (typeof v !== "string" || v.trim()) {
|
|
562
|
+
if (v === "true") {
|
|
548
563
|
ENV[k] = true;
|
|
549
564
|
}
|
|
550
|
-
else if (v ===
|
|
565
|
+
else if (v === "false") {
|
|
551
566
|
ENV[k] = false;
|
|
552
567
|
}
|
|
553
|
-
else if (v ===
|
|
568
|
+
else if (v === "null") {
|
|
554
569
|
ENV[k] = null;
|
|
555
570
|
}
|
|
556
571
|
else {
|
package/dist/field/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from "./index.types.js";
|
package/dist/field/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from "./index.types.js";
|
|
@@ -6,7 +6,7 @@ import { AssertBasicFn } from "@leyyo/assert";
|
|
|
6
6
|
/**
|
|
7
7
|
* Field types
|
|
8
8
|
* */
|
|
9
|
-
export type EnvFieldType =
|
|
9
|
+
export type EnvFieldType = "string" | "text" | "float" | "integer" | "boolean" | "literal" | "enumeration";
|
|
10
10
|
/**
|
|
11
11
|
* Printable field object
|
|
12
12
|
* */
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
1
|
+
export * from "./field/index.js";
|
|
2
|
+
export * from "./scope/index.js";
|
|
3
|
+
export * from "./core/index.js";
|
|
4
|
+
export * from "./index.foretell.js";
|
|
5
|
+
export * from "./index.loader.js";
|
package/dist/index.foretell.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const foretell_leyyoEnv:
|
|
1
|
+
export declare const foretell_leyyoEnv: (() => void)[];
|
package/dist/index.foretell.js
CHANGED
|
@@ -11,10 +11,10 @@ export const foretell_leyyoEnv = [
|
|
|
11
11
|
...foretell_leyyoType,
|
|
12
12
|
...foretell_leyyoAssert,
|
|
13
13
|
() => errorPool.register({
|
|
14
|
-
name:
|
|
14
|
+
name: "EnvironmentError",
|
|
15
15
|
fqn: FQN,
|
|
16
16
|
i18n: true,
|
|
17
17
|
emit: true,
|
|
18
|
-
lazyTarget: import(
|
|
18
|
+
lazyTarget: import("./core/environment.error.js").then((m) => m.EnvironmentError),
|
|
19
19
|
}),
|
|
20
20
|
];
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
1
|
+
export * from "./field/index.js";
|
|
2
|
+
export * from "./scope/index.js";
|
|
3
|
+
export * from "./core/index.js";
|
|
4
|
+
export * from "./index.foretell.js";
|
|
5
|
+
export * from "./index.loader.js";
|
package/dist/index.loader.js
CHANGED
|
@@ -8,8 +8,8 @@ export const loader_leyyoEnv = defineLoader(FQN,
|
|
|
8
8
|
// dependencies
|
|
9
9
|
...loader_leyyoCommon, ...loader_leyyoEnveloper, ...loader_leyyoType, ...loader_leyyoAssert,
|
|
10
10
|
// error
|
|
11
|
-
() => import(
|
|
11
|
+
() => import("./core/environment.error.js").then((m) => m.EnvironmentError),
|
|
12
12
|
// instances
|
|
13
|
-
() => import(
|
|
13
|
+
() => import("./core/env-core.impl.js").then((m) => m.envCore),
|
|
14
14
|
// classes
|
|
15
|
-
() => import(
|
|
15
|
+
() => import("./field/env-field.impl.js").then((m) => m.EnvFieldImpl), () => import("./scope/env-scope.impl.js").then((m) => m.EnvScopeImpl));
|
package/dist/internal.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const NME: string, FQN: string, VER: string
|
|
1
|
+
export declare const NME: string, FQN: string, VER: string;
|
package/dist/internal.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { packageJson } from "@leyyo/common";
|
|
2
|
+
// noinspection JSUnusedGlobalSymbols
|
|
3
|
+
export const { name: NME, fqn: FQN, version: VER } = packageJson(import.meta.url);
|
|
@@ -20,7 +20,7 @@ export class EnvScopeImpl {
|
|
|
20
20
|
_onOta;
|
|
21
21
|
_onChangeList;
|
|
22
22
|
_onSet;
|
|
23
|
-
_state =
|
|
23
|
+
_state = "pending";
|
|
24
24
|
// endregion property
|
|
25
25
|
constructor(core, name, prefix, variation) {
|
|
26
26
|
this.core = core;
|
|
@@ -31,11 +31,16 @@ export class EnvScopeImpl {
|
|
|
31
31
|
// region configure
|
|
32
32
|
field(name) {
|
|
33
33
|
if (this.variation) {
|
|
34
|
-
throw new EnvironmentError(
|
|
34
|
+
throw new EnvironmentError("varied.scope.does.not.support", `Scope[${this.name}] does not support to create new field`, { scope: this.name, where: WHERE, method: "finish" });
|
|
35
35
|
}
|
|
36
|
-
assertText(name, () => optFn({ where: WHERE, scope: this.name, method:
|
|
36
|
+
assertText(name, () => optFn({ where: WHERE, scope: this.name, method: "field" }));
|
|
37
37
|
if (this._fields.has(name)) {
|
|
38
|
-
|
|
38
|
+
new EnvironmentError("field.duplicated", `Field[${name}] is duplicated`, {
|
|
39
|
+
where: WHERE,
|
|
40
|
+
scope: this.name,
|
|
41
|
+
method: "field",
|
|
42
|
+
field: name,
|
|
43
|
+
}).log();
|
|
39
44
|
}
|
|
40
45
|
const ins = new EnvFieldImpl(this, name);
|
|
41
46
|
this._fields.set(name, ins);
|
|
@@ -45,17 +50,17 @@ export class EnvScopeImpl {
|
|
|
45
50
|
uses(p1) {
|
|
46
51
|
let name;
|
|
47
52
|
let scope;
|
|
48
|
-
if (typeof p1 ===
|
|
53
|
+
if (typeof p1 === "string") {
|
|
49
54
|
name = p1;
|
|
50
55
|
if (this.core.hasScope(name)) {
|
|
51
56
|
scope = this.core.getScope(name);
|
|
52
57
|
scope.$secure.$read();
|
|
53
58
|
}
|
|
54
59
|
else {
|
|
55
|
-
logger.warn(
|
|
60
|
+
logger.warn("Not found scope", { given: name, where: WHERE, scope: this.name });
|
|
56
61
|
}
|
|
57
62
|
if (this._uses.has(name)) {
|
|
58
|
-
logger.warn(
|
|
63
|
+
logger.warn("Duplicated used scope", { given: name, where: WHERE, scope: this.name });
|
|
59
64
|
}
|
|
60
65
|
else {
|
|
61
66
|
this._uses.set(name, scope);
|
|
@@ -65,7 +70,7 @@ export class EnvScopeImpl {
|
|
|
65
70
|
scope = p1;
|
|
66
71
|
name = scope.name;
|
|
67
72
|
if (this._uses.has(name)) {
|
|
68
|
-
logger.warn(
|
|
73
|
+
logger.warn("Duplicated used scope", { given: name, where: WHERE, scope: this.name });
|
|
69
74
|
}
|
|
70
75
|
else {
|
|
71
76
|
this._uses.set(name, scope);
|
|
@@ -73,12 +78,17 @@ export class EnvScopeImpl {
|
|
|
73
78
|
}
|
|
74
79
|
}
|
|
75
80
|
else {
|
|
76
|
-
logger.warn(
|
|
81
|
+
logger.warn("Invalid used scope", {
|
|
82
|
+
type: typeof p1,
|
|
83
|
+
clazz: p1?.constructor?.name,
|
|
84
|
+
where: WHERE,
|
|
85
|
+
scope: this.name,
|
|
86
|
+
});
|
|
77
87
|
}
|
|
78
88
|
return this;
|
|
79
89
|
}
|
|
80
90
|
onChange(fn) {
|
|
81
|
-
assertFunction(fn, () => optFn({ where: WHERE, scope: this.name, method:
|
|
91
|
+
assertFunction(fn, () => optFn({ where: WHERE, scope: this.name, method: "onChange" }));
|
|
82
92
|
if (!Array.isArray(this._onChangeList)) {
|
|
83
93
|
this._onChangeList = [];
|
|
84
94
|
}
|
|
@@ -86,30 +96,35 @@ export class EnvScopeImpl {
|
|
|
86
96
|
return this;
|
|
87
97
|
}
|
|
88
98
|
onSet(fn) {
|
|
89
|
-
assertFunction(fn, () => optFn({ where: WHERE, scope: this.name, method:
|
|
99
|
+
assertFunction(fn, () => optFn({ where: WHERE, scope: this.name, method: "onSet" }));
|
|
90
100
|
this._onSet = fn;
|
|
91
101
|
return this;
|
|
92
102
|
}
|
|
93
103
|
onOta(fn) {
|
|
94
|
-
assertFunction(fn, () => optFn({ where: WHERE, scope: this.name, method:
|
|
104
|
+
assertFunction(fn, () => optFn({ where: WHERE, scope: this.name, method: "onOta" }));
|
|
95
105
|
this._onOta = fn;
|
|
96
106
|
return this;
|
|
97
107
|
}
|
|
98
108
|
// endregion configure
|
|
99
109
|
// region runtime
|
|
100
110
|
getField(name) {
|
|
101
|
-
assertText(name, () => optFn({ where: WHERE, scope: this.name, method:
|
|
111
|
+
assertText(name, () => optFn({ where: WHERE, scope: this.name, method: "getField" }));
|
|
102
112
|
if (!this._fields.has(name)) {
|
|
103
|
-
throw new EnvironmentError(
|
|
113
|
+
throw new EnvironmentError("field.not.found", `Field[${name}] could not found`, {
|
|
114
|
+
where: WHERE,
|
|
115
|
+
scope: this.name,
|
|
116
|
+
method: "getField",
|
|
117
|
+
field: name,
|
|
118
|
+
});
|
|
104
119
|
}
|
|
105
120
|
return this._fields.get(name);
|
|
106
121
|
}
|
|
107
122
|
hasField(name) {
|
|
108
|
-
assertText(name, () => optFn({ where: WHERE, scope: this.name, method:
|
|
123
|
+
assertText(name, () => optFn({ where: WHERE, scope: this.name, method: "hasField" }));
|
|
109
124
|
return this._fields.has(name);
|
|
110
125
|
}
|
|
111
126
|
hasUse(name) {
|
|
112
|
-
assertText(name, () => optFn({ where: WHERE, scope: this.name, method:
|
|
127
|
+
assertText(name, () => optFn({ where: WHERE, scope: this.name, method: "hasUse" }));
|
|
113
128
|
return this._uses.has(name);
|
|
114
129
|
}
|
|
115
130
|
validUse(name) {
|
|
@@ -128,8 +143,7 @@ export class EnvScopeImpl {
|
|
|
128
143
|
this.read();
|
|
129
144
|
this._valueFull = {};
|
|
130
145
|
this._valueShort = {};
|
|
131
|
-
Array.from(this._fields.values())
|
|
132
|
-
.forEach(field => {
|
|
146
|
+
Array.from(this._fields.values()).forEach((field) => {
|
|
133
147
|
this._valueFull[field.full] = field.value;
|
|
134
148
|
this._valueShort[field.name] = field.value;
|
|
135
149
|
});
|
|
@@ -184,10 +198,10 @@ export class EnvScopeImpl {
|
|
|
184
198
|
}
|
|
185
199
|
}
|
|
186
200
|
if (changedAny && this._onOta) {
|
|
187
|
-
enveloper.handle(() => this._onOta(this), (e) => logger.warn(
|
|
201
|
+
enveloper.handle(() => this._onOta(this), (e) => logger.warn("OnOta Error", {
|
|
188
202
|
caused: { name: e.name, message: e.message },
|
|
189
203
|
where: WHERE,
|
|
190
|
-
scope: this.name
|
|
204
|
+
scope: this.name,
|
|
191
205
|
}));
|
|
192
206
|
}
|
|
193
207
|
}
|
|
@@ -200,27 +214,26 @@ export class EnvScopeImpl {
|
|
|
200
214
|
}
|
|
201
215
|
this._run = true;
|
|
202
216
|
let changedAny = false;
|
|
203
|
-
Array.from(this._fields.values())
|
|
204
|
-
.forEach(ins => {
|
|
217
|
+
Array.from(this._fields.values()).forEach((ins) => {
|
|
205
218
|
if (ins.read()) {
|
|
206
219
|
changedAny = true;
|
|
207
220
|
}
|
|
208
221
|
});
|
|
209
222
|
if (changedAny && this._onChangeList) {
|
|
210
223
|
this._onChangeList.forEach((fn, index) => {
|
|
211
|
-
enveloper.handle(() => fn(this), (e) => logger.warn(
|
|
224
|
+
enveloper.handle(() => fn(this), (e) => logger.warn("OnChange Error", {
|
|
212
225
|
caused: { name: e.name, message: e.message },
|
|
213
226
|
where: WHERE,
|
|
214
227
|
scope: this.name,
|
|
215
|
-
index
|
|
228
|
+
index,
|
|
216
229
|
}));
|
|
217
230
|
});
|
|
218
231
|
}
|
|
219
232
|
if (this._onSet) {
|
|
220
|
-
enveloper.handle(() => this._onSet(this), (e) => logger.warn(
|
|
233
|
+
enveloper.handle(() => this._onSet(this), (e) => logger.warn("OnSet Error", {
|
|
221
234
|
caused: { name: e.name, message: e.message },
|
|
222
235
|
where: WHERE,
|
|
223
|
-
scope: this.name
|
|
236
|
+
scope: this.name,
|
|
224
237
|
}));
|
|
225
238
|
}
|
|
226
239
|
}
|
|
@@ -229,8 +242,7 @@ export class EnvScopeImpl {
|
|
|
229
242
|
if (this._uses.size > 0) {
|
|
230
243
|
rec.uses = this.useList;
|
|
231
244
|
}
|
|
232
|
-
rec.fields = Array.from(this._fields.values())
|
|
233
|
-
.map(field => field.print());
|
|
245
|
+
rec.fields = Array.from(this._fields.values()).map((field) => field.print());
|
|
234
246
|
return rec;
|
|
235
247
|
}
|
|
236
248
|
$addOta(name) {
|
|
@@ -251,15 +263,24 @@ export class EnvScopeImpl {
|
|
|
251
263
|
}
|
|
252
264
|
_getVariationName(variation) {
|
|
253
265
|
if (this.variation) {
|
|
254
|
-
throw new EnvironmentError(
|
|
266
|
+
throw new EnvironmentError("scope.already.varied", `Scope is already varied`, {
|
|
267
|
+
value: this.name,
|
|
268
|
+
where: WHERE,
|
|
269
|
+
method: "newVariation",
|
|
270
|
+
variation,
|
|
271
|
+
});
|
|
255
272
|
}
|
|
256
|
-
assertText(variation, () => optFn({ where: WHERE, scope: this.name, method:
|
|
273
|
+
assertText(variation, () => optFn({ where: WHERE, scope: this.name, method: "newVariation", field: "variation" }));
|
|
257
274
|
return `${this.name}#${variation}`;
|
|
258
275
|
}
|
|
259
276
|
newVariation(variation) {
|
|
260
277
|
const name = this._getVariationName(variation);
|
|
261
278
|
if (this.core.hasScope(name)) {
|
|
262
|
-
|
|
279
|
+
new EnvironmentError("scope.duplicated", `Scope[${name}] is duplicated`, {
|
|
280
|
+
value: name,
|
|
281
|
+
where: WHERE,
|
|
282
|
+
method: "newVariation",
|
|
283
|
+
}).log();
|
|
263
284
|
}
|
|
264
285
|
return new EnvScopeImpl(this.core, name, this.prefix, variation);
|
|
265
286
|
}
|
|
@@ -272,33 +293,33 @@ export class EnvScopeImpl {
|
|
|
272
293
|
}
|
|
273
294
|
finish() {
|
|
274
295
|
if (this.variation) {
|
|
275
|
-
throw new EnvironmentError(
|
|
296
|
+
throw new EnvironmentError("varied.scope.does.not.support", `Scope[${this.name}] does not support finish operation`, { scope: this.name, where: WHERE, method: "finish" });
|
|
276
297
|
}
|
|
277
|
-
if (this._state ===
|
|
298
|
+
if (this._state === "started") {
|
|
278
299
|
this.read();
|
|
279
|
-
this._state =
|
|
300
|
+
this._state = "completed";
|
|
280
301
|
}
|
|
281
302
|
else {
|
|
282
|
-
logger.warn(
|
|
303
|
+
logger.warn("Unexpected end of configure", {
|
|
283
304
|
state: this._state,
|
|
284
305
|
scope: this.name,
|
|
285
|
-
where: WHERE
|
|
306
|
+
where: WHERE,
|
|
286
307
|
});
|
|
287
308
|
}
|
|
288
309
|
return this;
|
|
289
310
|
}
|
|
290
311
|
start() {
|
|
291
312
|
if (this.variation) {
|
|
292
|
-
throw new EnvironmentError(
|
|
313
|
+
throw new EnvironmentError("varied.scope.does.not.support", `Scope[${this.name}] does not support start operation`, { scope: this.name, where: WHERE, method: "finish" });
|
|
293
314
|
}
|
|
294
|
-
if (this._state ===
|
|
295
|
-
this._state =
|
|
315
|
+
if (this._state === "pending") {
|
|
316
|
+
this._state = "started";
|
|
296
317
|
}
|
|
297
318
|
else {
|
|
298
|
-
logger.warn(
|
|
319
|
+
logger.warn("Unexpected begin of configure", {
|
|
299
320
|
state: this._state,
|
|
300
321
|
scope: this.name,
|
|
301
|
-
where: WHERE
|
|
322
|
+
where: WHERE,
|
|
302
323
|
});
|
|
303
324
|
}
|
|
304
325
|
return this;
|
package/dist/scope/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from "./index.types.js";
|
package/dist/scope/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from "./index.types.js";
|
|
@@ -6,14 +6,14 @@ import { EnvFieldConfigure, EnvFieldPrint, EnvFieldRuntime } from "../field/inde
|
|
|
6
6
|
* Generics:
|
|
7
7
|
* - V: name part
|
|
8
8
|
* */
|
|
9
|
-
export type EnvNameBefore<V extends string | undefined> = V extends undefined ?
|
|
9
|
+
export type EnvNameBefore<V extends string | undefined> = V extends undefined ? "" : `_${V}`;
|
|
10
10
|
/**
|
|
11
11
|
* Environment mapped type for appending underscore after name part
|
|
12
12
|
*
|
|
13
13
|
* Generics:
|
|
14
14
|
* - V: name part
|
|
15
15
|
* */
|
|
16
|
-
export type EnvNameAfter<V extends string | undefined> = V extends undefined ?
|
|
16
|
+
export type EnvNameAfter<V extends string | undefined> = V extends undefined ? "" : `${V}_`;
|
|
17
17
|
/**
|
|
18
18
|
* Environment mapped type for appending underscore after name part
|
|
19
19
|
*
|
|
@@ -343,4 +343,4 @@ export interface EnvScopePrint {
|
|
|
343
343
|
* - started: after #start()
|
|
344
344
|
* - completed: after #finish()
|
|
345
345
|
* */
|
|
346
|
-
export type EnvScopeState =
|
|
346
|
+
export type EnvScopeState = "pending" | "started" | "completed";
|
package/dist/server.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leyyo/env",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.12",
|
|
4
4
|
"description": "Environment library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"env",
|
|
@@ -22,38 +22,38 @@
|
|
|
22
22
|
"scripts": {
|
|
23
23
|
"clear": "rimraf dist",
|
|
24
24
|
"lint": "eslint src/**/*.ts",
|
|
25
|
+
"lint:fix": "eslint src/**/*.ts --fix",
|
|
26
|
+
"format": "prettier --check \"{src,test}/**/*.{ts,tsx,js}\"",
|
|
27
|
+
"format:force": "prettier --write \"{src,test}/**/*.{ts,tsx,js}\"",
|
|
28
|
+
"test": "vitest run",
|
|
29
|
+
"test:watch": "vitest",
|
|
30
|
+
"test:coverage": "vitest run --coverage",
|
|
25
31
|
"asset": "node -r ts-node/register commands/assets.js",
|
|
26
32
|
"build": "npm run clear && tsc && npm run asset",
|
|
27
|
-
"
|
|
28
|
-
"test:watch": "jest --watch --config=jest.json",
|
|
29
|
-
"test:coverage": "jest --config=jest.json --coverage --coverageDirectory=coverage",
|
|
30
|
-
"~publish": "npm run build && npm publish -access=public"
|
|
33
|
+
"publish:public": "npm run lint && npm run format:force && npm run test && npm run build && npm publish --access=public"
|
|
31
34
|
},
|
|
32
35
|
"files": [
|
|
33
36
|
"dist/*"
|
|
34
37
|
],
|
|
35
38
|
"license": "ISC",
|
|
36
39
|
"devDependencies": {
|
|
37
|
-
"@
|
|
38
|
-
"@types/
|
|
39
|
-
"@
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"eslint": "^
|
|
43
|
-
"
|
|
44
|
-
"eslint-plugin-jsdoc": "^50.6.9",
|
|
45
|
-
"eslint-plugin-node": "^11.1.0",
|
|
46
|
-
"jest": "^29.7.0",
|
|
47
|
-
"prettier": "^3.5.3",
|
|
40
|
+
"@eslint/js": "^9.0.0",
|
|
41
|
+
"@types/node": "^24.2.1",
|
|
42
|
+
"@vitest/coverage-istanbul": "^4.0.18",
|
|
43
|
+
"eslint": "^9.0.0",
|
|
44
|
+
"eslint-config-prettier": "^10.1.8",
|
|
45
|
+
"eslint-plugin-n": "^17.24.0",
|
|
46
|
+
"prettier": "^3.8.1",
|
|
48
47
|
"rimraf": "^6.0.1",
|
|
49
|
-
"ts-
|
|
50
|
-
"
|
|
51
|
-
"typescript": "^
|
|
48
|
+
"ts-node": "^10.9.2",
|
|
49
|
+
"typescript": "^5.9.3",
|
|
50
|
+
"typescript-eslint": "^8.0.0",
|
|
51
|
+
"vitest": "^4.0.18"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@leyyo/assert": "^1.3.
|
|
55
|
-
"@leyyo/common": "^1.3.
|
|
56
|
-
"@leyyo/enveloper": "^1.3.
|
|
57
|
-
"@leyyo/type": "^1.3.
|
|
54
|
+
"@leyyo/assert": "^1.3.5",
|
|
55
|
+
"@leyyo/common": "^1.3.21",
|
|
56
|
+
"@leyyo/enveloper": "^1.3.6",
|
|
57
|
+
"@leyyo/type": "^1.3.10"
|
|
58
58
|
}
|
|
59
59
|
}
|