Skip to content

Commit 031868f

Browse files
committed
ref: Rename external-packages to on-the-fly, unskip #137 tests
- Rename `examples/external-packages/` → `examples/on-the-fly/` - Unskip create/createResource tests now that the duplicate meta key fix landed - Remove `continue-on-error` from CI jobs - Update examples/README.md with on-the-fly section
1 parent cf387de commit 031868f

12 files changed

Lines changed: 47 additions & 30 deletions

File tree

.github/workflows/sdk-tests.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,9 @@ jobs:
246246
run: bun install --frozen-lockfile
247247

248248
- name: Run tests
249-
# TODO(#137): remove continue-on-error once duplicate meta key bug is fixed
250-
continue-on-error: true
251249
run: make test-local-package-folder-example
252250

253-
test-external-packages-example:
251+
test-on-the-fly-example:
254252
runs-on: ubuntu-latest
255253

256254
strategy:
@@ -269,9 +267,7 @@ jobs:
269267
run: bun install --frozen-lockfile
270268

271269
- name: Run tests
272-
# TODO(#137): remove continue-on-error once duplicate meta key bug is fixed (KBV typecheck fails with TS1117)
273-
continue-on-error: true
274-
run: make test-external-packages-example
270+
run: make test-on-the-fly-example
275271

276272
test-mustache-java-r4-example:
277273
runs-on: ubuntu-latest

Makefile

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@ test-all-example-generation: test-other-example-generation
5757
bun run examples/typescript-sql-on-fhir/generate.ts
5858
bun run examples/typescript-us-core/generate.ts
5959

60-
test-other-example-generation: test-external-packages-example
61-
62-
test-external-packages-example:
63-
bun run examples/external-packages/norge-r4/generate.ts
64-
$(TYPECHECK) --project examples/external-packages/norge-r4/tsconfig.json
65-
$(TEST) ./examples/external-packages/norge-r4/
66-
bun run examples/external-packages/kbv-r4/generate.ts
67-
$(TYPECHECK) --project examples/external-packages/kbv-r4/tsconfig.json
68-
$(TEST) ./examples/external-packages/kbv-r4/
60+
test-other-example-generation: test-on-the-fly-example
61+
62+
test-on-the-fly-example:
63+
bun run examples/on-the-fly/norge-r4/generate.ts
64+
$(TYPECHECK) --project examples/on-the-fly/norge-r4/tsconfig.json
65+
$(TEST) ./examples/on-the-fly/norge-r4/
66+
bun run examples/on-the-fly/kbv-r4/generate.ts
67+
$(TYPECHECK) --project examples/on-the-fly/kbv-r4/tsconfig.json
68+
$(TEST) ./examples/on-the-fly/kbv-r4/
6969

7070
test-typescript-r4-example: typecheck format lint
7171
bun run examples/typescript-r4/generate.ts

examples/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,18 @@ This directory contains working examples demonstrating the capabilities of Atomi
5858
- Demonstrates dependency resolution with FHIR R4 core
5959
- Shows tree shaking for custom logical models
6060

61+
### On-the-Fly Generation
62+
63+
These examples pull packages from the FHIR registry and generate types on-the-fly (generated types are gitignored and regenerated on CI).
64+
65+
- **[on-the-fly/norge-r4/](on-the-fly/norge-r4/)** - Norwegian FHIR profiles (Grunndata, no-basis, SFM)
66+
- `generate.ts` - Fetches multiple Norwegian FHIR packages from Simplifier
67+
- Demonstrates `preprocessPackage` for fixing package metadata and dependency injection
68+
69+
- **[on-the-fly/kbv-r4/](on-the-fly/kbv-r4/)** - German KBV profiles (kbv.ita.for)
70+
- `generate.ts` - Fetches KBV packages with `ignorePackageIndex: true` for corrupt package indices
71+
- `profile-patient.test.ts` - Regression test for `meta` merge in profiles with required `meta` (#137)
72+
6173
## Running Examples
6274

6375
Each example contains a `generate.ts` script that can be run with:
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Bun Snapshot v1, https://bun.sh/docs/test/snapshots
2+
3+
exports[`demo: create a patient with required meta create sets meta.profile and preserves caller meta fields 1`] = `
4+
{
5+
"meta": {
6+
"lastUpdated": "2024-01-01T00:00:00Z",
7+
"profile": [
8+
"http://example.org/fhir/StructureDefinition/PatientMetaRequired",
9+
],
10+
"versionId": "1",
11+
},
12+
"resourceType": "Patient",
13+
}
14+
`;

examples/local-package-folder/profile-meta-required.test.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
/**
22
* PatientMetaRequired profile demo — exercises a profile where `meta` is required (min: 1).
33
*
4-
* This is a regression scenario for issue #137: when `meta` is required, `createResource()`
5-
* must merge the caller's meta fields with the auto-set `meta.profile` array, not emit
6-
* two separate `meta:` keys.
4+
* Regression test for #137: `createResource()` merges the caller's meta fields
5+
* with the auto-set `meta.profile` array via spread.
76
*/
87

98
import { describe, expect, test } from "bun:test";
@@ -13,9 +12,7 @@ import type { Patient } from "./fhir-types/hl7-fhir-r4-core/Patient";
1312
const canonicalUrl = "http://example.org/fhir/StructureDefinition/PatientMetaRequired";
1413

1514
describe("demo: create a patient with required meta", () => {
16-
// TODO(#137): create/createResource emit duplicate `meta:` keys — caller meta is overwritten.
17-
// Un-skip once the codegen fix merges the two meta values.
18-
test.skip("create sets meta.profile and preserves caller meta fields", () => {
15+
test("create sets meta.profile and preserves caller meta fields", () => {
1916
const profile = PatientMetaRequiredProfile.create({
2017
meta: { versionId: "1", lastUpdated: "2024-01-01T00:00:00Z" },
2118
});
@@ -33,7 +30,7 @@ describe("demo: create a patient with required meta", () => {
3330
expect(resource).toMatchSnapshot();
3431
});
3532

36-
test.skip("createResource also merges meta correctly", () => {
33+
test("createResource also merges meta correctly", () => {
3734
const resource = PatientMetaRequiredProfile.createResource({
3835
meta: { versionId: "2" },
3936
});
File renamed without changes.

examples/external-packages/kbv-r4/generate.ts renamed to examples/on-the-fly/kbv-r4/generate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ if (require.main === module) {
4141
openResourceTypeSet: false,
4242
})
4343
.typeSchema({})
44-
.outputTo("./examples/external-packages/kbv-r4/fhir-types")
44+
.outputTo("./examples/on-the-fly/kbv-r4/fhir-types")
4545
.cleanOutput(true);
4646

4747
const report = await builder.generate();

examples/external-packages/kbv-r4/profile-patient.test.ts renamed to examples/on-the-fly/kbv-r4/profile-patient.test.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
/**
22
* KBV_PR_FOR_Patient profile — regression test for duplicate meta key (#137).
33
*
4-
* KBV profiles require `meta` (min: 1). Until the codegen fix merges caller meta
5-
* with the auto-set meta.profile, `createResource` emits two `meta:` keys and
6-
* the caller-provided meta is silently overwritten.
4+
* KBV profiles require `meta` (min: 1). The codegen now merges caller meta
5+
* with the auto-set meta.profile via spread.
76
*/
87

98
import { describe, expect, test } from "bun:test";
@@ -13,8 +12,7 @@ import { KBV_PR_FOR_PatientProfile } from "./fhir-types/kbv-ita-for/profiles/Pat
1312
const canonicalUrl = "https://fhir.kbv.de/StructureDefinition/KBV_PR_FOR_Patient";
1413

1514
describe("demo: KBV Patient with required meta", () => {
16-
// TODO(#137): createResource emits duplicate `meta:` keys — caller meta is overwritten.
17-
test.skip("create preserves caller meta fields alongside meta.profile", () => {
15+
test("create preserves caller meta fields alongside meta.profile", () => {
1816
const profile = KBV_PR_FOR_PatientProfile.create({
1917
name: [{ family: "Müller", given: ["Hans"] }],
2018
birthDate: "1990-01-15",
@@ -28,7 +26,7 @@ describe("demo: KBV Patient with required meta", () => {
2826
expect(resource.meta?.lastUpdated).toBe("2024-01-01T00:00:00Z");
2927
});
3028

31-
test.skip("createResource merges meta correctly", () => {
29+
test("createResource merges meta correctly", () => {
3230
const resource = KBV_PR_FOR_PatientProfile.createResource({
3331
name: [{ family: "Schmidt" }],
3432
birthDate: "1985-06-20",
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)