@or-sdk/views 0.7.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.
@@ -0,0 +1,226 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
+ return new (P || (P = Promise))(function (resolve, reject) {
20
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
24
+ });
25
+ };
26
+ var __generator = (this && this.__generator) || function (thisArg, body) {
27
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
+ function verb(n) { return function (v) { return step([n, v]); }; }
30
+ function step(op) {
31
+ if (f) throw new TypeError("Generator is already executing.");
32
+ while (_) try {
33
+ 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;
34
+ if (y = 0, t) op = [op[0] & 2, t.value];
35
+ switch (op[0]) {
36
+ case 0: case 1: t = op; break;
37
+ case 4: _.label++; return { value: op[1], done: false };
38
+ case 5: _.label++; y = op[1]; op = [0]; continue;
39
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
+ default:
41
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
+ if (t[2]) _.ops.pop();
46
+ _.trys.pop(); continue;
47
+ }
48
+ op = body.call(thisArg, _);
49
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
+ }
52
+ };
53
+ Object.defineProperty(exports, "__esModule", { value: true });
54
+ exports.Views = void 0;
55
+ var base_1 = require("@or-sdk/base");
56
+ var data_hub_1 = require("@or-sdk/data-hub");
57
+ var constants_1 = require("./constants");
58
+ var Views = (function (_super) {
59
+ __extends(Views, _super);
60
+ function Views(params) {
61
+ var _this = this;
62
+ var token = params.token, discoveryUrl = params.discoveryUrl;
63
+ _this = _super.call(this, {
64
+ token: token,
65
+ discoveryUrl: discoveryUrl,
66
+ serviceKey: constants_1.SERVICE_KEY,
67
+ requestAccountId: true,
68
+ }) || this;
69
+ _this.dataHub = new data_hub_1.DataHub({ token: token, discoveryUrl: discoveryUrl });
70
+ return _this;
71
+ }
72
+ Views.prototype.listViews = function () {
73
+ return __awaiter(this, void 0, void 0, function () {
74
+ var variables, data;
75
+ return __generator(this, function (_a) {
76
+ variables = {
77
+ entity: constants_1.ENTITY_NAME,
78
+ params: {
79
+ queryParams: {},
80
+ includeDeleted: false,
81
+ includeExisting: true,
82
+ limit: 30,
83
+ },
84
+ sandbox: false,
85
+ };
86
+ data = {
87
+ operationName: 'list',
88
+ query: constants_1.QUERY_LIST,
89
+ variables: variables,
90
+ };
91
+ return [2, this.dataHub.getFullList('POST', '/graphql', data)];
92
+ });
93
+ });
94
+ };
95
+ Views.prototype.getView = function (id) {
96
+ return __awaiter(this, void 0, void 0, function () {
97
+ var variables, data, view;
98
+ return __generator(this, function (_a) {
99
+ switch (_a.label) {
100
+ case 0:
101
+ variables = {
102
+ entity: constants_1.ENTITY_NAME,
103
+ params: {
104
+ id: id,
105
+ includeDeleted: false,
106
+ includeExisting: true,
107
+ },
108
+ };
109
+ data = {
110
+ operationName: 'get',
111
+ query: constants_1.QUERY_GET,
112
+ variables: variables,
113
+ };
114
+ return [4, this.dataHub.makeRequest({
115
+ method: 'POST',
116
+ route: '/graphql',
117
+ data: data,
118
+ })];
119
+ case 1:
120
+ view = (_a.sent()).data.get;
121
+ return [2, view];
122
+ }
123
+ });
124
+ });
125
+ };
126
+ Views.prototype.saveView = function (source) {
127
+ return __awaiter(this, void 0, void 0, function () {
128
+ return __generator(this, function (_a) {
129
+ delete source.deletedDate;
130
+ return [2, source.id ? this.updateView(source) : this.createView(source)];
131
+ });
132
+ });
133
+ };
134
+ Views.prototype.createView = function (source) {
135
+ return __awaiter(this, void 0, void 0, function () {
136
+ var variables, data, view;
137
+ return __generator(this, function (_a) {
138
+ switch (_a.label) {
139
+ case 0:
140
+ variables = {
141
+ entity: constants_1.ENTITY_NAME,
142
+ data: {
143
+ body: source,
144
+ },
145
+ };
146
+ data = {
147
+ operationName: 'create',
148
+ query: constants_1.QUERY_CREATE,
149
+ variables: variables,
150
+ };
151
+ return [4, this.dataHub.makeRequest({
152
+ method: 'POST',
153
+ route: '/graphql',
154
+ data: data,
155
+ })];
156
+ case 1:
157
+ view = (_a.sent()).data.create;
158
+ return [2, view];
159
+ }
160
+ });
161
+ });
162
+ };
163
+ Views.prototype.updateView = function (source) {
164
+ return __awaiter(this, void 0, void 0, function () {
165
+ var variables, data, view;
166
+ return __generator(this, function (_a) {
167
+ switch (_a.label) {
168
+ case 0:
169
+ variables = {
170
+ entity: constants_1.ENTITY_NAME,
171
+ data: {
172
+ id: source.id,
173
+ body: source,
174
+ },
175
+ };
176
+ data = {
177
+ operationName: 'update',
178
+ query: source.id ? constants_1.QUERY_UPDATE : constants_1.QUERY_CREATE,
179
+ variables: variables,
180
+ };
181
+ return [4, this.dataHub.makeRequest({
182
+ method: 'POST',
183
+ route: '/graphql',
184
+ data: data,
185
+ })];
186
+ case 1:
187
+ view = (_a.sent()).data.update;
188
+ return [2, view];
189
+ }
190
+ });
191
+ });
192
+ };
193
+ Views.prototype.deleteView = function (viewId) {
194
+ return __awaiter(this, void 0, void 0, function () {
195
+ var variables, data, requestId;
196
+ return __generator(this, function (_a) {
197
+ switch (_a.label) {
198
+ case 0:
199
+ variables = {
200
+ entity: constants_1.ENTITY_NAME,
201
+ data: {
202
+ id: viewId,
203
+ subscribe: true,
204
+ },
205
+ };
206
+ data = {
207
+ operationName: 'deleteTemporarily',
208
+ query: constants_1.QUERY_DELETE,
209
+ variables: variables,
210
+ };
211
+ return [4, this.dataHub.makeRequest({
212
+ method: 'POST',
213
+ route: '/graphql',
214
+ data: data,
215
+ })];
216
+ case 1:
217
+ requestId = (_a.sent()).data.deleteTemporarily.requestId;
218
+ return [2, this.dataHub.subscribe(requestId)];
219
+ }
220
+ });
221
+ });
222
+ };
223
+ return Views;
224
+ }(base_1.Base));
225
+ exports.Views = Views;
226
+ //# sourceMappingURL=Views.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Views.js","sourceRoot":"","sources":["../../src/Views.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAA0C;AAC1C,6CAA2F;AAE3F,yCAAwH;AASxH;IAA2B,yBA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AI,MAAA;6BACL,CAAC,EAAA;;wBAJsB,IAAI,GAAO,CAAA,SAIjC,CAAA,YAJ0B;wBAM5B,WAAO,IAAI,EAAC;;;;KACb;IAQY,0BAAU,GAAvB,UAAwB,MAAc;;;;;;wBAC9B,SAAS,GAAG;4BAChB,MAAM,EAAE,uBAAW;4BACnB,IAAI,EAAE;gCACJ,EAAE,EAAE,MAAM;gCACV,SAAS,EAAE,IAAI;6BAChB;yBACF,CAAC;wBAEI,IAAI,GAAG;4BACX,aAAa,EAAE,mBAAmB;4BAClC,KAAK,EAAE,wBAAY;4BACnB,SAAS,WAAA;yBACV,CAAC;wBAEqD,WAAM,IAAI,CAAC,OAAO,CAAC,WAAW,CAA6C;gCAChI,MAAM,EAAE,MAAM;gCACd,KAAK,EAAE,UAAU;gCACjB,IAAI,MAAA;6BACL,CAAC,EAAA;;wBAJmC,SAAS,GAAS,CAAA,SAIrD,CAAA,iCAJ4C;wBAM9C,WAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,EAAC;;;;KAC1C;IACH,YAAC;AAAD,CAAC,AAvLD,CAA2B,WAAI,GAuL9B;AAvLY,sBAAK"}
@@ -0,0 +1,11 @@
1
+ "use strict";
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 = exports.SERVICE_KEY = void 0;
4
+ exports.SERVICE_KEY = 'sdk-api';
5
+ exports.QUERY_LIST = "query list($entity: EntityType!, $params: ListInput!, $sandbox: Boolean) {\n list(entity: $entity, params: $params, sandbox: $sandbox) {\n records {\n ... on View {\n id\n data {\n data\n }\n cardIds\n mirrorCardIds\n linkId\n linkType\n template {\n category\n description\n help\n icon\n iconUrl\n implicitly\n label\n publishedBy\n tags\n type\n version\n }\n reference\n }\n }\n last\n }\n}\n";
6
+ exports.QUERY_GET = "query get($entity: EntityType!, $params: GetInput!) {\n get(entity: $entity, params: $params) {\n ... on View {\n id\n cardIds\n linkId\n mirrorCardIds\n schemaVersion\n dateCreated\n dateModified\n data {\n data\n form {\n code\n data\n style\n template\n }\n presentation {\n code\n data\n style\n template\n }\n }\n linkType\n reference\n template {\n category\n description\n help\n icon\n iconUrl\n implicitly\n label\n publishedBy\n tags\n type\n version\n }\n }\n }\n}";
7
+ exports.QUERY_CREATE = "mutation create($entity: EntityType!, $data: CreateInput!) {\n create(entity: $entity, data: $data) {\n ... on View {\n id\n cardIds\n linkId\n mirrorCardIds\n schemaVersion\n dateCreated\n dateModified\n data {\n data\n form {\n code\n data\n style\n template\n }\n presentation {\n code\n data\n style\n template\n }\n }\n linkType\n reference\n template {\n category\n description\n help\n icon\n iconUrl\n implicitly\n label\n publishedBy\n tags\n type\n version\n }\n }\n }\n}";
8
+ exports.QUERY_UPDATE = "mutation update($entity: EntityType!, $data: UpdateInput!) {\n update(entity: $entity, data: $data) {\n ... on View {\n id\n cardIds\n linkId\n mirrorCardIds\n schemaVersion\n dateCreated\n dateModified\n data {\n data\n form {\n code\n data\n style\n template\n }\n presentation {\n code\n data\n style\n template\n }\n }\n linkType\n reference\n template {\n category\n description\n help\n icon\n iconUrl\n implicitly\n label\n publishedBy\n tags\n type\n version\n }\n }\n }\n}";
9
+ exports.QUERY_DELETE = "mutation deleteTemporarily($entity: EntityType!, $data: DeleteInput!) {\n deleteTemporarily(entity: $entity, data: $data) {\n ... on AsyncRequest {\n requestId\n }\n }\n}";
10
+ exports.ENTITY_NAME = 'VIEW';
11
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,WAAW,GAAG,SAAS,CAAC;AAExB,QAAA,UAAU,GAAG,qlBA+BzB,CAAC;AAEW,QAAA,SAAS,GAAG,8tBA0CvB,CAAC;AAEU,QAAA,YAAY,GAAG,ouBA0C1B,CAAC;AAEU,QAAA,YAAY,GAAG,ouBA0C1B,CAAC;AAEU,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.Views = void 0;
14
+ var Views_1 = require("./Views");
15
+ Object.defineProperty(exports, "Views", { enumerable: true, get: function () { return Views_1.Views; } });
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,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,140 @@
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 { Base } from '@or-sdk/base';
11
+ import { DataHub } from '@or-sdk/data-hub';
12
+ import { SERVICE_KEY, ENTITY_NAME, QUERY_LIST, QUERY_GET, QUERY_CREATE, QUERY_UPDATE, QUERY_DELETE } from './constants';
13
+ export class Views extends Base {
14
+ constructor(params) {
15
+ const { token, discoveryUrl } = params;
16
+ super({
17
+ token,
18
+ discoveryUrl,
19
+ serviceKey: SERVICE_KEY,
20
+ requestAccountId: true,
21
+ });
22
+ this.dataHub = new DataHub({ token,
23
+ discoveryUrl });
24
+ }
25
+ listViews() {
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
+ getView(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: view } } = yield this.dataHub.makeRequest({
61
+ method: 'POST',
62
+ route: '/graphql',
63
+ data,
64
+ });
65
+ return view;
66
+ });
67
+ }
68
+ saveView(source) {
69
+ return __awaiter(this, void 0, void 0, function* () {
70
+ delete source.deletedDate;
71
+ return source.id ? this.updateView(source) : this.createView(source);
72
+ });
73
+ }
74
+ createView(source) {
75
+ return __awaiter(this, void 0, void 0, function* () {
76
+ const variables = {
77
+ entity: ENTITY_NAME,
78
+ data: {
79
+ body: source,
80
+ },
81
+ };
82
+ const data = {
83
+ operationName: 'create',
84
+ query: QUERY_CREATE,
85
+ variables,
86
+ };
87
+ const { data: { create: view } } = yield this.dataHub.makeRequest({
88
+ method: 'POST',
89
+ route: '/graphql',
90
+ data,
91
+ });
92
+ return view;
93
+ });
94
+ }
95
+ updateView(source) {
96
+ return __awaiter(this, void 0, void 0, function* () {
97
+ const variables = {
98
+ entity: ENTITY_NAME,
99
+ data: {
100
+ id: source.id,
101
+ body: source,
102
+ },
103
+ };
104
+ const data = {
105
+ operationName: 'update',
106
+ query: source.id ? QUERY_UPDATE : QUERY_CREATE,
107
+ variables,
108
+ };
109
+ const { data: { update: view } } = yield this.dataHub.makeRequest({
110
+ method: 'POST',
111
+ route: '/graphql',
112
+ data,
113
+ });
114
+ return view;
115
+ });
116
+ }
117
+ deleteView(viewId) {
118
+ return __awaiter(this, void 0, void 0, function* () {
119
+ const variables = {
120
+ entity: ENTITY_NAME,
121
+ data: {
122
+ id: viewId,
123
+ subscribe: true,
124
+ },
125
+ };
126
+ const data = {
127
+ operationName: 'deleteTemporarily',
128
+ query: QUERY_DELETE,
129
+ variables,
130
+ };
131
+ const { data: { deleteTemporarily: { requestId } } } = yield this.dataHub.makeRequest({
132
+ method: 'POST',
133
+ route: '/graphql',
134
+ data,
135
+ });
136
+ return this.dataHub.subscribe(requestId);
137
+ });
138
+ }
139
+ }
140
+ //# sourceMappingURL=Views.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Views.js","sourceRoot":"","sources":["../../src/Views.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,IAAI,EAAQ,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAkD,MAAM,kBAAkB,CAAC;AAE3F,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AASxH,MAAM,OAAO,KAAM,SAAQ,I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H,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,171 @@
1
+ export const SERVICE_KEY = 'sdk-api';
2
+ export const QUERY_LIST = `query list($entity: EntityType!, $params: ListInput!, $sandbox: Boolean) {
3
+ list(entity: $entity, params: $params, sandbox: $sandbox) {
4
+ records {
5
+ ... on View {
6
+ id
7
+ data {
8
+ data
9
+ }
10
+ cardIds
11
+ mirrorCardIds
12
+ linkId
13
+ linkType
14
+ template {
15
+ category
16
+ description
17
+ help
18
+ icon
19
+ iconUrl
20
+ implicitly
21
+ label
22
+ publishedBy
23
+ tags
24
+ type
25
+ version
26
+ }
27
+ reference
28
+ }
29
+ }
30
+ last
31
+ }
32
+ }
33
+ `;
34
+ export const QUERY_GET = `query get($entity: EntityType!, $params: GetInput!) {
35
+ get(entity: $entity, params: $params) {
36
+ ... on View {
37
+ id
38
+ cardIds
39
+ linkId
40
+ mirrorCardIds
41
+ schemaVersion
42
+ dateCreated
43
+ dateModified
44
+ data {
45
+ data
46
+ form {
47
+ code
48
+ data
49
+ style
50
+ template
51
+ }
52
+ presentation {
53
+ code
54
+ data
55
+ style
56
+ template
57
+ }
58
+ }
59
+ linkType
60
+ reference
61
+ template {
62
+ category
63
+ description
64
+ help
65
+ icon
66
+ iconUrl
67
+ implicitly
68
+ label
69
+ publishedBy
70
+ tags
71
+ type
72
+ version
73
+ }
74
+ }
75
+ }
76
+ }`;
77
+ export const QUERY_CREATE = `mutation create($entity: EntityType!, $data: CreateInput!) {
78
+ create(entity: $entity, data: $data) {
79
+ ... on View {
80
+ id
81
+ cardIds
82
+ linkId
83
+ mirrorCardIds
84
+ schemaVersion
85
+ dateCreated
86
+ dateModified
87
+ data {
88
+ data
89
+ form {
90
+ code
91
+ data
92
+ style
93
+ template
94
+ }
95
+ presentation {
96
+ code
97
+ data
98
+ style
99
+ template
100
+ }
101
+ }
102
+ linkType
103
+ reference
104
+ template {
105
+ category
106
+ description
107
+ help
108
+ icon
109
+ iconUrl
110
+ implicitly
111
+ label
112
+ publishedBy
113
+ tags
114
+ type
115
+ version
116
+ }
117
+ }
118
+ }
119
+ }`;
120
+ export const QUERY_UPDATE = `mutation update($entity: EntityType!, $data: UpdateInput!) {
121
+ update(entity: $entity, data: $data) {
122
+ ... on View {
123
+ id
124
+ cardIds
125
+ linkId
126
+ mirrorCardIds
127
+ schemaVersion
128
+ dateCreated
129
+ dateModified
130
+ data {
131
+ data
132
+ form {
133
+ code
134
+ data
135
+ style
136
+ template
137
+ }
138
+ presentation {
139
+ code
140
+ data
141
+ style
142
+ template
143
+ }
144
+ }
145
+ linkType
146
+ reference
147
+ template {
148
+ category
149
+ description
150
+ help
151
+ icon
152
+ iconUrl
153
+ implicitly
154
+ label
155
+ publishedBy
156
+ tags
157
+ type
158
+ version
159
+ }
160
+ }
161
+ }
162
+ }`;
163
+ export const QUERY_DELETE = `mutation deleteTemporarily($entity: EntityType!, $data: DeleteInput!) {
164
+ deleteTemporarily(entity: $entity, data: $data) {
165
+ ... on AsyncRequest {
166
+ requestId
167
+ }
168
+ }
169
+ }`;
170
+ export const ENTITY_NAME = 'VIEW';
171
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG,SAAS,CAAC;AAErC,MAAM,CAAC,MAAM,UAAU,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+BzB,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0CvB,CAAC;AAEH,MAAM,CAAC,MAAM,YAAY,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0C1B,CAAC;AAEH,MAAM,CAAC,MAAM,YAAY,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0C1B,CAAC;AAEH,MAAM,CAAC,MAAM,YAAY,GAAG;;;;;;EAM1B,CAAC;AAEH,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { Views } from './Views';
2
+ export * from './types';
3
+ //# sourceMappingURL=index.js.map
@@ -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,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,13 @@
1
+ import { Base, List } from '@or-sdk/base';
2
+ import { GraphqlResponseCheckExecution } from '@or-sdk/data-hub';
3
+ import { ViewsConfig, View } from './types';
4
+ export declare class Views extends Base {
5
+ private readonly dataHub;
6
+ constructor(params: ViewsConfig);
7
+ listViews(): Promise<List<View>>;
8
+ getView(id: string): Promise<View>;
9
+ saveView(source: View): Promise<View>;
10
+ createView(source: View): Promise<View>;
11
+ updateView(source: View): Promise<View>;
12
+ deleteView(viewId: string): Promise<GraphqlResponseCheckExecution>;
13
+ }
@@ -0,0 +1,7 @@
1
+ export declare const SERVICE_KEY = "sdk-api";
2
+ 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 View {\n id\n data {\n data\n }\n cardIds\n mirrorCardIds\n linkId\n linkType\n template {\n category\n description\n help\n icon\n iconUrl\n implicitly\n label\n publishedBy\n tags\n type\n version\n }\n reference\n }\n }\n last\n }\n}\n";
3
+ export declare const QUERY_GET = "query get($entity: EntityType!, $params: GetInput!) {\n get(entity: $entity, params: $params) {\n ... on View {\n id\n cardIds\n linkId\n mirrorCardIds\n schemaVersion\n dateCreated\n dateModified\n data {\n data\n form {\n code\n data\n style\n template\n }\n presentation {\n code\n data\n style\n template\n }\n }\n linkType\n reference\n template {\n category\n description\n help\n icon\n iconUrl\n implicitly\n label\n publishedBy\n tags\n type\n version\n }\n }\n }\n}";
4
+ export declare const QUERY_CREATE = "mutation create($entity: EntityType!, $data: CreateInput!) {\n create(entity: $entity, data: $data) {\n ... on View {\n id\n cardIds\n linkId\n mirrorCardIds\n schemaVersion\n dateCreated\n dateModified\n data {\n data\n form {\n code\n data\n style\n template\n }\n presentation {\n code\n data\n style\n template\n }\n }\n linkType\n reference\n template {\n category\n description\n help\n icon\n iconUrl\n implicitly\n label\n publishedBy\n tags\n type\n version\n }\n }\n }\n}";
5
+ export declare const QUERY_UPDATE = "mutation update($entity: EntityType!, $data: UpdateInput!) {\n update(entity: $entity, data: $data) {\n ... on View {\n id\n cardIds\n linkId\n mirrorCardIds\n schemaVersion\n dateCreated\n dateModified\n data {\n data\n form {\n code\n data\n style\n template\n }\n presentation {\n code\n data\n style\n template\n }\n }\n linkType\n reference\n template {\n category\n description\n help\n icon\n iconUrl\n implicitly\n label\n publishedBy\n tags\n type\n version\n }\n }\n }\n}";
6
+ 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}";
7
+ export declare const ENTITY_NAME = "VIEW";
@@ -0,0 +1,2 @@
1
+ export { Views } from './Views';
2
+ export * from './types';
@@ -0,0 +1,87 @@
1
+ import { Token } from '@or-sdk/base';
2
+ export declare type ViewsConfig = {
3
+ token: Token;
4
+ discoveryUrl: string;
5
+ };
6
+ export declare type View = {
7
+ id?: string;
8
+ cardIds: string[];
9
+ linkId: string | null;
10
+ mirrorCardIds: string[] | null;
11
+ schemaVersion: number;
12
+ dateCreated: number;
13
+ dateModified: number;
14
+ data: {
15
+ data: {
16
+ filterByTagIds: string[];
17
+ label: string;
18
+ description: string;
19
+ isDefaultView: boolean;
20
+ destroyRejectedCards?: boolean;
21
+ allowCardsDragging?: boolean;
22
+ customBackgroundColor?: {
23
+ hex?: string;
24
+ source?: string;
25
+ fill?: string;
26
+ opacity?: number;
27
+ stroke?: string;
28
+ };
29
+ filters?: {
30
+ queryParams?: {
31
+ [key: string]: unknown;
32
+ };
33
+ timezone?: {
34
+ uiLabel?: string;
35
+ text?: string;
36
+ value?: string;
37
+ };
38
+ dates?: {
39
+ rangeName?: string;
40
+ };
41
+ };
42
+ navigationSection?: {
43
+ name?: string;
44
+ link?: {
45
+ name: string;
46
+ };
47
+ };
48
+ showViewLoadingStatus?: boolean;
49
+ useCustomBackgroundColor?: boolean;
50
+ viewClasses?: string[];
51
+ 'background-color'?: string;
52
+ viewLoadingStatus?: {
53
+ progressType?: string;
54
+ slots?: string[];
55
+ flat?: boolean;
56
+ showProgress?: boolean;
57
+ errorOptionIds?: string[];
58
+ message?: string;
59
+ title?: string;
60
+ };
61
+ allowCardsDraggingWhenReadOnly?: boolean;
62
+ loadEntities?: {
63
+ [key: string]: unknown;
64
+ };
65
+ };
66
+ form: {
67
+ code: string;
68
+ data?: {
69
+ [key: string]: unknown;
70
+ };
71
+ style: string;
72
+ template: string;
73
+ };
74
+ presentation: {
75
+ code: string;
76
+ data?: {
77
+ [key: string]: unknown;
78
+ };
79
+ style: string;
80
+ template: string;
81
+ };
82
+ };
83
+ linkType: null;
84
+ reference: null;
85
+ template: null;
86
+ deletedDate?: string;
87
+ };
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "version": "0.7.0",
3
+ "name": "@or-sdk/views",
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.7.0",
27
+ "@or-sdk/data-hub": "^0.7.0"
28
+ },
29
+ "gitHead": "836cfcb137cdc452b1ee3088fec811d1f4901255"
30
+ }
package/src/Views.ts ADDED
@@ -0,0 +1,196 @@
1
+ import { Base, List } from '@or-sdk/base';
2
+ import { DataHub, GraphqlResponse, GraphqlResponseCheckExecution } from '@or-sdk/data-hub';
3
+ import { ViewsConfig, View } from './types';
4
+ import { SERVICE_KEY, ENTITY_NAME, QUERY_LIST, QUERY_GET, QUERY_CREATE, QUERY_UPDATE, QUERY_DELETE } from './constants';
5
+
6
+ /**
7
+ * OneReach Views service client
8
+ * ## Installation:
9
+ * ```
10
+ * $ npm i @or-sdk/views
11
+ * ```
12
+ */
13
+ export class Views extends Base {
14
+ private readonly dataHub: DataHub;
15
+
16
+ /**
17
+ * ```typescript
18
+ * import { Views } from '@or-sdk/views'
19
+ * const views = new Views({token: 'my-account-token-string', discoveryUrl: 'http://example.views/endpoint'});
20
+ * ```
21
+ */
22
+ constructor(params: ViewsConfig) {
23
+ const { token, discoveryUrl } = params;
24
+
25
+ super({
26
+ token,
27
+ discoveryUrl,
28
+ serviceKey: SERVICE_KEY,
29
+ requestAccountId: true,
30
+ });
31
+
32
+ this.dataHub = new DataHub({ token,
33
+ discoveryUrl });
34
+ }
35
+
36
+ /**
37
+ * List views
38
+ * ```typescript
39
+ * const viewList = await views.listViews();
40
+ * ```
41
+ */
42
+ public async listViews(): Promise<List<View>> {
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<View>('POST', '/graphql', data);
61
+ }
62
+
63
+ /**
64
+ * Get view
65
+ * ```typescript
66
+ * const view = await views.getView('view-id');
67
+ * ```
68
+ */
69
+ public async getView(id: string): Promise<View> {
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: view } } = await this.dataHub.makeRequest<GraphqlResponse<'get', View>>({
86
+ method: 'POST',
87
+ route: '/graphql',
88
+ data,
89
+ });
90
+
91
+ return view as View;
92
+ }
93
+
94
+ /**
95
+ * Save view
96
+ *
97
+ * If source contains existing id - existing view be updated
98
+ * ```typescript
99
+ * const savedView = await views.saveView(viewSource);
100
+ * ```
101
+ */
102
+ public async saveView(source: View): Promise<View> {
103
+ delete source.deletedDate;
104
+
105
+ return source.id ? this.updateView(source) : this.createView(source);
106
+ }
107
+
108
+ /**
109
+ * Create view
110
+ * ```typescript
111
+ * const view = await views.createView(viewSource);
112
+ * ```
113
+ */
114
+ public async createView(source: View): Promise<View> {
115
+ const variables = {
116
+ entity: ENTITY_NAME,
117
+ data: {
118
+ body: source,
119
+ },
120
+ };
121
+
122
+ const data = {
123
+ operationName: 'create',
124
+ query: QUERY_CREATE,
125
+ variables,
126
+ };
127
+
128
+ const { data: { create: view } } = await this.dataHub.makeRequest<GraphqlResponse<'create', View>>({
129
+ method: 'POST',
130
+ route: '/graphql',
131
+ data,
132
+ });
133
+
134
+ return view;
135
+ }
136
+
137
+ /**
138
+ * Update view
139
+ * ```typescript
140
+ * const view = await views.updateView(viewSource);
141
+ * ```
142
+ */
143
+ public async updateView(source: View): Promise<View> {
144
+ const variables = {
145
+ entity: ENTITY_NAME,
146
+ data: {
147
+ id: source.id,
148
+ body: source,
149
+ },
150
+ };
151
+
152
+ const data = {
153
+ operationName: 'update',
154
+ query: source.id ? QUERY_UPDATE : QUERY_CREATE,
155
+ variables,
156
+ };
157
+
158
+ const { data: { update: view } } = await this.dataHub.makeRequest<GraphqlResponse<'update', View>>({
159
+ method: 'POST',
160
+ route: '/graphql',
161
+ data,
162
+ });
163
+
164
+ return view;
165
+ }
166
+
167
+ /**
168
+ * Delete view
169
+ * ```typescript
170
+ * await views.deleteView('view-id');
171
+ * ```
172
+ */
173
+ public async deleteView(viewId: string): Promise<GraphqlResponseCheckExecution> {
174
+ const variables = {
175
+ entity: ENTITY_NAME,
176
+ data: {
177
+ id: viewId,
178
+ subscribe: true,
179
+ },
180
+ };
181
+
182
+ const data = {
183
+ operationName: 'deleteTemporarily',
184
+ query: QUERY_DELETE,
185
+ variables,
186
+ };
187
+
188
+ const { data: { deleteTemporarily: { requestId } } } = await this.dataHub.makeRequest<GraphqlResponse<'deleteTemporarily', void>>({
189
+ method: 'POST',
190
+ route: '/graphql',
191
+ data,
192
+ });
193
+
194
+ return this.dataHub.subscribe(requestId);
195
+ }
196
+ }
@@ -0,0 +1,176 @@
1
+ export const SERVICE_KEY = 'sdk-api';
2
+
3
+ export const QUERY_LIST = `query list($entity: EntityType!, $params: ListInput!, $sandbox: Boolean) {
4
+ list(entity: $entity, params: $params, sandbox: $sandbox) {
5
+ records {
6
+ ... on View {
7
+ id
8
+ data {
9
+ data
10
+ }
11
+ cardIds
12
+ mirrorCardIds
13
+ linkId
14
+ linkType
15
+ template {
16
+ category
17
+ description
18
+ help
19
+ icon
20
+ iconUrl
21
+ implicitly
22
+ label
23
+ publishedBy
24
+ tags
25
+ type
26
+ version
27
+ }
28
+ reference
29
+ }
30
+ }
31
+ last
32
+ }
33
+ }
34
+ `;
35
+
36
+ export const QUERY_GET = `query get($entity: EntityType!, $params: GetInput!) {
37
+ get(entity: $entity, params: $params) {
38
+ ... on View {
39
+ id
40
+ cardIds
41
+ linkId
42
+ mirrorCardIds
43
+ schemaVersion
44
+ dateCreated
45
+ dateModified
46
+ data {
47
+ data
48
+ form {
49
+ code
50
+ data
51
+ style
52
+ template
53
+ }
54
+ presentation {
55
+ code
56
+ data
57
+ style
58
+ template
59
+ }
60
+ }
61
+ linkType
62
+ reference
63
+ template {
64
+ category
65
+ description
66
+ help
67
+ icon
68
+ iconUrl
69
+ implicitly
70
+ label
71
+ publishedBy
72
+ tags
73
+ type
74
+ version
75
+ }
76
+ }
77
+ }
78
+ }`;
79
+
80
+ export const QUERY_CREATE = `mutation create($entity: EntityType!, $data: CreateInput!) {
81
+ create(entity: $entity, data: $data) {
82
+ ... on View {
83
+ id
84
+ cardIds
85
+ linkId
86
+ mirrorCardIds
87
+ schemaVersion
88
+ dateCreated
89
+ dateModified
90
+ data {
91
+ data
92
+ form {
93
+ code
94
+ data
95
+ style
96
+ template
97
+ }
98
+ presentation {
99
+ code
100
+ data
101
+ style
102
+ template
103
+ }
104
+ }
105
+ linkType
106
+ reference
107
+ template {
108
+ category
109
+ description
110
+ help
111
+ icon
112
+ iconUrl
113
+ implicitly
114
+ label
115
+ publishedBy
116
+ tags
117
+ type
118
+ version
119
+ }
120
+ }
121
+ }
122
+ }`;
123
+
124
+ export const QUERY_UPDATE = `mutation update($entity: EntityType!, $data: UpdateInput!) {
125
+ update(entity: $entity, data: $data) {
126
+ ... on View {
127
+ id
128
+ cardIds
129
+ linkId
130
+ mirrorCardIds
131
+ schemaVersion
132
+ dateCreated
133
+ dateModified
134
+ data {
135
+ data
136
+ form {
137
+ code
138
+ data
139
+ style
140
+ template
141
+ }
142
+ presentation {
143
+ code
144
+ data
145
+ style
146
+ template
147
+ }
148
+ }
149
+ linkType
150
+ reference
151
+ template {
152
+ category
153
+ description
154
+ help
155
+ icon
156
+ iconUrl
157
+ implicitly
158
+ label
159
+ publishedBy
160
+ tags
161
+ type
162
+ version
163
+ }
164
+ }
165
+ }
166
+ }`;
167
+
168
+ export const QUERY_DELETE = `mutation deleteTemporarily($entity: EntityType!, $data: DeleteInput!) {
169
+ deleteTemporarily(entity: $entity, data: $data) {
170
+ ... on AsyncRequest {
171
+ requestId
172
+ }
173
+ }
174
+ }`;
175
+
176
+ export const ENTITY_NAME = 'VIEW';
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { Views } from './Views';
2
+ export * from './types';
package/src/types.ts ADDED
@@ -0,0 +1,95 @@
1
+ import { Token } from '@or-sdk/base';
2
+
3
+ export type ViewsConfig = {
4
+ /**
5
+ * token
6
+ */
7
+ token: Token;
8
+ /**
9
+ * Url of OneReach service discovery api
10
+ */
11
+ discoveryUrl: string;
12
+ };
13
+
14
+ export type View = {
15
+ id?: string;
16
+ cardIds: string[];
17
+ linkId: string | null;
18
+ mirrorCardIds: string[] | null;
19
+ schemaVersion: number;
20
+ dateCreated: number;
21
+ dateModified: number;
22
+ data: {
23
+ data: {
24
+ filterByTagIds: string[];
25
+ label: string;
26
+ description: string;
27
+ isDefaultView: boolean;
28
+ destroyRejectedCards?: boolean;
29
+ allowCardsDragging?: boolean;
30
+ customBackgroundColor?: {
31
+ hex?: string;
32
+ source?: string;
33
+ fill?: string;
34
+ opacity?: number;
35
+ stroke?: string;
36
+ };
37
+ filters?: {
38
+ queryParams?: {
39
+ [key: string]: unknown;
40
+ };
41
+ timezone?: {
42
+ uiLabel?: string;
43
+ text?: string;
44
+ value?: string;
45
+ };
46
+ dates?: {
47
+ rangeName?: string;
48
+ };
49
+ };
50
+ navigationSection?: {
51
+ name?: string;
52
+ link?: {
53
+ name: string;
54
+ };
55
+ };
56
+ showViewLoadingStatus?: boolean;
57
+ useCustomBackgroundColor?: boolean;
58
+ viewClasses?: string[];
59
+ 'background-color'?: string;
60
+ viewLoadingStatus?: {
61
+ progressType?: string;
62
+ slots?: string[];
63
+ flat?: boolean;
64
+ showProgress?: boolean;
65
+ errorOptionIds?: string[];
66
+ message?: string;
67
+ title?: string;
68
+ };
69
+ allowCardsDraggingWhenReadOnly?: boolean;
70
+ loadEntities?: {
71
+ [key: string]: unknown;
72
+ };
73
+ };
74
+ form: {
75
+ code: string;
76
+ data?: {
77
+ [key: string]: unknown;
78
+ };
79
+ style: string;
80
+ template: string;
81
+ };
82
+ presentation: {
83
+ code: string;
84
+ data?: {
85
+ [key: string]: unknown;
86
+ };
87
+ style: string;
88
+ template: string;
89
+ };
90
+ };
91
+ linkType: null;
92
+ reference: null;
93
+ template: null;
94
+ deletedDate?: string;
95
+ };
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "module": "ES6",
5
+ "target": "es6",
6
+ "outDir": "./dist/esm/",
7
+ "rootDir": "./src"
8
+ }
9
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "./dist/cjs/",
5
+ "rootDir": "./src"
6
+ }
7
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "./dist/types/",
5
+ "rootDir": "./src",
6
+ "declaration": true,
7
+ "emitDeclarationOnly": true
8
+ }
9
+ }