@truedat/dd 5.15.2 → 5.16.2
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truedat/dd",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.16.2",
|
|
4
4
|
"description": "Truedat Web Data Dictionary",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"jsnext:main": "src/index.js",
|
|
@@ -115,5 +115,5 @@
|
|
|
115
115
|
"react-dom": ">= 16.8.6 < 17",
|
|
116
116
|
"semantic-ui-react": ">= 2.0.3 < 2.2"
|
|
117
117
|
},
|
|
118
|
-
"gitHead": "
|
|
118
|
+
"gitHead": "4f7b257765169d14b8415107ee59d8b76124f829"
|
|
119
119
|
}
|
|
@@ -22,6 +22,8 @@ export const graphLoading = (state = false, { type, payload }) => {
|
|
|
22
22
|
return payload || true;
|
|
23
23
|
case createStructureGraph.REQUEST:
|
|
24
24
|
return true;
|
|
25
|
+
case fetchGraph.SUCCESS:
|
|
26
|
+
case fetchGraph.FAILURE:
|
|
25
27
|
case fetchGraph.FULFILL:
|
|
26
28
|
return false;
|
|
27
29
|
case fetchGraph.REQUEST:
|
|
@@ -5,10 +5,10 @@ import { apiJson, apiJsonPost, JSON_OPTS } from "@truedat/core/services/api";
|
|
|
5
5
|
import {
|
|
6
6
|
createGraphRequestSaga,
|
|
7
7
|
createGraphSaga,
|
|
8
|
-
polling,
|
|
9
8
|
POLLING_CANCELLED,
|
|
10
9
|
selectLineageQuery,
|
|
11
10
|
} from "../createGraph";
|
|
11
|
+
import { polling } from "../graph/polling";
|
|
12
12
|
import {
|
|
13
13
|
cancelPoll,
|
|
14
14
|
createGraph,
|
|
@@ -117,7 +117,7 @@ describe("sagas: createGraphSaga", () => {
|
|
|
117
117
|
.next(graphAccepted)
|
|
118
118
|
.put(fetchGraph.request(graphAccepted))
|
|
119
119
|
.next()
|
|
120
|
-
.fork(polling, graphAccepted, isRedirected)
|
|
120
|
+
.fork(polling, createGraph, graphAccepted, isRedirected)
|
|
121
121
|
.next()
|
|
122
122
|
.take(cancelPoll.TRIGGER)
|
|
123
123
|
.next()
|
|
@@ -171,7 +171,7 @@ describe("generator: polling", () => {
|
|
|
171
171
|
|
|
172
172
|
it("polling should keep requesting by graph hash until graph is received", () => {
|
|
173
173
|
expect(() => {
|
|
174
|
-
testSaga(polling, graphAccepted, isRedirected)
|
|
174
|
+
testSaga(polling, createGraph, graphAccepted, isRedirected)
|
|
175
175
|
.next()
|
|
176
176
|
.delay(1000)
|
|
177
177
|
.next()
|
|
@@ -207,7 +207,7 @@ describe("generator: polling", () => {
|
|
|
207
207
|
|
|
208
208
|
it("cancel should stop polling and return createGraph failure", () => {
|
|
209
209
|
expect(() => {
|
|
210
|
-
testSaga(polling, graphAccepted, isRedirected)
|
|
210
|
+
testSaga(polling, createGraph, graphAccepted, isRedirected)
|
|
211
211
|
.next()
|
|
212
212
|
.delay(1000)
|
|
213
213
|
.next()
|
package/src/sagas/createGraph.js
CHANGED
|
@@ -1,55 +1,43 @@
|
|
|
1
|
-
/* eslint-disable fp/no-mutation */
|
|
2
|
-
/* eslint-disable fp/no-let */
|
|
3
1
|
import _ from "lodash/fp";
|
|
4
2
|
import {
|
|
5
3
|
all,
|
|
6
4
|
call,
|
|
7
5
|
cancel,
|
|
8
|
-
cancelled,
|
|
9
6
|
fork,
|
|
10
7
|
put,
|
|
11
8
|
select,
|
|
12
9
|
take,
|
|
13
10
|
takeLatest,
|
|
14
|
-
delay,
|
|
15
11
|
} from "redux-saga/effects";
|
|
16
|
-
import {
|
|
17
|
-
import { compile } from "path-to-regexp";
|
|
12
|
+
import { apiJsonPost, JSON_OPTS } from "@truedat/core/services/api";
|
|
18
13
|
import { excludeNode, cancelPoll, createGraph, fetchGraph } from "../routines";
|
|
19
|
-
import { API_GRAPHS
|
|
14
|
+
import { API_GRAPHS } from "../api";
|
|
15
|
+
import { polling } from "./graph/polling";
|
|
20
16
|
|
|
21
17
|
export const selectLineageQuery = _.prop("lineageQuery");
|
|
22
18
|
|
|
23
19
|
export const POLLING_CANCELLED = "Polling cancelled!";
|
|
24
20
|
|
|
25
|
-
function* exponentialBackoff(base, power) {
|
|
26
|
-
while (true) {
|
|
27
|
-
yield Math.pow(base, power);
|
|
28
|
-
// eslint-disable-next-line fp/no-mutation, no-param-reassign
|
|
29
|
-
power++;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
21
|
export function* createGraphSaga() {
|
|
34
|
-
let graphAcceptedOrCreated;
|
|
35
22
|
try {
|
|
36
23
|
const body = yield select(selectLineageQuery);
|
|
37
24
|
yield put(createGraph.request(body));
|
|
38
25
|
|
|
39
26
|
/* graph is either new (accepted) or "created" (actually previously stored
|
|
40
27
|
from an earlier accepted one) */
|
|
41
|
-
graphAcceptedOrCreated = yield call(
|
|
28
|
+
const graphAcceptedOrCreated = yield call(
|
|
42
29
|
apiJsonPost,
|
|
43
30
|
API_GRAPHS,
|
|
44
31
|
body,
|
|
45
32
|
JSON_OPTS
|
|
46
33
|
);
|
|
47
34
|
|
|
48
|
-
if (graphAcceptedOrCreated.status
|
|
35
|
+
if (graphAcceptedOrCreated.status === 202) {
|
|
49
36
|
yield put(fetchGraph.request(graphAcceptedOrCreated));
|
|
50
37
|
// starts the task in the background
|
|
51
38
|
const pollingTask = yield fork(
|
|
52
39
|
polling,
|
|
40
|
+
createGraph,
|
|
53
41
|
graphAcceptedOrCreated,
|
|
54
42
|
body.isRedirected
|
|
55
43
|
);
|
|
@@ -59,7 +47,7 @@ export function* createGraphSaga() {
|
|
|
59
47
|
// user clicked stop. cancel the background task
|
|
60
48
|
// this will cause the forked bgSync task to jump into its finally block
|
|
61
49
|
yield cancel(pollingTask);
|
|
62
|
-
} else if (graphAcceptedOrCreated.status
|
|
50
|
+
} else if (graphAcceptedOrCreated.status === 201) {
|
|
63
51
|
yield put(
|
|
64
52
|
createGraph.success({
|
|
65
53
|
...graphAcceptedOrCreated,
|
|
@@ -82,58 +70,6 @@ export function* createGraphSaga() {
|
|
|
82
70
|
}
|
|
83
71
|
}
|
|
84
72
|
|
|
85
|
-
export function* polling(graphAccepted, isRedirected) {
|
|
86
|
-
const backoff = exponentialBackoff(1.2, 0);
|
|
87
|
-
let backoffTime,
|
|
88
|
-
retry = 0,
|
|
89
|
-
graphResp,
|
|
90
|
-
isCancelled = false;
|
|
91
|
-
|
|
92
|
-
do {
|
|
93
|
-
backoffTime = backoff.next().value * 1000;
|
|
94
|
-
yield delay(backoffTime);
|
|
95
|
-
|
|
96
|
-
try {
|
|
97
|
-
graphResp = yield call(
|
|
98
|
-
apiJson,
|
|
99
|
-
compile(API_GRAPH_HASH)({
|
|
100
|
-
hash: graphAccepted.data.graph_hash,
|
|
101
|
-
}),
|
|
102
|
-
JSON_OPTS
|
|
103
|
-
);
|
|
104
|
-
} catch (error) {
|
|
105
|
-
if (error.response) {
|
|
106
|
-
const { status, data } = error.response;
|
|
107
|
-
yield put(createGraph.failure({ status, data }));
|
|
108
|
-
} else {
|
|
109
|
-
yield put(createGraph.failure(error.message));
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
graphResp?.status == 202 &&
|
|
114
|
-
(yield put(
|
|
115
|
-
fetchGraph.failure({
|
|
116
|
-
data: {
|
|
117
|
-
graph_hash: graphAccepted.data.graph_hash,
|
|
118
|
-
retry: ++retry,
|
|
119
|
-
},
|
|
120
|
-
})
|
|
121
|
-
));
|
|
122
|
-
|
|
123
|
-
isCancelled = yield cancelled();
|
|
124
|
-
isCancelled && (yield put(createGraph.failure(POLLING_CANCELLED)));
|
|
125
|
-
} while (!isCancelled && graphResp?.status == 202);
|
|
126
|
-
|
|
127
|
-
graphResp?.status == 200 && !isCancelled
|
|
128
|
-
? yield put(
|
|
129
|
-
createGraph.success({
|
|
130
|
-
...graphResp,
|
|
131
|
-
data: { ...graphResp.data, isRedirected },
|
|
132
|
-
})
|
|
133
|
-
)
|
|
134
|
-
: yield put(createGraph.failure({}));
|
|
135
|
-
}
|
|
136
|
-
|
|
137
73
|
export function* createGraphRequestSaga() {
|
|
138
74
|
yield all([
|
|
139
75
|
takeLatest(createGraph.TRIGGER, createGraphSaga),
|
package/src/sagas/fetchGraph.js
CHANGED
|
@@ -1,18 +1,40 @@
|
|
|
1
|
+
import _ from "lodash/fp";
|
|
1
2
|
import { compile } from "path-to-regexp";
|
|
2
|
-
import { call, put, takeLatest } from "redux-saga/effects";
|
|
3
|
+
import { call, cancel, fork, put, take, takeLatest } from "redux-saga/effects";
|
|
3
4
|
import { apiJson, JSON_OPTS } from "@truedat/core/services/api";
|
|
4
|
-
import { fetchGraph } from "../routines";
|
|
5
5
|
import { API_GRAPH } from "../api";
|
|
6
|
+
import { cancelPoll, fetchGraph } from "../routines";
|
|
7
|
+
import { polling } from "./graph/polling";
|
|
6
8
|
|
|
7
9
|
const toApiPath = compile(API_GRAPH);
|
|
8
10
|
|
|
11
|
+
export const selectLineageQuery = _.prop("lineageQuery");
|
|
12
|
+
|
|
9
13
|
export function* fetchGraphSaga({ payload }) {
|
|
10
14
|
try {
|
|
11
15
|
const url = toApiPath(payload);
|
|
12
16
|
yield put(fetchGraph.request(payload));
|
|
13
|
-
const { data } = yield call(apiJson, url, JSON_OPTS);
|
|
14
17
|
|
|
15
|
-
|
|
18
|
+
/* graph is either new (202 accepted) or 200 OK*/
|
|
19
|
+
const graphAcceptedOrFetched = yield call(apiJson, url, JSON_OPTS);
|
|
20
|
+
|
|
21
|
+
if (graphAcceptedOrFetched.status === 202) {
|
|
22
|
+
yield put(fetchGraph.request(graphAcceptedOrFetched));
|
|
23
|
+
// starts the task in the background
|
|
24
|
+
const pollingTask = yield fork(
|
|
25
|
+
polling,
|
|
26
|
+
fetchGraph,
|
|
27
|
+
graphAcceptedOrFetched
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
// wait for the user stop action
|
|
31
|
+
yield take(cancelPoll.TRIGGER);
|
|
32
|
+
// user clicked stop. cancel the background task
|
|
33
|
+
// this will cause the forked bgSync task to jump into its finally block
|
|
34
|
+
yield cancel(pollingTask);
|
|
35
|
+
} else if (graphAcceptedOrFetched.status === 200) {
|
|
36
|
+
yield put(yield put(fetchGraph.success(graphAcceptedOrFetched.data)));
|
|
37
|
+
}
|
|
16
38
|
} catch (error) {
|
|
17
39
|
if (error.response) {
|
|
18
40
|
const { status, data } = error.response;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/* eslint-disable fp/no-mutation */
|
|
2
|
+
/* eslint-disable fp/no-let */
|
|
3
|
+
|
|
4
|
+
import { call, cancelled, delay, put } from "redux-saga/effects";
|
|
5
|
+
import { apiJson, JSON_OPTS } from "@truedat/core/services/api";
|
|
6
|
+
import { compile } from "path-to-regexp";
|
|
7
|
+
import { fetchGraph } from "../../routines";
|
|
8
|
+
import { API_GRAPH_HASH } from "../../api";
|
|
9
|
+
|
|
10
|
+
export const POLLING_CANCELLED = "Polling cancelled!";
|
|
11
|
+
|
|
12
|
+
function* exponentialBackoff(base, power) {
|
|
13
|
+
while (true) {
|
|
14
|
+
yield Math.pow(base, power);
|
|
15
|
+
// eslint-disable-next-line fp/no-mutation, no-param-reassign
|
|
16
|
+
power++;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function* polling(routine, graphAccepted, isRedirected) {
|
|
21
|
+
const backoff = exponentialBackoff(1.2, 0);
|
|
22
|
+
let backoffTime,
|
|
23
|
+
retry = 0,
|
|
24
|
+
graphResp,
|
|
25
|
+
isCancelled = false;
|
|
26
|
+
|
|
27
|
+
do {
|
|
28
|
+
backoffTime = backoff.next().value * 1000;
|
|
29
|
+
yield delay(backoffTime);
|
|
30
|
+
|
|
31
|
+
try {
|
|
32
|
+
graphResp = yield call(
|
|
33
|
+
apiJson,
|
|
34
|
+
compile(API_GRAPH_HASH)({
|
|
35
|
+
hash: graphAccepted.data.graph_hash,
|
|
36
|
+
}),
|
|
37
|
+
JSON_OPTS
|
|
38
|
+
);
|
|
39
|
+
} catch (error) {
|
|
40
|
+
if (error.response) {
|
|
41
|
+
const { status, data } = error.response;
|
|
42
|
+
yield put(routine.failure({ status, data }));
|
|
43
|
+
} else {
|
|
44
|
+
yield put(routine.failure(error.message));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
graphResp?.status == 202 &&
|
|
49
|
+
(yield put(
|
|
50
|
+
fetchGraph.failure({
|
|
51
|
+
data: {
|
|
52
|
+
graph_hash: graphAccepted.data.graph_hash,
|
|
53
|
+
retry: ++retry,
|
|
54
|
+
},
|
|
55
|
+
})
|
|
56
|
+
));
|
|
57
|
+
|
|
58
|
+
isCancelled = yield cancelled();
|
|
59
|
+
isCancelled && (yield put(routine.failure(POLLING_CANCELLED)));
|
|
60
|
+
} while (!isCancelled && graphResp?.status == 202);
|
|
61
|
+
|
|
62
|
+
graphResp?.status == 200 && !isCancelled
|
|
63
|
+
? yield put(
|
|
64
|
+
routine.success({
|
|
65
|
+
...graphResp,
|
|
66
|
+
data: { ...graphResp.data, isRedirected: isRedirected || false },
|
|
67
|
+
})
|
|
68
|
+
)
|
|
69
|
+
: yield put(routine.failure({}));
|
|
70
|
+
}
|