mango-cms 0.2.24 → 0.2.26

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.
@@ -7,6 +7,8 @@ Date.prototype.monthDays = function () {
7
7
 
8
8
  let startAutomations = function () {
9
9
 
10
+ let now = new Date()
11
+
10
12
  // console.log('starting!')
11
13
 
12
14
  setInterval(() => {
@@ -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.24",
28
+ "mango-cms": "^0.2.26",
29
29
  "mapbox-gl": "^2.7.0",
30
30
  "sweetalert2": "^11.4.0",
31
31
  "vite": "^6.2.2",
@@ -35,7 +35,8 @@
35
35
  "vue-upload-component": "^3.1.2",
36
36
  "vue3-clipboard": "^1.0.0",
37
37
  "vue3-touch-events": "^4.1.0",
38
- "vuedraggable": "^4.1.0"
38
+ "vuedraggable": "^4.1.0",
39
+ "socket.io-client": "^4.8.1"
39
40
  },
40
41
  "devDependencies": {
41
42
  "autoprefixer": "^10.4.0",
@@ -0,0 +1,10 @@
1
+ self.addEventListener('message', (event) => {
2
+ if (event.data && event.data.type === 'CLEAR_CACHE') {
3
+ caches.keys().then((cacheNames) => {
4
+ cacheNames.forEach((cacheName) => {
5
+ caches.delete(cacheName);
6
+ });
7
+ });
8
+ console.log('BUSTED cache')
9
+ }
10
+ });
@@ -0,0 +1,30 @@
1
+ self.addEventListener('fetch', (event) => {
2
+ if (event.request.method === 'GET' && event.request.url.startsWith('http')) {
3
+ // Check if the request URL contains '/opportunities'
4
+ if (event.request.url.includes('/opportunities') || event.request.url.includes('/rhdiStats')) {
5
+ // If it does, respond with the network request directly without caching
6
+ event.respondWith(fetch(event.request));
7
+ } else {
8
+ event.respondWith(
9
+ caches.match(event.request).then((cachedResponse) => {
10
+ const fetchPromise = fetch(event.request).then((networkResponse) => {
11
+ // Clone the network response before consuming it
12
+ const clonedResponse = networkResponse.clone();
13
+
14
+ // If the network request is successful, update the cache
15
+ caches.open('user-data-cache').then((cache) => {
16
+ cache.put(event.request, clonedResponse);
17
+ });
18
+ return networkResponse;
19
+ }).catch(() => {
20
+ // If the network request fails, return the cached response (if available)
21
+ return cachedResponse;
22
+ });
23
+
24
+ // Return the cached response immediately if available, or the network response if not
25
+ return cachedResponse || fetchPromise;
26
+ })
27
+ );
28
+ }
29
+ }
30
+ });
@@ -6,6 +6,7 @@ import axios from "axios";
6
6
  import { ref } from 'vue'
7
7
  import algoliasearch from 'algoliasearch/dist/algoliasearch-lite.esm.browser'
8
8
  import LocalDB from './localDB'
9
+ import { io } from 'socket.io-client';
9
10
 
10
11
  import { useRoute } from 'vue-router'
11
12
  let route = useRoute()
@@ -160,7 +161,6 @@ const Mango = collections.reduce((a, c) => {
160
161
  }
161
162
 
162
163
  let save = (data, options = {}) => {
163
- console.log('FROM SAVE:', data)
164
164
  if (!options.bypassLocal) return localDB.save(save, data, options)
165
165
  else return mangoSave(data, options)
166
166
  }
@@ -187,7 +187,7 @@ const Mango = collections.reduce((a, c) => {
187
187
 
188
188
  setInterval(async () => {
189
189
 
190
- console.log('syncing', syncing.value, route?.params?.id)
190
+ // console.log('syncing', syncing.value, route?.params?.id)
191
191
  online.value = navigator.onLine
192
192
 
193
193
  if (syncing.value) return
@@ -226,10 +226,23 @@ const Mango = collections.reduce((a, c) => {
226
226
 
227
227
  }
228
228
 
229
+ let subscribe = (callback, room) => {
230
+ let socket = io(`${api}/${c.name}`, { transports: ['websocket'] })
231
+ let userId = window.localStorage.getItem('auth').split(':')[1]
232
+ room = room || userId
233
+ socket.emit('subscribeToThread', room)
234
+ if (callback) socket.on('message', callback)
235
+ }
236
+
229
237
  a[c.name] = runQuery
230
238
  a[c.name]['save'] = save
231
239
  a[c.name]['delete'] = deleteEntry
240
+ a[c.name]['subscribe'] = subscribe
232
241
  a[c.singular] = (id, query) => runQuery({ id, ...query })
242
+ a[c.singular]['subscribe'] = (id, callback) => {
243
+ if (!id) return console.error('No id provided')
244
+ return subscribe(callback, id)
245
+ }
233
246
 
234
247
  a[c.name]['local'] = localDB.getEntries
235
248
  a[c.singular]['local'] = localDB.get
@@ -0,0 +1,50 @@
1
+ <template>
2
+ <div class="flex justify-between items-center bg-merlin-500/40 backdrop-blur-sm fixed top-0 left-0 w-full z-50">
3
+
4
+ <div v-if="remainingEntries.length" class="w-full px-4 py-2 flex justify-between relative">
5
+ <div>Syncing:</div>
6
+ <div>{{ syncedEntries.length }}/{{ remainingEntries.length + syncedEntries.length }}</div>
7
+
8
+ <div class="h-1 bg-red-500 absolute -bottom-1 left-0" :style="`width: ${progress}%;`" />
9
+ </div>
10
+
11
+ </div>
12
+ </template>
13
+
14
+ <script>
15
+ import Toggle from '../partials/toggle.vue'
16
+
17
+ export default {
18
+ components: { Toggle },
19
+ inject: ['store'],
20
+ data() {
21
+ return {
22
+ remainingEntries: [],
23
+ online: navigator.onLine,
24
+ syncing: false,
25
+ syncedEntries: [],
26
+ }
27
+ },
28
+ beforeDestroy() {
29
+ // clearInterval(this.onlineInterval)
30
+ },
31
+ async mounted() {
32
+
33
+ let response = this.$mango.opportunities.sync()
34
+ this.online = response.online
35
+ this.syncing = response.syncing
36
+ this.remainingEntries = response.remainingEntries
37
+ this.syncedEntries = response.syncedEntries
38
+
39
+ },
40
+ computed: {
41
+ progress() {
42
+ return Math.round(this.syncedEntries.length / (this.remainingEntries.length+this.syncedEntries.length) * 100)
43
+ }
44
+ }
45
+ }
46
+ </script>
47
+
48
+ <style>
49
+
50
+ </style>
@@ -1,5 +1,6 @@
1
1
  import { defineConfig } from 'vite'
2
2
  import vue from '@vitejs/plugin-vue'
3
+ // import { VitePWA } from 'vite-plugin-pwa'
3
4
  import path from 'path'
4
5
  import fs from 'fs'
5
6
 
@@ -24,6 +25,20 @@ const collectionsPath = path.resolve(configPath, 'config/.collections.json')
24
25
  export default defineConfig({
25
26
  plugins: [
26
27
  vue(),
28
+ // VitePWA({
29
+ // registerType: 'autoUpdate',
30
+ // includeAssets: ['images/*.jpg'],
31
+ // // devOptions: {
32
+ // // enabled: true,
33
+ // // },
34
+ // workbox: {
35
+ // importScripts: [
36
+ // '/swBustCache.js',
37
+ // '/swNetworkFirst.js?v=6'
38
+ // ],
39
+ // // globPatterns: ['**/*.{js,css,html,ico,png,svg,vue,jpg,jpeg}']
40
+ // }
41
+ // }),
27
42
  {
28
43
  name: 'watch-collections',
29
44
  configureServer(server) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mango-cms",
3
- "version": "0.2.24",
3
+ "version": "0.2.26",
4
4
  "main": "./index.js",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -80,7 +80,7 @@
80
80
  "node-lame": "^1.3.2",
81
81
  "node-zip": "^1.1.1",
82
82
  "nodemon-webpack-plugin": "^4.3.2",
83
- "openai": "^4.51.0",
83
+ "openai": "^5.15.0",
84
84
  "pack": "^2.2.0",
85
85
  "parse-html-text-content": "^1.1.1",
86
86
  "redis": "^4.7.0",