@gooddata/typings
Advanced tools
Comparing version 2.23.0-lanhuynh-lhq-sd-884-post-event-typings-2020-04-06T00-28-54-283Z to 2.23.0-lanhuynh-lhq-sd-884-post-event-typings-2020-04-06T08-55-20-053Z
@@ -1,5 +0,3 @@ | ||
import { CommandFailed, IObjectMeta, IGdcMessageEvent, IGdcMessageEventDataWrapper, ICommandFailedBody } from './common'; | ||
import { CommandFailed, IObjectMeta, IGdcMessageEvent, IGdcMessageEventDataWrapper, CommandFailedData, GdcProductName } from './common'; | ||
import { VisualizationObject } from '../VisualizationObject'; | ||
declare type ANALYTICAL_DESIGNER = 'analyticalDesigner'; | ||
export declare const AD_PRODUCT_NAME = "analyticalDesigner"; | ||
export interface IBaseExportConfig { | ||
@@ -14,3 +12,4 @@ title?: string; | ||
export declare namespace EmbeddedAnalyticalDesigner { | ||
type IADMessageEvent<T, TBody> = IGdcMessageEvent<ANALYTICAL_DESIGNER, T, TBody>; | ||
type IADMessageEvent<T, TBody> = IGdcMessageEvent<GdcProductName.ANALYTICAL_DESIGNER, T, TBody>; | ||
type IAdGdcMessageEventDataWrapper<T, TBody> = IGdcMessageEventDataWrapper<GdcProductName.ANALYTICAL_DESIGNER, T, TBody>; | ||
enum GdcAdCommandType { | ||
@@ -29,3 +28,3 @@ DrillableItems = "drillableItems", | ||
InsightOpened = "insightOpened", | ||
InsightSaved = "insightSaved", | ||
InsightSaved = "visualizationSaved", | ||
UndoFinished = "undoFinished", | ||
@@ -35,34 +34,10 @@ RedoFinished = "redoFinished", | ||
} | ||
enum GdcAdErrorType { | ||
/** | ||
* The posted command is not recognized by AD. | ||
*/ | ||
InvalidCommand = "error:invalidCommand", | ||
/** | ||
* Argument specified in the command body is invalid; it has failed the syntactical or semantic | ||
* validation done by AD. | ||
*/ | ||
InvalidArgument = "error:invalidArgument", | ||
/** | ||
* Command was posted when AD is not in a state to process the command. For instance: | ||
* | ||
* - trying to do save/save-as on new, empty insight | ||
* - trying to do save/save-as on insight that is in error | ||
* - trying to do undo when there is no step-back available | ||
* - trying to do redo when there is no step-forward available | ||
*/ | ||
InvalidState = "error:invalidState", | ||
/** | ||
* The Unexpected Happened. | ||
*/ | ||
RuntimeError = "error:runtime" | ||
} | ||
/** | ||
* This event will be emitted if AD runs into errors while processing the posted command. | ||
* | ||
* @remarks see {@link GdcAdErrorType} for types of errors that may fly | ||
* @remarks see {@link GdcErrorType} for types of errors that may fly | ||
*/ | ||
type AdCommandFailed = CommandFailed<ANALYTICAL_DESIGNER, ICommandFailedBody<GdcAdErrorType>>; | ||
type AdCommandFailedData = IGdcMessageEventDataWrapper<ANALYTICAL_DESIGNER, 'appCommandFailed', ICommandFailedBody<GdcAdErrorType>>; | ||
function createAdCommandFailedData(contextId: string, errorCode: GdcAdErrorType, errorMessage: string): AdCommandFailedData; | ||
type AdCommandFailed = CommandFailed<GdcProductName.ANALYTICAL_DESIGNER>; | ||
type AdCommandFailedData = CommandFailedData<GdcProductName.ANALYTICAL_DESIGNER>; | ||
function isAdCommandFailedData(obj: any): obj is AdCommandFailedData; | ||
interface ISimpleDrillableItemsCommandBody { | ||
@@ -76,4 +51,3 @@ uris?: string[]; | ||
type DrillableItemsCommand = IADMessageEvent<GdcAdCommandType.DrillableItems, IDrillableItemsCommandBody>; | ||
type DrillableItemsCommandData = IGdcMessageEventDataWrapper<ANALYTICAL_DESIGNER, GdcAdCommandType.DrillableItems, IDrillableItemsCommandBody>; | ||
function createIDrillableItemsData(drillableItemsData: IDrillableItemsCommandBody, contextId?: string): DrillableItemsCommandData; | ||
type DrillableItemsCommandData = IAdGdcMessageEventDataWrapper<GdcAdCommandType.DrillableItems, IDrillableItemsCommandBody>; | ||
/** | ||
@@ -95,4 +69,3 @@ * Type-guard checking whether object is an instance of DrillableItemsCommandData. | ||
type OpenInsightCommand = IADMessageEvent<GdcAdCommandType.OpenInsight, IOpenInsightCommandBody>; | ||
type OpenInsightCommandData = IGdcMessageEventDataWrapper<ANALYTICAL_DESIGNER, GdcAdCommandType.OpenInsight, IOpenInsightCommandBody>; | ||
function createOpenInsightData(insightData: IOpenInsightCommandBody, contextId?: string): OpenInsightCommandData; | ||
type OpenInsightCommandData = IAdGdcMessageEventDataWrapper<GdcAdCommandType.OpenInsight, IOpenInsightCommandBody>; | ||
/** | ||
@@ -122,15 +95,6 @@ * Type-guard checking whether object is an instance of OpenInsightCommandData. | ||
* Note: sending SaveCommand with different title means insight will be saved with that new title. | ||
* | ||
* @remarks use {@link createSaveInsightData} factory function to instantiate | ||
*/ | ||
type SaveInsightCommand = IADMessageEvent<GdcAdCommandType.Save, ISaveCommandBody>; | ||
type SaveInsightCommandData = IGdcMessageEventDataWrapper<ANALYTICAL_DESIGNER, GdcAdCommandType.Save, ISaveCommandBody>; | ||
type SaveInsightCommandData = IAdGdcMessageEventDataWrapper<GdcAdCommandType.Save, ISaveCommandBody>; | ||
/** | ||
* @param contextId - optionally specify contextId to include in any events that are posted | ||
* as part/at the end of command processing | ||
* @param title - title for the insight | ||
* @returns new Save insight command data | ||
*/ | ||
function createSaveInsightData(title: string, contextId?: string): SaveInsightCommandData; | ||
/** | ||
* Type-guard checking whether object is an instance of SaveInsightCommandData. | ||
@@ -148,15 +112,6 @@ * | ||
* Contract is same as {@link SaveInsightCommand}. | ||
* | ||
* @remarks use {@link createSaveAsInsightCommandData} factory function to instantiate | ||
*/ | ||
type SaveAsInsightCommand = IADMessageEvent<GdcAdCommandType.SaveAs, ISaveAsInsightCommandBody>; | ||
type SaveAsInsightCommandData = IGdcMessageEventDataWrapper<ANALYTICAL_DESIGNER, GdcAdCommandType.SaveAs, ISaveAsInsightCommandBody>; | ||
type SaveAsInsightCommandData = IAdGdcMessageEventDataWrapper<GdcAdCommandType.SaveAs, ISaveAsInsightCommandBody>; | ||
/** | ||
* @param title - title for the new insight | ||
* @param contextId - optionally specify contextId to include in any events that are posted | ||
* as part/at the end of command processing | ||
* @returns new SaveAsInsightCommandData | ||
*/ | ||
function createSaveAsInsightCommandData(title: string, contextId: string): SaveAsInsightCommandData; | ||
/** | ||
* Type-guard checking whether object is an instance of SaveAsCommand. | ||
@@ -183,15 +138,6 @@ * | ||
* will be posted | ||
* | ||
* @remarks use {@link createExportInsightCommandData} factory function to instantiate | ||
*/ | ||
type ExportInsightCommand = IADMessageEvent<GdcAdCommandType.Export, IExportInsightCommandBody>; | ||
type ExportInsightCommandData = IGdcMessageEventDataWrapper<ANALYTICAL_DESIGNER, GdcAdCommandType.Export, IExportInsightCommandBody>; | ||
type ExportInsightCommandData = IAdGdcMessageEventDataWrapper<GdcAdCommandType.Export, IExportInsightCommandBody>; | ||
/** | ||
* @param config - export config | ||
* @param contextId - optionally specify contextId to include in any events that are posted | ||
* as part/at the end of command processing | ||
* @returns new instance of ExportInsightCommandData | ||
*/ | ||
function createExportInsightCommandData(config: IExportConfig, contextId: string): ExportInsightCommandData; | ||
/** | ||
* Type-guard checking whether object is an instance of ExportCommand. | ||
@@ -211,9 +157,6 @@ * | ||
* - if the Undo operation is not available in current state of AD, then CommandFailed will be posted | ||
* | ||
* @remarks use {@link createUndoCommandData} factory function to instantiate | ||
*/ | ||
type UndoCommand = IADMessageEvent<GdcAdCommandType.Undo, undefined>; | ||
type UndoCommandData = IGdcMessageEventDataWrapper<ANALYTICAL_DESIGNER, GdcAdCommandType.Undo, undefined>; | ||
type UndoCommandData = IAdGdcMessageEventDataWrapper<GdcAdCommandType.Undo, undefined>; | ||
function isUndoCommandData(obj: any): obj is UndoCommandData; | ||
function createUndoCommandData(contextId?: string): UndoCommandData; | ||
/** | ||
@@ -228,9 +171,6 @@ * Triggers the redo action. | ||
* - if the Redo operation is not available in current state of AD, then CommandFailed will be posted | ||
* | ||
* @remarks use {@link createRedoCommandData} factory function to instantiate | ||
*/ | ||
type RedoCommand = IADMessageEvent<GdcAdCommandType.Redo, undefined>; | ||
type RedoCommandData = IGdcMessageEventDataWrapper<ANALYTICAL_DESIGNER, GdcAdCommandType.Redo, undefined>; | ||
type RedoCommandData = IAdGdcMessageEventDataWrapper<GdcAdCommandType.Redo, undefined>; | ||
function isRedoCommandData(obj: any): obj is RedoCommandData; | ||
function createRedoCommandData(contextId?: string): RedoCommandData; | ||
/** | ||
@@ -247,5 +187,4 @@ * List of available commands; this is included in each event sent by AD. | ||
type NewInsightInitialized = IADMessageEvent<GdcAdEventType.NewInsightInitialized, NewInsightInitializedBody>; | ||
type NewInsightInitializedData = IGdcMessageEventDataWrapper<ANALYTICAL_DESIGNER, GdcAdEventType.NewInsightInitialized, undefined>; | ||
type NewInsightInitializedData = IAdGdcMessageEventDataWrapper<GdcAdEventType.NewInsightInitialized, undefined>; | ||
function isNewInsightInitializedData(obj: any): obj is NewInsightInitializedData; | ||
function createNewInsightInitializedData(contextId: string): NewInsightInitializedData; | ||
type InsightOpenedBody = IAvailableCommands & { | ||
@@ -259,5 +198,4 @@ insight: IObjectMeta; | ||
type InsightOpened = IADMessageEvent<GdcAdEventType.InsightOpened, InsightOpenedBody>; | ||
type InsightOpenedData = IGdcMessageEventDataWrapper<ANALYTICAL_DESIGNER, GdcAdEventType.InsightOpened, InsightOpenedBody>; | ||
type InsightOpenedData = IAdGdcMessageEventDataWrapper<GdcAdEventType.InsightOpened, InsightOpenedBody>; | ||
function isInsightOpenedData(obj: any): obj is InsightOpenedData; | ||
function createInsightOpenedData(contextId: string): InsightOpenedData; | ||
type InsightSavedBody = IAvailableCommands & VisualizationObject.IVisualization & { | ||
@@ -270,5 +208,4 @@ insight: IObjectMeta; | ||
type InsightSaved = IADMessageEvent<GdcAdEventType.InsightSaved, InsightSavedBody>; | ||
type InsightSavedData = IGdcMessageEventDataWrapper<ANALYTICAL_DESIGNER, GdcAdEventType.InsightSaved, InsightSavedBody>; | ||
type InsightSavedData = IAdGdcMessageEventDataWrapper<GdcAdEventType.InsightSaved, InsightSavedBody>; | ||
function isInsightSavedData(obj: any): obj is InsightSavedData; | ||
function createInsightSavedData(contextId: string): InsightSavedData; | ||
type ExportFinishedBody = IAvailableCommands & { | ||
@@ -284,5 +221,4 @@ /** | ||
type ExportFinished = IADMessageEvent<GdcAdEventType.ExportFinished, ExportFinishedBody>; | ||
type ExportFinishedData = IGdcMessageEventDataWrapper<ANALYTICAL_DESIGNER, GdcAdEventType.ExportFinished, ExportFinishedBody>; | ||
type ExportFinishedData = IAdGdcMessageEventDataWrapper<GdcAdEventType.ExportFinished, ExportFinishedBody>; | ||
function isExportFinishedData(obj: any): obj is ExportFinishedData; | ||
function createExportFinishedData(contextId: string): ExportFinishedData; | ||
type UndoFinishedBody = IAvailableCommands; | ||
@@ -293,5 +229,4 @@ /** | ||
type UndoFinished = IADMessageEvent<GdcAdEventType.UndoFinished, UndoFinishedBody>; | ||
type UndoFinishedData = IGdcMessageEventDataWrapper<ANALYTICAL_DESIGNER, GdcAdEventType.UndoFinished, UndoFinishedBody>; | ||
type UndoFinishedData = IAdGdcMessageEventDataWrapper<GdcAdEventType.UndoFinished, UndoFinishedBody>; | ||
function isUndoFinishedData(obj: any): obj is UndoFinishedData; | ||
function createUndoFinishedData(contextId: string): UndoFinishedData; | ||
type RedoFinishedBody = IAvailableCommands; | ||
@@ -302,6 +237,4 @@ /** | ||
type RedoFinished = IADMessageEvent<GdcAdEventType.RedoFinished, RedoFinishedBody>; | ||
type RedoFinishedData = IGdcMessageEventDataWrapper<ANALYTICAL_DESIGNER, GdcAdEventType.RedoFinished, RedoFinishedBody>; | ||
type RedoFinishedData = IAdGdcMessageEventDataWrapper<GdcAdEventType.RedoFinished, RedoFinishedBody>; | ||
function isRedoFinishedData(obj: any): obj is RedoFinishedData; | ||
function createRedoFinishedData(contextId: string): RedoFinishedData; | ||
} | ||
export {}; |
"use strict"; | ||
exports.__esModule = true; | ||
// (C) 2020 GoodData Corporation | ||
exports.__esModule = true; | ||
var isEmpty = require("lodash/isEmpty"); | ||
exports.AD_PRODUCT_NAME = 'analyticalDesigner'; | ||
var lodash_1 = require("lodash"); | ||
var common_1 = require("./common"); | ||
var EmbeddedAnalyticalDesigner; | ||
@@ -23,3 +23,4 @@ (function (EmbeddedAnalyticalDesigner) { | ||
GdcAdEventType["InsightOpened"] = "insightOpened"; | ||
GdcAdEventType["InsightSaved"] = "insightSaved"; | ||
// use `visualizationSaved` because of backward compatibility | ||
GdcAdEventType["InsightSaved"] = "visualizationSaved"; | ||
GdcAdEventType["UndoFinished"] = "undoFinished"; | ||
@@ -29,56 +30,6 @@ GdcAdEventType["RedoFinished"] = "redoFinished"; | ||
})(GdcAdEventType = EmbeddedAnalyticalDesigner.GdcAdEventType || (EmbeddedAnalyticalDesigner.GdcAdEventType = {})); | ||
var GdcAdErrorType; | ||
(function (GdcAdErrorType) { | ||
/** | ||
* The posted command is not recognized by AD. | ||
*/ | ||
GdcAdErrorType["InvalidCommand"] = "error:invalidCommand"; | ||
/** | ||
* Argument specified in the command body is invalid; it has failed the syntactical or semantic | ||
* validation done by AD. | ||
*/ | ||
GdcAdErrorType["InvalidArgument"] = "error:invalidArgument"; | ||
/** | ||
* Command was posted when AD is not in a state to process the command. For instance: | ||
* | ||
* - trying to do save/save-as on new, empty insight | ||
* - trying to do save/save-as on insight that is in error | ||
* - trying to do undo when there is no step-back available | ||
* - trying to do redo when there is no step-forward available | ||
*/ | ||
GdcAdErrorType["InvalidState"] = "error:invalidState"; | ||
/** | ||
* The Unexpected Happened. | ||
*/ | ||
GdcAdErrorType["RuntimeError"] = "error:runtime"; | ||
})(GdcAdErrorType = EmbeddedAnalyticalDesigner.GdcAdErrorType || (EmbeddedAnalyticalDesigner.GdcAdErrorType = {})); | ||
function createAdCommandFailedData(contextId, errorCode, errorMessage) { | ||
return { | ||
gdc: { | ||
product: exports.AD_PRODUCT_NAME, | ||
event: { | ||
name: 'appCommandFailed', | ||
contextId: contextId, | ||
data: { | ||
errorCode: errorCode, | ||
errorMessage: errorMessage | ||
} | ||
} | ||
} | ||
}; | ||
function isAdCommandFailedData(obj) { | ||
return common_1.isCommandFailedData(obj); | ||
} | ||
EmbeddedAnalyticalDesigner.createAdCommandFailedData = createAdCommandFailedData; | ||
function createIDrillableItemsData(drillableItemsData, contextId) { | ||
return { | ||
gdc: { | ||
product: exports.AD_PRODUCT_NAME, | ||
event: { | ||
name: GdcAdCommandType.DrillableItems, | ||
contextId: contextId, | ||
data: drillableItemsData | ||
} | ||
} | ||
}; | ||
} | ||
EmbeddedAnalyticalDesigner.createIDrillableItemsData = createIDrillableItemsData; | ||
EmbeddedAnalyticalDesigner.isAdCommandFailedData = isAdCommandFailedData; | ||
/** | ||
@@ -90,18 +41,5 @@ * Type-guard checking whether object is an instance of DrillableItemsCommandData. | ||
function isDrillableItemsCommandData(obj) { | ||
return !isEmpty(obj) && obj.gdc.event.name === GdcAdCommandType.DrillableItems; | ||
return lodash_1.get(obj, 'gdc.event.name') === GdcAdCommandType.DrillableItems; | ||
} | ||
EmbeddedAnalyticalDesigner.isDrillableItemsCommandData = isDrillableItemsCommandData; | ||
function createOpenInsightData(insightData, contextId) { | ||
return { | ||
gdc: { | ||
product: exports.AD_PRODUCT_NAME, | ||
event: { | ||
name: GdcAdCommandType.OpenInsight, | ||
contextId: contextId, | ||
data: insightData | ||
} | ||
} | ||
}; | ||
} | ||
EmbeddedAnalyticalDesigner.createOpenInsightData = createOpenInsightData; | ||
/** | ||
@@ -113,27 +51,6 @@ * Type-guard checking whether object is an instance of OpenInsightCommandData. | ||
function isOpenInsightCommandData(obj) { | ||
return !isEmpty(obj) && obj.gdc.event.name === GdcAdCommandType.OpenInsight; | ||
return lodash_1.get(obj, 'gdc.event.name') === GdcAdCommandType.OpenInsight; | ||
} | ||
EmbeddedAnalyticalDesigner.isOpenInsightCommandData = isOpenInsightCommandData; | ||
/** | ||
* @param contextId - optionally specify contextId to include in any events that are posted | ||
* as part/at the end of command processing | ||
* @param title - title for the insight | ||
* @returns new Save insight command data | ||
*/ | ||
function createSaveInsightData(title, contextId) { | ||
return { | ||
gdc: { | ||
product: exports.AD_PRODUCT_NAME, | ||
event: { | ||
name: GdcAdCommandType.Save, | ||
contextId: contextId, | ||
data: { | ||
title: title | ||
} | ||
} | ||
} | ||
}; | ||
} | ||
EmbeddedAnalyticalDesigner.createSaveInsightData = createSaveInsightData; | ||
/** | ||
* Type-guard checking whether object is an instance of SaveInsightCommandData. | ||
@@ -144,27 +61,6 @@ * | ||
function isSaveInsightCommandData(obj) { | ||
return !isEmpty(obj) && obj.gdc.event.name === GdcAdCommandType.Save; | ||
return lodash_1.get(obj, 'gdc.event.name') === GdcAdCommandType.Save; | ||
} | ||
EmbeddedAnalyticalDesigner.isSaveInsightCommandData = isSaveInsightCommandData; | ||
/** | ||
* @param title - title for the new insight | ||
* @param contextId - optionally specify contextId to include in any events that are posted | ||
* as part/at the end of command processing | ||
* @returns new SaveAsInsightCommandData | ||
*/ | ||
function createSaveAsInsightCommandData(title, contextId) { | ||
return { | ||
gdc: { | ||
product: exports.AD_PRODUCT_NAME, | ||
event: { | ||
name: GdcAdCommandType.SaveAs, | ||
contextId: contextId, | ||
data: { | ||
title: title | ||
} | ||
} | ||
} | ||
}; | ||
} | ||
EmbeddedAnalyticalDesigner.createSaveAsInsightCommandData = createSaveAsInsightCommandData; | ||
/** | ||
* Type-guard checking whether object is an instance of SaveAsCommand. | ||
@@ -175,27 +71,6 @@ * | ||
function isSaveAsInsightCommandData(obj) { | ||
return !isEmpty(obj) && obj.gdc.event.name === GdcAdCommandType.SaveAs; | ||
return lodash_1.get(obj, 'gdc.event.name') === GdcAdCommandType.SaveAs; | ||
} | ||
EmbeddedAnalyticalDesigner.isSaveAsInsightCommandData = isSaveAsInsightCommandData; | ||
/** | ||
* @param config - export config | ||
* @param contextId - optionally specify contextId to include in any events that are posted | ||
* as part/at the end of command processing | ||
* @returns new instance of ExportInsightCommandData | ||
*/ | ||
function createExportInsightCommandData(config, contextId) { | ||
return { | ||
gdc: { | ||
product: exports.AD_PRODUCT_NAME, | ||
event: { | ||
name: GdcAdCommandType.Export, | ||
contextId: contextId, | ||
data: { | ||
config: config | ||
} | ||
} | ||
} | ||
}; | ||
} | ||
EmbeddedAnalyticalDesigner.createExportInsightCommandData = createExportInsightCommandData; | ||
/** | ||
* Type-guard checking whether object is an instance of ExportCommand. | ||
@@ -206,134 +81,38 @@ * | ||
function isExportInsightCommandData(obj) { | ||
return !isEmpty(obj) && obj.gdc.event.name === GdcAdCommandType.Export; | ||
return lodash_1.get(obj, 'gdc.event.name') === GdcAdCommandType.Export; | ||
} | ||
EmbeddedAnalyticalDesigner.isExportInsightCommandData = isExportInsightCommandData; | ||
function isUndoCommandData(obj) { | ||
return !isEmpty(obj) && obj.gdc.event.name === GdcAdCommandType.Undo; | ||
return lodash_1.get(obj, 'gdc.event.name') === GdcAdCommandType.Undo; | ||
} | ||
EmbeddedAnalyticalDesigner.isUndoCommandData = isUndoCommandData; | ||
function createUndoCommandData(contextId) { | ||
return { | ||
gdc: { | ||
product: exports.AD_PRODUCT_NAME, | ||
event: { | ||
name: GdcAdCommandType.Undo, | ||
contextId: contextId | ||
} | ||
} | ||
}; | ||
} | ||
EmbeddedAnalyticalDesigner.createUndoCommandData = createUndoCommandData; | ||
function isRedoCommandData(obj) { | ||
return !isEmpty(obj) && obj.gdc.event.name === GdcAdCommandType.Redo; | ||
return lodash_1.get(obj, 'gdc.event.name') === GdcAdCommandType.Redo; | ||
} | ||
EmbeddedAnalyticalDesigner.isRedoCommandData = isRedoCommandData; | ||
function createRedoCommandData(contextId) { | ||
return { | ||
gdc: { | ||
product: exports.AD_PRODUCT_NAME, | ||
event: { | ||
name: GdcAdCommandType.Redo, | ||
contextId: contextId | ||
} | ||
} | ||
}; | ||
} | ||
EmbeddedAnalyticalDesigner.createRedoCommandData = createRedoCommandData; | ||
function isNewInsightInitializedData(obj) { | ||
return (!isEmpty(obj) && obj.gdc.event.name === GdcAdEventType.NewInsightInitialized); | ||
return lodash_1.get(obj, 'gdc.event.name') === GdcAdEventType.NewInsightInitialized; | ||
} | ||
EmbeddedAnalyticalDesigner.isNewInsightInitializedData = isNewInsightInitializedData; | ||
function createNewInsightInitializedData(contextId) { | ||
return { | ||
gdc: { | ||
product: exports.AD_PRODUCT_NAME, | ||
event: { | ||
name: GdcAdEventType.NewInsightInitialized, | ||
contextId: contextId | ||
} | ||
} | ||
}; | ||
} | ||
EmbeddedAnalyticalDesigner.createNewInsightInitializedData = createNewInsightInitializedData; | ||
function isInsightOpenedData(obj) { | ||
return !isEmpty(obj) && obj.gdc.event.name === GdcAdEventType.InsightOpened; | ||
return lodash_1.get(obj, 'gdc.event.name') === GdcAdEventType.InsightOpened; | ||
} | ||
EmbeddedAnalyticalDesigner.isInsightOpenedData = isInsightOpenedData; | ||
function createInsightOpenedData(contextId) { | ||
return { | ||
gdc: { | ||
product: exports.AD_PRODUCT_NAME, | ||
event: { | ||
name: GdcAdEventType.InsightOpened, | ||
contextId: contextId | ||
} | ||
} | ||
}; | ||
} | ||
EmbeddedAnalyticalDesigner.createInsightOpenedData = createInsightOpenedData; | ||
function isInsightSavedData(obj) { | ||
return !isEmpty(obj) && obj.gdc.event.name === GdcAdEventType.InsightSaved; | ||
return lodash_1.get(obj, 'gdc.event.name') === GdcAdEventType.InsightSaved; | ||
} | ||
EmbeddedAnalyticalDesigner.isInsightSavedData = isInsightSavedData; | ||
function createInsightSavedData(contextId) { | ||
return { | ||
gdc: { | ||
product: exports.AD_PRODUCT_NAME, | ||
event: { | ||
name: GdcAdEventType.InsightSaved, | ||
contextId: contextId | ||
} | ||
} | ||
}; | ||
} | ||
EmbeddedAnalyticalDesigner.createInsightSavedData = createInsightSavedData; | ||
function isExportFinishedData(obj) { | ||
return !isEmpty(obj) && obj.gdc.event.name === GdcAdEventType.ExportFinished; | ||
return lodash_1.get(obj, 'gdc.event.name') === GdcAdEventType.ExportFinished; | ||
} | ||
EmbeddedAnalyticalDesigner.isExportFinishedData = isExportFinishedData; | ||
function createExportFinishedData(contextId) { | ||
return { | ||
gdc: { | ||
product: exports.AD_PRODUCT_NAME, | ||
event: { | ||
name: GdcAdEventType.ExportFinished, | ||
contextId: contextId | ||
} | ||
} | ||
}; | ||
} | ||
EmbeddedAnalyticalDesigner.createExportFinishedData = createExportFinishedData; | ||
function isUndoFinishedData(obj) { | ||
return !isEmpty(obj) && obj.gdc.event.name === GdcAdEventType.UndoFinished; | ||
return lodash_1.get(obj, 'gdc.event.name') === GdcAdEventType.UndoFinished; | ||
} | ||
EmbeddedAnalyticalDesigner.isUndoFinishedData = isUndoFinishedData; | ||
function createUndoFinishedData(contextId) { | ||
return { | ||
gdc: { | ||
product: exports.AD_PRODUCT_NAME, | ||
event: { | ||
name: GdcAdEventType.UndoFinished, | ||
contextId: contextId | ||
} | ||
} | ||
}; | ||
} | ||
EmbeddedAnalyticalDesigner.createUndoFinishedData = createUndoFinishedData; | ||
function isRedoFinishedData(obj) { | ||
return !isEmpty(obj) && obj.gdc.event.name === GdcAdEventType.RedoFinished; | ||
return lodash_1.get(obj, 'gdc.event.name') === GdcAdEventType.RedoFinished; | ||
} | ||
EmbeddedAnalyticalDesigner.isRedoFinishedData = isRedoFinishedData; | ||
function createRedoFinishedData(contextId) { | ||
return { | ||
gdc: { | ||
product: exports.AD_PRODUCT_NAME, | ||
event: { | ||
name: GdcAdEventType.RedoFinished, | ||
contextId: contextId | ||
} | ||
} | ||
}; | ||
} | ||
EmbeddedAnalyticalDesigner.createRedoFinishedData = createRedoFinishedData; | ||
})(EmbeddedAnalyticalDesigner = exports.EmbeddedAnalyticalDesigner || (exports.EmbeddedAnalyticalDesigner = {})); | ||
//# sourceMappingURL=ad.js.map |
@@ -0,1 +1,8 @@ | ||
export declare enum GdcProductName { | ||
ANALYTICAL_DESIGNER = "analyticalDesigner", | ||
KPI_DASHBOARDS = "dashboards" | ||
} | ||
export declare enum GdcEventType { | ||
AppCommandFailed = "appCommandFailed" | ||
} | ||
export interface IGdcMessageEventData<Product, T, TBody> { | ||
@@ -16,12 +23,36 @@ readonly product: Product; | ||
export declare type GdcMessageEventListener = (event: IGdcMessageEvent<string, string, any>) => boolean; | ||
export interface IConfig { | ||
export interface IGdcMessageEventListenerConfig { | ||
product: string; | ||
validReceivedPostEvents: string[]; | ||
} | ||
export interface ICommandFailedBody<TErrorCodes> { | ||
export declare enum GdcErrorType { | ||
/** | ||
* The posted command is not recognized by AD. | ||
*/ | ||
InvalidCommand = "error:invalidCommand", | ||
/** | ||
* Argument specified in the command body is invalid; it has failed the syntactical or semantic | ||
* validation done by AD. | ||
*/ | ||
InvalidArgument = "error:invalidArgument", | ||
/** | ||
* Command was posted when AD is not in a state to process the command. For instance: | ||
* | ||
* - trying to do save/save-as on new, empty insight | ||
* - trying to do save/save-as on insight that is in error | ||
* - trying to do undo when there is no step-back available | ||
* - trying to do redo when there is no step-forward available | ||
*/ | ||
InvalidState = "error:invalidState", | ||
/** | ||
* The Unexpected Happened. | ||
*/ | ||
RuntimeError = "error:runtime" | ||
} | ||
export interface ICommandFailedBody { | ||
/** | ||
* Error code indicates category of error that has occurred. | ||
* The possible types vary between applications. | ||
*/ | ||
errorCode: TErrorCodes; | ||
errorCode: GdcErrorType; | ||
/** | ||
@@ -37,4 +68,4 @@ * Error message includes descriptive information about the error. E.g. | ||
*/ | ||
export declare type CommandFailed<Product, TErrorCodes> = IGdcMessageEvent<Product, 'appCommandFailed', ICommandFailedBody<TErrorCodes>>; | ||
export declare type CommandFailedData<Product, TErrorCodes> = IGdcMessageEventDataWrapper<Product, 'appCommandFailed', ICommandFailedBody<TErrorCodes>>; | ||
export declare type CommandFailed<Product> = IGdcMessageEvent<Product, GdcEventType.AppCommandFailed, ICommandFailedBody>; | ||
export declare type CommandFailedData<Product> = IGdcMessageEventDataWrapper<Product, GdcEventType.AppCommandFailed, ICommandFailedBody>; | ||
/** | ||
@@ -45,4 +76,3 @@ * Type-guard checking whether an object is an instance of {@link CommandFailed} | ||
*/ | ||
export declare function isCommandFailedData<Product>(obj: any): obj is CommandFailedData<Product, any>; | ||
export declare function createCommandFailedData<Product, TErrorCodes>(product: Product, contextId: string, errorCode: TErrorCodes, errorMessage: string): CommandFailedData<Product, TErrorCodes>; | ||
export declare function isCommandFailedData<Product>(obj: any): obj is CommandFailedData<Product>; | ||
/** | ||
@@ -49,0 +79,0 @@ * Minimal meta-information about an object. |
@@ -5,2 +5,36 @@ "use strict"; | ||
var isEmpty = require("lodash/isEmpty"); | ||
var GdcProductName; | ||
(function (GdcProductName) { | ||
GdcProductName["ANALYTICAL_DESIGNER"] = "analyticalDesigner"; | ||
GdcProductName["KPI_DASHBOARDS"] = "dashboards"; | ||
})(GdcProductName = exports.GdcProductName || (exports.GdcProductName = {})); | ||
var GdcEventType; | ||
(function (GdcEventType) { | ||
GdcEventType["AppCommandFailed"] = "appCommandFailed"; | ||
})(GdcEventType = exports.GdcEventType || (exports.GdcEventType = {})); | ||
var GdcErrorType; | ||
(function (GdcErrorType) { | ||
/** | ||
* The posted command is not recognized by AD. | ||
*/ | ||
GdcErrorType["InvalidCommand"] = "error:invalidCommand"; | ||
/** | ||
* Argument specified in the command body is invalid; it has failed the syntactical or semantic | ||
* validation done by AD. | ||
*/ | ||
GdcErrorType["InvalidArgument"] = "error:invalidArgument"; | ||
/** | ||
* Command was posted when AD is not in a state to process the command. For instance: | ||
* | ||
* - trying to do save/save-as on new, empty insight | ||
* - trying to do save/save-as on insight that is in error | ||
* - trying to do undo when there is no step-back available | ||
* - trying to do redo when there is no step-forward available | ||
*/ | ||
GdcErrorType["InvalidState"] = "error:invalidState"; | ||
/** | ||
* The Unexpected Happened. | ||
*/ | ||
GdcErrorType["RuntimeError"] = "error:runtime"; | ||
})(GdcErrorType = exports.GdcErrorType || (exports.GdcErrorType = {})); | ||
/** | ||
@@ -12,21 +46,5 @@ * Type-guard checking whether an object is an instance of {@link CommandFailed} | ||
function isCommandFailedData(obj) { | ||
return !isEmpty(obj) && obj.gdc.event.name === 'appCommandFailed'; | ||
return !isEmpty(obj) && obj.gdc.event.name === GdcEventType.AppCommandFailed; | ||
} | ||
exports.isCommandFailedData = isCommandFailedData; | ||
function createCommandFailedData(product, contextId, errorCode, errorMessage) { | ||
return { | ||
gdc: { | ||
product: product, | ||
event: { | ||
name: 'appCommandFailed', | ||
contextId: contextId, | ||
data: { | ||
errorCode: errorCode, | ||
errorMessage: errorMessage | ||
} | ||
} | ||
} | ||
}; | ||
} | ||
exports.createCommandFailedData = createCommandFailedData; | ||
//# sourceMappingURL=common.js.map |
{ | ||
"name": "@gooddata/typings", | ||
"version": "2.23.0-lanhuynh-lhq-sd-884-post-event-typings-2020-04-06T00-28-54-283Z", | ||
"version": "2.23.0-lanhuynh-lhq-sd-884-post-event-typings-2020-04-06T08-55-20-053Z", | ||
"description": "TypeScript definition files for GoodData platform", | ||
@@ -5,0 +5,0 @@ "typings": "dist/index.d.ts", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
291131
4482