@ozdao/prometheus-framework 0.2.60 → 0.2.61

Sign up to get free protection for your applications and to get access to all the features.
Files changed (207) hide show
  1. package/dist/auth.server.js +12 -223
  2. package/dist/auth.server.mjs +12 -223
  3. package/dist/community.server.js +3 -2
  4. package/dist/community.server.mjs +2 -1
  5. package/dist/events.server.js +101 -29
  6. package/dist/events.server.mjs +100 -28
  7. package/dist/files.server.js +7 -7
  8. package/dist/files.server.mjs +7 -7
  9. package/dist/gallery.server.js +2 -2
  10. package/dist/gallery.server.mjs +2 -2
  11. package/dist/main-DsseFd2d.mjs +13753 -0
  12. package/dist/main-U466Gwzt.js +91 -0
  13. package/dist/main.css +1 -1
  14. package/dist/metadata.schema-CS6_9GLU.js +174 -0
  15. package/dist/metadata.schema-D88c1Ebp.mjs +175 -0
  16. package/dist/organizations.server.js +212 -16
  17. package/dist/organizations.server.mjs +212 -16
  18. package/dist/ownership.schema-DN0SlQL6.js +36 -0
  19. package/dist/ownership.schema-oyx6eNkZ.mjs +37 -0
  20. package/dist/products.server.js +8 -5
  21. package/dist/products.server.mjs +8 -5
  22. package/dist/prometheus-framework/src/components/Chips/Chips.vue.cjs +1 -1
  23. package/dist/prometheus-framework/src/components/Chips/Chips.vue.js +19 -14
  24. package/dist/prometheus-framework/src/components/Feed/Feed.vue.cjs +1 -1
  25. package/dist/prometheus-framework/src/components/Feed/Feed.vue.js +27 -27
  26. package/dist/prometheus-framework/src/components/Loader/Loader.vue.cjs +1 -1
  27. package/dist/prometheus-framework/src/components/Loader/Loader.vue.js +1 -51
  28. package/dist/prometheus-framework/src/components/Loader/Loader.vue2.cjs +1 -1
  29. package/dist/prometheus-framework/src/components/Loader/Loader.vue2.js +51 -1
  30. package/dist/prometheus-framework/src/components/Popup/Popup.vue.cjs +1 -1
  31. package/dist/prometheus-framework/src/components/Popup/Popup.vue.js +1 -72
  32. package/dist/prometheus-framework/src/components/Popup/Popup.vue2.cjs +1 -1
  33. package/dist/prometheus-framework/src/components/Popup/Popup.vue2.js +72 -1
  34. package/dist/prometheus-framework/src/components/Select/Select.vue.cjs +1 -1
  35. package/dist/prometheus-framework/src/components/Select/Select.vue.js +1 -97
  36. package/dist/prometheus-framework/src/components/Select/Select.vue2.cjs +1 -1
  37. package/dist/prometheus-framework/src/components/Select/Select.vue2.js +97 -1
  38. package/dist/prometheus-framework/src/components/Slider/Slider.vue.cjs +1 -1
  39. package/dist/prometheus-framework/src/components/Slider/Slider.vue.js +1 -1
  40. package/dist/prometheus-framework/src/components/Spoiler/Spoiler.vue.cjs +1 -1
  41. package/dist/prometheus-framework/src/components/Spoiler/Spoiler.vue.js +1 -36
  42. package/dist/prometheus-framework/src/components/Spoiler/Spoiler.vue2.cjs +1 -1
  43. package/dist/prometheus-framework/src/components/Spoiler/Spoiler.vue2.js +36 -1
  44. package/dist/prometheus-framework/src/components/Tab/Tab.vue.cjs +1 -1
  45. package/dist/prometheus-framework/src/components/Tab/Tab.vue.js +46 -1
  46. package/dist/prometheus-framework/src/components/Tab/Tab.vue2.cjs +1 -1
  47. package/dist/prometheus-framework/src/components/Tab/Tab.vue2.js +1 -46
  48. package/dist/prometheus-framework/src/components/UploadImageMultiple/UploadImageMultiple.vue.cjs +1 -1
  49. package/dist/prometheus-framework/src/components/UploadImageMultiple/UploadImageMultiple.vue.js +1 -1
  50. package/dist/prometheus-framework/src/modules/auth/auth.client.cjs +1 -1
  51. package/dist/prometheus-framework/src/modules/auth/auth.client.js +12 -14
  52. package/dist/prometheus-framework/src/modules/auth/components/layouts/Auth.vue.cjs +1 -1
  53. package/dist/prometheus-framework/src/modules/auth/components/layouts/Auth.vue.js +1 -1
  54. package/dist/prometheus-framework/src/modules/auth/components/pages/EnterPassword.vue.cjs +1 -1
  55. package/dist/prometheus-framework/src/modules/auth/components/pages/EnterPassword.vue.js +1 -1
  56. package/dist/prometheus-framework/src/modules/auth/components/pages/Invite.vue.cjs +1 -1
  57. package/dist/prometheus-framework/src/modules/auth/components/pages/Invite.vue.js +2 -2
  58. package/dist/prometheus-framework/src/modules/auth/components/pages/ResetPassword.vue.cjs +1 -1
  59. package/dist/prometheus-framework/src/modules/auth/components/pages/ResetPassword.vue.js +1 -1
  60. package/dist/prometheus-framework/src/modules/auth/components/pages/SignIn.vue.cjs +1 -1
  61. package/dist/prometheus-framework/src/modules/auth/components/pages/SignIn.vue.js +1 -1
  62. package/dist/prometheus-framework/src/modules/auth/components/pages/SignUp.vue.cjs +1 -1
  63. package/dist/prometheus-framework/src/modules/auth/components/pages/SignUp.vue.js +1 -1
  64. package/dist/prometheus-framework/src/modules/community/components/layouts/Community.vue.cjs +1 -1
  65. package/dist/prometheus-framework/src/modules/community/components/layouts/Community.vue.js +1 -1
  66. package/dist/prometheus-framework/src/modules/community/components/pages/BlogPost.vue.cjs +1 -1
  67. package/dist/prometheus-framework/src/modules/community/components/pages/BlogPost.vue.js +1 -1
  68. package/dist/prometheus-framework/src/modules/community/components/pages/Community.vue.cjs +1 -1
  69. package/dist/prometheus-framework/src/modules/community/components/pages/Community.vue.js +1 -1
  70. package/dist/prometheus-framework/src/modules/community/components/pages/CreateBlogPost.vue.cjs +1 -1
  71. package/dist/prometheus-framework/src/modules/community/components/pages/CreateBlogPost.vue.js +1 -1
  72. package/dist/prometheus-framework/src/modules/community/components/sections/Feed.vue.cjs +1 -1
  73. package/dist/prometheus-framework/src/modules/community/components/sections/Feed.vue.js +1 -1
  74. package/dist/prometheus-framework/src/modules/community/components/sections/HotPosts.vue.cjs +1 -1
  75. package/dist/prometheus-framework/src/modules/community/components/sections/HotPosts.vue.js +1 -1
  76. package/dist/prometheus-framework/src/modules/events/components/layouts/layoutEvents.vue.cjs +1 -1
  77. package/dist/prometheus-framework/src/modules/events/components/layouts/layoutEvents.vue.js +1 -1
  78. package/dist/prometheus-framework/src/modules/events/components/pages/EditEvent.vue.cjs +1 -1
  79. package/dist/prometheus-framework/src/modules/events/components/pages/EditEvent.vue.js +198 -184
  80. package/dist/prometheus-framework/src/modules/events/components/pages/EditEventTickets.vue.cjs +1 -0
  81. package/dist/prometheus-framework/src/modules/events/components/pages/EditEventTickets.vue.js +168 -0
  82. package/dist/prometheus-framework/src/modules/events/components/pages/EditEventTickets.vue2.cjs +1 -0
  83. package/dist/prometheus-framework/src/modules/events/components/pages/EditEventTickets.vue2.js +1 -0
  84. package/dist/prometheus-framework/src/modules/events/components/pages/Event.vue.cjs +1 -1
  85. package/dist/prometheus-framework/src/modules/events/components/pages/Event.vue.js +1 -1
  86. package/dist/prometheus-framework/src/modules/events/components/pages/Events.vue.cjs +1 -1
  87. package/dist/prometheus-framework/src/modules/events/components/pages/Events.vue.js +3 -3
  88. package/dist/prometheus-framework/src/modules/events/components/sections/Feed.vue.cjs +1 -1
  89. package/dist/prometheus-framework/src/modules/events/components/sections/Feed.vue.js +1 -1
  90. package/dist/prometheus-framework/src/modules/events/components/sections/List.vue.cjs +1 -1
  91. package/dist/prometheus-framework/src/modules/events/components/sections/List.vue.js +1 -1
  92. package/dist/prometheus-framework/src/modules/events/router/events.cjs +1 -1
  93. package/dist/prometheus-framework/src/modules/events/router/events.js +11 -2
  94. package/dist/prometheus-framework/src/modules/gallery/components/sections/BackofficeGallery.vue.cjs +1 -1
  95. package/dist/prometheus-framework/src/modules/gallery/components/sections/BackofficeGallery.vue.js +1 -1
  96. package/dist/prometheus-framework/src/modules/gallery/components/sections/GalleryWithCategories.vue.cjs +1 -1
  97. package/dist/prometheus-framework/src/modules/gallery/components/sections/GalleryWithCategories.vue.js +1 -1
  98. package/dist/prometheus-framework/src/modules/globals/components/blocks/CardHeader.vue.cjs +1 -1
  99. package/dist/prometheus-framework/src/modules/globals/components/blocks/CardHeader.vue.js +67 -64
  100. package/dist/prometheus-framework/src/modules/orders/components/pages/EditOrder.vue.cjs +1 -1
  101. package/dist/prometheus-framework/src/modules/orders/components/pages/EditOrder.vue.js +2 -2
  102. package/dist/prometheus-framework/src/modules/orders/components/pages/Orders.vue.cjs +1 -1
  103. package/dist/prometheus-framework/src/modules/orders/components/pages/Orders.vue.js +1 -1
  104. package/dist/prometheus-framework/src/modules/organizations/components/blocks/CardDepartment.vue.cjs +1 -1
  105. package/dist/prometheus-framework/src/modules/organizations/components/blocks/CardDepartment.vue.js +1 -1
  106. package/dist/prometheus-framework/src/modules/organizations/components/blocks/DepartmentMemberModify.vue.cjs +1 -1
  107. package/dist/prometheus-framework/src/modules/organizations/components/blocks/DepartmentMemberModify.vue.js +1 -1
  108. package/dist/prometheus-framework/src/modules/organizations/components/pages/Department.vue.cjs +1 -1
  109. package/dist/prometheus-framework/src/modules/organizations/components/pages/Department.vue.js +1 -1
  110. package/dist/prometheus-framework/src/modules/organizations/components/pages/DepartmentEdit.vue.cjs +1 -1
  111. package/dist/prometheus-framework/src/modules/organizations/components/pages/DepartmentEdit.vue.js +4 -4
  112. package/dist/prometheus-framework/src/modules/organizations/components/pages/Members.vue.cjs +1 -1
  113. package/dist/prometheus-framework/src/modules/organizations/components/pages/Members.vue.js +3 -3
  114. package/dist/prometheus-framework/src/modules/organizations/components/pages/Organization.vue.cjs +1 -1
  115. package/dist/prometheus-framework/src/modules/organizations/components/pages/Organization.vue.js +24 -24
  116. package/dist/prometheus-framework/src/modules/organizations/components/pages/OrganizationEdit.vue.cjs +1 -1
  117. package/dist/prometheus-framework/src/modules/organizations/components/pages/OrganizationEdit.vue.js +3 -3
  118. package/dist/prometheus-framework/src/modules/organizations/components/pages/Organizations.vue.cjs +1 -1
  119. package/dist/prometheus-framework/src/modules/organizations/components/pages/Organizations.vue.js +1 -1
  120. package/dist/prometheus-framework/src/modules/organizations/components/sections/Documents.vue.cjs +1 -1
  121. package/dist/prometheus-framework/src/modules/organizations/components/sections/Documents.vue.js +1 -1
  122. package/dist/prometheus-framework/src/modules/organizations/components/sections/Feed.vue.cjs +1 -1
  123. package/dist/prometheus-framework/src/modules/organizations/components/sections/Feed.vue.js +1 -1
  124. package/dist/prometheus-framework/src/modules/organizations/components/sections/MembersAdd.vue.cjs +1 -1
  125. package/dist/prometheus-framework/src/modules/organizations/components/sections/MembersAdd.vue.js +2 -2
  126. package/dist/prometheus-framework/src/modules/organizations/components/sections/Organizations.vue.cjs +1 -1
  127. package/dist/prometheus-framework/src/modules/organizations/components/sections/Organizations.vue.js +3 -3
  128. package/dist/prometheus-framework/src/modules/organizations/organizations.client.cjs +1 -1
  129. package/dist/prometheus-framework/src/modules/organizations/organizations.client.js +40 -38
  130. package/dist/prometheus-framework/src/modules/organizations/store/departments.cjs +1 -1
  131. package/dist/prometheus-framework/src/modules/organizations/store/departments.js +19 -19
  132. package/dist/prometheus-framework/src/modules/organizations/store/invites.cjs +1 -1
  133. package/dist/prometheus-framework/src/modules/organizations/store/invites.js +5 -5
  134. package/dist/prometheus-framework/src/modules/products/components/blocks/CardLeftover.vue.cjs +1 -1
  135. package/dist/prometheus-framework/src/modules/products/components/blocks/CardLeftover.vue.js +36 -27
  136. package/dist/prometheus-framework/src/modules/products/components/blocks/CardPosition.vue.cjs +1 -1
  137. package/dist/prometheus-framework/src/modules/products/components/blocks/CardPosition.vue.js +1 -1
  138. package/dist/prometheus-framework/src/modules/products/components/blocks/Images360.vue.cjs +1 -1
  139. package/dist/prometheus-framework/src/modules/products/components/blocks/Images360.vue.js +1 -1
  140. package/dist/prometheus-framework/src/modules/products/components/blocks/ImagesThumbnails.vue.cjs +1 -1
  141. package/dist/prometheus-framework/src/modules/products/components/blocks/ImagesThumbnails.vue.js +1 -1
  142. package/dist/prometheus-framework/src/modules/products/components/pages/CategoryEdit.vue.cjs +1 -1
  143. package/dist/prometheus-framework/src/modules/products/components/pages/CategoryEdit.vue.js +1 -1
  144. package/dist/prometheus-framework/src/modules/products/components/pages/EditLeftover.vue.cjs +1 -1
  145. package/dist/prometheus-framework/src/modules/products/components/pages/EditLeftover.vue.js +7 -7
  146. package/dist/prometheus-framework/src/modules/products/components/pages/Leftovers.vue.cjs +1 -1
  147. package/dist/prometheus-framework/src/modules/products/components/pages/Leftovers.vue.js +21 -21
  148. package/dist/prometheus-framework/src/modules/products/components/pages/ProductEdit.vue.cjs +1 -1
  149. package/dist/prometheus-framework/src/modules/products/components/pages/ProductEdit.vue.js +2 -2
  150. package/dist/prometheus-framework/src/modules/products/components/pages/ProductRecommmendation.vue.cjs +1 -1
  151. package/dist/prometheus-framework/src/modules/products/components/pages/ProductRecommmendation.vue.js +1 -1
  152. package/dist/prometheus-framework/src/modules/products/components/pages/Products.vue.cjs +1 -1
  153. package/dist/prometheus-framework/src/modules/products/components/pages/Products.vue.js +36 -50
  154. package/dist/prometheus-framework/src/modules/products/components/sections/EditProductInfo.vue.cjs +1 -1
  155. package/dist/prometheus-framework/src/modules/products/components/sections/EditProductInfo.vue.js +1 -1
  156. package/dist/prometheus-framework/src/modules/products/components/sections/FilterProducts.vue.cjs +1 -1
  157. package/dist/prometheus-framework/src/modules/products/components/sections/FilterProducts.vue.js +1 -1
  158. package/dist/prometheus-framework/src/modules/products/components/sections/PopularProducts.vue.cjs +1 -1
  159. package/dist/prometheus-framework/src/modules/products/components/sections/PopularProducts.vue.js +1 -1
  160. package/dist/prometheus-framework/src/modules/reports/components/sections/FormReport.vue.cjs +1 -1
  161. package/dist/prometheus-framework/src/modules/reports/components/sections/FormReport.vue.js +2 -2
  162. package/dist/prometheus-framework/src/modules/users/components/pages/ProfileBlogposts.vue.cjs +1 -1
  163. package/dist/prometheus-framework/src/modules/users/components/pages/ProfileBlogposts.vue.js +1 -1
  164. package/dist/prometheus-framework/src/modules/users/components/pages/ProfileEdit.vue.cjs +1 -1
  165. package/dist/prometheus-framework/src/modules/users/components/pages/ProfileEdit.vue.js +1 -1
  166. package/dist/prometheus-framework/src/modules/users/components/pages/ProfileEvents.vue.cjs +1 -1
  167. package/dist/prometheus-framework/src/modules/users/components/pages/ProfileEvents.vue.js +1 -1
  168. package/dist/prometheus-framework/src/modules/wallet/components/pages/Wallet.vue.cjs +1 -1
  169. package/dist/prometheus-framework/src/modules/wallet/components/pages/Wallet.vue.js +2 -2
  170. package/dist/prometheus-framework.cjs.js +1 -1
  171. package/dist/prometheus-framework.es.js +1 -1
  172. package/dist/style.css +1 -1
  173. package/dist/web-D7bW32Ul.mjs +54 -0
  174. package/dist/web-DpE9HxA3.js +1 -0
  175. package/package.json +1 -1
  176. package/src/components/Chips/Chips.vue +2 -2
  177. package/src/components/Feed/Feed.vue +2 -1
  178. package/src/modules/auth/auth.client.js +0 -2
  179. package/src/modules/auth/auth.server.js +1 -7
  180. package/src/modules/auth/components/pages/Invite.vue +1 -1
  181. package/src/modules/events/components/pages/EditEvent.vue +19 -0
  182. package/src/modules/events/components/pages/EditEventTickets.vue +194 -0
  183. package/src/modules/events/controllers/tickets.controller.js +103 -28
  184. package/src/modules/events/models/ticket.model.js +22 -4
  185. package/src/modules/events/router/events.js +5 -0
  186. package/src/modules/events/routes/tickets.routes.js +2 -2
  187. package/src/modules/events/store/tickets.js +1 -0
  188. package/src/modules/globals/components/blocks/CardHeader.vue +6 -6
  189. package/src/modules/organizations/components/pages/Members.vue +1 -1
  190. package/src/modules/organizations/components/pages/Organization.vue +4 -4
  191. package/src/modules/organizations/components/sections/MembersAdd.vue +1 -1
  192. package/src/modules/organizations/controllers/departments.controller.js +14 -1
  193. package/src/modules/organizations/models/department.model.js +5 -1
  194. package/src/modules/organizations/organizations.client.js +2 -0
  195. package/src/modules/organizations/organizations.server.js +6 -2
  196. package/src/modules/organizations/routes/departments.routes.js +1 -1
  197. package/src/modules/organizations/store/departments.js +3 -2
  198. package/src/modules/products/components/blocks/CardLeftover.vue +19 -7
  199. package/src/modules/products/components/pages/EditLeftover.vue +1 -1
  200. package/src/modules/products/components/pages/Leftovers.vue +14 -3
  201. package/src/modules/products/components/pages/Products.vue +8 -8
  202. package/src/modules/products/models/leftover.model.js +9 -5
  203. package/src/modules/users/models/client.model.js +60 -0
  204. /package/src/modules/{auth → organizations}/controllers/invites.controller.js +0 -0
  205. /package/src/modules/{auth → organizations}/models/invite.model.js +0 -0
  206. /package/src/modules/{auth → organizations}/routes/invites.routes.js +0 -0
  207. /package/src/modules/{auth → organizations}/store/invites.js +0 -0
@@ -0,0 +1,174 @@
1
+ "use strict";
2
+ const require$$0 = require("mongoose");
3
+ const ObjectId = require$$0.Types.ObjectId;
4
+ function getBasicOptions(query) {
5
+ const { _id, url, status, owner, creator } = query;
6
+ const conditions = [];
7
+ if (_id) {
8
+ conditions.push({ _id: new ObjectId(_id) });
9
+ }
10
+ if (url) {
11
+ conditions.push({ url });
12
+ }
13
+ if (status) {
14
+ conditions.push({ status });
15
+ }
16
+ if (owner) {
17
+ conditions.push({ "owner.target": new ObjectId(owner) });
18
+ }
19
+ if (creator) {
20
+ conditions.push({ "creator.target": new ObjectId(creator) });
21
+ }
22
+ if (conditions.length > 0) {
23
+ return [{ $match: { $and: conditions } }];
24
+ } else {
25
+ return [];
26
+ }
27
+ }
28
+ function getTagsOptions(tags) {
29
+ if (tags && tags.length > 0) {
30
+ [{ $in: tags.split(",") }];
31
+ } else {
32
+ return [];
33
+ }
34
+ }
35
+ function getSortingOptions(param = "createdAt", order = "desc") {
36
+ let sort = {
37
+ [param]: order === "desc" ? -1 : 1,
38
+ "_id": 1
39
+ };
40
+ return [{ $sort: sort }];
41
+ }
42
+ function getPaginationOptions(skip, limit) {
43
+ let pagination = {
44
+ skip: parseInt(skip) || 0,
45
+ limit: parseInt(limit) || 20
46
+ };
47
+ return [{ $skip: pagination.skip }, { $limit: pagination.limit }];
48
+ }
49
+ function getCreatorUserLookupStage() {
50
+ return {
51
+ $lookup: {
52
+ from: "users",
53
+ localField: "creator.target",
54
+ foreignField: "_id",
55
+ as: "creatorUser"
56
+ }
57
+ };
58
+ }
59
+ function getCreatorOrganizationLookupStage() {
60
+ return {
61
+ $lookup: {
62
+ from: "organizations",
63
+ localField: "creator.target",
64
+ foreignField: "_id",
65
+ as: "creatorOrganization"
66
+ }
67
+ };
68
+ }
69
+ function getOwnerUserLookupStage() {
70
+ return {
71
+ $lookup: {
72
+ from: "users",
73
+ localField: "owner.target",
74
+ foreignField: "_id",
75
+ as: "ownerUser"
76
+ }
77
+ };
78
+ }
79
+ function getOwnerOrganizationLookupStage() {
80
+ return {
81
+ $lookup: {
82
+ from: "organizations",
83
+ localField: "owner.target",
84
+ foreignField: "_id",
85
+ as: "ownerOrganization"
86
+ }
87
+ };
88
+ }
89
+ function getAddFieldsCreatorOwnerStage() {
90
+ return {
91
+ $addFields: {
92
+ "creator.target": {
93
+ $cond: [
94
+ { $eq: ["$creator.type", "user"] },
95
+ { $arrayElemAt: ["$creatorUser", 0] },
96
+ { $arrayElemAt: ["$creatorOrganization", 0] }
97
+ ]
98
+ },
99
+ "owner.target": {
100
+ $cond: [
101
+ { $eq: ["$owner.type", "user"] },
102
+ { $arrayElemAt: ["$ownerUser", 0] },
103
+ { $arrayElemAt: ["$ownerOrganization", 0] }
104
+ ]
105
+ }
106
+ }
107
+ };
108
+ }
109
+ var queryProcessor = {
110
+ getBasicOptions,
111
+ getSortingOptions,
112
+ getPaginationOptions,
113
+ getTagsOptions,
114
+ // Creator and Owner
115
+ getCreatorUserLookupStage,
116
+ getCreatorOrganizationLookupStage,
117
+ getOwnerUserLookupStage,
118
+ getOwnerOrganizationLookupStage,
119
+ getAddFieldsCreatorOwnerStage
120
+ };
121
+ var common_schema = function applyCommonSchema(schema, db) {
122
+ schema.add({
123
+ status: {
124
+ type: String,
125
+ enum: ["draft", "published", "removed"],
126
+ default: "draft",
127
+ required: true
128
+ }
129
+ });
130
+ };
131
+ var engagement_schema = function applyEngagementSchema(schema, db) {
132
+ schema.add({ views: { type: Number, default: 0 } });
133
+ schema.post("aggregate", async function(docs) {
134
+ if (docs.length === 0)
135
+ return;
136
+ console.log("Post-aggregate hook in engagement schema triggered");
137
+ const model = this._model;
138
+ if (!model) {
139
+ console.error("No model is associated with this schema!");
140
+ return;
141
+ }
142
+ try {
143
+ await updateDocumentViews(docs, model);
144
+ } catch (error) {
145
+ console.error("Error updating views:", error);
146
+ }
147
+ });
148
+ async function updateDocumentViews(docs, model) {
149
+ const updateViewsPromises = docs.map((doc) => model.findOneAndUpdate(
150
+ { _id: doc._id },
151
+ { $inc: { views: 1 } }
152
+ ).exec());
153
+ await Promise.all(updateViewsPromises);
154
+ }
155
+ };
156
+ var metadata_schema = function applyMetadataSchema(schema, db) {
157
+ schema.add({
158
+ url: {
159
+ type: String,
160
+ required: true
161
+ },
162
+ tags: [{
163
+ type: String
164
+ }]
165
+ });
166
+ schema.index({
167
+ "url": 1,
168
+ "tags": 1
169
+ });
170
+ };
171
+ exports.common_schema = common_schema;
172
+ exports.engagement_schema = engagement_schema;
173
+ exports.metadata_schema = metadata_schema;
174
+ exports.queryProcessor = queryProcessor;
@@ -0,0 +1,175 @@
1
+ import require$$0 from "mongoose";
2
+ const ObjectId = require$$0.Types.ObjectId;
3
+ function getBasicOptions(query) {
4
+ const { _id, url, status, owner, creator } = query;
5
+ const conditions = [];
6
+ if (_id) {
7
+ conditions.push({ _id: new ObjectId(_id) });
8
+ }
9
+ if (url) {
10
+ conditions.push({ url });
11
+ }
12
+ if (status) {
13
+ conditions.push({ status });
14
+ }
15
+ if (owner) {
16
+ conditions.push({ "owner.target": new ObjectId(owner) });
17
+ }
18
+ if (creator) {
19
+ conditions.push({ "creator.target": new ObjectId(creator) });
20
+ }
21
+ if (conditions.length > 0) {
22
+ return [{ $match: { $and: conditions } }];
23
+ } else {
24
+ return [];
25
+ }
26
+ }
27
+ function getTagsOptions(tags) {
28
+ if (tags && tags.length > 0) {
29
+ [{ $in: tags.split(",") }];
30
+ } else {
31
+ return [];
32
+ }
33
+ }
34
+ function getSortingOptions(param = "createdAt", order = "desc") {
35
+ let sort = {
36
+ [param]: order === "desc" ? -1 : 1,
37
+ "_id": 1
38
+ };
39
+ return [{ $sort: sort }];
40
+ }
41
+ function getPaginationOptions(skip, limit) {
42
+ let pagination = {
43
+ skip: parseInt(skip) || 0,
44
+ limit: parseInt(limit) || 20
45
+ };
46
+ return [{ $skip: pagination.skip }, { $limit: pagination.limit }];
47
+ }
48
+ function getCreatorUserLookupStage() {
49
+ return {
50
+ $lookup: {
51
+ from: "users",
52
+ localField: "creator.target",
53
+ foreignField: "_id",
54
+ as: "creatorUser"
55
+ }
56
+ };
57
+ }
58
+ function getCreatorOrganizationLookupStage() {
59
+ return {
60
+ $lookup: {
61
+ from: "organizations",
62
+ localField: "creator.target",
63
+ foreignField: "_id",
64
+ as: "creatorOrganization"
65
+ }
66
+ };
67
+ }
68
+ function getOwnerUserLookupStage() {
69
+ return {
70
+ $lookup: {
71
+ from: "users",
72
+ localField: "owner.target",
73
+ foreignField: "_id",
74
+ as: "ownerUser"
75
+ }
76
+ };
77
+ }
78
+ function getOwnerOrganizationLookupStage() {
79
+ return {
80
+ $lookup: {
81
+ from: "organizations",
82
+ localField: "owner.target",
83
+ foreignField: "_id",
84
+ as: "ownerOrganization"
85
+ }
86
+ };
87
+ }
88
+ function getAddFieldsCreatorOwnerStage() {
89
+ return {
90
+ $addFields: {
91
+ "creator.target": {
92
+ $cond: [
93
+ { $eq: ["$creator.type", "user"] },
94
+ { $arrayElemAt: ["$creatorUser", 0] },
95
+ { $arrayElemAt: ["$creatorOrganization", 0] }
96
+ ]
97
+ },
98
+ "owner.target": {
99
+ $cond: [
100
+ { $eq: ["$owner.type", "user"] },
101
+ { $arrayElemAt: ["$ownerUser", 0] },
102
+ { $arrayElemAt: ["$ownerOrganization", 0] }
103
+ ]
104
+ }
105
+ }
106
+ };
107
+ }
108
+ var queryProcessor = {
109
+ getBasicOptions,
110
+ getSortingOptions,
111
+ getPaginationOptions,
112
+ getTagsOptions,
113
+ // Creator and Owner
114
+ getCreatorUserLookupStage,
115
+ getCreatorOrganizationLookupStage,
116
+ getOwnerUserLookupStage,
117
+ getOwnerOrganizationLookupStage,
118
+ getAddFieldsCreatorOwnerStage
119
+ };
120
+ var common_schema = function applyCommonSchema(schema, db) {
121
+ schema.add({
122
+ status: {
123
+ type: String,
124
+ enum: ["draft", "published", "removed"],
125
+ default: "draft",
126
+ required: true
127
+ }
128
+ });
129
+ };
130
+ var engagement_schema = function applyEngagementSchema(schema, db) {
131
+ schema.add({ views: { type: Number, default: 0 } });
132
+ schema.post("aggregate", async function(docs) {
133
+ if (docs.length === 0)
134
+ return;
135
+ console.log("Post-aggregate hook in engagement schema triggered");
136
+ const model = this._model;
137
+ if (!model) {
138
+ console.error("No model is associated with this schema!");
139
+ return;
140
+ }
141
+ try {
142
+ await updateDocumentViews(docs, model);
143
+ } catch (error) {
144
+ console.error("Error updating views:", error);
145
+ }
146
+ });
147
+ async function updateDocumentViews(docs, model) {
148
+ const updateViewsPromises = docs.map((doc) => model.findOneAndUpdate(
149
+ { _id: doc._id },
150
+ { $inc: { views: 1 } }
151
+ ).exec());
152
+ await Promise.all(updateViewsPromises);
153
+ }
154
+ };
155
+ var metadata_schema = function applyMetadataSchema(schema, db) {
156
+ schema.add({
157
+ url: {
158
+ type: String,
159
+ required: true
160
+ },
161
+ tags: [{
162
+ type: String
163
+ }]
164
+ });
165
+ schema.index({
166
+ "url": 1,
167
+ "tags": 1
168
+ });
169
+ };
170
+ export {
171
+ common_schema as c,
172
+ engagement_schema as e,
173
+ metadata_schema as m,
174
+ queryProcessor as q
175
+ };
@@ -3,12 +3,14 @@ const _commonjsHelpers = require("./_commonjsHelpers-DHfMLFPC.js");
3
3
  const require$$0$1 = require("jsonwebtoken");
4
4
  require("axios");
5
5
  require("bcryptjs");
6
- require("uuidv4");
6
+ const require$$3 = require("uuidv4");
7
7
  const require$$0 = require("mongoose");
8
8
  const require$$5 = require("@googlemaps/google-maps-services-js");
9
9
  const addMembersQuantity$1 = require("./addMembersQuantity-B8UgqlUM.js");
10
+ const mailing = require("./mailing-CxEcQ8NY.js");
11
+ const index = require("./index-CL9l0HRS.js");
10
12
  const require$$0$2 = require("mongodb");
11
- const controllerFactory$5 = (db) => {
13
+ const controllerFactory$6 = (db) => {
12
14
  const Department = db.department;
13
15
  const readOne = (req, res) => {
14
16
  Department.findOne({ _id: req.params._id }).populate("members.user").populate("subdepartments").then((department) => {
@@ -21,7 +23,16 @@ const controllerFactory$5 = (db) => {
21
23
  });
22
24
  };
23
25
  const read = (req, res) => {
24
- Department.find({ organization: req.params._id }).populate("members.user").populate("subdepartments").then((departments) => {
26
+ let query = {};
27
+ let options = {};
28
+ console.log(req.query);
29
+ if (req.query.organization) {
30
+ query.organization = new db.mongoose.Types.ObjectId(req.query.organization);
31
+ }
32
+ if (req.query.hidden) {
33
+ query.hidden = req.query.hidden;
34
+ }
35
+ Department.find(query, null, options).populate("members.user").populate("subdepartments").then((departments) => {
25
36
  if (!departments) {
26
37
  return res.status(404).send({ message: "Departments not found" });
27
38
  }
@@ -70,14 +81,14 @@ const controllerFactory$5 = (db) => {
70
81
  delete: deleteDepartment
71
82
  };
72
83
  };
73
- var departments_controller = controllerFactory$5;
84
+ var departments_controller = controllerFactory$6;
74
85
  const jwt = require$$0$1;
75
86
  const ObjectId$2 = require$$0.Types.ObjectId;
76
87
  const { Client } = require$$5;
77
88
  const client = new Client({});
78
89
  const addUserStatusFields = addMembersQuantity$1.addUserStatusFields_1;
79
90
  const addMembersQuantity = addMembersQuantity$1.addMembersQuantity_1;
80
- const controllerFactory$4 = (db) => {
91
+ const controllerFactory$5 = (db) => {
81
92
  const Organization = db.organization;
82
93
  const Membership = db.membership;
83
94
  db.user;
@@ -438,9 +449,9 @@ const controllerFactory$4 = (db) => {
438
449
  // Map the method to 'delete' key
439
450
  };
440
451
  };
441
- var organizations_controller = controllerFactory$4;
452
+ var organizations_controller = controllerFactory$5;
442
453
  const ObjectId$1 = require$$0.Types.ObjectId;
443
- const controllerFactory$3 = (db) => {
454
+ const controllerFactory$4 = (db) => {
444
455
  const Membership = db.membership;
445
456
  const read = async (req, res) => {
446
457
  try {
@@ -522,10 +533,108 @@ const controllerFactory$3 = (db) => {
522
533
  deleteMembership
523
534
  };
524
535
  };
525
- var memberships_controller = controllerFactory$3;
526
- const controllerFactory$2 = departments_controller;
536
+ var memberships_controller = controllerFactory$4;
537
+ const { uuid } = require$$3;
538
+ const { sendEmail, sendSms } = mailing.mailing;
539
+ const сontrollerFactory = (db) => {
540
+ const User = db.user;
541
+ const Invite = db.invite;
542
+ const Membership = db.membership;
543
+ const getOneByCode = async (req, res) => {
544
+ try {
545
+ const invite = await Invite.findOne({ code: req.params._id });
546
+ if (!invite) {
547
+ return res.status(404).send({ message: "Приглашение не найдено" });
548
+ }
549
+ res.send(invite);
550
+ } catch (err) {
551
+ res.status(500).send({ message: err.message });
552
+ }
553
+ };
554
+ const read = async (req, res) => {
555
+ try {
556
+ const invites = await Invite.find({ organization: req.params._id });
557
+ if (!invites) {
558
+ return res.status(404).send({ message: "Invites not found" });
559
+ }
560
+ res.send(invites);
561
+ } catch (err) {
562
+ res.status(500).send({ message: err.message });
563
+ }
564
+ };
565
+ const create = async (req, res) => {
566
+ const userInviter = JSON.parse(req.cookies.user);
567
+ const organizationId = req.params._id;
568
+ try {
569
+ const invites = req.body;
570
+ for (let invite of invites) {
571
+ let user2 = null;
572
+ if (invite.contact.includes("@")) {
573
+ user2 = await User.findOne({ email: invite.contact });
574
+ } else {
575
+ user2 = await User.findOne({ phone: invite.contact });
576
+ }
577
+ if (user2) {
578
+ console.log(invite);
579
+ const membership = new Membership({
580
+ user: user2._id,
581
+ type: "organization",
582
+ target: organizationId,
583
+ role: invite.role
584
+ });
585
+ await membership.save();
586
+ res.status(200).json({ message: "Invites sent successfully!" });
587
+ } else {
588
+ const newInvite = new Invite({
589
+ code: uuid(),
590
+ organization: organizationId,
591
+ role: invite.role,
592
+ createdBy: userInviter._id,
593
+ invitedEmail: invite.contact.includes("@") ? invite.contact : null,
594
+ invitedPhone: !invite.contact.includes("@") ? invite.contact : null
595
+ });
596
+ const savedInvite = await newInvite.save();
597
+ if (savedInvite.invitedEmail) {
598
+ const to = savedInvite.invitedEmail;
599
+ const subject = "You have been added to the organization";
600
+ const text = `You have been invited to join an organization on ${process.env.APP_NAME}! Use this link to register: ${process.env.API_URL}/auth/invite?inviteCode=${newInvite.code}&type=email"`;
601
+ await sendEmail(to, subject, text);
602
+ }
603
+ if (savedInvite.invitedPhone !== null) {
604
+ const phone = savedInvite.invitedPhone;
605
+ const message = `You have been invited to join an organization on ${process.env.APP_NAME}! Use this link to register: ${process.env.API_URL}/auth/invite?inviteCode=${newInvite.code}&type=phone`;
606
+ await sendSms(phone, message);
607
+ }
608
+ res.status(200).json({ message: "Invites sent successfully!" });
609
+ }
610
+ }
611
+ } catch (error) {
612
+ console.error(error);
613
+ res.status(500).json({ message: "Something went wrong" });
614
+ }
615
+ };
616
+ const deleteInvite = async (req, res) => {
617
+ try {
618
+ const invite = await Invite.findOneAndDelete({ _id: req.params._id });
619
+ if (!invite) {
620
+ return res.status(404).send({ message: "Invite not found" });
621
+ }
622
+ res.send({ message: "Invite deleted successfully" });
623
+ } catch (err) {
624
+ res.status(500).send({ message: err.message });
625
+ }
626
+ };
627
+ return {
628
+ getOneByCode,
629
+ read,
630
+ create,
631
+ delete: deleteInvite
632
+ };
633
+ };
634
+ var invites_controller = сontrollerFactory;
635
+ const controllerFactory$3 = departments_controller;
527
636
  var departments_routes = function(app, db) {
528
- const controller = controllerFactory$2(db);
637
+ const controller = controllerFactory$3(db);
529
638
  app.use(function(req, res, next) {
530
639
  res.header(
531
640
  "Access-Control-Allow-Headers",
@@ -534,15 +643,15 @@ var departments_routes = function(app, db) {
534
643
  );
535
644
  next();
536
645
  });
537
- app.get("/api/departments/:_id", controller.read);
646
+ app.get("/api/departments/read", controller.read);
538
647
  app.get("/api/departments/get/:_id", controller.readOne);
539
648
  app.post("/api/departments/:_id/create", controller.create);
540
649
  app.post("/api/departments/:_id/update", controller.update);
541
650
  app.delete("/api/departments/:_id/delete", controller.delete);
542
651
  };
543
- const controllerFactory$1 = organizations_controller;
652
+ const controllerFactory$2 = organizations_controller;
544
653
  var organizations_routes = function(app, db) {
545
- const controller = controllerFactory$1(db);
654
+ const controller = controllerFactory$2(db);
546
655
  app.use(function(req, res, next) {
547
656
  res.header(
548
657
  "Access-Control-Allow-Headers",
@@ -568,9 +677,9 @@ var organizations_routes = function(app, db) {
568
677
  controller.delete
569
678
  );
570
679
  };
571
- const controllerFactory = memberships_controller;
680
+ const controllerFactory$1 = memberships_controller;
572
681
  var memberships_routes = function(app, db) {
573
- const controller = controllerFactory(db);
682
+ const controller = controllerFactory$1(db);
574
683
  app.use(function(req, res, next) {
575
684
  res.header(
576
685
  "Access-Control-Allow-Headers",
@@ -596,6 +705,40 @@ var memberships_routes = function(app, db) {
596
705
  controller.deleteMembership
597
706
  );
598
707
  };
708
+ const controllerFactory = invites_controller;
709
+ const middlewareFactory = index.server;
710
+ var invites_routes = function(app, db) {
711
+ const controller = controllerFactory(db);
712
+ const { verifyInvites } = middlewareFactory(db);
713
+ app.use(function(req, res, next) {
714
+ res.header(
715
+ "Access-Control-Allow-Headers",
716
+ "Access-Control-Allow-Origin",
717
+ "x-access-token, Origin, Content-Type, Accept"
718
+ );
719
+ next();
720
+ });
721
+ app.get(
722
+ "/api/invites/get/:_id",
723
+ controller.getOneByCode
724
+ );
725
+ app.get(
726
+ "/api/invites/:_id",
727
+ controller.read
728
+ );
729
+ app.post(
730
+ "/api/invites/:_id/create",
731
+ [
732
+ verifyInvites.checkInviteExist,
733
+ verifyInvites.checkUsersExist
734
+ ],
735
+ controller.create
736
+ );
737
+ app.delete(
738
+ "/api/invites/:_id/delete",
739
+ controller.delete
740
+ );
741
+ };
599
742
  var department_model = (mongoose) => {
600
743
  const departmentSchema = new mongoose.Schema({
601
744
  owner: {
@@ -619,6 +762,10 @@ var department_model = (mongoose) => {
619
762
  end: String
620
763
  }
621
764
  }],
765
+ hidden: {
766
+ type: Boolean,
767
+ default: false
768
+ },
622
769
  // Marketplace options
623
770
  delivery: [String],
624
771
  payment: [String],
@@ -748,25 +895,74 @@ var membership_model = (mongoose) => {
748
895
  const Membership = mongoose.model("Membership", MembershipSchema);
749
896
  return Membership;
750
897
  };
898
+ var invite_model = (mongoose) => {
899
+ const InviteSchema = new mongoose.Schema({
900
+ code: {
901
+ type: String,
902
+ required: true,
903
+ unique: true
904
+ },
905
+ organization: {
906
+ type: mongoose.Schema.Types.ObjectId,
907
+ ref: "Organization",
908
+ required: true
909
+ },
910
+ status: {
911
+ type: String,
912
+ enum: ["active", "used"],
913
+ default: "active"
914
+ },
915
+ role: {
916
+ name: {
917
+ type: String,
918
+ default: "Сотрудник"
919
+ },
920
+ value: {
921
+ type: String,
922
+ default: "member"
923
+ }
924
+ },
925
+ createdBy: {
926
+ type: mongoose.Schema.Types.ObjectId,
927
+ ref: "User"
928
+ },
929
+ invitedEmail: {
930
+ type: String
931
+ },
932
+ invitedPhone: {
933
+ type: String
934
+ }
935
+ }, {
936
+ timestamps: true
937
+ });
938
+ const Invite = mongoose.model("Invite", InviteSchema);
939
+ return Invite;
940
+ };
751
941
  const DepartmentsController = departments_controller;
752
942
  const OrganizationsController = organizations_controller;
753
943
  const MembershipsController = memberships_controller;
944
+ const InvitesController = invites_controller;
754
945
  const departmentsRoutes = departments_routes;
755
946
  const organizationsRoutes = organizations_routes;
756
947
  const membershipsRoutes = memberships_routes;
948
+ const invitesRoutes = invites_routes;
757
949
  const DepartmentModel = department_model;
758
950
  const OrganizationModel = organization_model;
759
951
  const MembershipModel = membership_model;
952
+ const InviteModel = invite_model;
760
953
  var organizations_server = {
761
954
  DepartmentsController,
762
955
  OrganizationsController,
763
956
  MembershipsController,
957
+ InvitesController,
764
958
  departmentsRoutes,
765
959
  organizationsRoutes,
766
960
  membershipsRoutes,
961
+ invitesRoutes,
767
962
  DepartmentModel,
768
963
  OrganizationModel,
769
- MembershipModel
964
+ MembershipModel,
965
+ InviteModel
770
966
  };
771
967
  const organizations_server$1 = /* @__PURE__ */ _commonjsHelpers.getDefaultExportFromCjs(organizations_server);
772
968
  module.exports = organizations_server$1;