@leyyo/env 1.3.8 → 1.3.11

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 (44) hide show
  1. package/dist/core/env-core.impl.d.ts +1 -1
  2. package/dist/core/env-core.impl.js +32 -68
  3. package/dist/core/environment.error.js +3 -8
  4. package/dist/core/index.d.ts +3 -3
  5. package/dist/core/index.js +3 -20
  6. package/dist/core/index.types.d.ts +2 -2
  7. package/dist/core/index.types.js +1 -3
  8. package/dist/field/env-field.impl.d.ts +5 -4
  9. package/dist/field/env-field.impl.js +98 -78
  10. package/dist/field/index.d.ts +1 -1
  11. package/dist/field/index.js +1 -18
  12. package/dist/field/index.types.d.ts +4 -3
  13. package/dist/field/index.types.js +1 -3
  14. package/dist/index.d.ts +5 -5
  15. package/dist/index.foretell.d.ts +1 -1
  16. package/dist/index.foretell.js +13 -48
  17. package/dist/index.js +5 -22
  18. package/dist/index.loader.js +10 -46
  19. package/dist/internal.d.ts +1 -1
  20. package/dist/internal.js +2 -5
  21. package/dist/scope/env-scope.impl.d.ts +3 -3
  22. package/dist/scope/env-scope.impl.js +47 -41
  23. package/dist/scope/index.d.ts +1 -1
  24. package/dist/scope/index.js +1 -18
  25. package/dist/scope/index.types.d.ts +2 -2
  26. package/dist/scope/index.types.js +1 -3
  27. package/dist/server.js +2 -5
  28. package/package.json +7 -6
  29. package/dist/assets/.gitkeep +0 -0
  30. package/dist/core/env-core.impl.js.map +0 -1
  31. package/dist/core/environment.error.js.map +0 -1
  32. package/dist/core/index.js.map +0 -1
  33. package/dist/core/index.types.js.map +0 -1
  34. package/dist/field/env-field.impl.js.map +0 -1
  35. package/dist/field/index.js.map +0 -1
  36. package/dist/field/index.types.js.map +0 -1
  37. package/dist/index.foretell.js.map +0 -1
  38. package/dist/index.js.map +0 -1
  39. package/dist/index.loader.js.map +0 -1
  40. package/dist/internal.js.map +0 -1
  41. package/dist/scope/env-scope.impl.js.map +0 -1
  42. package/dist/scope/index.js.map +0 -1
  43. package/dist/scope/index.types.js.map +0 -1
  44. package/dist/server.js.map +0 -1
@@ -1,2 +1,2 @@
1
- import { EnvCoreRuntime } from "./index.types";
1
+ import { EnvCoreRuntime } from "./index.types.js";
2
2
  export declare const envCore: EnvCoreRuntime;
@@ -1,76 +1,41 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.envCore = void 0;
37
- const internal_1 = require("../internal");
38
- const env_scope_impl_1 = require("../scope/env-scope.impl");
39
- const util = __importStar(require("node:util"));
40
- const environment_error_1 = require("./environment.error");
41
- const type_1 = require("@leyyo/type");
42
- const common_1 = require("@leyyo/common");
43
- const WHERE = `${internal_1.FQN}.EnvCore`;
1
+ import { FQN } from "../internal.js";
2
+ import { EnvScopeImpl } from "../scope/env-scope.impl.js";
3
+ import * as util from "node:util";
4
+ import { EnvironmentError } from "./environment.error.js";
5
+ import { isBareObject } from "@leyyo/type";
6
+ import { isFilledObj, optFn, repoCommon, setFqn } from "@leyyo/common";
7
+ import { assertText } from "@leyyo/assert";
8
+ const WHERE = `${FQN}.EnvCore`;
44
9
  /**
45
10
  * Environment core class
46
11
  * */
47
12
  class EnvCoreImpl {
13
+ // region property
14
+ /**
15
+ * Stores scopes with name
16
+ * */
17
+ _scopes = repoCommon.newMap(`${FQN}.scopes`); // scope name x scope instance
18
+ /**
19
+ * Stores fields with full name
20
+ * */
21
+ _keys = repoCommon.newMap(`${FQN}.keys`); // field name x scope name[]
48
22
  // endregion property
49
23
  constructor() {
50
- // region property
51
- /**
52
- * Stores scopes with name
53
- * */
54
- this._scopes = common_1.repoCommon.newMap(`${internal_1.FQN}.scopes`); // scope name x scope instance
55
- /**
56
- * Stores fields with full name
57
- * */
58
- this._keys = common_1.repoCommon.newMap(`${internal_1.FQN}.keys`); // field name x scope name[]
59
24
  }
60
25
  // region configure
61
26
  /** @inheritDoc */
62
27
  scope(name, prefix) {
63
- (0, type_1.assertText)(name, () => (0, common_1.optFn)({ field: 'name', where: WHERE, method: 'scope' }));
28
+ assertText(name, () => optFn({ field: 'name', where: WHERE, method: 'scope' }));
64
29
  if (this._scopes.has(name)) {
65
- throw new environment_error_1.EnvironmentError('scope.duplicated', `Scope[${name}] is duplicated`, { value: name, where: WHERE, method: 'scope' });
30
+ throw new EnvironmentError('scope.duplicated', `Scope[${name}] is duplicated`, { value: name, where: WHERE, method: 'scope' });
66
31
  }
67
32
  if (prefix) {
68
- (0, type_1.assertText)(prefix, () => (0, common_1.optFn)({ where: WHERE, scope: name, method: 'scope', field: 'prefix' }));
33
+ assertText(prefix, () => optFn({ where: WHERE, scope: name, method: 'scope', field: 'prefix' }));
69
34
  }
70
35
  else {
71
36
  prefix = undefined;
72
37
  }
73
- const ins = new env_scope_impl_1.EnvScopeImpl(this, name, prefix, undefined);
38
+ const ins = new EnvScopeImpl(this, name, prefix, undefined);
74
39
  this._scopes.set(name, ins);
75
40
  return ins;
76
41
  }
@@ -78,28 +43,28 @@ class EnvCoreImpl {
78
43
  // region runtime
79
44
  /** @inheritDoc */
80
45
  getScope(name) {
81
- (0, type_1.assertText)(name, () => (0, common_1.optFn)({ field: 'scope', where: WHERE, method: 'getScope' }));
46
+ assertText(name, () => optFn({ field: 'scope', where: WHERE, method: 'getScope' }));
82
47
  if (!this._scopes.has(name)) {
83
- throw new environment_error_1.EnvironmentError('scope.not.found', `Scope[${name}] could not found`, { value: name, where: WHERE, method: 'getScope' });
48
+ throw new EnvironmentError('scope.not.found', `Scope[${name}] could not found`, { value: name, where: WHERE, method: 'getScope' });
84
49
  }
85
50
  return this._scopes.get(name);
86
51
  }
87
52
  /** @inheritDoc */
88
53
  hasScope(name) {
89
- (0, type_1.assertText)(name, () => (0, common_1.optFn)({ field: 'scope', where: WHERE, method: 'hasScope' }));
54
+ assertText(name, () => optFn({ field: 'scope', where: WHERE, method: 'hasScope' }));
90
55
  return this._scopes.has(name);
91
56
  }
92
57
  /** @inheritDoc */
93
58
  getKey(key) {
94
- (0, type_1.assertText)(key, () => (0, common_1.optFn)({ field: 'key', where: WHERE, method: 'getKey' }));
59
+ assertText(key, () => optFn({ field: 'key', where: WHERE, method: 'getKey' }));
95
60
  if (!this._keys.has(key)) {
96
- throw new environment_error_1.EnvironmentError('field.not.found', `Key[${key}] could not found`, { value: key, where: WHERE, method: 'getKey' });
61
+ throw new EnvironmentError('field.not.found', `Key[${key}] could not found`, { value: key, where: WHERE, method: 'getKey' });
97
62
  }
98
63
  return this._keys.get(key);
99
64
  }
100
65
  /** @inheritDoc */
101
66
  hasKey(key) {
102
- (0, type_1.assertText)(key, () => {
67
+ assertText(key, () => {
103
68
  return { field: key, where: WHERE, method: 'hasKey' };
104
69
  });
105
70
  return this._keys.has(key);
@@ -112,7 +77,7 @@ class EnvCoreImpl {
112
77
  get keys() {
113
78
  const doc = {};
114
79
  for (const [key, value] of this._keys.entries()) {
115
- doc[key] = Object.assign({}, value);
80
+ doc[key] = { ...value };
116
81
  }
117
82
  return doc;
118
83
  }
@@ -137,7 +102,7 @@ class EnvCoreImpl {
137
102
  }
138
103
  /** @inheritDoc */
139
104
  fromOta(values) {
140
- if ((0, type_1.isBareObject)(values) && (0, common_1.isFilledObj)(values)) {
105
+ if (isBareObject(values) && isFilledObj(values)) {
141
106
  const scopeMap = {};
142
107
  for (const [key, value] of Object.entries(values)) {
143
108
  if (this._keys.has(key)) {
@@ -163,10 +128,9 @@ class EnvCoreImpl {
163
128
  // region secure
164
129
  /** @inheritDoc */
165
130
  $addKey(key, field, alternative) {
166
- var _a;
167
131
  if (this._keys.has(key)) {
168
132
  const existing = this._keys.get(key);
169
- throw new Error(`Key[${key}] is duplicated! existing: ${existing.field.scope.name}${(_a = existing.alternative) !== null && _a !== void 0 ? _a : ''}, new: ${field.scope.name}${alternative !== null && alternative !== void 0 ? alternative : ''}`);
133
+ throw new Error(`Key[${key}] is duplicated! existing: ${existing.field.scope.name}${existing.alternative ?? ''}, new: ${field.scope.name}${alternative ?? ''}`);
170
134
  }
171
135
  this._keys.set(key, { field, alternative });
172
136
  }
@@ -185,5 +149,5 @@ class EnvCoreImpl {
185
149
  return this;
186
150
  }
187
151
  }
188
- exports.envCore = new EnvCoreImpl();
189
- //# sourceMappingURL=env-core.impl.js.map
152
+ setFqn(EnvCoreImpl, FQN);
153
+ export const envCore = new EnvCoreImpl();
@@ -1,19 +1,14 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EnvironmentError = void 0;
4
- const common_1 = require("@leyyo/common");
1
+ import { LeyyoError } from "@leyyo/common";
5
2
  /**
6
3
  * Environment error
7
4
  * */
8
- class EnvironmentError extends common_1.LeyyoError {
5
+ export class EnvironmentError extends LeyyoError {
9
6
  /**
10
7
  * @param {string} issue - error code or issue code
11
8
  * @param {string} message - error message
12
9
  * @param {Opt} params - error parameters
13
10
  * */
14
11
  constructor(issue, message, params) {
15
- super(message !== null && message !== void 0 ? message : issue, Object.assign(Object.assign({}, params), { issue }));
12
+ super(message ?? issue, { ...params, issue });
16
13
  }
17
14
  }
18
- exports.EnvironmentError = EnvironmentError;
19
- //# sourceMappingURL=environment.error.js.map
@@ -1,3 +1,3 @@
1
- export * from './index.types';
2
- export * from './env-core.impl';
3
- export * from './environment.error';
1
+ export * from './index.types.js';
2
+ export * from './env-core.impl.js';
3
+ export * from './environment.error.js';
@@ -1,20 +1,3 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./index.types"), exports);
18
- __exportStar(require("./env-core.impl"), exports);
19
- __exportStar(require("./environment.error"), exports);
20
- //# sourceMappingURL=index.js.map
1
+ export * from './index.types.js';
2
+ export * from './env-core.impl.js';
3
+ export * from './environment.error.js';
@@ -1,5 +1,5 @@
1
- import { EnvScopeConfigure, EnvScopePrint, EnvScopeRuntime } from "../scope";
2
- import { EnvFieldRuntime } from "../field";
1
+ import { EnvScopeConfigure, EnvScopePrint, EnvScopeRuntime } from "../scope/index.js";
2
+ import { EnvFieldRuntime } from "../field/index.js";
3
3
  /**
4
4
  * Environment base object
5
5
  * */
@@ -1,3 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=index.types.js.map
1
+ export {};
@@ -1,8 +1,9 @@
1
- import { EnvField, EnvFieldConfigure, EnvFieldDefault, EnvFieldEnabled, EnvFieldEnumeration, EnvFieldLambda, EnvFieldLiteral, EnvFieldPrint, EnvFieldRuntime, EnvFieldSecure } from "./index.types";
2
- import { EnvScopeConfigure, EnvScopeRuntime, EnvVariation, EnvVariationValue } from "../scope";
3
- import { EnvBase } from "../core";
1
+ import { EnvField, EnvFieldConfigure, EnvFieldDefault, EnvFieldEnabled, EnvFieldEnumeration, EnvFieldLambda, EnvFieldLiteral, EnvFieldPrint, EnvFieldRuntime, EnvFieldSecure } from "./index.types.js";
2
+ import { EnvScopeConfigure, EnvScopeRuntime, EnvVariation, EnvVariationValue } from "../scope/index.js";
3
+ import { EnvBase } from "../core/index.js";
4
4
  import { Enum, KeyValue, Literal } from "@leyyo/common";
5
- import { AssertBasicFn, ToLambda } from "@leyyo/type";
5
+ import { ToLambda } from "@leyyo/type";
6
+ import { AssertBasicFn } from "@leyyo/assert";
6
7
  export declare class EnvFieldImpl<C extends EnvBase = EnvBase, P extends string = string, A extends string = undefined, Z extends keyof C = keyof C> implements EnvField<C, P, A, Z> {
7
8
  readonly scope: EnvScopeRuntime<C, P, A>;
8
9
  readonly name: Z;
@@ -1,13 +1,35 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EnvFieldImpl = void 0;
4
- const internal_1 = require("../internal");
5
- const common_1 = require("@leyyo/common");
6
- const type_1 = require("@leyyo/type");
7
- const enveloper_1 = require("@leyyo/enveloper");
8
- const WHERE = `${internal_1.FQN}.EnvFieldImpl`;
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";
5
+ import { enveloper } from "@leyyo/enveloper";
6
+ const WHERE = `${FQN}.EnvFieldImpl`;
9
7
  const ENV = {};
10
- class EnvFieldImpl {
8
+ export class EnvFieldImpl {
9
+ scope;
10
+ name;
11
+ // region properties
12
+ _required;
13
+ _requiredFn;
14
+ _off;
15
+ _offFn;
16
+ _assert;
17
+ _cast;
18
+ _def;
19
+ _defFn;
20
+ _clone;
21
+ _secret;
22
+ _aliases;
23
+ _array;
24
+ _initialized;
25
+ _type;
26
+ _typeOpt;
27
+ _onOta;
28
+ _onChangeList;
29
+ _onSet;
30
+ _literalFn;
31
+ _enumFn;
32
+ full;
11
33
  // endregion properties
12
34
  constructor(scope, name) {
13
35
  this.scope = scope;
@@ -26,7 +48,7 @@ class EnvFieldImpl {
26
48
  }
27
49
  get _findRequired() {
28
50
  if (this._requiredFn) {
29
- return enveloper_1.enveloper.swallow(() => this._requiredFn(this.scope.valueShort, this.name, this.scope.name), false, true);
51
+ return enveloper.swallow(() => this._requiredFn(this.scope.valueShort, this.name, this.scope.name), false, true);
30
52
  }
31
53
  return this._required;
32
54
  }
@@ -39,32 +61,32 @@ class EnvFieldImpl {
39
61
  const nullable = !this._findRequired;
40
62
  switch (this._type) {
41
63
  case 'string':
42
- to1 = type_1.toStringValue;
64
+ to1 = toStringValue;
43
65
  break;
44
66
  case 'text':
45
- to1 = type_1.toTextValue;
67
+ to1 = toTextValue;
46
68
  break;
47
69
  case 'integer':
48
- to1 = type_1.toIntegerValue;
70
+ to1 = toIntegerValue;
49
71
  break;
50
72
  case 'float':
51
- to1 = type_1.toNumberValue;
73
+ to1 = toNumberValue;
52
74
  break;
53
75
  case 'boolean':
54
- to1 = type_1.toBooleanValue;
76
+ to1 = toBooleanValue;
55
77
  break;
56
78
  case 'literal':
57
- to1 = type_1.toLiteralValue;
79
+ to1 = toLiteralValue;
58
80
  break;
59
81
  case 'enumeration':
60
- to1 = type_1.toEnumValue;
82
+ to1 = toEnumValue;
61
83
  break;
62
84
  }
63
- const opt = Object.assign(Object.assign({}, this._devOne), { nullable });
85
+ const opt = { ...this._devOne, nullable };
64
86
  if (this._type === 'literal') {
65
87
  let items;
66
88
  if (this._literalFn) {
67
- items = enveloper_1.enveloper.swallow(() => this._literalFn(this.scope.valueShort, this.name, this.scope.name), ['none']);
89
+ items = enveloper.swallow(() => this._literalFn(this.scope.valueShort, this.name, this.scope.name), ['none']);
68
90
  }
69
91
  else {
70
92
  items = this._typeOpt;
@@ -74,7 +96,7 @@ class EnvFieldImpl {
74
96
  else if (this._type === 'enumeration') {
75
97
  let map;
76
98
  if (this._enumFn) {
77
- map = enveloper_1.enveloper.swallow(() => this._enumFn(this.scope.valueShort, this.name, this.scope.name), { none: 'none' });
99
+ map = enveloper.swallow(() => this._enumFn(this.scope.valueShort, this.name, this.scope.name), { none: 'none' });
78
100
  }
79
101
  else {
80
102
  map = this._typeOpt;
@@ -83,7 +105,7 @@ class EnvFieldImpl {
83
105
  }
84
106
  if (this._array) {
85
107
  opt.itemFn = to1;
86
- this.$cast((v, _o) => (0, type_1.toDelimitedValue)(v, opt));
108
+ this.$cast((v, _o) => toDelimitedValue(v, opt));
87
109
  }
88
110
  else {
89
111
  this.$cast(v => to1(v, opt));
@@ -92,13 +114,13 @@ class EnvFieldImpl {
92
114
  get _fromDef() {
93
115
  let val;
94
116
  if (this._defFn) {
95
- val = enveloper_1.enveloper.swallow(() => this._defFn(this.scope.valueShort, this.name, this.scope.name), undefined, true);
117
+ val = enveloper.swallow(() => this._defFn(this.scope.valueShort, this.name, this.scope.name), undefined, true);
96
118
  }
97
119
  else {
98
120
  val = this._def;
99
121
  }
100
122
  if (this._array) {
101
- if ((0, common_1.isEmpty)(val)) {
123
+ if (isEmpty(val)) {
102
124
  return [];
103
125
  }
104
126
  else if (Array.isArray(val)) {
@@ -107,7 +129,7 @@ class EnvFieldImpl {
107
129
  return [val];
108
130
  }
109
131
  else {
110
- return val !== null && val !== void 0 ? val : undefined;
132
+ return val ?? undefined;
111
133
  }
112
134
  }
113
135
  get _plainValue() {
@@ -118,7 +140,7 @@ class EnvFieldImpl {
118
140
  }
119
141
  return '';
120
142
  }
121
- return (0, common_1.isEmpty)(value) ? '' : value;
143
+ return isEmpty(value) ? '' : value;
122
144
  }
123
145
  // endregion private
124
146
  // region configure
@@ -128,7 +150,7 @@ class EnvFieldImpl {
128
150
  }
129
151
  else {
130
152
  const opt = { field: this._f, method: 'off', where: WHERE, scope: this.scope.name };
131
- (0, type_1.assertBoolean)(p1, opt);
153
+ assertBoolean(p1, opt);
132
154
  this._off = p1;
133
155
  }
134
156
  return this;
@@ -159,7 +181,7 @@ class EnvFieldImpl {
159
181
  }
160
182
  clone(name) {
161
183
  const opt = { field: this._f, method: 'clone', where: WHERE, scope: this.scope.name };
162
- (0, type_1.assertText)(name, opt);
184
+ assertText(name, opt);
163
185
  if (name === this._f) {
164
186
  logger.warn('Same field', opt);
165
187
  this._clone = undefined;
@@ -177,7 +199,7 @@ class EnvFieldImpl {
177
199
  def(value) {
178
200
  this._def = undefined;
179
201
  this._defFn = undefined;
180
- if (!(0, common_1.isEmpty)(value)) {
202
+ if (!isEmpty(value)) {
181
203
  if (typeof value === 'function') {
182
204
  this._defFn = value;
183
205
  }
@@ -193,11 +215,11 @@ class EnvFieldImpl {
193
215
  /** {@inheritDoc} */
194
216
  alias(...keys) {
195
217
  const opt = { field: this._f, method: 'aliases', where: WHERE, scope: this.scope.name };
196
- (0, type_1.assertArray)(keys, opt);
218
+ assertArray(keys, opt);
197
219
  if (keys.length > 0) {
198
220
  keys.forEach((key, index) => {
199
- const opt2 = Object.assign(Object.assign({}, opt), { field: `${this._f}[${index}]` });
200
- (0, type_1.assertText)(key, opt2);
221
+ const opt2 = { ...opt, field: `${this._f}[${index}]` };
222
+ assertText(key, opt2);
201
223
  if (key === this._f) {
202
224
  logger.warn('Same alias', opt2);
203
225
  }
@@ -259,7 +281,7 @@ class EnvFieldImpl {
259
281
  this._literalFn = p1;
260
282
  }
261
283
  else {
262
- (0, type_1.assertFilledArray)(p1, { field: this._f, method: 'literal', where: WHERE, scope: this.scope.name });
284
+ assertFilledArray(p1, { field: this._f, method: 'literal', where: WHERE, scope: this.scope.name });
263
285
  this._typeOpt = p1;
264
286
  }
265
287
  return this;
@@ -273,7 +295,7 @@ class EnvFieldImpl {
273
295
  this._enumFn = p1;
274
296
  }
275
297
  else {
276
- (0, type_1.assertFilledObject)(p1, { field: this._f, method: 'enumeration', where: WHERE, scope: this.scope.name });
298
+ assertFilledObject(p1, { field: this._f, method: 'enumeration', where: WHERE, scope: this.scope.name });
277
299
  this._typeOpt = p1;
278
300
  }
279
301
  return this;
@@ -281,13 +303,13 @@ class EnvFieldImpl {
281
303
  /** {@inheritDoc} */
282
304
  onOta(fn) {
283
305
  this.scope.$secure.$addOta(this.name);
284
- (0, type_1.assertFunction)(fn, { field: this._f, where: WHERE, scope: this.scope.name, method: 'ota' });
306
+ assertFunction(fn, { field: this._f, where: WHERE, scope: this.scope.name, method: 'ota' });
285
307
  this._onOta = fn;
286
308
  return this;
287
309
  }
288
310
  /** {@inheritDoc} */
289
311
  onChange(fn) {
290
- (0, type_1.assertFunction)(fn, { field: this._f, where: WHERE, scope: this.scope.name, method: 'onChange' });
312
+ assertFunction(fn, { field: this._f, where: WHERE, scope: this.scope.name, method: 'onChange' });
291
313
  if (!Array.isArray(this._onChangeList)) {
292
314
  this._onChangeList = [];
293
315
  }
@@ -296,19 +318,19 @@ class EnvFieldImpl {
296
318
  }
297
319
  /** {@inheritDoc} */
298
320
  onSet(fn) {
299
- (0, type_1.assertFunction)(fn, { field: this._f, where: WHERE, scope: this.scope.name, method: 'onSet' });
321
+ assertFunction(fn, { field: this._f, where: WHERE, scope: this.scope.name, method: 'onSet' });
300
322
  this._onSet = fn;
301
323
  return this;
302
324
  }
303
325
  /** {@inheritDoc} */
304
326
  cast(fn) {
305
- (0, type_1.assertFunction)(fn, { field: this._f, method: 'cast', where: WHERE, scope: this.scope.name });
327
+ assertFunction(fn, { field: this._f, method: 'cast', where: WHERE, scope: this.scope.name });
306
328
  this.$cast(fn);
307
329
  return this;
308
330
  }
309
331
  /** {@inheritDoc} */
310
332
  assert(fn) {
311
- (0, type_1.assertFunction)(fn, { field: this._f, method: 'cast', where: WHERE, scope: this.scope.name });
333
+ assertFunction(fn, { field: this._f, method: 'cast', where: WHERE, scope: this.scope.name });
312
334
  this.$assert(fn);
313
335
  return this;
314
336
  }
@@ -324,7 +346,6 @@ class EnvFieldImpl {
324
346
  this.read();
325
347
  }
326
348
  _printValue(value) {
327
- var _a, _b;
328
349
  if (value === undefined || value === null) {
329
350
  return undefined;
330
351
  }
@@ -335,11 +356,11 @@ class EnvFieldImpl {
335
356
  case "bigint":
336
357
  return value;
337
358
  case "object":
338
- return (0, common_1.secureJson)(value);
359
+ return secureJson(value);
339
360
  case "function":
340
- return `[fnc]${(_a = value.name) !== null && _a !== void 0 ? _a : '~lambda~'}[${value.length}]`;
361
+ return `[fnc]${value.name ?? '~lambda~'}[${value.length}]`;
341
362
  case "symbol":
342
- return `[sym]${(_b = value.description) !== null && _b !== void 0 ? _b : '~symbol~'}]`;
363
+ return `[sym]${value.description ?? '~symbol~'}]`;
343
364
  default:
344
365
  return undefined;
345
366
  }
@@ -403,7 +424,7 @@ class EnvFieldImpl {
403
424
  let offValue = this._off;
404
425
  if (offValue === undefined) {
405
426
  if (this._offFn) {
406
- offValue = enveloper_1.enveloper.swallow(() => this._offFn(this.scope.valueShort, this.name, this.scope.name), false);
427
+ offValue = enveloper.swallow(() => this._offFn(this.scope.valueShort, this.name, this.scope.name), false);
407
428
  }
408
429
  else {
409
430
  this._off = false;
@@ -414,34 +435,34 @@ class EnvFieldImpl {
414
435
  return false;
415
436
  }
416
437
  const old = this._plainValue;
417
- if (this._clone && !(0, common_1.isEmpty)(ENV[this._clone])) {
438
+ if (this._clone && !isEmpty(ENV[this._clone])) {
418
439
  this.set(ENV[this._clone]);
419
440
  }
420
- if ((0, common_1.isEmpty)(this.value) && Array.isArray(this._aliases)) {
441
+ if (isEmpty(this.value) && Array.isArray(this._aliases)) {
421
442
  for (const alias of this._aliases) {
422
- if (!(0, common_1.isEmpty)(ENV[alias])) {
443
+ if (!isEmpty(ENV[alias])) {
423
444
  this.set(ENV[alias]);
424
445
  break;
425
446
  }
426
447
  }
427
448
  }
428
- if ((0, common_1.isEmpty)(this.value)) {
449
+ if (isEmpty(this.value)) {
429
450
  this.$set(this._fromDef);
430
451
  }
431
452
  else if (this._cast) {
432
453
  this.$set(this._cast(this.value));
433
- if ((0, common_1.isEmpty)(this.value)) {
454
+ if (isEmpty(this.value)) {
434
455
  this.$set(this._fromDef);
435
456
  }
436
457
  }
437
- if (!(0, common_1.isEmpty)(this.value) && this._assert) {
458
+ if (!isEmpty(this.value) && this._assert) {
438
459
  this._assert(this.value, this._devOne);
439
460
  }
440
461
  this.scope.clear();
441
462
  const current = this._plainValue;
442
463
  if (this._onChangeList && current !== old) {
443
464
  this._onChangeList.forEach((fn, index) => {
444
- enveloper_1.enveloper.handle(() => fn(this.scope.valueShort, this.name, this.scope.name), (e) => logger.warn('On Change error', {
465
+ enveloper.handle(() => fn(this.scope.valueShort, this.name, this.scope.name), (e) => logger.warn('On Change error', {
445
466
  caused: { name: e.name, message: e.message },
446
467
  where: WHERE,
447
468
  scope: this.scope.name,
@@ -451,7 +472,7 @@ class EnvFieldImpl {
451
472
  });
452
473
  }
453
474
  if (this._onSet) {
454
- enveloper_1.enveloper.handle(() => this._onSet(this.scope.valueShort, this.name, this.scope.name), (e) => logger.warn('On set error', {
475
+ enveloper.handle(() => this._onSet(this.scope.valueShort, this.name, this.scope.name), (e) => logger.warn('On set error', {
455
476
  caused: { name: e.name, message: e.message },
456
477
  where: WHERE,
457
478
  scope: this.scope.name,
@@ -464,7 +485,7 @@ class EnvFieldImpl {
464
485
  fromOta(value) {
465
486
  this.$set(value);
466
487
  let changed = false;
467
- enveloper_1.enveloper.handle(() => {
488
+ enveloper.handle(() => {
468
489
  changed = this.read();
469
490
  }, e => {
470
491
  logger.warn('Ota run error', {
@@ -475,7 +496,7 @@ class EnvFieldImpl {
475
496
  });
476
497
  });
477
498
  if (changed && this._onOta) {
478
- enveloper_1.enveloper.handle(() => this._onOta(this.scope.valueShort, this.name, this.scope.name), e => logger.warn('Ota error', {
499
+ enveloper.handle(() => this._onOta(this.scope.valueShort, this.name, this.scope.name), e => logger.warn('Ota error', {
479
500
  caused: { name: e.name, message: e.message },
480
501
  where: WHERE,
481
502
  scope: this.scope.name,
@@ -517,32 +538,31 @@ class EnvFieldImpl {
517
538
  get $secure() {
518
539
  return this;
519
540
  }
520
- }
521
- exports.EnvFieldImpl = EnvFieldImpl;
522
- // endregion mode
523
- (() => {
524
- try {
525
- for (const [k, v] of Object.entries(process.env)) {
526
- // ignore empty string
527
- if (typeof v !== 'string' || v.trim()) {
528
- if (v === 'true') {
529
- ENV[k] = true;
530
- }
531
- else if (v === 'false') {
532
- ENV[k] = false;
533
- }
534
- else if (v === 'null') {
535
- ENV[k] = null;
536
- }
537
- else {
538
- ENV[k] = v;
541
+ // endregion mode
542
+ static {
543
+ try {
544
+ for (const [k, v] of Object.entries(process.env)) {
545
+ // ignore empty string
546
+ if (typeof v !== 'string' || v.trim()) {
547
+ if (v === 'true') {
548
+ ENV[k] = true;
549
+ }
550
+ else if (v === 'false') {
551
+ ENV[k] = false;
552
+ }
553
+ else if (v === 'null') {
554
+ ENV[k] = null;
555
+ }
556
+ else {
557
+ ENV[k] = v;
558
+ }
539
559
  }
540
560
  }
541
561
  }
562
+ catch (_e) {
563
+ // nothing
564
+ }
542
565
  }
543
- catch (_e) {
544
- // nothing
545
- }
546
- })();
547
- const logger = common_1.logCommon.of(EnvFieldImpl);
548
- //# sourceMappingURL=env-field.impl.js.map
566
+ }
567
+ setFqn(EnvFieldImpl, FQN);
568
+ const logger = logCommon.of(EnvFieldImpl);
@@ -1 +1 @@
1
- export * from './index.types';
1
+ export * from './index.types.js';