@nice2dev/ui-api 1.4.11 → 1.4.13
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 +39 -0
- package/dist/NiceIntegrationsEditor.d.ts +62 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/integration.d.ts +172 -0
- package/dist/core.cjs +55 -55
- package/dist/core.mjs +1685 -1491
- package/dist/index.cjs +6 -6
- package/dist/index.d.ts +2 -0
- package/dist/index.mjs +2980 -2095
- package/dist/ui-api.css +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
# @nice2dev/ui-api
|
|
2
2
|
|
|
3
|
+
## 1.4.13
|
|
4
|
+
|
|
5
|
+
No changes in this release.
|
|
6
|
+
|
|
7
|
+
## 1.4.12
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- c3952fe: Module integrations and environment sets, with editors in the Development Studio.
|
|
12
|
+
|
|
13
|
+
- **`@nice2dev/ui-api/core`:**
|
|
14
|
+
- New types:
|
|
15
|
+
- `NiceIntegrationDef`: package, direction and requirements; a connection (protocol, base URL, auth,
|
|
16
|
+
headers, paging, retries, rate limit); the consumed API as a collection; exposed endpoints; operations with
|
|
17
|
+
field mapping, trigger, conflict rule and incremental field.
|
|
18
|
+
- `NiceEnvironmentSets`: declared variables and sets that extend one another or apply to one database.
|
|
19
|
+
- Helpers: `resolveEnvironmentSet`, `valueOrigin`, `toApiEnvironments`, `environmentSetFor`,
|
|
20
|
+
`validateIntegrations` (issues with stable codes), `groupIntegrations` and `integrationEndpoints`.
|
|
21
|
+
- **`NiceIntegrationsEditor`:** the list grouped by package and direction, with tabs for General, Connection,
|
|
22
|
+
API (in NiceApiClient), Exposed, Operations (with mapping) and Checks.
|
|
23
|
+
- **`NiceEnvironmentSetsEditor`:** variables × sets; inherited values are shown faded and secrets stay
|
|
24
|
+
`{{secret:KEY}}`.
|
|
25
|
+
- **`niceApiStudioEditors()`:** plugs both editors into the studio.
|
|
26
|
+
- **Development Studio:**
|
|
27
|
+
- New props `editors` and `editorServices`. A file kind whose `editor` the studio does not have opens in the
|
|
28
|
+
host's plug-in, or as JSON when there is none.
|
|
29
|
+
- New tree group "Integrations".
|
|
30
|
+
- New file kinds `{prefix}.integrations.json` and `{prefix}.environments.json`, in both the native and the
|
|
31
|
+
OmniVerk presets.
|
|
32
|
+
- **OmniVerk (`@nice2dev/erp-adapter/omniverk`):**
|
|
33
|
+
- `variablesFromManifest`: the wizard fields and environment variables become declared variables.
|
|
34
|
+
- `envVarsToManifest`: publishes variables to the manifest; secrets are left out.
|
|
35
|
+
- `exposedFromControllers`, `controllerDifferences` and `controllersFromExposed`: map, compare and sync
|
|
36
|
+
controllers with exposed endpoints.
|
|
37
|
+
- `toOmniVerkConnectorSeeds`: rows for RESTConnection / RESTEndpointDefinition, SOAPConnection /
|
|
38
|
+
SOAPSavedCall and GraphQLEndpoint / GraphQLSavedQuery, with OmniVerk's stable ids.
|
|
39
|
+
|
|
40
|
+
Guide: `documentation/omniverk/OMNIVERK_UPGRADE_1.4.12.md`.
|
|
41
|
+
|
|
3
42
|
## 1.4.11
|
|
4
43
|
|
|
5
44
|
### Patch Changes
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { NiceApiTransport, NiceEnvironmentSets, NiceIntegrationsFile } from './core';
|
|
3
|
+
export interface NiceIntegrationsEditorProps {
|
|
4
|
+
/** The module's integrations (controlled). */
|
|
5
|
+
value?: NiceIntegrationsFile;
|
|
6
|
+
defaultValue?: NiceIntegrationsFile;
|
|
7
|
+
onChange?: (value: NiceIntegrationsFile) => void;
|
|
8
|
+
/** The module's environment sets — the API tab sends with their values. */
|
|
9
|
+
environments?: NiceEnvironmentSets;
|
|
10
|
+
/** For the requirement checks: what exists around the module. */
|
|
11
|
+
known?: {
|
|
12
|
+
modules?: string[];
|
|
13
|
+
dataSources?: string[];
|
|
14
|
+
};
|
|
15
|
+
/** Sends the API tab's requests (the host's proxy). */
|
|
16
|
+
sendRequest?: NiceApiTransport;
|
|
17
|
+
resolveSecret?: (key: string) => string | undefined;
|
|
18
|
+
readOnly?: boolean;
|
|
19
|
+
/** Height. Default 640. */
|
|
20
|
+
height?: number | string;
|
|
21
|
+
className?: string;
|
|
22
|
+
style?: React.CSSProperties;
|
|
23
|
+
}
|
|
24
|
+
/** A module's integrations: the list on the left, the selected one in tabs. */
|
|
25
|
+
export declare function NiceIntegrationsEditor(props: NiceIntegrationsEditorProps): React.ReactElement;
|
|
26
|
+
export interface NiceEnvironmentSetsEditorProps {
|
|
27
|
+
/** The declared variables and the sets (controlled). */
|
|
28
|
+
value?: NiceEnvironmentSets;
|
|
29
|
+
defaultValue?: NiceEnvironmentSets;
|
|
30
|
+
onChange?: (value: NiceEnvironmentSets) => void;
|
|
31
|
+
readOnly?: boolean;
|
|
32
|
+
className?: string;
|
|
33
|
+
style?: React.CSSProperties;
|
|
34
|
+
}
|
|
35
|
+
/** Variables × sets: each set's own values, the inherited ones shown faded, secrets as `{{secret:KEY}}`. */
|
|
36
|
+
export declare function NiceEnvironmentSetsEditor(props: NiceEnvironmentSetsEditorProps): React.ReactElement;
|
|
37
|
+
/** What NiceDevelopmentStudio hands an editor plug-in (structural — no dependency on ui-forms). */
|
|
38
|
+
export interface NiceApiStudioEditorContext {
|
|
39
|
+
value: unknown;
|
|
40
|
+
onChange: (value: unknown) => void;
|
|
41
|
+
readOnly?: boolean;
|
|
42
|
+
/** The module's files — the integrations editor reads the environment sets from them. */
|
|
43
|
+
files?: readonly {
|
|
44
|
+
path: string;
|
|
45
|
+
text: string;
|
|
46
|
+
}[];
|
|
47
|
+
services?: {
|
|
48
|
+
sendRequest?: unknown;
|
|
49
|
+
resolveSecret?: (key: string) => string | undefined;
|
|
50
|
+
[name: string]: unknown;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The studio editors for integrations and environment sets — pass to NiceDevelopmentStudio's
|
|
55
|
+
* `editors`: `editors={niceApiStudioEditors({ sendRequest: proxy })}`.
|
|
56
|
+
*/
|
|
57
|
+
export declare function niceApiStudioEditors(services?: {
|
|
58
|
+
sendRequest?: NiceApiTransport;
|
|
59
|
+
resolveSecret?: (key: string) => string | undefined;
|
|
60
|
+
}): Record<'integrations' | 'environments', {
|
|
61
|
+
render: (ctx: NiceApiStudioEditorContext) => React.ReactNode;
|
|
62
|
+
}>;
|
package/dist/core/index.d.ts
CHANGED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { NiceApiAuth, NiceApiCollection, NiceApiEnvironment } from './model';
|
|
2
|
+
/** Which way the data moves. */
|
|
3
|
+
export type NiceIntegrationDirection = 'inbound' | 'outbound' | 'bidirectional';
|
|
4
|
+
/** The protocols a connection speaks. */
|
|
5
|
+
export type NiceConnectionProtocol = 'rest' | 'graphql' | 'soap' | 'odata' | 'grpc' | 'websocket' | 'sse' | 'webhook' | 'database' | 'sftp';
|
|
6
|
+
export declare const NICE_CONNECTION_PROTOCOLS: readonly NiceConnectionProtocol[];
|
|
7
|
+
/** How a list endpoint pages. */
|
|
8
|
+
export interface NiceConnectionPagination {
|
|
9
|
+
style: 'none' | 'page' | 'offset' | 'cursor' | 'link';
|
|
10
|
+
/** The query parameter (page / offset / cursor) and the page size parameter. */
|
|
11
|
+
param?: string;
|
|
12
|
+
sizeParam?: string;
|
|
13
|
+
size?: number;
|
|
14
|
+
/** Where the next cursor is in the response (`$.meta.next`). */
|
|
15
|
+
nextPath?: string;
|
|
16
|
+
}
|
|
17
|
+
/** Retries on failure. */
|
|
18
|
+
export interface NiceConnectionRetry {
|
|
19
|
+
attempts: number;
|
|
20
|
+
/** Milliseconds before the first retry; doubled each time with `backoff: 'exponential'`. */
|
|
21
|
+
delayMs: number;
|
|
22
|
+
backoff?: 'fixed' | 'exponential';
|
|
23
|
+
/** Status codes worth retrying. Default 429, 502, 503, 504. */
|
|
24
|
+
statuses?: number[];
|
|
25
|
+
}
|
|
26
|
+
/** How to talk to the other side. */
|
|
27
|
+
export interface NiceConnectionDef {
|
|
28
|
+
protocol: NiceConnectionProtocol;
|
|
29
|
+
/** May hold `{{VARIABLES}}`. */
|
|
30
|
+
baseUrl: string;
|
|
31
|
+
auth?: NiceApiAuth;
|
|
32
|
+
headers?: {
|
|
33
|
+
key: string;
|
|
34
|
+
value: string;
|
|
35
|
+
}[];
|
|
36
|
+
pagination?: NiceConnectionPagination;
|
|
37
|
+
retry?: NiceConnectionRetry;
|
|
38
|
+
/** Requests per second the other side allows. */
|
|
39
|
+
rateLimit?: number;
|
|
40
|
+
timeoutMs?: number;
|
|
41
|
+
}
|
|
42
|
+
/** An endpoint the module exposes (a webhook it receives, an API it serves). */
|
|
43
|
+
export interface NiceExposedEndpoint {
|
|
44
|
+
key: string;
|
|
45
|
+
method: string;
|
|
46
|
+
path: string;
|
|
47
|
+
/** The script / controller that handles it (`scripting.controllers` in OmniVerk). */
|
|
48
|
+
handler?: string;
|
|
49
|
+
/** Who may call it: `none`, an API key, the platform's session, a signature. */
|
|
50
|
+
auth?: 'none' | 'apiKey' | 'session' | 'signature';
|
|
51
|
+
description?: string;
|
|
52
|
+
}
|
|
53
|
+
/** Moving data: call an endpoint, read from / write to a data source, map the fields. */
|
|
54
|
+
export interface NiceIntegrationOperation {
|
|
55
|
+
key: string;
|
|
56
|
+
name?: string;
|
|
57
|
+
/** The id of the consumed request in `endpoints`, or the key of an exposed endpoint. */
|
|
58
|
+
endpoint?: string;
|
|
59
|
+
/** Where the data comes from: a data source key, an entity, `response`. */
|
|
60
|
+
source?: string;
|
|
61
|
+
/** Where it goes. */
|
|
62
|
+
target?: string;
|
|
63
|
+
/** Target field → source expression (`$.items[*].id`, `{{field}}`, a constant). */
|
|
64
|
+
mapping?: Record<string, string>;
|
|
65
|
+
/** `manual`, `schedule:<cron>`, `event:<name>`, `webhook`. */
|
|
66
|
+
trigger?: string;
|
|
67
|
+
/** Both sides changed: which wins. */
|
|
68
|
+
conflict?: 'source' | 'target' | 'newest' | 'manual';
|
|
69
|
+
/** Fetch only what changed since the last run, by this field. */
|
|
70
|
+
incremental?: string;
|
|
71
|
+
}
|
|
72
|
+
/** One integration of a module. */
|
|
73
|
+
export interface NiceIntegrationDef {
|
|
74
|
+
key: string;
|
|
75
|
+
name: string;
|
|
76
|
+
/** Grouping in the tree: `Banking/PSD2`, `Shipping/DHL`. */
|
|
77
|
+
package?: string;
|
|
78
|
+
direction: NiceIntegrationDirection;
|
|
79
|
+
description?: string;
|
|
80
|
+
/** What it needs to work. */
|
|
81
|
+
requires?: {
|
|
82
|
+
modules?: string[];
|
|
83
|
+
dataSources?: string[];
|
|
84
|
+
integrations?: string[];
|
|
85
|
+
};
|
|
86
|
+
connection: NiceConnectionDef;
|
|
87
|
+
/** The API it consumes. */
|
|
88
|
+
endpoints: NiceApiCollection;
|
|
89
|
+
/** What it serves. */
|
|
90
|
+
expose?: NiceExposedEndpoint[];
|
|
91
|
+
operations?: NiceIntegrationOperation[];
|
|
92
|
+
}
|
|
93
|
+
/** A module's `{prefix}.integrations.json`. */
|
|
94
|
+
export interface NiceIntegrationsFile {
|
|
95
|
+
integrations: NiceIntegrationDef[];
|
|
96
|
+
}
|
|
97
|
+
/** A declared variable (its values live in the sets). */
|
|
98
|
+
export interface NiceEnvironmentVariableDecl {
|
|
99
|
+
key: string;
|
|
100
|
+
description?: string;
|
|
101
|
+
/** Kept out of seeds: its value is `{{secret:KEY}}`, resolved by the host. */
|
|
102
|
+
secret?: boolean;
|
|
103
|
+
required?: boolean;
|
|
104
|
+
/** The value when no set gives one. */
|
|
105
|
+
defaultValue?: string;
|
|
106
|
+
}
|
|
107
|
+
/** A set of values: dev, test, prod, a customer's own. */
|
|
108
|
+
export interface NiceEnvironmentSet {
|
|
109
|
+
id: string;
|
|
110
|
+
name: string;
|
|
111
|
+
/** Takes every value of that set it does not give itself. */
|
|
112
|
+
extends?: string;
|
|
113
|
+
/** Used for one database only (the host picks the set by the database it runs on). */
|
|
114
|
+
appliesTo?: {
|
|
115
|
+
database?: string;
|
|
116
|
+
};
|
|
117
|
+
values: Record<string, string>;
|
|
118
|
+
}
|
|
119
|
+
/** A module's `{prefix}.environments.json`. */
|
|
120
|
+
export interface NiceEnvironmentSets {
|
|
121
|
+
variables: NiceEnvironmentVariableDecl[];
|
|
122
|
+
sets: NiceEnvironmentSet[];
|
|
123
|
+
}
|
|
124
|
+
/** A new integration with an empty connection and API. */
|
|
125
|
+
export declare function newIntegration(init?: Partial<NiceIntegrationDef>): NiceIntegrationDef;
|
|
126
|
+
/**
|
|
127
|
+
* The values of set `id` with everything it inherits: its own values over its parent's over the
|
|
128
|
+
* grandparent's…, then the declared defaults. A cycle stops at the first repeated set.
|
|
129
|
+
*/
|
|
130
|
+
export declare function resolveEnvironmentSet(sets: NiceEnvironmentSets, id: string): Record<string, string>;
|
|
131
|
+
/** Where a set's value of `key` comes from: itself, a set it extends (its id), a default, or nowhere. */
|
|
132
|
+
export declare function valueOrigin(sets: NiceEnvironmentSets, id: string, key: string): {
|
|
133
|
+
value?: string;
|
|
134
|
+
from: 'own' | 'inherited' | 'default' | 'none';
|
|
135
|
+
set?: string;
|
|
136
|
+
};
|
|
137
|
+
/** The sets as environments for NiceApiClient (inheritance resolved). */
|
|
138
|
+
export declare function toApiEnvironments(sets: NiceEnvironmentSets): NiceApiEnvironment[];
|
|
139
|
+
/** The set for a database: the one that applies to it, else the first without `appliesTo`. */
|
|
140
|
+
export declare function environmentSetFor(sets: NiceEnvironmentSets, database?: string): NiceEnvironmentSet | undefined;
|
|
141
|
+
/** A problem found in a module's integrations. */
|
|
142
|
+
export interface NiceIntegrationIssue {
|
|
143
|
+
severity: 'error' | 'warning';
|
|
144
|
+
integration?: string;
|
|
145
|
+
/** A stable code (for translations): `variableUndeclared`, `secretInSeed`, … */
|
|
146
|
+
code: 'keyDuplicate' | 'baseUrlMissing' | 'variableUndeclared' | 'secretInSeed' | 'requiredUnset' | 'endpointMissing' | 'extendsMissing' | 'requiresMissing';
|
|
147
|
+
message: string;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Checks a module's integrations against its environment sets: unique keys, a base URL, every
|
|
151
|
+
* `{{variable}}` declared, no secret written as a plain value, required variables set in every set,
|
|
152
|
+
* operations pointing at existing endpoints, `extends` to existing sets, and — given the module's
|
|
153
|
+
* neighbours — what `requires` names exists.
|
|
154
|
+
*/
|
|
155
|
+
export declare function validateIntegrations(file: NiceIntegrationsFile, sets?: NiceEnvironmentSets, known?: {
|
|
156
|
+
modules?: string[];
|
|
157
|
+
dataSources?: string[];
|
|
158
|
+
}): NiceIntegrationIssue[];
|
|
159
|
+
/** The integrations grouped for a tree: package → direction → integrations. */
|
|
160
|
+
export declare function groupIntegrations(integrations: readonly NiceIntegrationDef[]): {
|
|
161
|
+
package: string;
|
|
162
|
+
directions: {
|
|
163
|
+
direction: NiceIntegrationDirection;
|
|
164
|
+
integrations: NiceIntegrationDef[];
|
|
165
|
+
}[];
|
|
166
|
+
}[];
|
|
167
|
+
/** Every request of an integration's API and every endpoint it exposes, for pickers (operation → endpoint). */
|
|
168
|
+
export declare function integrationEndpoints(integration: NiceIntegrationDef): {
|
|
169
|
+
id: string;
|
|
170
|
+
label: string;
|
|
171
|
+
exposed: boolean;
|
|
172
|
+
}[];
|