@nextage/nx-frame-be 1.0.3 → 1.0.6

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.
@@ -687,11 +687,12 @@ class BaseModel extends events_1.EventEmitter {
687
687
  * @param {*} context
688
688
  */
689
689
  publishCRUDEvent(evt, context = {}) {
690
+ var _a;
690
691
  if (!this.defaultParams.CRUDEvents)
691
692
  return;
692
693
  if (context === null || context === void 0 ? void 0 : context.evtType)
693
694
  evt.type = context.evtType;
694
- constants_1.APP.nxPubSub.publish(constants_1.MODEL_CRUD_EVENT, evt, context);
695
+ (_a = constants_1.APP.nxPubSub) === null || _a === void 0 ? void 0 : _a.publish(constants_1.MODEL_CRUD_EVENT, evt, context);
695
696
  }
696
697
  /**
697
698
  *
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import { AppData } from './types';
3
4
  import { CryptoUtils } from './crypto';
4
- import { CryptoManager } from './manager/crypto-manager';
5
5
  export declare const APP: AppData;
6
6
  export declare const FILE_CONTENT_TYPES: {
7
7
  none: string;
@@ -23,5 +23,4 @@ export declare const REGEX: {
23
23
  export declare const BUFFER_NULL: Buffer;
24
24
  export declare const EVENT_TYPE: {};
25
25
  export declare const MODEL_CRUD_EVENT = "crudEvent";
26
- export declare const cryptoManager: CryptoManager;
27
26
  export declare const cryptoUtils: CryptoUtils;
@@ -3,12 +3,11 @@
3
3
  // import { CryptoUtils } from './crypto-utils';
4
4
  // import { PubSubManager } from './pubsub-manager';
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.cryptoUtils = exports.cryptoManager = exports.MODEL_CRUD_EVENT = exports.EVENT_TYPE = exports.BUFFER_NULL = exports.REGEX = exports.MIME_TYPES = exports.FILE_CONTENT_TYPES = exports.APP = void 0;
6
+ exports.cryptoUtils = exports.MODEL_CRUD_EVENT = exports.EVENT_TYPE = exports.BUFFER_NULL = exports.REGEX = exports.MIME_TYPES = exports.FILE_CONTENT_TYPES = exports.APP = void 0;
7
7
  const pubsub_manager_1 = require("./manager/pubsub-manager");
8
8
  const shutdown_manager_1 = require("./manager/shutdown-manager");
9
9
  const enums_1 = require("./enums");
10
10
  const crypto_1 = require("./crypto");
11
- const crypto_manager_1 = require("./manager/crypto-manager");
12
11
  exports.APP = {
13
12
  status: enums_1.AppStatus.INIT,
14
13
  logger: console,
@@ -66,5 +65,5 @@ exports.BUFFER_NULL = Buffer.from([0x00]);
66
65
  exports.EVENT_TYPE = {};
67
66
  exports.MODEL_CRUD_EVENT = 'crudEvent';
68
67
  // export const nxPubSub = new PubSubManager();
69
- exports.cryptoManager = new crypto_manager_1.CryptoManager();
68
+ // export const cryptoManager = new CryptoManager();
70
69
  exports.cryptoUtils = new crypto_1.CryptoUtils();
@@ -50,7 +50,7 @@ beforeAll(() => __awaiter(void 0, void 0, void 0, function* () {
50
50
  // generateSchema<CodedEntity>(ceModel, params);
51
51
  (0, generator_1.generateSchema)(coded_entity_controller_1.ceCtrl, params);
52
52
  const constraintDir = { name: 'constraint', typeDefs: graphql_constraint_directive_1.constraintDirectiveTypeDefs, transformer: (0, graphql_constraint_directive_1.constraintDirective)() };
53
- const config = (0, loader_1.makeApolloConfig)([directives_1.authDirective, constraintDir]);
53
+ const config = (0, loader_1.makeApolloConfig)([directives_1.authDirective, constraintDir], true);
54
54
  server = new server_1.ApolloServer(config);
55
55
  }));
56
56
  afterAll(() => __awaiter(void 0, void 0, void 0, function* () {
@@ -9,6 +9,11 @@ export interface NxContext {
9
9
  userAgent?: string;
10
10
  remoteAddress?: string;
11
11
  res?: Response;
12
+ i18n?: string;
13
+ }
14
+ export interface NxJwtData extends NxObject {
15
+ rls?: string[];
16
+ i18n?: string;
12
17
  }
13
18
  export declare abstract class BaseUser {
14
19
  id?: string;
@@ -33,6 +33,7 @@ import { BaseModel } from './base/base.model';
33
33
  import { NxObject, NxTypeObject } from './interfaces';
34
34
  import { PubSubManager } from './manager/pubsub-manager';
35
35
  import { ShutdownManager } from './manager/shutdown-manager';
36
+ import { CryptoManager } from './manager/crypto-manager';
36
37
  export type NxDateRage = {
37
38
  from?: Date;
38
39
  to?: Date;
@@ -51,8 +52,9 @@ export type AppData = {
51
52
  mongoModels: NxTypeObject<BaseModel<any, any, any>>;
52
53
  mongoose?: Mongoose;
53
54
  sqlz?: Sequelize;
54
- nxPubSub: PubSubManager;
55
+ nxPubSub?: PubSubManager;
55
56
  shutdownMng?: ShutdownManager;
57
+ cryptoMng?: CryptoManager;
56
58
  streams: ChangeStreamData[];
57
59
  config: AppConfig;
58
60
  };
@@ -1,5 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
+ /// <reference types="node" />
3
4
  import { ClassElement } from 'typescript';
4
5
  import moment, { Moment } from 'moment';
5
6
  import JSZip from 'jszip';
@@ -7,14 +8,14 @@ import schedule from 'node-schedule';
7
8
  import jwt from 'jsonwebtoken';
8
9
  import UAParser from 'ua-parser-js';
9
10
  import { DatePeriod } from './enums';
10
- import { NxObject, BaseUser, NxContext } from './interfaces';
11
+ import { NxObject, BaseUser, NxContext, NxJwtData } from './interfaces';
11
12
  export declare function devMode(): boolean;
12
13
  export declare function prodMode(): boolean;
13
14
  /**
14
15
  *
15
16
  * @param {*} jti
16
17
  */
17
- export declare function generateJwt(sub: string, jti: string, iss: string, signOpts?: jwt.SignOptions, secret?: jwt.Secret): string;
18
+ export declare function generateJwt(sub: string, jti: string, iss: string, data?: NxJwtData, signOpts?: jwt.SignOptions, secret?: jwt.Secret): string;
18
19
  /**
19
20
  *
20
21
  * @param {*} token
@@ -471,7 +472,7 @@ export declare function checkCommonPassword(commonPwds: string[], pwd: string):
471
472
  * @param {*} name
472
473
  * @param {*} callback
473
474
  */
474
- export declare function zipFolder(path: string, name: string): Promise<unknown>;
475
+ export declare function zipFolder(path: string, name: string): Promise<void>;
475
476
  /**
476
477
  *
477
478
  * @param {*} path
@@ -40,7 +40,7 @@ exports.prodMode = prodMode;
40
40
  *
41
41
  * @param {*} jti
42
42
  */
43
- function generateJwt(sub, jti, iss, signOpts = {}, secret) {
43
+ function generateJwt(sub, jti, iss, data, signOpts = {}, secret) {
44
44
  if (!secret)
45
45
  secret = process.env.JWT_SECRET;
46
46
  if (!signOpts)
@@ -54,7 +54,7 @@ function generateJwt(sub, jti, iss, signOpts = {}, secret) {
54
54
  if (!secret)
55
55
  throw new Error('Missing JWT secret');
56
56
  return jsonwebtoken_1.default.sign({
57
- sub, jti, iss
57
+ sub, jti, iss, data
58
58
  }, secret, signOpts);
59
59
  }
60
60
  exports.generateJwt = generateJwt;
@@ -817,7 +817,7 @@ exports.initObjectWithProperty = initObjectWithProperty;
817
817
  */
818
818
  function resizeBuffer(buffer, size) {
819
819
  const resizedBuffer = Buffer.allocUnsafe(size);
820
- buffer.copy(resizedBuffer);
820
+ buffer.copy(new Uint8Array(resizedBuffer));
821
821
  return resizedBuffer;
822
822
  }
823
823
  exports.resizeBuffer = resizeBuffer;
@@ -45,7 +45,7 @@ global.signin = () => {
45
45
  const userId = new mongoose_1.default.Types.ObjectId().toHexString();
46
46
  const accessId = new mongoose_1.default.Types.ObjectId().toHexString();
47
47
  // Create the JWT!
48
- const token = (0, common_1.generateJwt)(userId, accessId, 'user', {}, process.env.JWT_KEY);
48
+ const token = (0, common_1.generateJwt)(userId, accessId, 'user', {}, {}, process.env.JWT_KEY);
49
49
  // return a string thats the cookie with the encoded data
50
50
  return `Bearer ${token}`;
51
51
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextage/nx-frame-be",
3
- "version": "1.0.3",
3
+ "version": "1.0.6",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -10,7 +10,7 @@
10
10
  "scripts": {
11
11
  "clean": "del ./build/*",
12
12
  "build": "npm run clean && tsc",
13
- "test": "jest --watchAll --no-cache",
13
+ "test": "jest --no-cache",
14
14
  "pub": "git add . && git commit -m \"Library updates\" && npm version patch && npm run build && npm publish"
15
15
  },
16
16
  "jest": {