@sasjs/adapter 4.19.4 → 5.1.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.
- package/ContextManager.js +290 -0
- package/DISCLOSURE +45 -0
- package/README.md +1 -1
- package/SAS9ApiClient.d.ts +1 -1
- package/SAS9ApiClient.js +90 -0
- package/SASViyaApiClient.js +918 -0
- package/SASjs.js +794 -0
- package/SASjsApiClient.d.ts +1 -0
- package/SASjsApiClient.js +132 -0
- package/SessionManager.js +353 -0
- package/api/viya/executeOnComputeApi.js +198 -0
- package/api/viya/getFileStream.js +32 -0
- package/api/viya/pollJobState.js +247 -0
- package/api/viya/saveLog.js +45 -0
- package/api/viya/uploadTables.js +45 -0
- package/api/viya/writeStream.js +25 -0
- package/auth/AuthManager.js +305 -0
- package/auth/getAccessTokenForSasjs.js +43 -0
- package/auth/getAccessTokenForViya.js +54 -0
- package/auth/getTokenRequestErrorPrefix.js +70 -0
- package/auth/getTokens.js +110 -0
- package/auth/index.js +20 -0
- package/auth/isAuthorizeFormRequired.js +7 -0
- package/auth/isLoginRequired.js +9 -0
- package/auth/loginHeader.js +87 -0
- package/auth/openWebPage.js +31 -0
- package/auth/refreshTokensForSasjs.js +42 -0
- package/auth/refreshTokensForViya.js +53 -0
- package/auth/verifySas9Login.js +32 -0
- package/auth/verifySasViyaLogin.js +44 -0
- package/dist/minified_sas9.js +10892 -0
- package/dist/sasjs-adapter.js +19569 -0
- package/file/generateFileUploadForm.js +43 -0
- package/file/generateTableUploadForm.js +38 -0
- package/index.js +9 -80376
- package/job-execution/ComputeJobExecutor.js +55 -0
- package/job-execution/FileUploader.js +114 -0
- package/job-execution/JesJobExecutor.js +55 -0
- package/job-execution/JobExecutor.js +40 -0
- package/job-execution/Sas9JobExecutor.d.ts +1 -1
- package/job-execution/Sas9JobExecutor.js +115 -0
- package/job-execution/SasjsJobExecutor.js +100 -0
- package/job-execution/WebJobExecutor.js +254 -0
- package/job-execution/index.js +23 -0
- package/minified/sas9/SASjs.js +198 -0
- package/minified/sas9/WebJobExecutor.js +105 -0
- package/minified/sas9/index.js +22 -0
- package/node/index.d.ts +2 -9
- package/node/index.js +1 -30570
- package/package.json +40 -14
- package/request/RequestClient.d.ts +1 -1
- package/request/RequestClient.js +717 -0
- package/request/Sas9RequestClient.d.ts +1 -1
- package/request/Sas9RequestClient.js +121 -0
- package/request/SasjsRequestClient.js +77 -0
- package/types/Context.js +2 -0
- package/types/CsrfToken.js +2 -0
- package/types/ExecuteScript.js +2 -0
- package/types/File.js +2 -0
- package/types/FileResource.js +2 -0
- package/types/Folder.js +2 -0
- package/types/Job.js +2 -0
- package/types/JobDefinition.js +2 -0
- package/types/JobResult.js +2 -0
- package/types/Link.js +2 -0
- package/types/LogStatistics.js +2 -0
- package/types/Login.js +2 -0
- package/types/PollOptions.js +2 -0
- package/types/RequestClient.js +2 -0
- package/types/SASjsConfig.d.ts +1 -1
- package/types/SASjsConfig.js +91 -0
- package/types/Session.js +14 -0
- package/types/Tables.js +28 -0
- package/types/UploadFile.js +2 -0
- package/types/WriteStream.d.ts +1 -1
- package/types/WriteStream.js +2 -0
- package/types/errors/ArgumentError.js +12 -0
- package/types/errors/AuthorizeError.js +13 -0
- package/types/errors/CertificateError.js +12 -0
- package/types/errors/ComputeJobExecutionError.js +13 -0
- package/types/errors/ErrorResponse.js +23 -0
- package/types/errors/InternalServerError.js +11 -0
- package/types/errors/InvalidJsonError.js +11 -0
- package/types/errors/InvalidSASjsCsrfError.js +12 -0
- package/types/errors/JobExecutionError.js +14 -0
- package/types/errors/JobStatePollError.js +12 -0
- package/types/errors/JsonParseArrayError.js +11 -0
- package/types/errors/LoginRequiredError.js +14 -0
- package/types/errors/NoSessionStateError.js +14 -0
- package/types/errors/NotFoundError.js +12 -0
- package/types/errors/RootFolderNotFoundError.js +22 -0
- package/types/errors/SAS9AuthError.js +11 -0
- package/types/errors/WeboutResponseError.js +12 -0
- package/types/errors/index.js +31 -0
- package/types/index.js +34 -0
- package/utils/appendExtraResponseAttributes.js +25 -0
- package/utils/asyncForEach.js +20 -0
- package/utils/compareTimestamps.js +11 -0
- package/utils/convertToCsv.js +154 -0
- package/utils/createAxiosInstance.d.ts +1 -1
- package/utils/createAxiosInstance.js +9 -0
- package/utils/delay.js +5 -0
- package/{src/utils/extractWeboutBlob.ts → utils/extractWeboutBlob.js} +19 -20
- package/utils/fetchLogByChunks.js +56 -0
- package/utils/formatDataForRequest.js +39 -0
- package/utils/getFormData.js +10 -0
- package/{node/utils/getUserLanguage.d.ts → utils/getUserLanguage.js} +5 -1
- package/utils/getValidJson.js +27 -0
- package/utils/host.d.ts +24 -0
- package/utils/host.js +36 -0
- package/utils/index.js +41 -0
- package/utils/isIeOrEdge.js +30 -0
- package/utils/isNode.js +7 -0
- package/utils/isRelativePath.js +5 -0
- package/utils/isUri.js +9 -0
- package/utils/isUrl.js +20 -0
- package/utils/loginPrompt/index.js +180 -0
- package/utils/needsRetry.js +14 -0
- package/utils/parseGeneratedCode.js +10 -0
- package/utils/parseSasViyaLog.js +17 -0
- package/utils/parseSourceCode.js +9 -0
- package/utils/parseViyaDebugResponse.js +46 -0
- package/utils/parseViyaLogDebugResponse.js +32 -0
- package/utils/parseWeboutResponse.js +22 -0
- package/utils/sas9/extractUserLongNameSas9.js +30 -0
- package/utils/serialize.js +20 -0
- package/utils/splitChunks.js +13 -0
- package/utils/validateInput.js +83 -0
- package/.env.example +0 -2
- package/.git-hooks/commit-msg +0 -39
- package/.git-hooks/pre-commit +0 -12
- package/.gitattributes +0 -1
- package/.pre-commit-config.yaml +0 -25
- package/.vscode/settings.json +0 -3
- package/SASViyaApiClient.spec.d.ts +0 -1
- package/__mocks__/axios.d.ts +0 -3
- package/api/viya/spec/executeScript.spec.d.ts +0 -1
- package/api/viya/spec/getFileStream.spec.d.ts +0 -1
- package/api/viya/spec/mockResponses.d.ts +0 -10
- package/api/viya/spec/pollJobState.spec.d.ts +0 -1
- package/api/viya/spec/saveLog.spec.d.ts +0 -1
- package/api/viya/spec/uploadTables.spec.d.ts +0 -1
- package/api/viya/spec/writeStream.spec.d.ts +0 -1
- package/auth/spec/AuthManager.spec.d.ts +0 -4
- package/auth/spec/getAccessTokenForSasjs.spec.d.ts +0 -1
- package/auth/spec/getAccessTokenForViya.spec.d.ts +0 -1
- package/auth/spec/getTokenRequestErrorPrefix.spec.d.ts +0 -1
- package/auth/spec/getTokens.spec.d.ts +0 -1
- package/auth/spec/loginHeader.spec.d.ts +0 -4
- package/auth/spec/mockResponses.d.ts +0 -23
- package/auth/spec/openWebPage.spec.d.ts +0 -1
- package/auth/spec/refreshTokensForSasjs.spec.d.ts +0 -1
- package/auth/spec/refreshTokensForViya.spec.d.ts +0 -1
- package/auth/spec/verifySas9Login.spec.d.ts +0 -1
- package/auth/spec/verifySasViyaLogin.spec.d.ts +0 -1
- package/createTSDocs.js +0 -35
- package/cypress.config.js +0 -18
- package/example.html +0 -109
- package/file/spec/generateFileUploadForm.spec.d.ts +0 -1
- package/file/spec/generateTableUploadForm.spec.d.ts +0 -1
- package/index-dev.js +0 -80394
- package/job-execution/spec/ComputeJobExecutor.spec.d.ts +0 -1
- package/job-execution/spec/JesJobExecutor.spec.d.ts +0 -1
- package/job-execution/spec/Sas9JobExecutor.spec.d.ts +0 -1
- package/job-execution/spec/SasjsJobExecutor.spec.d.ts +0 -1
- package/job-execution/spec/WebJobExecutor.debug.spec.d.ts +0 -1
- package/job-execution/spec/WebJobExecutor.spec.d.ts +0 -1
- package/job-execution/spec/executionTasks.spec.d.ts +0 -1
- package/minified_sas9.js +0 -14039
- package/node/ContextManager.d.ts +0 -41
- package/node/SAS9ApiClient.d.ts +0 -30
- package/node/SASViyaApiClient.d.ts +0 -298
- package/node/SASjs.d.ts +0 -387
- package/node/SASjsApiClient.d.ts +0 -65
- package/node/SessionManager.d.ts +0 -115
- package/node/api/viya/executeOnComputeApi.d.ts +0 -21
- package/node/api/viya/getFileStream.d.ts +0 -2
- package/node/api/viya/pollJobState.d.ts +0 -57
- package/node/api/viya/saveLog.d.ts +0 -15
- package/node/api/viya/uploadTables.d.ts +0 -13
- package/node/api/viya/writeStream.d.ts +0 -2
- package/node/auth/AuthManager.d.ts +0 -49
- package/node/auth/getAccessTokenForSasjs.d.ts +0 -11
- package/node/auth/getAccessTokenForViya.d.ts +0 -10
- package/node/auth/getTokenRequestErrorPrefix.d.ts +0 -44
- package/node/auth/getTokens.d.ts +0 -22
- package/node/auth/index.d.ts +0 -4
- package/node/auth/isAuthorizeFormRequired.d.ts +0 -1
- package/node/auth/isLoginRequired.d.ts +0 -1
- package/node/auth/loginHeader.d.ts +0 -17
- package/node/auth/openWebPage.d.ts +0 -6
- package/node/auth/refreshTokensForSasjs.d.ts +0 -10
- package/node/auth/refreshTokensForViya.d.ts +0 -11
- package/node/auth/verifySas9Login.d.ts +0 -3
- package/node/auth/verifySasViyaLogin.d.ts +0 -4
- package/node/file/generateFileUploadForm.d.ts +0 -11
- package/node/file/generateTableUploadForm.d.ts +0 -5
- package/node/job-execution/ComputeJobExecutor.d.ts +0 -8
- package/node/job-execution/FileUploader.d.ts +0 -9
- package/node/job-execution/JesJobExecutor.d.ts +0 -9
- package/node/job-execution/JobExecutor.d.ts +0 -17
- package/node/job-execution/Sas9JobExecutor.d.ts +0 -19
- package/node/job-execution/SasjsJobExecutor.d.ts +0 -9
- package/node/job-execution/WebJobExecutor.d.ts +0 -18
- package/node/job-execution/index.d.ts +0 -7
- package/node/request/RequestClient.d.ts +0 -125
- package/node/request/Sas9RequestClient.d.ts +0 -25
- package/node/request/SasjsRequestClient.d.ts +0 -12
- package/node/types/Context.d.ts +0 -42
- package/node/types/CsrfToken.d.ts +0 -4
- package/node/types/ExecuteScript.d.ts +0 -4
- package/node/types/File.d.ts +0 -7
- package/node/types/FileResource.d.ts +0 -32
- package/node/types/Folder.d.ts +0 -7
- package/node/types/Job.d.ts +0 -14
- package/node/types/JobDefinition.d.ts +0 -3
- package/node/types/JobResult.d.ts +0 -3
- package/node/types/Link.d.ts +0 -7
- package/node/types/LogStatistics.d.ts +0 -4
- package/node/types/Login.d.ts +0 -14
- package/node/types/PollOptions.d.ts +0 -8
- package/node/types/RequestClient.d.ts +0 -46
- package/node/types/SASjsConfig.d.ts +0 -94
- package/node/types/Session.d.ts +0 -30
- package/node/types/Tables.d.ts +0 -7
- package/node/types/UploadFile.d.ts +0 -8
- package/node/types/WriteStream.d.ts +0 -7
- package/node/types/errors/ArgumentError.d.ts +0 -4
- package/node/types/errors/AuthorizeError.d.ts +0 -5
- package/node/types/errors/CertificateError.d.ts +0 -3
- package/node/types/errors/ComputeJobExecutionError.d.ts +0 -6
- package/node/types/errors/ErrorResponse.d.ts +0 -9
- package/node/types/errors/InternalServerError.d.ts +0 -3
- package/node/types/errors/InvalidJsonError.d.ts +0 -3
- package/node/types/errors/InvalidSASjsCsrfError.d.ts +0 -3
- package/node/types/errors/JobExecutionError.d.ts +0 -6
- package/node/types/errors/JobStatePollError.d.ts +0 -4
- package/node/types/errors/JsonParseArrayError.d.ts +0 -3
- package/node/types/errors/LoginRequiredError.d.ts +0 -3
- package/node/types/errors/NoSessionStateError.d.ts +0 -6
- package/node/types/errors/NotFoundError.d.ts +0 -4
- package/node/types/errors/RootFolderNotFoundError.d.ts +0 -3
- package/node/types/errors/SAS9AuthError.d.ts +0 -3
- package/node/types/errors/WeboutResponseError.d.ts +0 -4
- package/node/types/errors/index.d.ts +0 -15
- package/node/types/index.d.ts +0 -18
- package/node/utils/appendExtraResponseAttributes.d.ts +0 -2
- package/node/utils/asyncForEach.d.ts +0 -1
- package/node/utils/compareTimestamps.d.ts +0 -6
- package/node/utils/convertToCsv.d.ts +0 -12
- package/node/utils/createAxiosInstance.d.ts +0 -2
- package/node/utils/delay.d.ts +0 -1
- package/node/utils/extractWeboutBlob.d.ts +0 -13
- package/node/utils/fetchLogByChunks.d.ts +0 -20
- package/node/utils/formatDataForRequest.d.ts +0 -1
- package/node/utils/getFormData.d.ts +0 -2
- package/node/utils/getValidJson.d.ts +0 -5
- package/node/utils/index.d.ts +0 -25
- package/node/utils/isNode.d.ts +0 -1
- package/node/utils/isRelativePath.d.ts +0 -1
- package/node/utils/isUri.d.ts +0 -5
- package/node/utils/isUrl.d.ts +0 -5
- package/node/utils/loginPrompt/index.d.ts +0 -1
- package/node/utils/needsRetry.d.ts +0 -1
- package/node/utils/parseGeneratedCode.d.ts +0 -1
- package/node/utils/parseSasViyaLog.d.ts +0 -5
- package/node/utils/parseSourceCode.d.ts +0 -1
- package/node/utils/parseViyaDebugResponse.d.ts +0 -12
- package/node/utils/parseViyaLogDebugResponse.d.ts +0 -8
- package/node/utils/parseWeboutResponse.d.ts +0 -1
- package/node/utils/sas9/extractUserLongNameSas9.d.ts +0 -6
- package/node/utils/serialize.d.ts +0 -1
- package/node/utils/splitChunks.d.ts +0 -1
- package/node/utils/validateInput.d.ts +0 -14
- package/request/spec/SasjsRequestClient.spec.d.ts +0 -1
- package/screenshots/session-manager-first-request.png +0 -0
- package/screenshots/subsequent-session-request.png +0 -0
- package/spec/SAS9ApiClient.spec.d.ts +0 -1
- package/spec/SASjs.startComputeJob.spec.d.ts +0 -1
- package/spec/SASjsApiClient.spec.d.ts +0 -1
- package/src/ContextManager.ts +0 -454
- package/src/SAS9ApiClient.ts +0 -100
- package/src/SASViyaApiClient.ts +0 -1417
- package/src/SASjs.ts +0 -1268
- package/src/SASjsApiClient.ts +0 -177
- package/src/SessionManager.ts +0 -465
- package/src/__mocks__/axios.ts +0 -7
- package/src/api/viya/executeOnComputeApi.ts +0 -307
- package/src/api/viya/getFileStream.ts +0 -17
- package/src/api/viya/pollJobState.ts +0 -393
- package/src/api/viya/saveLog.ts +0 -55
- package/src/api/viya/spec/mockResponses.ts +0 -75
- package/src/api/viya/uploadTables.ts +0 -41
- package/src/api/viya/writeStream.ts +0 -16
- package/src/auth/AuthManager.ts +0 -387
- package/src/auth/getAccessTokenForSasjs.ts +0 -48
- package/src/auth/getAccessTokenForViya.ts +0 -61
- package/src/auth/getTokenRequestErrorPrefix.ts +0 -88
- package/src/auth/getTokens.ts +0 -127
- package/src/auth/index.ts +0 -4
- package/src/auth/isAuthorizeFormRequired.ts +0 -3
- package/src/auth/isLoginRequired.ts +0 -5
- package/src/auth/loginHeader.ts +0 -97
- package/src/auth/openWebPage.ts +0 -40
- package/src/auth/refreshTokensForSasjs.ts +0 -45
- package/src/auth/refreshTokensForViya.ts +0 -66
- package/src/auth/spec/mockResponses.ts +0 -53
- package/src/auth/verifySas9Login.ts +0 -25
- package/src/auth/verifySasViyaLogin.ts +0 -43
- package/src/file/generateFileUploadForm.ts +0 -48
- package/src/file/generateTableUploadForm.ts +0 -50
- package/src/index.ts +0 -9
- package/src/job-execution/ComputeJobExecutor.ts +0 -76
- package/src/job-execution/FileUploader.ts +0 -152
- package/src/job-execution/JesJobExecutor.ts +0 -78
- package/src/job-execution/JobExecutor.ts +0 -63
- package/src/job-execution/Sas9JobExecutor.ts +0 -137
- package/src/job-execution/SasjsJobExecutor.ts +0 -152
- package/src/job-execution/WebJobExecutor.ts +0 -341
- package/src/job-execution/index.ts +0 -7
- package/src/minified/sas9/SASjs.ts +0 -274
- package/src/minified/sas9/WebJobExecutor.ts +0 -156
- package/src/minified/sas9/index.ts +0 -3
- package/src/request/RequestClient.ts +0 -941
- package/src/request/Sas9RequestClient.ts +0 -132
- package/src/request/SasjsRequestClient.ts +0 -82
- package/src/test/SAS_server_app.ts +0 -47
- package/src/types/Context.ts +0 -39
- package/src/types/CsrfToken.ts +0 -4
- package/src/types/ExecuteScript.ts +0 -4
- package/src/types/File.ts +0 -8
- package/src/types/FileResource.ts +0 -33
- package/src/types/Folder.ts +0 -8
- package/src/types/Job.ts +0 -15
- package/src/types/JobDefinition.ts +0 -3
- package/src/types/JobResult.ts +0 -3
- package/src/types/Link.ts +0 -7
- package/src/types/LogStatistics.ts +0 -4
- package/src/types/Login.ts +0 -15
- package/src/types/PollOptions.ts +0 -9
- package/src/types/Process.d.ts +0 -5
- package/src/types/RequestClient.ts +0 -55
- package/src/types/SASjsConfig.ts +0 -95
- package/src/types/Session.ts +0 -34
- package/src/types/Tables.ts +0 -29
- package/src/types/UploadFile.ts +0 -8
- package/src/types/WriteStream.ts +0 -10
- package/src/types/errors/ArgumentError.ts +0 -7
- package/src/types/errors/AuthorizeError.ts +0 -10
- package/src/types/errors/CertificateError.ts +0 -12
- package/src/types/errors/ComputeJobExecutionError.ts +0 -12
- package/src/types/errors/ErrorResponse.ts +0 -28
- package/src/types/errors/InternalServerError.ts +0 -9
- package/src/types/errors/InvalidJsonError.ts +0 -7
- package/src/types/errors/InvalidSASjsCsrfError.ts +0 -9
- package/src/types/errors/JobExecutionError.ts +0 -11
- package/src/types/errors/JobStatePollError.ts +0 -14
- package/src/types/errors/JsonParseArrayError.ts +0 -7
- package/src/types/errors/LoginRequiredError.ts +0 -11
- package/src/types/errors/NoSessionStateError.ts +0 -15
- package/src/types/errors/NotFoundError.ts +0 -7
- package/src/types/errors/RootFolderNotFoundError.ts +0 -24
- package/src/types/errors/SAS9AuthError.ts +0 -9
- package/src/types/errors/WeboutResponseError.ts +0 -7
- package/src/types/errors/index.ts +0 -15
- package/src/types/index.ts +0 -18
- package/src/types/system/global.d.ts +0 -1
- package/src/utils/appendExtraResponseAttributes.ts +0 -22
- package/src/utils/asyncForEach.ts +0 -5
- package/src/utils/compareTimestamps.ts +0 -9
- package/src/utils/convertToCsv.ts +0 -198
- package/src/utils/createAxiosInstance.ts +0 -7
- package/src/utils/delay.ts +0 -2
- package/src/utils/fetchLogByChunks.ts +0 -63
- package/src/utils/formatDataForRequest.ts +0 -48
- package/src/utils/getFormData.ts +0 -5
- package/src/utils/getUserLanguage.ts +0 -10
- package/src/utils/getValidJson.ts +0 -23
- package/src/utils/index.ts +0 -25
- package/src/utils/isIeOrEdge.ts +0 -34
- package/src/utils/isNode.ts +0 -4
- package/src/utils/isRelativePath.ts +0 -2
- package/src/utils/isUri.ts +0 -5
- package/src/utils/isUrl.ts +0 -17
- package/src/utils/loginPrompt/index.ts +0 -177
- package/src/utils/needsRetry.ts +0 -14
- package/src/utils/parseGeneratedCode.ts +0 -7
- package/src/utils/parseSasViyaLog.ts +0 -12
- package/src/utils/parseSourceCode.ts +0 -6
- package/src/utils/parseViyaDebugResponse.ts +0 -46
- package/src/utils/parseViyaLogDebugResponse.ts +0 -22
- package/src/utils/parseWeboutResponse.ts +0 -20
- package/src/utils/sas9/extractUserLongNameSas9.ts +0 -31
- package/src/utils/serialize.ts +0 -15
- package/src/utils/splitChunks.ts +0 -12
- package/src/utils/validateInput.ts +0 -93
- package/test/ContextManager.spec.d.ts +0 -1
- package/test/FileUploader.spec.d.ts +0 -4
- package/test/FolderOperations.spec.d.ts +0 -1
- package/test/RequestClient.spec.d.ts +0 -1
- package/test/SAS_server_app.d.ts +0 -10
- package/test/SessionManager.spec.d.ts +0 -1
- package/test/getJobsInFolder.spec.d.ts +0 -1
- package/test/utils/formatDataForRequest.spec.d.ts +0 -1
- package/test/utils/getValidJson.spec.d.ts +0 -1
- package/test/utils/isUrl.spec.d.ts +0 -1
- package/test/utils/parseGeneratedCode.spec.d.ts +0 -1
- package/test/utils/parseSourceCode.spec.d.ts +0 -1
- package/types/Tables.spec.d.ts +0 -1
- package/types/errors/RootFolderNotFoundError.spec.d.ts +0 -1
- package/types/errors/spec/SAS9AuthError.spec.d.ts +0 -1
- package/utils/spec/convertToCsv.spec.d.ts +0 -1
- package/utils/spec/extractUserLongNameSas9.spec.d.ts +0 -1
- package/utils/spec/getFormData.spec.d.ts +0 -1
- package/utils/spec/parseSasViyaLog.spec.d.ts +0 -1
- package/utils/spec/parseViyaDebugResponse.spec.d.ts +0 -1
- package/utils/spec/parseViyaLogDebugResponse.spec.d.ts +0 -1
- package/utils/spec/validateInput.spec.d.ts +0 -1
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import NodeFormData from 'form-data'
|
|
2
|
-
import {
|
|
3
|
-
AuthConfig,
|
|
4
|
-
ExtraResponseAttributes,
|
|
5
|
-
ServerType
|
|
6
|
-
} from '@sasjs/utils/types'
|
|
7
|
-
import {
|
|
8
|
-
ErrorResponse,
|
|
9
|
-
JobExecutionError,
|
|
10
|
-
LoginRequiredError
|
|
11
|
-
} from '../types/errors'
|
|
12
|
-
import { generateFileUploadForm } from '../file/generateFileUploadForm'
|
|
13
|
-
import { RequestClient } from '../request/RequestClient'
|
|
14
|
-
import { getFormData } from '../utils'
|
|
15
|
-
|
|
16
|
-
import {
|
|
17
|
-
isRelativePath,
|
|
18
|
-
appendExtraResponseAttributes,
|
|
19
|
-
getValidJson
|
|
20
|
-
} from '../utils'
|
|
21
|
-
import { BaseJobExecutor } from './JobExecutor'
|
|
22
|
-
|
|
23
|
-
export class SasjsJobExecutor extends BaseJobExecutor {
|
|
24
|
-
constructor(
|
|
25
|
-
serverUrl: string,
|
|
26
|
-
private jobsPath: string,
|
|
27
|
-
private requestClient: RequestClient
|
|
28
|
-
) {
|
|
29
|
-
super(serverUrl, ServerType.Sasjs)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
async execute(
|
|
33
|
-
sasJob: string,
|
|
34
|
-
data: any,
|
|
35
|
-
config: any,
|
|
36
|
-
loginRequiredCallback?: any,
|
|
37
|
-
authConfig?: AuthConfig,
|
|
38
|
-
extraResponseAttributes: ExtraResponseAttributes[] = []
|
|
39
|
-
) {
|
|
40
|
-
const loginCallback = loginRequiredCallback
|
|
41
|
-
const program =
|
|
42
|
-
isRelativePath(sasJob) && config.appLoc
|
|
43
|
-
? config.appLoc.replace(/\/?$/, '/') + sasJob.replace(/^\//, '')
|
|
44
|
-
: sasJob
|
|
45
|
-
|
|
46
|
-
let apiUrl = `${config.serverUrl}${this.jobsPath}/?${'_program=' + program}`
|
|
47
|
-
|
|
48
|
-
let requestParams = {
|
|
49
|
-
...this.getRequestParams(config)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Use the available form data object (FormData in Browser, NodeFormData in
|
|
54
|
-
* Node)
|
|
55
|
-
*/
|
|
56
|
-
let formData = getFormData()
|
|
57
|
-
|
|
58
|
-
if (data) {
|
|
59
|
-
// file upload approach
|
|
60
|
-
try {
|
|
61
|
-
formData = generateFileUploadForm(formData, data)
|
|
62
|
-
} catch (e: any) {
|
|
63
|
-
return Promise.reject(new ErrorResponse(e?.message, e))
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
for (const key in requestParams) {
|
|
68
|
-
if (requestParams.hasOwnProperty(key)) {
|
|
69
|
-
formData.append(key, requestParams[key])
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/* The NodeFormData object does not set the request header - so, set it */
|
|
74
|
-
const contentType =
|
|
75
|
-
formData instanceof NodeFormData && typeof FormData === 'undefined'
|
|
76
|
-
? `multipart/form-data; boundary=${
|
|
77
|
-
formData.getHeaders()['content-type']
|
|
78
|
-
}`
|
|
79
|
-
: 'multipart/form-data'
|
|
80
|
-
|
|
81
|
-
const requestPromise = new Promise((resolve, reject) => {
|
|
82
|
-
this.requestClient!.post(
|
|
83
|
-
apiUrl,
|
|
84
|
-
formData,
|
|
85
|
-
authConfig?.access_token,
|
|
86
|
-
contentType
|
|
87
|
-
)
|
|
88
|
-
.then(async (res: any) => {
|
|
89
|
-
if (Object.entries(res.result).length < 1) {
|
|
90
|
-
throw new JobExecutionError(
|
|
91
|
-
0,
|
|
92
|
-
`No webout was returned by job ${program}. Please check the SAS log for more info.`,
|
|
93
|
-
res.log
|
|
94
|
-
)
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const { result } = res
|
|
98
|
-
|
|
99
|
-
if (result && typeof result === 'string' && result.trim())
|
|
100
|
-
res.result = getValidJson(result)
|
|
101
|
-
|
|
102
|
-
this.requestClient!.appendRequest(res, sasJob, config.debug)
|
|
103
|
-
|
|
104
|
-
const responseObject = appendExtraResponseAttributes(
|
|
105
|
-
res,
|
|
106
|
-
extraResponseAttributes
|
|
107
|
-
)
|
|
108
|
-
|
|
109
|
-
resolve(responseObject)
|
|
110
|
-
})
|
|
111
|
-
.catch(async (e: Error) => {
|
|
112
|
-
if (e instanceof JobExecutionError) {
|
|
113
|
-
this.requestClient!.appendRequest(e, sasJob, config.debug)
|
|
114
|
-
reject(new ErrorResponse(e?.message, e))
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
if (e instanceof LoginRequiredError) {
|
|
118
|
-
if (!loginRequiredCallback) {
|
|
119
|
-
reject(
|
|
120
|
-
new ErrorResponse(
|
|
121
|
-
'Request is not authenticated. Make sure .env file exists with valid credentials.',
|
|
122
|
-
e
|
|
123
|
-
)
|
|
124
|
-
)
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
this.appendWaitingRequest(() => {
|
|
128
|
-
return this.execute(
|
|
129
|
-
sasJob,
|
|
130
|
-
data,
|
|
131
|
-
config,
|
|
132
|
-
loginRequiredCallback,
|
|
133
|
-
authConfig,
|
|
134
|
-
extraResponseAttributes
|
|
135
|
-
).then(
|
|
136
|
-
(res: any) => {
|
|
137
|
-
resolve(res)
|
|
138
|
-
},
|
|
139
|
-
(err: any) => {
|
|
140
|
-
reject(err)
|
|
141
|
-
}
|
|
142
|
-
)
|
|
143
|
-
})
|
|
144
|
-
|
|
145
|
-
if (loginCallback) await loginCallback()
|
|
146
|
-
} else reject(new ErrorResponse(e?.message, e))
|
|
147
|
-
})
|
|
148
|
-
})
|
|
149
|
-
|
|
150
|
-
return requestPromise
|
|
151
|
-
}
|
|
152
|
-
}
|
|
@@ -1,341 +0,0 @@
|
|
|
1
|
-
import NodeFormData from 'form-data'
|
|
2
|
-
import {
|
|
3
|
-
AuthConfig,
|
|
4
|
-
ExtraResponseAttributes,
|
|
5
|
-
ServerType
|
|
6
|
-
} from '@sasjs/utils/types'
|
|
7
|
-
import {
|
|
8
|
-
ErrorResponse,
|
|
9
|
-
JobExecutionError,
|
|
10
|
-
LoginRequiredError
|
|
11
|
-
} from '../types/errors'
|
|
12
|
-
import { generateFileUploadForm } from '../file/generateFileUploadForm'
|
|
13
|
-
import { generateTableUploadForm } from '../file/generateTableUploadForm'
|
|
14
|
-
import { RequestClient } from '../request/RequestClient'
|
|
15
|
-
import { SASViyaApiClient } from '../SASViyaApiClient'
|
|
16
|
-
import {
|
|
17
|
-
isRelativePath,
|
|
18
|
-
parseSasViyaDebugResponse,
|
|
19
|
-
parseSasViyaLogDebugResponse,
|
|
20
|
-
appendExtraResponseAttributes,
|
|
21
|
-
parseWeboutResponse,
|
|
22
|
-
getFormData,
|
|
23
|
-
hasWeboutBlob,
|
|
24
|
-
isNode
|
|
25
|
-
} from '../utils'
|
|
26
|
-
import { BaseJobExecutor } from './JobExecutor'
|
|
27
|
-
|
|
28
|
-
export interface WaitingRequstPromise {
|
|
29
|
-
promise: Promise<any> | null
|
|
30
|
-
resolve: any
|
|
31
|
-
reject: any
|
|
32
|
-
}
|
|
33
|
-
export class WebJobExecutor extends BaseJobExecutor {
|
|
34
|
-
constructor(
|
|
35
|
-
serverUrl: string,
|
|
36
|
-
serverType: ServerType,
|
|
37
|
-
private jobsPath: string,
|
|
38
|
-
private requestClient: RequestClient,
|
|
39
|
-
private sasViyaApiClient: SASViyaApiClient
|
|
40
|
-
) {
|
|
41
|
-
super(serverUrl, serverType)
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
async execute(
|
|
45
|
-
sasJob: string,
|
|
46
|
-
data: any,
|
|
47
|
-
config: any,
|
|
48
|
-
loginRequiredCallback?: any,
|
|
49
|
-
authConfig?: AuthConfig,
|
|
50
|
-
extraResponseAttributes: ExtraResponseAttributes[] = []
|
|
51
|
-
) {
|
|
52
|
-
const loginCallback = loginRequiredCallback
|
|
53
|
-
const program = isRelativePath(sasJob)
|
|
54
|
-
? config.appLoc
|
|
55
|
-
? config.appLoc.replace(/\/?$/, '/') + sasJob.replace(/^\//, '')
|
|
56
|
-
: sasJob
|
|
57
|
-
: sasJob
|
|
58
|
-
let apiUrl = `${config.serverUrl}${this.jobsPath}/?${'_program=' + program}`
|
|
59
|
-
|
|
60
|
-
if (config.serverType === ServerType.SasViya) {
|
|
61
|
-
let jobUri
|
|
62
|
-
try {
|
|
63
|
-
jobUri = await this.getJobUri(program)
|
|
64
|
-
} catch (e: any) {
|
|
65
|
-
return new Promise(async (resolve, reject) => {
|
|
66
|
-
if (e instanceof LoginRequiredError) {
|
|
67
|
-
this.appendWaitingRequest(() => {
|
|
68
|
-
return this.execute(
|
|
69
|
-
sasJob,
|
|
70
|
-
data,
|
|
71
|
-
config,
|
|
72
|
-
loginRequiredCallback,
|
|
73
|
-
authConfig,
|
|
74
|
-
extraResponseAttributes
|
|
75
|
-
).then(
|
|
76
|
-
(res: any) => {
|
|
77
|
-
resolve(res)
|
|
78
|
-
},
|
|
79
|
-
(err: any) => {
|
|
80
|
-
reject(err)
|
|
81
|
-
}
|
|
82
|
-
)
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
if (loginCallback) await loginCallback()
|
|
86
|
-
} else {
|
|
87
|
-
reject(new ErrorResponse(e?.message, e))
|
|
88
|
-
}
|
|
89
|
-
})
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (jobUri.length > 0) {
|
|
93
|
-
apiUrl += '&_job=' + jobUri
|
|
94
|
-
/**
|
|
95
|
-
* Using both _job and _program parameters will cause a conflict in the JES web app, as it's not clear whether or not the server should make the extra fetch for the job uri.
|
|
96
|
-
* To handle this, we add the extra underscore and recreate the _program variable in the SAS side of the SASjs adapter so it remains available for backend developers.
|
|
97
|
-
*/
|
|
98
|
-
apiUrl = apiUrl.replace('_program=', '__program=')
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// Append context name to URL if provided and non-empty
|
|
102
|
-
apiUrl += config.contextName?.trim()
|
|
103
|
-
? `&_contextname=${encodeURIComponent(config.contextName)}`
|
|
104
|
-
: ''
|
|
105
|
-
|
|
106
|
-
if (config.runAsTask === true) {
|
|
107
|
-
apiUrl += '&_executionTasks=true'
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
let requestParams = {
|
|
112
|
-
...this.getRequestParams(config)
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Use the available form data object (FormData in Browser, NodeFormData in
|
|
117
|
-
* Node)
|
|
118
|
-
*/
|
|
119
|
-
let formData = getFormData()
|
|
120
|
-
|
|
121
|
-
// FIXME(viya - SAS Track CS0409737): remove when Viya stops rejecting empty multipart on
|
|
122
|
-
// _executionTasks=true. Dummy file keeps the body non-empty
|
|
123
|
-
const hasExecutionTasksFlag = config.runAsTask === true
|
|
124
|
-
|
|
125
|
-
// Move debug params to URL for viya; viya seems to honor them more
|
|
126
|
-
// reliably in the query string than the multipart body.
|
|
127
|
-
if (
|
|
128
|
-
hasExecutionTasksFlag &&
|
|
129
|
-
config.debug &&
|
|
130
|
-
config.serverType === ServerType.SasViya
|
|
131
|
-
) {
|
|
132
|
-
const debugKeys = ['_debug', '_omitSessionResults']
|
|
133
|
-
debugKeys.forEach((key) => {
|
|
134
|
-
if (requestParams[key] !== undefined) {
|
|
135
|
-
apiUrl += `&${key}=${encodeURIComponent(requestParams[key])}`
|
|
136
|
-
delete requestParams[key]
|
|
137
|
-
}
|
|
138
|
-
})
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
if (data) {
|
|
142
|
-
const stringifiedData = JSON.stringify(data)
|
|
143
|
-
if (
|
|
144
|
-
config.serverType === ServerType.Sas9 ||
|
|
145
|
-
stringifiedData.length > 500000 ||
|
|
146
|
-
stringifiedData.includes(';')
|
|
147
|
-
) {
|
|
148
|
-
// file upload approach
|
|
149
|
-
try {
|
|
150
|
-
formData = generateFileUploadForm(formData, data)
|
|
151
|
-
} catch (e: any) {
|
|
152
|
-
return Promise.reject(new ErrorResponse(e?.message, e))
|
|
153
|
-
}
|
|
154
|
-
} else {
|
|
155
|
-
// param based approach
|
|
156
|
-
try {
|
|
157
|
-
const { formData: newFormData, requestParams: params } =
|
|
158
|
-
generateTableUploadForm(formData, data)
|
|
159
|
-
formData = newFormData
|
|
160
|
-
requestParams = { ...requestParams, ...params }
|
|
161
|
-
|
|
162
|
-
if (
|
|
163
|
-
config.serverType === ServerType.SasViya &&
|
|
164
|
-
hasExecutionTasksFlag
|
|
165
|
-
) {
|
|
166
|
-
addDummyFile(formData)
|
|
167
|
-
}
|
|
168
|
-
} catch (e: any) {
|
|
169
|
-
return Promise.reject(new ErrorResponse(e?.message, e))
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
} else {
|
|
173
|
-
if (config.serverType === ServerType.SasViya && hasExecutionTasksFlag) {
|
|
174
|
-
addDummyFile(formData)
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
for (const key in requestParams) {
|
|
179
|
-
if (requestParams.hasOwnProperty(key)) {
|
|
180
|
-
formData.append(key, requestParams[key])
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
/* The NodeFormData object does not set the request header - so, set it */
|
|
185
|
-
const contentType =
|
|
186
|
-
formData instanceof NodeFormData && typeof FormData === 'undefined'
|
|
187
|
-
? `multipart/form-data; boundary=${
|
|
188
|
-
formData.getHeaders()['content-type']
|
|
189
|
-
}`
|
|
190
|
-
: 'multipart/form-data'
|
|
191
|
-
|
|
192
|
-
const requestPromise = new Promise((resolve, reject) => {
|
|
193
|
-
this.requestClient!.post(
|
|
194
|
-
apiUrl,
|
|
195
|
-
formData,
|
|
196
|
-
authConfig?.access_token,
|
|
197
|
-
contentType
|
|
198
|
-
)
|
|
199
|
-
.then(async (res: any) => {
|
|
200
|
-
this.requestClient!.appendRequest(res, sasJob, config.debug)
|
|
201
|
-
|
|
202
|
-
let jsonResponse = res.result
|
|
203
|
-
|
|
204
|
-
if (config.debug) {
|
|
205
|
-
switch (this.serverType) {
|
|
206
|
-
case ServerType.SasViya:
|
|
207
|
-
// Route on the shape of the response itself. The JES web app
|
|
208
|
-
// returns the webout inline in a script-constructed Blob when
|
|
209
|
-
// it runs the job as a compute task, and as an iframe file URL
|
|
210
|
-
// otherwise - but the _debug value sent does not determine
|
|
211
|
-
// which: a _debug=128 request without _EXECUTIONTASKS gets the
|
|
212
|
-
// iframe form back. A result that is already an object has
|
|
213
|
-
// been parsed upstream, and parseSasViyaDebugResponse also
|
|
214
|
-
// falls back to blob extraction, so either parser copes with
|
|
215
|
-
// a response that mixes the two.
|
|
216
|
-
jsonResponse =
|
|
217
|
-
typeof res.result !== 'string' || hasWeboutBlob(res.result)
|
|
218
|
-
? await parseSasViyaLogDebugResponse(res.result)
|
|
219
|
-
: await parseSasViyaDebugResponse(
|
|
220
|
-
res.result,
|
|
221
|
-
this.requestClient,
|
|
222
|
-
this.serverUrl
|
|
223
|
-
)
|
|
224
|
-
break
|
|
225
|
-
case ServerType.Sas9:
|
|
226
|
-
jsonResponse =
|
|
227
|
-
typeof res.result === 'string'
|
|
228
|
-
? parseWeboutResponse(res.result, apiUrl)
|
|
229
|
-
: res.result
|
|
230
|
-
break
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
const responseObject = appendExtraResponseAttributes(
|
|
235
|
-
{ result: jsonResponse, log: res.log },
|
|
236
|
-
extraResponseAttributes
|
|
237
|
-
)
|
|
238
|
-
resolve(responseObject)
|
|
239
|
-
})
|
|
240
|
-
.catch(async (e: Error) => {
|
|
241
|
-
if (e instanceof JobExecutionError) {
|
|
242
|
-
this.requestClient!.appendRequest(e, sasJob, config.debug)
|
|
243
|
-
reject(new ErrorResponse(e?.message, e))
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
if (e instanceof LoginRequiredError) {
|
|
247
|
-
if (!loginRequiredCallback) {
|
|
248
|
-
reject(
|
|
249
|
-
new ErrorResponse(
|
|
250
|
-
'Request is not authenticated. Make sure .env file exists with valid credentials.',
|
|
251
|
-
e
|
|
252
|
-
)
|
|
253
|
-
)
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
this.appendWaitingRequest(() => {
|
|
257
|
-
return this.execute(
|
|
258
|
-
sasJob,
|
|
259
|
-
data,
|
|
260
|
-
config,
|
|
261
|
-
loginRequiredCallback,
|
|
262
|
-
authConfig,
|
|
263
|
-
extraResponseAttributes
|
|
264
|
-
).then(
|
|
265
|
-
(res: any) => {
|
|
266
|
-
resolve(res)
|
|
267
|
-
},
|
|
268
|
-
(err: any) => {
|
|
269
|
-
reject(err)
|
|
270
|
-
}
|
|
271
|
-
)
|
|
272
|
-
})
|
|
273
|
-
|
|
274
|
-
if (loginCallback) await loginCallback()
|
|
275
|
-
} else reject(new ErrorResponse(e?.message, e))
|
|
276
|
-
})
|
|
277
|
-
})
|
|
278
|
-
|
|
279
|
-
return requestPromise
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
protected getRequestParams(config: any): any {
|
|
283
|
-
const requestParams = super.getRequestParams(config)
|
|
284
|
-
|
|
285
|
-
// FIXME(viya - possible issue with default debug flags)
|
|
286
|
-
// runAsTask on Viya: use _debug=128 (not 131) and omit _omittextlog
|
|
287
|
-
if (
|
|
288
|
-
config.debug &&
|
|
289
|
-
config.serverType === ServerType.SasViya &&
|
|
290
|
-
config.runAsTask === true
|
|
291
|
-
) {
|
|
292
|
-
requestParams['_debug'] = 128
|
|
293
|
-
delete requestParams['_omittextlog']
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
return requestParams
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
private async getJobUri(sasJob: string) {
|
|
300
|
-
if (!this.sasViyaApiClient) return ''
|
|
301
|
-
let uri = ''
|
|
302
|
-
|
|
303
|
-
// sasJob arrives with the appLoc already applied, so the folder is
|
|
304
|
-
// everything before the last segment. Reading the first two segments only
|
|
305
|
-
// would look up folder 'services' and job 'common' for a job like
|
|
306
|
-
// services/common/configure.
|
|
307
|
-
const folderPathParts = sasJob.split('/')
|
|
308
|
-
const jobName = folderPathParts.pop() || ''
|
|
309
|
-
const folderPath = folderPathParts.join('/')
|
|
310
|
-
|
|
311
|
-
if (!jobName) {
|
|
312
|
-
throw new Error('Job name is empty, null or undefined.')
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
const locJobs = await this.sasViyaApiClient.getJobsInFolder(folderPath)
|
|
316
|
-
if (locJobs) {
|
|
317
|
-
const job = locJobs.find(
|
|
318
|
-
(el: any) => el.name === jobName && el.contentType === 'jobDefinition'
|
|
319
|
-
)
|
|
320
|
-
if (job) {
|
|
321
|
-
uri = job.uri
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
return uri
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
function addDummyFile(formData: NodeFormData | FormData) {
|
|
329
|
-
if (isNode()) {
|
|
330
|
-
;(formData as NodeFormData).append('_sasjs_noop', '', {
|
|
331
|
-
filename: '_sasjs_noop.txt',
|
|
332
|
-
contentType: 'text/plain'
|
|
333
|
-
})
|
|
334
|
-
} else {
|
|
335
|
-
;(formData as FormData).append(
|
|
336
|
-
'_sasjs_noop',
|
|
337
|
-
new Blob([''], { type: 'text/plain' }),
|
|
338
|
-
'_sasjs_noop.txt'
|
|
339
|
-
)
|
|
340
|
-
}
|
|
341
|
-
}
|