@embeddable.com/sdk-core 0.2.0 → 1.0.0
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/configs/stencil.config.ts +5 -5
- package/lib/embedType.d.ts +12 -2
- package/lib/index.cjs.js +74 -17
- package/lib/index.d.ts +5 -4
- package/lib/index.esm.js +73 -18
- package/lib/index.umd.js +79 -20
- package/lib/loadData.d.ts +57 -9
- package/lib/operations.d.ts +11 -0
- package/lib/untils.d.ts +9 -0
- package/package.json +8 -3
- package/scripts/build.js +7 -7
- package/scripts/buildTypes.js +37 -30
- package/scripts/cleanup.js +11 -14
- package/scripts/createContext.js +24 -19
- package/scripts/findEmbFiles.js +17 -18
- package/scripts/generate.js +48 -43
- package/scripts/globalCleanup.js +13 -0
- package/scripts/index.js +10 -6
- package/scripts/login.js +72 -55
- package/scripts/prepare.js +13 -12
- package/scripts/push.js +128 -72
- package/scripts/validate.js +66 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Config } from
|
|
1
|
+
import { Config } from "@stencil/core";
|
|
2
2
|
|
|
3
3
|
export const config: Config = {
|
|
4
|
-
namespace:
|
|
5
|
-
srcDir:
|
|
4
|
+
namespace: "embeddable-wrapper",
|
|
5
|
+
srcDir: "component",
|
|
6
6
|
outputTargets: [
|
|
7
7
|
{
|
|
8
|
-
type:
|
|
8
|
+
type: "dist",
|
|
9
9
|
},
|
|
10
10
|
],
|
|
11
|
-
};
|
|
11
|
+
};
|
package/lib/embedType.d.ts
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
export declare const embedType: (typeName: string, typeConfig:
|
|
1
|
+
export declare const embedType: (typeName: string, typeConfig: TypeConfig) => void;
|
|
2
|
+
export type TypeConfig = {
|
|
2
3
|
label: string;
|
|
4
|
+
embeddableDataType?: typeof STRING | typeof NUMBER | typeof BOOLEAN | typeof DATE | typeof DATE_RANGE;
|
|
3
5
|
toString: (_: any) => string;
|
|
4
|
-
|
|
6
|
+
deserialize?: (_: any) => any;
|
|
7
|
+
toEmbeddableDataType?: (_: any) => any;
|
|
8
|
+
};
|
|
9
|
+
declare const STRING = "string";
|
|
10
|
+
declare const NUMBER = "number";
|
|
11
|
+
declare const BOOLEAN = "boolean";
|
|
12
|
+
declare const DATE = "date";
|
|
13
|
+
declare const DATE_RANGE = "dateRange";
|
|
14
|
+
export {};
|
package/lib/index.cjs.js
CHANGED
|
@@ -1,30 +1,84 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var normalizeEntities = function (entities, _a) {
|
|
4
|
+
var _b = _a.mapFn, mapFn = _b === void 0 ? function (x) { return x; } : _b, _c = _a.filterFn, filterFn = _c === void 0 ? Boolean : _c;
|
|
5
|
+
if (!entities)
|
|
6
|
+
return undefined;
|
|
7
|
+
var filtered = entities.filter(filterFn);
|
|
8
|
+
if (filtered.length === 0)
|
|
9
|
+
return undefined;
|
|
10
|
+
return filtered.map(mapFn);
|
|
11
|
+
};
|
|
12
|
+
var getName = function (x) { return x.name; };
|
|
13
|
+
var validateOrderBy = function (orderByParam, dimensions, measures) {
|
|
14
|
+
var unknownDimensionsOrMeasures = [];
|
|
15
|
+
var dimensionAndMeasureNames = measures
|
|
16
|
+
.concat(dimensions)
|
|
17
|
+
.map(function (x) { return x.name; });
|
|
18
|
+
for (var _i = 0, orderByParam_1 = orderByParam; _i < orderByParam_1.length; _i++) {
|
|
19
|
+
var orderBy = orderByParam_1[_i];
|
|
20
|
+
var name_1 = orderBy.property.name;
|
|
21
|
+
if (dimensionAndMeasureNames.includes(name_1))
|
|
22
|
+
continue;
|
|
23
|
+
unknownDimensionsOrMeasures.push(name_1);
|
|
24
|
+
}
|
|
25
|
+
return unknownDimensionsOrMeasures;
|
|
26
|
+
};
|
|
4
27
|
|
|
5
|
-
var
|
|
6
|
-
|
|
28
|
+
var LOAD_DATA_EVENT = "embeddable-event:load-data";
|
|
29
|
+
var isLoadDataParams = function (ldp) {
|
|
30
|
+
return typeof ldp === "object" && "requestParams" in ldp && "dataLoader" in ldp;
|
|
31
|
+
};
|
|
32
|
+
var executeDataRequest = function (request, componentId, propertyName) {
|
|
33
|
+
var _a;
|
|
7
34
|
if (!request.from)
|
|
8
|
-
return
|
|
9
|
-
var dimensions = (
|
|
10
|
-
var measures = (
|
|
11
|
-
var timeDimensions = (
|
|
35
|
+
return "No dataset selected";
|
|
36
|
+
var dimensions = normalizeEntities(request.dimensions, { mapFn: getName });
|
|
37
|
+
var measures = normalizeEntities(request.measures, { mapFn: getName });
|
|
38
|
+
var timeDimensions = normalizeEntities(request.timeDimensions, {
|
|
39
|
+
// @ts-expect-error
|
|
40
|
+
filterFn: getName,
|
|
41
|
+
});
|
|
42
|
+
var dimensionsOrMeasuresDefined = dimensions || measures || timeDimensions;
|
|
43
|
+
if (!dimensionsOrMeasuresDefined)
|
|
44
|
+
return "At least a dimension or a measure should be selected.";
|
|
45
|
+
var unknownDimensionsOrMeasures = validateOrderBy((_a = request.orderBy) !== null && _a !== void 0 ? _a : [], dimensions !== null && dimensions !== void 0 ? dimensions : [], measures !== null && measures !== void 0 ? measures : []);
|
|
46
|
+
if (unknownDimensionsOrMeasures.length) {
|
|
47
|
+
return "Cannot order by ".concat(unknownDimensionsOrMeasures.join(", "), " as no such ").concat(unknownDimensionsOrMeasures.length === 1 ? "property" : "properties", " has been loaded.");
|
|
48
|
+
}
|
|
12
49
|
var query = {
|
|
13
50
|
datasetId: request.from.datasetId,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
51
|
+
embeddableId: request.from.embeddableId,
|
|
52
|
+
dimensions: dimensions,
|
|
53
|
+
measures: measures,
|
|
54
|
+
timeDimensions: timeDimensions,
|
|
55
|
+
offset: request.offset,
|
|
56
|
+
limit: request.limit,
|
|
18
57
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
58
|
+
window.dispatchEvent(new CustomEvent(LOAD_DATA_EVENT, {
|
|
59
|
+
bubbles: false,
|
|
60
|
+
detail: {
|
|
61
|
+
query: query,
|
|
62
|
+
componentId: componentId,
|
|
63
|
+
propertyName: propertyName,
|
|
64
|
+
},
|
|
65
|
+
}));
|
|
22
66
|
};
|
|
23
67
|
var loadData = function (requestParams) { return ({
|
|
24
68
|
requestParams: requestParams,
|
|
25
|
-
dataLoader: executeDataRequest
|
|
69
|
+
dataLoader: executeDataRequest,
|
|
26
70
|
}); };
|
|
27
71
|
|
|
72
|
+
var getOperationObject = function (operation, value) { return ({
|
|
73
|
+
operation: operation,
|
|
74
|
+
value: value,
|
|
75
|
+
__embeddableVariableMeta: true,
|
|
76
|
+
}); };
|
|
77
|
+
var Value = {
|
|
78
|
+
noFilter: function () { return getOperationObject("NO_FILTER"); },
|
|
79
|
+
of: function (value) { return getOperationObject("VALUE", value); },
|
|
80
|
+
};
|
|
81
|
+
|
|
28
82
|
var UPDATE_VALUE_EVENT = "embeddable:value:changed";
|
|
29
83
|
var setValue = function (value, componentId, eventName) {
|
|
30
84
|
var event = new CustomEvent(UPDATE_VALUE_EVENT, {
|
|
@@ -32,7 +86,7 @@ var setValue = function (value, componentId, eventName) {
|
|
|
32
86
|
detail: {
|
|
33
87
|
componentId: componentId,
|
|
34
88
|
value: value,
|
|
35
|
-
eventName: eventName
|
|
89
|
+
eventName: eventName,
|
|
36
90
|
},
|
|
37
91
|
});
|
|
38
92
|
window.dispatchEvent(event);
|
|
@@ -87,12 +141,15 @@ var embedOption = function (typeName, option) {
|
|
|
87
141
|
if (!window.__EMBEDDABLE__.types[typeName])
|
|
88
142
|
return;
|
|
89
143
|
// @ts-ignore
|
|
90
|
-
window.__EMBEDDABLE__.types[typeName].options =
|
|
144
|
+
window.__EMBEDDABLE__.types[typeName].options =
|
|
145
|
+
window.__EMBEDDABLE__.types[typeName].options || [];
|
|
91
146
|
// @ts-ignore
|
|
92
147
|
window.__EMBEDDABLE__.types[typeName].options.push(option);
|
|
93
148
|
};
|
|
94
149
|
|
|
150
|
+
exports.Value = Value;
|
|
95
151
|
exports.embedOption = embedOption;
|
|
96
152
|
exports.embedType = embedType;
|
|
153
|
+
exports.isLoadDataParams = isLoadDataParams;
|
|
97
154
|
exports.loadData = loadData;
|
|
98
155
|
exports.setValue = setValue;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
1
|
+
export * from "./loadData";
|
|
2
|
+
export { Value } from "./operations";
|
|
3
|
+
export { setValue } from "./setValue";
|
|
4
|
+
export { embedType } from "./embedType";
|
|
5
|
+
export { embedOption } from "./embedOption";
|
package/lib/index.esm.js
CHANGED
|
@@ -1,28 +1,82 @@
|
|
|
1
|
-
|
|
1
|
+
var normalizeEntities = function (entities, _a) {
|
|
2
|
+
var _b = _a.mapFn, mapFn = _b === void 0 ? function (x) { return x; } : _b, _c = _a.filterFn, filterFn = _c === void 0 ? Boolean : _c;
|
|
3
|
+
if (!entities)
|
|
4
|
+
return undefined;
|
|
5
|
+
var filtered = entities.filter(filterFn);
|
|
6
|
+
if (filtered.length === 0)
|
|
7
|
+
return undefined;
|
|
8
|
+
return filtered.map(mapFn);
|
|
9
|
+
};
|
|
10
|
+
var getName = function (x) { return x.name; };
|
|
11
|
+
var validateOrderBy = function (orderByParam, dimensions, measures) {
|
|
12
|
+
var unknownDimensionsOrMeasures = [];
|
|
13
|
+
var dimensionAndMeasureNames = measures
|
|
14
|
+
.concat(dimensions)
|
|
15
|
+
.map(function (x) { return x.name; });
|
|
16
|
+
for (var _i = 0, orderByParam_1 = orderByParam; _i < orderByParam_1.length; _i++) {
|
|
17
|
+
var orderBy = orderByParam_1[_i];
|
|
18
|
+
var name_1 = orderBy.property.name;
|
|
19
|
+
if (dimensionAndMeasureNames.includes(name_1))
|
|
20
|
+
continue;
|
|
21
|
+
unknownDimensionsOrMeasures.push(name_1);
|
|
22
|
+
}
|
|
23
|
+
return unknownDimensionsOrMeasures;
|
|
24
|
+
};
|
|
2
25
|
|
|
3
|
-
var
|
|
4
|
-
|
|
26
|
+
var LOAD_DATA_EVENT = "embeddable-event:load-data";
|
|
27
|
+
var isLoadDataParams = function (ldp) {
|
|
28
|
+
return typeof ldp === "object" && "requestParams" in ldp && "dataLoader" in ldp;
|
|
29
|
+
};
|
|
30
|
+
var executeDataRequest = function (request, componentId, propertyName) {
|
|
31
|
+
var _a;
|
|
5
32
|
if (!request.from)
|
|
6
|
-
return
|
|
7
|
-
var dimensions = (
|
|
8
|
-
var measures = (
|
|
9
|
-
var timeDimensions = (
|
|
33
|
+
return "No dataset selected";
|
|
34
|
+
var dimensions = normalizeEntities(request.dimensions, { mapFn: getName });
|
|
35
|
+
var measures = normalizeEntities(request.measures, { mapFn: getName });
|
|
36
|
+
var timeDimensions = normalizeEntities(request.timeDimensions, {
|
|
37
|
+
// @ts-expect-error
|
|
38
|
+
filterFn: getName,
|
|
39
|
+
});
|
|
40
|
+
var dimensionsOrMeasuresDefined = dimensions || measures || timeDimensions;
|
|
41
|
+
if (!dimensionsOrMeasuresDefined)
|
|
42
|
+
return "At least a dimension or a measure should be selected.";
|
|
43
|
+
var unknownDimensionsOrMeasures = validateOrderBy((_a = request.orderBy) !== null && _a !== void 0 ? _a : [], dimensions !== null && dimensions !== void 0 ? dimensions : [], measures !== null && measures !== void 0 ? measures : []);
|
|
44
|
+
if (unknownDimensionsOrMeasures.length) {
|
|
45
|
+
return "Cannot order by ".concat(unknownDimensionsOrMeasures.join(", "), " as no such ").concat(unknownDimensionsOrMeasures.length === 1 ? "property" : "properties", " has been loaded.");
|
|
46
|
+
}
|
|
10
47
|
var query = {
|
|
11
48
|
datasetId: request.from.datasetId,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
49
|
+
embeddableId: request.from.embeddableId,
|
|
50
|
+
dimensions: dimensions,
|
|
51
|
+
measures: measures,
|
|
52
|
+
timeDimensions: timeDimensions,
|
|
53
|
+
offset: request.offset,
|
|
54
|
+
limit: request.limit,
|
|
16
55
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
56
|
+
window.dispatchEvent(new CustomEvent(LOAD_DATA_EVENT, {
|
|
57
|
+
bubbles: false,
|
|
58
|
+
detail: {
|
|
59
|
+
query: query,
|
|
60
|
+
componentId: componentId,
|
|
61
|
+
propertyName: propertyName,
|
|
62
|
+
},
|
|
63
|
+
}));
|
|
20
64
|
};
|
|
21
65
|
var loadData = function (requestParams) { return ({
|
|
22
66
|
requestParams: requestParams,
|
|
23
|
-
dataLoader: executeDataRequest
|
|
67
|
+
dataLoader: executeDataRequest,
|
|
24
68
|
}); };
|
|
25
69
|
|
|
70
|
+
var getOperationObject = function (operation, value) { return ({
|
|
71
|
+
operation: operation,
|
|
72
|
+
value: value,
|
|
73
|
+
__embeddableVariableMeta: true,
|
|
74
|
+
}); };
|
|
75
|
+
var Value = {
|
|
76
|
+
noFilter: function () { return getOperationObject("NO_FILTER"); },
|
|
77
|
+
of: function (value) { return getOperationObject("VALUE", value); },
|
|
78
|
+
};
|
|
79
|
+
|
|
26
80
|
var UPDATE_VALUE_EVENT = "embeddable:value:changed";
|
|
27
81
|
var setValue = function (value, componentId, eventName) {
|
|
28
82
|
var event = new CustomEvent(UPDATE_VALUE_EVENT, {
|
|
@@ -30,7 +84,7 @@ var setValue = function (value, componentId, eventName) {
|
|
|
30
84
|
detail: {
|
|
31
85
|
componentId: componentId,
|
|
32
86
|
value: value,
|
|
33
|
-
eventName: eventName
|
|
87
|
+
eventName: eventName,
|
|
34
88
|
},
|
|
35
89
|
});
|
|
36
90
|
window.dispatchEvent(event);
|
|
@@ -85,9 +139,10 @@ var embedOption = function (typeName, option) {
|
|
|
85
139
|
if (!window.__EMBEDDABLE__.types[typeName])
|
|
86
140
|
return;
|
|
87
141
|
// @ts-ignore
|
|
88
|
-
window.__EMBEDDABLE__.types[typeName].options =
|
|
142
|
+
window.__EMBEDDABLE__.types[typeName].options =
|
|
143
|
+
window.__EMBEDDABLE__.types[typeName].options || [];
|
|
89
144
|
// @ts-ignore
|
|
90
145
|
window.__EMBEDDABLE__.types[typeName].options.push(option);
|
|
91
146
|
};
|
|
92
147
|
|
|
93
|
-
export { embedOption, embedType, loadData, setValue };
|
|
148
|
+
export { Value, embedOption, embedType, isLoadDataParams, loadData, setValue };
|
package/lib/index.umd.js
CHANGED
|
@@ -1,32 +1,88 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports'
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.embeddableSdk = {}
|
|
5
|
-
})(this, (function (exports
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.embeddableSdk = {}));
|
|
5
|
+
})(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
|
-
var
|
|
8
|
-
var _a, _b, _c;
|
|
7
|
+
var normalizeEntities = function (entities, _a) {
|
|
8
|
+
var _b = _a.mapFn, mapFn = _b === void 0 ? function (x) { return x; } : _b, _c = _a.filterFn, filterFn = _c === void 0 ? Boolean : _c;
|
|
9
|
+
if (!entities)
|
|
10
|
+
return undefined;
|
|
11
|
+
var filtered = entities.filter(filterFn);
|
|
12
|
+
if (filtered.length === 0)
|
|
13
|
+
return undefined;
|
|
14
|
+
return filtered.map(mapFn);
|
|
15
|
+
};
|
|
16
|
+
var getName = function (x) { return x.name; };
|
|
17
|
+
var validateOrderBy = function (orderByParam, dimensions, measures) {
|
|
18
|
+
var unknownDimensionsOrMeasures = [];
|
|
19
|
+
var dimensionAndMeasureNames = measures
|
|
20
|
+
.concat(dimensions)
|
|
21
|
+
.map(function (x) { return x.name; });
|
|
22
|
+
for (var _i = 0, orderByParam_1 = orderByParam; _i < orderByParam_1.length; _i++) {
|
|
23
|
+
var orderBy = orderByParam_1[_i];
|
|
24
|
+
var name_1 = orderBy.property.name;
|
|
25
|
+
if (dimensionAndMeasureNames.includes(name_1))
|
|
26
|
+
continue;
|
|
27
|
+
unknownDimensionsOrMeasures.push(name_1);
|
|
28
|
+
}
|
|
29
|
+
return unknownDimensionsOrMeasures;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
var LOAD_DATA_EVENT = "embeddable-event:load-data";
|
|
33
|
+
var isLoadDataParams = function (ldp) {
|
|
34
|
+
return typeof ldp === "object" && "requestParams" in ldp && "dataLoader" in ldp;
|
|
35
|
+
};
|
|
36
|
+
var executeDataRequest = function (request, componentId, propertyName) {
|
|
37
|
+
var _a;
|
|
9
38
|
if (!request.from)
|
|
10
|
-
return
|
|
11
|
-
var dimensions = (
|
|
12
|
-
var measures = (
|
|
13
|
-
var timeDimensions = (
|
|
39
|
+
return "No dataset selected";
|
|
40
|
+
var dimensions = normalizeEntities(request.dimensions, { mapFn: getName });
|
|
41
|
+
var measures = normalizeEntities(request.measures, { mapFn: getName });
|
|
42
|
+
var timeDimensions = normalizeEntities(request.timeDimensions, {
|
|
43
|
+
// @ts-expect-error
|
|
44
|
+
filterFn: getName,
|
|
45
|
+
});
|
|
46
|
+
var dimensionsOrMeasuresDefined = dimensions || measures || timeDimensions;
|
|
47
|
+
if (!dimensionsOrMeasuresDefined)
|
|
48
|
+
return "At least a dimension or a measure should be selected.";
|
|
49
|
+
var unknownDimensionsOrMeasures = validateOrderBy((_a = request.orderBy) !== null && _a !== void 0 ? _a : [], dimensions !== null && dimensions !== void 0 ? dimensions : [], measures !== null && measures !== void 0 ? measures : []);
|
|
50
|
+
if (unknownDimensionsOrMeasures.length) {
|
|
51
|
+
return "Cannot order by ".concat(unknownDimensionsOrMeasures.join(", "), " as no such ").concat(unknownDimensionsOrMeasures.length === 1 ? "property" : "properties", " has been loaded.");
|
|
52
|
+
}
|
|
14
53
|
var query = {
|
|
15
54
|
datasetId: request.from.datasetId,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
55
|
+
embeddableId: request.from.embeddableId,
|
|
56
|
+
dimensions: dimensions,
|
|
57
|
+
measures: measures,
|
|
58
|
+
timeDimensions: timeDimensions,
|
|
59
|
+
offset: request.offset,
|
|
60
|
+
limit: request.limit,
|
|
20
61
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
62
|
+
window.dispatchEvent(new CustomEvent(LOAD_DATA_EVENT, {
|
|
63
|
+
bubbles: false,
|
|
64
|
+
detail: {
|
|
65
|
+
query: query,
|
|
66
|
+
componentId: componentId,
|
|
67
|
+
propertyName: propertyName,
|
|
68
|
+
},
|
|
69
|
+
}));
|
|
24
70
|
};
|
|
25
71
|
var loadData = function (requestParams) { return ({
|
|
26
72
|
requestParams: requestParams,
|
|
27
|
-
dataLoader: executeDataRequest
|
|
73
|
+
dataLoader: executeDataRequest,
|
|
28
74
|
}); };
|
|
29
75
|
|
|
76
|
+
var getOperationObject = function (operation, value) { return ({
|
|
77
|
+
operation: operation,
|
|
78
|
+
value: value,
|
|
79
|
+
__embeddableVariableMeta: true,
|
|
80
|
+
}); };
|
|
81
|
+
var Value = {
|
|
82
|
+
noFilter: function () { return getOperationObject("NO_FILTER"); },
|
|
83
|
+
of: function (value) { return getOperationObject("VALUE", value); },
|
|
84
|
+
};
|
|
85
|
+
|
|
30
86
|
var UPDATE_VALUE_EVENT = "embeddable:value:changed";
|
|
31
87
|
var setValue = function (value, componentId, eventName) {
|
|
32
88
|
var event = new CustomEvent(UPDATE_VALUE_EVENT, {
|
|
@@ -34,7 +90,7 @@
|
|
|
34
90
|
detail: {
|
|
35
91
|
componentId: componentId,
|
|
36
92
|
value: value,
|
|
37
|
-
eventName: eventName
|
|
93
|
+
eventName: eventName,
|
|
38
94
|
},
|
|
39
95
|
});
|
|
40
96
|
window.dispatchEvent(event);
|
|
@@ -89,13 +145,16 @@
|
|
|
89
145
|
if (!window.__EMBEDDABLE__.types[typeName])
|
|
90
146
|
return;
|
|
91
147
|
// @ts-ignore
|
|
92
|
-
window.__EMBEDDABLE__.types[typeName].options =
|
|
148
|
+
window.__EMBEDDABLE__.types[typeName].options =
|
|
149
|
+
window.__EMBEDDABLE__.types[typeName].options || [];
|
|
93
150
|
// @ts-ignore
|
|
94
151
|
window.__EMBEDDABLE__.types[typeName].options.push(option);
|
|
95
152
|
};
|
|
96
153
|
|
|
154
|
+
exports.Value = Value;
|
|
97
155
|
exports.embedOption = embedOption;
|
|
98
156
|
exports.embedType = embedType;
|
|
157
|
+
exports.isLoadDataParams = isLoadDataParams;
|
|
99
158
|
exports.loadData = loadData;
|
|
100
159
|
exports.setValue = setValue;
|
|
101
160
|
|
package/lib/loadData.d.ts
CHANGED
|
@@ -1,22 +1,70 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
declare const cubeType: {
|
|
2
|
+
readonly string: "string";
|
|
3
|
+
readonly number: "number";
|
|
4
|
+
readonly time: "time";
|
|
5
|
+
};
|
|
6
|
+
export type CubeType = keyof typeof cubeType;
|
|
7
|
+
export type Dimension = {
|
|
8
|
+
name: string;
|
|
9
|
+
title: string;
|
|
10
|
+
type: CubeType;
|
|
11
|
+
};
|
|
12
|
+
export type Measure = {
|
|
13
|
+
name: string;
|
|
14
|
+
title: string;
|
|
15
|
+
type: string;
|
|
16
|
+
};
|
|
17
|
+
export type DimensionOrMeasure = Dimension | Measure;
|
|
18
|
+
declare const timeDimensionGranularity: {
|
|
19
|
+
second: string;
|
|
20
|
+
minute: string;
|
|
21
|
+
hour: string;
|
|
22
|
+
day: string;
|
|
23
|
+
week: string;
|
|
24
|
+
month: string;
|
|
25
|
+
quarter: string;
|
|
26
|
+
year: string;
|
|
27
|
+
};
|
|
28
|
+
export type Granularity = keyof typeof timeDimensionGranularity;
|
|
29
|
+
export type TimeDimension = {
|
|
30
|
+
name: string;
|
|
31
|
+
granularity: Granularity;
|
|
32
|
+
};
|
|
33
|
+
export type OrderDirection = "asc" | "desc";
|
|
34
|
+
export type OrderBy = {
|
|
35
|
+
property: DimensionOrMeasure;
|
|
36
|
+
direction: OrderDirection;
|
|
37
|
+
};
|
|
38
|
+
export type LoadDataEvent = {
|
|
39
|
+
query: QueryRequest;
|
|
40
|
+
componentId: string;
|
|
41
|
+
propertyName: string;
|
|
42
|
+
};
|
|
43
|
+
type QueryRequest = {
|
|
44
|
+
embeddableId: string;
|
|
45
|
+
datasetId: string;
|
|
46
|
+
dimensions: string[];
|
|
47
|
+
measures?: string[];
|
|
48
|
+
timeDimensions?: TimeDimension[];
|
|
5
49
|
};
|
|
6
50
|
export type Dataset = {
|
|
51
|
+
embeddableId: string;
|
|
7
52
|
datasetId: string;
|
|
8
53
|
};
|
|
9
54
|
export type LoadDataRequest = {
|
|
10
55
|
from: Dataset;
|
|
11
|
-
measures?:
|
|
12
|
-
dimensions
|
|
13
|
-
timeDimensions?:
|
|
14
|
-
orderBy?:
|
|
56
|
+
measures?: Measure[];
|
|
57
|
+
dimensions?: Dimension[];
|
|
58
|
+
timeDimensions?: TimeDimension[];
|
|
59
|
+
orderBy?: OrderBy[];
|
|
60
|
+
limit?: number;
|
|
61
|
+
offset?: number;
|
|
15
62
|
};
|
|
16
63
|
export type LoadDataParams = {
|
|
17
64
|
requestParams: LoadDataRequest;
|
|
18
65
|
dataLoader: typeof executeDataRequest;
|
|
19
66
|
};
|
|
20
|
-
declare const
|
|
67
|
+
export declare const isLoadDataParams: (ldp: unknown) => ldp is LoadDataParams;
|
|
68
|
+
declare const executeDataRequest: (request: LoadDataRequest, componentId: string, propertyName: string) => string;
|
|
21
69
|
export declare const loadData: (requestParams: LoadDataRequest) => LoadDataParams;
|
|
22
70
|
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type OperationType = "NO_FILTER" | "VALUE";
|
|
2
|
+
type Operation = {
|
|
3
|
+
operation: OperationType;
|
|
4
|
+
value?: unknown;
|
|
5
|
+
};
|
|
6
|
+
export type ValueOperationType = {
|
|
7
|
+
noFilter: () => Operation;
|
|
8
|
+
of: (value: unknown) => Operation;
|
|
9
|
+
};
|
|
10
|
+
export declare const Value: ValueOperationType;
|
|
11
|
+
export {};
|
package/lib/untils.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Dimension, Measure, OrderBy } from "./loadData";
|
|
2
|
+
export declare const normalizeEntities: <T>(entities: T[], { mapFn, filterFn, }: {
|
|
3
|
+
mapFn?: (_: T) => any;
|
|
4
|
+
filterFn?: (_: T) => boolean;
|
|
5
|
+
}) => any[];
|
|
6
|
+
export declare const getName: <T extends {
|
|
7
|
+
name: string;
|
|
8
|
+
}>(x: T) => string;
|
|
9
|
+
export declare const validateOrderBy: (orderByParam: OrderBy[], dimensions: Dimension[], measures: Measure[]) => any[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embeddable.com/sdk-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Core Embeddable SDK module responsible for web-components bundling and publishing.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"embeddable",
|
|
@@ -35,7 +35,12 @@
|
|
|
35
35
|
"archiver": "^5.3.1",
|
|
36
36
|
"axios": "^1.4.0",
|
|
37
37
|
"formdata-node": "^5.0.1",
|
|
38
|
-
"
|
|
39
|
-
"
|
|
38
|
+
"open": "^9.1.0",
|
|
39
|
+
"yaml": "^2.3.3"
|
|
40
|
+
},
|
|
41
|
+
"lint-staged": {
|
|
42
|
+
"*.{js,ts,json}": [
|
|
43
|
+
"prettier --write"
|
|
44
|
+
]
|
|
40
45
|
}
|
|
41
46
|
}
|
package/scripts/build.js
CHANGED
|
@@ -5,16 +5,16 @@ const { cleanup } = require("./cleanup");
|
|
|
5
5
|
const { createContext } = require("./createContext");
|
|
6
6
|
|
|
7
7
|
async function build(pluginOptions = {}) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
const ctx = {
|
|
9
|
+
...createContext(path.resolve(__dirname, ".."), process.cwd()),
|
|
10
|
+
pluginOptions,
|
|
11
|
+
};
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
await prepare(ctx);
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
await generate(ctx);
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
await cleanup(ctx);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
module.exports = { build };
|