@sasjs/api 0.49.1 → 0.51.0
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.
- package/README.md +15 -0
- package/build/browser.js +453 -17
- package/build/cjs/viya/appSurface.js +241 -0
- package/build/cjs/viya/compute.js +127 -4
- package/build/cjs/viya/declared.js +107 -0
- package/build/cjs/viya/dispatch.js +3 -0
- package/build/cjs/viya/identity.js +191 -0
- package/build/cjs/viya/overlay.js +15 -6
- package/build/cjs/viya/service.js +3 -1
- package/build/esm/viya/appSurface.d.ts +51 -0
- package/build/esm/viya/appSurface.d.ts.map +1 -0
- package/build/esm/viya/appSurface.js +238 -0
- package/build/esm/viya/compute.d.ts.map +1 -1
- package/build/esm/viya/compute.js +128 -5
- package/build/esm/viya/declared.d.ts.map +1 -1
- package/build/esm/viya/declared.js +107 -0
- package/build/esm/viya/dispatch.d.ts.map +1 -1
- package/build/esm/viya/dispatch.js +4 -1
- package/build/esm/viya/identity.d.ts +34 -0
- package/build/esm/viya/identity.d.ts.map +1 -0
- package/build/esm/viya/identity.js +187 -0
- package/build/esm/viya/overlay.d.ts +1 -0
- package/build/esm/viya/overlay.d.ts.map +1 -1
- package/build/esm/viya/overlay.js +14 -5
- package/build/esm/viya/seed.d.ts +8 -4
- package/build/esm/viya/seed.d.ts.map +1 -1
- package/build/esm/viya/service.d.ts.map +1 -1
- package/build/esm/viya/service.js +3 -1
- package/build/esm/viya/sessions.d.ts +3 -1
- package/build/esm/viya/sessions.d.ts.map +1 -1
- package/package.json +4 -1
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.APP_SURFACE = exports.APP_SURFACE_APPLICATION = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The application the inventory was measured from.
|
|
6
|
+
*
|
|
7
|
+
* Named rather than assumed: the inventory describes one application's calls,
|
|
8
|
+
* and a second application running on an emulated estate is a second inventory -
|
|
9
|
+
* not an edit to this one, whose rows would then be a claim about a client
|
|
10
|
+
* nobody measured.
|
|
11
|
+
*/
|
|
12
|
+
exports.APP_SURFACE_APPLICATION = {
|
|
13
|
+
name: 'Data Controller for SAS',
|
|
14
|
+
repository: 'https://git.datacontroller.io/dc/dc',
|
|
15
|
+
measuredFrom: 'client/src'
|
|
16
|
+
};
|
|
17
|
+
/** Why a namespace the API-explorer page lists is not an answered operation. */
|
|
18
|
+
const EXPLORER_ONLY = 'The application names this namespace in its Viya API map, which its API-explorer page reads; no product screen calls it, so the emulated estate does not answer it.';
|
|
19
|
+
exports.APP_SURFACE = [
|
|
20
|
+
// the auth flow the client shares with the adapter
|
|
21
|
+
{
|
|
22
|
+
path: '/SASLogon',
|
|
23
|
+
family: 'viya-auth',
|
|
24
|
+
decision: 'in',
|
|
25
|
+
reason: 'the auth flow, named by the application as well as the adapter, and the reason the emulated paths cannot be renamed'
|
|
26
|
+
},
|
|
27
|
+
// compute: the list, and the read of one context a deploy screen makes
|
|
28
|
+
{
|
|
29
|
+
path: '/compute/contexts',
|
|
30
|
+
family: 'viya-compute',
|
|
31
|
+
decision: 'in',
|
|
32
|
+
reason: 'the deploy screen lists the contexts it may run a session in, and picks the one the wizard will use'
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
path: '/compute/contexts/{}',
|
|
36
|
+
family: 'viya-compute',
|
|
37
|
+
decision: 'in',
|
|
38
|
+
reason: 'the deploy screen reads each context in full for its batch identity and reuse setting, which the list view does not carry'
|
|
39
|
+
},
|
|
40
|
+
// folders: the two reads an application makes of a deployment folder
|
|
41
|
+
{
|
|
42
|
+
path: '/folders/folders/@item',
|
|
43
|
+
family: 'viya-folders',
|
|
44
|
+
decision: 'in',
|
|
45
|
+
reason: 'the application resolves its own appLoc by path to find the services it will run'
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
path: '/folders/folders/{}/members',
|
|
49
|
+
family: 'viya-folders',
|
|
50
|
+
decision: 'in',
|
|
51
|
+
reason: 'the application lists the members of the folder it resolved, to find a deployed service'
|
|
52
|
+
},
|
|
53
|
+
// identities: the family the adapter asks one question of and an app asks six
|
|
54
|
+
{
|
|
55
|
+
path: '/identities/groups',
|
|
56
|
+
family: 'viya-identity',
|
|
57
|
+
decision: 'in',
|
|
58
|
+
reason: 'the deploy screen fetches the group list to offer the admin-group dropdown, and its failure aborts the wizard'
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
path: '/identities/groups/{}',
|
|
62
|
+
family: 'viya-identity',
|
|
63
|
+
decision: 'in',
|
|
64
|
+
reason: 'the group screen appends the group id and a member list to this fragment, to show who holds a group'
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
path: '/identities/users',
|
|
68
|
+
family: 'viya-identity',
|
|
69
|
+
decision: 'in',
|
|
70
|
+
reason: 'the user screen lists the accounts the estate holds'
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
path: '/identities/users/@currentUser',
|
|
74
|
+
family: 'viya-identity',
|
|
75
|
+
decision: 'in',
|
|
76
|
+
reason: 'the caller, which the application reads for its own profile as the adapter does'
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
path: '/identities/users/@currentUser/memberships',
|
|
80
|
+
family: 'viya-identity',
|
|
81
|
+
decision: 'in',
|
|
82
|
+
reason: 'the deploy screen filters the group list to the caller own groups, and falls back to all groups when this read fails'
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
path: '/identities/users/{}',
|
|
86
|
+
family: 'viya-identity',
|
|
87
|
+
decision: 'in',
|
|
88
|
+
reason: 'the user screen appends an account id to this fragment for a profile and its memberships'
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
path: '/identities/users/{}/avatar/content',
|
|
92
|
+
family: 'viya-identity',
|
|
93
|
+
decision: 'in',
|
|
94
|
+
reason: 'the header renders the caller avatar from this URL, and an account with none answers the 404 an estate would'
|
|
95
|
+
},
|
|
96
|
+
// the API roots and the explorer-only namespaces: named, never called
|
|
97
|
+
{
|
|
98
|
+
path: '/identities',
|
|
99
|
+
family: 'viya-identity',
|
|
100
|
+
decision: 'declined',
|
|
101
|
+
reason: 'the service root the application API map lists for its explorer page, not an endpoint any screen calls'
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
path: '/folders',
|
|
105
|
+
family: 'viya-folders',
|
|
106
|
+
decision: 'declined',
|
|
107
|
+
reason: 'the service root the application API map lists for its explorer page, not an endpoint any screen calls'
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
path: '/files',
|
|
111
|
+
family: 'viya-files',
|
|
112
|
+
decision: 'declined',
|
|
113
|
+
reason: 'the service root the application API map lists for its explorer page, not an endpoint any screen calls'
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
path: '/jobDefinitions',
|
|
117
|
+
family: 'viya-jobs',
|
|
118
|
+
decision: 'declined',
|
|
119
|
+
reason: 'the service root the application API map lists for its explorer page, not an endpoint any screen calls'
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
path: '/jobExecution',
|
|
123
|
+
family: 'viya-jobs',
|
|
124
|
+
decision: 'declined',
|
|
125
|
+
reason: 'the service root the application API map lists for its explorer page, not an endpoint any screen calls'
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
path: '/annotations',
|
|
129
|
+
family: 'viya-files',
|
|
130
|
+
decision: 'declined',
|
|
131
|
+
reason: EXPLORER_ONLY
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
path: '/authorization',
|
|
135
|
+
family: 'viya-identity',
|
|
136
|
+
decision: 'declined',
|
|
137
|
+
reason: EXPLORER_ONLY
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
path: '/businessRules',
|
|
141
|
+
family: 'viya-jobs',
|
|
142
|
+
decision: 'declined',
|
|
143
|
+
reason: EXPLORER_ONLY
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
path: '/dataMining',
|
|
147
|
+
family: 'viya-jobs',
|
|
148
|
+
decision: 'declined',
|
|
149
|
+
reason: EXPLORER_ONLY
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
path: '/decisionsRuntimeBuilder',
|
|
153
|
+
family: 'viya-jobs',
|
|
154
|
+
decision: 'declined',
|
|
155
|
+
reason: EXPLORER_ONLY
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
path: '/insights',
|
|
159
|
+
family: 'viya-jobs',
|
|
160
|
+
decision: 'declined',
|
|
161
|
+
reason: EXPLORER_ONLY
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
path: '/microanalyticScore',
|
|
165
|
+
family: 'viya-jobs',
|
|
166
|
+
decision: 'declined',
|
|
167
|
+
reason: EXPLORER_ONLY
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
path: '/mlPipelineAutomation',
|
|
171
|
+
family: 'viya-jobs',
|
|
172
|
+
decision: 'declined',
|
|
173
|
+
reason: EXPLORER_ONLY
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
path: '/modelManagement',
|
|
177
|
+
family: 'viya-jobs',
|
|
178
|
+
decision: 'declined',
|
|
179
|
+
reason: EXPLORER_ONLY
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
path: '/modelPublish',
|
|
183
|
+
family: 'viya-jobs',
|
|
184
|
+
decision: 'declined',
|
|
185
|
+
reason: EXPLORER_ONLY
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
path: '/modelRepository',
|
|
189
|
+
family: 'viya-jobs',
|
|
190
|
+
decision: 'declined',
|
|
191
|
+
reason: EXPLORER_ONLY
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
path: '/referenceData',
|
|
195
|
+
family: 'viya-jobs',
|
|
196
|
+
decision: 'declined',
|
|
197
|
+
reason: EXPLORER_ONLY
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
path: '/relationships',
|
|
201
|
+
family: 'viya-folders',
|
|
202
|
+
decision: 'declined',
|
|
203
|
+
reason: EXPLORER_ONLY
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
path: '/reportImages',
|
|
207
|
+
family: 'viya-jobs',
|
|
208
|
+
decision: 'declined',
|
|
209
|
+
reason: EXPLORER_ONLY
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
path: '/reportTransforms',
|
|
213
|
+
family: 'viya-jobs',
|
|
214
|
+
decision: 'declined',
|
|
215
|
+
reason: EXPLORER_ONLY
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
path: '/reports',
|
|
219
|
+
family: 'viya-jobs',
|
|
220
|
+
decision: 'declined',
|
|
221
|
+
reason: EXPLORER_ONLY
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
path: '/subjectContacts',
|
|
225
|
+
family: 'viya-jobs',
|
|
226
|
+
decision: 'declined',
|
|
227
|
+
reason: EXPLORER_ONLY
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
path: '/treatmentDefinitions',
|
|
231
|
+
family: 'viya-jobs',
|
|
232
|
+
decision: 'declined',
|
|
233
|
+
reason: EXPLORER_ONLY
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
path: '/visualAnalytics',
|
|
237
|
+
family: 'viya-jobs',
|
|
238
|
+
decision: 'declined',
|
|
239
|
+
reason: EXPLORER_ONLY
|
|
240
|
+
}
|
|
241
|
+
];
|
|
@@ -5,6 +5,7 @@ const types_js_1 = require("../types.js");
|
|
|
5
5
|
const seed_js_1 = require("./seed.js");
|
|
6
6
|
const sessions_js_1 = require("./sessions.js");
|
|
7
7
|
const ids_js_1 = require("./ids.js");
|
|
8
|
+
const overlay_js_1 = require("./overlay.js");
|
|
8
9
|
/**
|
|
9
10
|
* The name the emulator answers when a client asks for no particular context.
|
|
10
11
|
*
|
|
@@ -76,6 +77,31 @@ const contextBody = (name, caller) => ({
|
|
|
76
77
|
version: 2,
|
|
77
78
|
links: linksFor(`/compute/contexts/${exports.EMULATED_CONTEXT_ID}`, 'application/vnd.sas.compute.context')
|
|
78
79
|
});
|
|
80
|
+
/**
|
|
81
|
+
* The context in full, for the read a client makes of one it already holds.
|
|
82
|
+
*
|
|
83
|
+
* The list view Viya answers is deliberately minimal, so a client that needs a
|
|
84
|
+
* context's attributes reads the context itself - Data Controller's deploy
|
|
85
|
+
* screen fetches each one to pick up its batch identity. The attributes are the
|
|
86
|
+
* ones an emulated estate truthfully has: nothing runs as a batch identity here,
|
|
87
|
+
* and `reuseServerProcesses` is `false` for the same reason, which is what leaves
|
|
88
|
+
* a client's batch-id list empty rather than inventing an account to run as.
|
|
89
|
+
*/
|
|
90
|
+
const contextDetailsBody = (caller) => ({
|
|
91
|
+
...contextBody(exports.DEFAULT_CONTEXT_NAME, caller),
|
|
92
|
+
description: 'The compute context an emulated estate answers for',
|
|
93
|
+
creationTimeStamp: ids_js_1.EMULATED_NOW,
|
|
94
|
+
modifiedTimeStamp: ids_js_1.EMULATED_NOW,
|
|
95
|
+
modifiedBy: caller,
|
|
96
|
+
launchType: 'service',
|
|
97
|
+
launchContext: { contextId: exports.EMULATED_CONTEXT_ID },
|
|
98
|
+
environment: { autoExecLines: [] },
|
|
99
|
+
attributes: {
|
|
100
|
+
reuseServerProcesses: 'false',
|
|
101
|
+
allowXCMD: 'false',
|
|
102
|
+
serverMinAvailable: '1'
|
|
103
|
+
}
|
|
104
|
+
});
|
|
79
105
|
const sessionBody = (services, session, autoExecLines, caller) => {
|
|
80
106
|
const { id } = session;
|
|
81
107
|
const uri = `/compute/sessions/${id}`;
|
|
@@ -116,7 +142,7 @@ const jobBody = (job) => {
|
|
|
116
142
|
...(job.completedTimeStamp
|
|
117
143
|
? { completedTimeStamp: job.completedTimeStamp }
|
|
118
144
|
: {}),
|
|
119
|
-
jobConditionCode: 0,
|
|
145
|
+
jobConditionCode: job.jobConditionCode ?? 0,
|
|
120
146
|
stateElapsedTime: 1,
|
|
121
147
|
listingStatistics: {
|
|
122
148
|
lineCount: job.log.length,
|
|
@@ -172,6 +198,13 @@ const jobOf = (services, sessionId, jobId, subject) => {
|
|
|
172
198
|
* no absent case to answer - a fallback here would be a branch nothing reaches.
|
|
173
199
|
*/
|
|
174
200
|
const segmentsOf = (params) => params.segments;
|
|
201
|
+
// Visit every index, including holes in arrays supplied by direct dispatch.
|
|
202
|
+
const validCodeLines = (lines) => {
|
|
203
|
+
for (let i = 0; i < lines.length; i++)
|
|
204
|
+
if (typeof lines[i] !== 'string')
|
|
205
|
+
return false;
|
|
206
|
+
return true;
|
|
207
|
+
};
|
|
175
208
|
exports.COMPUTE_HANDLERS = {
|
|
176
209
|
'GET /compute/contexts': async ({ request }) => {
|
|
177
210
|
const limit = Number(request.query?.limit ?? 0) || 0;
|
|
@@ -191,6 +224,14 @@ exports.COMPUTE_HANDLERS = {
|
|
|
191
224
|
}
|
|
192
225
|
};
|
|
193
226
|
},
|
|
227
|
+
'GET /compute/contexts/{}': async ({ request, params }) => {
|
|
228
|
+
// the estate has one context and its id does not move, so an id it is not is
|
|
229
|
+
// an id no context here ever had - the same refusal the drive makes for an
|
|
230
|
+
// unknown folder rather than a body about some other context
|
|
231
|
+
if (params.id !== exports.EMULATED_CONTEXT_ID)
|
|
232
|
+
throw new types_js_1.ApiError(404, `No compute context matches the id ${params.id}. The emulated estate answers one context, and this is not its id.`);
|
|
233
|
+
return { status: 200, body: contextDetailsBody((0, ids_js_1.callerId)(request.subject)) };
|
|
234
|
+
},
|
|
194
235
|
'POST /compute/contexts/{}/sessions': async ({ services, params, request }) => {
|
|
195
236
|
if (params.id !== exports.EMULATED_CONTEXT_ID)
|
|
196
237
|
throw new types_js_1.ApiError(404, `Context with ID '${params.id}' was not found.`);
|
|
@@ -201,6 +242,31 @@ exports.COMPUTE_HANDLERS = {
|
|
|
201
242
|
body: sessionBody(services, session, body.environment?.autoExecLines ?? [], (0, ids_js_1.callerId)(request.subject))
|
|
202
243
|
};
|
|
203
244
|
},
|
|
245
|
+
'GET /compute/sessions/{}/variables/{}': async ({ services, params, request }) => {
|
|
246
|
+
if (services.viya?.mockSysjobid !== true)
|
|
247
|
+
throw new types_js_1.ApiError(501, overlay_js_1.SESSION_VARIABLE_REFUSAL, {
|
|
248
|
+
message: overlay_js_1.SESSION_VARIABLE_REFUSAL
|
|
249
|
+
});
|
|
250
|
+
if (request.subject === undefined && request.token !== undefined)
|
|
251
|
+
throw new types_js_1.ApiError(401, 'A valid caller is required.');
|
|
252
|
+
const [sessionId, name] = segmentsOf(params);
|
|
253
|
+
const session = sessionOf(services, sessionId, request.subject);
|
|
254
|
+
if (name !== 'SYSJOBID')
|
|
255
|
+
throw new types_js_1.ApiError(501, overlay_js_1.SESSION_VARIABLE_REFUSAL, {
|
|
256
|
+
message: overlay_js_1.SESSION_VARIABLE_REFUSAL
|
|
257
|
+
});
|
|
258
|
+
const uri = `/compute/sessions/${encodeURIComponent(session.id)}/variables/SYSJOBID`;
|
|
259
|
+
return {
|
|
260
|
+
status: 200,
|
|
261
|
+
body: {
|
|
262
|
+
name: 'SYSJOBID',
|
|
263
|
+
value: `mock-${session.id}`,
|
|
264
|
+
scope: 'AUTOMATIC',
|
|
265
|
+
version: 1,
|
|
266
|
+
links: linksFor(uri, 'application/vnd.sas.compute.session.variable')
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
},
|
|
204
270
|
'GET /compute/sessions/{}/state': async ({ services, params, request }) => {
|
|
205
271
|
sessionOf(services, params.id, request.subject);
|
|
206
272
|
// a bare enum, not an object: the adapter calls `.trim()` on the answer, and
|
|
@@ -214,8 +280,17 @@ exports.COMPUTE_HANDLERS = {
|
|
|
214
280
|
},
|
|
215
281
|
'POST /compute/sessions/{}/jobs': async ({ services, params, request }) => {
|
|
216
282
|
const session = sessionOf(services, params.id, request.subject);
|
|
217
|
-
const
|
|
218
|
-
|
|
283
|
+
const input = request.body === undefined ? {} : request.body;
|
|
284
|
+
if (!input || typeof input !== 'object' || Array.isArray(input))
|
|
285
|
+
throw new types_js_1.ApiError(400, 'Compute job code must be a string or an array of strings.');
|
|
286
|
+
const body = input;
|
|
287
|
+
const code = body.code;
|
|
288
|
+
if (code !== undefined &&
|
|
289
|
+
typeof code !== 'string' &&
|
|
290
|
+
(!Array.isArray(code) || !validCodeLines(code)))
|
|
291
|
+
throw new types_js_1.ApiError(400, 'Compute job code must be a string or an array of strings.');
|
|
292
|
+
const program = (code ?? '');
|
|
293
|
+
const job = estateOf(services).submit(session, { ...body, code: program });
|
|
219
294
|
const execute = services.viya?.execute;
|
|
220
295
|
// a host with no engine has nothing to run, so the job is finished at once
|
|
221
296
|
if (!execute) {
|
|
@@ -231,7 +306,7 @@ exports.COMPUTE_HANDLERS = {
|
|
|
231
306
|
// not advertise them - the run writes the log when it has one
|
|
232
307
|
job.log = [];
|
|
233
308
|
void execute({
|
|
234
|
-
program
|
|
309
|
+
program,
|
|
235
310
|
variables: body.variables,
|
|
236
311
|
name: body.name,
|
|
237
312
|
sessionId: session.id
|
|
@@ -239,6 +314,7 @@ exports.COMPUTE_HANDLERS = {
|
|
|
239
314
|
.then((ran) => {
|
|
240
315
|
job.log = ran.log.split('\n');
|
|
241
316
|
job.state = ran.state ?? 'completed';
|
|
317
|
+
job.jobConditionCode = ran.jobConditionCode;
|
|
242
318
|
if (ran.webout !== undefined)
|
|
243
319
|
job.webout = ran.webout;
|
|
244
320
|
job.completedTimeStamp = new Date().toISOString();
|
|
@@ -286,6 +362,53 @@ exports.COMPUTE_HANDLERS = {
|
|
|
286
362
|
body: jobOf(services, sessionId, jobId, request.subject).state
|
|
287
363
|
};
|
|
288
364
|
},
|
|
365
|
+
// The collection is a separate CLI call from the adapter's /log/content.
|
|
366
|
+
'GET /compute/sessions/{}/jobs/{}/log': async ({ services, params, request }) => {
|
|
367
|
+
const [sessionId, jobId] = segmentsOf(params);
|
|
368
|
+
const job = jobOf(services, sessionId, jobId, request.subject);
|
|
369
|
+
const start = request.query?.start;
|
|
370
|
+
const limit = request.query?.limit;
|
|
371
|
+
const startValue = start === undefined ? '0' : start;
|
|
372
|
+
const limitValue = limit === undefined ? '10' : limit;
|
|
373
|
+
if (typeof startValue !== 'string' ||
|
|
374
|
+
typeof limitValue !== 'string' ||
|
|
375
|
+
!/^\d+$/.test(startValue) ||
|
|
376
|
+
!/^\d+$/.test(limitValue) ||
|
|
377
|
+
!Number.isSafeInteger(Number(startValue)) ||
|
|
378
|
+
!Number.isSafeInteger(Number(limitValue)) ||
|
|
379
|
+
Number(limitValue) > 2147483647)
|
|
380
|
+
throw new types_js_1.ApiError(400, 'Unsupported job log pagination.');
|
|
381
|
+
if (request.query?.type !== undefined ||
|
|
382
|
+
request.query?.timeout !== undefined)
|
|
383
|
+
throw new types_js_1.ApiError(400, 'Job log type and timeout are not supported by the emulator.');
|
|
384
|
+
const offset = Number(startValue);
|
|
385
|
+
const pageSize = Number(limitValue);
|
|
386
|
+
const uri = `/compute/sessions/${job.sessionId}/jobs/${job.id}/log`;
|
|
387
|
+
return {
|
|
388
|
+
status: 200,
|
|
389
|
+
body: {
|
|
390
|
+
accept: 'application/json',
|
|
391
|
+
name: 'log',
|
|
392
|
+
start: offset,
|
|
393
|
+
limit: pageSize,
|
|
394
|
+
count: job.log.length,
|
|
395
|
+
version: 2,
|
|
396
|
+
items: job.log
|
|
397
|
+
.slice(offset, offset + pageSize)
|
|
398
|
+
.map((line) => ({ line, type: 'NOTE', version: 2 })),
|
|
399
|
+
links: [
|
|
400
|
+
{
|
|
401
|
+
href: uri,
|
|
402
|
+
uri,
|
|
403
|
+
rel: 'self',
|
|
404
|
+
method: 'GET',
|
|
405
|
+
type: 'application/vnd.sas.collection',
|
|
406
|
+
itemType: 'application/vnd.sas.compute.log.line'
|
|
407
|
+
}
|
|
408
|
+
]
|
|
409
|
+
}
|
|
410
|
+
};
|
|
411
|
+
},
|
|
289
412
|
'GET /compute/sessions/{}/jobs/{}/log/content': async ({ services, params, request }) => {
|
|
290
413
|
const [sessionId, jobId] = segmentsOf(params);
|
|
291
414
|
const job = jobOf(services, sessionId, jobId, request.subject);
|
|
@@ -18,6 +18,17 @@ exports.VIYA_OPERATIONS = exports.DECLARED = void 0;
|
|
|
18
18
|
*/
|
|
19
19
|
const table_js_1 = require("./table.js");
|
|
20
20
|
exports.DECLARED = [
|
|
21
|
+
{
|
|
22
|
+
id: 'GET /compute/sessions/{}/jobs/{}/log',
|
|
23
|
+
method: 'GET',
|
|
24
|
+
path: '/compute/sessions/{}/jobs/{}/log',
|
|
25
|
+
steps: [],
|
|
26
|
+
statuses: [200, 400, 404],
|
|
27
|
+
queries: ['start', 'limit'],
|
|
28
|
+
request: { queries: ['start', 'limit'], body: undefined },
|
|
29
|
+
shape: undefined,
|
|
30
|
+
declared: 'The CLI follows the job log link directly and pages it; the adapter capture reads the different /log/content operation. SAS Compute documents this as a collection of log line objects.'
|
|
31
|
+
},
|
|
21
32
|
{
|
|
22
33
|
id: 'GET /compute/sessions/{}/filerefs/_webout/content',
|
|
23
34
|
method: 'GET',
|
|
@@ -32,6 +43,102 @@ exports.DECLARED = [
|
|
|
32
43
|
// there is no JSON shape to record
|
|
33
44
|
shape: undefined,
|
|
34
45
|
declared: 'The adapter fetches this only when a run expects a webout (`expectWebout`), and the recording pass submits a `%put` and reads the log instead. Without it an application cannot receive the data its service returns, so the emulator answers it from the job it just ran.'
|
|
46
|
+
},
|
|
47
|
+
// The application's own identity reads. No capture describes these at all: the
|
|
48
|
+
// recorder drives the client the adapter is, and Data Controller's group, user
|
|
49
|
+
// and deploy screens call the identity service from the browser instead. That
|
|
50
|
+
// is why they are declared rather than recorded, and why the scope they belong
|
|
51
|
+
// to is stated in `src/viya/appSurface.ts`.
|
|
52
|
+
{
|
|
53
|
+
id: 'GET /identities/groups',
|
|
54
|
+
method: 'GET',
|
|
55
|
+
path: '/identities/groups',
|
|
56
|
+
steps: [],
|
|
57
|
+
statuses: [200],
|
|
58
|
+
queries: ['sortBy', 'limit', 'start'],
|
|
59
|
+
request: { queries: ['sortBy', 'limit', 'start'], body: undefined },
|
|
60
|
+
// a collection of groups, whose own shape Viya publishes rather than an
|
|
61
|
+
// estate recording supplying it
|
|
62
|
+
shape: undefined,
|
|
63
|
+
declared: 'The application fetches the group list twice on its deploy screen - for the admin-group dropdown and, filtered, for the caller own groups - and aborts the wizard when that read fails. The adapter never calls it, so no recording pass reaches it.'
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
id: 'GET /identities/groups/{}/members',
|
|
67
|
+
method: 'GET',
|
|
68
|
+
path: '/identities/groups/{}/members',
|
|
69
|
+
steps: [],
|
|
70
|
+
statuses: [200, 404],
|
|
71
|
+
queries: ['limit'],
|
|
72
|
+
request: { queries: ['limit'], body: undefined },
|
|
73
|
+
shape: undefined,
|
|
74
|
+
declared: 'The group screen lists the accounts that hold a group, following the members link the group list advertises. The adapter has no identity route beyond the caller, so a capture driven by it cannot reach this one.'
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
id: 'GET /identities/users',
|
|
78
|
+
method: 'GET',
|
|
79
|
+
path: '/identities/users',
|
|
80
|
+
steps: [],
|
|
81
|
+
statuses: [200],
|
|
82
|
+
queries: ['limit', 'start'],
|
|
83
|
+
request: { queries: ['limit', 'start'], body: undefined },
|
|
84
|
+
shape: undefined,
|
|
85
|
+
declared: 'The user screen lists the estate accounts. The adapter does not offer an account list and never requests one, so the recording pass has no way to observe it.'
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
id: 'GET /identities/users/{}',
|
|
89
|
+
method: 'GET',
|
|
90
|
+
path: '/identities/users/{}',
|
|
91
|
+
steps: [],
|
|
92
|
+
statuses: [200, 404],
|
|
93
|
+
queries: [],
|
|
94
|
+
request: { queries: [], body: undefined },
|
|
95
|
+
shape: undefined,
|
|
96
|
+
declared: 'The user screen reads one account from the id the list returned, for the profile above the memberships. The adapter asks only about the caller, which is a different operation with its own row.'
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
id: 'GET /identities/users/@currentUser/memberships',
|
|
100
|
+
method: 'GET',
|
|
101
|
+
path: '/identities/users/@currentUser/memberships',
|
|
102
|
+
steps: [],
|
|
103
|
+
statuses: [200],
|
|
104
|
+
queries: ['limit', 'start'],
|
|
105
|
+
request: { queries: ['limit', 'start'], body: undefined },
|
|
106
|
+
shape: undefined,
|
|
107
|
+
declared: 'The deploy screen filters the admin-group list to the groups the caller belongs to, and shows every group when this read fails. The adapter reads the caller itself but never the caller memberships.'
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
id: 'GET /identities/users/{}/memberships',
|
|
111
|
+
method: 'GET',
|
|
112
|
+
path: '/identities/users/{}/memberships',
|
|
113
|
+
steps: [],
|
|
114
|
+
statuses: [200, 401],
|
|
115
|
+
queries: ['limit', 'start'],
|
|
116
|
+
request: { queries: ['limit', 'start'], body: undefined },
|
|
117
|
+
shape: undefined,
|
|
118
|
+
declared: 'The user screen lists the groups any account holds, addressed by the id the list returned. It is the same answer as the caller own memberships for one id, and the adapter asks for neither.'
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
id: 'GET /identities/users/{}/avatar/content',
|
|
122
|
+
method: 'GET',
|
|
123
|
+
path: '/identities/users/{}/avatar/content',
|
|
124
|
+
steps: [],
|
|
125
|
+
statuses: [404],
|
|
126
|
+
queries: [],
|
|
127
|
+
request: { queries: [], body: undefined },
|
|
128
|
+
// the body is an image when an estate holds one: there is no JSON shape
|
|
129
|
+
shape: undefined,
|
|
130
|
+
declared: 'The header renders the caller avatar from this URL, and an estate whose identity carries no avatar answers 404 so the client falls back to its own image. The adapter has no avatar read.'
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
id: 'GET /compute/contexts/{}',
|
|
134
|
+
method: 'GET',
|
|
135
|
+
path: '/compute/contexts/{}',
|
|
136
|
+
steps: [],
|
|
137
|
+
statuses: [200, 404],
|
|
138
|
+
queries: [],
|
|
139
|
+
request: { queries: [], body: undefined },
|
|
140
|
+
shape: undefined,
|
|
141
|
+
declared: 'The deploy screen reads each context in full, because the list view carries neither the batch identity nor the reuse setting it filters on. The capture recorded the list only, so the read it follows with is stated here.'
|
|
35
142
|
}
|
|
36
143
|
];
|
|
37
144
|
/** Every operation the emulator answers: what an estate did, plus what it must. */
|
|
@@ -91,6 +91,9 @@ const dispatchViya = async (services, method, path, request = {}) => {
|
|
|
91
91
|
message: `${found.operation.id} is not emulated. ${entry.reason ?? ''}`.trim()
|
|
92
92
|
}
|
|
93
93
|
};
|
|
94
|
+
if (found.operation.id === 'GET /compute/sessions/{}/variables/{}' &&
|
|
95
|
+
services.viya?.mockSysjobid !== true)
|
|
96
|
+
return { status: 501, headers, body: { message: overlay_js_1.SESSION_VARIABLE_REFUSAL } };
|
|
94
97
|
const handler = service_js_1.VIYA_HANDLERS[found.operation.id];
|
|
95
98
|
if (!handler)
|
|
96
99
|
return {
|