@or-sdk/cards 0.11.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 +215 -0
- package/dist/cjs/Cards.js.map +1 -0
- package/dist/cjs/constants.js +10 -0
- package/dist/cjs/constants.js.map +1 -0
- package/dist/cjs/index.js +17 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/types.js +3 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/esm/Cards.js +139 -0
- package/dist/esm/Cards.js.map +1 -0
- package/dist/esm/constants.js +188 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/types/Cards.d.ts +14 -0
- package/dist/types/constants.d.ts +6 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/types.d.ts +41 -0
- package/package.json +30 -0
- package/src/Cards.ts +194 -0
- package/src/constants.ts +192 -0
- package/src/index.ts +2 -0
- package/src/types.ts +50 -0
- package/tsconfig.esm.json +9 -0
- package/tsconfig.json +7 -0
- package/tsconfig.types.json +9 -0
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.Cards = void 0;
|
|
40
|
+
var data_hub_1 = require("@or-sdk/data-hub");
|
|
41
|
+
var constants_1 = require("./constants");
|
|
42
|
+
var Cards = (function () {
|
|
43
|
+
function Cards(params) {
|
|
44
|
+
var token = params.token, discoveryUrl = params.discoveryUrl;
|
|
45
|
+
this.dataHub = new data_hub_1.DataHub({
|
|
46
|
+
token: token,
|
|
47
|
+
discoveryUrl: discoveryUrl,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
Cards.prototype.init = function () {
|
|
51
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
52
|
+
return __generator(this, function (_a) {
|
|
53
|
+
switch (_a.label) {
|
|
54
|
+
case 0: return [4, this.dataHub.init()];
|
|
55
|
+
case 1:
|
|
56
|
+
_a.sent();
|
|
57
|
+
return [2];
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
Cards.prototype.listCards = function () {
|
|
63
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
64
|
+
var variables, data;
|
|
65
|
+
return __generator(this, function (_a) {
|
|
66
|
+
variables = {
|
|
67
|
+
entity: constants_1.ENTITY_NAME,
|
|
68
|
+
params: {
|
|
69
|
+
queryParams: {},
|
|
70
|
+
includeDeleted: false,
|
|
71
|
+
includeExisting: true,
|
|
72
|
+
limit: 30,
|
|
73
|
+
},
|
|
74
|
+
sandbox: false,
|
|
75
|
+
};
|
|
76
|
+
data = {
|
|
77
|
+
operationName: 'list',
|
|
78
|
+
query: constants_1.QUERY_LIST,
|
|
79
|
+
variables: variables,
|
|
80
|
+
};
|
|
81
|
+
return [2, this.dataHub.getFullList('POST', '/graphql', data)];
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
Cards.prototype.getCard = function (id) {
|
|
86
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
87
|
+
var variables, data, card;
|
|
88
|
+
return __generator(this, function (_a) {
|
|
89
|
+
switch (_a.label) {
|
|
90
|
+
case 0:
|
|
91
|
+
variables = {
|
|
92
|
+
entity: constants_1.ENTITY_NAME,
|
|
93
|
+
params: {
|
|
94
|
+
id: id,
|
|
95
|
+
includeDeleted: false,
|
|
96
|
+
includeExisting: true,
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
data = {
|
|
100
|
+
operationName: 'get',
|
|
101
|
+
query: constants_1.QUERY_GET,
|
|
102
|
+
variables: variables,
|
|
103
|
+
};
|
|
104
|
+
return [4, this.dataHub.makeRequest({
|
|
105
|
+
method: 'POST',
|
|
106
|
+
route: '/graphql',
|
|
107
|
+
data: data,
|
|
108
|
+
})];
|
|
109
|
+
case 1:
|
|
110
|
+
card = (_a.sent()).data.get;
|
|
111
|
+
return [2, card];
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
Cards.prototype.saveCard = function (source) {
|
|
117
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
118
|
+
return __generator(this, function (_a) {
|
|
119
|
+
return [2, source.id ? this.updateCard(source) : this.createCard(source)];
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
};
|
|
123
|
+
Cards.prototype.createCard = function (source) {
|
|
124
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
125
|
+
var variables, data, card;
|
|
126
|
+
return __generator(this, function (_a) {
|
|
127
|
+
switch (_a.label) {
|
|
128
|
+
case 0:
|
|
129
|
+
variables = {
|
|
130
|
+
entity: constants_1.ENTITY_NAME,
|
|
131
|
+
data: {
|
|
132
|
+
body: source,
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
data = {
|
|
136
|
+
operationName: 'create',
|
|
137
|
+
query: constants_1.QUERY_CREATE,
|
|
138
|
+
variables: variables,
|
|
139
|
+
};
|
|
140
|
+
return [4, this.dataHub.makeRequest({
|
|
141
|
+
method: 'POST',
|
|
142
|
+
route: '/graphql',
|
|
143
|
+
data: data,
|
|
144
|
+
})];
|
|
145
|
+
case 1:
|
|
146
|
+
card = (_a.sent()).data.create;
|
|
147
|
+
return [2, card];
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
Cards.prototype.updateCard = function (source) {
|
|
153
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
154
|
+
var variables, data, card;
|
|
155
|
+
return __generator(this, function (_a) {
|
|
156
|
+
switch (_a.label) {
|
|
157
|
+
case 0:
|
|
158
|
+
variables = {
|
|
159
|
+
entity: constants_1.ENTITY_NAME,
|
|
160
|
+
data: {
|
|
161
|
+
id: source.id,
|
|
162
|
+
body: source,
|
|
163
|
+
},
|
|
164
|
+
};
|
|
165
|
+
data = {
|
|
166
|
+
operationName: 'update',
|
|
167
|
+
query: source.id ? constants_1.QUERY_UPDATE : constants_1.QUERY_CREATE,
|
|
168
|
+
variables: variables,
|
|
169
|
+
};
|
|
170
|
+
return [4, this.dataHub.makeRequest({
|
|
171
|
+
method: 'POST',
|
|
172
|
+
route: '/graphql',
|
|
173
|
+
data: data,
|
|
174
|
+
})];
|
|
175
|
+
case 1:
|
|
176
|
+
card = (_a.sent()).data.update;
|
|
177
|
+
return [2, card];
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
};
|
|
182
|
+
Cards.prototype.deleteCard = function (cardId) {
|
|
183
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
184
|
+
var variables, data, requestId;
|
|
185
|
+
return __generator(this, function (_a) {
|
|
186
|
+
switch (_a.label) {
|
|
187
|
+
case 0:
|
|
188
|
+
variables = {
|
|
189
|
+
entity: constants_1.ENTITY_NAME,
|
|
190
|
+
data: {
|
|
191
|
+
id: cardId,
|
|
192
|
+
subscribe: true,
|
|
193
|
+
},
|
|
194
|
+
};
|
|
195
|
+
data = {
|
|
196
|
+
operationName: 'deleteTemporarily',
|
|
197
|
+
query: constants_1.QUERY_DELETE,
|
|
198
|
+
variables: variables,
|
|
199
|
+
};
|
|
200
|
+
return [4, this.dataHub.makeRequest({
|
|
201
|
+
method: 'POST',
|
|
202
|
+
route: '/graphql',
|
|
203
|
+
data: data,
|
|
204
|
+
})];
|
|
205
|
+
case 1:
|
|
206
|
+
requestId = (_a.sent()).data.deleteTemporarily.requestId;
|
|
207
|
+
return [2, this.dataHub.subscribe(requestId)];
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
};
|
|
212
|
+
return Cards;
|
|
213
|
+
}());
|
|
214
|
+
exports.Cards = Cards;
|
|
215
|
+
//# sourceMappingURL=Cards.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Cards.js","sourceRoot":"","sources":["../../src/Cards.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,6CAA2F;AAE3F,yCAA2G;AAS3G;IAUE,eAAY,MAAmB;QACrB,IAAA,KAAK,GAAmB,MAAM,MAAzB,EAAE,YAAY,GAAK,MAAM,aAAX,CAAY;QAEvC,IAAI,CAAC,OAAO,GAAG,IAAI,kBAAO,CAAC;YACzB,KAAK,OAAA;YACL,YAAY,cAAA;SACb,CAAC,CAAC;IACL,CAAC;IAEK,oBAAI,GAAV;;;;4BACE,WAAM,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAA;;wBAAzB,SAAyB,CAAC;;;;;KAC3B;IAQY,yBAAS,GAAtB;;;;gBACQ,SAAS,GAAG;oBAChB,MAAM,EAAE,uBAAW;oBACnB,MAAM,EAAE;wBACN,WAAW,EAAE,EAAE;wBACf,cAAc,EAAE,KAAK;wBACrB,eAAe,EAAE,IAAI;wBACrB,KAAK,EAAE,EAAE;qBACV;oBACD,OAAO,EAAE,KAAK;iBACf,CAAC;gBAEI,IAAI,GAAG;oBACX,aAAa,EAAE,MAAM;oBACrB,KAAK,EAAE,sBAAU;oBACjB,SAAS,WAAA;iBACV,CAAC;gBAEF,WAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CA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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;
|
|
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_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";
|
|
6
|
+
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";
|
|
7
|
+
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";
|
|
8
|
+
exports.QUERY_DELETE = "mutation deleteTemporarily($entity: EntityType!, $data: DeleteInput!) {\n deleteTemporarily(entity: $entity, data: $data) {\n ... on AsyncRequest {\n requestId\n }\n }\n}";
|
|
9
|
+
exports.ENTITY_NAME = 'CARD';
|
|
10
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.Cards = void 0;
|
|
14
|
+
var Cards_1 = require("./Cards");
|
|
15
|
+
Object.defineProperty(exports, "Cards", { enumerable: true, get: function () { return Cards_1.Cards; } });
|
|
16
|
+
__exportStar(require("./types"), exports);
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,iCAAgC;AAAvB,8FAAA,KAAK,OAAA;AACd,0CAAwB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,139 @@
|
|
|
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 { DataHub } from '@or-sdk/data-hub';
|
|
11
|
+
import { ENTITY_NAME, QUERY_LIST, QUERY_GET, QUERY_CREATE, QUERY_UPDATE, QUERY_DELETE } from './constants';
|
|
12
|
+
export class Cards {
|
|
13
|
+
constructor(params) {
|
|
14
|
+
const { token, discoveryUrl } = params;
|
|
15
|
+
this.dataHub = new DataHub({
|
|
16
|
+
token,
|
|
17
|
+
discoveryUrl,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
init() {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
yield this.dataHub.init();
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
listCards() {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
const variables = {
|
|
28
|
+
entity: ENTITY_NAME,
|
|
29
|
+
params: {
|
|
30
|
+
queryParams: {},
|
|
31
|
+
includeDeleted: false,
|
|
32
|
+
includeExisting: true,
|
|
33
|
+
limit: 30,
|
|
34
|
+
},
|
|
35
|
+
sandbox: false,
|
|
36
|
+
};
|
|
37
|
+
const data = {
|
|
38
|
+
operationName: 'list',
|
|
39
|
+
query: QUERY_LIST,
|
|
40
|
+
variables,
|
|
41
|
+
};
|
|
42
|
+
return this.dataHub.getFullList('POST', '/graphql', data);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
getCard(id) {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
const variables = {
|
|
48
|
+
entity: ENTITY_NAME,
|
|
49
|
+
params: {
|
|
50
|
+
id,
|
|
51
|
+
includeDeleted: false,
|
|
52
|
+
includeExisting: true,
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
const data = {
|
|
56
|
+
operationName: 'get',
|
|
57
|
+
query: QUERY_GET,
|
|
58
|
+
variables,
|
|
59
|
+
};
|
|
60
|
+
const { data: { get: card } } = yield this.dataHub.makeRequest({
|
|
61
|
+
method: 'POST',
|
|
62
|
+
route: '/graphql',
|
|
63
|
+
data,
|
|
64
|
+
});
|
|
65
|
+
return card;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
saveCard(source) {
|
|
69
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
+
return source.id ? this.updateCard(source) : this.createCard(source);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
createCard(source) {
|
|
74
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
const variables = {
|
|
76
|
+
entity: ENTITY_NAME,
|
|
77
|
+
data: {
|
|
78
|
+
body: source,
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
const data = {
|
|
82
|
+
operationName: 'create',
|
|
83
|
+
query: QUERY_CREATE,
|
|
84
|
+
variables,
|
|
85
|
+
};
|
|
86
|
+
const { data: { create: card } } = yield this.dataHub.makeRequest({
|
|
87
|
+
method: 'POST',
|
|
88
|
+
route: '/graphql',
|
|
89
|
+
data,
|
|
90
|
+
});
|
|
91
|
+
return card;
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
updateCard(source) {
|
|
95
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
96
|
+
const variables = {
|
|
97
|
+
entity: ENTITY_NAME,
|
|
98
|
+
data: {
|
|
99
|
+
id: source.id,
|
|
100
|
+
body: source,
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
const data = {
|
|
104
|
+
operationName: 'update',
|
|
105
|
+
query: source.id ? QUERY_UPDATE : QUERY_CREATE,
|
|
106
|
+
variables,
|
|
107
|
+
};
|
|
108
|
+
const { data: { update: card } } = yield this.dataHub.makeRequest({
|
|
109
|
+
method: 'POST',
|
|
110
|
+
route: '/graphql',
|
|
111
|
+
data,
|
|
112
|
+
});
|
|
113
|
+
return card;
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
deleteCard(cardId) {
|
|
117
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
118
|
+
const variables = {
|
|
119
|
+
entity: ENTITY_NAME,
|
|
120
|
+
data: {
|
|
121
|
+
id: cardId,
|
|
122
|
+
subscribe: true,
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
const data = {
|
|
126
|
+
operationName: 'deleteTemporarily',
|
|
127
|
+
query: QUERY_DELETE,
|
|
128
|
+
variables,
|
|
129
|
+
};
|
|
130
|
+
const { data: { deleteTemporarily: { requestId } } } = yield this.dataHub.makeRequest({
|
|
131
|
+
method: 'POST',
|
|
132
|
+
route: '/graphql',
|
|
133
|
+
data,
|
|
134
|
+
});
|
|
135
|
+
return this.dataHub.subscribe(requestId);
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=Cards.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"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EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,WAAW,CAAkC;gBACjG,MAAM,EAAE,MAAM;gBACd,KAAK,EAAE,UAAU;gBACjB,IAAI;aACL,CAAC,CAAC;YAEH,OAAO,IAAI,CAAC;QACd,CAAC;KAAA;IAQY,UAAU,CAAC,MAAc;;YACpC,MAAM,SAAS,GAAG;gBAChB,MAAM,EAAE,WAAW;gBACnB,IAAI,EAAE;oBACJ,EAAE,EAAE,MAAM;oBACV,SAAS,EAAE,IAAI;iBAChB;aACF,CAAC;YAEF,MAAM,IAAI,GAAG;gBACX,aAAa,EAAE,mBAAmB;gBAClC,KAAK,EAAE,YAAY;gBACnB,SAAS;aACV,CAAC;YAEF,MAAM,EAAE,IAAI,EAAE,EAAE,iBAAiB,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,WAAW,CAA6C;gBAChI,MAAM,EAAE,MAAM;gBACd,KAAK,EAAE,UAAU;gBACjB,IAAI;aACL,CAAC,CAAC;YAEH,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC3C,CAAC;KAAA;CACF"}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
export const QUERY_LIST = `query list($entity: EntityType!, $params: ListInput!, $sandbox: Boolean) {
|
|
2
|
+
list(entity: $entity, params: $params, sandbox: $sandbox) {
|
|
3
|
+
records {
|
|
4
|
+
... on Card {
|
|
5
|
+
id
|
|
6
|
+
schemaVersion
|
|
7
|
+
dateCreated
|
|
8
|
+
dateModified
|
|
9
|
+
data {
|
|
10
|
+
data
|
|
11
|
+
form {
|
|
12
|
+
code
|
|
13
|
+
data
|
|
14
|
+
style
|
|
15
|
+
template
|
|
16
|
+
}
|
|
17
|
+
presentation {
|
|
18
|
+
code
|
|
19
|
+
data
|
|
20
|
+
style
|
|
21
|
+
template
|
|
22
|
+
}
|
|
23
|
+
tagIds
|
|
24
|
+
}
|
|
25
|
+
reference {
|
|
26
|
+
id
|
|
27
|
+
type
|
|
28
|
+
}
|
|
29
|
+
template {
|
|
30
|
+
category
|
|
31
|
+
description
|
|
32
|
+
help
|
|
33
|
+
icon
|
|
34
|
+
iconUrl
|
|
35
|
+
implicitly
|
|
36
|
+
label
|
|
37
|
+
publishedBy
|
|
38
|
+
tags
|
|
39
|
+
type
|
|
40
|
+
version
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
last
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
`;
|
|
48
|
+
export const QUERY_GET = `query get($entity: EntityType!, $params: GetInput!) {
|
|
49
|
+
get(entity: $entity, params: $params) {
|
|
50
|
+
... on Card {
|
|
51
|
+
id
|
|
52
|
+
schemaVersion
|
|
53
|
+
dateCreated
|
|
54
|
+
dateModified
|
|
55
|
+
data {
|
|
56
|
+
data
|
|
57
|
+
form {
|
|
58
|
+
code
|
|
59
|
+
data
|
|
60
|
+
style
|
|
61
|
+
template
|
|
62
|
+
}
|
|
63
|
+
presentation {
|
|
64
|
+
code
|
|
65
|
+
data
|
|
66
|
+
style
|
|
67
|
+
template
|
|
68
|
+
}
|
|
69
|
+
tagIds
|
|
70
|
+
}
|
|
71
|
+
reference {
|
|
72
|
+
id
|
|
73
|
+
type
|
|
74
|
+
}
|
|
75
|
+
template {
|
|
76
|
+
category
|
|
77
|
+
description
|
|
78
|
+
help
|
|
79
|
+
icon
|
|
80
|
+
iconUrl
|
|
81
|
+
implicitly
|
|
82
|
+
label
|
|
83
|
+
publishedBy
|
|
84
|
+
tags
|
|
85
|
+
type
|
|
86
|
+
version
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
`;
|
|
92
|
+
export const QUERY_CREATE = `mutation create($entity: EntityType!, $data: CreateInput!) {
|
|
93
|
+
create(entity: $entity, data: $data) {
|
|
94
|
+
... on Card {
|
|
95
|
+
id
|
|
96
|
+
schemaVersion
|
|
97
|
+
dateCreated
|
|
98
|
+
dateModified
|
|
99
|
+
data {
|
|
100
|
+
data
|
|
101
|
+
form {
|
|
102
|
+
code
|
|
103
|
+
data
|
|
104
|
+
style
|
|
105
|
+
template
|
|
106
|
+
}
|
|
107
|
+
presentation {
|
|
108
|
+
code
|
|
109
|
+
data
|
|
110
|
+
style
|
|
111
|
+
template
|
|
112
|
+
}
|
|
113
|
+
tagIds
|
|
114
|
+
}
|
|
115
|
+
reference {
|
|
116
|
+
id
|
|
117
|
+
type
|
|
118
|
+
}
|
|
119
|
+
template {
|
|
120
|
+
category
|
|
121
|
+
description
|
|
122
|
+
help
|
|
123
|
+
icon
|
|
124
|
+
iconUrl
|
|
125
|
+
implicitly
|
|
126
|
+
label
|
|
127
|
+
publishedBy
|
|
128
|
+
tags
|
|
129
|
+
type
|
|
130
|
+
version
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
`;
|
|
136
|
+
export const QUERY_UPDATE = `mutation update($entity: EntityType!, $data: UpdateInput!) {
|
|
137
|
+
update(entity: $entity, data: $data) {
|
|
138
|
+
... on Card {
|
|
139
|
+
id
|
|
140
|
+
schemaVersion
|
|
141
|
+
dateCreated
|
|
142
|
+
dateModified
|
|
143
|
+
data {
|
|
144
|
+
data
|
|
145
|
+
form {
|
|
146
|
+
code
|
|
147
|
+
data
|
|
148
|
+
style
|
|
149
|
+
template
|
|
150
|
+
}
|
|
151
|
+
presentation {
|
|
152
|
+
code
|
|
153
|
+
data
|
|
154
|
+
style
|
|
155
|
+
template
|
|
156
|
+
}
|
|
157
|
+
tagIds
|
|
158
|
+
}
|
|
159
|
+
reference {
|
|
160
|
+
id
|
|
161
|
+
type
|
|
162
|
+
}
|
|
163
|
+
template {
|
|
164
|
+
category
|
|
165
|
+
description
|
|
166
|
+
help
|
|
167
|
+
icon
|
|
168
|
+
iconUrl
|
|
169
|
+
implicitly
|
|
170
|
+
label
|
|
171
|
+
publishedBy
|
|
172
|
+
tags
|
|
173
|
+
type
|
|
174
|
+
version
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
`;
|
|
180
|
+
export const QUERY_DELETE = `mutation deleteTemporarily($entity: EntityType!, $data: DeleteInput!) {
|
|
181
|
+
deleteTemporarily(entity: $entity, data: $data) {
|
|
182
|
+
... on AsyncRequest {
|
|
183
|
+
requestId
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}`;
|
|
187
|
+
export const ENTITY_NAME = 'CARD';
|
|
188
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { List } from '@or-sdk/base';
|
|
2
|
+
import { GraphqlResponseCheckExecution } from '@or-sdk/data-hub';
|
|
3
|
+
import { CardsConfig, Card } from './types';
|
|
4
|
+
export declare class Cards {
|
|
5
|
+
private readonly dataHub;
|
|
6
|
+
constructor(params: CardsConfig);
|
|
7
|
+
init(): Promise<void>;
|
|
8
|
+
listCards(): Promise<List<Card>>;
|
|
9
|
+
getCard(id: string): Promise<Card>;
|
|
10
|
+
saveCard(source: Card): Promise<Card>;
|
|
11
|
+
createCard(source: Card): Promise<Card>;
|
|
12
|
+
updateCard(source: Card): Promise<Card>;
|
|
13
|
+
deleteCard(cardId: string): Promise<GraphqlResponseCheckExecution>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
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_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";
|
|
3
|
+
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";
|
|
4
|
+
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";
|
|
5
|
+
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
|
+
export declare const ENTITY_NAME = "CARD";
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Token } from '@or-sdk/base';
|
|
2
|
+
export declare type CardsConfig = {
|
|
3
|
+
token: Token;
|
|
4
|
+
discoveryUrl: string;
|
|
5
|
+
};
|
|
6
|
+
export declare type Card = {
|
|
7
|
+
id?: string;
|
|
8
|
+
schemaVersion?: number;
|
|
9
|
+
dateCreated?: number;
|
|
10
|
+
dateModified?: number;
|
|
11
|
+
data: {
|
|
12
|
+
presentation: {
|
|
13
|
+
template: string;
|
|
14
|
+
code: string;
|
|
15
|
+
style: string;
|
|
16
|
+
data: {
|
|
17
|
+
[key: string]: unknown;
|
|
18
|
+
} | null;
|
|
19
|
+
};
|
|
20
|
+
form: {
|
|
21
|
+
template: string;
|
|
22
|
+
code: string;
|
|
23
|
+
style: string;
|
|
24
|
+
data: {
|
|
25
|
+
[key: string]: unknown;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
data: {
|
|
29
|
+
description: string;
|
|
30
|
+
height: string;
|
|
31
|
+
heightOption: string;
|
|
32
|
+
label: string;
|
|
33
|
+
viewClasses: string[];
|
|
34
|
+
width: string;
|
|
35
|
+
widthOption: string;
|
|
36
|
+
};
|
|
37
|
+
tagIds?: string[] | null;
|
|
38
|
+
};
|
|
39
|
+
reference?: string | null;
|
|
40
|
+
template?: string | null;
|
|
41
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.11.0",
|
|
3
|
+
"name": "@or-sdk/cards",
|
|
4
|
+
"main": "dist/cjs/index.js",
|
|
5
|
+
"module": "dist/esm/index.js",
|
|
6
|
+
"types": "dist/types/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "npm run clean && concurrently \"npm run build:cjs\" \"npm run build:esm\" \"npm run build:types\"",
|
|
9
|
+
"build:watch": "concurrently -r --hide 1,2 \"npm run build:watch:cjs\" \"npm run build:watch:esm\" \"npm run build:watch:types\"",
|
|
10
|
+
"build:cjs": "tsc --project tsconfig.json",
|
|
11
|
+
"build:watch:cjs": "tsc --project tsconfig.json -w",
|
|
12
|
+
"build:esm": "tsc --project tsconfig.esm.json",
|
|
13
|
+
"build:watch:esm": "tsc --project tsconfig.esm.json -w",
|
|
14
|
+
"build:types": "tsc --project tsconfig.types.json",
|
|
15
|
+
"build:watch:types": "tsc --project tsconfig.types.json -w",
|
|
16
|
+
"clean": "rm -rf ./dist"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"concurrently": "^6.4.0",
|
|
20
|
+
"typescript": "^4.4.4"
|
|
21
|
+
},
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@or-sdk/base": "^0.11.0",
|
|
27
|
+
"@or-sdk/data-hub": "^0.11.0"
|
|
28
|
+
},
|
|
29
|
+
"gitHead": "69c6cabbf681fe0fb9616058d58e89b0526e8f77"
|
|
30
|
+
}
|
package/src/Cards.ts
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { List } from '@or-sdk/base';
|
|
2
|
+
import { DataHub, GraphqlResponse, GraphqlResponseCheckExecution } from '@or-sdk/data-hub';
|
|
3
|
+
import { CardsConfig, Card } from './types';
|
|
4
|
+
import { ENTITY_NAME, QUERY_LIST, QUERY_GET, QUERY_CREATE, QUERY_UPDATE, QUERY_DELETE } from './constants';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* OneReach Cards service client
|
|
8
|
+
* ## Installation:
|
|
9
|
+
* ```
|
|
10
|
+
* $ npm i @or-sdk/cards
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export class Cards {
|
|
14
|
+
private readonly dataHub: DataHub;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import { Cards } from '@or-sdk/cards'
|
|
19
|
+
* const cards = new Cards({token: 'my-account-token-string', discoveryUrl: 'http://example.cards/endpoint'});
|
|
20
|
+
* await cards.init();
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
constructor(params: CardsConfig) {
|
|
24
|
+
const { token, discoveryUrl } = params;
|
|
25
|
+
|
|
26
|
+
this.dataHub = new DataHub({
|
|
27
|
+
token,
|
|
28
|
+
discoveryUrl,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async init() {
|
|
33
|
+
await this.dataHub.init();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* List cards
|
|
38
|
+
* ```typescript
|
|
39
|
+
* const cardList = await cards.listCards();
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
public async listCards(): Promise<List<Card>> {
|
|
43
|
+
const variables = {
|
|
44
|
+
entity: ENTITY_NAME,
|
|
45
|
+
params: {
|
|
46
|
+
queryParams: {},
|
|
47
|
+
includeDeleted: false,
|
|
48
|
+
includeExisting: true,
|
|
49
|
+
limit: 30,
|
|
50
|
+
},
|
|
51
|
+
sandbox: false,
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const data = {
|
|
55
|
+
operationName: 'list',
|
|
56
|
+
query: QUERY_LIST,
|
|
57
|
+
variables,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
return this.dataHub.getFullList<Card>('POST', '/graphql', data);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Get card
|
|
65
|
+
* ```typescript
|
|
66
|
+
* const card = await cards.getCard('card-id');
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
public async getCard(id: string): Promise<Card> {
|
|
70
|
+
const variables = {
|
|
71
|
+
entity: ENTITY_NAME,
|
|
72
|
+
params: {
|
|
73
|
+
id,
|
|
74
|
+
includeDeleted: false,
|
|
75
|
+
includeExisting: true,
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const data = {
|
|
80
|
+
operationName: 'get',
|
|
81
|
+
query: QUERY_GET,
|
|
82
|
+
variables,
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const { data: { get: card } } = await this.dataHub.makeRequest<GraphqlResponse<'get', Card>>({
|
|
86
|
+
method: 'POST',
|
|
87
|
+
route: '/graphql',
|
|
88
|
+
data,
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
return card;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Save card
|
|
96
|
+
*
|
|
97
|
+
* If source contains existing id - existing card be updated
|
|
98
|
+
* ```typescript
|
|
99
|
+
* const savedCard = await cards.saveCard(cardSource);
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
public async saveCard(source: Card): Promise<Card> {
|
|
103
|
+
return source.id ? this.updateCard(source) : this.createCard(source);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Create card
|
|
108
|
+
* ```typescript
|
|
109
|
+
* const card = await cards.createCard(cardSource);
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
public async createCard(source: Card): Promise<Card> {
|
|
113
|
+
const variables = {
|
|
114
|
+
entity: ENTITY_NAME,
|
|
115
|
+
data: {
|
|
116
|
+
body: source,
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const data = {
|
|
121
|
+
operationName: 'create',
|
|
122
|
+
query: QUERY_CREATE,
|
|
123
|
+
variables,
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
const { data: { create: card } } = await this.dataHub.makeRequest<GraphqlResponse<'create', Card>>({
|
|
127
|
+
method: 'POST',
|
|
128
|
+
route: '/graphql',
|
|
129
|
+
data,
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
return card;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Update card
|
|
137
|
+
* ```typescript
|
|
138
|
+
* const card = await cards.updateCard(cardSource);
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
public async updateCard(source: Card): Promise<Card> {
|
|
142
|
+
const variables = {
|
|
143
|
+
entity: ENTITY_NAME,
|
|
144
|
+
data: {
|
|
145
|
+
id: source.id,
|
|
146
|
+
body: source,
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
const data = {
|
|
151
|
+
operationName: 'update',
|
|
152
|
+
query: source.id ? QUERY_UPDATE : QUERY_CREATE,
|
|
153
|
+
variables,
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
const { data: { update: card } } = await this.dataHub.makeRequest<GraphqlResponse<'update', Card>>({
|
|
157
|
+
method: 'POST',
|
|
158
|
+
route: '/graphql',
|
|
159
|
+
data,
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
return card;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Delete card
|
|
167
|
+
* ```typescript
|
|
168
|
+
* await cards.deleteCard('card-id');
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
public async deleteCard(cardId: string): Promise<GraphqlResponseCheckExecution> {
|
|
172
|
+
const variables = {
|
|
173
|
+
entity: ENTITY_NAME,
|
|
174
|
+
data: {
|
|
175
|
+
id: cardId,
|
|
176
|
+
subscribe: true,
|
|
177
|
+
},
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const data = {
|
|
181
|
+
operationName: 'deleteTemporarily',
|
|
182
|
+
query: QUERY_DELETE,
|
|
183
|
+
variables,
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
const { data: { deleteTemporarily: { requestId } } } = await this.dataHub.makeRequest<GraphqlResponse<'deleteTemporarily', void>>({
|
|
187
|
+
method: 'POST',
|
|
188
|
+
route: '/graphql',
|
|
189
|
+
data,
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
return this.dataHub.subscribe(requestId);
|
|
193
|
+
}
|
|
194
|
+
}
|
package/src/constants.ts
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
export const QUERY_LIST = `query list($entity: EntityType!, $params: ListInput!, $sandbox: Boolean) {
|
|
2
|
+
list(entity: $entity, params: $params, sandbox: $sandbox) {
|
|
3
|
+
records {
|
|
4
|
+
... on Card {
|
|
5
|
+
id
|
|
6
|
+
schemaVersion
|
|
7
|
+
dateCreated
|
|
8
|
+
dateModified
|
|
9
|
+
data {
|
|
10
|
+
data
|
|
11
|
+
form {
|
|
12
|
+
code
|
|
13
|
+
data
|
|
14
|
+
style
|
|
15
|
+
template
|
|
16
|
+
}
|
|
17
|
+
presentation {
|
|
18
|
+
code
|
|
19
|
+
data
|
|
20
|
+
style
|
|
21
|
+
template
|
|
22
|
+
}
|
|
23
|
+
tagIds
|
|
24
|
+
}
|
|
25
|
+
reference {
|
|
26
|
+
id
|
|
27
|
+
type
|
|
28
|
+
}
|
|
29
|
+
template {
|
|
30
|
+
category
|
|
31
|
+
description
|
|
32
|
+
help
|
|
33
|
+
icon
|
|
34
|
+
iconUrl
|
|
35
|
+
implicitly
|
|
36
|
+
label
|
|
37
|
+
publishedBy
|
|
38
|
+
tags
|
|
39
|
+
type
|
|
40
|
+
version
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
last
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
`;
|
|
48
|
+
|
|
49
|
+
export const QUERY_GET = `query get($entity: EntityType!, $params: GetInput!) {
|
|
50
|
+
get(entity: $entity, params: $params) {
|
|
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
|
+
}
|
|
92
|
+
`;
|
|
93
|
+
|
|
94
|
+
export const QUERY_CREATE = `mutation create($entity: EntityType!, $data: CreateInput!) {
|
|
95
|
+
create(entity: $entity, data: $data) {
|
|
96
|
+
... on Card {
|
|
97
|
+
id
|
|
98
|
+
schemaVersion
|
|
99
|
+
dateCreated
|
|
100
|
+
dateModified
|
|
101
|
+
data {
|
|
102
|
+
data
|
|
103
|
+
form {
|
|
104
|
+
code
|
|
105
|
+
data
|
|
106
|
+
style
|
|
107
|
+
template
|
|
108
|
+
}
|
|
109
|
+
presentation {
|
|
110
|
+
code
|
|
111
|
+
data
|
|
112
|
+
style
|
|
113
|
+
template
|
|
114
|
+
}
|
|
115
|
+
tagIds
|
|
116
|
+
}
|
|
117
|
+
reference {
|
|
118
|
+
id
|
|
119
|
+
type
|
|
120
|
+
}
|
|
121
|
+
template {
|
|
122
|
+
category
|
|
123
|
+
description
|
|
124
|
+
help
|
|
125
|
+
icon
|
|
126
|
+
iconUrl
|
|
127
|
+
implicitly
|
|
128
|
+
label
|
|
129
|
+
publishedBy
|
|
130
|
+
tags
|
|
131
|
+
type
|
|
132
|
+
version
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
`;
|
|
138
|
+
|
|
139
|
+
export const QUERY_UPDATE = `mutation update($entity: EntityType!, $data: UpdateInput!) {
|
|
140
|
+
update(entity: $entity, data: $data) {
|
|
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
|
+
`;
|
|
183
|
+
|
|
184
|
+
export const QUERY_DELETE = `mutation deleteTemporarily($entity: EntityType!, $data: DeleteInput!) {
|
|
185
|
+
deleteTemporarily(entity: $entity, data: $data) {
|
|
186
|
+
... on AsyncRequest {
|
|
187
|
+
requestId
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}`;
|
|
191
|
+
|
|
192
|
+
export const ENTITY_NAME = 'CARD';
|
package/src/index.ts
ADDED
package/src/types.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Token } from '@or-sdk/base';
|
|
2
|
+
|
|
3
|
+
export type CardsConfig = {
|
|
4
|
+
/**
|
|
5
|
+
* token
|
|
6
|
+
*/
|
|
7
|
+
token: Token;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Url of OneReach service discovery api
|
|
11
|
+
*/
|
|
12
|
+
discoveryUrl: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type Card = {
|
|
16
|
+
id?: string;
|
|
17
|
+
schemaVersion?: number;
|
|
18
|
+
dateCreated?: number;
|
|
19
|
+
dateModified?: number;
|
|
20
|
+
data: {
|
|
21
|
+
presentation: {
|
|
22
|
+
template: string;
|
|
23
|
+
code: string;
|
|
24
|
+
style: string;
|
|
25
|
+
data: {
|
|
26
|
+
[key: string]: unknown;
|
|
27
|
+
} | null;
|
|
28
|
+
};
|
|
29
|
+
form: {
|
|
30
|
+
template: string;
|
|
31
|
+
code: string;
|
|
32
|
+
style: string;
|
|
33
|
+
data: {
|
|
34
|
+
[key: string]: unknown;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
data: {
|
|
38
|
+
description: string;
|
|
39
|
+
height: string;
|
|
40
|
+
heightOption: string;
|
|
41
|
+
label: string;
|
|
42
|
+
viewClasses: string[];
|
|
43
|
+
width: string;
|
|
44
|
+
widthOption: string;
|
|
45
|
+
};
|
|
46
|
+
tagIds?: string[] | null;
|
|
47
|
+
};
|
|
48
|
+
reference?: string | null;
|
|
49
|
+
template?: string | null;
|
|
50
|
+
};
|
package/tsconfig.json
ADDED