esoftplay 0.0.112-z → 0.0.113

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.
@@ -1,4 +1,4 @@
1
- import { esp, LibCrypt, LibNet_status, LibObject, LibProgress, LibToastProperty, LibUtils, LogStateProperty } from 'esoftplay';
1
+ import { esp, LibCrypt, LibNet_status, LibObject, LibProgress, LibUtils, LogStateProperty } from 'esoftplay';
2
2
  import { reportApiError } from "esoftplay/error";
3
3
  import moment from "esoftplay/moment";
4
4
  import Constants from 'expo-constants';
@@ -24,7 +24,7 @@ export default class ecurl {
24
24
  cancel: "Tutup"
25
25
  }
26
26
 
27
- constructor(uri?: string, post?: any, onDone?: (res: any, msg: string) => void, onFailed?: (msg: string, timeout: boolean) => void, debug?: number) {
27
+ constructor(uri?: string, post?: any, onDone?: (res: any, msg: string) => void, onFailed?: (error: any, timeout: boolean) => void, debug?: number) {
28
28
  this.header = {}
29
29
  this.maxRetry = 2;
30
30
  this.setUri = this.setUri.bind(this);
@@ -49,7 +49,7 @@ export default class ecurl {
49
49
  if (uri && str.isOnline) {
50
50
  this.init(uri, post, onDone, onFailed, debug);
51
51
  } else if (!str.isOnline && onFailed) {
52
- onFailed(this.refineErrorMessage("Failed to access"), false);
52
+ onFailed({ msg: this.refineErrorMessage("Failed to access") }, false);
53
53
  }
54
54
  }
55
55
 
@@ -135,7 +135,7 @@ export default class ecurl {
135
135
 
136
136
  }
137
137
 
138
- protected onFailed(msg: string, timeout: boolean): void {
138
+ protected onFailed(error: any, timeout: boolean): void {
139
139
 
140
140
  }
141
141
 
@@ -143,9 +143,9 @@ export default class ecurl {
143
143
  return true
144
144
  }
145
145
 
146
- public secure(token_uri?: string): (apiKey?: string) => (uri: string, post?: any, onDone?: (res: any, msg: string) => void, onFailed?: (msg: string, timeout: boolean) => void, debug?: number) => void {
147
- return (apiKey?: string): (uri: string, post?: any, onDone?: (res: any, msg: string) => void, onFailed?: (msg: string, timeout: boolean) => void, debug?: number) => void => {
148
- return async (uri: string, post?: any, onDone?: (res: any, msg: string) => void, onFailed?: (msg: string, timeout: boolean) => void, debug?: number) => {
146
+ public secure(token_uri?: string): (apiKey?: string) => (uri: string, post?: any, onDone?: (res: any, msg: string) => void, onFailed?: (error: any, timeout: boolean) => void, debug?: number) => void {
147
+ return (apiKey?: string): (uri: string, post?: any, onDone?: (res: any, msg: string) => void, onFailed?: (error: any, timeout: boolean) => void, debug?: number) => void => {
148
+ return async (uri: string, post?: any, onDone?: (res: any, msg: string) => void, onFailed?: (error: any, timeout: boolean) => void, debug?: number) => {
149
149
  this.isSecure = true
150
150
  await this.setHeader();
151
151
  const _apiKey = apiKey || this.apiKey
@@ -192,12 +192,12 @@ export default class ecurl {
192
192
  }
193
193
  }
194
194
 
195
- public withHeader(header: any): (uri: string, post?: any, onDone?: (res: any, msg: string) => void, onFailed?: (msg: string, timeout: boolean) => void, debug?: number) => void {
195
+ public withHeader(header: any): (uri: string, post?: any, onDone?: (res: any, msg: string) => void, onFailed?: (error: any, timeout: boolean) => void, debug?: number) => void {
196
196
  this.header = { ...this.header, ...header }
197
- return (uri: string, post?: any, onDone?: (res: any, msg: string) => void, onFailed?: (msg: string, timeout: boolean) => void, debug?: number) => this.init(uri, post, onDone, onFailed, debug)
197
+ return (uri: string, post?: any, onDone?: (res: any, msg: string) => void, onFailed?: (error: any, timeout: boolean) => void, debug?: number) => this.init(uri, post, onDone, onFailed, debug)
198
198
  }
199
199
 
200
- public upload(uri: string, postKey: string, fileUri: string, mimeType: string, onDone?: (res: any, msg: string) => void, onFailed?: (msg: string, timeout: boolean) => void, debug?: number): void {
200
+ public upload(uri: string, postKey: string, fileUri: string, mimeType: string, onDone?: (res: any, msg: string) => void, onFailed?: (error: any, timeout: boolean) => void, debug?: number): void {
201
201
  postKey = postKey || "image";
202
202
  var uName = fileUri.substring(fileUri.lastIndexOf("/") + 1, fileUri.length);
203
203
  if (!uName.includes('.')) {
@@ -341,7 +341,7 @@ export default class ecurl {
341
341
  }
342
342
  }
343
343
 
344
- private async init(uri: string, post?: any, onDone?: (res: any, msg: string) => void, onFailed?: (msg: string, timeout: boolean) => void, debug?: number, upload?: boolean): Promise<void> {
344
+ private async init(uri: string, post?: any, onDone?: (res: any, msg: string) => void, onFailed?: (error: any, timeout: boolean) => void, debug?: number, upload?: boolean): Promise<void> {
345
345
  if (post) {
346
346
  if (upload) {
347
347
  let fd = new FormData();
@@ -481,7 +481,7 @@ export default class ecurl {
481
481
 
482
482
 
483
483
 
484
- protected onFetched(resText: string | Object, onDone?: (res: any, msg: string) => void, onFailed?: (msg: string, timeout: boolean) => void, debug?: number): void {
484
+ protected onFetched(resText: string | Object, onDone?: (res: any, msg: string) => void, onFailed?: (error: any, timeout: boolean) => void, debug?: number): void {
485
485
  var resJson = typeof resText == 'string' && ((resText.startsWith("{") && resText.endsWith("}")) || (resText.startsWith("[") && resText.endsWith("]"))) ? JSON.parse(resText) : resText
486
486
  if (typeof resJson == "object") {
487
487
  if (!resJson.status_code || this.onStatusCode(resJson.ok, resJson.status_code, resJson.message, resJson.result)) {
@@ -489,8 +489,8 @@ export default class ecurl {
489
489
  if (onDone) onDone(resJson.result, resJson.message)
490
490
  this.onDone(resJson.result, resJson.message)
491
491
  } else {
492
- if (onFailed) onFailed(this.refineErrorMessage(resJson.message), false)
493
- this.onFailed(this.refineErrorMessage(resJson.message), false)
492
+ if (onFailed) onFailed(resJson, false)
493
+ this.onFailed(resJson, false)
494
494
  }
495
495
  }
496
496
  } else {
@@ -29,7 +29,7 @@ export default class m {
29
29
  },
30
30
  (msg) => {
31
31
  LibProgress.hide()
32
- esp.log('Document Gagal di Upload', msg)
32
+ esp.log('Document Gagal di Upload', msg.msg)
33
33
  }
34
34
  )
35
35
  })
@@ -221,8 +221,8 @@ class m extends LibComponent<LibImageProps, LibImageState> {
221
221
  LibProgress.hide()
222
222
  }
223
223
  },
224
- (msg: string) => {
225
- console.log(msg, "NOOO")
224
+ (msg: any) => {
225
+ console.log(msg.msg, "NOOO")
226
226
  if (x.length - 1 == i)
227
227
  LibProgress.hide()
228
228
  }, 1)
@@ -259,9 +259,9 @@ class m extends LibComponent<LibImageProps, LibImageState> {
259
259
  r(res);
260
260
  LibProgress.hide()
261
261
  },
262
- (msg: string) => {
262
+ (msg: any) => {
263
263
  LibProgress.hide()
264
- r(msg);
264
+ r(msg.msg);
265
265
  }, 1)
266
266
  }, 1);
267
267
  }
@@ -134,12 +134,12 @@ export default class m extends LibComponent<LibInfiniteProps, LibInfiniteState>{
134
134
  },
135
135
  (msg) => {
136
136
  if (this.props.isDebug) {
137
- esp.log(msg)
137
+ esp.log(msg.msg)
138
138
  }
139
139
  this.page = page
140
140
  this.isStop = true
141
141
  this.setState({
142
- error: msg,
142
+ error: msg.msg,
143
143
  })
144
144
  }, this.props.isDebug
145
145
  )
@@ -74,7 +74,7 @@ export default class m extends LibComponent<LibRollProps, LibRollState>{
74
74
  })
75
75
  },
76
76
  (_msg) => {
77
- this.setState({ msg: _msg })
77
+ this.setState({ msg: _msg.msg })
78
78
  }
79
79
  )
80
80
  else
@@ -16,7 +16,7 @@ export default function m(initialWithLoading?: boolean, withProgressText?: strin
16
16
  }, (msg) => {
17
17
  LibProgress.hide()
18
18
  setLoading(false)
19
- setError(msg)
19
+ setError(msg.msg)
20
20
  }, debug)
21
21
  }
22
22
  return [curl, loading, error]
@@ -111,7 +111,7 @@ export default class eclass {
111
111
  AsyncStorage.setItem("token", String(token))
112
112
  resolve(res)
113
113
  }, (msg) => {
114
- resolve(msg)
114
+ resolve(msg.msg)
115
115
  })
116
116
  })
117
117
  }
@@ -90,7 +90,7 @@ export default class euserLogin extends LibComponent<UserLoginProps, UserLoginSt
90
90
  },
91
91
  (msg) => {
92
92
  // console.log("gagal => " + msg, email)
93
- this.onFailedLogin(msg)
93
+ this.onFailedLogin(msg.msg)
94
94
  this.setState({ isLoading: false, email: "" })
95
95
  }, 1
96
96
  )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esoftplay",
3
- "version": "0.0.112-z",
3
+ "version": "0.0.113",
4
4
  "description": "embedding data from esoftplay framework (web based) into mobile app",
5
5
  "main": "cache/index.js",
6
6
  "types": "../../index.d.ts",