@l4yercak3/cli 1.3.1 → 2.0.0-alpha.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 (357) hide show
  1. package/README.md +10 -220
  2. package/dist/api/client.d.ts +12 -0
  3. package/dist/api/client.d.ts.map +1 -0
  4. package/dist/api/client.js +37 -0
  5. package/dist/api/client.js.map +1 -0
  6. package/dist/api/platform.d.ts +161 -0
  7. package/dist/api/platform.d.ts.map +1 -0
  8. package/dist/api/platform.js +70 -0
  9. package/dist/api/platform.js.map +1 -0
  10. package/dist/bin/sevenlayers.d.ts +3 -0
  11. package/dist/bin/sevenlayers.d.ts.map +1 -0
  12. package/dist/bin/sevenlayers.js +198 -0
  13. package/dist/bin/sevenlayers.js.map +1 -0
  14. package/dist/commands/agent/catalog.d.ts +5 -0
  15. package/dist/commands/agent/catalog.d.ts.map +1 -0
  16. package/dist/commands/agent/catalog.js +142 -0
  17. package/dist/commands/agent/catalog.js.map +1 -0
  18. package/dist/commands/agent/drift.d.ts +5 -0
  19. package/dist/commands/agent/drift.d.ts.map +1 -0
  20. package/dist/commands/agent/drift.js +113 -0
  21. package/dist/commands/agent/drift.js.map +1 -0
  22. package/dist/commands/agent/init.d.ts +5 -0
  23. package/dist/commands/agent/init.d.ts.map +1 -0
  24. package/dist/commands/agent/init.js +75 -0
  25. package/dist/commands/agent/init.js.map +1 -0
  26. package/dist/commands/agent/permissions.d.ts +5 -0
  27. package/dist/commands/agent/permissions.d.ts.map +1 -0
  28. package/dist/commands/agent/permissions.js +88 -0
  29. package/dist/commands/agent/permissions.js.map +1 -0
  30. package/dist/commands/agent/runner.d.ts +14 -0
  31. package/dist/commands/agent/runner.d.ts.map +1 -0
  32. package/dist/commands/agent/runner.js +59 -0
  33. package/dist/commands/agent/runner.js.map +1 -0
  34. package/dist/commands/agent/shared.d.ts +13 -0
  35. package/dist/commands/agent/shared.d.ts.map +1 -0
  36. package/dist/commands/agent/shared.js +31 -0
  37. package/dist/commands/agent/shared.js.map +1 -0
  38. package/dist/commands/agent/template.d.ts +5 -0
  39. package/dist/commands/agent/template.d.ts.map +1 -0
  40. package/dist/commands/agent/template.js +104 -0
  41. package/dist/commands/agent/template.js.map +1 -0
  42. package/dist/commands/app/connect.d.ts +7 -0
  43. package/dist/commands/app/connect.d.ts.map +1 -0
  44. package/dist/commands/app/connect.js +12 -0
  45. package/dist/commands/app/connect.js.map +1 -0
  46. package/dist/commands/app/init.d.ts +7 -0
  47. package/dist/commands/app/init.d.ts.map +1 -0
  48. package/dist/commands/app/init.js +12 -0
  49. package/dist/commands/app/init.js.map +1 -0
  50. package/dist/commands/app/link.d.ts +3 -0
  51. package/dist/commands/app/link.d.ts.map +1 -0
  52. package/dist/commands/app/link.js +92 -0
  53. package/dist/commands/app/link.js.map +1 -0
  54. package/dist/commands/app/pages.d.ts +15 -0
  55. package/dist/commands/app/pages.d.ts.map +1 -0
  56. package/dist/commands/app/pages.js +180 -0
  57. package/dist/commands/app/pages.js.map +1 -0
  58. package/dist/commands/app/register.d.ts +3 -0
  59. package/dist/commands/app/register.d.ts.map +1 -0
  60. package/dist/commands/app/register.js +120 -0
  61. package/dist/commands/app/register.js.map +1 -0
  62. package/dist/commands/app/remote.d.ts +14 -0
  63. package/dist/commands/app/remote.d.ts.map +1 -0
  64. package/dist/commands/app/remote.js +44 -0
  65. package/dist/commands/app/remote.js.map +1 -0
  66. package/dist/commands/app/setup.d.ts +3 -0
  67. package/dist/commands/app/setup.d.ts.map +1 -0
  68. package/dist/commands/app/setup.js +299 -0
  69. package/dist/commands/app/setup.js.map +1 -0
  70. package/dist/commands/app/shared.d.ts +9 -0
  71. package/dist/commands/app/shared.d.ts.map +1 -0
  72. package/dist/commands/app/shared.js +122 -0
  73. package/dist/commands/app/shared.js.map +1 -0
  74. package/dist/commands/app/sync.d.ts +7 -0
  75. package/dist/commands/app/sync.d.ts.map +1 -0
  76. package/dist/commands/app/sync.js +107 -0
  77. package/dist/commands/app/sync.js.map +1 -0
  78. package/dist/commands/booking/check.d.ts +3 -0
  79. package/dist/commands/booking/check.d.ts.map +1 -0
  80. package/dist/commands/booking/check.js +68 -0
  81. package/dist/commands/booking/check.js.map +1 -0
  82. package/dist/commands/booking/setup.d.ts +3 -0
  83. package/dist/commands/booking/setup.d.ts.map +1 -0
  84. package/dist/commands/booking/setup.js +95 -0
  85. package/dist/commands/booking/setup.js.map +1 -0
  86. package/dist/commands/booking/shared.d.ts +31 -0
  87. package/dist/commands/booking/shared.d.ts.map +1 -0
  88. package/dist/commands/booking/shared.js +112 -0
  89. package/dist/commands/booking/shared.js.map +1 -0
  90. package/dist/commands/booking/smoke.d.ts +3 -0
  91. package/dist/commands/booking/smoke.d.ts.map +1 -0
  92. package/dist/commands/booking/smoke.js +101 -0
  93. package/dist/commands/booking/smoke.js.map +1 -0
  94. package/dist/commands/cms/bind.d.ts +3 -0
  95. package/dist/commands/cms/bind.d.ts.map +1 -0
  96. package/dist/commands/cms/bind.js +212 -0
  97. package/dist/commands/cms/bind.js.map +1 -0
  98. package/dist/commands/cms/content.d.ts +40 -0
  99. package/dist/commands/cms/content.d.ts.map +1 -0
  100. package/dist/commands/cms/content.js +169 -0
  101. package/dist/commands/cms/content.js.map +1 -0
  102. package/dist/commands/cms/doctor.d.ts +3 -0
  103. package/dist/commands/cms/doctor.d.ts.map +1 -0
  104. package/dist/commands/cms/doctor.js +69 -0
  105. package/dist/commands/cms/doctor.js.map +1 -0
  106. package/dist/commands/cms/migrate.d.ts +3 -0
  107. package/dist/commands/cms/migrate.d.ts.map +1 -0
  108. package/dist/commands/cms/migrate.js +78 -0
  109. package/dist/commands/cms/migrate.js.map +1 -0
  110. package/dist/commands/cms/registry.d.ts +3 -0
  111. package/dist/commands/cms/registry.d.ts.map +1 -0
  112. package/dist/commands/cms/registry.js +161 -0
  113. package/dist/commands/cms/registry.js.map +1 -0
  114. package/dist/commands/cms/seed.d.ts +3 -0
  115. package/dist/commands/cms/seed.d.ts.map +1 -0
  116. package/dist/commands/cms/seed.js +102 -0
  117. package/dist/commands/cms/seed.js.map +1 -0
  118. package/dist/commands/cms/shared.d.ts +22 -0
  119. package/dist/commands/cms/shared.d.ts.map +1 -0
  120. package/dist/commands/cms/shared.js +82 -0
  121. package/dist/commands/cms/shared.js.map +1 -0
  122. package/dist/commands/doctor/target.d.ts +3 -0
  123. package/dist/commands/doctor/target.d.ts.map +1 -0
  124. package/dist/commands/doctor/target.js +46 -0
  125. package/dist/commands/doctor/target.js.map +1 -0
  126. package/dist/commands/env/list.d.ts +3 -0
  127. package/dist/commands/env/list.d.ts.map +1 -0
  128. package/dist/commands/env/list.js +28 -0
  129. package/dist/commands/env/list.js.map +1 -0
  130. package/dist/commands/env/set.d.ts +3 -0
  131. package/dist/commands/env/set.d.ts.map +1 -0
  132. package/dist/commands/env/set.js +36 -0
  133. package/dist/commands/env/set.js.map +1 -0
  134. package/dist/commands/env/use.d.ts +3 -0
  135. package/dist/commands/env/use.d.ts.map +1 -0
  136. package/dist/commands/env/use.js +15 -0
  137. package/dist/commands/env/use.js.map +1 -0
  138. package/dist/commands/legacy/connect.d.ts +3 -0
  139. package/dist/commands/legacy/connect.d.ts.map +1 -0
  140. package/dist/commands/legacy/connect.js +8 -0
  141. package/dist/commands/legacy/connect.js.map +1 -0
  142. package/dist/commands/legacy/pages.d.ts +3 -0
  143. package/dist/commands/legacy/pages.d.ts.map +1 -0
  144. package/dist/commands/legacy/pages.js +16 -0
  145. package/dist/commands/legacy/pages.js.map +1 -0
  146. package/dist/commands/legacy/spread.d.ts +3 -0
  147. package/dist/commands/legacy/spread.d.ts.map +1 -0
  148. package/dist/commands/legacy/spread.js +8 -0
  149. package/dist/commands/legacy/spread.js.map +1 -0
  150. package/dist/commands/legacy/sync.d.ts +3 -0
  151. package/dist/commands/legacy/sync.d.ts.map +1 -0
  152. package/dist/commands/legacy/sync.js +8 -0
  153. package/dist/commands/legacy/sync.js.map +1 -0
  154. package/dist/config/env-diff.d.ts +10 -0
  155. package/dist/config/env-diff.d.ts.map +1 -0
  156. package/dist/config/env-diff.js +24 -0
  157. package/dist/config/env-diff.js.map +1 -0
  158. package/dist/config/env-parser.d.ts +20 -0
  159. package/dist/config/env-parser.d.ts.map +1 -0
  160. package/dist/config/env-parser.js +70 -0
  161. package/dist/config/env-parser.js.map +1 -0
  162. package/dist/config/env-writer.d.ts +22 -0
  163. package/dist/config/env-writer.d.ts.map +1 -0
  164. package/dist/config/env-writer.js +172 -0
  165. package/dist/config/env-writer.js.map +1 -0
  166. package/dist/config/profile-store.d.ts +29 -0
  167. package/dist/config/profile-store.d.ts.map +1 -0
  168. package/dist/config/profile-store.js +257 -0
  169. package/dist/config/profile-store.js.map +1 -0
  170. package/dist/core/args.d.ts +11 -0
  171. package/dist/core/args.d.ts.map +1 -0
  172. package/dist/core/args.js +106 -0
  173. package/dist/core/args.js.map +1 -0
  174. package/dist/core/colors.d.ts +6 -0
  175. package/dist/core/colors.d.ts.map +1 -0
  176. package/dist/core/colors.js +29 -0
  177. package/dist/core/colors.js.map +1 -0
  178. package/dist/safety/target-guard.d.ts +16 -0
  179. package/dist/safety/target-guard.d.ts.map +1 -0
  180. package/dist/safety/target-guard.js +55 -0
  181. package/dist/safety/target-guard.js.map +1 -0
  182. package/dist/testing/booking-smoke.d.ts +17 -0
  183. package/dist/testing/booking-smoke.d.ts.map +1 -0
  184. package/dist/testing/booking-smoke.js +43 -0
  185. package/dist/testing/booking-smoke.js.map +1 -0
  186. package/dist/tests/agent-commands.test.d.ts +2 -0
  187. package/dist/tests/agent-commands.test.d.ts.map +1 -0
  188. package/dist/tests/agent-commands.test.js +180 -0
  189. package/dist/tests/agent-commands.test.js.map +1 -0
  190. package/dist/tests/agent-governance.test.d.ts +2 -0
  191. package/dist/tests/agent-governance.test.d.ts.map +1 -0
  192. package/dist/tests/agent-governance.test.js +233 -0
  193. package/dist/tests/agent-governance.test.js.map +1 -0
  194. package/dist/tests/app-commands.test.d.ts +2 -0
  195. package/dist/tests/app-commands.test.d.ts.map +1 -0
  196. package/dist/tests/app-commands.test.js +462 -0
  197. package/dist/tests/app-commands.test.js.map +1 -0
  198. package/dist/tests/booking-commands.test.d.ts +2 -0
  199. package/dist/tests/booking-commands.test.d.ts.map +1 -0
  200. package/dist/tests/booking-commands.test.js +204 -0
  201. package/dist/tests/booking-commands.test.js.map +1 -0
  202. package/dist/tests/booking-smoke.test.d.ts +2 -0
  203. package/dist/tests/booking-smoke.test.d.ts.map +1 -0
  204. package/dist/tests/booking-smoke.test.js +183 -0
  205. package/dist/tests/booking-smoke.test.js.map +1 -0
  206. package/dist/tests/cms-commands.test.d.ts +2 -0
  207. package/dist/tests/cms-commands.test.d.ts.map +1 -0
  208. package/dist/tests/cms-commands.test.js +254 -0
  209. package/dist/tests/cms-commands.test.js.map +1 -0
  210. package/dist/tests/cms-ops.test.d.ts +2 -0
  211. package/dist/tests/cms-ops.test.d.ts.map +1 -0
  212. package/dist/tests/cms-ops.test.js +125 -0
  213. package/dist/tests/cms-ops.test.js.map +1 -0
  214. package/dist/tests/env-writer.test.d.ts +2 -0
  215. package/dist/tests/env-writer.test.d.ts.map +1 -0
  216. package/dist/tests/env-writer.test.js +90 -0
  217. package/dist/tests/env-writer.test.js.map +1 -0
  218. package/dist/tests/profile-store.test.d.ts +2 -0
  219. package/dist/tests/profile-store.test.d.ts.map +1 -0
  220. package/dist/tests/profile-store.test.js +88 -0
  221. package/dist/tests/profile-store.test.js.map +1 -0
  222. package/dist/tests/target-guard.test.d.ts +2 -0
  223. package/dist/tests/target-guard.test.d.ts.map +1 -0
  224. package/dist/tests/target-guard.test.js +132 -0
  225. package/dist/tests/target-guard.test.js.map +1 -0
  226. package/dist/ui/logo.d.ts +2 -0
  227. package/dist/ui/logo.d.ts.map +1 -0
  228. package/dist/ui/logo.js +22 -0
  229. package/dist/ui/logo.js.map +1 -0
  230. package/package.json +17 -53
  231. package/.claude/settings.local.json +0 -36
  232. package/.cursor/rules.md +0 -203
  233. package/.eslintrc.js +0 -31
  234. package/CLAUDE.md +0 -100
  235. package/bin/cli.js +0 -116
  236. package/docs/ADDING_FRAMEWORK_DETECTORS.md +0 -391
  237. package/docs/ADDING_NEW_PROJECT_TYPE.md +0 -156
  238. package/docs/ARCHITECTURE_RELATIONSHIPS.md +0 -411
  239. package/docs/CLI_AUTHENTICATION.md +0 -214
  240. package/docs/CLI_PAGE_DETECTION_REQUIREMENTS.md +0 -519
  241. package/docs/CRM-PIPELINES-SEQUENCES-SPEC.md +0 -429
  242. package/docs/DETECTOR_ARCHITECTURE.md +0 -326
  243. package/docs/DEVELOPMENT.md +0 -194
  244. package/docs/IMPLEMENTATION_PHASES.md +0 -468
  245. package/docs/INTEGRATION_PATHS_ARCHITECTURE.md +0 -1543
  246. package/docs/OAUTH_CLARIFICATION.md +0 -258
  247. package/docs/OAUTH_SETUP_GUIDE_TEMPLATE.md +0 -211
  248. package/docs/PHASE_0_PROGRESS.md +0 -120
  249. package/docs/PHASE_1_COMPLETE.md +0 -366
  250. package/docs/PHASE_SUMMARY.md +0 -149
  251. package/docs/PLAN.md +0 -511
  252. package/docs/README.md +0 -56
  253. package/docs/STRIPE_INTEGRATION.md +0 -447
  254. package/docs/SUMMARY.md +0 -230
  255. package/docs/UPDATED_PLAN.md +0 -447
  256. package/docs/mcp_server/MCP_EXTENSION_GUIDE.md +0 -1313
  257. package/docs/mcp_server/MCP_SERVER_ARCHITECTURE.md +0 -1481
  258. package/docs/mcp_server/applicationOntology.ts +0 -817
  259. package/docs/mcp_server/cliApplications.ts +0 -639
  260. package/docs/mcp_server/crmOntology.ts +0 -1063
  261. package/docs/mcp_server/eventOntology.ts +0 -1183
  262. package/docs/mcp_server/formsOntology.ts +0 -1401
  263. package/docs/mcp_server/ontologySchemas.ts +0 -185
  264. package/docs/mcp_server/schema.ts +0 -250
  265. package/docs/microsass_production_machine/CLI_API_REFERENCE.md +0 -1197
  266. package/docs/microsass_production_machine/CLI_PRODUCT_VISION.md +0 -676
  267. package/docs/microsass_production_machine/CLI_REQUIREMENTS.md +0 -606
  268. package/docs/microsass_production_machine/CONNECTED_APPLICATIONS_SPEC.md +0 -390
  269. package/docs/microsass_production_machine/IMPLEMENTATION_ROADMAP.md +0 -725
  270. package/docs/microsass_production_machine/OBJECT_MAPPINGS.md +0 -808
  271. package/docs/microsass_production_machine/REFERENCE_IMPLEMENTATION.md +0 -532
  272. package/src/api/backend-client.js +0 -449
  273. package/src/commands/api-keys.js +0 -119
  274. package/src/commands/connect.js +0 -243
  275. package/src/commands/login.js +0 -332
  276. package/src/commands/logout.js +0 -30
  277. package/src/commands/mcp-server.js +0 -85
  278. package/src/commands/mcp-setup.js +0 -686
  279. package/src/commands/pages.js +0 -317
  280. package/src/commands/scaffold.js +0 -409
  281. package/src/commands/spread.js +0 -861
  282. package/src/commands/status.js +0 -62
  283. package/src/commands/sync.js +0 -169
  284. package/src/commands/upgrade.js +0 -48
  285. package/src/config/config-manager.js +0 -206
  286. package/src/detectors/api-client-detector.js +0 -85
  287. package/src/detectors/base-detector.js +0 -77
  288. package/src/detectors/database-detector.js +0 -245
  289. package/src/detectors/expo-detector.js +0 -166
  290. package/src/detectors/github-detector.js +0 -74
  291. package/src/detectors/index.js +0 -106
  292. package/src/detectors/mapping-suggestor.js +0 -119
  293. package/src/detectors/model-detector.js +0 -318
  294. package/src/detectors/nextjs-detector.js +0 -139
  295. package/src/detectors/oauth-detector.js +0 -122
  296. package/src/detectors/page-detector.js +0 -480
  297. package/src/detectors/registry.js +0 -121
  298. package/src/generators/api-client-generator.js +0 -223
  299. package/src/generators/api-only/client.js +0 -683
  300. package/src/generators/api-only/index.js +0 -96
  301. package/src/generators/api-only/types.js +0 -618
  302. package/src/generators/api-only/webhooks.js +0 -377
  303. package/src/generators/env-generator.js +0 -191
  304. package/src/generators/expo-auth-generator.js +0 -1009
  305. package/src/generators/gitignore-generator.js +0 -92
  306. package/src/generators/index.js +0 -166
  307. package/src/generators/manifest-generator.js +0 -154
  308. package/src/generators/mcp-guide-generator.js +0 -256
  309. package/src/generators/nextauth-generator.js +0 -247
  310. package/src/generators/oauth-guide-generator.js +0 -277
  311. package/src/generators/quickstart/components/index.js +0 -1699
  312. package/src/generators/quickstart/components-mobile/index.js +0 -1440
  313. package/src/generators/quickstart/database/convex.js +0 -1257
  314. package/src/generators/quickstart/database/index.js +0 -34
  315. package/src/generators/quickstart/database/supabase.js +0 -1132
  316. package/src/generators/quickstart/hooks/index.js +0 -1065
  317. package/src/generators/quickstart/index.js +0 -191
  318. package/src/generators/quickstart/pages/index.js +0 -1466
  319. package/src/generators/quickstart/screens/index.js +0 -1498
  320. package/src/logo.js +0 -116
  321. package/src/mcp/auth.js +0 -127
  322. package/src/mcp/registry/domains/applications.js +0 -516
  323. package/src/mcp/registry/domains/benefits.js +0 -798
  324. package/src/mcp/registry/domains/codegen.js +0 -894
  325. package/src/mcp/registry/domains/core.js +0 -324
  326. package/src/mcp/registry/domains/crm.js +0 -591
  327. package/src/mcp/registry/domains/events.js +0 -649
  328. package/src/mcp/registry/domains/forms.js +0 -696
  329. package/src/mcp/registry/index.js +0 -164
  330. package/src/mcp/server.js +0 -116
  331. package/src/utils/file-utils.js +0 -117
  332. package/src/utils/init-helpers.js +0 -243
  333. package/src/utils/prompt-utils.js +0 -195
  334. package/templates/CLAUDE.md +0 -86
  335. package/tests/api-client-detector.test.js +0 -214
  336. package/tests/api-client-generator.test.js +0 -176
  337. package/tests/backend-client.test.js +0 -640
  338. package/tests/base-detector.test.js +0 -101
  339. package/tests/commands/login.test.js +0 -143
  340. package/tests/commands/logout.test.js +0 -84
  341. package/tests/commands/status.test.js +0 -167
  342. package/tests/config-manager.test.js +0 -321
  343. package/tests/database-detector.test.js +0 -221
  344. package/tests/detector-index.test.js +0 -209
  345. package/tests/detector-registry.test.js +0 -93
  346. package/tests/env-generator.test.js +0 -278
  347. package/tests/expo-detector.test.js +0 -263
  348. package/tests/file-utils.test.js +0 -194
  349. package/tests/generators-index.test.js +0 -454
  350. package/tests/github-detector.test.js +0 -145
  351. package/tests/gitignore-generator.test.js +0 -109
  352. package/tests/logo.test.js +0 -96
  353. package/tests/nextauth-generator.test.js +0 -255
  354. package/tests/nextjs-detector.test.js +0 -235
  355. package/tests/oauth-detector.test.js +0 -264
  356. package/tests/oauth-guide-generator.test.js +0 -273
  357. package/tests/page-detector.test.js +0 -371
@@ -1,409 +0,0 @@
1
- /**
2
- * Scaffold Command
3
- * Generates integration files based on the project manifest (.l4yercak3.json)
4
- * Diff-aware: only creates files that don't already exist
5
- */
6
-
7
- const fs = require('fs');
8
- const path = require('path');
9
- const configManager = require('../config/config-manager');
10
- const manifestGenerator = require('../generators/manifest-generator');
11
- const { ensureDir, checkFileOverwrite, GENERATED_HEADER } = require('../utils/file-utils');
12
- const { requireAuth } = require('../utils/init-helpers');
13
- const chalk = require('chalk');
14
-
15
- async function handleScaffold() {
16
- requireAuth(configManager);
17
-
18
- console.log(chalk.cyan(' 📦 Scaffolding integration files...\n'));
19
-
20
- try {
21
- const projectPath = process.cwd();
22
-
23
- // Step 1: Load manifest
24
- const manifest = manifestGenerator.loadManifest(projectPath);
25
- if (!manifest) {
26
- console.log(chalk.yellow(' ⚠️ No .l4yercak3.json manifest found.'));
27
- console.log(chalk.gray(' Run "l4yercak3 init" first to scan your project.\n'));
28
- process.exit(1);
29
- }
30
-
31
- const framework = manifest.framework || 'unknown';
32
- const routerType = manifest.routerType || 'pages';
33
- const isTypeScript = manifest.typescript || false;
34
- const ext = isTypeScript ? 'ts' : 'js';
35
-
36
- console.log(chalk.green(` ✅ Loaded manifest: ${framework} (${routerType} router, ${isTypeScript ? 'TypeScript' : 'JavaScript'})`));
37
- console.log(chalk.gray(` ${manifest.detectedModels?.length || 0} models, ${manifest.detectedRoutes?.length || 0} routes\n`));
38
-
39
- // Step 2: Determine which files to generate
40
- const filesToGenerate = [];
41
-
42
- // a) lib/l4yercak3 client wrapper
43
- const clientDir = path.join(projectPath, 'lib');
44
- const clientFile = path.join(clientDir, `l4yercak3.${ext}`);
45
- filesToGenerate.push({
46
- path: clientFile,
47
- name: `lib/l4yercak3.${ext}`,
48
- content: generateClientWrapper(manifest, isTypeScript),
49
- });
50
-
51
- // b) Webhook handler (framework-specific path)
52
- let webhookFile;
53
- if (framework === 'nextjs' && routerType === 'app') {
54
- webhookFile = path.join(projectPath, 'app', 'api', 'webhooks', 'l4yercak3', `route.${ext}`);
55
- } else if (framework === 'nextjs') {
56
- webhookFile = path.join(projectPath, 'pages', 'api', 'webhooks', `l4yercak3.${ext}`);
57
- }
58
-
59
- if (webhookFile) {
60
- const relPath = path.relative(projectPath, webhookFile);
61
- filesToGenerate.push({
62
- path: webhookFile,
63
- name: relPath,
64
- content: generateWebhookHandler(manifest, isTypeScript, routerType),
65
- });
66
- }
67
-
68
- // c) Types file (if TypeScript and has models/mappings)
69
- if (isTypeScript && manifest.detectedModels?.length > 0) {
70
- const typesDir = path.join(projectPath, 'types');
71
- const typesFile = path.join(typesDir, 'l4yercak3.ts');
72
- filesToGenerate.push({
73
- path: typesFile,
74
- name: 'types/l4yercak3.ts',
75
- content: generateTypes(manifest),
76
- });
77
- }
78
-
79
- // Step 3: Diff-aware generation
80
- console.log(chalk.cyan(' 🔍 Checking existing files...\n'));
81
- const created = [];
82
- const skipped = [];
83
-
84
- for (const file of filesToGenerate) {
85
- const action = await checkFileOverwrite(file.path, { defaultAction: 'skip' });
86
-
87
- if (action === 'skip') {
88
- skipped.push(file.name);
89
- continue;
90
- }
91
-
92
- // Ensure directory exists
93
- ensureDir(path.dirname(file.path));
94
-
95
- // Write file
96
- fs.writeFileSync(file.path, file.content, 'utf8');
97
- created.push(file.name);
98
- }
99
-
100
- // Step 4: Display results
101
- if (created.length > 0) {
102
- console.log(chalk.green(' ✅ Files created:\n'));
103
- for (const name of created) {
104
- console.log(chalk.gray(` • ${name}`));
105
- }
106
- }
107
-
108
- if (skipped.length > 0) {
109
- console.log(chalk.gray(`\n ⏭️ Skipped (already exist):\n`));
110
- for (const name of skipped) {
111
- console.log(chalk.gray(` • ${name}`));
112
- }
113
- }
114
-
115
- if (created.length === 0 && skipped.length > 0) {
116
- console.log(chalk.green('\n ✅ All integration files already exist. Nothing to generate.\n'));
117
- } else {
118
- console.log(chalk.cyan('\n 🎉 Scaffold complete!\n'));
119
- }
120
-
121
- console.log(chalk.gray(' Next steps:'));
122
- console.log(chalk.gray(' • Import the L4YERCAK3 client: import { l4yercak3 } from "@/lib/l4yercak3"'));
123
- console.log(chalk.gray(' • Run "l4yercak3 sync" after changing your project structure\n'));
124
-
125
- } catch (error) {
126
- console.error(chalk.red(`\n ❌ Error: ${error.message}\n`));
127
- if (process.env.L4YERCAK3_DEBUG && error.stack) {
128
- console.error(chalk.gray(error.stack));
129
- }
130
- process.exit(1);
131
- }
132
- }
133
-
134
- /**
135
- * Generate the L4YERCAK3 client wrapper
136
- */
137
- function generateClientWrapper(manifest, isTypeScript) {
138
- const mappings = manifest.suggestedMappings || [];
139
- const hasContact = mappings.some(m => m.platformType === 'contact');
140
- const hasBooking = mappings.some(m => m.platformType === 'booking');
141
- const hasEvent = mappings.some(m => m.platformType === 'event');
142
- const hasProduct = mappings.some(m => m.platformType === 'product');
143
-
144
- const typeAnnotation = isTypeScript ? ': string' : '';
145
- const typeImport = isTypeScript
146
- ? `import type { L4yercak3Config } from '@/types/l4yercak3';\n\n`
147
- : '';
148
-
149
- return `/**
150
- * L4YERCAK3 API Client
151
- * ${GENERATED_HEADER}
152
- *
153
- * Usage: import { l4yercak3 } from '@/lib/l4yercak3';
154
- */
155
-
156
- ${typeImport}const API_KEY${typeAnnotation} = process.env.L4YERCAK3_API_KEY || '';
157
- const BASE_URL${typeAnnotation} = process.env.L4YERCAK3_BACKEND_URL || 'https://agreeable-lion-828.convex.site';
158
- const ORG_ID${typeAnnotation} = process.env.L4YERCAK3_ORG_ID || '';
159
- const APP_ID${typeAnnotation} = process.env.L4YERCAK3_APP_ID || '';
160
-
161
- class L4yercak3Client {
162
- constructor() {
163
- this.apiKey = API_KEY;
164
- this.baseUrl = BASE_URL;
165
- this.orgId = ORG_ID;
166
- this.appId = APP_ID;
167
- }
168
-
169
- async request(method${typeAnnotation ? ': string' : ''}, endpoint${typeAnnotation ? ': string' : ''}, data${isTypeScript ? '?: Record<string, unknown>' : ''}) {
170
- const url = \`\${this.baseUrl}\${endpoint}\`;
171
- const headers${isTypeScript ? ': Record<string, string>' : ''} = {
172
- 'Content-Type': 'application/json',
173
- 'Authorization': \`Bearer \${this.apiKey}\`,
174
- 'X-Organization-Id': this.orgId,
175
- 'X-Application-Id': this.appId,
176
- };
177
-
178
- const options${isTypeScript ? ': RequestInit' : ''} = { method, headers };
179
- if (data && (method === 'POST' || method === 'PUT' || method === 'PATCH')) {
180
- options.body = JSON.stringify(data);
181
- }
182
-
183
- const response = await fetch(url, options);
184
- if (!response.ok) {
185
- const error = await response.json().catch(() => ({}));
186
- throw new Error(error.message || \`API error: \${response.status}\`);
187
- }
188
- return response.json();
189
- }
190
- ${hasContact ? `
191
- // Contact methods
192
- async getContacts() {
193
- return this.request('GET', '/api/v1/contacts');
194
- }
195
-
196
- async createContact(data${isTypeScript ? ': Record<string, unknown>' : ''}) {
197
- return this.request('POST', '/api/v1/contacts', data);
198
- }
199
- ` : ''}${hasBooking ? `
200
- // Booking methods
201
- async getBookings() {
202
- return this.request('GET', '/api/v1/bookings');
203
- }
204
-
205
- async createBooking(data${isTypeScript ? ': Record<string, unknown>' : ''}) {
206
- return this.request('POST', '/api/v1/bookings', data);
207
- }
208
- ` : ''}${hasEvent ? `
209
- // Event methods
210
- async getEvents() {
211
- return this.request('GET', '/api/v1/events');
212
- }
213
-
214
- async createEvent(data${isTypeScript ? ': Record<string, unknown>' : ''}) {
215
- return this.request('POST', '/api/v1/events', data);
216
- }
217
- ` : ''}${hasProduct ? `
218
- // Product methods
219
- async getProducts() {
220
- return this.request('GET', '/api/v1/products');
221
- }
222
-
223
- async createProduct(data${isTypeScript ? ': Record<string, unknown>' : ''}) {
224
- return this.request('POST', '/api/v1/products', data);
225
- }
226
- ` : ''}
227
- // Generic resource methods
228
- async get(resource${typeAnnotation ? ': string' : ''}) {
229
- return this.request('GET', \`/api/v1/\${resource}\`);
230
- }
231
-
232
- async create(resource${typeAnnotation ? ': string' : ''}, data${isTypeScript ? ': Record<string, unknown>' : ''}) {
233
- return this.request('POST', \`/api/v1/\${resource}\`, data);
234
- }
235
-
236
- async update(resource${typeAnnotation ? ': string' : ''}, id${typeAnnotation ? ': string' : ''}, data${isTypeScript ? ': Record<string, unknown>' : ''}) {
237
- return this.request('PATCH', \`/api/v1/\${resource}/\${id}\`, data);
238
- }
239
-
240
- async remove(resource${typeAnnotation ? ': string' : ''}, id${typeAnnotation ? ': string' : ''}) {
241
- return this.request('DELETE', \`/api/v1/\${resource}/\${id}\`);
242
- }
243
- }
244
-
245
- export const l4yercak3 = new L4yercak3Client();
246
- export default l4yercak3;
247
- `;
248
- }
249
-
250
- /**
251
- * Generate webhook handler
252
- */
253
- function generateWebhookHandler(manifest, isTypeScript, routerType) {
254
- if (routerType === 'app') {
255
- return `/**
256
- * L4YERCAK3 Webhook Handler (App Router)
257
- * ${GENERATED_HEADER}
258
- *
259
- * Receives webhook events from the L4YERCAK3 platform.
260
- * Configure your webhook URL in the L4YERCAK3 dashboard.
261
- */
262
-
263
- import { NextResponse } from 'next/server';
264
-
265
- export async function POST(request${isTypeScript ? ': Request' : ''}) {
266
- try {
267
- const body = await request.json();
268
- const eventType = body.type;
269
-
270
- // Verify webhook signature (recommended for production)
271
- // const signature = request.headers.get('x-l4yercak3-signature');
272
-
273
- switch (eventType) {
274
- case 'contact.created':
275
- case 'contact.updated':
276
- // Handle contact events
277
- console.log(\`[L4YERCAK3] \${eventType}:\`, body.data);
278
- break;
279
-
280
- case 'booking.created':
281
- case 'booking.updated':
282
- // Handle booking events
283
- console.log(\`[L4YERCAK3] \${eventType}:\`, body.data);
284
- break;
285
-
286
- default:
287
- console.log(\`[L4YERCAK3] Unhandled event: \${eventType}\`);
288
- }
289
-
290
- return NextResponse.json({ received: true });
291
- } catch (error) {
292
- console.error('[L4YERCAK3] Webhook error:', error);
293
- return NextResponse.json({ error: 'Webhook processing failed' }, { status: 500 });
294
- }
295
- }
296
- `;
297
- }
298
-
299
- // Pages Router
300
- return `/**
301
- * L4YERCAK3 Webhook Handler (Pages Router)
302
- * ${GENERATED_HEADER}
303
- *
304
- * Receives webhook events from the L4YERCAK3 platform.
305
- * Configure your webhook URL in the L4YERCAK3 dashboard.
306
- */
307
-
308
- export default async function handler(req, res) {
309
- if (req.method !== 'POST') {
310
- return res.status(405).json({ error: 'Method not allowed' });
311
- }
312
-
313
- try {
314
- const body = req.body;
315
- const eventType = body.type;
316
-
317
- // Verify webhook signature (recommended for production)
318
- // const signature = req.headers['x-l4yercak3-signature'];
319
-
320
- switch (eventType) {
321
- case 'contact.created':
322
- case 'contact.updated':
323
- // Handle contact events
324
- console.log(\`[L4YERCAK3] \${eventType}:\`, body.data);
325
- break;
326
-
327
- case 'booking.created':
328
- case 'booking.updated':
329
- // Handle booking events
330
- console.log(\`[L4YERCAK3] \${eventType}:\`, body.data);
331
- break;
332
-
333
- default:
334
- console.log(\`[L4YERCAK3] Unhandled event: \${eventType}\`);
335
- }
336
-
337
- return res.status(200).json({ received: true });
338
- } catch (error) {
339
- console.error('[L4YERCAK3] Webhook error:', error);
340
- return res.status(500).json({ error: 'Webhook processing failed' });
341
- }
342
- }
343
- `;
344
- }
345
-
346
- /**
347
- * Generate TypeScript types based on manifest models and mappings
348
- */
349
- function generateTypes(manifest) {
350
- const models = manifest.detectedModels || [];
351
- const mappings = manifest.suggestedMappings || [];
352
-
353
- let content = `/**
354
- * L4YERCAK3 Types
355
- * ${GENERATED_HEADER}
356
- *
357
- * Types generated from your project's detected models and platform mappings.
358
- */
359
-
360
- export interface L4yercak3Config {
361
- apiKey: string;
362
- baseUrl: string;
363
- orgId: string;
364
- appId: string;
365
- }
366
-
367
- export interface WebhookEvent {
368
- type: string;
369
- data: Record<string, unknown>;
370
- timestamp: number;
371
- applicationId: string;
372
- }
373
-
374
- `;
375
-
376
- // Generate interfaces for each mapping
377
- for (const mapping of mappings) {
378
- const model = models.find(m => m.name === mapping.localModel);
379
- if (model) {
380
- content += `/**
381
- * Platform mapping: ${model.name} → ${mapping.platformType} (${mapping.confidence}% confidence)
382
- * Source: ${model.source}
383
- */
384
- export interface ${model.name}Mapping {
385
- `;
386
- for (const field of model.fields) {
387
- content += ` ${field}: unknown;\n`;
388
- }
389
- content += ` // Platform fields
390
- _platformType: '${mapping.platformType}';
391
- _platformId?: string;
392
- }\n\n`;
393
- }
394
- }
395
-
396
- // Generate union type of all platform types used
397
- const platformTypes = [...new Set(mappings.map(m => m.platformType))];
398
- if (platformTypes.length > 0) {
399
- content += `export type PlatformType = ${platformTypes.map(t => `'${t}'`).join(' | ')};\n`;
400
- }
401
-
402
- return content;
403
- }
404
-
405
- module.exports = {
406
- command: 'scaffold',
407
- description: 'Generate integration files based on your project manifest',
408
- handler: handleScaffold,
409
- };