@medplum/core 0.9.34 → 0.9.36
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/client.d.ts +15 -6
- package/dist/cjs/fhirlexer/index.d.ts +2 -0
- package/dist/cjs/fhirlexer/parse.d.ts +31 -0
- package/dist/cjs/fhirlexer/tokenize.d.ts +14 -0
- package/dist/cjs/fhirmapper/atoms.d.ts +67 -0
- package/dist/cjs/fhirmapper/parse.d.ts +7 -0
- package/dist/cjs/fhirmapper/tokenize.d.ts +2 -0
- package/dist/cjs/fhirpath/atoms.d.ts +2 -7
- package/dist/cjs/fhirpath/functions.d.ts +2 -1
- package/dist/cjs/fhirpath/parse.d.ts +8 -5
- package/dist/cjs/fhirpath/tokenize.d.ts +3 -4
- package/dist/cjs/fhirpath/utils.d.ts +1 -1
- package/dist/cjs/index.js +399 -311
- 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/cjs/searchparams.d.ts +1 -3
- package/dist/cjs/types.d.ts +18 -3
- package/dist/esm/client.d.ts +15 -6
- package/dist/esm/client.js +62 -48
- package/dist/esm/client.js.map +1 -1
- package/dist/esm/fhirlexer/index.d.ts +2 -0
- package/dist/esm/fhirlexer/parse.d.ts +31 -0
- package/dist/esm/fhirlexer/parse.js +105 -0
- package/dist/esm/fhirlexer/parse.js.map +1 -0
- package/dist/esm/fhirlexer/tokenize.d.ts +14 -0
- package/dist/esm/fhirlexer/tokenize.js +212 -0
- package/dist/esm/fhirlexer/tokenize.js.map +1 -0
- package/dist/esm/fhirmapper/atoms.d.ts +67 -0
- package/dist/esm/fhirmapper/parse.d.ts +7 -0
- package/dist/esm/fhirmapper/tokenize.d.ts +2 -0
- package/dist/esm/fhirpath/atoms.d.ts +2 -7
- package/dist/esm/fhirpath/atoms.js.map +1 -1
- package/dist/esm/fhirpath/functions.d.ts +2 -1
- package/dist/esm/fhirpath/functions.js.map +1 -1
- package/dist/esm/fhirpath/parse.d.ts +8 -5
- package/dist/esm/fhirpath/parse.js +57 -169
- package/dist/esm/fhirpath/parse.js.map +1 -1
- package/dist/esm/fhirpath/tokenize.d.ts +3 -4
- package/dist/esm/fhirpath/tokenize.js +5 -180
- package/dist/esm/fhirpath/tokenize.js.map +1 -1
- package/dist/esm/fhirpath/utils.d.ts +1 -1
- package/dist/esm/fhirpath/utils.js +16 -17
- package/dist/esm/fhirpath/utils.js.map +1 -1
- package/dist/esm/index.js +3 -3
- package/dist/esm/index.min.js +1 -1
- package/dist/esm/index.min.js.map +1 -1
- package/dist/esm/outcomes.js +4 -4
- package/dist/esm/outcomes.js.map +1 -1
- package/dist/esm/searchparams.d.ts +1 -3
- package/dist/esm/searchparams.js +23 -6
- package/dist/esm/searchparams.js.map +1 -1
- package/dist/esm/types.d.ts +18 -3
- package/dist/esm/types.js +45 -13
- package/dist/esm/types.js.map +1 -1
- package/package.json +3 -3
package/dist/cjs/index.js
CHANGED
|
@@ -6087,17 +6087,16 @@
|
|
|
6087
6087
|
for (const entry of bundle.entry) {
|
|
6088
6088
|
const resource = entry.resource;
|
|
6089
6089
|
if (resource.resourceType === 'StructureDefinition') {
|
|
6090
|
-
indexStructureDefinition(
|
|
6090
|
+
indexStructureDefinition(resource);
|
|
6091
6091
|
}
|
|
6092
6092
|
}
|
|
6093
6093
|
}
|
|
6094
6094
|
/**
|
|
6095
6095
|
* Indexes a StructureDefinition for fast lookup.
|
|
6096
6096
|
* See comments on IndexedStructureDefinition for more details.
|
|
6097
|
-
* @param schema The output IndexedStructureDefinition.
|
|
6098
6097
|
* @param structureDefinition The original StructureDefinition.
|
|
6099
6098
|
*/
|
|
6100
|
-
function indexStructureDefinition(
|
|
6099
|
+
function indexStructureDefinition(structureDefinition) {
|
|
6101
6100
|
var _a;
|
|
6102
6101
|
const typeName = structureDefinition.name;
|
|
6103
6102
|
if (!typeName) {
|
|
@@ -6106,9 +6105,9 @@
|
|
|
6106
6105
|
const elements = (_a = structureDefinition.snapshot) === null || _a === void 0 ? void 0 : _a.element;
|
|
6107
6106
|
if (elements) {
|
|
6108
6107
|
// First pass, build types
|
|
6109
|
-
elements.forEach((element) => indexType(
|
|
6108
|
+
elements.forEach((element) => indexType(structureDefinition, element));
|
|
6110
6109
|
// Second pass, build properties
|
|
6111
|
-
elements.forEach((element) => indexProperty(
|
|
6110
|
+
elements.forEach((element) => indexProperty(element));
|
|
6112
6111
|
}
|
|
6113
6112
|
}
|
|
6114
6113
|
/**
|
|
@@ -6118,7 +6117,7 @@
|
|
|
6118
6117
|
* @param schema The output IndexedStructureDefinition.
|
|
6119
6118
|
* @param element The input ElementDefinition.
|
|
6120
6119
|
*/
|
|
6121
|
-
function indexType(
|
|
6120
|
+
function indexType(structureDefinition, elementDefinition) {
|
|
6122
6121
|
var _a, _b;
|
|
6123
6122
|
const path = elementDefinition.path;
|
|
6124
6123
|
const typeCode = (_b = (_a = elementDefinition.type) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.code;
|
|
@@ -6127,22 +6126,22 @@
|
|
|
6127
6126
|
}
|
|
6128
6127
|
const parts = path.split('.');
|
|
6129
6128
|
const typeName = buildTypeName(parts);
|
|
6130
|
-
|
|
6131
|
-
|
|
6129
|
+
globalSchema.types[typeName] = createTypeSchema(typeName, structureDefinition, elementDefinition);
|
|
6130
|
+
globalSchema.types[typeName].parentType = buildTypeName(parts.slice(0, parts.length - 1));
|
|
6132
6131
|
}
|
|
6133
6132
|
/**
|
|
6134
6133
|
* Indexes PropertySchema from an ElementDefinition.
|
|
6135
6134
|
* @param schema The output IndexedStructureDefinition.
|
|
6136
6135
|
* @param element The input ElementDefinition.
|
|
6137
6136
|
*/
|
|
6138
|
-
function indexProperty(
|
|
6137
|
+
function indexProperty(element) {
|
|
6139
6138
|
const path = element.path;
|
|
6140
6139
|
const parts = path.split('.');
|
|
6141
6140
|
if (parts.length === 1) {
|
|
6142
6141
|
return;
|
|
6143
6142
|
}
|
|
6144
6143
|
const typeName = buildTypeName(parts.slice(0, parts.length - 1));
|
|
6145
|
-
const typeSchema =
|
|
6144
|
+
const typeSchema = globalSchema.types[typeName];
|
|
6146
6145
|
if (!typeSchema) {
|
|
6147
6146
|
return;
|
|
6148
6147
|
}
|
|
@@ -6155,17 +6154,23 @@
|
|
|
6155
6154
|
* @param schema The output IndexedStructureDefinition.
|
|
6156
6155
|
* @param searchParam The SearchParameter resource.
|
|
6157
6156
|
*/
|
|
6158
|
-
function indexSearchParameter(
|
|
6157
|
+
function indexSearchParameter(searchParam) {
|
|
6159
6158
|
if (!searchParam.base) {
|
|
6160
6159
|
return;
|
|
6161
6160
|
}
|
|
6162
6161
|
for (const resourceType of searchParam.base) {
|
|
6163
|
-
const typeSchema =
|
|
6162
|
+
const typeSchema = globalSchema.types[resourceType];
|
|
6164
6163
|
if (!typeSchema) {
|
|
6165
6164
|
continue;
|
|
6166
6165
|
}
|
|
6167
6166
|
if (!typeSchema.searchParams) {
|
|
6168
6167
|
typeSchema.searchParams = {
|
|
6168
|
+
_id: {
|
|
6169
|
+
base: [resourceType],
|
|
6170
|
+
code: '_id',
|
|
6171
|
+
type: 'token',
|
|
6172
|
+
expression: resourceType + '.id',
|
|
6173
|
+
},
|
|
6169
6174
|
_lastUpdated: {
|
|
6170
6175
|
base: [resourceType],
|
|
6171
6176
|
code: '_lastUpdated',
|
|
@@ -6205,6 +6210,33 @@
|
|
|
6205
6210
|
.replace('_', ' ')
|
|
6206
6211
|
.replace(/\s+/g, ' ');
|
|
6207
6212
|
}
|
|
6213
|
+
/**
|
|
6214
|
+
* Returns an element definition by type and property name.
|
|
6215
|
+
* Handles content references.
|
|
6216
|
+
* @param typeName The type name.
|
|
6217
|
+
* @param propertyName The property name.
|
|
6218
|
+
* @returns The element definition if found.
|
|
6219
|
+
*/
|
|
6220
|
+
function getElementDefinition(typeName, propertyName) {
|
|
6221
|
+
var _a;
|
|
6222
|
+
const typeSchema = globalSchema.types[typeName];
|
|
6223
|
+
if (!typeSchema) {
|
|
6224
|
+
return undefined;
|
|
6225
|
+
}
|
|
6226
|
+
const property = (_a = typeSchema.properties[propertyName]) !== null && _a !== void 0 ? _a : typeSchema.properties[propertyName + '[x]'];
|
|
6227
|
+
if (!property) {
|
|
6228
|
+
return undefined;
|
|
6229
|
+
}
|
|
6230
|
+
if (property.contentReference) {
|
|
6231
|
+
// Content references start with a "#"
|
|
6232
|
+
// Remove the "#" character
|
|
6233
|
+
const contentReference = property.contentReference.substring(1).split('.');
|
|
6234
|
+
const referencePropertyName = contentReference.pop();
|
|
6235
|
+
const referenceTypeName = buildTypeName(contentReference);
|
|
6236
|
+
return getElementDefinition(referenceTypeName, referencePropertyName);
|
|
6237
|
+
}
|
|
6238
|
+
return property;
|
|
6239
|
+
}
|
|
6208
6240
|
/**
|
|
6209
6241
|
* Global schema singleton.
|
|
6210
6242
|
*/
|
|
@@ -6212,7 +6244,7 @@
|
|
|
6212
6244
|
|
|
6213
6245
|
// PKCE auth based on:
|
|
6214
6246
|
// https://aws.amazon.com/blogs/security/how-to-add-authentication-single-page-web-application-with-amazon-cognito-oauth2-implementation/
|
|
6215
|
-
var _MedplumClient_instances, _MedplumClient_fetch, _MedplumClient_createPdf, _MedplumClient_storage, _MedplumClient_requestCache, _MedplumClient_cacheTime, _MedplumClient_baseUrl, _MedplumClient_clientId, _MedplumClient_authorizeUrl, _MedplumClient_tokenUrl, _MedplumClient_logoutUrl, _MedplumClient_onUnauthenticated, _MedplumClient_accessToken, _MedplumClient_refreshToken, _MedplumClient_refreshPromise, _MedplumClient_profilePromise, _MedplumClient_profile, _MedplumClient_config, _MedplumClient_addLogin, _MedplumClient_refreshProfile, _MedplumClient_getCacheEntry, _MedplumClient_setCacheEntry, _MedplumClient_request, _MedplumClient_addFetchOptionsDefaults, _MedplumClient_setRequestContentType, _MedplumClient_setRequestBody, _MedplumClient_handleUnauthenticated,
|
|
6247
|
+
var _MedplumClient_instances, _MedplumClient_fetch, _MedplumClient_createPdf, _MedplumClient_storage, _MedplumClient_requestCache, _MedplumClient_cacheTime, _MedplumClient_baseUrl, _MedplumClient_clientId, _MedplumClient_authorizeUrl, _MedplumClient_tokenUrl, _MedplumClient_logoutUrl, _MedplumClient_onUnauthenticated, _MedplumClient_accessToken, _MedplumClient_refreshToken, _MedplumClient_refreshPromise, _MedplumClient_profilePromise, _MedplumClient_profile, _MedplumClient_config, _MedplumClient_addLogin, _MedplumClient_refreshProfile, _MedplumClient_getCacheEntry, _MedplumClient_setCacheEntry, _MedplumClient_request, _MedplumClient_addFetchOptionsDefaults, _MedplumClient_setRequestContentType, _MedplumClient_setRequestBody, _MedplumClient_handleUnauthenticated, _MedplumClient_requestAuthorization, _MedplumClient_refresh, _MedplumClient_fetchTokens, _MedplumClient_verifyTokens, _MedplumClient_setupStorageListener;
|
|
6216
6248
|
const DEFAULT_BASE_URL = 'https://api.medplum.com/';
|
|
6217
6249
|
const DEFAULT_SCOPE = 'launch/patient openid fhirUser offline_access user/*.*';
|
|
6218
6250
|
const DEFAULT_RESOURCE_CACHE_SIZE = 1000;
|
|
@@ -6481,8 +6513,8 @@
|
|
|
6481
6513
|
*/
|
|
6482
6514
|
startNewUser(newUserRequest) {
|
|
6483
6515
|
return __awaiter(this, void 0, void 0, function* () {
|
|
6484
|
-
yield
|
|
6485
|
-
return this.post('auth/newuser', Object.assign(Object.assign({}, newUserRequest), { codeChallengeMethod: 'S256', codeChallenge:
|
|
6516
|
+
yield this.startPkce();
|
|
6517
|
+
return this.post('auth/newuser', Object.assign(Object.assign({}, newUserRequest), { codeChallengeMethod: 'S256', codeChallenge: sessionStorage.getItem('codeChallenge') }));
|
|
6486
6518
|
});
|
|
6487
6519
|
}
|
|
6488
6520
|
/**
|
|
@@ -6520,10 +6552,9 @@
|
|
|
6520
6552
|
startLogin(loginRequest) {
|
|
6521
6553
|
var _a, _b;
|
|
6522
6554
|
return __awaiter(this, void 0, void 0, function* () {
|
|
6523
|
-
|
|
6524
|
-
|
|
6525
|
-
|
|
6526
|
-
return this.post('auth/login', Object.assign(Object.assign({}, loginRequest), { clientId: (_a = loginRequest.clientId) !== null && _a !== void 0 ? _a : __classPrivateFieldGet(this, _MedplumClient_clientId, "f"), scope: (_b = loginRequest.scope) !== null && _b !== void 0 ? _b : DEFAULT_SCOPE, codeChallengeMethod: loginRequest.codeChallengeMethod || 'S256', codeChallenge: loginRequest.codeChallenge || __classPrivateFieldGet(this, _MedplumClient_storage, "f").getString('codeChallenge') }));
|
|
6555
|
+
const { codeChallenge, codeChallengeMethod } = this.getCodeChallenge(loginRequest);
|
|
6556
|
+
return this.post('auth/login', Object.assign(Object.assign({}, loginRequest), { clientId: (_a = loginRequest.clientId) !== null && _a !== void 0 ? _a : __classPrivateFieldGet(this, _MedplumClient_clientId, "f"), scope: (_b = loginRequest.scope) !== null && _b !== void 0 ? _b : DEFAULT_SCOPE, codeChallengeMethod,
|
|
6557
|
+
codeChallenge }));
|
|
6527
6558
|
});
|
|
6528
6559
|
}
|
|
6529
6560
|
/**
|
|
@@ -6537,12 +6568,27 @@
|
|
|
6537
6568
|
startGoogleLogin(loginRequest) {
|
|
6538
6569
|
var _a, _b;
|
|
6539
6570
|
return __awaiter(this, void 0, void 0, function* () {
|
|
6540
|
-
|
|
6541
|
-
|
|
6542
|
-
|
|
6543
|
-
return this.post('auth/google', Object.assign(Object.assign({}, loginRequest), { clientId: (_a = loginRequest.clientId) !== null && _a !== void 0 ? _a : __classPrivateFieldGet(this, _MedplumClient_clientId, "f"), scope: (_b = loginRequest.scope) !== null && _b !== void 0 ? _b : DEFAULT_SCOPE, codeChallengeMethod: loginRequest.codeChallengeMethod || 'S256', codeChallenge: loginRequest.codeChallenge || __classPrivateFieldGet(this, _MedplumClient_storage, "f").getString('codeChallenge') }));
|
|
6571
|
+
const { codeChallenge, codeChallengeMethod } = this.getCodeChallenge(loginRequest);
|
|
6572
|
+
return this.post('auth/google', Object.assign(Object.assign({}, loginRequest), { clientId: (_a = loginRequest.clientId) !== null && _a !== void 0 ? _a : __classPrivateFieldGet(this, _MedplumClient_clientId, "f"), scope: (_b = loginRequest.scope) !== null && _b !== void 0 ? _b : DEFAULT_SCOPE, codeChallengeMethod,
|
|
6573
|
+
codeChallenge }));
|
|
6544
6574
|
});
|
|
6545
6575
|
}
|
|
6576
|
+
getCodeChallenge(loginRequest) {
|
|
6577
|
+
if (loginRequest.codeChallenge) {
|
|
6578
|
+
return {
|
|
6579
|
+
codeChallenge: loginRequest.codeChallenge,
|
|
6580
|
+
codeChallengeMethod: loginRequest.codeChallengeMethod,
|
|
6581
|
+
};
|
|
6582
|
+
}
|
|
6583
|
+
const codeChallenge = sessionStorage.getItem('codeChallenge');
|
|
6584
|
+
if (codeChallenge) {
|
|
6585
|
+
return {
|
|
6586
|
+
codeChallenge,
|
|
6587
|
+
codeChallengeMethod: 'S256',
|
|
6588
|
+
};
|
|
6589
|
+
}
|
|
6590
|
+
return {};
|
|
6591
|
+
}
|
|
6546
6592
|
/**
|
|
6547
6593
|
* Signs out locally.
|
|
6548
6594
|
* Does not invalidate tokens with the server.
|
|
@@ -6617,7 +6663,7 @@
|
|
|
6617
6663
|
* ```json
|
|
6618
6664
|
* {
|
|
6619
6665
|
* "resourceType": "Bundle",
|
|
6620
|
-
* "type": "
|
|
6666
|
+
* "type": "searchset",
|
|
6621
6667
|
* "total": 1,
|
|
6622
6668
|
* "entry": [
|
|
6623
6669
|
* {
|
|
@@ -6772,8 +6818,8 @@
|
|
|
6772
6818
|
* @param id The resource ID.
|
|
6773
6819
|
* @returns The resource if available; undefined otherwise.
|
|
6774
6820
|
*/
|
|
6775
|
-
readResource(resourceType, id) {
|
|
6776
|
-
return this.get(this.fhirUrl(resourceType, id));
|
|
6821
|
+
readResource(resourceType, id, options = {}) {
|
|
6822
|
+
return this.get(this.fhirUrl(resourceType, id), options);
|
|
6777
6823
|
}
|
|
6778
6824
|
/**
|
|
6779
6825
|
* Reads a resource by `Reference`.
|
|
@@ -6794,7 +6840,7 @@
|
|
|
6794
6840
|
* @param reference The FHIR reference object.
|
|
6795
6841
|
* @returns The resource if available; undefined otherwise.
|
|
6796
6842
|
*/
|
|
6797
|
-
readReference(reference) {
|
|
6843
|
+
readReference(reference, options = {}) {
|
|
6798
6844
|
const refString = reference === null || reference === void 0 ? void 0 : reference.reference;
|
|
6799
6845
|
if (!refString) {
|
|
6800
6846
|
return new ReadablePromise(Promise.reject(new Error('Missing reference')));
|
|
@@ -6803,7 +6849,7 @@
|
|
|
6803
6849
|
if (!resourceType || !id) {
|
|
6804
6850
|
return new ReadablePromise(Promise.reject(new Error('Invalid reference')));
|
|
6805
6851
|
}
|
|
6806
|
-
return this.readResource(resourceType, id);
|
|
6852
|
+
return this.readResource(resourceType, id, options);
|
|
6807
6853
|
}
|
|
6808
6854
|
/**
|
|
6809
6855
|
* Returns a cached schema for a resource type.
|
|
@@ -6860,10 +6906,10 @@
|
|
|
6860
6906
|
}`.replace(/\s+/g, ' ');
|
|
6861
6907
|
const response = (yield this.graphql(query));
|
|
6862
6908
|
for (const structureDefinition of response.data.StructureDefinitionList) {
|
|
6863
|
-
indexStructureDefinition(
|
|
6909
|
+
indexStructureDefinition(structureDefinition);
|
|
6864
6910
|
}
|
|
6865
6911
|
for (const searchParameter of response.data.SearchParameterList) {
|
|
6866
|
-
indexSearchParameter(
|
|
6912
|
+
indexSearchParameter(searchParameter);
|
|
6867
6913
|
}
|
|
6868
6914
|
return globalSchema;
|
|
6869
6915
|
});
|
|
@@ -6887,8 +6933,8 @@
|
|
|
6887
6933
|
* @param id The resource ID.
|
|
6888
6934
|
* @returns Promise to the resource history.
|
|
6889
6935
|
*/
|
|
6890
|
-
readHistory(resourceType, id) {
|
|
6891
|
-
return this.get(this.fhirUrl(resourceType, id, '_history'));
|
|
6936
|
+
readHistory(resourceType, id, options = {}) {
|
|
6937
|
+
return this.get(this.fhirUrl(resourceType, id, '_history'), options);
|
|
6892
6938
|
}
|
|
6893
6939
|
/**
|
|
6894
6940
|
* Reads a specific version of a resource by resource type, ID, and version ID.
|
|
@@ -6907,8 +6953,8 @@
|
|
|
6907
6953
|
* @param id The resource ID.
|
|
6908
6954
|
* @returns The resource if available; undefined otherwise.
|
|
6909
6955
|
*/
|
|
6910
|
-
readVersion(resourceType, id, vid) {
|
|
6911
|
-
return this.get(this.fhirUrl(resourceType, id, '_history', vid));
|
|
6956
|
+
readVersion(resourceType, id, vid, options = {}) {
|
|
6957
|
+
return this.get(this.fhirUrl(resourceType, id, '_history', vid), options);
|
|
6912
6958
|
}
|
|
6913
6959
|
/**
|
|
6914
6960
|
*
|
|
@@ -6916,8 +6962,8 @@
|
|
|
6916
6962
|
* @param id The Patient Id
|
|
6917
6963
|
* @returns A Bundle of all Resources related to the Patient
|
|
6918
6964
|
*/
|
|
6919
|
-
readPatientEverything(id) {
|
|
6920
|
-
return this.get(this.fhirUrl('Patient', id, '$everything'));
|
|
6965
|
+
readPatientEverything(id, options = {}) {
|
|
6966
|
+
return this.get(this.fhirUrl('Patient', id, '$everything'), options);
|
|
6921
6967
|
}
|
|
6922
6968
|
/**
|
|
6923
6969
|
* Creates a new FHIR resource.
|
|
@@ -7427,28 +7473,36 @@
|
|
|
7427
7473
|
return response.blob();
|
|
7428
7474
|
});
|
|
7429
7475
|
}
|
|
7476
|
+
/**
|
|
7477
|
+
* Starts a new PKCE flow.
|
|
7478
|
+
* These PKCE values are stateful, and must survive redirects and page refreshes.
|
|
7479
|
+
*/
|
|
7480
|
+
startPkce() {
|
|
7481
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
7482
|
+
const pkceState = getRandomString();
|
|
7483
|
+
sessionStorage.setItem('pkceState', pkceState);
|
|
7484
|
+
const codeVerifier = getRandomString();
|
|
7485
|
+
sessionStorage.setItem('codeVerifier', codeVerifier);
|
|
7486
|
+
const arrayHash = yield encryptSHA256(codeVerifier);
|
|
7487
|
+
const codeChallenge = arrayBufferToBase64(arrayHash).replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
|
|
7488
|
+
sessionStorage.setItem('codeChallenge', codeChallenge);
|
|
7489
|
+
});
|
|
7490
|
+
}
|
|
7430
7491
|
/**
|
|
7431
7492
|
* Processes an OAuth authorization code.
|
|
7432
7493
|
* See: https://openid.net/specs/openid-connect-core-1_0.html#TokenRequest
|
|
7433
7494
|
* @param code The authorization code received by URL parameter.
|
|
7434
7495
|
*/
|
|
7435
7496
|
processCode(code) {
|
|
7436
|
-
const pkceState = __classPrivateFieldGet(this, _MedplumClient_storage, "f").getString('pkceState');
|
|
7437
|
-
if (!pkceState) {
|
|
7438
|
-
this.clear();
|
|
7439
|
-
throw new Error('Invalid PCKE state');
|
|
7440
|
-
}
|
|
7441
|
-
const codeVerifier = __classPrivateFieldGet(this, _MedplumClient_storage, "f").getString('codeVerifier');
|
|
7442
|
-
if (!codeVerifier) {
|
|
7443
|
-
this.clear();
|
|
7444
|
-
throw new Error('Invalid PCKE code verifier');
|
|
7445
|
-
}
|
|
7446
7497
|
const formBody = new URLSearchParams();
|
|
7447
7498
|
formBody.set('grant_type', 'authorization_code');
|
|
7448
7499
|
formBody.set('client_id', __classPrivateFieldGet(this, _MedplumClient_clientId, "f"));
|
|
7449
|
-
formBody.set('code_verifier', codeVerifier);
|
|
7450
7500
|
formBody.set('code', code);
|
|
7451
7501
|
formBody.set('redirect_uri', getBaseUrl());
|
|
7502
|
+
const codeVerifier = sessionStorage.getItem('codeVerifier');
|
|
7503
|
+
if (codeVerifier) {
|
|
7504
|
+
formBody.set('code_verifier', codeVerifier);
|
|
7505
|
+
}
|
|
7452
7506
|
return __classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_fetchTokens).call(this, formBody);
|
|
7453
7507
|
}
|
|
7454
7508
|
/**
|
|
@@ -7531,6 +7585,7 @@
|
|
|
7531
7585
|
options.headers = {};
|
|
7532
7586
|
}
|
|
7533
7587
|
const headers = options.headers;
|
|
7588
|
+
headers['X-Medplum'] = 'extended';
|
|
7534
7589
|
if (!headers['Content-Type']) {
|
|
7535
7590
|
headers['Content-Type'] = FHIR_CONTENT_TYPE;
|
|
7536
7591
|
}
|
|
@@ -7571,27 +7626,17 @@
|
|
|
7571
7626
|
return Promise.reject(error);
|
|
7572
7627
|
});
|
|
7573
7628
|
});
|
|
7574
|
-
}, _MedplumClient_startPkce = function _MedplumClient_startPkce() {
|
|
7575
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
7576
|
-
const pkceState = getRandomString();
|
|
7577
|
-
__classPrivateFieldGet(this, _MedplumClient_storage, "f").setString('pkceState', pkceState);
|
|
7578
|
-
const codeVerifier = getRandomString();
|
|
7579
|
-
__classPrivateFieldGet(this, _MedplumClient_storage, "f").setString('codeVerifier', codeVerifier);
|
|
7580
|
-
const arrayHash = yield encryptSHA256(codeVerifier);
|
|
7581
|
-
const codeChallenge = arrayBufferToBase64(arrayHash).replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
|
|
7582
|
-
__classPrivateFieldGet(this, _MedplumClient_storage, "f").setString('codeChallenge', codeChallenge);
|
|
7583
|
-
});
|
|
7584
7629
|
}, _MedplumClient_requestAuthorization = function _MedplumClient_requestAuthorization() {
|
|
7585
7630
|
return __awaiter(this, void 0, void 0, function* () {
|
|
7586
|
-
yield
|
|
7631
|
+
yield this.startPkce();
|
|
7587
7632
|
const url = new URL(__classPrivateFieldGet(this, _MedplumClient_authorizeUrl, "f"));
|
|
7588
7633
|
url.searchParams.set('response_type', 'code');
|
|
7589
|
-
url.searchParams.set('state',
|
|
7634
|
+
url.searchParams.set('state', sessionStorage.getItem('pkceState'));
|
|
7590
7635
|
url.searchParams.set('client_id', __classPrivateFieldGet(this, _MedplumClient_clientId, "f"));
|
|
7591
7636
|
url.searchParams.set('redirect_uri', getBaseUrl());
|
|
7592
7637
|
url.searchParams.set('scope', DEFAULT_SCOPE);
|
|
7593
7638
|
url.searchParams.set('code_challenge_method', 'S256');
|
|
7594
|
-
url.searchParams.set('code_challenge',
|
|
7639
|
+
url.searchParams.set('code_challenge', sessionStorage.getItem('codeChallenge'));
|
|
7595
7640
|
window.location.assign(url.toString());
|
|
7596
7641
|
});
|
|
7597
7642
|
}, _MedplumClient_refresh = function _MedplumClient_refresh() {
|
|
@@ -7616,6 +7661,7 @@
|
|
|
7616
7661
|
method: 'POST',
|
|
7617
7662
|
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
7618
7663
|
body: formBody,
|
|
7664
|
+
credentials: 'include',
|
|
7619
7665
|
})
|
|
7620
7666
|
.then((response) => {
|
|
7621
7667
|
if (!response.ok) {
|
|
@@ -7761,9 +7807,9 @@
|
|
|
7761
7807
|
if (!(input === null || input === void 0 ? void 0 : input.value)) {
|
|
7762
7808
|
return undefined;
|
|
7763
7809
|
}
|
|
7764
|
-
const
|
|
7765
|
-
if (
|
|
7766
|
-
const typedResult = getTypedPropertyValueWithSchema(input, path,
|
|
7810
|
+
const elementDefinition = getElementDefinition(input.type, path);
|
|
7811
|
+
if (elementDefinition) {
|
|
7812
|
+
const typedResult = getTypedPropertyValueWithSchema(input, path, elementDefinition);
|
|
7767
7813
|
if (typedResult) {
|
|
7768
7814
|
return typedResult;
|
|
7769
7815
|
}
|
|
@@ -7774,24 +7820,18 @@
|
|
|
7774
7820
|
* Returns the value of the property and the property type using a type schema.
|
|
7775
7821
|
* @param input The base context (FHIR resource or backbone element).
|
|
7776
7822
|
* @param path The property path.
|
|
7777
|
-
* @param
|
|
7823
|
+
* @param property The property element definition.
|
|
7778
7824
|
* @returns The value of the property and the property type.
|
|
7779
7825
|
*/
|
|
7780
|
-
function getTypedPropertyValueWithSchema(input, path,
|
|
7826
|
+
function getTypedPropertyValueWithSchema(input, path, property) {
|
|
7781
7827
|
var _a;
|
|
7782
|
-
const property = (_a = typeSchema.properties[path]) !== null && _a !== void 0 ? _a : typeSchema.properties[path + '[x]'];
|
|
7783
|
-
if (!property) {
|
|
7784
|
-
return undefined;
|
|
7785
|
-
}
|
|
7786
7828
|
const types = property.type;
|
|
7787
7829
|
if (!types || types.length === 0) {
|
|
7788
7830
|
return undefined;
|
|
7789
7831
|
}
|
|
7790
|
-
let propertyName = undefined;
|
|
7791
7832
|
let resultValue = undefined;
|
|
7792
7833
|
let resultType = 'undefined';
|
|
7793
7834
|
if (types.length === 1) {
|
|
7794
|
-
propertyName = path;
|
|
7795
7835
|
resultValue = input.value[path];
|
|
7796
7836
|
resultType = types[0].code;
|
|
7797
7837
|
}
|
|
@@ -7799,7 +7839,6 @@
|
|
|
7799
7839
|
for (const type of types) {
|
|
7800
7840
|
const path2 = path.replace('[x]', '') + capitalize(type.code);
|
|
7801
7841
|
if (path2 in input.value) {
|
|
7802
|
-
propertyName = path2;
|
|
7803
7842
|
resultValue = input.value[path2];
|
|
7804
7843
|
resultType = type.code;
|
|
7805
7844
|
break;
|
|
@@ -7809,16 +7848,22 @@
|
|
|
7809
7848
|
if (isEmpty(resultValue)) {
|
|
7810
7849
|
return undefined;
|
|
7811
7850
|
}
|
|
7812
|
-
if (resultType === 'BackboneElement') {
|
|
7813
|
-
resultType = buildTypeName(
|
|
7851
|
+
if (resultType === 'Element' || resultType === 'BackboneElement') {
|
|
7852
|
+
resultType = buildTypeName((_a = property.path) === null || _a === void 0 ? void 0 : _a.split('.'));
|
|
7814
7853
|
}
|
|
7815
7854
|
if (Array.isArray(resultValue)) {
|
|
7816
|
-
return resultValue.map((element) => (
|
|
7855
|
+
return resultValue.map((element) => toTypedValueWithType(element, resultType));
|
|
7817
7856
|
}
|
|
7818
7857
|
else {
|
|
7819
|
-
return
|
|
7858
|
+
return toTypedValueWithType(resultValue, resultType);
|
|
7820
7859
|
}
|
|
7821
7860
|
}
|
|
7861
|
+
function toTypedValueWithType(value, type) {
|
|
7862
|
+
if (type === 'Resource' && typeof value === 'object' && 'resourceType' in value) {
|
|
7863
|
+
type = value.resourceType;
|
|
7864
|
+
}
|
|
7865
|
+
return { type, value };
|
|
7866
|
+
}
|
|
7822
7867
|
/**
|
|
7823
7868
|
* Returns the value of the property and the property type using a type schema.
|
|
7824
7869
|
* Note that because the type schema is not available, this function may be inaccurate.
|
|
@@ -9893,10 +9938,108 @@
|
|
|
9893
9938
|
}
|
|
9894
9939
|
}
|
|
9895
9940
|
|
|
9896
|
-
var
|
|
9897
|
-
|
|
9898
|
-
|
|
9941
|
+
var _ParserBuilder_prefixParselets, _ParserBuilder_infixParselets, _Parser_tokens, _Parser_prefixParselets, _Parser_infixParselets;
|
|
9942
|
+
class ParserBuilder {
|
|
9943
|
+
constructor() {
|
|
9944
|
+
_ParserBuilder_prefixParselets.set(this, {});
|
|
9945
|
+
_ParserBuilder_infixParselets.set(this, {});
|
|
9946
|
+
}
|
|
9947
|
+
registerInfix(tokenType, parselet) {
|
|
9948
|
+
__classPrivateFieldGet(this, _ParserBuilder_infixParselets, "f")[tokenType] = parselet;
|
|
9949
|
+
return this;
|
|
9950
|
+
}
|
|
9951
|
+
registerPrefix(tokenType, parselet) {
|
|
9952
|
+
__classPrivateFieldGet(this, _ParserBuilder_prefixParselets, "f")[tokenType] = parselet;
|
|
9953
|
+
return this;
|
|
9954
|
+
}
|
|
9955
|
+
prefix(tokenType, precedence, builder) {
|
|
9956
|
+
return this.registerPrefix(tokenType, {
|
|
9957
|
+
parse(parser, token) {
|
|
9958
|
+
const right = parser.consumeAndParse(precedence);
|
|
9959
|
+
return builder(token, right);
|
|
9960
|
+
},
|
|
9961
|
+
});
|
|
9962
|
+
}
|
|
9963
|
+
infixLeft(tokenType, precedence, builder) {
|
|
9964
|
+
return this.registerInfix(tokenType, {
|
|
9965
|
+
parse(parser, left, token) {
|
|
9966
|
+
const right = parser.consumeAndParse(precedence);
|
|
9967
|
+
return builder(left, token, right);
|
|
9968
|
+
},
|
|
9969
|
+
precedence,
|
|
9970
|
+
});
|
|
9971
|
+
}
|
|
9972
|
+
construct(input) {
|
|
9973
|
+
return new Parser(input, __classPrivateFieldGet(this, _ParserBuilder_prefixParselets, "f"), __classPrivateFieldGet(this, _ParserBuilder_infixParselets, "f"));
|
|
9974
|
+
}
|
|
9899
9975
|
}
|
|
9976
|
+
_ParserBuilder_prefixParselets = new WeakMap(), _ParserBuilder_infixParselets = new WeakMap();
|
|
9977
|
+
class Parser {
|
|
9978
|
+
constructor(tokens, prefixParselets, infixParselets) {
|
|
9979
|
+
_Parser_tokens.set(this, void 0);
|
|
9980
|
+
_Parser_prefixParselets.set(this, void 0);
|
|
9981
|
+
_Parser_infixParselets.set(this, void 0);
|
|
9982
|
+
__classPrivateFieldSet(this, _Parser_tokens, tokens, "f");
|
|
9983
|
+
__classPrivateFieldSet(this, _Parser_prefixParselets, prefixParselets, "f");
|
|
9984
|
+
__classPrivateFieldSet(this, _Parser_infixParselets, infixParselets, "f");
|
|
9985
|
+
}
|
|
9986
|
+
hasMore() {
|
|
9987
|
+
return __classPrivateFieldGet(this, _Parser_tokens, "f").length > 0;
|
|
9988
|
+
}
|
|
9989
|
+
match(expected) {
|
|
9990
|
+
const token = this.peek();
|
|
9991
|
+
if ((token === null || token === void 0 ? void 0 : token.id) !== expected) {
|
|
9992
|
+
return false;
|
|
9993
|
+
}
|
|
9994
|
+
this.consume();
|
|
9995
|
+
return true;
|
|
9996
|
+
}
|
|
9997
|
+
consumeAndParse(precedence = Infinity) {
|
|
9998
|
+
const token = this.consume();
|
|
9999
|
+
const prefix = __classPrivateFieldGet(this, _Parser_prefixParselets, "f")[token.id];
|
|
10000
|
+
if (!prefix) {
|
|
10001
|
+
throw Error(`Parse error at "${token.value}" (line ${token.line}, column ${token.column}). No matching prefix parselet.`);
|
|
10002
|
+
}
|
|
10003
|
+
let left = prefix.parse(this, token);
|
|
10004
|
+
while (precedence > this.getPrecedence()) {
|
|
10005
|
+
const next = this.consume();
|
|
10006
|
+
const infix = __classPrivateFieldGet(this, _Parser_infixParselets, "f")[next.id];
|
|
10007
|
+
left = infix.parse(this, left, next);
|
|
10008
|
+
}
|
|
10009
|
+
return left;
|
|
10010
|
+
}
|
|
10011
|
+
getPrecedence() {
|
|
10012
|
+
const nextToken = this.peek();
|
|
10013
|
+
if (!nextToken) {
|
|
10014
|
+
return Infinity;
|
|
10015
|
+
}
|
|
10016
|
+
const parser = __classPrivateFieldGet(this, _Parser_infixParselets, "f")[nextToken.id];
|
|
10017
|
+
if (parser) {
|
|
10018
|
+
return parser.precedence;
|
|
10019
|
+
}
|
|
10020
|
+
return Infinity;
|
|
10021
|
+
}
|
|
10022
|
+
consume(expected) {
|
|
10023
|
+
var _a;
|
|
10024
|
+
if (!__classPrivateFieldGet(this, _Parser_tokens, "f").length) {
|
|
10025
|
+
throw Error('Cant consume unknown more tokens.');
|
|
10026
|
+
}
|
|
10027
|
+
if (expected && ((_a = this.peek()) === null || _a === void 0 ? void 0 : _a.id) !== expected) {
|
|
10028
|
+
const actual = this.peek();
|
|
10029
|
+
throw Error(`Expected ${expected} but got "${actual.value}" at line ${actual.line} column ${actual.column}.`);
|
|
10030
|
+
}
|
|
10031
|
+
return __classPrivateFieldGet(this, _Parser_tokens, "f").shift();
|
|
10032
|
+
}
|
|
10033
|
+
peek() {
|
|
10034
|
+
return __classPrivateFieldGet(this, _Parser_tokens, "f").length > 0 ? __classPrivateFieldGet(this, _Parser_tokens, "f")[0] : undefined;
|
|
10035
|
+
}
|
|
10036
|
+
removeComments() {
|
|
10037
|
+
__classPrivateFieldSet(this, _Parser_tokens, __classPrivateFieldGet(this, _Parser_tokens, "f").filter((t) => t.id !== 'Comment'), "f");
|
|
10038
|
+
}
|
|
10039
|
+
}
|
|
10040
|
+
_Parser_tokens = new WeakMap(), _Parser_prefixParselets = new WeakMap(), _Parser_infixParselets = new WeakMap();
|
|
10041
|
+
|
|
10042
|
+
var _Tokenizer_instances, _Tokenizer_str, _Tokenizer_keywords, _Tokenizer_operators, _Tokenizer_result, _Tokenizer_pos, _Tokenizer_markStack, _Tokenizer_prevToken, _Tokenizer_peekToken, _Tokenizer_consumeToken, _Tokenizer_consumeWhitespace, _Tokenizer_consumeMultiLineComment, _Tokenizer_consumeSingleLineComment, _Tokenizer_consumeString, _Tokenizer_consumeBacktickSymbol, _Tokenizer_consumeDateTime, _Tokenizer_consumeNumber, _Tokenizer_consumeSymbol, _Tokenizer_consumeOperator, _Tokenizer_consumeWhile, _Tokenizer_curr, _Tokenizer_prev, _Tokenizer_peek, _Tokenizer_mark, _Tokenizer_reset, _Tokenizer_advance, _Tokenizer_buildToken;
|
|
9900
10043
|
const STANDARD_UNITS = [
|
|
9901
10044
|
'year',
|
|
9902
10045
|
'years',
|
|
@@ -9915,30 +10058,35 @@
|
|
|
9915
10058
|
'millisecond',
|
|
9916
10059
|
'milliseconds',
|
|
9917
10060
|
];
|
|
9918
|
-
const TWO_CHAR_OPERATORS = ['!=', '!~', '<=', '>=', '{}'];
|
|
9919
10061
|
class Tokenizer {
|
|
9920
|
-
constructor(str) {
|
|
10062
|
+
constructor(str, keywords, operators) {
|
|
9921
10063
|
_Tokenizer_instances.add(this);
|
|
9922
10064
|
_Tokenizer_str.set(this, void 0);
|
|
9923
|
-
|
|
10065
|
+
_Tokenizer_keywords.set(this, void 0);
|
|
10066
|
+
_Tokenizer_operators.set(this, void 0);
|
|
10067
|
+
_Tokenizer_result.set(this, []);
|
|
10068
|
+
_Tokenizer_pos.set(this, { index: 0, line: 0, column: 0 });
|
|
10069
|
+
_Tokenizer_markStack.set(this, []);
|
|
9924
10070
|
__classPrivateFieldSet(this, _Tokenizer_str, str, "f");
|
|
9925
|
-
__classPrivateFieldSet(this,
|
|
10071
|
+
__classPrivateFieldSet(this, _Tokenizer_keywords, keywords, "f");
|
|
10072
|
+
__classPrivateFieldSet(this, _Tokenizer_operators, operators, "f");
|
|
9926
10073
|
}
|
|
9927
10074
|
tokenize() {
|
|
9928
|
-
|
|
9929
|
-
while (__classPrivateFieldGet(this, _Tokenizer_pos, "f") < __classPrivateFieldGet(this, _Tokenizer_str, "f").length) {
|
|
10075
|
+
while (__classPrivateFieldGet(this, _Tokenizer_pos, "f").index < __classPrivateFieldGet(this, _Tokenizer_str, "f").length) {
|
|
9930
10076
|
const token = __classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_consumeToken).call(this);
|
|
9931
10077
|
if (token) {
|
|
9932
|
-
|
|
10078
|
+
__classPrivateFieldGet(this, _Tokenizer_result, "f").push(token);
|
|
9933
10079
|
}
|
|
9934
10080
|
}
|
|
9935
|
-
return
|
|
10081
|
+
return __classPrivateFieldGet(this, _Tokenizer_result, "f");
|
|
9936
10082
|
}
|
|
9937
10083
|
}
|
|
9938
|
-
_Tokenizer_str = new WeakMap(), _Tokenizer_pos = new WeakMap(), _Tokenizer_instances = new WeakSet(),
|
|
9939
|
-
|
|
10084
|
+
_Tokenizer_str = new WeakMap(), _Tokenizer_keywords = new WeakMap(), _Tokenizer_operators = new WeakMap(), _Tokenizer_result = new WeakMap(), _Tokenizer_pos = new WeakMap(), _Tokenizer_markStack = new WeakMap(), _Tokenizer_instances = new WeakSet(), _Tokenizer_prevToken = function _Tokenizer_prevToken() {
|
|
10085
|
+
return __classPrivateFieldGet(this, _Tokenizer_result, "f").slice(-1)[0];
|
|
10086
|
+
}, _Tokenizer_peekToken = function _Tokenizer_peekToken() {
|
|
10087
|
+
__classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_mark).call(this);
|
|
9940
10088
|
const token = __classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_consumeToken).call(this);
|
|
9941
|
-
|
|
10089
|
+
__classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_reset).call(this);
|
|
9942
10090
|
return token;
|
|
9943
10091
|
}, _Tokenizer_consumeToken = function _Tokenizer_consumeToken() {
|
|
9944
10092
|
__classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_consumeWhitespace).call(this);
|
|
@@ -9946,6 +10094,7 @@
|
|
|
9946
10094
|
if (!c) {
|
|
9947
10095
|
return undefined;
|
|
9948
10096
|
}
|
|
10097
|
+
__classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_mark).call(this);
|
|
9949
10098
|
const next = __classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_peek).call(this);
|
|
9950
10099
|
if (c === '/' && next === '*') {
|
|
9951
10100
|
return __classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_consumeMultiLineComment).call(this);
|
|
@@ -9953,8 +10102,8 @@
|
|
|
9953
10102
|
if (c === '/' && next === '/') {
|
|
9954
10103
|
return __classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_consumeSingleLineComment).call(this);
|
|
9955
10104
|
}
|
|
9956
|
-
if (c === "'") {
|
|
9957
|
-
return __classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_consumeString).call(this);
|
|
10105
|
+
if (c === "'" || c === '"') {
|
|
10106
|
+
return __classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_consumeString).call(this, c);
|
|
9958
10107
|
}
|
|
9959
10108
|
if (c === '`') {
|
|
9960
10109
|
return __classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_consumeBacktickSymbol).call(this);
|
|
@@ -9973,54 +10122,51 @@
|
|
|
9973
10122
|
}
|
|
9974
10123
|
return __classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_consumeOperator).call(this);
|
|
9975
10124
|
}, _Tokenizer_consumeWhitespace = function _Tokenizer_consumeWhitespace() {
|
|
9976
|
-
|
|
10125
|
+
__classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_consumeWhile).call(this, () => __classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_curr).call(this).match(/\s/));
|
|
9977
10126
|
}, _Tokenizer_consumeMultiLineComment = function _Tokenizer_consumeMultiLineComment() {
|
|
9978
|
-
const start = __classPrivateFieldGet(this, _Tokenizer_pos, "f");
|
|
10127
|
+
const start = __classPrivateFieldGet(this, _Tokenizer_pos, "f").index;
|
|
9979
10128
|
__classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_consumeWhile).call(this, () => __classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_curr).call(this) !== '*' || __classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_peek).call(this) !== '/');
|
|
9980
|
-
|
|
9981
|
-
|
|
10129
|
+
__classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_advance).call(this);
|
|
10130
|
+
__classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_advance).call(this);
|
|
10131
|
+
return __classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_buildToken).call(this, 'Comment', __classPrivateFieldGet(this, _Tokenizer_str, "f").substring(start, __classPrivateFieldGet(this, _Tokenizer_pos, "f").index));
|
|
9982
10132
|
}, _Tokenizer_consumeSingleLineComment = function _Tokenizer_consumeSingleLineComment() {
|
|
9983
|
-
return
|
|
9984
|
-
}, _Tokenizer_consumeString = function _Tokenizer_consumeString() {
|
|
9985
|
-
|
|
9986
|
-
|
|
9987
|
-
|
|
9988
|
-
__classPrivateFieldSet(this, _Tokenizer_pos, (_b = __classPrivateFieldGet(this, _Tokenizer_pos, "f"), _b++, _b), "f");
|
|
10133
|
+
return __classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_buildToken).call(this, 'Comment', __classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_consumeWhile).call(this, () => __classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_curr).call(this) !== '\n'));
|
|
10134
|
+
}, _Tokenizer_consumeString = function _Tokenizer_consumeString(endChar) {
|
|
10135
|
+
__classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_advance).call(this);
|
|
10136
|
+
const result = __classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_buildToken).call(this, 'String', __classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_consumeWhile).call(this, () => __classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_prev).call(this) === '\\' || __classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_curr).call(this) !== endChar));
|
|
10137
|
+
__classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_advance).call(this);
|
|
9989
10138
|
return result;
|
|
9990
10139
|
}, _Tokenizer_consumeBacktickSymbol = function _Tokenizer_consumeBacktickSymbol() {
|
|
9991
|
-
|
|
9992
|
-
|
|
9993
|
-
|
|
9994
|
-
__classPrivateFieldSet(this, _Tokenizer_pos, (_b = __classPrivateFieldGet(this, _Tokenizer_pos, "f"), _b++, _b), "f");
|
|
10140
|
+
__classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_advance).call(this);
|
|
10141
|
+
const result = __classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_buildToken).call(this, 'Symbol', __classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_consumeWhile).call(this, () => __classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_curr).call(this) !== '`'));
|
|
10142
|
+
__classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_advance).call(this);
|
|
9995
10143
|
return result;
|
|
9996
10144
|
}, _Tokenizer_consumeDateTime = function _Tokenizer_consumeDateTime() {
|
|
9997
|
-
|
|
9998
|
-
const start = __classPrivateFieldGet(this, _Tokenizer_pos, "f");
|
|
9999
|
-
__classPrivateFieldSet(this, _Tokenizer_pos, (_a = __classPrivateFieldGet(this, _Tokenizer_pos, "f"), _a++, _a), "f");
|
|
10145
|
+
__classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_advance).call(this); // Consume "@"
|
|
10146
|
+
const start = __classPrivateFieldGet(this, _Tokenizer_pos, "f").index;
|
|
10000
10147
|
__classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_consumeWhile).call(this, () => __classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_curr).call(this).match(/[\d-]/));
|
|
10001
10148
|
if (__classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_curr).call(this) === 'T') {
|
|
10002
|
-
|
|
10149
|
+
__classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_advance).call(this);
|
|
10003
10150
|
__classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_consumeWhile).call(this, () => __classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_curr).call(this).match(/[\d:]/));
|
|
10004
10151
|
if (__classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_curr).call(this) === '.' && __classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_peek).call(this).match(/\d/)) {
|
|
10005
|
-
|
|
10006
|
-
__classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_consumeWhile).call(this, () => __classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_curr).call(this).match(
|
|
10152
|
+
__classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_advance).call(this);
|
|
10153
|
+
__classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_consumeWhile).call(this, () => __classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_curr).call(this).match(/\d/));
|
|
10007
10154
|
}
|
|
10008
10155
|
if (__classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_curr).call(this) === 'Z') {
|
|
10009
|
-
|
|
10156
|
+
__classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_advance).call(this);
|
|
10010
10157
|
}
|
|
10011
10158
|
else if (__classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_curr).call(this) === '+' || __classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_curr).call(this) === '-') {
|
|
10012
|
-
|
|
10159
|
+
__classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_advance).call(this);
|
|
10013
10160
|
__classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_consumeWhile).call(this, () => __classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_curr).call(this).match(/[\d:]/));
|
|
10014
10161
|
}
|
|
10015
10162
|
}
|
|
10016
|
-
return
|
|
10163
|
+
return __classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_buildToken).call(this, 'DateTime', __classPrivateFieldGet(this, _Tokenizer_str, "f").substring(start, __classPrivateFieldGet(this, _Tokenizer_pos, "f").index));
|
|
10017
10164
|
}, _Tokenizer_consumeNumber = function _Tokenizer_consumeNumber() {
|
|
10018
|
-
|
|
10019
|
-
const start = __classPrivateFieldGet(this, _Tokenizer_pos, "f");
|
|
10165
|
+
const start = __classPrivateFieldGet(this, _Tokenizer_pos, "f").index;
|
|
10020
10166
|
let id = 'Number';
|
|
10021
10167
|
__classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_consumeWhile).call(this, () => __classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_curr).call(this).match(/\d/));
|
|
10022
10168
|
if (__classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_curr).call(this) === '.' && __classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_peek).call(this).match(/\d/)) {
|
|
10023
|
-
|
|
10169
|
+
__classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_advance).call(this);
|
|
10024
10170
|
__classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_consumeWhile).call(this, () => __classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_curr).call(this).match(/\d/));
|
|
10025
10171
|
}
|
|
10026
10172
|
if (__classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_curr).call(this) === ' ') {
|
|
@@ -10029,39 +10175,66 @@
|
|
|
10029
10175
|
__classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_consumeToken).call(this);
|
|
10030
10176
|
}
|
|
10031
10177
|
}
|
|
10032
|
-
return
|
|
10178
|
+
return __classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_buildToken).call(this, id, __classPrivateFieldGet(this, _Tokenizer_str, "f").substring(start, __classPrivateFieldGet(this, _Tokenizer_pos, "f").index));
|
|
10033
10179
|
}, _Tokenizer_consumeSymbol = function _Tokenizer_consumeSymbol() {
|
|
10034
|
-
return buildToken('Symbol', __classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_consumeWhile).call(this, () => __classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_curr).call(this).match(/[$\w]/)));
|
|
10035
|
-
}, _Tokenizer_consumeOperator = function _Tokenizer_consumeOperator() {
|
|
10036
10180
|
var _a;
|
|
10181
|
+
const value = __classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_consumeWhile).call(this, () => __classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_curr).call(this).match(/[$\w]/));
|
|
10182
|
+
if (((_a = __classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_prevToken).call(this)) === null || _a === void 0 ? void 0 : _a.value) !== '.' && __classPrivateFieldGet(this, _Tokenizer_keywords, "f").includes(value)) {
|
|
10183
|
+
return __classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_buildToken).call(this, value, value);
|
|
10184
|
+
}
|
|
10185
|
+
return __classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_buildToken).call(this, 'Symbol', value);
|
|
10186
|
+
}, _Tokenizer_consumeOperator = function _Tokenizer_consumeOperator() {
|
|
10037
10187
|
const c = __classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_curr).call(this);
|
|
10038
10188
|
const next = __classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_peek).call(this);
|
|
10039
10189
|
const twoCharOp = c + next;
|
|
10040
|
-
if (
|
|
10041
|
-
|
|
10042
|
-
|
|
10190
|
+
if (__classPrivateFieldGet(this, _Tokenizer_operators, "f").includes(twoCharOp)) {
|
|
10191
|
+
__classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_advance).call(this);
|
|
10192
|
+
__classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_advance).call(this);
|
|
10193
|
+
return __classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_buildToken).call(this, twoCharOp, twoCharOp);
|
|
10043
10194
|
}
|
|
10044
|
-
|
|
10045
|
-
return
|
|
10195
|
+
__classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_advance).call(this);
|
|
10196
|
+
return __classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_buildToken).call(this, c, c);
|
|
10046
10197
|
}, _Tokenizer_consumeWhile = function _Tokenizer_consumeWhile(condition) {
|
|
10047
|
-
|
|
10048
|
-
|
|
10049
|
-
|
|
10050
|
-
__classPrivateFieldSet(this, _Tokenizer_pos, (_a = __classPrivateFieldGet(this, _Tokenizer_pos, "f"), _a++, _a), "f");
|
|
10198
|
+
const start = __classPrivateFieldGet(this, _Tokenizer_pos, "f").index;
|
|
10199
|
+
while (__classPrivateFieldGet(this, _Tokenizer_pos, "f").index < __classPrivateFieldGet(this, _Tokenizer_str, "f").length && condition()) {
|
|
10200
|
+
__classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_advance).call(this);
|
|
10051
10201
|
}
|
|
10052
|
-
return __classPrivateFieldGet(this, _Tokenizer_str, "f").substring(start, __classPrivateFieldGet(this, _Tokenizer_pos, "f"));
|
|
10202
|
+
return __classPrivateFieldGet(this, _Tokenizer_str, "f").substring(start, __classPrivateFieldGet(this, _Tokenizer_pos, "f").index);
|
|
10053
10203
|
}, _Tokenizer_curr = function _Tokenizer_curr() {
|
|
10054
|
-
return __classPrivateFieldGet(this, _Tokenizer_str, "f")[__classPrivateFieldGet(this, _Tokenizer_pos, "f")];
|
|
10204
|
+
return __classPrivateFieldGet(this, _Tokenizer_str, "f")[__classPrivateFieldGet(this, _Tokenizer_pos, "f").index];
|
|
10055
10205
|
}, _Tokenizer_prev = function _Tokenizer_prev() {
|
|
10056
10206
|
var _a;
|
|
10057
|
-
return (_a = __classPrivateFieldGet(this, _Tokenizer_str, "f")[__classPrivateFieldGet(this, _Tokenizer_pos, "f") - 1]) !== null && _a !== void 0 ? _a : '';
|
|
10207
|
+
return (_a = __classPrivateFieldGet(this, _Tokenizer_str, "f")[__classPrivateFieldGet(this, _Tokenizer_pos, "f").index - 1]) !== null && _a !== void 0 ? _a : '';
|
|
10058
10208
|
}, _Tokenizer_peek = function _Tokenizer_peek() {
|
|
10059
10209
|
var _a;
|
|
10060
|
-
return (_a = __classPrivateFieldGet(this, _Tokenizer_str, "f")[__classPrivateFieldGet(this, _Tokenizer_pos, "f") + 1]) !== null && _a !== void 0 ? _a : '';
|
|
10210
|
+
return (_a = __classPrivateFieldGet(this, _Tokenizer_str, "f")[__classPrivateFieldGet(this, _Tokenizer_pos, "f").index + 1]) !== null && _a !== void 0 ? _a : '';
|
|
10211
|
+
}, _Tokenizer_mark = function _Tokenizer_mark() {
|
|
10212
|
+
__classPrivateFieldGet(this, _Tokenizer_markStack, "f").push(Object.assign({}, __classPrivateFieldGet(this, _Tokenizer_pos, "f")));
|
|
10213
|
+
}, _Tokenizer_reset = function _Tokenizer_reset() {
|
|
10214
|
+
const mark = __classPrivateFieldGet(this, _Tokenizer_markStack, "f").pop();
|
|
10215
|
+
if (!mark) {
|
|
10216
|
+
throw new Error('No mark to reset to');
|
|
10217
|
+
}
|
|
10218
|
+
__classPrivateFieldGet(this, _Tokenizer_pos, "f").index = mark.index;
|
|
10219
|
+
__classPrivateFieldGet(this, _Tokenizer_pos, "f").line = mark.line;
|
|
10220
|
+
__classPrivateFieldGet(this, _Tokenizer_pos, "f").column = mark.column;
|
|
10221
|
+
}, _Tokenizer_advance = function _Tokenizer_advance() {
|
|
10222
|
+
__classPrivateFieldGet(this, _Tokenizer_pos, "f").index++;
|
|
10223
|
+
if (__classPrivateFieldGet(this, _Tokenizer_instances, "m", _Tokenizer_curr).call(this) === '\n') {
|
|
10224
|
+
__classPrivateFieldGet(this, _Tokenizer_pos, "f").line++;
|
|
10225
|
+
__classPrivateFieldGet(this, _Tokenizer_pos, "f").column = 0;
|
|
10226
|
+
}
|
|
10227
|
+
else {
|
|
10228
|
+
__classPrivateFieldGet(this, _Tokenizer_pos, "f").column++;
|
|
10229
|
+
}
|
|
10230
|
+
}, _Tokenizer_buildToken = function _Tokenizer_buildToken(id, value) {
|
|
10231
|
+
const mark = __classPrivateFieldGet(this, _Tokenizer_markStack, "f").pop();
|
|
10232
|
+
if (!mark) {
|
|
10233
|
+
throw new Error('No mark for token');
|
|
10234
|
+
}
|
|
10235
|
+
return Object.assign({ id,
|
|
10236
|
+
value }, mark);
|
|
10061
10237
|
};
|
|
10062
|
-
function buildToken(id, value) {
|
|
10063
|
-
return { id, value };
|
|
10064
|
-
}
|
|
10065
10238
|
function isUnitToken(token) {
|
|
10066
10239
|
if (token) {
|
|
10067
10240
|
if (token.id === 'String') {
|
|
@@ -10074,93 +10247,12 @@
|
|
|
10074
10247
|
return false;
|
|
10075
10248
|
}
|
|
10076
10249
|
|
|
10077
|
-
|
|
10078
|
-
|
|
10079
|
-
|
|
10080
|
-
|
|
10081
|
-
_ParserBuilder_infixParselets.set(this, {});
|
|
10082
|
-
}
|
|
10083
|
-
registerInfix(tokenType, parselet) {
|
|
10084
|
-
__classPrivateFieldGet(this, _ParserBuilder_infixParselets, "f")[tokenType] = parselet;
|
|
10085
|
-
return this;
|
|
10086
|
-
}
|
|
10087
|
-
registerPrefix(tokenType, parselet) {
|
|
10088
|
-
__classPrivateFieldGet(this, _ParserBuilder_prefixParselets, "f")[tokenType] = parselet;
|
|
10089
|
-
return this;
|
|
10090
|
-
}
|
|
10091
|
-
prefix(tokenType, precedence, builder) {
|
|
10092
|
-
return this.registerPrefix(tokenType, {
|
|
10093
|
-
parse(parser, token) {
|
|
10094
|
-
const right = parser.consumeAndParse(precedence);
|
|
10095
|
-
return builder(token, right);
|
|
10096
|
-
},
|
|
10097
|
-
});
|
|
10098
|
-
}
|
|
10099
|
-
infixLeft(tokenType, precedence, builder) {
|
|
10100
|
-
return this.registerInfix(tokenType, {
|
|
10101
|
-
parse(parser, left, token) {
|
|
10102
|
-
const right = parser.consumeAndParse(precedence);
|
|
10103
|
-
return builder(left, token, right);
|
|
10104
|
-
},
|
|
10105
|
-
precedence,
|
|
10106
|
-
});
|
|
10107
|
-
}
|
|
10108
|
-
construct(input) {
|
|
10109
|
-
return new Parser(tokenize(input), __classPrivateFieldGet(this, _ParserBuilder_prefixParselets, "f"), __classPrivateFieldGet(this, _ParserBuilder_infixParselets, "f"));
|
|
10110
|
-
}
|
|
10111
|
-
}
|
|
10112
|
-
_ParserBuilder_prefixParselets = new WeakMap(), _ParserBuilder_infixParselets = new WeakMap();
|
|
10113
|
-
class Parser {
|
|
10114
|
-
constructor(tokens, prefixParselets, infixParselets) {
|
|
10115
|
-
_Parser_instances.add(this);
|
|
10116
|
-
_Parser_tokens.set(this, void 0);
|
|
10117
|
-
_Parser_prefixParselets.set(this, void 0);
|
|
10118
|
-
_Parser_infixParselets.set(this, void 0);
|
|
10119
|
-
__classPrivateFieldSet(this, _Parser_tokens, tokens, "f");
|
|
10120
|
-
__classPrivateFieldSet(this, _Parser_prefixParselets, prefixParselets, "f");
|
|
10121
|
-
__classPrivateFieldSet(this, _Parser_infixParselets, infixParselets, "f");
|
|
10122
|
-
}
|
|
10123
|
-
match(expected) {
|
|
10124
|
-
const token = __classPrivateFieldGet(this, _Parser_instances, "m", _Parser_look).call(this);
|
|
10125
|
-
if ((token === null || token === void 0 ? void 0 : token.id) !== expected) {
|
|
10126
|
-
return false;
|
|
10127
|
-
}
|
|
10128
|
-
__classPrivateFieldGet(this, _Parser_instances, "m", _Parser_consume).call(this);
|
|
10129
|
-
return true;
|
|
10130
|
-
}
|
|
10131
|
-
consumeAndParse(precedence = 100 /* Precedence.MaximumPrecedence */) {
|
|
10132
|
-
const token = __classPrivateFieldGet(this, _Parser_instances, "m", _Parser_consume).call(this);
|
|
10133
|
-
const prefix = __classPrivateFieldGet(this, _Parser_prefixParselets, "f")[token.id];
|
|
10134
|
-
if (!prefix) {
|
|
10135
|
-
throw Error(`Parse error at ${token.value}. No matching prefix parselet.`);
|
|
10136
|
-
}
|
|
10137
|
-
let left = prefix.parse(this, token);
|
|
10138
|
-
while (precedence > __classPrivateFieldGet(this, _Parser_instances, "m", _Parser_getPrecedence).call(this)) {
|
|
10139
|
-
const next = __classPrivateFieldGet(this, _Parser_instances, "m", _Parser_consume).call(this);
|
|
10140
|
-
const infix = __classPrivateFieldGet(this, _Parser_infixParselets, "f")[next.id];
|
|
10141
|
-
left = infix.parse(this, left, next);
|
|
10142
|
-
}
|
|
10143
|
-
return left;
|
|
10144
|
-
}
|
|
10250
|
+
const FHIRPATH_KEYWORDS = ['true', 'false', 'and', 'as', 'contains', 'div', 'in', 'is', 'mod', 'or', 'xor'];
|
|
10251
|
+
const FHIRPATH_OPERATORS = ['!=', '!~', '<=', '>=', '{}', '->'];
|
|
10252
|
+
function tokenize(str) {
|
|
10253
|
+
return new Tokenizer(str, FHIRPATH_KEYWORDS, FHIRPATH_OPERATORS).tokenize();
|
|
10145
10254
|
}
|
|
10146
|
-
|
|
10147
|
-
const nextToken = __classPrivateFieldGet(this, _Parser_instances, "m", _Parser_look).call(this);
|
|
10148
|
-
if (!nextToken) {
|
|
10149
|
-
return 100 /* Precedence.MaximumPrecedence */;
|
|
10150
|
-
}
|
|
10151
|
-
const parser = __classPrivateFieldGet(this, _Parser_infixParselets, "f")[nextToken.id];
|
|
10152
|
-
if (parser) {
|
|
10153
|
-
return parser.precedence;
|
|
10154
|
-
}
|
|
10155
|
-
return 100 /* Precedence.MaximumPrecedence */;
|
|
10156
|
-
}, _Parser_consume = function _Parser_consume() {
|
|
10157
|
-
if (!__classPrivateFieldGet(this, _Parser_tokens, "f").length) {
|
|
10158
|
-
throw Error('Cant consume unknown more tokens.');
|
|
10159
|
-
}
|
|
10160
|
-
return __classPrivateFieldGet(this, _Parser_tokens, "f").shift();
|
|
10161
|
-
}, _Parser_look = function _Parser_look() {
|
|
10162
|
-
return __classPrivateFieldGet(this, _Parser_tokens, "f").length > 0 ? __classPrivateFieldGet(this, _Parser_tokens, "f")[0] : undefined;
|
|
10163
|
-
};
|
|
10255
|
+
|
|
10164
10256
|
const PARENTHESES_PARSELET = {
|
|
10165
10257
|
parse(parser) {
|
|
10166
10258
|
const expr = parser.consumeAndParse();
|
|
@@ -10209,75 +10301,55 @@
|
|
|
10209
10301
|
}
|
|
10210
10302
|
return { value, unit };
|
|
10211
10303
|
}
|
|
10212
|
-
|
|
10213
|
-
|
|
10214
|
-
|
|
10215
|
-
|
|
10216
|
-
|
|
10217
|
-
|
|
10218
|
-
|
|
10219
|
-
|
|
10220
|
-
|
|
10221
|
-
|
|
10222
|
-
|
|
10223
|
-
|
|
10224
|
-
|
|
10225
|
-
|
|
10226
|
-
|
|
10227
|
-
|
|
10228
|
-
|
|
10229
|
-
}
|
|
10230
|
-
|
|
10231
|
-
|
|
10232
|
-
|
|
10233
|
-
|
|
10234
|
-
|
|
10235
|
-
|
|
10236
|
-
|
|
10237
|
-
|
|
10238
|
-
|
|
10239
|
-
|
|
10240
|
-
|
|
10241
|
-
|
|
10242
|
-
|
|
10243
|
-
|
|
10244
|
-
|
|
10245
|
-
|
|
10246
|
-
|
|
10247
|
-
|
|
10248
|
-
|
|
10249
|
-
|
|
10250
|
-
|
|
10251
|
-
|
|
10252
|
-
|
|
10253
|
-
|
|
10254
|
-
|
|
10255
|
-
|
|
10256
|
-
|
|
10257
|
-
|
|
10258
|
-
|
|
10259
|
-
|
|
10260
|
-
|
|
10261
|
-
case 'as':
|
|
10262
|
-
return new AsAtom(left, right);
|
|
10263
|
-
case 'contains':
|
|
10264
|
-
return new ContainsAtom(left, right);
|
|
10265
|
-
case 'div':
|
|
10266
|
-
return new ArithemticOperatorAtom(left, right, (x, y) => (x / y) | 0);
|
|
10267
|
-
case 'in':
|
|
10268
|
-
return new InAtom(left, right);
|
|
10269
|
-
case 'is':
|
|
10270
|
-
return new IsAtom(left, right);
|
|
10271
|
-
case 'mod':
|
|
10272
|
-
return new ArithemticOperatorAtom(left, right, (x, y) => x % y);
|
|
10273
|
-
case 'or':
|
|
10274
|
-
return new OrAtom(left, right);
|
|
10275
|
-
case 'xor':
|
|
10276
|
-
return new XorAtom(left, right);
|
|
10277
|
-
default:
|
|
10278
|
-
throw new Error('Cannot use ' + symbol.value + ' as infix operator');
|
|
10279
|
-
}
|
|
10280
|
-
});
|
|
10304
|
+
function initFhirPathParserBuilder() {
|
|
10305
|
+
return new ParserBuilder()
|
|
10306
|
+
.registerPrefix('String', {
|
|
10307
|
+
parse: (_, token) => new LiteralAtom({ type: exports.PropertyType.string, value: token.value }),
|
|
10308
|
+
})
|
|
10309
|
+
.registerPrefix('DateTime', {
|
|
10310
|
+
parse: (_, token) => new LiteralAtom({ type: exports.PropertyType.dateTime, value: parseDateString(token.value) }),
|
|
10311
|
+
})
|
|
10312
|
+
.registerPrefix('Quantity', {
|
|
10313
|
+
parse: (_, token) => new LiteralAtom({ type: exports.PropertyType.Quantity, value: parseQuantity(token.value) }),
|
|
10314
|
+
})
|
|
10315
|
+
.registerPrefix('Number', {
|
|
10316
|
+
parse: (_, token) => new LiteralAtom({ type: exports.PropertyType.decimal, value: parseFloat(token.value) }),
|
|
10317
|
+
})
|
|
10318
|
+
.registerPrefix('true', { parse: () => new LiteralAtom({ type: exports.PropertyType.boolean, value: true }) })
|
|
10319
|
+
.registerPrefix('false', { parse: () => new LiteralAtom({ type: exports.PropertyType.boolean, value: false }) })
|
|
10320
|
+
.registerPrefix('Symbol', { parse: (_, token) => new SymbolAtom(token.value) })
|
|
10321
|
+
.registerPrefix('{}', { parse: () => new EmptySetAtom() })
|
|
10322
|
+
.registerPrefix('(', PARENTHESES_PARSELET)
|
|
10323
|
+
.registerInfix('[', INDEXER_PARSELET)
|
|
10324
|
+
.registerInfix('(', FUNCTION_CALL_PARSELET)
|
|
10325
|
+
.prefix('+', 3 /* Precedence.UnaryAdd */, (_, right) => new UnaryOperatorAtom(right, (x) => x))
|
|
10326
|
+
.prefix('-', 3 /* Precedence.UnarySubtract */, (_, right) => new ArithemticOperatorAtom(right, right, (_, y) => -y))
|
|
10327
|
+
.infixLeft('.', 1 /* Precedence.Dot */, (left, _, right) => new DotAtom(left, right))
|
|
10328
|
+
.infixLeft('/', 4 /* Precedence.Divide */, (left, _, right) => new ArithemticOperatorAtom(left, right, (x, y) => x / y))
|
|
10329
|
+
.infixLeft('*', 4 /* Precedence.Multiply */, (left, _, right) => new ArithemticOperatorAtom(left, right, (x, y) => x * y))
|
|
10330
|
+
.infixLeft('+', 5 /* Precedence.Add */, (left, _, right) => new ArithemticOperatorAtom(left, right, (x, y) => x + y))
|
|
10331
|
+
.infixLeft('-', 5 /* Precedence.Subtract */, (left, _, right) => new ArithemticOperatorAtom(left, right, (x, y) => x - y))
|
|
10332
|
+
.infixLeft('|', 7 /* Precedence.Union */, (left, _, right) => new UnionAtom(left, right))
|
|
10333
|
+
.infixLeft('=', 9 /* Precedence.Equals */, (left, _, right) => new EqualsAtom(left, right))
|
|
10334
|
+
.infixLeft('!=', 9 /* Precedence.Equals */, (left, _, right) => new NotEqualsAtom(left, right))
|
|
10335
|
+
.infixLeft('~', 9 /* Precedence.Equivalent */, (left, _, right) => new EquivalentAtom(left, right))
|
|
10336
|
+
.infixLeft('!~', 9 /* Precedence.NotEquivalent */, (left, _, right) => new NotEquivalentAtom(left, right))
|
|
10337
|
+
.infixLeft('<', 8 /* Precedence.LessThan */, (left, _, right) => new ArithemticOperatorAtom(left, right, (x, y) => x < y))
|
|
10338
|
+
.infixLeft('<=', 8 /* Precedence.LessThanOrEquals */, (left, _, right) => new ArithemticOperatorAtom(left, right, (x, y) => x <= y))
|
|
10339
|
+
.infixLeft('>', 8 /* Precedence.GreaterThan */, (left, _, right) => new ArithemticOperatorAtom(left, right, (x, y) => x > y))
|
|
10340
|
+
.infixLeft('>=', 8 /* Precedence.GreaterThanOrEquals */, (left, _, right) => new ArithemticOperatorAtom(left, right, (x, y) => x >= y))
|
|
10341
|
+
.infixLeft('&', 5 /* Precedence.Ampersand */, (left, _, right) => new ConcatAtom(left, right))
|
|
10342
|
+
.infixLeft('and', 6 /* Precedence.Is */, (left, _, right) => new AndAtom(left, right))
|
|
10343
|
+
.infixLeft('as', 6 /* Precedence.Is */, (left, _, right) => new AsAtom(left, right))
|
|
10344
|
+
.infixLeft('contains', 6 /* Precedence.Is */, (left, _, right) => new ContainsAtom(left, right))
|
|
10345
|
+
.infixLeft('div', 6 /* Precedence.Is */, (left, _, right) => new ArithemticOperatorAtom(left, right, (x, y) => (x / y) | 0))
|
|
10346
|
+
.infixLeft('in', 6 /* Precedence.Is */, (left, _, right) => new InAtom(left, right))
|
|
10347
|
+
.infixLeft('is', 6 /* Precedence.Is */, (left, _, right) => new IsAtom(left, right))
|
|
10348
|
+
.infixLeft('mod', 6 /* Precedence.Is */, (left, _, right) => new ArithemticOperatorAtom(left, right, (x, y) => x % y))
|
|
10349
|
+
.infixLeft('or', 6 /* Precedence.Is */, (left, _, right) => new OrAtom(left, right))
|
|
10350
|
+
.infixLeft('xor', 6 /* Precedence.Is */, (left, _, right) => new XorAtom(left, right));
|
|
10351
|
+
}
|
|
10352
|
+
const fhirPathParserBuilder = initFhirPathParserBuilder();
|
|
10281
10353
|
/**
|
|
10282
10354
|
* Parses a FHIRPath expression into an AST.
|
|
10283
10355
|
* The result can be used to evaluate the expression against a resource or other object.
|
|
@@ -10287,17 +10359,12 @@
|
|
|
10287
10359
|
* @returns The AST representing the expression.
|
|
10288
10360
|
*/
|
|
10289
10361
|
function parseFhirPath(input) {
|
|
10290
|
-
|
|
10291
|
-
return new FhirPathAtom(input, parserBuilder.construct(input).consumeAndParse());
|
|
10292
|
-
}
|
|
10293
|
-
catch (error) {
|
|
10294
|
-
throw new Error(`FhirPathError on "${input}": ${error}`);
|
|
10295
|
-
}
|
|
10362
|
+
return new FhirPathAtom(input, fhirPathParserBuilder.construct(tokenize(input)).consumeAndParse());
|
|
10296
10363
|
}
|
|
10297
10364
|
/**
|
|
10298
10365
|
* Evaluates a FHIRPath expression against a resource or other object.
|
|
10299
|
-
* @param
|
|
10300
|
-
* @param
|
|
10366
|
+
* @param expression The FHIRPath expression to parse.
|
|
10367
|
+
* @param input The resource or object to evaluate the expression against.
|
|
10301
10368
|
* @returns The result of the FHIRPath expression against the resource or object.
|
|
10302
10369
|
*/
|
|
10303
10370
|
function evalFhirPath(expression, input) {
|
|
@@ -10314,8 +10381,8 @@
|
|
|
10314
10381
|
}
|
|
10315
10382
|
/**
|
|
10316
10383
|
* Evaluates a FHIRPath expression against a resource or other object.
|
|
10317
|
-
* @param
|
|
10318
|
-
* @param
|
|
10384
|
+
* @param expression The FHIRPath expression to parse.
|
|
10385
|
+
* @param input The resource or object to evaluate the expression against.
|
|
10319
10386
|
* @returns The result of the FHIRPath expression against the resource or object.
|
|
10320
10387
|
*/
|
|
10321
10388
|
function evalFhirPathTyped(expression, input) {
|
|
@@ -10443,7 +10510,7 @@
|
|
|
10443
10510
|
issue: [
|
|
10444
10511
|
{
|
|
10445
10512
|
severity: 'information',
|
|
10446
|
-
code: '
|
|
10513
|
+
code: 'informational',
|
|
10447
10514
|
details: {
|
|
10448
10515
|
text: 'All OK',
|
|
10449
10516
|
},
|
|
@@ -10456,7 +10523,7 @@
|
|
|
10456
10523
|
issue: [
|
|
10457
10524
|
{
|
|
10458
10525
|
severity: 'information',
|
|
10459
|
-
code: '
|
|
10526
|
+
code: 'informational',
|
|
10460
10527
|
details: {
|
|
10461
10528
|
text: 'Created',
|
|
10462
10529
|
},
|
|
@@ -10469,7 +10536,7 @@
|
|
|
10469
10536
|
issue: [
|
|
10470
10537
|
{
|
|
10471
10538
|
severity: 'information',
|
|
10472
|
-
code: '
|
|
10539
|
+
code: 'informational',
|
|
10473
10540
|
details: {
|
|
10474
10541
|
text: 'Not Modified',
|
|
10475
10542
|
},
|
|
@@ -10521,7 +10588,7 @@
|
|
|
10521
10588
|
issue: [
|
|
10522
10589
|
{
|
|
10523
10590
|
severity: 'error',
|
|
10524
|
-
code: '
|
|
10591
|
+
code: 'deleted',
|
|
10525
10592
|
details: {
|
|
10526
10593
|
text: 'Gone',
|
|
10527
10594
|
},
|
|
@@ -10860,17 +10927,32 @@
|
|
|
10860
10927
|
* 2) The "token" type includes enums and booleans.
|
|
10861
10928
|
* 3) Arrays/multiple values are not reflected at all.
|
|
10862
10929
|
*
|
|
10863
|
-
* @param structureDefinitions Collection of StructureDefinition resources indexed by name.
|
|
10864
10930
|
* @param resourceType The root resource type.
|
|
10865
10931
|
* @param searchParam The search parameter.
|
|
10866
10932
|
* @returns The search parameter type details.
|
|
10867
10933
|
*/
|
|
10868
|
-
function getSearchParameterDetails(
|
|
10934
|
+
function getSearchParameterDetails(resourceType, searchParam) {
|
|
10935
|
+
var _a, _b;
|
|
10936
|
+
let result = (_b = (_a = globalSchema.types[resourceType]) === null || _a === void 0 ? void 0 : _a.searchParamsDetails) === null || _b === void 0 ? void 0 : _b[searchParam.code];
|
|
10937
|
+
if (!result) {
|
|
10938
|
+
result = buildSearchParamterDetails(resourceType, searchParam);
|
|
10939
|
+
}
|
|
10940
|
+
return result;
|
|
10941
|
+
}
|
|
10942
|
+
function setSearchParamterDetails(resourceType, code, details) {
|
|
10943
|
+
const typeSchema = globalSchema.types[resourceType];
|
|
10944
|
+
if (!typeSchema.searchParamsDetails) {
|
|
10945
|
+
typeSchema.searchParamsDetails = {};
|
|
10946
|
+
}
|
|
10947
|
+
typeSchema.searchParamsDetails[code] = details;
|
|
10948
|
+
}
|
|
10949
|
+
function buildSearchParamterDetails(resourceType, searchParam) {
|
|
10869
10950
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
10870
10951
|
if (searchParam.code === '_lastUpdated') {
|
|
10871
10952
|
return { columnName: 'lastUpdated', type: exports.SearchParameterType.DATETIME };
|
|
10872
10953
|
}
|
|
10873
|
-
const
|
|
10954
|
+
const code = searchParam.code;
|
|
10955
|
+
const columnName = convertCodeToColumnName(code);
|
|
10874
10956
|
const expression = (_a = getExpressionForResourceType(resourceType, searchParam.expression)) === null || _a === void 0 ? void 0 : _a.split('.');
|
|
10875
10957
|
if (!expression) {
|
|
10876
10958
|
// This happens on compound types
|
|
@@ -10885,7 +10967,7 @@
|
|
|
10885
10967
|
for (let i = 1; i < expression.length; i++) {
|
|
10886
10968
|
const propertyName = expression[i];
|
|
10887
10969
|
elementDefinition =
|
|
10888
|
-
(_d = (_c = (_b =
|
|
10970
|
+
(_d = (_c = (_b = globalSchema.types[baseType]) === null || _b === void 0 ? void 0 : _b.properties) === null || _c === void 0 ? void 0 : _c[propertyName]) !== null && _d !== void 0 ? _d : (_f = (_e = globalSchema.types[baseType]) === null || _e === void 0 ? void 0 : _e.properties) === null || _f === void 0 ? void 0 : _f[propertyName + '[x]'];
|
|
10889
10971
|
if (!elementDefinition) {
|
|
10890
10972
|
throw new Error(`Element definition not found for ${resourceType} ${searchParam.code}`);
|
|
10891
10973
|
}
|
|
@@ -10908,7 +10990,9 @@
|
|
|
10908
10990
|
}
|
|
10909
10991
|
}
|
|
10910
10992
|
const type = getSearchParameterType(searchParam, propertyType);
|
|
10911
|
-
|
|
10993
|
+
const result = { columnName, type, elementDefinition, array };
|
|
10994
|
+
setSearchParamterDetails(resourceType, code, result);
|
|
10995
|
+
return result;
|
|
10912
10996
|
}
|
|
10913
10997
|
/**
|
|
10914
10998
|
* Converts a hyphen-delimited code to camelCase string.
|
|
@@ -10990,6 +11074,8 @@
|
|
|
10990
11074
|
exports.EmptySetAtom = EmptySetAtom;
|
|
10991
11075
|
exports.EqualsAtom = EqualsAtom;
|
|
10992
11076
|
exports.EquivalentAtom = EquivalentAtom;
|
|
11077
|
+
exports.FHIRPATH_KEYWORDS = FHIRPATH_KEYWORDS;
|
|
11078
|
+
exports.FHIRPATH_OPERATORS = FHIRPATH_OPERATORS;
|
|
10993
11079
|
exports.FIELD_SEPARATOR = FIELD_SEPARATOR;
|
|
10994
11080
|
exports.FhirPathAtom = FhirPathAtom;
|
|
10995
11081
|
exports.FunctionAtom = FunctionAtom;
|
|
@@ -11051,6 +11137,7 @@
|
|
|
11051
11137
|
exports.getCodeBySystem = getCodeBySystem;
|
|
11052
11138
|
exports.getDateProperty = getDateProperty;
|
|
11053
11139
|
exports.getDisplayString = getDisplayString;
|
|
11140
|
+
exports.getElementDefinition = getElementDefinition;
|
|
11054
11141
|
exports.getExpressionForResourceType = getExpressionForResourceType;
|
|
11055
11142
|
exports.getExtensionValue = getExtensionValue;
|
|
11056
11143
|
exports.getIdentifier = getIdentifier;
|
|
@@ -11066,6 +11153,7 @@
|
|
|
11066
11153
|
exports.indexSearchParameter = indexSearchParameter;
|
|
11067
11154
|
exports.indexStructureDefinition = indexStructureDefinition;
|
|
11068
11155
|
exports.indexStructureDefinitionBundle = indexStructureDefinitionBundle;
|
|
11156
|
+
exports.initFhirPathParserBuilder = initFhirPathParserBuilder;
|
|
11069
11157
|
exports.isEmpty = isEmpty;
|
|
11070
11158
|
exports.isGone = isGone;
|
|
11071
11159
|
exports.isLowerCase = isLowerCase;
|