@sasjs/cli 3.0.0 → 3.0.4

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 (75) 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 -15
  17. package/build/commands/compile/internal/compileTestFile.d.ts +0 -2
  18. package/build/commands/compile/internal/compileTestFile.js +11 -15
  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 +24 -12
  24. package/build/commands/compile/spec/compile.spec.js +30 -0
  25. package/build/commands/compile/spec/compileJobFile.spec.js +3 -3
  26. package/build/commands/compile/spec/compileServiceFile.spec.js +3 -3
  27. package/build/commands/compile/spec/loadDependencies.spec.js +37 -37
  28. package/build/commands/create/spec/reactAppFiles.js +5 -5
  29. package/build/commands/deploy/deploy.js +1 -1
  30. package/build/commands/deploy/spec/cbd.spec.js +19 -3
  31. package/build/commands/docs/generateDocs.js +4 -5
  32. package/build/commands/docs/internal/getFileInputs.d.ts +1 -1
  33. package/build/commands/docs/internal/getFileInputs.js +2 -2
  34. package/build/commands/docs/internal/getFileOutputs.d.ts +1 -1
  35. package/build/commands/docs/internal/getFileOutputs.js +2 -2
  36. package/build/commands/docs/internal/getFoldersForDocs.d.ts +1 -1
  37. package/build/commands/docs/internal/getFoldersForDocs.js +1 -1
  38. package/build/commands/request/request.js +2 -2
  39. package/build/commands/run/run.js +1 -1
  40. package/build/commands/servicepack/deploy.js +1 -1
  41. package/build/commands/web/internal/getTags.d.ts +2 -1
  42. package/build/commands/web/internal/getTags.js +10 -12
  43. package/build/commands/web/internal/getWebServiceContent.js +1 -2
  44. package/build/commands/web/internal/sasjsout.d.ts +1 -1
  45. package/build/commands/web/internal/sasjsout.js +1 -1
  46. package/build/commands/web/internal/spec/updateLinkTag.spec.d.ts +4 -0
  47. package/build/commands/web/internal/spec/updateLinkTag.spec.js +32 -0
  48. package/build/commands/web/internal/updateAllTags.js +33 -8
  49. package/build/commands/web/internal/updateLinkTag.d.ts +4 -0
  50. package/build/commands/web/internal/updateLinkTag.js +24 -0
  51. package/build/commands/web/web.js +12 -13
  52. package/build/utils/auth.d.ts +10 -4
  53. package/build/utils/auth.js +17 -15
  54. package/build/utils/config.d.ts +2 -3
  55. package/build/utils/config.js +14 -16
  56. package/build/utils/file.d.ts +0 -6
  57. package/build/utils/file.js +1 -43
  58. package/build/utils/setConstants.js +1 -1
  59. package/build/utils/spec/utils.spec.js +31 -5
  60. package/build/utils/utils.d.ts +0 -2
  61. package/build/utils/utils.js +1 -16
  62. package/package.json +7 -13
  63. package/CHANGELOG.md +0 -30
  64. package/build/commands/compile/internal/config.d.ts +0 -25
  65. package/build/commands/compile/internal/config.js +0 -259
  66. package/build/commands/compile/spec/getDependencyPaths.spec.d.ts +0 -1
  67. package/build/commands/compile/spec/getDependencyPaths.spec.js +0 -263
  68. package/build/commands/compile/spec/getProgramDependencies.spec.d.ts +0 -1
  69. package/build/commands/compile/spec/getProgramDependencies.spec.js +0 -403
  70. package/build/commands/shared/dependencies.d.ts +0 -12
  71. package/build/commands/shared/dependencies.js +0 -332
  72. package/build/commands/web/internal/updateLinkHref.d.ts +0 -4
  73. package/build/commands/web/internal/updateLinkHref.js +0 -18
  74. package/build/utils/spec/utils.spec.server.d.ts +0 -1
  75. package/build/utils/spec/utils.spec.server.js +0 -72
@@ -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
@@ -633,7 +633,7 @@ function getProgramFolders(target) {
633
633
  }
634
634
  buildSourceFolder = process.sasjsConstants.buildSourceFolder;
635
635
  programFolders = programFolders.map(function (programFolder) {
636
- return utils_2.getAbsolutePath(programFolder, buildSourceFolder);
636
+ return utils_1.getAbsolutePath(programFolder, buildSourceFolder);
637
637
  });
638
638
  return [2 /*return*/, __spreadArray([], __read(new Set(programFolders)))];
639
639
  }
@@ -664,7 +664,7 @@ function getMacroFolders(target) {
664
664
  }
665
665
  buildSourceFolder = process.sasjsConstants.buildSourceFolder;
666
666
  macroFolders = macroFolders.map(function (macroFolder) {
667
- return utils_2.getAbsolutePath(macroFolder, buildSourceFolder);
667
+ return utils_1.getAbsolutePath(macroFolder, buildSourceFolder);
668
668
  });
669
669
  return [2 /*return*/, __spreadArray([], __read(new Set(macroFolders)))];
670
670
  }
@@ -691,10 +691,7 @@ function getStreamConfig(target) {
691
691
  });
692
692
  }
693
693
  exports.getStreamConfig = getStreamConfig;
694
- function getMacroCorePath() {
695
- var macroCorePath = process.sasjsConstants.macroCorePath;
696
- return macroCorePath;
697
- }
694
+ var getMacroCorePath = function () { return process.sasjsConstants.macroCorePath; };
698
695
  exports.getMacroCorePath = getMacroCorePath;
699
696
  /**
700
697
  * Sanitizes app location string.
@@ -761,7 +758,7 @@ exports.getProjectRoot = getProjectRoot;
761
758
  function getAuthConfig(target) {
762
759
  var _a, _b, _c, _d;
763
760
  return __awaiter(this, void 0, void 0, function () {
764
- var access_token, refresh_token, client, secret, authConfig, sasjs;
761
+ var access_token, refresh_token, client, secret, sasjs, tokens;
765
762
  return __generator(this, function (_e) {
766
763
  switch (_e.label) {
767
764
  case 0:
@@ -811,18 +808,19 @@ function getAuthConfig(target) {
811
808
  httpsAgentOptions: target.httpsAgentOptions,
812
809
  serverType: target.serverType
813
810
  });
811
+ tokens = void 0;
814
812
  if (!auth_1.isRefreshTokenExpiring(refresh_token)) return [3 /*break*/, 4];
815
813
  return [4 /*yield*/, auth_1.getNewAccessToken(sasjs, client, secret, target)];
816
814
  case 3:
817
- authConfig = _e.sent();
815
+ tokens = _e.sent();
818
816
  return [3 /*break*/, 6];
819
817
  case 4: return [4 /*yield*/, auth_1.refreshTokens(sasjs, client, secret, refresh_token)];
820
818
  case 5:
821
- authConfig = _e.sent();
819
+ tokens = _e.sent();
822
820
  _e.label = 6;
823
821
  case 6:
824
- access_token = (authConfig === null || authConfig === void 0 ? void 0 : authConfig.access_token) || access_token;
825
- refresh_token = (authConfig === null || authConfig === void 0 ? void 0 : authConfig.refresh_token) || refresh_token;
822
+ access_token = (tokens === null || tokens === void 0 ? void 0 : tokens.access_token) || access_token;
823
+ refresh_token = (tokens === null || tokens === void 0 ? void 0 : tokens.refresh_token) || refresh_token;
826
824
  _e.label = 7;
827
825
  case 7: return [2 /*return*/, {
828
826
  access_token: access_token,
@@ -852,7 +850,7 @@ exports.getAuthConfig = getAuthConfig;
852
850
  function getAccessToken(target, checkIfExpiring) {
853
851
  if (checkIfExpiring === void 0) { checkIfExpiring = true; }
854
852
  return __awaiter(this, void 0, void 0, function () {
855
- var accessToken, sasjs, client, secret, refreshToken, authConfig;
853
+ var accessToken, sasjs, client, secret, refreshToken, tokens;
856
854
  return __generator(this, function (_a) {
857
855
  switch (_a.label) {
858
856
  case 0:
@@ -907,18 +905,18 @@ function getAccessToken(target, checkIfExpiring) {
907
905
  (refreshToken.trim() === 'null' || refreshToken.trim() === 'undefined')
908
906
  ? undefined
909
907
  : refreshToken;
910
- authConfig = void 0;
908
+ tokens = void 0;
911
909
  if (!auth_1.isRefreshTokenExpiring(refreshToken)) return [3 /*break*/, 4];
912
910
  return [4 /*yield*/, auth_1.getNewAccessToken(sasjs, client, secret, target)];
913
911
  case 3:
914
- authConfig = _a.sent();
912
+ tokens = _a.sent();
915
913
  return [3 /*break*/, 6];
916
914
  case 4: return [4 /*yield*/, auth_1.refreshTokens(sasjs, client, secret, refreshToken)];
917
915
  case 5:
918
- authConfig = _a.sent();
916
+ tokens = _a.sent();
919
917
  _a.label = 6;
920
918
  case 6:
921
- accessToken = authConfig === null || authConfig === void 0 ? void 0 : authConfig.access_token;
919
+ accessToken = tokens === null || tokens === void 0 ? void 0 : tokens.access_token;
922
920
  _a.label = 7;
923
921
  case 7: return [2 /*return*/, accessToken];
924
922
  }
@@ -4,12 +4,6 @@ export function isSasFile(filePath: any): boolean;
4
4
  export function isJsonFile(filePath: any): boolean;
5
5
  export function isCsvFile(filePath: any): boolean;
6
6
  export function isShellScript(filePath: any): boolean;
7
- /**
8
- * Gets a list of @li items from the supplied file content with the specified header.
9
- * @param {string} listHeader - the header of the section to look for - e.g. <h4> SAS Macros </h4>.
10
- * @param {string} fileContent - the text content of the file.
11
- */
12
- export function getList(listHeader: string, fileContent: string): any[];
13
7
  export function getBrief(fileContent: any): any;
14
8
  export function getRelativePath(from: any, to: any): any[];
15
9
  export function saveToDefaultLocation(filePath: any, data: any): Promise<{
@@ -39,7 +39,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
39
39
  return (mod && mod.__esModule) ? mod : { "default": mod };
40
40
  };
41
41
  Object.defineProperty(exports, "__esModule", { value: true });
42
- exports.sasFileRegExp = exports.saveToDefaultLocation = exports.getRelativePath = exports.getBrief = exports.getList = exports.sanitizeFileName = exports.isShellScript = exports.isCsvFile = exports.isJsonFile = exports.isSasFile = exports.unifyFilePath = exports.createFolderStructure = void 0;
42
+ exports.sasFileRegExp = exports.saveToDefaultLocation = exports.getRelativePath = exports.getBrief = exports.sanitizeFileName = exports.isShellScript = exports.isCsvFile = exports.isJsonFile = exports.isSasFile = exports.unifyFilePath = exports.createFolderStructure = void 0;
43
43
  var path_1 = __importDefault(require("path"));
44
44
  var utils_1 = require("@sasjs/utils");
45
45
  var config_1 = require("./config");
@@ -129,48 +129,6 @@ var sanitizeFileName = function (fileName) {
129
129
  return fileName.replace(/[^a-z0-9]/gi, '_');
130
130
  };
131
131
  exports.sanitizeFileName = sanitizeFileName;
132
- /**
133
- * Gets a list of @li items from the supplied file content with the specified header.
134
- * @param {string} listHeader - the header of the section to look for - e.g. <h4> SAS Macros </h4>.
135
- * @param {string} fileContent - the text content of the file.
136
- */
137
- function getList(listHeader, fileContent) {
138
- var _a;
139
- var fileHeader;
140
- try {
141
- var hasFileHeader = fileContent.split('/**')[0] !== fileContent;
142
- if (!hasFileHeader)
143
- return [];
144
- fileHeader = fileContent.split('/**')[1].split('**/')[0];
145
- }
146
- catch (e) {
147
- (_a = process.logger) === null || _a === void 0 ? void 0 : _a.error('File header parse error.\nPlease make sure your file header is in the correct format.');
148
- }
149
- var list = [];
150
- var lines = fileHeader.split('\n').map(function (s) { return (s ? s.trim() : s); });
151
- var startIndex = null;
152
- var endIndex = null;
153
- for (var i = 0; i < lines.length; i++) {
154
- if (new RegExp(listHeader, 'i').test(lines[i])) {
155
- startIndex = i + 1;
156
- break;
157
- }
158
- }
159
- for (var i = startIndex; i < lines.length; i++) {
160
- if (!lines[i]) {
161
- endIndex = i;
162
- break;
163
- }
164
- }
165
- for (var i = startIndex; i < endIndex; i++) {
166
- list.push(lines[i]);
167
- }
168
- return list
169
- .filter(function (l) { return l.startsWith('@li'); })
170
- .map(function (d) { return d.replace(/\@li/g, ''); })
171
- .map(function (d) { return d.trim(); });
172
- }
173
- exports.getList = getList;
174
132
  function getBrief(fileContent) {
175
133
  var fileHeader;
176
134
  try {
@@ -43,7 +43,7 @@ exports.setConstants = exports.contextName = void 0;
43
43
  var path_1 = __importDefault(require("path"));
44
44
  var get_installed_path_1 = require("get-installed-path");
45
45
  var config_1 = require("./config");
46
- var utils_1 = require("./utils");
46
+ var utils_1 = require("@sasjs/utils");
47
47
  exports.contextName = 'sasjs cli compute context';
48
48
  var setConstants = function () { return __awaiter(void 0, void 0, void 0, function () {
49
49
  var _a, configuration, isLocal, buildOutputFolder, buildResultsFolder, homeDir, getMacroCoreGlobalPath, buildSourceFolder, buildSourceDbFolder, buildDestinationFolder, buildDestinationServicesFolder, buildDestinationTestFolder, buildDestinationJobsFolder, buildDestinationDbFolder, buildDestinationDocsFolder, macroCorePath, _b, buildDestinationResultsFolder, buildDestinationResultsLogsFolder, sas9CredentialsError, invalidSasError;