Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build typescript .d.ts files #61

Merged
merged 2 commits into from
Dec 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,6 @@ yarn.lock

# docker files created by the docker containers for testing
tmp

types/*
!types/types.d.ts
110 changes: 59 additions & 51 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
"description": "Implementation of DICOMweb client code",
"main": "build/dicomweb-client.js",
"module": "build/dicomweb-client.es.js",
"types": "types/dicomweb-client.d.ts",
"scripts": {
"test": "./test_ci.sh",
"test:watch": "./test.sh",
"start": "rollup -c",
"build": "rollup -c",
"build": "rollup -c && npx tsc",
"watch": "rollup -c -w",
"version": "node -p -e \"'export default \\'' + require('./package.json').version + '\\';'\" > src/version.js",
"lint": "eslint -c .eslintrc.js --fix src && prettier --write src/**/*.js"
Expand Down Expand Up @@ -44,7 +45,7 @@
"prettier": "^1.16.4",
"puppeteer": "^1.18.1",
"rollup": "^0.63.2",
"rollup-plugin-babel": "^4.0.3"
},
"dependencies": {}
"rollup-plugin-babel": "^4.0.3",
"typescript": "^4.8.4"
}
}
50 changes: 28 additions & 22 deletions src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ const MEDIATYPES = {
PNG: 'image/png',
};


/**
* @typedef { import("../types/types").InstanceMetadata } InstanceMetadata
*/

/**
* A callback with the request instance and metadata information
* of the currently request being executed that should necessarily
Expand All @@ -50,14 +55,14 @@ class DICOMwebClient {
* @constructor
* @param {Object} options
* @param {String} options.url - URL of the DICOMweb RESTful Service endpoint
* @param {String} options.qidoURLPrefix - URL path prefix for QIDO-RS
* @param {String} options.wadoURLPrefix - URL path prefix for WADO-RS
* @param {String} options.stowURLPrefix - URL path prefix for STOW-RS
* @param {String} options.username - Username
* @param {String} options.password - Password
* @param {Object} options.headers - HTTP headers
* @param {Array.<RequestHook>} options.requestHooks - Request hooks.
* @param {Object} options.verbose - print to console request warnings and errors, default true
* @param {String=} options.qidoURLPrefix - URL path prefix for QIDO-RS
* @param {String=} options.wadoURLPrefix - URL path prefix for WADO-RS
* @param {String=} options.stowURLPrefix - URL path prefix for STOW-RS
* @param {String=} options.username - Username
* @param {String=} options.password - Password
* @param {Object=} options.headers - HTTP headers
* @param {Array.<RequestHook>=} options.requestHooks - Request hooks.
* @param {Object=} options.verbose - print to console request warnings and errors, default true
*/
constructor(options) {
this.baseURL = options.url;
Expand Down Expand Up @@ -955,8 +960,8 @@ class DICOMwebClient {
* Retrieves metadata for a DICOM study.
*
* @param {Object} options
* @param {Object} studyInstanceUID - Study Instance UID
* @returns {Object[]} Metadata elements in DICOM JSON format for each instance
* @param {String} options.studyInstanceUID - Study Instance UID
* @returns {Promise<InstanceMetadata[]>} Metadata elements in DICOM JSON format for each instance
belonging to the study
*/
retrieveStudyMetadata(options) {
Expand Down Expand Up @@ -1007,9 +1012,9 @@ class DICOMwebClient {
* Retrieves metadata for a DICOM series.
*
* @param {Object} options
* @param {Object} options.studyInstanceUID - Study Instance UID
* @param {Object} options.seriesInstanceUID - Series Instance UID
* @returns {Object[]} Metadata elements in DICOM JSON format for each instance
* @param {String} options.studyInstanceUID - Study Instance UID
* @param {String} options.seriesInstanceUID - Series Instance UID
* @returns {Promise<InstanceMetadata[]>} Metadata elements in DICOM JSON format for each instance
belonging to the series
*/
retrieveSeriesMetadata(options) {
Expand Down Expand Up @@ -1041,8 +1046,8 @@ class DICOMwebClient {
* Searches for DICOM Instances.
*
* @param {Object} options
* @param {Object} [options.studyInstanceUID] - Study Instance UID
* @param {Object} [options.seriesInstanceUID] - Series Instance UID
* @param {String} [options.studyInstanceUID] - Study Instance UID
* @param {String} [options.seriesInstanceUID] - Series Instance UID
* @param {Object} [options.queryParams] - HTTP query parameters
* @returns {Object[]} Instance representations (http://dicom.nema.org/medical/dicom/current/output/chtml/part18/sect_6.7.html#table_6.7.1-2b)
*/
Expand Down Expand Up @@ -1079,9 +1084,9 @@ class DICOMwebClient {
/** Returns a WADO-URI URL for an instance
*
* @param {Object} options
* @param {Object} options.studyInstanceUID - Study Instance UID
* @param {Object} options.seriesInstanceUID - Series Instance UID
* @param {Object} options.sopInstanceUID - SOP Instance UID
* @param {String} options.studyInstanceUID - Study Instance UID
* @param {String} options.seriesInstanceUID - Series Instance UID
* @param {String} options.sopInstanceUID - SOP Instance UID
* @returns {String} WADO-URI URL
*/
buildInstanceWadoURIUrl(options) {
Expand Down Expand Up @@ -1118,7 +1123,7 @@ class DICOMwebClient {
* @param {String} options.studyInstanceUID - Study Instance UID
* @param {String} options.seriesInstanceUID - Series Instance UID
* @param {String} options.sopInstanceUID - SOP Instance UID
* @returns {Object} metadata elements in DICOM JSON format
* @returns {Promise<InstanceMetadata>} metadata elements in DICOM JSON format
*/
retrieveInstanceMetadata(options) {
if (!('studyInstanceUID' in options)) {
Expand Down Expand Up @@ -1272,7 +1277,7 @@ class DICOMwebClient {
* @param {String} options.sopInstanceUID - SOP Instance UID
* @param {String[]} [options.mediaType] - Acceptable HTTP media types
* @param {Object} [options.queryParams] - HTTP query parameters
* @returns {ArrayBuffer} Rendered DICOM Instance
* @returns {Promise<ArrayBuffer>} Rendered DICOM Instance
*/
retrieveInstanceRendered(options) {
if (!('studyInstanceUID' in options)) {
Expand Down Expand Up @@ -1582,7 +1587,7 @@ class DICOMwebClient {
* @param {String} options.studyInstanceUID - Study Instance UID
* @param {String} options.seriesInstanceUID - Series Instance UID
* @param {String} options.sopInstanceUID - SOP Instance UID
* @returns {ArrayBuffer} DICOM Part 10 file as Arraybuffer
* @returns {Promise<ArrayBuffer>} DICOM Part 10 file as Arraybuffer
*/
retrieveInstance(options) {
if (!('studyInstanceUID' in options)) {
Expand Down Expand Up @@ -1626,7 +1631,8 @@ class DICOMwebClient {
* @param {Object} options
* @param {String} options.studyInstanceUID - Study Instance UID
* @param {String} options.seriesInstanceUID - Series Instance UID
* @returns {ArrayBuffer[]} DICOM Instances
* @param {Function} options.progressCallback
* @returns {Promise<ArrayBuffer[]>} DICOM Instances
*/
retrieveSeries(options) {
if (!('studyInstanceUID' in options)) {
Expand Down
10 changes: 10 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"include": ["src/**/*"],
"compilerOptions": {
"allowJs": true,
"declaration": true,
"emitDeclarationOnly": true,
"outDir": "types",
"declarationMap": true
}
}
Loading