Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor and cleanup codebase #357

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,21 @@
"recommended": true,
"suspicious": {
"noConsoleLog": "error"
},
"correctness": {
"noUnusedImports": "error"
},
"style": {
"useFilenamingConvention": {
"level": "error",
"options": {
"filenameCases": ["kebab-case"]
}
}
}
}
},
"files": {
"ignore": ["dist/**"]
"ignore": ["dist/**", "npm/**"]
}
}
2 changes: 1 addition & 1 deletion src/data/types/range.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Tagged } from "../../cbor";
import { SurrealDbError } from "../../errors";
import { toSurrealqlString } from "../../util/to-surrealql-string";
import { TAG_BOUND_EXCLUDED, TAG_BOUND_INCLUDED, TAG_RANGE } from "../cbor";
import { TAG_BOUND_EXCLUDED, TAG_BOUND_INCLUDED } from "../cbor";
import {
type RecordIdValue,
escape_id_part,
Expand Down
9 changes: 1 addition & 8 deletions src/engines/abstract.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import type { Encoded } from "../cbor";
import type { EngineDisconnected } from "../errors";
import type {
LiveAction,
LiveHandlerArguments,
Patch,
RpcRequest,
RpcResponse,
} from "../types";
import type { LiveHandlerArguments, RpcRequest, RpcResponse } from "../types";
import type { Emitter } from "../util/emitter";

export type Engine = new (context: EngineContext) => AbstractEngine;
Expand Down
4 changes: 2 additions & 2 deletions src/engines/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {
MissingNamespaceDatabase,
} from "../errors";
import type { RpcRequest, RpcResponse } from "../types";
import { getIncrementalID } from "../util/getIncrementalID";
import { retrieveRemoteVersion } from "../util/versionCheck";
import { getIncrementalID } from "../util/get-incremental-id";
import { retrieveRemoteVersion } from "../util/version-check";
import {
AbstractEngine,
ConnectionStatus,
Expand Down
4 changes: 2 additions & 2 deletions src/engines/ws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {
UnexpectedServerResponse,
} from "../errors";
import { type RpcRequest, type RpcResponse, isLiveResult } from "../types";
import { getIncrementalID } from "../util/getIncrementalID";
import { retrieveRemoteVersion } from "../util/versionCheck";
import { getIncrementalID } from "../util/get-incremental-id";
import { retrieveRemoteVersion } from "../util/version-check";
import {
AbstractEngine,
ConnectionStatus,
Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
export { Emitter, type Listener, type UnknownEvents } from "./util/emitter.ts";
export { surql, surrealql } from "./util/tagged-template.ts";
export { PreparedQuery } from "./util/PreparedQuery.ts";
export { PreparedQuery } from "./util/prepared-query.ts";
export * as cbor from "./cbor";
export * from "./cbor/gap";
export * from "./cbor/error";
export * from "./data";
export * from "./errors.ts";
export * from "./types.ts";
export * from "./util/jsonify.ts";
export * from "./util/versionCheck.ts";
export * from "./util/getIncrementalID.ts";
export * from "./util/version-check.ts";
export * from "./util/get-incremental-id.ts";
export * from "./util/string-prefixes.ts";
export * from "./util/to-surrealql-string.ts";
export {
Expand Down
8 changes: 3 additions & 5 deletions src/surreal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import {
type EngineEvents,
type Engines,
} from "./engines/abstract.ts";
import { PreparedQuery } from "./util/PreparedQuery.ts";
import { Emitter } from "./util/emitter.ts";
import { processAuthVars } from "./util/processAuthVars.ts";
import { versionCheck } from "./util/versionCheck.ts";
import { PreparedQuery } from "./util/prepared-query.ts";
import { processAuthVars } from "./util/process-auth-vars.ts";
import { versionCheck } from "./util/version-check.ts";

import {
type AccessRecordAuth,
Expand All @@ -41,8 +41,6 @@ import { WebsocketEngine } from "./engines/ws.ts";
import {
EngineDisconnected,
NoActiveSocket,
NoDatabaseSpecified,
NoNamespaceSpecified,
NoTokenReturned,
ResponseError,
SurrealDbError,
Expand Down
4 changes: 2 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Encoded, Fill } from "./cbor";
import type { Fill } from "./cbor";
import { type RecordId, Uuid } from "./data";
import { SurrealDbError } from "./errors";
import type { PreparedQuery } from "./util/PreparedQuery";
import type { PreparedQuery } from "./util/prepared-query";

export type ActionResult<T extends Record<string, unknown>> = Prettify<
T["id"] extends RecordId ? T : { id: RecordId } & T
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/util/tagged-template.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PreparedQuery } from "./PreparedQuery.ts";
import { PreparedQuery } from "./prepared-query.ts";

export function surrealql(
query_raw: string[] | TemplateStringsArray,
Expand Down
File renamed without changes.
1 change: 0 additions & 1 deletion tests/integration/tests/live.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { describe, expect, test } from "bun:test";
import {
type LiveAction,
type LiveHandlerArguments,
RecordId,
ResponseError,
Expand Down
2 changes: 0 additions & 2 deletions tests/integration/tests/querying.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import {
StringRecordId,
Table,
Uuid,
decodeCbor,
encodeCbor,
surql,
} from "../../../src";
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, test } from "bun:test";
import { type AnyAuth, convertAuth } from "../../src";
import { convertAuth } from "../../src";

test("valid", () => {
expect(convertAuth({ username: "root", password: "root" })).toStrictEqual({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, test } from "bun:test";
import { isVersionSupported } from "../../src/util/versionCheck.ts";
import { isVersionSupported } from "../../src/util/version-check.ts";

describe("isVersionSupported", () => {
test("1.0.0 should be unsupported", () => {
Expand Down