tantee-nuxt-commons 0.0.173 → 0.0.175

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.
Files changed (35) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/module.mjs +9 -1
  3. package/dist/runtime/components/Alert.vue +1 -0
  4. package/dist/runtime/components/device/IdCardButton.vue +83 -0
  5. package/dist/runtime/components/device/IdCardWebSocket.vue +195 -0
  6. package/dist/runtime/components/device/Scanner.vue +338 -0
  7. package/dist/runtime/components/form/ActionPad.vue +1 -1
  8. package/dist/runtime/components/form/Dialog.vue +1 -1
  9. package/dist/runtime/components/form/EditPad.vue +1 -1
  10. package/dist/runtime/components/form/Iterator.vue +0 -2
  11. package/dist/runtime/components/form/Pad.vue +71 -2
  12. package/dist/runtime/components/form/Table.vue +4 -1
  13. package/dist/runtime/components/form/TableData.vue +4 -1
  14. package/dist/runtime/components/label/DateCount.vue +117 -13
  15. package/dist/runtime/components/model/Autocomplete.vue +4 -1
  16. package/dist/runtime/components/model/Combobox.vue +4 -1
  17. package/dist/runtime/components/model/Select.vue +4 -1
  18. package/dist/runtime/components/pdf/View.vue +42 -32
  19. package/dist/runtime/composables/api.d.ts +4 -4
  20. package/dist/runtime/composables/api.js +33 -21
  21. package/dist/runtime/composables/clientConfig.d.ts +15 -0
  22. package/dist/runtime/composables/clientConfig.js +79 -0
  23. package/dist/runtime/composables/document/templateFormTable.js +4 -1
  24. package/dist/runtime/composables/hostAgent.d.ts +260 -0
  25. package/dist/runtime/composables/hostAgent.js +74 -0
  26. package/dist/runtime/composables/hostAgentWs.d.ts +272 -0
  27. package/dist/runtime/composables/hostAgentWs.js +145 -0
  28. package/dist/runtime/composables/localStorageModel.d.ts +38 -0
  29. package/dist/runtime/composables/localStorageModel.js +88 -0
  30. package/dist/runtime/plugins/clientConfig.d.ts +2 -0
  31. package/dist/runtime/plugins/clientConfig.js +22 -0
  32. package/dist/runtime/plugins/default.d.ts +2 -0
  33. package/dist/runtime/plugins/default.js +50 -0
  34. package/dist/runtime/types/clientConfig.d.ts +13 -0
  35. package/package.json +3 -2
@@ -0,0 +1,79 @@
1
+ import ls from "localstorage-slim";
2
+ import { Thumbmark } from "@thumbmarkjs/thumbmarkjs";
3
+ import { useGraphQlOperation } from "./graphqlOperation.js";
4
+ import { useHostAgent } from "./hostAgent.js";
5
+ function isPlainObject(v) {
6
+ return v !== null && typeof v === "object" && !Array.isArray(v);
7
+ }
8
+ function readConfig(storageKey) {
9
+ try {
10
+ const v = ls.get(storageKey);
11
+ if (!v || !isPlainObject(v)) return null;
12
+ return v;
13
+ } catch {
14
+ return null;
15
+ }
16
+ }
17
+ function writeConfig(storageKey, cfg) {
18
+ ls.set(storageKey, cfg);
19
+ }
20
+ function clearConfig(storageKey) {
21
+ ls.remove(storageKey);
22
+ }
23
+ export function createClientConfigService(opts = {}) {
24
+ const storageKey = opts.storageKey ?? "client_config";
25
+ const thumbmarkInstance = new Thumbmark();
26
+ return {
27
+ get() {
28
+ return readConfig(storageKey);
29
+ },
30
+ set(cfg) {
31
+ if (!isPlainObject(cfg)) {
32
+ throw new Error("ClientConfig must be a JSON-serializable object.");
33
+ }
34
+ JSON.stringify(cfg);
35
+ writeConfig(storageKey, cfg);
36
+ },
37
+ clear() {
38
+ clearConfig(storageKey);
39
+ },
40
+ async load() {
41
+ try {
42
+ const cfg = await this.fetchFromGraphql();
43
+ this.set(cfg);
44
+ return cfg;
45
+ } catch {
46
+ return this.get();
47
+ }
48
+ },
49
+ async fetchFromGraphql() {
50
+ const thumbmark = await thumbmarkInstance.get();
51
+ let computerName = thumbmark.thumbmark;
52
+ try {
53
+ const machineInfo = await useHostAgent().getMachineInfo();
54
+ if (machineInfo?.computerName) {
55
+ computerName = machineInfo.computerName;
56
+ }
57
+ } catch (err) {
58
+ console.warn("[client-config] getMachineInfo() failed, fallback to fingerprint:", err);
59
+ }
60
+ try {
61
+ const result = await useGraphQlOperation(
62
+ "Query",
63
+ "clientConfigByComputerNameAndFingerprint",
64
+ ["*"],
65
+ {
66
+ computerName,
67
+ fingerprint: thumbmark.thumbmark
68
+ },
69
+ false
70
+ );
71
+ if (!result || !result.configuration) return {};
72
+ return result.configuration;
73
+ } catch (err) {
74
+ console.warn("[client-config] fetching config failed:", err);
75
+ return {};
76
+ }
77
+ }
78
+ };
79
+ }
@@ -34,13 +34,16 @@ function guessWidth(width) {
34
34
  export function processTemplateFormTable(item, parentTemplates, dataVariable) {
35
35
  let tableOptions = Object.assign({ title: item.inputLabel || "", formTemplate: "" }, item.inputOptions);
36
36
  let tableHeader = tableOptions.headers || [];
37
- if (!tableHeader.some((h) => h.key === "action")) tableHeader.push({ title: "Action", key: "action", width: "100px" });
38
37
  let tableItemTemplate = "";
39
38
  tableHeader.forEach((h) => {
40
39
  if (h.template) {
41
40
  tableItemTemplate += `\r
42
41
  <template #item.${h.key}="props">${h.template}</template>`;
42
+ } else {
43
+ tableItemTemplate += `\r
44
+ <template #item.${h.key}="props">{{autoSanitizedDisplay(props.item.${h.key})}}</template>`;
43
45
  }
44
46
  });
47
+ if (!tableHeader.some((h) => h.key === "action")) tableHeader.push({ title: "Action", key: "action", width: "100px" });
45
48
  return processDefaultTemplate(item, `<template #form="{data,rules}">${useDocumentTemplate(tableOptions.formTemplate)}</template>${tableItemTemplate}`, `title="${tableOptions.title}" :headers='${escapeObjectForInlineBinding(tableHeader)}'`, void 0, dataVariable);
46
49
  }
@@ -0,0 +1,260 @@
1
+ /**
2
+ * =========================
3
+ * Enums (STRING enums)
4
+ * =========================
5
+ */
6
+ export type Driver = 'Wia' | 'Twain' | 'Sane' | 'Escl';
7
+ export type PaperSource = 'Auto' | 'Flatbed' | 'Feeder' | 'Duplex';
8
+ export type BitDepth = 'Color' | 'Grayscale' | 'BlackAndWhite';
9
+ export type PrintDataType = 'Pdf' | 'Image' | 'Text' | 'Html' | 'Office';
10
+ export declare const DRIVER: {
11
+ readonly Wia: "Wia";
12
+ readonly Twain: "Twain";
13
+ readonly Sane: "Sane";
14
+ readonly Escl: "Escl";
15
+ };
16
+ export declare const PAPER_SOURCE: {
17
+ readonly Auto: "Auto";
18
+ readonly Flatbed: "Flatbed";
19
+ readonly Feeder: "Feeder";
20
+ readonly Duplex: "Duplex";
21
+ };
22
+ export declare const BIT_DEPTH: {
23
+ readonly Color: "Color";
24
+ readonly Grayscale: "Grayscale";
25
+ readonly BlackAndWhite: "BlackAndWhite";
26
+ };
27
+ export declare const PRINT_DATA_TYPE: {
28
+ readonly Pdf: "Pdf";
29
+ readonly Image: "Image";
30
+ readonly Text: "Text";
31
+ readonly Html: "Html";
32
+ readonly Office: "Office";
33
+ };
34
+ /**
35
+ * =========================
36
+ * REST DTOs
37
+ * =========================
38
+ */
39
+ export interface HostSettings {
40
+ printerA4?: string | null;
41
+ printerA5?: string | null;
42
+ defaultScanner?: string | null;
43
+ dpi?: number;
44
+ colorMode?: string | null;
45
+ pageSize?: string | null;
46
+ duplex?: boolean;
47
+ chromiumExecutablePath?: string | null;
48
+ }
49
+ export interface PrintRequest {
50
+ printData: string;
51
+ dataType: PrintDataType;
52
+ paperSize?: string | null;
53
+ printerName?: string | null;
54
+ copies?: number;
55
+ fileName?: string | null;
56
+ }
57
+ export interface PrintAcceptedResponse {
58
+ status: 'queued' | string;
59
+ printerName: string;
60
+ /** server returns DataType as string (effective.DataType.ToString()) */
61
+ DataType: PrintDataType | string;
62
+ paperSize?: string | null;
63
+ copies: number;
64
+ }
65
+ export interface ScanRequest {
66
+ deviceName?: string | null;
67
+ driver?: Driver | null;
68
+ paperSource?: PaperSource;
69
+ pageSize?: string | null;
70
+ dpi: number;
71
+ bitDepth?: BitDepth;
72
+ quality?: number;
73
+ maxQuality?: boolean;
74
+ autoDeskew?: boolean;
75
+ excludeBlankPages?: boolean;
76
+ brightness?: number;
77
+ contrast?: number;
78
+ }
79
+ export interface ScanResult {
80
+ base64String: string;
81
+ }
82
+ export interface ProblemDetails {
83
+ type?: string | null;
84
+ title?: string | null;
85
+ status?: number | null;
86
+ detail?: string | null;
87
+ instance?: string | null;
88
+ [k: string]: any;
89
+ }
90
+ export type DeviceNameList = string[];
91
+ export type LogFileList = string[];
92
+ /**
93
+ * =========================
94
+ * IDCardController result types
95
+ * =========================
96
+ */
97
+ export type JsonMeta = unknown;
98
+ export interface PatientRegisterInput {
99
+ citizenId?: string | null;
100
+ citizenIdVerified: boolean;
101
+ dob?: string | null;
102
+ dobPrecision?: 'yearMonthDay' | 'yearMonth' | 'year' | string;
103
+ gender?: string | null;
104
+ meta?: JsonMeta | null;
105
+ }
106
+ export interface PatientNameRegisterInput {
107
+ nameType: string;
108
+ prefix?: string | null;
109
+ firstName: string;
110
+ middleName?: string | null;
111
+ lastName?: string | null;
112
+ suffix?: string | null;
113
+ }
114
+ export interface PatientAddressRegisterInput {
115
+ mrn?: string | null;
116
+ addressType: string;
117
+ text: string;
118
+ place?: string | null;
119
+ villageNo?: string | null;
120
+ alleyWay?: string | null;
121
+ alley?: string | null;
122
+ street?: string | null;
123
+ subDistrictCode?: string | null;
124
+ districtCode?: string | null;
125
+ provinceCode?: string | null;
126
+ }
127
+ export interface PatientPhotoRegisterInput {
128
+ photoSource?: string | null;
129
+ base64String: string;
130
+ }
131
+ export interface PatientRegisterPayload {
132
+ patient: PatientRegisterInput;
133
+ patientNames?: PatientNameRegisterInput[] | null;
134
+ patientAddresses?: PatientAddressRegisterInput[] | null;
135
+ patientPhotos?: PatientPhotoRegisterInput[] | null;
136
+ }
137
+ export interface CitizenIdResult {
138
+ CitizenId?: string | null;
139
+ }
140
+ export interface MachineInfo {
141
+ computerName: string;
142
+ userName: string;
143
+ ipAddresses: string[];
144
+ softwareVersion: string;
145
+ }
146
+ /**
147
+ * =========================
148
+ * WS protocol types (exported for useHostAgentWs)
149
+ * =========================
150
+ */
151
+ export type IdCardWsClientMessage = {
152
+ action: 'subscribe';
153
+ reader?: string | null;
154
+ withPhoto?: boolean;
155
+ } | {
156
+ action: 'ping';
157
+ } | {
158
+ action: 'switchReader';
159
+ reader?: string | null;
160
+ } | {
161
+ action: 'unsubscribe';
162
+ } | {
163
+ action: string;
164
+ [k: string]: any;
165
+ };
166
+ export type IdCardWsServerMessage = {
167
+ type: 'monitor.subscribed';
168
+ ok: boolean;
169
+ reader?: string | null;
170
+ withPhoto?: boolean;
171
+ } | {
172
+ type: 'monitor.started';
173
+ reader?: string | null;
174
+ } | {
175
+ type: 'monitor.switchAck';
176
+ ok: boolean;
177
+ reader?: string | null;
178
+ } | {
179
+ type: 'monitor.switched';
180
+ reader?: string | null;
181
+ } | {
182
+ type: 'monitor.unsubscribed';
183
+ ok: boolean;
184
+ } | {
185
+ type: 'pong';
186
+ ts?: string;
187
+ } | {
188
+ type: 'card.inserted';
189
+ payload: PatientRegisterPayload;
190
+ } | {
191
+ type: 'card.removed';
192
+ } | {
193
+ type: 'card.error';
194
+ message?: string;
195
+ } | {
196
+ type: 'error';
197
+ code?: string;
198
+ message?: string;
199
+ } | {
200
+ type: string;
201
+ [k: string]: any;
202
+ };
203
+ export type IdCardWsEvent = {
204
+ type: 'open';
205
+ } | {
206
+ type: 'close';
207
+ code?: number;
208
+ reason?: string;
209
+ } | {
210
+ type: 'error';
211
+ error?: any;
212
+ } | {
213
+ type: 'message';
214
+ data: IdCardWsServerMessage;
215
+ raw: MessageEvent;
216
+ };
217
+ /**
218
+ * =========================
219
+ * Main REST composable (no WS, no lifecycle hooks)
220
+ * =========================
221
+ */
222
+ export declare function useHostAgent(): {
223
+ DRIVER: {
224
+ readonly Wia: "Wia";
225
+ readonly Twain: "Twain";
226
+ readonly Sane: "Sane";
227
+ readonly Escl: "Escl";
228
+ };
229
+ PAPER_SOURCE: {
230
+ readonly Auto: "Auto";
231
+ readonly Flatbed: "Flatbed";
232
+ readonly Feeder: "Feeder";
233
+ readonly Duplex: "Duplex";
234
+ };
235
+ BIT_DEPTH: {
236
+ readonly Color: "Color";
237
+ readonly Grayscale: "Grayscale";
238
+ readonly BlackAndWhite: "BlackAndWhite";
239
+ };
240
+ PRINT_DATA_TYPE: {
241
+ readonly Pdf: "Pdf";
242
+ readonly Image: "Image";
243
+ readonly Text: "Text";
244
+ readonly Html: "Html";
245
+ readonly Office: "Office";
246
+ };
247
+ getSettings: (cache?: boolean | number) => Promise<HostSettings>;
248
+ updateSettings: (settings: HostSettings) => Promise<HostSettings>;
249
+ getPrinters: (cache?: boolean | number) => Promise<DeviceNameList>;
250
+ getScanners: (cache?: boolean | number) => Promise<DeviceNameList>;
251
+ getIdCardInfo: (reader?: string) => Promise<PatientRegisterPayload>;
252
+ getIdCardInfoAndPhoto: (reader?: string) => Promise<PatientRegisterPayload>;
253
+ getCitizenId: (reader?: string) => Promise<CitizenIdResult>;
254
+ getMachineInfo: () => Promise<MachineInfo>;
255
+ print: (req: PrintRequest) => Promise<PrintAcceptedResponse>;
256
+ scan: (req: ScanRequest) => Promise<ScanResult[]>;
257
+ getLogFiles: (cache?: boolean | number) => Promise<LogFileList>;
258
+ tailLog: (file: string, lines?: number) => Promise<unknown>;
259
+ isProblemDetails: (x: any) => x is ProblemDetails;
260
+ };
@@ -0,0 +1,74 @@
1
+ import { useApi } from "./api.js";
2
+ export const DRIVER = { Wia: "Wia", Twain: "Twain", Sane: "Sane", Escl: "Escl" };
3
+ export const PAPER_SOURCE = { Auto: "Auto", Flatbed: "Flatbed", Feeder: "Feeder", Duplex: "Duplex" };
4
+ export const BIT_DEPTH = { Color: "Color", Grayscale: "Grayscale", BlackAndWhite: "BlackAndWhite" };
5
+ export const PRINT_DATA_TYPE = { Pdf: "Pdf", Image: "Image", Text: "Text", Html: "Html", Office: "Office" };
6
+ export function useHostAgent() {
7
+ const api = useApi();
8
+ const base = ["agent"];
9
+ function getSettings(cache = false) {
10
+ return api.getPromise([...base, "api/settings"], void 0, void 0, void 0, cache);
11
+ }
12
+ function updateSettings(settings) {
13
+ return api.postPromise([...base, "api/settings"], settings);
14
+ }
15
+ function getPrinters(cache = false) {
16
+ return api.getPromise([...base, "api/devices/printers"], void 0, void 0, void 0, cache);
17
+ }
18
+ function getScanners(cache = false) {
19
+ return api.getPromise([...base, "api/devices/scanners"], void 0, void 0, void 0, cache);
20
+ }
21
+ function getIdCardInfo(reader) {
22
+ return api.getPromise([...base, "idcard/info"], void 0, reader ? { reader } : void 0);
23
+ }
24
+ function getIdCardInfoAndPhoto(reader) {
25
+ return api.getPromise(
26
+ [...base, "idcard/infoAndPhoto"],
27
+ void 0,
28
+ reader ? { reader } : void 0
29
+ );
30
+ }
31
+ function getCitizenId(reader) {
32
+ return api.getPromise([...base, "idcard/citizenId"], void 0, reader ? { reader } : void 0);
33
+ }
34
+ function getMachineInfo() {
35
+ return api.getPromise([...base, "machine/info"]);
36
+ }
37
+ function print(req) {
38
+ return api.postPromise([...base, "print"], req);
39
+ }
40
+ function scan(req) {
41
+ return api.postPromise([...base, "scan"], req);
42
+ }
43
+ function getLogFiles(cache = false) {
44
+ return api.getPromise([...base, "api/logs/files"], void 0, void 0, void 0, cache);
45
+ }
46
+ function tailLog(file, lines = 500) {
47
+ return api.getPromise([...base, "api/logs/tail"], void 0, { file, lines });
48
+ }
49
+ function isProblemDetails(x) {
50
+ return !!x && typeof x === "object" && ("title" in x || "status" in x || "detail" in x);
51
+ }
52
+ return {
53
+ // enums/constants
54
+ DRIVER,
55
+ PAPER_SOURCE,
56
+ BIT_DEPTH,
57
+ PRINT_DATA_TYPE,
58
+ // REST
59
+ getSettings,
60
+ updateSettings,
61
+ getPrinters,
62
+ getScanners,
63
+ getIdCardInfo,
64
+ getIdCardInfoAndPhoto,
65
+ getCitizenId,
66
+ getMachineInfo,
67
+ print,
68
+ scan,
69
+ getLogFiles,
70
+ tailLog,
71
+ // util
72
+ isProblemDetails
73
+ };
74
+ }