@sasjs/api 0.44.2 → 0.44.4

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.2 - the SASjs Server API, for a service worker. https://github.com/sasjs/api */
1
+ /* @sasjs/api 0.44.4 - 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"],
@@ -6784,6 +6790,16 @@ var SASjsApi = (() => {
6784
6790
  }
6785
6791
  };
6786
6792
  var APP_ENTRY_FILE = "index.html";
6793
+ var layoutOf = (value) => {
6794
+ if (value === void 0) return void 0;
6795
+ if (typeof value === "boolean") return value;
6796
+ if (typeof value === "string") {
6797
+ const text2 = value.trim().toLowerCase();
6798
+ if (text2 === "true") return true;
6799
+ if (text2 === "false") return false;
6800
+ }
6801
+ throw new ApiError(400, '"layout" must be a boolean.');
6802
+ };
6787
6803
  var APP_NOT_REGISTERED = "No App Stream is registered with that id.";
6788
6804
  var appNotRegistered = () => new ApiError(404, APP_NOT_REGISTERED, {
6789
6805
  status: "failure",
@@ -7402,7 +7418,10 @@ var SASjsApi = (() => {
7402
7418
  status: 200,
7403
7419
  body: await code.format(await caller(), {
7404
7420
  code: body.code,
7405
- filePath: body.filePath
7421
+ filePath: body.filePath,
7422
+ // the body is rebuilt field by field here, so a flag the service reads
7423
+ // has to be named or the request's own answer is lost on the way
7424
+ layout: layoutOf(body.layout)
7406
7425
  })
7407
7426
  };
7408
7427
  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,39 @@ 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 real booleans
112
+ * and the string spellings of them - case-insensitively, and trimmed, as Joi 18
113
+ * does - and refuses every other shape. Both halves are reproduced here: a client
114
+ * that sent the string `"false"` and had its buffer laid out anyway would find two
115
+ * hosts disagreeing about which button it pressed.
116
+ *
117
+ * The conversion is limited to strings on purpose. `String(value)` would also read
118
+ * shapes the schema refuses - a one-element array `["true"]` stringifies to
119
+ * `'true'` - so a non-string, non-boolean value is not looked at, it is refused.
120
+ *
121
+ * A value that cannot be read is refused rather than guessed at, with the answer an
122
+ * installation gives it: `"yes"` is a caller's bug, and reading it as the default
123
+ * leaves that bug unanswered. `replaceOf` refuses its own boolean field for the
124
+ * same reason, though not by the same rules - an empty string there means the query
125
+ * parameter was not stated, and for this body field the schema refuses it.
126
+ */
127
+ const layoutOf = (value) => {
128
+ if (value === undefined)
129
+ return undefined;
130
+ if (typeof value === 'boolean')
131
+ return value;
132
+ if (typeof value === 'string') {
133
+ const text = value.trim().toLowerCase();
134
+ if (text === 'true')
135
+ return true;
136
+ if (text === 'false')
137
+ return false;
138
+ }
139
+ throw new types_js_1.ApiError(400, '"layout" must be a boolean.');
140
+ };
108
141
  /**
109
142
  * An app the index does not hold, in the wording the route answers with.
110
143
  *
@@ -769,7 +802,10 @@ const dispatch = async (services, routeId, request = {}) => {
769
802
  status: 200,
770
803
  body: await code.format(await caller(), {
771
804
  code: body.code,
772
- filePath: body.filePath
805
+ filePath: body.filePath,
806
+ // the body is rebuilt field by field here, so a flag the service reads
807
+ // has to be named or the request's own answer is lost on the way
808
+ layout: layoutOf(body.layout)
773
809
  })
774
810
  };
775
811
  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'],
@@ -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;CACl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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
  };
@@ -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,C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AC1B;;;;OAIG;IACH,OAAO,CAAC,EAAE,aAAa,CAAA;IACvB;;;OAGG;IACH,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,gBAAgB,CAAA;IACvB;;;OAGG;IACH,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB;;;;OAIG;IACH,SAAS,CAAC,EAAE,gBAAgB,CAAA;IAC5B;;;;OAIG;IACH,cAAc,CAAC,EAAE,qBAAqB,CAAA;CACvC;AAoHD,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,39 @@ 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 real booleans
109
+ * and the string spellings of them - case-insensitively, and trimmed, as Joi 18
110
+ * does - and refuses every other shape. Both halves are reproduced here: a client
111
+ * that sent the string `"false"` and had its buffer laid out anyway would find two
112
+ * hosts disagreeing about which button it pressed.
113
+ *
114
+ * The conversion is limited to strings on purpose. `String(value)` would also read
115
+ * shapes the schema refuses - a one-element array `["true"]` stringifies to
116
+ * `'true'` - so a non-string, non-boolean value is not looked at, it is refused.
117
+ *
118
+ * A value that cannot be read is refused rather than guessed at, with the answer an
119
+ * installation gives it: `"yes"` is a caller's bug, and reading it as the default
120
+ * leaves that bug unanswered. `replaceOf` refuses its own boolean field for the
121
+ * same reason, though not by the same rules - an empty string there means the query
122
+ * parameter was not stated, and for this body field the schema refuses it.
123
+ */
124
+ const layoutOf = (value) => {
125
+ if (value === undefined)
126
+ return undefined;
127
+ if (typeof value === 'boolean')
128
+ return value;
129
+ if (typeof value === 'string') {
130
+ const text = value.trim().toLowerCase();
131
+ if (text === 'true')
132
+ return true;
133
+ if (text === 'false')
134
+ return false;
135
+ }
136
+ throw new ApiError(400, '"layout" must be a boolean.');
137
+ };
105
138
  /**
106
139
  * An app the index does not hold, in the wording the route answers with.
107
140
  *
@@ -766,7 +799,10 @@ export const dispatch = async (services, routeId, request = {}) => {
766
799
  status: 200,
767
800
  body: await code.format(await caller(), {
768
801
  code: body.code,
769
- filePath: body.filePath
802
+ filePath: body.filePath,
803
+ // the body is rebuilt field by field here, so a flag the service reads
804
+ // has to be named or the request's own answer is lost on the way
805
+ layout: layoutOf(body.layout)
770
806
  })
771
807
  };
772
808
  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'],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sasjs/api",
3
- "version": "0.44.2",
3
+ "version": "0.44.4",
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",