@resolveio/server-lib 7.1.14 → 7.1.15-newrole

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.
@@ -22,13 +22,6 @@ var schema = {
22
22
  type: Date,
23
23
  optional: true
24
24
  },
25
- readonly: {
26
- type: Boolean,
27
- optional: true
28
- },
29
- active: {
30
- type: Boolean
31
- },
32
25
  attempts: {
33
26
  type: Number,
34
27
  optional: true
@@ -65,53 +58,67 @@ var schema = {
65
58
  type: String
66
59
  },
67
60
  roles: {
61
+ type: Object
62
+ },
63
+ 'roles.super_admin': {
64
+ type: Boolean
65
+ },
66
+ 'roles.approvals': {
68
67
  type: Array
69
68
  },
70
- 'roles.$': {
69
+ 'roles.approvals.$': {
70
+ type: Object
71
+ },
72
+ 'roles.approvals.$.name': {
71
73
  type: String
72
74
  },
73
- phonenumber: {
74
- type: String,
75
- optional: true
75
+ 'roles.approvals.$.type': {
76
+ type: String
76
77
  },
77
- other: {
78
- type: Object,
79
- blackbox: true,
80
- optional: true
78
+ 'roles.approvals.$.accounting_code': {
79
+ type: String
81
80
  },
82
- assets: {
83
- type: Array,
84
- optional: true
81
+ 'roles.groups': {
82
+ type: Array
85
83
  },
86
- 'assets.$': {
84
+ 'roles.groups.$': {
87
85
  type: Object
88
86
  },
89
- 'assets.$.type': {
87
+ 'roles.groups.$.name': {
90
88
  type: String
91
89
  },
92
- 'assets.$.id_asset': {
93
- type: String
90
+ 'roles.groups.$.views': {
91
+ type: Array
94
92
  },
95
- 'assets.$.asset_number': {
93
+ 'roles.groups.$.views.$': {
96
94
  type: String
97
95
  },
98
- 'assets.$.ownership': {
99
- type: String
96
+ 'roles.groups.$.yard': {
97
+ type: String,
98
+ optional: true
99
+ },
100
+ 'roles.notifications': {
101
+ type: Array
100
102
  },
101
- 'assets.$.ownership_driver': {
103
+ 'roles.notifications.$': {
102
104
  type: String
103
105
  },
104
- 'assets.$.date_start': {
105
- type: Date
106
+ 'roles.miscs': {
107
+ type: Array
106
108
  },
107
- 'assets.$.date_end': {
108
- type: Date,
109
- optional: true
109
+ 'roles.miscs.$': {
110
+ type: String
110
111
  },
111
- id_function: {
112
+ active: Boolean,
113
+ phonenumber: {
112
114
  type: String,
113
115
  optional: true
114
116
  },
117
+ other: {
118
+ type: Object,
119
+ optional: true,
120
+ blackbox: true
121
+ },
115
122
  customers: {
116
123
  type: Array,
117
124
  optional: true,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/collections/user.collection.ts"],"names":[],"mappings":";;AAAA,qCAAwG;AACxG,+DAAiE;AACjE,6CAAwC;AACxC,kCAA2C;AAG3C,uEAA8E;AAE9E,IAAI,MAAM,GAAQ;IACjB,GAAG,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;KACd;IACD,GAAG,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;KACd;IACD,SAAS,EAAE;QACV,IAAI,EAAE,IAAI;QACV,QAAQ,EAAE,IAAI;KACd;IACD,SAAS,EAAE;QACV,IAAI,EAAE,IAAI;QACV,QAAQ,EAAE,IAAI;KACd;IACD,QAAQ,EAAE;QACT,IAAI,EAAE,OAAO;QACb,QAAQ,EAAE,IAAI;KACd;IACD,MAAM,EAAE;QACP,IAAI,EAAE,OAAO;KACb;IACD,QAAQ,EAAE;QACT,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;KACd;IACD,IAAI,EAAE;QACL,IAAI,EAAE,IAAI;QACV,QAAQ,EAAE,IAAI;KACd;IACD,QAAQ,EAAE;QACT,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;KACd;IACD,qBAAqB,EAAE;QACtB,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;KACd;IACD,0BAA0B,EAAE;QAC3B,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;KACd;IACD,yBAAyB,EAAE;QAC1B,IAAI,EAAE,MAAM;QACZ,QA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;IACpB,UAAU,EAAE,KAAK;IACjB,UAAU,EAAE,IAAI;CAChB,CAAC,CAAC;AAEH,aAAa,CAAC,KAAK,CAAC,EAAC,SAAS,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAC,CAAC,CAAC;AAElD,aAAK,CAAC,mBAAmB,CAAC,GAAG,gBAAgB,CAAC;AAEjC,QAAA,YAAY,GAA0B,uBAAe,CAAC,SAAS,EAAE,CAAC,KAAK,CAAC,aAAK,CAAC,mBAAmB,CAAC,EAAE,aAAa,CAAC,CAAC;AAEhI,qCAAqC;AACrC,IAAI,SAAS,GAAmB,EAAE,CAAC;AAEnC,IAAI,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,sCAAc,CAAC,SAAS,EAAE,aAAa,EAAE,EAAE,CAAC,CAAC,CAAC;AACnF,aAAK,CAAC,UAAU,CAAC,GAAG,qCAAa,CAAC,QAAQ,CAAC,CAAC","file":"user.collection.js","sourcesContent":["import { Schema, Model, PassportLocalDocument, PassportLocalModel, PassportLocalSchema} from 'mongoose';\nimport * as passportLocalMongoose from 'passport-local-mongoose';\nimport SimpleSchema from 'simpl-schema';\nimport { ResolveIOServer } from '../index';\nimport { UserModel } from '../models/user.model';\nimport { LookupTables } from '../models/report-builder.model';\nimport { buildRbSchema, buildRbLookups } from '../util/schema-report-builder';\n\nlet schema: any = {\n\t_id: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\t__v: {\n\t\ttype: Number,\n\t\toptional: true\n\t},\n\tupdatedAt: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tcreatedAt: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\treadonly: {\n\t\ttype: Boolean,\n\t\toptional: true\n\t},\n\tactive: {\n\t\ttype: Boolean\n\t},\n\tattempts: {\n\t\ttype: Number,\n\t\toptional: true\n\t},\n\tlast: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tservices: {\n\t\ttype: Object,\n\t\toptional: true\n\t},\n\t'services.enrollment': {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\t'services.forgot_password': {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\t'services.reset_password': {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tusername: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\temail: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tfullname: {\n\t\ttype: String\n\t},\n\troles: {\n\t\ttype: Array\n\t},\n\t'roles.$': {\n\t\ttype: String\n\t},\n\tphonenumber: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tother: {\n\t\ttype: Object,\n\t\tblackbox: true,\n\t\toptional: true\n\t},\n\tassets: {\n\t\ttype: Array,\n\t\toptional: true\n\t},\n\t'assets.$': {\n\t\ttype: Object\n\t},\n\t'assets.$.type': {\n\t\ttype: String\n\t},\n\t'assets.$.id_asset': {\n\t\ttype: String\n\t},\n\t'assets.$.asset_number': {\n\t\ttype: String\n\t},\n\t'assets.$.ownership': {\n\t\ttype: String\n\t},\n\t'assets.$.ownership_driver': {\n\t\ttype: String\n\t},\n\t'assets.$.date_start': {\n\t\ttype: Date\n\t},\n\t'assets.$.date_end': {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tid_function: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tcustomers: {\n\t\ttype: Array,\n\t\toptional: true,\n\t},\n\t'customers.$': {\n\t\ttype: Object\n\t},\n\t'customers.$.id_customer': {\n\t\ttype: String\n\t},\n\t'customers.$.customer': {\n\t\ttype: String\n\t},\n\tid_customer: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tcustomer: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tcustomer_type: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tdepartments: {\n\t\ttype: Array,\n\t\toptional: true\n\t},\n\t'departments.$': {\n\t\ttype: Object\n\t},\n\t'departments.$.id_department': {\n\t\ttype: String\n\t},\n\t'departments.$.department': {\n\t\ttype: String\n\t}\n};\n\nconst DefaultSchema = <PassportLocalSchema>new Schema(schema, {\n\tskipVersioning: true,\n\tversionKey: false,\n\ttimestamps: true\n});\n\nDefaultSchema.plugin(passportLocalMongoose, {\n\tusernameUnique: true,\n\tlimitAttempts: true,\n\tmaxAttempts: 5,\n\tfindByUsername: (mongooseModel, queryParameters) => {\n\t\t// Add additional query parameter - AND condition - active: true\n\t\tqueryParameters.active = true;\n\t\treturn mongooseModel.findOne(queryParameters);\n\t}\n});\n\ninterface ResolveIOModel extends UserModel, PassportLocalDocument {}\nexport const Users: PassportLocalModel<ResolveIOModel> = (<any>ResolveIOServer.getMainDB()).model('users', DefaultSchema);\n\nUsers['simplschema'] = new SimpleSchema(schema);\n\nschema._id = {\n\ttype: Schema.Types.Mixed\n};\n\nlet VersionSchema = new Schema(schema, {\n\tskipVersioning: true,\n\tversionKey: false,\n\ttimestamps: true\n});\n\nVersionSchema.index({'_id.__v': 1, '_id._id': 1});\n\nUsers['versionCollection'] = 'users.versions';\n\nexport const UserVersions: Model<ResolveIOModel> = ResolveIOServer.getMainDB().model(Users['versionCollection'], VersionSchema);\n\n//------------- Report Builder Schema\nlet rbLookups: LookupTables[] = [];\n\nlet rbSchema = Object.assign(schema, buildRbLookups(rbLookups, DefaultSchema, []));\nUsers['rbSchema'] = buildRbSchema(rbSchema);"]}
1
+ {"version":3,"sources":["../../src/collections/user.collection.ts"],"names":[],"mappings":";;AAAA,qCAAwG;AACxG,+DAAiE;AACjE,6CAAwC;AACxC,kCAA2C;AAG3C,uEAA8E;AAE9E,IAAI,MAAM,GAAQ;IACjB,GAAG,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;KACd;IACD,GAAG,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;KACd;IACD,SAAS,EAAE;QACV,IAAI,EAAE,IAAI;QACV,QAAQ,EAAE,IAAI;KACd;IACD,SAAS,EAAE;QACV,IAAI,EAAE,IAAI;QACV,QAAQ,E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","file":"user.collection.js","sourcesContent":["import { Schema, Model, PassportLocalDocument, PassportLocalModel, PassportLocalSchema} from 'mongoose';\nimport * as passportLocalMongoose from 'passport-local-mongoose';\nimport SimpleSchema from 'simpl-schema';\nimport { ResolveIOServer } from '../index';\nimport { UserModel } from '../models/user.model';\nimport { LookupTables } from '../models/report-builder.model';\nimport { buildRbSchema, buildRbLookups } from '../util/schema-report-builder';\n\nlet schema: any = {\n\t_id: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\t__v: {\n\t\ttype: Number,\n\t\toptional: true\n\t},\n\tupdatedAt: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tcreatedAt: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tattempts: {\n\t\ttype: Number,\n\t\toptional: true\n\t},\n\tlast: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tservices: {\n\t\ttype: Object,\n\t\toptional: true\n\t},\n\t'services.enrollment': {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\t'services.forgot_password': {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\t'services.reset_password': {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tusername: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\temail: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tfullname: {\n\t\ttype: String\n\t},\n\troles: {\n\t\ttype: Object\n\t},\n\t'roles.super_admin': {\n\t\ttype: Boolean\n\t},\n\t'roles.approvals': {\n\t\ttype: Array\n\t},\n\t'roles.approvals.$': {\n\t\ttype: Object\n\t},\n\t'roles.approvals.$.name': {\n\t\ttype: String\n\t},\n\t'roles.approvals.$.type': {\n\t\ttype: String\n\t},\n\t'roles.approvals.$.accounting_code': {\n\t\ttype: String\n\t},\n\t'roles.groups': {\n\t\ttype: Array\n\t},\n\t'roles.groups.$': {\n\t\ttype: Object\n\t},\n\t'roles.groups.$.name': {\n\t\ttype: String\n\t},\n\t'roles.groups.$.views': {\n\t\ttype: Array\n\t},\n\t'roles.groups.$.views.$': {\n\t\ttype: String\n\t},\n\t'roles.groups.$.yard': {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\t'roles.notifications': {\n\t\ttype: Array\n\t},\n\t'roles.notifications.$': {\n\t\ttype: String\n\t},\n\t'roles.miscs': {\n\t\ttype: Array\n\t},\n\t'roles.miscs.$': {\n\t\ttype: String\n\t},\n\tactive: Boolean,\n\tphonenumber: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tother: {\n\t\ttype: Object,\n\t\toptional: true,\n\t\tblackbox: true\n\t},\n\tcustomers: {\n\t\ttype: Array,\n\t\toptional: true,\n\t},\n\t'customers.$': {\n\t\ttype: Object\n\t},\n\t'customers.$.id_customer': {\n\t\ttype: String\n\t},\n\t'customers.$.customer': {\n\t\ttype: String\n\t},\n\tid_customer: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tcustomer: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tcustomer_type: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tdepartments: {\n\t\ttype: Array,\n\t\toptional: true\n\t},\n\t'departments.$': {\n\t\ttype: Object\n\t},\n\t'departments.$.id_department': {\n\t\ttype: String\n\t},\n\t'departments.$.department': {\n\t\ttype: String\n\t}\n};\n\nconst DefaultSchema = <PassportLocalSchema>new Schema(schema, {\n\tskipVersioning: true,\n\tversionKey: false,\n\ttimestamps: true\n});\n\nDefaultSchema.plugin(passportLocalMongoose, {\n\tusernameUnique: true,\n\tlimitAttempts: true,\n\tmaxAttempts: 5,\n\tfindByUsername: (mongooseModel, queryParameters) => {\n\t\t// Add additional query parameter - AND condition - active: true\n\t\tqueryParameters.active = true;\n\t\treturn mongooseModel.findOne(queryParameters);\n\t}\n});\n\ninterface ResolveIOModel extends UserModel, PassportLocalDocument {}\nexport const Users: PassportLocalModel<ResolveIOModel> = (<any>ResolveIOServer.getMainDB()).model('users', DefaultSchema);\n\nUsers['simplschema'] = new SimpleSchema(schema);\n\nschema._id = {\n\ttype: Schema.Types.Mixed\n};\n\nlet VersionSchema = new Schema(schema, {\n\tskipVersioning: true,\n\tversionKey: false,\n\ttimestamps: true\n});\n\nVersionSchema.index({'_id.__v': 1, '_id._id': 1});\n\nUsers['versionCollection'] = 'users.versions';\n\nexport const UserVersions: Model<ResolveIOModel> = ResolveIOServer.getMainDB().model(Users['versionCollection'], VersionSchema);\n\n//------------- Report Builder Schema\nlet rbLookups: LookupTables[] = [];\n\nlet rbSchema = Object.assign(schema, buildRbLookups(rbLookups, DefaultSchema, []));\nUsers['rbSchema'] = buildRbSchema(rbSchema);"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/methods/accounts.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAwC;AACxC,qCAAiC;AACjC,kEAAuD;AACvD,uCAAyC;AACzC,kCAAoC;AACpC,wFAA0E;AAC1E,sFAA0E;AAE1E,kCAA2C;AAG3C,SAAgB,kBAAkB,CAAC,aAA4B;IAC9D,aAAa,CAAC,OAAO,CAAC;QACrB,eAAe,EAAE;YAChB,SAAS,EAAE,IAAI;YACf,KAAK,EAAE,IAAI,sBAAY,CAAC;gBACvB,OAAO,EAAE,MAAM;aACf,CAAC;YACF,QAAQ,EAAE,UAAS,OAAO;gBACzB,OAAO,0CAAa,CAAC,SAAS,CAAC,EAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAC,EAAE,EAAC,IAAI,EAAE,EAAC,WAAW,EAAE,OAAO,EAAC,EAAC,CAAC,CAAC,IAAI,EAAE,CAAC;YAC5F,CAAC;SACD;QACD,QAAQ,EAAE;YACT,SAAS,EAAE,IAAI;YACf,KAAK,EAAE,IAAI,sBAAY,CAAC;gBACvB,KAAK,EAAE,MAAM;aACb,CAAC;YACF,QAAQ,EAAE,UAAS,KAAK;gBAAd,iBAwBT;gBAvBA,OAAO,IAAI,OAAO,CAAC,UAAO,OAAO,EAAE,MAAM;;wBACxC,0CAAc,CAAC,MAAM,C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AAE;QAAE,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;KAAE;IAC/F,OAAO,MAAM,CAAC;AACf,CAAC","file":"accounts.js","sourcesContent":["import SimpleSchema from 'simpl-schema';\nimport { Types } from 'mongoose';\nimport { Users } from '../collections/user.collection';\nimport * as handlebars from 'handlebars';\nimport * as jwt from 'jsonwebtoken';\nimport { LoggedInUsers } from '../collections/logged-in-users.collection';\nimport { QueueResponses } from '../collections/queue-response.collection';\nimport { MethodManager } from '../managers/method.manager';\nimport { ResolveIOServer } from '../index';\nimport { UserModel } from '../models/user.model';\n\nexport function loadAccountMethods(methodManager: MethodManager) {\n\tmethodManager.methods({\n\t\tsetWSAppVersion: {\n\t\t\tskipQueue: true,\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tversion: Number\n\t\t\t}),\n\t\t\tfunction: function(version) {\n\t\t\t\treturn LoggedInUsers.updateOne({id_ws: this.id_ws}, {$set: {app_version: version}}).exec();\n\t\t\t}\n\t\t},\n\t\treloadWS: {\n\t\t\tskipQueue: true,\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tid_ws: String\n\t\t\t}),\n\t\t\tfunction: function(id_ws) {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\n\t\t\t\t\tQueueResponses.create({\n\t\t\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\tmethod: 'reloadWSCommand',\n\t\t\t\t\t\tmethod_data: [],\n\t\t\t\t\t\tid_ws: id_ws,\n\t\t\t\t\t\tmessageId: 0,\n\t\t\t\t\t\tid_user: this.id_user,\n\t\t\t\t\t\tuser: this.user,\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tmessageId: 0,\n\t\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\t\tdata: 'reloadWSCommand'\n\t\t\t\t\t\t}\n\t\t\t\t\t}).then(val => {\n\t\t\t\t\t\t// console.log(val);\n\t\t\t\t\t}, err => {\n\t\t\t\t\t\tconsole.log(err);\n\t\t\t\t\t});\n\n\t\t\t\t\tresolve();\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\treconnectWS: {\n\t\t\tskipQueue: true,\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tid_ws: String\n\t\t\t}),\n\t\t\tfunction: function(id_ws) {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\n\t\t\t\t\tQueueResponses.create({\n\t\t\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\tmethod: 'reconnectWSCommand',\n\t\t\t\t\t\tmethod_data: [],\n\t\t\t\t\t\tid_ws: id_ws,\n\t\t\t\t\t\tmessageId: 0,\n\t\t\t\t\t\tid_user: this.id_user,\n\t\t\t\t\t\tuser: this.user,\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tmessageId: 0,\n\t\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\t\tdata: 'reconnectWSCommand'\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\n\t\t\t\t\tresolve();\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\tdisconnectWS: {\n\t\t\tskipQueue: true,\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tid_ws: String\n\t\t\t}),\n\t\t\tfunction: function(id_ws) {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\n\t\t\t\t\tQueueResponses.create({\n\t\t\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\tmethod: 'disconnectWSCommand',\n\t\t\t\t\t\tmethod_data: [],\n\t\t\t\t\t\tid_ws: id_ws,\n\t\t\t\t\t\tmessageId: 0,\n\t\t\t\t\t\tid_user: this.id_user,\n\t\t\t\t\t\tuser: this.user,\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tmessageId: 0,\n\t\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\t\tdata: 'disconnectWSCommand'\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\n\t\t\t\t\tresolve();\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\tcreateUserAndEmailEnrollment: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tdata: {\n\t\t\t\t\ttype: Users['simplschema']\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: function(data) {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\n\t\t\t\t\tlet userId = Types.ObjectId().toHexString();\n\n\t\t\t\t\tlet newUser = {\n\t\t\t\t\t\t_id: userId,\n\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\tusername: data.username, \n\t\t\t\t\t\temail: data.email,\n\t\t\t\t\t\tfullname: data.fullname,\n\t\t\t\t\t\troles: data.roles,\n\t\t\t\t\t\tactive: true,\n\t\t\t\t\t\treadonly: false,\n\t\t\t\t\t\tservices: {\n\t\t\t\t\t\t\tenrollment: jwt.sign({id_user: userId}, this.serverConfig['JWT_SECRET'], {\n\t\t\t\t\t\t\t\texpiresIn : 3 * 24 * 60 * 60 * 1000 // 3 days\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t},\n\t\t\t\t\t\tphonenumber: data.phonenumber,\n\t\t\t\t\t\tother: {}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (data['departments']) {\n\t\t\t\t\t\tnewUser['departments'] = data['departments'];\n\t\t\t\t\t}\n\n\t\t\t\t\tif (data['other']) {\n\t\t\t\t\t\tnewUser['other'] = data['other'];\n\t\t\t\t\t}\n\n\t\t\t\t\tlet user = await Users.create(newUser);\n\n\t\t\t\t\tuser.setPassword(randomString(20, '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'), ((err, res) => {\n\t\t\t\t\t\tuser.resetAttempts();\n\n\t\t\t\t\t\tlet emailData = {\n\t\t\t\t\t\t\tfullname: user.fullname,\n\t\t\t\t\t\t\tuser: this.user,\n\t\t\t\t\t\t\turl: this.serverConfig['ROOT_URL'] + '/enroll-account?' + encodeURIComponent(this.serverConfig['SERVER_URL']) + '&' + user.services.enrollment\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tthis.readFile('email-templates/enrollment.html').then(html => {\n\t\t\t\t\t\t\tlet template = handlebars.compile(html);\n\t\t\t\t\t\t\thandlebars.registerHelper('equals', (a, b) => {\n\t\t\t\t\t\t\t\treturn a === b;\n\t\t\t\t\t\t\t});\n\t\t\n\t\t\t\t\t\t\tthis.sendEmail(user.email, 'ResolveIO (' + ResolveIOServer.getClientName() + ') - Enrollment Email', '', template(emailData));\n\t\t\n\t\t\t\t\t\t\tresolve(user);\n\t\t\t\t\t\t}, errEmail => reject(errEmail));\n\t\t\t\t\t}));\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\tresetUserPassword: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tuserId: {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: function(userId: string) {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\t\t\t\t\n\t\t\t\t\tlet user = await Users.findOne({_id: userId});\n\t\t\n\t\t\t\t\tif (user) {\n\n\t\t\t\t\t\tuser.services.forgot_password = jwt.sign({id_user: userId}, this.serverConfig['JWT_SECRET']);\n\n\t\t\t\t\t\tlet emailData = {\n\t\t\t\t\t\t\tuserToChangePassword: user.fullname,\n\t\t\t\t\t\t\tuserWhoResetPassword: this.user,\n\t\t\t\t\t\t\turl: this.serverConfig['ROOT_URL'] + '/forgot-password?' + encodeURIComponent(this.serverConfig['SERVER_URL']) + '&' + user.services.forgot_password\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tUsers.updateOne({_id: user._id}, {$set: {services: user.services}}).exec((err, res) => {\n\t\t\t\t\t\t\tthis.readFile('email-templates/forgot-password.html').then(html => {\n\t\t\t\t\t\t\t\tlet template = handlebars.compile(html);\n\t\t\t\t\t\t\t\thandlebars.registerHelper('equals', (a, b) => {\n\t\t\t\t\t\t\t\t\treturn a === b;\n\t\t\t\t\t\t\t\t});\n\t\t\t\n\t\t\t\t\t\t\t\tthis.sendEmail(user.email, 'ResolveIO (' + ResolveIOServer.getClientName() + ') - Forgot Password', '', template(emailData));\n\t\t\t\n\t\t\t\t\t\t\t\tresolve(true);\n\t\t\t\t\t\t\t}, errEmail => reject(errEmail));\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t});\n}\n\nfunction randomString(length, chars) {\n\tlet result = '';\n\tfor (let i = length; i > 0; --i) { result += chars[Math.floor(Math.random() * chars.length)]; }\n\treturn result;\n}"]}
1
+ {"version":3,"sources":["../../src/methods/accounts.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAwC;AACxC,qCAAiC;AACjC,kEAAuD;AACvD,uCAAyC;AACzC,kCAAoC;AACpC,wFAA0E;AAC1E,sFAA0E;AAE1E,kCAA2C;AAG3C,SAAgB,kBAAkB,CAAC,aAA4B;IAC9D,aAAa,CAAC,OAAO,CAAC;QACrB,eAAe,EAAE;YAChB,SAAS,EAAE,IAAI;YACf,KAAK,EAAE,IAAI,sBAAY,CAAC;gBACvB,OAAO,EAAE,MAAM;aACf,CAAC;YACF,QAAQ,EAAE,UAAS,OAAO;gBACzB,OAAO,0CAAa,CAAC,SAAS,CAAC,EAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAC,EAAE,EAAC,IAAI,EAAE,EAAC,WAAW,EAAE,OAAO,EAAC,EAAC,CAAC,CAAC,IAAI,EAAE,CAAC;YAC5F,CAAC;SACD;QACD,QAAQ,EAAE;YACT,SAAS,EAAE,IAAI;YACf,KAAK,EAAE,IAAI,sBAAY,CAAC;gBACvB,KAAK,EAAE,MAAM;aACb,CAAC;YACF,QAAQ,EAAE,UAAS,KAAK;gBAAd,iBAwBT;gBAvBA,OA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B,KAAK,IAAI,CAAC,GAAG,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;KAAE;IAC/F,OAAO,MAAM,CAAC;AACf,CAAC","file":"accounts.js","sourcesContent":["import SimpleSchema from 'simpl-schema';\nimport { Types } from 'mongoose';\nimport { Users } from '../collections/user.collection';\nimport * as handlebars from 'handlebars';\nimport * as jwt from 'jsonwebtoken';\nimport { LoggedInUsers } from '../collections/logged-in-users.collection';\nimport { QueueResponses } from '../collections/queue-response.collection';\nimport { MethodManager } from '../managers/method.manager';\nimport { ResolveIOServer } from '../index';\nimport { UserModel } from '../models/user.model';\n\nexport function loadAccountMethods(methodManager: MethodManager) {\n\tmethodManager.methods({\n\t\tsetWSAppVersion: {\n\t\t\tskipQueue: true,\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tversion: Number\n\t\t\t}),\n\t\t\tfunction: function(version) {\n\t\t\t\treturn LoggedInUsers.updateOne({id_ws: this.id_ws}, {$set: {app_version: version}}).exec();\n\t\t\t}\n\t\t},\n\t\treloadWS: {\n\t\t\tskipQueue: true,\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tid_ws: String\n\t\t\t}),\n\t\t\tfunction: function(id_ws) {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\n\t\t\t\t\tQueueResponses.create({\n\t\t\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\tmethod: 'reloadWSCommand',\n\t\t\t\t\t\tmethod_data: [],\n\t\t\t\t\t\tid_ws: id_ws,\n\t\t\t\t\t\tmessageId: 0,\n\t\t\t\t\t\tid_user: this.id_user,\n\t\t\t\t\t\tuser: this.user,\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tmessageId: 0,\n\t\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\t\tdata: 'reloadWSCommand'\n\t\t\t\t\t\t}\n\t\t\t\t\t}).then(val => {\n\t\t\t\t\t\t// console.log(val);\n\t\t\t\t\t}, err => {\n\t\t\t\t\t\tconsole.log(err);\n\t\t\t\t\t});\n\n\t\t\t\t\tresolve();\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\treconnectWS: {\n\t\t\tskipQueue: true,\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tid_ws: String\n\t\t\t}),\n\t\t\tfunction: function(id_ws) {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\n\t\t\t\t\tQueueResponses.create({\n\t\t\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\tmethod: 'reconnectWSCommand',\n\t\t\t\t\t\tmethod_data: [],\n\t\t\t\t\t\tid_ws: id_ws,\n\t\t\t\t\t\tmessageId: 0,\n\t\t\t\t\t\tid_user: this.id_user,\n\t\t\t\t\t\tuser: this.user,\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tmessageId: 0,\n\t\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\t\tdata: 'reconnectWSCommand'\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\n\t\t\t\t\tresolve();\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\tdisconnectWS: {\n\t\t\tskipQueue: true,\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tid_ws: String\n\t\t\t}),\n\t\t\tfunction: function(id_ws) {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\n\t\t\t\t\tQueueResponses.create({\n\t\t\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\tmethod: 'disconnectWSCommand',\n\t\t\t\t\t\tmethod_data: [],\n\t\t\t\t\t\tid_ws: id_ws,\n\t\t\t\t\t\tmessageId: 0,\n\t\t\t\t\t\tid_user: this.id_user,\n\t\t\t\t\t\tuser: this.user,\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tmessageId: 0,\n\t\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\t\tdata: 'disconnectWSCommand'\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\n\t\t\t\t\tresolve();\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\tcreateUserAndEmailEnrollment: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tdata: {\n\t\t\t\t\ttype: Users['simplschema']\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: function(data) {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\n\t\t\t\t\tlet userId = Types.ObjectId().toHexString();\n\n\t\t\t\t\tlet newUser = {\n\t\t\t\t\t\t_id: userId,\n\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\tusername: data.username, \n\t\t\t\t\t\temail: data.email,\n\t\t\t\t\t\tfullname: data.fullname,\n\t\t\t\t\t\troles: data.roles,\n\t\t\t\t\t\tactive: true,\n\t\t\t\t\t\treadonly: false,\n\t\t\t\t\t\tservices: {\n\t\t\t\t\t\t\tenrollment: jwt.sign({id_user: userId}, this.serverConfig['JWT_SECRET'], {\n\t\t\t\t\t\t\t\texpiresIn : 3 * 24 * 60 * 60 * 1000 // 3 days\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t},\n\t\t\t\t\t\tphonenumber: data.phonenumber,\n\t\t\t\t\t\tother: {}\n\t\t\t\t\t};\n\n\t\t\t\t\tif (data['departments']) {\n\t\t\t\t\t\tnewUser['departments'] = data['departments'];\n\t\t\t\t\t}\n\n\t\t\t\t\tif (data['other']) {\n\t\t\t\t\t\tnewUser['other'] = data['other'];\n\t\t\t\t\t}\n\n\t\t\t\t\tlet user = await Users.create(newUser);\n\n\t\t\t\t\tuser.setPassword(randomString(20, '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'), ((err, res) => {\n\t\t\t\t\t\tuser.resetAttempts();\n\n\t\t\t\t\t\tlet emailData = {\n\t\t\t\t\t\t\tfullname: user.fullname,\n\t\t\t\t\t\t\tuser: this.user,\n\t\t\t\t\t\t\turl: this.serverConfig['ROOT_URL'] + '/enroll-account?' + encodeURIComponent(this.serverConfig['SERVER_URL']) + '&' + user.services.enrollment\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tthis.readFile('email-templates/enrollment.html').then(html => {\n\t\t\t\t\t\t\tlet template = handlebars.compile(html);\n\t\t\t\t\t\t\thandlebars.registerHelper('equals', (a, b) => {\n\t\t\t\t\t\t\t\treturn a === b;\n\t\t\t\t\t\t\t});\n\t\t\n\t\t\t\t\t\t\tthis.sendEmail(user.email, 'ResolveIO (' + ResolveIOServer.getClientName() + ') - Enrollment Email', '', template(emailData));\n\t\t\n\t\t\t\t\t\t\tresolve(user);\n\t\t\t\t\t\t}, errEmail => reject(errEmail));\n\t\t\t\t\t}));\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\tresetUserPassword: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tuserId: {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: function(userId: string) {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\t\t\t\t\n\t\t\t\t\tlet user = await Users.findOne({_id: userId});\n\t\t\n\t\t\t\t\tif (user) {\n\n\t\t\t\t\t\tuser.services.forgot_password = jwt.sign({id_user: userId}, this.serverConfig['JWT_SECRET']);\n\n\t\t\t\t\t\tlet emailData = {\n\t\t\t\t\t\t\tuserToChangePassword: user.fullname,\n\t\t\t\t\t\t\tuserWhoResetPassword: this.user,\n\t\t\t\t\t\t\turl: this.serverConfig['ROOT_URL'] + '/forgot-password?' + encodeURIComponent(this.serverConfig['SERVER_URL']) + '&' + user.services.forgot_password\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tUsers.updateOne({_id: user._id}, {$set: {services: user.services}}).exec((err, res) => {\n\t\t\t\t\t\t\tthis.readFile('email-templates/forgot-password.html').then(html => {\n\t\t\t\t\t\t\t\tlet template = handlebars.compile(html);\n\t\t\t\t\t\t\t\thandlebars.registerHelper('equals', (a, b) => {\n\t\t\t\t\t\t\t\t\treturn a === b;\n\t\t\t\t\t\t\t\t});\n\t\t\t\n\t\t\t\t\t\t\t\tthis.sendEmail(user.email, 'ResolveIO (' + ResolveIOServer.getClientName() + ') - Forgot Password', '', template(emailData));\n\t\t\t\n\t\t\t\t\t\t\t\tresolve(true);\n\t\t\t\t\t\t\t}, errEmail => reject(errEmail));\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t});\n}\n\nfunction randomString(length, chars) {\n\tlet result = '';\n\tfor (let i = length; i > 0; --i) { result += chars[Math.floor(Math.random() * chars.length)]; }\n\treturn result;\n}"]}
@@ -42,6 +42,7 @@ var monitor_https_outbound_collection_1 = require("../collections/monitor-https-
42
42
  var monitor_https_inbound_collection_1 = require("../collections/monitor-https-inbound.collection");
43
43
  var monitor_memory_collection_1 = require("../collections/monitor-memory.collection");
44
44
  var __1 = require("..");
45
+ var common_1 = require("../util/common");
45
46
  function loadMonitorMethods(methodManager) {
46
47
  methodManager.methods({
47
48
  superadminMonitor: {
@@ -49,10 +50,10 @@ function loadMonitorMethods(methodManager) {
49
50
  function: function (date_start, date_end, collection, instance, client, graphInterval, variable, variableType) {
50
51
  var _this = this;
51
52
  return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
52
- var groupId, groupDate, query, graphData;
53
- var _a, _b, _c, _d, _e, _f, _g;
54
- return __generator(this, function (_h) {
55
- switch (_h.label) {
53
+ var groupId, groupDate, query, firstGroupId, graphData;
54
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
55
+ return __generator(this, function (_p) {
56
+ switch (_p.label) {
56
57
  case 0:
57
58
  groupId = {};
58
59
  groupDate = {};
@@ -242,33 +243,22 @@ function loadMonitorMethods(methodManager) {
242
243
  if (instance) {
243
244
  query[0]['$match'].$and.push({ instance: instance });
244
245
  }
245
- if (variableType === 'count') {
246
- query.push({
247
- $group: {
248
- _id: groupId,
249
- count: {
250
- $sum: 1
251
- },
252
- date: {
253
- $first: '$date'
254
- },
255
- client: {
256
- $first: '$client'
257
- },
258
- instance: {
259
- $first: '$instance'
260
- }
261
- }
262
- });
246
+ firstGroupId = common_1.deepCopy(groupId);
247
+ if (collection === 'monitor-mongos') {
248
+ firstGroupId[variable] = '$' + variable;
249
+ groupDate['data'] = '$data';
263
250
  }
264
- else {
251
+ if (collection === 'monitor-mongos') {
265
252
  query.push({
266
253
  $group: (_e = {
267
- _id: groupId
254
+ _id: firstGroupId
255
+ },
256
+ _e[variable] = {
257
+ '$sum': 1
258
+ },
259
+ _e[variable + '_name'] = {
260
+ $first: '$' + [variable]
268
261
  },
269
- _e[variable] = (_f = {},
270
- _f['$' + variableType] = '$' + variable,
271
- _f),
272
262
  _e.date = {
273
263
  $first: '$date'
274
264
  },
@@ -281,20 +271,75 @@ function loadMonitorMethods(methodManager) {
281
271
  _e)
282
272
  });
283
273
  query.push({
284
- $addFields: (_g = {},
285
- _g[variable] = groupDate,
274
+ $addFields: {
275
+ data: (_f = {},
276
+ _f[variable] = '$' + variable,
277
+ _f[variable + '_name'] = '$' + variable + '_name',
278
+ _f)
279
+ }
280
+ });
281
+ query.push({
282
+ $group: (_g = {
283
+ _id: groupId
284
+ },
285
+ _g[variable] = {
286
+ '$sum': '$data.' + variable
287
+ },
288
+ _g.data = {
289
+ $push: '$data'
290
+ },
286
291
  _g)
287
292
  });
288
293
  query.push({
289
- $group: {
290
- _id: {
291
- client: '$_id.client',
292
- instance: '$_id.instance'
294
+ $addFields: (_h = {},
295
+ _h[variable] = groupDate,
296
+ _h)
297
+ });
298
+ query.push({
299
+ $group: (_j = {
300
+ _id: {
301
+ client: '$_id.client',
302
+ instance: '$_id.instance'
303
+ },
304
+ data: {
305
+ $push: '$' + variable
306
+ }
293
307
  },
294
- data: {
295
- $push: '$' + variable
296
- }
297
- }
308
+ _j[variable] = {
309
+ $sum: '$' + variable + '.' + variable
310
+ },
311
+ _j)
312
+ });
313
+ }
314
+ else {
315
+ query.push({
316
+ $group: (_k = {
317
+ _id: groupId
318
+ },
319
+ _k[variable] = (_l = {},
320
+ _l['$' + variableType] = '$' + variable,
321
+ _l),
322
+ _k)
323
+ });
324
+ query.push({
325
+ $addFields: (_m = {},
326
+ _m[variable] = groupDate,
327
+ _m)
328
+ });
329
+ query.push({
330
+ $group: (_o = {
331
+ _id: {
332
+ client: '$_id.client',
333
+ instance: '$_id.instance'
334
+ },
335
+ data: {
336
+ $push: '$' + variable
337
+ }
338
+ },
339
+ _o[variable] = {
340
+ $sum: '$' + variable + '.' + variable
341
+ },
342
+ _o)
298
343
  });
299
344
  }
300
345
  query.push({
@@ -305,7 +350,7 @@ function loadMonitorMethods(methodManager) {
305
350
  });
306
351
  return [4 /*yield*/, __1.ResolveIOServer.getMainDB().model(collection).aggregate(query).allowDiskUse(true)];
307
352
  case 1:
308
- graphData = _h.sent();
353
+ graphData = _p.sent();
309
354
  resolve(graphData);
310
355
  return [2 /*return*/];
311
356
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/methods/monitor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,oFAAwE;AACxE,gFAAoE;AACpE,sGAAyF;AACzF,oGAAuF;AACvF,sFAA0E;AAC1E,wBAAqC;AAErC,SAAgB,kBAAkB,CAAC,aAA4B;IAC9D,aAAa,CAAC,OAAO,CAAC;QACf,iBAAiB,EAAE;YACf,SAAS,EAAE,IAAI;YACxB,QAAQ,EAAE,UAAS,UAAgB,EAAE,QAAc,EAAE,UAAkB,EAAE,QAAgB,EAAE,MAAc,EAAE,aAAqB,EAAE,QAAgB,EAAE,YAAoB;gBAA9J,iBA+QT;gBA9QA,OAAO,IAAI,OAAO,CAAC,UAAO,OAAO,EAAE,MAAM;;;;;;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EAAA;;gCAAnG,SAAS,GAAG,SAAuF;gCAEvG,OAAO,CAAC,SAAS,CAAC,CAAC;;;;qBACnB,CAAC,CAAC;YACJ,CAAC;YACD,cAAc,EAAE,IAAI;SACd;QACD,aAAa,EAAE;YACX,QAAQ,EAAE;gBACN,OAAO,wCAAa,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC;YACvC,CAAC;SACJ;QACD,WAAW,EAAE;YACT,QAAQ,EAAE;gBACN,OAAO,oCAAW,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC;YACrC,CAAC;SACJ;QACD,cAAc,EAAE;YACZ,QAAQ,EAAE;gBACN,OAAO,0CAAc,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC;YACxC,CAAC;SACJ;QACD,qBAAqB,EAAE;YACnB,QAAQ,EAAE;gBACN,OAAO,yDAAqB,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC;YAC/C,CAAC;SACJ;QACD,oBAAoB,EAAE;YAClB,QAAQ,EAAE;gBACN,OAAO,uDAAoB,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC;YAC9C,CAAC;SACJ;KACP,CAAC,CAAC;AACJ,CAAC;AAhTD,gDAgTC","file":"monitor.js","sourcesContent":["import { MethodManager } from '../managers/method.manager';\nimport { MonitorMongos } from '../collections/monitor-mongo.collection';\nimport { MonitorCPUs } from '../collections/monitor-cpu.collection';\nimport { MonitorHTTPSOutbounds } from '../collections/monitor-https-outbound.collection';\nimport { MonitorHTTPSInbounds } from '../collections/monitor-https-inbound.collection';\nimport { MonitorMemorys } from '../collections/monitor-memory.collection';\nimport { ResolveIOServer } from '..';\n\nexport function loadMonitorMethods(methodManager: MethodManager) {\n\tmethodManager.methods({\n superadminMonitor: {\n skipQueue: true,\n\t\t\tfunction: function(date_start: Date, date_end: Date, collection: string, instance: string, client: string, graphInterval: string, variable: string, variableType: string) {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\n\t\t\t\t\tlet groupId = {};\n\t\t\t\t\tlet groupDate = {};\n\n\t\t\t\t\tif (graphInterval === 'seconds') {\n\t\t\t\t\t\tgroupId = {\n\t\t\t\t\t\t\tsecond: {\n\t\t\t\t\t\t\t\t$second: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tminute: {\n\t\t\t\t\t\t\t\t$minute: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n },\n client: '$client',\n instance: '$instance'\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tgroupDate = {\n\t\t\t\t\t\t\t'year': '$_id.year',\n\t\t\t\t\t\t\t'month': '$_id.month',\n\t\t\t\t\t\t\t'day': '$_id.day',\n\t\t\t\t\t\t\t'hour': '$_id.hour',\n\t\t\t\t\t\t\t'minute': '$_id.minute',\n\t\t\t\t\t\t\t'second': '$_id.second',\n\t\t\t\t\t\t\t[variable]: '$' + variable\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\telse if (graphInterval === 'minutes') {\n\t\t\t\t\t\tgroupId = {\n\t\t\t\t\t\t\tminute: {\n\t\t\t\t\t\t\t\t$minute: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n },\n client: '$client',\n instance: '$instance'\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tgroupDate = {\n\t\t\t\t\t\t\t'year': '$_id.year',\n\t\t\t\t\t\t\t'month': '$_id.month',\n\t\t\t\t\t\t\t'day': '$_id.day',\n\t\t\t\t\t\t\t'hour': '$_id.hour',\n\t\t\t\t\t\t\t'minute': '$_id.minute',\n\t\t\t\t\t\t\t[variable]: '$' + variable\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\telse if (graphInterval === 'hours') {\n\t\t\t\t\t\tgroupId = {\n\t\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n },\n client: '$client',\n instance: '$instance'\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tgroupDate = {\n\t\t\t\t\t\t\t'year': '$_id.year',\n\t\t\t\t\t\t\t'month': '$_id.month',\n\t\t\t\t\t\t\t'day': '$_id.day',\n\t\t\t\t\t\t\t'hour': '$_id.hour',\n\t\t\t\t\t\t\t[variable]: '$' + variable\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tgroupId = {\n\t\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n },\n client: '$client',\n instance: '$instance'\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tgroupDate = {\n\t\t\t\t\t\t\t'year': '$_id.year',\n\t\t\t\t\t\t\t'month': '$_id.month',\n\t\t\t\t\t\t\t'day': '$_id.day',\n\t\t\t\t\t\t\t[variable]: '$' + variable\n\t\t\t\t\t\t};\n }\n\n let query = <any>[\n {\n $match: {\n $and: [\n {\n date: {$gte: date_start}\n },\n {\n date: {$lte: date_end}\n }\n ]\n }\n }\n ];\n\n if (client) {\n query[0]['$match'].$and.push({client: client});\n }\n\n if (instance) {\n query[0]['$match'].$and.push({instance: instance});\n }\n \n if (variableType === 'count') {\n query.push(\n {\n $group: {\n _id: groupId,\n count: {\n $sum: 1\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\tdate: {\n\t\t\t\t\t\t\t\t\t\t$first: '$date'\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\tclient: {\n\t\t\t\t\t\t\t\t\t\t$first: '$client'\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\tinstance: {\n\t\t\t\t\t\t\t\t\t\t$first: '$instance'\n\t\t\t\t\t\t\t\t\t}\n }\n }\n ); \n }\n else {\n query.push(\n {\n $group: {\n _id: groupId,\n [variable]: {\n ['$' + variableType]: '$' + variable\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\tdate: {\n\t\t\t\t\t\t\t\t\t\t$first: '$date'\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\tclient: {\n\t\t\t\t\t\t\t\t\t\t$first: '$client'\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\tinstance: {\n\t\t\t\t\t\t\t\t\t\t$first: '$instance'\n\t\t\t\t\t\t\t\t\t}\n }\n }\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tquery.push({\n\t\t\t\t\t\t\t$addFields: {\n\t\t\t\t\t\t\t\t[variable]: groupDate\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t\t\n\t\t\t\t\t\tquery.push(\n {\n $group: {\n _id: {\n\t\t\t\t\t\t\t\t\t\tclient: '$_id.client',\n\t\t\t\t\t\t\t\t\t\tinstance: '$_id.instance'\n\t\t\t\t\t\t\t\t\t},\n data: {\n $push: '$' + variable\n\t\t\t\t\t\t\t\t\t}\n }\n }\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tquery.push({\n\t\t\t\t\t\t$sort: {\n\t\t\t\t\t\t\t'_id.client': 1,\n\t\t\t\t\t\t\t'_id.instance': 1\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\n\t\t\t\t\t// console.log(JSON.stringify(query, null, 2));\n\n\t\t\t\t\tlet graphData = await ResolveIOServer.getMainDB().model(collection).aggregate(query).allowDiskUse(true);\n\n\t\t\t\t\tresolve(graphData);\n\t\t\t\t});\n\t\t\t},\n\t\t\tskipValidation: true\n },\n monitorMongos: {\n function: function() {\n return MonitorMongos.find().exec();\n }\n },\n monitorCPUs: {\n function: function() {\n return MonitorCPUs.find().exec();\n }\n },\n monitorMemorys: {\n function: function() {\n return MonitorMemorys.find().exec();\n }\n },\n monitorHTTPSOutbounds: {\n function: function() {\n return MonitorHTTPSOutbounds.find().exec();\n }\n },\n monitorHTTPSInbounds: {\n function: function() {\n return MonitorHTTPSInbounds.find().exec();\n }\n },\n\t});\n}"]}
1
+ {"version":3,"sources":["../../src/methods/monitor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,oFAAwE;AACxE,gFAAoE;AACpE,sGAAyF;AACzF,oGAAuF;AACvF,sFAA0E;AAC1E,wBAAqC;AACrC,yCAA0C;AAE1C,SAAgB,kBAAkB,CAAC,aAA4B;IAC9D,aAAa,CAAC,OAAO,CAAC;QACf,iBAAiB,EAAE;YACf,SAAS,EAAE,IAAI;YACxB,QAAQ,EAAE,UAAS,UAAgB,EAAE,QAAc,EAAE,UAAkB,EAAE,QAAgB,EAAE,MAAc,EAAE,aAAqB,EAAE,QAAgB,EAAE,YAAoB;gBAA9J,iBA+TT;gBA9TA,OAAO,IAAI,OAAO,CAAC,UAAO,OAAO,EAAE,MAAM;;;;;;gCACpC,OAAO,GAAG,EAAE,CAAC;gCACb,SAAS,GAAG,EAAE,CAAC;gCAEnB,IAAI,aAAa,KAAK,SAAS,EAAE;oCAChC,OAAO,GAAG;wCACT,MAAM,EAAE;4CACP,OAAO,EAAE;gDACR,IAAI,EAAE,OAAO;gDACb,QAAQ,EAAE,iBAAiB;6CAC3B;yCACD;wCACD,MAAM,EAAE;4CACP,OAAO,EAAE;gDACR,IAAI,EAAE,OAAO;gDACb,QAAQ,EAAE,iBAAiB;6CAC3B;yCACD;wCACD,IAAI,EAAE;4CACL,KAAK,EAAE;gDACN,IAAI,EAAE,OAAO;gDACb,QAAQ,EAAE,iBAAiB;6CAC3B;yCACD;wCACD,GAAG,EAAE;4CACJ,WAAW,EAAE;gDACZ,IAAI,EAAE,OAAO;gDACb,QAAQ,EAAE,iBAAiB;6CAC3B;yCACD;wCACD,KAAK,EAAE;4CACN,MAAM,EAAE;gDACP,IAAI,EAAE,OAAO;gDACb,QAAQ,EAAE,iBAAiB;6CAC3B;yCACD;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.manager';\nimport { MonitorMongos } from '../collections/monitor-mongo.collection';\nimport { MonitorCPUs } from '../collections/monitor-cpu.collection';\nimport { MonitorHTTPSOutbounds } from '../collections/monitor-https-outbound.collection';\nimport { MonitorHTTPSInbounds } from '../collections/monitor-https-inbound.collection';\nimport { MonitorMemorys } from '../collections/monitor-memory.collection';\nimport { ResolveIOServer } from '..';\nimport { deepCopy } from '../util/common';\n\nexport function loadMonitorMethods(methodManager: MethodManager) {\n\tmethodManager.methods({\n superadminMonitor: {\n skipQueue: true,\n\t\t\tfunction: function(date_start: Date, date_end: Date, collection: string, instance: string, client: string, graphInterval: string, variable: string, variableType: string) {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\n\t\t\t\t\tlet groupId = {};\n\t\t\t\t\tlet groupDate = {};\n\n\t\t\t\t\tif (graphInterval === 'seconds') {\n\t\t\t\t\t\tgroupId = {\n\t\t\t\t\t\t\tsecond: {\n\t\t\t\t\t\t\t\t$second: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tminute: {\n\t\t\t\t\t\t\t\t$minute: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n },\n client: '$client',\n instance: '$instance'\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tgroupDate = {\n\t\t\t\t\t\t\t'year': '$_id.year',\n\t\t\t\t\t\t\t'month': '$_id.month',\n\t\t\t\t\t\t\t'day': '$_id.day',\n\t\t\t\t\t\t\t'hour': '$_id.hour',\n\t\t\t\t\t\t\t'minute': '$_id.minute',\n\t\t\t\t\t\t\t'second': '$_id.second',\n\t\t\t\t\t\t\t[variable]: '$' + variable\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\telse if (graphInterval === 'minutes') {\n\t\t\t\t\t\tgroupId = {\n\t\t\t\t\t\t\tminute: {\n\t\t\t\t\t\t\t\t$minute: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n },\n client: '$client',\n instance: '$instance'\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tgroupDate = {\n\t\t\t\t\t\t\t'year': '$_id.year',\n\t\t\t\t\t\t\t'month': '$_id.month',\n\t\t\t\t\t\t\t'day': '$_id.day',\n\t\t\t\t\t\t\t'hour': '$_id.hour',\n\t\t\t\t\t\t\t'minute': '$_id.minute',\n\t\t\t\t\t\t\t[variable]: '$' + variable\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\telse if (graphInterval === 'hours') {\n\t\t\t\t\t\tgroupId = {\n\t\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n },\n client: '$client',\n instance: '$instance'\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tgroupDate = {\n\t\t\t\t\t\t\t'year': '$_id.year',\n\t\t\t\t\t\t\t'month': '$_id.month',\n\t\t\t\t\t\t\t'day': '$_id.day',\n\t\t\t\t\t\t\t'hour': '$_id.hour',\n\t\t\t\t\t\t\t[variable]: '$' + variable\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tgroupId = {\n\t\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n },\n client: '$client',\n instance: '$instance'\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tgroupDate = {\n\t\t\t\t\t\t\t'year': '$_id.year',\n\t\t\t\t\t\t\t'month': '$_id.month',\n\t\t\t\t\t\t\t'day': '$_id.day',\n\t\t\t\t\t\t\t[variable]: '$' + variable\n\t\t\t\t\t\t};\n }\n\n let query = <any>[\n {\n $match: {\n $and: [\n {\n date: {$gte: date_start}\n },\n {\n date: {$lte: date_end}\n }\n ]\n }\n }\n ];\n\n if (client) {\n query[0]['$match'].$and.push({client: client});\n }\n\n if (instance) {\n query[0]['$match'].$and.push({instance: instance});\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tlet firstGroupId = deepCopy(groupId);\n\t\t\t\t\t\n\t\t\t\t\tif (collection === 'monitor-mongos') {\n\t\t\t\t\t\tfirstGroupId[variable] = '$' + variable;\n\t\t\t\t\t\tgroupDate['data'] = '$data';\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tif (collection === 'monitor-mongos') {\n\t\t\t\t\t\tquery.push(\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t\t\t_id: firstGroupId,\n\t\t\t\t\t\t\t\t\t[variable]: {\n\t\t\t\t\t\t\t\t\t\t'$sum': 1\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t[variable + '_name']: {\n\t\t\t\t\t\t\t\t\t\t$first: '$' + [variable]\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\tdate: {\n\t\t\t\t\t\t\t\t\t\t$first: '$date'\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\tclient: {\n\t\t\t\t\t\t\t\t\t\t$first: '$client'\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\tinstance: {\n\t\t\t\t\t\t\t\t\t\t$first: '$instance'\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tquery.push({\n\t\t\t\t\t\t\t$addFields: {\n\t\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\t\t[variable]: '$' + variable,\n\t\t\t\t\t\t\t\t\t[variable + '_name']: '$' + variable + '_name'\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tquery.push({\n\t\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t\t_id: groupId,\n\t\t\t\t\t\t\t\t[variable]: {\n\t\t\t\t\t\t\t\t\t'$sum': '$data.' + variable\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\t\t$push: '$data'\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\n\t\t\t\t\t\tquery.push({\n\t\t\t\t\t\t\t$addFields: {\n\t\t\t\t\t\t\t\t[variable]: groupDate\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tquery.push(\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t\t\t_id: {\n\t\t\t\t\t\t\t\t\t\tclient: '$_id.client',\n\t\t\t\t\t\t\t\t\t\tinstance: '$_id.instance'\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\t\t\t$push: '$' + variable\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t[variable]: {\n\t\t\t\t\t\t\t\t\t\t$sum: '$' + variable + '.' + variable\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tquery.push(\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t\t\t_id: groupId,\n\t\t\t\t\t\t\t\t\t[variable]: {\n\t\t\t\t\t\t\t\t\t\t['$' + variableType]: '$' + variable\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\n\t\t\t\t\t\tquery.push({\n\t\t\t\t\t\t\t$addFields: {\n\t\t\t\t\t\t\t\t[variable]: groupDate\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tquery.push(\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t\t\t_id: {\n\t\t\t\t\t\t\t\t\t\tclient: '$_id.client',\n\t\t\t\t\t\t\t\t\t\tinstance: '$_id.instance'\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\t\t\t$push: '$' + variable\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t[variable]: {\n\t\t\t\t\t\t\t\t\t\t$sum: '$' + variable + '.' + variable\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tquery.push({\n\t\t\t\t\t\t$sort: {\n\t\t\t\t\t\t\t'_id.client': 1,\n\t\t\t\t\t\t\t'_id.instance': 1\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\n\t\t\t\t\t// console.log(JSON.stringify(query, null, 2));\n\n\t\t\t\t\tlet graphData = await ResolveIOServer.getMainDB().model(collection).aggregate(query).allowDiskUse(true);\n\n\t\t\t\t\tresolve(graphData);\n\t\t\t\t});\n\t\t\t},\n\t\t\tskipValidation: true\n },\n monitorMongos: {\n function: function() {\n return MonitorMongos.find().exec();\n }\n },\n monitorCPUs: {\n function: function() {\n return MonitorCPUs.find().exec();\n }\n },\n monitorMemorys: {\n function: function() {\n return MonitorMemorys.find().exec();\n }\n },\n monitorHTTPSOutbounds: {\n function: function() {\n return MonitorHTTPSOutbounds.find().exec();\n }\n },\n monitorHTTPSInbounds: {\n function: function() {\n return MonitorHTTPSInbounds.find().exec();\n }\n },\n\t});\n}"]}
@@ -1,29 +1,27 @@
1
1
  import { CollectionDocument } from './collection-document.model';
2
2
  export interface UserModel extends CollectionDocument {
3
- attempts: number;
4
- last: Date;
3
+ roles: UserRoleModel;
4
+ attempts?: number;
5
+ last?: Date;
6
+ services?: any;
5
7
  fullname: string;
6
- roles: string[];
7
- readonly?: boolean;
8
8
  username?: string;
9
9
  email?: string;
10
10
  active?: boolean;
11
- services?: any;
12
- phonenumber?: string;
13
- other?: UserObject;
14
11
  id_customer?: string;
15
12
  customer?: string;
16
13
  customer_type?: string;
17
- customers?: UserCustomersModel[];
14
+ customers?: UserCustomerModel[];
15
+ phonenumber?: string;
16
+ other?: UserObject;
17
+ assets?: UserAssetModel[];
18
+ id_function?: string;
19
+ readonly?: boolean;
18
20
  departments?: UserDepartmentModel[];
19
21
  }
20
22
  export interface UserObject {
21
23
  [key: string]: any;
22
24
  }
23
- export interface UserDepartmentModel {
24
- id_department: string;
25
- department: string;
26
- }
27
25
  export interface UserRoleModel {
28
26
  super_admin: boolean;
29
27
  approvals: UserRoleApprovalModel[];
@@ -41,7 +39,20 @@ export interface UserRoleGroupModel {
41
39
  views: string[];
42
40
  yard?: string;
43
41
  }
44
- export interface UserCustomersModel {
45
- id_customer: string;
42
+ export interface UserAssetModel {
43
+ type: any;
44
+ id_asset: string;
45
+ asset_number: string;
46
+ ownership: string;
47
+ ownership_driver: string;
48
+ date_start: Date;
49
+ date_end?: Date;
50
+ }
51
+ export interface UserCustomerModel {
46
52
  customer: string;
53
+ id_customer: string;
54
+ }
55
+ export interface UserDepartmentModel {
56
+ id_department: string;
57
+ department: string;
47
58
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/models/user.model.ts"],"names":[],"mappings":"","file":"user.model.js","sourcesContent":["import { CollectionDocument } from './collection-document.model';\n\nexport interface UserModel extends CollectionDocument {\n\tattempts: number;\n\tlast: Date;\n\tfullname: string;\n\troles: string[];\n\treadonly?: boolean;\n\tusername?: string;\n\temail?: string;\n\tactive?: boolean;\n\tservices?: any;\n\tphonenumber?: string;\n\tother?: UserObject;\n\tid_customer?: string;\n\tcustomer?: string;\n\tcustomer_type?: string;\n\tcustomers?: UserCustomersModel[];\n\tdepartments?: UserDepartmentModel[];\n}\n\nexport interface UserObject {\n [key: string]: any;\n}\n\nexport interface UserDepartmentModel {\n\tid_department: string;\n\tdepartment: string;\n}\n\nexport interface UserRoleModel {\n\tsuper_admin: boolean;\n\tapprovals: UserRoleApprovalModel[];\n\tgroups: UserRoleGroupModel[];\n\tnotifications: string[];\n\tmiscs: string[];\n}\n\nexport interface UserRoleApprovalModel {\n\taccounting_code: string;\n\ttype: string;\n\tname: string;\n}\n\nexport interface UserRoleGroupModel {\n\tname: string;\n\tviews: string[];\n\tyard?: string;\n}\n\nexport interface UserCustomersModel {\n\tid_customer: string;\n\tcustomer: string;\n}"]}
1
+ {"version":3,"sources":["../../src/models/user.model.ts"],"names":[],"mappings":"","file":"user.model.js","sourcesContent":["import { CollectionDocument } from './collection-document.model';\n\nexport interface UserModel extends CollectionDocument {\n\troles: UserRoleModel;\n\tattempts?: number;\n\tlast?: Date;\n\tservices?: any;\n\tfullname: string;\n\tusername?: string;\n\temail?: string;\n\tactive?: boolean;\n\tid_customer?: string;\n\tcustomer?: string;\n\tcustomer_type?: string;\n\tcustomers?: UserCustomerModel[];\n\tphonenumber?: string;\n\tother?: UserObject;\n\tassets?: UserAssetModel[];\n\tid_function?: string;\n\treadonly?: boolean;\n\tdepartments?: UserDepartmentModel[];\n}\n\nexport interface UserObject {\n [key: string]: any;\n}\n\nexport interface UserRoleModel {\n\tsuper_admin: boolean;\n\tapprovals: UserRoleApprovalModel[];\n\tgroups: UserRoleGroupModel[];\n\tnotifications: string[];\n\tmiscs: string[];\n}\n\nexport interface UserRoleApprovalModel {\n\taccounting_code: string;\n\ttype: string;\n\tname: string;\n}\n\nexport interface UserRoleGroupModel {\n\tname: string;\n\tviews: string[];\n\tyard?: string;\n}\n\nexport interface UserAssetModel {\n\ttype: any;\n\tid_asset: string;\n\tasset_number: string;\n\townership: string;\n\townership_driver: string;\n\tdate_start: Date;\n\tdate_end?: Date;\n}\n\nexport interface UserCustomerModel {\n\tcustomer: string;\n\tid_customer: string;\n}\n\nexport interface UserDepartmentModel {\n\tid_department: string;\n\tdepartment: string;\n}"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@resolveio/server-lib",
3
- "version": "7.1.14",
3
+ "version": "7.1.15-newrole",
4
4
  "description": "",
5
5
  "main": "index.ts",
6
6
  "scripts": {
@@ -67,14 +67,13 @@ function loadReportBuilderLibraryPublications(subscriptionManager) {
67
67
  }
68
68
  }),
69
69
  function: function (id_user) { return __awaiter(_this, void 0, void 0, function () {
70
- var user, userGroupNames, userGroups;
70
+ var user, userGroups;
71
71
  return __generator(this, function (_a) {
72
72
  switch (_a.label) {
73
73
  case 0: return [4 /*yield*/, user_collection_1.Users.findById(id_user)];
74
74
  case 1:
75
75
  user = _a.sent();
76
- userGroupNames = user.roles.filter(function (a) { return a.startsWith('group-'); }).map(function (a) { return a.replace('group-', ''); });
77
- return [4 /*yield*/, user_group_collection_1.UserGroups.find({ name: { $in: userGroupNames } })];
76
+ return [4 /*yield*/, user_group_collection_1.UserGroups.find({ name: { $in: user.roles.groups.map(function (a) { return a.name; }) } })];
78
77
  case 2:
79
78
  userGroups = _a.sent();
80
79
  return [2 /*return*/, report_builder_library_collection_1.ReportBuilderLibraries.find({ 'user_groups.id_user_group': { $in: userGroups.map(function (a) { return a._id; }) } }).sort({ name: 1 }).exec()];
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/publications/report-builder-libraries.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAwC;AAGxC,sGAA0F;AAC1F,kEAAuD;AACvD,8EAAkE;AAElE,SAAgB,oCAAoC,CAAC,mBAAwC;IAA7F,iBAoCC;IAnCA,mBAAmB,CAAC,YAAY,CAAC;QAChC,sBAAsB,EAAE;YACvB,QAAQ,EAAE;gBACT,OAAO,0DAAsB,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,CAAC,EAAC,CAAC,CAAC,IAAI,EAAE,CAAC;YAC7D,CAAC;YACD,WAAW,EAAE,C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AAI,EAAE,CAAC,EAAC,CAAC,CAAC,IAAI,EAAE,EAAC;;;iBAC5H;YACD,WAAW,EAAE,CAAC,OAAO,EAAE,0BAA0B,CAAC;SAClD;KACD,CAAC,CAAC;AACJ,CAAC;AApCD,oFAoCC","file":"report-builder-libraries.js","sourcesContent":["import SimpleSchema from 'simpl-schema';\nimport { Document } from 'mongoose';\nimport { SubscriptionManager } from '../managers/subscription.manager';\nimport { ReportBuilderLibraries } from '../collections/report-builder-library.collection';\nimport { Users } from '../collections/user.collection';\nimport { UserGroups } from '../collections/user-group.collection';\n\nexport function loadReportBuilderLibraryPublications(subscriptionManager: SubscriptionManager) {\n\tsubscriptionManager.publications({\n\t\treportbuilderlibraries: {\n\t\t\tfunction: () => {\n\t\t\t\treturn ReportBuilderLibraries.find().sort({name: 1}).exec();\n\t\t\t},\n\t\t\tcollections: ['report-builder-libraries']\n\t\t},\n\t\treportbuilderlibrariesWithIdUser: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tid_user: {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: (id_user: string) => {\n\t\t\t\treturn ReportBuilderLibraries.find({id_user_create: id_user}).sort({name: 1}).exec();\n\t\t\t},\n\t\t\tcollections: ['users', 'report-builder-libraries']\n\t\t},\n\t\treportbuilderlibrariesForUser: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tid_user: {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async (id_user: string) => {\n\t\t\t\tlet user = await Users.findById(id_user);\n\n\t\t\t\tlet userGroupNames = user.roles.filter(a => a.startsWith('group-')).map(a => a.replace('group-', ''));\n\t\t\t\tlet userGroups = await UserGroups.find({name: {$in: userGroupNames}})\n\n\t\t\t\treturn ReportBuilderLibraries.find({'user_groups.id_user_group': {$in: userGroups.map(a => a._id)}}).sort({name: 1}).exec();\n\t\t\t},\n\t\t\tcollections: ['users', 'report-builder-libraries']\n\t\t},\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C,CAAC,IAAI,EAAN,CAAM,CAAC,EAAC,EAAC,CAAC,EAAA;;4BAArF,UAAU,GAAG,SAAwE;4BAEzF,sBAAO,0DAAsB,CAAC,IAAI,CAAC,EAAC,2BAA2B,EAAE,EAAC,GAAG,EAAE,UAAU,CAAC,GAAG,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,GAAG,EAAL,CAAK,CAAC,EAAC,EAAC,CAAC,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,CAAC,EAAC,CAAC,CAAC,IAAI,EAAE,EAAC;;;iBAC5H;YACD,WAAW,EAAE,CAAC,OAAO,EAAE,0BAA0B,CAAC;SAClD;KACD,CAAC,CAAC;AACJ,CAAC;AAlCD,oFAkCC","file":"report-builder-libraries.js","sourcesContent":["import SimpleSchema from 'simpl-schema';\nimport { Document } from 'mongoose';\nimport { SubscriptionManager } from '../managers/subscription.manager';\nimport { ReportBuilderLibraries } from '../collections/report-builder-library.collection';\nimport { Users } from '../collections/user.collection';\nimport { UserGroups } from '../collections/user-group.collection';\n\nexport function loadReportBuilderLibraryPublications(subscriptionManager: SubscriptionManager) {\n\tsubscriptionManager.publications({\n\t\treportbuilderlibraries: {\n\t\t\tfunction: () => {\n\t\t\t\treturn ReportBuilderLibraries.find().sort({name: 1}).exec();\n\t\t\t},\n\t\t\tcollections: ['report-builder-libraries']\n\t\t},\n\t\treportbuilderlibrariesWithIdUser: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tid_user: {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: (id_user: string) => {\n\t\t\t\treturn ReportBuilderLibraries.find({id_user_create: id_user}).sort({name: 1}).exec();\n\t\t\t},\n\t\t\tcollections: ['users', 'report-builder-libraries']\n\t\t},\n\t\treportbuilderlibrariesForUser: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tid_user: {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async (id_user: string) => {\n\t\t\t\tlet user = await Users.findById(id_user);\n\t\t\t\tlet userGroups = await UserGroups.find({name: {$in: user.roles.groups.map(a => a.name)}});\n\n\t\t\t\treturn ReportBuilderLibraries.find({'user_groups.id_user_group': {$in: userGroups.map(a => a._id)}}).sort({name: 1}).exec();\n\t\t\t},\n\t\t\tcollections: ['users', 'report-builder-libraries']\n\t\t},\n\t});\n}"]}