@startanaicompany/crm 2.0.0 → 2.1.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 +225 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -917,4 +917,229 @@ leadsStageCmd
|
|
|
917
917
|
});
|
|
918
918
|
|
|
919
919
|
|
|
920
|
+
// ============================================================
|
|
921
|
+
// MEETINGS
|
|
922
|
+
// ============================================================
|
|
923
|
+
|
|
924
|
+
const meetingsCmd = program
|
|
925
|
+
.command('meetings')
|
|
926
|
+
.description('Manage booked meetings');
|
|
927
|
+
|
|
928
|
+
meetingsCmd
|
|
929
|
+
.command('create')
|
|
930
|
+
.description('Log a new meeting')
|
|
931
|
+
.requiredOption('--title <title>', 'Meeting title')
|
|
932
|
+
.requiredOption('--scheduled-at <iso>', 'Scheduled datetime (ISO8601, e.g. 2026-03-01T14:00:00Z)')
|
|
933
|
+
.option('--contact-id <id>', 'Contact ID')
|
|
934
|
+
.option('--lead-id <id>', 'Lead ID')
|
|
935
|
+
.option('--duration <minutes>', 'Duration in minutes')
|
|
936
|
+
.option('--location <location>', 'Physical location or address')
|
|
937
|
+
.option('--video-link <url>', 'Video call link (Zoom, Meet, etc.)')
|
|
938
|
+
.option('--notes <notes>', 'Meeting notes or agenda')
|
|
939
|
+
.option('--outcome <outcome>', 'scheduled | completed | cancelled | no_show')
|
|
940
|
+
.action(async (opts) => {
|
|
941
|
+
const globalOpts = program.opts();
|
|
942
|
+
const client = getClient(globalOpts);
|
|
943
|
+
try {
|
|
944
|
+
const body = {
|
|
945
|
+
title: opts.title,
|
|
946
|
+
scheduled_at: opts.scheduledAt,
|
|
947
|
+
};
|
|
948
|
+
if (opts.contactId) body.contact_id = opts.contactId;
|
|
949
|
+
if (opts.leadId) body.lead_id = opts.leadId;
|
|
950
|
+
if (opts.duration) body.duration_minutes = parseInt(opts.duration);
|
|
951
|
+
if (opts.location) body.location = opts.location;
|
|
952
|
+
if (opts.videoLink) body.video_link = opts.videoLink;
|
|
953
|
+
if (opts.notes) body.notes = opts.notes;
|
|
954
|
+
if (opts.outcome) body.outcome = opts.outcome;
|
|
955
|
+
const res = await client.post('/meetings', body);
|
|
956
|
+
printJSON(res.data);
|
|
957
|
+
} catch (err) {
|
|
958
|
+
handleError(err);
|
|
959
|
+
}
|
|
960
|
+
});
|
|
961
|
+
|
|
962
|
+
meetingsCmd
|
|
963
|
+
.command('list')
|
|
964
|
+
.description('List meetings')
|
|
965
|
+
.option('--contact-id <id>', 'Filter by contact ID')
|
|
966
|
+
.option('--lead-id <id>', 'Filter by lead ID')
|
|
967
|
+
.option('--outcome <outcome>', 'Filter by outcome')
|
|
968
|
+
.option('--scheduled-after <iso>', 'Filter meetings scheduled after date')
|
|
969
|
+
.option('--scheduled-before <iso>', 'Filter meetings scheduled before date')
|
|
970
|
+
.option('--page <n>', 'Page number', '1')
|
|
971
|
+
.option('--per-page <n>', 'Results per page', '20')
|
|
972
|
+
.action(async (opts) => {
|
|
973
|
+
const globalOpts = program.opts();
|
|
974
|
+
const client = getClient(globalOpts);
|
|
975
|
+
try {
|
|
976
|
+
const params = { page: opts.page, per_page: opts.perPage };
|
|
977
|
+
if (opts.contactId) params.contact_id = opts.contactId;
|
|
978
|
+
if (opts.leadId) params.lead_id = opts.leadId;
|
|
979
|
+
if (opts.outcome) params.outcome = opts.outcome;
|
|
980
|
+
if (opts.scheduledAfter) params.scheduled_after = opts.scheduledAfter;
|
|
981
|
+
if (opts.scheduledBefore) params.scheduled_before = opts.scheduledBefore;
|
|
982
|
+
const res = await client.get('/meetings', { params });
|
|
983
|
+
printJSON(res.data);
|
|
984
|
+
} catch (err) {
|
|
985
|
+
handleError(err);
|
|
986
|
+
}
|
|
987
|
+
});
|
|
988
|
+
|
|
989
|
+
meetingsCmd
|
|
990
|
+
.command('get <id>')
|
|
991
|
+
.description('Get a meeting by ID')
|
|
992
|
+
.action(async (id) => {
|
|
993
|
+
const globalOpts = program.opts();
|
|
994
|
+
const client = getClient(globalOpts);
|
|
995
|
+
try {
|
|
996
|
+
const res = await client.get(`/meetings/${id}`);
|
|
997
|
+
printJSON(res.data);
|
|
998
|
+
} catch (err) {
|
|
999
|
+
handleError(err);
|
|
1000
|
+
}
|
|
1001
|
+
});
|
|
1002
|
+
|
|
1003
|
+
meetingsCmd
|
|
1004
|
+
.command('update <id>')
|
|
1005
|
+
.description('Update a meeting')
|
|
1006
|
+
.option('--title <title>', 'New title')
|
|
1007
|
+
.option('--scheduled-at <iso>', 'New scheduled time (ISO8601)')
|
|
1008
|
+
.option('--duration <minutes>', 'Duration in minutes')
|
|
1009
|
+
.option('--location <location>', 'Location')
|
|
1010
|
+
.option('--video-link <url>', 'Video link')
|
|
1011
|
+
.option('--notes <notes>', 'Notes')
|
|
1012
|
+
.option('--outcome <outcome>', 'scheduled | completed | cancelled | no_show')
|
|
1013
|
+
.action(async (id, opts) => {
|
|
1014
|
+
const globalOpts = program.opts();
|
|
1015
|
+
const client = getClient(globalOpts);
|
|
1016
|
+
try {
|
|
1017
|
+
const body = {};
|
|
1018
|
+
if (opts.title !== undefined) body.title = opts.title;
|
|
1019
|
+
if (opts.scheduledAt !== undefined) body.scheduled_at = opts.scheduledAt;
|
|
1020
|
+
if (opts.duration !== undefined) body.duration_minutes = parseInt(opts.duration);
|
|
1021
|
+
if (opts.location !== undefined) body.location = opts.location;
|
|
1022
|
+
if (opts.videoLink !== undefined) body.video_link = opts.videoLink;
|
|
1023
|
+
if (opts.notes !== undefined) body.notes = opts.notes;
|
|
1024
|
+
if (opts.outcome !== undefined) body.outcome = opts.outcome;
|
|
1025
|
+
const res = await client.patch(`/meetings/${id}`, body);
|
|
1026
|
+
printJSON(res.data);
|
|
1027
|
+
} catch (err) {
|
|
1028
|
+
handleError(err);
|
|
1029
|
+
}
|
|
1030
|
+
});
|
|
1031
|
+
|
|
1032
|
+
meetingsCmd
|
|
1033
|
+
.command('cancel <id>')
|
|
1034
|
+
.description('Cancel a meeting')
|
|
1035
|
+
.option('--reason <reason>', 'Cancellation reason')
|
|
1036
|
+
.action(async (id, opts) => {
|
|
1037
|
+
const globalOpts = program.opts();
|
|
1038
|
+
const client = getClient(globalOpts);
|
|
1039
|
+
try {
|
|
1040
|
+
const body = {};
|
|
1041
|
+
if (opts.reason) body.reason = opts.reason;
|
|
1042
|
+
const res = await client.delete(`/meetings/${id}`, { data: body });
|
|
1043
|
+
printJSON(res.data);
|
|
1044
|
+
} catch (err) {
|
|
1045
|
+
handleError(err);
|
|
1046
|
+
}
|
|
1047
|
+
});
|
|
1048
|
+
|
|
1049
|
+
// ============================================================
|
|
1050
|
+
// EMAILS
|
|
1051
|
+
// ============================================================
|
|
1052
|
+
|
|
1053
|
+
const emailsCmd = program
|
|
1054
|
+
.command('emails')
|
|
1055
|
+
.description('Log and retrieve email interactions');
|
|
1056
|
+
|
|
1057
|
+
emailsCmd
|
|
1058
|
+
.command('log')
|
|
1059
|
+
.description('Log an email interaction (sent or received)')
|
|
1060
|
+
.requiredOption('--direction <dir>', 'sent or received')
|
|
1061
|
+
.requiredOption('--subject <subject>', 'Email subject line')
|
|
1062
|
+
.option('--contact-id <id>', 'Contact ID')
|
|
1063
|
+
.option('--lead-id <id>', 'Lead ID')
|
|
1064
|
+
.option('--body <summary>', 'Body summary (max 1000 chars)')
|
|
1065
|
+
.option('--thread-id <id>', 'Thread ID for grouping related emails')
|
|
1066
|
+
.option('--email-time <iso>', 'When the email was sent/received (ISO8601, defaults to now)')
|
|
1067
|
+
.action(async (opts) => {
|
|
1068
|
+
const globalOpts = program.opts();
|
|
1069
|
+
const client = getClient(globalOpts);
|
|
1070
|
+
try {
|
|
1071
|
+
const body = {
|
|
1072
|
+
direction: opts.direction,
|
|
1073
|
+
subject: opts.subject,
|
|
1074
|
+
};
|
|
1075
|
+
if (opts.contactId) body.contact_id = opts.contactId;
|
|
1076
|
+
if (opts.leadId) body.lead_id = opts.leadId;
|
|
1077
|
+
if (opts.body) body.body_summary = opts.body;
|
|
1078
|
+
if (opts.threadId) body.thread_id = opts.threadId;
|
|
1079
|
+
if (opts.emailTime) body.email_timestamp = opts.emailTime;
|
|
1080
|
+
const res = await client.post('/emails', body);
|
|
1081
|
+
printJSON(res.data);
|
|
1082
|
+
} catch (err) {
|
|
1083
|
+
handleError(err);
|
|
1084
|
+
}
|
|
1085
|
+
});
|
|
1086
|
+
|
|
1087
|
+
emailsCmd
|
|
1088
|
+
.command('list')
|
|
1089
|
+
.description('List email logs')
|
|
1090
|
+
.option('--contact-id <id>', 'Filter by contact ID')
|
|
1091
|
+
.option('--lead-id <id>', 'Filter by lead ID')
|
|
1092
|
+
.option('--direction <dir>', 'Filter by direction (sent/received)')
|
|
1093
|
+
.option('--thread-id <id>', 'Filter by thread ID')
|
|
1094
|
+
.option('--after <iso>', 'Filter emails after this date')
|
|
1095
|
+
.option('--before <iso>', 'Filter emails before this date')
|
|
1096
|
+
.option('--page <n>', 'Page number', '1')
|
|
1097
|
+
.option('--per-page <n>', 'Results per page', '20')
|
|
1098
|
+
.action(async (opts) => {
|
|
1099
|
+
const globalOpts = program.opts();
|
|
1100
|
+
const client = getClient(globalOpts);
|
|
1101
|
+
try {
|
|
1102
|
+
const params = { page: opts.page, per_page: opts.perPage };
|
|
1103
|
+
if (opts.contactId) params.contact_id = opts.contactId;
|
|
1104
|
+
if (opts.leadId) params.lead_id = opts.leadId;
|
|
1105
|
+
if (opts.direction) params.direction = opts.direction;
|
|
1106
|
+
if (opts.threadId) params.thread_id = opts.threadId;
|
|
1107
|
+
if (opts.after) params.after = opts.after;
|
|
1108
|
+
if (opts.before) params.before = opts.before;
|
|
1109
|
+
const res = await client.get('/emails', { params });
|
|
1110
|
+
printJSON(res.data);
|
|
1111
|
+
} catch (err) {
|
|
1112
|
+
handleError(err);
|
|
1113
|
+
}
|
|
1114
|
+
});
|
|
1115
|
+
|
|
1116
|
+
emailsCmd
|
|
1117
|
+
.command('get <id>')
|
|
1118
|
+
.description('Get an email log entry by ID')
|
|
1119
|
+
.action(async (id) => {
|
|
1120
|
+
const globalOpts = program.opts();
|
|
1121
|
+
const client = getClient(globalOpts);
|
|
1122
|
+
try {
|
|
1123
|
+
const res = await client.get(`/emails/${id}`);
|
|
1124
|
+
printJSON(res.data);
|
|
1125
|
+
} catch (err) {
|
|
1126
|
+
handleError(err);
|
|
1127
|
+
}
|
|
1128
|
+
});
|
|
1129
|
+
|
|
1130
|
+
emailsCmd
|
|
1131
|
+
.command('thread <thread-id>')
|
|
1132
|
+
.description('Get all emails in a thread by thread ID')
|
|
1133
|
+
.action(async (threadId) => {
|
|
1134
|
+
const globalOpts = program.opts();
|
|
1135
|
+
const client = getClient(globalOpts);
|
|
1136
|
+
try {
|
|
1137
|
+
const res = await client.get(`/emails/thread/${threadId}`);
|
|
1138
|
+
printJSON(res.data);
|
|
1139
|
+
} catch (err) {
|
|
1140
|
+
handleError(err);
|
|
1141
|
+
}
|
|
1142
|
+
});
|
|
1143
|
+
|
|
1144
|
+
|
|
920
1145
|
program.parse(process.argv);
|