@viengut/vgq-sdk 0.2.0 → 0.3.0
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/client.d.ts +6 -0
- package/dist/client.js +12 -0
- package/dist/session.d.ts +7 -2
- package/dist/session.js +8 -1
- package/dist/types.d.ts +2 -0
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -30,6 +30,12 @@ export declare class VgqClient {
|
|
|
30
30
|
/** Tải một Form Version bất biến (Response luôn gắn đúng version đã bắt đầu). */
|
|
31
31
|
getFormVersion(id: string): Promise<FormVersion>;
|
|
32
32
|
createResponse(publicationKey: string, options?: StartResponseOptions): Promise<ResponseDto>;
|
|
33
|
+
/**
|
|
34
|
+
* Bắt đầu Response xem thử trên bản Draft của Form (trang demo cổng bệnh
|
|
35
|
+
* nhân). Server chụp Draft vào shadow snapshot version và XOÁ Response
|
|
36
|
+
* preview cũ của Form — mỗi Form chỉ giữ một bản thử.
|
|
37
|
+
*/
|
|
38
|
+
createPreviewResponse(formId: string, options?: StartResponseOptions): Promise<ResponseDto>;
|
|
33
39
|
getInvitation(id: string): Promise<InvitationDto>;
|
|
34
40
|
/** Bắt đầu (hoặc mở lại) Response duy nhất của một Invitation. */
|
|
35
41
|
startInvitationResponse(invitationId: string): Promise<ResponseDto>;
|
package/dist/client.js
CHANGED
|
@@ -40,6 +40,18 @@ export class VgqClient {
|
|
|
40
40
|
care_context_ref: options.careContextRef ?? null,
|
|
41
41
|
}, headers);
|
|
42
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Bắt đầu Response xem thử trên bản Draft của Form (trang demo cổng bệnh
|
|
45
|
+
* nhân). Server chụp Draft vào shadow snapshot version và XOÁ Response
|
|
46
|
+
* preview cũ của Form — mỗi Form chỉ giữ một bản thử.
|
|
47
|
+
*/
|
|
48
|
+
createPreviewResponse(formId, options = {}) {
|
|
49
|
+
return this.request('POST', `/api/forms/${encodeURIComponent(formId)}/preview-responses`, {
|
|
50
|
+
subject_ref: options.subjectRef ?? null,
|
|
51
|
+
respondent_ref: options.respondentRef ?? null,
|
|
52
|
+
care_context_ref: options.careContextRef ?? null,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
43
55
|
getInvitation(id) {
|
|
44
56
|
return this.request('GET', `/api/invitations/${encodeURIComponent(id)}`);
|
|
45
57
|
}
|
package/dist/session.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { VgqClient } from './client.js';
|
|
|
2
2
|
import type { ActiveState, CompletionResult } from './engine.js';
|
|
3
3
|
import type { FormDefinition, JsonValue, ResponseDto, ResponseValues } from './types.js';
|
|
4
4
|
/** Phần VgqClient mà ResponseSession cần — thu hẹp để test dễ stub. */
|
|
5
|
-
export type SessionClient = Pick<VgqClient, 'getFormVersion' | 'createResponse' | 'startInvitationResponse' | 'getResponse' | 'updateValues' | 'completeResponse'>;
|
|
5
|
+
export type SessionClient = Pick<VgqClient, 'getFormVersion' | 'createResponse' | 'createPreviewResponse' | 'startInvitationResponse' | 'getResponse' | 'updateValues' | 'completeResponse'>;
|
|
6
6
|
export interface SessionOptions {
|
|
7
7
|
/** Thời gian gom thay đổi trước khi đồng bộ lên server (ms). Mặc định 800. */
|
|
8
8
|
debounceMs?: number;
|
|
@@ -14,8 +14,13 @@ export interface SessionOptions {
|
|
|
14
14
|
export interface StartSessionOptions {
|
|
15
15
|
/** Bắt đầu qua Publication key... */
|
|
16
16
|
publicationKey?: string;
|
|
17
|
-
/** ...hoặc qua Invitation đã được tạo sẵn
|
|
17
|
+
/** ...hoặc qua Invitation đã được tạo sẵn... */
|
|
18
18
|
invitationId?: string;
|
|
19
|
+
/**
|
|
20
|
+
* ...hoặc xem thử bản Draft của một Form (chưa phát hành). Server chụp
|
|
21
|
+
* Draft thành snapshot và thay thế Response preview cũ của Form đó.
|
|
22
|
+
*/
|
|
23
|
+
previewFormId?: string;
|
|
19
24
|
subjectRef?: string;
|
|
20
25
|
respondentRef?: string;
|
|
21
26
|
careContextRef?: string;
|
package/dist/session.js
CHANGED
|
@@ -41,8 +41,15 @@ export class ResponseSession {
|
|
|
41
41
|
idempotencyKey: start.idempotencyKey,
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
|
+
else if (start.previewFormId) {
|
|
45
|
+
response = await client.createPreviewResponse(start.previewFormId, {
|
|
46
|
+
subjectRef: start.subjectRef,
|
|
47
|
+
respondentRef: start.respondentRef,
|
|
48
|
+
careContextRef: start.careContextRef,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
44
51
|
else {
|
|
45
|
-
throw new Error('Cần publicationKey hoặc
|
|
52
|
+
throw new Error('Cần publicationKey, invitationId hoặc previewFormId để bắt đầu Response');
|
|
46
53
|
}
|
|
47
54
|
// Định nghĩa lấy theo đúng Form Version mà Response đã ghim, không phải
|
|
48
55
|
// version mới nhất của Publication (Draft không đổi Form giữa chừng).
|
package/dist/types.d.ts
CHANGED
|
@@ -151,6 +151,8 @@ export interface ResponseDto {
|
|
|
151
151
|
updated_at: string;
|
|
152
152
|
completed_at: string | null;
|
|
153
153
|
completed_by: string | null;
|
|
154
|
+
/** Response xem thử từ trang demo cổng bệnh nhân (server < 0.3.0 không trả). */
|
|
155
|
+
is_preview?: boolean;
|
|
154
156
|
}
|
|
155
157
|
export interface PublicationForm {
|
|
156
158
|
publication_key: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@viengut/vgq-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Headless TypeScript SDK for the VGQ clinical form platform: load published Forms, manage Response state, evaluate Enable Conditions and validate Response Values without any UI components.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|