hazo_notify 1.1.3 → 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.
Files changed (224) hide show
  1. package/README.md +239 -20
  2. package/dist/components/template_manager/category_dialog.d.ts +11 -0
  3. package/dist/components/template_manager/category_dialog.d.ts.map +1 -0
  4. package/dist/components/template_manager/category_dialog.js +41 -0
  5. package/dist/components/template_manager/category_dialog.js.map +1 -0
  6. package/dist/components/template_manager/category_tree.d.ts +13 -0
  7. package/dist/components/template_manager/category_tree.d.ts.map +1 -0
  8. package/dist/components/template_manager/category_tree.js +45 -0
  9. package/dist/components/template_manager/category_tree.js.map +1 -0
  10. package/dist/components/template_manager/index.d.ts +10 -0
  11. package/dist/components/template_manager/index.d.ts.map +1 -0
  12. package/dist/components/template_manager/index.js +8 -0
  13. package/dist/components/template_manager/index.js.map +1 -0
  14. package/dist/components/template_manager/preview_dialog.d.ts +11 -0
  15. package/dist/components/template_manager/preview_dialog.d.ts.map +1 -0
  16. package/dist/components/template_manager/preview_dialog.js +15 -0
  17. package/dist/components/template_manager/preview_dialog.js.map +1 -0
  18. package/dist/components/template_manager/template_dialog.d.ts +12 -0
  19. package/dist/components/template_manager/template_dialog.d.ts.map +1 -0
  20. package/dist/components/template_manager/template_dialog.js +46 -0
  21. package/dist/components/template_manager/template_dialog.js.map +1 -0
  22. package/dist/components/template_manager/template_editor.d.ts +12 -0
  23. package/dist/components/template_manager/template_editor.d.ts.map +1 -0
  24. package/dist/components/template_manager/template_editor.js +57 -0
  25. package/dist/components/template_manager/template_editor.js.map +1 -0
  26. package/dist/components/template_manager/template_globals_admin.d.ts +8 -0
  27. package/dist/components/template_manager/template_globals_admin.d.ts.map +1 -0
  28. package/dist/components/template_manager/template_globals_admin.js +27 -0
  29. package/dist/components/template_manager/template_globals_admin.js.map +1 -0
  30. package/dist/components/template_manager/template_manager_admin.d.ts +44 -0
  31. package/dist/components/template_manager/template_manager_admin.d.ts.map +1 -0
  32. package/dist/components/template_manager/template_manager_admin.js +272 -0
  33. package/dist/components/template_manager/template_manager_admin.js.map +1 -0
  34. package/dist/lib/emailer/emailer.d.ts.map +1 -0
  35. package/dist/lib/emailer/emailer.js.map +1 -0
  36. package/dist/lib/emailer/index.d.ts.map +1 -0
  37. package/dist/lib/emailer/index.js.map +1 -0
  38. package/dist/lib/emailer/providers/index.d.ts.map +1 -0
  39. package/dist/lib/emailer/providers/index.js.map +1 -0
  40. package/dist/lib/emailer/providers/pop3_provider.d.ts.map +1 -0
  41. package/dist/lib/emailer/providers/pop3_provider.js.map +1 -0
  42. package/dist/lib/emailer/providers/smtp_provider.d.ts.map +1 -0
  43. package/dist/lib/emailer/providers/smtp_provider.js.map +1 -0
  44. package/dist/lib/emailer/providers/zeptomail_provider.d.ts.map +1 -0
  45. package/dist/{emailer → lib/emailer}/providers/zeptomail_provider.js +9 -6
  46. package/dist/lib/emailer/providers/zeptomail_provider.js.map +1 -0
  47. package/dist/lib/emailer/types.d.ts.map +1 -0
  48. package/dist/lib/emailer/types.js.map +1 -0
  49. package/dist/lib/emailer/utils/constants.d.ts.map +1 -0
  50. package/dist/lib/emailer/utils/constants.js.map +1 -0
  51. package/dist/lib/emailer/utils/index.d.ts.map +1 -0
  52. package/dist/lib/emailer/utils/index.js.map +1 -0
  53. package/dist/lib/emailer/utils/logger.d.ts.map +1 -0
  54. package/dist/lib/emailer/utils/logger.js.map +1 -0
  55. package/dist/lib/emailer/utils/validation.d.ts.map +1 -0
  56. package/dist/lib/emailer/utils/validation.js.map +1 -0
  57. package/dist/lib/index.d.ts.map +1 -0
  58. package/dist/lib/index.js.map +1 -0
  59. package/dist/lib/template_manager/cache/scope_chain_cache.d.ts +26 -0
  60. package/dist/lib/template_manager/cache/scope_chain_cache.d.ts.map +1 -0
  61. package/dist/lib/template_manager/cache/scope_chain_cache.js +60 -0
  62. package/dist/lib/template_manager/cache/scope_chain_cache.js.map +1 -0
  63. package/dist/{template_manager → lib/template_manager}/config/config_loader.d.ts +16 -15
  64. package/dist/lib/template_manager/config/config_loader.d.ts.map +1 -0
  65. package/dist/lib/template_manager/config/config_loader.js +98 -0
  66. package/dist/lib/template_manager/config/config_loader.js.map +1 -0
  67. package/dist/{template_manager → lib/template_manager}/config/constants.d.ts +4 -54
  68. package/dist/lib/template_manager/config/constants.d.ts.map +1 -0
  69. package/dist/{template_manager → lib/template_manager}/config/constants.js +4 -84
  70. package/dist/lib/template_manager/config/constants.js.map +1 -0
  71. package/dist/lib/template_manager/config/index.d.ts.map +1 -0
  72. package/dist/lib/template_manager/config/index.js.map +1 -0
  73. package/dist/{template_manager → lib/template_manager}/db/category_repository.d.ts +22 -14
  74. package/dist/lib/template_manager/db/category_repository.d.ts.map +1 -0
  75. package/dist/{template_manager → lib/template_manager}/db/category_repository.js +127 -83
  76. package/dist/lib/template_manager/db/category_repository.js.map +1 -0
  77. package/dist/lib/template_manager/db/index.d.ts +6 -0
  78. package/dist/lib/template_manager/db/index.d.ts.map +1 -0
  79. package/dist/lib/template_manager/db/index.js +6 -0
  80. package/dist/lib/template_manager/db/index.js.map +1 -0
  81. package/dist/{template_manager → lib/template_manager}/db/template_repository.d.ts +25 -28
  82. package/dist/lib/template_manager/db/template_repository.d.ts.map +1 -0
  83. package/dist/lib/template_manager/db/template_repository.js +507 -0
  84. package/dist/lib/template_manager/db/template_repository.js.map +1 -0
  85. package/dist/lib/template_manager/engine/handlebars_engine.d.ts.map +1 -0
  86. package/dist/lib/template_manager/engine/handlebars_engine.js.map +1 -0
  87. package/dist/lib/template_manager/engine/index.d.ts.map +1 -0
  88. package/dist/lib/template_manager/engine/index.js.map +1 -0
  89. package/dist/{template_manager → lib/template_manager}/engine/variable_resolver.d.ts +13 -14
  90. package/dist/lib/template_manager/engine/variable_resolver.d.ts.map +1 -0
  91. package/dist/{template_manager → lib/template_manager}/engine/variable_resolver.js +25 -33
  92. package/dist/lib/template_manager/engine/variable_resolver.js.map +1 -0
  93. package/dist/lib/template_manager/index.d.ts +56 -0
  94. package/dist/lib/template_manager/index.d.ts.map +1 -0
  95. package/dist/lib/template_manager/index.js +68 -0
  96. package/dist/lib/template_manager/index.js.map +1 -0
  97. package/dist/lib/template_manager/init.d.ts +54 -0
  98. package/dist/lib/template_manager/init.d.ts.map +1 -0
  99. package/dist/lib/template_manager/init.js +85 -0
  100. package/dist/lib/template_manager/init.js.map +1 -0
  101. package/dist/lib/template_manager/registry.d.ts +23 -0
  102. package/dist/lib/template_manager/registry.d.ts.map +1 -0
  103. package/dist/lib/template_manager/registry.js +33 -0
  104. package/dist/lib/template_manager/registry.js.map +1 -0
  105. package/dist/lib/template_manager/seed/sync.d.ts +8 -0
  106. package/dist/lib/template_manager/seed/sync.d.ts.map +1 -0
  107. package/dist/lib/template_manager/seed/sync.js +77 -0
  108. package/dist/lib/template_manager/seed/sync.js.map +1 -0
  109. package/dist/{template_manager → lib/template_manager}/template_manager.d.ts +25 -27
  110. package/dist/lib/template_manager/template_manager.d.ts.map +1 -0
  111. package/dist/{template_manager → lib/template_manager}/template_manager.js +41 -55
  112. package/dist/lib/template_manager/template_manager.js.map +1 -0
  113. package/dist/{template_manager → lib/template_manager}/types.d.ts +32 -125
  114. package/dist/lib/template_manager/types.d.ts.map +1 -0
  115. package/dist/lib/template_manager/types.js +12 -0
  116. package/dist/lib/template_manager/types.js.map +1 -0
  117. package/dist/lib/template_manager/utils/index.d.ts.map +1 -0
  118. package/dist/lib/template_manager/utils/index.js.map +1 -0
  119. package/dist/lib/template_manager/utils/system_variables.d.ts.map +1 -0
  120. package/dist/lib/template_manager/utils/system_variables.js.map +1 -0
  121. package/dist/lib/template_manager/utils/validation.d.ts.map +1 -0
  122. package/dist/lib/template_manager/utils/validation.js.map +1 -0
  123. package/dist/lib/utils.d.ts +3 -0
  124. package/dist/lib/utils.d.ts.map +1 -0
  125. package/dist/lib/utils.js +6 -0
  126. package/dist/lib/utils.js.map +1 -0
  127. package/migrations/002_scope_migration.sql +93 -0
  128. package/package.json +57 -37
  129. package/dist/emailer/emailer.d.ts.map +0 -1
  130. package/dist/emailer/emailer.js.map +0 -1
  131. package/dist/emailer/index.d.ts.map +0 -1
  132. package/dist/emailer/index.js.map +0 -1
  133. package/dist/emailer/providers/index.d.ts.map +0 -1
  134. package/dist/emailer/providers/index.js.map +0 -1
  135. package/dist/emailer/providers/pop3_provider.d.ts.map +0 -1
  136. package/dist/emailer/providers/pop3_provider.js.map +0 -1
  137. package/dist/emailer/providers/smtp_provider.d.ts.map +0 -1
  138. package/dist/emailer/providers/smtp_provider.js.map +0 -1
  139. package/dist/emailer/providers/zeptomail_provider.d.ts.map +0 -1
  140. package/dist/emailer/providers/zeptomail_provider.js.map +0 -1
  141. package/dist/emailer/types.d.ts.map +0 -1
  142. package/dist/emailer/types.js.map +0 -1
  143. package/dist/emailer/utils/constants.d.ts.map +0 -1
  144. package/dist/emailer/utils/constants.js.map +0 -1
  145. package/dist/emailer/utils/index.d.ts.map +0 -1
  146. package/dist/emailer/utils/index.js.map +0 -1
  147. package/dist/emailer/utils/logger.d.ts.map +0 -1
  148. package/dist/emailer/utils/logger.js.map +0 -1
  149. package/dist/emailer/utils/validation.d.ts.map +0 -1
  150. package/dist/emailer/utils/validation.js.map +0 -1
  151. package/dist/index.d.ts.map +0 -1
  152. package/dist/index.js.map +0 -1
  153. package/dist/template_manager/config/config_loader.d.ts.map +0 -1
  154. package/dist/template_manager/config/config_loader.js +0 -154
  155. package/dist/template_manager/config/config_loader.js.map +0 -1
  156. package/dist/template_manager/config/constants.d.ts.map +0 -1
  157. package/dist/template_manager/config/constants.js.map +0 -1
  158. package/dist/template_manager/config/index.d.ts.map +0 -1
  159. package/dist/template_manager/config/index.js.map +0 -1
  160. package/dist/template_manager/db/category_repository.d.ts.map +0 -1
  161. package/dist/template_manager/db/category_repository.js.map +0 -1
  162. package/dist/template_manager/db/index.d.ts +0 -6
  163. package/dist/template_manager/db/index.d.ts.map +0 -1
  164. package/dist/template_manager/db/index.js +0 -6
  165. package/dist/template_manager/db/index.js.map +0 -1
  166. package/dist/template_manager/db/template_repository.d.ts.map +0 -1
  167. package/dist/template_manager/db/template_repository.js +0 -674
  168. package/dist/template_manager/db/template_repository.js.map +0 -1
  169. package/dist/template_manager/engine/handlebars_engine.d.ts.map +0 -1
  170. package/dist/template_manager/engine/handlebars_engine.js.map +0 -1
  171. package/dist/template_manager/engine/index.d.ts.map +0 -1
  172. package/dist/template_manager/engine/index.js.map +0 -1
  173. package/dist/template_manager/engine/variable_resolver.d.ts.map +0 -1
  174. package/dist/template_manager/engine/variable_resolver.js.map +0 -1
  175. package/dist/template_manager/index.d.ts +0 -32
  176. package/dist/template_manager/index.d.ts.map +0 -1
  177. package/dist/template_manager/index.js +0 -41
  178. package/dist/template_manager/index.js.map +0 -1
  179. package/dist/template_manager/template_manager.d.ts.map +0 -1
  180. package/dist/template_manager/template_manager.js.map +0 -1
  181. package/dist/template_manager/types.d.ts.map +0 -1
  182. package/dist/template_manager/types.js +0 -11
  183. package/dist/template_manager/types.js.map +0 -1
  184. package/dist/template_manager/utils/index.d.ts.map +0 -1
  185. package/dist/template_manager/utils/index.js.map +0 -1
  186. package/dist/template_manager/utils/system_variables.d.ts.map +0 -1
  187. package/dist/template_manager/utils/system_variables.js.map +0 -1
  188. package/dist/template_manager/utils/validation.d.ts.map +0 -1
  189. package/dist/template_manager/utils/validation.js.map +0 -1
  190. /package/dist/{emailer → lib/emailer}/emailer.d.ts +0 -0
  191. /package/dist/{emailer → lib/emailer}/emailer.js +0 -0
  192. /package/dist/{emailer → lib/emailer}/index.d.ts +0 -0
  193. /package/dist/{emailer → lib/emailer}/index.js +0 -0
  194. /package/dist/{emailer → lib/emailer}/providers/index.d.ts +0 -0
  195. /package/dist/{emailer → lib/emailer}/providers/index.js +0 -0
  196. /package/dist/{emailer → lib/emailer}/providers/pop3_provider.d.ts +0 -0
  197. /package/dist/{emailer → lib/emailer}/providers/pop3_provider.js +0 -0
  198. /package/dist/{emailer → lib/emailer}/providers/smtp_provider.d.ts +0 -0
  199. /package/dist/{emailer → lib/emailer}/providers/smtp_provider.js +0 -0
  200. /package/dist/{emailer → lib/emailer}/providers/zeptomail_provider.d.ts +0 -0
  201. /package/dist/{emailer → lib/emailer}/types.d.ts +0 -0
  202. /package/dist/{emailer → lib/emailer}/types.js +0 -0
  203. /package/dist/{emailer → lib/emailer}/utils/constants.d.ts +0 -0
  204. /package/dist/{emailer → lib/emailer}/utils/constants.js +0 -0
  205. /package/dist/{emailer → lib/emailer}/utils/index.d.ts +0 -0
  206. /package/dist/{emailer → lib/emailer}/utils/index.js +0 -0
  207. /package/dist/{emailer → lib/emailer}/utils/logger.d.ts +0 -0
  208. /package/dist/{emailer → lib/emailer}/utils/logger.js +0 -0
  209. /package/dist/{emailer → lib/emailer}/utils/validation.d.ts +0 -0
  210. /package/dist/{emailer → lib/emailer}/utils/validation.js +0 -0
  211. /package/dist/{index.d.ts → lib/index.d.ts} +0 -0
  212. /package/dist/{index.js → lib/index.js} +0 -0
  213. /package/dist/{template_manager → lib/template_manager}/config/index.d.ts +0 -0
  214. /package/dist/{template_manager → lib/template_manager}/config/index.js +0 -0
  215. /package/dist/{template_manager → lib/template_manager}/engine/handlebars_engine.d.ts +0 -0
  216. /package/dist/{template_manager → lib/template_manager}/engine/handlebars_engine.js +0 -0
  217. /package/dist/{template_manager → lib/template_manager}/engine/index.d.ts +0 -0
  218. /package/dist/{template_manager → lib/template_manager}/engine/index.js +0 -0
  219. /package/dist/{template_manager → lib/template_manager}/utils/index.d.ts +0 -0
  220. /package/dist/{template_manager → lib/template_manager}/utils/index.js +0 -0
  221. /package/dist/{template_manager → lib/template_manager}/utils/system_variables.d.ts +0 -0
  222. /package/dist/{template_manager → lib/template_manager}/utils/system_variables.js +0 -0
  223. /package/dist/{template_manager → lib/template_manager}/utils/validation.d.ts +0 -0
  224. /package/dist/{template_manager → lib/template_manager}/utils/validation.js +0 -0
@@ -1,16 +1,16 @@
1
1
  /**
2
- * Variable resolver for template manager
2
+ * Variable resolver for template manager (v2.0.0)
3
3
  *
4
- * Resolves user variables, system variables, and @template references
4
+ * Resolves user variables, system variables, and @template references.
5
+ * Uses scope_chain (hierarchical scope resolution) instead of org_id.
5
6
  */
6
7
  import { TEMPLATE_REFERENCE_PATTERN, MAX_TEMPLATE_REFERENCE_DEPTH, ERROR_MESSAGES, } from '../config/constants.js';
7
8
  import { resolve_system_variables } from '../utils/system_variables.js';
8
9
  import { get_template_by_name } from '../db/template_repository.js';
9
10
  import { render_handlebars_string } from './handlebars_engine.js';
10
11
  /**
11
- * Merge user variables with system variables
12
- *
13
- * System variables take lower priority than user variables
12
+ * Merge user variables with system variables.
13
+ * System variables take lower priority than user variables.
14
14
  *
15
15
  * @param user_variables - Variables provided by user
16
16
  * @returns Merged variables with system variables
@@ -23,7 +23,7 @@ export function resolve_variables(user_variables) {
23
23
  };
24
24
  }
25
25
  /**
26
- * Extract @template references from content
26
+ * Extract @template references from content.
27
27
  *
28
28
  * @param content - Template content to scan
29
29
  * @returns Array of template names referenced
@@ -42,21 +42,19 @@ export function extract_template_references(content) {
42
42
  return Array.from(references);
43
43
  }
44
44
  /**
45
- * Resolve @template references in content
46
- *
47
- * Recursively fetches and renders referenced templates
45
+ * Resolve @template references in HTML content.
46
+ * Recursively fetches and renders referenced templates using the scope_chain.
48
47
  *
49
48
  * @param content - Template content with @references
50
49
  * @param variables - Variables to use for rendering
51
50
  * @param hazo_connect - Database connection
52
- * @param org_id - Organization ID
51
+ * @param scope_chain - Ordered scope chain, deepest first (see get_template_by_name)
53
52
  * @param visited - Set of already visited templates (for circular detection)
54
53
  * @param depth - Current recursion depth
55
54
  * @returns Resolved content with references replaced
56
55
  */
57
- export async function resolve_template_references(content, variables, hazo_connect, org_id, visited = new Set(), depth = 0) {
56
+ export async function resolve_template_references(content, variables, hazo_connect, scope_chain, visited = new Set(), depth = 0) {
58
57
  try {
59
- // Check max depth
60
58
  if (depth > MAX_TEMPLATE_REFERENCE_DEPTH) {
61
59
  return {
62
60
  success: false,
@@ -74,7 +72,6 @@ export async function resolve_template_references(content, variables, hazo_conne
74
72
  }
75
73
  let resolved_content = content;
76
74
  for (const ref_name of references) {
77
- // Check for circular reference
78
75
  if (visited.has(ref_name)) {
79
76
  return {
80
77
  success: false,
@@ -82,22 +79,18 @@ export async function resolve_template_references(content, variables, hazo_conne
82
79
  message: `Circular reference detected: ${ref_name}`,
83
80
  };
84
81
  }
85
- // Fetch the referenced template
86
- const template_result = await get_template_by_name(hazo_connect, org_id, ref_name);
82
+ const template_result = await get_template_by_name(hazo_connect, scope_chain, ref_name);
87
83
  if (!template_result.success || !template_result.data) {
88
- // Template not found, leave reference as-is
84
+ // Template not found leave reference as-is
89
85
  continue;
90
86
  }
91
87
  const template = template_result.data;
92
88
  visited.add(ref_name);
93
- // Recursively resolve any references in the fetched template
94
- const nested_result = await resolve_template_references(template.template_html, variables, hazo_connect, org_id, new Set(visited), depth + 1);
89
+ const nested_result = await resolve_template_references(template.template_html, variables, hazo_connect, scope_chain, new Set(visited), depth + 1);
95
90
  if (!nested_result.success) {
96
91
  return nested_result;
97
92
  }
98
- // Render the fetched template with variables
99
93
  const rendered_ref = render_handlebars_string(nested_result.rendered_html || template.template_html, variables);
100
- // Replace the @reference with rendered content
101
94
  const ref_pattern = new RegExp(`@${ref_name}\\b`, 'g');
102
95
  resolved_content = resolved_content.replace(ref_pattern, rendered_ref);
103
96
  }
@@ -117,24 +110,24 @@ export async function resolve_template_references(content, variables, hazo_conne
117
110
  }
118
111
  }
119
112
  /**
120
- * Resolve @template references for both HTML and text content
113
+ * Resolve @template references for both HTML and text content.
121
114
  *
122
115
  * @param html_content - HTML template content
123
116
  * @param text_content - Text template content
124
117
  * @param variables - Variables for rendering
125
118
  * @param hazo_connect - Database connection
126
- * @param org_id - Organization ID
119
+ * @param scope_chain - Ordered scope chain, deepest first
127
120
  * @returns Resolved HTML and text content
128
121
  */
129
- export async function resolve_all_template_references(html_content, text_content, variables, hazo_connect, org_id) {
122
+ export async function resolve_all_template_references(html_content, text_content, variables, hazo_connect, scope_chain) {
130
123
  try {
131
- // Resolve HTML references
132
- const html_result = await resolve_template_references(html_content, variables, hazo_connect, org_id);
124
+ const [html_result, text_result] = await Promise.all([
125
+ resolve_template_references(html_content, variables, hazo_connect, scope_chain),
126
+ resolve_text_template_references(text_content, variables, hazo_connect, scope_chain),
127
+ ]);
133
128
  if (!html_result.success) {
134
129
  return html_result;
135
130
  }
136
- // Resolve text references (fetch text version of templates)
137
- const text_result = await resolve_text_template_references(text_content, variables, hazo_connect, org_id);
138
131
  if (!text_result.success) {
139
132
  return text_result;
140
133
  }
@@ -155,10 +148,10 @@ export async function resolve_all_template_references(html_content, text_content
155
148
  }
156
149
  }
157
150
  /**
158
- * Resolve @template references in text content
159
- * Uses template_text instead of template_html
151
+ * Resolve @template references in text content.
152
+ * Uses template_text instead of template_html.
160
153
  */
161
- async function resolve_text_template_references(content, variables, hazo_connect, org_id, visited = new Set(), depth = 0) {
154
+ async function resolve_text_template_references(content, variables, hazo_connect, scope_chain, visited = new Set(), depth = 0) {
162
155
  try {
163
156
  if (depth > MAX_TEMPLATE_REFERENCE_DEPTH) {
164
157
  return {
@@ -184,14 +177,13 @@ async function resolve_text_template_references(content, variables, hazo_connect
184
177
  message: `Circular reference detected: ${ref_name}`,
185
178
  };
186
179
  }
187
- const template_result = await get_template_by_name(hazo_connect, org_id, ref_name);
180
+ const template_result = await get_template_by_name(hazo_connect, scope_chain, ref_name);
188
181
  if (!template_result.success || !template_result.data) {
189
182
  continue;
190
183
  }
191
184
  const template = template_result.data;
192
185
  visited.add(ref_name);
193
- // Recursively resolve text template references
194
- const nested_result = await resolve_text_template_references(template.template_text, variables, hazo_connect, org_id, new Set(visited), depth + 1);
186
+ const nested_result = await resolve_text_template_references(template.template_text, variables, hazo_connect, scope_chain, new Set(visited), depth + 1);
195
187
  if (!nested_result.success) {
196
188
  return nested_result;
197
189
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variable_resolver.js","sourceRoot":"","sources":["../../../../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ager Module (v2.0.0)
3
+ *
4
+ * Email template management with Handlebars rendering and database storage.
5
+ * Uses scope_id for hierarchical template resolution (org hierarchy, tenant hierarchy, etc.).
6
+ *
7
+ * Usage:
8
+ * ```typescript
9
+ * import {
10
+ * send_template_email,
11
+ * register_template_type,
12
+ * set_scope_resolver,
13
+ * } from 'hazo_notify/template_manager';
14
+ * import { createHazoConnect } from 'hazo_connect/server';
15
+ *
16
+ * const hazo = createHazoConnect({ type: 'sqlite', sqlite: { database_path: './db.sqlite' } });
17
+ *
18
+ * // Register template types at boot (replaces seed_default_templates)
19
+ * register_template_type({
20
+ * template_name: 'welcome_email',
21
+ * template_label: 'Welcome Email',
22
+ * variables: [
23
+ * { variable_name: 'user_name', variable_description: "Recipient's full name" },
24
+ * { variable_name: 'login_url', variable_description: 'URL to login page' },
25
+ * ],
26
+ * });
27
+ *
28
+ * // Wire a scope resolver (optional — flat lookup if omitted)
29
+ * set_scope_resolver(async (scope_id) => {
30
+ * // Return ancestor scope IDs, nearest-to-root order
31
+ * return db.getAncestors(scope_id);
32
+ * });
33
+ *
34
+ * // Send a templated email
35
+ * const result = await send_template_email({
36
+ * template_name: 'welcome_email',
37
+ * variables: { user_name: 'John', login_url: 'https://example.com/login' },
38
+ * to: 'john@example.com',
39
+ * scope_id: 'tenant-uuid-here',
40
+ * subject: 'Welcome!',
41
+ * }, hazo);
42
+ * ```
43
+ */
44
+ export { send_template_email, render_template, preview_template, validate_template_variables, } from './template_manager.js';
45
+ export { load_template_config, get_template_variables, get_all_variable_names, clear_config_cache, } from './config/config_loader.js';
46
+ export { register_template_type, get_registered_template_types, get_registered_template_type, } from './registry.js';
47
+ export { get_scope_chain, invalidate_scope_chain, set_scope_resolver, } from './cache/scope_chain_cache.js';
48
+ export { list_categories, get_category, create_category, update_category, delete_category, find_category_by_name_in_chain, list_templates, list_templates_by_category, get_template, get_template_by_name, create_template, update_template, delete_template, } from './db/index.js';
49
+ export { render_handlebars, render_handlebars_string, clear_template_cache, invalidate_template_cache, resolve_variables, extract_template_references, resolve_template_references, resolve_all_template_references, } from './engine/index.js';
50
+ export { get_system_variables, resolve_system_variables, get_system_variable_definitions, validate_template_name, validate_category_name, validate_variable_name, extract_variables_from_content, validate_provided_variables, } from './utils/index.js';
51
+ export { TABLE_TEMPLATE_CATEGORY, TABLE_TEMPLATES, DEFAULT_CATEGORY_NAMES, MAX_TEMPLATE_NAME_LENGTH, MAX_CATEGORY_NAME_LENGTH, VARIABLE_PATTERN, TEMPLATE_REFERENCE_PATTERN, ERROR_MESSAGES, } from './config/constants.js';
52
+ export { sync_system_templates } from './seed/sync.js';
53
+ export { init_template_manager, verify_notify_setup, } from './init.js';
54
+ export type { InitTemplateManagerOptions } from './init.js';
55
+ export type { TemplateVariableDefinition, TemplateTypeDefinition, SystemVariable, TemplateManagerConfig, SystemTemplateManifest, TemplateCategory, TemplateCategoryInput, TemplateCategoryUpdate, EmailTemplate, EmailTemplateInput, EmailTemplateUpdate, HazoConnectInstance, HazoConnectQueryBuilder, TemplateRenderResult, TemplateOperationResponse, TemplateEmailAttachment, SendTemplateEmailOptions, SendTemplateEmailResponse, CategoryTreeItem, VariableItem, TemplateReferenceItem, Logger, } from './types.js';
56
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/template_manager/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAGH,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,2BAA2B,GAC5B,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EACL,sBAAsB,EACtB,6BAA6B,EAC7B,4BAA4B,GAC7B,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,eAAe,EACf,sBAAs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1,68 @@
1
+ /**
2
+ * Template Manager Module (v2.0.0)
3
+ *
4
+ * Email template management with Handlebars rendering and database storage.
5
+ * Uses scope_id for hierarchical template resolution (org hierarchy, tenant hierarchy, etc.).
6
+ *
7
+ * Usage:
8
+ * ```typescript
9
+ * import {
10
+ * send_template_email,
11
+ * register_template_type,
12
+ * set_scope_resolver,
13
+ * } from 'hazo_notify/template_manager';
14
+ * import { createHazoConnect } from 'hazo_connect/server';
15
+ *
16
+ * const hazo = createHazoConnect({ type: 'sqlite', sqlite: { database_path: './db.sqlite' } });
17
+ *
18
+ * // Register template types at boot (replaces seed_default_templates)
19
+ * register_template_type({
20
+ * template_name: 'welcome_email',
21
+ * template_label: 'Welcome Email',
22
+ * variables: [
23
+ * { variable_name: 'user_name', variable_description: "Recipient's full name" },
24
+ * { variable_name: 'login_url', variable_description: 'URL to login page' },
25
+ * ],
26
+ * });
27
+ *
28
+ * // Wire a scope resolver (optional — flat lookup if omitted)
29
+ * set_scope_resolver(async (scope_id) => {
30
+ * // Return ancestor scope IDs, nearest-to-root order
31
+ * return db.getAncestors(scope_id);
32
+ * });
33
+ *
34
+ * // Send a templated email
35
+ * const result = await send_template_email({
36
+ * template_name: 'welcome_email',
37
+ * variables: { user_name: 'John', login_url: 'https://example.com/login' },
38
+ * to: 'john@example.com',
39
+ * scope_id: 'tenant-uuid-here',
40
+ * subject: 'Welcome!',
41
+ * }, hazo);
42
+ * ```
43
+ */
44
+ // Core functions
45
+ export { send_template_email, render_template, preview_template, validate_template_variables, } from './template_manager.js';
46
+ // Config
47
+ export { load_template_config, get_template_variables, get_all_variable_names, clear_config_cache, } from './config/config_loader.js';
48
+ // Registry
49
+ export { register_template_type, get_registered_template_types, get_registered_template_type, } from './registry.js';
50
+ // Scope chain cache
51
+ export { get_scope_chain, invalidate_scope_chain, set_scope_resolver, } from './cache/scope_chain_cache.js';
52
+ // Database operations
53
+ export {
54
+ // Categories
55
+ list_categories, get_category, create_category, update_category, delete_category, find_category_by_name_in_chain,
56
+ // Templates
57
+ list_templates, list_templates_by_category, get_template, get_template_by_name, create_template, update_template, delete_template, } from './db/index.js';
58
+ // Engine
59
+ export { render_handlebars, render_handlebars_string, clear_template_cache, invalidate_template_cache, resolve_variables, extract_template_references, resolve_template_references, resolve_all_template_references, } from './engine/index.js';
60
+ // Utils
61
+ export { get_system_variables, resolve_system_variables, get_system_variable_definitions, validate_template_name, validate_category_name, validate_variable_name, extract_variables_from_content, validate_provided_variables, } from './utils/index.js';
62
+ // Constants
63
+ export { TABLE_TEMPLATE_CATEGORY, TABLE_TEMPLATES, DEFAULT_CATEGORY_NAMES, MAX_TEMPLATE_NAME_LENGTH, MAX_CATEGORY_NAME_LENGTH, VARIABLE_PATTERN, TEMPLATE_REFERENCE_PATTERN, ERROR_MESSAGES, } from './config/constants.js';
64
+ // Seed
65
+ export { sync_system_templates } from './seed/sync.js';
66
+ // Init
67
+ export { init_template_manager, verify_notify_setup, } from './init.js';
68
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/template_manager/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAEH,iBAAiB;AACjB,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,2BAA2B,GAC5B,MAAM,uBAAuB,CAAC;AAE/B,SAAS;AACT,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,2BAA2B,CAAC;AAEnC,WAAW;AACX,OAAO,EACL,sBAAsB,EACtB,6BAA6B,EAC7B,4BAA4B,GAC7B,MAAM,eAAe,CAAC;AAEvB,oBAAoB;AACpB,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,8BAA8B,CAAC;AAEtC,sBAAsB;AACtB,OAAO;AACL,aAAa;AACb,eAAe,EACf,YAAY,EACZ,eAAe,EACf,eAAe,EACf,eAAe,EACf,8BAA8B;AAC9B,YAAY;AACZ,cAAc,EACd,0BAA0B,EAC1B,YAAY,EACZ,oBAAoB,EACpB,eAAe,EACf,eAAe,EACf,eAAe,GAChB,MAAM,eAAe,CAAC;AAEvB,SAAS;AACT,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EACxB,oBAAoB,EACpB,yBAAyB,EACzB,iBAAiB,EACjB,2BAA2B,EAC3B,2BAA2B,EAC3B,+BAA+B,GAChC,MAAM,mBAAmB,CAAC;AAE3B,QAAQ;AACR,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACxB,+BAA+B,EAC/B,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,EACtB,8BAA8B,EAC9B,2BAA2B,GAC5B,MAAM,kBAAkB,CAAC;AAE1B,YAAY;AACZ,OAAO,EACL,uBAAuB,EACvB,eAAe,EACf,sBAAsB,EACtB,wBAAwB,EACxB,wBAAwB,EACxB,gBAAgB,EAChB,0BAA0B,EAC1B,cAAc,GACf,MAAM,uBAAuB,CAAC;AAE/B,OAAO;AACP,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO;AACP,OAAO,EACL,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,WAAW,CAAC"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Boot helper for the template manager (v2.0.0)
3
+ *
4
+ * Consumers call init_template_manager() once at application startup to:
5
+ * - Obtain a hazo_connect instance via the provided factory
6
+ * - Wire an optional scope resolver into the scope chain cache
7
+ * - Seed/sync system templates from provided manifests
8
+ *
9
+ * verify_notify_setup() can be called after init to confirm the required
10
+ * database tables are present and queryable.
11
+ */
12
+ import type { HazoConnectInstance, SystemTemplateManifest } from './types.js';
13
+ export interface InitTemplateManagerOptions {
14
+ /** Factory that returns (or resolves to) a hazo_connect instance. */
15
+ hazo_connect_factory: () => Promise<HazoConnectInstance> | HazoConnectInstance;
16
+ /**
17
+ * Optional scope resolver. Receives a scope_id and must return the ancestor
18
+ * chain (nearest-to-root order), NOT including scope_id itself.
19
+ * Omit for flat (single-scope) lookup mode.
20
+ */
21
+ scope_resolver?: (scope_id: string) => Promise<string[]>;
22
+ /** System template manifests to seed/sync on startup. */
23
+ manifests?: SystemTemplateManifest[];
24
+ }
25
+ /**
26
+ * Wire up the template manager at application startup.
27
+ *
28
+ * @param options - Factory, optional scope resolver, and optional manifests.
29
+ * @returns The resolved hazo_connect instance plus sync result counts.
30
+ */
31
+ export declare function init_template_manager(options: InitTemplateManagerOptions): Promise<{
32
+ hazo_connect: HazoConnectInstance;
33
+ synced: number;
34
+ updated: number;
35
+ skipped: number;
36
+ errors: string[];
37
+ }>;
38
+ /**
39
+ * Verify that the required hazo_notify tables exist and are queryable.
40
+ *
41
+ * Performs a lightweight list (limit 1) against both tables. Returns
42
+ * ok:true only when both succeed.
43
+ *
44
+ * @param hazo_connect - An already-initialised hazo_connect instance.
45
+ */
46
+ export declare function verify_notify_setup(hazo_connect: HazoConnectInstance): Promise<{
47
+ ok: boolean;
48
+ tables: {
49
+ categories: boolean;
50
+ templates: boolean;
51
+ };
52
+ error?: string;
53
+ }>;
54
+ //# sourceMappingURL=init.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/lib/template_manager/init.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAS9E,MAAM,WAAW,0BAA0B;IACzC,qEAAqE;IACrE,oBAAoB,EAAE,MAAM,OAAO,CAAC,mBAAmB,CAAC,GAAG,mBAAmB,CAAC;IAC/E;;;;OAIG;IACH,cAAc,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACzD,yDAAyD;IACzD,SAAS,CAAC,EAAE,sBAAsB,EAAE,CAAC;CACtC;AAMD;;;;;GAKG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC;IACT,YAAY,EAAE,mBAAmB,CAAC;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC,CAuBD;AAMD;;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CACvC,YAAY,EAAE,mBAAmB,GAChC,OAAO,CAAC;IACT,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE;QAAE,UAAU,EAAE,OAAO,CAAC;QAAC,SAAS,EAAE,OAAO,CAAA;KAAE,CAAC;IACpD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC,CAkCD"}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Boot helper for the template manager (v2.0.0)
3
+ *
4
+ * Consumers call init_template_manager() once at application startup to:
5
+ * - Obtain a hazo_connect instance via the provided factory
6
+ * - Wire an optional scope resolver into the scope chain cache
7
+ * - Seed/sync system templates from provided manifests
8
+ *
9
+ * verify_notify_setup() can be called after init to confirm the required
10
+ * database tables are present and queryable.
11
+ */
12
+ import { set_scope_resolver } from './cache/scope_chain_cache.js';
13
+ import { sync_system_templates } from './seed/sync.js';
14
+ import { TABLE_TEMPLATE_CATEGORY, TABLE_TEMPLATES } from './config/constants.js';
15
+ // ============================================================
16
+ // init_template_manager
17
+ // ============================================================
18
+ /**
19
+ * Wire up the template manager at application startup.
20
+ *
21
+ * @param options - Factory, optional scope resolver, and optional manifests.
22
+ * @returns The resolved hazo_connect instance plus sync result counts.
23
+ */
24
+ export async function init_template_manager(options) {
25
+ // 1. Resolve hazo_connect (factory may be sync or async)
26
+ const hazo_connect = await options.hazo_connect_factory();
27
+ // 2. Wire scope resolver if provided
28
+ if (options.scope_resolver) {
29
+ set_scope_resolver(options.scope_resolver);
30
+ }
31
+ // 3. Sync manifests if provided and non-empty
32
+ if (options.manifests && options.manifests.length > 0) {
33
+ const result = await sync_system_templates(hazo_connect, options.manifests);
34
+ return {
35
+ hazo_connect,
36
+ synced: result.synced,
37
+ updated: result.updated,
38
+ skipped: result.skipped,
39
+ errors: result.errors,
40
+ };
41
+ }
42
+ // No manifests — return zero counts
43
+ return { hazo_connect, synced: 0, updated: 0, skipped: 0, errors: [] };
44
+ }
45
+ // ============================================================
46
+ // verify_notify_setup
47
+ // ============================================================
48
+ /**
49
+ * Verify that the required hazo_notify tables exist and are queryable.
50
+ *
51
+ * Performs a lightweight list (limit 1) against both tables. Returns
52
+ * ok:true only when both succeed.
53
+ *
54
+ * @param hazo_connect - An already-initialised hazo_connect instance.
55
+ */
56
+ export async function verify_notify_setup(hazo_connect) {
57
+ let categories = false;
58
+ let templates = false;
59
+ const error_messages = [];
60
+ // Check categories table
61
+ try {
62
+ await hazo_connect.list(hazo_connect.query().from(TABLE_TEMPLATE_CATEGORY).select('*').limit(1));
63
+ categories = true;
64
+ }
65
+ catch (err) {
66
+ const msg = err instanceof Error ? err.message : String(err);
67
+ error_messages.push(`categories: ${msg}`);
68
+ }
69
+ // Check templates table
70
+ try {
71
+ await hazo_connect.list(hazo_connect.query().from(TABLE_TEMPLATES).select('*').limit(1));
72
+ templates = true;
73
+ }
74
+ catch (err) {
75
+ const msg = err instanceof Error ? err.message : String(err);
76
+ error_messages.push(`templates: ${msg}`);
77
+ }
78
+ const ok = categories && templates;
79
+ return {
80
+ ok,
81
+ tables: { categories, templates },
82
+ ...(error_messages.length > 0 ? { error: error_messages.join('; ') } : {}),
83
+ };
84
+ }
85
+ //# sourceMappingURL=init.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/lib/template_manager/init.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM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server-only: do not import in client bundles.
5
+ *
6
+ * Consuming packages register their TemplateTypeDefinition entries here at
7
+ * boot time. First-wins semantics prevent accidental double-registration.
8
+ */
9
+ import type { TemplateTypeDefinition } from './types.js';
10
+ /**
11
+ * Register a template type. First-wins: if already registered, logs a warning
12
+ * and skips. Call this once per template type at application boot time.
13
+ */
14
+ export declare function register_template_type(def: TemplateTypeDefinition): void;
15
+ /**
16
+ * Returns all registered template type definitions.
17
+ */
18
+ export declare function get_registered_template_types(): TemplateTypeDefinition[];
19
+ /**
20
+ * Get a single registered type by template_name, or undefined if not found.
21
+ */
22
+ export declare function get_registered_template_type(template_name: string): TemplateTypeDefinition | undefined;
23
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/lib/template_manager/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAIzD;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,sBAAsB,GAAG,IAAI,CAQxE;AAED;;GAEG;AACH,wBAAgB,6BAA6B,IAAI,sBAAsB,EAAE,CAExE;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAC1C,aAAa,EAAE,MAAM,GACpB,sBAAsB,GAAG,SAAS,CAEpC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Template type registry for template manager (v2.0.0)
3
+ *
4
+ * server-only: do not import in client bundles.
5
+ *
6
+ * Consuming packages register their TemplateTypeDefinition entries here at
7
+ * boot time. First-wins semantics prevent accidental double-registration.
8
+ */
9
+ const registry = new Map();
10
+ /**
11
+ * Register a template type. First-wins: if already registered, logs a warning
12
+ * and skips. Call this once per template type at application boot time.
13
+ */
14
+ export function register_template_type(def) {
15
+ if (registry.has(def.template_name)) {
16
+ console.warn(`[hazo_notify] template type '${def.template_name}' already registered; first registration wins`);
17
+ return;
18
+ }
19
+ registry.set(def.template_name, def);
20
+ }
21
+ /**
22
+ * Returns all registered template type definitions.
23
+ */
24
+ export function get_registered_template_types() {
25
+ return Array.from(registry.values());
26
+ }
27
+ /**
28
+ * Get a single registered type by template_name, or undefined if not found.
29
+ */
30
+ export function get_registered_template_type(template_name) {
31
+ return registry.get(template_name);
32
+ }
33
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../src/lib/template_manager/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAkC,CAAC;AAE3D;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAC,GAA2B;IAChE,IAAI,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC;QACpC,OAAO,CAAC,IAAI,CACV,gCAAgC,GAAG,CAAC,aAAa,+CAA+C,CACjG,CAAC;QACF,OAAO;IACT,CAAC;IACD,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC;AACvC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,6BAA6B;IAC3C,OAAO,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;AACvC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,4BAA4B,CAC1C,aAAqB;IAErB,OAAO,QAAQ,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;AACrC,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { HazoConnectInstance, SystemTemplateManifest } from '../types.js';
2
+ export declare function sync_system_templates(hazo_connect: HazoConnectInstance, manifests: SystemTemplateManifest[]): Promise<{
3
+ synced: number;
4
+ updated: number;
5
+ skipped: number;
6
+ errors: string[];
7
+ }>;
8
+ //# sourceMappingURL=sync.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../../../src/lib/template_manager/seed/sync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,sBAAsB,EAGvB,MAAM,aAAa,CAAC;AAOrB,wBAAsB,qBAAqB,CACzC,YAAY,EAAE,mBAAmB,EACjC,SAAS,EAAE,sBAAsB,EAAE,GAClC,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAuFjF"}
@@ -0,0 +1,77 @@
1
+ import { TABLE_TEMPLATES, TABLE_TEMPLATE_CATEGORY, ERROR_MESSAGES, } from '../config/constants.js';
2
+ export async function sync_system_templates(hazo_connect, manifests) {
3
+ if (!hazo_connect) {
4
+ throw new Error(ERROR_MESSAGES.DB_CONNECTION_REQUIRED);
5
+ }
6
+ let synced = 0;
7
+ let updated = 0;
8
+ let skipped = 0;
9
+ const errors = [];
10
+ for (const manifest of manifests) {
11
+ try {
12
+ // 1. Find or create the global category by name
13
+ const cat_q = hazo_connect
14
+ .query()
15
+ .from(TABLE_TEMPLATE_CATEGORY)
16
+ .select('*')
17
+ .where('template_category_name', 'eq', manifest.category)
18
+ .where('scope_id', 'is', null);
19
+ const cat_rows = await hazo_connect.list(cat_q);
20
+ let category;
21
+ if (cat_rows.length === 0) {
22
+ category = await hazo_connect.insert(TABLE_TEMPLATE_CATEGORY, {
23
+ scope_id: null,
24
+ template_category_name: manifest.category,
25
+ });
26
+ }
27
+ else {
28
+ category = cat_rows[0];
29
+ }
30
+ // 2. Look up the global template by name
31
+ const tpl_q = hazo_connect
32
+ .query()
33
+ .from(TABLE_TEMPLATES)
34
+ .select('*')
35
+ .where('template_name', 'eq', manifest.template_name)
36
+ .where('scope_id', 'is', null);
37
+ const tpl_rows = await hazo_connect.list(tpl_q);
38
+ if (tpl_rows.length === 0) {
39
+ // 3a. NOT found — insert new global template
40
+ await hazo_connect.insert(TABLE_TEMPLATES, {
41
+ scope_id: null,
42
+ template_category_id: category.id,
43
+ template_name: manifest.template_name,
44
+ template_html: manifest.html,
45
+ template_text: manifest.text,
46
+ template_variables: manifest.variables,
47
+ is_modified: false,
48
+ });
49
+ synced++;
50
+ }
51
+ else {
52
+ const existing = tpl_rows[0];
53
+ if (existing.is_modified) {
54
+ // 3c. User has customized this template — leave it alone
55
+ skipped++;
56
+ }
57
+ else {
58
+ // 3b. Found and unmodified — update content
59
+ await hazo_connect.updateById(TABLE_TEMPLATES, existing.id, {
60
+ template_html: manifest.html,
61
+ template_text: manifest.text,
62
+ template_variables: manifest.variables,
63
+ template_category_id: category.id,
64
+ changed_at: new Date().toISOString(),
65
+ });
66
+ updated++;
67
+ }
68
+ }
69
+ }
70
+ catch (error) {
71
+ const msg = error instanceof Error ? error.message : String(error);
72
+ errors.push(`${manifest.template_name}: ${msg}`);
73
+ }
74
+ }
75
+ return { synced, updated, skipped, errors };
76
+ }
77
+ //# sourceMappingURL=sync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync.js","sourceRoot":"","sources":["../../../../src/lib/template_manager/seed/sync.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,eAAe,EACf,uBAAuB,EACvB,cAAc,GACf,MAAM,wBAAwB,CAAC;AAEhC,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,YAAiC,EACjC,SAAmC;IAEnC,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,cAAc,CAAC,sBAAsB,CAAC,CAAC;IACzD,CAAC;IAED,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,MAAM,MAAM,GAAa,EAAE,CAAC;IAE5B,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,IAAI,CAAC;YACH,gDAAgD;YAChD,MAAM,KAAK,GAAG,YAAY;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