@sasjs/adapter 3.7.14 → 3.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,5 +12,4 @@ export * from './Session';
12
12
  export * from './UploadFile';
13
13
  export * from './PollOptions';
14
14
  export * from './WriteStream';
15
- export * from './FileTree';
16
15
  export * from './ExecuteScript';
package/package.json CHANGED
@@ -72,12 +72,12 @@
72
72
  },
73
73
  "main": "index.js",
74
74
  "dependencies": {
75
- "@sasjs/utils": "2.36.1",
75
+ "@sasjs/utils": "2.42.0",
76
76
  "axios": "0.26.0",
77
77
  "axios-cookiejar-support": "1.0.1",
78
78
  "form-data": "4.0.0",
79
79
  "https": "1.0.0",
80
80
  "tough-cookie": "4.0.0"
81
81
  },
82
- "version": "3.7.14"
82
+ "version": "3.8.2"
83
83
  }
package/src/SASjs.ts CHANGED
@@ -5,8 +5,7 @@ import {
5
5
  EditContextInput,
6
6
  PollOptions,
7
7
  LoginMechanism,
8
- ExecutionQuery,
9
- FileTree
8
+ ExecutionQuery
10
9
  } from './types'
11
10
  import { SASViyaApiClient } from './SASViyaApiClient'
12
11
  import { SAS9ApiClient } from './SAS9ApiClient'
@@ -17,7 +16,8 @@ import {
17
16
  MacroVar,
18
17
  AuthConfig,
19
18
  ExtraResponseAttributes,
20
- SasAuthResponse
19
+ SasAuthResponse,
20
+ ServicePackSASjs
21
21
  } from '@sasjs/utils/types'
22
22
  import { RequestClient } from './request/RequestClient'
23
23
  import { SasjsRequestClient } from './request/SasjsRequestClient'
@@ -134,7 +134,7 @@ export default class SASjs {
134
134
 
135
135
  /**
136
136
  * Gets compute contexts.
137
- * @param accessToken - an access token for an authorized user.
137
+ * @param accessToken - an access token for an authorised user.
138
138
  */
139
139
  public async getComputeContexts(accessToken: string) {
140
140
  this.isMethodSupported('getComputeContexts', [ServerType.SasViya])
@@ -144,7 +144,7 @@ export default class SASjs {
144
144
 
145
145
  /**
146
146
  * Gets launcher contexts.
147
- * @param accessToken - an access token for an authorized user.
147
+ * @param accessToken - an access token for an authorised user.
148
148
  */
149
149
  public async getLauncherContexts(accessToken: string) {
150
150
  this.isMethodSupported('getLauncherContexts', [ServerType.SasViya])
@@ -163,7 +163,7 @@ export default class SASjs {
163
163
 
164
164
  /**
165
165
  * Gets executable compute contexts.
166
- * @param authConfig - an access token, refresh token, client and secret for an authorized user.
166
+ * @param authConfig - an access token, refresh token, client and secret for an authorised user.
167
167
  */
168
168
  public async getExecutableContexts(authConfig: AuthConfig) {
169
169
  this.isMethodSupported('getExecutableContexts', [ServerType.SasViya])
@@ -177,8 +177,8 @@ export default class SASjs {
177
177
  * @param launchContextName - the name of the launcher context used by the compute service.
178
178
  * @param sharedAccountId - the ID of the account to run the servers for this context as.
179
179
  * @param autoExecLines - the lines of code to execute during session initialization.
180
- * @param accessToken - an access token for an authorized user.
181
- * @param authorizedUsers - an optional list of authorized user IDs.
180
+ * @param accessToken - an access token for an authorised user.
181
+ * @param authorisedUsers - an optional list of authorised user IDs.
182
182
  */
183
183
  public async createComputeContext(
184
184
  contextName: string,
@@ -186,7 +186,7 @@ export default class SASjs {
186
186
  sharedAccountId: string,
187
187
  autoExecLines: string[],
188
188
  accessToken: string,
189
- authorizedUsers?: string[]
189
+ authorisedUsers?: string[]
190
190
  ) {
191
191
  this.isMethodSupported('createComputeContext', [ServerType.SasViya])
192
192
 
@@ -196,7 +196,7 @@ export default class SASjs {
196
196
  sharedAccountId,
197
197
  autoExecLines,
198
198
  accessToken,
199
- authorizedUsers
199
+ authorisedUsers
200
200
  )
201
201
  }
202
202
 
@@ -205,7 +205,7 @@ export default class SASjs {
205
205
  * @param contextName - the name of the context to be created.
206
206
  * @param description - the description of the context to be created.
207
207
  * @param launchType - launch type of the context to be created.
208
- * @param accessToken - an access token for an authorized user.
208
+ * @param accessToken - an access token for an authorised user.
209
209
  */
210
210
  public async createLauncherContext(
211
211
  contextName: string,
@@ -227,7 +227,7 @@ export default class SASjs {
227
227
  * Updates a compute context on the given server.
228
228
  * @param contextName - the original name of the context to be deleted.
229
229
  * @param editedContext - an object with the properties to be updated.
230
- * @param accessToken - an access token for an authorized user.
230
+ * @param accessToken - an access token for an authorised user.
231
231
  */
232
232
  public async editComputeContext(
233
233
  contextName: string,
@@ -246,7 +246,7 @@ export default class SASjs {
246
246
  /**
247
247
  * Deletes a compute context on the given server.
248
248
  * @param contextName - the name of the context to be deleted.
249
- * @param accessToken - an access token for an authorized user.
249
+ * @param accessToken - an access token for an authorised user.
250
250
  */
251
251
  public async deleteComputeContext(contextName: string, accessToken?: string) {
252
252
  this.isMethodSupported('deleteComputeContext', [ServerType.SasViya])
@@ -261,7 +261,7 @@ export default class SASjs {
261
261
  * Returns a JSON representation of a compute context.
262
262
  * @example: { "createdBy": "admin", "links": [...], "id": "ID", "version": 2, "name": "context1" }
263
263
  * @param contextName - the name of the context to return.
264
- * @param accessToken - an access token for an authorized user.
264
+ * @param accessToken - an access token for an authorised user.
265
265
  */
266
266
  public async getComputeContextByName(
267
267
  contextName: string,
@@ -278,7 +278,7 @@ export default class SASjs {
278
278
  /**
279
279
  * Returns a JSON representation of a compute context.
280
280
  * @param contextId - an id of the context to return.
281
- * @param accessToken - an access token for an authorized user.
281
+ * @param accessToken - an access token for an authorised user.
282
282
  */
283
283
  public async getComputeContextById(contextId: string, accessToken?: string) {
284
284
  this.isMethodSupported('getComputeContextById', [ServerType.SasViya])
@@ -888,20 +888,21 @@ export default class SASjs {
888
888
 
889
889
  /**
890
890
  * Creates the folders and services at the given location `appLoc` on the given server `serverUrl`.
891
- * @param members - the JSON specifying the folders and services to be created.
892
- * @param appLoc - the base folder in which to create the new folders and
893
- * services. If not provided, is taken from SASjsConfig.
894
- * @param authConfig - a valid client, secret, refresh and access tokens that are authorised to execute compute jobs.
891
+ * @param dataJson - the JSON specifying the folders and files to be created, can also includes
892
+ * appLoc, streamServiceName, streamWebFolder, streamLogo
893
+ * @param appLoc - (optional) the base folder in which to create the new folders and
894
+ * services. If not provided, is taken from SASjsConfig. Precedence will be of appLoc present in dataJson.
895
+ * @param authConfig - (optional) a valid client, secret, refresh and access tokens that are authorised to execute compute jobs.
895
896
  */
896
897
  public async deployToSASjs(
897
- members: FileTree,
898
+ dataJson: ServicePackSASjs,
898
899
  appLoc?: string,
899
900
  authConfig?: AuthConfig
900
901
  ) {
901
902
  if (!appLoc) {
902
903
  appLoc = this.sasjsConfig.appLoc
903
904
  }
904
- return await this.sasJSApiClient?.deploy(members, appLoc, authConfig)
905
+ return await this.sasJSApiClient?.deploy(dataJson, appLoc, authConfig)
905
906
  }
906
907
 
907
908
  public async executeJobSASjs(query: ExecutionQuery) {
@@ -972,7 +973,7 @@ export default class SASjs {
972
973
  /**
973
974
  * Fetches content of the log file
974
975
  * @param logUrl - url of the log file.
975
- * @param accessToken - an access token for an authorized user.
976
+ * @param accessToken - an access token for an authorised user.
976
977
  */
977
978
  public async fetchLogFileContent(logUrl: string, accessToken?: string) {
978
979
  return await this.requestClient!.get(logUrl, accessToken).then((res) => {
@@ -1094,13 +1095,8 @@ export default class SASjs {
1094
1095
  }
1095
1096
 
1096
1097
  if (this.sasjsConfig.serverType === ServerType.Sasjs) {
1097
- if (this.sasJSApiClient) {
1098
- this.sasJSApiClient.setConfig(this.sasjsConfig.serverUrl)
1099
- } else {
1100
- this.sasJSApiClient = new SASjsApiClient(
1101
- this.sasjsConfig.serverUrl,
1102
- this.requestClient
1103
- )
1098
+ if (!this.sasJSApiClient) {
1099
+ this.sasJSApiClient = new SASjsApiClient(this.requestClient)
1104
1100
  }
1105
1101
  }
1106
1102
 
@@ -1,5 +1,5 @@
1
- import { AuthConfig, ServerType } from '@sasjs/utils/types'
2
- import { FileTree, ExecutionQuery } from './types'
1
+ import { AuthConfig, ServerType, ServicePackSASjs } from '@sasjs/utils/types'
2
+ import { ExecutionQuery } from './types'
3
3
  import { RequestClient } from './request/RequestClient'
4
4
  import { getAccessTokenForSasjs } from './auth/getAccessTokenForSasjs'
5
5
  import { refreshTokensForSasjs } from './auth/refreshTokensForSasjs'
@@ -8,17 +8,10 @@ import { parseWeboutResponse } from './utils'
8
8
  import { getTokens } from './auth/getTokens'
9
9
 
10
10
  export class SASjsApiClient {
11
- constructor(
12
- private serverUrl: string,
13
- private requestClient: RequestClient
14
- ) {}
15
-
16
- public setConfig(serverUrl: string) {
17
- if (serverUrl) this.serverUrl = serverUrl
18
- }
11
+ constructor(private requestClient: RequestClient) {}
19
12
 
20
13
  public async deploy(
21
- members: FileTree,
14
+ dataJson: ServicePackSASjs,
22
15
  appLoc: string,
23
16
  authConfig?: AuthConfig
24
17
  ) {
@@ -30,13 +23,17 @@ export class SASjsApiClient {
30
23
  ServerType.Sasjs
31
24
  ))
32
25
  }
26
+
27
+ dataJson.appLoc = dataJson.appLoc || appLoc
28
+
33
29
  const { result } = await this.requestClient.post<{
34
30
  status: string
35
31
  message: string
32
+ streamServiceName?: string
36
33
  example?: {}
37
34
  }>(
38
35
  'SASjsApi/drive/deploy',
39
- { fileTree: members, appLoc: appLoc },
36
+ dataJson,
40
37
  access_token,
41
38
  undefined,
42
39
  {},
@@ -26,11 +26,18 @@ export const generateFileUploadForm = (
26
26
  )
27
27
  }
28
28
 
29
- const file = new Blob([csv], {
30
- type: 'application/csv'
31
- })
29
+ if (typeof FormData === 'undefined' && formData instanceof NodeFormData) {
30
+ formData.append(name, csv, {
31
+ filename: `${name}.csv`,
32
+ contentType: 'application/csv'
33
+ })
34
+ } else {
35
+ const file = new Blob([csv], {
36
+ type: 'application/csv'
37
+ })
32
38
 
33
- formData.append(name, file, `${name}.csv`)
39
+ formData.append(name, file, `${name}.csv`)
40
+ }
34
41
  }
35
42
 
36
43
  return formData
@@ -12,5 +12,4 @@ export * from './Session'
12
12
  export * from './UploadFile'
13
13
  export * from './PollOptions'
14
14
  export * from './WriteStream'
15
- export * from './FileTree'
16
15
  export * from './ExecuteScript'
package/types/index.d.ts CHANGED
@@ -12,5 +12,4 @@ export * from './Session';
12
12
  export * from './UploadFile';
13
13
  export * from './PollOptions';
14
14
  export * from './WriteStream';
15
- export * from './FileTree';
16
15
  export * from './ExecuteScript';
@@ -1,18 +0,0 @@
1
- export interface FileTree {
2
- members: [FolderMember, ServiceMember];
3
- }
4
- export declare enum MemberType {
5
- folder = "folder",
6
- service = "service"
7
- }
8
- export interface FolderMember {
9
- name: string;
10
- type: MemberType.folder;
11
- members: [FolderMember, ServiceMember];
12
- }
13
- export interface ServiceMember {
14
- name: string;
15
- type: MemberType.service;
16
- code: string;
17
- }
18
- export declare const isFileTree: (arg: any) => arg is FileTree;
@@ -1,47 +0,0 @@
1
- export interface FileTree {
2
- members: [FolderMember, ServiceMember]
3
- }
4
-
5
- export enum MemberType {
6
- folder = 'folder',
7
- service = 'service'
8
- }
9
-
10
- export interface FolderMember {
11
- name: string
12
- type: MemberType.folder
13
- members: [FolderMember, ServiceMember]
14
- }
15
-
16
- export interface ServiceMember {
17
- name: string
18
- type: MemberType.service
19
- code: string
20
- }
21
-
22
- export const isFileTree = (arg: any): arg is FileTree =>
23
- arg &&
24
- arg.members &&
25
- Array.isArray(arg.members) &&
26
- arg.members.filter(
27
- (member: FolderMember | ServiceMember) =>
28
- !isFolderMember(member) && !isServiceMember(member)
29
- ).length === 0
30
-
31
- const isFolderMember = (arg: any): arg is FolderMember =>
32
- arg &&
33
- typeof arg.name === 'string' &&
34
- arg.type === MemberType.folder &&
35
- arg.members &&
36
- Array.isArray(arg.members) &&
37
- arg.members.filter(
38
- (member: FolderMember | ServiceMember) =>
39
- !isFolderMember(member) && !isServiceMember(member)
40
- ).length === 0
41
-
42
- const isServiceMember = (arg: any): arg is ServiceMember =>
43
- arg &&
44
- typeof arg.name === 'string' &&
45
- arg.type === MemberType.service &&
46
- arg.code &&
47
- typeof arg.code === 'string'
@@ -1,18 +0,0 @@
1
- export interface FileTree {
2
- members: [FolderMember, ServiceMember];
3
- }
4
- export declare enum MemberType {
5
- folder = "folder",
6
- service = "service"
7
- }
8
- export interface FolderMember {
9
- name: string;
10
- type: MemberType.folder;
11
- members: [FolderMember, ServiceMember];
12
- }
13
- export interface ServiceMember {
14
- name: string;
15
- type: MemberType.service;
16
- code: string;
17
- }
18
- export declare const isFileTree: (arg: any) => arg is FileTree;