@sasjs/adapter 4.19.4 → 5.1.1

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 (418) hide show
  1. package/ContextManager.js +290 -0
  2. package/DISCLOSURE +45 -0
  3. package/README.md +1 -1
  4. package/SAS9ApiClient.d.ts +1 -1
  5. package/SAS9ApiClient.js +90 -0
  6. package/SASViyaApiClient.js +918 -0
  7. package/SASjs.js +794 -0
  8. package/SASjsApiClient.d.ts +1 -0
  9. package/SASjsApiClient.js +132 -0
  10. package/SessionManager.js +353 -0
  11. package/api/viya/executeOnComputeApi.js +198 -0
  12. package/api/viya/getFileStream.js +32 -0
  13. package/api/viya/pollJobState.js +247 -0
  14. package/api/viya/saveLog.js +45 -0
  15. package/api/viya/uploadTables.js +45 -0
  16. package/api/viya/writeStream.js +25 -0
  17. package/auth/AuthManager.js +305 -0
  18. package/auth/getAccessTokenForSasjs.js +43 -0
  19. package/auth/getAccessTokenForViya.js +54 -0
  20. package/auth/getTokenRequestErrorPrefix.js +70 -0
  21. package/auth/getTokens.js +110 -0
  22. package/auth/index.js +20 -0
  23. package/auth/isAuthorizeFormRequired.js +7 -0
  24. package/auth/isLoginRequired.js +9 -0
  25. package/auth/loginHeader.js +87 -0
  26. package/auth/openWebPage.js +31 -0
  27. package/auth/refreshTokensForSasjs.js +42 -0
  28. package/auth/refreshTokensForViya.js +53 -0
  29. package/auth/verifySas9Login.js +32 -0
  30. package/auth/verifySasViyaLogin.js +44 -0
  31. package/dist/minified_sas9.js +10892 -0
  32. package/dist/sasjs-adapter.js +19569 -0
  33. package/file/generateFileUploadForm.js +43 -0
  34. package/file/generateTableUploadForm.js +38 -0
  35. package/index.js +9 -80376
  36. package/job-execution/ComputeJobExecutor.js +55 -0
  37. package/job-execution/FileUploader.js +114 -0
  38. package/job-execution/JesJobExecutor.js +55 -0
  39. package/job-execution/JobExecutor.js +40 -0
  40. package/job-execution/Sas9JobExecutor.d.ts +1 -1
  41. package/job-execution/Sas9JobExecutor.js +115 -0
  42. package/job-execution/SasjsJobExecutor.js +100 -0
  43. package/job-execution/WebJobExecutor.js +254 -0
  44. package/job-execution/index.js +23 -0
  45. package/minified/sas9/SASjs.js +198 -0
  46. package/minified/sas9/WebJobExecutor.js +105 -0
  47. package/minified/sas9/index.js +22 -0
  48. package/node/index.d.ts +2 -9
  49. package/node/index.js +1 -30570
  50. package/package.json +41 -15
  51. package/request/RequestClient.d.ts +1 -1
  52. package/request/RequestClient.js +717 -0
  53. package/request/Sas9RequestClient.d.ts +1 -1
  54. package/request/Sas9RequestClient.js +121 -0
  55. package/request/SasjsRequestClient.js +77 -0
  56. package/types/Context.js +2 -0
  57. package/types/CsrfToken.js +2 -0
  58. package/types/ExecuteScript.js +2 -0
  59. package/types/File.js +2 -0
  60. package/types/FileResource.js +2 -0
  61. package/types/Folder.js +2 -0
  62. package/types/Job.js +2 -0
  63. package/types/JobDefinition.js +2 -0
  64. package/types/JobResult.js +2 -0
  65. package/types/Link.js +2 -0
  66. package/types/LogStatistics.js +2 -0
  67. package/types/Login.js +2 -0
  68. package/types/PollOptions.js +2 -0
  69. package/types/RequestClient.js +2 -0
  70. package/types/SASjsConfig.d.ts +1 -1
  71. package/types/SASjsConfig.js +91 -0
  72. package/types/Session.js +14 -0
  73. package/types/Tables.js +28 -0
  74. package/types/UploadFile.js +2 -0
  75. package/types/WriteStream.d.ts +1 -1
  76. package/types/WriteStream.js +2 -0
  77. package/types/errors/ArgumentError.js +12 -0
  78. package/types/errors/AuthorizeError.js +13 -0
  79. package/types/errors/CertificateError.js +12 -0
  80. package/types/errors/ComputeJobExecutionError.js +13 -0
  81. package/types/errors/ErrorResponse.js +23 -0
  82. package/types/errors/InternalServerError.js +11 -0
  83. package/types/errors/InvalidJsonError.js +11 -0
  84. package/types/errors/InvalidSASjsCsrfError.js +12 -0
  85. package/types/errors/JobExecutionError.js +14 -0
  86. package/types/errors/JobStatePollError.js +12 -0
  87. package/types/errors/JsonParseArrayError.js +11 -0
  88. package/types/errors/LoginRequiredError.js +14 -0
  89. package/types/errors/NoSessionStateError.js +14 -0
  90. package/types/errors/NotFoundError.js +12 -0
  91. package/types/errors/RootFolderNotFoundError.js +22 -0
  92. package/types/errors/SAS9AuthError.js +11 -0
  93. package/types/errors/WeboutResponseError.js +12 -0
  94. package/types/errors/index.js +31 -0
  95. package/types/index.js +34 -0
  96. package/utils/appendExtraResponseAttributes.js +25 -0
  97. package/utils/asyncForEach.js +20 -0
  98. package/utils/compareTimestamps.js +11 -0
  99. package/utils/convertToCsv.js +154 -0
  100. package/utils/createAxiosInstance.d.ts +1 -1
  101. package/utils/createAxiosInstance.js +9 -0
  102. package/utils/delay.js +5 -0
  103. package/{src/utils/extractWeboutBlob.ts → utils/extractWeboutBlob.js} +19 -20
  104. package/utils/fetchLogByChunks.js +56 -0
  105. package/utils/formatDataForRequest.js +39 -0
  106. package/utils/getFormData.js +10 -0
  107. package/{node/utils/getUserLanguage.d.ts → utils/getUserLanguage.js} +5 -1
  108. package/utils/getValidJson.js +27 -0
  109. package/utils/host.d.ts +24 -0
  110. package/utils/host.js +36 -0
  111. package/utils/index.js +41 -0
  112. package/utils/isIeOrEdge.js +30 -0
  113. package/utils/isNode.js +7 -0
  114. package/utils/isRelativePath.js +5 -0
  115. package/utils/isUri.js +9 -0
  116. package/utils/isUrl.js +20 -0
  117. package/utils/loginPrompt/index.js +180 -0
  118. package/utils/needsRetry.js +14 -0
  119. package/utils/parseGeneratedCode.js +10 -0
  120. package/utils/parseSasViyaLog.js +17 -0
  121. package/utils/parseSourceCode.js +9 -0
  122. package/utils/parseViyaDebugResponse.js +46 -0
  123. package/utils/parseViyaLogDebugResponse.js +32 -0
  124. package/utils/parseWeboutResponse.js +22 -0
  125. package/utils/sas9/extractUserLongNameSas9.js +30 -0
  126. package/utils/serialize.js +20 -0
  127. package/utils/splitChunks.js +13 -0
  128. package/utils/validateInput.js +83 -0
  129. package/.env.example +0 -2
  130. package/.git-hooks/commit-msg +0 -39
  131. package/.git-hooks/pre-commit +0 -12
  132. package/.gitattributes +0 -1
  133. package/.pre-commit-config.yaml +0 -25
  134. package/.vscode/settings.json +0 -3
  135. package/SASViyaApiClient.spec.d.ts +0 -1
  136. package/__mocks__/axios.d.ts +0 -3
  137. package/api/viya/spec/executeScript.spec.d.ts +0 -1
  138. package/api/viya/spec/getFileStream.spec.d.ts +0 -1
  139. package/api/viya/spec/mockResponses.d.ts +0 -10
  140. package/api/viya/spec/pollJobState.spec.d.ts +0 -1
  141. package/api/viya/spec/saveLog.spec.d.ts +0 -1
  142. package/api/viya/spec/uploadTables.spec.d.ts +0 -1
  143. package/api/viya/spec/writeStream.spec.d.ts +0 -1
  144. package/auth/spec/AuthManager.spec.d.ts +0 -4
  145. package/auth/spec/getAccessTokenForSasjs.spec.d.ts +0 -1
  146. package/auth/spec/getAccessTokenForViya.spec.d.ts +0 -1
  147. package/auth/spec/getTokenRequestErrorPrefix.spec.d.ts +0 -1
  148. package/auth/spec/getTokens.spec.d.ts +0 -1
  149. package/auth/spec/loginHeader.spec.d.ts +0 -4
  150. package/auth/spec/mockResponses.d.ts +0 -23
  151. package/auth/spec/openWebPage.spec.d.ts +0 -1
  152. package/auth/spec/refreshTokensForSasjs.spec.d.ts +0 -1
  153. package/auth/spec/refreshTokensForViya.spec.d.ts +0 -1
  154. package/auth/spec/verifySas9Login.spec.d.ts +0 -1
  155. package/auth/spec/verifySasViyaLogin.spec.d.ts +0 -1
  156. package/createTSDocs.js +0 -35
  157. package/cypress.config.js +0 -18
  158. package/example.html +0 -109
  159. package/file/spec/generateFileUploadForm.spec.d.ts +0 -1
  160. package/file/spec/generateTableUploadForm.spec.d.ts +0 -1
  161. package/index-dev.js +0 -80394
  162. package/job-execution/spec/ComputeJobExecutor.spec.d.ts +0 -1
  163. package/job-execution/spec/JesJobExecutor.spec.d.ts +0 -1
  164. package/job-execution/spec/Sas9JobExecutor.spec.d.ts +0 -1
  165. package/job-execution/spec/SasjsJobExecutor.spec.d.ts +0 -1
  166. package/job-execution/spec/WebJobExecutor.debug.spec.d.ts +0 -1
  167. package/job-execution/spec/WebJobExecutor.spec.d.ts +0 -1
  168. package/job-execution/spec/executionTasks.spec.d.ts +0 -1
  169. package/minified_sas9.js +0 -14039
  170. package/node/ContextManager.d.ts +0 -41
  171. package/node/SAS9ApiClient.d.ts +0 -30
  172. package/node/SASViyaApiClient.d.ts +0 -298
  173. package/node/SASjs.d.ts +0 -387
  174. package/node/SASjsApiClient.d.ts +0 -65
  175. package/node/SessionManager.d.ts +0 -115
  176. package/node/api/viya/executeOnComputeApi.d.ts +0 -21
  177. package/node/api/viya/getFileStream.d.ts +0 -2
  178. package/node/api/viya/pollJobState.d.ts +0 -57
  179. package/node/api/viya/saveLog.d.ts +0 -15
  180. package/node/api/viya/uploadTables.d.ts +0 -13
  181. package/node/api/viya/writeStream.d.ts +0 -2
  182. package/node/auth/AuthManager.d.ts +0 -49
  183. package/node/auth/getAccessTokenForSasjs.d.ts +0 -11
  184. package/node/auth/getAccessTokenForViya.d.ts +0 -10
  185. package/node/auth/getTokenRequestErrorPrefix.d.ts +0 -44
  186. package/node/auth/getTokens.d.ts +0 -22
  187. package/node/auth/index.d.ts +0 -4
  188. package/node/auth/isAuthorizeFormRequired.d.ts +0 -1
  189. package/node/auth/isLoginRequired.d.ts +0 -1
  190. package/node/auth/loginHeader.d.ts +0 -17
  191. package/node/auth/openWebPage.d.ts +0 -6
  192. package/node/auth/refreshTokensForSasjs.d.ts +0 -10
  193. package/node/auth/refreshTokensForViya.d.ts +0 -11
  194. package/node/auth/verifySas9Login.d.ts +0 -3
  195. package/node/auth/verifySasViyaLogin.d.ts +0 -4
  196. package/node/file/generateFileUploadForm.d.ts +0 -11
  197. package/node/file/generateTableUploadForm.d.ts +0 -5
  198. package/node/job-execution/ComputeJobExecutor.d.ts +0 -8
  199. package/node/job-execution/FileUploader.d.ts +0 -9
  200. package/node/job-execution/JesJobExecutor.d.ts +0 -9
  201. package/node/job-execution/JobExecutor.d.ts +0 -17
  202. package/node/job-execution/Sas9JobExecutor.d.ts +0 -19
  203. package/node/job-execution/SasjsJobExecutor.d.ts +0 -9
  204. package/node/job-execution/WebJobExecutor.d.ts +0 -18
  205. package/node/job-execution/index.d.ts +0 -7
  206. package/node/request/RequestClient.d.ts +0 -125
  207. package/node/request/Sas9RequestClient.d.ts +0 -25
  208. package/node/request/SasjsRequestClient.d.ts +0 -12
  209. package/node/types/Context.d.ts +0 -42
  210. package/node/types/CsrfToken.d.ts +0 -4
  211. package/node/types/ExecuteScript.d.ts +0 -4
  212. package/node/types/File.d.ts +0 -7
  213. package/node/types/FileResource.d.ts +0 -32
  214. package/node/types/Folder.d.ts +0 -7
  215. package/node/types/Job.d.ts +0 -14
  216. package/node/types/JobDefinition.d.ts +0 -3
  217. package/node/types/JobResult.d.ts +0 -3
  218. package/node/types/Link.d.ts +0 -7
  219. package/node/types/LogStatistics.d.ts +0 -4
  220. package/node/types/Login.d.ts +0 -14
  221. package/node/types/PollOptions.d.ts +0 -8
  222. package/node/types/RequestClient.d.ts +0 -46
  223. package/node/types/SASjsConfig.d.ts +0 -94
  224. package/node/types/Session.d.ts +0 -30
  225. package/node/types/Tables.d.ts +0 -7
  226. package/node/types/UploadFile.d.ts +0 -8
  227. package/node/types/WriteStream.d.ts +0 -7
  228. package/node/types/errors/ArgumentError.d.ts +0 -4
  229. package/node/types/errors/AuthorizeError.d.ts +0 -5
  230. package/node/types/errors/CertificateError.d.ts +0 -3
  231. package/node/types/errors/ComputeJobExecutionError.d.ts +0 -6
  232. package/node/types/errors/ErrorResponse.d.ts +0 -9
  233. package/node/types/errors/InternalServerError.d.ts +0 -3
  234. package/node/types/errors/InvalidJsonError.d.ts +0 -3
  235. package/node/types/errors/InvalidSASjsCsrfError.d.ts +0 -3
  236. package/node/types/errors/JobExecutionError.d.ts +0 -6
  237. package/node/types/errors/JobStatePollError.d.ts +0 -4
  238. package/node/types/errors/JsonParseArrayError.d.ts +0 -3
  239. package/node/types/errors/LoginRequiredError.d.ts +0 -3
  240. package/node/types/errors/NoSessionStateError.d.ts +0 -6
  241. package/node/types/errors/NotFoundError.d.ts +0 -4
  242. package/node/types/errors/RootFolderNotFoundError.d.ts +0 -3
  243. package/node/types/errors/SAS9AuthError.d.ts +0 -3
  244. package/node/types/errors/WeboutResponseError.d.ts +0 -4
  245. package/node/types/errors/index.d.ts +0 -15
  246. package/node/types/index.d.ts +0 -18
  247. package/node/utils/appendExtraResponseAttributes.d.ts +0 -2
  248. package/node/utils/asyncForEach.d.ts +0 -1
  249. package/node/utils/compareTimestamps.d.ts +0 -6
  250. package/node/utils/convertToCsv.d.ts +0 -12
  251. package/node/utils/createAxiosInstance.d.ts +0 -2
  252. package/node/utils/delay.d.ts +0 -1
  253. package/node/utils/extractWeboutBlob.d.ts +0 -13
  254. package/node/utils/fetchLogByChunks.d.ts +0 -20
  255. package/node/utils/formatDataForRequest.d.ts +0 -1
  256. package/node/utils/getFormData.d.ts +0 -2
  257. package/node/utils/getValidJson.d.ts +0 -5
  258. package/node/utils/index.d.ts +0 -25
  259. package/node/utils/isNode.d.ts +0 -1
  260. package/node/utils/isRelativePath.d.ts +0 -1
  261. package/node/utils/isUri.d.ts +0 -5
  262. package/node/utils/isUrl.d.ts +0 -5
  263. package/node/utils/loginPrompt/index.d.ts +0 -1
  264. package/node/utils/needsRetry.d.ts +0 -1
  265. package/node/utils/parseGeneratedCode.d.ts +0 -1
  266. package/node/utils/parseSasViyaLog.d.ts +0 -5
  267. package/node/utils/parseSourceCode.d.ts +0 -1
  268. package/node/utils/parseViyaDebugResponse.d.ts +0 -12
  269. package/node/utils/parseViyaLogDebugResponse.d.ts +0 -8
  270. package/node/utils/parseWeboutResponse.d.ts +0 -1
  271. package/node/utils/sas9/extractUserLongNameSas9.d.ts +0 -6
  272. package/node/utils/serialize.d.ts +0 -1
  273. package/node/utils/splitChunks.d.ts +0 -1
  274. package/node/utils/validateInput.d.ts +0 -14
  275. package/request/spec/SasjsRequestClient.spec.d.ts +0 -1
  276. package/screenshots/session-manager-first-request.png +0 -0
  277. package/screenshots/subsequent-session-request.png +0 -0
  278. package/spec/SAS9ApiClient.spec.d.ts +0 -1
  279. package/spec/SASjs.startComputeJob.spec.d.ts +0 -1
  280. package/spec/SASjsApiClient.spec.d.ts +0 -1
  281. package/src/ContextManager.ts +0 -454
  282. package/src/SAS9ApiClient.ts +0 -100
  283. package/src/SASViyaApiClient.ts +0 -1417
  284. package/src/SASjs.ts +0 -1268
  285. package/src/SASjsApiClient.ts +0 -177
  286. package/src/SessionManager.ts +0 -465
  287. package/src/__mocks__/axios.ts +0 -7
  288. package/src/api/viya/executeOnComputeApi.ts +0 -307
  289. package/src/api/viya/getFileStream.ts +0 -17
  290. package/src/api/viya/pollJobState.ts +0 -393
  291. package/src/api/viya/saveLog.ts +0 -55
  292. package/src/api/viya/spec/mockResponses.ts +0 -75
  293. package/src/api/viya/uploadTables.ts +0 -41
  294. package/src/api/viya/writeStream.ts +0 -16
  295. package/src/auth/AuthManager.ts +0 -387
  296. package/src/auth/getAccessTokenForSasjs.ts +0 -48
  297. package/src/auth/getAccessTokenForViya.ts +0 -61
  298. package/src/auth/getTokenRequestErrorPrefix.ts +0 -88
  299. package/src/auth/getTokens.ts +0 -127
  300. package/src/auth/index.ts +0 -4
  301. package/src/auth/isAuthorizeFormRequired.ts +0 -3
  302. package/src/auth/isLoginRequired.ts +0 -5
  303. package/src/auth/loginHeader.ts +0 -97
  304. package/src/auth/openWebPage.ts +0 -40
  305. package/src/auth/refreshTokensForSasjs.ts +0 -45
  306. package/src/auth/refreshTokensForViya.ts +0 -66
  307. package/src/auth/spec/mockResponses.ts +0 -53
  308. package/src/auth/verifySas9Login.ts +0 -25
  309. package/src/auth/verifySasViyaLogin.ts +0 -43
  310. package/src/file/generateFileUploadForm.ts +0 -48
  311. package/src/file/generateTableUploadForm.ts +0 -50
  312. package/src/index.ts +0 -9
  313. package/src/job-execution/ComputeJobExecutor.ts +0 -76
  314. package/src/job-execution/FileUploader.ts +0 -152
  315. package/src/job-execution/JesJobExecutor.ts +0 -78
  316. package/src/job-execution/JobExecutor.ts +0 -63
  317. package/src/job-execution/Sas9JobExecutor.ts +0 -137
  318. package/src/job-execution/SasjsJobExecutor.ts +0 -152
  319. package/src/job-execution/WebJobExecutor.ts +0 -341
  320. package/src/job-execution/index.ts +0 -7
  321. package/src/minified/sas9/SASjs.ts +0 -274
  322. package/src/minified/sas9/WebJobExecutor.ts +0 -156
  323. package/src/minified/sas9/index.ts +0 -3
  324. package/src/request/RequestClient.ts +0 -941
  325. package/src/request/Sas9RequestClient.ts +0 -132
  326. package/src/request/SasjsRequestClient.ts +0 -82
  327. package/src/test/SAS_server_app.ts +0 -47
  328. package/src/types/Context.ts +0 -39
  329. package/src/types/CsrfToken.ts +0 -4
  330. package/src/types/ExecuteScript.ts +0 -4
  331. package/src/types/File.ts +0 -8
  332. package/src/types/FileResource.ts +0 -33
  333. package/src/types/Folder.ts +0 -8
  334. package/src/types/Job.ts +0 -15
  335. package/src/types/JobDefinition.ts +0 -3
  336. package/src/types/JobResult.ts +0 -3
  337. package/src/types/Link.ts +0 -7
  338. package/src/types/LogStatistics.ts +0 -4
  339. package/src/types/Login.ts +0 -15
  340. package/src/types/PollOptions.ts +0 -9
  341. package/src/types/Process.d.ts +0 -5
  342. package/src/types/RequestClient.ts +0 -55
  343. package/src/types/SASjsConfig.ts +0 -95
  344. package/src/types/Session.ts +0 -34
  345. package/src/types/Tables.ts +0 -29
  346. package/src/types/UploadFile.ts +0 -8
  347. package/src/types/WriteStream.ts +0 -10
  348. package/src/types/errors/ArgumentError.ts +0 -7
  349. package/src/types/errors/AuthorizeError.ts +0 -10
  350. package/src/types/errors/CertificateError.ts +0 -12
  351. package/src/types/errors/ComputeJobExecutionError.ts +0 -12
  352. package/src/types/errors/ErrorResponse.ts +0 -28
  353. package/src/types/errors/InternalServerError.ts +0 -9
  354. package/src/types/errors/InvalidJsonError.ts +0 -7
  355. package/src/types/errors/InvalidSASjsCsrfError.ts +0 -9
  356. package/src/types/errors/JobExecutionError.ts +0 -11
  357. package/src/types/errors/JobStatePollError.ts +0 -14
  358. package/src/types/errors/JsonParseArrayError.ts +0 -7
  359. package/src/types/errors/LoginRequiredError.ts +0 -11
  360. package/src/types/errors/NoSessionStateError.ts +0 -15
  361. package/src/types/errors/NotFoundError.ts +0 -7
  362. package/src/types/errors/RootFolderNotFoundError.ts +0 -24
  363. package/src/types/errors/SAS9AuthError.ts +0 -9
  364. package/src/types/errors/WeboutResponseError.ts +0 -7
  365. package/src/types/errors/index.ts +0 -15
  366. package/src/types/index.ts +0 -18
  367. package/src/types/system/global.d.ts +0 -1
  368. package/src/utils/appendExtraResponseAttributes.ts +0 -22
  369. package/src/utils/asyncForEach.ts +0 -5
  370. package/src/utils/compareTimestamps.ts +0 -9
  371. package/src/utils/convertToCsv.ts +0 -198
  372. package/src/utils/createAxiosInstance.ts +0 -7
  373. package/src/utils/delay.ts +0 -2
  374. package/src/utils/fetchLogByChunks.ts +0 -63
  375. package/src/utils/formatDataForRequest.ts +0 -48
  376. package/src/utils/getFormData.ts +0 -5
  377. package/src/utils/getUserLanguage.ts +0 -10
  378. package/src/utils/getValidJson.ts +0 -23
  379. package/src/utils/index.ts +0 -25
  380. package/src/utils/isIeOrEdge.ts +0 -34
  381. package/src/utils/isNode.ts +0 -4
  382. package/src/utils/isRelativePath.ts +0 -2
  383. package/src/utils/isUri.ts +0 -5
  384. package/src/utils/isUrl.ts +0 -17
  385. package/src/utils/loginPrompt/index.ts +0 -177
  386. package/src/utils/needsRetry.ts +0 -14
  387. package/src/utils/parseGeneratedCode.ts +0 -7
  388. package/src/utils/parseSasViyaLog.ts +0 -12
  389. package/src/utils/parseSourceCode.ts +0 -6
  390. package/src/utils/parseViyaDebugResponse.ts +0 -46
  391. package/src/utils/parseViyaLogDebugResponse.ts +0 -22
  392. package/src/utils/parseWeboutResponse.ts +0 -20
  393. package/src/utils/sas9/extractUserLongNameSas9.ts +0 -31
  394. package/src/utils/serialize.ts +0 -15
  395. package/src/utils/splitChunks.ts +0 -12
  396. package/src/utils/validateInput.ts +0 -93
  397. package/test/ContextManager.spec.d.ts +0 -1
  398. package/test/FileUploader.spec.d.ts +0 -4
  399. package/test/FolderOperations.spec.d.ts +0 -1
  400. package/test/RequestClient.spec.d.ts +0 -1
  401. package/test/SAS_server_app.d.ts +0 -10
  402. package/test/SessionManager.spec.d.ts +0 -1
  403. package/test/getJobsInFolder.spec.d.ts +0 -1
  404. package/test/utils/formatDataForRequest.spec.d.ts +0 -1
  405. package/test/utils/getValidJson.spec.d.ts +0 -1
  406. package/test/utils/isUrl.spec.d.ts +0 -1
  407. package/test/utils/parseGeneratedCode.spec.d.ts +0 -1
  408. package/test/utils/parseSourceCode.spec.d.ts +0 -1
  409. package/types/Tables.spec.d.ts +0 -1
  410. package/types/errors/RootFolderNotFoundError.spec.d.ts +0 -1
  411. package/types/errors/spec/SAS9AuthError.spec.d.ts +0 -1
  412. package/utils/spec/convertToCsv.spec.d.ts +0 -1
  413. package/utils/spec/extractUserLongNameSas9.spec.d.ts +0 -1
  414. package/utils/spec/getFormData.spec.d.ts +0 -1
  415. package/utils/spec/parseSasViyaLog.spec.d.ts +0 -1
  416. package/utils/spec/parseViyaDebugResponse.spec.d.ts +0 -1
  417. package/utils/spec/parseViyaLogDebugResponse.spec.d.ts +0 -1
  418. package/utils/spec/validateInput.spec.d.ts +0 -1
@@ -1,274 +0,0 @@
1
- import { validateInput, compareTimestamps } from '../../utils'
2
- import { SASjsConfig, UploadFile, LoginMechanism } from '../../types'
3
- import { AuthManager } from '../../auth'
4
- import {
5
- ServerType,
6
- AuthConfig,
7
- ExtraResponseAttributes
8
- } from '@sasjs/utils/types'
9
- import { RequestClient } from '../../request/RequestClient'
10
- import { FileUploader } from '../../job-execution/FileUploader'
11
- import { WebJobExecutor } from './WebJobExecutor'
12
- import { ErrorResponse } from '../../types/errors/ErrorResponse'
13
- import { LoginOptions, LoginResult } from '../../types/Login'
14
-
15
- const defaultConfig: SASjsConfig = {
16
- serverUrl: '',
17
- pathSASJS: '/SASjsApi/stp/execute',
18
- pathSAS9: '/SASStoredProcess/do',
19
- pathSASViya: '/SASJobExecution',
20
- appLoc: '/Public/seedapp',
21
- serverType: ServerType.Sas9,
22
- debug: false,
23
- contextName: 'SAS Job Execution compute context',
24
- useComputeApi: null,
25
- loginMechanism: LoginMechanism.Default
26
- }
27
-
28
- /**
29
- * SASjs is a JavaScript adapter for SAS.
30
- *
31
- */
32
- export default class SASjs {
33
- private sasjsConfig: SASjsConfig = new SASjsConfig()
34
- private jobsPath: string = ''
35
- private fileUploader: FileUploader | null = null
36
- private authManager: AuthManager | null = null
37
- private requestClient: RequestClient | null = null
38
- private webJobExecutor: WebJobExecutor | null = null
39
-
40
- constructor(config?: Partial<SASjsConfig>) {
41
- this.sasjsConfig = {
42
- ...defaultConfig,
43
- ...config
44
- }
45
-
46
- this.setupConfiguration()
47
- }
48
-
49
- /**
50
- * Logs into the SAS server with the supplied credentials.
51
- * @param username - a string representing the username.
52
- * @param password - a string representing the password.
53
- * @param clientId - a string representing the client ID.
54
- */
55
- public async logIn(
56
- username?: string,
57
- password?: string,
58
- clientId?: string,
59
- options: LoginOptions = {}
60
- ): Promise<LoginResult> {
61
- if (this.sasjsConfig.loginMechanism === LoginMechanism.Default) {
62
- if (!username || !password)
63
- throw new Error(
64
- 'A username and password are required when using the default login mechanism.'
65
- )
66
-
67
- return this.authManager!.logIn(username, password)
68
- }
69
-
70
- if (typeof window === typeof undefined) {
71
- throw new Error(
72
- 'The redirected login mechanism is only available for use in the browser.'
73
- )
74
- }
75
-
76
- return this.authManager!.redirectedLogIn(options)
77
- }
78
-
79
- /**
80
- * Logs out of the configured SAS server.
81
- */
82
- public logOut() {
83
- return this.authManager!.logOut()
84
- }
85
-
86
- /**
87
- * Returns the current SASjs configuration.
88
- *
89
- */
90
- public getSasjsConfig() {
91
- return this.sasjsConfig
92
- }
93
-
94
- /**
95
- * this method returns an array of SASjsRequest
96
- * @returns SASjsRequest[]
97
- */
98
- public getSasRequests() {
99
- const requests = [...this.requestClient!.getRequests()]
100
- const sortedRequests = requests.sort(compareTimestamps)
101
- return sortedRequests
102
- }
103
-
104
- /**
105
- * Sets the debug state. Turning this on will enable additional logging in the adapter.
106
- * @param value - boolean indicating debug state (on/off).
107
- */
108
- public setDebugState(value: boolean) {
109
- this.sasjsConfig.debug = value
110
- }
111
-
112
- /**
113
- * Uploads a file to the given service.
114
- * @param sasJob - the path to the SAS program (ultimately resolves to
115
- * the SAS `_program` parameter to run a Job Definition or SAS 9 Stored
116
- * Process). Is prepended at runtime with the value of `appLoc`.
117
- * @param files - array of files to be uploaded, including File object and file name.
118
- * @param params - request URL parameters.
119
- * @param config - provide any changes to the config here, for instance to
120
- * enable/disable `debug`. Any change provided will override the global config,
121
- * for that particular function call.
122
- * @param loginRequiredCallback - a function that is called if the
123
- * user is not logged in (eg to display a login form). The request will be
124
- * resubmitted after successful login.
125
- */
126
- public async uploadFile(
127
- sasJob: string,
128
- files: UploadFile[],
129
- params: { [key: string]: any } | null,
130
- config: { [key: string]: any } = {},
131
- loginRequiredCallback?: () => any
132
- ) {
133
- config = {
134
- ...this.sasjsConfig,
135
- ...config
136
- }
137
- const data = { files, params }
138
-
139
- return await this.fileUploader!.execute(
140
- sasJob,
141
- data,
142
- config,
143
- loginRequiredCallback
144
- )
145
- }
146
-
147
- /**
148
- * Makes a request to program specified in `SASjob` (could be a Viya Job, a
149
- * SAS 9 Stored Process, or a SASjs Server Stored Program). The response
150
- * object will always contain table names in lowercase, and column names in
151
- * uppercase. Values are returned formatted by default, unformatted
152
- * values can be configured as an option in the `%webout` macro.
153
- *
154
- * @param sasJob - the path to the SAS program (ultimately resolves to
155
- * the SAS `_program` parameter to run a Job Definition or SAS 9 Stored
156
- * Process). Is prepended at runtime with the value of `appLoc`.
157
- * @param data - a JSON object containing one or more tables to be sent to
158
- * SAS. For an example of the table structure, see the project README. This
159
- * value can be `null` if no inputs are required.
160
- * @param config - provide any changes to the config here, for instance to
161
- * enable/disable `debug`. Any change provided will override the global config,
162
- * for that particular function call.
163
- * @param loginRequiredCallback - a function that is called if the
164
- * user is not logged in (eg to display a login form). The request will be
165
- * resubmitted after successful login.
166
- * When using a `loginRequiredCallback`, the call to the request will look, for example, like so:
167
- * `await request(sasJobPath, data, config, () => setIsLoggedIn(false))`
168
- * If you are not passing in any data and configuration, it will look like so:
169
- * `await request(sasJobPath, {}, {}, () => setIsLoggedIn(false))`
170
- * @param extraResponseAttributes - a array of predefined values that are used
171
- * to provide extra attributes (same names as those values) to be added in response
172
- * Supported values are declared in ExtraResponseAttributes type.
173
- */
174
- public async request(
175
- sasJob: string,
176
- data: { [key: string]: any } | null,
177
- config: { [key: string]: any } = {},
178
- loginRequiredCallback?: () => any,
179
- authConfig?: AuthConfig,
180
- extraResponseAttributes: ExtraResponseAttributes[] = []
181
- ) {
182
- config = {
183
- ...this.sasjsConfig,
184
- ...config
185
- }
186
-
187
- const validationResult = validateInput(data)
188
-
189
- // status is true if the data passes validation checks above
190
- if (validationResult.status) {
191
- return await this.webJobExecutor!.execute(
192
- sasJob,
193
- data,
194
- config,
195
- loginRequiredCallback,
196
- authConfig,
197
- extraResponseAttributes
198
- )
199
- } else {
200
- return Promise.reject(new ErrorResponse(validationResult.msg))
201
- }
202
- }
203
-
204
- /**
205
- * Checks whether a session is active, or login is required.
206
- * @returns - a promise which resolves with an object containing two values - a boolean `isLoggedIn`, and a string `userName`.
207
- */
208
- public async checkSession() {
209
- return this.authManager!.checkSession()
210
- }
211
-
212
- private setupConfiguration() {
213
- if (
214
- this.sasjsConfig.serverUrl === undefined ||
215
- this.sasjsConfig.serverUrl === ''
216
- ) {
217
- if (typeof location !== 'undefined') {
218
- let url = `${location.protocol}//${location.hostname}`
219
-
220
- if (location.port) url = `${url}:${location.port}`
221
-
222
- this.sasjsConfig.serverUrl = url
223
- } else {
224
- this.sasjsConfig.serverUrl = ''
225
- }
226
- }
227
-
228
- if (this.sasjsConfig.serverUrl.slice(-1) === '/') {
229
- this.sasjsConfig.serverUrl = this.sasjsConfig.serverUrl.slice(0, -1)
230
- }
231
-
232
- if (!this.requestClient) {
233
- this.requestClient = new RequestClient(
234
- this.sasjsConfig.serverUrl,
235
- this.sasjsConfig.httpsAgentOptions,
236
- this.sasjsConfig.requestHistoryLimit,
237
- this.sasjsConfig.verbose
238
- )
239
- } else {
240
- this.requestClient.setConfig(
241
- this.sasjsConfig.serverUrl,
242
- this.sasjsConfig.httpsAgentOptions
243
- )
244
- }
245
-
246
- this.jobsPath = this.sasjsConfig.pathSAS9
247
-
248
- this.authManager = new AuthManager(
249
- this.sasjsConfig.serverUrl,
250
- this.sasjsConfig.serverType!,
251
- this.requestClient,
252
- this.resendWaitingRequests
253
- )
254
-
255
- this.fileUploader = new FileUploader(
256
- this.sasjsConfig.serverUrl,
257
- this.sasjsConfig.serverType!,
258
- this.jobsPath,
259
- this.requestClient
260
- )
261
-
262
- this.webJobExecutor = new WebJobExecutor(
263
- this.sasjsConfig.serverUrl,
264
- this.sasjsConfig.serverType!,
265
- this.jobsPath,
266
- this.requestClient
267
- )
268
- }
269
-
270
- private resendWaitingRequests = async () => {
271
- await this.webJobExecutor?.resendWaitingRequests()
272
- await this.fileUploader?.resendWaitingRequests()
273
- }
274
- }
@@ -1,156 +0,0 @@
1
- import {
2
- AuthConfig,
3
- ExtraResponseAttributes,
4
- ServerType
5
- } from '@sasjs/utils/types'
6
- import {
7
- ErrorResponse,
8
- JobExecutionError,
9
- LoginRequiredError
10
- } from '../../types/errors'
11
- import { RequestClient } from '../../request/RequestClient'
12
- import {
13
- isRelativePath,
14
- appendExtraResponseAttributes,
15
- convertToCSV
16
- } from '../../utils'
17
- import { BaseJobExecutor } from '../../job-execution/JobExecutor'
18
- import { parseWeboutResponse } from '../../utils/parseWeboutResponse'
19
-
20
- export interface WaitingRequstPromise {
21
- promise: Promise<any> | null
22
- resolve: any
23
- reject: any
24
- }
25
- export class WebJobExecutor extends BaseJobExecutor {
26
- constructor(
27
- serverUrl: string,
28
- serverType: ServerType,
29
- private jobsPath: string,
30
- private requestClient: RequestClient
31
- ) {
32
- super(serverUrl, serverType)
33
- }
34
-
35
- async execute(
36
- sasJob: string,
37
- data: any,
38
- config: any,
39
- loginRequiredCallback?: any,
40
- authConfig?: AuthConfig,
41
- extraResponseAttributes: ExtraResponseAttributes[] = []
42
- ) {
43
- const loginCallback = loginRequiredCallback
44
- const program = isRelativePath(sasJob)
45
- ? config.appLoc
46
- ? config.appLoc.replace(/\/?$/, '/') + sasJob.replace(/^\//, '')
47
- : sasJob
48
- : sasJob
49
- let apiUrl = `${config.serverUrl}${this.jobsPath}/?${'_program=' + program}`
50
-
51
- let requestParams = {
52
- ...this.getRequestParams(config)
53
- }
54
-
55
- let formData = new FormData()
56
-
57
- if (data) {
58
- try {
59
- formData = generateFileUploadForm(formData, data)
60
- } catch (e: any) {
61
- return Promise.reject(new ErrorResponse(e?.message, e))
62
- }
63
- }
64
-
65
- for (const key in requestParams) {
66
- if (requestParams.hasOwnProperty(key)) {
67
- formData.append(key, requestParams[key])
68
- }
69
- }
70
-
71
- const requestPromise = new Promise((resolve, reject) => {
72
- this.requestClient!.post(apiUrl, formData, authConfig?.access_token)
73
- .then(async (res: any) => {
74
- this.requestClient!.appendRequest(res, sasJob, config.debug)
75
-
76
- const jsonResponse =
77
- config.debug && typeof res.result === 'string'
78
- ? parseWeboutResponse(res.result, apiUrl)
79
- : res.result
80
-
81
- const responseObject = appendExtraResponseAttributes(
82
- { result: jsonResponse, log: res.log },
83
- extraResponseAttributes
84
- )
85
- resolve(responseObject)
86
- })
87
- .catch(async (e: Error) => {
88
- if (e instanceof JobExecutionError) {
89
- this.requestClient!.appendRequest(e, sasJob, config.debug)
90
- reject(new ErrorResponse(e?.message, e))
91
- }
92
-
93
- if (e instanceof LoginRequiredError) {
94
- if (!loginRequiredCallback) {
95
- reject(
96
- new ErrorResponse(
97
- 'Request is not authenticated. Make sure .env file exists with valid credentials.',
98
- e
99
- )
100
- )
101
- }
102
-
103
- this.appendWaitingRequest(() => {
104
- return this.execute(
105
- sasJob,
106
- data,
107
- config,
108
- loginRequiredCallback,
109
- authConfig,
110
- extraResponseAttributes
111
- ).then(
112
- (res: any) => {
113
- resolve(res)
114
- },
115
- (err: any) => {
116
- reject(err)
117
- }
118
- )
119
- })
120
-
121
- if (loginCallback) await loginCallback()
122
- } else reject(new ErrorResponse(e?.message, e))
123
- })
124
- })
125
-
126
- return requestPromise
127
- }
128
- }
129
-
130
- /**
131
- * One of the approaches SASjs takes to send tables-formatted JSON (see README)
132
- * to SAS is as multipart form data, where each table is provided as a specially
133
- * formatted CSV file.
134
- */
135
- const generateFileUploadForm = (formData: FormData, data: any): FormData => {
136
- for (const tableName in data) {
137
- if (!Array.isArray(data[tableName])) continue
138
-
139
- const name = tableName
140
- const csv = convertToCSV(data, tableName)
141
-
142
- if (csv === 'ERROR: LARGE STRING LENGTH') {
143
- throw new Error(
144
- 'The max length of a string value in SASjs is 32765 characters.'
145
- )
146
- }
147
-
148
- const file = new Blob([csv], {
149
- type: 'application/csv'
150
- })
151
-
152
- formData.append(name, file, `${name}.csv`)
153
- }
154
-
155
- return formData
156
- }
@@ -1,3 +0,0 @@
1
- import SASjs from './SASjs'
2
- export * from '../../types'
3
- export default SASjs