mirror of
https://github.com/sasjs/adapter.git
synced 2025-12-11 01:14:36 +00:00
Compare commits
41 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1aa92c0a69 | ||
|
|
4c097a69fd | ||
|
|
2634933e84 | ||
|
|
c1bab07b08 | ||
|
|
95f3ebd51d | ||
|
|
0e5b72b54f | ||
|
|
33ce592379 | ||
|
|
9f6591d7e3 | ||
|
|
5343ca00d8 | ||
|
|
f764f1f22f | ||
|
|
978af5037e | ||
|
|
39e88052c7 | ||
|
|
889351caf1 | ||
|
|
e6476dc230 | ||
|
|
e7de45c94f | ||
|
|
2f822aba71 | ||
|
|
ba687bf8e2 | ||
|
|
618cbe5a21 | ||
|
|
d723150b6d | ||
|
|
b1ad983ca5 | ||
|
|
4711d0510e | ||
|
|
93854c287f | ||
|
|
687a3047fd | ||
|
|
c067c6e74d | ||
|
|
04b44f40ba | ||
|
|
ce2126bd34 | ||
|
|
638efe8899 | ||
|
|
23353355e4 | ||
|
|
1be64798c5 | ||
|
|
a92a458cf1 | ||
|
|
703fdf9c02 | ||
|
|
bc239cf5d6 | ||
|
|
86780db478 | ||
|
|
5d5afa20c7 | ||
|
|
d662c1a981 | ||
|
|
f3abafd5ed | ||
|
|
5076ea696c | ||
|
|
3a60e6422c | ||
|
|
b90b5d5c03 | ||
|
|
d5a8140d4f | ||
|
|
5f5d84da87 |
17
PULL_REQUEST_TEMPLATE.md
Normal file
17
PULL_REQUEST_TEMPLATE.md
Normal file
@@ -0,0 +1,17 @@
|
||||
## Issue
|
||||
|
||||
Link any related issue(s) in this section.
|
||||
|
||||
## Intent
|
||||
|
||||
What this PR intends to achieve.
|
||||
|
||||
## Implementation
|
||||
|
||||
What code changes have been made to achieve the intent.
|
||||
|
||||
## Checks
|
||||
|
||||
- [ ] Code is formatted correctly (`npm run lint:fix`).
|
||||
- [ ] All unit tests are passing (`npm test`).
|
||||
- [ ] All `sasjs-tests` are passing (instructions available [here](https://github.com/sasjs/adapter/blob/master/sasjs-tests/README.md)).
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
231
docs/classes/reflection-725.reflection-191.fileuploader.html
Normal file
231
docs/classes/reflection-725.reflection-191.fileuploader.html
Normal file
File diff suppressed because one or more lines are too long
312
docs/classes/reflection-725.reflection-191.sas9apiclient.html
Normal file
312
docs/classes/reflection-725.reflection-191.sas9apiclient.html
Normal file
File diff suppressed because one or more lines are too long
1336
docs/classes/reflection-725.reflection-191.sasjs.html
Normal file
1336
docs/classes/reflection-725.reflection-191.sasjs.html
Normal file
File diff suppressed because one or more lines are too long
1267
docs/classes/reflection-725.reflection-191.sasviyaapiclient.html
Normal file
1267
docs/classes/reflection-725.reflection-191.sasviyaapiclient.html
Normal file
File diff suppressed because one or more lines are too long
271
docs/classes/reflection-725.reflection-191.sessionmanager.html
Normal file
271
docs/classes/reflection-725.reflection-191.sessionmanager.html
Normal file
File diff suppressed because one or more lines are too long
231
docs/classes/reflection-725.reflection-194.fileuploader.html
Normal file
231
docs/classes/reflection-725.reflection-194.fileuploader.html
Normal file
File diff suppressed because one or more lines are too long
312
docs/classes/reflection-725.reflection-194.sas9apiclient.html
Normal file
312
docs/classes/reflection-725.reflection-194.sas9apiclient.html
Normal file
File diff suppressed because one or more lines are too long
1336
docs/classes/reflection-725.reflection-194.sasjs.html
Normal file
1336
docs/classes/reflection-725.reflection-194.sasjs.html
Normal file
File diff suppressed because one or more lines are too long
1270
docs/classes/reflection-725.reflection-194.sasviyaapiclient.html
Normal file
1270
docs/classes/reflection-725.reflection-194.sasviyaapiclient.html
Normal file
File diff suppressed because one or more lines are too long
271
docs/classes/reflection-725.reflection-194.sessionmanager.html
Normal file
271
docs/classes/reflection-725.reflection-194.sessionmanager.html
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
106
docs/modules/reflection-725.html
Normal file
106
docs/modules/reflection-725.html
Normal file
File diff suppressed because one or more lines are too long
128
docs/modules/reflection-725.reflection-191.html
Normal file
128
docs/modules/reflection-725.reflection-191.html
Normal file
File diff suppressed because one or more lines are too long
128
docs/modules/reflection-725.reflection-194.html
Normal file
128
docs/modules/reflection-725.reflection-194.html
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
2221
package-lock.json
generated
2221
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
10
package.json
10
package.json
@@ -37,22 +37,22 @@
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"@types/isomorphic-fetch": "0.0.35",
|
||||
"@types/jest": "^26.0.13",
|
||||
"@types/jest": "^26.0.14",
|
||||
"cp": "^0.2.0",
|
||||
"jest": "^25.5.4",
|
||||
"path": "^0.12.7",
|
||||
"rimraf": "^3.0.2",
|
||||
"semantic-release": "^17.1.1",
|
||||
"semantic-release": "^17.1.2",
|
||||
"terser-webpack-plugin": "^4.2.2",
|
||||
"ts-jest": "^25.5.1",
|
||||
"ts-loader": "^8.0.3",
|
||||
"ts-loader": "^8.0.4",
|
||||
"tslint": "^6.1.3",
|
||||
"tslint-config-prettier": "^1.18.0",
|
||||
"typedoc": "^0.17.8",
|
||||
"typedoc-neo-theme": "^1.0.10",
|
||||
"typedoc-plugin-external-module-name": "^4.0.3",
|
||||
"typescript": "^3.9.7",
|
||||
"uglifyjs-webpack-plugin": "^2.2.0",
|
||||
"webpack": "^4.44.1",
|
||||
"webpack": "^4.44.2",
|
||||
"webpack-cli": "^3.3.12"
|
||||
},
|
||||
"main": "index.js",
|
||||
|
||||
6
sasjs-tests/package-lock.json
generated
6
sasjs-tests/package-lock.json
generated
@@ -1357,9 +1357,9 @@
|
||||
"integrity": "sha512-shAmDyaQC4H92APFoIaVDHCx5bStIocgvbwQyxPRrbUY20V1EYTbSDchWbuwlMG3V17cprZhA6+78JfB+3DTPw=="
|
||||
},
|
||||
"@sasjs/adapter": {
|
||||
"version": "1.3.13",
|
||||
"resolved": "https://registry.npmjs.org/@sasjs/adapter/-/adapter-1.3.13.tgz",
|
||||
"integrity": "sha512-dWcDxgY3FB7Yx1I5dPpeQeyJDu4lezhIFrjn6lbdwRhV15aqOt4l9o9qZP+VbgOXqyi9gN0Y+p+vs2chBDFQqg==",
|
||||
"version": "1.12.0",
|
||||
"resolved": "https://registry.npmjs.org/@sasjs/adapter/-/adapter-1.12.0.tgz",
|
||||
"integrity": "sha512-0uGQH9ynomWzdBaEujEtcR38q6V7LCgG0mrb1Wellv6cC/IHD3j6WfeZZAgtiMPeOSJjbCDBOlVnzC2TlBqJFw==",
|
||||
"requires": {
|
||||
"es6-promise": "^4.2.8",
|
||||
"form-data": "^3.0.0",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"homepage": ".",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@sasjs/adapter": "^1.3.13",
|
||||
"@sasjs/adapter": "^1.12.0",
|
||||
"@sasjs/test-framework": "^1.4.0",
|
||||
"@testing-library/jest-dom": "^4.2.4",
|
||||
"@testing-library/react": "^9.5.0",
|
||||
|
||||
@@ -13,7 +13,7 @@ const defaultConfig: SASjsConfig = {
|
||||
};
|
||||
|
||||
const customConfig = {
|
||||
serverUrl: "url",
|
||||
serverUrl: "http://url.com",
|
||||
pathSAS9: "sas9",
|
||||
pathSASViya: "viya",
|
||||
appLoc: "/Public/seedapp",
|
||||
|
||||
@@ -47,6 +47,16 @@ const getLargeObjectData = () => {
|
||||
export const sendArrTests = (adapter: SASjs): TestSuite => ({
|
||||
name: "sendArr",
|
||||
tests: [
|
||||
{
|
||||
title: "Absolute paths",
|
||||
description: "Should work with absolute paths to SAS jobs",
|
||||
test: () => {
|
||||
return adapter.request("/Public/app/common/sendArr", stringData);
|
||||
},
|
||||
assertion: (res: any) => {
|
||||
return res.table1[0][0] === stringData.table1[0].col1;
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Single string value",
|
||||
description: "Should send an array with a single string value",
|
||||
@@ -78,7 +88,7 @@ export const sendArrTests = (adapter: SASjs): TestSuite => ({
|
||||
return adapter.request("common/sendArr", data).catch((e) => e);
|
||||
},
|
||||
assertion: (error: any) => {
|
||||
return !!error && !!error.MESSAGE;
|
||||
return !!error && !!error.body && !!error.body.message;
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -175,7 +185,7 @@ export const sendObjTests = (adapter: SASjs): TestSuite => ({
|
||||
};
|
||||
return adapter.request("common/sendObj", invalidData).catch((e) => e);
|
||||
},
|
||||
assertion: (error: any) => !!error && !!error.MESSAGE
|
||||
assertion: (error: any) => !!error && !!error.body && !!error.body.message
|
||||
},
|
||||
{
|
||||
title: "Single string value",
|
||||
@@ -209,7 +219,7 @@ export const sendObjTests = (adapter: SASjs): TestSuite => ({
|
||||
.catch((e) => e);
|
||||
},
|
||||
assertion: (error: any) => {
|
||||
return !!error && !!error.MESSAGE;
|
||||
return !!error && !!error.body && !!error.body.message;
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -3,20 +3,21 @@ import {
|
||||
parseAndSubmitAuthorizeForm,
|
||||
convertToCSV,
|
||||
makeRequest,
|
||||
isRelativePath,
|
||||
isUri,
|
||||
isUrl
|
||||
} from './utils'
|
||||
import * as NodeFormData from 'form-data'
|
||||
import * as path from 'path'
|
||||
import {
|
||||
Job,
|
||||
Session,
|
||||
Context,
|
||||
Folder,
|
||||
CsrfToken,
|
||||
EditContextInput
|
||||
EditContextInput,
|
||||
ErrorResponse,
|
||||
JobDefinition
|
||||
} from './types'
|
||||
import { JobDefinition } from './types/JobDefinition'
|
||||
import { formatDataForRequest } from './utils/formatDataForRequest'
|
||||
import { SessionManager } from './SessionManager'
|
||||
|
||||
@@ -29,35 +30,34 @@ export class SASViyaApiClient {
|
||||
private serverUrl: string,
|
||||
private rootFolderName: string,
|
||||
private contextName: string,
|
||||
private setCsrfToken: (csrfToken: CsrfToken) => void,
|
||||
private rootFolderMap = new Map<string, Job[]>()
|
||||
private setCsrfToken: (csrfToken: CsrfToken) => void
|
||||
) {
|
||||
if (!rootFolderName) {
|
||||
throw new Error('Root folder must be provided.')
|
||||
}
|
||||
|
||||
if (serverUrl) isUrl(serverUrl)
|
||||
}
|
||||
|
||||
private csrfToken: CsrfToken | null = null
|
||||
private rootFolder: Folder | null = null
|
||||
private fileUploadCsrfToken: CsrfToken | null = null
|
||||
private sessionManager = new SessionManager(
|
||||
this.serverUrl,
|
||||
this.contextName,
|
||||
this.setCsrfToken
|
||||
)
|
||||
private isForceDeploy: boolean = false
|
||||
private folderMap = new Map<string, Job[]>()
|
||||
|
||||
/**
|
||||
* Returns a map containing the directory structure in the currently set root folder.
|
||||
* Returns a list of jobs in the currently set root folder.
|
||||
*/
|
||||
public async getAppLocMap() {
|
||||
if (this.rootFolderMap.size) {
|
||||
return this.rootFolderMap
|
||||
public async getJobsInFolder(folderPath: string) {
|
||||
const path = isRelativePath(folderPath)
|
||||
? `${this.rootFolderName}/${folderPath}`
|
||||
: folderPath
|
||||
if (this.folderMap.get(path)) {
|
||||
return this.folderMap.get(path)
|
||||
}
|
||||
|
||||
this.populateRootFolderMap()
|
||||
return this.rootFolderMap
|
||||
await this.populateFolderMap(path)
|
||||
return this.folderMap.get(path)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -192,7 +192,7 @@ export class SASViyaApiClient {
|
||||
}
|
||||
|
||||
const { result: contexts } = await this.request<{ items: Context[] }>(
|
||||
`${this.serverUrl}/compute/contexts`,
|
||||
`${this.serverUrl}/compute/contexts?limit=10000`,
|
||||
{ headers }
|
||||
)
|
||||
const executionContext =
|
||||
@@ -387,7 +387,7 @@ export class SASViyaApiClient {
|
||||
|
||||
/**
|
||||
* Executes code on the current SAS Viya server.
|
||||
* @param fileName - a name for the file being submitted for execution.
|
||||
* @param jobPath - the path to the file being submitted for execution.
|
||||
* @param linesOfCode - an array of code lines to execute.
|
||||
* @param contextName - the context to execute the code in.
|
||||
* @param accessToken - an access token for an authorized user.
|
||||
@@ -398,7 +398,7 @@ export class SASViyaApiClient {
|
||||
* @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).
|
||||
*/
|
||||
public async executeScript(
|
||||
jobName: string,
|
||||
jobPath: string,
|
||||
linesOfCode: string[],
|
||||
contextName: string,
|
||||
accessToken?: string,
|
||||
@@ -436,13 +436,21 @@ export class SASViyaApiClient {
|
||||
jobArguments['_DEBUG'] = 131
|
||||
}
|
||||
|
||||
const fileName = `exec-${
|
||||
jobName.includes('/') ? jobName.split('/')[1] : jobName
|
||||
}`
|
||||
let fileName
|
||||
if (isRelativePath(jobPath)) {
|
||||
fileName = `exec-${
|
||||
jobPath.includes('/') ? jobPath.split('/')[1] : jobPath
|
||||
}`
|
||||
} else {
|
||||
const jobPathParts = jobPath.split('/')
|
||||
fileName = jobPathParts.pop()
|
||||
}
|
||||
|
||||
let jobVariables: any = {
|
||||
SYS_JES_JOB_URI: '',
|
||||
_program: this.rootFolderName + '/' + jobName
|
||||
_program: isRelativePath(jobPath)
|
||||
? this.rootFolderName + '/' + jobPath
|
||||
: jobPath
|
||||
}
|
||||
|
||||
let files: any[] = []
|
||||
@@ -534,9 +542,30 @@ export class SASViyaApiClient {
|
||||
`${this.serverUrl}${resultLink}`,
|
||||
{ headers },
|
||||
'text'
|
||||
).catch((e) => ({
|
||||
result: JSON.stringify(e)
|
||||
}))
|
||||
).catch(async (e) => {
|
||||
if (e && e.status === 404) {
|
||||
if (logLink) {
|
||||
log = await this.request<any>(
|
||||
`${this.serverUrl}${logLink.href}/content?limit=10000`,
|
||||
{
|
||||
headers
|
||||
}
|
||||
).then((res: any) =>
|
||||
res.result.items.map((i: any) => i.line).join('\n')
|
||||
)
|
||||
|
||||
return Promise.reject(
|
||||
new ErrorResponse('Job execution failed', {
|
||||
status: 500,
|
||||
body: log
|
||||
})
|
||||
)
|
||||
}
|
||||
}
|
||||
return {
|
||||
result: JSON.stringify(e)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
await this.sessionManager.clearSession(executionSessionId, accessToken)
|
||||
@@ -545,7 +574,7 @@ export class SASViyaApiClient {
|
||||
} catch (e) {
|
||||
if (e && e.status === 404) {
|
||||
return this.executeScript(
|
||||
jobName,
|
||||
jobPath,
|
||||
linesOfCode,
|
||||
contextName,
|
||||
accessToken,
|
||||
@@ -662,8 +691,11 @@ export class SASViyaApiClient {
|
||||
createFolderRequest
|
||||
)
|
||||
|
||||
// updates rootFolderMap with newly created folder.
|
||||
await this.populateRootFolderMap(accessToken)
|
||||
// update folder map with newly created folder.
|
||||
await this.populateFolderMap(
|
||||
`${parentFolderPath}/${folderName}`,
|
||||
accessToken
|
||||
)
|
||||
return createFolderResponse
|
||||
}
|
||||
|
||||
@@ -892,30 +924,51 @@ export class SASViyaApiClient {
|
||||
data?: any,
|
||||
accessToken?: string
|
||||
) {
|
||||
if (!this.rootFolder) {
|
||||
await this.populateRootFolder(accessToken)
|
||||
}
|
||||
if (!this.rootFolder) {
|
||||
throw new Error(`Root folder was not found.`)
|
||||
}
|
||||
if (!this.rootFolderMap.size) {
|
||||
await this.populateRootFolderMap(accessToken)
|
||||
}
|
||||
if (!this.rootFolderMap.size) {
|
||||
if (isRelativePath(sasJob) && !this.rootFolderName) {
|
||||
throw new Error(
|
||||
`The job '${sasJob}' was not found in '${this.rootFolderName}'.`
|
||||
'Relative paths cannot be used without specifying a root folder name'
|
||||
)
|
||||
}
|
||||
|
||||
if (isRelativePath(sasJob)) {
|
||||
const folderName = sasJob.split('/')[0]
|
||||
await this.populateFolderMap(
|
||||
`${this.rootFolderName}/${folderName}`,
|
||||
accessToken
|
||||
)
|
||||
|
||||
if (!this.folderMap.get(`${this.rootFolderName}/${folderName}`)) {
|
||||
throw new Error(
|
||||
`The folder '${folderName}' was not found at '${this.serverUrl}/${this.rootFolderName}'`
|
||||
)
|
||||
}
|
||||
} else {
|
||||
const folderPathParts = sasJob.split('/')
|
||||
folderPathParts.pop()
|
||||
const folderPath = folderPathParts.join('/')
|
||||
await this.populateFolderMap(folderPath, accessToken)
|
||||
}
|
||||
|
||||
const headers: any = { 'Content-Type': 'application/json' }
|
||||
if (!!accessToken) {
|
||||
headers.Authorization = `Bearer ${accessToken}`
|
||||
}
|
||||
|
||||
const folderName = sasJob.split('/')[0]
|
||||
const jobName = sasJob.split('/')[1]
|
||||
const jobFolder = this.rootFolderMap.get(folderName)
|
||||
const jobToExecute = jobFolder?.find((item) => item.name === jobName)
|
||||
let jobToExecute
|
||||
if (isRelativePath(sasJob)) {
|
||||
const folderName = sasJob.split('/')[0]
|
||||
const jobName = sasJob.split('/')[1]
|
||||
const jobFolder = this.folderMap.get(
|
||||
`${this.rootFolderName}/${folderName}`
|
||||
)
|
||||
jobToExecute = jobFolder?.find((item) => item.name === jobName)
|
||||
} else {
|
||||
const folderPathParts = sasJob.split('/')
|
||||
const jobName = folderPathParts.pop()
|
||||
const folderPath = folderPathParts.join('/')
|
||||
const jobFolder = this.folderMap.get(folderPath)
|
||||
jobToExecute = jobFolder?.find((item) => item.name === jobName)
|
||||
}
|
||||
|
||||
if (!jobToExecute) {
|
||||
throw new Error(`Job was not found.`)
|
||||
@@ -957,8 +1010,8 @@ export class SASViyaApiClient {
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a job via the SAS Viya Job Execution API.
|
||||
* @param sasJob - the relative path to the job.
|
||||
* Executes a job via the SAS Viya Job Execution API
|
||||
* @param sasJob - the relative or absolute path to the job.
|
||||
* @param contextName - the name of the context where the job is to be executed.
|
||||
* @param debug - sets the _debug flag in the job arguments.
|
||||
* @param data - any data to be passed in as input to the job.
|
||||
@@ -971,20 +1024,34 @@ export class SASViyaApiClient {
|
||||
data?: any,
|
||||
accessToken?: string
|
||||
) {
|
||||
if (!this.rootFolder) {
|
||||
await this.populateRootFolder(accessToken)
|
||||
if (isRelativePath(sasJob) && !this.rootFolderName) {
|
||||
throw new Error(
|
||||
'Relative paths cannot be used without specifying a root folder name.'
|
||||
)
|
||||
}
|
||||
|
||||
if (!this.rootFolder) {
|
||||
throw new Error(`Root folder was not found.`)
|
||||
}
|
||||
if (!this.rootFolderMap.size) {
|
||||
await this.populateRootFolderMap(accessToken)
|
||||
}
|
||||
if (!this.rootFolderMap.size) {
|
||||
throw new Error(
|
||||
`The job '${sasJob}' was not found in folder '${this.rootFolderName}'.`
|
||||
if (isRelativePath(sasJob)) {
|
||||
const folderName = sasJob.split('/')[0]
|
||||
await this.populateFolderMap(
|
||||
`${this.rootFolderName}/${folderName}`,
|
||||
accessToken
|
||||
)
|
||||
|
||||
if (!this.folderMap.get(`${this.rootFolderName}/${folderName}`)) {
|
||||
throw new Error(
|
||||
`The folder '${folderName}' was not found at '${this.serverUrl}/${this.rootFolderName}'.`
|
||||
)
|
||||
}
|
||||
} else {
|
||||
const folderPathParts = sasJob.split('/')
|
||||
folderPathParts.pop()
|
||||
const folderPath = folderPathParts.join('/')
|
||||
await this.populateFolderMap(folderPath, accessToken)
|
||||
if (!this.folderMap.get(folderPath)) {
|
||||
throw new Error(
|
||||
`The folder '${folderPath}' was not found at '${this.serverUrl}'.`
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
let files: any[] = []
|
||||
@@ -992,124 +1059,128 @@ export class SASViyaApiClient {
|
||||
files = await this.uploadTables(data, accessToken)
|
||||
}
|
||||
|
||||
const jobName = path.basename(sasJob)
|
||||
const jobFolder = sasJob.replace(`/${jobName}`, '')
|
||||
const allJobsInFolder = this.rootFolderMap.get(jobFolder.replace('/', ''))
|
||||
|
||||
if (allJobsInFolder) {
|
||||
const jobSpec = allJobsInFolder.find((j: Job) => j.name === jobName)
|
||||
|
||||
if (!jobSpec) {
|
||||
throw new Error('Job was not found.')
|
||||
}
|
||||
|
||||
const jobDefinitionLink = jobSpec?.links.find(
|
||||
(l) => l.rel === 'getResource'
|
||||
)?.href
|
||||
|
||||
if (!jobDefinitionLink) {
|
||||
throw new Error('Job definition URI was not found.')
|
||||
}
|
||||
|
||||
const requestInfo: any = {
|
||||
method: 'GET'
|
||||
}
|
||||
const headers: any = { 'Content-Type': 'application/json' }
|
||||
|
||||
if (!!accessToken) {
|
||||
headers.Authorization = `Bearer ${accessToken}`
|
||||
}
|
||||
|
||||
requestInfo.headers = headers
|
||||
|
||||
const { result: jobDefinition } = await this.request<Job>(
|
||||
`${this.serverUrl}${jobDefinitionLink}`,
|
||||
requestInfo
|
||||
)
|
||||
|
||||
const jobArguments: { [key: string]: any } = {
|
||||
_contextName: contextName,
|
||||
_program: `${this.rootFolderName}/${sasJob}`,
|
||||
_webin_file_count: files.length,
|
||||
_OMITJSONLISTING: true,
|
||||
_OMITJSONLOG: true,
|
||||
_OMITSESSIONRESULTS: true,
|
||||
_OMITTEXTLISTING: true,
|
||||
_OMITTEXTLOG: true
|
||||
}
|
||||
|
||||
if (debug) {
|
||||
jobArguments['_OMITTEXTLOG'] = 'false'
|
||||
jobArguments['_OMITSESSIONRESULTS'] = 'false'
|
||||
jobArguments['_DEBUG'] = 131
|
||||
}
|
||||
|
||||
files.forEach((fileInfo, index) => {
|
||||
jobArguments[
|
||||
`_webin_fileuri${index + 1}`
|
||||
] = `/files/files/${fileInfo.file.id}`
|
||||
jobArguments[`_webin_name${index + 1}`] = fileInfo.tableName
|
||||
})
|
||||
|
||||
const postJobRequest = {
|
||||
method: 'POST',
|
||||
headers,
|
||||
body: JSON.stringify({
|
||||
name: `exec-${jobName}`,
|
||||
description: 'Powered by SASjs',
|
||||
jobDefinition,
|
||||
arguments: jobArguments
|
||||
})
|
||||
}
|
||||
const { result: postedJob, etag } = await this.request<Job>(
|
||||
`${this.serverUrl}/jobExecution/jobs?_action=wait`,
|
||||
postJobRequest
|
||||
)
|
||||
const jobStatus = await this.pollJobState(
|
||||
postedJob,
|
||||
etag,
|
||||
accessToken,
|
||||
true
|
||||
)
|
||||
const { result: currentJob } = await this.request<Job>(
|
||||
`${this.serverUrl}/jobExecution/jobs/${postedJob.id}`,
|
||||
{ headers }
|
||||
)
|
||||
|
||||
let jobResult, log
|
||||
if (jobStatus === 'failed') {
|
||||
return Promise.reject(currentJob.error)
|
||||
}
|
||||
const resultLink = currentJob.results['_webout.json']
|
||||
const logLink = currentJob.links.find((l) => l.rel === 'log')
|
||||
if (resultLink) {
|
||||
jobResult = await this.request<any>(
|
||||
`${this.serverUrl}${resultLink}/content`,
|
||||
{ headers },
|
||||
'text'
|
||||
)
|
||||
}
|
||||
if (debug && logLink) {
|
||||
log = await this.request<any>(
|
||||
`${this.serverUrl}${logLink.href}/content`,
|
||||
{
|
||||
headers
|
||||
}
|
||||
).then((res: any) =>
|
||||
res.result.items.map((i: any) => i.line).join('\n')
|
||||
)
|
||||
}
|
||||
return { result: jobResult?.result, log }
|
||||
let jobToExecute: Job | undefined
|
||||
let jobName: string | undefined
|
||||
let jobPath: string | undefined
|
||||
if (isRelativePath(sasJob)) {
|
||||
const folderName = sasJob.split('/')[0]
|
||||
jobName = sasJob.split('/')[1]
|
||||
jobPath = `${this.rootFolderName}/${folderName}`
|
||||
const jobFolder = this.folderMap.get(jobPath)
|
||||
jobToExecute = jobFolder?.find((item) => item.name === jobName)
|
||||
} else {
|
||||
throw new Error(
|
||||
`The job '${sasJob}' was not found in folder '${this.rootFolderName}'.`
|
||||
const folderPathParts = sasJob.split('/')
|
||||
jobName = folderPathParts.pop()
|
||||
jobPath = folderPathParts.join('/')
|
||||
const jobFolder = this.folderMap.get(jobPath)
|
||||
jobToExecute = jobFolder?.find((item) => item.name === jobName)
|
||||
}
|
||||
|
||||
if (!jobToExecute) {
|
||||
throw new Error(`The job ${sasJob} was not found.`)
|
||||
}
|
||||
const jobDefinitionLink = jobToExecute?.links.find(
|
||||
(l) => l.rel === 'getResource'
|
||||
)?.href
|
||||
const requestInfo: any = {
|
||||
method: 'GET'
|
||||
}
|
||||
const headers: any = { 'Content-Type': 'application/json' }
|
||||
|
||||
if (!!accessToken) {
|
||||
headers.Authorization = `Bearer ${accessToken}`
|
||||
}
|
||||
|
||||
requestInfo.headers = headers
|
||||
|
||||
const { result: jobDefinition } = await this.request<Job>(
|
||||
`${this.serverUrl}${jobDefinitionLink}`,
|
||||
requestInfo
|
||||
)
|
||||
|
||||
const jobArguments: { [key: string]: any } = {
|
||||
_contextName: contextName,
|
||||
_program: `${jobPath}/${jobName}`,
|
||||
_webin_file_count: files.length,
|
||||
_OMITJSONLISTING: true,
|
||||
_OMITJSONLOG: true,
|
||||
_OMITSESSIONRESULTS: true,
|
||||
_OMITTEXTLISTING: true,
|
||||
_OMITTEXTLOG: true
|
||||
}
|
||||
|
||||
if (debug) {
|
||||
jobArguments['_OMITTEXTLOG'] = 'false'
|
||||
jobArguments['_OMITSESSIONRESULTS'] = 'false'
|
||||
jobArguments['_DEBUG'] = 131
|
||||
}
|
||||
|
||||
files.forEach((fileInfo, index) => {
|
||||
jobArguments[
|
||||
`_webin_fileuri${index + 1}`
|
||||
] = `/files/files/${fileInfo.file.id}`
|
||||
jobArguments[`_webin_name${index + 1}`] = fileInfo.tableName
|
||||
})
|
||||
|
||||
const postJobRequest = {
|
||||
method: 'POST',
|
||||
headers,
|
||||
body: JSON.stringify({
|
||||
name: `exec-${jobName}`,
|
||||
description: 'Powered by SASjs',
|
||||
jobDefinition,
|
||||
arguments: jobArguments
|
||||
})
|
||||
}
|
||||
const { result: postedJob, etag } = await this.request<Job>(
|
||||
`${this.serverUrl}/jobExecution/jobs?_action=wait`,
|
||||
postJobRequest
|
||||
)
|
||||
const jobStatus = await this.pollJobState(
|
||||
postedJob,
|
||||
etag,
|
||||
accessToken,
|
||||
true
|
||||
)
|
||||
const { result: currentJob } = await this.request<Job>(
|
||||
`${this.serverUrl}/jobExecution/jobs/${postedJob.id}`,
|
||||
{ headers }
|
||||
)
|
||||
|
||||
let jobResult
|
||||
let log
|
||||
if (jobStatus === 'failed') {
|
||||
return Promise.reject(currentJob.error)
|
||||
}
|
||||
const resultLink = currentJob.results['_webout.json']
|
||||
const logLink = currentJob.links.find((l) => l.rel === 'log')
|
||||
if (resultLink) {
|
||||
jobResult = await this.request<any>(
|
||||
`${this.serverUrl}${resultLink}/content`,
|
||||
{ headers },
|
||||
'text'
|
||||
)
|
||||
}
|
||||
if (debug && logLink) {
|
||||
log = await this.request<any>(
|
||||
`${this.serverUrl}${logLink.href}/content`,
|
||||
{
|
||||
headers
|
||||
}
|
||||
).then((res: any) => res.result.items.map((i: any) => i.line).join('\n'))
|
||||
}
|
||||
return { result: jobResult?.result, log }
|
||||
}
|
||||
|
||||
private async populateRootFolderMap(accessToken?: string) {
|
||||
const allItems = new Map<string, Job[]>()
|
||||
const url = '/folders/folders/@item?path=' + this.rootFolderName
|
||||
private async populateFolderMap(folderPath: string, accessToken?: string) {
|
||||
const path = isRelativePath(folderPath)
|
||||
? `${this.rootFolderName}/${folderPath}`
|
||||
: folderPath
|
||||
if (this.folderMap.get(path)) {
|
||||
return
|
||||
}
|
||||
|
||||
const url = '/folders/folders/@item?path=' + path
|
||||
const requestInfo: any = {
|
||||
method: 'GET'
|
||||
}
|
||||
@@ -1121,9 +1192,7 @@ export class SASViyaApiClient {
|
||||
requestInfo
|
||||
)
|
||||
if (!folder) {
|
||||
throw new Error(
|
||||
`Not able to populate root folder map, because folder '${this.rootFolderName}' does not exist.`
|
||||
)
|
||||
throw new Error(`The path ${path} does not exist on ${this.serverUrl}`)
|
||||
}
|
||||
const { result: members } = await this.request<{ items: any[] }>(
|
||||
`${this.serverUrl}/folders/folders/${folder.id}/members`,
|
||||
@@ -1131,55 +1200,7 @@ export class SASViyaApiClient {
|
||||
)
|
||||
|
||||
const itemsAtRoot = members.items
|
||||
allItems.set('', itemsAtRoot)
|
||||
const subfolderRequests = members.items
|
||||
.filter((i: any) => i.contentType === 'folder')
|
||||
.map(async (member: any) => {
|
||||
const subFolderUrl =
|
||||
'/folders/folders/@item?path=' +
|
||||
this.rootFolderName +
|
||||
'/' +
|
||||
member.name
|
||||
const { result: memberDetail } = await this.request<Folder>(
|
||||
`${this.serverUrl}${subFolderUrl}`,
|
||||
requestInfo
|
||||
)
|
||||
|
||||
const membersLink = memberDetail.links.find(
|
||||
(l: any) => l.rel === 'members'
|
||||
)
|
||||
|
||||
const { result: memberContents } = await this.request<{ items: any[] }>(
|
||||
`${this.serverUrl}${membersLink!.href}`,
|
||||
requestInfo
|
||||
)
|
||||
const itemsInFolder = memberContents.items as any[]
|
||||
allItems.set(member.name, itemsInFolder)
|
||||
return itemsInFolder
|
||||
})
|
||||
await Promise.all(subfolderRequests)
|
||||
|
||||
this.rootFolderMap = allItems
|
||||
}
|
||||
|
||||
private async populateRootFolder(accessToken?: string) {
|
||||
const url = '/folders/folders/@item?path=' + this.rootFolderName
|
||||
const requestInfo: RequestInit = {
|
||||
method: 'GET'
|
||||
}
|
||||
if (accessToken) {
|
||||
requestInfo.headers = { Authorization: `Bearer ${accessToken}` }
|
||||
}
|
||||
let error
|
||||
const rootFolder = await this.request<Folder>(
|
||||
`${this.serverUrl}${url}`,
|
||||
requestInfo
|
||||
)
|
||||
|
||||
this.rootFolder = rootFolder?.result || null
|
||||
if (error) {
|
||||
throw new Error(JSON.stringify(error))
|
||||
}
|
||||
this.folderMap.set(path, itemsAtRoot)
|
||||
}
|
||||
|
||||
private async pollJobState(
|
||||
@@ -1321,7 +1342,9 @@ export class SASViyaApiClient {
|
||||
|
||||
const uploadResponse = await this.request<any>(
|
||||
`${this.serverUrl}/files/files#rawUpload`,
|
||||
createFileRequest
|
||||
createFileRequest,
|
||||
'json',
|
||||
'fileUpload'
|
||||
)
|
||||
|
||||
uploadedFiles.push({ tableName, file: uploadResponse.result })
|
||||
@@ -1476,22 +1499,36 @@ export class SASViyaApiClient {
|
||||
this.setCsrfToken(csrfToken)
|
||||
}
|
||||
|
||||
setFileUploadCsrfToken = (csrfToken: CsrfToken) => {
|
||||
this.fileUploadCsrfToken = csrfToken
|
||||
}
|
||||
|
||||
private async request<T>(
|
||||
url: string,
|
||||
options: RequestInit,
|
||||
contentType: 'text' | 'json' = 'json'
|
||||
contentType: 'text' | 'json' = 'json',
|
||||
type: 'fileUpload' | 'other' = 'other'
|
||||
) {
|
||||
if (this.csrfToken) {
|
||||
options.headers = {
|
||||
...options.headers,
|
||||
[this.csrfToken.headerName]: this.csrfToken.value
|
||||
const callback =
|
||||
type === 'fileUpload'
|
||||
? this.setFileUploadCsrfToken
|
||||
: this.setCsrfTokenLocal
|
||||
|
||||
if (type === 'other') {
|
||||
if (this.csrfToken) {
|
||||
options.headers = {
|
||||
...options.headers,
|
||||
[this.csrfToken.headerName]: this.csrfToken.value
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (this.fileUploadCsrfToken) {
|
||||
options.headers = {
|
||||
...options.headers,
|
||||
[this.fileUploadCsrfToken.headerName]: this.fileUploadCsrfToken.value
|
||||
}
|
||||
}
|
||||
}
|
||||
return await makeRequest<T>(
|
||||
url,
|
||||
options,
|
||||
this.setCsrfTokenLocal,
|
||||
contentType
|
||||
)
|
||||
return await makeRequest<T>(url, options, callback, contentType)
|
||||
}
|
||||
}
|
||||
|
||||
44
src/SASjs.ts
44
src/SASjs.ts
@@ -21,7 +21,8 @@ import {
|
||||
parseGeneratedCode,
|
||||
parseWeboutResponse,
|
||||
needsRetry,
|
||||
asyncForEach
|
||||
asyncForEach,
|
||||
isRelativePath
|
||||
} from './utils'
|
||||
import {
|
||||
SASjsConfig,
|
||||
@@ -501,8 +502,6 @@ export default class SASjs {
|
||||
...config
|
||||
}
|
||||
|
||||
sasJob = sasJob.startsWith('/') ? sasJob.replace('/', '') : sasJob
|
||||
|
||||
if (config.serverType === ServerType.SASViya && config.contextName) {
|
||||
if (config.useComputeApi) {
|
||||
requestResponse = await this.executeJobViaComputeApi(
|
||||
@@ -794,11 +793,15 @@ export default class SASjs {
|
||||
SASjob: sasJob,
|
||||
data
|
||||
}
|
||||
const program = config.appLoc
|
||||
? config.appLoc.replace(/\/?$/, '/') + sasJob.replace(/^\//, '')
|
||||
const program = isRelativePath(sasJob)
|
||||
? config.appLoc
|
||||
? config.appLoc.replace(/\/?$/, '/') + sasJob.replace(/^\//, '')
|
||||
: sasJob
|
||||
: sasJob
|
||||
const jobUri =
|
||||
config.serverType === 'SASVIYA' ? await this.getJobUri(sasJob) : ''
|
||||
config.serverType === ServerType.SASViya
|
||||
? await this.getJobUri(sasJob)
|
||||
: ''
|
||||
const apiUrl = `${config.serverUrl}${this.jobsPath}/?${
|
||||
jobUri.length > 0
|
||||
? '__program=' + program + '&_job=' + jobUri
|
||||
@@ -1091,21 +1094,26 @@ export default class SASjs {
|
||||
|
||||
private async getJobUri(sasJob: string) {
|
||||
if (!this.sasViyaApiClient) return ''
|
||||
const jobMap: any = await this.sasViyaApiClient.getAppLocMap()
|
||||
let uri = ''
|
||||
|
||||
if (jobMap.size) {
|
||||
const jobKey = sasJob.split('/')[0]
|
||||
const jobName = sasJob.split('/')[1]
|
||||
let folderPath
|
||||
let jobName: string
|
||||
if (isRelativePath(sasJob)) {
|
||||
folderPath = sasJob.split('/')[0]
|
||||
jobName = sasJob.split('/')[1]
|
||||
} else {
|
||||
const folderPathParts = sasJob.split('/')
|
||||
jobName = folderPathParts.pop() || ''
|
||||
folderPath = folderPathParts.join('/')
|
||||
}
|
||||
|
||||
const locJobs = jobMap.get(jobKey)
|
||||
if (locJobs) {
|
||||
const job = locJobs.find(
|
||||
(el: any) => el.name === jobName && el.contentType === 'jobDefinition'
|
||||
)
|
||||
if (job) {
|
||||
uri = job.uri
|
||||
}
|
||||
const locJobs = await this.sasViyaApiClient.getJobsInFolder(folderPath)
|
||||
if (locJobs) {
|
||||
const job = locJobs.find(
|
||||
(el: any) => el.name === jobName && el.contentType === 'jobDefinition'
|
||||
)
|
||||
if (job) {
|
||||
uri = job.uri
|
||||
}
|
||||
}
|
||||
return uri
|
||||
|
||||
@@ -78,7 +78,7 @@ export class SessionManager {
|
||||
if (!this.currentContext) {
|
||||
const { result: contexts } = await this.request<{
|
||||
items: Context[]
|
||||
}>(`${this.serverUrl}/compute/contexts`, {
|
||||
}>(`${this.serverUrl}/compute/contexts?limit=10000`, {
|
||||
headers: this.getHeaders(accessToken)
|
||||
})
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { ServerType } from './ServerType'
|
||||
|
||||
/**
|
||||
* Specifies the configuration for the SASjs instance.
|
||||
*
|
||||
* Specifies the configuration for the SASjs instance - eg where and how to
|
||||
* connect to SAS.
|
||||
*/
|
||||
export class SASjsConfig {
|
||||
/**
|
||||
@@ -11,11 +11,24 @@ export class SASjsConfig {
|
||||
* streamed.
|
||||
*/
|
||||
serverUrl: string = ''
|
||||
/**
|
||||
* The location of the Stored Process Web Application. By default the adapter
|
||||
* will use '/SASStoredProcess/do' on SAS 9.
|
||||
*/
|
||||
pathSAS9: string = ''
|
||||
/**
|
||||
* The location of the Job Execution Web Application. By default the adapter
|
||||
* will use '/SASJobExecution' on SAS Viya.
|
||||
*/
|
||||
pathSASViya: string = ''
|
||||
/**
|
||||
* The appLoc is the parent folder under which the SAS services (STPs or Job
|
||||
* Execution Services) are stored.
|
||||
* Execution Services) are stored. We recommend that each app is stored in
|
||||
* a dedicated parent folder (the appLoc) and the services are grouped inside
|
||||
* subfolders within the appLoc - allowing functionality to be restricted
|
||||
* according to those groups at backend.
|
||||
* When using appLoc, the paths provided in the `request` function should be
|
||||
* _without_ a leading slash (/).
|
||||
*/
|
||||
appLoc: string = ''
|
||||
/**
|
||||
@@ -26,6 +39,22 @@ export class SASjsConfig {
|
||||
* Set to `true` to enable additional debugging.
|
||||
*/
|
||||
debug: boolean = true
|
||||
/**
|
||||
* The name of the compute context to use when calling the Viya APIs directly.
|
||||
* Example value: 'SAS Job Execution compute context'
|
||||
* If set to missing or empty, and useComputeApi is true, the adapter will use
|
||||
* the JES APIs. If provided, the Job Code will be executed in pooled
|
||||
* compute sessions on this named context.
|
||||
*/
|
||||
contextName: string = ''
|
||||
/**
|
||||
* Set to `false` to use the Job Execution Web Service. To enhance VIYA
|
||||
* performance, set to `true` and provide a `contextName` on which to run
|
||||
* the code. When running on a named context, the code executes under the
|
||||
* user identity. When running as a Job Execution service, the code runs
|
||||
* under the identity in the JES context. If no `contextName` is provided,
|
||||
* and `useComputeApi` is `true`, then the service will run as a Job, except
|
||||
* triggered using the APIs instead of the Job Execution Web Service broker.
|
||||
*/
|
||||
useComputeApi = false
|
||||
}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
export * from './Context'
|
||||
export * from './CsrfToken'
|
||||
export * from './ErrorResponse'
|
||||
export * from './Folder'
|
||||
export * from './Job'
|
||||
export * from './JobDefinition'
|
||||
export * from './JobResult'
|
||||
export * from './Link'
|
||||
export * from './SASjsConfig'
|
||||
export * from './SASjsRequest'
|
||||
@@ -9,4 +12,3 @@ export * from './SASjsWaitingRequest'
|
||||
export * from './ServerType'
|
||||
export * from './Session'
|
||||
export * from './UploadFile'
|
||||
export * from './ErrorResponse'
|
||||
|
||||
@@ -4,6 +4,9 @@ export * from './convertToCsv'
|
||||
export * from './isAuthorizeFormRequired'
|
||||
export * from './isLoginRequired'
|
||||
export * from './isLoginSuccess'
|
||||
export * from './isRelativePath'
|
||||
export * from './isUri'
|
||||
export * from './isUrl'
|
||||
export * from './makeRequest'
|
||||
export * from './needsRetry'
|
||||
export * from './parseAndSubmitAuthorizeForm'
|
||||
@@ -13,5 +16,3 @@ export * from './parseSasViyaLog'
|
||||
export * from './serialize'
|
||||
export * from './splitChunks'
|
||||
export * from './parseWeboutResponse'
|
||||
export * from './isUri'
|
||||
export * from './isUrl'
|
||||
|
||||
2
src/utils/isRelativePath.ts
Normal file
2
src/utils/isRelativePath.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export const isRelativePath = (uri: string): boolean =>
|
||||
!!uri && !uri.startsWith('/')
|
||||
@@ -1,49 +1,56 @@
|
||||
const path = require("path");
|
||||
const webpack = require("webpack");
|
||||
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
|
||||
const path = require('path')
|
||||
const webpack = require('webpack')
|
||||
const terserPlugin = require('terser-webpack-plugin')
|
||||
|
||||
const browserConfig = {
|
||||
entry: "./src/index.ts",
|
||||
devtool: "inline-source-map",
|
||||
mode: "development",
|
||||
entry: './src/index.ts',
|
||||
devtool: 'inline-source-map',
|
||||
mode: 'production',
|
||||
optimization: {
|
||||
minimize: false,
|
||||
minimizer: [
|
||||
new terserPlugin({
|
||||
cache: true,
|
||||
parallel: true,
|
||||
sourceMap: true,
|
||||
terserOptions: {}
|
||||
})
|
||||
]
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.ts?$/,
|
||||
use: "ts-loader",
|
||||
exclude: /node_modules/,
|
||||
},
|
||||
],
|
||||
use: 'ts-loader',
|
||||
exclude: /node_modules/
|
||||
}
|
||||
]
|
||||
},
|
||||
resolve: {
|
||||
extensions: [".ts", ".js"],
|
||||
extensions: ['.ts', '.js']
|
||||
},
|
||||
output: {
|
||||
filename: "index.js",
|
||||
path: path.resolve(__dirname, "build"),
|
||||
libraryTarget: "umd",
|
||||
library: "SASjs",
|
||||
filename: 'index.js',
|
||||
path: path.resolve(__dirname, 'build'),
|
||||
libraryTarget: 'umd',
|
||||
library: 'SASjs'
|
||||
},
|
||||
plugins: [
|
||||
new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /en/),
|
||||
new webpack.SourceMapDevToolPlugin({
|
||||
filename: null,
|
||||
exclude: [/node_modules/],
|
||||
test: /\.ts($|\?)/i,
|
||||
}),
|
||||
],
|
||||
};
|
||||
test: /\.ts($|\?)/i
|
||||
})
|
||||
]
|
||||
}
|
||||
|
||||
const nodeConfig = {
|
||||
...browserConfig,
|
||||
target: "node",
|
||||
target: 'node',
|
||||
output: {
|
||||
...browserConfig.output,
|
||||
path: path.resolve(__dirname, "build", "node"),
|
||||
},
|
||||
};
|
||||
path: path.resolve(__dirname, 'build', 'node')
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = [browserConfig, nodeConfig];
|
||||
module.exports = [browserConfig, nodeConfig]
|
||||
|
||||
Reference in New Issue
Block a user