@redocly/theme 0.67.0-next.1 → 0.67.0-next.2
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.
- package/lib/ext/configure-helpers.d.ts +35 -0
- package/lib/ext/configure-helpers.js +3 -0
- package/lib/ext/configure.d.ts +3 -25
- package/lib/ext/configure.js +16 -0
- package/lib/ext/helpers/is-direct-configure-request-values.d.ts +15 -0
- package/lib/ext/helpers/is-direct-configure-request-values.js +42 -0
- package/lib/ext/use-configure-replay.d.ts +1 -1
- package/package.json +2 -2
- package/src/ext/configure-helpers.ts +45 -0
- package/src/ext/configure.ts +6 -26
- package/src/ext/helpers/is-direct-configure-request-values.ts +53 -0
- package/src/ext/use-configure-replay.ts +3 -3
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export type SecurityDetails = {
|
|
2
|
+
password?: string;
|
|
3
|
+
username?: string;
|
|
4
|
+
token?: {
|
|
5
|
+
token_type?: string;
|
|
6
|
+
access_token: string;
|
|
7
|
+
};
|
|
8
|
+
client_id?: string;
|
|
9
|
+
client_secret?: string;
|
|
10
|
+
scopes?: string[];
|
|
11
|
+
};
|
|
12
|
+
export type ConfigureInputHintAction = {
|
|
13
|
+
label: string;
|
|
14
|
+
action: () => void;
|
|
15
|
+
};
|
|
16
|
+
export type ConfigureInputHint = {
|
|
17
|
+
title: string;
|
|
18
|
+
text: string;
|
|
19
|
+
actions?: ConfigureInputHintAction[];
|
|
20
|
+
};
|
|
21
|
+
export type ConfigureRequestValues = {
|
|
22
|
+
headers?: Record<string, string>;
|
|
23
|
+
body?: Record<string, any>;
|
|
24
|
+
query?: Record<string, string>;
|
|
25
|
+
path?: Record<string, string>;
|
|
26
|
+
cookie?: Record<string, string>;
|
|
27
|
+
security?: Record<string, SecurityDetails>;
|
|
28
|
+
envVariables?: Record<string, string>;
|
|
29
|
+
serverVariables?: Record<string, string>;
|
|
30
|
+
inputHints?: Record<string, ConfigureInputHint>;
|
|
31
|
+
};
|
|
32
|
+
export type ConfigureServerRequestValues = {
|
|
33
|
+
[serverUrl: string]: ConfigureRequestValues;
|
|
34
|
+
};
|
|
35
|
+
export type ConfigureReplayConfig = ConfigureRequestValues | ConfigureServerRequestValues | null | undefined;
|
package/lib/ext/configure.d.ts
CHANGED
|
@@ -1,28 +1,7 @@
|
|
|
1
1
|
import type { UserClaims, OpenAPIServer } from '../core/types';
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
token?: {
|
|
6
|
-
token_type?: string;
|
|
7
|
-
access_token: string;
|
|
8
|
-
};
|
|
9
|
-
client_id?: string;
|
|
10
|
-
client_secret?: string;
|
|
11
|
-
scopes?: string[];
|
|
12
|
-
};
|
|
13
|
-
export type ConfigureRequestValues = {
|
|
14
|
-
headers?: Record<string, string>;
|
|
15
|
-
body?: Record<string, any>;
|
|
16
|
-
query?: Record<string, string>;
|
|
17
|
-
path?: Record<string, string>;
|
|
18
|
-
cookie?: Record<string, string>;
|
|
19
|
-
security?: Record<string, SecurityDetails>;
|
|
20
|
-
envVariables?: Record<string, string>;
|
|
21
|
-
serverVariables?: Record<string, string>;
|
|
22
|
-
};
|
|
23
|
-
export type ConfigureServerRequestValues = {
|
|
24
|
-
[serverUrl: string]: ConfigureRequestValues;
|
|
25
|
-
};
|
|
2
|
+
export * from '../ext/configure-helpers';
|
|
3
|
+
export * from '../ext/helpers/is-direct-configure-request-values';
|
|
4
|
+
import type { ConfigureRequestValues, ConfigureServerRequestValues } from '../ext/configure-helpers';
|
|
26
5
|
type Configure = {
|
|
27
6
|
requestValues?: ConfigureRequestValues | ConfigureServerRequestValues;
|
|
28
7
|
};
|
|
@@ -38,4 +17,3 @@ type ContextProps = {
|
|
|
38
17
|
servers: OpenAPIServer[];
|
|
39
18
|
};
|
|
40
19
|
export declare function configure(_context: ContextProps): Configure;
|
|
41
|
-
export {};
|
package/lib/ext/configure.js
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
17
|
exports.configure = configure;
|
|
18
|
+
__exportStar(require("../ext/configure-helpers"), exports);
|
|
19
|
+
__exportStar(require("../ext/helpers/is-direct-configure-request-values"), exports);
|
|
4
20
|
function configure(_context) {
|
|
5
21
|
// const exampleDefaultRequestValues: ConfigureRequestValues = {
|
|
6
22
|
// body: {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ConfigureRequestValues, ConfigureServerRequestValues } from '../../ext/configure-helpers';
|
|
2
|
+
/**
|
|
3
|
+
* Type guard that distinguishes a direct {@link ConfigureRequestValues} payload (request
|
|
4
|
+
* values that apply to every server) from a {@link ConfigureServerRequestValues} payload
|
|
5
|
+
* (request values keyed by server URL).
|
|
6
|
+
*
|
|
7
|
+
* A payload is treated as server-keyed when at least one top-level key is *not* a known
|
|
8
|
+
* request-value key (e.g. `headers`, `security`, `inputHints`) and its value looks like a
|
|
9
|
+
* nested {@link ConfigureRequestValues}. This keeps mixed shapes — e.g. server-keyed values
|
|
10
|
+
* alongside a top-level `inputHints` sibling — classified as server-keyed.
|
|
11
|
+
*
|
|
12
|
+
* @param value - The configure payload returned from `getReplayConfiguration`.
|
|
13
|
+
* @returns `true` when `value` is a direct {@link ConfigureRequestValues}, narrowing the type.
|
|
14
|
+
*/
|
|
15
|
+
export declare function isDirectConfigureRequestValues(value: ConfigureRequestValues | ConfigureServerRequestValues): value is ConfigureRequestValues;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isDirectConfigureRequestValues = isDirectConfigureRequestValues;
|
|
4
|
+
const CONFIGURE_REQUEST_VALUE_KEYS = [
|
|
5
|
+
'headers',
|
|
6
|
+
'body',
|
|
7
|
+
'query',
|
|
8
|
+
'path',
|
|
9
|
+
'cookie',
|
|
10
|
+
'security',
|
|
11
|
+
'envVariables',
|
|
12
|
+
'serverVariables',
|
|
13
|
+
'inputHints',
|
|
14
|
+
];
|
|
15
|
+
const CONFIGURE_REQUEST_VALUE_KEY_SET = new Set(CONFIGURE_REQUEST_VALUE_KEYS);
|
|
16
|
+
function hasConfigureRequestValueKeys(value) {
|
|
17
|
+
return CONFIGURE_REQUEST_VALUE_KEYS.some((key) => key in value);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Type guard that distinguishes a direct {@link ConfigureRequestValues} payload (request
|
|
21
|
+
* values that apply to every server) from a {@link ConfigureServerRequestValues} payload
|
|
22
|
+
* (request values keyed by server URL).
|
|
23
|
+
*
|
|
24
|
+
* A payload is treated as server-keyed when at least one top-level key is *not* a known
|
|
25
|
+
* request-value key (e.g. `headers`, `security`, `inputHints`) and its value looks like a
|
|
26
|
+
* nested {@link ConfigureRequestValues}. This keeps mixed shapes — e.g. server-keyed values
|
|
27
|
+
* alongside a top-level `inputHints` sibling — classified as server-keyed.
|
|
28
|
+
*
|
|
29
|
+
* @param value - The configure payload returned from `getReplayConfiguration`.
|
|
30
|
+
* @returns `true` when `value` is a direct {@link ConfigureRequestValues}, narrowing the type.
|
|
31
|
+
*/
|
|
32
|
+
function isDirectConfigureRequestValues(value) {
|
|
33
|
+
const hasServerKeyedValues = Object.entries(value).some(([key, entry]) => !CONFIGURE_REQUEST_VALUE_KEY_SET.has(key) &&
|
|
34
|
+
entry != null &&
|
|
35
|
+
typeof entry === 'object' &&
|
|
36
|
+
hasConfigureRequestValueKeys(entry));
|
|
37
|
+
if (hasServerKeyedValues) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
return hasConfigureRequestValueKeys(value);
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=is-direct-configure-request-values.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ConfigureRequestValues, type ConfigureServerRequestValues } from '../ext/configure';
|
|
2
2
|
import type { UserClaims, OpenAPIServer, OpenAPIInfo } from '../core/types';
|
|
3
3
|
type ContextProps = {
|
|
4
4
|
operation: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/theme",
|
|
3
|
-
"version": "0.67.0-next.
|
|
3
|
+
"version": "0.67.0-next.2",
|
|
4
4
|
"description": "Shared UI components lib",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"theme",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"vitest": "4.1.8",
|
|
64
64
|
"vitest-when": "0.6.2",
|
|
65
65
|
"webpack": "5.105.2",
|
|
66
|
-
"@redocly/realm-asyncapi-sdk": "0.13.0-next.
|
|
66
|
+
"@redocly/realm-asyncapi-sdk": "0.13.0-next.1"
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
69
|
"@tanstack/react-query": "5.62.3",
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export type SecurityDetails = {
|
|
2
|
+
password?: string;
|
|
3
|
+
username?: string;
|
|
4
|
+
token?: {
|
|
5
|
+
token_type?: string;
|
|
6
|
+
access_token: string;
|
|
7
|
+
};
|
|
8
|
+
client_id?: string;
|
|
9
|
+
client_secret?: string;
|
|
10
|
+
scopes?: string[];
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type ConfigureInputHintAction = {
|
|
14
|
+
label: string;
|
|
15
|
+
action: () => void;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type ConfigureInputHint = {
|
|
19
|
+
title: string;
|
|
20
|
+
text: string;
|
|
21
|
+
actions?: ConfigureInputHintAction[];
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type ConfigureRequestValues = {
|
|
25
|
+
headers?: Record<string, string>;
|
|
26
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
27
|
+
body?: Record<string, any>;
|
|
28
|
+
query?: Record<string, string>;
|
|
29
|
+
path?: Record<string, string>;
|
|
30
|
+
cookie?: Record<string, string>;
|
|
31
|
+
security?: Record<string, SecurityDetails>;
|
|
32
|
+
envVariables?: Record<string, string>;
|
|
33
|
+
serverVariables?: Record<string, string>;
|
|
34
|
+
inputHints?: Record<string, ConfigureInputHint>;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export type ConfigureServerRequestValues = {
|
|
38
|
+
[serverUrl: string]: ConfigureRequestValues;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export type ConfigureReplayConfig =
|
|
42
|
+
| ConfigureRequestValues
|
|
43
|
+
| ConfigureServerRequestValues
|
|
44
|
+
| null
|
|
45
|
+
| undefined;
|
package/src/ext/configure.ts
CHANGED
|
@@ -1,32 +1,12 @@
|
|
|
1
1
|
import type { UserClaims, OpenAPIServer } from '@redocly/theme/core/types';
|
|
2
2
|
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
username?: string;
|
|
6
|
-
token?: {
|
|
7
|
-
token_type?: string;
|
|
8
|
-
access_token: string;
|
|
9
|
-
};
|
|
10
|
-
client_id?: string;
|
|
11
|
-
client_secret?: string;
|
|
12
|
-
scopes?: string[];
|
|
13
|
-
};
|
|
3
|
+
export * from '@redocly/theme/ext/configure-helpers';
|
|
4
|
+
export * from '@redocly/theme/ext/helpers/is-direct-configure-request-values';
|
|
14
5
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
query?: Record<string, string>;
|
|
20
|
-
path?: Record<string, string>;
|
|
21
|
-
cookie?: Record<string, string>;
|
|
22
|
-
security?: Record<string, SecurityDetails>;
|
|
23
|
-
envVariables?: Record<string, string>;
|
|
24
|
-
serverVariables?: Record<string, string>;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export type ConfigureServerRequestValues = {
|
|
28
|
-
[serverUrl: string]: ConfigureRequestValues;
|
|
29
|
-
};
|
|
6
|
+
import type {
|
|
7
|
+
ConfigureRequestValues,
|
|
8
|
+
ConfigureServerRequestValues,
|
|
9
|
+
} from '@redocly/theme/ext/configure-helpers';
|
|
30
10
|
|
|
31
11
|
type Configure = {
|
|
32
12
|
requestValues?: ConfigureRequestValues | ConfigureServerRequestValues;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ConfigureRequestValues,
|
|
3
|
+
ConfigureServerRequestValues,
|
|
4
|
+
} from '@redocly/theme/ext/configure-helpers';
|
|
5
|
+
|
|
6
|
+
const CONFIGURE_REQUEST_VALUE_KEYS = [
|
|
7
|
+
'headers',
|
|
8
|
+
'body',
|
|
9
|
+
'query',
|
|
10
|
+
'path',
|
|
11
|
+
'cookie',
|
|
12
|
+
'security',
|
|
13
|
+
'envVariables',
|
|
14
|
+
'serverVariables',
|
|
15
|
+
'inputHints',
|
|
16
|
+
] as const;
|
|
17
|
+
|
|
18
|
+
const CONFIGURE_REQUEST_VALUE_KEY_SET = new Set<string>(CONFIGURE_REQUEST_VALUE_KEYS);
|
|
19
|
+
|
|
20
|
+
function hasConfigureRequestValueKeys(value: object): boolean {
|
|
21
|
+
return CONFIGURE_REQUEST_VALUE_KEYS.some((key) => key in value);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Type guard that distinguishes a direct {@link ConfigureRequestValues} payload (request
|
|
26
|
+
* values that apply to every server) from a {@link ConfigureServerRequestValues} payload
|
|
27
|
+
* (request values keyed by server URL).
|
|
28
|
+
*
|
|
29
|
+
* A payload is treated as server-keyed when at least one top-level key is *not* a known
|
|
30
|
+
* request-value key (e.g. `headers`, `security`, `inputHints`) and its value looks like a
|
|
31
|
+
* nested {@link ConfigureRequestValues}. This keeps mixed shapes — e.g. server-keyed values
|
|
32
|
+
* alongside a top-level `inputHints` sibling — classified as server-keyed.
|
|
33
|
+
*
|
|
34
|
+
* @param value - The configure payload returned from `getReplayConfiguration`.
|
|
35
|
+
* @returns `true` when `value` is a direct {@link ConfigureRequestValues}, narrowing the type.
|
|
36
|
+
*/
|
|
37
|
+
export function isDirectConfigureRequestValues(
|
|
38
|
+
value: ConfigureRequestValues | ConfigureServerRequestValues,
|
|
39
|
+
): value is ConfigureRequestValues {
|
|
40
|
+
const hasServerKeyedValues = Object.entries(value).some(
|
|
41
|
+
([key, entry]) =>
|
|
42
|
+
!CONFIGURE_REQUEST_VALUE_KEY_SET.has(key) &&
|
|
43
|
+
entry != null &&
|
|
44
|
+
typeof entry === 'object' &&
|
|
45
|
+
hasConfigureRequestValueKeys(entry),
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
if (hasServerKeyedValues) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return hasConfigureRequestValueKeys(value);
|
|
53
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useEffect, useState, useCallback } from 'react';
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
ConfigureRequestValues,
|
|
5
|
-
ConfigureServerRequestValues,
|
|
3
|
+
import {
|
|
4
|
+
type ConfigureRequestValues,
|
|
5
|
+
type ConfigureServerRequestValues,
|
|
6
6
|
} from '@redocly/theme/ext/configure';
|
|
7
7
|
import type { UserClaims, OpenAPIServer, OpenAPIInfo } from '@redocly/theme/core/types';
|
|
8
8
|
|