@leyyo/common 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/dist/assertion/common-assertion-impl.d.ts +3 -4
  2. package/dist/assertion/common-assertion-impl.js +9 -8
  3. package/dist/assertion/index-types.d.ts +6 -22
  4. package/dist/assertion/index.d.ts +0 -1
  5. package/dist/assertion/index.js +0 -1
  6. package/dist/error/common-error-impl.d.ts +6 -4
  7. package/dist/error/common-error-impl.js +8 -4
  8. package/dist/error/index-types.d.ts +5 -52
  9. package/dist/error/index.d.ts +0 -5
  10. package/dist/error/index.js +0 -5
  11. package/dist/{error → exception}/assertion-exception.d.ts +1 -1
  12. package/dist/{error → exception}/caused-exception.d.ts +1 -1
  13. package/dist/{error → exception}/developer-exception.d.ts +1 -1
  14. package/dist/{error → exception}/exception.d.ts +4 -3
  15. package/dist/{error → exception}/exception.js +4 -4
  16. package/dist/exception/index-types.d.ts +30 -0
  17. package/dist/exception/index.d.ts +6 -0
  18. package/dist/exception/index.js +22 -0
  19. package/dist/fqn/common-fqn-impl.d.ts +18 -0
  20. package/dist/fqn/common-fqn-impl.js +121 -0
  21. package/dist/fqn/index-types.d.ts +9 -0
  22. package/dist/fqn/index-types.js +2 -0
  23. package/dist/fqn/index.d.ts +2 -0
  24. package/dist/{callback → fqn}/index.js +1 -1
  25. package/dist/hook/common-hook-impl.d.ts +30 -0
  26. package/dist/hook/common-hook-impl.js +111 -0
  27. package/dist/hook/index-types.d.ts +56 -0
  28. package/dist/hook/index-types.js +2 -0
  29. package/dist/hook/index.d.ts +2 -0
  30. package/dist/hook/index.js +18 -0
  31. package/dist/index.d.ts +11 -5
  32. package/dist/index.js +19 -6
  33. package/dist/is/common-is-impl.js +6 -6
  34. package/dist/is/index-types.d.ts +2 -3
  35. package/dist/leyyo/index-types.d.ts +4 -2
  36. package/dist/leyyo/leyyo-impl.d.ts +4 -2
  37. package/dist/leyyo/leyyo-impl.js +53 -30
  38. package/dist/literal/country-code.d.ts +8 -0
  39. package/dist/literal/country-code.js +17 -0
  40. package/dist/literal/environment.d.ts +8 -0
  41. package/dist/literal/environment.js +7 -0
  42. package/dist/literal/http-method.d.ts +8 -0
  43. package/dist/literal/http-method.js +7 -0
  44. package/dist/literal/http-place.d.ts +8 -0
  45. package/dist/literal/http-place.js +7 -0
  46. package/dist/literal/index-types.d.ts +6 -0
  47. package/dist/literal/index-types.js +2 -0
  48. package/dist/literal/index.d.ts +16 -0
  49. package/dist/literal/index.js +32 -0
  50. package/dist/literal/key-value.d.ts +4 -0
  51. package/dist/literal/key-value.js +7 -0
  52. package/dist/literal/language-code.d.ts +8 -0
  53. package/dist/literal/language-code.js +12 -0
  54. package/dist/literal/locale-code.d.ts +10 -0
  55. package/dist/literal/locale-code.js +17 -0
  56. package/dist/literal/primitive.d.ts +8 -0
  57. package/dist/literal/primitive.js +7 -0
  58. package/dist/literal/real-value.d.ts +8 -0
  59. package/dist/literal/real-value.js +7 -0
  60. package/dist/literal/severity.d.ts +8 -0
  61. package/dist/literal/severity.js +7 -0
  62. package/dist/literal/storage-type.d.ts +8 -0
  63. package/dist/literal/storage-type.js +7 -0
  64. package/dist/literal/sys-class.d.ts +2 -0
  65. package/dist/literal/sys-class.js +19 -0
  66. package/dist/literal/sys-function.d.ts +2 -0
  67. package/dist/literal/sys-function.js +6 -0
  68. package/dist/literal/weak-false.d.ts +8 -0
  69. package/dist/literal/weak-false.js +7 -0
  70. package/dist/literal/weak-true.d.ts +8 -0
  71. package/dist/literal/weak-true.js +7 -0
  72. package/dist/log/common-log-impl.d.ts +3 -2
  73. package/dist/log/common-log-impl.js +6 -6
  74. package/dist/log/index-types.d.ts +2 -52
  75. package/dist/log/index-types.js +0 -1
  76. package/dist/log/index.d.ts +1 -1
  77. package/dist/log/index.js +1 -1
  78. package/dist/log/logger-impl.d.ts +3 -4
  79. package/dist/log/logger-impl.js +11 -8
  80. package/dist/{assertion → shared}/assert.js +1 -0
  81. package/dist/{aliases.d.ts → shared/index-aliases.d.ts} +1 -1
  82. package/dist/{constants.d.ts → shared/index-constants.d.ts} +1 -0
  83. package/dist/{constants.js → shared/index-constants.js} +2 -1
  84. package/dist/shared/index-types.d.ts +142 -0
  85. package/dist/shared/index-types.js +3 -0
  86. package/dist/shared/index.d.ts +5 -0
  87. package/dist/shared/index.js +21 -0
  88. package/dist/storage/common-storage-impl.d.ts +3 -3
  89. package/dist/storage/common-storage-impl.js +3 -3
  90. package/dist/storage/index-types.d.ts +3 -13
  91. package/dist/storage/index.d.ts +0 -1
  92. package/dist/storage/index.js +0 -1
  93. package/dist/to/common-to-impl.d.ts +3 -3
  94. package/dist/to/common-to-impl.js +11 -11
  95. package/dist/to/index-types.d.ts +1 -30
  96. package/package.json +1 -1
  97. package/dist/callback/common-callback-impl.d.ts +0 -31
  98. package/dist/callback/common-callback-impl.js +0 -134
  99. package/dist/callback/index-types.d.ts +0 -73
  100. package/dist/callback/index.d.ts +0 -2
  101. package/dist/literals.d.ts +0 -106
  102. package/dist/literals.js +0 -81
  103. package/dist/{error → exception}/assertion-exception.js +0 -0
  104. package/dist/{error → exception}/caused-exception.js +0 -0
  105. package/dist/{error → exception}/developer-exception.js +0 -0
  106. package/dist/{callback → exception}/index-types.js +0 -0
  107. package/dist/{error → exception}/multiple-exception.d.ts +1 -1
  108. package/dist/{error → exception}/multiple-exception.js +0 -0
  109. package/dist/{assertion → shared}/assert.d.ts +1 -1
  110. /package/dist/{aliases.js → shared/index-aliases.js} +0 -0
  111. /package/dist/{storage → shared}/list.d.ts +0 -0
  112. /package/dist/{storage → shared}/list.js +0 -0
@@ -0,0 +1,21 @@
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-aliases"), exports);
18
+ __exportStar(require("./index-constants"), exports);
19
+ __exportStar(require("./index-types"), exports);
20
+ __exportStar(require("./assert"), exports);
21
+ __exportStar(require("./list"), exports);
@@ -1,7 +1,7 @@
1
- import { List } from "./list";
2
- import { CommonStorage, CommonStorageSecure, StorageDetail, StorageItem } from "./index-types";
1
+ import { List, StorageDetail, StorageItem } from "../shared";
2
+ import { CommonStorage, CommonStorageSecure } from "./index-types";
3
3
  import { Leyyo } from "../leyyo";
4
- import { StorageType } from "../literals";
4
+ import { StorageType } from "../literal";
5
5
  /** @inheritDoc */
6
6
  export declare class CommonStorageImpl implements CommonStorage, CommonStorageSecure {
7
7
  private readonly _lists;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CommonStorageImpl = void 0;
4
- const list_1 = require("./list");
5
- // noinspection JSUnusedLocalSymbols
4
+ const shared_1 = require("../shared");
5
+ // noinspection JSUnusedLocalSymbols,JSUnusedGlobalSymbols
6
6
  /** @inheritDoc */
7
7
  class CommonStorageImpl {
8
8
  /**
@@ -80,7 +80,7 @@ class CommonStorageImpl {
80
80
  // region list
81
81
  /** @inheritDoc */
82
82
  newList(name) {
83
- const list = new list_1.List();
83
+ const list = new shared_1.List();
84
84
  this._lists.set(name, list);
85
85
  return list;
86
86
  }
@@ -1,6 +1,5 @@
1
- import { List } from "./list";
2
- import { Dict, InitLike, ShiftMain, ShiftSecure } from "../aliases";
3
- import { StorageType } from "../literals";
1
+ import { InitLike, List, ShiftMain, ShiftSecure, StorageDetail } from "../shared";
2
+ import { StorageType } from "../literal";
4
3
  /**
5
4
  * Storage factory
6
5
  *
@@ -85,13 +84,4 @@ export interface CommonStorage extends ShiftSecure<CommonStorageSecure> {
85
84
  * */
86
85
  details(type?: StorageType, name?: string): StorageDetail;
87
86
  }
88
- export interface CommonStorageSecure extends ShiftMain<CommonStorage>, InitLike {
89
- }
90
- /**
91
- * Storage size dictionary which in corresponding type
92
- * */
93
- export type StorageItem = Dict<number>;
94
- /**
95
- * Storage export dictionary which includes items
96
- * */
97
- export type StorageDetail = Record<StorageType, StorageItem>;
87
+ export type CommonStorageSecure = ShiftMain<CommonStorage> & InitLike;
@@ -1,3 +1,2 @@
1
1
  export * from './index-types';
2
- export * from './list';
3
2
  export * from './common-storage-impl';
@@ -15,5 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./index-types"), exports);
18
- __exportStar(require("./list"), exports);
19
18
  __exportStar(require("./common-storage-impl"), exports);
@@ -1,5 +1,5 @@
1
- import { CommonTo, CommonToSecure, ToTypeArrayOpt, ToTypeEnumOpt, ToTypeObjectOpt, ToTypeOpt } from "./index-types";
2
- import { Dict, KeyValue, OneOrMore } from "../aliases";
1
+ import { CommonTo, CommonToSecure } from "./index-types";
2
+ import { Dict, KeyValue, OneOrMore, ToTypeArrayOpt, ToTypeEnumOpt, ToTypeObjectOpt, ToTypeOpt } from "../shared";
3
3
  import { Leyyo } from "../leyyo";
4
4
  export declare class CommonToImpl implements CommonTo, CommonToSecure {
5
5
  private readonly _EXPECTED_ANY;
@@ -11,7 +11,7 @@ export declare class CommonToImpl implements CommonTo, CommonToSecure {
11
11
  private readonly _EXPECTED_NUMBER;
12
12
  private readonly _EXPECTED_STRING;
13
13
  private is;
14
- private callback;
14
+ private fqn;
15
15
  private assertion;
16
16
  private _enumInMap;
17
17
  private _enumInArray;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CommonToImpl = void 0;
4
- const literals_1 = require("../literals");
5
- const error_1 = require("../error");
4
+ const literal_1 = require("../literal");
5
+ const exception_1 = require("../exception");
6
6
  // noinspection JSUnusedGlobalSymbols
7
7
  class CommonToImpl {
8
8
  constructor() {
@@ -137,7 +137,7 @@ class CommonToImpl {
137
137
  return fn(value);
138
138
  }
139
139
  catch (e) {
140
- error_1.Exception.cast(e).raise(!(opt === null || opt === void 0 ? void 0 : opt.silent));
140
+ exception_1.Exception.cast(e).raise(!(opt === null || opt === void 0 ? void 0 : opt.silent));
141
141
  }
142
142
  return null;
143
143
  }
@@ -150,7 +150,7 @@ class CommonToImpl {
150
150
  indicator = 'type.invalid-value';
151
151
  }
152
152
  opt = Object.assign(Object.assign(Object.assign({}, opt), params), { expected, value });
153
- new error_1.DeveloperException(indicator, opt)
153
+ new exception_1.DeveloperException(indicator, opt)
154
154
  .with(this)
155
155
  .raise(!(opt === null || opt === void 0 ? void 0 : opt.silent));
156
156
  return null;
@@ -201,7 +201,7 @@ class CommonToImpl {
201
201
  result.push(valueFn(v, clonedOpt));
202
202
  }
203
203
  catch (e) {
204
- error_1.Exception.cast(e).raise(!opt.silent);
204
+ exception_1.Exception.cast(e).raise(!opt.silent);
205
205
  result.push(null);
206
206
  }
207
207
  });
@@ -226,10 +226,10 @@ class CommonToImpl {
226
226
  if (value === '') {
227
227
  return null;
228
228
  }
229
- if (literals_1.WeakTrueItems.includes(value)) {
229
+ if (literal_1.WeakTrueItems.includes(value)) {
230
230
  return true;
231
231
  }
232
- if (literals_1.WeakFalseItems.includes(value)) {
232
+ if (literal_1.WeakFalseItems.includes(value)) {
233
233
  return false;
234
234
  }
235
235
  return this.raiseInvalidValue(value, this._EXPECTED_BOOL, opt);
@@ -258,7 +258,7 @@ class CommonToImpl {
258
258
  return value;
259
259
  case 'object':
260
260
  case 'function':
261
- return this.callback.fqnName(value);
261
+ return this.fqn.name(value);
262
262
  }
263
263
  return this.raiseInvalidValue(value, this._EXPECTED_CLASS, opt);
264
264
  }
@@ -314,7 +314,7 @@ class CommonToImpl {
314
314
  mapType = 'array';
315
315
  }
316
316
  if (!mapType) {
317
- throw new error_1.DeveloperException('type.invalid-enum-items', { map: opt.map });
317
+ throw new exception_1.DeveloperException('type.invalid-enum-items', { map: opt.map });
318
318
  }
319
319
  let v;
320
320
  switch (typeof value) {
@@ -475,7 +475,7 @@ class CommonToImpl {
475
475
  result[keyOpt.fn(k, keyOpt)] = valueOpt.fn(v, valueOpt);
476
476
  }
477
477
  catch (e) {
478
- error_1.Exception.cast(e).raise(!opt.silent);
478
+ exception_1.Exception.cast(e).raise(!opt.silent);
479
479
  result[k] = null;
480
480
  }
481
481
  }
@@ -540,7 +540,7 @@ class CommonToImpl {
540
540
  // region secure
541
541
  $init(leyyo) {
542
542
  this.is = leyyo.is;
543
- this.callback = leyyo.callback;
543
+ this.fqn = leyyo.fqn;
544
544
  this.assertion = leyyo.assertion;
545
545
  }
546
546
  get $back() {
@@ -1,5 +1,4 @@
1
- import { Dict, InitLike, KeyValue, OneOrMore, ShiftMain, ShiftSecure } from "../aliases";
2
- import { AssertionOpt } from "../assertion";
1
+ import { Dict, InitLike, KeyValue, OneOrMore, ShiftMain, ShiftSecure, ToTypeArrayOpt, ToTypeEnumOpt, ToTypeObjectOpt, ToTypeOpt } from "../shared";
3
2
  export interface CommonTo extends ShiftSecure<CommonToSecure> {
4
3
  runFn<T = unknown>(fn: Function, value: Function, opt?: ToTypeOpt): T;
5
4
  raiseInvalidValue<T = unknown>(value: unknown, expected: OneOrMore<string>, opt?: ToTypeOpt, params?: Dict): T;
@@ -19,31 +18,3 @@ export interface CommonTo extends ShiftSecure<CommonToSecure> {
19
18
  }
20
19
  export interface CommonToSecure extends ShiftMain<CommonTo>, InitLike {
21
20
  }
22
- export interface ToTypeOpt extends AssertionOpt {
23
- silent?: true;
24
- children?: unknown;
25
- }
26
- export type ToTypeFnLambda<T = unknown, O extends ToTypeOpt = ToTypeOpt> = (value: unknown, opt?: O) => T;
27
- export interface ToTypeChildOpt<T = unknown> extends ToTypeOpt {
28
- fn?: ToTypeFnLambda<T>;
29
- }
30
- export interface ToTypeArrayChildOpt<V extends ToTypeChildOpt = ToTypeChildOpt> extends Dict<ToTypeChildOpt> {
31
- value?: V;
32
- }
33
- export interface ToTypeArrayOpt<V extends ToTypeChildOpt = ToTypeChildOpt> extends ToTypeOpt {
34
- children?: ToTypeArrayChildOpt<V>;
35
- }
36
- export interface ToTypeDictChildOpt<K extends ToTypeChildOpt = ToTypeChildOpt, V extends ToTypeChildOpt = ToTypeChildOpt> extends Record<string, ToTypeChildOpt> {
37
- key?: K;
38
- value?: V;
39
- }
40
- export interface ToTypeObjectOpt<K extends ToTypeChildOpt = ToTypeChildOpt, V extends ToTypeChildOpt = ToTypeChildOpt> extends ToTypeOpt {
41
- children?: ToTypeDictChildOpt<K, V>;
42
- }
43
- export interface ToTypeEnumOpt<E extends KeyValue = KeyValue> extends ToTypeOpt {
44
- map: EnumerationMap<E> | EnumerationArray<E>;
45
- alt?: EnumerationAlt<E>;
46
- }
47
- export type EnumerationMap<E extends KeyValue = KeyValue> = Dict<E>;
48
- export type EnumerationAlt<E extends KeyValue = KeyValue> = Dict<E>;
49
- export type EnumerationArray<E extends KeyValue = KeyValue> = Array<E>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leyyo/common",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Common library",
5
5
  "keywords": [
6
6
  "common"
@@ -1,31 +0,0 @@
1
- import { Arr } from "../aliases";
2
- import { CallbackWhenDefinedLambda, CommonCallback, CommonCallbackDefined, CommonCallbackSecure } from "./index-types";
3
- import { Leyyo } from "../leyyo";
4
- export declare class CommonCallbackImpl implements CommonCallback, CommonCallbackSecure {
5
- private _waitingForCallbacks;
6
- private _attachedCallbacks;
7
- private _waitingForProviders;
8
- private _definedProviders;
9
- fqnName(value: any): string;
10
- /**
11
- * Default constructor
12
- *
13
- * Responsibilities
14
- * - Create repositories => ie: callbacks
15
- * - Trigger clear pending operation
16
- * */
17
- constructor();
18
- $init(leyyo: Leyyo): void;
19
- /**
20
- * Clear jobs in the queue which named as pending
21
- *
22
- * Because the expected callback may not be defined
23
- * */
24
- private _clearPending;
25
- get $secure(): CommonCallbackSecure;
26
- attachCallback(name: string, fn: Function): void;
27
- queueForCallback(name: string, ...args: Arr): boolean;
28
- get $back(): CommonCallback;
29
- whenProviderDefined<T extends CommonCallbackDefined = CommonCallbackDefined>(name: string, consumer: Function, callback: CallbackWhenDefinedLambda<T>): void;
30
- defineProvider<T extends CommonCallbackDefined = CommonCallbackDefined>(name: string, producer: Function, instance: T): void;
31
- }
@@ -1,134 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CommonCallbackImpl = void 0;
4
- const constants_1 = require("../constants");
5
- const error_1 = require("../error");
6
- const internal_1 = require("../internal");
7
- class CommonCallbackImpl {
8
- fqnName(value) {
9
- switch (typeof value) {
10
- case "function":
11
- return value.name;
12
- case "object":
13
- return value.constructor.name;
14
- case "string":
15
- return value;
16
- default:
17
- return null;
18
- }
19
- }
20
- /**
21
- * Default constructor
22
- *
23
- * Responsibilities
24
- * - Create repositories => ie: callbacks
25
- * - Trigger clear pending operation
26
- * */
27
- constructor() {
28
- // clear after 1 minute
29
- setTimeout(() => this._clearPending(), 60000);
30
- }
31
- $init(leyyo) {
32
- this._waitingForCallbacks = leyyo.storage.newMap(`${internal_1.FQN_PCK}/waitingForCallbacks`);
33
- this._attachedCallbacks = leyyo.storage.newMap(`${internal_1.FQN_PCK}/attachedCallbacks`);
34
- this._waitingForProviders = leyyo.storage.newMap(`${internal_1.FQN_PCK}/waitingForProviders`);
35
- this._definedProviders = leyyo.storage.newMap(`${internal_1.FQN_PCK}/definedProviders`);
36
- // define itself temporarily for fqn name
37
- this.defineProvider(constants_1.LY_ATTACHED_FQN, CommonCallbackImpl, {
38
- proper: false,
39
- name: this.fqnName,
40
- });
41
- // when new fqn provider is defined, replace temporary name method
42
- this.whenProviderDefined(constants_1.LY_ATTACHED_FQN, CommonCallbackImpl, (ins) => {
43
- if (typeof ins.name === 'function') {
44
- this.fqnName = ins.name;
45
- }
46
- });
47
- }
48
- /**
49
- * Clear jobs in the queue which named as pending
50
- *
51
- * Because the expected callback may not be defined
52
- * */
53
- _clearPending() {
54
- for (const [name,] of this._waitingForCallbacks.entries()) {
55
- const rec = this._attachedCallbacks.get(name);
56
- if (rec && !rec.initialization) {
57
- continue;
58
- }
59
- this._waitingForCallbacks.delete(name);
60
- console.log(`callback.cleared.pending => {name: ${name}}`);
61
- }
62
- }
63
- get $secure() {
64
- return this;
65
- }
66
- attachCallback(name, fn) {
67
- if (!name || typeof name !== 'string') {
68
- throw new Error(`callback.invalid.name => {type: ${typeof name}}`);
69
- }
70
- // callback attached
71
- this._attachedCallbacks.set(name, { fn });
72
- // check waiting records, to be called
73
- if (this._waitingForCallbacks.has(name)) {
74
- this._waitingForCallbacks.get(name).forEach(item => {
75
- fn(...item);
76
- });
77
- this._waitingForCallbacks.delete(name);
78
- }
79
- }
80
- queueForCallback(name, ...args) {
81
- if (!name || typeof name !== 'string') {
82
- throw new Error(`callback.invalid.name => {type: ${typeof name}}`);
83
- }
84
- // callback already exists
85
- if (this._attachedCallbacks.has(name)) {
86
- const rec = this._attachedCallbacks.get(name);
87
- rec.fn(...args);
88
- return true;
89
- }
90
- // callback does not exist yet, so wait to be attached
91
- if (this._waitingForCallbacks.has(name)) {
92
- this._waitingForCallbacks.get(name).push(args);
93
- }
94
- else {
95
- this._waitingForCallbacks.set(name, [args]);
96
- }
97
- return false;
98
- }
99
- get $back() {
100
- return undefined;
101
- }
102
- whenProviderDefined(name, consumer, callback) {
103
- if (!name || typeof name !== 'string') {
104
- throw new error_1.DeveloperException(`callback.invalid.name`, { type: typeof name });
105
- }
106
- if (!this._waitingForProviders.has(name)) {
107
- this._waitingForProviders.set(name, []);
108
- }
109
- if (this._definedProviders.has(name)) {
110
- const ins = this._definedProviders.get(name);
111
- if (ins.producer !== consumer) {
112
- callback(ins);
113
- }
114
- }
115
- this._waitingForProviders.get(name).push({ consumer, callback });
116
- }
117
- defineProvider(name, producer, instance) {
118
- if (!name || typeof name !== 'string') {
119
- throw new error_1.DeveloperException(`callback.invalid.name`, { type: typeof name });
120
- }
121
- const ins = Object.assign(Object.assign({}, instance), { producer });
122
- this._definedProviders.set(name, ins);
123
- if (instance.proper) {
124
- if (this._waitingForProviders.has(name)) {
125
- this._waitingForProviders.get(name).forEach(item => {
126
- if (item.consumer !== producer) {
127
- item.callback(instance);
128
- }
129
- });
130
- }
131
- }
132
- }
133
- }
134
- exports.CommonCallbackImpl = CommonCallbackImpl;
@@ -1,73 +0,0 @@
1
- import { Arr, InitLike, ShiftMain, ShiftSecure } from "../aliases";
2
- /**
3
- * Callback repository, it collects all jobs and fire them when callback is defined
4
- * */
5
- export interface CommonCallback extends ShiftSecure<CommonCallbackSecure> {
6
- /**
7
- * Attach a callback
8
- *
9
- * @param {string} name
10
- * @param {Function} fn
11
- *
12
- * Notes:
13
- * - name should be regular string
14
- * - After attached, it should call all waiting calls in the queue
15
- * */
16
- attachCallback(name: string, fn: Function): void;
17
- /**
18
- * Add a call into queue, which to be executed by appropriate callback
19
- *
20
- * @param {string} name
21
- * @param {Array<any>} args
22
- * @returns {boolean} - callback exists?
23
- *
24
- * Notes:
25
- * - name should be regular string
26
- * */
27
- queueForCallback(name: string, ...args: Arr): boolean;
28
- fqnName(value: any): string;
29
- /**
30
- * Informs when callback is changed
31
- *
32
- * @param {string} name
33
- * @param {Function} consumer
34
- * @param {CallbackWhenDefinedLambda} callback
35
- *
36
- * Notes:
37
- * - name should be regular string
38
- * - callback should be regular function
39
- * - name should not be already defined
40
- * */
41
- whenProviderDefined<T extends CommonCallbackDefined = CommonCallbackDefined>(name: string, consumer: Function, callback: CallbackWhenDefinedLambda<T>): void;
42
- /**
43
- * Defines a provider to replace temporary providers
44
- *
45
- * @param {string} name
46
- * @param {Function} producer
47
- * @param {Object} instance
48
- *
49
- * Notes:
50
- * - name should be regular string
51
- * */
52
- defineProvider<T extends CommonCallbackDefined = CommonCallbackDefined>(name: string, producer: Function, instance: T): void;
53
- }
54
- export interface CommonCallbackSecure extends ShiftMain<CommonCallback>, InitLike {
55
- }
56
- export interface CallbackRec {
57
- initialization?: true;
58
- fn: Function;
59
- }
60
- export interface CommonCallbackDefinedInternal extends CommonCallbackDefined {
61
- producer: Function;
62
- }
63
- export interface CommonCallbackDefined {
64
- proper: boolean;
65
- }
66
- export interface CommonCallbackDefinedItem {
67
- consumer: Function;
68
- callback: CallbackWhenDefinedLambda;
69
- }
70
- export interface CommonFqnCb extends CommonCallbackDefined {
71
- name(value: any): string;
72
- }
73
- export type CallbackWhenDefinedLambda<T extends CommonCallbackDefined = CommonCallbackDefined> = (instance: T) => void;
@@ -1,2 +0,0 @@
1
- export * from './index-types';
2
- export * from './common-callback-impl';
@@ -1,106 +0,0 @@
1
- /**
2
- * Weak True items
3
- * */
4
- export declare const StorageTypeItems: readonly ["array", "list", "map", "set"];
5
- /**
6
- * Storage type literal, as an enum
7
- * */
8
- export type StorageType = typeof StorageTypeItems[number];
9
- /**
10
- * Weak True items
11
- * */
12
- export declare const PrimitiveItems: readonly ["string", "number", "boolean"];
13
- /**
14
- * Weak True
15
- * */
16
- export type Primitive = typeof PrimitiveItems[number];
17
- /**
18
- * Weak True items
19
- * */
20
- export declare const RealValueItems: readonly ["string", "number", "bigint", "boolean", "object", "function"];
21
- /**
22
- * Weak True
23
- * */
24
- export type RealValue = typeof RealValueItems[number];
25
- /**
26
- * Weak True items
27
- * */
28
- export declare const KeyValueItems: readonly ["string", "number"];
29
- /**
30
- * Weak True items
31
- * */
32
- export declare const WeakTrueItems: readonly ["1", "true", "t", "yes", "y", "on"];
33
- /**
34
- * Weak True
35
- * */
36
- export type WeakTrue = typeof WeakTrueItems[number];
37
- /**
38
- * Weak False items
39
- * */
40
- export declare const WeakFalseItems: readonly ["0", "-1", "false", "f", "no", "n", "off"];
41
- /**
42
- * Weak False
43
- * */
44
- export type WeakFalse = typeof WeakFalseItems[number];
45
- /**
46
- * Weak Boolean
47
- * */
48
- export type WeakBoolean = WeakTrue & WeakFalse;
49
- /**
50
- * Http Method items
51
- * */
52
- export declare const HttpMethodItems: readonly ["delete", "get", "head", "link", "options", "patch", "post", "purge", "put", "unlink"];
53
- /**
54
- * Http Method
55
- * */
56
- export type HttpMethod = typeof HttpMethodItems[number];
57
- /**
58
- * Http Place items
59
- * */
60
- export declare const HttpPlaceItems: readonly ["query", "body", "header", "path"];
61
- /**
62
- * Http Place
63
- * */
64
- export type HttpPlace = typeof HttpPlaceItems[number];
65
- /**
66
- * Severity items
67
- * */
68
- export declare const SeverityItems: readonly ["debug", "error", "fatal", "info", "log", "trace", "warn"];
69
- /**
70
- * Severity for log and errors
71
- * */
72
- export type Severity = typeof SeverityItems[number];
73
- /**
74
- * Environment items
75
- * */
76
- export declare const EnvironmentItems: readonly ["automation", "development", "local", "production", "staging", "test"];
77
- /**
78
- * Environment
79
- * */
80
- export type Environment = typeof EnvironmentItems[number];
81
- /**
82
- * Country code items
83
- * */
84
- export declare const CountryCodeItems: readonly ["AD", "AE", "AF", "AG", "AI", "AL", "AM", "AN", "AO", "AQ", "AR", "AS", "AT", "AU", "AW", "AX", "AZ", "BA", "BB", "BD", "BE", "BF", "BG", "BH", "BI", "BJ", "BM", "BN", "BO", "BR", "BS", "BT", "BV", "BW", "BY", "BZ", "CA", "CC", "CD", "CF", "CG", "CH", "CI", "CK", "CL", "CM", "CN", "CO", "CR", "CS", "CU", "CV", "CX", "CY", "CZ", "DE", "DJ", "DK", "DM", "DO", "DZ", "EC", "EE", "EG", "EH", "ER", "ES", "ET", "FI", "FJ", "FK", "FM", "FO", "FR", "GA", "GB", "GD", "GE", "GF", "GG", "GH", "GI", "GL", "GM", "GN", "GP", "GQ", "GR", "GS", "GT", "GU", "GW", "GY", "HK", "HM", "HN", "HR", "HT", "HU", "ID", "IE", "IL", "IM", "IN", "IO", "IQ", "IR", "IS", "IT", "JE", "JM", "JO", "JP", "KE", "KG", "KH", "KI", "KM", "KN", "KP", "KR", "KW", "KY", "KZ", "LA", "LB", "LC", "LI", "LK", "LR", "LS", "LT", "LU", "LV", "LY", "MA", "MC", "MD", "MG", "MH", "MK", "ML", "MM", "MN", "MO", "MP", "MQ", "MR", "MS", "MT", "MU", "MV", "MW", "MX", "MY", "MZ", "NA", "NC", "NE", "NF", "NG", "NI", "NL", "NO", "NP", "NR", "NU", "NZ", "OM", "PA", "PE", "PF", "PG", "PH", "PK", "PL", "PM", "PN", "PR", "PS", "PT", "PW", "PY", "QA", "RE", "RO", "RU", "RW", "SA", "SB", "SC", "SD", "SE", "SG", "SH", "SI", "SJ", "SK", "SL", "SM", "SN", "SO", "SR", "ST", "SV", "SY", "SZ", "TC", "TD", "TF", "TG", "TH", "TJ", "TK", "TL", "TM", "TN", "TO", "TR", "TT", "TV", "TW", "TZ", "UA", "UG", "UM", "US", "UY", "UZ", "VA", "VC", "VE", "VG", "VI", "VN", "VU", "WF", "WS", "YE", "YT", "ZA", "ZM", "ZW"];
85
- /**
86
- * Country code
87
- * */
88
- export type CountryCode = typeof CountryCodeItems[number];
89
- /**
90
- * Language code items
91
- * */
92
- export declare const LanguageCodeItems: readonly ["af", "an", "ar", "as", "ast", "az", "be", "bg", "bn", "br", "bs", "ca", "ce", "ch", "co", "cr", "cs", "cv", "cy", "da", "de", "el", "en", "eo", "es", "et", "eu", "fa", "fi", "fj", "fo", "fr", "fur", "fy", "ga", "gd", "gl", "gu", "he", "hi", "hr", "hsb", "ht", "hu", "hy", "id", "is", "it", "iu", "ja", "ji", "ka", "kk", "km", "kn", "ko", "ks", "ky", "la", "lb", "lt", "lv", "mi", "mk", "ml", "mo", "mr", "ms", "mt", "my", "nb", "ne", "ng", "nl", "nn", "no", "nv", "oc", "om", "or", "pa", "pl", "pt", "qu", "rm", "ro", "ru", "sa", "sb", "sc", "sd", "sg", "si", "sk", "sl", "so", "sq", "sr", "sv", "sw", "sx", "sz", "ta", "te", "th", "tig", "tk", "tlh", "tn", "tr", "ts", "tt", "uk", "ur", "ve", "vi", "vo", "wa", "xh", "zh", "zu"];
93
- /**
94
- * Language codes
95
- * */
96
- export type LanguageCode = typeof LanguageCodeItems[number];
97
- /**
98
- * Locale code items
99
- * */
100
- export declare const LocaleCodeItems: readonly ["af", "an", "ar", "ar-ae", "ar-bh", "ar-dz", "ar-eg", "ar-iq", "ar-jo", "ar-kw", "ar-lb", "ar-ly", "ar-ma", "ar-om", "ar-qa", "ar-sa", "ar-sy", "ar-tn", "ar-ye", "as", "ast", "az", "be", "bg", "bn", "br", "bs", "ca", "ce", "ch", "co", "cr", "cs", "cv", "cy", "da", "de", "de-at", "de-ch", "de-de", "de-li", "de-lu", "el", "en", "en-au", "en-bz", "en-ca", "en-gb", "en-ie", "en-jm", "en-nz", "en-ph", "en-tt", "en-us", "en-za", "en-zw", "eo", "es", "es-ar", "es-bo", "es-cl", "es-co", "es-cr", "es-do", "es-ec", "es-es", "es-gt", "es-hn", "es-mx", "es-ni", "es-pa", "es-pe", "es-pr", "es-py", "es-sv", "es-uy", "es-ve", "et", "eu", "fa", "fa-ir", "fi", "fj", "fo", "fr", "fr-be", "fr-ca", "fr-ch", "fr-fr", "fr-lu", "fr-mc", "fur", "fy", "ga", "gd", "gd-ie", "gl", "gu", "he", "hi", "hr", "hsb", "ht", "hu", "hy", "id", "is", "it", "it-ch", "iu", "ja", "ji", "ka", "kk", "km", "kn", "ko", "ko-kp", "ko-kr", "ks", "ky", "la", "lb", "lt", "lv", "mi", "mk", "ml", "mo", "mr", "ms", "mt", "my", "nb", "ne", "ng", "nl", "nl-be", "nn", "no", "nv", "oc", "om", "or", "pa", "pa-in", "pa-pk", "pl", "pt", "pt-br", "qu", "rm", "ro", "ro-mo", "ru", "ru-mo", "sa", "sb", "sc", "sd", "sg", "si", "sk", "sl", "so", "sq", "sr", "sv", "sv-fi", "sv-sv", "sw", "sx", "sz", "ta", "te", "th", "tig", "tk", "tlh", "tn", "tr", "ts", "tt", "uk", "ur", "ve", "vi", "vo", "wa", "xh", "zh", "zh-cn", "zh-hk", "zh-sg", "zh-tw", "zu"];
101
- /**
102
- * Locale codes
103
- *
104
- * Pattern: [Language Code]-[Country Code]
105
- * */
106
- export type LocaleCode = typeof LocaleCodeItems[number];