hazo_notify 1.1.4 → 3.1.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 (236) hide show
  1. package/README.md +163 -41
  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/handlers/adapters/hazo_auth.d.ts +20 -0
  94. package/dist/lib/template_manager/handlers/adapters/hazo_auth.d.ts.map +1 -0
  95. package/dist/lib/template_manager/handlers/adapters/hazo_auth.js +46 -0
  96. package/dist/lib/template_manager/handlers/adapters/hazo_auth.js.map +1 -0
  97. package/dist/lib/template_manager/handlers/auth.d.ts +47 -0
  98. package/dist/lib/template_manager/handlers/auth.d.ts.map +1 -0
  99. package/dist/lib/template_manager/handlers/auth.js +67 -0
  100. package/dist/lib/template_manager/handlers/auth.js.map +1 -0
  101. package/dist/lib/template_manager/handlers/index.d.ts +67 -0
  102. package/dist/lib/template_manager/handlers/index.d.ts.map +1 -0
  103. package/dist/lib/template_manager/handlers/index.js +284 -0
  104. package/dist/lib/template_manager/handlers/index.js.map +1 -0
  105. package/dist/lib/template_manager/index.d.ts +56 -0
  106. package/dist/lib/template_manager/index.d.ts.map +1 -0
  107. package/dist/lib/template_manager/index.js +68 -0
  108. package/dist/lib/template_manager/index.js.map +1 -0
  109. package/dist/lib/template_manager/init.d.ts +54 -0
  110. package/dist/lib/template_manager/init.d.ts.map +1 -0
  111. package/dist/lib/template_manager/init.js +85 -0
  112. package/dist/lib/template_manager/init.js.map +1 -0
  113. package/dist/lib/template_manager/registry.d.ts +23 -0
  114. package/dist/lib/template_manager/registry.d.ts.map +1 -0
  115. package/dist/lib/template_manager/registry.js +33 -0
  116. package/dist/lib/template_manager/registry.js.map +1 -0
  117. package/dist/lib/template_manager/seed/sync.d.ts +8 -0
  118. package/dist/lib/template_manager/seed/sync.d.ts.map +1 -0
  119. package/dist/lib/template_manager/seed/sync.js +77 -0
  120. package/dist/lib/template_manager/seed/sync.js.map +1 -0
  121. package/dist/{template_manager → lib/template_manager}/template_manager.d.ts +25 -27
  122. package/dist/lib/template_manager/template_manager.d.ts.map +1 -0
  123. package/dist/{template_manager → lib/template_manager}/template_manager.js +41 -55
  124. package/dist/lib/template_manager/template_manager.js.map +1 -0
  125. package/dist/{template_manager → lib/template_manager}/types.d.ts +32 -125
  126. package/dist/lib/template_manager/types.d.ts.map +1 -0
  127. package/dist/lib/template_manager/types.js +12 -0
  128. package/dist/lib/template_manager/types.js.map +1 -0
  129. package/dist/lib/template_manager/utils/index.d.ts.map +1 -0
  130. package/dist/lib/template_manager/utils/index.js.map +1 -0
  131. package/dist/lib/template_manager/utils/system_variables.d.ts.map +1 -0
  132. package/dist/lib/template_manager/utils/system_variables.js.map +1 -0
  133. package/dist/lib/template_manager/utils/validation.d.ts.map +1 -0
  134. package/dist/lib/template_manager/utils/validation.js.map +1 -0
  135. package/dist/lib/utils.d.ts +3 -0
  136. package/dist/lib/utils.d.ts.map +1 -0
  137. package/dist/lib/utils.js +6 -0
  138. package/dist/lib/utils.js.map +1 -0
  139. package/migrations/002_scope_migration.sql +93 -0
  140. package/package.json +65 -37
  141. package/dist/emailer/emailer.d.ts.map +0 -1
  142. package/dist/emailer/emailer.js.map +0 -1
  143. package/dist/emailer/index.d.ts.map +0 -1
  144. package/dist/emailer/index.js.map +0 -1
  145. package/dist/emailer/providers/index.d.ts.map +0 -1
  146. package/dist/emailer/providers/index.js.map +0 -1
  147. package/dist/emailer/providers/pop3_provider.d.ts.map +0 -1
  148. package/dist/emailer/providers/pop3_provider.js.map +0 -1
  149. package/dist/emailer/providers/smtp_provider.d.ts.map +0 -1
  150. package/dist/emailer/providers/smtp_provider.js.map +0 -1
  151. package/dist/emailer/providers/zeptomail_provider.d.ts.map +0 -1
  152. package/dist/emailer/providers/zeptomail_provider.js.map +0 -1
  153. package/dist/emailer/types.d.ts.map +0 -1
  154. package/dist/emailer/types.js.map +0 -1
  155. package/dist/emailer/utils/constants.d.ts.map +0 -1
  156. package/dist/emailer/utils/constants.js.map +0 -1
  157. package/dist/emailer/utils/index.d.ts.map +0 -1
  158. package/dist/emailer/utils/index.js.map +0 -1
  159. package/dist/emailer/utils/logger.d.ts.map +0 -1
  160. package/dist/emailer/utils/logger.js.map +0 -1
  161. package/dist/emailer/utils/validation.d.ts.map +0 -1
  162. package/dist/emailer/utils/validation.js.map +0 -1
  163. package/dist/index.d.ts.map +0 -1
  164. package/dist/index.js.map +0 -1
  165. package/dist/template_manager/config/config_loader.d.ts.map +0 -1
  166. package/dist/template_manager/config/config_loader.js +0 -154
  167. package/dist/template_manager/config/config_loader.js.map +0 -1
  168. package/dist/template_manager/config/constants.d.ts.map +0 -1
  169. package/dist/template_manager/config/constants.js.map +0 -1
  170. package/dist/template_manager/config/index.d.ts.map +0 -1
  171. package/dist/template_manager/config/index.js.map +0 -1
  172. package/dist/template_manager/db/category_repository.d.ts.map +0 -1
  173. package/dist/template_manager/db/category_repository.js.map +0 -1
  174. package/dist/template_manager/db/index.d.ts +0 -6
  175. package/dist/template_manager/db/index.d.ts.map +0 -1
  176. package/dist/template_manager/db/index.js +0 -6
  177. package/dist/template_manager/db/index.js.map +0 -1
  178. package/dist/template_manager/db/template_repository.d.ts.map +0 -1
  179. package/dist/template_manager/db/template_repository.js +0 -674
  180. package/dist/template_manager/db/template_repository.js.map +0 -1
  181. package/dist/template_manager/engine/handlebars_engine.d.ts.map +0 -1
  182. package/dist/template_manager/engine/handlebars_engine.js.map +0 -1
  183. package/dist/template_manager/engine/index.d.ts.map +0 -1
  184. package/dist/template_manager/engine/index.js.map +0 -1
  185. package/dist/template_manager/engine/variable_resolver.d.ts.map +0 -1
  186. package/dist/template_manager/engine/variable_resolver.js.map +0 -1
  187. package/dist/template_manager/index.d.ts +0 -32
  188. package/dist/template_manager/index.d.ts.map +0 -1
  189. package/dist/template_manager/index.js +0 -41
  190. package/dist/template_manager/index.js.map +0 -1
  191. package/dist/template_manager/template_manager.d.ts.map +0 -1
  192. package/dist/template_manager/template_manager.js.map +0 -1
  193. package/dist/template_manager/types.d.ts.map +0 -1
  194. package/dist/template_manager/types.js +0 -11
  195. package/dist/template_manager/types.js.map +0 -1
  196. package/dist/template_manager/utils/index.d.ts.map +0 -1
  197. package/dist/template_manager/utils/index.js.map +0 -1
  198. package/dist/template_manager/utils/system_variables.d.ts.map +0 -1
  199. package/dist/template_manager/utils/system_variables.js.map +0 -1
  200. package/dist/template_manager/utils/validation.d.ts.map +0 -1
  201. package/dist/template_manager/utils/validation.js.map +0 -1
  202. /package/dist/{emailer → lib/emailer}/emailer.d.ts +0 -0
  203. /package/dist/{emailer → lib/emailer}/emailer.js +0 -0
  204. /package/dist/{emailer → lib/emailer}/index.d.ts +0 -0
  205. /package/dist/{emailer → lib/emailer}/index.js +0 -0
  206. /package/dist/{emailer → lib/emailer}/providers/index.d.ts +0 -0
  207. /package/dist/{emailer → lib/emailer}/providers/index.js +0 -0
  208. /package/dist/{emailer → lib/emailer}/providers/pop3_provider.d.ts +0 -0
  209. /package/dist/{emailer → lib/emailer}/providers/pop3_provider.js +0 -0
  210. /package/dist/{emailer → lib/emailer}/providers/smtp_provider.d.ts +0 -0
  211. /package/dist/{emailer → lib/emailer}/providers/smtp_provider.js +0 -0
  212. /package/dist/{emailer → lib/emailer}/providers/zeptomail_provider.d.ts +0 -0
  213. /package/dist/{emailer → lib/emailer}/types.d.ts +0 -0
  214. /package/dist/{emailer → lib/emailer}/types.js +0 -0
  215. /package/dist/{emailer → lib/emailer}/utils/constants.d.ts +0 -0
  216. /package/dist/{emailer → lib/emailer}/utils/constants.js +0 -0
  217. /package/dist/{emailer → lib/emailer}/utils/index.d.ts +0 -0
  218. /package/dist/{emailer → lib/emailer}/utils/index.js +0 -0
  219. /package/dist/{emailer → lib/emailer}/utils/logger.d.ts +0 -0
  220. /package/dist/{emailer → lib/emailer}/utils/logger.js +0 -0
  221. /package/dist/{emailer → lib/emailer}/utils/validation.d.ts +0 -0
  222. /package/dist/{emailer → lib/emailer}/utils/validation.js +0 -0
  223. /package/dist/{index.d.ts → lib/index.d.ts} +0 -0
  224. /package/dist/{index.js → lib/index.js} +0 -0
  225. /package/dist/{template_manager → lib/template_manager}/config/index.d.ts +0 -0
  226. /package/dist/{template_manager → lib/template_manager}/config/index.js +0 -0
  227. /package/dist/{template_manager → lib/template_manager}/engine/handlebars_engine.d.ts +0 -0
  228. /package/dist/{template_manager → lib/template_manager}/engine/handlebars_engine.js +0 -0
  229. /package/dist/{template_manager → lib/template_manager}/engine/index.d.ts +0 -0
  230. /package/dist/{template_manager → lib/template_manager}/engine/index.js +0 -0
  231. /package/dist/{template_manager → lib/template_manager}/utils/index.d.ts +0 -0
  232. /package/dist/{template_manager → lib/template_manager}/utils/index.js +0 -0
  233. /package/dist/{template_manager → lib/template_manager}/utils/system_variables.d.ts +0 -0
  234. /package/dist/{template_manager → lib/template_manager}/utils/system_variables.js +0 -0
  235. /package/dist/{template_manager → lib/template_manager}/utils/validation.d.ts +0 -0
  236. /package/dist/{template_manager → lib/template_manager}/utils/validation.js +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../../src/lib/emailer/utils/validation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAO7D;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAM3D;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAKhE;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAO1D;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAUnF"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.js","sourceRoot":"","sources":["../../../../src/lib/emailer/utils/validation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEvF;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CAAC,KAAa;IAClD,IAA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H,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,MAAM,CAAC;QACnD,OAAO,IAAI,IAAI,QAAQ,CAAC;IAC1B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,oBAAoB,CAAC;AACnC,cAAc,6BAA6B,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,oBAAoB,CAAC;AACnC,cAAc,6BAA6B,CAAC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * LRU-backed scope chain cache for template manager (v2.0.0)
3
+ *
4
+ * Resolves and caches the full ancestor chain for a scope_id so that
5
+ * hierarchical template lookup avoids repeated DB or resolver calls.
6
+ */
7
+ type ScopeResolver = (scope_id: string) => Promise<string[]>;
8
+ /**
9
+ * Wire a scope resolver function.
10
+ * The resolver receives a scope_id and must return the ancestor chain
11
+ * (nearest-to-root order), NOT including scope_id itself.
12
+ */
13
+ export declare function set_scope_resolver(resolver: ScopeResolver): void;
14
+ /**
15
+ * Get the full scope chain for a scope_id: [scope_id, ...ancestors nearest-to-root].
16
+ * Returns [scope_id] if no resolver is wired (flat lookup mode).
17
+ * Does NOT cache failures.
18
+ */
19
+ export declare function get_scope_chain(scope_id: string): Promise<string[]>;
20
+ /**
21
+ * Invalidate the cache for a specific scope_id, or clear the entire cache
22
+ * if no argument is provided.
23
+ */
24
+ export declare function invalidate_scope_chain(scope_id?: string): void;
25
+ export {};
26
+ //# sourceMappingURL=scope_chain_cache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope_chain_cache.d.ts","sourceRoot":"","sources":["../../../../src/lib/template_manager/cache/scope_chain_cache.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,KAAK,aAAa,GAAG,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;AAe7D;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI,CAEhE;AAED;;;;GAIG;AACH,wBAAsB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAezE;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAO9D"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * LRU-backed scope chain cache for template manager (v2.0.0)
3
+ *
4
+ * Resolves and caches the full ancestor chain for a scope_id so that
5
+ * hierarchical template lookup avoids repeated DB or resolver calls.
6
+ */
7
+ import { LRUCache } from 'lru-cache';
8
+ let cache = null;
9
+ let wired_resolver = null;
10
+ function get_cache() {
11
+ if (!cache) {
12
+ cache = new LRUCache({
13
+ max: 1000,
14
+ ttl: 60 * 1000,
15
+ });
16
+ }
17
+ return cache;
18
+ }
19
+ /**
20
+ * Wire a scope resolver function.
21
+ * The resolver receives a scope_id and must return the ancestor chain
22
+ * (nearest-to-root order), NOT including scope_id itself.
23
+ */
24
+ export function set_scope_resolver(resolver) {
25
+ wired_resolver = resolver;
26
+ }
27
+ /**
28
+ * Get the full scope chain for a scope_id: [scope_id, ...ancestors nearest-to-root].
29
+ * Returns [scope_id] if no resolver is wired (flat lookup mode).
30
+ * Does NOT cache failures.
31
+ */
32
+ export async function get_scope_chain(scope_id) {
33
+ const c = get_cache();
34
+ const cached = c.get(scope_id);
35
+ if (cached)
36
+ return cached;
37
+ if (!wired_resolver) {
38
+ const chain = [scope_id];
39
+ c.set(scope_id, chain);
40
+ return chain;
41
+ }
42
+ const ancestors = await wired_resolver(scope_id);
43
+ const chain = [scope_id, ...ancestors];
44
+ c.set(scope_id, chain);
45
+ return chain;
46
+ }
47
+ /**
48
+ * Invalidate the cache for a specific scope_id, or clear the entire cache
49
+ * if no argument is provided.
50
+ */
51
+ export function invalidate_scope_chain(scope_id) {
52
+ const c = get_cache();
53
+ if (scope_id) {
54
+ c.delete(scope_id);
55
+ }
56
+ else {
57
+ c.clear();
58
+ }
59
+ }
60
+ //# sourceMappingURL=scope_chain_cache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope_chain_cache.js","sourceRoot":"","sources":["../../../../src/lib/template_manager/cache/scope_chain_cache.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAIrC,IAAI,KAAK,GAAsC,IAAI,CAAC;AACpD,IAAI,cAAc,GAAyB,IAAI,CAAC;AAEhD,SAAS,SAAS;IAChB,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,KAAK,GAAG,IAAI,QAAQ,CAAmB;YACrC,GAAG,EAAE,IAAI;YACT,GAAG,EAAE,EAAE,GAAG,IAAI;SACf,CAAC,CAAC;IACL,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,QAAuB;IACxD,cAAc,GAAG,QAAQ,CAAC;AAC5B,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,QAAgB;IACpD,MAAM,CAAC,GAAG,SAAS,EAAE,CAAC;IACtB,MAAM,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC/B,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC;IAE1B,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,MAAM,KAAK,GAAG,CAAC,QAAQ,CAAC,CAAC;QACzB,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QACvB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,SAAS,GAAG,MAAM,cAAc,CAAC,QAAQ,CAAC,CAAC;IACjD,MAAM,KAAK,GAAG,CAAC,QAAQ,EAAE,GAAG,SAAS,CAAC,CAAC;IACvC,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IACvB,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAC,QAAiB;IACtD,MAAM,CAAC,GAAG,SAAS,EAAE,CAAC;IACtB,IAAI,QAAQ,EAAE,CAAC;QACb,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACrB,CAAC;SAAM,CAAC;QACN,CAAC,CAAC,KAAK,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
@@ -1,13 +1,16 @@
1
1
  /**
2
- * Configuration loader for template manager
2
+ * Configuration loader for template manager (v2.0.0)
3
3
  *
4
- * Loads template configuration from config/hazo_notify_config.ini
4
+ * Loads template configuration from config/hazo_notify_config.ini.
5
+ * Template type variable definitions are now provided via the registry
6
+ * (register_template_type) rather than the INI file or compiled defaults.
5
7
  */
6
8
  import type { TemplateManagerConfig, TemplateVariableDefinition } from '../types.js';
7
9
  /**
8
- * Load template manager configuration from config/hazo_notify_config.ini
10
+ * Load template manager configuration from config/hazo_notify_config.ini.
9
11
  *
10
- * Configuration is cached after first load
12
+ * Configuration is cached after first load. Use force_reload to bust the cache
13
+ * when the INI file changes at runtime.
11
14
  *
12
15
  * @param force_reload - Force reload from file (bypass cache)
13
16
  * @returns Template manager configuration
@@ -15,32 +18,30 @@ import type { TemplateManagerConfig, TemplateVariableDefinition } from '../types
15
18
  */
16
19
  export declare function load_template_config(force_reload?: boolean): TemplateManagerConfig;
17
20
  /**
18
- * Get template variable definitions for a specific template type
21
+ * Get template variable definitions for a specific template type.
22
+ * Looks up the registered template type via the registry.
19
23
  *
20
24
  * @param template_name - Name of the template type
21
- * @param config - Optional config (loads if not provided)
22
- * @returns Variable definitions for the template, or empty array if not found
25
+ * @returns Variable definitions for the template, or empty array if not registered
23
26
  */
24
- export declare function get_template_variables(template_name: string, config?: TemplateManagerConfig): TemplateVariableDefinition[];
27
+ export declare function get_template_variables(template_name: string): TemplateVariableDefinition[];
25
28
  /**
26
- * Get all available variable names (user + system) for a template type
29
+ * Get all available variable names (user + system) for a template type.
27
30
  *
28
31
  * @param template_name - Name of the template type
29
- * @param config - Optional config (loads if not provided)
30
32
  * @returns Object with user and system variable names
31
33
  */
32
- export declare function get_all_variable_names(template_name: string, config?: TemplateManagerConfig): {
34
+ export declare function get_all_variable_names(template_name: string): {
33
35
  user: string[];
34
36
  system: string[];
35
37
  };
36
38
  /**
37
- * Clear the cached configuration
38
- *
39
- * Useful for testing or when config file has been updated
39
+ * Clear the cached configuration.
40
+ * Useful for testing or when the config file has been updated at runtime.
40
41
  */
41
42
  export declare function clear_config_cache(): void;
42
43
  /**
43
- * Check if configuration is loaded and cached
44
+ * Check if configuration is loaded and cached.
44
45
  *
45
46
  * @returns true if config is cached
46
47
  */
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config_loader.d.ts","sourceRoot":"","sources":["../../../../src/lib/template_manager/config/config_loader.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EACV,qBAAqB,EACrB,0BAA0B,EAC3B,MAAM,aAAa,CAAC;AAYrB;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAClC,YAAY,GAAE,OAAe,GAC5B,qBAAqB,CAwCvB;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,aAAa,EAAE,MAAM,GACpB,0BAA0B,EAAE,CAI9B;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,aAAa,EAAE,MAAM,GACpB;IAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAQtC;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,IAAI,CAEzC;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,OAAO,CAE1C"}
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Configuration loader for template manager (v2.0.0)
3
+ *
4
+ * Loads template configuration from config/hazo_notify_config.ini.
5
+ * Template type variable definitions are now provided via the registry
6
+ * (register_template_type) rather than the INI file or compiled defaults.
7
+ */
8
+ import { HazoConfig } from 'hazo_config/server';
9
+ import { join } from 'path';
10
+ import { get_system_variables } from '../utils/system_variables.js';
11
+ import { get_registered_template_types } from '../registry.js';
12
+ import { ERROR_MESSAGES, } from './constants.js';
13
+ /**
14
+ * Cached configuration
15
+ */
16
+ let cached_config = null;
17
+ /**
18
+ * Load template manager configuration from config/hazo_notify_config.ini.
19
+ *
20
+ * Configuration is cached after first load. Use force_reload to bust the cache
21
+ * when the INI file changes at runtime.
22
+ *
23
+ * @param force_reload - Force reload from file (bypass cache)
24
+ * @returns Template manager configuration
25
+ * @throws Error if configuration is invalid
26
+ */
27
+ export function load_template_config(force_reload = false) {
28
+ if (cached_config && !force_reload) {
29
+ return cached_config;
30
+ }
31
+ try {
32
+ const config_file_path = join(process.cwd(), 'config', 'hazo_notify_config.ini');
33
+ const hazo_config = new HazoConfig({ filePath: config_file_path });
34
+ const template_section = hazo_config.getSection('hazo_notify__template_manager') || {};
35
+ const ttl_raw = template_section?.scope_chain_cache_ttl_seconds;
36
+ const scope_chain_cache_ttl_seconds = ttl_raw
37
+ ? parseInt(String(ttl_raw), 10) || 60
38
+ : 60;
39
+ const cors_raw = template_section?.cors_allowed_origins;
40
+ const cors_allowed_origins = cors_raw
41
+ ? String(cors_raw)
42
+ .split(',')
43
+ .map((s) => s.trim())
44
+ .filter(Boolean)
45
+ : [];
46
+ cached_config = {
47
+ scope_chain_cache_ttl_seconds,
48
+ cors_allowed_origins,
49
+ };
50
+ return cached_config;
51
+ }
52
+ catch (error) {
53
+ const error_message = error instanceof Error ? error.message : 'Unknown error';
54
+ throw new Error(`${ERROR_MESSAGES.CONFIG_NOT_LOADED}: ${error_message}`);
55
+ }
56
+ }
57
+ /**
58
+ * Get template variable definitions for a specific template type.
59
+ * Looks up the registered template type via the registry.
60
+ *
61
+ * @param template_name - Name of the template type
62
+ * @returns Variable definitions for the template, or empty array if not registered
63
+ */
64
+ export function get_template_variables(template_name) {
65
+ const registered = get_registered_template_types();
66
+ const found = registered.find((t) => t.template_name === template_name);
67
+ return found?.variables || [];
68
+ }
69
+ /**
70
+ * Get all available variable names (user + system) for a template type.
71
+ *
72
+ * @param template_name - Name of the template type
73
+ * @returns Object with user and system variable names
74
+ */
75
+ export function get_all_variable_names(template_name) {
76
+ const user_vars = get_template_variables(template_name);
77
+ const system_vars = get_system_variables();
78
+ return {
79
+ user: user_vars.map((v) => v.variable_name),
80
+ system: system_vars.map((v) => v.variable_name),
81
+ };
82
+ }
83
+ /**
84
+ * Clear the cached configuration.
85
+ * Useful for testing or when the config file has been updated at runtime.
86
+ */
87
+ export function clear_config_cache() {
88
+ cached_config = null;
89
+ }
90
+ /**
91
+ * Check if configuration is loaded and cached.
92
+ *
93
+ * @returns true if config is cached
94
+ */
95
+ export function is_config_cached() {
96
+ return cached_config !== null;
97
+ }
98
+ //# sourceMappingURL=config_loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config_loader.js","sourceRoot":"","sources":["../../../../src/lib/template_manager/config/config_loader.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAK5B,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EACL,cAAc,GACf,MAAM,gBAAgB,CAAC;AAExB;;GAEG;AACH,IAAI,aAAa,GAAiC,IAAI,CAAC;AAEvD;;;;;;;;;GASG;AACH,MAAM,UAAU,oBAAoB,CAClC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CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CACpC,aAAqB;IAErB,MAAM,UAAU,GAAG,6BAA6B,EAAE,CAAC;IACnD,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,KAAK,aAAa,CAAC,CAAC;IACxE,OAAO,KAAK,EAAE,SAAS,IAAI,EAAE,CAAC;AAChC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CACpC,aAAqB;IAErB,MAAM,SAAS,GAAG,sBAAsB,CAAC,aAAa,CAAC,CAAC;IACxD,MAAM,WAAW,GAAG,oBAAoB,EAAE,CAAC;IAE3C,OAAO;QACL,IAAI,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC;QAC3C,MAAM,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC;KAChD,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB;IAChC,aAAa,GAAG,IAAI,CAAC;AACvB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB;IAC9B,OAAO,aAAa,KAAK,IAAI,CAAC;AAChC,CAAC"}
@@ -1,12 +1,12 @@
1
1
  /**
2
- * Constants for the template manager service
2
+ * Constants for the template manager service (v2.0.0)
3
3
  *
4
- * Default values, table names, and validation limits
4
+ * Default values, table names, and validation limits.
5
+ * Removed: DEFAULT_TEMPLATE_NAMES, DEFAULT_EMAIL_TEMPLATE_VARIABLE_TYPES
6
+ * (hazo_notify ships zero default templates; consuming packages register their own)
5
7
  */
6
8
  export declare const TABLE_TEMPLATE_CATEGORY = "hazo_notify_template_cat";
7
9
  export declare const TABLE_TEMPLATES = "hazo_notify_templates";
8
- export declare const DEFAULT_TEMPLATE_NAMES: readonly ["welcome_email", "email_verification", "forgot_password", "email_signature"];
9
- export type DefaultTemplateName = (typeof DEFAULT_TEMPLATE_NAMES)[number];
10
10
  export declare const DEFAULT_CATEGORY_NAMES: {
11
11
  readonly SYSTEM: "System";
12
12
  readonly USER: "Custom";
@@ -29,56 +29,6 @@ export declare const VARIABLE_PATTERN: RegExp;
29
29
  export declare const TEMPLATE_REFERENCE_PATTERN: RegExp;
30
30
  /** Valid variable name pattern (lowercase alphanumeric with underscores) */
31
31
  export declare const VALID_VARIABLE_NAME_PATTERN: RegExp;
32
- export declare const DEFAULT_EMAIL_TEMPLATE_VARIABLE_TYPES: readonly [{
33
- readonly template_name: "welcome_email";
34
- readonly template_label: "Welcome Email";
35
- readonly variables: readonly [{
36
- readonly variable_name: "user_name";
37
- readonly variable_description: "Recipient's full name";
38
- }, {
39
- readonly variable_name: "login_url";
40
- readonly variable_description: "URL to login page";
41
- }];
42
- }, {
43
- readonly template_name: "email_verification";
44
- readonly template_label: "Email Verification";
45
- readonly variables: readonly [{
46
- readonly variable_name: "user_name";
47
- readonly variable_description: "Recipient's name";
48
- }, {
49
- readonly variable_name: "verification_link";
50
- readonly variable_description: "Email verification URL";
51
- }, {
52
- readonly variable_name: "expiry_hours";
53
- readonly variable_description: "Hours until link expires";
54
- }];
55
- }, {
56
- readonly template_name: "forgot_password";
57
- readonly template_label: "Forgot Password";
58
- readonly variables: readonly [{
59
- readonly variable_name: "user_name";
60
- readonly variable_description: "Recipient's name";
61
- }, {
62
- readonly variable_name: "reset_link";
63
- readonly variable_description: "Password reset URL";
64
- }, {
65
- readonly variable_name: "expiry_minutes";
66
- readonly variable_description: "Minutes until link expires";
67
- }];
68
- }, {
69
- readonly template_name: "email_signature";
70
- readonly template_label: "Email Signature";
71
- readonly variables: readonly [{
72
- readonly variable_name: "sender_name";
73
- readonly variable_description: "Sender's name";
74
- }, {
75
- readonly variable_name: "sender_title";
76
- readonly variable_description: "Sender's job title";
77
- }, {
78
- readonly variable_name: "company_name";
79
- readonly variable_description: "Company name";
80
- }];
81
- }];
82
32
  export declare const SYSTEM_VARIABLE_NAMES: readonly ["date_yyyy_mm_dd", "date_mmm_dd", "date_mmmm_dd_yyyy", "date_dd_mm_yyyy", "date_dd_mmm_yyyy", "time_hh_mm", "time_hh_mm_ss", "datetime_full", "year", "month_name", "day_of_week"];
83
33
  export type SystemVariableName = (typeof SYSTEM_VARIABLE_NAMES)[number];
84
34
  export declare const ERROR_MESSAGES: {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/lib/template_manager/config/constants.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,eAAO,MAAM,uBAAuB,6BAA6B,CAAC;AAClE,eAAO,MAAM,eAAe,0BAA0B,CAAC;AAMvD,eAAO,MAAM,sBAAsB;;;CAGzB,CAAC;AAMX,uCAAuC;AACvC,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAE5C,uCAAuC;AACvC,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAE5C,mDAAmD;AACnD,eAAO,MAAM,sBAAsB,QAAc,CAAC;AAElD,qDAAqD;AACrD,eAAO,MAAM,sBAAsB,QAAa,CAAC;AAEjD,+CAA+C;AAC/C,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAE7C,uEAAuE;AACvE,eAAO,MAAM,4BAA4B,IAAI,CAAC;AAM9C,0CAA0C;AAC1C,eAAO,MAAM,gBAAgB,QAA+B,CAAC;AAE7D,uCAAuC;AACvC,eAAO,MAAM,0BAA0B,QAAwB,CAAC;AAEhE,4EAA4E;AAC5E,eAAO,MAAM,2BAA2B,QAAsB,CAAC;AAM/D,eAAO,MAAM,qBAAqB,8LAYxB,CAAC;AAEX,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,CAAC,CAAC;AAMxE,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;CAgBjB,CAAC"}
@@ -1,7 +1,9 @@
1
1
  /**
2
- * Constants for the template manager service
2
+ * Constants for the template manager service (v2.0.0)
3
3
  *
4
- * Default values, table names, and validation limits
4
+ * Default values, table names, and validation limits.
5
+ * Removed: DEFAULT_TEMPLATE_NAMES, DEFAULT_EMAIL_TEMPLATE_VARIABLE_TYPES
6
+ * (hazo_notify ships zero default templates; consuming packages register their own)
5
7
  */
6
8
  // ============================================================
7
9
  // Database Table Names
@@ -9,15 +11,6 @@
9
11
  export const TABLE_TEMPLATE_CATEGORY = 'hazo_notify_template_cat';
10
12
  export const TABLE_TEMPLATES = 'hazo_notify_templates';
11
13
  // ============================================================
12
- // Default Template Names
13
- // ============================================================
14
- export const DEFAULT_TEMPLATE_NAMES = [
15
- 'welcome_email',
16
- 'email_verification',
17
- 'forgot_password',
18
- 'email_signature',
19
- ];
20
- // ============================================================
21
14
  // Default Category Names
22
15
  // ============================================================
23
16
  export const DEFAULT_CATEGORY_NAMES = {
@@ -49,79 +42,6 @@ export const TEMPLATE_REFERENCE_PATTERN = /@([a-z][a-z0-9_]*)/g;
49
42
  /** Valid variable name pattern (lowercase alphanumeric with underscores) */
50
43
  export const VALID_VARIABLE_NAME_PATTERN = /^[a-z][a-z0-9_]*$/;
51
44
  // ============================================================
52
- // Default Template Variable Types
53
- // ============================================================
54
- export const DEFAULT_EMAIL_TEMPLATE_VARIABLE_TYPES = [
55
- {
56
- template_name: 'welcome_email',
57
- template_label: 'Welcome Email',
58
- variables: [
59
- {
60
- variable_name: 'user_name',
61
- variable_description: "Recipient's full name",
62
- },
63
- {
64
- variable_name: 'login_url',
65
- variable_description: 'URL to login page',
66
- },
67
- ],
68
- },
69
- {
70
- template_name: 'email_verification',
71
- template_label: 'Email Verification',
72
- variables: [
73
- {
74
- variable_name: 'user_name',
75
- variable_description: "Recipient's name",
76
- },
77
- {
78
- variable_name: 'verification_link',
79
- variable_description: 'Email verification URL',
80
- },
81
- {
82
- variable_name: 'expiry_hours',
83
- variable_description: 'Hours until link expires',
84
- },
85
- ],
86
- },
87
- {
88
- template_name: 'forgot_password',
89
- template_label: 'Forgot Password',
90
- variables: [
91
- {
92
- variable_name: 'user_name',
93
- variable_description: "Recipient's name",
94
- },
95
- {
96
- variable_name: 'reset_link',
97
- variable_description: 'Password reset URL',
98
- },
99
- {
100
- variable_name: 'expiry_minutes',
101
- variable_description: 'Minutes until link expires',
102
- },
103
- ],
104
- },
105
- {
106
- template_name: 'email_signature',
107
- template_label: 'Email Signature',
108
- variables: [
109
- {
110
- variable_name: 'sender_name',
111
- variable_description: "Sender's name",
112
- },
113
- {
114
- variable_name: 'sender_title',
115
- variable_description: "Sender's job title",
116
- },
117
- {
118
- variable_name: 'company_name',
119
- variable_description: 'Company name',
120
- },
121
- ],
122
- },
123
- ];
124
- // ============================================================
125
45
  // System Variable Names
126
46
  // ============================================================
127
47
  export const SYSTEM_VARIABLE_NAMES = [
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../src/lib/template_manager/config/constants.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,+DAA+D;AAC/D,uBAAuB;AACvB,+DAA+D;AAE/D,MAAM,CAAC,MAAM,uBAAuB,GAAG,0BAA0B,CAAC;AAClE,MAAM,CAAC,MAAM,eAAe,GAAG,uBAAuB,CAAC;AAEvD,+DAA+D;AAC/D,yBAAyB;AACzB,+DAA+D;AAE/D,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,QAAQ;CACN,CAAC;AAEX,+DAA+D;AAC/D,oBAAoB;AACpB,+DAA+D;AAE/D,uCAAuC;AACvC,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,CAAC;AAE5C,uCAAuC;AACvC,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,CAAC;AAE5C,mDAAmD;AACnD,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,GAAG,IAAI,CAAC;AAElD,qDAAqD;AACrD,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,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9D,sBAAsB,EAAE,uCAAuC;CACvD,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/template_manager/config/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/template_manager/config/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC"}
@@ -1,19 +1,22 @@
1
1
  /**
2
- * Category repository for template manager
2
+ * Category repository for template manager (v2.0.0)
3
3
  *
4
- * CRUD operations for template categories using hazo_connect
4
+ * CRUD operations for template categories using hazo_connect.
5
+ * Uses scope_id (null = global) for hierarchical category resolution.
5
6
  */
6
7
  import type { HazoConnectInstance, TemplateCategory, TemplateCategoryInput, TemplateCategoryUpdate, TemplateOperationResponse } from '../types.js';
7
8
  /**
8
- * List all template categories for an organization
9
+ * List all template categories visible for a given scope (scoped rows + global rows).
10
+ * When scope_id is provided, scoped rows override global rows with the same
11
+ * template_category_name in the returned set.
9
12
  *
10
13
  * @param hazo_connect - Database connection instance
11
- * @param org_id - Organization ID
14
+ * @param scope_id - Scope to list categories for (null/undefined = global only)
12
15
  * @returns Response with array of categories
13
16
  */
14
- export declare function list_categories(hazo_connect: HazoConnectInstance, org_id: string): Promise<TemplateOperationResponse<TemplateCategory[]>>;
17
+ export declare function list_categories(hazo_connect: HazoConnectInstance, scope_id?: string | null): Promise<TemplateOperationResponse<TemplateCategory[]>>;
15
18
  /**
16
- * Get a single template category by ID
19
+ * Get a single template category by ID.
17
20
  *
18
21
  * @param hazo_connect - Database connection instance
19
22
  * @param id - Category ID
@@ -21,7 +24,7 @@ export declare function list_categories(hazo_connect: HazoConnectInstance, org_i
21
24
  */
22
25
  export declare function get_category(hazo_connect: HazoConnectInstance, id: string): Promise<TemplateOperationResponse<TemplateCategory>>;
23
26
  /**
24
- * Create a new template category
27
+ * Create a new template category.
25
28
  *
26
29
  * @param hazo_connect - Database connection instance
27
30
  * @param data - Category input data
@@ -29,7 +32,7 @@ export declare function get_category(hazo_connect: HazoConnectInstance, id: stri
29
32
  */
30
33
  export declare function create_category(hazo_connect: HazoConnectInstance, data: TemplateCategoryInput): Promise<TemplateOperationResponse<TemplateCategory>>;
31
34
  /**
32
- * Update an existing template category
35
+ * Update an existing template category.
33
36
  *
34
37
  * @param hazo_connect - Database connection instance
35
38
  * @param id - Category ID
@@ -38,7 +41,9 @@ export declare function create_category(hazo_connect: HazoConnectInstance, data:
38
41
  */
39
42
  export declare function update_category(hazo_connect: HazoConnectInstance, id: string, data: TemplateCategoryUpdate): Promise<TemplateOperationResponse<TemplateCategory>>;
40
43
  /**
41
- * Delete a template category and all its templates
44
+ * Delete a template category.
45
+ * If the category has templates and the FK is RESTRICT, the DB will reject
46
+ * the delete — the error propagates to the caller to handle.
42
47
  *
43
48
  * @param hazo_connect - Database connection instance
44
49
  * @param id - Category ID
@@ -46,12 +51,15 @@ export declare function update_category(hazo_connect: HazoConnectInstance, id: s
46
51
  */
47
52
  export declare function delete_category(hazo_connect: HazoConnectInstance, id: string): Promise<TemplateOperationResponse<boolean>>;
48
53
  /**
49
- * Find a category by name within an organization
54
+ * Find a category by name using hierarchical scope resolution.
55
+ *
56
+ * scope_chain: [scope_id, ...ancestors] — chain[0] is deepest (most preferred).
57
+ * Empty array → global-only lookup.
50
58
  *
51
59
  * @param hazo_connect - Database connection instance
52
- * @param org_id - Organization ID
53
- * @param name - Category name
54
- * @returns Response with category if found
60
+ * @param scope_chain - Ordered scope chain, deepest first
61
+ * @param name - Category name to look up
62
+ * @returns Response with best-matching category or null if not found
55
63
  */
56
- export declare function find_category_by_name(hazo_connect: HazoConnectInstance, org_id: string, name: string): Promise<TemplateOperationResponse<TemplateCategory | null>>;
64
+ export declare function find_category_by_name_in_chain(hazo_connect: HazoConnectInstance, scope_chain: string[], name: string): Promise<TemplateOperationResponse<TemplateCategory | null>>;
57
65
  //# sourceMappingURL=category_repository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"category_repository.d.ts","sourceRoot":"","sources":["../../../../src/lib/template_manager/db/category_repository.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,EACrB,sBAAsB,EACtB,yBAAyB,EAC1B,MAAM,aAAa,CAAC;AAOrB;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CACnC,YAAY,EAAE,mBAAmB,EACjC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,GACvB,OAAO,CAAC,yBAAyB,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAgExD;AAED;;;;;;GAMG;AACH,wBAAsB,YAAY,CAChC,YAAY,EAAE,mBAAmB,EACjC,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,yBAAyB,CAAC,gBAAgB,CAAC,CAAC,CA4CtD;AAED;;;;;;GAMG;AACH,wBAAsB,eAAe,CACnC,YAAY,EAAE,mBAAmB,EACjC,IAAI,EAAE,qBAAqB,GAC1B,OAAO,CAAC,yBAAyB,CAAC,gBAAgB,CAAC,CAAC,CA+CtD;AAED;;;;;;;GAOG;AACH,wBAAsB,eAAe,CACnC,YAAY,EAAE,mBAAmB,EACjC,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,sBAAsB,GAC3B,OAAO,CAAC,yBAAyB,CAAC,gBAAgB,CAAC,CAAC,CAsEtD;AAED;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CACnC,YAAY,EAAE,mBAAmB,EACjC,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,yBAAyB,CAAC,OAAO,CAAC,CAAC,CA8C7C;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,8BAA8B,CAClD,YAAY,EAAE,mBAAmB,EACjC,WAAW,EAAE,MAAM,EAAE,EACrB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,yBAAyB,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC,CA6E7D"}