@redocly/openapi-core 1.10.0 → 1.10.1

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,14 +0,0 @@
1
- import { Region } from '../config/types';
2
- export declare const DEFAULT_REGION = "us";
3
- export declare const DOMAINS: {
4
- us: string;
5
- eu: string;
6
- };
7
- export declare const AVAILABLE_REGIONS: Region[];
8
- export declare function getDomains(): {
9
- us: string;
10
- eu: string;
11
- };
12
- export declare function setRedoclyDomain(domain: string): void;
13
- export declare function getRedoclyDomain(): string;
14
- export declare function isRedoclyRegistryURL(link: string): boolean;
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isRedoclyRegistryURL = exports.getRedoclyDomain = exports.setRedoclyDomain = exports.getDomains = exports.AVAILABLE_REGIONS = exports.DOMAINS = exports.DEFAULT_REGION = void 0;
4
- let redoclyDomain = 'redocly.com';
5
- exports.DEFAULT_REGION = 'us';
6
- exports.DOMAINS = getDomains();
7
- exports.AVAILABLE_REGIONS = Object.keys(exports.DOMAINS);
8
- function getDomains() {
9
- const domains = {
10
- us: 'redocly.com',
11
- eu: 'eu.redocly.com',
12
- };
13
- // FIXME: temporary fix for our lab environments
14
- const domain = redoclyDomain;
15
- if (domain === null || domain === void 0 ? void 0 : domain.endsWith('.redocly.host')) {
16
- domains[domain.split('.')[0]] = domain;
17
- }
18
- if (domain === 'redoc.online') {
19
- domains[domain] = domain;
20
- }
21
- return domains;
22
- }
23
- exports.getDomains = getDomains;
24
- function setRedoclyDomain(domain) {
25
- redoclyDomain = domain;
26
- }
27
- exports.setRedoclyDomain = setRedoclyDomain;
28
- function getRedoclyDomain() {
29
- return redoclyDomain;
30
- }
31
- exports.getRedoclyDomain = getRedoclyDomain;
32
- function isRedoclyRegistryURL(link) {
33
- const domain = getRedoclyDomain() || exports.DOMAINS[exports.DEFAULT_REGION];
34
- const legacyDomain = domain === 'redocly.com' ? 'redoc.ly' : domain;
35
- if (!link.startsWith(`https://api.${domain}/registry/`) &&
36
- !link.startsWith(`https://api.${legacyDomain}/registry/`)) {
37
- return false;
38
- }
39
- return true;
40
- }
41
- exports.isRedoclyRegistryURL = isRedoclyRegistryURL;
@@ -1,52 +0,0 @@
1
- import { RedoclyClient } from '../../index';
2
- import { setRedoclyDomain, getRedoclyDomain, getDomains, AVAILABLE_REGIONS } from '../domains';
3
-
4
- describe('domains', () => {
5
- const REDOCLY_DOMAIN_US = 'redocly.com';
6
- const TEST_DOMAIN = 'redoclyDomain.com';
7
- const TEST_LAB_DOMAIN = 'lab.redocly.host';
8
- const TEST_REDOC_ONLINE_DOMAIN = 'redoc.online';
9
-
10
- afterEach(() => {
11
- delete process.env.REDOCLY_DOMAIN;
12
- setRedoclyDomain('');
13
- });
14
-
15
- it('should resolve the US domain by default', () => {
16
- expect(getRedoclyDomain()).toBe(REDOCLY_DOMAIN_US);
17
- });
18
-
19
- it('should resolve the US and EU regions by default', () => {
20
- expect(AVAILABLE_REGIONS).toStrictEqual(['us', 'eu']);
21
- });
22
-
23
- it('should resolve the specified domain if used with setter', () => {
24
- setRedoclyDomain(TEST_DOMAIN);
25
- expect(getRedoclyDomain()).toBe(TEST_DOMAIN);
26
- });
27
-
28
- it('should resolve the specified domain provided in environmental variable, after initializing RedoclyClient', () => {
29
- process.env.REDOCLY_DOMAIN = TEST_DOMAIN;
30
- const client = new RedoclyClient();
31
- expect(getRedoclyDomain()).toBe(TEST_DOMAIN);
32
- expect(client.domain).toBe(TEST_DOMAIN);
33
- });
34
-
35
- it('should return correct object when redocly domain is set to lab env', () => {
36
- setRedoclyDomain(TEST_LAB_DOMAIN);
37
- const domains = getDomains();
38
- expect(domains).toEqual({ us: 'redocly.com', eu: 'eu.redocly.com', lab: 'lab.redocly.host' });
39
- expect(getRedoclyDomain()).toBe(TEST_LAB_DOMAIN);
40
- });
41
-
42
- it('should return correct object when redocly domain is set to redoc.online env', () => {
43
- setRedoclyDomain(TEST_REDOC_ONLINE_DOMAIN);
44
- const domains = getDomains();
45
- expect(domains).toEqual({
46
- us: 'redocly.com',
47
- eu: 'eu.redocly.com',
48
- 'redoc.online': 'redoc.online',
49
- });
50
- expect(getRedoclyDomain()).toBe(TEST_REDOC_ONLINE_DOMAIN);
51
- });
52
- });
@@ -1,48 +0,0 @@
1
- import { Region } from '../config/types';
2
-
3
- let redoclyDomain = 'redocly.com';
4
-
5
- export const DEFAULT_REGION = 'us';
6
-
7
- export const DOMAINS = getDomains();
8
- export const AVAILABLE_REGIONS = Object.keys(DOMAINS) as Region[];
9
-
10
- export function getDomains() {
11
- const domains: { [region in Region]: string } = {
12
- us: 'redocly.com',
13
- eu: 'eu.redocly.com',
14
- };
15
-
16
- // FIXME: temporary fix for our lab environments
17
- const domain = redoclyDomain;
18
- if (domain?.endsWith('.redocly.host')) {
19
- domains[domain.split('.')[0] as Region] = domain;
20
- }
21
- if (domain === 'redoc.online') {
22
- domains[domain as Region] = domain;
23
- }
24
- return domains;
25
- }
26
-
27
- export function setRedoclyDomain(domain: string) {
28
- redoclyDomain = domain;
29
- }
30
-
31
- export function getRedoclyDomain(): string {
32
- return redoclyDomain;
33
- }
34
-
35
- export function isRedoclyRegistryURL(link: string): boolean {
36
- const domain = getRedoclyDomain() || DOMAINS[DEFAULT_REGION];
37
-
38
- const legacyDomain = domain === 'redocly.com' ? 'redoc.ly' : domain;
39
-
40
- if (
41
- !link.startsWith(`https://api.${domain}/registry/`) &&
42
- !link.startsWith(`https://api.${legacyDomain}/registry/`)
43
- ) {
44
- return false;
45
- }
46
-
47
- return true;
48
- }