ismx-nexo-node-app 0.3.46 → 0.3.47
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/js/business/BusinessState.js +41 -0
- package/dist/js/business/utils/StringUtils.js +7 -0
- package/dist/js/index.js +12 -4
- package/dist/types/business/BusinessState.d.ts +10 -0
- package/dist/types/business/utils/StringUtils.d.ts +1 -0
- package/dist/types/index.d.ts +8 -4
- package/package.json +1 -1
- package/src/main/node/business/BusinessState.ts +26 -0
- package/src/main/node/business/utils/StringUtils.ts +8 -0
- package/src/main/node/index.ts +4 -4
|
@@ -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
|
-
|
|
51
|
+
class Business extends Business_1.default {
|
|
52
|
+
}
|
|
53
|
+
exports.Business = Business;
|
|
52
54
|
const BusinessState_1 = __importDefault(require("./business/BusinessState"));
|
|
53
|
-
|
|
55
|
+
class BusinessState extends BusinessState_1.default {
|
|
56
|
+
}
|
|
57
|
+
exports.BusinessState = BusinessState;
|
|
54
58
|
const BusinessProxy_1 = __importDefault(require("./business/BusinessProxy"));
|
|
55
|
-
|
|
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
|
-
|
|
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
|
}
|
|
@@ -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
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -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
|
|
21
|
+
export declare class Business extends BaseBusiness {
|
|
22
|
+
}
|
|
22
23
|
import BaseBusinessState from "./business/BusinessState";
|
|
23
|
-
export declare
|
|
24
|
+
export declare class BusinessState<M = any> extends BaseBusinessState<M> {
|
|
25
|
+
}
|
|
24
26
|
import BaseBusinessProxy, { Module as BaseModule } from "./business/BusinessProxy";
|
|
25
|
-
export declare
|
|
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
|
|
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
|
}
|
package/package.json
CHANGED
|
@@ -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
|
}
|
package/src/main/node/index.ts
CHANGED
|
@@ -16,13 +16,13 @@ export class ServiceRestFormalTemplate<A=any> extends BaseServiceRestFormalTempl
|
|
|
16
16
|
/**************************************************************/
|
|
17
17
|
|
|
18
18
|
import BaseBusiness from "./business/Business";
|
|
19
|
-
export
|
|
19
|
+
export class Business extends BaseBusiness {}
|
|
20
20
|
|
|
21
21
|
import BaseBusinessState from "./business/BusinessState";
|
|
22
|
-
export
|
|
22
|
+
export class BusinessState<M=any> extends BaseBusinessState<M> {}
|
|
23
23
|
|
|
24
24
|
import BaseBusinessProxy, { Module as BaseModule } from "./business/BusinessProxy";
|
|
25
|
-
export
|
|
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
|
|
53
|
+
export class Repository extends BaseRepository {}
|
|
54
54
|
|
|
55
55
|
import _RepositoryDatabase from "./repository/RepositoryDatabase";
|
|
56
56
|
export abstract class RepositoryDatabase extends _RepositoryDatabase {}
|