@startanaicompany/crm 2.6.0 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +36 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -395,7 +395,7 @@ leadsCmd
|
|
|
395
395
|
.option('--phone <phone>', 'Phone number')
|
|
396
396
|
.option('--company <company>', 'Company name')
|
|
397
397
|
.option('--status <status>', 'Status: new|contacted|qualified|unresponsive|converted|lost', 'new')
|
|
398
|
-
.option('--source <source>', 'Source: api|import|referral', 'api')
|
|
398
|
+
.option('--source <source>', 'Source: api|import|referral|linkedin|cold_email|website|inbound|partner|event|other', 'api')
|
|
399
399
|
.option('--deal-value <amount>', 'Deal value (numeric)')
|
|
400
400
|
.option('--pipeline-stage <stage>', 'Pipeline stage: new|prospecting|discovery|qualified|demo_scheduled|demo_completed|proposal_sent|negotiation|contract_sent|closed_won|closed_lost|no_decision|dormant')
|
|
401
401
|
.option('--notes <notes>', 'Notes')
|
|
@@ -439,10 +439,13 @@ leadsCmd
|
|
|
439
439
|
.option('--email <email>', 'Filter by email (partial match)')
|
|
440
440
|
.option('--company <company>', 'Filter by company (partial match)')
|
|
441
441
|
.option('--name <name>', 'Search by name or company (partial match)')
|
|
442
|
+
.option('--assigned-to <assignedTo>', 'Filter by assigned-to (partial match)')
|
|
442
443
|
.option('--pipeline-stage <stage>', 'Filter by pipeline stage (exact match)')
|
|
443
444
|
.option('--tag <tag>', 'Filter by tag — repeatable, AND logic', (v, prev) => prev.concat([v]), [])
|
|
444
445
|
.option('--api-key-id <id>', 'Filter by the API key ID that created the lead')
|
|
445
446
|
.option('--self', 'Filter leads created by the current API key (shorthand for --api-key-id self)')
|
|
447
|
+
.option('--sort-by <field>', 'Sort field: created_at|updated_at|deal_value|name|company|last_activity_at|status_changed_at')
|
|
448
|
+
.option('--order <dir>', 'Sort direction: asc|desc', 'desc')
|
|
446
449
|
.option('--created-after <date>', 'Filter leads created after this ISO8601 date (e.g. 2026-01-01T00:00:00Z)')
|
|
447
450
|
.option('--created-before <date>', 'Filter leads created before this ISO8601 date')
|
|
448
451
|
.option('--updated-after <date>', 'Filter leads updated after this ISO8601 date')
|
|
@@ -459,8 +462,11 @@ leadsCmd
|
|
|
459
462
|
...(opts.email && { email: opts.email }),
|
|
460
463
|
...(opts.company && { company: opts.company }),
|
|
461
464
|
...(opts.name && { name: opts.name }),
|
|
465
|
+
...(opts.assignedTo && { assigned_to: opts.assignedTo }),
|
|
462
466
|
...(opts.pipelineStage && { pipeline_stage: opts.pipelineStage }),
|
|
463
467
|
...(apiKeyIdFilter && { api_key_id: apiKeyIdFilter }),
|
|
468
|
+
...(opts.sortBy && { sort_by: opts.sortBy }),
|
|
469
|
+
...(opts.order && { order: opts.order }),
|
|
464
470
|
...(opts.createdAfter && { created_after: opts.createdAfter }),
|
|
465
471
|
...(opts.createdBefore && { created_before: opts.createdBefore }),
|
|
466
472
|
...(opts.updatedAfter && { updated_after: opts.updatedAfter }),
|
|
@@ -479,6 +485,35 @@ leadsCmd
|
|
|
479
485
|
}
|
|
480
486
|
});
|
|
481
487
|
|
|
488
|
+
leadsCmd
|
|
489
|
+
.command('bulk-create')
|
|
490
|
+
.description('Bulk create up to 100 leads from a JSON file (207 Multi-Status)')
|
|
491
|
+
.requiredOption('--file <path>', 'Path to JSON file containing array of lead objects')
|
|
492
|
+
.option('--fail-fast', 'Stop processing on first failure', false)
|
|
493
|
+
.option('--from-agent-name <name>', 'Agent name for attribution (falls back to config defaultAgentName)')
|
|
494
|
+
.action(async (opts) => {
|
|
495
|
+
const globalOpts = program.opts();
|
|
496
|
+
const agentName = resolveAgentName(opts.fromAgentName);
|
|
497
|
+
const client = getClient(globalOpts, agentName);
|
|
498
|
+
let leads;
|
|
499
|
+
try {
|
|
500
|
+
const fs = require('fs');
|
|
501
|
+
const raw = fs.readFileSync(opts.file, 'utf8');
|
|
502
|
+
const parsed = JSON.parse(raw);
|
|
503
|
+
leads = Array.isArray(parsed) ? parsed : parsed.leads;
|
|
504
|
+
if (!Array.isArray(leads)) throw new Error('JSON must be an array or object with a "leads" array');
|
|
505
|
+
} catch (fileErr) {
|
|
506
|
+
console.error(`Error reading file: ${fileErr.message}`);
|
|
507
|
+
process.exit(1);
|
|
508
|
+
}
|
|
509
|
+
try {
|
|
510
|
+
const res = await client.post('/leads/bulk', { leads, fail_fast: opts.failFast });
|
|
511
|
+
printJSON(res.data);
|
|
512
|
+
} catch (err) {
|
|
513
|
+
handleError(err);
|
|
514
|
+
}
|
|
515
|
+
});
|
|
516
|
+
|
|
482
517
|
leadsCmd
|
|
483
518
|
.command('get <id>')
|
|
484
519
|
.description('Get a single lead by ID')
|