@sasjs/api 0.48.1 → 0.49.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/build/browser.js CHANGED
@@ -1,4 +1,4 @@
1
- /* @sasjs/api 0.48.1 - the SASjs Server API, for a service worker. https://github.com/sasjs/api */
1
+ /* @sasjs/api 0.49.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;
@@ -139,12 +139,14 @@ var SASjsApi = (() => {
139
139
  parseIdentity: () => parseIdentity,
140
140
  programNotFound: () => programNotFound,
141
141
  publishRequestFor: () => publishRequestFor,
142
+ requestFor: () => requestFor,
142
143
  resolveProgram: () => resolveProgram,
143
144
  routeById: () => routeById,
144
145
  runCase: () => runCase,
145
146
  runTimeOfPath: () => runTimeOfPath,
146
147
  sanitiseDisplayName: () => sanitiseDisplayName,
147
148
  servicesFor: () => servicesFor,
149
+ shapeMismatches: () => shapeMismatches,
148
150
  splitAppBundle: () => splitAppBundle,
149
151
  topLevelRouteFor: () => topLevelRouteFor,
150
152
  withBundleVersion: () => withBundleVersion
@@ -6126,6 +6128,10 @@ var SASjsApi = (() => {
6126
6128
  modifiedTimeStamp: EMULATED_NOW,
6127
6129
  memberCount: listing.files.length + listing.folders.length,
6128
6130
  parentFolderUri: `/folders/folders/${idFor(parent)}`,
6131
+ // the capture's folder shape carries `properties`, and this body is the one a
6132
+ // real folder is read through: answering only the recycle bin with it left a
6133
+ // client reading `folder.properties` against nothing
6134
+ properties: { allowMove: "true" },
6129
6135
  links: linksFor2(`/folders/folders/${id}`)
6130
6136
  };
6131
6137
  };
@@ -6200,20 +6206,57 @@ var SASjsApi = (() => {
6200
6206
  }
6201
6207
  };
6202
6208
  },
6203
- "GET /types/types": async () => ({
6204
- status: 200,
6205
- body: {
6206
- count: 1,
6207
- items: [
6209
+ "GET /types/types": async ({ request }) => {
6210
+ const limit = Number(request.query?.limit ?? 0) || 0;
6211
+ const item = {
6212
+ name: "file",
6213
+ label: "File",
6214
+ description: "A file type",
6215
+ mediaType: "application/octet-stream",
6216
+ resourceUri: "/types/types/file",
6217
+ iconUri: "/types/types/file/icon",
6218
+ tags: ["file"],
6219
+ version: 1,
6220
+ links: [
6208
6221
  {
6209
- name: "file",
6210
- type: "typeDef",
6211
- version: 1,
6212
- links: [{ href: "/types/types/file", rel: "self", method: "GET" }]
6222
+ href: "/types/types/file",
6223
+ uri: "/types/types/file",
6224
+ rel: "self",
6225
+ method: "GET",
6226
+ type: "application/vnd.sas.type.definition"
6213
6227
  }
6214
6228
  ]
6215
- }
6216
- }),
6229
+ };
6230
+ return {
6231
+ status: 200,
6232
+ body: {
6233
+ accept: "application/json",
6234
+ name: "types",
6235
+ start: 0,
6236
+ limit,
6237
+ count: 1,
6238
+ version: 2,
6239
+ items: [item],
6240
+ links: [
6241
+ {
6242
+ href: "/types/types",
6243
+ uri: "/types/types",
6244
+ rel: "collection",
6245
+ method: "GET",
6246
+ type: "application/vnd.sas.collection",
6247
+ itemType: "typeDef"
6248
+ },
6249
+ {
6250
+ href: "/types/types",
6251
+ uri: "/types/types",
6252
+ rel: "self",
6253
+ method: "GET",
6254
+ type: "application/vnd.sas.collection"
6255
+ }
6256
+ ]
6257
+ }
6258
+ };
6259
+ },
6217
6260
  "GET /folders/folders/@item": async ({ services, request }) => ({
6218
6261
  status: 200,
6219
6262
  body: await folderBody(
@@ -7422,6 +7465,82 @@ var SASjsApi = (() => {
7422
7465
  }
7423
7466
  ];
7424
7467
 
7468
+ // src/corpus/viya/replay.ts
7469
+ var KEY_BY_SEGMENT = {
7470
+ contexts: "context",
7471
+ sessions: "session",
7472
+ jobs: "job",
7473
+ folders: "folder",
7474
+ files: "file",
7475
+ definitions: "definition",
7476
+ variables: "variable"
7477
+ };
7478
+ var requestFor = (viyaCase, state = {}, queryValues = {}) => {
7479
+ const [method, template] = viyaCase.route.split(" ");
7480
+ const unresolved = [];
7481
+ return build(
7482
+ method,
7483
+ template.split("/"),
7484
+ viyaCase,
7485
+ state,
7486
+ queryValues,
7487
+ unresolved
7488
+ );
7489
+ };
7490
+ var build = (method, segments, viyaCase, state, queryValues, unresolved) => {
7491
+ let previousSegment = "";
7492
+ const filled = segments.map((segment) => {
7493
+ if (segment !== "{}") {
7494
+ previousSegment = segment;
7495
+ return segment;
7496
+ }
7497
+ const key = KEY_BY_SEGMENT[previousSegment] ?? previousSegment;
7498
+ const id = state[key];
7499
+ if (id === void 0) {
7500
+ unresolved.push(key);
7501
+ return "{}";
7502
+ }
7503
+ return id;
7504
+ });
7505
+ let path = filled.join("/");
7506
+ const omittedQueries = [];
7507
+ const params = [];
7508
+ for (const name of viyaCase.queries) {
7509
+ const value = queryValues[name];
7510
+ if (value === void 0) omittedQueries.push(name);
7511
+ else params.push(`${encodeURIComponent(name)}=${encodeURIComponent(value)}`);
7512
+ }
7513
+ if (params.length) path += (path.includes("?") ? "&" : "?") + params.join("&");
7514
+ return { method, path, unresolved, omittedQueries };
7515
+ };
7516
+ var shapeMismatches = (shape, body, where = "body") => {
7517
+ if (shape === "object")
7518
+ return isRecord(body) ? [] : [`${where}: expected an object, got ${typeName(body)}`];
7519
+ if (shape === "array")
7520
+ return Array.isArray(body) ? [] : [`${where}: expected an array, got ${typeName(body)}`];
7521
+ if (Array.isArray(shape)) {
7522
+ if (!Array.isArray(body))
7523
+ return [`${where}: expected an array, got ${typeName(body)}`];
7524
+ const first = body[0];
7525
+ return first === void 0 || shape.length === 0 ? [] : shapeMismatches(shape[0], first, `${where}[0]`);
7526
+ }
7527
+ if (shape && typeof shape === "object") {
7528
+ if (!isRecord(body))
7529
+ return [`${where}: expected an object, got ${typeName(body)}`];
7530
+ const record = body;
7531
+ return Object.keys(shape).flatMap(
7532
+ (key) => key in record ? shapeMismatches(
7533
+ shape[key],
7534
+ record[key],
7535
+ `${where}.${key}`
7536
+ ) : [`${where}.${key}: missing from the answer`]
7537
+ );
7538
+ }
7539
+ return typeof body === String(shape) ? [] : [`${where}: expected ${String(shape)}, got ${typeName(body)}`];
7540
+ };
7541
+ var typeName = (value) => value === null ? "null" : Array.isArray(value) ? "array" : typeof value;
7542
+ var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
7543
+
7425
7544
  // src/appstream/bundle.ts
7426
7545
  var APP_MANIFEST = "sasjs.app.json";
7427
7546
  var FRONTEND_FOLDER = "web";
@@ -9667,16 +9786,16 @@ var SASjsApi = (() => {
9667
9786
  var normaliseDiagnostics = (report) => {
9668
9787
  if (!isObject2(report))
9669
9788
  throw new Error("The diagnostics report is not an object.");
9670
- const build = requireObject(
9789
+ const build2 = requireObject(
9671
9790
  report,
9672
9791
  "build",
9673
9792
  "diagnostics"
9674
9793
  );
9675
- requireString(build, "version", "diagnostics build");
9676
- requireString(build, "gitHash", "diagnostics build");
9677
- if (!(build.buildDate === null || isString(build.buildDate)))
9794
+ requireString(build2, "version", "diagnostics build");
9795
+ requireString(build2, "gitHash", "diagnostics build");
9796
+ if (!(build2.buildDate === null || isString(build2.buildDate)))
9678
9797
  throw new Error(
9679
- `The diagnostics build states \`buildDate\` as ${JSON.stringify(build.buildDate)}; the document states an ISO timestamp or null.`
9798
+ `The diagnostics build states \`buildDate\` as ${JSON.stringify(build2.buildDate)}; the document states an ISO timestamp or null.`
9680
9799
  );
9681
9800
  const server = requireObject(
9682
9801
  report,
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.shapeMismatches = exports.requestFor = void 0;
4
+ /** The segment a hole sits in, which is what names the id it takes. */
5
+ const KEY_BY_SEGMENT = {
6
+ contexts: 'context',
7
+ sessions: 'session',
8
+ jobs: 'job',
9
+ folders: 'folder',
10
+ files: 'file',
11
+ definitions: 'definition',
12
+ variables: 'variable'
13
+ };
14
+ /**
15
+ * The request a captured case stands for, with `{}` filled from the ids a replay
16
+ * has collected so far.
17
+ *
18
+ * A hole takes the id named by the segment before it (`/folders/folders/{}` is a
19
+ * folder). A hole the state cannot fill is reported, not guessed: a path built
20
+ * from a placeholder would answer a 404 that says nothing about the contract.
21
+ */
22
+ const requestFor = (viyaCase, state = {}, queryValues = {}) => {
23
+ const [method, template] = viyaCase.route.split(' ');
24
+ const unresolved = [];
25
+ return build(method, template.split('/'), viyaCase, state, queryValues, unresolved);
26
+ };
27
+ exports.requestFor = requestFor;
28
+ /** Segments back into the path, filling each hole from the state. */
29
+ const build = (method, segments, viyaCase, state, queryValues, unresolved) => {
30
+ let previousSegment = '';
31
+ const filled = segments.map((segment) => {
32
+ if (segment !== '{}') {
33
+ previousSegment = segment;
34
+ return segment;
35
+ }
36
+ const key = KEY_BY_SEGMENT[previousSegment] ?? previousSegment;
37
+ const id = state[key];
38
+ if (id === undefined) {
39
+ unresolved.push(key);
40
+ return '{}';
41
+ }
42
+ return id;
43
+ });
44
+ let path = filled.join('/');
45
+ const omittedQueries = [];
46
+ const params = [];
47
+ // encoded by hand rather than with `URLSearchParams`: this module is compiled
48
+ // for the browser host as well as for node, and the package's build does not
49
+ // carry the DOM types that class needs
50
+ for (const name of viyaCase.queries) {
51
+ const value = queryValues[name];
52
+ if (value === undefined)
53
+ omittedQueries.push(name);
54
+ else
55
+ params.push(`${encodeURIComponent(name)}=${encodeURIComponent(value)}`);
56
+ }
57
+ if (params.length)
58
+ path += (path.includes('?') ? '&' : '?') + params.join('&');
59
+ return { method, path, unresolved, omittedQueries };
60
+ };
61
+ /**
62
+ * Every place a captured shape and a body disagree, as readable strings.
63
+ *
64
+ * A shape's leaves are type names, so the comparison is on `typeof`; `'object'` is
65
+ * the depth cap and means "an object, contents not recorded". Unlike an
66
+ * assertion, this collects, so a host can report all the drift in one run instead
67
+ * of stopping at the first key - and a body with an element shows its element's
68
+ * shape, because an empty array proves nothing about it.
69
+ */
70
+ const shapeMismatches = (shape, body, where = 'body') => {
71
+ if (shape === 'object')
72
+ return isRecord(body)
73
+ ? []
74
+ : [`${where}: expected an object, got ${typeName(body)}`];
75
+ // `array` is a leaf the corpus really records (`properties: 'array'` on a job
76
+ // definition), and `typeof` never yields it: an array is `object`. Without this
77
+ // branch the comparison could never pass, and the message it produced -
78
+ // "expected array, got array" - contradicted itself
79
+ if (shape === 'array')
80
+ return Array.isArray(body)
81
+ ? []
82
+ : [`${where}: expected an array, got ${typeName(body)}`];
83
+ if (Array.isArray(shape)) {
84
+ if (!Array.isArray(body))
85
+ return [`${where}: expected an array, got ${typeName(body)}`];
86
+ const first = body[0];
87
+ // Neither side can say anything when the shape is empty: an empty answer
88
+ // cannot demonstrate its element's shape, and an element shape the capture
89
+ // recorded as `[]` is the absence of one. Comparing a real element against
90
+ // `undefined` invents a drift - "expected undefined, got object" - that no
91
+ // host could act on.
92
+ return first === undefined || shape.length === 0
93
+ ? []
94
+ : (0, exports.shapeMismatches)(shape[0], first, `${where}[0]`);
95
+ }
96
+ if (shape && typeof shape === 'object') {
97
+ if (!isRecord(body))
98
+ return [`${where}: expected an object, got ${typeName(body)}`];
99
+ const record = body;
100
+ return Object.keys(shape).flatMap((key) => key in record
101
+ ? (0, exports.shapeMismatches)(shape[key], record[key], `${where}.${key}`)
102
+ : [`${where}.${key}: missing from the answer`]);
103
+ }
104
+ return typeof body === String(shape)
105
+ ? []
106
+ : [`${where}: expected ${String(shape)}, got ${typeName(body)}`];
107
+ };
108
+ exports.shapeMismatches = shapeMismatches;
109
+ const typeName = (value) => value === null ? 'null' : Array.isArray(value) ? 'array' : typeof value;
110
+ /**
111
+ * An object with named fields, which is what every captured shape describes.
112
+ *
113
+ * An array is `typeof object` in JavaScript, so a body of `[]` would otherwise be
114
+ * compared as an object with no keys and reported as "missing every field" rather
115
+ * than as the array it is.
116
+ */
117
+ const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
@@ -14,9 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.HOME_CORPUS = exports.DIRECTORY_CORPUS = exports.AUTH_CONFIG_CORPUS = exports.ADMIN_CORPUS = exports.INFO_CORPUS = exports.CODE_CORPUS = exports.sanitiseDisplayName = exports.createRecordService = exports.createIdentityService = exports.HANDLED_ROUTES = exports.dispatch = exports.VIYA_CORPUS = exports.VIYA_HANDLERS = exports.VIYA_OVERLAY = exports.findViyaOperation = exports.dispatchViya = exports.emulatedHeaders = exports.VIYA_TARGET_VERSION = exports.VIYA_CAPTURED_AT = exports.EMULATED_HEADER_VALUE = exports.EMULATED_HEADER = exports.UNRECORDED = exports.VIYA_TABLE = exports.SURFACE_CLI_VERSION = exports.SURFACE_ADAPTER_VERSION = exports.SURFACE = exports.TAG_CAPABILITIES = exports.OVERLAY = exports.findRoute = exports.routeById = exports.ROUTES = exports.MemoryDriveStore = exports.measureDeployTree = exports.isDeployTree = exports.deployTree = exports.decodeBase64 = exports.checkDeployTree = exports.DEPLOY_SUCCESS = exports.DEPLOY_PAYLOAD_BYTES = exports.DEPLOY_LIMITS = exports.ONE_NAME_ONLY = exports.DEPLOYMENT_FILE_ERROR = exports.createDeploymentFileService = exports.assertOneFileName = exports.createDriveService = exports.isRoot = exports.basename = exports.dirname = exports.hasBlockedExtension = exports.normaliseDrivePath = void 0;
18
- exports.MemoryAppStreamStore = exports.hasFrontendRoot = exports.frontendFolderOf = exports.defaultAppName = exports.createAppStreamService = exports.checkPublishRequest = exports.appSummary = exports.APP_FOLDERS_ROOT = exports.servicesFor = exports.runCase = exports.PROVIDER_MANAGED = exports.ADMIN_SIGNED_IN = exports.RECORD_CORPUS = exports.RUNTIME_CORPUS = exports.MemorySessionRunner = exports.runTimeOfPath = exports.resolveProgram = exports.programNotFound = exports.DOCUMENTED_RUN_TIMES = exports.createRuntimeService = exports.CODE_DEBUG = exports.MemorySessionHost = exports.DEFAULT_SESSIONS = exports.createSessionService = exports.SESSION_CORPUS = exports.APP_CORPUS = exports.DEPLOY_CORPUS = exports.IDENTITY_CORPUS = exports.DRIVE_CORPUS = exports.parseIdentity = exports.IDENTITY_FORMAT = exports.DEFAULT_IDENTITY = exports.MemoryIdentityStore = exports.createDirectoryService = exports.normaliseLogFiles = exports.normaliseDiagnostics = exports.logLines = exports.createAdminService = exports.checkLogFileName = exports.MAX_LOG_LINES = exports.DEFAULT_LOG_LINES = exports.normaliseAuthConfig = exports.createAuthConfigService = exports.normaliseInfo = exports.createInfoService = exports.BROWSER_INFO = exports.withBundleVersion = exports.createHomeService = exports.NO_WEB_BUILD = exports.BUNDLE_NAME = void 0;
19
- exports.normaliseAppLoc = exports.newAppId = exports.isAppId = exports.escapeHtml = exports.createAppStreamWebService = exports.contentTypeFor = exports.cacheControlFor = exports.appRootOf = exports.NO_SUCH_APP = exports.DEFAULT_APP_PATH = exports.createDriveAppStreamStore = exports.APP_STREAM_INDEX = exports.splitAppBundle = exports.publishRequestFor = exports.parseAppManifest = exports.FRONTEND_FOLDER = exports.BACKEND_FOLDER = exports.APP_MANIFEST = void 0;
17
+ exports.AUTH_CONFIG_CORPUS = exports.ADMIN_CORPUS = exports.INFO_CORPUS = exports.CODE_CORPUS = exports.sanitiseDisplayName = exports.createRecordService = exports.createIdentityService = exports.HANDLED_ROUTES = exports.dispatch = exports.shapeMismatches = exports.requestFor = exports.VIYA_CORPUS = exports.VIYA_HANDLERS = exports.VIYA_OVERLAY = exports.findViyaOperation = exports.dispatchViya = exports.emulatedHeaders = exports.VIYA_TARGET_VERSION = exports.VIYA_CAPTURED_AT = exports.EMULATED_HEADER_VALUE = exports.EMULATED_HEADER = exports.UNRECORDED = exports.VIYA_TABLE = exports.SURFACE_CLI_VERSION = exports.SURFACE_ADAPTER_VERSION = exports.SURFACE = exports.TAG_CAPABILITIES = exports.OVERLAY = exports.findRoute = exports.routeById = exports.ROUTES = exports.MemoryDriveStore = exports.measureDeployTree = exports.isDeployTree = exports.deployTree = exports.decodeBase64 = exports.checkDeployTree = exports.DEPLOY_SUCCESS = exports.DEPLOY_PAYLOAD_BYTES = exports.DEPLOY_LIMITS = exports.ONE_NAME_ONLY = exports.DEPLOYMENT_FILE_ERROR = exports.createDeploymentFileService = exports.assertOneFileName = exports.createDriveService = exports.isRoot = exports.basename = exports.dirname = exports.hasBlockedExtension = exports.normaliseDrivePath = void 0;
18
+ exports.frontendFolderOf = exports.defaultAppName = exports.createAppStreamService = exports.checkPublishRequest = exports.appSummary = exports.APP_FOLDERS_ROOT = exports.servicesFor = exports.runCase = exports.PROVIDER_MANAGED = exports.ADMIN_SIGNED_IN = exports.RECORD_CORPUS = exports.RUNTIME_CORPUS = exports.MemorySessionRunner = exports.runTimeOfPath = exports.resolveProgram = exports.programNotFound = exports.DOCUMENTED_RUN_TIMES = exports.createRuntimeService = exports.CODE_DEBUG = exports.MemorySessionHost = exports.DEFAULT_SESSIONS = exports.createSessionService = exports.SESSION_CORPUS = exports.APP_CORPUS = exports.DEPLOY_CORPUS = exports.IDENTITY_CORPUS = exports.DRIVE_CORPUS = exports.parseIdentity = exports.IDENTITY_FORMAT = exports.DEFAULT_IDENTITY = exports.MemoryIdentityStore = exports.createDirectoryService = exports.normaliseLogFiles = exports.normaliseDiagnostics = exports.logLines = exports.createAdminService = exports.checkLogFileName = exports.MAX_LOG_LINES = exports.DEFAULT_LOG_LINES = exports.normaliseAuthConfig = exports.createAuthConfigService = exports.normaliseInfo = exports.createInfoService = exports.BROWSER_INFO = exports.withBundleVersion = exports.createHomeService = exports.NO_WEB_BUILD = exports.BUNDLE_NAME = exports.HOME_CORPUS = exports.DIRECTORY_CORPUS = void 0;
19
+ exports.normaliseAppLoc = exports.newAppId = exports.isAppId = exports.escapeHtml = exports.createAppStreamWebService = exports.contentTypeFor = exports.cacheControlFor = exports.appRootOf = exports.NO_SUCH_APP = exports.DEFAULT_APP_PATH = exports.createDriveAppStreamStore = exports.APP_STREAM_INDEX = exports.splitAppBundle = exports.publishRequestFor = exports.parseAppManifest = exports.FRONTEND_FOLDER = exports.BACKEND_FOLDER = exports.APP_MANIFEST = exports.MemoryAppStreamStore = exports.hasFrontendRoot = void 0;
20
20
  /**
21
21
  * `@sasjs/api` - the SASjs Server API described once.
22
22
  *
@@ -89,6 +89,9 @@ var service_js_2 = require("./viya/service.js");
89
89
  Object.defineProperty(exports, "VIYA_HANDLERS", { enumerable: true, get: function () { return service_js_2.VIYA_HANDLERS; } });
90
90
  var operations_js_1 = require("./corpus/viya/operations.js");
91
91
  Object.defineProperty(exports, "VIYA_CORPUS", { enumerable: true, get: function () { return operations_js_1.VIYA_CORPUS; } });
92
+ var replay_js_1 = require("./corpus/viya/replay.js");
93
+ Object.defineProperty(exports, "requestFor", { enumerable: true, get: function () { return replay_js_1.requestFor; } });
94
+ Object.defineProperty(exports, "shapeMismatches", { enumerable: true, get: function () { return replay_js_1.shapeMismatches; } });
92
95
  var dispatch_js_2 = require("./host/dispatch.js");
93
96
  Object.defineProperty(exports, "dispatch", { enumerable: true, get: function () { return dispatch_js_2.dispatch; } });
94
97
  Object.defineProperty(exports, "HANDLED_ROUTES", { enumerable: true, get: function () { return dispatch_js_2.HANDLED_ROUTES; } });
@@ -43,6 +43,10 @@ const folderBody = async (drive, path, caller) => {
43
43
  modifiedTimeStamp: ids_js_1.EMULATED_NOW,
44
44
  memberCount: listing.files.length + listing.folders.length,
45
45
  parentFolderUri: `/folders/folders/${(0, ids_js_1.idFor)(parent)}`,
46
+ // the capture's folder shape carries `properties`, and this body is the one a
47
+ // real folder is read through: answering only the recycle bin with it left a
48
+ // client reading `folder.properties` against nothing
49
+ properties: { allowMove: 'true' },
46
50
  links: linksFor(`/folders/folders/${id}`)
47
51
  };
48
52
  };
@@ -128,20 +132,60 @@ exports.VIYA_HANDLERS = {
128
132
  }
129
133
  };
130
134
  },
131
- 'GET /types/types': async () => ({
132
- status: 200,
133
- body: {
134
- count: 1,
135
- items: [
135
+ 'GET /types/types': async ({ request }) => {
136
+ const limit = Number(request.query?.limit ?? 0) || 0;
137
+ // the estate answers a collection envelope, not a bare list: a client reads
138
+ // `accept`, `start` and `version` off this answer, and a body carrying only
139
+ // `count` and `items` is a shape the capture does not have
140
+ const item = {
141
+ name: 'file',
142
+ label: 'File',
143
+ description: 'A file type',
144
+ mediaType: 'application/octet-stream',
145
+ resourceUri: '/types/types/file',
146
+ iconUri: '/types/types/file/icon',
147
+ tags: ['file'],
148
+ version: 1,
149
+ links: [
136
150
  {
137
- name: 'file',
138
- type: 'typeDef',
139
- version: 1,
140
- links: [{ href: '/types/types/file', rel: 'self', method: 'GET' }]
151
+ href: '/types/types/file',
152
+ uri: '/types/types/file',
153
+ rel: 'self',
154
+ method: 'GET',
155
+ type: 'application/vnd.sas.type.definition'
141
156
  }
142
157
  ]
143
- }
144
- }),
158
+ };
159
+ return {
160
+ status: 200,
161
+ body: {
162
+ accept: 'application/json',
163
+ name: 'types',
164
+ start: 0,
165
+ limit,
166
+ count: 1,
167
+ version: 2,
168
+ items: [item],
169
+ links: [
170
+ {
171
+ href: '/types/types',
172
+ uri: '/types/types',
173
+ rel: 'collection',
174
+ method: 'GET',
175
+ type: 'application/vnd.sas.collection',
176
+ itemType: 'typeDef'
177
+ },
178
+ {
179
+ href: '/types/types',
180
+ uri: '/types/types',
181
+ rel: 'self',
182
+ method: 'GET',
183
+ type: 'application/vnd.sas.collection'
184
+ }
185
+ ]
186
+ }
187
+ };
188
+ },
145
189
  'GET /folders/folders/@item': async ({ services, request }) => ({
146
190
  status: 200,
147
191
  body: await folderBody((0, ports_js_1.requireDrive)(services), pathFromQuery(request), (0, ids_js_1.callerId)(request.subject))
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Replaying the Viya corpus against a host.
3
+ *
4
+ * The corpus (`VIYA_CORPUS`) is what the estate answered, as data, and both hosts
5
+ * answer it: the package through its dispatcher and a server over HTTP, and a
6
+ * browser host through its service worker. Keeping the replay here is what makes
7
+ * that one implementation: a host supplies the ids its own answers handed out and
8
+ * the values its own drive can use, and the corpus supplies everything else.
9
+ *
10
+ * What the corpus does NOT carry is the request: it records the answer's shape and
11
+ * the names of the queries the client sent, because those are the contract. A
12
+ * write's body is the caller's data, so a replay of a write is only as honest as
13
+ * the host's own fixture - which is why `requestFor` reports a hole it cannot fill
14
+ * instead of inventing one.
15
+ */
16
+ import type { ViyaCase } from './operations.js';
17
+ /**
18
+ * The identifiers a replay has collected, named by the segment they follow.
19
+ *
20
+ * `/compute/sessions/{}/jobs/{}` reads `sessions` then `jobs`, so the ids are
21
+ * keyed that way rather than by position: a corpus case added later slots in
22
+ * without the keys moving.
23
+ */
24
+ export type ViyaReplayState = Record<string, string | undefined>;
25
+ export interface ViyaReplayRequest {
26
+ method: string;
27
+ /** The path with every hole this replay could fill replaced. */
28
+ path: string;
29
+ /** Holes the state has no id for, as `segment` names - a request not yet answerable. */
30
+ unresolved: string[];
31
+ /** Query names the case records that the caller supplied no value for. */
32
+ omittedQueries: string[];
33
+ }
34
+ /**
35
+ * The request a captured case stands for, with `{}` filled from the ids a replay
36
+ * has collected so far.
37
+ *
38
+ * A hole takes the id named by the segment before it (`/folders/folders/{}` is a
39
+ * folder). A hole the state cannot fill is reported, not guessed: a path built
40
+ * from a placeholder would answer a 404 that says nothing about the contract.
41
+ */
42
+ export declare const requestFor: (viyaCase: ViyaCase, state?: ViyaReplayState, queryValues?: Record<string, string>) => ViyaReplayRequest;
43
+ /**
44
+ * Every place a captured shape and a body disagree, as readable strings.
45
+ *
46
+ * A shape's leaves are type names, so the comparison is on `typeof`; `'object'` is
47
+ * the depth cap and means "an object, contents not recorded". Unlike an
48
+ * assertion, this collects, so a host can report all the drift in one run instead
49
+ * of stopping at the first key - and a body with an element shows its element's
50
+ * shape, because an empty array proves nothing about it.
51
+ */
52
+ export declare const shapeMismatches: (shape: unknown, body: unknown, where?: string) => string[];
53
+ //# sourceMappingURL=replay.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replay.d.ts","sourceRoot":"","sources":["../../../../src/corpus/viya/replay.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAE/C;;;;;;GAMG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAA;AAahE,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAA;IACd,gEAAgE;IAChE,IAAI,EAAE,MAAM,CAAA;IACZ,wFAAwF;IACxF,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,0EAA0E;IAC1E,cAAc,EAAE,MAAM,EAAE,CAAA;CACzB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,GACrB,UAAU,QAAQ,EAClB,QAAO,eAAoB,EAC3B,cAAa,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,KACvC,iBAaF,CAAA;AAkDD;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,GAC1B,OAAO,OAAO,EACd,MAAM,OAAO,EACb,cAAc,KACb,MAAM,EAmDR,CAAA"}
@@ -0,0 +1,112 @@
1
+ /** The segment a hole sits in, which is what names the id it takes. */
2
+ const KEY_BY_SEGMENT = {
3
+ contexts: 'context',
4
+ sessions: 'session',
5
+ jobs: 'job',
6
+ folders: 'folder',
7
+ files: 'file',
8
+ definitions: 'definition',
9
+ variables: 'variable'
10
+ };
11
+ /**
12
+ * The request a captured case stands for, with `{}` filled from the ids a replay
13
+ * has collected so far.
14
+ *
15
+ * A hole takes the id named by the segment before it (`/folders/folders/{}` is a
16
+ * folder). A hole the state cannot fill is reported, not guessed: a path built
17
+ * from a placeholder would answer a 404 that says nothing about the contract.
18
+ */
19
+ export const requestFor = (viyaCase, state = {}, queryValues = {}) => {
20
+ const [method, template] = viyaCase.route.split(' ');
21
+ const unresolved = [];
22
+ return build(method, template.split('/'), viyaCase, state, queryValues, unresolved);
23
+ };
24
+ /** Segments back into the path, filling each hole from the state. */
25
+ const build = (method, segments, viyaCase, state, queryValues, unresolved) => {
26
+ let previousSegment = '';
27
+ const filled = segments.map((segment) => {
28
+ if (segment !== '{}') {
29
+ previousSegment = segment;
30
+ return segment;
31
+ }
32
+ const key = KEY_BY_SEGMENT[previousSegment] ?? previousSegment;
33
+ const id = state[key];
34
+ if (id === undefined) {
35
+ unresolved.push(key);
36
+ return '{}';
37
+ }
38
+ return id;
39
+ });
40
+ let path = filled.join('/');
41
+ const omittedQueries = [];
42
+ const params = [];
43
+ // encoded by hand rather than with `URLSearchParams`: this module is compiled
44
+ // for the browser host as well as for node, and the package's build does not
45
+ // carry the DOM types that class needs
46
+ for (const name of viyaCase.queries) {
47
+ const value = queryValues[name];
48
+ if (value === undefined)
49
+ omittedQueries.push(name);
50
+ else
51
+ params.push(`${encodeURIComponent(name)}=${encodeURIComponent(value)}`);
52
+ }
53
+ if (params.length)
54
+ path += (path.includes('?') ? '&' : '?') + params.join('&');
55
+ return { method, path, unresolved, omittedQueries };
56
+ };
57
+ /**
58
+ * Every place a captured shape and a body disagree, as readable strings.
59
+ *
60
+ * A shape's leaves are type names, so the comparison is on `typeof`; `'object'` is
61
+ * the depth cap and means "an object, contents not recorded". Unlike an
62
+ * assertion, this collects, so a host can report all the drift in one run instead
63
+ * of stopping at the first key - and a body with an element shows its element's
64
+ * shape, because an empty array proves nothing about it.
65
+ */
66
+ export const shapeMismatches = (shape, body, where = 'body') => {
67
+ if (shape === 'object')
68
+ return isRecord(body)
69
+ ? []
70
+ : [`${where}: expected an object, got ${typeName(body)}`];
71
+ // `array` is a leaf the corpus really records (`properties: 'array'` on a job
72
+ // definition), and `typeof` never yields it: an array is `object`. Without this
73
+ // branch the comparison could never pass, and the message it produced -
74
+ // "expected array, got array" - contradicted itself
75
+ if (shape === 'array')
76
+ return Array.isArray(body)
77
+ ? []
78
+ : [`${where}: expected an array, got ${typeName(body)}`];
79
+ if (Array.isArray(shape)) {
80
+ if (!Array.isArray(body))
81
+ return [`${where}: expected an array, got ${typeName(body)}`];
82
+ const first = body[0];
83
+ // Neither side can say anything when the shape is empty: an empty answer
84
+ // cannot demonstrate its element's shape, and an element shape the capture
85
+ // recorded as `[]` is the absence of one. Comparing a real element against
86
+ // `undefined` invents a drift - "expected undefined, got object" - that no
87
+ // host could act on.
88
+ return first === undefined || shape.length === 0
89
+ ? []
90
+ : shapeMismatches(shape[0], first, `${where}[0]`);
91
+ }
92
+ if (shape && typeof shape === 'object') {
93
+ if (!isRecord(body))
94
+ return [`${where}: expected an object, got ${typeName(body)}`];
95
+ const record = body;
96
+ return Object.keys(shape).flatMap((key) => key in record
97
+ ? shapeMismatches(shape[key], record[key], `${where}.${key}`)
98
+ : [`${where}.${key}: missing from the answer`]);
99
+ }
100
+ return typeof body === String(shape)
101
+ ? []
102
+ : [`${where}: expected ${String(shape)}, got ${typeName(body)}`];
103
+ };
104
+ const typeName = (value) => value === null ? 'null' : Array.isArray(value) ? 'array' : typeof value;
105
+ /**
106
+ * An object with named fields, which is what every captured shape describes.
107
+ *
108
+ * An array is `typeof object` in JavaScript, so a body of `[]` would otherwise be
109
+ * compared as an object with no keys and reported as "missing every field" rather
110
+ * than as the array it is.
111
+ */
112
+ const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
@@ -40,6 +40,8 @@ export type { ViyaOverlayEntry } from './viya/overlay.js';
40
40
  export { VIYA_HANDLERS } from './viya/service.js';
41
41
  export { VIYA_CORPUS } from './corpus/viya/operations.js';
42
42
  export type { ViyaCase } from './corpus/viya/operations.js';
43
+ export { requestFor, shapeMismatches } from './corpus/viya/replay.js';
44
+ export type { ViyaReplayRequest, ViyaReplayState } from './corpus/viya/replay.js';
43
45
  export { dispatch, HANDLED_ROUTES } from './host/dispatch.js';
44
46
  export * from './identity/routeAccess.js';
45
47
  export type { ApiRequest, ApiResponse, Services } from './host/dispatch.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,c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AAoB,CAAA;AAC3B,YAAY,EACV,SAAS,EACT,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA"}
@@ -31,6 +31,7 @@ export { dispatchViya, findViyaOperation } from './viya/dispatch.js';
31
31
  export { VIYA_OVERLAY } from './viya/overlay.js';
32
32
  export { VIYA_HANDLERS } from './viya/service.js';
33
33
  export { VIYA_CORPUS } from './corpus/viya/operations.js';
34
+ export { requestFor, shapeMismatches } from './corpus/viya/replay.js';
34
35
  export { dispatch, HANDLED_ROUTES } from './host/dispatch.js';
35
36
  // a host gating its own middleware reads the same decision the inventory reports
36
37
  export * from './identity/routeAccess.js';
@@ -1 +1 @@
1
- {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/viya/service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAChE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AA6InD,gEAAgE;AAChE,eAAO,MAAM,aAAa,EAAE,MAAM,CAChC,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,CAwP3B,CAAA"}
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/viya/service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAChE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAiJnD,gEAAgE;AAChE,eAAO,MAAM,aAAa,EAAE,MAAM,CAChC,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,CAkS3B,CAAA"}
@@ -40,6 +40,10 @@ const folderBody = async (drive, path, caller) => {
40
40
  modifiedTimeStamp: EMULATED_NOW,
41
41
  memberCount: listing.files.length + listing.folders.length,
42
42
  parentFolderUri: `/folders/folders/${idFor(parent)}`,
43
+ // the capture's folder shape carries `properties`, and this body is the one a
44
+ // real folder is read through: answering only the recycle bin with it left a
45
+ // client reading `folder.properties` against nothing
46
+ properties: { allowMove: 'true' },
43
47
  links: linksFor(`/folders/folders/${id}`)
44
48
  };
45
49
  };
@@ -125,20 +129,60 @@ export const VIYA_HANDLERS = {
125
129
  }
126
130
  };
127
131
  },
128
- 'GET /types/types': async () => ({
129
- status: 200,
130
- body: {
131
- count: 1,
132
- items: [
132
+ 'GET /types/types': async ({ request }) => {
133
+ const limit = Number(request.query?.limit ?? 0) || 0;
134
+ // the estate answers a collection envelope, not a bare list: a client reads
135
+ // `accept`, `start` and `version` off this answer, and a body carrying only
136
+ // `count` and `items` is a shape the capture does not have
137
+ const item = {
138
+ name: 'file',
139
+ label: 'File',
140
+ description: 'A file type',
141
+ mediaType: 'application/octet-stream',
142
+ resourceUri: '/types/types/file',
143
+ iconUri: '/types/types/file/icon',
144
+ tags: ['file'],
145
+ version: 1,
146
+ links: [
133
147
  {
134
- name: 'file',
135
- type: 'typeDef',
136
- version: 1,
137
- links: [{ href: '/types/types/file', rel: 'self', method: 'GET' }]
148
+ href: '/types/types/file',
149
+ uri: '/types/types/file',
150
+ rel: 'self',
151
+ method: 'GET',
152
+ type: 'application/vnd.sas.type.definition'
138
153
  }
139
154
  ]
140
- }
141
- }),
155
+ };
156
+ return {
157
+ status: 200,
158
+ body: {
159
+ accept: 'application/json',
160
+ name: 'types',
161
+ start: 0,
162
+ limit,
163
+ count: 1,
164
+ version: 2,
165
+ items: [item],
166
+ links: [
167
+ {
168
+ href: '/types/types',
169
+ uri: '/types/types',
170
+ rel: 'collection',
171
+ method: 'GET',
172
+ type: 'application/vnd.sas.collection',
173
+ itemType: 'typeDef'
174
+ },
175
+ {
176
+ href: '/types/types',
177
+ uri: '/types/types',
178
+ rel: 'self',
179
+ method: 'GET',
180
+ type: 'application/vnd.sas.collection'
181
+ }
182
+ ]
183
+ }
184
+ };
185
+ },
142
186
  'GET /folders/folders/@item': async ({ services, request }) => ({
143
187
  status: 200,
144
188
  body: await folderBody(requireDrive(services), pathFromQuery(request), callerId(request.subject))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sasjs/api",
3
- "version": "0.48.1",
3
+ "version": "0.49.0",
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",