@@ -40,27 +40,22 @@
SyncApi.js
"use strict";
const request = require("sync-request");
-const _ = require("lodash");
-/**
- * @typedef {object} SyncApiOptions
- * @property cookies {object}
- */
+const Api = require("./Api");
/**
*
*/
-class SyncApi {
+class SyncApi extends Api {
/**
*
* @param baseUrl {string}
- * @param options {SyncApiOptions}
+ * @param options {ApiOptions}
*/
+ // eslint-disable-next-line no-useless-constructor
constructor(baseUrl, options) {
- this.baseUrl = baseUrl;
- this.cookies = _.get(options, ["cookies"], {});
- this.headers = _.get(options, ["headers"], {});
+ super(baseUrl, options);
}
/**
@@ -71,20 +66,18 @@ SyncApi.js
* @param [nonce] {string}
*/
doCall(method, url, json, nonce) {
+ const fullUrl = this.baseUrl + url;
+
const options = {
- headers: {
- "Cookie": _.map(this.cookies, (cookieObj, cookieName) => {
- return cookieName + "=" + cookieObj.value || "undefined";
- }).join("; "),
- ...this.headers
- },
+ headers: this._getRequestHeaders(),
json: json,
qs: {
nonce: nonce
}
};
- const response = request(method, this.baseUrl + url, options).getBody("utf-8");
+ const response = request(method, fullUrl, options).getBody("utf-8");
+
return JSON.parse(response);
}
diff --git a/docs/Table.html b/docs/Table.html
index f0f7361..81ee64a 100644
--- a/docs/Table.html
+++ b/docs/Table.html
@@ -22,7 +22,7 @@
- Classes Global
+ Classes Global
@@ -65,7 +65,7 @@
new TableSource:
@@ -235,7 +235,7 @@
Source:
@@ -352,7 +352,8 @@ Parameters:
- language in which raw values should be inserted (default: "first language of '/system/settings/langtags'")
+ language in which raw values should be inserted (default: "first language of
+ '/system/settings/langtags'")
@@ -391,7 +392,7 @@ Source:
@@ -508,7 +509,8 @@ Parameters:
- language from which values are taken as new values (default: first language of '/system/settings/langtags')
+ language from which values are taken as new values (default: first language of
+ '/system/settings/langtags')
@@ -547,7 +549,7 @@ createCol
Source:
@@ -698,7 +700,7 @@ createCo
Source:
@@ -845,7 +847,7 @@ createRowSource:
@@ -947,7 +949,7 @@ createR
Source:
@@ -1098,7 +1100,7 @@ createRows<
Source:
@@ -1272,7 +1274,7 @@ deleteCol
Source:
@@ -1404,7 +1406,7 @@ fetchSource:
@@ -1563,7 +1565,7 @@ findColumn<
Source:
@@ -1695,7 +1697,7 @@ getRowSource:
@@ -1853,7 +1855,7 @@ getRowsSource:
diff --git a/docs/TableBuilder.html b/docs/TableBuilder.html
index 7c78949..83c4a3b 100644
--- a/docs/TableBuilder.html
+++ b/docs/TableBuilder.html
@@ -22,7 +22,7 @@
- Classes Global
+ Classes Global
@@ -65,7 +65,7 @@
new Table
Source:
@@ -238,7 +238,7 @@ createSource:
@@ -336,7 +336,7 @@ displayNam
Source:
@@ -495,7 +495,7 @@ groupSource:
@@ -642,7 +642,7 @@ hiddenSource:
diff --git a/docs/Tables.html b/docs/Tables.html
index 45cb6fa..d5157e4 100644
--- a/docs/Tables.html
+++ b/docs/Tables.html
@@ -22,7 +22,7 @@
- Classes Global
+ Classes Global
@@ -65,7 +65,7 @@
new TablesSource:
@@ -163,7 +163,7 @@ fetchSource:
@@ -265,7 +265,7 @@ findSource:
diff --git a/docs/global.html b/docs/global.html
index fc59c5b..a492524 100644
--- a/docs/global.html
+++ b/docs/global.html
@@ -22,7 +22,7 @@
- Classes Global
+ Classes Global
@@ -115,7 +115,7 @@
Methods
-
grudStructorizer(baseUrl, options) → {Object}
+
grudStructorizer(baseUrl, options) → {GRUDStructorizer }
@@ -127,7 +127,7 @@
grudS
Source:
@@ -271,7 +271,7 @@ Returns:
-Object
+GRUDStructorizer
@@ -288,6 +288,127 @@ Type Definitions
+ApiOptions
+
+
+
+
+
+
+
+
+ Source:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Properties:
+
+
+
+
+
+
+
+ Name
+
+
+ Type
+
+
+
+
+
+ Description
+
+
+
+
+
+
+
+
+ cookies
+
+
+
+
+
+object
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Type:
+
+
+
+
+
+
+
+
+
Column
@@ -299,7 +420,7 @@
Column
Source:
@@ -466,7 +587,7 @@
ConstraintCardinality
Source:
@@ -535,7 +656,7 @@
ConstraintDeleteCascade
Source:
@@ -593,7 +714,7 @@
Type:
-
SyncApiOptions
+
GRUDStructorizer
@@ -604,7 +725,7 @@
SyncApiOptions
Source:
@@ -667,13 +788,151 @@
Properties:
- cookies
+ api
-object
+SyncApi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ asyncApi
+
+
+
+
+
+AsyncApi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Table
+
+
+
+
+
+Table
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Tables
+
+
+
+
+
+Tables
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ TableBuilder
+
+
+
+
+
+TableBuilder
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ColumnBuilder
+
+
+
+
+
+ColumnBuilder
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ConstraintBuilder
+
+
+
+
+
+ConstraintBuilder
diff --git a/docs/index.html b/docs/index.html
index ca417cf..8d6e7e3 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -22,7 +22,7 @@
- Classes Global
+ Classes Global
diff --git a/docs/index.js.html b/docs/index.js.html
index d6b2b00..f8ea555 100644
--- a/docs/index.js.html
+++ b/docs/index.js.html
@@ -22,7 +22,7 @@
- Classes Global
+ Classes Global
@@ -40,6 +40,8 @@
index.js
"use strict";
const _ = require("lodash");
+
+const AsyncApi = require("./AsyncApi");
const SyncApi = require("./SyncApi");
function argumentsToMultiLanguageObj(argsObj) {
@@ -81,20 +83,31 @@ index.js
return obj;
}
+/**
+ * @typedef {object} GRUDStructorizer
+ * @property api {SyncApi}
+ * @property asyncApi {AsyncApi}
+ * @property Table {Table}
+ * @property Tables {Tables}
+ * @property TableBuilder {TableBuilder}
+ * @property ColumnBuilder {ColumnBuilder}
+ * @property ConstraintBuilder {ConstraintBuilder}
+ */
+
/**
*
- * @param baseUrl {string}
- * @param options {object}
- * @returns {{api: SyncApi, Table: Table, Tables: Tables, TableBuilder: TableBuilder, ColumnBuilder: ColumnBuilder,
- * ConstraintBuilder: ConstraintBuilder}}
+ * @param baseUrl {string}
+ * @param options {object}
+ * @returns {GRUDStructorizer}
*/
function grudStructorizer(baseUrl, options) {
- const tableaux = new SyncApi(baseUrl, options);
+ const syncApi = new SyncApi(baseUrl, options);
+ const asyncApi = new AsyncApi(baseUrl, options);
const StaticHelpers = {
getLanguages: () => {
- return tableaux.doCall("GET", "/system/settings/langtags").value;
+ return syncApi.doCall("GET", "/system/settings/langtags").value;
},
checkKindForLanguageConversion: (kind) => {
@@ -130,7 +143,7 @@ index.js
* @returns {Tables}
*/
fetch() {
- Object.assign(this, tableaux.doCall("GET", "/tables"));
+ Object.assign(this, syncApi.doCall("GET", "/tables"));
return this;
}
@@ -186,7 +199,7 @@ index.js
* @returns {Table}
*/
fetch(includeRows = false) {
- Object.assign(this, tableaux.fetchTable(this.tableId, includeRows));
+ Object.assign(this, syncApi.fetchTable(this.tableId, includeRows));
return this;
}
@@ -283,7 +296,7 @@ index.js
});
});
- const newColumns = tableaux.createColumns(this.tableId, columnObjArray);
+ const newColumns = syncApi.createColumns(this.tableId, columnObjArray);
newColumns.forEach(function (newColumn) {
self.columns.push(newColumn);
@@ -303,7 +316,7 @@ index.js
throw new Error("No column with this name or ID found '" + nameOrId + "'");
}
- const response = tableaux.doCall("DELETE", "/tables/" + this.tableId + "/columns/" + column.id);
+ const response = syncApi.doCall("DELETE", "/tables/" + this.tableId + "/columns/" + column.id);
if (response) {
_.remove(this.columns, function (c) {
@@ -330,7 +343,7 @@ index.js
}
});
- const newColumn = tableaux.createColumn(this.tableId, columnBuilder.build());
+ const newColumn = syncApi.createColumn(this.tableId, columnBuilder.build());
this.columns.push(newColumn);
@@ -410,11 +423,11 @@ index.js
// generate IDs based on rowValues length
const columnIds = columns || _.range(1, firstRowValues.length + 1);
- return tableaux.createRows(this.tableId, columnIds, rows);
+ return syncApi.createRows(this.tableId, columnIds, rows);
}
changeColumn(columnId, changeObj) {
- return tableaux.doCall("POST", "/tables/" + this.tableId + "/columns/" + columnId, changeObj);
+ return syncApi.doCall("POST", "/tables/" + this.tableId + "/columns/" + columnId, changeObj);
}
getColumn(columnName) {
@@ -428,7 +441,8 @@ index.js
* Convenient method to change a single language column to multi language
*
* @param columnName {string}
- * @param pickLanguage language in which raw values should be inserted (default: "first language of '/system/settings/langtags'") {string}
+ * @param pickLanguage language in which raw values should be inserted (default: "first language of
+ * '/system/settings/langtags'") {string}
*/
convertColumnToMultilanguage(columnName, pickLanguage) {
this.fetch();
@@ -475,22 +489,23 @@ index.js
const newValue = mapValueIntoLanguage(value, pickLanguage || defaultLanguage);
- tableaux.doCall("PATCH", url, newValue);
+ syncApi.doCall("PATCH", url, newValue);
- tableaux.doCall("POST", `${url}/annotations`, {
+ syncApi.doCall("POST", `${url}/annotations`, {
langtags: languages,
type: "flag",
value: "needs_translation"
});
});
- tableaux.doCall("DELETE", "/tables/" + this.tableId + "/columns/" + column.id);
+ syncApi.doCall("DELETE", "/tables/" + this.tableId + "/columns/" + column.id);
};
/**
* Convenient method to change a multi language column to single language
* @param columnName {string}
- * @param pickLanguage language from which values are taken as new values (default: first language of '/system/settings/langtags') {string}
+ * @param pickLanguage language from which values are taken as new values (default: first language of
+ * '/system/settings/langtags') {string}
*/
convertColumnToSinglelanguage(columnName, pickLanguage) {
this.fetch();
@@ -527,19 +542,19 @@ index.js
return;
}
- tableaux.doCall("PATCH", url, { value: newValue });
+ syncApi.doCall("PATCH", url, { value: newValue });
if (_.includes(annotations, columnIndex)) {
// there schould be not more than one translation flag per cell
const langAnnotation = _.head(_.filter(annotations[columnIndex], { "value": "needs_translation" }));
if (langAnnotation) {
- tableaux.doCall("DELETE", `${url}/annotations/${langAnnotation.uuid}`);
+ syncApi.doCall("DELETE", `${url}/annotations/${langAnnotation.uuid}`);
}
}
});
- tableaux.doCall("DELETE", "/tables/" + this.tableId + "/columns/" + column.id);
+ syncApi.doCall("DELETE", "/tables/" + this.tableId + "/columns/" + column.id);
}
}
@@ -605,7 +620,7 @@ index.js
* @returns {Table}
*/
create() {
- const tableId = tableaux.createTable(this.name, this._hidden, this._displayName, this.type, this._groupId).id;
+ const tableId = syncApi.createTable(this.name, this._hidden, this._displayName, this.type, this._groupId).id;
return new Table(tableId, this.name);
}
@@ -993,7 +1008,8 @@ index.js
}
return {
- api: tableaux,
+ api: syncApi,
+ asyncApi: asyncApi,
Table: Table,
Tables: Tables,
diff --git a/lib/Api.js b/lib/Api.js
new file mode 100644
index 0000000..f2cc20c
--- /dev/null
+++ b/lib/Api.js
@@ -0,0 +1,51 @@
+"use strict";
+
+var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
+
+var _createClass = 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+var _ = require("lodash");
+
+/**
+ * @typedef {object} ApiOptions
+ * @property cookies {object}
+ */
+
+var Api = function () {
+
+ /**
+ *
+ * @param baseUrl {string}
+ * @param options {ApiOptions}
+ */
+ function Api(baseUrl, options) {
+ _classCallCheck(this, Api);
+
+ if (this.constructor === Api) {
+ throw new Error("Abstract class 'Api' cannot be instantiated!");
+ }
+
+ this.baseUrl = baseUrl;
+ this.cookies = _.get(options, ["cookies"], {});
+ this.headers = _.get(options, ["headers"], {});
+ }
+
+ _createClass(Api, [{
+ key: "_getRequestHeaders",
+ value: function _getRequestHeaders() {
+ return _extends({
+ "Cookie": _.map(this.cookies, function (_ref, name) {
+ var value = _ref.value;
+
+ return name + "=" + value || "undefined";
+ }).join("; ")
+ }, this.headers);
+ }
+ }]);
+
+ return Api;
+}();
+
+module.exports = Api;
\ No newline at end of file
diff --git a/lib/AsyncApi.js b/lib/AsyncApi.js
new file mode 100644
index 0000000..97d0b52
--- /dev/null
+++ b/lib/AsyncApi.js
@@ -0,0 +1,86 @@
+"use strict";
+
+var _createClass = 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+var fetch = require("node-fetch");
+
+var Api = require("./Api");
+
+/**
+ *
+ */
+
+var AsyncApi = function (_Api) {
+ _inherits(AsyncApi, _Api);
+
+ /**
+ *
+ * @param baseUrl {string}
+ * @param options {ApiOptions}
+ */
+ // eslint-disable-next-line no-useless-constructor
+ function AsyncApi(baseUrl, options) {
+ _classCallCheck(this, AsyncApi);
+
+ return _possibleConstructorReturn(this, (AsyncApi.__proto__ || Object.getPrototypeOf(AsyncApi)).call(this, baseUrl, options));
+ }
+
+ /**
+ *
+ * @param method {string}
+ * @param url {string}
+ * @param [json] {object}
+ * @param [nonce] {string}
+ */
+
+
+ _createClass(AsyncApi, [{
+ key: "doCall",
+ value: function () {
+ var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(method, url, json, nonce) {
+ var fullUrl, options, response;
+ return regeneratorRuntime.wrap(function _callee$(_context) {
+ while (1) {
+ switch (_context.prev = _context.next) {
+ case 0:
+ fullUrl = nonce ? this.baseUrl + url + "?" + new URLSearchParams({ nonce: nonce }) : this.baseUrl + url;
+ options = {
+ method: method,
+ headers: this._getRequestHeaders(),
+ body: json ? JSON.stringify(json) : undefined
+ };
+ _context.next = 4;
+ return fetch(fullUrl, options);
+
+ case 4:
+ response = _context.sent;
+ return _context.abrupt("return", response.json());
+
+ case 6:
+ case "end":
+ return _context.stop();
+ }
+ }
+ }, _callee, this);
+ }));
+
+ function doCall(_x, _x2, _x3, _x4) {
+ return _ref.apply(this, arguments);
+ }
+
+ return doCall;
+ }()
+ }]);
+
+ return AsyncApi;
+}(Api);
+
+module.exports = AsyncApi;
\ No newline at end of file
diff --git a/lib/SyncApi.js b/lib/SyncApi.js
index e893b23..656fef5 100644
--- a/lib/SyncApi.js
+++ b/lib/SyncApi.js
@@ -2,37 +2,35 @@
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
-var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
-
var _createClass = 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
var request = require("sync-request");
-var _ = require("lodash");
-/**
- * @typedef {object} SyncApiOptions
- * @property cookies {object}
- */
+var Api = require("./Api");
/**
*
*/
-var SyncApi = function () {
+var SyncApi = function (_Api) {
+ _inherits(SyncApi, _Api);
/**
*
* @param baseUrl {string}
- * @param options {SyncApiOptions}
+ * @param options {ApiOptions}
*/
+ // eslint-disable-next-line no-useless-constructor
function SyncApi(baseUrl, options) {
_classCallCheck(this, SyncApi);
- this.baseUrl = baseUrl;
- this.cookies = _.get(options, ["cookies"], {});
- this.headers = _.get(options, ["headers"], {});
+ return _possibleConstructorReturn(this, (SyncApi.__proto__ || Object.getPrototypeOf(SyncApi)).call(this, baseUrl, options));
}
/**
@@ -47,19 +45,18 @@ var SyncApi = function () {
_createClass(SyncApi, [{
key: "doCall",
value: function doCall(method, url, json, nonce) {
+ var fullUrl = this.baseUrl + url;
+
var options = {
- headers: _extends({
- "Cookie": _.map(this.cookies, function (cookieObj, cookieName) {
- return cookieName + "=" + cookieObj.value || "undefined";
- }).join("; ")
- }, this.headers),
+ headers: this._getRequestHeaders(),
json: json,
qs: {
nonce: nonce
}
};
- var response = request(method, this.baseUrl + url, options).getBody("utf-8");
+ var response = request(method, fullUrl, options).getBody("utf-8");
+
return JSON.parse(response);
}
@@ -219,6 +216,6 @@ var SyncApi = function () {
}]);
return SyncApi;
-}();
+}(Api);
module.exports = SyncApi;
\ No newline at end of file
diff --git a/lib/index.js b/lib/index.js
index a6c08a2..eaf1d0d 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -9,6 +9,8 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _ = require("lodash");
+
+var AsyncApi = require("./AsyncApi");
var SyncApi = require("./SyncApi");
function argumentsToMultiLanguageObj(argsObj) {
@@ -50,20 +52,31 @@ function argumentsToMultiLanguageObj(argsObj) {
return obj;
}
+/**
+ * @typedef {object} GRUDStructorizer
+ * @property api {SyncApi}
+ * @property asyncApi {AsyncApi}
+ * @property Table {Table}
+ * @property Tables {Tables}
+ * @property TableBuilder {TableBuilder}
+ * @property ColumnBuilder {ColumnBuilder}
+ * @property ConstraintBuilder {ConstraintBuilder}
+ */
+
/**
*
- * @param baseUrl {string}
- * @param options {object}
- * @returns {{api: SyncApi, Table: Table, Tables: Tables, TableBuilder: TableBuilder, ColumnBuilder: ColumnBuilder,
- * ConstraintBuilder: ConstraintBuilder}}
+ * @param baseUrl {string}
+ * @param options {object}
+ * @returns {GRUDStructorizer}
*/
function grudStructorizer(baseUrl, options) {
- var tableaux = new SyncApi(baseUrl, options);
+ var syncApi = new SyncApi(baseUrl, options);
+ var asyncApi = new AsyncApi(baseUrl, options);
var StaticHelpers = {
getLanguages: function getLanguages() {
- return tableaux.doCall("GET", "/system/settings/langtags").value;
+ return syncApi.doCall("GET", "/system/settings/langtags").value;
},
checkKindForLanguageConversion: function checkKindForLanguageConversion(kind) {
@@ -106,7 +119,7 @@ function grudStructorizer(baseUrl, options) {
_createClass(Tables, [{
key: "fetch",
value: function fetch() {
- Object.assign(this, tableaux.doCall("GET", "/tables"));
+ Object.assign(this, syncApi.doCall("GET", "/tables"));
return this;
}
@@ -178,7 +191,7 @@ function grudStructorizer(baseUrl, options) {
value: function fetch() {
var includeRows = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
- Object.assign(this, tableaux.fetchTable(this.tableId, includeRows));
+ Object.assign(this, syncApi.fetchTable(this.tableId, includeRows));
return this;
}
@@ -288,7 +301,7 @@ function grudStructorizer(baseUrl, options) {
});
});
- var newColumns = tableaux.createColumns(this.tableId, columnObjArray);
+ var newColumns = syncApi.createColumns(this.tableId, columnObjArray);
newColumns.forEach(function (newColumn) {
self.columns.push(newColumn);
@@ -311,7 +324,7 @@ function grudStructorizer(baseUrl, options) {
throw new Error("No column with this name or ID found '" + nameOrId + "'");
}
- var response = tableaux.doCall("DELETE", "/tables/" + this.tableId + "/columns/" + column.id);
+ var response = syncApi.doCall("DELETE", "/tables/" + this.tableId + "/columns/" + column.id);
if (response) {
_.remove(this.columns, function (c) {
@@ -341,7 +354,7 @@ function grudStructorizer(baseUrl, options) {
}
});
- var newColumn = tableaux.createColumn(this.tableId, columnBuilder.build());
+ var newColumn = syncApi.createColumn(this.tableId, columnBuilder.build());
this.columns.push(newColumn);
@@ -434,12 +447,12 @@ function grudStructorizer(baseUrl, options) {
// generate IDs based on rowValues length
var columnIds = columns || _.range(1, firstRowValues.length + 1);
- return tableaux.createRows(this.tableId, columnIds, rows);
+ return syncApi.createRows(this.tableId, columnIds, rows);
}
}, {
key: "changeColumn",
value: function changeColumn(columnId, changeObj) {
- return tableaux.doCall("POST", "/tables/" + this.tableId + "/columns/" + columnId, changeObj);
+ return syncApi.doCall("POST", "/tables/" + this.tableId + "/columns/" + columnId, changeObj);
}
}, {
key: "getColumn",
@@ -457,7 +470,8 @@ function grudStructorizer(baseUrl, options) {
* Convenient method to change a single language column to multi language
*
* @param columnName {string}
- * @param pickLanguage language in which raw values should be inserted (default: "first language of '/system/settings/langtags'") {string}
+ * @param pickLanguage language in which raw values should be inserted (default: "first language of
+ * '/system/settings/langtags'") {string}
*/
value: function convertColumnToMultilanguage(columnName, pickLanguage) {
var _this3 = this;
@@ -512,16 +526,16 @@ function grudStructorizer(baseUrl, options) {
var newValue = mapValueIntoLanguage(value, pickLanguage || defaultLanguage);
- tableaux.doCall("PATCH", url, newValue);
+ syncApi.doCall("PATCH", url, newValue);
- tableaux.doCall("POST", url + "/annotations", {
+ syncApi.doCall("POST", url + "/annotations", {
langtags: languages,
type: "flag",
value: "needs_translation"
});
});
- tableaux.doCall("DELETE", "/tables/" + this.tableId + "/columns/" + column.id);
+ syncApi.doCall("DELETE", "/tables/" + this.tableId + "/columns/" + column.id);
}
}, {
key: "convertColumnToSinglelanguage",
@@ -530,7 +544,8 @@ function grudStructorizer(baseUrl, options) {
/**
* Convenient method to change a multi language column to single language
* @param columnName {string}
- * @param pickLanguage language from which values are taken as new values (default: first language of '/system/settings/langtags') {string}
+ * @param pickLanguage language from which values are taken as new values (default: first language of
+ * '/system/settings/langtags') {string}
*/
value: function convertColumnToSinglelanguage(columnName, pickLanguage) {
var _this4 = this;
@@ -579,19 +594,19 @@ function grudStructorizer(baseUrl, options) {
return;
}
- tableaux.doCall("PATCH", url, { value: newValue });
+ syncApi.doCall("PATCH", url, { value: newValue });
if (_.includes(annotations, columnIndex)) {
// there schould be not more than one translation flag per cell
var langAnnotation = _.head(_.filter(annotations[columnIndex], { "value": "needs_translation" }));
if (langAnnotation) {
- tableaux.doCall("DELETE", url + "/annotations/" + langAnnotation.uuid);
+ syncApi.doCall("DELETE", url + "/annotations/" + langAnnotation.uuid);
}
}
});
- tableaux.doCall("DELETE", "/tables/" + this.tableId + "/columns/" + column.id);
+ syncApi.doCall("DELETE", "/tables/" + this.tableId + "/columns/" + column.id);
}
}]);
@@ -681,7 +696,7 @@ function grudStructorizer(baseUrl, options) {
}, {
key: "create",
value: function create() {
- var tableId = tableaux.createTable(this.name, this._hidden, this._displayName, this.type, this._groupId).id;
+ var tableId = syncApi.createTable(this.name, this._hidden, this._displayName, this.type, this._groupId).id;
return new Table(tableId, this.name);
}
@@ -1183,7 +1198,8 @@ function grudStructorizer(baseUrl, options) {
}();
return {
- api: tableaux,
+ api: syncApi,
+ asyncApi: asyncApi,
Table: Table,
Tables: Tables,
diff --git a/lib/types.d.ts b/lib/types.d.ts
index 47fb661..2f917bd 100644
--- a/lib/types.d.ts
+++ b/lib/types.d.ts
@@ -1,9 +1,18 @@
-declare type SyncApiOptions = {
+declare type ApiOptions = {
cookies: any;
};
+declare class Api {
+ constructor(baseUrl: string, options: ApiOptions);
+}
+
+declare class AsyncApi {
+ constructor(baseUrl: string, options: ApiOptions);
+ doCall(method: string, url: string, json?: any, nonce?: string): void;
+}
+
declare class SyncApi {
- constructor(baseUrl: string, options: SyncApiOptions);
+ constructor(baseUrl: string, options: ApiOptions);
doCall(method: string, url: string, json?: any, nonce?: string): void;
resetSchema(nonce: string): void;
fetchTable(tableId: number, includeRows?: boolean): void;
@@ -17,7 +26,17 @@ declare class SyncApi {
createRows(tableId: any, columnIds: any, rows: any): void;
}
-declare function grudStructorizer(baseUrl: string, options: any): any;
+declare type GRUDStructorizer = {
+ api: SyncApi;
+ asyncApi: AsyncApi;
+ Table: Table;
+ Tables: Tables;
+ TableBuilder: TableBuilder;
+ ColumnBuilder: ColumnBuilder;
+ ConstraintBuilder: ConstraintBuilder;
+};
+
+declare function grudStructorizer(baseUrl: string, options: any): GRUDStructorizer;
declare class Tables {
/**
@@ -80,12 +99,14 @@ declare class Table {
createRows(rows: any[][], columns: number[]): number[];
/**
* Convenient method to change a single language column to multi language
- * @param pickLanguage - language in which raw values should be inserted (default: "first language of '/system/settings/langtags'")
+ * @param pickLanguage - language in which raw values should be inserted (default: "first language of
+ * '/system/settings/langtags'")
*/
convertColumnToMultilanguage(columnName: string, pickLanguage: string): void;
/**
* Convenient method to change a multi language column to single language
- * @param pickLanguage - language from which values are taken as new values (default: first language of '/system/settings/langtags')
+ * @param pickLanguage - language from which values are taken as new values (default: first language of
+ * '/system/settings/langtags')
*/
convertColumnToSinglelanguage(columnName: string, pickLanguage: string): void;
}
diff --git a/package-lock.json b/package-lock.json
index 26e83d6..1b89dcc 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -10,6 +10,7 @@
"license": "Apache-2.0",
"dependencies": {
"lodash": "4.17.21",
+ "node-fetch": "^2.7.0",
"sync-request": "6.1.0"
},
"devDependencies": {
@@ -4548,6 +4549,25 @@
"integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=",
"dev": true
},
+ "node_modules/node-fetch": {
+ "version": "2.7.0",
+ "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz",
+ "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==",
+ "dependencies": {
+ "whatwg-url": "^5.0.0"
+ },
+ "engines": {
+ "node": "4.x || >=6.0.0"
+ },
+ "peerDependencies": {
+ "encoding": "^0.1.0"
+ },
+ "peerDependenciesMeta": {
+ "encoding": {
+ "optional": true
+ }
+ }
+ },
"node_modules/node-int64": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz",
@@ -5976,6 +5996,11 @@
"node": ">=0.8"
}
},
+ "node_modules/tr46": {
+ "version": "0.0.3",
+ "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
+ "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw=="
+ },
"node_modules/trim-right": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/trim-right/-/trim-right-1.0.1.tgz",
@@ -6238,6 +6263,20 @@
"iconv-lite": "0.4.19"
}
},
+ "node_modules/whatwg-url": {
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
+ "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==",
+ "dependencies": {
+ "tr46": "~0.0.3",
+ "webidl-conversions": "^3.0.0"
+ }
+ },
+ "node_modules/whatwg-url/node_modules/webidl-conversions": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
+ "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ=="
+ },
"node_modules/which": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz",
@@ -10326,6 +10365,14 @@
"integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=",
"dev": true
},
+ "node-fetch": {
+ "version": "2.7.0",
+ "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz",
+ "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==",
+ "requires": {
+ "whatwg-url": "^5.0.0"
+ }
+ },
"node-int64": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz",
@@ -11496,6 +11543,11 @@
"punycode": "^1.4.1"
}
},
+ "tr46": {
+ "version": "0.0.3",
+ "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
+ "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw=="
+ },
"trim-right": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/trim-right/-/trim-right-1.0.1.tgz",
@@ -11713,6 +11765,22 @@
"iconv-lite": "0.4.19"
}
},
+ "whatwg-url": {
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
+ "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==",
+ "requires": {
+ "tr46": "~0.0.3",
+ "webidl-conversions": "^3.0.0"
+ },
+ "dependencies": {
+ "webidl-conversions": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
+ "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ=="
+ }
+ }
+ },
"which": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz",
diff --git a/package.json b/package.json
index cf31703..fe61e6d 100644
--- a/package.json
+++ b/package.json
@@ -33,13 +33,13 @@
"homepage": "https://github.com/campudus/grud-structorizer",
"devDependencies": {
"babel-cli": "6.26.0",
+ "babel-core": "^6.26.3",
"babel-eslint": "8.2.1",
"babel-plugin-add-module-exports": "0.2.1",
+ "babel-plugin-inline-import": "^3.0.0",
"babel-preset-env": "^1.7.0",
- "babel-register": "^6.26.0",
"babel-preset-stage-0": "^6.24.1",
- "babel-plugin-inline-import": "^3.0.0",
- "babel-core": "^6.26.3",
+ "babel-register": "^6.26.0",
"babel-runtime": "^6.26.0",
"docdash": "0.4.0",
"eslint": "4.17.0",
@@ -53,6 +53,7 @@
},
"dependencies": {
"lodash": "4.17.21",
+ "node-fetch": "2.7.0",
"sync-request": "6.1.0"
}
}
diff --git a/src/Api.js b/src/Api.js
new file mode 100644
index 0000000..a83c4d7
--- /dev/null
+++ b/src/Api.js
@@ -0,0 +1,37 @@
+"use strict";
+
+const _ = require("lodash");
+
+/**
+ * @typedef {object} ApiOptions
+ * @property cookies {object}
+ */
+
+class Api {
+
+ /**
+ *
+ * @param baseUrl {string}
+ * @param options {ApiOptions}
+ */
+ constructor(baseUrl, options) {
+ if (this.constructor === Api) {
+ throw new Error("Abstract class 'Api' cannot be instantiated!");
+ }
+
+ this.baseUrl = baseUrl;
+ this.cookies = _.get(options, ["cookies"], {});
+ this.headers = _.get(options, ["headers"], {});
+ }
+
+ _getRequestHeaders() {
+ return {
+ "Cookie": _.map(this.cookies, ({value}, name) => {
+ return name + "=" + value || "undefined";
+ }).join("; "),
+ ...this.headers
+ };
+ }
+}
+
+module.exports = Api;
diff --git a/src/AsyncApi.js b/src/AsyncApi.js
new file mode 100644
index 0000000..d926d1b
--- /dev/null
+++ b/src/AsyncApi.js
@@ -0,0 +1,46 @@
+"use strict";
+
+const fetch = require("node-fetch");
+
+const Api = require("./Api");
+
+/**
+ *
+ */
+class AsyncApi extends Api {
+
+ /**
+ *
+ * @param baseUrl {string}
+ * @param options {ApiOptions}
+ */
+ // eslint-disable-next-line no-useless-constructor
+ constructor(baseUrl, options) {
+ super(baseUrl, options);
+ }
+
+ /**
+ *
+ * @param method {string}
+ * @param url {string}
+ * @param [json] {object}
+ * @param [nonce] {string}
+ */
+ async doCall(method, url, json, nonce) {
+ const fullUrl = nonce
+ ? this.baseUrl + url + "?" + new URLSearchParams({nonce})
+ : this.baseUrl + url;
+
+ const options = {
+ method: method,
+ headers: this._getRequestHeaders(),
+ body: json ? JSON.stringify(json) : undefined
+ };
+
+ const response = await fetch(fullUrl, options);
+
+ return response.json();
+ }
+}
+
+module.exports = AsyncApi;
diff --git a/src/SyncApi.js b/src/SyncApi.js
index 58e4bad..40ac96d 100644
--- a/src/SyncApi.js
+++ b/src/SyncApi.js
@@ -1,27 +1,22 @@
"use strict";
const request = require("sync-request");
-const _ = require("lodash");
-/**
- * @typedef {object} SyncApiOptions
- * @property cookies {object}
- */
+const Api = require("./Api");
/**
*
*/
-class SyncApi {
+class SyncApi extends Api {
/**
*
* @param baseUrl {string}
- * @param options {SyncApiOptions}
+ * @param options {ApiOptions}
*/
+ // eslint-disable-next-line no-useless-constructor
constructor(baseUrl, options) {
- this.baseUrl = baseUrl;
- this.cookies = _.get(options, ["cookies"], {});
- this.headers = _.get(options, ["headers"], {});
+ super(baseUrl, options);
}
/**
@@ -32,20 +27,18 @@ class SyncApi {
* @param [nonce] {string}
*/
doCall(method, url, json, nonce) {
+ const fullUrl = this.baseUrl + url;
+
const options = {
- headers: {
- "Cookie": _.map(this.cookies, (cookieObj, cookieName) => {
- return cookieName + "=" + cookieObj.value || "undefined";
- }).join("; "),
- ...this.headers
- },
+ headers: this._getRequestHeaders(),
json: json,
qs: {
nonce: nonce
}
};
- const response = request(method, this.baseUrl + url, options).getBody("utf-8");
+ const response = request(method, fullUrl, options).getBody("utf-8");
+
return JSON.parse(response);
}
diff --git a/src/index.js b/src/index.js
index 8733204..1a95ea3 100644
--- a/src/index.js
+++ b/src/index.js
@@ -1,6 +1,8 @@
"use strict";
const _ = require("lodash");
+
+const AsyncApi = require("./AsyncApi");
const SyncApi = require("./SyncApi");
function argumentsToMultiLanguageObj(argsObj) {
@@ -42,20 +44,31 @@ function argumentsToMultiLanguageObj(argsObj) {
return obj;
}
+/**
+ * @typedef {object} GRUDStructorizer
+ * @property api {SyncApi}
+ * @property asyncApi {AsyncApi}
+ * @property Table {Table}
+ * @property Tables {Tables}
+ * @property TableBuilder {TableBuilder}
+ * @property ColumnBuilder {ColumnBuilder}
+ * @property ConstraintBuilder {ConstraintBuilder}
+ */
+
/**
*
- * @param baseUrl {string}
- * @param options {object}
- * @returns {{api: SyncApi, Table: Table, Tables: Tables, TableBuilder: TableBuilder, ColumnBuilder: ColumnBuilder,
- * ConstraintBuilder: ConstraintBuilder}}
+ * @param baseUrl {string}
+ * @param options {object}
+ * @returns {GRUDStructorizer}
*/
function grudStructorizer(baseUrl, options) {
- const tableaux = new SyncApi(baseUrl, options);
+ const syncApi = new SyncApi(baseUrl, options);
+ const asyncApi = new AsyncApi(baseUrl, options);
const StaticHelpers = {
getLanguages: () => {
- return tableaux.doCall("GET", "/system/settings/langtags").value;
+ return syncApi.doCall("GET", "/system/settings/langtags").value;
},
checkKindForLanguageConversion: (kind) => {
@@ -91,7 +104,7 @@ function grudStructorizer(baseUrl, options) {
* @returns {Tables}
*/
fetch() {
- Object.assign(this, tableaux.doCall("GET", "/tables"));
+ Object.assign(this, syncApi.doCall("GET", "/tables"));
return this;
}
@@ -147,7 +160,7 @@ function grudStructorizer(baseUrl, options) {
* @returns {Table}
*/
fetch(includeRows = false) {
- Object.assign(this, tableaux.fetchTable(this.tableId, includeRows));
+ Object.assign(this, syncApi.fetchTable(this.tableId, includeRows));
return this;
}
@@ -244,7 +257,7 @@ function grudStructorizer(baseUrl, options) {
});
});
- const newColumns = tableaux.createColumns(this.tableId, columnObjArray);
+ const newColumns = syncApi.createColumns(this.tableId, columnObjArray);
newColumns.forEach(function (newColumn) {
self.columns.push(newColumn);
@@ -264,7 +277,7 @@ function grudStructorizer(baseUrl, options) {
throw new Error("No column with this name or ID found '" + nameOrId + "'");
}
- const response = tableaux.doCall("DELETE", "/tables/" + this.tableId + "/columns/" + column.id);
+ const response = syncApi.doCall("DELETE", "/tables/" + this.tableId + "/columns/" + column.id);
if (response) {
_.remove(this.columns, function (c) {
@@ -291,7 +304,7 @@ function grudStructorizer(baseUrl, options) {
}
});
- const newColumn = tableaux.createColumn(this.tableId, columnBuilder.build());
+ const newColumn = syncApi.createColumn(this.tableId, columnBuilder.build());
this.columns.push(newColumn);
@@ -371,11 +384,11 @@ function grudStructorizer(baseUrl, options) {
// generate IDs based on rowValues length
const columnIds = columns || _.range(1, firstRowValues.length + 1);
- return tableaux.createRows(this.tableId, columnIds, rows);
+ return syncApi.createRows(this.tableId, columnIds, rows);
}
changeColumn(columnId, changeObj) {
- return tableaux.doCall("POST", "/tables/" + this.tableId + "/columns/" + columnId, changeObj);
+ return syncApi.doCall("POST", "/tables/" + this.tableId + "/columns/" + columnId, changeObj);
}
getColumn(columnName) {
@@ -389,7 +402,8 @@ function grudStructorizer(baseUrl, options) {
* Convenient method to change a single language column to multi language
*
* @param columnName {string}
- * @param pickLanguage language in which raw values should be inserted (default: "first language of '/system/settings/langtags'") {string}
+ * @param pickLanguage language in which raw values should be inserted (default: "first language of
+ * '/system/settings/langtags'") {string}
*/
convertColumnToMultilanguage(columnName, pickLanguage) {
this.fetch();
@@ -436,22 +450,23 @@ function grudStructorizer(baseUrl, options) {
const newValue = mapValueIntoLanguage(value, pickLanguage || defaultLanguage);
- tableaux.doCall("PATCH", url, newValue);
+ syncApi.doCall("PATCH", url, newValue);
- tableaux.doCall("POST", `${url}/annotations`, {
+ syncApi.doCall("POST", `${url}/annotations`, {
langtags: languages,
type: "flag",
value: "needs_translation"
});
});
- tableaux.doCall("DELETE", "/tables/" + this.tableId + "/columns/" + column.id);
+ syncApi.doCall("DELETE", "/tables/" + this.tableId + "/columns/" + column.id);
};
/**
* Convenient method to change a multi language column to single language
* @param columnName {string}
- * @param pickLanguage language from which values are taken as new values (default: first language of '/system/settings/langtags') {string}
+ * @param pickLanguage language from which values are taken as new values (default: first language of
+ * '/system/settings/langtags') {string}
*/
convertColumnToSinglelanguage(columnName, pickLanguage) {
this.fetch();
@@ -488,19 +503,19 @@ function grudStructorizer(baseUrl, options) {
return;
}
- tableaux.doCall("PATCH", url, { value: newValue });
+ syncApi.doCall("PATCH", url, { value: newValue });
if (_.includes(annotations, columnIndex)) {
// there schould be not more than one translation flag per cell
const langAnnotation = _.head(_.filter(annotations[columnIndex], { "value": "needs_translation" }));
if (langAnnotation) {
- tableaux.doCall("DELETE", `${url}/annotations/${langAnnotation.uuid}`);
+ syncApi.doCall("DELETE", `${url}/annotations/${langAnnotation.uuid}`);
}
}
});
- tableaux.doCall("DELETE", "/tables/" + this.tableId + "/columns/" + column.id);
+ syncApi.doCall("DELETE", "/tables/" + this.tableId + "/columns/" + column.id);
}
}
@@ -566,7 +581,7 @@ function grudStructorizer(baseUrl, options) {
* @returns {Table}
*/
create() {
- const tableId = tableaux.createTable(this.name, this._hidden, this._displayName, this.type, this._groupId).id;
+ const tableId = syncApi.createTable(this.name, this._hidden, this._displayName, this.type, this._groupId).id;
return new Table(tableId, this.name);
}
@@ -954,7 +969,8 @@ function grudStructorizer(baseUrl, options) {
}
return {
- api: tableaux,
+ api: syncApi,
+ asyncApi: asyncApi,
Table: Table,
Tables: Tables,