@hostlink/nuxt-light 1.54.0 → 1.54.2

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,7 +1,7 @@
1
1
  {
2
2
  "name": "light",
3
3
  "configKey": "light",
4
- "version": "1.54.0",
4
+ "version": "1.54.2",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -366,10 +366,11 @@ const module$1 = defineNuxtModule({
366
366
  path: resolver.resolve("./runtime/components")
367
367
  });
368
368
  addImportsDir(resolver.resolve("./runtime/composables"));
369
+ const files0 = await resolveFiles(resolver.resolve("./runtime/models"), ["*"]);
369
370
  const files = await resolveFiles(process.cwd() + "/models", ["*"]);
370
371
  const files2 = await resolveFiles(process.cwd() + "/app/models", ["*"]);
371
372
  let content = "";
372
- for (const file of [...files, ...files2]) {
373
+ for (const file of [...files0, ...files, ...files2]) {
373
374
  content += `(await import('${file}')).default();
374
375
  `;
375
376
  }
@@ -381,6 +382,7 @@ const module$1 = defineNuxtModule({
381
382
  export default defineNuxtPlugin({
382
383
  name: 'light-model-plugin',
383
384
  async setup (nuxtApp) {
385
+
384
386
  ${content}
385
387
  }
386
388
  })`
@@ -1,6 +1,7 @@
1
1
  import { getApiClient } from "@hostlink/light";
2
+ const client = getApiClient();
2
3
  export default (model) => {
3
4
  return () => {
4
- getApiClient().models.create(model.name, model.fields);
5
+ client.models.create(model.name, model.fields);
5
6
  };
6
7
  };
@@ -1,7 +1,179 @@
1
- import type { Model } from '@hostlink/light';
2
1
  import type { LTableColumn } from "../components/l-table.vue.js";
3
- interface LModel extends Model {
4
- columns(fields: string[]): Array<LTableColumn>;
5
- }
6
- declare const _default: (name: string) => LModel;
2
+ declare const _default: (name: string) => Omit<{
3
+ field: (f: string) => import("@hostlink/light").Field | null;
4
+ $fields: Record<string, import("@hostlink/light").Field>;
5
+ setDataPath(path: string): string;
6
+ getDataPath(): string;
7
+ gqlFields(fields: (string | object)[]): Record<string, any>;
8
+ update(id: number, data: Object): Promise<any>;
9
+ delete(id: number): Promise<any>;
10
+ add(data: Object): Promise<any>;
11
+ fields(fields: string[]): import("@hostlink/light").Field[];
12
+ get(filters: any, fields: import("@hostlink/light").Fields): Promise<any>;
13
+ list(fields: Record<string, any>): {
14
+ fetch(): Promise<any[]>;
15
+ fetchFirst(): Promise<any>;
16
+ first(): Promise<any>;
17
+ all(): Promise<any[]>;
18
+ fetchWithMeta(): Promise<any>;
19
+ dataPath(dataPath?: string): {
20
+ first(): Promise<any>;
21
+ all(): Promise<any[]>;
22
+ fetchFirst(): Promise<any>;
23
+ fetchWithMeta(): Promise<any>;
24
+ fetch(): Promise<any[]>;
25
+ dataPath(dataPath?: string): any;
26
+ sort(sortStr: string): any;
27
+ filters(filterObj: Record<string, any>): any;
28
+ where(key: string, opOrVal?: any, maybeVal?: any): any;
29
+ whereContains(field: string, val: any): any;
30
+ whereIn(field: string, vals: any[]): any;
31
+ whereBetween(field: string, min: any, max: any): any;
32
+ limit(n: number): any;
33
+ offset(n: number): any;
34
+ toQuery(includeMeta?: boolean): any;
35
+ };
36
+ sort(sortStr: string): {
37
+ first(): Promise<any>;
38
+ all(): Promise<any[]>;
39
+ fetchFirst(): Promise<any>;
40
+ fetchWithMeta(): Promise<any>;
41
+ fetch(): Promise<any[]>;
42
+ dataPath(dataPath?: string): any;
43
+ sort(sortStr: string): any;
44
+ filters(filterObj: Record<string, any>): any;
45
+ where(key: string, opOrVal?: any, maybeVal?: any): any;
46
+ whereContains(field: string, val: any): any;
47
+ whereIn(field: string, vals: any[]): any;
48
+ whereBetween(field: string, min: any, max: any): any;
49
+ limit(n: number): any;
50
+ offset(n: number): any;
51
+ toQuery(includeMeta?: boolean): any;
52
+ };
53
+ filters(filterObj: Record<string, any>): {
54
+ first(): Promise<any>;
55
+ all(): Promise<any[]>;
56
+ fetchFirst(): Promise<any>;
57
+ fetchWithMeta(): Promise<any>;
58
+ fetch(): Promise<any[]>;
59
+ dataPath(dataPath?: string): any;
60
+ sort(sortStr: string): any;
61
+ filters(filterObj: Record<string, any>): any;
62
+ where(key: string, opOrVal?: any, maybeVal?: any): any;
63
+ whereContains(field: string, val: any): any;
64
+ whereIn(field: string, vals: any[]): any;
65
+ whereBetween(field: string, min: any, max: any): any;
66
+ limit(n: number): any;
67
+ offset(n: number): any;
68
+ toQuery(includeMeta?: boolean): any;
69
+ };
70
+ where(key: string, opOrVal?: any, maybeVal?: any): {
71
+ first(): Promise<any>;
72
+ all(): Promise<any[]>;
73
+ fetchFirst(): Promise<any>;
74
+ fetchWithMeta(): Promise<any>;
75
+ fetch(): Promise<any[]>;
76
+ dataPath(dataPath?: string): any;
77
+ sort(sortStr: string): any;
78
+ filters(filterObj: Record<string, any>): any;
79
+ where(key: string, opOrVal?: any, maybeVal?: any): any;
80
+ whereContains(field: string, val: any): any;
81
+ whereIn(field: string, vals: any[]): any;
82
+ whereBetween(field: string, min: any, max: any): any;
83
+ limit(n: number): any;
84
+ offset(n: number): any;
85
+ toQuery(includeMeta?: boolean): any;
86
+ };
87
+ whereContains(field: string, val: any): {
88
+ first(): Promise<any>;
89
+ all(): Promise<any[]>;
90
+ fetchFirst(): Promise<any>;
91
+ fetchWithMeta(): Promise<any>;
92
+ fetch(): Promise<any[]>;
93
+ dataPath(dataPath?: string): any;
94
+ sort(sortStr: string): any;
95
+ filters(filterObj: Record<string, any>): any;
96
+ where(key: string, opOrVal?: any, maybeVal?: any): any;
97
+ whereContains(field: string, val: any): any;
98
+ whereIn(field: string, vals: any[]): any;
99
+ whereBetween(field: string, min: any, max: any): any;
100
+ limit(n: number): any;
101
+ offset(n: number): any;
102
+ toQuery(includeMeta?: boolean): any;
103
+ };
104
+ whereIn(field: string, vals: any[]): {
105
+ first(): Promise<any>;
106
+ all(): Promise<any[]>;
107
+ fetchFirst(): Promise<any>;
108
+ fetchWithMeta(): Promise<any>;
109
+ fetch(): Promise<any[]>;
110
+ dataPath(dataPath?: string): any;
111
+ sort(sortStr: string): any;
112
+ filters(filterObj: Record<string, any>): any;
113
+ where(key: string, opOrVal?: any, maybeVal?: any): any;
114
+ whereContains(field: string, val: any): any;
115
+ whereIn(field: string, vals: any[]): any;
116
+ whereBetween(field: string, min: any, max: any): any;
117
+ limit(n: number): any;
118
+ offset(n: number): any;
119
+ toQuery(includeMeta?: boolean): any;
120
+ };
121
+ whereBetween(field: string, min: any, max: any): {
122
+ first(): Promise<any>;
123
+ all(): Promise<any[]>;
124
+ fetchFirst(): Promise<any>;
125
+ fetchWithMeta(): Promise<any>;
126
+ fetch(): Promise<any[]>;
127
+ dataPath(dataPath?: string): any;
128
+ sort(sortStr: string): any;
129
+ filters(filterObj: Record<string, any>): any;
130
+ where(key: string, opOrVal?: any, maybeVal?: any): any;
131
+ whereContains(field: string, val: any): any;
132
+ whereIn(field: string, vals: any[]): any;
133
+ whereBetween(field: string, min: any, max: any): any;
134
+ limit(n: number): any;
135
+ offset(n: number): any;
136
+ toQuery(includeMeta?: boolean): any;
137
+ };
138
+ limit(n: number): {
139
+ first(): Promise<any>;
140
+ all(): Promise<any[]>;
141
+ fetchFirst(): Promise<any>;
142
+ fetchWithMeta(): Promise<any>;
143
+ fetch(): Promise<any[]>;
144
+ dataPath(dataPath?: string): any;
145
+ sort(sortStr: string): any;
146
+ filters(filterObj: Record<string, any>): any;
147
+ where(key: string, opOrVal?: any, maybeVal?: any): any;
148
+ whereContains(field: string, val: any): any;
149
+ whereIn(field: string, vals: any[]): any;
150
+ whereBetween(field: string, min: any, max: any): any;
151
+ limit(n: number): any;
152
+ offset(n: number): any;
153
+ toQuery(includeMeta?: boolean): any;
154
+ };
155
+ offset(n: number): {
156
+ first(): Promise<any>;
157
+ all(): Promise<any[]>;
158
+ fetchFirst(): Promise<any>;
159
+ fetchWithMeta(): Promise<any>;
160
+ fetch(): Promise<any[]>;
161
+ dataPath(dataPath?: string): any;
162
+ sort(sortStr: string): any;
163
+ filters(filterObj: Record<string, any>): any;
164
+ where(key: string, opOrVal?: any, maybeVal?: any): any;
165
+ whereContains(field: string, val: any): any;
166
+ whereIn(field: string, vals: any[]): any;
167
+ whereBetween(field: string, min: any, max: any): any;
168
+ limit(n: number): any;
169
+ offset(n: number): any;
170
+ toQuery(includeMeta?: boolean): any;
171
+ };
172
+ toQuery(includeMeta?: boolean): any;
173
+ };
174
+ }, never> & Omit<{
175
+ columns(fields: string[] | {
176
+ [key: string]: boolean;
177
+ }): Array<LTableColumn>;
178
+ }, never> & {};
7
179
  export default _default;
@@ -1,7 +1,9 @@
1
- import { useGlobalModel } from "@hostlink/light";
1
+ import { getApiClient } from "@hostlink/light";
2
+ import defu from "defu";
2
3
  export default (name) => {
3
- const m = useGlobalModel().getModel(name);
4
- return Object.assign(m, {
4
+ const client = getApiClient();
5
+ const m = client.model(name);
6
+ return defu(m, {
5
7
  columns(fields) {
6
8
  let columns = [];
7
9
  if (!Array.isArray(fields)) {
@@ -1,6 +1,6 @@
1
1
  import { computed } from "vue";
2
2
  import useLight from "./useLight.js";
3
- import q from "./q";
3
+ import { query } from "@hostlink/light";
4
4
  export default function useRoles() {
5
5
  const light = useLight();
6
6
  const roles = computed(() => light.myRoles || []);
@@ -19,9 +19,9 @@ export default function useRoles() {
19
19
  return wanted.every((r) => light.myRoles.includes(r));
20
20
  }
21
21
  async function reload() {
22
- const data = await q({
22
+ const data = await query({
23
23
  my: {
24
- roles
24
+ roles: true
25
25
  }
26
26
  });
27
27
  const newRoles = (data?.my?.roles || []).map((r) => r.role || r);
@@ -1,26 +1,2 @@
1
- declare const _default: {
2
- name: string;
3
- fields: {
4
- name: {
5
- label: string;
6
- sortable: boolean;
7
- searchable: boolean;
8
- };
9
- model: {
10
- label: string;
11
- sortable: boolean;
12
- searchable: boolean;
13
- };
14
- type: {
15
- label: string;
16
- sortable: boolean;
17
- searchable: boolean;
18
- };
19
- validation: {
20
- label: string;
21
- sortable: boolean;
22
- searchable: boolean;
23
- };
24
- };
25
- };
1
+ declare const _default: () => void;
26
2
  export default _default;
@@ -1,4 +1,5 @@
1
- export default {
1
+ import { defineLightModel } from "#imports";
2
+ export default defineLightModel({
2
3
  name: "CustomField",
3
4
  fields: {
4
5
  name: {
@@ -22,4 +23,4 @@ export default {
22
23
  searchable: true
23
24
  }
24
25
  }
25
- };
26
+ });
@@ -1,38 +1,2 @@
1
- declare const _default: {
2
- name: string;
3
- fields: {
4
- eventlog_id: {
5
- label: string;
6
- sortable: boolean;
7
- searchable: boolean;
8
- autoWidth: boolean;
9
- };
10
- class: {
11
- label: string;
12
- sortable: boolean;
13
- searchable: boolean;
14
- };
15
- id: {
16
- label: string;
17
- sortable: boolean;
18
- searchable: boolean;
19
- };
20
- action: {
21
- label: string;
22
- sortable: boolean;
23
- searchable: boolean;
24
- };
25
- created_time: {
26
- label: string;
27
- sortable: boolean;
28
- searchable: boolean;
29
- searchType: string;
30
- };
31
- username: {
32
- label: string;
33
- sortable: boolean;
34
- searchable: boolean;
35
- };
36
- };
37
- };
1
+ declare const _default: () => void;
38
2
  export default _default;
@@ -1,4 +1,5 @@
1
- export default {
1
+ import { defineLightModel } from "#imports";
2
+ export default defineLightModel({
2
3
  name: "EventLog",
3
4
  fields: {
4
5
  eventlog_id: {
@@ -34,4 +35,4 @@ export default {
34
35
  searchable: true
35
36
  }
36
37
  }
37
- };
38
+ });
@@ -1,34 +1,2 @@
1
- declare const _default: {
2
- name: string;
3
- fields: {
4
- maillog_id: {
5
- label: string;
6
- sortable: boolean;
7
- searchable: boolean;
8
- searchType: string;
9
- autoWidth: boolean;
10
- };
11
- from: {
12
- label: string;
13
- sortable: boolean;
14
- searchable: boolean;
15
- };
16
- to: {
17
- label: string;
18
- sortable: boolean;
19
- searchable: boolean;
20
- };
21
- subject: {
22
- label: string;
23
- sortable: boolean;
24
- searchable: boolean;
25
- };
26
- created_time: {
27
- label: string;
28
- sortable: boolean;
29
- searchable: boolean;
30
- searchType: string;
31
- };
32
- };
33
- };
1
+ declare const _default: () => void;
34
2
  export default _default;
@@ -1,4 +1,5 @@
1
- export default {
1
+ import { defineLightModel } from "#imports";
2
+ export default defineLightModel({
2
3
  name: "MailLog",
3
4
  fields: {
4
5
  maillog_id: {
@@ -30,4 +31,4 @@ export default {
30
31
  searchType: "date"
31
32
  }
32
33
  }
33
- };
34
+ });
@@ -1,14 +1,2 @@
1
- declare const _default: {
2
- name: string;
3
- fields: {
4
- name: {
5
- label: string;
6
- sortable: boolean;
7
- searchable: boolean;
8
- };
9
- value: {
10
- label: string;
11
- };
12
- };
13
- };
1
+ declare const _default: () => void;
14
2
  export default _default;
@@ -1,4 +1,5 @@
1
- export default {
1
+ import { defineLightModel } from "#imports";
2
+ export default defineLightModel({
2
3
  name: "SystemValue",
3
4
  fields: {
4
5
  name: {
@@ -10,4 +11,4 @@ export default {
10
11
  label: "Value"
11
12
  }
12
13
  }
13
- };
14
+ });
@@ -1,71 +1,2 @@
1
- declare const _default: {
2
- name: string;
3
- fields: {
4
- Name: {
5
- label: string;
6
- gql: {
7
- first_name: boolean;
8
- last_name: boolean;
9
- };
10
- format: (row: any) => string;
11
- };
12
- username: {
13
- label: string;
14
- sortable: boolean;
15
- searchable: boolean;
16
- required: boolean;
17
- };
18
- first_name: {
19
- label: string;
20
- sortable: boolean;
21
- searchable: boolean;
22
- };
23
- last_name: {
24
- label: string;
25
- sortable: boolean;
26
- searchable: boolean;
27
- };
28
- email: {
29
- label: string;
30
- sortable: boolean;
31
- searchable: boolean;
32
- };
33
- phone: {
34
- label: string;
35
- sortable: boolean;
36
- searchable: boolean;
37
- };
38
- join_date: {
39
- label: string;
40
- sortable: boolean;
41
- searchable: boolean;
42
- searchType: string;
43
- };
44
- roles: {
45
- label: string;
46
- format: (value: any) => any;
47
- };
48
- status: {
49
- label: string;
50
- searchable: boolean;
51
- searchType: string;
52
- searchOptions: {
53
- label: string;
54
- value: number;
55
- }[];
56
- format: (value: any) => string | undefined;
57
- };
58
- has2FA: {
59
- label: string;
60
- format: (value: any) => "" | "✔️";
61
- };
62
- _test2: {
63
- label: string;
64
- component: any;
65
- componentProps: (a: any) => {
66
- test: any;
67
- };
68
- };
69
- };
70
- };
1
+ declare const _default: () => void;
71
2
  export default _default;
@@ -1,5 +1,5 @@
1
- import MyTest from "../components/MyTest.vue";
2
- export default {
1
+ import { defineLightModel } from "#imports";
2
+ export default defineLightModel({
3
3
  name: "User",
4
4
  fields: {
5
5
  Name: {
@@ -75,15 +75,6 @@ export default {
75
75
  format: (value) => {
76
76
  return value ? "\u2714\uFE0F" : "";
77
77
  }
78
- },
79
- _test2: {
80
- label: "Test",
81
- component: MyTest,
82
- componentProps: (a) => {
83
- return {
84
- test: a.username
85
- };
86
- }
87
78
  }
88
79
  }
89
- };
80
+ });
@@ -1,51 +1,2 @@
1
- declare const _default: {
2
- name: string;
3
- fields: {
4
- userlog_id: {
5
- label: string;
6
- sortable: boolean;
7
- searchable: boolean;
8
- autoWidth: boolean;
9
- };
10
- username: {
11
- label: string;
12
- sortable: boolean;
13
- searchable: boolean;
14
- };
15
- login_dt: {
16
- label: string;
17
- sortable: boolean;
18
- searchable: boolean;
19
- searchType: string;
20
- };
21
- logout_dt: {
22
- label: string;
23
- sortable: boolean;
24
- searchable: boolean;
25
- };
26
- result: {
27
- label: string;
28
- sortable: boolean;
29
- searchable: boolean;
30
- searchType: string;
31
- searchOptions: {
32
- label: string;
33
- value: string;
34
- }[];
35
- autoWidth: boolean;
36
- };
37
- user_agent: {
38
- label: string;
39
- sortable: boolean;
40
- searchable: boolean;
41
- whiteSpace: string;
42
- };
43
- last_access_time: {
44
- label: string;
45
- sortable: boolean;
46
- searchable: boolean;
47
- searchType: string;
48
- };
49
- };
50
- };
1
+ declare const _default: () => void;
51
2
  export default _default;
@@ -1,4 +1,5 @@
1
- export default {
1
+ import { defineLightModel } from "#imports";
2
+ export default defineLightModel({
2
3
  name: "UserLog",
3
4
  fields: {
4
5
  userlog_id: {
@@ -44,7 +45,7 @@ export default {
44
45
  label: "User agent",
45
46
  sortable: true,
46
47
  searchable: true,
47
- whiteSpace: "pre-line"
48
+ style: "white-space:pre-wrap;"
48
49
  },
49
50
  last_access_time: {
50
51
  label: "Last access time",
@@ -53,4 +54,4 @@ export default {
53
54
  searchType: "date"
54
55
  }
55
56
  }
56
- };
57
+ });
@@ -37,10 +37,10 @@ const options = [
37
37
  { label: "Active", value: 0 },
38
38
  { label: "Inactive", value: 1 }
39
39
  ];
40
- const tt = await q({
41
- app: ["languages"]
40
+ const { app } = await q({
41
+ app: { languages: true }
42
42
  });
43
- const languages = tt.app.languages.map((lang) => {
43
+ const languages = app.languages.map((lang) => {
44
44
  return {
45
45
  label: lang.name,
46
46
  value: lang.value
@@ -50,7 +50,7 @@ const languages = tt.app.languages.map((lang) => {
50
50
 
51
51
  <template>
52
52
  <l-page>
53
-
53
+
54
54
  <FormKit type="l-form" :value="obj">
55
55
  <l-row class="col">
56
56
  <l-col md="6">
@@ -1,6 +1,6 @@
1
1
  import QMarkdownVuePlugin from "@quasar/quasar-ui-qmarkdown";
2
2
  import "@quasar/quasar-ui-qmarkdown/dist/index.css";
3
- import { createClient, useGlobalModel, setApiClient } from "@hostlink/light";
3
+ import { createClient, setApiClient } from "@hostlink/light";
4
4
  import { q } from "#imports";
5
5
  import { createI18n } from "vue-i18n";
6
6
  import createLight from "./composables/createLight.js";
@@ -14,12 +14,6 @@ import { createLightPlugin } from "./formkit/index.js";
14
14
  import { plugin, defaultConfig } from "@formkit/vue";
15
15
  import getApiBase from "./composables/getApiBase.js";
16
16
  import useLight from "./composables/useLight.js";
17
- import TypeUser from "./models/User.js";
18
- import TypeUserLog from "./models/UserLog.js";
19
- import TypeSystemValue from "./models/SystemValue.js";
20
- import TypeMailLog from "./models/MailLog.js";
21
- import TypeEventLog from "./models/EventLog.js";
22
- import TypeCustomerField from "./models/CustomField.js";
23
17
  import { zhTW } from "@formkit/i18n";
24
18
  export default defineNuxtPlugin((nuxtApp) => {
25
19
  addRouteMiddleware("auth", async (to, from) => {
@@ -44,20 +38,6 @@ export default defineNuxtPlugin((nuxtApp) => {
44
38
  }, { global: true });
45
39
  const client = createClient(getApiBase());
46
40
  setApiClient(client);
47
- const models = useGlobalModel();
48
- models.createModel("User", TypeUser.fields);
49
- models.createModel("CustomField", TypeCustomerField.fields);
50
- models.createModel("UserLog", TypeUserLog.fields);
51
- models.createModel("SystemValue", TypeSystemValue.fields);
52
- models.createModel("MailLog", TypeMailLog.fields);
53
- models.createModel("EventLog", TypeEventLog.fields);
54
- models.createModel("Permission", {});
55
- models.getModel("User").setDataPath("app.listUser");
56
- models.getModel("MailLog").setDataPath("app.listMailLog");
57
- models.getModel("EventLog").setDataPath("app.listEventLog");
58
- models.getModel("UserLog").setDataPath("app.listUserLog");
59
- models.getModel("SystemValue").setDataPath("app.listSystemValue");
60
- models.getModel("Permission").setDataPath("app.listPermission");
61
41
  nuxtApp.vueApp.config.errorHandler = (err, instance, info) => {
62
42
  const $route = useRoute();
63
43
  const light = useLight();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hostlink/nuxt-light",
3
- "version": "1.54.0",
3
+ "version": "1.54.2",
4
4
  "description": "HostLink Nuxt Light Framework",
5
5
  "repository": {
6
6
  "type": "git",