@or-sdk/cards 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/Cards.js +97 -45
- package/dist/cjs/Cards.js.map +1 -1
- package/dist/cjs/constants.js +5 -1
- package/dist/cjs/constants.js.map +1 -1
- package/dist/esm/Cards.js +68 -41
- package/dist/esm/Cards.js.map +1 -1
- package/dist/esm/constants.js +179 -0
- package/dist/esm/constants.js.map +1 -1
- package/dist/types/Cards.d.ts +5 -1
- package/dist/types/constants.d.ts +4 -0
- package/dist/types/types.d.ts +1 -0
- package/package.json +5 -4
- package/src/Cards.ts +113 -24
- package/src/constants.ts +182 -0
- package/src/types.ts +4 -0
package/dist/cjs/Cards.js
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
14
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
15
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -39,19 +50,29 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
50
|
exports.Cards = void 0;
|
|
40
51
|
var data_hub_1 = require("@or-sdk/data-hub");
|
|
41
52
|
var constants_1 = require("./constants");
|
|
53
|
+
var tags_1 = require("@or-sdk/tags");
|
|
42
54
|
var Cards = (function () {
|
|
43
55
|
function Cards(params) {
|
|
44
|
-
var token = params.token, discoveryUrl = params.discoveryUrl;
|
|
56
|
+
var token = params.token, discoveryUrl = params.discoveryUrl, accountId = params.accountId;
|
|
45
57
|
this.dataHub = new data_hub_1.DataHub({
|
|
46
58
|
token: token,
|
|
47
59
|
discoveryUrl: discoveryUrl,
|
|
60
|
+
accountId: accountId,
|
|
61
|
+
});
|
|
62
|
+
this.tags = new tags_1.Tags({
|
|
63
|
+
token: token,
|
|
64
|
+
discoveryUrl: discoveryUrl,
|
|
65
|
+
accountId: accountId,
|
|
48
66
|
});
|
|
49
67
|
}
|
|
50
68
|
Cards.prototype.init = function () {
|
|
51
69
|
return __awaiter(this, void 0, void 0, function () {
|
|
52
70
|
return __generator(this, function (_a) {
|
|
53
71
|
switch (_a.label) {
|
|
54
|
-
case 0: return [4,
|
|
72
|
+
case 0: return [4, Promise.all([
|
|
73
|
+
this.dataHub.init(),
|
|
74
|
+
this.tags.init(),
|
|
75
|
+
])];
|
|
55
76
|
case 1:
|
|
56
77
|
_a.sent();
|
|
57
78
|
return [2];
|
|
@@ -61,21 +82,18 @@ var Cards = (function () {
|
|
|
61
82
|
};
|
|
62
83
|
Cards.prototype.listCards = function () {
|
|
63
84
|
return __awaiter(this, void 0, void 0, function () {
|
|
64
|
-
var variables, data;
|
|
85
|
+
var variables, operationName, data;
|
|
65
86
|
return __generator(this, function (_a) {
|
|
66
|
-
variables = {
|
|
67
|
-
entity: constants_1.ENTITY_NAME,
|
|
68
|
-
params: {
|
|
87
|
+
variables = __assign({ entity: constants_1.ENTITY_NAME, params: {
|
|
69
88
|
queryParams: {},
|
|
70
89
|
includeDeleted: false,
|
|
71
90
|
includeExisting: true,
|
|
72
91
|
limit: 30,
|
|
73
|
-
},
|
|
74
|
-
|
|
75
|
-
};
|
|
92
|
+
} }, this.dataHub.isCrossAccount ? { accountId: this.dataHub.currentAccountId } : { sandbox: false });
|
|
93
|
+
operationName = this.dataHub.getOperationName('list');
|
|
76
94
|
data = {
|
|
77
|
-
operationName:
|
|
78
|
-
query: constants_1.QUERY_LIST,
|
|
95
|
+
operationName: operationName,
|
|
96
|
+
query: this.dataHub.isCrossAccount ? constants_1.QUERY_LIST_CROSSACCOUNT : constants_1.QUERY_LIST,
|
|
79
97
|
variables: variables,
|
|
80
98
|
};
|
|
81
99
|
return [2, this.dataHub.getFullList('POST', '/graphql', data)];
|
|
@@ -84,21 +102,19 @@ var Cards = (function () {
|
|
|
84
102
|
};
|
|
85
103
|
Cards.prototype.getCard = function (id) {
|
|
86
104
|
return __awaiter(this, void 0, void 0, function () {
|
|
87
|
-
var variables, data,
|
|
105
|
+
var variables, operationName, data, result;
|
|
88
106
|
return __generator(this, function (_a) {
|
|
89
107
|
switch (_a.label) {
|
|
90
108
|
case 0:
|
|
91
|
-
variables = {
|
|
92
|
-
entity: constants_1.ENTITY_NAME,
|
|
93
|
-
params: {
|
|
109
|
+
variables = __assign({ entity: constants_1.ENTITY_NAME, params: {
|
|
94
110
|
id: id,
|
|
95
111
|
includeDeleted: false,
|
|
96
112
|
includeExisting: true,
|
|
97
|
-
},
|
|
98
|
-
|
|
113
|
+
} }, this.dataHub.isCrossAccount ? { accountId: this.dataHub.currentAccountId } : {});
|
|
114
|
+
operationName = this.dataHub.getOperationName('get');
|
|
99
115
|
data = {
|
|
100
|
-
operationName:
|
|
101
|
-
query: constants_1.QUERY_GET,
|
|
116
|
+
operationName: operationName,
|
|
117
|
+
query: this.dataHub.isCrossAccount ? constants_1.QUERY_GET_CROSSACCOUNT : constants_1.QUERY_GET,
|
|
102
118
|
variables: variables,
|
|
103
119
|
};
|
|
104
120
|
return [4, this.dataHub.makeRequest({
|
|
@@ -107,8 +123,8 @@ var Cards = (function () {
|
|
|
107
123
|
data: data,
|
|
108
124
|
})];
|
|
109
125
|
case 1:
|
|
110
|
-
|
|
111
|
-
return [2,
|
|
126
|
+
result = _a.sent();
|
|
127
|
+
return [2, result.data[operationName]];
|
|
112
128
|
}
|
|
113
129
|
});
|
|
114
130
|
});
|
|
@@ -122,19 +138,17 @@ var Cards = (function () {
|
|
|
122
138
|
};
|
|
123
139
|
Cards.prototype.createCard = function (source) {
|
|
124
140
|
return __awaiter(this, void 0, void 0, function () {
|
|
125
|
-
var variables, data,
|
|
141
|
+
var variables, operationName, data, result;
|
|
126
142
|
return __generator(this, function (_a) {
|
|
127
143
|
switch (_a.label) {
|
|
128
144
|
case 0:
|
|
129
|
-
variables = {
|
|
130
|
-
entity: constants_1.ENTITY_NAME,
|
|
131
|
-
data: {
|
|
145
|
+
variables = __assign({ entity: constants_1.ENTITY_NAME, data: {
|
|
132
146
|
body: source,
|
|
133
|
-
},
|
|
134
|
-
|
|
147
|
+
} }, this.dataHub.isCrossAccount ? { accountId: this.dataHub.currentAccountId } : {});
|
|
148
|
+
operationName = this.dataHub.getOperationName('create');
|
|
135
149
|
data = {
|
|
136
|
-
operationName:
|
|
137
|
-
query: constants_1.QUERY_CREATE,
|
|
150
|
+
operationName: operationName,
|
|
151
|
+
query: this.dataHub.isCrossAccount ? constants_1.QUERY_CREATE_CROSSACCOUNT : constants_1.QUERY_CREATE,
|
|
138
152
|
variables: variables,
|
|
139
153
|
};
|
|
140
154
|
return [4, this.dataHub.makeRequest({
|
|
@@ -143,28 +157,26 @@ var Cards = (function () {
|
|
|
143
157
|
data: data,
|
|
144
158
|
})];
|
|
145
159
|
case 1:
|
|
146
|
-
|
|
147
|
-
return [2,
|
|
160
|
+
result = _a.sent();
|
|
161
|
+
return [2, result.data[operationName]];
|
|
148
162
|
}
|
|
149
163
|
});
|
|
150
164
|
});
|
|
151
165
|
};
|
|
152
166
|
Cards.prototype.updateCard = function (source) {
|
|
153
167
|
return __awaiter(this, void 0, void 0, function () {
|
|
154
|
-
var variables, data,
|
|
168
|
+
var variables, operationName, data, result;
|
|
155
169
|
return __generator(this, function (_a) {
|
|
156
170
|
switch (_a.label) {
|
|
157
171
|
case 0:
|
|
158
|
-
variables = {
|
|
159
|
-
entity: constants_1.ENTITY_NAME,
|
|
160
|
-
data: {
|
|
172
|
+
variables = __assign({ entity: constants_1.ENTITY_NAME, data: {
|
|
161
173
|
id: source.id,
|
|
162
174
|
body: source,
|
|
163
|
-
},
|
|
164
|
-
|
|
175
|
+
} }, this.dataHub.isCrossAccount ? { accountId: this.dataHub.currentAccountId } : {});
|
|
176
|
+
operationName = this.dataHub.getOperationName('update');
|
|
165
177
|
data = {
|
|
166
|
-
operationName:
|
|
167
|
-
query:
|
|
178
|
+
operationName: operationName,
|
|
179
|
+
query: this.dataHub.isCrossAccount ? constants_1.QUERY_UPDATE_CROSSACCOUNT : constants_1.QUERY_UPDATE,
|
|
168
180
|
variables: variables,
|
|
169
181
|
};
|
|
170
182
|
return [4, this.dataHub.makeRequest({
|
|
@@ -173,18 +185,21 @@ var Cards = (function () {
|
|
|
173
185
|
data: data,
|
|
174
186
|
})];
|
|
175
187
|
case 1:
|
|
176
|
-
|
|
177
|
-
return [2,
|
|
188
|
+
result = _a.sent();
|
|
189
|
+
return [2, result.data[operationName]];
|
|
178
190
|
}
|
|
179
191
|
});
|
|
180
192
|
});
|
|
181
193
|
};
|
|
182
194
|
Cards.prototype.deleteCard = function (cardId) {
|
|
183
195
|
return __awaiter(this, void 0, void 0, function () {
|
|
184
|
-
var variables, data,
|
|
196
|
+
var variables, operationName, data, result;
|
|
185
197
|
return __generator(this, function (_a) {
|
|
186
198
|
switch (_a.label) {
|
|
187
199
|
case 0:
|
|
200
|
+
if (this.dataHub.isCrossAccount) {
|
|
201
|
+
throw Error('Cross-account deleting is not implemented.');
|
|
202
|
+
}
|
|
188
203
|
variables = {
|
|
189
204
|
entity: constants_1.ENTITY_NAME,
|
|
190
205
|
data: {
|
|
@@ -192,8 +207,9 @@ var Cards = (function () {
|
|
|
192
207
|
subscribe: true,
|
|
193
208
|
},
|
|
194
209
|
};
|
|
210
|
+
operationName = this.dataHub.getOperationName('deleteTemporarily');
|
|
195
211
|
data = {
|
|
196
|
-
operationName:
|
|
212
|
+
operationName: operationName,
|
|
197
213
|
query: constants_1.QUERY_DELETE,
|
|
198
214
|
variables: variables,
|
|
199
215
|
};
|
|
@@ -203,8 +219,44 @@ var Cards = (function () {
|
|
|
203
219
|
data: data,
|
|
204
220
|
})];
|
|
205
221
|
case 1:
|
|
206
|
-
|
|
207
|
-
return [2, this.dataHub.subscribe(requestId)];
|
|
222
|
+
result = _a.sent();
|
|
223
|
+
return [2, this.dataHub.subscribe(result.data[operationName].requestId)];
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
};
|
|
228
|
+
Cards.prototype.addTags = function (source, tagNames) {
|
|
229
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
230
|
+
var tags, tagIds, newIds;
|
|
231
|
+
return __generator(this, function (_a) {
|
|
232
|
+
switch (_a.label) {
|
|
233
|
+
case 0: return [4, this.tags.getMultipleTagsByName(tagNames, true)];
|
|
234
|
+
case 1:
|
|
235
|
+
tags = _a.sent();
|
|
236
|
+
tagIds = tags.map(function (tag) { return tag.id; });
|
|
237
|
+
newIds = (0, tags_1.filterTagIds)(source.data.tagIds, tagIds).newIds;
|
|
238
|
+
if (!newIds.length) {
|
|
239
|
+
throw Error('No tags to add.');
|
|
240
|
+
}
|
|
241
|
+
return [2, this.saveCard(__assign(__assign({}, source), { data: __assign(__assign({}, source.data), { tagIds: (0, tags_1.addTagsIds)(source.data.tagIds, newIds) }) }))];
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
};
|
|
246
|
+
Cards.prototype.removeTags = function (source, tagNames) {
|
|
247
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
248
|
+
var tags, tagIds, existingIds;
|
|
249
|
+
return __generator(this, function (_a) {
|
|
250
|
+
switch (_a.label) {
|
|
251
|
+
case 0: return [4, this.tags.getMultipleTagsByName(tagNames)];
|
|
252
|
+
case 1:
|
|
253
|
+
tags = _a.sent();
|
|
254
|
+
tagIds = tags.map(function (tag) { return tag.id; });
|
|
255
|
+
existingIds = (0, tags_1.filterTagIds)(source.data.tagIds, tagIds).existingIds;
|
|
256
|
+
if (!existingIds.length) {
|
|
257
|
+
throw Error('No tags to remove.');
|
|
258
|
+
}
|
|
259
|
+
return [2, this.saveCard(__assign(__assign({}, source), { data: __assign(__assign({}, source.data), { tagIds: (0, tags_1.removeTagIds)(source.data.tagIds, existingIds) }) }))];
|
|
208
260
|
}
|
|
209
261
|
});
|
|
210
262
|
});
|
package/dist/cjs/Cards.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Cards.js","sourceRoot":"","sources":["../../src/Cards.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Cards.js","sourceRoot":"","sources":["../../src/Cards.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,6CAAkH;AAElH,yCAWqB;AACrB,qCAAsF;AAStF;IAUE,eAAY,MAAmB;QACrB,IAAA,KAAK,GAA8B,MAAM,MAApC,EAAE,YAAY,GAAgB,MAAM,aAAtB,EAAE,SAAS,GAAK,MAAM,UAAX,CAAY;QAElD,IAAI,CAAC,OAAO,GAAG,IAAI,kBAAO,CAAC;YACzB,KAAK,OAAA;YACL,YAAY,cAAA;YACZ,SAAS,WAAA;SACV,CAAC,CAAC;QACH,IAAI,CAAC,IAAI,GAAG,IAAI,WAAI,CAAC;YACnB,KAAK,OAAA;YACL,YAAY,cAAA;YACZ,SAAS,WAAA;SACV,CAAC,CAAC;IAEL,CAAC;IAEK,oBAAI,GAAV;;;;4BACE,WAAM,OAAO,CAAC,GAAG,CAAC;4BAChB,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE;4BACnB,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;yBACjB,CAAC,EAAA;;wBAHF,SAGE,CAAC;;;;;KACJ;IAQY,yBAAS,GAAtB;;;;gBACQ,SAAS,cACb,MAAM,EAAE,uBAAW,EACnB,MAAM,EAAE;wBACN,WAAW,EAAE,EAAE;wBACf,cAAc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oB,CAAC,CAAC;yBACnC;wBAED,WAAO,IAAI,CAAC,QAAQ,uBACf,MAAM,KACT,IAAI,wBACC,MAAM,CAAC,IAAI,KACd,MAAM,EAAE,IAAA,mBAAY,EAAC,MAAM,CAAC,IAAI,CAAC,MAAO,EAAE,WAAW,CAAC,OAExD,EAAC;;;;KACJ;IACH,YAAC;AAAD,CAAC,AAlQD,IAkQC;AAlQY,sBAAK"}
|
package/dist/cjs/constants.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ENTITY_NAME = exports.QUERY_DELETE = exports.QUERY_UPDATE = exports.QUERY_CREATE = exports.QUERY_GET = exports.QUERY_LIST = void 0;
|
|
3
|
+
exports.ENTITY_NAME = exports.QUERY_DELETE = exports.QUERY_UPDATE_CROSSACCOUNT = exports.QUERY_UPDATE = exports.QUERY_CREATE_CROSSACCOUNT = exports.QUERY_CREATE = exports.QUERY_GET_CROSSACCOUNT = exports.QUERY_GET = exports.QUERY_LIST_CROSSACCOUNT = exports.QUERY_LIST = void 0;
|
|
4
4
|
exports.QUERY_LIST = "query list($entity: EntityType!, $params: ListInput!, $sandbox: Boolean) {\n list(entity: $entity, params: $params, sandbox: $sandbox) {\n records {\n ... on Card {\n id\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 tagIds\n }\n reference {\n id\n type\n }\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 last\n }\n}\n";
|
|
5
|
+
exports.QUERY_LIST_CROSSACCOUNT = "query listCrossAccount($entity: EntityType!, $params: ListInput!, $accountId: String!) {\n listCrossAccount(entity: $entity, params: $params, accountId: $accountId) {\n records {\n ... on Card {\n id\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 tagIds\n }\n reference {\n id\n type\n }\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 last\n }\n}\n";
|
|
5
6
|
exports.QUERY_GET = "query get($entity: EntityType!, $params: GetInput!) {\n get(entity: $entity, params: $params) {\n ... on Card {\n id\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 tagIds\n }\n reference {\n id\n type\n }\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}\n";
|
|
7
|
+
exports.QUERY_GET_CROSSACCOUNT = "query getCrossAccount($entity: EntityType!, $params: GetInput!, $accountId: String!) {\n getCrossAccount(entity: $entity, params: $params, accountId: $accountId) {\n ... on Card {\n id\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 tagIds\n }\n reference {\n id\n type\n }\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}\n";
|
|
6
8
|
exports.QUERY_CREATE = "mutation create($entity: EntityType!, $data: CreateInput!) {\n create(entity: $entity, data: $data) {\n ... on Card {\n id\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 tagIds\n }\n reference {\n id\n type\n }\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}\n";
|
|
9
|
+
exports.QUERY_CREATE_CROSSACCOUNT = "mutation createCrossAccount($entity: EntityType!, $data: CreateInput!, $accountId: String!) {\n createCrossAccount(entity: $entity, data: $data, accountId: $accountId) {\n ... on Card {\n id\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 tagIds\n }\n reference {\n id\n type\n }\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}\n";
|
|
7
10
|
exports.QUERY_UPDATE = "mutation update($entity: EntityType!, $data: UpdateInput!) {\n update(entity: $entity, data: $data) {\n ... on Card {\n id\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 tagIds\n }\n reference {\n id\n type\n }\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}\n";
|
|
11
|
+
exports.QUERY_UPDATE_CROSSACCOUNT = "mutation updateCrossAccount($entity: EntityType!, $data: UpdateInput!, $accountId: String!) {\n updateCrossAccount(entity: $entity, data: $data, accountId: $accountId) {\n ... on Card {\n id\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 tagIds\n }\n reference {\n id\n type\n }\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}\n";
|
|
8
12
|
exports.QUERY_DELETE = "mutation deleteTemporarily($entity: EntityType!, $data: DeleteInput!) {\n deleteTemporarily(entity: $entity, data: $data) {\n ... on AsyncRequest {\n requestId\n }\n }\n}";
|
|
9
13
|
exports.ENTITY_NAME = 'CARD';
|
|
10
14
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,UAAU,GAAG,02BA8CzB,CAAC;AAEW,QAAA,SAAS,GAAG,mtBA2CxB,CAAC;AAEW,QAAA,YAAY,GAAG,ytBA2C3B,CAAC;AAEW,QAAA,YAAY,GAAG,ytBA2C3B,CAAC;AAEW,QAAA,YAAY,GAAG,yLAM1B,CAAC;AAEU,QAAA,WAAW,GAAG,MAAM,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,UAAU,GAAG,02BA8CzB,CAAC;AAEW,QAAA,uBAAuB,GAAG,w4BA8CtC,CAAC;AAEW,QAAA,SAAS,GAAG,mtBA2CxB,CAAC;AAEW,QAAA,sBAAsB,GAAG,uxBA2CrC,CAAC;AAEW,QAAA,YAAY,GAAG,ytBA2C3B,CAAC;AAEW,QAAA,yBAAyB,GAAG,6xBA2CxC,CAAC;AAEW,QAAA,YAAY,GAAG,ytBA2C3B,CAAC;AACW,QAAA,yBAAyB,GAAG,6xBA2CxC,CAAC;AAEW,QAAA,YAAY,GAAG,yLAM1B,CAAC;AAEU,QAAA,WAAW,GAAG,MAAM,CAAC"}
|
package/dist/esm/Cards.js
CHANGED
|
@@ -8,35 +8,42 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { DataHub } from '@or-sdk/data-hub';
|
|
11
|
-
import { ENTITY_NAME, QUERY_LIST, QUERY_GET, QUERY_CREATE, QUERY_UPDATE, QUERY_DELETE } from './constants';
|
|
11
|
+
import { ENTITY_NAME, QUERY_LIST, QUERY_GET, QUERY_CREATE, QUERY_UPDATE, QUERY_DELETE, QUERY_LIST_CROSSACCOUNT, QUERY_GET_CROSSACCOUNT, QUERY_CREATE_CROSSACCOUNT, QUERY_UPDATE_CROSSACCOUNT, } from './constants';
|
|
12
|
+
import { Tags, filterTagIds, addTagsIds, removeTagIds } from '@or-sdk/tags';
|
|
12
13
|
export class Cards {
|
|
13
14
|
constructor(params) {
|
|
14
|
-
const { token, discoveryUrl } = params;
|
|
15
|
+
const { token, discoveryUrl, accountId } = params;
|
|
15
16
|
this.dataHub = new DataHub({
|
|
16
17
|
token,
|
|
17
18
|
discoveryUrl,
|
|
19
|
+
accountId,
|
|
20
|
+
});
|
|
21
|
+
this.tags = new Tags({
|
|
22
|
+
token,
|
|
23
|
+
discoveryUrl,
|
|
24
|
+
accountId,
|
|
18
25
|
});
|
|
19
26
|
}
|
|
20
27
|
init() {
|
|
21
28
|
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
-
yield
|
|
29
|
+
yield Promise.all([
|
|
30
|
+
this.dataHub.init(),
|
|
31
|
+
this.tags.init(),
|
|
32
|
+
]);
|
|
23
33
|
});
|
|
24
34
|
}
|
|
25
35
|
listCards() {
|
|
26
36
|
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
-
const variables = {
|
|
28
|
-
entity: ENTITY_NAME,
|
|
29
|
-
params: {
|
|
37
|
+
const variables = Object.assign({ entity: ENTITY_NAME, params: {
|
|
30
38
|
queryParams: {},
|
|
31
39
|
includeDeleted: false,
|
|
32
40
|
includeExisting: true,
|
|
33
41
|
limit: 30,
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
};
|
|
42
|
+
} }, this.dataHub.isCrossAccount ? { accountId: this.dataHub.currentAccountId } : { sandbox: false });
|
|
43
|
+
const operationName = this.dataHub.getOperationName('list');
|
|
37
44
|
const data = {
|
|
38
|
-
operationName
|
|
39
|
-
query: QUERY_LIST,
|
|
45
|
+
operationName,
|
|
46
|
+
query: this.dataHub.isCrossAccount ? QUERY_LIST_CROSSACCOUNT : QUERY_LIST,
|
|
40
47
|
variables,
|
|
41
48
|
};
|
|
42
49
|
return this.dataHub.getFullList('POST', '/graphql', data);
|
|
@@ -44,25 +51,23 @@ export class Cards {
|
|
|
44
51
|
}
|
|
45
52
|
getCard(id) {
|
|
46
53
|
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
-
const variables = {
|
|
48
|
-
entity: ENTITY_NAME,
|
|
49
|
-
params: {
|
|
54
|
+
const variables = Object.assign({ entity: ENTITY_NAME, params: {
|
|
50
55
|
id,
|
|
51
56
|
includeDeleted: false,
|
|
52
57
|
includeExisting: true,
|
|
53
|
-
},
|
|
54
|
-
|
|
58
|
+
} }, this.dataHub.isCrossAccount ? { accountId: this.dataHub.currentAccountId } : {});
|
|
59
|
+
const operationName = this.dataHub.getOperationName('get');
|
|
55
60
|
const data = {
|
|
56
|
-
operationName
|
|
57
|
-
query: QUERY_GET,
|
|
61
|
+
operationName,
|
|
62
|
+
query: this.dataHub.isCrossAccount ? QUERY_GET_CROSSACCOUNT : QUERY_GET,
|
|
58
63
|
variables,
|
|
59
64
|
};
|
|
60
|
-
const
|
|
65
|
+
const result = yield this.dataHub.makeRequest({
|
|
61
66
|
method: 'POST',
|
|
62
67
|
route: '/graphql',
|
|
63
68
|
data,
|
|
64
69
|
});
|
|
65
|
-
return
|
|
70
|
+
return result.data[operationName];
|
|
66
71
|
});
|
|
67
72
|
}
|
|
68
73
|
saveCard(source) {
|
|
@@ -72,49 +77,48 @@ export class Cards {
|
|
|
72
77
|
}
|
|
73
78
|
createCard(source) {
|
|
74
79
|
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
-
const variables = {
|
|
76
|
-
entity: ENTITY_NAME,
|
|
77
|
-
data: {
|
|
80
|
+
const variables = Object.assign({ entity: ENTITY_NAME, data: {
|
|
78
81
|
body: source,
|
|
79
|
-
},
|
|
80
|
-
|
|
82
|
+
} }, this.dataHub.isCrossAccount ? { accountId: this.dataHub.currentAccountId } : {});
|
|
83
|
+
const operationName = this.dataHub.getOperationName('create');
|
|
81
84
|
const data = {
|
|
82
|
-
operationName
|
|
83
|
-
query: QUERY_CREATE,
|
|
85
|
+
operationName,
|
|
86
|
+
query: this.dataHub.isCrossAccount ? QUERY_CREATE_CROSSACCOUNT : QUERY_CREATE,
|
|
84
87
|
variables,
|
|
85
88
|
};
|
|
86
|
-
const
|
|
89
|
+
const result = yield this.dataHub.makeRequest({
|
|
87
90
|
method: 'POST',
|
|
88
91
|
route: '/graphql',
|
|
89
92
|
data,
|
|
90
93
|
});
|
|
91
|
-
return
|
|
94
|
+
return result.data[operationName];
|
|
92
95
|
});
|
|
93
96
|
}
|
|
94
97
|
updateCard(source) {
|
|
95
98
|
return __awaiter(this, void 0, void 0, function* () {
|
|
96
|
-
const variables = {
|
|
97
|
-
entity: ENTITY_NAME,
|
|
98
|
-
data: {
|
|
99
|
+
const variables = Object.assign({ entity: ENTITY_NAME, data: {
|
|
99
100
|
id: source.id,
|
|
100
101
|
body: source,
|
|
101
|
-
},
|
|
102
|
-
|
|
102
|
+
} }, this.dataHub.isCrossAccount ? { accountId: this.dataHub.currentAccountId } : {});
|
|
103
|
+
const operationName = this.dataHub.getOperationName('update');
|
|
103
104
|
const data = {
|
|
104
|
-
operationName
|
|
105
|
-
query:
|
|
105
|
+
operationName,
|
|
106
|
+
query: this.dataHub.isCrossAccount ? QUERY_UPDATE_CROSSACCOUNT : QUERY_UPDATE,
|
|
106
107
|
variables,
|
|
107
108
|
};
|
|
108
|
-
const
|
|
109
|
+
const result = yield this.dataHub.makeRequest({
|
|
109
110
|
method: 'POST',
|
|
110
111
|
route: '/graphql',
|
|
111
112
|
data,
|
|
112
113
|
});
|
|
113
|
-
return
|
|
114
|
+
return result.data[operationName];
|
|
114
115
|
});
|
|
115
116
|
}
|
|
116
117
|
deleteCard(cardId) {
|
|
117
118
|
return __awaiter(this, void 0, void 0, function* () {
|
|
119
|
+
if (this.dataHub.isCrossAccount) {
|
|
120
|
+
throw Error('Cross-account deleting is not implemented.');
|
|
121
|
+
}
|
|
118
122
|
const variables = {
|
|
119
123
|
entity: ENTITY_NAME,
|
|
120
124
|
data: {
|
|
@@ -122,17 +126,40 @@ export class Cards {
|
|
|
122
126
|
subscribe: true,
|
|
123
127
|
},
|
|
124
128
|
};
|
|
129
|
+
const operationName = this.dataHub.getOperationName('deleteTemporarily');
|
|
125
130
|
const data = {
|
|
126
|
-
operationName
|
|
131
|
+
operationName,
|
|
127
132
|
query: QUERY_DELETE,
|
|
128
133
|
variables,
|
|
129
134
|
};
|
|
130
|
-
const
|
|
135
|
+
const result = yield this.dataHub.makeRequest({
|
|
131
136
|
method: 'POST',
|
|
132
137
|
route: '/graphql',
|
|
133
138
|
data,
|
|
134
139
|
});
|
|
135
|
-
return this.dataHub.subscribe(requestId);
|
|
140
|
+
return this.dataHub.subscribe(result.data[operationName].requestId);
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
addTags(source, tagNames) {
|
|
144
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
145
|
+
const tags = yield this.tags.getMultipleTagsByName(tagNames, true);
|
|
146
|
+
const tagIds = tags.map(tag => tag.id);
|
|
147
|
+
const { newIds } = filterTagIds(source.data.tagIds, tagIds);
|
|
148
|
+
if (!newIds.length) {
|
|
149
|
+
throw Error('No tags to add.');
|
|
150
|
+
}
|
|
151
|
+
return this.saveCard(Object.assign(Object.assign({}, source), { data: Object.assign(Object.assign({}, source.data), { tagIds: addTagsIds(source.data.tagIds, newIds) }) }));
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
removeTags(source, tagNames) {
|
|
155
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
156
|
+
const tags = yield this.tags.getMultipleTagsByName(tagNames);
|
|
157
|
+
const tagIds = tags.map(tag => tag.id);
|
|
158
|
+
const { existingIds } = filterTagIds(source.data.tagIds, tagIds);
|
|
159
|
+
if (!existingIds.length) {
|
|
160
|
+
throw Error('No tags to remove.');
|
|
161
|
+
}
|
|
162
|
+
return this.saveCard(Object.assign(Object.assign({}, source), { data: Object.assign(Object.assign({}, source.data), { tagIds: removeTagIds(source.data.tagIds, existingIds) }) }));
|
|
136
163
|
});
|
|
137
164
|
}
|
|
138
165
|
}
|
package/dist/esm/Cards.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Cards.js","sourceRoot":"","sources":["../../src/Cards.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"Cards.js","sourceRoot":"","sources":["../../src/Cards.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,OAAO,E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,EAAE,MAAM,CAAC,CAAC;YAE7D,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;gBAClB,MAAM,KAAK,CAAC,iBAAiB,CAAC,CAAC;aAChC;YAED,OAAO,IAAI,CAAC,QAAQ,iCACf,MAAM,KACT,IAAI,kCACC,MAAM,CAAC,IAAI,KACd,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,MAAO,EAAE,MAAM,CAAC,OAEjD,CAAC;QACL,CAAC;KAAA;IAQY,UAAU,CAAC,MAAY,EAAE,QAAkB;;YACtD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC;YAC7D,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAG,CAAC,CAAC;YAExC,MAAM,EAAE,WAAW,EAAE,GAAG,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,MAAO,EAAE,MAAM,CAAC,CAAC;YAElE,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE;gBACvB,MAAM,KAAK,CAAC,oBAAoB,CAAC,CAAC;aACnC;YAED,OAAO,IAAI,CAAC,QAAQ,iCACf,MAAM,KACT,IAAI,kCACC,MAAM,CAAC,IAAI,KACd,MAAM,EAAE,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,MAAO,EAAE,WAAW,CAAC,OAExD,CAAC;QACL,CAAC;KAAA;CACF"}
|
package/dist/esm/constants.js
CHANGED
|
@@ -45,6 +45,53 @@ export const QUERY_LIST = `query list($entity: EntityType!, $params: ListInput!,
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
`;
|
|
48
|
+
export const QUERY_LIST_CROSSACCOUNT = `query listCrossAccount($entity: EntityType!, $params: ListInput!, $accountId: String!) {
|
|
49
|
+
listCrossAccount(entity: $entity, params: $params, accountId: $accountId) {
|
|
50
|
+
records {
|
|
51
|
+
... on Card {
|
|
52
|
+
id
|
|
53
|
+
schemaVersion
|
|
54
|
+
dateCreated
|
|
55
|
+
dateModified
|
|
56
|
+
data {
|
|
57
|
+
data
|
|
58
|
+
form {
|
|
59
|
+
code
|
|
60
|
+
data
|
|
61
|
+
style
|
|
62
|
+
template
|
|
63
|
+
}
|
|
64
|
+
presentation {
|
|
65
|
+
code
|
|
66
|
+
data
|
|
67
|
+
style
|
|
68
|
+
template
|
|
69
|
+
}
|
|
70
|
+
tagIds
|
|
71
|
+
}
|
|
72
|
+
reference {
|
|
73
|
+
id
|
|
74
|
+
type
|
|
75
|
+
}
|
|
76
|
+
template {
|
|
77
|
+
category
|
|
78
|
+
description
|
|
79
|
+
help
|
|
80
|
+
icon
|
|
81
|
+
iconUrl
|
|
82
|
+
implicitly
|
|
83
|
+
label
|
|
84
|
+
publishedBy
|
|
85
|
+
tags
|
|
86
|
+
type
|
|
87
|
+
version
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
last
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
`;
|
|
48
95
|
export const QUERY_GET = `query get($entity: EntityType!, $params: GetInput!) {
|
|
49
96
|
get(entity: $entity, params: $params) {
|
|
50
97
|
... on Card {
|
|
@@ -89,6 +136,50 @@ export const QUERY_GET = `query get($entity: EntityType!, $params: GetInput!) {
|
|
|
89
136
|
}
|
|
90
137
|
}
|
|
91
138
|
`;
|
|
139
|
+
export const QUERY_GET_CROSSACCOUNT = `query getCrossAccount($entity: EntityType!, $params: GetInput!, $accountId: String!) {
|
|
140
|
+
getCrossAccount(entity: $entity, params: $params, accountId: $accountId) {
|
|
141
|
+
... on Card {
|
|
142
|
+
id
|
|
143
|
+
schemaVersion
|
|
144
|
+
dateCreated
|
|
145
|
+
dateModified
|
|
146
|
+
data {
|
|
147
|
+
data
|
|
148
|
+
form {
|
|
149
|
+
code
|
|
150
|
+
data
|
|
151
|
+
style
|
|
152
|
+
template
|
|
153
|
+
}
|
|
154
|
+
presentation {
|
|
155
|
+
code
|
|
156
|
+
data
|
|
157
|
+
style
|
|
158
|
+
template
|
|
159
|
+
}
|
|
160
|
+
tagIds
|
|
161
|
+
}
|
|
162
|
+
reference {
|
|
163
|
+
id
|
|
164
|
+
type
|
|
165
|
+
}
|
|
166
|
+
template {
|
|
167
|
+
category
|
|
168
|
+
description
|
|
169
|
+
help
|
|
170
|
+
icon
|
|
171
|
+
iconUrl
|
|
172
|
+
implicitly
|
|
173
|
+
label
|
|
174
|
+
publishedBy
|
|
175
|
+
tags
|
|
176
|
+
type
|
|
177
|
+
version
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
`;
|
|
92
183
|
export const QUERY_CREATE = `mutation create($entity: EntityType!, $data: CreateInput!) {
|
|
93
184
|
create(entity: $entity, data: $data) {
|
|
94
185
|
... on Card {
|
|
@@ -133,6 +224,50 @@ export const QUERY_CREATE = `mutation create($entity: EntityType!, $data: Create
|
|
|
133
224
|
}
|
|
134
225
|
}
|
|
135
226
|
`;
|
|
227
|
+
export const QUERY_CREATE_CROSSACCOUNT = `mutation createCrossAccount($entity: EntityType!, $data: CreateInput!, $accountId: String!) {
|
|
228
|
+
createCrossAccount(entity: $entity, data: $data, accountId: $accountId) {
|
|
229
|
+
... on Card {
|
|
230
|
+
id
|
|
231
|
+
schemaVersion
|
|
232
|
+
dateCreated
|
|
233
|
+
dateModified
|
|
234
|
+
data {
|
|
235
|
+
data
|
|
236
|
+
form {
|
|
237
|
+
code
|
|
238
|
+
data
|
|
239
|
+
style
|
|
240
|
+
template
|
|
241
|
+
}
|
|
242
|
+
presentation {
|
|
243
|
+
code
|
|
244
|
+
data
|
|
245
|
+
style
|
|
246
|
+
template
|
|
247
|
+
}
|
|
248
|
+
tagIds
|
|
249
|
+
}
|
|
250
|
+
reference {
|
|
251
|
+
id
|
|
252
|
+
type
|
|
253
|
+
}
|
|
254
|
+
template {
|
|
255
|
+
category
|
|
256
|
+
description
|
|
257
|
+
help
|
|
258
|
+
icon
|
|
259
|
+
iconUrl
|
|
260
|
+
implicitly
|
|
261
|
+
label
|
|
262
|
+
publishedBy
|
|
263
|
+
tags
|
|
264
|
+
type
|
|
265
|
+
version
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
`;
|
|
136
271
|
export const QUERY_UPDATE = `mutation update($entity: EntityType!, $data: UpdateInput!) {
|
|
137
272
|
update(entity: $entity, data: $data) {
|
|
138
273
|
... on Card {
|
|
@@ -177,6 +312,50 @@ export const QUERY_UPDATE = `mutation update($entity: EntityType!, $data: Update
|
|
|
177
312
|
}
|
|
178
313
|
}
|
|
179
314
|
`;
|
|
315
|
+
export const QUERY_UPDATE_CROSSACCOUNT = `mutation updateCrossAccount($entity: EntityType!, $data: UpdateInput!, $accountId: String!) {
|
|
316
|
+
updateCrossAccount(entity: $entity, data: $data, accountId: $accountId) {
|
|
317
|
+
... on Card {
|
|
318
|
+
id
|
|
319
|
+
schemaVersion
|
|
320
|
+
dateCreated
|
|
321
|
+
dateModified
|
|
322
|
+
data {
|
|
323
|
+
data
|
|
324
|
+
form {
|
|
325
|
+
code
|
|
326
|
+
data
|
|
327
|
+
style
|
|
328
|
+
template
|
|
329
|
+
}
|
|
330
|
+
presentation {
|
|
331
|
+
code
|
|
332
|
+
data
|
|
333
|
+
style
|
|
334
|
+
template
|
|
335
|
+
}
|
|
336
|
+
tagIds
|
|
337
|
+
}
|
|
338
|
+
reference {
|
|
339
|
+
id
|
|
340
|
+
type
|
|
341
|
+
}
|
|
342
|
+
template {
|
|
343
|
+
category
|
|
344
|
+
description
|
|
345
|
+
help
|
|
346
|
+
icon
|
|
347
|
+
iconUrl
|
|
348
|
+
implicitly
|
|
349
|
+
label
|
|
350
|
+
publishedBy
|
|
351
|
+
tags
|
|
352
|
+
type
|
|
353
|
+
version
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
`;
|
|
180
359
|
export const QUERY_DELETE = `mutation deleteTemporarily($entity: EntityType!, $data: DeleteInput!) {
|
|
181
360
|
deleteTemporarily(entity: $entity, data: $data) {
|
|
182
361
|
... on AsyncRequest {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8CzB,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2CxB,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2C3B,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2C3B,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG;;;;;;EAM1B,CAAC;AAEH,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8CzB,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8CtC,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2CxB,CAAC;AAEF,MAAM,CAAC,MAAM,sBAAsB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2CrC,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2C3B,CAAC;AAEF,MAAM,CAAC,MAAM,yBAAyB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2CxC,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2C3B,CAAC;AACF,MAAM,CAAC,MAAM,yBAAyB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2CxC,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG;;;;;;EAM1B,CAAC;AAEH,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC"}
|
package/dist/types/Cards.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { List } from '@or-sdk/base';
|
|
2
2
|
import { GraphqlResponseCheckExecution } from '@or-sdk/data-hub';
|
|
3
3
|
import { CardsConfig, Card } from './types';
|
|
4
|
-
|
|
4
|
+
import { Taggable } from '@or-sdk/tags';
|
|
5
|
+
export declare class Cards implements Taggable<Card> {
|
|
5
6
|
private readonly dataHub;
|
|
7
|
+
private readonly tags;
|
|
6
8
|
constructor(params: CardsConfig);
|
|
7
9
|
init(): Promise<void>;
|
|
8
10
|
listCards(): Promise<List<Card>>;
|
|
@@ -11,4 +13,6 @@ export declare class Cards {
|
|
|
11
13
|
createCard(source: Card): Promise<Card>;
|
|
12
14
|
updateCard(source: Card): Promise<Card>;
|
|
13
15
|
deleteCard(cardId: string): Promise<GraphqlResponseCheckExecution>;
|
|
16
|
+
addTags(source: Card, tagNames: string[]): Promise<Card>;
|
|
17
|
+
removeTags(source: Card, tagNames: string[]): Promise<Card>;
|
|
14
18
|
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export declare const QUERY_LIST = "query list($entity: EntityType!, $params: ListInput!, $sandbox: Boolean) {\n list(entity: $entity, params: $params, sandbox: $sandbox) {\n records {\n ... on Card {\n id\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 tagIds\n }\n reference {\n id\n type\n }\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 last\n }\n}\n";
|
|
2
|
+
export declare const QUERY_LIST_CROSSACCOUNT = "query listCrossAccount($entity: EntityType!, $params: ListInput!, $accountId: String!) {\n listCrossAccount(entity: $entity, params: $params, accountId: $accountId) {\n records {\n ... on Card {\n id\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 tagIds\n }\n reference {\n id\n type\n }\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 last\n }\n}\n";
|
|
2
3
|
export declare const QUERY_GET = "query get($entity: EntityType!, $params: GetInput!) {\n get(entity: $entity, params: $params) {\n ... on Card {\n id\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 tagIds\n }\n reference {\n id\n type\n }\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}\n";
|
|
4
|
+
export declare const QUERY_GET_CROSSACCOUNT = "query getCrossAccount($entity: EntityType!, $params: GetInput!, $accountId: String!) {\n getCrossAccount(entity: $entity, params: $params, accountId: $accountId) {\n ... on Card {\n id\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 tagIds\n }\n reference {\n id\n type\n }\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}\n";
|
|
3
5
|
export declare const QUERY_CREATE = "mutation create($entity: EntityType!, $data: CreateInput!) {\n create(entity: $entity, data: $data) {\n ... on Card {\n id\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 tagIds\n }\n reference {\n id\n type\n }\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}\n";
|
|
6
|
+
export declare const QUERY_CREATE_CROSSACCOUNT = "mutation createCrossAccount($entity: EntityType!, $data: CreateInput!, $accountId: String!) {\n createCrossAccount(entity: $entity, data: $data, accountId: $accountId) {\n ... on Card {\n id\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 tagIds\n }\n reference {\n id\n type\n }\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}\n";
|
|
4
7
|
export declare const QUERY_UPDATE = "mutation update($entity: EntityType!, $data: UpdateInput!) {\n update(entity: $entity, data: $data) {\n ... on Card {\n id\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 tagIds\n }\n reference {\n id\n type\n }\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}\n";
|
|
8
|
+
export declare const QUERY_UPDATE_CROSSACCOUNT = "mutation updateCrossAccount($entity: EntityType!, $data: UpdateInput!, $accountId: String!) {\n updateCrossAccount(entity: $entity, data: $data, accountId: $accountId) {\n ... on Card {\n id\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 tagIds\n }\n reference {\n id\n type\n }\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}\n";
|
|
5
9
|
export declare const QUERY_DELETE = "mutation deleteTemporarily($entity: EntityType!, $data: DeleteInput!) {\n deleteTemporarily(entity: $entity, data: $data) {\n ... on AsyncRequest {\n requestId\n }\n }\n}";
|
|
6
10
|
export declare const ENTITY_NAME = "CARD";
|
package/dist/types/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.16.0",
|
|
3
3
|
"name": "@or-sdk/cards",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
@@ -23,8 +23,9 @@
|
|
|
23
23
|
"access": "public"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@or-sdk/base": "^0.
|
|
27
|
-
"@or-sdk/data-hub": "^0.
|
|
26
|
+
"@or-sdk/base": "^0.16.0",
|
|
27
|
+
"@or-sdk/data-hub": "^0.16.0",
|
|
28
|
+
"@or-sdk/tags": "^0.16.0"
|
|
28
29
|
},
|
|
29
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "f855bf3ee6b361c5831479cee5cde6f7702b6ced"
|
|
30
31
|
}
|
package/src/Cards.ts
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
import { List } from '@or-sdk/base';
|
|
2
|
-
import { DataHub, GraphqlResponse, GraphqlResponseCheckExecution } from '@or-sdk/data-hub';
|
|
2
|
+
import { DataHub, GraphqlResponse, GraphqlResponseCheckExecution, GraphqlResponseDelete } from '@or-sdk/data-hub';
|
|
3
3
|
import { CardsConfig, Card } from './types';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
ENTITY_NAME,
|
|
6
|
+
QUERY_LIST,
|
|
7
|
+
QUERY_GET,
|
|
8
|
+
QUERY_CREATE,
|
|
9
|
+
QUERY_UPDATE,
|
|
10
|
+
QUERY_DELETE,
|
|
11
|
+
QUERY_LIST_CROSSACCOUNT,
|
|
12
|
+
QUERY_GET_CROSSACCOUNT,
|
|
13
|
+
QUERY_CREATE_CROSSACCOUNT,
|
|
14
|
+
QUERY_UPDATE_CROSSACCOUNT,
|
|
15
|
+
} from './constants';
|
|
16
|
+
import { Tags, Taggable, filterTagIds, addTagsIds, removeTagIds } from '@or-sdk/tags';
|
|
5
17
|
|
|
6
18
|
/**
|
|
7
19
|
* OneReach Cards service client
|
|
@@ -10,27 +22,37 @@ import { ENTITY_NAME, QUERY_LIST, QUERY_GET, QUERY_CREATE, QUERY_UPDATE, QUERY_D
|
|
|
10
22
|
* $ npm i @or-sdk/cards
|
|
11
23
|
* ```
|
|
12
24
|
*/
|
|
13
|
-
export class Cards {
|
|
25
|
+
export class Cards implements Taggable<Card> {
|
|
14
26
|
private readonly dataHub: DataHub;
|
|
27
|
+
private readonly tags: Tags;
|
|
15
28
|
|
|
16
29
|
/**
|
|
17
30
|
* ```typescript
|
|
18
31
|
* import { Cards } from '@or-sdk/cards'
|
|
19
32
|
* const cards = new Cards({token: 'my-account-token-string', discoveryUrl: 'http://example.cards/endpoint'});
|
|
20
|
-
* await cards.init();
|
|
21
33
|
* ```
|
|
22
34
|
*/
|
|
23
35
|
constructor(params: CardsConfig) {
|
|
24
|
-
const { token, discoveryUrl } = params;
|
|
36
|
+
const { token, discoveryUrl, accountId } = params;
|
|
25
37
|
|
|
26
38
|
this.dataHub = new DataHub({
|
|
27
39
|
token,
|
|
28
40
|
discoveryUrl,
|
|
41
|
+
accountId,
|
|
29
42
|
});
|
|
43
|
+
this.tags = new Tags({
|
|
44
|
+
token,
|
|
45
|
+
discoveryUrl,
|
|
46
|
+
accountId,
|
|
47
|
+
});
|
|
48
|
+
|
|
30
49
|
}
|
|
31
50
|
|
|
32
51
|
async init() {
|
|
33
|
-
await
|
|
52
|
+
await Promise.all([
|
|
53
|
+
this.dataHub.init(),
|
|
54
|
+
this.tags.init(),
|
|
55
|
+
]);
|
|
34
56
|
}
|
|
35
57
|
|
|
36
58
|
/**
|
|
@@ -48,12 +70,14 @@ export class Cards {
|
|
|
48
70
|
includeExisting: true,
|
|
49
71
|
limit: 30,
|
|
50
72
|
},
|
|
51
|
-
sandbox: false,
|
|
73
|
+
... this.dataHub.isCrossAccount ? { accountId: this.dataHub.currentAccountId } : { sandbox: false },
|
|
52
74
|
};
|
|
53
75
|
|
|
76
|
+
const operationName = this.dataHub.getOperationName('list');
|
|
77
|
+
|
|
54
78
|
const data = {
|
|
55
|
-
operationName
|
|
56
|
-
query: QUERY_LIST,
|
|
79
|
+
operationName,
|
|
80
|
+
query: this.dataHub.isCrossAccount ? QUERY_LIST_CROSSACCOUNT : QUERY_LIST,
|
|
57
81
|
variables,
|
|
58
82
|
};
|
|
59
83
|
|
|
@@ -74,21 +98,24 @@ export class Cards {
|
|
|
74
98
|
includeDeleted: false,
|
|
75
99
|
includeExisting: true,
|
|
76
100
|
},
|
|
101
|
+
... this.dataHub.isCrossAccount ? { accountId: this.dataHub.currentAccountId } : {},
|
|
77
102
|
};
|
|
78
103
|
|
|
104
|
+
const operationName = this.dataHub.getOperationName('get');
|
|
105
|
+
|
|
79
106
|
const data = {
|
|
80
|
-
operationName
|
|
81
|
-
query: QUERY_GET,
|
|
107
|
+
operationName,
|
|
108
|
+
query: this.dataHub.isCrossAccount ? QUERY_GET_CROSSACCOUNT : QUERY_GET,
|
|
82
109
|
variables,
|
|
83
110
|
};
|
|
84
111
|
|
|
85
|
-
const
|
|
112
|
+
const result = await this.dataHub.makeRequest<GraphqlResponse<Card>>({
|
|
86
113
|
method: 'POST',
|
|
87
114
|
route: '/graphql',
|
|
88
115
|
data,
|
|
89
116
|
});
|
|
90
117
|
|
|
91
|
-
return
|
|
118
|
+
return result.data[operationName] as Card;
|
|
92
119
|
}
|
|
93
120
|
|
|
94
121
|
/**
|
|
@@ -115,21 +142,24 @@ export class Cards {
|
|
|
115
142
|
data: {
|
|
116
143
|
body: source,
|
|
117
144
|
},
|
|
145
|
+
... this.dataHub.isCrossAccount ? { accountId: this.dataHub.currentAccountId } : {},
|
|
118
146
|
};
|
|
119
147
|
|
|
148
|
+
const operationName = this.dataHub.getOperationName('create');
|
|
149
|
+
|
|
120
150
|
const data = {
|
|
121
|
-
operationName
|
|
122
|
-
query: QUERY_CREATE,
|
|
151
|
+
operationName,
|
|
152
|
+
query: this.dataHub.isCrossAccount ? QUERY_CREATE_CROSSACCOUNT : QUERY_CREATE,
|
|
123
153
|
variables,
|
|
124
154
|
};
|
|
125
155
|
|
|
126
|
-
const
|
|
156
|
+
const result = await this.dataHub.makeRequest<GraphqlResponse<Card>>({
|
|
127
157
|
method: 'POST',
|
|
128
158
|
route: '/graphql',
|
|
129
159
|
data,
|
|
130
160
|
});
|
|
131
161
|
|
|
132
|
-
return
|
|
162
|
+
return result.data[operationName] as Card;
|
|
133
163
|
}
|
|
134
164
|
|
|
135
165
|
/**
|
|
@@ -145,21 +175,24 @@ export class Cards {
|
|
|
145
175
|
id: source.id,
|
|
146
176
|
body: source,
|
|
147
177
|
},
|
|
178
|
+
... this.dataHub.isCrossAccount ? { accountId: this.dataHub.currentAccountId } : {},
|
|
148
179
|
};
|
|
149
180
|
|
|
181
|
+
const operationName = this.dataHub.getOperationName('update');
|
|
182
|
+
|
|
150
183
|
const data = {
|
|
151
|
-
operationName
|
|
152
|
-
query:
|
|
184
|
+
operationName,
|
|
185
|
+
query: this.dataHub.isCrossAccount ? QUERY_UPDATE_CROSSACCOUNT : QUERY_UPDATE,
|
|
153
186
|
variables,
|
|
154
187
|
};
|
|
155
188
|
|
|
156
|
-
const
|
|
189
|
+
const result = await this.dataHub.makeRequest<GraphqlResponse<Card>>({
|
|
157
190
|
method: 'POST',
|
|
158
191
|
route: '/graphql',
|
|
159
192
|
data,
|
|
160
193
|
});
|
|
161
194
|
|
|
162
|
-
return
|
|
195
|
+
return result.data[operationName] as Card;
|
|
163
196
|
}
|
|
164
197
|
|
|
165
198
|
/**
|
|
@@ -169,6 +202,10 @@ export class Cards {
|
|
|
169
202
|
* ```
|
|
170
203
|
*/
|
|
171
204
|
public async deleteCard(cardId: string): Promise<GraphqlResponseCheckExecution> {
|
|
205
|
+
if (this.dataHub.isCrossAccount) {
|
|
206
|
+
throw Error('Cross-account deleting is not implemented.');
|
|
207
|
+
}
|
|
208
|
+
|
|
172
209
|
const variables = {
|
|
173
210
|
entity: ENTITY_NAME,
|
|
174
211
|
data: {
|
|
@@ -177,18 +214,70 @@ export class Cards {
|
|
|
177
214
|
},
|
|
178
215
|
};
|
|
179
216
|
|
|
217
|
+
const operationName = this.dataHub.getOperationName('deleteTemporarily');
|
|
218
|
+
|
|
180
219
|
const data = {
|
|
181
|
-
operationName
|
|
220
|
+
operationName,
|
|
182
221
|
query: QUERY_DELETE,
|
|
183
222
|
variables,
|
|
184
223
|
};
|
|
185
224
|
|
|
186
|
-
const
|
|
225
|
+
const result = await this.dataHub.makeRequest<GraphqlResponse<void>>({
|
|
187
226
|
method: 'POST',
|
|
188
227
|
route: '/graphql',
|
|
189
228
|
data,
|
|
190
229
|
});
|
|
191
230
|
|
|
192
|
-
return this.dataHub.subscribe(requestId);
|
|
231
|
+
return this.dataHub.subscribe((result.data[operationName] as GraphqlResponseDelete).requestId);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Add tags
|
|
236
|
+
* ```typescript
|
|
237
|
+
* const card = await cards.addTags(cardSource, tagIdsArr);
|
|
238
|
+
* ```
|
|
239
|
+
*/
|
|
240
|
+
public async addTags(source: Card, tagNames: string[]): Promise<Card> {
|
|
241
|
+
const tags = await this.tags.getMultipleTagsByName(tagNames, true);
|
|
242
|
+
const tagIds = tags.map(tag => tag.id!);
|
|
243
|
+
|
|
244
|
+
const { newIds } = filterTagIds(source.data.tagIds!, tagIds);
|
|
245
|
+
|
|
246
|
+
if (!newIds.length) {
|
|
247
|
+
throw Error('No tags to add.');
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
return this.saveCard({
|
|
251
|
+
...source,
|
|
252
|
+
data: {
|
|
253
|
+
...source.data,
|
|
254
|
+
tagIds: addTagsIds(source.data.tagIds!, newIds),
|
|
255
|
+
},
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Remove tags
|
|
261
|
+
* ```typescript
|
|
262
|
+
* const card = await cards.removeTags(cardSource, tagIdsArr);
|
|
263
|
+
* ```
|
|
264
|
+
*/
|
|
265
|
+
public async removeTags(source: Card, tagNames: string[]): Promise<Card> {
|
|
266
|
+
const tags = await this.tags.getMultipleTagsByName(tagNames);
|
|
267
|
+
const tagIds = tags.map(tag => tag.id!);
|
|
268
|
+
|
|
269
|
+
const { existingIds } = filterTagIds(source.data.tagIds!, tagIds);
|
|
270
|
+
|
|
271
|
+
if (!existingIds.length) {
|
|
272
|
+
throw Error('No tags to remove.');
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
return this.saveCard({
|
|
276
|
+
...source,
|
|
277
|
+
data: {
|
|
278
|
+
...source.data,
|
|
279
|
+
tagIds: removeTagIds(source.data.tagIds!, existingIds),
|
|
280
|
+
},
|
|
281
|
+
});
|
|
193
282
|
}
|
|
194
283
|
}
|
package/src/constants.ts
CHANGED
|
@@ -46,6 +46,54 @@ export const QUERY_LIST = `query list($entity: EntityType!, $params: ListInput!,
|
|
|
46
46
|
}
|
|
47
47
|
`;
|
|
48
48
|
|
|
49
|
+
export const QUERY_LIST_CROSSACCOUNT = `query listCrossAccount($entity: EntityType!, $params: ListInput!, $accountId: String!) {
|
|
50
|
+
listCrossAccount(entity: $entity, params: $params, accountId: $accountId) {
|
|
51
|
+
records {
|
|
52
|
+
... on Card {
|
|
53
|
+
id
|
|
54
|
+
schemaVersion
|
|
55
|
+
dateCreated
|
|
56
|
+
dateModified
|
|
57
|
+
data {
|
|
58
|
+
data
|
|
59
|
+
form {
|
|
60
|
+
code
|
|
61
|
+
data
|
|
62
|
+
style
|
|
63
|
+
template
|
|
64
|
+
}
|
|
65
|
+
presentation {
|
|
66
|
+
code
|
|
67
|
+
data
|
|
68
|
+
style
|
|
69
|
+
template
|
|
70
|
+
}
|
|
71
|
+
tagIds
|
|
72
|
+
}
|
|
73
|
+
reference {
|
|
74
|
+
id
|
|
75
|
+
type
|
|
76
|
+
}
|
|
77
|
+
template {
|
|
78
|
+
category
|
|
79
|
+
description
|
|
80
|
+
help
|
|
81
|
+
icon
|
|
82
|
+
iconUrl
|
|
83
|
+
implicitly
|
|
84
|
+
label
|
|
85
|
+
publishedBy
|
|
86
|
+
tags
|
|
87
|
+
type
|
|
88
|
+
version
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
last
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
`;
|
|
96
|
+
|
|
49
97
|
export const QUERY_GET = `query get($entity: EntityType!, $params: GetInput!) {
|
|
50
98
|
get(entity: $entity, params: $params) {
|
|
51
99
|
... on Card {
|
|
@@ -91,6 +139,51 @@ export const QUERY_GET = `query get($entity: EntityType!, $params: GetInput!) {
|
|
|
91
139
|
}
|
|
92
140
|
`;
|
|
93
141
|
|
|
142
|
+
export const QUERY_GET_CROSSACCOUNT = `query getCrossAccount($entity: EntityType!, $params: GetInput!, $accountId: String!) {
|
|
143
|
+
getCrossAccount(entity: $entity, params: $params, accountId: $accountId) {
|
|
144
|
+
... on Card {
|
|
145
|
+
id
|
|
146
|
+
schemaVersion
|
|
147
|
+
dateCreated
|
|
148
|
+
dateModified
|
|
149
|
+
data {
|
|
150
|
+
data
|
|
151
|
+
form {
|
|
152
|
+
code
|
|
153
|
+
data
|
|
154
|
+
style
|
|
155
|
+
template
|
|
156
|
+
}
|
|
157
|
+
presentation {
|
|
158
|
+
code
|
|
159
|
+
data
|
|
160
|
+
style
|
|
161
|
+
template
|
|
162
|
+
}
|
|
163
|
+
tagIds
|
|
164
|
+
}
|
|
165
|
+
reference {
|
|
166
|
+
id
|
|
167
|
+
type
|
|
168
|
+
}
|
|
169
|
+
template {
|
|
170
|
+
category
|
|
171
|
+
description
|
|
172
|
+
help
|
|
173
|
+
icon
|
|
174
|
+
iconUrl
|
|
175
|
+
implicitly
|
|
176
|
+
label
|
|
177
|
+
publishedBy
|
|
178
|
+
tags
|
|
179
|
+
type
|
|
180
|
+
version
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
`;
|
|
186
|
+
|
|
94
187
|
export const QUERY_CREATE = `mutation create($entity: EntityType!, $data: CreateInput!) {
|
|
95
188
|
create(entity: $entity, data: $data) {
|
|
96
189
|
... on Card {
|
|
@@ -136,6 +229,51 @@ export const QUERY_CREATE = `mutation create($entity: EntityType!, $data: Create
|
|
|
136
229
|
}
|
|
137
230
|
`;
|
|
138
231
|
|
|
232
|
+
export const QUERY_CREATE_CROSSACCOUNT = `mutation createCrossAccount($entity: EntityType!, $data: CreateInput!, $accountId: String!) {
|
|
233
|
+
createCrossAccount(entity: $entity, data: $data, accountId: $accountId) {
|
|
234
|
+
... on Card {
|
|
235
|
+
id
|
|
236
|
+
schemaVersion
|
|
237
|
+
dateCreated
|
|
238
|
+
dateModified
|
|
239
|
+
data {
|
|
240
|
+
data
|
|
241
|
+
form {
|
|
242
|
+
code
|
|
243
|
+
data
|
|
244
|
+
style
|
|
245
|
+
template
|
|
246
|
+
}
|
|
247
|
+
presentation {
|
|
248
|
+
code
|
|
249
|
+
data
|
|
250
|
+
style
|
|
251
|
+
template
|
|
252
|
+
}
|
|
253
|
+
tagIds
|
|
254
|
+
}
|
|
255
|
+
reference {
|
|
256
|
+
id
|
|
257
|
+
type
|
|
258
|
+
}
|
|
259
|
+
template {
|
|
260
|
+
category
|
|
261
|
+
description
|
|
262
|
+
help
|
|
263
|
+
icon
|
|
264
|
+
iconUrl
|
|
265
|
+
implicitly
|
|
266
|
+
label
|
|
267
|
+
publishedBy
|
|
268
|
+
tags
|
|
269
|
+
type
|
|
270
|
+
version
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
`;
|
|
276
|
+
|
|
139
277
|
export const QUERY_UPDATE = `mutation update($entity: EntityType!, $data: UpdateInput!) {
|
|
140
278
|
update(entity: $entity, data: $data) {
|
|
141
279
|
... on Card {
|
|
@@ -180,6 +318,50 @@ export const QUERY_UPDATE = `mutation update($entity: EntityType!, $data: Update
|
|
|
180
318
|
}
|
|
181
319
|
}
|
|
182
320
|
`;
|
|
321
|
+
export const QUERY_UPDATE_CROSSACCOUNT = `mutation updateCrossAccount($entity: EntityType!, $data: UpdateInput!, $accountId: String!) {
|
|
322
|
+
updateCrossAccount(entity: $entity, data: $data, accountId: $accountId) {
|
|
323
|
+
... on Card {
|
|
324
|
+
id
|
|
325
|
+
schemaVersion
|
|
326
|
+
dateCreated
|
|
327
|
+
dateModified
|
|
328
|
+
data {
|
|
329
|
+
data
|
|
330
|
+
form {
|
|
331
|
+
code
|
|
332
|
+
data
|
|
333
|
+
style
|
|
334
|
+
template
|
|
335
|
+
}
|
|
336
|
+
presentation {
|
|
337
|
+
code
|
|
338
|
+
data
|
|
339
|
+
style
|
|
340
|
+
template
|
|
341
|
+
}
|
|
342
|
+
tagIds
|
|
343
|
+
}
|
|
344
|
+
reference {
|
|
345
|
+
id
|
|
346
|
+
type
|
|
347
|
+
}
|
|
348
|
+
template {
|
|
349
|
+
category
|
|
350
|
+
description
|
|
351
|
+
help
|
|
352
|
+
icon
|
|
353
|
+
iconUrl
|
|
354
|
+
implicitly
|
|
355
|
+
label
|
|
356
|
+
publishedBy
|
|
357
|
+
tags
|
|
358
|
+
type
|
|
359
|
+
version
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
`;
|
|
183
365
|
|
|
184
366
|
export const QUERY_DELETE = `mutation deleteTemporarily($entity: EntityType!, $data: DeleteInput!) {
|
|
185
367
|
deleteTemporarily(entity: $entity, data: $data) {
|
package/src/types.ts
CHANGED