@l4yercak3/cli 1.0.6 → 1.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/bin/cli.js +6 -0
- package/docs/microsass_production_machine/CLI_API_REFERENCE.md +1197 -0
- package/docs/microsass_production_machine/CLI_PRODUCT_VISION.md +676 -0
- package/docs/microsass_production_machine/CLI_REQUIREMENTS.md +606 -0
- package/docs/microsass_production_machine/CONNECTED_APPLICATIONS_SPEC.md +390 -0
- package/docs/microsass_production_machine/IMPLEMENTATION_ROADMAP.md +725 -0
- package/docs/microsass_production_machine/OBJECT_MAPPINGS.md +808 -0
- package/docs/microsass_production_machine/REFERENCE_IMPLEMENTATION.md +532 -0
- package/package.json +1 -1
- package/src/api/backend-client.js +62 -0
- package/src/commands/spread.js +128 -11
- package/src/generators/api-client-generator.js +13 -6
- package/src/generators/env-generator.js +14 -1
- package/src/generators/index.js +4 -4
- package/src/generators/nextauth-generator.js +14 -9
- package/src/utils/file-utils.js +117 -0
- package/tests/api-client-generator.test.js +20 -13
- package/tests/backend-client.test.js +167 -0
- package/tests/file-utils.test.js +194 -0
- package/tests/generators-index.test.js +8 -0
- package/tests/nextauth-generator.test.js +38 -14
|
@@ -0,0 +1,676 @@
|
|
|
1
|
+
# L4YERCAK3 CLI - Product Vision v2.0
|
|
2
|
+
|
|
3
|
+
**The Ultimate Bridge Between External Apps and L4YERCAK3 Backend**
|
|
4
|
+
|
|
5
|
+
> "Your external app is the face. L4YERCAK3 is the brain. The CLI is the spine that connects them."
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Executive Summary
|
|
10
|
+
|
|
11
|
+
The L4YERCAK3 CLI is not just a setup tool - it's an **intelligent integration platform** that analyzes external applications, understands their architecture, and creates seamless bi-directional connections to the L4YERCAK3 backend. It transforms L4YERCAK3 from a standalone platform into a **headless backend-as-a-service** that developers can plug into any frontend.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Vision Statement
|
|
16
|
+
|
|
17
|
+
**Make L4YERCAK3 the invisible backend for any business application.**
|
|
18
|
+
|
|
19
|
+
The CLI enables developers to:
|
|
20
|
+
1. **Connect** their frontend to L4YERCAK3's powerful backend
|
|
21
|
+
2. **Sync** data models between their app and L4YERCAK3 objects
|
|
22
|
+
3. **Access** all L4YERCAK3 applications (CRM, Events, Invoicing, etc.) via API
|
|
23
|
+
4. **Manage** users, authentication, and payments through L4YERCAK3
|
|
24
|
+
5. **Automate** business logic with L4YERCAK3 workflows
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Current State Analysis
|
|
29
|
+
|
|
30
|
+
### What We Have (CLI v1)
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
l4yercak3-cli/
|
|
34
|
+
├── commands/
|
|
35
|
+
│ ├── login.js ✅ OAuth browser flow with CSRF protection
|
|
36
|
+
│ ├── logout.js ✅ Clear session
|
|
37
|
+
│ ├── spread.js ✅ Basic project setup wizard
|
|
38
|
+
│ ├── status.js ✅ Show current session/config
|
|
39
|
+
│ ├── api-keys.js ✅ List/manage API keys
|
|
40
|
+
│ └── upgrade.js ✅ Open upgrade page
|
|
41
|
+
├── detectors/
|
|
42
|
+
│ ├── nextjs-detector.js ✅ Detect Next.js projects
|
|
43
|
+
│ ├── github-detector.js ✅ Detect GitHub repos
|
|
44
|
+
│ ├── oauth-detector.js ✅ Detect existing OAuth setup
|
|
45
|
+
│ └── api-client-detector.js ✅ Detect existing API client
|
|
46
|
+
├── generators/
|
|
47
|
+
│ ├── api-client-generator.js ✅ Generate L4YERCAK3 API client
|
|
48
|
+
│ ├── env-generator.js ✅ Generate .env.local
|
|
49
|
+
│ ├── nextauth-generator.js ✅ Generate NextAuth config
|
|
50
|
+
│ └── gitignore-generator.js ✅ Update .gitignore
|
|
51
|
+
└── api/
|
|
52
|
+
└── backend-client.js ✅ API communication layer
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### What We're Missing
|
|
56
|
+
|
|
57
|
+
| Feature | Status | Priority |
|
|
58
|
+
|---------|--------|----------|
|
|
59
|
+
| Object type mapping | ❌ | HIGH |
|
|
60
|
+
| Backend registration of connected apps | ❌ | HIGH |
|
|
61
|
+
| Real-time sync commands | ❌ | HIGH |
|
|
62
|
+
| Multi-application CLI access | ❌ | HIGH |
|
|
63
|
+
| Bulk data operations | ❌ | MEDIUM |
|
|
64
|
+
| Template management | ❌ | MEDIUM |
|
|
65
|
+
| AI Assistant integration | ❌ | MEDIUM |
|
|
66
|
+
| Webhook management | ❌ | MEDIUM |
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## L4YERCAK3 Backend Applications
|
|
71
|
+
|
|
72
|
+
Based on our backend analysis, here are ALL applications available for CLI integration:
|
|
73
|
+
|
|
74
|
+
### Tier 1: Core Business (HIGH Priority for CLI)
|
|
75
|
+
|
|
76
|
+
| Application | Object Types | CLI Value |
|
|
77
|
+
|-------------|--------------|-----------|
|
|
78
|
+
| **CRM** | contact, crm_organization | Sync customers, manage leads |
|
|
79
|
+
| **Events** | event, ticket | Create/manage events, issue tickets |
|
|
80
|
+
| **Products** | product | Manage inventory, pricing |
|
|
81
|
+
| **Checkout** | checkout_session, transaction | Process payments |
|
|
82
|
+
| **Invoicing** | invoice | Generate, send, track invoices |
|
|
83
|
+
| **Forms** | form, form_response | Build forms, collect data |
|
|
84
|
+
|
|
85
|
+
### Tier 2: Extended Features (MEDIUM Priority)
|
|
86
|
+
|
|
87
|
+
| Application | Object Types | CLI Value |
|
|
88
|
+
|-------------|--------------|-----------|
|
|
89
|
+
| **Projects** | project, milestone, task | Client project management |
|
|
90
|
+
| **Templates** | template, template_set | Manage email/PDF templates |
|
|
91
|
+
| **Workflows** | workflow | Automate business logic |
|
|
92
|
+
| **Web Publishing** | page | Deploy landing pages |
|
|
93
|
+
| **Certificates** | certificate | Issue achievement certificates |
|
|
94
|
+
| **Benefits** | benefit | Membership perks |
|
|
95
|
+
|
|
96
|
+
### Tier 3: Platform Features (LOWER Priority)
|
|
97
|
+
|
|
98
|
+
| Application | Object Types | CLI Value |
|
|
99
|
+
|-------------|--------------|-----------|
|
|
100
|
+
| **AI Assistant** | conversation, message | AI-powered operations |
|
|
101
|
+
| **Media Library** | media_item, media_folder | File management |
|
|
102
|
+
| **Compliance** | compliance_record | Regulatory tracking |
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## Core Architecture: The "Model Mapping" System
|
|
107
|
+
|
|
108
|
+
### The Big Idea
|
|
109
|
+
|
|
110
|
+
When a developer runs `l4yercak3 spread`, the CLI should:
|
|
111
|
+
|
|
112
|
+
1. **Detect** the external app's data models (Prisma schema, TypeScript types, etc.)
|
|
113
|
+
2. **Map** them to L4YERCAK3 object types
|
|
114
|
+
3. **Generate** sync code that keeps both systems in sync
|
|
115
|
+
4. **Register** the connection in the L4YERCAK3 backend
|
|
116
|
+
|
|
117
|
+
### Example Flow
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
$ l4yercak3 spread
|
|
121
|
+
|
|
122
|
+
🍰 Layer Cake Integration Wizard
|
|
123
|
+
|
|
124
|
+
🔍 Analyzing your project...
|
|
125
|
+
|
|
126
|
+
✅ Detected: Next.js 15 (App Router)
|
|
127
|
+
✅ Detected: Prisma ORM with 8 models
|
|
128
|
+
✅ Detected: NextAuth.js (Microsoft, Google)
|
|
129
|
+
|
|
130
|
+
📊 Your Data Models:
|
|
131
|
+
|
|
132
|
+
┌─────────────────────────────────────────────────────┐
|
|
133
|
+
│ Your Model → L4YERCAK3 Object Confidence │
|
|
134
|
+
├─────────────────────────────────────────────────────┤
|
|
135
|
+
│ User → contact 95% │
|
|
136
|
+
│ Company → crm_organization 92% │
|
|
137
|
+
│ Event → event 100% │
|
|
138
|
+
│ Ticket → ticket 98% │
|
|
139
|
+
│ Invoice → invoice 96% │
|
|
140
|
+
│ Subscription → (custom mapping) 70% │
|
|
141
|
+
└─────────────────────────────────────────────────────┘
|
|
142
|
+
|
|
143
|
+
? Accept this mapping? (y/n)
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## CLI Command Structure (v2.0)
|
|
149
|
+
|
|
150
|
+
### Authentication & Session
|
|
151
|
+
```bash
|
|
152
|
+
l4yercak3 login # Browser OAuth flow
|
|
153
|
+
l4yercak3 logout # Clear session
|
|
154
|
+
l4yercak3 status # Show session info
|
|
155
|
+
l4yercak3 whoami # Current user/org details
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Project Setup
|
|
159
|
+
```bash
|
|
160
|
+
l4yercak3 spread # Interactive setup wizard
|
|
161
|
+
l4yercak3 spread --template <name> # Use template (landing, portal, saas)
|
|
162
|
+
l4yercak3 init # Alias for spread
|
|
163
|
+
l4yercak3 config # View/edit project config
|
|
164
|
+
l4yercak3 config set <key> <val> # Set config value
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### Organization & API Keys
|
|
168
|
+
```bash
|
|
169
|
+
l4yercak3 orgs # List organizations
|
|
170
|
+
l4yercak3 orgs switch <id> # Switch active org
|
|
171
|
+
l4yercak3 api-keys list # List API keys
|
|
172
|
+
l4yercak3 api-keys create <name> # Generate new key
|
|
173
|
+
l4yercak3 api-keys revoke <id> # Revoke key
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### CRM Operations
|
|
177
|
+
```bash
|
|
178
|
+
l4yercak3 crm contacts # List contacts
|
|
179
|
+
l4yercak3 crm contacts create # Create contact (interactive)
|
|
180
|
+
l4yercak3 crm contacts import <f> # Import from CSV/JSON
|
|
181
|
+
l4yercak3 crm contacts export # Export to CSV
|
|
182
|
+
l4yercak3 crm contacts sync # Sync with local DB
|
|
183
|
+
l4yercak3 crm orgs # List CRM organizations
|
|
184
|
+
l4yercak3 crm orgs create # Create organization
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Events & Tickets
|
|
188
|
+
```bash
|
|
189
|
+
l4yercak3 events list # List events
|
|
190
|
+
l4yercak3 events create # Create event (interactive)
|
|
191
|
+
l4yercak3 events <id> # Event details
|
|
192
|
+
l4yercak3 events <id> tickets # List tickets for event
|
|
193
|
+
l4yercak3 tickets generate <id> # Generate ticket PDFs
|
|
194
|
+
l4yercak3 tickets scan <code> # Scan/redeem ticket QR
|
|
195
|
+
l4yercak3 tickets export <event> # Export ticket list
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Products & Checkout
|
|
199
|
+
```bash
|
|
200
|
+
l4yercak3 products list # List products
|
|
201
|
+
l4yercak3 products create # Create product
|
|
202
|
+
l4yercak3 products <id> # Product details
|
|
203
|
+
l4yercak3 checkout create <prod> # Create checkout session
|
|
204
|
+
l4yercak3 checkout verify <id> # Verify payment
|
|
205
|
+
l4yercak3 transactions list # List transactions
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### Invoicing
|
|
209
|
+
```bash
|
|
210
|
+
l4yercak3 invoices list # List invoices
|
|
211
|
+
l4yercak3 invoices create # Create invoice
|
|
212
|
+
l4yercak3 invoices <id> # Invoice details
|
|
213
|
+
l4yercak3 invoices <id> send # Send invoice email
|
|
214
|
+
l4yercak3 invoices <id> pdf # Download PDF
|
|
215
|
+
l4yercak3 invoices consolidate # Run consolidation rules
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### Forms
|
|
219
|
+
```bash
|
|
220
|
+
l4yercak3 forms list # List forms
|
|
221
|
+
l4yercak3 forms create # Create form (opens editor)
|
|
222
|
+
l4yercak3 forms <id> responses # View form responses
|
|
223
|
+
l4yercak3 forms <id> export # Export responses
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### Projects
|
|
227
|
+
```bash
|
|
228
|
+
l4yercak3 projects list # List projects
|
|
229
|
+
l4yercak3 projects create # Create project
|
|
230
|
+
l4yercak3 projects <id> # Project details
|
|
231
|
+
l4yercak3 projects <id> tasks # List tasks
|
|
232
|
+
l4yercak3 projects <id> add-task # Add task
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### Templates
|
|
236
|
+
```bash
|
|
237
|
+
l4yercak3 templates list # List templates
|
|
238
|
+
l4yercak3 templates <type> # List by type (ticket_pdf, invoice_pdf, email)
|
|
239
|
+
l4yercak3 templates preview <id> # Preview template
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### Workflows & Automation
|
|
243
|
+
```bash
|
|
244
|
+
l4yercak3 workflows list # List workflows
|
|
245
|
+
l4yercak3 workflows <id> run # Manually trigger workflow
|
|
246
|
+
l4yercak3 workflows <id> logs # View execution logs
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### Publishing
|
|
250
|
+
```bash
|
|
251
|
+
l4yercak3 pages list # List published pages
|
|
252
|
+
l4yercak3 pages <id> deploy # Deploy page
|
|
253
|
+
l4yercak3 pages <id> status # Deployment status
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### Data Sync Operations
|
|
257
|
+
```bash
|
|
258
|
+
l4yercak3 sync # Sync all mapped models
|
|
259
|
+
l4yercak3 sync contacts # Sync contacts only
|
|
260
|
+
l4yercak3 sync --pull # Pull from L4YERCAK3 → local
|
|
261
|
+
l4yercak3 sync --push # Push from local → L4YERCAK3
|
|
262
|
+
l4yercak3 sync --dry-run # Show what would sync
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
### Bulk Operations
|
|
266
|
+
```bash
|
|
267
|
+
l4yercak3 bulk import <file> # Import data from CSV/JSON
|
|
268
|
+
l4yercak3 bulk export <type> # Export object type
|
|
269
|
+
l4yercak3 bulk update <type> # Bulk update objects
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### AI Assistant
|
|
273
|
+
```bash
|
|
274
|
+
l4yercak3 ai "<prompt>" # One-shot AI command
|
|
275
|
+
l4yercak3 ai chat # Interactive AI chat
|
|
276
|
+
l4yercak3 ai tools # List available AI tools
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### Webhooks
|
|
280
|
+
```bash
|
|
281
|
+
l4yercak3 webhooks list # List webhook subscriptions
|
|
282
|
+
l4yercak3 webhooks create <url> # Create webhook
|
|
283
|
+
l4yercak3 webhooks test <id> # Send test payload
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
### Development Tools
|
|
287
|
+
```bash
|
|
288
|
+
l4yercak3 dev # Start dev mode (watch for changes)
|
|
289
|
+
l4yercak3 dev logs # Stream backend logs
|
|
290
|
+
l4yercak3 test api # Test API connection
|
|
291
|
+
l4yercak3 test webhooks # Test webhook delivery
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
---
|
|
295
|
+
|
|
296
|
+
## Backend Registration: Connected Apps
|
|
297
|
+
|
|
298
|
+
When a project runs `l4yercak3 spread`, it should register in the backend:
|
|
299
|
+
|
|
300
|
+
### New Table: `cli_connected_apps`
|
|
301
|
+
|
|
302
|
+
```typescript
|
|
303
|
+
// Schema addition
|
|
304
|
+
cliConnectedApps: defineTable({
|
|
305
|
+
organizationId: v.id("organizations"),
|
|
306
|
+
name: v.string(), // "My Benefits Platform"
|
|
307
|
+
projectPath: v.string(), // Hash of local path (for identification)
|
|
308
|
+
framework: v.string(), // "nextjs", "remix", etc.
|
|
309
|
+
apiKeyId: v.optional(v.id("apiKeys")), // Linked API key
|
|
310
|
+
modelMappings: v.array(v.object({
|
|
311
|
+
localModel: v.string(), // "User"
|
|
312
|
+
layerCakeType: v.string(), // "contact"
|
|
313
|
+
syncDirection: v.string(), // "bidirectional" | "push" | "pull"
|
|
314
|
+
fieldMappings: v.array(v.object({
|
|
315
|
+
localField: v.string(),
|
|
316
|
+
layerCakeField: v.string(),
|
|
317
|
+
})),
|
|
318
|
+
})),
|
|
319
|
+
features: v.array(v.string()), // ["crm", "invoicing", "events"]
|
|
320
|
+
productionDomain: v.optional(v.string()),
|
|
321
|
+
status: v.string(), // "active" | "paused" | "disconnected"
|
|
322
|
+
lastSyncAt: v.optional(v.number()),
|
|
323
|
+
createdAt: v.number(),
|
|
324
|
+
updatedAt: v.number(),
|
|
325
|
+
})
|
|
326
|
+
.index("by_organization", ["organizationId"])
|
|
327
|
+
.index("by_api_key", ["apiKeyId"])
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
### UI: "Connected Apps" Section
|
|
331
|
+
|
|
332
|
+
In the L4YERCAK3 dashboard, add a "Connected Apps" window showing:
|
|
333
|
+
- List of all CLI-connected applications
|
|
334
|
+
- Connection status (last sync, health)
|
|
335
|
+
- Model mappings
|
|
336
|
+
- Sync controls (pause, force sync, disconnect)
|
|
337
|
+
- Activity log
|
|
338
|
+
|
|
339
|
+
---
|
|
340
|
+
|
|
341
|
+
## Implementation Phases
|
|
342
|
+
|
|
343
|
+
### Phase 1: Foundation Enhancement (Weeks 1-2)
|
|
344
|
+
|
|
345
|
+
**Goal:** Complete the basic CLI with all essential operations
|
|
346
|
+
|
|
347
|
+
Tasks:
|
|
348
|
+
1. ✅ Login/logout flow (DONE)
|
|
349
|
+
2. ✅ API key management (DONE)
|
|
350
|
+
3. [ ] Create `cli_connected_apps` table
|
|
351
|
+
4. [ ] Backend registration on `spread`
|
|
352
|
+
5. [ ] CRM commands (contacts, orgs)
|
|
353
|
+
6. [ ] Basic sync functionality
|
|
354
|
+
|
|
355
|
+
Deliverables:
|
|
356
|
+
- CLI can CRUD contacts and organizations
|
|
357
|
+
- Connected apps appear in backend UI
|
|
358
|
+
- Basic two-way sync works
|
|
359
|
+
|
|
360
|
+
### Phase 2: Event & Commerce (Weeks 3-4)
|
|
361
|
+
|
|
362
|
+
**Goal:** Full event management and payment processing
|
|
363
|
+
|
|
364
|
+
Tasks:
|
|
365
|
+
1. [ ] Events commands (list, create, manage)
|
|
366
|
+
2. [ ] Tickets commands (generate, scan, export)
|
|
367
|
+
3. [ ] Products commands (CRUD)
|
|
368
|
+
4. [ ] Checkout integration
|
|
369
|
+
5. [ ] Transactions listing
|
|
370
|
+
|
|
371
|
+
Deliverables:
|
|
372
|
+
- Complete event lifecycle via CLI
|
|
373
|
+
- Ticket PDF generation
|
|
374
|
+
- Payment processing works
|
|
375
|
+
|
|
376
|
+
### Phase 3: Invoicing & Projects (Weeks 5-6)
|
|
377
|
+
|
|
378
|
+
**Goal:** B2B operations support
|
|
379
|
+
|
|
380
|
+
Tasks:
|
|
381
|
+
1. [ ] Invoice commands (create, send, PDF)
|
|
382
|
+
2. [ ] Invoice consolidation rules
|
|
383
|
+
3. [ ] Projects commands
|
|
384
|
+
4. [ ] Task management
|
|
385
|
+
5. [ ] Forms commands
|
|
386
|
+
|
|
387
|
+
Deliverables:
|
|
388
|
+
- Full invoicing workflow via CLI
|
|
389
|
+
- Project management for client work
|
|
390
|
+
|
|
391
|
+
### Phase 4: Intelligence & Automation (Weeks 7-8)
|
|
392
|
+
|
|
393
|
+
**Goal:** Smart features and automation
|
|
394
|
+
|
|
395
|
+
Tasks:
|
|
396
|
+
1. [ ] Model detection and mapping
|
|
397
|
+
2. [ ] Schema analysis (Prisma, TypeScript)
|
|
398
|
+
3. [ ] AI assistant integration
|
|
399
|
+
4. [ ] Workflow management
|
|
400
|
+
5. [ ] Webhook configuration
|
|
401
|
+
|
|
402
|
+
Deliverables:
|
|
403
|
+
- Intelligent model mapping
|
|
404
|
+
- AI-powered CLI commands
|
|
405
|
+
- Automation setup
|
|
406
|
+
|
|
407
|
+
### Phase 5: Polish & Templates (Weeks 9-10)
|
|
408
|
+
|
|
409
|
+
**Goal:** Production-ready with templates
|
|
410
|
+
|
|
411
|
+
Tasks:
|
|
412
|
+
1. [ ] Template management commands
|
|
413
|
+
2. [ ] Web publishing integration
|
|
414
|
+
3. [ ] Bulk operations
|
|
415
|
+
4. [ ] Dev mode with hot reload
|
|
416
|
+
5. [ ] Comprehensive documentation
|
|
417
|
+
|
|
418
|
+
Deliverables:
|
|
419
|
+
- Full template support
|
|
420
|
+
- Bulk import/export
|
|
421
|
+
- Developer documentation
|
|
422
|
+
|
|
423
|
+
---
|
|
424
|
+
|
|
425
|
+
## Model Detection Strategy
|
|
426
|
+
|
|
427
|
+
### Supported Detection Sources
|
|
428
|
+
|
|
429
|
+
1. **Prisma Schema** (`schema.prisma`)
|
|
430
|
+
- Parse model definitions
|
|
431
|
+
- Extract field types and relationships
|
|
432
|
+
- Map to L4YERCAK3 object types
|
|
433
|
+
|
|
434
|
+
2. **TypeScript Types** (`*.ts`, `*.tsx`)
|
|
435
|
+
- Find interface/type definitions
|
|
436
|
+
- Extract field types
|
|
437
|
+
- Infer L4YERCAK3 mappings
|
|
438
|
+
|
|
439
|
+
3. **Convex Schema** (for Convex-based apps)
|
|
440
|
+
- Parse table definitions
|
|
441
|
+
- Direct type mapping
|
|
442
|
+
|
|
443
|
+
4. **GraphQL Schema** (`*.graphql`)
|
|
444
|
+
- Parse type definitions
|
|
445
|
+
- Map to objects
|
|
446
|
+
|
|
447
|
+
### Mapping Intelligence
|
|
448
|
+
|
|
449
|
+
```javascript
|
|
450
|
+
// Example mapping rules
|
|
451
|
+
const mappingRules = {
|
|
452
|
+
// Name-based matching
|
|
453
|
+
namePatterns: {
|
|
454
|
+
contact: ['user', 'customer', 'member', 'subscriber', 'lead'],
|
|
455
|
+
crm_organization: ['company', 'organization', 'business', 'client'],
|
|
456
|
+
event: ['event', 'conference', 'workshop', 'meetup', 'webinar'],
|
|
457
|
+
ticket: ['ticket', 'registration', 'booking', 'rsvp'],
|
|
458
|
+
product: ['product', 'item', 'sku', 'offering'],
|
|
459
|
+
invoice: ['invoice', 'bill', 'receipt'],
|
|
460
|
+
transaction: ['transaction', 'payment', 'order', 'purchase'],
|
|
461
|
+
project: ['project', 'campaign', 'engagement'],
|
|
462
|
+
},
|
|
463
|
+
|
|
464
|
+
// Field-based matching (presence of certain fields increases confidence)
|
|
465
|
+
fieldPatterns: {
|
|
466
|
+
contact: ['email', 'phone', 'firstName', 'lastName'],
|
|
467
|
+
crm_organization: ['companyName', 'taxId', 'industry'],
|
|
468
|
+
event: ['startDate', 'endDate', 'location', 'capacity'],
|
|
469
|
+
invoice: ['invoiceNumber', 'lineItems', 'dueDate', 'totalAmount'],
|
|
470
|
+
},
|
|
471
|
+
};
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
---
|
|
475
|
+
|
|
476
|
+
## User Journey Examples
|
|
477
|
+
|
|
478
|
+
### Journey 1: Benefits Platform Developer
|
|
479
|
+
|
|
480
|
+
```bash
|
|
481
|
+
# Developer has a Next.js app for employee benefits
|
|
482
|
+
|
|
483
|
+
$ cd my-benefits-app
|
|
484
|
+
$ l4yercak3 login
|
|
485
|
+
✅ Logged in as developer@company.com
|
|
486
|
+
|
|
487
|
+
$ l4yercak3 spread
|
|
488
|
+
🔍 Analyzing your project...
|
|
489
|
+
|
|
490
|
+
✅ Next.js 15 (App Router, TypeScript)
|
|
491
|
+
✅ Prisma with 5 models detected
|
|
492
|
+
|
|
493
|
+
📊 Suggested Mapping:
|
|
494
|
+
┌────────────────────────────────────────┐
|
|
495
|
+
│ Employee → contact (95%) │
|
|
496
|
+
│ Company → crm_organization (92%) │
|
|
497
|
+
│ Benefit → benefit (100%) │
|
|
498
|
+
│ Enrollment → form_response (88%) │
|
|
499
|
+
└────────────────────────────────────────┘
|
|
500
|
+
|
|
501
|
+
? Accept mapping? Yes
|
|
502
|
+
? Select features: [x] CRM [x] Benefits [ ] Invoicing
|
|
503
|
+
|
|
504
|
+
✅ Generated: lib/layercake.ts
|
|
505
|
+
✅ Generated: .env.local
|
|
506
|
+
✅ Registered in L4YERCAK3 backend
|
|
507
|
+
|
|
508
|
+
🍰 Your Benefits app is now connected!
|
|
509
|
+
|
|
510
|
+
Next: Run "l4yercak3 sync" to sync your employees
|
|
511
|
+
|
|
512
|
+
$ l4yercak3 sync --dry-run
|
|
513
|
+
Would sync:
|
|
514
|
+
- 150 Employees → L4YERCAK3 contacts
|
|
515
|
+
- 3 Companies → L4YERCAK3 organizations
|
|
516
|
+
|
|
517
|
+
$ l4yercak3 sync
|
|
518
|
+
✅ Synced 150 contacts
|
|
519
|
+
✅ Synced 3 organizations
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
### Journey 2: Event Organizer
|
|
523
|
+
|
|
524
|
+
```bash
|
|
525
|
+
# Organizer uses CLI to manage events
|
|
526
|
+
|
|
527
|
+
$ l4yercak3 events create
|
|
528
|
+
? Event name: Tech Conference 2025
|
|
529
|
+
? Type: conference
|
|
530
|
+
? Start date: 2025-06-15
|
|
531
|
+
? Location: Berlin
|
|
532
|
+
✅ Event created (ID: evt_abc123)
|
|
533
|
+
|
|
534
|
+
$ l4yercak3 products create
|
|
535
|
+
? Product name: Early Bird Ticket
|
|
536
|
+
? Price: 199
|
|
537
|
+
? Link to event: evt_abc123
|
|
538
|
+
✅ Product created (ID: prod_xyz789)
|
|
539
|
+
|
|
540
|
+
$ l4yercak3 tickets export evt_abc123 --format csv
|
|
541
|
+
✅ Exported 342 tickets to tickets_evt_abc123.csv
|
|
542
|
+
|
|
543
|
+
$ l4yercak3 tickets scan QR_CODE_DATA
|
|
544
|
+
✅ Ticket redeemed: John Doe (VIP)
|
|
545
|
+
```
|
|
546
|
+
|
|
547
|
+
### Journey 3: Freelancer with Client Portal
|
|
548
|
+
|
|
549
|
+
```bash
|
|
550
|
+
# Freelancer connects their portfolio/client portal
|
|
551
|
+
|
|
552
|
+
$ l4yercak3 spread --template freelancer-portal
|
|
553
|
+
|
|
554
|
+
🔍 Analyzing...
|
|
555
|
+
|
|
556
|
+
? Your business name: Jane Design Studio
|
|
557
|
+
? Enable: [x] Projects [x] Invoicing [x] CRM
|
|
558
|
+
|
|
559
|
+
✅ Configured for freelancer workflow
|
|
560
|
+
|
|
561
|
+
$ l4yercak3 projects create
|
|
562
|
+
? Client: Acme Corp
|
|
563
|
+
? Project name: Brand Redesign
|
|
564
|
+
? Budget: 15000
|
|
565
|
+
✅ Project created
|
|
566
|
+
|
|
567
|
+
$ l4yercak3 invoices create
|
|
568
|
+
? Select project: Brand Redesign
|
|
569
|
+
? Description: Phase 1 - Discovery
|
|
570
|
+
? Amount: 5000
|
|
571
|
+
✅ Invoice created (#INV-2025-001)
|
|
572
|
+
|
|
573
|
+
$ l4yercak3 invoices INV-2025-001 send
|
|
574
|
+
✅ Invoice sent to client@acmecorp.com
|
|
575
|
+
```
|
|
576
|
+
|
|
577
|
+
---
|
|
578
|
+
|
|
579
|
+
## Technical Specifications
|
|
580
|
+
|
|
581
|
+
### API Client Structure (Generated)
|
|
582
|
+
|
|
583
|
+
```typescript
|
|
584
|
+
// lib/layercake.ts (auto-generated)
|
|
585
|
+
|
|
586
|
+
import { LayerCakeClient } from '@l4yercak3/sdk';
|
|
587
|
+
|
|
588
|
+
export const layercake = new LayerCakeClient({
|
|
589
|
+
apiKey: process.env.L4YERCAK3_API_KEY,
|
|
590
|
+
organizationId: process.env.L4YERCAK3_ORG_ID,
|
|
591
|
+
});
|
|
592
|
+
|
|
593
|
+
// Type-safe access to mapped objects
|
|
594
|
+
export const contacts = layercake.crm.contacts;
|
|
595
|
+
export const events = layercake.events;
|
|
596
|
+
export const invoices = layercake.invoicing;
|
|
597
|
+
|
|
598
|
+
// Sync helpers
|
|
599
|
+
export async function syncContacts(localUsers: User[]) {
|
|
600
|
+
return layercake.sync.contacts(localUsers, {
|
|
601
|
+
mapping: {
|
|
602
|
+
email: 'email',
|
|
603
|
+
name: 'displayName',
|
|
604
|
+
company: 'customProperties.company',
|
|
605
|
+
},
|
|
606
|
+
});
|
|
607
|
+
}
|
|
608
|
+
```
|
|
609
|
+
|
|
610
|
+
### Environment Variables
|
|
611
|
+
|
|
612
|
+
```bash
|
|
613
|
+
# .env.local (auto-generated)
|
|
614
|
+
|
|
615
|
+
# L4YERCAK3 Configuration
|
|
616
|
+
L4YERCAK3_API_KEY=sk_live_xxxxx
|
|
617
|
+
L4YERCAK3_ORG_ID=org_xxxxx
|
|
618
|
+
L4YERCAK3_BACKEND_URL=https://app.l4yercak3.com
|
|
619
|
+
|
|
620
|
+
# Sync Configuration
|
|
621
|
+
L4YERCAK3_SYNC_ENABLED=true
|
|
622
|
+
L4YERCAK3_SYNC_DIRECTION=bidirectional
|
|
623
|
+
|
|
624
|
+
# Feature Flags
|
|
625
|
+
L4YERCAK3_FEATURES=crm,events,invoicing
|
|
626
|
+
```
|
|
627
|
+
|
|
628
|
+
---
|
|
629
|
+
|
|
630
|
+
## Success Metrics
|
|
631
|
+
|
|
632
|
+
### Phase 1 Success
|
|
633
|
+
- [ ] CLI can create/list contacts
|
|
634
|
+
- [ ] Connected apps appear in dashboard
|
|
635
|
+
- [ ] Basic sync works bidirectionally
|
|
636
|
+
- [ ] < 5 second response for all commands
|
|
637
|
+
|
|
638
|
+
### Phase 2 Success
|
|
639
|
+
- [ ] Full event lifecycle manageable via CLI
|
|
640
|
+
- [ ] Ticket PDFs generate correctly
|
|
641
|
+
- [ ] Payment flow works end-to-end
|
|
642
|
+
|
|
643
|
+
### Phase 3 Success
|
|
644
|
+
- [ ] Invoice workflow complete via CLI
|
|
645
|
+
- [ ] Project/task management functional
|
|
646
|
+
- [ ] Form responses accessible
|
|
647
|
+
|
|
648
|
+
### Phase 4 Success
|
|
649
|
+
- [ ] Model detection works for Prisma
|
|
650
|
+
- [ ] AI commands functional
|
|
651
|
+
- [ ] Webhooks configurable
|
|
652
|
+
|
|
653
|
+
### Phase 5 Success
|
|
654
|
+
- [ ] Complete documentation
|
|
655
|
+
- [ ] All templates available
|
|
656
|
+
- [ ] Bulk operations handle 10k+ records
|
|
657
|
+
|
|
658
|
+
---
|
|
659
|
+
|
|
660
|
+
## Appendix A: Full API Endpoint Reference
|
|
661
|
+
|
|
662
|
+
See [CLI_API_REFERENCE.md](./CLI_API_REFERENCE.md) for complete endpoint documentation.
|
|
663
|
+
|
|
664
|
+
## Appendix B: Object Type Mappings
|
|
665
|
+
|
|
666
|
+
See [OBJECT_MAPPINGS.md](./OBJECT_MAPPINGS.md) for full mapping rules.
|
|
667
|
+
|
|
668
|
+
## Appendix C: Migration Guide
|
|
669
|
+
|
|
670
|
+
See [MIGRATION_GUIDE.md](./MIGRATION_GUIDE.md) for upgrading from CLI v1.
|
|
671
|
+
|
|
672
|
+
---
|
|
673
|
+
|
|
674
|
+
*Document Version: 2.0*
|
|
675
|
+
*Last Updated: January 2025*
|
|
676
|
+
*Author: L4YERCAK3 Team*
|