@jd-data-limited/easy-fm 0.0.4 → 0.0.6

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.
Files changed (3) hide show
  1. package/index.js +9 -2
  2. package/index.ts +3 -1
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -1,3 +1,6 @@
1
+ /*
2
+ * Copyright (c) 2022. See LICENSE file for more information
3
+ */
1
4
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
5
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
6
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -351,6 +354,8 @@ class field {
351
354
  this.edited = true;
352
355
  }
353
356
  get dataType() {
357
+ if (!this.record.layout.metadata)
358
+ return "unknown";
354
359
  if (this.record instanceof portalItem) {
355
360
  return this.record.layout.metadata.portalMetaData.find(name => name === this.id).result;
356
361
  }
@@ -462,10 +467,12 @@ class find {
462
467
  port: 443,
463
468
  method: "POST",
464
469
  body: JSON.stringify(this.toObject())
465
- }).then(res => {
470
+ }).then((res) => __awaiter(this, void 0, void 0, function* () {
466
471
  // // console.log(res)
467
472
  if (res.messages[0].code === "0") {
468
473
  // console.log("RESOLVING")
474
+ if (!this.layout.metadata)
475
+ yield this.layout.getLayoutMeta();
469
476
  let data = res.response.data.map(item => {
470
477
  return new record(this.layout, item.recordId, item.modId, item.fieldData, item.portalData);
471
478
  });
@@ -474,7 +481,7 @@ class find {
474
481
  else {
475
482
  reject(new FMError(res.messages[0].code, res.status, res));
476
483
  }
477
- })
484
+ }))
478
485
  .catch(e => {
479
486
  reject(e);
480
487
  });
package/index.ts CHANGED
@@ -415,6 +415,7 @@ class field {
415
415
  }
416
416
 
417
417
  get dataType() {
418
+ if (!this.record.layout.metadata) return "unknown"
418
419
  if (this.record instanceof portalItem) {
419
420
  return this.record.layout.metadata.portalMetaData.find(name => name === this.id).result
420
421
  } else {
@@ -543,10 +544,11 @@ class find {
543
544
  port: 443,
544
545
  method: "POST",
545
546
  body: JSON.stringify(this.toObject())
546
- }).then(res => {
547
+ }).then(async res => {
547
548
  // // console.log(res)
548
549
  if (res.messages[0].code === "0") {
549
550
  // console.log("RESOLVING")
551
+ if (!this.layout.metadata) await this.layout.getLayoutMeta()
550
552
  let data = res.response.data.map(item => {
551
553
  return new record(this.layout, item.recordId, item.modId, item.fieldData, item.portalData)
552
554
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jd-data-limited/easy-fm",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "dependencies": {
5
5
  "@types/btoa": "^1.2.3",
6
6
  "@types/events": "^3.0.0",