record-replay-req-res-scenario 21.0.14 → 21.0.17

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.
Files changed (60) hide show
  1. package/browser/package.json +1 -1
  2. package/browser-prod/package.json +1 -1
  3. package/browser-prod.re-export.json +1 -0
  4. package/lib/build-info._auto-generated_.d.ts +1 -1
  5. package/lib/build-info._auto-generated_.js +1 -1
  6. package/lib/package.json +1 -1
  7. package/lib-prod/build-info._auto-generated_.js +14 -30
  8. package/lib-prod/env/env.angular-node-app.js +130 -71
  9. package/lib-prod/env/env.docs-webapp.js +130 -71
  10. package/lib-prod/env/env.electron-app.js +130 -71
  11. package/lib-prod/env/env.mobile-app.js +130 -71
  12. package/lib-prod/env/env.npm-lib-and-cli-tool.js +130 -71
  13. package/lib-prod/env/env.vscode-plugin.js +130 -71
  14. package/lib-prod/env/index.js +6 -23
  15. package/lib-prod/index._auto-generated_.js +0 -6
  16. package/lib-prod/index.js +3 -9
  17. package/lib-prod/migrations/index.js +1 -19
  18. package/lib-prod/migrations/migrations_index._auto-generated_.js +0 -4
  19. package/lib-prod/package.json +1 -1
  20. package/lib-prod/record-replay-req-res-scenario.js +0 -372
  21. package/lib-prod/scenario.backend.js +0 -232
  22. package/lib-prod/start.backend.js +0 -20
  23. package/lib-prod/tape.backend.js +0 -28
  24. package/lib-prod.re-export.json +1 -0
  25. package/package.json +2 -1
  26. package/websql/package.json +1 -1
  27. package/websql-prod/package.json +1 -1
  28. package/websql-prod.re-export.json +1 -0
  29. package/lib-prod/build-info._auto-generated_.d.ts +0 -24
  30. package/lib-prod/build-info._auto-generated_.js.map +0 -1
  31. package/lib-prod/env/env.angular-node-app.d.ts +0 -64
  32. package/lib-prod/env/env.angular-node-app.js.map +0 -1
  33. package/lib-prod/env/env.docs-webapp.d.ts +0 -64
  34. package/lib-prod/env/env.docs-webapp.js.map +0 -1
  35. package/lib-prod/env/env.electron-app.d.ts +0 -64
  36. package/lib-prod/env/env.electron-app.js.map +0 -1
  37. package/lib-prod/env/env.mobile-app.d.ts +0 -64
  38. package/lib-prod/env/env.mobile-app.js.map +0 -1
  39. package/lib-prod/env/env.npm-lib-and-cli-tool.d.ts +0 -64
  40. package/lib-prod/env/env.npm-lib-and-cli-tool.js.map +0 -1
  41. package/lib-prod/env/env.vscode-plugin.d.ts +0 -64
  42. package/lib-prod/env/env.vscode-plugin.js.map +0 -1
  43. package/lib-prod/env/index.d.ts +0 -6
  44. package/lib-prod/env/index.js.map +0 -1
  45. package/lib-prod/index._auto-generated_.d.ts +0 -0
  46. package/lib-prod/index._auto-generated_.js.map +0 -1
  47. package/lib-prod/index.d.ts +0 -1
  48. package/lib-prod/index.js.map +0 -1
  49. package/lib-prod/migrations/index.d.ts +0 -1
  50. package/lib-prod/migrations/index.js.map +0 -1
  51. package/lib-prod/migrations/migrations_index._auto-generated_.d.ts +0 -0
  52. package/lib-prod/migrations/migrations_index._auto-generated_.js.map +0 -1
  53. package/lib-prod/record-replay-req-res-scenario.d.ts +0 -0
  54. package/lib-prod/record-replay-req-res-scenario.js.map +0 -1
  55. package/lib-prod/scenario.backend.d.ts +0 -0
  56. package/lib-prod/scenario.backend.js.map +0 -1
  57. package/lib-prod/start.backend.d.ts +0 -0
  58. package/lib-prod/start.backend.js.map +0 -1
  59. package/lib-prod/tape.backend.d.ts +0 -0
  60. package/lib-prod/tape.backend.js.map +0 -1
@@ -1,372 +0,0 @@
1
- // //#region imports
2
- // //#region @backend
3
- // import * as _ from 'lodash';
4
- // import * as path from 'path';
5
- // import { Helpers, BaseProject as Project } from 'tnp-helpers';
6
- // import { URL } from 'url';
7
- // import { config } from 'tnp-core';
8
- // import * as moment from 'moment';
9
- // import { talkback, Options, RecordMode } from 'ng-talkback';
10
- // import * as glob from 'glob';
11
- // import { Scenario, ScenarioParam, ScenarioParams, ScenarioParamsReturn } from './scenario.backend';
12
- // import chalk from 'chalk';
13
- // import * as inquirer from 'inquirer';
14
- // // import { Models } from 'tnp-models';
15
- // //#endregion
16
- // //#endregion
17
- // //#region models
18
- // export type RecordData = { host: number | string | URL; talkbackProxyPort?: number | string; }
19
- // export type RecorderConfigMeta = {
20
- // [recordHostName: string]: RecordData;
21
- // } & { scenarioName: string; }
22
- // export type ReplayConfigMeta = {
23
- // [recordHostName: string]: { talkbackProxyPort?: number | string; }
24
- // } & { scenarioPath: string; }
25
- // type ArgsOptReplayRecordArgType = { port: string | string[]; hostName: string | string[]; };
26
- // interface RecordArgType {
27
- // record: {
28
- // /**
29
- // * url with host to record
30
- // */
31
- // url: URL;
32
- // /**
33
- // * Identifier of what was the name or id of server.
34
- // * this metadata is usefull to replay back multiple servers
35
- // * on different talkback ports
36
- // */
37
- // name: string;
38
- // };
39
- // /**
40
- // * talkback port for localhost proxy
41
- // */
42
- // talkbackProxyPort: number;
43
- // }
44
- // //#endregion
45
- // export class RecordReplayReqResScenario {
46
- // //#region @backend
47
- // //#region consts
48
- // /**
49
- // * by pinging to http://localhost:5544/path/to/something
50
- // * you are actually recording request from
51
- // * by pinging to http://< host for recording >/path/to/something
52
- // */
53
- // readonly DEFAULT_TALKBACK_PROXY_SERVER_PORT = 5544;
54
- // //#endregion
55
- // //#region singleton
56
- // private static _instances = {};
57
- // private constructor(
58
- // protected readonly cwd = process.cwd()
59
- // ) {
60
- // const pathToScenarios = path.join(cwd, config.folder.scenarios);
61
- // const pathToScenariosTemp = path.join(cwd, config.folder.tmpScenarios);
62
- // if (!Helpers.exists(pathToScenarios)) {
63
- // Helpers.createSymLink(pathToScenariosTemp, pathToScenarios,
64
- // { continueWhenExistedFolderDoesntExists: true })
65
- // }
66
- // }
67
- // public static Instance(cwd = process.cwd()) {
68
- // if (!RecordReplayReqResScenario._instances[cwd]) {
69
- // RecordReplayReqResScenario._instances[cwd] = new RecordReplayReqResScenario(cwd);
70
- // }
71
- // return RecordReplayReqResScenario._instances[cwd] as RecordReplayReqResScenario;
72
- // }
73
- // //#endregion
74
- // //#region resolve recoard args
75
- // private resolveArgsRecord(serverHostOrPort: string | string[] | RecorderConfigMeta)
76
- // : { args: RecordArgType[]; scenarioName: string; } {
77
- // const results = [] as RecordArgType[];
78
- // const configMeta = ((_.isObject(serverHostOrPort) && !_.isArray(serverHostOrPort))
79
- // ? serverHostOrPort : void 0) as RecorderConfigMeta;
80
- // let scenarioName = '' as string;
81
- // let talkbackPorts = [this.DEFAULT_TALKBACK_PROXY_SERVER_PORT];
82
- // if (configMeta) {
83
- // //#region by config
84
- // scenarioName = configMeta.scenarioName;
85
- // _.keys(configMeta)
86
- // .filter(key => _.isObject(configMeta[key]))
87
- // .forEach((name, i) => {
88
- // const url = Helpers.urlParse(configMeta[name].host);
89
- // results.push({
90
- // record: {
91
- // name,
92
- // url
93
- // },
94
- // talkbackProxyPort: Number(configMeta[name].talkbackProxyPort) + i
95
- // })
96
- // })
97
- // //#endregion
98
- // } else {
99
- // //#region by command line argument
100
- // const { commandString, resolved } = Helpers.cliTool.argsFromBegin<URL>(
101
- // serverHostOrPort as string,
102
- // a => Helpers.urlParse(a)
103
- // );
104
- // scenarioName = commandString;
105
- // let options = Helpers.cliTool.argsFrom<{ port: string; hostName: string; }>(scenarioName);
106
- // scenarioName = Helpers.cliTool.cleanCommand(scenarioName, options);
107
- // if (_.isArray(options.port)) {
108
- // talkbackPorts = options.port;
109
- // } else if (!isNaN(Number(options.port))) {
110
- // talkbackPorts = [Number(options.port)];
111
- // }
112
- // const hostName = _.isString(options.hostName) ? [options.hostName]
113
- // : (_.isArray(options.hostName) ? options.hostName : [])
114
- // if (talkbackPorts.length === 0) {
115
- // Helpers.error(`[rec-scenario-rep-rec] Incorrect configuration of ports:
116
- // recordHosts = ${resolved.map(c => Helpers.urlParse(c)).join(', ')}
117
- // talkback ports = ${talkbackPorts.join(', ')}
118
- // `, false, true);
119
- // }
120
- // if (talkbackPorts.length < resolved.length) {
121
- // const lastN = talkbackPorts[talkbackPorts.length - 1];
122
- // _.times((resolved.length - talkbackPorts.length), (i) => talkbackPorts.push(lastN + (i + 1)));
123
- // }
124
- // resolved.forEach((recordHost, i) => {
125
- // results.push({
126
- // record: {
127
- // name: hostName[i] ? hostName[i] : '',
128
- // url: recordHost
129
- // },
130
- // talkbackProxyPort: talkbackPorts[i]
131
- // })
132
- // });
133
- // //#endregion
134
- // }
135
- // return { args: results, scenarioName };
136
- // }
137
- // //#endregion
138
- // //#region command from config
139
- // public recordAsWorker(config: RecorderConfigMeta, cwd: string = process.cwd()) {
140
- // const hosts = Object
141
- // .keys(config)
142
- // .filter(hostName => _.isObject(config[hostName]))
143
- // .map(hostName => {
144
- // const v = config[hostName] as RecordData;
145
- // return (v.host as URL).origin;
146
- // });
147
- // const portName = Object
148
- // .keys(config)
149
- // .filter(hostName => _.isObject(config[hostName]))
150
- // .map(hostName => {
151
- // const v = config[hostName] as RecordData;
152
- // return `--port ${v.talkbackProxyPort} --hostName ${hostName}`
153
- // })
154
- // let command = `record-replay-req-res-scenario record ${hosts.join(' ')} '${config.scenarioName}' ${portName.join(' ')}`;
155
- // Helpers.run(command, { cwd }).async();
156
- // }
157
- // //#endregion
158
- // //#region record
159
- // /**
160
- // * rest-scenario-rep-rec record http://localhost:4444 Recording localhost data
161
- // * rest-scenario-rep-rec record http://192.168.10.22:4444 Test scenario
162
- // * rest-scenario-rep-rec record 4444 local setup test
163
- // * rest-scenario-rep-rec record 4444 5555 http://192.168.12.3 "my super scenario"
164
- // * rest-scenario-rep-rec record 4444 5555 http://192.168.12.3 192.158.32.3 'my super scenario --port 6767'
165
- // * <port or host for record > <scenario name > < talkbback server ports for proxy >
166
- // * rest-scenario-rep-rec record 4444 5555 http://my.api.com 'my super scenario --port 6767 --port 7777 --port 8888'
167
- // * ins.record( { portOrHost: http://192.129.23.12; name: 'localApiProxy' }, 'super scenario')
168
- // */
169
- // async record(serverHostOrPort: string | string[] | RecorderConfigMeta, debug = false) {
170
- // return new Promise((resolve, reject) => {
171
- // const currentDate = new Date();
172
- // let { args, scenarioName } = this.resolveArgsRecord(serverHostOrPort);
173
- // //#region prepare main scenario folder
174
- // let description = scenarioName;
175
- // if (!_.isString(scenarioName) || scenarioName.trim() === '') {
176
- // scenarioName = `new-scenario-${_.kebabCase(moment(currentDate).format('MMMM Do YYYY, h:mm:ss a'))}`;;
177
- // description = _.startCase(scenarioName);
178
- // }
179
- // const scenarioNameKebabKase = _.kebabCase(scenarioName);
180
- // const scenariosFolder = path.join(this.cwd, config.folder.tmpScenarios);
181
- // const scenarioKebabPath = path.join(scenariosFolder, scenarioNameKebabKase);
182
- // const packageJsonFroScenario = path.join(scenarioKebabPath, config.file.package_json);
183
- // if (!Helpers.exists(scenariosFolder)) {
184
- // Helpers.mkdirp(scenariosFolder);
185
- // }
186
- // Helpers.removeFolderIfExists(scenarioKebabPath);
187
- // //#endregion
188
- // //#region write package.json
189
- // Helpers.writeFile(packageJsonFroScenario, {
190
- // name: scenarioNameKebabKase,
191
- // description,
192
- // version: '0.0.0',
193
- // creationDate: currentDate.toDateString(),
194
- // scripts: {
195
- // start: 'firedev serve',
196
- // },
197
- // tnp: {
198
- // type: 'scenario',
199
- // } as any,
200
- // } as Partial<Models.npm.IPackageJSON>);
201
- // //#endregion
202
- // args.forEach(recData => {
203
- // Helpers.log(`RECORD FROM: ${recData.record.url.href}`)
204
- // const scenarioPath = path.join(
205
- // this.cwd,
206
- // config.folder.tmpScenarios,
207
- // scenarioNameKebabKase,
208
- // `${(_.kebabCase(recData.record.url.href)).toString()}__${_.camelCase(recData.record.name)}`
209
- // );
210
- // Helpers.remove(scenarioPath);
211
- // const talkbackHost = recData.record.url.origin;
212
- // debug && Helpers.info(`Talkback host: ${talkbackHost}`)
213
- // const server = talkback({
214
- // host: talkbackHost,
215
- // record: RecordMode.NEW,
216
- // port: recData.talkbackProxyPort,
217
- // path: scenarioPath,
218
- // silent: true,
219
- // // debug: true
220
- // } as Options);
221
- // server.start(() => {
222
- // Helpers.info(`"Talkback Started" on port ${recData.talkbackProxyPort} `
223
- // + `( click for test ${chalk.bold(recData.record?.name ? recData.record.name : '')} `
224
- // + `http://localhost:${recData.talkbackProxyPort}/ng-talkback-test ) => proxy to ${recData.record.url.href}`);
225
- // resolve(void 0);
226
- // });
227
- // })
228
- // });
229
- // }
230
- // //#endregion
231
- // //#region all scenaroios
232
- // public get allScenarios() {
233
- // return glob.sync(`${path.join(this.cwd, config.folder.tmpScenarios)}/*`)
234
- // .filter(f => !!Project.ins.From(f))
235
- // .map(f => Scenario.From(f))
236
- // .filter(f => !!f)
237
- // }
238
- // //#endregion
239
- // //#region select scenario
240
- // async selectScenario(goBackButtonOnList?: boolean): Promise<Scenario> {
241
- // const mainMessage = `Select scenario from list:`;
242
- // const choices = Scenario.allCurrent.map(c => {
243
- // return { name: `"${c.description}"`, value: c }
244
- // });
245
- // if (goBackButtonOnList) {
246
- // choices.push({ name: '<= Go back', value: void 0 });
247
- // }
248
- // const res = await inquirer.prompt({
249
- // type: 'list',
250
- // name: 'value',
251
- // message: mainMessage,
252
- // choices
253
- // } as any) as any;
254
- // return res.value;
255
- // }
256
- // //#endregion
257
- // //#region resolve replay args
258
- // private async resolveReplayData(
259
- // nameOrPathOrDescription: string | string[] | ReplayConfigMeta,
260
- // showListIfNotMatch = false,
261
- // goBackButtonOnList = false,
262
- // ) {
263
- // const returnValue = { scenarios: [] as Scenario[], params: void 0 as ScenarioParamsReturn }
264
- // if (_.isObject(nameOrPathOrDescription) && !_.isArray(nameOrPathOrDescription)) {
265
- // //#region config
266
- // const configMeta = nameOrPathOrDescription as ReplayConfigMeta;
267
- // const scenario = Scenario.From(configMeta.scenarioPath)
268
- // if (!scenario) {
269
- // Helpers.error(`[rest-scenario...] Scenario not found in "${configMeta.scenarioPath}"`
270
- // , false, true)
271
- // }
272
- // returnValue.scenarios = [scenario];
273
- // returnValue.params = _.pickBy(configMeta, _.isObject) as ScenarioParamsReturn;
274
- // //#endregion
275
- // } else {
276
- // //#region from command line
277
- // nameOrPathOrDescription = (_.isArray(nameOrPathOrDescription)
278
- // ? nameOrPathOrDescription.join(' ') : nameOrPathOrDescription) as string;
279
- // const options = Helpers.cliTool.argsFrom<ArgsOptReplayRecordArgType>(nameOrPathOrDescription);
280
- // nameOrPathOrDescription = Helpers.cliTool.cleanCommand(nameOrPathOrDescription, options);
281
- // const { resolved, commandString } = Helpers.cliTool
282
- // .argsFromBegin<Scenario>(nameOrPathOrDescription, possiblePathToScenario => {
283
- // const scenarioFromPath = (
284
- // path.isAbsolute(possiblePathToScenario || '') &&
285
- // Helpers.exists(possiblePathToScenario))
286
- // ? possiblePathToScenario
287
- // : path.join(
288
- // this.cwd,
289
- // config.folder.tmpScenarios,
290
- // (possiblePathToScenario || '').trim());
291
- // return Scenario.From(scenarioFromPath);
292
- // });
293
- // nameOrPathOrDescription = commandString;
294
- // let scenarios = resolved;
295
- // if (scenarios.length === 0 && commandString.trim() !== '') {
296
- // const list = this.allScenarios;
297
- // const { matches, results } = Helpers
298
- // .arrays
299
- // .fuzzy<Scenario>(nameOrPathOrDescription, list, (m) => m.description);
300
- // scenarios = scenarios.concat(results);
301
- // }
302
- // const hostName = _.isString(options.hostName) ? [options.hostName]
303
- // : (_.isArray(options.hostName) ? options.hostName : []);
304
- // const portsOrUrlsForReplayServer = (_.isString(options.port) ? [Helpers.urlParse(options.port)]
305
- // : (_.isArray(options.port) ? options.port.map(p => Helpers.urlParse(p))
306
- // : [Helpers.urlParse(this.DEFAULT_TALKBACK_PROXY_SERVER_PORT)])).filter(u => u instanceof URL);
307
- // if (portsOrUrlsForReplayServer.length === 0) {
308
- // Helpers.error(`Please provide correct number or ports and hostnames
309
- // host names = ${hostName.map(c => Helpers.urlParse(c)).join(', ')}
310
- // talkback ports = ${portsOrUrlsForReplayServer.join(', ')}
311
- // `, false, true);
312
- // }
313
- // let params = portsOrUrlsForReplayServer;
314
- // if (hostName.length > 0) {
315
- // if (hostName.length > portsOrUrlsForReplayServer.length) {
316
- // const maxPort = _.maxBy(portsOrUrlsForReplayServer, p => Number(p.port));
317
- // _.times(hostName.length - portsOrUrlsForReplayServer.length, n => {
318
- // portsOrUrlsForReplayServer.push(Helpers.urlParse(Number(maxPort.port) + (n + 1)))
319
- // });
320
- // }
321
- // params = hostName.reduce((prev, name, i) => {
322
- // return _.merge(prev, { [name]: portsOrUrlsForReplayServer[i] })
323
- // }, {}) as any;
324
- // }
325
- // returnValue.params = params as any;
326
- // returnValue.scenarios = scenarios;
327
- // //#endregion
328
- // }
329
- // //#region select menu scenraios
330
- // if (returnValue.scenarios.length === 0) {
331
- // if (showListIfNotMatch) {
332
- // const selectedScenario = await this.selectScenario(goBackButtonOnList);
333
- // returnValue.scenarios.push(selectedScenario);
334
- // }
335
- // }
336
- // //#endregion
337
- // return returnValue;
338
- // }
339
- // //#endregion
340
- // //#region replay
341
- // public async resolveScenariosData(
342
- // nameOrPathOrDescription: string | string[] | ReplayConfigMeta,
343
- // showListIfNotMatch = false,
344
- // goBackButtonOnList = false,
345
- // ) {
346
- // const { scenarios, params } = await this.resolveReplayData(
347
- // nameOrPathOrDescription,
348
- // showListIfNotMatch,
349
- // goBackButtonOnList,
350
- // );
351
- // if (scenarios.length === 0) {
352
- // Helpers.error(`[record - replay - req - res - scenario]`
353
- // + `Not able to find scenario by name or path "${nameOrPathOrDescription}"`, false, true);
354
- // }
355
- // // const tmpScenarioInfo = (s: Scenario) => {
356
- // // const paramsTmpls = _.isArray(params) ? params.map(p => ` replay on ${p}`).join(',')
357
- // // : _.keys(params).reduce((a, b) => {
358
- // // return `${a}\n\t${chalk.bold(b)}:${params[b].href}`
359
- // // }, '')
360
- // // return `> ${chalk.bold(s.basename)} "${s.description}"` +
361
- // // paramsTmpls;
362
- // // };
363
- // // Helpers.info(`
364
- // // (${chalk.bold(scenarios.length.toString())}) scenario(s) to replay: `
365
- // // + `${scenarios.map(s => tmpScenarioInfo(s)).join('\n')}`
366
- // // );
367
- // return { scenario: _.first(scenarios), scenarios, params };
368
- // }
369
- // //#endregion
370
- // //#endregion
371
- // }
372
- //# sourceMappingURL=record-replay-req-res-scenario.js.map
@@ -1,232 +0,0 @@
1
- // import { Application } from 'express';
2
- // import * as _ from 'lodash';
3
- // import * as glob from 'glob';
4
- // import * as path from 'path';
5
- // import * as express from 'express';
6
- // import * as http from 'http';
7
- // import * as fse from 'fs-extra';
8
- // import * as cors from 'cors';
9
- // import * as bodyParser from 'body-parser';
10
- // import * as cookieParser from 'cookie-parser';
11
- // import * as methodOverride from 'method-override';
12
- // import * as fileUpload from 'express-fileupload';
13
- // import { Models } from 'tnp-models';
14
- // import { Helpers } from 'tnp-helpers';
15
- // import { config } from 'tnp-core';
16
- // import { URL } from 'url';
17
- // import { Tape } from './tape.backend';
18
- // import { CLASS } from 'typescript-class-helpers';
19
- // export type PortOrURL = URL | number;
20
- // export type ScenarioParams = { [nameOfParam: string]: PortOrURL; };
21
- // export type ScenarioParamsReturn = { [nameOfParam: string]: Exclude<PortOrURL, number>; };
22
- // export type ScenarioParam = { name: string; portOrUrl: PortOrURL; }
23
- // export type ScenarioParamReturn = { name: string; portOrUrl: Exclude<PortOrURL, number>; }
24
- // export class Scenario {
25
- // public static get allCurrent() {
26
- // const currentScenariosFolder = path.join(process.cwd(), config.folder.tmpScenarios);
27
- // return !fse.existsSync(currentScenariosFolder) ? [] : fse
28
- // .readdirSync(currentScenariosFolder)
29
- // .map(p => Scenario.From(path.join(currentScenariosFolder, p)))
30
- // .filter(f => !!f)
31
- // }
32
- // private static instances = {};
33
- // static From(pathToScenario: string) {
34
- // if (!Helpers.exists(pathToScenario)) {
35
- // return void 0;
36
- // }
37
- // if (!Scenario.instances[pathToScenario]) {
38
- // Scenario.instances[pathToScenario] = new Scenario(pathToScenario)
39
- // }
40
- // const s = Scenario.instances[pathToScenario] as Scenario;
41
- // if (!s.packageJson) {
42
- // return void 0;
43
- // }
44
- // if (!s.packageJson.tnp || s.packageJson.tnp.type !== 'scenario') {
45
- // return void 0;
46
- // }
47
- // return s;
48
- // }
49
- // public static lastFromFolder(pathToFolder: string): Scenario {
50
- // const currentScenariosFolder = path.join(pathToFolder, config.folder.tmpScenarios);
51
- // if (!fse.existsSync(currentScenariosFolder)) {
52
- // return void 0;
53
- // }
54
- // const sorted = (_.sortBy(fse
55
- // .readdirSync(currentScenariosFolder)
56
- // .map(f => {
57
- // f = path.join(currentScenariosFolder, f);
58
- // const scenario = Scenario.From(f)
59
- // const mtime = fse.lstatSync(path.join(f, config.file.package_json)).mtime;
60
- // return { mtime, scenario };
61
- // }), a => a.mtime)
62
- // .filter(f => !!f.scenario)
63
- // );
64
- // return (sorted.length > 0) ? _.first(sorted).scenario : (void 0)
65
- // }
66
- // get folderHostNames() {
67
- // const res = fse
68
- // .readdirSync(this.location)
69
- // .filter(f => f !== config.file.package_json)
70
- // .map(f => {
71
- // const [addressPart, hostName] = f.split('__');
72
- // return hostName;
73
- // });
74
- // return res;
75
- // }
76
- // get path() {
77
- // return this.location;
78
- // }
79
- // get basename() {
80
- // return path.basename(this.location);
81
- // }
82
- // public get description() {
83
- // return this.packageJson?.description ? this.packageJson?.description
84
- // : _.startCase(this.packageJson?.name);
85
- // }
86
- // private packageJson: Models.npm.IPackageJSON;
87
- // constructor(
88
- // private readonly location: string
89
- // ) {
90
- // const pathToScenarioPackageJson = path.join(location, config.file.package_json);
91
- // // Helpers.log(`path to scenario pj: ${pathToScenarioPackageJson}`)
92
- // this.packageJson = Helpers.readJson(pathToScenarioPackageJson);
93
- // }
94
- // private initMidleware(app: express.Application) {
95
- // app.use(fileUpload())
96
- // app.use(bodyParser.urlencoded({ extended: true }));
97
- // app.use(bodyParser.json());
98
- // app.use(methodOverride());
99
- // app.use(cookieParser());
100
- // app.use(cors());
101
- // (() => {
102
- // app.use((req, res, next) => {
103
- // res.set('Access-Control-Expose-Headers',
104
- // [
105
- // 'Content-Type',
106
- // 'Authorization',
107
- // 'X-Requested-With',
108
- // ].join(', '))
109
- // next();
110
- // });
111
- // })()
112
- // }
113
- // private initRequests(app: express.Application, name?: string) {
114
- // const allReq = this.tapes(name);
115
- // app.get(/^\/(.*)/, (req, res) => {
116
- // respond(allReq, req, res);
117
- // });
118
- // app.post(/^\/(.*)/, (req, res) => {
119
- // respond(allReq, req, res);
120
- // });
121
- // app.delete(/^\/(.*)/, (req, res) => {
122
- // respond(allReq, req, res);
123
- // });
124
- // app.put(/^\/(.*)/, (req, res) => {
125
- // respond(allReq, req, res);
126
- // });
127
- // app.head(/^\/(.*)/, (req, res) => {
128
- // respond(allReq, req, res);
129
- // });
130
- // return allReq;
131
- // }
132
- // scenarioAsWorker(params: ScenarioParams, cwd = process.cwd()) {
133
- // const hostNames = _.keys(params).map(hostName => hostName);
134
- // const ports = _.keys(params).map(hostName => Helpers.urlParse(params[hostName]).port);
135
- // const command = `record-replay-req-res-scenario replay ${this.location} `
136
- // + `${hostNames.map(h => `--hostName ${h}`).join(' ')} `
137
- // + `${ports.map(h => `--port ${h}`).join(' ')} `
138
- // ;
139
- // Helpers.run(command, { cwd }).async();
140
- // }
141
- // async start(urlsOrPorts: number | number[] | URL | URL[] | ScenarioParams, debug = false) {
142
- // if (_.isString(urlsOrPorts) || _.isNumber(urlsOrPorts)) {
143
- // urlsOrPorts = [Number(urlsOrPorts)]
144
- // }
145
- // if (_.isArray(urlsOrPorts)) {
146
- // urlsOrPorts = (urlsOrPorts as (number | URL)[]).map(portLocalHOst => {
147
- // if (portLocalHOst instanceof URL) {
148
- // portLocalHOst = Number(portLocalHOst.port);
149
- // }
150
- // return Number(portLocalHOst)
151
- // });
152
- // urlsOrPorts = urlsOrPorts.reduce((a, b, i) => {
153
- // return _.merge(a, { '': Helpers.urlParse(b) })
154
- // }, {}) as ScenarioParams;
155
- // }
156
- // urlsOrPorts = urlsOrPorts as ScenarioParams;
157
- // const proxyPorts = _
158
- // .keys(urlsOrPorts)
159
- // .map(name => { return { name, portOrUrl: Helpers.urlParse(urlsOrPorts[name]) } }) as ScenarioParamReturn[];
160
- // const promises = [] as Promise<any>[];
161
- // for (let index = 0; index < proxyPorts.length; index++) {
162
- // let urlOrPort = proxyPorts[index];
163
- // ((promises, proxyURL) => {
164
- // promises.push(new Promise((resolve, reject) => {
165
- // const recordedServerName = ((urlOrPort.name && urlOrPort.name.trim() !== '') ? urlOrPort.name : '').trim();
166
- // const app = express()
167
- // this.initMidleware(app);
168
- // const tapes = this.initRequests(app, recordedServerName);
169
- // Helpers.info(`Starting scenario server on port ${proxyURL.port}
170
- // Recorded/assigned server name: ${recordedServerName !== '' ? recordedServerName : '-'}:
171
- // Description: "${this.description}"
172
- // `
173
- // + `${!debug ? '' : (tapes.length === 0) ? 'Tapes: < nothing for this server name >' :
174
- // ('Tapes:\n' + tapes.map(t => `(${t.req.method}) ${proxyURL.origin}${t.req.url}`).join('\n'))}\n`
175
- // + Helpers.terminalLine()
176
- // );
177
- // const h = new http.Server(app);
178
- // h.listen(proxyURL.port, () => {
179
- // console.log(`Server listening on ${proxyURL.href}
180
- // env: ${app.settings.env}
181
- // `);
182
- // resolve(void 0);
183
- // });
184
- // }));
185
- // })(promises, urlOrPort.portOrUrl);
186
- // }
187
- // await Promise.all(promises);
188
- // return proxyPorts;
189
- // }
190
- // tapes(name?: string) {
191
- // const allTapes = fse
192
- // .readdirSync(this.location)
193
- // .filter(f => {
194
- // const regTmpl = `.*\_\_${(_.isString(name) && name.trim() !== '') ? Helpers.escapeStringForRegEx(_.camelCase(name)) : '[a-zA-Z0-9]+'}$`;
195
- // const res = (new RegExp(regTmpl)).test(f);
196
- // return res;
197
- // })
198
- // .map(f => path.join(this.location, f))
199
- // .reduce((pre, folderLocation) => {
200
- // const patternFiles = `${folderLocation}/**/*.json5`;
201
- // const all = glob.sync(patternFiles) as any;
202
- // for (let index = 0; index < all.length; index++) {
203
- // const f = all[index];
204
- // all[index] = Tape.from(Helpers.readJson(f, void 0, true));
205
- // }
206
- // return pre.concat(all);
207
- // }, []);
208
- // return allTapes as Tape[];
209
- // }
210
- // }
211
- // export interface RequestType {
212
- // meta: {
213
- // createdAt: string | Date;
214
- // host: string;
215
- // }
216
- // }
217
- // function respond(allReq: Tape[], req, res) {
218
- // const match = allReq.find(s => s.matchToReq(req));
219
- // if (match) {
220
- // // Helpers.log(`MATCH: ${match.req.method} ${match.req.url}`);
221
- // _.keys(match.res.headers).forEach(headerKey => {
222
- // const headerString = _.isArray(match.res.headers[headerKey]) ?
223
- // ((match.res.headers[headerKey] || []).join(', ')) :
224
- // match.res.headers[headerKey];
225
- // res.set(headerKey, headerString)
226
- // })
227
- // res.send(match.res.body); //.status(match.res.status);
228
- // } else {
229
- // res.send('REQUEST DOES NOT MATCH ANY RECORDING')
230
- // }
231
- // }
232
- //# sourceMappingURL=scenario.backend.js.map
@@ -1,20 +0,0 @@
1
- // import { URL } from 'url';
2
- // import { RecordReplayReqResScenario } from './record-replay-req-res-scenario';
3
- // import { Helpers } from 'tnp-helpers';
4
- // export async function run(args: string[]) {
5
- // const ins = RecordReplayReqResScenario.Instance();
6
- // const command: 'record' | 'replay' = args.shift() as any;
7
- // if (command === 'record') {
8
- // Helpers.clearConsole();
9
- // await ins.record(args)
10
- // }
11
- // if (command === 'replay') {
12
- // const { scenarios, params } = await ins.resolveScenariosData(args, true);
13
- // for (let index = 0; index < scenarios.length; index++) {
14
- // const s = scenarios[index];
15
- // await s.start(params,true);
16
- // }
17
- // process.stdin.resume();
18
- // }
19
- // }
20
- //# sourceMappingURL=start.backend.js.map
@@ -1,28 +0,0 @@
1
- // import * as _ from 'lodash';
2
- // import * as express from 'express';
3
- // import { Tape as BaseTape } from 'ng-talkback';
4
- // export class Tape implements Partial<BaseTape> {
5
- // static from(data: object) {
6
- // return new Tape(data);
7
- // }
8
- // constructor(data) {
9
- // Object.assign(this, data);
10
- // }
11
- // matchToReq(req: express.Request) {
12
- // return (
13
- // (req.url === this.req.url)
14
- // && (req.method === this.req.method)
15
- // // && (req.body == this.req.body) // TODO
16
- // // && (req.headers == this.req.headers) // TODO
17
- // )
18
- // }
19
- // readonly req: any; // import('ng-talkback/types').Req;
20
- // readonly res?: any; //import('ng-talkback/types').Res;
21
- // readonly options: any; //import('ng-talkback/options').Options;
22
- // readonly queryParamsToIgnore: string[];
23
- // readonly meta: any; // import('ng-talkback/types').Metadata;
24
- // readonly path?: string;
25
- // readonly new: boolean;
26
- // readonly used: boolean;
27
- // }
28
- //# sourceMappingURL=tape.backend.js.map
@@ -0,0 +1 @@
1
+ {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "record-replay-req-res-scenario",
3
- "version": "21.0.14",
3
+ "version": "21.0.17",
4
4
  "scripts": {
5
5
  "taon init": "taon init",
6
6
  "taon start": "taon start",
@@ -36,6 +36,7 @@
36
36
  "record-replay-req-res-scenario-debug-brk": "bin/record-replay-req-res-scenario-debug-brk"
37
37
  },
38
38
  "peerDependencies": {},
39
+ "devDependencies": {},
39
40
  "repository": {
40
41
  "type": "git",
41
42
  "url": "https://github.com/darekf77/record-replay-req-res-scenario.git"