Switched from eslint and prettier to biome

This commit is contained in:
2025-10-20 15:21:17 +02:00
parent 66ad6c349a
commit 870825c5f2
15 changed files with 419 additions and 344 deletions

9
.zed/settings.json Normal file
View File

@@ -0,0 +1,9 @@
{
"lsp": {
"biome": {
"settings": {
"config_path": "./biome.json"
}
}
}
}

20
assets/env.d.ts vendored
View File

@@ -1,14 +1,12 @@
import type { TypedPocketbase } from "../../../src/lib/pocketbase/schemas";
import type { helpersFrom } from "astro-pocketbase-continue";
import type { TypedPocketbase } from '../../../src/lib/pocketbase/schemas'
import type { helpersFrom } from 'astro-pocketbase-continue'
declare global {
namespace App {
interface Locals {
pocketbase: TypedPocketbase;
getRecord: ReturnType<typeof helpersFrom>["getRecord"];
getRecords: ReturnType<typeof helpersFrom>["getRecords"];
}
}
namespace App {
interface Locals {
pocketbase: TypedPocketbase
getRecord: ReturnType<typeof helpersFrom>['getRecord']
getRecords: ReturnType<typeof helpersFrom>['getRecords']
}
}
}
export {};

View File

@@ -1,59 +1,69 @@
// This file was automatically generated by Astro PocketBase.
import type { Collection, TypedPocketbase } from "./schemas";
import type { LoaderContext } from "astro/loaders";
import Pocketbase from "pocketbase";
import Client from "pocketbase";
import type { RecordAuthResponse, } from "pocketbase";
import type { LoaderContext } from 'astro/loaders'
import type Client from 'pocketbase'
import type { RecordAuthResponse } from 'pocketbase'
import Pocketbase from 'pocketbase'
import type { Collection, TypedPocketbase } from './schemas'
let pocketbase: TypedPocketbase;
let auth: Promise<RecordAuthResponse<Client>>;
let isAuthenticating = false;
let pocketbase: TypedPocketbase
let auth: Promise<RecordAuthResponse<Client>>
let isAuthenticating = false
export function pocketbaseLoader({ collection }: PocketbaseLoaderOptions) {
return {
name: "pocketbase-loader",
load: async ({ store, logger, meta, parseData }: LoaderContext) => {
const { ASTRO_POCKETBASE_ADMIN_EMAIL, ASTRO_POCKETBASE_ADMIN_PASSWORD, PUBLIC_ASTRO_POCKETBASE_URL } = import.meta.env;
if (!ASTRO_POCKETBASE_ADMIN_EMAIL || !ASTRO_POCKETBASE_ADMIN_PASSWORD || !PUBLIC_ASTRO_POCKETBASE_URL)
return logger.error("Environment variables not set");
return {
name: 'pocketbase-loader',
load: async ({ store, logger, meta, parseData }: LoaderContext) => {
const {
ASTRO_POCKETBASE_ADMIN_EMAIL,
ASTRO_POCKETBASE_ADMIN_PASSWORD,
PUBLIC_ASTRO_POCKETBASE_URL,
} = import.meta.env
if (
!ASTRO_POCKETBASE_ADMIN_EMAIL ||
!ASTRO_POCKETBASE_ADMIN_PASSWORD ||
!PUBLIC_ASTRO_POCKETBASE_URL
)
return logger.error('Environment variables not set')
logger.info(`Loading ${collection}`);
logger.info(`Loading ${collection}`)
if (!pocketbase) pocketbase = new Pocketbase(PUBLIC_ASTRO_POCKETBASE_URL);
if (!pocketbase) pocketbase = new Pocketbase(PUBLIC_ASTRO_POCKETBASE_URL)
try {
if (!isAuthenticating && !pocketbase.authStore.isValid) {
isAuthenticating = true;
auth = pocketbase.collection("_superusers").authWithPassword(ASTRO_POCKETBASE_ADMIN_EMAIL, ASTRO_POCKETBASE_ADMIN_PASSWORD);
}
await auth;
try {
if (!isAuthenticating && !pocketbase.authStore.isValid) {
isAuthenticating = true
auth = pocketbase
.collection('_superusers')
.authWithPassword(ASTRO_POCKETBASE_ADMIN_EMAIL, ASTRO_POCKETBASE_ADMIN_PASSWORD)
}
await auth
const lastUpdatedItems = await pocketbase
.collection(collection)
.getList(1, 1, { fields: "updated", skipTotal: true, sort: "updated", order: "desc" });
const lastUpdated = lastUpdatedItems.items[0]?.updated;
const lastUpdatedItems = await pocketbase
.collection(collection)
.getList(1, 1, { fields: 'updated', skipTotal: true, sort: 'updated', order: 'desc' })
const lastUpdated = lastUpdatedItems.items[0]?.updated
if (lastUpdated !== meta.get("last-updated")) {
logger.info(`Refreshing ${collection}`);
if (lastUpdated !== meta.get('last-updated')) {
logger.info(`Refreshing ${collection}`)
meta.set("last-updated", lastUpdated);
const items = await pocketbase.collection(collection).getFullList();
for (const { id, updated, ...rest } of items) {
const data = await parseData({ id, data: { id, updated, ...rest } });
store.set({ data, digest: updated, id });
}
}
meta.set('last-updated', lastUpdated)
const items = await pocketbase.collection(collection).getFullList()
for (const { id, updated, ...rest } of items) {
const data = await parseData({ id, data: { id, updated, ...rest } })
store.set({ data, digest: updated, id })
}
}
logger.info(`Loaded ${collection}`);
} catch (error) {
logger.error(`Error fetching ${collection}: ${error}`);
return;
}
},
};
logger.info(`Loaded ${collection}`)
} catch (error) {
logger.error(`Error fetching ${collection}: ${error}`)
return
}
},
}
}
export type PocketbaseLoaderOptions = {
collection: Collection;
};
collection: Collection
}

View File

@@ -1,17 +1,17 @@
// This file was automatically generated by Astro PocketBase.
import { defineMiddleware } from "astro:middleware";
import { helpersFrom } from "astro-pocketbase-continue";
import PocketBase from "pocketbase";
import { defineMiddleware } from 'astro:middleware'
import { helpersFrom } from 'astro-pocketbase-continue'
import PocketBase from 'pocketbase'
const middleware = defineMiddleware((context, next) => {
const pocketbase = new PocketBase(import.meta.env.PUBLIC_ASTRO_POCKETBASE_URL);
const { getRecord, getRecords } = helpersFrom({ pocketbase });
context.locals.pocketbase = pocketbase;
context.locals.getRecord = getRecord;
context.locals.getRecords = getRecords;
return next();
});
const pocketbase = new PocketBase(import.meta.env.PUBLIC_ASTRO_POCKETBASE_URL)
const { getRecord, getRecords } = helpersFrom({ pocketbase })
context.locals.pocketbase = pocketbase
context.locals.getRecord = getRecord
context.locals.getRecords = getRecords
return next()
})
// You should NOT change the exported name as it is used by the Astro PocketBase integration.
export { middleware as onRequest };
export { middleware as onRequest }

View File

@@ -1,17 +1,17 @@
import { defineToolbarApp } from "astro/toolbar";
import { defineToolbarApp } from 'astro/toolbar'
export default defineToolbarApp({
init(_canvas, app, server) {
let pending = false;
init(_canvas, app, server) {
let pending = false
// const button = document.querySelector("astro-dev-toolbar")?.shadowRoot.querySelector("button[data-app-id='astro-pocketbase-continue']");
// const button = document.querySelector("astro-dev-toolbar")?.shadowRoot.querySelector("button[data-app-id='astro-pocketbase-continue']");
app.onToggled(({ state }) => {
if (!state) return;
app.toggleNotification({ level: "error", state: true });
if (pending) return;
pending = true;
server.send("astro-pocketbase-continue:refresh", undefined);
});
},
});
app.onToggled(({ state }) => {
if (!state) return
app.toggleNotification({ level: 'error', state: true })
if (pending) return
pending = true
server.send('astro-pocketbase-continue:refresh', undefined)
})
},
})

53
biome.json Normal file
View File

@@ -0,0 +1,53 @@
{
"$schema": "https://biomejs.dev/schemas/2.2.6/schema.json",
"vcs": {
"enabled": false,
"clientKind": "git",
"useIgnoreFile": false
},
"files": {
"ignoreUnknown": false,
"includes": ["**", "!**/node_modules", "!**/dist"]
},
"formatter": {
"enabled": true,
"formatWithErrors": false,
"indentStyle": "tab",
"indentWidth": 2,
"lineEnding": "lf",
"lineWidth": 100,
"attributePosition": "auto",
"bracketSameLine": false,
"bracketSpacing": true,
"expand": "auto",
"useEditorconfig": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
},
"javascript": {
"formatter": {
"jsxQuoteStyle": "double",
"quoteProperties": "asNeeded",
"trailingCommas": "all",
"semicolons": "asNeeded",
"arrowParentheses": "always",
"bracketSameLine": false,
"quoteStyle": "single",
"attributePosition": "auto",
"bracketSpacing": true
}
},
"overrides": [{ "includes": ["**/*.ts", "**/*.tsx"] }],
"assist": {
"enabled": true,
"actions": {
"source": {
"organizeImports": "on"
}
}
}
}

View File

@@ -7,20 +7,21 @@
"astro-integration-kit": "^0.19.0",
"dotenv": "^17.2.3",
"es-toolkit": "^1.30.1",
"zod-pocketbase-continue": "^0.5.0",
"zod-pocketbase-continue": "^0.6.0",
},
"devDependencies": {
"@biomejs/biome": "2.2.6",
"@changesets/cli": "^2.29.7",
"@typescript-eslint/eslint-plugin": "^8.46.1",
"@typescript-eslint/parser": "^8.46.1",
"pocketbase": "^0.26.2",
"tsdown": "^0.15.7",
"zod": "^3.25.76",
"zod": "^4.1.12",
},
"peerDependencies": {
"astro": "^5.14.4",
"pocketbase": "^0.26.2",
"zod": "^3.25.76",
"zod": "^4.1.12",
},
},
},
@@ -47,6 +48,24 @@
"@babel/types": ["@babel/types@7.28.4", "", { "dependencies": { "@babel/helper-string-parser": "^7.27.1", "@babel/helper-validator-identifier": "^7.27.1" } }, "sha512-bkFqkLhh3pMBUQQkpVgWDWq/lqzc2678eUyDlTBhRqhCHFguYYGM0Efga7tYk4TogG/3x0EEl66/OQ+WGbWB/Q=="],
"@biomejs/biome": ["@biomejs/biome@2.2.6", "", { "optionalDependencies": { "@biomejs/cli-darwin-arm64": "2.2.6", "@biomejs/cli-darwin-x64": "2.2.6", "@biomejs/cli-linux-arm64": "2.2.6", "@biomejs/cli-linux-arm64-musl": "2.2.6", "@biomejs/cli-linux-x64": "2.2.6", "@biomejs/cli-linux-x64-musl": "2.2.6", "@biomejs/cli-win32-arm64": "2.2.6", "@biomejs/cli-win32-x64": "2.2.6" }, "bin": { "biome": "bin/biome" } }, "sha512-yKTCNGhek0rL5OEW1jbLeZX8LHaM8yk7+3JRGv08my+gkpmtb5dDE+54r2ZjZx0ediFEn1pYBOJSmOdDP9xtFw=="],
"@biomejs/cli-darwin-arm64": ["@biomejs/cli-darwin-arm64@2.2.6", "", { "os": "darwin", "cpu": "arm64" }, "sha512-UZPmn3M45CjTYulgcrFJFZv7YmK3pTxTJDrFYlNElT2FNnkkX4fsxjExTSMeWKQYoZjvekpH5cvrYZZlWu3yfA=="],
"@biomejs/cli-darwin-x64": ["@biomejs/cli-darwin-x64@2.2.6", "", { "os": "darwin", "cpu": "x64" }, "sha512-HOUIquhHVgh/jvxyClpwlpl/oeMqntlteL89YqjuFDiZ091P0vhHccwz+8muu3nTyHWM5FQslt+4Jdcd67+xWQ=="],
"@biomejs/cli-linux-arm64": ["@biomejs/cli-linux-arm64@2.2.6", "", { "os": "linux", "cpu": "arm64" }, "sha512-BpGtuMJGN+o8pQjvYsUKZ+4JEErxdSmcRD/JG3mXoWc6zrcA7OkuyGFN1mDggO0Q1n7qXxo/PcupHk8gzijt5g=="],
"@biomejs/cli-linux-arm64-musl": ["@biomejs/cli-linux-arm64-musl@2.2.6", "", { "os": "linux", "cpu": "arm64" }, "sha512-TjCenQq3N6g1C+5UT3jE1bIiJb5MWQvulpUngTIpFsL4StVAUXucWD0SL9MCW89Tm6awWfeXBbZBAhJwjyFbRQ=="],
"@biomejs/cli-linux-x64": ["@biomejs/cli-linux-x64@2.2.6", "", { "os": "linux", "cpu": "x64" }, "sha512-1HaM/dpI/1Z68zp8ZdT6EiBq+/O/z97a2AiHMl+VAdv5/ELckFt9EvRb8hDHpk8hUMoz03gXkC7VPXOVtU7faA=="],
"@biomejs/cli-linux-x64-musl": ["@biomejs/cli-linux-x64-musl@2.2.6", "", { "os": "linux", "cpu": "x64" }, "sha512-1ZcBux8zVM3JhWN2ZCPaYf0+ogxXG316uaoXJdgoPZcdK/rmRcRY7PqHdAos2ExzvjIdvhQp72UcveI98hgOog=="],
"@biomejs/cli-win32-arm64": ["@biomejs/cli-win32-arm64@2.2.6", "", { "os": "win32", "cpu": "arm64" }, "sha512-h3A88G8PGM1ryTeZyLlSdfC/gz3e95EJw9BZmA6Po412DRqwqPBa2Y9U+4ZSGUAXCsnSQE00jLV8Pyrh0d+jQw=="],
"@biomejs/cli-win32-x64": ["@biomejs/cli-win32-x64@2.2.6", "", { "os": "win32", "cpu": "x64" }, "sha512-yx0CqeOhPjYQ5ZXgPfu8QYkgBhVJyvWe36as7jRuPrKPO5ylVDfwVtPQ+K/mooNTADW0IhxOZm3aPu16dP8yNQ=="],
"@capsizecss/unpack": ["@capsizecss/unpack@3.0.0", "", { "dependencies": { "fontkit": "^2.0.2" } }, "sha512-+ntATQe1AlL7nTOYjwjj6w3299CgRot48wL761TUGYpYgAou3AaONZazp0PKZyCyWhudWsjhq1nvRHOvbMzhTA=="],
"@changesets/apply-release-plan": ["@changesets/apply-release-plan@7.0.13", "", { "dependencies": { "@changesets/config": "^3.1.1", "@changesets/get-version-range-type": "^0.4.0", "@changesets/git": "^3.0.4", "@changesets/should-skip-package": "^0.1.2", "@changesets/types": "^6.1.0", "@manypkg/get-packages": "^1.1.3", "detect-indent": "^6.0.0", "fs-extra": "^7.0.1", "lodash.startcase": "^4.4.0", "outdent": "^0.5.0", "prettier": "^2.7.1", "resolve-from": "^5.0.0", "semver": "^7.5.3" } }, "sha512-BIW7bofD2yAWoE8H4V40FikC+1nNFEKBisMECccS16W1rt6qqhNTBDmIw5HaqmMgtLNz9e7oiALiEUuKrQ4oHg=="],
@@ -435,7 +454,7 @@
"brotli": ["brotli@1.3.3", "", { "dependencies": { "base64-js": "^1.1.2" } }, "sha512-oTKjJdShmDuGW94SyyaoQvAjf30dZaHnjJ8uAF+u2/vGJkJbJPJAT1gDiOJP5v1Zb6f9KEyW/1HpuaWIXtGHPg=="],
"c12": ["c12@3.3.0", "", { "dependencies": { "chokidar": "^4.0.3", "confbox": "^0.2.2", "defu": "^6.1.4", "dotenv": "^17.2.2", "exsolve": "^1.0.7", "giget": "^2.0.0", "jiti": "^2.5.1", "ohash": "^2.0.11", "pathe": "^2.0.3", "perfect-debounce": "^2.0.0", "pkg-types": "^2.3.0", "rc9": "^2.1.2" }, "peerDependencies": { "magicast": "^0.3.5" }, "optionalPeers": ["magicast"] }, "sha512-K9ZkuyeJQeqLEyqldbYLG3wjqwpw4BVaAqvmxq3GYKK0b1A/yYQdIcJxkzAOWcNVWhJpRXAPfZFueekiY/L8Dw=="],
"c12": ["c12@3.3.1", "", { "dependencies": { "chokidar": "^4.0.3", "confbox": "^0.2.2", "defu": "^6.1.4", "dotenv": "^17.2.3", "exsolve": "^1.0.7", "giget": "^2.0.0", "jiti": "^2.6.1", "ohash": "^2.0.11", "pathe": "^2.0.3", "perfect-debounce": "^2.0.0", "pkg-types": "^2.3.0", "rc9": "^2.1.2" }, "peerDependencies": { "magicast": "^0.3.5" }, "optionalPeers": ["magicast"] }, "sha512-LcWQ01LT9tkoUINHgpIOv3mMs+Abv7oVCrtpMRi1PaapVEpWoMga5WuT7/DqFTu7URP9ftbOmimNw1KNIGh9DQ=="],
"cac": ["cac@6.7.14", "", {}, "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ=="],
@@ -1113,9 +1132,9 @@
"yoctocolors": ["yoctocolors@2.1.2", "", {}, "sha512-CzhO+pFNo8ajLM2d2IW/R93ipy99LWjtwblvC1RsoSUMZgyLbYFr221TnSNT7GjGdYui6P459mw9JH/g/zW2ug=="],
"zod": ["zod@3.25.76", "", {}, "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ=="],
"zod": ["zod@4.1.12", "", {}, "sha512-JInaHOamG8pt5+Ey8kGmdcAcg3OL9reK8ltczgHTAwNhMys/6ThXHityHxVV2p3fkw/c+MAvBHFVYHFZDmjMCQ=="],
"zod-pocketbase-continue": ["zod-pocketbase-continue@0.5.0", "", { "dependencies": { "@clack/prompts": "^0.11.0", "c12": "^3.3.0", "citty": "^0.1.6", "es-toolkit": "^1.40.0" }, "peerDependencies": { "pocketbase": "^0.26.2", "zod": "^3.25.76" }, "bin": { "zod-pocketbase-continue": "dist/server/cli.js" } }, "sha512-4Wag9RSpozpnMqXthOtAn3F52SNhfWvMdTv9LOOTK1C1Lps4TYoafiWEWTwWnFFDLNA6HQ+WmEsfTdsG+CJINg=="],
"zod-pocketbase-continue": ["zod-pocketbase-continue@0.6.0", "", { "dependencies": { "@clack/prompts": "^0.11.0", "c12": "^3.3.1", "citty": "^0.1.6", "es-toolkit": "^1.40.0" }, "peerDependencies": { "pocketbase": "^0.26.2", "zod": "^4.1.12" }, "bin": { "zod-pocketbase-continue": "dist/server/cli.js" } }, "sha512-znZa/bYWulC9v2WYxgHs95OakHs+SYoZz2WC2lxFq9VFr5O9ZO1MrIgVBYt33EAGPGXceb0HE/IrQzoP5vBvWQ=="],
"zod-to-json-schema": ["zod-to-json-schema@3.24.6", "", { "peerDependencies": { "zod": "^3.24.1" } }, "sha512-h/z3PKvcTcTetyjl1fkj79MHNEjm+HpD6NXheWjzOekY7kV+lwDYnHw+ivHkijnCSMz1yJaWBD9vu/Fcmk+vEg=="],
@@ -1159,6 +1178,8 @@
"astro/package-manager-detector": ["package-manager-detector@1.4.0", "", {}, "sha512-rRZ+pR1Usc+ND9M2NkmCvE/LYJS+8ORVV9X0KuNSY/gFsp7RBHJM/ADh9LYq4Vvfq6QkKrW6/weuh8SMEtN5gw=="],
"astro/zod": ["zod@3.25.76", "", {}, "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ=="],
"boxen/chalk": ["chalk@5.6.2", "", {}, "sha512-7NzBL0rN6fMUW+f7A6Io4h40qQlG+xGmtMxfbnH/K7TAtt8JQWVQK+6g0UXKMeVJoyV5EkkNsErQ8pVD3bLHbA=="],
"c12/pathe": ["pathe@2.0.3", "", {}, "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w=="],

View File

@@ -1,22 +0,0 @@
import typescript from "@typescript-eslint/eslint-plugin";
import typescriptParser from "@typescript-eslint/parser";
export default [
{
files: ["**/*.ts", "**/*.tsx"],
languageOptions: {
parser: typescriptParser,
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
project: "./tsconfig.json",
},
},
plugins: {
"@typescript-eslint": typescript,
},
rules: {
...typescript.configs.recommended.rules,
},
},
];

View File

@@ -1,67 +1,67 @@
{
"name": "astro-pocketbase-continue",
"version": "0.12.1",
"description": "Astro integration to ease the use of PocketBase in your Astro projects",
"author": {
"email": "garandplg@garandplg.com",
"name": "Garand_PLG",
"url": "https://gitea.garandplg.com"
},
"license": "MIT",
"keywords": [
"astro-integration",
"astro-component",
"withastro",
"astro",
"pocketbase",
"tooling",
"utils",
"utility"
],
"homepage": "https://gitea.garandplg.com/GarandPLG/astro-pocketbase-continue",
"publishConfig": {
"access": "public"
},
"type": "module",
"sideEffects": false,
"packageManager": "bun@1.3.0",
"engines": {
"node": ">=24.9.0"
},
"main": "dist/index.js",
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
},
"files": [
"dist",
"assets"
],
"scripts": {
"dev": "tsdown --watch",
"build": "tsdown",
"changeset": "changeset",
"release": "bun scripts/release.mjs"
},
"dependencies": {
"astro-integration-kit": "^0.19.0",
"dotenv": "^17.2.3",
"es-toolkit": "^1.30.1",
"zod-pocketbase-continue": "^0.5.0"
},
"devDependencies": {
"@changesets/cli": "^2.29.7",
"@typescript-eslint/eslint-plugin": "^8.46.1",
"@typescript-eslint/parser": "^8.46.1",
"pocketbase": "^0.26.2",
"tsdown": "^0.15.7",
"zod": "^3.25.76"
},
"peerDependencies": {
"astro": "^5.14.4",
"pocketbase": "^0.26.2",
"zod": "^3.25.76"
}
"name": "astro-pocketbase-continue",
"version": "0.12.1",
"description": "Astro integration to ease the use of PocketBase in your Astro projects",
"author": {
"email": "garandplg@garandplg.com",
"name": "Garand_PLG",
"url": "https://gitea.garandplg.com"
},
"license": "MIT",
"keywords": [
"astro-integration",
"astro-component",
"withastro",
"astro",
"pocketbase",
"tooling",
"utils",
"utility"
],
"homepage": "https://gitea.garandplg.com/GarandPLG/astro-pocketbase-continue",
"publishConfig": {
"access": "public"
},
"type": "module",
"sideEffects": false,
"packageManager": "bun@1.3.0",
"engines": {
"node": ">=24.9.0"
},
"main": "dist/index.js",
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
},
"files": ["dist", "assets"],
"scripts": {
"dev": "tsdown --watch",
"build": "tsdown",
"changeset": "changeset",
"release": "bun scripts/release.mjs",
"lint": "biome check .",
"lint:w": "biome check --write .",
"format": "biome format .",
"format:w": "biome format --write ."
},
"dependencies": {
"astro-integration-kit": "^0.19.0",
"dotenv": "^17.2.3",
"es-toolkit": "^1.30.1",
"zod-pocketbase-continue": "^0.6.0"
},
"devDependencies": {
"@biomejs/biome": "2.2.6",
"@changesets/cli": "^2.29.7",
"pocketbase": "^0.26.2",
"tsdown": "^0.15.7",
"zod": "^4.1.12"
},
"peerDependencies": {
"astro": "^5.14.4",
"pocketbase": "^0.26.2",
"zod": "^4.1.12"
}
}

View File

@@ -1,4 +0,0 @@
/** @type {import("prettier").Config} */
export default {
printWidth: 140,
};

View File

@@ -1,5 +1,5 @@
import { spawn } from "node:child_process";
import { resolve } from "node:path";
import { spawn } from 'node:child_process'
import { resolve } from 'node:path'
/**
*
@@ -9,41 +9,41 @@ import { resolve } from "node:path";
* @returns {Promise<string>}
*/
const run = async (command, ...args) => {
const cwd = resolve();
return new Promise((resolve) => {
const cmd = spawn(command, args, {
stdio: ["inherit", "pipe", "pipe"], // Inherit stdin, pipe stdout, pipe stderr
shell: true,
cwd,
});
const cwd = resolve()
return new Promise((resolve) => {
const cmd = spawn(command, args, {
stdio: ['inherit', 'pipe', 'pipe'], // Inherit stdin, pipe stdout, pipe stderr
shell: true,
cwd,
})
let output = "";
let output = ''
cmd.stdout.on("data", (data) => {
process.stdout.write(data.toString());
output += data.toString();
});
cmd.stdout.on('data', (data) => {
process.stdout.write(data.toString())
output += data.toString()
})
cmd.stderr.on("data", (data) => {
process.stderr.write(data.toString());
});
cmd.stderr.on('data', (data) => {
process.stderr.write(data.toString())
})
cmd.on("close", () => {
resolve(output);
});
});
};
cmd.on('close', () => {
resolve(output)
})
})
}
const main = async () => {
await run("bun changeset version");
await run("git add .");
await run('git commit -m "chore: update version"');
await run("git push");
await run("bun run build");
await run("bun changeset publish");
await run("git push --follow-tags");
const tag = (await run("git describe --abbrev=0")).replace("\n", "");
await run(`tea releases create --tag ${tag} --title "${tag}"`);
};
await run('bun changeset version')
await run('git add .')
await run('git commit -m "chore: update version"')
await run('git push')
await run('bun run build')
await run('bun changeset publish')
await run('git push --follow-tags')
const tag = (await run('git describe --abbrev=0')).replace('\n', '')
await run(`tea releases create --tag ${tag} --title "${tag}"`)
}
main();
main()

View File

@@ -1,4 +1,5 @@
import { integration } from "@/integration.js";
export * from "zod-pocketbase-continue";
import { integration } from '@/integration.js'
export default integration;
export * from 'zod-pocketbase-continue'
export default integration

View File

@@ -1,74 +1,83 @@
import { createResolver, defineIntegration } from "astro-integration-kit";
import dotenv from "dotenv";
import { readFileSync, writeFileSync, existsSync } from "node:fs";
import type { CollectionModel } from "pocketbase";
import { Config, Credentials, defaultConfig, fetchCollections } from "zod-pocketbase-continue";
import { generate } from "zod-pocketbase-continue/server";
import { existsSync, readFileSync, writeFileSync } from 'node:fs'
import { createResolver, defineIntegration } from 'astro-integration-kit'
import dotenv from 'dotenv'
import type { CollectionModel } from 'pocketbase'
import { Config, Credentials, defaultConfig, fetchCollections } from 'zod-pocketbase-continue'
import { generate } from 'zod-pocketbase-continue/server'
dotenv.config();
dotenv.config()
export const integration = defineIntegration({
name: "astro-pocketbase-continue",
optionsSchema: Config.omit({ adminEmail: true, adminPassword: true, output: true, url: true }).default(defaultConfig),
setup({ options }) {
const { resolve } = createResolver(import.meta.url);
name: 'astro-pocketbase-continue',
optionsSchema: Config.omit({
adminEmail: true,
adminPassword: true,
output: true,
url: true,
}).default(defaultConfig),
setup({ options }) {
const { resolve } = createResolver(import.meta.url)
let collections: CollectionModel[] = [];
let collections: CollectionModel[] = []
return {
hooks: {
"astro:config:setup": async (params) => {
const { addDevToolbarApp, addMiddleware, config, logger } = params;
const { srcDir } = config;
return {
hooks: {
'astro:config:setup': async (params) => {
const { addDevToolbarApp, addMiddleware, config, logger } = params
const { srcDir } = config
const {
ASTRO_POCKETBASE_ADMIN_EMAIL: adminEmail,
ASTRO_POCKETBASE_ADMIN_PASSWORD: adminPassword,
PUBLIC_ASTRO_POCKETBASE_URL: url,
} = process.env;
const {
ASTRO_POCKETBASE_ADMIN_EMAIL: adminEmail,
ASTRO_POCKETBASE_ADMIN_PASSWORD: adminPassword,
PUBLIC_ASTRO_POCKETBASE_URL: url,
} = process.env
try {
const output = `${srcDir.pathname}lib/pocketbase/schemas.ts`;
const config = Config.parse({ ...options, adminEmail, adminPassword, url, output });
const credentials = Credentials.parse(config);
const allCollections = await fetchCollections(credentials);
collections = allCollections.filter(({ name }) => !config.ignore.includes(name));
await generate(collections, config);
} catch (error) {
logger.error(error instanceof Error ? error.message : "unknown error");
}
try {
const output = `${srcDir.pathname}lib/pocketbase/schemas.ts`
const config = Config.parse({ ...options, adminEmail, adminPassword, url, output })
const credentials = Credentials.parse(config)
const allCollections = await fetchCollections(credentials)
collections = allCollections.filter(({ name }) => !config.ignore.includes(name))
await generate(collections, config)
} catch (error) {
logger.error(error instanceof Error ? error.message : 'unknown error')
}
if (!existsSync(new URL("lib/pocketbase/loader.ts", srcDir))) {
const loaderContent = readFileSync(resolve("../assets/loader.ts"), "utf-8");
writeFileSync(new URL("lib/pocketbase/loader.ts", srcDir), loaderContent);
}
if (!existsSync(new URL('lib/pocketbase/loader.ts', srcDir))) {
const loaderContent = readFileSync(resolve('../assets/loader.ts'), 'utf-8')
writeFileSync(new URL('lib/pocketbase/loader.ts', srcDir), loaderContent)
}
if (!existsSync(new URL("lib/pocketbase/middleware.ts", srcDir))) {
const middlewareContent = readFileSync(resolve("../assets/middleware.ts"), "utf-8");
writeFileSync(new URL("lib/pocketbase/middleware.ts", srcDir), middlewareContent);
}
addMiddleware({ entrypoint: new URL("lib/pocketbase/middleware.ts", srcDir), order: "pre" });
if (!existsSync(new URL('lib/pocketbase/middleware.ts', srcDir))) {
const middlewareContent = readFileSync(resolve('../assets/middleware.ts'), 'utf-8')
writeFileSync(new URL('lib/pocketbase/middleware.ts', srcDir), middlewareContent)
}
addMiddleware({
entrypoint: new URL('lib/pocketbase/middleware.ts', srcDir),
order: 'pre',
})
addDevToolbarApp({
id: "astro-pocketbase-continue",
name: "Astro PocketBase Continued",
icon: `<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>PocketBase</title><path fill="currentColor" d="M5.684 12a.632.632 0 0 1-.631-.632V4.421c0-.349.282-.632.631-.632h2.37c.46 0 .889.047 1.287.139.407.084.758.23 1.053.44.303.202.541.475.715.82.173.335.26.75.26 1.246 0 .479-.092.894-.273 1.247a2.373 2.373 0 0 1-.715.869 3.11 3.11 0 0 1-1.053.503c-.398.11-.823.164-1.273.164h-.46a.632.632 0 0 0-.632.632v1.52a.632.632 0 0 1-.632.631Zm1.279-4.888c0 .349.283.632.632.632h.343c1.04 0 1.56-.437 1.56-1.31 0-.428-.135-.73-.404-.907-.26-.176-.645-.264-1.156-.264h-.343a.632.632 0 0 0-.632.631Zm6.3 13.098a.632.632 0 0 1-.631-.631v-6.947a.63.63 0 0 1 .631-.632h2.203c.44 0 .845.034 1.216.1.38.06.708.169.984.328.276.16.492.37.647.63.164.26.246.587.246.982 0 .185-.03.37-.09.554a1.537 1.537 0 0 1-.26.516 1.857 1.857 0 0 1-1.076.7.031.031 0 0 0-.023.03c0 .015.01.028.025.03.591.111 1.04.32 1.346.626.311.31.466.743.466 1.297 0 .42-.082.78-.246 1.083a2.153 2.153 0 0 1-.685.755 3.4 3.4 0 0 1-1.036.441 5.477 5.477 0 0 1-1.268.139zm1.271-5.542c0 .349.283.631.632.631h.21c.465 0 .802-.088 1.009-.264.207-.176.31-.424.31-.743 0-.302-.107-.516-.323-.642-.207-.135-.535-.202-.984-.202h-.222a.632.632 0 0 0-.632.632Zm0 3.463c0 .349.283.631.632.631h.39c1.019 0 1.528-.369 1.528-1.108 0-.36-.125-.621-.376-.78-.241-.16-.625-.24-1.152-.24h-.39a.632.632 0 0 0-.632.632zM1.389 0C.629 0 0 .629 0 1.389V15.03a1.4 1.4 0 0 0 1.389 1.39H8.21a.632.632 0 0 0 .63-.632.632.632 0 0 0-.63-.63H1.389c-.078 0-.125-.05-.125-.128V1.39c0-.078.047-.125.125-.125H15.03c.078 0 .127.047.127.125v6.82a.632.632 0 0 0 .631.63.632.632 0 0 0 .633-.63V1.389A1.4 1.4 0 0 0 15.032 0ZM15.79 7.578a.632.632 0 0 0-.632.633.632.632 0 0 0 .631.63h6.822c.078 0 .125.05.125.128V22.61c0 .078-.047.125-.125.125H8.97c-.077 0-.127-.047-.127-.125v-6.82a.632.632 0 0 0-.631-.63.632.632 0 0 0-.633.63v6.822A1.4 1.4 0 0 0 8.968 24h13.643c.76 0 1.389-.629 1.389-1.389V8.97a1.4 1.4 0 0 0-1.389-1.39Z"/></svg>`,
entrypoint: resolve("../assets/toolbar.ts"),
});
},
addDevToolbarApp({
id: 'astro-pocketbase-continue',
name: 'Astro PocketBase Continued',
icon: `<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>PocketBase</title><path fill="currentColor" d="M5.684 12a.632.632 0 0 1-.631-.632V4.421c0-.349.282-.632.631-.632h2.37c.46 0 .889.047 1.287.139.407.084.758.23 1.053.44.303.202.541.475.715.82.173.335.26.75.26 1.246 0 .479-.092.894-.273 1.247a2.373 2.373 0 0 1-.715.869 3.11 3.11 0 0 1-1.053.503c-.398.11-.823.164-1.273.164h-.46a.632.632 0 0 0-.632.632v1.52a.632.632 0 0 1-.632.631Zm1.279-4.888c0 .349.283.632.632.632h.343c1.04 0 1.56-.437 1.56-1.31 0-.428-.135-.73-.404-.907-.26-.176-.645-.264-1.156-.264h-.343a.632.632 0 0 0-.632.631Zm6.3 13.098a.632.632 0 0 1-.631-.631v-6.947a.63.63 0 0 1 .631-.632h2.203c.44 0 .845.034 1.216.1.38.06.708.169.984.328.276.16.492.37.647.63.164.26.246.587.246.982 0 .185-.03.37-.09.554a1.537 1.537 0 0 1-.26.516 1.857 1.857 0 0 1-1.076.7.031.031 0 0 0-.023.03c0 .015.01.028.025.03.591.111 1.04.32 1.346.626.311.31.466.743.466 1.297 0 .42-.082.78-.246 1.083a2.153 2.153 0 0 1-.685.755 3.4 3.4 0 0 1-1.036.441 5.477 5.477 0 0 1-1.268.139zm1.271-5.542c0 .349.283.631.632.631h.21c.465 0 .802-.088 1.009-.264.207-.176.31-.424.31-.743 0-.302-.107-.516-.323-.642-.207-.135-.535-.202-.984-.202h-.222a.632.632 0 0 0-.632.632Zm0 3.463c0 .349.283.631.632.631h.39c1.019 0 1.528-.369 1.528-1.108 0-.36-.125-.621-.376-.78-.241-.16-.625-.24-1.152-.24h-.39a.632.632 0 0 0-.632.632zM1.389 0C.629 0 0 .629 0 1.389V15.03a1.4 1.4 0 0 0 1.389 1.39H8.21a.632.632 0 0 0 .63-.632.632.632 0 0 0-.63-.63H1.389c-.078 0-.125-.05-.125-.128V1.39c0-.078.047-.125.125-.125H15.03c.078 0 .127.047.127.125v6.82a.632.632 0 0 0 .631.63.632.632 0 0 0 .633-.63V1.389A1.4 1.4 0 0 0 15.032 0ZM15.79 7.578a.632.632 0 0 0-.632.633.632.632 0 0 0 .631.63h6.822c.078 0 .125.05.125.128V22.61c0 .078-.047.125-.125.125H8.97c-.077 0-.127-.047-.127-.125v-6.82a.632.632 0 0 0-.631-.63.632.632 0 0 0-.633.63v6.822A1.4 1.4 0 0 0 8.968 24h13.643c.76 0 1.389-.629 1.389-1.389V8.97a1.4 1.4 0 0 0-1.389-1.39Z"/></svg>`,
entrypoint: resolve('../assets/toolbar.ts'),
})
},
"astro:config:done": ({ injectTypes }) => {
const content = readFileSync(resolve("../assets/env.d.ts"), "utf-8");
injectTypes({ filename: "env.d.ts", content });
},
'astro:config:done': ({ injectTypes }) => {
const content = readFileSync(resolve('../assets/env.d.ts'), 'utf-8')
injectTypes({ filename: 'env.d.ts', content })
},
"astro:server:setup": ({ refreshContent, toolbar }) => {
toolbar.on("astro-pocketbase-continue:refresh", async () => {
if (!refreshContent) console.warn("Content can only be refreshed in Astro v5.0.0 or higher");
await refreshContent?.({ loaders: ["pocketbase-loader"] });
});
},
},
};
},
});
'astro:server:setup': ({ refreshContent, toolbar }) => {
toolbar.on('astro-pocketbase-continue:refresh', async () => {
if (!refreshContent)
console.warn('Content can only be refreshed in Astro v5.0.0 or higher')
await refreshContent?.({ loaders: ['pocketbase-loader'] })
})
},
},
}
},
})

View File

@@ -1,57 +1,57 @@
{
"extends": "astro/tsconfigs/strictest",
"$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": {
// Enable top-level await, and other modern ESM features.
"target": "ESNext",
"module": "NodeNext",
// Enable module resolution without file extensions on relative paths, for things like npm package imports.
"moduleResolution": "nodenext",
// Allow importing TypeScript files using their native extension (.ts(x)).
"allowImportingTsExtensions": true,
// Enable JSON imports.
"resolveJsonModule": true,
// Enforce the usage of type-only imports when needed, which helps avoiding bundling issues.
"verbatimModuleSyntax": true,
// Ensure that each file can be transpiled without relying on other imports.
// This is redundant with the previous option, however it ensures that it's on even if someone disable `verbatimModuleSyntax`
"isolatedModules": true,
// Astro directly run TypeScript code, no transpilation needed.
"noEmit": true,
// Report an error when importing a file using a casing different from another import of the same file.
"forceConsistentCasingInFileNames": true,
// Properly support importing CJS modules in ESM
"esModuleInterop": true,
// Skip typechecking libraries and .d.ts files
"skipLibCheck": true,
// Allow JavaScript files to be imported
"allowJs": true,
// Allow JSX files (or files that are internally considered JSX, like Astro files) to be imported inside `.js` and `.ts` files.
"jsx": "preserve",
// Enable strict mode. This enables a few options at a time, see https://www.typescriptlang.org/tsconfig#strict for a list.
"strict": true,
// Report errors for fallthrough cases in switch statements
"noFallthroughCasesInSwitch": true,
// Force functions designed to override their parent class to be specified as `override`.
"noImplicitOverride": true,
// Force functions to specify that they can return `undefined` if a possible code path does not return a value.
"noImplicitReturns": true,
// Report an error when a variable is declared but never used.
"noUnusedLocals": true,
// Report an error when a parameter is declared but never used.
"noUnusedParameters": true,
// Force the usage of the indexed syntax to access fields declared using an index signature.
"noUncheckedIndexedAccess": true,
// Report an error when the value `undefined` is given to an optional property that doesn't specify `undefined` as a valid value.
"exactOptionalPropertyTypes": true,
// 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,
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
},
"exclude": ["dist"]
"compilerOptions": {
// Enable top-level await, and other modern ESM features.
"target": "ESNext",
"module": "NodeNext",
// Enable module resolution without file extensions on relative paths, for things like npm package imports.
"moduleResolution": "nodenext",
// Allow importing TypeScript files using their native extension (.ts(x)).
"allowImportingTsExtensions": true,
// Enable JSON imports.
"resolveJsonModule": true,
// Enforce the usage of type-only imports when needed, which helps avoiding bundling issues.
"verbatimModuleSyntax": true,
// Ensure that each file can be transpiled without relying on other imports.
// This is redundant with the previous option, however it ensures that it's on even if someone disable `verbatimModuleSyntax`
"isolatedModules": true,
// Astro directly run TypeScript code, no transpilation needed.
"noEmit": true,
// Report an error when importing a file using a casing different from another import of the same file.
"forceConsistentCasingInFileNames": true,
// Properly support importing CJS modules in ESM
"esModuleInterop": true,
// Skip typechecking libraries and .d.ts files
"skipLibCheck": true,
// Allow JavaScript files to be imported
"allowJs": true,
// Allow JSX files (or files that are internally considered JSX, like Astro files) to be imported inside `.js` and `.ts` files.
"jsx": "preserve",
// Enable strict mode. This enables a few options at a time, see https://www.typescriptlang.org/tsconfig#strict for a list.
"strict": true,
// Report errors for fallthrough cases in switch statements
"noFallthroughCasesInSwitch": true,
// Force functions designed to override their parent class to be specified as `override`.
"noImplicitOverride": true,
// Force functions to specify that they can return `undefined` if a possible code path does not return a value.
"noImplicitReturns": true,
// Report an error when a variable is declared but never used.
"noUnusedLocals": true,
// Report an error when a parameter is declared but never used.
"noUnusedParameters": true,
// Force the usage of the indexed syntax to access fields declared using an index signature.
"noUncheckedIndexedAccess": true,
// Report an error when the value `undefined` is given to an optional property that doesn't specify `undefined` as a valid value.
"exactOptionalPropertyTypes": true,
// 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,
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
},
"exclude": ["dist"]
}

View File

@@ -1,19 +1,19 @@
import { defineConfig } from "tsdown";
import { peerDependencies } from "./package.json" with { type: "json" };
import { defineConfig } from 'tsdown'
import { peerDependencies } from './package.json' with { type: 'json' }
export default defineConfig((options) => {
const dev = !!options.watch;
return {
entry: ["src/**/*.(ts|js)"],
format: ["esm"],
target: "node24",
unbundle: true,
dts: true,
sourcemap: true,
clean: true,
splitting: false,
minify: !dev,
external: [...Object.keys(peerDependencies)],
tsconfig: "tsconfig.json",
};
});
const dev = !!options.watch
return {
entry: ['src/**/*.(ts|js)'],
format: ['esm'],
target: 'node24',
unbundle: true,
dts: true,
sourcemap: true,
clean: true,
splitting: false,
minify: !dev,
external: [...Object.keys(peerDependencies)],
tsconfig: 'tsconfig.json',
}
})