@cakemail-org/cakemail-cli 1.2.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/LICENSE +21 -0
- package/README.md +460 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +66 -0
- package/dist/cli.js.map +1 -0
- package/dist/client.d.ts +27 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +41 -0
- package/dist/client.js.map +1 -0
- package/dist/commands/campaigns.d.ts +5 -0
- package/dist/commands/campaigns.d.ts.map +1 -0
- package/dist/commands/campaigns.js +334 -0
- package/dist/commands/campaigns.js.map +1 -0
- package/dist/commands/contacts.d.ts +5 -0
- package/dist/commands/contacts.d.ts.map +1 -0
- package/dist/commands/contacts.js +164 -0
- package/dist/commands/contacts.js.map +1 -0
- package/dist/commands/emails.d.ts +5 -0
- package/dist/commands/emails.d.ts.map +1 -0
- package/dist/commands/emails.js +140 -0
- package/dist/commands/emails.js.map +1 -0
- package/dist/commands/lists.d.ts +5 -0
- package/dist/commands/lists.d.ts.map +1 -0
- package/dist/commands/lists.js +102 -0
- package/dist/commands/lists.js.map +1 -0
- package/dist/commands/senders.d.ts +5 -0
- package/dist/commands/senders.d.ts.map +1 -0
- package/dist/commands/senders.js +168 -0
- package/dist/commands/senders.js.map +1 -0
- package/dist/commands/templates.d.ts +5 -0
- package/dist/commands/templates.d.ts.map +1 -0
- package/dist/commands/templates.js +198 -0
- package/dist/commands/templates.js.map +1 -0
- package/dist/commands/webhooks.d.ts +5 -0
- package/dist/commands/webhooks.d.ts.map +1 -0
- package/dist/commands/webhooks.js +144 -0
- package/dist/commands/webhooks.js.map +1 -0
- package/dist/utils/config.d.ts +7 -0
- package/dist/utils/config.d.ts.map +1 -0
- package/dist/utils/config.js +21 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/output.d.ts +16 -0
- package/dist/utils/output.d.ts.map +1 -0
- package/dist/utils/output.js +197 -0
- package/dist/utils/output.js.map +1 -0
- package/package.json +57 -0
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import ora from 'ora';
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
export function createEmailsCommand(client, formatter) {
|
|
5
|
+
const emails = new Command('emails')
|
|
6
|
+
.description('Manage Email API v2 - Send and track transactional emails');
|
|
7
|
+
// Submit email
|
|
8
|
+
emails
|
|
9
|
+
.command('send')
|
|
10
|
+
.description('Submit an email to be sent')
|
|
11
|
+
.requiredOption('-t, --to <email>', 'Recipient email address')
|
|
12
|
+
.requiredOption('-s, --subject <subject>', 'Email subject')
|
|
13
|
+
.option('--from-email <email>', 'Sender email address')
|
|
14
|
+
.option('--from-name <name>', 'Sender name')
|
|
15
|
+
.option('--reply-to <email>', 'Reply-to email address')
|
|
16
|
+
.option('--html <html>', 'HTML content')
|
|
17
|
+
.option('--html-file <path>', 'Path to HTML file')
|
|
18
|
+
.option('--text <text>', 'Plain text content')
|
|
19
|
+
.option('--text-file <path>', 'Path to text file')
|
|
20
|
+
.option('--template-id <id>', 'Template ID to use')
|
|
21
|
+
.option('--params <json>', 'Template parameters as JSON string')
|
|
22
|
+
.option('--tracking', 'Enable tracking (open/click tracking)')
|
|
23
|
+
.option('--tags <tags>', 'Comma-separated tags for categorization')
|
|
24
|
+
.option('--headers <json>', 'Custom headers as JSON object')
|
|
25
|
+
.option('--attachments <json>', 'Attachments as JSON array')
|
|
26
|
+
.action(async (options) => {
|
|
27
|
+
const spinner = ora('Submitting email...').start();
|
|
28
|
+
try {
|
|
29
|
+
const payload = {
|
|
30
|
+
to: options.to,
|
|
31
|
+
subject: options.subject,
|
|
32
|
+
};
|
|
33
|
+
// From
|
|
34
|
+
if (options.fromEmail) {
|
|
35
|
+
payload.from = { email: options.fromEmail };
|
|
36
|
+
if (options.fromName)
|
|
37
|
+
payload.from.name = options.fromName;
|
|
38
|
+
}
|
|
39
|
+
// Reply-to
|
|
40
|
+
if (options.replyTo) {
|
|
41
|
+
payload.reply_to = options.replyTo;
|
|
42
|
+
}
|
|
43
|
+
// Content
|
|
44
|
+
if (options.templateId) {
|
|
45
|
+
payload.template_id = parseInt(options.templateId);
|
|
46
|
+
if (options.params) {
|
|
47
|
+
payload.params = JSON.parse(options.params);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
payload.content = {};
|
|
52
|
+
if (options.htmlFile) {
|
|
53
|
+
payload.content.html = fs.readFileSync(options.htmlFile, 'utf-8');
|
|
54
|
+
}
|
|
55
|
+
else if (options.html) {
|
|
56
|
+
payload.content.html = options.html;
|
|
57
|
+
}
|
|
58
|
+
if (options.textFile) {
|
|
59
|
+
payload.content.text = fs.readFileSync(options.textFile, 'utf-8');
|
|
60
|
+
}
|
|
61
|
+
else if (options.text) {
|
|
62
|
+
payload.content.text = options.text;
|
|
63
|
+
}
|
|
64
|
+
if (!payload.content.html && !payload.content.text) {
|
|
65
|
+
spinner.fail();
|
|
66
|
+
formatter.error('Either --html/--html-file, --text/--text-file, or --template-id is required');
|
|
67
|
+
process.exit(1);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
// Tracking
|
|
71
|
+
if (options.tracking !== undefined) {
|
|
72
|
+
payload.tracking = options.tracking;
|
|
73
|
+
}
|
|
74
|
+
// Tags
|
|
75
|
+
if (options.tags) {
|
|
76
|
+
payload.tags = options.tags.split(',').map((t) => t.trim());
|
|
77
|
+
}
|
|
78
|
+
// Headers
|
|
79
|
+
if (options.headers) {
|
|
80
|
+
payload.headers = JSON.parse(options.headers);
|
|
81
|
+
}
|
|
82
|
+
// Attachments
|
|
83
|
+
if (options.attachments) {
|
|
84
|
+
payload.attachments = JSON.parse(options.attachments);
|
|
85
|
+
}
|
|
86
|
+
const data = await client.sdk.email.submit(payload);
|
|
87
|
+
spinner.stop();
|
|
88
|
+
formatter.success(`Email submitted: ${data.id}`);
|
|
89
|
+
formatter.output(data);
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
spinner.stop();
|
|
93
|
+
formatter.error(error.message);
|
|
94
|
+
process.exit(1);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
// Get email
|
|
98
|
+
emails
|
|
99
|
+
.command('get <email-id>')
|
|
100
|
+
.description('Retrieve a submitted email')
|
|
101
|
+
.action(async (emailId) => {
|
|
102
|
+
const spinner = ora(`Fetching email ${emailId}...`).start();
|
|
103
|
+
try {
|
|
104
|
+
const data = await client.sdk.email.retrieve(emailId);
|
|
105
|
+
spinner.stop();
|
|
106
|
+
formatter.output(data);
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
spinner.stop();
|
|
110
|
+
formatter.error(error.message);
|
|
111
|
+
process.exit(1);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
// Render email
|
|
115
|
+
emails
|
|
116
|
+
.command('render <email-id>')
|
|
117
|
+
.description('Render a submitted email (returns HTML)')
|
|
118
|
+
.option('--as-submitted', 'Render the original submitted content')
|
|
119
|
+
.option('--tracking', 'Enable tracking in rendered HTML')
|
|
120
|
+
.action(async (emailId, options) => {
|
|
121
|
+
const spinner = ora(`Rendering email ${emailId}...`).start();
|
|
122
|
+
try {
|
|
123
|
+
const params = {};
|
|
124
|
+
if (options.asSubmitted !== undefined)
|
|
125
|
+
params.as_submitted = options.asSubmitted;
|
|
126
|
+
if (options.tracking !== undefined)
|
|
127
|
+
params.tracking = options.tracking;
|
|
128
|
+
const data = await client.sdk.email.render(emailId, params);
|
|
129
|
+
spinner.stop();
|
|
130
|
+
formatter.output(data);
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
spinner.stop();
|
|
134
|
+
formatter.error(error.message);
|
|
135
|
+
process.exit(1);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
return emails;
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=emails.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version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;QACjC,MAAM,OAAO,GAAG,GAAG,CAAC,mBAAmB,OAAO,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC;QAC7D,IAAI,CAAC;YACH,MAAM,MAAM,GAAQ,EAAE,CAAC;YACvB,IAAI,OAAO,CAAC,WAAW,KAAK,SAAS;gBAAE,MAAM,CAAC,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC;YACjF,IAAI,OAAO,CAAC,QAAQ,KAAK,SAAS;gBAAE,MAAM,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;YAEvE,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YAC5D,OAAO,CAAC,IAAI,EAAE,CAAC;YACf,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACzB,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,OAAO,CAAC,IAAI,EAAE,CAAC;YACf,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YAC/B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;IAEL,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { CakemailClient } from '../client.js';
|
|
3
|
+
import { OutputFormatter } from '../utils/output.js';
|
|
4
|
+
export declare function createListsCommand(client: CakemailClient, formatter: OutputFormatter): Command;
|
|
5
|
+
//# sourceMappingURL=lists.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lists.d.ts","sourceRoot":"","sources":["../../src/commands/lists.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGrD,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,cAAc,EAAE,SAAS,EAAE,eAAe,GAAG,OAAO,CAiG9F"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import ora from 'ora';
|
|
3
|
+
export function createListsCommand(client, formatter) {
|
|
4
|
+
const lists = new Command('lists')
|
|
5
|
+
.description('Manage contact lists');
|
|
6
|
+
// List all lists
|
|
7
|
+
lists
|
|
8
|
+
.command('list')
|
|
9
|
+
.description('List all contact lists')
|
|
10
|
+
.option('-l, --limit <number>', 'Limit number of results')
|
|
11
|
+
.option('-p, --page <number>', 'Page number')
|
|
12
|
+
.option('--sort <sort>', 'Sort by field: +name, -created_on')
|
|
13
|
+
.option('--filter <filter>', 'Filter (e.g., "status==active;name==Newsletter")')
|
|
14
|
+
.action(async (options) => {
|
|
15
|
+
const spinner = ora('Fetching lists...').start();
|
|
16
|
+
try {
|
|
17
|
+
const params = {};
|
|
18
|
+
if (options.limit)
|
|
19
|
+
params.per_page = parseInt(options.limit);
|
|
20
|
+
if (options.page)
|
|
21
|
+
params.page = parseInt(options.page);
|
|
22
|
+
if (options.sort)
|
|
23
|
+
params.sort = options.sort;
|
|
24
|
+
if (options.filter)
|
|
25
|
+
params.filter = options.filter;
|
|
26
|
+
const data = await client.sdk.lists.list(params);
|
|
27
|
+
spinner.stop();
|
|
28
|
+
formatter.output(data);
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
spinner.stop();
|
|
32
|
+
formatter.error(error.message);
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
// Get list
|
|
37
|
+
lists
|
|
38
|
+
.command('get <id>')
|
|
39
|
+
.description('Get list details')
|
|
40
|
+
.action(async (id) => {
|
|
41
|
+
const spinner = ora(`Fetching list ${id}...`).start();
|
|
42
|
+
try {
|
|
43
|
+
const data = await client.sdk.lists.get(parseInt(id));
|
|
44
|
+
spinner.stop();
|
|
45
|
+
formatter.output(data);
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
spinner.stop();
|
|
49
|
+
formatter.error(error.message);
|
|
50
|
+
process.exit(1);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
// Create list
|
|
54
|
+
lists
|
|
55
|
+
.command('create')
|
|
56
|
+
.description('Create a new list')
|
|
57
|
+
.requiredOption('-n, --name <name>', 'List name')
|
|
58
|
+
.option('-l, --language <lang>', 'Language code (e.g., en, fr)')
|
|
59
|
+
.action(async (options) => {
|
|
60
|
+
const spinner = ora('Creating list...').start();
|
|
61
|
+
try {
|
|
62
|
+
const payload = {
|
|
63
|
+
name: options.name,
|
|
64
|
+
};
|
|
65
|
+
if (options.language)
|
|
66
|
+
payload.language = options.language;
|
|
67
|
+
const data = await client.sdk.lists.create(payload);
|
|
68
|
+
spinner.stop();
|
|
69
|
+
formatter.success(`List created: ${data.id}`);
|
|
70
|
+
formatter.output(data);
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
spinner.stop();
|
|
74
|
+
formatter.error(error.message);
|
|
75
|
+
process.exit(1);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
// Delete list
|
|
79
|
+
lists
|
|
80
|
+
.command('delete <id>')
|
|
81
|
+
.description('Delete a list')
|
|
82
|
+
.option('-f, --force', 'Skip confirmation')
|
|
83
|
+
.action(async (id, options) => {
|
|
84
|
+
if (!options.force) {
|
|
85
|
+
formatter.info('Use --force to confirm deletion');
|
|
86
|
+
process.exit(1);
|
|
87
|
+
}
|
|
88
|
+
const spinner = ora(`Deleting list ${id}...`).start();
|
|
89
|
+
try {
|
|
90
|
+
await client.sdk.lists.delete(parseInt(id));
|
|
91
|
+
spinner.stop();
|
|
92
|
+
formatter.success(`List ${id} deleted`);
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
spinner.stop();
|
|
96
|
+
formatter.error(error.message);
|
|
97
|
+
process.exit(1);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
return lists;
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=lists.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lists.js","sourceRoot":"","sources":["../../src/commands/lists.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,GAAG,MAAM,KAAK,CAAC;AAEtB,MAAM,UAAU,kBAAkB,CAAC,MAAsB,EAAE,SAA0B;IACnF,MAAM,KAAK,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC;SAC/B,WAAW,CAAC,sBAAsB,CAAC,CAAC;IAEvC,iBAAiB;IACjB,KAAK;SACF,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CAAC,wBAAwB,CAAC;SACrC,MAAM,CAAC,sBAAsB,EAAE,yBAAyB,CAAC;SACzD,MAAM,CAAC,qBAAqB,EAAE,aAAa,CAAC;SAC5C,MAAM,CAAC,eAAe,EAAE,mCAAmC,CAAC;SAC5D,MAAM,CAAC,mBAAmB,EAAE,kDAAkD,CAAC;SAC/E,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;QACxB,MAAM,OAAO,GAAG,GAAG,CAAC,mBAAmB,CAAC,CAAC,KAAK,EAAE,CAAC;QACjD,IAAI,CAAC;YACH,MAAM,MAAM,GAAQ,EAAE,CAAC;YACvB,IAAI,OAAO,CAAC,KAAK;gBAAE,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YAC7D,IAAI,OAAO,CAAC,IAAI;gBAAE,MAAM,CAAC,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YACvD,IAAI,OAAO,CAAC,IAAI;gBAAE,MAAM,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;YAC7C,IAAI,OAAO,CAAC,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AAiB,EAAE,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC;QACtD,IAAI,CAAC;YACH,MAAM,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;YAC5C,OAAO,CAAC,IAAI,EAAE,CAAC;YACf,SAAS,CAAC,OAAO,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;QAC1C,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,OAAO,CAAC,IAAI,EAAE,CAAC;YACf,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YAC/B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;IAEL,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { CakemailClient } from '../client.js';
|
|
3
|
+
import { OutputFormatter } from '../utils/output.js';
|
|
4
|
+
export declare function createSendersCommand(client: CakemailClient, formatter: OutputFormatter): Command;
|
|
5
|
+
//# sourceMappingURL=senders.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"senders.d.ts","sourceRoot":"","sources":["../../src/commands/senders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGrD,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,cAAc,EAAE,SAAS,EAAE,eAAe,GAAG,OAAO,CAmKhG"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import ora from 'ora';
|
|
3
|
+
export function createSendersCommand(client, formatter) {
|
|
4
|
+
const senders = new Command('senders')
|
|
5
|
+
.description('Manage email senders');
|
|
6
|
+
// List senders
|
|
7
|
+
senders
|
|
8
|
+
.command('list')
|
|
9
|
+
.description('List all senders')
|
|
10
|
+
.option('-l, --limit <number>', 'Limit number of results')
|
|
11
|
+
.option('-p, --page <number>', 'Page number')
|
|
12
|
+
.option('--sort <sort>', 'Sort by field: +name, +email, -confirmed')
|
|
13
|
+
.option('--filter <filter>', 'Filter (e.g., "confirmed==true;email==sender@example.com")')
|
|
14
|
+
.action(async (options) => {
|
|
15
|
+
const spinner = ora('Fetching senders...').start();
|
|
16
|
+
try {
|
|
17
|
+
const params = {};
|
|
18
|
+
if (options.limit)
|
|
19
|
+
params.perPage = parseInt(options.limit);
|
|
20
|
+
if (options.page)
|
|
21
|
+
params.page = parseInt(options.page);
|
|
22
|
+
if (options.sort)
|
|
23
|
+
params.sort = options.sort;
|
|
24
|
+
const data = await client.sdk.senderService.listSenders(params);
|
|
25
|
+
spinner.stop();
|
|
26
|
+
formatter.output(data);
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
spinner.stop();
|
|
30
|
+
formatter.error(error.message);
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
// Get sender
|
|
35
|
+
senders
|
|
36
|
+
.command('get <id>')
|
|
37
|
+
.description('Get sender details')
|
|
38
|
+
.action(async (id) => {
|
|
39
|
+
const spinner = ora(`Fetching sender ${id}...`).start();
|
|
40
|
+
try {
|
|
41
|
+
const data = await client.sdk.senderService.getSender({ senderId: id });
|
|
42
|
+
spinner.stop();
|
|
43
|
+
formatter.output(data);
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
spinner.stop();
|
|
47
|
+
formatter.error(error.message);
|
|
48
|
+
process.exit(1);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
// Create sender
|
|
52
|
+
senders
|
|
53
|
+
.command('create')
|
|
54
|
+
.description('Create a new sender')
|
|
55
|
+
.requiredOption('-n, --name <name>', 'Sender name')
|
|
56
|
+
.requiredOption('-e, --email <email>', 'Sender email')
|
|
57
|
+
.action(async (options) => {
|
|
58
|
+
const spinner = ora('Creating sender...').start();
|
|
59
|
+
try {
|
|
60
|
+
const data = await client.sdk.senderService.createSender({
|
|
61
|
+
requestBody: {
|
|
62
|
+
name: options.name,
|
|
63
|
+
email: options.email,
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
spinner.stop();
|
|
67
|
+
formatter.success(`Sender created: ${data.id}`);
|
|
68
|
+
formatter.info('A confirmation email has been sent to verify this sender');
|
|
69
|
+
formatter.output(data);
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
spinner.stop();
|
|
73
|
+
formatter.error(error.message);
|
|
74
|
+
process.exit(1);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
// Update sender
|
|
78
|
+
senders
|
|
79
|
+
.command('update <id>')
|
|
80
|
+
.description('Update a sender')
|
|
81
|
+
.option('-n, --name <name>', 'Sender name')
|
|
82
|
+
.option('-e, --email <email>', 'Sender email')
|
|
83
|
+
.action(async (id, options) => {
|
|
84
|
+
const spinner = ora(`Updating sender ${id}...`).start();
|
|
85
|
+
try {
|
|
86
|
+
const payload = {};
|
|
87
|
+
if (options.name)
|
|
88
|
+
payload.name = options.name;
|
|
89
|
+
if (options.email)
|
|
90
|
+
payload.email = options.email;
|
|
91
|
+
const data = await client.sdk.senderService.patchSender({
|
|
92
|
+
senderId: id,
|
|
93
|
+
requestBody: payload
|
|
94
|
+
});
|
|
95
|
+
spinner.stop();
|
|
96
|
+
formatter.success(`Sender ${id} updated`);
|
|
97
|
+
formatter.output(data);
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
spinner.stop();
|
|
101
|
+
formatter.error(error.message);
|
|
102
|
+
process.exit(1);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
// Delete sender
|
|
106
|
+
senders
|
|
107
|
+
.command('delete <id>')
|
|
108
|
+
.description('Delete a sender')
|
|
109
|
+
.option('-f, --force', 'Skip confirmation')
|
|
110
|
+
.action(async (id, options) => {
|
|
111
|
+
if (!options.force) {
|
|
112
|
+
formatter.info('Use --force to confirm deletion');
|
|
113
|
+
process.exit(1);
|
|
114
|
+
}
|
|
115
|
+
const spinner = ora(`Deleting sender ${id}...`).start();
|
|
116
|
+
try {
|
|
117
|
+
await client.sdk.senderService.deleteSender({ senderId: id });
|
|
118
|
+
spinner.stop();
|
|
119
|
+
formatter.success(`Sender ${id} deleted`);
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
spinner.stop();
|
|
123
|
+
formatter.error(error.message);
|
|
124
|
+
process.exit(1);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
// Confirm sender
|
|
128
|
+
senders
|
|
129
|
+
.command('confirm <confirmation-id>')
|
|
130
|
+
.description('Confirm sender email using confirmation ID from email')
|
|
131
|
+
.action(async (confirmationId) => {
|
|
132
|
+
const spinner = ora(`Confirming sender...`).start();
|
|
133
|
+
try {
|
|
134
|
+
const data = await client.sdk.senderService.confirmSender({
|
|
135
|
+
requestBody: {
|
|
136
|
+
confirmation_id: confirmationId
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
spinner.stop();
|
|
140
|
+
formatter.success('Sender confirmed');
|
|
141
|
+
formatter.output(data);
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
spinner.stop();
|
|
145
|
+
formatter.error(error.message);
|
|
146
|
+
process.exit(1);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
// Resend confirmation
|
|
150
|
+
senders
|
|
151
|
+
.command('resend-confirmation <id>')
|
|
152
|
+
.description('Resend confirmation email')
|
|
153
|
+
.action(async (id) => {
|
|
154
|
+
const spinner = ora(`Resending confirmation for sender ${id}...`).start();
|
|
155
|
+
try {
|
|
156
|
+
await client.sdk.senderService.resendConfirmationEmail({ senderId: id });
|
|
157
|
+
spinner.stop();
|
|
158
|
+
formatter.success(`Confirmation email resent for sender ${id}`);
|
|
159
|
+
}
|
|
160
|
+
catch (error) {
|
|
161
|
+
spinner.stop();
|
|
162
|
+
formatter.error(error.message);
|
|
163
|
+
process.exit(1);
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
return senders;
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=senders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"senders.js","sourceRoot":"","sources":["../../src/commands/senders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,GAAG,MAAM,KAAK,CAAC;AAEtB,MAAM,UAAU,oBAAoB,CAAC,MAAsB,EAAE,SAA0B;IACrF,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,SAAS,CAAC;SACnC,WAAW,CAAC,sBAAsB,CAAC,CAAC;IAEvC,eAAe;IACf,OAAO;SACJ,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CAAC,kBAAkB,CAAC;SAC/B,MAAM,CAAC,sBAAsB,EAAE,yBAAyB,CAAC;SACzD,MAAM,CAAC,qBAAqB,EAAE,aAAa,CAAC;SAC5C,MAAM,CAAC,eAAe,EAAE,0CAA0C,CAAC;SACnE,MAAM,CAAC,mBAAmB,EAAE,4DAA4D,CAAC;SACzF,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;QACxB,MAAM,OAAO,GAAG,GAAG,CAAC,qBAAqB,CAAC,CAAC,KAAK,EAAE,CAAC;QACnD,IAAI,CAAC;YACH,MAAM,MAAM,GAAQ,EAAE,CAAC;YACvB,IAAI,OAAO,CAAC,KAAK;gBAAE,MAAM,CAAC,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YAC5D,IAAI,OAAO,CAAC,IAAI;gBAAE,MAAM,CAAC,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YACvD,IAAI,OAAO,CA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C,qCAAqC,EAAE,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC;QAC1E,IAAI,CAAC;YACH,MAAM,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,uBAAuB,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC;YACzE,OAAO,CAAC,IAAI,EAAE,CAAC;YACf,SAAS,CAAC,OAAO,CAAC,wCAAwC,EAAE,EAAE,CAAC,CAAC;QAClE,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,OAAO,CAAC,IAAI,EAAE,CAAC;YACf,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YAC/B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;IAEL,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { CakemailClient } from '../client.js';
|
|
3
|
+
import { OutputFormatter } from '../utils/output.js';
|
|
4
|
+
export declare function createTemplatesCommand(client: CakemailClient, formatter: OutputFormatter): Command;
|
|
5
|
+
//# sourceMappingURL=templates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/commands/templates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAIrD,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,cAAc,EAAE,SAAS,EAAE,eAAe,GAAG,OAAO,CAsMlG"}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import ora from 'ora';
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
export function createTemplatesCommand(client, formatter) {
|
|
5
|
+
const templates = new Command('templates')
|
|
6
|
+
.description('Manage email templates');
|
|
7
|
+
// List templates
|
|
8
|
+
templates
|
|
9
|
+
.command('list')
|
|
10
|
+
.description('List all templates')
|
|
11
|
+
.option('-l, --limit <number>', 'Limit number of results')
|
|
12
|
+
.option('-p, --page <number>', 'Page number')
|
|
13
|
+
.option('-f, --filter <filter>', 'Filter by tag, name, or ownership (e.g., "name==Newsletter")')
|
|
14
|
+
.option('-s, --sort <sort>', 'Sort by field (e.g., "+name", "-created_on")')
|
|
15
|
+
.action(async (options) => {
|
|
16
|
+
const spinner = ora('Fetching templates...').start();
|
|
17
|
+
try {
|
|
18
|
+
const params = {};
|
|
19
|
+
if (options.limit)
|
|
20
|
+
params.perPage = parseInt(options.limit);
|
|
21
|
+
if (options.page)
|
|
22
|
+
params.page = parseInt(options.page);
|
|
23
|
+
if (options.filter)
|
|
24
|
+
params.filter = options.filter;
|
|
25
|
+
if (options.sort)
|
|
26
|
+
params.sort = options.sort;
|
|
27
|
+
const data = await client.sdk.templateService.listTemplates(params);
|
|
28
|
+
spinner.stop();
|
|
29
|
+
formatter.output(data);
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
spinner.stop();
|
|
33
|
+
formatter.error(error.message);
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
// Get template
|
|
38
|
+
templates
|
|
39
|
+
.command('get <id>')
|
|
40
|
+
.description('Get template details')
|
|
41
|
+
.action(async (id) => {
|
|
42
|
+
const spinner = ora(`Fetching template ${id}...`).start();
|
|
43
|
+
try {
|
|
44
|
+
const data = await client.sdk.templateService.getTemplate({ templateId: parseInt(id) });
|
|
45
|
+
spinner.stop();
|
|
46
|
+
formatter.output(data);
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
spinner.stop();
|
|
50
|
+
formatter.error(error.message);
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
// Create template
|
|
55
|
+
templates
|
|
56
|
+
.command('create')
|
|
57
|
+
.description('Create a new template')
|
|
58
|
+
.requiredOption('-n, --name <name>', 'Template name')
|
|
59
|
+
.option('--html <html>', 'HTML content')
|
|
60
|
+
.option('--html-file <path>', 'Path to HTML file')
|
|
61
|
+
.option('--text <text>', 'Plain text content')
|
|
62
|
+
.option('--text-file <path>', 'Path to text file')
|
|
63
|
+
.option('--subject <subject>', 'Default email subject')
|
|
64
|
+
.option('--tags <tags>', 'Comma-separated tags')
|
|
65
|
+
.action(async (options) => {
|
|
66
|
+
const spinner = ora('Creating template...').start();
|
|
67
|
+
try {
|
|
68
|
+
const payload = {
|
|
69
|
+
name: options.name,
|
|
70
|
+
};
|
|
71
|
+
// HTML content
|
|
72
|
+
if (options.htmlFile) {
|
|
73
|
+
payload.html = fs.readFileSync(options.htmlFile, 'utf-8');
|
|
74
|
+
}
|
|
75
|
+
else if (options.html) {
|
|
76
|
+
payload.html = options.html;
|
|
77
|
+
}
|
|
78
|
+
// Text content
|
|
79
|
+
if (options.textFile) {
|
|
80
|
+
payload.text = fs.readFileSync(options.textFile, 'utf-8');
|
|
81
|
+
}
|
|
82
|
+
else if (options.text) {
|
|
83
|
+
payload.text = options.text;
|
|
84
|
+
}
|
|
85
|
+
// Subject
|
|
86
|
+
if (options.subject) {
|
|
87
|
+
payload.subject = options.subject;
|
|
88
|
+
}
|
|
89
|
+
// Tags
|
|
90
|
+
if (options.tags) {
|
|
91
|
+
payload.tags = options.tags.split(',').map((t) => t.trim());
|
|
92
|
+
}
|
|
93
|
+
const data = await client.sdk.templateService.createTemplate({ requestBody: payload });
|
|
94
|
+
spinner.stop();
|
|
95
|
+
formatter.success(`Template created: ${data.id}`);
|
|
96
|
+
formatter.output(data);
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
spinner.stop();
|
|
100
|
+
formatter.error(error.message);
|
|
101
|
+
process.exit(1);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
// Update template
|
|
105
|
+
templates
|
|
106
|
+
.command('update <id>')
|
|
107
|
+
.description('Update a template')
|
|
108
|
+
.option('-n, --name <name>', 'Template name')
|
|
109
|
+
.option('--html <html>', 'HTML content')
|
|
110
|
+
.option('--html-file <path>', 'Path to HTML file')
|
|
111
|
+
.option('--text <text>', 'Plain text content')
|
|
112
|
+
.option('--text-file <path>', 'Path to text file')
|
|
113
|
+
.option('--subject <subject>', 'Default email subject')
|
|
114
|
+
.option('--tags <tags>', 'Comma-separated tags')
|
|
115
|
+
.action(async (id, options) => {
|
|
116
|
+
const spinner = ora(`Updating template ${id}...`).start();
|
|
117
|
+
try {
|
|
118
|
+
const payload = {};
|
|
119
|
+
if (options.name)
|
|
120
|
+
payload.name = options.name;
|
|
121
|
+
// HTML content
|
|
122
|
+
if (options.htmlFile) {
|
|
123
|
+
payload.html = fs.readFileSync(options.htmlFile, 'utf-8');
|
|
124
|
+
}
|
|
125
|
+
else if (options.html) {
|
|
126
|
+
payload.html = options.html;
|
|
127
|
+
}
|
|
128
|
+
// Text content
|
|
129
|
+
if (options.textFile) {
|
|
130
|
+
payload.text = fs.readFileSync(options.textFile, 'utf-8');
|
|
131
|
+
}
|
|
132
|
+
else if (options.text) {
|
|
133
|
+
payload.text = options.text;
|
|
134
|
+
}
|
|
135
|
+
// Subject
|
|
136
|
+
if (options.subject) {
|
|
137
|
+
payload.subject = options.subject;
|
|
138
|
+
}
|
|
139
|
+
// Tags
|
|
140
|
+
if (options.tags) {
|
|
141
|
+
payload.tags = options.tags.split(',').map((t) => t.trim());
|
|
142
|
+
}
|
|
143
|
+
const data = await client.sdk.templateService.patchTemplate({
|
|
144
|
+
templateId: parseInt(id),
|
|
145
|
+
requestBody: payload
|
|
146
|
+
});
|
|
147
|
+
spinner.stop();
|
|
148
|
+
formatter.success(`Template ${id} updated`);
|
|
149
|
+
formatter.output(data);
|
|
150
|
+
}
|
|
151
|
+
catch (error) {
|
|
152
|
+
spinner.stop();
|
|
153
|
+
formatter.error(error.message);
|
|
154
|
+
process.exit(1);
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
// Render template
|
|
158
|
+
templates
|
|
159
|
+
.command('render <id>')
|
|
160
|
+
.description('Render/preview a template')
|
|
161
|
+
.action(async (id) => {
|
|
162
|
+
const spinner = ora(`Rendering template ${id}...`).start();
|
|
163
|
+
try {
|
|
164
|
+
const data = await client.sdk.templateService.renderTemplate({ templateId: parseInt(id) });
|
|
165
|
+
spinner.stop();
|
|
166
|
+
formatter.output(data);
|
|
167
|
+
}
|
|
168
|
+
catch (error) {
|
|
169
|
+
spinner.stop();
|
|
170
|
+
formatter.error(error.message);
|
|
171
|
+
process.exit(1);
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
// Delete template
|
|
175
|
+
templates
|
|
176
|
+
.command('delete <id>')
|
|
177
|
+
.description('Delete a template')
|
|
178
|
+
.option('-f, --force', 'Skip confirmation')
|
|
179
|
+
.action(async (id, options) => {
|
|
180
|
+
if (!options.force) {
|
|
181
|
+
formatter.info('Use --force to confirm deletion');
|
|
182
|
+
process.exit(1);
|
|
183
|
+
}
|
|
184
|
+
const spinner = ora(`Deleting template ${id}...`).start();
|
|
185
|
+
try {
|
|
186
|
+
await client.sdk.templateService.deleteTemplate({ templateId: parseInt(id) });
|
|
187
|
+
spinner.stop();
|
|
188
|
+
formatter.success(`Template ${id} deleted`);
|
|
189
|
+
}
|
|
190
|
+
catch (error) {
|
|
191
|
+
spinner.stop();
|
|
192
|
+
formatter.error(error.message);
|
|
193
|
+
process.exit(1);
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
return templates;
|
|
197
|
+
}
|
|
198
|
+
//# sourceMappingURL=templates.js.map
|