@geenius/adapters 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.changeset/config.json +11 -0
- package/.github/CODEOWNERS +1 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +16 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +11 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +10 -0
- package/.github/dependabot.yml +11 -0
- package/.github/workflows/ci.yml +23 -0
- package/.github/workflows/release.yml +29 -0
- package/.nvmrc +1 -0
- package/.project/ACCOUNT.yaml +4 -0
- package/.project/IDEAS.yaml +7 -0
- package/.project/PROJECT.yaml +11 -0
- package/.project/ROADMAP.yaml +15 -0
- package/CHANGELOG.md +11 -0
- package/CODE_OF_CONDUCT.md +16 -0
- package/CONTRIBUTING.md +26 -0
- package/LICENSE +21 -0
- package/README.md +202 -0
- package/SECURITY.md +15 -0
- package/SUPPORT.md +8 -0
- package/package.json +51 -0
- package/packages/convex/README.md +64 -0
- package/packages/convex/package.json +42 -0
- package/packages/convex/src/adapter.ts +39 -0
- package/packages/convex/src/index.ts +19 -0
- package/packages/convex/src/mutations.ts +142 -0
- package/packages/convex/src/queries.ts +106 -0
- package/packages/convex/src/schema.ts +54 -0
- package/packages/convex/src/types.ts +20 -0
- package/packages/convex/tsconfig.json +11 -0
- package/packages/convex/tsup.config.ts +10 -0
- package/packages/react/README.md +1 -0
- package/packages/react/package.json +45 -0
- package/packages/react/src/components/AdapterCard.tsx +49 -0
- package/packages/react/src/components/AdapterConfigForm.tsx +118 -0
- package/packages/react/src/components/AdapterList.tsx +84 -0
- package/packages/react/src/components/AdapterStatusBadge.tsx +30 -0
- package/packages/react/src/components/index.ts +4 -0
- package/packages/react/src/hooks/index.ts +75 -0
- package/packages/react/src/index.tsx +44 -0
- package/packages/react/src/pages/AdapterDetailPage.tsx +133 -0
- package/packages/react/src/pages/AdaptersPage.tsx +111 -0
- package/packages/react/src/pages/index.ts +2 -0
- package/packages/react/src/provider/AdapterProvider.tsx +115 -0
- package/packages/react/src/provider/index.ts +2 -0
- package/packages/react/tsconfig.json +18 -0
- package/packages/react/tsup.config.ts +10 -0
- package/packages/react-css/README.md +1 -0
- package/packages/react-css/package.json +44 -0
- package/packages/react-css/src/adapters.css +1576 -0
- package/packages/react-css/src/components/AdapterCard.tsx +34 -0
- package/packages/react-css/src/components/AdapterConfigForm.tsx +63 -0
- package/packages/react-css/src/components/AdapterList.tsx +40 -0
- package/packages/react-css/src/components/AdapterStatusBadge.tsx +21 -0
- package/packages/react-css/src/components/index.ts +4 -0
- package/packages/react-css/src/hooks/index.ts +75 -0
- package/packages/react-css/src/index.tsx +25 -0
- package/packages/react-css/src/pages/AdapterDetailPage.tsx +133 -0
- package/packages/react-css/src/pages/AdaptersPage.tsx +111 -0
- package/packages/react-css/src/pages/index.ts +2 -0
- package/packages/react-css/src/provider/AdapterProvider.tsx +115 -0
- package/packages/react-css/src/provider/index.ts +2 -0
- package/packages/react-css/src/styles.css +494 -0
- package/packages/react-css/tsconfig.json +19 -0
- package/packages/react-css/tsup.config.ts +2 -0
- package/packages/shared/README.md +1 -0
- package/packages/shared/package.json +39 -0
- package/packages/shared/src/__tests__/adapters.test.ts +545 -0
- package/packages/shared/src/admin/index.ts +2 -0
- package/packages/shared/src/admin/interface.ts +34 -0
- package/packages/shared/src/admin/localStorage.ts +109 -0
- package/packages/shared/src/ai/anthropic.ts +123 -0
- package/packages/shared/src/ai/cloudflare-gateway.ts +130 -0
- package/packages/shared/src/ai/gemini.ts +181 -0
- package/packages/shared/src/ai/index.ts +14 -0
- package/packages/shared/src/ai/interface.ts +11 -0
- package/packages/shared/src/ai/localStorage.ts +78 -0
- package/packages/shared/src/ai/ollama.ts +143 -0
- package/packages/shared/src/ai/openai.ts +120 -0
- package/packages/shared/src/ai/vercel-ai.ts +101 -0
- package/packages/shared/src/auth/better-auth.ts +118 -0
- package/packages/shared/src/auth/clerk.ts +151 -0
- package/packages/shared/src/auth/convex-auth.ts +125 -0
- package/packages/shared/src/auth/index.ts +10 -0
- package/packages/shared/src/auth/interface.ts +17 -0
- package/packages/shared/src/auth/localStorage.ts +125 -0
- package/packages/shared/src/auth/supabase-auth.ts +136 -0
- package/packages/shared/src/config.ts +57 -0
- package/packages/shared/src/constants.ts +122 -0
- package/packages/shared/src/db/convex.ts +146 -0
- package/packages/shared/src/db/index.ts +10 -0
- package/packages/shared/src/db/interface.ts +13 -0
- package/packages/shared/src/db/localStorage.ts +91 -0
- package/packages/shared/src/db/mongodb.ts +125 -0
- package/packages/shared/src/db/neon.ts +171 -0
- package/packages/shared/src/db/supabase.ts +158 -0
- package/packages/shared/src/index.ts +117 -0
- package/packages/shared/src/payments/index.ts +4 -0
- package/packages/shared/src/payments/interface.ts +11 -0
- package/packages/shared/src/payments/localStorage.ts +81 -0
- package/packages/shared/src/payments/stripe.ts +177 -0
- package/packages/shared/src/storage/convex.ts +113 -0
- package/packages/shared/src/storage/index.ts +14 -0
- package/packages/shared/src/storage/interface.ts +11 -0
- package/packages/shared/src/storage/localStorage.ts +95 -0
- package/packages/shared/src/storage/minio.ts +47 -0
- package/packages/shared/src/storage/r2.ts +123 -0
- package/packages/shared/src/storage/s3.ts +128 -0
- package/packages/shared/src/storage/supabase-storage.ts +116 -0
- package/packages/shared/src/storage/uploadthing.ts +126 -0
- package/packages/shared/src/styles/adapters.css +494 -0
- package/packages/shared/src/tier-gate.ts +119 -0
- package/packages/shared/src/types.ts +162 -0
- package/packages/shared/tsconfig.json +18 -0
- package/packages/shared/tsup.config.ts +9 -0
- package/packages/shared/vitest.config.ts +14 -0
- package/packages/solidjs/README.md +1 -0
- package/packages/solidjs/package.json +44 -0
- package/packages/solidjs/src/components/AdapterCard.tsx +24 -0
- package/packages/solidjs/src/components/AdapterConfigForm.tsx +54 -0
- package/packages/solidjs/src/components/AdapterList.tsx +28 -0
- package/packages/solidjs/src/components/AdapterStatusBadge.tsx +20 -0
- package/packages/solidjs/src/components/index.ts +4 -0
- package/packages/solidjs/src/index.tsx +17 -0
- package/packages/solidjs/src/pages/AdapterDetailPage.tsx +38 -0
- package/packages/solidjs/src/pages/AdaptersPage.tsx +39 -0
- package/packages/solidjs/src/pages/index.ts +2 -0
- package/packages/solidjs/src/primitives/index.ts +78 -0
- package/packages/solidjs/src/provider/AdapterProvider.tsx +62 -0
- package/packages/solidjs/src/provider/index.ts +2 -0
- package/packages/solidjs/tsconfig.json +20 -0
- package/packages/solidjs/tsup.config.ts +10 -0
- package/packages/solidjs-css/README.md +1 -0
- package/packages/solidjs-css/package.json +43 -0
- package/packages/solidjs-css/src/adapters.css +1576 -0
- package/packages/solidjs-css/src/components/AdapterCard.tsx +43 -0
- package/packages/solidjs-css/src/components/AdapterConfigForm.tsx +119 -0
- package/packages/solidjs-css/src/components/AdapterList.tsx +68 -0
- package/packages/solidjs-css/src/components/AdapterStatusBadge.tsx +24 -0
- package/packages/solidjs-css/src/components/index.ts +8 -0
- package/packages/solidjs-css/src/index.tsx +30 -0
- package/packages/solidjs-css/src/pages/AdapterDetailPage.tsx +107 -0
- package/packages/solidjs-css/src/pages/AdaptersPage.tsx +94 -0
- package/packages/solidjs-css/src/pages/index.ts +4 -0
- package/packages/solidjs-css/src/primitives/index.ts +1 -0
- package/packages/solidjs-css/src/provider/AdapterProvider.tsx +61 -0
- package/packages/solidjs-css/src/provider/index.ts +2 -0
- package/packages/solidjs-css/tsconfig.json +20 -0
- package/packages/solidjs-css/tsup.config.ts +2 -0
- package/pnpm-workspace.yaml +2 -0
- package/tsconfig.json +17 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://unpkg.com/@changesets/config@3.1.1/schema.json",
|
|
3
|
+
"changelog": "@changesets/cli/changelog",
|
|
4
|
+
"commit": false,
|
|
5
|
+
"fixed": [],
|
|
6
|
+
"linked": [],
|
|
7
|
+
"access": "public",
|
|
8
|
+
"baseBranch": "main",
|
|
9
|
+
"updateInternalDependencies": "patch",
|
|
10
|
+
"ignore": []
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
* @mxn2020
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
on:
|
|
3
|
+
pull_request:
|
|
4
|
+
branches: [main]
|
|
5
|
+
push:
|
|
6
|
+
branches: [main]
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
check:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v4
|
|
13
|
+
- uses: pnpm/action-setup@v4
|
|
14
|
+
with:
|
|
15
|
+
version: 10
|
|
16
|
+
- uses: actions/setup-node@v4
|
|
17
|
+
with:
|
|
18
|
+
node-version-file: '.nvmrc'
|
|
19
|
+
cache: 'pnpm'
|
|
20
|
+
- run: pnpm install --frozen-lockfile
|
|
21
|
+
- run: pnpm build
|
|
22
|
+
- run: pnpm lint
|
|
23
|
+
- run: pnpm test
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches: [main]
|
|
5
|
+
|
|
6
|
+
concurrency: ${{ github.workflow }}-${{ github.ref }}
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
release:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v4
|
|
13
|
+
- uses: pnpm/action-setup@v4
|
|
14
|
+
with:
|
|
15
|
+
version: 10
|
|
16
|
+
- uses: actions/setup-node@v4
|
|
17
|
+
with:
|
|
18
|
+
node-version-file: '.nvmrc'
|
|
19
|
+
cache: 'pnpm'
|
|
20
|
+
registry-url: 'https://registry.npmjs.org'
|
|
21
|
+
- run: pnpm install --frozen-lockfile
|
|
22
|
+
- run: pnpm build
|
|
23
|
+
- uses: changesets/action@v1
|
|
24
|
+
with:
|
|
25
|
+
publish: pnpm changeset publish
|
|
26
|
+
version: pnpm changeset version
|
|
27
|
+
env:
|
|
28
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
29
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/.nvmrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
22
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
name: geenius-adapters
|
|
2
|
+
description: "Geenius Adapters — Backend adapter abstraction layer for auth, db, payments, AI, and storage"
|
|
3
|
+
category: library
|
|
4
|
+
priority: high
|
|
5
|
+
tags:
|
|
6
|
+
- geenius
|
|
7
|
+
- npm-package
|
|
8
|
+
- react
|
|
9
|
+
- solidjs
|
|
10
|
+
deploy_url: null
|
|
11
|
+
npm_scope: "@geenius-adapters"
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
version: "0.1"
|
|
2
|
+
milestones:
|
|
3
|
+
- name: "v0.1.0 — Initial Release"
|
|
4
|
+
status: in-progress
|
|
5
|
+
items:
|
|
6
|
+
- "Core shared types and logic"
|
|
7
|
+
- "React hooks and components"
|
|
8
|
+
- "SolidJS primitives"
|
|
9
|
+
- "npm publishing via Changesets"
|
|
10
|
+
- name: "v0.2.0 — Stability"
|
|
11
|
+
status: planned
|
|
12
|
+
items:
|
|
13
|
+
- "Test coverage ≥ 50%"
|
|
14
|
+
- "API documentation"
|
|
15
|
+
- "Convex adapter"
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.1.0] - 2026-03-21
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- Initial release
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our
|
|
6
|
+
community a harassment-free experience for everyone, regardless of age, body
|
|
7
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
8
|
+
education, socio-economic status, nationality, personal appearance, race,
|
|
9
|
+
religion, or sexual identity and orientation.
|
|
10
|
+
|
|
11
|
+
## Enforcement
|
|
12
|
+
|
|
13
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
14
|
+
reported to the project team at conduct@geenius.app.
|
|
15
|
+
|
|
16
|
+
This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org), version 2.1.
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Contributing to @geenius-adapters
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing!
|
|
4
|
+
|
|
5
|
+
## Development Setup
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
git clone https://github.com/mxn2020/geenius-adapters.git
|
|
9
|
+
cd geenius-adapters
|
|
10
|
+
pnpm install
|
|
11
|
+
pnpm build
|
|
12
|
+
pnpm test
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Pull Request Process
|
|
16
|
+
|
|
17
|
+
1. Fork the repo and create a feature branch from `main`
|
|
18
|
+
2. Add or update tests as appropriate
|
|
19
|
+
3. Run `pnpm changeset` to describe your changes for the changelog
|
|
20
|
+
4. Open a PR against `main`
|
|
21
|
+
|
|
22
|
+
## Code Style
|
|
23
|
+
|
|
24
|
+
- TypeScript strict mode
|
|
25
|
+
- ESLint + Prettier formatting
|
|
26
|
+
- Conventional commits preferred
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Mehdi Nabhani
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
# `@geenius/adapters`
|
|
2
|
+
|
|
3
|
+
> The architectural lynchpin of the Geenius ecosystem — a unified adapter layer that makes backend services interchangeable with a one-file swap.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
`@geenius/adapters` defines **standard interfaces** for six infrastructure domains and provides concrete implementations for each. Any frontend component talks exclusively to an adapter interface — never to a database or service directly.
|
|
10
|
+
|
|
11
|
+
This is what makes "swap Convex for Supabase" a single-file change instead of a months-long rewrite.
|
|
12
|
+
|
|
13
|
+
### Adapter Domains
|
|
14
|
+
|
|
15
|
+
| Domain | Interface | Providers |
|
|
16
|
+
|--------|-----------|-----------|
|
|
17
|
+
| **DB** | `DbAdapter` | `localStorage`, Convex, Supabase, Neon, MongoDB |
|
|
18
|
+
| **Auth** | `AuthAdapter` | `localStorage`, Better Auth, Convex Auth, Clerk, Supabase Auth |
|
|
19
|
+
| **Payments** | `PaymentsAdapter` | `localStorage`, Stripe, noop |
|
|
20
|
+
| **AI** | `AiAdapter` | `localStorage`, OpenAI, Anthropic, Gemini, Ollama, CF AI Gateway, Vercel AI SDK |
|
|
21
|
+
| **File Storage** | `FileStorageAdapter` | `localStorage`, R2, S3, Uploadthing, Supabase Storage, Convex Storage, Minio |
|
|
22
|
+
| **Admin** | `AdminAdapter` | `localStorage` |
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pnpm add @geenius/adapters
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Sub-package Exports
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
import { configureAdapters, createConvexDbAdapter } from '@geenius/adapters' // shared (default)
|
|
36
|
+
import { AdapterProvider, useDb, useAuth, useAi } from '@geenius/adapters/react' // React hooks
|
|
37
|
+
import { AdapterProvider, createDb, createAuth } from '@geenius/adapters/solidjs' // SolidJS primitives
|
|
38
|
+
import { adapterTables } from '@geenius/adapters/convex' // Convex schema
|
|
39
|
+
import { AdaptersPage, AdapterCard } from '@geenius/adapters/react-css' // Styled React components
|
|
40
|
+
import { AdaptersPage, AdapterCard } from '@geenius/adapters/solidjs-css' // Styled SolidJS components
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Quick Start
|
|
46
|
+
|
|
47
|
+
### 1. Configure adapters at app startup
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
import { configureAdapters } from '@geenius/adapters'
|
|
51
|
+
import { createConvexDbAdapter } from '@geenius/adapters'
|
|
52
|
+
|
|
53
|
+
// Call once before rendering
|
|
54
|
+
configureAdapters({
|
|
55
|
+
db: { provider: 'convex' },
|
|
56
|
+
auth: { provider: 'better-auth' },
|
|
57
|
+
ai: { provider: 'openai', apiKey: process.env.OPENAI_API_KEY },
|
|
58
|
+
storage: { provider: 'r2' },
|
|
59
|
+
payments: { provider: 'stripe' },
|
|
60
|
+
})
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### 2. Wrap your app with AdapterProvider (React)
|
|
64
|
+
|
|
65
|
+
```tsx
|
|
66
|
+
import { AdapterProvider } from '@geenius/adapters/react'
|
|
67
|
+
import { createBetterAuthAdapter } from '@geenius/adapters'
|
|
68
|
+
import { createConvexDbAdapter } from '@geenius/adapters'
|
|
69
|
+
|
|
70
|
+
export function App() {
|
|
71
|
+
return (
|
|
72
|
+
<AdapterProvider
|
|
73
|
+
adapters={{
|
|
74
|
+
db: createConvexDbAdapter({ client: convex, functions: myFns }),
|
|
75
|
+
auth: createBetterAuthAdapter({ client: authClient }),
|
|
76
|
+
ai: createOpenAiAdapter({ apiKey: process.env.OPENAI_API_KEY }),
|
|
77
|
+
}}
|
|
78
|
+
healthCheck
|
|
79
|
+
>
|
|
80
|
+
<Router />
|
|
81
|
+
</AdapterProvider>
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### 3. Use adapters in components
|
|
87
|
+
|
|
88
|
+
```tsx
|
|
89
|
+
import { useAuth, useDb, useAi } from '@geenius/adapters/react'
|
|
90
|
+
|
|
91
|
+
export function Dashboard() {
|
|
92
|
+
const auth = useAuth()
|
|
93
|
+
const db = useDb()
|
|
94
|
+
const ai = useAi()
|
|
95
|
+
|
|
96
|
+
async function handleSignIn() {
|
|
97
|
+
await auth.signIn('user@example.com', 'password')
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
async function handleOAuth() {
|
|
101
|
+
const { url } = await auth.signInWithOAuth('google', { redirectUrl: '/dashboard' })
|
|
102
|
+
window.location.href = url
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
async function handleChat() {
|
|
106
|
+
const response = await ai.chat([{ role: 'user', content: 'Hello!' }])
|
|
107
|
+
console.log(response.content)
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## Prototyping with localStorage (Pronto tier)
|
|
115
|
+
|
|
116
|
+
Every domain ships a `localStorage` implementation for zero-config prototyping:
|
|
117
|
+
|
|
118
|
+
```typescript
|
|
119
|
+
import {
|
|
120
|
+
createLocalStorageAuthAdapter,
|
|
121
|
+
createLocalStorageDbAdapter,
|
|
122
|
+
createLocalStorageAiAdapter,
|
|
123
|
+
createLocalStorageFileAdapter,
|
|
124
|
+
createLocalStoragePaymentsAdapter,
|
|
125
|
+
createLocalStorageAdminAdapter,
|
|
126
|
+
createNoopPaymentsAdapter,
|
|
127
|
+
} from '@geenius/adapters'
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
These adapters persist data in the browser's localStorage with no external dependencies. Upgrade to real adapters by replacing a single file.
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## Tier Gating
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
import { isFeatureAvailable, isPackageAvailable, getUpgradeFeatures } from '@geenius/adapters'
|
|
138
|
+
|
|
139
|
+
isFeatureAvailable('admin', 'pronto') // → false
|
|
140
|
+
isFeatureAvailable('admin', 'lancio') // → true
|
|
141
|
+
isFeatureAvailable('ai-magic', 'studio') // → true
|
|
142
|
+
|
|
143
|
+
getUpgradeFeatures('pronto', 'lancio')
|
|
144
|
+
// → ['admin', 'payments', 'blog', 'file-storage', 'ai-workflow', 'ai-embeddings']
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## Provider Registry
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
import { PROVIDER_REGISTRY, getProvidersForDomain, getProviderMeta } from '@geenius/adapters'
|
|
153
|
+
|
|
154
|
+
getProvidersForDomain('ai')
|
|
155
|
+
// → [{ id: 'localStorage', tier: 'pronto' }, { id: 'openai', tier: 'lancio' }, ...]
|
|
156
|
+
|
|
157
|
+
getProviderMeta('payments', 'stripe')
|
|
158
|
+
// → { id: 'stripe', name: 'Stripe', domain: 'payments', tier: 'lancio', ... }
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## Adapter Interface Contracts
|
|
164
|
+
|
|
165
|
+
All interfaces are **async (Promise-based)**, generic, and framework-agnostic. Swapping a provider only requires replacing the adapter factory call — no changes to consumers.
|
|
166
|
+
|
|
167
|
+
```typescript
|
|
168
|
+
// AuthAdapter — all providers
|
|
169
|
+
interface AuthAdapter {
|
|
170
|
+
signIn(email: string, password: string): Promise<AuthSession>
|
|
171
|
+
signUp(email: string, password: string, name?: string): Promise<AuthSession>
|
|
172
|
+
signInWithOAuth(provider: OAuthProvider, options?: { redirectUrl?: string }): Promise<{ url: string }>
|
|
173
|
+
signOut(): Promise<void>
|
|
174
|
+
getSession(): Promise<AuthSession | null>
|
|
175
|
+
getUser(): Promise<AuthUser | null>
|
|
176
|
+
updateUser(updates: Partial<Pick<AuthUser, 'name' | 'image'>>): Promise<AuthUser | null>
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// AiAdapter — all providers (stream is optional, falls back to chat)
|
|
180
|
+
interface AiAdapter {
|
|
181
|
+
chat(messages: ChatMessage[], options?: AiOptions): Promise<ChatResponse>
|
|
182
|
+
complete(prompt: string, options?: AiOptions): Promise<string>
|
|
183
|
+
embed(text: string | string[]): Promise<number[][]>
|
|
184
|
+
stream?(messages: ChatMessage[], options?: AiOptions): AsyncIterable<string>
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## Tier Availability
|
|
191
|
+
|
|
192
|
+
| Tier | Description |
|
|
193
|
+
|------|-------------|
|
|
194
|
+
| **Pronto** | Prototype-ready. localStorage only. Zero external deps. |
|
|
195
|
+
| **Lancio** | Production-ready. Real backends: Convex, Stripe, Better Auth, R2. |
|
|
196
|
+
| **Studio** | Full ecosystem. All Lancio providers + AI Magic, Analytics, Teams, and more. |
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## License
|
|
201
|
+
|
|
202
|
+
MIT — © Antigravity HQ
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Supported Versions
|
|
4
|
+
|
|
5
|
+
| Version | Supported |
|
|
6
|
+
| ------- | --------- |
|
|
7
|
+
| 0.x.x | ✅ |
|
|
8
|
+
|
|
9
|
+
## Reporting a Vulnerability
|
|
10
|
+
|
|
11
|
+
Please report security vulnerabilities by emailing **security@geenius.app**.
|
|
12
|
+
|
|
13
|
+
Do **not** open a public GitHub issue for security vulnerabilities.
|
|
14
|
+
|
|
15
|
+
We will acknowledge receipt within 48 hours and provide a detailed response within 5 business days.
|
package/SUPPORT.md
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Support
|
|
2
|
+
|
|
3
|
+
## Getting Help
|
|
4
|
+
|
|
5
|
+
- 📖 [Documentation](https://docs.geenius.app)
|
|
6
|
+
- 🐛 [Bug Reports](https://github.com/mxn2020/geenius-adapters/issues/new?template=bug_report.md)
|
|
7
|
+
- 💡 [Feature Requests](https://github.com/mxn2020/geenius-adapters/issues/new?template=feature_request.md)
|
|
8
|
+
- 📧 Email: support@geenius.app
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@geenius/adapters",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"build": "pnpm -r build",
|
|
7
|
+
"lint": "pnpm -r lint",
|
|
8
|
+
"test": "pnpm -r test",
|
|
9
|
+
"clean": "pnpm -r clean"
|
|
10
|
+
},
|
|
11
|
+
"devDependencies": {
|
|
12
|
+
"typescript": "~6.0.2"
|
|
13
|
+
},
|
|
14
|
+
"author": "Antigravity HQ",
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=20.0.0"
|
|
18
|
+
},
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./packages/shared/dist/index.d.ts",
|
|
22
|
+
"import": "./packages/shared/dist/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./shared": {
|
|
25
|
+
"types": "./packages/shared/dist/index.d.ts",
|
|
26
|
+
"import": "./packages/shared/dist/index.js"
|
|
27
|
+
},
|
|
28
|
+
"./convex": {
|
|
29
|
+
"types": "./packages/convex/dist/index.d.ts",
|
|
30
|
+
"import": "./packages/convex/dist/index.js"
|
|
31
|
+
},
|
|
32
|
+
"./react": {
|
|
33
|
+
"types": "./packages/react/dist/index.d.ts",
|
|
34
|
+
"import": "./packages/react/dist/index.js"
|
|
35
|
+
},
|
|
36
|
+
"./react-css": {
|
|
37
|
+
"types": "./packages/react-css/dist/index.d.ts",
|
|
38
|
+
"import": "./packages/react-css/dist/index.js"
|
|
39
|
+
},
|
|
40
|
+
"./solidjs": {
|
|
41
|
+
"types": "./packages/solidjs/dist/index.d.ts",
|
|
42
|
+
"import": "./packages/solidjs/dist/index.js"
|
|
43
|
+
},
|
|
44
|
+
"./solidjs-css": {
|
|
45
|
+
"types": "./packages/solidjs-css/dist/index.d.ts",
|
|
46
|
+
"import": "./packages/solidjs-css/dist/index.js"
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"main": "./packages/shared/dist/index.js",
|
|
50
|
+
"types": "./packages/shared/dist/index.d.ts"
|
|
51
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# `@geenius-adapters/convex`
|
|
2
|
+
|
|
3
|
+
> Convex backend integration for `@geenius/adapters` — registry, health logs, and adapter lifecycle management.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
This sub-package provides the Convex schema, mutations, and queries needed to persist adapter registry state in a Convex backend. It tracks which adapters are registered, their current status, and health check history.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
This package is a private workspace dependency used by the `@geenius/adapters` root package. It is consumed via the `/convex` export:
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { schema, registerAdapter, listAdapters } from '@geenius/adapters/convex'
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Schema
|
|
20
|
+
|
|
21
|
+
### `adapter_registry`
|
|
22
|
+
|
|
23
|
+
Stores the active adapter configuration per domain.
|
|
24
|
+
|
|
25
|
+
| Field | Type | Description |
|
|
26
|
+
|-------|------|-------------|
|
|
27
|
+
| `domain` | string | Adapter domain (`db`, `auth`, `ai`, etc.) |
|
|
28
|
+
| `provider` | string | Provider name (e.g., `convex`, `openai`) |
|
|
29
|
+
| `status` | string | `active` \| `inactive` \| `error` |
|
|
30
|
+
| `config` | any | Provider-specific configuration |
|
|
31
|
+
|
|
32
|
+
### `adapter_health_logs`
|
|
33
|
+
|
|
34
|
+
Tracks adapter health check results over time.
|
|
35
|
+
|
|
36
|
+
| Field | Type | Description |
|
|
37
|
+
|-------|------|-------------|
|
|
38
|
+
| `adapterId` | Id | Reference to `adapter_registry` |
|
|
39
|
+
| `domain` | string | Adapter domain |
|
|
40
|
+
| `status` | string | Check result (`healthy` \| `unhealthy`) |
|
|
41
|
+
| `latencyMs` | number | Check response time in ms |
|
|
42
|
+
| `timestamp` | number | Unix timestamp |
|
|
43
|
+
|
|
44
|
+
## API
|
|
45
|
+
|
|
46
|
+
### Mutations
|
|
47
|
+
|
|
48
|
+
- `registerAdapter(domain, provider, config?)` — Register or update an adapter for a domain
|
|
49
|
+
- `updateAdapterStatus(id, status)` — Update the status of a registered adapter
|
|
50
|
+
- `updateAdapter(id, updates)` — Update adapter configuration
|
|
51
|
+
- `removeAdapter(id)` — Remove adapter and all associated health logs
|
|
52
|
+
|
|
53
|
+
### Queries
|
|
54
|
+
|
|
55
|
+
- `listAdapters()` — List all registered adapters
|
|
56
|
+
- `listAdaptersByDomain(domain)` — List adapters for a specific domain
|
|
57
|
+
- `getAdapter(id)` — Get a single adapter by ID
|
|
58
|
+
- `getActiveAdapter(domain)` — Get the currently active adapter for a domain
|
|
59
|
+
- `getAdapterStatusSummary()` — Aggregate status counts across all domains
|
|
60
|
+
- `getAdapterHealthLogs(adapterId, limit?)` — Get recent health logs for an adapter
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
*Part of the [Geenius Boilerplate Ecosystem](https://github.com/AntigravityHQ/geenius) by Antigravity HQ*
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@geenius-adapters/convex",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"description": "Convex adapter factory and configuration for database integration",
|
|
7
|
+
"author": "Antigravity HQ",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public"
|
|
11
|
+
},
|
|
12
|
+
"main": "./dist/index.js",
|
|
13
|
+
"module": "./dist/index.js",
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"import": "./dist/index.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"src"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "tsup",
|
|
27
|
+
"clean": "rm -rf dist",
|
|
28
|
+
"type-check": "tsc --noEmit",
|
|
29
|
+
"prepublishOnly": "pnpm clean && pnpm build"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"convex": "^1.34.0"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"convex": "^1.34.0",
|
|
36
|
+
"tsup": "^8.5.1",
|
|
37
|
+
"typescript": "~6.0.2"
|
|
38
|
+
},
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": ">=20.0.0"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ConvexAdapterConfig, ConvexDbAdapter } from './types'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Factory function to create a Convex database adapter
|
|
5
|
+
*/
|
|
6
|
+
export function createConvexAdapter(
|
|
7
|
+
config: ConvexAdapterConfig,
|
|
8
|
+
): ConvexDbAdapter {
|
|
9
|
+
let isConnected = false
|
|
10
|
+
|
|
11
|
+
return {
|
|
12
|
+
query: async (queryFn: string, args?: Record<string, unknown>) => {
|
|
13
|
+
if (!isConnected) {
|
|
14
|
+
throw new Error('Convex adapter not initialized')
|
|
15
|
+
}
|
|
16
|
+
// Placeholder: would execute query through Convex client
|
|
17
|
+
return null
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
mutation: async (
|
|
21
|
+
mutationFn: string,
|
|
22
|
+
args?: Record<string, unknown>,
|
|
23
|
+
) => {
|
|
24
|
+
if (!isConnected) {
|
|
25
|
+
throw new Error('Convex adapter not initialized')
|
|
26
|
+
}
|
|
27
|
+
// Placeholder: would execute mutation through Convex client
|
|
28
|
+
return null
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
isReady: () => {
|
|
32
|
+
return isConnected
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
disconnect: async () => {
|
|
36
|
+
isConnected = false
|
|
37
|
+
},
|
|
38
|
+
}
|
|
39
|
+
}
|