-
-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
Overview
Create a complete Convex storage adapter for Keypal API key management.
Current Status
Basic Convex adapter structure exists at src/storage/convex.ts but needs completion.
Tasks
1. Schema Definition
- Create
src/convex/schema.tswith proper Convex schema definitions - Define
apiKeystable with required fields (id, keyHash, metadata) - Define
auditLogstable with proper indexes - Add proper indexes for performance (by_keyHash, by_owner, by_timestamp)
2. Convex Functions
Create the following Convex mutations and queries in src/convex/storage.ts:
-
createmutation - Create new API key record -
findByHashquery - Find by key hash -
findByIdquery - Find by ID -
findByOwnerquery - Find all keys for an owner -
findByTagsquery - Find keys by tags -
updateMetadatamutation - Update key metadata -
deletemutation - Delete a key -
deleteByOwnermutation - Delete all keys for an owner -
createLogmutation - Create audit log entry -
findLogsquery - Query audit logs -
countLogsquery - Count audit logs -
deleteLogsmutation - Delete audit logs -
getLogStatsquery - Get log statistics
3. Testing
- Create comprehensive test suite at
src/storage/convex.test.ts - Test all CRUD operations
- Test audit logging functionality
- Test error handling
- Add integration tests with real Convex backend
4. Documentation
- Add Convex to package.json exports
- Update README with Convex usage examples
- Create example Convex schema
- Document setup instructions
- Add Convex to keywords in package.json
5. Build Configuration
- Add Convex types to tsconfig
- Ensure proper build output for Convex adapter
- Add Convex as optional peer dependency
Example Usage
import { ConvexStore } from 'keypal/convex';
import { api } from './_generated/api';
const store = new ConvexStore({
ctx, // Convex query or action context
api, // Convex API object
tableName: 'apiKeys',
logTableName: 'auditLogs',
});Schema Requirements
import { defineSchema, defineTable } from "convex/server";
import { v } from "convex/values";
export default defineSchema({
apiKeys: defineTable({
keyHash: v.string(),
metadata: v.any(),
})
.index("by_keyHash", ["keyHash"])
.index("by_owner", ["metadata.ownerId"]),
auditLogs: defineTable({
keyId: v.string(),
ownerId: v.string(),
action: v.string(),
timestamp: v.string(),
data: v.optional(v.any()),
})
.index("by_keyId", ["keyId"])
.index("by_owner", ["ownerId"])
.index("by_timestamp", ["timestamp"]),
});Acceptance Criteria
- All Convex functions implemented and tested
- Tests pass with mock Convex implementation
- Integration tests pass with real Convex backend
- Documentation complete
- Adapter works with existing Keypal manager
- Follows same patterns as other storage adapters (Memory, Redis, Drizzle, Prisma)
Metadata
Metadata
Assignees
Labels
No labels