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
4 changes: 2 additions & 2 deletions src/package/packageBundleVersionCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ export class PackageBundleVersionCreate {
return bundleVersionComponents.map((component) => {
const packageVersion = component.packageVersion;

// Check if it's already an ID (04t followed by 15 characters)
if (/^04t[a-zA-Z0-9]{15}$/.test(packageVersion)) {
// Check if it's a package version ID (04t prefix, 15 or 18 characters)
if (/^04t[a-zA-Z0-9]{12,15}$/.test(packageVersion)) {
return packageVersion;
}

Expand Down
69 changes: 69 additions & 0 deletions test/package/bundleVersionCreate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,75 @@ describe('PackageBundleVersion.create', () => {
fs.unlinkSync(componentsPath);
});

it('should accept 15-char package version IDs', async () => {
const componentsPath = path.join(project.getPath(), 'bundle-components.json');
const components = [
{ packageVersion: '04t5f000000WM9y' }, // 15-char ID
{ packageVersion: '04t000000000000003' }, // 18-char ID
];
fs.writeFileSync(componentsPath, JSON.stringify(components));

let capturedRequest: { BundleVersionComponents: string } | undefined;
Object.assign(connection.tooling, {
sobject: () => ({
create: (req: { BundleVersionComponents: string }) => {
capturedRequest = req;
return Promise.resolve({
success: true,
id: '0Ho000000000000',
});
},
}),
query: () =>
Promise.resolve({
records: [{ BundleName: 'testBundle' }],
}),
});

Object.assign(connection, {
autoFetchQuery: () =>
Promise.resolve({
records: [
{
Id: '0Ho000000000000',
RequestStatus: BundleSObjects.PkgBundleVersionCreateReqStatus.success,
PackageBundle: { Id: '0Ho123456789012' },
PackageBundleVersion: { Id: '1Q8000000000001' },
VersionName: 'ver 1.0',
MajorVersion: '1',
MinorVersion: '0',
Ancestor: null,
BundleVersionComponents: JSON.stringify(components),
CreatedDate: '2025-01-01T00:00:00.000Z',
CreatedById: '005000000000000',
ValidationError: '',
},
],
}),
});

const options: BundleVersionCreateOptions = {
connection,
project,
PackageBundle: 'testBundle',
MajorVersion: '1',
MinorVersion: '0',
Ancestor: null,
BundleVersionComponentsPath: componentsPath,
};

const result = await PackageBundleVersion.create(options);
expect(result).to.have.property('RequestStatus', BundleSObjects.PkgBundleVersionCreateReqStatus.success);

// Verify both 15-char and 18-char IDs are passed through to the API
expect(capturedRequest).to.not.be.undefined;
const sentComponents = JSON.parse(capturedRequest!.BundleVersionComponents) as string[];
expect(sentComponents[0]).to.equal('04t5f000000WM9y'); // 15-char passed through
expect(sentComponents[1]).to.equal('04t000000000000003'); // 18-char passed through

fs.unlinkSync(componentsPath);
});

it('should handle invalid bundle components format', async () => {
const componentsPath = path.join(project.getPath(), 'bundle-components.json');

Expand Down
Loading