dataconv-client-sdk-ts 0.2.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/.github/copilot-instructions.md +104 -0
- package/LICENSE +201 -0
- package/README.md +183 -0
- package/__mocks__/gdc-common-utils-ts/utils/didcomm.ts +39 -0
- package/dist/DataConvClient.d.ts +47 -0
- package/dist/DataConvClient.d.ts.map +1 -0
- package/dist/DataConvClient.js +395 -0
- package/dist/DataConvClient.js.map +1 -0
- package/dist/client/constants.d.ts +9 -0
- package/dist/client/constants.d.ts.map +1 -0
- package/dist/client/constants.js +9 -0
- package/dist/client/constants.js.map +1 -0
- package/dist/client/helpers.d.ts +18 -0
- package/dist/client/helpers.d.ts.map +1 -0
- package/dist/client/helpers.js +105 -0
- package/dist/client/helpers.js.map +1 -0
- package/dist/client/message.d.ts +27 -0
- package/dist/client/message.d.ts.map +1 -0
- package/dist/client/message.js +91 -0
- package/dist/client/message.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +272 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/jest.config.js +16 -0
- package/package.json +46 -0
- package/src/DataConvClient.ts +567 -0
- package/src/__tests__/DataConvClient.test.ts +608 -0
- package/src/client/constants.ts +8 -0
- package/src/client/helpers.ts +127 -0
- package/src/client/message.ts +139 -0
- package/src/index.ts +39 -0
- package/src/types.ts +302 -0
- package/tsconfig.json +21 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
<!-- Use this file to provide workspace-specific custom instructions to Copilot. For more details, visit https://code.visualstudio.com/docs/copilot/copilot-customization#_use-a-githubcopilotinstructionsmd-file -->
|
|
2
|
+
- [x] Verify that the copilot-instructions.md file in the .github directory is created.
|
|
3
|
+
|
|
4
|
+
- [x] Clarify Project Requirements
|
|
5
|
+
<!-- Ask for project type, language, and frameworks if not specified. Skip if already provided. -->
|
|
6
|
+
|
|
7
|
+
- [x] Scaffold the Project
|
|
8
|
+
<!--
|
|
9
|
+
Ensure that the previous step has been marked as completed.
|
|
10
|
+
Call project setup tool with projectType parameter.
|
|
11
|
+
Run scaffolding command to create project files and folders.
|
|
12
|
+
Use '.' as the working directory.
|
|
13
|
+
If no appropriate projectType is available, search documentation using available tools.
|
|
14
|
+
Otherwise, create the project structure manually using available file creation tools.
|
|
15
|
+
-->
|
|
16
|
+
|
|
17
|
+
- [x] Customize the Project
|
|
18
|
+
<!--
|
|
19
|
+
Verify that all previous steps have been completed successfully and you have marked the step as completed.
|
|
20
|
+
Develop a plan to modify codebase according to user requirements.
|
|
21
|
+
Apply modifications using appropriate tools and user-provided references.
|
|
22
|
+
Skip this step for "Hello World" projects.
|
|
23
|
+
-->
|
|
24
|
+
|
|
25
|
+
- [ ] Install Required Extensions
|
|
26
|
+
<!-- ONLY install extensions provided mentioned in the get_project_setup_info. Skip this step otherwise and mark as completed. -->
|
|
27
|
+
|
|
28
|
+
- [x] Compile the Project
|
|
29
|
+
<!--
|
|
30
|
+
Verify that all previous steps have been completed.
|
|
31
|
+
Install any missing dependencies.
|
|
32
|
+
Run diagnostics and resolve any issues.
|
|
33
|
+
Check for markdown files in project folder for relevant instructions on how to do this.
|
|
34
|
+
-->
|
|
35
|
+
|
|
36
|
+
- [ ] Create and Run Task
|
|
37
|
+
<!--
|
|
38
|
+
Verify that all previous steps have been completed.
|
|
39
|
+
Check https://code.visualstudio.com/docs/debugtest/tasks to determine if the project needs a task. If so, use the create_and_run_task to create and launch a task based on package.json, README.md, and project structure.
|
|
40
|
+
Skip this step otherwise.
|
|
41
|
+
-->
|
|
42
|
+
|
|
43
|
+
- [ ] Launch the Project
|
|
44
|
+
<!--
|
|
45
|
+
Verify that all previous steps have been completed.
|
|
46
|
+
Prompt user for debug mode, launch only if confirmed.
|
|
47
|
+
-->
|
|
48
|
+
|
|
49
|
+
- [x] Ensure Documentation is Complete
|
|
50
|
+
<!--
|
|
51
|
+
Verify that all previous steps have been completed.
|
|
52
|
+
Verify that README.md and the copilot-instructions.md file in the .github directory exists and contains current project information.
|
|
53
|
+
Clean up the copilot-instructions.md file in the .github directory by removing all HTML comments.
|
|
54
|
+
-->
|
|
55
|
+
|
|
56
|
+
<!--
|
|
57
|
+
## Execution Guidelines
|
|
58
|
+
PROGRESS TRACKING:
|
|
59
|
+
- If any tools are available to manage the above todo list, use it to track progress through this checklist.
|
|
60
|
+
- After completing each step, mark it complete and add a summary.
|
|
61
|
+
- Read current todo list status before starting each new step.
|
|
62
|
+
|
|
63
|
+
COMMUNICATION RULES:
|
|
64
|
+
- Avoid verbose explanations or printing full command outputs.
|
|
65
|
+
- If a step is skipped, state that briefly (e.g. "No extensions needed").
|
|
66
|
+
- Do not explain project structure unless asked.
|
|
67
|
+
- Keep explanations concise and focused.
|
|
68
|
+
|
|
69
|
+
DEVELOPMENT RULES:
|
|
70
|
+
- Use '.' as the working directory unless user specifies otherwise.
|
|
71
|
+
- Avoid adding media or external links unless explicitly requested.
|
|
72
|
+
- Use placeholders only with a note that they should be replaced.
|
|
73
|
+
- Use VS Code API tool only for VS Code extension projects.
|
|
74
|
+
- Once the project is created, it is already opened in Visual Studio Code—do not suggest commands to open this project in vscode.
|
|
75
|
+
- If the project setup information has additional rules, follow them strictly.
|
|
76
|
+
|
|
77
|
+
FOLDER CREATION RULES:
|
|
78
|
+
- Always use the current directory as the project root.
|
|
79
|
+
- If you are running any terminal commands, use the '.' argument to ensure that the current working directory is used ALWAYS.
|
|
80
|
+
- Do not create a new folder unless the user explicitly requests it besides a .vscode folder for a tasks.json file.
|
|
81
|
+
- If any of the scaffolding commands mention that the folder name is not correct, let the user know to create a new folder with the correct name and then reopen it again in vscode.
|
|
82
|
+
|
|
83
|
+
EXTENSION INSTALLATION RULES:
|
|
84
|
+
- Only install extension specified by the get_project_setup_info tool. DO NOT INSTALL any other extensions.
|
|
85
|
+
|
|
86
|
+
PROJECT CONTENT RULES:
|
|
87
|
+
- If the user has not specified project details, assume they want a "Hello World" project as a starting point.
|
|
88
|
+
- Avoid adding links of any type (URLs, files, folders, etc.) or integrations that are not explicitly required.
|
|
89
|
+
- Avoid generating images, videos, or any other media files unless explicitly requested.
|
|
90
|
+
- If a feature is assumed but not confirmed, prompt the user for clarification before including it.
|
|
91
|
+
- If you are working on a VS Code extension, use the VS Code API tool with a query to find relevant VS Code API references and samples related to that query.
|
|
92
|
+
|
|
93
|
+
TASK COMPLETION RULES:
|
|
94
|
+
- Your task is complete when:
|
|
95
|
+
- Project is successfully scaffolded and compiled without errors
|
|
96
|
+
- copilot-instructions.md file in the .github directory exists
|
|
97
|
+
- README.md file exists and is up to date
|
|
98
|
+
- User is provided with clear instructions to debug/launch the project
|
|
99
|
+
|
|
100
|
+
Before starting a new task in the above plan, update progress in the plan.
|
|
101
|
+
-->
|
|
102
|
+
- Work through each checklist item systematically.
|
|
103
|
+
- Keep communication concise and focused.
|
|
104
|
+
- Follow development best practices.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
# DataConv Client SDK for TypeScript
|
|
2
|
+
|
|
3
|
+
TypeScript SDK for consuming the `adapter-ingestion-py` pre-conversion API.
|
|
4
|
+
|
|
5
|
+
It includes:
|
|
6
|
+
|
|
7
|
+
- tenant/software configuration creation and polling
|
|
8
|
+
- Excel/XLSX upload via DIDComm attachment or `multipart/form-data`
|
|
9
|
+
- `_upload-response` polling
|
|
10
|
+
- promotion through `Composition/_patch` and `Patient/_batch`
|
|
11
|
+
- tenant-scoped search under `/host/.../org.hl7.fhir.api/{resourceType}/_search`
|
|
12
|
+
- helpers to read the converted `Bundle` and keep the last received response
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install dataconv-client-sdk-ts
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Configuration
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
DATACONV_BASE_URL=http://localhost:8080
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Basic usage
|
|
27
|
+
|
|
28
|
+
Minimum end-to-end flow:
|
|
29
|
+
|
|
30
|
+
1. Initialize the client and tokens.
|
|
31
|
+
2. Create the tenant/software configuration.
|
|
32
|
+
3. Wait for `_create-response`.
|
|
33
|
+
4. Upload the Excel file.
|
|
34
|
+
5. Wait for `_upload-response`.
|
|
35
|
+
6. Review and promote with `_patch`.
|
|
36
|
+
7. Publish aggregated resources with `_batch` if needed.
|
|
37
|
+
8. Search promoted resources with `_search`.
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
import { DataConvClient } from 'dataconv-client-sdk-ts';
|
|
41
|
+
|
|
42
|
+
const client = new DataConvClient({
|
|
43
|
+
issuerDid: 'did:web:clinic.example:employee:...',
|
|
44
|
+
alternateName: 'clinic-demo',
|
|
45
|
+
tenantId: 'VATES-B00000000',
|
|
46
|
+
jurisdiction: 'ES',
|
|
47
|
+
sector: 'onehealth-research',
|
|
48
|
+
crypto: globalThis.crypto
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
client.setIdToken('<id_token>');
|
|
52
|
+
client.setVpToken('<vp_token>');
|
|
53
|
+
|
|
54
|
+
// 1. Create the tenant/software configuration.
|
|
55
|
+
const createResult = await client.createConfig({
|
|
56
|
+
entries: [
|
|
57
|
+
{
|
|
58
|
+
softwareId: 'qvet-v1.0',
|
|
59
|
+
config: {
|
|
60
|
+
mappingConfig: {
|
|
61
|
+
headerRowIndex: 1,
|
|
62
|
+
fieldMap: {
|
|
63
|
+
section: 'SECCION',
|
|
64
|
+
family: 'FAMILIA',
|
|
65
|
+
subfamily: 'SUBFAMILIA',
|
|
66
|
+
concept: 'CONCEPTO',
|
|
67
|
+
subjectId: 'HISTORIA_ID',
|
|
68
|
+
species: 'ESPECIE',
|
|
69
|
+
date: 'FECHA',
|
|
70
|
+
time: 'HORA'
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
]
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// 2. Wait until the configuration job completes.
|
|
79
|
+
const configResponse = await client.pollConfig({
|
|
80
|
+
thid: createResult.thid
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
// 3. Upload the Excel or XLSX file for pre-conversion.
|
|
84
|
+
const uploadResult = await client.uploadWithLink(
|
|
85
|
+
'https://example.com/exampleQvetES.xlsx?dl=1',
|
|
86
|
+
{
|
|
87
|
+
softwareId: 'qvet-v1.0',
|
|
88
|
+
fileName: 'exampleQvetES.xlsx'
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
// 4. Wait for the pre-conversion result.
|
|
93
|
+
const conversionResponse = await client.pollUploadResponse({
|
|
94
|
+
thid: uploadResult.thid,
|
|
95
|
+
softwareId: 'qvet-v1.0'
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
const convertedBundle = client.getConvertedBundle(conversionResponse);
|
|
99
|
+
const storedConfigs = client.getSuccessfulTenantConfigs(configResponse);
|
|
100
|
+
|
|
101
|
+
// 5. Confirm promotion of the reviewed thread.
|
|
102
|
+
const patchResponse = await client.patchConversion({
|
|
103
|
+
thid: uploadResult.thid,
|
|
104
|
+
softwareId: 'qvet-v1.0'
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
// 6. Publish aggregated resources in batch if your flow needs it.
|
|
108
|
+
const publicationResponse = await client.batchPromotion({
|
|
109
|
+
thid: uploadResult.thid,
|
|
110
|
+
softwareId: 'qvet-v1.0'
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
// 7. Search promoted resources using lowercase FHIR parameters.
|
|
114
|
+
const searchResponse = await client.searchResources({
|
|
115
|
+
resourceType: 'DocumentReference',
|
|
116
|
+
searchParams: {
|
|
117
|
+
userselected: 'false',
|
|
118
|
+
date: 'ge2026-01-01'
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Multipart / local file upload
|
|
124
|
+
|
|
125
|
+
```ts
|
|
126
|
+
await client.uploadSpreadsheetMultipart({
|
|
127
|
+
softwareId: 'qvet-v1.0',
|
|
128
|
+
fileBytes: new Uint8Array([...]),
|
|
129
|
+
fileName: 'exampleQvetES.xlsx'
|
|
130
|
+
});
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Backend initialization
|
|
134
|
+
|
|
135
|
+
If the backend instantiates the SDK after `Organization/_activate`, it can inject `axios` or `fetch` just like `ica-client-sdk-ts`.
|
|
136
|
+
|
|
137
|
+
```ts
|
|
138
|
+
import axios from 'axios';
|
|
139
|
+
import { DataConvClient } from 'dataconv-client-sdk-ts';
|
|
140
|
+
|
|
141
|
+
const httpClient = axios.create({
|
|
142
|
+
baseURL: process.env.DATACONV_BASE_URL
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
const client = new DataConvClient({
|
|
146
|
+
issuerDid: activatedOrganizationDid,
|
|
147
|
+
alternateName: tenantAlternateName,
|
|
148
|
+
tenantId: tenantAlternateName,
|
|
149
|
+
jurisdiction: 'ES',
|
|
150
|
+
httpClient,
|
|
151
|
+
crypto: globalThis.crypto
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
client.setVpToken(vpTokenFromActivation);
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
It also works with `fetch`:
|
|
158
|
+
|
|
159
|
+
```ts
|
|
160
|
+
const client = new DataConvClient({
|
|
161
|
+
issuerDid: activatedOrganizationDid,
|
|
162
|
+
alternateName: tenantAlternateName,
|
|
163
|
+
tenantId: tenantAlternateName,
|
|
164
|
+
jurisdiction: 'ES',
|
|
165
|
+
fetch,
|
|
166
|
+
crypto: globalThis.crypto
|
|
167
|
+
});
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## Notes
|
|
171
|
+
|
|
172
|
+
- For configuration and conversion calls, the operational tenant identifier should be `tenantId`, typically the organization's VAT/taxId. `alternateName` remains as a compatibility alias.
|
|
173
|
+
- `sector` is variable and is part of the public route for config, digital twin, and search.
|
|
174
|
+
- `patchConversion()` defaults to `Composition/_patch`.
|
|
175
|
+
- `batchPromotion()` defaults to `Patient/_batch`.
|
|
176
|
+
- `searchResources()` resolves to `/host/cds-{jurisdiction}/v1/{sector}/{tenantId}/org.hl7.fhir.api/{resourceType}/_search`.
|
|
177
|
+
- Parameter names sent by `searchResources()` are lowercase. Example: `userselected`, `date`.
|
|
178
|
+
- Even if the caller passes `userSelected`, the SDK normalizes it to `userselected` before sending the body.
|
|
179
|
+
- In `_search`, the current comparators are prefixed in the value: `ge2026-01-01`, `gt...`, `le...`, `lt...`.
|
|
180
|
+
- The pre-conversion service can already require `vp_token` and/or `id_token` depending on `PRECONV_AUTH_MODE`, although it does not yet validate signatures or the full session exchange in `adapter-ingestion-py`.
|
|
181
|
+
- The current backend still rejects `source_format=csv`; the SDK models it because the route exists, but real support today is Excel/XLSX.
|
|
182
|
+
- `gdc-common-utils-ts` is consumed from npm; this SDK adds the concrete pre-conversion types on top of those DIDComm helpers.
|
|
183
|
+
- ICA VCs and `controller.publicKeyJwk` belong to the backend onboarding/`_activate` flow. `DataConvClient` is instantiated afterwards, once the tenant is already activated and only pre-conversion calls are needed.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export class DidCommMessage {
|
|
2
|
+
id = 'mock';
|
|
3
|
+
type = '';
|
|
4
|
+
body: any = {};
|
|
5
|
+
attachments?: any[];
|
|
6
|
+
thid?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type DidCommAttachment = {
|
|
10
|
+
id: string;
|
|
11
|
+
media_type: string;
|
|
12
|
+
data: any;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export function prepareDidCommRequest(type: string, body: any = {}, attachments: any[] = []): DidCommMessage {
|
|
16
|
+
const message = new DidCommMessage();
|
|
17
|
+
message.type = type;
|
|
18
|
+
message.body = body;
|
|
19
|
+
message.attachments = attachments;
|
|
20
|
+
message.thid = message.id;
|
|
21
|
+
return message;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function includeVpTokenInMessage(message: DidCommMessage, vpToken: string): void {
|
|
25
|
+
message.body.vp_token = vpToken;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function includeFileInMessage(message: DidCommMessage, fileBytes: Uint8Array, mediaType: string, id: string): void {
|
|
29
|
+
if (!message.attachments) message.attachments = [];
|
|
30
|
+
message.attachments.push({ id, media_type: mediaType, data: { base64: Buffer.from(fileBytes).toString('base64') } });
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function getThidFromMessage(message: DidCommMessage): string {
|
|
34
|
+
return message.thid || message.id;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function getDataResults(response: DidCommMessage): any[] {
|
|
38
|
+
return response.body?.data || [];
|
|
39
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { DataConvBatchOptions, ConversionResultEntry, ConvertedBundleResource, CreateTenantConfigOptions, DataConvClientConfig, DataConvConversionPollOptions, DataConvCreateResult, DataConvDidCommResponse, DataConvMultipartUploadOptions, DataConvOperationOutcome, DataConvPatchOptions, DataConvPatchResponse, DataConvSearchBundle, DataConvSearchOptions, DataConvTenantConfigPollOptions, DataConvUploadDidCommOptions, DataConvUploadResult, TenantAdapterConfigEntry, TenantAdapterConfigResource } from './types.js';
|
|
2
|
+
export declare class DataConvClient {
|
|
3
|
+
private readonly config;
|
|
4
|
+
private readonly httpClient?;
|
|
5
|
+
private readonly fetchFn?;
|
|
6
|
+
private readonly cryptoApi?;
|
|
7
|
+
private readonly baseUrl;
|
|
8
|
+
private readonly retryTimes;
|
|
9
|
+
private readonly retryDelayMs;
|
|
10
|
+
private readonly defaultExpSeconds;
|
|
11
|
+
private idToken?;
|
|
12
|
+
private vpToken?;
|
|
13
|
+
private lastTenantConfigResponse?;
|
|
14
|
+
private lastConversionResponse?;
|
|
15
|
+
constructor(config: DataConvClientConfig);
|
|
16
|
+
setIdToken(idToken: string): void;
|
|
17
|
+
setVpToken(vpToken: string): void;
|
|
18
|
+
getLastTenantConfigResponse(): DataConvDidCommResponse<TenantAdapterConfigResource> | undefined;
|
|
19
|
+
getLastConversionResponse(): DataConvDidCommResponse<ConvertedBundleResource> | undefined;
|
|
20
|
+
clearStoredResponses(): void;
|
|
21
|
+
getTenantConfigEntries(response?: DataConvDidCommResponse<TenantAdapterConfigResource> | undefined): Array<TenantAdapterConfigEntry<TenantAdapterConfigResource>>;
|
|
22
|
+
getSuccessfulTenantConfigs(response?: DataConvDidCommResponse<TenantAdapterConfigResource> | undefined): TenantAdapterConfigResource[];
|
|
23
|
+
getConversionEntry(response?: DataConvDidCommResponse<ConvertedBundleResource> | undefined): ConversionResultEntry | undefined;
|
|
24
|
+
getConvertedBundle(response?: DataConvDidCommResponse<ConvertedBundleResource> | undefined): ConvertedBundleResource | undefined;
|
|
25
|
+
getResponseIssues<TResource>(response: DataConvDidCommResponse<TResource> | undefined): DataConvOperationOutcome | undefined;
|
|
26
|
+
createTenantConfig(options: CreateTenantConfigOptions): Promise<DataConvCreateResult>;
|
|
27
|
+
createConfig(options: CreateTenantConfigOptions): Promise<DataConvCreateResult>;
|
|
28
|
+
pollTenantConfigResponse(options: DataConvTenantConfigPollOptions): Promise<DataConvDidCommResponse<TenantAdapterConfigResource>>;
|
|
29
|
+
pollConfig(options: DataConvTenantConfigPollOptions): Promise<DataConvDidCommResponse<TenantAdapterConfigResource>>;
|
|
30
|
+
createTenantConfigAndWait(options: CreateTenantConfigOptions): Promise<DataConvDidCommResponse<TenantAdapterConfigResource>>;
|
|
31
|
+
uploadSpreadsheet(source: string | Uint8Array, options: DataConvUploadDidCommOptions): Promise<DataConvUploadResult>;
|
|
32
|
+
uploadWithLink(source: string, options: DataConvUploadDidCommOptions): Promise<DataConvUploadResult>;
|
|
33
|
+
uploadWithBinary(source: Uint8Array, options: DataConvUploadDidCommOptions): Promise<DataConvUploadResult>;
|
|
34
|
+
private uploadDidComm;
|
|
35
|
+
uploadSpreadsheetMultipart(options: DataConvMultipartUploadOptions): Promise<DataConvUploadResult>;
|
|
36
|
+
uploadWithFile(options: DataConvMultipartUploadOptions): Promise<DataConvUploadResult>;
|
|
37
|
+
pollConversionResponse(options: DataConvConversionPollOptions): Promise<DataConvDidCommResponse<ConvertedBundleResource>>;
|
|
38
|
+
pollUploadResponse(options: DataConvConversionPollOptions): Promise<DataConvDidCommResponse<ConvertedBundleResource>>;
|
|
39
|
+
uploadSpreadsheetAndWait(source: string | Uint8Array, options: DataConvUploadDidCommOptions): Promise<DataConvDidCommResponse<ConvertedBundleResource>>;
|
|
40
|
+
patchConversion(options: DataConvPatchOptions): Promise<DataConvPatchResponse>;
|
|
41
|
+
batchPromotion(options: DataConvBatchOptions): Promise<DataConvPatchResponse>;
|
|
42
|
+
searchResources<TResource = Record<string, unknown>>(options: DataConvSearchOptions): Promise<DataConvSearchBundle<TResource>>;
|
|
43
|
+
private pollUntilComplete;
|
|
44
|
+
private request;
|
|
45
|
+
private messageDeps;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=DataConvClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataConvClient.d.ts","sourceRoot":"","sources":["../src/DataConvClient.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EACV,oBAAoB,EACpB,qBAAqB,EACrB,uBAAuB,EACvB,yBAAyB,EACzB,oBAAoB,E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