@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,468 @@
|
|
|
1
|
+
# Implementation Phases - Backend & CLI Breakdown
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
This document breaks down the implementation into clear phases, separating **Backend tasks** from **CLI tasks**, and identifying dependencies between them.
|
|
6
|
+
|
|
7
|
+
**Key Principle:** CLI sets up boilerplate and connects it to backend. Backend provides APIs that CLI needs.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Phase 0: Foundation & Backend Prerequisites 🏗️
|
|
12
|
+
|
|
13
|
+
**Goal:** Set up backend APIs that CLI needs to function
|
|
14
|
+
|
|
15
|
+
### Backend Tasks
|
|
16
|
+
|
|
17
|
+
#### 0.1 CLI Authentication Flow (Like GitHub CLI)
|
|
18
|
+
- [ ] **CLI Login Command** (Browser-based OAuth)
|
|
19
|
+
- User runs: `l4yercak3 login`
|
|
20
|
+
- Opens browser for OAuth flow (similar to `gh auth login`)
|
|
21
|
+
- User authenticates with platform (Google/Microsoft/GitHub)
|
|
22
|
+
- Returns session token stored locally (`~/.l4yercak3/config.json` or similar)
|
|
23
|
+
- **Security:** Requires 2FA if enabled on account
|
|
24
|
+
- **Pattern:** Follow GitHub CLI authentication pattern
|
|
25
|
+
- **Dependency:** Backend OAuth endpoints (for platform login, not frontend OAuth)
|
|
26
|
+
- **Priority:** 🔴 HIGH (foundation for everything else)
|
|
27
|
+
|
|
28
|
+
- [ ] **CLI Session Management**
|
|
29
|
+
- Store session token securely
|
|
30
|
+
- Refresh tokens when expired
|
|
31
|
+
- Validate session before API calls
|
|
32
|
+
- **Dependency:** CLI login
|
|
33
|
+
- **Priority:** 🔴 HIGH
|
|
34
|
+
|
|
35
|
+
- [ ] **Create Organization** (After authentication)
|
|
36
|
+
- `POST /api/v1/organizations/create` (or use existing endpoint)
|
|
37
|
+
- Requires authenticated session
|
|
38
|
+
- Creates organization for logged-in user
|
|
39
|
+
- Returns: `{ organizationId, apiKey }`
|
|
40
|
+
- **Note:** User must be logged in first (via CLI login)
|
|
41
|
+
- **Dependency:** CLI authentication
|
|
42
|
+
- **Priority:** 🔴 HIGH
|
|
43
|
+
|
|
44
|
+
- [ ] **Create Sub-Organization Endpoint** (for agencies) ⚠️ FUTURE FEATURE
|
|
45
|
+
- `POST /api/v1/organizations/create-sub`
|
|
46
|
+
- Creates sub-organization under agency
|
|
47
|
+
- Returns: `{ subOrganizationId, apiKey }`
|
|
48
|
+
- **Status:** Sub-org feature not yet implemented (see `vc83-com/.kiro/sub_org_feature/`)
|
|
49
|
+
- **Dependency:** Sub-org feature implementation
|
|
50
|
+
- **Priority:** 🟢 LOW (can skip for MVP, add when sub-org feature is ready)
|
|
51
|
+
|
|
52
|
+
- [ ] **Detect Organization Type**
|
|
53
|
+
- `GET /api/v1/organizations/type`
|
|
54
|
+
- Returns: `{ type: "agency" | "regular", canCreateSubOrgs: boolean }`
|
|
55
|
+
- **Dependency:** None
|
|
56
|
+
- **Priority:** 🟡 MEDIUM
|
|
57
|
+
|
|
58
|
+
#### 0.2 API Key Management ✅ ALREADY EXISTS
|
|
59
|
+
- [x] **Generate API Key Action** - `convex/actions/apiKeys.ts:generateApiKey`
|
|
60
|
+
- Already implemented! ✅
|
|
61
|
+
- Action: `generateApiKey({ sessionId, organizationId, name, scopes, type })`
|
|
62
|
+
- Returns: `{ id, key, keyPrefix, name, scopes, createdAt, warning }`
|
|
63
|
+
- **Note:** Requires sessionId - CLI will have session from login
|
|
64
|
+
- **CLI Task:** Call Convex action directly using authenticated session
|
|
65
|
+
- **Priority:** 🔴 HIGH (but already exists!)
|
|
66
|
+
|
|
67
|
+
- [ ] **List API Keys**
|
|
68
|
+
- `GET /api/v1/api-keys`
|
|
69
|
+
- Returns list of organization's API keys
|
|
70
|
+
- **Dependency:** None
|
|
71
|
+
- **Priority:** 🟢 LOW
|
|
72
|
+
|
|
73
|
+
#### 0.3 Schema Endpoint
|
|
74
|
+
- [ ] **API Schema Endpoint**
|
|
75
|
+
- `GET /api/v1/schema`
|
|
76
|
+
- Returns API structure/types (OpenAPI or JSON Schema format)
|
|
77
|
+
- Read-only, requires authentication
|
|
78
|
+
- **Dependency:** None
|
|
79
|
+
- **Priority:** 🟡 MEDIUM (needed for TypeScript type generation)
|
|
80
|
+
|
|
81
|
+
### CLI Tasks
|
|
82
|
+
|
|
83
|
+
#### 0.1 Project Structure Setup
|
|
84
|
+
- [ ] Create command structure (`src/commands/`)
|
|
85
|
+
- [ ] Create generator structure (`src/generators/`)
|
|
86
|
+
- [ ] Create detector structure (`src/detectors/`)
|
|
87
|
+
- [ ] Create config manager (`src/config/`)
|
|
88
|
+
- [ ] Create backend API client (`src/api/backend-client.js`)
|
|
89
|
+
- [ ] **Dependency:** None
|
|
90
|
+
- **Priority:** 🔴 HIGH
|
|
91
|
+
|
|
92
|
+
#### 0.2 Backend API Client
|
|
93
|
+
- [ ] Implement backend API client class
|
|
94
|
+
- [ ] Handle authentication (API key, session tokens)
|
|
95
|
+
- [ ] Error handling and retries
|
|
96
|
+
- [ ] **Dependency:** Backend endpoints (0.1, 0.2)
|
|
97
|
+
- **Priority:** 🔴 HIGH
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## Phase 1: Core Integration (MVP) 🎯
|
|
102
|
+
|
|
103
|
+
**Goal:** Basic CLI that can set up boilerplate and connect to backend
|
|
104
|
+
|
|
105
|
+
### Backend Tasks
|
|
106
|
+
|
|
107
|
+
#### 1.1 Stripe Integration APIs (Wrap Existing Functions) ✅ MOSTLY EXISTS
|
|
108
|
+
- [ ] **Start Stripe Onboarding API** (Wrap existing)
|
|
109
|
+
- Wrap existing `convex/stripeConnect.ts:getStripeOnboardingUrl` action
|
|
110
|
+
- `POST /api/v1/stripe/start-onboarding`
|
|
111
|
+
- **Note:** Requires `sessionId` - CLI will need to handle sessions
|
|
112
|
+
- **Dependency:** Stripe Connect already exists ✅
|
|
113
|
+
- **Priority:** 🟡 MEDIUM
|
|
114
|
+
|
|
115
|
+
- [x] **Get Stripe Status Query** - `convex/stripeConnect.ts:getStripeConnectStatus` ✅
|
|
116
|
+
- Already implemented! ✅
|
|
117
|
+
- Query: `getStripeConnectStatus({ organizationId })`
|
|
118
|
+
- Returns account status, onboarding status, etc.
|
|
119
|
+
- **CLI Task:** Wrap in API endpoint OR call Convex query directly
|
|
120
|
+
- **Priority:** 🟡 MEDIUM
|
|
121
|
+
|
|
122
|
+
- [ ] **Get Stripe Keys API**
|
|
123
|
+
- `GET /api/v1/stripe/keys`
|
|
124
|
+
- Returns organization's Stripe publishable key
|
|
125
|
+
- **Dependency:** Stripe Connect already exists ✅
|
|
126
|
+
- **Priority:** 🟡 MEDIUM
|
|
127
|
+
|
|
128
|
+
#### 1.2 OAuth User Sync (Already Exists ✅)
|
|
129
|
+
- [x] `POST /api/v1/auth/sync-user` - Already implemented
|
|
130
|
+
- [x] `GET /api/v1/auth/user` - Already implemented
|
|
131
|
+
- [x] `POST /api/v1/auth/validate-token` - Already implemented
|
|
132
|
+
|
|
133
|
+
### CLI Tasks
|
|
134
|
+
|
|
135
|
+
#### 1.1 Project Detection ✅ COMPLETE
|
|
136
|
+
- [x] Detect Next.js projects
|
|
137
|
+
- Check for `next.config.*`, `package.json`
|
|
138
|
+
- Detect App Router vs Pages Router
|
|
139
|
+
- [x] Detect GitHub repository (from git remote)
|
|
140
|
+
- [x] Detect existing API client patterns
|
|
141
|
+
- [x] Detect existing OAuth setup ✅ NEW
|
|
142
|
+
- [ ] **Dependency:** None
|
|
143
|
+
- **Priority:** 🔴 HIGH
|
|
144
|
+
|
|
145
|
+
#### 1.2 Configuration Wizard ✅ COMPLETE
|
|
146
|
+
- [x] Check if user is logged in (check for session token)
|
|
147
|
+
- If not logged in: Prompt `l4yercak3 login` first
|
|
148
|
+
- If logged in: Continue with setup
|
|
149
|
+
- [x] Interactive prompts:
|
|
150
|
+
- Organization type (agency vs regular) - Note: Agency sub-orgs not yet implemented
|
|
151
|
+
- Create new organization or use existing?
|
|
152
|
+
- Sub-organization creation (if agency) - ⚠️ Future feature
|
|
153
|
+
- Backend API URL (auto-detect if possible)
|
|
154
|
+
- Features to enable (CRM, Projects, Invoices, OAuth, Stripe)
|
|
155
|
+
- [x] Save configuration to `.l4yercak3/config.json` ✅ NEW
|
|
156
|
+
- [ ] **Dependency:** CLI authentication (Phase 0)
|
|
157
|
+
- **Priority:** 🔴 HIGH
|
|
158
|
+
|
|
159
|
+
#### 1.3 File Generation ✅ COMPLETE
|
|
160
|
+
- [x] Generate API client (`lib/api-client.ts`)
|
|
161
|
+
- Scoped to Organization (Sub-Organization support deferred)
|
|
162
|
+
- Uses organization's API key
|
|
163
|
+
- Typed functions for CRM, Projects, Invoices
|
|
164
|
+
- [x] Generate environment file (`.env.local`)
|
|
165
|
+
- Pre-fill with detected values
|
|
166
|
+
- Include all required variables
|
|
167
|
+
- [x] Generate `.gitignore` updates (if needed) ✅ NEW
|
|
168
|
+
- [ ] **Dependency:** Backend API client (Phase 0)
|
|
169
|
+
- **Priority:** 🔴 HIGH
|
|
170
|
+
|
|
171
|
+
#### 1.4 Basic Testing
|
|
172
|
+
- [ ] Test with example projects
|
|
173
|
+
- `l4yercak3-landing`
|
|
174
|
+
- `freelancer-client-portal`
|
|
175
|
+
- [ ] Verify API client works
|
|
176
|
+
- [ ] Verify environment variables are correct
|
|
177
|
+
- [ ] **Dependency:** All Phase 1 tasks
|
|
178
|
+
- **Priority:** 🔴 HIGH
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## Phase 2: Authentication & OAuth 🚀
|
|
183
|
+
|
|
184
|
+
**Goal:** Automate OAuth setup for frontend authentication
|
|
185
|
+
|
|
186
|
+
### Backend Tasks
|
|
187
|
+
|
|
188
|
+
#### 2.1 OAuth App Creation APIs (If Possible)
|
|
189
|
+
- [ ] Research provider APIs:
|
|
190
|
+
- Google Cloud API for OAuth app creation
|
|
191
|
+
- Microsoft Graph API for OAuth app creation
|
|
192
|
+
- GitHub API for OAuth app creation
|
|
193
|
+
- [ ] **Decision Point:** Can we automate this?
|
|
194
|
+
- If yes: Create backend endpoints to proxy provider APIs
|
|
195
|
+
- If no: CLI guides user through manual setup
|
|
196
|
+
- [ ] **Dependency:** Provider API research
|
|
197
|
+
- **Priority:** 🟡 MEDIUM (can guide manually if needed)
|
|
198
|
+
|
|
199
|
+
### CLI Tasks
|
|
200
|
+
|
|
201
|
+
#### 2.1 OAuth Setup (Manual Guide Approach) ✅ DECISION MADE
|
|
202
|
+
- [ ] Detect OAuth providers needed (Google, Microsoft, GitHub)
|
|
203
|
+
- [ ] **Generate OAuth Setup Guide** (Manual approach - no automation)
|
|
204
|
+
- Create step-by-step todo list
|
|
205
|
+
- Generate example `.env.local` file with placeholders
|
|
206
|
+
- Include links to provider setup pages:
|
|
207
|
+
- Google Cloud Console
|
|
208
|
+
- Microsoft Azure Portal
|
|
209
|
+
- GitHub Developer Settings
|
|
210
|
+
- Include correct redirect URLs (production + development)
|
|
211
|
+
- Generate markdown guide file: `OAUTH_SETUP_GUIDE.md`
|
|
212
|
+
- **Template:** See `docs/OAUTH_SETUP_GUIDE_TEMPLATE.md`
|
|
213
|
+
- [ ] Generate NextAuth.js configuration
|
|
214
|
+
- `app/api/auth/[...nextauth]/route.ts`
|
|
215
|
+
- Configure providers (with placeholder env vars)
|
|
216
|
+
- Set up sync-user callback
|
|
217
|
+
- [ ] Generate sign-in page (`app/auth/signin/page.tsx`)
|
|
218
|
+
- [ ] **Note:** User will manually complete OAuth app setup, then fill in `.env.local`
|
|
219
|
+
- [ ] **Future:** Video tutorial (user will create)
|
|
220
|
+
- [ ] **Dependency:** None (manual setup)
|
|
221
|
+
- **Priority:** 🟡 MEDIUM
|
|
222
|
+
|
|
223
|
+
#### 2.2 Authentication Code Generation
|
|
224
|
+
- [ ] Generate session provider wrapper
|
|
225
|
+
- [ ] Generate protected route middleware
|
|
226
|
+
- [ ] Generate auth utilities
|
|
227
|
+
- [ ] **Dependency:** OAuth setup (2.1)
|
|
228
|
+
- **Priority:** 🟡 MEDIUM
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
## Phase 3: Stripe Integration 💳
|
|
233
|
+
|
|
234
|
+
**Goal:** Automate Stripe Connect setup and webhook configuration
|
|
235
|
+
|
|
236
|
+
### Backend Tasks
|
|
237
|
+
|
|
238
|
+
#### 3.1 Stripe API Endpoints (Wrap Existing Functions)
|
|
239
|
+
- [ ] **Start Onboarding API**
|
|
240
|
+
- Wrap existing `getStripeOnboardingUrl` action
|
|
241
|
+
- `POST /api/v1/stripe/start-onboarding`
|
|
242
|
+
- **Dependency:** Stripe Connect already exists ✅
|
|
243
|
+
- **Priority:** 🟡 MEDIUM
|
|
244
|
+
|
|
245
|
+
- [ ] **Complete Onboarding Callback**
|
|
246
|
+
- Wrap existing `handleOAuthCallback` mutation
|
|
247
|
+
- `POST /api/v1/stripe/complete-onboarding`
|
|
248
|
+
- **Dependency:** Stripe Connect already exists ✅
|
|
249
|
+
- **Priority:** 🟡 MEDIUM
|
|
250
|
+
|
|
251
|
+
- [ ] **Webhook Forwarding**
|
|
252
|
+
- `POST /api/v1/stripe/webhooks/forward`
|
|
253
|
+
- Receives webhooks from frontend
|
|
254
|
+
- Forwards to existing webhook processor
|
|
255
|
+
- **Dependency:** Stripe webhooks already exist ✅
|
|
256
|
+
- **Priority:** 🟡 MEDIUM
|
|
257
|
+
|
|
258
|
+
### CLI Tasks
|
|
259
|
+
|
|
260
|
+
#### 3.1 Stripe Onboarding Page Generation
|
|
261
|
+
- [ ] Generate Stripe connect page (`app/stripe/connect/page.tsx`)
|
|
262
|
+
- Simple UI for Sub-Organization/Organization
|
|
263
|
+
- Calls backend to get onboarding URL
|
|
264
|
+
- Opens Stripe OAuth flow
|
|
265
|
+
- [ ] Generate callback handler (`app/stripe/connect/callback/page.tsx`)
|
|
266
|
+
- Handles Stripe OAuth callback
|
|
267
|
+
- Calls backend to complete onboarding
|
|
268
|
+
- Shows success/error states
|
|
269
|
+
- [ ] **Dependency:** Backend Stripe APIs (3.1)
|
|
270
|
+
- **Priority:** 🟡 MEDIUM
|
|
271
|
+
|
|
272
|
+
#### 3.2 Webhook Handler Generation
|
|
273
|
+
- [ ] Generate webhook handler (`app/api/webhooks/stripe/route.ts`)
|
|
274
|
+
- Verifies Stripe webhook signatures
|
|
275
|
+
- Forwards to backend API
|
|
276
|
+
- Handles errors gracefully
|
|
277
|
+
- [ ] **Dependency:** Backend webhook forwarding (3.1)
|
|
278
|
+
- **Priority:** 🟡 MEDIUM
|
|
279
|
+
|
|
280
|
+
#### 3.3 Stripe Environment Variables
|
|
281
|
+
- [ ] Fetch Stripe keys from backend
|
|
282
|
+
- [ ] Generate `.env.local` with Stripe variables
|
|
283
|
+
- [ ] Store webhook secrets securely
|
|
284
|
+
- [ ] **Dependency:** Backend Stripe APIs (3.1)
|
|
285
|
+
- **Priority:** 🟡 MEDIUM
|
|
286
|
+
|
|
287
|
+
---
|
|
288
|
+
|
|
289
|
+
## Phase 4: Advanced Features ✨
|
|
290
|
+
|
|
291
|
+
**Goal:** Polish and advanced automation
|
|
292
|
+
|
|
293
|
+
### Backend Tasks
|
|
294
|
+
|
|
295
|
+
#### 4.1 Publishing Ontology Integration
|
|
296
|
+
- [ ] Expose publishing ontology functions via API
|
|
297
|
+
- `GET /api/v1/publishing/env-vars` - Get deployment env vars
|
|
298
|
+
- `POST /api/v1/publishing/env-vars` - Update deployment env vars
|
|
299
|
+
- [ ] **Dependency:** Publishing ontology already exists ✅
|
|
300
|
+
- **Priority:** 🟢 LOW
|
|
301
|
+
|
|
302
|
+
#### 4.2 TypeScript Types Generation
|
|
303
|
+
- [ ] Implement schema endpoint (if not done in Phase 0)
|
|
304
|
+
- [ ] Return OpenAPI/JSON Schema format
|
|
305
|
+
- [ ] **Dependency:** None
|
|
306
|
+
- **Priority:** 🟢 LOW
|
|
307
|
+
|
|
308
|
+
### CLI Tasks
|
|
309
|
+
|
|
310
|
+
#### 4.1 Publishing Ontology Integration
|
|
311
|
+
- [ ] Use publishing ontology for env var detection
|
|
312
|
+
- [ ] Auto-detect env vars from GitHub repos
|
|
313
|
+
- [ ] Pre-fill deployment configurations
|
|
314
|
+
- [ ] **Dependency:** Backend publishing APIs (4.1)
|
|
315
|
+
- **Priority:** 🟢 LOW
|
|
316
|
+
|
|
317
|
+
#### 4.2 TypeScript Types Generation
|
|
318
|
+
- [ ] Fetch schema from backend
|
|
319
|
+
- [ ] Generate TypeScript type definitions
|
|
320
|
+
- [ ] Keep types in sync with backend
|
|
321
|
+
- [ ] **Dependency:** Backend schema endpoint (4.2)
|
|
322
|
+
- **Priority:** 🟢 LOW
|
|
323
|
+
|
|
324
|
+
#### 4.3 Project Templates
|
|
325
|
+
- [ ] Create template system
|
|
326
|
+
- [ ] Landing page template
|
|
327
|
+
- [ ] Client portal template
|
|
328
|
+
- [ ] E-commerce template
|
|
329
|
+
- [ ] **Dependency:** Core generation (Phase 1)
|
|
330
|
+
- **Priority:** 🟢 LOW
|
|
331
|
+
|
|
332
|
+
---
|
|
333
|
+
|
|
334
|
+
## Implementation Timeline
|
|
335
|
+
|
|
336
|
+
### Week 1-2: Phase 0 + Phase 1 Foundation
|
|
337
|
+
**Backend:**
|
|
338
|
+
- CLI authentication endpoints (`/auth/cli-login`, `/auth/cli/callback`)
|
|
339
|
+
- CLI session management (validate, refresh)
|
|
340
|
+
- Organization creation endpoint (for authenticated users)
|
|
341
|
+
|
|
342
|
+
**CLI:**
|
|
343
|
+
- CLI login command (`l4yercak3 login`)
|
|
344
|
+
- Browser OAuth flow
|
|
345
|
+
- Session token storage
|
|
346
|
+
- Project structure setup
|
|
347
|
+
- Backend API client (with session handling)
|
|
348
|
+
- Project detection
|
|
349
|
+
- Basic configuration wizard
|
|
350
|
+
- API client generation
|
|
351
|
+
|
|
352
|
+
### Week 3-4: Phase 1 Complete + Phase 2 Start
|
|
353
|
+
**Backend:**
|
|
354
|
+
- Stripe API wrappers (if needed)
|
|
355
|
+
- Schema endpoint (if needed)
|
|
356
|
+
|
|
357
|
+
**CLI:**
|
|
358
|
+
- Complete file generation
|
|
359
|
+
- Environment file generation
|
|
360
|
+
- OAuth setup (manual or automated)
|
|
361
|
+
- NextAuth.js configuration generation
|
|
362
|
+
|
|
363
|
+
### Week 5-6: Phase 2 Complete + Phase 3
|
|
364
|
+
**Backend:**
|
|
365
|
+
- Stripe webhook forwarding (if needed)
|
|
366
|
+
|
|
367
|
+
**CLI:**
|
|
368
|
+
- Stripe onboarding page generation
|
|
369
|
+
- Webhook handler generation
|
|
370
|
+
- Stripe environment setup
|
|
371
|
+
|
|
372
|
+
### Week 7+: Phase 4 (Polish)
|
|
373
|
+
**Backend:**
|
|
374
|
+
- Publishing ontology APIs
|
|
375
|
+
- Advanced features
|
|
376
|
+
|
|
377
|
+
**CLI:**
|
|
378
|
+
- TypeScript types generation
|
|
379
|
+
- Project templates
|
|
380
|
+
- Advanced automation
|
|
381
|
+
|
|
382
|
+
---
|
|
383
|
+
|
|
384
|
+
## Questions for Backend Team
|
|
385
|
+
|
|
386
|
+
### Immediate (Phase 0)
|
|
387
|
+
1. **Sub-Organization Creation:** Do we need a separate endpoint, or can we use existing organization creation with `parentOrganizationId`?
|
|
388
|
+
2. **API Key Generation:** Does this already exist, or do we need to create it?
|
|
389
|
+
3. **Account Creation:** Should this be a single endpoint or multiple steps?
|
|
390
|
+
|
|
391
|
+
### Phase 1
|
|
392
|
+
4. **Stripe APIs:** Can we wrap existing Stripe Connect functions, or do we need new endpoints?
|
|
393
|
+
5. **Schema Endpoint:** Do we want to implement this now or later?
|
|
394
|
+
|
|
395
|
+
### Phase 2
|
|
396
|
+
6. **OAuth Automation:** Which providers support programmatic app creation?
|
|
397
|
+
- Google Cloud API?
|
|
398
|
+
- Microsoft Graph API?
|
|
399
|
+
- GitHub API?
|
|
400
|
+
|
|
401
|
+
---
|
|
402
|
+
|
|
403
|
+
## Dependencies Map
|
|
404
|
+
|
|
405
|
+
```
|
|
406
|
+
Phase 0 (Backend)
|
|
407
|
+
├─> Account Creation → CLI needs this
|
|
408
|
+
├─> API Key Generation → CLI needs this
|
|
409
|
+
└─> Sub-Org Creation → CLI needs this (for agencies)
|
|
410
|
+
|
|
411
|
+
Phase 0 (CLI)
|
|
412
|
+
├─> Project Structure → Foundation
|
|
413
|
+
└─> Backend API Client → Needs backend endpoints
|
|
414
|
+
|
|
415
|
+
Phase 1 (CLI)
|
|
416
|
+
├─> Project Detection → Independent
|
|
417
|
+
├─> Config Wizard → Needs backend endpoints
|
|
418
|
+
└─> File Generation → Needs backend API client
|
|
419
|
+
|
|
420
|
+
Phase 2 (CLI)
|
|
421
|
+
└─> OAuth Setup → Can work manually if automation fails
|
|
422
|
+
|
|
423
|
+
Phase 3 (CLI)
|
|
424
|
+
└─> Stripe Setup → Needs backend Stripe APIs
|
|
425
|
+
|
|
426
|
+
Phase 4 (CLI)
|
|
427
|
+
└─> Advanced Features → Nice to have, not critical
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
---
|
|
431
|
+
|
|
432
|
+
## Success Criteria by Phase
|
|
433
|
+
|
|
434
|
+
### Phase 0 ✅
|
|
435
|
+
- [ ] Backend endpoints exist and are tested
|
|
436
|
+
- [ ] CLI can call backend APIs
|
|
437
|
+
- [ ] CLI project structure is set up
|
|
438
|
+
|
|
439
|
+
### Phase 1 ✅
|
|
440
|
+
- [ ] CLI detects Next.js projects
|
|
441
|
+
- [ ] CLI generates API client
|
|
442
|
+
- [ ] CLI generates environment files
|
|
443
|
+
- [ ] Generated boilerplate connects to backend
|
|
444
|
+
- [ ] Can make API calls successfully
|
|
445
|
+
|
|
446
|
+
### Phase 2 ✅
|
|
447
|
+
- [ ] OAuth setup works (manual or automated)
|
|
448
|
+
- [ ] NextAuth.js configuration generated
|
|
449
|
+
- [ ] Frontend users can authenticate
|
|
450
|
+
- [ ] Frontend users linked to CRM contacts
|
|
451
|
+
|
|
452
|
+
### Phase 3 ✅
|
|
453
|
+
- [ ] Stripe onboarding page generated
|
|
454
|
+
- [ ] Sub-Organization/Organization can connect Stripe
|
|
455
|
+
- [ ] Webhook handler generated
|
|
456
|
+
- [ ] Webhooks forward to backend successfully
|
|
457
|
+
|
|
458
|
+
### Phase 4 ✅
|
|
459
|
+
- [ ] TypeScript types generated from schema
|
|
460
|
+
- [ ] Project templates available
|
|
461
|
+
- [ ] Advanced automation working
|
|
462
|
+
|
|
463
|
+
---
|
|
464
|
+
|
|
465
|
+
**Last Updated:** 2025-01-14
|
|
466
|
+
**Status:** Ready for Implementation
|
|
467
|
+
**Next Step:** Start Phase 0 Backend tasks
|
|
468
|
+
|