@ramathibodi/nuxt-commons 4.0.16 → 4.0.18
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/components/device/IdCardButton.d.vue.ts +2 -2
- package/dist/runtime/components/device/IdCardButton.vue.d.ts +2 -2
- package/dist/runtime/components/device/IdCardWebSocket.vue +7 -1
- package/dist/runtime/components/dialog/Confirm.d.vue.ts +1 -1
- package/dist/runtime/components/dialog/Confirm.vue.d.ts +1 -1
- package/dist/runtime/components/dialog/default/Confirm.d.vue.ts +2 -2
- package/dist/runtime/components/dialog/default/Confirm.vue.d.ts +2 -2
- package/dist/runtime/components/dialog/default/Notify.d.vue.ts +3 -3
- package/dist/runtime/components/dialog/default/Notify.vue.d.ts +3 -3
- package/dist/runtime/components/dialog/default/VerifyUser.d.vue.ts +2 -2
- package/dist/runtime/components/dialog/default/VerifyUser.vue.d.ts +2 -2
- package/dist/runtime/components/form/CheckboxGroup.vue +2 -2
- package/dist/runtime/components/form/DateTime.d.vue.ts +1 -1
- package/dist/runtime/components/form/DateTime.vue.d.ts +1 -1
- package/dist/runtime/components/form/Login.d.vue.ts +1 -1
- package/dist/runtime/components/form/Login.vue.d.ts +1 -1
- package/dist/runtime/components/form/Pad.d.vue.ts +1 -1
- package/dist/runtime/components/form/Pad.vue +1 -1
- package/dist/runtime/components/form/Pad.vue.d.ts +1 -1
- package/dist/runtime/components/form/images/Capture.d.vue.ts +1 -1
- package/dist/runtime/components/form/images/Capture.vue.d.ts +1 -1
- package/dist/runtime/components/label/Field.d.vue.ts +1 -1
- package/dist/runtime/components/label/Field.vue.d.ts +1 -1
- package/dist/runtime/components/model/Table.vue +5 -0
- package/dist/runtime/components/model/iterator.vue +6 -0
- package/dist/runtime/composables/api.d.ts +14 -0
- package/dist/runtime/composables/api.js +18 -3
- package/dist/runtime/composables/apiModel.js +1 -0
- package/dist/runtime/composables/clientConfig.d.ts +17 -0
- package/dist/runtime/composables/clientConfig.js +18 -6
- package/dist/runtime/composables/graphqlModel.js +1 -0
- package/dist/runtime/composables/hostAgent.d.ts +40 -0
- package/dist/runtime/composables/hostAgent.js +56 -2
- package/dist/runtime/labs/Calendar.d.vue.ts +4 -4
- package/dist/runtime/labs/Calendar.vue.d.ts +4 -4
- package/dist/runtime/plugins/clientConfig.js +30 -17
- package/dist/runtime/types/api.d.ts +36 -0
- package/dist/runtime/types/clientConfig.d.ts +17 -4
- package/package.json +1 -1
- package/templates/.codegen/plugin-schema-object.cjs +1 -1
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -36,7 +36,7 @@ const module$1 = defineNuxtModule({
|
|
|
36
36
|
src: resolver.resolve("runtime/plugins/default"),
|
|
37
37
|
mode: "client"
|
|
38
38
|
});
|
|
39
|
-
const typeFiles = ["modules", "alert", "menu", "graphqlOperation", "formDialog", "dialogManager", "permission", "clientConfig", "bridge"];
|
|
39
|
+
const typeFiles = ["modules", "alert", "menu", "graphqlOperation", "api", "formDialog", "dialogManager", "permission", "clientConfig", "bridge"];
|
|
40
40
|
for (const file of typeFiles) {
|
|
41
41
|
addTypeTemplate({
|
|
42
42
|
src: resolver.resolve(`runtime/types/${file}.d.ts`),
|
|
@@ -17,16 +17,16 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
|
|
|
17
17
|
reader: null;
|
|
18
18
|
disableWhileLoading: boolean;
|
|
19
19
|
}>>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
20
|
-
loading: (loading: boolean) => any;
|
|
21
20
|
error: (err: unknown) => any;
|
|
21
|
+
loading: (loading: boolean) => any;
|
|
22
22
|
read: (payload: PatientRegisterPayload) => any;
|
|
23
23
|
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<Props>, {
|
|
24
24
|
withPhoto: boolean;
|
|
25
25
|
reader: null;
|
|
26
26
|
disableWhileLoading: boolean;
|
|
27
27
|
}>>> & Readonly<{
|
|
28
|
-
onLoading?: ((loading: boolean) => any) | undefined;
|
|
29
28
|
onError?: ((err: unknown) => any) | undefined;
|
|
29
|
+
onLoading?: ((loading: boolean) => any) | undefined;
|
|
30
30
|
onRead?: ((payload: PatientRegisterPayload) => any) | undefined;
|
|
31
31
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
32
32
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
@@ -17,16 +17,16 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
|
|
|
17
17
|
reader: null;
|
|
18
18
|
disableWhileLoading: boolean;
|
|
19
19
|
}>>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
20
|
-
loading: (loading: boolean) => any;
|
|
21
20
|
error: (err: unknown) => any;
|
|
21
|
+
loading: (loading: boolean) => any;
|
|
22
22
|
read: (payload: PatientRegisterPayload) => any;
|
|
23
23
|
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<Props>, {
|
|
24
24
|
withPhoto: boolean;
|
|
25
25
|
reader: null;
|
|
26
26
|
disableWhileLoading: boolean;
|
|
27
27
|
}>>> & Readonly<{
|
|
28
|
-
onLoading?: ((loading: boolean) => any) | undefined;
|
|
29
28
|
onError?: ((err: unknown) => any) | undefined;
|
|
29
|
+
onLoading?: ((loading: boolean) => any) | undefined;
|
|
30
30
|
onRead?: ((payload: PatientRegisterPayload) => any) | undefined;
|
|
31
31
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
32
32
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
@@ -94,7 +94,13 @@ const off = host.onIdCardWsEvent((ev) => {
|
|
|
94
94
|
});
|
|
95
95
|
onMounted(() => {
|
|
96
96
|
mounted.value = true;
|
|
97
|
-
if (props.autoConnect)
|
|
97
|
+
if (props.autoConnect) {
|
|
98
|
+
try {
|
|
99
|
+
connectAndSubscribe();
|
|
100
|
+
} catch (e) {
|
|
101
|
+
emit("error", e);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
98
104
|
});
|
|
99
105
|
onBeforeUnmount(() => {
|
|
100
106
|
mounted.value = false;
|
|
@@ -21,9 +21,9 @@ declare const __VLS_base: import("vue").DefineComponent<DialogProps, {}, {}, {},
|
|
|
21
21
|
"onUpdate:modelValue"?: ((value: boolean) => any) | undefined;
|
|
22
22
|
"onUpdate:result"?: ((value: boolean) => any) | undefined;
|
|
23
23
|
}>, {
|
|
24
|
-
title: string;
|
|
25
24
|
message: string;
|
|
26
25
|
width: string;
|
|
26
|
+
title: string;
|
|
27
27
|
buttonTrueText: string;
|
|
28
28
|
buttonFalseText: string;
|
|
29
29
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -21,9 +21,9 @@ declare const __VLS_base: import("vue").DefineComponent<DialogProps, {}, {}, {},
|
|
|
21
21
|
"onUpdate:modelValue"?: ((value: boolean) => any) | undefined;
|
|
22
22
|
"onUpdate:result"?: ((value: boolean) => any) | undefined;
|
|
23
23
|
}>, {
|
|
24
|
-
title: string;
|
|
25
24
|
message: string;
|
|
26
25
|
width: string;
|
|
26
|
+
title: string;
|
|
27
27
|
buttonTrueText: string;
|
|
28
28
|
buttonFalseText: string;
|
|
29
29
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -23,10 +23,10 @@ declare const __VLS_base: import("vue").DefineComponent<DialogProps, {}, {}, {},
|
|
|
23
23
|
onResolve?: ((value: boolean) => any) | undefined;
|
|
24
24
|
onReject?: ((value: any) => any) | undefined;
|
|
25
25
|
}>, {
|
|
26
|
-
title: string;
|
|
27
|
-
type: "primary" | "success" | "warning" | "info" | "error";
|
|
28
26
|
message: string;
|
|
29
27
|
width: string;
|
|
28
|
+
title: string;
|
|
29
|
+
type: "primary" | "success" | "warning" | "info" | "error";
|
|
30
30
|
buttonTrueText: string;
|
|
31
31
|
buttonFalseText: string;
|
|
32
32
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -23,10 +23,10 @@ declare const __VLS_base: import("vue").DefineComponent<DialogProps, {}, {}, {},
|
|
|
23
23
|
onResolve?: ((value: boolean) => any) | undefined;
|
|
24
24
|
onReject?: ((value: any) => any) | undefined;
|
|
25
25
|
}>, {
|
|
26
|
-
title: string;
|
|
27
|
-
type: "primary" | "success" | "warning" | "info" | "error";
|
|
28
26
|
message: string;
|
|
29
27
|
width: string;
|
|
28
|
+
title: string;
|
|
29
|
+
type: "primary" | "success" | "warning" | "info" | "error";
|
|
30
30
|
buttonTrueText: string;
|
|
31
31
|
buttonFalseText: string;
|
|
32
32
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -13,11 +13,11 @@ declare const __VLS_export: import("vue").DefineComponent<DialogProps, {}, {}, {
|
|
|
13
13
|
"onUpdate:modelValue"?: ((value: boolean) => any) | undefined;
|
|
14
14
|
onResolve?: ((value: boolean) => any) | undefined;
|
|
15
15
|
}>, {
|
|
16
|
-
title: string;
|
|
17
|
-
buttonText: string;
|
|
18
|
-
type: "primary" | "success" | "warning" | "info" | "error";
|
|
19
16
|
message: string;
|
|
20
17
|
width: string;
|
|
18
|
+
title: string;
|
|
19
|
+
type: "primary" | "success" | "warning" | "info" | "error";
|
|
20
|
+
buttonText: string;
|
|
21
21
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
22
22
|
declare const _default: typeof __VLS_export;
|
|
23
23
|
export default _default;
|
|
@@ -13,11 +13,11 @@ declare const __VLS_export: import("vue").DefineComponent<DialogProps, {}, {}, {
|
|
|
13
13
|
"onUpdate:modelValue"?: ((value: boolean) => any) | undefined;
|
|
14
14
|
onResolve?: ((value: boolean) => any) | undefined;
|
|
15
15
|
}>, {
|
|
16
|
-
title: string;
|
|
17
|
-
buttonText: string;
|
|
18
|
-
type: "primary" | "success" | "warning" | "info" | "error";
|
|
19
16
|
message: string;
|
|
20
17
|
width: string;
|
|
18
|
+
title: string;
|
|
19
|
+
type: "primary" | "success" | "warning" | "info" | "error";
|
|
20
|
+
buttonText: string;
|
|
21
21
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
22
22
|
declare const _default: typeof __VLS_export;
|
|
23
23
|
export default _default;
|
|
@@ -17,10 +17,10 @@ declare const __VLS_export: import("vue").DefineComponent<DialogProps, {}, {}, {
|
|
|
17
17
|
onResolve?: ((value: string) => any) | undefined;
|
|
18
18
|
onReject?: ((value: any) => any) | undefined;
|
|
19
19
|
}>, {
|
|
20
|
-
title: string;
|
|
21
|
-
type: "primary" | "success" | "warning" | "info" | "error";
|
|
22
20
|
message: string;
|
|
23
21
|
width: string;
|
|
22
|
+
title: string;
|
|
23
|
+
type: "primary" | "success" | "warning" | "info" | "error";
|
|
24
24
|
confirmButtonText: string;
|
|
25
25
|
cancelButtonText: string;
|
|
26
26
|
fixedUsername: boolean | string;
|
|
@@ -17,10 +17,10 @@ declare const __VLS_export: import("vue").DefineComponent<DialogProps, {}, {}, {
|
|
|
17
17
|
onResolve?: ((value: string) => any) | undefined;
|
|
18
18
|
onReject?: ((value: any) => any) | undefined;
|
|
19
19
|
}>, {
|
|
20
|
-
title: string;
|
|
21
|
-
type: "primary" | "success" | "warning" | "info" | "error";
|
|
22
20
|
message: string;
|
|
23
21
|
width: string;
|
|
22
|
+
title: string;
|
|
23
|
+
type: "primary" | "success" | "warning" | "info" | "error";
|
|
24
24
|
confirmButtonText: string;
|
|
25
25
|
cancelButtonText: string;
|
|
26
26
|
fixedUsername: boolean | string;
|
|
@@ -71,7 +71,7 @@ watch(props.modelValue, () => {
|
|
|
71
71
|
:value="item.value"
|
|
72
72
|
density="compact"
|
|
73
73
|
hide-details
|
|
74
|
-
:error="isValid === false"
|
|
74
|
+
:error="isValid.value === false"
|
|
75
75
|
:="$attrs"
|
|
76
76
|
:label="item.label"
|
|
77
77
|
@update:model-value="onInteract"
|
|
@@ -81,7 +81,7 @@ watch(props.modelValue, () => {
|
|
|
81
81
|
v-if="computedOther"
|
|
82
82
|
v-model="valuesOther"
|
|
83
83
|
hide-details
|
|
84
|
-
:error="isValid === false"
|
|
84
|
+
:error="isValid.value === false"
|
|
85
85
|
:="$attrs"
|
|
86
86
|
:label="computedOther.label"
|
|
87
87
|
@update:model-value="onInteract"
|
|
@@ -22,9 +22,9 @@ declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {},
|
|
|
22
22
|
}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
|
|
23
23
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
24
24
|
}>, {
|
|
25
|
+
readonly: boolean;
|
|
25
26
|
locale: "TH" | "EN";
|
|
26
27
|
format: dateFormat | string;
|
|
27
|
-
readonly: boolean;
|
|
28
28
|
dense: boolean;
|
|
29
29
|
pickerOnly: boolean;
|
|
30
30
|
defaultDate: boolean | string;
|
|
@@ -22,9 +22,9 @@ declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {},
|
|
|
22
22
|
}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
|
|
23
23
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
24
24
|
}>, {
|
|
25
|
+
readonly: boolean;
|
|
25
26
|
locale: "TH" | "EN";
|
|
26
27
|
format: dateFormat | string;
|
|
27
|
-
readonly: boolean;
|
|
28
28
|
dense: boolean;
|
|
29
29
|
pickerOnly: boolean;
|
|
30
30
|
defaultDate: boolean | string;
|
|
@@ -15,8 +15,8 @@ declare const __VLS_base: import("vue").DefineComponent<Props, {}, {}, {}, {}, i
|
|
|
15
15
|
}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
|
|
16
16
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
17
17
|
}>, {
|
|
18
|
-
title: string;
|
|
19
18
|
loading: boolean;
|
|
19
|
+
title: string;
|
|
20
20
|
errorMessages: string;
|
|
21
21
|
hint: string;
|
|
22
22
|
btnSubmit: string;
|
|
@@ -15,8 +15,8 @@ declare const __VLS_base: import("vue").DefineComponent<Props, {}, {}, {}, {}, i
|
|
|
15
15
|
}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
|
|
16
16
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
17
17
|
}>, {
|
|
18
|
-
title: string;
|
|
19
18
|
loading: boolean;
|
|
19
|
+
title: string;
|
|
20
20
|
errorMessages: string;
|
|
21
21
|
hint: string;
|
|
22
22
|
btnSubmit: string;
|
|
@@ -681,9 +681,9 @@ declare const __VLS_base: import("vue").DefineComponent<Props, {
|
|
|
681
681
|
}>, {
|
|
682
682
|
disabled: boolean;
|
|
683
683
|
readonly: boolean;
|
|
684
|
+
parentTemplates: string | string[];
|
|
684
685
|
isolated: boolean;
|
|
685
686
|
decoration: object;
|
|
686
|
-
parentTemplates: string | string[];
|
|
687
687
|
dirtyClass: string;
|
|
688
688
|
dirtyOnCreate: boolean;
|
|
689
689
|
sanitizeDelay: number;
|
|
@@ -313,5 +313,5 @@ defineExpose({
|
|
|
313
313
|
</template>
|
|
314
314
|
|
|
315
315
|
<style>
|
|
316
|
-
.form-data-dirty:not(.v-input--error) :not(.v-chip):not(.v-chip *):not(.v-toolbar):not(.v-toolbar *){color:color-mix(in srgb,currentColor 70%,rgb(var(--v-theme-primary)))!important;text-shadow:0 0 .02em currentColor}
|
|
316
|
+
.form-data-dirty:not(.v-input--error) :not(.v-chip):not(.v-chip *):not(.v-toolbar):not(.v-toolbar *):not(.dp__main):not(.dp__main *){color:color-mix(in srgb,currentColor 70%,rgb(var(--v-theme-primary)))!important;text-shadow:0 0 .02em currentColor}
|
|
317
317
|
</style>
|
|
@@ -681,9 +681,9 @@ declare const __VLS_base: import("vue").DefineComponent<Props, {
|
|
|
681
681
|
}>, {
|
|
682
682
|
disabled: boolean;
|
|
683
683
|
readonly: boolean;
|
|
684
|
+
parentTemplates: string | string[];
|
|
684
685
|
isolated: boolean;
|
|
685
686
|
decoration: object;
|
|
686
|
-
parentTemplates: string | string[];
|
|
687
687
|
dirtyClass: string;
|
|
688
688
|
dirtyOnCreate: boolean;
|
|
689
689
|
sanitizeDelay: number;
|
|
@@ -78,10 +78,10 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
|
78
78
|
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
79
79
|
"onUpdate:modelValue"?: ((value: string | undefined) => any) | undefined;
|
|
80
80
|
}>, {
|
|
81
|
-
buttonText: string;
|
|
82
81
|
disabled: boolean;
|
|
83
82
|
maxWidth: string | number;
|
|
84
83
|
readonly: boolean;
|
|
84
|
+
buttonText: string;
|
|
85
85
|
imageFormat: ImageFormat;
|
|
86
86
|
autoStart: boolean;
|
|
87
87
|
fileOnly: boolean;
|
|
@@ -78,10 +78,10 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
|
78
78
|
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
79
79
|
"onUpdate:modelValue"?: ((value: string | undefined) => any) | undefined;
|
|
80
80
|
}>, {
|
|
81
|
-
buttonText: string;
|
|
82
81
|
disabled: boolean;
|
|
83
82
|
maxWidth: string | number;
|
|
84
83
|
readonly: boolean;
|
|
84
|
+
buttonText: string;
|
|
85
85
|
imageFormat: ImageFormat;
|
|
86
86
|
autoStart: boolean;
|
|
87
87
|
fileOnly: boolean;
|
|
@@ -22,8 +22,8 @@ type __VLS_Slots = {} & {
|
|
|
22
22
|
};
|
|
23
23
|
declare const __VLS_base: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {
|
|
24
24
|
value: string | null;
|
|
25
|
-
label: string;
|
|
26
25
|
size: "large" | "medium";
|
|
26
|
+
label: string;
|
|
27
27
|
horizontal: boolean;
|
|
28
28
|
truncate: boolean;
|
|
29
29
|
notFoundText: string;
|
|
@@ -22,8 +22,8 @@ type __VLS_Slots = {} & {
|
|
|
22
22
|
};
|
|
23
23
|
declare const __VLS_base: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {
|
|
24
24
|
value: string | null;
|
|
25
|
-
label: string;
|
|
26
25
|
size: "large" | "medium";
|
|
26
|
+
label: string;
|
|
27
27
|
horizontal: boolean;
|
|
28
28
|
truncate: boolean;
|
|
29
29
|
notFoundText: string;
|
|
@@ -74,6 +74,10 @@ usePerPagePreference(itemsPerPageInternal, {
|
|
|
74
74
|
storageKey: props.perPageStorageKey ?? props.modelName,
|
|
75
75
|
enabled: props.perPageStorageEnabled
|
|
76
76
|
});
|
|
77
|
+
const pageInternal = ref(1);
|
|
78
|
+
watch([() => props.modelName, () => props.modelBy], () => {
|
|
79
|
+
pageInternal.value = 1;
|
|
80
|
+
}, { deep: true });
|
|
77
81
|
const {
|
|
78
82
|
items,
|
|
79
83
|
itemsLength,
|
|
@@ -255,6 +259,7 @@ defineExpose({ reload, operation, items, autoRefresh, importProgress });
|
|
|
255
259
|
v-if="canServerPageable && !useVirtual"
|
|
256
260
|
v-bind="plainAttrs"
|
|
257
261
|
v-model:items-per-page="itemsPerPageInternal"
|
|
262
|
+
v-model:page="pageInternal"
|
|
258
263
|
color="primary"
|
|
259
264
|
:items="items"
|
|
260
265
|
:items-length="itemsLength"
|
|
@@ -162,6 +162,7 @@ const pageCount = computed(() => {
|
|
|
162
162
|
else return Math.ceil(itemsLength.value / Number(itemsPerPageInternal.value));
|
|
163
163
|
});
|
|
164
164
|
const currentPage = ref(1);
|
|
165
|
+
const tablePageInternal = ref(1);
|
|
165
166
|
watch([currentPage, itemsPerPageInternal, sortBy], () => {
|
|
166
167
|
if (canServerPageable.value) {
|
|
167
168
|
loadItems({
|
|
@@ -171,6 +172,10 @@ watch([currentPage, itemsPerPageInternal, sortBy], () => {
|
|
|
171
172
|
});
|
|
172
173
|
}
|
|
173
174
|
}, { immediate: true });
|
|
175
|
+
watch([() => props.modelName, () => props.modelBy], () => {
|
|
176
|
+
currentPage.value = 1;
|
|
177
|
+
tablePageInternal.value = 1;
|
|
178
|
+
}, { deep: true });
|
|
174
179
|
watch(
|
|
175
180
|
[itemsLength, computedPreferTable, () => display.name?.value],
|
|
176
181
|
([len, prefer]) => {
|
|
@@ -392,6 +397,7 @@ defineExpose({ reload, operation, autoRefresh, importProgress });
|
|
|
392
397
|
<v-data-table-server
|
|
393
398
|
v-if="canServerPageable && !useVirtual"
|
|
394
399
|
v-bind="plainAttrs"
|
|
400
|
+
v-model:page="tablePageInternal"
|
|
395
401
|
color="primary"
|
|
396
402
|
:items="items"
|
|
397
403
|
:items-length="itemsLength"
|
|
@@ -56,6 +56,20 @@ export type CacheOption = boolean | number | {
|
|
|
56
56
|
} | {
|
|
57
57
|
ttlMs: number;
|
|
58
58
|
};
|
|
59
|
+
/**
|
|
60
|
+
* Thrown by `urlBuilder` when an `['agent', ...]` url is requested but no host-agent
|
|
61
|
+
* base URL resolves. Callers get a typed, request-free failure instead of a silent
|
|
62
|
+
* misrouted call to `{WS_API}/undefined/...`.
|
|
63
|
+
*/
|
|
64
|
+
export declare class AgentNotConfiguredError extends Error {
|
|
65
|
+
constructor(message?: string);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Single source of truth for "is a host agent reachable in principle".
|
|
69
|
+
* Returns the trimmed base URL, or null when the agent is not configured.
|
|
70
|
+
* `HOST_AGENT_ENABLED=false` is a hard kill switch: it wins over any base URL.
|
|
71
|
+
*/
|
|
72
|
+
export declare function resolveAgentBase(publicConfig: Record<string, any>): string | null;
|
|
59
73
|
/**
|
|
60
74
|
* Per-call options accepted by useApi alongside Nuxt's UseFetchOptions.
|
|
61
75
|
*
|
|
@@ -8,6 +8,18 @@ import { useAuthentication } from "../bridges/authentication.js";
|
|
|
8
8
|
const DEFAULT_TTL_SECONDS_FOR_TRUE = 5 * 60;
|
|
9
9
|
const CACHE_PREFIX = "api-cache-";
|
|
10
10
|
const IDEMPOTENCY_HEADER_DEFAULT = "Idempotency-Key";
|
|
11
|
+
export class AgentNotConfiguredError extends Error {
|
|
12
|
+
constructor(message = "Host agent is not configured: set runtimeConfig.public.WS_AGENT (or WS_DEVICE), and do not set HOST_AGENT_ENABLED=false.") {
|
|
13
|
+
super(message);
|
|
14
|
+
this.name = "AgentNotConfiguredError";
|
|
15
|
+
Object.setPrototypeOf(this, AgentNotConfiguredError.prototype);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export function resolveAgentBase(publicConfig) {
|
|
19
|
+
if (publicConfig?.HOST_AGENT_ENABLED === false) return null;
|
|
20
|
+
const base = publicConfig?.WS_AGENT || publicConfig?.WS_DEVICE;
|
|
21
|
+
return base ? trimEnd(base, "/") : null;
|
|
22
|
+
}
|
|
11
23
|
let _legacyHeuristicWarned = false;
|
|
12
24
|
function warnLegacyHeuristic(value, resolvedSeconds) {
|
|
13
25
|
if (_legacyHeuristicWarned) return;
|
|
@@ -68,10 +80,13 @@ export function useApi() {
|
|
|
68
80
|
function urlBuilder(url) {
|
|
69
81
|
let returnUrl;
|
|
70
82
|
if (Array.isArray(url)) {
|
|
71
|
-
|
|
72
|
-
|
|
83
|
+
const segments = [...url];
|
|
84
|
+
if (segments[0]?.toLowerCase() === "agent") {
|
|
85
|
+
const agentBase = resolveAgentBase(config?.public ?? {});
|
|
86
|
+
if (!agentBase) throw new AgentNotConfiguredError();
|
|
87
|
+
segments[0] = agentBase;
|
|
73
88
|
}
|
|
74
|
-
returnUrl =
|
|
89
|
+
returnUrl = segments.join("/");
|
|
75
90
|
} else {
|
|
76
91
|
returnUrl = url;
|
|
77
92
|
}
|
|
@@ -165,6 +165,7 @@ export function useApiModel(props) {
|
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
167
|
watchDebounced([() => props.modelName, () => props.modelBy, () => props.modelKey], () => {
|
|
168
|
+
if (currentOptions.value) currentOptions.value = { ...currentOptions.value, page: 1 };
|
|
168
169
|
reload();
|
|
169
170
|
}, { deep: true, debounce: 500, maxWait: 500 });
|
|
170
171
|
onMounted(() => {
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useClientConfig exposes runtime client configuration and resolves environment-driven settings for feature behavior.
|
|
3
|
+
* This doc block is consumed by vue-docgen for generated API documentation.
|
|
4
|
+
*/
|
|
5
|
+
import type { Ref } from "vue";
|
|
1
6
|
/** JSON-serializable config object (backend: Map<String, Object>) */
|
|
2
7
|
export type ClientConfig = Record<string, any>;
|
|
3
8
|
export interface ClientConfigOptions {
|
|
@@ -13,3 +18,15 @@ export interface ClientConfigService {
|
|
|
13
18
|
fetchFromGraphql(): Promise<ClientConfig>;
|
|
14
19
|
}
|
|
15
20
|
export declare function createClientConfigService(opts?: ClientConfigOptions): ClientConfigService;
|
|
21
|
+
/**
|
|
22
|
+
* Access the app-wide client config provided by the `clientConfig` plugin.
|
|
23
|
+
*
|
|
24
|
+
* `config` is populated synchronously from the localStorage cache at plugin setup, then
|
|
25
|
+
* refreshed over GraphQL once the app is mounted AND an auth token exists. Apps whose
|
|
26
|
+
* `useAuthentication()` is not reactive must call `refresh()` themselves after login.
|
|
27
|
+
*/
|
|
28
|
+
export declare function useClientConfig(): {
|
|
29
|
+
config: Ref<ClientConfig>;
|
|
30
|
+
refresh: () => Promise<ClientConfig>;
|
|
31
|
+
service: ClientConfigService;
|
|
32
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import ls from "localstorage-slim";
|
|
2
2
|
import { Thumbmark } from "@thumbmarkjs/thumbmarkjs";
|
|
3
|
+
import { useNuxtApp } from "#imports";
|
|
3
4
|
import { useGraphQlOperation } from "./graphqlOperation.js";
|
|
4
5
|
import { useHostAgent } from "./hostAgent.js";
|
|
5
6
|
function isPlainObject(v) {
|
|
@@ -49,13 +50,16 @@ export function createClientConfigService(opts = {}) {
|
|
|
49
50
|
async fetchFromGraphql() {
|
|
50
51
|
const thumbmark = await thumbmarkInstance.get();
|
|
51
52
|
let computerName = thumbmark.thumbmark;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
const host = useHostAgent();
|
|
54
|
+
if (host.isConfigured() && await host.isAvailable()) {
|
|
55
|
+
try {
|
|
56
|
+
const machineInfo = await host.getMachineInfo();
|
|
57
|
+
if (machineInfo?.computerName) {
|
|
58
|
+
computerName = machineInfo.computerName;
|
|
59
|
+
}
|
|
60
|
+
} catch (err) {
|
|
61
|
+
console.debug("[client-config] machine info unavailable, using fingerprint:", err);
|
|
56
62
|
}
|
|
57
|
-
} catch (err) {
|
|
58
|
-
console.warn("[client-config] getMachineInfo() failed, fallback to fingerprint:", err);
|
|
59
63
|
}
|
|
60
64
|
try {
|
|
61
65
|
const result = await useGraphQlOperation(
|
|
@@ -77,3 +81,11 @@ export function createClientConfigService(opts = {}) {
|
|
|
77
81
|
}
|
|
78
82
|
};
|
|
79
83
|
}
|
|
84
|
+
export function useClientConfig() {
|
|
85
|
+
const nuxtApp = useNuxtApp();
|
|
86
|
+
return {
|
|
87
|
+
config: nuxtApp.$clientConfig,
|
|
88
|
+
refresh: nuxtApp.$clientConfigRefresh,
|
|
89
|
+
service: nuxtApp.$clientConfigService
|
|
90
|
+
};
|
|
91
|
+
}
|
|
@@ -162,6 +162,7 @@ export function useGraphqlModel(props) {
|
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
164
|
watchDebounced([() => props.modelName, () => props.modelBy, () => props.modelKey, canServerPageable], () => {
|
|
165
|
+
if (currentOptions.value) currentOptions.value = { ...currentOptions.value, page: 1 };
|
|
165
166
|
reload();
|
|
166
167
|
}, { deep: true, debounce: 500, maxWait: 500 });
|
|
167
168
|
onMounted(() => {
|
|
@@ -31,6 +31,20 @@ export declare const PRINT_DATA_TYPE: {
|
|
|
31
31
|
readonly Html: "Html";
|
|
32
32
|
readonly Office: "Office";
|
|
33
33
|
};
|
|
34
|
+
/**
|
|
35
|
+
* Timeout for the cheap, always-fast machine endpoints. Scanning and printing are
|
|
36
|
+
* legitimately slow and deliberately stay untimed.
|
|
37
|
+
*/
|
|
38
|
+
export declare const AGENT_TIMEOUT_MS = 2000;
|
|
39
|
+
/**
|
|
40
|
+
* Thrown by `ensureAvailable()` when a host agent is configured but does not answer.
|
|
41
|
+
* `isAvailable()` never throws this — it returns `false`.
|
|
42
|
+
*/
|
|
43
|
+
export declare class AgentUnavailableError extends Error {
|
|
44
|
+
constructor(message?: string);
|
|
45
|
+
}
|
|
46
|
+
/** Test-only hook: drop the memoized availability verdict. */
|
|
47
|
+
export declare function _resetHostAgentAvailability(): void;
|
|
34
48
|
/**
|
|
35
49
|
* =========================
|
|
36
50
|
* REST DTOs
|
|
@@ -143,6 +157,27 @@ export interface MachineInfo {
|
|
|
143
157
|
ipAddresses: string[];
|
|
144
158
|
softwareVersion: string;
|
|
145
159
|
}
|
|
160
|
+
/**
|
|
161
|
+
* Where the interactive session lives. `null` when no session was resolved.
|
|
162
|
+
*/
|
|
163
|
+
export type LoggedOnUserSource = 'console' | 'remote' | null;
|
|
164
|
+
/**
|
|
165
|
+
* Response of `GET /machine/user`.
|
|
166
|
+
*
|
|
167
|
+
* The agent runs as a service, so the process identity is NOT the person at the
|
|
168
|
+
* keyboard; this is the resolved interactive desktop user.
|
|
169
|
+
*
|
|
170
|
+
* IMPORTANT: when there is no interactive session (headless host, or the machine is
|
|
171
|
+
* sitting at the logon screen) the agent returns **empty strings**, not nulls. Branch
|
|
172
|
+
* on `isResolved`, never on the truthiness of `userName`.
|
|
173
|
+
*/
|
|
174
|
+
export interface LoggedOnUser {
|
|
175
|
+
login: string;
|
|
176
|
+
domain: string;
|
|
177
|
+
userName: string;
|
|
178
|
+
isResolved: boolean;
|
|
179
|
+
source: LoggedOnUserSource;
|
|
180
|
+
}
|
|
146
181
|
/**
|
|
147
182
|
* =========================
|
|
148
183
|
* WS protocol types (exported for useHostAgentWs)
|
|
@@ -244,6 +279,10 @@ export declare function useHostAgent(): {
|
|
|
244
279
|
readonly Html: "Html";
|
|
245
280
|
readonly Office: "Office";
|
|
246
281
|
};
|
|
282
|
+
isConfigured: () => boolean;
|
|
283
|
+
isAvailable: () => Promise<boolean>;
|
|
284
|
+
ensureAvailable: () => Promise<void>;
|
|
285
|
+
resetAvailability: () => void;
|
|
247
286
|
getSettings: (cache?: boolean | number) => Promise<HostSettings>;
|
|
248
287
|
updateSettings: (settings: HostSettings) => Promise<HostSettings>;
|
|
249
288
|
getPrinters: (cache?: boolean | number) => Promise<DeviceNameList>;
|
|
@@ -252,6 +291,7 @@ export declare function useHostAgent(): {
|
|
|
252
291
|
getIdCardInfoAndPhoto: (reader?: string) => Promise<PatientRegisterPayload>;
|
|
253
292
|
getCitizenId: (reader?: string) => Promise<CitizenIdResult>;
|
|
254
293
|
getMachineInfo: () => Promise<MachineInfo>;
|
|
294
|
+
getLoggedOnUser: () => Promise<LoggedOnUser>;
|
|
255
295
|
print: (req: PrintRequest) => Promise<PrintAcceptedResponse>;
|
|
256
296
|
scan: (req: ScanRequest) => Promise<ScanResult[]>;
|
|
257
297
|
getLogFiles: (cache?: boolean | number) => Promise<LogFileList>;
|
|
@@ -1,11 +1,56 @@
|
|
|
1
|
-
import { useApi } from "./api.js";
|
|
1
|
+
import { useApi, resolveAgentBase, AgentNotConfiguredError } from "./api.js";
|
|
2
|
+
import { useRuntimeConfig } from "#imports";
|
|
2
3
|
export const DRIVER = { Wia: "Wia", Twain: "Twain", Sane: "Sane", Escl: "Escl" };
|
|
3
4
|
export const PAPER_SOURCE = { Auto: "Auto", Flatbed: "Flatbed", Feeder: "Feeder", Duplex: "Duplex" };
|
|
4
5
|
export const BIT_DEPTH = { Color: "Color", Grayscale: "Grayscale", BlackAndWhite: "BlackAndWhite" };
|
|
5
6
|
export const PRINT_DATA_TYPE = { Pdf: "Pdf", Image: "Image", Text: "Text", Html: "Html", Office: "Office" };
|
|
7
|
+
export const AGENT_TIMEOUT_MS = 2e3;
|
|
8
|
+
const AGENT_PROBE_OPTIONS = { retry: 0, timeout: AGENT_TIMEOUT_MS };
|
|
9
|
+
export class AgentUnavailableError extends Error {
|
|
10
|
+
constructor(message = "Host agent is configured but not reachable.") {
|
|
11
|
+
super(message);
|
|
12
|
+
this.name = "AgentUnavailableError";
|
|
13
|
+
Object.setPrototypeOf(this, AgentUnavailableError.prototype);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const PROBE_TTL_MS_DEFAULT = 6e4;
|
|
17
|
+
let probeCache = null;
|
|
18
|
+
let probeInFlight = null;
|
|
19
|
+
export function _resetHostAgentAvailability() {
|
|
20
|
+
probeCache = null;
|
|
21
|
+
probeInFlight = null;
|
|
22
|
+
}
|
|
6
23
|
export function useHostAgent() {
|
|
7
24
|
const api = useApi();
|
|
8
25
|
const base = ["agent"];
|
|
26
|
+
const config = useRuntimeConfig();
|
|
27
|
+
function isConfigured() {
|
|
28
|
+
return resolveAgentBase(config?.public ?? {}) !== null;
|
|
29
|
+
}
|
|
30
|
+
function isAvailable() {
|
|
31
|
+
if (!isConfigured()) return Promise.resolve(false);
|
|
32
|
+
const now = Date.now();
|
|
33
|
+
if (probeCache && probeCache.expiresAt > now) return Promise.resolve(probeCache.value);
|
|
34
|
+
if (probeInFlight) return probeInFlight;
|
|
35
|
+
const ttl = Number(config?.public?.HOST_AGENT_PROBE_TTL_MS ?? PROBE_TTL_MS_DEFAULT);
|
|
36
|
+
probeInFlight = api.getPromise([...base, "machine/info"], void 0, void 0, AGENT_PROBE_OPTIONS).then(() => {
|
|
37
|
+
probeCache = { value: true, expiresAt: Number.POSITIVE_INFINITY };
|
|
38
|
+
return true;
|
|
39
|
+
}).catch(() => {
|
|
40
|
+
probeCache = { value: false, expiresAt: Date.now() + ttl };
|
|
41
|
+
return false;
|
|
42
|
+
}).finally(() => {
|
|
43
|
+
probeInFlight = null;
|
|
44
|
+
});
|
|
45
|
+
return probeInFlight;
|
|
46
|
+
}
|
|
47
|
+
async function ensureAvailable() {
|
|
48
|
+
if (!isConfigured()) throw new AgentNotConfiguredError();
|
|
49
|
+
if (!await isAvailable()) throw new AgentUnavailableError();
|
|
50
|
+
}
|
|
51
|
+
function resetAvailability() {
|
|
52
|
+
_resetHostAgentAvailability();
|
|
53
|
+
}
|
|
9
54
|
function getSettings(cache = false) {
|
|
10
55
|
return api.getPromise([...base, "api/settings"], void 0, void 0, void 0, cache);
|
|
11
56
|
}
|
|
@@ -32,7 +77,10 @@ export function useHostAgent() {
|
|
|
32
77
|
return api.getPromise([...base, "idcard/citizenId"], void 0, reader ? { reader } : void 0);
|
|
33
78
|
}
|
|
34
79
|
function getMachineInfo() {
|
|
35
|
-
return api.getPromise([...base, "machine/info"]);
|
|
80
|
+
return api.getPromise([...base, "machine/info"], void 0, void 0, AGENT_PROBE_OPTIONS);
|
|
81
|
+
}
|
|
82
|
+
function getLoggedOnUser() {
|
|
83
|
+
return api.getPromise([...base, "machine/user"], void 0, void 0, AGENT_PROBE_OPTIONS);
|
|
36
84
|
}
|
|
37
85
|
function print(req) {
|
|
38
86
|
return api.postPromise([...base, "print"], req);
|
|
@@ -55,6 +103,11 @@ export function useHostAgent() {
|
|
|
55
103
|
PAPER_SOURCE,
|
|
56
104
|
BIT_DEPTH,
|
|
57
105
|
PRINT_DATA_TYPE,
|
|
106
|
+
// availability
|
|
107
|
+
isConfigured,
|
|
108
|
+
isAvailable,
|
|
109
|
+
ensureAvailable,
|
|
110
|
+
resetAvailability,
|
|
58
111
|
// REST
|
|
59
112
|
getSettings,
|
|
60
113
|
updateSettings,
|
|
@@ -64,6 +117,7 @@ export function useHostAgent() {
|
|
|
64
117
|
getIdCardInfoAndPhoto,
|
|
65
118
|
getCitizenId,
|
|
66
119
|
getMachineInfo,
|
|
120
|
+
getLoggedOnUser,
|
|
67
121
|
print,
|
|
68
122
|
scan,
|
|
69
123
|
getLogFiles,
|
|
@@ -18,18 +18,18 @@ interface CalendarProps {
|
|
|
18
18
|
mode: 'dayGridMonth' | 'timeGridDay';
|
|
19
19
|
}
|
|
20
20
|
declare const __VLS_export: import("vue").DefineComponent<CalendarProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
21
|
-
select: (...args: any[]) => void;
|
|
22
21
|
dialog: (...args: any[]) => void;
|
|
22
|
+
select: (...args: any[]) => void;
|
|
23
23
|
}, string, import("vue").PublicProps, Readonly<CalendarProps> & Readonly<{
|
|
24
|
-
onSelect?: ((...args: any[]) => any) | undefined;
|
|
25
24
|
onDialog?: ((...args: any[]) => any) | undefined;
|
|
25
|
+
onSelect?: ((...args: any[]) => any) | undefined;
|
|
26
26
|
}>, {
|
|
27
|
+
height: string | number;
|
|
28
|
+
mode: "dayGridMonth" | "timeGridDay";
|
|
27
29
|
locale: "th" | "en";
|
|
28
30
|
toolBarLeft: string;
|
|
29
31
|
toolBarCenter: string;
|
|
30
32
|
toolBarRight: string;
|
|
31
|
-
height: string | number;
|
|
32
|
-
mode: "dayGridMonth" | "timeGridDay";
|
|
33
33
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
34
34
|
declare const _default: typeof __VLS_export;
|
|
35
35
|
export default _default;
|
|
@@ -18,18 +18,18 @@ interface CalendarProps {
|
|
|
18
18
|
mode: 'dayGridMonth' | 'timeGridDay';
|
|
19
19
|
}
|
|
20
20
|
declare const __VLS_export: import("vue").DefineComponent<CalendarProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
21
|
-
select: (...args: any[]) => void;
|
|
22
21
|
dialog: (...args: any[]) => void;
|
|
22
|
+
select: (...args: any[]) => void;
|
|
23
23
|
}, string, import("vue").PublicProps, Readonly<CalendarProps> & Readonly<{
|
|
24
|
-
onSelect?: ((...args: any[]) => any) | undefined;
|
|
25
24
|
onDialog?: ((...args: any[]) => any) | undefined;
|
|
25
|
+
onSelect?: ((...args: any[]) => any) | undefined;
|
|
26
26
|
}>, {
|
|
27
|
+
height: string | number;
|
|
28
|
+
mode: "dayGridMonth" | "timeGridDay";
|
|
27
29
|
locale: "th" | "en";
|
|
28
30
|
toolBarLeft: string;
|
|
29
31
|
toolBarCenter: string;
|
|
30
32
|
toolBarRight: string;
|
|
31
|
-
height: string | number;
|
|
32
|
-
mode: "dayGridMonth" | "timeGridDay";
|
|
33
33
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
34
34
|
declare const _default: typeof __VLS_export;
|
|
35
35
|
export default _default;
|
|
@@ -1,22 +1,35 @@
|
|
|
1
|
-
import { createClientConfigService } from "../composables/clientConfig.js";
|
|
2
1
|
import { defineNuxtPlugin } from "nuxt/app";
|
|
3
|
-
import { ref } from "vue";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import { ref, watch } from "vue";
|
|
3
|
+
import { createClientConfigService } from "../composables/clientConfig.js";
|
|
4
|
+
import { useAuthentication } from "../bridges/authentication.js";
|
|
5
|
+
function readToken() {
|
|
6
|
+
const auth = useAuthentication();
|
|
7
|
+
return auth?.keycloak?.token || auth?.token;
|
|
8
|
+
}
|
|
9
|
+
export default defineNuxtPlugin((nuxtApp) => {
|
|
10
|
+
const clientConfigService = createClientConfigService({ storageKey: "client_config" });
|
|
8
11
|
const clientConfig = ref(clientConfigService.get() ?? {});
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const loaded = await clientConfigService.load();
|
|
12
|
-
clientConfig.value = loaded ?? {};
|
|
12
|
+
const refresh = async () => {
|
|
13
|
+
clientConfig.value = await clientConfigService.load() ?? {};
|
|
13
14
|
return clientConfig.value;
|
|
15
|
+
};
|
|
16
|
+
nuxtApp.provide("clientConfig", clientConfig);
|
|
17
|
+
nuxtApp.provide("clientConfigService", clientConfigService);
|
|
18
|
+
nuxtApp.provide("clientConfigRefresh", refresh);
|
|
19
|
+
const load = () => {
|
|
20
|
+
void refresh().catch((err) => {
|
|
21
|
+
console.debug("[client-config] deferred load failed:", err);
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
nuxtApp.hook("app:mounted", () => {
|
|
25
|
+
if (readToken()) {
|
|
26
|
+
load();
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const stop = watch(readToken, (token) => {
|
|
30
|
+
if (!token) return;
|
|
31
|
+
stop();
|
|
32
|
+
load();
|
|
33
|
+
});
|
|
14
34
|
});
|
|
15
|
-
try {
|
|
16
|
-
const loaded = await clientConfigService.load();
|
|
17
|
-
clientConfig.value = loaded ?? {};
|
|
18
|
-
} catch (e) {
|
|
19
|
-
console.warn("[client-config] init load failed:", e?.message || e);
|
|
20
|
-
clientConfig.value = clientConfigService.get() ?? {};
|
|
21
|
-
}
|
|
22
35
|
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// Self-contained type template surfaced through `#build/types/api` via
|
|
2
|
+
// `addTypeTemplate` in src/module.ts (mirrors runtime/types/graphqlOperation.d.ts).
|
|
3
|
+
//
|
|
4
|
+
// Why a dedicated template instead of relying on `#imports`:
|
|
5
|
+
// `ApiIdempotencyOption` / `ApiFetchOptions` are **type-only** exports of
|
|
6
|
+
// src/runtime/composables/api.ts. In the playground `#imports` resolves them
|
|
7
|
+
// because unimport scans the TypeScript source, but a consumer installing the
|
|
8
|
+
// built package scans the compiled `.js` where interfaces are erased — so the
|
|
9
|
+
// types never land in the consumer's `#imports` and the codegen-generated
|
|
10
|
+
// `graphqlObject.ts` (`import type { ApiIdempotencyOption } from ...`) fails
|
|
11
|
+
// vue-tsc with TS2305 (see issue #253).
|
|
12
|
+
//
|
|
13
|
+
// This file must stay **self-contained** (no relative imports of ../composables/*)
|
|
14
|
+
// because type templates are copied verbatim into `.nuxt/types/`, where a relative
|
|
15
|
+
// path back into `src/` would not resolve. Keep these declarations in sync with
|
|
16
|
+
// src/runtime/composables/api.ts — that composable remains the runtime source of truth.
|
|
17
|
+
import type { UseFetchOptions } from 'nuxt/app'
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Per-call options accepted by useApi alongside Nuxt's UseFetchOptions.
|
|
21
|
+
*
|
|
22
|
+
* `idempotent: false` skips Idempotency-Key header injection for this single call.
|
|
23
|
+
* Default is `true`. See the useApi() docblock for the full idempotency contract.
|
|
24
|
+
*/
|
|
25
|
+
export interface ApiIdempotencyOption {
|
|
26
|
+
idempotent?: boolean
|
|
27
|
+
/**
|
|
28
|
+
* Optional discriminator folded as a trailing component into the
|
|
29
|
+
* Idempotency-Key hash: SHA-256(`<second>|<username>|<body>|<salt>`).
|
|
30
|
+
* Lets legitimately-identical payloads (e.g. duplicate bulk-import rows)
|
|
31
|
+
* resolve to distinct keys without weakening dedup elsewhere.
|
|
32
|
+
*/
|
|
33
|
+
idempotencySalt?: string | number
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type ApiFetchOptions = UseFetchOptions<unknown> & ApiIdempotencyOption
|
|
@@ -1,13 +1,26 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Ref } from "vue";
|
|
2
|
+
import type { ClientConfig, ClientConfigService } from "../composables/clientConfig";
|
|
2
3
|
|
|
3
4
|
declare module "#app" {
|
|
4
5
|
interface NuxtApp {
|
|
5
|
-
|
|
6
|
+
/** Reactive app-wide client config. Hydrated from localStorage, refreshed after auth. */
|
|
7
|
+
$clientConfig: Ref<ClientConfig>;
|
|
8
|
+
/** The underlying service: get / set / clear / load / fetchFromGraphql. */
|
|
6
9
|
$clientConfigService: ClientConfigService;
|
|
10
|
+
/** Force a GraphQL reload. Call this after login if your auth state is not reactive. */
|
|
11
|
+
$clientConfigRefresh: () => Promise<ClientConfig>;
|
|
7
12
|
}
|
|
13
|
+
}
|
|
8
14
|
|
|
9
|
-
|
|
10
|
-
|
|
15
|
+
declare module "vue" {
|
|
16
|
+
interface ComponentCustomProperties {
|
|
17
|
+
/** Reactive app-wide client config. Hydrated from localStorage, refreshed after auth. */
|
|
18
|
+
$clientConfig: Ref<ClientConfig>;
|
|
19
|
+
/** The underlying service: get / set / clear / load / fetchFromGraphql. */
|
|
11
20
|
$clientConfigService: ClientConfigService;
|
|
21
|
+
/** Force a GraphQL reload. Call this after login if your auth state is not reactive. */
|
|
22
|
+
$clientConfigRefresh: () => Promise<ClientConfig>;
|
|
12
23
|
}
|
|
13
24
|
}
|
|
25
|
+
|
|
26
|
+
export {};
|
package/package.json
CHANGED
|
@@ -104,7 +104,7 @@ module.exports = {
|
|
|
104
104
|
return `
|
|
105
105
|
import * as graphQlClass from "~/types/graphql"
|
|
106
106
|
import { useGraphQlOperation } from "#imports";
|
|
107
|
-
import type { ApiIdempotencyOption } from "#
|
|
107
|
+
import type { ApiIdempotencyOption } from "#build/types/api";
|
|
108
108
|
import type {
|
|
109
109
|
graphqlInputObject,
|
|
110
110
|
graphqlOperationObject,
|