@pdfbutler/migration-cli 0.0.25 → 0.0.27
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/lib/commands/butler/pb/admincredentials.d.ts +0 -5
- package/lib/commands/butler/pb/admincredentials.js +10 -79
- package/lib/commands/butler/pb/admincredentials.js.map +1 -1
- package/lib/commands/butler/pb/adminsettings.d.ts +0 -5
- package/lib/commands/butler/pb/adminsettings.js +10 -79
- package/lib/commands/butler/pb/adminsettings.js.map +1 -1
- package/lib/commands/butler/pb/export.d.ts +0 -5
- package/lib/commands/butler/pb/export.js +31 -139
- package/lib/commands/butler/pb/export.js.map +1 -1
- package/lib/commands/butler/pb/exportpack.d.ts +0 -5
- package/lib/commands/butler/pb/exportpack.js +22 -101
- package/lib/commands/butler/pb/exportpack.js.map +1 -1
- package/lib/commands/butler/pb/import.d.ts +0 -5
- package/lib/commands/butler/pb/import.js +37 -102
- package/lib/commands/butler/pb/import.js.map +1 -1
- package/lib/commands/butler/pb/importpack.d.ts +0 -5
- package/lib/commands/butler/pb/importpack.js +20 -101
- package/lib/commands/butler/pb/importpack.js.map +1 -1
- package/lib/utils/authentication.d.ts +2 -0
- package/lib/utils/authentication.js +73 -0
- package/lib/utils/authentication.js.map +1 -0
- package/lib/utils/constants.d.ts +101 -0
- package/lib/utils/constants.js +105 -0
- package/lib/utils/constants.js.map +1 -0
- package/lib/utils/logger.d.ts +8 -0
- package/lib/utils/logger.js +43 -0
- package/lib/utils/logger.js.map +1 -0
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
|
@@ -19,92 +19,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
19
19
|
const sf_plugins_core_1 = require("@salesforce/sf-plugins-core");
|
|
20
20
|
const core_1 = require("@salesforce/core");
|
|
21
21
|
const fs = require("graceful-fs");
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const ERROR_VERSION = 'Verify that you have PDFButler version greater than v1.440.';
|
|
26
|
-
const MSG_CONNECTION_FAILED = 'Connection to Salesforce has been failed.';
|
|
27
|
-
const MSG_CREATION_CONNECTION = 'Creating Connection with the Salesforce org.';
|
|
28
|
-
const MSG_AUTHORIZATION = 'Authorization with the username: [VALUE].';
|
|
29
|
-
const MSG_NO_AUTH_PARAMS = 'No authentication parameters provided. Please provide either username or session and instance parameters.';
|
|
30
|
-
const MSG_RUN_AUTH_COMMAND = 'Run the command "sf org login web" before authenticating with the target.';
|
|
31
|
-
const MSG_CHECK_SESSION_INSTANCE = 'Check if the session is up to date and if the instance is correct.';
|
|
22
|
+
const logger_1 = require("../../../utils/logger");
|
|
23
|
+
const constants_1 = require("../../../utils/constants");
|
|
24
|
+
const authentication_1 = require("../../../utils/authentication");
|
|
32
25
|
core_1.Messages.importMessagesDirectory(__dirname);
|
|
33
26
|
const messages = core_1.Messages.loadMessages('@pdfbutler/migration-cli', 'butler.pb.importpack');
|
|
34
27
|
class ButlerPbImportpack extends sf_plugins_core_1.SfCommand {
|
|
35
|
-
static log(message, type = 'info') {
|
|
36
|
-
const prefix = type === 'info' ? '[INFO]' : type === 'warn' ? '[WARN]' : '[ERROR]';
|
|
37
|
-
console.log(`${prefix} ${message}`);
|
|
38
|
-
}
|
|
39
|
-
static isBlank(value) {
|
|
40
|
-
return value?.trim() === ''
|
|
41
|
-
|| value === null
|
|
42
|
-
|| value === undefined;
|
|
43
|
-
}
|
|
44
|
-
static async authenticateWithTarget(username) {
|
|
45
|
-
try {
|
|
46
|
-
if (this.isLogsActive)
|
|
47
|
-
this.log(MSG_AUTHORIZATION.replace('[VALUE]', username));
|
|
48
|
-
const authInfo = await core_1.AuthInfo.create({ username });
|
|
49
|
-
if (this.isLogsActive)
|
|
50
|
-
this.log(MSG_CREATION_CONNECTION);
|
|
51
|
-
const connection = await core_1.Connection.create({ authInfo });
|
|
52
|
-
this.log(`Connected to ${username} (Org ID: ${authInfo.getFields().orgId})`);
|
|
53
|
-
return connection;
|
|
54
|
-
}
|
|
55
|
-
catch (error) {
|
|
56
|
-
this.log(MSG_RUN_AUTH_COMMAND, 'error');
|
|
57
|
-
throw new Error(MSG_CONNECTION_FAILED);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
static async authenticateWitsSession(session, instance) {
|
|
61
|
-
if (!this.isBlank(instance) && !this.isBlank(session)) {
|
|
62
|
-
const connection = await new jsforce.Connection({
|
|
63
|
-
instanceUrl: `${instance}`,
|
|
64
|
-
sessionId: `${session}`,
|
|
65
|
-
});
|
|
66
|
-
this.log(`Connected to ${connection.instanceUrl}`);
|
|
67
|
-
return connection;
|
|
68
|
-
}
|
|
69
|
-
else if (!this.isBlank(session) && this.isBlank(instance)) {
|
|
70
|
-
this.log('Instance URL (--instance) cannot be empty', 'error');
|
|
71
|
-
}
|
|
72
|
-
else if (this.isBlank(session) && !this.isBlank(instance)) {
|
|
73
|
-
this.log('Session Id (--session) cannot be empty', 'error');
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
this.log('Session Id and Instance URL (--session and --instance) cannot be empty', 'error');
|
|
77
|
-
}
|
|
78
|
-
this.log(MSG_CHECK_SESSION_INSTANCE, 'error');
|
|
79
|
-
throw new Error(MSG_CONNECTION_FAILED);
|
|
80
|
-
}
|
|
81
|
-
static async authenticate(username, session, instance) {
|
|
82
|
-
let connection;
|
|
83
|
-
if (this.isBlank(username) && (this.isBlank(session) || this.isBlank(instance))) {
|
|
84
|
-
throw new Error(MSG_NO_AUTH_PARAMS);
|
|
85
|
-
}
|
|
86
|
-
try {
|
|
87
|
-
if (this.isBlank(session) || this.isBlank(instance)) {
|
|
88
|
-
connection = await this.authenticateWithTarget(username);
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
connection = await this.authenticateWitsSession(session, instance);
|
|
92
|
-
}
|
|
93
|
-
return connection;
|
|
94
|
-
}
|
|
95
|
-
catch (error) {
|
|
96
|
-
throw new Error(MSG_CONNECTION_FAILED);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
28
|
static async getFilesInFolder(folderPath, packsToRetrieve) {
|
|
100
29
|
try {
|
|
101
30
|
if (!packsToRetrieve || packsToRetrieve.trim().length === 0) {
|
|
102
|
-
|
|
31
|
+
logger_1.Logger.error(constants_1.ERROR.BLANK_PACK_FLAG);
|
|
103
32
|
return [];
|
|
104
33
|
}
|
|
105
|
-
|
|
106
|
-
this.log('Retrieving items from the directory');
|
|
107
|
-
}
|
|
34
|
+
logger_1.Logger.info(constants_1.MESSAGE.RETRIEVING_ITEMS, this.isLogsActive);
|
|
108
35
|
const packs = packsToRetrieve.split(',').map(pack => pack.trim());
|
|
109
36
|
const fileList = fs.readdirSync(folderPath, { withFileTypes: true });
|
|
110
37
|
const foundFiles = fileList
|
|
@@ -115,7 +42,7 @@ class ButlerPbImportpack extends sf_plugins_core_1.SfCommand {
|
|
|
115
42
|
.map(file => file.name.replace('.json', ''));
|
|
116
43
|
const missingPacks = packs.filter(pack => !existingPackNames.includes(pack));
|
|
117
44
|
if (missingPacks.length > 0) {
|
|
118
|
-
|
|
45
|
+
logger_1.Logger.info(constants_1.MESSAGE.MISSING_PACKS.replace('[PACKS]', missingPacks.join(', ')));
|
|
119
46
|
}
|
|
120
47
|
if (missingPacks.length === fileList.length) {
|
|
121
48
|
return [];
|
|
@@ -124,27 +51,27 @@ class ButlerPbImportpack extends sf_plugins_core_1.SfCommand {
|
|
|
124
51
|
}
|
|
125
52
|
catch (error) {
|
|
126
53
|
const message = error instanceof Error ? error.message : String(error);
|
|
127
|
-
|
|
128
|
-
throw new Error(
|
|
54
|
+
logger_1.Logger.error(constants_1.ERROR.READING_FOLDER.replace('[MESSAGE]', message));
|
|
55
|
+
throw new Error(constants_1.ERROR.READING_FILES.replace('[FOLDER]', folderPath));
|
|
129
56
|
}
|
|
130
57
|
}
|
|
131
58
|
static async importPackData(connection, filePath) {
|
|
132
59
|
try {
|
|
133
60
|
const fileData = await fs.promises.readFile(filePath, 'utf8');
|
|
134
61
|
const parsedData = JSON.parse(fileData);
|
|
135
|
-
const response = await connection.apex.post(
|
|
136
|
-
|
|
62
|
+
const response = await connection.apex.post(constants_1.PATH.IMPORT_PACK, parsedData, { headers: { 'Content-Type': 'application/json' } });
|
|
63
|
+
logger_1.Logger.success(constants_1.MESSAGE.SUCCESS_IMPORT_PACK.replace('[PACK]', filePath));
|
|
137
64
|
return response;
|
|
138
65
|
}
|
|
139
66
|
catch (error) {
|
|
140
67
|
if (this.isLogsActive) {
|
|
141
68
|
const message = error instanceof Error ? error.message : String(error);
|
|
142
|
-
if (message.includes(
|
|
143
|
-
|
|
69
|
+
if (message.includes(constants_1.ERROR.URL_NOT_FOUND)) {
|
|
70
|
+
logger_1.Logger.error(`${constants_1.ERROR.URL_NOT_FOUND}. ${constants_1.ERROR.VERSION_TOO_LOW}`);
|
|
144
71
|
}
|
|
145
72
|
}
|
|
146
73
|
else {
|
|
147
|
-
|
|
74
|
+
logger_1.Logger.error(constants_1.ERROR.IMPORT_FILE);
|
|
148
75
|
}
|
|
149
76
|
}
|
|
150
77
|
}
|
|
@@ -156,24 +83,16 @@ class ButlerPbImportpack extends sf_plugins_core_1.SfCommand {
|
|
|
156
83
|
const session = flags.session;
|
|
157
84
|
const instance = flags.instance;
|
|
158
85
|
ButlerPbImportpack.isLogsActive = flags.logs;
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
ButlerPbImportpack.log(`Packs to import: "${packsToRetrieve}"`);
|
|
164
|
-
}
|
|
165
|
-
if (ButlerPbImportpack.isLogsActive) {
|
|
166
|
-
ButlerPbImportpack.log(`Folder to retrieve: "${folderPath}"`);
|
|
167
|
-
}
|
|
168
|
-
const connection = await ButlerPbImportpack.authenticate(targetUsername, session, instance);
|
|
86
|
+
logger_1.Logger.info(constants_1.MESSAGE.USERNAME.replace('[USERNAME]', targetUsername), ButlerPbImportpack.isLogsActive);
|
|
87
|
+
logger_1.Logger.info(constants_1.MESSAGE.PACKS_TO_IMPORT.replace('[PACKS]', packsToRetrieve), ButlerPbImportpack.isLogsActive);
|
|
88
|
+
logger_1.Logger.info(constants_1.MESSAGE.FOLDER_TO_RETRIEVE.replace('[FOLDER]', folderPath), ButlerPbImportpack.isLogsActive);
|
|
89
|
+
const connection = await (0, authentication_1.authenticate)(targetUsername, session, instance);
|
|
169
90
|
const files = await ButlerPbImportpack.getFilesInFolder(folderPath, packsToRetrieve);
|
|
170
91
|
if (!files || files.length === 0) {
|
|
171
|
-
|
|
92
|
+
logger_1.Logger.error(constants_1.ERROR.NO_FILES_IN_FOLDER.replace('[FOLDER]', folderPath));
|
|
172
93
|
return { success: false };
|
|
173
94
|
}
|
|
174
|
-
|
|
175
|
-
ButlerPbImportpack.log(`Files found in folder: ${files.length}`);
|
|
176
|
-
}
|
|
95
|
+
logger_1.Logger.info(constants_1.MESSAGE.FILES_IN_FOLDER.replace('[FILES]', String(files.length)), ButlerPbImportpack.isLogsActive);
|
|
177
96
|
try {
|
|
178
97
|
await Promise.all(files.map((filePath) => {
|
|
179
98
|
ButlerPbImportpack.importPackData(connection, filePath);
|
|
@@ -181,7 +100,7 @@ class ButlerPbImportpack extends sf_plugins_core_1.SfCommand {
|
|
|
181
100
|
}
|
|
182
101
|
catch (error) {
|
|
183
102
|
const message = error instanceof Error ? error.message : String(error);
|
|
184
|
-
|
|
103
|
+
logger_1.Logger.error(constants_1.ERROR.IMPORT_PROCESS.replace('[MESSAGE]', message));
|
|
185
104
|
return { success: false };
|
|
186
105
|
}
|
|
187
106
|
return { success: true };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"importpack.js","sourceRoot":"","sources":["../../../../src/commands/butler/pb/importpack.ts"],"names":[],"mappings":";;AAAA,uDAAuD;AACvD,wDAAwD;AACxD,4DAA4D;AAC5D,+BAA+B;AAC/B,2DAA2D;AAC3D,0DAA0D;AAC1D,qEAAqE;AACrE,sDAAsD;AACtD,+DAA+D;AAC/D,kDAAkD;AAClD,qDAAqD;AACrD,qCAA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AI;KACf,CAAC;IACF,MAAM,EAAE,uBAAK,CAAC,MAAM,CAAC;QACnB,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,sBAAsB,CAAC;QACpD,IAAI,EAAE,GAAG;QACT,QAAQ,EAAE,IAAI;KACf,CAAC;IACF,MAAM,EAAE,uBAAK,CAAC,MAAM,CAAC;QACnB,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,sBAAsB,CAAC;QACpD,IAAI,EAAE,GAAG;QACT,QAAQ,EAAE,KAAK;KAChB,CAAC;IACF,IAAI,EAAE,uBAAK,CAAC,OAAO,CAAC;QAClB,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,oBAAoB,CAAC;QAClD,IAAI,EAAE,GAAG;KACV,CAAC;IACF,OAAO,EAAE,uBAAK,CAAC,MAAM,CAAC;QACpB,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,uBAAuB,CAAC;KACtD,CAAC;IACF,QAAQ,EAAE,uBAAK,CAAC,MAAM,CAAC;QACrB,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,wBAAwB,CAAC;KACvD,CAAC;CACH,CAAC;AAEa,+BAAY,GAAG,KAAK,CAAC;kBAvCjB,kBAAkB"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
3
|
+
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
|
4
|
+
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
5
|
+
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
|
6
|
+
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
7
|
+
/* eslint-disable @typescript-eslint/require-await */
|
|
8
|
+
/* eslint-disable no-console */
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.authenticate = void 0;
|
|
11
|
+
const core_1 = require("@salesforce/core");
|
|
12
|
+
const constants_1 = require("../utils/constants");
|
|
13
|
+
const logger_1 = require("../utils/logger");
|
|
14
|
+
const jsforce = require('jsforce');
|
|
15
|
+
function isBlank(value) {
|
|
16
|
+
return value?.trim() === '' || value === null || value === undefined;
|
|
17
|
+
}
|
|
18
|
+
async function authenticateWithTarget(username) {
|
|
19
|
+
try {
|
|
20
|
+
const authInfo = await core_1.AuthInfo.create({ username });
|
|
21
|
+
const connection = await core_1.Connection.create({ authInfo });
|
|
22
|
+
logger_1.Logger.info(constants_1.MESSAGE.CONNECTED_TO_ORG
|
|
23
|
+
.replace('[USERNAME]', username)
|
|
24
|
+
.replace('ORG_ID', `${authInfo.getFields().orgId}`));
|
|
25
|
+
return connection;
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
logger_1.Logger.error(JSON.stringify(error, null, 2));
|
|
29
|
+
throw new Error(constants_1.ERROR.CONNECTION_FAILED);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
async function authenticateWithSession(session, instance) {
|
|
33
|
+
if (!isBlank(instance) && !isBlank(session)) {
|
|
34
|
+
const connection = new jsforce.Connection({
|
|
35
|
+
instanceUrl: instance,
|
|
36
|
+
sessionId: session,
|
|
37
|
+
});
|
|
38
|
+
if (instance != null) {
|
|
39
|
+
logger_1.Logger.info(constants_1.MESSAGE.CONNECTED_TO_INSTANCE.replace('[INSTANCE_URL]', instance));
|
|
40
|
+
}
|
|
41
|
+
return connection;
|
|
42
|
+
}
|
|
43
|
+
else if (!isBlank(session) && isBlank(instance)) {
|
|
44
|
+
logger_1.Logger.error(constants_1.ERROR.EMPTY_INSTANCE);
|
|
45
|
+
}
|
|
46
|
+
else if (isBlank(session) && !isBlank(instance)) {
|
|
47
|
+
logger_1.Logger.error(constants_1.ERROR.EMPTY_SESSION);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
logger_1.Logger.error(constants_1.ERROR.EMPTY_INSTANCE_AND_SESSION);
|
|
51
|
+
}
|
|
52
|
+
logger_1.Logger.error(constants_1.MESSAGE.CHECK_SESSION_INSTANCE);
|
|
53
|
+
throw new Error(constants_1.ERROR.CONNECTION_FAILED);
|
|
54
|
+
}
|
|
55
|
+
async function authenticate(username, session, instance) {
|
|
56
|
+
if (isBlank(username) && (isBlank(session) || isBlank(instance))) {
|
|
57
|
+
throw new Error(constants_1.ERROR.NO_AUTH_PARAMS);
|
|
58
|
+
}
|
|
59
|
+
try {
|
|
60
|
+
if (isBlank(session) || isBlank(instance)) {
|
|
61
|
+
return await authenticateWithTarget(username);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
return await authenticateWithSession(session, instance);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
console.log(err);
|
|
69
|
+
throw new Error(constants_1.ERROR.CONNECTION_FAILED);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.authenticate = authenticate;
|
|
73
|
+
//# sourceMappingURL=authentication.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authentication.js","sourceRoot":"","sources":["../../src/utils/authentication.ts"],"names":[],"mappings":";AAAA,uDAAuD;AACvD,wDAAwD;AACxD,+DAA+D;AAC/D,sDAAsD;AACtD,4DAA4D;AAC5D,qDAAqD;AACrD,+BAA+B;;;AAE/B,2CAA0E;AAC1E,kDAAoD;AACpD,4CAAyC;AACzC,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AAEnC,SAAS,OAAO,CAAC,KAAyB;IACxC,OAAO,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,CAAC;AACvE,CAAC;AAED,KAAK,UAAU,sBAAsB,CAAC,QAAgB;IACpD,IAAI;QACF,MAAM,QAAQ,GAAG,MAAM,eAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;QACrD,MAAM,UAAU,GAAG,MAAM,iBAAc,CAAC,MAAM,CAAC,EAAE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BAAK,CAAC,0BAA0B,CAAC,CAAC;KAChD;IAED,eAAM,CAAC,KAAK,CAAC,mBAAO,CAAC,sBAAsB,CAAC,CAAC;IAC7C,MAAM,IAAI,KAAK,CAAC,iBAAK,CAAC,iBAAiB,CAAC,CAAC;AAC3C,CAAC;AAEM,KAAK,UAAU,YAAY,CAChC,QAAgB,EAChB,OAAe,EACf,QAAgB;IAEhB,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAE;QAChE,MAAM,IAAI,KAAK,CAAC,iBAAK,CAAC,cAAc,CAAC,CAAC;KACvC;IAED,IAAI;QACF,IAAI,OAAO,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,EAAE;YACzC,OAAO,MAAM,sBAAsB,CAAC,QAAQ,CAAC,CAAC;SAC/C;aAAM;YACL,OAAO,MAAM,uBAAuB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;SACzD;KACF;IAAC,OAAO,GAAG,EAAE;QACZ,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAEjB,MAAM,IAAI,KAAK,CAAC,iBAAK,CAAC,iBAAiB,CAAC,CAAC;KAC1C;AACH,CAAC;AApBD,oCAoBC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
export declare const PATH: {
|
|
2
|
+
IMPORT_EXCEL: string;
|
|
3
|
+
IMPORT_WORD: string;
|
|
4
|
+
IMPORT_PPTX: string;
|
|
5
|
+
IMPORT_PDF: string;
|
|
6
|
+
IMPORT_EMAIL: string;
|
|
7
|
+
IMPORT_CSV: string;
|
|
8
|
+
EXPORT_DOC_CONFIG: string;
|
|
9
|
+
IMPORT_PACK: string;
|
|
10
|
+
EXPORT_PACK: string;
|
|
11
|
+
ADMIN: string;
|
|
12
|
+
};
|
|
13
|
+
export declare const ERROR: {
|
|
14
|
+
UNSUPPORTED_RECORD_TYPE: string;
|
|
15
|
+
CONNECTION_FAILED: string;
|
|
16
|
+
UNKNOWN_SERVER: string;
|
|
17
|
+
NO_AUTH_PARAMS: string;
|
|
18
|
+
NO_MATCHING_DOC_CONFIGS: string;
|
|
19
|
+
NO_MATCHING_FILES: string;
|
|
20
|
+
EXPORT_FAILED: string;
|
|
21
|
+
URL_NOT_FOUND: string;
|
|
22
|
+
VERSION_TOO_LOW: string;
|
|
23
|
+
ID_NOT_EXIST: string;
|
|
24
|
+
PACK_NOT_EXIST: string;
|
|
25
|
+
EMPTY_INSTANCE: string;
|
|
26
|
+
EMPTY_SESSION: string;
|
|
27
|
+
EMPTY_INSTANCE_AND_SESSION: string;
|
|
28
|
+
BLANK_PACK_FLAG: string;
|
|
29
|
+
READING_FOLDER: string;
|
|
30
|
+
READING_FILES: string;
|
|
31
|
+
IMPORT_FILE: string;
|
|
32
|
+
NO_FILES_IN_FOLDER: string;
|
|
33
|
+
IMPORT_PROCESS: string;
|
|
34
|
+
WRITE_DATA: string;
|
|
35
|
+
AUTH_ENV_VAR_REQUIRED: string;
|
|
36
|
+
WRITE_DATA_TO_PDF: string;
|
|
37
|
+
SAVING: string;
|
|
38
|
+
FAILED_TO_SAVE_FILE: string;
|
|
39
|
+
OUT_FLAG_REQUIRED: string;
|
|
40
|
+
EMPTY_PACK: string;
|
|
41
|
+
IMPORT_SETTINGS: string;
|
|
42
|
+
IMPORT_CREDENTIALS: string;
|
|
43
|
+
BLANK_BACKEND: string;
|
|
44
|
+
USER_NO_PERMISSIONS: string;
|
|
45
|
+
};
|
|
46
|
+
export declare const MESSAGE: {
|
|
47
|
+
CREATION_CONNECTION: string;
|
|
48
|
+
AUTHORIZATION: string;
|
|
49
|
+
RUN_AUTH_COMMAND: string;
|
|
50
|
+
CHECK_SESSION_INSTANCE: string;
|
|
51
|
+
CONNECTED_TO_ORG: string;
|
|
52
|
+
CONNECTED_TO_INSTANCE: string;
|
|
53
|
+
SPLITTED_DOC_CONFIGS: string;
|
|
54
|
+
EXPORTED_DOC_CONFIGS: string;
|
|
55
|
+
FOLDER_CREATED: string;
|
|
56
|
+
DOC_CONFIG_NO_BACKEND: string;
|
|
57
|
+
BACKEND_DATA_ARCHIVED: string;
|
|
58
|
+
USER_HAS_PERMISSIONS: string;
|
|
59
|
+
ARCHIVE_UNZIPPED: string;
|
|
60
|
+
ARCHIVE_RECORDED: string;
|
|
61
|
+
FETCH_DATA: string;
|
|
62
|
+
UNZIP_FILES: string;
|
|
63
|
+
SAVE_AS_ZIP: string;
|
|
64
|
+
SAVE_BACKEND: string;
|
|
65
|
+
PARTIAL_EXPORT_ACTIVE: string;
|
|
66
|
+
TRY_GET_DOC_CONFIG_BACKEND: string;
|
|
67
|
+
START_EXPORT_BACKEND: string;
|
|
68
|
+
RETRIEVING_ITEMS: string;
|
|
69
|
+
MISSING_PACKS: string;
|
|
70
|
+
USERNAME: string;
|
|
71
|
+
PACKS_TO_IMPORT: string;
|
|
72
|
+
PACKS_TO_EXPORT: string;
|
|
73
|
+
FOLDER_TO_RETRIEVE: string;
|
|
74
|
+
FOLDER_TO_OUTPUT: string;
|
|
75
|
+
FILES_IN_FOLDER: string;
|
|
76
|
+
SUCCESS_DATA_WRITTEN: string;
|
|
77
|
+
SUCCESS_IMPORT_PACK: string;
|
|
78
|
+
ENDPOINT_URL: string;
|
|
79
|
+
FINAL_URL: string;
|
|
80
|
+
CALL_SERVICE: string;
|
|
81
|
+
SAVING_TO_DIRECTORY: string;
|
|
82
|
+
DIRECTORY_HIERARCHY: string;
|
|
83
|
+
FILE_PATH: string;
|
|
84
|
+
SUCCESS_EXPORT_TO: string;
|
|
85
|
+
TRY_EXPORT_PACK: string;
|
|
86
|
+
USED_SHORT_PATH: string;
|
|
87
|
+
SENDING_TO_ENDPOINT: string;
|
|
88
|
+
SUCCESS_IMPORT_SETTINGS: string;
|
|
89
|
+
SUCCESS_IMPORT_CREDENTIALS: string;
|
|
90
|
+
};
|
|
91
|
+
export declare const RESULT: {
|
|
92
|
+
FAILED: string;
|
|
93
|
+
SUCCESS: string;
|
|
94
|
+
SUCCESS_WITH_WARNINGS: string;
|
|
95
|
+
};
|
|
96
|
+
export declare const PATTERN: {
|
|
97
|
+
DOC_CONFIG: RegExp;
|
|
98
|
+
};
|
|
99
|
+
export declare const CUT: {
|
|
100
|
+
AFTER: number;
|
|
101
|
+
};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CUT = exports.PATTERN = exports.RESULT = exports.MESSAGE = exports.ERROR = exports.PATH = void 0;
|
|
4
|
+
exports.PATH = {
|
|
5
|
+
IMPORT_EXCEL: 'config/xls/import-config',
|
|
6
|
+
IMPORT_WORD: 'config/import-config',
|
|
7
|
+
IMPORT_PPTX: 'config/pptx/import-config',
|
|
8
|
+
IMPORT_PDF: 'config/pdf/import-config',
|
|
9
|
+
IMPORT_EMAIL: 'config/import-config',
|
|
10
|
+
IMPORT_CSV: 'config/csv/import-config',
|
|
11
|
+
EXPORT_DOC_CONFIG: '/cadmus_core/DocConfig/Export2/',
|
|
12
|
+
IMPORT_PACK: '/services/apexrest/cadmus_core/Pack/Import',
|
|
13
|
+
EXPORT_PACK: '/services/apexrest/cadmus_core/Pack/Export/',
|
|
14
|
+
ADMIN: '/services/apexrest/cadmus_core/Manage/Admin',
|
|
15
|
+
};
|
|
16
|
+
exports.ERROR = {
|
|
17
|
+
UNSUPPORTED_RECORD_TYPE: 'Unsupported record type',
|
|
18
|
+
CONNECTION_FAILED: 'Connection to Salesforce failed.',
|
|
19
|
+
UNKNOWN_SERVER: 'An unexpected error occurred. Please contact support.',
|
|
20
|
+
NO_AUTH_PARAMS: 'Authentication parameters missing. Provide either username or session and instance.',
|
|
21
|
+
NO_MATCHING_DOC_CONFIGS: 'No matching DocConfig IDs found.',
|
|
22
|
+
NO_MATCHING_FILES: 'No matching files found',
|
|
23
|
+
EXPORT_FAILED: 'DocConfig export failed. Check the IDs and try again.',
|
|
24
|
+
URL_NOT_FOUND: 'Could not find a matching URL.',
|
|
25
|
+
VERSION_TOO_LOW: 'Verify that you have PDFButler version greater than v1.440.',
|
|
26
|
+
ID_NOT_EXIST: 'No rows found for the given ID.',
|
|
27
|
+
PACK_NOT_EXIST: 'Cannot find the Pack with Customer Pack ID: [PACK_ID].',
|
|
28
|
+
EMPTY_INSTANCE: 'Instance URL (--instance) cannot be empty.',
|
|
29
|
+
EMPTY_SESSION: 'Session ID (--session) cannot be empty.',
|
|
30
|
+
EMPTY_INSTANCE_AND_SESSION: 'Both Session ID and Instance URL cannot be empty.',
|
|
31
|
+
BLANK_PACK_FLAG: 'Flag "pack" cannot be blank.',
|
|
32
|
+
READING_FOLDER: 'Error reading folder: [MESSAGE].',
|
|
33
|
+
READING_FILES: 'Failed to read files from folder: [FOLDER].',
|
|
34
|
+
IMPORT_FILE: 'Error while importing file.',
|
|
35
|
+
NO_FILES_IN_FOLDER: 'No files found in folder: [FOLDER].',
|
|
36
|
+
IMPORT_PROCESS: 'Error during import process: [MESSAGE].',
|
|
37
|
+
WRITE_DATA: 'Failed to write data to the target Salesforce org.',
|
|
38
|
+
AUTH_ENV_VAR_REQUIRED: '"auth-env-var" parameter is required when endpoint is provided.',
|
|
39
|
+
WRITE_DATA_TO_PDF: 'Failed to write data to the PDF Butler system.',
|
|
40
|
+
SAVING: 'Error while saving file: [MESSAGE].',
|
|
41
|
+
FAILED_TO_SAVE_FILE: 'Failed to save the file.',
|
|
42
|
+
OUT_FLAG_REQUIRED: 'The flag "out" cannot be empty.',
|
|
43
|
+
EMPTY_PACK: 'Exported pack data for Pack ID [PACK] is empty.',
|
|
44
|
+
IMPORT_SETTINGS: 'Failed while importing settings. Error: [MESSAGE].',
|
|
45
|
+
IMPORT_CREDENTIALS: 'Failed to import user credentials. Error: [MESSAGE].',
|
|
46
|
+
BLANK_BACKEND: 'One or more DocConfigs have no backend.',
|
|
47
|
+
USER_NO_PERMISSIONS: 'User does not have read/write permissions.',
|
|
48
|
+
};
|
|
49
|
+
exports.MESSAGE = {
|
|
50
|
+
CREATION_CONNECTION: 'Creating connection with the Salesforce org...',
|
|
51
|
+
AUTHORIZATION: 'Authorizing with username: [VALUE].',
|
|
52
|
+
RUN_AUTH_COMMAND: 'Run "sf org login web" before authenticating with the target.',
|
|
53
|
+
CHECK_SESSION_INSTANCE: 'Verify that the session is valid and the instance is correct.',
|
|
54
|
+
CONNECTED_TO_ORG: 'Connected to [USERNAME] (Org ID: [ORG_ID]).',
|
|
55
|
+
CONNECTED_TO_INSTANCE: 'Connected to instance: [INSTANCE_URL].',
|
|
56
|
+
SPLITTED_DOC_CONFIGS: 'DocConfig IDs after splitting: [VALUE].',
|
|
57
|
+
EXPORTED_DOC_CONFIGS: 'Exported DocConfigs: [VALUE].',
|
|
58
|
+
FOLDER_CREATED: 'Folder structure created at: [VALUE].',
|
|
59
|
+
DOC_CONFIG_NO_BACKEND: 'DocConfig with ID [VALUE] has no backend.',
|
|
60
|
+
BACKEND_DATA_ARCHIVED: 'Exported backend data has been archived.',
|
|
61
|
+
USER_HAS_PERMISSIONS: 'User has read/write permissions.',
|
|
62
|
+
ARCHIVE_UNZIPPED: 'Archive unzipped and stored locally.',
|
|
63
|
+
ARCHIVE_RECORDED: 'Archive stored locally.',
|
|
64
|
+
FETCH_DATA: 'Fetching data from the org...',
|
|
65
|
+
UNZIP_FILES: 'Unzipping files...',
|
|
66
|
+
SAVE_AS_ZIP: 'Saving as ZIP...',
|
|
67
|
+
SAVE_BACKEND: 'Saving backend only.',
|
|
68
|
+
PARTIAL_EXPORT_ACTIVE: 'Partial export active. DocConfigs without backend will not be exported.',
|
|
69
|
+
TRY_GET_DOC_CONFIG_BACKEND: 'Retrieving backend for DocConfig ID: [VALUE].',
|
|
70
|
+
START_EXPORT_BACKEND: 'Starting backend export for DocConfigs.',
|
|
71
|
+
RETRIEVING_ITEMS: 'Retrieving items from directory...',
|
|
72
|
+
MISSING_PACKS: 'Missing packs: [PACKS].',
|
|
73
|
+
USERNAME: 'Username: [USERNAME].',
|
|
74
|
+
PACKS_TO_IMPORT: 'Packs to import: [PACKS].',
|
|
75
|
+
PACKS_TO_EXPORT: 'Packs to export: [PACKS].',
|
|
76
|
+
FOLDER_TO_RETRIEVE: 'Retrieving from folder: [FOLDER].',
|
|
77
|
+
FOLDER_TO_OUTPUT: 'Output folder: [FOLDER].',
|
|
78
|
+
FILES_IN_FOLDER: 'Files found: [FILES].',
|
|
79
|
+
SUCCESS_DATA_WRITTEN: 'Data successfully written to the Salesforce org.',
|
|
80
|
+
SUCCESS_IMPORT_PACK: 'Successfully imported [PACK]',
|
|
81
|
+
ENDPOINT_URL: 'Endpoint base URL: [URL].',
|
|
82
|
+
FINAL_URL: 'Final URL: [URL].',
|
|
83
|
+
CALL_SERVICE: 'Calling external service...',
|
|
84
|
+
SAVING_TO_DIRECTORY: 'Saving to directory...',
|
|
85
|
+
DIRECTORY_HIERARCHY: 'Directory hierarchy: [PATH].',
|
|
86
|
+
FILE_PATH: 'File path: [PATH].',
|
|
87
|
+
SUCCESS_EXPORT_TO: 'Data successfully exported to: [PATH].',
|
|
88
|
+
TRY_EXPORT_PACK: 'Trying to export pack with ID: [PACK].',
|
|
89
|
+
USED_SHORT_PATH: 'Using short paths.',
|
|
90
|
+
SENDING_TO_ENDPOINT: 'Sending data to endpoint: [URL].',
|
|
91
|
+
SUCCESS_IMPORT_SETTINGS: 'Settings imported successfully.',
|
|
92
|
+
SUCCESS_IMPORT_CREDENTIALS: 'User credentials imported successfully.',
|
|
93
|
+
};
|
|
94
|
+
exports.RESULT = {
|
|
95
|
+
FAILED: 'FAILED',
|
|
96
|
+
SUCCESS: 'SUCCESS',
|
|
97
|
+
SUCCESS_WITH_WARNINGS: 'SUCCESS_WITH_WARNINGS',
|
|
98
|
+
};
|
|
99
|
+
exports.PATTERN = {
|
|
100
|
+
DOC_CONFIG: /([\w-]{36})/,
|
|
101
|
+
};
|
|
102
|
+
exports.CUT = {
|
|
103
|
+
AFTER: 150,
|
|
104
|
+
};
|
|
105
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/utils/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,IAAI,GAAG;IAClB,YAAY,EAAE,0BAA0B;IACxC,WAAW,EAAE,sBAAsB;IACnC,WAAW,EAAE,2BAA2B;IACxC,UAAU,EAAE,0BAA0B;IACtC,YAAY,EAAE,sBAAsB;IACpC,UAAU,EAAE,0BAA0B;IACtC,iBAAiB,EAAE,iCAAiC;IACpD,WAAW,EAAE,4CAA4C;IACzD,WAAW,EAAE,6CAA6C;IAC1D,KAAK,EAAE,6CAA6C;CACrD,CAAC;AAEW,QAAA,KAAK,GAAG;IACnB,uBAAuB,EAAE,yBAAyB;IAClD,iBAAiB,EAAE,kCAAkC;IACrD,cAAc,EAAE,uDAAuD;IACvE,cAAc,EAAE,qFAAqF;IACrG,uBAAuB,EAAE,kCAAkC;IAC3D,iBAAiB,EAAE,yBAAyB;IAC5C,aAAa,EAAE,uDAAuD;IACtE,aAAa,EAAE,gCAAgC;IAC/C,eAAe,EAAE,6DAA6D;IAC9E,YAAY,EAAE,iCAAiC;IAC/C,cAAc,EAAE,wDAAwD;IACxE,cAAc,EAAE,4CAA4C;IAC5D,aAAa,EAAE,yCAAyC;IACxD,0BAA0B,EAAE,mDAAmD;IAC/E,eAAe,EAAE,8BAA8B;IAC/C,cAAc,EAAE,kCAAkC;IAClD,aAAa,EAAE,6CAA6C;IAC5D,WAAW,EAAE,6BAA6B;IAC1C,kBAAkB,EAAE,qCAAqC;IACzD,cAAc,EAAE,yCAAyC;IACzD,UAAU,EAAE,oDAAoD;IAChE,qBAAqB,EAAE,iEAAiE;IACxF,iBAAiB,EAAE,gDAAgD;IACnE,MAAM,EAAE,qCAAqC;IAC7C,mBAAmB,EAAE,0BAA0B;IAC/C,iBAAiB,EAAE,iCAAiC;IACpD,UAAU,EAA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wCAAwC;IAC3D,eAAe,EAAE,wCAAwC;IACzD,eAAe,EAAE,oBAAoB;IACrC,mBAAmB,EAAE,kCAAkC;IACvD,uBAAuB,EAAE,iCAAiC;IAC1D,0BAA0B,EAAE,yCAAyC;CACtE,CAAC;AAEW,QAAA,MAAM,GAAG;IACpB,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,SAAS;IAClB,qBAAqB,EAAE,uBAAuB;CAC/C,CAAC;AAEW,QAAA,OAAO,GAAG;IACrB,UAAU,EAAE,aAAa;CAC1B,CAAC;AAEW,QAAA,GAAG,GAAG;IACjB,KAAK,EAAE,GAAG;CACX,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type LogType = 'info' | 'error' | 'success';
|
|
2
|
+
export declare class Logger {
|
|
3
|
+
private static readonly COLORS;
|
|
4
|
+
static info(message: string, isShow?: boolean): void;
|
|
5
|
+
static error(message: string, isShow?: boolean): void;
|
|
6
|
+
static success(message: string, isShow?: boolean): void;
|
|
7
|
+
private static log;
|
|
8
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Logger = void 0;
|
|
4
|
+
class Logger {
|
|
5
|
+
static info(message, isShow = true) {
|
|
6
|
+
Logger.log(message, 'info', isShow);
|
|
7
|
+
}
|
|
8
|
+
static error(message, isShow = true) {
|
|
9
|
+
Logger.log(message, 'error', isShow);
|
|
10
|
+
}
|
|
11
|
+
static success(message, isShow = true) {
|
|
12
|
+
Logger.log(message, 'success', isShow);
|
|
13
|
+
}
|
|
14
|
+
static log(message, type = 'info', isShow = true) {
|
|
15
|
+
if (!isShow)
|
|
16
|
+
return;
|
|
17
|
+
let prefix;
|
|
18
|
+
let color;
|
|
19
|
+
switch (type) {
|
|
20
|
+
case 'error':
|
|
21
|
+
prefix = '[ERROR]';
|
|
22
|
+
color = Logger.COLORS.red;
|
|
23
|
+
break;
|
|
24
|
+
case 'success':
|
|
25
|
+
prefix = '[SUCCESS]';
|
|
26
|
+
color = Logger.COLORS.green;
|
|
27
|
+
break;
|
|
28
|
+
default:
|
|
29
|
+
prefix = '[INFO]';
|
|
30
|
+
color = Logger.COLORS.blue;
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
console.log(`${color}${prefix} ${message}${Logger.COLORS.reset}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.Logger = Logger;
|
|
37
|
+
Logger.COLORS = {
|
|
38
|
+
blue: '\x1b[34m',
|
|
39
|
+
green: '\x1b[32m',
|
|
40
|
+
red: '\x1b[31m',
|
|
41
|
+
reset: '\x1b[0m',
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":";;;AAGA,MAAa,MAAM;IAQV,MAAM,CAAC,IAAI,CAAC,OAAe,EAAE,MAAM,GAAG,IAAI;QAC/C,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,OAAe,EAAE,MAAM,GAAG,IAAI;QAChD,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IACvC,CAAC;IAEM,MAAM,CAAC,OAAO,CAAC,OAAe,EAAE,MAAM,GAAG,IAAI;QAClD,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;IACzC,CAAC;IAEO,MAAM,CAAC,GAAG,CAAC,OAAe,EAAE,OAAgB,MAAM,EAAE,MAAM,GAAG,IAAI;QACvE,IAAI,CAAC,MAAM;YAAE,OAAO;QAEpB,IAAI,MAAc,CAAC;QACnB,IAAI,KAAa,CAAC;QAElB,QAAQ,IAAI,EAAE;YACZ,KAAK,OAAO;gBACV,MAAM,GAAG,SAAS,CAAC;gBACnB,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC;gBAC1B,MAAM;YACR,KAAK,SAAS;gBACZ,MAAM,GAAG,WAAW,CAAC;gBACrB,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;gBAC5B,MAAM;YACR;gBACE,MAAM,GAAG,QAAQ,CAAC;gBAClB,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;gBAC3B,MAAM;SACT;QAED,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,GAAG,MAAM,IAAI,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;IACpE,CAAC;;AA1CH,wBA2CC;AA1CyB,aAAM,GAAG;IAC/B,IAAI,EAAE,UAAU;IAChB,KAAK,EAAE,UAAU;IACjB,GAAG,EAAE,UAAU;IACf,KAAK,EAAE,SAAS;CACjB,CAAC"}
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pdfbutler/migration-cli",
|
|
3
3
|
"description": "[](https://www.npmjs.com/package/pdfbutler-migration-cli) [](https://npmjs.org/package/pdfbutler-migration-cli) [](https://raw.githubusercontent.com/salesforcecli/pdfbutler-migration-cli/main/LICENSE.txt)",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.27",
|
|
5
5
|
"script": {
|
|
6
6
|
"postinstall": "sf plugins link @pdfbutler/migration-cli"
|
|
7
7
|
},
|