{"version":3,"file":"index.mjs","sources":["../../@hive/hive/dist/index.mjs"],"sourcesContent":["import { serializeError } from \"@hive/sdk/errors\";\nimport { EventEmitter, InstanceStartEvent, InstanceStopEvent } from \"@hive/sdk/events\";\nimport { formatDuration } from \"@hive/sdk/format\";\nimport { Operation } from \"@hive/sdk/operation\";\nimport { Selector } from \"@hive/sdk/selector\";\nimport { SQLITE_FIXTURE } from \"@hive/sdk/sqlite\";\n\n//#region src/index.ts\nvar Hive = class Hive {\n\tstatic name = \"hive\";\n\t/**\n\t* Unique identifier for the `Hive` instance.\n\t*\n\t* Used primarily for communication and logging.\n\t*/\n\tid;\n\t/**\n\t* Driver instance wrapping a runtime-specific implementation of SQLite.\n\t*/\n\tdriver;\n\t/**\n\t* Storage implementation the `Hive` instance manages.\n\t*/\n\tstorage;\n\t/**\n\t* EventEmitter instance internal events are emitted through.\n\t*/\n\tevents;\n\t/**\n\t* Logger instance the `Hive` instance uses for logging.\n\t*/\n\tlogger;\n\t/**\n\t* Error handler invoked when an error occurs.\n\t*/\n\tonError;\n\t/**\n\t* If currently starting, the Promise resolving when the Hive instance\n\t* has started.\n\t*/\n\tstarting;\n\t/**\n\t* If currently stopping, the Promise resolving when the Hive instance\n\t* has stopped.\n\t*/\n\tstopping;\n\tconstructor(config) {\n\t\tthis.id = config.id ?? crypto.randomUUID();\n\t\tthis.driver = config.driver ?? null;\n\t\tthis.storage = config.storage;\n\t\tthis.events = config.events ?? new EventEmitter();\n\t\tthis.logger = config.logger ?? null;\n\t\tthis.onError = config.onError ?? (() => {});\n\t\tthis.starting = null;\n\t\tthis.stopping = null;\n\t\tthis.start();\n\t}\n\t/**\n\t* Starts the `Hive` instance.\n\t*\n\t* This method is automatically called by the `Hive` constructor. It\n\t* initializes and starts all configured components in the correct order.\n\t*\n\t* To prevent race conditions, repeated calls to this method return the same\n\t* Promise, ensuring the `Hive` is started only once.\n\t*\n\t* @param opts Options for starting the `Hive` instance.\n\t*\n\t* @returns Promise resolving the `Hive` instance once it has started.\n\t*/\n\tstart = (opts) => {\n\t\tif (this.starting) return this.starting;\n\t\tconst promise = new Promise(async (resolve, reject) => {\n\t\t\tconst operation = new Operation({\n\t\t\t\ttype: InstanceStartEvent.type,\n\t\t\t\ttrace: opts?.trace ?? crypto.randomUUID()\n\t\t\t});\n\t\t\ttry {\n\t\t\t\tawait this.driver?.start({\n\t\t\t\t\tlogger: this.logger,\n\t\t\t\t\tonError: this.onError,\n\t\t\t\t\ttrace: operation.trace\n\t\t\t\t});\n\t\t\t\tawait this.storage.start({\n\t\t\t\t\tdriver: this.driver,\n\t\t\t\t\tevents: this.events,\n\t\t\t\t\tlogger: this.logger,\n\t\t\t\t\tonError: this.onError,\n\t\t\t\t\ttrace: operation.trace\n\t\t\t\t});\n\t\t\t\tthis.logger?.info(\"initialized instance\", {\n\t\t\t\t\tmodule: Hive.name,\n\t\t\t\t\ttrace: operation.trace,\n\t\t\t\t\tdur: formatDuration(operation.duration)\n\t\t\t\t});\n\t\t\t\tthis.events.emit(InstanceStartEvent.type, new InstanceStartEvent({ trace: operation.trace }));\n\t\t\t\tresolve(this);\n\t\t\t} catch (err) {\n\t\t\t\tconst error = err instanceof Error ? err : new Error(String(err));\n\t\t\t\tthis.logger?.error(`error initializing instance (${error.message})`, {\n\t\t\t\t\tmodule: Hive.name,\n\t\t\t\t\ttrace: operation.trace,\n\t\t\t\t\tdur: formatDuration(operation.duration),\n\t\t\t\t\terr: JSON.stringify(serializeError(error))\n\t\t\t\t});\n\t\t\t\treject(err);\n\t\t\t} finally {\n\t\t\t\tthis.starting = null;\n\t\t\t}\n\t\t});\n\t\tthis.starting = promise;\n\t\treturn promise;\n\t};\n\t/**\n\t* Stops the `Hive` instance.\n\t*\n\t* This method ensures that all pending operations are completed and all\n\t* components are stopped in the correct order, ensuring no state is lost.\n\t*\n\t* To prevent race conditions, repeated calls to this method return the same\n\t* Promise, ensuring the `Hive` is stopped only once.\n\t*\n\t* @param opts Options for stopping the `Hive` instance.\n\t*\n\t* @returns Promise resolving the `Hive` instance once it has stopped.\n\t*/\n\tstop = (opts) => {\n\t\tif (this.stopping) return this.stopping;\n\t\tconst promise = new Promise(async (resolve, reject) => {\n\t\t\tconst trace = opts?.trace ?? crypto.randomUUID();\n\t\t\tconst operation = new Operation({\n\t\t\t\ttype: InstanceStopEvent.type,\n\t\t\t\ttrace\n\t\t\t});\n\t\t\ttry {\n\t\t\t\tawait this.storage.stop({ trace });\n\t\t\t\tthis.logger?.info(\"closed instance\", {\n\t\t\t\t\tmodule: Hive.name,\n\t\t\t\t\ttrace,\n\t\t\t\t\tdur: formatDuration(operation.duration)\n\t\t\t\t});\n\t\t\t\tthis.events.emit(InstanceStopEvent.type, new InstanceStopEvent({ trace }));\n\t\t\t\tresolve(this);\n\t\t\t} catch (err) {\n\t\t\t\tconst error = err instanceof Error ? err : new Error(String(err));\n\t\t\t\tthis.logger?.error(\"error closing instance\", {\n\t\t\t\t\tmodule: Hive.name,\n\t\t\t\t\ttrace,\n\t\t\t\t\tdur: formatDuration(operation.duration),\n\t\t\t\t\terr: JSON.stringify(serializeError(error))\n\t\t\t\t});\n\t\t\t\treject(err);\n\t\t\t} finally {\n\t\t\t\tthis.stopping = null;\n\t\t\t}\n\t\t});\n\t\tthis.stopping = promise;\n\t\treturn promise;\n\t};\n\t/**\n\t* List all Resources matching the provided filter.\n\t*\n\t* @param opts Options for listing the Resources.\n\t*\n\t* @example ```\n\t* // List all top-level Resources.\n\t* const resources = await hive.list();\n\t* ```\n\t*\n\t* @example ```\n\t* // List all child Resources of a specific Resource.\n\t* const children = await hive.list({\n\t*   parent: {\n\t*     type: 'database',\n\t*     id: 'my-db',\n\t*   },\n\t* });\n\t* ```\n\t*\n\t* @returns Promise resolving an Array containing the Metadata for the\n\t* listed Resources.\n\t*/\n\tlist(opts) {\n\t\tconst trace = opts?.trace ?? crypto.randomUUID();\n\t\treturn this.storage.list({\n\t\t\tparent: opts?.parent,\n\t\t\ttrace\n\t\t});\n\t}\n\t/**\n\t* Create a new Resource.\n\t*\n\t* @param resource Details of the Resource to create.\n\t* @param opts Options for creating the Resource.\n\t*\n\t* @example ```\n\t* // Create a new Resource.\n\t* await hive.create({\n\t*   type: 'database',\n\t*   id: 'my-database', // Optional.\n\t*   contents: new Uint8Array(), // Optional.\n\t* });\n\t* ```\n\t*\n\t* @returns Promise resolving to the created Resource.\n\t*/\n\tcreate(resource, opts) {\n\t\tconst trace = opts?.trace ?? crypto.randomUUID();\n\t\tconst selector = resource instanceof Selector ? resource : new Selector(resource);\n\t\tswitch (selector.type) {\n\t\t\tcase \"database\":\n\t\t\tcase \"snapshot\":\n\t\t\tcase \"branch\": {\n\t\t\t\tconst contents = opts?.contents ?? SQLITE_FIXTURE;\n\t\t\t\treturn this.storage.create(selector, {\n\t\t\t\t\ttrace,\n\t\t\t\t\tcontents\n\t\t\t\t});\n\t\t\t}\n\t\t\tcase \"namespace\": return this.storage.create(selector, { trace });\n\t\t}\n\t}\n\t/**\n\t* Check if a Resource exists.\n\t*\n\t* @param resource Details of the Resource to check.\n\t* @param opts Options for checking the Resource.\n\t*\n\t* @example ```\n\t* // Check if a Resource exists.\n\t* const exists = await hive.has({\n\t*   type: 'database',\n\t*   id: 'my-database',\n\t* });\n\t* ```\n\t*\n\t* @returns Promise resolving a boolean indicating whether the Resource exists.\n\t*/\n\thas(resource, opts) {\n\t\tconst trace = opts?.trace ?? crypto.randomUUID();\n\t\tconst selector = resource instanceof Selector ? resource : new Selector(resource);\n\t\treturn this.storage.has(selector, { trace });\n\t}\n\t/**\n\t* Get a Resource.\n\t*\n\t* @param resource Details of the Resource to get.\n\t* @param opts Options for getting the Resource.\n\t*\n\t* @example ```\n\t* // Get a Database.\n\t* const database = await hive.get({\n\t*   type: 'database',\n\t*   id: 'my-database',\n\t* });\n\t* ```\n\t*\n\t* @returns Promise resolving the requested Resource and its metadata.\n\t*/\n\tget(resource, opts) {\n\t\tconst trace = opts?.trace ?? crypto.randomUUID();\n\t\tconst selector = resource instanceof Selector ? resource : new Selector(resource);\n\t\treturn this.storage.get(selector, { trace });\n\t}\n\tquery(resource, input, opts) {\n\t\tconst trace = opts?.trace ?? crypto.randomUUID();\n\t\tconst selector = resource instanceof Selector ? resource : new Selector(resource);\n\t\tconst statements = (Array.isArray(input) ? input : input.statements).map((statement) => ({\n\t\t\tsql: typeof statement === \"string\" ? statement : statement.sql,\n\t\t\tparams: typeof statement === \"string\" ? null : statement.params ?? null,\n\t\t\tmethod: typeof statement === \"string\" ? \"all\" : statement.method ?? \"all\"\n\t\t}));\n\t\tconst transaction = {\n\t\t\tstatements,\n\t\t\tmode: Array.isArray(input) ? \"DEFERRED\" : input.mode ?? \"DEFERRED\"\n\t\t};\n\t\treturn this.storage.query(selector, transaction, { trace });\n\t}\n\t/**\n\t* Free a Resource.\n\t*\n\t* @param resource Details of the Resource to free.\n\t* @param opts Options for freeing the Resource.\n\t*\n\t* @example ```\n\t* // Free a Database.\n\t* await hive.free({\n\t*   type: 'database',\n\t*   id: 'my-database',\n\t* });\n\t* ```\n\t*\n\t* @returns Promise resolving once the Resource has been freed.\n\t*/\n\tfree(resource, opts) {\n\t\tconst trace = opts?.trace ?? crypto.randomUUID();\n\t\tconst selector = resource instanceof Selector ? resource : new Selector(resource);\n\t\treturn this.storage.free(selector, { trace });\n\t}\n\t/**\n\t* Delete a Resource.\n\t*\n\t* @param resource Details of the Resource to delete.\n\t* @param opts Options for deleting the Resource.\n\t*\n\t* @example ```\n\t* // Delete a Database.\n\t* await hive.delete({\n\t*   type: 'database',\n\t*   id: 'my-database',\n\t* });\n\t* ```\n\t*\n\t* @returns Promise resolving once the Resource has been deleted.\n\t*/\n\tdelete(resource, opts) {\n\t\tconst trace = opts?.trace ?? crypto.randomUUID();\n\t\tconst selector = resource instanceof Selector ? resource : new Selector(resource);\n\t\treturn this.storage.delete(selector, { trace });\n\t}\n};\n\n//#endregion\nexport { Hive };"],"names":["Hive"],"mappings":";;;;;;;;;;AAQA,IAAI,IAAA,GAAO,MAAMA,KAAAA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