@sasjs/api 0.18.0 → 0.18.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/build/browser.js CHANGED
@@ -1,4 +1,4 @@
1
- /* @sasjs/api 0.18.0 - the SASjs Server API, for a service worker. https://github.com/sasjs/api */
1
+ /* @sasjs/api 0.18.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;
@@ -4073,6 +4073,8 @@ var SASjsApi = (() => {
4073
4073
  "version"
4074
4074
  ];
4075
4075
  var REQUIRED_FIELDS = FIELDS.filter((field) => field !== "oidcProviderName");
4076
+ var MODES = ["server", "desktop"];
4077
+ var CORS_VALUES = ["enable", "disable"];
4076
4078
  var isNonEmptyString = (value) => typeof value === "string" && value.length > 0;
4077
4079
  var portOf = (value, name) => {
4078
4080
  if (value === null || value === void 0) return null;
@@ -4112,14 +4114,14 @@ var SASjsApi = (() => {
4112
4114
  `The info configuration does not state \`${key}\`, which the document requires. A client validating the response refuses an answer that omits it.`
4113
4115
  );
4114
4116
  const mode = config.mode;
4115
- if (!isNonEmptyString(mode) || mode.trim() === "")
4117
+ if (!MODES.includes(mode))
4116
4118
  throw new Error(
4117
- `The info configuration states mode as ${JSON.stringify(mode)}; the document states which mode the host runs in.`
4119
+ `The info configuration states mode as ${JSON.stringify(mode)}; the document states the ModeType enum - ${MODES.map((value) => `\`${value}\``).join(" or ")}.`
4118
4120
  );
4119
4121
  const cors = config.cors;
4120
- if (!isNonEmptyString(cors) || cors.trim() === "")
4122
+ if (!CORS_VALUES.includes(cors))
4121
4123
  throw new Error(
4122
- `The info configuration states cors as ${JSON.stringify(cors)}; the document states the host's CORS setting.`
4124
+ `The info configuration states cors as ${JSON.stringify(cors)}; the document states the CorsType enum - ${CORS_VALUES.map((value) => `\`${value}\``).join(" or ")}.`
4123
4125
  );
4124
4126
  const version = config.version;
4125
4127
  if (!isNonEmptyString(version) || version.trim() === "")
@@ -25,7 +25,7 @@
25
25
  * the response and finds an unexpected property.
26
26
  */
27
27
  Object.defineProperty(exports, "__esModule", { value: true });
28
- exports.createInfoService = exports.normaliseInfo = exports.BROWSER_INFO = void 0;
28
+ exports.createInfoService = exports.normaliseInfo = exports.CORS_VALUES = exports.MODES = exports.BROWSER_INFO = void 0;
29
29
  /**
30
30
  * What the browser build answers, and the case the corpus runs.
31
31
  *
@@ -60,6 +60,14 @@ const FIELDS = [
60
60
  ];
61
61
  /** The properties the document makes required; `oidcProviderName` is not one. */
62
62
  const REQUIRED_FIELDS = FIELDS.filter((field) => field !== 'oidcProviderName');
63
+ /**
64
+ * The two enums the document states for this body, from the `ModeType` and
65
+ * `CorsType` schemas sasjs/server publishes (v4.16.2). `spec/info.spec.ts`
66
+ * reads them back out of `spec/swagger.yaml` and fails if these lists and the
67
+ * document disagree in either direction.
68
+ */
69
+ exports.MODES = ['server', 'desktop'];
70
+ exports.CORS_VALUES = ['enable', 'disable'];
63
71
  const isNonEmptyString = (value) => typeof value === 'string' && value.length > 0;
64
72
  /**
65
73
  * A port the document can carry: an integer in range, or `null`.
@@ -106,14 +114,11 @@ const normaliseInfo = (config) => {
106
114
  if (!Object.prototype.hasOwnProperty.call(config, key))
107
115
  throw new Error(`The info configuration does not state \`${key}\`, which the document requires. A client validating the response refuses an answer that omits it.`);
108
116
  const mode = config.mode;
109
- if (!isNonEmptyString(mode) || mode.trim() === '')
110
- throw new Error(`The info configuration states mode as ${JSON.stringify(mode)}; the document states which mode the host runs in.`);
111
- // the document states `cors` as a string and the server passes `CORS` through
112
- // verbatim, so any word is accepted here. sasjs/server#593 types both as
113
- // enums; the refusal tightens with the release that publishes them.
117
+ if (!exports.MODES.includes(mode))
118
+ throw new Error(`The info configuration states mode as ${JSON.stringify(mode)}; the document states the ModeType enum - ${exports.MODES.map((value) => `\`${value}\``).join(' or ')}.`);
114
119
  const cors = config.cors;
115
- if (!isNonEmptyString(cors) || cors.trim() === '')
116
- throw new Error(`The info configuration states cors as ${JSON.stringify(cors)}; the document states the host's CORS setting.`);
120
+ if (!exports.CORS_VALUES.includes(cors))
121
+ throw new Error(`The info configuration states cors as ${JSON.stringify(cors)}; the document states the CorsType enum - ${exports.CORS_VALUES.map((value) => `\`${value}\``).join(' or ')}.`);
117
122
  const version = config.version;
118
123
  if (!isNonEmptyString(version) || version.trim() === '')
119
124
  throw new Error(`The info configuration states version as ${JSON.stringify(version)}; the document states the release that produced the build, such as \`v3.2.2 (4a26a3d)\`.`);
@@ -32,15 +32,15 @@
32
32
  */
33
33
  export interface InfoResponse {
34
34
  /**
35
- * Which mode the host runs in, from `MODE` - `server` or `desktop` on
36
- * sasjs/server. Typed as a string because that is what the published document
37
- * states: sasjs/server#593 types it as the enum so tsoa publishes one, and the
38
- * refusal below tightens to the two words when that release is vendored here.
35
+ * Which mode the host runs in, from `MODE` - and the two words the document
36
+ * states, `ModeType` (`server`, `desktop`). Typed as a string because that is
37
+ * the JSON type; the service refuses anything outside the enum, and a spec
38
+ * reads the enum out of `spec/swagger.yaml` so the two cannot drift.
39
39
  */
40
40
  mode: string;
41
41
  /**
42
- * The host's CORS setting, from `CORS`. The server passes the variable
43
- * through, so it is read as a string until sasjs/server#593 states the enum.
42
+ * The host's CORS setting, from `CORS` - the document's `CorsType` (`enable`,
43
+ * `disable`), enforced the same way.
44
44
  */
45
45
  cors: string;
46
46
  /** The plain HTTP listener's port, or `null` when it is disabled. */
@@ -81,6 +81,14 @@ export interface InfoService {
81
81
  * site is served by whoever serves the site.
82
82
  */
83
83
  export declare const BROWSER_INFO: InfoResponse;
84
+ /**
85
+ * The two enums the document states for this body, from the `ModeType` and
86
+ * `CorsType` schemas sasjs/server publishes (v4.16.2). `spec/info.spec.ts`
87
+ * reads them back out of `spec/swagger.yaml` and fails if these lists and the
88
+ * document disagree in either direction.
89
+ */
90
+ export declare const MODES: string[];
91
+ export declare const CORS_VALUES: string[];
84
92
  /**
85
93
  * The configuration, checked and put in the document's order.
86
94
  *
@@ -1 +1 @@
1
- {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/info/service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH;;;;;;GAMG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;;OAKG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ,qEAAqE;IACrE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,8DAA8D;IAC9D,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,0EAA0E;IAC1E,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,8DAA8D;IAC9D,aAAa,EAAE,MAAM,EAAE,CAAA;IACvB,sEAAsE;IACtE,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,kEAAkE;IAClE,iBAAiB,EAAE,OAAO,CAAA;IAC1B;;;;;;;;OAQG;IACH,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,WAAW;IAC1B,6CAA6C;IAC7C,IAAI,IAAI,OAAO,CAAC,YAAY,CAAC,CAAA;CAC9B;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY,EAAE,YAS1B,CAAA;AA6DD;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,GAAI,QAAQ,YAAY,KAAG,YAuEpD,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAC5B,QAAQ,YAAY,GAAG,CAAC,MAAM,YAAY,CAAC,KAC1C,WAQF,CAAA"}
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/info/service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH;;;;;;GAMG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;;OAKG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ,qEAAqE;IACrE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,8DAA8D;IAC9D,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,0EAA0E;IAC1E,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,8DAA8D;IAC9D,aAAa,EAAE,MAAM,EAAE,CAAA;IACvB,sEAAsE;IACtE,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,kEAAkE;IAClE,iBAAiB,EAAE,OAAO,CAAA;IAC1B;;;;;;;;OAQG;IACH,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,WAAW;IAC1B,6CAA6C;IAC7C,IAAI,IAAI,OAAO,CAAC,YAAY,CAAC,CAAA;CAC9B;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY,EAAE,YAS1B,CAAA;AAkBD;;;;;GAKG;AACH,eAAO,MAAM,KAAK,UAAwB,CAAA;AAC1C,eAAO,MAAM,WAAW,UAAwB,CAAA;AA6ChD;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,GAAI,QAAQ,YAAY,KAAG,YAoEpD,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAC5B,QAAQ,YAAY,GAAG,CAAC,MAAM,YAAY,CAAC,KAC1C,WAQF,CAAA"}
@@ -57,6 +57,14 @@ const FIELDS = [
57
57
  ];
58
58
  /** The properties the document makes required; `oidcProviderName` is not one. */
59
59
  const REQUIRED_FIELDS = FIELDS.filter((field) => field !== 'oidcProviderName');
60
+ /**
61
+ * The two enums the document states for this body, from the `ModeType` and
62
+ * `CorsType` schemas sasjs/server publishes (v4.16.2). `spec/info.spec.ts`
63
+ * reads them back out of `spec/swagger.yaml` and fails if these lists and the
64
+ * document disagree in either direction.
65
+ */
66
+ export const MODES = ['server', 'desktop'];
67
+ export const CORS_VALUES = ['enable', 'disable'];
60
68
  const isNonEmptyString = (value) => typeof value === 'string' && value.length > 0;
61
69
  /**
62
70
  * A port the document can carry: an integer in range, or `null`.
@@ -103,14 +111,11 @@ export const normaliseInfo = (config) => {
103
111
  if (!Object.prototype.hasOwnProperty.call(config, key))
104
112
  throw new Error(`The info configuration does not state \`${key}\`, which the document requires. A client validating the response refuses an answer that omits it.`);
105
113
  const mode = config.mode;
106
- if (!isNonEmptyString(mode) || mode.trim() === '')
107
- throw new Error(`The info configuration states mode as ${JSON.stringify(mode)}; the document states which mode the host runs in.`);
108
- // the document states `cors` as a string and the server passes `CORS` through
109
- // verbatim, so any word is accepted here. sasjs/server#593 types both as
110
- // enums; the refusal tightens with the release that publishes them.
114
+ if (!MODES.includes(mode))
115
+ throw new Error(`The info configuration states mode as ${JSON.stringify(mode)}; the document states the ModeType enum - ${MODES.map((value) => `\`${value}\``).join(' or ')}.`);
111
116
  const cors = config.cors;
112
- if (!isNonEmptyString(cors) || cors.trim() === '')
113
- throw new Error(`The info configuration states cors as ${JSON.stringify(cors)}; the document states the host's CORS setting.`);
117
+ if (!CORS_VALUES.includes(cors))
118
+ throw new Error(`The info configuration states cors as ${JSON.stringify(cors)}; the document states the CorsType enum - ${CORS_VALUES.map((value) => `\`${value}\``).join(' or ')}.`);
114
119
  const version = config.version;
115
120
  if (!isNonEmptyString(version) || version.trim() === '')
116
121
  throw new Error(`The info configuration states version as ${JSON.stringify(version)}; the document states the release that produced the build, such as \`v3.2.2 (4a26a3d)\`.`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sasjs/api",
3
- "version": "0.18.0",
3
+ "version": "0.18.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",