import { UploadOptions } from "./types" ; import getConfig from "./util/getConfig" ; export { DataResource , FunctionResource , IndexResource , Membership , Privilege , ProviderResource , RoleResource , ResourceType } from "./types" ; const { schemaPath , indexesDir , fnsDir , rolesDir , dataDir , providersDir , codegen , mode } = getConfig ( ) ; export async function upload ( { override = false , resources = [ "schema" , "data" , "functions" , "indexes" , "providers" , "roles" ] } = { } ) { ensurePackage ( "faunadb" ) ; const uploadSchema = ( await import ( "./lib/schema" ) ) . default ; const uploadResources = ( await import ( "./lib/resources" ) ) . default ; if ( resources . includes ( "schema" ) ) { const ok = await uploadSchema ( schemaPath , { override , mode } ) ; if ( ! ok ) return ; } if ( resources . includes ( "indexes" ) ) await uploadResources ( indexesDir , "indexes" ) ; if ( resources . includes ( "functions" ) ) await uploadResources ( fnsDir , "functions" , { fnsWithRoles : false } ) ; if ( resources . includes ( "roles" ) ) await uploadResources ( rolesDir , "roles" ) ; if ( resources . includes ( "functions" ) ) await uploadResources ( fnsDir , "functions" , { fnsWithRoles : true } ) ; if ( resources . includes ( "data" ) ) await uploadResources ( dataDir , "data" ) ; if ( resources . includes ( "providers" ) ) await uploadResources ( providersDir , "providers" ) ; if ( codegen ) { ensurePackage ( "graphql" ) ; const runCodegen = ( await import ( "./lib/codegen" ) ) . default ; runCodegen ( ) ; } } ; function ensurePackage ( name ) { try { require ( name ) ; } catch ( err ) { throw `Missing required peer dependency "${ name }".
			
Run "yarn add -D ${ name }" to install it with yarn,
or "npm i --save-dev ${ name }" to install with npm.
			` ; } }