@@ -55,28 +55,90 @@ index 4c3b118..f6d4f2d 100644
55
55
if (result.Total > 0 && result.Async && result.Total == result.Finished) {
56
56
result.Finished--;
57
57
diff --git a/node_modules/vlocity/lib/datapacksbuilder.js b/node_modules/vlocity/lib/datapacksbuilder.js
58
- index 7ab38ff..76c8b6f 100644
58
+ index 7ab38ff..d19bced 100644
59
59
--- a/node_modules/vlocity/lib/datapacksbuilder.js
60
60
+++ b/node_modules/vlocity/lib/datapacksbuilder.js
61
61
@@ -14,7 +14,7 @@ var DataPacksBuilder = module.exports = function(vlocity) {
62
62
63
63
this.compileQueue = []; // array with files that require compilation
64
64
65
65
- this.defaultdatapack = fs.readFileSync(path.join(__dirname, 'defaultdatapack.json'), 'utf8');
66
- + this.defaultdatapack = require('./defaultdatapack.json');
66
+ + this.defaultdatapack = JSON.stringify( require('./defaultdatapack.json') );
67
67
68
68
this.dataPackSizes = {};
69
69
70
- @@ -347,7 +347,7 @@ DataPacksBuilder.prototype.getFileData = function() {
70
+ @@ -347,34 +347,53 @@ DataPacksBuilder.prototype.getFileData = function() {
71
71
return this.allFileDataMap[path.normalize(pathString).toLowerCase()];
72
72
}
73
73
74
74
- DataPacksBuilder.prototype.setFileData = async function(filePath, filePath, encoding) {
75
+ - var data = await fs.readFile(filePath, encoding);
75
76
+ DataPacksBuilder.prototype.setFileData = async function(filePath, encoding) {
76
- var data = await fs.readFile(filePath, encoding);
77
+ + //const data = await fs.readFile(filePath, encoding);
78
+ + const fileKey = path.normalize(filePath).toLowerCase();
79
+ + const isDatapackMeta = fileKey.endsWith('_datapack.json') || fileKey.endsWith('.json');
77
80
78
81
if (!this.allFileDataMap) {
79
- @@ -387,7 +387,7 @@ DataPacksBuilder.prototype.loadFilesAtPath = async function(srcpath, jobInfo, da
82
+ this.allFileDataMap = {};
83
+ }
84
+
85
+ - this.allFileDataMap[path.normalize(filePath).toLowerCase()] = data;
86
+ -
87
+ - try {
88
+ - var dataPack = JSON.parse(data);
89
+ -
90
+ - if (dataPack) {
91
+ - if (!this.recordSourceKeyToFilePath) {
92
+ - this.recordSourceKeyToFilePath = {};
93
+ + // Define transparent lazy property on the all file datamap
94
+ + Object.defineProperty(this.allFileDataMap, fileKey, {
95
+ + get() {
96
+ + // Initlize lazy loader cache on allFileDataMap obj
97
+ + const cache = this['__cache'] || (this['__cache'] = new Map());
98
+ + let fileData = cache.get(fileKey);
99
+ + if (!fileData) {
100
+ + // Ideally we make this an async function but for now
101
+ + // keep it sync for simplicty and backawrd compaitiblity
102
+ + fileData = fs.readFileSync(filePath, encoding);
103
+ + cache.set(fileKey, fileData);
104
+ }
105
+ + return fileData;
106
+ + }
107
+ + });
108
+
109
+ - if (dataPack instanceof Array) {
110
+ - for (data of dataPack) {
111
+ - if (data.VlocityRecordSourceKey) {
112
+ - this.recordSourceKeyToFilePath[data.VlocityRecordSourceKey] = path.normalize(filePath);
113
+ + if (isDatapackMeta) {
114
+ + try {
115
+ + var dataPack = JSON.parse(this.allFileDataMap[fileKey]);
116
+ + if (dataPack) {
117
+ + if (!this.recordSourceKeyToFilePath) {
118
+ + this.recordSourceKeyToFilePath = {};
119
+ + }
120
+ +
121
+ + if (dataPack instanceof Array) {
122
+ + for (data of dataPack) {
123
+ + if (data.VlocityRecordSourceKey) {
124
+ + this.recordSourceKeyToFilePath[data.VlocityRecordSourceKey] = path.normalize(filePath);
125
+ + }
126
+ }
127
+ + } else if (dataPack.VlocityRecordSourceKey){
128
+ + this.recordSourceKeyToFilePath[dataPack.VlocityRecordSourceKey] = path.normalize(filePath);
129
+ }
130
+ - } else if (dataPack.VlocityRecordSourceKey){
131
+ - this.recordSourceKeyToFilePath[dataPack.VlocityRecordSourceKey] = path.normalize(filePath);
132
+ }
133
+ + } catch (e) {
134
+ + VlocityUtils.error(`Unable to parse datapack meta file: ${path.basename(filePath)}`, e)
135
+ }
136
+ - } catch (e) {}
137
+ + }
138
+ }
139
+
140
+ DataPacksBuilder.prototype.loadFilesAtPath = async function(srcpath, jobInfo, dataPackKey) {
141
+ @@ -387,7 +406,7 @@ DataPacksBuilder.prototype.loadFilesAtPath = async function(srcpath, jobInfo, da
80
142
encoding = 'utf8';
81
143
}
82
144
var filemapkey = path.normalize(path.join(srcpath, filename));
@@ -85,7 +147,7 @@ index 7ab38ff..76c8b6f 100644
85
147
}
86
148
87
149
if (filePromises.length > 0) {
88
- @@ -707,12 +707 ,19 @@ DataPacksBuilder.prototype.getNextImports = function(importPath, jobInfo, curren
150
+ @@ -707,12 +726 ,19 @@ DataPacksBuilder.prototype.getNextImports = function(importPath, jobInfo, curren
89
151
return;
90
152
}
91
153
@@ -110,7 +172,7 @@ index 7ab38ff..76c8b6f 100644
110
172
}
111
173
});
112
174
113
- @@ -770,6 +777 ,7 @@ DataPacksBuilder.prototype.getNextImports = function(importPath, jobInfo, curren
175
+ @@ -770,6 +796 ,7 @@ DataPacksBuilder.prototype.getNextImports = function(importPath, jobInfo, curren
114
176
&& jobInfo.currentStatus[referenceKey]
115
177
&& !(jobInfo.currentStatus[referenceKey] == 'Success'
116
178
|| jobInfo.currentStatus[referenceKey] == 'Header')) {
@@ -132,7 +194,7 @@ index f475d46..4aabfe9 100644
132
194
133
195
DataPacksErrorHandling.prototype.getSanitizedErrorMessage = async function(jobInfo, dataPack) {
134
196
diff --git a/node_modules/vlocity/lib/datapacksjob.js b/node_modules/vlocity/lib/datapacksjob.js
135
- index b4f97c8..f10bf9b 100644
197
+ index b4f97c8..b0b3b7c 100644
136
198
--- a/node_modules/vlocity/lib/datapacksjob.js
137
199
+++ b/node_modules/vlocity/lib/datapacksjob.js
138
200
@@ -7,8 +7,8 @@ var childProcess = require('child_process');
@@ -156,17 +218,38 @@ index b4f97c8..f10bf9b 100644
156
218
};
157
219
158
220
var MAX_PER_GROUP = 10;
159
- @@ -2039,7 +2040,7 @@ DataPacksJob.prototype.deployPack = async function(inputMap) {
221
+ @@ -1076,7 +1077,10 @@ DataPacksJob.prototype.exportGroup = async function(inputMap) {
222
+ return false;
223
+ }
224
+
225
+ - VlocityUtils.success('Exporting', dataPack.VlocityDataPackType, this.vlocity.datapacksutils.getDisplayName(dataPack));
226
+ + var name = this.vlocity.datapacksutils.getDisplayName(dataPack);
227
+ + if (name) {
228
+ + VlocityUtils.success('Exporting', dataPack.VlocityDataPackType, name);
229
+ + }
230
+
231
+ return true;
232
+ });
233
+ @@ -1892,6 +1896,7 @@ DataPacksJob.prototype.deployPack = async function(inputMap) {
234
+
235
+ let result = await this.vlocity.datapacks.import(dataJson, this.getOptionsFromJobInfo(jobInfo));
236
+
237
+ +
238
+ await new Promise(resolve => setTimeout(resolve, 1));
239
+
240
+ // Prevent endless deploy loops due to server side issues
241
+ @@ -2039,7 +2044,8 @@ DataPacksJob.prototype.deployPack = async function(inputMap) {
160
242
throw e;
161
243
}
162
244
163
245
- VlocityUtils.error('Error', 'Deploying Pack', e.stack);
164
246
+ VlocityUtils.error('Error', 'Deploying Pack', e.stack || e);
247
+ + throw e;
165
248
}
166
249
}
167
250
168
251
diff --git a/node_modules/vlocity/lib/datapacksutils.js b/node_modules/vlocity/lib/datapacksutils.js
169
- index 16b7f2e..e97f6ea 100644
252
+ index 16b7f2e..18493f0 100644
170
253
--- a/node_modules/vlocity/lib/datapacksutils.js
171
254
+++ b/node_modules/vlocity/lib/datapacksutils.js
172
255
@@ -22,7 +22,7 @@ var DataPacksUtils = module.exports = function(vlocity) {
@@ -178,6 +261,16 @@ index 16b7f2e..e97f6ea 100644
178
261
179
262
this.runJavaScriptModules = {};
180
263
264
+ @@ -975,6 +975,9 @@ DataPacksUtils.prototype.getDisplayName = function(dataPack) {
265
+ dataPackKey = dataPack.VlocityDataPackKey.substring(dataPack.VlocityDataPackKey.indexOf('/') + 1);
266
+ } else if (dataPack.VlocityDataPackKeyForManifest) {
267
+ dataPackKey = dataPack.VlocityDataPackKeyForManifest.substring(dataPack.VlocityDataPackKeyForManifest.indexOf('/') + 1);
268
+ + if (dataPackKey == 'null') {
269
+ + dataPackKey = null;
270
+ + }
271
+ } else if (dataPack.VlocityRecordSourceKey) {
272
+ dataPackKey = dataPack.VlocityRecordSourceKey.substring(dataPack.VlocityRecordSourceKey.indexOf('/') + 1);
273
+ }
181
274
diff --git a/node_modules/vlocity/lib/datapacktypes/attributecategory.js b/node_modules/vlocity/lib/datapacktypes/attributecategory.js
182
275
index d1849c0..af04645 100644
183
276
--- a/node_modules/vlocity/lib/datapacktypes/attributecategory.js
0 commit comments