@leyyo/common 1.3.17 → 1.3.19

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 (146) hide show
  1. package/dist/base/index.d.ts +3 -3
  2. package/dist/base/index.js +3 -3
  3. package/dist/base/index.types.d.ts +3 -70
  4. package/dist/base/index.types.js +0 -32
  5. package/dist/base/leyyo.d.ts +0 -3
  6. package/dist/base/leyyo.js +12 -23
  7. package/dist/class/index.d.ts +2 -2
  8. package/dist/class/index.js +2 -2
  9. package/dist/class/index.types.d.ts +0 -20
  10. package/dist/class/list.d.ts +0 -6
  11. package/dist/class/list.js +0 -6
  12. package/dist/class/logger.instance.d.ts +8 -13
  13. package/dist/class/logger.instance.js +13 -27
  14. package/dist/common/deploy.common.d.ts +0 -16
  15. package/dist/common/deploy.common.js +4 -21
  16. package/dist/common/enum.pool.d.ts +5 -13
  17. package/dist/common/enum.pool.js +16 -17
  18. package/dist/common/error.common.d.ts +0 -30
  19. package/dist/common/error.common.js +33 -69
  20. package/dist/common/error.pool.d.ts +1 -10
  21. package/dist/common/error.pool.js +2 -13
  22. package/dist/common/event.common.d.ts +0 -8
  23. package/dist/common/event.common.js +15 -25
  24. package/dist/common/index.d.ts +11 -11
  25. package/dist/common/index.js +11 -11
  26. package/dist/common/index.types.d.ts +12 -435
  27. package/dist/common/index.types.js +0 -1
  28. package/dist/common/inert.d.ts +1 -49
  29. package/dist/common/inert.js +35 -64
  30. package/dist/common/lifecycle.common.d.ts +0 -14
  31. package/dist/common/lifecycle.common.js +13 -29
  32. package/dist/common/literal.pool.d.ts +1 -12
  33. package/dist/common/literal.pool.js +3 -18
  34. package/dist/common/log.common.d.ts +0 -54
  35. package/dist/common/log.common.js +62 -147
  36. package/dist/common/repo.common.d.ts +0 -188
  37. package/dist/common/repo.common.js +23 -239
  38. package/dist/const/index.d.ts +8 -12
  39. package/dist/const/index.js +28 -33
  40. package/dist/enum/index.d.ts +1 -1
  41. package/dist/enum/index.js +1 -1
  42. package/dist/enum/log-level.d.ts +1 -4
  43. package/dist/enum/log-level.js +1 -1
  44. package/dist/error/caused.error.d.ts +0 -10
  45. package/dist/error/caused.error.js +0 -10
  46. package/dist/error/developer.error.d.ts +4 -17
  47. package/dist/error/developer.error.js +11 -33
  48. package/dist/error/http.error.d.ts +0 -13
  49. package/dist/error/http.error.js +1 -8
  50. package/dist/error/index.d.ts +7 -7
  51. package/dist/error/index.js +7 -7
  52. package/dist/error/index.types.d.ts +1 -150
  53. package/dist/error/invalid-value.error.d.ts +0 -3
  54. package/dist/error/invalid-value.error.js +1 -4
  55. package/dist/error/leyyo.error.d.ts +2 -35
  56. package/dist/error/leyyo.error.js +26 -58
  57. package/dist/error/multiple.error.d.ts +0 -6
  58. package/dist/error/multiple.error.js +2 -9
  59. package/dist/function/define-loader.d.ts +0 -6
  60. package/dist/function/define-loader.js +0 -6
  61. package/dist/function/delay.d.ts +0 -8
  62. package/dist/function/delay.js +0 -9
  63. package/dist/function/delete-prop.d.ts +0 -21
  64. package/dist/function/delete-prop.js +6 -28
  65. package/dist/function/empty-fn.d.ts +0 -6
  66. package/dist/function/empty-fn.js +1 -9
  67. package/dist/function/extended-type.d.ts +0 -6
  68. package/dist/function/extended-type.js +18 -24
  69. package/dist/function/get-fqn.d.ts +0 -6
  70. package/dist/function/get-fqn.js +2 -8
  71. package/dist/function/get-prop.d.ts +0 -21
  72. package/dist/function/get-prop.js +5 -26
  73. package/dist/function/get-stat.d.ts +0 -20
  74. package/dist/function/get-stat.js +7 -2
  75. package/dist/function/has-fqn.d.ts +0 -6
  76. package/dist/function/has-fqn.js +2 -8
  77. package/dist/function/index.d.ts +40 -40
  78. package/dist/function/index.js +40 -40
  79. package/dist/function/index.types.d.ts +1 -1
  80. package/dist/function/is-anonymous-name.js +1 -1
  81. package/dist/function/is-class.d.ts +0 -6
  82. package/dist/function/is-class.js +2 -20
  83. package/dist/function/is-empty.d.ts +0 -11
  84. package/dist/function/is-empty.js +1 -12
  85. package/dist/function/is-filled-arr.d.ts +0 -9
  86. package/dist/function/is-filled-arr.js +0 -9
  87. package/dist/function/is-filled-obj.d.ts +0 -9
  88. package/dist/function/is-filled-obj.js +0 -9
  89. package/dist/function/is-obj.d.ts +0 -8
  90. package/dist/function/is-obj.js +1 -9
  91. package/dist/function/is-test.d.ts +0 -8
  92. package/dist/function/is-test.js +3 -19
  93. package/dist/function/is-text.d.ts +0 -10
  94. package/dist/function/is-text.js +1 -11
  95. package/dist/function/jitter-interval.d.ts +0 -9
  96. package/dist/function/jitter-interval.js +2 -18
  97. package/dist/function/load-config.d.ts +0 -19
  98. package/dist/function/load-config.js +10 -61
  99. package/dist/function/on-fqn-set.js +3 -3
  100. package/dist/function/one-or-more.d.ts +0 -6
  101. package/dist/function/one-or-more.js +0 -7
  102. package/dist/function/opt-add.d.ts +0 -8
  103. package/dist/function/opt-add.js +2 -10
  104. package/dist/function/opt-append.d.ts +0 -7
  105. package/dist/function/opt-append.js +0 -7
  106. package/dist/function/opt-check.d.ts +0 -6
  107. package/dist/function/opt-check.js +2 -9
  108. package/dist/function/opt-clone.d.ts +0 -6
  109. package/dist/function/opt-clone.js +0 -7
  110. package/dist/function/opt-field.d.ts +0 -8
  111. package/dist/function/opt-field.js +6 -14
  112. package/dist/function/opt-fn.d.ts +0 -6
  113. package/dist/function/opt-fn.js +0 -7
  114. package/dist/function/random-test-no.d.ts +0 -5
  115. package/dist/function/random-test-no.js +0 -5
  116. package/dist/function/remove-fqn.d.ts +0 -8
  117. package/dist/function/remove-fqn.js +3 -12
  118. package/dist/function/run-exporter.d.ts +0 -5
  119. package/dist/function/run-exporter.js +3 -17
  120. package/dist/function/secure-clone.js +3 -3
  121. package/dist/function/secure-json.d.ts +0 -35
  122. package/dist/function/secure-json.js +12 -54
  123. package/dist/function/set-anonymous-fqn.js +4 -5
  124. package/dist/function/set-anonymous-name.js +14 -14
  125. package/dist/function/set-fqn.d.ts +0 -7
  126. package/dist/function/set-fqn.js +8 -15
  127. package/dist/function/set-prop.d.ts +0 -24
  128. package/dist/function/set-prop.js +6 -30
  129. package/dist/function/stamp-loader.d.ts +0 -6
  130. package/dist/function/stamp-loader.js +1 -7
  131. package/dist/function/test-case.d.ts +0 -7
  132. package/dist/function/test-case.js +3 -10
  133. package/dist/function/test-name.d.ts +0 -7
  134. package/dist/function/test-name.js +2 -9
  135. package/dist/function/trigger-fqn.js +2 -3
  136. package/dist/index.d.ts +10 -10
  137. package/dist/index.foretell.js +7 -10
  138. package/dist/index.js +10 -11
  139. package/dist/index.loader.js +1 -8
  140. package/dist/init/index.js +5 -7
  141. package/dist/sys/index.d.ts +2 -2
  142. package/dist/sys/index.js +2 -2
  143. package/dist/sys/leyyo-storage.d.ts +0 -7
  144. package/dist/sys/leyyo-storage.js +5 -28
  145. package/dist/sys/package-json.js +5 -5
  146. package/package.json +16 -31
package/dist/index.d.ts CHANGED
@@ -7,13 +7,13 @@ export declare const literalPool: import("./common/index.types.js").LiteralPoolL
7
7
  export declare const lifecycleCommon: import("./common/index.types.js").LifecycleCommonLike;
8
8
  export declare const logCommon: import("./common/index.types.js").LogCommonLike;
9
9
  export declare const repoCommon: import("./common/index.types.js").RepoCommonLike;
10
- export * from './base/index.js';
11
- export * from './class/index.js';
12
- export * from './common/index.js';
13
- export * from './const/index.js';
14
- export * from './enum/index.js';
15
- export * from './error/index.js';
16
- export * from './function/index.js';
17
- export * from './sys/index.js';
18
- export * from './index.loader.js';
19
- export * from './index.foretell.js';
10
+ export * from "./base/index.js";
11
+ export * from "./class/index.js";
12
+ export * from "./common/index.js";
13
+ export * from "./const/index.js";
14
+ export * from "./enum/index.js";
15
+ export * from "./error/index.js";
16
+ export * from "./function/index.js";
17
+ export * from "./sys/index.js";
18
+ export * from "./index.loader.js";
19
+ export * from "./index.foretell.js";
@@ -1,14 +1,11 @@
1
1
  import { leyyo } from "./base/index.js";
2
2
  import { FQN } from "./internal.js";
3
- // noinspection JSUnusedGlobalSymbols
4
3
  export const foretell_leyyoCommon = [
5
- // errors
6
- () => leyyo.errorPool.lazy(FQN, 'CausedError', import('./error/caused.error.js').then(m => m.CausedError), { i18n: true, emit: true }),
7
- () => leyyo.errorPool.lazy(FQN, 'DeveloperError', import('./error/developer.error.js').then(m => m.DeveloperError), { i18n: true, emit: true }),
8
- () => leyyo.errorPool.lazy(FQN, 'HttpError', import('./error/http.error.js').then(m => m.HttpError), { i18n: true, emit: true }),
9
- () => leyyo.errorPool.lazy(FQN, 'InvalidValueError', import('./error/invalid-value.error.js').then(m => m.InvalidValueError), { i18n: true, emit: true }),
10
- () => leyyo.errorPool.lazy(FQN, 'LeyyoError', import('./error/leyyo.error.js').then(m => m.LeyyoError), { i18n: true, emit: false }),
11
- () => leyyo.errorPool.lazy(FQN, 'MultipleError', import('./error/multiple.error.js').then(m => m.MultipleError), { i18n: true, emit: true }),
12
- // enums
13
- () => leyyo.literalPool.lazy(FQN, 'LogLevel', import('./enum/log-level.js').then(m => m.LogLevelItems), { i18n: true }),
4
+ () => leyyo.errorPool.lazy(FQN, "CausedError", import("./error/caused.error.js").then((m) => m.CausedError), { i18n: true, emit: true }),
5
+ () => leyyo.errorPool.lazy(FQN, "DeveloperError", import("./error/developer.error.js").then((m) => m.DeveloperError), { i18n: true, emit: true }),
6
+ () => leyyo.errorPool.lazy(FQN, "HttpError", import("./error/http.error.js").then((m) => m.HttpError), { i18n: true, emit: true }),
7
+ () => leyyo.errorPool.lazy(FQN, "InvalidValueError", import("./error/invalid-value.error.js").then((m) => m.InvalidValueError), { i18n: true, emit: true }),
8
+ () => leyyo.errorPool.lazy(FQN, "LeyyoError", import("./error/leyyo.error.js").then((m) => m.LeyyoError), { i18n: true, emit: false }),
9
+ () => leyyo.errorPool.lazy(FQN, "MultipleError", import("./error/multiple.error.js").then((m) => m.MultipleError), { i18n: true, emit: true }),
10
+ () => leyyo.literalPool.lazy(FQN, "LogLevel", import("./enum/log-level.js").then((m) => m.LogLevelItems), { i18n: true }),
14
11
  ];
package/dist/index.js CHANGED
@@ -1,4 +1,3 @@
1
- // noinspection JSUnusedGlobalSymbols
2
1
  import { init } from "./init/index.js";
3
2
  import { leyyo } from "./base/index.js";
4
3
  import { setFqn } from "./function/index.js";
@@ -26,13 +25,13 @@ setFqn(logCommon.constructor, FQN);
26
25
  setFqn(repoCommon.constructor, FQN);
27
26
  setFqn(LoggerInstance, FQN);
28
27
  setFqn(List, FQN);
29
- export * from './base/index.js';
30
- export * from './class/index.js';
31
- export * from './common/index.js';
32
- export * from './const/index.js';
33
- export * from './enum/index.js';
34
- export * from './error/index.js';
35
- export * from './function/index.js';
36
- export * from './sys/index.js';
37
- export * from './index.loader.js';
38
- export * from './index.foretell.js';
28
+ export * from "./base/index.js";
29
+ export * from "./class/index.js";
30
+ export * from "./common/index.js";
31
+ export * from "./const/index.js";
32
+ export * from "./enum/index.js";
33
+ export * from "./error/index.js";
34
+ export * from "./function/index.js";
35
+ export * from "./sys/index.js";
36
+ export * from "./index.loader.js";
37
+ export * from "./index.foretell.js";
@@ -1,10 +1,3 @@
1
1
  import { defineLoader } from "./function/index.js";
2
2
  import { FQN } from "./internal.js";
3
- // noinspection JSUnusedGlobalSymbols
4
- export const loader_leyyoCommon = defineLoader(FQN,
5
- // errors
6
- () => import('./error/caused.error.js').then(m => m.CausedError), () => import('./error/developer.error.js').then(m => m.DeveloperError), () => import('./error/http.error.js').then(m => m.HttpError), () => import('./error/invalid-value.error.js').then(m => m.InvalidValueError), () => import('./error/leyyo.error.js').then(m => m.LeyyoError), () => import('./error/multiple.error.js').then(m => m.MultipleError),
7
- // enums
8
- () => import('./enum/log-level.js').then(m => m.LogLevelItems),
9
- // classes
10
- () => import('./class/list.js').then(m => m.List), () => import('./class/logger.instance.js').then(m => m.LoggerInstance));
3
+ export const loader_leyyoCommon = defineLoader(FQN, () => import("./error/caused.error.js").then((m) => m.CausedError), () => import("./error/developer.error.js").then((m) => m.DeveloperError), () => import("./error/http.error.js").then((m) => m.HttpError), () => import("./error/invalid-value.error.js").then((m) => m.InvalidValueError), () => import("./error/leyyo.error.js").then((m) => m.LeyyoError), () => import("./error/multiple.error.js").then((m) => m.MultipleError), () => import("./enum/log-level.js").then((m) => m.LogLevelItems), () => import("./class/list.js").then((m) => m.List), () => import("./class/logger.instance.js").then((m) => m.LoggerInstance));
@@ -1,20 +1,18 @@
1
1
  export function init() {
2
2
  if (global.console) {
3
- global.console['fatal'] = (...args) => console.error(...args);
3
+ global.console["fatal"] = (...args) => console.error(...args);
4
4
  }
5
5
  if (console) {
6
- console['fatal'] = (...args) => console.error(...args);
6
+ console["fatal"] = (...args) => console.error(...args);
7
7
  }
8
8
  if (global?.leyyo_is_testing) {
9
- ['log', 'debug', 'trace', 'info', 'warn', 'error', 'fatal'].forEach(name => {
9
+ ["log", "debug", "trace", "info", "warn", "error", "fatal"].forEach((name) => {
10
10
  if (global?.console) {
11
- global.console[name] = () => {
12
- };
11
+ global.console[name] = () => { };
13
12
  }
14
13
  if (console) {
14
+ console[name] = () => { };
15
15
  }
16
- console[name] = () => {
17
- };
18
16
  });
19
17
  }
20
18
  }
@@ -1,2 +1,2 @@
1
- export * from './package-json.js';
2
- export * from './leyyo-storage.js';
1
+ export * from "./package-json.js";
2
+ export * from "./leyyo-storage.js";
package/dist/sys/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export * from './package-json.js';
2
- export * from './leyyo-storage.js';
1
+ export * from "./package-json.js";
2
+ export * from "./leyyo-storage.js";
@@ -1,11 +1,4 @@
1
1
  type LeyyoStorage = Map<string, unknown>;
2
- /**
3
- * Local storage for leyyo platform
4
- * */
5
2
  export declare const leyyoStorage: LeyyoStorage;
6
- /**
7
- * @param {string} name - name of storage
8
- * @param {any} def - initial value
9
- * */
10
3
  export declare function getRootStorage<T>(name: string, def: T): T;
11
4
  export {};
@@ -1,18 +1,7 @@
1
- const _NAME = '$$leyyo.packages';
2
- /**
3
- * Create a standalone storage
4
- *
5
- * @return {LeyyoStorage}
6
- * */
1
+ const _NAME = "$$leyyo.packages";
7
2
  function _new() {
8
3
  return new Map();
9
4
  }
10
- /**
11
- * Get a global storage
12
- *
13
- * @param {any} source - `global` or `globalThis`
14
- * @return {LeyyoStorage}
15
- * */
16
5
  function _get(source) {
17
6
  if (!source) {
18
7
  return undefined;
@@ -23,11 +12,6 @@ function _get(source) {
23
12
  source[_NAME] = _new();
24
13
  return source[_NAME];
25
14
  }
26
- /**
27
- * Build storage
28
- *
29
- * @return {LeyyoStorage}
30
- * */
31
15
  function _build() {
32
16
  try {
33
17
  return _get(globalThis) ?? _get(global) ?? _new();
@@ -36,23 +20,16 @@ function _build() {
36
20
  return _new();
37
21
  }
38
22
  }
39
- /**
40
- * Local storage for leyyo platform
41
- * */
42
23
  export const leyyoStorage = _build();
43
- /**
44
- * @param {string} name - name of storage
45
- * @param {any} def - initial value
46
- * */
47
24
  export function getRootStorage(name, def) {
48
- if (typeof name !== 'string') {
49
- throw new Error('Invalid storage name', name);
25
+ if (typeof name !== "string") {
26
+ throw new Error("Invalid storage name", name);
50
27
  }
51
28
  if (leyyoStorage.has(name)) {
52
29
  return leyyoStorage.get(name);
53
30
  }
54
- if (!def || typeof def !== 'object') {
55
- throw new Error('Invalid storage value', def);
31
+ if (!def || typeof def !== "object") {
32
+ throw new Error("Invalid storage value", def);
56
33
  }
57
34
  leyyoStorage.set(name, def);
58
35
  return def;
@@ -3,15 +3,15 @@ import path from "node:path";
3
3
  import { dirname } from "path";
4
4
  import { fileURLToPath } from "url";
5
5
  import { getRootStorage } from "./leyyo-storage.js";
6
- const _NAME = '$$leyyo.packages';
7
- const _empty = { fqn: 'leyyo.unknown', name: '@leyyo/unknown', version: '0.0.0' };
6
+ const _NAME = "$$leyyo.packages";
7
+ const _empty = { fqn: "leyyo.unknown", name: "@leyyo/unknown", version: "0.0.0" };
8
8
  const _map = getRootStorage(_NAME, new Map());
9
9
  export function packageJson(url, full) {
10
10
  try {
11
11
  const __dirname = dirname(dirname(fileURLToPath(url)));
12
- const jsonPath = path.normalize(__dirname + '/package.json');
12
+ const jsonPath = path.normalize(__dirname + "/package.json");
13
13
  if (fs.existsSync(jsonPath)) {
14
- const jsonData = JSON.parse(fs.readFileSync(jsonPath, { encoding: 'utf-8', flag: 'r' }));
14
+ const jsonData = JSON.parse(fs.readFileSync(jsonPath, { encoding: "utf-8", flag: "r" }));
15
15
  if (jsonData) {
16
16
  if (!jsonData?.name) {
17
17
  return _empty;
@@ -30,7 +30,7 @@ export function packageJson(url, full) {
30
30
  _map.set(name, []);
31
31
  }
32
32
  _map.get(name).push(version);
33
- const fqn = jsonData?.name.split('/').join('.').split('@').join('');
33
+ const fqn = jsonData?.name.split("/").join(".").split("@").join("");
34
34
  if (full) {
35
35
  return { ...jsonData, fqn };
36
36
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leyyo/common",
3
- "version": "1.3.17",
3
+ "version": "1.3.19",
4
4
  "description": "Leyyo common library",
5
5
  "keywords": [
6
6
  "common"
@@ -20,52 +20,37 @@
20
20
  "scripts": {
21
21
  "clear": "rimraf dist",
22
22
  "lint": "eslint src/**/*.ts",
23
+ "lint:fix": "eslint src/**/*.ts --fix",
24
+ "format": "prettier --check \"{src,test}/**/*.{ts,tsx,js}\"",
25
+ "format:force": "prettier --write \"{src,test}/**/*.{ts,tsx,js}\"",
26
+ "test": "vitest run",
27
+ "test:watch": "vitest",
28
+ "test:coverage": "vitest run --coverage",
23
29
  "asset": "node -r ts-node/register commands/assets.js",
24
30
  "build": "npm run clear && tsc && npm run asset",
25
- "test": "npx jest --config=jest.json --clearCache && npx jest --config=jest.json --verbose",
26
- "test:watch": "jest --watch --config=jest.json",
27
- "test:coverage": "jest --config=jest.json --coverage --coverageDirectory=coverage",
28
- "~publish": "npm run build && npm publish -access=public"
31
+ "publish:public": "npm run lint && npm run format:force && npm run test && npm run build && npm publish --access=public"
29
32
  },
30
33
  "files": [
31
34
  "dist/*"
32
35
  ],
33
36
  "license": "ISC",
34
37
  "devDependencies": {
35
- "@babel/preset-env": "^7.29.0",
36
- "@babel/preset-typescript": "^7.27.0",
37
- "@eslint/js": "^9.33.0",
38
- "@jest/globals": "^29.7.0",
39
- "@types/jest": "^30.0.0",
38
+ "@eslint/js": "^9.0.0",
40
39
  "@types/js-yaml": "^4.0.9",
41
40
  "@types/node": "^24.2.1",
42
- "@types/node-localstorage": "^1.3.3",
43
- "@typescript-eslint/eslint-plugin": "^8.39.1",
44
- "@typescript-eslint/parser": "^8.39.1",
45
- "eslint": "^9.33.0",
41
+ "@vitest/coverage-istanbul": "^4.0.18",
42
+ "eslint": "^9.0.0",
46
43
  "eslint-config-prettier": "^10.1.8",
47
- "eslint-config-standard": "^17.1.0",
48
- "eslint-plugin-import": "^2.32.0",
49
- "eslint-plugin-jsdoc": "^54.0.0",
50
- "eslint-plugin-node": "^11.1.0",
51
- "husky": "^9.1.7",
52
- "jest": "^29.7.0",
53
- "prettier": "^3.6.2",
44
+ "eslint-plugin-n": "^17.24.0",
45
+ "prettier": "^3.8.1",
54
46
  "rimraf": "^6.0.1",
55
- "test": "^3.3.0",
56
- "ts-jest": "^29.4.1",
57
47
  "ts-node": "^10.9.2",
58
- "typescript": "^5.9.2",
59
- "typescript-eslint": "^8.39.1"
60
- },
61
- "overrides": {
62
- "eslint-config-standard": {
63
- "eslint": "^9.33.0"
64
- }
48
+ "typescript": "^5.9.3",
49
+ "typescript-eslint": "^8.0.0",
50
+ "vitest": "^4.0.18"
65
51
  },
66
52
  "dependencies": {
67
53
  "js-yaml": "^4.1.1",
68
- "node-localstorage": "^3.0.5",
69
54
  "stacktrace-parser": "^0.1.11"
70
55
  }
71
56
  }