diff --git a/bun.lockb b/bun.lockb index 1236a7c..df34991 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 772297e..2bb8d9d 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "description": "Access the RONIN data platform via TypeScript.", "scripts": { "dev": "bun run build -- --watch", - "build": "tsc --build", + "build": "tsup ./src/index.ts ./src/bin/index.ts ./src/utils/index.ts --format esm", "test": "bun test", "lint": "bun run lint:tsc && bun run lint:eslint --", "lint:eslint": "eslint . --ext .ts --ignore-path .gitignore", @@ -90,6 +90,7 @@ "husky": "9.0.11", "lint-staged": "15.2.5", "prettier": "3.3.1", + "tsup": "8.1.0", "typescript": "5.4.5" } } diff --git a/src/bin/commands/login.ts b/src/bin/commands/login.ts index 6833429..f891659 100644 --- a/src/bin/commands/login.ts +++ b/src/bin/commands/login.ts @@ -3,7 +3,7 @@ import http from 'http'; import open from 'open'; import ora from 'ora'; -import { storeSession, storeTokenForBun, storeTokenForNPM } from '../utils/session'; +import { storeSession, storeTokenForBun, storeTokenForNPM } from '@/src/bin/utils/session'; export default async (appToken?: string) => { const spinner = ora('Logging in').start(); diff --git a/src/bin/index.ts b/src/bin/index.ts index e45c17a..b7f6ada 100644 --- a/src/bin/index.ts +++ b/src/bin/index.ts @@ -2,10 +2,10 @@ import { parseArgs } from 'util'; -import { printHelp, printVersion } from '../bin/utils/info'; -import initializeProject from './commands/init'; -import logIn from './commands/login'; -import { getSession } from './utils/session'; +import initializeProject from '@/src/bin/commands/init'; +import logIn from '@/src/bin/commands/login'; +import { printHelp, printVersion } from '@/src/bin/utils/info'; +import { getSession } from '@/src/bin/utils/session'; let values; let positionals; diff --git a/src/bin/utils/info.ts b/src/bin/utils/info.ts index d753b09..d78714a 100644 --- a/src/bin/utils/info.ts +++ b/src/bin/utils/info.ts @@ -1,6 +1,6 @@ import chalkTemplate from 'chalk-template'; -import { version } from '../../../package.json'; +import { version } from '@/src/../package.json'; export const printVersion = () => { console.log(version); diff --git a/src/index.ts b/src/index.ts index 83f2bae..a1d84b8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,7 +1,7 @@ -import { createSyntaxFactory } from './syntax'; +import { createSyntaxFactory } from '@/src/syntax'; const { create, get, set, drop, count, batch } = createSyntaxFactory({}); export { create, get, set, drop, count, batch }; -export type { RONIN } from './types/codegen'; +export type { RONIN } from '@/src/types/codegen'; export default createSyntaxFactory; diff --git a/src/queries.ts b/src/queries.ts index 21eb10a..2ec0059 100644 --- a/src/queries.ts +++ b/src/queries.ts @@ -1,9 +1,9 @@ -import { processStorableObjects, uploadStorableObjects } from './storage'; -import type { Query, Results } from './types/query'; -import type { QueryHandlerOptions } from './types/utils'; -import { runQueriesWithHooks } from './utils/data-hooks'; -import { getDotNotatedPath, InvalidQueryError } from './utils/errors'; -import { formatTimeFields, getProperty } from './utils/helpers'; +import { processStorableObjects, uploadStorableObjects } from '@/src/storage'; +import type { Query, Results } from '@/src/types/query'; +import type { QueryHandlerOptions } from '@/src/types/utils'; +import { runQueriesWithHooks } from '@/src/utils/data-hooks'; +import { getDotNotatedPath, InvalidQueryError } from '@/src/utils/errors'; +import { formatTimeFields, getProperty } from '@/src/utils/helpers'; type QueryResponse = { results: Result[]; diff --git a/src/storage.ts b/src/storage.ts index 23ae7fe..3f1bce0 100644 --- a/src/storage.ts +++ b/src/storage.ts @@ -1,6 +1,6 @@ -import type { CombinedInstructions, Query } from './types/query'; -import type { StorableObject, StoredObject } from './types/storage'; -import type { QueryHandlerOptions } from './types/utils'; +import type { CombinedInstructions, Query } from '@/src/types/query'; +import type { StorableObject, StoredObject } from '@/src/types/storage'; +import type { QueryHandlerOptions } from '@/src/types/utils'; /** * Extract `StorableObject`s from queries. These will be uploaded separately diff --git a/src/syntax/handlers.ts b/src/syntax/handlers.ts index 4fbf1fd..bdd2a8f 100644 --- a/src/syntax/handlers.ts +++ b/src/syntax/handlers.ts @@ -1,6 +1,6 @@ -import { runQueriesWithStorageAndHooks } from '../queries'; -import type { Query } from '../types/query'; -import type { QueryHandlerOptionsFactory } from '../types/utils'; +import { runQueriesWithStorageAndHooks } from '@/src/queries'; +import type { Query } from '@/src/types/query'; +import type { QueryHandlerOptionsFactory } from '@/src/types/utils'; /** * Executes an array of queries and handles their results. It is used to execute diff --git a/src/syntax/index.ts b/src/syntax/index.ts index d1a0a63..ab8c71b 100644 --- a/src/syntax/index.ts +++ b/src/syntax/index.ts @@ -1,7 +1,7 @@ -import type { RONIN } from '../types/codegen'; -import type { QueryHandlerOptionsFactory } from '../types/utils'; -import { queriesHandler, queryHandler } from './handlers'; -import { getBatchProxy, getSyntaxProxy } from './utils'; +import { queriesHandler, queryHandler } from '@/src/syntax/handlers'; +import { getBatchProxy, getSyntaxProxy } from '@/src/syntax/utils'; +import type { RONIN } from '@/src/types/codegen'; +import type { QueryHandlerOptionsFactory } from '@/src/types/utils'; /** * Creates a syntax factory for generating and executing queries. diff --git a/src/syntax/utils.ts b/src/syntax/utils.ts index 8445fcd..6b9a890 100644 --- a/src/syntax/utils.ts +++ b/src/syntax/utils.ts @@ -1,6 +1,6 @@ -import type { Query } from '../types/query'; -import type { PromiseTuple } from '../types/utils'; -import { objectFromAccessor } from '../utils/helpers'; +import type { Query } from '@/src/types/query'; +import type { PromiseTuple } from '@/src/types/utils'; +import { objectFromAccessor } from '@/src/utils/helpers'; let inBatch = false; diff --git a/src/tsconfig.json b/src/tsconfig.json deleted file mode 100644 index e08f57e..0000000 --- a/src/tsconfig.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "../tsconfig.json", - "compilerOptions": { - "composite": true, - "outDir": "../dist", - "noEmit": false, - "allowImportingTsExtensions": false - } -} diff --git a/src/types/codegen.ts b/src/types/codegen.ts index 7151ebf..f28667b 100644 --- a/src/types/codegen.ts +++ b/src/types/codegen.ts @@ -1,5 +1,5 @@ -import type { StorableObjectValue, StoredObject } from './storage'; -import type { ReducedFunction, ReplaceRecursively } from './utils'; +import type { StorableObjectValue, StoredObject } from '@/src/types/storage'; +import type { ReducedFunction, ReplaceRecursively } from '@/src/types/utils'; export namespace RONIN { export interface RoninRecord { diff --git a/src/types/index.ts b/src/types/index.ts index 4ede5a6..dde8229 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -28,7 +28,7 @@ export type { BeforeHookHandler, AfterHookHandler, DuringHookHandler, -} from '../utils/data-hooks'; +} from '@/src/utils/data-hooks'; export type { // Queries @@ -56,7 +56,7 @@ export type { // Query Instructions WithInstruction, -} from './query'; +} from '@/src/types/query'; // Storage -export type { StorableObjectValue, StoredObject } from './storage'; +export type { StorableObjectValue, StoredObject } from '@/src/types/storage'; diff --git a/src/types/utils.ts b/src/types/utils.ts index d1ab28b..07054c9 100644 --- a/src/types/utils.ts +++ b/src/types/utils.ts @@ -1,4 +1,4 @@ -import type { Hooks } from '../utils/data-hooks'; +import type { Hooks } from '@/src/utils/data-hooks'; export interface QueryHandlerOptions { /** diff --git a/src/utils/data-hooks.ts b/src/utils/data-hooks.ts index 5bd332d..f644d1c 100644 --- a/src/utils/data-hooks.ts +++ b/src/utils/data-hooks.ts @@ -1,9 +1,9 @@ import type AsyncHooks from 'node:async_hooks'; -import { runQueries } from '../queries'; -import type { CombinedInstructions, Query, QuerySchemaType, QueryType, Results } from '../types/query'; -import type { QueryHandlerOptions, RecursivePartial } from '../types/utils'; -import { toDashCase } from './helpers'; +import { runQueries } from '@/src/queries'; +import type { CombinedInstructions, Query, QuerySchemaType, QueryType, Results } from '@/src/types/query'; +import type { QueryHandlerOptions, RecursivePartial } from '@/src/types/utils'; +import { toDashCase } from '@/src/utils/helpers'; const EMPTY = Symbol('empty'); diff --git a/src/utils/index.ts b/src/utils/index.ts index 8b6f52f..fc1b65a 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -1,5 +1,5 @@ -import { runQueriesWithStorageAndHooks as runQueries } from '../queries'; -import { processStorableObjects } from '../storage'; -import { getBatchProxy, getSyntaxProxy } from '../syntax/utils'; +import { runQueriesWithStorageAndHooks as runQueries } from '@/src/queries'; +import { processStorableObjects } from '@/src/storage'; +import { getBatchProxy, getSyntaxProxy } from '@/src/syntax/utils'; export { runQueries, processStorableObjects, getSyntaxProxy, getBatchProxy }; diff --git a/tests/integration/edge.test.ts b/tests/integration/edge.test.ts index 70f06a0..beeec6e 100644 --- a/tests/integration/edge.test.ts +++ b/tests/integration/edge.test.ts @@ -1,7 +1,7 @@ import { beforeEach, describe, expect, mock, spyOn, test } from 'bun:test'; -import createSyntaxFactory from '../../src'; -import { runQueriesWithHooks } from '../../src/utils/data-hooks'; +import createSyntaxFactory from '@/src/index'; +import { runQueriesWithHooks } from '@/src/utils/data-hooks'; const mockFetch = mock(async () => { return Response.json({ diff --git a/tests/integration/factory.test.ts b/tests/integration/factory.test.ts index 7bd3b41..8200bbe 100644 --- a/tests/integration/factory.test.ts +++ b/tests/integration/factory.test.ts @@ -1,7 +1,7 @@ import { beforeEach, describe, expect, mock, test } from 'bun:test'; -import { createSyntaxFactory } from '../../src/syntax'; -import type { StoredObject } from '../../src/types/storage'; +import { createSyntaxFactory } from '@/src/syntax'; +import type { StoredObject } from '@/src/types/storage'; let mockRequestResolvedValue: Request | undefined = undefined; let mockResolvedRequestText: any = undefined; diff --git a/tests/integration/hooks.test.ts b/tests/integration/hooks.test.ts index f880d29..ba5d7f5 100644 --- a/tests/integration/hooks.test.ts +++ b/tests/integration/hooks.test.ts @@ -1,8 +1,8 @@ import { beforeEach, describe, expect, mock, test } from 'bun:test'; -import { createSyntaxFactory } from '../../src/syntax'; -import type { CombinedInstructions, QueryType } from '../../src/types/query'; -import { type FilteredHookQuery, runQueriesWithHooks } from '../../src/utils/data-hooks'; +import { createSyntaxFactory } from '@/src/syntax'; +import type { CombinedInstructions, QueryType } from '@/src/types/query'; +import { type FilteredHookQuery, runQueriesWithHooks } from '@/src/utils/data-hooks'; let mockResolvedRequestText: any = undefined; diff --git a/tests/unit/error.test.ts b/tests/unit/error.test.ts index df5a358..df40ab6 100644 --- a/tests/unit/error.test.ts +++ b/tests/unit/error.test.ts @@ -1,6 +1,6 @@ import { describe, expect, test } from 'bun:test'; -import { getDotNotatedPath } from '../../src/utils/errors'; +import { getDotNotatedPath } from '@/src/utils/errors'; describe('generate dot notation', () => { test('generate path from segments containing only strings', () => { diff --git a/tests/unit/queries.test.ts b/tests/unit/queries.test.ts index 041b002..ccfa025 100644 --- a/tests/unit/queries.test.ts +++ b/tests/unit/queries.test.ts @@ -1,6 +1,6 @@ import { beforeEach, describe, expect, mock, spyOn, test } from 'bun:test'; -import { queriesHandler } from '../../src/syntax/handlers'; +import { queriesHandler } from '@/src/syntax/handlers'; let mockRequestResolvedValue: Request | undefined; diff --git a/tests/unit/strings.test.ts b/tests/unit/strings.test.ts index 1c2f567..10dbde6 100644 --- a/tests/unit/strings.test.ts +++ b/tests/unit/strings.test.ts @@ -1,6 +1,6 @@ import { expect, test } from 'bun:test'; -import { toDashCase } from '../../src/utils/helpers'; +import { toDashCase } from '@/src/utils/helpers'; test('correctly convert strings to dash case', async () => { expect(toDashCase('superLongSlug')).toBe('super-long-slug'); diff --git a/tsconfig.json b/tsconfig.json index 2740e26..6b14fe8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,7 @@ { "compilerOptions": { + "outDir": "dist", + "esModuleInterop": true, "resolveJsonModule": true, "baseUrl": ".", @@ -12,7 +14,6 @@ "allowJs": true, "moduleResolution": "node", - "allowImportingTsExtensions": true, "verbatimModuleSyntax": true, "noEmit": true, "pretty": true, @@ -22,7 +23,10 @@ "noFallthroughCasesInSwitch": true, "noUnusedLocals": true, - "noUnusedParameters": true - }, - "references": [{ "path": "./src" }] + "noUnusedParameters": true, + + "paths": { + "@/src/*": ["./src/*"] + } + } }