@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,257 +1,257 @@
|
|
|
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 interfaces_1 = require("../interfaces");
|
|
13
|
-
const sdk_1 = require("@contrail/sdk");
|
|
14
|
-
const fs = require('fs');
|
|
15
|
-
const data_grouping_1 = require("@contrail/data-grouping");
|
|
16
|
-
const showcase_frame_generator_1 = require("../showcase-frame-generator");
|
|
17
|
-
function run() {
|
|
18
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
-
const orgSlug = 'converse-prod';
|
|
20
|
-
yield loginSDK(orgSlug);
|
|
21
|
-
const assortmentId = 'Z7nTOauGtuuiU9UC';
|
|
22
|
-
const itemType = yield new sdk_1.Types().getType({ path: 'item' });
|
|
23
|
-
const projectItemType = yield new sdk_1.Types().getType({ path: 'project-item' });
|
|
24
|
-
const PROPERTY_COMPONENT_TEMPLATE = {
|
|
25
|
-
imageDimension: { width: 600 },
|
|
26
|
-
imageLocation: 'top',
|
|
27
|
-
textHorizontalAlignment: 'center',
|
|
28
|
-
properties: [
|
|
29
|
-
{
|
|
30
|
-
propertyDefinition: itemType.typeProperties.find((p) => p.slug === 'name'),
|
|
31
|
-
typeRootSlug: 'item',
|
|
32
|
-
slug: 'name',
|
|
33
|
-
style: {
|
|
34
|
-
font: {
|
|
35
|
-
size: 14,
|
|
36
|
-
weight: 'bold',
|
|
37
|
-
},
|
|
38
|
-
color: 'rgba(0,0,0,.5)',
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
propertyDefinition: itemType.typeProperties.find((p) => p.slug === 'optionName'),
|
|
43
|
-
typeRootSlug: 'item',
|
|
44
|
-
slug: 'optionName',
|
|
45
|
-
style: {
|
|
46
|
-
font: {
|
|
47
|
-
size: 10,
|
|
48
|
-
weight: 'bold',
|
|
49
|
-
},
|
|
50
|
-
color: 'green',
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
propertyDefinition: itemType.typeProperties.find((p) => p.slug === 'category'),
|
|
55
|
-
typeRootSlug: 'item',
|
|
56
|
-
slug: 'category',
|
|
57
|
-
includeLabel: true,
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
propertyDefinition: itemType.typeProperties.find((p) => p.slug === 'designTheme'),
|
|
61
|
-
typeRootSlug: 'item',
|
|
62
|
-
slug: 'designTheme',
|
|
63
|
-
includeLabel: true,
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
propertyDefinition: itemType.typeProperties.find((p) => p.slug === 'baseStyleNumber'),
|
|
67
|
-
typeRootSlug: 'item',
|
|
68
|
-
slug: 'baseStyleNumber',
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
propertyDefinition: projectItemType.typeProperties.find((p) => p.slug === 'colorwayStatus'),
|
|
72
|
-
slug: 'colorwayStatus',
|
|
73
|
-
typeRootSlug: 'project-item',
|
|
74
|
-
includeLabel: true,
|
|
75
|
-
},
|
|
76
|
-
],
|
|
77
|
-
};
|
|
78
|
-
const PANEL_PROPERTY_TEMPLATE = {
|
|
79
|
-
properties: [
|
|
80
|
-
{
|
|
81
|
-
propertyDefinition: itemType.typeProperties.find((p) => p.slug === 'name'),
|
|
82
|
-
typeRootSlug: 'item',
|
|
83
|
-
slug: 'name',
|
|
84
|
-
includeLabel: false,
|
|
85
|
-
style: {
|
|
86
|
-
font: {
|
|
87
|
-
size: 25,
|
|
88
|
-
weight: 'bold',
|
|
89
|
-
},
|
|
90
|
-
color: 'white',
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
propertyDefinition: itemType.typeProperties.find((p) => p.slug === 'segment'),
|
|
95
|
-
typeRootSlug: 'item',
|
|
96
|
-
slug: 'segment',
|
|
97
|
-
includeLabel: true,
|
|
98
|
-
style: {
|
|
99
|
-
font: {
|
|
100
|
-
size: 14,
|
|
101
|
-
},
|
|
102
|
-
color: 'white',
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
propertyDefinition: itemType.typeProperties.find((p) => p.slug === 'familyName'),
|
|
107
|
-
typeRootSlug: 'item',
|
|
108
|
-
slug: 'familyName',
|
|
109
|
-
includeLabel: true,
|
|
110
|
-
style: {
|
|
111
|
-
font: {
|
|
112
|
-
size: 14,
|
|
113
|
-
},
|
|
114
|
-
color: 'white',
|
|
115
|
-
},
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
propertyDefinition: itemType.typeProperties.find((p) => p.slug === 'ageGroup'),
|
|
119
|
-
typeRootSlug: 'item',
|
|
120
|
-
slug: 'ageGroup',
|
|
121
|
-
includeLabel: true,
|
|
122
|
-
style: {
|
|
123
|
-
font: {
|
|
124
|
-
size: 14,
|
|
125
|
-
},
|
|
126
|
-
color: 'white',
|
|
127
|
-
},
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
propertyDefinition: itemType.typeProperties.find((p) => p.slug === 'planningLevel1'),
|
|
131
|
-
typeRootSlug: 'item',
|
|
132
|
-
slug: 'planningLevel1',
|
|
133
|
-
includeLabel: true,
|
|
134
|
-
style: {
|
|
135
|
-
font: {
|
|
136
|
-
size: 14,
|
|
137
|
-
},
|
|
138
|
-
color: 'white',
|
|
139
|
-
},
|
|
140
|
-
},
|
|
141
|
-
],
|
|
142
|
-
};
|
|
143
|
-
const documentTemplateDefinition = {
|
|
144
|
-
frameOrientation: interfaces_1.Orientation.HORIZONTAL,
|
|
145
|
-
frameSize: { width: 1200, height: 675 },
|
|
146
|
-
framePadding: 30,
|
|
147
|
-
frameGroupHeaderTemplate: {
|
|
148
|
-
style: {
|
|
149
|
-
color: '#ffffff',
|
|
150
|
-
font: {
|
|
151
|
-
size: 20,
|
|
152
|
-
},
|
|
153
|
-
backgroundColor: 'rgba(0, 0, 0, 0.8)',
|
|
154
|
-
},
|
|
155
|
-
size: {
|
|
156
|
-
height: 60,
|
|
157
|
-
},
|
|
158
|
-
},
|
|
159
|
-
frameInfoPanelTemplate: {
|
|
160
|
-
panelDocumentTemplate: {
|
|
161
|
-
style: {
|
|
162
|
-
color: '#ffffff',
|
|
163
|
-
font: {
|
|
164
|
-
size: 20,
|
|
165
|
-
},
|
|
166
|
-
backgroundColor: 'rgba(0, 0, 0, 0.8)',
|
|
167
|
-
border: {
|
|
168
|
-
radius: 4,
|
|
169
|
-
},
|
|
170
|
-
},
|
|
171
|
-
size: {
|
|
172
|
-
width: 250,
|
|
173
|
-
height: 400,
|
|
174
|
-
},
|
|
175
|
-
},
|
|
176
|
-
propertyTemplate: PANEL_PROPERTY_TEMPLATE,
|
|
177
|
-
},
|
|
178
|
-
componentGridTemplate: {
|
|
179
|
-
gridDimensions: { cols: 3, rows: 1 },
|
|
180
|
-
componentPadding: 5,
|
|
181
|
-
componentTemplate: {
|
|
182
|
-
propertyTemplate: PROPERTY_COMPONENT_TEMPLATE,
|
|
183
|
-
},
|
|
184
|
-
},
|
|
185
|
-
};
|
|
186
|
-
const groupingProperties = [
|
|
187
|
-
{
|
|
188
|
-
propertyDefinition: itemType.typeProperties.find((p) => p.slug === 'category'),
|
|
189
|
-
typeRootSlug: 'item',
|
|
190
|
-
sort: sdk_1.SortOrderOptions.ASC,
|
|
191
|
-
values: null,
|
|
192
|
-
},
|
|
193
|
-
{
|
|
194
|
-
propertyDefinition: itemType.typeProperties.find((p) => p.slug === 'name'),
|
|
195
|
-
typeRootSlug: 'item',
|
|
196
|
-
sort: sdk_1.SortOrderOptions.ASC,
|
|
197
|
-
values: null,
|
|
198
|
-
},
|
|
199
|
-
];
|
|
200
|
-
documentTemplateDefinition.componentGridTemplate.componentTemplate.propertyTemplate = PROPERTY_COMPONENT_TEMPLATE;
|
|
201
|
-
const dataGroup = yield getDataGroupStructure(assortmentId, groupingProperties, documentTemplateDefinition);
|
|
202
|
-
const params = {
|
|
203
|
-
startingCoordinates: { x: 500, y: 500 },
|
|
204
|
-
data: {
|
|
205
|
-
dataGroup,
|
|
206
|
-
},
|
|
207
|
-
documentTemplateDefinition,
|
|
208
|
-
};
|
|
209
|
-
const frames = showcase_frame_generator_1.ShowcaseFrameGenerator.generateFrames(params);
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
function loginSDK(orgSlug) {
|
|
213
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
214
|
-
const config = {
|
|
215
|
-
email: 'brian@vibeiq.com',
|
|
216
|
-
password: process.env.CONTRAIL_PW,
|
|
217
|
-
orgSlug: orgSlug,
|
|
218
|
-
};
|
|
219
|
-
yield (0, sdk_1.login)(config);
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
function getAssortmentItems(assortmentId) {
|
|
223
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
224
|
-
const assortment = yield new sdk_1.Entities().get({
|
|
225
|
-
entityName: 'assortment',
|
|
226
|
-
id: assortmentId,
|
|
227
|
-
relations: ['assortmentItems', 'assortmentItems.item', 'assortmentItems.projectItem'],
|
|
228
|
-
});
|
|
229
|
-
let assortmentItems = assortment.assortmentItems;
|
|
230
|
-
if (assortment.itemsDownloadURL) {
|
|
231
|
-
const response = yield fetch(assortment.itemsDownloadURL);
|
|
232
|
-
assortmentItems = yield response.json();
|
|
233
|
-
}
|
|
234
|
-
return assortmentItems;
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
function getDataGroupStructure(assortmentId, groupingProperties, template) {
|
|
238
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
239
|
-
const assortmentItems = yield getAssortmentItems(assortmentId);
|
|
240
|
-
const data = fromAssortmentModelToItemModel(assortmentItems);
|
|
241
|
-
const leafNodeDataCount = template.componentGridTemplate.gridDimensions.cols * template.componentGridTemplate.gridDimensions.rows;
|
|
242
|
-
return data_grouping_1.DataGroupGenerator.buildDataGroupStructure(data, groupingProperties, leafNodeDataCount);
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
function fromAssortmentModelToItemModel(data) {
|
|
246
|
-
const results = [];
|
|
247
|
-
data.forEach((ai) => {
|
|
248
|
-
results.push({
|
|
249
|
-
item: ai.item,
|
|
250
|
-
projectItem: ai.projectItem,
|
|
251
|
-
viewable: ai.item,
|
|
252
|
-
assortmentItem: ai,
|
|
253
|
-
});
|
|
254
|
-
});
|
|
255
|
-
return results;
|
|
256
|
-
}
|
|
257
|
-
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 interfaces_1 = require("../interfaces");
|
|
13
|
+
const sdk_1 = require("@contrail/sdk");
|
|
14
|
+
const fs = require('fs');
|
|
15
|
+
const data_grouping_1 = require("@contrail/data-grouping");
|
|
16
|
+
const showcase_frame_generator_1 = require("../showcase-frame-generator");
|
|
17
|
+
function run() {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
const orgSlug = 'converse-prod';
|
|
20
|
+
yield loginSDK(orgSlug);
|
|
21
|
+
const assortmentId = 'Z7nTOauGtuuiU9UC';
|
|
22
|
+
const itemType = yield new sdk_1.Types().getType({ path: 'item' });
|
|
23
|
+
const projectItemType = yield new sdk_1.Types().getType({ path: 'project-item' });
|
|
24
|
+
const PROPERTY_COMPONENT_TEMPLATE = {
|
|
25
|
+
imageDimension: { width: 600 },
|
|
26
|
+
imageLocation: 'top',
|
|
27
|
+
textHorizontalAlignment: 'center',
|
|
28
|
+
properties: [
|
|
29
|
+
{
|
|
30
|
+
propertyDefinition: itemType.typeProperties.find((p) => p.slug === 'name'),
|
|
31
|
+
typeRootSlug: 'item',
|
|
32
|
+
slug: 'name',
|
|
33
|
+
style: {
|
|
34
|
+
font: {
|
|
35
|
+
size: 14,
|
|
36
|
+
weight: 'bold',
|
|
37
|
+
},
|
|
38
|
+
color: 'rgba(0,0,0,.5)',
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
propertyDefinition: itemType.typeProperties.find((p) => p.slug === 'optionName'),
|
|
43
|
+
typeRootSlug: 'item',
|
|
44
|
+
slug: 'optionName',
|
|
45
|
+
style: {
|
|
46
|
+
font: {
|
|
47
|
+
size: 10,
|
|
48
|
+
weight: 'bold',
|
|
49
|
+
},
|
|
50
|
+
color: 'green',
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
propertyDefinition: itemType.typeProperties.find((p) => p.slug === 'category'),
|
|
55
|
+
typeRootSlug: 'item',
|
|
56
|
+
slug: 'category',
|
|
57
|
+
includeLabel: true,
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
propertyDefinition: itemType.typeProperties.find((p) => p.slug === 'designTheme'),
|
|
61
|
+
typeRootSlug: 'item',
|
|
62
|
+
slug: 'designTheme',
|
|
63
|
+
includeLabel: true,
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
propertyDefinition: itemType.typeProperties.find((p) => p.slug === 'baseStyleNumber'),
|
|
67
|
+
typeRootSlug: 'item',
|
|
68
|
+
slug: 'baseStyleNumber',
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
propertyDefinition: projectItemType.typeProperties.find((p) => p.slug === 'colorwayStatus'),
|
|
72
|
+
slug: 'colorwayStatus',
|
|
73
|
+
typeRootSlug: 'project-item',
|
|
74
|
+
includeLabel: true,
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
};
|
|
78
|
+
const PANEL_PROPERTY_TEMPLATE = {
|
|
79
|
+
properties: [
|
|
80
|
+
{
|
|
81
|
+
propertyDefinition: itemType.typeProperties.find((p) => p.slug === 'name'),
|
|
82
|
+
typeRootSlug: 'item',
|
|
83
|
+
slug: 'name',
|
|
84
|
+
includeLabel: false,
|
|
85
|
+
style: {
|
|
86
|
+
font: {
|
|
87
|
+
size: 25,
|
|
88
|
+
weight: 'bold',
|
|
89
|
+
},
|
|
90
|
+
color: 'white',
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
propertyDefinition: itemType.typeProperties.find((p) => p.slug === 'segment'),
|
|
95
|
+
typeRootSlug: 'item',
|
|
96
|
+
slug: 'segment',
|
|
97
|
+
includeLabel: true,
|
|
98
|
+
style: {
|
|
99
|
+
font: {
|
|
100
|
+
size: 14,
|
|
101
|
+
},
|
|
102
|
+
color: 'white',
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
propertyDefinition: itemType.typeProperties.find((p) => p.slug === 'familyName'),
|
|
107
|
+
typeRootSlug: 'item',
|
|
108
|
+
slug: 'familyName',
|
|
109
|
+
includeLabel: true,
|
|
110
|
+
style: {
|
|
111
|
+
font: {
|
|
112
|
+
size: 14,
|
|
113
|
+
},
|
|
114
|
+
color: 'white',
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
propertyDefinition: itemType.typeProperties.find((p) => p.slug === 'ageGroup'),
|
|
119
|
+
typeRootSlug: 'item',
|
|
120
|
+
slug: 'ageGroup',
|
|
121
|
+
includeLabel: true,
|
|
122
|
+
style: {
|
|
123
|
+
font: {
|
|
124
|
+
size: 14,
|
|
125
|
+
},
|
|
126
|
+
color: 'white',
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
propertyDefinition: itemType.typeProperties.find((p) => p.slug === 'planningLevel1'),
|
|
131
|
+
typeRootSlug: 'item',
|
|
132
|
+
slug: 'planningLevel1',
|
|
133
|
+
includeLabel: true,
|
|
134
|
+
style: {
|
|
135
|
+
font: {
|
|
136
|
+
size: 14,
|
|
137
|
+
},
|
|
138
|
+
color: 'white',
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
],
|
|
142
|
+
};
|
|
143
|
+
const documentTemplateDefinition = {
|
|
144
|
+
frameOrientation: interfaces_1.Orientation.HORIZONTAL,
|
|
145
|
+
frameSize: { width: 1200, height: 675 },
|
|
146
|
+
framePadding: 30,
|
|
147
|
+
frameGroupHeaderTemplate: {
|
|
148
|
+
style: {
|
|
149
|
+
color: '#ffffff',
|
|
150
|
+
font: {
|
|
151
|
+
size: 20,
|
|
152
|
+
},
|
|
153
|
+
backgroundColor: 'rgba(0, 0, 0, 0.8)',
|
|
154
|
+
},
|
|
155
|
+
size: {
|
|
156
|
+
height: 60,
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
frameInfoPanelTemplate: {
|
|
160
|
+
panelDocumentTemplate: {
|
|
161
|
+
style: {
|
|
162
|
+
color: '#ffffff',
|
|
163
|
+
font: {
|
|
164
|
+
size: 20,
|
|
165
|
+
},
|
|
166
|
+
backgroundColor: 'rgba(0, 0, 0, 0.8)',
|
|
167
|
+
border: {
|
|
168
|
+
radius: 4,
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
size: {
|
|
172
|
+
width: 250,
|
|
173
|
+
height: 400,
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
propertyTemplate: PANEL_PROPERTY_TEMPLATE,
|
|
177
|
+
},
|
|
178
|
+
componentGridTemplate: {
|
|
179
|
+
gridDimensions: { cols: 3, rows: 1 },
|
|
180
|
+
componentPadding: 5,
|
|
181
|
+
componentTemplate: {
|
|
182
|
+
propertyTemplate: PROPERTY_COMPONENT_TEMPLATE,
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
};
|
|
186
|
+
const groupingProperties = [
|
|
187
|
+
{
|
|
188
|
+
propertyDefinition: itemType.typeProperties.find((p) => p.slug === 'category'),
|
|
189
|
+
typeRootSlug: 'item',
|
|
190
|
+
sort: sdk_1.SortOrderOptions.ASC,
|
|
191
|
+
values: null,
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
propertyDefinition: itemType.typeProperties.find((p) => p.slug === 'name'),
|
|
195
|
+
typeRootSlug: 'item',
|
|
196
|
+
sort: sdk_1.SortOrderOptions.ASC,
|
|
197
|
+
values: null,
|
|
198
|
+
},
|
|
199
|
+
];
|
|
200
|
+
documentTemplateDefinition.componentGridTemplate.componentTemplate.propertyTemplate = PROPERTY_COMPONENT_TEMPLATE;
|
|
201
|
+
const dataGroup = yield getDataGroupStructure(assortmentId, groupingProperties, documentTemplateDefinition);
|
|
202
|
+
const params = {
|
|
203
|
+
startingCoordinates: { x: 500, y: 500 },
|
|
204
|
+
data: {
|
|
205
|
+
dataGroup,
|
|
206
|
+
},
|
|
207
|
+
documentTemplateDefinition,
|
|
208
|
+
};
|
|
209
|
+
const frames = showcase_frame_generator_1.ShowcaseFrameGenerator.generateFrames(params);
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
function loginSDK(orgSlug) {
|
|
213
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
214
|
+
const config = {
|
|
215
|
+
email: 'brian@vibeiq.com',
|
|
216
|
+
password: process.env.CONTRAIL_PW,
|
|
217
|
+
orgSlug: orgSlug,
|
|
218
|
+
};
|
|
219
|
+
yield (0, sdk_1.login)(config);
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
function getAssortmentItems(assortmentId) {
|
|
223
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
224
|
+
const assortment = yield new sdk_1.Entities().get({
|
|
225
|
+
entityName: 'assortment',
|
|
226
|
+
id: assortmentId,
|
|
227
|
+
relations: ['assortmentItems', 'assortmentItems.item', 'assortmentItems.projectItem'],
|
|
228
|
+
});
|
|
229
|
+
let assortmentItems = assortment.assortmentItems;
|
|
230
|
+
if (assortment.itemsDownloadURL) {
|
|
231
|
+
const response = yield fetch(assortment.itemsDownloadURL);
|
|
232
|
+
assortmentItems = yield response.json();
|
|
233
|
+
}
|
|
234
|
+
return assortmentItems;
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
function getDataGroupStructure(assortmentId, groupingProperties, template) {
|
|
238
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
239
|
+
const assortmentItems = yield getAssortmentItems(assortmentId);
|
|
240
|
+
const data = fromAssortmentModelToItemModel(assortmentItems);
|
|
241
|
+
const leafNodeDataCount = template.componentGridTemplate.gridDimensions.cols * template.componentGridTemplate.gridDimensions.rows;
|
|
242
|
+
return data_grouping_1.DataGroupGenerator.buildDataGroupStructure(data, groupingProperties, leafNodeDataCount);
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
function fromAssortmentModelToItemModel(data) {
|
|
246
|
+
const results = [];
|
|
247
|
+
data.forEach((ai) => {
|
|
248
|
+
results.push({
|
|
249
|
+
item: ai.item,
|
|
250
|
+
projectItem: ai.projectItem,
|
|
251
|
+
viewable: ai.item,
|
|
252
|
+
assortmentItem: ai,
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
return results;
|
|
256
|
+
}
|
|
257
|
+
run();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { DocumentGenerationOptions } from './interfaces';
|
|
2
|
-
import { DocumentFrame } from './frames/frame';
|
|
3
|
-
export declare class ShowcaseFrameGenerator {
|
|
4
|
-
constructor();
|
|
5
|
-
static generateFrames(options: DocumentGenerationOptions): Array<DocumentFrame>;
|
|
6
|
-
private static getFrameGroups;
|
|
7
|
-
private static getLeafGroupsFromGroups;
|
|
8
|
-
}
|
|
1
|
+
import { DocumentGenerationOptions } from './interfaces';
|
|
2
|
+
import { DocumentFrame } from './frames/frame';
|
|
3
|
+
export declare class ShowcaseFrameGenerator {
|
|
4
|
+
constructor();
|
|
5
|
+
static generateFrames(options: DocumentGenerationOptions): Array<DocumentFrame>;
|
|
6
|
+
private static getFrameGroups;
|
|
7
|
+
private static getLeafGroupsFromGroups;
|
|
8
|
+
}
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ShowcaseFrameGenerator = void 0;
|
|
4
|
-
const frame_1 = require("./frames/frame");
|
|
5
|
-
const frame_generator_1 = require("./frames/frame-generator");
|
|
6
|
-
class ShowcaseFrameGenerator {
|
|
7
|
-
constructor() { }
|
|
8
|
-
static generateFrames(options) {
|
|
9
|
-
const frames = [];
|
|
10
|
-
const structure = options.data.dataGroup;
|
|
11
|
-
const template = options.documentTemplateDefinition;
|
|
12
|
-
const frameTemplate = options.frameTemplate;
|
|
13
|
-
const groups = this.getFrameGroups(structure);
|
|
14
|
-
for (let group of groups) {
|
|
15
|
-
const showcaseFrame = frame_generator_1.FrameGenerator.generateFrameContentForGroup(new frame_1.ShowcaseFrame(), group, template, frameTemplate);
|
|
16
|
-
console.log('showcaseFrame: ', showcaseFrame);
|
|
17
|
-
frames.push(showcaseFrame);
|
|
18
|
-
}
|
|
19
|
-
return frames;
|
|
20
|
-
}
|
|
21
|
-
static getFrameGroups(groupStructure) {
|
|
22
|
-
return this.getLeafGroupsFromGroups(groupStructure.rootGroup.subGroups, groupStructure.depth, 0);
|
|
23
|
-
}
|
|
24
|
-
static getLeafGroupsFromGroups(groups, totalDepth, currentDepth, groupName = null) {
|
|
25
|
-
const currentGroupName = groupName;
|
|
26
|
-
const leafGroups = [];
|
|
27
|
-
for (let group of groups) {
|
|
28
|
-
if (currentDepth === 0) {
|
|
29
|
-
groupName = null;
|
|
30
|
-
}
|
|
31
|
-
if (currentDepth === totalDepth) {
|
|
32
|
-
group.name = !groupName ? group.name : groupName + ' / ' + group.name;
|
|
33
|
-
leafGroups.push(group);
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
if (currentDepth < totalDepth - 1)
|
|
37
|
-
groupName = !currentGroupName ? group.name : currentGroupName + ' / ' + group.name;
|
|
38
|
-
leafGroups.push(...this.getLeafGroupsFromGroups(group.subGroups, totalDepth, currentDepth + 1, groupName));
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return leafGroups;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
exports.ShowcaseFrameGenerator = ShowcaseFrameGenerator;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ShowcaseFrameGenerator = void 0;
|
|
4
|
+
const frame_1 = require("./frames/frame");
|
|
5
|
+
const frame_generator_1 = require("./frames/frame-generator");
|
|
6
|
+
class ShowcaseFrameGenerator {
|
|
7
|
+
constructor() { }
|
|
8
|
+
static generateFrames(options) {
|
|
9
|
+
const frames = [];
|
|
10
|
+
const structure = options.data.dataGroup;
|
|
11
|
+
const template = options.documentTemplateDefinition;
|
|
12
|
+
const frameTemplate = options.frameTemplate;
|
|
13
|
+
const groups = this.getFrameGroups(structure);
|
|
14
|
+
for (let group of groups) {
|
|
15
|
+
const showcaseFrame = frame_generator_1.FrameGenerator.generateFrameContentForGroup(new frame_1.ShowcaseFrame((group === null || group === void 0 ? void 0 : group.name) || ''), group, template, frameTemplate);
|
|
16
|
+
console.log('showcaseFrame: ', showcaseFrame);
|
|
17
|
+
frames.push(showcaseFrame);
|
|
18
|
+
}
|
|
19
|
+
return frames;
|
|
20
|
+
}
|
|
21
|
+
static getFrameGroups(groupStructure) {
|
|
22
|
+
return this.getLeafGroupsFromGroups(groupStructure.rootGroup.subGroups, groupStructure.depth, 0);
|
|
23
|
+
}
|
|
24
|
+
static getLeafGroupsFromGroups(groups, totalDepth, currentDepth, groupName = null) {
|
|
25
|
+
const currentGroupName = groupName;
|
|
26
|
+
const leafGroups = [];
|
|
27
|
+
for (let group of groups) {
|
|
28
|
+
if (currentDepth === 0) {
|
|
29
|
+
groupName = null;
|
|
30
|
+
}
|
|
31
|
+
if (currentDepth === totalDepth) {
|
|
32
|
+
group.name = !groupName ? group.name : groupName + ' / ' + group.name;
|
|
33
|
+
leafGroups.push(group);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
if (currentDepth < totalDepth - 1)
|
|
37
|
+
groupName = !currentGroupName ? group.name : currentGroupName + ' / ' + group.name;
|
|
38
|
+
leafGroups.push(...this.getLeafGroupsFromGroups(group.subGroups, totalDepth, currentDepth + 1, groupName));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return leafGroups;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.ShowcaseFrameGenerator = ShowcaseFrameGenerator;
|