nucleus-core-ts 0.9.847 → 0.9.848
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/dist/fe/components/IntegrationsPage/components/EndpointForm.d.ts +2 -1
- package/dist/fe/components/IntegrationsPage/components/EndpointForm.js +1 -1
- package/dist/fe/components/IntegrationsPage/components/EndpointsTab.js +6 -1
- package/dist/fe/components/IntegrationsPage/components/MappingsTab.js +6 -0
- package/dist/fe/components/IntegrationsPage/store/index.js +22 -0
- package/dist/fe/components/IntegrationsPage/store/state.d.ts +22 -0
- package/package.json +1 -1
|
@@ -5,7 +5,8 @@ export type EndpointFormProps = {
|
|
|
5
5
|
endpoint: IntegrationEndpoint | null;
|
|
6
6
|
actions: IntegrationsActions;
|
|
7
7
|
onSaved: (endpoint: IntegrationEndpoint) => void;
|
|
8
|
-
|
|
8
|
+
/** Told WHICH call went, so the list can drop it without waiting for a fetch. */
|
|
9
|
+
onDeleted: (deletedId: string) => void;
|
|
9
10
|
onCancel: () => void;
|
|
10
11
|
};
|
|
11
12
|
export declare function EndpointForm({ sourceId, endpoint, actions, onSaved, onDeleted, onCancel, }: EndpointFormProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -113,7 +113,7 @@ export function EndpointForm({ sourceId, endpoint, actions, onSaved, onDeleted,
|
|
|
113
113
|
store.setError(null);
|
|
114
114
|
actions.deleteEndpoint(endpoint.id).then((ok)=>{
|
|
115
115
|
setDeleting(false);
|
|
116
|
-
if (ok) onDeleted();
|
|
116
|
+
if (ok) onDeleted(endpoint.id);
|
|
117
117
|
else store.setError('The endpoint was not deleted.');
|
|
118
118
|
}).catch(fail('Deleting the endpoint failed.'));
|
|
119
119
|
};
|
|
@@ -52,13 +52,18 @@ export function EndpointsTab({ actions }) {
|
|
|
52
52
|
};
|
|
53
53
|
const handleSaved = (saved)=>{
|
|
54
54
|
setCreating(false);
|
|
55
|
+
// Into the list FIRST. `editing` is looked up in store.endpoints, so
|
|
56
|
+
// selecting an id the list has not fetched yet made the whole editor
|
|
57
|
+
// collapse to "pick one" — with the form still half-filled a moment ago.
|
|
58
|
+
store.upsertEndpoint(saved);
|
|
55
59
|
// Re-selecting drops the old sample: it described the call as it was
|
|
56
60
|
// configured a moment ago, and the mapping would be built from it.
|
|
57
61
|
store.selectEndpoint(saved.id);
|
|
58
62
|
setReloadToken((token)=>token + 1);
|
|
59
63
|
};
|
|
60
|
-
const handleDeleted = ()=>{
|
|
64
|
+
const handleDeleted = (deletedId)=>{
|
|
61
65
|
setCreating(false);
|
|
66
|
+
store.removeEndpoint(deletedId);
|
|
62
67
|
store.selectEndpoint(null);
|
|
63
68
|
setReloadToken((token)=>token + 1);
|
|
64
69
|
};
|
|
@@ -144,6 +144,11 @@ export function MappingsTab({ actions }) {
|
|
|
144
144
|
if (!saved) return store.setError('The mapping was not saved.');
|
|
145
145
|
setCreating(false);
|
|
146
146
|
setSelected(saved);
|
|
147
|
+
// Into the list too, not just local state. The IMPORT step finds its
|
|
148
|
+
// mapping in store.mappings, and the list that fills it is unmounted
|
|
149
|
+
// the moment that step is shown — so "Run import" on a mapping saved a
|
|
150
|
+
// second earlier landed on "choose a mapping".
|
|
151
|
+
store.upsertMapping(saved);
|
|
147
152
|
store.selectMapping(saved.id);
|
|
148
153
|
setReloadToken((token)=>token + 1);
|
|
149
154
|
then?.(saved);
|
|
@@ -178,6 +183,7 @@ export function MappingsTab({ actions }) {
|
|
|
178
183
|
actions.deleteMapping(id).then((removed)=>{
|
|
179
184
|
setDeleting(false);
|
|
180
185
|
if (!removed) return store.setError('The mapping was not deleted.');
|
|
186
|
+
store.removeMapping(id);
|
|
181
187
|
closeEditor();
|
|
182
188
|
setReloadToken((token)=>token + 1);
|
|
183
189
|
}).catch((error)=>{
|
|
@@ -66,6 +66,17 @@ export const { useStore: useIntegrationsStore } = createStore(initial, {
|
|
|
66
66
|
store.endpointsTotal = total;
|
|
67
67
|
store.endpointsLoading = false;
|
|
68
68
|
}),
|
|
69
|
+
upsertEndpoint: (store)=>(endpoint)=>batch(()=>{
|
|
70
|
+
if (isNewTo(store.endpoints, endpoint)) store.endpointsTotal = store.endpointsTotal + 1;
|
|
71
|
+
store.endpoints = upsertInto(store.endpoints, endpoint);
|
|
72
|
+
}),
|
|
73
|
+
removeEndpoint: (store)=>(id)=>batch(()=>{
|
|
74
|
+
const kept = store.endpoints.filter((candidate)=>candidate.id !== id);
|
|
75
|
+
if (kept.length !== store.endpoints.length) {
|
|
76
|
+
store.endpointsTotal = Math.max(0, store.endpointsTotal - 1);
|
|
77
|
+
store.endpoints = kept;
|
|
78
|
+
}
|
|
79
|
+
}),
|
|
69
80
|
setEndpointsSearch: (store)=>(search)=>batch(()=>{
|
|
70
81
|
store.endpointsSearch = search;
|
|
71
82
|
store.endpointsPage = 1;
|
|
@@ -84,6 +95,17 @@ export const { useStore: useIntegrationsStore } = createStore(initial, {
|
|
|
84
95
|
store.mappingsTotal = total;
|
|
85
96
|
store.mappingsLoading = false;
|
|
86
97
|
}),
|
|
98
|
+
upsertMapping: (store)=>(mapping)=>batch(()=>{
|
|
99
|
+
if (isNewTo(store.mappings, mapping)) store.mappingsTotal = store.mappingsTotal + 1;
|
|
100
|
+
store.mappings = upsertInto(store.mappings, mapping);
|
|
101
|
+
}),
|
|
102
|
+
removeMapping: (store)=>(id)=>batch(()=>{
|
|
103
|
+
const kept = store.mappings.filter((candidate)=>candidate.id !== id);
|
|
104
|
+
if (kept.length !== store.mappings.length) {
|
|
105
|
+
store.mappingsTotal = Math.max(0, store.mappingsTotal - 1);
|
|
106
|
+
store.mappings = kept;
|
|
107
|
+
}
|
|
108
|
+
}),
|
|
87
109
|
setMappingsTotal: (store)=>(total)=>{
|
|
88
110
|
store.mappingsTotal = total;
|
|
89
111
|
},
|
|
@@ -76,6 +76,17 @@ export type Actions = {
|
|
|
76
76
|
setTab: (tab: ConnectionTab) => void;
|
|
77
77
|
setFocusTargetEntity: (entity: string | null, step?: 'mapping' | 'import') => void;
|
|
78
78
|
setEndpoints: (items: IntegrationEndpoint[], total: number) => void;
|
|
79
|
+
/**
|
|
80
|
+
* Put one call into the list, whether or not it is already there.
|
|
81
|
+
*
|
|
82
|
+
* Same reason as [upsertSource]: the list is the only thing that fetches, and
|
|
83
|
+
* the editor finds the record it is editing BY LOOKING IN THAT LIST. Between
|
|
84
|
+
* saving and the refetch landing, the record is in neither — so the editor
|
|
85
|
+
* collapsed to "pick one" and the form the operator was filling in vanished.
|
|
86
|
+
*/
|
|
87
|
+
upsertEndpoint: (endpoint: IntegrationEndpoint) => void;
|
|
88
|
+
/** Drop one call from the list, for when it has just been deleted. */
|
|
89
|
+
removeEndpoint: (id: string) => void;
|
|
79
90
|
/**
|
|
80
91
|
* Just the count, without the rows.
|
|
81
92
|
*
|
|
@@ -86,6 +97,17 @@ export type Actions = {
|
|
|
86
97
|
setEndpointsLoading: (loading: boolean) => void;
|
|
87
98
|
selectEndpoint: (id: string | null) => void;
|
|
88
99
|
setMappings: (items: IntegrationMapping[], total: number) => void;
|
|
100
|
+
/**
|
|
101
|
+
* Put one mapping into the list, whether or not it is already there.
|
|
102
|
+
*
|
|
103
|
+
* The import step looks the selected mapping up in this array, and the list
|
|
104
|
+
* that fills it belongs to the MAPPINGS tab — which is unmounted the moment
|
|
105
|
+
* the import step is shown. Saving a mapping and pressing "Run import" landed
|
|
106
|
+
* on a screen that said "choose a mapping" about the one just saved.
|
|
107
|
+
*/
|
|
108
|
+
upsertMapping: (mapping: IntegrationMapping) => void;
|
|
109
|
+
/** Drop one mapping from the list, for when it has just been deleted. */
|
|
110
|
+
removeMapping: (id: string) => void;
|
|
89
111
|
setMappingsTotal: (total: number) => void;
|
|
90
112
|
setMappingsSearch: (search: string) => void;
|
|
91
113
|
setMappingsLoading: (loading: boolean) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nucleus-core-ts",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.848",
|
|
4
4
|
"description": "Production-ready, enterprise-grade TypeScript framework for building multi-tenant APIs",
|
|
5
5
|
"author": "Hidayet Can Özcan <hidayetcan@gmail.com>",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|