ismx-nexo-node-app 0.3.46 → 0.3.48

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.
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class ColorUtils {
4
+ static transparency(color, transparency) {
5
+ if (!color || !transparency)
6
+ return undefined;
7
+ return color.substring(0, 7) + Math.ceil(transparency * 255).toString(16);
8
+ }
9
+ }
10
+ exports.default = ColorUtils;
@@ -1,5 +1,46 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
12
  class BusinessState {
13
+ constructor() {
14
+ this.listeners = {};
15
+ this.listenerCount = 0;
16
+ }
17
+ init() {
18
+ return __awaiter(this, void 0, void 0, function* () { });
19
+ }
20
+ observe(listener, runOnObserve) {
21
+ return this.observeId("" + ++this.listenerCount, listener, runOnObserve);
22
+ }
23
+ observeId(id, listener, runOnObserve) {
24
+ if (runOnObserve)
25
+ try {
26
+ listener(this.data);
27
+ }
28
+ catch (_a) { }
29
+ this.listeners[id] = listener;
30
+ return id;
31
+ }
32
+ remove(id) {
33
+ delete this.listeners[id];
34
+ }
35
+ notify(data) {
36
+ var _a, _b;
37
+ if (data)
38
+ this.data = data;
39
+ for (let l in this.listeners)
40
+ try {
41
+ (_b = (_a = this.listeners)[l]) === null || _b === void 0 ? void 0 : _b.call(_a, this.data);
42
+ }
43
+ catch (error) { }
44
+ }
4
45
  }
5
46
  exports.default = BusinessState;
@@ -16,5 +16,12 @@ class StringUtils {
16
16
  base64String += '=';
17
17
  return StringUtils.base64Decode(base64String);
18
18
  }
19
+ static random(length, chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789') {
20
+ let result = '';
21
+ const charactersLength = chars.length;
22
+ while (result.length < length)
23
+ result += chars.charAt(Math.floor(Math.random() * charactersLength));
24
+ return result;
25
+ }
19
26
  }
20
27
  exports.default = StringUtils;
package/dist/js/index.js CHANGED
@@ -48,11 +48,17 @@ class ServiceRestFormalTemplate extends ServiceRestFormalTemplate_1.default {
48
48
  exports.ServiceRestFormalTemplate = ServiceRestFormalTemplate;
49
49
  /**************************************************************/
50
50
  const Business_1 = __importDefault(require("./business/Business"));
51
- exports.Business = Business_1.default;
51
+ class Business extends Business_1.default {
52
+ }
53
+ exports.Business = Business;
52
54
  const BusinessState_1 = __importDefault(require("./business/BusinessState"));
53
- exports.BusinessState = BusinessState_1.default;
55
+ class BusinessState extends BusinessState_1.default {
56
+ }
57
+ exports.BusinessState = BusinessState;
54
58
  const BusinessProxy_1 = __importDefault(require("./business/BusinessProxy"));
55
- exports.BusinessProxy = BusinessProxy_1.default;
59
+ class BusinessProxy extends BusinessProxy_1.default {
60
+ }
61
+ exports.BusinessProxy = BusinessProxy;
56
62
  const BusinessServer_1 = __importDefault(require("./business/BusinessServer"));
57
63
  class BusinessServer extends BusinessServer_1.default {
58
64
  }
@@ -83,7 +89,9 @@ class StringUtils extends StringUtils_1.default {
83
89
  exports.StringUtils = StringUtils;
84
90
  /**************************************************************/
85
91
  const Repository_1 = __importDefault(require("./repository/Repository"));
86
- exports.Repository = Repository_1.default;
92
+ class Repository extends Repository_1.default {
93
+ }
94
+ exports.Repository = Repository;
87
95
  const RepositoryDatabase_1 = __importDefault(require("./repository/RepositoryDatabase"));
88
96
  class RepositoryDatabase extends RepositoryDatabase_1.default {
89
97
  }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class RestUtils {
4
+ static notNull(value) {
5
+ return value;
6
+ }
7
+ }
8
+ exports.default = RestUtils;
@@ -0,0 +1,3 @@
1
+ export default abstract class ColorUtils {
2
+ static transparency(color?: string, transparency?: number): string | undefined;
3
+ }
@@ -1,2 +1,12 @@
1
1
  export default class BusinessState<Model> {
2
+ data: Model;
3
+ protected readonly listeners: {
4
+ [key: string]: (data: Model) => any;
5
+ };
6
+ private listenerCount;
7
+ init(): Promise<void>;
8
+ observe(listener: (data: Model) => any, runOnObserve?: boolean): string;
9
+ observeId(id: string, listener: (data: Model) => any, runOnObserve?: boolean): string;
10
+ protected remove(id: string): void;
11
+ protected notify(data?: Model): void;
2
12
  }
@@ -2,4 +2,5 @@ export default abstract class StringUtils {
2
2
  static base64Decode(base64: string): Buffer;
3
3
  static base64Encode(buffer: Buffer): string;
4
4
  static base64UrlDecode(base64: string): Buffer;
5
+ static random(length: number, chars?: string): string;
5
6
  }
@@ -18,11 +18,14 @@ export declare class ServiceRestFormalTemplate<A = any> extends BaseServiceRestF
18
18
  }
19
19
  /**************************************************************/
20
20
  import BaseBusiness from "./business/Business";
21
- export declare const Business: typeof BaseBusiness;
21
+ export declare class Business extends BaseBusiness {
22
+ }
22
23
  import BaseBusinessState from "./business/BusinessState";
23
- export declare const BusinessState: typeof BaseBusinessState;
24
+ export declare class BusinessState<M = any> extends BaseBusinessState<M> {
25
+ }
24
26
  import BaseBusinessProxy, { Module as BaseModule } from "./business/BusinessProxy";
25
- export declare const BusinessProxy: typeof BaseBusinessProxy;
27
+ export declare class BusinessProxy extends BaseBusinessProxy {
28
+ }
26
29
  export interface Module extends BaseModule {
27
30
  }
28
31
  import BaseBusinessServer from "./business/BusinessServer";
@@ -50,7 +53,8 @@ export declare abstract class StringUtils extends _StringUtils {
50
53
  }
51
54
  /**************************************************************/
52
55
  import BaseRepository from "./repository/Repository";
53
- export declare const Repository: typeof BaseRepository;
56
+ export declare class Repository extends BaseRepository {
57
+ }
54
58
  import _RepositoryDatabase from "./repository/RepositoryDatabase";
55
59
  export declare abstract class RepositoryDatabase extends _RepositoryDatabase {
56
60
  }
@@ -0,0 +1,3 @@
1
+ export default class RestUtils {
2
+ static notNull<T>(value: T | undefined): T;
3
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ismx-nexo-node-app",
3
- "version": "0.3.46",
3
+ "version": "0.3.48",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "build": "rm -rf ./dist && npx tsc",
@@ -0,0 +1,8 @@
1
+ export default abstract class ColorUtils {
2
+
3
+ static transparency(color?: string, transparency?: number) {
4
+ if (!color || !transparency) return undefined;
5
+ return color.substring(0, 7) + Math.ceil(transparency*255).toString(16);
6
+ }
7
+
8
+ }
@@ -1,4 +1,30 @@
1
1
  export default class BusinessState<Model>
2
2
  {
3
+ data!: Model;
3
4
 
5
+ protected readonly listeners: {[key: string]: (data: Model) => any} = {};
6
+
7
+ private listenerCount: number = 0;
8
+
9
+ async init(): Promise<void> { }
10
+
11
+ observe(listener: (data: Model) => any, runOnObserve?: boolean): string {
12
+ return this.observeId(""+ ++this.listenerCount, listener, runOnObserve);
13
+ }
14
+
15
+ observeId(id: string, listener: (data: Model) => any, runOnObserve?: boolean): string {
16
+ if (runOnObserve) try { listener(this.data); } catch {}
17
+ this.listeners[id] = listener;
18
+ return id;
19
+ }
20
+
21
+ protected remove(id: string) {
22
+ delete this.listeners[id];
23
+ }
24
+
25
+ protected notify(data?: Model): void {
26
+ if (data) this.data = data;
27
+ for (let l in this.listeners)
28
+ try { this.listeners[l]?.(this.data); } catch (error) {}
29
+ }
4
30
  }
@@ -17,4 +17,12 @@ export default abstract class StringUtils {
17
17
 
18
18
  return StringUtils.base64Decode(base64String);
19
19
  }
20
+
21
+ static random(length: number, chars: string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'): string {
22
+ let result = '';
23
+ const charactersLength = chars.length;
24
+ while (result.length < length)
25
+ result += chars.charAt(Math.floor(Math.random() * charactersLength));
26
+ return result;
27
+ }
20
28
  }
@@ -16,13 +16,13 @@ export class ServiceRestFormalTemplate<A=any> extends BaseServiceRestFormalTempl
16
16
  /**************************************************************/
17
17
 
18
18
  import BaseBusiness from "./business/Business";
19
- export const Business = BaseBusiness;
19
+ export class Business extends BaseBusiness {}
20
20
 
21
21
  import BaseBusinessState from "./business/BusinessState";
22
- export const BusinessState = BaseBusinessState;
22
+ export class BusinessState<M=any> extends BaseBusinessState<M> {}
23
23
 
24
24
  import BaseBusinessProxy, { Module as BaseModule } from "./business/BusinessProxy";
25
- export const BusinessProxy = BaseBusinessProxy;
25
+ export class BusinessProxy extends BaseBusinessProxy {}
26
26
  export interface Module extends BaseModule {}
27
27
 
28
28
  import BaseBusinessServer from "./business/BusinessServer";
@@ -50,7 +50,7 @@ export abstract class StringUtils extends _StringUtils {}
50
50
  /**************************************************************/
51
51
 
52
52
  import BaseRepository from "./repository/Repository";
53
- export const Repository = BaseRepository
53
+ export class Repository extends BaseRepository {}
54
54
 
55
55
  import _RepositoryDatabase from "./repository/RepositoryDatabase";
56
56
  export abstract class RepositoryDatabase extends _RepositoryDatabase {}
@@ -0,0 +1,6 @@
1
+ export default class RestUtils
2
+ {
3
+ static notNull<T>(value: T | undefined): T {
4
+ return value!
5
+ }
6
+ }