@sasjs/api 0.44.1 → 0.44.3

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.44.1 - the SASjs Server API, for a service worker. https://github.com/sasjs/api */
1
+ /* @sasjs/api 0.44.3 - 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;
@@ -1567,6 +1567,12 @@ var SASjsApi = (() => {
1567
1567
  in: "body",
1568
1568
  required: false,
1569
1569
  type: "string"
1570
+ },
1571
+ {
1572
+ name: "layout",
1573
+ in: "body",
1574
+ required: false,
1575
+ type: "boolean"
1570
1576
  }
1571
1577
  ],
1572
1578
  requestBodies: ["application/json"],
@@ -5178,7 +5184,7 @@ var SASjsApi = (() => {
5178
5184
  };
5179
5185
 
5180
5186
  // src/viya/compute.ts
5181
- var DEFAULT_CONTEXT_NAME = "Emulated Compute Context";
5187
+ var DEFAULT_CONTEXT_NAME = "SAS Job Execution compute context";
5182
5188
  var EMULATED_CONTEXT_ID = idFor("emulated-context", "context");
5183
5189
  var relLinks = (type, rels) => rels.map(([rel, href]) => ({ href, uri: href, rel, method: "GET", type }));
5184
5190
  var linksFor = (uri, type, collection = false, itemType = false) => [
@@ -5588,7 +5594,7 @@ var SASjsApi = (() => {
5588
5594
  const drive = requireDrive(services);
5589
5595
  const path = await pathForFileId(drive, params.id);
5590
5596
  const body = request.body;
5591
- const contents = request.file?.contents ?? (typeof body === "string" ? body : body?.contents);
5597
+ const contents = request.contents ?? request.file?.contents ?? (typeof body === "string" || body instanceof Uint8Array ? body : body?.contents);
5592
5598
  if (contents === void 0 || contents === null)
5593
5599
  throw new ApiError(400, "File content is required.");
5594
5600
  await drive.update(path, contents);
@@ -5769,7 +5775,7 @@ var SASjsApi = (() => {
5769
5775
  creationTimeStamp: EMULATED_NOW,
5770
5776
  modifiedTimeStamp: EMULATED_NOW,
5771
5777
  parentFolderUri: `/folders/folders/${idFor(path)}`,
5772
- uri: `${path}/${name}`.replace(/\/{2,}/g, "/"),
5778
+ uri: `/folders/folders/${idFor(`${path}/${name}`.replace(/\/{2,}/g, "/"))}`,
5773
5779
  links: linksFor2(
5774
5780
  `/folders/folders/${idFor(`${path}/${name}`.replace(/\/{2,}/g, "/"))}`
5775
5781
  )
@@ -5786,7 +5792,7 @@ var SASjsApi = (() => {
5786
5792
  modifiedTimeStamp: EMULATED_NOW,
5787
5793
  parentFolderUri: `/folders/folders/${idFor(path)}`,
5788
5794
  added: EMULATED_NOW,
5789
- uri: `${path}/${name}`.replace(/\/{2,}/g, "/"),
5795
+ uri: `/files/files/${idFor(`${path}/${name}`.replace(/\/{2,}/g, "/"), "file")}`,
5790
5796
  links: linksFor2(
5791
5797
  `/files/files/${idFor(`${path}/${name}`.replace(/\/{2,}/g, "/"), "file")}`
5792
5798
  )
@@ -6784,6 +6790,12 @@ var SASjsApi = (() => {
6784
6790
  }
6785
6791
  };
6786
6792
  var APP_ENTRY_FILE = "index.html";
6793
+ var flagOf = (value) => {
6794
+ if (typeof value === "boolean") return value;
6795
+ if (value === "true") return true;
6796
+ if (value === "false") return false;
6797
+ return void 0;
6798
+ };
6787
6799
  var APP_NOT_REGISTERED = "No App Stream is registered with that id.";
6788
6800
  var appNotRegistered = () => new ApiError(404, APP_NOT_REGISTERED, {
6789
6801
  status: "failure",
@@ -7402,7 +7414,10 @@ var SASjsApi = (() => {
7402
7414
  status: 200,
7403
7415
  body: await code.format(await caller(), {
7404
7416
  code: body.code,
7405
- filePath: body.filePath
7417
+ filePath: body.filePath,
7418
+ // the body is rebuilt field by field here, so a flag the service reads
7419
+ // has to be named or the request's own answer is lost on the way
7420
+ layout: flagOf(body.layout)
7406
7421
  })
7407
7422
  };
7408
7423
  case "GET /SASjsApi/info/authorizedRoutes":
@@ -50,8 +50,12 @@ const createCodeService = (options = {}) => {
50
50
  },
51
51
  async format(caller, body) {
52
52
  requireCaller(caller);
53
+ // A caller that asked for the rules alone gets them alone. The flag is read
54
+ // here and not left to a host: a browser host always has its engine to hand,
55
+ // so a request that could not turn it off would be laid out anyway - which is
56
+ // two buttons in the Studio doing one job.
53
57
  return (0, lint_1.formatText)(codeOf(body), await configFor(body.filePath), {
54
- reprint: options.reprint
58
+ reprint: body.layout === false ? undefined : options.reprint
55
59
  });
56
60
  }
57
61
  };
@@ -105,6 +105,27 @@ const validate = (route, request) => {
105
105
  };
106
106
  /** The file an app is served from for a directory request, as the surface serves it. */
107
107
  const APP_ENTRY_FILE = 'index.html';
108
+ /**
109
+ * A body field the document states as a boolean, read the way the server reads it.
110
+ *
111
+ * The server validates this one with `Joi.boolean()`, which converts the two
112
+ * strings `'true'` and `'false'` as well as real booleans, and refuses anything
113
+ * else. There is no schema in this package to run, so the two spellings a caller
114
+ * might mean are read here: a client that sent the string `"false"` and had its
115
+ * buffer laid out anyway would find two hosts disagreeing about which button it
116
+ * pressed. Anything else is left undefined, which is the field's default rather
117
+ * than a refusal - the Studio's own client sends a boolean, so this is the
118
+ * boundary making sense of a caller the package did not write.
119
+ */
120
+ const flagOf = (value) => {
121
+ if (typeof value === 'boolean')
122
+ return value;
123
+ if (value === 'true')
124
+ return true;
125
+ if (value === 'false')
126
+ return false;
127
+ return undefined;
128
+ };
108
129
  /**
109
130
  * An app the index does not hold, in the wording the route answers with.
110
131
  *
@@ -769,7 +790,10 @@ const dispatch = async (services, routeId, request = {}) => {
769
790
  status: 200,
770
791
  body: await code.format(await caller(), {
771
792
  code: body.code,
772
- filePath: body.filePath
793
+ filePath: body.filePath,
794
+ // the body is rebuilt field by field here, so a flag the service reads
795
+ // has to be named or the request's own answer is lost on the way
796
+ layout: flagOf(body.layout)
773
797
  })
774
798
  };
775
799
  case 'GET /SASjsApi/info/authorizedRoutes':
@@ -438,6 +438,12 @@ exports.GENERATED_ROUTES = [
438
438
  in: 'body',
439
439
  required: false,
440
440
  type: 'string'
441
+ },
442
+ {
443
+ name: 'layout',
444
+ in: 'body',
445
+ required: false,
446
+ type: 'boolean'
441
447
  }
442
448
  ],
443
449
  requestBodies: ['application/json'],
@@ -6,8 +6,17 @@ const seed_js_1 = require("./seed.js");
6
6
  const seed_js_2 = require("./seed.js");
7
7
  const sessions_js_1 = require("./sessions.js");
8
8
  const ids_js_1 = require("./ids.js");
9
- /** The name the emulator answers when a client asks for no particular context. */
10
- exports.DEFAULT_CONTEXT_NAME = 'Emulated Compute Context';
9
+ /**
10
+ * The name the emulator answers when a client asks for no particular context.
11
+ *
12
+ * It is the name of the context a Viya estate ships with, because that is the
13
+ * name a client carries: `SASViyaApiClient.createSession` lists `/compute/contexts`
14
+ * with no filter and picks the entry whose name it was given, so a default of the
15
+ * emulator's own choosing fails every caller with a name that is right everywhere
16
+ * else. A client may still name any context it likes - see `contextNameFrom` - and
17
+ * the estate answers under that name.
18
+ */
19
+ exports.DEFAULT_CONTEXT_NAME = 'SAS Job Execution compute context';
11
20
  /** The one context id this estate mints, whatever name it is asked for. */
12
21
  exports.EMULATED_CONTEXT_ID = (0, ids_js_1.idFor)('emulated-context', 'context');
13
22
  /**
@@ -185,10 +185,14 @@ exports.FILE_HANDLERS = {
185
185
  'PUT /files/files/{}/content': async ({ services, params, request }) => {
186
186
  const drive = (0, ports_js_1.requireDrive)(services);
187
187
  const path = await pathForFileId(drive, params.id);
188
- // a host may hand the bytes over as the multipart part or as the body
188
+ // a host may hand the bytes over as the multipart part, as the raw body (a
189
+ // file PUT carries the content, with the file's own content type), or as a
190
+ // JSON body carrying `contents`. Raw content is bytes as often as it is text -
191
+ // an upload is not required to be UTF-8 - so both are accepted here.
189
192
  const body = request.body;
190
- const contents = request.file?.contents ??
191
- (typeof body === 'string'
193
+ const contents = request.contents ??
194
+ request.file?.contents ??
195
+ (typeof body === 'string' || body instanceof Uint8Array
192
196
  ? body
193
197
  : body?.contents);
194
198
  if (contents === undefined || contents === null)
@@ -183,6 +183,15 @@ exports.VIYA_HANDLERS = {
183
183
  };
184
184
  const path = await pathForId(drive, params.id);
185
185
  const listing = await drive.list(path);
186
+ /**
187
+ * A member's `uri` is the resource, not its path.
188
+ *
189
+ * `@sasjs/adapter`'s `getFileUri` reads `member.uri` and fetches
190
+ * `${uri}/content`, so a path here sends the client to
191
+ * `/someFolder/some.txt/content`, which is not a route any host has. The
192
+ * value also has to agree with the `self` link in the same entry: two
193
+ * spellings of one member is a client choosing between them.
194
+ */
186
195
  const items = [
187
196
  ...listing.folders.map((name) => ({
188
197
  id: (0, ids_js_1.idFor)(`${path}/${name}`.replace(/\/{2,}/g, '/')),
@@ -194,7 +203,7 @@ exports.VIYA_HANDLERS = {
194
203
  creationTimeStamp: ids_js_1.EMULATED_NOW,
195
204
  modifiedTimeStamp: ids_js_1.EMULATED_NOW,
196
205
  parentFolderUri: `/folders/folders/${(0, ids_js_1.idFor)(path)}`,
197
- uri: `${path}/${name}`.replace(/\/{2,}/g, '/'),
206
+ uri: `/folders/folders/${(0, ids_js_1.idFor)(`${path}/${name}`.replace(/\/{2,}/g, '/'))}`,
198
207
  links: linksFor(`/folders/folders/${(0, ids_js_1.idFor)(`${path}/${name}`.replace(/\/{2,}/g, '/'))}`)
199
208
  })),
200
209
  ...listing.files.map((name) => ({
@@ -209,7 +218,7 @@ exports.VIYA_HANDLERS = {
209
218
  modifiedTimeStamp: ids_js_1.EMULATED_NOW,
210
219
  parentFolderUri: `/folders/folders/${(0, ids_js_1.idFor)(path)}`,
211
220
  added: ids_js_1.EMULATED_NOW,
212
- uri: `${path}/${name}`.replace(/\/{2,}/g, '/'),
221
+ uri: `/files/files/${(0, ids_js_1.idFor)(`${path}/${name}`.replace(/\/{2,}/g, '/'), 'file')}`,
213
222
  links: linksFor(`/files/files/${(0, ids_js_1.idFor)(`${path}/${name}`.replace(/\/{2,}/g, '/'), 'file')}`)
214
223
  }))
215
224
  ];
@@ -5,6 +5,17 @@ export interface CodeRequest {
5
5
  code: string;
6
6
  /** The drive path the code belongs to, so a host can pick that folder's rules. */
7
7
  filePath?: string;
8
+ /**
9
+ * Whether the format route runs the host's layout engine as well as the rules.
10
+ * Defaults to true, which is what "format" means.
11
+ *
12
+ * `false` is the editor's "fix lint issues": the rules are the changes that can
13
+ * be made without judgement - trailing spaces, tabs, line endings, the header's
14
+ * macro list, the wrapping a long line gets - and an author who asks for those
15
+ * does not want the engine's statement breaks and indentation rewritten at the
16
+ * same time. The answer is still the rewritten buffer, header and all.
17
+ */
18
+ layout?: boolean;
8
19
  }
9
20
  export interface CodeServiceOptions {
10
21
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/code/service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAGxE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAEnD,uFAAuF;AACvF,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,kFAAkF;IAClF,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,OAAO,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,CAAA;IAClC;;;;;;;;;;;;;OAaG;IACH,UAAU,CAAC,EAAE,CACX,QAAQ,CAAC,EAAE,MAAM,KACd,UAAU,GAAG,SAAS,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAAA;CAC9D;AAED,MAAM,WAAW,WAAW;IAC1B,gFAAgF;IAChF,IAAI,CAAC,MAAM,EAAE,OAAO,GAAG,SAAS,EAAE,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAAA;IAC3E,4BAA4B;IAC5B,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,SAAS,EAAE,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;CACxE;AAmBD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,iBAAiB,GAC5B,UAAS,kBAAuB,KAC/B,WAuBF,CAAA"}
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/code/service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAGxE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAEnD,uFAAuF;AACvF,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,kFAAkF;IAClF,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;;;;;;;;OASG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB;AAED,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,OAAO,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,CAAA;IAClC;;;;;;;;;;;;;OAaG;IACH,UAAU,CAAC,EAAE,CACX,QAAQ,CAAC,EAAE,MAAM,KACd,UAAU,GAAG,SAAS,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAAA;CAC9D;AAED,MAAM,WAAW,WAAW;IAC1B,gFAAgF;IAChF,IAAI,CAAC,MAAM,EAAE,OAAO,GAAG,SAAS,EAAE,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAAA;IAC3E,4BAA4B;IAC5B,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,SAAS,EAAE,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;CACxE;AAmBD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,iBAAiB,GAC5B,UAAS,kBAAuB,KAC/B,WA2BF,CAAA"}
@@ -47,8 +47,12 @@ export const createCodeService = (options = {}) => {
47
47
  },
48
48
  async format(caller, body) {
49
49
  requireCaller(caller);
50
+ // A caller that asked for the rules alone gets them alone. The flag is read
51
+ // here and not left to a host: a browser host always has its engine to hand,
52
+ // so a request that could not turn it off would be laid out anyway - which is
53
+ // two buttons in the Studio doing one job.
50
54
  return formatText(codeOf(body), await configFor(body.filePath), {
51
- reprint: options.reprint
55
+ reprint: body.layout === false ? undefined : options.reprint
52
56
  });
53
57
  }
54
58
  };
@@ -23,6 +23,12 @@ export interface ApiRequest {
23
23
  * states them.
24
24
  */
25
25
  params?: Record<string, string>;
26
+ /**
27
+ * The raw request body, for the routes that take the body as content rather
28
+ * than as JSON - a file PUT, whose bytes carry the file's own content type and
29
+ * which no JSON parser reads. It mirrors `ApiResponse.contents`.
30
+ */
31
+ contents?: string | Uint8Array;
26
32
  /** The multipart payload: the API names it `file` on every route that takes one. */
27
33
  file?: {
28
34
  name: string;
@@ -1 +1 @@
1
- {"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../../../src/host/dispatch.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AASvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AACjE,OAAO,KAAK,EAAE,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eAAO,MAAM,QAAQ,GACnB,UAAU,QAAQ,EAClB,SAAS,MAAM,EACf,UAAS,UAAe,KACvB,OAAO,CAAC,WAAW,CAi/BrB,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,SAAS,GAAI,SAAS,MAAM,KAAG,QAO3C,CAAA;AAED,0DAA0D;AAC1D,eAAO,MAAM,cAAc,EAAE,MAAM,EA+DlC,CAAA"}
@@ -102,6 +102,27 @@ const validate = (route, request) => {
102
102
  };
103
103
  /** The file an app is served from for a directory request, as the surface serves it. */
104
104
  const APP_ENTRY_FILE = 'index.html';
105
+ /**
106
+ * A body field the document states as a boolean, read the way the server reads it.
107
+ *
108
+ * The server validates this one with `Joi.boolean()`, which converts the two
109
+ * strings `'true'` and `'false'` as well as real booleans, and refuses anything
110
+ * else. There is no schema in this package to run, so the two spellings a caller
111
+ * might mean are read here: a client that sent the string `"false"` and had its
112
+ * buffer laid out anyway would find two hosts disagreeing about which button it
113
+ * pressed. Anything else is left undefined, which is the field's default rather
114
+ * than a refusal - the Studio's own client sends a boolean, so this is the
115
+ * boundary making sense of a caller the package did not write.
116
+ */
117
+ const flagOf = (value) => {
118
+ if (typeof value === 'boolean')
119
+ return value;
120
+ if (value === 'true')
121
+ return true;
122
+ if (value === 'false')
123
+ return false;
124
+ return undefined;
125
+ };
105
126
  /**
106
127
  * An app the index does not hold, in the wording the route answers with.
107
128
  *
@@ -766,7 +787,10 @@ export const dispatch = async (services, routeId, request = {}) => {
766
787
  status: 200,
767
788
  body: await code.format(await caller(), {
768
789
  code: body.code,
769
- filePath: body.filePath
790
+ filePath: body.filePath,
791
+ // the body is rebuilt field by field here, so a flag the service reads
792
+ // has to be named or the request's own answer is lost on the way
793
+ layout: flagOf(body.layout)
770
794
  })
771
795
  };
772
796
  case 'GET /SASjsApi/info/authorizedRoutes':
@@ -1 +1 @@
1
- {"version":3,"file":"generated.d.ts","sourceRoot":"","sources":["../../../src/routes/generated.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEjD,eAAO,MAAM,gBAAgB,EAAE,cAAc,EA0qE5C,CAAA"}
1
+ {"version":3,"file":"generated.d.ts","sourceRoot":"","sources":["../../../src/routes/generated.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEjD,eAAO,MAAM,gBAAgB,EAAE,cAAc,EAgrE5C,CAAA"}
@@ -435,6 +435,12 @@ export const GENERATED_ROUTES = [
435
435
  in: 'body',
436
436
  required: false,
437
437
  type: 'string'
438
+ },
439
+ {
440
+ name: 'layout',
441
+ in: 'body',
442
+ required: false,
443
+ type: 'boolean'
438
444
  }
439
445
  ],
440
446
  requestBodies: ['application/json'],
@@ -13,8 +13,17 @@
13
13
  * name, so a session can be created for the id the list returned.
14
14
  */
15
15
  import type { ApiResponse, Services } from '../host/dispatch.js';
16
- /** The name the emulator answers when a client asks for no particular context. */
17
- export declare const DEFAULT_CONTEXT_NAME = "Emulated Compute Context";
16
+ /**
17
+ * The name the emulator answers when a client asks for no particular context.
18
+ *
19
+ * It is the name of the context a Viya estate ships with, because that is the
20
+ * name a client carries: `SASViyaApiClient.createSession` lists `/compute/contexts`
21
+ * with no filter and picks the entry whose name it was given, so a default of the
22
+ * emulator's own choosing fails every caller with a name that is right everywhere
23
+ * else. A client may still name any context it likes - see `contextNameFrom` - and
24
+ * the estate answers under that name.
25
+ */
26
+ export declare const DEFAULT_CONTEXT_NAME = "SAS Job Execution compute context";
18
27
  /** The one context id this estate mints, whatever name it is asked for. */
19
28
  export declare const EMULATED_CONTEXT_ID: string;
20
29
  /**
@@ -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,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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,CAmM3B,CAAA"}
@@ -3,8 +3,17 @@ import { normaliseServerUrl } from './seed.js';
3
3
  import { seedOf } from './seed.js';
4
4
  import { estateFor } from './sessions.js';
5
5
  import { EMULATED_USER, idFor } from './ids.js';
6
- /** The name the emulator answers when a client asks for no particular context. */
7
- export const DEFAULT_CONTEXT_NAME = 'Emulated Compute Context';
6
+ /**
7
+ * The name the emulator answers when a client asks for no particular context.
8
+ *
9
+ * It is the name of the context a Viya estate ships with, because that is the
10
+ * name a client carries: `SASViyaApiClient.createSession` lists `/compute/contexts`
11
+ * with no filter and picks the entry whose name it was given, so a default of the
12
+ * emulator's own choosing fails every caller with a name that is right everywhere
13
+ * else. A client may still name any context it likes - see `contextNameFrom` - and
14
+ * the estate answers under that name.
15
+ */
16
+ export const DEFAULT_CONTEXT_NAME = 'SAS Job Execution compute context';
8
17
  /** The one context id this estate mints, whatever name it is asked for. */
9
18
  export const EMULATED_CONTEXT_ID = idFor('emulated-context', 'context');
10
19
  /**
@@ -21,6 +21,7 @@ export declare const FILE_HANDLERS: Record<string, (context: {
21
21
  request: {
22
22
  query?: Record<string, string | undefined>;
23
23
  body?: unknown;
24
+ contents?: string | Uint8Array;
24
25
  file?: {
25
26
  name: string;
26
27
  contents: string | Uint8Array;
@@ -1 +1 @@
1
- {"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../../src/viya/files.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAOhE,sEAAsE;AACtE,MAAM,WAAW,YAAY;IAC3B,IAA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;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,CAAA;SAAE,CAAA;QACtD,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,CAiF3B,CAAA"}
@@ -182,10 +182,14 @@ export const FILE_HANDLERS = {
182
182
  'PUT /files/files/{}/content': async ({ services, params, request }) => {
183
183
  const drive = requireDrive(services);
184
184
  const path = await pathForFileId(drive, params.id);
185
- // a host may hand the bytes over as the multipart part or as the body
185
+ // a host may hand the bytes over as the multipart part, as the raw body (a
186
+ // file PUT carries the content, with the file's own content type), or as a
187
+ // JSON body carrying `contents`. Raw content is bytes as often as it is text -
188
+ // an upload is not required to be UTF-8 - so both are accepted here.
186
189
  const body = request.body;
187
- const contents = request.file?.contents ??
188
- (typeof body === 'string'
190
+ const contents = request.contents ??
191
+ request.file?.contents ??
192
+ (typeof body === 'string' || body instanceof Uint8Array
189
193
  ? body
190
194
  : body?.contents);
191
195
  if (contents === undefined || contents === null)
@@ -1 +1 @@
1
- {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/viya/service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAmIhE,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,CAgO3B,CAAA"}
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/viya/service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAmIhE,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,CAyO3B,CAAA"}
@@ -180,6 +180,15 @@ export const VIYA_HANDLERS = {
180
180
  };
181
181
  const path = await pathForId(drive, params.id);
182
182
  const listing = await drive.list(path);
183
+ /**
184
+ * A member's `uri` is the resource, not its path.
185
+ *
186
+ * `@sasjs/adapter`'s `getFileUri` reads `member.uri` and fetches
187
+ * `${uri}/content`, so a path here sends the client to
188
+ * `/someFolder/some.txt/content`, which is not a route any host has. The
189
+ * value also has to agree with the `self` link in the same entry: two
190
+ * spellings of one member is a client choosing between them.
191
+ */
183
192
  const items = [
184
193
  ...listing.folders.map((name) => ({
185
194
  id: idFor(`${path}/${name}`.replace(/\/{2,}/g, '/')),
@@ -191,7 +200,7 @@ export const VIYA_HANDLERS = {
191
200
  creationTimeStamp: EMULATED_NOW,
192
201
  modifiedTimeStamp: EMULATED_NOW,
193
202
  parentFolderUri: `/folders/folders/${idFor(path)}`,
194
- uri: `${path}/${name}`.replace(/\/{2,}/g, '/'),
203
+ uri: `/folders/folders/${idFor(`${path}/${name}`.replace(/\/{2,}/g, '/'))}`,
195
204
  links: linksFor(`/folders/folders/${idFor(`${path}/${name}`.replace(/\/{2,}/g, '/'))}`)
196
205
  })),
197
206
  ...listing.files.map((name) => ({
@@ -206,7 +215,7 @@ export const VIYA_HANDLERS = {
206
215
  modifiedTimeStamp: EMULATED_NOW,
207
216
  parentFolderUri: `/folders/folders/${idFor(path)}`,
208
217
  added: EMULATED_NOW,
209
- uri: `${path}/${name}`.replace(/\/{2,}/g, '/'),
218
+ uri: `/files/files/${idFor(`${path}/${name}`.replace(/\/{2,}/g, '/'), 'file')}`,
210
219
  links: linksFor(`/files/files/${idFor(`${path}/${name}`.replace(/\/{2,}/g, '/'), 'file')}`)
211
220
  }))
212
221
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sasjs/api",
3
- "version": "0.44.1",
3
+ "version": "0.44.3",
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",
@@ -48,6 +48,7 @@
48
48
  "sync:viya": "node scripts/viya-generate.mjs",
49
49
  "check:viya": "node scripts/viya-generate.mjs --check",
50
50
  "check:builds": "node scripts/check-builds.mjs",
51
+ "check:package": "node scripts/check-package.mjs",
51
52
  "audit:gate": "node scripts/audit.mjs",
52
53
  "check:appstream": "node scripts/appstream-browser-check.cjs",
53
54
  "conformance": "node tools/viya-conformance/conformance.mjs",