@hostlink/nuxt-light 0.0.5 → 0.0.7

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/dist/module.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "light",
3
3
  "configKey": "light",
4
- "version": "0.0.5"
4
+ "version": "0.0.7"
5
5
  }
package/dist/module.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { defineNuxtModule, createResolver, addComponentsDir, addImportsDir, addPlugin } from '@nuxt/kit';
1
+ import { defineNuxtModule, createResolver, addComponentsDir, addImports, addPlugin } from '@nuxt/kit';
2
2
  import AutoImport from 'unplugin-auto-import/vite';
3
3
 
4
4
  const module = defineNuxtModule({
@@ -41,9 +41,24 @@ const module = defineNuxtModule({
41
41
  addComponentsDir({
42
42
  path: resolver.resolve("./runtime/components")
43
43
  });
44
- addImportsDir(resolver.resolve("./runtime/composables"), {
45
- prepend: true
46
- });
44
+ const composables = resolver.resolve("./runtime/composables");
45
+ addImports([
46
+ { name: "q", from: composables },
47
+ { name: "addObject", from: composables },
48
+ { name: "f", from: composables },
49
+ { name: "getApiUrl", from: composables },
50
+ { name: "getCurrentUser", from: composables },
51
+ { name: "id", from: composables },
52
+ { name: "list", from: composables },
53
+ { name: "listData", from: composables },
54
+ { name: "m", from: composables },
55
+ { name: "mutation", from: composables },
56
+ { name: "q", from: composables },
57
+ { name: "removeObject", from: composables },
58
+ { name: "t", from: composables },
59
+ { name: "updateObject", from: composables },
60
+ { name: "viewAs", from: composables }
61
+ ]);
47
62
  addPlugin(resolver.resolve("./runtime/plugin"));
48
63
  }
49
64
  });
@@ -1 +1 @@
1
- export default function _default(operation: any, args: any, fields?: any[]): Promise<any>;
1
+ export default function (operation: any, args: any, fields?: never[]): Promise<any>;
@@ -1,73 +1,51 @@
1
- import axios from 'axios';
2
- //import { mutation } from 'gql-query-builder';
3
- import { jsonToGraphQLQuery } from 'json-to-graphql-query';
4
-
5
- export default async function (operation, args, fields = []) {
6
-
7
- const mutation = {
8
- mutation: {
9
-
10
- }
11
- }
12
-
13
-
14
- mutation.mutation[operation] = {};
15
- if (args) {
16
- mutation.mutation[operation].__args = args;
17
-
18
- }
19
-
20
-
21
- let map = {};
22
- let map_values = [];
23
-
24
- fields.forEach(field => {
25
-
26
- if (typeof field === 'string') {
27
- mutation.mutation[operation][field] = true;
28
- } else {
29
- mutation.mutation.__variables = mutation.mutation.__variables || {};
30
-
31
- let i = 0;
32
- Object.entries(field.__variables).forEach(([key, value]) => {
33
- mutation.mutation.__variables[key] = value.type;
34
- map[i] = ["variables." + key];
35
- map_values.push(value.value);
36
- i++;
37
- });
38
- }
39
- });
40
-
41
-
42
- const graphql_query = jsonToGraphQLQuery(mutation);
43
- let service = axios.create({
44
- withCredentials: true
45
- });
46
-
47
- let data = null;
48
- if (map_values.length) {
49
- const fd = new FormData;
50
-
51
- fd.append("operations", JSON.stringify({
52
- query: graphql_query
53
- }));
54
- fd.append("map", JSON.stringify(map));
55
- for (let i = 0; i < map_values.length; i++) {
56
- fd.append(i, map_values[i]);
57
- }
58
- data = (await service.post("/api/", fd)).data;
59
-
60
- } else {
61
- data = (await service.post("/api/", {
62
- query: graphql_query
63
- })).data;
64
- }
65
-
66
- if (data.errors) {
67
- throw new Error(data.errors[0].message);
68
- }
69
-
70
- return data.data[operation];
71
-
72
-
73
- }
1
+ import axios from "axios";
2
+ import { jsonToGraphQLQuery } from "json-to-graphql-query";
3
+ export default async function(operation, args, fields = []) {
4
+ const mutation = {
5
+ mutation: {}
6
+ };
7
+ mutation.mutation[operation] = {};
8
+ if (args) {
9
+ mutation.mutation[operation].__args = args;
10
+ }
11
+ let map = {};
12
+ let map_values = [];
13
+ fields.forEach((field) => {
14
+ if (typeof field === "string") {
15
+ mutation.mutation[operation][field] = true;
16
+ } else {
17
+ mutation.mutation.__variables = mutation.mutation.__variables || {};
18
+ let i = 0;
19
+ Object.entries(field.__variables).forEach(([key, value]) => {
20
+ mutation.mutation.__variables[key] = value.type;
21
+ map[i] = ["variables." + key];
22
+ map_values.push(value.value);
23
+ i++;
24
+ });
25
+ }
26
+ });
27
+ const graphql_query = jsonToGraphQLQuery(mutation);
28
+ let service = axios.create({
29
+ withCredentials: true
30
+ });
31
+ let data = null;
32
+ if (map_values.length) {
33
+ const fd = new FormData();
34
+ fd.append("operations", JSON.stringify({
35
+ query: graphql_query
36
+ }));
37
+ fd.append("map", JSON.stringify(map));
38
+ for (let i = 0; i < map_values.length; i++) {
39
+ fd.append(i, map_values[i]);
40
+ }
41
+ data = (await service.post("/api/", fd)).data;
42
+ } else {
43
+ data = (await service.post("/api/", {
44
+ query: graphql_query
45
+ })).data;
46
+ }
47
+ if (data.errors) {
48
+ throw new Error(data.errors[0].message);
49
+ }
50
+ return data.data[operation];
51
+ }
@@ -1 +1 @@
1
- export default function _default(options: any): Promise<any>;
1
+ export default function (options: any): Promise<any>;
@@ -1,23 +1,12 @@
1
- import axios from 'axios';
2
- import { mutation } from 'gql-query-builder';
3
-
4
- export default async function (options) {
5
-
6
-
7
- let service = axios.create({
8
- withCredentials: true
9
- });
10
-
11
-
12
-
13
- const data = (await service.post("/api/", mutation(options))).data;
14
-
15
-
16
- if (data.errors) {
17
- throw new Error(data.errors[0].message);
18
- }
19
-
20
- return data;
21
-
22
-
23
- }
1
+ import axios from "axios";
2
+ import { mutation } from "gql-query-builder";
3
+ export default async function(options) {
4
+ let service = axios.create({
5
+ withCredentials: true
6
+ });
7
+ const data = (await service.post("/api/", mutation(options))).data;
8
+ if (data.errors) {
9
+ throw new Error(data.errors[0].message);
10
+ }
11
+ return data;
12
+ }
@@ -1 +1 @@
1
- export default function _default(x: any): string;
1
+ export default function (x: any): string;
@@ -1,8 +1,5 @@
1
- import { useI18n } from 'vue-i18n';
2
-
3
- export default function (x) {
4
- const i18n = useI18n();
5
-
6
- return i18n.t(x);
7
-
8
- }
1
+ import { useI18n } from "vue-i18n";
2
+ export default function(x) {
3
+ const i18n = useI18n();
4
+ return i18n.t(x);
5
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hostlink/nuxt-light",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "description": "My new Nuxt module",
5
5
  "repository": "@hostlink/nuxt-light",
6
6
  "license": "MIT",