1
0
mirror of https://github.com/sasjs/adapter.git synced 2025-12-11 01:14:36 +00:00

Compare commits

...

3 Commits

Author SHA1 Message Date
Allan Bowe
cc28dfe7f0 fix: tidying up logic and adding descriptive comments 2022-02-21 19:40:24 +00:00
2ec2147245 chore: add detailed comment 2022-02-21 23:22:57 +05:00
9ca4732f76 fix: call sasJsJobExecutor only from cli 2022-02-21 23:08:55 +05:00
2 changed files with 40 additions and 13 deletions

View File

@@ -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,18 +685,40 @@ 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) {
return await this.sasJsJobExecutor!.execute(
sasJob,
data,
config,
loginRequiredCallback,
authConfig,
extraResponseAttributes
)
/**
* 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.Sas9 &&
config.serverType === ServerType.SasViya &&
config.useComputeApi !== undefined &&
config.useComputeApi !== null
) {

View File

@@ -108,6 +108,8 @@ export class WebJobExecutor extends BaseJobExecutor {
...this.getRequestParams(config)
}
// FormData is only valid in browser
// FormData is a part of JS web API (not included in native NodeJS).
let formData = new FormData()
if (data) {