@sasjs/cli 3.0.2 → 3.2.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 (81) hide show
  1. package/build/commands/add/addCredential.d.ts +6 -2
  2. package/build/commands/add/addCredential.js +79 -47
  3. package/build/commands/add/addTarget.js +32 -20
  4. package/build/commands/add/internal/input.d.ts +7 -0
  5. package/build/commands/add/internal/input.js +53 -8
  6. package/build/commands/add/spec/addTarget.spec.js +78 -0
  7. package/build/commands/build/build.js +11 -11
  8. package/build/commands/build/internal/config.d.ts +1 -1
  9. package/build/commands/build/internal/config.js +5 -6
  10. package/build/commands/compile/compile.js +4 -4
  11. package/build/commands/compile/compileCommand.js +2 -1
  12. package/build/commands/compile/compileSingleFile.d.ts +1 -1
  13. package/build/commands/compile/compileSingleFile.js +6 -7
  14. package/build/commands/compile/internal/compareFolders.js +1 -2
  15. package/build/commands/compile/internal/compileJobFile.js +1 -1
  16. package/build/commands/compile/internal/compileServiceFile.js +32 -16
  17. package/build/commands/compile/internal/compileTestFile.d.ts +0 -2
  18. package/build/commands/compile/internal/compileTestFile.js +10 -14
  19. package/build/commands/compile/internal/getAllJobFolders.js +1 -1
  20. package/build/commands/compile/internal/getAllServiceFolders.js +1 -1
  21. package/build/commands/compile/internal/loadDependencies.d.ts +2 -3
  22. package/build/commands/compile/internal/loadDependencies.js +43 -230
  23. package/build/commands/compile/internal/spec/compileTestFile.spec.js +8 -8
  24. package/build/commands/compile/spec/compileJobFile.spec.js +3 -3
  25. package/build/commands/compile/spec/compileServiceFile.spec.js +3 -3
  26. package/build/commands/compile/spec/loadDependencies.spec.js +37 -37
  27. package/build/commands/create/spec/reactAppFiles.js +5 -5
  28. package/build/commands/deploy/deploy.js +1 -1
  29. package/build/commands/deploy/spec/cbd.spec.js +19 -3
  30. package/build/commands/docs/generateDocs.js +4 -5
  31. package/build/commands/docs/internal/getFileInputs.d.ts +1 -1
  32. package/build/commands/docs/internal/getFileInputs.js +2 -2
  33. package/build/commands/docs/internal/getFileOutputs.d.ts +1 -1
  34. package/build/commands/docs/internal/getFileOutputs.js +2 -2
  35. package/build/commands/docs/internal/getFoldersForDocs.d.ts +1 -1
  36. package/build/commands/docs/internal/getFoldersForDocs.js +1 -1
  37. package/build/commands/job/internal/execute/viya.js +0 -6
  38. package/build/commands/job/internal/utils.js +6 -8
  39. package/build/commands/job/jobCommand.d.ts +1 -0
  40. package/build/commands/job/jobCommand.js +8 -3
  41. package/build/commands/job/spec/jobCommand.spec.js +10 -3
  42. package/build/commands/request/request.js +2 -2
  43. package/build/commands/run/run.js +1 -1
  44. package/build/commands/servicepack/deploy.js +1 -1
  45. package/build/commands/shared/fetchLogFileContent.js +6 -8
  46. package/build/commands/testing/test.js +1 -1
  47. package/build/commands/web/internal/getTags.d.ts +2 -1
  48. package/build/commands/web/internal/getTags.js +10 -12
  49. package/build/commands/web/internal/getWebServiceContent.js +1 -2
  50. package/build/commands/web/internal/sasjsout.d.ts +1 -1
  51. package/build/commands/web/internal/sasjsout.js +1 -1
  52. package/build/commands/web/internal/spec/updateLinkTag.spec.d.ts +4 -0
  53. package/build/commands/web/internal/spec/updateLinkTag.spec.js +32 -0
  54. package/build/commands/web/internal/updateAllTags.js +33 -8
  55. package/build/commands/web/internal/updateLinkTag.d.ts +4 -0
  56. package/build/commands/web/internal/updateLinkTag.js +24 -0
  57. package/build/commands/web/web.js +12 -13
  58. package/build/utils/auth.d.ts +10 -4
  59. package/build/utils/auth.js +17 -15
  60. package/build/utils/config.d.ts +2 -3
  61. package/build/utils/config.js +14 -16
  62. package/build/utils/file.d.ts +0 -6
  63. package/build/utils/file.js +1 -43
  64. package/build/utils/setConstants.js +1 -1
  65. package/build/utils/spec/utils.spec.js +31 -5
  66. package/build/utils/utils.d.ts +0 -2
  67. package/build/utils/utils.js +2 -21
  68. package/package.json +8 -14
  69. package/CHANGELOG.md +0 -30
  70. package/build/commands/compile/internal/config.d.ts +0 -25
  71. package/build/commands/compile/internal/config.js +0 -259
  72. package/build/commands/compile/spec/getDependencyPaths.spec.d.ts +0 -1
  73. package/build/commands/compile/spec/getDependencyPaths.spec.js +0 -263
  74. package/build/commands/compile/spec/getProgramDependencies.spec.d.ts +0 -1
  75. package/build/commands/compile/spec/getProgramDependencies.spec.js +0 -403
  76. package/build/commands/shared/dependencies.d.ts +0 -12
  77. package/build/commands/shared/dependencies.js +0 -332
  78. package/build/commands/web/internal/updateLinkHref.d.ts +0 -4
  79. package/build/commands/web/internal/updateLinkHref.js +0 -18
  80. package/build/utils/spec/utils.spec.server.d.ts +0 -1
  81. package/build/utils/spec/utils.spec.server.js +0 -72
@@ -59,7 +59,7 @@ function runSasJob(target, isLocal, sasJobLocation, dataFilePath, configFilePath
59
59
  if (dataFilePath.split('.').slice(-1)[0] !== 'json') {
60
60
  throw new Error('Provided data file must be valid json.');
61
61
  }
62
- return [4 /*yield*/, utils_1.readFile(utils_2.getAbsolutePath(dataFilePath, process.projectDir))];
62
+ return [4 /*yield*/, utils_1.readFile(utils_1.getAbsolutePath(dataFilePath, process.projectDir))];
63
63
  case 1:
64
64
  dataFile = _a.sent();
65
65
  try {
@@ -74,7 +74,7 @@ function runSasJob(target, isLocal, sasJobLocation, dataFilePath, configFilePath
74
74
  if (configFilePath.split('.').slice(-1)[0] !== 'json') {
75
75
  throw new Error('Provided config file must be valid json.');
76
76
  }
77
- return [4 /*yield*/, utils_1.readFile(utils_2.getAbsolutePath(configFilePath, process.projectDir))];
77
+ return [4 /*yield*/, utils_1.readFile(utils_1.getAbsolutePath(configFilePath, process.projectDir))];
78
78
  case 3:
79
79
  configFile = _a.sent();
80
80
  try {
@@ -113,7 +113,7 @@ function runSasCode(target, filePath, compile) {
113
113
  (_a = process.logger) === null || _a === void 0 ? void 0 : _a.success("File Compiled and placed at: " + filePath + " .");
114
114
  _b.label = 4;
115
115
  case 4:
116
- sasFilePath = utils_2.getAbsolutePath(filePath, process.currentDir);
116
+ sasFilePath = utils_1.getAbsolutePath(filePath, process.currentDir);
117
117
  return [4 /*yield*/, utils_1.readFile(sasFilePath)];
118
118
  case 5:
119
119
  sasFileContent = _b.sent();
@@ -42,7 +42,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
42
42
  exports.servicePackDeploy = void 0;
43
43
  var path_1 = __importDefault(require("path"));
44
44
  var displayResult_1 = require("../../utils/displayResult");
45
- var utils_1 = require("../../utils/utils");
45
+ var utils_1 = require("@sasjs/utils");
46
46
  var deployToSasViyaWithServicePack_1 = require("../shared/deployToSasViyaWithServicePack");
47
47
  function servicePackDeploy(target, isLocal, jsonFilePath, isForced) {
48
48
  var _a;
@@ -68,28 +68,26 @@ exports.fetchLogFileContent = void 0;
68
68
  */
69
69
  var fetchLogFileContent = function (sasjs, accessToken, logUrl, logCount) { return __awaiter(void 0, void 0, void 0, function () {
70
70
  var logJson, loglimit, start, logChunkJson, _a, _b;
71
- var _c;
72
- return __generator(this, function (_d) {
73
- switch (_d.label) {
71
+ return __generator(this, function (_c) {
72
+ switch (_c.label) {
74
73
  case 0:
75
74
  logJson = { items: [] };
76
75
  loglimit = logCount < 10000 ? logCount : 10000;
77
76
  start = 0;
78
- _d.label = 1;
77
+ _c.label = 1;
79
78
  case 1:
80
- (_c = process.logger) === null || _c === void 0 ? void 0 : _c.info("Fetching logs from line no: " + (start + 1) + " to " + (start + loglimit) + " of " + logCount + ".");
81
79
  _b = (_a = JSON).parse;
82
80
  return [4 /*yield*/, sasjs.fetchLogFileContent(logUrl + "?start=" + start + "&limit=" + loglimit, accessToken)];
83
81
  case 2:
84
- logChunkJson = _b.apply(_a, [(_d.sent())]);
82
+ logChunkJson = _b.apply(_a, [(_c.sent())]);
85
83
  if (logChunkJson.items.length === 0)
86
84
  return [3 /*break*/, 4];
87
85
  logJson.items = __spreadArray(__spreadArray([], __read(logJson.items)), __read(logChunkJson.items));
88
86
  start += loglimit;
89
- _d.label = 3;
87
+ _c.label = 3;
90
88
  case 3:
91
89
  if (start < logCount) return [3 /*break*/, 1];
92
- _d.label = 4;
90
+ _c.label = 4;
93
91
  case 4: return [2 /*return*/, logJson];
94
92
  }
95
93
  });
@@ -205,6 +205,7 @@ function runTest(target, testRegExps, outDirectory, flowSourcePath) {
205
205
  testUrl = testUrl + "&_contextName=" + encodeURIComponent(target.contextName);
206
206
  }
207
207
  printTestUrl = function () { return process.logger.info("Test URL: " + testUrl); };
208
+ printTestUrl();
208
209
  return [4 /*yield*/, sasjs
209
210
  .request(sasJobLocation, {}, { username: username, password: password }, function () {
210
211
  displayResult_1.displayError(null, 'Login callback called. Request failed.');
@@ -247,7 +248,6 @@ function runTest(target, testRegExps, outDirectory, flowSourcePath) {
247
248
  }
248
249
  if (!((_a = res.result) === null || _a === void 0 ? void 0 : _a.test_results))
249
250
  lineBreak = false;
250
- printTestUrl();
251
251
  if (!res.log) return [3 /*break*/, 2];
252
252
  return [4 /*yield*/, saveOutput_1.saveLog(outDirectory, test, res.log, lineBreak)];
253
253
  case 1:
@@ -1,4 +1,5 @@
1
1
  import { JSDOM } from 'jsdom';
2
2
  export declare const getScriptTags: (parsedHtml: JSDOM) => HTMLScriptElement[];
3
- export declare const getLinkTags: (parsedHtml: JSDOM) => HTMLLinkElement[];
3
+ export declare const getStyleTags: (parsedHtml: JSDOM) => HTMLLinkElement[];
4
4
  export declare const getFaviconTags: (parsedHtml: JSDOM) => HTMLLinkElement[];
5
+ export declare const getImgTags: (parsedHtml: JSDOM) => HTMLImageElement[];
@@ -1,21 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getFaviconTags = exports.getLinkTags = exports.getScriptTags = void 0;
3
+ exports.getImgTags = exports.getFaviconTags = exports.getStyleTags = exports.getScriptTags = void 0;
4
4
  var getScriptTags = function (parsedHtml) {
5
- return Array.from(parsedHtml.window.document.querySelectorAll('script'));
5
+ return Array.from(parsedHtml.window.document.getElementsByTagName('script'));
6
6
  };
7
7
  exports.getScriptTags = getScriptTags;
8
- var getLinkTags = function (parsedHtml) {
9
- var linkTags = Array.from(parsedHtml.window.document.querySelectorAll('link')).filter(function (s) { return s.getAttribute('rel') === 'stylesheet'; });
10
- return linkTags;
8
+ var getStyleTags = function (parsedHtml) {
9
+ return Array.from(parsedHtml.window.document.getElementsByTagName('link')).filter(function (s) { return s.getAttribute('rel') === 'stylesheet'; });
11
10
  };
12
- exports.getLinkTags = getLinkTags;
11
+ exports.getStyleTags = getStyleTags;
13
12
  var getFaviconTags = function (parsedHtml) {
14
- var linkTags = Array.from(parsedHtml.window.document.querySelectorAll('link')).filter(function (s) {
15
- return s.getAttribute('rel') &&
16
- s.getAttribute('rel') &&
17
- s.getAttribute('rel').includes('icon');
18
- });
19
- return linkTags;
13
+ return Array.from(parsedHtml.window.document.getElementsByTagName('link')).filter(function (s) { var _a; return (_a = s.getAttribute('rel')) === null || _a === void 0 ? void 0 : _a.includes('icon'); });
20
14
  };
21
15
  exports.getFaviconTags = getFaviconTags;
16
+ var getImgTags = function (parsedHtml) {
17
+ return Array.from(parsedHtml.window.document.getElementsByTagName('img')).filter(function (s) { return s.getAttribute('src'); });
18
+ };
19
+ exports.getImgTags = getImgTags;
@@ -38,7 +38,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.getWebServiceContent = void 0;
40
40
  var utils_1 = require("@sasjs/utils");
41
- var utils_2 = require("../../../utils");
42
41
  var sasjsout_1 = require("./sasjsout");
43
42
  var getWebServiceContent = function (contentBase64, type, serverType) {
44
43
  if (type === void 0) { type = 'JS'; }
@@ -52,7 +51,7 @@ var getWebServiceContent = function (contentBase64, type, serverType) {
52
51
  };
53
52
  serviceContent = sasjsout_1.sasjsout + "\nfilename sasjs temp lrecl=99999999;\ndata _null_;\nfile sasjs;\n";
54
53
  lines.forEach(function (line) {
55
- var chunkedLines = utils_2.chunk(line);
54
+ var chunkedLines = utils_1.chunk(line);
56
55
  if (chunkedLines.length === 1) {
57
56
  serviceContent += "put '" + chunkedLines[0].split("'").join("''") + "';\n";
58
57
  }
@@ -1 +1 @@
1
- export declare const sasjsout = "\n%macro sasjsout(type,fref=sasjs);\n%global sysprocessmode SYS_JES_JOB_URI;\n%if \"&sysprocessmode\"=\"SAS Compute Server\" %then %do;\n %if &type=HTML %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name=\"_webout.json\"\n contenttype=\"text/html\";\n %end;\n %else %if &type=JS or &type=JS64 %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.js'\n contenttype='application/javascript';\n %end;\n %else %if &type=CSS or &type=CSS64 %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.css'\n contenttype='text/css';\n %end;\n %else %if &type=PNG %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.png'\n contenttype='image/png' lrecl=2000000 recfm=n;\n %end;\n %else %if &type=ICO %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.ico'\n contenttype='image/vnd.microsoft.icon' lrecl=2000000 recfm=n;\n %end;\n %else %if &type=JSON %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.json'\n contenttype='application/json' lrecl=2000000 recfm=n;\n %end;\n %else %if &type=MP3 %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.mp3'\n contenttype='audio/mpeg' lrecl=2000000 recfm=n;\n %end;\n %else %if &type=WAV %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.wav'\n contenttype='audio/x-wav' lrecl=2000000 recfm=n;\n %end;\n %else %if &type=OGG %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.ogg'\n contenttype='audio/ogg' lrecl=2000000 recfm=n;\n %end;\n%end;\n%else %do;\n %if &type=JS or &type=JS64 %then %do;\n %let rc=%sysfunc(stpsrv_header(\n Content-type,application/javascript%str(;)charset=UTF-8\n ));\n %end;\n %else %if &type=CSS or &type=CSS64 %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,text/css));\n %end;\n %else %if &type=PNG %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,image/png));\n %end;\n %else %if &type=ICO %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,image/vnd.microsoft.icon));\n %end;\n %else %if &type=JSON %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,application/json));\n %end;\n %else %if &type=MP3 %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,audio/mpeg));\n %end;\n %else %if &type=WAV %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,audio/x-wav));\n %end;\n %else %if &type=OGG %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,audio/ogg));\n %end;\n%end;\n%if &type=HTML %then %do;\n /*\n We need to perform some substitutions -eg to get the APPLOC and SERVERTYPE.\n Therefore the developer should avoid writing lines that exceed 32k\n characters (eg base64 encoded images) as they will get truncated when passing\n through the datastep. This could of course be re-written using LUA, removing\n the length restriction. Pull requests are welcome!\n */\n filename _sjs temp;\n data _null_;\n file _sjs lrecl=32767 encoding='utf-8';\n infile &fref lrecl=32767;\n input;\n length appLoc expanded_path $1048;\n if _n_=1 then do;\n retain pgm \"&_program\" appLoc expanded_path;\n /* index is deployed in the /services/ folder under the appLoc */\n appLoc=substr(pgm,1,find(pgm,'/services/')-1);\n expanded_path=cats('?_PROGRAM=',appLoc,'/services/');\n end;\n if find(_infile_,' appLoc: ') then put ' appLoc: ' apploc:$quote1048. ',';\n else if find(_infile_,' serverType: ') then do;\n if symexist('_metaperson') then put ' serverType: \"SAS9\" ,';\n else put ' serverType: \"SASVIYA\" ,';\n end;\n else if find(_infile_,' hostUrl: ') then do;\n /* nothing - we are streaming, so remove to default as hostname */\n end;\n else do;\n length newline $32767;\n /* during SAS9 compilation, dependencies are assigned three slashes /// */\n newline=tranwrd(_infile_,'?_PROGRAM=///',cats(expanded_path));\n put newline;\n end;\n run;\n %let fref=_sjs;\n%end;\n\n/* stream byte by byte */\n/* in SAS9, JS & CSS files are base64 encoded to avoid UTF8 issues in WLATIN1 metadata */\n%if &type=PNG or &type=ICO or &type=MP3 or &type=JS64 or &type=CSS64 or &type=WAV or &type=OGG\n%then %do;\n data _null_;\n length filein 8 fileout 8;\n filein = fopen(\"&fref\",'I',4,'B');\n fileout = fopen(\"_webout\",'A',1,'B');\n char= '20'x;\n do while(fread(filein)=0);\n length raw $4 ;\n do i=1 to 4;\n rc=fget(filein,char,1);\n substr(raw,i,1)=char;\n end;\n rc = fput(fileout, input(raw,$base64X4.));\n rc =fwrite(fileout);\n end;\n rc = fclose(filein);\n rc = fclose(fileout);\n run;\n%end;\n%else %do;\n data _null_;\n length filein 8 fileid 8;\n filein = fopen(\"&fref\",'I',1,'B');\n fileid = fopen(\"_webout\",'A',1,'B');\n rec = '20'x;\n do while(fread(filein)=0);\n rc = fget(filein,rec,1);\n rc = fput(fileid, rec);\n rc =fwrite(fileid);\n end;\n rc = fclose(filein);\n rc = fclose(fileid);\n run;\n%end;\n%mend;";
1
+ export declare const sasjsout = "\n%macro sasjsout(type,fref=sasjs);\n%global sysprocessmode SYS_JES_JOB_URI;\n%if \"&sysprocessmode\"=\"SAS Compute Server\" %then %do;\n %if &type=HTML %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name=\"_webout.json\"\n contenttype=\"text/html\";\n %end;\n %else %if &type=JS or &type=JS64 %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.js'\n contenttype='application/javascript';\n %end;\n %else %if &type=CSS or &type=CSS64 %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.css'\n contenttype='text/css';\n %end;\n %else %if &type=PNG %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.png'\n contenttype='image/png' lrecl=2000000 recfm=n;\n %end;\n %else %if &type=JPG %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.jpg'\n contenttype='image/jpg' lrecl=2000000 recfm=n;\n %end;\n %else %if &type=JPEG %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.jpeg'\n contenttype='image/jpeg' lrecl=2000000 recfm=n;\n %end;\n %else %if &type=ICO %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.ico'\n contenttype='image/vnd.microsoft.icon' lrecl=2000000 recfm=n;\n %end;\n %else %if &type=JSON %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.json'\n contenttype='application/json' lrecl=2000000 recfm=n;\n %end;\n %else %if &type=MP3 %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.mp3'\n contenttype='audio/mpeg' lrecl=2000000 recfm=n;\n %end;\n %else %if &type=WAV %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.wav'\n contenttype='audio/x-wav' lrecl=2000000 recfm=n;\n %end;\n %else %if &type=OGG %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.ogg'\n contenttype='audio/ogg' lrecl=2000000 recfm=n;\n %end;\n%end;\n%else %do;\n %if &type=JS or &type=JS64 %then %do;\n %let rc=%sysfunc(stpsrv_header(\n Content-type,application/javascript%str(;)charset=UTF-8\n ));\n %end;\n %else %if &type=CSS or &type=CSS64 %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,text/css));\n %end;\n %else %if &type=PNG %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,image/png));\n %end;\n %else %if &type=JPG %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,image/jpg));\n %end;\n %else %if &type=JPEG %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,image/jpeg));\n %end;\n %else %if &type=ICO %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,image/vnd.microsoft.icon));\n %end;\n %else %if &type=JSON %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,application/json));\n %end;\n %else %if &type=MP3 %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,audio/mpeg));\n %end;\n %else %if &type=WAV %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,audio/x-wav));\n %end;\n %else %if &type=OGG %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,audio/ogg));\n %end;\n%end;\n%if &type=HTML %then %do;\n /*\n We need to perform some substitutions -eg to get the APPLOC and SERVERTYPE.\n Therefore the developer should avoid writing lines that exceed 32k\n characters (eg base64 encoded images) as they will get truncated when passing\n through the datastep. This could of course be re-written using LUA, removing\n the length restriction. Pull requests are welcome!\n */\n filename _sjs temp;\n data _null_;\n file _sjs lrecl=32767 encoding='utf-8';\n infile &fref lrecl=32767;\n input;\n length appLoc expanded_path $1048;\n if _n_=1 then do;\n retain pgm \"&_program\" appLoc expanded_path;\n /* index is deployed in the /services/ folder under the appLoc */\n appLoc=substr(pgm,1,find(pgm,'/services/')-1);\n expanded_path=cats('?_PROGRAM=',appLoc,'/services/');\n end;\n if find(_infile_,' appLoc: ') then put ' appLoc: ' apploc:$quote1048. ',';\n else if find(_infile_,' serverType: ') then do;\n if symexist('_metaperson') then put ' serverType: \"SAS9\" ,';\n else put ' serverType: \"SASVIYA\" ,';\n end;\n else if find(_infile_,' hostUrl: ') then do;\n /* nothing - we are streaming, so remove to default as hostname */\n end;\n else do;\n length newline $32767;\n /* during SAS9 compilation, dependencies are assigned three slashes /// */\n newline=tranwrd(_infile_,'?_PROGRAM=///',cats(expanded_path));\n put newline;\n end;\n run;\n %let fref=_sjs;\n%end;\n\n/* stream byte by byte */\n/* in SAS9, JS & CSS files are base64 encoded to avoid UTF8 issues in WLATIN1 metadata */\n%if &type=PNG or &type=JPG or &type=JPEG or &type=ICO or &type=MP3 or &type=JS64 or &type=CSS64 or &type=WAV or &type=OGG\n%then %do;\n data _null_;\n length filein 8 fileout 8;\n filein = fopen(\"&fref\",'I',4,'B');\n fileout = fopen(\"_webout\",'A',1,'B');\n char= '20'x;\n do while(fread(filein)=0);\n length raw $4 ;\n do i=1 to 4;\n rc=fget(filein,char,1);\n substr(raw,i,1)=char;\n end;\n rc = fput(fileout, input(raw,$base64X4.));\n rc =fwrite(fileout);\n end;\n rc = fclose(filein);\n rc = fclose(fileout);\n run;\n%end;\n%else %do;\n data _null_;\n length filein 8 fileid 8;\n filein = fopen(\"&fref\",'I',1,'B');\n fileid = fopen(\"_webout\",'A',1,'B');\n rec = '20'x;\n do while(fread(filein)=0);\n rc = fget(filein,rec,1);\n rc = fput(fileid, rec);\n rc =fwrite(fileid);\n end;\n rc = fclose(filein);\n rc = fclose(fileid);\n run;\n%end;\n%mend;";
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.sasjsout = void 0;
4
- exports.sasjsout = "\n%macro sasjsout(type,fref=sasjs);\n%global sysprocessmode SYS_JES_JOB_URI;\n%if \"&sysprocessmode\"=\"SAS Compute Server\" %then %do;\n %if &type=HTML %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name=\"_webout.json\"\n contenttype=\"text/html\";\n %end;\n %else %if &type=JS or &type=JS64 %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.js'\n contenttype='application/javascript';\n %end;\n %else %if &type=CSS or &type=CSS64 %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.css'\n contenttype='text/css';\n %end;\n %else %if &type=PNG %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.png'\n contenttype='image/png' lrecl=2000000 recfm=n;\n %end;\n %else %if &type=ICO %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.ico'\n contenttype='image/vnd.microsoft.icon' lrecl=2000000 recfm=n;\n %end;\n %else %if &type=JSON %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.json'\n contenttype='application/json' lrecl=2000000 recfm=n;\n %end;\n %else %if &type=MP3 %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.mp3'\n contenttype='audio/mpeg' lrecl=2000000 recfm=n;\n %end;\n %else %if &type=WAV %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.wav'\n contenttype='audio/x-wav' lrecl=2000000 recfm=n;\n %end;\n %else %if &type=OGG %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.ogg'\n contenttype='audio/ogg' lrecl=2000000 recfm=n;\n %end;\n%end;\n%else %do;\n %if &type=JS or &type=JS64 %then %do;\n %let rc=%sysfunc(stpsrv_header(\n Content-type,application/javascript%str(;)charset=UTF-8\n ));\n %end;\n %else %if &type=CSS or &type=CSS64 %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,text/css));\n %end;\n %else %if &type=PNG %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,image/png));\n %end;\n %else %if &type=ICO %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,image/vnd.microsoft.icon));\n %end;\n %else %if &type=JSON %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,application/json));\n %end;\n %else %if &type=MP3 %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,audio/mpeg));\n %end;\n %else %if &type=WAV %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,audio/x-wav));\n %end;\n %else %if &type=OGG %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,audio/ogg));\n %end;\n%end;\n%if &type=HTML %then %do;\n /*\n We need to perform some substitutions -eg to get the APPLOC and SERVERTYPE.\n Therefore the developer should avoid writing lines that exceed 32k\n characters (eg base64 encoded images) as they will get truncated when passing\n through the datastep. This could of course be re-written using LUA, removing\n the length restriction. Pull requests are welcome!\n */\n filename _sjs temp;\n data _null_;\n file _sjs lrecl=32767 encoding='utf-8';\n infile &fref lrecl=32767;\n input;\n length appLoc expanded_path $1048;\n if _n_=1 then do;\n retain pgm \"&_program\" appLoc expanded_path;\n /* index is deployed in the /services/ folder under the appLoc */\n appLoc=substr(pgm,1,find(pgm,'/services/')-1);\n expanded_path=cats('?_PROGRAM=',appLoc,'/services/');\n end;\n if find(_infile_,' appLoc: ') then put ' appLoc: ' apploc:$quote1048. ',';\n else if find(_infile_,' serverType: ') then do;\n if symexist('_metaperson') then put ' serverType: \"SAS9\" ,';\n else put ' serverType: \"SASVIYA\" ,';\n end;\n else if find(_infile_,' hostUrl: ') then do;\n /* nothing - we are streaming, so remove to default as hostname */\n end;\n else do;\n length newline $32767;\n /* during SAS9 compilation, dependencies are assigned three slashes /// */\n newline=tranwrd(_infile_,'?_PROGRAM=///',cats(expanded_path));\n put newline;\n end;\n run;\n %let fref=_sjs;\n%end;\n\n/* stream byte by byte */\n/* in SAS9, JS & CSS files are base64 encoded to avoid UTF8 issues in WLATIN1 metadata */\n%if &type=PNG or &type=ICO or &type=MP3 or &type=JS64 or &type=CSS64 or &type=WAV or &type=OGG\n%then %do;\n data _null_;\n length filein 8 fileout 8;\n filein = fopen(\"&fref\",'I',4,'B');\n fileout = fopen(\"_webout\",'A',1,'B');\n char= '20'x;\n do while(fread(filein)=0);\n length raw $4 ;\n do i=1 to 4;\n rc=fget(filein,char,1);\n substr(raw,i,1)=char;\n end;\n rc = fput(fileout, input(raw,$base64X4.));\n rc =fwrite(fileout);\n end;\n rc = fclose(filein);\n rc = fclose(fileout);\n run;\n%end;\n%else %do;\n data _null_;\n length filein 8 fileid 8;\n filein = fopen(\"&fref\",'I',1,'B');\n fileid = fopen(\"_webout\",'A',1,'B');\n rec = '20'x;\n do while(fread(filein)=0);\n rc = fget(filein,rec,1);\n rc = fput(fileid, rec);\n rc =fwrite(fileid);\n end;\n rc = fclose(filein);\n rc = fclose(fileid);\n run;\n%end;\n%mend;";
4
+ exports.sasjsout = "\n%macro sasjsout(type,fref=sasjs);\n%global sysprocessmode SYS_JES_JOB_URI;\n%if \"&sysprocessmode\"=\"SAS Compute Server\" %then %do;\n %if &type=HTML %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name=\"_webout.json\"\n contenttype=\"text/html\";\n %end;\n %else %if &type=JS or &type=JS64 %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.js'\n contenttype='application/javascript';\n %end;\n %else %if &type=CSS or &type=CSS64 %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.css'\n contenttype='text/css';\n %end;\n %else %if &type=PNG %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.png'\n contenttype='image/png' lrecl=2000000 recfm=n;\n %end;\n %else %if &type=JPG %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.jpg'\n contenttype='image/jpg' lrecl=2000000 recfm=n;\n %end;\n %else %if &type=JPEG %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.jpeg'\n contenttype='image/jpeg' lrecl=2000000 recfm=n;\n %end;\n %else %if &type=ICO %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.ico'\n contenttype='image/vnd.microsoft.icon' lrecl=2000000 recfm=n;\n %end;\n %else %if &type=JSON %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.json'\n contenttype='application/json' lrecl=2000000 recfm=n;\n %end;\n %else %if &type=MP3 %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.mp3'\n contenttype='audio/mpeg' lrecl=2000000 recfm=n;\n %end;\n %else %if &type=WAV %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.wav'\n contenttype='audio/x-wav' lrecl=2000000 recfm=n;\n %end;\n %else %if &type=OGG %then %do;\n filename _webout filesrvc parenturi=\"&SYS_JES_JOB_URI\" name='_webout.ogg'\n contenttype='audio/ogg' lrecl=2000000 recfm=n;\n %end;\n%end;\n%else %do;\n %if &type=JS or &type=JS64 %then %do;\n %let rc=%sysfunc(stpsrv_header(\n Content-type,application/javascript%str(;)charset=UTF-8\n ));\n %end;\n %else %if &type=CSS or &type=CSS64 %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,text/css));\n %end;\n %else %if &type=PNG %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,image/png));\n %end;\n %else %if &type=JPG %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,image/jpg));\n %end;\n %else %if &type=JPEG %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,image/jpeg));\n %end;\n %else %if &type=ICO %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,image/vnd.microsoft.icon));\n %end;\n %else %if &type=JSON %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,application/json));\n %end;\n %else %if &type=MP3 %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,audio/mpeg));\n %end;\n %else %if &type=WAV %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,audio/x-wav));\n %end;\n %else %if &type=OGG %then %do;\n %let rc=%sysfunc(stpsrv_header(Content-type,audio/ogg));\n %end;\n%end;\n%if &type=HTML %then %do;\n /*\n We need to perform some substitutions -eg to get the APPLOC and SERVERTYPE.\n Therefore the developer should avoid writing lines that exceed 32k\n characters (eg base64 encoded images) as they will get truncated when passing\n through the datastep. This could of course be re-written using LUA, removing\n the length restriction. Pull requests are welcome!\n */\n filename _sjs temp;\n data _null_;\n file _sjs lrecl=32767 encoding='utf-8';\n infile &fref lrecl=32767;\n input;\n length appLoc expanded_path $1048;\n if _n_=1 then do;\n retain pgm \"&_program\" appLoc expanded_path;\n /* index is deployed in the /services/ folder under the appLoc */\n appLoc=substr(pgm,1,find(pgm,'/services/')-1);\n expanded_path=cats('?_PROGRAM=',appLoc,'/services/');\n end;\n if find(_infile_,' appLoc: ') then put ' appLoc: ' apploc:$quote1048. ',';\n else if find(_infile_,' serverType: ') then do;\n if symexist('_metaperson') then put ' serverType: \"SAS9\" ,';\n else put ' serverType: \"SASVIYA\" ,';\n end;\n else if find(_infile_,' hostUrl: ') then do;\n /* nothing - we are streaming, so remove to default as hostname */\n end;\n else do;\n length newline $32767;\n /* during SAS9 compilation, dependencies are assigned three slashes /// */\n newline=tranwrd(_infile_,'?_PROGRAM=///',cats(expanded_path));\n put newline;\n end;\n run;\n %let fref=_sjs;\n%end;\n\n/* stream byte by byte */\n/* in SAS9, JS & CSS files are base64 encoded to avoid UTF8 issues in WLATIN1 metadata */\n%if &type=PNG or &type=JPG or &type=JPEG or &type=ICO or &type=MP3 or &type=JS64 or &type=CSS64 or &type=WAV or &type=OGG\n%then %do;\n data _null_;\n length filein 8 fileout 8;\n filein = fopen(\"&fref\",'I',4,'B');\n fileout = fopen(\"_webout\",'A',1,'B');\n char= '20'x;\n do while(fread(filein)=0);\n length raw $4 ;\n do i=1 to 4;\n rc=fget(filein,char,1);\n substr(raw,i,1)=char;\n end;\n rc = fput(fileout, input(raw,$base64X4.));\n rc =fwrite(fileout);\n end;\n rc = fclose(filein);\n rc = fclose(fileout);\n run;\n%end;\n%else %do;\n data _null_;\n length filein 8 fileid 8;\n filein = fopen(\"&fref\",'I',1,'B');\n fileid = fopen(\"_webout\",'A',1,'B');\n rec = '20'x;\n do while(fread(filein)=0);\n rc = fget(filein,rec,1);\n rc = fput(fileid, rec);\n rc =fwrite(fileid);\n end;\n rc = fclose(filein);\n rc = fclose(fileid);\n run;\n%end;\n%mend;";
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @jest-environment jsdom
3
+ */
4
+ export {};
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ /**
3
+ * @jest-environment jsdom
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ var updateLinkTag_1 = require("../updateLinkTag");
7
+ describe('updateLinkTag', function () {
8
+ it("should update href of link tag", function () {
9
+ var linkTag = document.createElement('link');
10
+ linkTag.setAttribute('href', './style.css');
11
+ var assetPathMap = [];
12
+ var sasProgramPath = '/SASJobExecution?_FILE=appLoc/services/streamWebFolder/style.css';
13
+ assetPathMap.push({
14
+ source: 'style.css',
15
+ target: sasProgramPath
16
+ });
17
+ updateLinkTag_1.updateLinkTag(linkTag, assetPathMap);
18
+ expect(linkTag.getAttribute('href')).toEqual(sasProgramPath);
19
+ });
20
+ it("should update src of image tag", function () {
21
+ var imgTag = document.createElement('img');
22
+ imgTag.setAttribute('src', './image.jpeg');
23
+ var assetPathMap = [];
24
+ var sasProgramPath = '/SASJobExecution?_FILE=appLoc/services/streamWebFolder/image.jpeg';
25
+ assetPathMap.push({
26
+ source: 'image.jpeg',
27
+ target: sasProgramPath
28
+ });
29
+ updateLinkTag_1.updateLinkTag(imgTag, assetPathMap, 'image');
30
+ expect(imgTag.getAttribute('src')).toEqual(sasProgramPath);
31
+ });
32
+ });
@@ -35,16 +35,37 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
35
35
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
36
  }
37
37
  };
38
+ var __read = (this && this.__read) || function (o, n) {
39
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
40
+ if (!m) return o;
41
+ var i = m.call(o), r, ar = [], e;
42
+ try {
43
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
44
+ }
45
+ catch (error) { e = { error: error }; }
46
+ finally {
47
+ try {
48
+ if (r && !r.done && (m = i["return"])) m.call(i);
49
+ }
50
+ finally { if (e) throw e.error; }
51
+ }
52
+ return ar;
53
+ };
54
+ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
55
+ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
56
+ to[j] = from[i];
57
+ return to;
58
+ };
38
59
  Object.defineProperty(exports, "__esModule", { value: true });
39
60
  exports.updateAllTags = void 0;
40
61
  var utils_1 = require("@sasjs/utils");
41
62
  var getTags_1 = require("./getTags");
42
63
  var updateScriptTag_1 = require("./updateScriptTag");
43
- var updateLinkHref_1 = require("./updateLinkHref");
64
+ var updateLinkTag_1 = require("./updateLinkTag");
44
65
  var updateAllTags = function (parsedHtml, _a) {
45
66
  var webSourcePathFull = _a.webSourcePathFull, destinationPath = _a.destinationPath, serverType = _a.serverType, assetPathMap = _a.assetPathMap;
46
67
  return __awaiter(void 0, void 0, void 0, function () {
47
- var assetsNotFound, scriptTags, linkTags, faviconTags, notFoundErrors;
68
+ var assetsNotFound, scriptTags, styleTags, faviconTags, linkTags, imgTags, notFoundErrors;
48
69
  return __generator(this, function (_b) {
49
70
  switch (_b.label) {
50
71
  case 0:
@@ -62,21 +83,25 @@ var updateAllTags = function (parsedHtml, _a) {
62
83
  }); })];
63
84
  case 1:
64
85
  _b.sent();
65
- linkTags = getTags_1.getLinkTags(parsedHtml);
66
- linkTags.forEach(function (linkTag) {
86
+ styleTags = getTags_1.getStyleTags(parsedHtml);
87
+ faviconTags = getTags_1.getFaviconTags(parsedHtml);
88
+ linkTags = __spreadArray(__spreadArray([], __read(styleTags)), __read(faviconTags));
89
+ linkTags.forEach(function (tag) {
67
90
  try {
68
- updateLinkHref_1.updateLinkHref(linkTag, assetPathMap);
91
+ updateLinkTag_1.updateLinkTag(tag, assetPathMap);
69
92
  }
70
93
  catch (error) {
94
+ console.log(tag, error);
71
95
  assetsNotFound.push(error);
72
96
  }
73
97
  });
74
- faviconTags = getTags_1.getFaviconTags(parsedHtml);
75
- faviconTags.forEach(function (faviconTag) {
98
+ imgTags = getTags_1.getImgTags(parsedHtml);
99
+ imgTags.forEach(function (tag) {
76
100
  try {
77
- updateLinkHref_1.updateLinkHref(faviconTag, assetPathMap);
101
+ updateLinkTag_1.updateLinkTag(tag, assetPathMap, 'image');
78
102
  }
79
103
  catch (error) {
104
+ console.log(tag, error);
80
105
  assetsNotFound.push(error);
81
106
  }
82
107
  });
@@ -0,0 +1,4 @@
1
+ export declare const updateLinkTag: (linkTag: HTMLLinkElement | HTMLImageElement, assetPathMap: {
2
+ source: string;
3
+ target: string;
4
+ }[], tagType?: 'link' | 'image') => void;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateLinkTag = void 0;
4
+ var updateLinkTag = function (linkTag, assetPathMap, tagType) {
5
+ if (tagType === void 0) { tagType = 'link'; }
6
+ var linkSourcePath = tagType === 'link'
7
+ ? linkTag.getAttribute('href')
8
+ : linkTag.getAttribute('src');
9
+ if (!linkSourcePath)
10
+ return;
11
+ var isUrl = linkSourcePath.startsWith('http') || linkSourcePath.startsWith('//');
12
+ if (isUrl)
13
+ return;
14
+ var assetPath = assetPathMap.find(function (entry) {
15
+ return entry.source === linkSourcePath || "./" + entry.source === linkSourcePath;
16
+ });
17
+ if (!(assetPath === null || assetPath === void 0 ? void 0 : assetPath.target)) {
18
+ throw new Error("Unable to find file: " + linkSourcePath);
19
+ }
20
+ tagType === 'link'
21
+ ? linkTag.setAttribute('href', assetPath.target)
22
+ : linkTag.setAttribute('src', assetPath.target);
23
+ };
24
+ exports.updateLinkTag = updateLinkTag;
@@ -40,8 +40,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
40
40
  };
41
41
  Object.defineProperty(exports, "__esModule", { value: true });
42
42
  exports.createWebAppServices = void 0;
43
- var utils_1 = require("../../utils/utils");
44
- var utils_2 = require("@sasjs/utils");
43
+ var utils_1 = require("@sasjs/utils");
45
44
  var config_1 = require("../../utils/config");
46
45
  var path_1 = __importDefault(require("path"));
47
46
  var jsdom_1 = __importDefault(require("jsdom"));
@@ -85,7 +84,7 @@ function createWebAppServices(target) {
85
84
  })];
86
85
  case 5:
87
86
  assetPathMap = _c.sent();
88
- return [4 /*yield*/, utils_2.readFile(indexHtmlPath).then(function (content) { return new jsdom_1.default.JSDOM(content); })];
87
+ return [4 /*yield*/, utils_1.readFile(indexHtmlPath).then(function (content) { return new jsdom_1.default.JSDOM(content); })];
89
88
  case 6:
90
89
  indexHtml = _c.sent();
91
90
  return [4 /*yield*/, updateAllTags_1.updateAllTags(indexHtml, {
@@ -96,7 +95,7 @@ function createWebAppServices(target) {
96
95
  })];
97
96
  case 7:
98
97
  _c.sent();
99
- if (!(target.serverType === utils_2.ServerType.SasViya)) return [3 /*break*/, 9];
98
+ if (!(target.serverType === utils_1.ServerType.SasViya)) return [3 /*break*/, 9];
100
99
  indexHtml.window.document.body.innerHTML += adjustIframeScript_1.adjustIframeScript;
101
100
  return [4 /*yield*/, createClickMeFile(indexHtml.serialize(), streamConfig.streamServiceName)];
102
101
  case 8:
@@ -128,13 +127,13 @@ var validateStreamConfig = function (streamConfig) { return __awaiter(void 0, vo
128
127
  throw new Error("Invalid stream web folder: Please specify the `streamConfig` in your target in the following format: \n " + JSON.stringify(exampleStreamConfig, null, 2));
129
128
  }
130
129
  webSourcePathFull = utils_1.getAbsolutePath(streamConfig.webSourcePath, process.projectDir);
131
- return [4 /*yield*/, utils_2.folderExists(webSourcePathFull)];
130
+ return [4 /*yield*/, utils_1.folderExists(webSourcePathFull)];
132
131
  case 1:
133
132
  if (!(_a.sent())) {
134
133
  throw new Error("webSourcePath: '" + webSourcePathFull + "' present in 'streamConfig' doesn't exist.");
135
134
  }
136
135
  indexHtmlPath = path_1.default.join(webSourcePathFull, 'index.html');
137
- return [4 /*yield*/, utils_2.fileExists(indexHtmlPath)];
136
+ return [4 /*yield*/, utils_1.fileExists(indexHtmlPath)];
138
137
  case 2:
139
138
  if (!(_a.sent())) {
140
139
  throw new Error("'index.html' doesn't exist at webSourcePath: '" + webSourcePathFull + "' present in 'streamConfig'");
@@ -150,11 +149,11 @@ function createBuildDestinationFolder() {
150
149
  switch (_a.label) {
151
150
  case 0:
152
151
  buildDestinationFolder = process.sasjsConstants.buildDestinationFolder;
153
- return [4 /*yield*/, utils_2.fileExists(buildDestinationFolder)];
152
+ return [4 /*yield*/, utils_1.fileExists(buildDestinationFolder)];
154
153
  case 1:
155
154
  pathExists = _a.sent();
156
155
  if (!!pathExists) return [3 /*break*/, 3];
157
- return [4 /*yield*/, utils_2.createFolder(buildDestinationFolder)];
156
+ return [4 /*yield*/, utils_1.createFolder(buildDestinationFolder)];
158
157
  case 2:
159
158
  _a.sent();
160
159
  _a.label = 3;
@@ -168,15 +167,15 @@ function createTargetDestinationFolder(destinationPath) {
168
167
  var pathExists;
169
168
  return __generator(this, function (_a) {
170
169
  switch (_a.label) {
171
- case 0: return [4 /*yield*/, utils_2.fileExists(destinationPath)];
170
+ case 0: return [4 /*yield*/, utils_1.fileExists(destinationPath)];
172
171
  case 1:
173
172
  pathExists = _a.sent();
174
173
  if (!pathExists) return [3 /*break*/, 3];
175
- return [4 /*yield*/, utils_2.deleteFolder(destinationPath)];
174
+ return [4 /*yield*/, utils_1.deleteFolder(destinationPath)];
176
175
  case 2:
177
176
  _a.sent();
178
177
  _a.label = 3;
179
- case 3: return [4 /*yield*/, utils_2.createFolder(destinationPath)];
178
+ case 3: return [4 /*yield*/, utils_1.createFolder(destinationPath)];
180
179
  case 4:
181
180
  _a.sent();
182
181
  return [2 /*return*/];
@@ -218,7 +217,7 @@ function createClickMeService(indexHtmlContent, fileName) {
218
217
  });
219
218
  clickMeServiceContent += 'run;\n%sasjsout(HTML)';
220
219
  buildDestinationServicesFolder = process.sasjsConstants.buildDestinationServicesFolder;
221
- return [4 /*yield*/, utils_2.createFile(path_1.default.join(buildDestinationServicesFolder, fileName + ".sas"), clickMeServiceContent)];
220
+ return [4 /*yield*/, utils_1.createFile(path_1.default.join(buildDestinationServicesFolder, fileName + ".sas"), clickMeServiceContent)];
222
221
  case 1:
223
222
  _a.sent();
224
223
  return [2 /*return*/];
@@ -233,7 +232,7 @@ function createClickMeFile(indexHtmlContent, fileName) {
233
232
  switch (_a.label) {
234
233
  case 0:
235
234
  buildDestinationServicesFolder = process.sasjsConstants.buildDestinationServicesFolder;
236
- return [4 /*yield*/, utils_2.createFile(path_1.default.join(buildDestinationServicesFolder, fileName + ".html"), indexHtmlContent)];
235
+ return [4 /*yield*/, utils_1.createFile(path_1.default.join(buildDestinationServicesFolder, fileName + ".html"), indexHtmlContent)];
237
236
  case 1:
238
237
  _a.sent();
239
238
  return [2 /*return*/];
@@ -1,6 +1,6 @@
1
- import { SasAuthResponse, Target } from '@sasjs/utils';
1
+ import { ServerType, Target } from '@sasjs/utils';
2
2
  import SASjs from '@sasjs/adapter/node';
3
- export declare function getAuthUrl(serverUrl: string, clientId: string): string;
3
+ export declare const getAuthUrl: (serverType: ServerType, serverUrl: string, clientId: string) => string;
4
4
  export declare function getAuthCode(authUrl: string): Promise<string>;
5
5
  /**
6
6
  * Checks if the Access Token is expired or is expiring in 1 hour. A default Access Token
@@ -18,5 +18,11 @@ export declare function isAccessTokenExpiring(token: string): boolean;
18
18
  * @param {string} token- token string that will be evaluated
19
19
  */
20
20
  export declare function isRefreshTokenExpiring(token?: string): boolean;
21
- export declare function refreshTokens(sasjsInstance: SASjs, clientId: string, clientSecret: string, refreshToken: string): Promise<SasAuthResponse>;
22
- export declare function getNewAccessToken(sasjsInstance: SASjs, clientId: string, clientSecret: string, target: Target): Promise<SasAuthResponse>;
21
+ export declare function refreshTokens(sasjsInstance: SASjs, clientId: string, clientSecret: string, refreshToken: string): Promise<{
22
+ access_token: string;
23
+ refresh_token: string;
24
+ }>;
25
+ export declare function getNewAccessToken(sasjsInstance: SASjs, clientId: string, clientSecret: string, target: Target): Promise<{
26
+ access_token: string;
27
+ refresh_token: string;
28
+ }>;
@@ -42,9 +42,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
42
42
  exports.getNewAccessToken = exports.refreshTokens = exports.isRefreshTokenExpiring = exports.isAccessTokenExpiring = exports.getAuthCode = exports.getAuthUrl = void 0;
43
43
  var utils_1 = require("@sasjs/utils");
44
44
  var jwt_decode_1 = __importDefault(require("jwt-decode"));
45
- function getAuthUrl(serverUrl, clientId) {
46
- return serverUrl + "/SASLogon/oauth/authorize?client_id=" + clientId + "&response_type=code";
47
- }
45
+ var getAuthUrl = function (serverType, serverUrl, clientId) {
46
+ return serverType === utils_1.ServerType.Sasjs
47
+ ? serverUrl + "/#/SASjsLogon?client_id=" + clientId + "&response_type=code"
48
+ : serverUrl + "/SASLogon/oauth/authorize?client_id=" + clientId + "&response_type=code";
49
+ };
48
50
  exports.getAuthUrl = getAuthUrl;
49
51
  function getAuthCode(authUrl) {
50
52
  return __awaiter(this, void 0, void 0, function () {
@@ -100,13 +102,13 @@ function isRefreshTokenExpiring(token) {
100
102
  exports.isRefreshTokenExpiring = isRefreshTokenExpiring;
101
103
  function refreshTokens(sasjsInstance, clientId, clientSecret, refreshToken) {
102
104
  return __awaiter(this, void 0, void 0, function () {
103
- var authResponse;
104
- return __generator(this, function (_a) {
105
- switch (_a.label) {
105
+ var _a, access_token, refresh_token;
106
+ return __generator(this, function (_b) {
107
+ switch (_b.label) {
106
108
  case 0: return [4 /*yield*/, sasjsInstance.refreshTokens(clientId, clientSecret, refreshToken)];
107
109
  case 1:
108
- authResponse = _a.sent();
109
- return [2 /*return*/, authResponse];
110
+ _a = _b.sent(), access_token = _a.access_token, refresh_token = _a.refresh_token;
111
+ return [2 /*return*/, { access_token: access_token, refresh_token: refresh_token }];
110
112
  }
111
113
  });
112
114
  });
@@ -114,18 +116,18 @@ function refreshTokens(sasjsInstance, clientId, clientSecret, refreshToken) {
114
116
  exports.refreshTokens = refreshTokens;
115
117
  function getNewAccessToken(sasjsInstance, clientId, clientSecret, target) {
116
118
  return __awaiter(this, void 0, void 0, function () {
117
- var authUrl, authCode, authResponse;
118
- return __generator(this, function (_a) {
119
- switch (_a.label) {
119
+ var authUrl, authCode, _a, access_token, refresh_token;
120
+ return __generator(this, function (_b) {
121
+ switch (_b.label) {
120
122
  case 0:
121
- authUrl = getAuthUrl(target.serverUrl, clientId);
123
+ authUrl = exports.getAuthUrl(target.serverType, target.serverUrl, clientId);
122
124
  return [4 /*yield*/, getAuthCode(authUrl)];
123
125
  case 1:
124
- authCode = _a.sent();
126
+ authCode = _b.sent();
125
127
  return [4 /*yield*/, sasjsInstance.getAccessToken(clientId, clientSecret, authCode)];
126
128
  case 2:
127
- authResponse = _a.sent();
128
- return [2 /*return*/, authResponse];
129
+ _a = _b.sent(), access_token = _a.access_token, refresh_token = _a.refresh_token;
130
+ return [2 /*return*/, { access_token: access_token, refresh_token: refresh_token }];
129
131
  }
130
132
  });
131
133
  });
@@ -1,5 +1,4 @@
1
- import { Configuration, Target, AuthConfig } from '@sasjs/utils';
2
- import { StreamConfig } from '@sasjs/utils/types/config';
1
+ import { Configuration, Target, AuthConfig, StreamConfig } from '@sasjs/utils';
3
2
  import { TargetScope } from '../types/targetScope';
4
3
  /**
5
4
  * Returns an object that represents the SASjs CLI configuration in a given file.
@@ -52,7 +51,7 @@ export declare function getMacroFolders(target?: Target): Promise<string[]>;
52
51
  * @param {Target} target- the target to check stream configuration for.
53
52
  */
54
53
  export declare function getStreamConfig(target?: Target): Promise<StreamConfig>;
55
- export declare function getMacroCorePath(): string;
54
+ export declare const getMacroCorePath: () => string;
56
55
  /**
57
56
  * Sanitizes app location string.
58
57
  * @param {string} appLoc - app location