@l4yercak3/cli 1.2.15 → 1.2.18

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.
@@ -0,0 +1,96 @@
1
+ /**
2
+ * API-Only Generator
3
+ * Generates just the typed API client and types for the project
4
+ */
5
+
6
+ const clientGenerator = require('./client');
7
+ const typesGenerator = require('./types');
8
+ const webhooksGenerator = require('./webhooks');
9
+
10
+ class ApiOnlyGenerator {
11
+ /**
12
+ * Generate API-only files
13
+ * @param {Object} options - Generation options
14
+ * @returns {Promise<Object>} - Generated file paths
15
+ */
16
+ async generate(options) {
17
+ const results = {
18
+ client: null,
19
+ types: null,
20
+ webhooks: null,
21
+ index: null,
22
+ };
23
+
24
+ // Generate TypeScript types first (used by client)
25
+ results.types = await typesGenerator.generate(options);
26
+
27
+ // Generate the typed API client
28
+ results.client = await clientGenerator.generate(options);
29
+
30
+ // Generate webhook utilities
31
+ results.webhooks = await webhooksGenerator.generate(options);
32
+
33
+ // Generate index file
34
+ results.index = await this.generateIndex(options);
35
+
36
+ return results;
37
+ }
38
+
39
+ /**
40
+ * Generate index.ts/js that exports everything
41
+ */
42
+ async generateIndex(options) {
43
+ const { projectPath, isTypeScript } = options;
44
+ const fs = require('fs');
45
+ const path = require('path');
46
+ const { ensureDir, writeFileWithBackup, checkFileOverwrite } = require('../../utils/file-utils');
47
+
48
+ // Determine output directory
49
+ let outputDir;
50
+ if (fs.existsSync(path.join(projectPath, 'src'))) {
51
+ outputDir = path.join(projectPath, 'src', 'lib', 'l4yercak3');
52
+ } else {
53
+ outputDir = path.join(projectPath, 'lib', 'l4yercak3');
54
+ }
55
+
56
+ ensureDir(outputDir);
57
+
58
+ const extension = isTypeScript ? 'ts' : 'js';
59
+ const outputPath = path.join(outputDir, `index.${extension}`);
60
+
61
+ const action = await checkFileOverwrite(outputPath);
62
+ if (action === 'skip') {
63
+ return null;
64
+ }
65
+
66
+ const content = isTypeScript
67
+ ? `/**
68
+ * L4YERCAK3 API Client
69
+ * Auto-generated by @l4yercak3/cli
70
+ */
71
+
72
+ export { L4yercak3Client, getL4yercak3Client, L4yercak3Error } from './client';
73
+ export type * from './types';
74
+ export { verifyWebhookSignature, type WebhookEvent } from './webhooks';
75
+ `
76
+ : `/**
77
+ * L4YERCAK3 API Client
78
+ * Auto-generated by @l4yercak3/cli
79
+ */
80
+
81
+ const { L4yercak3Client, getL4yercak3Client, L4yercak3Error } = require('./client');
82
+ const { verifyWebhookSignature } = require('./webhooks');
83
+
84
+ module.exports = {
85
+ L4yercak3Client,
86
+ getL4yercak3Client,
87
+ L4yercak3Error,
88
+ verifyWebhookSignature,
89
+ };
90
+ `;
91
+
92
+ return writeFileWithBackup(outputPath, content, action);
93
+ }
94
+ }
95
+
96
+ module.exports = new ApiOnlyGenerator();
@@ -0,0 +1,618 @@
1
+ /**
2
+ * Types Generator
3
+ * Generates TypeScript type definitions for the L4YERCAK3 API
4
+ */
5
+
6
+ const fs = require('fs');
7
+ const path = require('path');
8
+ const { ensureDir, writeFileWithBackup, checkFileOverwrite } = require('../../utils/file-utils');
9
+
10
+ class TypesGenerator {
11
+ /**
12
+ * Generate the types file
13
+ * @param {Object} options - Generation options
14
+ * @returns {Promise<string|null>} - Path to generated file or null if skipped
15
+ */
16
+ async generate(options) {
17
+ const { projectPath, isTypeScript } = options;
18
+
19
+ // Only generate for TypeScript projects
20
+ if (!isTypeScript) {
21
+ return null;
22
+ }
23
+
24
+ // Determine output directory
25
+ let outputDir;
26
+ if (fs.existsSync(path.join(projectPath, 'src'))) {
27
+ outputDir = path.join(projectPath, 'src', 'lib', 'l4yercak3');
28
+ } else {
29
+ outputDir = path.join(projectPath, 'lib', 'l4yercak3');
30
+ }
31
+
32
+ ensureDir(outputDir);
33
+
34
+ const outputPath = path.join(outputDir, 'types.ts');
35
+
36
+ const action = await checkFileOverwrite(outputPath);
37
+ if (action === 'skip') {
38
+ return null;
39
+ }
40
+
41
+ const content = this.generateTypes();
42
+
43
+ return writeFileWithBackup(outputPath, content, action);
44
+ }
45
+
46
+ generateTypes() {
47
+ return `/**
48
+ * L4YERCAK3 API Types
49
+ * Auto-generated by @l4yercak3/cli
50
+ *
51
+ * Comprehensive type definitions for the L4YERCAK3 platform.
52
+ */
53
+
54
+ // ============ CRM Types ============
55
+
56
+ export interface Contact {
57
+ id: string;
58
+ firstName: string;
59
+ lastName: string;
60
+ email: string;
61
+ phone?: string;
62
+ company?: string;
63
+ jobTitle?: string;
64
+ status: 'active' | 'inactive' | 'unsubscribed' | 'archived';
65
+ subtype: 'customer' | 'lead' | 'prospect' | 'partner';
66
+ tags: string[];
67
+ customFields?: Record<string, unknown>;
68
+ organizationId?: string;
69
+ organization?: Organization;
70
+ avatarUrl?: string;
71
+ notes?: ContactNote[];
72
+ activities?: ContactActivity[];
73
+ createdAt: string;
74
+ updatedAt: string;
75
+ }
76
+
77
+ export interface ContactCreateInput {
78
+ firstName: string;
79
+ lastName: string;
80
+ email: string;
81
+ phone?: string;
82
+ company?: string;
83
+ jobTitle?: string;
84
+ subtype?: 'customer' | 'lead' | 'prospect' | 'partner';
85
+ tags?: string[];
86
+ customFields?: Record<string, unknown>;
87
+ organizationId?: string;
88
+ }
89
+
90
+ export interface ContactUpdateInput {
91
+ firstName?: string;
92
+ lastName?: string;
93
+ email?: string;
94
+ phone?: string;
95
+ company?: string;
96
+ jobTitle?: string;
97
+ status?: 'active' | 'inactive' | 'unsubscribed';
98
+ subtype?: 'customer' | 'lead' | 'prospect' | 'partner';
99
+ tags?: string[];
100
+ customFields?: Record<string, unknown>;
101
+ }
102
+
103
+ export interface ContactNote {
104
+ id: string;
105
+ content: string;
106
+ createdBy: string;
107
+ createdAt: string;
108
+ }
109
+
110
+ export interface ContactActivity {
111
+ id: string;
112
+ type: 'email' | 'call' | 'meeting' | 'note' | 'task' | 'event';
113
+ title: string;
114
+ description?: string;
115
+ occurredAt: string;
116
+ metadata?: Record<string, unknown>;
117
+ }
118
+
119
+ export interface Organization {
120
+ id: string;
121
+ name: string;
122
+ website?: string;
123
+ industry?: string;
124
+ size?: 'small' | 'medium' | 'large' | 'enterprise';
125
+ subtype: 'customer' | 'prospect' | 'partner' | 'vendor';
126
+ address?: Address;
127
+ taxId?: string;
128
+ billingEmail?: string;
129
+ contacts?: Contact[];
130
+ createdAt: string;
131
+ updatedAt: string;
132
+ }
133
+
134
+ export interface OrganizationCreateInput {
135
+ name: string;
136
+ website?: string;
137
+ industry?: string;
138
+ size?: 'small' | 'medium' | 'large' | 'enterprise';
139
+ subtype?: 'customer' | 'prospect' | 'partner' | 'vendor';
140
+ address?: AddressInput;
141
+ taxId?: string;
142
+ billingEmail?: string;
143
+ }
144
+
145
+ // ============ Event Types ============
146
+
147
+ export interface Event {
148
+ id: string;
149
+ name: string;
150
+ description?: string;
151
+ shortDescription?: string;
152
+ startDate: string;
153
+ endDate: string;
154
+ timezone: string;
155
+ location: string;
156
+ venue?: Venue;
157
+ status: 'draft' | 'published' | 'cancelled' | 'completed';
158
+ subtype: 'conference' | 'workshop' | 'webinar' | 'meetup' | 'seminar' | 'other';
159
+ maxCapacity?: number;
160
+ registeredCount?: number;
161
+ imageUrl?: string;
162
+ coverImageUrl?: string;
163
+ products?: Product[];
164
+ sponsors?: Sponsor[];
165
+ forms?: Form[];
166
+ tags?: string[];
167
+ customFields?: Record<string, unknown>;
168
+ createdAt: string;
169
+ updatedAt: string;
170
+ }
171
+
172
+ export interface EventCreateInput {
173
+ name: string;
174
+ description?: string;
175
+ shortDescription?: string;
176
+ startDate: string;
177
+ endDate: string;
178
+ timezone?: string;
179
+ location: string;
180
+ venue?: VenueInput;
181
+ subtype?: 'conference' | 'workshop' | 'webinar' | 'meetup' | 'seminar' | 'other';
182
+ maxCapacity?: number;
183
+ imageUrl?: string;
184
+ tags?: string[];
185
+ }
186
+
187
+ export interface Attendee {
188
+ id: string;
189
+ contactId: string;
190
+ contact: Contact;
191
+ eventId: string;
192
+ ticketId: string;
193
+ ticketName: string;
194
+ status: 'registered' | 'checked_in' | 'cancelled' | 'no_show';
195
+ checkedInAt?: string;
196
+ checkedInBy?: string;
197
+ registeredAt: string;
198
+ metadata?: Record<string, unknown>;
199
+ }
200
+
201
+ export interface Venue {
202
+ name: string;
203
+ address: Address;
204
+ capacity?: number;
205
+ website?: string;
206
+ phone?: string;
207
+ notes?: string;
208
+ }
209
+
210
+ export interface VenueInput {
211
+ name: string;
212
+ address: AddressInput;
213
+ capacity?: number;
214
+ website?: string;
215
+ phone?: string;
216
+ }
217
+
218
+ export interface Sponsor {
219
+ id: string;
220
+ organizationId: string;
221
+ organizationName: string;
222
+ level: 'platinum' | 'gold' | 'silver' | 'bronze' | 'community';
223
+ logoUrl?: string;
224
+ websiteUrl?: string;
225
+ description?: string;
226
+ order?: number;
227
+ }
228
+
229
+ // ============ Form Types ============
230
+
231
+ export interface Form {
232
+ id: string;
233
+ name: string;
234
+ description?: string;
235
+ status: 'draft' | 'published' | 'closed';
236
+ subtype: 'registration' | 'survey' | 'application' | 'feedback' | 'contact' | 'custom';
237
+ eventId?: string;
238
+ fields: FormField[];
239
+ settings: FormSettings;
240
+ responseCount: number;
241
+ createdAt: string;
242
+ updatedAt: string;
243
+ }
244
+
245
+ export interface FormField {
246
+ id: string;
247
+ type: FormFieldType;
248
+ label: string;
249
+ name: string;
250
+ required: boolean;
251
+ placeholder?: string;
252
+ helpText?: string;
253
+ options?: FormFieldOption[];
254
+ validation?: FormFieldValidation;
255
+ conditionalLogic?: FormFieldConditional;
256
+ order: number;
257
+ }
258
+
259
+ export type FormFieldType =
260
+ | 'text'
261
+ | 'email'
262
+ | 'phone'
263
+ | 'number'
264
+ | 'textarea'
265
+ | 'select'
266
+ | 'multiselect'
267
+ | 'checkbox'
268
+ | 'radio'
269
+ | 'date'
270
+ | 'datetime'
271
+ | 'time'
272
+ | 'file'
273
+ | 'image'
274
+ | 'signature'
275
+ | 'rating'
276
+ | 'slider'
277
+ | 'hidden';
278
+
279
+ export interface FormFieldOption {
280
+ label: string;
281
+ value: string;
282
+ }
283
+
284
+ export interface FormFieldValidation {
285
+ min?: number;
286
+ max?: number;
287
+ minLength?: number;
288
+ maxLength?: number;
289
+ pattern?: string;
290
+ customMessage?: string;
291
+ }
292
+
293
+ export interface FormFieldConditional {
294
+ action: 'show' | 'hide' | 'require';
295
+ conditions: Array<{
296
+ fieldId: string;
297
+ operator: 'equals' | 'not_equals' | 'contains' | 'greater_than' | 'less_than';
298
+ value: unknown;
299
+ }>;
300
+ logic: 'and' | 'or';
301
+ }
302
+
303
+ export interface FormSettings {
304
+ submitButtonText: string;
305
+ confirmationMessage: string;
306
+ redirectUrl?: string;
307
+ notifyEmails: string[];
308
+ allowMultipleSubmissions: boolean;
309
+ requireAuth: boolean;
310
+ closedMessage?: string;
311
+ limitResponses?: number;
312
+ }
313
+
314
+ export interface FormSubmission {
315
+ id: string;
316
+ formId: string;
317
+ contactId?: string;
318
+ contact?: Contact;
319
+ data: Record<string, unknown>;
320
+ status: 'submitted' | 'reviewed' | 'approved' | 'rejected';
321
+ reviewedBy?: string;
322
+ reviewedAt?: string;
323
+ reviewNotes?: string;
324
+ submittedAt: string;
325
+ metadata?: {
326
+ ipAddress?: string;
327
+ userAgent?: string;
328
+ referrer?: string;
329
+ };
330
+ }
331
+
332
+ // ============ Product & Checkout Types ============
333
+
334
+ export interface Product {
335
+ id: string;
336
+ name: string;
337
+ description?: string;
338
+ shortDescription?: string;
339
+ priceInCents: number;
340
+ currency: string;
341
+ eventId?: string;
342
+ category?: string;
343
+ sku?: string;
344
+ status: 'active' | 'sold_out' | 'hidden' | 'archived';
345
+ inventory?: number;
346
+ maxPerOrder?: number;
347
+ minPerOrder?: number;
348
+ salesStart?: string;
349
+ salesEnd?: string;
350
+ imageUrl?: string;
351
+ metadata?: Record<string, unknown>;
352
+ createdAt: string;
353
+ updatedAt: string;
354
+ }
355
+
356
+ export interface Order {
357
+ id: string;
358
+ orderNumber: string;
359
+ contactId: string;
360
+ contact?: Contact;
361
+ items: OrderItem[];
362
+ subtotalInCents: number;
363
+ discountInCents?: number;
364
+ taxInCents?: number;
365
+ totalInCents: number;
366
+ currency: string;
367
+ status: 'pending' | 'paid' | 'partially_refunded' | 'refunded' | 'cancelled';
368
+ paymentStatus: 'unpaid' | 'paid' | 'refunded';
369
+ stripePaymentIntentId?: string;
370
+ stripeCustomerId?: string;
371
+ billingAddress?: Address;
372
+ notes?: string;
373
+ metadata?: Record<string, unknown>;
374
+ createdAt: string;
375
+ completedAt?: string;
376
+ }
377
+
378
+ export interface OrderItem {
379
+ id: string;
380
+ productId: string;
381
+ productName: string;
382
+ productSku?: string;
383
+ quantity: number;
384
+ unitPriceInCents: number;
385
+ totalPriceInCents: number;
386
+ metadata?: Record<string, unknown>;
387
+ }
388
+
389
+ // ============ Invoice Types ============
390
+
391
+ export interface Invoice {
392
+ id: string;
393
+ number: string;
394
+ contactId?: string;
395
+ contact?: Contact;
396
+ organizationId?: string;
397
+ organization?: Organization;
398
+ type: 'b2b' | 'b2c';
399
+ status: 'draft' | 'sent' | 'viewed' | 'paid' | 'overdue' | 'cancelled' | 'void';
400
+ issueDate: string;
401
+ dueDate: string;
402
+ paidAt?: string;
403
+ lineItems: InvoiceLineItem[];
404
+ subtotalInCents: number;
405
+ discountInCents?: number;
406
+ discountDescription?: string;
407
+ taxInCents: number;
408
+ taxRate: number;
409
+ totalInCents: number;
410
+ currency: string;
411
+ notes?: string;
412
+ terms?: string;
413
+ footer?: string;
414
+ pdfUrl?: string;
415
+ paymentLink?: string;
416
+ billingAddress?: Address;
417
+ paymentMethod?: string;
418
+ paymentReference?: string;
419
+ reminders?: InvoiceReminder[];
420
+ createdAt: string;
421
+ updatedAt: string;
422
+ }
423
+
424
+ export interface InvoiceLineItem {
425
+ id?: string;
426
+ description: string;
427
+ quantity: number;
428
+ unitPriceInCents: number;
429
+ totalInCents: number;
430
+ productId?: string;
431
+ taxable?: boolean;
432
+ }
433
+
434
+ export interface InvoiceCreateInput {
435
+ contactId?: string;
436
+ organizationId?: string;
437
+ type: 'b2b' | 'b2c';
438
+ dueDate: string;
439
+ lineItems: Array<{
440
+ description: string;
441
+ quantity: number;
442
+ unitPriceInCents: number;
443
+ productId?: string;
444
+ taxable?: boolean;
445
+ }>;
446
+ taxRate?: number;
447
+ discountInCents?: number;
448
+ discountDescription?: string;
449
+ notes?: string;
450
+ terms?: string;
451
+ billingAddress?: AddressInput;
452
+ }
453
+
454
+ export interface InvoiceReminder {
455
+ sentAt: string;
456
+ type: 'upcoming' | 'due' | 'overdue';
457
+ method: 'email' | 'sms';
458
+ }
459
+
460
+ // ============ Benefits Types ============
461
+
462
+ export interface BenefitClaim {
463
+ id: string;
464
+ claimNumber: string;
465
+ memberId: string;
466
+ memberName: string;
467
+ memberEmail?: string;
468
+ benefitType: string;
469
+ benefitPlanId?: string;
470
+ amountInCents: number;
471
+ currency: string;
472
+ status: 'pending' | 'under_review' | 'approved' | 'rejected' | 'paid' | 'cancelled';
473
+ description?: string;
474
+ receiptUrl?: string;
475
+ supportingDocuments?: string[];
476
+ submittedAt: string;
477
+ processedAt?: string;
478
+ processedBy?: string;
479
+ paidAt?: string;
480
+ paymentMethod?: string;
481
+ paymentReference?: string;
482
+ rejectionReason?: string;
483
+ notes?: string;
484
+ metadata?: Record<string, unknown>;
485
+ }
486
+
487
+ export interface BenefitClaimInput {
488
+ memberId: string;
489
+ benefitType: string;
490
+ benefitPlanId?: string;
491
+ amountInCents: number;
492
+ currency?: string;
493
+ description?: string;
494
+ receiptUrl?: string;
495
+ supportingDocuments?: string[];
496
+ metadata?: Record<string, unknown>;
497
+ }
498
+
499
+ export interface CommissionPayout {
500
+ id: string;
501
+ payoutNumber: string;
502
+ memberId: string;
503
+ memberName: string;
504
+ memberEmail?: string;
505
+ commissionType: string;
506
+ amountInCents: number;
507
+ currency: string;
508
+ status: 'pending' | 'processing' | 'completed' | 'failed' | 'cancelled';
509
+ sourceTransactionId?: string;
510
+ sourceTransactionType?: string;
511
+ calculationDetails?: {
512
+ baseAmount: number;
513
+ rate: number;
514
+ adjustments?: Array<{ description: string; amount: number }>;
515
+ };
516
+ scheduledFor?: string;
517
+ processedAt?: string;
518
+ paymentMethod?: string;
519
+ paymentReference?: string;
520
+ failureReason?: string;
521
+ notes?: string;
522
+ }
523
+
524
+ // ============ Certificate Types ============
525
+
526
+ export interface Certificate {
527
+ id: string;
528
+ certificateNumber: string;
529
+ type: 'attendance' | 'completion' | 'cme' | 'ce' | 'achievement' | 'custom';
530
+ recipientId: string;
531
+ recipientName: string;
532
+ recipientEmail?: string;
533
+ eventId?: string;
534
+ eventName?: string;
535
+ courseName?: string;
536
+ credits?: number;
537
+ creditType?: string;
538
+ issueDate: string;
539
+ expiryDate?: string;
540
+ status: 'draft' | 'issued' | 'revoked' | 'expired';
541
+ pdfUrl?: string;
542
+ verificationUrl?: string;
543
+ metadata?: Record<string, unknown>;
544
+ createdAt: string;
545
+ }
546
+
547
+ // ============ Common Types ============
548
+
549
+ export interface Address {
550
+ street?: string;
551
+ street2?: string;
552
+ city?: string;
553
+ state?: string;
554
+ postalCode?: string;
555
+ country?: string;
556
+ }
557
+
558
+ export interface AddressInput {
559
+ street?: string;
560
+ street2?: string;
561
+ city?: string;
562
+ state?: string;
563
+ postalCode?: string;
564
+ country?: string;
565
+ }
566
+
567
+ // ============ Pagination ============
568
+
569
+ export interface PaginatedResponse<T> {
570
+ items: T[];
571
+ total: number;
572
+ hasMore: boolean;
573
+ nextCursor?: string;
574
+ }
575
+
576
+ // ============ Webhook Types ============
577
+
578
+ export interface WebhookEvent {
579
+ id: string;
580
+ type: WebhookEventType;
581
+ timestamp: string;
582
+ data: Record<string, unknown>;
583
+ organizationId: string;
584
+ }
585
+
586
+ export type WebhookEventType =
587
+ | 'contact.created'
588
+ | 'contact.updated'
589
+ | 'contact.deleted'
590
+ | 'organization.created'
591
+ | 'organization.updated'
592
+ | 'event.created'
593
+ | 'event.updated'
594
+ | 'event.published'
595
+ | 'event.cancelled'
596
+ | 'attendee.registered'
597
+ | 'attendee.checked_in'
598
+ | 'attendee.cancelled'
599
+ | 'form.submitted'
600
+ | 'order.created'
601
+ | 'order.paid'
602
+ | 'order.refunded'
603
+ | 'invoice.created'
604
+ | 'invoice.sent'
605
+ | 'invoice.paid'
606
+ | 'invoice.overdue'
607
+ | 'benefit_claim.submitted'
608
+ | 'benefit_claim.approved'
609
+ | 'benefit_claim.rejected'
610
+ | 'benefit_claim.paid'
611
+ | 'commission.calculated'
612
+ | 'commission.paid'
613
+ | 'certificate.issued';
614
+ `;
615
+ }
616
+ }
617
+
618
+ module.exports = new TypesGenerator();