@l4yercak3/cli 1.0.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/.claude/settings.local.json +18 -0
- package/.cursor/rules.md +203 -0
- package/.eslintrc.js +31 -0
- package/README.md +227 -0
- package/bin/cli.js +61 -0
- package/docs/ADDING_NEW_PROJECT_TYPE.md +156 -0
- package/docs/ARCHITECTURE_RELATIONSHIPS.md +411 -0
- package/docs/CLI_AUTHENTICATION.md +214 -0
- package/docs/DETECTOR_ARCHITECTURE.md +326 -0
- package/docs/DEVELOPMENT.md +194 -0
- package/docs/IMPLEMENTATION_PHASES.md +468 -0
- package/docs/OAUTH_CLARIFICATION.md +258 -0
- package/docs/OAUTH_SETUP_GUIDE_TEMPLATE.md +211 -0
- package/docs/PHASE_0_PROGRESS.md +120 -0
- package/docs/PHASE_1_COMPLETE.md +366 -0
- package/docs/PHASE_SUMMARY.md +149 -0
- package/docs/PLAN.md +511 -0
- package/docs/README.md +56 -0
- package/docs/STRIPE_INTEGRATION.md +447 -0
- package/docs/SUMMARY.md +230 -0
- package/docs/UPDATED_PLAN.md +447 -0
- package/package.json +53 -0
- package/src/api/backend-client.js +148 -0
- package/src/commands/login.js +146 -0
- package/src/commands/logout.js +24 -0
- package/src/commands/spread.js +364 -0
- package/src/commands/status.js +62 -0
- package/src/config/config-manager.js +205 -0
- package/src/detectors/api-client-detector.js +85 -0
- package/src/detectors/base-detector.js +77 -0
- package/src/detectors/github-detector.js +74 -0
- package/src/detectors/index.js +80 -0
- package/src/detectors/nextjs-detector.js +139 -0
- package/src/detectors/oauth-detector.js +122 -0
- package/src/detectors/registry.js +97 -0
- package/src/generators/api-client-generator.js +197 -0
- package/src/generators/env-generator.js +162 -0
- package/src/generators/gitignore-generator.js +92 -0
- package/src/generators/index.js +50 -0
- package/src/generators/nextauth-generator.js +242 -0
- package/src/generators/oauth-guide-generator.js +277 -0
- package/src/logo.js +116 -0
- package/tests/api-client-detector.test.js +214 -0
- package/tests/api-client-generator.test.js +169 -0
- package/tests/backend-client.test.js +361 -0
- package/tests/base-detector.test.js +101 -0
- package/tests/commands/login.test.js +98 -0
- package/tests/commands/logout.test.js +70 -0
- package/tests/commands/status.test.js +167 -0
- package/tests/config-manager.test.js +313 -0
- package/tests/detector-index.test.js +209 -0
- package/tests/detector-registry.test.js +93 -0
- package/tests/env-generator.test.js +278 -0
- package/tests/generators-index.test.js +215 -0
- package/tests/github-detector.test.js +145 -0
- package/tests/gitignore-generator.test.js +109 -0
- package/tests/logo.test.js +96 -0
- package/tests/nextauth-generator.test.js +231 -0
- package/tests/nextjs-detector.test.js +235 -0
- package/tests/oauth-detector.test.js +264 -0
- package/tests/oauth-guide-generator.test.js +273 -0
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
# Phase 1 Implementation Status 🚧
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
Phase 1 of the L4YERCAK3 CLI tool is **partially implemented**. This document tracks what's been built and what still needs to be done.
|
|
6
|
+
|
|
7
|
+
**Status:** 🟡 In Progress
|
|
8
|
+
**Last Updated:** 2025-01-14
|
|
9
|
+
**Note:** This document was created prematurely - Phase 1 is not yet complete.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## What Was Implemented
|
|
14
|
+
|
|
15
|
+
### 1. Project Detection (`src/detectors/`)
|
|
16
|
+
|
|
17
|
+
#### Next.js Detector (`nextjs-detector.js`)
|
|
18
|
+
- ✅ Detects Next.js projects by checking `package.json`
|
|
19
|
+
- ✅ Identifies Next.js version
|
|
20
|
+
- ✅ Detects router type (App Router vs Pages Router)
|
|
21
|
+
- ✅ Detects TypeScript usage
|
|
22
|
+
- ✅ Reads Next.js configuration files
|
|
23
|
+
|
|
24
|
+
#### GitHub Detector (`github-detector.js`)
|
|
25
|
+
- ✅ Detects Git repository
|
|
26
|
+
- ✅ Extracts GitHub repository information (owner, repo, URL)
|
|
27
|
+
- ✅ Gets current branch name
|
|
28
|
+
- ✅ Supports both HTTPS and SSH Git URLs
|
|
29
|
+
|
|
30
|
+
#### API Client Detector (`api-client-detector.js`)
|
|
31
|
+
- ✅ Detects existing API client implementations
|
|
32
|
+
- ✅ Identifies client type (fetch, axios, custom)
|
|
33
|
+
- ✅ Detects existing environment files
|
|
34
|
+
- ✅ Checks common API client locations
|
|
35
|
+
|
|
36
|
+
#### Main Detector (`index.js`)
|
|
37
|
+
- ✅ Orchestrates all detectors
|
|
38
|
+
- ✅ Returns combined detection results
|
|
39
|
+
|
|
40
|
+
### 2. Configuration Wizard (`src/commands/spread.js`)
|
|
41
|
+
|
|
42
|
+
The `spread` command now includes a full interactive wizard:
|
|
43
|
+
|
|
44
|
+
1. **Project Detection**
|
|
45
|
+
- Automatically detects Next.js, GitHub, and existing API clients
|
|
46
|
+
- Warns if project doesn't appear to be Next.js
|
|
47
|
+
- Shows detected project information
|
|
48
|
+
|
|
49
|
+
2. **Organization Management**
|
|
50
|
+
- Lists existing organizations
|
|
51
|
+
- Allows selection of existing organization
|
|
52
|
+
- Option to create new organization
|
|
53
|
+
- Handles different API response formats
|
|
54
|
+
|
|
55
|
+
3. **API Key Generation**
|
|
56
|
+
- Automatically generates API key for selected organization
|
|
57
|
+
- Handles API response format variations
|
|
58
|
+
- Provides clear error messages
|
|
59
|
+
|
|
60
|
+
4. **Feature Selection**
|
|
61
|
+
- Interactive checkbox selection for:
|
|
62
|
+
- CRM (Contacts)
|
|
63
|
+
- Projects
|
|
64
|
+
- Invoices
|
|
65
|
+
- OAuth Authentication
|
|
66
|
+
- Stripe Integration
|
|
67
|
+
|
|
68
|
+
5. **OAuth Provider Selection**
|
|
69
|
+
- If OAuth is enabled, prompts for provider selection:
|
|
70
|
+
- Google
|
|
71
|
+
- Microsoft
|
|
72
|
+
- GitHub
|
|
73
|
+
|
|
74
|
+
6. **Configuration**
|
|
75
|
+
- Backend URL configuration (with default)
|
|
76
|
+
- Production domain for OAuth redirect URIs
|
|
77
|
+
|
|
78
|
+
### 3. File Generation (`src/generators/`)
|
|
79
|
+
|
|
80
|
+
#### API Client Generator (`api-client-generator.js`)
|
|
81
|
+
- ✅ Generates typed API client (`lib/api-client.ts` or `lib/api-client.js`)
|
|
82
|
+
- ✅ Supports TypeScript and JavaScript
|
|
83
|
+
- ✅ Includes methods for:
|
|
84
|
+
- CRM (getContacts, getContact, createContact, updateContact, deleteContact)
|
|
85
|
+
- Projects (getProjects, getProject, createProject, updateProject, deleteProject)
|
|
86
|
+
- Invoices (getInvoices, getInvoice, createInvoice, updateInvoice, deleteInvoice)
|
|
87
|
+
- ✅ Uses native fetch API (Next.js compatible)
|
|
88
|
+
- ✅ Includes organization ID in headers
|
|
89
|
+
- ✅ Proper error handling
|
|
90
|
+
|
|
91
|
+
#### Environment File Generator (`env-generator.js`)
|
|
92
|
+
- ✅ Generates/updates `.env.local` file
|
|
93
|
+
- ✅ Preserves existing environment variables
|
|
94
|
+
- ✅ Adds L4YERCAK3 configuration:
|
|
95
|
+
- API key
|
|
96
|
+
- Backend URL
|
|
97
|
+
- Organization ID
|
|
98
|
+
- ✅ Adds OAuth variables (if OAuth enabled)
|
|
99
|
+
- ✅ Adds Stripe variables (if Stripe enabled)
|
|
100
|
+
- ✅ Proper formatting and comments
|
|
101
|
+
|
|
102
|
+
#### NextAuth.js Generator (`nextauth-generator.js`)
|
|
103
|
+
- ✅ Generates NextAuth.js configuration
|
|
104
|
+
- ✅ Supports App Router and Pages Router
|
|
105
|
+
- ✅ Supports TypeScript and JavaScript
|
|
106
|
+
- ✅ Configures selected OAuth providers:
|
|
107
|
+
- Google
|
|
108
|
+
- Microsoft (Azure AD)
|
|
109
|
+
- GitHub
|
|
110
|
+
- ✅ Includes user sync callback to L4YERCAK3 backend
|
|
111
|
+
- ✅ Proper session handling
|
|
112
|
+
|
|
113
|
+
#### OAuth Setup Guide Generator (`oauth-guide-generator.js`)
|
|
114
|
+
- ✅ Generates comprehensive OAuth setup guide (`OAUTH_SETUP_GUIDE.md`)
|
|
115
|
+
- ✅ Step-by-step instructions for each provider
|
|
116
|
+
- ✅ Includes redirect URI configuration
|
|
117
|
+
- ✅ Troubleshooting section
|
|
118
|
+
- ✅ Customized based on selected providers
|
|
119
|
+
|
|
120
|
+
#### Main Generator (`index.js`)
|
|
121
|
+
- ✅ Orchestrates all generators
|
|
122
|
+
- ✅ Returns paths to generated files
|
|
123
|
+
|
|
124
|
+
### 4. Dependencies
|
|
125
|
+
|
|
126
|
+
Added to `package.json`:
|
|
127
|
+
- ✅ `inquirer@^8.2.6` - Interactive command-line prompts
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## File Structure
|
|
132
|
+
|
|
133
|
+
```
|
|
134
|
+
l4yercak3-cli/
|
|
135
|
+
├── src/
|
|
136
|
+
│ ├── detectors/
|
|
137
|
+
│ │ ├── nextjs-detector.js ✅ NEW
|
|
138
|
+
│ │ ├── github-detector.js ✅ NEW
|
|
139
|
+
│ │ ├── api-client-detector.js ✅ NEW
|
|
140
|
+
│ │ └── index.js ✅ NEW
|
|
141
|
+
│ ├── generators/
|
|
142
|
+
│ │ ├── api-client-generator.js ✅ NEW
|
|
143
|
+
│ │ ├── env-generator.js ✅ NEW
|
|
144
|
+
│ │ ├── nextauth-generator.js ✅ NEW
|
|
145
|
+
│ │ ├── oauth-guide-generator.js ✅ NEW
|
|
146
|
+
│ │ └── index.js ✅ NEW
|
|
147
|
+
│ ├── commands/
|
|
148
|
+
│ │ └── spread.js ✅ UPDATED
|
|
149
|
+
│ ├── api/
|
|
150
|
+
│ │ └── backend-client.js (existing)
|
|
151
|
+
│ └── config/
|
|
152
|
+
│ └── config-manager.js (existing)
|
|
153
|
+
└── package.json ✅ UPDATED
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## Usage
|
|
159
|
+
|
|
160
|
+
### Basic Usage
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
# Make sure you're logged in first
|
|
164
|
+
l4yercak3 login
|
|
165
|
+
|
|
166
|
+
# Run the setup wizard
|
|
167
|
+
l4yercak3 spread
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### What Happens
|
|
171
|
+
|
|
172
|
+
1. **Project Detection**
|
|
173
|
+
- CLI detects Next.js project, GitHub repo, existing API clients
|
|
174
|
+
|
|
175
|
+
2. **Organization Setup**
|
|
176
|
+
- Lists existing organizations or creates new one
|
|
177
|
+
- Generates API key
|
|
178
|
+
|
|
179
|
+
3. **Feature Selection**
|
|
180
|
+
- Interactive prompts for features and OAuth providers
|
|
181
|
+
|
|
182
|
+
4. **File Generation**
|
|
183
|
+
- Generates API client
|
|
184
|
+
- Updates `.env.local`
|
|
185
|
+
- Generates NextAuth.js config (if OAuth enabled)
|
|
186
|
+
- Generates OAuth setup guide (if OAuth enabled)
|
|
187
|
+
|
|
188
|
+
5. **Next Steps**
|
|
189
|
+
- CLI provides instructions for completing OAuth setup
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## Generated Files
|
|
194
|
+
|
|
195
|
+
### API Client
|
|
196
|
+
- **Location:** `lib/api-client.ts` or `lib/api-client.js` (or `src/lib/` if `src/` exists)
|
|
197
|
+
- **Features:** Typed methods for CRM, Projects, Invoices
|
|
198
|
+
- **Usage:** Import and use in your Next.js app
|
|
199
|
+
|
|
200
|
+
### Environment File
|
|
201
|
+
- **Location:** `.env.local`
|
|
202
|
+
- **Contains:** API keys, backend URL, OAuth credentials (if enabled), Stripe keys (if enabled)
|
|
203
|
+
- **Note:** Already in `.gitignore` - never commit this file!
|
|
204
|
+
|
|
205
|
+
### NextAuth.js Configuration
|
|
206
|
+
- **Location:**
|
|
207
|
+
- App Router: `app/api/auth/[...nextauth]/route.ts`
|
|
208
|
+
- Pages Router: `pages/api/auth/[...nextauth].ts`
|
|
209
|
+
- **Features:** OAuth providers, user sync to backend
|
|
210
|
+
|
|
211
|
+
### OAuth Setup Guide
|
|
212
|
+
- **Location:** `OAUTH_SETUP_GUIDE.md`
|
|
213
|
+
- **Contains:** Step-by-step instructions for setting up OAuth with each provider
|
|
214
|
+
|
|
215
|
+
---
|
|
216
|
+
|
|
217
|
+
## API Integration
|
|
218
|
+
|
|
219
|
+
The CLI integrates with the following backend endpoints:
|
|
220
|
+
|
|
221
|
+
### Organization Management
|
|
222
|
+
- `GET /api/v1/organizations` - List organizations
|
|
223
|
+
- `POST /api/v1/organizations` - Create organization
|
|
224
|
+
|
|
225
|
+
### API Key Generation
|
|
226
|
+
- `POST /api/v1/api-keys/generate` - Generate API key
|
|
227
|
+
- Body: `{ organizationId, name, scopes }`
|
|
228
|
+
- Response: `{ key, keyPrefix, ... }`
|
|
229
|
+
|
|
230
|
+
### Authentication
|
|
231
|
+
- Uses existing CLI session from `l4yercak3 login`
|
|
232
|
+
- All API calls include `Authorization: Bearer <session_token>`
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
## Error Handling
|
|
237
|
+
|
|
238
|
+
The CLI includes robust error handling:
|
|
239
|
+
|
|
240
|
+
- ✅ Network errors with clear messages
|
|
241
|
+
- ✅ API response format variations handled
|
|
242
|
+
- ✅ Missing required fields detected
|
|
243
|
+
- ✅ User-friendly error messages
|
|
244
|
+
- ✅ Graceful exit on errors
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
## Testing Checklist
|
|
249
|
+
|
|
250
|
+
### Manual Testing
|
|
251
|
+
- [ ] Run `l4yercak3 spread` in a Next.js project
|
|
252
|
+
- [ ] Verify project detection works
|
|
253
|
+
- [ ] Test organization creation
|
|
254
|
+
- [ ] Test organization selection
|
|
255
|
+
- [ ] Verify API key generation
|
|
256
|
+
- [ ] Test feature selection
|
|
257
|
+
- [ ] Verify file generation
|
|
258
|
+
- [ ] Check generated API client works
|
|
259
|
+
- [ ] Verify `.env.local` is correct
|
|
260
|
+
- [ ] Test NextAuth.js config (if OAuth enabled)
|
|
261
|
+
- [ ] Verify OAuth guide is complete
|
|
262
|
+
|
|
263
|
+
### Edge Cases
|
|
264
|
+
- [ ] Non-Next.js project (should warn but allow)
|
|
265
|
+
- [ ] No GitHub repo (should work fine)
|
|
266
|
+
- [ ] Existing API client (should detect)
|
|
267
|
+
- [ ] Existing `.env.local` (should preserve existing vars)
|
|
268
|
+
- [ ] No organizations (should create one)
|
|
269
|
+
- [ ] Multiple organizations (should allow selection)
|
|
270
|
+
|
|
271
|
+
---
|
|
272
|
+
|
|
273
|
+
## Known Limitations
|
|
274
|
+
|
|
275
|
+
1. **API Response Formats**
|
|
276
|
+
- CLI handles common response formats but may need adjustment based on actual backend responses
|
|
277
|
+
- Organization ID extraction tries multiple field names
|
|
278
|
+
- API key extraction tries multiple field names
|
|
279
|
+
|
|
280
|
+
2. **NextAuth.js Dependencies**
|
|
281
|
+
- CLI doesn't automatically install NextAuth.js dependencies
|
|
282
|
+
- User must run: `npm install next-auth`
|
|
283
|
+
- Azure AD provider requires: `npm install next-auth/providers/azure-ad`
|
|
284
|
+
|
|
285
|
+
3. **TypeScript Types**
|
|
286
|
+
- Generated API client uses `any` types for TypeScript
|
|
287
|
+
- Future: Generate proper types from backend schema
|
|
288
|
+
|
|
289
|
+
4. **OAuth Setup**
|
|
290
|
+
- Manual setup required (no automation)
|
|
291
|
+
- User must follow guide and add credentials to `.env.local`
|
|
292
|
+
|
|
293
|
+
---
|
|
294
|
+
|
|
295
|
+
## Next Steps (Phase 2)
|
|
296
|
+
|
|
297
|
+
Phase 2 will focus on:
|
|
298
|
+
|
|
299
|
+
1. **OAuth Automation** (if possible)
|
|
300
|
+
- Research provider APIs for programmatic app creation
|
|
301
|
+
- Automate OAuth app setup where possible
|
|
302
|
+
|
|
303
|
+
2. **Sign-in Page Generation**
|
|
304
|
+
- Generate sign-in page component
|
|
305
|
+
- Generate session provider wrapper
|
|
306
|
+
- Generate protected route middleware
|
|
307
|
+
|
|
308
|
+
3. **TypeScript Types**
|
|
309
|
+
- Generate proper types from backend schema
|
|
310
|
+
- Improve API client type safety
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
## Notes
|
|
315
|
+
|
|
316
|
+
- All code follows existing project patterns
|
|
317
|
+
- Error messages are user-friendly
|
|
318
|
+
- Code is well-commented
|
|
319
|
+
- No linter errors
|
|
320
|
+
- All files compile successfully
|
|
321
|
+
|
|
322
|
+
---
|
|
323
|
+
|
|
324
|
+
---
|
|
325
|
+
|
|
326
|
+
## Current Status
|
|
327
|
+
|
|
328
|
+
### ✅ What's Implemented
|
|
329
|
+
|
|
330
|
+
#### 1.1 Project Detection ✅ COMPLETE
|
|
331
|
+
- ✅ Next.js detector (with extensible architecture)
|
|
332
|
+
- ✅ GitHub detector (framework-agnostic)
|
|
333
|
+
- ✅ API client detector (framework-agnostic)
|
|
334
|
+
- ✅ **OAuth detector** (detects NextAuth.js setup) ✅ NEW
|
|
335
|
+
- ✅ Detector registry system (supports multiple project types)
|
|
336
|
+
|
|
337
|
+
#### 1.2 Configuration Wizard ✅ COMPLETE
|
|
338
|
+
- ✅ Check if user is logged in
|
|
339
|
+
- ✅ Interactive prompts (organization, features, OAuth providers, backend URL)
|
|
340
|
+
- ✅ **Save configuration to `.l4yercak3/config.json`** ✅ NEW
|
|
341
|
+
- ✅ Project config storage (tracks setup per project)
|
|
342
|
+
|
|
343
|
+
#### 1.3 File Generation ✅ COMPLETE
|
|
344
|
+
- ✅ API client generator (`lib/api-client.ts` or `.js`)
|
|
345
|
+
- ✅ Environment file generator (`.env.local`)
|
|
346
|
+
- ✅ NextAuth.js generator (if OAuth enabled)
|
|
347
|
+
- ✅ OAuth setup guide generator
|
|
348
|
+
- ✅ **Gitignore updater** (ensures sensitive files aren't committed) ✅ NEW
|
|
349
|
+
|
|
350
|
+
#### 1.4 Basic Testing
|
|
351
|
+
- [ ] Test with actual projects (`l4yercak3-landing`, `freelancer-client-portal`)
|
|
352
|
+
- [ ] Verify API client works
|
|
353
|
+
- [ ] Verify environment variables are correct
|
|
354
|
+
|
|
355
|
+
### 🎯 Ready for Testing
|
|
356
|
+
All Phase 1 CLI tasks are complete! Ready for user testing.
|
|
357
|
+
|
|
358
|
+
### 📝 Notes
|
|
359
|
+
- Detector system was recently refactored to support multiple project types
|
|
360
|
+
- Some code may still reference old detector interface
|
|
361
|
+
- Need to verify everything works end-to-end
|
|
362
|
+
|
|
363
|
+
---
|
|
364
|
+
|
|
365
|
+
**Status:** ✅ Phase 1 CLI Tasks Complete
|
|
366
|
+
**Next:** User testing with real projects
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# Implementation Phase Summary
|
|
2
|
+
|
|
3
|
+
## Quick Overview
|
|
4
|
+
|
|
5
|
+
**What CLI Does:** Sets up boilerplate and connects it to backend API
|
|
6
|
+
**What Backend Provides:** APIs for account management, Stripe, OAuth, CRM, etc.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Phase Breakdown
|
|
11
|
+
|
|
12
|
+
### Phase 0: Foundation 🏗️ (Week 1-2)
|
|
13
|
+
|
|
14
|
+
**Backend Must Build:**
|
|
15
|
+
- ✅ Account creation endpoint (`POST /api/v1/auth/create-account`)
|
|
16
|
+
- ✅ API key generation endpoint (`POST /api/v1/api-keys/generate`)
|
|
17
|
+
- ✅ Sub-organization creation endpoint (`POST /api/v1/organizations/create-sub`) - for agencies
|
|
18
|
+
|
|
19
|
+
**CLI Must Build:**
|
|
20
|
+
- ✅ Project structure (commands, generators, detectors)
|
|
21
|
+
- ✅ Backend API client
|
|
22
|
+
|
|
23
|
+
**Dependencies:** None - foundation for everything else
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
### Phase 1: Core Integration 🎯 (Week 2-3)
|
|
28
|
+
|
|
29
|
+
**Backend Must Build:**
|
|
30
|
+
- ✅ Stripe API wrappers (wrap existing functions)
|
|
31
|
+
- `POST /api/v1/stripe/start-onboarding`
|
|
32
|
+
- `GET /api/v1/stripe/status`
|
|
33
|
+
- `GET /api/v1/stripe/keys`
|
|
34
|
+
|
|
35
|
+
**CLI Must Build:**
|
|
36
|
+
- ✅ Project detection (Next.js, GitHub, etc.)
|
|
37
|
+
- ✅ Configuration wizard
|
|
38
|
+
- ✅ API client generation
|
|
39
|
+
- ✅ Environment file generation
|
|
40
|
+
|
|
41
|
+
**Dependencies:** Phase 0 complete
|
|
42
|
+
|
|
43
|
+
**Outcome:** CLI can generate boilerplate that connects to backend
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
### Phase 2: Authentication & OAuth 🚀 (Week 3-4)
|
|
48
|
+
|
|
49
|
+
**Backend Must Build:**
|
|
50
|
+
- 🟡 OAuth app creation APIs (if provider APIs support it)
|
|
51
|
+
- OR: Manual setup guide (if automation not possible)
|
|
52
|
+
|
|
53
|
+
**CLI Must Build:**
|
|
54
|
+
- ✅ OAuth setup (automated or manual)
|
|
55
|
+
- ✅ NextAuth.js configuration generation
|
|
56
|
+
- ✅ Sign-in page generation
|
|
57
|
+
|
|
58
|
+
**Dependencies:** Phase 1 complete
|
|
59
|
+
|
|
60
|
+
**Outcome:** Frontend users can authenticate, linked to CRM contacts
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
### Phase 3: Stripe Integration 💳 (Week 4-5)
|
|
65
|
+
|
|
66
|
+
**Backend Must Build:**
|
|
67
|
+
- ✅ Stripe webhook forwarding (`POST /api/v1/stripe/webhooks/forward`)
|
|
68
|
+
|
|
69
|
+
**CLI Must Build:**
|
|
70
|
+
- ✅ Stripe onboarding page generation (customer-facing)
|
|
71
|
+
- ✅ Webhook handler generation
|
|
72
|
+
- ✅ Stripe environment setup
|
|
73
|
+
|
|
74
|
+
**Dependencies:** Phase 1 complete (Stripe APIs)
|
|
75
|
+
|
|
76
|
+
**Outcome:** Sub-Organization/Organization can connect Stripe, webhooks work
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
### Phase 4: Advanced Features ✨ (Week 6+)
|
|
81
|
+
|
|
82
|
+
**Backend Must Build:**
|
|
83
|
+
- 🟢 Publishing ontology APIs
|
|
84
|
+
- 🟢 Schema endpoint (for TypeScript types)
|
|
85
|
+
|
|
86
|
+
**CLI Must Build:**
|
|
87
|
+
- 🟢 TypeScript types generation
|
|
88
|
+
- 🟢 Project templates
|
|
89
|
+
- 🟢 Advanced automation
|
|
90
|
+
|
|
91
|
+
**Dependencies:** Phases 1-3 complete
|
|
92
|
+
|
|
93
|
+
**Outcome:** Polish and advanced features
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## Critical Backend Endpoints Needed
|
|
98
|
+
|
|
99
|
+
### Must Have (Phase 0-1)
|
|
100
|
+
1. ✅ **CLI Authentication** - Browser OAuth flow (`GET /auth/cli-login`, `GET /auth/cli/callback`)
|
|
101
|
+
2. ✅ **Session Management** - Validate/refresh CLI sessions (`GET /auth/cli/validate`, `POST /auth/cli/refresh`)
|
|
102
|
+
3. ✅ `generateApiKey` action exists - Call directly with authenticated session (`convex/actions/apiKeys.ts`)
|
|
103
|
+
4. ⚠️ `POST /api/v1/organizations/create-sub` - Create sub-org (SKIP for MVP - feature not implemented yet)
|
|
104
|
+
5. `POST /api/v1/stripe/start-onboarding` - Wrap `getStripeOnboardingUrl` action
|
|
105
|
+
6. ✅ `getStripeConnectStatus` query exists - Call directly with authenticated session
|
|
106
|
+
7. `GET /api/v1/stripe/keys` - Get Stripe publishable key (may need to create)
|
|
107
|
+
8. `POST /api/v1/stripe/webhooks/forward` - Forward webhooks from frontend
|
|
108
|
+
|
|
109
|
+
### Nice to Have (Phase 2-4)
|
|
110
|
+
8. `GET /api/v1/schema` - API schema for TypeScript types
|
|
111
|
+
9. OAuth app creation APIs (if provider APIs support it)
|
|
112
|
+
10. Publishing ontology APIs
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## Questions for Backend Team ✅ ALL ANSWERED
|
|
117
|
+
|
|
118
|
+
### Phase 0 Questions ✅ ANSWERED
|
|
119
|
+
1. ✅ **Sub-Organization Creation:** Still being built - Skip for MVP, add when feature is ready
|
|
120
|
+
2. ✅ **API Key Generation:** Already exists! `convex/actions/apiKeys.ts:generateApiKey` - Call directly with authenticated session
|
|
121
|
+
3. ✅ **Account Creation:** CLI requires login first (like GitHub CLI) - User authenticates via browser OAuth, then CLI can create orgs/API keys
|
|
122
|
+
4. ✅ **CLI Authentication:** Follow GitHub CLI pattern - `l4yercak3 login` opens browser OAuth, stores session token
|
|
123
|
+
|
|
124
|
+
### Phase 1 Questions ✅ ANSWERED
|
|
125
|
+
4. ✅ **Stripe APIs:** Can wrap existing:
|
|
126
|
+
- `getStripeOnboardingUrl` action (requires sessionId)
|
|
127
|
+
- `getStripeConnectStatus` query ✅ (already exists)
|
|
128
|
+
5. **Schema Endpoint:** Do we want to implement this now or later? (Still open)
|
|
129
|
+
|
|
130
|
+
### Phase 2 Questions ✅ ANSWERED
|
|
131
|
+
6. ✅ **OAuth Automation:** Manual setup approach:
|
|
132
|
+
- Generate step-by-step guide with todo list
|
|
133
|
+
- Generate example `.env.local` file
|
|
134
|
+
- Include links to provider setup pages
|
|
135
|
+
- User completes manually, fills in env vars
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## Next Steps
|
|
140
|
+
|
|
141
|
+
1. **Backend Team:** Review Phase 0-1 endpoints, confirm what exists vs what needs to be built
|
|
142
|
+
2. **CLI Team:** Start Phase 0 CLI tasks (project structure, backend API client)
|
|
143
|
+
3. **Both Teams:** Coordinate on API contracts and testing
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
**See:** `IMPLEMENTATION_PHASES.md` for detailed breakdown
|
|
148
|
+
**See:** `ARCHITECTURE_RELATIONSHIPS.md` for organization hierarchy
|
|
149
|
+
|