@crvouga/mockingbird-service-junction 2.3.0 → 3.0.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/CHANGELOG.md +29 -5
- package/dist/{chunk-C2UGIPPM.js → chunk-2FZJPMTR.js} +21553 -31289
- package/dist/{chunk-C2UGIPPM.js.map → chunk-2FZJPMTR.js.map} +2 -2
- package/dist/{chunk-UXBNCMYV.js → chunk-G3BD4D34.js} +69 -13
- package/dist/chunk-G3BD4D34.js.map +7 -0
- package/dist/{chunk-TRSGVIZL.js → chunk-XMZYEZ4V.js} +3 -3
- package/dist/cli.js +3 -3
- package/dist/corpus.js +1 -1
- package/dist/index.js +1 -1
- package/dist/server.js +3 -3
- package/package.json +2 -2
- package/dist/chunk-UXBNCMYV.js.map +0 -7
- /package/dist/{chunk-TRSGVIZL.js.map → chunk-XMZYEZ4V.js.map} +0 -0
|
@@ -57,8 +57,38 @@ var CORE_MIGRATIONS = [
|
|
|
57
57
|
`
|
|
58
58
|
}
|
|
59
59
|
];
|
|
60
|
+
var LEGACY_TABLES = [
|
|
61
|
+
["emulates_records", "mockingbird_records"],
|
|
62
|
+
["emulators_records", "mockingbird_records"],
|
|
63
|
+
["emulates_sequences", "mockingbird_sequences"],
|
|
64
|
+
["emulators_sequences", "mockingbird_sequences"]
|
|
65
|
+
];
|
|
66
|
+
var LEGACY_INDEXES = [
|
|
67
|
+
["emulates_records_seq", "mockingbird_records_seq"],
|
|
68
|
+
["emulators_records_seq", "mockingbird_records_seq"]
|
|
69
|
+
];
|
|
70
|
+
var namesOf = (sqlite, type) => new Set(sqlite.prepare("SELECT name FROM sqlite_master WHERE type = ?").all(type).map((row) => row.name));
|
|
60
71
|
var migrateCore = (sqlite) => {
|
|
61
72
|
migrate(sqlite, CORE_MIGRATIONS);
|
|
73
|
+
const tables = namesOf(sqlite, "table");
|
|
74
|
+
const indexes = namesOf(sqlite, "index");
|
|
75
|
+
sqlite.transaction(() => {
|
|
76
|
+
for (const [from, to] of LEGACY_TABLES) {
|
|
77
|
+
if (!tables.has(from) || tables.has(to))
|
|
78
|
+
continue;
|
|
79
|
+
sqlite.exec(`ALTER TABLE ${from} RENAME TO ${to}`);
|
|
80
|
+
tables.delete(from);
|
|
81
|
+
tables.add(to);
|
|
82
|
+
}
|
|
83
|
+
for (const [from, to] of LEGACY_INDEXES) {
|
|
84
|
+
if (!indexes.has(from) || indexes.has(to))
|
|
85
|
+
continue;
|
|
86
|
+
sqlite.exec(`DROP INDEX ${from}`);
|
|
87
|
+
sqlite.exec(`CREATE INDEX ${to} ON mockingbird_records (namespace, collection, seq)`);
|
|
88
|
+
indexes.delete(from);
|
|
89
|
+
indexes.add(to);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
62
92
|
};
|
|
63
93
|
var clearNamespace = (sqlite, namespace) => {
|
|
64
94
|
sqlite.transaction(() => {
|
|
@@ -2108,7 +2138,7 @@ var stateAdminRoutes = (routes) => {
|
|
|
2108
2138
|
};
|
|
2109
2139
|
|
|
2110
2140
|
// ../core/dist/version.js
|
|
2111
|
-
var PACKAGE_VERSION = true ? "
|
|
2141
|
+
var PACKAGE_VERSION = true ? "3.0.0" : UNRELEASED_VERSION;
|
|
2112
2142
|
|
|
2113
2143
|
// ../core/dist/webhooks.js
|
|
2114
2144
|
var json4 = (status, body) => new Response(JSON.stringify(body), {
|
|
@@ -6638,8 +6668,10 @@ var patientDetails = (input) => ({
|
|
|
6638
6668
|
sexual_orientation: null,
|
|
6639
6669
|
gender_identity: null
|
|
6640
6670
|
});
|
|
6641
|
-
var patientAddress = (input) => ({
|
|
6671
|
+
var patientAddress = (input, details) => ({
|
|
6642
6672
|
...input,
|
|
6673
|
+
receiver_name: input.receiver_name ?? `${details.first_name} ${details.last_name}`,
|
|
6674
|
+
phone_number: input.phone_number ?? details.phone_number,
|
|
6643
6675
|
second_line: null,
|
|
6644
6676
|
access_notes: null
|
|
6645
6677
|
});
|
|
@@ -7194,9 +7226,24 @@ var orderHandlers = (state) => ({
|
|
|
7194
7226
|
data: state.listLabTests().filter((test) => test.auto_generated !== true),
|
|
7195
7227
|
next_cursor: null
|
|
7196
7228
|
}),
|
|
7197
|
-
//
|
|
7198
|
-
//
|
|
7199
|
-
get_lab_tests_for_team_v3_lab_tests_get: async (context) =>
|
|
7229
|
+
// The legacy endpoint orders the same records differently from the paginated catalog.
|
|
7230
|
+
// Use its recorded order while retaining the current state of each test.
|
|
7231
|
+
get_lab_tests_for_team_v3_lab_tests_get: async (context) => {
|
|
7232
|
+
const recorded2 = state.getGetCache("GET /v3/lab_tests")?.body;
|
|
7233
|
+
const positions = new Map(
|
|
7234
|
+
(Array.isArray(recorded2) ? recorded2 : []).map((test, index) => [
|
|
7235
|
+
typeof test === "object" && test !== null && "id" in test ? String(test.id) : "",
|
|
7236
|
+
index
|
|
7237
|
+
])
|
|
7238
|
+
);
|
|
7239
|
+
const tests = state.listLabTests();
|
|
7240
|
+
if (positions.size > 0) {
|
|
7241
|
+
tests.sort(
|
|
7242
|
+
(a, b) => (positions.get(a.id) ?? positions.size) - (positions.get(b.id) ?? positions.size)
|
|
7243
|
+
);
|
|
7244
|
+
}
|
|
7245
|
+
return jsonRes(200, filterLabTests(tests, context.url.searchParams));
|
|
7246
|
+
},
|
|
7200
7247
|
get_lab_test_for_team_v3_lab_tests__lab_test_id__get: async (context) => {
|
|
7201
7248
|
const id = context.params.lab_test_id ?? "";
|
|
7202
7249
|
const test = state.labTestById(id);
|
|
@@ -7632,7 +7679,7 @@ var buildOrderRecord = (state, draft, now) => {
|
|
|
7632
7679
|
user_id: userId,
|
|
7633
7680
|
team_id: state.teamId,
|
|
7634
7681
|
patient_details: patientDetails(details),
|
|
7635
|
-
patient_address: patientAddress(draft.patientAddress),
|
|
7682
|
+
patient_address: patientAddress(draft.patientAddress, details),
|
|
7636
7683
|
lab_test: orderLabTest,
|
|
7637
7684
|
details: METHOD_DETAILS(method, state.testkitIdFor(orderId), nowIso),
|
|
7638
7685
|
sample_id: null,
|
|
@@ -9691,6 +9738,7 @@ var pullCorpus = async (options) => {
|
|
|
9691
9738
|
if (cursor === null) break;
|
|
9692
9739
|
await sleep(gap);
|
|
9693
9740
|
}
|
|
9741
|
+
await recordObservation(real, "GET", "/v3/lab_tests", getCache);
|
|
9694
9742
|
const labs = listOf(await recordObservation(real, "GET", "/v3/lab_tests/labs", getCache));
|
|
9695
9743
|
const expectedResults = {};
|
|
9696
9744
|
for (const test of labTests) {
|
|
@@ -10207,6 +10255,13 @@ var scenario = (corpus, withOrders) => {
|
|
|
10207
10255
|
skip: (ctx) => !ctx.real.orderId || !ctx.mock.orderId,
|
|
10208
10256
|
request: (ctx) => ({ method: "GET", path: `/v3/order/${ctx.orderId}` })
|
|
10209
10257
|
},
|
|
10258
|
+
{
|
|
10259
|
+
name: "order.address",
|
|
10260
|
+
compare: "exact",
|
|
10261
|
+
skip: (ctx) => !ctx.real.orderId || !ctx.mock.orderId,
|
|
10262
|
+
request: (ctx) => ({ method: "GET", path: `/v3/order/${ctx.orderId}` }),
|
|
10263
|
+
project: (body) => body?.patient_address ?? null
|
|
10264
|
+
},
|
|
10210
10265
|
{
|
|
10211
10266
|
name: "order.cancel",
|
|
10212
10267
|
compare: "shape",
|
|
@@ -10394,22 +10449,23 @@ var verifyAgainstReal = async (options) => {
|
|
|
10394
10449
|
step.capture?.(replies[side], ctx[side]);
|
|
10395
10450
|
}
|
|
10396
10451
|
const { real, mock } = replies;
|
|
10452
|
+
const realBody = step.project ? step.project(real.body) : real.body;
|
|
10453
|
+
const mockBody = step.project ? step.project(mock.body) : mock.body;
|
|
10397
10454
|
let divergence;
|
|
10398
10455
|
if (real.status !== mock.status) {
|
|
10399
10456
|
divergence = { check: step.name, kind: "status", real: real.status, mock: mock.status };
|
|
10400
10457
|
} else if (step.compare === "exact") {
|
|
10401
|
-
const at = firstDifference(
|
|
10402
|
-
if (at)
|
|
10403
|
-
divergence = { check: step.name, kind: "body", at, real: real.body, mock: mock.body };
|
|
10458
|
+
const at = firstDifference(realBody, mockBody);
|
|
10459
|
+
if (at) divergence = { check: step.name, kind: "body", at, real: realBody, mock: mockBody };
|
|
10404
10460
|
} else {
|
|
10405
|
-
const at = firstDifference(shapeOf(
|
|
10461
|
+
const at = firstDifference(shapeOf(realBody), shapeOf(mockBody));
|
|
10406
10462
|
if (at) {
|
|
10407
10463
|
divergence = {
|
|
10408
10464
|
check: step.name,
|
|
10409
10465
|
kind: "shape",
|
|
10410
10466
|
at,
|
|
10411
|
-
real: shapeOf(
|
|
10412
|
-
mock: shapeOf(
|
|
10467
|
+
real: shapeOf(realBody),
|
|
10468
|
+
mock: shapeOf(mockBody)
|
|
10413
10469
|
};
|
|
10414
10470
|
}
|
|
10415
10471
|
}
|
|
@@ -10873,4 +10929,4 @@ export {
|
|
|
10873
10929
|
JunctionAPI,
|
|
10874
10930
|
LabAccountConflict
|
|
10875
10931
|
};
|
|
10876
|
-
//# sourceMappingURL=chunk-
|
|
10932
|
+
//# sourceMappingURL=chunk-G3BD4D34.js.map
|