@slavmak2486/bx24ts 1.2.15 → 1.2.16
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/BX24Dev.ts +2 -0
- package/BX24Hook.ts +18 -10
- package/BX24Server.ts +8 -4
- package/base/BX24.ts +2 -2
- package/dist/BX24Dev.js +3 -1
- package/dist/BX24Hook.js +13 -5
- package/dist/BX24Server.js +13 -8
- package/package.json +1 -1
- package/types/authBaseServe.ts +2 -2
package/BX24Dev.ts
CHANGED
package/BX24Hook.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { baseBX24 } from "./base/BX24";
|
|
2
|
-
import {
|
|
2
|
+
import { Logger } from "./types/authBaseServe";
|
|
3
3
|
import { getAuth } from "./types/getAuth";
|
|
4
4
|
|
|
5
5
|
export class Bx24Hook extends baseBX24{
|
|
6
6
|
declare url:string;
|
|
7
7
|
|
|
8
|
-
logger=
|
|
8
|
+
logger:Logger|null=null;
|
|
9
9
|
|
|
10
10
|
constructor(url:string){
|
|
11
11
|
super();
|
|
@@ -14,28 +14,36 @@ export class Bx24Hook extends baseBX24{
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
refreshAuth(cb?: ((params: any) => void) | undefined): void {
|
|
17
|
+
if (this.logger){
|
|
17
18
|
this.logger?.log('Dont use refresh auth for Bx24Hook');
|
|
18
|
-
|
|
19
|
+
}
|
|
20
|
+
if (cb) cb(this.getAuth());
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
refreshAuthAsync(): Promise<getAuth> {
|
|
22
24
|
return new Promise(reject=>{
|
|
25
|
+
if (this.logger){
|
|
23
26
|
this.logger?.log('Dont use refresh auth for Bx24Hook');
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
}
|
|
28
|
+
reject({
|
|
29
|
+
access_token:'',
|
|
30
|
+
domain:this.url,
|
|
31
|
+
expires_in:0,
|
|
32
|
+
member_id:'',
|
|
33
|
+
refresh_token:''
|
|
34
|
+
});
|
|
31
35
|
});
|
|
32
36
|
}
|
|
33
37
|
|
|
34
38
|
runCallback(e: MessageEvent<any>): void {
|
|
39
|
+
if (this.logger){
|
|
35
40
|
this.logger?.log('Dont use runCallback for Bx24Hook', e);
|
|
41
|
+
}
|
|
36
42
|
}
|
|
37
43
|
|
|
38
44
|
sendMessage(cmd: string, params: any, cb?: ((params: any) => void) | undefined): void {
|
|
45
|
+
if (this.logger){
|
|
39
46
|
this.logger?.log('Dont use sendMessage for Bx24Hook', [cmd, params, cb]);
|
|
47
|
+
}
|
|
40
48
|
}
|
|
41
49
|
}
|
package/BX24Server.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { baseBX24 } from "./base/BX24";
|
|
2
|
-
import { AuthBaseServe,
|
|
2
|
+
import { AuthBaseServe, Logger } from "./types/authBaseServe";
|
|
3
3
|
import {getAuth} from './types/getAuth';
|
|
4
4
|
import { CallResult } from "./callResult";
|
|
5
5
|
import { BitrixEvent } from "./types/bitrixEvent";
|
|
@@ -7,7 +7,7 @@ import { BitrixEvent } from "./types/bitrixEvent";
|
|
|
7
7
|
|
|
8
8
|
export class BX24Server extends baseBX24{
|
|
9
9
|
|
|
10
|
-
logger:
|
|
10
|
+
logger:Logger|null=null;
|
|
11
11
|
|
|
12
12
|
constructor(param: AuthBaseServe){
|
|
13
13
|
super();
|
|
@@ -142,7 +142,9 @@ export class BX24Server extends baseBX24{
|
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
runCallback(e:MessageEvent){
|
|
145
|
+
if (this.logger){
|
|
145
146
|
this.logger.debug('callBack not allowed in server!', e);
|
|
147
|
+
}
|
|
146
148
|
}
|
|
147
149
|
|
|
148
150
|
onRefresh(cb:(params:getAuth)=>void){
|
|
@@ -155,7 +157,7 @@ export class BX24Server extends baseBX24{
|
|
|
155
157
|
if (cb) cb(newAuth);
|
|
156
158
|
})
|
|
157
159
|
.catch(err=>{
|
|
158
|
-
|
|
160
|
+
if (cb) cb(err);
|
|
159
161
|
});
|
|
160
162
|
}
|
|
161
163
|
|
|
@@ -192,11 +194,13 @@ export class BX24Server extends baseBX24{
|
|
|
192
194
|
|
|
193
195
|
|
|
194
196
|
sendMessage(cmd: string, params: any, cb?: CallableFunction): void {
|
|
197
|
+
if (this.logger){
|
|
195
198
|
this.logger.log('sendMessage',{
|
|
196
199
|
cmd:cmd,
|
|
197
200
|
params:params,
|
|
198
201
|
cb:cb
|
|
199
202
|
});
|
|
200
|
-
|
|
203
|
+
}
|
|
204
|
+
if (cb) cb();
|
|
201
205
|
}
|
|
202
206
|
}
|
package/base/BX24.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { eventElement } from "../types/eventElement";
|
|
|
4
4
|
import axios, { AxiosError, AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
5
5
|
import { CallResult } from "../callResult";
|
|
6
6
|
import {cloneDeep, get as __get} from 'lodash'
|
|
7
|
-
import {
|
|
7
|
+
import { Logger } from "../types/authBaseServe";
|
|
8
8
|
import { getAuth } from "../types/getAuth";
|
|
9
9
|
|
|
10
10
|
// проблемы декларирования методов HTMLElement
|
|
@@ -54,7 +54,7 @@ export abstract class baseBX24{
|
|
|
54
54
|
|
|
55
55
|
arrEvents:eventElement[]=[];
|
|
56
56
|
|
|
57
|
-
logger:
|
|
57
|
+
logger:Logger|null=null;
|
|
58
58
|
|
|
59
59
|
isReadyVal=false; //check
|
|
60
60
|
|
package/dist/BX24Dev.js
CHANGED
package/dist/BX24Hook.js
CHANGED
|
@@ -5,20 +5,24 @@ const BX24_1 = require("./base/BX24");
|
|
|
5
5
|
class Bx24Hook extends BX24_1.baseBX24 {
|
|
6
6
|
constructor(url) {
|
|
7
7
|
super();
|
|
8
|
-
this.logger =
|
|
8
|
+
this.logger = null;
|
|
9
9
|
this.AUTH_EXPIRES = new Date().getTime() + 365 * 24 * 60 * 60 * 1000;
|
|
10
10
|
this.url = url;
|
|
11
11
|
}
|
|
12
12
|
refreshAuth(cb) {
|
|
13
13
|
var _a;
|
|
14
|
-
(
|
|
14
|
+
if (this.logger) {
|
|
15
|
+
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.log('Dont use refresh auth for Bx24Hook');
|
|
16
|
+
}
|
|
15
17
|
if (cb)
|
|
16
18
|
cb(this.getAuth());
|
|
17
19
|
}
|
|
18
20
|
refreshAuthAsync() {
|
|
19
21
|
return new Promise(reject => {
|
|
20
22
|
var _a;
|
|
21
|
-
(
|
|
23
|
+
if (this.logger) {
|
|
24
|
+
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.log('Dont use refresh auth for Bx24Hook');
|
|
25
|
+
}
|
|
22
26
|
reject({
|
|
23
27
|
access_token: '',
|
|
24
28
|
domain: this.url,
|
|
@@ -30,11 +34,15 @@ class Bx24Hook extends BX24_1.baseBX24 {
|
|
|
30
34
|
}
|
|
31
35
|
runCallback(e) {
|
|
32
36
|
var _a;
|
|
33
|
-
(
|
|
37
|
+
if (this.logger) {
|
|
38
|
+
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.log('Dont use runCallback for Bx24Hook', e);
|
|
39
|
+
}
|
|
34
40
|
}
|
|
35
41
|
sendMessage(cmd, params, cb) {
|
|
36
42
|
var _a;
|
|
37
|
-
(
|
|
43
|
+
if (this.logger) {
|
|
44
|
+
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.log('Dont use sendMessage for Bx24Hook', [cmd, params, cb]);
|
|
45
|
+
}
|
|
38
46
|
}
|
|
39
47
|
}
|
|
40
48
|
exports.Bx24Hook = Bx24Hook;
|
package/dist/BX24Server.js
CHANGED
|
@@ -7,7 +7,7 @@ class BX24Server extends BX24_1.baseBX24 {
|
|
|
7
7
|
constructor(param) {
|
|
8
8
|
var _a;
|
|
9
9
|
super();
|
|
10
|
-
this.logger =
|
|
10
|
+
this.logger = null;
|
|
11
11
|
if (param.auth_connector)
|
|
12
12
|
this.AUTH_CONNECTOR = param.auth_connector;
|
|
13
13
|
if (param.logger)
|
|
@@ -107,7 +107,9 @@ class BX24Server extends BX24_1.baseBX24 {
|
|
|
107
107
|
return result;
|
|
108
108
|
}
|
|
109
109
|
runCallback(e) {
|
|
110
|
-
this.logger
|
|
110
|
+
if (this.logger) {
|
|
111
|
+
this.logger.debug('callBack not allowed in server!', e);
|
|
112
|
+
}
|
|
111
113
|
}
|
|
112
114
|
onRefresh(cb) {
|
|
113
115
|
this.addEvent('refreshAuth', cb);
|
|
@@ -119,7 +121,8 @@ class BX24Server extends BX24_1.baseBX24 {
|
|
|
119
121
|
cb(newAuth);
|
|
120
122
|
})
|
|
121
123
|
.catch(err => {
|
|
122
|
-
|
|
124
|
+
if (cb)
|
|
125
|
+
cb(err);
|
|
123
126
|
});
|
|
124
127
|
}
|
|
125
128
|
refreshAuthAsync() {
|
|
@@ -152,11 +155,13 @@ class BX24Server extends BX24_1.baseBX24 {
|
|
|
152
155
|
});
|
|
153
156
|
}
|
|
154
157
|
sendMessage(cmd, params, cb) {
|
|
155
|
-
this.logger
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
158
|
+
if (this.logger) {
|
|
159
|
+
this.logger.log('sendMessage', {
|
|
160
|
+
cmd: cmd,
|
|
161
|
+
params: params,
|
|
162
|
+
cb: cb
|
|
163
|
+
});
|
|
164
|
+
}
|
|
160
165
|
if (cb)
|
|
161
166
|
cb();
|
|
162
167
|
}
|
package/package.json
CHANGED
package/types/authBaseServe.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export interface
|
|
1
|
+
export interface Logger{
|
|
2
2
|
log(message: any, ...optionalParams: any[]): any;
|
|
3
3
|
error(message: any, ...optionalParams: any[]): any;
|
|
4
4
|
warn(message: any, ...optionalParams: any[]): any;
|
|
@@ -17,5 +17,5 @@ export interface AuthBaseServe{
|
|
|
17
17
|
app?:number;
|
|
18
18
|
isAdmin?:boolean;
|
|
19
19
|
auth_connector?:string;
|
|
20
|
-
logger?:
|
|
20
|
+
logger?:Logger
|
|
21
21
|
}
|