@salesforce/core
Version:
Core libraries to interact with SFDX projects, orgs, and APIs.
76 lines • 2.86 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ReplacementsSchema = void 0;
/*
* Copyright (c) 2023, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
const zod_1 = require("zod");
const EnvConditionalSchema = zod_1.z
.object({
env: zod_1.z.string(),
value: zod_1.z.string(),
})
.strict();
const BaseReplacementSchema = zod_1.z.object({
replaceWhenEnv: zod_1.z.array(EnvConditionalSchema).optional(),
});
// Create explicit union variants to generate proper JSON Schema with anyOf
// Each variant has strict required fields and additionalProperties: false
exports.ReplacementsSchema = zod_1.z.union([
// filename + stringToReplace + replaceWithFile
BaseReplacementSchema.extend({
filename: zod_1.z.string(),
stringToReplace: zod_1.z.string(),
replaceWithFile: zod_1.z.string(),
}).strict(),
// filename + stringToReplace + replaceWithEnv
BaseReplacementSchema.extend({
filename: zod_1.z.string(),
stringToReplace: zod_1.z.string(),
replaceWithEnv: zod_1.z.string(),
allowUnsetEnvVariable: zod_1.z.boolean().optional(),
}).strict(),
// filename + regexToReplace + replaceWithFile
BaseReplacementSchema.extend({
filename: zod_1.z.string(),
regexToReplace: zod_1.z.string(),
replaceWithFile: zod_1.z.string(),
}).strict(),
// filename + regexToReplace + replaceWithEnv
BaseReplacementSchema.extend({
filename: zod_1.z.string(),
regexToReplace: zod_1.z.string(),
replaceWithEnv: zod_1.z.string(),
allowUnsetEnvVariable: zod_1.z.boolean().optional(),
}).strict(),
// glob + stringToReplace + replaceWithFile
BaseReplacementSchema.extend({
glob: zod_1.z.string(),
stringToReplace: zod_1.z.string(),
replaceWithFile: zod_1.z.string(),
}).strict(),
// glob + stringToReplace + replaceWithEnv
BaseReplacementSchema.extend({
glob: zod_1.z.string(),
stringToReplace: zod_1.z.string(),
replaceWithEnv: zod_1.z.string(),
allowUnsetEnvVariable: zod_1.z.boolean().optional(),
}).strict(),
// glob + regexToReplace + replaceWithFile
BaseReplacementSchema.extend({
glob: zod_1.z.string(),
regexToReplace: zod_1.z.string(),
replaceWithFile: zod_1.z.string(),
}).strict(),
// glob + regexToReplace + replaceWithEnv
BaseReplacementSchema.extend({
glob: zod_1.z.string(),
regexToReplace: zod_1.z.string(),
replaceWithEnv: zod_1.z.string(),
allowUnsetEnvVariable: zod_1.z.boolean().optional(),
}).strict(),
]);
//# sourceMappingURL=replacements.js.map