@nsshunt/stsfhirclient 1.0.5 → 1.0.6
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/stsfhirclient.mjs +3 -707
- package/dist/stsfhirclient.mjs.map +1 -1
- package/dist/stsfhirclient.umd.js +3 -706
- package/dist/stsfhirclient.umd.js.map +1 -1
- package/package.json +1 -1
- package/types/index.d.ts +0 -2
- package/types/index.d.ts.map +1 -1
package/dist/stsfhirclient.mjs
CHANGED
|
@@ -8,12 +8,11 @@ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot
|
|
|
8
8
|
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
9
9
|
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
10
10
|
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
11
|
-
var _options, _DUMMY_USER, _httpsAgent, _invokeMethods, _maxRetries, _sleepDuration, _NoRetryStatusCodes, _LogDebugMessage, _LogErrorMessage, _GetHttpsAgent, _HandleError, _InvokeResourceAPI, _TestMode, ___InvokeResourceAPI
|
|
11
|
+
var _options, _DUMMY_USER, _httpsAgent, _invokeMethods, _maxRetries, _sleepDuration, _NoRetryStatusCodes, _LogDebugMessage, _LogErrorMessage, _GetHttpsAgent, _HandleError, _InvokeResourceAPI, _TestMode, ___InvokeResourceAPI;
|
|
12
12
|
import https from "node:https";
|
|
13
13
|
import axios from "axios";
|
|
14
|
-
import { Sleep
|
|
14
|
+
import { Sleep } from "@nsshunt/stsutils";
|
|
15
15
|
import { Gauge } from "@nsshunt/stsobservability";
|
|
16
|
-
import { expect } from "vitest";
|
|
17
16
|
var IFhirPersistenceType = /* @__PURE__ */ ((IFhirPersistenceType2) => {
|
|
18
17
|
IFhirPersistenceType2["postgresResources"] = "postgresResources";
|
|
19
18
|
IFhirPersistenceType2["postgresResourcesEntities"] = "postgresResourcesEntities";
|
|
@@ -3861,711 +3860,8 @@ _HandleError = new WeakMap();
|
|
|
3861
3860
|
_InvokeResourceAPI = new WeakMap();
|
|
3862
3861
|
_TestMode = new WeakMap();
|
|
3863
3862
|
___InvokeResourceAPI = new WeakMap();
|
|
3864
|
-
class STSFhirControllerTestCasesClient {
|
|
3865
|
-
// ststestrunnernode password
|
|
3866
|
-
constructor(options) {
|
|
3867
|
-
__privateAdd(this, _testHelper);
|
|
3868
|
-
__privateAdd(this, _endpoint, `https://localhost:${goptions.stsfhirport}`);
|
|
3869
|
-
__privateAdd(this, _fhirClient);
|
|
3870
|
-
__privateAdd(this, _accesssToken, null);
|
|
3871
|
-
__privateAdd(this, _options2);
|
|
3872
|
-
__privateAdd(this, _clientId, "36615b3a-b71b-49af-a68b-4180daed7a5a");
|
|
3873
|
-
// ststestrunnernode
|
|
3874
|
-
__privateAdd(this, _clientSecret, "7fbbf116-0537-424b-904f-d8d0a62adf9e");
|
|
3875
|
-
__privateAdd(this, _GetAccessToken, async () => {
|
|
3876
|
-
if (!__privateGet(this, _accesssToken)) {
|
|
3877
|
-
const api = "api://fb6513e4-16fe-4931-bed8-33b82b404a14";
|
|
3878
|
-
const resource = "Person";
|
|
3879
|
-
const stsFhirApiPrefix = "stsfhir5";
|
|
3880
|
-
const scopes = `${api}/${resource}.${stsFhirApiPrefix}:Create${resource} ${api}/${resource}.${stsFhirApiPrefix}:Get${resource}s ${api}/${resource}.${stsFhirApiPrefix}:Update${resource}s ${api}/${resource}.${stsFhirApiPrefix}:Patch${resource}s ${api}/${resource}.${stsFhirApiPrefix}:Delete${resource}s ${api}/${resource}/*.${stsFhirApiPrefix}:Get${resource} ${api}/${resource}/*.${stsFhirApiPrefix}:Update${resource} ${api}/${resource}/*.${stsFhirApiPrefix}:Patch${resource} ${api}/${resource}/*.${stsFhirApiPrefix}:Delete${resource}`.split(" ").sort().join(" ");
|
|
3881
|
-
__privateSet(this, _accesssToken, await __privateGet(this, _options2).authUtilsNode.GetAPITokenFromAuthServerUsingScope({
|
|
3882
|
-
clientId: __privateGet(this, _clientId),
|
|
3883
|
-
authClientSecret: __privateGet(this, _clientSecret),
|
|
3884
|
-
scope: scopes,
|
|
3885
|
-
endPoint: __privateGet(this, _testHelper).authEndpoint
|
|
3886
|
-
}, (error) => __privateGet(this, _LogErrorMessage2).call(this, error)));
|
|
3887
|
-
await __privateGet(this, _options2).authUtilsNode.ValidateJWT(__privateGet(this, _accesssToken), "api://fb6513e4-16fe-4931-bed8-33b82b404a14", __privateGet(this, _testHelper).authEndpoint);
|
|
3888
|
-
}
|
|
3889
|
-
return __privateGet(this, _accesssToken);
|
|
3890
|
-
});
|
|
3891
|
-
__privateAdd(this, _LogDebugMessage2, (message) => {
|
|
3892
|
-
defaultLogger.debug(message);
|
|
3893
|
-
});
|
|
3894
|
-
__privateAdd(this, _LogErrorMessage2, (message) => {
|
|
3895
|
-
defaultLogger.error(message);
|
|
3896
|
-
});
|
|
3897
|
-
__privateAdd(this, _HandleError2, (error) => {
|
|
3898
|
-
__privateGet(this, _LogDebugMessage2).call(this, chalk$1.red(`HandleError(): Error: [${error}]`));
|
|
3899
|
-
});
|
|
3900
|
-
__privateAdd(this, _GetPersonRecord, (prefix, index) => {
|
|
3901
|
-
const id = `${prefix}${v4()}`;
|
|
3902
|
-
const personRecord = {
|
|
3903
|
-
id,
|
|
3904
|
-
_resourceType: "Person",
|
|
3905
|
-
name: [
|
|
3906
|
-
{
|
|
3907
|
-
family: `family ${index}`,
|
|
3908
|
-
given: [`given ${index}`],
|
|
3909
|
-
use: `usual`
|
|
3910
|
-
}
|
|
3911
|
-
],
|
|
3912
|
-
text: {
|
|
3913
|
-
div: `New Record ${index}`,
|
|
3914
|
-
status: "generated"
|
|
3915
|
-
}
|
|
3916
|
-
};
|
|
3917
|
-
return personRecord;
|
|
3918
|
-
});
|
|
3919
|
-
__privateAdd(this, _GetPersonRecordBatch, (prefix, iterations) => {
|
|
3920
|
-
const persons = [];
|
|
3921
|
-
for (let i = 0; i < iterations; i++) {
|
|
3922
|
-
persons.push(__privateGet(this, _GetPersonRecord).call(this, prefix, i));
|
|
3923
|
-
}
|
|
3924
|
-
return persons;
|
|
3925
|
-
});
|
|
3926
|
-
__publicField(this, "TestGetLatency", async () => {
|
|
3927
|
-
expect.assertions(1);
|
|
3928
|
-
try {
|
|
3929
|
-
const retVal = await __privateGet(this, _fhirClient).GetLatency();
|
|
3930
|
-
if (retVal) {
|
|
3931
|
-
expect(retVal.status).toEqual(200);
|
|
3932
|
-
}
|
|
3933
|
-
} catch (error) {
|
|
3934
|
-
__privateGet(this, _HandleError2).call(this, error);
|
|
3935
|
-
}
|
|
3936
|
-
});
|
|
3937
|
-
__publicField(this, "TestGetAccessToken", async () => {
|
|
3938
|
-
expect.assertions(1);
|
|
3939
|
-
try {
|
|
3940
|
-
const retVal = await __privateGet(this, _GetAccessToken).call(this);
|
|
3941
|
-
expect(retVal).not.toBeNull();
|
|
3942
|
-
} catch (error) {
|
|
3943
|
-
__privateGet(this, _HandleError2).call(this, error);
|
|
3944
|
-
}
|
|
3945
|
-
});
|
|
3946
|
-
__publicField(this, "CheckDuplicateErrorHandling", async () => {
|
|
3947
|
-
expect.assertions(2);
|
|
3948
|
-
const personRecord = __privateGet(this, _GetPersonRecord).call(this, "", 1);
|
|
3949
|
-
const retVal = await __privateGet(this, _fhirClient).CreateResource("Person", personRecord, (error) => {
|
|
3950
|
-
__privateGet(this, _LogErrorMessage2).call(this, chalk$1.red(`test(POST /stsresource): ${error}`));
|
|
3951
|
-
});
|
|
3952
|
-
expect(retVal).toMatchObject(personRecord);
|
|
3953
|
-
const retVal2 = await __privateGet(this, _fhirClient).CreateResource("Person", personRecord, (error) => {
|
|
3954
|
-
__privateGet(this, _LogErrorMessage2).call(this, chalk$1.red(`test(POST /stsresource): ${error}`));
|
|
3955
|
-
});
|
|
3956
|
-
expect(retVal2).toBeNull();
|
|
3957
|
-
});
|
|
3958
|
-
__publicField(this, "PostResources", async () => {
|
|
3959
|
-
const iterations = 10;
|
|
3960
|
-
expect.assertions(iterations);
|
|
3961
|
-
for (let i = 0; i < iterations; i++) {
|
|
3962
|
-
const personRecord = __privateGet(this, _GetPersonRecord).call(this, "", i);
|
|
3963
|
-
const retVal = await __privateGet(this, _fhirClient).CreateResource("Person", personRecord, (error) => {
|
|
3964
|
-
__privateGet(this, _LogErrorMessage2).call(this, chalk$1.red(`test(POST /stsresource): ${error}`));
|
|
3965
|
-
});
|
|
3966
|
-
expect(retVal).toMatchObject(personRecord);
|
|
3967
|
-
}
|
|
3968
|
-
});
|
|
3969
|
-
__publicField(this, "StandardCRUDOperations", async () => {
|
|
3970
|
-
expect.assertions(8);
|
|
3971
|
-
let personRecord = __privateGet(this, _GetPersonRecord).call(this, "", 1);
|
|
3972
|
-
let retVal = await __privateGet(this, _fhirClient).CreateResource("Person", personRecord, (error) => {
|
|
3973
|
-
__privateGet(this, _LogErrorMessage2).call(this, chalk$1.red(`test(PostResource): ${error}`));
|
|
3974
|
-
});
|
|
3975
|
-
expect(retVal).toMatchObject(personRecord);
|
|
3976
|
-
const retVal2 = await __privateGet(this, _fhirClient).CreateResource("Person", personRecord, (error) => {
|
|
3977
|
-
__privateGet(this, _LogErrorMessage2).call(this, chalk$1.red(`test(POST /stsresource): ${error}`));
|
|
3978
|
-
});
|
|
3979
|
-
expect(retVal2).toBeNull();
|
|
3980
|
-
personRecord.text.div = "user01 put updated at " + (/* @__PURE__ */ new Date()).toString();
|
|
3981
|
-
retVal = await __privateGet(this, _fhirClient).UpdateResource("Person", personRecord, (error) => {
|
|
3982
|
-
__privateGet(this, _LogErrorMessage2).call(this, chalk$1.red(`test(PutResource): ${error}`));
|
|
3983
|
-
});
|
|
3984
|
-
expect(retVal).toMatchObject(personRecord);
|
|
3985
|
-
const patchPersonRecord = {
|
|
3986
|
-
id: personRecord.id,
|
|
3987
|
-
text: {
|
|
3988
|
-
div: "user01 patched at " + (/* @__PURE__ */ new Date()).toString(),
|
|
3989
|
-
status: "generated"
|
|
3990
|
-
}
|
|
3991
|
-
};
|
|
3992
|
-
retVal = await __privateGet(this, _fhirClient).PatchResource("Person", patchPersonRecord, (error) => {
|
|
3993
|
-
__privateGet(this, _LogErrorMessage2).call(this, chalk$1.red(`test(PatchResource): ${error}`));
|
|
3994
|
-
});
|
|
3995
|
-
personRecord = Object.assign({}, personRecord, patchPersonRecord);
|
|
3996
|
-
expect(retVal).toMatchObject(personRecord);
|
|
3997
|
-
retVal = await __privateGet(this, _fhirClient).GetResource("Person", personRecord.id, null, (error) => {
|
|
3998
|
-
__privateGet(this, _LogErrorMessage2).call(this, chalk$1.red(`test(GetResource): ${error}`));
|
|
3999
|
-
});
|
|
4000
|
-
expect(retVal).toMatchObject(personRecord);
|
|
4001
|
-
retVal = await __privateGet(this, _fhirClient).GetResource("Person", "willnotfind", null, (error) => {
|
|
4002
|
-
__privateGet(this, _LogErrorMessage2).call(this, chalk$1.red(`test(GetResource will not find): ${error}`));
|
|
4003
|
-
});
|
|
4004
|
-
expect(retVal).toBeNull();
|
|
4005
|
-
retVal = await __privateGet(this, _fhirClient).DeleteResource("Person", personRecord.id, (error) => {
|
|
4006
|
-
__privateGet(this, _LogErrorMessage2).call(this, chalk$1.red(`test(DeleteResource): ${error}`));
|
|
4007
|
-
});
|
|
4008
|
-
expect(retVal).toMatchObject(personRecord);
|
|
4009
|
-
retVal = await __privateGet(this, _fhirClient).GetResource("Person", personRecord.id, null, (error) => {
|
|
4010
|
-
__privateGet(this, _LogErrorMessage2).call(this, chalk$1.red(`test(GetResource after delete): ${error}`));
|
|
4011
|
-
});
|
|
4012
|
-
expect(retVal).toBeNull();
|
|
4013
|
-
});
|
|
4014
|
-
__publicField(this, "PostAndQuery", async () => {
|
|
4015
|
-
const iterations = 10;
|
|
4016
|
-
const personPrefix = `_${v4().replaceAll("-", "_")}_`;
|
|
4017
|
-
expect.assertions(3 + 2 * iterations);
|
|
4018
|
-
for (let i = 0; i < iterations; i++) {
|
|
4019
|
-
const personRecord = __privateGet(this, _GetPersonRecord).call(this, `${personPrefix}s1_`, i);
|
|
4020
|
-
const retVal2 = await __privateGet(this, _fhirClient).CreateResource("Person", personRecord, (error) => {
|
|
4021
|
-
__privateGet(this, _LogErrorMessage2).call(this, chalk$1.red(`test(POST /stsresource and query using filter): ${error}`));
|
|
4022
|
-
});
|
|
4023
|
-
expect(retVal2).toMatchObject(personRecord);
|
|
4024
|
-
}
|
|
4025
|
-
for (let i = 0; i < iterations; i++) {
|
|
4026
|
-
const personRecord = __privateGet(this, _GetPersonRecord).call(this, `${personPrefix}s2_`, i);
|
|
4027
|
-
const retVal2 = await __privateGet(this, _fhirClient).CreateResource("Person", personRecord, (error) => {
|
|
4028
|
-
__privateGet(this, _LogErrorMessage2).call(this, chalk$1.red(`test(POST /stsresource and query using filter): ${error}`));
|
|
4029
|
-
});
|
|
4030
|
-
expect(retVal2).toMatchObject(personRecord);
|
|
4031
|
-
}
|
|
4032
|
-
let retVal = await __privateGet(this, _fhirClient).GetResources("Person", [`${personPrefix}`], (error) => {
|
|
4033
|
-
__privateGet(this, _LogErrorMessage2).call(this, chalk$1.red(`test(POST /stsresource and query using filter): ${error}`));
|
|
4034
|
-
});
|
|
4035
|
-
if (retVal) {
|
|
4036
|
-
expect(retVal.length).toEqual(iterations * 2);
|
|
4037
|
-
}
|
|
4038
|
-
retVal = await __privateGet(this, _fhirClient).GetResources("Person", [`${personPrefix}s1_`], (error) => {
|
|
4039
|
-
__privateGet(this, _LogErrorMessage2).call(this, chalk$1.red(`test(POST /stsresource and query using filter): ${error}`));
|
|
4040
|
-
});
|
|
4041
|
-
if (retVal) {
|
|
4042
|
-
expect(retVal.length).toEqual(iterations);
|
|
4043
|
-
}
|
|
4044
|
-
retVal = await __privateGet(this, _fhirClient).GetResources("Person", [`${personPrefix}s2_`, `${personPrefix}s1_`], (error) => {
|
|
4045
|
-
__privateGet(this, _LogErrorMessage2).call(this, chalk$1.red(`test(POST /stsresource and query using filter): ${error}`));
|
|
4046
|
-
});
|
|
4047
|
-
if (retVal) {
|
|
4048
|
-
expect(retVal.length).toEqual(iterations * 2);
|
|
4049
|
-
}
|
|
4050
|
-
});
|
|
4051
|
-
__publicField(this, "BatchMethods", async () => {
|
|
4052
|
-
const iterations = 10;
|
|
4053
|
-
const personPrefix = `_${v4().replaceAll("-", "_")}_`;
|
|
4054
|
-
expect.assertions(11);
|
|
4055
|
-
const personRecords = __privateGet(this, _GetPersonRecordBatch).call(this, `${personPrefix}`, 10);
|
|
4056
|
-
let stepMessage = `Resource list after put (batch create) resources`;
|
|
4057
|
-
let retVal = await __privateGet(this, _fhirClient).UpdateResources("Person", personRecords, (error) => {
|
|
4058
|
-
__privateGet(this, _LogErrorMessage2).call(this, chalk$1.red(`test(${stepMessage}): ${error}`));
|
|
4059
|
-
});
|
|
4060
|
-
if (retVal) {
|
|
4061
|
-
expect(retVal.length).toEqual(iterations);
|
|
4062
|
-
expect(retVal).toMatchObject(personRecords);
|
|
4063
|
-
}
|
|
4064
|
-
for (let i = 0; i < iterations; i++) {
|
|
4065
|
-
personRecords[i].text = {
|
|
4066
|
-
div: `user${i} updated at ` + (/* @__PURE__ */ new Date()).toString(),
|
|
4067
|
-
status: "extensions"
|
|
4068
|
-
};
|
|
4069
|
-
}
|
|
4070
|
-
stepMessage = `Resource list after put (update) resources`;
|
|
4071
|
-
retVal = await __privateGet(this, _fhirClient).UpdateResources("Person", personRecords, (error) => {
|
|
4072
|
-
__privateGet(this, _LogErrorMessage2).call(this, chalk$1.red(`test(${stepMessage}): ${error}`));
|
|
4073
|
-
});
|
|
4074
|
-
if (retVal) {
|
|
4075
|
-
expect(retVal.length).toEqual(iterations);
|
|
4076
|
-
expect(retVal).toMatchObject(personRecords);
|
|
4077
|
-
}
|
|
4078
|
-
const patchRecords = [];
|
|
4079
|
-
for (let i = 0; i < iterations; i++) {
|
|
4080
|
-
const updateTextObject = {
|
|
4081
|
-
div: `user${i} patched at ` + (/* @__PURE__ */ new Date()).toString(),
|
|
4082
|
-
status: "extensions"
|
|
4083
|
-
};
|
|
4084
|
-
patchRecords.push({
|
|
4085
|
-
id: personRecords[i].id,
|
|
4086
|
-
text: updateTextObject
|
|
4087
|
-
});
|
|
4088
|
-
personRecords[i].text = updateTextObject;
|
|
4089
|
-
}
|
|
4090
|
-
stepMessage = `Resource list after patch resources`;
|
|
4091
|
-
retVal = await __privateGet(this, _fhirClient).PatchResources("Person", patchRecords, (error) => {
|
|
4092
|
-
__privateGet(this, _LogErrorMessage2).call(this, chalk$1.red(`test(${stepMessage}): ${error}`));
|
|
4093
|
-
});
|
|
4094
|
-
if (retVal) {
|
|
4095
|
-
expect(retVal.length).toEqual(iterations);
|
|
4096
|
-
expect(retVal).toMatchObject(personRecords);
|
|
4097
|
-
}
|
|
4098
|
-
stepMessage = `Resource list before deleted resources`;
|
|
4099
|
-
retVal = await __privateGet(this, _fhirClient).GetResources("Person", [`${personPrefix}`], (error) => {
|
|
4100
|
-
__privateGet(this, _LogErrorMessage2).call(this, chalk$1.red(`test(${stepMessage}): ${error}`));
|
|
4101
|
-
});
|
|
4102
|
-
if (retVal) {
|
|
4103
|
-
expect(retVal.length).toEqual(iterations);
|
|
4104
|
-
}
|
|
4105
|
-
const remainingPersonRecords = personRecords.splice(5);
|
|
4106
|
-
stepMessage = `Resource list of deleted resources`;
|
|
4107
|
-
retVal = await __privateGet(this, _fhirClient).DeleteResources("Person", personRecords, (error) => {
|
|
4108
|
-
__privateGet(this, _LogErrorMessage2).call(this, chalk$1.red(`test(${stepMessage}): ${error}`));
|
|
4109
|
-
});
|
|
4110
|
-
if (retVal) {
|
|
4111
|
-
expect(retVal.length).toEqual(5);
|
|
4112
|
-
retVal.sort((a, b) => a.id.localeCompare(b.id));
|
|
4113
|
-
personRecords.sort((a, b) => a.id.localeCompare(b.id));
|
|
4114
|
-
expect(retVal).toMatchObject(personRecords);
|
|
4115
|
-
}
|
|
4116
|
-
stepMessage = `Resource list after partial deletes`;
|
|
4117
|
-
retVal = await __privateGet(this, _fhirClient).GetResources("Person", [`${personPrefix}`], (error) => {
|
|
4118
|
-
__privateGet(this, _LogErrorMessage2).call(this, chalk$1.red(`test(${stepMessage}): ${error}`));
|
|
4119
|
-
});
|
|
4120
|
-
if (retVal) {
|
|
4121
|
-
expect(retVal.length).toEqual(5);
|
|
4122
|
-
retVal.sort((a, b) => a.id.localeCompare(b.id));
|
|
4123
|
-
remainingPersonRecords.sort((a, b) => a.id.localeCompare(b.id));
|
|
4124
|
-
expect(retVal).toMatchObject(remainingPersonRecords);
|
|
4125
|
-
}
|
|
4126
|
-
});
|
|
4127
|
-
__privateSet(this, _options2, options);
|
|
4128
|
-
__privateSet(this, _testHelper, options.testHelper);
|
|
4129
|
-
__privateSet(this, _fhirClient, new FhirClient({
|
|
4130
|
-
fhirEndpoint: __privateGet(this, _endpoint),
|
|
4131
|
-
logger: defaultLogger,
|
|
4132
|
-
publishInstrumentController: null,
|
|
4133
|
-
// options.stsApp.InstrumentController,
|
|
4134
|
-
testingMode: true,
|
|
4135
|
-
GetAccessToken: () => {
|
|
4136
|
-
return __privateGet(this, _GetAccessToken).call(this);
|
|
4137
|
-
},
|
|
4138
|
-
ResetAccessToken: () => {
|
|
4139
|
-
__privateSet(this, _accesssToken, null);
|
|
4140
|
-
}
|
|
4141
|
-
}));
|
|
4142
|
-
}
|
|
4143
|
-
}
|
|
4144
|
-
_testHelper = new WeakMap();
|
|
4145
|
-
_endpoint = new WeakMap();
|
|
4146
|
-
_fhirClient = new WeakMap();
|
|
4147
|
-
_accesssToken = new WeakMap();
|
|
4148
|
-
_options2 = new WeakMap();
|
|
4149
|
-
_clientId = new WeakMap();
|
|
4150
|
-
_clientSecret = new WeakMap();
|
|
4151
|
-
_GetAccessToken = new WeakMap();
|
|
4152
|
-
_LogDebugMessage2 = new WeakMap();
|
|
4153
|
-
_LogErrorMessage2 = new WeakMap();
|
|
4154
|
-
_HandleError2 = new WeakMap();
|
|
4155
|
-
_GetPersonRecord = new WeakMap();
|
|
4156
|
-
_GetPersonRecordBatch = new WeakMap();
|
|
4157
|
-
class STSFhirControllerTestCasesDirect {
|
|
4158
|
-
constructor(options) {
|
|
4159
|
-
__publicField(this, "timeoutVal", 5e3);
|
|
4160
|
-
__privateAdd(this, _testHelper2);
|
|
4161
|
-
__privateAdd(this, _authUtilsNode);
|
|
4162
|
-
__publicField(this, "endpoint", "https://localhost");
|
|
4163
|
-
__publicField(this, "DUMMY_USER", "USR_user01@stsmda.com.au");
|
|
4164
|
-
__publicField(this, "LogDebugMessage", (message) => {
|
|
4165
|
-
defaultLogger.debug(message);
|
|
4166
|
-
});
|
|
4167
|
-
__publicField(this, "LogErrorMessage", (message) => {
|
|
4168
|
-
defaultLogger.error(message);
|
|
4169
|
-
});
|
|
4170
|
-
__publicField(this, "HandleError", (error) => {
|
|
4171
|
-
this.LogDebugMessage(chalk$1.red(`HandleError(): Error: [${error}]`));
|
|
4172
|
-
let responseCode = 500;
|
|
4173
|
-
if (axios.isAxiosError(error)) {
|
|
4174
|
-
const axiosError = error;
|
|
4175
|
-
if (axiosError.response) {
|
|
4176
|
-
responseCode = axiosError.response.status;
|
|
4177
|
-
this.LogDebugMessage(chalk$1.red(`AXIOS Error Response.Status = [${axiosError.response.status}]`));
|
|
4178
|
-
if (axiosError.response.headers) {
|
|
4179
|
-
this.LogErrorMessage(chalk$1.red(` headers: [${JSON.stringify(axiosError.response.headers)}]`));
|
|
4180
|
-
}
|
|
4181
|
-
if (axiosError.response.data) {
|
|
4182
|
-
this.LogErrorMessage(chalk$1.red(` data: [${JSON.stringify(axiosError.response.data)}]`));
|
|
4183
|
-
}
|
|
4184
|
-
try {
|
|
4185
|
-
if (axiosError.response.config) {
|
|
4186
|
-
this.LogErrorMessage(chalk$1.red(` config: [${JSON.stringify(axiosError.response.config)}]`));
|
|
4187
|
-
}
|
|
4188
|
-
} catch (innererror) {
|
|
4189
|
-
this.LogErrorMessage(chalk$1.red(` could not get response config, error: [${innererror}]`));
|
|
4190
|
-
}
|
|
4191
|
-
} else {
|
|
4192
|
-
this.LogDebugMessage(chalk$1.red(`AXIOS Error = [${axiosError}]`));
|
|
4193
|
-
}
|
|
4194
|
-
}
|
|
4195
|
-
return responseCode;
|
|
4196
|
-
});
|
|
4197
|
-
__publicField(this, "GetAccessToken", async () => {
|
|
4198
|
-
const api = "api://fb6513e4-16fe-4931-bed8-33b82b404a14";
|
|
4199
|
-
const resource = "Person";
|
|
4200
|
-
const stsFhirApiPrefix = "stsfhir5";
|
|
4201
|
-
const scopes = `${api}/${resource}.${stsFhirApiPrefix}:Create${resource} ${api}/${resource}.${stsFhirApiPrefix}:Get${resource}s ${api}/${resource}.${stsFhirApiPrefix}:Update${resource}s ${api}/${resource}.${stsFhirApiPrefix}:Patch${resource}s ${api}/${resource}.${stsFhirApiPrefix}:Delete${resource}s ${api}/${resource}/*.${stsFhirApiPrefix}:Get${resource} ${api}/${resource}/*.${stsFhirApiPrefix}:Update${resource} ${api}/${resource}/*.${stsFhirApiPrefix}:Patch${resource} ${api}/${resource}/*.${stsFhirApiPrefix}:Delete${resource}`.split(" ").sort().join(" ");
|
|
4202
|
-
return await __privateGet(this, _authUtilsNode).GetAPITokenFromAuthServerUsingScope({
|
|
4203
|
-
clientId: "36615b3a-b71b-49af-a68b-4180daed7a5a",
|
|
4204
|
-
// ststestrunnernode
|
|
4205
|
-
authClientSecret: "7fbbf116-0537-424b-904f-d8d0a62adf9e",
|
|
4206
|
-
// ststestrunnernode password
|
|
4207
|
-
scope: scopes,
|
|
4208
|
-
endPoint: __privateGet(this, _testHelper2).authEndpoint
|
|
4209
|
-
}, (error) => this.LogErrorMessage(error));
|
|
4210
|
-
});
|
|
4211
|
-
__publicField(this, "__UpdateGeneric", async (url, httpVerb, accesss_token, domainResource, filters, errorCb) => {
|
|
4212
|
-
try {
|
|
4213
|
-
const headers = {
|
|
4214
|
-
"Content-Type": "application/json",
|
|
4215
|
-
"Authorization": "Bearer " + accesss_token,
|
|
4216
|
-
"x-sts_user_id": this.DUMMY_USER
|
|
4217
|
-
};
|
|
4218
|
-
const requestConfig = {
|
|
4219
|
-
url,
|
|
4220
|
-
method: httpVerb,
|
|
4221
|
-
headers,
|
|
4222
|
-
httpsAgent: __privateGet(this, _testHelper2).getHttpsAgent
|
|
4223
|
-
};
|
|
4224
|
-
if (filters) {
|
|
4225
|
-
requestConfig.data = filters;
|
|
4226
|
-
} else if (domainResource) {
|
|
4227
|
-
requestConfig.data = domainResource;
|
|
4228
|
-
}
|
|
4229
|
-
const retVal = await axios(requestConfig);
|
|
4230
|
-
return retVal;
|
|
4231
|
-
} catch (error) {
|
|
4232
|
-
this.HandleError(error);
|
|
4233
|
-
errorCb(error);
|
|
4234
|
-
return null;
|
|
4235
|
-
}
|
|
4236
|
-
});
|
|
4237
|
-
__publicField(this, "__UpdateResource", async (url, httpVerb, accesss_token, domainResource, filters, errorCb) => {
|
|
4238
|
-
return this.__UpdateGeneric(url, httpVerb, accesss_token, domainResource, filters, errorCb);
|
|
4239
|
-
});
|
|
4240
|
-
__publicField(this, "PostResource", async (accesss_token, resource, domainResource, errorCb) => {
|
|
4241
|
-
const url = `${this.endpoint}:${goptions.stsfhirport}${goptions.stsfhirapiroot}/${resource}`;
|
|
4242
|
-
return this.__UpdateResource(url, "post", accesss_token, domainResource, null, errorCb);
|
|
4243
|
-
});
|
|
4244
|
-
__publicField(this, "PutResource", async (accesss_token, resource, domainResource, errorCb) => {
|
|
4245
|
-
const url = `${this.endpoint}:${goptions.stsfhirport}${goptions.stsfhirapiroot}/${resource}/${domainResource.id}`;
|
|
4246
|
-
return this.__UpdateResource(url, "put", accesss_token, domainResource, null, errorCb);
|
|
4247
|
-
});
|
|
4248
|
-
__publicField(this, "PutResources", async (accesss_token, resource, domainResources, errorCb) => {
|
|
4249
|
-
const url = `${this.endpoint}:${goptions.stsfhirport}${goptions.stsfhirapiroot}/${resource}`;
|
|
4250
|
-
return this.__UpdateResource(url, "put", accesss_token, domainResources, null, errorCb);
|
|
4251
|
-
});
|
|
4252
|
-
__publicField(this, "PatchResource", async (accesss_token, resource, domainResource, errorCb) => {
|
|
4253
|
-
const url = `${this.endpoint}:${goptions.stsfhirport}${goptions.stsfhirapiroot}/${resource}/${domainResource.id}`;
|
|
4254
|
-
return this.__UpdateResource(url, "patch", accesss_token, domainResource, null, errorCb);
|
|
4255
|
-
});
|
|
4256
|
-
__publicField(this, "PatchResources", async (accesss_token, resource, domainResources, errorCb) => {
|
|
4257
|
-
const url = `${this.endpoint}:${goptions.stsfhirport}${goptions.stsfhirapiroot}/${resource}`;
|
|
4258
|
-
return this.__UpdateResource(url, "patch", accesss_token, domainResources, null, errorCb);
|
|
4259
|
-
});
|
|
4260
|
-
__publicField(this, "GetResource", async (accesss_token, resource, id, filters, errorCb) => {
|
|
4261
|
-
const url = `${this.endpoint}:${goptions.stsfhirport}${goptions.stsfhirapiroot}/${resource}/${id}`;
|
|
4262
|
-
return this.__UpdateResource(url, "get", accesss_token, null, filters, errorCb);
|
|
4263
|
-
});
|
|
4264
|
-
__publicField(this, "DeleteResource", async (accesss_token, resource, id, errorCb) => {
|
|
4265
|
-
const url = `${this.endpoint}:${goptions.stsfhirport}${goptions.stsfhirapiroot}/${resource}/${id}`;
|
|
4266
|
-
return this.__UpdateResource(url, "delete", accesss_token, null, null, errorCb);
|
|
4267
|
-
});
|
|
4268
|
-
__publicField(this, "DeleteResources", async (accesss_token, resource, domainResources, errorCb) => {
|
|
4269
|
-
const url = `${this.endpoint}:${goptions.stsfhirport}${goptions.stsfhirapiroot}/${resource}`;
|
|
4270
|
-
return this.__UpdateResource(url, "delete", accesss_token, domainResources, null, errorCb);
|
|
4271
|
-
});
|
|
4272
|
-
__publicField(this, "GetResources", async (accesss_token, resource, filters, errorCb) => {
|
|
4273
|
-
const url = `${this.endpoint}:${goptions.stsfhirport}${goptions.stsfhirapiroot}/${resource}`;
|
|
4274
|
-
return this.__UpdateResource(url, "get", accesss_token, null, filters, errorCb);
|
|
4275
|
-
});
|
|
4276
|
-
__publicField(this, "CheckResourceMetaData", (response, status, checkData) => {
|
|
4277
|
-
expect(response.status).toEqual(status);
|
|
4278
|
-
const returnData = response.data;
|
|
4279
|
-
expect(returnData).toMatchObject(checkData);
|
|
4280
|
-
});
|
|
4281
|
-
__publicField(this, "GetPersonRecord", (prefix, index) => {
|
|
4282
|
-
const id = `${prefix}${v4()}`;
|
|
4283
|
-
const personRecord = {
|
|
4284
|
-
id,
|
|
4285
|
-
_resourceType: "Person",
|
|
4286
|
-
name: [
|
|
4287
|
-
{
|
|
4288
|
-
family: `family ${index}`,
|
|
4289
|
-
given: [`given ${index}`],
|
|
4290
|
-
use: `usual`
|
|
4291
|
-
}
|
|
4292
|
-
],
|
|
4293
|
-
text: {
|
|
4294
|
-
div: `New Record ${index}`,
|
|
4295
|
-
status: "generated"
|
|
4296
|
-
}
|
|
4297
|
-
};
|
|
4298
|
-
return personRecord;
|
|
4299
|
-
});
|
|
4300
|
-
__publicField(this, "GetPersonRecordBatch", (prefix, iterations) => {
|
|
4301
|
-
const persons = [];
|
|
4302
|
-
for (let i = 0; i < iterations; i++) {
|
|
4303
|
-
persons.push(this.GetPersonRecord(prefix, i));
|
|
4304
|
-
}
|
|
4305
|
-
return persons;
|
|
4306
|
-
});
|
|
4307
|
-
__publicField(this, "TestGetLatency", async () => {
|
|
4308
|
-
expect.assertions(1);
|
|
4309
|
-
const url = `${this.endpoint}:${goptions.stsfhirport}${goptions.stsfhirapiroot}/latency`;
|
|
4310
|
-
try {
|
|
4311
|
-
const headers = {
|
|
4312
|
-
"Content-Type": "application/json"
|
|
4313
|
-
};
|
|
4314
|
-
const retVal = await axios({
|
|
4315
|
-
url,
|
|
4316
|
-
method: "get",
|
|
4317
|
-
headers,
|
|
4318
|
-
httpsAgent: __privateGet(this, _testHelper2).getHttpsAgent
|
|
4319
|
-
});
|
|
4320
|
-
expect(retVal.status).toEqual(200);
|
|
4321
|
-
} catch (error) {
|
|
4322
|
-
this.HandleError(error);
|
|
4323
|
-
}
|
|
4324
|
-
});
|
|
4325
|
-
__publicField(this, "GetAPITokenFromAuthServer", async () => {
|
|
4326
|
-
expect.assertions(1);
|
|
4327
|
-
const accesss_token = await this.GetAccessToken();
|
|
4328
|
-
await __privateGet(this, _authUtilsNode).ValidateJWT(accesss_token, "api://fb6513e4-16fe-4931-bed8-33b82b404a14", __privateGet(this, _testHelper2).authEndpoint);
|
|
4329
|
-
await Sleep(200);
|
|
4330
|
-
console.log(chalk$1.rgb(255, 204, 255)(`Access Token: [${accesss_token}]`));
|
|
4331
|
-
console.log(chalk$1.rgb(255, 204, 255)(`Access Token Size: [${accesss_token.length}]`));
|
|
4332
|
-
expect(1).toEqual(1);
|
|
4333
|
-
});
|
|
4334
|
-
__publicField(this, "CheckDuplicateErrorHandling", async () => {
|
|
4335
|
-
expect.assertions(4);
|
|
4336
|
-
const accesss_token = await this.GetAccessToken();
|
|
4337
|
-
expect(accesss_token).not.toEqual("");
|
|
4338
|
-
const personRecord = this.GetPersonRecord("", 1);
|
|
4339
|
-
const retVal = await this.PostResource(accesss_token, "Person", personRecord, (error) => {
|
|
4340
|
-
this.LogErrorMessage(chalk$1.red(`test(POST /stsresource): ${error}`));
|
|
4341
|
-
});
|
|
4342
|
-
if (retVal) {
|
|
4343
|
-
this.CheckResourceMetaData(retVal, 201, personRecord);
|
|
4344
|
-
}
|
|
4345
|
-
const retVal2 = await this.PostResource(accesss_token, "Person", personRecord, (error) => {
|
|
4346
|
-
this.LogErrorMessage(chalk$1.red(`test(POST /stsresource): ${error}`));
|
|
4347
|
-
});
|
|
4348
|
-
expect(retVal2).toBeNull();
|
|
4349
|
-
});
|
|
4350
|
-
__publicField(this, "PostResources", async () => {
|
|
4351
|
-
const iterations = 10;
|
|
4352
|
-
expect.assertions(1 + 2 * iterations);
|
|
4353
|
-
const accesss_token = await this.GetAccessToken();
|
|
4354
|
-
expect(accesss_token).not.toEqual("");
|
|
4355
|
-
for (let i = 0; i < iterations; i++) {
|
|
4356
|
-
const personRecord = this.GetPersonRecord("", i);
|
|
4357
|
-
const retVal = await this.PostResource(accesss_token, "Person", personRecord, (error) => {
|
|
4358
|
-
this.LogErrorMessage(chalk$1.red(`test(POST /stsresource): ${error}`));
|
|
4359
|
-
});
|
|
4360
|
-
if (retVal) {
|
|
4361
|
-
this.CheckResourceMetaData(retVal, 201, personRecord);
|
|
4362
|
-
}
|
|
4363
|
-
}
|
|
4364
|
-
});
|
|
4365
|
-
__publicField(this, "StandardCRUDOperations", async () => {
|
|
4366
|
-
expect.assertions(15);
|
|
4367
|
-
const accesss_token = await this.GetAccessToken();
|
|
4368
|
-
expect(accesss_token).not.toEqual("");
|
|
4369
|
-
let personRecord = this.GetPersonRecord("", 1);
|
|
4370
|
-
let retVal = await this.PostResource(accesss_token, "Person", personRecord, (error) => {
|
|
4371
|
-
this.LogErrorMessage(chalk$1.red(`test(PostResource): ${error}`));
|
|
4372
|
-
});
|
|
4373
|
-
if (retVal) {
|
|
4374
|
-
this.CheckResourceMetaData(retVal, 201, personRecord);
|
|
4375
|
-
}
|
|
4376
|
-
retVal = await this.PostResource(accesss_token, "Person", personRecord, (error) => {
|
|
4377
|
-
this.LogErrorMessage(chalk$1.red(`test(PostResource duplicate): ${error}`));
|
|
4378
|
-
const responseCode = this.HandleError(error);
|
|
4379
|
-
expect(responseCode).toEqual(StatusCodes.CONFLICT);
|
|
4380
|
-
});
|
|
4381
|
-
expect(retVal).toBeNull();
|
|
4382
|
-
personRecord.text.div = "user01 put updated at " + (/* @__PURE__ */ new Date()).toString();
|
|
4383
|
-
retVal = await this.PutResource(accesss_token, "Person", personRecord, (error) => {
|
|
4384
|
-
this.LogErrorMessage(chalk$1.red(`test(PutResource): ${error}`));
|
|
4385
|
-
});
|
|
4386
|
-
if (retVal) {
|
|
4387
|
-
this.CheckResourceMetaData(retVal, 200, personRecord);
|
|
4388
|
-
}
|
|
4389
|
-
const patchPersonRecord = {
|
|
4390
|
-
id: personRecord.id,
|
|
4391
|
-
text: {
|
|
4392
|
-
div: "user01 patched at " + (/* @__PURE__ */ new Date()).toString(),
|
|
4393
|
-
status: "generated"
|
|
4394
|
-
}
|
|
4395
|
-
};
|
|
4396
|
-
retVal = await this.PatchResource(accesss_token, "Person", patchPersonRecord, (error) => {
|
|
4397
|
-
this.LogErrorMessage(chalk$1.red(`test(PatchResource): ${error}`));
|
|
4398
|
-
});
|
|
4399
|
-
personRecord = Object.assign({}, personRecord, patchPersonRecord);
|
|
4400
|
-
if (retVal) {
|
|
4401
|
-
this.CheckResourceMetaData(retVal, 200, personRecord);
|
|
4402
|
-
}
|
|
4403
|
-
retVal = await this.GetResource(accesss_token, "Person", personRecord.id, null, (error) => {
|
|
4404
|
-
this.LogErrorMessage(chalk$1.red(`test(GetResource): ${error}`));
|
|
4405
|
-
});
|
|
4406
|
-
if (retVal) {
|
|
4407
|
-
this.CheckResourceMetaData(retVal, 200, personRecord);
|
|
4408
|
-
}
|
|
4409
|
-
retVal = await this.GetResource(accesss_token, "Person", "willnotfind", null, (error) => {
|
|
4410
|
-
this.LogErrorMessage(chalk$1.red(`test(GetResource will not find): ${error}`));
|
|
4411
|
-
});
|
|
4412
|
-
expect(retVal).toBeNull();
|
|
4413
|
-
retVal = await this.DeleteResource(accesss_token, "Person", personRecord.id, (error) => {
|
|
4414
|
-
this.LogErrorMessage(chalk$1.red(`test(DeleteResource): ${error}`));
|
|
4415
|
-
});
|
|
4416
|
-
if (retVal) {
|
|
4417
|
-
this.CheckResourceMetaData(retVal, 200, personRecord);
|
|
4418
|
-
}
|
|
4419
|
-
retVal = await this.GetResource(accesss_token, "Person", personRecord.id, null, (error) => {
|
|
4420
|
-
this.LogErrorMessage(chalk$1.red(`test(GetResource after delete): ${error}`));
|
|
4421
|
-
});
|
|
4422
|
-
expect(retVal).toBeNull();
|
|
4423
|
-
});
|
|
4424
|
-
__publicField(this, "PostAndQuery", async () => {
|
|
4425
|
-
const iterations = 10;
|
|
4426
|
-
const personPrefix = `_${v4().replaceAll("-", "_")}_`;
|
|
4427
|
-
expect.assertions(4 + 4 * iterations);
|
|
4428
|
-
const accesss_token = await this.GetAccessToken();
|
|
4429
|
-
expect(accesss_token).not.toEqual("");
|
|
4430
|
-
for (let i = 0; i < iterations; i++) {
|
|
4431
|
-
const personRecord = this.GetPersonRecord(`${personPrefix}s1_`, i);
|
|
4432
|
-
const retVal2 = await this.PostResource(accesss_token, "Person", personRecord, (error) => {
|
|
4433
|
-
this.LogErrorMessage(chalk$1.red(`test(POST /stsresource and query using filter): ${error}`));
|
|
4434
|
-
});
|
|
4435
|
-
if (retVal2) {
|
|
4436
|
-
this.CheckResourceMetaData(retVal2, 201, personRecord);
|
|
4437
|
-
}
|
|
4438
|
-
}
|
|
4439
|
-
for (let i = 0; i < iterations; i++) {
|
|
4440
|
-
const personRecord = this.GetPersonRecord(`${personPrefix}s2_`, i);
|
|
4441
|
-
const retVal2 = await this.PostResource(accesss_token, "Person", personRecord, (error) => {
|
|
4442
|
-
this.LogErrorMessage(chalk$1.red(`test(POST /stsresource and query using filter): ${error}`));
|
|
4443
|
-
});
|
|
4444
|
-
if (retVal2) {
|
|
4445
|
-
this.CheckResourceMetaData(retVal2, 201, personRecord);
|
|
4446
|
-
}
|
|
4447
|
-
}
|
|
4448
|
-
let retVal = await this.GetResources(accesss_token, "Person", [`${personPrefix}`], (error) => {
|
|
4449
|
-
this.LogErrorMessage(chalk$1.red(`test(POST /stsresource and query using filter): ${error}`));
|
|
4450
|
-
});
|
|
4451
|
-
if (retVal) {
|
|
4452
|
-
console.log(retVal.data);
|
|
4453
|
-
expect(retVal.data.length).toEqual(iterations * 2);
|
|
4454
|
-
}
|
|
4455
|
-
retVal = await this.GetResources(accesss_token, "Person", [`${personPrefix}s1_`], (error) => {
|
|
4456
|
-
this.LogErrorMessage(chalk$1.red(`test(POST /stsresource and query using filter): ${error}`));
|
|
4457
|
-
});
|
|
4458
|
-
if (retVal) {
|
|
4459
|
-
console.log(retVal.data);
|
|
4460
|
-
expect(retVal.data.length).toEqual(iterations);
|
|
4461
|
-
}
|
|
4462
|
-
retVal = await this.GetResources(accesss_token, "Person", [`${personPrefix}s2_`, `${personPrefix}s1_`], (error) => {
|
|
4463
|
-
this.LogErrorMessage(chalk$1.red(`test(POST /stsresource and query using filter): ${error}`));
|
|
4464
|
-
});
|
|
4465
|
-
if (retVal) {
|
|
4466
|
-
console.log(retVal.data);
|
|
4467
|
-
expect(retVal.data.length).toEqual(iterations * 2);
|
|
4468
|
-
}
|
|
4469
|
-
});
|
|
4470
|
-
__publicField(this, "BatchMethods", async () => {
|
|
4471
|
-
const iterations = 10;
|
|
4472
|
-
const personPrefix = `_${v4().replaceAll("-", "_")}_`;
|
|
4473
|
-
expect.assertions(15);
|
|
4474
|
-
const accesss_token = await this.GetAccessToken();
|
|
4475
|
-
expect(accesss_token).not.toEqual("");
|
|
4476
|
-
const personRecords = this.GetPersonRecordBatch(`${personPrefix}`, 10);
|
|
4477
|
-
let stepMessage = `Resource list after put (batch create) resources`;
|
|
4478
|
-
let retVal = await this.PutResources(accesss_token, "Person", personRecords, (error) => {
|
|
4479
|
-
this.LogErrorMessage(chalk$1.red(`test(${stepMessage}): ${error}`));
|
|
4480
|
-
});
|
|
4481
|
-
if (retVal) {
|
|
4482
|
-
console.log(chalk$1.yellow(stepMessage));
|
|
4483
|
-
console.log(retVal.data);
|
|
4484
|
-
expect(retVal.status).toEqual(StatusCodes.OK);
|
|
4485
|
-
expect(retVal.data.length).toEqual(iterations);
|
|
4486
|
-
expect(retVal.data).toMatchObject(personRecords);
|
|
4487
|
-
}
|
|
4488
|
-
for (let i = 0; i < iterations; i++) {
|
|
4489
|
-
personRecords[i].text = {
|
|
4490
|
-
div: `user${i} updated at ` + (/* @__PURE__ */ new Date()).toString(),
|
|
4491
|
-
status: "extensions"
|
|
4492
|
-
};
|
|
4493
|
-
}
|
|
4494
|
-
stepMessage = `Resource list after put (update) resources`;
|
|
4495
|
-
retVal = await this.PutResources(accesss_token, "Person", personRecords, (error) => {
|
|
4496
|
-
this.LogErrorMessage(chalk$1.red(`test(${stepMessage}): ${error}`));
|
|
4497
|
-
});
|
|
4498
|
-
if (retVal) {
|
|
4499
|
-
console.log(chalk$1.yellow(stepMessage));
|
|
4500
|
-
console.log(retVal.data);
|
|
4501
|
-
expect(retVal.status).toEqual(StatusCodes.OK);
|
|
4502
|
-
expect(retVal.data.length).toEqual(iterations);
|
|
4503
|
-
expect(retVal.data).toMatchObject(personRecords);
|
|
4504
|
-
}
|
|
4505
|
-
const patchRecords = [];
|
|
4506
|
-
for (let i = 0; i < iterations; i++) {
|
|
4507
|
-
const updateTextObject = {
|
|
4508
|
-
div: `user${i} patched at ` + (/* @__PURE__ */ new Date()).toString(),
|
|
4509
|
-
status: "extensions"
|
|
4510
|
-
};
|
|
4511
|
-
patchRecords.push({
|
|
4512
|
-
id: personRecords[i].id,
|
|
4513
|
-
text: updateTextObject
|
|
4514
|
-
});
|
|
4515
|
-
personRecords[i].text = updateTextObject;
|
|
4516
|
-
}
|
|
4517
|
-
stepMessage = `Resource list after patch resources`;
|
|
4518
|
-
retVal = await this.PatchResources(accesss_token, "Person", patchRecords, (error) => {
|
|
4519
|
-
this.LogErrorMessage(chalk$1.red(`test(${stepMessage}): ${error}`));
|
|
4520
|
-
});
|
|
4521
|
-
if (retVal) {
|
|
4522
|
-
console.log(chalk$1.yellow(stepMessage));
|
|
4523
|
-
console.log(retVal.data);
|
|
4524
|
-
expect(retVal.status).toEqual(StatusCodes.OK);
|
|
4525
|
-
expect(retVal.data.length).toEqual(iterations);
|
|
4526
|
-
expect(retVal.data).toMatchObject(personRecords);
|
|
4527
|
-
}
|
|
4528
|
-
stepMessage = `Resource list before deleted resources`;
|
|
4529
|
-
retVal = await this.GetResources(accesss_token, "Person", [`${personPrefix}`], (error) => {
|
|
4530
|
-
this.LogErrorMessage(chalk$1.red(`test(${stepMessage}): ${error}`));
|
|
4531
|
-
});
|
|
4532
|
-
if (retVal) {
|
|
4533
|
-
console.log(chalk$1.yellow(stepMessage));
|
|
4534
|
-
console.log(retVal.data);
|
|
4535
|
-
expect(retVal.data.length).toEqual(iterations);
|
|
4536
|
-
}
|
|
4537
|
-
personRecords.splice(5);
|
|
4538
|
-
stepMessage = `Resource list of deleted resources`;
|
|
4539
|
-
retVal = await this.DeleteResources(accesss_token, "Person", personRecords, (error) => {
|
|
4540
|
-
this.LogErrorMessage(chalk$1.red(`test(${stepMessage}): ${error}`));
|
|
4541
|
-
});
|
|
4542
|
-
if (retVal) {
|
|
4543
|
-
console.log(chalk$1.yellow(stepMessage));
|
|
4544
|
-
console.log(retVal.data);
|
|
4545
|
-
expect(retVal.status).toEqual(StatusCodes.OK);
|
|
4546
|
-
expect(retVal.data.length).toEqual(5);
|
|
4547
|
-
expect(retVal.data).toMatchObject(personRecords);
|
|
4548
|
-
}
|
|
4549
|
-
stepMessage = `Resource list after partial deletes`;
|
|
4550
|
-
retVal = await this.GetResources(accesss_token, "Person", [`${personPrefix}`], (error) => {
|
|
4551
|
-
this.LogErrorMessage(chalk$1.red(`test(${stepMessage}): ${error}`));
|
|
4552
|
-
});
|
|
4553
|
-
if (retVal) {
|
|
4554
|
-
console.log(chalk$1.yellow(stepMessage));
|
|
4555
|
-
console.log(retVal.data);
|
|
4556
|
-
expect(retVal.data.length).toEqual(5);
|
|
4557
|
-
}
|
|
4558
|
-
});
|
|
4559
|
-
__privateSet(this, _testHelper2, options.testHelper);
|
|
4560
|
-
__privateSet(this, _authUtilsNode, options.authUtilsNode);
|
|
4561
|
-
}
|
|
4562
|
-
}
|
|
4563
|
-
_testHelper2 = new WeakMap();
|
|
4564
|
-
_authUtilsNode = new WeakMap();
|
|
4565
3863
|
export {
|
|
4566
3864
|
FhirClient,
|
|
4567
|
-
IFhirPersistenceType
|
|
4568
|
-
STSFhirControllerTestCasesClient,
|
|
4569
|
-
STSFhirControllerTestCasesDirect
|
|
3865
|
+
IFhirPersistenceType
|
|
4570
3866
|
};
|
|
4571
3867
|
//# sourceMappingURL=stsfhirclient.mjs.map
|