dtable-sdk
Advanced tools
Comparing version 0.2.3 to 0.2.4
@@ -7,21 +7,13 @@ "use strict"; | ||
exports["default"] = void 0; | ||
var _axios = _interopRequireDefault(require("axios")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
var DTableServerAPI = /*#__PURE__*/function () { | ||
function DTableServerAPI(config) { | ||
_classCallCheck(this, DTableServerAPI); | ||
this.req = _axios["default"].create(); | ||
this.config = config; | ||
} | ||
_createClass(DTableServerAPI, [{ | ||
@@ -31,6 +23,6 @@ key: "getTableData", | ||
var _this$config = this.config, | ||
dtableServer = _this$config.dtableServer, | ||
dtableUuid = _this$config.dtableUuid, | ||
accessToken = _this$config.accessToken, | ||
lang = _this$config.lang; | ||
dtableServer = _this$config.dtableServer, | ||
dtableUuid = _this$config.dtableUuid, | ||
accessToken = _this$config.accessToken, | ||
lang = _this$config.lang; | ||
var url = dtableServer + 'dtables/' + dtableUuid; | ||
@@ -50,5 +42,5 @@ return this.req.get(url, { | ||
var _this$config2 = this.config, | ||
dtableServer = _this$config2.dtableServer, | ||
dtableUuid = _this$config2.dtableUuid, | ||
accessToken = _this$config2.accessToken; | ||
dtableServer = _this$config2.dtableServer, | ||
dtableUuid = _this$config2.dtableUuid, | ||
accessToken = _this$config2.accessToken; | ||
var url = dtableServer + 'api/v1/dtables/' + dtableUuid + '/comments-count/'; | ||
@@ -66,7 +58,5 @@ var params = { | ||
}]); | ||
return DTableServerAPI; | ||
}(); | ||
var _default = DTableServerAPI; | ||
exports["default"] = _default; |
@@ -7,21 +7,13 @@ "use strict"; | ||
exports["default"] = void 0; | ||
var _axios = _interopRequireDefault(require("axios")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
var DTableWebAPI = /*#__PURE__*/function () { | ||
function DTableWebAPI(config) { | ||
_classCallCheck(this, DTableWebAPI); | ||
this.config = config; | ||
this.req = _axios["default"].create(); | ||
} | ||
_createClass(DTableWebAPI, [{ | ||
@@ -31,7 +23,6 @@ key: "login", | ||
var _this = this; | ||
var _this$config = this.config, | ||
server = _this$config.server, | ||
username = _this$config.username, | ||
password = _this$config.password; | ||
server = _this$config.server, | ||
username = _this$config.username, | ||
password = _this$config.password; | ||
var url = server + '/api2/auth-token/'; | ||
@@ -55,4 +46,4 @@ return _axios["default"].post(url, { | ||
var _this$config2 = this.config, | ||
server = _this$config2.server, | ||
APIToken = _this$config2.APIToken; | ||
server = _this$config2.server, | ||
APIToken = _this$config2.APIToken; | ||
var url = server + '/api/v2.1/dtable/app-access-token/'; | ||
@@ -70,6 +61,6 @@ var headers = { | ||
var _this$config3 = this.config, | ||
server = _this$config3.server, | ||
APIToken = _this$config3.APIToken, | ||
workspaceID = _this$config3.workspaceID, | ||
dtableName = _this$config3.dtableName; | ||
server = _this$config3.server, | ||
APIToken = _this$config3.APIToken, | ||
workspaceID = _this$config3.workspaceID, | ||
dtableName = _this$config3.dtableName; | ||
var url = server + '/api/v2.1/dtable/app-upload-link/'; | ||
@@ -149,7 +140,5 @@ var headers = { | ||
}]); | ||
return DTableWebAPI; | ||
}(); | ||
var _default = DTableWebAPI; | ||
exports["default"] = _default; |
@@ -7,59 +7,36 @@ "use strict"; | ||
exports["default"] = void 0; | ||
var _fs = _interopRequireDefault(require("fs")); | ||
var _axios = _interopRequireDefault(require("axios")); | ||
var _formData = _interopRequireDefault(require("form-data")); | ||
var _dtableStore = require("dtable-store"); | ||
var _debug = _interopRequireDefault(require("debug")); | ||
var _dtableServerApi = _interopRequireDefault(require("./dtable-server-api")); | ||
var _dtableWebApi = _interopRequireDefault(require("./dtable-web-api")); | ||
var _utils = _interopRequireDefault(require("./utils")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } | ||
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var debug = (0, _debug["default"])('dtable:sdk'); | ||
var ACCESS_TOKEN_INTERVAL_TIME = (3 * 24 * 60 - 1) * 60 * 1000; | ||
var DTable = /*#__PURE__*/function () { | ||
function DTable() { | ||
var _this = this; | ||
_classCallCheck(this, DTable); | ||
_defineProperty(this, "addLink", function (linkId, tableId, otherTableId, rowId, otherRowId) { | ||
_this.dtableStore.addLink(linkId, tableId, otherTableId, rowId, otherRowId); | ||
}); | ||
_defineProperty(this, "removeLink", function (linkId, tableId, otherTableId, rowId, otherRowId) { | ||
_this.dtableStore.removeLink(linkId, tableId, otherTableId, rowId, otherRowId); | ||
}); | ||
_defineProperty(this, "getScripts", function () { | ||
var _ref = _this.dtableStore.value || { | ||
scripts: [] | ||
}, | ||
scripts = _ref.scripts; | ||
scripts: [] | ||
}, | ||
scripts = _ref.scripts; | ||
return scripts; | ||
}); | ||
this.dtableStore = null; | ||
@@ -71,3 +48,2 @@ this.eventBus = null; | ||
} | ||
_createClass(DTable, [{ | ||
@@ -78,3 +54,2 @@ key: "init", | ||
var res, _res$data, app_name, access_token, dtable_uuid, dtable_server, dtable_socket; | ||
return regeneratorRuntime.wrap(function _callee$(_context) { | ||
@@ -89,3 +64,2 @@ while (1) { | ||
return this.dtableWebAPI.getDTableAccessToken(); | ||
case 5: | ||
@@ -104,3 +78,2 @@ res = _context.sent; | ||
break; | ||
case 17: | ||
@@ -110,3 +83,2 @@ _context.prev = 17; | ||
console.log(_context.t0); | ||
case 20: | ||
@@ -119,7 +91,5 @@ case "end": | ||
})); | ||
function init(_x) { | ||
return _init.apply(this, arguments); | ||
} | ||
return init; | ||
@@ -146,11 +116,8 @@ }() | ||
return this.dtableStore.loadFromServer(); | ||
case 2: | ||
_context2.next = 4; | ||
return this.dtableStore.loadRelatedUsers(); | ||
case 4: | ||
this.dtableStore.syncWithServer(); | ||
this.updateDTableAccessToken(); | ||
case 6: | ||
@@ -163,7 +130,5 @@ case "end": | ||
})); | ||
function syncWithServer() { | ||
return _syncWithServer.apply(this, arguments); | ||
} | ||
return syncWithServer; | ||
@@ -175,3 +140,2 @@ }() | ||
var _this2 = this; | ||
setInterval( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() { | ||
@@ -186,11 +150,7 @@ var res; | ||
return _this2.dtableWebAPI.getDTableAccessToken(); | ||
case 3: | ||
res = _context3.sent; | ||
_this2.dtableStore.updateAccessToken(res.data.access_token); | ||
_context3.next = 10; | ||
break; | ||
case 7: | ||
@@ -200,3 +160,2 @@ _context3.prev = 7; | ||
console.log(_context3.t0); | ||
case 10: | ||
@@ -230,3 +189,2 @@ case "end": | ||
var _this3 = this; | ||
this.dtableWebAPI.getFileUploadLink().then(function (res) { | ||
@@ -247,3 +205,2 @@ var uploadLink = res.data.upload_link + '?ret-json=1'; | ||
}, formData.getHeaders()); | ||
_axios["default"].post(uploadLink, formData, { | ||
@@ -255,4 +212,4 @@ headers: headers | ||
var _this3$config = _this3.config, | ||
server = _this3$config.server, | ||
workspaceID = _this3$config.workspaceID; | ||
server = _this3$config.server, | ||
workspaceID = _this3$config.workspaceID; | ||
var url = server + '/workspace/' + workspaceID + parentPath + '/' + relativePath + '/' + encodeURIComponent(fileInfo.name); | ||
@@ -350,5 +307,3 @@ fileInfo.url = url; | ||
var selectedTable = tables[tableIndex]; | ||
var view = _dtableStore.Views.getViewByName(selectedTable.views, viewName); | ||
this.dtableStore.deleteView(tableIndex, view._id); | ||
@@ -364,5 +319,3 @@ } | ||
var selectedTable = tables[index]; | ||
var view = _dtableStore.Views.getViewByName(selectedTable.views, previousName); | ||
this.dtableStore.renameView(index, view._id, viewName); | ||
@@ -454,13 +407,9 @@ } | ||
}); | ||
if (tableIndex === -1) { | ||
return; | ||
} | ||
var updateColumn = this.getColumnByName(table, columnName); | ||
if (!updateColumn) { | ||
return; | ||
} | ||
this.dtableStore.setColumnData(tableIndex, updateColumn.key, columnData); | ||
@@ -474,7 +423,5 @@ } | ||
var view = null; | ||
if (viewName) { | ||
view = this.getViewByName(table, viewName); | ||
} | ||
return this.appendRow(table, rowData, view); | ||
@@ -486,4 +433,3 @@ } | ||
var _ref3 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}, | ||
collaborators = _ref3.collaborators; | ||
collaborators = _ref3.collaborators; | ||
var tables = this.getTables(); | ||
@@ -493,9 +439,6 @@ var tableIndex = tables.findIndex(function (t) { | ||
}); | ||
if (tableIndex === -1) { | ||
return; | ||
} | ||
var newRowData = _dtableStore.RowUtils.convertRowBack(rowData, table, collaborators); | ||
var rows = view ? this.getViewRows(view, table) : table.rows; | ||
@@ -523,9 +466,6 @@ var lastRow = rows.length === 0 ? null : rows[rows.length - 1]; | ||
}); | ||
if (tableIndex === -1) { | ||
return; | ||
} | ||
var newUpdated = _dtableStore.RowUtils.convertRowBack(updated, table); | ||
var oldData = {}; | ||
@@ -535,7 +475,5 @@ Object.keys(newUpdated).forEach(function (key) { | ||
}); | ||
if (JSON.stringify(oldData) === JSON.stringify(newUpdated)) { | ||
return; | ||
} | ||
this.dtableStore.modifyRow(tableIndex, row._id, newUpdated, null); | ||
@@ -547,9 +485,6 @@ } | ||
var _ref4 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}, | ||
convertLinkID = _ref4.convertLinkID; | ||
convertLinkID = _ref4.convertLinkID; | ||
var value = this.dtableStore.value; | ||
var tables = this.getTables(); | ||
var table = _dtableStore.TableUtils.getTableByName(tables, tableName); | ||
if (!table) { | ||
@@ -559,5 +494,3 @@ debug("table ".concat(tableName, " does not exist.")); | ||
} | ||
var view = _dtableStore.Views.getViewByName(table.views, viewName); | ||
if (!view) { | ||
@@ -567,14 +500,10 @@ debug("view ".concat(viewName, " does not exist.")); | ||
} | ||
var rows = this.getViewRows(view, table); | ||
var formulaColumns = convertLinkID ? _dtableStore.Views.getFormulaColumnsContainLinks(table) : _dtableStore.Views.getAllFormulaColumns(_dtableStore.Views.getColumns(view, table)); | ||
var formulaResults = {}; | ||
if (formulaColumns && formulaColumns.length > 0) { | ||
formulaResults = _dtableStore.Views.getTableFormulaResults(table, rows, value, formulaColumns); | ||
} | ||
rows.forEach(function (row) { | ||
var newRow = _dtableStore.RowUtils.convertRow(row, value, table, view, formulaResults, convertLinkID); | ||
callback(newRow); | ||
@@ -592,6 +521,6 @@ }); | ||
var _this$dtableStore$dta = this.dtableStore.dtableSettings, | ||
_this$dtableStore$dta2 = _this$dtableStore$dta.username, | ||
username = _this$dtableStore$dta2 === void 0 ? null : _this$dtableStore$dta2, | ||
_this$dtableStore$dta3 = _this$dtableStore$dta.userId, | ||
userId = _this$dtableStore$dta3 === void 0 ? null : _this$dtableStore$dta3; | ||
_this$dtableStore$dta2 = _this$dtableStore$dta.username, | ||
username = _this$dtableStore$dta2 === void 0 ? null : _this$dtableStore$dta2, | ||
_this$dtableStore$dta3 = _this$dtableStore$dta.userId, | ||
userId = _this$dtableStore$dta3 === void 0 ? null : _this$dtableStore$dta3; | ||
return _dtableStore.Views.getViewRows(view, table, this.dtableStore.value, username, userId); | ||
@@ -610,11 +539,9 @@ } | ||
var value = this.dtableStore.value; | ||
if (!_dtableStore.Views.isDefaultView(view, table.columns)) { | ||
// originRowData: {[column.key]: cell_value}, exclude columns: auto_number | ||
// row_data, which is converted from originRowData: {[column.name]: converted_cell_value} | ||
var originRowData = _dtableStore.Views.getRowDataUsedInFilters(view, table, row_id); | ||
row_data = _dtableStore.RowUtils.convertRow(originRowData, value, table, view); | ||
} | ||
return row_data; | ||
@@ -639,7 +566,5 @@ } | ||
}); | ||
if (tableIndex === -1) { | ||
return; | ||
} | ||
this.dtableStore.moveGroupRows(tableIndex, targetIds, movePosition, movedRows, upperRowIds, updated, oldRows, groupbyColumn); | ||
@@ -677,3 +602,2 @@ } | ||
var formulaColumns = _dtableStore.Views.getFormulaColumnsContainLinks(table); | ||
return _dtableStore.Views.getTableFormulaResults(table, rows, this.dtableStore.value, formulaColumns); | ||
@@ -685,6 +609,6 @@ } | ||
var _ref5 = _dtableStore.Views.getRowsColor(rows, view, table, this.dtableStore.value) || {}, | ||
colors = _ref5.colors; | ||
colors = _ref5.colors; | ||
return colors || {}; | ||
} | ||
/** | ||
@@ -694,3 +618,2 @@ * @deprecated | ||
*/ | ||
}, { | ||
@@ -701,2 +624,3 @@ key: "getCellType", | ||
} | ||
/** | ||
@@ -706,3 +630,2 @@ * @deprecated | ||
*/ | ||
}, { | ||
@@ -713,2 +636,3 @@ key: "getFormulaResultType", | ||
} | ||
/** | ||
@@ -718,3 +642,2 @@ * @deprecated | ||
*/ | ||
}, { | ||
@@ -725,2 +648,3 @@ key: "getColumnIconConfig", | ||
} | ||
/** | ||
@@ -730,3 +654,2 @@ * @deprecated | ||
*/ | ||
}, { | ||
@@ -737,2 +660,3 @@ key: "getOptionColors", | ||
} | ||
/** | ||
@@ -742,3 +666,2 @@ * @deprecated | ||
*/ | ||
}, { | ||
@@ -749,2 +672,3 @@ key: "getHighlightColors", | ||
} | ||
/** | ||
@@ -754,3 +678,2 @@ * @deprecated | ||
*/ | ||
}, { | ||
@@ -770,8 +693,8 @@ key: "getTablePermissionType", | ||
var _ref6$tables = _ref6.tables, | ||
tables = _ref6$tables === void 0 ? [] : _ref6$tables, | ||
_ref6$formulaRows = _ref6.formulaRows, | ||
formulaRows = _ref6$formulaRows === void 0 ? {} : _ref6$formulaRows, | ||
data = _ref6.data, | ||
_ref6$collaborators = _ref6.collaborators, | ||
collaborators = _ref6$collaborators === void 0 ? [] : _ref6$collaborators; | ||
tables = _ref6$tables === void 0 ? [] : _ref6$tables, | ||
_ref6$formulaRows = _ref6.formulaRows, | ||
formulaRows = _ref6$formulaRows === void 0 ? {} : _ref6$formulaRows, | ||
data = _ref6.data, | ||
_ref6$collaborators = _ref6.collaborators, | ||
collaborators = _ref6$collaborators === void 0 ? [] : _ref6$collaborators; | ||
return (0, _dtableStore.getCellValueDisplayString)(row, type, key, { | ||
@@ -788,9 +711,8 @@ tables: tables, | ||
var _ref7 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}, | ||
_ref7$formulaRows = _ref7.formulaRows, | ||
formulaRows = _ref7$formulaRows === void 0 ? {} : _ref7$formulaRows, | ||
_ref7$collaborators = _ref7.collaborators, | ||
collaborators = _ref7$collaborators === void 0 ? [] : _ref7$collaborators, | ||
_ref7$isArchiveView = _ref7.isArchiveView, | ||
isArchiveView = _ref7$isArchiveView === void 0 ? false : _ref7$isArchiveView; | ||
_ref7$formulaRows = _ref7.formulaRows, | ||
formulaRows = _ref7$formulaRows === void 0 ? {} : _ref7$formulaRows, | ||
_ref7$collaborators = _ref7.collaborators, | ||
collaborators = _ref7$collaborators === void 0 ? [] : _ref7$collaborators, | ||
_ref7$isArchiveView = _ref7.isArchiveView, | ||
isArchiveView = _ref7$isArchiveView === void 0 ? false : _ref7$isArchiveView; | ||
return (0, _dtableStore.getCellValueStringResult)(row, column, { | ||
@@ -806,5 +728,4 @@ formulaRows: formulaRows, | ||
var _ref8 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}, | ||
_ref8$tables = _ref8.tables, | ||
tables = _ref8$tables === void 0 ? [] : _ref8$tables; | ||
_ref8$tables = _ref8.tables, | ||
tables = _ref8$tables === void 0 ? [] : _ref8$tables; | ||
return (0, _dtableStore.getFormulaDisplayString)(cellValue, columnData, { | ||
@@ -870,3 +791,3 @@ tables: tables | ||
var columnData = _ref9.columnData, | ||
value = _ref9.value; | ||
value = _ref9.value; | ||
return (0, _dtableStore.sortFormula)(currCellVal, nextCellVal, sortType, { | ||
@@ -888,7 +809,5 @@ columnData: columnData, | ||
}]); | ||
return DTable; | ||
}(); | ||
var _default = DTable; | ||
exports["default"] = _default; |
@@ -121,12 +121,7 @@ "use strict"; | ||
}); | ||
var _dtable = _interopRequireDefault(require("./dtable")); | ||
var _dtableStore = require("dtable-store"); | ||
var _statUtils = _interopRequireDefault(require("./stat-utils")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
var _default = _dtable["default"]; | ||
exports["default"] = _default; |
@@ -7,13 +7,7 @@ "use strict"; | ||
exports["default"] = void 0; | ||
var _dtableStore = require("dtable-store"); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
var SUPPORT_SORT_COLUMNS = [_dtableStore.CellType.TEXT, _dtableStore.CellType.NUMBER, _dtableStore.CellType.DATE, _dtableStore.CellType.SINGLE_SELECT, _dtableStore.CellType.FORMULA, _dtableStore.CellType.LINK_FORMULA, _dtableStore.CellType.CTIME, _dtableStore.CellType.MTIME, _dtableStore.CellType.RATE]; | ||
var StatUtils = /*#__PURE__*/function () { | ||
@@ -23,3 +17,2 @@ function StatUtils() { | ||
} | ||
_createClass(StatUtils, null, [{ | ||
@@ -44,8 +37,8 @@ key: "getStatisticRows", | ||
var _ref$tables = _ref.tables, | ||
tables = _ref$tables === void 0 ? [] : _ref$tables, | ||
_ref$formulaRows = _ref.formulaRows, | ||
formulaRows = _ref$formulaRows === void 0 ? {} : _ref$formulaRows, | ||
data = _ref.data, | ||
_ref$collaborators = _ref.collaborators, | ||
collaborators = _ref$collaborators === void 0 ? [] : _ref$collaborators; | ||
tables = _ref$tables === void 0 ? [] : _ref$tables, | ||
_ref$formulaRows = _ref.formulaRows, | ||
formulaRows = _ref$formulaRows === void 0 ? {} : _ref$formulaRows, | ||
data = _ref.data, | ||
_ref$collaborators = _ref.collaborators, | ||
collaborators = _ref$collaborators === void 0 ? [] : _ref$collaborators; | ||
return (0, _dtableStore.getCellValueDisplayString)(row, type, key, { | ||
@@ -67,5 +60,4 @@ tables: tables, | ||
var type = column.type, | ||
key = column.key, | ||
data = column.data; | ||
key = column.key, | ||
data = column.data; | ||
switch (type) { | ||
@@ -76,3 +68,2 @@ case _dtableStore.CellType.TEXT: | ||
} | ||
case _dtableStore.CellType.NUMBER: | ||
@@ -83,3 +74,2 @@ { | ||
} | ||
var number = (0, _dtableStore.getPrecisionNumber)(cellValue, data); | ||
@@ -89,3 +79,2 @@ var valueNumber = parseFloat(number); | ||
} | ||
case _dtableStore.CellType.SINGLE_SELECT: | ||
@@ -96,10 +85,7 @@ { | ||
}) < 0; | ||
if (isInvalidValue) { | ||
return null; | ||
} | ||
return cellValue; | ||
} | ||
case _dtableStore.CellType.DATE: | ||
@@ -112,14 +98,10 @@ case _dtableStore.CellType.CTIME: | ||
} | ||
return _dtableStore.DateUtils.getDateByGranularity(cellValue, dateGranularity); | ||
} | ||
case _dtableStore.CellType.MULTIPLE_SELECT: | ||
{ | ||
var options = data && data.options; | ||
if (!Array.isArray(cellValue)) { | ||
return []; | ||
} | ||
return cellValue.filter(function (id) { | ||
@@ -131,3 +113,2 @@ return options.findIndex(function (o) { | ||
} | ||
case _dtableStore.CellType.COLLABORATOR: | ||
@@ -137,3 +118,2 @@ { | ||
} | ||
case _dtableStore.CellType.CREATOR: | ||
@@ -144,3 +124,2 @@ case _dtableStore.CellType.LAST_MODIFIER: | ||
} | ||
case _dtableStore.CellType.LINK_FORMULA: | ||
@@ -151,6 +130,4 @@ case _dtableStore.CellType.FORMULA: | ||
var formulaCellValue = formulaRow[key]; | ||
var _ref2 = data || {}, | ||
result_type = _ref2.result_type; | ||
result_type = _ref2.result_type; | ||
if (result_type === _dtableStore.FORMULA_RESULT_TYPE.ARRAY) { | ||
@@ -161,30 +138,22 @@ return (0, _dtableStore.getFormulaDisplayString)(formulaCellValue, data, { | ||
} | ||
if (result_type === _dtableStore.FORMULA_RESULT_TYPE.NUMBER) { | ||
return (0, _dtableStore.getPrecisionNumber)(formulaCellValue, data); | ||
} | ||
return formulaCellValue ? formulaCellValue + '' : null; | ||
} | ||
case _dtableStore.CellType.GEOLOCATION: | ||
{ | ||
var _ref3 = data || {}, | ||
geo_format = _ref3.geo_format; | ||
geo_format = _ref3.geo_format; | ||
if (geo_format === 'country_region' || geo_format === 'lng_lat' || !geoGranularity) { | ||
return (0, _dtableStore.getGeolocationDisplayString)(cellValue, data); | ||
} | ||
return cellValue ? cellValue[geoGranularity] : null; | ||
} | ||
case _dtableStore.CellType.LINK: | ||
{ | ||
var linkCellValue = formulaRow && formulaRow[key]; | ||
if (!Array.isArray(linkCellValue)) { | ||
return []; | ||
} | ||
return linkCellValue.map(function (linkVal) { | ||
@@ -194,3 +163,2 @@ return linkVal.display_value; | ||
} | ||
case _dtableStore.CellType.CHECKBOX: | ||
@@ -200,3 +168,2 @@ { | ||
} | ||
case _dtableStore.CellType.RATE: | ||
@@ -207,3 +174,2 @@ { | ||
} | ||
default: | ||
@@ -219,10 +185,8 @@ { | ||
var column_type = column.type, | ||
data = column.data; | ||
data = column.data; | ||
var sortType = 'up'; | ||
var option_id_index_map = {}; | ||
if (column_type === _dtableStore.CellType.SINGLE_SELECT) { | ||
var _ref4 = data || {}, | ||
options = _ref4.options; | ||
options = _ref4.options; | ||
Array.isArray(options) && options.forEach(function (option, index) { | ||
@@ -232,15 +196,11 @@ option_id_index_map[option.id] = index; | ||
} | ||
statistics.sort(function (currResult, nextResult) { | ||
var current = currResult[sort_key]; | ||
var next = nextResult[sort_key]; | ||
if (!current && current !== 0) { | ||
return -1; | ||
} | ||
if (!next && next !== 0) { | ||
return 1; | ||
} | ||
if (SUPPORT_SORT_COLUMNS.includes(column_type)) { | ||
@@ -253,10 +213,7 @@ switch (column_type) { | ||
} | ||
if (next) { | ||
next = next - 0; | ||
} | ||
return (0, _dtableStore.sortNumber)(current, next, sortType); | ||
} | ||
case _dtableStore.CellType.DATE: | ||
@@ -268,3 +225,2 @@ case _dtableStore.CellType.CTIME: | ||
} | ||
case _dtableStore.CellType.SINGLE_SELECT: | ||
@@ -278,3 +234,2 @@ case _dtableStore.CellType.MULTIPLE_SELECT: | ||
} | ||
case _dtableStore.CellType.FORMULA: | ||
@@ -284,4 +239,3 @@ case _dtableStore.CellType.LINK_FORMULA: | ||
var _ref5 = data || {}, | ||
result_type = _ref5.result_type; | ||
result_type = _ref5.result_type; | ||
if (result_type === _dtableStore.FORMULA_RESULT_TYPE.NUMBER) { | ||
@@ -291,13 +245,9 @@ if (current) { | ||
} | ||
if (next) { | ||
next = next - 0; | ||
} | ||
return (0, _dtableStore.sortNumber)(current, next, sortType); | ||
} | ||
return (0, _dtableStore.sortText)(result_type, current, next, sortType); | ||
} | ||
default: | ||
@@ -312,6 +262,4 @@ { | ||
}]); | ||
return StatUtils; | ||
}(); | ||
var getValidCollaborators = function getValidCollaborators(collaborators, emails) { | ||
@@ -321,3 +269,2 @@ if (!Array.isArray(emails)) { | ||
} | ||
return emails.filter(function (e) { | ||
@@ -329,4 +276,3 @@ return collaborators.findIndex(function (c) { | ||
}; | ||
var _default = StatUtils; | ||
exports["default"] = _default; |
@@ -7,9 +7,5 @@ "use strict"; | ||
exports["default"] = void 0; | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
var Utils = /*#__PURE__*/function () { | ||
@@ -19,3 +15,2 @@ function Utils() { | ||
} | ||
_createClass(Utils, [{ | ||
@@ -35,18 +30,12 @@ key: "formatDate", | ||
var widthMinutes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; | ||
if (!isNaN(Date.parse(new Date(date)))) { | ||
var newDate = new Date(date); | ||
if (newDate && newDate.getYear()) { | ||
var year = newDate.getFullYear(); | ||
if (String(year).length !== 4) { | ||
return 'Invaild date'; | ||
} | ||
; | ||
var month = newDate.getMonth() + 1; | ||
var _date = newDate.getDate(); | ||
var minute = newDate.getMinutes(); | ||
@@ -58,3 +47,2 @@ var hour = newDate.getHours(); | ||
minute = minute < 10 ? "0".concat(minute) : minute; | ||
if (!widthMinutes) { | ||
@@ -67,11 +55,8 @@ return "".concat(year, "-").concat(month, "-").concat(_date); | ||
} | ||
return 'Invalid date'; | ||
} | ||
}]); | ||
return Utils; | ||
}(); | ||
var _default = Utils; | ||
exports["default"] = _default; |
{ | ||
"name": "dtable-sdk", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"description": "dtable sdk", | ||
@@ -22,3 +22,3 @@ "main": "./dist/index.js", | ||
"axios": "1.4.0", | ||
"dtable-store": "4.2.11", | ||
"dtable-store": "4.2.19", | ||
"form-data": "^3.0.0" | ||
@@ -25,0 +25,0 @@ }, |
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
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
65123
+ Addeddtable-store@4.2.19(transitive)
+ Addeddtable-utils@4.2.6(transitive)
- Removeddtable-store@4.2.11(transitive)
- Removeddtable-utils@4.2.5(transitive)
Updateddtable-store@4.2.19