From 67edbd5ffbcd7659a5bf559fd4f8e6d3918ae241 Mon Sep 17 00:00:00 2001 From: Ruben Slabbert Date: Thu, 1 Jun 2017 15:01:09 +1000 Subject: [PATCH] Added qlik sense 3.1 typings (#16836) * Added qlik sense 3.1 typings * Fixed linting issues * Add explicit typescript version to header * Bump required typescript version to 2.2 * No relative imports --- types/qlik/index.d.ts | 914 +++++++++++++++++++++++++++++++++++++++ types/qlik/qlik-tests.ts | 53 +++ types/qlik/tsconfig.json | 23 + types/qlik/tslint.json | 1 + 4 files changed, 991 insertions(+) create mode 100644 types/qlik/index.d.ts create mode 100644 types/qlik/qlik-tests.ts create mode 100644 types/qlik/tsconfig.json create mode 100644 types/qlik/tslint.json diff --git a/types/qlik/index.d.ts b/types/qlik/index.d.ts new file mode 100644 index 0000000000..22c84f0ff1 --- /dev/null +++ b/types/qlik/index.d.ts @@ -0,0 +1,914 @@ +// Type definitions for Qlik Sense 3.1 +// Project: https://help.qlik.com/en-US/sense-developer/3.1/Content/APIs-and-SDKs.htm +// Definitions by: Ruben Slabbert , AginicX +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +import 'jquery'; + +export interface Size { + qcx: number; + qcy: number; +} + +export interface NxValidationError { + qErrorCode: number; + qContext: string; + qExtendedMessage: string; +} + +export interface NxStateCounts { + qLocked: number; + qSelected: number; + qOption: number; + qDeselected: number; + qAlternative: number; + qExcluded: number; + qSelectedExcluded: number; + qLockedExcluded: number; +} + +export interface FieldAttributes { + qType: 'U' | 'A' | 'I' | 'R' | 'F' | 'M' | 'D' | 'T' | 'TS' | 'IV'; + qnDec: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15; + qUseThou: 0 | 1; + qFmt: string; + qDec: string; + qThou: string; + qSAFEARRAY: any[]; +} + +export interface CharRange { + qCharPos: number; + qCharCount: number; +} + +export interface NxHighlightRanges { + qRanges: CharRange[]; +} + +export interface NxSimpleValue { + qText: string; + qNum: number; +} + +export interface NxAttributeExpressionValues { + qValues: NxSimpleValue[]; +} + +export type NxCellRows = NxCell[]; + +export interface NxGroupTail { + qUp: number; + qDown: number; +} + +export interface Rect { + qLeft: number; + qTop: number; + qWdith: number; + qHeight: number; +} + +export interface NxPivotDimensioncell { + qText: string; + qElemNo: number; + qValue: number; + qCanExpand: boolean; + qCanCollapse: boolean; + qType: 'V' | 'E' | 'N' | 'T' | 'P' | 'R' | 'U'; + qUp: number; + qDown: number; + qSubNodes: NxPivotDimensioncell[]; + qAttrExps: NxAttributeExpressionValues[]; + qAttrDims: NxAttributeDimValues[]; +} + +export interface NxPivotValuePoint { + qLabel?: string; + qText: string; + qNum: number; + qType: 'V' | 'E' | 'N' | 'T' | 'P' | 'R' | 'U'; + qAttrExps: NxAttributeExpressionValues; +} + +export interface NxPivotPage { + qLeft: NxPivotDimensioncell[]; + qTop: NxPivotDimensioncell[]; + qData: NxPivotValuePoint[]; + qArea: Rect; +} + +export interface NxStackedPivotCell { + qText: string; + qElemNo: number; + qValue: number; + qCanExpand: boolean; + qCanCollapse: boolean; + qType: 'V' | 'E' | 'N' | 'T' | 'P' | 'R' | 'U'; + qMaxPos: number; + qMinNeg: number; + qUp: number; + qDown: number; + qRow: number; + qSubNodes: NxStackedPivotCell[]; + qAttrExps: NxAttributeExpressionValues; + qAttrDims: NxAttributeDimValues; +} + +export interface NxStackPage { + qData: NxStackedPivotCell[]; + qArea: Rect; +} + +export interface NxCellPosition { + qx: number; + qy: number; +} + +export interface NxDataPage { + qMatrix: NxCellRows[]; + qTails: NxGroupTail[]; + qArea: Rect; + qIsReduced: boolean; +} + +export interface NxAttributeDimValues { + qValues: NxSimpleDimValue[]; +} + +export interface NxSimpleDimValue { + qText: string; + qElemNo: number; +} + +export interface NxCell { + qText: string; + qNum: number; + qElemNumber: number; + qState: 'L' | 'S' | 'O' | 'D' | 'A' | 'X' | 'XS' | 'XL'; + qIsEmpty: boolean; + qIsTotalCell: boolean; + qIsOtherCell: boolean; + qFrequency: string; + qHighlightRanges: NxHighlightRanges; + qAttrExps: NxAttributeExpressionValues; + qIsNull: boolean; + qAttrDims: NxAttributeDimValues; +} + +export interface NxAttrExprInfo { + qMin: number; + qMax: number; + qContinuousAxes: boolean; + qIsCyclic: boolean; + qFallbackTitle: string; +} + +export interface NxAttrDimInfo { + qCardinal: number; + qSize: Size; + qFallbackTitle: string; + qLocked: boolean; + qError: NxValidationError; +} + +export interface ColumnInfo { + qFallbackTitle: string; + qApprMaxGlyphCount: number; + qCardinal: string; + qSortIndicator: 'N' | 'A' | 'D'; + qNumFormat: FieldAttributes; + qIsAutoFormat: boolean; + qMin: number; + qMax: number; + qError: NxValidationError; + qReverseSort: boolean; + qAttrExprInfo: NxAttrExprInfo[]; + qAttrDimInfo: NxAttrDimInfo[]; +} + +export interface NxDimensionInfo extends ColumnInfo { + qLocker: string; + qGroupFallbackTitles: string[]; + qGroupPos: number; + qStateCounts: NxStateCounts; + qTags: string[]; + qDimensionType: 'D' | 'N' | 'T'; + qGrouping: 'N' | 'H' | 'C'; + qIsSemantic: boolean; + qGroupFieldDefs: string[]; + qContinuousAxes: boolean; + qIsCyclic: boolean; + qDerivedField: boolean; +} + +export type NxMeasureInfo = ColumnInfo; + +export interface HyperCube { + qStateName: string; + qSize: Size; + qError: NxValidationError; + qDimensionInfo: NxDimensionInfo[]; + qMeasureInfo: NxMeasureInfo[]; + qEffectiveInterColumnSortOrder: number[]; + qGrandTotalRow: NxCell[]; + qDataPages: NxDataPage[]; + qPivotDataPages: NxPivotPage[]; + qStackedDataPages: NxStackPage[]; + qMode: 'S' | 'P' | 'K'; + qNoOfLeftDims: number; + qIndentMode: boolean; + qLastExpandedPos: NxCellPosition; + qHasOtherValues: boolean; +} + +export interface NxInfo { + qId: string; + qType: string; +} + +export interface NxCurrentSelectionItem { + qTotal: number; + qIsNum?: boolean; + qField: string; + qLocked?: boolean; + qOneAndOnlyOne?: boolean; + qTextSearch?: string; + qSelectedCount: number; + qSelected: string; + qRangeInfo: RangeSelectInfo[]; + qSortIndex: number; + qStateCounts: NxStateCounts; + qSelectedFieldSelectionInfo: NxFieldSelectionInfo[]; + qNotSelectedFieldSelectionInfo: NxFieldSelectionInfo[]; + qSelectionThreshold: number; +} + +export interface RangeSelectInfo { + qRangeLo: number; + qRangeHi: number; + qMeasure: string; +} + +export interface NxFieldSelectionInfo { + qName: string; + qFieldSelectionmode: 'NORMAL' | 'AND' | 'NOT'; +} + +export interface Selectionobject { + qBackCount: number; + qForwardCount: number; + qSelections: NxCurrentSelectionItem[]; +} + +export interface Layout { + qHyperCube: HyperCube; + qInfo: NxInfo; + qSelectionInfo: Selectionobject; +} + +export interface ValueExpr { + qv: string; +} + +export interface SortCriteria { + qSortByState: -1 | 0 | 1; + qSortByFrequency: -1 | 0 | 1; + qSortByNumeric: -1 | 0 | 1; + qSortByAscii: -1 | 0 | 1; + qSortByLoadOrder: -1 | 0 | 1; + qSortByExpression: -1 | 0 | 1; + qExpression: ValueExpr; +} + +export interface NxInlineDimensionDef { + qGrouping: 'N' | 'H' | 'C'; + qFieldDefs: string[]; + qSortCriteries: SortCriteria[]; + qNumberPresentations: FieldAttributes[]; + qReverseSort: boolean; + qActiveField: number; +} + +export interface OtherTotalSpecProp { + qOtherMode: 'OTHER_OFF' | 'OTHER_COUNTED' + | 'OTHER_ABS_LIMITED' | 'OTHER_ABS_ACC_TARGET' + | 'OTHER_REL_LIMITED' | 'OTHER_REL_ACC_TARGET'; + qOtherCounted: ValueExpr; + qOtherLimit: ValueExpr; + qOtherLimitMode: 'OTHER_GE_LIMIT' | 'OTHER_LE_LIMIT' | 'OTHER_GT_LIMIT' | 'OTHER_LT_LIMIT'; + qSupressOther: boolean; + qForceBadValueKeeping: boolean; + qApplyEvenWhenPossiblyWrongResult: boolean; + qGlobalOtherGrouping: boolean; + qOtherCollapseInnerDimensions: boolean; + qOtherSortMode: 'OTHER_SORT_DEFAULT' | 'OTHER_SORT_DESCENDING' | 'OTHER_SORT_ASCENDING'; + qTotalMode: 'TOTAL_OFF' | 'TOTAL_EXPR'; + qReferencedExpression: string; +} + +export interface NxAttrExprDef { + qExpression: string; + qLibraryId: string; +} + +export interface NxAttrDimDef { + qDef: string; + qLibraryId: string; + qSortBy: SortCriteria; +} + +export interface NxDimension { + qLibraryId: string; + qDef: NxInlineDimensionDef; + qNullSuppression: boolean; + qOtherTotalSpec: OtherTotalSpecProp; + qShowAll: boolean; + qOtherLabel: string; + qTotalLabel: string; + qCalcCond: ValueExpr; + qAttributeExpressions: NxAttrExprDef[]; + qAttributeDimensions: NxAttrDimDef[]; +} + +export interface NxMeasure { + qLibraryId: string; + qDef: NxInlineMeasureDef; + qSortBy: SortCriteria; + qAttributeExpressions: NxAttrExprDef[]; + qCalcCond: ValueExpr; + qAttributeDimensions: NxAttrDimDef[]; +} + +export interface NxInlineMeasureDef { + qcx: number; + qcy: number; +} + +export interface NxPage { + qLeft?: number; + qTop?: number; + qWidth?: number; + qHeight?: number; +} + +export interface HyperCubeDef { + qStateName?: string; + qDimensions?: NxDimension[]; + qMeasures?: NxMeasure[]; + qInterColumnSortOrder?: number[]; + qSuppressZero?: boolean; + qSupressMissing?: boolean; + qInitialDataFetch?: NxPage[]; + qMode?: 'S' | 'P' | 'K'; + qNoOfLeftDims?: number; + qAlwaysFullyExpanded?: boolean; + qMaxStackedCells?: number; + qPopulateMissing?: boolean; + qShowTotalsAbove?: boolean; + qIndentMode?: boolean; + qCalcCond?: ValueExpr; + qSortByYValue?: -1 | 0 | 1; +} + +export interface NxAutoSortByStateDef { + qDisplayNumberOfRows: number; +} + +export interface NxListobjectExpressionDef { + qExpr: string; + qLibraryId: string; +} + +export interface ListobjectDef { + qStateName: string; + qLibraryId: string; + qDef: NxInlineDimensionDef; + qAutoSortByState: NxAutoSortByStateDef; + qFrequencyMode: 'NX_FREQUENCY_NONE' | 'NX_FREQUENCY_VALUE' | 'NX_FREQUENCY_PERCENT' | 'NX_FREQUENCY_RELATIVE'; + qShowAlternatives: boolean; + qInitialDataFetch: NxPage[]; + qExpressions: NxListobjectExpressionDef[]; +} + +export interface InitialPropertiesHyperCube { + qHyperCubeDef: HyperCubeDef; + + [key: string]: any; +} + +export interface InitialPropertiesListobject { + qListobjectDef: ListobjectDef; + + [key: string]: any; +} + +export type InitialProperties = InitialPropertiesHyperCube | InitialPropertiesListobject; + +export interface SnapshotLegacy { + canTakeSnapshot: boolean; +} + +export type SupportFunction = (layout: Layout) => boolean; +export type SupportItem = boolean | SupportFunction; + +export interface Support { + snapshot: SupportItem | SnapshotLegacy; + export: SupportItem; + exportData: SupportItem; +} + +export type Paint = ( + this: ExtensionContext, + $element?: JQuery, + layout?: Layout, + qDimensionInfo?: NxDimensionInfo, + qMeasureInfo?: NxDimensionInfo, + qMatrix?: NxCellRows[], + dimensions?: NxCell[], + measures?: NxCell[], + qSize?: Size, + qId?: string, + qSelectionInfo?: Selectionobject +) => void; + +export interface VisualizationCommon { + qHyperCubeDef: HyperCubeDef; + title: string; + showTitles: boolean; + subtitle: string; + footnote: string; +} + +// TODO: Other types of visualizations +export type VisualizationOptions = VisualizationCommon; + +// TODO: Figure out other types +export type ShowFunction = (layout: Layout, cls: any, obj: any) => boolean + | ((measure: NxMeasure) => boolean); + +export interface CustomPropertyCommon { + type?: 'string' | 'integer' | 'number' | 'array' | 'boolean' | 'items'; + ref?: string; + label?: string; + show?: boolean | ShowFunction; +} + +export interface CustomPropertyString extends CustomPropertyCommon { + type: 'string'; + expression?: 'always' | 'optional' | ''; + maxLength?: number; + defaultValue?: string; +} + +export interface CustomPropertyInteger extends CustomPropertyCommon { + type: 'integer'; + component?: string; + min?: string; + max?: string; + defaultValue?: number; +} + +export interface CustomPropertyNumber extends CustomPropertyCommon { + type: 'number'; + component?: string; + min?: string; + max?: string; + defaultValue?: number; +} + +export interface CustomPropertyArray extends CustomPropertyCommon { + type: 'array'; + component?: undefined; + itemTitleRef?: string; + allowAdd?: boolean; + allowRemove?: boolean; + addTranslation?: string; + allowMove?: boolean; +} + +export interface CustomPropertyButton extends CustomPropertyCommon { + component: 'button'; + action(data: VisualizationOptions): void; +} + +export interface ButtonGroupOption { + value: string; + label: string; + tooltip: string; +} + +export interface CustomPropertyButtonGroup extends CustomPropertyCommon { + type: 'string'; + component: 'buttongroup'; + defaultValue?: string; + options?: ButtonGroupOption[] | (() => ButtonGroupOption[]); +} + +export interface CustomPropertyCheckbox extends CustomPropertyCommon { + type: 'boolean'; + defaultValue?: boolean; +} + +export interface CustomPropertyColorPicker extends CustomPropertyCommon { + type: 'integer'; + component: 'color-picker'; + defaultValue?: number; +} + +export interface CustomPropertyOption { + value: string; + label: string; +} + +export type CustomPropertyOptions = CustomPropertyOption[] | (() => CustomPropertyOption[]); + +export interface CustomPropertyDropdown extends CustomPropertyCommon { + type: 'string'; + ref: string; + component: 'dropdown'; + defaultValue?: string; + options?: CustomPropertyOptions; +} + +export interface CustomPropertyLink extends CustomPropertyCommon { + component: 'link'; + url?: string; +} + +export interface CustomProperyMedia extends CustomPropertyCommon { + type: 'string'; + component: 'media'; + layoutRef?: string; +} + +export interface CustomPropertyRadio extends CustomPropertyCommon { + type: 'string'; + component: 'radiobuttons'; + defaultValue?: string; + options?: CustomPropertyOptions; +} + +export interface CustomPropertySlider extends CustomPropertyCommon { + type: 'number'; + component: 'slider'; + defaultValue?: number; + min?: number; + max?: number; + step?: number; +} + +export interface CustomPropertyRangeSlider extends CustomPropertyCommon { + type: 'array'; + component: 'slider'; + defaultValue?: number; + min?: number; + max?: number; + step?: number; +} + +export interface CustomPropertySwitch extends CustomPropertyCommon { + type: 'boolean'; + component: 'switch'; + defaultValue?: string; + options?: CustomPropertyOptions; +} + +export interface CustomPropertyText extends CustomPropertyCommon { + component: 'text'; +} + +export interface CustomPropertyTextArea extends CustomPropertyCommon { + type: 'string'; + component: 'textarea'; + rows?: number; + maxlength?: number; + defaultValue?: string; +} + +export interface CustomPropertyExpression extends CustomPropertyCommon { + type: undefined; + component: 'expression'; + expressionType: 'dimension' | 'measure' | 'StringExpr' | 'ValueExpr' | 'ValueExpression' | 'StringExpression'; + defaultValue?: string; +} + +export interface CustomPropertyItems extends CustomPropertyCommon { + type: 'items'; + items: { + [key: string]: CustomProperty; + }; +} + +export type CustomProperty = CustomPropertyString | CustomPropertyInteger | CustomPropertyNumber + | CustomPropertyArray | CustomPropertyButton | CustomPropertyButtonGroup + | CustomPropertyCheckbox | CustomPropertyColorPicker | CustomPropertyDropdown + | CustomPropertyLink | CustomProperyMedia | CustomPropertyRadio + | CustomPropertySlider | CustomPropertyRangeSlider | CustomPropertySwitch + | CustomPropertyText | CustomPropertyTextArea | CustomPropertyExpression + | CustomPropertyItems; + +export interface Definition { + type: 'items'; + component: 'accordion'; + items: { + data?: { + uses: 'data'; + }; + dimensions?: { + uses: 'dimensions'; + ref?: string; + min?: number; + max?: number; + items?: { + [key: string]: CustomProperty; + } + }; + measures?: { + uses: 'measures'; + ref?: string; + min?: number; + max?: number; + items?: { + [key: string]: CustomProperty; + } + }; + sorting?: { + uses: 'sorting'; + items?: { + [key: string]: CustomProperty; + } + }; + settings?: { + uses: 'settings'; + items?: { + [key: string]: CustomProperty; + } + }; + }; +} + +export interface Extension { + initialProperties: InitialProperties; + definition: Definition; + paint: Paint; + support?: Support; +} + +export interface Patch { + qOp: 'add' | 'remove' | 'replace'; + qPath: string; + qValue: string; +} + +export interface BackendApi { + abortSearch(): void; + acceptSearch(toggleMode: boolean): void; + applyPatches(qPatches: Patch[], qSoftPatch: boolean): Promise; + clearSelections(): void; + clearSoftPatches(): Promise; + collapseLeft(qRow: number, qCol: number, qAll?: boolean): Promise; + collapseTop(qRow: number, qCol: number, qAll?: boolean): Promise; + eachDataRow(callback: (i: number, d: NxCellRows) => boolean | void): NxCellRows; + expandLeft(qRow: number, qCol: number, qAll?: boolean): Promise; + expandTop(qRow: number, qCol: number, qAll?: boolean): Promise; + getData(qPages: NxPage[]): Promise; + getDataRow(rownum: number): NxCellRows | null; + getDimensionInfos(): NxDimensionInfo[]; + getMeasureInfos(): NxMeasureInfo[]; + getPivotData(qPages: NxPage[]): Promise; + // TODO: getProperties(): Promise; + // TODO: getReducedData(qPages: NxPage[], qZoomFactor: number, qReductionMode: 'N' | 'D1' | 'S' | 'C' | 'ST'): Promise; + getRowCount(): number; + getStackeddata(qPages: NxPage[], qMaxNbrCells: number): Promise; + hasSelections(): boolean; + save(): Promise; + search(term: string): void; + // TODO: selectRange(qRanges: Ranges, qOrMode: boolean): void; + selectValues(qDimNo: number, qValues: number[], qToggleMode: boolean): void; + selectProperties(props: {}): Promise; +} + +export interface ExtensionContext { + $element: JQuery; + $scope: any; + _inAnalysisState: boolean; + _inEditState: boolean; + _interactionState: number; + _on: boolean; + backendApi: BackendApi; + // TODO: options: ExtensionOptions; + paint: Paint; + selectionsEnabled: boolean; + toggleLasso(): void; + + selectValues(dimNo: number, values: number[], toggleMode: boolean): void; + + // TODO: LOTS MORE +} + +export interface QDimensionCell { + qText: string; + qElemNumber: number; + qState: string; + qNum?: number; + + select(): void; +} + +export interface QMeasureCell { + qText: string; + qNum?: number; + + getPercent(): number; + getPercentOfMax(): number; +} + +export interface QRow { + dimensions: QDimensionCell[]; + measures: QMeasureCell[]; + cells: Array; +} + +export interface QHeader { + qFallbackTitle: string; + qSortIndicator: 'A' | 'B'; + isOrderedBy: boolean; + qReverseSort: boolean; + col: number; + qCardinal?: number; + qStateCounts?: { [state: string]: number }; + // field?: Field + qMin?: number; + qMax?: number; + errorCode?: number; + errorMessage?: number; + + orderBy(): void; + reverseOrder(): void; + selectRange(min: number, max: number, inclMin: boolean, inclMax: boolean): Promise; +} + +export interface ExportDataOptions { + format: 'OOXML' | 'CSV_C' | 'CSV_T'; + filename?: string; + state: 'A' | 'P'; + download: boolean; +} + +export interface QTable { + rows: QRow[]; + headers: QHeader[]; + totals: QMeasureCell[]; + rowCount: number; + colCount: number; + + exportData(options: ExportDataOptions, callback: (url: string) => void): void; + getColByName(fld: string): number | undefined; + getMoreData(): void; +} + +export interface Variable { + qContent: { + qIsNum: boolean; + qString: string; + }; +} + +export interface QFieldValue { + qText: string; + qElemNumber: number; + qState: any; // TODO + qNum?: string; + qFrequency?: string; + + select(toggle?: boolean, softlock?: boolean): Promise; +} + +export interface GetDataOptions { + rows: number; + frequencyMode: 'V' | 'P' | 'R' | 'N'; +} + +export interface QField { + rows?: QFieldValue[]; + rowCount?: number; + qStateCounts?: { [state: string]: number; }; + + clear(): Promise; + clearOther(softlock: boolean): Promise; + getData(options: GetDataOptions): this; + getMoreData(): this; + lock(): Promise; + select(values: number[], toggle?: boolean, softlock?: boolean): Promise; + selectAll(softlock?: boolean): Promise; + selectAlternative(softlock?: boolean): Promise; + selectExcluded(softlock?: boolean): Promise; + selectMatch(match: string, softlock?: boolean): Promise; + selectPossible(softlock?: boolean): Promise; + selectValues(values: QFieldValue[], toggle?: boolean, softlock?: boolean): Promise; + toggleSelect(match: string, softlock?: boolean): Promise; + unlock(): Promise; +} + +export type ListTypes = 'FieldList' | 'MeasureList' | 'DimensionList' | 'BookmarkList' + | 'Selectionobject' | 'SnapshotList' | 'MediaList' | 'sheet' + | 'Materobject' | 'VariableList' | 'story'; + +export interface App { + addAlternateState(qStateName: string): Promise; + back(): Promise; + clearrAll(lockedAlso?: boolean, state?: string): Promise; + close(): void; + createCube(qHyperCubeDef: HyperCubeDef, callback?: (hypercube: HyperCube) => void): Promise; // TODO: Returns Promise + // TODO: createGenericobject + // TODO: createList(qListobjectDef: ListobjectDef, callback?: (hypercube: TODO) => void): Promise; + // TODO: createTable(dimensions: Array, measures: Array, options?: object): QTable; + destroySession(id: string): Promise; + doReload(qMode?: '0' | '1' | '2', qPartial?: boolean, qDebug?: boolean): Promise; + doSave(qFileName?: string): Promise; + field(field: string, state?: string): QField; + forward(): Promise; + getAppLayout(callback: (layout: Layout) => void): Promise; + // getAppobjectList(type: 'sheet' | 'masterobject', callback: (list: )) + getFullPropertyTree(id: string): Promise; + // getList(type: ListTypes, callback): Promise; + getobject(elem?: HTMLElement | string, id?: string | 'CurrentSelections', options?: { noInteraction?: boolean, noSelections?: boolean }): Promise; + getobjectProperties(id: string): Promise; + getSnapshot(elem?: HTMLElement | string, id?: string): Promise; + lockAll(state?: string): Promise; + removeAlternateState(qStateName: string): Promise; + // searchResults(qTerms: any[], qPage) + // searchSuggest(qTerms: any[], qOptions: { qSearchFields: any[] }, ): Promise; + // selectAssociations + // selectionState(state?: string): QSelectionState; + unlockAll(state?: string): Promise; + + variable: { + getContent(variable: string, callback: (value: Variable, app: App) => void): Promise; + setContent(variable: string, value: string): void; + }; +} + +export function callRepository(path: string, method: string, body: string): Promise; +export function currApp(reference: object): App; + +export interface GetAppConfig { + host?: string; + port: string | number; + prefix?: string; + isSecure?: boolean; + openWithoutData?: boolean; + identity?: string; +} + +export function getAppList(callback: App[], config: GetAppConfig): void; + +// TODO: fix any +export function getExtensionList(callback: any[]): Promise; + +export type Global = any; + +export interface GetGlobalConfig { + host: string; + port: string; + prefix: string; + isSecure: boolean; + identity: string; +} + +export function getGlobal(config: GetGlobalConfig): Global; +export function openApp(appId: string, config: GetAppConfig): App; +export function registerExtension(id: string, impl: Extension, metadata: object): void; +export function resize(ID?: string): void; + +export namespace LanguageCodes { + type German = 'de' | 'de-DE'; + type English = 'en' | 'en-US'; + type Spanish = 'es' | 'es-ES'; + type French = 'fr' | 'fr-FR'; + type Italian = 'it' | 'it-IT'; + type Japanese = 'ja' | 'ja-JP'; + type Korean = 'ko' | 'ko-KR'; + type Dutch = 'nl' | 'nl-NL'; + type Polish = 'pl' | 'pl-PL'; + type BrazilianPortuguese = 'pt' | 'pt-BR'; + type Russian = 'ru' | 'ru-RU'; + type Swedish = 'sv' | 'sv-SE'; + type Turkish = 'ts' | 'ts-TR'; + type SimplifiedChinese = 'zh-CN'; + type TraditionalChinese = 'zh-TW'; + + type ALL = German | English | Spanish | French | Italian | Japanese + | Korean | Dutch | Polish | BrazilianPortuguese | Russian + | Swedish | Turkish | SimplifiedChinese | TraditionalChinese; +} +export function setLanguage(lang: LanguageCodes.ALL): void; + +export interface Error { + code: any; // TODO: Find out if String or number + message: string; +} +export function setOnError(onError: (error: Error) => void, onWarning: (warning: string) => void): void; +export function table(ext: object, path?: string): void; diff --git a/types/qlik/qlik-tests.ts b/types/qlik/qlik-tests.ts new file mode 100644 index 0000000000..3256ac477f --- /dev/null +++ b/types/qlik/qlik-tests.ts @@ -0,0 +1,53 @@ +import * as Qlik from 'qlik'; + +// Extension API Test +() => { + const definition: Qlik.Definition = { + type: 'items', + component: 'accordion', + items: { + dimensions: { + uses: 'dimensions', + min: 1, + ref: "qHyperCubeDef.qDimensions", + items: { + isGrouping: { + type: 'boolean', + ref: 'qDef.isGrouping', + label: 'Is Grouping', + defaultValue: false, + }, + }, + }, + measures: { + uses: 'measures', + ref: "qHyperCubeDef.qMeasures", + min: 0, + }, + } + }; + + const initialProperties: Qlik.InitialProperties = { + qHyperCubeDef: { + qDimensions: [], + qMeasures: [], + qInitialDataFetch: [{ + qWidth: 10, + qHeight: 100, + }], + }, + }; + + function paint(this: Qlik.ExtensionContext, $element: JQuery, layout: Qlik.Layout) { + const dataRow = this.backendApi.getDataRow(0); + if (dataRow) { + $element.html(dataRow[0].qText); + } + } + + const e: Qlik.Extension = { + definition, + initialProperties, + paint, + }; +}; diff --git a/types/qlik/tsconfig.json b/types/qlik/tsconfig.json new file mode 100644 index 0000000000..88e56e6236 --- /dev/null +++ b/types/qlik/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "qlik-tests.ts" + ] +} diff --git a/types/qlik/tslint.json b/types/qlik/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/qlik/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }