@sasjs/api 0.50.0 → 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 CHANGED
@@ -33,8 +33,16 @@ Both lists are held against their inventory in both directions by `spec/viyaAppS
33
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
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
35
 
36
+ **Viya job log collection.** The CLI follows a job's `log` link and pages the returned line objects. The emulator supports non-negative decimal `start` and `limit` (default 0 and 10; maximum limit 2147483647, maximum start JavaScript's safe integer), with `count` equal to the total stored lines. Malformed or repeated values are refused with 400; `type` filtering and `timeout` are not implemented and are refused. Every stored string is labelled `NOTE`, without classifying its content; `/log/content` retains its existing behavior. Defaults, validation, link details and line types are mock choices, not verified Viya behavior. A successful collection read is not evidence of SAS execution; its lines come from the configured host or the mock generator.
37
+
38
+ **Viya mock SYSJOBID.** By default every session-variable lookup retains the 501 refusal. A trusted host may set `services.viya.mockSysjobid: true` in host configuration, never from HTTP data, to enable only the exact case-sensitive name `SYSJOBID` after normal subject, estate and session ownership checks. The value is `mock-<session UUID>`, stable only for that mock session and unmistakably synthetic: it is not a process ID, a SAS value or evidence of execution. The adapter's `printPid` nevertheless labels it `PID`; do not interpret it as a real one. Unknown variables remain 501 for an authorized live session; foreign, missing, deleted or ownerless sessions return 404, and unresolved credentials return 401. No subject and no token is the shared anonymous mock identity described below, not authentication. The [SAS getVariable documentation](https://developer.sas.com/rest-apis/compute/getVariable/index.md) specifies name, value, scope and representation version 1; the committed capture records link field types, not their values. `AUTOMATIC` and the single self link and its media type are mock-specific choices, not observed Viya values. The dispatch request carries no Accept header: this mock only returns a JSON-shaped resource and does not implement or negotiate SAS's documented `text/plain` or other Accept representations. Hosts must not enable it for clients relying on content negotiation.
39
+
36
40
  **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.
37
41
 
42
+ **Viya mock job submissions.** After resolving the session owner, the mock accepts an omitted request body or an object whose optional `code` is a string or an array of strings (including empty strings and arrays); omitted `code` becomes an empty string. Explicit null, non-object or array bodies, a null or non-string/non-array `code`, and arrays with non-string or sparse elements return 400 before job allocation, generated logging or executor invocation. This is a mock safety contract, not a verified Viya validation response. Valid code is still handed to any trusted host-configured executor, so hosts must enforce their own execution policy; the emulator alone does not execute SAS.
43
+
44
+ **Viya compute outcomes.** A trusted host's `services.viya.execute` may return `state: 'completed' | 'warning' | 'error' | 'failed'` and an optional integer `jobConditionCode`. These are host results, not request fields: never infer either from code, log text or webout. `warning` and `error` model explicit Compute outcomes; `failed` and thrown executor errors retain the existing mock infrastructure-failure behavior. Omitted state means `completed`; omitted condition code retains the historical `0` response, including while running, and does **not** prove SYSCC was zero. The host is responsible for supplying a valid integer and its meaning; the mock does not calculate or validate SYSCC. SAS documents SYSCC as the job condition code once a job completes; the mock does not emulate all Compute states or a SAS engine. Adapter 6.2.0 stops polling on warning, and treats error and failed as execution errors; web requests expecting webout have separate output-handling semantics.
45
+
38
46
  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.
39
47
 
40
48
  **The app stream** (`createAppStreamService`, `createAppStreamWebService`, `splitAppBundle`) is what a deployed folder becomes when it is an app.
package/build/browser.js CHANGED
@@ -1,4 +1,4 @@
1
- /* @sasjs/api 0.50.0 - the SASjs Server API, for a service worker. https://github.com/sasjs/api */
1
+ /* @sasjs/api 0.51.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;
@@ -5406,6 +5406,17 @@ var SASjsApi = (() => {
5406
5406
 
5407
5407
  // src/viya/declared.ts
5408
5408
  var DECLARED = [
5409
+ {
5410
+ id: "GET /compute/sessions/{}/jobs/{}/log",
5411
+ method: "GET",
5412
+ path: "/compute/sessions/{}/jobs/{}/log",
5413
+ steps: [],
5414
+ statuses: [200, 400, 404],
5415
+ queries: ["start", "limit"],
5416
+ request: { queries: ["start", "limit"], body: void 0 },
5417
+ shape: void 0,
5418
+ 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."
5419
+ },
5409
5420
  {
5410
5421
  id: "GET /compute/sessions/{}/filerefs/_webout/content",
5411
5422
  method: "GET",
@@ -5523,6 +5534,7 @@ var SASjsApi = (() => {
5523
5534
  // src/viya/overlay.ts
5524
5535
  var NEEDS_AUTH = "The token endpoint is answered by the host that mounts the emulator, which owns the token port.";
5525
5536
  var NEEDS_JOBS = "The emulator answers the compute and content families; the job definitions a deploy creates and the executions a run submits are not modelled yet.";
5537
+ var SESSION_VARIABLE_REFUSAL = "GET /compute/sessions/{}/variables/{} is not emulated. The emulator does not model session variables; the client reads these only to log the pid of a job it is about to submit (SYSJOBID), and any name it asks for is refused here rather than answered with a value the emulator did not run.";
5526
5538
  var VIYA_OVERLAY = {
5527
5539
  // answered here
5528
5540
  "POST /folders/folders": { implemented: true },
@@ -5549,6 +5561,7 @@ var SASjsApi = (() => {
5549
5561
  "DELETE /compute/sessions/{}": { implemented: true },
5550
5562
  "POST /compute/sessions/{}/jobs": { implemented: true },
5551
5563
  "GET /compute/sessions/{}/jobs/{}": { implemented: true },
5564
+ "GET /compute/sessions/{}/jobs/{}/log": { implemented: true },
5552
5565
  "GET /compute/sessions/{}/jobs/{}/log/content": { implemented: true },
5553
5566
  "GET /compute/sessions/{}/jobs/{}/state": { implemented: true },
5554
5567
  "GET /compute/sessions/{}/state": { implemented: true },
@@ -5579,11 +5592,8 @@ var SASjsApi = (() => {
5579
5592
  implemented: false,
5580
5593
  reason: "The emulator answers compute contexts from its seed; the launcher list a client falls back to is not modelled, and nothing on the emulated path asks for it."
5581
5594
  },
5582
- // declined: session variables are not modelled
5583
- "GET /compute/sessions/{}/variables/{}": {
5584
- implemented: false,
5585
- reason: "The emulator does not model session variables; the client reads these only to log the pid of a job it is about to submit (SYSJOBID), and any name it asks for is refused here rather than answered with a value the emulator did not run."
5586
- },
5595
+ // Default refusal, with an explicit host opt-in for a synthetic SYSJOBID.
5596
+ "GET /compute/sessions/{}/variables/{}": { implemented: true },
5587
5597
  // declined: the host owns the token port
5588
5598
  "POST /SASLogon/oauth/token": { implemented: false, reason: NEEDS_AUTH },
5589
5599
  // declared, not captured: the webout an application's service returns
@@ -5869,7 +5879,7 @@ var SASjsApi = (() => {
5869
5879
  state: job.state,
5870
5880
  creationTimeStamp: job.creationTimeStamp,
5871
5881
  ...job.completedTimeStamp ? { completedTimeStamp: job.completedTimeStamp } : {},
5872
- jobConditionCode: 0,
5882
+ jobConditionCode: job.jobConditionCode ?? 0,
5873
5883
  stateElapsedTime: 1,
5874
5884
  listingStatistics: {
5875
5885
  lineCount: job.log.length,
@@ -5912,6 +5922,11 @@ var SASjsApi = (() => {
5912
5922
  return job;
5913
5923
  };
5914
5924
  var segmentsOf = (params) => params.segments;
5925
+ var validCodeLines = (lines) => {
5926
+ for (let i = 0; i < lines.length; i++)
5927
+ if (typeof lines[i] !== "string") return false;
5928
+ return true;
5929
+ };
5915
5930
  var COMPUTE_HANDLERS = {
5916
5931
  "GET /compute/contexts": async ({ request }) => {
5917
5932
  const limit = Number(request.query?.limit ?? 0) || 0;
@@ -5965,6 +5980,35 @@ var SASjsApi = (() => {
5965
5980
  )
5966
5981
  };
5967
5982
  },
5983
+ "GET /compute/sessions/{}/variables/{}": async ({
5984
+ services,
5985
+ params,
5986
+ request
5987
+ }) => {
5988
+ if (services.viya?.mockSysjobid !== true)
5989
+ throw new ApiError(501, SESSION_VARIABLE_REFUSAL, {
5990
+ message: SESSION_VARIABLE_REFUSAL
5991
+ });
5992
+ if (request.subject === void 0 && request.token !== void 0)
5993
+ throw new ApiError(401, "A valid caller is required.");
5994
+ const [sessionId, name] = segmentsOf(params);
5995
+ const session = sessionOf(services, sessionId, request.subject);
5996
+ if (name !== "SYSJOBID")
5997
+ throw new ApiError(501, SESSION_VARIABLE_REFUSAL, {
5998
+ message: SESSION_VARIABLE_REFUSAL
5999
+ });
6000
+ const uri = `/compute/sessions/${encodeURIComponent(session.id)}/variables/SYSJOBID`;
6001
+ return {
6002
+ status: 200,
6003
+ body: {
6004
+ name: "SYSJOBID",
6005
+ value: `mock-${session.id}`,
6006
+ scope: "AUTOMATIC",
6007
+ version: 1,
6008
+ links: linksFor(uri, "application/vnd.sas.compute.session.variable")
6009
+ }
6010
+ };
6011
+ },
5968
6012
  "GET /compute/sessions/{}/state": async ({ services, params, request }) => {
5969
6013
  sessionOf(services, params.id, request.subject);
5970
6014
  return { status: 200, body: "idle" };
@@ -5976,8 +6020,21 @@ var SASjsApi = (() => {
5976
6020
  },
5977
6021
  "POST /compute/sessions/{}/jobs": async ({ services, params, request }) => {
5978
6022
  const session = sessionOf(services, params.id, request.subject);
5979
- const body = request.body ?? {};
5980
- const job = estateOf(services).submit(session, body);
6023
+ const input = request.body === void 0 ? {} : request.body;
6024
+ if (!input || typeof input !== "object" || Array.isArray(input))
6025
+ throw new ApiError(
6026
+ 400,
6027
+ "Compute job code must be a string or an array of strings."
6028
+ );
6029
+ const body = input;
6030
+ const code = body.code;
6031
+ if (code !== void 0 && typeof code !== "string" && (!Array.isArray(code) || !validCodeLines(code)))
6032
+ throw new ApiError(
6033
+ 400,
6034
+ "Compute job code must be a string or an array of strings."
6035
+ );
6036
+ const program = code ?? "";
6037
+ const job = estateOf(services).submit(session, { ...body, code: program });
5981
6038
  const execute = services.viya?.execute;
5982
6039
  if (!execute) {
5983
6040
  job.state = "completed";
@@ -5987,13 +6044,14 @@ var SASjsApi = (() => {
5987
6044
  job.state = "running";
5988
6045
  job.log = [];
5989
6046
  void execute({
5990
- program: body.code ?? "",
6047
+ program,
5991
6048
  variables: body.variables,
5992
6049
  name: body.name,
5993
6050
  sessionId: session.id
5994
6051
  }).then((ran) => {
5995
6052
  job.log = ran.log.split("\n");
5996
6053
  job.state = ran.state ?? "completed";
6054
+ job.jobConditionCode = ran.jobConditionCode;
5997
6055
  if (ran.webout !== void 0) job.webout = ran.webout;
5998
6056
  job.completedTimeStamp = (/* @__PURE__ */ new Date()).toISOString();
5999
6057
  }).catch((error) => {
@@ -6044,6 +6102,51 @@ var SASjsApi = (() => {
6044
6102
  body: jobOf(services, sessionId, jobId, request.subject).state
6045
6103
  };
6046
6104
  },
6105
+ // The collection is a separate CLI call from the adapter's /log/content.
6106
+ "GET /compute/sessions/{}/jobs/{}/log": async ({
6107
+ services,
6108
+ params,
6109
+ request
6110
+ }) => {
6111
+ const [sessionId, jobId] = segmentsOf(params);
6112
+ const job = jobOf(services, sessionId, jobId, request.subject);
6113
+ const start = request.query?.start;
6114
+ const limit = request.query?.limit;
6115
+ const startValue = start === void 0 ? "0" : start;
6116
+ const limitValue = limit === void 0 ? "10" : limit;
6117
+ if (typeof startValue !== "string" || typeof limitValue !== "string" || !/^\d+$/.test(startValue) || !/^\d+$/.test(limitValue) || !Number.isSafeInteger(Number(startValue)) || !Number.isSafeInteger(Number(limitValue)) || Number(limitValue) > 2147483647)
6118
+ throw new ApiError(400, "Unsupported job log pagination.");
6119
+ if (request.query?.type !== void 0 || request.query?.timeout !== void 0)
6120
+ throw new ApiError(
6121
+ 400,
6122
+ "Job log type and timeout are not supported by the emulator."
6123
+ );
6124
+ const offset = Number(startValue);
6125
+ const pageSize = Number(limitValue);
6126
+ const uri = `/compute/sessions/${job.sessionId}/jobs/${job.id}/log`;
6127
+ return {
6128
+ status: 200,
6129
+ body: {
6130
+ accept: "application/json",
6131
+ name: "log",
6132
+ start: offset,
6133
+ limit: pageSize,
6134
+ count: job.log.length,
6135
+ version: 2,
6136
+ items: job.log.slice(offset, offset + pageSize).map((line) => ({ line, type: "NOTE", version: 2 })),
6137
+ links: [
6138
+ {
6139
+ href: uri,
6140
+ uri,
6141
+ rel: "self",
6142
+ method: "GET",
6143
+ type: "application/vnd.sas.collection",
6144
+ itemType: "application/vnd.sas.compute.log.line"
6145
+ }
6146
+ ]
6147
+ }
6148
+ };
6149
+ },
6047
6150
  "GET /compute/sessions/{}/jobs/{}/log/content": async ({
6048
6151
  services,
6049
6152
  params,
@@ -6821,6 +6924,8 @@ var SASjsApi = (() => {
6821
6924
  message: `${found.operation.id} is not emulated. ${entry.reason ?? ""}`.trim()
6822
6925
  }
6823
6926
  };
6927
+ if (found.operation.id === "GET /compute/sessions/{}/variables/{}" && services.viya?.mockSysjobid !== true)
6928
+ return { status: 501, headers, body: { message: SESSION_VARIABLE_REFUSAL } };
6824
6929
  const handler = VIYA_HANDLERS[found.operation.id];
6825
6930
  if (!handler)
6826
6931
  return {
@@ -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
  *
@@ -141,7 +142,7 @@ const jobBody = (job) => {
141
142
  ...(job.completedTimeStamp
142
143
  ? { completedTimeStamp: job.completedTimeStamp }
143
144
  : {}),
144
- jobConditionCode: 0,
145
+ jobConditionCode: job.jobConditionCode ?? 0,
145
146
  stateElapsedTime: 1,
146
147
  listingStatistics: {
147
148
  lineCount: job.log.length,
@@ -197,6 +198,13 @@ const jobOf = (services, sessionId, jobId, subject) => {
197
198
  * no absent case to answer - a fallback here would be a branch nothing reaches.
198
199
  */
199
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
+ };
200
208
  exports.COMPUTE_HANDLERS = {
201
209
  'GET /compute/contexts': async ({ request }) => {
202
210
  const limit = Number(request.query?.limit ?? 0) || 0;
@@ -234,6 +242,31 @@ exports.COMPUTE_HANDLERS = {
234
242
  body: sessionBody(services, session, body.environment?.autoExecLines ?? [], (0, ids_js_1.callerId)(request.subject))
235
243
  };
236
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
+ },
237
270
  'GET /compute/sessions/{}/state': async ({ services, params, request }) => {
238
271
  sessionOf(services, params.id, request.subject);
239
272
  // a bare enum, not an object: the adapter calls `.trim()` on the answer, and
@@ -247,8 +280,17 @@ exports.COMPUTE_HANDLERS = {
247
280
  },
248
281
  'POST /compute/sessions/{}/jobs': async ({ services, params, request }) => {
249
282
  const session = sessionOf(services, params.id, request.subject);
250
- const body = (request.body ?? {});
251
- const job = estateOf(services).submit(session, body);
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 });
252
294
  const execute = services.viya?.execute;
253
295
  // a host with no engine has nothing to run, so the job is finished at once
254
296
  if (!execute) {
@@ -264,7 +306,7 @@ exports.COMPUTE_HANDLERS = {
264
306
  // not advertise them - the run writes the log when it has one
265
307
  job.log = [];
266
308
  void execute({
267
- program: body.code ?? '',
309
+ program,
268
310
  variables: body.variables,
269
311
  name: body.name,
270
312
  sessionId: session.id
@@ -272,6 +314,7 @@ exports.COMPUTE_HANDLERS = {
272
314
  .then((ran) => {
273
315
  job.log = ran.log.split('\n');
274
316
  job.state = ran.state ?? 'completed';
317
+ job.jobConditionCode = ran.jobConditionCode;
275
318
  if (ran.webout !== undefined)
276
319
  job.webout = ran.webout;
277
320
  job.completedTimeStamp = new Date().toISOString();
@@ -319,6 +362,53 @@ exports.COMPUTE_HANDLERS = {
319
362
  body: jobOf(services, sessionId, jobId, request.subject).state
320
363
  };
321
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
+ },
322
412
  'GET /compute/sessions/{}/jobs/{}/log/content': async ({ services, params, request }) => {
323
413
  const [sessionId, jobId] = segmentsOf(params);
324
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',
@@ -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 {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.assertOverlayEntries = exports.VIYA_OVERLAY = void 0;
3
+ exports.assertOverlayEntries = exports.VIYA_OVERLAY = exports.SESSION_VARIABLE_REFUSAL = void 0;
4
4
  /**
5
5
  * What this package answers of the Viya table, and what it declines.
6
6
  *
@@ -32,6 +32,7 @@ const NEEDS_AUTH = 'The token endpoint is answered by the host that mounts the e
32
32
  * what is missing and a client learning nothing.
33
33
  */
34
34
  const NEEDS_JOBS = 'The emulator answers the compute and content families; the job definitions a deploy creates and the executions a run submits are not modelled yet.';
35
+ exports.SESSION_VARIABLE_REFUSAL = 'GET /compute/sessions/{}/variables/{} is not emulated. The emulator does not model session variables; the client reads these only to log the pid of a job it is about to submit (SYSJOBID), and any name it asks for is refused here rather than answered with a value the emulator did not run.';
35
36
  exports.VIYA_OVERLAY = {
36
37
  // answered here
37
38
  'POST /folders/folders': { implemented: true },
@@ -58,6 +59,7 @@ exports.VIYA_OVERLAY = {
58
59
  'DELETE /compute/sessions/{}': { implemented: true },
59
60
  'POST /compute/sessions/{}/jobs': { implemented: true },
60
61
  'GET /compute/sessions/{}/jobs/{}': { implemented: true },
62
+ 'GET /compute/sessions/{}/jobs/{}/log': { implemented: true },
61
63
  'GET /compute/sessions/{}/jobs/{}/log/content': { implemented: true },
62
64
  'GET /compute/sessions/{}/jobs/{}/state': { implemented: true },
63
65
  'GET /compute/sessions/{}/state': { implemented: true },
@@ -88,11 +90,8 @@ exports.VIYA_OVERLAY = {
88
90
  implemented: false,
89
91
  reason: 'The emulator answers compute contexts from its seed; the launcher list a client falls back to is not modelled, and nothing on the emulated path asks for it.'
90
92
  },
91
- // declined: session variables are not modelled
92
- 'GET /compute/sessions/{}/variables/{}': {
93
- implemented: false,
94
- reason: 'The emulator does not model session variables; the client reads these only to log the pid of a job it is about to submit (SYSJOBID), and any name it asks for is refused here rather than answered with a value the emulator did not run.'
95
- },
93
+ // Default refusal, with an explicit host opt-in for a synthetic SYSJOBID.
94
+ 'GET /compute/sessions/{}/variables/{}': { implemented: true },
96
95
  // declined: the host owns the token port
97
96
  'POST /SASLogon/oauth/token': { implemented: false, reason: NEEDS_AUTH },
98
97
  // declared, not captured: the webout an application's service returns
@@ -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;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
+ {"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;AAOnD;;;;;;;;;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;AA0KD,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,CAwU3B,CAAA"}
@@ -2,6 +2,7 @@ import { ApiError } from '../types.js';
2
2
  import { estateKeyOf, normaliseServerUrl, seedOf } from './seed.js';
3
3
  import { estateFor } from './sessions.js';
4
4
  import { idFor, callerId, EMULATED_NOW } from './ids.js';
5
+ import { SESSION_VARIABLE_REFUSAL } from './overlay.js';
5
6
  /**
6
7
  * The name the emulator answers when a client asks for no particular context.
7
8
  *
@@ -137,7 +138,7 @@ const jobBody = (job) => {
137
138
  ...(job.completedTimeStamp
138
139
  ? { completedTimeStamp: job.completedTimeStamp }
139
140
  : {}),
140
- jobConditionCode: 0,
141
+ jobConditionCode: job.jobConditionCode ?? 0,
141
142
  stateElapsedTime: 1,
142
143
  listingStatistics: {
143
144
  lineCount: job.log.length,
@@ -193,6 +194,13 @@ const jobOf = (services, sessionId, jobId, subject) => {
193
194
  * no absent case to answer - a fallback here would be a branch nothing reaches.
194
195
  */
195
196
  const segmentsOf = (params) => params.segments;
197
+ // Visit every index, including holes in arrays supplied by direct dispatch.
198
+ const validCodeLines = (lines) => {
199
+ for (let i = 0; i < lines.length; i++)
200
+ if (typeof lines[i] !== 'string')
201
+ return false;
202
+ return true;
203
+ };
196
204
  export const COMPUTE_HANDLERS = {
197
205
  'GET /compute/contexts': async ({ request }) => {
198
206
  const limit = Number(request.query?.limit ?? 0) || 0;
@@ -230,6 +238,31 @@ export const COMPUTE_HANDLERS = {
230
238
  body: sessionBody(services, session, body.environment?.autoExecLines ?? [], callerId(request.subject))
231
239
  };
232
240
  },
241
+ 'GET /compute/sessions/{}/variables/{}': async ({ services, params, request }) => {
242
+ if (services.viya?.mockSysjobid !== true)
243
+ throw new ApiError(501, SESSION_VARIABLE_REFUSAL, {
244
+ message: SESSION_VARIABLE_REFUSAL
245
+ });
246
+ if (request.subject === undefined && request.token !== undefined)
247
+ throw new ApiError(401, 'A valid caller is required.');
248
+ const [sessionId, name] = segmentsOf(params);
249
+ const session = sessionOf(services, sessionId, request.subject);
250
+ if (name !== 'SYSJOBID')
251
+ throw new ApiError(501, SESSION_VARIABLE_REFUSAL, {
252
+ message: SESSION_VARIABLE_REFUSAL
253
+ });
254
+ const uri = `/compute/sessions/${encodeURIComponent(session.id)}/variables/SYSJOBID`;
255
+ return {
256
+ status: 200,
257
+ body: {
258
+ name: 'SYSJOBID',
259
+ value: `mock-${session.id}`,
260
+ scope: 'AUTOMATIC',
261
+ version: 1,
262
+ links: linksFor(uri, 'application/vnd.sas.compute.session.variable')
263
+ }
264
+ };
265
+ },
233
266
  'GET /compute/sessions/{}/state': async ({ services, params, request }) => {
234
267
  sessionOf(services, params.id, request.subject);
235
268
  // a bare enum, not an object: the adapter calls `.trim()` on the answer, and
@@ -243,8 +276,17 @@ export const COMPUTE_HANDLERS = {
243
276
  },
244
277
  'POST /compute/sessions/{}/jobs': async ({ services, params, request }) => {
245
278
  const session = sessionOf(services, params.id, request.subject);
246
- const body = (request.body ?? {});
247
- const job = estateOf(services).submit(session, body);
279
+ const input = request.body === undefined ? {} : request.body;
280
+ if (!input || typeof input !== 'object' || Array.isArray(input))
281
+ throw new ApiError(400, 'Compute job code must be a string or an array of strings.');
282
+ const body = input;
283
+ const code = body.code;
284
+ if (code !== undefined &&
285
+ typeof code !== 'string' &&
286
+ (!Array.isArray(code) || !validCodeLines(code)))
287
+ throw new ApiError(400, 'Compute job code must be a string or an array of strings.');
288
+ const program = (code ?? '');
289
+ const job = estateOf(services).submit(session, { ...body, code: program });
248
290
  const execute = services.viya?.execute;
249
291
  // a host with no engine has nothing to run, so the job is finished at once
250
292
  if (!execute) {
@@ -260,7 +302,7 @@ export const COMPUTE_HANDLERS = {
260
302
  // not advertise them - the run writes the log when it has one
261
303
  job.log = [];
262
304
  void execute({
263
- program: body.code ?? '',
305
+ program,
264
306
  variables: body.variables,
265
307
  name: body.name,
266
308
  sessionId: session.id
@@ -268,6 +310,7 @@ export const COMPUTE_HANDLERS = {
268
310
  .then((ran) => {
269
311
  job.log = ran.log.split('\n');
270
312
  job.state = ran.state ?? 'completed';
313
+ job.jobConditionCode = ran.jobConditionCode;
271
314
  if (ran.webout !== undefined)
272
315
  job.webout = ran.webout;
273
316
  job.completedTimeStamp = new Date().toISOString();
@@ -315,6 +358,53 @@ export const COMPUTE_HANDLERS = {
315
358
  body: jobOf(services, sessionId, jobId, request.subject).state
316
359
  };
317
360
  },
361
+ // The collection is a separate CLI call from the adapter's /log/content.
362
+ 'GET /compute/sessions/{}/jobs/{}/log': async ({ services, params, request }) => {
363
+ const [sessionId, jobId] = segmentsOf(params);
364
+ const job = jobOf(services, sessionId, jobId, request.subject);
365
+ const start = request.query?.start;
366
+ const limit = request.query?.limit;
367
+ const startValue = start === undefined ? '0' : start;
368
+ const limitValue = limit === undefined ? '10' : limit;
369
+ if (typeof startValue !== 'string' ||
370
+ typeof limitValue !== 'string' ||
371
+ !/^\d+$/.test(startValue) ||
372
+ !/^\d+$/.test(limitValue) ||
373
+ !Number.isSafeInteger(Number(startValue)) ||
374
+ !Number.isSafeInteger(Number(limitValue)) ||
375
+ Number(limitValue) > 2147483647)
376
+ throw new ApiError(400, 'Unsupported job log pagination.');
377
+ if (request.query?.type !== undefined ||
378
+ request.query?.timeout !== undefined)
379
+ throw new ApiError(400, 'Job log type and timeout are not supported by the emulator.');
380
+ const offset = Number(startValue);
381
+ const pageSize = Number(limitValue);
382
+ const uri = `/compute/sessions/${job.sessionId}/jobs/${job.id}/log`;
383
+ return {
384
+ status: 200,
385
+ body: {
386
+ accept: 'application/json',
387
+ name: 'log',
388
+ start: offset,
389
+ limit: pageSize,
390
+ count: job.log.length,
391
+ version: 2,
392
+ items: job.log
393
+ .slice(offset, offset + pageSize)
394
+ .map((line) => ({ line, type: 'NOTE', version: 2 })),
395
+ links: [
396
+ {
397
+ href: uri,
398
+ uri,
399
+ rel: 'self',
400
+ method: 'GET',
401
+ type: 'application/vnd.sas.collection',
402
+ itemType: 'application/vnd.sas.compute.log.line'
403
+ }
404
+ ]
405
+ }
406
+ };
407
+ },
318
408
  'GET /compute/sessions/{}/jobs/{}/log/content': async ({ services, params, request }) => {
319
409
  const [sessionId, jobId] = segmentsOf(params);
320
410
  const job = jobOf(services, sessionId, jobId, request.subject);
@@ -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,EA0HvC,CAAA;AAED,mFAAmF;AACnF,eAAO,MAAM,eAAe,EAAE,aAAa,EAAiC,CAAA"}
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,EAsIvC,CAAA;AAED,mFAAmF;AACnF,eAAO,MAAM,eAAe,EAAE,aAAa,EAAiC,CAAA"}
@@ -15,6 +15,17 @@
15
15
  */
16
16
  import { VIYA_TABLE } from './table.js';
17
17
  export const DECLARED = [
18
+ {
19
+ id: 'GET /compute/sessions/{}/jobs/{}/log',
20
+ method: 'GET',
21
+ path: '/compute/sessions/{}/jobs/{}/log',
22
+ steps: [],
23
+ statuses: [200, 400, 404],
24
+ queries: ['start', 'limit'],
25
+ request: { queries: ['start', 'limit'], body: undefined },
26
+ shape: undefined,
27
+ 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.'
28
+ },
18
29
  {
19
30
  id: 'GET /compute/sessions/{}/filerefs/_webout/content',
20
31
  method: 'GET',
@@ -1 +1 @@
1
- {"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../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iB,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,CAwGtB,CAAA"}
@@ -1,6 +1,6 @@
1
1
  import { ApiError, isApiError } from '../types.js';
2
2
  import { VIYA_OPERATIONS } from './declared.js';
3
- import { VIYA_OVERLAY } from './overlay.js';
3
+ import { VIYA_OVERLAY, SESSION_VARIABLE_REFUSAL } from './overlay.js';
4
4
  import { VIYA_HANDLERS } from './service.js';
5
5
  import { emulatedHeaders } from './version.js';
6
6
  const escape = (segment) => segment.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
@@ -87,6 +87,9 @@ export const dispatchViya = async (services, method, path, request = {}) => {
87
87
  message: `${found.operation.id} is not emulated. ${entry.reason ?? ''}`.trim()
88
88
  }
89
89
  };
90
+ if (found.operation.id === 'GET /compute/sessions/{}/variables/{}' &&
91
+ services.viya?.mockSysjobid !== true)
92
+ return { status: 501, headers, body: { message: SESSION_VARIABLE_REFUSAL } };
90
93
  const handler = VIYA_HANDLERS[found.operation.id];
91
94
  if (!handler)
92
95
  return {
@@ -3,6 +3,7 @@ export interface ViyaOverlayEntry {
3
3
  /** Present when declined: what a caller is told, and why. */
4
4
  reason?: string;
5
5
  }
6
+ export declare const SESSION_VARIABLE_REFUSAL = "GET /compute/sessions/{}/variables/{} is not emulated. The emulator does not model session variables; the client reads these only to log the pid of a job it is about to submit (SYSJOBID), and any name it asks for is refused here rather than answered with a value the emulator did not run.";
6
7
  export declare const VIYA_OVERLAY: Record<string, ViyaOverlayEntry>;
7
8
  /**
8
9
  * Refuse an overlay and a table that do not describe the same operations.
@@ -1 +1 @@
1
- {"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../../../src/viya/overlay.ts"],"names":[],"mappings":"AAeA,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,OAAO,CAAA;IACpB,6DAA6D;IAC7D,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAuBD,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CA4EzD,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,oBAAoB,GAC/B,SAAS,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,EACzC,aAAY,KAAK,CAAC;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAmB,KAClD,IAcF,CAAA"}
1
+ {"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../../../src/viya/overlay.ts"],"names":[],"mappings":"AAeA,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,OAAO,CAAA;IACpB,6DAA6D;IAC7D,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAuBD,eAAO,MAAM,wBAAwB,qSAC+P,CAAA;AAEpS,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAyEzD,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,oBAAoB,GAC/B,SAAS,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,EACzC,aAAY,KAAK,CAAC;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAmB,KAClD,IAcF,CAAA"}
@@ -29,6 +29,7 @@ const NEEDS_AUTH = 'The token endpoint is answered by the host that mounts the e
29
29
  * what is missing and a client learning nothing.
30
30
  */
31
31
  const NEEDS_JOBS = 'The emulator answers the compute and content families; the job definitions a deploy creates and the executions a run submits are not modelled yet.';
32
+ export const SESSION_VARIABLE_REFUSAL = 'GET /compute/sessions/{}/variables/{} is not emulated. The emulator does not model session variables; the client reads these only to log the pid of a job it is about to submit (SYSJOBID), and any name it asks for is refused here rather than answered with a value the emulator did not run.';
32
33
  export const VIYA_OVERLAY = {
33
34
  // answered here
34
35
  'POST /folders/folders': { implemented: true },
@@ -55,6 +56,7 @@ export const VIYA_OVERLAY = {
55
56
  'DELETE /compute/sessions/{}': { implemented: true },
56
57
  'POST /compute/sessions/{}/jobs': { implemented: true },
57
58
  'GET /compute/sessions/{}/jobs/{}': { implemented: true },
59
+ 'GET /compute/sessions/{}/jobs/{}/log': { implemented: true },
58
60
  'GET /compute/sessions/{}/jobs/{}/log/content': { implemented: true },
59
61
  'GET /compute/sessions/{}/jobs/{}/state': { implemented: true },
60
62
  'GET /compute/sessions/{}/state': { implemented: true },
@@ -85,11 +87,8 @@ export const VIYA_OVERLAY = {
85
87
  implemented: false,
86
88
  reason: 'The emulator answers compute contexts from its seed; the launcher list a client falls back to is not modelled, and nothing on the emulated path asks for it.'
87
89
  },
88
- // declined: session variables are not modelled
89
- 'GET /compute/sessions/{}/variables/{}': {
90
- implemented: false,
91
- reason: 'The emulator does not model session variables; the client reads these only to log the pid of a job it is about to submit (SYSJOBID), and any name it asks for is refused here rather than answered with a value the emulator did not run.'
92
- },
90
+ // Default refusal, with an explicit host opt-in for a synthetic SYSJOBID.
91
+ 'GET /compute/sessions/{}/variables/{}': { implemented: true },
93
92
  // declined: the host owns the token port
94
93
  'POST /SASLogon/oauth/token': { implemented: false, reason: NEEDS_AUTH },
95
94
  // declared, not captured: the webout an application's service returns
@@ -57,17 +57,21 @@ export interface ViyaRun {
57
57
  /**
58
58
  * How the run ended.
59
59
  *
60
- * A client decides a service failed from the job's state, not from the log, so
61
- * a run that failed has to say so - otherwise the webout it did not produce
62
- * reads as data. Absent, the run completed.
60
+ * The trusted host supplies this explicitly, never inferred from the log.
61
+ * `warning` and `error` are Compute outcomes; `failed` preserves the existing
62
+ * host/infrastructure failure state. Absent, the run completed.
63
63
  */
64
- state?: 'completed' | 'failed';
64
+ state?: 'completed' | 'warning' | 'error' | 'failed';
65
+ /** Trusted host's integer SYSCC, when known. Not inferred from the log. */
66
+ jobConditionCode?: number;
65
67
  }
66
68
  export interface ViyaSeedSettings {
67
69
  /** The address this estate answers at, which is what seeds it. */
68
70
  serverUrl?: string;
69
71
  /** Runs a submitted program, when the host has an engine. */
70
72
  execute?: ViyaExecutor['execute'];
73
+ /** Trusted host-only opt-in for a synthetic session SYSJOBID; never set from HTTP. */
74
+ mockSysjobid?: boolean;
71
75
  }
72
76
  /**
73
77
  * The address reduced to what identifies it.
@@ -1 +1 @@
1
- {"version":3,"file":"seed.d.ts","sourceRoot":"","sources":["../../../src/viya/seed.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,oDAAoD;AACpD,eAAO,MAAM,YAAY,aAAa,CAAA;AAEtC;;;;;;;GAOG;AACH,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,OAAO,EAAE;QACf,2DAA2D;QAC3D,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;QAC1B,4DAA4D;QAC5D,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;QAClC,kEAAkE;QAClE,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,sCAAsC;QACtC,SAAS,EAAE,MAAM,CAAA;KAClB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;CACrB;AAED,8CAA8C;AAC9C,MAAM,WAAW,OAAO;IACtB,6DAA6D;IAC7D,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,gFAAgF;IAChF,GAAG,EAAE,MAAM,CAAA;IACX;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,WAAW,GAAG,QAAQ,CAAA;CAC/B;AAED,MAAM,WAAW,gBAAgB;IAC/B,kEAAkE;IAClE,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,6DAA6D;IAC7D,OAAO,CAAC,EAAE,YAAY,CAAC,SAAS,CAAC,CAAA;CAClC;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,GAAI,KAAK,MAAM,GAAG,SAAS,KAAG,MA+C5D,CAAA;AAED,8DAA8D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CAAC,EAAE,WAAW,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,CAAA;IACpD,2EAA2E;IAC3E,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAC1B;AAED,MAAM,WAAW,gBAAgB;IAC/B,kEAAkE;IAClE,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,6DAA6D;IAC7D,OAAO,CAAC,EAAE,YAAY,CAAC,SAAS,CAAC,CAAA;IACjC,sFAAsF;IACtF,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,GAAI,KAAK,MAAM,GAAG,SAAS,KAAG,MA+C5D,CAAA;AAED,8DAA8D;AAC9D,eAAO,MAAM,IAAI,GAAI,OAAO,MAAM,KAAG,MASpC,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,MAAM,GAAI,WAAU,gBAAqB,KAAG,MAIxD,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,WAAW,GAAI,WAAU,gBAAqB,KAAG,MAI7D,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,KAAG,CAAC,MAAM,MAAM,CAarD,CAAA;AAED,4DAA4D;AAC5D,eAAO,MAAM,OAAO,GAAI,MAAM,MAAM,MAAM,EAAE,OAAO,MAAM,KAAG,MAChC,CAAA;AAE5B,oDAAoD;AACpD,eAAO,MAAM,QAAQ,GAAI,CAAC,EAAE,MAAM,MAAM,MAAM,EAAE,QAAQ,CAAC,EAAE,KAAG,CACxB,CAAA"}
@@ -14,7 +14,9 @@ export interface EmulatedJob {
14
14
  * because the client polls this and a submission that answered `completed`
15
15
  * would be a lie about work that had not happened.
16
16
  */
17
- state: 'running' | 'completed' | 'failed';
17
+ state: 'running' | 'completed' | 'warning' | 'error' | 'failed';
18
+ /** Trusted host's condition code, when provided. */
19
+ jobConditionCode?: number;
18
20
  creationTimeStamp: string;
19
21
  /**
20
22
  * When the run finished, absent until it does.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  "description": "The SASjs Server API, described once - a generated route table, the services behind it, and the conformance corpus both hosts run",
5
5
  "license": "MIT",
6
6
  "author": "SASjs",
@@ -58,6 +58,7 @@
58
58
  "prepublishOnly": "node -e \"const v=require('./package.json').version; if (/^0\\.0\\.0/.test(v)) { console.error('refusing to publish ' + v + ': the version is stamped from the tag by @sasjs/release --prepare-publish'); process.exit(1) }\""
59
59
  },
60
60
  "devDependencies": {
61
+ "@sasjs/adapter": "6.2.0",
61
62
  "@sasjs/release": "0.18.0",
62
63
  "@types/jest": "30.0.0",
63
64
  "@types/node": "22.20.5",