@embeddable.com/sdk-core 0.0.15 → 0.1.1

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.
@@ -0,0 +1 @@
1
+ export declare const embedOption: (typeName: string, option: any) => void;
@@ -0,0 +1,4 @@
1
+ export declare const embedType: (typeName: string, typeConfig: {
2
+ label: string;
3
+ toString: (_: any) => string;
4
+ }) => void;
package/lib/index.cjs.js CHANGED
@@ -2,6 +2,42 @@
2
2
 
3
3
  var axios = require('axios');
4
4
 
5
+ var executeDataRequest = function (request, variables) {
6
+ var _a, _b, _c;
7
+ if (!request.from)
8
+ return Promise.reject('No dataset selected');
9
+ var dimensions = (_a = request.dimensions) === null || _a === void 0 ? void 0 : _a.filter(Boolean);
10
+ var measures = (_b = request.measures) === null || _b === void 0 ? void 0 : _b.filter(Boolean);
11
+ var timeDimensions = (_c = request.timeDimensions) === null || _c === void 0 ? void 0 : _c.filter(function (d) { return d.dimension; });
12
+ var query = {
13
+ datasetId: request.from.datasetId,
14
+ dimensions: (dimensions === null || dimensions === void 0 ? void 0 : dimensions.length) ? dimensions : undefined,
15
+ measures: (measures === null || measures === void 0 ? void 0 : measures.length) ? measures : undefined,
16
+ timeDimensions: (timeDimensions === null || timeDimensions === void 0 ? void 0 : timeDimensions.length) ? timeDimensions : undefined,
17
+ variableValues: variables
18
+ };
19
+ if (!query.dimensions && !query.timeDimensions)
20
+ return Promise.reject('No dimension selected');
21
+ return axios.post("".concat("https://api.embeddable.com", "/data-modeling/query"), query);
22
+ };
23
+ var loadData = function (requestParams) { return ({
24
+ requestParams: requestParams,
25
+ dataLoader: executeDataRequest
26
+ }); };
27
+
28
+ var UPDATE_VALUE_EVENT = "embeddable:value:changed";
29
+ var setValue = function (value, componentId, eventName) {
30
+ var event = new CustomEvent(UPDATE_VALUE_EVENT, {
31
+ bubbles: false,
32
+ detail: {
33
+ componentId: componentId,
34
+ value: value,
35
+ eventName: eventName
36
+ },
37
+ });
38
+ window.dispatchEvent(event);
39
+ };
40
+
5
41
  /******************************************************************************
6
42
  Copyright (c) Microsoft Corporation.
7
43
 
@@ -19,73 +55,44 @@ PERFORMANCE OF THIS SOFTWARE.
19
55
  /* global Reflect, Promise, SuppressedError, Symbol */
20
56
 
21
57
 
22
- function __awaiter(thisArg, _arguments, P, generator) {
23
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
24
- return new (P || (P = Promise))(function (resolve, reject) {
25
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
26
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
27
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
28
- step((generator = generator.apply(thisArg, _arguments || [])).next());
29
- });
30
- }
31
-
32
- function __generator(thisArg, body) {
33
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
34
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
35
- function verb(n) { return function (v) { return step([n, v]); }; }
36
- function step(op) {
37
- if (f) throw new TypeError("Generator is already executing.");
38
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
39
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
40
- if (y = 0, t) op = [op[0] & 2, t.value];
41
- switch (op[0]) {
42
- case 0: case 1: t = op; break;
43
- case 4: _.label++; return { value: op[1], done: false };
44
- case 5: _.label++; y = op[1]; op = [0]; continue;
45
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
46
- default:
47
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
48
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
49
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
50
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
51
- if (t[2]) _.ops.pop();
52
- _.trys.pop(); continue;
53
- }
54
- op = body.call(thisArg, _);
55
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
56
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
57
- }
58
- }
58
+ var __assign = function() {
59
+ __assign = Object.assign || function __assign(t) {
60
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
61
+ s = arguments[i];
62
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
63
+ }
64
+ return t;
65
+ };
66
+ return __assign.apply(this, arguments);
67
+ };
59
68
 
60
69
  typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
61
70
  var e = new Error(message);
62
71
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
63
72
  };
64
73
 
65
- function loadData(request) {
66
- var _a, _b, _c;
67
- return __awaiter(this, void 0, void 0, function () {
68
- var dimensions, measures, timeDimensions, query, response;
69
- return __generator(this, function (_d) {
70
- switch (_d.label) {
71
- case 0:
72
- dimensions = (_a = request.dimensions) === null || _a === void 0 ? void 0 : _a.filter(Boolean);
73
- measures = (_b = request.measures) === null || _b === void 0 ? void 0 : _b.filter(Boolean);
74
- timeDimensions = (_c = request.timeDimensions) === null || _c === void 0 ? void 0 : _c.filter(function (d) { return d.dimension; });
75
- query = {
76
- dimensions: (dimensions === null || dimensions === void 0 ? void 0 : dimensions.length) ? dimensions : undefined,
77
- measures: (measures === null || measures === void 0 ? void 0 : measures.length) ? measures : undefined,
78
- timeDimensions: (timeDimensions === null || timeDimensions === void 0 ? void 0 : timeDimensions.length) ? timeDimensions : undefined
79
- };
80
- if (!query.dimensions && !query.timeDimensions)
81
- return [2 /*return*/, null];
82
- return [4 /*yield*/, axios.post("".concat("https://api.embeddable.com", "/data-modeling/query?datasourceId=").concat(request.from), query)];
83
- case 1:
84
- response = _d.sent();
85
- return [2 /*return*/, response.data];
86
- }
87
- });
88
- });
89
- }
74
+ var embedType = function (typeName, typeConfig) {
75
+ // @ts-ignore
76
+ window.__EMBEDDABLE__ = window.__EMBEDDABLE__ || {};
77
+ // @ts-ignore
78
+ window.__EMBEDDABLE__.types = window.__EMBEDDABLE__.types || {};
79
+ // @ts-ignore
80
+ window.__EMBEDDABLE__.types[typeName] = __assign({ name: typeName }, typeConfig);
81
+ };
82
+
83
+ var embedOption = function (typeName, option) {
84
+ // @ts-ignore
85
+ window.__EMBEDDABLE__ = window.__EMBEDDABLE__ || {};
86
+ // @ts-ignore
87
+ if (!window.__EMBEDDABLE__.types[typeName])
88
+ return;
89
+ // @ts-ignore
90
+ window.__EMBEDDABLE__.types[typeName].options = window.__EMBEDDABLE__.types[typeName].options || [];
91
+ // @ts-ignore
92
+ window.__EMBEDDABLE__.types[typeName].options.push(option);
93
+ };
90
94
 
95
+ exports.embedOption = embedOption;
96
+ exports.embedType = embedType;
91
97
  exports.loadData = loadData;
98
+ exports.setValue = setValue;
package/lib/index.d.ts CHANGED
@@ -1 +1,4 @@
1
- export { loadData } from './loadData';
1
+ export * from './loadData';
2
+ export { setValue } from './setValue';
3
+ export { embedType } from './embedType';
4
+ export { embedOption } from './embedOption';
package/lib/index.esm.js CHANGED
@@ -1,5 +1,41 @@
1
1
  import axios from 'axios';
2
2
 
3
+ var executeDataRequest = function (request, variables) {
4
+ var _a, _b, _c;
5
+ if (!request.from)
6
+ return Promise.reject('No dataset selected');
7
+ var dimensions = (_a = request.dimensions) === null || _a === void 0 ? void 0 : _a.filter(Boolean);
8
+ var measures = (_b = request.measures) === null || _b === void 0 ? void 0 : _b.filter(Boolean);
9
+ var timeDimensions = (_c = request.timeDimensions) === null || _c === void 0 ? void 0 : _c.filter(function (d) { return d.dimension; });
10
+ var query = {
11
+ datasetId: request.from.datasetId,
12
+ dimensions: (dimensions === null || dimensions === void 0 ? void 0 : dimensions.length) ? dimensions : undefined,
13
+ measures: (measures === null || measures === void 0 ? void 0 : measures.length) ? measures : undefined,
14
+ timeDimensions: (timeDimensions === null || timeDimensions === void 0 ? void 0 : timeDimensions.length) ? timeDimensions : undefined,
15
+ variableValues: variables
16
+ };
17
+ if (!query.dimensions && !query.timeDimensions)
18
+ return Promise.reject('No dimension selected');
19
+ return axios.post("".concat("https://api.embeddable.com", "/data-modeling/query"), query);
20
+ };
21
+ var loadData = function (requestParams) { return ({
22
+ requestParams: requestParams,
23
+ dataLoader: executeDataRequest
24
+ }); };
25
+
26
+ var UPDATE_VALUE_EVENT = "embeddable:value:changed";
27
+ var setValue = function (value, componentId, eventName) {
28
+ var event = new CustomEvent(UPDATE_VALUE_EVENT, {
29
+ bubbles: false,
30
+ detail: {
31
+ componentId: componentId,
32
+ value: value,
33
+ eventName: eventName
34
+ },
35
+ });
36
+ window.dispatchEvent(event);
37
+ };
38
+
3
39
  /******************************************************************************
4
40
  Copyright (c) Microsoft Corporation.
5
41
 
@@ -17,73 +53,41 @@ PERFORMANCE OF THIS SOFTWARE.
17
53
  /* global Reflect, Promise, SuppressedError, Symbol */
18
54
 
19
55
 
20
- function __awaiter(thisArg, _arguments, P, generator) {
21
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
22
- return new (P || (P = Promise))(function (resolve, reject) {
23
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
24
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
25
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
26
- step((generator = generator.apply(thisArg, _arguments || [])).next());
27
- });
28
- }
29
-
30
- function __generator(thisArg, body) {
31
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
32
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
33
- function verb(n) { return function (v) { return step([n, v]); }; }
34
- function step(op) {
35
- if (f) throw new TypeError("Generator is already executing.");
36
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
37
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
38
- if (y = 0, t) op = [op[0] & 2, t.value];
39
- switch (op[0]) {
40
- case 0: case 1: t = op; break;
41
- case 4: _.label++; return { value: op[1], done: false };
42
- case 5: _.label++; y = op[1]; op = [0]; continue;
43
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
44
- default:
45
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
46
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
47
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
48
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
49
- if (t[2]) _.ops.pop();
50
- _.trys.pop(); continue;
51
- }
52
- op = body.call(thisArg, _);
53
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
54
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
55
- }
56
- }
56
+ var __assign = function() {
57
+ __assign = Object.assign || function __assign(t) {
58
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
59
+ s = arguments[i];
60
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
61
+ }
62
+ return t;
63
+ };
64
+ return __assign.apply(this, arguments);
65
+ };
57
66
 
58
67
  typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
59
68
  var e = new Error(message);
60
69
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
61
70
  };
62
71
 
63
- function loadData(request) {
64
- var _a, _b, _c;
65
- return __awaiter(this, void 0, void 0, function () {
66
- var dimensions, measures, timeDimensions, query, response;
67
- return __generator(this, function (_d) {
68
- switch (_d.label) {
69
- case 0:
70
- dimensions = (_a = request.dimensions) === null || _a === void 0 ? void 0 : _a.filter(Boolean);
71
- measures = (_b = request.measures) === null || _b === void 0 ? void 0 : _b.filter(Boolean);
72
- timeDimensions = (_c = request.timeDimensions) === null || _c === void 0 ? void 0 : _c.filter(function (d) { return d.dimension; });
73
- query = {
74
- dimensions: (dimensions === null || dimensions === void 0 ? void 0 : dimensions.length) ? dimensions : undefined,
75
- measures: (measures === null || measures === void 0 ? void 0 : measures.length) ? measures : undefined,
76
- timeDimensions: (timeDimensions === null || timeDimensions === void 0 ? void 0 : timeDimensions.length) ? timeDimensions : undefined
77
- };
78
- if (!query.dimensions && !query.timeDimensions)
79
- return [2 /*return*/, null];
80
- return [4 /*yield*/, axios.post("".concat("https://api.embeddable.com", "/data-modeling/query?datasourceId=").concat(request.from), query)];
81
- case 1:
82
- response = _d.sent();
83
- return [2 /*return*/, response.data];
84
- }
85
- });
86
- });
87
- }
72
+ var embedType = function (typeName, typeConfig) {
73
+ // @ts-ignore
74
+ window.__EMBEDDABLE__ = window.__EMBEDDABLE__ || {};
75
+ // @ts-ignore
76
+ window.__EMBEDDABLE__.types = window.__EMBEDDABLE__.types || {};
77
+ // @ts-ignore
78
+ window.__EMBEDDABLE__.types[typeName] = __assign({ name: typeName }, typeConfig);
79
+ };
80
+
81
+ var embedOption = function (typeName, option) {
82
+ // @ts-ignore
83
+ window.__EMBEDDABLE__ = window.__EMBEDDABLE__ || {};
84
+ // @ts-ignore
85
+ if (!window.__EMBEDDABLE__.types[typeName])
86
+ return;
87
+ // @ts-ignore
88
+ window.__EMBEDDABLE__.types[typeName].options = window.__EMBEDDABLE__.types[typeName].options || [];
89
+ // @ts-ignore
90
+ window.__EMBEDDABLE__.types[typeName].options.push(option);
91
+ };
88
92
 
89
- export { loadData };
93
+ export { embedOption, embedType, loadData, setValue };
package/lib/index.umd.js CHANGED
@@ -4,6 +4,42 @@
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.embeddableSdk = {}, global.axios));
5
5
  })(this, (function (exports, axios) { 'use strict';
6
6
 
7
+ var executeDataRequest = function (request, variables) {
8
+ var _a, _b, _c;
9
+ if (!request.from)
10
+ return Promise.reject('No dataset selected');
11
+ var dimensions = (_a = request.dimensions) === null || _a === void 0 ? void 0 : _a.filter(Boolean);
12
+ var measures = (_b = request.measures) === null || _b === void 0 ? void 0 : _b.filter(Boolean);
13
+ var timeDimensions = (_c = request.timeDimensions) === null || _c === void 0 ? void 0 : _c.filter(function (d) { return d.dimension; });
14
+ var query = {
15
+ datasetId: request.from.datasetId,
16
+ dimensions: (dimensions === null || dimensions === void 0 ? void 0 : dimensions.length) ? dimensions : undefined,
17
+ measures: (measures === null || measures === void 0 ? void 0 : measures.length) ? measures : undefined,
18
+ timeDimensions: (timeDimensions === null || timeDimensions === void 0 ? void 0 : timeDimensions.length) ? timeDimensions : undefined,
19
+ variableValues: variables
20
+ };
21
+ if (!query.dimensions && !query.timeDimensions)
22
+ return Promise.reject('No dimension selected');
23
+ return axios.post("".concat("https://api.embeddable.com", "/data-modeling/query"), query);
24
+ };
25
+ var loadData = function (requestParams) { return ({
26
+ requestParams: requestParams,
27
+ dataLoader: executeDataRequest
28
+ }); };
29
+
30
+ var UPDATE_VALUE_EVENT = "embeddable:value:changed";
31
+ var setValue = function (value, componentId, eventName) {
32
+ var event = new CustomEvent(UPDATE_VALUE_EVENT, {
33
+ bubbles: false,
34
+ detail: {
35
+ componentId: componentId,
36
+ value: value,
37
+ eventName: eventName
38
+ },
39
+ });
40
+ window.dispatchEvent(event);
41
+ };
42
+
7
43
  /******************************************************************************
8
44
  Copyright (c) Microsoft Corporation.
9
45
 
@@ -21,75 +57,46 @@
21
57
  /* global Reflect, Promise, SuppressedError, Symbol */
22
58
 
23
59
 
24
- function __awaiter(thisArg, _arguments, P, generator) {
25
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
26
- return new (P || (P = Promise))(function (resolve, reject) {
27
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
28
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
29
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
30
- step((generator = generator.apply(thisArg, _arguments || [])).next());
31
- });
32
- }
33
-
34
- function __generator(thisArg, body) {
35
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
36
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
37
- function verb(n) { return function (v) { return step([n, v]); }; }
38
- function step(op) {
39
- if (f) throw new TypeError("Generator is already executing.");
40
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
41
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
42
- if (y = 0, t) op = [op[0] & 2, t.value];
43
- switch (op[0]) {
44
- case 0: case 1: t = op; break;
45
- case 4: _.label++; return { value: op[1], done: false };
46
- case 5: _.label++; y = op[1]; op = [0]; continue;
47
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
48
- default:
49
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
50
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
51
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
52
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
53
- if (t[2]) _.ops.pop();
54
- _.trys.pop(); continue;
55
- }
56
- op = body.call(thisArg, _);
57
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
58
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
59
- }
60
- }
60
+ var __assign = function() {
61
+ __assign = Object.assign || function __assign(t) {
62
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
63
+ s = arguments[i];
64
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
65
+ }
66
+ return t;
67
+ };
68
+ return __assign.apply(this, arguments);
69
+ };
61
70
 
62
71
  typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
63
72
  var e = new Error(message);
64
73
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
65
74
  };
66
75
 
67
- function loadData(request) {
68
- var _a, _b, _c;
69
- return __awaiter(this, void 0, void 0, function () {
70
- var dimensions, measures, timeDimensions, query, response;
71
- return __generator(this, function (_d) {
72
- switch (_d.label) {
73
- case 0:
74
- dimensions = (_a = request.dimensions) === null || _a === void 0 ? void 0 : _a.filter(Boolean);
75
- measures = (_b = request.measures) === null || _b === void 0 ? void 0 : _b.filter(Boolean);
76
- timeDimensions = (_c = request.timeDimensions) === null || _c === void 0 ? void 0 : _c.filter(function (d) { return d.dimension; });
77
- query = {
78
- dimensions: (dimensions === null || dimensions === void 0 ? void 0 : dimensions.length) ? dimensions : undefined,
79
- measures: (measures === null || measures === void 0 ? void 0 : measures.length) ? measures : undefined,
80
- timeDimensions: (timeDimensions === null || timeDimensions === void 0 ? void 0 : timeDimensions.length) ? timeDimensions : undefined
81
- };
82
- if (!query.dimensions && !query.timeDimensions)
83
- return [2 /*return*/, null];
84
- return [4 /*yield*/, axios.post("".concat("https://api.embeddable.com", "/data-modeling/query?datasourceId=").concat(request.from), query)];
85
- case 1:
86
- response = _d.sent();
87
- return [2 /*return*/, response.data];
88
- }
89
- });
90
- });
91
- }
76
+ var embedType = function (typeName, typeConfig) {
77
+ // @ts-ignore
78
+ window.__EMBEDDABLE__ = window.__EMBEDDABLE__ || {};
79
+ // @ts-ignore
80
+ window.__EMBEDDABLE__.types = window.__EMBEDDABLE__.types || {};
81
+ // @ts-ignore
82
+ window.__EMBEDDABLE__.types[typeName] = __assign({ name: typeName }, typeConfig);
83
+ };
84
+
85
+ var embedOption = function (typeName, option) {
86
+ // @ts-ignore
87
+ window.__EMBEDDABLE__ = window.__EMBEDDABLE__ || {};
88
+ // @ts-ignore
89
+ if (!window.__EMBEDDABLE__.types[typeName])
90
+ return;
91
+ // @ts-ignore
92
+ window.__EMBEDDABLE__.types[typeName].options = window.__EMBEDDABLE__.types[typeName].options || [];
93
+ // @ts-ignore
94
+ window.__EMBEDDABLE__.types[typeName].options.push(option);
95
+ };
92
96
 
97
+ exports.embedOption = embedOption;
98
+ exports.embedType = embedType;
93
99
  exports.loadData = loadData;
100
+ exports.setValue = setValue;
94
101
 
95
102
  }));
package/lib/loadData.d.ts CHANGED
@@ -1,12 +1,22 @@
1
+ import axios from 'axios';
1
2
  export type TimeDimensions = {
2
3
  dimension: string;
3
4
  granularity: string;
4
5
  };
6
+ export type Dataset = {
7
+ datasetId: string;
8
+ };
5
9
  export type LoadDataRequest = {
6
- from: string;
10
+ from: Dataset;
7
11
  measures?: string[];
8
12
  dimensions: string[];
9
13
  timeDimensions?: TimeDimensions[];
10
14
  orderBy?: string[];
11
15
  };
12
- export declare function loadData(request: LoadDataRequest): Promise<any>;
16
+ export type LoadDataParams = {
17
+ requestParams: LoadDataRequest;
18
+ dataLoader: typeof executeDataRequest;
19
+ };
20
+ declare const executeDataRequest: (request: LoadDataRequest, variables?: Record<string, any>) => Promise<axios.AxiosResponse<any, any>>;
21
+ export declare const loadData: (requestParams: LoadDataRequest) => LoadDataParams;
22
+ export {};
@@ -0,0 +1 @@
1
+ export declare const setValue: <T>(value: T, componentId: string, eventName?: string) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embeddable.com/sdk-core",
3
- "version": "0.0.15",
3
+ "version": "0.1.1",
4
4
  "description": "Core Embeddable SDK module responsible for web-components bundling and publishing.",
5
5
  "keywords": [
6
6
  "embeddable",
@@ -0,0 +1,52 @@
1
+ const fs = require("node:fs/promises");
2
+ const path = require("node:path");
3
+ const vite = require("vite");
4
+
5
+ const { findEmbFiles } = require("./findEmbFiles");
6
+
7
+
8
+ const EMB_TYPE_FILE_REGEX = /^(.*)\.type\.emb\.[jt]s$/;
9
+
10
+ async function buildTypes(ctx) {
11
+ await generate(ctx);
12
+
13
+ await build(ctx);
14
+
15
+ await cleanup(ctx);
16
+ }
17
+
18
+ module.exports = { buildTypes };
19
+
20
+
21
+ async function generate(ctx) {
22
+ const typeFiles = await findEmbFiles(ctx.client.srcDir, EMB_TYPE_FILE_REGEX);
23
+
24
+ const typeImports = typeFiles.map(([fileName, filePath]) =>
25
+ `import './${path.relative(ctx.client.rootDir, filePath)}';`
26
+ ).join('\n');
27
+
28
+ await fs.writeFile(
29
+ path.resolve(ctx.client.rootDir, ctx.outputOptions.typesEntryPointFilename),
30
+ typeImports
31
+ );
32
+ }
33
+
34
+ async function build(ctx) {
35
+ process.chdir(ctx.client.rootDir);
36
+
37
+ await vite.build({
38
+ build: {
39
+ emptyOutDir: false,
40
+ lib: {
41
+ entry: `./${ctx.outputOptions.typesEntryPointFilename}`,
42
+ formats: ['es'],
43
+ fileName: 'embeddable-types'
44
+ },
45
+ outDir: '.embeddable-build/'
46
+ },
47
+ });
48
+ }
49
+
50
+ async function cleanup(ctx) {
51
+ await fs.rm(path.resolve(ctx.client.rootDir, 'embeddable-types-entry-point.js'));
52
+ }
@@ -4,7 +4,6 @@ const path = require("path");
4
4
  const stencilNodeApi = require("@stencil/core/sys/node");
5
5
  const stencil = require("@stencil/core/cli");
6
6
 
7
-
8
7
  const STYLE_IMPORTS_TOKEN = '{{STYLES_IMPORT}}';
9
8
  const RENDER_IMPORT_TOKEN = '{{RENDER_IMPORT}}';
10
9
 
package/scripts/index.js CHANGED
@@ -1,10 +1,12 @@
1
1
  const { build } = require("./build");
2
+ const { buildTypes } = require("./buildTypes");
2
3
  const { findEmbFiles } = require("./findEmbFiles");
3
4
  const { login } = require("./login");
4
5
  const { push } = require("./push");
5
6
 
6
7
  module.exports = {
7
8
  build,
9
+ buildTypes,
8
10
  findEmbFiles,
9
11
  login,
10
12
  push
package/scripts/login.js CHANGED
@@ -32,7 +32,7 @@ async function login () {
32
32
  const { username, password } = await prompt.get(PROMPT_SCHEMA);
33
33
 
34
34
  const authResponse = await axios.post(
35
- 'http://localhost:8080/auth/token', // TODO: hardcoded for now.
35
+ 'https://metadata.embeddable.com/auth/token', // TODO: hardcoded for now.
36
36
  { username, password }
37
37
  );
38
38
 
package/scripts/push.js CHANGED
@@ -81,7 +81,7 @@ async function sendBuild(ctx, token) {
81
81
  form.set('file', file, 'embeddable-build.zip');
82
82
 
83
83
  await axios.post(
84
- 'http://localhost:8080/sdk/upload-files',
84
+ 'https://metadata.embeddable.com/sdk/upload-files',
85
85
  form,
86
86
  {
87
87
  headers: {
@@ -13,6 +13,11 @@ export class EmbeddableComponent {
13
13
  @Prop() componentName: string;
14
14
  @Prop() props: string = '{}';
15
15
 
16
+ @Watch('componentName')
17
+ watchComponentName() {
18
+ this.handlePops();
19
+ }
20
+
16
21
  componentDidLoad() {
17
22
  this.handlePops();
18
23
  }