@resolveio/server-lib 7.1.13-newrole → 7.1.14

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,6 +22,13 @@ 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
+ },
25
32
  attempts: {
26
33
  type: Number,
27
34
  optional: true
@@ -58,67 +65,53 @@ var schema = {
58
65
  type: String
59
66
  },
60
67
  roles: {
61
- type: Object
62
- },
63
- 'roles.super_admin': {
64
- type: Boolean
65
- },
66
- 'roles.approvals': {
67
68
  type: Array
68
69
  },
69
- 'roles.approvals.$': {
70
- type: Object
71
- },
72
- 'roles.approvals.$.name': {
70
+ 'roles.$': {
73
71
  type: String
74
72
  },
75
- 'roles.approvals.$.type': {
76
- type: String
73
+ phonenumber: {
74
+ type: String,
75
+ optional: true
77
76
  },
78
- 'roles.approvals.$.accounting_code': {
79
- type: String
77
+ other: {
78
+ type: Object,
79
+ blackbox: true,
80
+ optional: true
80
81
  },
81
- 'roles.groups': {
82
- type: Array
82
+ assets: {
83
+ type: Array,
84
+ optional: true
83
85
  },
84
- 'roles.groups.$': {
86
+ 'assets.$': {
85
87
  type: Object
86
88
  },
87
- 'roles.groups.$.name': {
89
+ 'assets.$.type': {
88
90
  type: String
89
91
  },
90
- 'roles.groups.$.views': {
91
- type: Array
92
- },
93
- 'roles.groups.$.views.$': {
92
+ 'assets.$.id_asset': {
94
93
  type: String
95
94
  },
96
- 'roles.groups.$.yard': {
97
- type: String,
98
- optional: true
95
+ 'assets.$.asset_number': {
96
+ type: String
99
97
  },
100
- 'roles.notifications': {
101
- type: Array
98
+ 'assets.$.ownership': {
99
+ type: String
102
100
  },
103
- 'roles.notifications.$': {
101
+ 'assets.$.ownership_driver': {
104
102
  type: String
105
103
  },
106
- 'roles.miscs': {
107
- type: Array
104
+ 'assets.$.date_start': {
105
+ type: Date
108
106
  },
109
- 'roles.miscs.$': {
110
- type: String
107
+ 'assets.$.date_end': {
108
+ type: Date,
109
+ optional: true
111
110
  },
112
- active: Boolean,
113
- phonenumber: {
111
+ id_function: {
114
112
  type: String,
115
113
  optional: true
116
114
  },
117
- other: {
118
- type: Object,
119
- optional: true,
120
- blackbox: true
121
- },
122
115
  customers: {
123
116
  type: Array,
124
117
  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,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,QAAQ,EAAE,IAAI;KACd;IACD,QAAQ,EAAE;QACT,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;KACd;IACD,KAAK,EAAE;QACN,IAAI,EAA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AC,KAAK;CACxB,CAAC;AAEF,IAAI,aAAa,GAAG,IAAI,iBAAM,CAAC,MAAM,EAAE;IACtC,cAAc,EAAE,IAAI;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\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
+ {"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,M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C,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 +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,CAAC;4BACr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E,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,OAAO,IAAI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AAI,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}"]}
@@ -1,12 +1,319 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
2
38
  Object.defineProperty(exports, "__esModule", { value: true });
3
39
  var monitor_mongo_collection_1 = require("../collections/monitor-mongo.collection");
4
40
  var monitor_cpu_collection_1 = require("../collections/monitor-cpu.collection");
5
41
  var monitor_https_outbound_collection_1 = require("../collections/monitor-https-outbound.collection");
6
42
  var monitor_https_inbound_collection_1 = require("../collections/monitor-https-inbound.collection");
7
43
  var monitor_memory_collection_1 = require("../collections/monitor-memory.collection");
44
+ var __1 = require("..");
8
45
  function loadMonitorMethods(methodManager) {
9
46
  methodManager.methods({
47
+ superadminMonitor: {
48
+ skipQueue: true,
49
+ function: function (date_start, date_end, collection, instance, client, graphInterval, variable, variableType) {
50
+ var _this = this;
51
+ 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) {
56
+ case 0:
57
+ groupId = {};
58
+ groupDate = {};
59
+ if (graphInterval === 'seconds') {
60
+ groupId = {
61
+ second: {
62
+ $second: {
63
+ date: '$date',
64
+ timezone: "America/Chicago"
65
+ }
66
+ },
67
+ minute: {
68
+ $minute: {
69
+ date: '$date',
70
+ timezone: "America/Chicago"
71
+ }
72
+ },
73
+ hour: {
74
+ $hour: {
75
+ date: '$date',
76
+ timezone: "America/Chicago"
77
+ }
78
+ },
79
+ day: {
80
+ $dayOfMonth: {
81
+ date: '$date',
82
+ timezone: "America/Chicago"
83
+ }
84
+ },
85
+ month: {
86
+ $month: {
87
+ date: '$date',
88
+ timezone: "America/Chicago"
89
+ }
90
+ },
91
+ year: {
92
+ $year: {
93
+ date: '$date',
94
+ timezone: "America/Chicago"
95
+ }
96
+ },
97
+ client: '$client',
98
+ instance: '$instance'
99
+ };
100
+ groupDate = (_a = {
101
+ 'year': '$_id.year',
102
+ 'month': '$_id.month',
103
+ 'day': '$_id.day',
104
+ 'hour': '$_id.hour',
105
+ 'minute': '$_id.minute',
106
+ 'second': '$_id.second'
107
+ },
108
+ _a[variable] = '$' + variable,
109
+ _a);
110
+ }
111
+ else if (graphInterval === 'minutes') {
112
+ groupId = {
113
+ minute: {
114
+ $minute: {
115
+ date: '$date',
116
+ timezone: "America/Chicago"
117
+ }
118
+ },
119
+ hour: {
120
+ $hour: {
121
+ date: '$date',
122
+ timezone: "America/Chicago"
123
+ }
124
+ },
125
+ day: {
126
+ $dayOfMonth: {
127
+ date: '$date',
128
+ timezone: "America/Chicago"
129
+ }
130
+ },
131
+ month: {
132
+ $month: {
133
+ date: '$date',
134
+ timezone: "America/Chicago"
135
+ }
136
+ },
137
+ year: {
138
+ $year: {
139
+ date: '$date',
140
+ timezone: "America/Chicago"
141
+ }
142
+ },
143
+ client: '$client',
144
+ instance: '$instance'
145
+ };
146
+ groupDate = (_b = {
147
+ 'year': '$_id.year',
148
+ 'month': '$_id.month',
149
+ 'day': '$_id.day',
150
+ 'hour': '$_id.hour',
151
+ 'minute': '$_id.minute'
152
+ },
153
+ _b[variable] = '$' + variable,
154
+ _b);
155
+ }
156
+ else if (graphInterval === 'hours') {
157
+ groupId = {
158
+ hour: {
159
+ $hour: {
160
+ date: '$date',
161
+ timezone: "America/Chicago"
162
+ }
163
+ },
164
+ day: {
165
+ $dayOfMonth: {
166
+ date: '$date',
167
+ timezone: "America/Chicago"
168
+ }
169
+ },
170
+ month: {
171
+ $month: {
172
+ date: '$date',
173
+ timezone: "America/Chicago"
174
+ }
175
+ },
176
+ year: {
177
+ $year: {
178
+ date: '$date',
179
+ timezone: "America/Chicago"
180
+ }
181
+ },
182
+ client: '$client',
183
+ instance: '$instance'
184
+ };
185
+ groupDate = (_c = {
186
+ 'year': '$_id.year',
187
+ 'month': '$_id.month',
188
+ 'day': '$_id.day',
189
+ 'hour': '$_id.hour'
190
+ },
191
+ _c[variable] = '$' + variable,
192
+ _c);
193
+ }
194
+ else {
195
+ groupId = {
196
+ day: {
197
+ $dayOfMonth: {
198
+ date: '$date',
199
+ timezone: "America/Chicago"
200
+ }
201
+ },
202
+ month: {
203
+ $month: {
204
+ date: '$date',
205
+ timezone: "America/Chicago"
206
+ }
207
+ },
208
+ year: {
209
+ $year: {
210
+ date: '$date',
211
+ timezone: "America/Chicago"
212
+ }
213
+ },
214
+ client: '$client',
215
+ instance: '$instance'
216
+ };
217
+ groupDate = (_d = {
218
+ 'year': '$_id.year',
219
+ 'month': '$_id.month',
220
+ 'day': '$_id.day'
221
+ },
222
+ _d[variable] = '$' + variable,
223
+ _d);
224
+ }
225
+ query = [
226
+ {
227
+ $match: {
228
+ $and: [
229
+ {
230
+ date: { $gte: date_start }
231
+ },
232
+ {
233
+ date: { $lte: date_end }
234
+ }
235
+ ]
236
+ }
237
+ }
238
+ ];
239
+ if (client) {
240
+ query[0]['$match'].$and.push({ client: client });
241
+ }
242
+ if (instance) {
243
+ query[0]['$match'].$and.push({ instance: instance });
244
+ }
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
+ });
263
+ }
264
+ else {
265
+ query.push({
266
+ $group: (_e = {
267
+ _id: groupId
268
+ },
269
+ _e[variable] = (_f = {},
270
+ _f['$' + variableType] = '$' + variable,
271
+ _f),
272
+ _e.date = {
273
+ $first: '$date'
274
+ },
275
+ _e.client = {
276
+ $first: '$client'
277
+ },
278
+ _e.instance = {
279
+ $first: '$instance'
280
+ },
281
+ _e)
282
+ });
283
+ query.push({
284
+ $addFields: (_g = {},
285
+ _g[variable] = groupDate,
286
+ _g)
287
+ });
288
+ query.push({
289
+ $group: {
290
+ _id: {
291
+ client: '$_id.client',
292
+ instance: '$_id.instance'
293
+ },
294
+ data: {
295
+ $push: '$' + variable
296
+ }
297
+ }
298
+ });
299
+ }
300
+ query.push({
301
+ $sort: {
302
+ '_id.client': 1,
303
+ '_id.instance': 1
304
+ }
305
+ });
306
+ return [4 /*yield*/, __1.ResolveIOServer.getMainDB().model(collection).aggregate(query).allowDiskUse(true)];
307
+ case 1:
308
+ graphData = _h.sent();
309
+ resolve(graphData);
310
+ return [2 /*return*/];
311
+ }
312
+ });
313
+ }); });
314
+ },
315
+ skipValidation: true
316
+ },
10
317
  monitorMongos: {
11
318
  function: function () {
12
319
  return monitor_mongo_collection_1.MonitorMongos.find().exec();
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/methods/monitor.ts"],"names":[],"mappings":";;AACA,oFAAwE;AACxE,gFAAoE;AACpE,sGAAyF;AACzF,oGAAuF;AACvF,sFAA0E;AAE1E,SAAgB,kBAAkB,CAAC,aAA4B;IAC9D,aAAa,CAAC,OAAO,CAAC;QACf,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;AA5BD,gDA4BC","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';\n\nexport function loadMonitorMethods(methodManager: MethodManager) {\n\tmethodManager.methods({\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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C/B,MAAM,EAAE,aAAa;gDACrB,QAAQ,EAAE,eAAe;6CACzB;4CAC0B,IAAI,EAAE;gDACF,KAAK,EAAE,GAAG,GAAG,QAAQ;6CACnD;yCACuB;qCACJ,CACtB,CAAC;iCACF;gCAED,KAAK,CAAC,IAAI,CAAC;oCACV,KAAK,EAAE;wCACN,YAAY,EAAE,CAAC;wCACf,cAAc,EAAE,CAAC;qCACjB;iCACD,CAAC,CAAC;gCAIa,qBAAM,mBAAe,CAAC,SAAS,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,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,27 +1,29 @@
1
1
  import { CollectionDocument } from './collection-document.model';
2
2
  export interface UserModel extends CollectionDocument {
3
- roles: UserRoleModel;
4
- attempts?: number;
5
- last?: Date;
6
- services?: any;
3
+ attempts: number;
4
+ last: Date;
7
5
  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;
11
14
  id_customer?: string;
12
15
  customer?: string;
13
16
  customer_type?: string;
14
- customers?: UserCustomerModel[];
15
- phonenumber?: string;
16
- other?: UserObject;
17
- assets?: UserAssetModel[];
18
- id_function?: string;
19
- readonly?: boolean;
17
+ customers?: UserCustomersModel[];
20
18
  departments?: UserDepartmentModel[];
21
19
  }
22
20
  export interface UserObject {
23
21
  [key: string]: any;
24
22
  }
23
+ export interface UserDepartmentModel {
24
+ id_department: string;
25
+ department: string;
26
+ }
25
27
  export interface UserRoleModel {
26
28
  super_admin: boolean;
27
29
  approvals: UserRoleApprovalModel[];
@@ -39,20 +41,7 @@ export interface UserRoleGroupModel {
39
41
  views: string[];
40
42
  yard?: string;
41
43
  }
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 {
52
- customer: string;
44
+ export interface UserCustomersModel {
53
45
  id_customer: string;
54
- }
55
- export interface UserDepartmentModel {
56
- id_department: string;
57
- department: string;
46
+ customer: string;
58
47
  }
@@ -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\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}"]}
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}"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@resolveio/server-lib",
3
- "version": "7.1.13-newrole",
3
+ "version": "7.1.14",
4
4
  "description": "",
5
5
  "main": "index.ts",
6
6
  "scripts": {
@@ -67,13 +67,14 @@ function loadReportBuilderLibraryPublications(subscriptionManager) {
67
67
  }
68
68
  }),
69
69
  function: function (id_user) { return __awaiter(_this, void 0, void 0, function () {
70
- var user, userGroups;
70
+ var user, userGroupNames, 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
- return [4 /*yield*/, user_group_collection_1.UserGroups.find({ name: { $in: user.roles.groups.map(function (a) { return a.name; }) } })];
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 } })];
77
78
  case 2:
78
79
  userGroups = _a.sent();
79
80
  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,iBAkCC;IAjCA,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,CAAC,0BAA0B,CAAC;SACzC;QACD,gCAAgC,EAAE;YACjC,KAAK,EAAE,IAAI,sBAAY,CAAC;gBACvB,OAAO,EAAE;oBACR,IAAI,EAAE,MAAM;iBACZ;aACD,CAAC;YACF,QAAQ,EAAE,UAAC,OAAe;gBACzB,OAAO,0DAAsB,CAAC,IAAI,CAAC,EAAC,cAAc,EAAE,OAAO,EAAC,CAAC,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,CAAC,EAAC,CAAC,CAAC,IAAI,EAAE,CAAC;YACtF,CAAC;YACD,WAAW,EAAE,CAAC,OAAO,EAAE,0BAA0B,CAAC;SAClD;QACD,6BAA6B,EAAE;YAC9B,KAAK,EAAE,IAAI,sBAAY,CAAC;gBACvB,OAAO,EAAE;oBACR,IAAI,EAAE,MAAM;iBACZ;aACD,CAAC;YACF,QAAQ,EAAE,UAAO,OAAe;;;;gCACpB,qBAAM,uBAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAA;;4BAApC,IAAI,GAAG,SAA6B;4BACvB,qBAAM,kCAAU,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,EAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,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}"]}
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,CAAC,0BAA0B,CAAC;SACzC;QACD,gCAAgC,EAAE;YACjC,KAAK,EAAE,IAAI,sBAAY,CAAC;gBACvB,OAAO,EAAE;oBACR,IAAI,EAAE,MAAM;iBACZ;aACD,CAAC;YACF,QAAQ,EAAE,UAAC,OAAe;gBACzB,OAAO,0DAAsB,CAAC,IAAI,CAAC,EAAC,cAAc,EAAE,OAAO,EAAC,CAAC,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,CAAC,EAAC,CAAC,CAAC,IAAI,EAAE,CAAC;YACtF,CAAC;YACD,WAAW,EAAE,CAAC,OAAO,EAAE,0BAA0B,CAAC;SAClD;QACD,6BAA6B,EAAE;YAC9B,KAAK,EAAE,IAAI,sBAAY,CAAC;gBACvB,OAAO,EAAE;oBACR,IAAI,EAAE,MAAM;iBACZ;aACD,CAAC;YACF,QAAQ,EAAE,UAAO,OAAe;;;;gCACpB,qBAAM,uBAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAA;;4BAApC,IAAI,GAAG,SAA6B;4BAEpC,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAtB,CAAsB,CAAC,CAAC,GAAG,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,EAAvB,CAAuB,CAAC,CAAC;4BACrF,qBAAM,kCAAU,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,EAAC,GAAG,EAAE,cAAc,EAAC,EAAC,CAAC,EAAA;;4BAAjE,UAAU,GAAG,SAAoD;4BAErE,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;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},\n\t});\n}"]}