mango-cms 0.2.28 → 0.2.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,24 +1,32 @@
1
1
  {
2
- "port": 6646,
3
- "frontPort": 6645,
4
- "siteName": "Example",
5
- "siteDomain": "example.com",
6
- "mangoDomain": "api.example.com",
2
+ "port": 6646,
3
+ "frontPort": 6645,
4
+ "siteName": "Example",
5
+ "siteDomain": "example.com",
6
+ "mangoDomain": "api.example.com",
7
7
 
8
- "useDevAPI": true,
8
+ "mangoThreads": 2,
9
+ "maxPoolSize": 10,
10
+ "minPoolSize": 0,
11
+ "maxIdleTimeMS": 60000,
12
+ "waitQueueTimeoutMS": 5000,
9
13
 
10
- "mongoURI":"mongodb://127.0.0.1:27017",
11
- "database":"exampleMongoDB",
14
+ "useDevAPI": true,
12
15
 
13
- "s3AccessKeyId": null,
14
- "s3AccessKeySecret": null,
15
- "s3Region": null,
16
- "s3Bucket":"exampleBucket",
16
+ "mongoURI": "mongodb://127.0.0.1:27017",
17
+ "database": "exampleMongoDB",
17
18
 
18
- "mailgunKey": null,
19
- "mailgunDomain": null,
19
+ "s3AccessKeyId": null,
20
+ "s3AccessKeySecret": null,
21
+ "s3Region": null,
22
+ "s3Bucket": "exampleBucket",
20
23
 
21
- "algoliaAppId": null,
22
- "algoliaSearchKey": null,
23
- "algoliaIndex": null
24
+ "emailProvider": "",
25
+ "resendKey": null,
26
+ "mailgunKey": null,
27
+ "mailgunDomain": null,
28
+
29
+ "algoliaAppId": null,
30
+ "algoliaSearchKey": null,
31
+ "algoliaIndex": null
24
32
  }
@@ -0,0 +1,25 @@
1
+ const subscribe = ({ io, collection, document, request, individual, originalDocument }) => {
2
+ let method = request.method
3
+ if (collection.subscribe && method != 'read' && individual) {
4
+
5
+ const subscription = io.of(collection.name);
6
+
7
+ // Send to the id and the author id
8
+ let payload = method == 'delete' ? originalDocument : document
9
+ subscription.to(request.member?.id).emit(`${collection.name}:${method}d`, payload);
10
+ subscription.to((document?.id||originalDocument?.id)).emit(`${collection.name}:${method}d`, payload);
11
+
12
+ // Send to each custom room
13
+ for (let room of (collection.subscribe?.rooms||[])) {
14
+ let keys = room.split('.')
15
+ let target = document
16
+ for (let key of keys) target = target[key]
17
+ console.log(document, keys)
18
+ let roomId = target
19
+ console.log('attempting to emit to', collection.name, roomId, `${collection.name}:${method}d`)
20
+ subscription.to(roomId).emit(`${collection.name}:${method}d`, payload);
21
+ }
22
+ }
23
+ }
24
+
25
+ export { subscribe }
@@ -25,7 +25,7 @@
25
25
  "dayjs": "^1.10.7",
26
26
  "express": "^4.18.1",
27
27
  "google-maps": "^4.3.3",
28
- "mango-cms": "^0.2.28",
28
+ "mango-cms": "^0.2.31",
29
29
  "mapbox-gl": "^2.7.0",
30
30
  "sweetalert2": "^11.4.0",
31
31
  "vite": "^6.2.2",
@@ -238,15 +238,28 @@ const Mango = collections.reduce((a, c) => {
238
238
  let defaultTriggers = {
239
239
  created: (data) => {
240
240
  if (Array.isArray(target)) target.push(data)
241
- else target = data
241
+ else Object.assign(target, data)
242
242
  },
243
243
  updated: (data) => {
244
- if (Array.isArray(target)) target = target.map(t => t.id == data.id ? data : t)
245
- else if (target.id == data.id) target = data
244
+ if (Array.isArray(target)) {
245
+ const index = target.findIndex(t => t.id == data.id)
246
+ if (index !== -1) {
247
+ Object.assign(target[index], data)
248
+ }
249
+ }
250
+ else if (target.id == data.id) Object.assign(target, data)
246
251
  },
247
252
  deleted: (data) => {
248
- if (Array.isArray(target)) target = target.filter(t => t.id != data.id)
249
- else if (target.id == data.id) target = null
253
+ if (Array.isArray(target)) {
254
+ const index = target.findIndex(t => t.id == data.id)
255
+ if (index !== -1) {
256
+ target.splice(index, 1) // Mutates the existing array
257
+ }
258
+ }
259
+ else if (target.id == data.id) {
260
+ // Clear the object properties while maintaining reactivity
261
+ Object.keys(target).forEach(key => delete target[key])
262
+ }
250
263
  }
251
264
  }
252
265
 
@@ -78,8 +78,7 @@ const store = reactive({
78
78
 
79
79
  })
80
80
 
81
- let Authorization = window.localStorage.getItem('email') + ';' + window.localStorage.getItem('user')
82
- axios.defaults.headers.common['Authorization'] = Authorization
81
+ axios.defaults.headers.common['Authorization'] = window.localStorage.getItem('token')
83
82
 
84
83
  app.provide('store', store)
85
84
  app.provide('axios', axios)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mango-cms",
3
- "version": "0.2.28",
3
+ "version": "0.2.31",
4
4
  "main": "./index.js",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -85,6 +85,7 @@
85
85
  "parse-html-text-content": "^1.1.1",
86
86
  "redis": "^4.7.0",
87
87
  "require-all": "^3.0.0",
88
+ "resend": "^6.3.0",
88
89
  "sharp": "^0.32.1",
89
90
  "socket.io": "^4.8.0",
90
91
  "socket.io-redis": "^6.1.1",