skapi-js 1.0.41 → 1.0.43
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/dist/skapi.js +1 -1
- package/dist/skapi.js.map +1 -1
- package/dist/skapi.module.js +1 -1
- package/dist/skapi.module.js.map +1 -1
- package/js/main/skapi.d.ts +5 -1
- package/js/main/skapi.js +2 -2
- package/js/methods/request.d.ts +5 -1
- package/js/methods/request.js +8 -3
- package/package.json +1 -1
package/js/main/skapi.d.ts
CHANGED
|
@@ -103,7 +103,11 @@ export default class Skapi {
|
|
|
103
103
|
url: string;
|
|
104
104
|
data?: any;
|
|
105
105
|
sync?: boolean;
|
|
106
|
-
}
|
|
106
|
+
}, Response = {
|
|
107
|
+
response: any;
|
|
108
|
+
statusCode: number;
|
|
109
|
+
url: string;
|
|
110
|
+
}>(params: Params | Params[]): Promise<Response | Response[]>;
|
|
107
111
|
getFormResponse(): Promise<any>;
|
|
108
112
|
getRecords(query: GetRecordQuery, fetchOptions?: FetchOptions): Promise<DatabaseResponse<RecordData>>;
|
|
109
113
|
getTables(query: {
|
package/js/main/skapi.js
CHANGED
|
@@ -23,7 +23,7 @@ export default class Skapi {
|
|
|
23
23
|
set user(value) {
|
|
24
24
|
}
|
|
25
25
|
constructor(service, owner, options, __etc) {
|
|
26
|
-
this.version = '1.0.
|
|
26
|
+
this.version = '1.0.43';
|
|
27
27
|
this.session = null;
|
|
28
28
|
this.connection = null;
|
|
29
29
|
this.host = 'skapi';
|
|
@@ -97,7 +97,7 @@ export default class Skapi {
|
|
|
97
97
|
}
|
|
98
98
|
this.service = service;
|
|
99
99
|
this.owner = owner;
|
|
100
|
-
let autoLogin =
|
|
100
|
+
let autoLogin = !!options.autoLogin;
|
|
101
101
|
this.target_cdn = __etc?.target_cdn || this.target_cdn;
|
|
102
102
|
this.hostDomain = __etc?.hostDomain || this.hostDomain;
|
|
103
103
|
const cdn_domain = `https://${this.target_cdn}.cloudfront.net`;
|
package/js/methods/request.d.ts
CHANGED
|
@@ -14,7 +14,11 @@ export declare function secureRequest<RequestParams = {
|
|
|
14
14
|
url: string;
|
|
15
15
|
data?: any;
|
|
16
16
|
sync?: boolean;
|
|
17
|
-
}
|
|
17
|
+
}, Response = {
|
|
18
|
+
response: any;
|
|
19
|
+
statusCode: number;
|
|
20
|
+
url: string;
|
|
21
|
+
}>(params: RequestParams | RequestParams[]): Promise<Response | Response[]>;
|
|
18
22
|
export declare function mock(data: Form<any | {
|
|
19
23
|
raise?: 'ERR_INVALID_REQUEST' | 'ERR_INVALID_PARAMETER' | 'SOMETHING_WENT_WRONG' | 'ERR_EXISTS' | 'ERR_NOT_EXISTS';
|
|
20
24
|
}>, options?: {
|
package/js/methods/request.js
CHANGED
|
@@ -396,7 +396,7 @@ async function _fetch(url, opt, progress) {
|
|
|
396
396
|
xhr.responseType = opt.responseType;
|
|
397
397
|
}
|
|
398
398
|
xhr.onload = () => {
|
|
399
|
-
if (xhr.status
|
|
399
|
+
if (xhr.status < 400) {
|
|
400
400
|
if (opts.responseType == 'json' || opts.responseType == 'blob') {
|
|
401
401
|
res(xhr.response);
|
|
402
402
|
}
|
|
@@ -432,7 +432,10 @@ async function _fetch(url, opt, progress) {
|
|
|
432
432
|
}
|
|
433
433
|
else if (typeof result === 'object' && result?.message) {
|
|
434
434
|
let code = (result?.code || (status ? status.toString() : null) || 'ERROR');
|
|
435
|
-
rej(new SkapiError(result
|
|
435
|
+
rej(new SkapiError(result.message.trim(), { code: code }));
|
|
436
|
+
}
|
|
437
|
+
else {
|
|
438
|
+
rej(result);
|
|
436
439
|
}
|
|
437
440
|
}
|
|
438
441
|
};
|
|
@@ -510,6 +513,7 @@ async function _get(url, params, option, progress, noParams) {
|
|
|
510
513
|
}
|
|
511
514
|
;
|
|
512
515
|
export async function secureRequest(params) {
|
|
516
|
+
await this.__connection;
|
|
513
517
|
let paramsStruct = {
|
|
514
518
|
url: (v) => {
|
|
515
519
|
return validator.Url(v);
|
|
@@ -525,10 +529,11 @@ export async function secureRequest(params) {
|
|
|
525
529
|
else {
|
|
526
530
|
params = validator.Params(params, paramsStruct);
|
|
527
531
|
}
|
|
528
|
-
return
|
|
532
|
+
return request.bind(this)('post-secure', params, { auth: true });
|
|
529
533
|
}
|
|
530
534
|
;
|
|
531
535
|
export async function mock(data, options) {
|
|
536
|
+
await this.__connection;
|
|
532
537
|
let { auth = true, method = 'POST', meta, bypassAwaitConnection = false, responseType, contentType } = options || {};
|
|
533
538
|
let { response, onerror, formData, progress } = options || {};
|
|
534
539
|
if (options) {
|