@salesforce/packaging
Version:
Packaging library for the Salesforce packaging platform
85 lines • 3.3 kB
JavaScript
;
/*
* Copyright 2026, Salesforce, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.PackageBundle = void 0;
const core_1 = require("@salesforce/core");
const kit_1 = require("@salesforce/kit");
const packageBundleCreate_1 = require("./packageBundleCreate");
const packageBundleVersion_1 = require("./packageBundleVersion");
const BundleFields = [
'BundleName',
'Description',
'Id',
'IsDeleted',
'CreatedDate',
'CreatedById',
'LastModifiedDate',
'LastModifiedById',
'SystemModstamp',
];
class PackageBundle {
/**
* Create a new package bundle.
*
* @param connection - instance of Connection
* @param project - instance of SfProject
* @param options - options for creating a bundle - see BundleCreateOptions
* @returns PackageBundle
*/
static async create(connection, project, options) {
return (0, packageBundleCreate_1.createBundle)(connection, project, options);
}
/**
* Create a new package bundle version.
*
* @param connection - instance of Connection
* @param project - instance of SfProject
* @param options - options for creating a bundle version - see BundleVersionCreateOptions
* @returns PackageBundle
*/
static async createVersion(options, polling = {
frequency: kit_1.Duration.seconds(0),
timeout: kit_1.Duration.seconds(0),
}) {
return packageBundleVersion_1.PackageBundleVersion.create({ ...options, polling });
}
static async delete(connection, project, idOrAlias) {
// Check if it's already an ID (1Fl followed by 15 characters)
if (/^1Fl.{15}$/.test(idOrAlias)) {
return connection.tooling.sobject('PackageBundle').delete(idOrAlias);
}
// Validate that project is provided when using aliases
if (!project) {
throw new core_1.SfError('Project instance is required when deleting package bundle by alias');
}
// eslint-disable-next-line no-param-reassign
idOrAlias = project.getPackageBundleIdFromAlias(idOrAlias) ?? idOrAlias;
return connection.tooling.sobject('PackageBundle').delete(idOrAlias);
}
/**
* Returns all the package bundles that are available in the org, up to 10,000. If more records are
* needed use the `SF_ORG_MAX_QUERY_LIMIT` env var.
*
* @param connection
*/
static async list(connection) {
const query = `select ${BundleFields.join(', ')} from PackageBundle ORDER BY BundleName`;
return (await connection.autoFetchQuery(query, { tooling: true }))?.records;
}
}
exports.PackageBundle = PackageBundle;
//# sourceMappingURL=packageBundle.js.map