diff --git a/src/package/packageBundleVersionCreate.ts b/src/package/packageBundleVersionCreate.ts index 3c32d6626..ecaba80c7 100644 --- a/src/package/packageBundleVersionCreate.ts +++ b/src/package/packageBundleVersionCreate.ts @@ -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)) { + // Subscriber package version ID: 15-char (04t + 12) or 18-char (04t + 15 with checksum) + if (/^04t[a-zA-Z0-9]{12}(?:[a-zA-Z0-9]{3})?$/.test(packageVersion)) { return packageVersion; } diff --git a/test/package/bundleVersionCreate.test.ts b/test/package/bundleVersionCreate.test.ts index af7ddf260..4bbb0188a 100644 --- a/test/package/bundleVersionCreate.test.ts +++ b/test/package/bundleVersionCreate.test.ts @@ -184,6 +184,77 @@ describe('PackageBundleVersion.create', () => { fs.unlinkSync(componentsPath); }); + it('should accept 15-character 04t package version id in bundle components file', async () => { + const fifteenCharPvId = '04t5f000000WM9y'; + const componentsPath = path.join(project.getPath(), 'bundle-components-15.json'); + const components = [{ packageVersion: fifteenCharPvId }]; + fs.writeFileSync(componentsPath, JSON.stringify(components)); + + let createPayload: Record | undefined; + Object.assign(connection.tooling, { + sobject: () => ({ + create: (payload: Record) => { + createPayload = payload; + 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', + BundleName: 'testBundle', + }, + 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, + }; + + await PackageBundleVersion.create(options); + + expect(createPayload?.BundleVersionComponents).to.equal(JSON.stringify([fifteenCharPvId])); + + fs.unlinkSync(componentsPath); + }); + it('should create bundle version with wait flag and polling success', async () => { const componentsPath = path.join(project.getPath(), 'bundle-components.json'); const components = [