@jd-data-limited/easy-fm 0.0.10 → 0.0.11

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 -3
  2. package/index.ts +6 -3
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -233,6 +233,9 @@ class record extends EventEmitter {
233
233
  });
234
234
  }
235
235
  get() {
236
+ if (this.recordId === -1) {
237
+ throw "Cannot get this record until a commit() is done.";
238
+ }
236
239
  return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
237
240
  if (!this.layout.metadata)
238
241
  yield this.layout.getLayoutMeta();
@@ -275,8 +278,9 @@ class record extends EventEmitter {
275
278
  })
276
279
  .then(res => {
277
280
  if (res.messages[0].code === "0") {
278
- this.recordId = res.response.recordId;
279
- this.modId = res.response.modId;
281
+ this.recordId = parseInt(res.response.recordId);
282
+ console.log(this.recordId);
283
+ this.modId = parseInt(res.response.modId);
280
284
  resolve(this);
281
285
  }
282
286
  else {
@@ -489,7 +493,9 @@ class find {
489
493
  }
490
494
  export class FMError extends Error {
491
495
  constructor(code, httpStatus, res) {
492
- super(errs.find(err => err.e === code) || "Unknown error");
496
+ if (typeof code === "string")
497
+ code = parseInt(code);
498
+ super(errs.find(err => err.e === code).d || "Unknown error");
493
499
  this.httpStatus = httpStatus;
494
500
  this.res = res;
495
501
  this.code = typeof code === "string" ? parseInt(code) : code;
package/index.ts CHANGED
@@ -281,6 +281,7 @@ class record extends EventEmitter {
281
281
  }
282
282
 
283
283
  get() {
284
+ if (this.recordId === -1) {throw "Cannot get this record until a commit() is done."}
284
285
  return new Promise(async (resolve, reject) => {
285
286
  if (!this.layout.metadata) await this.layout.getLayoutMeta()
286
287
 
@@ -323,8 +324,9 @@ class record extends EventEmitter {
323
324
  })
324
325
  .then(res => {
325
326
  if (res.messages[0].code === "0") {
326
- this.recordId = res.response.recordId
327
- this.modId = res.response.modId
327
+ this.recordId = parseInt(res.response.recordId)
328
+ console.log(this.recordId)
329
+ this.modId = parseInt(res.response.modId)
328
330
  resolve(this)
329
331
  } else {
330
332
  reject(new FMError(res.messages[0].code, res.status, res))
@@ -570,7 +572,8 @@ export class FMError extends Error {
570
572
  readonly message: string
571
573
 
572
574
  constructor(code, httpStatus, res) {
573
- super(errs.find(err => err.e === code) || "Unknown error");
575
+ if (typeof code === "string") code = parseInt(code)
576
+ super(errs.find(err => err.e === code).d || "Unknown error");
574
577
  this.httpStatus = httpStatus
575
578
  this.res = res
576
579
  this.code = typeof code === "string" ? parseInt(code) : code
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jd-data-limited/easy-fm",
3
- "version": "0.0.10",
3
+ "version": "0.0.11",
4
4
  "dependencies": {
5
5
  "@types/btoa": "^1.2.3",
6
6
  "@types/events": "^3.0.0",