@sasjs/cli 2.38.8 → 3.0.2

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 (52) hide show
  1. package/build/commands/add/addCredential.d.ts +2 -2
  2. package/build/commands/add/addCredential.js +26 -28
  3. package/build/commands/add/internal/input.js +15 -2
  4. package/build/commands/build/build.d.ts +1 -1
  5. package/build/commands/build/build.js +41 -19
  6. package/build/commands/build/internal/getLaunchPageCode.js +2 -1
  7. package/build/commands/compile/internal/compileServiceFile.js +11 -7
  8. package/build/commands/compile/internal/compileTestFile.js +1 -1
  9. package/build/commands/compile/internal/spec/compileTestFile.spec.js +16 -4
  10. package/build/commands/compile/spec/compile.spec.js +30 -0
  11. package/build/commands/compile/spec/loadDependencies.spec.js +3 -3
  12. package/build/commands/context/contextCommand.js +5 -5
  13. package/build/commands/deploy/deploy.d.ts +2 -1
  14. package/build/commands/deploy/deploy.js +92 -46
  15. package/build/commands/deploy/spec/cbd.spec.d.ts +1 -0
  16. package/build/commands/deploy/spec/cbd.spec.js +141 -0
  17. package/build/commands/deploy/spec/cbd.spec.server.js +6 -57
  18. package/build/commands/deploy/spec/utils.d.ts +6 -0
  19. package/build/commands/deploy/spec/utils.js +242 -0
  20. package/build/commands/flow/flowCommand.js +1 -1
  21. package/build/commands/flow/spec/flow.spec.server.js +1 -1
  22. package/build/commands/folder/folderCommand.js +2 -2
  23. package/build/commands/folder/spec/folder.spec.server.js +1 -1
  24. package/build/commands/job/internal/execute/index.d.ts +2 -0
  25. package/build/commands/job/internal/execute/index.js +14 -0
  26. package/build/commands/job/internal/execute/sasjs.d.ts +8 -0
  27. package/build/commands/job/internal/execute/sasjs.js +69 -0
  28. package/build/commands/job/{execute.d.ts → internal/execute/viya.d.ts} +1 -1
  29. package/build/commands/job/{execute.js → internal/execute/viya.js} +29 -68
  30. package/build/commands/job/internal/utils.d.ts +1 -0
  31. package/build/commands/job/internal/utils.js +81 -0
  32. package/build/commands/job/jobCommand.d.ts +2 -1
  33. package/build/commands/job/jobCommand.js +65 -23
  34. package/build/commands/job/spec/execute.spec.js +41 -21
  35. package/build/commands/job/spec/getContextName.spec.js +1 -1
  36. package/build/commands/job/spec/job.spec.server.js +4 -4
  37. package/build/commands/job/spec/jobCommand.spec.js +10 -10
  38. package/build/commands/request/request.js +1 -1
  39. package/build/commands/run/run.js +2 -2
  40. package/build/commands/servicepack/spec/servicepack.spec.server.js +0 -1
  41. package/build/commands/shared/deployToSasViyaWithServicePack.js +1 -1
  42. package/build/commands/testing/test.js +1 -1
  43. package/build/config.json +3 -1
  44. package/build/utils/config.js +104 -64
  45. package/build/utils/file.d.ts +1 -1
  46. package/build/utils/file.js +1 -1
  47. package/build/utils/spec/removeComments.spec.d.ts +1 -1
  48. package/build/utils/spec/removeComments.spec.js +1 -1
  49. package/build/utils/test.js +1 -1
  50. package/build/utils/utils.d.ts +1 -0
  51. package/build/utils/utils.js +8 -2
  52. package/package.json +13 -13
@@ -0,0 +1,81 @@
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
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.saveLog = void 0;
43
+ var path_1 = __importDefault(require("path"));
44
+ var utils_1 = require("@sasjs/utils");
45
+ var utils_2 = require("../../../utils/utils");
46
+ var displayResult_1 = require("../../../utils/displayResult");
47
+ var saveLog = function (logData, logFile, jobPath, returnStatusOnly) { return __awaiter(void 0, void 0, void 0, function () {
48
+ var logPath, folderPath, parentFolderPath, logLines;
49
+ var _a;
50
+ return __generator(this, function (_b) {
51
+ switch (_b.label) {
52
+ case 0:
53
+ if (logFile) {
54
+ logPath = logFile;
55
+ }
56
+ else {
57
+ logPath = path_1.default.join(process.projectDir, jobPath.split('/').slice(-1).pop() + ".log");
58
+ }
59
+ folderPath = logPath.split(path_1.default.sep);
60
+ folderPath.pop();
61
+ parentFolderPath = folderPath.join(path_1.default.sep);
62
+ return [4 /*yield*/, utils_1.folderExists(parentFolderPath)];
63
+ case 1:
64
+ if (!!(_b.sent())) return [3 /*break*/, 3];
65
+ return [4 /*yield*/, utils_1.createFolder(parentFolderPath)];
66
+ case 2:
67
+ _b.sent();
68
+ _b.label = 3;
69
+ case 3:
70
+ logLines = typeof logData === 'object' ? utils_2.parseLogLines(logData) : logData;
71
+ (_a = process.logger) === null || _a === void 0 ? void 0 : _a.info("Creating log file at " + logPath + " .");
72
+ return [4 /*yield*/, utils_1.createFile(logPath, logLines)];
73
+ case 4:
74
+ _b.sent();
75
+ if (!returnStatusOnly)
76
+ displayResult_1.displaySuccess("Log saved to " + logPath);
77
+ return [2 /*return*/];
78
+ }
79
+ });
80
+ }); };
81
+ exports.saveLog = saveLog;
@@ -5,5 +5,6 @@ import { TargetCommand } from '../../types/command/targetCommand';
5
5
  export declare class JobCommand extends TargetCommand {
6
6
  constructor(args: string[]);
7
7
  execute(): Promise<ReturnCode>;
8
- executeJob(target: Target, sasjs: SASjs, authConfig: AuthConfig): Promise<ReturnCode>;
8
+ executeJobSasjs(sasjs: SASjs, target: Target): Promise<ReturnCode>;
9
+ executeJobViya(target: Target, sasjs: SASjs, authConfig: AuthConfig): Promise<ReturnCode>;
9
10
  }
@@ -62,7 +62,7 @@ var command_1 = require("../../types/command");
62
62
  var targetCommand_1 = require("../../types/command/targetCommand");
63
63
  var utils_2 = require("../../utils");
64
64
  var prefixAppLoc_1 = require("../../utils/prefixAppLoc");
65
- var execute_1 = require("./execute");
65
+ var execute_1 = require("./internal/execute");
66
66
  var JobSubCommand;
67
67
  (function (JobSubCommand) {
68
68
  JobSubCommand["Execute"] = "execute";
@@ -137,19 +137,22 @@ var JobCommand = /** @class */ (function (_super) {
137
137
  JobCommand.prototype.execute = function () {
138
138
  var _a;
139
139
  return __awaiter(this, void 0, void 0, function () {
140
- var target, sasjs, authConfig, _b;
141
- return __generator(this, function (_c) {
142
- switch (_c.label) {
140
+ var target, sasjs, _b, authConfig, _c, _d;
141
+ return __generator(this, function (_e) {
142
+ switch (_e.label) {
143
143
  case 0: return [4 /*yield*/, this.getTargetInfo()];
144
144
  case 1:
145
- target = (_c.sent()).target;
146
- if (target.serverType !== utils_1.ServerType.SasViya) {
147
- (_a = process.logger) === null || _a === void 0 ? void 0 : _a.error("This command is only supported for SAS Viya targets.\nPlease try again with a different target.");
148
- return [2 /*return*/, command_1.ReturnCode.InternalError];
145
+ target = (_e.sent()).target;
146
+ _b = target.serverType;
147
+ switch (_b) {
148
+ case utils_1.ServerType.SasViya: return [3 /*break*/, 2];
149
+ case utils_1.ServerType.Sasjs: return [3 /*break*/, 7];
149
150
  }
151
+ return [3 /*break*/, 11];
152
+ case 2:
150
153
  sasjs = new node_1.default({
151
154
  serverUrl: target.serverUrl,
152
- allowInsecureRequests: target.allowInsecureRequests,
155
+ httpsAgentOptions: target.httpsAgentOptions,
153
156
  appLoc: target.appLoc,
154
157
  serverType: target.serverType,
155
158
  debug: true
@@ -159,25 +162,64 @@ var JobCommand = /** @class */ (function (_super) {
159
162
  (_a = process.logger) === null || _a === void 0 ? void 0 : _a.error('Unable to execute job. Error fetching auth config: ', err);
160
163
  return null;
161
164
  })];
162
- case 2:
163
- authConfig = _c.sent();
164
- if (!authConfig) {
165
- return [2 /*return*/, command_1.ReturnCode.InternalError];
166
- }
167
- if (!(this.parsed.subCommand === JobSubCommand.Execute)) return [3 /*break*/, 4];
168
- return [4 /*yield*/, this.executeJob(target, sasjs, authConfig)];
169
165
  case 3:
170
- _b = _c.sent();
171
- return [3 /*break*/, 5];
166
+ authConfig = _e.sent();
167
+ if (!authConfig)
168
+ return [2 /*return*/, command_1.ReturnCode.InternalError];
169
+ if (!(this.parsed.subCommand === JobSubCommand.Execute)) return [3 /*break*/, 5];
170
+ return [4 /*yield*/, this.executeJobViya(target, sasjs, authConfig)];
172
171
  case 4:
173
- _b = command_1.ReturnCode.InvalidCommand;
174
- _c.label = 5;
175
- case 5: return [2 /*return*/, _b];
172
+ _c = _e.sent();
173
+ return [3 /*break*/, 6];
174
+ case 5:
175
+ _c = command_1.ReturnCode.InvalidCommand;
176
+ _e.label = 6;
177
+ case 6: return [2 /*return*/, _c];
178
+ case 7:
179
+ sasjs = new node_1.default({
180
+ serverType: target.serverType,
181
+ serverUrl: target.serverUrl
182
+ });
183
+ if (typeof this.parsed.jobPath !== 'string')
184
+ return [2 /*return*/, command_1.ReturnCode.InvalidCommand];
185
+ if (!(this.parsed.subCommand === JobSubCommand.Execute)) return [3 /*break*/, 9];
186
+ return [4 /*yield*/, this.executeJobSasjs(sasjs, target)];
187
+ case 8:
188
+ _d = _e.sent();
189
+ return [3 /*break*/, 10];
190
+ case 9:
191
+ _d = command_1.ReturnCode.InvalidCommand;
192
+ _e.label = 10;
193
+ case 10: return [2 /*return*/, _d];
194
+ case 11:
195
+ (_a = process.logger) === null || _a === void 0 ? void 0 : _a.error("This command is only supported for SAS Viya targets.\nPlease try again with a different target.");
196
+ return [2 /*return*/, command_1.ReturnCode.InternalError];
197
+ }
198
+ });
199
+ });
200
+ };
201
+ JobCommand.prototype.executeJobSasjs = function (sasjs, target) {
202
+ return __awaiter(this, void 0, void 0, function () {
203
+ var jobPath, returnCode;
204
+ return __generator(this, function (_a) {
205
+ switch (_a.label) {
206
+ case 0:
207
+ jobPath = prefixAppLoc_1.prefixAppLoc(target.appLoc, this.parsed.jobPath);
208
+ return [4 /*yield*/, execute_1.executeJobSasjs(sasjs, jobPath, this.parsed.log)
209
+ .then(function () { return command_1.ReturnCode.Success; })
210
+ .catch(function (err) {
211
+ var _a;
212
+ (_a = process.logger) === null || _a === void 0 ? void 0 : _a.error('Error executing job: ', err);
213
+ return command_1.ReturnCode.InternalError;
214
+ })];
215
+ case 1:
216
+ returnCode = _a.sent();
217
+ return [2 /*return*/, returnCode];
176
218
  }
177
219
  });
178
220
  });
179
221
  };
180
- JobCommand.prototype.executeJob = function (target, sasjs, authConfig) {
222
+ JobCommand.prototype.executeJobViya = function (target, sasjs, authConfig) {
181
223
  var _a, _b, _c;
182
224
  return __awaiter(this, void 0, void 0, function () {
183
225
  var jobPath, log, wait, output, statusFile, returnStatusOnly, ignoreWarnings, source, streamLog, returnCode;
@@ -202,7 +244,7 @@ var JobCommand = /** @class */ (function (_super) {
202
244
  if (ignoreWarnings && !returnStatusOnly) {
203
245
  (_c = process.logger) === null || _c === void 0 ? void 0 : _c.warn("Using the 'ignoreWarnings' flag without 'returnStatusOnly' flag will not affect the sasjs job execute command.");
204
246
  }
205
- return [4 /*yield*/, execute_1.execute(sasjs, authConfig, jobPath, target, wait, output, log, statusFile, returnStatusOnly, ignoreWarnings, source, streamLog)
247
+ return [4 /*yield*/, execute_1.executeJobViya(sasjs, authConfig, jobPath, target, wait, output, log, statusFile, returnStatusOnly, ignoreWarnings, source, streamLog)
206
248
  .then(function () {
207
249
  return command_1.ReturnCode.Success;
208
250
  })
@@ -44,42 +44,33 @@ var utils_1 = require("@sasjs/utils");
44
44
  var types_1 = require("@sasjs/utils/types");
45
45
  var path_1 = __importDefault(require("path"));
46
46
  var utils_2 = require("../../../utils");
47
- var execute_1 = require("../execute");
47
+ var execute_1 = require("../internal/execute");
48
48
  var mocks_1 = require("./mocks");
49
49
  var sasjs = new node_1.default();
50
50
  var target = new types_1.Target({
51
51
  name: 'test',
52
- serverType: types_1.ServerType.SasViya,
52
+ serverType: types_1.ServerType.Sasjs,
53
53
  appLoc: '/test',
54
54
  contextName: 'Mock Context'
55
55
  });
56
56
  var statusFile;
57
- describe('execute', function () {
57
+ describe('executeJobViya', function () {
58
58
  beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () {
59
59
  return __generator(this, function (_a) {
60
60
  switch (_a.label) {
61
- case 0: return [4 /*yield*/, setupMocks()];
62
- case 1:
63
- _a.sent();
64
- statusFile = path_1.default.join(process.projectDir, 'test');
65
- return [2 /*return*/];
66
- }
67
- });
68
- }); });
69
- afterEach(function () { return __awaiter(void 0, void 0, void 0, function () {
70
- return __generator(this, function (_a) {
71
- switch (_a.label) {
72
- case 0: return [4 /*yield*/, utils_1.deleteFile(statusFile)];
61
+ case 0: return [4 /*yield*/, setupMocks(types_1.ServerType.SasViya)];
73
62
  case 1:
74
63
  _a.sent();
75
64
  return [2 /*return*/];
76
65
  }
77
66
  });
78
67
  }); });
68
+ var testFilePath = path_1.default.join(__dirname, 'test');
69
+ var testLogsPath = path_1.default.join(__dirname, 'logs');
79
70
  it('should set streamLog to true when the flag is passed in', function () { return __awaiter(void 0, void 0, void 0, function () {
80
71
  return __generator(this, function (_a) {
81
72
  switch (_a.label) {
82
- case 0: return [4 /*yield*/, execute_1.execute(sasjs, mocks_1.mockAuthConfig, 'test/job', target, false, false, path_1.default.join(process.projectDir, 'logs'), statusFile, false, false, undefined, true)];
73
+ case 0: return [4 /*yield*/, execute_1.executeJobViya(sasjs, mocks_1.mockAuthConfig, 'test/job', target, false, false, testLogsPath, testFilePath, false, false, undefined, true)];
83
74
  case 1:
84
75
  _a.sent();
85
76
  expect(sasjs.startComputeJob).toHaveBeenCalledWith('test/job', null, {
@@ -88,8 +79,11 @@ describe('execute', function () {
88
79
  maxPollCount: 24 * 60 * 60,
89
80
  pollInterval: 1000,
90
81
  streamLog: true,
91
- logFolderPath: path_1.default.join(process.projectDir, 'logs')
82
+ logFolderPath: testLogsPath
92
83
  }, true, undefined);
84
+ return [4 /*yield*/, utils_1.deleteFile(testFilePath)];
85
+ case 2:
86
+ _a.sent();
93
87
  return [2 /*return*/];
94
88
  }
95
89
  });
@@ -97,7 +91,7 @@ describe('execute', function () {
97
91
  it('should set streamLog to false when the flag is false', function () { return __awaiter(void 0, void 0, void 0, function () {
98
92
  return __generator(this, function (_a) {
99
93
  switch (_a.label) {
100
- case 0: return [4 /*yield*/, execute_1.execute(sasjs, mocks_1.mockAuthConfig, 'test/job', target, false, false, path_1.default.join(process.projectDir, 'logs'), statusFile, false, false, undefined, false)];
94
+ case 0: return [4 /*yield*/, execute_1.executeJobViya(sasjs, mocks_1.mockAuthConfig, 'test/job', target, false, false, testLogsPath, testFilePath, false, false, undefined, false)];
101
95
  case 1:
102
96
  _a.sent();
103
97
  expect(sasjs.startComputeJob).toHaveBeenCalledWith('test/job', null, {
@@ -106,14 +100,40 @@ describe('execute', function () {
106
100
  maxPollCount: 24 * 60 * 60,
107
101
  pollInterval: 1000,
108
102
  streamLog: false,
109
- logFolderPath: path_1.default.join(process.projectDir, 'logs')
103
+ logFolderPath: testLogsPath
110
104
  }, true, undefined);
105
+ return [4 /*yield*/, utils_1.deleteFile(testFilePath)];
106
+ case 2:
107
+ _a.sent();
108
+ return [2 /*return*/];
109
+ }
110
+ });
111
+ }); });
112
+ });
113
+ describe('executeJobSasjs', function () {
114
+ beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () {
115
+ return __generator(this, function (_a) {
116
+ switch (_a.label) {
117
+ case 0: return [4 /*yield*/, setupMocks(types_1.ServerType.Sasjs)];
118
+ case 1:
119
+ _a.sent();
120
+ return [2 /*return*/];
121
+ }
122
+ });
123
+ }); });
124
+ it('should pass job pass as a _program parameter', function () { return __awaiter(void 0, void 0, void 0, function () {
125
+ return __generator(this, function (_a) {
126
+ switch (_a.label) {
127
+ case 0: return [4 /*yield*/, execute_1.executeJobSasjs(sasjs, 'test/job', path_1.default.join(process.projectDir, 'logs'))];
128
+ case 1:
129
+ _a.sent();
130
+ expect(sasjs.executeJobSASjs).toHaveBeenCalledWith({ _program: 'test/job' });
111
131
  return [2 /*return*/];
112
132
  }
113
133
  });
114
134
  }); });
115
135
  });
116
- var setupMocks = function () { return __awaiter(void 0, void 0, void 0, function () {
136
+ var setupMocks = function (serverType) { return __awaiter(void 0, void 0, void 0, function () {
117
137
  return __generator(this, function (_a) {
118
138
  switch (_a.label) {
119
139
  case 0:
@@ -124,7 +144,7 @@ var setupMocks = function () { return __awaiter(void 0, void 0, void 0, function
124
144
  jest.restoreAllMocks();
125
145
  jest.mock('@sasjs/adapter');
126
146
  jest
127
- .spyOn(sasjs, 'startComputeJob')
147
+ .spyOn(sasjs, serverType === types_1.ServerType.SasViya ? 'startComputeJob' : 'executeJobSASjs')
128
148
  .mockImplementation(function () { return Promise.resolve(); });
129
149
  return [2 /*return*/];
130
150
  }
@@ -37,7 +37,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  var utils_1 = require("../../../utils");
40
- var execute_1 = require("../execute");
40
+ var execute_1 = require("../internal/execute");
41
41
  describe('getContextName', function () {
42
42
  it('should return the context name if specified in the target', function () { return __awaiter(void 0, void 0, void 0, function () {
43
43
  var target;
@@ -65,7 +65,7 @@ var config_1 = require("../../../utils/config");
65
65
  var test_1 = require("../../../utils/test");
66
66
  var node_1 = __importStar(require("@sasjs/adapter/node"));
67
67
  var utils_2 = require("../../../utils");
68
- var execute_1 = require("../execute");
68
+ var execute_1 = require("../internal/execute");
69
69
  var prefixAppLoc_1 = require("../../../utils/prefixAppLoc");
70
70
  var build_1 = require("../../build/build");
71
71
  var deploy_1 = require("../../deploy/deploy");
@@ -92,7 +92,7 @@ describe('sasjs job execute', function () {
92
92
  _a.sent();
93
93
  sasjs = new node_1.default({
94
94
  serverUrl: target.serverUrl,
95
- allowInsecureRequests: target.allowInsecureRequests,
95
+ httpsAgentOptions: target.httpsAgentOptions,
96
96
  appLoc: target.appLoc,
97
97
  serverType: target.serverType,
98
98
  debug: true
@@ -530,7 +530,7 @@ describe('sasjs job execute', function () {
530
530
  case 0:
531
531
  adapter = new node_1.default({
532
532
  serverUrl: target.serverUrl,
533
- allowInsecureRequests: target.allowInsecureRequests,
533
+ httpsAgentOptions: target.httpsAgentOptions,
534
534
  appLoc: target.appLoc,
535
535
  serverType: target.serverType
536
536
  });
@@ -611,7 +611,7 @@ var executeWrapper = function (_a) {
611
611
  var _b = _a.adapter, adapter = _b === void 0 ? sasjs : _b, jobPath = _a.jobPath, _c = _a.waitForJob, waitForJob = _c === void 0 ? false : _c, _d = _a.output, output = _d === void 0 ? false : _d, _e = _a.logFile, logFile = _e === void 0 ? undefined : _e, _f = _a.statusFile, statusFile = _f === void 0 ? undefined : _f, _g = _a.returnStatusOnly, returnStatusOnly = _g === void 0 ? false : _g, _h = _a.ignoreWarnings, ignoreWarnings = _h === void 0 ? false : _h, _j = _a.source, source = _j === void 0 ? undefined : _j, _k = _a.streamLog, streamLog = _k === void 0 ? false : _k;
612
612
  return __awaiter(void 0, void 0, void 0, function () {
613
613
  return __generator(this, function (_l) {
614
- return [2 /*return*/, execute_1.execute(adapter, authConfig, jobPath, target, waitForJob, output, logFile, statusFile, returnStatusOnly, ignoreWarnings, source, streamLog)];
614
+ return [2 /*return*/, execute_1.executeJobViya(adapter, authConfig, jobPath, target, waitForJob, output, logFile, statusFile, returnStatusOnly, ignoreWarnings, source, streamLog)];
615
615
  });
616
616
  });
617
617
  };
@@ -91,7 +91,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
91
91
  };
92
92
  Object.defineProperty(exports, "__esModule", { value: true });
93
93
  var path_1 = __importDefault(require("path"));
94
- var executeModule = __importStar(require("../execute"));
94
+ var viyaExecuteModule = __importStar(require("../internal/execute/viya"));
95
95
  var jobCommand_1 = require("../jobCommand");
96
96
  var utils_1 = require("@sasjs/utils");
97
97
  var configUtils = __importStar(require("../../../utils/config"));
@@ -128,7 +128,7 @@ describe('JobCommand', function () {
128
128
  case 0: return [4 /*yield*/, executeCommandWrapper([jobPath])];
129
129
  case 1:
130
130
  _b.sent();
131
- (_a = expect(executeModule.execute)).toHaveBeenCalledWith.apply(_a, __spreadArray([], __read(executeCalledWith({ jobPath: jobPath }))));
131
+ (_a = expect(viyaExecuteModule.executeJobViya)).toHaveBeenCalledWith.apply(_a, __spreadArray([], __read(executeCalledWith({ jobPath: jobPath }))));
132
132
  return [2 /*return*/];
133
133
  }
134
134
  });
@@ -140,7 +140,7 @@ describe('JobCommand', function () {
140
140
  case 0: return [4 /*yield*/, executeCommandWrapper([jobPath, '--log', log])];
141
141
  case 1:
142
142
  _b.sent();
143
- (_a = expect(executeModule.execute)).toHaveBeenCalledWith.apply(_a, __spreadArray([], __read(executeCalledWith({
143
+ (_a = expect(viyaExecuteModule.executeJobViya)).toHaveBeenCalledWith.apply(_a, __spreadArray([], __read(executeCalledWith({
144
144
  jobPath: jobPath,
145
145
  waitForJob: true,
146
146
  logFile: path_1.default.join(projectFolder, log)
@@ -156,7 +156,7 @@ describe('JobCommand', function () {
156
156
  case 0: return [4 /*yield*/, executeCommandWrapper([jobPath, '--log'])];
157
157
  case 1:
158
158
  _b.sent();
159
- (_a = expect(executeModule.execute)).toHaveBeenCalledWith.apply(_a, __spreadArray([], __read(executeCalledWith({
159
+ (_a = expect(viyaExecuteModule.executeJobViya)).toHaveBeenCalledWith.apply(_a, __spreadArray([], __read(executeCalledWith({
160
160
  jobPath: jobPath,
161
161
  waitForJob: true,
162
162
  logFile: path_1.default.join(process.projectDir, jobFileName + ".log")
@@ -172,7 +172,7 @@ describe('JobCommand', function () {
172
172
  case 0: return [4 /*yield*/, executeCommandWrapper([jobPath, '--returnStatusOnly'])];
173
173
  case 1:
174
174
  _b.sent();
175
- (_a = expect(executeModule.execute)).toHaveBeenCalledWith.apply(_a, __spreadArray([], __read(executeCalledWith({
175
+ (_a = expect(viyaExecuteModule.executeJobViya)).toHaveBeenCalledWith.apply(_a, __spreadArray([], __read(executeCalledWith({
176
176
  jobPath: jobPath,
177
177
  waitForJob: true,
178
178
  returnStatusOnly: true
@@ -204,7 +204,7 @@ describe('JobCommand', function () {
204
204
  ])];
205
205
  case 1:
206
206
  _b.sent();
207
- (_a = expect(executeModule.execute)).toHaveBeenCalledWith.apply(_a, __spreadArray([], __read(executeCalledWith({
207
+ (_a = expect(viyaExecuteModule.executeJobViya)).toHaveBeenCalledWith.apply(_a, __spreadArray([], __read(executeCalledWith({
208
208
  jobPath: jobPath,
209
209
  waitForJob: true,
210
210
  output: output,
@@ -242,7 +242,7 @@ describe('JobCommand', function () {
242
242
  ])];
243
243
  case 1:
244
244
  _b.sent();
245
- (_a = expect(executeModule.execute)).toHaveBeenCalledWith.apply(_a, __spreadArray([], __read(executeCalledWith({
245
+ (_a = expect(viyaExecuteModule.executeJobViya)).toHaveBeenCalledWith.apply(_a, __spreadArray([], __read(executeCalledWith({
246
246
  jobPath: jobPath,
247
247
  waitForJob: true,
248
248
  output: output,
@@ -314,7 +314,7 @@ describe('JobCommand', function () {
314
314
  switch (_a.label) {
315
315
  case 0:
316
316
  jest
317
- .spyOn(executeModule, 'execute')
317
+ .spyOn(viyaExecuteModule, 'executeJobViya')
318
318
  .mockImplementation(function () { return Promise.reject(new Error('Test Error')); });
319
319
  return [4 /*yield*/, executeCommandWrapper([jobPath])];
320
320
  case 1:
@@ -328,10 +328,10 @@ describe('JobCommand', function () {
328
328
  });
329
329
  var setupMocks = function () {
330
330
  jest.resetAllMocks();
331
- jest.mock('../execute');
331
+ jest.mock('../internal/execute');
332
332
  jest.mock('../../../utils/config');
333
333
  jest
334
- .spyOn(executeModule, 'execute')
334
+ .spyOn(viyaExecuteModule, 'executeJobViya')
335
335
  .mockImplementation(function () { return Promise.resolve(); });
336
336
  jest
337
337
  .spyOn(configUtils, 'findTargetInConfiguration')
@@ -102,7 +102,7 @@ function runSasJob(target, isLocal, sasJobLocation, dataFilePath, configFilePath
102
102
  }
103
103
  sasjs = new node_1.default({
104
104
  serverUrl: target.serverUrl,
105
- allowInsecureRequests: target.allowInsecureRequests,
105
+ httpsAgentOptions: target.httpsAgentOptions,
106
106
  appLoc: target.appLoc,
107
107
  serverType: target.serverType,
108
108
  contextName: target.contextName,
@@ -139,7 +139,7 @@ function executeOnSasViya(filePath, isTempFile, target, linesToExecute) {
139
139
  (_a = process.logger) === null || _a === void 0 ? void 0 : _a.info("Sending " + path_1.default.basename(filePath) + " to SAS server for execution.");
140
140
  sasjs = new node_1.default({
141
141
  serverUrl: target.serverUrl,
142
- allowInsecureRequests: target.allowInsecureRequests,
142
+ httpsAgentOptions: target.httpsAgentOptions,
143
143
  appLoc: target.appLoc,
144
144
  serverType: target.serverType,
145
145
  debug: true,
@@ -225,7 +225,7 @@ function executeOnSas9(filePath, isTempFile, target, linesToExecute) {
225
225
  password = utils_1.decodeFromBase64(password);
226
226
  sasjs = new node_1.default({
227
227
  serverUrl: target.serverUrl,
228
- allowInsecureRequests: target.allowInsecureRequests,
228
+ httpsAgentOptions: target.httpsAgentOptions,
229
229
  appLoc: target.appLoc,
230
230
  serverType: target.serverType,
231
231
  debug: true
@@ -61,7 +61,6 @@ describe('sasjs servicepack', function () {
61
61
  name: targetName,
62
62
  serverType: utils_1.ServerType.SasViya,
63
63
  serverUrl: process.env.VIYA_SERVER_URL,
64
- allowInsecureRequests: false,
65
64
  appLoc: "/Public/app/cli-tests/" + targetName,
66
65
  contextName: utils_2.contextName,
67
66
  authConfig: {
@@ -67,7 +67,7 @@ function deployToSasViyaWithServicePack(jsonFilePath, target, isLocal, isForced)
67
67
  throw new Error("Deployment failed. Request is not authenticated.\nPlease add the following variables to your .env" + (isLocal ? "." + target.name : '') + " file:\nCLIENT, SECRET, ACCESS_TOKEN, REFRESH_TOKEN");
68
68
  }
69
69
  sasjs = new node_1.default({
70
- allowInsecureRequests: target.allowInsecureRequests,
70
+ httpsAgentOptions: target.httpsAgentOptions,
71
71
  appLoc: target.appLoc,
72
72
  serverType: target.serverType,
73
73
  serverUrl: target.serverUrl,
@@ -144,7 +144,7 @@ function runTest(target, testRegExps, outDirectory, flowSourcePath) {
144
144
  flow.push(testFlow.testTearDown);
145
145
  sasjs = new node_1.default({
146
146
  serverUrl: target.serverUrl,
147
- allowInsecureRequests: target.allowInsecureRequests,
147
+ httpsAgentOptions: target.httpsAgentOptions,
148
148
  appLoc: target.appLoc,
149
149
  serverType: target.serverType,
150
150
  debug: true,
package/build/config.json CHANGED
@@ -241,7 +241,9 @@
241
241
  "name": "viya",
242
242
  "serverType": "SASVIYA",
243
243
  "serverUrl": "https://sas.analytium.co.uk",
244
- "allowInsecureRequests": false,
244
+ "httpsAgentOptions": {
245
+ "allowInsecureRequests": false
246
+ },
245
247
  "appLoc": "/Public/app",
246
248
  "contextName": "SAS Job Execution compute context",
247
249
  "buildConfig": {