hazo_notify 1.0.2 → 1.1.1
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/README.md +30 -10
- package/config/hazo_logs_config.ini +21 -0
- package/{hazo_notify_config.ini → config/hazo_notify_config.ini} +39 -0
- package/data/templates/email_signature.html +11 -0
- package/data/templates/email_signature.txt +4 -0
- package/data/templates/email_verification.html +64 -0
- package/data/templates/email_verification.txt +11 -0
- package/data/templates/forgot_password.html +64 -0
- package/data/templates/forgot_password.txt +11 -0
- package/data/templates/manifest.json +86 -0
- package/data/templates/welcome_email.html +54 -0
- package/data/templates/welcome_email.txt +8 -0
- package/dist/emailer/emailer.d.ts +3 -3
- package/dist/emailer/emailer.d.ts.map +1 -1
- package/dist/emailer/emailer.js +25 -15
- package/dist/emailer/emailer.js.map +1 -1
- package/dist/emailer/index.d.ts +1 -0
- package/dist/emailer/index.d.ts.map +1 -1
- package/dist/emailer/index.js +5 -1
- package/dist/emailer/index.js.map +1 -1
- package/dist/emailer/providers/pop3_provider.d.ts +3 -2
- package/dist/emailer/providers/pop3_provider.d.ts.map +1 -1
- package/dist/emailer/providers/pop3_provider.js +2 -1
- package/dist/emailer/providers/pop3_provider.js.map +1 -1
- package/dist/emailer/providers/smtp_provider.d.ts +3 -2
- package/dist/emailer/providers/smtp_provider.d.ts.map +1 -1
- package/dist/emailer/providers/smtp_provider.js +2 -1
- package/dist/emailer/providers/smtp_provider.js.map +1 -1
- package/dist/emailer/providers/zeptomail_provider.d.ts +3 -2
- package/dist/emailer/providers/zeptomail_provider.d.ts.map +1 -1
- package/dist/emailer/providers/zeptomail_provider.js +24 -11
- package/dist/emailer/providers/zeptomail_provider.js.map +1 -1
- package/dist/emailer/types.d.ts +13 -1
- package/dist/emailer/types.d.ts.map +1 -1
- package/dist/emailer/utils/logger.d.ts +22 -14
- package/dist/emailer/utils/logger.d.ts.map +1 -1
- package/dist/emailer/utils/logger.js +51 -13
- package/dist/emailer/utils/logger.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/template_manager/config/config_loader.d.ts +48 -0
- package/dist/template_manager/config/config_loader.d.ts.map +1 -0
- package/dist/template_manager/config/config_loader.js +161 -0
- package/dist/template_manager/config/config_loader.js.map +1 -0
- package/dist/template_manager/config/constants.d.ts +101 -0
- package/dist/template_manager/config/constants.d.ts.map +1 -0
- package/dist/template_manager/config/constants.js +163 -0
- package/dist/template_manager/config/constants.js.map +1 -0
- package/dist/template_manager/config/index.d.ts +6 -0
- package/dist/template_manager/config/index.d.ts.map +1 -0
- package/dist/{lib/emailer/utils → template_manager/config}/index.js +4 -4
- package/dist/template_manager/config/index.js.map +1 -0
- package/dist/template_manager/db/category_repository.d.ts +57 -0
- package/dist/template_manager/db/category_repository.d.ts.map +1 -0
- package/dist/template_manager/db/category_repository.js +326 -0
- package/dist/template_manager/db/category_repository.js.map +1 -0
- package/dist/template_manager/db/index.d.ts +6 -0
- package/dist/template_manager/db/index.d.ts.map +1 -0
- package/dist/template_manager/db/index.js +23 -0
- package/dist/template_manager/db/index.js.map +1 -0
- package/dist/template_manager/db/template_repository.d.ts +76 -0
- package/dist/template_manager/db/template_repository.d.ts.map +1 -0
- package/dist/template_manager/db/template_repository.js +684 -0
- package/dist/template_manager/db/template_repository.js.map +1 -0
- package/dist/template_manager/engine/handlebars_engine.d.ts +52 -0
- package/dist/template_manager/engine/handlebars_engine.d.ts.map +1 -0
- package/dist/template_manager/engine/handlebars_engine.js +175 -0
- package/dist/template_manager/engine/handlebars_engine.js.map +1 -0
- package/dist/template_manager/engine/index.d.ts +6 -0
- package/dist/template_manager/engine/index.d.ts.map +1 -0
- package/dist/template_manager/engine/index.js +19 -0
- package/dist/template_manager/engine/index.js.map +1 -0
- package/dist/template_manager/engine/variable_resolver.d.ts +48 -0
- package/dist/template_manager/engine/variable_resolver.d.ts.map +1 -0
- package/dist/template_manager/engine/variable_resolver.js +223 -0
- package/dist/template_manager/engine/variable_resolver.js.map +1 -0
- package/dist/template_manager/index.d.ts +32 -0
- package/dist/template_manager/index.d.ts.map +1 -0
- package/dist/template_manager/index.js +88 -0
- package/dist/template_manager/index.js.map +1 -0
- package/dist/template_manager/template_manager.d.ts +69 -0
- package/dist/template_manager/template_manager.d.ts.map +1 -0
- package/dist/template_manager/template_manager.js +335 -0
- package/dist/template_manager/template_manager.js.map +1 -0
- package/dist/template_manager/types.d.ts +255 -0
- package/dist/template_manager/types.d.ts.map +1 -0
- package/dist/template_manager/types.js +12 -0
- package/dist/template_manager/types.js.map +1 -0
- package/dist/template_manager/utils/index.d.ts +6 -0
- package/dist/template_manager/utils/index.d.ts.map +1 -0
- package/dist/template_manager/utils/index.js +21 -0
- package/dist/template_manager/utils/index.js.map +1 -0
- package/dist/template_manager/utils/system_variables.d.ts +28 -0
- package/dist/template_manager/utils/system_variables.d.ts.map +1 -0
- package/dist/template_manager/utils/system_variables.js +209 -0
- package/dist/template_manager/utils/system_variables.js.map +1 -0
- package/dist/template_manager/utils/validation.d.ts +74 -0
- package/dist/template_manager/utils/validation.d.ts.map +1 -0
- package/dist/template_manager/utils/validation.js +163 -0
- package/dist/template_manager/utils/validation.js.map +1 -0
- package/package.json +70 -22
- package/dist/lib/emailer/emailer.d.ts +0 -19
- package/dist/lib/emailer/emailer.d.ts.map +0 -1
- package/dist/lib/emailer/emailer.js +0 -220
- package/dist/lib/emailer/emailer.js.map +0 -1
- package/dist/lib/emailer/index.d.ts +0 -11
- package/dist/lib/emailer/index.d.ts.map +0 -1
- package/dist/lib/emailer/index.js +0 -34
- package/dist/lib/emailer/index.js.map +0 -1
- package/dist/lib/emailer/providers/index.d.ts +0 -15
- package/dist/lib/emailer/providers/index.d.ts.map +0 -1
- package/dist/lib/emailer/providers/index.js +0 -36
- package/dist/lib/emailer/providers/index.js.map +0 -1
- package/dist/lib/emailer/providers/pop3_provider.d.ts +0 -15
- package/dist/lib/emailer/providers/pop3_provider.d.ts.map +0 -1
- package/dist/lib/emailer/providers/pop3_provider.js +0 -29
- package/dist/lib/emailer/providers/pop3_provider.js.map +0 -1
- package/dist/lib/emailer/providers/smtp_provider.d.ts +0 -15
- package/dist/lib/emailer/providers/smtp_provider.d.ts.map +0 -1
- package/dist/lib/emailer/providers/smtp_provider.js +0 -29
- package/dist/lib/emailer/providers/smtp_provider.js.map +0 -1
- package/dist/lib/emailer/providers/zeptomail_provider.d.ts +0 -15
- package/dist/lib/emailer/providers/zeptomail_provider.d.ts.map +0 -1
- package/dist/lib/emailer/providers/zeptomail_provider.js +0 -250
- package/dist/lib/emailer/providers/zeptomail_provider.js.map +0 -1
- package/dist/lib/emailer/types.d.ts +0 -94
- package/dist/lib/emailer/types.d.ts.map +0 -1
- package/dist/lib/emailer/types.js +0 -6
- package/dist/lib/emailer/types.js.map +0 -1
- package/dist/lib/emailer/utils/constants.d.ts +0 -14
- package/dist/lib/emailer/utils/constants.d.ts.map +0 -1
- package/dist/lib/emailer/utils/constants.js +0 -22
- package/dist/lib/emailer/utils/constants.js.map +0 -1
- package/dist/lib/emailer/utils/index.d.ts +0 -8
- package/dist/lib/emailer/utils/index.d.ts.map +0 -1
- package/dist/lib/emailer/utils/index.js.map +0 -1
- package/dist/lib/emailer/utils/logger.d.ts +0 -37
- package/dist/lib/emailer/utils/logger.d.ts.map +0 -1
- package/dist/lib/emailer/utils/logger.js +0 -60
- package/dist/lib/emailer/utils/logger.js.map +0 -1
- package/dist/lib/emailer/utils/validation.d.ts +0 -37
- package/dist/lib/emailer/utils/validation.d.ts.map +0 -1
- package/dist/lib/emailer/utils/validation.js +0 -81
- package/dist/lib/emailer/utils/validation.js.map +0 -1
- package/dist/lib/index.d.ts +0 -6
- package/dist/lib/index.d.ts.map +0 -1
- package/dist/lib/index.js +0 -22
- package/dist/lib/index.js.map +0 -1
- package/dist/lib/utils.d.ts +0 -3
- package/dist/lib/utils.d.ts.map +0 -1
- package/dist/lib/utils.js +0 -9
- package/dist/lib/utils.js.map +0 -1
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for the template manager service
|
|
3
|
+
*
|
|
4
|
+
* This module provides TypeScript interfaces for:
|
|
5
|
+
* - Template configuration and variable definitions
|
|
6
|
+
* - Database entity types (categories and templates)
|
|
7
|
+
* - hazo_connect integration
|
|
8
|
+
* - Service request/response types
|
|
9
|
+
*/
|
|
10
|
+
import type { Logger } from '../emailer/types';
|
|
11
|
+
/**
|
|
12
|
+
* Definition of a template variable
|
|
13
|
+
*/
|
|
14
|
+
export interface TemplateVariableDefinition {
|
|
15
|
+
variable_name: string;
|
|
16
|
+
variable_description: string;
|
|
17
|
+
default_value?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Definition of a template type with its associated variables
|
|
21
|
+
* Loaded from config: email_template_variable_types
|
|
22
|
+
*/
|
|
23
|
+
export interface TemplateTypeDefinition {
|
|
24
|
+
template_name: string;
|
|
25
|
+
template_label: string;
|
|
26
|
+
variables: TemplateVariableDefinition[];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* System variable that is auto-generated (e.g., date formats)
|
|
30
|
+
*/
|
|
31
|
+
export interface SystemVariable {
|
|
32
|
+
variable_name: string;
|
|
33
|
+
variable_description: string;
|
|
34
|
+
resolver: () => string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Configuration for the template manager
|
|
38
|
+
*/
|
|
39
|
+
export interface TemplateManagerConfig {
|
|
40
|
+
email_template_variable_types: TemplateTypeDefinition[];
|
|
41
|
+
system_email_template_variables: SystemVariable[];
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Email type enum: system templates cannot be deleted
|
|
45
|
+
*/
|
|
46
|
+
export type EmailType = 'system' | 'user';
|
|
47
|
+
/**
|
|
48
|
+
* Template category entity from hazo_notify_template_cat table
|
|
49
|
+
*/
|
|
50
|
+
export interface TemplateCategory {
|
|
51
|
+
id: string;
|
|
52
|
+
org_id: string;
|
|
53
|
+
root_org_id: string;
|
|
54
|
+
template_category_name: string;
|
|
55
|
+
created_at: string;
|
|
56
|
+
changed_at: string | null;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Input for creating a new template category
|
|
60
|
+
*/
|
|
61
|
+
export interface TemplateCategoryInput {
|
|
62
|
+
org_id: string;
|
|
63
|
+
root_org_id: string;
|
|
64
|
+
template_category_name: string;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Input for updating an existing template category
|
|
68
|
+
*/
|
|
69
|
+
export interface TemplateCategoryUpdate {
|
|
70
|
+
template_category_name?: string;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Email template entity from hazo_notify_templates table
|
|
74
|
+
*/
|
|
75
|
+
export interface EmailTemplate {
|
|
76
|
+
id: string;
|
|
77
|
+
org_id: string;
|
|
78
|
+
root_org_id: string;
|
|
79
|
+
template_category_id: string;
|
|
80
|
+
template_variables: Record<string, unknown>;
|
|
81
|
+
template_name: string;
|
|
82
|
+
template_html: string;
|
|
83
|
+
template_text: string;
|
|
84
|
+
email_type: EmailType;
|
|
85
|
+
created_at: string;
|
|
86
|
+
changed_at: string | null;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Input for creating a new email template
|
|
90
|
+
*/
|
|
91
|
+
export interface EmailTemplateInput {
|
|
92
|
+
org_id: string;
|
|
93
|
+
root_org_id: string;
|
|
94
|
+
template_category_id: string;
|
|
95
|
+
template_variables?: Record<string, unknown>;
|
|
96
|
+
template_name: string;
|
|
97
|
+
template_html: string;
|
|
98
|
+
template_text: string;
|
|
99
|
+
email_type?: EmailType;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Input for updating an existing email template
|
|
103
|
+
*/
|
|
104
|
+
export interface EmailTemplateUpdate {
|
|
105
|
+
template_category_id?: string;
|
|
106
|
+
template_variables?: Record<string, unknown>;
|
|
107
|
+
template_name?: string;
|
|
108
|
+
template_html?: string;
|
|
109
|
+
template_text?: string;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Query builder interface for hazo_connect
|
|
113
|
+
* Supports fluent chaining pattern
|
|
114
|
+
*/
|
|
115
|
+
export interface HazoConnectQueryBuilder {
|
|
116
|
+
from(table: string): this;
|
|
117
|
+
select(columns: string | string[]): this;
|
|
118
|
+
where(column: string, operator: string, value: unknown): this;
|
|
119
|
+
whereIn(column: string, values: unknown[]): this;
|
|
120
|
+
order(column: string, direction: 'asc' | 'desc'): this;
|
|
121
|
+
limit(n: number): this;
|
|
122
|
+
offset(n: number): this;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* hazo_connect instance interface
|
|
126
|
+
* Consuming apps pass this to template manager functions
|
|
127
|
+
*/
|
|
128
|
+
export interface HazoConnectInstance {
|
|
129
|
+
/** Execute query and return list of results */
|
|
130
|
+
list<T>(query: HazoConnectQueryBuilder): Promise<T[]>;
|
|
131
|
+
/** Find a single record by ID */
|
|
132
|
+
findById<T>(table: string, id: string): Promise<T | null>;
|
|
133
|
+
/** Find records matching criteria */
|
|
134
|
+
findBy<T>(table: string, criteria: Record<string, unknown>): Promise<T[]>;
|
|
135
|
+
/** Insert a new record */
|
|
136
|
+
insert<T>(table: string, data: Partial<T>): Promise<T>;
|
|
137
|
+
/** Update a record by ID */
|
|
138
|
+
updateById<T>(table: string, id: string, patch: Partial<T>): Promise<T>;
|
|
139
|
+
/** Delete a record by ID */
|
|
140
|
+
deleteById(table: string, id: string): Promise<boolean>;
|
|
141
|
+
/** Create a new query builder */
|
|
142
|
+
query(): HazoConnectQueryBuilder;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Result of rendering a template
|
|
146
|
+
*/
|
|
147
|
+
export interface TemplateRenderResult {
|
|
148
|
+
success: boolean;
|
|
149
|
+
rendered_html?: string;
|
|
150
|
+
rendered_text?: string;
|
|
151
|
+
error?: string;
|
|
152
|
+
message?: string;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Generic response for template operations
|
|
156
|
+
*/
|
|
157
|
+
export interface TemplateOperationResponse<T = unknown> {
|
|
158
|
+
success: boolean;
|
|
159
|
+
data?: T;
|
|
160
|
+
error?: string;
|
|
161
|
+
message?: string;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Attachment for template email
|
|
165
|
+
*/
|
|
166
|
+
export interface TemplateEmailAttachment {
|
|
167
|
+
filename: string;
|
|
168
|
+
content: string;
|
|
169
|
+
mime_type: string;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Options for sending a templated email
|
|
173
|
+
*/
|
|
174
|
+
export interface SendTemplateEmailOptions {
|
|
175
|
+
/** Name of template to use (must match a template_name in DB) */
|
|
176
|
+
template_name: string;
|
|
177
|
+
/** Variables to substitute in the template */
|
|
178
|
+
variables: Record<string, string>;
|
|
179
|
+
/** Recipient email address(es) */
|
|
180
|
+
to: string | string[];
|
|
181
|
+
/** Subject line (overrides template subject if provided) */
|
|
182
|
+
subject?: string;
|
|
183
|
+
/** Sender email address (overrides config default) */
|
|
184
|
+
from?: string;
|
|
185
|
+
/** Sender name (overrides config default) */
|
|
186
|
+
from_name?: string;
|
|
187
|
+
/** Reply-to email address */
|
|
188
|
+
reply_to?: string;
|
|
189
|
+
/** CC recipients */
|
|
190
|
+
cc?: string | string[];
|
|
191
|
+
/** BCC recipients */
|
|
192
|
+
bcc?: string | string[];
|
|
193
|
+
/** File attachments */
|
|
194
|
+
attachments?: TemplateEmailAttachment[];
|
|
195
|
+
/** Optional logger instance (compatible with hazo_logs) */
|
|
196
|
+
logger?: Logger;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Response from send_template_email
|
|
200
|
+
*/
|
|
201
|
+
export interface SendTemplateEmailResponse {
|
|
202
|
+
success: boolean;
|
|
203
|
+
message_id?: string;
|
|
204
|
+
message?: string;
|
|
205
|
+
/** Rendered HTML content (for debugging) */
|
|
206
|
+
rendered_html?: string;
|
|
207
|
+
/** Rendered text content (for debugging) */
|
|
208
|
+
rendered_text?: string;
|
|
209
|
+
raw_response?: Record<string, unknown> | string;
|
|
210
|
+
error?: string;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Category with its templates for UI tree display
|
|
214
|
+
*/
|
|
215
|
+
export interface CategoryTreeItem {
|
|
216
|
+
category: TemplateCategory;
|
|
217
|
+
templates: EmailTemplate[];
|
|
218
|
+
expanded: boolean;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Variable item for dropdown display
|
|
222
|
+
*/
|
|
223
|
+
export interface VariableItem {
|
|
224
|
+
name: string;
|
|
225
|
+
description: string;
|
|
226
|
+
type: 'user' | 'system';
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Template reference item for dropdown display
|
|
230
|
+
*/
|
|
231
|
+
export interface TemplateReferenceItem {
|
|
232
|
+
category_name: string;
|
|
233
|
+
template_name: string;
|
|
234
|
+
template_id: string;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Manifest entry for a default template shipped with the package
|
|
238
|
+
*/
|
|
239
|
+
export interface DefaultTemplateManifestEntry {
|
|
240
|
+
template_name: string;
|
|
241
|
+
template_label: string;
|
|
242
|
+
category: string;
|
|
243
|
+
html_file: string;
|
|
244
|
+
text_file: string;
|
|
245
|
+
variables: TemplateVariableDefinition[];
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Manifest file structure for default templates
|
|
249
|
+
*/
|
|
250
|
+
export interface DefaultTemplateManifest {
|
|
251
|
+
version: string;
|
|
252
|
+
templates: DefaultTemplateManifestEntry[];
|
|
253
|
+
}
|
|
254
|
+
export type { Logger };
|
|
255
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/template_manager/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;A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This module provides TypeScript interfaces for:
|
|
6
|
+
* - Template configuration and variable definitions
|
|
7
|
+
* - Database entity types (categories and templates)
|
|
8
|
+
* - hazo_connect integration
|
|
9
|
+
* - Service request/response types
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/lib/template_manager/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utils barrel export for template manager
|
|
3
|
+
*/
|
|
4
|
+
export { get_system_variables, resolve_system_variables, get_system_variable_definitions, } from './system_variables';
|
|
5
|
+
export { validate_template_name, validate_category_name, validate_variable_name, validate_template_html_size, validate_template_text_size, extract_variables_from_content, validate_provided_variables, validate_uuid, sanitize_template_name, } from './validation';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/template_manager/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACxB,+BAA+B,GAChC,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,EACtB,2BAA2B,EAC3B,2BAA2B,EAC3B,8BAA8B,EAC9B,2BAA2B,EAC3B,aAAa,EACb,sBAAsB,GACvB,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Utils barrel export for template manager
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.sanitize_template_name = exports.validate_uuid = exports.validate_provided_variables = exports.extract_variables_from_content = exports.validate_template_text_size = exports.validate_template_html_size = exports.validate_variable_name = exports.validate_category_name = exports.validate_template_name = exports.get_system_variable_definitions = exports.resolve_system_variables = exports.get_system_variables = void 0;
|
|
7
|
+
var system_variables_1 = require("./system_variables");
|
|
8
|
+
Object.defineProperty(exports, "get_system_variables", { enumerable: true, get: function () { return system_variables_1.get_system_variables; } });
|
|
9
|
+
Object.defineProperty(exports, "resolve_system_variables", { enumerable: true, get: function () { return system_variables_1.resolve_system_variables; } });
|
|
10
|
+
Object.defineProperty(exports, "get_system_variable_definitions", { enumerable: true, get: function () { return system_variables_1.get_system_variable_definitions; } });
|
|
11
|
+
var validation_1 = require("./validation");
|
|
12
|
+
Object.defineProperty(exports, "validate_template_name", { enumerable: true, get: function () { return validation_1.validate_template_name; } });
|
|
13
|
+
Object.defineProperty(exports, "validate_category_name", { enumerable: true, get: function () { return validation_1.validate_category_name; } });
|
|
14
|
+
Object.defineProperty(exports, "validate_variable_name", { enumerable: true, get: function () { return validation_1.validate_variable_name; } });
|
|
15
|
+
Object.defineProperty(exports, "validate_template_html_size", { enumerable: true, get: function () { return validation_1.validate_template_html_size; } });
|
|
16
|
+
Object.defineProperty(exports, "validate_template_text_size", { enumerable: true, get: function () { return validation_1.validate_template_text_size; } });
|
|
17
|
+
Object.defineProperty(exports, "extract_variables_from_content", { enumerable: true, get: function () { return validation_1.extract_variables_from_content; } });
|
|
18
|
+
Object.defineProperty(exports, "validate_provided_variables", { enumerable: true, get: function () { return validation_1.validate_provided_variables; } });
|
|
19
|
+
Object.defineProperty(exports, "validate_uuid", { enumerable: true, get: function () { return validation_1.validate_uuid; } });
|
|
20
|
+
Object.defineProperty(exports, "sanitize_template_name", { enumerable: true, get: function () { return validation_1.sanitize_template_name; } });
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/template_manager/utils/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,uDAI4B;AAH1B,wHAAA,oBAAoB,OAAA;AACpB,4HAAA,wBAAwB,OAAA;AACxB,mIAAA,+BAA+B,OAAA;AAGjC,2CAUsB;AATpB,oHAAA,sBAAsB,OAAA;AACtB,oHAAA,sBAAsB,OAAA;AACtB,oHAAA,sBAAsB,OAAA;AACtB,yHAAA,2BAA2B,OAAA;AAC3B,yHAAA,2BAA2B,OAAA;AAC3B,4HAAA,8BAA8B,OAAA;AAC9B,yHAAA,2BAA2B,OAAA;AAC3B,2GAAA,aAAa,OAAA;AACb,oHAAA,sBAAsB,OAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* System variables for template manager
|
|
3
|
+
*
|
|
4
|
+
* Auto-generated date format variables that can be used in templates
|
|
5
|
+
*/
|
|
6
|
+
import type { SystemVariable } from '../types';
|
|
7
|
+
/**
|
|
8
|
+
* Get all system variables with their resolvers
|
|
9
|
+
*
|
|
10
|
+
* @returns Array of system variables that can be used in templates
|
|
11
|
+
*/
|
|
12
|
+
export declare function get_system_variables(): SystemVariable[];
|
|
13
|
+
/**
|
|
14
|
+
* Resolve all system variables to their current values
|
|
15
|
+
*
|
|
16
|
+
* @returns Record mapping variable names to their resolved values
|
|
17
|
+
*/
|
|
18
|
+
export declare function resolve_system_variables(): Record<string, string>;
|
|
19
|
+
/**
|
|
20
|
+
* Get system variable definitions for UI display (without resolvers)
|
|
21
|
+
*
|
|
22
|
+
* @returns Array of variable info objects suitable for UI
|
|
23
|
+
*/
|
|
24
|
+
export declare function get_system_variable_definitions(): Array<{
|
|
25
|
+
variable_name: string;
|
|
26
|
+
variable_description: string;
|
|
27
|
+
}>;
|
|
28
|
+
//# sourceMappingURL=system_variables.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system_variables.d.ts","sourceRoot":"","sources":["../../../src/lib/template_manager/utils/system_variables.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAgE/C;;;;GAIG;AACH,wBAAgB,oBAAoB,IAAI,cAAc,EAAE,CAkHvD;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CASjE;AAED;;;;GAIG;AACH,wBAAgB,+BAA+B,IAAI,KAAK,CAAC;IACvD,aAAa,EAAE,MAAM,CAAC;IACtB,oBAAoB,EAAE,MAAM,CAAC;CAC9B,CAAC,CAKD"}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* System variables for template manager
|
|
4
|
+
*
|
|
5
|
+
* Auto-generated date format variables that can be used in templates
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.get_system_variables = get_system_variables;
|
|
9
|
+
exports.resolve_system_variables = resolve_system_variables;
|
|
10
|
+
exports.get_system_variable_definitions = get_system_variable_definitions;
|
|
11
|
+
/**
|
|
12
|
+
* Month names for formatting
|
|
13
|
+
*/
|
|
14
|
+
const MONTH_NAMES_FULL = [
|
|
15
|
+
'January',
|
|
16
|
+
'February',
|
|
17
|
+
'March',
|
|
18
|
+
'April',
|
|
19
|
+
'May',
|
|
20
|
+
'June',
|
|
21
|
+
'July',
|
|
22
|
+
'August',
|
|
23
|
+
'September',
|
|
24
|
+
'October',
|
|
25
|
+
'November',
|
|
26
|
+
'December',
|
|
27
|
+
];
|
|
28
|
+
const MONTH_NAMES_SHORT = [
|
|
29
|
+
'Jan',
|
|
30
|
+
'Feb',
|
|
31
|
+
'Mar',
|
|
32
|
+
'Apr',
|
|
33
|
+
'May',
|
|
34
|
+
'Jun',
|
|
35
|
+
'Jul',
|
|
36
|
+
'Aug',
|
|
37
|
+
'Sep',
|
|
38
|
+
'Oct',
|
|
39
|
+
'Nov',
|
|
40
|
+
'Dec',
|
|
41
|
+
];
|
|
42
|
+
const DAY_NAMES = [
|
|
43
|
+
'Sunday',
|
|
44
|
+
'Monday',
|
|
45
|
+
'Tuesday',
|
|
46
|
+
'Wednesday',
|
|
47
|
+
'Thursday',
|
|
48
|
+
'Friday',
|
|
49
|
+
'Saturday',
|
|
50
|
+
];
|
|
51
|
+
/**
|
|
52
|
+
* Pad a number with leading zeros
|
|
53
|
+
*/
|
|
54
|
+
function pad_number(num, length = 2) {
|
|
55
|
+
return String(num).padStart(length, '0');
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Format time as 12-hour with AM/PM
|
|
59
|
+
*/
|
|
60
|
+
function format_time_12h(date) {
|
|
61
|
+
let hours = date.getHours();
|
|
62
|
+
const minutes = pad_number(date.getMinutes());
|
|
63
|
+
const ampm = hours >= 12 ? 'PM' : 'AM';
|
|
64
|
+
hours = hours % 12;
|
|
65
|
+
hours = hours ? hours : 12; // 0 should be 12
|
|
66
|
+
return `${hours}:${minutes} ${ampm}`;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Get all system variables with their resolvers
|
|
70
|
+
*
|
|
71
|
+
* @returns Array of system variables that can be used in templates
|
|
72
|
+
*/
|
|
73
|
+
function get_system_variables() {
|
|
74
|
+
return [
|
|
75
|
+
{
|
|
76
|
+
variable_name: 'date_yyyy_mm_dd',
|
|
77
|
+
variable_description: 'Date in YYYY-MM-DD format (e.g., 2024-01-15)',
|
|
78
|
+
resolver: () => {
|
|
79
|
+
const now = new Date();
|
|
80
|
+
const year = now.getFullYear();
|
|
81
|
+
const month = pad_number(now.getMonth() + 1);
|
|
82
|
+
const day = pad_number(now.getDate());
|
|
83
|
+
return `${year}-${month}-${day}`;
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
variable_name: 'date_mmm_dd',
|
|
88
|
+
variable_description: 'Date in MMM DD format (e.g., Jan 15)',
|
|
89
|
+
resolver: () => {
|
|
90
|
+
const now = new Date();
|
|
91
|
+
const month = MONTH_NAMES_SHORT[now.getMonth()];
|
|
92
|
+
const day = now.getDate();
|
|
93
|
+
return `${month} ${day}`;
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
variable_name: 'date_mmmm_dd_yyyy',
|
|
98
|
+
variable_description: 'Date in full format (e.g., January 15, 2024)',
|
|
99
|
+
resolver: () => {
|
|
100
|
+
const now = new Date();
|
|
101
|
+
const month = MONTH_NAMES_FULL[now.getMonth()];
|
|
102
|
+
const day = now.getDate();
|
|
103
|
+
const year = now.getFullYear();
|
|
104
|
+
return `${month} ${day}, ${year}`;
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
variable_name: 'date_dd_mm_yyyy',
|
|
109
|
+
variable_description: 'Date in DD/MM/YYYY format (e.g., 15/01/2024)',
|
|
110
|
+
resolver: () => {
|
|
111
|
+
const now = new Date();
|
|
112
|
+
const day = pad_number(now.getDate());
|
|
113
|
+
const month = pad_number(now.getMonth() + 1);
|
|
114
|
+
const year = now.getFullYear();
|
|
115
|
+
return `${day}/${month}/${year}`;
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
variable_name: 'date_dd_mmm_yyyy',
|
|
120
|
+
variable_description: 'Date in DD MMM YYYY format (e.g., 15 Jan 2024)',
|
|
121
|
+
resolver: () => {
|
|
122
|
+
const now = new Date();
|
|
123
|
+
const day = now.getDate();
|
|
124
|
+
const month = MONTH_NAMES_SHORT[now.getMonth()];
|
|
125
|
+
const year = now.getFullYear();
|
|
126
|
+
return `${day} ${month} ${year}`;
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
variable_name: 'time_hh_mm',
|
|
131
|
+
variable_description: 'Time in HH:MM format (24-hour, e.g., 14:30)',
|
|
132
|
+
resolver: () => {
|
|
133
|
+
const now = new Date();
|
|
134
|
+
const hours = pad_number(now.getHours());
|
|
135
|
+
const minutes = pad_number(now.getMinutes());
|
|
136
|
+
return `${hours}:${minutes}`;
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
variable_name: 'time_hh_mm_ss',
|
|
141
|
+
variable_description: 'Time in HH:MM:SS format (24-hour, e.g., 14:30:45)',
|
|
142
|
+
resolver: () => {
|
|
143
|
+
const now = new Date();
|
|
144
|
+
const hours = pad_number(now.getHours());
|
|
145
|
+
const minutes = pad_number(now.getMinutes());
|
|
146
|
+
const seconds = pad_number(now.getSeconds());
|
|
147
|
+
return `${hours}:${minutes}:${seconds}`;
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
variable_name: 'datetime_full',
|
|
152
|
+
variable_description: 'Full datetime (e.g., January 15, 2024 at 2:30 PM)',
|
|
153
|
+
resolver: () => {
|
|
154
|
+
const now = new Date();
|
|
155
|
+
const month = MONTH_NAMES_FULL[now.getMonth()];
|
|
156
|
+
const day = now.getDate();
|
|
157
|
+
const year = now.getFullYear();
|
|
158
|
+
const time = format_time_12h(now);
|
|
159
|
+
return `${month} ${day}, ${year} at ${time}`;
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
variable_name: 'year',
|
|
164
|
+
variable_description: 'Current year (e.g., 2024)',
|
|
165
|
+
resolver: () => {
|
|
166
|
+
return String(new Date().getFullYear());
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
variable_name: 'month_name',
|
|
171
|
+
variable_description: 'Current month name (e.g., January)',
|
|
172
|
+
resolver: () => {
|
|
173
|
+
return MONTH_NAMES_FULL[new Date().getMonth()];
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
variable_name: 'day_of_week',
|
|
178
|
+
variable_description: 'Current day of week (e.g., Monday)',
|
|
179
|
+
resolver: () => {
|
|
180
|
+
return DAY_NAMES[new Date().getDay()];
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
];
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Resolve all system variables to their current values
|
|
187
|
+
*
|
|
188
|
+
* @returns Record mapping variable names to their resolved values
|
|
189
|
+
*/
|
|
190
|
+
function resolve_system_variables() {
|
|
191
|
+
const system_vars = get_system_variables();
|
|
192
|
+
const resolved = {};
|
|
193
|
+
for (const sys_var of system_vars) {
|
|
194
|
+
resolved[sys_var.variable_name] = sys_var.resolver();
|
|
195
|
+
}
|
|
196
|
+
return resolved;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Get system variable definitions for UI display (without resolvers)
|
|
200
|
+
*
|
|
201
|
+
* @returns Array of variable info objects suitable for UI
|
|
202
|
+
*/
|
|
203
|
+
function get_system_variable_definitions() {
|
|
204
|
+
return get_system_variables().map((v) => ({
|
|
205
|
+
variable_name: v.variable_name,
|
|
206
|
+
variable_description: v.variable_description,
|
|
207
|
+
}));
|
|
208
|
+
}
|
|
209
|
+
//# sourceMappingURL=system_variables.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system_variables.js","sourceRoot":"","sources":["../../../src/lib/template_manager/utils/system_variables.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAuEH,oDAkHC;AAOD,4DASC;AAOD,0EAQC;AApND;;GAEG;AACH,MAAM,gBAAgB,GAAG;IACvB,SAAS;IACT,UAAU;IACV,OAAO;IACP,OAAO;IACP,KAAK;IACL,MAAM;IACN,MAAM;IACN,QAAQ;IACR,WAAW;IACX,SAAS;IACT,UAAU;IACV,UAAU;CACX,CAAC;AAEF,MAAM,iBAAiB,GAAG;IACxB,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;CACN,CAAC;AAEF,MAAM,SAAS,GAAG;IAChB,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,WAAW;IACX,UAAU;IACV,QAAQ;IACR,UAAU;CACX,CAAC;AAEF;;GAEG;AACH,SAAS,U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xC,aAAa,EAAE,CAAC,CAAC,aAAa;QAC9B,oBAAoB,EAAE,CAAC,CAAC,oBAAoB;KAC7C,CAAC,CAAC,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validation utilities for template manager
|
|
3
|
+
*
|
|
4
|
+
* Validates template names, category names, variables, and content
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Validate a template name
|
|
8
|
+
*
|
|
9
|
+
* @param name - Template name to validate
|
|
10
|
+
* @returns true if valid, false otherwise
|
|
11
|
+
*/
|
|
12
|
+
export declare function validate_template_name(name: string): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Validate a category name
|
|
15
|
+
*
|
|
16
|
+
* @param name - Category name to validate
|
|
17
|
+
* @returns true if valid, false otherwise
|
|
18
|
+
*/
|
|
19
|
+
export declare function validate_category_name(name: string): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Validate a variable name
|
|
22
|
+
*
|
|
23
|
+
* @param name - Variable name to validate
|
|
24
|
+
* @returns true if valid, false otherwise
|
|
25
|
+
*/
|
|
26
|
+
export declare function validate_variable_name(name: string): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Validate template HTML content size
|
|
29
|
+
*
|
|
30
|
+
* @param html - HTML content to validate
|
|
31
|
+
* @returns true if valid, false otherwise
|
|
32
|
+
*/
|
|
33
|
+
export declare function validate_template_html_size(html: string): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Validate template text content size
|
|
36
|
+
*
|
|
37
|
+
* @param text - Text content to validate
|
|
38
|
+
* @returns true if valid, false otherwise
|
|
39
|
+
*/
|
|
40
|
+
export declare function validate_template_text_size(text: string): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Extract variable names from template content
|
|
43
|
+
*
|
|
44
|
+
* @param content - Template content (HTML or text)
|
|
45
|
+
* @returns Array of variable names found in the content
|
|
46
|
+
*/
|
|
47
|
+
export declare function extract_variables_from_content(content: string): string[];
|
|
48
|
+
/**
|
|
49
|
+
* Validate that all required variables are provided
|
|
50
|
+
*
|
|
51
|
+
* @param template_content - Template content to check
|
|
52
|
+
* @param provided_variables - Variables provided by user
|
|
53
|
+
* @param system_variable_names - Names of system variables
|
|
54
|
+
* @returns Object with validation result and missing variables
|
|
55
|
+
*/
|
|
56
|
+
export declare function validate_provided_variables(template_content: string, provided_variables: Record<string, string>, system_variable_names: string[]): {
|
|
57
|
+
valid: boolean;
|
|
58
|
+
missing: string[];
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Validate UUID format
|
|
62
|
+
*
|
|
63
|
+
* @param uuid - String to validate as UUID
|
|
64
|
+
* @returns true if valid UUID format, false otherwise
|
|
65
|
+
*/
|
|
66
|
+
export declare function validate_uuid(uuid: string): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Sanitize template name for safe use
|
|
69
|
+
*
|
|
70
|
+
* @param name - Template name to sanitize
|
|
71
|
+
* @returns Sanitized template name
|
|
72
|
+
*/
|
|
73
|
+
export declare function sanitize_template_name(name: string): string;
|
|
74
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../src/lib/template_manager/utils/validation.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAWH;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAiB5D;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAgB5D;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAM5D;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAOjE;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAOjE;AAED;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAexE;AAED;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CACzC,gBAAgB,EAAE,MAAM,EACxB,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC1C,qBAAqB,EAAE,MAAM,EAAE,GAC9B;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,CAWvC;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAQnD;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAY3D"}
|