{"version":3,"sources":["jsdelivr-header.js","/npm/graphql-to-sql@4.1.10/lib/index.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,OCNS,UAAW,WAAY,kBAAsB,8BAC7C,gBAAoB,0BACpB,yBAA4B,+BAC9B,SAAS,2BAA2B,GACvC,MAAO,cAAc,4PAYzB,gBACe,SAAS,aAAa,EAAgB,OAiCjD,MAAO,CACH,qBAAsB,2BAA2B,GACjD,YAAa,CAAC,EAAO,KACjB,IAAI,EACJ,GAAI,EAAM,OACN,EAAS,EAAM,WAEd,KAAI,EAAM,SAMX,MAAM,IAAI,MAAM,2DALhB,EAAS,qBAAqB,CAC1B,SAAU,EAAM,UAKxB,CACA,MAAM,EA/Cd,SAAe,GACX,MAAM,EAAkB,CAAC,EACnB,EAAmB,CAAC,EAyB1B,OAxBA,UAAU,EAAQ,CACd,CAAC,WAAW,MAAQ,IAChB,MAAM,EAAa,cAAc,EAAQ,GACnC,EAAY,GAAY,MAAM,GAAM,EAAE,OAAS,IAIrD,OAHI,IACA,EAAgB,EAAK,MAAQ,GAE1B,CAAI,EAEf,CAAC,WAAW,cAAe,CAAC,EAAa,EAAW,KAChD,MAAM,EAAa,cAAc,EAAQ,GACnC,EAAY,GAAY,MAAM,GAAM,EAAE,OAAS,IAUrD,OATI,IACK,EAAiB,KAClB,EAAiB,GAAY,CAAC,GAElC,EAAiB,GAAU,GAAa,CACpC,YACA,YAAa,EAAY,KAAK,aAG/B,CAAW,IAGnB,CACH,kBACA,mBAER,CAgB4B,CAAM,GAC1B,OAAO,YAAY,EAAa,EAAQ,EAGpD","file":"/npm/graphql-to-sql@4.1.10/lib/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/graphql-to-sql@4.1.10/lib/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","import { mapSchema, MapperKind, getDirectives, } from '@graphql-tools/utils';\nimport { generateSql, } from './generateSql.js';\nimport { makeExecutableSchema } from '@graphql-tools/schema';\nexport function customDirectiveDeclaration(customDirectiveName) {\n    return `directive @${customDirectiveName}(\n    unicode: Boolean\n    auto: Boolean\n    default: String\n    index: Boolean\n    nullable: Boolean\n    primary: Boolean\n    type: String\n    unique: Boolean\n    generated: String\n    constraints: String\n  ) on OBJECT | FIELD_DEFINITION`;\n}\nexport default function sqlDirective(directiveName = 'sql') {\n    function visit(schema) {\n        const typeAnnotations = {};\n        const fieldAnnotations = {};\n        mapSchema(schema, {\n            [MapperKind.TYPE]: (type) => {\n                const directives = getDirectives(schema, type);\n                const directive = directives?.find((d) => d.name === directiveName);\n                if (directive) {\n                    typeAnnotations[type.name] = directive;\n                }\n                return type;\n            },\n            [MapperKind.OBJECT_FIELD]: (fieldConfig, fieldName, typeName) => {\n                const directives = getDirectives(schema, fieldConfig);\n                const directive = directives?.find((d) => d.name === directiveName);\n                if (directive) {\n                    if (!fieldAnnotations[typeName]) {\n                        fieldAnnotations[typeName] = {};\n                    }\n                    fieldAnnotations[typeName][fieldName] = {\n                        directive,\n                        graphQLType: fieldConfig.type.toString(),\n                    };\n                }\n                return fieldConfig;\n            },\n        });\n        return {\n            typeAnnotations,\n            fieldAnnotations,\n        };\n    }\n    return {\n        sqlDirectiveTypeDefs: customDirectiveDeclaration(directiveName),\n        generateSql: (input, options) => {\n            let schema;\n            if (input.schema) {\n                schema = input.schema;\n            }\n            else if (input.typeDefs) {\n                schema = makeExecutableSchema({\n                    typeDefs: input.typeDefs,\n                });\n            }\n            else {\n                throw new Error('Either schema or typeDefs should be specified as input.');\n            }\n            const annotations = visit(schema);\n            return generateSql(annotations, options);\n        },\n    };\n}\n"]}