@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.
- 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 +41 -15
- 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,50 +0,0 @@
|
|
|
1
|
-
import NodeFormData from 'form-data'
|
|
2
|
-
import { convertToCSV, isFormatsTable } from '../utils/convertToCsv'
|
|
3
|
-
import { splitChunks } from '../utils/splitChunks'
|
|
4
|
-
|
|
5
|
-
export const generateTableUploadForm = (
|
|
6
|
-
formData: FormData | NodeFormData,
|
|
7
|
-
data: any
|
|
8
|
-
) => {
|
|
9
|
-
const sasjsTables = []
|
|
10
|
-
const requestParams: any = {}
|
|
11
|
-
let tableCounter = 0
|
|
12
|
-
|
|
13
|
-
for (const tableName in data) {
|
|
14
|
-
if (
|
|
15
|
-
isFormatsTable(tableName) &&
|
|
16
|
-
Object.keys(data).includes(tableName.replace(/^\$/, ''))
|
|
17
|
-
) {
|
|
18
|
-
continue
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
tableCounter++
|
|
22
|
-
|
|
23
|
-
// Formats table should not be sent as part of 'sasjs_tables'
|
|
24
|
-
if (!isFormatsTable(tableName)) sasjsTables.push(tableName)
|
|
25
|
-
|
|
26
|
-
const csv = convertToCSV(data, tableName)
|
|
27
|
-
|
|
28
|
-
if (csv === 'ERROR: LARGE STRING LENGTH') {
|
|
29
|
-
throw new Error(
|
|
30
|
-
'The max length of a string value in SASjs is 32765 characters.'
|
|
31
|
-
)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// if csv has length more then 16k, send in chunks
|
|
35
|
-
if (csv.length > 16000) {
|
|
36
|
-
const csvChunks = splitChunks(csv)
|
|
37
|
-
|
|
38
|
-
// append chunks to form data with same key
|
|
39
|
-
csvChunks.map((chunk) => {
|
|
40
|
-
formData.append(`sasjs${tableCounter}data`, chunk)
|
|
41
|
-
})
|
|
42
|
-
} else {
|
|
43
|
-
requestParams[`sasjs${tableCounter}data`] = csv
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
requestParams['sasjs_tables'] = sasjsTables.join(' ')
|
|
48
|
-
|
|
49
|
-
return { formData, requestParams }
|
|
50
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import SASjs from './SASjs'
|
|
2
|
-
export * from './types'
|
|
3
|
-
export * from './types/errors'
|
|
4
|
-
export * from './SASViyaApiClient'
|
|
5
|
-
export * from './SAS9ApiClient'
|
|
6
|
-
export * from './SASjsApiClient'
|
|
7
|
-
export * from './request/SasjsRequestClient'
|
|
8
|
-
export type { OnTokensRefreshed } from './auth/getTokens'
|
|
9
|
-
export default SASjs
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { AuthConfig, ServerType } from '@sasjs/utils/types'
|
|
2
|
-
import { SASViyaApiClient } from '../SASViyaApiClient'
|
|
3
|
-
import {
|
|
4
|
-
ErrorResponse,
|
|
5
|
-
ComputeJobExecutionError,
|
|
6
|
-
LoginRequiredError
|
|
7
|
-
} from '../types/errors'
|
|
8
|
-
import { BaseJobExecutor } from './JobExecutor'
|
|
9
|
-
|
|
10
|
-
export class ComputeJobExecutor extends BaseJobExecutor {
|
|
11
|
-
constructor(
|
|
12
|
-
serverUrl: string,
|
|
13
|
-
private sasViyaApiClient: SASViyaApiClient
|
|
14
|
-
) {
|
|
15
|
-
super(serverUrl, ServerType.SasViya)
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
async execute(
|
|
19
|
-
sasJob: string,
|
|
20
|
-
data: any,
|
|
21
|
-
config: any,
|
|
22
|
-
loginRequiredCallback?: any,
|
|
23
|
-
authConfig?: AuthConfig
|
|
24
|
-
) {
|
|
25
|
-
const loginCallback = loginRequiredCallback || (() => Promise.resolve())
|
|
26
|
-
const waitForResult = true
|
|
27
|
-
const expectWebout = true
|
|
28
|
-
|
|
29
|
-
const requestPromise = new Promise((resolve, reject) => {
|
|
30
|
-
this.sasViyaApiClient
|
|
31
|
-
?.executeComputeJob(
|
|
32
|
-
sasJob,
|
|
33
|
-
config.contextName,
|
|
34
|
-
config.debug,
|
|
35
|
-
data,
|
|
36
|
-
authConfig,
|
|
37
|
-
waitForResult,
|
|
38
|
-
expectWebout
|
|
39
|
-
)
|
|
40
|
-
.then((response) => {
|
|
41
|
-
this.sasViyaApiClient.appendRequest(response, sasJob, config.debug)
|
|
42
|
-
resolve(response.result)
|
|
43
|
-
})
|
|
44
|
-
.catch(async (e: Error) => {
|
|
45
|
-
if (e instanceof ComputeJobExecutionError) {
|
|
46
|
-
this.sasViyaApiClient.appendRequest(e, sasJob, config.debug)
|
|
47
|
-
reject(new ErrorResponse(e?.message, e))
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (e instanceof LoginRequiredError) {
|
|
51
|
-
this.appendWaitingRequest(() => {
|
|
52
|
-
return this.execute(
|
|
53
|
-
sasJob,
|
|
54
|
-
data,
|
|
55
|
-
config,
|
|
56
|
-
loginRequiredCallback
|
|
57
|
-
).then(
|
|
58
|
-
(res: any) => {
|
|
59
|
-
resolve(res)
|
|
60
|
-
},
|
|
61
|
-
(err: any) => {
|
|
62
|
-
reject(err)
|
|
63
|
-
}
|
|
64
|
-
)
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
await loginCallback()
|
|
68
|
-
} else {
|
|
69
|
-
reject(new ErrorResponse(e?.message, e))
|
|
70
|
-
}
|
|
71
|
-
})
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
return requestPromise
|
|
75
|
-
}
|
|
76
|
-
}
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getValidJson,
|
|
3
|
-
parseSasViyaDebugResponse,
|
|
4
|
-
parseWeboutResponse
|
|
5
|
-
} from '../utils'
|
|
6
|
-
import { UploadFile } from '../types/UploadFile'
|
|
7
|
-
import {
|
|
8
|
-
ErrorResponse,
|
|
9
|
-
JobExecutionError,
|
|
10
|
-
LoginRequiredError
|
|
11
|
-
} from '../types/errors'
|
|
12
|
-
import { RequestClient } from '../request/RequestClient'
|
|
13
|
-
import { ServerType } from '@sasjs/utils/types'
|
|
14
|
-
import { BaseJobExecutor } from './JobExecutor'
|
|
15
|
-
|
|
16
|
-
interface dataFileUpload {
|
|
17
|
-
files: UploadFile[]
|
|
18
|
-
params: { [key: string]: any } | null
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export class FileUploader extends BaseJobExecutor {
|
|
22
|
-
constructor(
|
|
23
|
-
serverUrl: string,
|
|
24
|
-
serverType: ServerType,
|
|
25
|
-
private jobsPath: string,
|
|
26
|
-
private requestClient: RequestClient
|
|
27
|
-
) {
|
|
28
|
-
super(serverUrl, serverType)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
public async execute(
|
|
32
|
-
sasJob: string,
|
|
33
|
-
data: any,
|
|
34
|
-
config: any,
|
|
35
|
-
loginRequiredCallback?: any
|
|
36
|
-
) {
|
|
37
|
-
const { files, params }: dataFileUpload = data
|
|
38
|
-
const loginCallback = loginRequiredCallback || (() => Promise.resolve())
|
|
39
|
-
|
|
40
|
-
if (!files?.length)
|
|
41
|
-
throw new ErrorResponse('At least one file must be provided.')
|
|
42
|
-
|
|
43
|
-
if (!sasJob || sasJob === '')
|
|
44
|
-
throw new ErrorResponse('sasJob must be provided.')
|
|
45
|
-
|
|
46
|
-
let paramsString = ''
|
|
47
|
-
|
|
48
|
-
for (let param in params)
|
|
49
|
-
if (params.hasOwnProperty(param))
|
|
50
|
-
paramsString += `&${param}=${params[param]}`
|
|
51
|
-
|
|
52
|
-
const program = config.appLoc
|
|
53
|
-
? config.appLoc.replace(/\/?$/, '/') + sasJob.replace(/^\//, '')
|
|
54
|
-
: sasJob
|
|
55
|
-
const uploadUrl = `${this.jobsPath}/?${
|
|
56
|
-
'_program=' + program
|
|
57
|
-
}${paramsString}`
|
|
58
|
-
|
|
59
|
-
const formData = new FormData()
|
|
60
|
-
|
|
61
|
-
for (let file of files) {
|
|
62
|
-
formData.append('file', file.file, file.fileName)
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const csrfToken = this.requestClient.getCsrfToken('file')
|
|
66
|
-
if (csrfToken) formData.append('_csrf', csrfToken.value)
|
|
67
|
-
if (config.debug) formData.append('_debug', '131')
|
|
68
|
-
if (config.serverType === ServerType.SasViya && config.contextName)
|
|
69
|
-
formData.append('_contextname', config.contextName)
|
|
70
|
-
|
|
71
|
-
const headers = {
|
|
72
|
-
'cache-control': 'no-cache',
|
|
73
|
-
Accept: '*/*',
|
|
74
|
-
'Content-Type': 'text/plain'
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// currently only web approach is supported for file upload
|
|
78
|
-
// therefore log is part of response with debug enabled and must be parsed
|
|
79
|
-
const requestPromise = new Promise((resolve, reject) => {
|
|
80
|
-
this.requestClient
|
|
81
|
-
.post(uploadUrl, formData, undefined, 'application/json', headers)
|
|
82
|
-
.then(async (res: any) => {
|
|
83
|
-
this.requestClient.appendRequest(res, sasJob, config.debug)
|
|
84
|
-
|
|
85
|
-
let jsonResponse = res.result
|
|
86
|
-
|
|
87
|
-
if (config.debug) {
|
|
88
|
-
switch (this.serverType) {
|
|
89
|
-
case ServerType.SasViya:
|
|
90
|
-
jsonResponse = await parseSasViyaDebugResponse(
|
|
91
|
-
res.result,
|
|
92
|
-
this.requestClient,
|
|
93
|
-
config.serverUrl
|
|
94
|
-
)
|
|
95
|
-
|
|
96
|
-
break
|
|
97
|
-
case ServerType.Sas9:
|
|
98
|
-
jsonResponse =
|
|
99
|
-
typeof res.result === 'string'
|
|
100
|
-
? parseWeboutResponse(res.result, uploadUrl)
|
|
101
|
-
: res.result
|
|
102
|
-
|
|
103
|
-
break
|
|
104
|
-
case ServerType.Sasjs:
|
|
105
|
-
jsonResponse =
|
|
106
|
-
typeof res.result === 'string'
|
|
107
|
-
? getValidJson(res.result)
|
|
108
|
-
: res.result
|
|
109
|
-
|
|
110
|
-
break
|
|
111
|
-
}
|
|
112
|
-
} else {
|
|
113
|
-
jsonResponse =
|
|
114
|
-
typeof res.result === 'string'
|
|
115
|
-
? getValidJson(res.result)
|
|
116
|
-
: res.result
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
resolve(jsonResponse)
|
|
120
|
-
})
|
|
121
|
-
.catch(async (e: Error) => {
|
|
122
|
-
if (e instanceof JobExecutionError) {
|
|
123
|
-
this.requestClient!.appendRequest(e, sasJob, config.debug)
|
|
124
|
-
reject(new ErrorResponse(e?.message, e))
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
if (e instanceof LoginRequiredError) {
|
|
128
|
-
this.appendWaitingRequest(() => {
|
|
129
|
-
return this.execute(
|
|
130
|
-
sasJob,
|
|
131
|
-
data,
|
|
132
|
-
config,
|
|
133
|
-
loginRequiredCallback
|
|
134
|
-
).then(
|
|
135
|
-
(res: any) => {
|
|
136
|
-
resolve(res)
|
|
137
|
-
},
|
|
138
|
-
(err: any) => {
|
|
139
|
-
reject(err)
|
|
140
|
-
}
|
|
141
|
-
)
|
|
142
|
-
})
|
|
143
|
-
|
|
144
|
-
await loginCallback()
|
|
145
|
-
} else {
|
|
146
|
-
reject(new ErrorResponse('File upload request failed.', e))
|
|
147
|
-
}
|
|
148
|
-
})
|
|
149
|
-
})
|
|
150
|
-
return requestPromise
|
|
151
|
-
}
|
|
152
|
-
}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { AuthConfig, ServerType } from '@sasjs/utils/types'
|
|
2
|
-
import { SASViyaApiClient } from '../SASViyaApiClient'
|
|
3
|
-
import {
|
|
4
|
-
ErrorResponse,
|
|
5
|
-
JobExecutionError,
|
|
6
|
-
LoginRequiredError
|
|
7
|
-
} from '../types/errors'
|
|
8
|
-
import { ExtraResponseAttributes } from '@sasjs/utils/types'
|
|
9
|
-
import { BaseJobExecutor } from './JobExecutor'
|
|
10
|
-
import { appendExtraResponseAttributes } from '../utils'
|
|
11
|
-
|
|
12
|
-
export class JesJobExecutor extends BaseJobExecutor {
|
|
13
|
-
constructor(
|
|
14
|
-
serverUrl: string,
|
|
15
|
-
private sasViyaApiClient: SASViyaApiClient
|
|
16
|
-
) {
|
|
17
|
-
super(serverUrl, ServerType.SasViya)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
async execute(
|
|
21
|
-
sasJob: string,
|
|
22
|
-
data: any,
|
|
23
|
-
config: any,
|
|
24
|
-
loginRequiredCallback?: any,
|
|
25
|
-
authConfig?: AuthConfig,
|
|
26
|
-
extraResponseAttributes: ExtraResponseAttributes[] = []
|
|
27
|
-
) {
|
|
28
|
-
const loginCallback = loginRequiredCallback || (() => Promise.resolve())
|
|
29
|
-
|
|
30
|
-
const requestPromise = new Promise((resolve, reject) => {
|
|
31
|
-
this.sasViyaApiClient
|
|
32
|
-
?.executeJob(sasJob, config.contextName, config.debug, data, authConfig)
|
|
33
|
-
.then((response: any) => {
|
|
34
|
-
this.sasViyaApiClient.appendRequest(response, sasJob, config.debug)
|
|
35
|
-
|
|
36
|
-
const responseObject = appendExtraResponseAttributes(
|
|
37
|
-
response,
|
|
38
|
-
extraResponseAttributes
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
resolve(responseObject)
|
|
42
|
-
})
|
|
43
|
-
.catch(async (e: Error) => {
|
|
44
|
-
if (e instanceof JobExecutionError) {
|
|
45
|
-
this.sasViyaApiClient.appendRequest(e, sasJob, config.debug)
|
|
46
|
-
|
|
47
|
-
reject(new ErrorResponse(e?.message, e))
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (e instanceof LoginRequiredError) {
|
|
51
|
-
this.appendWaitingRequest(() => {
|
|
52
|
-
return this.execute(
|
|
53
|
-
sasJob,
|
|
54
|
-
data,
|
|
55
|
-
config,
|
|
56
|
-
loginRequiredCallback,
|
|
57
|
-
authConfig,
|
|
58
|
-
extraResponseAttributes
|
|
59
|
-
).then(
|
|
60
|
-
(res: any) => {
|
|
61
|
-
resolve(res)
|
|
62
|
-
},
|
|
63
|
-
(err: any) => {
|
|
64
|
-
reject(err)
|
|
65
|
-
}
|
|
66
|
-
)
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
await loginCallback()
|
|
70
|
-
} else {
|
|
71
|
-
reject(new ErrorResponse(e?.message, e))
|
|
72
|
-
}
|
|
73
|
-
})
|
|
74
|
-
})
|
|
75
|
-
|
|
76
|
-
return requestPromise
|
|
77
|
-
}
|
|
78
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { AuthConfig, ServerType } from '@sasjs/utils/types'
|
|
2
|
-
import { ExtraResponseAttributes } from '@sasjs/utils/types'
|
|
3
|
-
import { asyncForEach, isRelativePath } from '../utils'
|
|
4
|
-
|
|
5
|
-
export type ExecuteFunction = () => Promise<any>
|
|
6
|
-
|
|
7
|
-
export interface JobExecutor {
|
|
8
|
-
execute: (
|
|
9
|
-
sasJob: string,
|
|
10
|
-
data: any,
|
|
11
|
-
config: any,
|
|
12
|
-
loginRequiredCallback?: any,
|
|
13
|
-
authConfig?: AuthConfig,
|
|
14
|
-
extraResponseAttributes?: ExtraResponseAttributes[]
|
|
15
|
-
) => Promise<any>
|
|
16
|
-
resendWaitingRequests: () => Promise<void>
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export abstract class BaseJobExecutor implements JobExecutor {
|
|
20
|
-
constructor(
|
|
21
|
-
protected serverUrl: string,
|
|
22
|
-
protected serverType: ServerType
|
|
23
|
-
) {}
|
|
24
|
-
|
|
25
|
-
private waitingRequests: ExecuteFunction[] = []
|
|
26
|
-
|
|
27
|
-
abstract execute(
|
|
28
|
-
sasJob: string,
|
|
29
|
-
data: any,
|
|
30
|
-
config: any,
|
|
31
|
-
loginRequiredCallback?: any,
|
|
32
|
-
authConfig?: AuthConfig | undefined,
|
|
33
|
-
extraResponseAttributes?: ExtraResponseAttributes[]
|
|
34
|
-
): Promise<any>
|
|
35
|
-
|
|
36
|
-
resendWaitingRequests = async () => {
|
|
37
|
-
await asyncForEach(
|
|
38
|
-
this.waitingRequests,
|
|
39
|
-
async (waitingRequest: ExecuteFunction) => {
|
|
40
|
-
await waitingRequest()
|
|
41
|
-
}
|
|
42
|
-
)
|
|
43
|
-
|
|
44
|
-
this.waitingRequests = []
|
|
45
|
-
return
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
protected appendWaitingRequest(request: ExecuteFunction) {
|
|
49
|
-
this.waitingRequests.push(request)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
protected getRequestParams(config: any): any {
|
|
53
|
-
const requestParams: any = {}
|
|
54
|
-
|
|
55
|
-
if (config.debug) {
|
|
56
|
-
requestParams['_omittextlog'] = 'false'
|
|
57
|
-
requestParams['_omitSessionResults'] = 'false'
|
|
58
|
-
requestParams['_debug'] = 131
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return requestParams
|
|
62
|
-
}
|
|
63
|
-
}
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import * as https from 'https'
|
|
2
|
-
import { ServerType } from '@sasjs/utils/types'
|
|
3
|
-
import NodeFormData from 'form-data'
|
|
4
|
-
import { ErrorResponse } from '../types/errors'
|
|
5
|
-
import { convertToCSV, isRelativePath } from '../utils'
|
|
6
|
-
import { BaseJobExecutor } from './JobExecutor'
|
|
7
|
-
import { Sas9RequestClient } from '../request/Sas9RequestClient'
|
|
8
|
-
import { RequestClient } from '../request/RequestClient'
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Job executor for SAS9 servers for use in Node.js environments.
|
|
12
|
-
* Initiates login with the provided username and password from the config
|
|
13
|
-
* The cookies are stored in the request client and used in subsequent
|
|
14
|
-
* job execution requests.
|
|
15
|
-
*/
|
|
16
|
-
export class Sas9JobExecutor extends BaseJobExecutor {
|
|
17
|
-
private sas9RequestClient: Sas9RequestClient
|
|
18
|
-
constructor(
|
|
19
|
-
serverUrl: string,
|
|
20
|
-
serverType: ServerType,
|
|
21
|
-
private jobsPath: string,
|
|
22
|
-
private requestClient: RequestClient,
|
|
23
|
-
httpsAgentOptions?: https.AgentOptions
|
|
24
|
-
) {
|
|
25
|
-
super(serverUrl, serverType)
|
|
26
|
-
this.sas9RequestClient = new Sas9RequestClient(serverUrl, httpsAgentOptions)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
async execute(sasJob: string, data: any, config: any) {
|
|
30
|
-
const program = isRelativePath(sasJob)
|
|
31
|
-
? config.appLoc
|
|
32
|
-
? config.appLoc.replace(/\/?$/, '/') + sasJob.replace(/^\//, '')
|
|
33
|
-
: sasJob
|
|
34
|
-
: sasJob
|
|
35
|
-
let apiUrl = `${config.serverUrl}${this.jobsPath}?${'_program=' + program}`
|
|
36
|
-
apiUrl = `${apiUrl}${
|
|
37
|
-
config.username && config.password
|
|
38
|
-
? '&_username=' + config.username + '&_password=' + config.password
|
|
39
|
-
: ''
|
|
40
|
-
}`
|
|
41
|
-
|
|
42
|
-
apiUrl = `${apiUrl}${config.debug ? '&_debug=131' : ''}`
|
|
43
|
-
|
|
44
|
-
let requestParams = {
|
|
45
|
-
...this.getRequestParams(config)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
let formData = new NodeFormData()
|
|
49
|
-
|
|
50
|
-
if (data) {
|
|
51
|
-
try {
|
|
52
|
-
formData = generateFileUploadForm(formData, data)
|
|
53
|
-
} catch (e: any) {
|
|
54
|
-
return Promise.reject(new ErrorResponse(e?.message, e))
|
|
55
|
-
}
|
|
56
|
-
} else {
|
|
57
|
-
data = ''
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
for (const key in requestParams) {
|
|
61
|
-
if (requestParams.hasOwnProperty(key)) {
|
|
62
|
-
formData.append(key, requestParams[key])
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
await this.sas9RequestClient.login(
|
|
67
|
-
config.username,
|
|
68
|
-
config.password,
|
|
69
|
-
this.jobsPath
|
|
70
|
-
)
|
|
71
|
-
|
|
72
|
-
const contentType =
|
|
73
|
-
data && Object.keys(data).length
|
|
74
|
-
? 'multipart/form-data; boundary=' + (formData as any)._boundary
|
|
75
|
-
: 'text/plain'
|
|
76
|
-
|
|
77
|
-
const requestPromise = new Promise((resolve, reject) =>
|
|
78
|
-
this.sas9RequestClient!.post(apiUrl, formData, undefined, contentType, {
|
|
79
|
-
Accept: '*/*',
|
|
80
|
-
Connection: 'Keep-Alive'
|
|
81
|
-
})
|
|
82
|
-
.then((res: any) => {
|
|
83
|
-
// appending response to requests array that will be used for requests history reference
|
|
84
|
-
this.requestClient!.appendRequest(res, sasJob, config.debug)
|
|
85
|
-
resolve(res)
|
|
86
|
-
})
|
|
87
|
-
.catch((err: any) => {
|
|
88
|
-
// by default error string is equal to actual error object
|
|
89
|
-
let errString = err
|
|
90
|
-
|
|
91
|
-
// if error object contains non empty result attribute, set result to errString
|
|
92
|
-
if (err.result && err.result !== '') errString = err.result
|
|
93
|
-
// if there's no result but error message, set error message to errString
|
|
94
|
-
else if (err.message) errString = err.message
|
|
95
|
-
|
|
96
|
-
// appending error to requests array that will be used for requests history reference
|
|
97
|
-
this.requestClient!.appendRequest(errString, sasJob, config.debug)
|
|
98
|
-
reject(new ErrorResponse(err?.message, err))
|
|
99
|
-
})
|
|
100
|
-
)
|
|
101
|
-
|
|
102
|
-
return requestPromise
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
protected getRequestParams(config: any): any {
|
|
106
|
-
const requestParams: any = {}
|
|
107
|
-
|
|
108
|
-
if (config.debug) {
|
|
109
|
-
requestParams['_debug'] = 131
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return requestParams
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
const generateFileUploadForm = (
|
|
117
|
-
formData: NodeFormData,
|
|
118
|
-
data: any
|
|
119
|
-
): NodeFormData => {
|
|
120
|
-
for (const tableName in data) {
|
|
121
|
-
const name = tableName
|
|
122
|
-
const csv = convertToCSV(data, tableName)
|
|
123
|
-
|
|
124
|
-
if (csv === 'ERROR: LARGE STRING LENGTH') {
|
|
125
|
-
throw new Error(
|
|
126
|
-
'The max length of a string value in SASjs is 32765 characters.'
|
|
127
|
-
)
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
formData.append(name, csv, {
|
|
131
|
-
filename: `${name}.csv`,
|
|
132
|
-
contentType: 'application/csv'
|
|
133
|
-
})
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
return formData
|
|
137
|
-
}
|