@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
package/node/SASjs.d.ts
DELETED
|
@@ -1,387 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { SASjsConfig, UploadFile, EditContextInput, PollOptions, VerboseMode, LoginOptions, LoginResult, ExecutionQuery, Tables } from './types';
|
|
3
|
-
import { SASViyaApiClient } from './SASViyaApiClient';
|
|
4
|
-
import { SASjsAuthResponse } from './SASjsApiClient';
|
|
5
|
-
import { OnTokensRefreshed } from './auth/getTokens';
|
|
6
|
-
import { MacroVar, AuthConfig, ExtraResponseAttributes, SasAuthResponse, AuthConfigSas9 } from '@sasjs/utils/types';
|
|
7
|
-
import { AxiosResponse, AxiosError } from 'axios';
|
|
8
|
-
interface ExecuteScriptParams {
|
|
9
|
-
linesOfCode: string[];
|
|
10
|
-
fileName?: string;
|
|
11
|
-
contextName?: string;
|
|
12
|
-
runTime?: string;
|
|
13
|
-
authConfig?: AuthConfig;
|
|
14
|
-
authConfigSas9?: AuthConfigSas9;
|
|
15
|
-
debug?: boolean;
|
|
16
|
-
onTokensRefreshed?: OnTokensRefreshed;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* SASjs is a JavaScript adapter for SAS.
|
|
20
|
-
*
|
|
21
|
-
*/
|
|
22
|
-
export default class SASjs {
|
|
23
|
-
private sasjsConfig;
|
|
24
|
-
private jobsPath;
|
|
25
|
-
private sasViyaApiClient;
|
|
26
|
-
private sas9ApiClient;
|
|
27
|
-
private sasJSApiClient;
|
|
28
|
-
private fileUploader;
|
|
29
|
-
private authManager;
|
|
30
|
-
private requestClient;
|
|
31
|
-
private webJobExecutor;
|
|
32
|
-
private sasjsJobExecutor;
|
|
33
|
-
private computeJobExecutor;
|
|
34
|
-
private jesJobExecutor;
|
|
35
|
-
private sas9JobExecutor;
|
|
36
|
-
constructor(config?: Partial<SASjsConfig>);
|
|
37
|
-
getCsrfToken(type?: 'general' | 'file'): import("./types").CsrfToken | undefined;
|
|
38
|
-
/**
|
|
39
|
-
* Executes code on a SAS server.
|
|
40
|
-
* @param linesOfCode - lines of code to run.
|
|
41
|
-
* @param fileName - (required for server type sas viya) name of the file to run. It will be converted to path to the file being submitted for execution.
|
|
42
|
-
* @param contextName - (required for server type sas viya) context name on which code will be run on the server.
|
|
43
|
-
* @param runTime - (required for server type sasjs) a string to represent runTime for code execution.
|
|
44
|
-
* @param authConfig - (optional) a valid client, secret, refresh and access tokens that are authorised to execute scripts.
|
|
45
|
-
* @param authConfigSas9 - (required for server type sas9) a valid username and password that are authorised to execute scripts.
|
|
46
|
-
* @param debug - (optional) if true, global debug config will be overriden
|
|
47
|
-
* @param onTokensRefreshed - (optional, SAS Viya only) callback invoked with the rotated token pair after a successful internal refresh, so consumers that persist tokens can store the new pair.
|
|
48
|
-
*/
|
|
49
|
-
executeScript({ linesOfCode, fileName, contextName, runTime, authConfig, authConfigSas9, debug, onTokensRefreshed }: ExecuteScriptParams): Promise<any>;
|
|
50
|
-
/**
|
|
51
|
-
* Executes job on SASJS server.
|
|
52
|
-
* @param query - an object containing job path and debug level.
|
|
53
|
-
* @param appLoc - an application path.
|
|
54
|
-
* @param authConfig - an object for authentication.
|
|
55
|
-
* @returns a promise that resolves into job execution result and log.
|
|
56
|
-
*/
|
|
57
|
-
executeJob(query: ExecutionQuery, appLoc: string, authConfig?: AuthConfig): Promise<{
|
|
58
|
-
result: any;
|
|
59
|
-
log: any;
|
|
60
|
-
} | undefined>;
|
|
61
|
-
/**
|
|
62
|
-
* Gets compute contexts.
|
|
63
|
-
* @param accessToken - an access token for an authorised user.
|
|
64
|
-
*/
|
|
65
|
-
getComputeContexts(accessToken: string): Promise<{
|
|
66
|
-
createdBy: any;
|
|
67
|
-
id: any;
|
|
68
|
-
name: any;
|
|
69
|
-
version: any;
|
|
70
|
-
attributes: {};
|
|
71
|
-
}[]>;
|
|
72
|
-
/**
|
|
73
|
-
* Gets launcher contexts.
|
|
74
|
-
* @param accessToken - an access token for an authorised user.
|
|
75
|
-
*/
|
|
76
|
-
getLauncherContexts(accessToken: string): Promise<{
|
|
77
|
-
createdBy: any;
|
|
78
|
-
id: any;
|
|
79
|
-
name: any;
|
|
80
|
-
version: any;
|
|
81
|
-
attributes: {};
|
|
82
|
-
}[]>;
|
|
83
|
-
/**
|
|
84
|
-
* Gets default(system) launcher contexts.
|
|
85
|
-
*/
|
|
86
|
-
getDefaultComputeContexts(): string[];
|
|
87
|
-
/**
|
|
88
|
-
* Gets executable compute contexts.
|
|
89
|
-
* @param authConfig - an access token, refresh token, client and secret for an authorised user.
|
|
90
|
-
*/
|
|
91
|
-
getExecutableContexts(authConfig: AuthConfig): Promise<any[]>;
|
|
92
|
-
/**
|
|
93
|
-
* Creates a compute context on the given server.
|
|
94
|
-
* @param contextName - the name of the context to be created.
|
|
95
|
-
* @param launchContextName - the name of the launcher context used by the compute service.
|
|
96
|
-
* @param sharedAccountId - the ID of the account to run the servers for this context as.
|
|
97
|
-
* @param autoExecLines - the lines of code to execute during session initialization.
|
|
98
|
-
* @param accessToken - an access token for an authorised user.
|
|
99
|
-
* @param authorisedUsers - an optional list of authorised user IDs.
|
|
100
|
-
*/
|
|
101
|
-
createComputeContext(contextName: string, launchContextName: string, sharedAccountId: string, autoExecLines: string[], accessToken: string, authorisedUsers?: string[]): Promise<import("./types").Context>;
|
|
102
|
-
/**
|
|
103
|
-
* Creates a launcher context on the given server.
|
|
104
|
-
* @param contextName - the name of the context to be created.
|
|
105
|
-
* @param description - the description of the context to be created.
|
|
106
|
-
* @param launchType - launch type of the context to be created.
|
|
107
|
-
* @param accessToken - an access token for an authorised user.
|
|
108
|
-
*/
|
|
109
|
-
createLauncherContext(contextName: string, description: string, launchType: string, accessToken: string): Promise<import("./types").Context>;
|
|
110
|
-
/**
|
|
111
|
-
* Updates a compute context on the given server.
|
|
112
|
-
* @param contextName - the original name of the context to be deleted.
|
|
113
|
-
* @param editedContext - an object with the properties to be updated.
|
|
114
|
-
* @param accessToken - an access token for an authorised user.
|
|
115
|
-
*/
|
|
116
|
-
editComputeContext(contextName: string, editedContext: EditContextInput, accessToken?: string): Promise<{
|
|
117
|
-
result: import("./types").Context;
|
|
118
|
-
etag: string;
|
|
119
|
-
}>;
|
|
120
|
-
/**
|
|
121
|
-
* Deletes a compute context on the given server.
|
|
122
|
-
* @param contextName - the name of the context to be deleted.
|
|
123
|
-
* @param accessToken - an access token for an authorised user.
|
|
124
|
-
*/
|
|
125
|
-
deleteComputeContext(contextName: string, accessToken?: string): Promise<{
|
|
126
|
-
result: import("./types").Context;
|
|
127
|
-
etag: string;
|
|
128
|
-
}>;
|
|
129
|
-
/**
|
|
130
|
-
* Returns a JSON representation of a compute context.
|
|
131
|
-
* @example: { "createdBy": "admin", "links": [...], "id": "ID", "version": 2, "name": "context1" }
|
|
132
|
-
* @param contextName - the name of the context to return.
|
|
133
|
-
* @param accessToken - an access token for an authorised user.
|
|
134
|
-
*/
|
|
135
|
-
getComputeContextByName(contextName: string, accessToken?: string): Promise<import("./types").Context>;
|
|
136
|
-
/**
|
|
137
|
-
* Returns a JSON representation of a compute context.
|
|
138
|
-
* @param contextId - an id of the context to return.
|
|
139
|
-
* @param accessToken - an access token for an authorised user.
|
|
140
|
-
*/
|
|
141
|
-
getComputeContextById(contextId: string, accessToken?: string): Promise<import("./types").ContextAllAttributes>;
|
|
142
|
-
createSession(contextName: string, accessToken: string): Promise<import("./types").Session>;
|
|
143
|
-
/**
|
|
144
|
-
* Creates a folder in the logical SAS folder tree
|
|
145
|
-
* @param folderName - name of the folder to be created.
|
|
146
|
-
* @param parentFolderPath - the full path (eg `/Public/example/myFolder`) of the parent folder.
|
|
147
|
-
* @param parentFolderUri - the URI of the parent folder.
|
|
148
|
-
* @param accessToken - the access token to authorizing the request.
|
|
149
|
-
* @param sasApiClient - a client for interfacing with SAS API.
|
|
150
|
-
* @param isForced - flag that indicates if target folder already exists, it and all subfolders have to be deleted. Applicable for SAS VIYA only.
|
|
151
|
-
*/
|
|
152
|
-
createFolder(folderName: string, parentFolderPath: string, parentFolderUri?: string, accessToken?: string, sasApiClient?: SASViyaApiClient, isForced?: boolean): Promise<import("./types").Folder>;
|
|
153
|
-
/**
|
|
154
|
-
* Creates a file in the logical SAS folder tree
|
|
155
|
-
* @param fileName - name of the file to be created.
|
|
156
|
-
* @param content - content of the file to be created.
|
|
157
|
-
* @param parentFolderPath - the full path (eg `/Public/example/myFolder`) of the parent folder.
|
|
158
|
-
* @param parentFolderUri - the URI of the parent folder.
|
|
159
|
-
* @param accessToken - the access token to authorizing the request.
|
|
160
|
-
* @param sasApiClient - a client for interfacing with SAS API.
|
|
161
|
-
*/
|
|
162
|
-
createFile(fileName: string, content: Buffer, parentFolderPath: string, parentFolderUri?: string, accessToken?: string, sasApiClient?: SASViyaApiClient): Promise<import("./types").File>;
|
|
163
|
-
/**
|
|
164
|
-
* Fetches the file content for a file in the specified folder.
|
|
165
|
-
*
|
|
166
|
-
* @param folderPath - the full path to the folder containing the file. eg: /Public/folder1/folder2
|
|
167
|
-
* @param fileName - the name of the file in the `folderPath`
|
|
168
|
-
* @param accessToken - an access token for authorizing the request
|
|
169
|
-
*/
|
|
170
|
-
getFileContent(folderPath: string, fileName: string, accessToken?: string): Promise<string>;
|
|
171
|
-
/**
|
|
172
|
-
* Updates the file content for a file in the specified folder.
|
|
173
|
-
*
|
|
174
|
-
* @param folderPath - the full path to the folder containing the file. eg: /Public/folder1/folder2
|
|
175
|
-
* @param fileName - the name of the file in the `folderPath`
|
|
176
|
-
* @param content - the new content to be written to the file
|
|
177
|
-
* @param accessToken - an access token for authorizing the request
|
|
178
|
-
*/
|
|
179
|
-
updateFileContent(folderPath: string, fileName: string, content: string, accessToken?: string): Promise<import("./types/FileResource").FileResource>;
|
|
180
|
-
/**
|
|
181
|
-
* Fetches a folder from the SAS file system.
|
|
182
|
-
* @param folderPath - path of the folder to be fetched.
|
|
183
|
-
* @param accessToken - the access token to authorize the request.
|
|
184
|
-
*/
|
|
185
|
-
getFolder(folderPath: string, accessToken?: string): Promise<unknown>;
|
|
186
|
-
/**
|
|
187
|
-
* For performance (and in case of accidental error) the `deleteFolder` function does not actually delete the folder (and all its content and subfolder content). Instead the folder is simply moved to the recycle bin. Deletion time will be added to the folder name.
|
|
188
|
-
* @param folderPath - the full path (eg `/Public/example/deleteThis`) of the folder to be deleted.
|
|
189
|
-
* @param accessToken - an access token for authorizing the request.
|
|
190
|
-
*/
|
|
191
|
-
deleteFolder(folderPath: string, accessToken: string): Promise<import("./types").Folder | undefined>;
|
|
192
|
-
/**
|
|
193
|
-
* Lists children folders for given Viya folder.
|
|
194
|
-
* @param sourceFolder - the full path (eg `/Public/example/myFolder`) or URI of the source folder listed. Providing URI instead of path will save one extra request.
|
|
195
|
-
* @param accessToken - an access token for authorizing the request.
|
|
196
|
-
* @param returnDetails - when set to true, the function will return an array of objects with member details, otherwise it will return an array of member names.
|
|
197
|
-
*/
|
|
198
|
-
listFolder(sourceFolder: string, accessToken?: string, limit?: number, returnDetails?: boolean): Promise<any[] | undefined>;
|
|
199
|
-
/**
|
|
200
|
-
* Moves folder to a new location. The folder may be renamed at the same time.
|
|
201
|
-
* @param sourceFolder - the full path (eg `/Public/example/myFolder`) or URI of the source folder to be moved. Providing URI instead of path will save one extra request.
|
|
202
|
-
* @param targetParentFolder - the full path or URI of the _parent_ folder to which the `sourceFolder` will be moved (eg `/Public/newDestination`). To move a folder, a user has to have write permissions in targetParentFolder. Providing URI instead of path will save one extra request.
|
|
203
|
-
* @param targetFolderName - the name of the "moved" folder. If left blank, the original folder name will be used (eg `myFolder` in `/Public/newDestination/myFolder` for the example above). Optional field.
|
|
204
|
-
* @param accessToken - an access token for authorizing the request.
|
|
205
|
-
*/
|
|
206
|
-
moveFolder(sourceFolder: string, targetParentFolder: string, targetFolderName: string, accessToken: string): Promise<import("./types").Folder | undefined>;
|
|
207
|
-
createJobDefinition(jobName: string, code: string, parentFolderPath?: string, parentFolderUri?: string, accessToken?: string, sasApiClient?: SASViyaApiClient): Promise<{
|
|
208
|
-
result: import("./types").Job;
|
|
209
|
-
etag: string;
|
|
210
|
-
}>;
|
|
211
|
-
getAuthCode(clientId: string): Promise<string | null>;
|
|
212
|
-
/**
|
|
213
|
-
* Exchanges the auth code for an access token for the given client.
|
|
214
|
-
* @param clientId - the client ID to authenticate with.
|
|
215
|
-
* @param clientSecret - the client secret to authenticate with.
|
|
216
|
-
* @param authCode - the auth code received from the server.
|
|
217
|
-
*/
|
|
218
|
-
getAccessToken(clientId: string, clientSecret: string, authCode: string): Promise<SasAuthResponse | SASjsAuthResponse>;
|
|
219
|
-
/**
|
|
220
|
-
* Exchanges the refresh token for an access token for the given client.
|
|
221
|
-
* @param clientId - the client ID to authenticate with.
|
|
222
|
-
* @param clientSecret - the client secret to authenticate with.
|
|
223
|
-
* @param refreshToken - the refresh token received from the server.
|
|
224
|
-
*/
|
|
225
|
-
refreshTokens(clientId: string, clientSecret: string, refreshToken: string): Promise<SasAuthResponse | SASjsAuthResponse>;
|
|
226
|
-
deleteClient(clientId: string, accessToken: string): Promise<unknown>;
|
|
227
|
-
/**
|
|
228
|
-
* Returns the current SASjs configuration.
|
|
229
|
-
*
|
|
230
|
-
*/
|
|
231
|
-
getSasjsConfig(): SASjsConfig;
|
|
232
|
-
/**
|
|
233
|
-
* Returns the username of the user currently logged in.
|
|
234
|
-
*
|
|
235
|
-
*/
|
|
236
|
-
getUserName(): string;
|
|
237
|
-
/**
|
|
238
|
-
* Sets the SASjs configuration.
|
|
239
|
-
* @param config - SASjs configuration.
|
|
240
|
-
*/
|
|
241
|
-
setSASjsConfig(config: SASjsConfig): Promise<void>;
|
|
242
|
-
/**
|
|
243
|
-
* Sets the debug state. Turning this on will enable additional logging in the adapter.
|
|
244
|
-
* @param value - boolean indicating debug state (on/off).
|
|
245
|
-
*/
|
|
246
|
-
setDebugState(value: boolean): void;
|
|
247
|
-
/**
|
|
248
|
-
* Checks whether a session is active, or login is required.
|
|
249
|
-
* @returns - a promise which resolves with an object containing two values - a boolean `isLoggedIn`, and a string `userName`.
|
|
250
|
-
*/
|
|
251
|
-
checkSession(): Promise<import("./types").LoginResultInternal>;
|
|
252
|
-
/**
|
|
253
|
-
* Logs into the SAS server with the supplied credentials.
|
|
254
|
-
* @param username - a string representing the username.
|
|
255
|
-
* @param password - a string representing the password.
|
|
256
|
-
* @param clientId - a string representing the client ID.
|
|
257
|
-
*/
|
|
258
|
-
logIn(username?: string, password?: string, clientId?: string, options?: LoginOptions): Promise<LoginResult>;
|
|
259
|
-
/**
|
|
260
|
-
* Logs out of the configured SAS server.
|
|
261
|
-
*/
|
|
262
|
-
logOut(): Promise<boolean>;
|
|
263
|
-
/**
|
|
264
|
-
* Uploads a file to the given service.
|
|
265
|
-
* @param sasJob - the path to the SAS program (ultimately resolves to
|
|
266
|
-
* the SAS `_program` parameter to run a Job Definition or SAS 9 Stored
|
|
267
|
-
* Process). Is prepended at runtime with the value of `appLoc`.
|
|
268
|
-
* @param files - array of files to be uploaded, including File object and file name.
|
|
269
|
-
* @param params - request URL parameters.
|
|
270
|
-
* @param config - provide any changes to the config here, for instance to
|
|
271
|
-
* enable/disable `debug`. Any change provided will override the global config,
|
|
272
|
-
* for that particular function call.
|
|
273
|
-
* @param loginRequiredCallback - a function that is called if the
|
|
274
|
-
* user is not logged in (eg to display a login form). The request will be
|
|
275
|
-
* resubmitted after successful login.
|
|
276
|
-
*/
|
|
277
|
-
uploadFile(sasJob: string, files: UploadFile[], params: {
|
|
278
|
-
[key: string]: any;
|
|
279
|
-
} | null, config?: {
|
|
280
|
-
[key: string]: any;
|
|
281
|
-
}, loginRequiredCallback?: () => any): Promise<unknown>;
|
|
282
|
-
/**
|
|
283
|
-
* Makes a request to program specified in `SASjob` (could be a Viya Job, a
|
|
284
|
-
* SAS 9 Stored Process, or a SASjs Server Stored Program). The response
|
|
285
|
-
* object will always contain table names in lowercase, and column names in
|
|
286
|
-
* uppercase. Values are returned formatted by default, unformatted
|
|
287
|
-
* values can be configured as an option in the `%webout` macro.
|
|
288
|
-
*
|
|
289
|
-
* @param sasJob - the path to the SAS program (ultimately resolves to
|
|
290
|
-
* the SAS `_program` parameter to run a Job Definition or SAS 9 Stored
|
|
291
|
-
* Process). Is prepended at runtime with the value of `appLoc`.
|
|
292
|
-
* @param data - a JSON object containing one or more tables to be sent to
|
|
293
|
-
* SAS. For an example of the table structure, see the project README. This
|
|
294
|
-
* value can be `null` if no inputs are required.
|
|
295
|
-
* @param config - provide any changes to the config here, for instance to
|
|
296
|
-
* enable/disable `debug`. Any change provided will override the global config,
|
|
297
|
-
* for that particular function call.
|
|
298
|
-
* @param loginRequiredCallback - a function that is called if the
|
|
299
|
-
* user is not logged in (eg to display a login form). The request will be
|
|
300
|
-
* resubmitted after successful login.
|
|
301
|
-
* When using a `loginRequiredCallback`, the call to the request will look, for example, like so:
|
|
302
|
-
* `await request(sasJobPath, data, config, () => setIsLoggedIn(false))`
|
|
303
|
-
* If you are not passing in any data and configuration, it will look like so:
|
|
304
|
-
* `await request(sasJobPath, {}, {}, () => setIsLoggedIn(false))`
|
|
305
|
-
* @param extraResponseAttributes - a array of predefined values that are used
|
|
306
|
-
* to provide extra attributes (same names as those values) to be added in response
|
|
307
|
-
* Supported values are declared in ExtraResponseAttributes type.
|
|
308
|
-
*/
|
|
309
|
-
request(sasJob: string, data: {
|
|
310
|
-
[key: string]: any;
|
|
311
|
-
} | null, config?: {
|
|
312
|
-
[key: string]: any;
|
|
313
|
-
}, loginRequiredCallback?: () => any, authConfig?: AuthConfig, extraResponseAttributes?: ExtraResponseAttributes[]): Promise<any>;
|
|
314
|
-
/**
|
|
315
|
-
* Creates the folders and services at the given location `appLoc` on the given server `serverUrl`.
|
|
316
|
-
* @param serviceJson - the JSON specifying the folders and services to be created.
|
|
317
|
-
* @param appLoc - the base folder in which to create the new folders and
|
|
318
|
-
* services. If not provided, is taken from SASjsConfig.
|
|
319
|
-
* @param serverUrl - the server on which to deploy the folders and services.
|
|
320
|
-
* If not provided, is taken from SASjsConfig.
|
|
321
|
-
* @param accessToken - an optional access token to be passed in when
|
|
322
|
-
* using this function from the command line.
|
|
323
|
-
* @param isForced - flag that indicates if target folder already exists, it and all subfolders have to be deleted.
|
|
324
|
-
*/
|
|
325
|
-
deployServicePack(serviceJson: any, appLoc?: string, serverUrl?: string, accessToken?: string, isForced?: boolean): Promise<void>;
|
|
326
|
-
/**
|
|
327
|
-
* Kicks off execution of the given job via the compute API.
|
|
328
|
-
* @returns an object representing the compute session created for the given job.
|
|
329
|
-
* @param sasJob - the path to the SAS program (ultimately resolves to
|
|
330
|
-
* the SAS `_program` parameter to run a Job Definition or SAS 9 Stored
|
|
331
|
-
* Process). Is prepended at runtime with the value of `appLoc`.
|
|
332
|
-
* @param data - a JSON object containing one or more tables to be sent to
|
|
333
|
-
* SAS. Can be `null` if no inputs required.
|
|
334
|
-
* @param config - provide any changes to the config here, for instance to
|
|
335
|
-
* enable/disable `debug`. Any change provided will override the global config,
|
|
336
|
-
* for that particular function call.
|
|
337
|
-
* @param authConfig - a valid client, secret, refresh and access tokens that are authorised to execute compute jobs.
|
|
338
|
-
* The access token is not required when the user is authenticated via the browser.
|
|
339
|
-
* @param waitForResult - a boolean that indicates whether the function needs to wait for execution to complete.
|
|
340
|
-
* @param pollOptions - an object that represents poll interval(milliseconds) and maximum amount of attempts. Object example: { maxPollCount: 24 * 60 * 60, pollInterval: 1000 }. More information available at src/api/viya/pollJobState.ts.
|
|
341
|
-
* @param printPid - a boolean that indicates whether the function should print (PID) of the started job.
|
|
342
|
-
* @param variables - an object that represents macro variables.
|
|
343
|
-
* @param verboseMode - boolean or a string equal to 'bleached' to enable verbose mode (log every HTTP response).
|
|
344
|
-
* @param onTokensRefreshed - (optional, SAS Viya only) callback invoked with the rotated token pair after a successful internal refresh, so consumers that persist tokens can store the new pair.
|
|
345
|
-
*/
|
|
346
|
-
startComputeJob(sasJob: string, data: any, config?: any, authConfig?: AuthConfig, waitForResult?: boolean, pollOptions?: PollOptions, printPid?: boolean, variables?: MacroVar, verboseMode?: VerboseMode, onTokensRefreshed?: OnTokensRefreshed): Promise<any>;
|
|
347
|
-
private resendWaitingRequests;
|
|
348
|
-
/**
|
|
349
|
-
* Fetches content of the log file
|
|
350
|
-
* @param logUrl - url of the log file.
|
|
351
|
-
* @param accessToken - an access token for an authorised user.
|
|
352
|
-
*/
|
|
353
|
-
fetchLogFileContent(logUrl: string, accessToken?: string): Promise<string>;
|
|
354
|
-
/**
|
|
355
|
-
* this method returns an array of SASjsRequest
|
|
356
|
-
* @returns SASjsRequest[]
|
|
357
|
-
*/
|
|
358
|
-
getSasRequests(): import("./types").SASjsRequest[];
|
|
359
|
-
clearSasRequests(): void;
|
|
360
|
-
private setupConfiguration;
|
|
361
|
-
private createFoldersAndServices;
|
|
362
|
-
private isMethodSupported;
|
|
363
|
-
/**
|
|
364
|
-
* Enables verbose mode that will log a summary of every HTTP response.
|
|
365
|
-
* @param successCallBack - function that should be triggered on every HTTP response with the status 2**.
|
|
366
|
-
* @param errorCallBack - function that should be triggered on every HTTP response with the status different from 2**.
|
|
367
|
-
*/
|
|
368
|
-
enableVerboseMode(successCallBack?: (response: AxiosResponse) => AxiosResponse, errorCallBack?: (response: AxiosError) => AxiosError): void;
|
|
369
|
-
/**
|
|
370
|
-
* Turns off verbose mode to log every HTTP response.
|
|
371
|
-
*/
|
|
372
|
-
disableVerboseMode(): void;
|
|
373
|
-
/**
|
|
374
|
-
* Sets verbose mode.
|
|
375
|
-
* @param verboseMode - value of the verbose mode, can be true, false or bleached(without extra colors).
|
|
376
|
-
*/
|
|
377
|
-
setVerboseMode: (verboseMode: VerboseMode) => void;
|
|
378
|
-
/**
|
|
379
|
-
* Create a tables class containing one or more tables to be sent to
|
|
380
|
-
* SAS.
|
|
381
|
-
* @param table - initial table data
|
|
382
|
-
* @param macroName - macro name
|
|
383
|
-
* @returns Tables class
|
|
384
|
-
*/
|
|
385
|
-
Tables(table: Record<string, any>, macroName: string): Tables;
|
|
386
|
-
}
|
|
387
|
-
export {};
|
package/node/SASjsApiClient.d.ts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { AuthConfig, ServicePackSASjs } from '@sasjs/utils/types';
|
|
2
|
-
import { ExecutionQuery } from './types';
|
|
3
|
-
import { RequestClient } from './request/RequestClient';
|
|
4
|
-
export interface SASjsAuthResponse {
|
|
5
|
-
access_token: string;
|
|
6
|
-
refresh_token: string;
|
|
7
|
-
}
|
|
8
|
-
export interface ScriptExecutionResult {
|
|
9
|
-
log: string;
|
|
10
|
-
webout?: string;
|
|
11
|
-
printOutput?: string;
|
|
12
|
-
}
|
|
13
|
-
export declare class SASjsApiClient {
|
|
14
|
-
private requestClient;
|
|
15
|
-
constructor(requestClient: RequestClient);
|
|
16
|
-
private getAccessTokenForRequest;
|
|
17
|
-
/**
|
|
18
|
-
* Creates the folders and services at the given location `appLoc` on the given server `serverUrl`.
|
|
19
|
-
* @param dataJson - the JSON specifying the folders and files to be created, can also includes
|
|
20
|
-
* appLoc, streamServiceName, streamWebFolder, streamLogo
|
|
21
|
-
* @param appLoc - the base folder in which to create the new folders and services.
|
|
22
|
-
* @param authConfig - (optional) a valid client, secret, refresh and access tokens that are authorised to execute compute jobs.
|
|
23
|
-
*/
|
|
24
|
-
deploy(dataJson: ServicePackSASjs, appLoc: string, authConfig?: AuthConfig): Promise<{
|
|
25
|
-
status: string;
|
|
26
|
-
message: string;
|
|
27
|
-
streamServiceName?: string | undefined;
|
|
28
|
-
example?: {} | undefined;
|
|
29
|
-
}>;
|
|
30
|
-
/**
|
|
31
|
-
* Creates/updates files within SASjs drive using uploaded json compressed file.
|
|
32
|
-
* @param zipFilePath - Compressed file path; file should only contain one JSON file and
|
|
33
|
-
* should have same name as of compressed file e.g. deploy.JSON should be compressed to deploy.JSON.zip
|
|
34
|
-
* Any other file or JSON file in zipped will be ignored!
|
|
35
|
-
* @param authConfig - (optional) a valid client, secret, refresh and access tokens that are authorised to execute compute jobs.
|
|
36
|
-
*/
|
|
37
|
-
deployZipFile(zipFilePath: string, authConfig?: AuthConfig): Promise<{
|
|
38
|
-
status: string;
|
|
39
|
-
message: string;
|
|
40
|
-
streamServiceName?: string | undefined;
|
|
41
|
-
example?: {} | undefined;
|
|
42
|
-
}>;
|
|
43
|
-
executeJob(query: ExecutionQuery, appLoc: string, authConfig?: AuthConfig): Promise<{
|
|
44
|
-
result: any;
|
|
45
|
-
log: any;
|
|
46
|
-
}>;
|
|
47
|
-
/**
|
|
48
|
-
* Executes code on a SASJS server.
|
|
49
|
-
* @param code - a string of code to execute.
|
|
50
|
-
* @param runTime - a string to representing runTime for code execution
|
|
51
|
-
* @param authConfig - an object for authentication.
|
|
52
|
-
*/
|
|
53
|
-
executeScript(code: string, runTime?: string, authConfig?: AuthConfig): Promise<ScriptExecutionResult>;
|
|
54
|
-
/**
|
|
55
|
-
* Exchanges the auth code for an access token for the given client.
|
|
56
|
-
* @param clientId - the client ID to authenticate with.
|
|
57
|
-
* @param authCode - the auth code received from the server.
|
|
58
|
-
*/
|
|
59
|
-
getAccessToken(clientId: string, authCode: string): Promise<SASjsAuthResponse>;
|
|
60
|
-
/**
|
|
61
|
-
* Exchanges the refresh token for an access token.
|
|
62
|
-
* @param refreshToken - the refresh token received from the server.
|
|
63
|
-
*/
|
|
64
|
-
refreshTokens(refreshToken: string): Promise<SASjsAuthResponse>;
|
|
65
|
-
}
|
package/node/SessionManager.d.ts
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { Session, SessionVariable } from './types';
|
|
2
|
-
import { RequestClient } from './request/RequestClient';
|
|
3
|
-
export declare class SessionManager {
|
|
4
|
-
private serverUrl;
|
|
5
|
-
private contextName;
|
|
6
|
-
private requestClient;
|
|
7
|
-
private loggedErrors;
|
|
8
|
-
private sessionStateLinkError;
|
|
9
|
-
constructor(serverUrl: string, contextName: string, requestClient: RequestClient);
|
|
10
|
-
private sessions;
|
|
11
|
-
private currentContext;
|
|
12
|
-
private settingContext;
|
|
13
|
-
private _debug;
|
|
14
|
-
private printedSessionState;
|
|
15
|
-
get debug(): boolean;
|
|
16
|
-
set debug(value: boolean);
|
|
17
|
-
/**
|
|
18
|
-
* Checks if session is valid. Session is considered valid if time since it's creation is less than 'sessionInactiveTimeout' attribute.
|
|
19
|
-
* @param session - session object.
|
|
20
|
-
* @returns - boolean indicating if session is valid.
|
|
21
|
-
*/
|
|
22
|
-
private isSessionValid;
|
|
23
|
-
/**
|
|
24
|
-
* Removes session from pool of hot sessions.
|
|
25
|
-
* @param session - session object.
|
|
26
|
-
* @returns - void.
|
|
27
|
-
*/
|
|
28
|
-
private removeSessionFromPool;
|
|
29
|
-
/**
|
|
30
|
-
* Filters session pool to keep only valid sessions.
|
|
31
|
-
* @param session - session object.
|
|
32
|
-
* @returns - void.
|
|
33
|
-
*/
|
|
34
|
-
private removeExpiredSessions;
|
|
35
|
-
/**
|
|
36
|
-
* Throws set of errors as a single error.
|
|
37
|
-
* @param errors - array of errors or string.
|
|
38
|
-
* @param prefix - an optional final error prefix.
|
|
39
|
-
* @returns - never.
|
|
40
|
-
*/
|
|
41
|
-
private throwErrors;
|
|
42
|
-
/**
|
|
43
|
-
* Returns session.
|
|
44
|
-
* If there is a hot session available, it will be returned immediately and an asynchronous request to create new hot session will be submitted.
|
|
45
|
-
* If there is no available session, 2 session creation requests will be submitted. The session is returned once it is created and ready.
|
|
46
|
-
* @param accessToken - an optional access token.
|
|
47
|
-
* @returns - a promise which resolves with a session.
|
|
48
|
-
*/
|
|
49
|
-
getSession(accessToken?: string): Promise<Session>;
|
|
50
|
-
/**
|
|
51
|
-
* Returns error message based on the response from SAS API.
|
|
52
|
-
* @param err - an optional access token.
|
|
53
|
-
* @param accessToken - an optional access token.
|
|
54
|
-
* @returns - an error message.
|
|
55
|
-
*/
|
|
56
|
-
private getErrorMessage;
|
|
57
|
-
/**
|
|
58
|
-
* Deletes session.
|
|
59
|
-
* @param id - a session id.
|
|
60
|
-
* @param accessToken - an optional access token.
|
|
61
|
-
* @returns - a promise which resolves when session is deleted.
|
|
62
|
-
*/
|
|
63
|
-
clearSession(id: string, accessToken?: string): Promise<void>;
|
|
64
|
-
/**
|
|
65
|
-
* Creates sessions in amount equal to MAX_SESSION_COUNT.
|
|
66
|
-
* @param accessToken - an optional access token.
|
|
67
|
-
* @returns - a promise which resolves when required amount of sessions is created.
|
|
68
|
-
*/
|
|
69
|
-
private createSessions;
|
|
70
|
-
/**
|
|
71
|
-
* Waits for the current context to be set.
|
|
72
|
-
* @returns - a promise which resolves when current context is set.
|
|
73
|
-
*/
|
|
74
|
-
private waitForCurrentContext;
|
|
75
|
-
/**
|
|
76
|
-
* Creates and waits for session to be ready.
|
|
77
|
-
* @param accessToken - an optional access token.
|
|
78
|
-
* @returns - a promise which resolves with a session.
|
|
79
|
-
*/
|
|
80
|
-
private createAndWaitForSession;
|
|
81
|
-
/**
|
|
82
|
-
* Sets current context.
|
|
83
|
-
* @param accessToken - an optional access token.
|
|
84
|
-
* @returns - a promise which resolves when current context is set.
|
|
85
|
-
*/
|
|
86
|
-
private setCurrentContext;
|
|
87
|
-
/**
|
|
88
|
-
* Waits for session to be ready.
|
|
89
|
-
* @param session - a session object.
|
|
90
|
-
* @param etag - an etag that can be a string or null.
|
|
91
|
-
* @param accessToken - an optional access token.
|
|
92
|
-
* @returns - a promise which resolves with a session state.
|
|
93
|
-
*/
|
|
94
|
-
private waitForSession;
|
|
95
|
-
/**
|
|
96
|
-
* Gets session state.
|
|
97
|
-
* @param url - a URL to get session state.
|
|
98
|
-
* @param etag - an etag string.
|
|
99
|
-
* @param accessToken - an optional access token.
|
|
100
|
-
* @returns - a promise which resolves with a result string and response status.
|
|
101
|
-
*/
|
|
102
|
-
private getSessionState;
|
|
103
|
-
/**
|
|
104
|
-
* Gets variable.
|
|
105
|
-
* @param sessionId - a session id.
|
|
106
|
-
* @param variable - a variable string.
|
|
107
|
-
* @param accessToken - an optional access token.
|
|
108
|
-
* @returns - a promise which resolves with a result that confirms to SessionVariable interface, etag string and status code.
|
|
109
|
-
*/
|
|
110
|
-
getVariable(sessionId: string, variable: string, accessToken?: string): Promise<{
|
|
111
|
-
result: SessionVariable;
|
|
112
|
-
etag: string;
|
|
113
|
-
status: number;
|
|
114
|
-
}>;
|
|
115
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { AuthConfig, MacroVar } from '@sasjs/utils/types';
|
|
2
|
-
import { PollOptions } from '../..';
|
|
3
|
-
import { OnTokensRefreshed } from '../../auth/getTokens';
|
|
4
|
-
import { RequestClient } from '../../request/RequestClient';
|
|
5
|
-
import { SessionManager } from '../../SessionManager';
|
|
6
|
-
/**
|
|
7
|
-
* Executes SAS program on the current SAS Viya server using Compute API.
|
|
8
|
-
* @param jobPath - the path to the file being submitted for execution.
|
|
9
|
-
* @param linesOfCode - an array of code lines to execute.
|
|
10
|
-
* @param contextName - the context to execute the code in.
|
|
11
|
-
* @param authConfig - an object containing an access token, refresh token, client ID and secret.
|
|
12
|
-
* @param data - execution data.
|
|
13
|
-
* @param debug - when set to true, the log will be returned.
|
|
14
|
-
* @param expectWebout - when set to true, the automatic _webout fileref will be checked for content, and that content returned. This fileref is used when the Job contains a SASjs web request (as opposed to executing arbitrary SAS code).
|
|
15
|
-
* @param waitForResult - when set to true, function will return the session
|
|
16
|
-
* @param pollOptions - an object that represents poll interval(milliseconds) and maximum amount of attempts. Object example: { maxPollCount: 24 * 60 * 60, pollInterval: 1000 }. More information available at src/api/viya/pollJobState.ts.
|
|
17
|
-
* @param printPid - a boolean that indicates whether the function should print (PID) of the started job.
|
|
18
|
-
* @param variables - an object that represents macro variables.
|
|
19
|
-
* @param onTokensRefreshed - optional callback invoked with the rotated token pair after a successful internal refresh, so consumers that persist tokens can store the new pair.
|
|
20
|
-
*/
|
|
21
|
-
export declare function executeOnComputeApi(requestClient: RequestClient, sessionManager: SessionManager, rootFolderName: string, jobPath: string, linesOfCode: string[], contextName: string, authConfig?: AuthConfig, data?: any, debug?: boolean, expectWebout?: boolean, waitForResult?: boolean, pollOptions?: PollOptions, printPid?: boolean, variables?: MacroVar, onTokensRefreshed?: OnTokensRefreshed): Promise<any>;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { AuthConfig } from '@sasjs/utils/types';
|
|
2
|
-
import { Job, PollOptions } from '../..';
|
|
3
|
-
import { OnTokensRefreshed } from '../../auth/getTokens';
|
|
4
|
-
import { RequestClient } from '../../request/RequestClient';
|
|
5
|
-
import { WriteStream, JobSessionManager } from '../../types';
|
|
6
|
-
export declare enum JobState {
|
|
7
|
-
Completed = "completed",
|
|
8
|
-
Running = "running",
|
|
9
|
-
Pending = "pending",
|
|
10
|
-
Unavailable = "unavailable",
|
|
11
|
-
NoState = "",
|
|
12
|
-
Failed = "failed",
|
|
13
|
-
Error = "error"
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Polls job status using default or provided poll options.
|
|
17
|
-
* @param requestClient - the pre-configured HTTP request client.
|
|
18
|
-
* @param postedJob - the relative or absolute path to the job.
|
|
19
|
-
* @param debug - sets the _debug flag in the job arguments.
|
|
20
|
-
* @param authConfig - an access token, refresh token, client and secret for an authorized user.
|
|
21
|
-
* @param pollOptions - an object containing maxPollCount, pollInterval, streamLog and logFolderPath. It will override the first default poll options in poll strategy if provided.
|
|
22
|
-
* Example pollOptions:
|
|
23
|
-
* {
|
|
24
|
-
* maxPollCount: 200,
|
|
25
|
-
* pollInterval: 300,
|
|
26
|
-
* streamLog: true, // optional, equals to false by default.
|
|
27
|
-
* pollStrategy?: // optional array of poll options that should be applied after 'maxPollCount' of the provided poll options is reached. If not provided the default (see example below) poll strategy will be used.
|
|
28
|
-
* }
|
|
29
|
-
* Example pollStrategy (values used from default poll strategy):
|
|
30
|
-
* [
|
|
31
|
-
* { maxPollCount: 200, pollInterval: 300 }, // approximately ~2 mins (including time to get response (~300ms))
|
|
32
|
-
* { maxPollCount: 300, pollInterval: 3000 }, // approximately ~5.5 mins (including time to get response (~300ms))
|
|
33
|
-
* { maxPollCount: 500, pollInterval: 30000 }, // approximately ~50.5 mins (including time to get response (~300ms))
|
|
34
|
-
* { maxPollCount: 3400, pollInterval: 60000 } // approximately ~3015 mins (~125 hours) (including time to get response (~300ms))
|
|
35
|
-
* ]
|
|
36
|
-
* @param jobSessionManager - job session object containing session object and an instance of Session Manager. Job session object is used to periodically (every 10th job state poll) check parent session state.
|
|
37
|
-
* @returns - a promise which resolves with a job state
|
|
38
|
-
*/
|
|
39
|
-
export declare function pollJobState(requestClient: RequestClient, postedJob: Job, debug: boolean, authConfig?: AuthConfig, pollOptions?: PollOptions, jobSessionManager?: JobSessionManager, onTokensRefreshed?: OnTokensRefreshed): Promise<JobState>;
|
|
40
|
-
/**
|
|
41
|
-
* Polls job state.
|
|
42
|
-
* @param requestClient - the pre-configured HTTP request client.
|
|
43
|
-
* @param postedJob - the relative or absolute path to the job.
|
|
44
|
-
* @param currentState - current job state.
|
|
45
|
-
* @param debug - sets the _debug flag in the job arguments.
|
|
46
|
-
* @param pollCount - current poll count.
|
|
47
|
-
* @param pollOptions - an object containing maxPollCount, pollInterval, streamLog and logFolderPath.
|
|
48
|
-
* @param authConfig - an access token, refresh token, client and secret for an authorized user.
|
|
49
|
-
* @param streamLog - indicates if job log should be streamed.
|
|
50
|
-
* @param logStream - job log stream.
|
|
51
|
-
* @param jobSessionManager - job session object containing session object and an instance of Session Manager. Job session object is used to periodically (every 10th job state poll) check parent session state. Session state is considered healthy if it is equal to 'running' or 'idle'.
|
|
52
|
-
* @returns - a promise which resolves with a job state
|
|
53
|
-
*/
|
|
54
|
-
export declare const doPoll: (requestClient: RequestClient, postedJob: Job, currentState: JobState, debug: boolean, pollCount: number, pollOptions: PollOptions, authConfig?: AuthConfig, streamLog?: boolean, logStream?: WriteStream, jobSessionManager?: JobSessionManager, onTokensRefreshed?: OnTokensRefreshed) => Promise<{
|
|
55
|
-
state: JobState;
|
|
56
|
-
pollCount: number;
|
|
57
|
-
}>;
|