@sasjs/api 0.49.0 → 0.50.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 +11 -0
- package/build/browser.js +407 -47
- package/build/cjs/appstream/identity.js +2 -31
- package/build/cjs/uuid.js +30 -0
- package/build/cjs/viya/appSurface.js +241 -0
- package/build/cjs/viya/compute.js +71 -20
- package/build/cjs/viya/declared.js +96 -0
- package/build/cjs/viya/dispatch.js +10 -0
- package/build/cjs/viya/identity.js +191 -0
- package/build/cjs/viya/overlay.js +10 -0
- package/build/cjs/viya/seed.js +34 -8
- package/build/cjs/viya/service.js +3 -1
- package/build/cjs/viya/sessions.js +24 -10
- package/build/esm/appstream/identity.d.ts +1 -9
- package/build/esm/appstream/identity.d.ts.map +1 -1
- package/build/esm/appstream/identity.js +1 -30
- package/build/esm/identity/types.d.ts +2 -0
- package/build/esm/identity/types.d.ts.map +1 -1
- package/build/esm/uuid.d.ts +6 -0
- package/build/esm/uuid.d.ts.map +1 -0
- package/build/esm/uuid.js +26 -0
- 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 +73 -22
- package/build/esm/viya/declared.d.ts.map +1 -1
- package/build/esm/viya/declared.js +96 -0
- package/build/esm/viya/dispatch.d.ts +3 -0
- package/build/esm/viya/dispatch.d.ts.map +1 -1
- package/build/esm/viya/dispatch.js +11 -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.map +1 -1
- package/build/esm/viya/overlay.js +10 -0
- package/build/esm/viya/seed.d.ts +29 -7
- package/build/esm/viya/seed.d.ts.map +1 -1
- package/build/esm/viya/seed.js +32 -7
- 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 +24 -6
- package/build/esm/viya/sessions.d.ts.map +1 -1
- package/build/esm/viya/sessions.js +24 -10
- package/package.json +3 -1
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The application the inventory was measured from.
|
|
3
|
+
*
|
|
4
|
+
* Named rather than assumed: the inventory describes one application's calls,
|
|
5
|
+
* and a second application running on an emulated estate is a second inventory -
|
|
6
|
+
* not an edit to this one, whose rows would then be a claim about a client
|
|
7
|
+
* nobody measured.
|
|
8
|
+
*/
|
|
9
|
+
export const APP_SURFACE_APPLICATION = {
|
|
10
|
+
name: 'Data Controller for SAS',
|
|
11
|
+
repository: 'https://git.datacontroller.io/dc/dc',
|
|
12
|
+
measuredFrom: 'client/src'
|
|
13
|
+
};
|
|
14
|
+
/** Why a namespace the API-explorer page lists is not an answered operation. */
|
|
15
|
+
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.';
|
|
16
|
+
export const APP_SURFACE = [
|
|
17
|
+
// the auth flow the client shares with the adapter
|
|
18
|
+
{
|
|
19
|
+
path: '/SASLogon',
|
|
20
|
+
family: 'viya-auth',
|
|
21
|
+
decision: 'in',
|
|
22
|
+
reason: 'the auth flow, named by the application as well as the adapter, and the reason the emulated paths cannot be renamed'
|
|
23
|
+
},
|
|
24
|
+
// compute: the list, and the read of one context a deploy screen makes
|
|
25
|
+
{
|
|
26
|
+
path: '/compute/contexts',
|
|
27
|
+
family: 'viya-compute',
|
|
28
|
+
decision: 'in',
|
|
29
|
+
reason: 'the deploy screen lists the contexts it may run a session in, and picks the one the wizard will use'
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
path: '/compute/contexts/{}',
|
|
33
|
+
family: 'viya-compute',
|
|
34
|
+
decision: 'in',
|
|
35
|
+
reason: 'the deploy screen reads each context in full for its batch identity and reuse setting, which the list view does not carry'
|
|
36
|
+
},
|
|
37
|
+
// folders: the two reads an application makes of a deployment folder
|
|
38
|
+
{
|
|
39
|
+
path: '/folders/folders/@item',
|
|
40
|
+
family: 'viya-folders',
|
|
41
|
+
decision: 'in',
|
|
42
|
+
reason: 'the application resolves its own appLoc by path to find the services it will run'
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
path: '/folders/folders/{}/members',
|
|
46
|
+
family: 'viya-folders',
|
|
47
|
+
decision: 'in',
|
|
48
|
+
reason: 'the application lists the members of the folder it resolved, to find a deployed service'
|
|
49
|
+
},
|
|
50
|
+
// identities: the family the adapter asks one question of and an app asks six
|
|
51
|
+
{
|
|
52
|
+
path: '/identities/groups',
|
|
53
|
+
family: 'viya-identity',
|
|
54
|
+
decision: 'in',
|
|
55
|
+
reason: 'the deploy screen fetches the group list to offer the admin-group dropdown, and its failure aborts the wizard'
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
path: '/identities/groups/{}',
|
|
59
|
+
family: 'viya-identity',
|
|
60
|
+
decision: 'in',
|
|
61
|
+
reason: 'the group screen appends the group id and a member list to this fragment, to show who holds a group'
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
path: '/identities/users',
|
|
65
|
+
family: 'viya-identity',
|
|
66
|
+
decision: 'in',
|
|
67
|
+
reason: 'the user screen lists the accounts the estate holds'
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
path: '/identities/users/@currentUser',
|
|
71
|
+
family: 'viya-identity',
|
|
72
|
+
decision: 'in',
|
|
73
|
+
reason: 'the caller, which the application reads for its own profile as the adapter does'
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
path: '/identities/users/@currentUser/memberships',
|
|
77
|
+
family: 'viya-identity',
|
|
78
|
+
decision: 'in',
|
|
79
|
+
reason: 'the deploy screen filters the group list to the caller own groups, and falls back to all groups when this read fails'
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
path: '/identities/users/{}',
|
|
83
|
+
family: 'viya-identity',
|
|
84
|
+
decision: 'in',
|
|
85
|
+
reason: 'the user screen appends an account id to this fragment for a profile and its memberships'
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
path: '/identities/users/{}/avatar/content',
|
|
89
|
+
family: 'viya-identity',
|
|
90
|
+
decision: 'in',
|
|
91
|
+
reason: 'the header renders the caller avatar from this URL, and an account with none answers the 404 an estate would'
|
|
92
|
+
},
|
|
93
|
+
// the API roots and the explorer-only namespaces: named, never called
|
|
94
|
+
{
|
|
95
|
+
path: '/identities',
|
|
96
|
+
family: 'viya-identity',
|
|
97
|
+
decision: 'declined',
|
|
98
|
+
reason: 'the service root the application API map lists for its explorer page, not an endpoint any screen calls'
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
path: '/folders',
|
|
102
|
+
family: 'viya-folders',
|
|
103
|
+
decision: 'declined',
|
|
104
|
+
reason: 'the service root the application API map lists for its explorer page, not an endpoint any screen calls'
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
path: '/files',
|
|
108
|
+
family: 'viya-files',
|
|
109
|
+
decision: 'declined',
|
|
110
|
+
reason: 'the service root the application API map lists for its explorer page, not an endpoint any screen calls'
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
path: '/jobDefinitions',
|
|
114
|
+
family: 'viya-jobs',
|
|
115
|
+
decision: 'declined',
|
|
116
|
+
reason: 'the service root the application API map lists for its explorer page, not an endpoint any screen calls'
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
path: '/jobExecution',
|
|
120
|
+
family: 'viya-jobs',
|
|
121
|
+
decision: 'declined',
|
|
122
|
+
reason: 'the service root the application API map lists for its explorer page, not an endpoint any screen calls'
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
path: '/annotations',
|
|
126
|
+
family: 'viya-files',
|
|
127
|
+
decision: 'declined',
|
|
128
|
+
reason: EXPLORER_ONLY
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
path: '/authorization',
|
|
132
|
+
family: 'viya-identity',
|
|
133
|
+
decision: 'declined',
|
|
134
|
+
reason: EXPLORER_ONLY
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
path: '/businessRules',
|
|
138
|
+
family: 'viya-jobs',
|
|
139
|
+
decision: 'declined',
|
|
140
|
+
reason: EXPLORER_ONLY
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
path: '/dataMining',
|
|
144
|
+
family: 'viya-jobs',
|
|
145
|
+
decision: 'declined',
|
|
146
|
+
reason: EXPLORER_ONLY
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
path: '/decisionsRuntimeBuilder',
|
|
150
|
+
family: 'viya-jobs',
|
|
151
|
+
decision: 'declined',
|
|
152
|
+
reason: EXPLORER_ONLY
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
path: '/insights',
|
|
156
|
+
family: 'viya-jobs',
|
|
157
|
+
decision: 'declined',
|
|
158
|
+
reason: EXPLORER_ONLY
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
path: '/microanalyticScore',
|
|
162
|
+
family: 'viya-jobs',
|
|
163
|
+
decision: 'declined',
|
|
164
|
+
reason: EXPLORER_ONLY
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
path: '/mlPipelineAutomation',
|
|
168
|
+
family: 'viya-jobs',
|
|
169
|
+
decision: 'declined',
|
|
170
|
+
reason: EXPLORER_ONLY
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
path: '/modelManagement',
|
|
174
|
+
family: 'viya-jobs',
|
|
175
|
+
decision: 'declined',
|
|
176
|
+
reason: EXPLORER_ONLY
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
path: '/modelPublish',
|
|
180
|
+
family: 'viya-jobs',
|
|
181
|
+
decision: 'declined',
|
|
182
|
+
reason: EXPLORER_ONLY
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
path: '/modelRepository',
|
|
186
|
+
family: 'viya-jobs',
|
|
187
|
+
decision: 'declined',
|
|
188
|
+
reason: EXPLORER_ONLY
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
path: '/referenceData',
|
|
192
|
+
family: 'viya-jobs',
|
|
193
|
+
decision: 'declined',
|
|
194
|
+
reason: EXPLORER_ONLY
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
path: '/relationships',
|
|
198
|
+
family: 'viya-folders',
|
|
199
|
+
decision: 'declined',
|
|
200
|
+
reason: EXPLORER_ONLY
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
path: '/reportImages',
|
|
204
|
+
family: 'viya-jobs',
|
|
205
|
+
decision: 'declined',
|
|
206
|
+
reason: EXPLORER_ONLY
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
path: '/reportTransforms',
|
|
210
|
+
family: 'viya-jobs',
|
|
211
|
+
decision: 'declined',
|
|
212
|
+
reason: EXPLORER_ONLY
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
path: '/reports',
|
|
216
|
+
family: 'viya-jobs',
|
|
217
|
+
decision: 'declined',
|
|
218
|
+
reason: EXPLORER_ONLY
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
path: '/subjectContacts',
|
|
222
|
+
family: 'viya-jobs',
|
|
223
|
+
decision: 'declined',
|
|
224
|
+
reason: EXPLORER_ONLY
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
path: '/treatmentDefinitions',
|
|
228
|
+
family: 'viya-jobs',
|
|
229
|
+
decision: 'declined',
|
|
230
|
+
reason: EXPLORER_ONLY
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
path: '/visualAnalytics',
|
|
234
|
+
family: 'viya-jobs',
|
|
235
|
+
decision: 'declined',
|
|
236
|
+
reason: EXPLORER_ONLY
|
|
237
|
+
}
|
|
238
|
+
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compute.d.ts","sourceRoot":"","sources":["../../../src/viya/compute.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAChE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"compute.d.ts","sourceRoot":"","sources":["../../../src/viya/compute.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAChE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAMnD;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB,sCAAsC,CAAA;AAEvE,2EAA2E;AAC3E,eAAO,MAAM,mBAAmB,QAAuC,CAAA;AAgDvE;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,MAAM,GAAG,SAAS,KAAG,MAM5D,CAAA;AAmKD,eAAO,MAAM,gBAAgB,EAAE,MAAM,CACnC,MAAM,EACN,CAAC,OAAO,EAAE;IACR,QAAQ,EAAE,QAAQ,CAAA;IAClB,OAAO,EAAE;QACP,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAA;QAC1C,IAAI,CAAC,EAAE,OAAO,CAAA;QACd,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,OAAO,CAAC,EAAE,OAAO,CAAA;KAClB,CAAA;IACD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC/B,KAAK,OAAO,CAAC,WAAW,CAAC,CA8N3B,CAAA"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { ApiError } from '../types.js';
|
|
2
|
-
import { normaliseServerUrl } from './seed.js';
|
|
3
|
-
import { seedOf } from './seed.js';
|
|
2
|
+
import { estateKeyOf, normaliseServerUrl, seedOf } from './seed.js';
|
|
4
3
|
import { estateFor } from './sessions.js';
|
|
5
|
-
import { idFor, callerId } from './ids.js';
|
|
4
|
+
import { idFor, callerId, EMULATED_NOW } from './ids.js';
|
|
6
5
|
/**
|
|
7
6
|
* The name the emulator answers when a client asks for no particular context.
|
|
8
7
|
*
|
|
@@ -51,7 +50,7 @@ const linksFor = (uri, type, collection = false, itemType = false) => [
|
|
|
51
50
|
...(itemType ? { itemType: type } : {})
|
|
52
51
|
}
|
|
53
52
|
];
|
|
54
|
-
const estateOf = (services) => estateFor(seedOf(services.viya));
|
|
53
|
+
const estateOf = (services) => estateFor(estateKeyOf(services.viya), seedOf(services.viya));
|
|
55
54
|
/**
|
|
56
55
|
* The context name a client asked for.
|
|
57
56
|
*
|
|
@@ -73,6 +72,31 @@ const contextBody = (name, caller) => ({
|
|
|
73
72
|
version: 2,
|
|
74
73
|
links: linksFor(`/compute/contexts/${EMULATED_CONTEXT_ID}`, 'application/vnd.sas.compute.context')
|
|
75
74
|
});
|
|
75
|
+
/**
|
|
76
|
+
* The context in full, for the read a client makes of one it already holds.
|
|
77
|
+
*
|
|
78
|
+
* The list view Viya answers is deliberately minimal, so a client that needs a
|
|
79
|
+
* context's attributes reads the context itself - Data Controller's deploy
|
|
80
|
+
* screen fetches each one to pick up its batch identity. The attributes are the
|
|
81
|
+
* ones an emulated estate truthfully has: nothing runs as a batch identity here,
|
|
82
|
+
* and `reuseServerProcesses` is `false` for the same reason, which is what leaves
|
|
83
|
+
* a client's batch-id list empty rather than inventing an account to run as.
|
|
84
|
+
*/
|
|
85
|
+
const contextDetailsBody = (caller) => ({
|
|
86
|
+
...contextBody(DEFAULT_CONTEXT_NAME, caller),
|
|
87
|
+
description: 'The compute context an emulated estate answers for',
|
|
88
|
+
creationTimeStamp: EMULATED_NOW,
|
|
89
|
+
modifiedTimeStamp: EMULATED_NOW,
|
|
90
|
+
modifiedBy: caller,
|
|
91
|
+
launchType: 'service',
|
|
92
|
+
launchContext: { contextId: EMULATED_CONTEXT_ID },
|
|
93
|
+
environment: { autoExecLines: [] },
|
|
94
|
+
attributes: {
|
|
95
|
+
reuseServerProcesses: 'false',
|
|
96
|
+
allowXCMD: 'false',
|
|
97
|
+
serverMinAvailable: '1'
|
|
98
|
+
}
|
|
99
|
+
});
|
|
76
100
|
const sessionBody = (services, session, autoExecLines, caller) => {
|
|
77
101
|
const { id } = session;
|
|
78
102
|
const uri = `/compute/sessions/${id}`;
|
|
@@ -133,15 +157,31 @@ const jobBody = (job) => {
|
|
|
133
157
|
])
|
|
134
158
|
};
|
|
135
159
|
};
|
|
136
|
-
/** The
|
|
137
|
-
const
|
|
160
|
+
/** The browser mock has an anonymous principal distinct from every named user. */
|
|
161
|
+
const ownerOf = (subject) => {
|
|
162
|
+
if (subject === undefined)
|
|
163
|
+
return { kind: 'anonymous' };
|
|
164
|
+
if (!subject || typeof subject.userId !== 'string' || !subject.userId.trim())
|
|
165
|
+
throw new ApiError(401, 'A valid caller is required.');
|
|
166
|
+
if (subject.ownerId === undefined)
|
|
167
|
+
return { kind: 'user', key: subject.userId };
|
|
168
|
+
if (typeof subject.ownerId !== 'string' || !subject.ownerId.trim())
|
|
169
|
+
throw new ApiError(401, 'A valid caller is required.');
|
|
170
|
+
return { kind: 'account', key: subject.ownerId };
|
|
171
|
+
};
|
|
172
|
+
/** Ownerless records cannot be attributed and are deliberately inaccessible. */
|
|
173
|
+
const sessionOf = (services, id, subject) => {
|
|
174
|
+
const owner = ownerOf(subject);
|
|
138
175
|
const session = estateOf(services).session(id);
|
|
139
|
-
if (!session
|
|
176
|
+
if (!session ||
|
|
177
|
+
!session.owner ||
|
|
178
|
+
session.owner.kind !== owner.kind ||
|
|
179
|
+
session.owner.key !== owner.key)
|
|
140
180
|
throw new ApiError(404, `Session with ID '${id}' was not found.`);
|
|
141
181
|
return session;
|
|
142
182
|
};
|
|
143
|
-
const jobOf = (services, sessionId, jobId) => {
|
|
144
|
-
const job = sessionOf(services, sessionId).jobs.get(jobId);
|
|
183
|
+
const jobOf = (services, sessionId, jobId, subject) => {
|
|
184
|
+
const job = sessionOf(services, sessionId, subject).jobs.get(jobId);
|
|
145
185
|
if (!job)
|
|
146
186
|
throw new ApiError(404, `Job with ID '${jobId}' was not found.`);
|
|
147
187
|
return job;
|
|
@@ -172,29 +212,37 @@ export const COMPUTE_HANDLERS = {
|
|
|
172
212
|
}
|
|
173
213
|
};
|
|
174
214
|
},
|
|
215
|
+
'GET /compute/contexts/{}': async ({ request, params }) => {
|
|
216
|
+
// the estate has one context and its id does not move, so an id it is not is
|
|
217
|
+
// an id no context here ever had - the same refusal the drive makes for an
|
|
218
|
+
// unknown folder rather than a body about some other context
|
|
219
|
+
if (params.id !== EMULATED_CONTEXT_ID)
|
|
220
|
+
throw new ApiError(404, `No compute context matches the id ${params.id}. The emulated estate answers one context, and this is not its id.`);
|
|
221
|
+
return { status: 200, body: contextDetailsBody(callerId(request.subject)) };
|
|
222
|
+
},
|
|
175
223
|
'POST /compute/contexts/{}/sessions': async ({ services, params, request }) => {
|
|
176
224
|
if (params.id !== EMULATED_CONTEXT_ID)
|
|
177
225
|
throw new ApiError(404, `Context with ID '${params.id}' was not found.`);
|
|
178
226
|
const body = (request.body ?? {});
|
|
179
|
-
const session = estateOf(services).create();
|
|
227
|
+
const session = estateOf(services).create(ownerOf(request.subject));
|
|
180
228
|
return {
|
|
181
229
|
status: 201,
|
|
182
230
|
body: sessionBody(services, session, body.environment?.autoExecLines ?? [], callerId(request.subject))
|
|
183
231
|
};
|
|
184
232
|
},
|
|
185
|
-
'GET /compute/sessions/{}/state': async ({ services, params }) => {
|
|
186
|
-
sessionOf(services, params.id);
|
|
233
|
+
'GET /compute/sessions/{}/state': async ({ services, params, request }) => {
|
|
234
|
+
sessionOf(services, params.id, request.subject);
|
|
187
235
|
// a bare enum, not an object: the adapter calls `.trim()` on the answer, and
|
|
188
236
|
// the capture recorded no shape here because there is no JSON body
|
|
189
237
|
return { status: 200, body: 'idle' };
|
|
190
238
|
},
|
|
191
|
-
'DELETE /compute/sessions/{}': async ({ services, params }) => {
|
|
192
|
-
sessionOf(services, params.id);
|
|
239
|
+
'DELETE /compute/sessions/{}': async ({ services, params, request }) => {
|
|
240
|
+
sessionOf(services, params.id, request.subject);
|
|
193
241
|
estateOf(services).remove(params.id);
|
|
194
242
|
return { status: 204, body: undefined };
|
|
195
243
|
},
|
|
196
244
|
'POST /compute/sessions/{}/jobs': async ({ services, params, request }) => {
|
|
197
|
-
const session = sessionOf(services, params.id);
|
|
245
|
+
const session = sessionOf(services, params.id, request.subject);
|
|
198
246
|
const body = (request.body ?? {});
|
|
199
247
|
const job = estateOf(services).submit(session, body);
|
|
200
248
|
const execute = services.viya?.execute;
|
|
@@ -233,8 +281,8 @@ export const COMPUTE_HANDLERS = {
|
|
|
233
281
|
});
|
|
234
282
|
return { status: 201, body: jobBody(job) };
|
|
235
283
|
},
|
|
236
|
-
'GET /compute/sessions/{}/filerefs/_webout/content': async ({ services, params }) => {
|
|
237
|
-
const session = sessionOf(services, params.id);
|
|
284
|
+
'GET /compute/sessions/{}/filerefs/_webout/content': async ({ services, params, request }) => {
|
|
285
|
+
const session = sessionOf(services, params.id, request.subject);
|
|
238
286
|
const last = [...session.jobs.values()].pop();
|
|
239
287
|
if (!last)
|
|
240
288
|
throw new ApiError(404, 'This session has no `_webout` yet: nothing has run in it.');
|
|
@@ -253,20 +301,23 @@ export const COMPUTE_HANDLERS = {
|
|
|
253
301
|
headers: { 'content-type': 'text/plain' }
|
|
254
302
|
};
|
|
255
303
|
},
|
|
256
|
-
'GET /compute/sessions/{}/jobs/{}': async ({ services, params }) => {
|
|
304
|
+
'GET /compute/sessions/{}/jobs/{}': async ({ services, params, request }) => {
|
|
257
305
|
const [sessionId, jobId] = segmentsOf(params);
|
|
258
|
-
return {
|
|
306
|
+
return {
|
|
307
|
+
status: 200,
|
|
308
|
+
body: jobBody(jobOf(services, sessionId, jobId, request.subject))
|
|
309
|
+
};
|
|
259
310
|
},
|
|
260
|
-
'GET /compute/sessions/{}/jobs/{}/state': async ({ services, params }) => {
|
|
311
|
+
'GET /compute/sessions/{}/jobs/{}/state': async ({ services, params, request }) => {
|
|
261
312
|
const [sessionId, jobId] = segmentsOf(params);
|
|
262
313
|
return {
|
|
263
314
|
status: 200,
|
|
264
|
-
body: jobOf(services, sessionId, jobId).state
|
|
315
|
+
body: jobOf(services, sessionId, jobId, request.subject).state
|
|
265
316
|
};
|
|
266
317
|
},
|
|
267
318
|
'GET /compute/sessions/{}/jobs/{}/log/content': async ({ services, params, request }) => {
|
|
268
319
|
const [sessionId, jobId] = segmentsOf(params);
|
|
269
|
-
const job = jobOf(services, sessionId, jobId);
|
|
320
|
+
const job = jobOf(services, sessionId, jobId, request.subject);
|
|
270
321
|
const start = Number(request.query?.start ?? 0) || 0;
|
|
271
322
|
const limit = Number(request.query?.limit ?? 0) || 0;
|
|
272
323
|
const lines = job.log.slice(start, limit ? start + limit : undefined);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"declared.d.ts","sourceRoot":"","sources":["../../../src/viya/declared.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAc,KAAK,aAAa,EAAE,MAAM,YAAY,CAAA;AAE3D,wDAAwD;AACxD,MAAM,WAAW,iBAAkB,SAAQ,aAAa;IACtD,qEAAqE;IACrE,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,eAAO,MAAM,QAAQ,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"declared.d.ts","sourceRoot":"","sources":["../../../src/viya/declared.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAc,KAAK,aAAa,EAAE,MAAM,YAAY,CAAA;AAE3D,wDAAwD;AACxD,MAAM,WAAW,iBAAkB,SAAQ,aAAa;IACtD,qEAAqE;IACrE,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,eAAO,MAAM,QAAQ,EAAE,iBAAiB,EA0HvC,CAAA;AAED,mFAAmF;AACnF,eAAO,MAAM,eAAe,EAAE,aAAa,EAAiC,CAAA"}
|
|
@@ -29,6 +29,102 @@ export const DECLARED = [
|
|
|
29
29
|
// there is no JSON shape to record
|
|
30
30
|
shape: undefined,
|
|
31
31
|
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.'
|
|
32
|
+
},
|
|
33
|
+
// The application's own identity reads. No capture describes these at all: the
|
|
34
|
+
// recorder drives the client the adapter is, and Data Controller's group, user
|
|
35
|
+
// and deploy screens call the identity service from the browser instead. That
|
|
36
|
+
// is why they are declared rather than recorded, and why the scope they belong
|
|
37
|
+
// to is stated in `src/viya/appSurface.ts`.
|
|
38
|
+
{
|
|
39
|
+
id: 'GET /identities/groups',
|
|
40
|
+
method: 'GET',
|
|
41
|
+
path: '/identities/groups',
|
|
42
|
+
steps: [],
|
|
43
|
+
statuses: [200],
|
|
44
|
+
queries: ['sortBy', 'limit', 'start'],
|
|
45
|
+
request: { queries: ['sortBy', 'limit', 'start'], body: undefined },
|
|
46
|
+
// a collection of groups, whose own shape Viya publishes rather than an
|
|
47
|
+
// estate recording supplying it
|
|
48
|
+
shape: undefined,
|
|
49
|
+
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.'
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
id: 'GET /identities/groups/{}/members',
|
|
53
|
+
method: 'GET',
|
|
54
|
+
path: '/identities/groups/{}/members',
|
|
55
|
+
steps: [],
|
|
56
|
+
statuses: [200, 404],
|
|
57
|
+
queries: ['limit'],
|
|
58
|
+
request: { queries: ['limit'], body: undefined },
|
|
59
|
+
shape: undefined,
|
|
60
|
+
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.'
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
id: 'GET /identities/users',
|
|
64
|
+
method: 'GET',
|
|
65
|
+
path: '/identities/users',
|
|
66
|
+
steps: [],
|
|
67
|
+
statuses: [200],
|
|
68
|
+
queries: ['limit', 'start'],
|
|
69
|
+
request: { queries: ['limit', 'start'], body: undefined },
|
|
70
|
+
shape: undefined,
|
|
71
|
+
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.'
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
id: 'GET /identities/users/{}',
|
|
75
|
+
method: 'GET',
|
|
76
|
+
path: '/identities/users/{}',
|
|
77
|
+
steps: [],
|
|
78
|
+
statuses: [200, 404],
|
|
79
|
+
queries: [],
|
|
80
|
+
request: { queries: [], body: undefined },
|
|
81
|
+
shape: undefined,
|
|
82
|
+
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.'
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
id: 'GET /identities/users/@currentUser/memberships',
|
|
86
|
+
method: 'GET',
|
|
87
|
+
path: '/identities/users/@currentUser/memberships',
|
|
88
|
+
steps: [],
|
|
89
|
+
statuses: [200],
|
|
90
|
+
queries: ['limit', 'start'],
|
|
91
|
+
request: { queries: ['limit', 'start'], body: undefined },
|
|
92
|
+
shape: undefined,
|
|
93
|
+
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.'
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
id: 'GET /identities/users/{}/memberships',
|
|
97
|
+
method: 'GET',
|
|
98
|
+
path: '/identities/users/{}/memberships',
|
|
99
|
+
steps: [],
|
|
100
|
+
statuses: [200, 401],
|
|
101
|
+
queries: ['limit', 'start'],
|
|
102
|
+
request: { queries: ['limit', 'start'], body: undefined },
|
|
103
|
+
shape: undefined,
|
|
104
|
+
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.'
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
id: 'GET /identities/users/{}/avatar/content',
|
|
108
|
+
method: 'GET',
|
|
109
|
+
path: '/identities/users/{}/avatar/content',
|
|
110
|
+
steps: [],
|
|
111
|
+
statuses: [404],
|
|
112
|
+
queries: [],
|
|
113
|
+
request: { queries: [], body: undefined },
|
|
114
|
+
// the body is an image when an estate holds one: there is no JSON shape
|
|
115
|
+
shape: undefined,
|
|
116
|
+
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.'
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
id: 'GET /compute/contexts/{}',
|
|
120
|
+
method: 'GET',
|
|
121
|
+
path: '/compute/contexts/{}',
|
|
122
|
+
steps: [],
|
|
123
|
+
statuses: [200, 404],
|
|
124
|
+
queries: [],
|
|
125
|
+
request: { queries: [], body: undefined },
|
|
126
|
+
shape: undefined,
|
|
127
|
+
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.'
|
|
32
128
|
}
|
|
33
129
|
];
|
|
34
130
|
/** Every operation the emulator answers: what an estate did, plus what it must. */
|
|
@@ -30,6 +30,9 @@ export declare const findViyaOperation: (method: string, path: string) => ViyaMa
|
|
|
30
30
|
*
|
|
31
31
|
* `request` is the same shape the SASjs dispatch takes, so a host that already
|
|
32
32
|
* resolves a caller - a session cookie - passes `subject` rather than a token.
|
|
33
|
+
* For compute sessions a host with credentials must pass the authenticated
|
|
34
|
+
* subject on every request: a token alone is refused. No subject and no token
|
|
35
|
+
* is the anonymous browser mock, not an authentication boundary.
|
|
33
36
|
*/
|
|
34
37
|
export declare const dispatchViya: (services: Services, method: string, path: string, request?: ApiRequest) => Promise<ViyaResponse>;
|
|
35
38
|
//# sourceMappingURL=dispatch.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../../../src/viya/dispatch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAE5E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAM/C,wDAAwD;AACxD,MAAM,WAAW,YAAa,SAAQ,WAAW;IAC/C,uEAAuE;IACvE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAChC;AAED,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,aAAa,CAAA;IACxB,sDAAsD;IACtD,QAAQ,EAAE,MAAM,EAAE,CAAA;CACnB;AA4BD,2EAA2E;AAC3E,eAAO,MAAM,iBAAiB,GAC5B,QAAQ,MAAM,EACd,MAAM,MAAM,KACX,SAAS,GAAG,SA0Bd,CAAA;AAED
|
|
1
|
+
{"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../../../src/viya/dispatch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAE5E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAM/C,wDAAwD;AACxD,MAAM,WAAW,YAAa,SAAQ,WAAW;IAC/C,uEAAuE;IACvE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAChC;AAED,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,aAAa,CAAA;IACxB,sDAAsD;IACtD,QAAQ,EAAE,MAAM,EAAE,CAAA;CACnB;AA4BD,2EAA2E;AAC3E,eAAO,MAAM,iBAAiB,GAC5B,QAAQ,MAAM,EACd,MAAM,MAAM,KACX,SAAS,GAAG,SA0Bd,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,GACvB,UAAU,QAAQ,EAClB,QAAQ,MAAM,EACd,MAAM,MAAM,EACZ,UAAS,UAAe,KACvB,OAAO,CAAC,YAAY,CAkGtB,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isApiError } from '../types.js';
|
|
1
|
+
import { ApiError, isApiError } from '../types.js';
|
|
2
2
|
import { VIYA_OPERATIONS } from './declared.js';
|
|
3
3
|
import { VIYA_OVERLAY } from './overlay.js';
|
|
4
4
|
import { VIYA_HANDLERS } from './service.js';
|
|
@@ -52,6 +52,9 @@ export const findViyaOperation = (method, path) => {
|
|
|
52
52
|
*
|
|
53
53
|
* `request` is the same shape the SASjs dispatch takes, so a host that already
|
|
54
54
|
* resolves a caller - a session cookie - passes `subject` rather than a token.
|
|
55
|
+
* For compute sessions a host with credentials must pass the authenticated
|
|
56
|
+
* subject on every request: a token alone is refused. No subject and no token
|
|
57
|
+
* is the anonymous browser mock, not an authentication boundary.
|
|
55
58
|
*/
|
|
56
59
|
export const dispatchViya = async (services, method, path, request = {}) => {
|
|
57
60
|
const headers = emulatedHeaders();
|
|
@@ -94,6 +97,13 @@ export const dispatchViya = async (services, method, path, request = {}) => {
|
|
|
94
97
|
}
|
|
95
98
|
};
|
|
96
99
|
try {
|
|
100
|
+
// A host must resolve credentials before compute dispatch. A missing subject
|
|
101
|
+
// is the anonymous mock only when no credential was supplied.
|
|
102
|
+
if (request.subject === undefined &&
|
|
103
|
+
request.token !== undefined &&
|
|
104
|
+
(found.operation.id === 'POST /compute/contexts/{}/sessions' ||
|
|
105
|
+
found.operation.path.startsWith('/compute/sessions/')))
|
|
106
|
+
throw new ApiError(401, 'A valid caller is required.');
|
|
97
107
|
const answer = await handler({
|
|
98
108
|
services,
|
|
99
109
|
request,
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Viya identity answers an application reads for itself.
|
|
3
|
+
*
|
|
4
|
+
* The adapter asks Viya who the caller is and nothing else, so `/identities`
|
|
5
|
+
* used to be one operation here. An application asks more than that: Data
|
|
6
|
+
* Controller's group, user and deploy screens call the identity service
|
|
7
|
+
* directly - `GET /identities/groups` twice on the deploy screen alone - and on
|
|
8
|
+
* an emulated estate those calls answered 404, which is a screen a visitor
|
|
9
|
+
* cannot use. `src/viya/appSurface.ts` is where those calls are declared, and
|
|
10
|
+
* this is where they are answered.
|
|
11
|
+
*
|
|
12
|
+
* The estate has one identity: the store the package already serves the
|
|
13
|
+
* administration routes from. That store is the project's `mock-identity.json`
|
|
14
|
+
* on a mock site and the host's own records on a server, so a group named in the
|
|
15
|
+
* fixture is the group this answers - nothing here invents a population. The
|
|
16
|
+
* port is `RecordService` rather than `IdentityStore` because the administration
|
|
17
|
+
* routes' gates belong with them: a caller with no account gets the same 401
|
|
18
|
+
* here that it gets there.
|
|
19
|
+
*/
|
|
20
|
+
import type { ApiResponse, Services } from '../host/dispatch.js';
|
|
21
|
+
import type { Subject } from '../identity/types.js';
|
|
22
|
+
import type { RecordService } from '../identity/records.js';
|
|
23
|
+
/** The port these handlers read, or the capability the host did not supply. */
|
|
24
|
+
export declare const requireRecords: (services: Services) => RecordService;
|
|
25
|
+
export declare const IDENTITY_HANDLERS: Record<string, (context: {
|
|
26
|
+
services: Services;
|
|
27
|
+
request: {
|
|
28
|
+
query?: Record<string, string | undefined>;
|
|
29
|
+
subject?: Subject;
|
|
30
|
+
token?: string;
|
|
31
|
+
};
|
|
32
|
+
params: Record<string, string>;
|
|
33
|
+
}) => Promise<ApiResponse>>;
|
|
34
|
+
//# sourceMappingURL=identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../../src/viya/identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAEhE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAG3D,+EAA+E;AAC/E,eAAO,MAAM,cAAc,GAAI,UAAU,QAAQ,KAAG,aAQnD,CAAA;AAqID,eAAO,MAAM,iBAAiB,EAAE,MAAM,CACpC,MAAM,EACN,CAAC,OAAO,EAAE;IACR,QAAQ,EAAE,QAAQ,CAAA;IAClB,OAAO,EAAE;QACP,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAA;QAC1C,OAAO,CAAC,EAAE,OAAO,CAAA;QACjB,KAAK,CAAC,EAAE,MAAM,CAAA;KACf,CAAA;IACD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC/B,KAAK,OAAO,CAAC,WAAW,CAAC,CAsJ3B,CAAA"}
|