export const addSelectGenericsToGeneratedTypes = ({ compiledGeneratedTypes })=>{ const modifiedLines = []; let isCollectionsSelectToken = false; let isSelectTypeToken = false; for (const line of compiledGeneratedTypes.split('\n')){ let newLine = line; if (line === ` collectionsSelect: {` || line === ` globalsSelect: {`) { isCollectionsSelectToken = true; } if (isCollectionsSelectToken) { if (line === ' };') { isCollectionsSelectToken = false; } else { // replace with | PostsSelect newLine = line.replace(/(['"]?\w+['"]?):\s*(\w+);/g, (_, variable, type)=>{ return `${variable}: ${type} | ${type};`; }); } } // eslint-disable-next-line regexp/no-unused-capturing-group if (line.match(/via the `definition` "([\w-]+_select)"/g)) { isSelectTypeToken = true; } if (isSelectTypeToken) { if (line.startsWith('export interface')) { // add generic to the interface newLine = line.replace(/(export interface\s+\w+)(\s*\{)/g, '$1$2'); } else { newLine = line// replace booleans with T on the line .replace(/(? .replace(/\b(\w+)\s*\|\s*(\w+)\b/g, (_match, left, right)=>`${left} | ${right}<${left}>`); if (line === '}') { isSelectTypeToken = false; } } } modifiedLines.push(newLine); } return modifiedLines.join('\n'); }; //# sourceMappingURL=addSelectGenericsToGeneretedTypes.js.map