mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-14 15:40:06 +00:00
Merge pull request #56 from sasjs/performance-improvements
fix(*): Performance improvements
This commit is contained in:
8
.github/workflows/build.yml
vendored
8
.github/workflows/build.yml
vendored
@@ -21,7 +21,11 @@ jobs:
|
|||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v1
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ matrix.node-version }}
|
||||||
- run: npm ci
|
- name: Install Dependencies
|
||||||
- run: npm run package:lib
|
run: npm ci
|
||||||
|
- name: Check code style
|
||||||
|
run: npm run lint
|
||||||
|
- name: Build Package
|
||||||
|
run: npm run package:lib
|
||||||
env:
|
env:
|
||||||
CI: true
|
CI: true
|
||||||
|
|||||||
2
.github/workflows/npmpublish.yml
vendored
2
.github/workflows/npmpublish.yml
vendored
@@ -16,6 +16,8 @@ jobs:
|
|||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: npm ci
|
run: npm ci
|
||||||
|
- name: Check code style
|
||||||
|
run: npm run lint
|
||||||
- name: Build Project
|
- name: Build Project
|
||||||
run: npm run build
|
run: npm run build
|
||||||
- name: Semantic Release
|
- name: Semantic Release
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
"package:lib": "npm run build && cp ./package.json build && cd build && npm version \"5.0.0\" && npm pack",
|
"package:lib": "npm run build && cp ./package.json build && cd build && npm version \"5.0.0\" && npm pack",
|
||||||
"publish:lib": "npm run build && cd build && npm publish",
|
"publish:lib": "npm run build && cd build && npm publish",
|
||||||
"lint:fix": "npx prettier --write 'src/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}'",
|
"lint:fix": "npx prettier --write 'src/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}'",
|
||||||
"lint": "tslint -p tsconfig.json",
|
"lint": "npx prettier --check 'src/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}'",
|
||||||
"test": "jest",
|
"test": "jest",
|
||||||
"prepublishOnly": "cp -r ./build/* . && rm -rf ./build",
|
"prepublishOnly": "cp -r ./build/* . && rm -rf ./build",
|
||||||
"postpublish": "git clean -fd",
|
"postpublish": "git clean -fd",
|
||||||
@@ -41,7 +41,6 @@
|
|||||||
"cp": "^0.2.0",
|
"cp": "^0.2.0",
|
||||||
"jest": "^25.5.4",
|
"jest": "^25.5.4",
|
||||||
"path": "^0.12.7",
|
"path": "^0.12.7",
|
||||||
"prettier": "^2.1.1",
|
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"semantic-release": "^17.1.1",
|
"semantic-release": "^17.1.1",
|
||||||
"ts-jest": "^25.5.1",
|
"ts-jest": "^25.5.1",
|
||||||
|
|||||||
@@ -675,20 +675,30 @@ export class SASViyaApiClient {
|
|||||||
const jobName = sasJob.split("/")[1];
|
const jobName = sasJob.split("/")[1];
|
||||||
const jobFolder = this.rootFolderMap.get(folderName);
|
const jobFolder = this.rootFolderMap.get(folderName);
|
||||||
const jobToExecute = jobFolder?.find((item) => item.name === jobName);
|
const jobToExecute = jobFolder?.find((item) => item.name === jobName);
|
||||||
const jobDefinitionLink = jobToExecute?.links.find(
|
if (!jobToExecute) {
|
||||||
(l) => l.rel === "getResource"
|
throw new Error("Job was not found.");
|
||||||
);
|
|
||||||
if (!jobDefinitionLink) {
|
|
||||||
console.error("Job definition URI was not found.");
|
|
||||||
throw new Error("Job definition URI was not found.");
|
|
||||||
}
|
}
|
||||||
const { result: jobDefinition } = await this.request<JobDefinition>(
|
|
||||||
`${this.serverUrl}${jobDefinitionLink.href}`,
|
let code = jobToExecute?.code;
|
||||||
headers
|
if (!code) {
|
||||||
);
|
const jobDefinitionLink = jobToExecute?.links.find(
|
||||||
const linesToExecute = jobDefinition.code
|
(l) => l.rel === "getResource"
|
||||||
.replace(/\r\n/g, "\n")
|
);
|
||||||
.split("\n");
|
if (!jobDefinitionLink) {
|
||||||
|
console.error("Job definition URI was not found.");
|
||||||
|
throw new Error("Job definition URI was not found.");
|
||||||
|
}
|
||||||
|
const { result: jobDefinition } = await this.request<JobDefinition>(
|
||||||
|
`${this.serverUrl}${jobDefinitionLink.href}`,
|
||||||
|
headers
|
||||||
|
);
|
||||||
|
|
||||||
|
code = jobDefinition.code;
|
||||||
|
|
||||||
|
// Add code to existing job definition
|
||||||
|
jobToExecute.code = code;
|
||||||
|
}
|
||||||
|
const linesToExecute = code.replace(/\r\n/g, "\n").split("\n");
|
||||||
return await this.executeScript(
|
return await this.executeScript(
|
||||||
sasJob,
|
sasJob,
|
||||||
linesToExecute,
|
linesToExecute,
|
||||||
@@ -928,6 +938,23 @@ export class SASViyaApiClient {
|
|||||||
headers.Authorization = `Bearer ${accessToken}`;
|
headers.Authorization = `Bearer ${accessToken}`;
|
||||||
}
|
}
|
||||||
const stateLink = postedJob.links.find((l: any) => l.rel === "state");
|
const stateLink = postedJob.links.find((l: any) => l.rel === "state");
|
||||||
|
if (!stateLink) {
|
||||||
|
Promise.reject("Job state link was not found.");
|
||||||
|
}
|
||||||
|
|
||||||
|
const { result: state } = await this.request<string>(
|
||||||
|
`${this.serverUrl}${stateLink.href}?_action=wait&wait=30`,
|
||||||
|
{
|
||||||
|
headers
|
||||||
|
},
|
||||||
|
"text"
|
||||||
|
);
|
||||||
|
|
||||||
|
const currentState = state.trim();
|
||||||
|
if (currentState === "completed") {
|
||||||
|
return Promise.resolve(currentState);
|
||||||
|
}
|
||||||
|
|
||||||
return new Promise(async (resolve, _) => {
|
return new Promise(async (resolve, _) => {
|
||||||
const interval = setInterval(async () => {
|
const interval = setInterval(async () => {
|
||||||
if (
|
if (
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ export interface Job {
|
|||||||
name: string;
|
name: string;
|
||||||
uri: string;
|
uri: string;
|
||||||
createdBy: string;
|
createdBy: string;
|
||||||
|
code?: string;
|
||||||
links: Link[];
|
links: Link[];
|
||||||
results: JobResult;
|
results: JobResult;
|
||||||
error?: any;
|
error?: any;
|
||||||
|
|||||||
Reference in New Issue
Block a user