@or-sdk/data-hub 0.13.0 → 0.16.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.
- package/dist/cjs/DataHub.js +17 -15
- package/dist/cjs/DataHub.js.map +1 -1
- package/dist/cjs/constants.js +2 -1
- package/dist/cjs/constants.js.map +1 -1
- package/dist/esm/DataHub.js +16 -14
- package/dist/esm/DataHub.js.map +1 -1
- package/dist/esm/constants.js +3 -0
- package/dist/esm/constants.js.map +1 -1
- package/dist/types/DataHub.d.ts +2 -1
- package/dist/types/constants.d.ts +1 -0
- package/dist/types/types.d.ts +22 -24
- package/package.json +3 -3
- package/src/DataHub.ts +23 -13
- package/src/constants.ts +4 -0
- package/src/types.ts +26 -11
package/dist/cjs/DataHub.js
CHANGED
|
@@ -79,12 +79,12 @@ var DataHub = (function (_super) {
|
|
|
79
79
|
__extends(DataHub, _super);
|
|
80
80
|
function DataHub(params) {
|
|
81
81
|
var _this = this;
|
|
82
|
-
var token = params.token, discoveryUrl = params.discoveryUrl;
|
|
82
|
+
var token = params.token, discoveryUrl = params.discoveryUrl, accountId = params.accountId;
|
|
83
83
|
_this = _super.call(this, {
|
|
84
84
|
token: token,
|
|
85
85
|
discoveryUrl: discoveryUrl,
|
|
86
86
|
serviceKey: constants_1.SERVICE_KEY,
|
|
87
|
-
|
|
87
|
+
accountId: accountId,
|
|
88
88
|
}) || this;
|
|
89
89
|
return _this;
|
|
90
90
|
}
|
|
@@ -98,9 +98,12 @@ var DataHub = (function (_super) {
|
|
|
98
98
|
});
|
|
99
99
|
});
|
|
100
100
|
};
|
|
101
|
+
DataHub.prototype.getOperationName = function (name) {
|
|
102
|
+
return this.isCrossAccount ? name + "CrossAccount" : name;
|
|
103
|
+
};
|
|
101
104
|
DataHub.prototype.subscribe = function (requestId) {
|
|
102
105
|
return __awaiter(this, void 0, void 0, function () {
|
|
103
|
-
var counter, variables, data, result;
|
|
106
|
+
var counter, operationName, variables, data, result, executionResult;
|
|
104
107
|
return __generator(this, function (_a) {
|
|
105
108
|
switch (_a.label) {
|
|
106
109
|
case 0:
|
|
@@ -108,6 +111,7 @@ var DataHub = (function (_super) {
|
|
|
108
111
|
throw new Error('subscription error: requestId is required');
|
|
109
112
|
}
|
|
110
113
|
counter = 0;
|
|
114
|
+
operationName = this.getOperationName('checkExecutionResult');
|
|
111
115
|
_a.label = 1;
|
|
112
116
|
case 1:
|
|
113
117
|
counter++;
|
|
@@ -118,23 +122,20 @@ var DataHub = (function (_super) {
|
|
|
118
122
|
requestId: requestId,
|
|
119
123
|
hash: (0, uuid_1.v4)(),
|
|
120
124
|
};
|
|
121
|
-
data = {
|
|
122
|
-
operationName: 'checkExecutionResult',
|
|
123
|
-
query: constants_1.QUERY_CHECK_EXECUTION_RESULT,
|
|
124
|
-
variables: variables,
|
|
125
|
-
};
|
|
125
|
+
data = __assign({ operationName: operationName, query: this.isCrossAccount ? constants_1.QUERY_CHECK_EXECUTION_RESULT_CROSSACCOUNT : constants_1.QUERY_CHECK_EXECUTION_RESULT, variables: variables }, this.isCrossAccount ? { accountId: this.currentAccountId } : {});
|
|
126
126
|
return [4, this.makeRequest({
|
|
127
127
|
method: 'POST',
|
|
128
128
|
route: '/graphql',
|
|
129
129
|
data: data,
|
|
130
130
|
})];
|
|
131
131
|
case 3:
|
|
132
|
-
result =
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
132
|
+
result = _a.sent();
|
|
133
|
+
executionResult = result.data[operationName];
|
|
134
|
+
if (executionResult.status !== 'pending') {
|
|
135
|
+
if (executionResult.error) {
|
|
136
|
+
throw executionResult.error;
|
|
136
137
|
}
|
|
137
|
-
return [2,
|
|
138
|
+
return [2, executionResult];
|
|
138
139
|
}
|
|
139
140
|
_a.label = 4;
|
|
140
141
|
case 4:
|
|
@@ -147,11 +148,12 @@ var DataHub = (function (_super) {
|
|
|
147
148
|
};
|
|
148
149
|
DataHub.prototype.getFullList = function (method, route, data) {
|
|
149
150
|
return __awaiter(this, void 0, void 0, function () {
|
|
150
|
-
var resultList, resultFullList, result;
|
|
151
|
+
var resultList, resultFullList, operationName, result;
|
|
151
152
|
return __generator(this, function (_a) {
|
|
152
153
|
switch (_a.label) {
|
|
153
154
|
case 0:
|
|
154
155
|
resultFullList = [];
|
|
156
|
+
operationName = data.operationName;
|
|
155
157
|
_a.label = 1;
|
|
156
158
|
case 1: return [4, this.makeRequest({
|
|
157
159
|
method: method,
|
|
@@ -160,7 +162,7 @@ var DataHub = (function (_super) {
|
|
|
160
162
|
})];
|
|
161
163
|
case 2:
|
|
162
164
|
result = _a.sent();
|
|
163
|
-
resultList = result.data
|
|
165
|
+
resultList = result.data[operationName];
|
|
164
166
|
resultFullList = __spreadArray(__spreadArray([], resultFullList, true), resultList.records, true);
|
|
165
167
|
data.variables.params = __assign(__assign({}, data.variables.params), { last: resultList.last });
|
|
166
168
|
_a.label = 3;
|
package/dist/cjs/DataHub.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataHub.js","sourceRoot":"","sources":["../../src/DataHub.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAA2E;AAO3E,
|
|
1
|
+
{"version":3,"file":"DataHub.js","sourceRoot":"","sources":["../../src/DataHub.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAA2E;AAO3E,yCAAmH;AACnH,6BAAoC;AASpC;IAA6B,2BAAI;IAO/B,iBAAY,MAAqB;QAAjC,iBASC;QARS,IAAA,KAAK,GAA8B,MAAM,MAApC,EAAE,YAAY,GAAgB,MAAM,aAAtB,EAAE,SAAS,GAAK,MAAM,UAAX,CAAY;QAElD,QAAA,kBAAM;YACJ,KAAK,OAAA;YACL,YAAY,cAAA;YACZ,UAAU,E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AAe,CAAC,MAAM,KAAK,SAAS,EAAE;4BACxC,IAAI,eAAe,CAAC,KAAK,EAAE;gCACzB,MAAM,eAAe,CAAC,KAAK,CAAC;6BAC7B;4BAED,WAAO,eAAe,EAAC;yBACxB;;;4BAEM,OAAO,GAAG,GAAG;;4BAEtB,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;;;;KAC5D;IAQY,6BAAW,GAAxB,UAA4B,MAA8B,EAAE,KAAa,EAAE,IAAwB;;;;;;wBAE7F,cAAc,GAAQ,EAAE,CAAC;wBACvB,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC;;4BAGxB,WAAM,IAAI,CAAC,WAAW,CAAqB;4BACxD,MAAM,QAAA;4BACN,KAAK,OAAA;4BACL,IAAI,MAAA;yBACL,CAAC,EAAA;;wBAJI,MAAM,GAAG,SAIb;wBAEF,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,aAAa,CAA2B,CAAC;wBAClE,cAAc,mCAAO,cAAc,SAAK,UAAU,CAAC,OAAO,OAAC,CAAC;wBAE5D,IAAI,CAAC,SAAS,CAAC,MAAM,yBAChB,IAAI,CAAC,SAAS,CAAC,MAAM,KACxB,IAAI,EAAE,UAAU,CAAC,IAAI,GACtB,CAAC;;;4BAEK,UAAU,CAAC,IAAI;;4BAExB,WAAO,IAAA,eAAQ,EAAI,cAAc,CAAC,EAAC;;;;KACpC;IAEH,cAAC;AAAD,CAAC,AAxHD,CAA6B,WAAI,GAwHhC;AAxHY,0BAAO"}
|
package/dist/cjs/constants.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.QUERY_CHECK_EXECUTION_RESULT = exports.SERVICE_KEY = void 0;
|
|
3
|
+
exports.QUERY_CHECK_EXECUTION_RESULT_CROSSACCOUNT = exports.QUERY_CHECK_EXECUTION_RESULT = exports.SERVICE_KEY = void 0;
|
|
4
4
|
exports.SERVICE_KEY = 'data-hub';
|
|
5
5
|
exports.QUERY_CHECK_EXECUTION_RESULT = "query checkExecutionResult($hash: ID!, $requestId: String!) {\n checkExecutionResult(requestId: $requestId, hash: $hash)\n}";
|
|
6
|
+
exports.QUERY_CHECK_EXECUTION_RESULT_CROSSACCOUNT = "query checkExecutionResultCrossAccount($hash: ID!, $requestId: String!, $accountId: String!) {\n checkExecutionResultCrossAccount(requestId: $requestId, hash: $hash, accountId: $accountId)\n}";
|
|
6
7
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,WAAW,GAAG,UAAU,CAAC;AAEzB,QAAA,4BAA4B,GAAG,8HAE1C,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,WAAW,GAAG,UAAU,CAAC;AAEzB,QAAA,4BAA4B,GAAG,8HAE1C,CAAC;AAEU,QAAA,yCAAyC,GAAG,kMAEvD,CAAC"}
|
package/dist/esm/DataHub.js
CHANGED
|
@@ -8,16 +8,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { Base, timeout, makeList } from '@or-sdk/base';
|
|
11
|
-
import { SERVICE_KEY, QUERY_CHECK_EXECUTION_RESULT } from './constants';
|
|
11
|
+
import { SERVICE_KEY, QUERY_CHECK_EXECUTION_RESULT, QUERY_CHECK_EXECUTION_RESULT_CROSSACCOUNT } from './constants';
|
|
12
12
|
import { v4 as uuidv4 } from 'uuid';
|
|
13
13
|
export class DataHub extends Base {
|
|
14
14
|
constructor(params) {
|
|
15
|
-
const { token, discoveryUrl } = params;
|
|
15
|
+
const { token, discoveryUrl, accountId } = params;
|
|
16
16
|
super({
|
|
17
17
|
token,
|
|
18
18
|
discoveryUrl,
|
|
19
19
|
serviceKey: SERVICE_KEY,
|
|
20
|
-
|
|
20
|
+
accountId,
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
makeRequest(params) {
|
|
@@ -25,12 +25,16 @@ export class DataHub extends Base {
|
|
|
25
25
|
return yield this.callApi(params);
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
|
+
getOperationName(name) {
|
|
29
|
+
return this.isCrossAccount ? `${name}CrossAccount` : name;
|
|
30
|
+
}
|
|
28
31
|
subscribe(requestId) {
|
|
29
32
|
return __awaiter(this, void 0, void 0, function* () {
|
|
30
33
|
if (!requestId) {
|
|
31
34
|
throw new Error('subscription error: requestId is required');
|
|
32
35
|
}
|
|
33
36
|
let counter = 0;
|
|
37
|
+
const operationName = this.getOperationName('checkExecutionResult');
|
|
34
38
|
do {
|
|
35
39
|
counter++;
|
|
36
40
|
yield timeout(1000);
|
|
@@ -38,21 +42,18 @@ export class DataHub extends Base {
|
|
|
38
42
|
requestId,
|
|
39
43
|
hash: uuidv4(),
|
|
40
44
|
};
|
|
41
|
-
const data = {
|
|
42
|
-
|
|
43
|
-
query: QUERY_CHECK_EXECUTION_RESULT,
|
|
44
|
-
variables,
|
|
45
|
-
};
|
|
46
|
-
const { data: { checkExecutionResult: result } } = yield this.makeRequest({
|
|
45
|
+
const data = Object.assign({ operationName, query: this.isCrossAccount ? QUERY_CHECK_EXECUTION_RESULT_CROSSACCOUNT : QUERY_CHECK_EXECUTION_RESULT, variables }, this.isCrossAccount ? { accountId: this.currentAccountId } : {});
|
|
46
|
+
const result = yield this.makeRequest({
|
|
47
47
|
method: 'POST',
|
|
48
48
|
route: '/graphql',
|
|
49
49
|
data,
|
|
50
50
|
});
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
const executionResult = result.data[operationName];
|
|
52
|
+
if (executionResult.status !== 'pending') {
|
|
53
|
+
if (executionResult.error) {
|
|
54
|
+
throw executionResult.error;
|
|
54
55
|
}
|
|
55
|
-
return
|
|
56
|
+
return executionResult;
|
|
56
57
|
}
|
|
57
58
|
} while (counter < 100);
|
|
58
59
|
throw new Error('subscription error: polling is too long');
|
|
@@ -62,13 +63,14 @@ export class DataHub extends Base {
|
|
|
62
63
|
return __awaiter(this, void 0, void 0, function* () {
|
|
63
64
|
let resultList;
|
|
64
65
|
let resultFullList = [];
|
|
66
|
+
const operationName = data.operationName;
|
|
65
67
|
do {
|
|
66
68
|
const result = yield this.makeRequest({
|
|
67
69
|
method,
|
|
68
70
|
route,
|
|
69
71
|
data,
|
|
70
72
|
});
|
|
71
|
-
resultList = result.data
|
|
73
|
+
resultList = result.data[operationName];
|
|
72
74
|
resultFullList = [...resultFullList, ...resultList.records];
|
|
73
75
|
data.variables.params = Object.assign(Object.assign({}, data.variables.params), { last: resultList.last });
|
|
74
76
|
} while (resultList.last);
|
package/dist/esm/DataHub.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataHub.js","sourceRoot":"","sources":["../../src/DataHub.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,IAAI,EAAgB,OAAO,EAAQ,QAAQ,EAAE,MAAM,cAAc,CAAC;AAO3E,OAAO,EAAE,WAAW,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"DataHub.js","sourceRoot":"","sources":["../../src/DataHub.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,IAAI,EAAgB,OAAO,EAAQ,QAAQ,EAAE,MAAM,cAAc,CAAC;AAO3E,OAAO,EAAE,WAAW,EAAE,4BAA4B,EAAE,yCAAyC,EAAE,MAAM,aAAa,CAAC;AACnH,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AASpC,MAAM,OAAO,OAAQ,SAAQ,IAAI;IAO/B,YAAY,MAAqB;QAC/B,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC;QAElD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E;oBACxC,IAAI,eAAe,CAAC,KAAK,EAAE;wBACzB,MAAM,eAAe,CAAC,KAAK,CAAC;qBAC7B;oBAED,OAAO,eAAe,CAAC;iBACxB;aAEF,QAAQ,OAAO,GAAG,GAAG,EAAE;YAExB,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;QAC7D,CAAC;KAAA;IAQY,WAAW,CAAI,MAA8B,EAAE,KAAa,EAAE,IAAwB;;YACjG,IAAI,UAAkC,CAAC;YACvC,IAAI,cAAc,GAAQ,EAAE,CAAC;YAC7B,MAAM,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC;YAEzC,GAAG;gBACD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CAAqB;oBACxD,MAAM;oBACN,KAAK;oBACL,IAAI;iBACL,CAAC,CAAC;gBAEH,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,aAAa,CAA2B,CAAC;gBAClE,cAAc,GAAG,CAAC,GAAG,cAAc,EAAE,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;gBAE5D,IAAI,CAAC,SAAS,CAAC,MAAM,mCAChB,IAAI,CAAC,SAAS,CAAC,MAAM,KACxB,IAAI,EAAE,UAAU,CAAC,IAAI,GACtB,CAAC;aAEH,QAAQ,UAAU,CAAC,IAAI,EAAE;YAE1B,OAAO,QAAQ,CAAI,cAAc,CAAC,CAAC;QACrC,CAAC;KAAA;CAEF"}
|
package/dist/esm/constants.js
CHANGED
|
@@ -2,4 +2,7 @@ export const SERVICE_KEY = 'data-hub';
|
|
|
2
2
|
export const QUERY_CHECK_EXECUTION_RESULT = `query checkExecutionResult($hash: ID!, $requestId: String!) {
|
|
3
3
|
checkExecutionResult(requestId: $requestId, hash: $hash)
|
|
4
4
|
}`;
|
|
5
|
+
export const QUERY_CHECK_EXECUTION_RESULT_CROSSACCOUNT = `query checkExecutionResultCrossAccount($hash: ID!, $requestId: String!, $accountId: String!) {
|
|
6
|
+
checkExecutionResultCrossAccount(requestId: $requestId, hash: $hash, accountId: $accountId)
|
|
7
|
+
}`;
|
|
5
8
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG,UAAU,CAAC;AAEtC,MAAM,CAAC,MAAM,4BAA4B,GAAG;;EAE1C,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG,UAAU,CAAC;AAEtC,MAAM,CAAC,MAAM,4BAA4B,GAAG;;EAE1C,CAAC;AAEH,MAAM,CAAC,MAAM,yCAAyC,GAAG;;EAEvD,CAAC"}
|
package/dist/types/DataHub.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Base, CalApiParams, List } from '@or-sdk/base';
|
|
2
|
-
import { DataHubConfig, GraphqlRequestData, GraphqlResponseCheckExecution } from './types';
|
|
2
|
+
import { DataHubConfig, GraphqlRequestData, GraphqlResponseCheckExecution, GraphqlResponseDataSimpleVariations, GraphqlResponseDataVariations } from './types';
|
|
3
3
|
export declare class DataHub extends Base {
|
|
4
4
|
constructor(params: DataHubConfig);
|
|
5
5
|
makeRequest<T>(params: CalApiParams): Promise<T>;
|
|
6
|
+
getOperationName(name: keyof GraphqlResponseDataSimpleVariations<void>): keyof GraphqlResponseDataVariations<void>;
|
|
6
7
|
subscribe(requestId: string): Promise<GraphqlResponseCheckExecution>;
|
|
7
8
|
getFullList<T>(method: CalApiParams['method'], route: string, data: GraphqlRequestData): Promise<List<T>>;
|
|
8
9
|
}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export declare const SERVICE_KEY = "data-hub";
|
|
2
2
|
export declare const QUERY_CHECK_EXECUTION_RESULT = "query checkExecutionResult($hash: ID!, $requestId: String!) {\n checkExecutionResult(requestId: $requestId, hash: $hash)\n}";
|
|
3
|
+
export declare const QUERY_CHECK_EXECUTION_RESULT_CROSSACCOUNT = "query checkExecutionResultCrossAccount($hash: ID!, $requestId: String!, $accountId: String!) {\n checkExecutionResultCrossAccount(requestId: $requestId, hash: $hash, accountId: $accountId)\n}";
|
package/dist/types/types.d.ts
CHANGED
|
@@ -2,9 +2,10 @@ import { Token } from '@or-sdk/base';
|
|
|
2
2
|
export declare type DataHubConfig = {
|
|
3
3
|
token: Token;
|
|
4
4
|
discoveryUrl: string;
|
|
5
|
+
accountId?: string;
|
|
5
6
|
};
|
|
6
7
|
export declare type GraphqlRequestData = {
|
|
7
|
-
operationName:
|
|
8
|
+
operationName: keyof GraphqlResponseDataVariations<void>;
|
|
8
9
|
query: string;
|
|
9
10
|
variables: {
|
|
10
11
|
params: {
|
|
@@ -34,27 +35,24 @@ export declare type GraphqlResponseCheckExecution = {
|
|
|
34
35
|
error?: string;
|
|
35
36
|
stack?: string;
|
|
36
37
|
};
|
|
37
|
-
|
|
38
|
-
list
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
export declare type GraphqlResponse<key extends keyof GraphqlResponseVariations<void>, T> = {
|
|
58
|
-
data: GraphqlResponseVariations<T>[key];
|
|
38
|
+
export declare type GraphqlResponseDataSimpleVariations<T> = {
|
|
39
|
+
list?: GraphqlResponseList<T>;
|
|
40
|
+
get?: T;
|
|
41
|
+
create?: T;
|
|
42
|
+
update?: T;
|
|
43
|
+
delete?: GraphqlResponseDelete;
|
|
44
|
+
deleteTemporarily?: GraphqlResponseDelete;
|
|
45
|
+
checkExecutionResult?: GraphqlResponseCheckExecution;
|
|
46
|
+
};
|
|
47
|
+
export declare type GraphqlResponseDataVariations<T> = GraphqlResponseDataSimpleVariations<T> & {
|
|
48
|
+
listCrossAccount?: GraphqlResponseList<T>;
|
|
49
|
+
getCrossAccount?: T;
|
|
50
|
+
createCrossAccount?: T;
|
|
51
|
+
updateCrossAccount?: T;
|
|
52
|
+
deleteCrossAccount?: GraphqlResponseDelete;
|
|
53
|
+
deleteTemporarilyCrossAccount?: GraphqlResponseDelete;
|
|
54
|
+
checkExecutionResultCrossAccount?: GraphqlResponseCheckExecution;
|
|
55
|
+
};
|
|
56
|
+
export declare type GraphqlResponse<T> = {
|
|
57
|
+
data: GraphqlResponseDataVariations<T>;
|
|
59
58
|
};
|
|
60
|
-
export {};
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.16.0",
|
|
3
3
|
"name": "@or-sdk/data-hub",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"access": "public"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@or-sdk/base": "^0.
|
|
27
|
+
"@or-sdk/base": "^0.16.0",
|
|
28
28
|
"uuid": "^8.3.2"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "f855bf3ee6b361c5831479cee5cde6f7702b6ced"
|
|
31
31
|
}
|
package/src/DataHub.ts
CHANGED
|
@@ -3,9 +3,9 @@ import {
|
|
|
3
3
|
DataHubConfig,
|
|
4
4
|
GraphqlRequestData,
|
|
5
5
|
GraphqlResponseList,
|
|
6
|
-
GraphqlResponse, GraphqlResponseCheckExecution,
|
|
6
|
+
GraphqlResponse, GraphqlResponseCheckExecution, GraphqlResponseDataSimpleVariations, GraphqlResponseDataVariations,
|
|
7
7
|
} from './types';
|
|
8
|
-
import { SERVICE_KEY, QUERY_CHECK_EXECUTION_RESULT } from './constants';
|
|
8
|
+
import { SERVICE_KEY, QUERY_CHECK_EXECUTION_RESULT, QUERY_CHECK_EXECUTION_RESULT_CROSSACCOUNT } from './constants';
|
|
9
9
|
import { v4 as uuidv4 } from 'uuid';
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -23,13 +23,13 @@ export class DataHub extends Base {
|
|
|
23
23
|
* ```
|
|
24
24
|
*/
|
|
25
25
|
constructor(params: DataHubConfig) {
|
|
26
|
-
const { token, discoveryUrl } = params;
|
|
26
|
+
const { token, discoveryUrl, accountId } = params;
|
|
27
27
|
|
|
28
28
|
super({
|
|
29
29
|
token,
|
|
30
30
|
discoveryUrl,
|
|
31
31
|
serviceKey: SERVICE_KEY,
|
|
32
|
-
|
|
32
|
+
accountId,
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -48,6 +48,10 @@ export class DataHub extends Base {
|
|
|
48
48
|
return await this.callApi<T>(params);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
public getOperationName(name: keyof GraphqlResponseDataSimpleVariations<void>): keyof GraphqlResponseDataVariations<void> {
|
|
52
|
+
return this.isCrossAccount ? `${name}CrossAccount` : name;
|
|
53
|
+
}
|
|
54
|
+
|
|
51
55
|
/**
|
|
52
56
|
* Subscribe for result
|
|
53
57
|
* ```typescript
|
|
@@ -60,6 +64,7 @@ export class DataHub extends Base {
|
|
|
60
64
|
}
|
|
61
65
|
|
|
62
66
|
let counter = 0;
|
|
67
|
+
const operationName = this.getOperationName('checkExecutionResult');
|
|
63
68
|
|
|
64
69
|
do {
|
|
65
70
|
counter++;
|
|
@@ -70,24 +75,28 @@ export class DataHub extends Base {
|
|
|
70
75
|
hash: uuidv4(),
|
|
71
76
|
};
|
|
72
77
|
|
|
78
|
+
|
|
73
79
|
const data = {
|
|
74
|
-
operationName
|
|
75
|
-
query: QUERY_CHECK_EXECUTION_RESULT,
|
|
80
|
+
operationName,
|
|
81
|
+
query: this.isCrossAccount ? QUERY_CHECK_EXECUTION_RESULT_CROSSACCOUNT : QUERY_CHECK_EXECUTION_RESULT,
|
|
76
82
|
variables,
|
|
83
|
+
... this.isCrossAccount ? { accountId: this.currentAccountId } : {},
|
|
77
84
|
};
|
|
78
85
|
|
|
79
|
-
const
|
|
86
|
+
const result = await this.makeRequest<GraphqlResponse<undefined>>({
|
|
80
87
|
method: 'POST',
|
|
81
88
|
route: '/graphql',
|
|
82
89
|
data,
|
|
83
90
|
});
|
|
84
91
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
92
|
+
const executionResult = result.data[operationName] as GraphqlResponseCheckExecution;
|
|
93
|
+
|
|
94
|
+
if (executionResult.status !== 'pending') {
|
|
95
|
+
if (executionResult.error) {
|
|
96
|
+
throw executionResult.error;
|
|
88
97
|
}
|
|
89
98
|
|
|
90
|
-
return
|
|
99
|
+
return executionResult;
|
|
91
100
|
}
|
|
92
101
|
|
|
93
102
|
} while (counter < 100);
|
|
@@ -104,15 +113,16 @@ export class DataHub extends Base {
|
|
|
104
113
|
public async getFullList<T>(method: CalApiParams['method'], route: string, data: GraphqlRequestData): Promise<List<T>> {
|
|
105
114
|
let resultList: GraphqlResponseList<T>;
|
|
106
115
|
let resultFullList: T[] = [];
|
|
116
|
+
const operationName = data.operationName;
|
|
107
117
|
|
|
108
118
|
do {
|
|
109
|
-
const result = await this.makeRequest<GraphqlResponse<
|
|
119
|
+
const result = await this.makeRequest<GraphqlResponse<T>>({
|
|
110
120
|
method,
|
|
111
121
|
route,
|
|
112
122
|
data,
|
|
113
123
|
});
|
|
114
124
|
|
|
115
|
-
resultList = result.data
|
|
125
|
+
resultList = result.data[operationName] as GraphqlResponseList<T>;
|
|
116
126
|
resultFullList = [...resultFullList, ...resultList.records];
|
|
117
127
|
|
|
118
128
|
data.variables.params = {
|
package/src/constants.ts
CHANGED
|
@@ -3,3 +3,7 @@ export const SERVICE_KEY = 'data-hub';
|
|
|
3
3
|
export const QUERY_CHECK_EXECUTION_RESULT = `query checkExecutionResult($hash: ID!, $requestId: String!) {
|
|
4
4
|
checkExecutionResult(requestId: $requestId, hash: $hash)
|
|
5
5
|
}`;
|
|
6
|
+
|
|
7
|
+
export const QUERY_CHECK_EXECUTION_RESULT_CROSSACCOUNT = `query checkExecutionResultCrossAccount($hash: ID!, $requestId: String!, $accountId: String!) {
|
|
8
|
+
checkExecutionResultCrossAccount(requestId: $requestId, hash: $hash, accountId: $accountId)
|
|
9
|
+
}`;
|
package/src/types.ts
CHANGED
|
@@ -10,10 +10,14 @@ export type DataHubConfig = {
|
|
|
10
10
|
* Url of OneReach service discovery api
|
|
11
11
|
*/
|
|
12
12
|
discoveryUrl: string;
|
|
13
|
+
/**
|
|
14
|
+
* Account ID for cross-account requests (super admin only)
|
|
15
|
+
*/
|
|
16
|
+
accountId?: string;
|
|
13
17
|
};
|
|
14
18
|
|
|
15
19
|
export type GraphqlRequestData = {
|
|
16
|
-
operationName:
|
|
20
|
+
operationName: keyof GraphqlResponseDataVariations<void>;
|
|
17
21
|
query: string;
|
|
18
22
|
variables: {
|
|
19
23
|
params: {
|
|
@@ -47,15 +51,26 @@ export type GraphqlResponseCheckExecution = {
|
|
|
47
51
|
stack?: string;
|
|
48
52
|
};
|
|
49
53
|
|
|
50
|
-
|
|
51
|
-
list
|
|
52
|
-
get
|
|
53
|
-
create
|
|
54
|
-
update
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
export type GraphqlResponseDataSimpleVariations<T> = {
|
|
55
|
+
list?: GraphqlResponseList<T>;
|
|
56
|
+
get?: T;
|
|
57
|
+
create?: T;
|
|
58
|
+
update?: T;
|
|
59
|
+
delete?: GraphqlResponseDelete;
|
|
60
|
+
deleteTemporarily?: GraphqlResponseDelete;
|
|
61
|
+
checkExecutionResult?: GraphqlResponseCheckExecution;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export type GraphqlResponseDataVariations<T> = GraphqlResponseDataSimpleVariations<T> & {
|
|
65
|
+
listCrossAccount?: GraphqlResponseList<T>;
|
|
66
|
+
getCrossAccount?: T;
|
|
67
|
+
createCrossAccount?: T;
|
|
68
|
+
updateCrossAccount?: T;
|
|
69
|
+
deleteCrossAccount?: GraphqlResponseDelete;
|
|
70
|
+
deleteTemporarilyCrossAccount?: GraphqlResponseDelete;
|
|
71
|
+
checkExecutionResultCrossAccount?: GraphqlResponseCheckExecution;
|
|
72
|
+
};
|
|
58
73
|
|
|
59
|
-
export type GraphqlResponse<
|
|
60
|
-
data:
|
|
74
|
+
export type GraphqlResponse<T> = {
|
|
75
|
+
data: GraphqlResponseDataVariations<T>;
|
|
61
76
|
};
|