@google/dscc
Advanced tools
Comparing version 0.3.17 to 0.3.20
@@ -8,3 +8,2 @@ { | ||
"cssFile": "index.css", | ||
"print": "printMessage.js", | ||
"testReport": "https://datastudio.google.com/c/u/0/reporting/1lx0XNLBSZDCKH3T6_VaXztX5FlS540ho/page/h74q" | ||
@@ -11,0 +10,0 @@ }, |
@@ -284,2 +284,21 @@ /*! | ||
const testDateRange = (numRequested: number): sut.DSDateRange[] => { | ||
const dateRanges = [ | ||
{ | ||
id: sut.DateRangeType.DEFAULT, | ||
start: '20200130', | ||
end: '20210130', | ||
}, | ||
{ | ||
id: sut.DateRangeType.COMPARISON, | ||
start: '20190130', | ||
end: '20200130', | ||
}, | ||
]; | ||
if (numRequested > 2) { | ||
throw new Error(`Can't support ${numRequested} date ranges.`); | ||
} | ||
return dateRanges.splice(0, numRequested); | ||
}; | ||
const testStyle = (numRequested: number): sut.StyleEntry[] => { | ||
@@ -323,3 +342,4 @@ const styleElements: sut.ConfigStyle[] = [ | ||
numMetrics: number, | ||
numStyle: number | ||
numStyle: number, | ||
numDateRange: number | ||
): sut.Message => { | ||
@@ -330,2 +350,3 @@ const dimensionFields = testDimensionFields(numDimensions); | ||
const style = testStyle(numStyle); | ||
const dateRanges = testDateRange(numDateRange); | ||
return { | ||
@@ -411,2 +432,3 @@ type: sut.MessageType.RENDER, | ||
], | ||
dateRanges, | ||
}, | ||
@@ -418,3 +440,3 @@ }; | ||
window.history.replaceState({}, 'Test Title', '/test?dscId=my-id'); | ||
const message = testMessage(1, 1, 1); | ||
const message = testMessage(1, 1, 1, 0); | ||
const addEventListenerMock = jest.fn((event, cb) => { | ||
@@ -487,2 +509,3 @@ if (event === 'message') { | ||
const expected: sut.TableFormat = { | ||
dateRanges: {}, | ||
interactions: interactionsById, | ||
@@ -543,3 +566,3 @@ fields: expectedFields, | ||
}; | ||
const actual = sut.tableTransform(testMessage(2, 2, 0)); | ||
const actual = sut.tableTransform(testMessage(2, 2, 0, 0)); | ||
expect(actual).toEqual(expected); | ||
@@ -586,2 +609,3 @@ }); | ||
theme, | ||
dateRanges: {}, | ||
fields: expectedFields, | ||
@@ -649,3 +673,3 @@ tables: { | ||
}; | ||
const actual: sut.TableFormat = sut.tableTransform(testMessage(2, 2, 2)); | ||
const actual: sut.TableFormat = sut.tableTransform(testMessage(2, 2, 2, 0)); | ||
expect(actual).toEqual(expected); | ||
@@ -657,2 +681,3 @@ }); | ||
interactions: interactionsById, | ||
dateRanges: {}, | ||
fields: { | ||
@@ -726,3 +751,3 @@ dimensions: [ | ||
}; | ||
const actual: sut.ObjectFormat = sut.objectTransform(testMessage(2, 2, 2)); | ||
const actual: sut.ObjectFormat = sut.objectTransform(testMessage(2, 2, 2, 0)); | ||
expect(actual).toEqual(expected); | ||
@@ -732,3 +757,3 @@ }); | ||
test('identity transform logs warning', () => { | ||
const message = testMessage(1, 1, 1); | ||
const message = testMessage(1, 1, 1, 2); | ||
const mockWarn = jest.fn((warn) => { | ||
@@ -753,3 +778,3 @@ throw new Error(warn); | ||
test('custom transform not supported', () => { | ||
const message = testMessage(1, 1, 1); | ||
const message = testMessage(1, 1, 1, 2); | ||
const addEventListenerMock = jest.fn((event, cb) => { | ||
@@ -810,3 +835,3 @@ if (event === 'message') { | ||
const message: sut.Message = testMessage(1, 1, 1); | ||
const message: sut.Message = testMessage(1, 1, 1, 2); | ||
message.config.style = styleWithReusedIds; | ||
@@ -818,2 +843,33 @@ expect(() => { | ||
test('If there is no date range in the input, it returns the correct value', () => { | ||
const actual: sut.ObjectFormat = sut.objectTransform(testMessage(2, 2, 2, 0)); | ||
expect(actual.dateRanges).toEqual({}); | ||
}); | ||
test('If there is one date range in the input, it returns the correct value', () => { | ||
const expectedDateRanges = { | ||
[sut.DateRangeType.DEFAULT]: { | ||
end: '20210130', | ||
start: '20200130', | ||
}, | ||
}; | ||
const actual: sut.ObjectFormat = sut.objectTransform(testMessage(2, 2, 2, 1)); | ||
expect(actual.dateRanges).toEqual(expectedDateRanges); | ||
}); | ||
test('If there is both date ranges in the input, it returns the correct value', () => { | ||
const expectedDateRanges = { | ||
[sut.DateRangeType.DEFAULT]: { | ||
end: '20210130', | ||
start: '20200130', | ||
}, | ||
[sut.DateRangeType.COMPARISON]: { | ||
end: '20200130', | ||
start: '20190130', | ||
}, | ||
}; | ||
const actual: sut.ObjectFormat = sut.objectTransform(testMessage(2, 2, 2, 2)); | ||
expect(actual.dateRanges).toEqual(expectedDateRanges); | ||
}); | ||
test('If elements are dim met dim dim, they have to be sorted specially.', () => { | ||
@@ -820,0 +876,0 @@ const messageDimMetDimDim: sut.Message = { |
@@ -1,6 +0,6 @@ | ||
!function(e,R){"object"==typeof exports&&"object"==typeof module?module.exports=R():"function"==typeof define&&define.amd?define("dscc",[],R):"object"==typeof exports?exports.dscc=R():e.dscc=R()}(window,function(){return t={},n.m=C={"./src/index.ts": | ||
!function(e,R){"object"==typeof exports&&"object"==typeof module?module.exports=R():"function"==typeof define&&define.amd?define("dscc",[],R):"object"==typeof exports?exports.dscc=R():e.dscc=R()}(window,function(){return C={},n.m=t={"./src/index.ts": | ||
/*!**********************!*\ | ||
!*** ./src/index.ts ***! | ||
\**********************/ | ||
/*! no static exports found */function(e,N,R){"use strict";var i=this&&this.__assign||function(){return(i=Object.assign||function(e){for(var R,C=1,t=arguments.length;C<t;C++)for(var n in R=arguments[C])Object.prototype.hasOwnProperty.call(R,n)&&(e[n]=R[n]);return e}).apply(this,arguments)};Object.defineProperty(N,"__esModule",{value:!0}); | ||
/*! no static exports found */function(e,N,R){"use strict";var i=this&&this.__assign||function(){return(i=Object.assign||function(e){for(var R,t=1,C=arguments.length;t<C;t++)for(var n in R=arguments[t])Object.prototype.hasOwnProperty.call(R,n)&&(e[n]=R[n]);return e}).apply(this,arguments)};Object.defineProperty(N,"__esModule",{value:!0}); | ||
/*! | ||
@@ -22,6 +22,6 @@ @license | ||
*/ | ||
var _=R(/*! ./types */"./src/types.ts");!function(e){for(var R in e)N.hasOwnProperty(R)||(N[R]=e[R])}(R(/*! ./types */"./src/types.ts")),N.getWidth=function(){return document.body.clientWidth},N.getHeight=function(){return document.documentElement.clientHeight},N.getComponentId=function(){var e=new URLSearchParams(window.location.search);if(null!==e.get("dscId"))return e.get("dscId");throw new Error("dscId must be in the query parameters. This is a bug in ds-component, please file a bug: https://github.com/googledatastudio/ds-component/issues/new")};function E(e){return e.type===_.ConfigDataElementType.DIMENSION||e.type===_.ConfigDataElementType.METRIC}function r(e){return e===_.ConfigDataElementType.DIMENSION?-1:1}function a(e){var R=[];e.config.data.forEach(function(e){e.elements.filter(E).forEach(function(e){R.push(e)})});var C,t=(C=function(e,R){return r(e.type)-r(R.type)},R.map(function(e,R){return{item:e,index:R}}).sort(function(e,R){return C(e.item,R.item)||e.index-R.index}).map(function(e){return e.item})),n=[];return t.forEach(function(e){e.value.forEach(function(){return n.push(e.id)})}),n}function o(R){return function(e){var C,t,n={};return t=R,((C=e).length<t.length?C.map(function(e,R){return[e,t[R]]}):t.map(function(e,R){return[C[R],e]})).forEach(function(e){var R=e[0],C=e[1];void 0===n[C]&&(n[C]=[]),n[C].push(R)},{}),n}}N.fieldsByConfigId=function(e){var R=e.fields.reduce(function(e,R){return e[R.id]=R,e},{}),C={};return e.config.data.forEach(function(e){e.elements.filter(E).forEach(function(e){C[e.id]=e.value.map(function(e){return R[e]})})}),C};function U(e){var R={};return(e.config.style||[]).forEach(function(e){e.elements.forEach(function(e){if(void 0!==R[e.id])throw new Error("styleIds must be unique. Your styleId: '"+e.id+"' is used more than once.");R[e.id]={value:e.value,defaultValue:e.defaultValue}})},{}),R}function Y(e){return e.config.themeStyle}function n(e){switch(e){case _.DSInteractionType.FILTER:return _.InteractionType.FILTER}}function s(e){var R=e.config.interactions;return void 0===R?{}:R.reduce(function(e,R){var C=R.supportedActions.map(n),t={type:n(R.value.type),data:R.value.data};return e[R.id]={value:t,supportedActions:C},e},{})}N.tableTransform=function(e){return{tables:(R=e,t=N.fieldsByConfigId(R),n=a(R),E={},r=n.map(function(e){void 0===E[e]?E[e]=0:E[e]++;var R=E[e],C=t[e][R];return i(i({},C),{configId:e})}),(C={})[_.TableType.DEFAULT]={headers:[],rows:[]},o=C,R.dataResponse.tables.forEach(function(e){o[e.id]={headers:r,rows:e.rows}}),o),fields:N.fieldsByConfigId(e),style:U(e),theme:Y(e),interactions:s(e)};var R,C,t,n,E,r,o},N.objectTransform=function(e){return{tables:(t=a(R=e),(C={})[_.TableType.DEFAULT]=[],n=C,R.dataResponse.tables.forEach(function(e){var R=e.rows.map(o(t));e.id===_.TableType.DEFAULT?n[e.id]=R:(void 0===n[e.id]&&(n[e.id]=[]),n[e.id]=n[e.id].concat(R))}),n),fields:N.fieldsByConfigId(e),style:U(e),theme:Y(e),interactions:s(e)};var R,C,t,n};function u(e){var R,C=!1;return e===N.tableTransform||e===N.objectTransform?C=!0:(R=!1,"identity"===e("identity")&&(R=!0,console.warn("This is an unsupported data format. Please use one of the supported transforms:\n dscc.objectFormat or dscc.tableFormat.")),R&&(C=!0)),C}N.subscribeToData=function(R,C){if(u(C.transform)){var e=function(e){e.data.type===_.MessageType.RENDER?R(C.transform(e.data)):console.error("MessageType: "+e.data.type+" is not supported by this version of the library.")};window.addEventListener("message",e);var t={componentId:N.getComponentId(),type:_.ToDSMessageType.VIZ_READY};return window.parent.postMessage(t,"*"),function(){return window.removeEventListener("message",e)}}throw new Error("Only the built in transform functions are supported.")},N.sendInteraction=function(e,R,C){var t=N.getComponentId(),n={type:_.ToDSMessageType.INTERACTION,id:e,data:C,componentId:t};window.parent.postMessage(n,"*")},N.clearInteraction=function(e,R){N.sendInteraction(e,R,void 0)}},"./src/types.ts": | ||
var _=R(/*! ./types */"./src/types.ts");!function(e){for(var R in e)N.hasOwnProperty(R)||(N[R]=e[R])}(R(/*! ./types */"./src/types.ts")),N.getWidth=function(){return document.body.clientWidth},N.getHeight=function(){return document.documentElement.clientHeight},N.getComponentId=function(){var e=new URLSearchParams(window.location.search);if(null!==e.get("dscId"))return e.get("dscId");throw new Error("dscId must be in the query parameters. This is a bug in ds-component, please file a bug: https://github.com/googledatastudio/ds-component/issues/new")};function E(e){return e.type===_.ConfigDataElementType.DIMENSION||e.type===_.ConfigDataElementType.METRIC}function r(e){return e===_.ConfigDataElementType.DIMENSION?-1:1}function a(e){var R=[];e.config.data.forEach(function(e){e.elements.filter(E).forEach(function(e){R.push(e)})});var t,C=(t=function(e,R){return r(e.type)-r(R.type)},R.map(function(e,R){return{item:e,index:R}}).sort(function(e,R){return t(e.item,R.item)||e.index-R.index}).map(function(e){return e.item})),n=[];return C.forEach(function(e){e.value.forEach(function(){return n.push(e.id)})}),n}function o(R){return function(e){var t,C,n={};return C=R,((t=e).length<C.length?t.map(function(e,R){return[e,C[R]]}):C.map(function(e,R){return[t[R],e]})).forEach(function(e){var R=e[0],t=e[1];void 0===n[t]&&(n[t]=[]),n[t].push(R)},{}),n}}N.fieldsByConfigId=function(e){var R=e.fields.reduce(function(e,R){return e[R.id]=R,e},{}),t={};return e.config.data.forEach(function(e){e.elements.filter(E).forEach(function(e){t[e.id]=e.value.map(function(e){return R[e]})})}),t};function U(e){var R={};return(e.config.style||[]).forEach(function(e){e.elements.forEach(function(e){if(void 0!==R[e.id])throw new Error("styleIds must be unique. Your styleId: '"+e.id+"' is used more than once.");R[e.id]={value:e.value,defaultValue:e.defaultValue}})},{}),R}function Y(e){return e.config.themeStyle}function n(e){switch(e){case _.DSInteractionType.FILTER:return _.InteractionType.FILTER}}function s(e){var R=e.config.interactions;return void 0===R?{}:R.reduce(function(e,R){var t=R.supportedActions.map(n),C={type:n(R.value.type),data:R.value.data};return e[R.id]={value:C,supportedActions:t},e},{})}function u(e){return(e.dataResponse.dateRanges||[]).reduce(function(e,R){return e[R.id]={start:R.start,end:R.end},e},{})}N.tableTransform=function(e){return{tables:(R=e,C=N.fieldsByConfigId(R),n=a(R),E={},r=n.map(function(e){void 0===E[e]?E[e]=0:E[e]++;var R=E[e],t=C[e][R];return i(i({},t),{configId:e})}),(t={})[_.TableType.DEFAULT]={headers:[],rows:[]},o=t,R.dataResponse.tables.forEach(function(e){o[e.id]={headers:r,rows:e.rows}}),o),dateRanges:u(e),fields:N.fieldsByConfigId(e),style:U(e),theme:Y(e),interactions:s(e)};var R,t,C,n,E,r,o},N.objectTransform=function(e){return{tables:(C=a(R=e),(t={})[_.TableType.DEFAULT]=[],n=t,R.dataResponse.tables.forEach(function(e){var R=e.rows.map(o(C));e.id===_.TableType.DEFAULT?n[e.id]=R:(void 0===n[e.id]&&(n[e.id]=[]),n[e.id]=n[e.id].concat(R))}),n),dateRanges:u(e),fields:N.fieldsByConfigId(e),style:U(e),theme:Y(e),interactions:s(e)};var R,t,C,n};function T(e){var R,t=!1;return e===N.tableTransform||e===N.objectTransform?t=!0:(R=!1,"identity"===e("identity")&&(R=!0,console.warn("This is an unsupported data format. Please use one of the supported transforms:\n dscc.objectFormat or dscc.tableFormat.")),R&&(t=!0)),t}N.subscribeToData=function(R,t){if(T(t.transform)){var e=function(e){e.data.type===_.MessageType.RENDER?R(t.transform(e.data)):console.error("MessageType: "+e.data.type+" is not supported by this version of the library.")};window.addEventListener("message",e);var C={componentId:N.getComponentId(),type:_.ToDSMessageType.VIZ_READY};return window.parent.postMessage(C,"*"),function(){return window.removeEventListener("message",e)}}throw new Error("Only the built in transform functions are supported.")},N.sendInteraction=function(e,R,t){var C=N.getComponentId(),n={type:_.ToDSMessageType.INTERACTION,id:e,data:t,componentId:C};window.parent.postMessage(n,"*")},N.clearInteraction=function(e,R){N.sendInteraction(e,R,void 0)}},"./src/types.ts": | ||
/*!**********************!*\ | ||
!*** ./src/types.ts ***! | ||
\**********************/ | ||
/*! no static exports found */function(e,R,C){"use strict";var t,n,E,r,o,N;Object.defineProperty(R,"__esModule",{value:!0}),(t=R.ConceptType||(R.ConceptType={})).METRIC="METRIC",t.DIMENSION="DIMENSION",(R.MessageType||(R.MessageType={})).RENDER="RENDER",(n=R.FieldType||(R.FieldType={})).YEAR="YEAR",n.YEAR_QUARTER="YEAR_QUARTER",n.YEAR_MONTH="YEAR_MONTH",n.YEAR_WEEK="YEAR_WEEK",n.YEAR_MONTH_DAY="YEAR_MONTH_DAY",n.YEAR_MONTH_DAY_HOUR="YEAR_MONTH_DAY_HOUR",n.QUARTER="QUARTER",n.MONTH="MONTH",n.WEEK="WEEK",n.MONTH_DAY="MONTH_DAY",n.DAY_OF_WEEK="DAY_OF_WEEK",n.DAY="DAY",n.HOUR="HOUR",n.MINUTE="MINUTE",n.DURATION="DURATION",n.COUNTRY="COUNTRY",n.COUNTRY_CODE="COUNTRY_CODE",n.CONTINENT="CONTINENT",n.CONTINENT_CODE="CONTINENT_CODE",n.SUB_CONTINENT="SUB_CONTINENT",n.SUB_CONTINENT_CODE="SUB_CONTINENT_CODE",n.REGION="REGION",n.REGION_CODE="REGION_CODE",n.CITY="CITY",n.CITY_CODE="CITY_CODE",n.METRO_CODE="METRO_CODE",n.LATITUDE_LONGITUDE="LATITUDE_LONGITUDE",n.NUMBER="NUMBER",n.PERCENT="PERCENT",n.TEXT="TEXT",n.BOOLEAN="BOOLEAN",n.URL="URL",n.IMAGE="IMAGE",n.CURRENCY_AED="CURRENCY_AED",n.CURRENCY_ALL="CURRENCY_ALL",n.CURRENCY_ARS="CURRENCY_ARS",n.CURRENCY_AUD="CURRENCY_AUD",n.CURRENCY_BDT="CURRENCY_BDT",n.CURRENCY_BGN="CURRENCY_BGN",n.CURRENCY_BOB="CURRENCY_BOB",n.CURRENCY_BRL="CURRENCY_BRL",n.CURRENCY_CAD="CURRENCY_CAD",n.CURRENCY_CDF="CURRENCY_CDF",n.CURRENCY_CHF="CURRENCY_CHF",n.CURRENCY_CLP="CURRENCY_CLP",n.CURRENCY_CNY="CURRENCY_CNY",n.CURRENCY_COP="CURRENCY_COP",n.CURRENCY_CRC="CURRENCY_CRC",n.CURRENCY_CZK="CURRENCY_CZK",n.CURRENCY_DKK="CURRENCY_DKK",n.CURRENCY_DOP="CURRENCY_DOP",n.CURRENCY_EGP="CURRENCY_EGP",n.CURRENCY_ETB="CURRENCY_ETB",n.CURRENCY_EUR="CURRENCY_EUR",n.CURRENCY_GBP="CURRENCY_GBP",n.CURRENCY_HKD="CURRENCY_HKD",n.CURRENCY_HRK="CURRENCY_HRK",n.CURRENCY_HUF="CURRENCY_HUF",n.CURRENCY_IDR="CURRENCY_IDR",n.CURRENCY_ILS="CURRENCY_ILS",n.CURRENCY_INR="CURRENCY_INR",n.CURRENCY_IRR="CURRENCY_IRR",n.CURRENCY_ISK="CURRENCY_ISK",n.CURRENCY_JMD="CURRENCY_JMD",n.CURRENCY_JPY="CURRENCY_JPY",n.CURRENCY_KRW="CURRENCY_KRW",n.CURRENCY_LKR="CURRENCY_LKR",n.CURRENCY_LTL="CURRENCY_LTL",n.CURRENCY_MNT="CURRENCY_MNT",n.CURRENCY_MVR="CURRENCY_MVR",n.CURRENCY_MXN="CURRENCY_MXN",n.CURRENCY_MYR="CURRENCY_MYR",n.CURRENCY_NOK="CURRENCY_NOK",n.CURRENCY_NZD="CURRENCY_NZD",n.CURRENCY_PAB="CURRENCY_PAB",n.CURRENCY_PEN="CURRENCY_PEN",n.CURRENCY_PHP="CURRENCY_PHP",n.CURRENCY_PKR="CURRENCY_PKR",n.CURRENCY_PLN="CURRENCY_PLN",n.CURRENCY_RON="CURRENCY_RON",n.CURRENCY_RSD="CURRENCY_RSD",n.CURRENCY_RUB="CURRENCY_RUB",n.CURRENCY_SAR="CURRENCY_SAR",n.CURRENCY_SEK="CURRENCY_SEK",n.CURRENCY_SGD="CURRENCY_SGD",n.CURRENCY_THB="CURRENCY_THB",n.CURRENCY_TRY="CURRENCY_TRY",n.CURRENCY_TWD="CURRENCY_TWD",n.CURRENCY_TZS="CURRENCY_TZS",n.CURRENCY_UAH="CURRENCY_UAH",n.CURRENCY_USD="CURRENCY_USD",n.CURRENCY_UYU="CURRENCY_UYU",n.CURRENCY_VEF="CURRENCY_VEF",n.CURRENCY_VND="CURRENCY_VND",n.CURRENCY_YER="CURRENCY_YER",n.CURRENCY_ZAR="CURRENCY_ZAR",(E=R.TableType||(R.TableType={})).DEFAULT="DEFAULT",E.COMPARISON="COMPARISON",E.SUMMARY="SUMMARY",(r=R.ConfigDataElementType||(R.ConfigDataElementType={})).METRIC="METRIC",r.DIMENSION="DIMENSION",r.MAX_RESULTS="MAX_RESULTS",(o=R.ConfigStyleElementType||(R.ConfigStyleElementType={})).TEXTINPUT="TEXTINPUT",o.SELECT_SINGLE="SELECT_SINGLE",o.CHECKBOX="CHECKBOX",o.FONT_COLOR="FONT_COLOR",o.FONT_SIZE="FONT_SIZE",o.FONT_FAMILY="FONT_FAMILY",o.FILL_COLOR="FILL_COLOR",o.BORDER_COLOR="BORDER_COLOR",o.AXIS_COLOR="AXIS_COLOR",o.GRID_COLOR="GRID_COLOR",o.OPACITY="OPACITY",o.LINE_WEIGHT="LINE_WEIGHT",o.LINE_STYLE="LINE_STYLE",o.BORDER_RADIUS="BORDER_RADIUS",o.INTERVAL="INTERVAL",o.SELECT_RADIO="SELECT_RADIO",(R.DSInteractionType||(R.DSInteractionType={})).FILTER="FILTER",(N=R.ToDSMessageType||(R.ToDSMessageType={})).VIZ_READY="vizReady",N.INTERACTION="vizAction",(R.InteractionType||(R.InteractionType={})).FILTER="FILTER"}},n.c=t,n.d=function(e,R,C){n.o(e,R)||Object.defineProperty(e,R,{enumerable:!0,get:C})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(R,e){if(1&e&&(R=n(R)),8&e)return R;if(4&e&&"object"==typeof R&&R&&R.__esModule)return R;var C=Object.create(null);if(n.r(C),Object.defineProperty(C,"default",{enumerable:!0,value:R}),2&e&&"string"!=typeof R)for(var t in R)n.d(C,t,function(e){return R[e]}.bind(null,t));return C},n.n=function(e){var R=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(R,"a",R),R},n.o=function(e,R){return Object.prototype.hasOwnProperty.call(e,R)},n.p="",n(n.s="./src/index.ts");function n(e){if(t[e])return t[e].exports;var R=t[e]={i:e,l:!1,exports:{}};return C[e].call(R.exports,R,R.exports,n),R.l=!0,R.exports}var C,t}); | ||
/*! no static exports found */function(e,R,t){"use strict";var C,n,E,r,o,N,i;Object.defineProperty(R,"__esModule",{value:!0}),(C=R.ConceptType||(R.ConceptType={})).METRIC="METRIC",C.DIMENSION="DIMENSION",(R.MessageType||(R.MessageType={})).RENDER="RENDER",(n=R.FieldType||(R.FieldType={})).YEAR="YEAR",n.YEAR_QUARTER="YEAR_QUARTER",n.YEAR_MONTH="YEAR_MONTH",n.YEAR_WEEK="YEAR_WEEK",n.YEAR_MONTH_DAY="YEAR_MONTH_DAY",n.YEAR_MONTH_DAY_HOUR="YEAR_MONTH_DAY_HOUR",n.QUARTER="QUARTER",n.MONTH="MONTH",n.WEEK="WEEK",n.MONTH_DAY="MONTH_DAY",n.DAY_OF_WEEK="DAY_OF_WEEK",n.DAY="DAY",n.HOUR="HOUR",n.MINUTE="MINUTE",n.DURATION="DURATION",n.COUNTRY="COUNTRY",n.COUNTRY_CODE="COUNTRY_CODE",n.CONTINENT="CONTINENT",n.CONTINENT_CODE="CONTINENT_CODE",n.SUB_CONTINENT="SUB_CONTINENT",n.SUB_CONTINENT_CODE="SUB_CONTINENT_CODE",n.REGION="REGION",n.REGION_CODE="REGION_CODE",n.CITY="CITY",n.CITY_CODE="CITY_CODE",n.METRO_CODE="METRO_CODE",n.LATITUDE_LONGITUDE="LATITUDE_LONGITUDE",n.NUMBER="NUMBER",n.PERCENT="PERCENT",n.TEXT="TEXT",n.BOOLEAN="BOOLEAN",n.URL="URL",n.IMAGE="IMAGE",n.CURRENCY_AED="CURRENCY_AED",n.CURRENCY_ALL="CURRENCY_ALL",n.CURRENCY_ARS="CURRENCY_ARS",n.CURRENCY_AUD="CURRENCY_AUD",n.CURRENCY_BDT="CURRENCY_BDT",n.CURRENCY_BGN="CURRENCY_BGN",n.CURRENCY_BOB="CURRENCY_BOB",n.CURRENCY_BRL="CURRENCY_BRL",n.CURRENCY_CAD="CURRENCY_CAD",n.CURRENCY_CDF="CURRENCY_CDF",n.CURRENCY_CHF="CURRENCY_CHF",n.CURRENCY_CLP="CURRENCY_CLP",n.CURRENCY_CNY="CURRENCY_CNY",n.CURRENCY_COP="CURRENCY_COP",n.CURRENCY_CRC="CURRENCY_CRC",n.CURRENCY_CZK="CURRENCY_CZK",n.CURRENCY_DKK="CURRENCY_DKK",n.CURRENCY_DOP="CURRENCY_DOP",n.CURRENCY_EGP="CURRENCY_EGP",n.CURRENCY_ETB="CURRENCY_ETB",n.CURRENCY_EUR="CURRENCY_EUR",n.CURRENCY_GBP="CURRENCY_GBP",n.CURRENCY_HKD="CURRENCY_HKD",n.CURRENCY_HRK="CURRENCY_HRK",n.CURRENCY_HUF="CURRENCY_HUF",n.CURRENCY_IDR="CURRENCY_IDR",n.CURRENCY_ILS="CURRENCY_ILS",n.CURRENCY_INR="CURRENCY_INR",n.CURRENCY_IRR="CURRENCY_IRR",n.CURRENCY_ISK="CURRENCY_ISK",n.CURRENCY_JMD="CURRENCY_JMD",n.CURRENCY_JPY="CURRENCY_JPY",n.CURRENCY_KRW="CURRENCY_KRW",n.CURRENCY_LKR="CURRENCY_LKR",n.CURRENCY_LTL="CURRENCY_LTL",n.CURRENCY_MNT="CURRENCY_MNT",n.CURRENCY_MVR="CURRENCY_MVR",n.CURRENCY_MXN="CURRENCY_MXN",n.CURRENCY_MYR="CURRENCY_MYR",n.CURRENCY_NOK="CURRENCY_NOK",n.CURRENCY_NZD="CURRENCY_NZD",n.CURRENCY_PAB="CURRENCY_PAB",n.CURRENCY_PEN="CURRENCY_PEN",n.CURRENCY_PHP="CURRENCY_PHP",n.CURRENCY_PKR="CURRENCY_PKR",n.CURRENCY_PLN="CURRENCY_PLN",n.CURRENCY_RON="CURRENCY_RON",n.CURRENCY_RSD="CURRENCY_RSD",n.CURRENCY_RUB="CURRENCY_RUB",n.CURRENCY_SAR="CURRENCY_SAR",n.CURRENCY_SEK="CURRENCY_SEK",n.CURRENCY_SGD="CURRENCY_SGD",n.CURRENCY_THB="CURRENCY_THB",n.CURRENCY_TRY="CURRENCY_TRY",n.CURRENCY_TWD="CURRENCY_TWD",n.CURRENCY_TZS="CURRENCY_TZS",n.CURRENCY_UAH="CURRENCY_UAH",n.CURRENCY_USD="CURRENCY_USD",n.CURRENCY_UYU="CURRENCY_UYU",n.CURRENCY_VEF="CURRENCY_VEF",n.CURRENCY_VND="CURRENCY_VND",n.CURRENCY_YER="CURRENCY_YER",n.CURRENCY_ZAR="CURRENCY_ZAR",(E=R.TableType||(R.TableType={})).DEFAULT="DEFAULT",E.COMPARISON="COMPARISON",E.SUMMARY="SUMMARY",(r=R.DateRangeType||(R.DateRangeType={})).DEFAULT="DEFAULT",r.COMPARISON="COMPARISON",(o=R.ConfigDataElementType||(R.ConfigDataElementType={})).METRIC="METRIC",o.DIMENSION="DIMENSION",o.MAX_RESULTS="MAX_RESULTS",(N=R.ConfigStyleElementType||(R.ConfigStyleElementType={})).TEXTINPUT="TEXTINPUT",N.SELECT_SINGLE="SELECT_SINGLE",N.CHECKBOX="CHECKBOX",N.FONT_COLOR="FONT_COLOR",N.FONT_SIZE="FONT_SIZE",N.FONT_FAMILY="FONT_FAMILY",N.FILL_COLOR="FILL_COLOR",N.BORDER_COLOR="BORDER_COLOR",N.AXIS_COLOR="AXIS_COLOR",N.GRID_COLOR="GRID_COLOR",N.OPACITY="OPACITY",N.LINE_WEIGHT="LINE_WEIGHT",N.LINE_STYLE="LINE_STYLE",N.BORDER_RADIUS="BORDER_RADIUS",N.INTERVAL="INTERVAL",N.SELECT_RADIO="SELECT_RADIO",(R.DSInteractionType||(R.DSInteractionType={})).FILTER="FILTER",(i=R.ToDSMessageType||(R.ToDSMessageType={})).VIZ_READY="vizReady",i.INTERACTION="vizAction",(R.InteractionType||(R.InteractionType={})).FILTER="FILTER"}},n.c=C,n.d=function(e,R,t){n.o(e,R)||Object.defineProperty(e,R,{enumerable:!0,get:t})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(R,e){if(1&e&&(R=n(R)),8&e)return R;if(4&e&&"object"==typeof R&&R&&R.__esModule)return R;var t=Object.create(null);if(n.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:R}),2&e&&"string"!=typeof R)for(var C in R)n.d(t,C,function(e){return R[e]}.bind(null,C));return t},n.n=function(e){var R=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(R,"a",R),R},n.o=function(e,R){return Object.prototype.hasOwnProperty.call(e,R)},n.p="",n(n.s="./src/index.ts");function n(e){if(C[e])return C[e].exports;var R=C[e]={i:e,l:!1,exports:{}};return t[e].call(R.exports,R,R.exports,n),R.l=!0,R.exports}var t,C}); |
@@ -270,2 +270,16 @@ "use strict"; | ||
/** | ||
* Transform for date ranges | ||
*/ | ||
var toDateRanges = function (message) { | ||
var dateRanges = message.dataResponse.dateRanges || []; | ||
var output = {}; | ||
return dateRanges.reduce(function (inProgress, currentDSDateRange) { | ||
inProgress[currentDSDateRange.id] = { | ||
start: currentDSDateRange.start, | ||
end: currentDSDateRange.end, | ||
}; | ||
return inProgress; | ||
}, output); | ||
}; | ||
/** | ||
* The transform to use for data in a Table format. i.e. `[[1, 2, 3], [4, 5, 6]]` | ||
@@ -275,2 +289,3 @@ */ | ||
tables: tableFormatTable(message), | ||
dateRanges: toDateRanges(message), | ||
fields: exports.fieldsByConfigId(message), | ||
@@ -286,2 +301,3 @@ style: flattenStyle(message), | ||
tables: objectFormatTable(message), | ||
dateRanges: toDateRanges(message), | ||
fields: exports.fieldsByConfigId(message), | ||
@@ -288,0 +304,0 @@ style: flattenStyle(message), |
@@ -60,2 +60,7 @@ export interface PostMessage extends MessageEvent { | ||
} | ||
export interface DSDateRange { | ||
id: DateRangeType; | ||
start: string; | ||
end: string; | ||
} | ||
export interface DataResponse { | ||
@@ -66,2 +71,3 @@ /** | ||
tables: Table[]; | ||
dateRanges?: DSDateRange[]; | ||
} | ||
@@ -442,2 +448,6 @@ export declare enum MessageType { | ||
} | ||
export declare enum DateRangeType { | ||
DEFAULT = "DEFAULT", | ||
COMPARISON = "COMPARISON" | ||
} | ||
export declare enum ConfigDataElementType { | ||
@@ -606,2 +616,3 @@ /** | ||
tables: Tables; | ||
dateRanges: DateRangesById; | ||
theme: ThemeStyle; | ||
@@ -623,2 +634,12 @@ interactions: InteractionsById; | ||
} | ||
export interface DateRangesById { | ||
[DateRangeType.DEFAULT]?: { | ||
start: string; | ||
end: string; | ||
}; | ||
[DateRangeType.COMPARISON]?: { | ||
start: string; | ||
end: string; | ||
}; | ||
} | ||
export interface ObjectFormat { | ||
@@ -628,2 +649,3 @@ fields: FieldsByConfigId; | ||
tables: ObjectTables; | ||
dateRanges: DateRangesById; | ||
theme: ThemeStyle; | ||
@@ -630,0 +652,0 @@ interactions: InteractionsById; |
@@ -117,2 +117,7 @@ "use strict"; | ||
})(TableType = exports.TableType || (exports.TableType = {})); | ||
var DateRangeType; | ||
(function (DateRangeType) { | ||
DateRangeType["DEFAULT"] = "DEFAULT"; | ||
DateRangeType["COMPARISON"] = "COMPARISON"; | ||
})(DateRangeType = exports.DateRangeType || (exports.DateRangeType = {})); | ||
var ConfigDataElementType; | ||
@@ -119,0 +124,0 @@ (function (ConfigDataElementType) { |
{ | ||
"name": "@google/dscc", | ||
"libraryName": "dscc", | ||
"version": "0.3.17", | ||
"version": "0.3.20", | ||
"main": "lib/index.js", | ||
@@ -59,3 +59,3 @@ "license": "Apache-2.0", | ||
}, | ||
"repository": "googledatastudio/ds-component", | ||
"repository": "googledatastudio/tooling", | ||
"keywords": [ | ||
@@ -62,0 +62,0 @@ "datastudio", |
# dscc - Google Data Studio Community Component Helper Library | ||
<a href="https://travis-ci.org/googledatastudio/ds-component"><img src="https://travis-ci.org/googledatastudio/ds-component.svg?branch=master" alt="Build Status"></a> | ||
<a href="https://travis-ci.org/googledatastudio/ds-component"><img src="https://travis-ci.org/googledatastudio/ds-component.svg?branch=main" alt="Build Status"></a> | ||
@@ -5,0 +5,0 @@ `dscc` (Data Studio Community Component) is a library to help with the building |
@@ -27,2 +27,3 @@ /*! | ||
ConfigStyleElement, | ||
DateRangesById, | ||
DSInteractionData, | ||
@@ -338,2 +339,16 @@ DSInteractionType, | ||
/** | ||
* Transform for date ranges | ||
*/ | ||
const toDateRanges = (message: Message): DateRangesById => { | ||
const dateRanges = message.dataResponse.dateRanges || []; | ||
const output: DateRangesById = {}; | ||
return dateRanges.reduce((inProgress, currentDSDateRange) => { | ||
inProgress[currentDSDateRange.id] = { | ||
start: currentDSDateRange.start, | ||
end: currentDSDateRange.end, | ||
}; | ||
return inProgress; | ||
}, output); | ||
}; | ||
/** | ||
* The transform to use for data in a Table format. i.e. `[[1, 2, 3], [4, 5, 6]]` | ||
@@ -345,2 +360,3 @@ */ | ||
tables: tableFormatTable(message), | ||
dateRanges: toDateRanges(message), | ||
fields: fieldsByConfigId(message), | ||
@@ -357,2 +373,3 @@ style: flattenStyle(message), | ||
tables: objectFormatTable(message), | ||
dateRanges: toDateRanges(message), | ||
fields: fieldsByConfigId(message), | ||
@@ -359,0 +376,0 @@ style: flattenStyle(message), |
@@ -83,2 +83,8 @@ /*! | ||
export interface DSDateRange { | ||
id: DateRangeType; | ||
start: string; | ||
end: string; | ||
} | ||
export interface DataResponse { | ||
@@ -89,2 +95,3 @@ /** | ||
tables: Table[]; | ||
dateRanges?: DSDateRange[]; | ||
} | ||
@@ -483,2 +490,7 @@ | ||
export enum DateRangeType { | ||
DEFAULT = 'DEFAULT', | ||
COMPARISON = 'COMPARISON', | ||
} | ||
export enum ConfigDataElementType { | ||
@@ -667,2 +679,3 @@ /** | ||
tables: Tables; | ||
dateRanges: DateRangesById; | ||
theme: ThemeStyle; | ||
@@ -690,2 +703,13 @@ interactions: InteractionsById; | ||
export interface DateRangesById { | ||
[DateRangeType.DEFAULT]?: { | ||
start: string; | ||
end: string; | ||
}; | ||
[DateRangeType.COMPARISON]?: { | ||
start: string; | ||
end: string; | ||
}; | ||
} | ||
export interface ObjectFormat { | ||
@@ -695,2 +719,3 @@ fields: FieldsByConfigId; | ||
tables: ObjectTables; | ||
dateRanges: DateRangesById; | ||
theme: ThemeStyle; | ||
@@ -697,0 +722,0 @@ interactions: InteractionsById; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
416949
4527