@churchsoln/dbms 1.0.27 → 1.0.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/constants/index.js +37 -1
  2. package/controllers/master.js +0 -89
  3. package/migrations/{common/20221226143349-create-province.js → church/20221226151615-create-province.js} +2 -0
  4. package/migrations/{common/20221226150238-create-city.js → church/20221226151616-create-city.js} +1 -0
  5. package/migrations/church/20221226151618-create-membership.js +68 -0
  6. package/migrations/church/20221226151619-create-member.js +140 -0
  7. package/migrations/church/20221227151615-create-user.js +50 -139
  8. package/migrations/church/20230826140644-create-eventsUpdates.js +1 -0
  9. package/migrations/church/20240918170620-create-donation.js +2 -0
  10. package/migrations/church/20240918170621-create-church.js +17 -2
  11. package/migrations/church/20240918170627-create-pledge.js +0 -2
  12. package/migrations/common/20221226140655-create-subscriptionPlan.js +2 -2
  13. package/migrations/common/20240815170619-create-permission.js +2 -0
  14. package/migrations/common/20240815170620-create-church.js +1 -29
  15. package/models/church/church.js +16 -2
  16. package/models/{common → church}/city.js +2 -1
  17. package/models/church/member.js +171 -0
  18. package/models/church/membership.js +81 -0
  19. package/models/{common → church}/province.js +3 -1
  20. package/models/church/user.js +43 -254
  21. package/package.json +1 -1
  22. package/public/swagger/church.json +18 -18
  23. package/public/swagger/master.json +0 -313
  24. package/routes/v1/master.js +0 -24
  25. package/seeders/church/20241005124245-province.js +101 -0
  26. package/seeders/church/20241005124547-city.js +87 -0
  27. package/services/church.js +2 -2
  28. package/services/master.js +0 -152
  29. package/validators/church.js +3 -3
  30. package/workers/seed.js +1 -1
  31. package/migrations/church/20221226150553-create-maritalStatus.js +0 -25
  32. package/migrations/church/20221226151615-create-relationship.js +0 -25
  33. package/migrations/church/20240918170624-create-membershipType.js +0 -24
  34. package/migrations/church/20240918170625-update-user.js +0 -24
  35. package/migrations/church/20240918170626-update-eventsUpdate.js +0 -12
  36. package/migrations/church/20240918170628-update-pledge.js +0 -12
  37. package/migrations/church/20240918170629-update-donation.js +0 -12
  38. package/migrations/church/20240918170630-update-donation.js +0 -12
  39. package/migrations/church/20240918170631-update-church.js +0 -12
  40. package/migrations/common/20240918170624-update-church.js +0 -23
  41. package/migrations/common/20240918170625-update-permission.js +0 -17
  42. package/migrations/common/20240918170626-update-subscriptionPlan.js +0 -20
  43. package/migrations/common/20240918170628-update-church.js +0 -12
  44. package/models/church/maritalStatus.js +0 -15
  45. package/models/church/membershipType.js +0 -16
  46. package/models/church/relationship.js +0 -15
  47. package/seeders/church/20241005131256-maritalStatus.js +0 -43
  48. package/seeders/church/20241005131416-relationship.js +0 -43
  49. package/seeders/church/20241005131417-membershipType.js +0 -39
  50. package/seeders/common/20241005124245-province.js +0 -42
  51. package/seeders/common/20241005124547-city.js +0 -55
@@ -5,17 +5,24 @@ module.exports = (sequelize, DataTypes) => {
5
5
  "User",
6
6
  {
7
7
  id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
8
- username: { type: DataTypes.STRING, unique: true },
9
- roleId: { type: DataTypes.INTEGER },
10
- subRoleId: { type: DataTypes.INTEGER },
11
- isHeadOfFamily: { type: DataTypes.BOOLEAN, defaultValue: false },
12
- familyCode: { type: DataTypes.STRING },
13
- familyName: { type: DataTypes.STRING },
14
- memberCode: { type: DataTypes.STRING },
15
- email: { type: DataTypes.STRING },
16
- showEmail: { type: DataTypes.BOOLEAN, defaultValue: false },
8
+
9
+ // Link to the individual profile
10
+ memberId: {
11
+ type: DataTypes.INTEGER,
12
+ set(memberId) {
13
+ this.setDataValue("memberId", memberId?.id || memberId);
14
+ },
15
+ },
16
+
17
+ // Authentication Fields
18
+ username: {
19
+ type: DataTypes.STRING,
20
+ allowNull: false,
21
+ unique: true,
22
+ },
17
23
  password: {
18
24
  type: DataTypes.STRING,
25
+ allowNull: false,
19
26
  set(password) {
20
27
  if (password) {
21
28
  const encrypted = utils.genHash(password);
@@ -23,268 +30,50 @@ module.exports = (sequelize, DataTypes) => {
23
30
  }
24
31
  },
25
32
  },
26
- phone: { type: DataTypes.STRING },
27
- showPhone: { type: DataTypes.BOOLEAN, defaultValue: false },
28
- firstName: { type: DataTypes.STRING },
29
- showFirstName: { type: DataTypes.BOOLEAN, defaultValue: false },
30
- lastName: { type: DataTypes.STRING },
31
- showLastName: { type: DataTypes.BOOLEAN, defaultValue: false },
32
- gender: { type: DataTypes.STRING },
33
- showGender: { type: DataTypes.BOOLEAN, defaultValue: false },
34
- dob: { type: DataTypes.DATEONLY },
35
- showDob: { type: DataTypes.BOOLEAN, defaultValue: false },
36
- education: { type: DataTypes.STRING },
37
- showEducation: { type: DataTypes.BOOLEAN, defaultValue: false },
38
- relationshipId: {
39
- type: DataTypes.INTEGER,
40
- set(relationshipId) {
41
- this.setDataValue("relationshipId", relationshipId?.id || relationshipId);
42
- },
43
- },
44
- partnerId: {
45
- type: DataTypes.INTEGER,
46
- set(partnerId) {
47
- this.setDataValue("partnerId", partnerId?.id || partnerId);
48
- },
49
- },
50
- showRelationship: { type: DataTypes.BOOLEAN, defaultValue: false },
51
- maritalStatusId: {
52
- type: DataTypes.INTEGER,
53
- set(maritalStatusId) {
54
- this.setDataValue("maritalStatusId", maritalStatusId?.id || maritalStatusId);
55
- },
56
- },
57
- showMaritalStatus: { type: DataTypes.BOOLEAN, defaultValue: false },
58
- dateJoined: { type: DataTypes.DATEONLY },
59
- showDateJoined: { type: DataTypes.BOOLEAN, defaultValue: false },
60
- emergencyContact: { type: DataTypes.STRING },
61
- showEmergencyContact: { type: DataTypes.BOOLEAN, defaultValue: false },
62
- emergencyContactName: { type: DataTypes.STRING },
63
- showEmergencyContactName: { type: DataTypes.BOOLEAN, defaultValue: false },
64
- emergencyContactRelationshipId: {
65
- type: DataTypes.INTEGER,
66
- set(emergencyContactRelationshipId) {
67
- this.setDataValue(
68
- "emergencyContactRelationshipId",
69
- emergencyContactRelationshipId?.id || emergencyContactRelationshipId
70
- );
71
- },
72
- },
73
- showEmergencyContactRelationship: { type: DataTypes.BOOLEAN, defaultValue: false },
74
- imageUrl: { type: DataTypes.TEXT },
75
- showImage: { type: DataTypes.BOOLEAN, defaultValue: false },
76
- address: { type: DataTypes.STRING },
77
- showAddress: { type: DataTypes.BOOLEAN, defaultValue: false },
78
- cityId: {
79
- type: DataTypes.STRING,
80
- set(cityId) {
81
- this.setDataValue("cityId", cityId?.id || cityId);
82
- },
83
- },
84
- showCity: { type: DataTypes.BOOLEAN, defaultValue: false },
85
- provinceId: {
86
- type: DataTypes.INTEGER,
87
- set(provinceId) {
88
- this.setDataValue("provinceId", provinceId?.id || provinceId);
89
- },
90
- },
91
- postalCode: {
33
+ email: {
92
34
  type: DataTypes.STRING,
93
- get() {
94
- return this.getDataValue("showPostal")
95
- ? this.getDataValue("postalCode")
96
- : undefined;
97
- },
35
+ allowNull: false,
36
+ unique: true,
37
+ validate: { isEmail: true },
98
38
  },
99
- showPostal: { type: DataTypes.BOOLEAN, defaultValue: false },
100
- otp: { type: DataTypes.INTEGER },
101
- membershipTypeId: {
102
- type: DataTypes.INTEGER,
103
- set(membershipTypeId) {
104
- this.setDataValue("membershipTypeId", membershipTypeId?.id || membershipTypeId);
105
- },
106
- },
107
- isUserAuthenticated: { type: DataTypes.BOOLEAN, defaultValue: false },
108
- delUpdateAccess: { type: DataTypes.BOOLEAN, defaultValue: false },
109
- directoryVisibility: { type: DataTypes.BOOLEAN, defaultValue: false },
110
- userLoginAccess: { type: DataTypes.BOOLEAN, defaultValue: false },
111
- isEmailSubscribed: { type: DataTypes.BOOLEAN, defaultValue: false },
39
+
40
+ // Roles & Permissions
41
+ roleId: { type: DataTypes.INTEGER },
42
+ subRoleId: { type: DataTypes.INTEGER },
43
+ enableLoginAccess: { type: DataTypes.BOOLEAN, defaultValue: true },
112
44
  status: { type: DataTypes.BOOLEAN, defaultValue: true },
45
+
46
+ // Metadata
47
+ lastLogin: { type: DataTypes.DATE },
113
48
  createdAt: { type: DataTypes.DATE },
114
49
  updatedAt: { type: DataTypes.DATE },
115
50
  },
116
51
  { freezeTableName: true, timestamps: false }
117
52
  );
118
53
  user.associate = function (models) {
119
- user.belongsTo(models.relationship, { foreignKey: "relationshipId", as: "relationship" });
120
- user.belongsTo(models.user, { foreignKey: "partnerId", as: "partner" });
121
- user.belongsTo(models.maritalStatus, {
122
- foreignKey: "maritalStatusId",
123
- as: "maritalStatus",
124
- });
125
- user.belongsTo(models.relationship, {
126
- foreignKey: "emergencyContactRelationshipId",
127
- as: "emergencyContactRelationship",
128
- });
54
+ user.belongsTo(models.member, { foreignKey: "memberId", as: "member" });
129
55
  user.belongsTo(models.subRole, { foreignKey: "subRoleId", as: "subRole" });
130
- user.belongsTo(models.membershipType, {
131
- foreignKey: "membershipTypeId",
132
- as: "membershipType",
133
- });
134
56
  };
135
- user.selectedFields = [
57
+ const selectedFields = [
136
58
  "id",
59
+ "memberId",
137
60
  "username",
138
- "roleId",
139
- "isHeadOfFamily",
140
- "familyCode",
141
- "familyName",
142
- "memberCode",
143
- "email",
144
- "showEmail",
145
61
  "password",
146
- "phone",
147
- "showPhone",
148
- "firstName",
149
- "showFirstName",
150
- "lastName",
151
- "showLastName",
152
- "gender",
153
- "showGender",
154
- "dob",
155
- "showDob",
156
- "education",
157
- "showEducation",
158
- "relationshipId",
159
- "partnerId",
160
- "showRelationship",
161
- "maritalStatusId",
162
- "showMaritalStatus",
163
- "dateJoined",
164
- "showDateJoined",
165
- "emergencyContact",
166
- "showEmergencyContact",
167
- "emergencyContactName",
168
- "showEmergencyContactName",
169
- "emergencyContactRelationshipId",
170
- "showEmergencyContactRelationship",
171
- "imageUrl",
172
- "showImage",
173
- "address",
174
- "showAddress",
175
- "cityId",
176
- "showCity",
177
- "provinceId",
178
- "postalCode",
179
- "showPostal",
180
- "otp",
181
- "membershipTypeId",
182
- "isUserAuthenticated",
183
- "delUpdateAccess",
184
- "directoryVisibility",
185
- "userLoginAccess",
186
- "isEmailSubscribed",
187
- "status",
188
- "createdAt",
189
- "updatedAt",
190
- ];
191
- user.responseFields = [
192
- "id",
193
- "username",
194
- "roleId",
195
- "isHeadOfFamily",
196
- "familyCode",
197
- "familyName",
198
- "memberCode",
199
- "email",
200
- "showEmail",
201
- "phone",
202
- "showPhone",
203
- "firstName",
204
- "showFirstName",
205
- "lastName",
206
- "showLastName",
207
- "gender",
208
- "showGender",
209
- "dob",
210
- "showDob",
211
- "education",
212
- "showEducation",
213
- "relationshipId",
214
- "partnerId",
215
- "showRelationship",
216
- "maritalStatusId",
217
- "showMaritalStatus",
218
- "dateJoined",
219
- "showDateJoined",
220
- "emergencyContact",
221
- "showEmergencyContact",
222
- "emergencyContactName",
223
- "showEmergencyContactName",
224
- "emergencyContactRelationshipId",
225
- "showEmergencyContactRelationship",
226
- "imageUrl",
227
- "showImage",
228
- "address",
229
- "showAddress",
230
- "cityId",
231
- "showCity",
232
- "provinceId",
233
- "postalCode",
234
- "showPostal",
235
- "delUpdateAccess",
236
- "directoryVisibility",
237
- "userLoginAccess",
238
- "isEmailSubscribed",
239
- "membershipTypeId",
240
- "status",
241
- ];
242
- user.listFields = [
243
- "id",
244
- "username",
245
62
  "email",
246
63
  "roleId",
247
- "dob",
248
- "gender",
249
- "firstName",
250
- "lastName",
251
- "address",
252
- "isUserAuthenticated",
253
- "membershipTypeId",
254
- "familyCode",
255
- "memberCode",
64
+ "subRoleId",
65
+ "enableLoginAccess",
256
66
  "status",
257
- ];
258
- user.transferFields = [
259
- "id",
260
- "username",
261
- "familyCode",
262
- "firstName",
263
- "lastName",
264
- "email",
265
- "phone",
266
- ];
267
- user.showFields = [
268
- ["showEmail", ["email"]],
269
- ["showPhone", ["phone"]],
270
- ["showFirstName", ["firstName"]],
271
- ["showLastName", ["lastName"]],
272
- ["showGender", ["gender"]],
273
- ["showDob", ["dob"]],
274
- ["showEducation", ["education"]],
275
- ["showRelationship", ["relationshipId", "relationship"]],
276
- ["showMaritalStatus", ["maritalStatusId", "maritalStatus"]],
277
- ["showDateJoined", ["dateJoined"]],
278
- ["showEmergencyContact", ["emergencyContact"]],
279
- ["showEmergencyContactName", ["emergencyContactName"]],
280
- [
281
- "showEmergencyContactRelationship",
282
- ["emergencyContactRelationshipId", "emergencyContactRelationship"]
283
- ],
284
- ["showImage", ["imageUrl"]],
285
- ["showAddress", ["address"]],
286
- ["showCity", ["cityId", "city"]],
287
- ["showPostal", ["postalCode"]],
67
+ "lastLogin",
68
+ "createdAt",
69
+ "updatedAt",
288
70
  ]
71
+ user.selectedFields = [
72
+ ...selectedFields,
73
+ "password"
74
+ ];
75
+ user.responseFields = selectedFields;
76
+ user.listFields = selectedFields;
77
+ user.transferFields = selectedFields;
289
78
  return user;
290
79
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@churchsoln/dbms",
3
- "version": "1.0.27",
3
+ "version": "1.0.30",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "prestart": "node db-setup.js",
@@ -54,11 +54,11 @@
54
54
  "validity": 30,
55
55
  "permissionId": [1],
56
56
  "churchAdminDetails": {
57
+ "username": "churchadmin",
58
+ "email": "churchadmin@xavier.com",
59
+ "password": "Church@123",
57
60
  "firstName": "Jose",
58
- "lastName": "Mathew",
59
- "email": "josemathew@xavier.com",
60
- "phone": "123456789",
61
- "password": "password"
61
+ "lastName": "Mathew"
62
62
  }
63
63
  }
64
64
  }
@@ -385,11 +385,11 @@
385
385
  "validity": 30,
386
386
  "permissionId": [1],
387
387
  "churchAdminDetails": {
388
+ "username": "churchadmin",
389
+ "email": "churchadmin@xavier.com",
390
+ "password": "Church@123",
388
391
  "firstName": "Jose",
389
- "lastName": "Mathew",
390
- "email": "josemathew@xavier.com",
391
- "phone": "123456789",
392
- "password": "password"
392
+ "lastName": "Mathew"
393
393
  }
394
394
  }
395
395
  },
@@ -441,31 +441,31 @@
441
441
  },
442
442
  "ChurchAdminDataRequest": {
443
443
  "title": "ChurchAdminDataRequest",
444
- "required": ["firstName", "lastName", "email", "phone", "password"],
444
+ "required": ["username", "email", "password", "firstName", "lastName"],
445
445
  "type": "object",
446
446
  "properties": {
447
- "firstName": {
447
+ "username": {
448
448
  "type": "string"
449
449
  },
450
- "lastName": {
450
+ "email": {
451
451
  "type": "string"
452
452
  },
453
- "email": {
453
+ "password": {
454
454
  "type": "string"
455
455
  },
456
- "phone": {
456
+ "firstName": {
457
457
  "type": "string"
458
458
  },
459
- "password": {
459
+ "lastName": {
460
460
  "type": "string"
461
461
  }
462
462
  },
463
463
  "example": {
464
+ "username": "churchadmin",
465
+ "email": "churchadmin@xavier.com",
466
+ "password": "Church@123",
464
467
  "firstName": "Jose",
465
- "lastName": "Mathew",
466
- "email": "josemathew@xavier.com",
467
- "phone": "123456789",
468
- "password": "password"
468
+ "lastName": "Mathew"
469
469
  }
470
470
  },
471
471
  "SuperAdminLoginDataRequest": {