@hostlink/nuxt-light 0.0.55 → 0.0.56

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/README.md CHANGED
@@ -1,106 +1,106 @@
1
- <!--
2
- Get your module up and running quickly.
3
-
4
- Find and replace all on all files (CMD+SHIFT+F):
5
- - Name: nuxt-light
6
- - Package name: nuxt-light
7
- - Description: My new Nuxt module
8
- -->
9
-
10
- # nuxt-light
11
-
12
- [![npm version][npm-version-src]][npm-version-href]
13
- [![npm downloads][npm-downloads-src]][npm-downloads-href]
14
- [![License][license-src]][license-href]
15
- [![Nuxt][nuxt-src]][nuxt-href]
16
-
17
- This is a Hostlink nuxt-light framework for Nuxt.
18
-
19
- - [✨ &nbsp;Release Notes](/CHANGELOG.md)
20
- <!-- - [🏀 Online playground](https://stackblitz.com/github/your-org/nuxt-light?file=playground%2Fapp.vue) -->
21
- <!-- - [📖 &nbsp;Documentation](https://example.com) -->
22
-
23
- ## Features
24
-
25
- <!-- Highlight some of the features your module provide here -->
26
- - HostLink nuxt-light framework
27
-
28
- ## Quick Setup
29
-
30
- 1. Add `nuxt-light` dependency to your project
31
-
32
- ```bash
33
- # Using npm
34
- npm install --save-dev nuxt-light
35
- ```
36
-
37
- 2. Add `@hostlink/nuxt-light` to the `modules` section of `nuxt.config.ts`
38
-
39
- ```js
40
- import pkg from './package.json'
41
- export default defineNuxtConfig({
42
- runtimeConfig: {
43
- public: {
44
- //apiBase: 'your-api-base-url'
45
- appVersion: pkg.version
46
- }
47
- },
48
- ssr:false,
49
- modules: [
50
- '@hostlink/nuxt-light'
51
- ]
52
- })
53
- ```
54
-
55
- That's it! You can now use nuxt-light in your Nuxt app ✨
56
-
57
- ## Development
58
-
59
- ```bash
60
- # Install dependencies
61
- npm install
62
-
63
- # Generate type stubs
64
- npm run dev:prepare
65
-
66
- # Develop with the playground
67
- npm run dev
68
-
69
- # Build the playground
70
- npm run dev:build
71
-
72
- # Run ESLint
73
- npm run lint
74
-
75
- # Run Vitest
76
- npm run test
77
- npm run test:watch
78
-
79
- # Release new version
80
- npm run release
81
- ```
82
-
83
- <!-- Badges -->
84
- [npm-version-src]: https://img.shields.io/npm/v/@hostlink/nuxt-light/latest.svg?style=flat&colorA=18181B&colorB=28CF8D
85
- [npm-version-href]: https://npmjs.com/package/@hostlink/nuxt-light
86
-
87
- [npm-downloads-src]: https://img.shields.io/npm/dm/@hostlink/nuxt-light.svg?style=flat&colorA=18181B&colorB=28CF8D
88
- [npm-downloads-href]: https://npmjs.com/package/@hostlink/nuxt-light
89
-
90
- [license-src]: https://img.shields.io/npm/l/@hostlink/nuxt-light.svg?style=flat&colorA=18181B&colorB=28CF8D
91
- [license-href]: https://npmjs.com/package/@hostlink/nuxt-light
92
-
93
- [nuxt-src]: https://img.shields.io/badge/Nuxt-18181B?logo=nuxt.js
94
- [nuxt-href]: https://nuxt.com
95
-
96
-
97
-
98
- ### app.vue
99
- ```html
100
- <template>
101
- <l-app>
102
- <NuxtLoadingIndicator />
103
- <NuxtPage />
104
- </l-app>
105
- </template>
106
- ```
1
+ <!--
2
+ Get your module up and running quickly.
3
+
4
+ Find and replace all on all files (CMD+SHIFT+F):
5
+ - Name: nuxt-light
6
+ - Package name: nuxt-light
7
+ - Description: My new Nuxt module
8
+ -->
9
+
10
+ # nuxt-light
11
+
12
+ [![npm version][npm-version-src]][npm-version-href]
13
+ [![npm downloads][npm-downloads-src]][npm-downloads-href]
14
+ [![License][license-src]][license-href]
15
+ [![Nuxt][nuxt-src]][nuxt-href]
16
+
17
+ This is a Hostlink nuxt-light framework for Nuxt.
18
+
19
+ - [✨ &nbsp;Release Notes](/CHANGELOG.md)
20
+ <!-- - [🏀 Online playground](https://stackblitz.com/github/your-org/nuxt-light?file=playground%2Fapp.vue) -->
21
+ <!-- - [📖 &nbsp;Documentation](https://example.com) -->
22
+
23
+ ## Features
24
+
25
+ <!-- Highlight some of the features your module provide here -->
26
+ - HostLink nuxt-light framework
27
+
28
+ ## Quick Setup
29
+
30
+ 1. Add `nuxt-light` dependency to your project
31
+
32
+ ```bash
33
+ # Using npm
34
+ npm install --save-dev @hostlink/nuxt-light
35
+ ```
36
+
37
+ 2. Add `@hostlink/nuxt-light` to the `modules` section of `nuxt.config.ts`
38
+
39
+ ```js
40
+ import pkg from './package.json'
41
+ export default defineNuxtConfig({
42
+ runtimeConfig: {
43
+ public: {
44
+ //apiBase: 'your-api-base-url'
45
+ appVersion: pkg.version
46
+ }
47
+ },
48
+ ssr:false,
49
+ modules: [
50
+ '@hostlink/nuxt-light'
51
+ ]
52
+ })
53
+ ```
54
+
55
+ That's it! You can now use nuxt-light in your Nuxt app ✨
56
+
57
+ ## Development
58
+
59
+ ```bash
60
+ # Install dependencies
61
+ npm install
62
+
63
+ # Generate type stubs
64
+ npm run dev:prepare
65
+
66
+ # Develop with the playground
67
+ npm run dev
68
+
69
+ # Build the playground
70
+ npm run dev:build
71
+
72
+ # Run ESLint
73
+ npm run lint
74
+
75
+ # Run Vitest
76
+ npm run test
77
+ npm run test:watch
78
+
79
+ # Release new version
80
+ npm run release
81
+ ```
82
+
83
+ <!-- Badges -->
84
+ [npm-version-src]: https://img.shields.io/npm/v/@hostlink/nuxt-light/latest.svg?style=flat&colorA=18181B&colorB=28CF8D
85
+ [npm-version-href]: https://npmjs.com/package/@hostlink/nuxt-light
86
+
87
+ [npm-downloads-src]: https://img.shields.io/npm/dm/@hostlink/nuxt-light.svg?style=flat&colorA=18181B&colorB=28CF8D
88
+ [npm-downloads-href]: https://npmjs.com/package/@hostlink/nuxt-light
89
+
90
+ [license-src]: https://img.shields.io/npm/l/@hostlink/nuxt-light.svg?style=flat&colorA=18181B&colorB=28CF8D
91
+ [license-href]: https://npmjs.com/package/@hostlink/nuxt-light
92
+
93
+ [nuxt-src]: https://img.shields.io/badge/Nuxt-18181B?logo=nuxt.js
94
+ [nuxt-href]: https://nuxt.com
95
+
96
+
97
+
98
+ ### app.vue
99
+ ```html
100
+ <template>
101
+ <l-app>
102
+ <NuxtLoadingIndicator />
103
+ <NuxtPage />
104
+ </l-app>
105
+ </template>
106
+ ```
package/dist/module.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "light",
3
3
  "configKey": "light",
4
- "version": "0.0.55"
4
+ "version": "0.0.56"
5
5
  }
package/dist/module.mjs CHANGED
@@ -45,7 +45,6 @@ const module = defineNuxtModule({
45
45
  { name: "id", from },
46
46
  { name: "list", from },
47
47
  { name: "listData", from },
48
- { name: "login", from },
49
48
  { name: "m", from },
50
49
  { name: "mutation", from },
51
50
  { name: "q", from },
@@ -1,5 +1,11 @@
1
1
  <script setup>
2
+ import { useRuntimeConfig } from 'nuxt/app';
3
+ import { setApiUrl } from '@hostlink/light'
2
4
  import { q } from '../';
5
+ const config = useRuntimeConfig();
6
+ setApiUrl(config?.public?.apiBase ?? '/api/');
7
+
8
+
3
9
  const { app } = await q({ app: ['company', 'companyLogo', 'logged', 'twoFactorAuthentication'] });
4
10
  </script>
5
11
  <template>
@@ -3,7 +3,7 @@ import { VariableType } from "json-to-graphql-query";
3
3
  import { useI18n } from "vue-i18n";
4
4
  import { ref, watch, computed } from 'vue';
5
5
  import { useQuasar } from 'quasar';
6
- import { q } from '../';
6
+ import { q, m } from '../';
7
7
 
8
8
  const i18n = useI18n();
9
9
  const quasar = useQuasar();
@@ -2,7 +2,10 @@
2
2
  import { ref, reactive } from 'vue'
3
3
  import { useQuasar } from 'quasar';
4
4
  import { useI18n } from 'vue-i18n';
5
- import { login, m, notify } from '../';
5
+ import { m, notify } from '../';
6
+
7
+ import { login } from '@hostlink/light';
8
+
6
9
 
7
10
  defineProps({
8
11
  company: String,
@@ -7,4 +7,4 @@ interface Light {
7
7
  getVersion(): string;
8
8
  }
9
9
  export declare function useLight(): Light;
10
- export { notify, addObject, f, getApiUrl, getCurrentUser, getObject, id, list, listData, login, m, mutation, q, removeObject, t, updateObject, getID, deleteObject, listObject, getApiBase } from "./lib";
10
+ export { notify, addObject, f, getApiUrl, getCurrentUser, getObject, id, list, listData, m, mutation, q, removeObject, t, updateObject, getID, deleteObject, listObject, getApiBase } from "./lib";
@@ -39,7 +39,6 @@ export {
39
39
  id,
40
40
  list,
41
41
  listData,
42
- login,
43
42
  m,
44
43
  mutation,
45
44
  q,
@@ -1,4 +1,5 @@
1
1
  import { jsonToGraphQLQuery } from "json-to-graphql-query";
2
+ import toJson from "./toJson.mjs";
2
3
  export default function(operation, args, fields = []) {
3
4
  if (arguments.length === 2) {
4
5
  fields = args;
@@ -15,11 +16,8 @@ export default function(operation, args, fields = []) {
15
16
  if (typeof field === "string") {
16
17
  query[operation][field] = true;
17
18
  } else if (typeof field === "object") {
18
- Object.entries(field).forEach(([key, value]) => {
19
- query[operation][key] = {};
20
- value.forEach((subField) => {
21
- query[operation][key][subField] = true;
22
- });
19
+ Object.entries(toJson(field)).forEach(([key, value]) => {
20
+ query[operation][key] = value;
23
21
  });
24
22
  }
25
23
  });
@@ -6,7 +6,6 @@ import getObject from "./getObject";
6
6
  import id from "./id";
7
7
  import list from "./list";
8
8
  import listData from "./listData";
9
- import login from "./login";
10
9
  import m from "./m";
11
10
  import mutation from "./mutation";
12
11
  import q from "./q";
@@ -19,4 +18,4 @@ import isGranted from "./isGranted";
19
18
  declare const notify: (message: string, color?: string) => void;
20
19
  import getID from "./getID";
21
20
  declare const getApiBase: () => {};
22
- export { addObject, f, getApiUrl, getCurrentUser, getObject, id, list, listData, login, m, mutation, q, removeObject, t, updateObject, notify, getID, deleteObject, listObject, isGranted, getApiBase };
21
+ export { addObject, f, getApiUrl, getCurrentUser, getObject, id, list, listData, m, mutation, q, removeObject, t, updateObject, notify, getID, deleteObject, listObject, isGranted, getApiBase };
@@ -8,7 +8,6 @@ import getObject from "./getObject.mjs";
8
8
  import id from "./id.mjs";
9
9
  import list from "./list.mjs";
10
10
  import listData from "./listData.mjs";
11
- import login from "./login.mjs";
12
11
  import m from "./m.mjs";
13
12
  import mutation from "./mutation.mjs";
14
13
  import q from "./q.mjs";
@@ -39,7 +38,6 @@ export {
39
38
  id,
40
39
  list,
41
40
  listData,
42
- login,
43
41
  m,
44
42
  mutation,
45
43
  q,
@@ -2,33 +2,14 @@ import axios from "axios";
2
2
  import f from "./f.mjs";
3
3
  import { jsonToGraphQLQuery } from "json-to-graphql-query";
4
4
  import { getApiBase } from "./index.mjs";
5
- const mapping = function(obj) {
6
- let q = {};
7
- Object.entries(obj).forEach(([key, value]) => {
8
- if (value instanceof Array) {
9
- q[key] = {};
10
- value.forEach((subField) => {
11
- if (subField instanceof Object) {
12
- Object.entries(mapping(subField)).forEach(([subKey, subValue]) => {
13
- q[key][subKey] = subValue;
14
- });
15
- } else {
16
- q[key][subField] = true;
17
- }
18
- });
19
- } else {
20
- q[key] = mapping(value);
21
- }
22
- });
23
- return q;
24
- };
5
+ import toJson from "./toJson.mjs";
25
6
  export default async function(operation, args, fields = []) {
26
7
  const service = axios.create({
27
8
  withCredentials: true
28
9
  });
29
10
  let query;
30
11
  if (operation instanceof Object) {
31
- query = jsonToGraphQLQuery(mapping(operation));
12
+ query = jsonToGraphQLQuery(toJson(operation));
32
13
  } else {
33
14
  if (arguments.length === 2) {
34
15
  fields = args;
@@ -0,0 +1,2 @@
1
+ declare const mapping: (obj: object) => any;
2
+ export default mapping;
@@ -0,0 +1,21 @@
1
+ const mapping = function(obj) {
2
+ let q = {};
3
+ Object.entries(obj).forEach(([key, value]) => {
4
+ if (value instanceof Array) {
5
+ q[key] = {};
6
+ value.forEach((subField) => {
7
+ if (subField instanceof Object) {
8
+ Object.entries(mapping(subField)).forEach(([subKey, subValue]) => {
9
+ q[key][subKey] = subValue;
10
+ });
11
+ } else {
12
+ q[key][subField] = true;
13
+ }
14
+ });
15
+ } else {
16
+ q[key] = mapping(value);
17
+ }
18
+ });
19
+ return q;
20
+ };
21
+ export default mapping;
@@ -1,7 +1,8 @@
1
1
  <script setup>
2
- import { m } from '../'
3
- await m("logout");
4
2
 
3
+ import { logout } from '@hostlink/light';
4
+
5
+ await logout();
5
6
  const href = window.self.location.href;
6
7
 
7
8
  const url = new URL(href);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hostlink/nuxt-light",
3
- "version": "0.0.55",
3
+ "version": "0.0.56",
4
4
  "description": "HostLink Nuxt Light Framework",
5
5
  "repository": "@hostlink/nuxt-light",
6
6
  "license": "MIT",
@@ -35,6 +35,7 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@formkit/inputs": "^1.1.0",
38
+ "@hostlink/light": "^0.0.6",
38
39
  "@nuxt/kit": "^3.7.0",
39
40
  "@quasar/extras": "^1.16.6",
40
41
  "axios": "^1.5.0",
@@ -1,2 +0,0 @@
1
- declare const _default: (username: string, password: string, code?: string) => Promise<boolean>;
2
- export default _default;
@@ -1,9 +0,0 @@
1
- import m from "./m.mjs";
2
- export default async (username, password, code) => {
3
- await m("login", {
4
- username,
5
- password,
6
- code
7
- });
8
- return true;
9
- };