mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-09 21:30:05 +00:00
fix(context): cache contexts after first request
This commit is contained in:
@@ -26,6 +26,7 @@ export class SASViyaApiClient {
|
|||||||
}
|
}
|
||||||
private csrfToken: { headerName: string; value: string } | null = null;
|
private csrfToken: { headerName: string; value: string } | null = null;
|
||||||
private rootFolder: Folder | null = null;
|
private rootFolder: Folder | null = null;
|
||||||
|
private contexts: Context[] = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a map containing the directory structure in the currently set root folder.
|
* Returns a map containing the directory structure in the currently set root folder.
|
||||||
@@ -95,14 +96,18 @@ export class SASViyaApiClient {
|
|||||||
if (accessToken) {
|
if (accessToken) {
|
||||||
headers.Authorization = `Bearer ${accessToken}`;
|
headers.Authorization = `Bearer ${accessToken}`;
|
||||||
}
|
}
|
||||||
const { result: contexts } = await this.request<{ items: Context[] }>(
|
|
||||||
`${this.serverUrl}/compute/contexts`,
|
if (!this.contexts.length) {
|
||||||
{ headers }
|
const { result: contexts } = await this.request<{ items: Context[] }>(
|
||||||
);
|
`${this.serverUrl}/compute/contexts`,
|
||||||
const contextsList = contexts && contexts.items ? contexts.items : [];
|
{ headers }
|
||||||
|
);
|
||||||
|
|
||||||
|
this.contexts = contexts && contexts.items ? contexts.items : [];
|
||||||
|
}
|
||||||
const executableContexts: any[] = [];
|
const executableContexts: any[] = [];
|
||||||
|
|
||||||
const promises = contextsList.map((context: any) => {
|
const promises = this.contexts.map((context: any) => {
|
||||||
const linesOfCode = ["%put &=sysuserid;"];
|
const linesOfCode = ["%put &=sysuserid;"];
|
||||||
return this.executeScript(
|
return this.executeScript(
|
||||||
`test-${context.name}`,
|
`test-${context.name}`,
|
||||||
@@ -127,10 +132,10 @@ export class SASViyaApiClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
executableContexts.push({
|
executableContexts.push({
|
||||||
createdBy: contextsList[index].createdBy,
|
createdBy: this.contexts[index].createdBy,
|
||||||
id: contextsList[index].id,
|
id: this.contexts[index].id,
|
||||||
name: contextsList[index].name,
|
name: this.contexts[index].name,
|
||||||
version: contextsList[index].version,
|
version: this.contexts[index].version,
|
||||||
attributes: {
|
attributes: {
|
||||||
sysUserId,
|
sysUserId,
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user