@redocly/replay 0.8.13 → 0.9.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.
Files changed (4) hide show
  1. package/dist/replay.cjs +825 -620
  2. package/dist/replay.d.ts +64 -382
  3. package/dist/replay.js +40870 -39398
  4. package/package.json +10 -5
package/dist/replay.d.ts CHANGED
@@ -3,35 +3,12 @@ import { ImmutableObject } from '@hookstate/core';
3
3
  import { JSX as JSX_2 } from 'react/jsx-runtime';
4
4
  import { NamedExoticComponent } from 'react';
5
5
  import { ReactElement } from 'react';
6
- import { State } from '@hookstate/core';
7
-
8
- declare enum ApiKeyLocation {
9
- Query = "Query",
10
- Header = "Header",
11
- Cookie = "Cookie"
12
- }
13
-
14
- declare type App = {
15
- title: string;
16
- id: string;
17
- credentials?: AppCredential[];
18
- };
19
-
20
- declare type AppCredential = {
21
- id: string;
22
- clientId?: string;
23
- clientSecret?: string;
24
- stage?: string;
25
- issuedAt: string;
26
- expiresAt: string;
27
- status: string;
28
- valueToUseInHeader: 'clientId' | 'clientSecret';
29
- };
30
6
 
31
7
  declare type AuthorizationCodeOAuthFlowsObject = {
32
8
  authorizationUrl: string;
33
9
  tokenUrl: string;
34
10
  scopes: Record<string, string>;
11
+ 'x-usePkce'?: boolean;
35
12
  };
36
13
 
37
14
  declare type Certificate = {
@@ -41,292 +18,59 @@ declare type Certificate = {
41
18
  keyFilePath: string;
42
19
  };
43
20
 
21
+ declare type ChangedOperation = {
22
+ sourcePath: SourcePath;
23
+ requestValues: {
24
+ cookie?: {
25
+ [key: string]: string;
26
+ };
27
+ header?: {
28
+ [key: string]: string;
29
+ };
30
+ query?: {
31
+ [key: string]: string;
32
+ };
33
+ body?: any;
34
+ };
35
+ activeExampleName?: string;
36
+ activeSecuritySchemeIds?: string[];
37
+ activeOneOf?: {
38
+ [key: string]: number;
39
+ };
40
+ };
41
+
44
42
  declare type ClientCredentialsOAuthFlowsObject = {
45
43
  'x-assertionType'?: 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer';
46
44
  tokenUrl: string;
47
45
  scopes: Record<string, string>;
48
46
  };
49
47
 
50
- declare type CollectionsFolder = {
51
- id: string;
52
- name: string;
53
- items: CollectionsItem[];
54
- state: CollectionsItemState;
55
- };
56
-
57
- declare type CollectionsItem = {
58
- type: CollectionsItemType;
59
- value: CollectionsFolder | CollectionsRequest;
60
- };
61
-
62
- declare enum CollectionsItemState {
63
- Normal = "Normal",
64
- Edit = "Edit",
65
- Draft = "Draft"
66
- }
67
-
68
- declare enum CollectionsItemType {
69
- Folder = "folder",
70
- Request = "request"
71
- }
72
-
73
- declare type CollectionsRequest = {
74
- id: string;
75
- state: CollectionsItemState;
76
- name: string;
77
- request: Request_2;
78
- response: Response_2 | null;
79
- };
48
+ declare type ConvertOperationFunction = (path: string, method: string, openAPI: any) => OpenAPIOperation | undefined;
80
49
 
81
50
  export declare function EmbeddedReplay(props: ReplayAppProps): JSX_2.Element;
82
51
 
83
- declare type Environment = {
84
- id: string;
85
- url?: string;
86
- name: string;
87
- variables: EnvironmentVariable[];
88
- state: EnvironmentState;
89
- canBeRemoved: boolean;
90
- canBeEdited: boolean;
91
- };
92
-
93
- declare enum EnvironmentState {
94
- Normal = "Normal",
95
- Edit = "Edit",
96
- Draft = "Draft"
97
- }
98
-
99
- declare type EnvironmentVariable = {
100
- id: string;
101
- name: string;
102
- value: string;
103
- type: EnvironmentVariableType;
104
- canBeRemoved: boolean;
105
- canBeEdited: boolean;
106
- isSecret?: boolean;
107
- readonlyName?: boolean;
108
- };
109
-
110
- declare enum EnvironmentVariableType {
111
- Server = "Server",
112
- ServerUrl = "ServerUrl",
113
- Path = "Path",
114
- UserCreated = "UserCreated",
115
- Security = "Security"
116
- }
117
-
118
- declare type FormDataParameter = Parameter & {
119
- type: InputType;
120
- files: FileList | null;
121
- };
122
-
123
- declare const globalState: State< {
124
- requestController: AbortController | undefined;
125
- request: {
126
- method: string;
127
- url: string;
128
- security: {
129
- securitySchemeVariants: SecuritySchemeVariantType[];
130
- selectedSecuritySchemeId: string;
131
- securities: {
132
- securityType: SecurityTypes;
133
- securitySchemeId: string;
134
- "Basic Auth": {
135
- username: string;
136
- password: string;
137
- };
138
- JWT: {
139
- token: string;
140
- };
141
- "Digest Auth": {
142
- username: string;
143
- password: string;
144
- nc: string;
145
- realm: string | undefined;
146
- nonce: string | undefined;
147
- opaque: string | undefined;
148
- qop: string | undefined;
149
- algorithm: string | undefined;
150
- cnonce: string | undefined;
151
- };
152
- "API key": {
153
- location: ApiKeyLocation;
154
- name: string;
155
- key: string;
156
- };
157
- "OAuth 2.0": {
158
- documentedOAuth2Types: SecurityFlows[];
159
- grantType: SecurityFlows;
160
- authRequestExtraParams: Parameter[];
161
- tokenRequestExtraParams: SecurityDataParameter[];
162
- "Client Credentials": {
163
- clientId: string;
164
- clientSecret: string;
165
- clientAssertion: string;
166
- tokenUrl: string;
167
- scopes: Parameter[];
168
- accessToken: string;
169
- };
170
- "Client Credentials with JWT Assertion": {
171
- clientId: string;
172
- clientSecret: string;
173
- clientAssertion: string;
174
- tokenUrl: string;
175
- scopes: Parameter[];
176
- accessToken: string;
177
- };
178
- "Authorization Code": {
179
- clientId: string;
180
- clientSecret: string;
181
- tokenUrl: string;
182
- authorizationUrl: string;
183
- callbackUrl: string;
184
- availableScopes: string[];
185
- scopes: Parameter[];
186
- codeVerifier: string;
187
- codeChallenge: string;
188
- accessToken: string;
189
- };
190
- Implicit: {
191
- clientId: string;
192
- authorizationUrl: string;
193
- callbackUrl: string;
194
- availableScopes: string[];
195
- scopes: Parameter[];
196
- accessToken: string;
197
- };
198
- Password: {
199
- username: string;
200
- password: string;
201
- clientId: string;
202
- clientSecret: string;
203
- tokenUrl: string;
204
- accessToken: string;
205
- };
206
- };
207
- "OpenID Connect": {
208
- openIdConnectUrl: string;
209
- userInfoUrl: string;
210
- documentedOAuth2Types: SecurityFlows[];
211
- grantType: SecurityFlows;
212
- authRequestExtraParams: Parameter[];
213
- tokenRequestExtraParams: SecurityDataParameter[];
214
- "Client Credentials": {
215
- clientId: string;
216
- clientSecret: string;
217
- clientAssertion: string;
218
- tokenUrl: string;
219
- scopes: Parameter[];
220
- accessToken: string;
221
- };
222
- "Client Credentials with JWT Assertion": {
223
- clientId: string;
224
- clientSecret: string;
225
- clientAssertion: string;
226
- tokenUrl: string;
227
- scopes: Parameter[];
228
- accessToken: string;
229
- };
230
- "Authorization Code": {
231
- clientId: string;
232
- clientSecret: string;
233
- tokenUrl: string;
234
- authorizationUrl: string;
235
- callbackUrl: string;
236
- availableScopes: string[];
237
- scopes: Parameter[];
238
- codeVerifier: string;
239
- codeChallenge: string;
240
- accessToken: string;
241
- };
242
- Implicit: {
243
- clientId: string;
244
- authorizationUrl: string;
245
- callbackUrl: string;
246
- availableScopes: string[];
247
- scopes: Parameter[];
248
- accessToken: string;
249
- };
250
- Password: {
251
- username: string;
252
- password: string;
253
- clientId: string;
254
- clientSecret: string;
255
- tokenUrl: string;
256
- accessToken: string;
257
- };
258
- };
259
- }[];
260
- };
261
- body: {
262
- type: string;
263
- content: string;
264
- activeExampleName: string;
265
- formData: {
266
- [x: string]: FormDataParameter[];
267
- };
268
- binary: File | null;
269
- };
270
- queryParameters: Parameter[];
271
- headers: Parameter[];
272
- cookies: Parameter[];
273
- };
274
- isProcessingRequest: boolean;
275
- response: ImmutableObject< {
276
- headers: [string, string][];
277
- cookies: [string, string][];
278
- body: string;
279
- duration: number;
280
- size: number;
281
- status: number;
282
- bodyUsed: boolean;
283
- arrayBuffer: ArrayBuffer;
284
- }> | null;
285
- requestError: string | null;
286
- history: HistoryItem[];
287
- collections: CollectionsItem[];
288
- operation: Operation | null;
289
- operationUrl: string | undefined;
290
- isLinked: boolean;
291
- environments: Environment[];
292
- selectedEnvironmentId: string | null;
293
- corsProxyUrl: string | undefined;
294
- mockServer: MockServer | undefined;
295
- appsLoadingState: LoadingState;
296
- apps: App[];
297
- apiId: string | undefined;
298
- requestActiveTabIdx: number;
299
- oAuth2RedirectURI: string | null | undefined;
300
- isRequestEditable: boolean;
301
- tokenRequestError: string | null;
302
- definitionUrl: string | undefined;
303
- transactionSource: TransactionSource | null;
304
- showUnsavedChangesModal: boolean;
305
- pendingTransaction: Transaction | null;
306
- pendingTransactionSource: TransactionSource | null;
307
- disableCollectionsTab: boolean | undefined;
308
- certificates: Certificate[];
309
- }, {}>;
310
-
311
- declare type HistoryItem = {
312
- date: number;
313
- request: Request_2;
314
- response: Response_2 | null;
315
- };
52
+ declare type GetOperationURLFunction = (operationId?: string, source?: Source) => string | undefined;
316
53
 
317
54
  declare type ImplicitOAuthFlowsObject = {
318
55
  authorizationUrl?: string;
319
56
  scopes: Record<string, string>;
320
57
  };
321
58
 
322
- declare type InputType = 'text' | 'file';
323
-
324
- declare enum LoadingState {
325
- Idle = "idle",
326
- Loading = "loading",
327
- Success = "success",
328
- Error = "error"
329
- }
59
+ declare type InputSettings = {
60
+ corsProxyUrl?: string;
61
+ mockServer?: MockServer;
62
+ disableCollectionsTab?: boolean;
63
+ disableDraft?: boolean;
64
+ oAuth2RedirectURI?: string | null;
65
+ inline?: boolean;
66
+ environment?: string;
67
+ apiId?: string;
68
+ predefinedEnvValues?: Record<string, Record<string, string>>;
69
+ certificates?: Certificate[];
70
+ storageKey?: string;
71
+ convertOperationToReplayValue?: ConvertOperationFunction;
72
+ getOperationUrl?: GetOperationURLFunction;
73
+ };
330
74
 
331
75
  declare type MediaType = {
332
76
  name: string;
@@ -366,12 +110,6 @@ declare type ModalProps = {
366
110
  className?: string;
367
111
  };
368
112
 
369
- declare enum OAuth2ExtraParamsLocation {
370
- Body = "Body",
371
- Header = "Header",
372
- URL = "URL"
373
- }
374
-
375
113
  declare type OAuthFlowsObject = {
376
114
  implicit?: ImplicitOAuthFlowsObject;
377
115
  password?: PasswordOAuthFlowsObject;
@@ -379,16 +117,14 @@ declare type OAuthFlowsObject = {
379
117
  authorizationCode?: AuthorizationCodeOAuthFlowsObject;
380
118
  };
381
119
 
382
- declare function openFile({ name, extensions, multiple, }: {
383
- name: string;
384
- extensions: string[];
385
- multiple: boolean;
386
- }): Promise<FileResponse | string | null>;
387
-
388
- declare type Operation = {
120
+ declare type OpenAPIOperation = {
121
+ id: string;
122
+ sourceId?: string;
389
123
  name: string;
390
124
  method: string;
391
125
  path: string;
126
+ href: string;
127
+ operationId?: string;
392
128
  parameters: OperationParameter[];
393
129
  body?: {
394
130
  mediaTypes: MediaTypes;
@@ -397,8 +133,15 @@ declare type Operation = {
397
133
  };
398
134
  servers: Server[];
399
135
  security?: OperationSecurity[][];
136
+ response?: Response_2 | null;
400
137
  };
401
138
 
139
+ declare function openFile({ name, extensions, multiple, }: {
140
+ name: string;
141
+ extensions: string[];
142
+ multiple: boolean;
143
+ }): Promise<FileResponse | string | null>;
144
+
402
145
  declare type OperationIn = 'query' | 'header' | 'path' | 'cookie';
403
146
 
404
147
  declare type OperationParameter = {
@@ -433,13 +176,6 @@ export declare type OperationSecurity = {
433
176
  flows?: OAuthFlowsObject;
434
177
  };
435
178
 
436
- declare type Parameter = {
437
- id: string;
438
- active: boolean;
439
- key: string;
440
- value: string;
441
- };
442
-
443
179
  declare type PasswordOAuthFlowsObject = {
444
180
  tokenUrl: string;
445
181
  scopes: Record<string, string>;
@@ -448,42 +184,18 @@ declare type PasswordOAuthFlowsObject = {
448
184
  export declare function Replay(props: ReplayAppProps): JSX_2.Element;
449
185
 
450
186
  declare type ReplayAppProps = {
451
- value?: Operation;
452
- inline?: boolean;
453
- operationUrl?: string;
454
- corsProxyUrl?: string;
455
- mockServer?: MockServer;
456
- disableDraft?: boolean;
457
- environment?: string;
458
- predefinedEnvValues?: Record<string, Record<string, string>>;
459
- apiId?: string;
460
- oAuth2RedirectURI?: string | null;
461
- definitionUrl?: string;
462
- disableCollectionsTab?: boolean;
463
- certificates?: Certificate[];
187
+ activeOperationId?: string;
188
+ source?: Omit<Source, 'id'>;
189
+ settings: InputSettings;
464
190
  };
465
191
 
466
- declare type ReplayOnChangeParams = {
467
- requestValues: {
468
- cookie?: {
469
- [key: string]: string;
470
- };
471
- header?: {
472
- [key: string]: string;
473
- };
474
- query?: {
475
- [key: string]: string;
476
- };
477
- body?: any;
478
- } | object;
479
- activeExampleName?: string;
192
+ export declare type ReplayOnChangeParams = {
193
+ operations: ChangedOperation[];
480
194
  activeMimeName?: string;
481
- activeServer?: Server;
482
195
  environment?: string;
483
196
  environments?: Record<string, {
484
197
  [key: string]: string;
485
198
  }>;
486
- activeSecuritySchemeIds?: string[];
487
199
  };
488
200
 
489
201
  export declare function ReplayOverlay({ onClose, onLoad, onRequestChange, ...props }: ReplayOverlayProps): JSX_2.Element;
@@ -494,10 +206,6 @@ declare type ReplayOverlayProps = {
494
206
  onRequestChange?: (props: ReplayOnChangeParams) => void;
495
207
  } & ReplayAppProps;
496
208
 
497
- export declare type ReplayState = typeof globalState.value;
498
-
499
- declare type Request_2 = typeof globalState.value.request;
500
-
501
209
  declare type Response_2 = ImmutableObject<{
502
210
  headers: [string, string][];
503
211
  cookies: [string, string][];
@@ -509,33 +217,6 @@ declare type Response_2 = ImmutableObject<{
509
217
  arrayBuffer: ArrayBuffer;
510
218
  }>;
511
219
 
512
- declare type SecurityDataParameter = Parameter & {
513
- sendIn: OAuth2ExtraParamsLocation;
514
- };
515
-
516
- declare enum SecurityFlows {
517
- ClientCredentials = "Client Credentials",
518
- ClientCredentialsWithJwtAssertion = "Client Credentials with JWT Assertion",
519
- AuthorizationCode = "Authorization Code",
520
- Implicit = "Implicit",
521
- Password = "Password"
522
- }
523
-
524
- declare type SecuritySchemeVariantType = {
525
- id: string;
526
- schemes: string[];
527
- };
528
-
529
- declare enum SecurityTypes {
530
- NoAuth = "No Auth",
531
- BasicAuth = "Basic Auth",
532
- DigestAuth = "Digest Auth",
533
- JWT = "JWT",
534
- APIKey = "API key",
535
- OAuth2 = "OAuth 2.0",
536
- OpenIDConnect = "OpenID Connect"
537
- }
538
-
539
220
  declare type Server = {
540
221
  url: string;
541
222
  description?: string;
@@ -550,15 +231,16 @@ declare type ServerVariable = {
550
231
  description?: string;
551
232
  };
552
233
 
553
- declare type Transaction = {
554
- request: Request_2;
555
- response: Response_2 | null;
234
+ declare type Source = {
235
+ id: string;
236
+ type: 'openapi' | 'arazzo';
237
+ path?: string;
238
+ data: Record<string, any>;
556
239
  };
557
240
 
558
- declare type TransactionSource = {
559
- id: string;
560
- type: 'collection';
561
- name: string;
241
+ declare type SourcePath = {
242
+ path: string;
243
+ method: string;
562
244
  };
563
245
 
564
246
  export declare const utils: {