diff --git a/src/content.ts b/src/content.ts index a2fdcc8..884f5a6 100644 --- a/src/content.ts +++ b/src/content.ts @@ -1,6 +1,6 @@ import { sortBy } from "es-toolkit"; import type { CollectionModel, CollectionField } from "pocketbase"; -import type { GenerateOpts } from "./server/utils.ts"; +import type { GenerateOpts } from "@/server/utils.ts"; export function stringifyContent(collections: CollectionModel[], opts: GenerateOpts) { function getCollectionSelectFields() { @@ -110,7 +110,8 @@ export function stringifyContent(collections: CollectionModel[], opts: GenerateO break; case "select": - // if (collectionName === "testFiles") console.log(`${collectionName}:`, field); + // if (collectionName === "testFiles") + console.log(`${collectionName}:`, field); // TODO: implement values const maxSelect = field.maxSelect; diff --git a/src/helpers.ts b/src/helpers.ts index f0e79b6..f24fd26 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -1,8 +1,8 @@ import type { default as Pocketbase, SendOptions } from "pocketbase"; -import { fullListOptionsFrom, optionsFrom } from "./options.js"; -import type { AnyZodRecord, RecordFullListOpts, RecordIdRef, RecordRef, RecordSlugRef } from "./types.ts"; -import { AnyRecordsList } from "./schemas.ts"; -import type { RecordsList } from "./schemas.ts"; +import { fullListOptionsFrom, optionsFrom } from "@/options.ts"; +import type { AnyZodRecord, RecordFullListOpts, RecordIdRef, RecordRef, RecordSlugRef } from "@/types.ts"; +import { AnyRecordsList } from "@/schemas.ts"; +import type { RecordsList } from "@/schemas.ts"; export function helpersFrom({ fetch, pocketbase }: HelpersFromOpts) { async function getRecord(ref: RecordSlugRef, opts: GetRecordOpts): Promise; diff --git a/src/options.ts b/src/options.ts index b4a718c..34a7888 100644 --- a/src/options.ts +++ b/src/options.ts @@ -1,6 +1,6 @@ import { z } from "zod"; import type { AnyZodObject, ZodTypeAny } from "zod"; -import type { AnyZodRecord, RecordFullListOpts, RecordListOpts } from "./types.ts"; +import type { AnyZodRecord, RecordFullListOpts, RecordListOpts } from "@/types.ts"; /** * Extends the given schema with the given expansion. diff --git a/src/schemas.ts b/src/schemas.ts index 15daa2f..1cc8b69 100644 --- a/src/schemas.ts +++ b/src/schemas.ts @@ -1,6 +1,6 @@ import { z, ZodOptional, ZodEffects } from "zod"; import type { AnyZodObject, objectUtil, ZodObject, ZodRawShape } from "zod"; -import type { AnyZodRecord, HasRequiredKeys, ZodRecordKeys } from "./types.ts"; +import type { AnyZodRecord, HasRequiredKeys, ZodRecordKeys } from "@/types.ts"; /** * Records list schema. diff --git a/src/sdk.ts b/src/sdk.ts index 780f338..e54a7da 100644 --- a/src/sdk.ts +++ b/src/sdk.ts @@ -1,5 +1,5 @@ import Pocketbase from "pocketbase"; -import type { Credentials } from "./config.ts"; +import type { Credentials } from "@/config.ts"; let adminPocketbase: Pocketbase; diff --git a/src/server/cli.ts b/src/server/cli.ts index 4469c24..219e4c8 100644 --- a/src/server/cli.ts +++ b/src/server/cli.ts @@ -1,13 +1,13 @@ #!/usr/bin/env bun -import { Config } from "../config.ts"; -import type { ResolvedConfig } from "../config.ts"; +import { Config } from "@/config.ts"; +import type { ResolvedConfig } from "@/config.ts"; import pkg from "../../package.json" with { type: "json" }; import { loadConfig } from "c12"; import { defineCommand, runMain } from "citty"; import { cancel, group, intro, log, outro, confirm, text, spinner, multiselect, isCancel } from "@clack/prompts"; -import { fetchCollections } from "../utils.ts"; -import { generate } from "./utils.ts"; +import { fetchCollections } from "@/utils.ts"; +import { generate } from "@/server/utils.ts"; import { existsSync } from "node:fs"; async function getConfig() { diff --git a/src/server/utils.ts b/src/server/utils.ts index 1f6b464..25b49ab 100644 --- a/src/server/utils.ts +++ b/src/server/utils.ts @@ -2,8 +2,8 @@ import { mkdirSync, readFileSync, writeFileSync } from "node:fs"; import { dirname, resolve } from "node:path"; import { fileURLToPath } from "node:url"; import type { CollectionModel } from "pocketbase"; -import { stringifyContent } from "../content.js"; -import type { ResolvedConfig } from "../config.ts"; +import { stringifyContent } from "@/content.js"; +import type { ResolvedConfig } from "@/config.ts"; export async function generate(collections: CollectionModel[], opts: GenerateOpts) { const stub = readFileSync(resolve(dirname(fileURLToPath(import.meta.url)), "../../assets/stubs/index.ts"), "utf-8"); diff --git a/src/utils.ts b/src/utils.ts index 1e6d457..adfd0b1 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,7 +1,7 @@ import { sortBy } from "es-toolkit"; import type { CollectionModel } from "pocketbase"; -import { getPocketbase } from "./sdk.js"; -import type { Credentials } from "./config.ts"; +import { getPocketbase } from "@/sdk.js"; +import type { Credentials } from "@/config.ts"; export async function fetchCollections(credentials: Credentials): Promise { const pocketbase = await getPocketbase(credentials); diff --git a/tsconfig.json b/tsconfig.json index 9bcd708..01d2f0e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -46,7 +46,11 @@ // Report an error for unreachable code instead of just a warning. "allowUnreachableCode": false, // Report an error for unused labels instead of just a warning. - "allowUnusedLabels": false + "allowUnusedLabels": false, + "baseUrl": ".", + "paths": { + "@/*": ["./src/*"] + } }, "exclude": ["dist", "assets/stubs"] }