@hostlink/nuxt-light 0.0.54 → 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: My Module
6
- - Package name: my-module
7
- - Description: My new Nuxt module
8
- -->
9
-
10
- # My Module
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
- My new Nuxt module for doing amazing things.
18
-
19
- - [✨ &nbsp;Release Notes](/CHANGELOG.md)
20
- <!-- - [🏀 Online playground](https://stackblitz.com/github/your-org/my-module?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
- - &nbsp;Foo
27
- - 🚠 &nbsp;Bar
28
- - 🌲 &nbsp;Baz
29
-
30
- ## Quick Setup
31
-
32
- 1. Add `my-module` dependency to your project
33
-
34
- ```bash
35
- # Using pnpm
36
- pnpm add -D my-module
37
-
38
- # Using yarn
39
- yarn add --dev my-module
40
-
41
- # Using npm
42
- npm install --save-dev my-module
43
- ```
44
-
45
- 2. Add `my-module` to the `modules` section of `nuxt.config.ts`
46
-
47
- ```js
48
- export default defineNuxtConfig({
49
- modules: [
50
- 'my-module'
51
- ]
52
- })
53
- ```
54
-
55
- That's it! You can now use My Module 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/my-module/latest.svg?style=flat&colorA=18181B&colorB=28CF8D
85
- [npm-version-href]: https://npmjs.com/package/my-module
86
-
87
- [npm-downloads-src]: https://img.shields.io/npm/dm/my-module.svg?style=flat&colorA=18181B&colorB=28CF8D
88
- [npm-downloads-href]: https://npmjs.com/package/my-module
89
-
90
- [license-src]: https://img.shields.io/npm/l/my-module.svg?style=flat&colorA=18181B&colorB=28CF8D
91
- [license-href]: https://npmjs.com/package/my-module
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.54"
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 },
@@ -3,6 +3,13 @@ import { useQuasar } from 'quasar';
3
3
  import { useI18n } from 'vue-i18n';
4
4
  import { useLight, q, getCurrentUser, m, f } from '../';
5
5
  import { ref, computed, reactive, provide, watch } from 'vue';
6
+ import { useRuntimeConfig } from 'nuxt/app';
7
+
8
+
9
+ const config = useRuntimeConfig();
10
+
11
+ const appVersion = config.public.appVersion ?? '0.0.1';
12
+
6
13
 
7
14
  const quasar = useQuasar();
8
15
  quasar.dark.set(false);
@@ -19,7 +26,6 @@ const tt = await q({
19
26
  my: ["styles", "language", f('granted_storage:granted', { right: "system.storage" }, [])],
20
27
  })
21
28
 
22
- const allTranslate = ref(await q("allTranslate", []))
23
29
 
24
30
  let app = tt.app
25
31
  let my = tt.my
@@ -35,15 +41,14 @@ const menus = ref(app.menus)
35
41
  const i18n = useI18n();
36
42
  i18n.locale = my.language || 'en';
37
43
 
38
- const messages = i18n.messages.value[i18n.locale];
44
+ let messages = i18n.messages.value[i18n.locale];
39
45
 
40
- for (const translate of allTranslate.value) {
41
- messages[translate.name] = translate[my.language]
46
+ for (let t of app.i18nMessages) {
47
+ messages[t.name] = t.value;
42
48
  }
43
49
 
44
50
  i18n.setLocaleMessage(i18n.locale, messages);
45
51
 
46
-
47
52
  const user = ref(await getCurrentUser());
48
53
 
49
54
  const leftDrawerOpen = ref(false)
@@ -338,7 +343,7 @@ const storageUsagePercent = computed(() => {
338
343
  <q-footer class="bg-white text-grey" bordered>
339
344
  <q-item>
340
345
  <q-item-section>
341
- {{ company }} {{ light.getVersion() }} - Copyright 2023 HostLink(HK)
346
+ {{ company }} {{ appVersion }} - Copyright 2023 HostLink(HK). Build {{ light.getVersion() }}
342
347
  </q-item-section>
343
348
  </q-item>
344
349
  </q-footer>
@@ -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,
@@ -20,7 +20,7 @@ if (typeof props.value === "number") {
20
20
 
21
21
  </script>
22
22
  <template>
23
- <div>
23
+ <div class="q-pa-sm">
24
24
  <div class="row">
25
25
  {{ title }}
26
26
  </div>
@@ -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,
@@ -1,9 +1,7 @@
1
1
  import axios from "axios";
2
2
  import { jsonToGraphQLQuery } from "json-to-graphql-query";
3
- import { useRuntimeConfig } from "nuxt/app";
4
3
  import { getApiBase } from "./index.mjs";
5
4
  export default async function(operation, args, fields = []) {
6
- const config = useRuntimeConfig();
7
5
  const mutation = {
8
6
  mutation: {}
9
7
  };
@@ -1,36 +1,15 @@
1
1
  import axios from "axios";
2
2
  import f from "./f.mjs";
3
3
  import { jsonToGraphQLQuery } from "json-to-graphql-query";
4
- import { useRuntimeConfig } from "nuxt/app";
5
4
  import { getApiBase } from "./index.mjs";
6
- const mapping = function(obj) {
7
- let q = {};
8
- Object.entries(obj).forEach(([key, value]) => {
9
- if (value instanceof Array) {
10
- q[key] = {};
11
- value.forEach((subField) => {
12
- if (subField instanceof Object) {
13
- Object.entries(mapping(subField)).forEach(([subKey, subValue]) => {
14
- q[key][subKey] = subValue;
15
- });
16
- } else {
17
- q[key][subField] = true;
18
- }
19
- });
20
- } else {
21
- q[key] = mapping(value);
22
- }
23
- });
24
- return q;
25
- };
5
+ import toJson from "./toJson.mjs";
26
6
  export default async function(operation, args, fields = []) {
27
- const config = useRuntimeConfig();
28
7
  const service = axios.create({
29
8
  withCredentials: true
30
9
  });
31
10
  let query;
32
11
  if (operation instanceof Object) {
33
- query = jsonToGraphQLQuery(mapping(operation));
12
+ query = jsonToGraphQLQuery(toJson(operation));
34
13
  } else {
35
14
  if (arguments.length === 2) {
36
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.54",
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
- };