mirror of
https://github.com/sasjs/server.git
synced 2025-12-11 19:44:35 +00:00
feat: added mocking endpoints
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -6,6 +6,7 @@ node_modules/
|
||||
sas/
|
||||
sasjs_root/
|
||||
tmp/
|
||||
api/mocks/*
|
||||
build/
|
||||
sasjsbuild/
|
||||
sasjscore/
|
||||
|
||||
@@ -96,6 +96,9 @@ PROTOCOL=
|
||||
# default: 5000
|
||||
PORT=
|
||||
|
||||
# options: [sas9|sasviya]
|
||||
# If not present, mocking function is disabled
|
||||
MOCK_SERVERTYPE=
|
||||
|
||||
#
|
||||
## Additional SAS Options
|
||||
|
||||
@@ -85,8 +85,10 @@ components:
|
||||
type: string
|
||||
_webout:
|
||||
anyOf:
|
||||
- type: string
|
||||
- $ref: '#/components/schemas/IRecordOfAny'
|
||||
-
|
||||
type: string
|
||||
-
|
||||
$ref: '#/components/schemas/IRecordOfAny'
|
||||
log:
|
||||
items:
|
||||
$ref: '#/components/schemas/LogLine'
|
||||
@@ -106,6 +108,7 @@ components:
|
||||
enum:
|
||||
- sas
|
||||
- js
|
||||
- py
|
||||
type: string
|
||||
ExecuteCodePayload:
|
||||
properties:
|
||||
@@ -135,9 +138,12 @@ components:
|
||||
members:
|
||||
items:
|
||||
anyOf:
|
||||
- $ref: '#/components/schemas/FolderMember'
|
||||
- $ref: '#/components/schemas/ServiceMember'
|
||||
- $ref: '#/components/schemas/FileMember'
|
||||
-
|
||||
$ref: '#/components/schemas/FolderMember'
|
||||
-
|
||||
$ref: '#/components/schemas/ServiceMember'
|
||||
-
|
||||
$ref: '#/components/schemas/FileMember'
|
||||
type: array
|
||||
required:
|
||||
- name
|
||||
@@ -186,9 +192,12 @@ components:
|
||||
members:
|
||||
items:
|
||||
anyOf:
|
||||
- $ref: '#/components/schemas/FolderMember'
|
||||
- $ref: '#/components/schemas/ServiceMember'
|
||||
- $ref: '#/components/schemas/FileMember'
|
||||
-
|
||||
$ref: '#/components/schemas/FolderMember'
|
||||
-
|
||||
$ref: '#/components/schemas/ServiceMember'
|
||||
-
|
||||
$ref: '#/components/schemas/FileMember'
|
||||
type: array
|
||||
required:
|
||||
- members
|
||||
@@ -374,7 +383,7 @@ components:
|
||||
autoExec:
|
||||
type: string
|
||||
description: 'User-specific auto-exec code'
|
||||
example: ''
|
||||
example: ""
|
||||
required:
|
||||
- displayName
|
||||
- username
|
||||
@@ -423,27 +432,13 @@ components:
|
||||
- description
|
||||
type: object
|
||||
additionalProperties: false
|
||||
_LeanDocument__LeanDocument_T__:
|
||||
FlattenMaps_T_:
|
||||
properties: {}
|
||||
type: object
|
||||
Pick__LeanDocument_T_.Exclude_keyof_LeanDocument_T_.Exclude_keyofDocument._id-or-id-or-__v_-or-%24isSingleNested__:
|
||||
properties:
|
||||
_id:
|
||||
$ref: '#/components/schemas/_LeanDocument__LeanDocument_T__'
|
||||
description: 'This documents _id.'
|
||||
__v:
|
||||
description: 'This documents __v.'
|
||||
id:
|
||||
description: 'The string version of this documents _id.'
|
||||
type: object
|
||||
description: 'From T, pick a set of properties whose keys are in the union K'
|
||||
Omit__LeanDocument_this_.Exclude_keyofDocument._id-or-id-or-__v_-or-%24isSingleNested_:
|
||||
$ref: '#/components/schemas/Pick__LeanDocument_T_.Exclude_keyof_LeanDocument_T_.Exclude_keyofDocument._id-or-id-or-__v_-or-%24isSingleNested__'
|
||||
description: 'Construct a type with the properties of T except for those in type K.'
|
||||
LeanDocument_this_:
|
||||
$ref: '#/components/schemas/Omit__LeanDocument_this_.Exclude_keyofDocument._id-or-id-or-__v_-or-%24isSingleNested_'
|
||||
IGroup:
|
||||
$ref: '#/components/schemas/LeanDocument_this_'
|
||||
$ref: '#/components/schemas/FlattenMaps_T_'
|
||||
ObjectId:
|
||||
type: string
|
||||
InfoResponse:
|
||||
properties:
|
||||
mode:
|
||||
@@ -623,11 +618,7 @@ paths:
|
||||
$ref: '#/components/schemas/TokenResponse'
|
||||
examples:
|
||||
'Example 1':
|
||||
value:
|
||||
{
|
||||
accessToken: someRandomCryptoString,
|
||||
refreshToken: someRandomCryptoString
|
||||
}
|
||||
value: {accessToken: someRandomCryptoString, refreshToken: someRandomCryptoString}
|
||||
summary: 'Accepts client/auth code and returns access/refresh tokens'
|
||||
tags:
|
||||
- Auth
|
||||
@@ -651,16 +642,13 @@ paths:
|
||||
$ref: '#/components/schemas/TokenResponse'
|
||||
examples:
|
||||
'Example 1':
|
||||
value:
|
||||
{
|
||||
accessToken: someRandomCryptoString,
|
||||
refreshToken: someRandomCryptoString
|
||||
}
|
||||
value: {accessToken: someRandomCryptoString, refreshToken: someRandomCryptoString}
|
||||
summary: 'Returns new access/refresh tokens'
|
||||
tags:
|
||||
- Auth
|
||||
security:
|
||||
- bearerAuth: []
|
||||
-
|
||||
bearerAuth: []
|
||||
parameters: []
|
||||
/SASjsApi/auth/logout:
|
||||
post:
|
||||
@@ -672,7 +660,8 @@ paths:
|
||||
tags:
|
||||
- Auth
|
||||
security:
|
||||
- bearerAuth: []
|
||||
-
|
||||
bearerAuth: []
|
||||
parameters: []
|
||||
/SASjsApi/client:
|
||||
post:
|
||||
@@ -686,16 +675,13 @@ paths:
|
||||
$ref: '#/components/schemas/ClientPayload'
|
||||
examples:
|
||||
'Example 1':
|
||||
value:
|
||||
{
|
||||
clientId: someFormattedClientID1234,
|
||||
clientSecret: someRandomCryptoString
|
||||
}
|
||||
value: {clientId: someFormattedClientID1234, clientSecret: someRandomCryptoString}
|
||||
summary: 'Create client with the following attributes: ClientId, ClientSecret. Admin only task.'
|
||||
tags:
|
||||
- Client
|
||||
security:
|
||||
- bearerAuth: []
|
||||
-
|
||||
bearerAuth: []
|
||||
parameters: []
|
||||
requestBody:
|
||||
required: true
|
||||
@@ -718,7 +704,8 @@ paths:
|
||||
tags:
|
||||
- CODE
|
||||
security:
|
||||
- bearerAuth: []
|
||||
-
|
||||
bearerAuth: []
|
||||
parameters: []
|
||||
requestBody:
|
||||
required: true
|
||||
@@ -738,11 +725,7 @@ paths:
|
||||
$ref: '#/components/schemas/DeployResponse'
|
||||
examples:
|
||||
'Example 1':
|
||||
value:
|
||||
{
|
||||
status: success,
|
||||
message: 'Files deployed successfully to @sasjs/server.'
|
||||
}
|
||||
value: {status: success, message: 'Files deployed successfully to @sasjs/server.'}
|
||||
'400':
|
||||
description: 'Invalid Format'
|
||||
content:
|
||||
@@ -751,11 +734,7 @@ paths:
|
||||
$ref: '#/components/schemas/DeployResponse'
|
||||
examples:
|
||||
'Example 1':
|
||||
value:
|
||||
{
|
||||
status: failure,
|
||||
message: 'Provided not supported data format.'
|
||||
}
|
||||
value: {status: failure, message: 'Provided not supported data format.'}
|
||||
'500':
|
||||
description: 'Execution Error'
|
||||
content:
|
||||
@@ -769,7 +748,8 @@ paths:
|
||||
tags:
|
||||
- Drive
|
||||
security:
|
||||
- bearerAuth: []
|
||||
-
|
||||
bearerAuth: []
|
||||
parameters: []
|
||||
requestBody:
|
||||
required: true
|
||||
@@ -789,11 +769,7 @@ paths:
|
||||
$ref: '#/components/schemas/DeployResponse'
|
||||
examples:
|
||||
'Example 1':
|
||||
value:
|
||||
{
|
||||
status: success,
|
||||
message: 'Files deployed successfully to @sasjs/server.'
|
||||
}
|
||||
value: {status: success, message: 'Files deployed successfully to @sasjs/server.'}
|
||||
'400':
|
||||
description: 'Invalid Format'
|
||||
content:
|
||||
@@ -802,11 +778,7 @@ paths:
|
||||
$ref: '#/components/schemas/DeployResponse'
|
||||
examples:
|
||||
'Example 1':
|
||||
value:
|
||||
{
|
||||
status: failure,
|
||||
message: 'Provided not supported data format.'
|
||||
}
|
||||
value: {status: failure, message: 'Provided not supported data format.'}
|
||||
'500':
|
||||
description: 'Execution Error'
|
||||
content:
|
||||
@@ -821,7 +793,8 @@ paths:
|
||||
tags:
|
||||
- Drive
|
||||
security:
|
||||
- bearerAuth: []
|
||||
-
|
||||
bearerAuth: []
|
||||
parameters: []
|
||||
requestBody:
|
||||
required: true
|
||||
@@ -845,9 +818,11 @@ paths:
|
||||
tags:
|
||||
- Drive
|
||||
security:
|
||||
- bearerAuth: []
|
||||
-
|
||||
bearerAuth: []
|
||||
parameters:
|
||||
- in: query
|
||||
-
|
||||
in: query
|
||||
name: _filePath
|
||||
required: true
|
||||
schema:
|
||||
@@ -870,9 +845,11 @@ paths:
|
||||
tags:
|
||||
- Drive
|
||||
security:
|
||||
- bearerAuth: []
|
||||
-
|
||||
bearerAuth: []
|
||||
parameters:
|
||||
- in: query
|
||||
-
|
||||
in: query
|
||||
name: _filePath
|
||||
required: true
|
||||
schema:
|
||||
@@ -904,9 +881,11 @@ paths:
|
||||
tags:
|
||||
- Drive
|
||||
security:
|
||||
- bearerAuth: []
|
||||
-
|
||||
bearerAuth: []
|
||||
parameters:
|
||||
- description: 'Location of file'
|
||||
-
|
||||
description: 'Location of file'
|
||||
in: query
|
||||
name: _filePath
|
||||
required: false
|
||||
@@ -940,7 +919,7 @@ paths:
|
||||
'Example 1':
|
||||
value: {status: success}
|
||||
'403':
|
||||
description: ''
|
||||
description: ""
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
@@ -953,9 +932,11 @@ paths:
|
||||
tags:
|
||||
- Drive
|
||||
security:
|
||||
- bearerAuth: []
|
||||
-
|
||||
bearerAuth: []
|
||||
parameters:
|
||||
- description: 'Location of SAS program'
|
||||
-
|
||||
description: 'Location of SAS program'
|
||||
in: query
|
||||
name: _filePath
|
||||
required: false
|
||||
@@ -996,9 +977,11 @@ paths:
|
||||
tags:
|
||||
- Drive
|
||||
security:
|
||||
- bearerAuth: []
|
||||
-
|
||||
bearerAuth: []
|
||||
parameters:
|
||||
- in: query
|
||||
-
|
||||
in: query
|
||||
name: _folderPath
|
||||
required: false
|
||||
schema:
|
||||
@@ -1021,9 +1004,11 @@ paths:
|
||||
tags:
|
||||
- Drive
|
||||
security:
|
||||
- bearerAuth: []
|
||||
-
|
||||
bearerAuth: []
|
||||
parameters:
|
||||
- in: query
|
||||
-
|
||||
in: query
|
||||
name: _folderPath
|
||||
required: true
|
||||
schema:
|
||||
@@ -1049,13 +1034,13 @@ paths:
|
||||
$ref: '#/components/schemas/FileFolderResponse'
|
||||
examples:
|
||||
'Example 1':
|
||||
value:
|
||||
{ status: failure, message: 'Add folder request failed.' }
|
||||
value: {status: failure, message: 'Add folder request failed.'}
|
||||
summary: 'Create an empty folder in SASjs Drive'
|
||||
tags:
|
||||
- Drive
|
||||
security:
|
||||
- bearerAuth: []
|
||||
-
|
||||
bearerAuth: []
|
||||
parameters: []
|
||||
requestBody:
|
||||
required: true
|
||||
@@ -1089,7 +1074,8 @@ paths:
|
||||
tags:
|
||||
- Drive
|
||||
security:
|
||||
- bearerAuth: []
|
||||
-
|
||||
bearerAuth: []
|
||||
parameters: []
|
||||
requestBody:
|
||||
required: true
|
||||
@@ -1111,7 +1097,8 @@ paths:
|
||||
tags:
|
||||
- Drive
|
||||
security:
|
||||
- bearerAuth: []
|
||||
-
|
||||
bearerAuth: []
|
||||
parameters: []
|
||||
/SASjsApi/user:
|
||||
get:
|
||||
@@ -1127,26 +1114,13 @@ paths:
|
||||
type: array
|
||||
examples:
|
||||
'Example 1':
|
||||
value:
|
||||
[
|
||||
{
|
||||
id: 123,
|
||||
username: johnusername,
|
||||
displayName: John,
|
||||
isAdmin: false
|
||||
},
|
||||
{
|
||||
id: 456,
|
||||
username: starkusername,
|
||||
displayName: Stark,
|
||||
isAdmin: true
|
||||
}
|
||||
]
|
||||
value: [{id: 123, username: johnusername, displayName: John, isAdmin: false}, {id: 456, username: starkusername, displayName: Stark, isAdmin: true}]
|
||||
summary: 'Get list of all users (username, displayname). All users can request this.'
|
||||
tags:
|
||||
- User
|
||||
security:
|
||||
- bearerAuth: []
|
||||
-
|
||||
bearerAuth: []
|
||||
parameters: []
|
||||
post:
|
||||
operationId: CreateUser
|
||||
@@ -1159,19 +1133,13 @@ paths:
|
||||
$ref: '#/components/schemas/UserDetailsResponse'
|
||||
examples:
|
||||
'Example 1':
|
||||
value:
|
||||
{
|
||||
id: 1234,
|
||||
displayName: 'John Snow',
|
||||
username: johnSnow01,
|
||||
isAdmin: false,
|
||||
isActive: true
|
||||
}
|
||||
value: {id: 1234, displayName: 'John Snow', username: johnSnow01, isAdmin: false, isActive: true}
|
||||
summary: 'Create user with the following attributes: UserId, UserName, Password, isAdmin, isActive. Admin only task.'
|
||||
tags:
|
||||
- User
|
||||
security:
|
||||
- bearerAuth: []
|
||||
-
|
||||
bearerAuth: []
|
||||
parameters: []
|
||||
requestBody:
|
||||
required: true
|
||||
@@ -1194,9 +1162,11 @@ paths:
|
||||
tags:
|
||||
- User
|
||||
security:
|
||||
- bearerAuth: []
|
||||
-
|
||||
bearerAuth: []
|
||||
parameters:
|
||||
- description: "The User's username"
|
||||
-
|
||||
description: 'The User''s username'
|
||||
in: path
|
||||
name: username
|
||||
required: true
|
||||
@@ -1214,21 +1184,16 @@ paths:
|
||||
$ref: '#/components/schemas/UserDetailsResponse'
|
||||
examples:
|
||||
'Example 1':
|
||||
value:
|
||||
{
|
||||
id: 1234,
|
||||
displayName: 'John Snow',
|
||||
username: johnSnow01,
|
||||
isAdmin: false,
|
||||
isActive: true
|
||||
}
|
||||
value: {id: 1234, displayName: 'John Snow', username: johnSnow01, isAdmin: false, isActive: true}
|
||||
summary: 'Update user properties - such as displayName. Can be performed either by admins, or the user in question.'
|
||||
tags:
|
||||
- User
|
||||
security:
|
||||
- bearerAuth: []
|
||||
-
|
||||
bearerAuth: []
|
||||
parameters:
|
||||
- description: "The User's username"
|
||||
-
|
||||
description: 'The User''s username'
|
||||
in: path
|
||||
name: username
|
||||
required: true
|
||||
@@ -1250,9 +1215,11 @@ paths:
|
||||
tags:
|
||||
- User
|
||||
security:
|
||||
- bearerAuth: []
|
||||
-
|
||||
bearerAuth: []
|
||||
parameters:
|
||||
- description: "The User's username"
|
||||
-
|
||||
description: 'The User''s username'
|
||||
in: path
|
||||
name: username
|
||||
required: true
|
||||
@@ -1283,9 +1250,11 @@ paths:
|
||||
tags:
|
||||
- User
|
||||
security:
|
||||
- bearerAuth: []
|
||||
-
|
||||
bearerAuth: []
|
||||
parameters:
|
||||
- description: "The user's identifier"
|
||||
-
|
||||
description: 'The user''s identifier'
|
||||
in: path
|
||||
name: userId
|
||||
required: true
|
||||
@@ -1304,21 +1273,16 @@ paths:
|
||||
$ref: '#/components/schemas/UserDetailsResponse'
|
||||
examples:
|
||||
'Example 1':
|
||||
value:
|
||||
{
|
||||
id: 1234,
|
||||
displayName: 'John Snow',
|
||||
username: johnSnow01,
|
||||
isAdmin: false,
|
||||
isActive: true
|
||||
}
|
||||
value: {id: 1234, displayName: 'John Snow', username: johnSnow01, isAdmin: false, isActive: true}
|
||||
summary: 'Update user properties - such as displayName. Can be performed either by admins, or the user in question.'
|
||||
tags:
|
||||
- User
|
||||
security:
|
||||
- bearerAuth: []
|
||||
-
|
||||
bearerAuth: []
|
||||
parameters:
|
||||
- description: "The user's identifier"
|
||||
-
|
||||
description: 'The user''s identifier'
|
||||
in: path
|
||||
name: userId
|
||||
required: true
|
||||
@@ -1341,9 +1305,11 @@ paths:
|
||||
tags:
|
||||
- User
|
||||
security:
|
||||
- bearerAuth: []
|
||||
-
|
||||
bearerAuth: []
|
||||
parameters:
|
||||
- description: "The user's identifier"
|
||||
-
|
||||
description: 'The user''s identifier'
|
||||
in: path
|
||||
name: userId
|
||||
required: true
|
||||
@@ -1374,19 +1340,13 @@ paths:
|
||||
type: array
|
||||
examples:
|
||||
'Example 1':
|
||||
value:
|
||||
[
|
||||
{
|
||||
groupId: 123,
|
||||
name: DCGroup,
|
||||
description: 'This group represents Data Controller Users'
|
||||
}
|
||||
]
|
||||
value: [{groupId: 123, name: DCGroup, description: 'This group represents Data Controller Users'}]
|
||||
summary: 'Get list of all groups (groupName and groupDescription). All users can request this.'
|
||||
tags:
|
||||
- Group
|
||||
security:
|
||||
- bearerAuth: []
|
||||
-
|
||||
bearerAuth: []
|
||||
parameters: []
|
||||
post:
|
||||
operationId: CreateGroup
|
||||
@@ -1399,19 +1359,13 @@ paths:
|
||||
$ref: '#/components/schemas/GroupDetailsResponse'
|
||||
examples:
|
||||
'Example 1':
|
||||
value:
|
||||
{
|
||||
groupId: 123,
|
||||
name: DCGroup,
|
||||
description: 'This group represents Data Controller Users',
|
||||
isActive: true,
|
||||
users: []
|
||||
}
|
||||
value: {groupId: 123, name: DCGroup, description: 'This group represents Data Controller Users', isActive: true, users: []}
|
||||
summary: 'Create a new group. Admin only.'
|
||||
tags:
|
||||
- Group
|
||||
security:
|
||||
- bearerAuth: []
|
||||
-
|
||||
bearerAuth: []
|
||||
parameters: []
|
||||
requestBody:
|
||||
required: true
|
||||
@@ -1433,9 +1387,11 @@ paths:
|
||||
tags:
|
||||
- Group
|
||||
security:
|
||||
- bearerAuth: []
|
||||
-
|
||||
bearerAuth: []
|
||||
parameters:
|
||||
- description: "The group's name"
|
||||
-
|
||||
description: 'The group''s name'
|
||||
in: path
|
||||
name: name
|
||||
required: true
|
||||
@@ -1455,9 +1411,11 @@ paths:
|
||||
tags:
|
||||
- Group
|
||||
security:
|
||||
- bearerAuth: []
|
||||
-
|
||||
bearerAuth: []
|
||||
parameters:
|
||||
- description: "The group's identifier"
|
||||
-
|
||||
description: 'The group''s identifier'
|
||||
in: path
|
||||
name: groupId
|
||||
required: true
|
||||
@@ -1475,14 +1433,16 @@ paths:
|
||||
schema:
|
||||
allOf:
|
||||
- {$ref: '#/components/schemas/IGroup'}
|
||||
- { properties: { _id: {} }, required: [_id], type: object }
|
||||
- {properties: {_id: {$ref: '#/components/schemas/ObjectId'}}, required: [_id], type: object}
|
||||
summary: 'Delete a group. Admin task only.'
|
||||
tags:
|
||||
- Group
|
||||
security:
|
||||
- bearerAuth: []
|
||||
-
|
||||
bearerAuth: []
|
||||
parameters:
|
||||
- description: "The group's identifier"
|
||||
-
|
||||
description: 'The group''s identifier'
|
||||
in: path
|
||||
name: groupId
|
||||
required: true
|
||||
@@ -1502,21 +1462,16 @@ paths:
|
||||
$ref: '#/components/schemas/GroupDetailsResponse'
|
||||
examples:
|
||||
'Example 1':
|
||||
value:
|
||||
{
|
||||
groupId: 123,
|
||||
name: DCGroup,
|
||||
description: 'This group represents Data Controller Users',
|
||||
isActive: true,
|
||||
users: []
|
||||
}
|
||||
value: {groupId: 123, name: DCGroup, description: 'This group represents Data Controller Users', isActive: true, users: []}
|
||||
summary: 'Add a user to a group. Admin task only.'
|
||||
tags:
|
||||
- Group
|
||||
security:
|
||||
- bearerAuth: []
|
||||
-
|
||||
bearerAuth: []
|
||||
parameters:
|
||||
- description: "The group's identifier"
|
||||
-
|
||||
description: 'The group''s identifier'
|
||||
in: path
|
||||
name: groupId
|
||||
required: true
|
||||
@@ -1524,7 +1479,8 @@ paths:
|
||||
format: double
|
||||
type: number
|
||||
example: '1234'
|
||||
- description: "The user's identifier"
|
||||
-
|
||||
description: 'The user''s identifier'
|
||||
in: path
|
||||
name: userId
|
||||
required: true
|
||||
@@ -1543,21 +1499,16 @@ paths:
|
||||
$ref: '#/components/schemas/GroupDetailsResponse'
|
||||
examples:
|
||||
'Example 1':
|
||||
value:
|
||||
{
|
||||
groupId: 123,
|
||||
name: DCGroup,
|
||||
description: 'This group represents Data Controller Users',
|
||||
isActive: true,
|
||||
users: []
|
||||
}
|
||||
value: {groupId: 123, name: DCGroup, description: 'This group represents Data Controller Users', isActive: true, users: []}
|
||||
summary: 'Remove a user to a group. Admin task only.'
|
||||
tags:
|
||||
- Group
|
||||
security:
|
||||
- bearerAuth: []
|
||||
-
|
||||
bearerAuth: []
|
||||
parameters:
|
||||
- description: "The group's identifier"
|
||||
-
|
||||
description: 'The group''s identifier'
|
||||
in: path
|
||||
name: groupId
|
||||
required: true
|
||||
@@ -1565,7 +1516,8 @@ paths:
|
||||
format: double
|
||||
type: number
|
||||
example: '1234'
|
||||
- description: "The user's identifier"
|
||||
-
|
||||
description: 'The user''s identifier'
|
||||
in: path
|
||||
name: userId
|
||||
required: true
|
||||
@@ -1585,14 +1537,7 @@ paths:
|
||||
$ref: '#/components/schemas/InfoResponse'
|
||||
examples:
|
||||
'Example 1':
|
||||
value:
|
||||
{
|
||||
mode: desktop,
|
||||
cors: enable,
|
||||
whiteList: ['http://example.com', 'http://example2.com'],
|
||||
protocol: http,
|
||||
runTimes: [sas, js]
|
||||
}
|
||||
value: {mode: desktop, cors: enable, whiteList: ['http://example.com', 'http://example2.com'], protocol: http, runTimes: [sas, js]}
|
||||
summary: 'Get server info (mode, cors, whiteList, protocol).'
|
||||
tags:
|
||||
- Info
|
||||
@@ -1630,42 +1575,14 @@ paths:
|
||||
type: array
|
||||
examples:
|
||||
'Example 1':
|
||||
value:
|
||||
[
|
||||
{
|
||||
permissionId: 123,
|
||||
path: /SASjsApi/code/execute,
|
||||
type: Route,
|
||||
setting: Grant,
|
||||
user:
|
||||
{
|
||||
id: 1,
|
||||
username: johnSnow01,
|
||||
displayName: 'John Snow',
|
||||
isAdmin: false
|
||||
}
|
||||
},
|
||||
{
|
||||
permissionId: 124,
|
||||
path: /SASjsApi/code/execute,
|
||||
type: Route,
|
||||
setting: Grant,
|
||||
group:
|
||||
{
|
||||
groupId: 1,
|
||||
name: DCGroup,
|
||||
description: 'This group represents Data Controller Users',
|
||||
isActive: true,
|
||||
users: []
|
||||
}
|
||||
}
|
||||
]
|
||||
value: [{permissionId: 123, path: /SASjsApi/code/execute, type: Route, setting: Grant, user: {id: 1, username: johnSnow01, displayName: 'John Snow', isAdmin: false}}, {permissionId: 124, path: /SASjsApi/code/execute, type: Route, setting: Grant, group: {groupId: 1, name: DCGroup, description: 'This group represents Data Controller Users', isActive: true, users: []}}]
|
||||
description: "Get the list of permission rules applicable the authenticated user.\nIf the user is an admin, all rules are returned."
|
||||
summary: 'Get the list of permission rules. If the user is admin, all rules are returned.'
|
||||
tags:
|
||||
- Permission
|
||||
security:
|
||||
- bearerAuth: []
|
||||
-
|
||||
bearerAuth: []
|
||||
parameters: []
|
||||
post:
|
||||
operationId: CreatePermission
|
||||
@@ -1678,25 +1595,13 @@ paths:
|
||||
$ref: '#/components/schemas/PermissionDetailsResponse'
|
||||
examples:
|
||||
'Example 1':
|
||||
value:
|
||||
{
|
||||
permissionId: 123,
|
||||
path: /SASjsApi/code/execute,
|
||||
type: Route,
|
||||
setting: Grant,
|
||||
user:
|
||||
{
|
||||
id: 1,
|
||||
username: johnSnow01,
|
||||
displayName: 'John Snow',
|
||||
isAdmin: false
|
||||
}
|
||||
}
|
||||
value: {permissionId: 123, path: /SASjsApi/code/execute, type: Route, setting: Grant, user: {id: 1, username: johnSnow01, displayName: 'John Snow', isAdmin: false}}
|
||||
summary: 'Create a new permission. Admin only.'
|
||||
tags:
|
||||
- Permission
|
||||
security:
|
||||
- bearerAuth: []
|
||||
-
|
||||
bearerAuth: []
|
||||
parameters: []
|
||||
requestBody:
|
||||
required: true
|
||||
@@ -1716,27 +1621,16 @@ paths:
|
||||
$ref: '#/components/schemas/PermissionDetailsResponse'
|
||||
examples:
|
||||
'Example 1':
|
||||
value:
|
||||
{
|
||||
permissionId: 123,
|
||||
path: /SASjsApi/code/execute,
|
||||
type: Route,
|
||||
setting: Grant,
|
||||
user:
|
||||
{
|
||||
id: 1,
|
||||
username: johnSnow01,
|
||||
displayName: 'John Snow',
|
||||
isAdmin: false
|
||||
}
|
||||
}
|
||||
value: {permissionId: 123, path: /SASjsApi/code/execute, type: Route, setting: Grant, user: {id: 1, username: johnSnow01, displayName: 'John Snow', isAdmin: false}}
|
||||
summary: 'Update permission setting. Admin only'
|
||||
tags:
|
||||
- Permission
|
||||
security:
|
||||
- bearerAuth: []
|
||||
-
|
||||
bearerAuth: []
|
||||
parameters:
|
||||
- description: "The permission's identifier"
|
||||
-
|
||||
description: 'The permission''s identifier'
|
||||
in: path
|
||||
name: permissionId
|
||||
required: true
|
||||
@@ -1759,9 +1653,11 @@ paths:
|
||||
tags:
|
||||
- Permission
|
||||
security:
|
||||
- bearerAuth: []
|
||||
-
|
||||
bearerAuth: []
|
||||
parameters:
|
||||
- description: "The user's identifier"
|
||||
-
|
||||
description: 'The user''s identifier'
|
||||
in: path
|
||||
name: permissionId
|
||||
required: true
|
||||
@@ -1781,18 +1677,13 @@ paths:
|
||||
$ref: '#/components/schemas/UserResponse'
|
||||
examples:
|
||||
'Example 1':
|
||||
value:
|
||||
{
|
||||
id: 123,
|
||||
username: johnusername,
|
||||
displayName: John,
|
||||
isAdmin: false
|
||||
}
|
||||
value: {id: 123, username: johnusername, displayName: John, isAdmin: false}
|
||||
summary: 'Get session info (username).'
|
||||
tags:
|
||||
- Session
|
||||
security:
|
||||
- bearerAuth: []
|
||||
-
|
||||
bearerAuth: []
|
||||
parameters: []
|
||||
/SASjsApi/stp/execute:
|
||||
get:
|
||||
@@ -1811,9 +1702,11 @@ paths:
|
||||
tags:
|
||||
- STP
|
||||
security:
|
||||
- bearerAuth: []
|
||||
-
|
||||
bearerAuth: []
|
||||
parameters:
|
||||
- description: 'Location of SAS or JS code'
|
||||
-
|
||||
description: 'Location of SAS or JS code'
|
||||
in: query
|
||||
name: _program
|
||||
required: true
|
||||
@@ -1831,25 +1724,17 @@ paths:
|
||||
$ref: '#/components/schemas/ExecuteReturnJsonResponse'
|
||||
examples:
|
||||
'Example 1':
|
||||
value:
|
||||
{
|
||||
status: success,
|
||||
_webout: 'webout content',
|
||||
log: [],
|
||||
httpHeaders:
|
||||
{
|
||||
Content-type: application/zip,
|
||||
Cache-Control: 'public, max-age=1000'
|
||||
}
|
||||
}
|
||||
value: {status: success, _webout: 'webout content', log: [], httpHeaders: {Content-type: application/zip, Cache-Control: 'public, max-age=1000'}}
|
||||
description: "Trigger a SAS or JS program using the _program URL parameter.\n\nAccepts URL parameters and file uploads. For more details, see docs:\n\nhttps://server.sasjs.io/storedprograms\n\nThe response will be a JSON object with the following root attributes:\nlog, webout, headers.\n\nThe webout attribute will be nested JSON ONLY if the response-header\ncontains a content-type of application/json AND it is valid JSON.\nOtherwise it will be a stringified version of the webout content."
|
||||
summary: 'Execute a Stored Program, return a JSON object'
|
||||
tags:
|
||||
- STP
|
||||
security:
|
||||
- bearerAuth: []
|
||||
-
|
||||
bearerAuth: []
|
||||
parameters:
|
||||
- description: 'Location of SAS or JS code'
|
||||
-
|
||||
description: 'Location of SAS or JS code'
|
||||
in: query
|
||||
name: _program
|
||||
required: false
|
||||
@@ -1887,18 +1772,7 @@ paths:
|
||||
application/json:
|
||||
schema:
|
||||
properties:
|
||||
user:
|
||||
{
|
||||
properties:
|
||||
{
|
||||
isAdmin: { type: boolean },
|
||||
displayName: { type: string },
|
||||
username: { type: string },
|
||||
id: { type: number, format: double }
|
||||
},
|
||||
required: [isAdmin, displayName, username, id],
|
||||
type: object
|
||||
}
|
||||
user: {properties: {isAdmin: {type: boolean}, displayName: {type: string}, username: {type: string}, id: {type: number, format: double}}, required: [isAdmin, displayName, username, id], type: object}
|
||||
loggedIn: {type: boolean}
|
||||
required:
|
||||
- user
|
||||
@@ -1954,27 +1828,39 @@ paths:
|
||||
security: []
|
||||
parameters: []
|
||||
servers:
|
||||
- url: /
|
||||
-
|
||||
url: /
|
||||
tags:
|
||||
- name: Auth
|
||||
-
|
||||
name: Auth
|
||||
description: 'Operations about auth'
|
||||
- name: Client
|
||||
-
|
||||
name: Client
|
||||
description: 'Operations about clients'
|
||||
- name: CODE
|
||||
-
|
||||
name: CODE
|
||||
description: 'Execution of code (various runtimes are supported)'
|
||||
- name: Drive
|
||||
-
|
||||
name: Drive
|
||||
description: 'Operations on SASjs Drive'
|
||||
- name: Group
|
||||
-
|
||||
name: Group
|
||||
description: 'Operations on groups and group memberships'
|
||||
- name: Info
|
||||
-
|
||||
name: Info
|
||||
description: 'Get Server Information'
|
||||
- name: Permission
|
||||
-
|
||||
name: Permission
|
||||
description: 'Operations about permissions'
|
||||
- name: Session
|
||||
-
|
||||
name: Session
|
||||
description: 'Get Session information'
|
||||
- name: STP
|
||||
-
|
||||
name: STP
|
||||
description: 'Execution of Stored Programs'
|
||||
- name: User
|
||||
-
|
||||
name: User
|
||||
description: 'Operations with users'
|
||||
- name: Web
|
||||
-
|
||||
name: Web
|
||||
description: 'Operations on Web'
|
||||
|
||||
57
api/src/routes/api/mock-sas9.ts
Normal file
57
api/src/routes/api/mock-sas9.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
import { readFile } from '@sasjs/utils'
|
||||
import express, { Request } from 'express'
|
||||
import path from 'path'
|
||||
|
||||
const mockSas9Router = express.Router()
|
||||
|
||||
const { MOCK_SERVERTYPE } = process.env
|
||||
|
||||
mockSas9Router.post('/SASStoredProcess/do/', async (req, res) => {
|
||||
let program = req.query._program?.toString() || ''
|
||||
program = program.replace('/', '')
|
||||
const filePath = path.join(process.cwd(), 'mocks', program)
|
||||
|
||||
let file
|
||||
|
||||
try {
|
||||
file = await readFile(
|
||||
filePath
|
||||
)
|
||||
} catch (err: any) {
|
||||
console.error(`Mocked file on path: ${filePath} is not found.`)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if (!file) {
|
||||
console.error(`Mocked file on path: ${filePath} is not found.`)
|
||||
return
|
||||
}
|
||||
|
||||
let fileContent = ''
|
||||
|
||||
try {
|
||||
fileContent = JSON.parse(file)
|
||||
} catch (err: any) {
|
||||
fileContent = file
|
||||
}
|
||||
|
||||
try {
|
||||
res.send(fileContent)
|
||||
} catch (err: any) {
|
||||
res.status(403).send(err.toString())
|
||||
}
|
||||
})
|
||||
|
||||
if (MOCK_SERVERTYPE === undefined) {
|
||||
mockSas9Router.post('/SASLogon/login', async (req, res) => {
|
||||
try {
|
||||
res.send({ msg: 'Login' })
|
||||
} catch (err: any) {
|
||||
res.status(403).send(err.toString())
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
export default mockSas9Router
|
||||
13
api/src/routes/api/mock-viya.ts
Normal file
13
api/src/routes/api/mock-viya.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import express from 'express'
|
||||
|
||||
const mockViyaRouter = express.Router()
|
||||
|
||||
mockViyaRouter.post('/SASJobExecution/', async (req, res) => {
|
||||
try {
|
||||
res.send({ test: 'test' })
|
||||
} catch (err: any) {
|
||||
res.status(403).send(err.toString())
|
||||
}
|
||||
})
|
||||
|
||||
export default mockViyaRouter
|
||||
@@ -2,10 +2,13 @@ import express from 'express'
|
||||
import { WebController } from '../../controllers/web'
|
||||
import { authenticateAccessToken, desktopRestrict } from '../../middlewares'
|
||||
import { authorizeValidation, loginWebValidation } from '../../utils'
|
||||
import mockSas9Router from '../api/mock-sas9'
|
||||
|
||||
const webRouter = express.Router()
|
||||
const controller = new WebController()
|
||||
|
||||
const { MOCK_SERVERTYPE } = process.env
|
||||
|
||||
webRouter.get('/', async (req, res) => {
|
||||
let response
|
||||
try {
|
||||
@@ -23,6 +26,7 @@ webRouter.get('/', async (req, res) => {
|
||||
}
|
||||
})
|
||||
|
||||
if (MOCK_SERVERTYPE !== undefined) {
|
||||
webRouter.post('/SASLogon/login', desktopRestrict, async (req, res) => {
|
||||
const { error, value: body } = loginWebValidation(req.body)
|
||||
if (error) return res.status(400).send(error.details[0].message)
|
||||
@@ -34,6 +38,7 @@ webRouter.post('/SASLogon/login', desktopRestrict, async (req, res) => {
|
||||
res.status(403).send(err.toString())
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
webRouter.post(
|
||||
'/SASLogon/authorize',
|
||||
@@ -61,4 +66,8 @@ webRouter.get('/SASLogon/logout', desktopRestrict, async (req, res) => {
|
||||
}
|
||||
})
|
||||
|
||||
webRouter.use('/', mockSas9Router)
|
||||
// disabled for now
|
||||
// webRouter.use('/', mockViyaRouter)
|
||||
|
||||
export default webRouter
|
||||
|
||||
Reference in New Issue
Block a user