@evaro/consultation-sdk 0.0.0-stage → 0.2.0-next.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/README.md +51 -2
- package/dist/index.mjs +21053 -0
- package/dist/types/Consultation.d.ts +39 -0
- package/dist/types/api.d.ts +20 -0
- package/dist/types/draftQueue.d.ts +22 -0
- package/dist/types/events.d.ts +15 -0
- package/dist/types/flow/answer.d.ts +46 -0
- package/dist/types/flow/form.d.ts +67 -0
- package/dist/types/flow/path.d.ts +34 -0
- package/dist/types/flow/questionnaire.d.ts +133 -0
- package/dist/types/flow/useConsultationFlow.d.ts +36 -0
- package/dist/types/flow/validations.d.ts +6 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/sanitize.d.ts +2 -0
- package/dist/types/targets/diagnosisRequest.d.ts +3 -0
- package/dist/types/targets/index.d.ts +3 -0
- package/dist/types/types.d.ts +71 -0
- package/dist/types/ui/ErrorNotice.d.ts +4 -0
- package/dist/types/ui/FormFlow.d.ts +9 -0
- package/dist/types/ui/Knockout.d.ts +8 -0
- package/dist/types/ui/Question.d.ts +21 -0
- package/dist/types/ui/ReadOnlyAnswers.d.ts +9 -0
- package/dist/types/ui/ShadowRoot.d.ts +6 -0
- package/dist/types/ui/form/Blocks.d.ts +6 -0
- package/dist/types/ui/form/FormField.d.ts +38 -0
- package/dist/types/ui/form/inputs.d.ts +28 -0
- package/dist/types/ui/primitives.d.ts +37 -0
- package/dist/types/useTargetSave.d.ts +30 -0
- package/package.json +36 -4
package/README.md
CHANGED
|
@@ -1,3 +1,52 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @evaro/consultation-sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The Evaro consultation as one React component: one question at a time, a progress bar, follow-up questions, jumps, the knockout screen and a Back button. It loads the consultation and the vendor theme itself, and it can save the answers to a target.
|
|
4
|
+
|
|
5
|
+
It renders in a shadow root with its own CSS, so the host CSS does not change it and it does not change the host.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add @evaro/consultation-sdk
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
React 19 and React DOM 19 are peer dependencies. Install an exact version.
|
|
14
|
+
|
|
15
|
+
## Use
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import { Consultation } from '@evaro/consultation-sdk'
|
|
19
|
+
|
|
20
|
+
<Consultation
|
|
21
|
+
consultation='<consultation hash>'
|
|
22
|
+
vendor='<vendor hash>'
|
|
23
|
+
environment='staging'
|
|
24
|
+
target={{ type: 'diagnosis-request', id: '<diagnosis request id>' }}
|
|
25
|
+
getToken={getToken}
|
|
26
|
+
onDone={closePanel}
|
|
27
|
+
onEvent={event => track(event.name, event.data)}
|
|
28
|
+
/>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
With no `target`, the component runs as a preview and saves nothing. With `readOnly`, it shows the saved answers of the target. With `nodeApiUrl`, the target's calls go to that URL, for example a local stub server, in place of the environment's NodeAPI host. It must use https, except for localhost. When `consultation`, `vendor`, `environment`, `preview`, `target`, `readOnly` or `layout` changes, or `nodeApiUrl` sends the target's calls to another server, the component sends the last unsaved answers to the old target and loads again, so a host does not have to remount it.
|
|
32
|
+
|
|
33
|
+
The props, the target endpoints and the events are described in [docs/consultation-sdk.md](https://github.com/TotalAccessHealth/consultation/blob/main/docs/consultation-sdk.md).
|
|
34
|
+
|
|
35
|
+
## Develop
|
|
36
|
+
|
|
37
|
+
The package lives in the `sdk/` folder of the CB repo. Run these commands from the repo root:
|
|
38
|
+
|
|
39
|
+
| Command | What it does |
|
|
40
|
+
|---------|--------------|
|
|
41
|
+
| `pnpm build:sdk` | Builds `sdk/dist`: the bundle and the type declarations. |
|
|
42
|
+
| `pnpm test:sdk` | Runs the tests. |
|
|
43
|
+
| `pnpm typecheck:sdk` | Checks the types. |
|
|
44
|
+
|
|
45
|
+
`pnpm dev` and `pnpm build` build the package first, because the CB preview uses it. `pnpm dev` builds it only once, so when you change the package while CB runs, also run `pnpm dev:sdk` to rebuild on each change.
|
|
46
|
+
|
|
47
|
+
`src/flow/questionnaire.ts` and its test are copies of Connect's `utils/questionnaire.ts` and its test at commit `53135f37` on Connect `main`. Until Connect uses this package, a change to the flow goes to both repos, with its tests. When you copy a newer version, change the commit here and in the design doc.
|
|
48
|
+
|
|
49
|
+
## Publish
|
|
50
|
+
|
|
51
|
+
1. Change `version` in `sdk/package.json`.
|
|
52
|
+
2. Run `npm publish` from `sdk/`. It builds and tests the package first, and it asks for your npm 2FA code.
|