diff --git a/package.json b/package.json index 4448b42..b4fae27 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@molgenis/vip-report-api", - "version": "0.8.1", + "version": "1.0.0", "description": "Report API for Variant Call Format (VCF) Report Templates", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/src/__tests__/index.test.ts b/src/__tests__/index.test.ts index 13dae8f..377f208 100644 --- a/src/__tests__/index.test.ts +++ b/src/__tests__/index.test.ts @@ -120,6 +120,7 @@ beforeEach(() => { info: [], format: [], }, + urls: {}, }, data: { samples: { @@ -166,6 +167,7 @@ test('getMeta', async () => { info: [], format: [], }, + urls: {}, }); }); diff --git a/src/index.ts b/src/index.ts index ccaab95..50bd39e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -7,6 +7,7 @@ export interface Metadata { app: AppMetadata; htsFile: HtsFileMetadata; records: RecordsMetadata; + urls: UrlsMetadata; } export interface Data { @@ -84,6 +85,15 @@ export interface RecordsMetadata { format: FormatMetadata[]; } +export interface UrlsMetadata { + reference?: string; + referenceAccessToken?: string; + alignment?: string; + alignmentAccessToken?: string; + variant?: string; + variantAccessToken?: string; +} + export interface CompoundMetadata { id: string; number?: NumberMetadata; @@ -183,9 +193,7 @@ export default class Api { } getMeta(): Promise { - return new Promise((resolve) => { - resolve(this.reportData.metadata); - }); + return Promise.resolve(this.reportData.metadata); } get(resource: string, params: Params = {}): Promise> { @@ -257,17 +265,33 @@ function compareAsc(a: unknown, b: unknown) { } else if (b === null) { return -1; } else if (typeof a === 'number' && typeof b === 'number') { - return a - b; + return compareAscNumber(a, b); } else if (typeof a === 'string' && typeof b === 'string') { - return a.toUpperCase().localeCompare(b.toUpperCase()); + return compareAscString(a, b); } else if (typeof a === 'boolean' && typeof b === 'boolean') { - return a === b ? 0 : a ? -1 : 1; + return compareAscBoolean(a, b); } else { const type = typeof a; throw new Error(`can't compare values of type '${type}'. consider providing a custom compare function.`); } } +function compareAscNumber(a: number, b: number) { + return a - b; +} + +function compareAscString(a: string, b: string) { + return a.toUpperCase().localeCompare(b.toUpperCase()); +} + +function compareAscBoolean(a: boolean, b: boolean) { + if (a === b) { + return 0; + } else { + return a ? -1 : 1; + } +} + function compareDesc(a: unknown, b: unknown) { return compareAsc(b, a); }