@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,1065 +0,0 @@
1
- /**
2
- * React Hooks Generator
3
- * Generates React Query hooks for L4YERCAK3 data fetching
4
- */
5
-
6
- const fs = require('fs');
7
- const path = require('path');
8
- const { ensureDir, writeFileWithBackup, checkFileOverwrite } = require('../../../utils/file-utils');
9
-
10
- class HooksGenerator {
11
- /**
12
- * Generate React hooks based on selected features
13
- * @param {Object} options - Generation options
14
- * @returns {Promise<Object>} - Generated file paths
15
- */
16
- /**
17
- * Check if framework is Expo/React Native
18
- */
19
- isMobileFramework(frameworkType) {
20
- return ['expo', 'react-native'].includes(frameworkType);
21
- }
22
-
23
- async generate(options) {
24
- const { projectPath, features = [], frameworkType } = options;
25
- const isMobile = this.isMobileFramework(frameworkType);
26
-
27
- const results = {};
28
-
29
- // Determine output directory based on framework
30
- let outputDir;
31
- if (isMobile) {
32
- // Expo typically uses src/lib or just lib
33
- if (fs.existsSync(path.join(projectPath, 'src'))) {
34
- outputDir = path.join(projectPath, 'src', 'lib', 'l4yercak3', 'hooks');
35
- } else {
36
- outputDir = path.join(projectPath, 'lib', 'l4yercak3', 'hooks');
37
- }
38
- } else {
39
- // Next.js uses src/lib
40
- if (fs.existsSync(path.join(projectPath, 'src'))) {
41
- outputDir = path.join(projectPath, 'src', 'lib', 'l4yercak3', 'hooks');
42
- } else {
43
- outputDir = path.join(projectPath, 'lib', 'l4yercak3', 'hooks');
44
- }
45
- }
46
-
47
- ensureDir(outputDir);
48
-
49
- // Generate hooks based on features
50
- if (features.includes('crm')) {
51
- results.contacts = await this.generateContactsHook(outputDir, options);
52
- results.organizations = await this.generateOrganizationsHook(outputDir, options);
53
- }
54
-
55
- if (features.includes('events')) {
56
- results.events = await this.generateEventsHook(outputDir, options);
57
- }
58
-
59
- if (features.includes('forms')) {
60
- results.forms = await this.generateFormsHook(outputDir, options);
61
- }
62
-
63
- if (features.includes('products') || features.includes('checkout')) {
64
- results.products = await this.generateProductsHook(outputDir, options);
65
- }
66
-
67
- if (features.includes('invoicing')) {
68
- results.invoices = await this.generateInvoicesHook(outputDir, options);
69
- }
70
-
71
- // Generate index file
72
- results.index = await this.generateIndex(outputDir, options, Object.keys(results));
73
-
74
- return results;
75
- }
76
-
77
- async generateContactsHook(outputDir, options) {
78
- const { isTypeScript, selectedDatabase } = options;
79
- const extension = isTypeScript ? 'ts' : 'js';
80
- const outputPath = path.join(outputDir, `use-contacts.${extension}`);
81
-
82
- const action = await checkFileOverwrite(outputPath);
83
- if (action === 'skip') {
84
- return null;
85
- }
86
-
87
- const content = isTypeScript
88
- ? this.generateContactsHookTS(selectedDatabase)
89
- : this.generateContactsHookJS(selectedDatabase);
90
-
91
- return writeFileWithBackup(outputPath, content, action);
92
- }
93
-
94
- generateContactsHookTS(database) {
95
- const isConvex = database === 'convex';
96
-
97
- return `/**
98
- * Contacts Hooks
99
- * Auto-generated by @l4yercak3/cli
100
- */
101
-
102
- ${isConvex ? `import { useQuery, useMutation } from "convex/react";
103
- import { api } from "@/convex/_generated/api";
104
- import type { Id } from "@/convex/_generated/dataModel";` : `import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
105
- import { getL4yercak3Client } from '../client';
106
- import type { Contact, ContactCreateInput, ContactUpdateInput } from '../types';`}
107
-
108
- ${isConvex ? `
109
- // ============ Convex Hooks ============
110
-
111
- export function useContacts(options?: { status?: string; subtype?: string; limit?: number }) {
112
- return useQuery(api.objects.list, {
113
- type: "contact",
114
- status: options?.status,
115
- subtype: options?.subtype,
116
- limit: options?.limit,
117
- });
118
- }
119
-
120
- export function useContact(id: Id<"objects"> | undefined) {
121
- return useQuery(api.objects.get, id ? { id } : "skip");
122
- }
123
-
124
- export function useCreateContact() {
125
- return useMutation(api.objects.create);
126
- }
127
-
128
- export function useUpdateContact() {
129
- return useMutation(api.objects.update);
130
- }
131
-
132
- export function useDeleteContact() {
133
- return useMutation(api.objects.remove);
134
- }
135
-
136
- export function useSearchContacts(searchTerm: string) {
137
- return useQuery(
138
- api.objects.search,
139
- searchTerm ? { type: "contact", searchTerm } : "skip"
140
- );
141
- }
142
- ` : `
143
- // ============ React Query Hooks ============
144
-
145
- const client = getL4yercak3Client();
146
-
147
- export function useContacts(options?: {
148
- status?: 'active' | 'inactive' | 'archived';
149
- subtype?: 'customer' | 'lead' | 'prospect' | 'partner';
150
- search?: string;
151
- limit?: number;
152
- }) {
153
- return useQuery({
154
- queryKey: ['contacts', options],
155
- queryFn: () => client.listContacts(options),
156
- });
157
- }
158
-
159
- export function useContact(id: string | undefined, options?: {
160
- includeActivities?: boolean;
161
- includeNotes?: boolean;
162
- }) {
163
- return useQuery({
164
- queryKey: ['contact', id, options],
165
- queryFn: () => client.getContact(id!, options),
166
- enabled: !!id,
167
- });
168
- }
169
-
170
- export function useCreateContact() {
171
- const queryClient = useQueryClient();
172
-
173
- return useMutation({
174
- mutationFn: (data: ContactCreateInput) => client.createContact(data),
175
- onSuccess: () => {
176
- queryClient.invalidateQueries({ queryKey: ['contacts'] });
177
- },
178
- });
179
- }
180
-
181
- export function useUpdateContact() {
182
- const queryClient = useQueryClient();
183
-
184
- return useMutation({
185
- mutationFn: ({ id, data }: { id: string; data: ContactUpdateInput }) =>
186
- client.updateContact(id, data),
187
- onSuccess: (_, variables) => {
188
- queryClient.invalidateQueries({ queryKey: ['contacts'] });
189
- queryClient.invalidateQueries({ queryKey: ['contact', variables.id] });
190
- },
191
- });
192
- }
193
-
194
- export function useDeleteContact() {
195
- const queryClient = useQueryClient();
196
-
197
- return useMutation({
198
- mutationFn: (id: string) => client.deleteContact(id),
199
- onSuccess: () => {
200
- queryClient.invalidateQueries({ queryKey: ['contacts'] });
201
- },
202
- });
203
- }
204
-
205
- export function useAddTagsToContact() {
206
- const queryClient = useQueryClient();
207
-
208
- return useMutation({
209
- mutationFn: ({ id, tags }: { id: string; tags: string[] }) =>
210
- client.addTagsToContact(id, tags),
211
- onSuccess: (_, variables) => {
212
- queryClient.invalidateQueries({ queryKey: ['contact', variables.id] });
213
- },
214
- });
215
- }
216
- `}`;
217
- }
218
-
219
- generateContactsHookJS(database) {
220
- const isConvex = database === 'convex';
221
-
222
- return `/**
223
- * Contacts Hooks
224
- * Auto-generated by @l4yercak3/cli
225
- */
226
-
227
- ${isConvex ? `const { useQuery, useMutation } = require("convex/react");
228
- const { api } = require("@/convex/_generated/api");` : `const { useQuery, useMutation, useQueryClient } = require('@tanstack/react-query');
229
- const { getL4yercak3Client } = require('../client');`}
230
-
231
- ${isConvex ? `
232
- // ============ Convex Hooks ============
233
-
234
- function useContacts(options = {}) {
235
- return useQuery(api.objects.list, {
236
- type: "contact",
237
- status: options.status,
238
- subtype: options.subtype,
239
- limit: options.limit,
240
- });
241
- }
242
-
243
- function useContact(id) {
244
- return useQuery(api.objects.get, id ? { id } : "skip");
245
- }
246
-
247
- function useCreateContact() {
248
- return useMutation(api.objects.create);
249
- }
250
-
251
- function useUpdateContact() {
252
- return useMutation(api.objects.update);
253
- }
254
-
255
- function useDeleteContact() {
256
- return useMutation(api.objects.remove);
257
- }
258
-
259
- function useSearchContacts(searchTerm) {
260
- return useQuery(
261
- api.objects.search,
262
- searchTerm ? { type: "contact", searchTerm } : "skip"
263
- );
264
- }
265
-
266
- module.exports = {
267
- useContacts,
268
- useContact,
269
- useCreateContact,
270
- useUpdateContact,
271
- useDeleteContact,
272
- useSearchContacts,
273
- };
274
- ` : `
275
- // ============ React Query Hooks ============
276
-
277
- const client = getL4yercak3Client();
278
-
279
- function useContacts(options = {}) {
280
- return useQuery({
281
- queryKey: ['contacts', options],
282
- queryFn: () => client.listContacts(options),
283
- });
284
- }
285
-
286
- function useContact(id, options = {}) {
287
- return useQuery({
288
- queryKey: ['contact', id, options],
289
- queryFn: () => client.getContact(id, options),
290
- enabled: !!id,
291
- });
292
- }
293
-
294
- function useCreateContact() {
295
- const queryClient = useQueryClient();
296
-
297
- return useMutation({
298
- mutationFn: (data) => client.createContact(data),
299
- onSuccess: () => {
300
- queryClient.invalidateQueries({ queryKey: ['contacts'] });
301
- },
302
- });
303
- }
304
-
305
- function useUpdateContact() {
306
- const queryClient = useQueryClient();
307
-
308
- return useMutation({
309
- mutationFn: ({ id, data }) => client.updateContact(id, data),
310
- onSuccess: (_, variables) => {
311
- queryClient.invalidateQueries({ queryKey: ['contacts'] });
312
- queryClient.invalidateQueries({ queryKey: ['contact', variables.id] });
313
- },
314
- });
315
- }
316
-
317
- function useDeleteContact() {
318
- const queryClient = useQueryClient();
319
-
320
- return useMutation({
321
- mutationFn: (id) => client.deleteContact(id),
322
- onSuccess: () => {
323
- queryClient.invalidateQueries({ queryKey: ['contacts'] });
324
- },
325
- });
326
- }
327
-
328
- module.exports = {
329
- useContacts,
330
- useContact,
331
- useCreateContact,
332
- useUpdateContact,
333
- useDeleteContact,
334
- };
335
- `}`;
336
- }
337
-
338
- async generateOrganizationsHook(outputDir, options) {
339
- const { isTypeScript } = options;
340
- const extension = isTypeScript ? 'ts' : 'js';
341
- const outputPath = path.join(outputDir, `use-organizations.${extension}`);
342
-
343
- const action = await checkFileOverwrite(outputPath);
344
- if (action === 'skip') {
345
- return null;
346
- }
347
-
348
- const content = isTypeScript
349
- ? `/**
350
- * Organizations Hooks
351
- * Auto-generated by @l4yercak3/cli
352
- */
353
-
354
- import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
355
- import { getL4yercak3Client } from '../client';
356
- import type { Organization, OrganizationCreateInput } from '../types';
357
-
358
- const client = getL4yercak3Client();
359
-
360
- export function useOrganizations(options?: {
361
- subtype?: 'customer' | 'prospect' | 'partner' | 'vendor';
362
- search?: string;
363
- limit?: number;
364
- }) {
365
- return useQuery({
366
- queryKey: ['organizations', options],
367
- queryFn: () => client.listOrganizations(options),
368
- });
369
- }
370
-
371
- export function useOrganization(id: string | undefined, options?: {
372
- includeContacts?: boolean;
373
- }) {
374
- return useQuery({
375
- queryKey: ['organization', id, options],
376
- queryFn: () => client.getOrganization(id!, options),
377
- enabled: !!id,
378
- });
379
- }
380
-
381
- export function useCreateOrganization() {
382
- const queryClient = useQueryClient();
383
-
384
- return useMutation({
385
- mutationFn: (data: OrganizationCreateInput) => client.createOrganization(data),
386
- onSuccess: () => {
387
- queryClient.invalidateQueries({ queryKey: ['organizations'] });
388
- },
389
- });
390
- }
391
- `
392
- : `/**
393
- * Organizations Hooks
394
- * Auto-generated by @l4yercak3/cli
395
- */
396
-
397
- const { useQuery, useMutation, useQueryClient } = require('@tanstack/react-query');
398
- const { getL4yercak3Client } = require('../client');
399
-
400
- const client = getL4yercak3Client();
401
-
402
- function useOrganizations(options = {}) {
403
- return useQuery({
404
- queryKey: ['organizations', options],
405
- queryFn: () => client.listOrganizations(options),
406
- });
407
- }
408
-
409
- function useOrganization(id, options = {}) {
410
- return useQuery({
411
- queryKey: ['organization', id, options],
412
- queryFn: () => client.getOrganization(id, options),
413
- enabled: !!id,
414
- });
415
- }
416
-
417
- function useCreateOrganization() {
418
- const queryClient = useQueryClient();
419
-
420
- return useMutation({
421
- mutationFn: (data) => client.createOrganization(data),
422
- onSuccess: () => {
423
- queryClient.invalidateQueries({ queryKey: ['organizations'] });
424
- },
425
- });
426
- }
427
-
428
- module.exports = {
429
- useOrganizations,
430
- useOrganization,
431
- useCreateOrganization,
432
- };
433
- `;
434
-
435
- return writeFileWithBackup(outputPath, content, action);
436
- }
437
-
438
- async generateEventsHook(outputDir, options) {
439
- const { isTypeScript } = options;
440
- const extension = isTypeScript ? 'ts' : 'js';
441
- const outputPath = path.join(outputDir, `use-events.${extension}`);
442
-
443
- const action = await checkFileOverwrite(outputPath);
444
- if (action === 'skip') {
445
- return null;
446
- }
447
-
448
- const content = isTypeScript
449
- ? `/**
450
- * Events Hooks
451
- * Auto-generated by @l4yercak3/cli
452
- */
453
-
454
- import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
455
- import { getL4yercak3Client } from '../client';
456
- import type { Event, EventCreateInput, Attendee } from '../types';
457
-
458
- const client = getL4yercak3Client();
459
-
460
- export function useEvents(options?: {
461
- status?: 'draft' | 'published' | 'cancelled' | 'completed';
462
- fromDate?: string;
463
- toDate?: string;
464
- limit?: number;
465
- }) {
466
- return useQuery({
467
- queryKey: ['events', options],
468
- queryFn: () => client.listEvents(options),
469
- });
470
- }
471
-
472
- export function useEvent(id: string | undefined, options?: {
473
- includeProducts?: boolean;
474
- includeSponsors?: boolean;
475
- includeForms?: boolean;
476
- }) {
477
- return useQuery({
478
- queryKey: ['event', id, options],
479
- queryFn: () => client.getEvent(id!, options),
480
- enabled: !!id,
481
- });
482
- }
483
-
484
- export function useEventAttendees(eventId: string | undefined, options?: {
485
- status?: 'registered' | 'checked_in' | 'cancelled' | 'no_show';
486
- limit?: number;
487
- }) {
488
- return useQuery({
489
- queryKey: ['eventAttendees', eventId, options],
490
- queryFn: () => client.getEventAttendees(eventId!, options),
491
- enabled: !!eventId,
492
- });
493
- }
494
-
495
- export function useCreateEvent() {
496
- const queryClient = useQueryClient();
497
-
498
- return useMutation({
499
- mutationFn: (data: EventCreateInput) => client.createEvent(data),
500
- onSuccess: () => {
501
- queryClient.invalidateQueries({ queryKey: ['events'] });
502
- },
503
- });
504
- }
505
-
506
- export function useCheckInAttendee() {
507
- const queryClient = useQueryClient();
508
-
509
- return useMutation({
510
- mutationFn: ({ eventId, attendeeId }: { eventId: string; attendeeId: string }) =>
511
- client.checkInAttendee(eventId, attendeeId),
512
- onSuccess: (_, variables) => {
513
- queryClient.invalidateQueries({ queryKey: ['eventAttendees', variables.eventId] });
514
- },
515
- });
516
- }
517
- `
518
- : `/**
519
- * Events Hooks
520
- * Auto-generated by @l4yercak3/cli
521
- */
522
-
523
- const { useQuery, useMutation, useQueryClient } = require('@tanstack/react-query');
524
- const { getL4yercak3Client } = require('../client');
525
-
526
- const client = getL4yercak3Client();
527
-
528
- function useEvents(options = {}) {
529
- return useQuery({
530
- queryKey: ['events', options],
531
- queryFn: () => client.listEvents(options),
532
- });
533
- }
534
-
535
- function useEvent(id, options = {}) {
536
- return useQuery({
537
- queryKey: ['event', id, options],
538
- queryFn: () => client.getEvent(id, options),
539
- enabled: !!id,
540
- });
541
- }
542
-
543
- function useEventAttendees(eventId, options = {}) {
544
- return useQuery({
545
- queryKey: ['eventAttendees', eventId, options],
546
- queryFn: () => client.getEventAttendees(eventId, options),
547
- enabled: !!eventId,
548
- });
549
- }
550
-
551
- function useCreateEvent() {
552
- const queryClient = useQueryClient();
553
-
554
- return useMutation({
555
- mutationFn: (data) => client.createEvent(data),
556
- onSuccess: () => {
557
- queryClient.invalidateQueries({ queryKey: ['events'] });
558
- },
559
- });
560
- }
561
-
562
- function useCheckInAttendee() {
563
- const queryClient = useQueryClient();
564
-
565
- return useMutation({
566
- mutationFn: ({ eventId, attendeeId }) => client.checkInAttendee(eventId, attendeeId),
567
- onSuccess: (_, variables) => {
568
- queryClient.invalidateQueries({ queryKey: ['eventAttendees', variables.eventId] });
569
- },
570
- });
571
- }
572
-
573
- module.exports = {
574
- useEvents,
575
- useEvent,
576
- useEventAttendees,
577
- useCreateEvent,
578
- useCheckInAttendee,
579
- };
580
- `;
581
-
582
- return writeFileWithBackup(outputPath, content, action);
583
- }
584
-
585
- async generateFormsHook(outputDir, options) {
586
- const { isTypeScript } = options;
587
- const extension = isTypeScript ? 'ts' : 'js';
588
- const outputPath = path.join(outputDir, `use-forms.${extension}`);
589
-
590
- const action = await checkFileOverwrite(outputPath);
591
- if (action === 'skip') {
592
- return null;
593
- }
594
-
595
- const content = isTypeScript
596
- ? `/**
597
- * Forms Hooks
598
- * Auto-generated by @l4yercak3/cli
599
- */
600
-
601
- import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
602
- import { getL4yercak3Client } from '../client';
603
- import type { Form, FormSubmission } from '../types';
604
-
605
- const client = getL4yercak3Client();
606
-
607
- export function useForms(options?: {
608
- status?: 'draft' | 'published' | 'closed';
609
- eventId?: string;
610
- subtype?: 'registration' | 'survey' | 'application' | 'feedback' | 'contact';
611
- limit?: number;
612
- }) {
613
- return useQuery({
614
- queryKey: ['forms', options],
615
- queryFn: () => client.listForms(options),
616
- });
617
- }
618
-
619
- export function useForm(id: string | undefined) {
620
- return useQuery({
621
- queryKey: ['form', id],
622
- queryFn: () => client.getForm(id!),
623
- enabled: !!id,
624
- });
625
- }
626
-
627
- export function useFormResponses(formId: string | undefined, options?: {
628
- status?: 'submitted' | 'reviewed' | 'approved' | 'rejected';
629
- limit?: number;
630
- }) {
631
- return useQuery({
632
- queryKey: ['formResponses', formId, options],
633
- queryFn: () => client.getFormResponses(formId!, options),
634
- enabled: !!formId,
635
- });
636
- }
637
-
638
- export function useSubmitForm() {
639
- const queryClient = useQueryClient();
640
-
641
- return useMutation({
642
- mutationFn: ({ formId, data }: { formId: string; data: Record<string, unknown> }) =>
643
- client.submitForm(formId, data),
644
- onSuccess: (_, variables) => {
645
- queryClient.invalidateQueries({ queryKey: ['formResponses', variables.formId] });
646
- },
647
- });
648
- }
649
- `
650
- : `/**
651
- * Forms Hooks
652
- * Auto-generated by @l4yercak3/cli
653
- */
654
-
655
- const { useQuery, useMutation, useQueryClient } = require('@tanstack/react-query');
656
- const { getL4yercak3Client } = require('../client');
657
-
658
- const client = getL4yercak3Client();
659
-
660
- function useForms(options = {}) {
661
- return useQuery({
662
- queryKey: ['forms', options],
663
- queryFn: () => client.listForms(options),
664
- });
665
- }
666
-
667
- function useForm(id) {
668
- return useQuery({
669
- queryKey: ['form', id],
670
- queryFn: () => client.getForm(id),
671
- enabled: !!id,
672
- });
673
- }
674
-
675
- function useFormResponses(formId, options = {}) {
676
- return useQuery({
677
- queryKey: ['formResponses', formId, options],
678
- queryFn: () => client.getFormResponses(formId, options),
679
- enabled: !!formId,
680
- });
681
- }
682
-
683
- function useSubmitForm() {
684
- const queryClient = useQueryClient();
685
-
686
- return useMutation({
687
- mutationFn: ({ formId, data }) => client.submitForm(formId, data),
688
- onSuccess: (_, variables) => {
689
- queryClient.invalidateQueries({ queryKey: ['formResponses', variables.formId] });
690
- },
691
- });
692
- }
693
-
694
- module.exports = {
695
- useForms,
696
- useForm,
697
- useFormResponses,
698
- useSubmitForm,
699
- };
700
- `;
701
-
702
- return writeFileWithBackup(outputPath, content, action);
703
- }
704
-
705
- async generateProductsHook(outputDir, options) {
706
- const { isTypeScript } = options;
707
- const extension = isTypeScript ? 'ts' : 'js';
708
- const outputPath = path.join(outputDir, `use-products.${extension}`);
709
-
710
- const action = await checkFileOverwrite(outputPath);
711
- if (action === 'skip') {
712
- return null;
713
- }
714
-
715
- const content = isTypeScript
716
- ? `/**
717
- * Products & Checkout Hooks
718
- * Auto-generated by @l4yercak3/cli
719
- */
720
-
721
- import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
722
- import { getL4yercak3Client } from '../client';
723
- import type { Product, Order } from '../types';
724
-
725
- const client = getL4yercak3Client();
726
-
727
- export function useProducts(options?: {
728
- eventId?: string;
729
- status?: 'active' | 'sold_out' | 'hidden';
730
- category?: string;
731
- limit?: number;
732
- }) {
733
- return useQuery({
734
- queryKey: ['products', options],
735
- queryFn: () => client.listProducts(options),
736
- });
737
- }
738
-
739
- export function useProduct(id: string | undefined) {
740
- return useQuery({
741
- queryKey: ['product', id],
742
- queryFn: () => client.getProduct(id!),
743
- enabled: !!id,
744
- });
745
- }
746
-
747
- export function useOrders(options?: {
748
- contactId?: string;
749
- status?: 'pending' | 'paid' | 'refunded' | 'cancelled';
750
- limit?: number;
751
- }) {
752
- return useQuery({
753
- queryKey: ['orders', options],
754
- queryFn: () => client.listOrders(options),
755
- });
756
- }
757
-
758
- export function useOrder(id: string | undefined) {
759
- return useQuery({
760
- queryKey: ['order', id],
761
- queryFn: () => client.getOrder(id!),
762
- enabled: !!id,
763
- });
764
- }
765
-
766
- export function useCreateCheckoutSession() {
767
- return useMutation({
768
- mutationFn: (data: {
769
- items: Array<{ productId: string; quantity: number }>;
770
- contactId?: string;
771
- email?: string;
772
- successUrl: string;
773
- cancelUrl: string;
774
- }) => client.createCheckoutSession(data),
775
- });
776
- }
777
-
778
- export function useCheckoutSession(sessionId: string | undefined) {
779
- return useQuery({
780
- queryKey: ['checkoutSession', sessionId],
781
- queryFn: () => client.getCheckoutSession(sessionId!),
782
- enabled: !!sessionId,
783
- });
784
- }
785
- `
786
- : `/**
787
- * Products & Checkout Hooks
788
- * Auto-generated by @l4yercak3/cli
789
- */
790
-
791
- const { useQuery, useMutation } = require('@tanstack/react-query');
792
- const { getL4yercak3Client } = require('../client');
793
-
794
- const client = getL4yercak3Client();
795
-
796
- function useProducts(options = {}) {
797
- return useQuery({
798
- queryKey: ['products', options],
799
- queryFn: () => client.listProducts(options),
800
- });
801
- }
802
-
803
- function useProduct(id) {
804
- return useQuery({
805
- queryKey: ['product', id],
806
- queryFn: () => client.getProduct(id),
807
- enabled: !!id,
808
- });
809
- }
810
-
811
- function useOrders(options = {}) {
812
- return useQuery({
813
- queryKey: ['orders', options],
814
- queryFn: () => client.listOrders(options),
815
- });
816
- }
817
-
818
- function useOrder(id) {
819
- return useQuery({
820
- queryKey: ['order', id],
821
- queryFn: () => client.getOrder(id),
822
- enabled: !!id,
823
- });
824
- }
825
-
826
- function useCreateCheckoutSession() {
827
- return useMutation({
828
- mutationFn: (data) => client.createCheckoutSession(data),
829
- });
830
- }
831
-
832
- function useCheckoutSession(sessionId) {
833
- return useQuery({
834
- queryKey: ['checkoutSession', sessionId],
835
- queryFn: () => client.getCheckoutSession(sessionId),
836
- enabled: !!sessionId,
837
- });
838
- }
839
-
840
- module.exports = {
841
- useProducts,
842
- useProduct,
843
- useOrders,
844
- useOrder,
845
- useCreateCheckoutSession,
846
- useCheckoutSession,
847
- };
848
- `;
849
-
850
- return writeFileWithBackup(outputPath, content, action);
851
- }
852
-
853
- async generateInvoicesHook(outputDir, options) {
854
- const { isTypeScript } = options;
855
- const extension = isTypeScript ? 'ts' : 'js';
856
- const outputPath = path.join(outputDir, `use-invoices.${extension}`);
857
-
858
- const action = await checkFileOverwrite(outputPath);
859
- if (action === 'skip') {
860
- return null;
861
- }
862
-
863
- const content = isTypeScript
864
- ? `/**
865
- * Invoices Hooks
866
- * Auto-generated by @l4yercak3/cli
867
- */
868
-
869
- import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
870
- import { getL4yercak3Client } from '../client';
871
- import type { Invoice, InvoiceCreateInput } from '../types';
872
-
873
- const client = getL4yercak3Client();
874
-
875
- export function useInvoices(options?: {
876
- contactId?: string;
877
- organizationId?: string;
878
- status?: 'draft' | 'sent' | 'paid' | 'overdue' | 'cancelled';
879
- type?: 'b2b' | 'b2c';
880
- limit?: number;
881
- }) {
882
- return useQuery({
883
- queryKey: ['invoices', options],
884
- queryFn: () => client.listInvoices(options),
885
- });
886
- }
887
-
888
- export function useInvoice(id: string | undefined) {
889
- return useQuery({
890
- queryKey: ['invoice', id],
891
- queryFn: () => client.getInvoice(id!),
892
- enabled: !!id,
893
- });
894
- }
895
-
896
- export function useCreateInvoice() {
897
- const queryClient = useQueryClient();
898
-
899
- return useMutation({
900
- mutationFn: (data: InvoiceCreateInput) => client.createInvoice(data),
901
- onSuccess: () => {
902
- queryClient.invalidateQueries({ queryKey: ['invoices'] });
903
- },
904
- });
905
- }
906
-
907
- export function useSendInvoice() {
908
- const queryClient = useQueryClient();
909
-
910
- return useMutation({
911
- mutationFn: ({ id, options }: { id: string; options?: { emailTo?: string; message?: string } }) =>
912
- client.sendInvoice(id, options),
913
- onSuccess: (_, variables) => {
914
- queryClient.invalidateQueries({ queryKey: ['invoice', variables.id] });
915
- queryClient.invalidateQueries({ queryKey: ['invoices'] });
916
- },
917
- });
918
- }
919
-
920
- export function useMarkInvoicePaid() {
921
- const queryClient = useQueryClient();
922
-
923
- return useMutation({
924
- mutationFn: ({ id, data }: { id: string; data?: { paidAt?: string; paymentMethod?: string } }) =>
925
- client.markInvoicePaid(id, data),
926
- onSuccess: (_, variables) => {
927
- queryClient.invalidateQueries({ queryKey: ['invoice', variables.id] });
928
- queryClient.invalidateQueries({ queryKey: ['invoices'] });
929
- },
930
- });
931
- }
932
-
933
- export function useInvoicePdf(id: string | undefined) {
934
- return useQuery({
935
- queryKey: ['invoicePdf', id],
936
- queryFn: () => client.getInvoicePdf(id!),
937
- enabled: !!id,
938
- });
939
- }
940
- `
941
- : `/**
942
- * Invoices Hooks
943
- * Auto-generated by @l4yercak3/cli
944
- */
945
-
946
- const { useQuery, useMutation, useQueryClient } = require('@tanstack/react-query');
947
- const { getL4yercak3Client } = require('../client');
948
-
949
- const client = getL4yercak3Client();
950
-
951
- function useInvoices(options = {}) {
952
- return useQuery({
953
- queryKey: ['invoices', options],
954
- queryFn: () => client.listInvoices(options),
955
- });
956
- }
957
-
958
- function useInvoice(id) {
959
- return useQuery({
960
- queryKey: ['invoice', id],
961
- queryFn: () => client.getInvoice(id),
962
- enabled: !!id,
963
- });
964
- }
965
-
966
- function useCreateInvoice() {
967
- const queryClient = useQueryClient();
968
-
969
- return useMutation({
970
- mutationFn: (data) => client.createInvoice(data),
971
- onSuccess: () => {
972
- queryClient.invalidateQueries({ queryKey: ['invoices'] });
973
- },
974
- });
975
- }
976
-
977
- function useSendInvoice() {
978
- const queryClient = useQueryClient();
979
-
980
- return useMutation({
981
- mutationFn: ({ id, options }) => client.sendInvoice(id, options),
982
- onSuccess: (_, variables) => {
983
- queryClient.invalidateQueries({ queryKey: ['invoice', variables.id] });
984
- queryClient.invalidateQueries({ queryKey: ['invoices'] });
985
- },
986
- });
987
- }
988
-
989
- function useMarkInvoicePaid() {
990
- const queryClient = useQueryClient();
991
-
992
- return useMutation({
993
- mutationFn: ({ id, data }) => client.markInvoicePaid(id, data),
994
- onSuccess: (_, variables) => {
995
- queryClient.invalidateQueries({ queryKey: ['invoice', variables.id] });
996
- queryClient.invalidateQueries({ queryKey: ['invoices'] });
997
- },
998
- });
999
- }
1000
-
1001
- module.exports = {
1002
- useInvoices,
1003
- useInvoice,
1004
- useCreateInvoice,
1005
- useSendInvoice,
1006
- useMarkInvoicePaid,
1007
- };
1008
- `;
1009
-
1010
- return writeFileWithBackup(outputPath, content, action);
1011
- }
1012
-
1013
- async generateIndex(outputDir, options, generatedHooks) {
1014
- const { isTypeScript } = options;
1015
- const extension = isTypeScript ? 'ts' : 'js';
1016
- const outputPath = path.join(outputDir, `index.${extension}`);
1017
-
1018
- const action = await checkFileOverwrite(outputPath);
1019
- if (action === 'skip') {
1020
- return null;
1021
- }
1022
-
1023
- const exports = [];
1024
- if (generatedHooks.includes('contacts')) {
1025
- exports.push(isTypeScript ? "export * from './use-contacts';" : "...require('./use-contacts'),");
1026
- }
1027
- if (generatedHooks.includes('organizations')) {
1028
- exports.push(isTypeScript ? "export * from './use-organizations';" : "...require('./use-organizations'),");
1029
- }
1030
- if (generatedHooks.includes('events')) {
1031
- exports.push(isTypeScript ? "export * from './use-events';" : "...require('./use-events'),");
1032
- }
1033
- if (generatedHooks.includes('forms')) {
1034
- exports.push(isTypeScript ? "export * from './use-forms';" : "...require('./use-forms'),");
1035
- }
1036
- if (generatedHooks.includes('products')) {
1037
- exports.push(isTypeScript ? "export * from './use-products';" : "...require('./use-products'),");
1038
- }
1039
- if (generatedHooks.includes('invoices')) {
1040
- exports.push(isTypeScript ? "export * from './use-invoices';" : "...require('./use-invoices'),");
1041
- }
1042
-
1043
- const content = isTypeScript
1044
- ? `/**
1045
- * L4YERCAK3 React Hooks
1046
- * Auto-generated by @l4yercak3/cli
1047
- */
1048
-
1049
- ${exports.join('\n')}
1050
- `
1051
- : `/**
1052
- * L4YERCAK3 React Hooks
1053
- * Auto-generated by @l4yercak3/cli
1054
- */
1055
-
1056
- module.exports = {
1057
- ${exports.join('\n ')}
1058
- };
1059
- `;
1060
-
1061
- return writeFileWithBackup(outputPath, content, action);
1062
- }
1063
- }
1064
-
1065
- module.exports = new HooksGenerator();