Firebase Data Source Driver
fable-ui/firebase-driverFreeUtility
Optional Fable UI data source driver for allowlisted Firestore resources.
Live preview
live · rendered by the registry
Rendered by fable-ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://fable-ui.shobky.com/r/firebase-driver.jsonSource
1import {2 getDataValue,3 queryLocalRows,4 type DataActionInput,5 type DataActionResult,6 type DataFilter,7 type DataQuery,8 type DataQueryResult,9 type DataRow,10 type DataSourceContext,11 type DataSourceDriver,12 type ResourceConfig,13 type ResourceRuntime,14} from "@/lib/fable-ui/core"15import type {16 FirebaseAuthLike,17 FirebaseDriverConfig,18 FirestorePathParam,19 FirestoreResourceSource,20 FirestoreSdk,21} from "./firebase-driver.types"2223async function loadFirestoreSdk(): Promise<FirestoreSdk> {24 const moduleName = "firebase/firestore"25 return (await import(moduleName)) as FirestoreSdk26}2728function mapFirestoreError(error: unknown) {29 const message = error instanceof Error ? error.message : String(error || "")30 const code =31 typeof error === "object" && error && "code" in error32 ? String((error as { code?: unknown }).code)33 : ""3435 if (/permission-denied|permission|forbidden/i.test(`${code} ${message}`)) {36 return new Error("Firestore permission denied. Check authentication and security rules.")37 }3839 if (/failed-precondition|index/i.test(`${code} ${message}`)) {40 return new Error("Firestore query requires an index. Check the Firebase console index suggestion.")41 }4243 if (/invalid-argument|invalid/i.test(`${code} ${message}`)) {44 return new Error(`Firestore query is invalid: ${message}`)45 }4647 return error instanceof Error ? error : new Error("Firestore request failed.")48}4950function assertSafePathParam(key: string, value: string) {51 if (!value || value.includes("/") || value.includes("..")) {52 throw new Error(`Invalid Firestore path parameter "${key}".`)53 }5455 return value56}5758async function resolvePathParam(key: string, param: FirestorePathParam, ctx: DataSourceContext) {59 const value = typeof param === "function" ? await param(ctx) : param60 return assertSafePathParam(key, String(value))61}6263async function resolveCollectionPath(source: FirestoreResourceSource, ctx: DataSourceContext) {64 const params: Record<string, string> = {}6566 if (ctx.orgId) {67 params.orgId = assertSafePathParam("orgId", String(ctx.orgId))68 }6970 if (ctx.tenantId) {71 params.tenantId = assertSafePathParam("tenantId", String(ctx.tenantId))72 }7374 for (const [key, param] of Object.entries(source.pathParams ?? {})) {75 params[key] = await resolvePathParam(key, param, ctx)76 }7778 return source.collection.replace(/\{([^}]+)\}/g, (_match, key: string) => {79 const value = params[key]8081 if (!value) {82// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from fable-ui
All 10 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Fable UI Corecore | fable-ui | Utilities | Free | 2 deps · 9 files | |
| REST Data Source Driverrest-driver | fable-ui | Utilities | Free | no deps · 3 files |
