Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 19 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,55 +10,61 @@
"@oclif/command": "^1",
"@oclif/config": "^1",
"@oclif/errors": "^1",
"@salesforce/command": "^4.2.1",
"@salesforce/core": "^2.37.1",
"@salesforce/command": "^5.3.9",
"@salesforce/core": "^8.6.1",
"@types/jsdom": "^21.1.7",
"@types/lodash.chunk": "^4.2.9",
"@types/shelljs": "^0.8.15",
"@xmldom/xmldom": "^0.7.5",
"cheerio": "^1.0.0",
"jsdom": "^25.0.0",
"lodash.chunk": "^4.2.0",
"minimatch": "^10.0.1",
"nanoid": "^5.0.7",
"open": "^8.4.2",
"prettier-plugin-apex": "^2.1.4",
"shelljs": "^0.8.5",
"tslib": "^2",
"xmldom": "^0.6.0"
"tslib": "^2"
},
"devDependencies": {
"@babel/parser": "^7.25.6",
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.12.0",
"@oclif/dev-cli": "^1",
"@oclif/plugin-command-snapshot": "^3.3.15",
"@oclif/plugin-help": "^3",
"@oclif/test": "^1",
"@salesforce/dev-config": "^2.1.2",
"@salesforce/dev-scripts": "^0",
"@salesforce/dev-scripts": "^10.2.10",
"@salesforce/plugin-command-reference": "^1.4.7",
"@salesforce/prettier-config": "^0.0.3",
"@salesforce/ts-sinon": "^1",
"@types/babel__traverse": "^7.20.6",
"@types/jsforce": "^1.11.5",
"@typescript-eslint/eslint-plugin": "^4.2.0",
"@typescript-eslint/parser": "^4.2.0",
"@typescript-eslint/eslint-plugin": "^8.8.0",
"@typescript-eslint/parser": "^8.8.0",
"chai": "^4.4.1",
"eslint": "^7.27.0",
"eslint": "^9.12.0",
"eslint-config-oclif": "^3.1",
"eslint-config-prettier": "^8",
"eslint-config-salesforce": "^0.1.6",
"eslint-config-salesforce-license": "^0.2.0",
"eslint-config-salesforce-typescript": "^0.2.7",
"eslint-config-salesforce-typescript": "^3.4.0",
"eslint-plugin-header": "^3.0.0",
"eslint-plugin-import": "2.24.2",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jsdoc": "^35.1.2",
"eslint-plugin-prettier": "^3.1.3",
"eslint-plugin-typescript": "^0",
"globby": "^11",
"husky": "^4.3.8",
"mocha": "^8.4.0",
"mocha": "^10.7.3",
"nyc": "^15.1.0",
"prettier": "^2.8.8",
"prettier": "^3.3.3",
"pretty-quick": "^3.3.1",
"sinon": "10.0.0",
"ts-node": "^10.9.2",
"typescript": "^4.9.5"
"typedoc": "^0.26.10",
"typescript": "^5.6.2"
},
"engines": {
"node": ">=12.0.0"
Expand Down
4 changes: 2 additions & 2 deletions src/commands/omnistudio/migration/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
import * as os from 'os';
import { flags, SfdxCommand } from '@salesforce/command';
import { Messages, SfdxError } from '@salesforce/core';
import { Messages, SfError } from '@salesforce/core';
import { AnyJson } from '@salesforce/ts-types';

// Initialize Messages with the current plugin directory
Expand Down Expand Up @@ -66,7 +66,7 @@ export default class Org extends SfdxCommand {
// Organization will always return one result, but this is an example of throwing an error
// The output and --json will automatically be handled for you.
if (!result.records || result.records.length <= 0) {
throw new SfdxError(messages.getMessage('errorNoOrgResults', [this.org.getOrgId()]));
throw new SfError(messages.getMessage('errorNoOrgResults', [this.org.getOrgId()]));
}

// Organization always only returns one result
Expand Down
34 changes: 14 additions & 20 deletions src/commands/omnistudio/migration/migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
import * as os from 'os';
import { flags } from '@salesforce/command';
import { Messages } from '@salesforce/core';
import { Messages, Org } from '@salesforce/core';
import '../../../utils/prototypes';
import OmniStudioBaseCommand from '../../basecommand';
import { DataRaptorMigrationTool } from '../../../migration/dataraptor';
Expand Down Expand Up @@ -58,10 +58,12 @@ export default class Migrate extends OmniStudioBaseCommand {
const migrateOnly = (this.flags.only || '') as string;
const allVersions = this.flags.allversions || false;

Logger.initialiseLogger(this.ux, this.logger);
this.logger = Logger.logger;
Logger.initialiseLogger(this.ux, Logger.logger);
// this.logger = Logger.logger;
const logger = Logger.logger;
// this.org is guaranteed because requiresUsername=true, as opposed to supportsUsername
const conn = this.org.getConnection();
const org = new Org();
const conn = org.getConnection();
conn.setApiVersion(apiVersion);

// Let's time every step
Expand All @@ -71,17 +73,9 @@ export default class Migrate extends OmniStudioBaseCommand {
let migrationObjects: MigrationTool[] = [];
if (!migrateOnly) {
migrationObjects = [
new DataRaptorMigrationTool(namespace, conn, this.logger, messages, this.ux),
new OmniScriptMigrationTool(
OmniScriptExportType.All,
namespace,
conn,
this.logger,
messages,
this.ux,
allVersions
),
new CardMigrationTool(namespace, conn, this.logger, messages, this.ux, allVersions),
new DataRaptorMigrationTool(namespace, conn, logger, messages, this.ux),
new OmniScriptMigrationTool(OmniScriptExportType.All, namespace, conn, logger, messages, this.ux, allVersions),
new CardMigrationTool(namespace, conn, logger, messages, this.ux, allVersions),
];
} else {
switch (migrateOnly) {
Expand All @@ -91,7 +85,7 @@ export default class Migrate extends OmniStudioBaseCommand {
OmniScriptExportType.OS,
namespace,
conn,
this.logger,
logger,
messages,
this.ux,
allVersions
Expand All @@ -104,18 +98,18 @@ export default class Migrate extends OmniStudioBaseCommand {
OmniScriptExportType.IP,
namespace,
conn,
this.logger,
logger,
messages,
this.ux,
allVersions
)
);
break;
case 'fc':
migrationObjects.push(new CardMigrationTool(namespace, conn, this.logger, messages, this.ux, allVersions));
migrationObjects.push(new CardMigrationTool(namespace, conn, logger, messages, this.ux, allVersions));
break;
case 'dr':
migrationObjects.push(new DataRaptorMigrationTool(namespace, conn, this.logger, messages, this.ux));
migrationObjects.push(new DataRaptorMigrationTool(namespace, conn, logger, messages, this.ux));
break;
default:
throw new Error(messages.getMessage('invalidOnlyFlag'));
Expand Down Expand Up @@ -173,7 +167,7 @@ export default class Migrate extends OmniStudioBaseCommand {
namespace,
migrateOnly,
allVersions,
this.org
org
);
omnistudioRelatedObjectsMigration.migrateAll(objectMigrationResults, []);
await ResultsBuilder.generate(objectMigrationResults, conn.instanceUrl);
Expand Down
4 changes: 2 additions & 2 deletions src/migration/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ export class BaseMigrationTool {
protected readonly connection: Connection;
protected readonly namespacePrefix: string;
protected readonly logger: Logger;
protected readonly messages: Messages;
protected readonly messages: Messages<string>;
protected readonly ux: UX;

public constructor(namespace: string, connection: Connection, logger: Logger, messages: Messages, ux: UX) {
public constructor(namespace: string, connection: Connection, logger: Logger, messages: Messages<string>, ux: UX) {
this.namespace = namespace;
this.connection = connection;
this.logger = logger;
Expand Down
2 changes: 1 addition & 1 deletion src/migration/flexcard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class CardMigrationTool extends BaseMigrationTool implements MigrationToo
namespace: string,
connection: Connection,
logger: Logger,
messages: Messages,
messages: Messages<string>,
ux: UX,
allVersions: boolean
) {
Expand Down
2 changes: 1 addition & 1 deletion src/migration/omniscript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class OmniScriptMigrationTool extends BaseMigrationTool implements Migrat
namespace: string,
connection: Connection,
logger: Logger,
messages: Messages,
messages: Messages<string>,
ux: UX,
allVersions: boolean
) {
Expand Down
52 changes: 52 additions & 0 deletions src/utils/apex/executor/AnonymousApexRunner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AnonymousApexRunner = void 0;
var AnonymousApexRunner = /** @class */ (function () {
function AnonymousApexRunner() {
}
AnonymousApexRunner.run = function (org, anonymousApex) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, org.getConnection().tooling.executeAnonymous(anonymousApex)];
});
});
};
return AnonymousApexRunner;
}());
exports.AnonymousApexRunner = AnonymousApexRunner;
6 changes: 3 additions & 3 deletions src/utils/apex/executor/AnonymousApexRunner.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Org } from '@salesforce/core';
import { ExecuteAnonymousResult } from 'jsforce';

export class AnonymousApexRunner {
public static async run(org: Org, anonymousApex: string): Promise<ExecuteAnonymousResult> {
return org.getConnection().tooling.executeAnonymous(anonymousApex);
public static async run(org: Org, anonymousApex: string): Promise<AnonymousApexRunner> {
const connection = org.getConnection();
return connection.tooling.executeAnonymous(anonymousApex);
}
}
Loading