@jd-data-limited/easy-fm 1.1.3-alpha2 → 1.1.3-alpha3

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 +8 -4
  2. package/index.ts +9 -4
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -22,8 +22,9 @@ import { fileURLToPath } from "url";
22
22
  import * as https from "https";
23
23
  // @ts-ignore
24
24
  const errs = JSON.parse(fs.readFileSync(path.join(path.dirname(fileURLToPath(import.meta.url)), 'fmErrors.json')).toString());
25
- export default class FileMakerConnection {
25
+ export default class FileMakerConnection extends EventEmitter {
26
26
  constructor(conn, rejectUnauthorized = true) {
27
+ super();
27
28
  this.hostname = conn.hostname;
28
29
  this.name = conn.database.database;
29
30
  this.databaseConDetails = conn;
@@ -180,6 +181,9 @@ export default class FileMakerConnection {
180
181
  script(name, parameter) {
181
182
  return { name, parameter };
182
183
  }
184
+ _tokenExpired() {
185
+ this.emit("token_expired");
186
+ }
183
187
  }
184
188
  class layout {
185
189
  constructor(database, name) {
@@ -201,7 +205,7 @@ class layout {
201
205
  fields[_field.name] = "";
202
206
  }
203
207
  resolve(new record(this, -1, 0, fields));
204
- });
208
+ }).catch(e => { reject(e); });
205
209
  });
206
210
  }
207
211
  getRecord(recordId) {
@@ -212,9 +216,9 @@ class layout {
212
216
  }
213
217
  runScript(script) {
214
218
  return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
215
- let url = `${this.endpoint}/script/${encodeURI(script.name)}`;
219
+ let url = `${this.endpoint}/script/${encodeURIComponent(script.name)}`;
216
220
  if (script.parameter)
217
- url += "?" + encodeURI(script.parameter);
221
+ url += "?" + encodeURIComponent(script.parameter);
218
222
  this.database.apiRequest(url, {
219
223
  port: 443,
220
224
  method: "GET"
package/index.ts CHANGED
@@ -88,7 +88,7 @@ interface recordObject {
88
88
  fieldData: any
89
89
  }
90
90
 
91
- export default class FileMakerConnection {
91
+ export default class FileMakerConnection extends EventEmitter {
92
92
  private _token: any;
93
93
  private hostname: string;
94
94
  public readonly rejectUnauthroized: boolean;
@@ -96,6 +96,7 @@ export default class FileMakerConnection {
96
96
  public name: string;
97
97
 
98
98
  constructor(conn: hostConnectionOptions, rejectUnauthorized = true) {
99
+ super()
99
100
  this.hostname = conn.hostname
100
101
  this.name = conn.database.database
101
102
  this.databaseConDetails = conn
@@ -253,6 +254,10 @@ export default class FileMakerConnection {
253
254
  script(name, parameter): Script {
254
255
  return ({name, parameter} as Script)
255
256
  }
257
+
258
+ _tokenExpired() {
259
+ this.emit("token_expired")
260
+ }
256
261
  }
257
262
 
258
263
  class layout {
@@ -282,7 +287,7 @@ class layout {
282
287
  fields[_field.name] = ""
283
288
  }
284
289
  resolve(new record(this, -1, 0, fields))
285
- })
290
+ }).catch(e => {reject(e)})
286
291
  })
287
292
  }
288
293
 
@@ -296,8 +301,8 @@ class layout {
296
301
 
297
302
  runScript(script): Promise<string | FMError | Error> {
298
303
  return new Promise(async (resolve, reject) => {
299
- let url = `${this.endpoint}/script/${encodeURI(script.name)}`
300
- if (script.parameter) url += "?" + encodeURI(script.parameter)
304
+ let url = `${this.endpoint}/script/${encodeURIComponent(script.name)}`
305
+ if (script.parameter) url += "?" + encodeURIComponent(script.parameter)
301
306
  this.database.apiRequest(url, {
302
307
  port: 443,
303
308
  method: "GET"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jd-data-limited/easy-fm",
3
- "version": "1.1.3alpha2",
3
+ "version": "1.1.3alpha3",
4
4
  "dependencies": {
5
5
  "@types/btoa": "^1.2.3",
6
6
  "@types/events": "^3.0.0",