@restorecommerce/gql-bot 1.0.1 → 1.0.3

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/CHANGELOG.md CHANGED
@@ -3,6 +3,25 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.0.3](https://github.com/restorecommerce/libs/compare/@restorecommerce/gql-bot@1.0.2...@restorecommerce/gql-bot@1.0.3) (2023-05-29)
7
+
8
+ **Note:** Version bump only for package @restorecommerce/gql-bot
9
+
10
+
11
+
12
+
13
+
14
+ ## [1.0.2](https://github.com/restorecommerce/libs/compare/@restorecommerce/gql-bot@1.0.1...@restorecommerce/gql-bot@1.0.2) (2023-05-22)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * **acs-client:** fix test imports ([3a092ef](https://github.com/restorecommerce/libs/commit/3a092ef3e34b45df0c121c3fef3f8a51d99acb96))
20
+
21
+
22
+
23
+
24
+
6
25
  ## [1.0.1](https://github.com/restorecommerce/libs/compare/@restorecommerce/gql-bot@1.0.0...@restorecommerce/gql-bot@1.0.1) (2022-10-14)
7
26
 
8
27
  **Note:** Version bump only for package @restorecommerce/gql-bot
package/lib/client.js CHANGED
@@ -1,24 +1,41 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
10
27
  };
11
28
  Object.defineProperty(exports, "__esModule", { value: true });
12
29
  exports.Client = void 0;
13
- const _ = require("lodash");
14
- const url = require("url");
15
- const fs = require("fs");
16
- const graphql_tag_1 = require("graphql-tag");
30
+ const _ = __importStar(require("lodash"));
31
+ const url = __importStar(require("url"));
32
+ const fs = __importStar(require("fs"));
33
+ const graphql_tag_1 = __importDefault(require("graphql-tag"));
17
34
  const apollo_client_1 = require("apollo-client");
18
35
  const apollo_cache_inmemory_1 = require("apollo-cache-inmemory");
19
- const node_fetch_1 = require("node-fetch"); // required for apollo-link-http
36
+ const node_fetch_1 = __importDefault(require("node-fetch")); // required for apollo-link-http
20
37
  const apollo_link_http_1 = require("apollo-link-http");
21
- const https = require("https");
38
+ const https = __importStar(require("https"));
22
39
  const utils_1 = require("./utils");
23
40
  const _checkVariableMutation = (mutation) => {
24
41
  const mutationName = mutation.slice(mutation.indexOf(' '), mutation.indexOf('($'));
@@ -134,77 +151,76 @@ class Client {
134
151
  }
135
152
  return url.resolve(this.entryBaseUrl, extendURL);
136
153
  }
137
- post(source, job, verbose = false, ignoreErrors = false, ignoreSelfSigned = false) {
138
- return __awaiter(this, void 0, void 0, function* () {
139
- const normalUrl = this._normalizeUrl();
140
- let mutation;
141
- if (job && job.mutation) {
142
- mutation = JSON.stringify(job.mutation);
143
- }
144
- else {
145
- throw new Error(`mutation not present in job config (${job.name})`);
146
- }
147
- const apiKey = JSON.stringify(this.opts.apiKey);
148
- let resource_list = JSON.stringify(source);
149
- if (mutation) {
150
- // don't replace quoted strings inside outer quotes
151
- // (i.e. if the quote is preceded by a backslash)
152
- // make sure to also match line/expression start
153
- // and keep the symbol preceding the quote
154
- mutation = mutation.replace(/(^|[^\\])\"/g, '$1');
155
- // afterwards, replace escaped quotes with regular ones
156
- mutation = mutation.replace(/\\\"/g, '\"');
157
- }
158
- let variables;
159
- if (_checkVariableMutation(mutation)) {
160
- const queryVarKey = job.queryVariables;
161
- const inputVarName = mutation.slice(mutation.indexOf('$') + 1, mutation.indexOf(':'));
162
- variables = _createQueryVariables(inputVarName, queryVarKey, resource_list);
163
- }
164
- else {
165
- // To remove double quotes from the keys in JSON data
166
- resource_list = resource_list.replace(/\"([^(\")"]+)\":/g, '$1:');
167
- mutation = _replaceInlineVars(mutation, { resource_list, apiKey });
168
- }
169
- const apolloLinkOpts = {
170
- uri: normalUrl,
171
- fetch: node_fetch_1.default
154
+ async post(source, job, verbose = false, ignoreErrors = false, ignoreSelfSigned = false) {
155
+ const normalUrl = this._normalizeUrl();
156
+ let mutation;
157
+ if (job && job.mutation) {
158
+ mutation = JSON.stringify(job.mutation);
159
+ }
160
+ else {
161
+ throw new Error(`mutation not present in job config (${job.name})`);
162
+ }
163
+ const apiKey = JSON.stringify(this.opts.apiKey);
164
+ let resource_list = JSON.stringify(source);
165
+ if (mutation) {
166
+ // don't replace quoted strings inside outer quotes
167
+ // (i.e. if the quote is preceded by a backslash)
168
+ // make sure to also match line/expression start
169
+ // and keep the symbol preceding the quote
170
+ mutation = mutation.replace(/(^|[^\\])\"/g, '$1');
171
+ // afterwards, replace escaped quotes with regular ones
172
+ mutation = mutation.replace(/\\\"/g, '\"');
173
+ }
174
+ let variables;
175
+ if (_checkVariableMutation(mutation)) {
176
+ const queryVarKey = job.queryVariables;
177
+ const inputVarName = mutation.slice(mutation.indexOf('$') + 1, mutation.indexOf(':'));
178
+ variables = _createQueryVariables(inputVarName, queryVarKey, resource_list);
179
+ }
180
+ else {
181
+ // To remove double quotes from the keys in JSON data
182
+ resource_list = resource_list.replace(/\"([^(\")"]+)\":/g, '$1:');
183
+ mutation = _replaceInlineVars(mutation, { resource_list, apiKey });
184
+ }
185
+ const apolloLinkOpts = {
186
+ uri: normalUrl,
187
+ fetch: node_fetch_1.default
188
+ };
189
+ if (this.opts.headers) {
190
+ apolloLinkOpts['headers'] = this.opts.headers;
191
+ }
192
+ if (ignoreSelfSigned) {
193
+ apolloLinkOpts.fetchOptions = {
194
+ agent: new https.Agent({ rejectUnauthorized: false }),
172
195
  };
173
- if (this.opts.headers) {
174
- apolloLinkOpts['headers'] = this.opts.headers;
175
- }
176
- if (ignoreSelfSigned) {
177
- apolloLinkOpts.fetchOptions = {
178
- agent: new https.Agent({ rejectUnauthorized: false }),
179
- };
196
+ }
197
+ let apolloLink = (0, apollo_link_http_1.createHttpLink)(apolloLinkOpts);
198
+ const apolloCache = new apollo_cache_inmemory_1.InMemoryCache();
199
+ const apolloClient = new apollo_client_1.ApolloClient({
200
+ cache: apolloCache,
201
+ link: apolloLink
202
+ });
203
+ const response = await apolloClient.mutate({
204
+ mutation: (0, graphql_tag_1.default) `${mutation}`,
205
+ variables
206
+ });
207
+ const error = checkError(response);
208
+ if (error) {
209
+ const processed = (0, utils_1.processResponse)(response);
210
+ if (verbose) {
211
+ console.error(JSON.stringify({
212
+ request: mutation,
213
+ variables,
214
+ response: processed
215
+ }));
180
216
  }
181
- let apolloLink = (0, apollo_link_http_1.createHttpLink)(apolloLinkOpts);
182
- const apolloCache = new apollo_cache_inmemory_1.InMemoryCache();
183
- const apolloClient = new apollo_client_1.ApolloClient({
184
- cache: apolloCache,
185
- link: apolloLink
186
- });
187
- const response = yield apolloClient.mutate({
188
- mutation: (0, graphql_tag_1.default) `${mutation}`,
189
- variables
190
- });
191
- const error = checkError(response);
192
- if (error) {
193
- const processed = (0, utils_1.processResponse)(response);
194
- if (verbose) {
195
- console.error(JSON.stringify({
196
- request: mutation,
197
- variables,
198
- response: processed
199
- }));
200
- }
201
- else if (ignoreErrors) {
202
- console.error(JSON.stringify(processed));
203
- }
204
- throw new Error(JSON.stringify(error));
217
+ else if (ignoreErrors) {
218
+ console.error(JSON.stringify(processed));
205
219
  }
206
- return response;
207
- });
220
+ throw new Error(JSON.stringify(error));
221
+ }
222
+ return response;
208
223
  }
209
224
  }
210
225
  exports.Client = Client;
226
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAA4B;AAC5B,yCAA2B;AAC3B,uCAAyB;AACzB,8DAA8B;AAC9B,iDAA6C;AAC7C,iEAAsD;AACtD,4DAA+B,CAAC,gCAAgC;AAChE,uDAA4D;AAC5D,6CAA+B;AAC/B,mCAA0C;AAE1C,MAAM,sBAAsB,GAAG,CAAC,QAAgB,EAAW,EAAE;IAC3D,MAAM,YAAY,GAAG,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,EACvD,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1B,IAAI,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;QACjC,OAAO,KAAK,CAAC;KACd;SAAM;QACL,OAAO,IAAI,MAAM,CAAC,KAAK,GAAG,YAAY,GAAG,KAAK,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,QAAQ,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ACL;iBAAM,IAAI,YAAY,EAAE;gBACvB,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC;aAC1C;YACD,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;SACxC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AA/ID,wBA+IC"}
package/lib/index.js CHANGED
@@ -8,3 +8,4 @@ Object.defineProperty(exports, "GraphQLProcessor", { enumerable: true, get: func
8
8
  const job_processor_1 = require("./job_processor");
9
9
  Object.defineProperty(exports, "JobProcessor", { enumerable: true, get: function () { return job_processor_1.JobProcessor; } });
10
10
  Object.defineProperty(exports, "Job", { enumerable: true, get: function () { return job_processor_1.Job; } });
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,qCAAkC;AACzB,uFADA,eAAM,OACA;AAEf,2DAAuD;AAC9C,iGADA,oCAAgB,OACA;AAEzB,mDAAoD;AAC3C,6FADA,4BAAY,OACA;AAAE,oFADA,mBAAG,OACA"}
@@ -1,21 +1,38 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
10
27
  };
11
28
  Object.defineProperty(exports, "__esModule", { value: true });
12
29
  exports.JobProcessor = exports.Job = exports.ReadArrayStream = void 0;
13
- const _ = require("lodash");
14
- const ps = require("promise-streams");
30
+ const _ = __importStar(require("lodash"));
31
+ const ps = __importStar(require("promise-streams"));
15
32
  const stream_1 = require("stream");
16
- const through2 = require("through2");
17
- const readdirp = require("readdirp");
18
- const path = require("path");
33
+ const through2 = __importStar(require("through2"));
34
+ const readdirp_1 = __importDefault(require("readdirp"));
35
+ const path = __importStar(require("path"));
19
36
  const events_1 = require("events");
20
37
  const utils_1 = require("./utils");
21
38
  class ReadArrayStream extends stream_1.Readable {
@@ -48,18 +65,16 @@ class Job extends events_1.EventEmitter {
48
65
  this.once('done', () => this.done = true);
49
66
  this.once('error', (err) => this.error = err);
50
67
  }
51
- wait() {
52
- return __awaiter(this, void 0, void 0, function* () {
53
- if (this.error) {
54
- throw this.error;
55
- }
56
- if (this.done) {
57
- return;
58
- }
59
- return new Promise((resolve, reject) => {
60
- this.once('done', resolve);
61
- this.once('error', reject);
62
- });
68
+ async wait() {
69
+ if (this.error) {
70
+ throw this.error;
71
+ }
72
+ if (this.done) {
73
+ return;
74
+ }
75
+ return new Promise((resolve, reject) => {
76
+ this.once('done', resolve);
77
+ this.once('error', reject);
63
78
  });
64
79
  }
65
80
  }
@@ -72,108 +87,105 @@ class JobProcessor {
72
87
  processor: null
73
88
  });
74
89
  }
75
- start(tasks, job, verbose = false, ignoreErrors = false, ignoreSelfSigned = false) {
76
- return __awaiter(this, void 0, void 0, function* () {
77
- job = job || new Job();
78
- tasks = tasks || this.jobInfo.tasks;
79
- const concurrency = this.jobInfo.options.concurrency;
80
- this.taskStream = ps.map({ concurrent: concurrency }, (task) => {
81
- return this.jobInfo.options.processor.process(task, verbose, ignoreErrors, ignoreSelfSigned).then((body) => {
82
- const logColor = (0, utils_1.stringToChalk)(task.name);
83
- if (verbose) {
84
- const processed = (0, utils_1.processResponse)(body);
85
- console.log(`[${logColor(task.name)}] Completed`, JSON.stringify(processed));
86
- }
87
- else {
88
- console.log(`[${logColor(task.name)}] Completed`);
89
- }
90
- task.inputTask.processing--;
91
- task.progress.value = 100; // task complete
92
- job.emit('progress', task);
93
- });
90
+ async start(tasks, job, verbose = false, ignoreErrors = false, ignoreSelfSigned = false) {
91
+ job = job || new Job();
92
+ tasks = tasks || this.jobInfo.tasks;
93
+ const concurrency = this.jobInfo.options.concurrency;
94
+ this.taskStream = ps.map({ concurrent: concurrency }, (task) => {
95
+ return this.jobInfo.options.processor.process(task, verbose, ignoreErrors, ignoreSelfSigned).then((body) => {
96
+ const logColor = (0, utils_1.stringToChalk)(task.name);
97
+ if (verbose) {
98
+ const processed = (0, utils_1.processResponse)(body);
99
+ console.log(`[${logColor(task.name)}] Completed`, JSON.stringify(processed));
100
+ }
101
+ else {
102
+ console.log(`[${logColor(task.name)}] Completed`);
103
+ }
104
+ task.inputTask.processing--;
105
+ task.progress.value = 100; // task complete
106
+ job.emit('progress', task);
94
107
  });
95
- this.taskStream.setMaxListeners(100);
96
- const inputTaskStream = new ReadArrayStream({
97
- objectMode: true
98
- }, tasks);
99
- inputTaskStream.pipe(through2.obj((task, enc, cb) => __awaiter(this, void 0, void 0, function* () {
100
- const operation = task.operation;
101
- yield this[operation].apply(this, [task, job]);
102
- cb();
103
- })));
104
- yield ps.wait(inputTaskStream);
105
- this.taskStream.on('error', (err) => {
106
- job.emit('error', err);
107
- });
108
- const tasksStreamEnded = ps.wait(this.taskStream);
109
- // Wait until the task stream emitted 'end'
110
- tasksStreamEnded.then(() => {
111
- job.emit('done');
112
- });
113
- return job;
114
108
  });
109
+ this.taskStream.setMaxListeners(100);
110
+ const inputTaskStream = new ReadArrayStream({
111
+ objectMode: true
112
+ }, tasks);
113
+ inputTaskStream.pipe(through2.obj(async (task, enc, cb) => {
114
+ const operation = task.operation;
115
+ await this[operation].apply(this, [task, job]);
116
+ cb();
117
+ }));
118
+ await ps.wait(inputTaskStream);
119
+ this.taskStream.on('error', (err) => {
120
+ job.emit('error', err);
121
+ });
122
+ const tasksStreamEnded = ps.wait(this.taskStream);
123
+ // Wait until the task stream emitted 'end'
124
+ tasksStreamEnded.then(() => {
125
+ job.emit('done');
126
+ });
127
+ return job;
115
128
  }
116
- sync(task, job) {
117
- return __awaiter(this, void 0, void 0, function* () {
118
- const pathOptions = {
119
- fileFilter: (entry) => {
120
- return true;
121
- },
122
- depth: 1,
123
- lstat: true
124
- };
125
- const pathSegments = [process.cwd()];
126
- if (!_.isUndefined(this.jobInfo.base)) {
127
- pathSegments.push(this.jobInfo.base);
128
- }
129
- if (!_.isUndefined(task.src)) {
130
- pathSegments.push(task.src);
131
- }
132
- pathOptions.fileFilter = task.filter || pathOptions.fileFilter;
133
- if (task.depth) {
134
- pathOptions.depth = task.depth;
135
- }
136
- else {
137
- delete pathOptions.depth;
138
- }
139
- const fileItemStream = readdirp(path.join.apply(this, pathSegments), pathOptions);
140
- yield new Promise((resolve, reject) => {
141
- fileItemStream
142
- .on('warn', (warn) => {
143
- job.emit('warn', warn);
144
- })
145
- .on('error', (err) => {
146
- job.emit('error', err);
147
- })
148
- .on('data', (fileItem) => {
149
- fileItem.progress = {
150
- value: 0
151
- };
152
- _.merge(fileItem, task);
153
- if (!task.processing) {
154
- task.processing = 0;
155
- }
156
- task.processing++;
157
- fileItem.inputTask = task;
158
- job.emit('progress', fileItem);
159
- resolve(job);
160
- })
161
- .on('end', () => {
162
- if (!this.processedTasks) {
163
- this.processedTasks = 0;
164
- }
165
- this.processedTasks++;
166
- // Check processedTasks tasks
167
- // Manually emit `end` event for all tasks finished
168
- if (this.processedTasks === this.jobInfo.tasks.length) {
169
- this.taskStream._flush(() => {
170
- });
171
- this.taskStream.end();
172
- }
173
- })
174
- .pipe(this.taskStream, { end: false });
175
- });
129
+ async sync(task, job) {
130
+ const pathOptions = {
131
+ fileFilter: (entry) => {
132
+ return true;
133
+ },
134
+ depth: 1,
135
+ lstat: true
136
+ };
137
+ const pathSegments = [process.cwd()];
138
+ if (!_.isUndefined(this.jobInfo.base)) {
139
+ pathSegments.push(this.jobInfo.base);
140
+ }
141
+ if (!_.isUndefined(task.src)) {
142
+ pathSegments.push(task.src);
143
+ }
144
+ pathOptions.fileFilter = task.filter || pathOptions.fileFilter;
145
+ if (task.depth) {
146
+ pathOptions.depth = task.depth;
147
+ }
148
+ else {
149
+ delete pathOptions.depth;
150
+ }
151
+ const fileItemStream = (0, readdirp_1.default)(path.join.apply(this, pathSegments), pathOptions);
152
+ await new Promise((resolve, reject) => {
153
+ fileItemStream
154
+ .on('warn', (warn) => {
155
+ job.emit('warn', warn);
156
+ })
157
+ .on('error', (err) => {
158
+ job.emit('error', err);
159
+ })
160
+ .on('data', (fileItem) => {
161
+ fileItem.progress = {
162
+ value: 0
163
+ };
164
+ _.merge(fileItem, task);
165
+ if (!task.processing) {
166
+ task.processing = 0;
167
+ }
168
+ task.processing++;
169
+ fileItem.inputTask = task;
170
+ job.emit('progress', fileItem);
171
+ resolve(job);
172
+ })
173
+ .on('end', () => {
174
+ if (!this.processedTasks) {
175
+ this.processedTasks = 0;
176
+ }
177
+ this.processedTasks++;
178
+ // Check processedTasks tasks
179
+ // Manually emit `end` event for all tasks finished
180
+ if (this.processedTasks === this.jobInfo.tasks.length) {
181
+ this.taskStream._flush(() => {
182
+ });
183
+ this.taskStream.end();
184
+ }
185
+ })
186
+ .pipe(this.taskStream, { end: false });
176
187
  });
177
188
  }
178
189
  }
179
190
  exports.JobProcessor = JobProcessor;
191
+ //# sourceMappingURL=job_processor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"job_processor.js","sourceRoot":"","sources":["../src/job_processor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAA4B;AAC5B,oDAAsC;AACtC,mCAAkC;AAClC,mDAAqC;AACrC,wDAAgC;AAChC,2CAA6B;AAC7B,mCAAsC;AACtC,mCAAyD;AAEzD,MAAa,eAAgB,SAAQ,iBAAQ;IAG3C,YAAY,IAAS,EAAE,KAAY;QACjC,KAAK,CAAC,IAAI,CAAC,CAAC;QACZ,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;IAED,KAAK;QACH,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;YACvC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;YAChC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SACjB;aAAM;YACL,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SACjB;IACH,CAAC;CACF;AAhBD,0CAgBC;AAED;;;GAGG;AACH,MAAa,GAAI,SAAQ,qBAAY;IAKnC,YAAY,IAAU;QACpB,KAAK,EAAE,CAAC;QAJV,SAAI,GAAG,KAAK,CAAC;QACb,UAAK,GAAG,SAAS,CAAC;QAIhB,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;QAC1B,IAAI,C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,CAAC;iBACzB;gBACD,IAAI,CAAC,cAAc,EAAE,CAAC;gBACtB,6BAA6B;gBAC7B,mDAAmD;gBACnD,IAAI,IAAI,CAAC,cAAc,KAAK,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE;oBACrD,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,EAAE;oBAC5B,CAAC,CAAC,CAAC;oBACH,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC;iBACvB;YACH,CAAC,CAAC;iBACD,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,EAAC,GAAG,EAAE,KAAK,EAAC,CAAC,CAAC;QACzC,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA9HD,oCA8HC"}
@@ -1,17 +1,31 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
10
24
  };
11
25
  Object.defineProperty(exports, "__esModule", { value: true });
12
26
  exports.GraphQLProcessor = void 0;
13
- const _ = require("lodash");
14
- const fs = require("fs");
27
+ const _ = __importStar(require("lodash"));
28
+ const fs = __importStar(require("fs"));
15
29
  const index_1 = require("./index");
16
30
  const yaml_document_stream_1 = require("yaml-document-stream");
17
31
  const utils_1 = require("./utils");
@@ -30,88 +44,41 @@ class GraphQLProcessor {
30
44
  this.opts = opts;
31
45
  this.client = new index_1.Client(opts);
32
46
  }
33
- process(task, verbose = false, ignoreErrors = false, ignoreSelfSigned = false) {
34
- return __awaiter(this, void 0, void 0, function* () {
35
- let yamlStream = new yaml_document_stream_1.YamlStreamReadTransformer();
36
- let jobPath = task.path;
37
- let data = false;
38
- const logColor = (0, utils_1.stringToChalk)(task.name);
39
- switch (task.operation) {
40
- case 'sync': { // synchronous operation
41
- return new Promise((resolve, reject) => {
42
- try {
43
- yamlStream.on('error', (err) => {
44
- !ignoreErrors && reject(err);
45
- });
46
- const fileStream = fs.createReadStream(task.fullPath);
47
- fileStream.pipe(yamlStream);
48
- let batchsize;
49
- if (task.batchSize) {
50
- batchsize = task.batchSize;
51
- console.log(`[${logColor(task.name)}] Batch size:`, batchsize);
52
- }
53
- let counter = 0;
54
- let batchCounter = 0;
55
- let docArr = [];
56
- let resultArr = [];
57
- // Here we read from the readable stream each yaml document parsed
58
- // as an object, and if we have batching enabled we first batch this
59
- // documents into smaller sets. When a dataset is ready to be imported,
60
- // we pause the readable stream and emit a 'pause' event and
61
- // right after that we reset the dataset object 'docArr'.
62
- yamlStream.on('data', (doc) => {
63
- data = true;
64
- if (batchsize) {
65
- docArr.push(doc);
66
- counter++;
67
- if (counter === batchsize) {
68
- counter = 0;
69
- let batchText = '';
70
- if (batchsize > 0) {
71
- const from = batchCounter * batchsize + 1;
72
- const to = from + (docArr.length - 1);
73
- batchText = from == to ? ` (${from})` : ` (${from} - ${to})`;
74
- }
75
- batchCounter++;
76
- console.log(`[${logColor(task.name)}] Processing batch: ${batchCounter}${batchText}`);
77
- yamlStream.pause();
78
- docArr = [];
79
- }
80
- }
81
- else {
82
- docArr.push(doc);
83
- }
84
- });
85
- // On 'pause' event we create a post request using the GQL Client
86
- // using the accumulated resources inside the 'docArr' dataset,
87
- // we wait for the response, store the response inside an array and
88
- // only then we emit a 'resume' event, resuming reading from the
89
- // 'yamlStream' readable stream.
90
- yamlStream.on('pause', () => __awaiter(this, void 0, void 0, function* () {
91
- try {
92
- resultArr.push(yield this.client.post(docArr, task, verbose, ignoreErrors, ignoreSelfSigned));
93
- yamlStream.resume();
94
- }
95
- catch (e) {
96
- !ignoreErrors && reject(e);
97
- ignoreErrors && yamlStream.resume();
98
- }
99
- }));
100
- let runOnResume;
101
- yamlStream.on('resume', () => __awaiter(this, void 0, void 0, function* () {
102
- if (runOnResume) {
103
- runOnResume();
104
- }
105
- }));
106
- // On 'end' if we still have data accumulated inside the 'docArr'
107
- // dataset, we create a final post request to import this data as-well,
108
- // store the response inside the array and finally resolve this as a
109
- // Promise to return all the responses back to the initial caller.
110
- const endFunc = () => __awaiter(this, void 0, void 0, function* () {
111
- if (data === false) {
112
- throw new Error(`Could not import resources from ${jobPath}. Readable stream is empty. Please provide a file with YAML multi-document format.`);
113
- }
114
- if (docArr && !_.isEmpty(docArr)) {
47
+ async process(task, verbose = false, ignoreErrors = false, ignoreSelfSigned = false) {
48
+ let yamlStream = new yaml_document_stream_1.YamlStreamReadTransformer();
49
+ let jobPath = task.path;
50
+ let data = false;
51
+ const logColor = (0, utils_1.stringToChalk)(task.name);
52
+ switch (task.operation) {
53
+ case 'sync': { // synchronous operation
54
+ return new Promise((resolve, reject) => {
55
+ try {
56
+ yamlStream.on('error', (err) => {
57
+ !ignoreErrors && reject(err);
58
+ });
59
+ const fileStream = fs.createReadStream(task.fullPath);
60
+ fileStream.pipe(yamlStream);
61
+ let batchsize;
62
+ if (task.batchSize) {
63
+ batchsize = task.batchSize;
64
+ console.log(`[${logColor(task.name)}] Batch size:`, batchsize);
65
+ }
66
+ let counter = 0;
67
+ let batchCounter = 0;
68
+ let docArr = [];
69
+ let resultArr = [];
70
+ // Here we read from the readable stream each yaml document parsed
71
+ // as an object, and if we have batching enabled we first batch this
72
+ // documents into smaller sets. When a dataset is ready to be imported,
73
+ // we pause the readable stream and emit a 'pause' event and
74
+ // right after that we reset the dataset object 'docArr'.
75
+ yamlStream.on('data', (doc) => {
76
+ data = true;
77
+ if (batchsize) {
78
+ docArr.push(doc);
79
+ counter++;
80
+ if (counter === batchsize) {
81
+ counter = 0;
115
82
  let batchText = '';
116
83
  if (batchsize > 0) {
117
84
  const from = batchCounter * batchsize + 1;
@@ -120,35 +87,81 @@ class GraphQLProcessor {
120
87
  }
121
88
  batchCounter++;
122
89
  console.log(`[${logColor(task.name)}] Processing batch: ${batchCounter}${batchText}`);
123
- try {
124
- resultArr.push(yield this.client.post(docArr, task, verbose, ignoreErrors, ignoreSelfSigned));
125
- }
126
- catch (e) {
127
- !ignoreErrors && reject(e);
128
- }
90
+ yamlStream.pause();
129
91
  docArr = [];
130
92
  }
131
- resolve(resultArr);
132
- });
133
- yamlStream.on('end', () => {
134
- if (yamlStream.isPaused()) {
135
- runOnResume = endFunc;
93
+ }
94
+ else {
95
+ docArr.push(doc);
96
+ }
97
+ });
98
+ // On 'pause' event we create a post request using the GQL Client
99
+ // using the accumulated resources inside the 'docArr' dataset,
100
+ // we wait for the response, store the response inside an array and
101
+ // only then we emit a 'resume' event, resuming reading from the
102
+ // 'yamlStream' readable stream.
103
+ yamlStream.on('pause', async () => {
104
+ try {
105
+ resultArr.push(await this.client.post(docArr, task, verbose, ignoreErrors, ignoreSelfSigned));
106
+ yamlStream.resume();
107
+ }
108
+ catch (e) {
109
+ !ignoreErrors && reject(e);
110
+ ignoreErrors && yamlStream.resume();
111
+ }
112
+ });
113
+ let runOnResume;
114
+ yamlStream.on('resume', async () => {
115
+ if (runOnResume) {
116
+ runOnResume();
117
+ }
118
+ });
119
+ // On 'end' if we still have data accumulated inside the 'docArr'
120
+ // dataset, we create a final post request to import this data as-well,
121
+ // store the response inside the array and finally resolve this as a
122
+ // Promise to return all the responses back to the initial caller.
123
+ const endFunc = async () => {
124
+ if (data === false) {
125
+ throw new Error(`Could not import resources from ${jobPath}. Readable stream is empty. Please provide a file with YAML multi-document format.`);
126
+ }
127
+ if (docArr && !_.isEmpty(docArr)) {
128
+ let batchText = '';
129
+ if (batchsize > 0) {
130
+ const from = batchCounter * batchsize + 1;
131
+ const to = from + (docArr.length - 1);
132
+ batchText = from == to ? ` (${from})` : ` (${from} - ${to})`;
133
+ }
134
+ batchCounter++;
135
+ console.log(`[${logColor(task.name)}] Processing batch: ${batchCounter}${batchText}`);
136
+ try {
137
+ resultArr.push(await this.client.post(docArr, task, verbose, ignoreErrors, ignoreSelfSigned));
136
138
  }
137
- else {
138
- endFunc();
139
+ catch (e) {
140
+ !ignoreErrors && reject(e);
139
141
  }
140
- });
141
- }
142
- catch (e) {
143
- !ignoreErrors && reject(e);
144
- }
145
- });
146
- }
147
- default: {
148
- throw new Error('Unsupported job operation');
149
- }
142
+ docArr = [];
143
+ }
144
+ resolve(resultArr);
145
+ };
146
+ yamlStream.on('end', () => {
147
+ if (yamlStream.isPaused()) {
148
+ runOnResume = endFunc;
149
+ }
150
+ else {
151
+ endFunc();
152
+ }
153
+ });
154
+ }
155
+ catch (e) {
156
+ !ignoreErrors && reject(e);
157
+ }
158
+ });
150
159
  }
151
- });
160
+ default: {
161
+ throw new Error('Unsupported job operation');
162
+ }
163
+ }
152
164
  }
153
165
  }
154
166
  exports.GraphQLProcessor = GraphQLProcessor;
167
+ //# sourceMappingURL=job_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gBACP,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;aAC9C;SACF;IACH,CAAC;CACF;AA3ID,4CA2IC"}
package/lib/utils.d.ts CHANGED
@@ -1,3 +1,2 @@
1
- import * as chalk from 'chalk';
2
- export declare const stringToChalk: (str: any) => chalk.Chalk;
1
+ export declare const stringToChalk: (str: any) => any;
3
2
  export declare const processResponse: (body: any | any[]) => any;
package/lib/utils.js CHANGED
@@ -1,8 +1,11 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.processResponse = exports.stringToChalk = void 0;
4
- const color_hash_1 = require("color-hash");
5
- const chalk = require("chalk");
7
+ const color_hash_1 = __importDefault(require("color-hash"));
8
+ const chalk = require('chalk');
6
9
  const colorHash = new color_hash_1.default({
7
10
  lightness: [0.45, 0.6, 0.75]
8
11
  });
@@ -38,3 +41,4 @@ const processResponse = (body) => {
38
41
  return result;
39
42
  };
40
43
  exports.processResponse = processResponse;
44
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;;;;AAAA,4DAAmC;AACnC,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAE/B,MAAM,SAAS,GAAG,IAAI,oBAAS,CAAC;IAC9B,SAAS,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC;CAC7B,CAAC,CAAC;AAEI,MAAM,aAAa,GAAG,CAAC,GAAG,EAAE,EAAE;IACnC,OAAO,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;AACvC,CAAC,CAAC;AAFW,QAAA,aAAa,iBAExB;AAEF,MAAM,MAAM,GAAG,CAAC,IAAS,EAAO,EAAE;IAChC,IAAI,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@
2
2
  "name": "@restorecommerce/gql-bot",
3
3
  "description": "GraphQL Client Automated Task Processor",
4
4
  "main": "lib/index",
5
- "version": "1.0.1",
5
+ "version": "1.0.3",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/restorecommerce/libs.git"
@@ -20,7 +20,7 @@
20
20
  "apollo-client": "^2.6.10",
21
21
  "apollo-link-http": "^1.5.17",
22
22
  "chalk": "^4.1.2",
23
- "color-hash": "^2.0.1",
23
+ "color-hash": "^2.0.2",
24
24
  "graphql": "^15.5.0",
25
25
  "graphql-tag": "^2.12.6",
26
26
  "js-yaml": "^4.1.0",
@@ -33,24 +33,24 @@
33
33
  },
34
34
  "devDependencies": {
35
35
  "@types/color-hash": "^1.0.2",
36
- "@types/mocha": "^10.0.0",
37
- "@types/node": "^18.8.5",
38
- "@typescript-eslint/eslint-plugin": "^5.40.0",
39
- "@typescript-eslint/parser": "^5.40.0",
36
+ "@types/mocha": "^10.0.1",
37
+ "@types/node": "^20.2.5",
38
+ "@typescript-eslint/eslint-plugin": "^5.59.7",
39
+ "@typescript-eslint/parser": "^5.59.7",
40
40
  "coveralls": "^3.1.1",
41
- "eslint": "^8.25.0",
41
+ "eslint": "^8.41.0",
42
42
  "eslint-plugin-prefer-arrow-functions": "^3.1.4",
43
- "mocha": "^10.0.0",
44
- "nock": "^13.2.9",
43
+ "mocha": "^10.2.0",
44
+ "nock": "^13.3.1",
45
45
  "npm-run-all": "^4.1.5",
46
46
  "nyc": "^15.1.0",
47
47
  "should": "^13.2.3",
48
48
  "ts-node": "^10.9.1",
49
- "typescript": "^4.8.4"
49
+ "typescript": "^5.0.4"
50
50
  },
51
51
  "scripts": {
52
52
  "pretest": "npm run lint",
53
- "test": "nyc mocha",
53
+ "test": "mocha --full-trace --exit",
54
54
  "lint": "eslint './src/**/*.ts'",
55
55
  "build:tsc": "tsc -d",
56
56
  "build:clean": "rimraf lib",
@@ -71,5 +71,5 @@
71
71
  }
72
72
  }
73
73
  },
74
- "gitHead": "64f3de896ab288cfa71e66aafe6e01ab3e37af26"
74
+ "gitHead": "1c4ac0aaccaa55439930b96256d6db3884690cb0"
75
75
  }
@@ -2,7 +2,7 @@ import * as _ from 'lodash';
2
2
  import * as ps from 'promise-streams';
3
3
  import { Readable } from 'stream';
4
4
  import * as through2 from 'through2';
5
- import * as readdirp from 'readdirp';
5
+ import readdirp from 'readdirp';
6
6
  import * as path from 'path';
7
7
  import { EventEmitter } from 'events';
8
8
  import { stringToChalk, processResponse } from './utils';
package/src/utils.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import ColorHash from 'color-hash';
2
- import * as chalk from 'chalk';
2
+ const chalk = require('chalk');
3
3
 
4
4
  const colorHash = new ColorHash({
5
5
  lightness: [0.45, 0.6, 0.75]
package/tsconfig.json CHANGED
@@ -1,16 +1,24 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "target": "ES6",
3
+ "target": "ES2021",
4
4
  "module": "commonjs",
5
5
  "moduleResolution": "node",
6
+ "declaration": true,
7
+ // "strict": true,
6
8
  "emitDecoratorMetadata": true,
7
9
  "experimentalDecorators": true,
8
10
  "allowSyntheticDefaultImports": true,
9
11
  "noUnusedLocals": false,
10
- "skipLibCheck": false,
12
+ "skipLibCheck": true,
13
+ "esModuleInterop": true,
14
+ "sourceMap": true,
11
15
  "outDir": "lib",
12
16
  "typeRoots": [
13
17
  "node_modules/@types"
18
+ ],
19
+ "lib": [
20
+ "es2020.promise",
21
+ "dom"
14
22
  ]
15
23
  },
16
24
  "include": [
@@ -19,7 +27,6 @@
19
27
  "exclude": [
20
28
  "node_modules",
21
29
  "lib",
22
- "doc",
23
- "**/*.test.ts"
30
+ "doc"
24
31
  ]
25
32
  }