@medplum/mock 0.9.3 → 0.9.4
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/dist/cjs/index.js +48 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/index.min.js +1 -1
- package/dist/cjs/index.min.js.map +1 -1
- package/dist/esm/index.js +48 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.min.js +1 -1
- package/dist/esm/index.min.js.map +1 -1
- package/dist/types/mocks/bot.d.ts +2 -1
- package/dist/types/repo.d.ts +1 -0
- package/package.json +6 -6
package/dist/cjs/index.js
CHANGED
|
@@ -123,6 +123,11 @@
|
|
|
123
123
|
id: '123',
|
|
124
124
|
name: 'Test Bot',
|
|
125
125
|
code: 'console.log("hello world");',
|
|
126
|
+
};
|
|
127
|
+
const ExampleClient = {
|
|
128
|
+
resourceType: 'ClientApplication',
|
|
129
|
+
id: '123',
|
|
130
|
+
name: 'Test Client',
|
|
126
131
|
};
|
|
127
132
|
|
|
128
133
|
const ExampleQuestionnaire = {
|
|
@@ -8471,7 +8476,11 @@
|
|
|
8471
8476
|
refStr = e;
|
|
8472
8477
|
}
|
|
8473
8478
|
else if (typeof e === 'object') {
|
|
8474
|
-
|
|
8479
|
+
const ref = e;
|
|
8480
|
+
if (ref.resource) {
|
|
8481
|
+
return ref.resource;
|
|
8482
|
+
}
|
|
8483
|
+
refStr = ref.reference;
|
|
8475
8484
|
}
|
|
8476
8485
|
if (!refStr) {
|
|
8477
8486
|
return undefined;
|
|
@@ -9118,6 +9127,12 @@
|
|
|
9118
9127
|
total: result.length,
|
|
9119
9128
|
};
|
|
9120
9129
|
}
|
|
9130
|
+
deleteResource(resourceType, id) {
|
|
9131
|
+
var _a, _b;
|
|
9132
|
+
if ((_b = (_a = __classPrivateFieldGet$1(this, _MemoryRepository_resources, "f")) === null || _a === void 0 ? void 0 : _a[resourceType]) === null || _b === void 0 ? void 0 : _b[id]) {
|
|
9133
|
+
delete __classPrivateFieldGet$1(this, _MemoryRepository_resources, "f")[resourceType][id];
|
|
9134
|
+
}
|
|
9135
|
+
}
|
|
9121
9136
|
generateId() {
|
|
9122
9137
|
return Date.now().toString(36);
|
|
9123
9138
|
}
|
|
@@ -9235,6 +9250,7 @@
|
|
|
9235
9250
|
members: [
|
|
9236
9251
|
{ id: '123', profile: { reference: 'Practitioner/123', display: 'Alice Smith' }, role: 'owner' },
|
|
9237
9252
|
{ id: '888', profile: { reference: 'ClientApplication/123', display: 'Test Client' }, role: 'client' },
|
|
9253
|
+
{ id: '999', profile: { reference: 'Bot/123', display: 'Test Bot' }, role: 'bot' },
|
|
9238
9254
|
],
|
|
9239
9255
|
};
|
|
9240
9256
|
}
|
|
@@ -9373,6 +9389,7 @@
|
|
|
9373
9389
|
mockRepo.createResource(ExampleStatusValueSet);
|
|
9374
9390
|
mockRepo.createResource(ExampleUserConfiguration);
|
|
9375
9391
|
mockRepo.createResource(ExampleBot);
|
|
9392
|
+
mockRepo.createResource(ExampleClient);
|
|
9376
9393
|
mockRepo.createResource(HomerDiagnosticReport);
|
|
9377
9394
|
mockRepo.createResource(HomerEncounter);
|
|
9378
9395
|
mockRepo.createResource(HomerCommunication);
|
|
@@ -9406,7 +9423,7 @@
|
|
|
9406
9423
|
return exampleValueSet;
|
|
9407
9424
|
}
|
|
9408
9425
|
else if (path === 'fhir/R4/%24graphql') {
|
|
9409
|
-
return
|
|
9426
|
+
return mockFhirGraphqlHandler(method, path, options);
|
|
9410
9427
|
}
|
|
9411
9428
|
else if (path === 'not-found' || id === 'not-found') {
|
|
9412
9429
|
return core.notFound;
|
|
@@ -9436,6 +9453,34 @@
|
|
|
9436
9453
|
else if (method === 'PUT') {
|
|
9437
9454
|
return mockRepo.createResource(JSON.parse(options.body));
|
|
9438
9455
|
}
|
|
9456
|
+
else if (method === 'DELETE') {
|
|
9457
|
+
if (resourceType && id) {
|
|
9458
|
+
return mockRepo.deleteResource(resourceType, id);
|
|
9459
|
+
}
|
|
9460
|
+
else {
|
|
9461
|
+
return core.notFound;
|
|
9462
|
+
}
|
|
9463
|
+
}
|
|
9464
|
+
}
|
|
9465
|
+
function mockFhirGraphqlHandler(_method, _path, options) {
|
|
9466
|
+
const { body } = options;
|
|
9467
|
+
if (body.includes('ResourceList: ServiceRequestList')) {
|
|
9468
|
+
return {
|
|
9469
|
+
data: {
|
|
9470
|
+
ResourceList: [
|
|
9471
|
+
Object.assign(Object.assign({}, HomerServiceRequest), { ObservationList: [
|
|
9472
|
+
HomerObservation1,
|
|
9473
|
+
HomerObservation2,
|
|
9474
|
+
HomerObservation3,
|
|
9475
|
+
HomerObservation4,
|
|
9476
|
+
HomerObservation5,
|
|
9477
|
+
HomerObservation6,
|
|
9478
|
+
] }),
|
|
9479
|
+
],
|
|
9480
|
+
},
|
|
9481
|
+
};
|
|
9482
|
+
}
|
|
9483
|
+
return GraphQLSchemaResponse;
|
|
9439
9484
|
}
|
|
9440
9485
|
function mockFhirBatchHandler(_method, _path, options) {
|
|
9441
9486
|
var _a;
|
|
@@ -9471,6 +9516,7 @@
|
|
|
9471
9516
|
exports.ExampleAccessPolicy = ExampleAccessPolicy;
|
|
9472
9517
|
exports.ExampleAuditEvent = ExampleAuditEvent;
|
|
9473
9518
|
exports.ExampleBot = ExampleBot;
|
|
9519
|
+
exports.ExampleClient = ExampleClient;
|
|
9474
9520
|
exports.ExampleQuestionnaire = ExampleQuestionnaire;
|
|
9475
9521
|
exports.ExampleQuestionnaireResponse = ExampleQuestionnaireResponse;
|
|
9476
9522
|
exports.ExampleStatusValueSet = ExampleStatusValueSet;
|