mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-07 04:20:05 +00:00
fix: tidying up logic and adding descriptive comments
This commit is contained in:
54
src/SASjs.ts
54
src/SASjs.ts
@@ -79,7 +79,8 @@ export default class SASjs {
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the sas code against SAS9 server
|
||||
* Executes code against a SAS 9 server. Requires a runner to be present in
|
||||
* the users home directory in metadata.
|
||||
* @param linesOfCode - lines of sas code from the file to run.
|
||||
* @param username - a string representing the username.
|
||||
* @param password - a string representing the password.
|
||||
@@ -99,7 +100,7 @@ export default class SASjs {
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the sas code against SASViya server
|
||||
* Executes sas code in a SAS Viya compute session.
|
||||
* @param fileName - name of the file to run. It will be converted to path to the file being submitted for execution.
|
||||
* @param linesOfCode - lines of sas code from the file to run.
|
||||
* @param contextName - context name on which code will be run on the server.
|
||||
@@ -643,7 +644,8 @@ export default class SASjs {
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a request to the SAS Service specified in `SASjob`. The response
|
||||
* Makes a request to program specified in `SASjob` (could be a Viya Job, a
|
||||
* SAS 9 Stored Process, or a SASjs Server Stored Program). The response
|
||||
* object will always contain table names in lowercase, and column names in
|
||||
* uppercase. Values are returned formatted by default, unformatted
|
||||
* values can be configured as an option in the `%webout` macro.
|
||||
@@ -652,7 +654,8 @@ export default class SASjs {
|
||||
* the SAS `_program` parameter to run a Job Definition or SAS 9 Stored
|
||||
* Process). Is prepended at runtime with the value of `appLoc`.
|
||||
* @param data - a JSON object containing one or more tables to be sent to
|
||||
* SAS. Can be `null` if no inputs required.
|
||||
* SAS. For an example of the table structure, see the project README. This
|
||||
* value can be `null` if no inputs are required.
|
||||
* @param config - provide any changes to the config here, for instance to
|
||||
* enable/disable `debug`. Any change provided will override the global config,
|
||||
* for that particular function call.
|
||||
@@ -682,19 +685,38 @@ export default class SASjs {
|
||||
|
||||
const validationResult = this.validateInput(data)
|
||||
|
||||
// status is true if the data passes validation checks above
|
||||
if (validationResult.status) {
|
||||
if (
|
||||
config.serverType === ServerType.Sasjs &&
|
||||
typeof FormData === 'undefined'
|
||||
) {
|
||||
return await this.sasJsJobExecutor!.execute(
|
||||
sasJob,
|
||||
data,
|
||||
config,
|
||||
loginRequiredCallback,
|
||||
authConfig,
|
||||
extraResponseAttributes
|
||||
)
|
||||
if (config.serverType === ServerType.Sasjs) {
|
||||
/**
|
||||
* When sending the JSON data object to SAS, it is first converted to
|
||||
* a set of specially formatted CSVs. These are passed as multi-part
|
||||
* form data (converted to input files in the backend SAS session by the
|
||||
* API). When running outside of a browser, the FormData object is not
|
||||
* available. So in this case, a slightly different executor is invoked,
|
||||
* which is similar to the sas9JobExecutor.
|
||||
*/
|
||||
if (typeof FormData === 'undefined') {
|
||||
// cli invocation
|
||||
return await this.sasJsJobExecutor!.execute(
|
||||
sasJob,
|
||||
data,
|
||||
config,
|
||||
loginRequiredCallback,
|
||||
authConfig,
|
||||
extraResponseAttributes
|
||||
)
|
||||
} else {
|
||||
// web invocation
|
||||
return await this.webJobExecutor!.execute(
|
||||
sasJob,
|
||||
data,
|
||||
config,
|
||||
loginRequiredCallback,
|
||||
authConfig,
|
||||
extraResponseAttributes
|
||||
)
|
||||
}
|
||||
} else if (
|
||||
config.serverType === ServerType.SasViya &&
|
||||
config.useComputeApi !== undefined &&
|
||||
|
||||
Reference in New Issue
Block a user