@maxzima/wa-communicator 0.0.13 → 0.0.14

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/.editorconfig ADDED
@@ -0,0 +1,16 @@
1
+ root = true
2
+
3
+ [*]
4
+ charset = utf-8
5
+ indent_style = space
6
+ indent_size = 2
7
+ end_of_line = lf
8
+ insert_final_newline = true
9
+ trim_trailing_whitespace = true
10
+
11
+ [*.{diff,md,sh}]
12
+ trim_trailing_whitespace = false
13
+ insert_final_newline = false
14
+
15
+ [*.json]
16
+ insert_final_newline = false
package/.eslintrc.js ADDED
@@ -0,0 +1,58 @@
1
+ 'use strict';
2
+
3
+ module.exports = {
4
+ root: true,
5
+ parser: '@typescript-eslint/parser',
6
+ extends: [
7
+ 'eslint:recommended',
8
+ 'plugin:eslint-comments/recommended',
9
+ 'plugin:@typescript-eslint/recommended',
10
+ 'plugin:import/typescript',
11
+ 'prettier',
12
+ ],
13
+ plugins: [
14
+ '@typescript-eslint',
15
+ 'prettier',
16
+ 'import',
17
+ 'eslint-comments',
18
+ 'editorconfig',
19
+ ],
20
+ parserOptions: {
21
+ ecmaVersion: 6,
22
+ sourceType: 'module',
23
+ },
24
+ env: {
25
+ es6: true,
26
+ node: true,
27
+ browser: true,
28
+ },
29
+ ignorePatterns: [
30
+ 'node_modules',
31
+ 'dist'
32
+ ],
33
+ globals: {
34
+ BigInt: true,
35
+ console: true,
36
+ document: true,
37
+ navigator: true,
38
+ window: true,
39
+ Math: true,
40
+ module: true,
41
+ require: true,
42
+ global: true,
43
+ },
44
+ rules: {
45
+ 'no-empty': 'off',
46
+ 'no-async-promise-executor': 'off',
47
+ "no-extra-boolean-cast": 'off',
48
+ '@typescript-eslint/explicit-module-boundary-types': 'off',
49
+ 'eslint-comments/disable-enable-pair': ['error', {allowWholeFile: true}],
50
+ 'eslint-comments/no-unused-disable': 'error',
51
+ // 'eslint-comments/no-unlimited-disable': 'off',
52
+ '@typescript-eslint/ban-ts-ignore': 'off',
53
+ '@typescript-eslint/ban-ts-comment': 'off',
54
+ '@typescript-eslint/no-empty-function': 'off',
55
+ 'semi': ['error', 'always'],
56
+ 'no-prototype-builtins': 'off',
57
+ },
58
+ };
package/.gitattributes ADDED
@@ -0,0 +1,29 @@
1
+ #*.php text eol=lf
2
+ *.sh text eol=lf
3
+ *.js text eol=lf
4
+ *.ts text eol=lf
5
+ *.json text eol=lf
6
+ *.css text eol=lf
7
+ *.scss text eol=lf
8
+ *.sql text eol=lf
9
+
10
+ *.jpg binary
11
+ *.jpeg binary
12
+ *.apng binary
13
+ *.png binary
14
+ *.gif binary
15
+ *.swf binary
16
+ *.ico binary
17
+
18
+ *.ttf binary
19
+ *.woff binary
20
+ *.woff2 binary
21
+
22
+ *.exe binary
23
+
24
+ *.mp3 binary
25
+ *.ogg binary
26
+ *.mov binary
27
+ *.mp4 binary
28
+
29
+ *.zip binary
@@ -0,0 +1,9 @@
1
+ # Dependencies
2
+ node_modules
3
+
4
+ # Production
5
+ dist/
6
+
7
+ # package.json is formatted by package managers, so we ignore it here
8
+ package-lock.json
9
+ package.json
package/.prettierrc.js ADDED
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+
3
+ module.exports = {
4
+ 'semi': true,
5
+ 'singleQuote': true,
6
+ 'arrowParens': 'always',
7
+ 'printWidth': 180,
8
+ 'bracketSpacing': false,
9
+ 'endOfLine': 'lf',
10
+ 'bracketSameLine': false,
11
+ 'proseWrap': 'preserve',
12
+ 'requirePragma': false,
13
+ 'tabWidth': 2,
14
+ 'trailingComma': 'es5',
15
+ 'useTabs': false
16
+ }
@@ -6,5 +6,5 @@
6
6
  },
7
7
  "exclude": [
8
8
  "../src/types/index.ts",
9
- ]
9
+ ],
10
10
  }
@@ -3,6 +3,6 @@
3
3
  "compilerOptions": {
4
4
  "declaration": true,
5
5
  "emitDeclarationOnly": true,
6
- "outDir": "../dist"
7
- }
6
+ "outDir": "../dist",
7
+ },
8
8
  }
@@ -1,4 +1,4 @@
1
- import { isValidMessage, modifyOrigin } from "./utils";
1
+ import { isValidMessage, modifyOrigin, sortMessageQueue } from "./utils";
2
2
  import { CommunicatorTargetEnum_isCorrect } from '../enums/CommunicatorTargetEnum';
3
3
  import { CommunicatorActionEnum_isCorrect, CommunicatorActionEnum_scenario } from '../enums/CommunicatorActionEnum';
4
4
  export class CommunicatorReceiver {
@@ -24,29 +24,10 @@ export class CommunicatorReceiver {
24
24
  }
25
25
  const queue = this.queue.filter(item => item.target === message.target && message.action.hasOwnProperty(item.action));
26
26
  const defaultScenario = CommunicatorActionEnum_scenario();
27
- let sortedQueue = queue.sort((a, b) => {
28
- if (defaultScenario.indexOf(a.action) > defaultScenario.indexOf(b.action)) {
29
- return -1;
30
- }
31
- if (defaultScenario.indexOf(a.action) < defaultScenario.indexOf(b.action)) {
32
- return 1;
33
- }
34
- return 0;
35
- });
27
+ let sortedQueue = sortMessageQueue(queue, defaultScenario);
36
28
  const scenario = this.getMessageScenario(message.target);
37
29
  if (defaultScenario !== scenario) {
38
- sortedQueue = queue.sort((a, b) => {
39
- if (scenario.indexOf(a.action) === -1 || scenario.indexOf(b.action) === -1) {
40
- return 0;
41
- }
42
- if (scenario.indexOf(a.action) > scenario.indexOf(b.action)) {
43
- return 1;
44
- }
45
- if (scenario.indexOf(a.action) < scenario.indexOf(b.action)) {
46
- return -1;
47
- }
48
- return 0;
49
- });
30
+ sortedQueue = sortMessageQueue(queue, scenario);
50
31
  }
51
32
  if (sortedQueue.length) {
52
33
  sortedQueue.forEach(item => {
@@ -102,7 +83,7 @@ export class CommunicatorReceiver {
102
83
  return false;
103
84
  };
104
85
  this.getMessageScenario = (target) => {
105
- let scenario = this.scenario[target];
86
+ const scenario = this.scenario[target];
106
87
  if (scenario) {
107
88
  return scenario;
108
89
  }
@@ -1,3 +1,5 @@
1
- import { TCommunicatorMessage } from "../types";
1
+ import { TCommunicatorMessage, TReceiverMessageQueue } from "../types";
2
+ import { CommunicatorActionEnum } from "../enums/CommunicatorActionEnum";
2
3
  export declare function modifyOrigin(address: string): string;
3
4
  export declare function isValidMessage(message: TCommunicatorMessage): boolean;
5
+ export declare function sortMessageQueue(queue: TReceiverMessageQueue, scenario: CommunicatorActionEnum[]): TReceiverMessageQueue;
@@ -28,3 +28,14 @@ export function isValidMessage(message) {
28
28
  }
29
29
  return isValidTarget && isValidActions;
30
30
  }
31
+ export function sortMessageQueue(queue, scenario) {
32
+ return queue.sort((a, b) => {
33
+ if (scenario.indexOf(a.action) > scenario.indexOf(b.action)) {
34
+ return 1;
35
+ }
36
+ if (scenario.indexOf(a.action) < scenario.indexOf(b.action)) {
37
+ return -1;
38
+ }
39
+ return 0;
40
+ });
41
+ }
@@ -6,4 +6,4 @@ export declare enum CommunicatorActionEnum {
6
6
  GOTO = "goto"
7
7
  }
8
8
  export declare function CommunicatorActionEnum_isCorrect(item: string): boolean;
9
- export declare function CommunicatorActionEnum_scenario(): string[];
9
+ export declare function CommunicatorActionEnum_scenario(): CommunicatorActionEnum[];
package/jest.config.js ADDED
@@ -0,0 +1,18 @@
1
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
2
+ const { defaultsESM: tsjPreset } = require('ts-jest/presets');
3
+
4
+ module.exports = {
5
+ roots: ['<rootDir>/test'],
6
+ testMatch: [
7
+ '**/__tests__/**/*.+(ts|js)',
8
+ '**/?(*.)+(spec).+(ts|js)',
9
+ ],
10
+ transform: {
11
+ ...tsjPreset.transform,
12
+ },
13
+ globals: {
14
+ 'ts-jest': {
15
+ 'tsconfig': 'tsconfig.json'
16
+ }
17
+ }
18
+ };
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.13",
2
+ "version": "0.0.14",
3
3
  "name": "@maxzima/wa-communicator",
4
4
  "description": "",
5
5
  "author": "Noname",
@@ -13,16 +13,34 @@
13
13
  "type": "git",
14
14
  "url": ""
15
15
  },
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
16
19
  "scripts": {
17
- "prepublishOnly": "npm run build",
20
+ "prepublishOnly": "npm run test && npm run build",
18
21
  "clean": "node tools/cleanup",
19
22
  "build": "npm run clean && run-p build:*",
20
23
  "build:esm": "tsc -p config/tsconfig.esm.json",
21
24
  "build:types": "tsc -p config/tsconfig.types.json",
22
- "package": "npm run build"
25
+ "package": "npm run build",
26
+ "lint": "eslint --cache --ext .ts ./src",
27
+ "lint:fix": "npm run lint -- --fix",
28
+ "test": "jest --no-cache --runInBand"
23
29
  },
24
30
  "devDependencies": {
31
+ "@types/jest": "^28.1.8",
32
+ "@typescript-eslint/eslint-plugin": "^5.35.1",
33
+ "@typescript-eslint/parser": "^5.35.1",
34
+ "eslint": "^8.22.0",
35
+ "eslint-config-prettier": "^8.5.0",
36
+ "eslint-plugin-editorconfig": "^4.0.2",
37
+ "eslint-plugin-eslint-comments": "^3.2.0",
38
+ "eslint-plugin-import": "^2.26.0",
39
+ "eslint-plugin-prettier": "^4.2.1",
40
+ "jest": "^28.1.3",
25
41
  "npm-run-all": "^4.1.5",
42
+ "prettier": "^2.7.1",
43
+ "ts-jest": "^28.0.8",
26
44
  "typescript": "^4.7.4"
27
45
  }
28
46
  }
@@ -6,7 +6,7 @@ import {
6
6
  TReceiverTargetScenario,
7
7
  TReceiverUnsubscribeMessageParams,
8
8
  } from '../types';
9
- import {isValidMessage, modifyOrigin} from "./utils";
9
+ import {isValidMessage, modifyOrigin, sortMessageQueue} from "./utils";
10
10
  import {CommunicatorTargetEnum, CommunicatorTargetEnum_isCorrect} from '../enums/CommunicatorTargetEnum';
11
11
  import {
12
12
  CommunicatorActionEnum,
@@ -55,36 +55,16 @@ export class CommunicatorReceiver {
55
55
  return;
56
56
  }
57
57
 
58
- // Find queue by target and action
59
58
  const queue = this.queue.filter(item => item.target === message.target && message.action.hasOwnProperty(item.action));
60
59
 
61
60
  // default sort queue
62
61
  const defaultScenario = CommunicatorActionEnum_scenario();
63
- let sortedQueue = queue.sort((a, b) => {
64
- if (defaultScenario.indexOf(a.action) > defaultScenario.indexOf(b.action)) {
65
- return -1;
66
- }
67
- if (defaultScenario.indexOf(a.action) < defaultScenario.indexOf(b.action)) {
68
- return 1;
69
- }
70
- return 0;
71
- })
62
+ let sortedQueue = sortMessageQueue(queue, defaultScenario);
72
63
 
73
64
  // sort queue
74
65
  const scenario = this.getMessageScenario(message.target);
75
66
  if (defaultScenario !== scenario) {
76
- sortedQueue = queue.sort((a, b) => {
77
- if (scenario.indexOf(a.action) === -1 || scenario.indexOf(b.action) === -1) {
78
- return 0;
79
- }
80
- if (scenario.indexOf(a.action) > scenario.indexOf(b.action)) {
81
- return 1;
82
- }
83
- if (scenario.indexOf(a.action) < scenario.indexOf(b.action)) {
84
- return -1;
85
- }
86
- return 0;
87
- })
67
+ sortedQueue = sortMessageQueue(queue, scenario);
88
68
  }
89
69
 
90
70
  if (sortedQueue.length) {
@@ -92,7 +72,7 @@ export class CommunicatorReceiver {
92
72
  if (typeof item.params.callback === 'function') {
93
73
  item.params.callback(message);
94
74
  }
95
- })
75
+ });
96
76
  }
97
77
  };
98
78
 
@@ -134,7 +114,7 @@ export class CommunicatorReceiver {
134
114
  }
135
115
 
136
116
  this.queue.push(newQueueItem);
137
- }
117
+ };
138
118
 
139
119
  /**
140
120
  * Subscribe by code or target or action
@@ -159,18 +139,27 @@ export class CommunicatorReceiver {
159
139
  }
160
140
 
161
141
  return false;
162
- }
142
+ };
163
143
 
144
+ /**
145
+ * Get scenario for target
146
+ * @param target
147
+ */
164
148
  private getMessageScenario = (target: CommunicatorTargetEnum) => {
165
- let scenario = this.scenario[target];
149
+ const scenario = this.scenario[target];
166
150
 
167
151
  if (scenario) {
168
152
  return scenario;
169
153
  }
170
154
 
171
155
  return CommunicatorActionEnum_scenario();
172
- }
156
+ };
173
157
 
158
+ /**
159
+ * Change scenario for target
160
+ * @param target
161
+ * @param scenario
162
+ */
174
163
  public setMessageScenario = (target: CommunicatorTargetEnum, scenario: CommunicatorActionEnum[]) => {
175
164
  if (
176
165
  !CommunicatorTargetEnum_isCorrect(target) ||
@@ -185,9 +174,9 @@ export class CommunicatorReceiver {
185
174
  if (!CommunicatorActionEnum_isCorrect(item)) {
186
175
  throw new Error('WAC: failed scenario action!');
187
176
  }
188
- })
177
+ });
189
178
 
190
179
  this.scenario[target] = scenario;
191
- }
180
+ };
192
181
  }
193
182
 
@@ -1,6 +1,6 @@
1
- import {TCommunicatorMessage} from "../types";
1
+ import {TCommunicatorMessage, TReceiverMessageQueue} from "../types";
2
2
  import {CommunicatorTargetEnum_isCorrect} from "../enums/CommunicatorTargetEnum";
3
- import {CommunicatorActionEnum_isCorrect} from "../enums/CommunicatorActionEnum";
3
+ import {CommunicatorActionEnum, CommunicatorActionEnum_isCorrect} from "../enums/CommunicatorActionEnum";
4
4
 
5
5
  /**
6
6
  * @param address
@@ -39,3 +39,15 @@ export function isValidMessage(message: TCommunicatorMessage) {
39
39
 
40
40
  return isValidTarget && isValidActions;
41
41
  }
42
+
43
+ export function sortMessageQueue(queue: TReceiverMessageQueue, scenario: CommunicatorActionEnum[]) {
44
+ return queue.sort((a, b) => {
45
+ if (scenario.indexOf(a.action) > scenario.indexOf(b.action)) {
46
+ return 1;
47
+ }
48
+ if (scenario.indexOf(a.action) < scenario.indexOf(b.action)) {
49
+ return -1;
50
+ }
51
+ return 0;
52
+ });
53
+ }
@@ -10,6 +10,6 @@ export function CommunicatorActionEnum_isCorrect(item: string): boolean {
10
10
  return Object.values(CommunicatorActionEnum).includes(item as CommunicatorActionEnum);
11
11
  }
12
12
 
13
- export function CommunicatorActionEnum_scenario(): string[] {
13
+ export function CommunicatorActionEnum_scenario(): CommunicatorActionEnum[] {
14
14
  return Object.values(CommunicatorActionEnum);
15
15
  }
package/src/index.ts CHANGED
@@ -1,7 +1,7 @@
1
- import {CommunicatorReceiver} from "./engine/CommunicatorReceiver"
2
- import {CommunicatorSender} from "./engine/CommunicatorSender"
3
- import {CommunicatorTargetEnum} from "./enums/CommunicatorTargetEnum"
4
- import {CommunicatorActionEnum} from "./enums/CommunicatorActionEnum"
1
+ import {CommunicatorReceiver} from "./engine/CommunicatorReceiver";
2
+ import {CommunicatorSender} from "./engine/CommunicatorSender";
3
+ import {CommunicatorTargetEnum} from "./enums/CommunicatorTargetEnum";
4
+ import {CommunicatorActionEnum} from "./enums/CommunicatorActionEnum";
5
5
  import * as types from "./types";
6
6
 
7
7
  export {
@@ -10,4 +10,4 @@ export {
10
10
  CommunicatorTargetEnum,
11
11
  CommunicatorActionEnum,
12
12
  types,
13
- }
13
+ };
package/src/receiver.ts CHANGED
@@ -1,6 +1,6 @@
1
- import {CommunicatorReceiver} from "./engine/CommunicatorReceiver"
2
- import {CommunicatorTargetEnum} from "./enums/CommunicatorTargetEnum"
3
- import {CommunicatorActionEnum} from "./enums/CommunicatorActionEnum"
1
+ import {CommunicatorReceiver} from "./engine/CommunicatorReceiver";
2
+ import {CommunicatorTargetEnum} from "./enums/CommunicatorTargetEnum";
3
+ import {CommunicatorActionEnum} from "./enums/CommunicatorActionEnum";
4
4
  import * as types from "./types";
5
5
  import {isValidMessage as communicatorMessageIsValid} from "./engine/utils";
6
6
 
@@ -10,4 +10,4 @@ export {
10
10
  CommunicatorActionEnum,
11
11
  types,
12
12
  communicatorMessageIsValid
13
- }
13
+ };
package/src/sender.ts CHANGED
@@ -1,6 +1,6 @@
1
- import {CommunicatorSender} from "./engine/CommunicatorSender"
2
- import {CommunicatorTargetEnum} from "./enums/CommunicatorTargetEnum"
3
- import {CommunicatorActionEnum} from "./enums/CommunicatorActionEnum"
1
+ import {CommunicatorSender} from "./engine/CommunicatorSender";
2
+ import {CommunicatorTargetEnum} from "./enums/CommunicatorTargetEnum";
3
+ import {CommunicatorActionEnum} from "./enums/CommunicatorActionEnum";
4
4
  import * as types from "./types";
5
5
 
6
6
  export {
@@ -8,4 +8,4 @@ export {
8
8
  CommunicatorTargetEnum,
9
9
  CommunicatorActionEnum,
10
10
  types,
11
- }
11
+ };
@@ -0,0 +1,44 @@
1
+ import {TCommunicatorMessage} from '../../src/types';
2
+ import {CommunicatorActionEnum, CommunicatorTargetEnum} from '../../src';
3
+
4
+ const normalMessage: TCommunicatorMessage = {
5
+ target: CommunicatorTargetEnum.SIGN_UP,
6
+ action: {
7
+ [CommunicatorActionEnum.OPEN]: CommunicatorTargetEnum.SIGN_IN,
8
+ [CommunicatorActionEnum.CLOSE]: true,
9
+ [CommunicatorActionEnum.GOTO]: {
10
+ url: 'google.com',
11
+ },
12
+ }
13
+ };
14
+
15
+ const messageWithInvalidTarget: TCommunicatorMessage = {
16
+ target: 'Invalid' as CommunicatorTargetEnum,
17
+ action: {
18
+ [CommunicatorActionEnum.OPEN]: CommunicatorTargetEnum.SIGN_IN,
19
+ [CommunicatorActionEnum.CLOSE]: true,
20
+ }
21
+ };
22
+
23
+ const messageWithInvalidAction: TCommunicatorMessage = {
24
+ target: CommunicatorTargetEnum.SIGN_UP,
25
+ action: {
26
+ ['Invalid' as CommunicatorActionEnum]: CommunicatorTargetEnum.SIGN_IN,
27
+ [CommunicatorActionEnum.CLOSE]: true,
28
+ }
29
+ };
30
+
31
+ const messageWithInvalidActionParams: TCommunicatorMessage = {
32
+ target: 'Invalid' as CommunicatorTargetEnum,
33
+ action: {
34
+ [CommunicatorActionEnum.OPEN]: 'failed' as CommunicatorTargetEnum,
35
+ [CommunicatorActionEnum.CLOSE]: true,
36
+ }
37
+ };
38
+
39
+ export {
40
+ normalMessage,
41
+ messageWithInvalidTarget,
42
+ messageWithInvalidAction,
43
+ messageWithInvalidActionParams
44
+ };
@@ -0,0 +1,56 @@
1
+ import {TReceiverMessageQueue} from '../../src/types';
2
+ import {CommunicatorActionEnum, CommunicatorTargetEnum} from '../../src';
3
+
4
+ const getQueue = (isDefaultSort = false): TReceiverMessageQueue => {
5
+ if (isDefaultSort) {
6
+ return [
7
+ {
8
+ target: CommunicatorTargetEnum.SIGN_IN,
9
+ action: CommunicatorActionEnum.CLOSE,
10
+ params: {
11
+ callback: () => {}
12
+ }
13
+ },
14
+ {
15
+ target: CommunicatorTargetEnum.SIGN_IN,
16
+ action: CommunicatorActionEnum.OPEN,
17
+ params: {
18
+ callback: () => {}
19
+ }
20
+ },
21
+ {
22
+ target: CommunicatorTargetEnum.SIGN_IN,
23
+ action: CommunicatorActionEnum.GOTO,
24
+ params: {
25
+ callback: () => {}
26
+ }
27
+ }
28
+ ];
29
+ }
30
+
31
+ return [
32
+ {
33
+ target: CommunicatorTargetEnum.SIGN_IN,
34
+ action: CommunicatorActionEnum.OPEN,
35
+ params: {
36
+ callback: () => {}
37
+ }
38
+ },
39
+ {
40
+ target: CommunicatorTargetEnum.SIGN_IN,
41
+ action: CommunicatorActionEnum.CLOSE,
42
+ params: {
43
+ callback: () => {}
44
+ }
45
+ },
46
+ {
47
+ target: CommunicatorTargetEnum.SIGN_IN,
48
+ action: CommunicatorActionEnum.GOTO,
49
+ params: {
50
+ callback: () => {}
51
+ }
52
+ }
53
+ ];
54
+ };
55
+
56
+ export default getQueue;
@@ -0,0 +1,44 @@
1
+ import {isValidMessage, modifyOrigin, sortMessageQueue} from '../src/engine/utils';
2
+ import {CommunicatorActionEnum_scenario} from '../src/enums/CommunicatorActionEnum';
3
+ import getQueue from './testUnits/queue';
4
+ import {messageWithInvalidAction, messageWithInvalidTarget, normalMessage} from './testUnits/message';
5
+
6
+ test('modifyOrigin', () => {
7
+ expect(modifyOrigin('google.com')).toBe('https://google.com');
8
+ expect(modifyOrigin('google.com/test')).toBe('https://google.com');
9
+ expect(modifyOrigin('https://google.com/')).toBe('https://google.com');
10
+ });
11
+
12
+ describe('isValidMessage', () => {
13
+ it('message is valid', () => {
14
+ expect(isValidMessage(normalMessage)).toBeTruthy();
15
+ });
16
+
17
+ it('message has invalid target', () => {
18
+ expect(
19
+ isValidMessage(messageWithInvalidTarget)
20
+ ).toBeFalsy();
21
+ });
22
+
23
+ it('message has invalid action', () => {
24
+ expect(
25
+ isValidMessage(messageWithInvalidAction)
26
+ ).toBeFalsy();
27
+ });
28
+
29
+ // TODO: need validation action params
30
+ // it('Invalid Action Params', () => {
31
+ // expect(
32
+ // isValidMessage(messageWithInvalidActionParams)
33
+ // ).toBeFalsy();
34
+ // });
35
+ });
36
+
37
+ describe('sortMessageQueue', () => {
38
+ it('Default Sorting', () => {
39
+ expect(
40
+ JSON.stringify(sortMessageQueue(getQueue(), CommunicatorActionEnum_scenario()))
41
+ ).toBe(JSON.stringify(getQueue(true)));
42
+ });
43
+ });
44
+
package/tools/cleanup.js CHANGED
@@ -1,26 +1,26 @@
1
- /* eslint-disable */
2
- const fs = require('fs')
3
- const Path = require('path')
4
- /* eslint-enable */
1
+ /* eslint-disable @typescript-eslint/no-var-requires */
2
+ const fs = require('fs');
3
+ const Path = require('path');
4
+ /* eslint-enable @typescript-eslint/no-var-requires */
5
5
 
6
6
  const deleteFolderRecursive = (path) => {
7
7
  if (fs.existsSync(path)) {
8
8
  fs.readdirSync(path).forEach((file) => {
9
- const curPath = Path.join(path, file)
9
+ const curPath = Path.join(path, file);
10
10
  if (fs.lstatSync(curPath).isDirectory()) {
11
- deleteFolderRecursive(curPath)
11
+ deleteFolderRecursive(curPath);
12
12
  } else {
13
- fs.unlinkSync(curPath)
13
+ fs.unlinkSync(curPath);
14
14
  }
15
- })
16
- fs.rmdirSync(path)
15
+ });
16
+ fs.rmdirSync(path);
17
17
  }
18
- }
18
+ };
19
19
 
20
- const folder = process.argv.slice(2)[0]
20
+ const folder = process.argv.slice(2)[0];
21
21
 
22
22
  if (folder) {
23
- deleteFolderRecursive(Path.join(__dirname, '../dist', folder))
23
+ deleteFolderRecursive(Path.join(__dirname, '../dist', folder));
24
24
  } else {
25
- deleteFolderRecursive(Path.join(__dirname, '../dist'))
25
+ deleteFolderRecursive(Path.join(__dirname, '../dist'));
26
26
  }