UNPKG

@composedb/devtools

Version:

Development tools for ComposeDB projects.

41 lines (40 loc) 3.33 kB
import type { ModelRelationDefinition, ModelRelationsDefinition } from '@ceramicnetwork/stream-model'; import type { FieldsIndex, JSONSchema } from '@composedb/types'; import { type DirectiveAnnotation } from '@graphql-tools/utils'; import { type GraphQLFieldMap, type GraphQLInterfaceType, GraphQLList, type GraphQLObjectType, type GraphQLScalarType, type GraphQLType } from 'graphql'; import type { ScalarSchema } from '../types.js'; import type { ItemDefinition, ListFieldDefinition, ObjectDefinition, ObjectFieldsDefinition, ParsedModelDefinition, ReferenceFieldType, SchemaDefinition, ViewFieldDefinition } from './types.js'; type NumberDirectiveArguments = { default?: number; max?: number; min?: number; }; type DefinitionWithReferences<T> = { definition: T; references: Array<string>; }; type IntermediaryObjectDefinition = DefinitionWithReferences<ObjectFieldsDefinition> & { relations: ModelRelationsDefinition; }; export declare class SchemaParser { #private; constructor(schema: string); parse(): SchemaDefinition; _parseIndices(directives: Array<DirectiveAnnotation>): Array<FieldsIndex>; _validateRelatedModel(key: string, modelName: string): void; _parseModelDirective(type: GraphQLInterfaceType | GraphQLObjectType, directives: Array<DirectiveAnnotation>, object: ObjectDefinition): ParsedModelDefinition | void; _parseObject(type: GraphQLInterfaceType | GraphQLObjectType, directives: Array<DirectiveAnnotation>): ObjectDefinition; _parseObjectFields(type: GraphQLInterfaceType | GraphQLObjectType, directives: Array<DirectiveAnnotation>): IntermediaryObjectDefinition; _parseRelations(objectName: string, fieldName: string, type: GraphQLType, directives: Array<DirectiveAnnotation>): ModelRelationDefinition | void; _parseViews(objectName: string, fieldName: string, type: GraphQLType, directives: Array<DirectiveAnnotation>, objectFields: GraphQLFieldMap<unknown, unknown>): ViewFieldDefinition | void; _parseListType(objectName: string, fieldName: string, type: GraphQLList<GraphQLType>, required: boolean, directives: Array<DirectiveAnnotation>, hasCreateModel: boolean): DefinitionWithReferences<ListFieldDefinition>; _parseItemType(objectName: string, fieldName: string, type: GraphQLType, directives: Array<DirectiveAnnotation>, hasCreateModel: boolean): DefinitionWithReferences<ItemDefinition>; _parseScalarSchema(objectName: string, fieldName: string, type: GraphQLScalarType, directives: Array<DirectiveAnnotation>): ScalarSchema; _validateIntegerSchema(objectName: string, fieldName: string, schema: JSONSchema.Integer, directive: DirectiveAnnotation | undefined): JSONSchema.Integer; _validateNumberSchema(objectName: string, fieldName: string, schema: JSONSchema.Number, directive: DirectiveAnnotation | undefined): JSONSchema.Number; _validateNumberArguments<T extends JSONSchema.Integer | JSONSchema.Number>(objectName: string, fieldName: string, schema: T, args: NumberDirectiveArguments): T; _validateStringSchema(objectName: string, fieldName: string, schema: JSONSchema.String, string: DirectiveAnnotation | undefined): JSONSchema.String; _getReferenceFieldType(type: GraphQLType): ReferenceFieldType | void; } export declare function parseSchema(schema: string): SchemaDefinition; export {};