import { z } from 'zod'; import { replaceSchema } from '../../shared/definition.js'; import { createBuiltInParserDefinition } from '../../internals/createBuiltInParserDefinition.js'; import { applyTo } from '../../shared/definition.js'; export const replaceStringParserName = 'replace-string'; export const replaceStringParserOptionsSchema = z .object({ all: replaceSchema.optional(), group: replaceSchema.optional(), collection: replaceSchema.optional(), token: replaceSchema.optional(), applyTo, }) .strict(); // .superRefine((val, ctx) => { // if (!val.all && !val.group && !val.collection && !val.token) { // ctx.addIssue({ // code: z.ZodIssueCode.custom, // message: 'You need to define at least one of: "all", "token", "group" or "collection".', // }); // } // // if (val.all && (val.group || val.collection || val.token)) { // ctx.addIssue({ // code: z.ZodIssueCode.custom, // message: // 'You can\'t provide "all" and one of "group", "collection" or "token" at the same time. Please only provide "all" or one of "token", "group" or "collection"', // }); // } // }); export const replaceStringParserDefinition = createBuiltInParserDefinition({ name: replaceStringParserName, kind: 'utility', hasOptionalOptions: false, optionsSchema: replaceStringParserOptionsSchema, hasOptionalOutput: true, outputTypes: undefined, inTypes: ['SDTF', 'SDTF Engine'], outType: 'SDTF Engine', }); export type ReplaceStringParserDefinition = typeof replaceStringParserDefinition; export type ReplaceStringParserOptions = z.infer;