@vizzly/dashboard 0.14.4-dev-bba43aecbb9d5b65a950ef259163441af1041848 → 0.14.4-dev-7cba24e151ef9b87b5980bb4d617335aa42d5fc5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dashboard.esm.js
CHANGED
|
@@ -3675,6 +3675,10 @@ var usedMeasures = function usedMeasures(attrs) {
|
|
|
3675
3675
|
if ('yMeasure' in attrs && attrs.yMeasure) {
|
|
3676
3676
|
usedMeasures = [].concat(usedMeasures, [attrs.yMeasure]);
|
|
3677
3677
|
}
|
|
3678
|
+
if ('zMeasure' in attrs && attrs.zMeasure) {
|
|
3679
|
+
var newMeasures = Array.isArray(attrs.zMeasure) ? attrs.zMeasure : [attrs.zMeasure];
|
|
3680
|
+
usedMeasures = [].concat(usedMeasures, newMeasures);
|
|
3681
|
+
}
|
|
3678
3682
|
return usedMeasures;
|
|
3679
3683
|
};
|
|
3680
3684
|
var usedDimensions = function usedDimensions(attrs) {
|
|
@@ -3693,18 +3697,34 @@ var usedDimensions = function usedDimensions(attrs) {
|
|
|
3693
3697
|
var usedFields = function usedFields(attrs) {
|
|
3694
3698
|
var usedFields = [];
|
|
3695
3699
|
usedMeasures(attrs).forEach(function (measure) {
|
|
3696
|
-
usedFields = [].concat(usedFields, [
|
|
3700
|
+
usedFields = [].concat(usedFields, [{
|
|
3701
|
+
fieldId: measure.field,
|
|
3702
|
+
"function": measure["function"],
|
|
3703
|
+
dataSetId: attrs.dataSetId
|
|
3704
|
+
}]);
|
|
3697
3705
|
});
|
|
3698
3706
|
usedDimensions(attrs).forEach(function (dimension) {
|
|
3699
|
-
usedFields = [].concat(usedFields, [
|
|
3707
|
+
usedFields = [].concat(usedFields, [{
|
|
3708
|
+
fieldId: dimension.field,
|
|
3709
|
+
"function": dimension["function"],
|
|
3710
|
+
dataSetId: attrs.dataSetId
|
|
3711
|
+
}]);
|
|
3700
3712
|
});
|
|
3701
3713
|
if ('order' in attrs && attrs.order) {
|
|
3702
3714
|
usedFields = [].concat(usedFields, [].concat(attrs.order).map(function (d) {
|
|
3703
|
-
return
|
|
3715
|
+
return {
|
|
3716
|
+
fieldId: d.field,
|
|
3717
|
+
"function": d["function"],
|
|
3718
|
+
dataSetId: attrs.dataSetId
|
|
3719
|
+
};
|
|
3704
3720
|
}));
|
|
3705
3721
|
}
|
|
3706
3722
|
if ('timeDimension' in attrs && attrs.timeDimension) {
|
|
3707
|
-
usedFields = [].concat(usedFields, [
|
|
3723
|
+
usedFields = [].concat(usedFields, [{
|
|
3724
|
+
fieldId: attrs.timeDimension.field,
|
|
3725
|
+
"function": attrs.timeDimension.truncate,
|
|
3726
|
+
dataSetId: attrs.dataSetId
|
|
3727
|
+
}]);
|
|
3708
3728
|
}
|
|
3709
3729
|
return usedFields;
|
|
3710
3730
|
};
|
|
@@ -3725,7 +3745,9 @@ var validateView = (function (attrs, dataSets, queryEngineConfig) {
|
|
|
3725
3745
|
// Check the data set for the view exists
|
|
3726
3746
|
var dataSet = find(dataSets, attrs.dataSetId);
|
|
3727
3747
|
if (!dataSet) return [new DataSetNotFound(dataSets, attrs.dataSetId)];
|
|
3728
|
-
var requiredFields = usedFields(attrs)
|
|
3748
|
+
var requiredFields = usedFields(attrs).map(function (field) {
|
|
3749
|
+
return field.fieldId;
|
|
3750
|
+
});
|
|
3729
3751
|
try {
|
|
3730
3752
|
requiredFields.forEach(function (requiredField) {
|
|
3731
3753
|
findField(dataSet, requiredField);
|
|
@@ -23080,6 +23102,7 @@ var getDataSetsUsedOnDisplay = function getDataSetsUsedOnDisplay(dashboard) {
|
|
|
23080
23102
|
if (!isComponentEmpty(component) && !isComponent(component)) {
|
|
23081
23103
|
usedDataSetIds = [].concat(usedDataSetIds, [component.attributes.dataSetId]);
|
|
23082
23104
|
}
|
|
23105
|
+
return;
|
|
23083
23106
|
});
|
|
23084
23107
|
});
|
|
23085
23108
|
return uniq(usedDataSetIds).flatMap(function (dataSetId) {
|
|
@@ -23260,6 +23283,83 @@ var checkAndReturnProgrammaticDashboardId = function checkAndReturnProgrammaticD
|
|
|
23260
23283
|
}
|
|
23261
23284
|
return programmaticDashboards[0].id;
|
|
23262
23285
|
};
|
|
23286
|
+
var getFieldUsage = function getFieldUsage(dashboardDefinition, dataSets) {
|
|
23287
|
+
var fieldUsageFields = [];
|
|
23288
|
+
|
|
23289
|
+
// TODO; look through the fields used in custom metrics
|
|
23290
|
+
// and add those to the list of used fields
|
|
23291
|
+
|
|
23292
|
+
// TODO; look through the component library and
|
|
23293
|
+
// add those fields to the list of those used by the dashboard
|
|
23294
|
+
// NOTE; initial plan was to store fields used in the library on the library
|
|
23295
|
+
// field usage, however at this point, we get the component library and the
|
|
23296
|
+
// dashboard manager updates them separately, meaning we'd need to pass through
|
|
23297
|
+
// the field usage individually for the dashboard or the component library, but we
|
|
23298
|
+
// only allow one pass through of used fields at the moment.
|
|
23299
|
+
|
|
23300
|
+
// Add fields from the global filters
|
|
23301
|
+
dashboardDefinition.globalFilters.forEach(function (globalFilter) {
|
|
23302
|
+
globalFilter.appliesToFields.forEach(function (field) {
|
|
23303
|
+
try {
|
|
23304
|
+
var dataSet = find(dataSets, field.dataSetId);
|
|
23305
|
+
if (!dataSet) {
|
|
23306
|
+
logDebug('Did not find data set when finding field usage', field.dataSetId);
|
|
23307
|
+
return;
|
|
23308
|
+
}
|
|
23309
|
+
var fieldInDataSet = findField(dataSet, field.fieldId);
|
|
23310
|
+
fieldUsageFields = [].concat(fieldUsageFields, [{
|
|
23311
|
+
data_set_id: field.dataSetId,
|
|
23312
|
+
field_id: field.fieldId,
|
|
23313
|
+
"function": 'none',
|
|
23314
|
+
name: fieldInDataSet.publicName
|
|
23315
|
+
}]);
|
|
23316
|
+
} catch (e) {
|
|
23317
|
+
if (e instanceof FieldNotFoundInDataSet) {
|
|
23318
|
+
logDebug("Did not find field in data set, assuming custom metric. " + field.fieldId);
|
|
23319
|
+
} else {
|
|
23320
|
+
logError(e);
|
|
23321
|
+
}
|
|
23322
|
+
return;
|
|
23323
|
+
}
|
|
23324
|
+
});
|
|
23325
|
+
});
|
|
23326
|
+
|
|
23327
|
+
// Add fields from the views on the dashboard
|
|
23328
|
+
dashboardDefinition.display.forEach(function (row) {
|
|
23329
|
+
row.components.forEach(function (component) {
|
|
23330
|
+
if (!('attributes' in component)) return;
|
|
23331
|
+
var dataSet = find(dataSets, component.attributes.dataSetId);
|
|
23332
|
+
if (!dataSet) {
|
|
23333
|
+
logDebug('Did not find field in data set, assuming custom metric. ', component.attributes.dataSetId);
|
|
23334
|
+
return;
|
|
23335
|
+
}
|
|
23336
|
+
var fields = usedFields(component.attributes).flatMap(function (usedField) {
|
|
23337
|
+
try {
|
|
23338
|
+
var field = findField(dataSet, usedField.fieldId);
|
|
23339
|
+
return [{
|
|
23340
|
+
data_set_id: usedField.dataSetId,
|
|
23341
|
+
field_id: usedField.fieldId,
|
|
23342
|
+
"function": usedField["function"],
|
|
23343
|
+
name: field.publicName
|
|
23344
|
+
}];
|
|
23345
|
+
} catch (e) {
|
|
23346
|
+
if (e instanceof FieldNotFoundInDataSet) {
|
|
23347
|
+
logDebug("Did not find field in data set, assuming custom metric. " + usedField.fieldId);
|
|
23348
|
+
} else {
|
|
23349
|
+
logError(e);
|
|
23350
|
+
}
|
|
23351
|
+
}
|
|
23352
|
+
return [];
|
|
23353
|
+
});
|
|
23354
|
+
fieldUsageFields = [].concat(fieldUsageFields, fields);
|
|
23355
|
+
return;
|
|
23356
|
+
});
|
|
23357
|
+
});
|
|
23358
|
+
return {
|
|
23359
|
+
lowest_date_granularity_function: null,
|
|
23360
|
+
fields: fieldUsageFields
|
|
23361
|
+
};
|
|
23362
|
+
};
|
|
23263
23363
|
|
|
23264
23364
|
// type RawGlobalFilter = Omit<GlobalFilter, 'context'>;
|
|
23265
23365
|
var Dashboard;
|
|
@@ -23294,6 +23394,7 @@ var DashboardLogic = {
|
|
|
23294
23394
|
updateWithProgrammaticDashboard: updateWithProgrammaticDashboard,
|
|
23295
23395
|
addUniqueLibraryComponents: addUniqueLibraryComponents,
|
|
23296
23396
|
checkAndReturnProgrammaticDashboardId: checkAndReturnProgrammaticDashboardId,
|
|
23397
|
+
getFieldUsage: getFieldUsage,
|
|
23297
23398
|
colSpanSchema: colSpanSchema,
|
|
23298
23399
|
saveableDashboardDefinitionSchema: saveableDashboardDefinitionSchema,
|
|
23299
23400
|
displaySchema: displaySchema,
|
|
@@ -26289,7 +26390,9 @@ var filterStyles = /*#__PURE__*/Object.assign(function () {
|
|
|
26289
26390
|
/** Returns a key to be used in an useEffect dependency, that changes if there's any change to a field in a data set. */
|
|
26290
26391
|
var watchDataSetFieldChanges = function watchDataSetFieldChanges(dataSet, queryable) {
|
|
26291
26392
|
if ('dataSetId' in queryable) {
|
|
26292
|
-
var watchFields = usedFields(queryable)
|
|
26393
|
+
var watchFields = usedFields(queryable).map(function (field) {
|
|
26394
|
+
return field.fieldId;
|
|
26395
|
+
});
|
|
26293
26396
|
|
|
26294
26397
|
// Custom fields are the only ones that can have their definition changed. So
|
|
26295
26398
|
// we only need to watch them.
|
|
@@ -26411,7 +26514,9 @@ var useVariablesInDataSet = function useVariablesInDataSet(dataSet, queryable, v
|
|
|
26411
26514
|
setNoOfVariableChanges = _useState3[1];
|
|
26412
26515
|
useEffect(function () {
|
|
26413
26516
|
if ('dataSetId' in queryable) {
|
|
26414
|
-
var watchFields = usedFields(queryable)
|
|
26517
|
+
var watchFields = usedFields(queryable).map(function (field) {
|
|
26518
|
+
return field.fieldId;
|
|
26519
|
+
});
|
|
26415
26520
|
if (variables && variables.changes) {
|
|
26416
26521
|
Object.keys(variables.changes).forEach(function (variableId) {
|
|
26417
26522
|
var watchedCustomFields = checkFieldsForVariableInValues(watchFields, dataSet, variableId, findField, function (filterValue) {
|
|
@@ -26429,7 +26534,9 @@ var useVariablesInDataSet = function useVariablesInDataSet(dataSet, queryable, v
|
|
|
26429
26534
|
}, [JSON.stringify(variables)]);
|
|
26430
26535
|
useEffect(function () {
|
|
26431
26536
|
if ('dataSetId' in queryable) {
|
|
26432
|
-
var watchFields = usedFields(queryable)
|
|
26537
|
+
var watchFields = usedFields(queryable).map(function (field) {
|
|
26538
|
+
return field.fieldId;
|
|
26539
|
+
});
|
|
26433
26540
|
if (variables && variables.variables) {
|
|
26434
26541
|
watchFields.forEach(function (fieldId) {
|
|
26435
26542
|
var dataSetField = findField(dataSet, fieldId);
|
|
@@ -73152,7 +73259,8 @@ var VizzlyServices = /*#__PURE__*/function () {
|
|
|
73152
73259
|
parentDashboardId: params.parentDashboardId,
|
|
73153
73260
|
permissions: [{
|
|
73154
73261
|
scope: 'read_write'
|
|
73155
|
-
}]
|
|
73262
|
+
}],
|
|
73263
|
+
usage_metadata: params.definition ? getFieldUsage(params.definition, this.dataSets) : undefined
|
|
73156
73264
|
});
|
|
73157
73265
|
case 5:
|
|
73158
73266
|
_yield$dashboardManag = _context3.sent;
|
|
@@ -73188,7 +73296,8 @@ var VizzlyServices = /*#__PURE__*/function () {
|
|
|
73188
73296
|
definition: params.definition,
|
|
73189
73297
|
deleted: params.deleted,
|
|
73190
73298
|
abortSignal: params.abortSignal,
|
|
73191
|
-
name: params.name
|
|
73299
|
+
name: params.name,
|
|
73300
|
+
usage_metadata: params.definition ? getFieldUsage(params.definition, this.dataSets) : undefined
|
|
73192
73301
|
});
|
|
73193
73302
|
case 5:
|
|
73194
73303
|
dashboard = _context4.sent;
|
|
@@ -73695,7 +73804,9 @@ if (typeof window !== 'undefined' && !window.Vizzly) {
|
|
|
73695
73804
|
// @ts-ignore
|
|
73696
73805
|
var Vizzly$1 =
|
|
73697
73806
|
// @ts-ignore
|
|
73698
|
-
typeof window !== 'undefined' ?
|
|
73807
|
+
typeof window !== 'undefined' ?
|
|
73808
|
+
// @ts-ignore
|
|
73809
|
+
window.Vizzly || VizzlyServices : VizzlyServices;
|
|
73699
73810
|
|
|
73700
73811
|
function pushGlobalLibraryCustomFieldsIntoDashboardFields(preparedDataSets, customFields) {
|
|
73701
73812
|
[].concat(preparedDataSets).forEach(function (dataset) {
|
|
@@ -2,5 +2,9 @@ import { QueryAttributes } from '../QueryAttributes/types';
|
|
|
2
2
|
import { Component } from './types';
|
|
3
3
|
export declare const usedMeasures: (attrs: Partial<Component.Attributes | QueryAttributes>) => QueryAttributes['measure'];
|
|
4
4
|
export declare const usedDimensions: (attrs: Partial<Component.Attributes | QueryAttributes>) => QueryAttributes['dimension'];
|
|
5
|
-
declare const usedFields: (attrs: Partial<Component.Attributes | QueryAttributes>) =>
|
|
5
|
+
declare const usedFields: (attrs: Partial<Component.Attributes | QueryAttributes>) => Array<{
|
|
6
|
+
dataSetId: string;
|
|
7
|
+
fieldId: string;
|
|
8
|
+
function: string;
|
|
9
|
+
}>;
|
|
6
10
|
export default usedFields;
|
|
@@ -2,6 +2,7 @@ import { Component as ComponentType } from '../Component/types';
|
|
|
2
2
|
import { DataSet } from '../DataSet/types';
|
|
3
3
|
import { CustomField } from '../CustomField/types';
|
|
4
4
|
import { Dashboard, SaveableDashboardDefinition, ImportableDashboard } from './types';
|
|
5
|
+
import { FieldUsage } from '@vizzly/api-client';
|
|
5
6
|
export * from './saveableDashboardDefinitionSchema';
|
|
6
7
|
export * from './fromRaw';
|
|
7
8
|
export declare const indexOfDataSet: (dashboard: Dashboard, dataSetId: string) => number;
|
|
@@ -35,3 +36,4 @@ export declare const VIZZLY_EDITOR_ID = "vizzly_editor";
|
|
|
35
36
|
export declare function updateWithProgrammaticDashboard(allDashboards: Dashboard[], programmaticDashboards: Dashboard[]): Dashboard[];
|
|
36
37
|
export declare const addUniqueLibraryComponents: (programmaticLibrary: ComponentType[], dashboardLibrary: ComponentType[]) => ComponentType[];
|
|
37
38
|
export declare const checkAndReturnProgrammaticDashboardId: (dashboards: Dashboard[]) => string | undefined;
|
|
39
|
+
export declare const getFieldUsage: (dashboardDefinition: SaveableDashboardDefinition, dataSets: DataSet[]) => FieldUsage;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vizzly/dashboard",
|
|
3
3
|
"author": "james@vizzly.co",
|
|
4
|
-
"version": "0.14.4-dev-
|
|
4
|
+
"version": "0.14.4-dev-7cba24e151ef9b87b5980bb4d617335aa42d5fc5",
|
|
5
5
|
"source": "src/index.tsx",
|
|
6
6
|
"types": "./dist/dashboard/src/index.d.ts",
|
|
7
7
|
"module": "./dist/dashboard.esm.js",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@react-hook/window-size": "^3.1.1",
|
|
54
54
|
"@react-spring/web": "9.6.1",
|
|
55
55
|
"@visx/visx": "^3.10.2",
|
|
56
|
-
"@vizzly/api-client": "0.0.
|
|
56
|
+
"@vizzly/api-client": "0.0.51",
|
|
57
57
|
"@vizzly/joi": "^17.7.0",
|
|
58
58
|
"@vizzly/semantic-layer-public": "0.0.229",
|
|
59
59
|
"@vizzly/sqlbuilder-public": "0.1.33",
|