@sasjs/api 0.50.0 → 0.51.1

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,18 @@ 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
+
40
+ **Viya mock compute context.** The list and detail expose one context, `SASjs Mock context`. Configure `contextName: 'SASjs Mock context'` when constructing a SASjs adapter for this mock: the adapter's own default remains `SAS Job Execution compute context` and does not match. Filtered name lookups return an empty collection for other names, not a synthesized context. The emulator supports only `eq(name,"...")` and `eq(name,'...')` with literal unescaped values, and case-sensitive matching; other filters and `sortBy` return 400 rather than silently being ignored. It supports non-negative integer `start` and `limit` (defaults 0 and 10); repeated or non-string values for `filter`, `start`, or `limit` return 400, and any supplied `sortBy` returns 400. `count` is the total matching collection size before pagination. This is a bounded mock contract, not a claim that these are the only valid Viya requests or that Viya uses the same error responses. The emulator does not execute SAS or provide a reusable batch identity.
41
+
36
42
  **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
43
 
44
+ **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.
45
+
46
+ **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.
47
+
38
48
  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
49
 
40
50
  **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.1 - 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
@@ -5770,7 +5780,7 @@ var SASjsApi = (() => {
5770
5780
  };
5771
5781
 
5772
5782
  // src/viya/compute.ts
5773
- var DEFAULT_CONTEXT_NAME = "SAS Job Execution compute context";
5783
+ var DEFAULT_CONTEXT_NAME = "SASjs Mock context";
5774
5784
  var EMULATED_CONTEXT_ID = idFor("emulated-context", "context");
5775
5785
  var relLinks = (type, rels) => rels.map(([rel, href]) => ({ href, uri: href, rel, method: "GET", type }));
5776
5786
  var linksFor = (uri, type, collection2 = false, itemType = false) => [
@@ -5799,9 +5809,16 @@ var SASjsApi = (() => {
5799
5809
  ];
5800
5810
  var estateOf = (services) => estateFor(estateKeyOf(services.viya), seedOf(services.viya));
5801
5811
  var contextNameFrom = (filter) => {
5802
- if (!filter) return DEFAULT_CONTEXT_NAME;
5803
- const match = /name\s*,\s*'([^']*)'|name\s*,\s*"([^"]*)"/i.exec(filter);
5804
- return match?.[1] ?? match?.[2] ?? DEFAULT_CONTEXT_NAME;
5812
+ if (filter === void 0) return DEFAULT_CONTEXT_NAME;
5813
+ const match = typeof filter === "string" ? /^\s*eq\(\s*name\s*,\s*(?:'([^'\\]*)'|"([^"\\]*)")\s*\)\s*$/.exec(
5814
+ filter
5815
+ ) : null;
5816
+ if (!match)
5817
+ throw new ApiError(
5818
+ 400,
5819
+ 'Unsupported compute context filter. Use eq(name, "...").'
5820
+ );
5821
+ return match[1] ?? match[2];
5805
5822
  };
5806
5823
  var contextBody = (name, caller) => ({
5807
5824
  id: EMULATED_CONTEXT_ID,
@@ -5869,7 +5886,7 @@ var SASjsApi = (() => {
5869
5886
  state: job.state,
5870
5887
  creationTimeStamp: job.creationTimeStamp,
5871
5888
  ...job.completedTimeStamp ? { completedTimeStamp: job.completedTimeStamp } : {},
5872
- jobConditionCode: 0,
5889
+ jobConditionCode: job.jobConditionCode ?? 0,
5873
5890
  stateElapsedTime: 1,
5874
5891
  listingStatistics: {
5875
5892
  lineCount: job.log.length,
@@ -5912,24 +5929,37 @@ var SASjsApi = (() => {
5912
5929
  return job;
5913
5930
  };
5914
5931
  var segmentsOf = (params) => params.segments;
5932
+ var validCodeLines = (lines) => {
5933
+ for (let i = 0; i < lines.length; i++)
5934
+ if (typeof lines[i] !== "string") return false;
5935
+ return true;
5936
+ };
5915
5937
  var COMPUTE_HANDLERS = {
5916
5938
  "GET /compute/contexts": async ({ request }) => {
5917
- const limit = Number(request.query?.limit ?? 0) || 0;
5939
+ if (request.query?.sortBy !== void 0)
5940
+ throw new ApiError(400, "Unsupported compute context sortBy.");
5941
+ const limitText = request.query?.limit;
5942
+ const startText = request.query?.start;
5943
+ const limitValue = limitText === void 0 ? "10" : limitText;
5944
+ const startValue = startText === void 0 ? "0" : startText;
5945
+ if (typeof startValue !== "string" || typeof limitValue !== "string" || !/^\d+$/.test(startValue) || !/^\d+$/.test(limitValue) || !Number.isSafeInteger(Number(startValue)) || !Number.isSafeInteger(Number(limitValue)))
5946
+ throw new ApiError(
5947
+ 400,
5948
+ "Unsupported compute context pagination. Use non-negative integers for start and limit."
5949
+ );
5950
+ const start = Number(startValue);
5951
+ const limit = Number(limitValue);
5952
+ const matches = contextNameFrom(request.query?.filter) === DEFAULT_CONTEXT_NAME ? [contextBody(DEFAULT_CONTEXT_NAME, callerId(request.subject))] : [];
5918
5953
  return {
5919
5954
  status: 200,
5920
5955
  body: {
5921
5956
  accept: "application/json",
5922
5957
  name: "contexts",
5923
- start: 0,
5958
+ start,
5924
5959
  limit,
5925
- count: 1,
5960
+ count: matches.length,
5926
5961
  version: 2,
5927
- items: [
5928
- contextBody(
5929
- contextNameFrom(request.query?.filter),
5930
- callerId(request.subject)
5931
- )
5932
- ],
5962
+ items: matches.slice(start, start + limit),
5933
5963
  links: linksFor(
5934
5964
  "/compute/contexts",
5935
5965
  "application/vnd.sas.compute.context",
@@ -5965,6 +5995,35 @@ var SASjsApi = (() => {
5965
5995
  )
5966
5996
  };
5967
5997
  },
5998
+ "GET /compute/sessions/{}/variables/{}": async ({
5999
+ services,
6000
+ params,
6001
+ request
6002
+ }) => {
6003
+ if (services.viya?.mockSysjobid !== true)
6004
+ throw new ApiError(501, SESSION_VARIABLE_REFUSAL, {
6005
+ message: SESSION_VARIABLE_REFUSAL
6006
+ });
6007
+ if (request.subject === void 0 && request.token !== void 0)
6008
+ throw new ApiError(401, "A valid caller is required.");
6009
+ const [sessionId, name] = segmentsOf(params);
6010
+ const session = sessionOf(services, sessionId, request.subject);
6011
+ if (name !== "SYSJOBID")
6012
+ throw new ApiError(501, SESSION_VARIABLE_REFUSAL, {
6013
+ message: SESSION_VARIABLE_REFUSAL
6014
+ });
6015
+ const uri = `/compute/sessions/${encodeURIComponent(session.id)}/variables/SYSJOBID`;
6016
+ return {
6017
+ status: 200,
6018
+ body: {
6019
+ name: "SYSJOBID",
6020
+ value: `mock-${session.id}`,
6021
+ scope: "AUTOMATIC",
6022
+ version: 1,
6023
+ links: linksFor(uri, "application/vnd.sas.compute.session.variable")
6024
+ }
6025
+ };
6026
+ },
5968
6027
  "GET /compute/sessions/{}/state": async ({ services, params, request }) => {
5969
6028
  sessionOf(services, params.id, request.subject);
5970
6029
  return { status: 200, body: "idle" };
@@ -5976,8 +6035,21 @@ var SASjsApi = (() => {
5976
6035
  },
5977
6036
  "POST /compute/sessions/{}/jobs": async ({ services, params, request }) => {
5978
6037
  const session = sessionOf(services, params.id, request.subject);
5979
- const body = request.body ?? {};
5980
- const job = estateOf(services).submit(session, body);
6038
+ const input = request.body === void 0 ? {} : request.body;
6039
+ if (!input || typeof input !== "object" || Array.isArray(input))
6040
+ throw new ApiError(
6041
+ 400,
6042
+ "Compute job code must be a string or an array of strings."
6043
+ );
6044
+ const body = input;
6045
+ const code = body.code;
6046
+ if (code !== void 0 && typeof code !== "string" && (!Array.isArray(code) || !validCodeLines(code)))
6047
+ throw new ApiError(
6048
+ 400,
6049
+ "Compute job code must be a string or an array of strings."
6050
+ );
6051
+ const program = code ?? "";
6052
+ const job = estateOf(services).submit(session, { ...body, code: program });
5981
6053
  const execute = services.viya?.execute;
5982
6054
  if (!execute) {
5983
6055
  job.state = "completed";
@@ -5987,13 +6059,14 @@ var SASjsApi = (() => {
5987
6059
  job.state = "running";
5988
6060
  job.log = [];
5989
6061
  void execute({
5990
- program: body.code ?? "",
6062
+ program,
5991
6063
  variables: body.variables,
5992
6064
  name: body.name,
5993
6065
  sessionId: session.id
5994
6066
  }).then((ran) => {
5995
6067
  job.log = ran.log.split("\n");
5996
6068
  job.state = ran.state ?? "completed";
6069
+ job.jobConditionCode = ran.jobConditionCode;
5997
6070
  if (ran.webout !== void 0) job.webout = ran.webout;
5998
6071
  job.completedTimeStamp = (/* @__PURE__ */ new Date()).toISOString();
5999
6072
  }).catch((error) => {
@@ -6044,6 +6117,51 @@ var SASjsApi = (() => {
6044
6117
  body: jobOf(services, sessionId, jobId, request.subject).state
6045
6118
  };
6046
6119
  },
6120
+ // The collection is a separate CLI call from the adapter's /log/content.
6121
+ "GET /compute/sessions/{}/jobs/{}/log": async ({
6122
+ services,
6123
+ params,
6124
+ request
6125
+ }) => {
6126
+ const [sessionId, jobId] = segmentsOf(params);
6127
+ const job = jobOf(services, sessionId, jobId, request.subject);
6128
+ const start = request.query?.start;
6129
+ const limit = request.query?.limit;
6130
+ const startValue = start === void 0 ? "0" : start;
6131
+ const limitValue = limit === void 0 ? "10" : limit;
6132
+ if (typeof startValue !== "string" || typeof limitValue !== "string" || !/^\d+$/.test(startValue) || !/^\d+$/.test(limitValue) || !Number.isSafeInteger(Number(startValue)) || !Number.isSafeInteger(Number(limitValue)) || Number(limitValue) > 2147483647)
6133
+ throw new ApiError(400, "Unsupported job log pagination.");
6134
+ if (request.query?.type !== void 0 || request.query?.timeout !== void 0)
6135
+ throw new ApiError(
6136
+ 400,
6137
+ "Job log type and timeout are not supported by the emulator."
6138
+ );
6139
+ const offset = Number(startValue);
6140
+ const pageSize = Number(limitValue);
6141
+ const uri = `/compute/sessions/${job.sessionId}/jobs/${job.id}/log`;
6142
+ return {
6143
+ status: 200,
6144
+ body: {
6145
+ accept: "application/json",
6146
+ name: "log",
6147
+ start: offset,
6148
+ limit: pageSize,
6149
+ count: job.log.length,
6150
+ version: 2,
6151
+ items: job.log.slice(offset, offset + pageSize).map((line) => ({ line, type: "NOTE", version: 2 })),
6152
+ links: [
6153
+ {
6154
+ href: uri,
6155
+ uri,
6156
+ rel: "self",
6157
+ method: "GET",
6158
+ type: "application/vnd.sas.collection",
6159
+ itemType: "application/vnd.sas.compute.log.line"
6160
+ }
6161
+ ]
6162
+ }
6163
+ };
6164
+ },
6047
6165
  "GET /compute/sessions/{}/jobs/{}/log/content": async ({
6048
6166
  services,
6049
6167
  params,
@@ -6821,6 +6939,8 @@ var SASjsApi = (() => {
6821
6939
  message: `${found.operation.id} is not emulated. ${entry.reason ?? ""}`.trim()
6822
6940
  }
6823
6941
  };
6942
+ if (found.operation.id === "GET /compute/sessions/{}/variables/{}" && services.viya?.mockSysjobid !== true)
6943
+ return { status: 501, headers, body: { message: SESSION_VARIABLE_REFUSAL } };
6824
6944
  const handler = VIYA_HANDLERS[found.operation.id];
6825
6945
  if (!handler)
6826
6946
  return {
@@ -5,18 +5,10 @@ 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
- /**
9
- * The name the emulator answers when a client asks for no particular context.
10
- *
11
- * It is the name of the context a Viya estate ships with, because that is the
12
- * name a client carries: `SASViyaApiClient.createSession` lists `/compute/contexts`
13
- * with no filter and picks the entry whose name it was given, so a default of the
14
- * emulator's own choosing fails every caller with a name that is right everywhere
15
- * else. A client may still name any context it likes - see `contextNameFrom` - and
16
- * the estate answers under that name.
17
- */
18
- exports.DEFAULT_CONTEXT_NAME = 'SAS Job Execution compute context';
19
- /** The one context id this estate mints, whatever name it is asked for. */
8
+ const overlay_js_1 = require("./overlay.js");
9
+ /** The one mock context, selected explicitly by clients. */
10
+ exports.DEFAULT_CONTEXT_NAME = 'SASjs Mock context';
11
+ /** The fixed id of the one emulated context. */
20
12
  exports.EMULATED_CONTEXT_ID = (0, ids_js_1.idFor)('emulated-context', 'context');
21
13
  /**
22
14
  * The links a client follows, by rel.
@@ -55,18 +47,19 @@ const linksFor = (uri, type, collection = false, itemType = false) => [
55
47
  ];
56
48
  const estateOf = (services) => (0, sessions_js_1.estateFor)((0, seed_js_1.estateKeyOf)(services.viya), (0, seed_js_1.seedOf)(services.viya));
57
49
  /**
58
- * The context name a client asked for.
59
- *
60
- * The adapter filters by name (`filter=eq(name,'X')`), so the answer is the one
61
- * emulated context under the requested name. A second estate is not something an
62
- * emulator can have, and an empty list would fail a client that has nothing wrong
63
- * with it.
50
+ * Read only the simple equality filter used by the adapter. Single-quoted
51
+ * names are also supported for existing mock clients. Escapes, other operators
52
+ * and compound expressions are refused rather than guessed.
64
53
  */
65
54
  const contextNameFrom = (filter) => {
66
- if (!filter)
55
+ if (filter === undefined)
67
56
  return exports.DEFAULT_CONTEXT_NAME;
68
- const match = /name\s*,\s*'([^']*)'|name\s*,\s*"([^"]*)"/i.exec(filter);
69
- return match?.[1] ?? match?.[2] ?? exports.DEFAULT_CONTEXT_NAME;
57
+ const match = typeof filter === 'string'
58
+ ? /^\s*eq\(\s*name\s*,\s*(?:'([^'\\]*)'|"([^"\\]*)")\s*\)\s*$/.exec(filter)
59
+ : null;
60
+ if (!match)
61
+ throw new types_js_1.ApiError(400, 'Unsupported compute context filter. Use eq(name, "...").');
62
+ return match[1] ?? match[2];
70
63
  };
71
64
  exports.contextNameFrom = contextNameFrom;
72
65
  const contextBody = (name, caller) => ({
@@ -141,7 +134,7 @@ const jobBody = (job) => {
141
134
  ...(job.completedTimeStamp
142
135
  ? { completedTimeStamp: job.completedTimeStamp }
143
136
  : {}),
144
- jobConditionCode: 0,
137
+ jobConditionCode: job.jobConditionCode ?? 0,
145
138
  stateElapsedTime: 1,
146
139
  listingStatistics: {
147
140
  lineCount: job.log.length,
@@ -197,21 +190,43 @@ const jobOf = (services, sessionId, jobId, subject) => {
197
190
  * no absent case to answer - a fallback here would be a branch nothing reaches.
198
191
  */
199
192
  const segmentsOf = (params) => params.segments;
193
+ // Visit every index, including holes in arrays supplied by direct dispatch.
194
+ const validCodeLines = (lines) => {
195
+ for (let i = 0; i < lines.length; i++)
196
+ if (typeof lines[i] !== 'string')
197
+ return false;
198
+ return true;
199
+ };
200
200
  exports.COMPUTE_HANDLERS = {
201
201
  'GET /compute/contexts': async ({ request }) => {
202
- const limit = Number(request.query?.limit ?? 0) || 0;
202
+ if (request.query?.sortBy !== undefined)
203
+ throw new types_js_1.ApiError(400, 'Unsupported compute context sortBy.');
204
+ const limitText = request.query?.limit;
205
+ const startText = request.query?.start;
206
+ const limitValue = limitText === undefined ? '10' : limitText;
207
+ const startValue = startText === undefined ? '0' : startText;
208
+ if (typeof startValue !== 'string' ||
209
+ typeof limitValue !== 'string' ||
210
+ !/^\d+$/.test(startValue) ||
211
+ !/^\d+$/.test(limitValue) ||
212
+ !Number.isSafeInteger(Number(startValue)) ||
213
+ !Number.isSafeInteger(Number(limitValue)))
214
+ throw new types_js_1.ApiError(400, 'Unsupported compute context pagination. Use non-negative integers for start and limit.');
215
+ const start = Number(startValue);
216
+ const limit = Number(limitValue);
217
+ const matches = (0, exports.contextNameFrom)(request.query?.filter) === exports.DEFAULT_CONTEXT_NAME
218
+ ? [contextBody(exports.DEFAULT_CONTEXT_NAME, (0, ids_js_1.callerId)(request.subject))]
219
+ : [];
203
220
  return {
204
221
  status: 200,
205
222
  body: {
206
223
  accept: 'application/json',
207
224
  name: 'contexts',
208
- start: 0,
225
+ start,
209
226
  limit,
210
- count: 1,
227
+ count: matches.length,
211
228
  version: 2,
212
- items: [
213
- contextBody((0, exports.contextNameFrom)(request.query?.filter), (0, ids_js_1.callerId)(request.subject))
214
- ],
229
+ items: matches.slice(start, start + limit),
215
230
  links: linksFor('/compute/contexts', 'application/vnd.sas.compute.context', true)
216
231
  }
217
232
  };
@@ -234,6 +249,31 @@ exports.COMPUTE_HANDLERS = {
234
249
  body: sessionBody(services, session, body.environment?.autoExecLines ?? [], (0, ids_js_1.callerId)(request.subject))
235
250
  };
236
251
  },
252
+ 'GET /compute/sessions/{}/variables/{}': async ({ services, params, request }) => {
253
+ if (services.viya?.mockSysjobid !== true)
254
+ throw new types_js_1.ApiError(501, overlay_js_1.SESSION_VARIABLE_REFUSAL, {
255
+ message: overlay_js_1.SESSION_VARIABLE_REFUSAL
256
+ });
257
+ if (request.subject === undefined && request.token !== undefined)
258
+ throw new types_js_1.ApiError(401, 'A valid caller is required.');
259
+ const [sessionId, name] = segmentsOf(params);
260
+ const session = sessionOf(services, sessionId, request.subject);
261
+ if (name !== 'SYSJOBID')
262
+ throw new types_js_1.ApiError(501, overlay_js_1.SESSION_VARIABLE_REFUSAL, {
263
+ message: overlay_js_1.SESSION_VARIABLE_REFUSAL
264
+ });
265
+ const uri = `/compute/sessions/${encodeURIComponent(session.id)}/variables/SYSJOBID`;
266
+ return {
267
+ status: 200,
268
+ body: {
269
+ name: 'SYSJOBID',
270
+ value: `mock-${session.id}`,
271
+ scope: 'AUTOMATIC',
272
+ version: 1,
273
+ links: linksFor(uri, 'application/vnd.sas.compute.session.variable')
274
+ }
275
+ };
276
+ },
237
277
  'GET /compute/sessions/{}/state': async ({ services, params, request }) => {
238
278
  sessionOf(services, params.id, request.subject);
239
279
  // a bare enum, not an object: the adapter calls `.trim()` on the answer, and
@@ -247,8 +287,17 @@ exports.COMPUTE_HANDLERS = {
247
287
  },
248
288
  'POST /compute/sessions/{}/jobs': async ({ services, params, request }) => {
249
289
  const session = sessionOf(services, params.id, request.subject);
250
- const body = (request.body ?? {});
251
- const job = estateOf(services).submit(session, body);
290
+ const input = request.body === undefined ? {} : request.body;
291
+ if (!input || typeof input !== 'object' || Array.isArray(input))
292
+ throw new types_js_1.ApiError(400, 'Compute job code must be a string or an array of strings.');
293
+ const body = input;
294
+ const code = body.code;
295
+ if (code !== undefined &&
296
+ typeof code !== 'string' &&
297
+ (!Array.isArray(code) || !validCodeLines(code)))
298
+ throw new types_js_1.ApiError(400, 'Compute job code must be a string or an array of strings.');
299
+ const program = (code ?? '');
300
+ const job = estateOf(services).submit(session, { ...body, code: program });
252
301
  const execute = services.viya?.execute;
253
302
  // a host with no engine has nothing to run, so the job is finished at once
254
303
  if (!execute) {
@@ -264,7 +313,7 @@ exports.COMPUTE_HANDLERS = {
264
313
  // not advertise them - the run writes the log when it has one
265
314
  job.log = [];
266
315
  void execute({
267
- program: body.code ?? '',
316
+ program,
268
317
  variables: body.variables,
269
318
  name: body.name,
270
319
  sessionId: session.id
@@ -272,6 +321,7 @@ exports.COMPUTE_HANDLERS = {
272
321
  .then((ran) => {
273
322
  job.log = ran.log.split('\n');
274
323
  job.state = ran.state ?? 'completed';
324
+ job.jobConditionCode = ran.jobConditionCode;
275
325
  if (ran.webout !== undefined)
276
326
  job.webout = ran.webout;
277
327
  job.completedTimeStamp = new Date().toISOString();
@@ -319,6 +369,53 @@ exports.COMPUTE_HANDLERS = {
319
369
  body: jobOf(services, sessionId, jobId, request.subject).state
320
370
  };
321
371
  },
372
+ // The collection is a separate CLI call from the adapter's /log/content.
373
+ 'GET /compute/sessions/{}/jobs/{}/log': async ({ services, params, request }) => {
374
+ const [sessionId, jobId] = segmentsOf(params);
375
+ const job = jobOf(services, sessionId, jobId, request.subject);
376
+ const start = request.query?.start;
377
+ const limit = request.query?.limit;
378
+ const startValue = start === undefined ? '0' : start;
379
+ const limitValue = limit === undefined ? '10' : limit;
380
+ if (typeof startValue !== 'string' ||
381
+ typeof limitValue !== 'string' ||
382
+ !/^\d+$/.test(startValue) ||
383
+ !/^\d+$/.test(limitValue) ||
384
+ !Number.isSafeInteger(Number(startValue)) ||
385
+ !Number.isSafeInteger(Number(limitValue)) ||
386
+ Number(limitValue) > 2147483647)
387
+ throw new types_js_1.ApiError(400, 'Unsupported job log pagination.');
388
+ if (request.query?.type !== undefined ||
389
+ request.query?.timeout !== undefined)
390
+ throw new types_js_1.ApiError(400, 'Job log type and timeout are not supported by the emulator.');
391
+ const offset = Number(startValue);
392
+ const pageSize = Number(limitValue);
393
+ const uri = `/compute/sessions/${job.sessionId}/jobs/${job.id}/log`;
394
+ return {
395
+ status: 200,
396
+ body: {
397
+ accept: 'application/json',
398
+ name: 'log',
399
+ start: offset,
400
+ limit: pageSize,
401
+ count: job.log.length,
402
+ version: 2,
403
+ items: job.log
404
+ .slice(offset, offset + pageSize)
405
+ .map((line) => ({ line, type: 'NOTE', version: 2 })),
406
+ links: [
407
+ {
408
+ href: uri,
409
+ uri,
410
+ rel: 'self',
411
+ method: 'GET',
412
+ type: 'application/vnd.sas.collection',
413
+ itemType: 'application/vnd.sas.compute.log.line'
414
+ }
415
+ ]
416
+ }
417
+ };
418
+ },
322
419
  'GET /compute/sessions/{}/jobs/{}/log/content': async ({ services, params, request }) => {
323
420
  const [sessionId, jobId] = segmentsOf(params);
324
421
  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
@@ -7,35 +7,21 @@
7
7
  * because there is no SAS engine to reach for in a browser and no reason to reach
8
8
  * for one here.
9
9
  *
10
- * The context is the one place the emulator answers the question it was asked
11
- * rather than one it chose: a client names the context it wants by filter and the
12
- * emulated estate has exactly one, under that name. Its id does not move with the
13
- * name, so a session can be created for the id the list returned.
10
+ * The emulated estate has one context. Its list, detail and session creation
11
+ * share its fixed identity; a filter cannot rename it.
14
12
  */
15
13
  import type { ApiResponse, Services } from '../host/dispatch.js';
16
14
  import type { Subject } from '../identity/types.js';
17
- /**
18
- * The name the emulator answers when a client asks for no particular context.
19
- *
20
- * It is the name of the context a Viya estate ships with, because that is the
21
- * name a client carries: `SASViyaApiClient.createSession` lists `/compute/contexts`
22
- * with no filter and picks the entry whose name it was given, so a default of the
23
- * emulator's own choosing fails every caller with a name that is right everywhere
24
- * else. A client may still name any context it likes - see `contextNameFrom` - and
25
- * the estate answers under that name.
26
- */
27
- export declare const DEFAULT_CONTEXT_NAME = "SAS Job Execution compute context";
28
- /** The one context id this estate mints, whatever name it is asked for. */
15
+ /** The one mock context, selected explicitly by clients. */
16
+ export declare const DEFAULT_CONTEXT_NAME = "SASjs Mock context";
17
+ /** The fixed id of the one emulated context. */
29
18
  export declare const EMULATED_CONTEXT_ID: string;
30
19
  /**
31
- * The context name a client asked for.
32
- *
33
- * The adapter filters by name (`filter=eq(name,'X')`), so the answer is the one
34
- * emulated context under the requested name. A second estate is not something an
35
- * emulator can have, and an empty list would fail a client that has nothing wrong
36
- * with it.
20
+ * Read only the simple equality filter used by the adapter. Single-quoted
21
+ * names are also supported for existing mock clients. Escapes, other operators
22
+ * and compound expressions are refused rather than guessed.
37
23
  */
38
- export declare const contextNameFrom: (filter: string | undefined) => string;
24
+ export declare const contextNameFrom: (filter: unknown) => string;
39
25
  export declare const COMPUTE_HANDLERS: Record<string, (context: {
40
26
  services: Services;
41
27
  request: {
@@ -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;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAChE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAOnD,4DAA4D;AAC5D,eAAO,MAAM,oBAAoB,uBAAuB,CAAA;AAExD,gDAAgD;AAChD,eAAO,MAAM,mBAAmB,QAAuC,CAAA;AAgDvE;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,OAAO,KAAG,MAgBjD,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,CA0V3B,CAAA"}
@@ -2,18 +2,10 @@ 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
- /**
6
- * The name the emulator answers when a client asks for no particular context.
7
- *
8
- * It is the name of the context a Viya estate ships with, because that is the
9
- * name a client carries: `SASViyaApiClient.createSession` lists `/compute/contexts`
10
- * with no filter and picks the entry whose name it was given, so a default of the
11
- * emulator's own choosing fails every caller with a name that is right everywhere
12
- * else. A client may still name any context it likes - see `contextNameFrom` - and
13
- * the estate answers under that name.
14
- */
15
- export const DEFAULT_CONTEXT_NAME = 'SAS Job Execution compute context';
16
- /** The one context id this estate mints, whatever name it is asked for. */
5
+ import { SESSION_VARIABLE_REFUSAL } from './overlay.js';
6
+ /** The one mock context, selected explicitly by clients. */
7
+ export const DEFAULT_CONTEXT_NAME = 'SASjs Mock context';
8
+ /** The fixed id of the one emulated context. */
17
9
  export const EMULATED_CONTEXT_ID = idFor('emulated-context', 'context');
18
10
  /**
19
11
  * The links a client follows, by rel.
@@ -52,18 +44,19 @@ const linksFor = (uri, type, collection = false, itemType = false) => [
52
44
  ];
53
45
  const estateOf = (services) => estateFor(estateKeyOf(services.viya), seedOf(services.viya));
54
46
  /**
55
- * The context name a client asked for.
56
- *
57
- * The adapter filters by name (`filter=eq(name,'X')`), so the answer is the one
58
- * emulated context under the requested name. A second estate is not something an
59
- * emulator can have, and an empty list would fail a client that has nothing wrong
60
- * with it.
47
+ * Read only the simple equality filter used by the adapter. Single-quoted
48
+ * names are also supported for existing mock clients. Escapes, other operators
49
+ * and compound expressions are refused rather than guessed.
61
50
  */
62
51
  export const contextNameFrom = (filter) => {
63
- if (!filter)
52
+ if (filter === undefined)
64
53
  return DEFAULT_CONTEXT_NAME;
65
- const match = /name\s*,\s*'([^']*)'|name\s*,\s*"([^"]*)"/i.exec(filter);
66
- return match?.[1] ?? match?.[2] ?? DEFAULT_CONTEXT_NAME;
54
+ const match = typeof filter === 'string'
55
+ ? /^\s*eq\(\s*name\s*,\s*(?:'([^'\\]*)'|"([^"\\]*)")\s*\)\s*$/.exec(filter)
56
+ : null;
57
+ if (!match)
58
+ throw new ApiError(400, 'Unsupported compute context filter. Use eq(name, "...").');
59
+ return match[1] ?? match[2];
67
60
  };
68
61
  const contextBody = (name, caller) => ({
69
62
  id: EMULATED_CONTEXT_ID,
@@ -137,7 +130,7 @@ const jobBody = (job) => {
137
130
  ...(job.completedTimeStamp
138
131
  ? { completedTimeStamp: job.completedTimeStamp }
139
132
  : {}),
140
- jobConditionCode: 0,
133
+ jobConditionCode: job.jobConditionCode ?? 0,
141
134
  stateElapsedTime: 1,
142
135
  listingStatistics: {
143
136
  lineCount: job.log.length,
@@ -193,21 +186,43 @@ const jobOf = (services, sessionId, jobId, subject) => {
193
186
  * no absent case to answer - a fallback here would be a branch nothing reaches.
194
187
  */
195
188
  const segmentsOf = (params) => params.segments;
189
+ // Visit every index, including holes in arrays supplied by direct dispatch.
190
+ const validCodeLines = (lines) => {
191
+ for (let i = 0; i < lines.length; i++)
192
+ if (typeof lines[i] !== 'string')
193
+ return false;
194
+ return true;
195
+ };
196
196
  export const COMPUTE_HANDLERS = {
197
197
  'GET /compute/contexts': async ({ request }) => {
198
- const limit = Number(request.query?.limit ?? 0) || 0;
198
+ if (request.query?.sortBy !== undefined)
199
+ throw new ApiError(400, 'Unsupported compute context sortBy.');
200
+ const limitText = request.query?.limit;
201
+ const startText = request.query?.start;
202
+ const limitValue = limitText === undefined ? '10' : limitText;
203
+ const startValue = startText === undefined ? '0' : startText;
204
+ if (typeof startValue !== 'string' ||
205
+ typeof limitValue !== 'string' ||
206
+ !/^\d+$/.test(startValue) ||
207
+ !/^\d+$/.test(limitValue) ||
208
+ !Number.isSafeInteger(Number(startValue)) ||
209
+ !Number.isSafeInteger(Number(limitValue)))
210
+ throw new ApiError(400, 'Unsupported compute context pagination. Use non-negative integers for start and limit.');
211
+ const start = Number(startValue);
212
+ const limit = Number(limitValue);
213
+ const matches = contextNameFrom(request.query?.filter) === DEFAULT_CONTEXT_NAME
214
+ ? [contextBody(DEFAULT_CONTEXT_NAME, callerId(request.subject))]
215
+ : [];
199
216
  return {
200
217
  status: 200,
201
218
  body: {
202
219
  accept: 'application/json',
203
220
  name: 'contexts',
204
- start: 0,
221
+ start,
205
222
  limit,
206
- count: 1,
223
+ count: matches.length,
207
224
  version: 2,
208
- items: [
209
- contextBody(contextNameFrom(request.query?.filter), callerId(request.subject))
210
- ],
225
+ items: matches.slice(start, start + limit),
211
226
  links: linksFor('/compute/contexts', 'application/vnd.sas.compute.context', true)
212
227
  }
213
228
  };
@@ -230,6 +245,31 @@ export const COMPUTE_HANDLERS = {
230
245
  body: sessionBody(services, session, body.environment?.autoExecLines ?? [], callerId(request.subject))
231
246
  };
232
247
  },
248
+ 'GET /compute/sessions/{}/variables/{}': async ({ services, params, request }) => {
249
+ if (services.viya?.mockSysjobid !== true)
250
+ throw new ApiError(501, SESSION_VARIABLE_REFUSAL, {
251
+ message: SESSION_VARIABLE_REFUSAL
252
+ });
253
+ if (request.subject === undefined && request.token !== undefined)
254
+ throw new ApiError(401, 'A valid caller is required.');
255
+ const [sessionId, name] = segmentsOf(params);
256
+ const session = sessionOf(services, sessionId, request.subject);
257
+ if (name !== 'SYSJOBID')
258
+ throw new ApiError(501, SESSION_VARIABLE_REFUSAL, {
259
+ message: SESSION_VARIABLE_REFUSAL
260
+ });
261
+ const uri = `/compute/sessions/${encodeURIComponent(session.id)}/variables/SYSJOBID`;
262
+ return {
263
+ status: 200,
264
+ body: {
265
+ name: 'SYSJOBID',
266
+ value: `mock-${session.id}`,
267
+ scope: 'AUTOMATIC',
268
+ version: 1,
269
+ links: linksFor(uri, 'application/vnd.sas.compute.session.variable')
270
+ }
271
+ };
272
+ },
233
273
  'GET /compute/sessions/{}/state': async ({ services, params, request }) => {
234
274
  sessionOf(services, params.id, request.subject);
235
275
  // a bare enum, not an object: the adapter calls `.trim()` on the answer, and
@@ -243,8 +283,17 @@ export const COMPUTE_HANDLERS = {
243
283
  },
244
284
  'POST /compute/sessions/{}/jobs': async ({ services, params, request }) => {
245
285
  const session = sessionOf(services, params.id, request.subject);
246
- const body = (request.body ?? {});
247
- const job = estateOf(services).submit(session, body);
286
+ const input = request.body === undefined ? {} : request.body;
287
+ if (!input || typeof input !== 'object' || Array.isArray(input))
288
+ throw new ApiError(400, 'Compute job code must be a string or an array of strings.');
289
+ const body = input;
290
+ const code = body.code;
291
+ if (code !== undefined &&
292
+ typeof code !== 'string' &&
293
+ (!Array.isArray(code) || !validCodeLines(code)))
294
+ throw new ApiError(400, 'Compute job code must be a string or an array of strings.');
295
+ const program = (code ?? '');
296
+ const job = estateOf(services).submit(session, { ...body, code: program });
248
297
  const execute = services.viya?.execute;
249
298
  // a host with no engine has nothing to run, so the job is finished at once
250
299
  if (!execute) {
@@ -260,7 +309,7 @@ export const COMPUTE_HANDLERS = {
260
309
  // not advertise them - the run writes the log when it has one
261
310
  job.log = [];
262
311
  void execute({
263
- program: body.code ?? '',
312
+ program,
264
313
  variables: body.variables,
265
314
  name: body.name,
266
315
  sessionId: session.id
@@ -268,6 +317,7 @@ export const COMPUTE_HANDLERS = {
268
317
  .then((ran) => {
269
318
  job.log = ran.log.split('\n');
270
319
  job.state = ran.state ?? 'completed';
320
+ job.jobConditionCode = ran.jobConditionCode;
271
321
  if (ran.webout !== undefined)
272
322
  job.webout = ran.webout;
273
323
  job.completedTimeStamp = new Date().toISOString();
@@ -315,6 +365,53 @@ export const COMPUTE_HANDLERS = {
315
365
  body: jobOf(services, sessionId, jobId, request.subject).state
316
366
  };
317
367
  },
368
+ // The collection is a separate CLI call from the adapter's /log/content.
369
+ 'GET /compute/sessions/{}/jobs/{}/log': async ({ services, params, request }) => {
370
+ const [sessionId, jobId] = segmentsOf(params);
371
+ const job = jobOf(services, sessionId, jobId, request.subject);
372
+ const start = request.query?.start;
373
+ const limit = request.query?.limit;
374
+ const startValue = start === undefined ? '0' : start;
375
+ const limitValue = limit === undefined ? '10' : limit;
376
+ if (typeof startValue !== 'string' ||
377
+ typeof limitValue !== 'string' ||
378
+ !/^\d+$/.test(startValue) ||
379
+ !/^\d+$/.test(limitValue) ||
380
+ !Number.isSafeInteger(Number(startValue)) ||
381
+ !Number.isSafeInteger(Number(limitValue)) ||
382
+ Number(limitValue) > 2147483647)
383
+ throw new ApiError(400, 'Unsupported job log pagination.');
384
+ if (request.query?.type !== undefined ||
385
+ request.query?.timeout !== undefined)
386
+ throw new ApiError(400, 'Job log type and timeout are not supported by the emulator.');
387
+ const offset = Number(startValue);
388
+ const pageSize = Number(limitValue);
389
+ const uri = `/compute/sessions/${job.sessionId}/jobs/${job.id}/log`;
390
+ return {
391
+ status: 200,
392
+ body: {
393
+ accept: 'application/json',
394
+ name: 'log',
395
+ start: offset,
396
+ limit: pageSize,
397
+ count: job.log.length,
398
+ version: 2,
399
+ items: job.log
400
+ .slice(offset, offset + pageSize)
401
+ .map((line) => ({ line, type: 'NOTE', version: 2 })),
402
+ links: [
403
+ {
404
+ href: uri,
405
+ uri,
406
+ rel: 'self',
407
+ method: 'GET',
408
+ type: 'application/vnd.sas.collection',
409
+ itemType: 'application/vnd.sas.compute.log.line'
410
+ }
411
+ ]
412
+ }
413
+ };
414
+ },
318
415
  'GET /compute/sessions/{}/jobs/{}/log/content': async ({ services, params, request }) => {
319
416
  const [sessionId, jobId] = segmentsOf(params);
320
417
  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":["../../../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
+ {"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,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,g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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.
@@ -1 +1 @@
1
- {"version":3,"file":"sessions.d.ts","sourceRoot":"","sources":["../../../src/viya/sessions.ts"],"names":[],"mappings":"AAkBA,gEAAgE;AAChE,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,oDAAoD;IACpD,GAAG,EAAE,MAAM,EAAE,CAAA;IACb,sEAAsE;IACtE,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;;;;;;OAOG;IACH,KAAK,EAAE,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAA;IACzC,iBAAiB,EAAE,MAAM,CAAA;IACzB;;;;;OAKG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,MAAM,YAAY,GACtB;IAAE,IAAI,EAAE,SAAS,GAAG,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,GAAG,CAAC,EAAE,KAAK,CAAA;CAAE,CAAA;AAEhF,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAA;IACV,0DAA0D;IAC1D,KAAK,EAAE,YAAY,CAAA;IACnB,gFAAgF;IAChF,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;IAC9B,8EAA8E;IAC9E,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,kFAAkF;AAClF,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC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GAAG,EAAE,YAAY,GAAG,WAAW;CAwBjE;AAKD;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,GAAI,KAAK,MAAM,EAAE,MAAM,MAAM,KAAG,cAUrD,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sasjs/api",
3
- "version": "0.50.0",
3
+ "version": "0.51.1",
4
4
  "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",