@contrail/document-generation 2.0.50 → 2.0.51
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/README.md +2 -2
- package/lib/board-document-generator.d.ts +23 -23
- package/lib/board-document-generator.js +241 -241
- package/lib/components/component-generator.d.ts +6 -6
- package/lib/components/component-generator.js +55 -55
- package/lib/components/component-grid-generator.d.ts +7 -7
- package/lib/components/component-grid-generator.js +84 -84
- package/lib/components/component-util.d.ts +5 -5
- package/lib/components/component-util.js +43 -43
- package/lib/document-generator.d.ts +6 -6
- package/lib/document-generator.js +11 -11
- package/lib/frames/frame-generator.d.ts +12 -12
- package/lib/frames/frame-generator.js +141 -141
- package/lib/frames/frame.d.ts +18 -16
- package/lib/frames/frame.js +71 -67
- package/lib/frames/index.d.ts +2 -2
- package/lib/frames/index.js +18 -18
- package/lib/index.d.ts +6 -6
- package/lib/index.js +22 -22
- package/lib/info-panel/info-panel-generator.d.ts +6 -6
- package/lib/info-panel/info-panel-generator.js +56 -56
- package/lib/interfaces.d.ts +72 -72
- package/lib/interfaces.js +8 -8
- package/lib/scripts/test-board.d.ts +1 -1
- package/lib/scripts/test-board.js +230 -230
- package/lib/scripts/test-showcase.d.ts +1 -1
- package/lib/scripts/test-showcase.js +257 -257
- package/lib/showcase-frame-generator.d.ts +8 -8
- package/lib/showcase-frame-generator.js +44 -44
- package/lib/test-data.d.ts +72 -72
- package/lib/test-data.js +187 -187
- package/lib/util/document-dynamic-text-element-util.d.ts +8 -8
- package/lib/util/document-dynamic-text-element-util.js +77 -77
- package/lib/util/document-property-util.d.ts +9 -9
- package/lib/util/document-property-util.js +102 -102
- package/lib/util/document-text-element-util.d.ts +12 -12
- package/lib/util/document-text-element-util.js +148 -148
- package/lib/util/document-util.d.ts +8 -8
- package/lib/util/document-util.js +22 -22
- package/lib/util/index.d.ts +2 -2
- package/lib/util/index.js +18 -18
- package/lib/util/text-util.d.ts +4 -4
- package/lib/util/text-util.js +28 -28
- package/package.json +1 -1
- package/testdocument.json +25972 -25972
|
@@ -1,230 +1,230 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const document_generator_1 = require("../document-generator");
|
|
13
|
-
const interfaces_1 = require("../interfaces");
|
|
14
|
-
const sdk_1 = require("@contrail/sdk");
|
|
15
|
-
const fs = require('fs');
|
|
16
|
-
const nanoid_1 = require("nanoid");
|
|
17
|
-
const data_grouping_1 = require("@contrail/data-grouping");
|
|
18
|
-
function run() {
|
|
19
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
const orgSlug = 'nb-legacy-prod';
|
|
21
|
-
yield loginSDK(orgSlug);
|
|
22
|
-
const assortmentId = 'ejNEwWTgDPAtPoSY';
|
|
23
|
-
const itemType = yield new sdk_1.Types().getType({ path: 'item' });
|
|
24
|
-
const projectItemType = yield new sdk_1.Types().getType({ path: 'project-item' });
|
|
25
|
-
const assortmentItemType = yield new sdk_1.Types().getType({ path: 'assortment-item' });
|
|
26
|
-
const PROPERTY_COMPONENT_TEMPLATE = {
|
|
27
|
-
imageDimension: { width: 600 },
|
|
28
|
-
imageLocation: 'top',
|
|
29
|
-
textHorizontalAlignment: 'center',
|
|
30
|
-
properties: [
|
|
31
|
-
{
|
|
32
|
-
propertyDefinition: itemType.typeProperties.find((p) => p.slug === 'name'),
|
|
33
|
-
typeRootSlug: 'item',
|
|
34
|
-
slug: 'name',
|
|
35
|
-
style: {
|
|
36
|
-
font: {
|
|
37
|
-
size: 14,
|
|
38
|
-
weight: 'bold',
|
|
39
|
-
},
|
|
40
|
-
color: 'rgba(0,0,0,.5)',
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
propertyDefinition: itemType.typeProperties.find((p) => p.slug === 'optionName'),
|
|
45
|
-
typeRootSlug: 'item',
|
|
46
|
-
slug: 'optionName',
|
|
47
|
-
style: {
|
|
48
|
-
font: {
|
|
49
|
-
size: 10,
|
|
50
|
-
weight: 'bold',
|
|
51
|
-
},
|
|
52
|
-
color: 'green',
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
propertyDefinition: assortmentItemType.typeProperties.find((p) => p.slug === 'targetVolume'),
|
|
57
|
-
slug: 'targetVolume',
|
|
58
|
-
typeRootSlug: 'assortment-item',
|
|
59
|
-
includeLabel: true,
|
|
60
|
-
},
|
|
61
|
-
],
|
|
62
|
-
};
|
|
63
|
-
const PANEL_PROPERTY_TEMPLATE = {
|
|
64
|
-
properties: [
|
|
65
|
-
{
|
|
66
|
-
propertyDefinition: itemType.typeProperties.find((p) => p.slug === 'name'),
|
|
67
|
-
typeRootSlug: 'item',
|
|
68
|
-
slug: 'name',
|
|
69
|
-
includeLabel: false,
|
|
70
|
-
style: {
|
|
71
|
-
font: {
|
|
72
|
-
size: 25,
|
|
73
|
-
weight: 'bold',
|
|
74
|
-
},
|
|
75
|
-
color: 'white',
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
],
|
|
79
|
-
};
|
|
80
|
-
const documentTemplateDefinition = {
|
|
81
|
-
frameOrientation: interfaces_1.Orientation.HORIZONTAL,
|
|
82
|
-
frameSize: { width: 1200, height: 675 },
|
|
83
|
-
framePadding: 30,
|
|
84
|
-
frameGroupHeaderTemplate: {
|
|
85
|
-
style: {
|
|
86
|
-
color: '#ffffff',
|
|
87
|
-
font: {
|
|
88
|
-
size: 20,
|
|
89
|
-
},
|
|
90
|
-
backgroundColor: 'rgba(0, 0, 0, 0.8)',
|
|
91
|
-
},
|
|
92
|
-
size: {
|
|
93
|
-
height: 60,
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
frameInfoPanelTemplate: {
|
|
97
|
-
panelDocumentTemplate: {
|
|
98
|
-
style: {
|
|
99
|
-
color: '#ffffff',
|
|
100
|
-
font: {
|
|
101
|
-
size: 20,
|
|
102
|
-
},
|
|
103
|
-
backgroundColor: 'rgba(0, 0, 0, 0.8)',
|
|
104
|
-
border: {
|
|
105
|
-
radius: 4,
|
|
106
|
-
},
|
|
107
|
-
},
|
|
108
|
-
size: {
|
|
109
|
-
width: 250,
|
|
110
|
-
height: 400,
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
propertyTemplate: PANEL_PROPERTY_TEMPLATE,
|
|
114
|
-
},
|
|
115
|
-
componentGridTemplate: {
|
|
116
|
-
gridDimensions: { cols: 3, rows: 1 },
|
|
117
|
-
componentPadding: 5,
|
|
118
|
-
componentTemplate: {
|
|
119
|
-
propertyTemplate: PROPERTY_COMPONENT_TEMPLATE,
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
|
-
};
|
|
123
|
-
const groupingProperties = [
|
|
124
|
-
{
|
|
125
|
-
propertyDefinition: itemType.typeProperties.find((p) => p.slug === 'category'),
|
|
126
|
-
typeRootSlug: 'item',
|
|
127
|
-
sort: sdk_1.SortOrderOptions.ASC,
|
|
128
|
-
values: null,
|
|
129
|
-
},
|
|
130
|
-
{
|
|
131
|
-
propertyDefinition: itemType.typeProperties.find((p) => p.slug === 'name'),
|
|
132
|
-
typeRootSlug: 'item',
|
|
133
|
-
sort: sdk_1.SortOrderOptions.ASC,
|
|
134
|
-
values: null,
|
|
135
|
-
},
|
|
136
|
-
];
|
|
137
|
-
documentTemplateDefinition.componentGridTemplate.componentTemplate.propertyTemplate = PROPERTY_COMPONENT_TEMPLATE;
|
|
138
|
-
const dataGroup = yield getDataGroupStructure(assortmentId, groupingProperties, documentTemplateDefinition);
|
|
139
|
-
const params = {
|
|
140
|
-
startingCoordinates: { x: 500, y: 500 },
|
|
141
|
-
data: {
|
|
142
|
-
dataGroup,
|
|
143
|
-
},
|
|
144
|
-
documentTemplateDefinition,
|
|
145
|
-
};
|
|
146
|
-
const elements = document_generator_1.DocumentGenerator.generateDocumentElements(params, {});
|
|
147
|
-
const documentId = (0, nanoid_1.nanoid)(16);
|
|
148
|
-
elements.forEach((el) => {
|
|
149
|
-
el.id = (0, nanoid_1.nanoid)(16);
|
|
150
|
-
});
|
|
151
|
-
const document = {
|
|
152
|
-
size: { width: 1600, height: 900 },
|
|
153
|
-
elements,
|
|
154
|
-
id: documentId,
|
|
155
|
-
};
|
|
156
|
-
yield uploadAndOpen(orgSlug, document);
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
function loginSDK(orgSlug) {
|
|
160
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
161
|
-
const config = {
|
|
162
|
-
email: 'brian@vibeiq.com',
|
|
163
|
-
password: process.env.CONTRAIL_PW,
|
|
164
|
-
orgSlug: orgSlug,
|
|
165
|
-
};
|
|
166
|
-
yield (0, sdk_1.login)(config);
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
function getAssortmentItems(assortmentId) {
|
|
170
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
171
|
-
const assortment = yield new sdk_1.Entities().get({
|
|
172
|
-
entityName: 'assortment',
|
|
173
|
-
id: assortmentId,
|
|
174
|
-
relations: ['assortmentItems', 'assortmentItems.item', 'assortmentItems.projectItem'],
|
|
175
|
-
});
|
|
176
|
-
let assortmentItems = assortment.assortmentItems;
|
|
177
|
-
if (assortment.itemsDownloadURL) {
|
|
178
|
-
const response = yield fetch(assortment.itemsDownloadURL);
|
|
179
|
-
assortmentItems = yield response.json();
|
|
180
|
-
}
|
|
181
|
-
return assortmentItems;
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
function getDataGroupStructure(assortmentId, groupingProperties, template) {
|
|
185
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
186
|
-
const assortmentItems = yield getAssortmentItems(assortmentId);
|
|
187
|
-
const data = fromAssortmentModelToItemModel(assortmentItems);
|
|
188
|
-
const leafNodeDataCount = template.componentGridTemplate.gridDimensions.cols * template.componentGridTemplate.gridDimensions.rows;
|
|
189
|
-
return data_grouping_1.DataGroupGenerator.buildDataGroupStructure(data, groupingProperties, leafNodeDataCount);
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
function fromAssortmentModelToItemModel(data) {
|
|
193
|
-
const results = [];
|
|
194
|
-
data.forEach((ai) => {
|
|
195
|
-
results.push({
|
|
196
|
-
item: ai.item,
|
|
197
|
-
projectItem: ai.projectItem,
|
|
198
|
-
viewable: ai.item,
|
|
199
|
-
assortmentItem: ai,
|
|
200
|
-
assortment: { id: ai.assortmentId },
|
|
201
|
-
});
|
|
202
|
-
});
|
|
203
|
-
return results;
|
|
204
|
-
}
|
|
205
|
-
function uploadAndOpen(orgSlug, document) {
|
|
206
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
207
|
-
let config = (0, sdk_1.getConfig)();
|
|
208
|
-
var writeStream = fs.createWriteStream('testdocument.json');
|
|
209
|
-
writeStream.write(JSON.stringify(document));
|
|
210
|
-
writeStream.end();
|
|
211
|
-
const file = fs.createReadStream('testdocument.json');
|
|
212
|
-
const fileEntity = yield new sdk_1.Files().createAndUploadFileFromBuffer(file, 'application/json', 'testdocument.json', null, 300);
|
|
213
|
-
const domain = 'http://preview.vibeiq.com';
|
|
214
|
-
const authToken = config.apiUserToken;
|
|
215
|
-
const documentType = 'board';
|
|
216
|
-
let url = domain +
|
|
217
|
-
'?url=' +
|
|
218
|
-
encodeURIComponent(fileEntity.downloadUrl) +
|
|
219
|
-
'&orgSlug=' +
|
|
220
|
-
encodeURIComponent(orgSlug) +
|
|
221
|
-
'&apiToken=' +
|
|
222
|
-
encodeURIComponent(authToken) +
|
|
223
|
-
'&documentType=' +
|
|
224
|
-
encodeURIComponent(documentType);
|
|
225
|
-
var start = process.platform == 'darwin' ? 'open' : process.platform == 'win32' ? 'start' : 'xdg-open';
|
|
226
|
-
const encodedUrl = url.replace(/&/g, '^&');
|
|
227
|
-
require('child_process').exec(start + ' ' + encodedUrl);
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
run();
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const document_generator_1 = require("../document-generator");
|
|
13
|
+
const interfaces_1 = require("../interfaces");
|
|
14
|
+
const sdk_1 = require("@contrail/sdk");
|
|
15
|
+
const fs = require('fs');
|
|
16
|
+
const nanoid_1 = require("nanoid");
|
|
17
|
+
const data_grouping_1 = require("@contrail/data-grouping");
|
|
18
|
+
function run() {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
const orgSlug = 'nb-legacy-prod';
|
|
21
|
+
yield loginSDK(orgSlug);
|
|
22
|
+
const assortmentId = 'ejNEwWTgDPAtPoSY';
|
|
23
|
+
const itemType = yield new sdk_1.Types().getType({ path: 'item' });
|
|
24
|
+
const projectItemType = yield new sdk_1.Types().getType({ path: 'project-item' });
|
|
25
|
+
const assortmentItemType = yield new sdk_1.Types().getType({ path: 'assortment-item' });
|
|
26
|
+
const PROPERTY_COMPONENT_TEMPLATE = {
|
|
27
|
+
imageDimension: { width: 600 },
|
|
28
|
+
imageLocation: 'top',
|
|
29
|
+
textHorizontalAlignment: 'center',
|
|
30
|
+
properties: [
|
|
31
|
+
{
|
|
32
|
+
propertyDefinition: itemType.typeProperties.find((p) => p.slug === 'name'),
|
|
33
|
+
typeRootSlug: 'item',
|
|
34
|
+
slug: 'name',
|
|
35
|
+
style: {
|
|
36
|
+
font: {
|
|
37
|
+
size: 14,
|
|
38
|
+
weight: 'bold',
|
|
39
|
+
},
|
|
40
|
+
color: 'rgba(0,0,0,.5)',
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
propertyDefinition: itemType.typeProperties.find((p) => p.slug === 'optionName'),
|
|
45
|
+
typeRootSlug: 'item',
|
|
46
|
+
slug: 'optionName',
|
|
47
|
+
style: {
|
|
48
|
+
font: {
|
|
49
|
+
size: 10,
|
|
50
|
+
weight: 'bold',
|
|
51
|
+
},
|
|
52
|
+
color: 'green',
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
propertyDefinition: assortmentItemType.typeProperties.find((p) => p.slug === 'targetVolume'),
|
|
57
|
+
slug: 'targetVolume',
|
|
58
|
+
typeRootSlug: 'assortment-item',
|
|
59
|
+
includeLabel: true,
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
};
|
|
63
|
+
const PANEL_PROPERTY_TEMPLATE = {
|
|
64
|
+
properties: [
|
|
65
|
+
{
|
|
66
|
+
propertyDefinition: itemType.typeProperties.find((p) => p.slug === 'name'),
|
|
67
|
+
typeRootSlug: 'item',
|
|
68
|
+
slug: 'name',
|
|
69
|
+
includeLabel: false,
|
|
70
|
+
style: {
|
|
71
|
+
font: {
|
|
72
|
+
size: 25,
|
|
73
|
+
weight: 'bold',
|
|
74
|
+
},
|
|
75
|
+
color: 'white',
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
};
|
|
80
|
+
const documentTemplateDefinition = {
|
|
81
|
+
frameOrientation: interfaces_1.Orientation.HORIZONTAL,
|
|
82
|
+
frameSize: { width: 1200, height: 675 },
|
|
83
|
+
framePadding: 30,
|
|
84
|
+
frameGroupHeaderTemplate: {
|
|
85
|
+
style: {
|
|
86
|
+
color: '#ffffff',
|
|
87
|
+
font: {
|
|
88
|
+
size: 20,
|
|
89
|
+
},
|
|
90
|
+
backgroundColor: 'rgba(0, 0, 0, 0.8)',
|
|
91
|
+
},
|
|
92
|
+
size: {
|
|
93
|
+
height: 60,
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
frameInfoPanelTemplate: {
|
|
97
|
+
panelDocumentTemplate: {
|
|
98
|
+
style: {
|
|
99
|
+
color: '#ffffff',
|
|
100
|
+
font: {
|
|
101
|
+
size: 20,
|
|
102
|
+
},
|
|
103
|
+
backgroundColor: 'rgba(0, 0, 0, 0.8)',
|
|
104
|
+
border: {
|
|
105
|
+
radius: 4,
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
size: {
|
|
109
|
+
width: 250,
|
|
110
|
+
height: 400,
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
propertyTemplate: PANEL_PROPERTY_TEMPLATE,
|
|
114
|
+
},
|
|
115
|
+
componentGridTemplate: {
|
|
116
|
+
gridDimensions: { cols: 3, rows: 1 },
|
|
117
|
+
componentPadding: 5,
|
|
118
|
+
componentTemplate: {
|
|
119
|
+
propertyTemplate: PROPERTY_COMPONENT_TEMPLATE,
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
const groupingProperties = [
|
|
124
|
+
{
|
|
125
|
+
propertyDefinition: itemType.typeProperties.find((p) => p.slug === 'category'),
|
|
126
|
+
typeRootSlug: 'item',
|
|
127
|
+
sort: sdk_1.SortOrderOptions.ASC,
|
|
128
|
+
values: null,
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
propertyDefinition: itemType.typeProperties.find((p) => p.slug === 'name'),
|
|
132
|
+
typeRootSlug: 'item',
|
|
133
|
+
sort: sdk_1.SortOrderOptions.ASC,
|
|
134
|
+
values: null,
|
|
135
|
+
},
|
|
136
|
+
];
|
|
137
|
+
documentTemplateDefinition.componentGridTemplate.componentTemplate.propertyTemplate = PROPERTY_COMPONENT_TEMPLATE;
|
|
138
|
+
const dataGroup = yield getDataGroupStructure(assortmentId, groupingProperties, documentTemplateDefinition);
|
|
139
|
+
const params = {
|
|
140
|
+
startingCoordinates: { x: 500, y: 500 },
|
|
141
|
+
data: {
|
|
142
|
+
dataGroup,
|
|
143
|
+
},
|
|
144
|
+
documentTemplateDefinition,
|
|
145
|
+
};
|
|
146
|
+
const elements = document_generator_1.DocumentGenerator.generateDocumentElements(params, {});
|
|
147
|
+
const documentId = (0, nanoid_1.nanoid)(16);
|
|
148
|
+
elements.forEach((el) => {
|
|
149
|
+
el.id = (0, nanoid_1.nanoid)(16);
|
|
150
|
+
});
|
|
151
|
+
const document = {
|
|
152
|
+
size: { width: 1600, height: 900 },
|
|
153
|
+
elements,
|
|
154
|
+
id: documentId,
|
|
155
|
+
};
|
|
156
|
+
yield uploadAndOpen(orgSlug, document);
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
function loginSDK(orgSlug) {
|
|
160
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
161
|
+
const config = {
|
|
162
|
+
email: 'brian@vibeiq.com',
|
|
163
|
+
password: process.env.CONTRAIL_PW,
|
|
164
|
+
orgSlug: orgSlug,
|
|
165
|
+
};
|
|
166
|
+
yield (0, sdk_1.login)(config);
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
function getAssortmentItems(assortmentId) {
|
|
170
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
171
|
+
const assortment = yield new sdk_1.Entities().get({
|
|
172
|
+
entityName: 'assortment',
|
|
173
|
+
id: assortmentId,
|
|
174
|
+
relations: ['assortmentItems', 'assortmentItems.item', 'assortmentItems.projectItem'],
|
|
175
|
+
});
|
|
176
|
+
let assortmentItems = assortment.assortmentItems;
|
|
177
|
+
if (assortment.itemsDownloadURL) {
|
|
178
|
+
const response = yield fetch(assortment.itemsDownloadURL);
|
|
179
|
+
assortmentItems = yield response.json();
|
|
180
|
+
}
|
|
181
|
+
return assortmentItems;
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
function getDataGroupStructure(assortmentId, groupingProperties, template) {
|
|
185
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
186
|
+
const assortmentItems = yield getAssortmentItems(assortmentId);
|
|
187
|
+
const data = fromAssortmentModelToItemModel(assortmentItems);
|
|
188
|
+
const leafNodeDataCount = template.componentGridTemplate.gridDimensions.cols * template.componentGridTemplate.gridDimensions.rows;
|
|
189
|
+
return data_grouping_1.DataGroupGenerator.buildDataGroupStructure(data, groupingProperties, leafNodeDataCount);
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
function fromAssortmentModelToItemModel(data) {
|
|
193
|
+
const results = [];
|
|
194
|
+
data.forEach((ai) => {
|
|
195
|
+
results.push({
|
|
196
|
+
item: ai.item,
|
|
197
|
+
projectItem: ai.projectItem,
|
|
198
|
+
viewable: ai.item,
|
|
199
|
+
assortmentItem: ai,
|
|
200
|
+
assortment: { id: ai.assortmentId },
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
return results;
|
|
204
|
+
}
|
|
205
|
+
function uploadAndOpen(orgSlug, document) {
|
|
206
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
207
|
+
let config = (0, sdk_1.getConfig)();
|
|
208
|
+
var writeStream = fs.createWriteStream('testdocument.json');
|
|
209
|
+
writeStream.write(JSON.stringify(document));
|
|
210
|
+
writeStream.end();
|
|
211
|
+
const file = fs.createReadStream('testdocument.json');
|
|
212
|
+
const fileEntity = yield new sdk_1.Files().createAndUploadFileFromBuffer(file, 'application/json', 'testdocument.json', null, 300);
|
|
213
|
+
const domain = 'http://preview.vibeiq.com';
|
|
214
|
+
const authToken = config.apiUserToken;
|
|
215
|
+
const documentType = 'board';
|
|
216
|
+
let url = domain +
|
|
217
|
+
'?url=' +
|
|
218
|
+
encodeURIComponent(fileEntity.downloadUrl) +
|
|
219
|
+
'&orgSlug=' +
|
|
220
|
+
encodeURIComponent(orgSlug) +
|
|
221
|
+
'&apiToken=' +
|
|
222
|
+
encodeURIComponent(authToken) +
|
|
223
|
+
'&documentType=' +
|
|
224
|
+
encodeURIComponent(documentType);
|
|
225
|
+
var start = process.platform == 'darwin' ? 'open' : process.platform == 'win32' ? 'start' : 'xdg-open';
|
|
226
|
+
const encodedUrl = url.replace(/&/g, '^&');
|
|
227
|
+
require('child_process').exec(start + ' ' + encodedUrl);
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
run();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|