@salesforce/plugin-omnistudio-migration-tool 1.1.1 → 1.2.1
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/CHANGELOG.md +1 -1
- package/README.md +19 -48
- package/lib/commands/omnistudio/migration/migrate.js +48 -28
- package/lib/commands/omnistudio/migration/migrate.js.map +1 -1
- package/lib/migration/base.d.ts +1 -0
- package/lib/migration/base.js +5 -0
- package/lib/migration/base.js.map +1 -1
- package/lib/migration/dataraptor.js +49 -49
- package/lib/migration/dataraptor.js.map +1 -1
- package/lib/migration/flexcard.d.ts +3 -0
- package/lib/migration/flexcard.js +75 -21
- package/lib/migration/flexcard.js.map +1 -1
- package/lib/migration/omniscript.d.ts +12 -2
- package/lib/migration/omniscript.js +50 -31
- package/lib/migration/omniscript.js.map +1 -1
- package/lib/utils/net/index.d.ts +1 -0
- package/lib/utils/net/index.js +18 -5
- package/lib/utils/net/index.js.map +1 -1
- package/lib/utils/query/index.d.ts +9 -0
- package/lib/utils/query/index.js +37 -1
- package/lib/utils/query/index.js.map +1 -1
- package/lib/utils/resultsbuilder/index.js +3 -2
- package/lib/utils/resultsbuilder/index.js.map +1 -1
- package/messages/migrate.json +3 -1
- package/oclif.manifest.json +1 -1
- package/package.json +4 -4
- package/lib/migration/drbulkdata.d.ts +0 -19
- package/lib/migration/drbulkdata.js +0 -88
- package/lib/migration/drbulkdata.js.map +0 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -1,18 +1,31 @@
|
|
|
1
1
|
OmniStudio Migration Tool
|
|
2
2
|
=========================
|
|
3
3
|
|
|
4
|
-
This repository contains the code required to enable the OmniStudio Migration Tool SFDX plugin.
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
### Before You Begin
|
|
6
|
+
1. Confirm you have an OmniStudio Admin license.
|
|
7
|
+
2. Enable Standard OmniStudio Runtime in Setup > OmniStudio Settings.
|
|
8
|
+
|
|
9
|
+
## Running SFDX plugin
|
|
7
10
|
|
|
8
11
|
1. Install SFDX cli using the official documentation located [here](https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_setup_install_cli.htm).
|
|
9
12
|
2. Authenticate your SFDX cli into the org you are going to use for development. You can follow authentication steps [here](https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_auth_web.htm).
|
|
10
|
-
3.
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
3. In a new terminal session, install the plugin using the following command
|
|
14
|
+
```
|
|
15
|
+
sfdx plugins:install @salesforce/plugin-omnistudio-migration-tool
|
|
13
16
|
```
|
|
14
|
-
|
|
17
|
+
4. To run the migration tool, run the following command from your command line tool:
|
|
18
|
+
```
|
|
19
|
+
// To migrate everything
|
|
20
|
+
sfdx omnistudio:migration:migrate -u YOUR_ORG_USERNAME@DOMAIN.COM --namespace=VLOCITY_PACKAGE_NAMESPACE
|
|
21
|
+
|
|
22
|
+
//to migrate specific components: FlexCards, DataRaptors, Integration Procedures, or OmniScripts, add the following parameters:
|
|
23
|
+
--only=dr
|
|
24
|
+
--only=ip
|
|
25
|
+
--only=os
|
|
26
|
+
--only=fc
|
|
15
27
|
```
|
|
28
|
+
5. An HTML page will be open in your default browser with the results of your migration job.
|
|
16
29
|
|
|
17
30
|
### Usage & parameters
|
|
18
31
|
|
|
@@ -39,45 +52,3 @@ OPTIONS
|
|
|
39
52
|
this command invocation
|
|
40
53
|
|
|
41
54
|
```
|
|
42
|
-
|
|
43
|
-
### Folder structure
|
|
44
|
-
```
|
|
45
|
-
-
|
|
46
|
-
- .vscode VSCode configuration folder
|
|
47
|
-
- bin Tools required to run in developer mode
|
|
48
|
-
- messages JSON files with user messages used in the plugin
|
|
49
|
-
- src
|
|
50
|
-
- commands SFDX plugin commands
|
|
51
|
-
- mappings A list of mappings between vertical and standard objects
|
|
52
|
-
- migration OmniStudio Migration Tool code
|
|
53
|
-
- utils Utilities (network, debugging, logging, etc.)
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
_See code: [src/commands/hello/org.ts](https://github.com/agarcia-sf/omnistudio-migration-tool/blob/v0.0.0/src/commands/hello/org.ts)_
|
|
59
|
-
<!-- commandsstop -->
|
|
60
|
-
<!-- debugging-your-plugin -->
|
|
61
|
-
# Debugging your plugin
|
|
62
|
-
We recommend using the Visual Studio Code (VS Code) IDE for your plugin development. Included in the `.vscode` directory of this plugin is a `launch.json` config file, which allows you to attach a debugger to the node process when running your commands.
|
|
63
|
-
|
|
64
|
-
To debug the `hello:org` command:
|
|
65
|
-
1. Start the inspector
|
|
66
|
-
|
|
67
|
-
If you linked your plugin to the sfdx cli, call your command with the `dev-suspend` switch:
|
|
68
|
-
```sh-session
|
|
69
|
-
$ sfdx hello:org -u myOrg@example.com --dev-suspend
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
Alternatively, to call your command using the `bin/run` script, set the `NODE_OPTIONS` environment variable to `--inspect-brk` when starting the debugger:
|
|
73
|
-
```sh-session
|
|
74
|
-
$ NODE_OPTIONS=--inspect-brk bin/run hello:org -u myOrg@example.com
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
2. Set some breakpoints in your command code
|
|
78
|
-
3. Click on the Debug icon in the Activity Bar on the side of VS Code to open up the Debug view.
|
|
79
|
-
4. In the upper left hand corner of VS Code, verify that the "Attach to Remote" launch configuration has been chosen.
|
|
80
|
-
5. Hit the green play button to the left of the "Attach to Remote" launch configuration window. The debugger should now be suspended on the first line of the program.
|
|
81
|
-
6. Hit the green play button at the top middle of VS Code (this play button will be to the right of the play button that you clicked in step #5).
|
|
82
|
-
<br><img src=".images/vscodeScreenshot.png" width="480" height="278"><br>
|
|
83
|
-
Congrats, you are debugging!
|
|
@@ -1,11 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright (c) 2020, salesforce.com, inc.
|
|
4
|
-
* All rights reserved.
|
|
5
|
-
* Licensed under the BSD 3-Clause license.
|
|
6
|
-
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
|
-
*/
|
|
8
|
-
/* eslint-disable */
|
|
9
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
3
|
if (k2 === undefined) k2 = k;
|
|
11
4
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
@@ -29,6 +22,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
29
22
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
30
23
|
};
|
|
31
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
26
|
+
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
27
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
28
|
+
/*
|
|
29
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
|
30
|
+
* All rights reserved.
|
|
31
|
+
* Licensed under the BSD 3-Clause license.
|
|
32
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
33
|
+
*/
|
|
32
34
|
const os = __importStar(require("os"));
|
|
33
35
|
const command_1 = require("@salesforce/command");
|
|
34
36
|
const core_1 = require("@salesforce/core");
|
|
@@ -46,10 +48,11 @@ core_1.Messages.importMessagesDirectory(__dirname);
|
|
|
46
48
|
// or any library that is using the messages framework can also be loaded this way.
|
|
47
49
|
const messages = core_1.Messages.loadMessages('@salesforce/plugin-omnistudio-migration-tool', 'migrate');
|
|
48
50
|
class Migrate extends basecommand_1.default {
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
49
52
|
async run() {
|
|
50
53
|
const namespace = (this.flags.namespace || 'vlocity_ins');
|
|
51
|
-
const apiVersion = (this.flags.apiversion ||
|
|
52
|
-
const migrateOnly = (this.flags.only ||
|
|
54
|
+
const apiVersion = (this.flags.apiversion || '55.0');
|
|
55
|
+
const migrateOnly = (this.flags.only || '');
|
|
53
56
|
// this.org is guaranteed because requiresUsername=true, as opposed to supportsUsername
|
|
54
57
|
const conn = this.org.getConnection();
|
|
55
58
|
conn.setApiVersion(apiVersion);
|
|
@@ -60,12 +63,12 @@ class Migrate extends basecommand_1.default {
|
|
|
60
63
|
let migrationObjects = [];
|
|
61
64
|
if (!migrateOnly) {
|
|
62
65
|
await namecheck.checkName('DRBundle__c');
|
|
63
|
-
await namecheck.checkName('VlocityCard__c');
|
|
64
66
|
await namecheck.checkName('OmniScript__c');
|
|
67
|
+
await namecheck.checkName('VlocityCard__c');
|
|
65
68
|
migrationObjects = [
|
|
66
|
-
new dataraptor_1.DataRaptorMigrationTool(namespace, conn, this.logger, messages),
|
|
67
69
|
new flexcard_1.CardMigrationTool(namespace, conn, this.logger, messages),
|
|
68
|
-
new omniscript_1.OmniScriptMigrationTool(omniscript_1.OmniScriptExportType.All, namespace, conn, this.logger, messages)
|
|
70
|
+
new omniscript_1.OmniScriptMigrationTool(omniscript_1.OmniScriptExportType.All, namespace, conn, this.logger, messages),
|
|
71
|
+
new dataraptor_1.DataRaptorMigrationTool(namespace, conn, this.logger, messages),
|
|
69
72
|
];
|
|
70
73
|
}
|
|
71
74
|
else {
|
|
@@ -93,25 +96,42 @@ class Migrate extends basecommand_1.default {
|
|
|
93
96
|
// Migrate individual objects
|
|
94
97
|
const debugTimer = utils_1.DebugTimer.getInstance();
|
|
95
98
|
let objectMigrationResults = [];
|
|
96
|
-
|
|
99
|
+
// We need to truncate the standard objects first
|
|
100
|
+
let allTruncateComplete = true;
|
|
101
|
+
for (const cls of migrationObjects) {
|
|
97
102
|
try {
|
|
103
|
+
debugTimer.lap('Truncating: ' + cls.getName());
|
|
98
104
|
await cls.truncate();
|
|
99
|
-
debugTimer.lap('Migrating: ' + cls.getName());
|
|
100
|
-
const results = await cls.migrate();
|
|
101
|
-
objectMigrationResults = objectMigrationResults.concat(results.map(r => {
|
|
102
|
-
return {
|
|
103
|
-
name: r.name,
|
|
104
|
-
data: this.mergeRecordAndUploadResults(r, cls),
|
|
105
|
-
};
|
|
106
|
-
}));
|
|
107
105
|
}
|
|
108
106
|
catch (ex) {
|
|
107
|
+
allTruncateComplete = false;
|
|
109
108
|
objectMigrationResults.push({
|
|
110
109
|
name: cls.getName(),
|
|
111
|
-
errors: [ex.message]
|
|
110
|
+
errors: [ex.message],
|
|
112
111
|
});
|
|
113
112
|
}
|
|
114
113
|
}
|
|
114
|
+
if (allTruncateComplete) {
|
|
115
|
+
for (const cls of migrationObjects) {
|
|
116
|
+
try {
|
|
117
|
+
debugTimer.lap('Migrating: ' + cls.getName());
|
|
118
|
+
const results = await cls.migrate();
|
|
119
|
+
objectMigrationResults = objectMigrationResults.concat(results.map((r) => {
|
|
120
|
+
return {
|
|
121
|
+
name: r.name,
|
|
122
|
+
data: this.mergeRecordAndUploadResults(r, cls),
|
|
123
|
+
};
|
|
124
|
+
}));
|
|
125
|
+
}
|
|
126
|
+
catch (ex) {
|
|
127
|
+
this.logger.error(JSON.stringify(ex));
|
|
128
|
+
objectMigrationResults.push({
|
|
129
|
+
name: cls.getName(),
|
|
130
|
+
errors: [ex.message],
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
115
135
|
// Stop the debug timer
|
|
116
136
|
const timer = utils_1.DebugTimer.getInstance().stop();
|
|
117
137
|
await resultsbuilder_1.ResultsBuilder.generate(objectMigrationResults, conn.instanceUrl);
|
|
@@ -121,17 +141,17 @@ class Migrate extends basecommand_1.default {
|
|
|
121
141
|
return { objectMigrationResults };
|
|
122
142
|
}
|
|
123
143
|
mergeRecordAndUploadResults(migrationResults, migrationTool) {
|
|
124
|
-
|
|
125
|
-
for (
|
|
144
|
+
const mergedResults = [];
|
|
145
|
+
for (const record of Array.from(migrationResults.records.values())) {
|
|
126
146
|
const obj = {
|
|
127
147
|
id: record['Id'],
|
|
128
148
|
name: migrationTool.getRecordName(record),
|
|
129
149
|
status: 'Skipped',
|
|
130
150
|
errors: record['errors'],
|
|
131
|
-
migratedId: undefined
|
|
151
|
+
migratedId: undefined,
|
|
132
152
|
};
|
|
133
153
|
if (migrationResults.results.has(record['Id'])) {
|
|
134
|
-
|
|
154
|
+
const recordResults = migrationResults.results.get(record['Id']);
|
|
135
155
|
obj.status = !recordResults || recordResults.hasErrors ? 'Error' : 'Complete';
|
|
136
156
|
obj.errors = obj.errors || recordResults.errors;
|
|
137
157
|
obj.migratedId = recordResults.id;
|
|
@@ -152,7 +172,7 @@ Migrate.flagsConfig = {
|
|
|
152
172
|
}),
|
|
153
173
|
only: command_1.flags.string({
|
|
154
174
|
char: 'o',
|
|
155
|
-
description: messages.getMessage('onlyFlagDescription')
|
|
156
|
-
})
|
|
175
|
+
description: messages.getMessage('onlyFlagDescription'),
|
|
176
|
+
}),
|
|
157
177
|
};
|
|
158
178
|
//# sourceMappingURL=migrate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate.js","sourceRoot":"","sources":["../../../../src/commands/omnistudio/migration/migrate.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"migrate.js","sourceRoot":"","sources":["../../../../src/commands/omnistudio/migration/migrate.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAA4D;AAC5D,+DAA+D;AAC/D,uDAAuD;AACvD;;;;;GAKG;AACH,uCAAyB;AACzB,iDAA4C;AAC5C,2CAA4C;AAC5C,qCAAmC;AACnC,oEAAsD;AACtD,kFAA+E;AAC/E,8DAAwE;AACxE,0CAAgF;AAEhF,kEAA+D;AAC/D,0DAAgE;AAChE,8DAA8F;AAE9F,wDAAwD;AACxD,eAAQ,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;AAE5C,iGAAiG;AACjG,mFAAmF;AACnF,MAAM,QAAQ,GAAG,eAAQ,CAAC,YAAY,CAAC,8CAA8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e,mBAAW,GAAG,QAAQ,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC;AAExD,gBAAQ,GAAG,QAAQ,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;AAEzD,YAAI,GAAG,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;AAEvB,mBAAW,GAAG;IAC7B,SAAS,EAAE,eAAK,CAAC,MAAM,CAAC;QACtB,IAAI,EAAE,GAAG;QACT,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,0BAA0B,CAAC;KAC7D,CAAC;IACF,IAAI,EAAE,eAAK,CAAC,MAAM,CAAC;QACjB,IAAI,EAAE,GAAG;QACT,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,qBAAqB,CAAC;KACxD,CAAC;CACH,CAAC"}
|
package/lib/migration/base.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export declare class BaseMigrationTool {
|
|
|
18
18
|
*/
|
|
19
19
|
protected getCleanFieldName(fieldName: string): string;
|
|
20
20
|
protected validMetaDataName(name: string): boolean;
|
|
21
|
+
protected cleanName(name: string): string;
|
|
21
22
|
protected truncate(objectName: string): Promise<void>;
|
|
22
23
|
/**
|
|
23
24
|
* Stores any errors found while validating the source record in the record object
|
package/lib/migration/base.js
CHANGED
|
@@ -37,6 +37,11 @@ class BaseMigrationTool {
|
|
|
37
37
|
}
|
|
38
38
|
return false;
|
|
39
39
|
}
|
|
40
|
+
cleanName(name) {
|
|
41
|
+
if (!name)
|
|
42
|
+
return '';
|
|
43
|
+
return name.replace(/[^a-z0-9]+/gi, '');
|
|
44
|
+
}
|
|
40
45
|
async truncate(objectName) {
|
|
41
46
|
utils_1.DebugTimer.getInstance().lap('Truncating ' + objectName);
|
|
42
47
|
const ids = await utils_1.QueryTools.queryIds(this.connection, objectName);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/mig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I,KAAK,CAAC,qBAAqB,GAAG,UAAU,CAAC,CAAC;SACrD;IACH,CAAC;IAED;;;;;OAKG;IACO,eAAe,CAAC,MAAe,EAAE,GAAG,MAAgB;QAC5D,MAAM,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC;IAC5B,CAAC;;AA1EH,8CA2EC;AA1E2B,6BAAW,GAAG,GAAG,CAAC"}
|
|
@@ -7,6 +7,7 @@ exports.DataRaptorMigrationTool = void 0;
|
|
|
7
7
|
const DRBundle_1 = __importDefault(require("../mappings/DRBundle"));
|
|
8
8
|
const DRMapItem_1 = __importDefault(require("../mappings/DRMapItem"));
|
|
9
9
|
const utils_1 = require("../utils");
|
|
10
|
+
const net_1 = require("../utils/net");
|
|
10
11
|
const base_1 = require("./base");
|
|
11
12
|
class DataRaptorMigrationTool extends base_1.BaseMigrationTool {
|
|
12
13
|
getName() {
|
|
@@ -26,7 +27,6 @@ class DataRaptorMigrationTool extends base_1.BaseMigrationTool {
|
|
|
26
27
|
}
|
|
27
28
|
async truncate() {
|
|
28
29
|
await super.truncate(DataRaptorMigrationTool.OMNIDATATRANSFORM_NAME);
|
|
29
|
-
await super.truncate(DataRaptorMigrationTool.OMNIDATATRANSFORMITEM_NAME);
|
|
30
30
|
}
|
|
31
31
|
async migrate() {
|
|
32
32
|
return [await this.MigrateDataRaptorData()];
|
|
@@ -34,6 +34,7 @@ class DataRaptorMigrationTool extends base_1.BaseMigrationTool {
|
|
|
34
34
|
async MigrateDataRaptorData() {
|
|
35
35
|
let originalDrRecords = new Map();
|
|
36
36
|
let drUploadInfo = new Map();
|
|
37
|
+
const duplicatedNames = new Set();
|
|
37
38
|
// Query all dataraptors and the respective items
|
|
38
39
|
utils_1.DebugTimer.getInstance().lap('Query data raptors');
|
|
39
40
|
const dataRaptors = await this.getAllDataRaptors();
|
|
@@ -41,19 +42,12 @@ class DataRaptorMigrationTool extends base_1.BaseMigrationTool {
|
|
|
41
42
|
// Start transforming each dataRaptor
|
|
42
43
|
utils_1.DebugTimer.getInstance().lap('Transform Data Raptor');
|
|
43
44
|
for (let dr of dataRaptors) {
|
|
44
|
-
const mappedRecords = [], originalRecords = new Map();
|
|
45
45
|
// Skip if Type is "Migration"
|
|
46
46
|
if (dr[this.namespacePrefix + 'Type__c'] === 'Migration')
|
|
47
47
|
continue;
|
|
48
48
|
const recordId = dr['Id'];
|
|
49
49
|
const name = dr['Name'];
|
|
50
|
-
if (!this.validMetaDataName(name)) {
|
|
51
|
-
this.setRecordErrors(dr, this.messages.getMessage('invalidDataRaptorName'));
|
|
52
|
-
originalRecords.set(recordId, dr);
|
|
53
|
-
continue;
|
|
54
|
-
}
|
|
55
50
|
const typeKey = dr[this.namespacePrefix + 'Type__c'];
|
|
56
|
-
const inputTypeKey = dr[this.namespacePrefix + 'InputType__c'];
|
|
57
51
|
const outputTypeKey = dr[this.namespacePrefix + 'OutputType__c'];
|
|
58
52
|
const targetOutputDocumentIdentifier = dr[this.namespacePrefix + 'TargetOutDocuSignTemplateId__c'];
|
|
59
53
|
const targetOutputFileName = dr[this.namespacePrefix + 'TargetOutPdfDocName__c'];
|
|
@@ -61,50 +55,57 @@ class DataRaptorMigrationTool extends base_1.BaseMigrationTool {
|
|
|
61
55
|
dr[this.namespacePrefix + 'Type__c'] = 'Extract';
|
|
62
56
|
}
|
|
63
57
|
// Fix up Input/Output types for older DR's
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
else {
|
|
77
|
-
dr[this.namespacePrefix + 'OutputType__c'] = 'JSON';
|
|
78
|
-
}
|
|
79
|
-
break;
|
|
80
|
-
case 'Extract (JSON)':
|
|
81
|
-
dr[this.namespacePrefix + 'Type__c'] = 'Extract';
|
|
82
|
-
dr[this.namespacePrefix + 'InputType__c'] = 'JSON';
|
|
58
|
+
switch (typeKey) {
|
|
59
|
+
case 'Transform':
|
|
60
|
+
dr[this.namespacePrefix + 'Type__c'] = 'Transform';
|
|
61
|
+
dr[this.namespacePrefix + 'InputType__c'] = 'JSON';
|
|
62
|
+
if (targetOutputDocumentIdentifier !== null) {
|
|
63
|
+
dr[this.namespacePrefix + 'OutputType__c'] = 'DocuSign';
|
|
64
|
+
}
|
|
65
|
+
else if (targetOutputFileName !== null &&
|
|
66
|
+
(outputTypeKey !== 'PDF' || outputTypeKey !== 'Document Template')) {
|
|
67
|
+
dr[this.namespacePrefix + 'OutputType__c'] = 'PDF';
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
83
70
|
dr[this.namespacePrefix + 'OutputType__c'] = 'JSON';
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
71
|
+
}
|
|
72
|
+
break;
|
|
73
|
+
case 'Extract (JSON)':
|
|
74
|
+
dr[this.namespacePrefix + 'Type__c'] = 'Extract';
|
|
75
|
+
dr[this.namespacePrefix + 'InputType__c'] = 'JSON';
|
|
76
|
+
dr[this.namespacePrefix + 'OutputType__c'] = 'JSON';
|
|
77
|
+
break;
|
|
78
|
+
case 'Load (JSON)':
|
|
79
|
+
dr[this.namespacePrefix + 'Type__c'] = 'Load';
|
|
80
|
+
dr[this.namespacePrefix + 'InputType__c'] = 'JSON';
|
|
81
|
+
dr[this.namespacePrefix + 'OutputType__c'] = 'SObject';
|
|
82
|
+
break;
|
|
83
|
+
case 'Load (Object)':
|
|
84
|
+
dr[this.namespacePrefix + 'Type__c'] = 'Load';
|
|
85
|
+
dr[this.namespacePrefix + 'InputType__c'] = 'SObject';
|
|
86
|
+
dr[this.namespacePrefix + 'OutputType__c'] = 'SObject';
|
|
87
|
+
break;
|
|
88
|
+
default: // no-op;
|
|
97
89
|
}
|
|
98
|
-
|
|
90
|
+
// Transform the data raptor
|
|
91
|
+
const transformedDataRaptor = this.mapDataRaptorRecord(dr);
|
|
92
|
+
// Verify duplicated names before trying to submitt
|
|
93
|
+
if (duplicatedNames.has(transformedDataRaptor['Name'])) {
|
|
94
|
+
this.setRecordErrors(dr, this.messages.getMessage('duplicatedDrName'));
|
|
95
|
+
originalDrRecords.set(recordId, dr);
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
duplicatedNames.add(transformedDataRaptor['Name']);
|
|
99
99
|
// Create a map of the original records
|
|
100
|
-
|
|
100
|
+
originalDrRecords.set(recordId, dr);
|
|
101
101
|
// Save the data raptors
|
|
102
|
-
const drUploadResponse = await this.uploadTransformedData(DataRaptorMigrationTool.OMNIDATATRANSFORM_NAME, { mappedRecords, originalRecords });
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
// const drUploadResponse = await this.uploadTransformedData(DataRaptorMigrationTool.OMNIDATATRANSFORM_NAME, { mappedRecords, originalRecords });
|
|
103
|
+
const drUploadResponse = await net_1.NetUtils.createOne(this.connection, DataRaptorMigrationTool.OMNIDATATRANSFORM_NAME, recordId, transformedDataRaptor);
|
|
104
|
+
if (drUploadResponse && drUploadResponse.success === true) {
|
|
105
|
+
const items = await this.getItemsForDataRaptor(dataRaptorItemsData, name, drUploadResponse.id);
|
|
106
|
+
// Move the items
|
|
105
107
|
await this.uploadTransformedData(DataRaptorMigrationTool.OMNIDATATRANSFORMITEM_NAME, items);
|
|
106
|
-
|
|
107
|
-
drUploadInfo = new Map([...Array.from(drUploadInfo.entries()), ...Array.from(drUploadResponse.entries())]);
|
|
108
|
+
drUploadInfo.set(recordId, drUploadResponse);
|
|
108
109
|
}
|
|
109
110
|
}
|
|
110
111
|
;
|
|
@@ -128,8 +129,6 @@ class DataRaptorMigrationTool extends base_1.BaseMigrationTool {
|
|
|
128
129
|
async getItemsForDataRaptor(dataRaptorItems, drName, drId) {
|
|
129
130
|
//Query all Elements
|
|
130
131
|
const mappedRecords = [], originalRecords = new Map();
|
|
131
|
-
// Start transforming each dataRaptor
|
|
132
|
-
utils_1.DebugTimer.getInstance().lap('Transform items');
|
|
133
132
|
dataRaptorItems.forEach(drItem => {
|
|
134
133
|
const recordId = drItem['Id'];
|
|
135
134
|
// const itemParentId = drItem[nsPrefix + 'OmniDataTransformationId__c']
|
|
@@ -158,6 +157,7 @@ class DataRaptorMigrationTool extends base_1.BaseMigrationTool {
|
|
|
158
157
|
mappedObject[DRBundle_1.default[cleanFieldName]] = dataRaptorRecord[recordField];
|
|
159
158
|
}
|
|
160
159
|
});
|
|
160
|
+
mappedObject['Name'] = this.cleanName(mappedObject['Name']);
|
|
161
161
|
// BATCH framework requires that each record has an "attributes" property
|
|
162
162
|
mappedObject['attributes'] = {
|
|
163
163
|
type: DataRaptorMigrationTool.OMNIDATATRANSFORM_NAME,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataraptor.js","sourceRoot":"","sources":["../../src/migration/dataraptor.ts"],"names":[],"mappings":";;;;;;AAEA,oEAAoD;AACpD,sEAAsD;AACtD,oCAAkD;AAClD,iCAA2C;AAI3C,MAAa,uBAAwB,SAAQ,wBAAiB;IAQ7D,OAAO;QACN,OAAO,YAAY,CAAC;IACrB,CAAC;IAED,aAAa,CAAC,MAAc;QAC3B,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC;IACvB,CAAC;IAED,WAAW;QACV,OAAO,CAAC;gBACP,MAAM,EAAE,uBAAuB,CAAC,aAAa;gBAC7C,MAAM,EAAE,uBAAuB,CAAC,sBAAsB;aACtD,EAAE;gBACF,MAAM,EAAE,uBAAuB,CAAC,cAAc;gBAC9C,MAAM,EAAE,uBAAuB,CAAC,0BAA0B;aAC1D,CAAC,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,QAAQ;QACb,MAAM,KAAK,CAAC,QAAQ,CAAC,uBAAuB,CAAC,sBAAsB,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"dataraptor.js","sourceRoot":"","sources":["../../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B,GAAG,uBAAuB,CAAC"}
|
|
@@ -10,6 +10,9 @@ export declare class CardMigrationTool extends BaseMigrationTool implements Migr
|
|
|
10
10
|
migrate(): Promise<MigrationResult[]>;
|
|
11
11
|
private getAllActiveCards;
|
|
12
12
|
private uploadAllCards;
|
|
13
|
+
private uploadCard;
|
|
14
|
+
private getChildCards;
|
|
15
|
+
private updateChildCards;
|
|
13
16
|
private prepareCardData;
|
|
14
17
|
private mapVlocityCardRecord;
|
|
15
18
|
private getCardFields;
|
|
@@ -64,35 +64,86 @@ class CardMigrationTool extends base_1.BaseMigrationTool {
|
|
|
64
64
|
}
|
|
65
65
|
// Upload All the VlocityCard__c records to OmniUiCard
|
|
66
66
|
async uploadAllCards(cards) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
67
|
+
const cardsUploadInfo = new Map();
|
|
68
|
+
const originalRecords = new Map();
|
|
69
|
+
const uniqueNames = new Set();
|
|
70
|
+
for (let card of cards) {
|
|
71
|
+
await this.uploadCard(cards, card, cardsUploadInfo, originalRecords, uniqueNames);
|
|
72
|
+
}
|
|
73
|
+
return cardsUploadInfo;
|
|
74
|
+
}
|
|
75
|
+
async uploadCard(allCards, card, cardsUploadInfo, originalRecords, uniqueNames) {
|
|
76
|
+
const recordId = card['Id'];
|
|
77
|
+
// If we already uploaded this card, skip
|
|
78
|
+
if (cardsUploadInfo.has(recordId)) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const childCards = this.getChildCards(card);
|
|
82
|
+
if (childCards.length > 0) {
|
|
83
|
+
for (let childCardName of childCards) {
|
|
84
|
+
// Upload child cards
|
|
85
|
+
const childCard = allCards.find(c => c['Name'] === childCardName);
|
|
86
|
+
if (childCard) {
|
|
87
|
+
await this.uploadCard(allCards, childCard, cardsUploadInfo, originalRecords, uniqueNames);
|
|
78
88
|
}
|
|
79
89
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
90
|
+
this.updateChildCards(card);
|
|
91
|
+
}
|
|
92
|
+
// Perform the transformation
|
|
93
|
+
const transformedCard = this.mapVlocityCardRecord(card, cardsUploadInfo);
|
|
94
|
+
// Verify duplicated names
|
|
95
|
+
const transformedCardName = transformedCard['Name'];
|
|
96
|
+
const transformedCardAuthorName = transformedCard['AuthorName'];
|
|
97
|
+
if (uniqueNames.has(transformedCardName)) {
|
|
98
|
+
this.setRecordErrors(card, this.messages.getMessage('duplicatedCardName'));
|
|
99
|
+
originalRecords.set(recordId, card);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
// Save the name for duplicated names check
|
|
103
|
+
uniqueNames.add(transformedCardName);
|
|
104
|
+
// Create a map of the original records
|
|
105
|
+
originalRecords.set(recordId, card);
|
|
106
|
+
// Create card
|
|
107
|
+
const uploadResult = await net_1.NetUtils.createOne(this.connection, CardMigrationTool.OMNIUICARD_NAME, recordId, transformedCard);
|
|
108
|
+
if (uploadResult) {
|
|
109
|
+
// Fix errors
|
|
110
|
+
if (!uploadResult.success) {
|
|
111
|
+
uploadResult.errors = Array.isArray(uploadResult.errors) ? uploadResult.errors : [uploadResult.errors];
|
|
83
112
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
cardsUploadInfo = new Map([...Array.from(cardsUploadInfo.entries()), ...Array.from(cardsUploadResponse.entries())]);
|
|
113
|
+
// If name has been changed, add a warning message
|
|
114
|
+
if (transformedCardName !== card[this.namespacePrefix + 'Name']) {
|
|
115
|
+
uploadResult.errors.unshift('WARNING: Card name has been modified to fit naming rules: ' + transformedCardName);
|
|
88
116
|
}
|
|
89
|
-
|
|
90
|
-
|
|
117
|
+
if (transformedCardAuthorName !== card[this.namespacePrefix + 'Author__c']) {
|
|
118
|
+
uploadResult.errors.unshift('WARNING: Card author name has been modified to fit naming rules: ' + transformedCardAuthorName);
|
|
119
|
+
}
|
|
120
|
+
cardsUploadInfo.set(recordId, uploadResult);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
getChildCards(card) {
|
|
124
|
+
let childs = [];
|
|
125
|
+
const definition = JSON.parse(card[this.namespacePrefix + 'Definition__c']);
|
|
126
|
+
for (let state of (definition.states || [])) {
|
|
127
|
+
if (state.childCards && Array.isArray(state.childCards)) {
|
|
128
|
+
childs = childs.concat(state.childCards);
|
|
129
|
+
// Modify the name of the child cards
|
|
130
|
+
state.childCards = state.childCards.map(c => this.cleanName(c));
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return childs;
|
|
134
|
+
}
|
|
135
|
+
updateChildCards(card) {
|
|
136
|
+
const definition = JSON.parse(card[this.namespacePrefix + 'Definition__c']);
|
|
137
|
+
for (let state of (definition.states || [])) {
|
|
138
|
+
if (state.childCards && Array.isArray(state.childCards)) {
|
|
139
|
+
state.childCards = state.childCards.map(c => this.cleanName(c));
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
card[this.namespacePrefix + 'Definition__c'] = JSON.stringify(definition);
|
|
91
143
|
}
|
|
92
144
|
async prepareCardData(cards, cardsUploadInfo) {
|
|
93
145
|
const mappedRecords = [], originalRecords = new Map();
|
|
94
146
|
// Start transforming each Card
|
|
95
|
-
utils_1.DebugTimer.getInstance().lap('Transform cards');
|
|
96
147
|
for (let card of cards) {
|
|
97
148
|
const recordId = card['Id'];
|
|
98
149
|
// Perform the transformation
|
|
@@ -130,6 +181,9 @@ class CardMigrationTool extends base_1.BaseMigrationTool {
|
|
|
130
181
|
}
|
|
131
182
|
}
|
|
132
183
|
});
|
|
184
|
+
// Clean the name
|
|
185
|
+
mappedObject['Name'] = this.cleanName(mappedObject['Name']);
|
|
186
|
+
mappedObject['AuthorName'] = this.cleanName(mappedObject['AuthorName']);
|
|
133
187
|
mappedObject['attributes'] = {
|
|
134
188
|
type: CardMigrationTool.OMNIUICARD_NAME,
|
|
135
189
|
referenceId: cardRecord['Id']
|