@medplum/definitions
Version:
Medplum Data Definitions
8 lines (7 loc) • 3.15 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../../src/index.ts"],
"sourcesContent": ["// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors\n// SPDX-License-Identifier: Apache-2.0\nimport { readFileSync } from 'fs';\nimport { existsSync } from 'node:fs';\nimport { dirname, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nexport function readJson(filename: string): any {\n const filenamePath = resolve(getDataDir(), filename);\n return JSON.parse(readFileSync(filenamePath, 'utf8'));\n}\n\nlet cachedDataDir: string | undefined = undefined;\n\nexport function getDataDir(): string {\n if (cachedDataDir) {\n return cachedDataDir;\n }\n\n const currentDir = getCurrentDir();\n\n // Need to handle the following cases:\n // v4 and earlier: `index.js` in `dist/`, data in `dist/fhir/`\n // v5.0.0: data in `index.js` in `dist/cjs/` and `dist/esm/`, data in `/dist/cjs/fhir/` and `/dist/esm/fhir/`\n // v5.0.1 and after: `index.js` in `dist/cjs/` and `dist/esm/`, data back in `/dist/fhir/`\n const relativePaths = ['./', '../', './cjs/', './esm/'];\n for (const relativePath of relativePaths) {\n const fullPath = resolve(currentDir, relativePath);\n const fhirPath = resolve(fullPath, 'fhir');\n if (existsSync(fhirPath)) {\n cachedDataDir = fullPath;\n return fullPath;\n }\n }\n throw new Error('No data directory found');\n}\n\nfunction getCurrentDir(): string {\n if (typeof __dirname !== 'undefined') {\n return resolve(__dirname);\n } else if (import.meta.url) {\n return resolve(dirname(fileURLToPath(import.meta.url)));\n } else {\n throw new Error('No data directory found');\n }\n}\n\n/**\n * The list of all known search parameter definition bundle file paths relative to the\n * `@medplum/definitions` package. Typically used in conjunction with `readJson`.\n */\nexport const SEARCH_PARAMETER_BUNDLE_FILES = [\n 'fhir/r4/search-parameters.json',\n 'fhir/r4/search-parameters-medplum.json',\n 'fhir/r4/search-parameters-uscore.json',\n];\n"],
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mCAAAE,EAAA,eAAAC,EAAA,aAAAC,IAAA,eAAAC,EAAAL,GAEA,IAAAM,EAA6B,cAC7BC,EAA2B,mBAC3BC,EAAiC,qBACjCC,EAA8B,oBAL9BC,EAAA,GAOO,SAASN,EAASO,EAAuB,CAC9C,IAAMC,KAAe,WAAQT,EAAW,EAAGQ,CAAQ,EACnD,OAAO,KAAK,SAAM,gBAAaC,EAAc,MAAM,CAAC,CACtD,CAEA,IAAIC,EAEG,SAASV,GAAqB,CACnC,GAAIU,EACF,OAAOA,EAGT,IAAMC,EAAaC,EAAc,EAM3BC,EAAgB,CAAC,KAAM,MAAO,SAAU,QAAQ,EACtD,QAAWC,KAAgBD,EAAe,CACxC,IAAME,KAAW,WAAQJ,EAAYG,CAAY,EAC3CE,KAAW,WAAQD,EAAU,MAAM,EACzC,MAAI,cAAWC,CAAQ,EACrB,OAAAN,EAAgBK,EACTA,CAEX,CACA,MAAM,IAAI,MAAM,yBAAyB,CAC3C,CAEA,SAASH,GAAwB,CAC/B,GAAI,OAAO,UAAc,IACvB,SAAO,WAAQ,SAAS,EACnB,GAAIL,EAAY,IACrB,SAAO,cAAQ,cAAQ,iBAAcA,EAAY,GAAG,CAAC,CAAC,EAEtD,MAAM,IAAI,MAAM,yBAAyB,CAE7C,CAMO,IAAMR,EAAgC,CAC3C,iCACA,yCACA,uCACF",
"names": ["index_exports", "__export", "SEARCH_PARAMETER_BUNDLE_FILES", "getDataDir", "readJson", "__toCommonJS", "import_fs", "import_node_fs", "import_node_path", "import_node_url", "import_meta", "filename", "filenamePath", "cachedDataDir", "currentDir", "getCurrentDir", "relativePaths", "relativePath", "fullPath", "fhirPath"]
}