import * as Meta from "../meta"; import * as DataModel from "./data"; export { DataModel }; /** * @category Internal */ export type Collections = { sources: { resource: DataModel.Source; input: DataModel.SourceInput; idFields: ["contents", "sourcePath"]; names: { resource: "source"; Resource: "Source"; resources: "sources"; Resources: "Sources"; resourcesMutate: "sourcesAdd"; ResourcesMutate: "SourcesAdd"; }; }; bytecodes: { resource: DataModel.Bytecode; input: DataModel.BytecodeInput; idFields: ["bytes", "linkReferences"]; names: { resource: "bytecode"; Resource: "Bytecode"; resources: "bytecodes"; Resources: "Bytecodes"; resourcesMutate: "bytecodesAdd"; ResourcesMutate: "BytecodesAdd"; }; }; compilations: { resource: DataModel.Compilation; input: DataModel.CompilationInput; idFields: ["compiler", "sources"]; names: { resource: "compilation"; Resource: "Compilation"; resources: "compilations"; Resources: "Compilations"; resourcesMutate: "compilationsAdd"; ResourcesMutate: "CompilationsAdd"; }; }; contractInstances: { resource: DataModel.ContractInstance; input: DataModel.ContractInstanceInput; idFields: ["contract", "address", "creation"]; names: { resource: "contractInstance"; Resource: "ContractInstance"; resources: "contractInstances"; Resources: "ContractInstances"; resourcesMutate: "contractInstancesAdd"; ResourcesMutate: "ContractInstancesAdd"; }; }; contracts: { resource: DataModel.Contract; input: DataModel.ContractInput; idFields: ["name", "abi", "processedSource", "compilation"]; named: true; names: { resource: "contract"; Resource: "Contract"; resources: "contracts"; Resources: "Contracts"; resourcesMutate: "contractsAdd"; ResourcesMutate: "ContractsAdd"; }; }; nameRecords: { resource: DataModel.NameRecord; input: DataModel.NameRecordInput; idFields: ["resource", "previous"]; names: { resource: "nameRecord"; Resource: "NameRecord"; resources: "nameRecords"; Resources: "NameRecords"; resourcesMutate: "nameRecordsAdd"; ResourcesMutate: "NameRecordsAdd"; }; }; networks: { resource: DataModel.Network; input: DataModel.NetworkInput; idFields: ["networkId", "historicBlock"]; named: true; names: { resource: "network"; Resource: "Network"; resources: "networks"; Resources: "Networks"; resourcesMutate: "networksAdd"; ResourcesMutate: "NetworksAdd"; }; }; projects: { resource: DataModel.Project; input: DataModel.ProjectInput; idFields: ["directory"]; names: { resource: "project"; Resource: "Project"; resources: "projects"; Resources: "Projects"; resourcesMutate: "projectsAdd"; ResourcesMutate: "ProjectsAdd"; }; }; projectNames: { resource: DataModel.ProjectName; input: DataModel.ProjectNameInput; idFields: ["project", "key"]; mutable: true; names: { resource: "projectName"; Resource: "ProjectName"; resources: "projectNames"; Resources: "ProjectNames"; resourcesMutate: "projectNamesAssign"; ResourcesMutate: "ProjectNamesAssign"; }; }; networkGenealogies: { resource: DataModel.NetworkGenealogy; input: DataModel.NetworkGenealogyInput; idFields: ["ancestor", "descendant"]; names: { resource: "networkGenealogy"; Resource: "NetworkGenealogy"; resources: "networkGenealogies"; Resources: "NetworkGenealogies"; resourcesMutate: "networkGenealogiesAdd"; ResourcesMutate: "NetworkGenealogiesAdd"; }; }; }; /** * An instance of @truffle/db * * Defines the [[Meta.Db.execute | `db.execute()`]] method, which accepts * GraphQL requests and returns GraphQL responses. * * See [[connect | connect()]] for how to instantiate this interface. * * @example * ```typescript * import gql from "graphql-tag"; * import { connect, Db } from "@truffle/db"; * * const db: Db = connect({ * // ... * }); * * const { * project: { * contract: { * id, * abi, * processedSource, * callBytecode * } * } * } = await db.execute(gql` * query { * project(id: "0x...") { * contract(name: "MagicSquare") { * id * abi { json } * processedSource { * source { contents } * ast { json } * } * callBytecode { * bytes * linkReferences { name length offsets } * instructions { opcode programCounter pushData } * } * } * } * } * `); * ``` */ export type Db = Meta.Db; /** * @category Internal */ export type Definitions = Meta.Definitions; /** * @category Internal */ export type Definition = Definitions[N]; /** * `bytecodes`, `contracts`, etc. * * @category Primary */ export type CollectionName = Meta.CollectionName; /** * Input type for a given collection name * * @example * ```typescript * import { Resources } from "@truffle/db"; * * const sourceInput: Resources.Input<"sources"> = { * contents: "echo \"hello world\"" * } * ``` * @category Primary */ export type Input = Meta.Input; /** * Resource type for a given collection name * * @example * ```typescript * import { Resources } from "@truffle/db"; * * const source: Resources.Resource<"sources"> = { * id: "0x...", * contents: "echo \"hello world\"" * } * ``` * @category Primary */ export type Resource = Meta.Resource; export type SavedInput = Meta.SavedInput; export type IdFields = Meta.IdFields; /** * Common reference type for resources in the system * * This exists for type safety purposes. Typically, do not define variables * of this type directly; use [[toIdObject]] on existing resources. * * @example * ```typescript * import { Resources } from "@truffle/db"; * * declare const source: Resources.Resource<"sources">; * * const { id }: Resources.IdObject<"sources"> = Resources.toIdObject(source); * ``` * @category Primary */ export type IdObject = Meta.IdObject; /** * Convert a given [[Resource]] to an [[IdObject]] * * @category Primary */ export declare const toIdObject: | SavedInput = import("../meta/collections").CollectionProperty<"resource", Collections, N> | SavedInput, I extends Pick | null | undefined = Pick | null | undefined>(resource: I) => Pick extends I ? Meta.IdObject : Meta.IdObject | undefined; /** * Type akin to [[CollectionName]] but only includes mutable collections * * @category Primary */ export type MutableCollectionName = Meta.MutableCollectionName; /** * Type akin to [[CollectionName]] but only includes named collections * * @category Primary */ export type NamedCollectionName = Meta.NamedCollectionName; /** * @category Internal */ export type Workspace = Meta.Workspace;