From 7615530ae4334d294e7864a8fb572b3dd1e4e285 Mon Sep 17 00:00:00 2001 From: Brayden Wilmoth Date: Tue, 14 Jan 2025 09:45:48 -0500 Subject: [PATCH] Release 0.1.4 --- package.json | 3 +- src/do.ts | 135 --------------------------------------------------- 2 files changed, 2 insertions(+), 136 deletions(-) diff --git a/package.json b/package.json index 7e8075f..8a47fd1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@outerbase/starbasedb", - "version": "0.1.0", + "version": "0.1.4", "files": [ "src", "dist", @@ -23,6 +23,7 @@ "deploy": "wrangler deploy", "dev": "wrangler dev", "start": "wrangler dev", + "publish-npm-module": "npm publish --access public", "cf-typegen": "wrangler types", "delete": "wrangler delete", "prepare": "husky" diff --git a/src/do.ts b/src/do.ts index 04c8b60..a050072 100644 --- a/src/do.ts +++ b/src/do.ts @@ -1,18 +1,10 @@ import { DurableObject } from 'cloudflare:workers' -// import { OperationQueueItem } from "./operation"; -// import { createResponse } from "./utils"; export class StarbaseDBDurableObject extends DurableObject { // Durable storage for the SQL database public sql: SqlStorage public storage: DurableObjectStorage - // // Queue of operations to be processed, with each operation containing a list of queries to be executed - // private operationQueue: Array = []; - - // // Flag to indicate if an operation is currently being processed - // private processingOperation: { value: boolean } = { value: false }; - /** * The constructor is invoked once upon creation of the Durable Object, i.e. the first call to * `DurableObjectStub::get` for a given identifier (no-op constructors can be omitted) @@ -73,44 +65,6 @@ export class StarbaseDBDurableObject extends DurableObject { } } - // TODO: Hiding for now as it's not used in the current implementation - // /** - // * Execute a raw SQL query on the database, typically used for external requests - // * from other service bindings (e.g. auth). This serves as an exposed function for - // * other service bindings to query the database without having to have knowledge of - // * the current operation queue or processing state. - // * - // * @param sql - The SQL query to execute. - // * @param params - Optional parameters for the SQL query. - // * @returns A response containing the query result or an error message. - // */ - // private async executeExternalQuery( - // sql: string, - // params: any[] | undefined - // ): Promise { - // try { - // const queries = [{ sql, params }]; - // const response = await this.enqueueOperation( - // queries, - // false, - // false, - // this.operationQueue, - // () => - // this.processNextOperation( - // this.sql, - // this.operationQueue, - // this.ctx, - // this.processingOperation - // ) - // ); - - // return response; - // } catch (error: any) { - // console.error("Execute External Query Error:", error); - // return null; - // } - // } - private async executeRawQuery< T extends Record = Record< string, @@ -177,93 +131,4 @@ export class StarbaseDBDurableObject extends DurableObject { } }) } - - // TODO: Hiding for now as it's not used in the current implementation - // private enqueueOperation( - // queries: { sql: string; params?: any[] }[], - // isTransaction: boolean, - // isRaw: boolean, - // operationQueue: any[], - // processNextOperation: () => Promise - // ): Promise<{ result?: any; error?: string | undefined; status: number }> { - // const MAX_WAIT_TIME = 25000; - // return new Promise((resolve, reject) => { - // const timeout = setTimeout(() => { - // reject(createResponse(undefined, "Operation timed out.", 503)); - // }, MAX_WAIT_TIME); - - // operationQueue.push({ - // queries, - // isTransaction, - // isRaw, - // resolve: (value: any) => { - // clearTimeout(timeout); - - // resolve({ - // result: value, - // error: undefined, - // status: 200, - // }); - // }, - // reject: (reason?: any) => { - // clearTimeout(timeout); - - // reject({ - // result: undefined, - // error: reason ?? "Operation failed.", - // status: 500, - // }); - // }, - // }); - - // processNextOperation().catch((err) => { - // console.error("Error processing operation queue:", err); - // }); - // }); - // } - - // TODO: Hiding for now as it's not used in the current implementation - // private async processNextOperation( - // sqlInstance: any, - // operationQueue: OperationQueueItem[], - // ctx: any, - // processingOperation: { value: boolean } - // ) { - // if (processingOperation.value) { - // // Already processing an operation - // return; - // } - - // if (operationQueue.length === 0) { - // // No operations remaining to process - // return; - // } - - // processingOperation.value = true; - // const { queries, isTransaction, isRaw, resolve, reject } = - // operationQueue.shift()!; - - // try { - // let result; - - // if (isTransaction) { - // result = await this.executeTransaction(queries, isRaw); - // } else { - // const { sql, params } = queries[0]; - // result = this.executeQuery({ sql, params }); - // } - - // resolve(result); - // } catch (error: any) { - // reject(error.message || "Operation failed."); - // } finally { - // processingOperation.value = false; - // await this.processNextOperation( - // sqlInstance, - // operationQueue, - // ctx, - // processingOperation - // ); - // } - // } }