@sasjs/api 0.49.1 → 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 +7 -0
- package/build/browser.js +339 -8
- package/build/cjs/viya/appSurface.js +241 -0
- package/build/cjs/viya/compute.js +33 -0
- package/build/cjs/viya/declared.js +96 -0
- package/build/cjs/viya/identity.js +191 -0
- package/build/cjs/viya/overlay.js +10 -0
- 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 +34 -1
- package/build/esm/viya/declared.d.ts.map +1 -1
- package/build/esm/viya/declared.js +96 -0
- 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/service.d.ts.map +1 -1
- package/build/esm/viya/service.js +3 -1
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -26,6 +26,13 @@ Where the document is wrong, it is corrected in `sasjs/server` and re-vendored h
|
|
|
26
26
|
`createAdminService` carries the three Admin reports over the host's `AdminReports`, owning the diagnostics shape, the log-name rule and the `lines` bounds; `createDirectoryService` imports a directory over a five-method `DirectoryStore`, creating what is missing and leaving what exists; `createHomeService` stamps the interface's shell with a token derived from its bundle, so a cached page cannot pin an old build.
|
|
27
27
|
They are `async`, take a `DriveStore`, and import nothing - so the same code runs under Express and inside a service worker.
|
|
28
28
|
|
|
29
|
+
**The emulated Viya estate's scope** is two measurements, not one.
|
|
30
|
+
`src/viya/surface.ts` classifies every path `@sasjs/adapter` was measured to build (`spec/viya/adapter-paths.json`, re-derived by `npm run check:scope` from the pinned adapter).
|
|
31
|
+
`src/viya/appSurface.ts` does the same for an application's own calls to the platform (`spec/viya/app-paths.json`, re-derived by `npm run check:app-scope -- <checkout>`), because an application can speak Viya REST directly where the adapter has no method: Data Controller's group, user and deploy screens do, and a scope measured from the adapter alone left those paths answering the emulator's 404.
|
|
32
|
+
Both lists are held against their inventory in both directions by `spec/viyaAppScope.spec.ts` and `spec/viyaTable.spec.ts`, and an in-scope path with no operation answering it fails the app spec - which is the failure the adapter-only scope could not see.
|
|
33
|
+
`check:app-scope` is not a CI step: it needs a checkout of the application, so it runs where that checkout exists and states so when it is not given one.
|
|
34
|
+
The operations an application's calls add are declared rather than captured (`src/viya/declared.ts`), since no recording pass driven by the adapter can observe them.
|
|
35
|
+
|
|
29
36
|
**Viya compute ownership.** A multi-user host must authenticate its caller and pass the resolved `subject` to `dispatchViya` on every compute session request. Set `subject.ownerId` to the immutable account ID from the host's identity store, never from request data. `subject.userId` still controls the username on the wire. Hosts that omit `ownerId` use `userId` as before, in a separate namespace; switching an existing host to stable IDs requires recreating any live username-scoped sessions. Ownership spans client IDs, and another owner gets the same 404 as for a missing session. Ownerless records are refused. A token without a resolved subject is refused; no subject and no token selects a shared anonymous browser mock, not an authentication boundary. Session stores are keyed by the full normalised `serverUrl`, not the 32-bit seed.
|
|
30
37
|
|
|
31
38
|
New emulated session IDs are opaque UUID v4 strings (Web Crypto is required). Job IDs still derive from their session ID and therefore change with it; clients should use the returned IDs or links rather than parse their format. This does not change externally issued Viya IDs or the emulator's seeded folder IDs and generated logs.
|
package/build/browser.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* @sasjs/api 0.
|
|
1
|
+
/* @sasjs/api 0.50.0 - the SASjs Server API, for a service worker. https://github.com/sasjs/api */
|
|
2
2
|
"use strict";
|
|
3
3
|
var SASjsApi = (() => {
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -5420,6 +5420,102 @@ var SASjsApi = (() => {
|
|
|
5420
5420
|
// there is no JSON shape to record
|
|
5421
5421
|
shape: void 0,
|
|
5422
5422
|
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."
|
|
5423
|
+
},
|
|
5424
|
+
// The application's own identity reads. No capture describes these at all: the
|
|
5425
|
+
// recorder drives the client the adapter is, and Data Controller's group, user
|
|
5426
|
+
// and deploy screens call the identity service from the browser instead. That
|
|
5427
|
+
// is why they are declared rather than recorded, and why the scope they belong
|
|
5428
|
+
// to is stated in `src/viya/appSurface.ts`.
|
|
5429
|
+
{
|
|
5430
|
+
id: "GET /identities/groups",
|
|
5431
|
+
method: "GET",
|
|
5432
|
+
path: "/identities/groups",
|
|
5433
|
+
steps: [],
|
|
5434
|
+
statuses: [200],
|
|
5435
|
+
queries: ["sortBy", "limit", "start"],
|
|
5436
|
+
request: { queries: ["sortBy", "limit", "start"], body: void 0 },
|
|
5437
|
+
// a collection of groups, whose own shape Viya publishes rather than an
|
|
5438
|
+
// estate recording supplying it
|
|
5439
|
+
shape: void 0,
|
|
5440
|
+
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."
|
|
5441
|
+
},
|
|
5442
|
+
{
|
|
5443
|
+
id: "GET /identities/groups/{}/members",
|
|
5444
|
+
method: "GET",
|
|
5445
|
+
path: "/identities/groups/{}/members",
|
|
5446
|
+
steps: [],
|
|
5447
|
+
statuses: [200, 404],
|
|
5448
|
+
queries: ["limit"],
|
|
5449
|
+
request: { queries: ["limit"], body: void 0 },
|
|
5450
|
+
shape: void 0,
|
|
5451
|
+
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."
|
|
5452
|
+
},
|
|
5453
|
+
{
|
|
5454
|
+
id: "GET /identities/users",
|
|
5455
|
+
method: "GET",
|
|
5456
|
+
path: "/identities/users",
|
|
5457
|
+
steps: [],
|
|
5458
|
+
statuses: [200],
|
|
5459
|
+
queries: ["limit", "start"],
|
|
5460
|
+
request: { queries: ["limit", "start"], body: void 0 },
|
|
5461
|
+
shape: void 0,
|
|
5462
|
+
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."
|
|
5463
|
+
},
|
|
5464
|
+
{
|
|
5465
|
+
id: "GET /identities/users/{}",
|
|
5466
|
+
method: "GET",
|
|
5467
|
+
path: "/identities/users/{}",
|
|
5468
|
+
steps: [],
|
|
5469
|
+
statuses: [200, 404],
|
|
5470
|
+
queries: [],
|
|
5471
|
+
request: { queries: [], body: void 0 },
|
|
5472
|
+
shape: void 0,
|
|
5473
|
+
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."
|
|
5474
|
+
},
|
|
5475
|
+
{
|
|
5476
|
+
id: "GET /identities/users/@currentUser/memberships",
|
|
5477
|
+
method: "GET",
|
|
5478
|
+
path: "/identities/users/@currentUser/memberships",
|
|
5479
|
+
steps: [],
|
|
5480
|
+
statuses: [200],
|
|
5481
|
+
queries: ["limit", "start"],
|
|
5482
|
+
request: { queries: ["limit", "start"], body: void 0 },
|
|
5483
|
+
shape: void 0,
|
|
5484
|
+
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."
|
|
5485
|
+
},
|
|
5486
|
+
{
|
|
5487
|
+
id: "GET /identities/users/{}/memberships",
|
|
5488
|
+
method: "GET",
|
|
5489
|
+
path: "/identities/users/{}/memberships",
|
|
5490
|
+
steps: [],
|
|
5491
|
+
statuses: [200, 401],
|
|
5492
|
+
queries: ["limit", "start"],
|
|
5493
|
+
request: { queries: ["limit", "start"], body: void 0 },
|
|
5494
|
+
shape: void 0,
|
|
5495
|
+
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."
|
|
5496
|
+
},
|
|
5497
|
+
{
|
|
5498
|
+
id: "GET /identities/users/{}/avatar/content",
|
|
5499
|
+
method: "GET",
|
|
5500
|
+
path: "/identities/users/{}/avatar/content",
|
|
5501
|
+
steps: [],
|
|
5502
|
+
statuses: [404],
|
|
5503
|
+
queries: [],
|
|
5504
|
+
request: { queries: [], body: void 0 },
|
|
5505
|
+
// the body is an image when an estate holds one: there is no JSON shape
|
|
5506
|
+
shape: void 0,
|
|
5507
|
+
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."
|
|
5508
|
+
},
|
|
5509
|
+
{
|
|
5510
|
+
id: "GET /compute/contexts/{}",
|
|
5511
|
+
method: "GET",
|
|
5512
|
+
path: "/compute/contexts/{}",
|
|
5513
|
+
steps: [],
|
|
5514
|
+
statuses: [200, 404],
|
|
5515
|
+
queries: [],
|
|
5516
|
+
request: { queries: [], body: void 0 },
|
|
5517
|
+
shape: void 0,
|
|
5518
|
+
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."
|
|
5423
5519
|
}
|
|
5424
5520
|
];
|
|
5425
5521
|
var VIYA_OPERATIONS = [...VIYA_TABLE, ...DECLARED];
|
|
@@ -5436,9 +5532,19 @@ var SASjsApi = (() => {
|
|
|
5436
5532
|
"GET /folders/folders/@item": { implemented: true },
|
|
5437
5533
|
"GET /folders/folders/@myRecycleBin": { implemented: true },
|
|
5438
5534
|
"GET /identities/users/@currentUser": { implemented: true },
|
|
5535
|
+
// answered here: the application's own identity reads, declared rather than
|
|
5536
|
+
// captured - see src/viya/appSurface.ts for the scope they belong to
|
|
5537
|
+
"GET /identities/groups": { implemented: true },
|
|
5538
|
+
"GET /identities/groups/{}/members": { implemented: true },
|
|
5539
|
+
"GET /identities/users": { implemented: true },
|
|
5540
|
+
"GET /identities/users/{}": { implemented: true },
|
|
5541
|
+
"GET /identities/users/@currentUser/memberships": { implemented: true },
|
|
5542
|
+
"GET /identities/users/{}/memberships": { implemented: true },
|
|
5543
|
+
"GET /identities/users/{}/avatar/content": { implemented: true },
|
|
5439
5544
|
"GET /types/types": { implemented: true },
|
|
5440
5545
|
// answered here: compute
|
|
5441
5546
|
"GET /compute/contexts": { implemented: true },
|
|
5547
|
+
"GET /compute/contexts/{}": { implemented: true },
|
|
5442
5548
|
"POST /compute/contexts/{}/sessions": { implemented: true },
|
|
5443
5549
|
"DELETE /compute/sessions/{}": { implemented: true },
|
|
5444
5550
|
"POST /compute/sessions/{}/jobs": { implemented: true },
|
|
@@ -5667,10 +5773,10 @@ var SASjsApi = (() => {
|
|
|
5667
5773
|
var DEFAULT_CONTEXT_NAME = "SAS Job Execution compute context";
|
|
5668
5774
|
var EMULATED_CONTEXT_ID = idFor("emulated-context", "context");
|
|
5669
5775
|
var relLinks = (type, rels) => rels.map(([rel, href]) => ({ href, uri: href, rel, method: "GET", type }));
|
|
5670
|
-
var linksFor = (uri, type,
|
|
5776
|
+
var linksFor = (uri, type, collection2 = false, itemType = false) => [
|
|
5671
5777
|
// the collection link comes first, because that is the order the capture
|
|
5672
5778
|
// recorded and the item shape assertion walks the first element
|
|
5673
|
-
...
|
|
5779
|
+
...collection2 ? [
|
|
5674
5780
|
{
|
|
5675
5781
|
href: `${uri}/members`,
|
|
5676
5782
|
uri: `${uri}/members`,
|
|
@@ -5707,6 +5813,21 @@ var SASjsApi = (() => {
|
|
|
5707
5813
|
"application/vnd.sas.compute.context"
|
|
5708
5814
|
)
|
|
5709
5815
|
});
|
|
5816
|
+
var contextDetailsBody = (caller) => ({
|
|
5817
|
+
...contextBody(DEFAULT_CONTEXT_NAME, caller),
|
|
5818
|
+
description: "The compute context an emulated estate answers for",
|
|
5819
|
+
creationTimeStamp: EMULATED_NOW,
|
|
5820
|
+
modifiedTimeStamp: EMULATED_NOW,
|
|
5821
|
+
modifiedBy: caller,
|
|
5822
|
+
launchType: "service",
|
|
5823
|
+
launchContext: { contextId: EMULATED_CONTEXT_ID },
|
|
5824
|
+
environment: { autoExecLines: [] },
|
|
5825
|
+
attributes: {
|
|
5826
|
+
reuseServerProcesses: "false",
|
|
5827
|
+
allowXCMD: "false",
|
|
5828
|
+
serverMinAvailable: "1"
|
|
5829
|
+
}
|
|
5830
|
+
});
|
|
5710
5831
|
var sessionBody = (services, session, autoExecLines, caller) => {
|
|
5711
5832
|
const { id } = session;
|
|
5712
5833
|
const uri = `/compute/sessions/${id}`;
|
|
@@ -5817,6 +5938,14 @@ var SASjsApi = (() => {
|
|
|
5817
5938
|
}
|
|
5818
5939
|
};
|
|
5819
5940
|
},
|
|
5941
|
+
"GET /compute/contexts/{}": async ({ request, params }) => {
|
|
5942
|
+
if (params.id !== EMULATED_CONTEXT_ID)
|
|
5943
|
+
throw new ApiError(
|
|
5944
|
+
404,
|
|
5945
|
+
`No compute context matches the id ${params.id}. The emulated estate answers one context, and this is not its id.`
|
|
5946
|
+
);
|
|
5947
|
+
return { status: 200, body: contextDetailsBody(callerId(request.subject)) };
|
|
5948
|
+
},
|
|
5820
5949
|
"POST /compute/contexts/{}/sessions": async ({
|
|
5821
5950
|
services,
|
|
5822
5951
|
params,
|
|
@@ -6119,8 +6248,209 @@ var SASjsApi = (() => {
|
|
|
6119
6248
|
}
|
|
6120
6249
|
};
|
|
6121
6250
|
|
|
6251
|
+
// src/viya/identity.ts
|
|
6252
|
+
var requireRecords = (services) => {
|
|
6253
|
+
if (!services.records)
|
|
6254
|
+
throw new ApiError(
|
|
6255
|
+
501,
|
|
6256
|
+
"The emulated identity answers from the records service, which this host does not supply."
|
|
6257
|
+
);
|
|
6258
|
+
return services.records;
|
|
6259
|
+
};
|
|
6260
|
+
var callerOf = async (services, request) => request.subject ?? await services.identity?.authenticate(request.token);
|
|
6261
|
+
var userIdFrom = (segment, caller) => {
|
|
6262
|
+
if (segment.toLowerCase() !== "@currentuser") return segment;
|
|
6263
|
+
const id = caller?.userId;
|
|
6264
|
+
if (!id) throw new ApiError(401, "No caller is signed in.");
|
|
6265
|
+
return id;
|
|
6266
|
+
};
|
|
6267
|
+
var collection = (name, items, limit, uri, type) => {
|
|
6268
|
+
const page = limit > 0 ? items.slice(0, limit) : items;
|
|
6269
|
+
return {
|
|
6270
|
+
accept: "application/json",
|
|
6271
|
+
name,
|
|
6272
|
+
start: 0,
|
|
6273
|
+
// the value asked for is echoed, as the folder answers echo it: a caller
|
|
6274
|
+
// that asked for five and is told zero cannot tell what happened
|
|
6275
|
+
limit: limit || page.length,
|
|
6276
|
+
count: page.length,
|
|
6277
|
+
version: 2,
|
|
6278
|
+
items: page,
|
|
6279
|
+
links: [
|
|
6280
|
+
{
|
|
6281
|
+
href: uri,
|
|
6282
|
+
uri,
|
|
6283
|
+
rel: "self",
|
|
6284
|
+
method: "GET",
|
|
6285
|
+
type: "application/vnd.sas.collection",
|
|
6286
|
+
itemType: type
|
|
6287
|
+
}
|
|
6288
|
+
]
|
|
6289
|
+
};
|
|
6290
|
+
};
|
|
6291
|
+
var identityLinks = (uri, type) => [
|
|
6292
|
+
{ href: uri, uri, rel: "self", method: "GET", type }
|
|
6293
|
+
];
|
|
6294
|
+
var GROUP_TYPE = "application/vnd.sas.identity.group";
|
|
6295
|
+
var USER_TYPE = "application/vnd.sas.identity.user";
|
|
6296
|
+
var groupBody = (group, memberCount) => ({
|
|
6297
|
+
id: group.uid,
|
|
6298
|
+
name: group.name,
|
|
6299
|
+
description: group.description,
|
|
6300
|
+
providerId: "sas",
|
|
6301
|
+
state: "active",
|
|
6302
|
+
memberCount,
|
|
6303
|
+
creationTimeStamp: EMULATED_NOW,
|
|
6304
|
+
modifiedTimeStamp: EMULATED_NOW,
|
|
6305
|
+
version: 1,
|
|
6306
|
+
links: identityLinks(`/identities/groups/${group.uid}`, GROUP_TYPE)
|
|
6307
|
+
});
|
|
6308
|
+
var userBody = (user3) => ({
|
|
6309
|
+
id: user3.uid,
|
|
6310
|
+
// Viya's `name` is the identifier a person signs in with; the display name is
|
|
6311
|
+
// a separate field, and this is the one a member list shows
|
|
6312
|
+
name: user3.username,
|
|
6313
|
+
displayName: user3.displayName,
|
|
6314
|
+
providerId: "sas",
|
|
6315
|
+
state: "active",
|
|
6316
|
+
version: 1,
|
|
6317
|
+
links: identityLinks(`/identities/users/${user3.uid}`, USER_TYPE)
|
|
6318
|
+
});
|
|
6319
|
+
var membershipsOf = async (records, caller, uid) => {
|
|
6320
|
+
const users = await records.listUsers(caller);
|
|
6321
|
+
const user3 = users.find((item) => item.uid === uid) ?? users.find((item) => item.username === uid);
|
|
6322
|
+
const resolvedUid = user3?.uid ?? uid;
|
|
6323
|
+
const groups = await records.listGroups(caller);
|
|
6324
|
+
const found = [];
|
|
6325
|
+
for (const group of groups) {
|
|
6326
|
+
const details = await records.getGroup(caller, { uid: group.uid });
|
|
6327
|
+
if (details.users.some((member) => member.uid === resolvedUid))
|
|
6328
|
+
found.push(groupBody(group, details.users.length));
|
|
6329
|
+
}
|
|
6330
|
+
return found;
|
|
6331
|
+
};
|
|
6332
|
+
var IDENTITY_HANDLERS = {
|
|
6333
|
+
"GET /identities/groups": async ({ services, request }) => {
|
|
6334
|
+
const records = requireRecords(services);
|
|
6335
|
+
const caller = await callerOf(services, request);
|
|
6336
|
+
const limit = Number(request.query?.limit ?? 0) || 0;
|
|
6337
|
+
const sortBy = request.query?.sortBy;
|
|
6338
|
+
const groups = await records.listGroups(caller);
|
|
6339
|
+
const items = [];
|
|
6340
|
+
for (const group of groups) {
|
|
6341
|
+
const details = await records.getGroup(caller, { uid: group.uid });
|
|
6342
|
+
items.push(groupBody(group, details.users.length));
|
|
6343
|
+
}
|
|
6344
|
+
const ordered = sortBy && sortBy.toLowerCase() === "name" ? [...items].sort((left, right) => left.name.localeCompare(right.name)) : items;
|
|
6345
|
+
return {
|
|
6346
|
+
status: 200,
|
|
6347
|
+
body: collection(
|
|
6348
|
+
"groups",
|
|
6349
|
+
ordered,
|
|
6350
|
+
limit,
|
|
6351
|
+
"/identities/groups",
|
|
6352
|
+
GROUP_TYPE
|
|
6353
|
+
)
|
|
6354
|
+
};
|
|
6355
|
+
},
|
|
6356
|
+
"GET /identities/groups/{}/members": async ({
|
|
6357
|
+
services,
|
|
6358
|
+
request,
|
|
6359
|
+
params
|
|
6360
|
+
}) => {
|
|
6361
|
+
const records = requireRecords(services);
|
|
6362
|
+
const caller = await callerOf(services, request);
|
|
6363
|
+
const limit = Number(request.query?.limit ?? 0) || 0;
|
|
6364
|
+
const details = await records.getGroup(caller, { uid: params.id });
|
|
6365
|
+
const items = details.users.map((user3) => userBody(user3));
|
|
6366
|
+
return {
|
|
6367
|
+
status: 200,
|
|
6368
|
+
body: collection(
|
|
6369
|
+
"members",
|
|
6370
|
+
items,
|
|
6371
|
+
limit,
|
|
6372
|
+
`/identities/groups/${details.uid}/members`,
|
|
6373
|
+
USER_TYPE
|
|
6374
|
+
)
|
|
6375
|
+
};
|
|
6376
|
+
},
|
|
6377
|
+
"GET /identities/users": async ({ services, request }) => {
|
|
6378
|
+
const records = requireRecords(services);
|
|
6379
|
+
const caller = await callerOf(services, request);
|
|
6380
|
+
const limit = Number(request.query?.limit ?? 0) || 0;
|
|
6381
|
+
const users = await records.listUsers(caller);
|
|
6382
|
+
return {
|
|
6383
|
+
status: 200,
|
|
6384
|
+
body: collection(
|
|
6385
|
+
"users",
|
|
6386
|
+
users.map((user3) => userBody(user3)),
|
|
6387
|
+
limit,
|
|
6388
|
+
"/identities/users",
|
|
6389
|
+
USER_TYPE
|
|
6390
|
+
)
|
|
6391
|
+
};
|
|
6392
|
+
},
|
|
6393
|
+
"GET /identities/users/{}": async ({ services, request, params }) => {
|
|
6394
|
+
const records = requireRecords(services);
|
|
6395
|
+
const caller = await callerOf(services, request);
|
|
6396
|
+
const uid = userIdFrom(params.id, caller);
|
|
6397
|
+
const user3 = await records.getUser(caller, { uid });
|
|
6398
|
+
return { status: 200, body: userBody(user3) };
|
|
6399
|
+
},
|
|
6400
|
+
"GET /identities/users/@currentUser/memberships": async ({
|
|
6401
|
+
services,
|
|
6402
|
+
request
|
|
6403
|
+
}) => {
|
|
6404
|
+
const records = requireRecords(services);
|
|
6405
|
+
const caller = await callerOf(services, request);
|
|
6406
|
+
const limit = Number(request.query?.limit ?? 0) || 0;
|
|
6407
|
+
const uid = userIdFrom("@currentUser", caller);
|
|
6408
|
+
const items = await membershipsOf(records, caller, uid);
|
|
6409
|
+
return {
|
|
6410
|
+
status: 200,
|
|
6411
|
+
body: collection(
|
|
6412
|
+
"memberships",
|
|
6413
|
+
items,
|
|
6414
|
+
limit,
|
|
6415
|
+
"/identities/users/@currentUser/memberships",
|
|
6416
|
+
GROUP_TYPE
|
|
6417
|
+
)
|
|
6418
|
+
};
|
|
6419
|
+
},
|
|
6420
|
+
"GET /identities/users/{}/memberships": async ({
|
|
6421
|
+
services,
|
|
6422
|
+
request,
|
|
6423
|
+
params
|
|
6424
|
+
}) => {
|
|
6425
|
+
const records = requireRecords(services);
|
|
6426
|
+
const caller = await callerOf(services, request);
|
|
6427
|
+
const limit = Number(request.query?.limit ?? 0) || 0;
|
|
6428
|
+
const uid = userIdFrom(params.id, caller);
|
|
6429
|
+
const items = await membershipsOf(records, caller, uid);
|
|
6430
|
+
return {
|
|
6431
|
+
status: 200,
|
|
6432
|
+
body: collection(
|
|
6433
|
+
"memberships",
|
|
6434
|
+
items,
|
|
6435
|
+
limit,
|
|
6436
|
+
`/identities/users/${params.id}/memberships`,
|
|
6437
|
+
GROUP_TYPE
|
|
6438
|
+
)
|
|
6439
|
+
};
|
|
6440
|
+
},
|
|
6441
|
+
"GET /identities/users/{}/avatar/content": async ({
|
|
6442
|
+
services,
|
|
6443
|
+
request,
|
|
6444
|
+
params
|
|
6445
|
+
}) => {
|
|
6446
|
+
const caller = await callerOf(services, request);
|
|
6447
|
+
const uid = userIdFrom(params.id, caller);
|
|
6448
|
+
throw new ApiError(404, `No avatar is recorded for the user ${uid}.`);
|
|
6449
|
+
}
|
|
6450
|
+
};
|
|
6451
|
+
|
|
6122
6452
|
// src/viya/service.ts
|
|
6123
|
-
var linksFor2 = (uri,
|
|
6453
|
+
var linksFor2 = (uri, collection2 = false) => {
|
|
6124
6454
|
const self = {
|
|
6125
6455
|
href: uri,
|
|
6126
6456
|
uri,
|
|
@@ -6136,7 +6466,7 @@ var SASjsApi = (() => {
|
|
|
6136
6466
|
type: "application/vnd.sas.collection",
|
|
6137
6467
|
itemType: "folder"
|
|
6138
6468
|
};
|
|
6139
|
-
return
|
|
6469
|
+
return collection2 ? [members, self] : [self, members];
|
|
6140
6470
|
};
|
|
6141
6471
|
var folderBody = async (drive, path, caller) => {
|
|
6142
6472
|
const listing = await drive.list(path);
|
|
@@ -6420,7 +6750,8 @@ var SASjsApi = (() => {
|
|
|
6420
6750
|
};
|
|
6421
6751
|
},
|
|
6422
6752
|
...COMPUTE_HANDLERS,
|
|
6423
|
-
...FILE_HANDLERS
|
|
6753
|
+
...FILE_HANDLERS,
|
|
6754
|
+
...IDENTITY_HANDLERS
|
|
6424
6755
|
};
|
|
6425
6756
|
|
|
6426
6757
|
// src/viya/dispatch.ts
|
|
@@ -12110,7 +12441,7 @@ var SASjsApi = (() => {
|
|
|
12110
12441
|
};
|
|
12111
12442
|
var createRuntimeService = (directory, runner, options = {}) => {
|
|
12112
12443
|
const runTimes = options.runTimes || DOCUMENTED_RUN_TIMES;
|
|
12113
|
-
const
|
|
12444
|
+
const callerOf2 = async (caller) => {
|
|
12114
12445
|
if (!caller) throw new ApiError(401, "Unauthorized");
|
|
12115
12446
|
const reader = await directory.userById(caller.userId);
|
|
12116
12447
|
if (!reader || !reader.isActive) throw new ApiError(401, "Unauthorized");
|
|
@@ -12167,7 +12498,7 @@ var SASjsApi = (() => {
|
|
|
12167
12498
|
return minutes;
|
|
12168
12499
|
};
|
|
12169
12500
|
const prepare = async (caller, request) => {
|
|
12170
|
-
const reader = await
|
|
12501
|
+
const reader = await callerOf2(caller);
|
|
12171
12502
|
const program = programOf2(request);
|
|
12172
12503
|
const vars = { ...request.vars || {} };
|
|
12173
12504
|
const debug = "code" in program ? CODE_DEBUG : parseDebugValue(vars._debug);
|
|
@@ -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
|
+
];
|