@nextage/nx-frame-be 1.0.1
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/README.md +1 -0
- package/README.md.old +45 -0
- package/build/app.d.ts +0 -0
- package/build/app.js +1 -0
- package/build/aws/aws-cluster-manager.d.ts +28 -0
- package/build/aws/aws-cluster-manager.js +105 -0
- package/build/aws/aws-email-manager.d.ts +24 -0
- package/build/aws/aws-email-manager.js +57 -0
- package/build/aws/aws-queue-manager.d.ts +37 -0
- package/build/aws/aws-queue-manager.js +100 -0
- package/build/aws/aws.interfaces.d.ts +39 -0
- package/build/aws/aws.interfaces.js +2 -0
- package/build/aws/index.d.ts +4 -0
- package/build/aws/index.js +20 -0
- package/build/common/base/__test__/base.model.test.d.ts +1 -0
- package/build/common/base/__test__/base.model.test.js +283 -0
- package/build/common/base/base.controller.d.ts +124 -0
- package/build/common/base/base.controller.js +134 -0
- package/build/common/base/base.interfaces.d.ts +81 -0
- package/build/common/base/base.interfaces.js +2 -0
- package/build/common/base/base.model.d.ts +384 -0
- package/build/common/base/base.model.js +730 -0
- package/build/common/base/folded.model.d.ts +41 -0
- package/build/common/base/folded.model.js +215 -0
- package/build/common/base/mongo-utils.d.ts +122 -0
- package/build/common/base/mongo-utils.js +242 -0
- package/build/common/base/mongo.types.d.ts +20 -0
- package/build/common/base/mongo.types.js +2 -0
- package/build/common/base/sql-utils.d.ts +20 -0
- package/build/common/base/sql-utils.js +69 -0
- package/build/common/constants.d.ts +27 -0
- package/build/common/constants.js +70 -0
- package/build/common/crypto/crypto.classes.d.ts +100 -0
- package/build/common/crypto/crypto.classes.js +146 -0
- package/build/common/crypto/crypto.constants.d.ts +68 -0
- package/build/common/crypto/crypto.constants.js +57 -0
- package/build/common/crypto/crypto.error.d.ts +4 -0
- package/build/common/crypto/crypto.error.js +10 -0
- package/build/common/crypto/crypto.interfaces.d.ts +46 -0
- package/build/common/crypto/crypto.interfaces.js +2 -0
- package/build/common/crypto/crypto.utils.d.ts +139 -0
- package/build/common/crypto/crypto.utils.js +380 -0
- package/build/common/crypto/index.d.ts +3 -0
- package/build/common/crypto/index.js +19 -0
- package/build/common/enums.d.ts +61 -0
- package/build/common/enums.js +75 -0
- package/build/common/errors.d.ts +13 -0
- package/build/common/errors.js +24 -0
- package/build/common/express/express.interfaces.d.ts +20 -0
- package/build/common/express/express.interfaces.js +2 -0
- package/build/common/express/express.utils.d.ts +31 -0
- package/build/common/express/express.utils.js +85 -0
- package/build/common/express/index.d.ts +2 -0
- package/build/common/express/index.js +18 -0
- package/build/common/graphql/__test__/generator.schema.test.d.ts +1 -0
- package/build/common/graphql/__test__/generator.schema.test.js +391 -0
- package/build/common/graphql/directives.d.ts +18 -0
- package/build/common/graphql/directives.js +56 -0
- package/build/common/graphql/generator copy.d.ts +41 -0
- package/build/common/graphql/generator copy.js +385 -0
- package/build/common/graphql/generator.d.ts +42 -0
- package/build/common/graphql/generator.js +385 -0
- package/build/common/graphql/index.d.ts +4 -0
- package/build/common/graphql/index.js +21 -0
- package/build/common/graphql/interfaces.d.ts +67 -0
- package/build/common/graphql/interfaces.js +2 -0
- package/build/common/graphql/loader.d.ts +22 -0
- package/build/common/graphql/loader.js +186 -0
- package/build/common/graphql/scalars/index.d.ts +10 -0
- package/build/common/graphql/scalars/index.js +6 -0
- package/build/common/graphql/scalars/resolvers.d.ts +8 -0
- package/build/common/graphql/scalars/resolvers.js +71 -0
- package/build/common/graphql/scalars/schema.d.ts +1 -0
- package/build/common/graphql/scalars/schema.js +12 -0
- package/build/common/graphql/types/index.d.ts +3 -0
- package/build/common/graphql/types/index.js +6 -0
- package/build/common/graphql/types/schema.d.ts +1 -0
- package/build/common/graphql/types/schema.js +98 -0
- package/build/common/graphql/utils.d.ts +18 -0
- package/build/common/graphql/utils.js +40 -0
- package/build/common/grid-fs/gridfs-base.model.d.ts +53 -0
- package/build/common/grid-fs/gridfs-base.model.js +95 -0
- package/build/common/grid-fs/gridfs.interfaces.d.ts +41 -0
- package/build/common/grid-fs/gridfs.interfaces.js +2 -0
- package/build/common/index.d.ts +10 -0
- package/build/common/index.js +32 -0
- package/build/common/interfaces.d.ts +26 -0
- package/build/common/interfaces.js +10 -0
- package/build/common/manager/bulk-manager.d.ts +59 -0
- package/build/common/manager/bulk-manager.js +103 -0
- package/build/common/manager/crypto-manager.d.ts +88 -0
- package/build/common/manager/crypto-manager.js +200 -0
- package/build/common/manager/index.d.ts +5 -0
- package/build/common/manager/index.js +21 -0
- package/build/common/manager/pubsub-manager.d.ts +20 -0
- package/build/common/manager/pubsub-manager.js +38 -0
- package/build/common/manager/shutdown-manager.d.ts +27 -0
- package/build/common/manager/shutdown-manager.js +118 -0
- package/build/common/manager/socket-io-cli-manager.d.ts +53 -0
- package/build/common/manager/socket-io-cli-manager.js +91 -0
- package/build/common/manager/tunnel-manager.d.ts +28 -0
- package/build/common/manager/tunnel-manager.js +49 -0
- package/build/common/models/coded-entity.controller.d.ts +5 -0
- package/build/common/models/coded-entity.controller.js +9 -0
- package/build/common/models/coded-entity.model.d.ts +25 -0
- package/build/common/models/coded-entity.model.js +51 -0
- package/build/common/models/user.model.d.ts +56 -0
- package/build/common/models/user.model.js +72 -0
- package/build/common/types.d.ts +136 -0
- package/build/common/types.js +16 -0
- package/build/common/utils.d.ts +552 -0
- package/build/common/utils.js +1100 -0
- package/build/index.d.ts +2 -0
- package/build/index.js +18 -0
- package/build/test/env.d.ts +0 -0
- package/build/test/env.js +5 -0
- package/build/test/setup.d.ts +6 -0
- package/build/test/setup.js +59 -0
- package/package.json +90 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SocketIoCliManager = void 0;
|
|
7
|
+
const events_1 = __importDefault(require("events"));
|
|
8
|
+
const socket_io_client_1 = require("socket.io-client");
|
|
9
|
+
const constants_1 = require("../constants");
|
|
10
|
+
const utils_1 = require("../utils");
|
|
11
|
+
class SocketIoCliManager extends events_1.default {
|
|
12
|
+
constructor(host, port, params = { reconnection: true }, logger) {
|
|
13
|
+
super();
|
|
14
|
+
this.protocol = 'http';
|
|
15
|
+
this._listeners = {};
|
|
16
|
+
this._logCtx = (0, utils_1.logClassCtx)(this);
|
|
17
|
+
this.params = params;
|
|
18
|
+
this.host = host;
|
|
19
|
+
this.port = port;
|
|
20
|
+
this.logger = logger || constants_1.APP.logger;
|
|
21
|
+
this.init();
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Init Socket
|
|
25
|
+
*
|
|
26
|
+
* @param {*} encoding
|
|
27
|
+
*/
|
|
28
|
+
init(encoding) {
|
|
29
|
+
var _a, _b;
|
|
30
|
+
this.uri = `${this.protocol}://${this.host}:${this.port}`;
|
|
31
|
+
this.manager = new socket_io_client_1.Manager(this.uri, this.params);
|
|
32
|
+
this.socket = this.manager.socket('/');
|
|
33
|
+
// this.client = io.connect(this.uri, this.params);
|
|
34
|
+
(_a = this.socket) === null || _a === void 0 ? void 0 : _a.on('connect', () => this.onConnect());
|
|
35
|
+
(_b = this.socket) === null || _b === void 0 ? void 0 : _b.on("disconnect", () => this.onDisconnect());
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
*
|
|
39
|
+
*/
|
|
40
|
+
onConnect() {
|
|
41
|
+
this.logger.info(`Socket.io connected to server: ${this.uri}`, this._logCtx);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
*
|
|
45
|
+
*/
|
|
46
|
+
onDisconnect() {
|
|
47
|
+
this.logger.info(`Socket.io disconnected from server: ${this.uri}`, this._logCtx);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Format and send message
|
|
51
|
+
* @param {*} event
|
|
52
|
+
* @param {*} data
|
|
53
|
+
* @param {*} callback
|
|
54
|
+
*/
|
|
55
|
+
sendData(event, data, callback) {
|
|
56
|
+
var _a;
|
|
57
|
+
(_a = this.socket) === null || _a === void 0 ? void 0 : _a.emit(event, data, callback);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
*
|
|
61
|
+
* @param {*} event
|
|
62
|
+
* @param {*} callback
|
|
63
|
+
*/
|
|
64
|
+
addEventListener(event, callback) {
|
|
65
|
+
var _a;
|
|
66
|
+
if (this._listeners[event])
|
|
67
|
+
this.removeEventListener(event);
|
|
68
|
+
if (!callback)
|
|
69
|
+
callback = (data) => this.logger.info(`Socket.io receved data: ${event} - ${data}`, this._logCtx);
|
|
70
|
+
this._listeners[event] = callback;
|
|
71
|
+
(_a = this.socket) === null || _a === void 0 ? void 0 : _a.on(event, callback);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
*
|
|
75
|
+
* @param {*} event
|
|
76
|
+
* @param {*} callback
|
|
77
|
+
*/
|
|
78
|
+
removeEventListener(event) {
|
|
79
|
+
var _a;
|
|
80
|
+
(_a = this.socket) === null || _a === void 0 ? void 0 : _a.off(event);
|
|
81
|
+
delete this._listeners[event];
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Close Socket
|
|
85
|
+
*/
|
|
86
|
+
close() {
|
|
87
|
+
var _a;
|
|
88
|
+
(_a = this.socket) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
exports.SocketIoCliManager = SocketIoCliManager;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { TunnelOptions } from 'tunnel-ssh';
|
|
3
|
+
import { ForwardOptions, ServerOptions } from 'tunnel-ssh';
|
|
4
|
+
import { SshOptions } from 'tunnel-ssh';
|
|
5
|
+
import { Server } from 'net';
|
|
6
|
+
export declare class TunnelManager {
|
|
7
|
+
private readonly tunnelOptions;
|
|
8
|
+
private readonly serverOptions;
|
|
9
|
+
private readonly sshOptions;
|
|
10
|
+
private readonly forwardOptions;
|
|
11
|
+
private readonly logger;
|
|
12
|
+
private readonly tnl?;
|
|
13
|
+
private server?;
|
|
14
|
+
constructor(config: {
|
|
15
|
+
tunnel: TunnelOptions;
|
|
16
|
+
server: ServerOptions;
|
|
17
|
+
ssh: SshOptions;
|
|
18
|
+
forward: ForwardOptions;
|
|
19
|
+
}, logger?: any);
|
|
20
|
+
/**
|
|
21
|
+
*
|
|
22
|
+
*/
|
|
23
|
+
open(): Promise<Server | undefined>;
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
*/
|
|
27
|
+
close(): void;
|
|
28
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.TunnelManager = void 0;
|
|
13
|
+
const tunnel_ssh_1 = require("tunnel-ssh");
|
|
14
|
+
const constants_1 = require("../constants");
|
|
15
|
+
const utils_1 = require("../utils");
|
|
16
|
+
class TunnelManager {
|
|
17
|
+
constructor(config, logger) {
|
|
18
|
+
this.logger = logger !== null && logger !== void 0 ? logger : constants_1.APP.logger;
|
|
19
|
+
// tunnel config
|
|
20
|
+
this.tunnelOptions = config.tunnel;
|
|
21
|
+
this.serverOptions = config.server;
|
|
22
|
+
this.sshOptions = config.ssh;
|
|
23
|
+
this.forwardOptions = config.forward;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
*
|
|
27
|
+
*/
|
|
28
|
+
open() {
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
try {
|
|
31
|
+
let [server, conn] = yield (0, tunnel_ssh_1.createTunnel)(this.tunnelOptions, this.serverOptions, this.sshOptions, this.forwardOptions);
|
|
32
|
+
this.server = server;
|
|
33
|
+
this.logger.info('tunnel established');
|
|
34
|
+
}
|
|
35
|
+
catch (err) {
|
|
36
|
+
this.logger.error(`%o`, err, (0, utils_1.logClassCtx)(this));
|
|
37
|
+
}
|
|
38
|
+
return this.server;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
*
|
|
43
|
+
*/
|
|
44
|
+
close() {
|
|
45
|
+
var _a;
|
|
46
|
+
(_a = this.tnl) === null || _a === void 0 ? void 0 : _a.end();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.TunnelManager = TunnelManager;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { BaseController } from '../base/base.controller';
|
|
2
|
+
import { CodedEntity, CodedEntityAttrs, CodedEntityDoc } from './coded-entity.model';
|
|
3
|
+
export declare class CodedEntityCtrl extends BaseController<CodedEntityAttrs, CodedEntityDoc, CodedEntity> {
|
|
4
|
+
}
|
|
5
|
+
export declare const ceCtrl: CodedEntityCtrl;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ceCtrl = exports.CodedEntityCtrl = void 0;
|
|
4
|
+
const base_controller_1 = require("../base/base.controller");
|
|
5
|
+
const coded_entity_model_1 = require("./coded-entity.model");
|
|
6
|
+
class CodedEntityCtrl extends base_controller_1.BaseController {
|
|
7
|
+
}
|
|
8
|
+
exports.CodedEntityCtrl = CodedEntityCtrl;
|
|
9
|
+
exports.ceCtrl = new CodedEntityCtrl({ model: coded_entity_model_1.ceModel });
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { NxObject } from '../interfaces';
|
|
2
|
+
import { BaseMongoDoc, BaseMongoModel } from '../base/base.interfaces';
|
|
3
|
+
import { BaseModel } from '../base/base.model';
|
|
4
|
+
export interface CodedEntityAttrs {
|
|
5
|
+
id?: string;
|
|
6
|
+
code?: string;
|
|
7
|
+
name?: string;
|
|
8
|
+
data?: {
|
|
9
|
+
items: NxObject[];
|
|
10
|
+
};
|
|
11
|
+
version?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface CodedEntityDoc extends BaseMongoDoc {
|
|
14
|
+
code: string;
|
|
15
|
+
name: string;
|
|
16
|
+
data: {
|
|
17
|
+
items: NxObject[];
|
|
18
|
+
};
|
|
19
|
+
version: number;
|
|
20
|
+
}
|
|
21
|
+
export interface CodedEntityModel extends BaseMongoModel<CodedEntityAttrs, CodedEntityDoc> {
|
|
22
|
+
}
|
|
23
|
+
export declare class CodedEntity extends BaseModel<CodedEntityAttrs, CodedEntityDoc, CodedEntityModel> {
|
|
24
|
+
}
|
|
25
|
+
export declare const ceModel: CodedEntity;
|
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.ceModel = exports.CodedEntity = void 0;
|
|
16
|
+
const mongoose_1 = __importDefault(require("mongoose"));
|
|
17
|
+
const base_model_1 = require("../base/base.model");
|
|
18
|
+
const mongo_utils_1 = require("../base/mongo-utils");
|
|
19
|
+
class CodedEntity extends base_model_1.BaseModel {
|
|
20
|
+
}
|
|
21
|
+
exports.CodedEntity = CodedEntity;
|
|
22
|
+
const schema = {
|
|
23
|
+
code: {
|
|
24
|
+
type: String,
|
|
25
|
+
required: true,
|
|
26
|
+
},
|
|
27
|
+
name: {
|
|
28
|
+
type: String,
|
|
29
|
+
required: true,
|
|
30
|
+
},
|
|
31
|
+
data: {
|
|
32
|
+
type: mongoose_1.default.SchemaTypes.Mixed,
|
|
33
|
+
required: true,
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const params = {
|
|
37
|
+
name: 'CodedEntity',
|
|
38
|
+
modelName: 'CodedEntity',
|
|
39
|
+
collection: 'codedEntity',
|
|
40
|
+
classDef: CodedEntity,
|
|
41
|
+
mergeSchema: false,
|
|
42
|
+
modelParams: { sort: { name: 1 }, CRUDEvents: true },
|
|
43
|
+
schema
|
|
44
|
+
};
|
|
45
|
+
exports.ceModel = (0, mongo_utils_1.createModel)(params, false);
|
|
46
|
+
exports.ceModel.mgModel.schema.pre('save', function (done) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
console.log('CIAONE');
|
|
49
|
+
done();
|
|
50
|
+
});
|
|
51
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { BaseUser, NxObject } from '../interfaces';
|
|
2
|
+
import { BaseMongoDoc, BaseMongoModel } from '../base/base.interfaces';
|
|
3
|
+
import { BaseModel } from '../base/base.model';
|
|
4
|
+
import { BaseDBItem } from '../types';
|
|
5
|
+
export interface UserAttrs extends BaseDBItem {
|
|
6
|
+
username: string;
|
|
7
|
+
profile: UserAttrProfile;
|
|
8
|
+
roles: string[];
|
|
9
|
+
services?: UserAttrService;
|
|
10
|
+
data?: NxObject;
|
|
11
|
+
active?: boolean;
|
|
12
|
+
createdBy?: string;
|
|
13
|
+
createdAt?: Date;
|
|
14
|
+
updatedBy?: string;
|
|
15
|
+
updatedAt?: Date;
|
|
16
|
+
deletedBy?: string;
|
|
17
|
+
deletedAt?: Date;
|
|
18
|
+
version: number;
|
|
19
|
+
}
|
|
20
|
+
export interface UserAttrProfile {
|
|
21
|
+
firstname?: string;
|
|
22
|
+
lastname?: string;
|
|
23
|
+
email?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface UserAttrService {
|
|
26
|
+
password?: {
|
|
27
|
+
hash?: string;
|
|
28
|
+
salt?: string;
|
|
29
|
+
expiresAt?: Date;
|
|
30
|
+
};
|
|
31
|
+
resetPassword?: {
|
|
32
|
+
token?: string;
|
|
33
|
+
expiresAt?: Date;
|
|
34
|
+
};
|
|
35
|
+
pb?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface UserDoc extends BaseMongoDoc, BaseUser {
|
|
38
|
+
username: string;
|
|
39
|
+
profile: UserAttrProfile;
|
|
40
|
+
roles: string[];
|
|
41
|
+
services?: UserAttrService;
|
|
42
|
+
data?: NxObject;
|
|
43
|
+
active?: boolean;
|
|
44
|
+
createdBy?: string;
|
|
45
|
+
createdAt?: Date;
|
|
46
|
+
updatedBy?: string;
|
|
47
|
+
updatedAt?: Date;
|
|
48
|
+
deletedBy?: string;
|
|
49
|
+
deletedAt?: Date;
|
|
50
|
+
version: number;
|
|
51
|
+
}
|
|
52
|
+
export interface UserModel extends BaseMongoModel<UserAttrs, UserDoc> {
|
|
53
|
+
}
|
|
54
|
+
export declare class User extends BaseModel<UserAttrs, UserDoc, UserModel> {
|
|
55
|
+
}
|
|
56
|
+
export declare const users: User;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.users = exports.User = void 0;
|
|
7
|
+
const mongoose_1 = __importDefault(require("mongoose"));
|
|
8
|
+
const base_model_1 = require("../base/base.model");
|
|
9
|
+
const mongo_utils_1 = require("../base/mongo-utils");
|
|
10
|
+
const constants_1 = require("../constants");
|
|
11
|
+
const utils_1 = require("../utils");
|
|
12
|
+
class User extends base_model_1.BaseModel {
|
|
13
|
+
}
|
|
14
|
+
exports.User = User;
|
|
15
|
+
const required = true;
|
|
16
|
+
const unique = true;
|
|
17
|
+
const secret = constants_1.APP.dataScr || process.env.SECRET || '';
|
|
18
|
+
const get = (text) => constants_1.cryptoUtils.decryptText(text, secret);
|
|
19
|
+
const set = (text) => constants_1.cryptoUtils.encryptText(text, secret);
|
|
20
|
+
const schema = {
|
|
21
|
+
username: { type: String, required, unique },
|
|
22
|
+
email: { type: String, required, get, set },
|
|
23
|
+
password: String,
|
|
24
|
+
services: {
|
|
25
|
+
password: { hash: { type: String }, salt: { type: String }, expiresAt: Date },
|
|
26
|
+
resetPassword: { token: { type: String }, expiresAt: { type: Date } },
|
|
27
|
+
//resume : { loginTokens: [{ when: { type: Date }, hashedToken: { type: String } }]},
|
|
28
|
+
pb: { type: String }
|
|
29
|
+
},
|
|
30
|
+
profile: {
|
|
31
|
+
lastname: { type: String, get, set },
|
|
32
|
+
firstname: { type: String, get, set },
|
|
33
|
+
email: { type: String, get, set },
|
|
34
|
+
},
|
|
35
|
+
//functs : [String],
|
|
36
|
+
//organizations : [mongoose.SchemaTypes.Mixed],
|
|
37
|
+
roles: [String],
|
|
38
|
+
data: mongoose_1.default.SchemaTypes.Mixed,
|
|
39
|
+
// delegations: {
|
|
40
|
+
// functs: [mongoose.SchemaTypes.Mixed],
|
|
41
|
+
// roles : [mongoose.SchemaTypes.Mixed],
|
|
42
|
+
// },
|
|
43
|
+
// config : mongoose.SchemaTypes.Mixed,
|
|
44
|
+
createdBy: mongoose_1.default.SchemaTypes.ObjectId,
|
|
45
|
+
createdAt: Date,
|
|
46
|
+
updatedBy: mongoose_1.default.SchemaTypes.ObjectId,
|
|
47
|
+
updatedAt: Date,
|
|
48
|
+
deleted: { type: Boolean, default: false },
|
|
49
|
+
deletedAt: Date,
|
|
50
|
+
active: { type: Boolean, default: false }
|
|
51
|
+
};
|
|
52
|
+
const params = {
|
|
53
|
+
name: 'User',
|
|
54
|
+
modelName: 'User',
|
|
55
|
+
collection: 'users',
|
|
56
|
+
classDef: User,
|
|
57
|
+
mergeSchema: false,
|
|
58
|
+
modelParams: { sort: { name: 1 }, CRUDEvents: true },
|
|
59
|
+
schema
|
|
60
|
+
};
|
|
61
|
+
exports.users = (0, mongo_utils_1.createModel)(params, false);
|
|
62
|
+
// users.mgModel.prototype.validPassword = function(password) {
|
|
63
|
+
// return bcrypt.compareSync(password, this.services.password.hash);
|
|
64
|
+
// };
|
|
65
|
+
exports.users.mgModel.prototype.hasRole = function (role) {
|
|
66
|
+
if (Array.isArray(role))
|
|
67
|
+
return (0, utils_1.containsArrayValue)(this.roles, role);
|
|
68
|
+
return !!this.roles.find((r) => r === role);
|
|
69
|
+
};
|
|
70
|
+
// users.mgModel.prototype.isAdmin = function() {
|
|
71
|
+
// return !!this.roles.find((r: string) => r === BASE_ROLES.ADMIN);
|
|
72
|
+
// };
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/// <reference types="mongoose/types/aggregate" />
|
|
2
|
+
/// <reference types="mongoose/types/callback" />
|
|
3
|
+
/// <reference types="mongoose/types/collection" />
|
|
4
|
+
/// <reference types="mongoose/types/connection" />
|
|
5
|
+
/// <reference types="mongoose/types/cursor" />
|
|
6
|
+
/// <reference types="mongoose/types/document" />
|
|
7
|
+
/// <reference types="mongoose/types/error" />
|
|
8
|
+
/// <reference types="mongoose/types/expressions" />
|
|
9
|
+
/// <reference types="mongoose/types/helpers" />
|
|
10
|
+
/// <reference types="mongoose/types/middlewares" />
|
|
11
|
+
/// <reference types="mongoose/types/indexes" />
|
|
12
|
+
/// <reference types="mongoose/types/models" />
|
|
13
|
+
/// <reference types="mongoose/types/mongooseoptions" />
|
|
14
|
+
/// <reference types="mongoose/types/pipelinestage" />
|
|
15
|
+
/// <reference types="mongoose/types/populate" />
|
|
16
|
+
/// <reference types="mongoose/types/query" />
|
|
17
|
+
/// <reference types="mongoose/types/schemaoptions" />
|
|
18
|
+
/// <reference types="mongoose/types/schematypes" />
|
|
19
|
+
/// <reference types="mongoose/types/session" />
|
|
20
|
+
/// <reference types="mongoose/types/types" />
|
|
21
|
+
/// <reference types="mongoose/types/utility" />
|
|
22
|
+
/// <reference types="mongoose/types/validation" />
|
|
23
|
+
/// <reference types="mongoose/types/virtuals" />
|
|
24
|
+
/// <reference types="mongoose/types/inferschematype" />
|
|
25
|
+
/// <reference types="mongoose/types/inferrawdoctype" />
|
|
26
|
+
import { Mongoose } from 'mongoose';
|
|
27
|
+
import { Sequelize } from 'sequelize';
|
|
28
|
+
import { Algorithm } from 'jsonwebtoken';
|
|
29
|
+
import { Express } from 'express';
|
|
30
|
+
import { AppStatus } from './enums';
|
|
31
|
+
import { ChangeStreamData } from './base/base.interfaces';
|
|
32
|
+
import { BaseModel } from './base/base.model';
|
|
33
|
+
import { NxObject, NxTypeObject } from './interfaces';
|
|
34
|
+
import { PubSubManager } from './manager/pubsub-manager';
|
|
35
|
+
import { ShutdownManager } from './manager/shutdown-manager';
|
|
36
|
+
export type NxDateRage = {
|
|
37
|
+
from?: Date;
|
|
38
|
+
to?: Date;
|
|
39
|
+
eq?: Date;
|
|
40
|
+
};
|
|
41
|
+
export type BaseDBItem = {
|
|
42
|
+
id?: string;
|
|
43
|
+
};
|
|
44
|
+
export type AppData = {
|
|
45
|
+
app?: Express;
|
|
46
|
+
logger: any;
|
|
47
|
+
appName: string;
|
|
48
|
+
prodMode: boolean;
|
|
49
|
+
status?: AppStatus;
|
|
50
|
+
dataScr?: string;
|
|
51
|
+
mongoModels: NxTypeObject<BaseModel<any, any, any>>;
|
|
52
|
+
mongoose?: Mongoose;
|
|
53
|
+
sqlz?: Sequelize;
|
|
54
|
+
nxPubSub: PubSubManager;
|
|
55
|
+
shutdownMng?: ShutdownManager;
|
|
56
|
+
streams: ChangeStreamData[];
|
|
57
|
+
config: AppConfig;
|
|
58
|
+
};
|
|
59
|
+
export type AppConfig = {
|
|
60
|
+
endpoint: AppEndpoint;
|
|
61
|
+
email: AppEmail;
|
|
62
|
+
jwt: AppJwt;
|
|
63
|
+
aws: AppAWS;
|
|
64
|
+
msg: AppMessages;
|
|
65
|
+
mongo: AppMongoDB;
|
|
66
|
+
invite: AppInvitation;
|
|
67
|
+
logging: AppLogging;
|
|
68
|
+
};
|
|
69
|
+
export type AppMongoDB = {
|
|
70
|
+
auth?: {
|
|
71
|
+
us: string;
|
|
72
|
+
pw: string;
|
|
73
|
+
};
|
|
74
|
+
dbname?: string;
|
|
75
|
+
host?: string;
|
|
76
|
+
port?: string;
|
|
77
|
+
protocol?: string;
|
|
78
|
+
options?: NxObject;
|
|
79
|
+
ssl?: boolean;
|
|
80
|
+
tnlHost?: string;
|
|
81
|
+
tnlPort?: string;
|
|
82
|
+
tnlAuth?: {
|
|
83
|
+
us?: string;
|
|
84
|
+
pw?: string;
|
|
85
|
+
key?: string;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
export type AppInvitation = {
|
|
89
|
+
validity?: string | number;
|
|
90
|
+
};
|
|
91
|
+
export type AppLogging = {
|
|
92
|
+
format?: string;
|
|
93
|
+
dir?: string;
|
|
94
|
+
filename?: string;
|
|
95
|
+
};
|
|
96
|
+
export type AppMessages = {
|
|
97
|
+
servers?: string | string[];
|
|
98
|
+
clientId?: string;
|
|
99
|
+
clientName?: string;
|
|
100
|
+
clientType?: 'nats' | 'msg';
|
|
101
|
+
ackWait?: number;
|
|
102
|
+
maxDeliver?: number;
|
|
103
|
+
};
|
|
104
|
+
export type AppEndpoint = {
|
|
105
|
+
rest?: string;
|
|
106
|
+
graphql?: string;
|
|
107
|
+
graphqlWs?: string;
|
|
108
|
+
ws?: boolean;
|
|
109
|
+
port?: number;
|
|
110
|
+
};
|
|
111
|
+
export type AppJwt = {
|
|
112
|
+
secret?: string;
|
|
113
|
+
algorithm?: Algorithm;
|
|
114
|
+
duration?: string;
|
|
115
|
+
};
|
|
116
|
+
export type AppEmail = {
|
|
117
|
+
source?: string;
|
|
118
|
+
aws?: boolean;
|
|
119
|
+
};
|
|
120
|
+
export type AppAWS = {
|
|
121
|
+
region?: string;
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* const endpoint = {
|
|
125
|
+
http: process.env.GRAPHQL_ENDPOINT || '/api/graphql',
|
|
126
|
+
ws : process.env.GRAPHQL_WS_ENDPOINT || '/subscriptions',
|
|
127
|
+
wsOn: !!process.env.GRAPHQL_WS,
|
|
128
|
+
port: process.env.SERVER_PORT ? parseInt(process.env.SERVER_PORT) : 4200
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
const jwtData = {
|
|
132
|
+
secret : process.env.JWT_SECRET,
|
|
133
|
+
algorithm: (process.env.JWT_ALGORITHM || 'HS512') as unknown as Algorithm,
|
|
134
|
+
duration : process.env.JWT_VALIDITY || '1h'
|
|
135
|
+
};
|
|
136
|
+
*/
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* const endpoint = {
|
|
5
|
+
http: process.env.GRAPHQL_ENDPOINT || '/api/graphql',
|
|
6
|
+
ws : process.env.GRAPHQL_WS_ENDPOINT || '/subscriptions',
|
|
7
|
+
wsOn: !!process.env.GRAPHQL_WS,
|
|
8
|
+
port: process.env.SERVER_PORT ? parseInt(process.env.SERVER_PORT) : 4200
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const jwtData = {
|
|
12
|
+
secret : process.env.JWT_SECRET,
|
|
13
|
+
algorithm: (process.env.JWT_ALGORITHM || 'HS512') as unknown as Algorithm,
|
|
14
|
+
duration : process.env.JWT_VALIDITY || '1h'
|
|
15
|
+
};
|
|
16
|
+
*/
|