Commit 48274f8
committed
fix(client): stop BundleParser handing back types it never checked
FhirResourceReader.search() already returns Bundle<WithId<T>>, and every
BundleParser method threw that away, so callers cast back to what they
started with. Three defects, one template, so r4/r4b/r5 are fixed together.
- getAllResources is generic in the bundle's element type, so a searchset
comes back as what the reader knew instead of widening to Resource[].
- The resourceType argument is checked against the FHIR resourceType union:
a typo, or a type argument that disagrees with it, is now a compile error
instead of an empty array typed as the resource that was asked for.
- Nothing promises WithId any more. id is optional in FHIR (contained
resources and POST bundle entries have none) and was never verified, so
the promise moved into the hasId guard, which callers chain where the
guarantee is needed.
- resolveReference takes its return type from the bundle rather than
asserting one; resolveReferenceOfType narrows a mixed bundle by a checked
resourceType and returns undefined when the reference resolves elsewhere.
reader.ts loses the two casts that repeated the same pattern on values the
bundle type already described.
Breaking for consumers of the 0.2 line, so the three packages go to 0.3.0
and each README carries the migration.
CI now builds and tests every package under packages/. They were compiled
only at release time, so a type error in the template reached npm before
anything ran tsc over it.
Closes #1491 parent ff74594 commit 48274f8
30 files changed
Lines changed: 913 additions & 171 deletions
File tree
- .github/workflows
- packages
- client-r4b
- src
- client-r4
- src
- client-r5
- src
- scripts/client-codegen/template
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
| 75 | + | |
76 | 76 | | |
77 | | - | |
78 | | - | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
79 | 97 | | |
80 | 98 | | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
81 | 114 | | |
82 | 115 | | |
83 | 116 | | |
| |||
87 | 120 | | |
88 | 121 | | |
89 | 122 | | |
| 123 | + | |
| 124 | + | |
90 | 125 | | |
91 | 126 | | |
92 | 127 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
25 | | - | |
| 26 | + | |
26 | 27 | | |
27 | | - | |
28 | | - | |
| 28 | + | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
32 | | - | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| |||
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
49 | 66 | | |
50 | 67 | | |
51 | 68 | | |
52 | 69 | | |
53 | | - | |
| 70 | + | |
54 | 71 | | |
55 | 72 | | |
56 | 73 | | |
| |||
65 | 82 | | |
66 | 83 | | |
67 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
68 | 96 | | |
69 | 97 | | |
70 | 98 | | |
| |||
96 | 124 | | |
97 | 125 | | |
98 | 126 | | |
99 | | - | |
| 127 | + | |
100 | 128 | | |
101 | 129 | | |
102 | 130 | | |
103 | 131 | | |
104 | 132 | | |
105 | 133 | | |
106 | 134 | | |
107 | | - | |
| 135 | + | |
108 | 136 | | |
109 | 137 | | |
110 | 138 | | |
111 | 139 | | |
112 | 140 | | |
113 | 141 | | |
114 | 142 | | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
| 143 | + | |
119 | 144 | | |
120 | 145 | | |
121 | 146 | | |
| |||
127 | 152 | | |
128 | 153 | | |
129 | 154 | | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
| 155 | + | |
134 | 156 | | |
135 | 157 | | |
136 | 158 | | |
| |||
151 | 173 | | |
152 | 174 | | |
153 | 175 | | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
154 | 218 | | |
155 | 219 | | |
0 commit comments