@jd-data-limited/easy-fm 3.0.0 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jd-data-limited/easy-fm",
3
- "version": "3.0.0",
3
+ "version": "3.0.2",
4
4
  "dependencies": {
5
5
  "@types/btoa": "^1.2.3",
6
6
  "@types/events": "^3.0.0",
package/src/index.js CHANGED
@@ -1220,7 +1220,7 @@ export class Database extends EventEmitter {
1220
1220
  });
1221
1221
  });
1222
1222
  }
1223
- script(name, parameter) {
1223
+ script(name, parameter = "") {
1224
1224
  return { name, parameter };
1225
1225
  }
1226
1226
  _tokenExpired() {
@@ -1384,6 +1384,7 @@ export class RecordBase extends EventEmitter {
1384
1384
  return !!this.fields.find(i => i.edited);
1385
1385
  }
1386
1386
  processPortalData(portalData) {
1387
+ this.portals = [];
1387
1388
  for (let item of Object.keys(portalData)) {
1388
1389
  let _portal = new Portal(this, item);
1389
1390
  _portal.records = portalData[item].map(item => {
@@ -1457,21 +1458,32 @@ export class RecordBase extends EventEmitter {
1457
1458
  });
1458
1459
  }));
1459
1460
  }
1460
- commit(extraBody = {
1461
- fieldData: undefined
1462
- }) {
1461
+ commit(extraBody) {
1463
1462
  return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
1464
1463
  let data = this.toObject();
1465
1464
  delete data.recordId;
1466
1465
  delete data.modId;
1466
+ if (extraBody.scripts.after) {
1467
+ data["script"] = extraBody.scripts.after.name;
1468
+ if (extraBody.scripts.after.parameter)
1469
+ data["param"] = extraBody.scripts.after.parameter;
1470
+ }
1471
+ if (extraBody.scripts.prerequest) {
1472
+ data["script"] = extraBody.scripts.after.name;
1473
+ if (extraBody.scripts.prerequest.parameter)
1474
+ data["param"] = extraBody.scripts.prerequest.parameter;
1475
+ }
1476
+ if (extraBody.scripts.presort) {
1477
+ data["script"] = extraBody.scripts.presort.name;
1478
+ if (extraBody.scripts.presort.parameter)
1479
+ data["param"] = extraBody.scripts.presort.parameter;
1480
+ }
1467
1481
  if (this.recordId === -1) {
1468
1482
  // This is a new LayoutRecord
1469
- for (let item of Object.keys(data))
1470
- extraBody[item] = data[item];
1471
1483
  this.layout.database.apiRequest(`${this.layout.endpoint}/records`, {
1472
1484
  port: 443,
1473
1485
  method: "POST",
1474
- body: JSON.stringify(extraBody)
1486
+ body: JSON.stringify(data)
1475
1487
  })
1476
1488
  .then(res => {
1477
1489
  if (typeof res.response.scriptError !== "undefined" && res.response.scriptError !== '0') {
@@ -1491,13 +1503,11 @@ export class RecordBase extends EventEmitter {
1491
1503
  });
1492
1504
  return;
1493
1505
  }
1494
- for (let item of Object.keys(data))
1495
- extraBody[item] = data[item];
1496
- console.log(extraBody.portalData);
1506
+ // for (let item of Object.keys(data)) extraBody[item] = data[item]
1497
1507
  this.layout.database.apiRequest(this.endpoint, {
1498
1508
  port: 443,
1499
1509
  method: "PATCH",
1500
- body: JSON.stringify(extraBody)
1510
+ body: JSON.stringify(data)
1501
1511
  })
1502
1512
  .then(res => {
1503
1513
  if (typeof res.response.scriptError !== "undefined" && res.response.scriptError !== '0') {
@@ -1785,7 +1795,7 @@ export class PortalRecord extends RecordBase {
1785
1795
  super._onSave();
1786
1796
  this.portal.record._onSave();
1787
1797
  }
1788
- commit(extraBody = { fieldData: undefined }) {
1798
+ commit(extraBody) {
1789
1799
  return this.portal.record.commit(extraBody);
1790
1800
  }
1791
1801
  toObject(fieldFilter) {
@@ -1868,18 +1878,18 @@ export class RecordGetRange extends RecordGetOperation {
1868
1878
  if (extraBody.scripts) {
1869
1879
  if (extraBody.scripts.prerequest) {
1870
1880
  params.push("script.prerequest=" + extraBody.scripts.prerequest.name);
1871
- if (extraBody.scripts.prerequest.param)
1872
- params.push("script.prerequest.param=" + extraBody.scripts.prerequest.param);
1881
+ if (extraBody.scripts.prerequest.parameter)
1882
+ params.push("script.prerequest.param=" + extraBody.scripts.prerequest.parameter);
1873
1883
  }
1874
1884
  if (extraBody.scripts.presort) {
1875
1885
  params.push("script.presort=" + extraBody.scripts.presort.name);
1876
- if (extraBody.scripts.presort.param)
1877
- params.push("script.presort.param=" + extraBody.scripts.presort.param);
1886
+ if (extraBody.scripts.presort.parameter)
1887
+ params.push("script.presort.param=" + extraBody.scripts.presort.parameter);
1878
1888
  }
1879
1889
  if (extraBody.scripts.after) {
1880
1890
  params.push("script=" + extraBody.scripts.after.name);
1881
- if (extraBody.scripts.after.param)
1882
- params.push("script.param=" + extraBody.scripts.after.param);
1891
+ if (extraBody.scripts.after.parameter)
1892
+ params.push("script.param=" + extraBody.scripts.after.parameter);
1883
1893
  }
1884
1894
  }
1885
1895
  if (params.length === 0)
package/src/index.ts CHANGED
@@ -1554,6 +1554,7 @@ export class RecordBase extends EventEmitter {
1554
1554
  }
1555
1555
 
1556
1556
  protected processPortalData(portalData): void {
1557
+ this.portals = []
1557
1558
  for (let item of Object.keys(portalData)) {
1558
1559
  let _portal = new Portal(this, item)
1559
1560
  _portal.records = portalData[item].map(item => {
@@ -1678,7 +1679,6 @@ export class RecordBase extends EventEmitter {
1678
1679
  }
1679
1680
 
1680
1681
  // for (let item of Object.keys(data)) extraBody[item] = data[item]
1681
- console.log((extraBody as any).portalData)
1682
1682
  this.layout.database.apiRequest(this.endpoint, {
1683
1683
  port: 443,
1684
1684
  method: "PATCH",