@resolveio/server-lib 6.4.2 → 6.4.3-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.
@@ -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": "6.4.2",
3
+ "version": "6.4.3-newrole",
4
4
  "description": "",
5
5
  "main": "index.ts",
6
6
  "scripts": {
@@ -70,17 +70,16 @@ function loadReportBuilderLibraryPublications(subscriptionManager) {
70
70
  }
71
71
  }),
72
72
  function: function (id_user) { return __awaiter(_this, void 0, void 0, function () {
73
- var user, userGroupNames, userGroups;
73
+ var user, userGroups;
74
74
  return __generator(this, function (_a) {
75
75
  switch (_a.label) {
76
76
  case 0: return [4 /*yield*/, user_collection_1.Users.findById(id_user)];
77
77
  case 1:
78
78
  user = _a.sent();
79
- userGroupNames = user.roles.filter(function (a) { return a.startsWith('group-'); }).map(function (a) { return a.replace('group-', ''); });
80
- return [4 /*yield*/, user_group_collection_1.UserGroups.find({ name: { $in: userGroupNames } })];
79
+ return [4 /*yield*/, user_group_collection_1.UserGroups.find({ name: { $in: user.roles.groups.map(function (a) { return a.name; }) } })];
81
80
  case 2:
82
81
  userGroups = _a.sent();
83
- return [2 /*return*/, report_builder_library_collection_1.ReportBuilderLibraries.find({ 'user_groups.id_user_group': { $in: userGroups } }).sort({ name: 1 }).exec()];
82
+ 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()];
84
83
  }
85
84
  });
86
85
  }); },
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/publications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AA,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,EAAC,EAAC,CAAC,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,CAAC,EAAC,CAAC,CAAC,IAAI,EAAE,EAAC;;;iBAC5G;YACD,WAAW,EAAE,CAAC,0BAA0B,CAAC;YACzC,aAAa,EAAE,UAAC,QAAkB,EAAE,OAAe;gBAClD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,QAAQ,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,aAAa,EAAf,CAAe,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;YACzG,CAAC;SACD;KACD,CAAC,CAAC;AACJ,CAAC;AA1CD,oFA0CC","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: ['report-builder-libraries'],\n\t\t\tfetchFunction: (document: Document, id_user: string) => {\n\t\t\t\treturn (document['id_user_create'] === id_user);\n\t\t\t}\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}}).sort({name: 1}).exec();\n\t\t\t},\n\t\t\tcollections: ['report-builder-libraries'],\n\t\t\tfetchFunction: (document: Document, id_user: string) => {\n\t\t\t\treturn (document['user_groups'] && document['user_groups'].map(a => a.id_user_group).includes(id_user));\n\t\t\t}\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,iBAwCC;IAvCA,mBAAmB,CAAC,YAAY,CAAC;QAChC,sBAAsB,EAAE;YACvB,QAAQ,EAAE;gBACT,OAAO,0DAAsB,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,CAAC,EAAC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C,IAAI,CAAC,EAAC,IAAI,EAAE,CAAC,EAAC,CAAC,CAAC,IAAI,EAAE,EAAC;;;iBAC5H;YACD,WAAW,EAAE,CAAC,0BAA0B,CAAC;YACzC,aAAa,EAAE,UAAC,QAAkB,EAAE,OAAe;gBAClD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,QAAQ,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,aAAa,EAAf,CAAe,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;YACzG,CAAC;SACD;KACD,CAAC,CAAC;AACJ,CAAC;AAxCD,oFAwCC","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: ['report-builder-libraries'],\n\t\t\tfetchFunction: (document: Document, id_user: string) => {\n\t\t\t\treturn (document['id_user_create'] === id_user);\n\t\t\t}\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: ['report-builder-libraries'],\n\t\t\tfetchFunction: (document: Document, id_user: string) => {\n\t\t\t\treturn (document['user_groups'] && document['user_groups'].map(a => a.id_user_group).includes(id_user));\n\t\t\t}\n\t\t},\n\t});\n}"]}