@universis/accommodation 1.0.0

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 (134) hide show
  1. package/.gitlab-ci.yml +23 -0
  2. package/LICENSE +163 -0
  3. package/README.md +3 -0
  4. package/dist/AccommodationSchemaLoader.js +35 -0
  5. package/dist/AccommodationSchemaLoader.js.map +1 -0
  6. package/dist/AccommodationService.js +68 -0
  7. package/dist/AccommodationService.js.map +1 -0
  8. package/dist/DepartmentReplacer.js +54 -0
  9. package/dist/DepartmentReplacer.js.map +1 -0
  10. package/dist/StudentReplacer.js +75 -0
  11. package/dist/StudentReplacer.js.map +1 -0
  12. package/dist/config/models/Accommodation.json +96 -0
  13. package/dist/config/models/AccommodationCardEffectiveStatusType.json +107 -0
  14. package/dist/config/models/AccommodationCardEffectiveStatusTypeLocale.json +85 -0
  15. package/dist/config/models/AccommodationChildFinancialAttribute.json +46 -0
  16. package/dist/config/models/AccommodationGuardianFinancialAttribute.json +46 -0
  17. package/dist/config/models/AccommodationInscriptionModeTag.json +100 -0
  18. package/dist/config/models/AccommodationRequestAction.json +500 -0
  19. package/dist/config/models/AccommodationRequestActionMessage.json +46 -0
  20. package/dist/config/models/AccommodationRequestActionReview.json +31 -0
  21. package/dist/config/models/AccommodationRequestAttachmentConfiguration.json +72 -0
  22. package/dist/config/models/AccommodationRequestCategory.json +50 -0
  23. package/dist/config/models/AccommodationRequestEffectiveStatusType.json +212 -0
  24. package/dist/config/models/AccommodationRequestEffectiveStatusTypeLocale.json +85 -0
  25. package/dist/config/models/AccommodationRequestEvent.json +117 -0
  26. package/dist/config/models/AccommodationRequestFinancialAttribute.json +53 -0
  27. package/dist/config/models/AccommodationRoom.json +151 -0
  28. package/dist/config/models/AccommodationSiblingFinancialAttribute.json +57 -0
  29. package/dist/config/models/CancelAccommodationCardAction.json +32 -0
  30. package/dist/config/models/GuardianType.json +78 -0
  31. package/dist/config/models/Review.json +50 -0
  32. package/dist/config/models/RoomType.json +320 -0
  33. package/dist/config/models/RoomTypeLocale.json +86 -0
  34. package/dist/config/models/StudentAccommodationCard.json +158 -0
  35. package/dist/config/models/TestAction.json +50 -0
  36. package/dist/config/scope.access.js +148 -0
  37. package/dist/config/scope.access.js.map +1 -0
  38. package/dist/index.d.ts +2 -0
  39. package/dist/index.js +3 -0
  40. package/dist/index.js.map +1 -0
  41. package/dist/listeners/AddDefaultAttachmentConfiguration.js +44 -0
  42. package/dist/listeners/AddDefaultAttachmentConfiguration.js.map +1 -0
  43. package/dist/listeners/DefaultAttachmentConfigurations.json +277 -0
  44. package/dist/listeners/DefaultAttachmentTypes.json +523 -0
  45. package/dist/listeners/GenerateRequestNumberListener.js +87 -0
  46. package/dist/listeners/GenerateRequestNumberListener.js.map +1 -0
  47. package/dist/listeners/OnActionCompleteListener.js +96 -0
  48. package/dist/listeners/OnActionCompleteListener.js.map +1 -0
  49. package/dist/listeners/OnCancelAccommodationCardListener.js +87 -0
  50. package/dist/listeners/OnCancelAccommodationCardListener.js.map +1 -0
  51. package/dist/listeners/OnReactivateAccommodationCardListener.js +87 -0
  52. package/dist/listeners/OnReactivateAccommodationCardListener.js.map +1 -0
  53. package/dist/listeners/SendEmailAfterActionStatusChangeListener.js +98 -0
  54. package/dist/listeners/SendEmailAfterActionStatusChangeListener.js.map +1 -0
  55. package/dist/listeners/SendEmailAfterCardStatusChangeListener.js +139 -0
  56. package/dist/listeners/SendEmailAfterCardStatusChangeListener.js.map +1 -0
  57. package/dist/listeners/StudentAccommodationCardSaveListener.js +90 -0
  58. package/dist/listeners/StudentAccommodationCardSaveListener.js.map +1 -0
  59. package/dist/listeners/UpdateStudentAccommodationCardListener.js +70 -0
  60. package/dist/listeners/UpdateStudentAccommodationCardListener.js.map +1 -0
  61. package/dist/listeners/ValidateActionListener.js +348 -0
  62. package/dist/listeners/ValidateActionListener.js.map +1 -0
  63. package/dist/listeners/data-localization.js +209 -0
  64. package/dist/listeners/data-localization.js.map +1 -0
  65. package/dist/listeners/lookup-cache-listener.js +90 -0
  66. package/dist/listeners/lookup-cache-listener.js.map +1 -0
  67. package/dist/models/Accommodation.js +53 -0
  68. package/dist/models/Accommodation.js.map +1 -0
  69. package/dist/models/AccommodationRequestAction.js +214 -0
  70. package/dist/models/AccommodationRequestAction.js.map +1 -0
  71. package/dist/models/AccommodationRequestEvent.js +277 -0
  72. package/dist/models/AccommodationRequestEvent.js.map +1 -0
  73. package/dist/models/EnableAttachmentModel.js +210 -0
  74. package/dist/models/EnableAttachmentModel.js.map +1 -0
  75. package/dist/models/StudentAccommodationCard.js +93 -0
  76. package/dist/models/StudentAccommodationCard.js.map +1 -0
  77. package/dist/models/TestAction.d.ts +5 -0
  78. package/dist/models/TestAction.js +5 -0
  79. package/dist/models/TestAction.js.map +1 -0
  80. package/dist/templates/mail-after-dining-request-status-change/html.ejs +27 -0
  81. package/package.json +57 -0
  82. package/src/AccommodationSchemaLoader.js +35 -0
  83. package/src/AccommodationService.js +67 -0
  84. package/src/DepartmentReplacer.js +53 -0
  85. package/src/StudentReplacer.js +74 -0
  86. package/src/config/models/Accommodation.json +96 -0
  87. package/src/config/models/AccommodationCardEffectiveStatusType.json +107 -0
  88. package/src/config/models/AccommodationCardEffectiveStatusTypeLocale.json +85 -0
  89. package/src/config/models/AccommodationChildFinancialAttribute.json +46 -0
  90. package/src/config/models/AccommodationGuardianFinancialAttribute.json +46 -0
  91. package/src/config/models/AccommodationInscriptionModeTag.json +100 -0
  92. package/src/config/models/AccommodationRequestAction.json +500 -0
  93. package/src/config/models/AccommodationRequestActionMessage.json +46 -0
  94. package/src/config/models/AccommodationRequestActionReview.json +31 -0
  95. package/src/config/models/AccommodationRequestAttachmentConfiguration.json +72 -0
  96. package/src/config/models/AccommodationRequestCategory.json +50 -0
  97. package/src/config/models/AccommodationRequestEffectiveStatusType.json +212 -0
  98. package/src/config/models/AccommodationRequestEffectiveStatusTypeLocale.json +85 -0
  99. package/src/config/models/AccommodationRequestEvent.json +117 -0
  100. package/src/config/models/AccommodationRequestFinancialAttribute.json +53 -0
  101. package/src/config/models/AccommodationRoom.json +151 -0
  102. package/src/config/models/AccommodationSiblingFinancialAttribute.json +57 -0
  103. package/src/config/models/CancelAccommodationCardAction.json +32 -0
  104. package/src/config/models/GuardianType.json +78 -0
  105. package/src/config/models/Review.json +50 -0
  106. package/src/config/models/RoomType.json +320 -0
  107. package/src/config/models/RoomTypeLocale.json +86 -0
  108. package/src/config/models/StudentAccommodationCard.json +158 -0
  109. package/src/config/models/TestAction.json +50 -0
  110. package/src/config/scope.access.js +148 -0
  111. package/src/index.d.ts +2 -0
  112. package/src/index.js +2 -0
  113. package/src/listeners/AddDefaultAttachmentConfiguration.js +43 -0
  114. package/src/listeners/DefaultAttachmentConfigurations.json +277 -0
  115. package/src/listeners/DefaultAttachmentTypes.json +523 -0
  116. package/src/listeners/GenerateRequestNumberListener.js +86 -0
  117. package/src/listeners/OnActionCompleteListener.js +95 -0
  118. package/src/listeners/OnCancelAccommodationCardListener.js +86 -0
  119. package/src/listeners/OnReactivateAccommodationCardListener.js +86 -0
  120. package/src/listeners/SendEmailAfterActionStatusChangeListener.js +97 -0
  121. package/src/listeners/SendEmailAfterCardStatusChangeListener.js +138 -0
  122. package/src/listeners/StudentAccommodationCardSaveListener.js +89 -0
  123. package/src/listeners/UpdateStudentAccommodationCardListener.js +69 -0
  124. package/src/listeners/ValidateActionListener.js +347 -0
  125. package/src/listeners/data-localization.js +214 -0
  126. package/src/listeners/lookup-cache-listener.js +89 -0
  127. package/src/models/Accommodation.js +52 -0
  128. package/src/models/AccommodationRequestAction.js +195 -0
  129. package/src/models/AccommodationRequestEvent.js +276 -0
  130. package/src/models/EnableAttachmentModel.js +209 -0
  131. package/src/models/StudentAccommodationCard.js +92 -0
  132. package/src/models/TestAction.d.ts +5 -0
  133. package/src/models/TestAction.js +10 -0
  134. package/src/templates/mail-after-dining-request-status-change/html.ejs +27 -0
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ var _data = require("@themost/data");
3
+ var _common = require("@themost/common");var _dec, _dec2, _dec3, _class, _class2;function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) {var desc = {};Object.keys(descriptor).forEach(function (key) {desc[key] = descriptor[key];});desc.enumerable = !!desc.enumerable;desc.configurable = !!desc.configurable;if ('value' in desc || desc.initializer) {desc.writable = true;}desc = decorators.slice().reverse().reduce(function (desc, decorator) {return decorator(target, property, desc) || desc;}, desc);if (context && desc.initializer !== void 0) {desc.value = desc.initializer ? desc.initializer.call(context) : void 0;desc.initializer = undefined;}if (desc.initializer === void 0) {Object.defineProperty(target, property, desc);desc = null;}return desc;}
4
+
5
+ /**
6
+ * @class
7
+
8
+ * @property {number} id
9
+ * @property {number} serialNumber
10
+ * @property {boolean} active
11
+ * @property {string} cancelReason
12
+ * @property {string} notes
13
+ * @property {AccommodationRequestAction|any} action
14
+ * @property {AcademicYear|any} academicYear
15
+ * @property {AcademicPeriod|any} academicPeriod
16
+ * @property {Date} dateCreated
17
+ * @property {Date} dateModified
18
+ * @property {Date} validFrom
19
+ * @property {Date} validThrough
20
+ * @property {User|any} student
21
+ */let
22
+
23
+ StudentAccommodationCard = (_dec = _data.EdmMapping.entityType('StudentAccommodationCard'), _dec2 =
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+ _data.EdmMapping.param('data', 'Object', false, true), _dec3 =
34
+ _data.EdmMapping.action('cancel', 'StudentAccommodationCard'), _dec(_class = (_class2 = class StudentAccommodationCard extends _data.DataObject {/**
35
+ * @constructor
36
+ */constructor() {super();} /**
37
+ * POST StudentAccommodationCards/:id/Cancel
38
+ */async cancel(data) {if (!data.cancelReason) {
39
+ throw new _common.DataError('E_CANCEL_REASON', 'Cancel Reason should be provided');
40
+ }
41
+
42
+ await this.context.executeInTransactionAsync(async () => {
43
+ // find StudentAccommodationCard from id
44
+ const StudentAccommodationCard = await this.context.model('StudentAccommodationCard').
45
+ where('id').
46
+ equal(this.getId()).
47
+ select('id', 'active', 'action', 'student', 'academicPeriod', 'academicYear').
48
+ flatten().
49
+ getItem();
50
+
51
+ // validate existance and permission
52
+ if (StudentAccommodationCard == null) {
53
+ throw new _common.DataNotFoundError('The specified Student Accommodation Card cannot be found or is inaccessible');
54
+ }
55
+ // StudentAccommodationCard already cancelled throw error
56
+ if (StudentAccommodationCard.active === false) {
57
+ throw new _common.DataError('E_ACTIVE', 'The specified Student Accommodation Card is already cancelled');
58
+ }
59
+
60
+ //validate AccommodationRequestAction
61
+ if (StudentAccommodationCard.action == null) {
62
+ throw new _common.DataError('E_ACTION', 'The Student Accommodation Card is not linked to a Accommodation Request Action');
63
+ }
64
+
65
+ // cancel StudentAccommodationCard
66
+ StudentAccommodationCard.cardStatus = { alternateName: "CancelledActionStatus" };
67
+ StudentAccommodationCard.cancelReason = data.cancelReason;
68
+ await this.context.model('StudentAccommodationCard').save(StudentAccommodationCard);
69
+
70
+ const action = await this.context.model('AccommodationRequestAction').where('id').equal(StudentAccommodationCard.action).select('id', 'actionStatus/alternateName as requestStatus').getItem();
71
+ //validate AccommodationRequestAction
72
+ if (action == null) {
73
+ throw new _common.DataError('E_ACTION', 'The specified AccommodationRequestAction cannot be found or is inaccessible');
74
+ }
75
+
76
+ if (action.requestStatus !== 'CompletedActionStatus') {
77
+ throw new _common.DataError('E_ACTION', 'The specified AccommodationRequestAction is not in Completed state');
78
+ }
79
+
80
+ action.actionStatus = {
81
+ alternateName: "ActiveActionStatus"
82
+ };
83
+
84
+ delete action.requestStatus;
85
+ await this.context.model('AccommodationRequestAction').save(action);
86
+ });
87
+ }
88
+
89
+
90
+ }, (_applyDecoratedDescriptor(_class2.prototype, "cancel", [_dec2, _dec3], Object.getOwnPropertyDescriptor(_class2.prototype, "cancel"), _class2.prototype)), _class2)) || _class);
91
+
92
+ module.exports = StudentAccommodationCard;
93
+ //# sourceMappingURL=StudentAccommodationCard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StudentAccommodationCard.js","names":["_data","require","_common","_dec","_dec2","_dec3","_class","_class2","_applyDecoratedDescriptor","target","property","decorators","descriptor","context","desc","Object","keys","forEach","key","enumerable","configurable","initializer","writable","slice","reverse","reduce","decorator","value","call","undefined","defineProperty","StudentAccommodationCard","EdmMapping","entityType","param","action","DataObject","constructor","cancel","data","cancelReason","DataError","executeInTransactionAsync","model","where","equal","getId","select","flatten","getItem","DataNotFoundError","active","cardStatus","alternateName","save","requestStatus","actionStatus","prototype","getOwnPropertyDescriptor","module","exports"],"sources":["../../src/models/StudentAccommodationCard.js"],"sourcesContent":["\nimport { DataObject, EdmMapping } from '@themost/data';\nimport { DataError, DataNotFoundError } from \"@themost/common\"\n\n/**\n * @class\n \n * @property {number} id \n * @property {number} serialNumber \n * @property {boolean} active \n * @property {string} cancelReason \n * @property {string} notes \n * @property {AccommodationRequestAction|any} action \n * @property {AcademicYear|any} academicYear\n * @property {AcademicPeriod|any} academicPeriod\n * @property {Date} dateCreated \n * @property {Date} dateModified \n * @property {Date} validFrom \n * @property {Date} validThrough \n * @property {User|any} student \n */\n@EdmMapping.entityType('StudentAccommodationCard')\nclass StudentAccommodationCard extends DataObject {\n /**\n * @constructor\n */\n constructor() {\n super();\n }\n /**\n * POST StudentAccommodationCards/:id/Cancel\n */\n @EdmMapping.param('data', 'Object', false, true)\n @EdmMapping.action('cancel', 'StudentAccommodationCard')\n\n async cancel(data) {\n\n if (!data.cancelReason) {\n throw new DataError('E_CANCEL_REASON', 'Cancel Reason should be provided');\n }\n\n await this.context.executeInTransactionAsync(async () => {\n // find StudentAccommodationCard from id\n const StudentAccommodationCard = await this.context.model('StudentAccommodationCard')\n .where('id')\n .equal(this.getId())\n .select('id', 'active', 'action', 'student', 'academicPeriod', 'academicYear')\n .flatten()\n .getItem();\n\n // validate existance and permission\n if (StudentAccommodationCard == null) {\n throw new DataNotFoundError('The specified Student Accommodation Card cannot be found or is inaccessible');\n }\n // StudentAccommodationCard already cancelled throw error\n if (StudentAccommodationCard.active === false) {\n throw new DataError('E_ACTIVE', 'The specified Student Accommodation Card is already cancelled')\n }\n\n //validate AccommodationRequestAction\n if (StudentAccommodationCard.action == null) {\n throw new DataError('E_ACTION', 'The Student Accommodation Card is not linked to a Accommodation Request Action')\n }\n\n // cancel StudentAccommodationCard\n StudentAccommodationCard.cardStatus = {alternateName: \"CancelledActionStatus\"};\n StudentAccommodationCard.cancelReason = data.cancelReason;\n await this.context.model('StudentAccommodationCard').save(StudentAccommodationCard);\n\n const action = await this.context.model('AccommodationRequestAction').where('id').equal(StudentAccommodationCard.action).select('id', 'actionStatus/alternateName as requestStatus').getItem();\n //validate AccommodationRequestAction\n if (action == null) {\n throw new DataError('E_ACTION', 'The specified AccommodationRequestAction cannot be found or is inaccessible')\n }\n\n if (action.requestStatus !== 'CompletedActionStatus') {\n throw new DataError('E_ACTION', 'The specified AccommodationRequestAction is not in Completed state')\n }\n\n action.actionStatus = {\n alternateName: \"ActiveActionStatus\"\n }\n\n delete action.requestStatus;\n await this.context.model('AccommodationRequestAction').save(action);\n });\n }\n\n\n}\n\nmodule.exports = StudentAccommodationCard;"],"mappings":";AACA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA,oBAA8D,IAAAE,IAAA,EAAAC,KAAA,EAAAC,KAAA,EAAAC,MAAA,EAAAC,OAAA,UAAAC,0BAAAC,MAAA,EAAAC,QAAA,EAAAC,UAAA,EAAAC,UAAA,EAAAC,OAAA,OAAAC,IAAA,MAAAC,MAAA,CAAAC,IAAA,CAAAJ,UAAA,EAAAK,OAAA,WAAAC,GAAA,GAAAJ,IAAA,CAAAI,GAAA,IAAAN,UAAA,CAAAM,GAAA,KAAAJ,IAAA,CAAAK,UAAA,KAAAL,IAAA,CAAAK,UAAA,CAAAL,IAAA,CAAAM,YAAA,KAAAN,IAAA,CAAAM,YAAA,gBAAAN,IAAA,IAAAA,IAAA,CAAAO,WAAA,GAAAP,IAAA,CAAAQ,QAAA,SAAAR,IAAA,GAAAH,UAAA,CAAAY,KAAA,GAAAC,OAAA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AS,CAAC,UAAU,EAAE,oEAAoE,CAAC;MACzG;;MAEAN,MAAM,CAACqB,YAAY,GAAG;QAClBH,aAAa,EAAE;MACnB,CAAC;;MAED,OAAOlB,MAAM,CAACoB,aAAa;MAC3B,MAAM,IAAI,CAAC1C,OAAO,CAAC8B,KAAK,CAAC,4BAA4B,CAAC,CAACW,IAAI,CAACnB,MAAM,CAAC;IACvE,CAAC,CAAC;EACN;;;AAGJ,CAAC,GAAA3B,yBAAA,CAAAD,OAAA,CAAAkD,SAAA,aAAArD,KAAA,EAAAC,KAAA,GAAAU,MAAA,CAAA2C,wBAAA,CAAAnD,OAAA,CAAAkD,SAAA,aAAAlD,OAAA,CAAAkD,SAAA,IAAAlD,OAAA,MAAAD,MAAA;;AAEDqD,MAAM,CAACC,OAAO,GAAG7B,wBAAwB"}
@@ -0,0 +1,5 @@
1
+ import { DataObject } from '@themost/data';
2
+
3
+ export declare class TestAction extends DataObject {
4
+
5
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.TestAction = void 0;var _data = require("@themost/data");var _dec, _class;let
2
+
3
+
4
+ TestAction = (_dec = _data.EdmMapping.entityType(), _dec(_class = class TestAction extends _data.DataObject {}) || _class);exports.TestAction = TestAction;
5
+ //# sourceMappingURL=TestAction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TestAction.js","names":["_data","require","_dec","_class","TestAction","EdmMapping","entityType","DataObject","exports"],"sources":["../../src/models/TestAction.js"],"sourcesContent":["import { DataObject, EdmMapping } from \"@themost/data\";\n\n@EdmMapping.entityType()\nclass TestAction extends DataObject {\n\n}\n\nexport {\n TestAction\n}"],"mappings":"uGAAA,IAAAA,KAAA,GAAAC,OAAA,kBAAuD,IAAAC,IAAA,EAAAC,MAAA;;;AAGjDC,UAAU,IAAAF,IAAA,GADfG,gBAAU,CAACC,UAAU,EAAE,EAAAJ,IAAA,CAAAC,MAAA,GAAxB,MACMC,UAAU,SAASG,gBAAU,CAAC,EAEnC,KAAAJ,MAAA,EAAAK,OAAA,CAAAJ,UAAA,GAAAA,UAAA"}
@@ -0,0 +1,27 @@
1
+ <html lang="en">
2
+ <head>
3
+ <link rel="stylesheet"
4
+ href="https://unpkg.com/@universis/theme@1.0.5/css/universis.css"
5
+ integrity="sha384-GcIMWx3Jq0rHFUoV9TxtmxKkYHxwNoaXhDb/sNO7H6s6X34p02LJyfVwnH2B61sl"
6
+ crossorigin="anonymous">
7
+ </head>
8
+ <body>
9
+ <div class="container-fluid">
10
+ <div class="text-right mb-2">
11
+ <img style="height: 64px" src="https://students.universis.io/assets/img/universis_logo_128_color.png"
12
+ alt="Universis Project Logo">
13
+ </div>
14
+ <div class="page-header">
15
+ <h3>Κατάσταση Αίτησης Σίτισης</h3>
16
+ </div>
17
+ <p>Αγαπητέ/ή <%= model.student.person.givenName %> <%= model.student.person.familyName %>,</p>
18
+ <p>
19
+ Η κατάσταση της αίτησης σίτισής σου άλλαξε. Μπορείς να δεις την τρέχουσα εικόνα της αίτησης <a href="<%= application.url %>/#/<%= configuration.url %>">εδώ</a>
20
+ </p>
21
+
22
+ <br>
23
+ <p>Με εκτίμηση,</p>
24
+ <p>Universis Support</p>
25
+ </div>
26
+ </body>
27
+ </html>
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@universis/accommodation",
3
+ "version": "1.0.0",
4
+ "description": "Universis api library template",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "engines": {
8
+ "node": ">=14"
9
+ },
10
+ "scripts": {
11
+ "test": "jasmine",
12
+ "build": "rimraf dist && babel src --out-dir dist --copy-files --source-maps"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://gitlab.com/universis/accommodation.git"
17
+ },
18
+ "keywords": [
19
+ "universis",
20
+ "api",
21
+ "extension",
22
+ "plugin",
23
+ "library",
24
+ "microservice"
25
+ ],
26
+ "author": "",
27
+ "license": "LGPL-3.0-or-later",
28
+ "bugs": {
29
+ "url": "https://gitlab.com/universis/accommodation/issues"
30
+ },
31
+ "dependencies": {},
32
+ "peerDependencies": {
33
+ "@themost/common": "^2",
34
+ "@themost/data": "^2",
35
+ "@themost/query": "^2",
36
+ "@themost/xml": "^2",
37
+ "@themost/express": "^1"
38
+ },
39
+ "devDependencies": {
40
+ "@babel/cli": "^7.21.0",
41
+ "@babel/core": "^7.21.4",
42
+ "@babel/eslint-parser": "^7.21.3",
43
+ "@babel/plugin-proposal-decorators": "^7.21.0",
44
+ "@babel/preset-env": "^7.21.4",
45
+ "@babel/register": "^7.21.0",
46
+ "@rollup/plugin-babel": "^6.0.3",
47
+ "@types/express": "^4.17.6",
48
+ "@types/jasmine": "^3.5.10",
49
+ "dotenv": "^8.2.0",
50
+ "eslint": "^8.39.0",
51
+ "jasmine": "^4.6.0",
52
+ "jasmine-spec-reporter": "^5.0.2",
53
+ "rimraf": "3.0.2",
54
+ "typescript": "^5.0.4"
55
+ },
56
+ "homepage": "https://gitlab.com/universis/accommodation#readme"
57
+ }
@@ -0,0 +1,35 @@
1
+ import {FileSchemaLoaderStrategy} from "@themost/data";
2
+ import path from 'path';
3
+ /**
4
+ * A schema loader for loading extra data models
5
+ */
6
+ export class AccommodationSchemaLoader extends FileSchemaLoaderStrategy {
7
+
8
+ /**
9
+ * @param {ConfigurationBase} config
10
+ */
11
+ constructor(config) {
12
+ super(config);
13
+ // set model path
14
+ this.setModelPath(path.resolve(__dirname, 'config/models'));
15
+ }
16
+
17
+ getModelDefinition(name) {
18
+ const model = super.getModelDefinition.bind(this)(name);
19
+ if (model) {
20
+ if (Array.isArray(model.eventListeners) ) {
21
+ model.eventListeners.forEach(eventListener => {
22
+ if (eventListener.type.indexOf('.') === 0) {
23
+ eventListener.type = path.resolve(__dirname, eventListener.type);
24
+ }
25
+ });
26
+ }
27
+ if (model.classPath && model.classPath.indexOf('.')===0) {
28
+ model.classPath= path.resolve(__dirname, model.classPath);
29
+ }
30
+ }
31
+ return model;
32
+ }
33
+
34
+ }
35
+
@@ -0,0 +1,67 @@
1
+ import { ApplicationService, Args } from "@themost/common";
2
+ import LocalScopeAccessConfiguration from './config/scope.access';
3
+ import { StudentReplacer } from "./StudentReplacer";
4
+ export class AccommodationService extends ApplicationService {
5
+ constructor(app) {
6
+ super(app);
7
+ new StudentReplacer(app).apply();
8
+ // new DepartmentReplacer(app).apply();
9
+ // extend universis api scope access configuration
10
+ if (app && app.container) {
11
+ app.container.subscribe((container) => {
12
+ if (container) {
13
+ // add extra scope access elements
14
+ const scopeAccess = app.getConfiguration().getStrategy(function ScopeAccessConfiguration() { });
15
+ if (scopeAccess != null) {
16
+ scopeAccess.elements.push.apply(scopeAccess.elements, LocalScopeAccessConfiguration);
17
+ console.log('Local scope access configuration has been loaded.');
18
+ }
19
+ }
20
+ });
21
+ }
22
+ }
23
+
24
+
25
+ /**
26
+ * Returns the next request number based on the given request event
27
+ * @param {*} context
28
+ * @param {*} requestEvent
29
+ * @returns
30
+ */
31
+ async nextNumber(context, requestEvent) {
32
+ // validate id
33
+ const model = context.model('AccommodationRequestEvent');
34
+ const parentRequestEvent = model.convert(requestEvent);
35
+ const id = parentRequestEvent.id;
36
+ Args.notNumber(id, 'Item identifier');
37
+ let lastIndex;
38
+ await new Promise((resolve, reject) => {
39
+ context.db.executeInTransaction(cb => {
40
+ // execute async method
41
+ (async function () {
42
+ /**
43
+ * @type {{lastIndex: any}}
44
+ */
45
+ const item = await model.where('id').equal(id).select('lastIndex').silent().getItem();
46
+ //get last index or 0
47
+ lastIndex = item.lastIndex ? item.lastIndex : 0;
48
+ // increase last index
49
+ lastIndex += 1;
50
+ // save last index
51
+ await model.silent().save({ id, lastIndex });
52
+ })().then(() => {
53
+ return cb();
54
+ }).catch(err => {
55
+ return cb(err);
56
+ });
57
+ }, err => {
58
+ if (err) {
59
+ return reject(err);
60
+ }
61
+ return resolve();
62
+ });
63
+ });
64
+ return lastIndex;
65
+ }
66
+
67
+ }
@@ -0,0 +1,53 @@
1
+ import { ApplicationService, TraceUtils } from '@themost/common';
2
+ import {
3
+ SchemaLoaderStrategy,
4
+
5
+ } from '@themost/data';
6
+
7
+
8
+ export class DepartmentReplacer extends ApplicationService {
9
+ constructor(app) {
10
+ super(app);
11
+ }
12
+
13
+ apply() {
14
+ try {
15
+ // get schema loader
16
+ const schemaLoader = this.getApplication()
17
+ .getConfiguration()
18
+ .getStrategy(SchemaLoaderStrategy);
19
+ // get model definition
20
+ const model = schemaLoader.getModelDefinition('Department');
21
+ const findAttribute = model.fields.find((field) => {
22
+ return field.name === 'accommodation';
23
+ });
24
+ if (findAttribute == null) {
25
+ model.fields.push({
26
+ "name": "accommodation",
27
+ "@id": "https://universis.io/schemas/accommodation",
28
+ "title": "Accommodation place",
29
+ "description": "Building accommodate students",
30
+ "type": "Accommodation",
31
+ "editable": true,
32
+ "nullable": false
33
+ },);
34
+ // model.eventListeners = model.eventListeners || [];
35
+ // model.eventListeners.push({
36
+ // type: path.resolve(
37
+ // __dirname,
38
+ // 'listeners/UpdateStudenDiningCardListener'
39
+ // ),
40
+ // });
41
+ schemaLoader.setModelDefinition(model);
42
+ }
43
+ // get model class loader
44
+
45
+ } catch (err) {
46
+ TraceUtils.error(
47
+ 'An error occured while the DiningService tried to extend the Student model (StudentReplacer).'
48
+ );
49
+ TraceUtils.error(err);
50
+ throw err;
51
+ }
52
+ }
53
+ }
@@ -0,0 +1,74 @@
1
+ import { ApplicationService, DataError, TraceUtils } from '@themost/common';
2
+ import {
3
+ SchemaLoaderStrategy,
4
+ DataObject,
5
+ EdmMapping,
6
+ ModelClassLoaderStrategy,
7
+ } from '@themost/data';
8
+ import path from 'path';
9
+ import fs from 'fs';
10
+
11
+ export class Student extends DataObject {
12
+
13
+ }
14
+
15
+ export class StudentReplacer extends ApplicationService {
16
+ constructor(app) {
17
+ super(app);
18
+ }
19
+
20
+ apply() {
21
+ try {
22
+ // get schema loader
23
+ const schemaLoader = this.getApplication()
24
+ .getConfiguration()
25
+ .getStrategy(SchemaLoaderStrategy);
26
+ // get model definition
27
+ const model = schemaLoader.getModelDefinition('Student');
28
+ const findAttribute = model.fields.find((field) => {
29
+ return field.name === 'accommodationCard';
30
+ });
31
+ if (findAttribute == null) {
32
+ model.fields.push({
33
+ name: 'accommodationCard',
34
+ type: 'AccommodationCard',
35
+ many: true,
36
+ multiplicity: 'ZeroOrOne',
37
+ mapping: {
38
+ associationType: 'junction',
39
+ associationAdapter: 'StudentAccommodationCard',
40
+ associatedObjectField: 'student',
41
+ associatedValueField: 'accommodationCard',
42
+ cascade: 'delete',
43
+ parentModel: 'Student',
44
+ parentField: 'id',
45
+ childModel: 'AccommodationCard',
46
+ childField: 'id',
47
+ },
48
+ });
49
+ model.eventListeners = model.eventListeners || [];
50
+ model.eventListeners.push({
51
+ type: path.resolve(
52
+ __dirname,
53
+ 'listeners/UpdateStudentAccommodationCardListener'
54
+ ),
55
+ });
56
+ schemaLoader.setModelDefinition(model);
57
+ }
58
+ // get model class loader
59
+ const loader = this.getApplication()
60
+ .getConfiguration()
61
+ .getStrategy(ModelClassLoaderStrategy);
62
+ // and student class
63
+ const StudentClass = loader.resolve(model);
64
+ // extend existing functions
65
+
66
+ } catch (err) {
67
+ TraceUtils.error(
68
+ 'An error occured while the AccommodationService tried to extend the Student model (StudentReplacer).'
69
+ );
70
+ TraceUtils.error(err);
71
+ throw err;
72
+ }
73
+ }
74
+ }
@@ -0,0 +1,96 @@
1
+ {
2
+ "$schema": "https://themost-framework.github.io/themost/models/2018/2/schema.json",
3
+ "@id": "http://schema.org/Accommodation",
4
+ "name": "Accommodation",
5
+ "description": "An accommodation is a place that can accommodate human beings, e.g. a hotel room, a camping pitch, or a meeting room.",
6
+ "title": "Accommodation",
7
+ "abstract": false,
8
+ "sealed": false,
9
+ "implements": "Place",
10
+ "classPath": "./models/Accommodation",
11
+ "version": "1.5",
12
+ "fields": [
13
+ {
14
+ "@id": "http://schema.org/identifier",
15
+ "name": "identifier",
16
+ "title": "identifier",
17
+ "description": "The identifier property represents any kind of identifier for any kind of Thing, such as ISBNs, GTIN codes, UUIDs etc. Schema.org provides dedicated properties for representing many of these, either as textual strings or as URL (URI) links.",
18
+ "type": "Guid",
19
+ "value": "javascript:return this.newGuid();",
20
+ "nullable": false,
21
+ "editable": false
22
+ },
23
+ {
24
+ "name": "petsAllowed",
25
+ "type": "Boolean",
26
+ "default": true
27
+ },
28
+ {
29
+ "name": "numberOfRooms",
30
+ "description": "The number of rooms (excluding bathrooms and closets) of the accommodation.",
31
+ "type": "Number",
32
+ "nullable": false,
33
+ "editable": true
34
+ },
35
+ {
36
+ "@id": "http://schema.org/events",
37
+ "name": "events",
38
+ "title": "events",
39
+ "description": "Upcoming or past events associated with this place or organization.",
40
+ "type": "AccommodationRequestEvent"
41
+ },
42
+ {
43
+ "@id": "http://schema.org/telephone",
44
+ "name": "securityPhoneNumber",
45
+ "title": "telephone",
46
+ "description": "The contact phone number for the security office or personnel of the student accommodation, available for emergencies or security issues.",
47
+ "type": "Text"
48
+ },
49
+ {
50
+ "name": "active",
51
+ "type": "Boolean",
52
+ "default": true
53
+ },
54
+ {
55
+ "@id": "http://schema.org/address",
56
+ "name": "address",
57
+ "title": "address",
58
+ "description": "Physical address of the item.",
59
+ "type": "Json",
60
+ "additionalType": "PostalAddress"
61
+ },
62
+ {
63
+ "@id": "http://schema.org/geo",
64
+ "name": "geo",
65
+ "title": "geo",
66
+ "description": "The geo coordinates of the accommodation.",
67
+ "type": "Json",
68
+ "additionalType": "GeoCoordinates"
69
+ }
70
+ ],
71
+ "eventListeners": [],
72
+ "constraints": [
73
+ {
74
+ "type": "unique",
75
+ "fields": [
76
+ "identifier"
77
+ ]
78
+ }
79
+ ],
80
+ "privileges": [
81
+ {
82
+ "mask": 1,
83
+ "type": "global",
84
+ "account": "*"
85
+ },
86
+ {
87
+ "mask": 31,
88
+ "type": "global"
89
+ },
90
+ {
91
+ "mask": 15,
92
+ "type": "global",
93
+ "account": "Administrators"
94
+ }
95
+ ]
96
+ }
@@ -0,0 +1,107 @@
1
+ {
2
+ "$schema": "https://themost-framework.github.io/themost/models/2018/2/schema.json",
3
+ "@id": "http://schema.org/AccommodationCardEffectiveStatusType",
4
+ "name": "AccommodationCardEffectiveStatusType",
5
+ "description": "The effective status of a potential Accommodation request action.",
6
+ "title": "AccommodationCardEffectiveStatusType",
7
+ "abstract": false,
8
+ "sealed": false,
9
+ "implements": "ActionStatusType",
10
+ "version": "1.2",
11
+ "fields": [
12
+ {
13
+ "@id": "http://schema.org/additionalType",
14
+ "name": "additionalType",
15
+ "type": "Text",
16
+ "readonly": true,
17
+ "nullable": false,
18
+ "value": "javascript:return this.model.name;"
19
+ },
20
+ {
21
+ "@id": "http://schema.org/alternateName",
22
+ "name": "alternateName",
23
+ "type": "Text",
24
+ "nullable": false
25
+ },
26
+ {
27
+ "@id": "http://schema.org/name",
28
+ "name": "name",
29
+ "type": "Text",
30
+ "nullable": false
31
+ },
32
+ {
33
+ "name": "activates",
34
+ "type": "Boolean",
35
+ "nullable": true
36
+ },
37
+ {
38
+ "name": "locales",
39
+ "type": "AccommodationCardEffectiveStatusTypeLocale",
40
+ "mapping": {
41
+ "associationType": "association",
42
+ "cascade": "delete",
43
+ "parentModel": "AccommodationCardEffectiveStatusType",
44
+ "parentField": "id",
45
+ "childModel": "AccommodationCardEffectiveStatusTypeLocale",
46
+ "childField": "object"
47
+ }
48
+ },
49
+ {
50
+ "name": "locale",
51
+ "type": "AccommodationCardEffectiveStatusTypeLocale",
52
+ "readonly": true,
53
+ "editable": false,
54
+ "many": true,
55
+ "expandable": true,
56
+ "multiplicity": "ZeroOrOne",
57
+ "mapping": {
58
+ "associationType": "association",
59
+ "cascade": "delete",
60
+ "parentModel": "AccommodationCardEffectiveStatusType",
61
+ "parentField": "id",
62
+ "childModel": "AccommodationCardEffectiveStatusTypeLocale",
63
+ "childField": "object",
64
+ "options": {
65
+ "$filter": "inLanguage eq lang()",
66
+ "$first": true
67
+ }
68
+ }
69
+ }
70
+ ],
71
+ "eventListeners": [
72
+ {
73
+ "type": "./listeners/data-localization"
74
+ }
75
+ ],
76
+ "privileges": [
77
+ {
78
+ "mask": 1,
79
+ "type": "global",
80
+ "account": "*"
81
+ },
82
+ {
83
+ "mask": 15,
84
+ "type": "global"
85
+ },
86
+ {
87
+ "mask": 15,
88
+ "type": "global",
89
+ "account": "Administrators"
90
+ },
91
+ {
92
+ "mask": 15,
93
+ "type": "global",
94
+ "account": "AccommodationAdministrators"
95
+ }
96
+ ],
97
+ "constraints": [
98
+ {
99
+ "type": "unique",
100
+ "description": "Alternate name must be unique across different records",
101
+ "fields": [
102
+ "alternateName"
103
+ ]
104
+ }
105
+ ]
106
+
107
+ }