@redocly/replay 0.8.12 → 0.9.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 (4) hide show
  1. package/dist/replay.cjs +817 -612
  2. package/dist/replay.d.ts +63 -382
  3. package/dist/replay.js +40826 -39406
  4. package/package.json +10 -5
package/dist/replay.d.ts CHANGED
@@ -3,30 +3,6 @@ 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;
@@ -41,292 +17,59 @@ declare type Certificate = {
41
17
  keyFilePath: string;
42
18
  };
43
19
 
20
+ declare type ChangedOperation = {
21
+ sourcePath: SourcePath;
22
+ requestValues: {
23
+ cookie?: {
24
+ [key: string]: string;
25
+ };
26
+ header?: {
27
+ [key: string]: string;
28
+ };
29
+ query?: {
30
+ [key: string]: string;
31
+ };
32
+ body?: any;
33
+ };
34
+ activeExampleName?: string;
35
+ activeSecuritySchemeIds?: string[];
36
+ activeOneOf?: {
37
+ [key: string]: number;
38
+ };
39
+ };
40
+
44
41
  declare type ClientCredentialsOAuthFlowsObject = {
45
42
  'x-assertionType'?: 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer';
46
43
  tokenUrl: string;
47
44
  scopes: Record<string, string>;
48
45
  };
49
46
 
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
- };
47
+ declare type ConvertOperationFunction = (path: string, method: string, openAPI: any) => OpenAPIOperation | undefined;
80
48
 
81
49
  export declare function EmbeddedReplay(props: ReplayAppProps): JSX_2.Element;
82
50
 
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
- };
51
+ declare type GetOperationURLFunction = (operationId?: string, source?: Source) => string | undefined;
316
52
 
317
53
  declare type ImplicitOAuthFlowsObject = {
318
54
  authorizationUrl?: string;
319
55
  scopes: Record<string, string>;
320
56
  };
321
57
 
322
- declare type InputType = 'text' | 'file';
323
-
324
- declare enum LoadingState {
325
- Idle = "idle",
326
- Loading = "loading",
327
- Success = "success",
328
- Error = "error"
329
- }
58
+ declare type InputSettings = {
59
+ corsProxyUrl?: string;
60
+ mockServer?: MockServer;
61
+ disableCollectionsTab?: boolean;
62
+ disableDraft?: boolean;
63
+ oAuth2RedirectURI?: string | null;
64
+ inline?: boolean;
65
+ environment?: string;
66
+ apiId?: string;
67
+ predefinedEnvValues?: Record<string, Record<string, string>>;
68
+ certificates?: Certificate[];
69
+ storageKey?: string;
70
+ convertOperationToReplayValue?: ConvertOperationFunction;
71
+ getOperationUrl?: GetOperationURLFunction;
72
+ };
330
73
 
331
74
  declare type MediaType = {
332
75
  name: string;
@@ -366,12 +109,6 @@ declare type ModalProps = {
366
109
  className?: string;
367
110
  };
368
111
 
369
- declare enum OAuth2ExtraParamsLocation {
370
- Body = "Body",
371
- Header = "Header",
372
- URL = "URL"
373
- }
374
-
375
112
  declare type OAuthFlowsObject = {
376
113
  implicit?: ImplicitOAuthFlowsObject;
377
114
  password?: PasswordOAuthFlowsObject;
@@ -379,16 +116,14 @@ declare type OAuthFlowsObject = {
379
116
  authorizationCode?: AuthorizationCodeOAuthFlowsObject;
380
117
  };
381
118
 
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 = {
119
+ declare type OpenAPIOperation = {
120
+ id: string;
121
+ sourceId?: string;
389
122
  name: string;
390
123
  method: string;
391
124
  path: string;
125
+ href: string;
126
+ operationId?: string;
392
127
  parameters: OperationParameter[];
393
128
  body?: {
394
129
  mediaTypes: MediaTypes;
@@ -397,8 +132,15 @@ declare type Operation = {
397
132
  };
398
133
  servers: Server[];
399
134
  security?: OperationSecurity[][];
135
+ response?: Response_2 | null;
400
136
  };
401
137
 
138
+ declare function openFile({ name, extensions, multiple, }: {
139
+ name: string;
140
+ extensions: string[];
141
+ multiple: boolean;
142
+ }): Promise<FileResponse | string | null>;
143
+
402
144
  declare type OperationIn = 'query' | 'header' | 'path' | 'cookie';
403
145
 
404
146
  declare type OperationParameter = {
@@ -433,13 +175,6 @@ export declare type OperationSecurity = {
433
175
  flows?: OAuthFlowsObject;
434
176
  };
435
177
 
436
- declare type Parameter = {
437
- id: string;
438
- active: boolean;
439
- key: string;
440
- value: string;
441
- };
442
-
443
178
  declare type PasswordOAuthFlowsObject = {
444
179
  tokenUrl: string;
445
180
  scopes: Record<string, string>;
@@ -448,42 +183,18 @@ declare type PasswordOAuthFlowsObject = {
448
183
  export declare function Replay(props: ReplayAppProps): JSX_2.Element;
449
184
 
450
185
  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[];
186
+ activeOperationId?: string;
187
+ source?: Omit<Source, 'id'>;
188
+ settings: InputSettings;
464
189
  };
465
190
 
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;
191
+ export declare type ReplayOnChangeParams = {
192
+ operations: ChangedOperation[];
480
193
  activeMimeName?: string;
481
- activeServer?: Server;
482
194
  environment?: string;
483
195
  environments?: Record<string, {
484
196
  [key: string]: string;
485
197
  }>;
486
- activeSecuritySchemeIds?: string[];
487
198
  };
488
199
 
489
200
  export declare function ReplayOverlay({ onClose, onLoad, onRequestChange, ...props }: ReplayOverlayProps): JSX_2.Element;
@@ -494,10 +205,6 @@ declare type ReplayOverlayProps = {
494
205
  onRequestChange?: (props: ReplayOnChangeParams) => void;
495
206
  } & ReplayAppProps;
496
207
 
497
- export declare type ReplayState = typeof globalState.value;
498
-
499
- declare type Request_2 = typeof globalState.value.request;
500
-
501
208
  declare type Response_2 = ImmutableObject<{
502
209
  headers: [string, string][];
503
210
  cookies: [string, string][];
@@ -509,33 +216,6 @@ declare type Response_2 = ImmutableObject<{
509
216
  arrayBuffer: ArrayBuffer;
510
217
  }>;
511
218
 
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
219
  declare type Server = {
540
220
  url: string;
541
221
  description?: string;
@@ -550,15 +230,16 @@ declare type ServerVariable = {
550
230
  description?: string;
551
231
  };
552
232
 
553
- declare type Transaction = {
554
- request: Request_2;
555
- response: Response_2 | null;
233
+ declare type Source = {
234
+ id: string;
235
+ type: 'openapi' | 'arazzo';
236
+ path?: string;
237
+ data: Record<string, any>;
556
238
  };
557
239
 
558
- declare type TransactionSource = {
559
- id: string;
560
- type: 'collection';
561
- name: string;
240
+ declare type SourcePath = {
241
+ path: string;
242
+ method: string;
562
243
  };
563
244
 
564
245
  export declare const utils: {