@nice2dev/ui-api 1.4.29 → 1.4.31

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/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # @nice2dev/ui-api
2
2
 
3
+ ## 1.4.31
4
+
5
+ ### Patch Changes
6
+
7
+ - 7eb35bc: NiceApiClient (round 44, 1.4.31).
8
+
9
+ - A menubar: File ▸ New / Open… / Save / Import… / Export ▸ (OpenAPI YAML / JSON, Postman, HAR,
10
+ Markdown), Edit ▸ New request / New folder / Duplicate / Delete, View ▸ Try / Docs and
11
+ Layout ▸ Horizontal (the response beside the request) / Vertical (under it). New props `onSave`,
12
+ `onNew`, `layout` / `defaultLayout` / `onLayoutChange`.
13
+ - Export is a button with a list (it was an icon beside a select); adding is one icon button with a
14
+ list — a request or a folder (into the selected folder, or the folder of the selected request).
15
+ - The collection is the tree's fixed root (it replaces the Overview button); folders and requests are
16
+ dragged — before, after or into a folder, also with Ctrl+Shift+arrows — and several at once: Shift +
17
+ click picks a range, Ctrl + click adds or removes one; Delete and dragging work on all picked.
18
+ - Variable sets: the collection keeps named sets of variables (`variableSets` — on its page, the
19
+ tree's root); a folder or a request uses one or several of them in order (its Variables tab / the
20
+ folder page), shown with the sets it inherits and the variables in force with their source. Resolved:
21
+ collection variables, the environment, the folders' sets (outermost first), the request's — a later
22
+ one wins (`variableScope(…, assigned)`, new `assignedVariableSets`).
23
+ - NiceTreeView: new `selectionBehavior="extended"` — a click selects one node, Ctrl / ⌘ + click adds or
24
+ removes it, Shift + click selects a range in the order shown.
25
+ - Translations for the new texts in all twelve dictionaries.
26
+
27
+ ## 1.4.30
28
+
29
+ No changes in this release.
30
+
3
31
  ## 1.4.29
4
32
 
5
33
  No changes in this release.
@@ -33,7 +33,17 @@ export interface NiceApiClientProps {
33
33
  readOnly?: boolean;
34
34
  /** Height of the client. Default 640. */
35
35
  height?: number | string;
36
+ /** 1.4.31: File ▸ Save — the whole collection. Without it the menu has no Save. */
37
+ onSave?: (collection: NiceApiCollection) => void;
38
+ /** 1.4.31: File ▸ New. Default: an empty collection in place of this one. */
39
+ onNew?: () => void;
40
+ /** 1.4.31: the response beside the request (`horizontal`, default) or under it (`vertical`). */
41
+ layout?: NiceApiClientLayout;
42
+ defaultLayout?: NiceApiClientLayout;
43
+ onLayoutChange?: (layout: NiceApiClientLayout) => void;
36
44
  className?: string;
37
45
  style?: React.CSSProperties;
38
46
  }
47
+ /** Where the response sits: beside the request or under it. */
48
+ export type NiceApiClientLayout = 'horizontal' | 'vertical';
39
49
  export declare function NiceApiClient(props: NiceApiClientProps): React.ReactElement;
@@ -1,5 +1,5 @@
1
1
  import { default as React } from 'react';
2
- import { NiceApiAuth, NiceApiBody, NiceApiCollection, NiceApiParam, NiceApiParamLocation, NiceApiRequest, NiceApiResolvedRequest, NiceApiResponse, NiceApiSchema } from '../core';
2
+ import { NiceApiAuth, NiceApiBody, NiceApiCollection, NiceApiEnvironment, NiceApiParam, NiceApiParamLocation, NiceApiRequest, NiceApiResolvedRequest, NiceApiResponse, NiceApiSchema } from '../core';
3
3
  /** The method as a coloured badge (GET, POST, …). */
4
4
  export declare function ApiMethodBadge({ method }: {
5
5
  method: string;
@@ -73,3 +73,33 @@ export declare function ApiCollectionDocs({ collection, showModels, }: {
73
73
  /** The Models section (off when the models have a tab of their own). */
74
74
  showModels?: boolean;
75
75
  }): React.ReactElement;
76
+ export interface ApiVariableSetsEditorProps {
77
+ sets: NiceApiEnvironment[];
78
+ onChange: (sets: NiceApiEnvironment[]) => void;
79
+ /** Ids in use (assigned to a folder or a request) — removing one asks first. */
80
+ usedIds?: ReadonlySet<string>;
81
+ readOnly?: boolean;
82
+ }
83
+ /** The collection's variable sets: a name and a table of variables each; add, rename, remove. */
84
+ export declare function ApiVariableSetsEditor({ sets, onChange, usedIds, readOnly, }: ApiVariableSetsEditorProps): React.ReactElement;
85
+ export interface ApiAssignedSetsProps {
86
+ /** The item's own sets, in order. */
87
+ value: readonly string[];
88
+ onChange: (ids: string[]) => void;
89
+ /** Every set it can use: the collection's and the host's environments. */
90
+ available: readonly NiceApiEnvironment[];
91
+ /** The sets it gets from its folders (outermost first) — shown, not edited here. */
92
+ inherited?: ReadonlyArray<{
93
+ set: NiceApiEnvironment;
94
+ from: string;
95
+ }>;
96
+ /** The values in force for this item, with the set each comes from. */
97
+ resolved?: ReadonlyArray<{
98
+ key: string;
99
+ value: string;
100
+ from: string;
101
+ }>;
102
+ readOnly?: boolean;
103
+ }
104
+ /** The variable sets of a folder or a request: the inherited ones, then its own, in order. */
105
+ export declare function ApiAssignedSets({ value, onChange, available, inherited, resolved, readOnly, }: ApiAssignedSetsProps): React.ReactElement;
@@ -246,6 +246,11 @@ export interface NiceApiRequest {
246
246
  deprecated?: boolean;
247
247
  responses?: Record<string, NiceApiResponseDoc>;
248
248
  examples?: NiceApiExample[];
249
+ /**
250
+ * 1.4.31: the variable sets this request uses (ids from the collection's `variableSets` or the
251
+ * host's environments), in order — a later set wins; over its folders' sets.
252
+ */
253
+ variableSets?: string[];
249
254
  }
250
255
  /** A folder of requests and folders. */
251
256
  export interface NiceApiFolder {
@@ -255,6 +260,8 @@ export interface NiceApiFolder {
255
260
  description?: string;
256
261
  items: NiceApiItem[];
257
262
  auth?: NiceApiAuth;
263
+ /** 1.4.31: the variable sets every request inside uses (see {@link NiceApiRequest.variableSets}). */
264
+ variableSets?: string[];
258
265
  }
259
266
  /** A collection entry: a request or a folder. */
260
267
  export type NiceApiItem = NiceApiRequest | NiceApiFolder;
@@ -283,6 +290,11 @@ export interface NiceApiCollection {
283
290
  servers?: NiceApiServer[];
284
291
  /** Named models, referenced from requests as `#/components/schemas/<name>`. */
285
292
  schemas?: Record<string, NiceApiSchema>;
293
+ /**
294
+ * 1.4.31: named sets of variables kept with the collection (auth, tenant, paging…), assigned to
295
+ * folders and requests; the environment switch stays for dev / test / prod.
296
+ */
297
+ variableSets?: NiceApiEnvironment[];
286
298
  }
287
299
  /** A named set of variable values (dev, test, prod…). */
288
300
  export interface NiceApiEnvironment {
@@ -18,8 +18,16 @@ export declare function findVariables(text: string): string[];
18
18
  export declare function interpolate(text: string, lookup: NiceApiVariableLookup | Record<string, string>, options?: NiceApiInterpolateOptions): string;
19
19
  /** The names `text` still refers to after interpolation — what is missing. */
20
20
  export declare function unresolvedVariables(text: string, lookup: NiceApiVariableLookup | Record<string, string>, options?: NiceApiInterpolateOptions): string[];
21
+ /**
22
+ * 1.4.31: the variable sets assigned on the way to an item — its folders' (outermost first), then its
23
+ * own — each list in its order. `sets`: the collection's sets and the host's environments.
24
+ */
25
+ export declare function assignedVariableSets(path: ReadonlyArray<{
26
+ variableSets?: readonly string[];
27
+ } | undefined>, sets: readonly NiceApiEnvironment[]): NiceApiEnvironment[];
21
28
  /**
22
29
  * The values in force: the collection's variables, overridden by the environment's, overridden by
30
+ * the assigned variable sets (1.4.31, in order — see {@link assignedVariableSets}), overridden by
23
31
  * `extra` (values set at run time — a token from a login call). Disabled rows are skipped.
24
32
  */
25
- export declare function variableScope(collection?: Pick<NiceApiCollection, 'variables'>, environment?: Pick<NiceApiEnvironment, 'values'>, extra?: Record<string, string>): Record<string, string>;
33
+ export declare function variableScope(collection?: Pick<NiceApiCollection, 'variables'>, environment?: Pick<NiceApiEnvironment, 'values'>, extra?: Record<string, string>, assigned?: ReadonlyArray<Pick<NiceApiEnvironment, 'values'>>): Record<string, string>;