@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.
Files changed (119) hide show
  1. package/README.md +1 -0
  2. package/README.md.old +45 -0
  3. package/build/app.d.ts +0 -0
  4. package/build/app.js +1 -0
  5. package/build/aws/aws-cluster-manager.d.ts +28 -0
  6. package/build/aws/aws-cluster-manager.js +105 -0
  7. package/build/aws/aws-email-manager.d.ts +24 -0
  8. package/build/aws/aws-email-manager.js +57 -0
  9. package/build/aws/aws-queue-manager.d.ts +37 -0
  10. package/build/aws/aws-queue-manager.js +100 -0
  11. package/build/aws/aws.interfaces.d.ts +39 -0
  12. package/build/aws/aws.interfaces.js +2 -0
  13. package/build/aws/index.d.ts +4 -0
  14. package/build/aws/index.js +20 -0
  15. package/build/common/base/__test__/base.model.test.d.ts +1 -0
  16. package/build/common/base/__test__/base.model.test.js +283 -0
  17. package/build/common/base/base.controller.d.ts +124 -0
  18. package/build/common/base/base.controller.js +134 -0
  19. package/build/common/base/base.interfaces.d.ts +81 -0
  20. package/build/common/base/base.interfaces.js +2 -0
  21. package/build/common/base/base.model.d.ts +384 -0
  22. package/build/common/base/base.model.js +730 -0
  23. package/build/common/base/folded.model.d.ts +41 -0
  24. package/build/common/base/folded.model.js +215 -0
  25. package/build/common/base/mongo-utils.d.ts +122 -0
  26. package/build/common/base/mongo-utils.js +242 -0
  27. package/build/common/base/mongo.types.d.ts +20 -0
  28. package/build/common/base/mongo.types.js +2 -0
  29. package/build/common/base/sql-utils.d.ts +20 -0
  30. package/build/common/base/sql-utils.js +69 -0
  31. package/build/common/constants.d.ts +27 -0
  32. package/build/common/constants.js +70 -0
  33. package/build/common/crypto/crypto.classes.d.ts +100 -0
  34. package/build/common/crypto/crypto.classes.js +146 -0
  35. package/build/common/crypto/crypto.constants.d.ts +68 -0
  36. package/build/common/crypto/crypto.constants.js +57 -0
  37. package/build/common/crypto/crypto.error.d.ts +4 -0
  38. package/build/common/crypto/crypto.error.js +10 -0
  39. package/build/common/crypto/crypto.interfaces.d.ts +46 -0
  40. package/build/common/crypto/crypto.interfaces.js +2 -0
  41. package/build/common/crypto/crypto.utils.d.ts +139 -0
  42. package/build/common/crypto/crypto.utils.js +380 -0
  43. package/build/common/crypto/index.d.ts +3 -0
  44. package/build/common/crypto/index.js +19 -0
  45. package/build/common/enums.d.ts +61 -0
  46. package/build/common/enums.js +75 -0
  47. package/build/common/errors.d.ts +13 -0
  48. package/build/common/errors.js +24 -0
  49. package/build/common/express/express.interfaces.d.ts +20 -0
  50. package/build/common/express/express.interfaces.js +2 -0
  51. package/build/common/express/express.utils.d.ts +31 -0
  52. package/build/common/express/express.utils.js +85 -0
  53. package/build/common/express/index.d.ts +2 -0
  54. package/build/common/express/index.js +18 -0
  55. package/build/common/graphql/__test__/generator.schema.test.d.ts +1 -0
  56. package/build/common/graphql/__test__/generator.schema.test.js +391 -0
  57. package/build/common/graphql/directives.d.ts +18 -0
  58. package/build/common/graphql/directives.js +56 -0
  59. package/build/common/graphql/generator copy.d.ts +41 -0
  60. package/build/common/graphql/generator copy.js +385 -0
  61. package/build/common/graphql/generator.d.ts +42 -0
  62. package/build/common/graphql/generator.js +385 -0
  63. package/build/common/graphql/index.d.ts +4 -0
  64. package/build/common/graphql/index.js +21 -0
  65. package/build/common/graphql/interfaces.d.ts +67 -0
  66. package/build/common/graphql/interfaces.js +2 -0
  67. package/build/common/graphql/loader.d.ts +22 -0
  68. package/build/common/graphql/loader.js +186 -0
  69. package/build/common/graphql/scalars/index.d.ts +10 -0
  70. package/build/common/graphql/scalars/index.js +6 -0
  71. package/build/common/graphql/scalars/resolvers.d.ts +8 -0
  72. package/build/common/graphql/scalars/resolvers.js +71 -0
  73. package/build/common/graphql/scalars/schema.d.ts +1 -0
  74. package/build/common/graphql/scalars/schema.js +12 -0
  75. package/build/common/graphql/types/index.d.ts +3 -0
  76. package/build/common/graphql/types/index.js +6 -0
  77. package/build/common/graphql/types/schema.d.ts +1 -0
  78. package/build/common/graphql/types/schema.js +98 -0
  79. package/build/common/graphql/utils.d.ts +18 -0
  80. package/build/common/graphql/utils.js +40 -0
  81. package/build/common/grid-fs/gridfs-base.model.d.ts +53 -0
  82. package/build/common/grid-fs/gridfs-base.model.js +95 -0
  83. package/build/common/grid-fs/gridfs.interfaces.d.ts +41 -0
  84. package/build/common/grid-fs/gridfs.interfaces.js +2 -0
  85. package/build/common/index.d.ts +10 -0
  86. package/build/common/index.js +32 -0
  87. package/build/common/interfaces.d.ts +26 -0
  88. package/build/common/interfaces.js +10 -0
  89. package/build/common/manager/bulk-manager.d.ts +59 -0
  90. package/build/common/manager/bulk-manager.js +103 -0
  91. package/build/common/manager/crypto-manager.d.ts +88 -0
  92. package/build/common/manager/crypto-manager.js +200 -0
  93. package/build/common/manager/index.d.ts +5 -0
  94. package/build/common/manager/index.js +21 -0
  95. package/build/common/manager/pubsub-manager.d.ts +20 -0
  96. package/build/common/manager/pubsub-manager.js +38 -0
  97. package/build/common/manager/shutdown-manager.d.ts +27 -0
  98. package/build/common/manager/shutdown-manager.js +118 -0
  99. package/build/common/manager/socket-io-cli-manager.d.ts +53 -0
  100. package/build/common/manager/socket-io-cli-manager.js +91 -0
  101. package/build/common/manager/tunnel-manager.d.ts +28 -0
  102. package/build/common/manager/tunnel-manager.js +49 -0
  103. package/build/common/models/coded-entity.controller.d.ts +5 -0
  104. package/build/common/models/coded-entity.controller.js +9 -0
  105. package/build/common/models/coded-entity.model.d.ts +25 -0
  106. package/build/common/models/coded-entity.model.js +51 -0
  107. package/build/common/models/user.model.d.ts +56 -0
  108. package/build/common/models/user.model.js +72 -0
  109. package/build/common/types.d.ts +136 -0
  110. package/build/common/types.js +16 -0
  111. package/build/common/utils.d.ts +552 -0
  112. package/build/common/utils.js +1100 -0
  113. package/build/index.d.ts +2 -0
  114. package/build/index.js +18 -0
  115. package/build/test/env.d.ts +0 -0
  116. package/build/test/env.js +5 -0
  117. package/build/test/setup.d.ts +6 -0
  118. package/build/test/setup.js +59 -0
  119. package/package.json +90 -0
@@ -0,0 +1,10 @@
1
+ export declare const scalarsSchema: {
2
+ typeDefs: string;
3
+ resolvers: {
4
+ JSON: import("graphql").GraphQLScalarType<any, any>;
5
+ RegExp: import("graphql").GraphQLScalarType<RegExp, unknown>;
6
+ Date: import("graphql").GraphQLScalarType<Date, unknown>;
7
+ Encrypted: import("graphql").GraphQLScalarType<string, string>;
8
+ Any: import("graphql").GraphQLScalarType<unknown, unknown>;
9
+ };
10
+ };
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.scalarsSchema = void 0;
4
+ const schema_1 = require("./schema");
5
+ const resolvers_1 = require("./resolvers");
6
+ exports.scalarsSchema = { typeDefs: schema_1.typeDefs, resolvers: resolvers_1.resolvers };
@@ -0,0 +1,8 @@
1
+ import { GraphQLScalarType } from 'graphql/type';
2
+ export declare const resolvers: {
3
+ JSON: GraphQLScalarType<any, any>;
4
+ RegExp: GraphQLScalarType<RegExp, unknown>;
5
+ Date: GraphQLScalarType<Date, unknown>;
6
+ Encrypted: GraphQLScalarType<string, string>;
7
+ Any: GraphQLScalarType<unknown, unknown>;
8
+ };
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolvers = void 0;
4
+ // import GraphQLJSON from 'graphql-type-json';
5
+ const type_1 = require("graphql/type");
6
+ const language_1 = require("graphql/language");
7
+ // import GraphQLRegExp from 'graphql-type-regexp';
8
+ const constants_1 = require("../../constants");
9
+ const utils_1 = require("../../utils");
10
+ const graphql_scalars_1 = require("graphql-scalars");
11
+ const scalarDate = new type_1.GraphQLScalarType({
12
+ name: 'Date',
13
+ serialize(value) {
14
+ return value;
15
+ },
16
+ parseValue(value) {
17
+ return new Date(value); // value from the client
18
+ }
19
+ });
20
+ const scalarEncrypted = new type_1.GraphQLScalarType({
21
+ name: 'Encrypted',
22
+ serialize(value) {
23
+ var _a;
24
+ const secret = (_a = constants_1.APP.dataScr) !== null && _a !== void 0 ? _a : process.env.SECRET;
25
+ if (!secret)
26
+ throw new Error('Secret is not defined');
27
+ return (0, utils_1.isString)(value) ? constants_1.cryptoUtils.decryptText(value, secret) : '';
28
+ },
29
+ parseValue(value) {
30
+ var _a;
31
+ const secret = (_a = constants_1.APP.dataScr) !== null && _a !== void 0 ? _a : process.env.SECRET;
32
+ if (!secret)
33
+ throw new Error('Secret is not defined');
34
+ return value ? constants_1.cryptoUtils.encryptText(value, secret) : '';
35
+ }
36
+ });
37
+ const scalarAny = new type_1.GraphQLScalarType({
38
+ name: 'Any',
39
+ serialize(value) {
40
+ return value;
41
+ }
42
+ });
43
+ const GraphQLRegExp = new type_1.GraphQLScalarType({
44
+ name: 'RegExp',
45
+ description: 'JS RegExp represented as string',
46
+ serialize(value) {
47
+ return value;
48
+ },
49
+ parseValue(value) {
50
+ // if (Array.isArray(value))
51
+ // return value;
52
+ if (!(0, utils_1.isString)(value))
53
+ throw new Error(`Expected string, got ${typeof value}`);
54
+ return new RegExp(value, 'i');
55
+ },
56
+ parseLiteral(ast) {
57
+ switch (ast.kind) {
58
+ case language_1.Kind.STRING:
59
+ return new RegExp(ast.value, 'i');
60
+ default:
61
+ throw new Error(`Expected string, got ${ast.kind}`);
62
+ }
63
+ }
64
+ });
65
+ exports.resolvers = {
66
+ JSON: graphql_scalars_1.JSONResolver,
67
+ RegExp: GraphQLRegExp,
68
+ Date: scalarDate,
69
+ Encrypted: scalarEncrypted,
70
+ Any: scalarAny
71
+ };
@@ -0,0 +1 @@
1
+ export declare const typeDefs = "\n\n scalar JSON\n scalar Date\n scalar Encrypted\n scalar Any\n scalar RegExp\n";
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.typeDefs = void 0;
4
+ // The GraphQL schema in string form
5
+ exports.typeDefs = `
6
+
7
+ scalar JSON
8
+ scalar Date
9
+ scalar Encrypted
10
+ scalar Any
11
+ scalar RegExp
12
+ `;
@@ -0,0 +1,3 @@
1
+ export declare const typesSchema: {
2
+ typeDefs: string;
3
+ };
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.typesSchema = void 0;
4
+ const schema_1 = require("./schema");
5
+ // import { resolvers } from './resolvers';
6
+ exports.typesSchema = { typeDefs: schema_1.typeDefs };
@@ -0,0 +1 @@
1
+ export declare const typeDefs = "\n\n input OffsetPagination {\n offset: Int\n limit : Int\n sort : JSON\n }\n\n input ArrayCodedItem {\n _id : String\n id : String\n code: String\n name: String\n }\n\n input FilterDate {\n eq : Date\n from: Date\n to : Date\n }\n\n input AddArrayElemItem {\n path: String!\n data: JSON!\n }\n\n input UpdateArrayElemItem {\n path : String!\n filter : JSON!\n updateAttr: String\n partial : Boolean\n data : JSON!\n }\n\n input RemoveArrayElemItem {\n path : String!\n data : JSON!\n }\n\n input FolderItem {\n id : ID\n name : String\n description : String\n locked : Boolean\n folder : Boolean\n folderId : String\n ownerId : String\n users : [JSON]\n organizations: [JSON]\n }\n\n input FolderItemShareInput {\n users : [JSON]\n organizations: [JSON]\n }\n\n input BaseEntityInput {\n id : String\n code: String\n name: String\n }\n\n input AddressInfoInput {\n street : String\n city : String\n postalCode: String\n country : String\n }\n\n type CodedItem @shareable {\n _id : ID\n id : String\n code: String\n name: String\n }\n\n type FoldedItem @shareable {\n id : ID\n children: [JSON]\n }\n\n type File @shareable {\n filename: String!\n mimetype: String!\n encoding: String!\n }\n \n type AddressInfo @shareable {\n street : String\n city : String\n postalCode: String\n country : String\n }\n";
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.typeDefs = void 0;
4
+ // The GraphQL schema in string form
5
+ exports.typeDefs = `
6
+
7
+ input OffsetPagination {
8
+ offset: Int
9
+ limit : Int
10
+ sort : JSON
11
+ }
12
+
13
+ input ArrayCodedItem {
14
+ _id : String
15
+ id : String
16
+ code: String
17
+ name: String
18
+ }
19
+
20
+ input FilterDate {
21
+ eq : Date
22
+ from: Date
23
+ to : Date
24
+ }
25
+
26
+ input AddArrayElemItem {
27
+ path: String!
28
+ data: JSON!
29
+ }
30
+
31
+ input UpdateArrayElemItem {
32
+ path : String!
33
+ filter : JSON!
34
+ updateAttr: String
35
+ partial : Boolean
36
+ data : JSON!
37
+ }
38
+
39
+ input RemoveArrayElemItem {
40
+ path : String!
41
+ data : JSON!
42
+ }
43
+
44
+ input FolderItem {
45
+ id : ID
46
+ name : String
47
+ description : String
48
+ locked : Boolean
49
+ folder : Boolean
50
+ folderId : String
51
+ ownerId : String
52
+ users : [JSON]
53
+ organizations: [JSON]
54
+ }
55
+
56
+ input FolderItemShareInput {
57
+ users : [JSON]
58
+ organizations: [JSON]
59
+ }
60
+
61
+ input BaseEntityInput {
62
+ id : String
63
+ code: String
64
+ name: String
65
+ }
66
+
67
+ input AddressInfoInput {
68
+ street : String
69
+ city : String
70
+ postalCode: String
71
+ country : String
72
+ }
73
+
74
+ type CodedItem @shareable {
75
+ _id : ID
76
+ id : String
77
+ code: String
78
+ name: String
79
+ }
80
+
81
+ type FoldedItem @shareable {
82
+ id : ID
83
+ children: [JSON]
84
+ }
85
+
86
+ type File @shareable {
87
+ filename: String!
88
+ mimetype: String!
89
+ encoding: String!
90
+ }
91
+
92
+ type AddressInfo @shareable {
93
+ street : String
94
+ city : String
95
+ postalCode: String
96
+ country : String
97
+ }
98
+ `;
@@ -0,0 +1,18 @@
1
+ import { PubSub, FilterFn } from 'graphql-subscriptions';
2
+ import { GraphQLFieldResolver } from 'graphql';
3
+ import { BaseModel } from '../base/base.model';
4
+ import { NxContext } from '../interfaces';
5
+ export declare const pubsub: PubSub;
6
+ /**
7
+ *
8
+ * @param {*} subscriptionId
9
+ * @param {*} filterMethod (payload, variables, context) => true
10
+ */
11
+ export declare function getSubscriber<T>(subscriptionId: string, filterMethod: FilterFn): GraphQLFieldResolver<any, NxContext, any, unknown>;
12
+ /**
13
+ *
14
+ * @param {*} subscriptionId
15
+ * @param {*} payloadId
16
+ * @param {*} channelIdAttr
17
+ */
18
+ export declare function getChannelSubscriber<T>(subscriptionId: string, payloadId?: string, model?: BaseModel<any, any, any>, channelIdAttr?: string): GraphQLFieldResolver<any, NxContext, any, unknown>;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getChannelSubscriber = exports.getSubscriber = exports.pubsub = void 0;
4
+ const graphql_subscriptions_1 = require("graphql-subscriptions");
5
+ const utils_1 = require("../utils");
6
+ exports.pubsub = new graphql_subscriptions_1.PubSub();
7
+ /**
8
+ *
9
+ * @param {*} subscriptionId
10
+ * @param {*} filterMethod (payload, variables, context) => true
11
+ */
12
+ function getSubscriber(subscriptionId, filterMethod) {
13
+ // if (!filterMethod)
14
+ // return pubsub.asyncIterator<any>(subscriptionId);
15
+ return (0, graphql_subscriptions_1.withFilter)(() => exports.pubsub.asyncIterator(subscriptionId), filterMethod);
16
+ }
17
+ exports.getSubscriber = getSubscriber;
18
+ /**
19
+ *
20
+ * @param {*} subscriptionId
21
+ * @param {*} payloadId
22
+ * @param {*} channelIdAttr
23
+ */
24
+ function getChannelSubscriber(subscriptionId, payloadId, model, channelIdAttr = 'nxChannelId') {
25
+ payloadId !== null && payloadId !== void 0 ? payloadId : (payloadId = subscriptionId);
26
+ return getSubscriber(subscriptionId, (payload, variables, context) => {
27
+ const modelCheck = (model) ? model.checkChannelSubscriber(payload[payloadId], context) : Promise.resolve(true);
28
+ return context.user && payload[payloadId] && checkChannel(payload[payloadId][channelIdAttr], variables.channelId) && modelCheck; // payload[payloadId][channelIdAttr] === variables.channelId;
29
+ });
30
+ }
31
+ exports.getChannelSubscriber = getChannelSubscriber;
32
+ /**
33
+ *
34
+ * @param {*} channels
35
+ * @param {*} value
36
+ */
37
+ function checkChannel(channels, value) {
38
+ // return contains(channels, value) || channels === value;
39
+ return (0, utils_1.contains)(channels, value);
40
+ }
@@ -0,0 +1,53 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="mongoose/types/aggregate" />
3
+ /// <reference types="mongoose/types/callback" />
4
+ /// <reference types="mongoose/types/collection" />
5
+ /// <reference types="mongoose/types/connection" />
6
+ /// <reference types="mongoose/types/cursor" />
7
+ /// <reference types="mongoose/types/document" />
8
+ /// <reference types="mongoose/types/error" />
9
+ /// <reference types="mongoose/types/expressions" />
10
+ /// <reference types="mongoose/types/helpers" />
11
+ /// <reference types="mongoose/types/middlewares" />
12
+ /// <reference types="mongoose/types/indexes" />
13
+ /// <reference types="mongoose/types/models" />
14
+ /// <reference types="mongoose/types/mongooseoptions" />
15
+ /// <reference types="mongoose/types/pipelinestage" />
16
+ /// <reference types="mongoose/types/populate" />
17
+ /// <reference types="mongoose/types/query" />
18
+ /// <reference types="mongoose/types/schemaoptions" />
19
+ /// <reference types="mongoose/types/schematypes" />
20
+ /// <reference types="mongoose/types/session" />
21
+ /// <reference types="mongoose/types/types" />
22
+ /// <reference types="mongoose/types/utility" />
23
+ /// <reference types="mongoose/types/validation" />
24
+ /// <reference types="mongoose/types/virtuals" />
25
+ /// <reference types="mongoose/types/inferschematype" />
26
+ /// <reference types="mongoose/types/inferrawdoctype" />
27
+ import mongoose from 'mongoose';
28
+ import { Stream } from 'stream';
29
+ import { GridFSData, GridFSFileData, GridFSUploadOptions } from './gridfs.interfaces';
30
+ export declare class GridFsBaseModel {
31
+ private bucket?;
32
+ constructor({ bucketName, chunkSizeBytes, db, connection }: GridFSData);
33
+ /**
34
+ *
35
+ * @param { Stream } fileStream
36
+ */
37
+ uploadFile(fileStream: Stream, options: GridFSUploadOptions): Promise<unknown>;
38
+ /**
39
+ *
40
+ * @param {*} id File id
41
+ */
42
+ getFileInfo(id: mongoose.Types.ObjectId | string): Promise<mongoose.mongo.GridFSFile>;
43
+ /**
44
+ *
45
+ * @param {*} id File id
46
+ */
47
+ getFile(id: mongoose.Types.ObjectId | string): Promise<GridFSFileData>;
48
+ /**
49
+ *
50
+ * @param {*} id File id
51
+ */
52
+ removeFile(id: mongoose.Types.ObjectId | string): Promise<void>;
53
+ }
@@ -0,0 +1,95 @@
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.GridFsBaseModel = void 0;
13
+ const mongodb_1 = require("mongodb");
14
+ const constants_1 = require("../constants");
15
+ const mongo_utils_1 = require("../base/mongo-utils");
16
+ class GridFsBaseModel {
17
+ constructor({ bucketName, chunkSizeBytes, db, connection }) {
18
+ var _a;
19
+ if (!bucketName)
20
+ throw new Error('Error, you need to define at least bucketName');
21
+ const bucketOptions = {
22
+ chunkSizeBytes: chunkSizeBytes || 255 * 1024,
23
+ bucketName
24
+ };
25
+ if (db) {
26
+ this.bucket = new mongodb_1.GridFSBucket(db, bucketOptions);
27
+ return;
28
+ }
29
+ if (!connection)
30
+ connection = (_a = constants_1.APP.mongoose) === null || _a === void 0 ? void 0 : _a.connection;
31
+ if (!connection)
32
+ throw new Error('Error, you need to open mongo connection');
33
+ const promise = connection.db ? Promise.resolve(connection) : connection.asPromise();
34
+ promise.then((conn) => {
35
+ if (!conn)
36
+ return;
37
+ this.bucket = new mongodb_1.GridFSBucket(conn.db, bucketOptions);
38
+ });
39
+ }
40
+ /**
41
+ *
42
+ * @param { Stream } fileStream
43
+ */
44
+ uploadFile(fileStream, options) {
45
+ var _a;
46
+ if (!this.bucket)
47
+ throw new Error('Bucket not initialized');
48
+ const writeStream = (_a = this.bucket) === null || _a === void 0 ? void 0 : _a.openUploadStream(options.fileName, { metadata: options.metadata });
49
+ return new Promise((resolve, reject) => {
50
+ fileStream.pipe(writeStream).on('error', (error) => reject(error))
51
+ .on('finish', (fileInfo) => resolve(fileInfo));
52
+ });
53
+ }
54
+ /**
55
+ *
56
+ * @param {*} id File id
57
+ */
58
+ getFileInfo(id) {
59
+ return __awaiter(this, void 0, void 0, function* () {
60
+ var _a;
61
+ const gridFsFileInfo = yield ((_a = this.bucket) === null || _a === void 0 ? void 0 : _a.find({ _id: (0, mongo_utils_1.toObjectId)(id) }).next());
62
+ //TODO REJECT ERROR HANDLING
63
+ if (!gridFsFileInfo)
64
+ throw new Error(`File ${id} not found in bucket`);
65
+ return gridFsFileInfo;
66
+ });
67
+ }
68
+ /**
69
+ *
70
+ * @param {*} id File id
71
+ */
72
+ getFile(id) {
73
+ return __awaiter(this, void 0, void 0, function* () {
74
+ var _a;
75
+ const fileInfo = yield this.getFileInfo(id);
76
+ if (!fileInfo)
77
+ throw new Error('messages.fileNotFound');
78
+ if (!this.bucket)
79
+ throw new Error('Bucket not initialized');
80
+ const stream = (_a = this.bucket) === null || _a === void 0 ? void 0 : _a.openDownloadStream((0, mongo_utils_1.toObjectId)(id));
81
+ return { metadata: fileInfo.metadata || {}, stream };
82
+ });
83
+ }
84
+ /**
85
+ *
86
+ * @param {*} id File id
87
+ */
88
+ removeFile(id) {
89
+ var _a;
90
+ if (!this.bucket)
91
+ throw new Error('Bucket not initialized');
92
+ return (_a = this.bucket) === null || _a === void 0 ? void 0 : _a.delete((0, mongo_utils_1.toObjectId)(id));
93
+ }
94
+ }
95
+ exports.GridFsBaseModel = GridFsBaseModel;
@@ -0,0 +1,41 @@
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 { NxObject } from '../interfaces';
28
+ export interface GridFSData {
29
+ bucketName: string;
30
+ chunkSizeBytes?: number;
31
+ db?: mongoose.mongo.Db;
32
+ connection?: mongoose.Connection;
33
+ }
34
+ export interface GridFSUploadOptions {
35
+ fileName: string;
36
+ metadata: NxObject;
37
+ }
38
+ export interface GridFSFileData {
39
+ metadata: NxObject;
40
+ stream: mongoose.mongo.GridFSBucketReadStream;
41
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,10 @@
1
+ export * from './constants';
2
+ export * from './enums';
3
+ export * from './errors';
4
+ export * from './graphql';
5
+ export * from './interfaces';
6
+ export * from './types';
7
+ export * from './manager';
8
+ export * from './utils';
9
+ export * from './express';
10
+ export * from './crypto';
@@ -0,0 +1,32 @@
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("./constants"), exports);
18
+ __exportStar(require("./enums"), exports);
19
+ __exportStar(require("./errors"), exports);
20
+ __exportStar(require("./graphql"), exports);
21
+ __exportStar(require("./interfaces"), exports);
22
+ __exportStar(require("./types"), exports);
23
+ __exportStar(require("./manager"), exports);
24
+ __exportStar(require("./utils"), exports);
25
+ // export * from './models';
26
+ __exportStar(require("./express"), exports);
27
+ // export * from './nx-disk-storage';
28
+ __exportStar(require("./crypto"), exports);
29
+ // export * from './crypto-manager';
30
+ // export * from './pubsub-manager';
31
+ // export * from './tunnel-manager';
32
+ // export * from './tcpcli-manager';
@@ -0,0 +1,26 @@
1
+ import { Response } from 'express';
2
+ import { ModelCrudEventType, AuthIssuer } from './enums';
3
+ export interface NxContext {
4
+ access?: string;
5
+ user?: BaseUser;
6
+ userType?: AuthIssuer;
7
+ evtItem?: any;
8
+ evtType?: ModelCrudEventType;
9
+ userAgent?: string;
10
+ remoteAddress?: string;
11
+ res?: Response;
12
+ }
13
+ export declare abstract class BaseUser {
14
+ id?: string;
15
+ username?: string;
16
+ roles?: string[];
17
+ active?: boolean;
18
+ hasRole: (role: string | string[]) => boolean;
19
+ validPassword: (password: string) => Promise<boolean>;
20
+ }
21
+ export interface NxObject {
22
+ [key: string]: any;
23
+ }
24
+ export interface NxTypeObject<T> {
25
+ [key: string]: T;
26
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseUser = void 0;
4
+ class BaseUser {
5
+ constructor() {
6
+ this.hasRole = () => false;
7
+ this.validPassword = () => Promise.resolve(false);
8
+ }
9
+ }
10
+ exports.BaseUser = BaseUser;
@@ -0,0 +1,59 @@
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 { ClassElement } from 'typescript';
28
+ import { NxObject } from '../interfaces';
29
+ import { BaseModel } from '../base/base.model';
30
+ export declare class BulkManager {
31
+ private bulk?;
32
+ private model;
33
+ private logClass;
34
+ private logger;
35
+ constructor(model: BaseModel<any, any, any>, logClass: ClassElement, logger: any);
36
+ /**
37
+ *
38
+ */
39
+ reset(): void;
40
+ /**
41
+ *
42
+ * @param selector
43
+ * @param update
44
+ * @param multi
45
+ * @param upsert
46
+ * @returns
47
+ */
48
+ add(selector: NxObject, update: NxObject, multi?: boolean, upsert?: boolean): number | undefined;
49
+ /**
50
+ *
51
+ * @param {*} res
52
+ */
53
+ parseRes(res: mongoose.mongo.BulkWriteResult): void;
54
+ /**
55
+ *
56
+ * @param {*} callback
57
+ */
58
+ apply(callback: Function): Promise<void>;
59
+ }