@aws-sdk/util-endpoints 3.290.0 → 3.293.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 declare 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,2 +1,28 @@
1
1
  import { EndpointPartition } from "@aws-sdk/types";
2
+ export declare 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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/util-endpoints",
3
- "version": "3.290.0",
3
+ "version": "3.293.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.290.0",
24
+ "@aws-sdk/types": "3.292.0",
25
25
  "tslib": "^2.3.1"
26
26
  },
27
27
  "engines": {
@@ -48,7 +48,10 @@
48
48
  "concurrently": "7.0.0",
49
49
  "downlevel-dts": "0.10.1",
50
50
  "rimraf": "3.0.2",
51
- "typedoc": "0.19.2",
51
+ "typedoc": "0.23.23",
52
52
  "typescript": "~4.6.2"
53
+ },
54
+ "typedoc": {
55
+ "entryPoint": "src/index.ts"
53
56
  }
54
57
  }