@aws-sdk/util-endpoints 3.197.0 → 3.200.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/CHANGELOG.md CHANGED
@@ -3,6 +3,25 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [3.200.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.199.0...v3.200.0) (2022-10-31)
7
+
8
+ **Note:** Version bump only for package @aws-sdk/util-endpoints
9
+
10
+
11
+
12
+
13
+
14
+ # [3.198.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.197.0...v3.198.0) (2022-10-27)
15
+
16
+
17
+ ### Features
18
+
19
+ * **endpoint:** log endpoint decisions at debug level ([#4106](https://github.com/aws/aws-sdk-js-v3/issues/4106)) ([d600213](https://github.com/aws/aws-sdk-js-v3/commit/d600213292eb1bea870c43420367f78406db1c82))
20
+
21
+
22
+
23
+
24
+
6
25
  # [3.197.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.196.0...v3.197.0) (2022-10-26)
7
26
 
8
27
  **Note:** Version bump only for package @aws-sdk/util-endpoints
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.debugId = void 0;
4
+ exports.debugId = "endpoints";
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./debugId"), exports);
5
+ tslib_1.__exportStar(require("./toDebugString"), exports);
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toDebugString = void 0;
4
+ function toDebugString(input) {
5
+ if (typeof input !== "object" || input == null) {
6
+ return input;
7
+ }
8
+ if ("ref" in input) {
9
+ return `$${toDebugString(input.ref)}`;
10
+ }
11
+ if ("fn" in input) {
12
+ return `${input.fn}(${(input.argv || []).map(toDebugString).join(", ")})`;
13
+ }
14
+ return JSON.stringify(input, null, 2);
15
+ }
16
+ exports.toDebugString = toDebugString;
@@ -1,18 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.resolveEndpoint = void 0;
4
+ const debug_1 = require("./debug");
4
5
  const types_1 = require("./types");
5
6
  const utils_1 = require("./utils");
6
7
  const resolveEndpoint = (ruleSetObject, options) => {
7
- var _a, _b;
8
+ var _a, _b, _c, _d, _e, _f;
8
9
  const { endpointParams, logger } = options;
9
10
  const { parameters, rules } = ruleSetObject;
11
+ (_b = (_a = options.logger) === null || _a === void 0 ? void 0 : _a.debug) === null || _b === void 0 ? void 0 : _b.call(_a, debug_1.debugId, `Initial EndpointParams: ${(0, debug_1.toDebugString)(endpointParams)}`);
10
12
  const paramsWithDefault = Object.entries(parameters)
11
13
  .filter(([, v]) => v.default != null)
12
14
  .map(([k, v]) => [k, v.default]);
13
15
  if (paramsWithDefault.length > 0) {
14
16
  for (const [paramKey, paramDefaultValue] of paramsWithDefault) {
15
- endpointParams[paramKey] = (_a = endpointParams[paramKey]) !== null && _a !== void 0 ? _a : paramDefaultValue;
17
+ endpointParams[paramKey] = (_c = endpointParams[paramKey]) !== null && _c !== void 0 ? _c : paramDefaultValue;
16
18
  }
17
19
  }
18
20
  const requiredParams = Object.entries(parameters)
@@ -24,7 +26,7 @@ const resolveEndpoint = (ruleSetObject, options) => {
24
26
  }
25
27
  }
26
28
  const endpoint = (0, utils_1.evaluateRules)(rules, { endpointParams, logger, referenceRecord: {} });
27
- if ((_b = options.endpointParams) === null || _b === void 0 ? void 0 : _b.Endpoint) {
29
+ if ((_d = options.endpointParams) === null || _d === void 0 ? void 0 : _d.Endpoint) {
28
30
  try {
29
31
  const givenEndpoint = new URL(options.endpointParams.Endpoint);
30
32
  const { protocol, port } = givenEndpoint;
@@ -34,6 +36,7 @@ const resolveEndpoint = (ruleSetObject, options) => {
34
36
  catch (e) {
35
37
  }
36
38
  }
39
+ (_f = (_e = options.logger) === null || _e === void 0 ? void 0 : _e.debug) === null || _f === void 0 ? void 0 : _f.call(_e, debug_1.debugId, `Resolved endpoint: ${(0, debug_1.toDebugString)(endpoint)}`);
37
40
  return endpoint;
38
41
  };
39
42
  exports.resolveEndpoint = resolveEndpoint;
@@ -1,13 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.evaluateCondition = void 0;
4
+ const debug_1 = require("../debug");
4
5
  const types_1 = require("../types");
5
6
  const callFunction_1 = require("./callFunction");
6
7
  const evaluateCondition = ({ assign, ...fnArgs }, options) => {
8
+ var _a, _b;
7
9
  if (assign && assign in options.referenceRecord) {
8
10
  throw new types_1.EndpointError(`'${assign}' is already defined in Reference Record.`);
9
11
  }
10
12
  const value = (0, callFunction_1.callFunction)(fnArgs, options);
13
+ (_b = (_a = options.logger) === null || _a === void 0 ? void 0 : _a.debug) === null || _b === void 0 ? void 0 : _b.call(_a, debug_1.debugId, `evaluateCondition: ${(0, debug_1.toDebugString)(fnArgs)} = ${(0, debug_1.toDebugString)(value)}`);
11
14
  return {
12
15
  result: value === "" ? true : !!value,
13
16
  ...(assign != null && { toAssign: { name: assign, value } }),
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.evaluateConditions = void 0;
4
+ const debug_1 = require("../debug");
4
5
  const evaluateCondition_1 = require("./evaluateCondition");
5
6
  const evaluateConditions = (conditions = [], options) => {
7
+ var _a, _b;
6
8
  const conditionsReferenceRecord = {};
7
9
  for (const condition of conditions) {
8
10
  const { result, toAssign } = (0, evaluateCondition_1.evaluateCondition)(condition, {
@@ -17,6 +19,7 @@ const evaluateConditions = (conditions = [], options) => {
17
19
  }
18
20
  if (toAssign) {
19
21
  conditionsReferenceRecord[toAssign.name] = toAssign.value;
22
+ (_b = (_a = options.logger) === null || _a === void 0 ? void 0 : _a.debug) === null || _b === void 0 ? void 0 : _b.call(_a, debug_1.debugId, `assign: ${toAssign.name} := ${(0, debug_1.toDebugString)(toAssign.value)}`);
20
23
  }
21
24
  }
22
25
  return { result: true, referenceRecord: conditionsReferenceRecord };
@@ -1,11 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.evaluateEndpointRule = void 0;
4
+ const debug_1 = require("../debug");
4
5
  const evaluateConditions_1 = require("./evaluateConditions");
5
6
  const getEndpointHeaders_1 = require("./getEndpointHeaders");
6
7
  const getEndpointProperties_1 = require("./getEndpointProperties");
7
8
  const getEndpointUrl_1 = require("./getEndpointUrl");
8
9
  const evaluateEndpointRule = (endpointRule, options) => {
10
+ var _a, _b;
9
11
  const { conditions, endpoint } = endpointRule;
10
12
  const { result, referenceRecord } = (0, evaluateConditions_1.evaluateConditions)(conditions, options);
11
13
  if (!result) {
@@ -16,6 +18,7 @@ const evaluateEndpointRule = (endpointRule, options) => {
16
18
  referenceRecord: { ...options.referenceRecord, ...referenceRecord },
17
19
  };
18
20
  const { url, properties, headers } = endpoint;
21
+ (_b = (_a = options.logger) === null || _a === void 0 ? void 0 : _a.debug) === null || _b === void 0 ? void 0 : _b.call(_a, debug_1.debugId, `Resolving endpoint from template: ${(0, debug_1.toDebugString)(endpoint)}`);
19
22
  return {
20
23
  ...(headers != undefined && {
21
24
  headers: (0, getEndpointHeaders_1.getEndpointHeaders)(headers, endpointRuleOptions),
@@ -0,0 +1 @@
1
+ export const debugId = "endpoints";
@@ -0,0 +1,2 @@
1
+ export * from "./debugId";
2
+ export * from "./toDebugString";
@@ -0,0 +1,12 @@
1
+ export function toDebugString(input) {
2
+ if (typeof input !== "object" || input == null) {
3
+ return input;
4
+ }
5
+ if ("ref" in input) {
6
+ return `$${toDebugString(input.ref)}`;
7
+ }
8
+ if ("fn" in input) {
9
+ return `${input.fn}(${(input.argv || []).map(toDebugString).join(", ")})`;
10
+ }
11
+ return JSON.stringify(input, null, 2);
12
+ }
@@ -1,8 +1,10 @@
1
+ import { debugId, toDebugString } from "./debug";
1
2
  import { EndpointError } from "./types";
2
3
  import { evaluateRules } from "./utils";
3
4
  export const resolveEndpoint = (ruleSetObject, options) => {
4
5
  const { endpointParams, logger } = options;
5
6
  const { parameters, rules } = ruleSetObject;
7
+ options.logger?.debug?.(debugId, `Initial EndpointParams: ${toDebugString(endpointParams)}`);
6
8
  const paramsWithDefault = Object.entries(parameters)
7
9
  .filter(([, v]) => v.default != null)
8
10
  .map(([k, v]) => [k, v.default]);
@@ -30,5 +32,6 @@ export const resolveEndpoint = (ruleSetObject, options) => {
30
32
  catch (e) {
31
33
  }
32
34
  }
35
+ options.logger?.debug?.(debugId, `Resolved endpoint: ${toDebugString(endpoint)}`);
33
36
  return endpoint;
34
37
  };
@@ -1,3 +1,4 @@
1
+ import { debugId, toDebugString } from "../debug";
1
2
  import { EndpointError } from "../types";
2
3
  import { callFunction } from "./callFunction";
3
4
  export const evaluateCondition = ({ assign, ...fnArgs }, options) => {
@@ -5,6 +6,7 @@ export const evaluateCondition = ({ assign, ...fnArgs }, options) => {
5
6
  throw new EndpointError(`'${assign}' is already defined in Reference Record.`);
6
7
  }
7
8
  const value = callFunction(fnArgs, options);
9
+ options.logger?.debug?.(debugId, `evaluateCondition: ${toDebugString(fnArgs)} = ${toDebugString(value)}`);
8
10
  return {
9
11
  result: value === "" ? true : !!value,
10
12
  ...(assign != null && { toAssign: { name: assign, value } }),
@@ -1,3 +1,4 @@
1
+ import { debugId, toDebugString } from "../debug";
1
2
  import { evaluateCondition } from "./evaluateCondition";
2
3
  export const evaluateConditions = (conditions = [], options) => {
3
4
  const conditionsReferenceRecord = {};
@@ -14,6 +15,7 @@ export const evaluateConditions = (conditions = [], options) => {
14
15
  }
15
16
  if (toAssign) {
16
17
  conditionsReferenceRecord[toAssign.name] = toAssign.value;
18
+ options.logger?.debug?.(debugId, `assign: ${toAssign.name} := ${toDebugString(toAssign.value)}`);
17
19
  }
18
20
  }
19
21
  return { result: true, referenceRecord: conditionsReferenceRecord };
@@ -1,3 +1,4 @@
1
+ import { debugId, toDebugString } from "../debug";
1
2
  import { evaluateConditions } from "./evaluateConditions";
2
3
  import { getEndpointHeaders } from "./getEndpointHeaders";
3
4
  import { getEndpointProperties } from "./getEndpointProperties";
@@ -13,6 +14,7 @@ export const evaluateEndpointRule = (endpointRule, options) => {
13
14
  referenceRecord: { ...options.referenceRecord, ...referenceRecord },
14
15
  };
15
16
  const { url, properties, headers } = endpoint;
17
+ options.logger?.debug?.(debugId, `Resolving endpoint from template: ${toDebugString(endpoint)}`);
16
18
  return {
17
19
  ...(headers != undefined && {
18
20
  headers: getEndpointHeaders(headers, endpointRuleOptions),
@@ -0,0 +1 @@
1
+ export declare const debugId = "endpoints";
@@ -0,0 +1,2 @@
1
+ export * from "./debugId";
2
+ export * from "./toDebugString";
@@ -0,0 +1,9 @@
1
+ import { EndpointParameters, EndpointV2 } from "@aws-sdk/types";
2
+ import { GetAttrValue } from "../lib";
3
+ import { EndpointObject, FunctionObject, FunctionReturn } from "../types";
4
+ export declare function toDebugString(input: EndpointParameters): string;
5
+ export declare function toDebugString(input: EndpointV2): string;
6
+ export declare function toDebugString(input: GetAttrValue): string;
7
+ export declare function toDebugString(input: FunctionObject): string;
8
+ export declare function toDebugString(input: FunctionReturn): string;
9
+ export declare function toDebugString(input: EndpointObject): string;
@@ -0,0 +1 @@
1
+ export declare const debugId = "endpoints";
@@ -0,0 +1,2 @@
1
+ export * from "./debugId";
2
+ export * from "./toDebugString";
@@ -0,0 +1,9 @@
1
+ import { EndpointParameters, EndpointV2 } from "@aws-sdk/types";
2
+ import { GetAttrValue } from "../lib";
3
+ import { EndpointObject, FunctionObject, FunctionReturn } from "../types";
4
+ export declare function toDebugString(input: EndpointParameters): string;
5
+ export declare function toDebugString(input: EndpointV2): string;
6
+ export declare function toDebugString(input: GetAttrValue): string;
7
+ export declare function toDebugString(input: FunctionObject): string;
8
+ export declare function toDebugString(input: FunctionReturn): string;
9
+ export declare function toDebugString(input: EndpointObject): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/util-endpoints",
3
- "version": "3.197.0",
3
+ "version": "3.200.0",
4
4
  "description": "Utilities to help with endpoint resolution",
5
5
  "main": "./dist-cjs/index.js",
6
6
  "module": "./dist-es/index.js",
@@ -21,7 +21,7 @@
21
21
  },
22
22
  "license": "Apache-2.0",
23
23
  "dependencies": {
24
- "@aws-sdk/types": "3.197.0",
24
+ "@aws-sdk/types": "3.200.0",
25
25
  "tslib": "^2.3.1"
26
26
  },
27
27
  "engines": {