@or-sdk/views 0.26.0-beta.647.0 → 0.26.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/CHANGELOG.md +13 -0
- package/README.md +1 -1
- package/dist/cjs/Views.js +64 -121
- package/dist/cjs/Views.js.map +1 -1
- package/dist/cjs/constants.js +3 -13
- package/dist/cjs/constants.js.map +1 -1
- package/dist/esm/Views.js +92 -146
- package/dist/esm/Views.js.map +1 -1
- package/dist/esm/constants.js +1 -331
- package/dist/esm/constants.js.map +1 -1
- package/dist/types/Views.d.ts +5 -6
- package/dist/types/Views.d.ts.map +1 -1
- package/dist/types/constants.d.ts +1 -11
- package/dist/types/constants.d.ts.map +1 -1
- package/dist/types/types.d.ts +13 -1
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +6 -5
- package/src/Views.ts +64 -131
- package/src/constants.ts +1 -341
- package/src/types.ts +16 -2
- package/tsconfig.esm.json +1 -1
- package/dist/cjs/utils/addTagsIds.js +0 -20
- package/dist/cjs/utils/addTagsIds.js.map +0 -1
- package/dist/cjs/utils/filterTagIds.js +0 -25
- package/dist/cjs/utils/filterTagIds.js.map +0 -1
- package/dist/cjs/utils/index.js +0 -13
- package/dist/cjs/utils/index.js.map +0 -1
- package/dist/cjs/utils/removeTagIds.js +0 -11
- package/dist/cjs/utils/removeTagIds.js.map +0 -1
- package/dist/esm/utils/addTagsIds.js +0 -9
- package/dist/esm/utils/addTagsIds.js.map +0 -1
- package/dist/esm/utils/filterTagIds.js +0 -23
- package/dist/esm/utils/filterTagIds.js.map +0 -1
- package/dist/esm/utils/index.js +0 -4
- package/dist/esm/utils/index.js.map +0 -1
- package/dist/esm/utils/removeTagIds.js +0 -9
- package/dist/esm/utils/removeTagIds.js.map +0 -1
- package/dist/types/utils/addTagsIds.d.ts +0 -4
- package/dist/types/utils/addTagsIds.d.ts.map +0 -1
- package/dist/types/utils/filterTagIds.d.ts +0 -7
- package/dist/types/utils/filterTagIds.d.ts.map +0 -1
- package/dist/types/utils/index.d.ts +0 -4
- package/dist/types/utils/index.d.ts.map +0 -1
- package/dist/types/utils/removeTagIds.d.ts +0 -4
- package/dist/types/utils/removeTagIds.d.ts.map +0 -1
- package/src/utils/addTagsIds.ts +0 -15
- package/src/utils/filterTagIds.ts +0 -27
- package/src/utils/index.ts +0 -6
- package/src/utils/removeTagIds.ts +0 -15
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,19 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [0.26.0](https://gitlab.com/onereach/platform/or-sdk-next/compare/@or-sdk/views@0.25.6...@or-sdk/views@0.26.0) (2022-10-21)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### ⚠ BREAKING CHANGES
|
|
10
|
+
|
|
11
|
+
* **data-hub-svc:** DataHub changed to DataHubSvc, now constructor needs `dataHubSvcUrl` instead of `dataHubUrl`
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* **data-hub-svc:** DataHub changed to DataHubSvc, now constructor needs `dataHubSvcUrl` instead of `dataHubUrl` ([bf9c8ff](https://gitlab.com/onereach/platform/or-sdk-next/commit/bf9c8ff0c660e19f174ad04a135320c98152c4e7))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
6
19
|
### [0.25.6](https://gitlab.com/onereach/platform/or-sdk-next/compare/@or-sdk/views@0.25.5...@or-sdk/views@0.25.6) (2022-09-09)
|
|
7
20
|
|
|
8
21
|
**Note:** Version bump only for package @or-sdk/views
|
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ import { Views } from '@or-sdk/views'
|
|
|
10
10
|
// with direct api url
|
|
11
11
|
const views = new Views({
|
|
12
12
|
token: 'my-account-token-string',
|
|
13
|
-
|
|
13
|
+
dataHubSvcUrl: 'http://example.data-hub-svc/endpoint'
|
|
14
14
|
});
|
|
15
15
|
|
|
16
16
|
// with service discovery(slower)
|
package/dist/cjs/Views.js
CHANGED
|
@@ -48,182 +48,125 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
48
48
|
};
|
|
49
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
50
|
exports.Views = void 0;
|
|
51
|
-
var
|
|
52
|
-
var
|
|
51
|
+
var base_1 = require("@or-sdk/base");
|
|
52
|
+
var data_hub_svc_1 = require("@or-sdk/data-hub-svc");
|
|
53
53
|
var tags_1 = require("@or-sdk/tags");
|
|
54
54
|
var Views = (function () {
|
|
55
55
|
function Views(params) {
|
|
56
|
-
var token = params.token, discoveryUrl = params.discoveryUrl, accountId = params.accountId,
|
|
57
|
-
this.
|
|
56
|
+
var token = params.token, discoveryUrl = params.discoveryUrl, accountId = params.accountId, dataHubSvcUrl = params.dataHubSvcUrl;
|
|
57
|
+
this.dataHubSvc = new data_hub_svc_1.DataHubSvc({
|
|
58
58
|
token: token,
|
|
59
59
|
discoveryUrl: discoveryUrl,
|
|
60
60
|
accountId: accountId,
|
|
61
|
-
|
|
61
|
+
dataHubSvcUrl: dataHubSvcUrl,
|
|
62
62
|
});
|
|
63
63
|
this.tags = new tags_1.Tags({
|
|
64
64
|
token: token,
|
|
65
65
|
discoveryUrl: discoveryUrl,
|
|
66
66
|
accountId: accountId,
|
|
67
|
-
|
|
67
|
+
dataHubSvcUrl: dataHubSvcUrl,
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
|
-
Views.prototype.
|
|
70
|
+
Views.prototype.listViews = function (params, paginationOptions) {
|
|
71
|
+
if (params === void 0) { params = {}; }
|
|
72
|
+
if (paginationOptions === void 0) { paginationOptions = {}; }
|
|
71
73
|
return __awaiter(this, void 0, void 0, function () {
|
|
74
|
+
var result;
|
|
72
75
|
return __generator(this, function (_a) {
|
|
73
76
|
switch (_a.label) {
|
|
74
|
-
case 0: return [4,
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
77
|
+
case 0: return [4, this.dataHubSvc.makeRequest({
|
|
78
|
+
method: 'GET',
|
|
79
|
+
route: 'views',
|
|
80
|
+
params: __assign(__assign(__assign({}, params), paginationOptions), this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {}),
|
|
81
|
+
})];
|
|
78
82
|
case 1:
|
|
79
|
-
_a.sent();
|
|
80
|
-
return [2];
|
|
83
|
+
result = _a.sent();
|
|
84
|
+
return [2, (0, base_1.makeList)(result)];
|
|
81
85
|
}
|
|
82
86
|
});
|
|
83
87
|
});
|
|
84
88
|
};
|
|
85
|
-
Views.prototype.listViews = function () {
|
|
86
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
87
|
-
var variables, operationName, data;
|
|
88
|
-
return __generator(this, function (_a) {
|
|
89
|
-
variables = __assign({ entity: constants_1.ENTITY_NAME, params: {
|
|
90
|
-
queryParams: {},
|
|
91
|
-
includeDeleted: false,
|
|
92
|
-
includeExisting: true,
|
|
93
|
-
limit: 30,
|
|
94
|
-
} }, this.dataHub.isCrossAccount ? { accountId: this.dataHub.currentAccountId } : { sandbox: false });
|
|
95
|
-
operationName = this.dataHub.getOperationName(data_hub_1.OperationNames.LIST);
|
|
96
|
-
data = {
|
|
97
|
-
operationName: operationName,
|
|
98
|
-
query: this.dataHub.isCrossAccount ? constants_1.QUERY_LIST_CROSSACCOUNT : constants_1.QUERY_LIST,
|
|
99
|
-
variables: variables,
|
|
100
|
-
};
|
|
101
|
-
return [2, this.dataHub.getFullList('POST', '/graphql', data)];
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
};
|
|
105
89
|
Views.prototype.getView = function (id) {
|
|
106
90
|
return __awaiter(this, void 0, void 0, function () {
|
|
107
|
-
var variables, operationName, data, result;
|
|
108
91
|
return __generator(this, function (_a) {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
includeExisting: true,
|
|
115
|
-
} }, this.dataHub.isCrossAccount ? { accountId: this.dataHub.currentAccountId } : {});
|
|
116
|
-
operationName = this.dataHub.getOperationName(data_hub_1.OperationNames.GET);
|
|
117
|
-
data = {
|
|
118
|
-
operationName: operationName,
|
|
119
|
-
query: this.dataHub.isCrossAccount ? constants_1.QUERY_GET_CROSSACCOUNT : constants_1.QUERY_GET,
|
|
120
|
-
variables: variables,
|
|
121
|
-
};
|
|
122
|
-
return [4, this.dataHub.makeRequest({
|
|
123
|
-
method: 'POST',
|
|
124
|
-
route: '/graphql',
|
|
125
|
-
data: data,
|
|
126
|
-
})];
|
|
127
|
-
case 1:
|
|
128
|
-
result = _a.sent();
|
|
129
|
-
return [2, result.data[operationName]];
|
|
130
|
-
}
|
|
92
|
+
return [2, this.dataHubSvc.makeRequest({
|
|
93
|
+
method: 'GET',
|
|
94
|
+
route: "views/".concat(id),
|
|
95
|
+
params: __assign({}, this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {}),
|
|
96
|
+
})];
|
|
131
97
|
});
|
|
132
98
|
});
|
|
133
99
|
};
|
|
134
100
|
Views.prototype.saveView = function (source) {
|
|
135
101
|
return __awaiter(this, void 0, void 0, function () {
|
|
136
102
|
return __generator(this, function (_a) {
|
|
137
|
-
return [2, source.id ? this.updateView(source) : this.createView(source)];
|
|
103
|
+
return [2, (source.id && source.id !== 'new') ? this.updateView(source) : this.createView(source)];
|
|
138
104
|
});
|
|
139
105
|
});
|
|
140
106
|
};
|
|
141
107
|
Views.prototype.createView = function (source) {
|
|
142
108
|
return __awaiter(this, void 0, void 0, function () {
|
|
143
|
-
var
|
|
109
|
+
var result;
|
|
144
110
|
return __generator(this, function (_a) {
|
|
145
111
|
switch (_a.label) {
|
|
146
|
-
case 0:
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
variables: variables,
|
|
155
|
-
};
|
|
156
|
-
return [4, this.dataHub.makeRequest({
|
|
157
|
-
method: 'POST',
|
|
158
|
-
route: '/graphql',
|
|
159
|
-
data: data,
|
|
160
|
-
})];
|
|
112
|
+
case 0: return [4, this.dataHubSvc.makeRequest({
|
|
113
|
+
method: 'POST',
|
|
114
|
+
route: 'views/new',
|
|
115
|
+
data: {
|
|
116
|
+
view: __assign(__assign({}, source), { id: 'new' }),
|
|
117
|
+
},
|
|
118
|
+
params: __assign({}, this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {}),
|
|
119
|
+
})];
|
|
161
120
|
case 1:
|
|
162
121
|
result = _a.sent();
|
|
163
|
-
return [2, result
|
|
122
|
+
return [2, (0, data_hub_svc_1.setDiff)(source, result)];
|
|
164
123
|
}
|
|
165
124
|
});
|
|
166
125
|
});
|
|
167
126
|
};
|
|
168
127
|
Views.prototype.updateView = function (source) {
|
|
169
128
|
return __awaiter(this, void 0, void 0, function () {
|
|
170
|
-
var
|
|
129
|
+
var result;
|
|
171
130
|
return __generator(this, function (_a) {
|
|
172
131
|
switch (_a.label) {
|
|
173
|
-
case 0:
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
query: this.dataHub.isCrossAccount ? constants_1.QUERY_UPDATE_CROSSACCOUNT : constants_1.QUERY_UPDATE,
|
|
182
|
-
variables: variables,
|
|
183
|
-
};
|
|
184
|
-
return [4, this.dataHub.makeRequest({
|
|
185
|
-
method: 'POST',
|
|
186
|
-
route: '/graphql',
|
|
187
|
-
data: data,
|
|
188
|
-
})];
|
|
132
|
+
case 0: return [4, this.dataHubSvc.makeRequest({
|
|
133
|
+
method: 'POST',
|
|
134
|
+
route: "views/".concat(source.id),
|
|
135
|
+
data: {
|
|
136
|
+
view: source,
|
|
137
|
+
},
|
|
138
|
+
params: __assign({}, this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {}),
|
|
139
|
+
})];
|
|
189
140
|
case 1:
|
|
190
141
|
result = _a.sent();
|
|
191
|
-
return [2, result
|
|
142
|
+
return [2, (0, data_hub_svc_1.setDiff)(source, result)];
|
|
192
143
|
}
|
|
193
144
|
});
|
|
194
145
|
});
|
|
195
146
|
};
|
|
196
|
-
Views.prototype.deleteView = function (viewId) {
|
|
147
|
+
Views.prototype.deleteView = function (viewId, temporarily) {
|
|
148
|
+
if (temporarily === void 0) { temporarily = true; }
|
|
197
149
|
return __awaiter(this, void 0, void 0, function () {
|
|
198
|
-
var variables, operationName, data, result;
|
|
199
150
|
return __generator(this, function (_a) {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
method: 'POST',
|
|
220
|
-
route: '/graphql',
|
|
221
|
-
data: data,
|
|
222
|
-
})];
|
|
223
|
-
case 1:
|
|
224
|
-
result = _a.sent();
|
|
225
|
-
return [2, this.dataHub.subscribe(result.data[operationName].requestId)];
|
|
226
|
-
}
|
|
151
|
+
return [2, this.dataHubSvc.makeRequest({
|
|
152
|
+
method: 'DELETE',
|
|
153
|
+
route: "views/".concat(viewId),
|
|
154
|
+
data: {
|
|
155
|
+
temporarily: temporarily,
|
|
156
|
+
},
|
|
157
|
+
params: __assign({}, this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {}),
|
|
158
|
+
})];
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
};
|
|
162
|
+
Views.prototype.recoverView = function (viewId) {
|
|
163
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
164
|
+
return __generator(this, function (_a) {
|
|
165
|
+
return [2, this.dataHubSvc.makeRequest({
|
|
166
|
+
method: 'PATCH',
|
|
167
|
+
route: "views/".concat(viewId),
|
|
168
|
+
params: __assign({}, this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {}),
|
|
169
|
+
})];
|
|
227
170
|
});
|
|
228
171
|
});
|
|
229
172
|
};
|
package/dist/cjs/Views.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Views.js","sourceRoot":"","sources":["../../src/Views.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"Views.js","sourceRoot":"","sources":["../../src/Views.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAA8C;AAC9C,qDAA2D;AAE3D,qCAAsF;AAEtF;IAIE,eAAY,MAAmB;QACrB,IAAA,KAAK,GAA6C,MAAM,MAAnD,EAAE,YAAY,GAA+B,MAAM,aAArC,EAAE,SAAS,GAAoB,MAAM,UAA1B,EAAE,aAAa,GAAK,MAAM,cAAX,CAAY;QAEjE,IAAI,CAAC,UAAU,GAAG,IAAI,yBAAU,CAAC;YAC/B,KAAK,OAAA;YACL,YAAY,cAAA;YACZ,SAAS,WAAA;YACT,aAAa,eAAA;SACd,CAAC,CAAC;QACH,IAAI,CAAC,IAAI,GAAG,IAAI,WAAI,CAAC;YACnB,KAAK,OAAA;YACL,YAAY,cAAA;YACZ,SAAS,WAAA;YACT,aAAa,eAAA;SACd,CAAC,CAAC;IACL,CAAC;IAQY,yBAAS,GAAtB,UAAuB,MAA2B,EAAE,iBAAyC;QAAtE,uBAAA,EAAA,WAA2B;QAAE,kCAAA,EAAA,sBAAyC;;;;;4BAC5E,WAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAAS;4BACvD,MAAM,EAAE,KAAK;4BACb,KAAK,EAAE,OAAO;4BACd,MAAM,iCACD,MAAM,GACN,iBAAiB,GAChB,IAAI,CAAC,UAAU,CAAC,cAAc,CAA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ED,WAAO,IAAI,CAAC,QAAQ,uBACf,MAAM,KACT,IAAI,wBACC,MAAM,CAAC,IAAI,KACd,IAAI,wBACC,MAAM,CAAC,IAAI,CAAC,IAAI,KACnB,cAAc,EAAE,IAAA,mBAAY,EAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,WAAW,CAAC,UAG9E,EAAC;;;;KACJ;IACH,YAAC;AAAD,CAAC,AA5MD,IA4MC;AA5MY,sBAAK"}
|
package/dist/cjs/constants.js
CHANGED
|
@@ -1,16 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
var
|
|
5
|
-
Object.defineProperty(exports, "
|
|
6
|
-
exports.QUERY_LIST = "query list($entity: EntityType!, $params: ListInput!, $sandbox: Boolean) {\n list(entity: $entity, params: $params, sandbox: $sandbox) {\n records {\n ... on View {\n id\n data {\n data\n }\n cardIds\n mirrorCardIds\n linkId\n linkType\n template {\n category\n description\n help\n icon\n iconUrl\n implicitly\n label\n publishedBy\n tags\n type\n version\n }\n reference\n }\n }\n last\n }\n}\n";
|
|
7
|
-
exports.QUERY_LIST_CROSSACCOUNT = "query listCrossAccount($entity: EntityType!, $params: ListInput!, $accountId: String!) {\n listCrossAccount(entity: $entity, params: $params, accountId: $accountId) {\n records {\n ... on View {\n id\n data {\n data\n }\n cardIds\n mirrorCardIds\n linkId\n linkType\n template {\n category\n description\n help\n icon\n iconUrl\n implicitly\n label\n publishedBy\n tags\n type\n version\n }\n reference\n }\n }\n last\n }\n}\n";
|
|
8
|
-
exports.QUERY_GET = "query get($entity: EntityType!, $params: GetInput!) {\n get(entity: $entity, params: $params) {\n ... on View {\n id\n cardIds\n linkId\n mirrorCardIds\n schemaVersion\n dateCreated\n dateModified\n data {\n data\n form {\n code\n data\n style\n template\n }\n presentation {\n code\n data\n style\n template\n }\n }\n linkType\n reference\n template {\n category\n description\n help\n icon\n iconUrl\n implicitly\n label\n publishedBy\n tags\n type\n version\n }\n }\n }\n}";
|
|
9
|
-
exports.QUERY_GET_CROSSACCOUNT = "query getCrossAccount($entity: EntityType!, $params: GetInput!, $accountId: String!) {\n getCrossAccount(entity: $entity, params: $params, accountId: $accountId) {\n ... on View {\n id\n cardIds\n linkId\n mirrorCardIds\n schemaVersion\n dateCreated\n dateModified\n data {\n data\n form {\n code\n data\n style\n template\n }\n presentation {\n code\n data\n style\n template\n }\n }\n linkType\n reference\n template {\n category\n description\n help\n icon\n iconUrl\n implicitly\n label\n publishedBy\n tags\n type\n version\n }\n }\n }\n}";
|
|
10
|
-
exports.QUERY_CREATE = "mutation create($entity: EntityType!, $data: CreateInput!) {\n create(entity: $entity, data: $data) {\n ... on View {\n id\n cardIds\n linkId\n mirrorCardIds\n schemaVersion\n dateCreated\n dateModified\n data {\n data\n form {\n code\n data\n style\n template\n }\n presentation {\n code\n data\n style\n template\n }\n }\n linkType\n reference\n template {\n category\n description\n help\n icon\n iconUrl\n implicitly\n label\n publishedBy\n tags\n type\n version\n }\n }\n }\n}";
|
|
11
|
-
exports.QUERY_CREATE_CROSSACCOUNT = "mutation createCrossAccount($entity: EntityType!, $data: CreateInput!, $accountId: String!) {\n createCrossAccount(entity: $entity, data: $data, accountId: $accountId) {\n ... on View {\n id\n cardIds\n linkId\n mirrorCardIds\n schemaVersion\n dateCreated\n dateModified\n data {\n data\n form {\n code\n data\n style\n template\n }\n presentation {\n code\n data\n style\n template\n }\n }\n linkType\n reference\n template {\n category\n description\n help\n icon\n iconUrl\n implicitly\n label\n publishedBy\n tags\n type\n version\n }\n }\n }\n}";
|
|
12
|
-
exports.QUERY_UPDATE = "mutation update($entity: EntityType!, $data: UpdateInput!) {\n update(entity: $entity, data: $data) {\n ... on View {\n id\n cardIds\n linkId\n mirrorCardIds\n schemaVersion\n dateCreated\n dateModified\n data {\n data\n form {\n code\n data\n style\n template\n }\n presentation {\n code\n data\n style\n template\n }\n }\n linkType\n reference\n template {\n category\n description\n help\n icon\n iconUrl\n implicitly\n label\n publishedBy\n tags\n type\n version\n }\n }\n }\n}";
|
|
13
|
-
exports.QUERY_UPDATE_CROSSACCOUNT = "mutation updateCrossAccount($entity: EntityType!, $data: UpdateInput!, $accountId: String!) {\n updateCrossAccount(entity: $entity, data: $data, accountId: $accountId) {\n ... on View {\n id\n cardIds\n linkId\n mirrorCardIds\n schemaVersion\n dateCreated\n dateModified\n data {\n data\n form {\n code\n data\n style\n template\n }\n presentation {\n code\n data\n style\n template\n }\n }\n linkType\n reference\n template {\n category\n description\n help\n icon\n iconUrl\n implicitly\n label\n publishedBy\n tags\n type\n version\n }\n }\n }\n}";
|
|
14
|
-
exports.QUERY_DELETE = "mutation deleteTemporarily($entity: EntityType!, $data: DeleteInput!) {\n deleteTemporarily(entity: $entity, data: $data) {\n ... on AsyncRequest {\n requestId\n }\n }\n}";
|
|
15
|
-
exports.ENTITY_NAME = 'VIEW';
|
|
3
|
+
exports.DATA_HUB_SVC_SERVICE_KEY = void 0;
|
|
4
|
+
var data_hub_svc_1 = require("@or-sdk/data-hub-svc");
|
|
5
|
+
Object.defineProperty(exports, "DATA_HUB_SVC_SERVICE_KEY", { enumerable: true, get: function () { return data_hub_svc_1.DATA_HUB_SVC_SERVICE_KEY; } });
|
|
16
6
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAA,qDAAgE;AAAvD,wHAAA,wBAAwB,OAAA"}
|
package/dist/esm/Views.js
CHANGED
|
@@ -1,176 +1,122 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { makeList } from '@or-sdk/base';
|
|
11
|
+
import { DataHubSvc, setDiff } from '@or-sdk/data-hub-svc';
|
|
3
12
|
import { Tags, filterTagIds, addTagsIds, removeTagIds } from '@or-sdk/tags';
|
|
4
13
|
export class Views {
|
|
5
|
-
dataHub;
|
|
6
|
-
tags;
|
|
7
14
|
constructor(params) {
|
|
8
|
-
const { token, discoveryUrl, accountId,
|
|
9
|
-
this.
|
|
15
|
+
const { token, discoveryUrl, accountId, dataHubSvcUrl } = params;
|
|
16
|
+
this.dataHubSvc = new DataHubSvc({
|
|
10
17
|
token,
|
|
11
18
|
discoveryUrl,
|
|
12
19
|
accountId,
|
|
13
|
-
|
|
20
|
+
dataHubSvcUrl,
|
|
14
21
|
});
|
|
15
22
|
this.tags = new Tags({
|
|
16
23
|
token,
|
|
17
24
|
discoveryUrl,
|
|
18
25
|
accountId,
|
|
19
|
-
|
|
26
|
+
dataHubSvcUrl,
|
|
20
27
|
});
|
|
21
28
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
this.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
entity: ENTITY_NAME,
|
|
31
|
-
params: {
|
|
32
|
-
queryParams: {},
|
|
33
|
-
includeDeleted: false,
|
|
34
|
-
includeExisting: true,
|
|
35
|
-
limit: 30,
|
|
36
|
-
},
|
|
37
|
-
...this.dataHub.isCrossAccount ? { accountId: this.dataHub.currentAccountId } : { sandbox: false },
|
|
38
|
-
};
|
|
39
|
-
const operationName = this.dataHub.getOperationName(OperationNames.LIST);
|
|
40
|
-
const data = {
|
|
41
|
-
operationName,
|
|
42
|
-
query: this.dataHub.isCrossAccount ? QUERY_LIST_CROSSACCOUNT : QUERY_LIST,
|
|
43
|
-
variables,
|
|
44
|
-
};
|
|
45
|
-
return this.dataHub.getFullList('POST', '/graphql', data);
|
|
46
|
-
}
|
|
47
|
-
async getView(id) {
|
|
48
|
-
const variables = {
|
|
49
|
-
entity: ENTITY_NAME,
|
|
50
|
-
params: {
|
|
51
|
-
id,
|
|
52
|
-
includeDeleted: false,
|
|
53
|
-
includeExisting: true,
|
|
54
|
-
},
|
|
55
|
-
...this.dataHub.isCrossAccount ? { accountId: this.dataHub.currentAccountId } : {},
|
|
56
|
-
};
|
|
57
|
-
const operationName = this.dataHub.getOperationName(OperationNames.GET);
|
|
58
|
-
const data = {
|
|
59
|
-
operationName,
|
|
60
|
-
query: this.dataHub.isCrossAccount ? QUERY_GET_CROSSACCOUNT : QUERY_GET,
|
|
61
|
-
variables,
|
|
62
|
-
};
|
|
63
|
-
const result = await this.dataHub.makeRequest({
|
|
64
|
-
method: 'POST',
|
|
65
|
-
route: '/graphql',
|
|
66
|
-
data,
|
|
29
|
+
listViews(params = {}, paginationOptions = {}) {
|
|
30
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
const result = yield this.dataHubSvc.makeRequest({
|
|
32
|
+
method: 'GET',
|
|
33
|
+
route: 'views',
|
|
34
|
+
params: Object.assign(Object.assign(Object.assign({}, params), paginationOptions), this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {}),
|
|
35
|
+
});
|
|
36
|
+
return makeList(result);
|
|
67
37
|
});
|
|
68
|
-
return result.data[operationName];
|
|
69
|
-
}
|
|
70
|
-
async saveView(source) {
|
|
71
|
-
return source.id ? this.updateView(source) : this.createView(source);
|
|
72
38
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
};
|
|
81
|
-
const operationName = this.dataHub.getOperationName(OperationNames.CREATE);
|
|
82
|
-
const data = {
|
|
83
|
-
operationName,
|
|
84
|
-
query: this.dataHub.isCrossAccount ? QUERY_CREATE_CROSSACCOUNT : QUERY_CREATE,
|
|
85
|
-
variables,
|
|
86
|
-
};
|
|
87
|
-
const result = await this.dataHub.makeRequest({
|
|
88
|
-
method: 'POST',
|
|
89
|
-
route: '/graphql',
|
|
90
|
-
data,
|
|
39
|
+
getView(id) {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
return this.dataHubSvc.makeRequest({
|
|
42
|
+
method: 'GET',
|
|
43
|
+
route: `views/${id}`,
|
|
44
|
+
params: Object.assign({}, this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {}),
|
|
45
|
+
});
|
|
91
46
|
});
|
|
92
|
-
return result.data[operationName];
|
|
93
47
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
data: {
|
|
98
|
-
id: source.id,
|
|
99
|
-
body: source,
|
|
100
|
-
},
|
|
101
|
-
...this.dataHub.isCrossAccount ? { accountId: this.dataHub.currentAccountId } : {},
|
|
102
|
-
};
|
|
103
|
-
const operationName = this.dataHub.getOperationName(OperationNames.UPDATE);
|
|
104
|
-
const data = {
|
|
105
|
-
operationName,
|
|
106
|
-
query: this.dataHub.isCrossAccount ? QUERY_UPDATE_CROSSACCOUNT : QUERY_UPDATE,
|
|
107
|
-
variables,
|
|
108
|
-
};
|
|
109
|
-
const result = await this.dataHub.makeRequest({
|
|
110
|
-
method: 'POST',
|
|
111
|
-
route: '/graphql',
|
|
112
|
-
data,
|
|
48
|
+
saveView(source) {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
return (source.id && source.id !== 'new') ? this.updateView(source) : this.createView(source);
|
|
113
51
|
});
|
|
114
|
-
return result.data[operationName];
|
|
115
52
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
const operationName = this.dataHub.getOperationName(OperationNames.DELETE_TEMPORARILY);
|
|
128
|
-
const data = {
|
|
129
|
-
operationName,
|
|
130
|
-
query: QUERY_DELETE,
|
|
131
|
-
variables,
|
|
132
|
-
};
|
|
133
|
-
const result = await this.dataHub.makeRequest({
|
|
134
|
-
method: 'POST',
|
|
135
|
-
route: '/graphql',
|
|
136
|
-
data,
|
|
53
|
+
createView(source) {
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
const result = yield this.dataHubSvc.makeRequest({
|
|
56
|
+
method: 'POST',
|
|
57
|
+
route: 'views/new',
|
|
58
|
+
data: {
|
|
59
|
+
view: Object.assign(Object.assign({}, source), { id: 'new' }),
|
|
60
|
+
},
|
|
61
|
+
params: Object.assign({}, this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {}),
|
|
62
|
+
});
|
|
63
|
+
return setDiff(source, result);
|
|
137
64
|
});
|
|
138
|
-
return this.dataHub.subscribe(result.data[operationName].requestId);
|
|
139
65
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
throw Error('No tag IDs to add.');
|
|
146
|
-
}
|
|
147
|
-
return this.saveView({
|
|
148
|
-
...source,
|
|
149
|
-
data: {
|
|
150
|
-
...source.data,
|
|
66
|
+
updateView(source) {
|
|
67
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
const result = yield this.dataHubSvc.makeRequest({
|
|
69
|
+
method: 'POST',
|
|
70
|
+
route: `views/${source.id}`,
|
|
151
71
|
data: {
|
|
152
|
-
|
|
153
|
-
filterByTagIds: addTagsIds(source.data.data.filterByTagIds, newIds),
|
|
72
|
+
view: source,
|
|
154
73
|
},
|
|
155
|
-
|
|
74
|
+
params: Object.assign({}, this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {}),
|
|
75
|
+
});
|
|
76
|
+
return setDiff(source, result);
|
|
156
77
|
});
|
|
157
78
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
throw Error('No tag IDs to remove.');
|
|
164
|
-
}
|
|
165
|
-
return this.saveView({
|
|
166
|
-
...source,
|
|
167
|
-
data: {
|
|
168
|
-
...source.data,
|
|
79
|
+
deleteView(viewId, temporarily = true) {
|
|
80
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
81
|
+
return this.dataHubSvc.makeRequest({
|
|
82
|
+
method: 'DELETE',
|
|
83
|
+
route: `views/${viewId}`,
|
|
169
84
|
data: {
|
|
170
|
-
|
|
171
|
-
filterByTagIds: removeTagIds(source.data.data.filterByTagIds, existingIds),
|
|
85
|
+
temporarily,
|
|
172
86
|
},
|
|
173
|
-
|
|
87
|
+
params: Object.assign({}, this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {}),
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
recoverView(viewId) {
|
|
92
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
+
return this.dataHubSvc.makeRequest({
|
|
94
|
+
method: 'PATCH',
|
|
95
|
+
route: `views/${viewId}`,
|
|
96
|
+
params: Object.assign({}, this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {}),
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
addTags(source, tagNames) {
|
|
101
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
102
|
+
const tags = yield this.tags.getMultipleTagsByName(tagNames, true);
|
|
103
|
+
const tagIds = tags.map(tag => tag.id);
|
|
104
|
+
const { newIds } = filterTagIds(source.data.data.filterByTagIds, tagIds);
|
|
105
|
+
if (!newIds.length) {
|
|
106
|
+
throw Error('No tag IDs to add.');
|
|
107
|
+
}
|
|
108
|
+
return this.saveView(Object.assign(Object.assign({}, source), { data: Object.assign(Object.assign({}, source.data), { data: Object.assign(Object.assign({}, source.data.data), { filterByTagIds: addTagsIds(source.data.data.filterByTagIds, newIds) }) }) }));
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
removeTags(source, tagNames) {
|
|
112
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
+
const tags = yield this.tags.getMultipleTagsByName(tagNames);
|
|
114
|
+
const tagIds = tags.map(tag => tag.id);
|
|
115
|
+
const { existingIds } = filterTagIds(source.data.data.filterByTagIds, tagIds);
|
|
116
|
+
if (!existingIds.length) {
|
|
117
|
+
throw Error('No tag IDs to remove.');
|
|
118
|
+
}
|
|
119
|
+
return this.saveView(Object.assign(Object.assign({}, source), { data: Object.assign(Object.assign({}, source.data), { data: Object.assign(Object.assign({}, source.data.data), { filterByTagIds: removeTagIds(source.data.data.filterByTagIds, existingIds) }) }) }));
|
|
174
120
|
});
|
|
175
121
|
}
|
|
176
122
|
}
|