@hostlink/nuxt-light 0.0.60 → 0.0.62
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 +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/index.mjs +1 -20
- package/dist/runtime/lib/getObject.d.ts +1 -1
- package/dist/runtime/lib/getObject.mjs +3 -9
- package/dist/runtime/lib/index.d.ts +2 -2
- package/dist/runtime/lib/index.mjs +3 -3
- package/dist/runtime/lib/listData.d.ts +1 -1
- package/dist/runtime/lib/listData.mjs +36 -20
- package/dist/runtime/lib/loadObject.d.ts +1 -0
- package/dist/runtime/lib/loadObject.mjs +10 -0
- package/dist/runtime/lib/q.d.ts +1 -1
- package/dist/runtime/lib/q.mjs +1 -1
- package/dist/runtime/pages/User/_user_id/view.vue +7 -2
- package/package.json +1 -1
- package/dist/runtime/lib/id.d.ts +0 -2
- package/dist/runtime/lib/id.mjs +0 -12
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -42,7 +42,7 @@ const module = defineNuxtModule({
|
|
|
42
42
|
{ name: "getApiUrl", from },
|
|
43
43
|
{ name: "getCurrentUser", from },
|
|
44
44
|
{ name: "getObject", from },
|
|
45
|
-
{ name: "
|
|
45
|
+
{ name: "loadObject", from },
|
|
46
46
|
{ name: "list", from },
|
|
47
47
|
{ name: "listData", from },
|
|
48
48
|
{ name: "m", from },
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -7,4 +7,4 @@ interface Light {
|
|
|
7
7
|
getVersion(): string;
|
|
8
8
|
}
|
|
9
9
|
export declare function useLight(): Light;
|
|
10
|
-
export
|
|
10
|
+
export * from "./lib";
|
package/dist/runtime/index.mjs
CHANGED
|
@@ -29,23 +29,4 @@ export function useLight() {
|
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
-
export
|
|
33
|
-
notify,
|
|
34
|
-
addObject,
|
|
35
|
-
f,
|
|
36
|
-
getApiUrl,
|
|
37
|
-
getCurrentUser,
|
|
38
|
-
getObject,
|
|
39
|
-
id,
|
|
40
|
-
list,
|
|
41
|
-
listData,
|
|
42
|
-
m,
|
|
43
|
-
q,
|
|
44
|
-
removeObject,
|
|
45
|
-
t,
|
|
46
|
-
updateObject,
|
|
47
|
-
getID,
|
|
48
|
-
deleteObject,
|
|
49
|
-
listObject,
|
|
50
|
-
getApiBase
|
|
51
|
-
} from "./lib/index.mjs";
|
|
32
|
+
export * from "./lib/index.mjs";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function (fields?: Array<string>): Promise<any>;
|
|
1
|
+
export default function (fields?: Array<string | Object>): Promise<any>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useRoute } from "vue-router";
|
|
2
|
-
import
|
|
2
|
+
import loadObject from "./loadObject.mjs";
|
|
3
3
|
export default async function(fields = []) {
|
|
4
4
|
let route = useRoute();
|
|
5
5
|
if (!route.name) {
|
|
@@ -9,14 +9,8 @@ export default async function(fields = []) {
|
|
|
9
9
|
const id = parseInt(route.params[id_name]);
|
|
10
10
|
const filters = {};
|
|
11
11
|
filters[id_name] = id;
|
|
12
|
-
if (fields.length == 0) {
|
|
12
|
+
if (fields instanceof Array && fields.length == 0) {
|
|
13
13
|
fields.push(id_name);
|
|
14
14
|
}
|
|
15
|
-
|
|
16
|
-
filters
|
|
17
|
-
}, fields);
|
|
18
|
-
if (data.length > 0) {
|
|
19
|
-
return data[0];
|
|
20
|
-
}
|
|
21
|
-
return null;
|
|
15
|
+
return await loadObject(module, filters, fields);
|
|
22
16
|
}
|
|
@@ -3,7 +3,6 @@ import f from "./f";
|
|
|
3
3
|
import getApiUrl from "./getApiUrl";
|
|
4
4
|
import getCurrentUser from "./getCurrentUser";
|
|
5
5
|
import getObject from "./getObject";
|
|
6
|
-
import id from "./id";
|
|
7
6
|
import list from "./list";
|
|
8
7
|
import listData from "./listData";
|
|
9
8
|
import m from "./m";
|
|
@@ -13,8 +12,9 @@ import deleteObject from "./deleteObject";
|
|
|
13
12
|
import t from "./t";
|
|
14
13
|
import updateObject from "./updateObject";
|
|
15
14
|
import listObject from "./listObject";
|
|
15
|
+
import loadObject from "./loadObject";
|
|
16
16
|
import isGranted from "./isGranted";
|
|
17
17
|
declare const notify: (message: string, color?: string) => void;
|
|
18
18
|
import getID from "./getID";
|
|
19
19
|
declare const getApiBase: () => {};
|
|
20
|
-
export { addObject, f, getApiUrl, getCurrentUser, getObject,
|
|
20
|
+
export { addObject, f, getApiUrl, getCurrentUser, getObject, list, listData, m, q, removeObject, t, updateObject, notify, getID, deleteObject, listObject, isGranted, getApiBase, loadObject };
|
|
@@ -5,7 +5,6 @@ import f from "./f.mjs";
|
|
|
5
5
|
import getApiUrl from "./getApiUrl.mjs";
|
|
6
6
|
import getCurrentUser from "./getCurrentUser.mjs";
|
|
7
7
|
import getObject from "./getObject.mjs";
|
|
8
|
-
import id from "./id.mjs";
|
|
9
8
|
import list from "./list.mjs";
|
|
10
9
|
import listData from "./listData.mjs";
|
|
11
10
|
import m from "./m.mjs";
|
|
@@ -15,6 +14,7 @@ import deleteObject from "./deleteObject.mjs";
|
|
|
15
14
|
import t from "./t.mjs";
|
|
16
15
|
import updateObject from "./updateObject.mjs";
|
|
17
16
|
import listObject from "./listObject.mjs";
|
|
17
|
+
import loadObject from "./loadObject.mjs";
|
|
18
18
|
import isGranted from "./isGranted.mjs";
|
|
19
19
|
const notify = function(message, color = "green") {
|
|
20
20
|
Notify.create({
|
|
@@ -34,7 +34,6 @@ export {
|
|
|
34
34
|
getApiUrl,
|
|
35
35
|
getCurrentUser,
|
|
36
36
|
getObject,
|
|
37
|
-
id,
|
|
38
37
|
list,
|
|
39
38
|
listData,
|
|
40
39
|
m,
|
|
@@ -47,5 +46,6 @@ export {
|
|
|
47
46
|
deleteObject,
|
|
48
47
|
listObject,
|
|
49
48
|
isGranted,
|
|
50
|
-
getApiBase
|
|
49
|
+
getApiBase,
|
|
50
|
+
loadObject
|
|
51
51
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function listData(name: string, props?: any, fields?: Array<string>): Promise<any>;
|
|
1
|
+
export default function listData(name: string, props?: any, fields?: Array<string | Object> | Object): Promise<any>;
|
|
@@ -1,32 +1,48 @@
|
|
|
1
|
-
import
|
|
2
|
-
import f from "./f.mjs";
|
|
1
|
+
import { query, toQuery } from "@hostlink/light";
|
|
3
2
|
export default async function listData(name, props = {}, fields = []) {
|
|
4
|
-
let
|
|
3
|
+
let json = {};
|
|
5
4
|
if (props.sort) {
|
|
6
|
-
|
|
5
|
+
json.__args = json.__args || {};
|
|
6
|
+
json.__args.sort = props.sort;
|
|
7
7
|
}
|
|
8
8
|
if (props.filters) {
|
|
9
|
-
|
|
9
|
+
json.__args = json.__args || {};
|
|
10
|
+
json.__args.filters = props.filters;
|
|
10
11
|
}
|
|
11
|
-
|
|
12
|
+
json.data = {};
|
|
12
13
|
if (props.offset) {
|
|
13
|
-
|
|
14
|
+
json.data.__args = json.data.__args || {};
|
|
15
|
+
json.data.__args.offset = props.offset;
|
|
14
16
|
}
|
|
15
17
|
if (props.limit) {
|
|
16
|
-
|
|
18
|
+
json.data.__args = json.data.__args || {};
|
|
19
|
+
json.data.__args.limit = props.limit;
|
|
17
20
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
key: data.meta.key,
|
|
28
|
-
name: data.meta.name
|
|
21
|
+
if (fields instanceof Array) {
|
|
22
|
+
fields.forEach((field) => {
|
|
23
|
+
if (field instanceof Object) {
|
|
24
|
+
Object.entries(field).forEach(([key, value]) => {
|
|
25
|
+
json.data[key] = toQuery(value);
|
|
26
|
+
});
|
|
27
|
+
} else {
|
|
28
|
+
json.data[field] = true;
|
|
29
|
+
}
|
|
29
30
|
});
|
|
31
|
+
} else if (fields instanceof Object) {
|
|
32
|
+
json.data = Object.assign({}, fields);
|
|
33
|
+
if (props.fields) {
|
|
34
|
+
props.fields.forEach((field) => {
|
|
35
|
+
json.data[field] = true;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
30
38
|
}
|
|
31
|
-
|
|
39
|
+
json.meta = {
|
|
40
|
+
total: true,
|
|
41
|
+
key: true,
|
|
42
|
+
name: true
|
|
43
|
+
};
|
|
44
|
+
const q = {};
|
|
45
|
+
q[`list${name}`] = json;
|
|
46
|
+
let data = await query(q);
|
|
47
|
+
return data[`list${name}`];
|
|
32
48
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function (module: string, filters: Object, fields?: Array<string | Object>): Promise<any>;
|
package/dist/runtime/lib/q.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function (operation: string | object, args
|
|
1
|
+
export default function (operation: string | object, args?: any, fields?: Array<any>): Promise<any>;
|
package/dist/runtime/lib/q.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import f from "./f.mjs";
|
|
|
3
3
|
import { jsonToGraphQLQuery } from "json-to-graphql-query";
|
|
4
4
|
import { getApiBase } from "./index.mjs";
|
|
5
5
|
import toJson from "./toJson.mjs";
|
|
6
|
-
export default async function(operation, args, fields = []) {
|
|
6
|
+
export default async function(operation, args = null, fields = []) {
|
|
7
7
|
const service = axios.create({
|
|
8
8
|
withCredentials: true
|
|
9
9
|
});
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { getObject } from '../../../';
|
|
3
|
-
const obj = await getObject(["username", "first_name", "last_name", "email", "phone", "roles"]);
|
|
2
|
+
import { getObject, loadObject } from '../../../';
|
|
3
|
+
const obj = await getObject(["user_id", "username", "first_name", "last_name", "email", "phone", "roles"]);
|
|
4
|
+
|
|
5
|
+
/* const test = async () => {
|
|
6
|
+
console.log(await loadObject("User", { user_id: obj.user_id }, ["username"]));
|
|
7
|
+
}
|
|
8
|
+
*/
|
|
4
9
|
|
|
5
10
|
</script>
|
|
6
11
|
|
package/package.json
CHANGED
package/dist/runtime/lib/id.d.ts
DELETED
package/dist/runtime/lib/id.mjs
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { useRoute } from "vue-router";
|
|
2
|
-
const route = useRoute();
|
|
3
|
-
export default () => {
|
|
4
|
-
let name = route.name?.toString();
|
|
5
|
-
if (name == void 0)
|
|
6
|
-
return 0;
|
|
7
|
-
let parts = name.split("-");
|
|
8
|
-
const module = parts[0];
|
|
9
|
-
const moduleLower = module.charAt(0).toLowerCase() + module.slice(1);
|
|
10
|
-
const keyname = parts[1];
|
|
11
|
-
return parseInt(route.params[keyname]);
|
|
12
|
-
};
|