@slavmak2486/bx24ts 1.2.17 → 1.2.18

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/BX24.ts CHANGED
@@ -5,9 +5,9 @@ export class BX24 extends baseBX24{
5
5
  constructor(cb?:(params:any)=>void){
6
6
  super();
7
7
  const q = window.name.split('|');
8
- this.DOMAIN = q[0].replace(/:(80|443)$/, '');
9
- this.PROTOCOL = parseInt(q[1])||0;
10
- this.APP_SID = q[2];
8
+ this.DOMAIN = q[0]?.replace(/:(80|443)$/, '')||'';
9
+ this.PROTOCOL = parseInt(String(q[1]))||0;
10
+ this.APP_SID = q[2]||'';
11
11
  if (window&&window instanceof Window){
12
12
  window.addEventListener("message", (event:MessageEvent)=>{
13
13
  this.runCallback(event);
package/BX24Dev.ts CHANGED
@@ -53,8 +53,7 @@ export class BX24Dev extends BX24Server{
53
53
  }
54
54
  }
55
55
 
56
-
57
- appOption={
56
+ override appOption={
58
57
  get: (name:string)=>{
59
58
  return this.APP_OPTIONS[name];
60
59
  },
@@ -77,7 +76,7 @@ export class BX24Dev extends BX24Server{
77
76
  }
78
77
  }
79
78
 
80
- userOption={
79
+ override userOption={
81
80
  get:(name:string)=>{
82
81
  return this.USER_OPTIONS[name];
83
82
  },
@@ -106,15 +105,15 @@ export class BX24Dev extends BX24Server{
106
105
  done=el.done===true?true:false;
107
106
  if (el.value){
108
107
  let tempArrPath=Array.from(el.value[0].matchAll(regexp)) as string[];
109
- tempArrPath=tempArrPath.map(ell=>{return ell[1]});
108
+ tempArrPath=tempArrPath.map(ell=>{return ell[1]}).filter(el=>!!el) as string[];
110
109
  const base=el.value[0].split('[')[0];
111
110
  __set(result, [base, ...tempArrPath], el.value[1]);
112
111
  }
113
112
  }
114
113
 
115
- if (result.placement){
116
- this.PLACEMENT=result.placement;
117
- delete(result.placement);
114
+ if (result["placement"]){
115
+ this.PLACEMENT=result["placement"];
116
+ delete(result["placement"]);
118
117
  }
119
118
  else{
120
119
  this.PLACEMENT='DEFAULT';
package/BX24Hook.ts CHANGED
@@ -5,7 +5,7 @@ import { type getAuth } from "./types/getAuth";
5
5
  export class Bx24Hook extends baseBX24{
6
6
  declare url:string;
7
7
 
8
- logger:Logger|null=null;
8
+ override logger:Logger|null=null;
9
9
 
10
10
  constructor(url:string){
11
11
  super();
package/BX24Server.ts CHANGED
@@ -7,7 +7,7 @@ import { type BitrixEvent } from "./types/bitrixEvent";
7
7
 
8
8
  export class BX24Server extends baseBX24{
9
9
 
10
- logger:Logger|null=null;
10
+ override logger:Logger|null=null;
11
11
 
12
12
  constructor(param: AuthBaseServe){
13
13
  super();
@@ -62,13 +62,13 @@ export class BX24Server extends baseBX24{
62
62
  else{
63
63
  const props:Record<string, string|number>={};
64
64
  if (processId){
65
- props.process_id=processId;
65
+ props["process_id"]=processId;
66
66
  }
67
67
  if (clear){
68
- props.clear=1;
68
+ props["clear"]=1;
69
69
  }
70
70
  else{
71
- props.clear=0;
71
+ props["clear"]=0;
72
72
  }
73
73
  this.callMethod('event.offline.get', props, ress=>{
74
74
  if (ress.error()){
package/BatchHelper.ts CHANGED
@@ -66,6 +66,7 @@ export class BatchHelper{
66
66
 
67
67
  for(const dep of deps){
68
68
  alradyInBatch.push(dep);
69
+ if (!obj[dep]) continue;
69
70
  currentChunk[dep] = obj[dep];
70
71
  currentSize++;
71
72
  }
package/base/BX24.ts CHANGED
@@ -98,7 +98,8 @@ export abstract class baseBX24{
98
98
  const arrHandler=this.arrEvents.filter(el=>{return el.event==event});
99
99
  for (const idx in arrHandler){
100
100
  setTimeout(()=>{
101
- arrHandler[idx].handler.call(this, params);
101
+ if (!arrHandler[idx]?.handler) return;
102
+ arrHandler[idx].handler.call(this, params);
102
103
  }, 10);
103
104
  }
104
105
  }
@@ -322,8 +323,8 @@ export abstract class baseBX24{
322
323
 
323
324
  for(const idx in cmd){
324
325
  const row=cmd[idx];
325
- const method=Array.isArray(row)?row[0]:row.method;
326
- const params=Array.isArray(row)?row[1]:row.params;
326
+ const method=Array.isArray(row)?row[0]:row?.method;
327
+ const params=Array.isArray(row)?row[1]:row?.params;
327
328
 
328
329
  if(method)
329
330
  {
@@ -422,6 +423,8 @@ export abstract class baseBX24{
422
423
  const result:Partial<{[key in keyof R]:CallResult}>={};
423
424
  for(const idx in calls){
424
425
  const cmd=calls[idx];
426
+ const method=Array.isArray(cmd)?cmd[0]:cmd?.method;
427
+ if (!method) continue;
425
428
  if (data?.result?.[idx]!==undefined|| data?.result_error?.[idx]!==undefined){
426
429
  result[idx]=new CallResult({
427
430
  result: data.result?.[idx]||{},
@@ -430,7 +433,7 @@ export abstract class baseBX24{
430
433
  time:data.result_time[idx],
431
434
  next: data.result_next[idx]
432
435
  }, {
433
- method:Array.isArray(cmd)?cmd[0]:cmd?.method,
436
+ method,
434
437
  data: Array.isArray(cmd)?cmd[1]:cmd?.params,
435
438
  callback:callback
436
439
  }, this, res.status)
@@ -442,7 +445,7 @@ export abstract class baseBX24{
442
445
  error_description:()=>JSON.stringify(res),
443
446
  answer:data?.result?.[idx],
444
447
  query: {
445
- method:Array.isArray(cmd)?cmd[0]:cmd?.method,
448
+ method,
446
449
  data: Array.isArray(cmd)?cmd[1]:cmd?.params,
447
450
  callback:callback
448
451
  },
package/dist/BX24.js CHANGED
@@ -4,11 +4,12 @@ exports.BX24 = void 0;
4
4
  const BX24_1 = require("./base/BX24");
5
5
  class BX24 extends BX24_1.baseBX24 {
6
6
  constructor(cb) {
7
+ var _a;
7
8
  super();
8
9
  const q = window.name.split('|');
9
- this.DOMAIN = q[0].replace(/:(80|443)$/, '');
10
- this.PROTOCOL = parseInt(q[1]) || 0;
11
- this.APP_SID = q[2];
10
+ this.DOMAIN = ((_a = q[0]) === null || _a === void 0 ? void 0 : _a.replace(/:(80|443)$/, '')) || '';
11
+ this.PROTOCOL = parseInt(String(q[1])) || 0;
12
+ this.APP_SID = q[2] || '';
12
13
  if (window && window instanceof Window) {
13
14
  window.addEventListener("message", (event) => {
14
15
  this.runCallback(event);
package/dist/BX24Dev.js CHANGED
@@ -99,14 +99,14 @@ class BX24Dev extends BX24Server_1.BX24Server {
99
99
  done = el.done === true ? true : false;
100
100
  if (el.value) {
101
101
  let tempArrPath = Array.from(el.value[0].matchAll(regexp));
102
- tempArrPath = tempArrPath.map(ell => { return ell[1]; });
102
+ tempArrPath = tempArrPath.map(ell => { return ell[1]; }).filter(el => !!el);
103
103
  const base = el.value[0].split('[')[0];
104
104
  (0, lodash_1.set)(result, [base, ...tempArrPath], el.value[1]);
105
105
  }
106
106
  }
107
- if (result.placement) {
108
- this.PLACEMENT = result.placement;
109
- delete (result.placement);
107
+ if (result["placement"]) {
108
+ this.PLACEMENT = result["placement"];
109
+ delete (result["placement"]);
110
110
  }
111
111
  else {
112
112
  this.PLACEMENT = 'DEFAULT';
@@ -49,13 +49,13 @@ class BX24Server extends BX24_1.baseBX24 {
49
49
  else {
50
50
  const props = {};
51
51
  if (processId) {
52
- props.process_id = processId;
52
+ props["process_id"] = processId;
53
53
  }
54
54
  if (clear) {
55
- props.clear = 1;
55
+ props["clear"] = 1;
56
56
  }
57
57
  else {
58
- props.clear = 0;
58
+ props["clear"] = 0;
59
59
  }
60
60
  this.callMethod('event.offline.get', props, ress => {
61
61
  var _a, _b;
@@ -60,6 +60,8 @@ class BatchHelper {
60
60
  const deps = dependencies[key] || [];
61
61
  for (const dep of deps) {
62
62
  alradyInBatch.push(dep);
63
+ if (!obj[dep])
64
+ continue;
63
65
  currentChunk[dep] = obj[dep];
64
66
  currentSize++;
65
67
  }
package/dist/base/BX24.js CHANGED
@@ -8,6 +8,65 @@ const axios_1 = __importDefault(require("axios"));
8
8
  const callResult_1 = require("../callResult");
9
9
  const lodash_1 = require("lodash");
10
10
  class baseBX24 {
11
+ getHttpString(value, prefix = '') {
12
+ if (value instanceof Date) {
13
+ return prefix + '=' + encodeURIComponent(value.toISOString());
14
+ }
15
+ else if (typeof value == 'object') {
16
+ const resultObj = [];
17
+ for (const field in value) {
18
+ resultObj.push(this.getHttpString(value[field], prefix + `${prefix != '' ? '[' : ""}${field}${prefix != '' ? ']' : ''}`));
19
+ }
20
+ return resultObj.join('&');
21
+ }
22
+ else if (prefix != '') {
23
+ return encodeURIComponent(prefix) + '=' + encodeURIComponent(value);
24
+ }
25
+ return encodeURIComponent(value);
26
+ }
27
+ setTimeoutCall(ms) {
28
+ this.timeoutCall = ms;
29
+ }
30
+ clearTimeoutCall() {
31
+ this.timeoutCall = 0;
32
+ }
33
+ isFunction(item) {
34
+ return item === null ? false : (typeof (item) == "function" || item instanceof Function);
35
+ }
36
+ addEvent(event, handler) {
37
+ this.arrEvents.push({
38
+ event: event,
39
+ handler: handler
40
+ });
41
+ }
42
+ emitEvent(event, params) {
43
+ const arrHandler = this.arrEvents.filter(el => { return el.event == event; });
44
+ for (const idx in arrHandler) {
45
+ setTimeout(() => {
46
+ var _a;
47
+ if (!((_a = arrHandler[idx]) === null || _a === void 0 ? void 0 : _a.handler))
48
+ return;
49
+ arrHandler[idx].handler.call(this, params);
50
+ }, 10);
51
+ }
52
+ }
53
+ uniqid() {
54
+ const charsList = '0123456789abcdefghijklmnopqrstuvwxyz';
55
+ let s = '';
56
+ for (let i = 0; i < 32; i++)
57
+ s += charsList[Math.round(Math.random() * (charsList.length - 1))];
58
+ return s;
59
+ }
60
+ setCallback(cb) {
61
+ const cbId = this.uniqid();
62
+ if (cb) {
63
+ this.cbArray.push({ uid: cbId, cb: cb });
64
+ }
65
+ return cbId;
66
+ }
67
+ doInit() {
68
+ this.emitEvent('init', this);
69
+ }
11
70
  constructor() {
12
71
  this.cbArray = [];
13
72
  this.AUTH_CONNECTOR = "";
@@ -97,62 +156,6 @@ class baseBX24 {
97
156
  this.DOMAIN = "";
98
157
  this.PROTOCOL = 1;
99
158
  }
100
- getHttpString(value, prefix = '') {
101
- if (value instanceof Date) {
102
- return prefix + '=' + encodeURIComponent(value.toISOString());
103
- }
104
- else if (typeof value == 'object') {
105
- const resultObj = [];
106
- for (const field in value) {
107
- resultObj.push(this.getHttpString(value[field], prefix + `${prefix != '' ? '[' : ""}${field}${prefix != '' ? ']' : ''}`));
108
- }
109
- return resultObj.join('&');
110
- }
111
- else if (prefix != '') {
112
- return encodeURIComponent(prefix) + '=' + encodeURIComponent(value);
113
- }
114
- return encodeURIComponent(value);
115
- }
116
- setTimeoutCall(ms) {
117
- this.timeoutCall = ms;
118
- }
119
- clearTimeoutCall() {
120
- this.timeoutCall = 0;
121
- }
122
- isFunction(item) {
123
- return item === null ? false : (typeof (item) == "function" || item instanceof Function);
124
- }
125
- addEvent(event, handler) {
126
- this.arrEvents.push({
127
- event: event,
128
- handler: handler
129
- });
130
- }
131
- emitEvent(event, params) {
132
- const arrHandler = this.arrEvents.filter(el => { return el.event == event; });
133
- for (const idx in arrHandler) {
134
- setTimeout(() => {
135
- arrHandler[idx].handler.call(this, params);
136
- }, 10);
137
- }
138
- }
139
- uniqid() {
140
- const charsList = '0123456789abcdefghijklmnopqrstuvwxyz';
141
- let s = '';
142
- for (let i = 0; i < 32; i++)
143
- s += charsList[Math.round(Math.random() * (charsList.length - 1))];
144
- return s;
145
- }
146
- setCallback(cb) {
147
- const cbId = this.uniqid();
148
- if (cb) {
149
- this.cbArray.push({ uid: cbId, cb: cb });
150
- }
151
- return cbId;
152
- }
153
- doInit() {
154
- this.emitEvent('init', this);
155
- }
156
159
  utilReady() {
157
160
  if (document.readyState === "complete") {
158
161
  return this.runReady();
@@ -265,8 +268,8 @@ class baseBX24 {
265
268
  let cnt = 0;
266
269
  for (const idx in cmd) {
267
270
  const row = cmd[idx];
268
- const method = Array.isArray(row) ? row[0] : row.method;
269
- const params = Array.isArray(row) ? row[1] : row.params;
271
+ const method = Array.isArray(row) ? row[0] : row === null || row === void 0 ? void 0 : row.method;
272
+ const params = Array.isArray(row) ? row[1] : row === null || row === void 0 ? void 0 : row.params;
270
273
  if (method) {
271
274
  cnt++;
272
275
  comands[idx] = `${method}?${this.getHttpString(params)}`;
@@ -349,6 +352,9 @@ class baseBX24 {
349
352
  const result = {};
350
353
  for (const idx in calls) {
351
354
  const cmd = calls[idx];
355
+ const method = Array.isArray(cmd) ? cmd[0] : cmd === null || cmd === void 0 ? void 0 : cmd.method;
356
+ if (!method)
357
+ continue;
352
358
  if (((_a = data === null || data === void 0 ? void 0 : data.result) === null || _a === void 0 ? void 0 : _a[idx]) !== undefined || ((_b = data === null || data === void 0 ? void 0 : data.result_error) === null || _b === void 0 ? void 0 : _b[idx]) !== undefined) {
353
359
  result[idx] = new callResult_1.CallResult({
354
360
  result: ((_c = data.result) === null || _c === void 0 ? void 0 : _c[idx]) || {},
@@ -357,7 +363,7 @@ class baseBX24 {
357
363
  time: data.result_time[idx],
358
364
  next: data.result_next[idx]
359
365
  }, {
360
- method: Array.isArray(cmd) ? cmd[0] : cmd === null || cmd === void 0 ? void 0 : cmd.method,
366
+ method,
361
367
  data: Array.isArray(cmd) ? cmd[1] : cmd === null || cmd === void 0 ? void 0 : cmd.params,
362
368
  callback: callback
363
369
  }, this, res.status);
@@ -369,7 +375,7 @@ class baseBX24 {
369
375
  error_description: () => JSON.stringify(res),
370
376
  answer: (_d = data === null || data === void 0 ? void 0 : data.result) === null || _d === void 0 ? void 0 : _d[idx],
371
377
  query: {
372
- method: Array.isArray(cmd) ? cmd[0] : cmd === null || cmd === void 0 ? void 0 : cmd.method,
378
+ method,
373
379
  data: Array.isArray(cmd) ? cmd[1] : cmd === null || cmd === void 0 ? void 0 : cmd.params,
374
380
  callback: callback
375
381
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slavmak2486/bx24ts",
3
- "version": "1.2.17",
3
+ "version": "1.2.18",
4
4
  "description": "Library for bitrix24",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -17,20 +17,20 @@
17
17
  "author": "dc",
18
18
  "license": "ISC",
19
19
  "devDependencies": {
20
- "@types/jest": "^27.4.1",
21
- "@typescript-eslint/eslint-plugin": "^5.13.0",
22
- "@types/lodash": "^4.14.179",
23
- "@typescript-eslint/parser": "^5.13.0",
24
- "axios-mock-adapter": "^1.20.0",
25
- "eslint": "^8.10.0",
26
- "jest": "^27.5.1",
27
- "nodemon": "^2.0.15",
28
- "ts-jest": "^27.1.3",
29
- "ts-node": "^10.6.0",
30
- "typescript": "^4.6.2"
20
+ "@types/jest": "^30.0.0",
21
+ "@typescript-eslint/eslint-plugin": "^8.48.0",
22
+ "@types/lodash": "^4.17.21",
23
+ "@typescript-eslint/parser": "^8.48.0",
24
+ "axios-mock-adapter": "^2.1.0",
25
+ "eslint": "^9.39.1",
26
+ "jest": "^30.2.0",
27
+ "nodemon": "^3.1.11",
28
+ "ts-jest": "^29.4.5",
29
+ "ts-node": "^10.9.2",
30
+ "typescript": "^5.9.3"
31
31
  },
32
32
  "dependencies": {
33
33
  "lodash": "^4.17.21",
34
- "axios": "^1.7.9"
34
+ "axios": "^1.13.2"
35
35
  }
36
36
  }
package/tsconfig.json CHANGED
@@ -86,16 +86,16 @@
86
86
  // "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */
87
87
  // "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */
88
88
  // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
89
- // "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */
90
- // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */
89
+ "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */
90
+ "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */
91
91
  // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
92
- // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
93
- // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
94
- // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
95
- // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
96
- // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */
97
- // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
98
- // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
92
+ "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
93
+ "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
94
+ "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
95
+ "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
96
+ "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */
97
+ "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
98
+ "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
99
99
 
100
100
  /* Completeness */
101
101
  // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */