@geenius/adapters 0.1.0 → 0.3.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.
Files changed (185) hide show
  1. package/README.md +79 -42
  2. package/package.json +23 -4
  3. package/packages/convex/README.md +1 -1
  4. package/packages/convex/dist/index.cjs +300 -0
  5. package/packages/convex/dist/index.cjs.map +1 -0
  6. package/packages/convex/dist/index.d.cts +231 -0
  7. package/packages/convex/dist/index.d.ts +231 -0
  8. package/packages/convex/dist/index.js +263 -0
  9. package/packages/convex/dist/index.js.map +1 -0
  10. package/packages/react/README.md +1 -1
  11. package/packages/react/dist/index.d.mts +106 -0
  12. package/packages/react/dist/index.d.ts +106 -0
  13. package/packages/react/dist/index.js +611 -0
  14. package/packages/react/dist/index.js.map +1 -0
  15. package/packages/react/dist/index.mjs +570 -0
  16. package/packages/react/dist/index.mjs.map +1 -0
  17. package/packages/react-css/README.md +1 -1
  18. package/packages/react-css/dist/index.cjs +515 -0
  19. package/packages/react-css/dist/index.cjs.map +1 -0
  20. package/packages/react-css/dist/index.d.cts +105 -0
  21. package/packages/react-css/dist/index.d.ts +105 -0
  22. package/packages/react-css/dist/index.js +467 -0
  23. package/packages/react-css/dist/index.js.map +1 -0
  24. package/packages/shared/README.md +1 -1
  25. package/packages/shared/dist/index.d.mts +625 -0
  26. package/packages/shared/dist/index.d.ts +625 -0
  27. package/packages/shared/dist/index.js +1567 -0
  28. package/packages/shared/dist/index.js.map +1 -0
  29. package/packages/shared/dist/index.mjs +1489 -0
  30. package/packages/shared/dist/index.mjs.map +1 -0
  31. package/packages/solidjs/README.md +1 -1
  32. package/packages/solidjs/dist/index.d.mts +97 -0
  33. package/packages/solidjs/dist/index.d.ts +97 -0
  34. package/packages/solidjs/dist/index.js +250 -0
  35. package/packages/solidjs/dist/index.js.map +1 -0
  36. package/packages/solidjs/dist/index.mjs +202 -0
  37. package/packages/solidjs/dist/index.mjs.map +1 -0
  38. package/packages/solidjs-css/README.md +1 -1
  39. package/packages/solidjs-css/dist/index.cjs +343 -0
  40. package/packages/solidjs-css/dist/index.cjs.map +1 -0
  41. package/packages/solidjs-css/dist/index.d.cts +67 -0
  42. package/packages/solidjs-css/dist/index.d.ts +67 -0
  43. package/packages/solidjs-css/dist/index.js +326 -0
  44. package/packages/solidjs-css/dist/index.js.map +1 -0
  45. package/.changeset/config.json +0 -11
  46. package/.github/CODEOWNERS +0 -1
  47. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -16
  48. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -11
  49. package/.github/PULL_REQUEST_TEMPLATE.md +0 -10
  50. package/.github/dependabot.yml +0 -11
  51. package/.github/workflows/ci.yml +0 -23
  52. package/.github/workflows/release.yml +0 -29
  53. package/.nvmrc +0 -1
  54. package/.project/ACCOUNT.yaml +0 -4
  55. package/.project/IDEAS.yaml +0 -7
  56. package/.project/PROJECT.yaml +0 -11
  57. package/.project/ROADMAP.yaml +0 -15
  58. package/CODE_OF_CONDUCT.md +0 -16
  59. package/CONTRIBUTING.md +0 -26
  60. package/SECURITY.md +0 -15
  61. package/SUPPORT.md +0 -8
  62. package/packages/convex/package.json +0 -42
  63. package/packages/convex/src/adapter.ts +0 -39
  64. package/packages/convex/src/index.ts +0 -19
  65. package/packages/convex/src/mutations.ts +0 -142
  66. package/packages/convex/src/queries.ts +0 -106
  67. package/packages/convex/src/schema.ts +0 -54
  68. package/packages/convex/src/types.ts +0 -20
  69. package/packages/convex/tsconfig.json +0 -11
  70. package/packages/convex/tsup.config.ts +0 -10
  71. package/packages/react/package.json +0 -45
  72. package/packages/react/src/components/AdapterCard.tsx +0 -49
  73. package/packages/react/src/components/AdapterConfigForm.tsx +0 -118
  74. package/packages/react/src/components/AdapterList.tsx +0 -84
  75. package/packages/react/src/components/AdapterStatusBadge.tsx +0 -30
  76. package/packages/react/src/components/index.ts +0 -4
  77. package/packages/react/src/hooks/index.ts +0 -75
  78. package/packages/react/src/index.tsx +0 -44
  79. package/packages/react/src/pages/AdapterDetailPage.tsx +0 -133
  80. package/packages/react/src/pages/AdaptersPage.tsx +0 -111
  81. package/packages/react/src/pages/index.ts +0 -2
  82. package/packages/react/src/provider/AdapterProvider.tsx +0 -115
  83. package/packages/react/src/provider/index.ts +0 -2
  84. package/packages/react/tsconfig.json +0 -18
  85. package/packages/react/tsup.config.ts +0 -10
  86. package/packages/react-css/package.json +0 -44
  87. package/packages/react-css/src/adapters.css +0 -1576
  88. package/packages/react-css/src/components/AdapterCard.tsx +0 -34
  89. package/packages/react-css/src/components/AdapterConfigForm.tsx +0 -63
  90. package/packages/react-css/src/components/AdapterList.tsx +0 -40
  91. package/packages/react-css/src/components/AdapterStatusBadge.tsx +0 -21
  92. package/packages/react-css/src/components/index.ts +0 -4
  93. package/packages/react-css/src/hooks/index.ts +0 -75
  94. package/packages/react-css/src/index.tsx +0 -25
  95. package/packages/react-css/src/pages/AdapterDetailPage.tsx +0 -133
  96. package/packages/react-css/src/pages/AdaptersPage.tsx +0 -111
  97. package/packages/react-css/src/pages/index.ts +0 -2
  98. package/packages/react-css/src/provider/AdapterProvider.tsx +0 -115
  99. package/packages/react-css/src/provider/index.ts +0 -2
  100. package/packages/react-css/src/styles.css +0 -494
  101. package/packages/react-css/tsconfig.json +0 -19
  102. package/packages/react-css/tsup.config.ts +0 -2
  103. package/packages/shared/package.json +0 -39
  104. package/packages/shared/src/__tests__/adapters.test.ts +0 -545
  105. package/packages/shared/src/admin/index.ts +0 -2
  106. package/packages/shared/src/admin/interface.ts +0 -34
  107. package/packages/shared/src/admin/localStorage.ts +0 -109
  108. package/packages/shared/src/ai/anthropic.ts +0 -123
  109. package/packages/shared/src/ai/cloudflare-gateway.ts +0 -130
  110. package/packages/shared/src/ai/gemini.ts +0 -181
  111. package/packages/shared/src/ai/index.ts +0 -14
  112. package/packages/shared/src/ai/interface.ts +0 -11
  113. package/packages/shared/src/ai/localStorage.ts +0 -78
  114. package/packages/shared/src/ai/ollama.ts +0 -143
  115. package/packages/shared/src/ai/openai.ts +0 -120
  116. package/packages/shared/src/ai/vercel-ai.ts +0 -101
  117. package/packages/shared/src/auth/better-auth.ts +0 -118
  118. package/packages/shared/src/auth/clerk.ts +0 -151
  119. package/packages/shared/src/auth/convex-auth.ts +0 -125
  120. package/packages/shared/src/auth/index.ts +0 -10
  121. package/packages/shared/src/auth/interface.ts +0 -17
  122. package/packages/shared/src/auth/localStorage.ts +0 -125
  123. package/packages/shared/src/auth/supabase-auth.ts +0 -136
  124. package/packages/shared/src/config.ts +0 -57
  125. package/packages/shared/src/constants.ts +0 -122
  126. package/packages/shared/src/db/convex.ts +0 -146
  127. package/packages/shared/src/db/index.ts +0 -10
  128. package/packages/shared/src/db/interface.ts +0 -13
  129. package/packages/shared/src/db/localStorage.ts +0 -91
  130. package/packages/shared/src/db/mongodb.ts +0 -125
  131. package/packages/shared/src/db/neon.ts +0 -171
  132. package/packages/shared/src/db/supabase.ts +0 -158
  133. package/packages/shared/src/index.ts +0 -117
  134. package/packages/shared/src/payments/index.ts +0 -4
  135. package/packages/shared/src/payments/interface.ts +0 -11
  136. package/packages/shared/src/payments/localStorage.ts +0 -81
  137. package/packages/shared/src/payments/stripe.ts +0 -177
  138. package/packages/shared/src/storage/convex.ts +0 -113
  139. package/packages/shared/src/storage/index.ts +0 -14
  140. package/packages/shared/src/storage/interface.ts +0 -11
  141. package/packages/shared/src/storage/localStorage.ts +0 -95
  142. package/packages/shared/src/storage/minio.ts +0 -47
  143. package/packages/shared/src/storage/r2.ts +0 -123
  144. package/packages/shared/src/storage/s3.ts +0 -128
  145. package/packages/shared/src/storage/supabase-storage.ts +0 -116
  146. package/packages/shared/src/storage/uploadthing.ts +0 -126
  147. package/packages/shared/src/styles/adapters.css +0 -494
  148. package/packages/shared/src/tier-gate.ts +0 -119
  149. package/packages/shared/src/types.ts +0 -162
  150. package/packages/shared/tsconfig.json +0 -18
  151. package/packages/shared/tsup.config.ts +0 -9
  152. package/packages/shared/vitest.config.ts +0 -14
  153. package/packages/solidjs/package.json +0 -44
  154. package/packages/solidjs/src/components/AdapterCard.tsx +0 -24
  155. package/packages/solidjs/src/components/AdapterConfigForm.tsx +0 -54
  156. package/packages/solidjs/src/components/AdapterList.tsx +0 -28
  157. package/packages/solidjs/src/components/AdapterStatusBadge.tsx +0 -20
  158. package/packages/solidjs/src/components/index.ts +0 -4
  159. package/packages/solidjs/src/index.tsx +0 -17
  160. package/packages/solidjs/src/pages/AdapterDetailPage.tsx +0 -38
  161. package/packages/solidjs/src/pages/AdaptersPage.tsx +0 -39
  162. package/packages/solidjs/src/pages/index.ts +0 -2
  163. package/packages/solidjs/src/primitives/index.ts +0 -78
  164. package/packages/solidjs/src/provider/AdapterProvider.tsx +0 -62
  165. package/packages/solidjs/src/provider/index.ts +0 -2
  166. package/packages/solidjs/tsconfig.json +0 -20
  167. package/packages/solidjs/tsup.config.ts +0 -10
  168. package/packages/solidjs-css/package.json +0 -43
  169. package/packages/solidjs-css/src/adapters.css +0 -1576
  170. package/packages/solidjs-css/src/components/AdapterCard.tsx +0 -43
  171. package/packages/solidjs-css/src/components/AdapterConfigForm.tsx +0 -119
  172. package/packages/solidjs-css/src/components/AdapterList.tsx +0 -68
  173. package/packages/solidjs-css/src/components/AdapterStatusBadge.tsx +0 -24
  174. package/packages/solidjs-css/src/components/index.ts +0 -8
  175. package/packages/solidjs-css/src/index.tsx +0 -30
  176. package/packages/solidjs-css/src/pages/AdapterDetailPage.tsx +0 -107
  177. package/packages/solidjs-css/src/pages/AdaptersPage.tsx +0 -94
  178. package/packages/solidjs-css/src/pages/index.ts +0 -4
  179. package/packages/solidjs-css/src/primitives/index.ts +0 -1
  180. package/packages/solidjs-css/src/provider/AdapterProvider.tsx +0 -61
  181. package/packages/solidjs-css/src/provider/index.ts +0 -2
  182. package/packages/solidjs-css/tsconfig.json +0 -20
  183. package/packages/solidjs-css/tsup.config.ts +0 -2
  184. package/pnpm-workspace.yaml +0 -2
  185. package/tsconfig.json +0 -17
@@ -0,0 +1,625 @@
1
+ interface AuthUser {
2
+ id: string;
3
+ email?: string;
4
+ name?: string;
5
+ image?: string;
6
+ role?: string;
7
+ createdAt?: string;
8
+ }
9
+ interface AuthSession {
10
+ userId: string;
11
+ token?: string;
12
+ expiresAt?: string;
13
+ }
14
+ interface ListOptions {
15
+ limit?: number;
16
+ offset?: number;
17
+ orderBy?: string;
18
+ order?: 'asc' | 'desc';
19
+ }
20
+ type QueryOperator = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'in' | 'contains';
21
+ interface QueryCondition {
22
+ field: string;
23
+ operator: QueryOperator;
24
+ value: unknown;
25
+ }
26
+ type QueryFilter = QueryCondition[];
27
+ interface Plan {
28
+ id: string;
29
+ name: string;
30
+ price: number;
31
+ currency: string;
32
+ interval: 'month' | 'year' | 'one-time';
33
+ features: string[];
34
+ }
35
+ interface Subscription {
36
+ id: string;
37
+ userId: string;
38
+ planId: string;
39
+ status: 'active' | 'cancelled' | 'past_due' | 'trialing';
40
+ currentPeriodEnd: string;
41
+ cancelAtPeriodEnd: boolean;
42
+ }
43
+ interface CheckoutParams {
44
+ planId: string;
45
+ userId: string;
46
+ successUrl?: string;
47
+ cancelUrl?: string;
48
+ }
49
+ interface CheckoutResult {
50
+ url: string;
51
+ sessionId: string;
52
+ }
53
+ type ChatRole = 'system' | 'user' | 'assistant';
54
+ interface ChatMessage {
55
+ role: ChatRole;
56
+ content: string;
57
+ }
58
+ interface AiOptions {
59
+ model?: string;
60
+ temperature?: number;
61
+ maxTokens?: number;
62
+ }
63
+ interface ChatResponse {
64
+ content: string;
65
+ finishReason: 'stop' | 'length' | 'error';
66
+ usage?: {
67
+ promptTokens: number;
68
+ completionTokens: number;
69
+ totalTokens: number;
70
+ };
71
+ }
72
+ interface StoredFile {
73
+ id: string;
74
+ name: string;
75
+ path: string;
76
+ size: number;
77
+ mimeType: string;
78
+ url: string;
79
+ createdAt: string;
80
+ }
81
+ type AdapterDomain = 'db' | 'auth' | 'payments' | 'ai' | 'storage' | 'admin';
82
+ interface DomainAdapterConfig {
83
+ provider: string;
84
+ apiKey?: string;
85
+ baseUrl?: string;
86
+ options?: Record<string, unknown>;
87
+ }
88
+ interface AdapterConfig {
89
+ db?: DomainAdapterConfig;
90
+ auth?: DomainAdapterConfig;
91
+ payments?: DomainAdapterConfig;
92
+ ai?: DomainAdapterConfig;
93
+ storage?: DomainAdapterConfig;
94
+ admin?: DomainAdapterConfig;
95
+ }
96
+ type AdapterStatusType = 'connected' | 'disconnected' | 'error' | 'initializing';
97
+ interface AdapterStatusInfo {
98
+ domain: AdapterDomain;
99
+ provider: string;
100
+ status: AdapterStatusType;
101
+ latency?: number;
102
+ lastCheckedAt?: number;
103
+ error?: string;
104
+ }
105
+ interface AdapterRegistryEntry {
106
+ domain: AdapterDomain;
107
+ provider: string;
108
+ status: AdapterStatusType;
109
+ config: DomainAdapterConfig;
110
+ connectedAt?: number;
111
+ }
112
+
113
+ type DbErrorCode = 'NOT_FOUND' | 'CONSTRAINT_VIOLATION' | 'QUERY_ERROR' | 'CONNECTION_ERROR' | 'COLLECTION_NOT_CONFIGURED';
114
+ type AuthErrorCode = 'INVALID_CREDENTIALS' | 'USER_EXISTS' | 'SESSION_EXPIRED' | 'UNAUTHORIZED' | 'OAUTH_ERROR' | 'SERVICE_ERROR';
115
+ type AiErrorCode = 'MODEL_ERROR' | 'RATE_LIMIT' | 'CONTEXT_LENGTH' | 'SERVICE_ERROR' | 'EMBEDDING_ERROR';
116
+ type StorageErrorCode = 'NOT_FOUND' | 'UPLOAD_FAILED' | 'DOWNLOAD_FAILED' | 'QUOTA_EXCEEDED' | 'INVALID_KEY' | 'SERVICE_ERROR';
117
+ type PaymentsErrorCode = 'INVALID_PLAN' | 'CHECKOUT_FAILED' | 'SUBSCRIPTION_NOT_FOUND' | 'CANCEL_FAILED' | 'SERVICE_ERROR' | 'NOT_AVAILABLE';
118
+ type AdminErrorCode = 'USER_NOT_FOUND' | 'OPERATION_FAILED' | 'SERVICE_ERROR';
119
+ declare class AdapterError extends Error {
120
+ readonly domain: string;
121
+ readonly code: string;
122
+ readonly cause?: unknown | undefined;
123
+ constructor(message: string, domain: string, code: string, cause?: unknown | undefined);
124
+ }
125
+ declare class DbError extends AdapterError {
126
+ constructor(message: string, code: DbErrorCode, cause?: unknown);
127
+ }
128
+ declare class AuthError extends AdapterError {
129
+ constructor(message: string, code: AuthErrorCode, cause?: unknown);
130
+ }
131
+ declare class AiError extends AdapterError {
132
+ constructor(message: string, code: AiErrorCode, cause?: unknown);
133
+ }
134
+ declare class StorageError extends AdapterError {
135
+ constructor(message: string, code: StorageErrorCode, cause?: unknown);
136
+ }
137
+ declare class PaymentsError extends AdapterError {
138
+ constructor(message: string, code: PaymentsErrorCode, cause?: unknown);
139
+ }
140
+ declare class AdminError extends AdapterError {
141
+ constructor(message: string, code: AdminErrorCode, cause?: unknown);
142
+ }
143
+ declare function isAdapterError(error: unknown): error is AdapterError;
144
+ declare function isRetryable(error: unknown): boolean;
145
+
146
+ interface RetryOptions {
147
+ /** Maximum number of attempts (default: 3) */
148
+ maxAttempts?: number;
149
+ /** Initial delay in milliseconds (default: 500) */
150
+ delayMs?: number;
151
+ /** Backoff multiplier (default: 2) */
152
+ backoffMultiplier?: number;
153
+ /** Custom predicate to determine if error is retryable (default: isRetryable) */
154
+ shouldRetry?: (error: unknown) => boolean;
155
+ }
156
+ declare function withRetry<T>(fn: () => Promise<T>, options?: RetryOptions): Promise<T>;
157
+
158
+ /**
159
+ * Configure the adapter system.
160
+ * Call once at app startup before using any adapter hooks.
161
+ *
162
+ * @example
163
+ * ```ts
164
+ * configureAdapters({
165
+ * db: { provider: 'convex' },
166
+ * auth: { provider: 'better-auth' },
167
+ * ai: { provider: 'openai', apiKey: process.env.OPENAI_API_KEY },
168
+ * storage: { provider: 'r2' },
169
+ * payments: { provider: 'stripe' },
170
+ * })
171
+ * ```
172
+ */
173
+ declare function configureAdapters(config: AdapterConfig): void;
174
+ /**
175
+ * Get the current adapter configuration.
176
+ * Throws if configureAdapters() has not been called.
177
+ */
178
+ declare function getAdapterConfig(): AdapterConfig;
179
+ /**
180
+ * Check if adapters have been configured.
181
+ */
182
+ declare function isAdaptersConfigured(): boolean;
183
+ /**
184
+ * Reset adapter configuration (useful for testing).
185
+ */
186
+ declare function resetAdapterConfig(): void;
187
+ /**
188
+ * Get config for a specific adapter domain.
189
+ */
190
+ declare function getDomainConfig(domain: AdapterDomain): DomainAdapterConfig | null;
191
+
192
+ /** OAuth provider identifiers */
193
+ type OAuthProvider = 'google' | 'github' | 'discord' | 'twitter' | 'apple' | 'microsoft' | string;
194
+ /**
195
+ * Minimal auth adapter contract.
196
+ *
197
+ * This interface defines the core authentication operations that every provider
198
+ * must support. For rich auth features (MFA, passkeys, API keys, RBAC, session
199
+ * management, magic links, password reset), use `@geenius/auth` directly — it
200
+ * implements this interface and extends it with the full `AuthProviderAdapter`.
201
+ *
202
+ * @example
203
+ * ```ts
204
+ * import type { AuthAdapter } from '@geenius/adapters'
205
+ * import { createLocalStorageAuthAdapter } from '@geenius/adapters' // mock
206
+ * import { createAuthProvider } from '@geenius/auth' // real
207
+ * ```
208
+ */
209
+ interface AuthAdapter {
210
+ signIn(email: string, password: string): Promise<AuthSession>;
211
+ signUp(email: string, password: string, name?: string): Promise<AuthSession>;
212
+ /** Initiate an OAuth sign-in flow. Returns the redirect URL for the provider. */
213
+ signInWithOAuth(provider: OAuthProvider, options?: {
214
+ redirectUrl?: string;
215
+ }): Promise<{
216
+ url: string;
217
+ }>;
218
+ signOut(): Promise<void>;
219
+ getSession(): Promise<AuthSession | null>;
220
+ getUser(): Promise<AuthUser | null>;
221
+ updateUser(updates: Partial<Pick<AuthUser, 'name' | 'image'>>): Promise<AuthUser | null>;
222
+ }
223
+
224
+ interface DbAdapter {
225
+ create<T extends Record<string, unknown>>(collection: string, data: Omit<T, 'id'>): Promise<T & {
226
+ id: string;
227
+ }>;
228
+ get<T>(collection: string, id: string): Promise<T | null>;
229
+ update<T extends Record<string, unknown>>(collection: string, id: string, data: Partial<T>): Promise<T | null>;
230
+ delete(collection: string, id: string): Promise<boolean>;
231
+ list<T>(collection: string, options?: ListOptions): Promise<T[]>;
232
+ query<T>(collection: string, filter: QueryFilter): Promise<T[]>;
233
+ count(collection: string, filter?: QueryFilter): Promise<number>;
234
+ }
235
+
236
+ /**
237
+ * Minimal AI adapter contract.
238
+ *
239
+ * This interface defines the core AI operations that every provider must support.
240
+ * For rich AI features (memory, skills, tool calling, content templates, streaming
241
+ * callbacks), use `@geenius/ai` directly — it implements this interface and extends
242
+ * it with the full feature set.
243
+ *
244
+ * @example
245
+ * ```ts
246
+ * import type { AiAdapter } from '@geenius/adapters'
247
+ * import { createLocalStorageAiAdapter } from '@geenius/adapters' // mock
248
+ * import { AIClient } from '@geenius/ai' // real
249
+ * ```
250
+ */
251
+ interface AiAdapter {
252
+ chat(messages: ChatMessage[], options?: AiOptions): Promise<ChatResponse>;
253
+ complete(prompt: string, options?: AiOptions): Promise<string>;
254
+ embed(text: string | string[]): Promise<number[][]>;
255
+ /** Stream chat tokens as an async iterable of text deltas. */
256
+ stream(messages: ChatMessage[], options?: AiOptions): AsyncIterable<string>;
257
+ }
258
+
259
+ interface FileStorageAdapter {
260
+ upload(file: File | Blob, path: string, name?: string): Promise<StoredFile>;
261
+ download(fileId: string): Promise<Blob>;
262
+ delete(fileId: string): Promise<boolean>;
263
+ list(prefix?: string): Promise<StoredFile[]>;
264
+ getUrl(fileId: string): Promise<string>;
265
+ }
266
+
267
+ /**
268
+ * Minimal payments adapter contract.
269
+ *
270
+ * This interface defines the core payment operations that every provider must
271
+ * support. For rich payment features (webhooks, invoices, customer portal, plan
272
+ * sync, subscription updates, refunds), use `@geenius/payments` directly — it
273
+ * implements this interface and extends it with the full `PaymentProviderAdapter`.
274
+ *
275
+ * @example
276
+ * ```ts
277
+ * import type { PaymentsAdapter } from '@geenius/adapters'
278
+ * import { createLocalStoragePaymentsAdapter } from '@geenius/adapters' // mock
279
+ * import { createPaymentProvider } from '@geenius/payments' // real
280
+ * ```
281
+ */
282
+ interface PaymentsAdapter {
283
+ createCheckout(params: CheckoutParams): Promise<CheckoutResult>;
284
+ getSubscription(userId: string): Promise<Subscription | null>;
285
+ cancelSubscription(subscriptionId: string): Promise<void>;
286
+ getPlans(): Promise<Plan[]>;
287
+ isFeatureEnabled(userId: string, feature: string): Promise<boolean>;
288
+ }
289
+
290
+ interface AdminMetrics {
291
+ totalUsers: number;
292
+ activeUsers: number;
293
+ newUsersToday: number;
294
+ totalRevenue?: number;
295
+ mrr?: number;
296
+ }
297
+ interface ManagedUser extends AuthUser {
298
+ isActive: boolean;
299
+ isBanned: boolean;
300
+ plan?: string;
301
+ lastLoginAt?: string;
302
+ }
303
+ interface AdminAdapter {
304
+ /** List all users with pagination */
305
+ listUsers(options?: {
306
+ limit?: number;
307
+ offset?: number;
308
+ search?: string;
309
+ }): Promise<ManagedUser[]>;
310
+ /** Get a single user by ID */
311
+ getUser(id: string): Promise<ManagedUser | null>;
312
+ /** Ban a user */
313
+ banUser(id: string): Promise<boolean>;
314
+ /** Unban a user */
315
+ unbanUser(id: string): Promise<boolean>;
316
+ /** Delete a user */
317
+ deleteUser(id: string): Promise<boolean>;
318
+ /** Get dashboard metrics */
319
+ getMetrics(): Promise<AdminMetrics>;
320
+ }
321
+
322
+ type AdapterForDomain<D extends AdapterDomain> = D extends 'auth' ? AuthAdapter : D extends 'db' ? DbAdapter : D extends 'ai' ? AiAdapter : D extends 'storage' ? FileStorageAdapter : D extends 'payments' ? PaymentsAdapter : D extends 'admin' ? AdminAdapter : never;
323
+ /**
324
+ * Register a factory function for a specific domain + provider combination.
325
+ *
326
+ * @example
327
+ * ```ts
328
+ * import { registerResolver, createConvexDbAdapter } from '@geenius/adapters-shared'
329
+ *
330
+ * registerResolver('db', 'convex', (config) =>
331
+ * createConvexDbAdapter({ client: convex, functions: myFunctions })
332
+ * )
333
+ * ```
334
+ */
335
+ declare function registerResolver<D extends AdapterDomain>(domain: D, provider: string, resolver: (config: DomainAdapterConfig) => AdapterForDomain<D>): void;
336
+ /**
337
+ * Resolve an adapter for a given domain using the current config.
338
+ * Requires that configureAdapters() has been called and a resolver
339
+ * has been registered for the domain's provider.
340
+ *
341
+ * @example
342
+ * ```ts
343
+ * configureAdapters({ db: { provider: 'convex' } })
344
+ * const db = resolveAdapter('db') // returns the registered Convex adapter
345
+ * ```
346
+ */
347
+ declare function resolveAdapter<D extends AdapterDomain>(domain: D): AdapterForDomain<D>;
348
+ /**
349
+ * Check if a resolver is registered for a domain + provider.
350
+ */
351
+ declare function hasResolver(domain: AdapterDomain, provider: string): boolean;
352
+ /**
353
+ * Clear all registered resolvers (useful for testing).
354
+ */
355
+ declare function clearResolvers(): void;
356
+
357
+ declare const ADAPTER_DOMAINS: readonly AdapterDomain[];
358
+ declare const DB_PROVIDERS: readonly ["localStorage", "convex", "supabase", "neon", "mongodb"];
359
+ declare const AUTH_PROVIDERS: readonly ["localStorage", "better-auth", "convex-auth", "clerk", "supabase-auth"];
360
+ declare const AI_PROVIDERS: readonly ["localStorage", "openai", "anthropic", "gemini", "ollama", "cloudflare-ai-gateway", "vercel-ai-sdk"];
361
+ declare const STORAGE_PROVIDERS: readonly ["localStorage", "r2", "s3", "uploadthing", "supabase-storage", "convex-storage", "minio"];
362
+ declare const PAYMENT_PROVIDERS: readonly ["localStorage", "stripe", "noop"];
363
+ declare const ADMIN_PROVIDERS: readonly ["localStorage"];
364
+ type DbProviderName = (typeof DB_PROVIDERS)[number];
365
+ type AuthProviderName = (typeof AUTH_PROVIDERS)[number];
366
+ type AiProviderName = (typeof AI_PROVIDERS)[number];
367
+ type StorageProviderName = (typeof STORAGE_PROVIDERS)[number];
368
+ type PaymentProviderName = (typeof PAYMENT_PROVIDERS)[number];
369
+ type AdminProviderName = (typeof ADMIN_PROVIDERS)[number];
370
+ declare const ADAPTER_STATUSES: readonly ["connected", "disconnected", "error", "initializing"];
371
+ type AdapterStatus = (typeof ADAPTER_STATUSES)[number];
372
+ declare const DOMAIN_LABELS: Record<AdapterDomain, string>;
373
+ declare const DOMAIN_ICONS: Record<AdapterDomain, string>;
374
+ declare const DOMAIN_DESCRIPTIONS: Record<AdapterDomain, string>;
375
+ interface ProviderMeta {
376
+ id: string;
377
+ name: string;
378
+ domain: AdapterDomain;
379
+ description: string;
380
+ /** Minimum tier required to use this provider */
381
+ tier: 'pronto' | 'lancio' | 'studio';
382
+ docUrl?: string;
383
+ }
384
+ declare const PROVIDER_REGISTRY: ProviderMeta[];
385
+ /**
386
+ * Get all providers for a specific domain.
387
+ */
388
+ declare function getProvidersForDomain(domain: AdapterDomain): ProviderMeta[];
389
+ /**
390
+ * Get a specific provider by id and domain.
391
+ */
392
+ declare function getProviderMeta(domain: AdapterDomain, providerId: string): ProviderMeta | undefined;
393
+
394
+ declare function createLocalStorageAuthAdapter(): AuthAdapter;
395
+
396
+ declare function createLocalStorageDbAdapter(): DbAdapter;
397
+
398
+ interface ConvexClient {
399
+ query: (fn: unknown, args?: Record<string, unknown>) => Promise<unknown>;
400
+ mutation: (fn: unknown, args?: Record<string, unknown>) => Promise<unknown>;
401
+ }
402
+ interface ConvexDbAdapterOptions {
403
+ /** Pre-configured Convex client */
404
+ client: ConvexClient;
405
+ /** Map of collection names to Convex function references */
406
+ functions: {
407
+ [collection: string]: {
408
+ create?: unknown;
409
+ get?: unknown;
410
+ update?: unknown;
411
+ delete?: unknown;
412
+ list?: unknown;
413
+ query?: unknown;
414
+ count?: unknown;
415
+ };
416
+ };
417
+ }
418
+ /**
419
+ * Creates a Convex-backed DbAdapter.
420
+ *
421
+ * Since Convex uses predefined queries/mutations rather than arbitrary SQL,
422
+ * you must provide function references for each collection. The adapter maps
423
+ * generic CRUD calls to these Convex functions.
424
+ *
425
+ * @example
426
+ * ```ts
427
+ * import { api } from '../convex/_generated/api'
428
+ *
429
+ * const db = createConvexDbAdapter({
430
+ * client: convex,
431
+ * functions: {
432
+ * tasks: {
433
+ * create: api.tasks.create,
434
+ * get: api.tasks.get,
435
+ * list: api.tasks.list,
436
+ * update: api.tasks.update,
437
+ * delete: api.tasks.remove,
438
+ * },
439
+ * },
440
+ * })
441
+ * ```
442
+ */
443
+ declare function createConvexDbAdapter(options: ConvexDbAdapterOptions): DbAdapter;
444
+
445
+ interface DrizzleTable {
446
+ [key: string]: unknown;
447
+ }
448
+ interface DrizzleClient {
449
+ select: (fields?: Record<string, unknown>) => unknown;
450
+ insert: (table: unknown) => unknown;
451
+ update: (table: unknown) => unknown;
452
+ delete: (table: unknown) => unknown;
453
+ }
454
+ /** Drizzle operator functions — injected by the consumer */
455
+ interface DrizzleOperators {
456
+ eq: (col: unknown, value: unknown) => unknown;
457
+ ne: (col: unknown, value: unknown) => unknown;
458
+ gt: (col: unknown, value: unknown) => unknown;
459
+ gte: (col: unknown, value: unknown) => unknown;
460
+ lt: (col: unknown, value: unknown) => unknown;
461
+ lte: (col: unknown, value: unknown) => unknown;
462
+ inArray: (col: unknown, values: unknown[]) => unknown;
463
+ like: (col: unknown, pattern: string) => unknown;
464
+ and: (...conditions: unknown[]) => unknown;
465
+ asc: (col: unknown) => unknown;
466
+ desc: (col: unknown) => unknown;
467
+ sql: unknown;
468
+ count: (col?: unknown) => unknown;
469
+ }
470
+ interface NeonDbAdapterOptions {
471
+ /** Pre-configured Drizzle client instance */
472
+ client: DrizzleClient;
473
+ /** Map of collection names to Drizzle table schema objects */
474
+ tables: Record<string, DrizzleTable>;
475
+ /** Drizzle operator functions (import from 'drizzle-orm') */
476
+ operators: DrizzleOperators;
477
+ }
478
+ /**
479
+ * Creates a Neon-backed DbAdapter using Drizzle ORM.
480
+ *
481
+ * @example
482
+ * ```ts
483
+ * import { drizzle } from 'drizzle-orm/neon-http'
484
+ * import { neon } from '@neondatabase/serverless'
485
+ * import { eq, ne, gt, gte, lt, lte, inArray, like, and, asc, desc, sql, count } from 'drizzle-orm'
486
+ * import * as schema from './schema'
487
+ *
488
+ * const db = drizzle(neon(process.env.DATABASE_URL!))
489
+ *
490
+ * const adapter = createNeonDbAdapter({
491
+ * client: db,
492
+ * tables: { tasks: schema.tasks },
493
+ * operators: { eq, ne, gt, gte, lt, lte, inArray, like, and, asc, desc, sql, count },
494
+ * })
495
+ * ```
496
+ */
497
+ declare function createNeonDbAdapter(options: NeonDbAdapterOptions): DbAdapter;
498
+
499
+ interface SupabaseClient {
500
+ from: (table: string) => SupabaseQueryBuilder;
501
+ }
502
+ interface SupabaseQueryBuilder {
503
+ select: (columns?: string) => SupabaseQueryBuilder;
504
+ insert: (data: Record<string, unknown>) => SupabaseQueryBuilder;
505
+ update: (data: Record<string, unknown>) => SupabaseQueryBuilder;
506
+ delete: () => SupabaseQueryBuilder;
507
+ eq: (column: string, value: unknown) => SupabaseQueryBuilder;
508
+ neq: (column: string, value: unknown) => SupabaseQueryBuilder;
509
+ gt: (column: string, value: unknown) => SupabaseQueryBuilder;
510
+ gte: (column: string, value: unknown) => SupabaseQueryBuilder;
511
+ lt: (column: string, value: unknown) => SupabaseQueryBuilder;
512
+ lte: (column: string, value: unknown) => SupabaseQueryBuilder;
513
+ in: (column: string, values: unknown[]) => SupabaseQueryBuilder;
514
+ ilike: (column: string, pattern: string) => SupabaseQueryBuilder;
515
+ order: (column: string, options?: {
516
+ ascending?: boolean;
517
+ }) => SupabaseQueryBuilder;
518
+ range: (from: number, to: number) => SupabaseQueryBuilder;
519
+ limit: (count: number) => SupabaseQueryBuilder;
520
+ single: () => SupabaseQueryBuilder;
521
+ then: (resolve: (value: {
522
+ data: unknown;
523
+ error: {
524
+ message: string;
525
+ } | null;
526
+ }) => void) => Promise<unknown>;
527
+ }
528
+ interface SupabaseDbAdapterOptions {
529
+ /** Pre-configured Supabase client instance */
530
+ client: SupabaseClient;
531
+ /** Optional table name mapping: { collectionName: 'actual_table_name' } */
532
+ tableNames?: Record<string, string>;
533
+ }
534
+ /**
535
+ * Creates a Supabase-backed DbAdapter.
536
+ *
537
+ * @example
538
+ * ```ts
539
+ * import { createClient } from '@supabase/supabase-js'
540
+ *
541
+ * const supabase = createClient(url, key)
542
+ * const db = createSupabaseDbAdapter({ client: supabase })
543
+ * ```
544
+ */
545
+ declare function createSupabaseDbAdapter(options: SupabaseDbAdapterOptions): DbAdapter;
546
+
547
+ interface MongoCollection {
548
+ insertOne: (doc: Record<string, unknown>) => Promise<{
549
+ insertedId: unknown;
550
+ }>;
551
+ findOne: (filter: Record<string, unknown>) => Promise<Record<string, unknown> | null>;
552
+ updateOne: (filter: Record<string, unknown>, update: Record<string, unknown>) => Promise<unknown>;
553
+ deleteOne: (filter: Record<string, unknown>) => Promise<{
554
+ deletedCount: number;
555
+ }>;
556
+ find: (filter?: Record<string, unknown>) => MongoCursor;
557
+ countDocuments: (filter?: Record<string, unknown>) => Promise<number>;
558
+ }
559
+ interface MongoCursor {
560
+ sort: (sort: Record<string, number>) => MongoCursor;
561
+ skip: (n: number) => MongoCursor;
562
+ limit: (n: number) => MongoCursor;
563
+ toArray: () => Promise<Record<string, unknown>[]>;
564
+ }
565
+ interface MongoDb {
566
+ collection: (name: string) => MongoCollection;
567
+ }
568
+ interface MongoDbAdapterOptions {
569
+ /** Pre-configured MongoDB database instance */
570
+ db: MongoDb;
571
+ /** Optional collection name mapping */
572
+ collectionNames?: Record<string, string>;
573
+ }
574
+ /**
575
+ * Creates a MongoDB-backed DbAdapter.
576
+ *
577
+ * @example
578
+ * ```ts
579
+ * import { MongoClient } from 'mongodb'
580
+ *
581
+ * const client = new MongoClient(process.env.MONGODB_URI!)
582
+ * const db = client.db('myapp')
583
+ * const adapter = createMongoDbAdapter({ db })
584
+ * ```
585
+ */
586
+ declare function createMongoDbAdapter(options: MongoDbAdapterOptions): DbAdapter;
587
+
588
+ interface KVNamespaceLike {
589
+ get(key: string, type: 'json'): Promise<unknown>;
590
+ put(key: string, value: string): Promise<void>;
591
+ }
592
+ declare function createCloudflareKVDbAdapter(kv: KVNamespaceLike): DbAdapter;
593
+
594
+ declare function createMemoryDbAdapter(): DbAdapter;
595
+
596
+ declare function createLocalStoragePaymentsAdapter(): PaymentsAdapter;
597
+ declare function createNoopPaymentsAdapter(): PaymentsAdapter;
598
+
599
+ declare function createLocalStorageAiAdapter(): AiAdapter;
600
+
601
+ declare function createLocalStorageFileAdapter(): FileStorageAdapter;
602
+
603
+ declare function createLocalStorageAdminAdapter(): AdminAdapter;
604
+
605
+ type ProjectTier = 'pronto' | 'lancio' | 'studio';
606
+ /** Feature access rules per tier */
607
+ interface TierGateConfig {
608
+ /** Features available in each tier (cumulative — higher tiers include lower) */
609
+ features: Record<ProjectTier, string[]>;
610
+ /** UI component packages available per tier */
611
+ packages: Record<ProjectTier, string[]>;
612
+ }
613
+ declare const DEFAULT_TIER_GATE: TierGateConfig;
614
+ /** Check if a feature is available for a given tier */
615
+ declare function isFeatureAvailable(feature: string, tier: ProjectTier): boolean;
616
+ /** Check if a package is available for a given tier */
617
+ declare function isPackageAvailable(pkg: string, tier: ProjectTier): boolean;
618
+ /** Get all features available for a tier */
619
+ declare function getAvailableFeatures(tier: ProjectTier): string[];
620
+ /** Get all packages available for a tier */
621
+ declare function getAvailablePackages(tier: ProjectTier): string[];
622
+ /** Get the features that would be unlocked by upgrading to a higher tier */
623
+ declare function getUpgradeFeatures(currentTier: ProjectTier, targetTier: ProjectTier): string[];
624
+
625
+ export { ADAPTER_DOMAINS, ADAPTER_STATUSES, ADMIN_PROVIDERS, AI_PROVIDERS, AUTH_PROVIDERS, type AdapterConfig, type AdapterDomain, AdapterError, type AdapterRegistryEntry, type AdapterStatus, type AdapterStatusInfo, type AdapterStatusType, type AdminAdapter, AdminError, type AdminErrorCode, type AdminMetrics, type AdminProviderName, type AiAdapter, AiError, type AiErrorCode, type AiOptions, type AiProviderName, type AuthAdapter, AuthError, type AuthErrorCode, type AuthProviderName, type AuthSession, type AuthUser, type ChatMessage, type ChatResponse, type ChatRole, type CheckoutParams, type CheckoutResult, type ConvexDbAdapterOptions, DB_PROVIDERS, DEFAULT_TIER_GATE, DOMAIN_DESCRIPTIONS, DOMAIN_ICONS, DOMAIN_LABELS, type DbAdapter, DbError, type DbErrorCode, type DbProviderName, type DomainAdapterConfig, type FileStorageAdapter, type KVNamespaceLike, type ListOptions, type ManagedUser, type MongoDbAdapterOptions, type NeonDbAdapterOptions, type OAuthProvider, PAYMENT_PROVIDERS, PROVIDER_REGISTRY, type PaymentProviderName, type PaymentsAdapter, PaymentsError, type PaymentsErrorCode, type Plan, type ProjectTier, type ProviderMeta, type QueryCondition, type QueryFilter, type QueryOperator, type RetryOptions, STORAGE_PROVIDERS, StorageError, type StorageErrorCode, type StorageProviderName, type StoredFile, type Subscription, type SupabaseDbAdapterOptions, type TierGateConfig, clearResolvers, configureAdapters, createCloudflareKVDbAdapter, createConvexDbAdapter, createLocalStorageAdminAdapter, createLocalStorageAiAdapter, createLocalStorageAuthAdapter, createLocalStorageDbAdapter, createLocalStorageFileAdapter, createLocalStoragePaymentsAdapter, createMemoryDbAdapter, createMongoDbAdapter, createNeonDbAdapter, createNoopPaymentsAdapter, createSupabaseDbAdapter, getAdapterConfig, getAvailableFeatures, getAvailablePackages, getDomainConfig, getProviderMeta, getProvidersForDomain, getUpgradeFeatures, hasResolver, isAdapterError, isAdaptersConfigured, isFeatureAvailable, isPackageAvailable, isRetryable, registerResolver, resetAdapterConfig, resolveAdapter, withRetry };