UNPKG

@composedb/devtools

Version:

Development tools for ComposeDB projects.

55 lines (54 loc) 2.87 kB
import type { FieldsIndex } from '@ceramicnetwork/common'; import type { ModelDefinition, ModelRelationsDefinitionV2, ModelViewsDefinitionV2 } from '@ceramicnetwork/stream-model'; import type { CustomRuntimeScalarType, InternalCompositeDefinition, JSONSchema, RuntimeCompositeDefinition, RuntimeList, RuntimeObjectField, RuntimeObjectFields, RuntimeReference, RuntimeScalar, RuntimeViewReference } from '@composedb/types'; import type { AnySchema, ScalarSchema } from '../types.js'; type EnumSchema = JSONSchema.String & { title: string; enum: Array<string>; }; /** @internal */ export declare function getName(base: string, prefix?: string): string; /** @internal */ export declare function getStringScalarType(schema: JSONSchema.String): CustomRuntimeScalarType | 'string'; type RuntimeModelBuilderParams = { name: string; definition: ModelDefinition; commonEmbeds?: Array<string>; views: ModelViewsDefinitionV2; indices: Array<FieldsIndex>; }; type ExtractSchemaParams = { parentName?: string; ownName?: string; required?: boolean; localRef?: boolean; immutable?: boolean; }; type RuntimeModelDefinition = { accountData: Record<string, RuntimeViewReference>; objects: Record<string, RuntimeObjectFields>; enums: Record<string, Array<string>>; unions: Record<string, Array<string>>; }; /** @internal */ export declare class RuntimeModelBuilder { #private; constructor(params: RuntimeModelBuilderParams); build(): RuntimeModelDefinition; _getName(schema: AnySchema, params: ExtractSchemaParams, isReference?: boolean): string; _getReferenceSchema<T extends AnySchema = AnySchema>(reference: string): T; _buildObject(schema: JSONSchema.Object, params?: ExtractSchemaParams): RuntimeObjectFields; _buildObjectField(schema: AnySchema, params?: ExtractSchemaParams): RuntimeObjectField; _buildList(schema: JSONSchema.Array, params?: ExtractSchemaParams): RuntimeList; _buildListReference(reference: string, params?: ExtractSchemaParams): RuntimeScalar | RuntimeReference<'enum' | 'object'>; _buildObjectReferenceField(schema: JSONSchema.Object, params?: ExtractSchemaParams): RuntimeReference<'object'>; _buildEnumReferenceField(schema: EnumSchema, params?: ExtractSchemaParams): RuntimeReference<'enum'>; _buildReferenceSchema(reference: string, params?: ExtractSchemaParams): RuntimeObjectField; _buildScalar(schema: ScalarSchema, params?: ExtractSchemaParams): RuntimeScalar; _buildRelations(relations?: ModelRelationsDefinitionV2): void; _buildViews(object: RuntimeObjectFields, views?: ModelViewsDefinitionV2): void; _buildIndices(object: RuntimeObjectFields, indices: Array<FieldsIndex>): void; } /** @internal */ export declare function createRuntimeDefinition(definition: InternalCompositeDefinition): RuntimeCompositeDefinition; export {};