@emartech/program-executor 3.10.0 → 3.11.1
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/eslint.config.js +56 -0
- package/package.json +15 -14
- package/src/graphql/schema.spec.js +22 -6
- package/src/program-executor-processor/index.spec.js +3 -1
- package/src/program-handler/index.js +7 -1
- package/.eslintrc +0 -31
package/eslint.config.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const mocha = require('eslint-plugin-mocha');
|
|
4
|
+
const globals = require('globals');
|
|
5
|
+
const js = require('@eslint/js');
|
|
6
|
+
const { FlatCompat } = require('@eslint/eslintrc');
|
|
7
|
+
|
|
8
|
+
const compat = new FlatCompat({
|
|
9
|
+
baseDirectory: __dirname,
|
|
10
|
+
recommendedConfig: js.configs.recommended,
|
|
11
|
+
allConfig: js.configs.all
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
module.exports = [
|
|
15
|
+
...compat.extends('emarsys'),
|
|
16
|
+
{
|
|
17
|
+
plugins: {
|
|
18
|
+
mocha
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
languageOptions: {
|
|
22
|
+
globals: {
|
|
23
|
+
...globals.node,
|
|
24
|
+
...globals.mocha,
|
|
25
|
+
inject: true,
|
|
26
|
+
onmessage: true,
|
|
27
|
+
expect: true
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
ecmaVersion: 9,
|
|
31
|
+
sourceType: 'commonjs'
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
rules: {
|
|
35
|
+
'no-unused-expressions': 0,
|
|
36
|
+
'operator-linebreak': 'off',
|
|
37
|
+
|
|
38
|
+
'no-unused-vars': [
|
|
39
|
+
2,
|
|
40
|
+
{
|
|
41
|
+
vars: 'all',
|
|
42
|
+
args: 'after-used'
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
|
|
46
|
+
curly: [2, 'multi-line'],
|
|
47
|
+
'require-yield': 0,
|
|
48
|
+
'new-cap': 0,
|
|
49
|
+
'security/detect-object-injection': 0,
|
|
50
|
+
'security/detect-non-literal-require': 0,
|
|
51
|
+
'security/detect-non-literal-fs-filename': 0,
|
|
52
|
+
'security/detect-non-literal-regexp': 0,
|
|
53
|
+
'space-before-function-paren': 0
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
];
|
package/package.json
CHANGED
|
@@ -17,30 +17,31 @@
|
|
|
17
17
|
"author": "team-shopify@emarsys.com",
|
|
18
18
|
"license": "ISC",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@emartech/rabbitmq-client": "
|
|
20
|
+
"@emartech/rabbitmq-client": "5.9.0",
|
|
21
|
+
"@emartech/json-logger": "3.4.0",
|
|
21
22
|
"camelcase-keys": "^6.2.2",
|
|
22
|
-
"graphql": "^
|
|
23
|
+
"graphql": "^16.10.0"
|
|
23
24
|
},
|
|
24
25
|
"engines": {
|
|
25
26
|
"node": "20.18.0"
|
|
26
27
|
},
|
|
27
28
|
"devDependencies": {
|
|
28
|
-
"chai": "^4.
|
|
29
|
+
"chai": "^4.5.0",
|
|
29
30
|
"chai-as-promised": "7.1.1",
|
|
30
31
|
"chai-string": "1.5.0",
|
|
31
32
|
"chai-subset": "1.6.0",
|
|
32
|
-
"dotenv": "^16.4.
|
|
33
|
-
"eslint": "^
|
|
33
|
+
"dotenv": "^16.4.7",
|
|
34
|
+
"eslint": "^9.21.0",
|
|
34
35
|
"eslint-config-emarsys": "5.1.0",
|
|
35
|
-
"eslint-plugin-mocha": "^10.
|
|
36
|
-
"eslint-plugin-no-only-tests": "^3.
|
|
37
|
-
"eslint-plugin-security": "^
|
|
38
|
-
"knex": "^
|
|
39
|
-
"mocha": "^
|
|
40
|
-
"pg": "^8.
|
|
41
|
-
"semantic-release": "^
|
|
42
|
-
"sinon": "
|
|
36
|
+
"eslint-plugin-mocha": "^10.5.0",
|
|
37
|
+
"eslint-plugin-no-only-tests": "^3.3.0",
|
|
38
|
+
"eslint-plugin-security": "^3.0.1",
|
|
39
|
+
"knex": "^3.1.0",
|
|
40
|
+
"mocha": "^11.1.0",
|
|
41
|
+
"pg": "^8.13.3",
|
|
42
|
+
"semantic-release": "^24.2.0",
|
|
43
|
+
"sinon": "19.0.2",
|
|
43
44
|
"sinon-chai": "^3.7.0"
|
|
44
45
|
},
|
|
45
|
-
"version": "3.
|
|
46
|
+
"version": "3.11.1"
|
|
46
47
|
}
|
|
@@ -14,7 +14,7 @@ describe('schema', function () {
|
|
|
14
14
|
}
|
|
15
15
|
}`;
|
|
16
16
|
|
|
17
|
-
const { data } = await graphql(schema, query,
|
|
17
|
+
const { data } = await graphql({ schema, source: query, contextValue: { knex: this.db, tableName: 'programs' } });
|
|
18
18
|
expect(data).to.eql({ programs: [] });
|
|
19
19
|
});
|
|
20
20
|
});
|
|
@@ -73,7 +73,7 @@ describe('schema', function () {
|
|
|
73
73
|
}
|
|
74
74
|
}`;
|
|
75
75
|
|
|
76
|
-
const { data } = await graphql(schema, query,
|
|
76
|
+
const { data } = await graphql({ schema, source: query, contextValue: { knex: this.db, tableName: 'programs' } });
|
|
77
77
|
|
|
78
78
|
expect(data.programs[0]).to.containSubset({
|
|
79
79
|
...programs[0],
|
|
@@ -110,7 +110,11 @@ describe('schema', function () {
|
|
|
110
110
|
}
|
|
111
111
|
}`;
|
|
112
112
|
|
|
113
|
-
const { data } = await graphql(
|
|
113
|
+
const { data } = await graphql({
|
|
114
|
+
schema,
|
|
115
|
+
source: query,
|
|
116
|
+
contextValue: { knex: this.db, tableName: 'programs' }
|
|
117
|
+
});
|
|
114
118
|
const ids = data.programs.map((program) => program.id);
|
|
115
119
|
|
|
116
120
|
expect(ids).to.eql(['1', '2', '3']);
|
|
@@ -123,7 +127,11 @@ describe('schema', function () {
|
|
|
123
127
|
}
|
|
124
128
|
}`;
|
|
125
129
|
|
|
126
|
-
const { data } = await graphql(
|
|
130
|
+
const { data } = await graphql({
|
|
131
|
+
schema,
|
|
132
|
+
source: query,
|
|
133
|
+
contextValue: { knex: this.db, tableName: 'programs' }
|
|
134
|
+
});
|
|
127
135
|
const ids = data.programs.map((program) => program.id);
|
|
128
136
|
|
|
129
137
|
expect(ids).to.eql(['3', '2', '1']);
|
|
@@ -138,7 +146,11 @@ describe('schema', function () {
|
|
|
138
146
|
}
|
|
139
147
|
}`;
|
|
140
148
|
|
|
141
|
-
const { data } = await graphql(
|
|
149
|
+
const { data } = await graphql({
|
|
150
|
+
schema,
|
|
151
|
+
source: query,
|
|
152
|
+
contextValue: { knex: this.db, tableName: 'programs' }
|
|
153
|
+
});
|
|
142
154
|
const ids = data.programs.map((program) => program.id);
|
|
143
155
|
|
|
144
156
|
expect(ids).to.eql(['1']);
|
|
@@ -151,7 +163,11 @@ describe('schema', function () {
|
|
|
151
163
|
}
|
|
152
164
|
}`;
|
|
153
165
|
|
|
154
|
-
const { data } = await graphql(
|
|
166
|
+
const { data } = await graphql({
|
|
167
|
+
schema,
|
|
168
|
+
source: query,
|
|
169
|
+
contextValue: { knex: this.db, tableName: 'programs' }
|
|
170
|
+
});
|
|
155
171
|
const ids = data.programs.map((program) => program.id);
|
|
156
172
|
|
|
157
173
|
expect(ids).to.eql(['3']);
|
|
@@ -175,6 +175,7 @@ describe('ProgramExecutorProcessor', function () {
|
|
|
175
175
|
programData: {},
|
|
176
176
|
runId: '1'
|
|
177
177
|
});
|
|
178
|
+
// eslint-disable-next-line no-unused-vars
|
|
178
179
|
} catch (error) {
|
|
179
180
|
expect(ProgramHandler.prototype.setProgramToError).to.be.calledWith('1', 'Something wrong happened!');
|
|
180
181
|
expect(ProgramHandler.prototype.setJobRetriableErrorMessage).not.have.been.called;
|
|
@@ -188,7 +189,7 @@ describe('ProgramExecutorProcessor', function () {
|
|
|
188
189
|
programData: {},
|
|
189
190
|
runId: '1'
|
|
190
191
|
});
|
|
191
|
-
// eslint-disable-next-line no-empty
|
|
192
|
+
// eslint-disable-next-line no-empty, no-unused-vars
|
|
192
193
|
} catch (_error) {}
|
|
193
194
|
|
|
194
195
|
expect(ProgramHandler.prototype.incrementStepRetryCount).to.have.been.calledWith('1');
|
|
@@ -201,6 +202,7 @@ describe('ProgramExecutorProcessor', function () {
|
|
|
201
202
|
programData: {},
|
|
202
203
|
runId: '1'
|
|
203
204
|
});
|
|
205
|
+
// eslint-disable-next-line no-unused-vars
|
|
204
206
|
} catch (error) {
|
|
205
207
|
expect(ProgramHandler.prototype.setProgramToError).not.have.been.called;
|
|
206
208
|
expect(ProgramHandler.prototype.setJobRetriableErrorMessage).to.be.calledWith(
|
|
@@ -52,7 +52,13 @@ class ProgramHandler {
|
|
|
52
52
|
|
|
53
53
|
jobData[jobName] = merge ? { ...jobData[jobName], ...payload } : payload;
|
|
54
54
|
|
|
55
|
-
devLogger.info('db update job data', {
|
|
55
|
+
devLogger.info('db update job data', {
|
|
56
|
+
run_id: runId,
|
|
57
|
+
jobName,
|
|
58
|
+
payload: JSON.stringify(payload),
|
|
59
|
+
merge,
|
|
60
|
+
OSPID: process.pid
|
|
61
|
+
});
|
|
56
62
|
return this._programsRepository.setJobDataByRunId(runId, jobData);
|
|
57
63
|
}
|
|
58
64
|
|
package/.eslintrc
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"root": true,
|
|
3
|
-
"extends": ["emarsys"],
|
|
4
|
-
"plugins": ["mocha"],
|
|
5
|
-
"env": {
|
|
6
|
-
"es6": true,
|
|
7
|
-
"node": true,
|
|
8
|
-
"mocha": true
|
|
9
|
-
},
|
|
10
|
-
"globals": {
|
|
11
|
-
"inject": true,
|
|
12
|
-
"onmessage": true,
|
|
13
|
-
"expect": true
|
|
14
|
-
},
|
|
15
|
-
"parserOptions": {
|
|
16
|
-
"ecmaVersion": 9
|
|
17
|
-
},
|
|
18
|
-
"rules": {
|
|
19
|
-
"no-unused-expressions": 0,
|
|
20
|
-
"operator-linebreak": "off",
|
|
21
|
-
"no-unused-vars": [2, { "vars": "all", "args": "after-used" }],
|
|
22
|
-
"curly": [2, "multi-line"],
|
|
23
|
-
"require-yield": 0,
|
|
24
|
-
"new-cap": 0,
|
|
25
|
-
"security/detect-object-injection": 0,
|
|
26
|
-
"security/detect-non-literal-require": 0,
|
|
27
|
-
"security/detect-non-literal-fs-filename": 0,
|
|
28
|
-
"security/detect-non-literal-regexp": 0,
|
|
29
|
-
"space-before-function-paren": 0
|
|
30
|
-
}
|
|
31
|
-
}
|