Skip to content

Commit b0ed113

Browse files
committed
Support cancellation of all data pack job types.
Update Icons to match new VSCode icons (1.37+). Add Vlocity build tools patch to lazy load datapack files. Add support exporting and importing using job files; mind that it will use the project path as set in vscode. Run each Vlocity command in a separate instance, this avoid potential conflicts when running parallel jobs. Fix previous Vlocity patch did no convert datapack defaults back to a string.
1 parent 2714b81 commit b0ed113

18 files changed

+198
-878
lines changed

commands.yaml

+8-2
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ vlocity.datapackExplorer.refresh:
149149
when: view == datapackExplorer
150150
vlocity.datapackExplorer.openSalesforce:
151151
title: View in Salesforce
152-
icon: resources/{type}/external-link-small.svg
152+
icon: resources/{type}/link-external.svg
153153
menus:
154154
- menu: commandPalette
155155
when: false
@@ -168,4 +168,10 @@ vlocity.jobExplorer.refresh:
168168
- menu: view/title
169169
group: navigation
170170
when: view == jobExplorer
171-
171+
vlocity.jobExplorer.run:
172+
title: Run job
173+
icon: resources/{type}/start.svg
174+
menus:
175+
- menu: view/item/context
176+
group: inline
177+
when: viewItem == vlocity:jobYaml

package.json

+17-3
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@
5050
"onCommand:vlocity.datapackExplorer.refresh",
5151
"onCommand:vlocity.datapackExplorer.openSalesforce",
5252
"onCommand:vlocity.jobExplorer.refresh",
53-
"onCommand:vlocity.destroyMetadata"
53+
"onCommand:vlocity.destroyMetadata",
54+
"onCommand:vlocity.jobExplorer.run"
5455
],
5556
"main": "./out/vlocode",
5657
"contributes": {
@@ -172,8 +173,8 @@
172173
"command": "vlocity.datapackExplorer.openSalesforce",
173174
"title": "View in Salesforce",
174175
"icon": {
175-
"light": "resources/light/external-link-small.svg",
176-
"dark": "resources/dark/external-link-small.svg"
176+
"light": "resources/light/link-external.svg",
177+
"dark": "resources/dark/link-external.svg"
177178
}
178179
},
179180
{
@@ -183,6 +184,14 @@
183184
"light": "resources/light/refresh.svg",
184185
"dark": "resources/dark/refresh.svg"
185186
}
187+
},
188+
{
189+
"command": "vlocity.jobExplorer.run",
190+
"title": "Run job",
191+
"icon": {
192+
"light": "resources/light/start.svg",
193+
"dark": "resources/dark/start.svg"
194+
}
186195
}
187196
],
188197
"menus": {
@@ -357,6 +366,11 @@
357366
"command": "vlocity.datapackExplorer.openSalesforce",
358367
"group": "v_vlocity",
359368
"when": "viewItem == vlocity:datapack:object"
369+
},
370+
{
371+
"command": "vlocity.jobExplorer.run",
372+
"group": "inline",
373+
"when": "viewItem == vlocity:jobYaml"
360374
}
361375
],
362376
"view/title": [

patches/vlocity+1.11.12.patch

+103-10
Original file line numberDiff line numberDiff line change
@@ -55,28 +55,90 @@ index 4c3b118..f6d4f2d 100644
5555
if (result.Total > 0 && result.Async && result.Total == result.Finished) {
5656
result.Finished--;
5757
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
5959
--- a/node_modules/vlocity/lib/datapacksbuilder.js
6060
+++ b/node_modules/vlocity/lib/datapacksbuilder.js
6161
@@ -14,7 +14,7 @@ var DataPacksBuilder = module.exports = function(vlocity) {
6262

6363
this.compileQueue = []; // array with files that require compilation
6464

6565
- this.defaultdatapack = fs.readFileSync(path.join(__dirname, 'defaultdatapack.json'), 'utf8');
66-
+ this.defaultdatapack = require('./defaultdatapack.json');
66+
+ this.defaultdatapack = JSON.stringify(require('./defaultdatapack.json'));
6767

6868
this.dataPackSizes = {};
6969

70-
@@ -347,7 +347,7 @@ DataPacksBuilder.prototype.getFileData = function() {
70+
@@ -347,34 +347,53 @@ DataPacksBuilder.prototype.getFileData = function() {
7171
return this.allFileDataMap[path.normalize(pathString).toLowerCase()];
7272
}
7373

7474
-DataPacksBuilder.prototype.setFileData = async function(filePath, filePath, encoding) {
75+
- var data = await fs.readFile(filePath, encoding);
7576
+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');
7780

7881
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
80142
encoding = 'utf8';
81143
}
82144
var filemapkey = path.normalize(path.join(srcpath, filename));
@@ -85,7 +147,7 @@ index 7ab38ff..76c8b6f 100644
85147
}
86148

87149
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
89151
return;
90152
}
91153

@@ -110,7 +172,7 @@ index 7ab38ff..76c8b6f 100644
110172
}
111173
});
112174

113-
@@ -770,6 +777,7 @@ DataPacksBuilder.prototype.getNextImports = function(importPath, jobInfo, curren
175+
@@ -770,6 +796,7 @@ DataPacksBuilder.prototype.getNextImports = function(importPath, jobInfo, curren
114176
&& jobInfo.currentStatus[referenceKey]
115177
&& !(jobInfo.currentStatus[referenceKey] == 'Success'
116178
|| jobInfo.currentStatus[referenceKey] == 'Header')) {
@@ -132,7 +194,7 @@ index f475d46..4aabfe9 100644
132194

133195
DataPacksErrorHandling.prototype.getSanitizedErrorMessage = async function(jobInfo, dataPack) {
134196
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
136198
--- a/node_modules/vlocity/lib/datapacksjob.js
137199
+++ b/node_modules/vlocity/lib/datapacksjob.js
138200
@@ -7,8 +7,8 @@ var childProcess = require('child_process');
@@ -156,17 +218,38 @@ index b4f97c8..f10bf9b 100644
156218
};
157219

158220
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) {
160242
throw e;
161243
}
162244

163245
- VlocityUtils.error('Error', 'Deploying Pack', e.stack);
164246
+ VlocityUtils.error('Error', 'Deploying Pack', e.stack || e);
247+
+ throw e;
165248
}
166249
}
167250

168251
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
170253
--- a/node_modules/vlocity/lib/datapacksutils.js
171254
+++ b/node_modules/vlocity/lib/datapacksutils.js
172255
@@ -22,7 +22,7 @@ var DataPacksUtils = module.exports = function(vlocity) {
@@ -178,6 +261,16 @@ index 16b7f2e..e97f6ea 100644
178261

179262
this.runJavaScriptModules = {};
180263

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+
}
181274
diff --git a/node_modules/vlocity/lib/datapacktypes/attributecategory.js b/node_modules/vlocity/lib/datapacktypes/attributecategory.js
182275
index d1849c0..af04645 100644
183276
--- a/node_modules/vlocity/lib/datapacktypes/attributecategory.js

0 commit comments

Comments
 (0)