@xapp/stentor-service 1.86.2 → 1.86.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.
@@ -2,12 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AbstractResourceService = exports.DEFAULT_PROTOCOL = void 0;
4
4
  /*! Copyright (c) 2019, XAPPmedia */
5
- const queryString = require("query-string");
6
5
  const URL = require("url");
7
6
  const stentor_service_fetch_1 = require("stentor-service-fetch");
8
7
  const ResourceService_1 = require("./ResourceService");
8
+ const utils_1 = require("./utils");
9
9
  const find = require("lodash.find");
10
- const template = require("lodash.template");
11
10
  exports.DEFAULT_PROTOCOL = "https:";
12
11
  /**
13
12
  * Abstract resource service for performing HTTP GETs on
@@ -63,9 +62,8 @@ class AbstractResourceService extends stentor_service_fetch_1.FetchService {
63
62
  hostname: this.hostname
64
63
  };
65
64
  // Do any necessary replacements on the path
66
- const pathCompiler = template(resource.path);
67
- url.pathname = pathCompiler(resource.requestMap);
68
- url.search = queryString.stringify(resource.query);
65
+ url.pathname = (0, utils_1.compilePath)(resource.path, resource.requestMap);
66
+ url.search = (0, utils_1.stringifyQuery)(resource.query);
69
67
  const headers = this.headers;
70
68
  return this.fetch(URL.format(url), { method: "GET", headers })
71
69
  .then(response => {
@@ -1 +1 @@
1
- {"version":3,"file":"AbstractResourceService.js","sourceRoot":"","sources":["../../src/ResourceService/AbstractResourceService.ts"],"names":[],"mappings":";;;AAAA,oCAAoC;AACpC,4CAA4C;AAC5C,2BAA2B;AAC3B,iEAAqD;AACrD,uDAAqF;AAErF,MAAM,IAAI,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AACpC,MAAM,QAAQ,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAE/B,QAAA,gBAAgB,GAAG,QAAQ,CAAC;AAEzC;;;;;;;;;;GAUG;AACH,MAAsB,uBAAwB,SAAQ,oCAAY;IAW9D,YAAY,KAAuB;QAC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K,EAAE,OAAO,EAAE,CAAC;aACzD,IAAI,CAAC,QAAQ,CAAC,EAAE;YACb,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;QAC3B,CAAC,CAAC;aACD,IAAI,CAAC,IAAI,CAAC,EAAE;YACT,cAAc;YACd,OAAO,IAAA,uCAAqB,EAAI,IAAI,EAAE,QAAQ,CAAC,CAAC;QACpD,CAAC,CAAC,CAAC;IACX,CAAC;CACJ;AAvED,0DAuEC"}
@@ -0,0 +1,39 @@
1
+ /*! Copyright (c) 2026, XAPPmedia */
2
+ /**
3
+ * Fills `${key}` placeholders in a resource path from its request map.
4
+ *
5
+ * Replaces `lodash.template`, which compiled the path into a function. Only
6
+ * the `${key}` form is used by any resource in this repo, so this deliberately
7
+ * does not support lodash's `<% %>` evaluate form — and it never evaluates the
8
+ * placeholder as code. `lodash.template` compiled arbitrary JavaScript, which
9
+ * is why it has a CVE history; a path is data, not a program.
10
+ *
11
+ * Matches lodash by **throwing** on a placeholder with no matching key, so a
12
+ * misconfigured resource fails loudly instead of requesting a malformed URL.
13
+ *
14
+ * @export
15
+ * @param {string} path
16
+ * @param {{ [key: string]: unknown }} [data]
17
+ * @returns {string}
18
+ */
19
+ export declare function compilePath(path: string, data?: {
20
+ [key: string]: unknown;
21
+ }): string;
22
+ /**
23
+ * Serializes a resource's query object.
24
+ *
25
+ * Replaces `query-string.stringify`. `URLSearchParams` is not a drop-in here —
26
+ * these differences were measured against query-string@7 and are preserved:
27
+ *
28
+ * - keys are sorted alphabetically (`URLSearchParams` keeps insertion order)
29
+ * - `undefined` values are omitted entirely (`URLSearchParams` would emit the
30
+ * string "undefined")
31
+ * - spaces encode as `%20`, not `+`
32
+ *
33
+ * @export
34
+ * @param {{ [key: string]: string }} [query]
35
+ * @returns {string}
36
+ */
37
+ export declare function stringifyQuery(query?: {
38
+ [key: string]: string;
39
+ }): string;
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ /*! Copyright (c) 2026, XAPPmedia */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.compilePath = compilePath;
5
+ exports.stringifyQuery = stringifyQuery;
6
+ const INTERPOLATE = /\$\{([^{}]*)\}/g;
7
+ /**
8
+ * Fills `${key}` placeholders in a resource path from its request map.
9
+ *
10
+ * Replaces `lodash.template`, which compiled the path into a function. Only
11
+ * the `${key}` form is used by any resource in this repo, so this deliberately
12
+ * does not support lodash's `<% %>` evaluate form — and it never evaluates the
13
+ * placeholder as code. `lodash.template` compiled arbitrary JavaScript, which
14
+ * is why it has a CVE history; a path is data, not a program.
15
+ *
16
+ * Matches lodash by **throwing** on a placeholder with no matching key, so a
17
+ * misconfigured resource fails loudly instead of requesting a malformed URL.
18
+ *
19
+ * @export
20
+ * @param {string} path
21
+ * @param {{ [key: string]: unknown }} [data]
22
+ * @returns {string}
23
+ */
24
+ function compilePath(path, data) {
25
+ return path.replace(INTERPOLATE, (_match, rawKey) => {
26
+ const key = rawKey.trim();
27
+ const value = data ? data[key] : undefined;
28
+ if (value === undefined || value === null) {
29
+ throw new Error(`${key} is not defined`);
30
+ }
31
+ return `${value}`;
32
+ });
33
+ }
34
+ /**
35
+ * Serializes a resource's query object.
36
+ *
37
+ * Replaces `query-string.stringify`. `URLSearchParams` is not a drop-in here —
38
+ * these differences were measured against query-string@7 and are preserved:
39
+ *
40
+ * - keys are sorted alphabetically (`URLSearchParams` keeps insertion order)
41
+ * - `undefined` values are omitted entirely (`URLSearchParams` would emit the
42
+ * string "undefined")
43
+ * - spaces encode as `%20`, not `+`
44
+ *
45
+ * @export
46
+ * @param {{ [key: string]: string }} [query]
47
+ * @returns {string}
48
+ */
49
+ function stringifyQuery(query) {
50
+ if (!query) {
51
+ return "";
52
+ }
53
+ return Object.keys(query)
54
+ .sort()
55
+ .filter((key) => query[key] !== undefined)
56
+ .map((key) => `${encodeURIComponent(key)}=${encodeURIComponent(query[key])}`)
57
+ .join("&");
58
+ }
59
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/ResourceService/utils.ts"],"names":[],"mappings":";AAAA,oCAAoC;;AAqBpC,kCAWC;AAiBD,wCAUC;AAzDD,MAAM,WAAW,GAAG,iBAAiB,CAAC;AAEtC;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,WAAW,CAAC,IAAY,EAAE,IAAiC;IACvE,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,MAAM,EAAE,MAAc,EAAE,EAAE;QACxD,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;QAC1B,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAE3C,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACxC,MAAM,IAAI,KAAK,CAAC,GAAG,GAAG,iBAAiB,CAAC,CAAC;QAC7C,CAAC;QAED,OAAO,GAAG,KAAK,EAAE,CAAC;IACtB,CAAC,CAAC,CAAC;AACP,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,SAAgB,cAAc,CAAC,KAAiC;IAC5D,IAAI,CAAC,KAAK,EAAE,CAAC;QACT,OAAO,EAAE,CAAC;IACd,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;SACpB,IAAI,EAAE;SACN,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,SAAS,CAAC;SACzC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,kBAAkB,CAAC,GAAG,CAAC,IAAI,kBAAkB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;SAC5E,IAAI,CAAC,GAAG,CAAC,CAAC;AACnB,CAAC"}
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "1.86.2",
7
+ "version": "1.86.4",
8
8
  "description": "Base service to be extended for making API calls",
9
9
  "types": "lib/index",
10
10
  "main": "lib/index",
@@ -17,30 +17,28 @@
17
17
  "devDependencies": {
18
18
  "@types/chai": "5.2.3",
19
19
  "@types/chai-as-promised": "7.1.8",
20
- "@types/lodash": "4.17.24",
20
+ "@types/lodash": "4.17.25",
21
21
  "@types/sinon": "4.3.3",
22
22
  "@types/sinon-chai": "3.2.12",
23
23
  "@xapp/config": "0.3.0",
24
24
  "chai": "4.5.0",
25
25
  "chai-as-promised": "7.1.2",
26
26
  "fetch-mock": "9.11.0",
27
- "mocha": "11.7.6",
27
+ "mocha": "11.8.0",
28
28
  "sinon": "21.0.0",
29
29
  "sinon-chai": "3.7.0",
30
- "stentor-constants": "1.74.1",
31
- "stentor-context": "1.74.2",
32
- "stentor-models": "1.75.0",
33
- "stentor-request": "1.74.2",
34
- "stentor-service-fetch": "1.74.1",
35
- "stentor-utils": "1.74.2",
30
+ "stentor-constants": "1.74.3",
31
+ "stentor-context": "1.74.6",
32
+ "stentor-models": "1.77.0",
33
+ "stentor-request": "1.74.5",
34
+ "stentor-service-fetch": "1.74.3",
35
+ "stentor-utils": "1.75.1",
36
36
  "ts-node": "10.9.2",
37
37
  "typescript": "5.9.3"
38
38
  },
39
39
  "dependencies": {
40
40
  "jsonpath-plus": "10.4.0",
41
- "lodash.find": "4.6.0",
42
- "lodash.template": "4.18.1",
43
- "query-string": "7.1.3"
41
+ "lodash.find": "4.6.0"
44
42
  },
45
43
  "peerDependencies": {
46
44
  "stentor-constants": "1.x",
@@ -54,7 +52,8 @@
54
52
  "prepack": "yarn build",
55
53
  "build": "tsc -d true -p .",
56
54
  "clean": "rm -rf ./lib/*",
57
- "ftest": "mocha --recursive -r ts-node/register \"./src/**/*.ftest.ts\""
55
+ "ftest": "mocha --recursive -r ts-node/register \"./src/**/*.ftest.ts\"",
56
+ "test": "mocha --recursive -r ts-node/register \"./src/**/*.test.ts\""
58
57
  },
59
58
  "gitHead": "3a345719866a5c39329b605545f04c465e6baf48"
60
59
  }