@churchsoln/dbms 1.0.27 → 1.0.29

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 +49 -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 +41 -254
  21. package/package.json +1 -1
  22. package/public/swagger/church.json +11 -23
  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 +0 -2
  28. package/services/master.js +0 -152
  29. package/validators/church.js +1 -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
@@ -324,319 +324,6 @@
324
324
  "deprecated": false
325
325
  }
326
326
  },
327
- "/master/province": {
328
- "post": {
329
- "tags": ["Province CRUD API's"],
330
- "summary": "Add Province",
331
- "operationId": "Add Province",
332
- "parameters": [],
333
- "requestBody": {
334
- "content": {
335
- "application/json": {
336
- "schema": {
337
- "$ref": "#/components/schemas/MasterDataRequest"
338
- },
339
- "example": {
340
- "name": "Label"
341
- }
342
- }
343
- },
344
- "required": true
345
- },
346
- "responses": {
347
- "200": {
348
- "description": "OK"
349
- }
350
- },
351
- "deprecated": false
352
- },
353
- "get": {
354
- "tags": ["Province CRUD API's"],
355
- "summary": "Get All Provinces with search",
356
- "operationId": "Get All Provinces with search",
357
- "parameters": [
358
- {
359
- "name": "search",
360
- "in": "query",
361
- "required": false,
362
- "style": "form",
363
- "explode": true,
364
- "schema": {
365
- "type": "string",
366
- "example": ""
367
- }
368
- }
369
- ],
370
- "requestBody": {},
371
- "responses": {
372
- "200": {
373
- "description": "OK"
374
- }
375
- },
376
- "deprecated": false
377
- }
378
- },
379
- "/master/province/{id}": {
380
- "get": {
381
- "tags": ["Province CRUD API's"],
382
- "summary": "Get Province by id",
383
- "operationId": "Get Province by id",
384
- "parameters": [
385
- {
386
- "name": "id",
387
- "in": "path",
388
- "required": true,
389
- "style": "form",
390
- "explode": true,
391
- "schema": {
392
- "type": "integer",
393
- "format": "int32",
394
- "example": 1
395
- }
396
- }
397
- ],
398
- "requestBody": {},
399
- "responses": {
400
- "200": {
401
- "description": "OK"
402
- }
403
- },
404
- "deprecated": false
405
- },
406
- "patch": {
407
- "tags": ["Province CRUD API's"],
408
- "summary": "Update Province by id",
409
- "operationId": "Update Province by id",
410
- "parameters": [
411
- {
412
- "name": "id",
413
- "in": "path",
414
- "required": true,
415
- "style": "form",
416
- "explode": true,
417
- "schema": {
418
- "type": "integer",
419
- "format": "int32",
420
- "example": 1
421
- }
422
- }
423
- ],
424
- "requestBody": {
425
- "content": {
426
- "application/json": {
427
- "schema": {
428
- "$ref": "#/components/schemas/MasterDataRequest"
429
- },
430
- "example": {
431
- "name": "Label"
432
- }
433
- }
434
- },
435
- "required": true
436
- },
437
- "responses": {
438
- "200": {
439
- "description": "OK"
440
- }
441
- },
442
- "deprecated": false
443
- },
444
- "delete": {
445
- "tags": ["Province CRUD API's"],
446
- "summary": "Delete Province by id",
447
- "operationId": "Delete Province by id",
448
- "parameters": [
449
- {
450
- "name": "id",
451
- "in": "path",
452
- "required": true,
453
- "style": "form",
454
- "explode": true,
455
- "schema": {
456
- "type": "integer",
457
- "format": "int32",
458
- "example": 1
459
- }
460
- }
461
- ],
462
- "requestBody": {},
463
- "responses": {
464
- "200": {
465
- "description": "OK"
466
- }
467
- },
468
- "deprecated": false
469
- }
470
- },
471
- "/master/city": {
472
- "post": {
473
- "tags": ["City CRUD API's"],
474
- "summary": "Add City",
475
- "operationId": "Add City",
476
- "parameters": [
477
- {
478
- "name": "provinceId",
479
- "in": "query",
480
- "required": true,
481
- "style": "form",
482
- "explode": true,
483
- "schema": {
484
- "type": "integer",
485
- "format": "int32",
486
- "example": 1
487
- }
488
- }
489
- ],
490
- "requestBody": {
491
- "content": {
492
- "application/json": {
493
- "schema": {
494
- "$ref": "#/components/schemas/MasterDataRequest"
495
- },
496
- "example": {
497
- "name": "Label"
498
- }
499
- }
500
- },
501
- "required": true
502
- },
503
- "responses": {
504
- "200": {
505
- "description": "OK"
506
- }
507
- },
508
- "deprecated": false
509
- },
510
- "get": {
511
- "tags": ["City CRUD API's"],
512
- "summary": "Get all cities by province id with search",
513
- "operationId": "Get all cities by province id with search",
514
- "parameters": [
515
- {
516
- "name": "provinceId",
517
- "in": "query",
518
- "required": false,
519
- "style": "form",
520
- "explode": true,
521
- "schema": {
522
- "type": "integer",
523
- "format": "int32",
524
- "example": 1
525
- }
526
- },
527
- {
528
- "name": "search",
529
- "in": "query",
530
- "required": false,
531
- "style": "form",
532
- "explode": true,
533
- "schema": {
534
- "type": "string",
535
- "example": ""
536
- }
537
- }
538
- ],
539
- "requestBody": {},
540
- "responses": {
541
- "200": {
542
- "description": "OK"
543
- }
544
- },
545
- "deprecated": false
546
- }
547
- },
548
- "/master/city/{id}": {
549
- "get": {
550
- "tags": ["City CRUD API's"],
551
- "summary": "Get City by id",
552
- "operationId": "Get City by id",
553
- "parameters": [
554
- {
555
- "name": "id",
556
- "in": "path",
557
- "required": true,
558
- "style": "form",
559
- "explode": true,
560
- "schema": {
561
- "type": "integer",
562
- "format": "int32",
563
- "example": 1
564
- }
565
- }
566
- ],
567
- "requestBody": {},
568
- "responses": {
569
- "200": {
570
- "description": "OK"
571
- }
572
- },
573
- "deprecated": false
574
- },
575
- "patch": {
576
- "tags": ["City CRUD API's"],
577
- "summary": "Update City by id",
578
- "operationId": "Update City by id",
579
- "parameters": [
580
- {
581
- "name": "id",
582
- "in": "path",
583
- "required": true,
584
- "style": "form",
585
- "explode": true,
586
- "schema": {
587
- "type": "integer",
588
- "format": "int32",
589
- "example": 1
590
- }
591
- }
592
- ],
593
- "requestBody": {
594
- "content": {
595
- "application/json": {
596
- "schema": {
597
- "$ref": "#/components/schemas/MasterDataRequest"
598
- },
599
- "example": {
600
- "name": "Label"
601
- }
602
- }
603
- },
604
- "required": true
605
- },
606
- "responses": {
607
- "200": {
608
- "description": "OK"
609
- }
610
- },
611
- "deprecated": false
612
- },
613
- "delete": {
614
- "tags": ["City CRUD API's"],
615
- "summary": "Delete City by id",
616
- "operationId": "Delete City by id",
617
- "parameters": [
618
- {
619
- "name": "id",
620
- "in": "path",
621
- "required": true,
622
- "style": "form",
623
- "explode": true,
624
- "schema": {
625
- "type": "integer",
626
- "format": "int32",
627
- "example": 1
628
- }
629
- }
630
- ],
631
- "requestBody": {},
632
- "responses": {
633
- "200": {
634
- "description": "OK"
635
- }
636
- },
637
- "deprecated": false
638
- }
639
- },
640
327
  "/master/permission": {
641
328
  "post": {
642
329
  "tags": ["Permission API's"],
@@ -38,30 +38,6 @@ router.get("/role/:id", verifyToken, validators.getById, MasterController.roleBy
38
38
  router.patch("/role/:id", verifyToken, validators.updateById, MasterController.updateRoleById);
39
39
  router.delete("/role/:id", verifyToken, validators.getById, MasterController.deleteRoleById);
40
40
 
41
- // Province API's
42
- router.get("/province", MasterController.allProvinces);
43
- router.post("/province", verifyToken, validators.addMaster, MasterController.addProvince);
44
- router.get("/province/:id", verifyToken, validators.getById, MasterController.provinceById);
45
- router.patch(
46
- "/province/:id",
47
- verifyToken,
48
- validators.updateById,
49
- MasterController.updateProvinceById
50
- );
51
- router.delete(
52
- "/province/:id",
53
- verifyToken,
54
- validators.getById,
55
- MasterController.deleteProvinceById
56
- );
57
-
58
- // City API's
59
- router.get("/city", validators.allCities, MasterController.allCities);
60
- router.post("/city", verifyToken, validators.addCity, MasterController.addCity);
61
- router.get("/city/:id", verifyToken, validators.getById, MasterController.cityById);
62
- router.patch("/city/:id", verifyToken, validators.updateById, MasterController.updateCityById);
63
- router.delete("/city/:id", verifyToken, validators.getById, MasterController.deleteCityById);
64
-
65
41
  // Permission API's
66
42
  router.post(
67
43
  "/permission",
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+
3
+ module.exports = {
4
+ up: async (queryInterface, Sequelize) => {
5
+ const provinces = [
6
+ { country: "US", code: "AL", name: "Alabama" },
7
+ { country: "US", code: "AK", name: "Alaska" },
8
+ { country: "US", code: "AZ", name: "Arizona" },
9
+ { country: "US", code: "AR", name: "Arkansas" },
10
+ { country: "US", code: "CA", name: "California" },
11
+ { country: "US", code: "CO", name: "Colorado" },
12
+ { country: "US", code: "CT", name: "Connecticut" },
13
+ { country: "US", code: "DE", name: "Delaware" },
14
+ { country: "US", code: "FL", name: "Florida" },
15
+ { country: "US", code: "GA", name: "Georgia" },
16
+ { country: "US", code: "HI", name: "Hawaii" },
17
+ { country: "US", code: "ID", name: "Idaho" },
18
+ { country: "US", code: "IL", name: "Illinois" },
19
+ { country: "US", code: "IN", name: "Indiana" },
20
+ { country: "US", code: "IA", name: "Iowa" },
21
+ { country: "US", code: "KS", name: "Kansas" },
22
+ { country: "US", code: "KY", name: "Kentucky" },
23
+ { country: "US", code: "LA", name: "Louisiana" },
24
+ { country: "US", code: "ME", name: "Maine" },
25
+ { country: "US", code: "MD", name: "Maryland" },
26
+ { country: "US", code: "MA", name: "Massachusetts" },
27
+ { country: "US", code: "MI", name: "Michigan" },
28
+ { country: "US", code: "MN", name: "Minnesota" },
29
+ { country: "US", code: "MS", name: "Mississippi" },
30
+ { country: "US", code: "MO", name: "Missouri" },
31
+ { country: "US", code: "MT", name: "Montana" },
32
+ { country: "US", code: "NE", name: "Nebraska" },
33
+ { country: "US", code: "NV", name: "Nevada" },
34
+ { country: "US", code: "NH", name: "New Hampshire" },
35
+ { country: "US", code: "NJ", name: "New Jersey" },
36
+ { country: "US", code: "NM", name: "New Mexico" },
37
+ { country: "US", code: "NY", name: "New York" },
38
+ { country: "US", code: "NC", name: "North Carolina" },
39
+ { country: "US", code: "ND", name: "North Dakota" },
40
+ { country: "US", code: "OH", name: "Ohio" },
41
+ { country: "US", code: "OK", name: "Oklahoma" },
42
+ { country: "US", code: "OR", name: "Oregon" },
43
+ { country: "US", code: "PA", name: "Pennsylvania" },
44
+ { country: "US", code: "RI", name: "Rhode Island" },
45
+ { country: "US", code: "SC", name: "South Carolina" },
46
+ { country: "US", code: "SD", name: "South Dakota" },
47
+ { country: "US", code: "TN", name: "Tennessee" },
48
+ { country: "US", code: "TX", name: "Texas" },
49
+ { country: "US", code: "UT", name: "Utah" },
50
+ { country: "US", code: "VT", name: "Vermont" },
51
+ { country: "US", code: "VA", name: "Virginia" },
52
+ { country: "US", code: "WA", name: "Washington" },
53
+ { country: "US", code: "WV", name: "West Virginia" },
54
+ { country: "US", code: "WI", name: "Wisconsin" },
55
+ { country: "US", code: "WY", name: "Wyoming" },
56
+ { country: "CA", code: "AB", name: "Alberta" },
57
+ { country: "CA", code: "BC", name: "British Columbia" },
58
+ { country: "CA", code: "MB", name: "Manitoba" },
59
+ { country: "CA", code: "NB", name: "New Brunswick" },
60
+ { country: "CA", code: "NL", name: "Newfoundland and Labrador" },
61
+ { country: "CA", code: "NS", name: "Nova Scotia" },
62
+ { country: "CA", code: "NT", name: "Northwest Territories" },
63
+ { country: "CA", code: "NU", name: "Nunavut" },
64
+ { country: "CA", code: "ON", name: "Ontario" },
65
+ { country: "CA", code: "PE", name: "Prince Edward Island" },
66
+ { country: "CA", code: "QC", name: "Quebec" },
67
+ { country: "CA", code: "SK", name: "Saskatchewan" },
68
+ { country: "CA", code: "YT", name: "Yukon" },
69
+ ];
70
+
71
+ for (const province of provinces) {
72
+ const existingProvince = await queryInterface.rawSelect(
73
+ "Province",
74
+ {
75
+ where: { code: province.code },
76
+ },
77
+ ["id"]
78
+ );
79
+
80
+ if (existingProvince) {
81
+ await queryInterface.bulkUpdate(
82
+ "Province",
83
+ { country: province.country, name: province.name },
84
+ { code: province.code }
85
+ );
86
+ } else {
87
+ await queryInterface.bulkInsert("Province", [province], {});
88
+ }
89
+ }
90
+ },
91
+
92
+ down: async (queryInterface, Sequelize) => {
93
+ await queryInterface.bulkDelete(
94
+ "Province",
95
+ {
96
+ code: provinces.map((province) => province.code),
97
+ },
98
+ {}
99
+ );
100
+ },
101
+ };
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+
3
+ module.exports = {
4
+ up: async (queryInterface, Sequelize) => {
5
+ const citiesList = [
6
+ { city: "Toronto", provinceCode: "ON" },
7
+ { city: "Ottawa", provinceCode: "ON" },
8
+ { city: "Mississauga", provinceCode: "ON" },
9
+ { city: "Brampton", provinceCode: "ON" },
10
+ { city: "Hamilton", provinceCode: "ON" },
11
+ { city: "London", provinceCode: "ON" },
12
+ { city: "Kitchener", provinceCode: "ON" },
13
+ { city: "Windsor", provinceCode: "ON" },
14
+ { city: "Markham", provinceCode: "ON" },
15
+ { city: "Vaughan", provinceCode: "ON" },
16
+ { city: "Montreal", provinceCode: "QC" },
17
+ { city: "Quebec City", provinceCode: "QC" },
18
+ { city: "Laval", provinceCode: "QC" },
19
+ { city: "Gatineau", provinceCode: "QC" },
20
+ { city: "Longueuil", provinceCode: "QC" },
21
+ { city: "Vancouver", provinceCode: "BC" },
22
+ { city: "Surrey", provinceCode: "BC" },
23
+ { city: "Burnaby", provinceCode: "BC" },
24
+ { city: "Richmond", provinceCode: "BC" },
25
+ { city: "Victoria", provinceCode: "BC" },
26
+ { city: "Calgary", provinceCode: "AB" },
27
+ { city: "Edmonton", provinceCode: "AB" },
28
+ { city: "Red Deer", provinceCode: "AB" },
29
+ { city: "Lethbridge", provinceCode: "AB" },
30
+ { city: "Winnipeg", provinceCode: "MB" },
31
+ { city: "Saskatoon", provinceCode: "SK" },
32
+ { city: "Regina", provinceCode: "SK" },
33
+ { city: "Halifax", provinceCode: "NS" },
34
+ { city: "St. Johns", provinceCode: "NL" },
35
+ { city: "Charlottetown", provinceCode: "PE" },
36
+ { city: "Fredericton", provinceCode: "NB" },
37
+ { city: "Whitehorse", provinceCode: "YT" },
38
+ { city: "Yellowknife", provinceCode: "NT" },
39
+ { city: "Iqaluit", provinceCode: "NU" },
40
+ ];
41
+ const provinces = await queryInterface.sequelize.query(
42
+ `SELECT id, code FROM "Province" WHERE code IN (${citiesList
43
+ .map(({ provinceCode }) => `'${provinceCode}'`)
44
+ .join(", ")});`,
45
+ { type: Sequelize.QueryTypes.SELECT }
46
+ );
47
+ process.stdout.write('provinces')
48
+ const provinceMap = provinces.reduce((acc, province) => {
49
+ acc[province.code] = province.id;
50
+ return acc;
51
+ }, {});
52
+ const cities = citiesList.map((city) => ({
53
+ name: city.city,
54
+ provinceId: provinceMap[city.provinceCode],
55
+ provinceCode: city.provinceCode,
56
+ }));
57
+
58
+ for (const city of cities) {
59
+ const existingCity = await queryInterface.rawSelect(
60
+ "City",
61
+ {
62
+ where: { name: city.name, provinceCode: city.provinceCode },
63
+ },
64
+ ["id"]
65
+ );
66
+ if (existingCity) {
67
+ await queryInterface.bulkUpdate(
68
+ "City",
69
+ { name: city.name, provinceCode: city.provinceCode, provinceId: city.provinceId },
70
+ { id: existingCity }
71
+ );
72
+ } else {
73
+ await queryInterface.bulkInsert("City", [city], {});
74
+ }
75
+ }
76
+ },
77
+
78
+ down: async (queryInterface, Sequelize) => {
79
+ await queryInterface.bulkDelete(
80
+ "City",
81
+ {
82
+ name: cities.map((city) => city.name),
83
+ },
84
+ {}
85
+ );
86
+ },
87
+ };
@@ -91,9 +91,7 @@ class ChurchService {
91
91
  const churchDb = await churchManager.getChurchDbConnectionById(churchData.id);
92
92
  await churchDb.user.create({
93
93
  ...churchAdminDetails,
94
- username: churchAdminDetails.email,
95
94
  status: true,
96
- isUserAuthenticated: true,
97
95
  roleId: ROLES.CHURCH_ADMIN,
98
96
  churchId: churchData.id,
99
97
  });