@metigan/angular 1.0.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.
Files changed (48) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +581 -0
  3. package/dist/LICENSE +22 -0
  4. package/dist/README.md +581 -0
  5. package/dist/esm2022/metigan-angular.mjs +5 -0
  6. package/dist/esm2022/public-api.mjs +21 -0
  7. package/dist/esm2022/src/lib/audiences.service.mjs +157 -0
  8. package/dist/esm2022/src/lib/config.mjs +30 -0
  9. package/dist/esm2022/src/lib/contacts.service.mjs +267 -0
  10. package/dist/esm2022/src/lib/email.service.mjs +267 -0
  11. package/dist/esm2022/src/lib/errors.mjs +40 -0
  12. package/dist/esm2022/src/lib/forms.service.mjs +180 -0
  13. package/dist/esm2022/src/lib/http-client.service.mjs +111 -0
  14. package/dist/esm2022/src/lib/metigan.module.mjs +67 -0
  15. package/dist/esm2022/src/lib/metigan.service.mjs +72 -0
  16. package/dist/esm2022/src/lib/templates.service.mjs +85 -0
  17. package/dist/esm2022/src/lib/types.mjs +6 -0
  18. package/dist/fesm2022/metigan-angular.mjs +1241 -0
  19. package/dist/fesm2022/metigan-angular.mjs.map +1 -0
  20. package/dist/index.d.ts +5 -0
  21. package/dist/public-api.d.ts +15 -0
  22. package/dist/src/lib/audiences.service.d.ts +62 -0
  23. package/dist/src/lib/config.d.ts +28 -0
  24. package/dist/src/lib/contacts.service.d.ts +80 -0
  25. package/dist/src/lib/email.service.d.ts +44 -0
  26. package/dist/src/lib/errors.d.ts +24 -0
  27. package/dist/src/lib/forms.service.d.ts +67 -0
  28. package/dist/src/lib/http-client.service.d.ts +46 -0
  29. package/dist/src/lib/metigan.module.d.ts +27 -0
  30. package/dist/src/lib/metigan.service.d.ts +27 -0
  31. package/dist/src/lib/templates.service.d.ts +36 -0
  32. package/dist/src/lib/types.d.ts +329 -0
  33. package/examples/basic.component.ts +113 -0
  34. package/ng-package.json +8 -0
  35. package/package.json +68 -0
  36. package/public-api.ts +26 -0
  37. package/src/lib/audiences.service.ts +230 -0
  38. package/src/lib/config.ts +35 -0
  39. package/src/lib/contacts.service.ts +377 -0
  40. package/src/lib/email.service.ts +286 -0
  41. package/src/lib/errors.ts +45 -0
  42. package/src/lib/forms.service.ts +263 -0
  43. package/src/lib/http-client.service.ts +156 -0
  44. package/src/lib/metigan.module.ts +55 -0
  45. package/src/lib/metigan.service.ts +80 -0
  46. package/src/lib/templates.service.ts +103 -0
  47. package/src/lib/types.ts +398 -0
  48. package/tsconfig.json +38 -0
@@ -0,0 +1,398 @@
1
+ /**
2
+ * Type definitions for Metigan Angular SDK
3
+ * @version 1.0.0
4
+ */
5
+
6
+ // ============================================
7
+ // EMAIL TYPES
8
+ // ============================================
9
+
10
+ /**
11
+ * Email attachment interface for Angular
12
+ */
13
+ export interface EmailAttachment {
14
+ content: ArrayBuffer | Uint8Array | string;
15
+ filename: string;
16
+ contentType: string;
17
+ }
18
+
19
+ /**
20
+ * Email options interface
21
+ */
22
+ export interface EmailOptions {
23
+ /** Sender email address (or Name <email>) */
24
+ from: string;
25
+ /** List of recipient email addresses */
26
+ recipients: string[];
27
+ /** Email subject */
28
+ subject: string;
29
+ /** Email content (HTML supported) - Required if not using templateId */
30
+ content?: string;
31
+ /** Template ID for using pre-created templates (optional) */
32
+ templateId?: string;
33
+ /** Optional file attachments */
34
+ attachments?: File[] | EmailAttachment[];
35
+ /** Optional CC recipients */
36
+ cc?: string[];
37
+ /** Optional BCC recipients */
38
+ bcc?: string[];
39
+ /** Optional reply-to address */
40
+ replyTo?: string;
41
+ }
42
+
43
+ /**
44
+ * API response interface for successful email
45
+ */
46
+ export interface EmailSuccessResponse {
47
+ success: true;
48
+ message: string;
49
+ successfulEmails: {
50
+ recipient: string;
51
+ trackingId: string;
52
+ }[];
53
+ failedEmails: {
54
+ recipient: string;
55
+ error: string;
56
+ }[];
57
+ recipientCount: number;
58
+ emailsRemaining: number;
59
+ }
60
+
61
+ /**
62
+ * API error response interfaces
63
+ */
64
+ export interface EmailErrorResponse {
65
+ error: string;
66
+ message: string;
67
+ }
68
+
69
+ /**
70
+ * Union type for all possible API responses
71
+ */
72
+ export type EmailApiResponse = EmailSuccessResponse | EmailErrorResponse;
73
+
74
+ // ============================================
75
+ // FORM TYPES
76
+ // ============================================
77
+
78
+ /**
79
+ * Form field types
80
+ */
81
+ export type FormFieldType =
82
+ | 'text'
83
+ | 'email'
84
+ | 'number'
85
+ | 'textarea'
86
+ | 'select'
87
+ | 'checkbox'
88
+ | 'radio'
89
+ | 'date'
90
+ | 'phone'
91
+ | 'url'
92
+ | 'file'
93
+ | 'step'
94
+ | 'password'
95
+ | 'rating'
96
+ | 'slider'
97
+ | 'heading'
98
+ | 'image-choice'
99
+ | 'matrix';
100
+
101
+ /**
102
+ * Form field configuration
103
+ */
104
+ export interface FormFieldConfig {
105
+ id: string;
106
+ type: FormFieldType;
107
+ label: string;
108
+ placeholder?: string;
109
+ required?: boolean;
110
+ helpText?: string;
111
+ options?: string[];
112
+ imageUrls?: string[];
113
+ defaultValue?: string | number | boolean;
114
+ }
115
+
116
+ /**
117
+ * Form settings
118
+ */
119
+ export interface FormSettings {
120
+ successMessage?: string;
121
+ processingMessage?: string;
122
+ redirectUrl?: string;
123
+ notifyEmail?: string;
124
+ enableCaptcha?: boolean;
125
+ storeResponses?: boolean;
126
+ allowMultipleSubmissions?: boolean;
127
+ showProgressBar?: boolean;
128
+ }
129
+
130
+ /**
131
+ * Complete form configuration
132
+ */
133
+ export interface FormConfig {
134
+ id?: string;
135
+ title: string;
136
+ description?: string;
137
+ coverImage?: string;
138
+ fields: FormFieldConfig[];
139
+ audienceId?: string;
140
+ settings?: FormSettings;
141
+ published?: boolean;
142
+ publishedUrl?: string;
143
+ slug?: string;
144
+ analytics?: {
145
+ views: number;
146
+ submissions: number;
147
+ conversionRate?: number;
148
+ };
149
+ createdAt?: Date;
150
+ updatedAt?: Date;
151
+ }
152
+
153
+ /**
154
+ * Form submission data
155
+ */
156
+ export interface FormSubmissionData {
157
+ [fieldId: string]: any;
158
+ }
159
+
160
+ /**
161
+ * Form submission options
162
+ */
163
+ export interface FormSubmissionOptions {
164
+ formId: string;
165
+ data: FormSubmissionData;
166
+ }
167
+
168
+ /**
169
+ * Form submission response
170
+ */
171
+ export interface FormSubmissionResponse {
172
+ success: boolean;
173
+ message: string;
174
+ submissionId?: string;
175
+ }
176
+
177
+ /**
178
+ * Form list response
179
+ */
180
+ export interface FormListResponse {
181
+ forms: FormConfig[];
182
+ pagination: {
183
+ total: number;
184
+ page: number;
185
+ limit: number;
186
+ pages: number;
187
+ };
188
+ }
189
+
190
+ // ============================================
191
+ // CONTACT TYPES
192
+ // ============================================
193
+
194
+ /**
195
+ * Contact status
196
+ */
197
+ export type ContactStatus = 'subscribed' | 'unsubscribed' | 'pending' | 'bounced' | 'complained';
198
+
199
+ /**
200
+ * Contact data
201
+ */
202
+ export interface Contact {
203
+ id?: string;
204
+ email: string;
205
+ firstName?: string;
206
+ lastName?: string;
207
+ phone?: string;
208
+ status: ContactStatus;
209
+ audienceId: string;
210
+ tags?: string[];
211
+ customFields?: Record<string, any>;
212
+ createdAt?: Date;
213
+ updatedAt?: Date;
214
+ }
215
+
216
+ /**
217
+ * Contact creation options
218
+ */
219
+ export interface CreateContactOptions {
220
+ email: string;
221
+ firstName?: string;
222
+ lastName?: string;
223
+ phone?: string;
224
+ audienceId: string;
225
+ tags?: string[];
226
+ customFields?: Record<string, any>;
227
+ status?: ContactStatus;
228
+ }
229
+
230
+ /**
231
+ * Contact update options
232
+ */
233
+ export interface UpdateContactOptions {
234
+ firstName?: string;
235
+ lastName?: string;
236
+ phone?: string;
237
+ tags?: string[];
238
+ customFields?: Record<string, any>;
239
+ status?: ContactStatus;
240
+ }
241
+
242
+ /**
243
+ * Contact list filters
244
+ */
245
+ export interface ContactListFilters {
246
+ audienceId?: string;
247
+ status?: ContactStatus;
248
+ tag?: string;
249
+ search?: string;
250
+ page?: number;
251
+ limit?: number;
252
+ }
253
+
254
+ /**
255
+ * Contact list response
256
+ */
257
+ export interface ContactListResponse {
258
+ contacts: Contact[];
259
+ pagination: {
260
+ total: number;
261
+ page: number;
262
+ limit: number;
263
+ pages: number;
264
+ };
265
+ }
266
+
267
+ /**
268
+ * Bulk contact operation result
269
+ */
270
+ export interface BulkContactResult {
271
+ success: boolean;
272
+ imported: number;
273
+ failed: number;
274
+ errors?: { email: string; error: string }[];
275
+ }
276
+
277
+ // ============================================
278
+ // AUDIENCE TYPES
279
+ // ============================================
280
+
281
+ /**
282
+ * Audience data
283
+ */
284
+ export interface Audience {
285
+ id?: string;
286
+ name: string;
287
+ description?: string;
288
+ count: number;
289
+ createdAt?: Date;
290
+ updatedAt?: Date;
291
+ }
292
+
293
+ /**
294
+ * Audience creation options
295
+ */
296
+ export interface CreateAudienceOptions {
297
+ name: string;
298
+ description?: string;
299
+ }
300
+
301
+ /**
302
+ * Audience update options
303
+ */
304
+ export interface UpdateAudienceOptions {
305
+ name?: string;
306
+ description?: string;
307
+ }
308
+
309
+ /**
310
+ * Audience list response
311
+ */
312
+ export interface AudienceListResponse {
313
+ audiences: Audience[];
314
+ pagination: {
315
+ total: number;
316
+ page: number;
317
+ limit: number;
318
+ pages: number;
319
+ };
320
+ }
321
+
322
+ /**
323
+ * Audience statistics
324
+ */
325
+ export interface AudienceStats {
326
+ total: number;
327
+ subscribed: number;
328
+ unsubscribed: number;
329
+ pending: number;
330
+ bounced: number;
331
+ complained: number;
332
+ growthRate?: number;
333
+ }
334
+
335
+ // ============================================
336
+ // TEMPLATE TYPES
337
+ // ============================================
338
+
339
+ /**
340
+ * Email template data
341
+ */
342
+ export interface EmailTemplate {
343
+ id: string;
344
+ name: string;
345
+ subject: string;
346
+ components?: any[];
347
+ styles?: any;
348
+ createdAt?: Date;
349
+ updatedAt?: Date;
350
+ }
351
+
352
+ /**
353
+ * Email template list response
354
+ */
355
+ export interface EmailTemplateListResponse {
356
+ templates: EmailTemplate[];
357
+ pagination: {
358
+ total: number;
359
+ page: number;
360
+ limit: number;
361
+ pages: number;
362
+ };
363
+ }
364
+
365
+ // ============================================
366
+ // COMMON TYPES
367
+ // ============================================
368
+
369
+ /**
370
+ * Pagination options
371
+ */
372
+ export interface PaginationOptions {
373
+ page?: number;
374
+ limit?: number;
375
+ }
376
+
377
+ /**
378
+ * Client options for Metigan
379
+ */
380
+ export interface MetiganClientOptions {
381
+ /** API Key */
382
+ apiKey: string;
383
+ /** User ID for logging */
384
+ userId?: string;
385
+ /** Disable logging */
386
+ disableLogs?: boolean;
387
+ /** Request timeout in ms */
388
+ timeout?: number;
389
+ /** Number of retries */
390
+ retryCount?: number;
391
+ /** Delay between retries in ms */
392
+ retryDelay?: number;
393
+ /** Enable debug mode */
394
+ debug?: boolean;
395
+ /** Custom API URL */
396
+ apiUrl?: string;
397
+ }
398
+
package/tsconfig.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "compileOnSave": false,
3
+ "compilerOptions": {
4
+ "baseUrl": "./",
5
+ "outDir": "./dist/out-tsc",
6
+ "forceConsistentCasingInFileNames": true,
7
+ "strict": true,
8
+ "noImplicitOverride": true,
9
+ "noPropertyAccessFromIndexSignature": true,
10
+ "noImplicitReturns": true,
11
+ "noFallthroughCasesInSwitch": true,
12
+ "sourceMap": true,
13
+ "declaration": false,
14
+ "declarationMap": false,
15
+ "downlevelIteration": true,
16
+ "experimentalDecorators": true,
17
+ "moduleResolution": "node",
18
+ "importHelpers": true,
19
+ "target": "ES2022",
20
+ "module": "ES2022",
21
+ "lib": [
22
+ "ES2022",
23
+ "dom"
24
+ ],
25
+ "paths": {
26
+ "@metigan/angular": [
27
+ "./src/public-api.ts"
28
+ ]
29
+ }
30
+ },
31
+ "angularCompilerOptions": {
32
+ "enableI18nLegacyMessageIdFormat": false,
33
+ "strictInjectionParameters": true,
34
+ "strictInputAccessModifiers": true,
35
+ "strictTemplates": true
36
+ }
37
+ }
38
+