@aws-sdk/util-endpoints 3.292.0 → 3.295.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.
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.partition = void 0;
3
+ exports.getUserAgentPrefix = exports.useDefaultPartitionInfo = exports.setPartitionInfo = exports.partition = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const partitions_json_1 = tslib_1.__importDefault(require("./partitions.json"));
6
- const { partitions } = partitions_json_1.default;
7
- const DEFAULT_PARTITION = partitions.find((partition) => partition.id === "aws");
6
+ let selectedPartitionsInfo = partitions_json_1.default;
7
+ let selectedUserAgentPrefix = "";
8
8
  const partition = (value) => {
9
+ const { partitions } = selectedPartitionsInfo;
9
10
  for (const partition of partitions) {
10
11
  const { regions, outputs } = partition;
11
12
  for (const [region, regionData] of Object.entries(regions)) {
@@ -25,6 +26,7 @@ const partition = (value) => {
25
26
  };
26
27
  }
27
28
  }
29
+ const DEFAULT_PARTITION = partitions.find((partition) => partition.id === "aws");
28
30
  if (!DEFAULT_PARTITION) {
29
31
  throw new Error("Provided region was not found in the partition array or regex," +
30
32
  " and default partition with id 'aws' doesn't exist.");
@@ -34,3 +36,14 @@ const partition = (value) => {
34
36
  };
35
37
  };
36
38
  exports.partition = partition;
39
+ const setPartitionInfo = (partitionsInfo, userAgentPrefix = "") => {
40
+ selectedPartitionsInfo = partitionsInfo;
41
+ selectedUserAgentPrefix = userAgentPrefix;
42
+ };
43
+ exports.setPartitionInfo = setPartitionInfo;
44
+ const useDefaultPartitionInfo = () => {
45
+ (0, exports.setPartitionInfo)(partitions_json_1.default, "");
46
+ };
47
+ exports.useDefaultPartitionInfo = useDefaultPartitionInfo;
48
+ const getUserAgentPrefix = () => selectedUserAgentPrefix;
49
+ exports.getUserAgentPrefix = getUserAgentPrefix;
@@ -1,7 +1,8 @@
1
1
  import partitionsInfo from "./partitions.json";
2
- const { partitions } = partitionsInfo;
3
- const DEFAULT_PARTITION = partitions.find((partition) => partition.id === "aws");
2
+ let selectedPartitionsInfo = partitionsInfo;
3
+ let selectedUserAgentPrefix = "";
4
4
  export const partition = (value) => {
5
+ const { partitions } = selectedPartitionsInfo;
5
6
  for (const partition of partitions) {
6
7
  const { regions, outputs } = partition;
7
8
  for (const [region, regionData] of Object.entries(regions)) {
@@ -21,6 +22,7 @@ export const partition = (value) => {
21
22
  };
22
23
  }
23
24
  }
25
+ const DEFAULT_PARTITION = partitions.find((partition) => partition.id === "aws");
24
26
  if (!DEFAULT_PARTITION) {
25
27
  throw new Error("Provided region was not found in the partition array or regex," +
26
28
  " and default partition with id 'aws' doesn't exist.");
@@ -29,3 +31,11 @@ export const partition = (value) => {
29
31
  ...DEFAULT_PARTITION.outputs,
30
32
  };
31
33
  };
34
+ export const setPartitionInfo = (partitionsInfo, userAgentPrefix = "") => {
35
+ selectedPartitionsInfo = partitionsInfo;
36
+ selectedUserAgentPrefix = userAgentPrefix;
37
+ };
38
+ export const useDefaultPartitionInfo = () => {
39
+ setPartitionInfo(partitionsInfo, "");
40
+ };
41
+ export const getUserAgentPrefix = () => selectedUserAgentPrefix;
@@ -1,4 +1,20 @@
1
1
  import { EndpointPartition } from "@aws-sdk/types";
2
+ export type PartitionsInfo = {
3
+ partitions: Array<{
4
+ id: string;
5
+ outputs: {
6
+ dnsSuffix: string;
7
+ dualStackDnsSuffix: string;
8
+ name: string;
9
+ supportsDualStack: boolean;
10
+ supportsFIPS: boolean;
11
+ };
12
+ regionRegex: string;
13
+ regions: Record<string, {
14
+ description?: string;
15
+ } | undefined>;
16
+ }>;
17
+ };
2
18
  /**
3
19
  * Evaluates a single string argument value as a region, and matches the
4
20
  * string value to an AWS partition.
@@ -6,3 +22,17 @@ import { EndpointPartition } from "@aws-sdk/types";
6
22
  * that the region has been determined to be a part of.
7
23
  */
8
24
  export declare const partition: (value: string) => EndpointPartition;
25
+ /**
26
+ * Set custom partitions.json data.
27
+ * @internal
28
+ */
29
+ export declare const setPartitionInfo: (partitionsInfo: PartitionsInfo, userAgentPrefix?: string) => void;
30
+ /**
31
+ * Reset to the default partitions.json data.
32
+ * @internal
33
+ */
34
+ export declare const useDefaultPartitionInfo: () => void;
35
+ /**
36
+ * @internal
37
+ */
38
+ export declare const getUserAgentPrefix: () => string;
@@ -1,4 +1,4 @@
1
- export declare type GetAttrValue = string | boolean | {
1
+ export type GetAttrValue = string | boolean | {
2
2
  [key: string]: GetAttrValue;
3
3
  } | Array<GetAttrValue>;
4
4
  /**
@@ -1,2 +1,28 @@
1
1
  import { EndpointPartition } from "@aws-sdk/types";
2
+ export type PartitionsInfo = {
3
+ partitions: Array<{
4
+ id: string;
5
+ outputs: {
6
+ dnsSuffix: string;
7
+ dualStackDnsSuffix: string;
8
+ name: string;
9
+ supportsDualStack: boolean;
10
+ supportsFIPS: boolean;
11
+ };
12
+ regionRegex: string;
13
+ regions: Record<
14
+ string,
15
+ | {
16
+ description?: string;
17
+ }
18
+ | undefined
19
+ >;
20
+ }>;
21
+ };
2
22
  export declare const partition: (value: string) => EndpointPartition;
23
+ export declare const setPartitionInfo: (
24
+ partitionsInfo: PartitionsInfo,
25
+ userAgentPrefix?: string
26
+ ) => void;
27
+ export declare const useDefaultPartitionInfo: () => void;
28
+ export declare const getUserAgentPrefix: () => string;
@@ -1,4 +1,4 @@
1
- export declare type GetAttrValue =
1
+ export type GetAttrValue =
2
2
  | string
3
3
  | boolean
4
4
  | {
@@ -1,16 +1,13 @@
1
1
  import { EndpointObjectProperty } from "@aws-sdk/types";
2
2
  import { ConditionObject, Expression } from "./shared";
3
- export declare type EndpointObjectProperties = Record<
4
- string,
5
- EndpointObjectProperty
6
- >;
7
- export declare type EndpointObjectHeaders = Record<string, Expression[]>;
8
- export declare type EndpointObject = {
3
+ export type EndpointObjectProperties = Record<string, EndpointObjectProperty>;
4
+ export type EndpointObjectHeaders = Record<string, Expression[]>;
5
+ export type EndpointObject = {
9
6
  url: Expression;
10
7
  properties?: EndpointObjectProperties;
11
8
  headers?: EndpointObjectHeaders;
12
9
  };
13
- export declare type EndpointRuleObject = {
10
+ export type EndpointRuleObject = {
14
11
  type: "endpoint";
15
12
  conditions?: ConditionObject[];
16
13
  endpoint: EndpointObject;
@@ -1,5 +1,5 @@
1
1
  import { ConditionObject, Expression } from "./shared";
2
- export declare type ErrorRuleObject = {
2
+ export type ErrorRuleObject = {
3
3
  type: "error";
4
4
  conditions?: ConditionObject[];
5
5
  error: Expression;
@@ -1,9 +1,9 @@
1
1
  import { RuleSetRules } from "./TreeRuleObject";
2
- export declare type DeprecatedObject = {
2
+ export type DeprecatedObject = {
3
3
  message?: string;
4
4
  since?: string;
5
5
  };
6
- export declare type ParameterObject = {
6
+ export type ParameterObject = {
7
7
  type: "String" | "Boolean";
8
8
  default?: string | boolean;
9
9
  required?: boolean;
@@ -11,7 +11,7 @@ export declare type ParameterObject = {
11
11
  builtIn?: string;
12
12
  deprecated?: DeprecatedObject;
13
13
  };
14
- export declare type RuleSetObject = {
14
+ export type RuleSetObject = {
15
15
  version: string;
16
16
  serviceId?: string;
17
17
  parameters: Record<string, ParameterObject>;
@@ -1,10 +1,10 @@
1
1
  import { EndpointRuleObject } from "./EndpointRuleObject";
2
2
  import { ErrorRuleObject } from "./ErrorRuleObject";
3
3
  import { ConditionObject } from "./shared";
4
- export declare type RuleSetRules = Array<
4
+ export type RuleSetRules = Array<
5
5
  EndpointRuleObject | ErrorRuleObject | TreeRuleObject
6
6
  >;
7
- export declare type TreeRuleObject = {
7
+ export type TreeRuleObject = {
8
8
  type: "tree";
9
9
  conditions?: ConditionObject[];
10
10
  rules: RuleSetRules;
@@ -1,29 +1,29 @@
1
1
  import { Logger } from "@aws-sdk/types";
2
- export declare type ReferenceObject = {
2
+ export type ReferenceObject = {
3
3
  ref: string;
4
4
  };
5
- export declare type FunctionObject = {
5
+ export type FunctionObject = {
6
6
  fn: string;
7
7
  argv: FunctionArgv;
8
8
  };
9
- export declare type FunctionArgv = Array<Expression | boolean | number>;
10
- export declare type FunctionReturn =
9
+ export type FunctionArgv = Array<Expression | boolean | number>;
10
+ export type FunctionReturn =
11
11
  | string
12
12
  | boolean
13
13
  | number
14
14
  | {
15
15
  [key: string]: FunctionReturn;
16
16
  };
17
- export declare type ConditionObject = FunctionObject & {
17
+ export type ConditionObject = FunctionObject & {
18
18
  assign?: string;
19
19
  };
20
- export declare type Expression = string | ReferenceObject | FunctionObject;
21
- export declare type EndpointParams = Record<string, string | boolean>;
22
- export declare type EndpointResolverOptions = {
20
+ export type Expression = string | ReferenceObject | FunctionObject;
21
+ export type EndpointParams = Record<string, string | boolean>;
22
+ export type EndpointResolverOptions = {
23
23
  endpointParams: EndpointParams;
24
24
  logger?: Logger;
25
25
  };
26
- export declare type ReferenceRecord = Record<string, FunctionReturn>;
27
- export declare type EvaluateOptions = EndpointResolverOptions & {
26
+ export type ReferenceRecord = Record<string, FunctionReturn>;
27
+ export type EvaluateOptions = EndpointResolverOptions & {
28
28
  referenceRecord: ReferenceRecord;
29
29
  };
@@ -1,13 +1,13 @@
1
1
  import { EndpointObjectProperty } from "@aws-sdk/types";
2
2
  import { ConditionObject, Expression } from "./shared";
3
- export declare type EndpointObjectProperties = Record<string, EndpointObjectProperty>;
4
- export declare type EndpointObjectHeaders = Record<string, Expression[]>;
5
- export declare type EndpointObject = {
3
+ export type EndpointObjectProperties = Record<string, EndpointObjectProperty>;
4
+ export type EndpointObjectHeaders = Record<string, Expression[]>;
5
+ export type EndpointObject = {
6
6
  url: Expression;
7
7
  properties?: EndpointObjectProperties;
8
8
  headers?: EndpointObjectHeaders;
9
9
  };
10
- export declare type EndpointRuleObject = {
10
+ export type EndpointRuleObject = {
11
11
  type: "endpoint";
12
12
  conditions?: ConditionObject[];
13
13
  endpoint: EndpointObject;
@@ -1,5 +1,5 @@
1
1
  import { ConditionObject, Expression } from "./shared";
2
- export declare type ErrorRuleObject = {
2
+ export type ErrorRuleObject = {
3
3
  type: "error";
4
4
  conditions?: ConditionObject[];
5
5
  error: Expression;
@@ -1,9 +1,9 @@
1
1
  import { RuleSetRules } from "./TreeRuleObject";
2
- export declare type DeprecatedObject = {
2
+ export type DeprecatedObject = {
3
3
  message?: string;
4
4
  since?: string;
5
5
  };
6
- export declare type ParameterObject = {
6
+ export type ParameterObject = {
7
7
  type: "String" | "Boolean";
8
8
  default?: string | boolean;
9
9
  required?: boolean;
@@ -11,7 +11,7 @@ export declare type ParameterObject = {
11
11
  builtIn?: string;
12
12
  deprecated?: DeprecatedObject;
13
13
  };
14
- export declare type RuleSetObject = {
14
+ export type RuleSetObject = {
15
15
  version: string;
16
16
  serviceId?: string;
17
17
  parameters: Record<string, ParameterObject>;
@@ -1,8 +1,8 @@
1
1
  import { EndpointRuleObject } from "./EndpointRuleObject";
2
2
  import { ErrorRuleObject } from "./ErrorRuleObject";
3
3
  import { ConditionObject } from "./shared";
4
- export declare type RuleSetRules = Array<EndpointRuleObject | ErrorRuleObject | TreeRuleObject>;
5
- export declare type TreeRuleObject = {
4
+ export type RuleSetRules = Array<EndpointRuleObject | ErrorRuleObject | TreeRuleObject>;
5
+ export type TreeRuleObject = {
6
6
  type: "tree";
7
7
  conditions?: ConditionObject[];
8
8
  rules: RuleSetRules;
@@ -1,25 +1,25 @@
1
1
  import { Logger } from "@aws-sdk/types";
2
- export declare type ReferenceObject = {
2
+ export type ReferenceObject = {
3
3
  ref: string;
4
4
  };
5
- export declare type FunctionObject = {
5
+ export type FunctionObject = {
6
6
  fn: string;
7
7
  argv: FunctionArgv;
8
8
  };
9
- export declare type FunctionArgv = Array<Expression | boolean | number>;
10
- export declare type FunctionReturn = string | boolean | number | {
9
+ export type FunctionArgv = Array<Expression | boolean | number>;
10
+ export type FunctionReturn = string | boolean | number | {
11
11
  [key: string]: FunctionReturn;
12
12
  };
13
- export declare type ConditionObject = FunctionObject & {
13
+ export type ConditionObject = FunctionObject & {
14
14
  assign?: string;
15
15
  };
16
- export declare type Expression = string | ReferenceObject | FunctionObject;
17
- export declare type EndpointParams = Record<string, string | boolean>;
18
- export declare type EndpointResolverOptions = {
16
+ export type Expression = string | ReferenceObject | FunctionObject;
17
+ export type EndpointParams = Record<string, string | boolean>;
18
+ export type EndpointResolverOptions = {
19
19
  endpointParams: EndpointParams;
20
20
  logger?: Logger;
21
21
  };
22
- export declare type ReferenceRecord = Record<string, FunctionReturn>;
23
- export declare type EvaluateOptions = EndpointResolverOptions & {
22
+ export type ReferenceRecord = Record<string, FunctionReturn>;
23
+ export type EvaluateOptions = EndpointResolverOptions & {
24
24
  referenceRecord: ReferenceRecord;
25
25
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/util-endpoints",
3
- "version": "3.292.0",
3
+ "version": "3.295.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,8 +21,8 @@
21
21
  },
22
22
  "license": "Apache-2.0",
23
23
  "dependencies": {
24
- "@aws-sdk/types": "3.292.0",
25
- "tslib": "^2.3.1"
24
+ "@aws-sdk/types": "3.295.0",
25
+ "tslib": "^2.5.0"
26
26
  },
27
27
  "engines": {
28
28
  "node": ">=14.0.0"
@@ -49,7 +49,7 @@
49
49
  "downlevel-dts": "0.10.1",
50
50
  "rimraf": "3.0.2",
51
51
  "typedoc": "0.23.23",
52
- "typescript": "~4.6.2"
52
+ "typescript": "~4.9.5"
53
53
  },
54
54
  "typedoc": {
55
55
  "entryPoint": "src/index.ts"