@mapomodule/core 1.0.0-alpha.13 → 1.0.0-alpha.17

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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,45 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [1.0.0-alpha.17](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.16...v1.0.0-alpha.17) (2022-04-03)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * various fixes to auth loops ([58cdb58](https://github.com/lotrekagency/mapo/commit/58cdb586e88df8e595876ba4dd4d4cc11865f7e3))
12
+
13
+
14
+
15
+
16
+
17
+ # [1.0.0-alpha.16](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.15...v1.0.0-alpha.16) (2022-04-03)
18
+
19
+
20
+ ### Features
21
+
22
+ * Added mapo integrations module! 🎉 ([76d2c80](https://github.com/lotrekagency/mapo/commit/76d2c805245b4cf49a33696339da52e4c17f4053))
23
+ * added mapo options to mapo helper ([38dcbf2](https://github.com/lotrekagency/mapo/commit/38dcbf28d286eb02c2a6785a883a14edaa0837b1))
24
+
25
+
26
+ ### BREAKING CHANGES
27
+
28
+ * This change removes all the camomilla cms references moving the compatibility layer in a detached package [mapo-integrations-camomilla](https://github.com/lotrekagency/mapo-integrations-camomilla). The guidelines to make mapo work with camomilla will be provided in the package readme.
29
+
30
+
31
+
32
+
33
+
34
+ # [1.0.0-alpha.15](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.14...v1.0.0-alpha.15) (2022-03-11)
35
+
36
+
37
+ ### Features
38
+
39
+ * **ordering:** added sortablejs to drag and reorder list ([eb8bf21](https://github.com/lotrekagency/mapo/commit/eb8bf21c3178c3ad62db5aa7c06c0562e944dea6))
40
+
41
+
42
+
43
+
44
+
6
45
  # [1.0.0-alpha.13](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.12...v1.0.0-alpha.13) (2022-03-01)
7
46
 
8
47
 
package/api/crud.js CHANGED
@@ -105,7 +105,22 @@ const createRepository = ($axios) => (endpoint, higherConf = {}) => ({
105
105
  delete(id, config) {
106
106
  const func = $axios.$delete(`/${trimslashes(endpoint)}/${id}/`, { ...higherConf, ...config })
107
107
  return endpoint !== null ? func : Promise.reject(endpointError)
108
- }
108
+ },
109
+ /**
110
+ * This makes a POST http call to the crud endpoint slash update_order. Returns as a promise the server response.
111
+ * Use this endpoint to change the order of the items in the list.
112
+ * @alias $api.crud.update_order
113
+ * @param {String} startId The id of the item we want to move in the list.
114
+ * @param {String} endId The id of the item in the position where we want to move.
115
+ * @param {external:AxiosRequestConfig} [config] This is a further axios configuration object that allows you to override the options previously setted.
116
+ * @returns {Promise<external:AxiosResponse>}
117
+ */
118
+ update_order(startId, endId, config) {
119
+ const func = $axios.$post(`/${trimslashes(endpoint)}/update_order/`, { startId, endId }, { ...higherConf, ...config })
120
+ return endpoint !== null ? func : Promise.reject(endpointError)
121
+ },
122
+
123
+
109
124
  })
110
125
  /**
111
126
  * @external AxiosResponse
package/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import createRepository from '@mapomodule/core/api/crud'
2
2
  import transformRequestInMultipart from '@mapomodule/core/api/multipart'
3
3
  import initInterceptors from '@mapomodule/core/interceptor'
4
+ import options from './options'
4
5
 
5
6
  function getRouteMiddlewares(route) {
6
7
  const meta = Array.isArray(route?.meta) ? route.meta[0] : route.meta
@@ -8,6 +9,7 @@ function getRouteMiddlewares(route) {
8
9
  return (typeof middleware === "string" ? [middleware] : middleware) || []
9
10
  }
10
11
 
12
+ const { axios, ...conf } = options;
11
13
 
12
14
  export default (ctx, inject) => {
13
15
 
@@ -19,8 +21,10 @@ export default (ctx, inject) => {
19
21
  */
20
22
  $api: {
21
23
  crud: createRepository(ctx.$axios),
22
- multipart: transformRequestInMultipart
24
+ multipart: transformRequestInMultipart,
25
+ conf: axios
23
26
  },
27
+ $options: conf,
24
28
  /**
25
29
  * From here you can reach some utilities that simplify the interaction with the user authentication flow.
26
30
  */
@@ -35,7 +39,7 @@ export default (ctx, inject) => {
35
39
  *
36
40
  * This simply commits a logout to the vuex store.
37
41
  */
38
- logout: () => ctx.store.dispatch("mapo/user/login"),
42
+ logout: () => ctx.store.dispatch("mapo/user/logout"),
39
43
  /**
40
44
  * This refresh user informations present in vuex store and returns them.
41
45
  * @returns {UserData}
@@ -19,9 +19,9 @@ module.exports = ({ $axios, store }) => {
19
19
  })
20
20
 
21
21
  $axios.onError((error) => {
22
- const { status } = error.response || {}
23
- if (status === 401) {
24
- store.dispatch('mapo/user/logout');
22
+ const { status, request } = error.response || {}
23
+ if (status === 401 && request?.path !== '/api/auth/logout') {
24
+ store.dispatch('mapo/user/logout')
25
25
  }
26
26
  if (status == 403) {
27
27
  store.dispatch("mapo/app/showSnackMessage", { message: "Permission denied..", color: "error" })
@@ -1,8 +1,8 @@
1
1
  import Middleware from '../../middleware' // little hack to inject middleware in root project :P
2
2
 
3
3
  Middleware.auth = Middleware.auth || function ({ route, redirect, query, store }) {
4
- const hasToken = store.getters['mapo/user/token']
5
- if (!hasToken) {
4
+ const isLoggedIn = store.getters['mapo/user/isLoggedIn']
5
+ if (!isLoggedIn) {
6
6
  query['redirect'] = route.path
7
7
  return redirect('/login', query)
8
8
  }
@@ -9,7 +9,7 @@ Middleware.permissions = Middleware.permissions || async function ({ route, erro
9
9
  return
10
10
  }
11
11
  const { model } = route.meta.permissions
12
- const userPermission = userInfo.user_permissions.filter(perm => perm.codename.endsWith(model)).map(({ codename }) => codename.replace(`_${model}`, ''))
12
+ const userPermission = (userInfo.user_permissions || []).filter(perm => perm.codename.endsWith(model)).map(({ codename }) => codename.replace(`_${model}`, ''))
13
13
  if (!userPermission.includes('view')) {
14
14
  return error({ statusCode: 404, message: 'This page could not be found' })
15
15
  } else {
package/module.js CHANGED
@@ -23,6 +23,13 @@ export default async function (moduleOptions) {
23
23
  fileName: path.join(namespace, 'mapo.js')
24
24
  })
25
25
 
26
+ // INJECT MAPO OPTIONS
27
+ this.addTemplate({
28
+ src: path.resolve(__dirname, './options.js'),
29
+ fileName: path.join(namespace, 'options.js'),
30
+ options: { axios: (this.options && this.options.axios), ...moduleOptions }
31
+ })
32
+
26
33
  // INJECT ALL MIDDLEWARES
27
34
  const middlewares = (await resolver.resolveRelative(__dirname, 'middleware')).map(({ src }) => src)
28
35
 
package/options.js ADDED
@@ -0,0 +1 @@
1
+ export default <%= serializeFunction(options) %>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mapomodule/core",
3
- "version": "1.0.0-alpha.13",
3
+ "version": "1.0.0-alpha.17",
4
4
  "description": "This is part of Mapo nuxt module. Injects the core mapo plugin helpers.",
5
5
  "author": "bnznamco <gabriele.baldi.01@gmail.com>",
6
6
  "keywords": [
@@ -13,10 +13,10 @@
13
13
  "repository": "https://github.com/lotrekagency/mapo",
14
14
  "main": "./module.js",
15
15
  "dependencies": {
16
- "@mapomodule/utils": "^1.0.0-alpha.13"
16
+ "@mapomodule/utils": "^1.0.0-alpha.15"
17
17
  },
18
18
  "publishConfig": {
19
19
  "access": "public"
20
20
  },
21
- "gitHead": "b0fac0f5ebde4c65cc5347dbb841392dc04ef5e8"
21
+ "gitHead": "abd0d72a2d294acfde87af3a6f3fa3c19f100b30"
22
22
  }