@redocly/openapi-core 1.15.0 → 1.17.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.
Files changed (45) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/lib/bundle.d.ts +1 -1
  3. package/lib/bundle.js +2 -2
  4. package/lib/config/config.d.ts +0 -6
  5. package/lib/config/config.js +1 -19
  6. package/lib/config/load.d.ts +12 -3
  7. package/lib/config/load.js +34 -14
  8. package/lib/config/utils.d.ts +1 -0
  9. package/lib/config/utils.js +5 -1
  10. package/lib/decorators/common/registry-dependencies.js +2 -2
  11. package/lib/index.d.ts +3 -2
  12. package/lib/index.js +17 -2
  13. package/lib/lint.d.ts +1 -0
  14. package/lib/lint.js +3 -7
  15. package/lib/oas-types.d.ts +1 -1
  16. package/lib/redocly/domains.d.ts +14 -0
  17. package/lib/redocly/domains.js +41 -0
  18. package/lib/redocly/index.d.ts +1 -2
  19. package/lib/redocly/index.js +14 -24
  20. package/lib/redocly/registry-api.d.ts +2 -2
  21. package/lib/redocly/registry-api.js +9 -9
  22. package/lib/types/oas3_1.js +1 -0
  23. package/lib/types/redocly-yaml.d.ts +3 -1
  24. package/lib/types/redocly-yaml.js +34 -36
  25. package/lib/utils.d.ts +2 -0
  26. package/lib/utils.js +7 -1
  27. package/package.json +4 -2
  28. package/src/__tests__/lint.test.ts +22 -12
  29. package/src/bundle.ts +1 -1
  30. package/src/config/__tests__/load.test.ts +86 -61
  31. package/src/config/config.ts +1 -23
  32. package/src/config/load.ts +51 -24
  33. package/src/config/utils.ts +4 -0
  34. package/src/decorators/common/registry-dependencies.ts +1 -1
  35. package/src/index.ts +4 -1
  36. package/src/lint.ts +10 -9
  37. package/src/redocly/__tests__/domains.test.ts +52 -0
  38. package/src/redocly/__tests__/redocly-client.test.ts +5 -3
  39. package/src/redocly/domains.ts +48 -0
  40. package/src/redocly/index.ts +14 -24
  41. package/src/redocly/registry-api.ts +25 -31
  42. package/src/types/oas3_1.ts +1 -0
  43. package/src/types/redocly-yaml.ts +32 -33
  44. package/src/utils.ts +7 -1
  45. package/tsconfig.tsbuildinfo +1 -1
package/src/index.ts CHANGED
@@ -4,6 +4,7 @@ export {
4
4
  slash,
5
5
  doesYamlFileExist,
6
6
  isTruthy,
7
+ getProxyAgent,
7
8
  pause,
8
9
  } from './utils';
9
10
  export { Oas3_1Types } from './types/oas3_1';
@@ -48,7 +49,9 @@ export {
48
49
  ResolvedApi,
49
50
  } from './config';
50
51
 
51
- export { RedoclyClient, isRedoclyRegistryURL } from './redocly';
52
+ export { RedoclyClient } from './redocly';
53
+
54
+ export * from './redocly/domains';
52
55
 
53
56
  export {
54
57
  Source,
package/src/lint.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  import { BaseResolver, resolveDocument, makeDocumentFromString } from './resolve';
2
2
  import { normalizeVisitors } from './visitors';
3
3
  import { walkDocument } from './walk';
4
- import { StyleguideConfig, Config, initRules, defaultPlugin, resolvePlugins } from './config';
4
+ import { StyleguideConfig, Config, initRules } from './config';
5
5
  import { normalizeTypes } from './types';
6
6
  import { releaseAjvInstance } from './rules/ajv';
7
7
  import { SpecVersion, getMajorSpecVersion, detectSpec, getTypes } from './oas-types';
8
- import { ConfigTypes } from './types/redocly-yaml';
8
+ import { createConfigTypes } from './types/redocly-yaml';
9
9
  import { Spec } from './rules/common/spec';
10
10
  import { NoUnresolvedRefs } from './rules/no-unresolved-refs';
11
11
 
@@ -13,6 +13,7 @@ import type { Document, ResolvedRefMap } from './resolve';
13
13
  import type { ProblemSeverity, WalkContext } from './walk';
14
14
  import type { NodeType } from './types';
15
15
  import type { NestedVisitObject, Oas3Visitor, RuleInstanceConfig } from './visitors';
16
+ import { rootRedoclyConfigSchema } from '@redocly/config';
16
17
 
17
18
  export async function lint(opts: {
18
19
  ref: string;
@@ -109,25 +110,25 @@ export async function lintDocument(opts: {
109
110
 
110
111
  export async function lintConfig(opts: {
111
112
  document: Document;
113
+ config: Config;
112
114
  resolvedRefMap?: ResolvedRefMap;
113
115
  severity?: ProblemSeverity;
114
116
  externalRefResolver?: BaseResolver;
115
117
  externalConfigTypes?: Record<string, NodeType>;
116
118
  }) {
117
- const { document, severity, externalRefResolver = new BaseResolver() } = opts;
119
+ const { document, severity, externalRefResolver = new BaseResolver(), config } = opts;
118
120
 
119
121
  const ctx: WalkContext = {
120
122
  problems: [],
121
123
  oasVersion: SpecVersion.OAS3_0,
122
124
  visitorsData: {},
123
125
  };
124
- const plugins = resolvePlugins([defaultPlugin]);
125
- const config = new StyleguideConfig({
126
- plugins,
127
- rules: { spec: 'error' },
128
- });
129
126
 
130
- const types = normalizeTypes(opts.externalConfigTypes || ConfigTypes, config);
127
+ const types = normalizeTypes(
128
+ opts.externalConfigTypes || createConfigTypes(rootRedoclyConfigSchema, config),
129
+ { doNotResolveExamples: config.styleguide.doNotResolveExamples }
130
+ );
131
+
131
132
  const rules: (RuleInstanceConfig & {
132
133
  visitor: NestedVisitObject<unknown, Oas3Visitor | Oas3Visitor[]>;
133
134
  })[] = [
@@ -0,0 +1,52 @@
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,3 +1,4 @@
1
+ import { setRedoclyDomain } from '../domains';
1
2
  import { RedoclyClient } from '../index';
2
3
 
3
4
  jest.mock('node-fetch', () => ({
@@ -16,6 +17,7 @@ describe('RedoclyClient', () => {
16
17
 
17
18
  afterEach(() => {
18
19
  delete process.env.REDOCLY_DOMAIN;
20
+ setRedoclyDomain('');
19
21
  });
20
22
 
21
23
  it('should resolve the US domain by default', () => {
@@ -40,19 +42,19 @@ describe('RedoclyClient', () => {
40
42
  });
41
43
 
42
44
  it('should resolve domain by EU region prioritizing flag over env variable', () => {
43
- process.env.REDOCLY_DOMAIN = testRedoclyDomain;
45
+ setRedoclyDomain(testRedoclyDomain);
44
46
  const client = new RedoclyClient('eu');
45
47
  expect(client.domain).toBe(REDOCLY_DOMAIN_EU);
46
48
  });
47
49
 
48
50
  it('should resolve domain by US region prioritizing flag over env variable', () => {
49
- process.env.REDOCLY_DOMAIN = testRedoclyDomain;
51
+ setRedoclyDomain(testRedoclyDomain);
50
52
  const client = new RedoclyClient('us');
51
53
  expect(client.domain).toBe(REDOCLY_DOMAIN_US);
52
54
  });
53
55
 
54
56
  it('should resolve domain by US region when REDOCLY_DOMAIN consists EU domain', () => {
55
- process.env.REDOCLY_DOMAIN = REDOCLY_DOMAIN_EU;
57
+ setRedoclyDomain(REDOCLY_DOMAIN_EU);
56
58
  const client = new RedoclyClient();
57
59
  expect(client.getRegion()).toBe('eu');
58
60
  });
@@ -0,0 +1,48 @@
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
+ }
@@ -2,13 +2,19 @@ import { existsSync, readFileSync, writeFileSync, unlinkSync } from 'fs';
2
2
  import { resolve } from 'path';
3
3
  import { homedir } from 'os';
4
4
  import { RegistryApi } from './registry-api';
5
- import { DEFAULT_REGION, DOMAINS, AVAILABLE_REGIONS } from '../config/config';
6
5
  import { env } from '../env';
7
6
  import { RegionalToken, RegionalTokenWithValidity } from './redocly-client-types';
8
7
  import { isNotEmptyObject } from '../utils';
9
8
  import { colorize } from '../logger';
10
9
 
11
10
  import type { AccessTokens, Region } from '../config/types';
11
+ import {
12
+ AVAILABLE_REGIONS,
13
+ DEFAULT_REGION,
14
+ DOMAINS,
15
+ getRedoclyDomain,
16
+ setRedoclyDomain,
17
+ } from './domains';
12
18
 
13
19
  export const TOKEN_FILENAME = '.redocly-config.json';
14
20
 
@@ -23,7 +29,7 @@ export class RedoclyClient {
23
29
  this.loadTokens();
24
30
  this.domain = region ? DOMAINS[region] : env.REDOCLY_DOMAIN || DOMAINS[DEFAULT_REGION];
25
31
 
26
- env.REDOCLY_DOMAIN = this.domain; // isRedoclyRegistryURL depends on the value to be set
32
+ setRedoclyDomain(this.domain);
27
33
  this.registryApi = new RegistryApi(this.accessTokens, this.region);
28
34
  }
29
35
 
@@ -36,9 +42,9 @@ export class RedoclyClient {
36
42
  );
37
43
  }
38
44
 
39
- if (env.REDOCLY_DOMAIN) {
45
+ if (getRedoclyDomain()) {
40
46
  return (AVAILABLE_REGIONS.find(
41
- (region) => DOMAINS[region as Region] === env.REDOCLY_DOMAIN
47
+ (region) => DOMAINS[region as Region] === getRedoclyDomain()
42
48
  ) || DEFAULT_REGION) as Region;
43
49
  }
44
50
  return region || DEFAULT_REGION;
@@ -96,7 +102,7 @@ export class RedoclyClient {
96
102
  const allTokens = this.getAllTokens();
97
103
 
98
104
  const verifiedTokens = await Promise.allSettled(
99
- allTokens.map(({ token, region }) => this.verifyToken(token, region))
105
+ allTokens.map(({ token }) => this.verifyToken(token))
100
106
  );
101
107
 
102
108
  return allTokens
@@ -120,7 +126,7 @@ export class RedoclyClient {
120
126
  }
121
127
 
122
128
  try {
123
- await this.verifyToken(accessToken, this.region);
129
+ await this.verifyToken(accessToken);
124
130
 
125
131
  return true;
126
132
  } catch (err) {
@@ -138,17 +144,16 @@ export class RedoclyClient {
138
144
 
139
145
  async verifyToken(
140
146
  accessToken: string,
141
- region: Region,
142
147
  verbose: boolean = false
143
148
  ): Promise<{ viewerId: string; organizations: string[] }> {
144
- return this.registryApi.authStatus(accessToken, region, verbose);
149
+ return this.registryApi.authStatus(accessToken, verbose);
145
150
  }
146
151
 
147
152
  async login(accessToken: string, verbose: boolean = false) {
148
153
  const credentialsPath = resolve(homedir(), TOKEN_FILENAME);
149
154
 
150
155
  try {
151
- await this.verifyToken(accessToken, this.region, verbose);
156
+ await this.verifyToken(accessToken, verbose);
152
157
  } catch (err) {
153
158
  throw new Error('Authorization failed. Please check if you entered a valid API key.');
154
159
  }
@@ -170,18 +175,3 @@ export class RedoclyClient {
170
175
  }
171
176
  }
172
177
  }
173
-
174
- export function isRedoclyRegistryURL(link: string): boolean {
175
- const domain = env.REDOCLY_DOMAIN || DOMAINS[DEFAULT_REGION];
176
-
177
- const legacyDomain = domain === 'redocly.com' ? 'redoc.ly' : domain;
178
-
179
- if (
180
- !link.startsWith(`https://api.${domain}/registry/`) &&
181
- !link.startsWith(`https://api.${legacyDomain}/registry/`)
182
- ) {
183
- return false;
184
- }
185
-
186
- return true;
187
- }
@@ -6,8 +6,8 @@ import type {
6
6
  PushApiParams,
7
7
  } from './registry-api-types';
8
8
  import type { AccessTokens, Region } from '../config/types';
9
- import { DEFAULT_REGION, DOMAINS } from '../config/config';
10
- import { isNotEmptyObject } from '../utils';
9
+ import { getProxyAgent, isNotEmptyObject } from '../utils';
10
+ import { getRedoclyDomain } from './domains';
11
11
 
12
12
  const version = require('../../package.json').version;
13
13
 
@@ -18,8 +18,8 @@ export class RegistryApi {
18
18
  return isNotEmptyObject(this.accessTokens) && this.accessTokens[this.region];
19
19
  }
20
20
 
21
- getBaseUrl(region: Region = DEFAULT_REGION) {
22
- return `https://api.${DOMAINS[region]}/registry`;
21
+ getBaseUrl() {
22
+ return `https://api.${getRedoclyDomain()}/registry`;
23
23
  }
24
24
 
25
25
  setAccessTokens(accessTokens: AccessTokens) {
@@ -27,7 +27,7 @@ export class RegistryApi {
27
27
  return this;
28
28
  }
29
29
 
30
- private async request(path = '', options: RequestInit = {}, region?: Region) {
30
+ private async request(path = '', options: RequestInit = {}) {
31
31
  const currentCommand =
32
32
  typeof process !== 'undefined' ? process.env?.REDOCLY_CLI_COMMAND || '' : '';
33
33
  const redoclyEnv = typeof process !== 'undefined' ? process.env?.REDOCLY_ENVIRONMENT || '' : '';
@@ -42,8 +42,8 @@ export class RegistryApi {
42
42
  }
43
43
 
44
44
  const response = await fetch(
45
- `${this.getBaseUrl(region)}${path}`,
46
- Object.assign({}, options, { headers })
45
+ `${this.getBaseUrl()}${path}`,
46
+ Object.assign({}, options, { headers, agent: getProxyAgent() })
47
47
  );
48
48
 
49
49
  if (response.status === 401) {
@@ -60,11 +60,10 @@ export class RegistryApi {
60
60
 
61
61
  async authStatus(
62
62
  accessToken: string,
63
- region: Region,
64
63
  verbose = false
65
64
  ): Promise<{ viewerId: string; organizations: string[] }> {
66
65
  try {
67
- const response = await this.request('', { headers: { authorization: accessToken } }, region);
66
+ const response = await this.request('', { headers: { authorization: accessToken } });
68
67
 
69
68
  return await response.json();
70
69
  } catch (error) {
@@ -97,8 +96,7 @@ export class RegistryApi {
97
96
  filename,
98
97
  isUpsert,
99
98
  }),
100
- },
101
- this.region
99
+ }
102
100
  );
103
101
 
104
102
  if (response.ok) {
@@ -120,26 +118,22 @@ export class RegistryApi {
120
118
  batchId,
121
119
  batchSize,
122
120
  }: PushApiParams) {
123
- const response = await this.request(
124
- `/${organizationId}/${name}/${version}`,
125
- {
126
- method: 'PUT',
127
- headers: {
128
- 'content-type': 'application/json',
129
- authorization: this.accessToken,
130
- } as HeadersInit,
131
- body: JSON.stringify({
132
- rootFilePath,
133
- filePaths,
134
- branch,
135
- isUpsert,
136
- isPublic,
137
- batchId,
138
- batchSize,
139
- }),
140
- },
141
- this.region
142
- );
121
+ const response = await this.request(`/${organizationId}/${name}/${version}`, {
122
+ method: 'PUT',
123
+ headers: {
124
+ 'content-type': 'application/json',
125
+ authorization: this.accessToken,
126
+ } as HeadersInit,
127
+ body: JSON.stringify({
128
+ rootFilePath,
129
+ filePaths,
130
+ branch,
131
+ isUpsert,
132
+ isPublic,
133
+ batchId,
134
+ batchSize,
135
+ }),
136
+ });
143
137
 
144
138
  if (response.ok) {
145
139
  return;
@@ -170,6 +170,7 @@ const Schema: NodeType = {
170
170
  format: { type: 'string' },
171
171
  contentEncoding: { type: 'string' },
172
172
  contentMediaType: { type: 'string' },
173
+ contentSchema: 'Schema',
173
174
  default: null,
174
175
  readOnly: { type: 'boolean' },
175
176
  writeOnly: { type: 'boolean' },
@@ -5,6 +5,8 @@ import { getNodeTypesFromJSONSchema } from './json-schema-adapter';
5
5
 
6
6
  import type { NodeType } from '.';
7
7
  import type { JSONSchema } from 'json-schema-to-ts';
8
+ import { SpecVersion, getTypes } from '../oas-types';
9
+ import { Config } from '../config';
8
10
 
9
11
  const builtInCommonRules = [
10
12
  'spec',
@@ -222,8 +224,6 @@ const oas3_1NodeTypesList = [
222
224
 
223
225
  export type Oas3_1NodeType = typeof oas3_1NodeTypesList[number];
224
226
 
225
- const asyncNodeTypesList = ['Message'] as const;
226
-
227
227
  const ConfigStyleguide: NodeType = {
228
228
  properties: {
229
229
  extends: {
@@ -350,35 +350,28 @@ const Schema: NodeType = {
350
350
  additionalProperties: {},
351
351
  };
352
352
 
353
- const AssertionDefinitionSubject: NodeType = {
354
- properties: {
355
- type: {
356
- enum: [
357
- ...new Set([
358
- 'any',
359
- ...oas2NodeTypesList,
360
- ...oas3NodeTypesList,
361
- ...oas3_1NodeTypesList,
362
- ...asyncNodeTypesList,
363
- 'SpecExtension',
364
- ]),
365
- ],
366
- },
367
- property: (value: unknown) => {
368
- if (Array.isArray(value)) {
369
- return { type: 'array', items: { type: 'string' } };
370
- } else if (value === null) {
371
- return null;
372
- } else {
373
- return { type: 'string' };
374
- }
353
+ function createAssertionDefinitionSubject(nodeNames: string[]): NodeType {
354
+ return {
355
+ properties: {
356
+ type: {
357
+ enum: [...new Set(['any', ...nodeNames, 'SpecExtension'])],
358
+ },
359
+ property: (value: unknown) => {
360
+ if (Array.isArray(value)) {
361
+ return { type: 'array', items: { type: 'string' } };
362
+ } else if (value === null) {
363
+ return null;
364
+ } else {
365
+ return { type: 'string' };
366
+ }
367
+ },
368
+ filterInParentKeys: { type: 'array', items: { type: 'string' } },
369
+ filterOutParentKeys: { type: 'array', items: { type: 'string' } },
370
+ matchParentKeys: { type: 'string' },
375
371
  },
376
- filterInParentKeys: { type: 'array', items: { type: 'string' } },
377
- filterOutParentKeys: { type: 'array', items: { type: 'string' } },
378
- matchParentKeys: { type: 'string' },
379
- },
380
- required: ['type'],
381
- };
372
+ required: ['type'],
373
+ };
374
+ }
382
375
 
383
376
  const AssertionDefinitionAssertions: NodeType = {
384
377
  properties: {
@@ -1057,7 +1050,13 @@ const ConfigMockServer: NodeType = {
1057
1050
  },
1058
1051
  };
1059
1052
 
1060
- export const createConfigTypes = (extraSchemas: JSONSchema) => {
1053
+ export function createConfigTypes(extraSchemas: JSONSchema, config?: Config) {
1054
+ const nodeNames = Object.values(SpecVersion).flatMap((version) => {
1055
+ const types = config?.styleguide
1056
+ ? config.styleguide.extendTypes(getTypes(version), version)
1057
+ : getTypes(version);
1058
+ return Object.keys(types);
1059
+ });
1061
1060
  // Create types based on external schemas
1062
1061
  const nodeTypes = getNodeTypesFromJSONSchema('rootRedoclyConfigSchema', extraSchemas);
1063
1062
 
@@ -1065,9 +1064,10 @@ export const createConfigTypes = (extraSchemas: JSONSchema) => {
1065
1064
  ...CoreConfigTypes,
1066
1065
  ConfigRoot: createConfigRoot(nodeTypes), // This is the REAL config root type
1067
1066
  ConfigApisProperties: createConfigApisProperties(nodeTypes),
1067
+ AssertionDefinitionSubject: createAssertionDefinitionSubject(nodeNames),
1068
1068
  ...nodeTypes,
1069
1069
  };
1070
- };
1070
+ }
1071
1071
 
1072
1072
  const CoreConfigTypes: Record<string, NodeType> = {
1073
1073
  Assert,
@@ -1130,7 +1130,6 @@ const CoreConfigTypes: Record<string, NodeType> = {
1130
1130
  Heading,
1131
1131
  Typography,
1132
1132
  AssertionDefinitionAssertions,
1133
- AssertionDefinitionSubject,
1134
1133
  };
1135
1134
 
1136
1135
  export const ConfigTypes: Record<string, NodeType> = createConfigTypes(rootRedoclyConfigSchema);
package/src/utils.ts CHANGED
@@ -5,9 +5,10 @@ import fetch from 'node-fetch';
5
5
  import * as pluralize from 'pluralize';
6
6
  import { parseYaml } from './js-yaml';
7
7
  import { UserContext } from './walk';
8
- import { HttpResolveConfig } from './config';
9
8
  import { env } from './env';
10
9
  import { logger, colorize } from './logger';
10
+ import { HttpResolveConfig } from './config';
11
+ import { HttpsProxyAgent } from 'https-proxy-agent';
11
12
 
12
13
  export { parseYaml, stringifyYaml } from './js-yaml';
13
14
 
@@ -278,3 +279,8 @@ export async function pause(ms: number): Promise<void> {
278
279
  function getUpdatedFieldName(updatedField: string, updatedObject?: string) {
279
280
  return `${typeof updatedObject !== 'undefined' ? `${updatedObject}.` : ''}${updatedField}`;
280
281
  }
282
+
283
+ export function getProxyAgent() {
284
+ const proxy = process.env.HTTPS_PROXY || process.env.HTTP_PROXY;
285
+ return proxy ? new HttpsProxyAgent(proxy) : undefined;
286
+ }