hazo_notify 1.1.4 → 3.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.
- package/README.md +163 -41
- package/dist/components/template_manager/category_dialog.d.ts +11 -0
- package/dist/components/template_manager/category_dialog.d.ts.map +1 -0
- package/dist/components/template_manager/category_dialog.js +41 -0
- package/dist/components/template_manager/category_dialog.js.map +1 -0
- package/dist/components/template_manager/category_tree.d.ts +13 -0
- package/dist/components/template_manager/category_tree.d.ts.map +1 -0
- package/dist/components/template_manager/category_tree.js +45 -0
- package/dist/components/template_manager/category_tree.js.map +1 -0
- package/dist/components/template_manager/index.d.ts +10 -0
- package/dist/components/template_manager/index.d.ts.map +1 -0
- package/dist/components/template_manager/index.js +8 -0
- package/dist/components/template_manager/index.js.map +1 -0
- package/dist/components/template_manager/preview_dialog.d.ts +11 -0
- package/dist/components/template_manager/preview_dialog.d.ts.map +1 -0
- package/dist/components/template_manager/preview_dialog.js +15 -0
- package/dist/components/template_manager/preview_dialog.js.map +1 -0
- package/dist/components/template_manager/template_dialog.d.ts +12 -0
- package/dist/components/template_manager/template_dialog.d.ts.map +1 -0
- package/dist/components/template_manager/template_dialog.js +46 -0
- package/dist/components/template_manager/template_dialog.js.map +1 -0
- package/dist/components/template_manager/template_editor.d.ts +12 -0
- package/dist/components/template_manager/template_editor.d.ts.map +1 -0
- package/dist/components/template_manager/template_editor.js +57 -0
- package/dist/components/template_manager/template_editor.js.map +1 -0
- package/dist/components/template_manager/template_globals_admin.d.ts +8 -0
- package/dist/components/template_manager/template_globals_admin.d.ts.map +1 -0
- package/dist/components/template_manager/template_globals_admin.js +27 -0
- package/dist/components/template_manager/template_globals_admin.js.map +1 -0
- package/dist/components/template_manager/template_manager_admin.d.ts +44 -0
- package/dist/components/template_manager/template_manager_admin.d.ts.map +1 -0
- package/dist/components/template_manager/template_manager_admin.js +272 -0
- package/dist/components/template_manager/template_manager_admin.js.map +1 -0
- package/dist/lib/emailer/emailer.d.ts.map +1 -0
- package/dist/lib/emailer/emailer.js.map +1 -0
- package/dist/lib/emailer/index.d.ts.map +1 -0
- package/dist/lib/emailer/index.js.map +1 -0
- package/dist/lib/emailer/providers/index.d.ts.map +1 -0
- package/dist/lib/emailer/providers/index.js.map +1 -0
- package/dist/lib/emailer/providers/pop3_provider.d.ts.map +1 -0
- package/dist/lib/emailer/providers/pop3_provider.js.map +1 -0
- package/dist/lib/emailer/providers/smtp_provider.d.ts.map +1 -0
- package/dist/lib/emailer/providers/smtp_provider.js.map +1 -0
- package/dist/lib/emailer/providers/zeptomail_provider.d.ts.map +1 -0
- package/dist/{emailer → lib/emailer}/providers/zeptomail_provider.js +9 -6
- package/dist/lib/emailer/providers/zeptomail_provider.js.map +1 -0
- package/dist/lib/emailer/types.d.ts.map +1 -0
- package/dist/lib/emailer/types.js.map +1 -0
- package/dist/lib/emailer/utils/constants.d.ts.map +1 -0
- package/dist/lib/emailer/utils/constants.js.map +1 -0
- package/dist/lib/emailer/utils/index.d.ts.map +1 -0
- package/dist/lib/emailer/utils/index.js.map +1 -0
- package/dist/lib/emailer/utils/logger.d.ts.map +1 -0
- package/dist/lib/emailer/utils/logger.js.map +1 -0
- package/dist/lib/emailer/utils/validation.d.ts.map +1 -0
- package/dist/lib/emailer/utils/validation.js.map +1 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/template_manager/cache/scope_chain_cache.d.ts +26 -0
- package/dist/lib/template_manager/cache/scope_chain_cache.d.ts.map +1 -0
- package/dist/lib/template_manager/cache/scope_chain_cache.js +60 -0
- package/dist/lib/template_manager/cache/scope_chain_cache.js.map +1 -0
- package/dist/{template_manager → lib/template_manager}/config/config_loader.d.ts +16 -15
- package/dist/lib/template_manager/config/config_loader.d.ts.map +1 -0
- package/dist/lib/template_manager/config/config_loader.js +98 -0
- package/dist/lib/template_manager/config/config_loader.js.map +1 -0
- package/dist/{template_manager → lib/template_manager}/config/constants.d.ts +4 -54
- package/dist/lib/template_manager/config/constants.d.ts.map +1 -0
- package/dist/{template_manager → lib/template_manager}/config/constants.js +4 -84
- package/dist/lib/template_manager/config/constants.js.map +1 -0
- package/dist/lib/template_manager/config/index.d.ts.map +1 -0
- package/dist/lib/template_manager/config/index.js.map +1 -0
- package/dist/{template_manager → lib/template_manager}/db/category_repository.d.ts +22 -14
- package/dist/lib/template_manager/db/category_repository.d.ts.map +1 -0
- package/dist/{template_manager → lib/template_manager}/db/category_repository.js +127 -83
- package/dist/lib/template_manager/db/category_repository.js.map +1 -0
- package/dist/lib/template_manager/db/index.d.ts +6 -0
- package/dist/lib/template_manager/db/index.d.ts.map +1 -0
- package/dist/lib/template_manager/db/index.js +6 -0
- package/dist/lib/template_manager/db/index.js.map +1 -0
- package/dist/{template_manager → lib/template_manager}/db/template_repository.d.ts +25 -28
- package/dist/lib/template_manager/db/template_repository.d.ts.map +1 -0
- package/dist/lib/template_manager/db/template_repository.js +507 -0
- package/dist/lib/template_manager/db/template_repository.js.map +1 -0
- package/dist/lib/template_manager/engine/handlebars_engine.d.ts.map +1 -0
- package/dist/lib/template_manager/engine/handlebars_engine.js.map +1 -0
- package/dist/lib/template_manager/engine/index.d.ts.map +1 -0
- package/dist/lib/template_manager/engine/index.js.map +1 -0
- package/dist/{template_manager → lib/template_manager}/engine/variable_resolver.d.ts +13 -14
- package/dist/lib/template_manager/engine/variable_resolver.d.ts.map +1 -0
- package/dist/{template_manager → lib/template_manager}/engine/variable_resolver.js +25 -33
- package/dist/lib/template_manager/engine/variable_resolver.js.map +1 -0
- package/dist/lib/template_manager/index.d.ts +56 -0
- package/dist/lib/template_manager/index.d.ts.map +1 -0
- package/dist/lib/template_manager/index.js +68 -0
- package/dist/lib/template_manager/index.js.map +1 -0
- package/dist/lib/template_manager/init.d.ts +54 -0
- package/dist/lib/template_manager/init.d.ts.map +1 -0
- package/dist/lib/template_manager/init.js +85 -0
- package/dist/lib/template_manager/init.js.map +1 -0
- package/dist/lib/template_manager/registry.d.ts +23 -0
- package/dist/lib/template_manager/registry.d.ts.map +1 -0
- package/dist/lib/template_manager/registry.js +33 -0
- package/dist/lib/template_manager/registry.js.map +1 -0
- package/dist/lib/template_manager/seed/sync.d.ts +8 -0
- package/dist/lib/template_manager/seed/sync.d.ts.map +1 -0
- package/dist/lib/template_manager/seed/sync.js +77 -0
- package/dist/lib/template_manager/seed/sync.js.map +1 -0
- package/dist/{template_manager → lib/template_manager}/template_manager.d.ts +25 -27
- package/dist/lib/template_manager/template_manager.d.ts.map +1 -0
- package/dist/{template_manager → lib/template_manager}/template_manager.js +41 -55
- package/dist/lib/template_manager/template_manager.js.map +1 -0
- package/dist/{template_manager → lib/template_manager}/types.d.ts +32 -125
- package/dist/lib/template_manager/types.d.ts.map +1 -0
- package/dist/lib/template_manager/types.js +12 -0
- package/dist/lib/template_manager/types.js.map +1 -0
- package/dist/lib/template_manager/utils/index.d.ts.map +1 -0
- package/dist/lib/template_manager/utils/index.js.map +1 -0
- package/dist/lib/template_manager/utils/system_variables.d.ts.map +1 -0
- package/dist/lib/template_manager/utils/system_variables.js.map +1 -0
- package/dist/lib/template_manager/utils/validation.d.ts.map +1 -0
- package/dist/lib/template_manager/utils/validation.js.map +1 -0
- package/dist/lib/utils.d.ts +3 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +6 -0
- package/dist/lib/utils.js.map +1 -0
- package/migrations/002_scope_migration.sql +93 -0
- package/package.json +57 -37
- package/dist/emailer/emailer.d.ts.map +0 -1
- package/dist/emailer/emailer.js.map +0 -1
- package/dist/emailer/index.d.ts.map +0 -1
- package/dist/emailer/index.js.map +0 -1
- package/dist/emailer/providers/index.d.ts.map +0 -1
- package/dist/emailer/providers/index.js.map +0 -1
- package/dist/emailer/providers/pop3_provider.d.ts.map +0 -1
- package/dist/emailer/providers/pop3_provider.js.map +0 -1
- package/dist/emailer/providers/smtp_provider.d.ts.map +0 -1
- package/dist/emailer/providers/smtp_provider.js.map +0 -1
- package/dist/emailer/providers/zeptomail_provider.d.ts.map +0 -1
- package/dist/emailer/providers/zeptomail_provider.js.map +0 -1
- package/dist/emailer/types.d.ts.map +0 -1
- package/dist/emailer/types.js.map +0 -1
- package/dist/emailer/utils/constants.d.ts.map +0 -1
- package/dist/emailer/utils/constants.js.map +0 -1
- package/dist/emailer/utils/index.d.ts.map +0 -1
- package/dist/emailer/utils/index.js.map +0 -1
- package/dist/emailer/utils/logger.d.ts.map +0 -1
- package/dist/emailer/utils/logger.js.map +0 -1
- package/dist/emailer/utils/validation.d.ts.map +0 -1
- package/dist/emailer/utils/validation.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/template_manager/config/config_loader.d.ts.map +0 -1
- package/dist/template_manager/config/config_loader.js +0 -154
- package/dist/template_manager/config/config_loader.js.map +0 -1
- package/dist/template_manager/config/constants.d.ts.map +0 -1
- package/dist/template_manager/config/constants.js.map +0 -1
- package/dist/template_manager/config/index.d.ts.map +0 -1
- package/dist/template_manager/config/index.js.map +0 -1
- package/dist/template_manager/db/category_repository.d.ts.map +0 -1
- package/dist/template_manager/db/category_repository.js.map +0 -1
- package/dist/template_manager/db/index.d.ts +0 -6
- package/dist/template_manager/db/index.d.ts.map +0 -1
- package/dist/template_manager/db/index.js +0 -6
- package/dist/template_manager/db/index.js.map +0 -1
- package/dist/template_manager/db/template_repository.d.ts.map +0 -1
- package/dist/template_manager/db/template_repository.js +0 -674
- package/dist/template_manager/db/template_repository.js.map +0 -1
- package/dist/template_manager/engine/handlebars_engine.d.ts.map +0 -1
- package/dist/template_manager/engine/handlebars_engine.js.map +0 -1
- package/dist/template_manager/engine/index.d.ts.map +0 -1
- package/dist/template_manager/engine/index.js.map +0 -1
- package/dist/template_manager/engine/variable_resolver.d.ts.map +0 -1
- package/dist/template_manager/engine/variable_resolver.js.map +0 -1
- package/dist/template_manager/index.d.ts +0 -32
- package/dist/template_manager/index.d.ts.map +0 -1
- package/dist/template_manager/index.js +0 -41
- package/dist/template_manager/index.js.map +0 -1
- package/dist/template_manager/template_manager.d.ts.map +0 -1
- package/dist/template_manager/template_manager.js.map +0 -1
- package/dist/template_manager/types.d.ts.map +0 -1
- package/dist/template_manager/types.js +0 -11
- package/dist/template_manager/types.js.map +0 -1
- package/dist/template_manager/utils/index.d.ts.map +0 -1
- package/dist/template_manager/utils/index.js.map +0 -1
- package/dist/template_manager/utils/system_variables.d.ts.map +0 -1
- package/dist/template_manager/utils/system_variables.js.map +0 -1
- package/dist/template_manager/utils/validation.d.ts.map +0 -1
- package/dist/template_manager/utils/validation.js.map +0 -1
- /package/dist/{emailer → lib/emailer}/emailer.d.ts +0 -0
- /package/dist/{emailer → lib/emailer}/emailer.js +0 -0
- /package/dist/{emailer → lib/emailer}/index.d.ts +0 -0
- /package/dist/{emailer → lib/emailer}/index.js +0 -0
- /package/dist/{emailer → lib/emailer}/providers/index.d.ts +0 -0
- /package/dist/{emailer → lib/emailer}/providers/index.js +0 -0
- /package/dist/{emailer → lib/emailer}/providers/pop3_provider.d.ts +0 -0
- /package/dist/{emailer → lib/emailer}/providers/pop3_provider.js +0 -0
- /package/dist/{emailer → lib/emailer}/providers/smtp_provider.d.ts +0 -0
- /package/dist/{emailer → lib/emailer}/providers/smtp_provider.js +0 -0
- /package/dist/{emailer → lib/emailer}/providers/zeptomail_provider.d.ts +0 -0
- /package/dist/{emailer → lib/emailer}/types.d.ts +0 -0
- /package/dist/{emailer → lib/emailer}/types.js +0 -0
- /package/dist/{emailer → lib/emailer}/utils/constants.d.ts +0 -0
- /package/dist/{emailer → lib/emailer}/utils/constants.js +0 -0
- /package/dist/{emailer → lib/emailer}/utils/index.d.ts +0 -0
- /package/dist/{emailer → lib/emailer}/utils/index.js +0 -0
- /package/dist/{emailer → lib/emailer}/utils/logger.d.ts +0 -0
- /package/dist/{emailer → lib/emailer}/utils/logger.js +0 -0
- /package/dist/{emailer → lib/emailer}/utils/validation.d.ts +0 -0
- /package/dist/{emailer → lib/emailer}/utils/validation.js +0 -0
- /package/dist/{index.d.ts → lib/index.d.ts} +0 -0
- /package/dist/{index.js → lib/index.js} +0 -0
- /package/dist/{template_manager → lib/template_manager}/config/index.d.ts +0 -0
- /package/dist/{template_manager → lib/template_manager}/config/index.js +0 -0
- /package/dist/{template_manager → lib/template_manager}/engine/handlebars_engine.d.ts +0 -0
- /package/dist/{template_manager → lib/template_manager}/engine/handlebars_engine.js +0 -0
- /package/dist/{template_manager → lib/template_manager}/engine/index.d.ts +0 -0
- /package/dist/{template_manager → lib/template_manager}/engine/index.js +0 -0
- /package/dist/{template_manager → lib/template_manager}/utils/index.d.ts +0 -0
- /package/dist/{template_manager → lib/template_manager}/utils/index.js +0 -0
- /package/dist/{template_manager → lib/template_manager}/utils/system_variables.d.ts +0 -0
- /package/dist/{template_manager → lib/template_manager}/utils/system_variables.js +0 -0
- /package/dist/{template_manager → lib/template_manager}/utils/validation.d.ts +0 -0
- /package/dist/{template_manager → lib/template_manager}/utils/validation.js +0 -0
|
@@ -1,67 +1,65 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Template Manager Core Service
|
|
2
|
+
* Template Manager Core Service (v2.0.0)
|
|
3
3
|
*
|
|
4
|
-
* Core functions for rendering and sending templated emails
|
|
4
|
+
* Core functions for rendering and sending templated emails.
|
|
5
|
+
* Uses scope_chain for hierarchical template resolution.
|
|
5
6
|
*/
|
|
6
7
|
import type { HazoConnectInstance, TemplateManagerConfig, SendTemplateEmailOptions, SendTemplateEmailResponse, TemplateRenderResult, Logger } from './types.js';
|
|
7
8
|
/**
|
|
8
|
-
* Render a template with variables (without sending)
|
|
9
|
+
* Render a template with variables (without sending).
|
|
9
10
|
*
|
|
10
|
-
*
|
|
11
|
-
* (including system variables), processes @template
|
|
12
|
-
* the final content using Handlebars.
|
|
11
|
+
* Fetches a template from the database using hierarchical scope resolution,
|
|
12
|
+
* resolves all variables (including system variables), processes @template
|
|
13
|
+
* references, and renders the final content using Handlebars.
|
|
13
14
|
*
|
|
14
15
|
* @param template_name - Name of the template to render
|
|
15
16
|
* @param variables - User-provided variables to substitute
|
|
16
17
|
* @param hazo_connect - Database connection instance
|
|
17
|
-
* @param
|
|
18
|
+
* @param scope_id - Scope ID for hierarchical lookup (null = global only)
|
|
18
19
|
* @param config - Optional config override (loads from file if not provided)
|
|
19
20
|
* @param logger - Optional logger instance
|
|
20
21
|
* @returns Render result with HTML and text content
|
|
21
22
|
*/
|
|
22
|
-
export declare function render_template(template_name: string, variables: Record<string, string>, hazo_connect: HazoConnectInstance,
|
|
23
|
+
export declare function render_template(template_name: string, variables: Record<string, string>, hazo_connect: HazoConnectInstance, scope_id: string | null, config?: TemplateManagerConfig, logger?: Logger): Promise<TemplateRenderResult>;
|
|
23
24
|
/**
|
|
24
|
-
* Send an email using a named template
|
|
25
|
+
* Send an email using a named template.
|
|
25
26
|
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
27
|
+
* 1. Resolves scope chain from options.scope_id
|
|
28
|
+
* 2. Fetches the template from the database
|
|
29
|
+
* 3. Resolves all variables (user + system)
|
|
30
|
+
* 4. Processes @template references
|
|
31
|
+
* 5. Renders with Handlebars
|
|
32
|
+
* 6. Sends via the emailer module
|
|
32
33
|
*
|
|
33
34
|
* @param options - Template email options
|
|
34
35
|
* @param hazo_connect - Database connection instance
|
|
35
|
-
* @param org_id - Organization ID
|
|
36
36
|
* @param config - Optional config override
|
|
37
37
|
* @returns Email send response
|
|
38
38
|
*/
|
|
39
|
-
export declare function send_template_email(options: SendTemplateEmailOptions, hazo_connect: HazoConnectInstance,
|
|
39
|
+
export declare function send_template_email(options: SendTemplateEmailOptions, hazo_connect: HazoConnectInstance, config?: TemplateManagerConfig): Promise<SendTemplateEmailResponse>;
|
|
40
40
|
/**
|
|
41
|
-
* Preview a template render without saving or sending
|
|
42
|
-
*
|
|
43
|
-
* Useful for the UI to show a preview of what the email will look like
|
|
41
|
+
* Preview a template render without saving or sending.
|
|
42
|
+
* Useful for the UI to show a preview of what the email will look like.
|
|
44
43
|
*
|
|
45
44
|
* @param html_content - Raw HTML template content
|
|
46
45
|
* @param text_content - Raw text template content
|
|
47
46
|
* @param variables - Variables to substitute
|
|
48
47
|
* @param hazo_connect - Database connection (for @template resolution)
|
|
49
|
-
* @param
|
|
48
|
+
* @param scope_id - Scope ID for hierarchical @template resolution
|
|
50
49
|
* @returns Render result
|
|
51
50
|
*/
|
|
52
|
-
export declare function preview_template(html_content: string, text_content: string, variables: Record<string, string>, hazo_connect?: HazoConnectInstance,
|
|
51
|
+
export declare function preview_template(html_content: string, text_content: string, variables: Record<string, string>, hazo_connect?: HazoConnectInstance, scope_id?: string | null): Promise<TemplateRenderResult>;
|
|
53
52
|
/**
|
|
54
|
-
* Validate template variables before rendering
|
|
55
|
-
*
|
|
56
|
-
* Checks that all required variables are provided
|
|
53
|
+
* Validate template variables before rendering.
|
|
54
|
+
* Checks that all required variables are provided.
|
|
57
55
|
*
|
|
58
56
|
* @param template_name - Name of the template
|
|
59
57
|
* @param variables - Variables to validate
|
|
60
58
|
* @param hazo_connect - Database connection
|
|
61
|
-
* @param
|
|
59
|
+
* @param scope_id - Scope ID for hierarchical lookup
|
|
62
60
|
* @returns Validation result
|
|
63
61
|
*/
|
|
64
|
-
export declare function validate_template_variables(template_name: string, variables: Record<string, string>, hazo_connect: HazoConnectInstance,
|
|
62
|
+
export declare function validate_template_variables(template_name: string, variables: Record<string, string>, hazo_connect: HazoConnectInstance, scope_id: string | null): Promise<{
|
|
65
63
|
valid: boolean;
|
|
66
64
|
missing: string[];
|
|
67
65
|
message: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template_manager.d.ts","sourceRoot":"","sources":["../../../src/lib/template_manager/template_manager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,EACxB,yBAAyB,EACzB,oBAA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and sending templated emails
|
|
4
|
+
* Core functions for rendering and sending templated emails.
|
|
5
|
+
* Uses scope_chain for hierarchical template resolution.
|
|
5
6
|
*/
|
|
6
7
|
import { send_email } from '../emailer/emailer.js';
|
|
7
8
|
import { get_logger, create_fallback_logger } from '../emailer/utils/logger.js';
|
|
8
|
-
import { load_template_config } from './config/config_loader.js';
|
|
9
9
|
import { ERROR_MESSAGES } from './config/constants.js';
|
|
10
10
|
import { get_template_by_name } from './db/template_repository.js';
|
|
11
|
+
import { get_scope_chain } from './cache/scope_chain_cache.js';
|
|
11
12
|
import { render_handlebars, resolve_variables, resolve_all_template_references, } from './engine/index.js';
|
|
12
13
|
import { validate_provided_variables, } from './utils/validation.js';
|
|
14
|
+
import { get_system_variables } from './utils/system_variables.js';
|
|
13
15
|
/**
|
|
14
|
-
* Render a template with variables (without sending)
|
|
16
|
+
* Render a template with variables (without sending).
|
|
15
17
|
*
|
|
16
|
-
*
|
|
17
|
-
* (including system variables), processes @template
|
|
18
|
-
* the final content using Handlebars.
|
|
18
|
+
* Fetches a template from the database using hierarchical scope resolution,
|
|
19
|
+
* resolves all variables (including system variables), processes @template
|
|
20
|
+
* references, and renders the final content using Handlebars.
|
|
19
21
|
*
|
|
20
22
|
* @param template_name - Name of the template to render
|
|
21
23
|
* @param variables - User-provided variables to substitute
|
|
22
24
|
* @param hazo_connect - Database connection instance
|
|
23
|
-
* @param
|
|
25
|
+
* @param scope_id - Scope ID for hierarchical lookup (null = global only)
|
|
24
26
|
* @param config - Optional config override (loads from file if not provided)
|
|
25
27
|
* @param logger - Optional logger instance
|
|
26
28
|
* @returns Render result with HTML and text content
|
|
27
29
|
*/
|
|
28
|
-
export async function render_template(template_name, variables, hazo_connect,
|
|
30
|
+
export async function render_template(template_name, variables, hazo_connect, scope_id, config, logger) {
|
|
29
31
|
const log = logger || create_fallback_logger('template_manager');
|
|
30
32
|
const filename = 'template_manager.ts';
|
|
31
33
|
const function_name = 'render_template';
|
|
@@ -34,9 +36,8 @@ export async function render_template(template_name, variables, hazo_connect, or
|
|
|
34
36
|
filename,
|
|
35
37
|
function_name,
|
|
36
38
|
template_name,
|
|
37
|
-
|
|
39
|
+
scope_id,
|
|
38
40
|
});
|
|
39
|
-
// Validate inputs
|
|
40
41
|
if (!hazo_connect) {
|
|
41
42
|
return {
|
|
42
43
|
success: false,
|
|
@@ -44,10 +45,10 @@ export async function render_template(template_name, variables, hazo_connect, or
|
|
|
44
45
|
message: ERROR_MESSAGES.DB_CONNECTION_REQUIRED,
|
|
45
46
|
};
|
|
46
47
|
}
|
|
47
|
-
//
|
|
48
|
-
const
|
|
48
|
+
// Resolve scope chain for hierarchical lookup
|
|
49
|
+
const scope_chain = scope_id ? await get_scope_chain(scope_id) : [];
|
|
49
50
|
// Fetch template from database
|
|
50
|
-
const template_result = await get_template_by_name(hazo_connect,
|
|
51
|
+
const template_result = await get_template_by_name(hazo_connect, scope_chain, template_name);
|
|
51
52
|
if (!template_result.success || !template_result.data) {
|
|
52
53
|
log.warn('Template not found', {
|
|
53
54
|
filename,
|
|
@@ -65,7 +66,7 @@ export async function render_template(template_name, variables, hazo_connect, or
|
|
|
65
66
|
// Merge user variables with system variables
|
|
66
67
|
const all_variables = resolve_variables(variables);
|
|
67
68
|
// Resolve @template references in both HTML and text
|
|
68
|
-
const resolved_result = await resolve_all_template_references(template.template_html, template.template_text, all_variables, hazo_connect,
|
|
69
|
+
const resolved_result = await resolve_all_template_references(template.template_html, template.template_text, all_variables, hazo_connect, scope_chain);
|
|
69
70
|
if (!resolved_result.success) {
|
|
70
71
|
log.warn('Failed to resolve template references', {
|
|
71
72
|
filename,
|
|
@@ -114,22 +115,21 @@ export async function render_template(template_name, variables, hazo_connect, or
|
|
|
114
115
|
}
|
|
115
116
|
}
|
|
116
117
|
/**
|
|
117
|
-
* Send an email using a named template
|
|
118
|
+
* Send an email using a named template.
|
|
118
119
|
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
120
|
+
* 1. Resolves scope chain from options.scope_id
|
|
121
|
+
* 2. Fetches the template from the database
|
|
122
|
+
* 3. Resolves all variables (user + system)
|
|
123
|
+
* 4. Processes @template references
|
|
124
|
+
* 5. Renders with Handlebars
|
|
125
|
+
* 6. Sends via the emailer module
|
|
125
126
|
*
|
|
126
127
|
* @param options - Template email options
|
|
127
128
|
* @param hazo_connect - Database connection instance
|
|
128
|
-
* @param org_id - Organization ID
|
|
129
129
|
* @param config - Optional config override
|
|
130
130
|
* @returns Email send response
|
|
131
131
|
*/
|
|
132
|
-
export async function send_template_email(options, hazo_connect,
|
|
132
|
+
export async function send_template_email(options, hazo_connect, config) {
|
|
133
133
|
const log = options.logger
|
|
134
134
|
? get_logger(options.logger)
|
|
135
135
|
: create_fallback_logger('template_manager');
|
|
@@ -141,9 +141,8 @@ export async function send_template_email(options, hazo_connect, org_id, config)
|
|
|
141
141
|
function_name,
|
|
142
142
|
template_name: options.template_name,
|
|
143
143
|
to: options.to,
|
|
144
|
-
|
|
144
|
+
scope_id: options.scope_id,
|
|
145
145
|
});
|
|
146
|
-
// Validate inputs
|
|
147
146
|
if (!hazo_connect) {
|
|
148
147
|
return {
|
|
149
148
|
success: false,
|
|
@@ -151,8 +150,7 @@ export async function send_template_email(options, hazo_connect, org_id, config)
|
|
|
151
150
|
message: ERROR_MESSAGES.DB_CONNECTION_REQUIRED,
|
|
152
151
|
};
|
|
153
152
|
}
|
|
154
|
-
|
|
155
|
-
const render_result = await render_template(options.template_name, options.variables, hazo_connect, org_id, config, log);
|
|
153
|
+
const render_result = await render_template(options.template_name, options.variables, hazo_connect, options.scope_id, config, log);
|
|
156
154
|
if (!render_result.success) {
|
|
157
155
|
return {
|
|
158
156
|
success: false,
|
|
@@ -160,12 +158,10 @@ export async function send_template_email(options, hazo_connect, org_id, config)
|
|
|
160
158
|
message: render_result.message,
|
|
161
159
|
};
|
|
162
160
|
}
|
|
163
|
-
// Build subject - use provided subject or template name as fallback
|
|
164
161
|
const subject = options.subject ||
|
|
165
162
|
options.template_name
|
|
166
163
|
.replace(/_/g, ' ')
|
|
167
164
|
.replace(/\b\w/g, (l) => l.toUpperCase());
|
|
168
|
-
// Send the email using the emailer module
|
|
169
165
|
const email_response = await send_email({
|
|
170
166
|
to: options.to,
|
|
171
167
|
subject,
|
|
@@ -237,34 +233,30 @@ export async function send_template_email(options, hazo_connect, org_id, config)
|
|
|
237
233
|
}
|
|
238
234
|
}
|
|
239
235
|
/**
|
|
240
|
-
* Preview a template render without saving or sending
|
|
241
|
-
*
|
|
242
|
-
* Useful for the UI to show a preview of what the email will look like
|
|
236
|
+
* Preview a template render without saving or sending.
|
|
237
|
+
* Useful for the UI to show a preview of what the email will look like.
|
|
243
238
|
*
|
|
244
239
|
* @param html_content - Raw HTML template content
|
|
245
240
|
* @param text_content - Raw text template content
|
|
246
241
|
* @param variables - Variables to substitute
|
|
247
242
|
* @param hazo_connect - Database connection (for @template resolution)
|
|
248
|
-
* @param
|
|
243
|
+
* @param scope_id - Scope ID for hierarchical @template resolution
|
|
249
244
|
* @returns Render result
|
|
250
245
|
*/
|
|
251
|
-
export async function preview_template(html_content, text_content, variables, hazo_connect,
|
|
246
|
+
export async function preview_template(html_content, text_content, variables, hazo_connect, scope_id) {
|
|
252
247
|
try {
|
|
253
|
-
// Merge with system variables
|
|
254
248
|
const all_variables = resolve_variables(variables);
|
|
255
|
-
// If hazo_connect is provided, resolve @template references
|
|
256
249
|
let resolved_html = html_content;
|
|
257
250
|
let resolved_text = text_content;
|
|
258
|
-
if (hazo_connect
|
|
259
|
-
const
|
|
251
|
+
if (hazo_connect) {
|
|
252
|
+
const scope_chain = scope_id ? await get_scope_chain(scope_id) : [];
|
|
253
|
+
const resolved_result = await resolve_all_template_references(html_content, text_content, all_variables, hazo_connect, scope_chain);
|
|
260
254
|
if (resolved_result.success) {
|
|
261
255
|
resolved_html = resolved_result.rendered_html || html_content;
|
|
262
256
|
resolved_text = resolved_result.rendered_text || text_content;
|
|
263
257
|
}
|
|
264
258
|
}
|
|
265
|
-
|
|
266
|
-
const render_result = render_handlebars(resolved_html, resolved_text, all_variables);
|
|
267
|
-
return render_result;
|
|
259
|
+
return render_handlebars(resolved_html, resolved_text, all_variables);
|
|
268
260
|
}
|
|
269
261
|
catch (error) {
|
|
270
262
|
const error_message = error instanceof Error ? error.message : 'Unknown error occurred';
|
|
@@ -276,20 +268,19 @@ export async function preview_template(html_content, text_content, variables, ha
|
|
|
276
268
|
}
|
|
277
269
|
}
|
|
278
270
|
/**
|
|
279
|
-
* Validate template variables before rendering
|
|
280
|
-
*
|
|
281
|
-
* Checks that all required variables are provided
|
|
271
|
+
* Validate template variables before rendering.
|
|
272
|
+
* Checks that all required variables are provided.
|
|
282
273
|
*
|
|
283
274
|
* @param template_name - Name of the template
|
|
284
275
|
* @param variables - Variables to validate
|
|
285
276
|
* @param hazo_connect - Database connection
|
|
286
|
-
* @param
|
|
277
|
+
* @param scope_id - Scope ID for hierarchical lookup
|
|
287
278
|
* @returns Validation result
|
|
288
279
|
*/
|
|
289
|
-
export async function validate_template_variables(template_name, variables, hazo_connect,
|
|
280
|
+
export async function validate_template_variables(template_name, variables, hazo_connect, scope_id) {
|
|
290
281
|
try {
|
|
291
|
-
|
|
292
|
-
const template_result = await get_template_by_name(hazo_connect,
|
|
282
|
+
const scope_chain = scope_id ? await get_scope_chain(scope_id) : [];
|
|
283
|
+
const template_result = await get_template_by_name(hazo_connect, scope_chain, template_name);
|
|
293
284
|
if (!template_result.success || !template_result.data) {
|
|
294
285
|
return {
|
|
295
286
|
valid: false,
|
|
@@ -298,14 +289,9 @@ export async function validate_template_variables(template_name, variables, hazo
|
|
|
298
289
|
};
|
|
299
290
|
}
|
|
300
291
|
const template = template_result.data;
|
|
301
|
-
const
|
|
302
|
-
// Get system variable names
|
|
303
|
-
const system_var_names = config.system_email_template_variables.map((v) => v.variable_name);
|
|
304
|
-
// Validate HTML content
|
|
292
|
+
const system_var_names = get_system_variables().map((v) => v.variable_name);
|
|
305
293
|
const html_validation = validate_provided_variables(template.template_html, variables, system_var_names);
|
|
306
|
-
// Validate text content
|
|
307
294
|
const text_validation = validate_provided_variables(template.template_text, variables, system_var_names);
|
|
308
|
-
// Combine missing variables
|
|
309
295
|
const all_missing = [
|
|
310
296
|
...new Set([...html_validation.missing, ...text_validation.missing]),
|
|
311
297
|
];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template_manager.js","sourceRoot":"","sources":["../../../src/lib/template_manager/template_manager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAUH,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAEhF,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,+BAA+B,GAChC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,2BAA2B,GAC5B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAEnE;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,aAAqB,EACrB,SAAiC,EACjC,YAAiC,EACjC,QAAuB,EACvB,MAA8B,EAC9B,MAAe;IAEf,MAAM,GAAG,GAAG,MAAM,IAAI,sBAAsB,CAAC,kBAAkB,CAAC,CAAC;IACjE,MAAM,QAAQ,GAAG,qBAAqB,CAAC;IACvC,MAAM,aAAa,GAAG,iBAAiB,CAAC;IAExC,IAAI,CAAC;QACH,GAAG,CAAC,IAAI,CAAC,oBAAoB,EAAE;YAC7B,QAAQ;YACR,aAAa;YACb,aAAa;YACb,QAAQ;SACT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AAE,KAAK;YACZ,OAAO,EAAE,EAAE;YACX,OAAO,EAAE,qBAAqB,aAAa,EAAE;SAC9C,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -1,117 +1,87 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Type definitions for the template manager service
|
|
2
|
+
* Type definitions for the template manager service (v2.0.0)
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* -
|
|
6
|
-
* -
|
|
7
|
-
* -
|
|
8
|
-
* -
|
|
4
|
+
* Key changes from v1:
|
|
5
|
+
* - org_id/root_org_id replaced with scope_id (null = global)
|
|
6
|
+
* - email_type enum removed (use scope_id IS NULL discriminator instead)
|
|
7
|
+
* - is_modified added to EmailTemplate (tracks super-admin edits to globals)
|
|
8
|
+
* - template_variables retyped to TemplateVariableDefinition[]
|
|
9
|
+
* - SystemTemplateManifest added (inline content, no file paths)
|
|
9
10
|
*/
|
|
10
11
|
import type { Logger } from '../emailer/types.js';
|
|
11
|
-
/**
|
|
12
|
-
* Definition of a template variable
|
|
13
|
-
*/
|
|
14
12
|
export interface TemplateVariableDefinition {
|
|
15
13
|
variable_name: string;
|
|
16
14
|
variable_description: string;
|
|
17
15
|
default_value?: string;
|
|
18
16
|
}
|
|
19
|
-
/**
|
|
20
|
-
* Definition of a template type with its associated variables
|
|
21
|
-
* Loaded from config: email_template_variable_types
|
|
22
|
-
*/
|
|
23
17
|
export interface TemplateTypeDefinition {
|
|
24
18
|
template_name: string;
|
|
25
19
|
template_label: string;
|
|
26
20
|
variables: TemplateVariableDefinition[];
|
|
27
21
|
}
|
|
28
|
-
/**
|
|
29
|
-
* System variable that is auto-generated (e.g., date formats)
|
|
30
|
-
*/
|
|
31
22
|
export interface SystemVariable {
|
|
32
23
|
variable_name: string;
|
|
33
24
|
variable_description: string;
|
|
34
25
|
resolver: () => string;
|
|
35
26
|
}
|
|
36
|
-
/**
|
|
37
|
-
* Configuration for the template manager
|
|
38
|
-
*/
|
|
39
27
|
export interface TemplateManagerConfig {
|
|
40
|
-
|
|
41
|
-
|
|
28
|
+
scope_chain_cache_ttl_seconds?: number;
|
|
29
|
+
cors_allowed_origins?: string[];
|
|
42
30
|
}
|
|
43
31
|
/**
|
|
44
|
-
*
|
|
45
|
-
|
|
46
|
-
export type EmailType = 'system' | 'user';
|
|
47
|
-
/**
|
|
48
|
-
* Template category entity from hazo_notify_template_cat table
|
|
32
|
+
* Manifest entry for a system template shipped by a consuming package.
|
|
33
|
+
* Consumers read file content at boot; hazo_notify never does file I/O.
|
|
49
34
|
*/
|
|
35
|
+
export interface SystemTemplateManifest {
|
|
36
|
+
template_name: string;
|
|
37
|
+
template_label: string;
|
|
38
|
+
category: string;
|
|
39
|
+
html: string;
|
|
40
|
+
text: string;
|
|
41
|
+
variables: TemplateVariableDefinition[];
|
|
42
|
+
}
|
|
50
43
|
export interface TemplateCategory {
|
|
51
44
|
id: string;
|
|
52
|
-
|
|
53
|
-
root_org_id: string;
|
|
45
|
+
scope_id: string | null;
|
|
54
46
|
template_category_name: string;
|
|
55
47
|
created_at: string;
|
|
56
48
|
changed_at: string | null;
|
|
57
49
|
}
|
|
58
|
-
/**
|
|
59
|
-
* Input for creating a new template category
|
|
60
|
-
*/
|
|
61
50
|
export interface TemplateCategoryInput {
|
|
62
|
-
|
|
63
|
-
root_org_id: string;
|
|
51
|
+
scope_id: string | null;
|
|
64
52
|
template_category_name: string;
|
|
65
53
|
}
|
|
66
|
-
/**
|
|
67
|
-
* Input for updating an existing template category
|
|
68
|
-
*/
|
|
69
54
|
export interface TemplateCategoryUpdate {
|
|
70
55
|
template_category_name?: string;
|
|
71
56
|
}
|
|
72
|
-
/**
|
|
73
|
-
* Email template entity from hazo_notify_templates table
|
|
74
|
-
*/
|
|
75
57
|
export interface EmailTemplate {
|
|
76
58
|
id: string;
|
|
77
|
-
|
|
78
|
-
root_org_id: string;
|
|
59
|
+
scope_id: string | null;
|
|
79
60
|
template_category_id: string;
|
|
80
|
-
template_variables:
|
|
61
|
+
template_variables: TemplateVariableDefinition[];
|
|
81
62
|
template_name: string;
|
|
82
63
|
template_html: string;
|
|
83
64
|
template_text: string;
|
|
84
|
-
|
|
65
|
+
is_modified: boolean;
|
|
85
66
|
created_at: string;
|
|
86
67
|
changed_at: string | null;
|
|
87
68
|
}
|
|
88
|
-
/**
|
|
89
|
-
* Input for creating a new email template
|
|
90
|
-
*/
|
|
91
69
|
export interface EmailTemplateInput {
|
|
92
|
-
|
|
93
|
-
root_org_id: string;
|
|
70
|
+
scope_id: string | null;
|
|
94
71
|
template_category_id: string;
|
|
95
|
-
template_variables?:
|
|
72
|
+
template_variables?: TemplateVariableDefinition[];
|
|
96
73
|
template_name: string;
|
|
97
74
|
template_html: string;
|
|
98
75
|
template_text: string;
|
|
99
|
-
email_type?: EmailType;
|
|
100
76
|
}
|
|
101
|
-
/**
|
|
102
|
-
* Input for updating an existing email template
|
|
103
|
-
*/
|
|
104
77
|
export interface EmailTemplateUpdate {
|
|
105
78
|
template_category_id?: string;
|
|
106
|
-
template_variables?:
|
|
79
|
+
template_variables?: TemplateVariableDefinition[];
|
|
107
80
|
template_name?: string;
|
|
108
81
|
template_html?: string;
|
|
109
82
|
template_text?: string;
|
|
83
|
+
is_modified?: boolean;
|
|
110
84
|
}
|
|
111
|
-
/**
|
|
112
|
-
* Query builder interface for hazo_connect
|
|
113
|
-
* Supports fluent chaining pattern
|
|
114
|
-
*/
|
|
115
85
|
export interface HazoConnectQueryBuilder {
|
|
116
86
|
from(table: string): this;
|
|
117
87
|
select(columns: string | string[]): this;
|
|
@@ -121,29 +91,17 @@ export interface HazoConnectQueryBuilder {
|
|
|
121
91
|
limit(n: number): this;
|
|
122
92
|
offset(n: number): this;
|
|
123
93
|
}
|
|
124
|
-
/**
|
|
125
|
-
* hazo_connect instance interface
|
|
126
|
-
* Consuming apps pass this to template manager functions
|
|
127
|
-
*/
|
|
128
94
|
export interface HazoConnectInstance {
|
|
129
|
-
/** Execute query and return list of results */
|
|
130
95
|
list<T>(query: HazoConnectQueryBuilder): Promise<T[]>;
|
|
131
|
-
/** Find a single record by ID */
|
|
132
96
|
findById<T>(table: string, id: string): Promise<T | null>;
|
|
133
|
-
/** Find records matching criteria */
|
|
134
97
|
findBy<T>(table: string, criteria: Record<string, unknown>): Promise<T[]>;
|
|
135
|
-
/** Insert a new record */
|
|
136
98
|
insert<T>(table: string, data: Partial<T>): Promise<T>;
|
|
137
|
-
/** Update a record by ID */
|
|
138
99
|
updateById<T>(table: string, id: string, patch: Partial<T>): Promise<T>;
|
|
139
|
-
/** Delete a record by ID */
|
|
140
100
|
deleteById(table: string, id: string): Promise<boolean>;
|
|
141
|
-
/** Create a new query builder */
|
|
142
101
|
query(): HazoConnectQueryBuilder;
|
|
102
|
+
/** Execute raw SQL with positional parameters */
|
|
103
|
+
raw?<T>(sql: string, params?: unknown[]): Promise<T[]>;
|
|
143
104
|
}
|
|
144
|
-
/**
|
|
145
|
-
* Result of rendering a template
|
|
146
|
-
*/
|
|
147
105
|
export interface TemplateRenderResult {
|
|
148
106
|
success: boolean;
|
|
149
107
|
rendered_html?: string;
|
|
@@ -151,105 +109,54 @@ export interface TemplateRenderResult {
|
|
|
151
109
|
error?: string;
|
|
152
110
|
message?: string;
|
|
153
111
|
}
|
|
154
|
-
/**
|
|
155
|
-
* Generic response for template operations
|
|
156
|
-
*/
|
|
157
112
|
export interface TemplateOperationResponse<T = unknown> {
|
|
158
113
|
success: boolean;
|
|
159
114
|
data?: T;
|
|
160
115
|
error?: string;
|
|
161
116
|
message?: string;
|
|
162
117
|
}
|
|
163
|
-
/**
|
|
164
|
-
* Attachment for template email
|
|
165
|
-
*/
|
|
166
118
|
export interface TemplateEmailAttachment {
|
|
167
119
|
filename: string;
|
|
168
120
|
content: string;
|
|
169
121
|
mime_type: string;
|
|
170
122
|
}
|
|
171
|
-
/**
|
|
172
|
-
* Options for sending a templated email
|
|
173
|
-
*/
|
|
174
123
|
export interface SendTemplateEmailOptions {
|
|
175
|
-
/** Name of template to use (must match a template_name in DB) */
|
|
176
124
|
template_name: string;
|
|
177
|
-
/** Variables to substitute in the template */
|
|
178
125
|
variables: Record<string, string>;
|
|
179
|
-
/** Recipient email address(es) */
|
|
180
126
|
to: string | string[];
|
|
181
|
-
|
|
127
|
+
scope_id: string | null;
|
|
182
128
|
subject?: string;
|
|
183
|
-
/** Sender email address (overrides config default) */
|
|
184
129
|
from?: string;
|
|
185
|
-
/** Sender name (overrides config default) */
|
|
186
130
|
from_name?: string;
|
|
187
|
-
/** Reply-to email address */
|
|
188
131
|
reply_to?: string;
|
|
189
|
-
/** CC recipients */
|
|
190
132
|
cc?: string | string[];
|
|
191
|
-
/** BCC recipients */
|
|
192
133
|
bcc?: string | string[];
|
|
193
|
-
/** File attachments */
|
|
194
134
|
attachments?: TemplateEmailAttachment[];
|
|
195
|
-
/** Optional logger instance (compatible with hazo_logs) */
|
|
196
135
|
logger?: Logger;
|
|
197
136
|
}
|
|
198
|
-
/**
|
|
199
|
-
* Response from send_template_email
|
|
200
|
-
*/
|
|
201
137
|
export interface SendTemplateEmailResponse {
|
|
202
138
|
success: boolean;
|
|
203
139
|
message_id?: string;
|
|
204
140
|
message?: string;
|
|
205
|
-
/** Rendered HTML content (for debugging) */
|
|
206
141
|
rendered_html?: string;
|
|
207
|
-
/** Rendered text content (for debugging) */
|
|
208
142
|
rendered_text?: string;
|
|
209
143
|
raw_response?: Record<string, unknown> | string;
|
|
210
144
|
error?: string;
|
|
211
145
|
}
|
|
212
|
-
/**
|
|
213
|
-
* Category with its templates for UI tree display
|
|
214
|
-
*/
|
|
215
146
|
export interface CategoryTreeItem {
|
|
216
147
|
category: TemplateCategory;
|
|
217
148
|
templates: EmailTemplate[];
|
|
218
149
|
expanded: boolean;
|
|
219
150
|
}
|
|
220
|
-
/**
|
|
221
|
-
* Variable item for dropdown display
|
|
222
|
-
*/
|
|
223
151
|
export interface VariableItem {
|
|
224
152
|
name: string;
|
|
225
153
|
description: string;
|
|
226
|
-
type: '
|
|
154
|
+
type: 'registry' | 'db' | 'extracted';
|
|
227
155
|
}
|
|
228
|
-
/**
|
|
229
|
-
* Template reference item for dropdown display
|
|
230
|
-
*/
|
|
231
156
|
export interface TemplateReferenceItem {
|
|
232
157
|
category_name: string;
|
|
233
158
|
template_name: string;
|
|
234
159
|
template_id: string;
|
|
235
160
|
}
|
|
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
161
|
export type { Logger };
|
|
255
162
|
//# 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;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAMlD,MAAM,WAAW,0BAA0B;IACzC,aAAa,EAAE,MAAM,CAAC;IACtB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,sBAAsB;IACrC,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,0BAA0B,EAAE,CAAC;CACzC;AAED,MAAM,WAAW,cAAc;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,QAAQ,EAAE,MAAM,MAAM,CA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AM,EAAE,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for the template manager service (v2.0.0)
|
|
3
|
+
*
|
|
4
|
+
* Key changes from v1:
|
|
5
|
+
* - org_id/root_org_id replaced with scope_id (null = global)
|
|
6
|
+
* - email_type enum removed (use scope_id IS NULL discriminator instead)
|
|
7
|
+
* - is_modified added to EmailTemplate (tracks super-admin edits to globals)
|
|
8
|
+
* - template_variables retyped to TemplateVariableDefinition[]
|
|
9
|
+
* - SystemTemplateManifest added (inline content, no file paths)
|
|
10
|
+
*/
|
|
11
|
+
export {};
|
|
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;;;;;;;;;GASG"}
|