oci-common 2.12.1 → 2.13.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.
@@ -4,7 +4,9 @@
4
4
  */
5
5
  import { Region } from "./region";
6
6
  export declare class EndpointBuilder {
7
- static createEndpointFromRegion(template: string, region: Region): string;
8
- static createEndpointFromRegionId(template: string, regionId: string): string;
7
+ static createEndpointFromRegion(template: string, region: Region, endpointServiceName?: string): string;
8
+ static createEndpointFromRegionId(template: string, regionId: string, endpointServiceName?: string): string;
9
9
  static createEndpointFromRegionIdAndSecondLevelDomain(template: string, regionId: string, secondLevelDomain: string): string;
10
+ static createEndpointForDottedRegion(template: string, // https://identity.{region}.oci.{secondLevelDomain}
11
+ regionId: string, endpointServiceName?: string): string;
10
12
  }
@@ -8,15 +8,25 @@ exports.EndpointBuilder = void 0;
8
8
  const region_1 = require("./region");
9
9
  const realm_1 = require("./realm");
10
10
  class EndpointBuilder {
11
- static createEndpointFromRegion(template, region) {
11
+ static createEndpointFromRegion(template, region, endpointServiceName) {
12
12
  const regionId = region.regionId;
13
13
  const secondLevelDomain = region.realm.secondLevelDomain;
14
- return EndpointBuilder.createEndpointFromRegionIdAndSecondLevelDomain(template, regionId, secondLevelDomain);
14
+ // If regionId is a dotted region, call createEndpointForDottedRegion
15
+ if (regionId.includes(".")) {
16
+ return EndpointBuilder.createEndpointForDottedRegion(template, regionId, endpointServiceName);
17
+ }
18
+ else {
19
+ // Default to using regionId and secondLevelDomain
20
+ return EndpointBuilder.createEndpointFromRegionIdAndSecondLevelDomain(template, regionId, secondLevelDomain);
21
+ }
15
22
  }
16
- static createEndpointFromRegionId(template, regionId) {
23
+ static createEndpointFromRegionId(template, regionId, endpointServiceName) {
24
+ // If regionId is a dotted region, call createEndpointForDottedRegion
25
+ if (regionId.includes("."))
26
+ return EndpointBuilder.createEndpointForDottedRegion(template, regionId, endpointServiceName);
17
27
  const region = region_1.Region.fromRegionId(regionId);
18
28
  if (region)
19
- return EndpointBuilder.createEndpointFromRegion(template, region);
29
+ return EndpointBuilder.createEndpointFromRegion(template, region, endpointServiceName);
20
30
  // If regionId does not return a known region, check to see if there is a fallback second level domain from env.OCI_DEFAULT_REALM
21
31
  // If no fallback for second level domain, default it to OC1's second level domain.
22
32
  const fallbackSecondLevelDomain = process.env["OCI_DEFAULT_REALM"];
@@ -35,6 +45,16 @@ class EndpointBuilder {
35
45
  throw Error("secondLevelDomain can not be undefined or empty");
36
46
  return template.replace("{secondLevelDomain}", secondLevelDomain).replace("{region}", regionId);
37
47
  }
48
+ static createEndpointForDottedRegion(template, // https://identity.{region}.oci.{secondLevelDomain}
49
+ regionId, endpointServiceName) {
50
+ if (endpointServiceName) {
51
+ return `https://${endpointServiceName}.${regionId}`;
52
+ }
53
+ else {
54
+ const serviceName = template.substring(template.lastIndexOf("/") + 1, template.indexOf(".")); // Extract service name
55
+ return `https://${serviceName}.${regionId}`;
56
+ }
57
+ }
38
58
  }
39
59
  exports.EndpointBuilder = EndpointBuilder;
40
60
  //# sourceMappingURL=endpoint-builder.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"endpoint-builder.js","sourceRoot":"","sources":["../../../../lib/endpoint-builder.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qCAAkC;AAClC,mCAAgC;AAEhC,MAAa,eAAe;IACnB,MAAM,CAAC,wBAAwB,CAAC,QAAgB,EAAE,MAAc;QACrE,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;QACjC,MAAM,iBAAiB,GAAG,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC;QACzD,OAAO,eAAe,CAAC,8CAA8C,CACnE,QAAQ,EACR,QAAQ,EACR,iBAAiB,CAClB,CAAC;IACJ,CAAC;IAEM,MAAM,CAAC,0BAA0B,CAAC,QAAgB,EAAE,QAAgB;QACzE,MAAM,MAAM,GAAG,eAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QAC7C,IAAI,MAAM;YAAE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AM,KAAK,CAAC,wCAAwC,CAAC,CAAC;QACrE,IAAI,CAAC,iBAAiB;YAAE,MAAM,KAAK,CAAC,iDAAiD,CAAC,CAAC;QACvF,OAAO,QAAQ,CAAC,OAAO,CAAC,qBAAqB,EAAE,iBAAiB,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IAClG,CAAC;IAEM,MAAM,CAAC,6BAA6B,CACzC,QAAgB,EAAE,oDAAoD;IACtE,QAAgB,EAChB,mBAA4B;QAE5B,IAAI,mBAAmB,EAAE;YACvB,OAAO,WAAW,mBAAmB,IAAI,QAAQ,EAAE,CAAC;SACrD;aAAM;YACL,MAAM,WAAW,GAAG,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,uBAAuB;YACrH,OAAO,WAAW,WAAW,IAAI,QAAQ,EAAE,CAAC;SAC7C;IACH,CAAC;CACF;AA1ED,0CA0EC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oci-common",
3
- "version": "2.12.1",
3
+ "version": "2.13.0",
4
4
  "description": "OCI Common module for NodeJS",
5
5
  "repository": {
6
6
  "type": "git",