@hintergrund/worker 0.1.2 → 0.1.5
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/dist/api/cms/handlers/assets.handler.d.ts +24 -1
- package/dist/api/cms/handlers/assets.handler.d.ts.map +1 -1
- package/dist/api/cms/handlers/assets.handler.js +111 -210
- package/dist/api/cms/handlers/auth.handler.d.ts +4 -3
- package/dist/api/cms/handlers/auth.handler.d.ts.map +1 -1
- package/dist/api/cms/handlers/auth.handler.js +24 -14
- package/dist/api/cms/handlers/config.handler.d.ts +4 -0
- package/dist/api/cms/handlers/config.handler.d.ts.map +1 -1
- package/dist/api/cms/handlers/config.handler.js +20 -71
- package/dist/api/cms/handlers/content.handler.d.ts +12 -1
- package/dist/api/cms/handlers/content.handler.d.ts.map +1 -1
- package/dist/api/cms/handlers/content.handler.js +57 -233
- package/dist/api/cms/handlers/dashboard.handler.js +1 -1
- package/dist/api/cms/routes/auth.routes.d.ts +2 -1
- package/dist/api/cms/routes/auth.routes.d.ts.map +1 -1
- package/dist/api/cms/routes/auth.routes.js +7 -0
- package/dist/api/cms/routes/index.d.ts +2 -1
- package/dist/api/cms/routes/index.d.ts.map +1 -1
- package/dist/api/emails/handlers/branding.handler.d.ts +17 -0
- package/dist/api/emails/handlers/branding.handler.d.ts.map +1 -0
- package/dist/api/emails/handlers/branding.handler.js +120 -0
- package/dist/api/emails/handlers/campaigns.handler.d.ts +32 -0
- package/dist/api/emails/handlers/campaigns.handler.d.ts.map +1 -0
- package/dist/api/emails/handlers/campaigns.handler.js +139 -0
- package/dist/api/emails/handlers/contacts.handler.d.ts +37 -0
- package/dist/api/emails/handlers/contacts.handler.d.ts.map +1 -0
- package/dist/api/emails/handlers/contacts.handler.js +161 -0
- package/dist/api/emails/handlers/invoice.handler.d.ts +30 -0
- package/dist/api/emails/handlers/invoice.handler.d.ts.map +1 -0
- package/dist/api/emails/handlers/invoice.handler.js +463 -0
- package/dist/api/emails/handlers/public.handler.d.ts +36 -0
- package/dist/api/emails/handlers/public.handler.d.ts.map +1 -0
- package/dist/api/emails/handlers/public.handler.js +350 -0
- package/dist/api/emails/handlers/send.handler.d.ts +23 -0
- package/dist/api/emails/handlers/send.handler.d.ts.map +1 -0
- package/dist/api/emails/handlers/send.handler.js +117 -0
- package/dist/api/emails/handlers/settings.handler.d.ts +36 -0
- package/dist/api/emails/handlers/settings.handler.d.ts.map +1 -0
- package/dist/api/emails/handlers/settings.handler.js +312 -0
- package/dist/api/emails/handlers/templates.handler.d.ts +32 -0
- package/dist/api/emails/handlers/templates.handler.d.ts.map +1 -0
- package/dist/api/emails/handlers/templates.handler.js +132 -0
- package/dist/api/emails/handlers/webhook.handler.d.ts +10 -0
- package/dist/api/emails/handlers/webhook.handler.d.ts.map +1 -0
- package/dist/api/emails/handlers/webhook.handler.js +261 -0
- package/dist/api/emails/routes/admin.routes.d.ts +9 -0
- package/dist/api/emails/routes/admin.routes.d.ts.map +1 -0
- package/dist/api/emails/routes/admin.routes.js +77 -0
- package/dist/api/emails/routes/index.d.ts +9 -0
- package/dist/api/emails/routes/index.d.ts.map +1 -0
- package/dist/api/emails/routes/index.js +14 -0
- package/dist/api/emails/routes/public.routes.d.ts +9 -0
- package/dist/api/emails/routes/public.routes.d.ts.map +1 -0
- package/dist/api/emails/routes/public.routes.js +18 -0
- package/dist/api/shop/handlers/webhook.handler.d.ts.map +1 -1
- package/dist/api/shop/handlers/webhook.handler.js +66 -60
- package/dist/api/shop/routes.d.ts.map +1 -1
- package/dist/api/shop/routes.js +0 -3
- package/dist/hintergrund-assets.d.ts +2 -2
- package/dist/hintergrund-assets.d.ts.map +1 -1
- package/dist/hintergrund-assets.js +2 -2
- package/dist/index.d.ts +20 -19
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -7
- package/dist/lib/config.d.ts +13 -7
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +44 -46
- package/dist/lib/email.d.ts +2 -2
- package/dist/lib/email.d.ts.map +1 -1
- package/dist/lib/email.js +7 -9
- package/dist/lib/github.d.ts +124 -0
- package/dist/lib/github.d.ts.map +1 -0
- package/dist/lib/github.js +286 -0
- package/dist/lib/plunk.d.ts +204 -0
- package/dist/lib/plunk.d.ts.map +1 -0
- package/dist/lib/plunk.js +259 -0
- package/dist/middleware/auth.d.ts.map +1 -1
- package/dist/middleware/auth.js +2 -5
- package/package.json +32 -32
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared GitHub Utilities
|
|
3
|
+
*
|
|
4
|
+
* Provides common GitHub operations for both CMS and Emails modules.
|
|
5
|
+
* Uses Octokit for GitHub API interactions with proper UTF-8 handling.
|
|
6
|
+
*/
|
|
7
|
+
import { Octokit } from '@octokit/rest';
|
|
8
|
+
/**
|
|
9
|
+
* Decode base64 content to UTF-8 string.
|
|
10
|
+
* atob() decodes to Latin-1, which corrupts multi-byte UTF-8 characters.
|
|
11
|
+
*/
|
|
12
|
+
export function decodeBase64UTF8(base64) {
|
|
13
|
+
const binaryString = atob(base64);
|
|
14
|
+
const bytes = new Uint8Array(binaryString.length);
|
|
15
|
+
for (let i = 0; i < binaryString.length; i++) {
|
|
16
|
+
bytes[i] = binaryString.charCodeAt(i);
|
|
17
|
+
}
|
|
18
|
+
return new TextDecoder('utf-8').decode(bytes);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Encode UTF-8 string to base64.
|
|
22
|
+
* btoa() only works with Latin-1, which corrupts multi-byte UTF-8 characters like ß.
|
|
23
|
+
*/
|
|
24
|
+
export function encodeUTF8Base64(str) {
|
|
25
|
+
const bytes = new TextEncoder().encode(str);
|
|
26
|
+
let binaryString = '';
|
|
27
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
28
|
+
binaryString += String.fromCharCode(bytes[i]);
|
|
29
|
+
}
|
|
30
|
+
return btoa(binaryString);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* GitHub client wrapper for common operations
|
|
34
|
+
*/
|
|
35
|
+
export class GitHubClient {
|
|
36
|
+
constructor(config) {
|
|
37
|
+
this.octokit = new Octokit({ auth: config.gitToken });
|
|
38
|
+
this.owner = config.gitOwner;
|
|
39
|
+
this.repo = config.gitRepo;
|
|
40
|
+
this.branch = config.gitBranch;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Get the current commit SHA of the branch
|
|
44
|
+
*/
|
|
45
|
+
async getCommitSha() {
|
|
46
|
+
const ref = await this.octokit.rest.git.getRef({
|
|
47
|
+
owner: this.owner,
|
|
48
|
+
repo: this.repo,
|
|
49
|
+
ref: `heads/${this.branch}`
|
|
50
|
+
});
|
|
51
|
+
return ref.data.object.sha;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Read a single file from the repository
|
|
55
|
+
* Returns null if file doesn't exist
|
|
56
|
+
*/
|
|
57
|
+
async readFile(path) {
|
|
58
|
+
try {
|
|
59
|
+
const response = await this.octokit.rest.repos.getContent({
|
|
60
|
+
owner: this.owner,
|
|
61
|
+
repo: this.repo,
|
|
62
|
+
path,
|
|
63
|
+
ref: this.branch
|
|
64
|
+
});
|
|
65
|
+
if (Array.isArray(response.data) || !('content' in response.data)) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
content: decodeBase64UTF8(response.data.content || ''),
|
|
70
|
+
sha: response.data.sha
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
if (error.status === 404) {
|
|
75
|
+
console.warn(`[GitHub] File not found: ${path}`);
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
throw error;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Read a binary file from the repository (returns raw base64 without UTF-8 decoding)
|
|
83
|
+
* Use this for images, videos, and other binary files
|
|
84
|
+
* Returns null if file doesn't exist
|
|
85
|
+
*/
|
|
86
|
+
async readFileBinary(path) {
|
|
87
|
+
try {
|
|
88
|
+
const response = await this.octokit.rest.repos.getContent({
|
|
89
|
+
owner: this.owner,
|
|
90
|
+
repo: this.repo,
|
|
91
|
+
path,
|
|
92
|
+
ref: this.branch
|
|
93
|
+
});
|
|
94
|
+
if (Array.isArray(response.data) || !('content' in response.data)) {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
// Return raw base64 content without decoding (for binary files)
|
|
98
|
+
// GitHub returns base64 with newlines, so we need to clean it
|
|
99
|
+
const rawContent = (response.data.content || '').replace(/\n/g, '');
|
|
100
|
+
return {
|
|
101
|
+
content: rawContent,
|
|
102
|
+
sha: response.data.sha
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
if (error.status === 404) {
|
|
107
|
+
console.warn(`[GitHub] File not found: ${path}`);
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
throw error;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Read a JSON file from the repository
|
|
115
|
+
* Returns null if file doesn't exist
|
|
116
|
+
*/
|
|
117
|
+
async readJsonFile(path) {
|
|
118
|
+
const result = await this.readFile(path);
|
|
119
|
+
if (!result)
|
|
120
|
+
return null;
|
|
121
|
+
return {
|
|
122
|
+
data: JSON.parse(result.content),
|
|
123
|
+
sha: result.sha
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Read multiple files in parallel
|
|
128
|
+
*/
|
|
129
|
+
async readFiles(paths) {
|
|
130
|
+
const results = await Promise.all(paths.map(async (path) => {
|
|
131
|
+
const result = await this.readFile(path);
|
|
132
|
+
return [path, result];
|
|
133
|
+
}));
|
|
134
|
+
return new Map(results);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Write a single file to the repository
|
|
138
|
+
* Creates the file if it doesn't exist, updates if it does
|
|
139
|
+
*/
|
|
140
|
+
async writeFile(path, content, message) {
|
|
141
|
+
// Get existing file SHA if it exists
|
|
142
|
+
const existing = await this.readFile(path);
|
|
143
|
+
const response = await this.octokit.rest.repos.createOrUpdateFileContents({
|
|
144
|
+
owner: this.owner,
|
|
145
|
+
repo: this.repo,
|
|
146
|
+
path,
|
|
147
|
+
message,
|
|
148
|
+
content: encodeUTF8Base64(content),
|
|
149
|
+
branch: this.branch,
|
|
150
|
+
sha: existing?.sha
|
|
151
|
+
});
|
|
152
|
+
return response.data.commit.sha || '';
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Write a JSON file to the repository
|
|
156
|
+
*/
|
|
157
|
+
async writeJsonFile(path, data, message) {
|
|
158
|
+
const content = JSON.stringify(data, null, 2);
|
|
159
|
+
return this.writeFile(path, content, message);
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Write multiple files atomically in a single commit
|
|
163
|
+
* This uses the Git Data API (blob → tree → commit → update ref)
|
|
164
|
+
*/
|
|
165
|
+
async writeFilesAtomic(files, message, baseCommitSha) {
|
|
166
|
+
// Get base commit SHA if not provided
|
|
167
|
+
const commitSha = baseCommitSha || await this.getCommitSha();
|
|
168
|
+
// Get the commit to find tree SHA
|
|
169
|
+
const commit = await this.octokit.rest.git.getCommit({
|
|
170
|
+
owner: this.owner,
|
|
171
|
+
repo: this.repo,
|
|
172
|
+
commit_sha: commitSha
|
|
173
|
+
});
|
|
174
|
+
// Create blobs for all files
|
|
175
|
+
const blobs = await Promise.all(files.map(async (file) => {
|
|
176
|
+
const blob = await this.octokit.rest.git.createBlob({
|
|
177
|
+
owner: this.owner,
|
|
178
|
+
repo: this.repo,
|
|
179
|
+
content: file.content,
|
|
180
|
+
encoding: 'utf-8'
|
|
181
|
+
});
|
|
182
|
+
return {
|
|
183
|
+
path: file.path,
|
|
184
|
+
mode: '100644',
|
|
185
|
+
type: 'blob',
|
|
186
|
+
sha: blob.data.sha
|
|
187
|
+
};
|
|
188
|
+
}));
|
|
189
|
+
// Create new tree
|
|
190
|
+
const newTree = await this.octokit.rest.git.createTree({
|
|
191
|
+
owner: this.owner,
|
|
192
|
+
repo: this.repo,
|
|
193
|
+
tree: blobs,
|
|
194
|
+
base_tree: commit.data.tree.sha
|
|
195
|
+
});
|
|
196
|
+
// Create new commit
|
|
197
|
+
const newCommit = await this.octokit.rest.git.createCommit({
|
|
198
|
+
owner: this.owner,
|
|
199
|
+
repo: this.repo,
|
|
200
|
+
message,
|
|
201
|
+
tree: newTree.data.sha,
|
|
202
|
+
parents: [commit.data.sha]
|
|
203
|
+
});
|
|
204
|
+
// Update reference
|
|
205
|
+
await this.octokit.rest.git.updateRef({
|
|
206
|
+
owner: this.owner,
|
|
207
|
+
repo: this.repo,
|
|
208
|
+
ref: `heads/${this.branch}`,
|
|
209
|
+
sha: newCommit.data.sha
|
|
210
|
+
});
|
|
211
|
+
return newCommit.data.sha;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Delete a file from the repository
|
|
215
|
+
*/
|
|
216
|
+
async deleteFile(path, message) {
|
|
217
|
+
const existing = await this.readFile(path);
|
|
218
|
+
if (!existing) {
|
|
219
|
+
return; // File doesn't exist, nothing to delete
|
|
220
|
+
}
|
|
221
|
+
await this.octokit.rest.repos.deleteFile({
|
|
222
|
+
owner: this.owner,
|
|
223
|
+
repo: this.repo,
|
|
224
|
+
path,
|
|
225
|
+
message,
|
|
226
|
+
sha: existing.sha,
|
|
227
|
+
branch: this.branch
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* List files in a directory
|
|
232
|
+
*/
|
|
233
|
+
async listDirectory(path) {
|
|
234
|
+
try {
|
|
235
|
+
const response = await this.octokit.rest.repos.getContent({
|
|
236
|
+
owner: this.owner,
|
|
237
|
+
repo: this.repo,
|
|
238
|
+
path,
|
|
239
|
+
ref: this.branch
|
|
240
|
+
});
|
|
241
|
+
if (!Array.isArray(response.data)) {
|
|
242
|
+
return [];
|
|
243
|
+
}
|
|
244
|
+
return response.data
|
|
245
|
+
.filter((item) => item.type === 'file')
|
|
246
|
+
.map((item) => item.path);
|
|
247
|
+
}
|
|
248
|
+
catch (error) {
|
|
249
|
+
if (error.status === 404) {
|
|
250
|
+
console.warn(`[GitHub] Directory not found: ${path}`);
|
|
251
|
+
return [];
|
|
252
|
+
}
|
|
253
|
+
throw error;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Check if commit SHA matches current branch HEAD
|
|
258
|
+
* Returns true if they match (no conflict), false if there's a conflict
|
|
259
|
+
*/
|
|
260
|
+
async checkNoConflict(expectedSha) {
|
|
261
|
+
const currentSha = await this.getCommitSha();
|
|
262
|
+
return expectedSha === currentSha;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Get raw Octokit instance for advanced operations
|
|
266
|
+
*/
|
|
267
|
+
getOctokit() {
|
|
268
|
+
return this.octokit;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Get repository info
|
|
272
|
+
*/
|
|
273
|
+
getRepoInfo() {
|
|
274
|
+
return {
|
|
275
|
+
owner: this.owner,
|
|
276
|
+
repo: this.repo,
|
|
277
|
+
branch: this.branch
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Create a GitHub client from CMS module config
|
|
283
|
+
*/
|
|
284
|
+
export function createGitHubClient(config) {
|
|
285
|
+
return new GitHubClient(config);
|
|
286
|
+
}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plunk API Client
|
|
3
|
+
*
|
|
4
|
+
* Provides methods for interacting with Plunk's email marketing API:
|
|
5
|
+
* - Contacts management
|
|
6
|
+
* - Templates management
|
|
7
|
+
* - Campaigns management
|
|
8
|
+
* - Transactional email sending
|
|
9
|
+
* - Event tracking
|
|
10
|
+
*/
|
|
11
|
+
import type { Contact, PlunkTemplate, PlunkCampaign } from '@hintergrund/shared';
|
|
12
|
+
interface PlunkConfig {
|
|
13
|
+
secretKey: string;
|
|
14
|
+
publicKey?: string;
|
|
15
|
+
}
|
|
16
|
+
interface PlunkContactResponse {
|
|
17
|
+
success: boolean;
|
|
18
|
+
id: string;
|
|
19
|
+
email: string;
|
|
20
|
+
subscribed: boolean;
|
|
21
|
+
}
|
|
22
|
+
interface PlunkTemplateResponse {
|
|
23
|
+
success: boolean;
|
|
24
|
+
id: string;
|
|
25
|
+
}
|
|
26
|
+
interface PlunkCampaignResponse {
|
|
27
|
+
success: boolean;
|
|
28
|
+
id: string;
|
|
29
|
+
timestamp: string;
|
|
30
|
+
emails?: PlunkCampaignEmail[];
|
|
31
|
+
}
|
|
32
|
+
interface PlunkCampaignEmail {
|
|
33
|
+
contact: string;
|
|
34
|
+
email: string;
|
|
35
|
+
}
|
|
36
|
+
interface PlunkSendResponse {
|
|
37
|
+
success: boolean;
|
|
38
|
+
emails?: Array<{
|
|
39
|
+
contact: {
|
|
40
|
+
id: string;
|
|
41
|
+
};
|
|
42
|
+
email: string;
|
|
43
|
+
}>;
|
|
44
|
+
}
|
|
45
|
+
interface PlunkTrackResponse {
|
|
46
|
+
success: boolean;
|
|
47
|
+
contact: string;
|
|
48
|
+
event: string;
|
|
49
|
+
timestamp: string;
|
|
50
|
+
}
|
|
51
|
+
export declare class PlunkClient {
|
|
52
|
+
private baseUrl;
|
|
53
|
+
private secretKey;
|
|
54
|
+
private publicKey?;
|
|
55
|
+
constructor(config: PlunkConfig);
|
|
56
|
+
private request;
|
|
57
|
+
/**
|
|
58
|
+
* Get all contacts
|
|
59
|
+
*/
|
|
60
|
+
getContacts(): Promise<{
|
|
61
|
+
contacts: Contact[];
|
|
62
|
+
count: number;
|
|
63
|
+
}>;
|
|
64
|
+
/**
|
|
65
|
+
* Get a single contact by ID
|
|
66
|
+
*/
|
|
67
|
+
getContact(id: string): Promise<Contact>;
|
|
68
|
+
/**
|
|
69
|
+
* Create a new contact
|
|
70
|
+
*/
|
|
71
|
+
createContact(data: {
|
|
72
|
+
email: string;
|
|
73
|
+
subscribed?: boolean;
|
|
74
|
+
data?: Record<string, unknown>;
|
|
75
|
+
}): Promise<PlunkContactResponse>;
|
|
76
|
+
/**
|
|
77
|
+
* Update an existing contact
|
|
78
|
+
*/
|
|
79
|
+
updateContact(id: string, data: {
|
|
80
|
+
subscribed?: boolean;
|
|
81
|
+
data?: Record<string, unknown>;
|
|
82
|
+
}): Promise<PlunkContactResponse>;
|
|
83
|
+
/**
|
|
84
|
+
* Delete a contact
|
|
85
|
+
*/
|
|
86
|
+
deleteContact(id: string): Promise<{
|
|
87
|
+
success: boolean;
|
|
88
|
+
}>;
|
|
89
|
+
/**
|
|
90
|
+
* Subscribe a contact (set subscribed to true)
|
|
91
|
+
*/
|
|
92
|
+
subscribeContact(id: string): Promise<PlunkContactResponse>;
|
|
93
|
+
/**
|
|
94
|
+
* Unsubscribe a contact (set subscribed to false)
|
|
95
|
+
*/
|
|
96
|
+
unsubscribeContact(id: string): Promise<PlunkContactResponse>;
|
|
97
|
+
/**
|
|
98
|
+
* Get all templates
|
|
99
|
+
*/
|
|
100
|
+
getTemplates(): Promise<{
|
|
101
|
+
templates: PlunkTemplate[];
|
|
102
|
+
}>;
|
|
103
|
+
/**
|
|
104
|
+
* Get a single template by ID
|
|
105
|
+
*/
|
|
106
|
+
getTemplate(id: string): Promise<PlunkTemplate>;
|
|
107
|
+
/**
|
|
108
|
+
* Create a new template
|
|
109
|
+
*/
|
|
110
|
+
createTemplate(data: {
|
|
111
|
+
name: string;
|
|
112
|
+
subject: string;
|
|
113
|
+
body: string;
|
|
114
|
+
type?: 'TRANSACTIONAL' | 'MARKETING';
|
|
115
|
+
}): Promise<PlunkTemplateResponse>;
|
|
116
|
+
/**
|
|
117
|
+
* Update an existing template
|
|
118
|
+
*/
|
|
119
|
+
updateTemplate(id: string, data: {
|
|
120
|
+
name?: string;
|
|
121
|
+
subject?: string;
|
|
122
|
+
body?: string;
|
|
123
|
+
}): Promise<PlunkTemplateResponse>;
|
|
124
|
+
/**
|
|
125
|
+
* Delete a template
|
|
126
|
+
*/
|
|
127
|
+
deleteTemplate(id: string): Promise<{
|
|
128
|
+
success: boolean;
|
|
129
|
+
}>;
|
|
130
|
+
/**
|
|
131
|
+
* Get all campaigns
|
|
132
|
+
*/
|
|
133
|
+
getCampaigns(): Promise<{
|
|
134
|
+
campaigns: PlunkCampaign[];
|
|
135
|
+
}>;
|
|
136
|
+
/**
|
|
137
|
+
* Get a single campaign by ID
|
|
138
|
+
*/
|
|
139
|
+
getCampaign(id: string): Promise<PlunkCampaign>;
|
|
140
|
+
/**
|
|
141
|
+
* Create a new campaign (draft)
|
|
142
|
+
*/
|
|
143
|
+
createCampaign(data: {
|
|
144
|
+
name: string;
|
|
145
|
+
subject: string;
|
|
146
|
+
body: string;
|
|
147
|
+
from?: string;
|
|
148
|
+
style?: Record<string, string>;
|
|
149
|
+
}): Promise<PlunkCampaignResponse>;
|
|
150
|
+
/**
|
|
151
|
+
* Send a campaign to all subscribed contacts
|
|
152
|
+
*/
|
|
153
|
+
sendCampaign(id: string): Promise<PlunkCampaignResponse>;
|
|
154
|
+
/**
|
|
155
|
+
* Send a test email for a campaign to a specific email
|
|
156
|
+
*/
|
|
157
|
+
testCampaign(id: string, email: string): Promise<PlunkSendResponse>;
|
|
158
|
+
/**
|
|
159
|
+
* Send a transactional email
|
|
160
|
+
*/
|
|
161
|
+
send(data: {
|
|
162
|
+
to: string;
|
|
163
|
+
subject: string;
|
|
164
|
+
body: string;
|
|
165
|
+
name?: string;
|
|
166
|
+
from?: string;
|
|
167
|
+
replyTo?: string;
|
|
168
|
+
headers?: Record<string, string>;
|
|
169
|
+
}): Promise<PlunkSendResponse>;
|
|
170
|
+
/**
|
|
171
|
+
* Track an event for a contact
|
|
172
|
+
* Uses the public key if available for client-side tracking
|
|
173
|
+
*/
|
|
174
|
+
track(data: {
|
|
175
|
+
email: string;
|
|
176
|
+
event: string;
|
|
177
|
+
data?: Record<string, unknown>;
|
|
178
|
+
}): Promise<PlunkTrackResponse>;
|
|
179
|
+
/**
|
|
180
|
+
* Find a contact by email
|
|
181
|
+
*/
|
|
182
|
+
findContactByEmail(email: string): Promise<Contact | null>;
|
|
183
|
+
/**
|
|
184
|
+
* Create or update a contact by email
|
|
185
|
+
*/
|
|
186
|
+
upsertContact(data: {
|
|
187
|
+
email: string;
|
|
188
|
+
subscribed?: boolean;
|
|
189
|
+
data?: Record<string, unknown>;
|
|
190
|
+
}): Promise<PlunkContactResponse>;
|
|
191
|
+
/**
|
|
192
|
+
* Get count of subscribed contacts
|
|
193
|
+
*/
|
|
194
|
+
getSubscribedCount(): Promise<number>;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Create a Plunk client from environment configuration
|
|
198
|
+
*/
|
|
199
|
+
export declare function createPlunkClient(env: {
|
|
200
|
+
HG_EMAILS_PLUNK_SECRET_KEY?: string;
|
|
201
|
+
HG_EMAILS_PLUNK_PUBLIC_KEY?: string;
|
|
202
|
+
}): PlunkClient;
|
|
203
|
+
export {};
|
|
204
|
+
//# sourceMappingURL=plunk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plunk.d.ts","sourceRoot":"","sources":["../../src/lib/plunk.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EACX,OAAO,EACP,aAAa,EACb,aAAa,EACb,MAAM,qBAAqB,CAAC;AAE7B,UAAU,WAAW;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAOD,UAAU,oBAAoB;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,OAAO,CAAC;CACpB;AAMD,UAAU,qBAAqB;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;CACX;AAMD,UAAU,qBAAqB;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,EA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