@sasjs/cli 3.19.6 → 3.20.0

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 (28) hide show
  1. package/build/commands/deploy/deploy.js +54 -108
  2. package/build/commands/deploy/spec/cbd.spec.js +31 -8
  3. package/build/commands/fs/fsCommand.d.ts +11 -0
  4. package/build/commands/fs/fsCommand.js +335 -0
  5. package/build/commands/fs/internal/executeCode.d.ts +4 -0
  6. package/build/commands/fs/internal/executeCode.js +126 -0
  7. package/build/commands/fs/internal/extractHashArray.d.ts +1 -0
  8. package/build/commands/fs/internal/extractHashArray.js +20 -0
  9. package/build/commands/fs/spec/executeCode.spec.d.ts +1 -0
  10. package/build/commands/fs/spec/executeCode.spec.js +197 -0
  11. package/build/commands/fs/spec/extractHashArray.spec.d.ts +1 -0
  12. package/build/commands/fs/spec/extractHashArray.spec.js +14 -0
  13. package/build/commands/fs/spec/fsCommand.spec.d.ts +1 -0
  14. package/build/commands/fs/spec/fsCommand.spec.js +297 -0
  15. package/build/commands/job/internal/execute/sas9.d.ts +1 -1
  16. package/build/commands/job/internal/execute/sasjs.d.ts +3 -4
  17. package/build/commands/job/internal/execute/sasjs.js +36 -20
  18. package/build/commands/job/jobCommand.d.ts +4 -8
  19. package/build/commands/job/jobCommand.js +64 -98
  20. package/build/commands/job/spec/execute.spec.js +52 -7
  21. package/build/commands/request/spec/request.spec.server.sas9.js +2 -0
  22. package/build/commands/run/run.js +70 -107
  23. package/build/types/command/commandFactory.js +2 -0
  24. package/build/utils/config.d.ts +28 -1
  25. package/build/utils/config.js +71 -1
  26. package/build/utils/index.d.ts +1 -0
  27. package/build/utils/index.js +1 -0
  28. package/package.json +4 -4
@@ -0,0 +1,335 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
+ return new (P || (P = Promise))(function (resolve, reject) {
20
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
24
+ });
25
+ };
26
+ var __generator = (this && this.__generator) || function (thisArg, body) {
27
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
+ function verb(n) { return function (v) { return step([n, v]); }; }
30
+ function step(op) {
31
+ if (f) throw new TypeError("Generator is already executing.");
32
+ while (_) try {
33
+ 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;
34
+ if (y = 0, t) op = [op[0] & 2, t.value];
35
+ switch (op[0]) {
36
+ case 0: case 1: t = op; break;
37
+ case 4: _.label++; return { value: op[1], done: false };
38
+ case 5: _.label++; y = op[1]; op = [0]; continue;
39
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
+ default:
41
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
+ if (t[2]) _.ops.pop();
46
+ _.trys.pop(); continue;
47
+ }
48
+ op = body.call(thisArg, _);
49
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
+ }
52
+ };
53
+ var __read = (this && this.__read) || function (o, n) {
54
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
55
+ if (!m) return o;
56
+ var i = m.call(o), r, ar = [], e;
57
+ try {
58
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
59
+ }
60
+ catch (error) { e = { error: error }; }
61
+ finally {
62
+ try {
63
+ if (r && !r.done && (m = i["return"])) m.call(i);
64
+ }
65
+ finally { if (e) throw e.error; }
66
+ }
67
+ return ar;
68
+ };
69
+ var __importDefault = (this && this.__importDefault) || function (mod) {
70
+ return (mod && mod.__esModule) ? mod : { "default": mod };
71
+ };
72
+ Object.defineProperty(exports, "__esModule", { value: true });
73
+ exports.FSCommand = void 0;
74
+ var command_1 = require("../../types/command");
75
+ var targetCommand_1 = require("../../types/command/targetCommand");
76
+ var utils_1 = require("../../utils");
77
+ var path_1 = __importDefault(require("path"));
78
+ var utils_2 = require("@sasjs/utils");
79
+ var executeCode_1 = require("./internal/executeCode");
80
+ var extractHashArray_1 = require("./internal/extractHashArray");
81
+ var FsSubCommand;
82
+ (function (FsSubCommand) {
83
+ FsSubCommand["Compile"] = "compile";
84
+ FsSubCommand["Sync"] = "sync";
85
+ })(FsSubCommand || (FsSubCommand = {}));
86
+ var syntax = 'fs <subCommand> [options]';
87
+ var usage = 'Usage: sasjs fs <subCommand> [options]';
88
+ // TODO: update
89
+ var description = 'generate a SAS program that contains the contents of a local directory';
90
+ var compileCommandSyntax = 'fs <subCommand> <localFolder> [options]';
91
+ var compileCommandUsage = 'Usage: sasjs fs compile <localFolder> [options]';
92
+ var compileCommandDescription = 'generate a SAS program that contains the contents of a local directory';
93
+ var compileCommandExamples = [
94
+ {
95
+ command: 'sasjs fs compile <path/of/folder> <path/of/outputProgram>',
96
+ description: 'generate a SAS program that contains the contents of a local directory'
97
+ }
98
+ ];
99
+ var syncCommandSyntax = 'fs <subCommand> <localFolder> <remoteFolder>';
100
+ var syncCommandUsage = 'Usage: sasjs fs sync <localFolder> <remoteFolder>';
101
+ var syncCommandDescription = 'generate a SAS program that will synchronize the remote folder with local';
102
+ var syncCommandExamples = [
103
+ {
104
+ command: 'sasjs fs sync <path/of/folder> <path/of/remote/folder>',
105
+ description: 'generate a SAS program that will synchronize the remote folder with local'
106
+ }
107
+ ];
108
+ var parseOptions = {
109
+ output: { type: 'string', alias: 'o' }
110
+ };
111
+ var FSCommand = /** @class */ (function (_super) {
112
+ __extends(FSCommand, _super);
113
+ function FSCommand(args) {
114
+ var _this = this;
115
+ var commandOptions = {
116
+ syntax: syntax,
117
+ usage: usage,
118
+ description: description,
119
+ parseOptions: parseOptions
120
+ };
121
+ var subCommand = args[3];
122
+ switch (subCommand) {
123
+ case FsSubCommand.Compile:
124
+ commandOptions.syntax = compileCommandSyntax;
125
+ commandOptions.usage = compileCommandUsage;
126
+ commandOptions.description = compileCommandDescription;
127
+ commandOptions.examples = compileCommandExamples;
128
+ break;
129
+ case FsSubCommand.Sync:
130
+ commandOptions.syntax = syncCommandSyntax;
131
+ commandOptions.usage = syncCommandUsage;
132
+ commandOptions.description = syncCommandDescription;
133
+ commandOptions.examples = syncCommandExamples;
134
+ break;
135
+ }
136
+ _this = _super.call(this, args, commandOptions) || this;
137
+ return _this;
138
+ }
139
+ Object.defineProperty(FSCommand.prototype, "localFolder", {
140
+ get: function () {
141
+ var sourcePath = this.parsed.localFolder;
142
+ var currentDirPath = path_1.default.isAbsolute(sourcePath) ? '' : process.projectDir;
143
+ return path_1.default.join(currentDirPath, sourcePath);
144
+ },
145
+ enumerable: false,
146
+ configurable: true
147
+ });
148
+ Object.defineProperty(FSCommand.prototype, "remoteFolder", {
149
+ get: function () {
150
+ var remotePath = this.parsed.remoteFolder;
151
+ return remotePath.endsWith(path_1.default.sep) ? remotePath.slice(0, -1) : remotePath;
152
+ },
153
+ enumerable: false,
154
+ configurable: true
155
+ });
156
+ FSCommand.prototype.getOutputPath = function () {
157
+ return __awaiter(this, void 0, void 0, function () {
158
+ var outputPath, outputFolder, filename;
159
+ return __generator(this, function (_a) {
160
+ outputPath = this.parsed.output;
161
+ if (this.parsed.subCommand === FsSubCommand.Compile) {
162
+ if (!outputPath) {
163
+ outputFolder = path_1.default.join(process.sasjsConstants.buildDestinationFolder, 'fs-compile', (0, utils_2.generateTimestamp)());
164
+ filename = 'compileProgram.sas';
165
+ return [2 /*return*/, path_1.default.join(outputFolder, filename)];
166
+ }
167
+ if (!outputPath.endsWith('.sas')) {
168
+ outputPath += '.sas';
169
+ }
170
+ }
171
+ if (!outputPath) {
172
+ return [2 /*return*/, path_1.default.join(process.sasjsConstants.buildDestinationResultsFolder, 'fs', (0, utils_2.generateTimestamp)())];
173
+ }
174
+ if (path_1.default.isAbsolute(outputPath))
175
+ return [2 /*return*/, outputPath];
176
+ return [2 /*return*/, path_1.default.join(process.cwd(), outputPath)];
177
+ });
178
+ });
179
+ };
180
+ FSCommand.prototype.execute = function () {
181
+ return __awaiter(this, void 0, void 0, function () {
182
+ return __generator(this, function (_a) {
183
+ switch (_a.label) {
184
+ case 0:
185
+ if (!(this.parsed.subCommand === FsSubCommand.Compile)) return [3 /*break*/, 2];
186
+ return [4 /*yield*/, this.compile()];
187
+ case 1: return [2 /*return*/, _a.sent()];
188
+ case 2:
189
+ if (!(this.parsed.subCommand === FsSubCommand.Sync)) return [3 /*break*/, 4];
190
+ return [4 /*yield*/, this.sync()];
191
+ case 3: return [2 /*return*/, _a.sent()];
192
+ case 4: return [2 /*return*/, command_1.ReturnCode.InvalidCommand];
193
+ }
194
+ });
195
+ });
196
+ };
197
+ FSCommand.prototype.compile = function () {
198
+ return __awaiter(this, void 0, void 0, function () {
199
+ var folderPath, outputPath, programContent;
200
+ return __generator(this, function (_a) {
201
+ switch (_a.label) {
202
+ case 0:
203
+ folderPath = this.localFolder;
204
+ return [4 /*yield*/, this.getOutputPath()];
205
+ case 1:
206
+ outputPath = _a.sent();
207
+ return [4 /*yield*/, (0, utils_2.generateCompileProgram)(folderPath)];
208
+ case 2:
209
+ programContent = _a.sent();
210
+ return [4 /*yield*/, (0, utils_2.createFile)(outputPath, programContent)
211
+ .then(function () {
212
+ var _a;
213
+ (_a = process.logger) === null || _a === void 0 ? void 0 : _a.success("A compiled sas program has been successfully created at ".concat(outputPath));
214
+ return command_1.ReturnCode.Success;
215
+ })
216
+ .catch(function (err) {
217
+ (0, utils_1.displayError)(err, 'An error has occurred when creating program file.');
218
+ return command_1.ReturnCode.InternalError;
219
+ })];
220
+ case 3: return [2 /*return*/, _a.sent()];
221
+ }
222
+ });
223
+ });
224
+ };
225
+ FSCommand.prototype.sync = function () {
226
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
227
+ return __awaiter(this, void 0, void 0, function () {
228
+ var target, remoteFolderPath, localFolderPath, outputFolder, program, log, remoteHashes, localHash, remoteHashMap, hashedDiff, syncProgram, syncLog, syncedHash, syncedHashMap, syncedResources, resourcesNotPresentLocally;
229
+ return __generator(this, function (_l) {
230
+ switch (_l.label) {
231
+ case 0: return [4 /*yield*/, this.getTargetInfo()];
232
+ case 1:
233
+ target = (_l.sent()).target;
234
+ remoteFolderPath = this.remoteFolder;
235
+ localFolderPath = this.localFolder;
236
+ return [4 /*yield*/, this.getOutputPath()];
237
+ case 2:
238
+ outputFolder = _l.sent();
239
+ (_a = process.logger) === null || _a === void 0 ? void 0 : _a.info('generating program to get remote hash');
240
+ return [4 /*yield*/, (0, utils_2.generateProgramToGetRemoteHash)(remoteFolderPath)];
241
+ case 3:
242
+ program = _l.sent();
243
+ (_b = process.logger) === null || _b === void 0 ? void 0 : _b.info('executing program to get remote hash');
244
+ return [4 /*yield*/, (0, executeCode_1.executeCode)(target, program)];
245
+ case 4:
246
+ log = (_l.sent()).log;
247
+ return [4 /*yield*/, (0, utils_1.saveLog)(log, path_1.default.join(outputFolder, 'getRemoteHash.log'), '', false)];
248
+ case 5:
249
+ _l.sent();
250
+ (_c = process.logger) === null || _c === void 0 ? void 0 : _c.info('extracting hashes from log');
251
+ remoteHashes = (0, extractHashArray_1.extractHashArray)(log);
252
+ return [4 /*yield*/, createHashFile(JSON.stringify(remoteHashes, null, 2), path_1.default.join(outputFolder, 'hashesBeforeSync.json'))];
253
+ case 6:
254
+ _l.sent();
255
+ (_d = process.logger) === null || _d === void 0 ? void 0 : _d.info('creating the hash of local folder');
256
+ return [4 /*yield*/, (0, utils_2.getHash)(localFolderPath)];
257
+ case 7:
258
+ localHash = _l.sent();
259
+ remoteHashMap = remoteHashes.reduce(function (map, item) {
260
+ var relativePath = (0, utils_2.getRelativePath)(remoteFolderPath, item.FILE_PATH);
261
+ map[relativePath] = item.FILE_HASH;
262
+ return map;
263
+ }, {});
264
+ if (remoteHashMap[localHash.relativePath] === localHash.hash) {
265
+ (_e = process.logger) === null || _e === void 0 ? void 0 : _e.info('There are no differences between Remote and Local directory. Already synced.');
266
+ return [2 /*return*/, command_1.ReturnCode.Success];
267
+ }
268
+ (_f = process.logger) === null || _f === void 0 ? void 0 : _f.info('Extract differences from local and remote hash');
269
+ hashedDiff = (0, utils_2.compareHashes)(localHash, remoteHashMap);
270
+ return [4 /*yield*/, createHashFile(JSON.stringify(hashedDiff, null, 2), path_1.default.join(outputFolder, 'hashesDiff.json'))];
271
+ case 8:
272
+ _l.sent();
273
+ (_g = process.logger) === null || _g === void 0 ? void 0 : _g.info('generating program to sync differences');
274
+ return [4 /*yield*/, (0, utils_2.generateProgramToSyncHashDiff)(hashedDiff, remoteFolderPath)];
275
+ case 9:
276
+ syncProgram = _l.sent();
277
+ (_h = process.logger) === null || _h === void 0 ? void 0 : _h.info('executing program to sync differences');
278
+ return [4 /*yield*/, (0, executeCode_1.executeCode)(target, syncProgram)];
279
+ case 10:
280
+ syncLog = (_l.sent()).log;
281
+ return [4 /*yield*/, (0, utils_1.saveLog)(syncLog, path_1.default.join(outputFolder, 'sync.log'), '', false)];
282
+ case 11:
283
+ _l.sent();
284
+ syncedHash = (0, extractHashArray_1.extractHashArray)(syncLog);
285
+ return [4 /*yield*/, createHashFile(JSON.stringify(syncedHash, null, 2), path_1.default.join(outputFolder, 'hashesAfterSync.json'))];
286
+ case 12:
287
+ _l.sent();
288
+ syncedHashMap = syncedHash.reduce(function (map, item) {
289
+ var relativePath = (0, utils_2.getRelativePath)(remoteFolderPath, item.FILE_PATH);
290
+ map[relativePath] = item.FILE_HASH;
291
+ return map;
292
+ }, {});
293
+ syncedResources = [];
294
+ Object.entries(syncedHashMap).forEach(function (_a) {
295
+ var _b = __read(_a, 2), key = _b[0], value = _b[1];
296
+ if (remoteHashMap[key] !== value)
297
+ syncedResources.push(key);
298
+ });
299
+ if (syncedResources.length) {
300
+ (_j = process.logger) === null || _j === void 0 ? void 0 : _j.log('The following resources were synced:');
301
+ syncedResources.forEach(function (item) {
302
+ var _a;
303
+ (_a = process.logger) === null || _a === void 0 ? void 0 : _a.log("* ".concat(item));
304
+ });
305
+ }
306
+ resourcesNotPresentLocally = (0, utils_2.findResourcesNotPresentLocally)(localHash, syncedHashMap);
307
+ if (resourcesNotPresentLocally.length) {
308
+ (_k = process.logger) === null || _k === void 0 ? void 0 : _k.log('The following resources are present in remote directory but not in local:');
309
+ resourcesNotPresentLocally.forEach(function (item) {
310
+ var _a;
311
+ (_a = process.logger) === null || _a === void 0 ? void 0 : _a.log("* ".concat(item));
312
+ });
313
+ }
314
+ return [2 /*return*/, command_1.ReturnCode.Success];
315
+ }
316
+ });
317
+ });
318
+ };
319
+ return FSCommand;
320
+ }(targetCommand_1.TargetCommand));
321
+ exports.FSCommand = FSCommand;
322
+ var createHashFile = function (content, fileName) { return __awaiter(void 0, void 0, void 0, function () {
323
+ var _a, _b;
324
+ return __generator(this, function (_c) {
325
+ switch (_c.label) {
326
+ case 0:
327
+ (_a = process.logger) === null || _a === void 0 ? void 0 : _a.info("Creating json file at ".concat(fileName, " ."));
328
+ return [4 /*yield*/, (0, utils_2.createFile)(fileName, content)];
329
+ case 1:
330
+ _c.sent();
331
+ (_b = process.logger) === null || _b === void 0 ? void 0 : _b.success("Hashes saved to ".concat(fileName, " ."));
332
+ return [2 /*return*/];
333
+ }
334
+ });
335
+ }); };
@@ -0,0 +1,4 @@
1
+ import { Target } from '@sasjs/utils';
2
+ export declare const executeCode: (target: Target, code: string) => Promise<{
3
+ log: any;
4
+ }>;
@@ -0,0 +1,126 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.executeCode = void 0;
40
+ var utils_1 = require("@sasjs/utils");
41
+ var utils_2 = require("../../../utils/");
42
+ var executeCode = function (target, code) { return __awaiter(void 0, void 0, void 0, function () {
43
+ return __generator(this, function (_a) {
44
+ switch (_a.label) {
45
+ case 0:
46
+ if (!(target.serverType === utils_1.ServerType.SasViya)) return [3 /*break*/, 2];
47
+ return [4 /*yield*/, executeOnSasViya(target, code)];
48
+ case 1: return [2 /*return*/, _a.sent()];
49
+ case 2:
50
+ if (!(target.serverType === utils_1.ServerType.Sas9)) return [3 /*break*/, 4];
51
+ return [4 /*yield*/, executeOnSas9(target, code)];
52
+ case 3: return [2 /*return*/, _a.sent()];
53
+ case 4: return [4 /*yield*/, executeOnSasJS(target, code)];
54
+ case 5: return [2 /*return*/, _a.sent()];
55
+ }
56
+ });
57
+ }); };
58
+ exports.executeCode = executeCode;
59
+ var executeOnSasViya = function (target, code) { return __awaiter(void 0, void 0, void 0, function () {
60
+ var _a, sasjs, authConfig, contextName, log;
61
+ var _b;
62
+ return __generator(this, function (_c) {
63
+ switch (_c.label) {
64
+ case 0: return [4 /*yield*/, (0, utils_2.getSASjsAndAuthConfig)(target)];
65
+ case 1:
66
+ _a = _c.sent(), sasjs = _a.sasjs, authConfig = _a.authConfig;
67
+ contextName = (_b = target.contextName) !== null && _b !== void 0 ? _b : sasjs.getSasjsConfig().contextName;
68
+ return [4 /*yield*/, sasjs.executeScript({
69
+ fileName: 'program.sas',
70
+ linesOfCode: code.split('\n'),
71
+ contextName: contextName,
72
+ authConfig: authConfig
73
+ })];
74
+ case 2:
75
+ log = (_c.sent()).log;
76
+ return [2 /*return*/, { log: log }];
77
+ }
78
+ });
79
+ }); };
80
+ var executeOnSas9 = function (target, code) { return __awaiter(void 0, void 0, void 0, function () {
81
+ var _a, sasjs, authConfigSas9, userName, password, executionResult;
82
+ return __generator(this, function (_b) {
83
+ switch (_b.label) {
84
+ case 0: return [4 /*yield*/, (0, utils_2.getSASjsAndAuthConfig)(target)];
85
+ case 1:
86
+ _a = _b.sent(), sasjs = _a.sasjs, authConfigSas9 = _a.authConfigSas9;
87
+ userName = authConfigSas9.userName;
88
+ password = (0, utils_1.decodeFromBase64)(authConfigSas9.password);
89
+ return [4 /*yield*/, sasjs.executeScript({
90
+ linesOfCode: code.split('\n'),
91
+ authConfigSas9: { userName: userName, password: password }
92
+ })];
93
+ case 2:
94
+ executionResult = _b.sent();
95
+ return [2 /*return*/, { log: executionResult }];
96
+ }
97
+ });
98
+ }); };
99
+ var executeOnSasJS = function (target, code) { return __awaiter(void 0, void 0, void 0, function () {
100
+ var authConfig, _a, sasjs, executionResult;
101
+ return __generator(this, function (_b) {
102
+ switch (_b.label) {
103
+ case 0: return [4 /*yield*/, (0, utils_2.isSasJsServerInServerMode)(target)];
104
+ case 1:
105
+ if (!(_b.sent())) return [3 /*break*/, 3];
106
+ return [4 /*yield*/, (0, utils_2.getAuthConfig)(target)];
107
+ case 2:
108
+ _a = _b.sent();
109
+ return [3 /*break*/, 4];
110
+ case 3:
111
+ _a = undefined;
112
+ _b.label = 4;
113
+ case 4:
114
+ authConfig = _a;
115
+ sasjs = (0, utils_2.getSASjs)(target);
116
+ return [4 /*yield*/, sasjs.executeScript({
117
+ linesOfCode: code.split('\n'),
118
+ runTime: 'sas',
119
+ authConfig: authConfig
120
+ })];
121
+ case 5:
122
+ executionResult = _b.sent();
123
+ return [2 /*return*/, { log: executionResult }];
124
+ }
125
+ });
126
+ }); };
@@ -0,0 +1 @@
1
+ export declare const extractHashArray: (log: string) => any;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractHashArray = void 0;
4
+ var utils_1 = require("../../../utils");
5
+ var extractHashArray = function (log) {
6
+ if (log.includes('>>weboutBEGIN<<')) {
7
+ try {
8
+ var webout = log
9
+ .split(/>>weboutBEGIN<<\n/)[1]
10
+ .split(/>>weboutEND<<\n/)[0];
11
+ var jsonWebout = JSON.parse(webout);
12
+ return jsonWebout.hashes;
13
+ }
14
+ catch (err) {
15
+ (0, utils_1.displayError)(err, 'An error occurred while extracting hashes array from webout.');
16
+ throw new Error('An error occurred while extracting hashes array from webout.');
17
+ }
18
+ }
19
+ };
20
+ exports.extractHashArray = extractHashArray;
@@ -0,0 +1 @@
1
+ export {};