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OAAQ,EAAI,QAAQ,SAAS,MAC7B,QAAU,aAAa,QAAQ,cACrC,QAAQ,QAAU,QAClB,MAAM,QAAU,aAAa,QAAQ,cACrC,QAAQ,QAAU,QAClB,MAAM,UAAY,aAAa,QAAQ,gBACvC,QAAQ,UAAY,UACpB,MAAM,QAAU,aAAa,QAAQ,aAoCrC,IAAI,MAOA,MAvCJ,QAAQ,QAAU,QAAQ,QAQ1B,QAAQ,MAAQ,QAAQ,MAOxB,QAAQ,WAAa,QAAQ,WAkB7B,SAAW,GACP,EAAM,OAAS,QAAQ,MAC1B,CAFD,CAEG,MAAQ,QAAQ,QAAU,QAAQ,MAAQ,CAAC,IAK9C,SAAW,GACP,EAAM,OAAS,QAAQ,MAC1B,CAFD,CAEG,MAAQ,QAAQ,QAAU,QAAQ,MAAQ,CAAC,IAC9C,MAAM,QAAU,aAAa,QAAQ,cACrC,QAAQ,QAAU,QAClB,MAAM,KAAO,aAAa,QAAQ,WAClC,QAAQ,KAAO","file":"/npm/@truffle/db@2.0.36/dist/src/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@truffle/db@2.0.36/dist/src/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","\"use strict\";\n/**\n * # @truffle/db API documentation\n *\n * ## Introduction\n *\n * **@truffle/db** tracks information about smart contracts and their\n * development histories. It organizes this information almost entirely in the\n * form of **content-addressed, immutable resources** and seeks to serve as a\n * **complete system of record**, suitable to perfectly reproduce prior builds\n * and to act as a single source of truth.\n *\n * This system of record covers the full gamut of concepts related to smart\n * contract development, from source code to deployment. Among other features,\n * it includes mechanisms for tracking the continuity of a smart contract as it\n * is implemented and even as the network to which it's deployed experiences\n * a hard-fork. **Blockchain data is not forgotten — neither should blockchain\n * metadata.**\n *\n * At a high-level, this package provides a\n * [GraphQL](https://graphql.org/) interface and stores data via one of\n * several persistence backends thanks to [PouchDB](https://pouchdb.com/).\n * Use of this package directly is intended mostly for other tools – end users\n * can find interfaces to @truffle/db by way of Truffle itself, e.g. with the\n * `truffle db serve` command that starts a GraphQL Playground HTTP server.\n *\n * This documentation serves to organize the modules and namespaces included\n * in the package, both for tool developer reference and for continued work\n * on @truffle/db itself. (Disclaimer: as a result, this API documentation\n * may serve neither of these purposes well. Please reach out with questions\n * and/or to suggest helpful clarifications!)\n *\n * Continue reading below for an overview and full index of this package's\n * exports.\n *\n * ---\n *\n * <figure style=\"text-align: center\">\n * <img\n *   src=\"media://images/example-query.png\"\n *   alt=\"Example query\"\n *   style=\"width: 85%\" />\n * <figcaption style=\"font-size: small; font-style: italic\">\n * <strong>Figure</strong>:\n * Example query for a project's <code>MagicSquare</code> contract\n * </figcaption>\n * </figure>\n *\n * ---\n *\n * ## Contents\n *\n * For quick reference, this documentation summary contains the following\n * headings:\n *\n * - [Introduction](#introduction)\n *\n * - [Contents](#contents)\n *\n * - [Core library interface](#core-library-interface)\n *   - [Instantiating @truffle/db](#instantiating-truffledb)\n *   - [GraphQL schema](#graphql-schema)\n *\n * - [Data model](#data-model)\n *   - [Structure](#structure)\n *   - [List of collections](#list-of-collections)\n *\n * - [Other interfaces](#other-interfaces)\n *   - [JavaScript / TypeScript interface](#javascript---typescript-interface)\n *   - [Network abstraction](#network-abstraction)\n *   - [Truffle project abstraction](#truffle-project-abstraction)\n *   - [HTTP interface](#http-interface)\n *\n * - [Additional materials](#additional-materials)\n *\n * ## Core library interface\n *\n * ### Instantiating @truffle/db\n *\n * This package defines the primary [[connect | `connect()`]] function, which\n * returns an object adhering to the [[Db]] interface for given\n * [ConnectOptions](#connectoptions).\n * This [[Db]] interface defines the `async`\n * [[Meta.Db.execute | `db.execute()`]]\n * method that accepts a GraphQL request and returns a GraphQL response.\n *\n * ### GraphQL schema\n *\n * \\@truffle/db makes its GraphQL schema available as the exported\n * [[Graph.schema | `Graph.schema`]] variable, or view the SDL\n * details in the [[Graph]] namespace description.\n *\n * ## Data model\n *\n * ### Structure\n *\n * Data is organized as collections of representations of key\n * concepts related to smart contract development. Each collection specifies:\n *   - A collection name\n *   - A complete resource type (exported as\n *     [[Resources.Resource | `Resources.Resource<\"<collectionName>\">`]]; for\n *     retrieved records)\n *   - An input type (exported as\n *     [[Resources.Input | `Resources.Input<\"<collectionName>\">`]]; for\n *     new records)\n *   - A subset list of fields from its input type whose values strictly\n *     compose to form a resource's content-addressable ID.\n *   - Whether its resources are mutable (**note**: currently, only\n *     `\"projectNames\"` resources are mutable)\n *   - Whether its resources are named (meaning that resources of the same\n *     and collection will be tracked by name, for continuity and easy lookup)\n *\n * ### List of collections\n *\n * \\@truffle/db defines the following collections:\n *   - `\"bytecodes\"`\n *     [_resource_: [[DataModel.Bytecode | Bytecode]];\n *     _input_: [[DataModel.BytecodeInput | BytecodeInput]]]\n *   - `\"compilations\"`\n *     [_resource_: [[DataModel.Compilation | Compilation]];\n *     _input_: [[DataModel.CompilationInput | CompilationInput]]]\n *   - `\"contracts\"`\n *     [_**named**_; _resource_: [[DataModel.Contract | Contract]];\n *     _input_: [[DataModel.ContractInput | ContractInput]]]\n *   - `\"contractInstances\"`\n *     [_resource_: [[DataModel.ContractInstance | ContractInstance]];\n *     _input_: [[DataModel.ContractInstanceInput | ContractInstanceInput]]]\n *   - `\"nameRecords\"`\n *     [_resource_: [[DataModel.NameRecord | NameRecord]];\n *     _input_: [[DataModel.NameRecordInput | NameRecordInput]]]\n *   - `\"networks\"`\n *     [_**named**_; _resource_: [[DataModel.Network | Network]];\n *     _input_: [[DataModel.NetworkInput | NetworkInput]]]\n *   - `\"networkGenealogies\"`\n *     [_resource_: [[DataModel.NetworkGenealogy | NetworkGenealogy]];\n *     _input_: [[DataModel.NetworkGenealogyInput | NetworkGenealogyInput]]]\n *   - `\"projectNames\"`\n *     [_**mutable**_; _resource_: [[DataModel.ProjectName | ProjectName]];\n *     _input_: [[DataModel.ProjectNameInput | ProjectNameInput]]]\n *   - `\"projects\"`\n *     [_resource_: [[DataModel.Project | Project]];\n *     _input_: [[DataModel.ProjectInput | ProjectInput]]]\n *   - `\"sources\"`\n *     [_resource_: [[DataModel.Source | Source]];\n *     _input_: [[DataModel.SourceInput | SourceInput]]]\n *\n * This list is not intended to be static; since @truffle/db is in early\n * release, it may make sense to add new collections / change relationships\n * between existing collections. Backwards compatibility is planned but not yet\n * guaranteed.\n *\n * ## Other interfaces\n *\n * ### JavaScript / TypeScript interface\n *\n * This package exposes programmatic interfaces for working with\n * the resources listed above:\n *   - [[Process.resources]], a set of four generator functions that encode\n *     logic for storing and retrieving resources for a given `collectionName`.\n *\n *   - [[Process.Run.forDb()]], to construct an `async` helper that facilitates\n *     requests/responses from/to the above generator functions against a given\n *     [[Db]] instance.\n *\n *   - [[generateId | generateId()]], to predict the ID for a given resource\n *     input. This can be useful for determining how to query for additional\n *     information about entities with known properties.\n *\n * In addition, please see the [[Resources]] module for handy helper types for\n * dealing with @truffle/db entities.\n *\n * ### Network abstraction\n *\n * Keeping track of blockchain networks is nontrivial if you want to handle\n * network forks/re-orgs. To accommodate this, @truffle/db models\n * blockchain networks as individual point-in-time slices at various historic\n * blocks. As a result, a single blockchain network (e.g., \"mainnet\") can and\n * will comprise many disparate [[DataModel.Network]] resources, one for each\n * block previously added.\n *\n * This approach preserves immutability but requires additional record-keeping\n * in order to provide the commonly-understood continuous view of a blockchain.\n * To maintain this continuity, @truffle/db defines the\n * [[DataModel.NetworkGenealogy]] resource, each of which links two\n * [[DataModel.Network]] resources, stating that a given network is ancestor\n * to another. This collection of genealogy pairs is then used to compute a\n * sparse list of past historic blocks for a given latest network.\n *\n * The process to populate @truffle/db with correct network data involves\n * alternately querying GraphQL and the underlying blockchain JSON-RPC.\n *\n * This package provides the [[Network]] abstraction to simplify this process.\n *\n * <details>\n * <summary>Example usage</summary>\n *\n * ```typescript\n * import type { Provider } from \"web3/providers\";\n * declare const provider: Provider;\n *\n * import { connect, Network } from \"@truffle/db\";\n *\n * const db = connect({\n *   // ...\n * });\n *\n * const network = await Network.initialize({\n *   provider,\n *   db: connect({\n *     // ...\n *   }),\n *   network: { name: \"mainnet\" }\n * });\n *\n * await network.includeBlocks([\n *   { height: 10000000, hash: \"0x...\" },\n *   // ...\n * ]);\n *\n * const { historicBlock } = network.knownLatest;\n * ```\n *\n * </details>\n *\n * ### Truffle project abstraction\n *\n * This package also provides an abstraction to interface with other\n * Truffle data formats, namely `WorkflowCompileResult`, returned by\n * \\@truffle/workflow-compile, and the Truffle contract artifacts format,\n * defined by @truffle/contract-schema. This abstraction covers two classes:\n *   - [[Project.Project]] for operations that **do not** require a network\n *     connection. Use function [[Project.initialize | `Project.initialize()`]]\n *     to create.\n *   - [[Project.ConnectedProject]] for operations that **do** require a\n *     blockchain network. Use existing project abstraction's\n *     [[Project.connect | `project.connect()`]] method to create.\n *\n * ### HTTP interface\n *\n * This package exposes the [[serve | `serve()`]] function, which returns an\n * [Apollo Server](https://www.apollographql.com/docs/apollo-server/)\n * instance, adherent to the\n * [Node.js `http.Server`](https://nodejs.org/api/http.html#http_class_http_server)\n * interface. This server runs\n * [GraphQL Playground](https://github.com/graphql/graphql-playground) for the\n * browser and also accepts plain GraphQL requests.\n *\n * _(This is a handy way to explore @truffle/db, since it offers schema-aware\n * auto-completion and the ability to explore relationships between entities.)_\n *\n * ## Additional materials\n *\n * This package listing contains other namespaces not mentioned above.\n * These are for internal use and not to be considered part of @truffle/db's\n * public interface.\n *\n * For those curious about these internals, of particular note is the [[Meta]]\n * namespace, which houses underlying collections-agnostic logic for\n * integrating GraphQL and PouchDB.\n *\n * @packageDocumentation\n */ /** */\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n    if (k2 === undefined) k2 = k;\n    var desc = Object.getOwnPropertyDescriptor(m, k);\n    if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n      desc = { enumerable: true, get: function() { return m[k]; } };\n    }\n    Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n    if (k2 === undefined) k2 = k;\n    o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n    Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n    o[\"default\"] = v;\n});\nvar __importStar = (this && this.__importStar) || function (mod) {\n    if (mod && mod.__esModule) return mod;\n    var result = {};\n    if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n    __setModuleDefault(result, mod);\n    return result;\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n    return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Meta = exports.Process = exports.Pouch = exports.Graph = exports.generateId = exports.serve = exports.connect = exports.Resources = exports.Project = exports.Network = void 0;\nconst debug_1 = __importDefault(require(\"debug\"));\nconst debug = (0, debug_1.default)(\"db\");\nconst Network = __importStar(require(\"./network\"));\nexports.Network = Network;\nconst Project = __importStar(require(\"./project\"));\nexports.Project = Project;\nconst Resources = __importStar(require(\"./resources\"));\nexports.Resources = Resources;\nconst _System = __importStar(require(\"./system\"));\n/**\n * Instantiate @truffle/db for given [[ConnectOptions]]\n */\nexports.connect = _System.connect;\n/**\n * Create an Apollo GraphQL server for @truffle/db for given [[ConnectOptions]]\n *\n * See\n * [Apollo Server documentation](https://www.apollographql.com/docs/apollo-server/)\n * for more information.\n */\nexports.serve = _System.serve;\n/**\n * Compute an ID for a given collection name and input. This accepts either\n * a full [[Resources.Input | `Resources.Input<\"<collectionName>\">`]]\n * representation or an object containing only the relevant subset of\n * [[Resources.IdFields | `Resources.IdFields<\"<collectionName>\">`]].\n */\nexports.generateId = _System.generateId;\n/**\n * # GraphQL-related exports for @truffle/db\n *\n * ## SDL\n *\n * <details>\n * <summary>@truffle/db SDL</summary>\n *\n * ```graphql\n * [[include:schema.sdl]]\n * ```\n *\n * </details>\n *\n * @category Primary\n */\nvar Graph;\n(function (Graph) {\n    Graph.schema = _System.schema;\n})(Graph = exports.Graph || (exports.Graph = {}));\n/**\n * @category Internal\n */\nvar Pouch;\n(function (Pouch) {\n    Pouch.attach = _System.attach;\n})(Pouch = exports.Pouch || (exports.Pouch = {}));\nconst Process = __importStar(require(\"./process\"));\nexports.Process = Process;\nconst Meta = __importStar(require(\"./meta\"));\nexports.Meta = Meta;\n"]}