@gooddata/sdk-model
Advanced tools
Comparing version 8.0.0-alpha.3 to 8.0.0-alpha.4
import { IAttribute } from "./index"; | ||
import { ObjRef, Identifier } from "../base"; | ||
/** | ||
@@ -14,3 +15,3 @@ * Builder for attributes. | ||
*/ | ||
constructor(displayFormId: string); | ||
constructor(displayForm: ObjRef); | ||
alias: (alias: string) => this; | ||
@@ -21,3 +22,3 @@ localId: (localId: string) => this; | ||
localIdentifier: string; | ||
displayForm: import("../base").ObjRef; | ||
displayForm: ObjRef; | ||
alias?: string | undefined; | ||
@@ -34,7 +35,7 @@ }; | ||
/** | ||
* Creates a new attribute with the specified display form identifier and optional modifications and localIdentifier. | ||
* @param displayFormId - identifier of the attribute display form | ||
* Creates a new attribute with the specified display form ref and optional modifications and localIdentifier. | ||
* @param displayForm - ref or identifier of the attribute display form | ||
* @param modifications - optional modifications (e.g. alias, etc.) | ||
* @public | ||
*/ | ||
export declare function newAttribute(displayFormId: string, modifications?: AttributeModifications): IAttribute; | ||
export declare function newAttribute(displayForm: ObjRef | Identifier, modifications?: AttributeModifications): IAttribute; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// (C) 2019 GoodData Corporation | ||
// (C) 2019-2020 GoodData Corporation | ||
var identity = require("lodash/identity"); | ||
var base_1 = require("../base"); | ||
var factory_1 = require("../base/factory"); | ||
/** | ||
@@ -16,3 +18,3 @@ * Builder for attributes. | ||
*/ | ||
function AttributeBuilder(displayFormId) { | ||
function AttributeBuilder(displayForm) { | ||
var _this = this; | ||
@@ -31,4 +33,4 @@ this.alias = function (alias) { | ||
this.attribute = { | ||
displayForm: { identifier: displayFormId }, | ||
localIdentifier: "a_" + displayFormId, | ||
displayForm: displayForm, | ||
localIdentifier: "a_" + base_1.objectRefValue(displayForm), | ||
}; | ||
@@ -40,12 +42,13 @@ } | ||
/** | ||
* Creates a new attribute with the specified display form identifier and optional modifications and localIdentifier. | ||
* @param displayFormId - identifier of the attribute display form | ||
* Creates a new attribute with the specified display form ref and optional modifications and localIdentifier. | ||
* @param displayForm - ref or identifier of the attribute display form | ||
* @param modifications - optional modifications (e.g. alias, etc.) | ||
* @public | ||
*/ | ||
function newAttribute(displayFormId, modifications) { | ||
function newAttribute(displayForm, modifications) { | ||
if (modifications === void 0) { modifications = identity; } | ||
var builder = new AttributeBuilder(displayFormId); | ||
var ref = base_1.isObjRef(displayForm) ? displayForm : factory_1.idRef(displayForm); | ||
var builder = new AttributeBuilder(ref); | ||
return modifications(builder).build(); | ||
} | ||
exports.newAttribute = newAttribute; |
@@ -8,2 +8,8 @@ /** | ||
/** | ||
* Type for all URI's. | ||
* | ||
* @public | ||
*/ | ||
export declare type Uri = string; | ||
/** | ||
* Model object reference using object's URI. | ||
@@ -17,3 +23,3 @@ * | ||
export declare type UriRef = { | ||
uri: string; | ||
uri: Uri; | ||
}; | ||
@@ -68,2 +74,8 @@ /** | ||
/** | ||
* Type guard checking whether object is an Identifier Reference or an URI reference. | ||
* | ||
* @public | ||
*/ | ||
export declare function isObjRef(obj: any): obj is ObjRef; | ||
/** | ||
* Type guard checking whether object is a localId Reference. | ||
@@ -80,1 +92,8 @@ * | ||
export declare function objectRefValue(objRef: ObjRef | ObjRefInScope): string; | ||
/** | ||
* Returns a value indicating whether the two ObjRef instances are semantically equal (i.e. are of the same type and have the same value). | ||
* Null and undefined are considered equal to each other. | ||
* | ||
* @public | ||
*/ | ||
export declare function areObjRefsEqual(a: ObjRefInScope | null | undefined, b: ObjRefInScope | null | undefined): boolean; |
"use strict"; | ||
// (C) 2019 GoodData Corporation | ||
// (C) 2019-2020 GoodData Corporation | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -31,2 +31,11 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
/** | ||
* Type guard checking whether object is an Identifier Reference or an URI reference. | ||
* | ||
* @public | ||
*/ | ||
function isObjRef(obj) { | ||
return isUriRef(obj) || isIdentifierRef(obj); | ||
} | ||
exports.isObjRef = isObjRef; | ||
/** | ||
* Type guard checking whether object is a localId Reference. | ||
@@ -56,1 +65,20 @@ * | ||
exports.objectRefValue = objectRefValue; | ||
/** | ||
* Returns a value indicating whether the two ObjRef instances are semantically equal (i.e. are of the same type and have the same value). | ||
* Null and undefined are considered equal to each other. | ||
* | ||
* @public | ||
*/ | ||
function areObjRefsEqual(a, b) { | ||
if (a == null) { | ||
return b == null; | ||
} | ||
if (isIdentifierRef(a)) { | ||
return isIdentifierRef(b) && a.identifier === b.identifier; | ||
} | ||
if (isUriRef(a)) { | ||
return isUriRef(b) && a.uri === b.uri; | ||
} | ||
return isLocalIdRef(b) && a.localIdentifier === b.localIdentifier; | ||
} | ||
exports.areObjRefsEqual = areObjRefsEqual; |
import { AttributeElements, ComparisonConditionOperator, IAbsoluteDateFilter, IMeasureValueFilter, INegativeAttributeFilter, IPositiveAttributeFilter, IRelativeDateFilter, RangeConditionOperator } from "./index"; | ||
import { IAttribute } from "../attribute"; | ||
import { ObjRefInScope } from "../base"; | ||
import { ObjRefInScope, ObjRef, Identifier } from "../base"; | ||
import { IMeasure } from "../measure"; | ||
@@ -8,4 +8,3 @@ /** | ||
* | ||
* @param attributeOrId - either instance of attribute to create filter for or identifier of attribute's display form | ||
* if the input is attribute object, then it is expected that attribute references display form by identifier | ||
* @param attributeOrRef - either instance of attribute to create filter for or ref or identifier of attribute's display form | ||
* @param inValues - values to filter for; these can be either specified as AttributeElements object or as an array | ||
@@ -15,8 +14,7 @@ * of attribute element _values_ | ||
*/ | ||
export declare function newPositiveAttributeFilter(attributeOrId: IAttribute | string, inValues: AttributeElements | string[]): IPositiveAttributeFilter; | ||
export declare function newPositiveAttributeFilter(attributeOrRef: IAttribute | ObjRef | Identifier, inValues: AttributeElements | string[]): IPositiveAttributeFilter; | ||
/** | ||
* Creates a new negative attribute filter. | ||
* | ||
* @param attributeOrId - either instance of attribute to create filter for or identifier of attribute's display form; | ||
* if the input is attribute object, then it is expected that attribute references display form by identifier | ||
* @param attributeOrRef - either instance of attribute to create filter for or ref or identifier of attribute's display form | ||
* @param notInValues - values to filter out; these can be either specified as AttributeElements object or as an array | ||
@@ -26,7 +24,7 @@ * of attribute element _values_ | ||
*/ | ||
export declare function newNegativeAttributeFilter(attributeOrId: IAttribute | string, notInValues: AttributeElements | string[]): INegativeAttributeFilter; | ||
export declare function newNegativeAttributeFilter(attributeOrRef: IAttribute | ObjRef | Identifier, notInValues: AttributeElements | string[]): INegativeAttributeFilter; | ||
/** | ||
* Creates a new absolute date filter. | ||
* | ||
* @param dateDataSetId - identifier of the date data set to filter on | ||
* @param dateDataSet - ref or identifier of the date data set to filter on | ||
* @param from - start of the interval in ISO-8601 calendar date format | ||
@@ -36,7 +34,7 @@ * @param to - end of the interval in ISO-8601 calendar date format | ||
*/ | ||
export declare function newAbsoluteDateFilter(dateDataSetId: string, from: string, to: string): IAbsoluteDateFilter; | ||
export declare function newAbsoluteDateFilter(dateDataSet: ObjRef | Identifier, from: string, to: string): IAbsoluteDateFilter; | ||
/** | ||
* Creates a new relative date filter. | ||
* | ||
* @param dateDataSetId - identifier of the date data set to filter on | ||
* @param dateDataSet - ref or identifier of the date data set to filter on | ||
* @param granularity - granularity of the filters (month, year, etc.) | ||
@@ -47,3 +45,3 @@ * @param from - start of the interval – negative numbers mean the past, zero means today, positive numbers mean the future | ||
*/ | ||
export declare function newRelativeDateFilter(dateDataSetId: string, granularity: string, from: number, to: number): IRelativeDateFilter; | ||
export declare function newRelativeDateFilter(dateDataSet: ObjRef | Identifier, granularity: string, from: number, to: number): IRelativeDateFilter; | ||
/** | ||
@@ -50,0 +48,0 @@ * Creates a new measure value filter. |
@@ -6,11 +6,12 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// (C) 2019 GoodData Corporation | ||
// (C) 2019-2020 GoodData Corporation | ||
var ts_invariant_1 = __importDefault(require("ts-invariant")); | ||
var attribute_1 = require("../attribute"); | ||
var base_1 = require("../base"); | ||
var measure_1 = require("../measure"); | ||
var factory_1 = require("../base/factory"); | ||
/** | ||
* Creates a new positive attribute filter. | ||
* | ||
* @param attributeOrId - either instance of attribute to create filter for or identifier of attribute's display form | ||
* if the input is attribute object, then it is expected that attribute references display form by identifier | ||
* @param attributeOrRef - either instance of attribute to create filter for or ref or identifier of attribute's display form | ||
* @param inValues - values to filter for; these can be either specified as AttributeElements object or as an array | ||
@@ -20,8 +21,12 @@ * of attribute element _values_ | ||
*/ | ||
function newPositiveAttributeFilter(attributeOrId, inValues) { | ||
var displayFormId = typeof attributeOrId === "string" ? attributeOrId : attribute_1.attributeIdentifier(attributeOrId); | ||
function newPositiveAttributeFilter(attributeOrRef, inValues) { | ||
var objRef = base_1.isObjRef(attributeOrRef) | ||
? attributeOrRef | ||
: typeof attributeOrRef === "string" | ||
? factory_1.idRef(attributeOrRef) | ||
: attribute_1.attributeAttributeDisplayFormObjRef(attributeOrRef); | ||
var inObject = Array.isArray(inValues) ? { values: inValues } : inValues; | ||
return { | ||
positiveAttributeFilter: { | ||
displayForm: { identifier: displayFormId }, | ||
displayForm: objRef, | ||
in: inObject, | ||
@@ -35,4 +40,3 @@ }, | ||
* | ||
* @param attributeOrId - either instance of attribute to create filter for or identifier of attribute's display form; | ||
* if the input is attribute object, then it is expected that attribute references display form by identifier | ||
* @param attributeOrRef - either instance of attribute to create filter for or ref or identifier of attribute's display form | ||
* @param notInValues - values to filter out; these can be either specified as AttributeElements object or as an array | ||
@@ -42,8 +46,12 @@ * of attribute element _values_ | ||
*/ | ||
function newNegativeAttributeFilter(attributeOrId, notInValues) { | ||
var displayFormId = typeof attributeOrId === "string" ? attributeOrId : attribute_1.attributeIdentifier(attributeOrId); | ||
function newNegativeAttributeFilter(attributeOrRef, notInValues) { | ||
var objRef = base_1.isObjRef(attributeOrRef) | ||
? attributeOrRef | ||
: typeof attributeOrRef === "string" | ||
? factory_1.idRef(attributeOrRef) | ||
: attribute_1.attributeAttributeDisplayFormObjRef(attributeOrRef); | ||
var notInObject = Array.isArray(notInValues) ? { values: notInValues } : notInValues; | ||
return { | ||
negativeAttributeFilter: { | ||
displayForm: { identifier: displayFormId }, | ||
displayForm: objRef, | ||
notIn: notInObject, | ||
@@ -57,3 +65,3 @@ }, | ||
* | ||
* @param dateDataSetId - identifier of the date data set to filter on | ||
* @param dateDataSet - ref or identifier of the date data set to filter on | ||
* @param from - start of the interval in ISO-8601 calendar date format | ||
@@ -63,6 +71,7 @@ * @param to - end of the interval in ISO-8601 calendar date format | ||
*/ | ||
function newAbsoluteDateFilter(dateDataSetId, from, to) { | ||
function newAbsoluteDateFilter(dateDataSet, from, to) { | ||
var dataSet = base_1.isObjRef(dateDataSet) ? dateDataSet : factory_1.idRef(dateDataSet); | ||
return { | ||
absoluteDateFilter: { | ||
dataSet: { identifier: dateDataSetId }, | ||
dataSet: dataSet, | ||
from: from, | ||
@@ -77,3 +86,3 @@ to: to, | ||
* | ||
* @param dateDataSetId - identifier of the date data set to filter on | ||
* @param dateDataSet - ref or identifier of the date data set to filter on | ||
* @param granularity - granularity of the filters (month, year, etc.) | ||
@@ -84,6 +93,7 @@ * @param from - start of the interval – negative numbers mean the past, zero means today, positive numbers mean the future | ||
*/ | ||
function newRelativeDateFilter(dateDataSetId, granularity, from, to) { | ||
function newRelativeDateFilter(dateDataSet, granularity, from, to) { | ||
var dataSet = base_1.isObjRef(dateDataSet) ? dateDataSet : factory_1.idRef(dateDataSet); | ||
return { | ||
relativeDateFilter: { | ||
dataSet: { identifier: dateDataSetId }, | ||
dataSet: dataSet, | ||
granularity: granularity, | ||
@@ -90,0 +100,0 @@ from: from, |
import { ArithmeticMeasureOperator, IArithmeticMeasureDefinition, IMeasure, IMeasureDefinition, IMeasureDefinitionType, IPoPMeasureDefinition, IPreviousPeriodMeasureDefinition, MeasureAggregation } from "./index"; | ||
import { Identifier, ObjRef } from "../base"; | ||
/** | ||
@@ -44,3 +45,3 @@ * Simplified Previous Period Data DataSet specification | ||
*/ | ||
constructor(measureOrId: IMeasure<IMeasureDefinition> | string); | ||
constructor(measureOrRef: IMeasure<IMeasureDefinition> | ObjRef); | ||
aggregation: (aggregation: MeasureAggregation) => this; | ||
@@ -61,3 +62,3 @@ ratio: () => this; | ||
*/ | ||
constructor(measureIds: string[], operator: ArithmeticMeasureOperator); | ||
constructor(measureIds: Identifier[], operator: ArithmeticMeasureOperator); | ||
} | ||
@@ -75,3 +76,3 @@ /** | ||
*/ | ||
constructor(measureId: string, popAttributeId: string); | ||
constructor(measureId: Identifier, popAttributeId: Identifier); | ||
} | ||
@@ -99,7 +100,7 @@ /** | ||
* Creates a new measure with the specified identifier and optional modifications and localIdentifier. | ||
* @param measureId - identifier of the measure | ||
* @param measure - ref of identifier of the measure | ||
* @param modifications - optional modifications (e.g. alias, title, etc.) | ||
* @public | ||
*/ | ||
export declare function newMeasure(measureId: string, modifications?: MeasureModifications<MeasureBuilder>): IMeasure<IMeasureDefinition>; | ||
export declare function newMeasure(measure: ObjRef | Identifier, modifications?: MeasureModifications<MeasureBuilder>): IMeasure<IMeasureDefinition>; | ||
/** | ||
@@ -123,6 +124,6 @@ * Creates a new simple measure by applying modifications on top of an existing measure. | ||
*/ | ||
export declare function newArithmeticMeasure(measuresOrIds: ReadonlyArray<IMeasure | string>, operator: ArithmeticMeasureOperator, modifications?: MeasureModifications<ArithmeticMeasureBuilder>): IMeasure<IArithmeticMeasureDefinition>; | ||
export declare function newArithmeticMeasure(measuresOrIds: ReadonlyArray<IMeasure | Identifier>, operator: ArithmeticMeasureOperator, modifications?: MeasureModifications<ArithmeticMeasureBuilder>): IMeasure<IArithmeticMeasureDefinition>; | ||
/** | ||
* Creates a new PoP measure with the specified identifier and PoP attribute identifier and optional modifications and localIdentifier. | ||
* @param measureOrId - measure or identifier of the measure | ||
* @param measureOrLocalId - measure or local identifier of the measure | ||
* @param popAttributeId - identifier of the PoP attribute | ||
@@ -132,6 +133,6 @@ * @param modifications - optional modifications (e.g. alias, title, etc.) | ||
*/ | ||
export declare function newPopMeasure(measureOrId: IMeasure | string, popAttributeId: string, modifications?: MeasureModifications<PoPMeasureBuilder>): IMeasure<IPoPMeasureDefinition>; | ||
export declare function newPopMeasure(measureOrLocalId: IMeasure | Identifier, popAttributeId: string, modifications?: MeasureModifications<PoPMeasureBuilder>): IMeasure<IPoPMeasureDefinition>; | ||
/** | ||
* Creates a new Previous Period measure with the specified measure identifier and date data sets and optional modifications and localIdentifier. | ||
* @param measureIdOrId - measure or identifier of the measure to create Previous Period measure for | ||
* @param measureIdOrLocalId - measure or local identifier of the measure to create Previous Period measure for | ||
* @param dateDataSets - date data sets to use in the Previous Period calculation | ||
@@ -141,2 +142,2 @@ * @param modifications - optional modifications (e.g. alias, title, etc.) | ||
*/ | ||
export declare function newPreviousPeriodMeasure(measureIdOrId: IMeasure | string, dateDataSets: IPreviousPeriodDateDataSetSimple[], modifications?: MeasureModifications<PreviousPeriodMeasureBuilder>): IMeasure<IPreviousPeriodMeasureDefinition>; | ||
export declare function newPreviousPeriodMeasure(measureIdOrLocalId: IMeasure | Identifier, dateDataSets: IPreviousPeriodDateDataSetSimple[], modifications?: MeasureModifications<PreviousPeriodMeasureBuilder>): IMeasure<IPreviousPeriodMeasureDefinition>; |
@@ -27,6 +27,8 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// (C) 2019 GoodData Corporation | ||
// (C) 2019-2020 GoodData Corporation | ||
var cloneDeep = require("lodash/cloneDeep"); | ||
var identity = require("lodash/identity"); | ||
var index_1 = require("./index"); | ||
var base_1 = require("../base"); | ||
var factory_1 = require("../base/factory"); | ||
/** | ||
@@ -86,3 +88,3 @@ * Abstract base class for measure builders. Measure builders allow for incremental, fluent construction | ||
*/ | ||
function MeasureBuilder(measureOrId) { | ||
function MeasureBuilder(measureOrRef) { | ||
var _this = _super.call(this) || this; | ||
@@ -108,15 +110,16 @@ _this.aggregation = function (aggregation) { | ||
}; | ||
if (typeof measureOrId === "string") { | ||
if (base_1.isObjRef(measureOrRef)) { | ||
_this.measure.definition = { | ||
measureDefinition: { | ||
item: { identifier: measureOrId }, | ||
item: measureOrRef, | ||
}, | ||
}; | ||
_this.measure.localIdentifier = "m_" + measureOrId; | ||
_this.measureId = measureOrId; | ||
var refValue = base_1.objectRefValue(measureOrRef); | ||
_this.measure.localIdentifier = "m_" + refValue; | ||
_this.measureId = refValue; | ||
} | ||
else { | ||
_this.measure = cloneDeep(measureOrId.measure); | ||
_this.measure = cloneDeep(measureOrRef.measure); | ||
_this.customLocalId = true; | ||
_this.measureId = index_1.measureIdentifier(measureOrId); | ||
_this.measureId = index_1.measureIdentifier(measureOrRef); | ||
} | ||
@@ -210,9 +213,10 @@ return _this; | ||
* Creates a new measure with the specified identifier and optional modifications and localIdentifier. | ||
* @param measureId - identifier of the measure | ||
* @param measure - ref of identifier of the measure | ||
* @param modifications - optional modifications (e.g. alias, title, etc.) | ||
* @public | ||
*/ | ||
function newMeasure(measureId, modifications) { | ||
function newMeasure(measure, modifications) { | ||
if (modifications === void 0) { modifications = identity; } | ||
var builder = new MeasureBuilder(measureId); | ||
var ref = base_1.isObjRef(measure) ? measure : factory_1.idRef(measure); | ||
var builder = new MeasureBuilder(ref); | ||
return modifications(builder).build(); | ||
@@ -253,3 +257,3 @@ } | ||
* Creates a new PoP measure with the specified identifier and PoP attribute identifier and optional modifications and localIdentifier. | ||
* @param measureOrId - measure or identifier of the measure | ||
* @param measureOrLocalId - measure or local identifier of the measure | ||
* @param popAttributeId - identifier of the PoP attribute | ||
@@ -259,5 +263,5 @@ * @param modifications - optional modifications (e.g. alias, title, etc.) | ||
*/ | ||
function newPopMeasure(measureOrId, popAttributeId, modifications) { | ||
function newPopMeasure(measureOrLocalId, popAttributeId, modifications) { | ||
if (modifications === void 0) { modifications = identity; } | ||
var measureId = typeof measureOrId === "string" ? measureOrId : index_1.measureLocalId(measureOrId); | ||
var measureId = typeof measureOrLocalId === "string" ? measureOrLocalId : index_1.measureLocalId(measureOrLocalId); | ||
var builder = new PoPMeasureBuilder(measureId, popAttributeId); | ||
@@ -269,3 +273,3 @@ return modifications(builder).build(); | ||
* Creates a new Previous Period measure with the specified measure identifier and date data sets and optional modifications and localIdentifier. | ||
* @param measureIdOrId - measure or identifier of the measure to create Previous Period measure for | ||
* @param measureIdOrLocalId - measure or local identifier of the measure to create Previous Period measure for | ||
* @param dateDataSets - date data sets to use in the Previous Period calculation | ||
@@ -275,5 +279,5 @@ * @param modifications - optional modifications (e.g. alias, title, etc.) | ||
*/ | ||
function newPreviousPeriodMeasure(measureIdOrId, dateDataSets, modifications) { | ||
function newPreviousPeriodMeasure(measureIdOrLocalId, dateDataSets, modifications) { | ||
if (modifications === void 0) { modifications = identity; } | ||
var measureId = typeof measureIdOrId === "string" ? measureIdOrId : index_1.measureLocalId(measureIdOrId); | ||
var measureId = typeof measureIdOrLocalId === "string" ? measureIdOrLocalId : index_1.measureLocalId(measureIdOrLocalId); | ||
var builder = new PreviousPeriodMeasureBuilder(measureId, dateDataSets); | ||
@@ -280,0 +284,0 @@ return modifications(builder).build(); |
@@ -10,3 +10,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// (C) 2019 GoodData Corporation | ||
// (C) 2019-2020 GoodData Corporation | ||
var flow = require("lodash/flow"); | ||
@@ -62,3 +62,3 @@ var identity = require("lodash/identity"); | ||
var builder = getBuilder("a => a", [addAlias(attribute), addLocalId(attribute)]); | ||
return "newAttribute(\"" + getObjQualifierValue(attribute.displayForm) + "\", " + builder + ")"; | ||
return "newAttribute(" + stringify(attribute.displayForm) + ", " + builder + ")"; | ||
}; | ||
@@ -77,3 +77,3 @@ var baseMeasureDotAdders = function (measure) { return [ | ||
])); | ||
return "newMeasure(\"" + getObjQualifierValue(definition.measureDefinition.item) + "\", " + builder + ")"; | ||
return "newMeasure(" + stringify(definition.measureDefinition.item) + ", " + builder + ")"; | ||
}; | ||
@@ -131,3 +131,3 @@ var convertArithmeticMeasure = function (measure, definition) { | ||
var _b = _a.absoluteDateFilter, dataSet = _b.dataSet, from = _b.from, to = _b.to; | ||
var args = [getObjQualifierValue(dataSet), from, to].filter(identity).map(stringify); | ||
var args = [dataSet, from, to].filter(identity).map(stringify); | ||
return "newAbsoluteDateFilter(" + args.join(ARRAY_JOINER) + ")"; | ||
@@ -137,3 +137,3 @@ }; | ||
var _b = _a.relativeDateFilter, dataSet = _b.dataSet, granularity = _b.granularity, from = _b.from, to = _b.to; | ||
var args = [getObjQualifierValue(dataSet), granularity, from, to].filter(identity).map(stringify); | ||
var args = [dataSet, granularity, from, to].filter(identity).map(stringify); | ||
return "newRelativeDateFilter(" + args.join(ARRAY_JOINER) + ")"; | ||
@@ -143,3 +143,3 @@ }; | ||
var _b = _a.positiveAttributeFilter, displayForm = _b.displayForm, inValues = _b.in; | ||
var args = [getObjQualifierValue(displayForm), inValues].filter(identity).map(stringify); | ||
var args = [displayForm, inValues].filter(identity).map(stringify); | ||
return "newPositiveAttributeFilter(" + args.join(ARRAY_JOINER) + ")"; | ||
@@ -149,3 +149,3 @@ }; | ||
var _b = _a.negativeAttributeFilter, displayForm = _b.displayForm, notIn = _b.notIn; | ||
var args = [getObjQualifierValue(displayForm), notIn].filter(identity).map(stringify); | ||
var args = [displayForm, notIn].filter(identity).map(stringify); | ||
return "newNegativeAttributeFilter(" + args.join(ARRAY_JOINER) + ")"; | ||
@@ -152,0 +152,0 @@ }; |
export { IAttribute, isAttribute, attributeLocalId, AttributePredicate, anyAttribute, idMatchAttribute, attributesFind, attributeUri, attributeIdentifier, attributeAlias, attributeAttributeDisplayFormObjRef, } from "./execution/attribute"; | ||
export { newAttribute, AttributeBuilder, AttributeModifications } from "./execution/attribute/factory"; | ||
export { IAttributeDisplayForm, attributeDisplayFormId, attributeDisplayFormTitle, attributeDisplayFormAttributeId, attributeDisplayFormAttributeUri, } from "./ldm/attributeDisplayForm"; | ||
export { Identifier, UriRef, IdentifierRef, LocalIdRef, ObjRef, ObjRefInScope, isUriRef, isIdentifierRef, objectRefValue, } from "./execution/base"; | ||
export { Identifier, Uri, UriRef, IdentifierRef, LocalIdRef, ObjRef, ObjRefInScope, isUriRef, isIdentifierRef, objectRefValue, isLocalIdRef, areObjRefsEqual, isObjRef, } from "./execution/base"; | ||
export { IDimension, isDimension, dimensionTotals, DimensionItem, newTwoDimensional, newDimension, MeasureGroupIdentifier, dimensionSetTotals, } from "./execution/base/dimension"; | ||
export { idRef, uriRef, localIdRef } from "./execution/base/factory"; | ||
export { TotalType, ITotal, isTotal, newTotal, totalIsNative } from "./execution/base/totals"; | ||
@@ -17,3 +18,3 @@ export { SortDirection, IAttributeSortItem, SortItem, IMeasureSortItem, LocatorItem, IAttributeLocatorItem, IMeasureLocatorItem, isMeasureLocator, isAttributeLocator, isMeasureSort, isAttributeSort, newMeasureSort, newAttributeSort, newAttributeLocator, SortEntityIds, sortEntityIds, } from "./execution/base/sort"; | ||
export { GuidType, RgbType, IRgbColorValue, IColor, IColorPalette, IColorPaletteItem, IColorFromPalette, IRgbColor, isColorFromPalette, isRgbColor, } from "./colors"; | ||
export { IInsight, IInsightDefinition, IVisualizationClass, VisualizationProperties, IColorMappingItem, isInsight, insightId, insightMeasures, insightHasMeasures, insightAttributes, insightHasAttributes, insightHasDataDefined, insightProperties, insightBuckets, insightSorts, insightBucket, insightTitle, insightTotals, insightFilters, insightVisualizationClassUri, insightSetProperties, insightSetSorts, visClassUrl, } from "./insight"; | ||
export { IInsight, IInsightDefinition, IVisualizationClass, VisualizationProperties, IColorMappingItem, isInsight, insightId, insightMeasures, insightHasMeasures, insightAttributes, insightHasAttributes, insightHasDataDefined, insightProperties, insightBuckets, insightSorts, insightBucket, insightTitle, insightTotals, insightFilters, insightVisualizationUrl, insightSetProperties, insightSetSorts, visClassUrl, } from "./insight"; | ||
export { newInsightDefinition, InsightDefinitionBuilder, InsightModifications } from "./insight/factory"; | ||
@@ -20,0 +21,0 @@ export { CatalogItemType, CatalogItem, CatalogDateAttributeGranularity, ICatalogGroup, ICatalogAttribute, ICatalogFact, ICatalogMeasure, ICatalogDateDataset, ICatalogDateAttribute, isCatalogAttribute, isCatalogFact, isCatalogMeasure, isCatalogDateDataset, ICatalogItemBase, IGroupableCatalogItemBase, } from "./ldm/catalog"; |
@@ -26,2 +26,5 @@ "use strict"; | ||
exports.objectRefValue = base_1.objectRefValue; | ||
exports.isLocalIdRef = base_1.isLocalIdRef; | ||
exports.areObjRefsEqual = base_1.areObjRefsEqual; | ||
exports.isObjRef = base_1.isObjRef; | ||
var dimension_1 = require("./execution/base/dimension"); | ||
@@ -34,2 +37,6 @@ exports.isDimension = dimension_1.isDimension; | ||
exports.dimensionSetTotals = dimension_1.dimensionSetTotals; | ||
var factory_2 = require("./execution/base/factory"); | ||
exports.idRef = factory_2.idRef; | ||
exports.uriRef = factory_2.uriRef; | ||
exports.localIdRef = factory_2.localIdRef; | ||
var totals_1 = require("./execution/base/totals"); | ||
@@ -70,8 +77,8 @@ exports.isTotal = totals_1.isTotal; | ||
exports.measureValueFilterMeasure = filter_1.measureValueFilterMeasure; | ||
var factory_2 = require("./execution/filter/factory"); | ||
exports.newAbsoluteDateFilter = factory_2.newAbsoluteDateFilter; | ||
exports.newNegativeAttributeFilter = factory_2.newNegativeAttributeFilter; | ||
exports.newPositiveAttributeFilter = factory_2.newPositiveAttributeFilter; | ||
exports.newRelativeDateFilter = factory_2.newRelativeDateFilter; | ||
exports.newMeasureValueFilter = factory_2.newMeasureValueFilter; | ||
var factory_3 = require("./execution/filter/factory"); | ||
exports.newAbsoluteDateFilter = factory_3.newAbsoluteDateFilter; | ||
exports.newNegativeAttributeFilter = factory_3.newNegativeAttributeFilter; | ||
exports.newPositiveAttributeFilter = factory_3.newPositiveAttributeFilter; | ||
exports.newRelativeDateFilter = factory_3.newRelativeDateFilter; | ||
exports.newMeasureValueFilter = factory_3.newMeasureValueFilter; | ||
var measure_1 = require("./execution/measure"); | ||
@@ -104,13 +111,13 @@ exports.isMeasure = measure_1.isMeasure; | ||
exports.measurePreviousPeriodDateDataSets = measure_1.measurePreviousPeriodDateDataSets; | ||
var factory_3 = require("./execution/measure/factory"); | ||
exports.ArithmeticMeasureBuilder = factory_3.ArithmeticMeasureBuilder; | ||
exports.MeasureBuilder = factory_3.MeasureBuilder; | ||
exports.PoPMeasureBuilder = factory_3.PoPMeasureBuilder; | ||
exports.PreviousPeriodMeasureBuilder = factory_3.PreviousPeriodMeasureBuilder; | ||
exports.MeasureBuilderBase = factory_3.MeasureBuilderBase; | ||
exports.newMeasure = factory_3.newMeasure; | ||
exports.modifyMeasure = factory_3.modifyMeasure; | ||
exports.newArithmeticMeasure = factory_3.newArithmeticMeasure; | ||
exports.newPopMeasure = factory_3.newPopMeasure; | ||
exports.newPreviousPeriodMeasure = factory_3.newPreviousPeriodMeasure; | ||
var factory_4 = require("./execution/measure/factory"); | ||
exports.ArithmeticMeasureBuilder = factory_4.ArithmeticMeasureBuilder; | ||
exports.MeasureBuilder = factory_4.MeasureBuilder; | ||
exports.PoPMeasureBuilder = factory_4.PoPMeasureBuilder; | ||
exports.PreviousPeriodMeasureBuilder = factory_4.PreviousPeriodMeasureBuilder; | ||
exports.MeasureBuilderBase = factory_4.MeasureBuilderBase; | ||
exports.newMeasure = factory_4.newMeasure; | ||
exports.modifyMeasure = factory_4.modifyMeasure; | ||
exports.newArithmeticMeasure = factory_4.newArithmeticMeasure; | ||
exports.newPopMeasure = factory_4.newPopMeasure; | ||
exports.newPreviousPeriodMeasure = factory_4.newPreviousPeriodMeasure; | ||
var buckets_1 = require("./execution/buckets"); | ||
@@ -146,10 +153,10 @@ exports.isBucket = buckets_1.isBucket; | ||
exports.defTotals = executionDefinition_1.defTotals; | ||
var factory_4 = require("./execution/executionDefinition/factory"); | ||
exports.newDefForItems = factory_4.newDefForItems; | ||
exports.newDefForBuckets = factory_4.newDefForBuckets; | ||
exports.newDefForInsight = factory_4.newDefForInsight; | ||
exports.defWithDimensions = factory_4.defWithDimensions; | ||
exports.defWithSorting = factory_4.defWithSorting; | ||
exports.defaultDimensionsGenerator = factory_4.defaultDimensionsGenerator; | ||
exports.emptyDef = factory_4.emptyDef; | ||
var factory_5 = require("./execution/executionDefinition/factory"); | ||
exports.newDefForItems = factory_5.newDefForItems; | ||
exports.newDefForBuckets = factory_5.newDefForBuckets; | ||
exports.newDefForInsight = factory_5.newDefForInsight; | ||
exports.defWithDimensions = factory_5.defWithDimensions; | ||
exports.defWithSorting = factory_5.defWithSorting; | ||
exports.defaultDimensionsGenerator = factory_5.defaultDimensionsGenerator; | ||
exports.emptyDef = factory_5.emptyDef; | ||
var colors_1 = require("./colors"); | ||
@@ -173,9 +180,9 @@ exports.isColorFromPalette = colors_1.isColorFromPalette; | ||
exports.insightFilters = insight_1.insightFilters; | ||
exports.insightVisualizationClassUri = insight_1.insightVisualizationClassUri; | ||
exports.insightVisualizationUrl = insight_1.insightVisualizationUrl; | ||
exports.insightSetProperties = insight_1.insightSetProperties; | ||
exports.insightSetSorts = insight_1.insightSetSorts; | ||
exports.visClassUrl = insight_1.visClassUrl; | ||
var factory_5 = require("./insight/factory"); | ||
exports.newInsightDefinition = factory_5.newInsightDefinition; | ||
exports.InsightDefinitionBuilder = factory_5.InsightDefinitionBuilder; | ||
var factory_6 = require("./insight/factory"); | ||
exports.newInsightDefinition = factory_6.newInsightDefinition; | ||
exports.InsightDefinitionBuilder = factory_6.InsightDefinitionBuilder; | ||
var catalog_1 = require("./ldm/catalog"); | ||
@@ -182,0 +189,0 @@ exports.isCatalogAttribute = catalog_1.isCatalogAttribute; |
@@ -56,3 +56,3 @@ "use strict"; | ||
this.insight = { | ||
visualizationClassUri: visClassUri, | ||
visualizationUrl: visClassUri, | ||
title: "Untitled", | ||
@@ -59,0 +59,0 @@ buckets: [], |
@@ -41,5 +41,11 @@ import { SortItem } from "../execution/base/sort"; | ||
/** | ||
* URI of the visualization class that should be used to render this insight. | ||
* URL of visualization that should be used to render this insight. This is a link to the location | ||
* where the visualization assets are stored and where they should be loaded and linked from. | ||
* | ||
* Note: at the moment, the SDK supports only compile-time linkage; for this the visualization URL | ||
* is in format "local:visName" (as in "local:bar" for BarChart) | ||
* | ||
* @alpha | ||
*/ | ||
visualizationClassUri: string; | ||
visualizationUrl: string; | ||
/** | ||
@@ -243,8 +249,12 @@ * Buckets of attributes, measures and totals to render on the visualization. | ||
/** | ||
* Gets visualization class URI of an insight. | ||
* Gets URL of visualization that should be used to render this insight. This is a link to the location | ||
* where the visualization assets are stored and where they should be loaded and linked from. | ||
* | ||
* @param insight - insight to get vis class URI for | ||
* @public | ||
* Note: at the moment, the SDK supports only compile-time linkage; for this the visualization URL | ||
* is in format "local:visName" (as in "local:bar" for BarChart) | ||
* | ||
* @param insight - insight to get visualization URL from | ||
* @alpha | ||
*/ | ||
export declare function insightVisualizationClassUri(insight: IInsightDefinition): string; | ||
export declare function insightVisualizationUrl(insight: IInsightDefinition): string; | ||
/** | ||
@@ -251,0 +261,0 @@ * Gets the insight title |
@@ -206,12 +206,16 @@ "use strict"; | ||
/** | ||
* Gets visualization class URI of an insight. | ||
* Gets URL of visualization that should be used to render this insight. This is a link to the location | ||
* where the visualization assets are stored and where they should be loaded and linked from. | ||
* | ||
* @param insight - insight to get vis class URI for | ||
* @public | ||
* Note: at the moment, the SDK supports only compile-time linkage; for this the visualization URL | ||
* is in format "local:visName" (as in "local:bar" for BarChart) | ||
* | ||
* @param insight - insight to get visualization URL from | ||
* @alpha | ||
*/ | ||
function insightVisualizationClassUri(insight) { | ||
function insightVisualizationUrl(insight) { | ||
ts_invariant_1.default(insight, "insight to get vis class URI from must be defined"); | ||
return insight.insight.visualizationClassUri; | ||
return insight.insight.visualizationUrl; | ||
} | ||
exports.insightVisualizationClassUri = insightVisualizationClassUri; | ||
exports.insightVisualizationUrl = insightVisualizationUrl; | ||
/** | ||
@@ -218,0 +222,0 @@ * Gets the insight title |
@@ -12,2 +12,3 @@ /** | ||
description: string; | ||
isDemo?: boolean; | ||
} | ||
@@ -14,0 +15,0 @@ /** |
"use strict"; | ||
// (C) 2019 GoodData Corporation | ||
// (C) 2019-2020 GoodData Corporation | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
{ | ||
"name": "@gooddata/sdk-model", | ||
"version": "8.0.0-alpha.3", | ||
"version": "8.0.0-alpha.4", | ||
"author": "GoodData", | ||
@@ -5,0 +5,0 @@ "description": "GoodData Model definitions used by UI components and Backend SPI and its implementations", |
@@ -1,4 +0,6 @@ | ||
// (C) 2019 GoodData Corporation | ||
// (C) 2019-2020 GoodData Corporation | ||
import identity = require("lodash/identity"); | ||
import { IAttribute } from "./index"; | ||
import { ObjRef, objectRefValue, Identifier, isObjRef } from "../base"; | ||
import { idRef } from "../base/factory"; | ||
@@ -18,6 +20,6 @@ /** | ||
*/ | ||
constructor(displayFormId: string) { | ||
constructor(displayForm: ObjRef) { | ||
this.attribute = { | ||
displayForm: { identifier: displayFormId }, | ||
localIdentifier: `a_${displayFormId}`, | ||
displayForm, | ||
localIdentifier: `a_${objectRefValue(displayForm)}`, | ||
}; | ||
@@ -49,4 +51,4 @@ } | ||
/** | ||
* Creates a new attribute with the specified display form identifier and optional modifications and localIdentifier. | ||
* @param displayFormId - identifier of the attribute display form | ||
* Creates a new attribute with the specified display form ref and optional modifications and localIdentifier. | ||
* @param displayForm - ref or identifier of the attribute display form | ||
* @param modifications - optional modifications (e.g. alias, etc.) | ||
@@ -56,7 +58,8 @@ * @public | ||
export function newAttribute( | ||
displayFormId: string, | ||
displayForm: ObjRef | Identifier, | ||
modifications: AttributeModifications = identity, | ||
): IAttribute { | ||
const builder = new AttributeBuilder(displayFormId); | ||
const ref = isObjRef(displayForm) ? displayForm : idRef(displayForm); | ||
const builder = new AttributeBuilder(ref); | ||
return modifications(builder).build(); | ||
} |
@@ -1,2 +0,2 @@ | ||
// (C) 2019 GoodData Corporation | ||
// (C) 2019-2020 GoodData Corporation | ||
@@ -14,2 +14,9 @@ import isEmpty = require("lodash/isEmpty"); | ||
/** | ||
* Type for all URI's. | ||
* | ||
* @public | ||
*/ | ||
export type Uri = string; | ||
/** | ||
* Model object reference using object's URI. | ||
@@ -23,3 +30,3 @@ * | ||
export type UriRef = { | ||
uri: string; | ||
uri: Uri; | ||
}; | ||
@@ -89,2 +96,11 @@ | ||
/** | ||
* Type guard checking whether object is an Identifier Reference or an URI reference. | ||
* | ||
* @public | ||
*/ | ||
export function isObjRef(obj: any): obj is ObjRef { | ||
return isUriRef(obj) || isIdentifierRef(obj); | ||
} | ||
/** | ||
* Type guard checking whether object is a localId Reference. | ||
@@ -114,1 +130,23 @@ * | ||
} | ||
/** | ||
* Returns a value indicating whether the two ObjRef instances are semantically equal (i.e. are of the same type and have the same value). | ||
* Null and undefined are considered equal to each other. | ||
* | ||
* @public | ||
*/ | ||
export function areObjRefsEqual( | ||
a: ObjRefInScope | null | undefined, | ||
b: ObjRefInScope | null | undefined, | ||
): boolean { | ||
if (a == null) { | ||
return b == null; | ||
} | ||
if (isIdentifierRef(a)) { | ||
return isIdentifierRef(b) && a.identifier === b.identifier; | ||
} | ||
if (isUriRef(a)) { | ||
return isUriRef(b) && a.uri === b.uri; | ||
} | ||
return isLocalIdRef(b) && a.localIdentifier === b.localIdentifier; | ||
} |
@@ -1,3 +0,3 @@ | ||
// (C) 2019 GoodData Corporation | ||
import { objectRefValue, ObjRef } from "../index"; | ||
// (C) 2019-2020 GoodData Corporation | ||
import { objectRefValue, ObjRef, ObjRefInScope, areObjRefsEqual } from "../index"; | ||
@@ -24,1 +24,61 @@ describe("objectRefValue", () => { | ||
}); | ||
describe("areObjRefsEqual", () => { | ||
const Scenarios: Array<[ | ||
boolean, | ||
string, | ||
ObjRefInScope | null | undefined, | ||
ObjRefInScope | null | undefined, | ||
]> = [ | ||
// same type | ||
[true, "uri, uri, same value", { uri: "/uri" }, { uri: "/uri" }], | ||
[false, "uri, uri, different value", { uri: "/uri1" }, { uri: "/uri2" }], | ||
[ | ||
true, | ||
"identifier, identifier, same value", | ||
{ identifier: "/identifier" }, | ||
{ identifier: "/identifier" }, | ||
], | ||
[ | ||
false, | ||
"identifier, identifier, different value", | ||
{ identifier: "/identifier1" }, | ||
{ identifier: "/identifier2" }, | ||
], | ||
[ | ||
true, | ||
"localIdentifier, localIdentifier, same value", | ||
{ localIdentifier: "/localIdentifier" }, | ||
{ localIdentifier: "/localIdentifier" }, | ||
], | ||
[ | ||
false, | ||
"localIdentifier, localIdentifier, different value", | ||
{ localIdentifier: "/localIdentifier1" }, | ||
{ localIdentifier: "/localIdentifier2" }, | ||
], | ||
// different types | ||
[false, "identifier, uri, same value", { identifier: "foo" }, { uri: "foo" }], | ||
[false, "identifier, uri, different value", { identifier: "foo" }, { uri: "/foo/bar" }], | ||
[false, "localIdentifier, uri, same value", { localIdentifier: "foo" }, { uri: "foo" }], | ||
[false, "localIdentifier, uri, different value", { localIdentifier: "foo" }, { uri: "/foo/bar" }], | ||
[false, "identifier, localIdentifier, same value", { identifier: "foo" }, { localIdentifier: "foo" }], | ||
[ | ||
false, | ||
"identifier, localIdentifier, different value", | ||
{ identifier: "foo" }, | ||
{ localIdentifier: "bar" }, | ||
], | ||
// both nullish | ||
[true, "null, null", null, null], | ||
[true, "undefined, undefined", undefined, undefined], | ||
[true, "null, undefined", null, undefined], | ||
// nullish and non-nullish | ||
[false, "null, uri", null, { uri: "foo" }], | ||
[false, "undefined, identifier", undefined, { identifier: "foo" }], | ||
]; | ||
it.each(Scenarios)("should return %s for ", (expected, _desc, a, b) => { | ||
expect(areObjRefsEqual(a, b)).toEqual(expected); | ||
}); | ||
}); |
@@ -1,2 +0,2 @@ | ||
// (C) 2019 GoodData Corporation | ||
// (C) 2019-2020 GoodData Corporation | ||
@@ -6,3 +6,3 @@ import { InvalidInputTestCases } from "../../../../__mocks__/typeGuards"; | ||
import { Won } from "../../../../__mocks__/model"; | ||
import { isIdentifierRef, isLocalIdRef, isUriRef } from "../index"; | ||
import { isIdentifierRef, isLocalIdRef, isUriRef, isObjRef } from "../index"; | ||
import { isAttributeLocator, isAttributeSort, isMeasureLocator, isMeasureSort } from "../sort"; | ||
@@ -50,2 +50,15 @@ import { isTotal } from "../totals"; | ||
describe("isObjRef", () => { | ||
const Scenarios: Array<[boolean, string, any]> = [ | ||
...InvalidInputTestCases, | ||
[true, "uri ref", { uri: "/" }], | ||
[true, "identifier ref", { identifier: "id" }], | ||
[false, "localId ref", { localIdentifier: "localId" }], | ||
]; | ||
it.each(Scenarios)("should return %s when input is %s", (expectedResult, _desc, input) => { | ||
expect(isObjRef(input)).toBe(expectedResult); | ||
}); | ||
}); | ||
describe("isLocalIdRef", () => { | ||
@@ -52,0 +65,0 @@ const Scenarios: Array<[boolean, string, any]> = [ |
@@ -1,2 +0,2 @@ | ||
// (C) 2019 GoodData Corporation | ||
// (C) 2019-2020 GoodData Corporation | ||
@@ -28,3 +28,3 @@ import { | ||
const PositiveFilter = newPositiveAttributeFilter(Account.Name, ["myAccount"]); | ||
const RelativeDateFilter = newRelativeDateFilter("myDs", DateGranularity.month, 0, -10); | ||
const RelativeDateFilter = newRelativeDateFilter({ identifier: "myDs" }, DateGranularity.month, 0, -10); | ||
const MeasureValueFilter = newMeasureValueFilter(Won, "EQUAL_TO", 11); | ||
@@ -31,0 +31,0 @@ const EmptyBucket = newBucket("emptyBucket"); |
@@ -1,2 +0,2 @@ | ||
// (C) 2019 GoodData Corporation | ||
// (C) 2019-2020 GoodData Corporation | ||
import invariant from "ts-invariant"; | ||
@@ -13,5 +13,6 @@ import { | ||
} from "./index"; | ||
import { attributeIdentifier, IAttribute } from "../attribute"; | ||
import { ObjRefInScope } from "../base"; | ||
import { IAttribute, attributeAttributeDisplayFormObjRef } from "../attribute"; | ||
import { ObjRefInScope, ObjRef, isObjRef, Identifier } from "../base"; | ||
import { IMeasure, isMeasure, measureLocalId } from "../measure"; | ||
import { idRef } from "../base/factory"; | ||
@@ -21,4 +22,3 @@ /** | ||
* | ||
* @param attributeOrId - either instance of attribute to create filter for or identifier of attribute's display form | ||
* if the input is attribute object, then it is expected that attribute references display form by identifier | ||
* @param attributeOrRef - either instance of attribute to create filter for or ref or identifier of attribute's display form | ||
* @param inValues - values to filter for; these can be either specified as AttributeElements object or as an array | ||
@@ -29,7 +29,11 @@ * of attribute element _values_ | ||
export function newPositiveAttributeFilter( | ||
attributeOrId: IAttribute | string, | ||
attributeOrRef: IAttribute | ObjRef | Identifier, | ||
inValues: AttributeElements | string[], | ||
): IPositiveAttributeFilter { | ||
const displayFormId = | ||
typeof attributeOrId === "string" ? attributeOrId : attributeIdentifier(attributeOrId)!; | ||
const objRef = isObjRef(attributeOrRef) | ||
? attributeOrRef | ||
: typeof attributeOrRef === "string" | ||
? idRef(attributeOrRef) | ||
: attributeAttributeDisplayFormObjRef(attributeOrRef); | ||
const inObject: AttributeElements = Array.isArray(inValues) ? { values: inValues } : inValues; | ||
@@ -39,3 +43,3 @@ | ||
positiveAttributeFilter: { | ||
displayForm: { identifier: displayFormId }, | ||
displayForm: objRef, | ||
in: inObject, | ||
@@ -49,4 +53,3 @@ }, | ||
* | ||
* @param attributeOrId - either instance of attribute to create filter for or identifier of attribute's display form; | ||
* if the input is attribute object, then it is expected that attribute references display form by identifier | ||
* @param attributeOrRef - either instance of attribute to create filter for or ref or identifier of attribute's display form | ||
* @param notInValues - values to filter out; these can be either specified as AttributeElements object or as an array | ||
@@ -57,7 +60,11 @@ * of attribute element _values_ | ||
export function newNegativeAttributeFilter( | ||
attributeOrId: IAttribute | string, | ||
attributeOrRef: IAttribute | ObjRef | Identifier, | ||
notInValues: AttributeElements | string[], | ||
): INegativeAttributeFilter { | ||
const displayFormId = | ||
typeof attributeOrId === "string" ? attributeOrId : attributeIdentifier(attributeOrId)!; | ||
const objRef = isObjRef(attributeOrRef) | ||
? attributeOrRef | ||
: typeof attributeOrRef === "string" | ||
? idRef(attributeOrRef) | ||
: attributeAttributeDisplayFormObjRef(attributeOrRef); | ||
const notInObject: AttributeElements = Array.isArray(notInValues) ? { values: notInValues } : notInValues; | ||
@@ -67,3 +74,3 @@ | ||
negativeAttributeFilter: { | ||
displayForm: { identifier: displayFormId }, | ||
displayForm: objRef, | ||
notIn: notInObject, | ||
@@ -77,3 +84,3 @@ }, | ||
* | ||
* @param dateDataSetId - identifier of the date data set to filter on | ||
* @param dateDataSet - ref or identifier of the date data set to filter on | ||
* @param from - start of the interval in ISO-8601 calendar date format | ||
@@ -83,6 +90,11 @@ * @param to - end of the interval in ISO-8601 calendar date format | ||
*/ | ||
export function newAbsoluteDateFilter(dateDataSetId: string, from: string, to: string): IAbsoluteDateFilter { | ||
export function newAbsoluteDateFilter( | ||
dateDataSet: ObjRef | Identifier, | ||
from: string, | ||
to: string, | ||
): IAbsoluteDateFilter { | ||
const dataSet = isObjRef(dateDataSet) ? dateDataSet : idRef(dateDataSet); | ||
return { | ||
absoluteDateFilter: { | ||
dataSet: { identifier: dateDataSetId }, | ||
dataSet, | ||
from, | ||
@@ -97,3 +109,3 @@ to, | ||
* | ||
* @param dateDataSetId - identifier of the date data set to filter on | ||
* @param dateDataSet - ref or identifier of the date data set to filter on | ||
* @param granularity - granularity of the filters (month, year, etc.) | ||
@@ -105,3 +117,3 @@ * @param from - start of the interval – negative numbers mean the past, zero means today, positive numbers mean the future | ||
export function newRelativeDateFilter( | ||
dateDataSetId: string, | ||
dateDataSet: ObjRef | Identifier, | ||
granularity: string, | ||
@@ -111,5 +123,6 @@ from: number, | ||
): IRelativeDateFilter { | ||
const dataSet = isObjRef(dateDataSet) ? dateDataSet : idRef(dateDataSet); | ||
return { | ||
relativeDateFilter: { | ||
dataSet: { identifier: dateDataSetId }, | ||
dataSet, | ||
granularity, | ||
@@ -116,0 +129,0 @@ from, |
@@ -22,12 +22,8 @@ // (C) 2019-2020 GoodData Corporation | ||
} from "../index"; | ||
import { objectRefValue, ObjRef } from "../../base"; | ||
import { ObjRef } from "../../base"; | ||
const AbsoluteDateFilter = newAbsoluteDateFilter( | ||
objectRefValue(ClosedDate.MmDdYyyy.attribute.displayForm), | ||
"2018", | ||
"2019", | ||
); | ||
const AbsoluteDateFilter = newAbsoluteDateFilter(ClosedDate.MmDdYyyy.attribute.displayForm, "2018", "2019"); | ||
const RelativeDateFilter = newRelativeDateFilter( | ||
objectRefValue(ClosedDate.MmDdYyyy.attribute.displayForm), | ||
ClosedDate.MmDdYyyy.attribute.displayForm, | ||
"GDC.time.date", | ||
@@ -34,0 +30,0 @@ -6, |
@@ -1,2 +0,2 @@ | ||
// (C) 2019 GoodData Corporation | ||
// (C) 2019-2020 GoodData Corporation | ||
import cloneDeep = require("lodash/cloneDeep"); | ||
@@ -17,4 +17,5 @@ import identity = require("lodash/identity"); | ||
} from "./index"; | ||
import { Identifier } from "../base"; | ||
import { Identifier, ObjRef, isObjRef, objectRefValue } from "../base"; | ||
import { IMeasureFilter } from "../filter"; | ||
import { idRef } from "../base/factory"; | ||
@@ -61,3 +62,3 @@ /** | ||
public localId = (localId: string) => { | ||
public localId = (localId: Identifier) => { | ||
this.measure.localIdentifier = localId; | ||
@@ -91,17 +92,18 @@ this.customLocalId = true; | ||
*/ | ||
constructor(measureOrId: IMeasure<IMeasureDefinition> | string) { | ||
constructor(measureOrRef: IMeasure<IMeasureDefinition> | ObjRef) { | ||
super(); | ||
if (typeof measureOrId === "string") { | ||
if (isObjRef(measureOrRef)) { | ||
this.measure.definition = { | ||
measureDefinition: { | ||
item: { identifier: measureOrId }, | ||
item: measureOrRef, | ||
}, | ||
}; | ||
this.measure.localIdentifier = `m_${measureOrId}`; | ||
this.measureId = measureOrId; | ||
const refValue = objectRefValue(measureOrRef); | ||
this.measure.localIdentifier = `m_${refValue}`; | ||
this.measureId = refValue; | ||
} else { | ||
this.measure = cloneDeep(measureOrId.measure); | ||
this.measure = cloneDeep(measureOrRef.measure); | ||
this.customLocalId = true; | ||
this.measureId = measureIdentifier(measureOrId)!; | ||
this.measureId = measureIdentifier(measureOrRef)!; | ||
} | ||
@@ -140,3 +142,3 @@ } | ||
*/ | ||
constructor(measureIds: string[], operator: ArithmeticMeasureOperator) { | ||
constructor(measureIds: Identifier[], operator: ArithmeticMeasureOperator) { | ||
super(); | ||
@@ -164,3 +166,3 @@ this.measure.definition = { | ||
*/ | ||
constructor(measureId: string, popAttributeId: string) { | ||
constructor(measureId: Identifier, popAttributeId: Identifier) { | ||
super(); | ||
@@ -216,3 +218,3 @@ this.measure.definition = { | ||
* Creates a new measure with the specified identifier and optional modifications and localIdentifier. | ||
* @param measureId - identifier of the measure | ||
* @param measure - ref of identifier of the measure | ||
* @param modifications - optional modifications (e.g. alias, title, etc.) | ||
@@ -222,6 +224,7 @@ * @public | ||
export function newMeasure( | ||
measureId: string, | ||
measure: ObjRef | Identifier, | ||
modifications: MeasureModifications<MeasureBuilder> = identity, | ||
): IMeasure<IMeasureDefinition> { | ||
const builder = new MeasureBuilder(measureId); | ||
const ref = isObjRef(measure) ? measure : idRef(measure); | ||
const builder = new MeasureBuilder(ref); | ||
@@ -258,3 +261,3 @@ return modifications(builder).build(); | ||
export function newArithmeticMeasure( | ||
measuresOrIds: ReadonlyArray<IMeasure | string>, | ||
measuresOrIds: ReadonlyArray<IMeasure | Identifier>, | ||
operator: ArithmeticMeasureOperator, | ||
@@ -271,3 +274,3 @@ modifications: MeasureModifications<ArithmeticMeasureBuilder> = identity, | ||
* Creates a new PoP measure with the specified identifier and PoP attribute identifier and optional modifications and localIdentifier. | ||
* @param measureOrId - measure or identifier of the measure | ||
* @param measureOrLocalId - measure or local identifier of the measure | ||
* @param popAttributeId - identifier of the PoP attribute | ||
@@ -278,7 +281,8 @@ * @param modifications - optional modifications (e.g. alias, title, etc.) | ||
export function newPopMeasure( | ||
measureOrId: IMeasure | string, | ||
measureOrLocalId: IMeasure | Identifier, | ||
popAttributeId: string, | ||
modifications: MeasureModifications<PoPMeasureBuilder> = identity, | ||
): IMeasure<IPoPMeasureDefinition> { | ||
const measureId = typeof measureOrId === "string" ? measureOrId : measureLocalId(measureOrId); | ||
const measureId = | ||
typeof measureOrLocalId === "string" ? measureOrLocalId : measureLocalId(measureOrLocalId); | ||
const builder = new PoPMeasureBuilder(measureId, popAttributeId); | ||
@@ -291,3 +295,3 @@ | ||
* Creates a new Previous Period measure with the specified measure identifier and date data sets and optional modifications and localIdentifier. | ||
* @param measureIdOrId - measure or identifier of the measure to create Previous Period measure for | ||
* @param measureIdOrLocalId - measure or local identifier of the measure to create Previous Period measure for | ||
* @param dateDataSets - date data sets to use in the Previous Period calculation | ||
@@ -298,7 +302,8 @@ * @param modifications - optional modifications (e.g. alias, title, etc.) | ||
export function newPreviousPeriodMeasure( | ||
measureIdOrId: IMeasure | string, | ||
measureIdOrLocalId: IMeasure | Identifier, | ||
dateDataSets: IPreviousPeriodDateDataSetSimple[], | ||
modifications: MeasureModifications<PreviousPeriodMeasureBuilder> = identity, | ||
): IMeasure<IPreviousPeriodMeasureDefinition> { | ||
const measureId = typeof measureIdOrId === "string" ? measureIdOrId : measureLocalId(measureIdOrId); | ||
const measureId = | ||
typeof measureIdOrLocalId === "string" ? measureIdOrLocalId : measureLocalId(measureIdOrLocalId); | ||
const builder = new PreviousPeriodMeasureBuilder(measureId, dateDataSets); | ||
@@ -305,0 +310,0 @@ |
@@ -1,2 +0,2 @@ | ||
// (C) 2019 GoodData Corporation | ||
// (C) 2019-2020 GoodData Corporation | ||
@@ -25,2 +25,3 @@ import { Velocity, Won } from "../../../../__mocks__/model"; | ||
import { IFilter } from "../../filter"; | ||
import { idRef } from "../../base/factory"; | ||
@@ -32,3 +33,3 @@ const SimpleMeasureWithIdentifier = Won; | ||
const SimpleMeasureWithFilters = modifyMeasure(Won, m => | ||
m.filters(newPositiveAttributeFilter("myAttribute", ["foo"])), | ||
m.filters(newPositiveAttributeFilter(idRef("myAttribute"), ["foo"])), | ||
); | ||
@@ -35,0 +36,0 @@ |
@@ -1,2 +0,2 @@ | ||
// (C) 2019 GoodData Corporation | ||
// (C) 2019-2020 GoodData Corporation | ||
import flow = require("lodash/flow"); | ||
@@ -86,3 +86,3 @@ import identity = require("lodash/identity"); | ||
const builder = getBuilder("a => a", [addAlias(attribute), addLocalId(attribute)]); | ||
return `newAttribute("${getObjQualifierValue(attribute.displayForm)}", ${builder})`; | ||
return `newAttribute(${stringify(attribute.displayForm)}, ${builder})`; | ||
}; | ||
@@ -104,3 +104,3 @@ | ||
]); | ||
return `newMeasure("${getObjQualifierValue(definition.measureDefinition.item)}", ${builder})`; | ||
return `newMeasure(${stringify(definition.measureDefinition.item)}, ${builder})`; | ||
}; | ||
@@ -171,3 +171,3 @@ | ||
}) => { | ||
const args = [getObjQualifierValue(dataSet), from, to].filter(identity).map(stringify); | ||
const args = [dataSet, from, to].filter(identity).map(stringify); | ||
return `newAbsoluteDateFilter(${args.join(ARRAY_JOINER)})`; | ||
@@ -179,3 +179,3 @@ }; | ||
}) => { | ||
const args = [getObjQualifierValue(dataSet), granularity, from, to].filter(identity).map(stringify); | ||
const args = [dataSet, granularity, from, to].filter(identity).map(stringify); | ||
return `newRelativeDateFilter(${args.join(ARRAY_JOINER)})`; | ||
@@ -187,3 +187,3 @@ }; | ||
}) => { | ||
const args = [getObjQualifierValue(displayForm), inValues].filter(identity).map(stringify); | ||
const args = [displayForm, inValues].filter(identity).map(stringify); | ||
return `newPositiveAttributeFilter(${args.join(ARRAY_JOINER)})`; | ||
@@ -195,3 +195,3 @@ }; | ||
}) => { | ||
const args = [getObjQualifierValue(displayForm), notIn].filter(identity).map(stringify); | ||
const args = [displayForm, notIn].filter(identity).map(stringify); | ||
return `newNegativeAttributeFilter(${args.join(ARRAY_JOINER)})`; | ||
@@ -198,0 +198,0 @@ }; |
@@ -29,2 +29,3 @@ // (C) 2019-2020 GoodData Corporation | ||
Identifier, | ||
Uri, | ||
UriRef, | ||
@@ -38,2 +39,5 @@ IdentifierRef, | ||
objectRefValue, | ||
isLocalIdRef, | ||
areObjRefsEqual, | ||
isObjRef, | ||
} from "./execution/base"; | ||
@@ -52,2 +56,4 @@ | ||
export { idRef, uriRef, localIdRef } from "./execution/base/factory"; | ||
export { TotalType, ITotal, isTotal, newTotal, totalIsNative } from "./execution/base/totals"; | ||
@@ -266,3 +272,3 @@ | ||
insightFilters, | ||
insightVisualizationClassUri, | ||
insightVisualizationUrl, | ||
insightSetProperties, | ||
@@ -269,0 +275,0 @@ insightSetSorts, |
@@ -44,3 +44,3 @@ // (C) 2020 GoodData Corporation | ||
this.insight = { | ||
visualizationClassUri: visClassUri, | ||
visualizationUrl: visClassUri, | ||
title: "Untitled", | ||
@@ -47,0 +47,0 @@ buckets: [], |
@@ -56,5 +56,11 @@ // (C) 2019-2020 GoodData Corporation | ||
/** | ||
* URI of the visualization class that should be used to render this insight. | ||
* URL of visualization that should be used to render this insight. This is a link to the location | ||
* where the visualization assets are stored and where they should be loaded and linked from. | ||
* | ||
* Note: at the moment, the SDK supports only compile-time linkage; for this the visualization URL | ||
* is in format "local:visName" (as in "local:bar" for BarChart) | ||
* | ||
* @alpha | ||
*/ | ||
visualizationClassUri: string; | ||
visualizationUrl: string; | ||
@@ -362,11 +368,15 @@ /** | ||
/** | ||
* Gets visualization class URI of an insight. | ||
* Gets URL of visualization that should be used to render this insight. This is a link to the location | ||
* where the visualization assets are stored and where they should be loaded and linked from. | ||
* | ||
* @param insight - insight to get vis class URI for | ||
* @public | ||
* Note: at the moment, the SDK supports only compile-time linkage; for this the visualization URL | ||
* is in format "local:visName" (as in "local:bar" for BarChart) | ||
* | ||
* @param insight - insight to get visualization URL from | ||
* @alpha | ||
*/ | ||
export function insightVisualizationClassUri(insight: IInsightDefinition): string { | ||
export function insightVisualizationUrl(insight: IInsightDefinition): string { | ||
invariant(insight, "insight to get vis class URI from must be defined"); | ||
return insight.insight.visualizationClassUri; | ||
return insight.insight.visualizationUrl; | ||
} | ||
@@ -373,0 +383,0 @@ |
@@ -1,2 +0,2 @@ | ||
// (C) 2019 GoodData Corporation | ||
// (C) 2019-2020 GoodData Corporation | ||
@@ -14,2 +14,3 @@ /** | ||
description: string; | ||
isDemo?: boolean; | ||
} | ||
@@ -16,0 +17,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
683665
127
16814