@l4yercak3/cli 1.2.16 → 1.2.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.local.json +3 -1
- package/docs/CRM-PIPELINES-SEQUENCES-SPEC.md +429 -0
- package/docs/INTEGRATION_PATHS_ARCHITECTURE.md +1543 -0
- package/package.json +1 -1
- package/src/commands/login.js +26 -7
- package/src/commands/spread.js +251 -10
- package/src/detectors/database-detector.js +245 -0
- package/src/detectors/expo-detector.js +4 -4
- package/src/detectors/index.js +17 -4
- package/src/generators/api-only/client.js +683 -0
- package/src/generators/api-only/index.js +96 -0
- package/src/generators/api-only/types.js +618 -0
- package/src/generators/api-only/webhooks.js +377 -0
- package/src/generators/env-generator.js +23 -8
- package/src/generators/expo-auth-generator.js +1009 -0
- package/src/generators/index.js +88 -2
- package/src/generators/mcp-guide-generator.js +256 -0
- package/src/generators/quickstart/components/index.js +1699 -0
- package/src/generators/quickstart/components-mobile/index.js +1440 -0
- package/src/generators/quickstart/database/convex.js +1257 -0
- package/src/generators/quickstart/database/index.js +34 -0
- package/src/generators/quickstart/database/supabase.js +1132 -0
- package/src/generators/quickstart/hooks/index.js +1065 -0
- package/src/generators/quickstart/index.js +177 -0
- package/src/generators/quickstart/pages/index.js +1466 -0
- package/src/generators/quickstart/screens/index.js +1498 -0
- package/src/mcp/registry/domains/benefits.js +798 -0
- package/src/mcp/registry/index.js +2 -0
- package/tests/database-detector.test.js +221 -0
- package/tests/expo-detector.test.js +3 -4
- package/tests/generators-index.test.js +215 -3
|
@@ -0,0 +1,1065 @@
|
|
|
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();
|