@wildo-ai/dev-companion 1.1.13 → 1.1.15

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 (363) hide show
  1. package/dist/esm/.tsbuildinfo +1 -1
  2. package/dist/esm/claude-cli/models/coding-agent-dispatch.models.d.ts +89 -1
  3. package/dist/esm/claude-cli/models/coding-agent-dispatch.models.d.ts.map +1 -1
  4. package/dist/esm/claude-cli/models/coding-agent-dispatch.models.js +114 -9
  5. package/dist/esm/claude-cli/models/coding-agent-dispatch.models.js.map +1 -1
  6. package/dist/esm/claude-cli/models/concurrent-coding-runs.models.d.ts +46 -1
  7. package/dist/esm/claude-cli/models/concurrent-coding-runs.models.d.ts.map +1 -1
  8. package/dist/esm/claude-cli/models/concurrent-coding-runs.models.js +39 -2
  9. package/dist/esm/claude-cli/models/concurrent-coding-runs.models.js.map +1 -1
  10. package/dist/esm/claude-cli/models/shared-tree-reconciliation.models.d.ts +6 -0
  11. package/dist/esm/claude-cli/models/shared-tree-reconciliation.models.d.ts.map +1 -1
  12. package/dist/esm/claude-cli/models/shared-tree-reconciliation.models.js.map +1 -1
  13. package/dist/esm/claude-cli/models/verification-tool-availability.models.d.ts +19 -5
  14. package/dist/esm/claude-cli/models/verification-tool-availability.models.d.ts.map +1 -1
  15. package/dist/esm/claude-cli/models/verification-tool-availability.models.js +17 -5
  16. package/dist/esm/claude-cli/models/verification-tool-availability.models.js.map +1 -1
  17. package/dist/esm/claude-cli/services/accepted-change-commit.companion.service.d.ts +16 -1
  18. package/dist/esm/claude-cli/services/accepted-change-commit.companion.service.d.ts.map +1 -1
  19. package/dist/esm/claude-cli/services/accepted-change-commit.companion.service.js +53 -6
  20. package/dist/esm/claude-cli/services/accepted-change-commit.companion.service.js.map +1 -1
  21. package/dist/esm/claude-cli/services/coding-agent-dispatch.companion.service.d.ts +145 -6
  22. package/dist/esm/claude-cli/services/coding-agent-dispatch.companion.service.d.ts.map +1 -1
  23. package/dist/esm/claude-cli/services/coding-agent-dispatch.companion.service.js +474 -47
  24. package/dist/esm/claude-cli/services/coding-agent-dispatch.companion.service.js.map +1 -1
  25. package/dist/esm/claude-cli/services/git-change-set.companion.service.d.ts +6 -2
  26. package/dist/esm/claude-cli/services/git-change-set.companion.service.d.ts.map +1 -1
  27. package/dist/esm/claude-cli/services/git-change-set.companion.service.js +16 -39
  28. package/dist/esm/claude-cli/services/git-change-set.companion.service.js.map +1 -1
  29. package/dist/esm/claude-cli/services/research-evidence-store.companion.d.ts +14 -0
  30. package/dist/esm/claude-cli/services/research-evidence-store.companion.d.ts.map +1 -1
  31. package/dist/esm/claude-cli/services/research-evidence-store.companion.js +35 -0
  32. package/dist/esm/claude-cli/services/research-evidence-store.companion.js.map +1 -1
  33. package/dist/esm/claude-cli/services/unrecorded-provider-directories.companion.d.ts +36 -0
  34. package/dist/esm/claude-cli/services/unrecorded-provider-directories.companion.d.ts.map +1 -0
  35. package/dist/esm/claude-cli/services/unrecorded-provider-directories.companion.js +134 -0
  36. package/dist/esm/claude-cli/services/unrecorded-provider-directories.companion.js.map +1 -0
  37. package/dist/esm/code-compliance-check/check-raw-feature-id-literals.companion.js +31 -2
  38. package/dist/esm/code-compliance-check/check-raw-feature-id-literals.companion.js.map +1 -1
  39. package/dist/esm/companion-api/companion-api.schemas.d.ts +2 -0
  40. package/dist/esm/companion-api/companion-api.schemas.d.ts.map +1 -1
  41. package/dist/esm/companion-api/companion-api.schemas.js +8 -0
  42. package/dist/esm/companion-api/companion-api.schemas.js.map +1 -1
  43. package/dist/esm/companion-api/controllers/companion.controller.d.ts +7 -0
  44. package/dist/esm/companion-api/controllers/companion.controller.d.ts.map +1 -1
  45. package/dist/esm/companion-api/controllers/companion.controller.js +26 -12
  46. package/dist/esm/companion-api/controllers/companion.controller.js.map +1 -1
  47. package/dist/esm/companion-api/controllers/long-held-request.companion.d.ts +17 -0
  48. package/dist/esm/companion-api/controllers/long-held-request.companion.d.ts.map +1 -0
  49. package/dist/esm/companion-api/controllers/long-held-request.companion.js +33 -0
  50. package/dist/esm/companion-api/controllers/long-held-request.companion.js.map +1 -0
  51. package/dist/esm/core/introspection/resources/creation-home-projection.companion.d.ts +9 -0
  52. package/dist/esm/core/introspection/resources/creation-home-projection.companion.d.ts.map +1 -1
  53. package/dist/esm/core/introspection/resources/creation-home-projection.companion.js +12 -0
  54. package/dist/esm/core/introspection/resources/creation-home-projection.companion.js.map +1 -1
  55. package/dist/esm/core/introspection/resources/creation-plane-projection.companion.service.d.ts.map +1 -1
  56. package/dist/esm/core/introspection/resources/creation-plane-projection.companion.service.js +7 -1
  57. package/dist/esm/core/introspection/resources/creation-plane-projection.companion.service.js.map +1 -1
  58. package/dist/esm/core/introspection/services/introspection-source-state.companion.service.d.ts +8 -20
  59. package/dist/esm/core/introspection/services/introspection-source-state.companion.service.d.ts.map +1 -1
  60. package/dist/esm/core/introspection/services/introspection-source-state.companion.service.js +37 -142
  61. package/dist/esm/core/introspection/services/introspection-source-state.companion.service.js.map +1 -1
  62. package/dist/esm/core/introspection/services/introspection-source-walk.worker.d.ts +64 -0
  63. package/dist/esm/core/introspection/services/introspection-source-walk.worker.d.ts.map +1 -0
  64. package/dist/esm/core/introspection/services/introspection-source-walk.worker.js +304 -0
  65. package/dist/esm/core/introspection/services/introspection-source-walk.worker.js.map +1 -0
  66. package/dist/esm/core/introspection/services/translation-placement.companion.service.d.ts +3 -2
  67. package/dist/esm/core/introspection/services/translation-placement.companion.service.d.ts.map +1 -1
  68. package/dist/esm/core/introspection/services/translation-placement.companion.service.js.map +1 -1
  69. package/dist/esm/core/introspection/subprocess/companion-introspection-behavior-handlers.d.ts.map +1 -1
  70. package/dist/esm/core/introspection/subprocess/companion-introspection-behavior-handlers.js +24 -14
  71. package/dist/esm/core/introspection/subprocess/companion-introspection-behavior-handlers.js.map +1 -1
  72. package/dist/esm/core/introspection/workspace-element-index.companion.d.ts +42 -0
  73. package/dist/esm/core/introspection/workspace-element-index.companion.d.ts.map +1 -1
  74. package/dist/esm/core/introspection/workspace-element-index.companion.js +42 -0
  75. package/dist/esm/core/introspection/workspace-element-index.companion.js.map +1 -1
  76. package/dist/esm/core/runtime/companion-language-model-route.d.ts +16 -1
  77. package/dist/esm/core/runtime/companion-language-model-route.d.ts.map +1 -1
  78. package/dist/esm/core/runtime/companion-language-model-route.js +23 -1
  79. package/dist/esm/core/runtime/companion-language-model-route.js.map +1 -1
  80. package/dist/esm/core/runtime/dev-compile-quiet.companion.d.ts +53 -0
  81. package/dist/esm/core/runtime/dev-compile-quiet.companion.d.ts.map +1 -1
  82. package/dist/esm/core/runtime/dev-compile-quiet.companion.js +119 -2
  83. package/dist/esm/core/runtime/dev-compile-quiet.companion.js.map +1 -1
  84. package/dist/esm/core/runtime/services/start-companion-application.service.d.ts.map +1 -1
  85. package/dist/esm/core/runtime/services/start-companion-application.service.js +16 -3
  86. package/dist/esm/core/runtime/services/start-companion-application.service.js.map +1 -1
  87. package/dist/esm/core/runtime/utils/companion-platform-config.companion.d.ts +2 -2
  88. package/dist/esm/core/runtime/utils/companion-platform-config.companion.d.ts.map +1 -1
  89. package/dist/esm/core/runtime/utils/companion-platform-config.companion.js +6 -6
  90. package/dist/esm/core/runtime/utils/companion-platform-config.companion.js.map +1 -1
  91. package/dist/esm/core/utils/git-read-broker.companion.d.ts +62 -0
  92. package/dist/esm/core/utils/git-read-broker.companion.d.ts.map +1 -0
  93. package/dist/esm/core/utils/git-read-broker.companion.js +282 -0
  94. package/dist/esm/core/utils/git-read-broker.companion.js.map +1 -0
  95. package/dist/esm/core/utils/local-write-recording.companion.d.ts +8 -1
  96. package/dist/esm/core/utils/local-write-recording.companion.d.ts.map +1 -1
  97. package/dist/esm/core/utils/local-write-recording.companion.js +7 -23
  98. package/dist/esm/core/utils/local-write-recording.companion.js.map +1 -1
  99. package/dist/esm/email/services/email-template.companion.service.d.ts +5 -0
  100. package/dist/esm/email/services/email-template.companion.service.d.ts.map +1 -1
  101. package/dist/esm/email/services/email-template.companion.service.js +44 -11
  102. package/dist/esm/email/services/email-template.companion.service.js.map +1 -1
  103. package/dist/esm/email/utils/email-template-fs-discovery.utils.d.ts +26 -2
  104. package/dist/esm/email/utils/email-template-fs-discovery.utils.d.ts.map +1 -1
  105. package/dist/esm/email/utils/email-template-fs-discovery.utils.js +41 -2
  106. package/dist/esm/email/utils/email-template-fs-discovery.utils.js.map +1 -1
  107. package/dist/esm/email/utils/email-template-scanner-calls.companion.utils.d.ts +19 -0
  108. package/dist/esm/email/utils/email-template-scanner-calls.companion.utils.d.ts.map +1 -0
  109. package/dist/esm/email/utils/email-template-scanner-calls.companion.utils.js +171 -0
  110. package/dist/esm/email/utils/email-template-scanner-calls.companion.utils.js.map +1 -0
  111. package/dist/esm/email/utils/module-email-root.companion.utils.d.ts +75 -0
  112. package/dist/esm/email/utils/module-email-root.companion.utils.d.ts.map +1 -0
  113. package/dist/esm/email/utils/module-email-root.companion.utils.js +162 -0
  114. package/dist/esm/email/utils/module-email-root.companion.utils.js.map +1 -0
  115. package/dist/esm/i18n/components/HIGH_LEVEL_VIEWS_CHART_DASHBOARD_LAYOUT_EDITOR.en.d.ts +29 -0
  116. package/dist/esm/i18n/components/HIGH_LEVEL_VIEWS_CHART_DASHBOARD_LAYOUT_EDITOR.en.d.ts.map +1 -0
  117. package/dist/esm/i18n/components/HIGH_LEVEL_VIEWS_CHART_DASHBOARD_LAYOUT_EDITOR.en.js +29 -0
  118. package/dist/esm/i18n/components/HIGH_LEVEL_VIEWS_CHART_DASHBOARD_LAYOUT_EDITOR.en.js.map +1 -0
  119. package/dist/esm/i18n/components/HIGH_LEVEL_VIEWS_CHART_DASHBOARD_LAYOUT_EDITOR.fr.d.ts +29 -0
  120. package/dist/esm/i18n/components/HIGH_LEVEL_VIEWS_CHART_DASHBOARD_LAYOUT_EDITOR.fr.d.ts.map +1 -0
  121. package/dist/esm/i18n/components/HIGH_LEVEL_VIEWS_CHART_DASHBOARD_LAYOUT_EDITOR.fr.js +29 -0
  122. package/dist/esm/i18n/components/HIGH_LEVEL_VIEWS_CHART_DASHBOARD_LAYOUT_EDITOR.fr.js.map +1 -0
  123. package/dist/esm/i18n/components/LOW_LEVEL_AI_AGENT_CONFIG.en.d.ts +1 -0
  124. package/dist/esm/i18n/components/LOW_LEVEL_AI_AGENT_CONFIG.en.d.ts.map +1 -1
  125. package/dist/esm/i18n/components/LOW_LEVEL_AI_AGENT_CONFIG.en.js +1 -0
  126. package/dist/esm/i18n/components/LOW_LEVEL_AI_AGENT_CONFIG.en.js.map +1 -1
  127. package/dist/esm/i18n/components/LOW_LEVEL_AI_AGENT_CONFIG.fr.d.ts +1 -0
  128. package/dist/esm/i18n/components/LOW_LEVEL_AI_AGENT_CONFIG.fr.d.ts.map +1 -1
  129. package/dist/esm/i18n/components/LOW_LEVEL_AI_AGENT_CONFIG.fr.js +1 -0
  130. package/dist/esm/i18n/components/LOW_LEVEL_AI_AGENT_CONFIG.fr.js.map +1 -1
  131. package/dist/esm/i18n/components/LOW_LEVEL_AI_APPROVAL.en.d.ts +1 -0
  132. package/dist/esm/i18n/components/LOW_LEVEL_AI_APPROVAL.en.d.ts.map +1 -1
  133. package/dist/esm/i18n/components/LOW_LEVEL_AI_APPROVAL.en.js +2 -1
  134. package/dist/esm/i18n/components/LOW_LEVEL_AI_APPROVAL.en.js.map +1 -1
  135. package/dist/esm/i18n/components/LOW_LEVEL_AI_APPROVAL.fr.d.ts +1 -0
  136. package/dist/esm/i18n/components/LOW_LEVEL_AI_APPROVAL.fr.d.ts.map +1 -1
  137. package/dist/esm/i18n/components/LOW_LEVEL_AI_APPROVAL.fr.js +2 -1
  138. package/dist/esm/i18n/components/LOW_LEVEL_AI_APPROVAL.fr.js.map +1 -1
  139. package/dist/esm/i18n/components/LOW_LEVEL_AI_CONVERSATION_THREAD.en.d.ts +5 -2
  140. package/dist/esm/i18n/components/LOW_LEVEL_AI_CONVERSATION_THREAD.en.d.ts.map +1 -1
  141. package/dist/esm/i18n/components/LOW_LEVEL_AI_CONVERSATION_THREAD.en.js +5 -2
  142. package/dist/esm/i18n/components/LOW_LEVEL_AI_CONVERSATION_THREAD.en.js.map +1 -1
  143. package/dist/esm/i18n/components/LOW_LEVEL_AI_CONVERSATION_THREAD.fr.d.ts +5 -2
  144. package/dist/esm/i18n/components/LOW_LEVEL_AI_CONVERSATION_THREAD.fr.d.ts.map +1 -1
  145. package/dist/esm/i18n/components/LOW_LEVEL_AI_CONVERSATION_THREAD.fr.js +5 -2
  146. package/dist/esm/i18n/components/LOW_LEVEL_AI_CONVERSATION_THREAD.fr.js.map +1 -1
  147. package/dist/esm/i18n/components/LOW_LEVEL_APPROVAL_SEAL.en.d.ts +41 -0
  148. package/dist/esm/i18n/components/LOW_LEVEL_APPROVAL_SEAL.en.d.ts.map +1 -0
  149. package/dist/esm/i18n/components/LOW_LEVEL_APPROVAL_SEAL.en.js +41 -0
  150. package/dist/esm/i18n/components/LOW_LEVEL_APPROVAL_SEAL.en.js.map +1 -0
  151. package/dist/esm/i18n/components/LOW_LEVEL_APPROVAL_SEAL.fr.d.ts +41 -0
  152. package/dist/esm/i18n/components/LOW_LEVEL_APPROVAL_SEAL.fr.d.ts.map +1 -0
  153. package/dist/esm/i18n/components/LOW_LEVEL_APPROVAL_SEAL.fr.js +41 -0
  154. package/dist/esm/i18n/components/LOW_LEVEL_APPROVAL_SEAL.fr.js.map +1 -0
  155. package/dist/esm/i18n/components/LOW_LEVEL_CONTENT_SECTION_CONTAINER.en.d.ts +1 -0
  156. package/dist/esm/i18n/components/LOW_LEVEL_CONTENT_SECTION_CONTAINER.en.d.ts.map +1 -1
  157. package/dist/esm/i18n/components/LOW_LEVEL_CONTENT_SECTION_CONTAINER.en.js +2 -1
  158. package/dist/esm/i18n/components/LOW_LEVEL_CONTENT_SECTION_CONTAINER.en.js.map +1 -1
  159. package/dist/esm/i18n/components/LOW_LEVEL_CONTENT_SECTION_CONTAINER.fr.d.ts +1 -0
  160. package/dist/esm/i18n/components/LOW_LEVEL_CONTENT_SECTION_CONTAINER.fr.d.ts.map +1 -1
  161. package/dist/esm/i18n/components/LOW_LEVEL_CONTENT_SECTION_CONTAINER.fr.js +2 -1
  162. package/dist/esm/i18n/components/LOW_LEVEL_CONTENT_SECTION_CONTAINER.fr.js.map +1 -1
  163. package/dist/esm/i18n/components/LOW_LEVEL_FORM_FIELD_STRING.en.d.ts +1 -0
  164. package/dist/esm/i18n/components/LOW_LEVEL_FORM_FIELD_STRING.en.d.ts.map +1 -1
  165. package/dist/esm/i18n/components/LOW_LEVEL_FORM_FIELD_STRING.en.js +2 -1
  166. package/dist/esm/i18n/components/LOW_LEVEL_FORM_FIELD_STRING.en.js.map +1 -1
  167. package/dist/esm/i18n/components/LOW_LEVEL_FORM_FIELD_STRING.fr.d.ts +1 -0
  168. package/dist/esm/i18n/components/LOW_LEVEL_FORM_FIELD_STRING.fr.d.ts.map +1 -1
  169. package/dist/esm/i18n/components/LOW_LEVEL_FORM_FIELD_STRING.fr.js +2 -1
  170. package/dist/esm/i18n/components/LOW_LEVEL_FORM_FIELD_STRING.fr.js.map +1 -1
  171. package/dist/esm/i18n/components/PUBLIC_LAYOUTS_MFA_CHALLENGE.en.d.ts +1 -0
  172. package/dist/esm/i18n/components/PUBLIC_LAYOUTS_MFA_CHALLENGE.en.d.ts.map +1 -1
  173. package/dist/esm/i18n/components/PUBLIC_LAYOUTS_MFA_CHALLENGE.en.js +2 -1
  174. package/dist/esm/i18n/components/PUBLIC_LAYOUTS_MFA_CHALLENGE.en.js.map +1 -1
  175. package/dist/esm/i18n/components/PUBLIC_LAYOUTS_MFA_CHALLENGE.fr.d.ts +1 -0
  176. package/dist/esm/i18n/components/PUBLIC_LAYOUTS_MFA_CHALLENGE.fr.d.ts.map +1 -1
  177. package/dist/esm/i18n/components/PUBLIC_LAYOUTS_MFA_CHALLENGE.fr.js +2 -1
  178. package/dist/esm/i18n/components/PUBLIC_LAYOUTS_MFA_CHALLENGE.fr.js.map +1 -1
  179. package/dist/esm/i18n/components/PUBLIC_LAYOUTS_TERMS.en.d.ts +2 -0
  180. package/dist/esm/i18n/components/PUBLIC_LAYOUTS_TERMS.en.d.ts.map +1 -1
  181. package/dist/esm/i18n/components/PUBLIC_LAYOUTS_TERMS.en.js +3 -1
  182. package/dist/esm/i18n/components/PUBLIC_LAYOUTS_TERMS.en.js.map +1 -1
  183. package/dist/esm/i18n/components/PUBLIC_LAYOUTS_TERMS.fr.d.ts +2 -0
  184. package/dist/esm/i18n/components/PUBLIC_LAYOUTS_TERMS.fr.d.ts.map +1 -1
  185. package/dist/esm/i18n/components/PUBLIC_LAYOUTS_TERMS.fr.js +3 -1
  186. package/dist/esm/i18n/components/PUBLIC_LAYOUTS_TERMS.fr.js.map +1 -1
  187. package/dist/esm/i18n/components/PUBLIC_LAYOUTS_USER_AUTH.en.d.ts +1 -1
  188. package/dist/esm/i18n/components/PUBLIC_LAYOUTS_USER_AUTH.en.js +1 -1
  189. package/dist/esm/i18n/components/PUBLIC_LAYOUTS_USER_AUTH.en.js.map +1 -1
  190. package/dist/esm/i18n/components/PUBLIC_LAYOUTS_USER_AUTH.fr.d.ts +1 -1
  191. package/dist/esm/i18n/components/PUBLIC_LAYOUTS_USER_AUTH.fr.js +1 -1
  192. package/dist/esm/i18n/components/PUBLIC_LAYOUTS_USER_AUTH.fr.js.map +1 -1
  193. package/dist/esm/i18n/components/RESOURCES_LAYOUTS_FILTERS.en.d.ts +2 -0
  194. package/dist/esm/i18n/components/RESOURCES_LAYOUTS_FILTERS.en.d.ts.map +1 -1
  195. package/dist/esm/i18n/components/RESOURCES_LAYOUTS_FILTERS.en.js +3 -1
  196. package/dist/esm/i18n/components/RESOURCES_LAYOUTS_FILTERS.en.js.map +1 -1
  197. package/dist/esm/i18n/components/RESOURCES_LAYOUTS_FILTERS.fr.d.ts +3 -1
  198. package/dist/esm/i18n/components/RESOURCES_LAYOUTS_FILTERS.fr.d.ts.map +1 -1
  199. package/dist/esm/i18n/components/RESOURCES_LAYOUTS_FILTERS.fr.js +4 -2
  200. package/dist/esm/i18n/components/RESOURCES_LAYOUTS_FILTERS.fr.js.map +1 -1
  201. package/dist/esm/i18n/components/RESOURCES_LAYOUTS_LIST.en.d.ts +17 -0
  202. package/dist/esm/i18n/components/RESOURCES_LAYOUTS_LIST.en.d.ts.map +1 -1
  203. package/dist/esm/i18n/components/RESOURCES_LAYOUTS_LIST.en.js +18 -1
  204. package/dist/esm/i18n/components/RESOURCES_LAYOUTS_LIST.en.js.map +1 -1
  205. package/dist/esm/i18n/components/RESOURCES_LAYOUTS_LIST.fr.d.ts +17 -0
  206. package/dist/esm/i18n/components/RESOURCES_LAYOUTS_LIST.fr.d.ts.map +1 -1
  207. package/dist/esm/i18n/components/RESOURCES_LAYOUTS_LIST.fr.js +18 -1
  208. package/dist/esm/i18n/components/RESOURCES_LAYOUTS_LIST.fr.js.map +1 -1
  209. package/dist/esm/i18n/composite_views/app.creation-conversation.fr.d.ts +206 -195
  210. package/dist/esm/i18n/composite_views/app.creation-conversation.fr.d.ts.map +1 -1
  211. package/dist/esm/i18n/composite_views/app.creation-conversation.fr.js +206 -195
  212. package/dist/esm/i18n/composite_views/app.creation-conversation.fr.js.map +1 -1
  213. package/dist/esm/i18n/composite_views/app.creation-dossier.fr.d.ts +10 -0
  214. package/dist/esm/i18n/composite_views/app.creation-dossier.fr.d.ts.map +1 -1
  215. package/dist/esm/i18n/composite_views/app.creation-dossier.fr.js +12 -2
  216. package/dist/esm/i18n/composite_views/app.creation-dossier.fr.js.map +1 -1
  217. package/dist/esm/i18n/resources/wildoApplicationActorSystemExecutions.fr.d.ts +70 -0
  218. package/dist/esm/i18n/resources/wildoApplicationActorSystemExecutions.fr.d.ts.map +1 -1
  219. package/dist/esm/i18n/resources/wildoApplicationActorSystemExecutions.fr.js +70 -0
  220. package/dist/esm/i18n/resources/wildoApplicationActorSystemExecutions.fr.js.map +1 -1
  221. package/dist/esm/i18n/resources/wildoApplicationActorTasks.fr.d.ts +12 -2
  222. package/dist/esm/i18n/resources/wildoApplicationActorTasks.fr.d.ts.map +1 -1
  223. package/dist/esm/i18n/resources/wildoApplicationActorTasks.fr.js +12 -2
  224. package/dist/esm/i18n/resources/wildoApplicationActorTasks.fr.js.map +1 -1
  225. package/dist/esm/i18n/resources/wildoApplicationFlowSystemExecutions.fr.d.ts +10 -0
  226. package/dist/esm/i18n/resources/wildoApplicationFlowSystemExecutions.fr.d.ts.map +1 -1
  227. package/dist/esm/i18n/resources/wildoApplicationFlowSystemExecutions.fr.js +10 -0
  228. package/dist/esm/i18n/resources/wildoApplicationFlowSystemExecutions.fr.js.map +1 -1
  229. package/dist/esm/i18n/resources/workbenchAspects.en.d.ts.map +1 -1
  230. package/dist/esm/i18n/resources/workbenchAspects.en.js +4 -0
  231. package/dist/esm/i18n/resources/workbenchAspects.en.js.map +1 -1
  232. package/dist/esm/i18n/resources/workbenchBuildDispatchPlan.fr.d.ts +25 -20
  233. package/dist/esm/i18n/resources/workbenchBuildDispatchPlan.fr.d.ts.map +1 -1
  234. package/dist/esm/i18n/resources/workbenchBuildDispatchPlan.fr.js +25 -20
  235. package/dist/esm/i18n/resources/workbenchBuildDispatchPlan.fr.js.map +1 -1
  236. package/dist/esm/i18n/resources/workbenchBuildPlanTasks.fr.d.ts +32 -32
  237. package/dist/esm/i18n/resources/workbenchBuildPlanTasks.fr.js +32 -32
  238. package/dist/esm/i18n/resources/workbenchBuildPlanTasks.fr.js.map +1 -1
  239. package/dist/esm/i18n/resources/workbenchBuildTaskRecords.fr.d.ts +65 -65
  240. package/dist/esm/i18n/resources/workbenchBuildTaskRecords.fr.js +65 -65
  241. package/dist/esm/i18n/resources/workbenchBuildTaskRecords.fr.js.map +1 -1
  242. package/dist/esm/i18n/resources/workbenchDossierEntries.fr.d.ts +20 -0
  243. package/dist/esm/i18n/resources/workbenchDossierEntries.fr.d.ts.map +1 -1
  244. package/dist/esm/i18n/resources/workbenchDossierEntries.fr.js +20 -0
  245. package/dist/esm/i18n/resources/workbenchDossierEntries.fr.js.map +1 -1
  246. package/dist/esm/i18n/resources/workbenchGovernanceQuestions.fr.d.ts +12 -0
  247. package/dist/esm/i18n/resources/workbenchGovernanceQuestions.fr.d.ts.map +1 -1
  248. package/dist/esm/i18n/resources/workbenchGovernanceQuestions.fr.js +13 -1
  249. package/dist/esm/i18n/resources/workbenchGovernanceQuestions.fr.js.map +1 -1
  250. package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.en.d.ts +35 -0
  251. package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.en.d.ts.map +1 -1
  252. package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.en.js +12 -0
  253. package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.en.js.map +1 -1
  254. package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.fr.d.ts +536 -531
  255. package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.fr.d.ts.map +1 -1
  256. package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.fr.js +536 -531
  257. package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.fr.js.map +1 -1
  258. package/dist/esm/i18n/system_enums/application-creation.fr.d.ts +170 -170
  259. package/dist/esm/i18n/system_enums/application-creation.fr.js +170 -170
  260. package/dist/esm/i18n/system_enums/application-creation.fr.js.map +1 -1
  261. package/dist/esm/i18n/system_enums/flows-actors.fr.d.ts +22 -22
  262. package/dist/esm/i18n/system_enums/flows-actors.fr.js +22 -22
  263. package/dist/esm/i18n/system_enums/flows-actors.fr.js.map +1 -1
  264. package/dist/esm/i18n/system_enums/run-records.fr.d.ts +21 -21
  265. package/dist/esm/i18n/system_enums/run-records.fr.js +21 -21
  266. package/dist/esm/i18n/system_enums/run-records.fr.js.map +1 -1
  267. package/dist/esm/i18n/system_enums/workbench-build.en.d.ts +3 -2
  268. package/dist/esm/i18n/system_enums/workbench-build.en.d.ts.map +1 -1
  269. package/dist/esm/i18n/system_enums/workbench-build.en.js +3 -2
  270. package/dist/esm/i18n/system_enums/workbench-build.en.js.map +1 -1
  271. package/dist/esm/i18n/system_enums/workbench-build.fr.d.ts +37 -33
  272. package/dist/esm/i18n/system_enums/workbench-build.fr.d.ts.map +1 -1
  273. package/dist/esm/i18n/system_enums/workbench-build.fr.js +37 -33
  274. package/dist/esm/i18n/system_enums/workbench-build.fr.js.map +1 -1
  275. package/dist/esm/i18n/system_enums/workbench-creation-home.en.d.ts +1 -0
  276. package/dist/esm/i18n/system_enums/workbench-creation-home.en.d.ts.map +1 -1
  277. package/dist/esm/i18n/system_enums/workbench-creation-home.en.js +1 -0
  278. package/dist/esm/i18n/system_enums/workbench-creation-home.en.js.map +1 -1
  279. package/dist/esm/i18n/system_enums/workbench-creation-home.fr.d.ts +18 -17
  280. package/dist/esm/i18n/system_enums/workbench-creation-home.fr.d.ts.map +1 -1
  281. package/dist/esm/i18n/system_enums/workbench-creation-home.fr.js +18 -17
  282. package/dist/esm/i18n/system_enums/workbench-creation-home.fr.js.map +1 -1
  283. package/dist/esm/i18n/system_enums/workbench-dossier.fr.d.ts +7 -5
  284. package/dist/esm/i18n/system_enums/workbench-dossier.fr.d.ts.map +1 -1
  285. package/dist/esm/i18n/system_enums/workbench-dossier.fr.js +8 -6
  286. package/dist/esm/i18n/system_enums/workbench-dossier.fr.js.map +1 -1
  287. package/dist/esm/i18n/system_enums/workbench-secrets.fr.d.ts +12 -12
  288. package/dist/esm/i18n/system_enums/workbench-secrets.fr.js +12 -12
  289. package/dist/esm/i18n/system_enums/workbench-secrets.fr.js.map +1 -1
  290. package/dist/esm/i18n/system_enums/workbench-specification-artifact.fr.d.ts +1 -0
  291. package/dist/esm/i18n/system_enums/workbench-specification-artifact.fr.d.ts.map +1 -1
  292. package/dist/esm/i18n/system_enums/workbench-specification-artifact.fr.js +2 -1
  293. package/dist/esm/i18n/system_enums/workbench-specification-artifact.fr.js.map +1 -1
  294. package/dist/esm/i18n-labelling/services/email-template-labelling-units.companion.service.d.ts.map +1 -1
  295. package/dist/esm/i18n-labelling/services/email-template-labelling-units.companion.service.js +7 -3
  296. package/dist/esm/i18n-labelling/services/email-template-labelling-units.companion.service.js.map +1 -1
  297. package/dist/esm/i18n-labelling/services/labelling-planner.companion.service.d.ts.map +1 -1
  298. package/dist/esm/i18n-labelling/services/labelling-planner.companion.service.js +3 -4
  299. package/dist/esm/i18n-labelling/services/labelling-planner.companion.service.js.map +1 -1
  300. package/dist/esm/i18n-labelling/utils/declared-refusal-codes.utils.d.ts +11 -0
  301. package/dist/esm/i18n-labelling/utils/declared-refusal-codes.utils.d.ts.map +1 -1
  302. package/dist/esm/i18n-labelling/utils/declared-refusal-codes.utils.js +21 -0
  303. package/dist/esm/i18n-labelling/utils/declared-refusal-codes.utils.js.map +1 -1
  304. package/dist/esm/meta-workflows/models/creation-journey-timeline.models.d.ts +9 -0
  305. package/dist/esm/meta-workflows/models/creation-journey-timeline.models.d.ts.map +1 -1
  306. package/dist/esm/meta-workflows/models/creation-journey-timeline.models.js +18 -2
  307. package/dist/esm/meta-workflows/models/creation-journey-timeline.models.js.map +1 -1
  308. package/dist/esm/meta-workflows/services/application-build-dispatch.companion.service.d.ts +153 -22
  309. package/dist/esm/meta-workflows/services/application-build-dispatch.companion.service.d.ts.map +1 -1
  310. package/dist/esm/meta-workflows/services/application-build-dispatch.companion.service.js +970 -208
  311. package/dist/esm/meta-workflows/services/application-build-dispatch.companion.service.js.map +1 -1
  312. package/dist/esm/meta-workflows/services/application-build-follow-up-derivation.companion.d.ts +115 -13
  313. package/dist/esm/meta-workflows/services/application-build-follow-up-derivation.companion.d.ts.map +1 -1
  314. package/dist/esm/meta-workflows/services/application-build-follow-up-derivation.companion.js +295 -56
  315. package/dist/esm/meta-workflows/services/application-build-follow-up-derivation.companion.js.map +1 -1
  316. package/dist/esm/meta-workflows/services/application-build-landing-projection.companion.d.ts +3 -3
  317. package/dist/esm/meta-workflows/services/application-build-landing-projection.companion.js +3 -3
  318. package/dist/esm/meta-workflows/services/application-build-landing-projection.companion.js.map +1 -1
  319. package/dist/esm/meta-workflows/services/application-build-task-closure.companion.d.ts +9 -0
  320. package/dist/esm/meta-workflows/services/application-build-task-closure.companion.d.ts.map +1 -1
  321. package/dist/esm/meta-workflows/services/application-build-task-closure.companion.js +19 -0
  322. package/dist/esm/meta-workflows/services/application-build-task-closure.companion.js.map +1 -1
  323. package/dist/esm/meta-workflows/services/application-build-task-coding-policy.companion.service.d.ts +1 -1
  324. package/dist/esm/meta-workflows/services/application-build-task-coding-policy.companion.service.d.ts.map +1 -1
  325. package/dist/esm/meta-workflows/services/application-build-task-coding-policy.companion.service.js +48 -26
  326. package/dist/esm/meta-workflows/services/application-build-task-coding-policy.companion.service.js.map +1 -1
  327. package/dist/esm/meta-workflows/services/build-task-brief-application-facts.companion.d.ts +12 -0
  328. package/dist/esm/meta-workflows/services/build-task-brief-application-facts.companion.d.ts.map +1 -1
  329. package/dist/esm/meta-workflows/services/build-task-brief-application-facts.companion.js +30 -1
  330. package/dist/esm/meta-workflows/services/build-task-brief-application-facts.companion.js.map +1 -1
  331. package/dist/esm/meta-workflows/services/creation-intervention-ledger.companion.service.d.ts.map +1 -1
  332. package/dist/esm/meta-workflows/services/creation-intervention-ledger.companion.service.js +4 -5
  333. package/dist/esm/meta-workflows/services/creation-intervention-ledger.companion.service.js.map +1 -1
  334. package/dist/esm/meta-workflows/services/creation-run-report.companion.service.d.ts.map +1 -1
  335. package/dist/esm/meta-workflows/services/creation-run-report.companion.service.js +12 -1
  336. package/dist/esm/meta-workflows/services/creation-run-report.companion.service.js.map +1 -1
  337. package/dist/esm/meta-workflows/services/foundation-executor.companion.service.d.ts.map +1 -1
  338. package/dist/esm/meta-workflows/services/foundation-executor.companion.service.js +6 -3
  339. package/dist/esm/meta-workflows/services/foundation-executor.companion.service.js.map +1 -1
  340. package/dist/esm/meta-workflows/services/playbook-run-write-register-window.companion.d.ts.map +1 -1
  341. package/dist/esm/meta-workflows/services/playbook-run-write-register-window.companion.js +3 -5
  342. package/dist/esm/meta-workflows/services/playbook-run-write-register-window.companion.js.map +1 -1
  343. package/dist/esm/meta-workflows/services/playbook-run.companion.service.d.ts +8 -1
  344. package/dist/esm/meta-workflows/services/playbook-run.companion.service.d.ts.map +1 -1
  345. package/dist/esm/meta-workflows/services/playbook-run.companion.service.js +119 -25
  346. package/dist/esm/meta-workflows/services/playbook-run.companion.service.js.map +1 -1
  347. package/dist/esm/meta-workflows/services/provider-registry-brief.companion.utils.d.ts +55 -1
  348. package/dist/esm/meta-workflows/services/provider-registry-brief.companion.utils.d.ts.map +1 -1
  349. package/dist/esm/meta-workflows/services/provider-registry-brief.companion.utils.js +157 -10
  350. package/dist/esm/meta-workflows/services/provider-registry-brief.companion.utils.js.map +1 -1
  351. package/dist/esm/module-layout/module-layout-convention.companion.d.ts +158 -0
  352. package/dist/esm/module-layout/module-layout-convention.companion.d.ts.map +1 -0
  353. package/dist/esm/module-layout/module-layout-convention.companion.js +272 -0
  354. package/dist/esm/module-layout/module-layout-convention.companion.js.map +1 -0
  355. package/dist/esm/module-layout/module-layout-inspection.companion.d.ts +42 -0
  356. package/dist/esm/module-layout/module-layout-inspection.companion.d.ts.map +1 -0
  357. package/dist/esm/module-layout/module-layout-inspection.companion.js +290 -0
  358. package/dist/esm/module-layout/module-layout-inspection.companion.js.map +1 -0
  359. package/dist/esm/module-layout/module-source-files.companion.d.ts +3 -0
  360. package/dist/esm/module-layout/module-source-files.companion.d.ts.map +1 -0
  361. package/dist/esm/module-layout/module-source-files.companion.js +45 -0
  362. package/dist/esm/module-layout/module-source-files.companion.js.map +1 -0
  363. package/package.json +18 -18
@@ -1,4 +1,19 @@
1
1
  import { type CompanionEmailTemplateOwnershipDescriptor } from '@wildo-ai/saas-models/companion';
2
+ import type { ModuleEmailTemplateLayout } from './module-email-root.companion.utils';
3
+ /**
4
+ * An owner as the `email-template-placement-info` introspection reports it: the shared descriptor, plus, for a business
5
+ * module, the layout read from its definitions file (#3904 review F2, F5). Absent for the engine owner, whose layout is
6
+ * the skeleton's (`system/` and `resources/` under `backend-api/src/engine/email`).
7
+ */
8
+ export interface EmailTemplateOwnershipPlacement extends CompanionEmailTemplateOwnershipDescriptor {
9
+ readonly backendEmailLayout?: ModuleEmailTemplateLayout;
10
+ }
11
+ /** A template the generation step will not write, because where its owner registers it cannot be read (#3904 review F2). */
12
+ export interface UnplacedEmailTemplate {
13
+ readonly ownerId: string;
14
+ readonly templateRef: string;
15
+ readonly reason: string;
16
+ }
2
17
  export interface EmailTemplateArtifactTarget {
3
18
  ownerId: string;
4
19
  templateRef: string;
@@ -29,8 +44,17 @@ export declare function listTemplateRefsUnderEmailRoot(emailRoot: string): Promi
29
44
  * application lacks is one an application created today would have; adding it here lets the run seed it from the canon
30
45
  * with no model call, and lets a caller name it. A domain module's refs are its own and are left alone.
31
46
  */
32
- export declare function withDeliveredCanonEngineRefs(ownership: CompanionEmailTemplateOwnershipDescriptor[], canonRefs: readonly string[]): CompanionEmailTemplateOwnershipDescriptor[];
33
- export declare function resolveEmailTemplateArtifactTargets(workspaceRoot: string, ownership: CompanionEmailTemplateOwnershipDescriptor[], templateRefs?: string[]): EmailTemplateArtifactTarget[];
47
+ export declare function withDeliveredCanonEngineRefs<Owner extends CompanionEmailTemplateOwnershipDescriptor>(ownership: Owner[], canonRefs: readonly string[]): Owner[];
48
+ export declare function resolveEmailTemplateArtifactTargets(workspaceRoot: string, ownership: readonly EmailTemplateOwnershipPlacement[], templateRefs?: string[]): EmailTemplateArtifactTarget[];
49
+ /**
50
+ * Where each owned template is written (`targets`), and the templates that are NOT written because their owner's
51
+ * registration cannot be read (`unplaced`, #3904 review F2). A caller that generates must report the unplaced ones; one
52
+ * that only lists files may ignore them.
53
+ */
54
+ export declare function resolveEmailTemplateArtifactPlacement(workspaceRoot: string, ownership: readonly EmailTemplateOwnershipPlacement[], templateRefs?: string[]): {
55
+ readonly targets: EmailTemplateArtifactTarget[];
56
+ readonly unplaced: UnplacedEmailTemplate[];
57
+ };
34
58
  export declare function readUtf8File(p: string): Promise<string>;
35
59
  export declare function writeUtf8File(p: string, content: string): Promise<void>;
36
60
  export declare function labelsFilePath(dirPath: string, localeCode: string): string;
@@ -1 +1 @@
1
- {"version":3,"file":"email-template-fs-discovery.utils.d.ts","sourceRoot":"","sources":["../../../../src/email/utils/email-template-fs-discovery.utils.ts"],"names":[],"mappings":"AAGA,OAAO,EAA0B,KAAK,yCAAyC,EAAE,MAAM,iCAAiC,CAAC;AAEzH,MAAM,WAAW,2BAA2B;IAC1C,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,wBAAwB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAqBpE;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAKhF;AAED;;;;GAIG;AACH,wBAAsB,8BAA8B,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAoBzF;AAED;;;;;;;;GAQG;AACH,wBAAgB,4BAA4B,CAC1C,SAAS,EAAE,yCAAyC,EAAE,EACtD,SAAS,EAAE,SAAS,MAAM,EAAE,GAC3B,yCAAyC,EAAE,CAK7C;AAED,wBAAgB,mCAAmC,CACjD,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,yCAAyC,EAAE,EACtD,YAAY,CAAC,EAAE,MAAM,EAAE,GACtB,2BAA2B,EAAE,CAgC/B;AAED,wBAAsB,YAAY,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAE7D;AAED,wBAAsB,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAG7E;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAE1E;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAExD;AAED,wBAAsB,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAO5D"}
1
+ {"version":3,"file":"email-template-fs-discovery.utils.d.ts","sourceRoot":"","sources":["../../../../src/email/utils/email-template-fs-discovery.utils.ts"],"names":[],"mappings":"AAGA,OAAO,EAA0B,KAAK,yCAAyC,EAAE,MAAM,iCAAiC,CAAC;AAEzH,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AAErF;;;;GAIG;AACH,MAAM,WAAW,+BAAgC,SAAQ,yCAAyC;IAChG,QAAQ,CAAC,kBAAkB,CAAC,EAAE,yBAAyB,CAAC;CACzD;AAED,4HAA4H;AAC5H,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,2BAA2B;IAC1C,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,wBAAwB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAqBpE;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAKhF;AAED;;;;GAIG;AACH,wBAAsB,8BAA8B,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAoBzF;AAED;;;;;;;;GAQG;AACH,wBAAgB,4BAA4B,CAAC,KAAK,SAAS,yCAAyC,EAClG,SAAS,EAAE,KAAK,EAAE,EAClB,SAAS,EAAE,SAAS,MAAM,EAAE,GAC3B,KAAK,EAAE,CAKT;AAED,wBAAgB,mCAAmC,CACjD,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,SAAS,+BAA+B,EAAE,EACrD,YAAY,CAAC,EAAE,MAAM,EAAE,GACtB,2BAA2B,EAAE,CAE/B;AAyBD;;;;GAIG;AACH,wBAAgB,qCAAqC,CACnD,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,SAAS,+BAA+B,EAAE,EACrD,YAAY,CAAC,EAAE,MAAM,EAAE,GACtB;IAAE,QAAQ,CAAC,OAAO,EAAE,2BAA2B,EAAE,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,qBAAqB,EAAE,CAAA;CAAE,CAmCjG;AAED,wBAAsB,YAAY,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAE7D;AAED,wBAAsB,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAG7E;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAE1E;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAExD;AAED,wBAAsB,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAO5D"}
@@ -77,8 +77,41 @@ export function withDeliveredCanonEngineRefs(ownership, canonRefs) {
77
77
  : owner));
78
78
  }
79
79
  export function resolveEmailTemplateArtifactTargets(workspaceRoot, ownership, templateRefs) {
80
+ return resolveEmailTemplateArtifactPlacement(workspaceRoot, ownership, templateRefs).targets;
81
+ }
82
+ /**
83
+ * The directory a template is written to, relative to its owner's email root (#3904 review F5): the folder the owner's
84
+ * scanner registers the ref's family from (`email.` → its `subdir`), then the ref's path within it, derived as the
85
+ * standard `keyFromPath` derives it. An owner with no layout (the engine) uses the standard folders. A family the owner's
86
+ * definitions file registers from no readable folder is unplaced, with the reason.
87
+ */
88
+ function templateDirectoryUnderRoot(templateRef, layout) {
89
+ const standard = templateRefToRelativeDir(templateRef);
90
+ if (layout === undefined)
91
+ return { relativeDir: standard };
92
+ if (!layout.determined)
93
+ return { reason: layout.reason };
94
+ const prefix = templateRef.slice(0, templateRef.indexOf('.') + 1);
95
+ const directory = layout.directoriesByRefPrefix[prefix];
96
+ if (directory === undefined) {
97
+ return {
98
+ reason: `${layout.definitionsFile} registers no \`${prefix}\` refs from a folder that can be read`
99
+ + (layout.undeterminedScannerCalls > 0 ? ` (${layout.undeterminedScannerCalls} of its scanner call(s) have a \`subdir\` or \`keyFromPath\` that is not a literal)` : '')
100
+ + ', so nothing is written for it',
101
+ };
102
+ }
103
+ const withinFamily = standard.slice(standard.indexOf('/') + 1);
104
+ return { relativeDir: directory === '.' ? withinFamily : path.posix.join(directory, withinFamily) };
105
+ }
106
+ /**
107
+ * Where each owned template is written (`targets`), and the templates that are NOT written because their owner's
108
+ * registration cannot be read (`unplaced`, #3904 review F2). A caller that generates must report the unplaced ones; one
109
+ * that only lists files may ignore them.
110
+ */
111
+ export function resolveEmailTemplateArtifactPlacement(workspaceRoot, ownership, templateRefs) {
80
112
  const allow = templateRefs?.length ? new Set(templateRefs) : null;
81
113
  const deduped = new Map();
114
+ const unplaced = new Map();
82
115
  for (const owner of ownership) {
83
116
  const backendRoot = owner.rootsByRole.backend;
84
117
  if (!backendRoot) {
@@ -88,7 +121,13 @@ export function resolveEmailTemplateArtifactTargets(workspaceRoot, ownership, te
88
121
  if (allow && !allow.has(templateRef)) {
89
122
  continue;
90
123
  }
91
- const dirPath = path.resolve(workspaceRoot, backendRoot, templateRefToRelativeDir(templateRef));
124
+ const placement = templateDirectoryUnderRoot(templateRef, owner.backendEmailLayout);
125
+ if ('reason' in placement) {
126
+ unplaced.set(templateRef, { ownerId: owner.ownerId, templateRef, reason: placement.reason });
127
+ continue;
128
+ }
129
+ const dirPath = path.resolve(workspaceRoot, backendRoot, placement.relativeDir);
130
+ unplaced.delete(templateRef);
92
131
  deduped.set(templateRef, {
93
132
  ownerId: owner.ownerId,
94
133
  templateRef,
@@ -98,7 +137,7 @@ export function resolveEmailTemplateArtifactTargets(workspaceRoot, ownership, te
98
137
  });
99
138
  }
100
139
  }
101
- return Array.from(deduped.values());
140
+ return { targets: Array.from(deduped.values()), unplaced: [...unplaced.values()].filter((entry) => !deduped.has(entry.templateRef)) };
102
141
  }
103
142
  export async function readUtf8File(p) {
104
143
  return fs.readFile(p, 'utf-8');
@@ -1 +1 @@
1
- {"version":3,"file":"email-template-fs-discovery.utils.js","sourceRoot":"","sources":["../../../../src/email/utils/email-template-fs-discovery.utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,sBAAsB,EAAkD,MAAM,iCAAiC,CAAC;AAUzH,MAAM,UAAU,wBAAwB,CAAC,WAAmB;IAC1D,IAAI,WAAW,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QACtC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CACpB,QAAQ,EACR,WAAW;aACR,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC;aACvB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;aACnB,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CACtB,CAAC;IACJ,CAAC;IAED,IAAI,WAAW,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QACrC,MAAM,CAAC,EAAE,YAAY,EAAE,GAAG,SAAS,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC9D,IAAI,CAAC,YAAY,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC5C,MAAM,IAAI,KAAK,CAAC,wCAAwC,WAAW,EAAE,CAAC,CAAC;QACzE,CAAC;QAED,OAAO,IAAI,CAAC,KAAK,C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OAAO,EAAE,UAAU,UAAU,KAAK,CAAC,CAAC;AACvD,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,OAAe;IAC9C,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;AAC5C,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,CAAS;IACxC,IAAI,CAAC;QACH,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC5B,OAAO,EAAE,CAAC,MAAM,EAAE,CAAC;IACrB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC","sourcesContent":["import type { Dirent } from 'fs';\nimport * as fs from 'fs/promises';\nimport * as path from 'path';\nimport { CompanionArtifactClass, type CompanionEmailTemplateOwnershipDescriptor } from '@wildo-ai/saas-models/companion';\n\nexport interface EmailTemplateArtifactTarget {\n ownerId: string;\n templateRef: string;\n dirPath: string;\n templatePath: string;\n backendRoot: string;\n}\n\nexport function templateRefToRelativeDir(templateRef: string): string {\n if (templateRef.startsWith('system.')) {\n return path.posix.join(\n 'system',\n templateRef\n .slice('system.'.length)\n .replace(/\\./g, '/')\n .replace(/_/g, '-'),\n );\n }\n\n if (templateRef.startsWith('email.')) {\n const [, resourceType, ...remainder] = templateRef.split('.');\n if (!resourceType || remainder.length === 0) {\n throw new Error(`Invalid resource email template ref: ${templateRef}`);\n }\n\n return path.posix.join('resources', resourceType, remainder.join('.'));\n }\n\n throw new Error(`Unsupported email template ref: ${templateRef}`);\n}\n\n/**\n * The ref a template directory registers as, given its path RELATIVE to an email root (`system/...` or `resources/...`).\n * The inverse of {@link templateRefToRelativeDir}, and the same derivation as the `keyFromPath` an application's\n * `email-template-definitions.ts` gives its scanner: `system/{name}` registers as `system.{name, - → _, / → .}` and\n * `resources/{path}` as `email.{path, / → .}`. Undefined for any other directory.\n */\nexport function relativeDirToTemplateRef(relativeDir: string): string | undefined {\n const posix = relativeDir.split(path.sep).join('/');\n if (posix.startsWith('system/')) return `system.${posix.slice('system/'.length).replace(/-/g, '_').replace(/\\//g, '.')}`;\n if (posix.startsWith('resources/')) return `email.${posix.slice('resources/'.length).replace(/\\//g, '.')}`;\n return undefined;\n}\n\n/**\n * Every template ref an email root holds: each directory under its `system/` and `resources/` that contains a\n * `template.tsx`. Read from the delivered engine canon (#3156) to know which engine templates exist at all, since the\n * application's own registry lists only the folders it already has. An absent root holds none.\n */\nexport async function listTemplateRefsUnderEmailRoot(emailRoot: string): Promise<string[]> {\n const refs: string[] = [];\n const walk = async (relativeDir: string): Promise<void> => {\n let entries: Dirent[];\n try {\n entries = await fs.readdir(path.join(emailRoot, relativeDir), { withFileTypes: true });\n } catch {\n return;\n }\n if (entries.some((entry) => entry.isFile() && entry.name === 'template.tsx')) {\n const ref = relativeDirToTemplateRef(relativeDir);\n if (ref) refs.push(ref);\n }\n for (const entry of entries) {\n if (entry.isDirectory()) await walk(path.join(relativeDir, entry.name));\n }\n };\n await walk('system');\n await walk('resources');\n return refs.sort();\n}\n\n/**\n * The ownership, with the ENGINE owner also answering for every engine template the delivered canon carries (#3156).\n *\n * The engine owner's refs come from the application's own registry, which SCANS the application's email folders, so a\n * template the engine added after the application was created was in no target list: `wildo generate email` could not\n * deliver it, and asking for it by ref was refused as unknown. `wildo init` copies the whole canon, so a canon ref the\n * application lacks is one an application created today would have; adding it here lets the run seed it from the canon\n * with no model call, and lets a caller name it. A domain module's refs are its own and are left alone.\n */\nexport function withDeliveredCanonEngineRefs(\n ownership: CompanionEmailTemplateOwnershipDescriptor[],\n canonRefs: readonly string[],\n): CompanionEmailTemplateOwnershipDescriptor[] {\n if (canonRefs.length === 0) return ownership;\n return ownership.map((owner) => (owner.artifactClass === CompanionArtifactClass.ENGINE\n ? { ...owner, templateRefs: [...new Set([...owner.templateRefs, ...canonRefs])] }\n : owner));\n}\n\nexport function resolveEmailTemplateArtifactTargets(\n workspaceRoot: string,\n ownership: CompanionEmailTemplateOwnershipDescriptor[],\n templateRefs?: string[],\n): EmailTemplateArtifactTarget[] {\n const allow = templateRefs?.length ? new Set(templateRefs) : null;\n const deduped = new Map<string, EmailTemplateArtifactTarget>();\n\n for (const owner of ownership) {\n const backendRoot = owner.rootsByRole.backend;\n if (!backendRoot) {\n continue;\n }\n\n for (const templateRef of owner.templateRefs) {\n if (allow && !allow.has(templateRef)) {\n continue;\n }\n\n const dirPath = path.resolve(\n workspaceRoot,\n backendRoot,\n templateRefToRelativeDir(templateRef),\n );\n\n deduped.set(templateRef, {\n ownerId: owner.ownerId,\n templateRef,\n dirPath,\n templatePath: templateFilePath(dirPath),\n backendRoot,\n });\n }\n }\n\n return Array.from(deduped.values());\n}\n\nexport async function readUtf8File(p: string): Promise<string> {\n return fs.readFile(p, 'utf-8');\n}\n\nexport async function writeUtf8File(p: string, content: string): Promise<void> {\n await fs.mkdir(path.dirname(p), { recursive: true });\n await fs.writeFile(p, content, 'utf-8');\n}\n\nexport function labelsFilePath(dirPath: string, localeCode: string): string {\n return path.join(dirPath, `labels.${localeCode}.ts`);\n}\n\nexport function templateFilePath(dirPath: string): string {\n return path.join(dirPath, 'template.tsx');\n}\n\nexport async function fileExists(p: string): Promise<boolean> {\n try {\n const st = await fs.stat(p);\n return st.isFile();\n } catch {\n return false;\n }\n}\n"]}
1
+ {"version":3,"file":"email-template-fs-discovery.utils.js","sourceRoot":"","sources":["../../../../src/email/utils/email-template-fs-discovery.utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,sBAAsB,EAAkD,MAAM,iCAAiC,CAAC;AA4BzH,MAAM,UAAU,wBAAwB,CAAC,WAAmB;IAC1D,IAAI,WAAW,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QACtC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CACpB,QAAQ,EACR,WAAW;a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,CAAC;AAC5C,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,CAAS;IACxC,IAAI,CAAC;QACH,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC5B,OAAO,EAAE,CAAC,MAAM,EAAE,CAAC;IACrB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC","sourcesContent":["import type { Dirent } from 'fs';\nimport * as fs from 'fs/promises';\nimport * as path from 'path';\nimport { CompanionArtifactClass, type CompanionEmailTemplateOwnershipDescriptor } from '@wildo-ai/saas-models/companion';\n\nimport type { ModuleEmailTemplateLayout } from './module-email-root.companion.utils';\n\n/**\n * An owner as the `email-template-placement-info` introspection reports it: the shared descriptor, plus, for a business\n * module, the layout read from its definitions file (#3904 review F2, F5). Absent for the engine owner, whose layout is\n * the skeleton's (`system/` and `resources/` under `backend-api/src/engine/email`).\n */\nexport interface EmailTemplateOwnershipPlacement extends CompanionEmailTemplateOwnershipDescriptor {\n readonly backendEmailLayout?: ModuleEmailTemplateLayout;\n}\n\n/** A template the generation step will not write, because where its owner registers it cannot be read (#3904 review F2). */\nexport interface UnplacedEmailTemplate {\n readonly ownerId: string;\n readonly templateRef: string;\n readonly reason: string;\n}\n\nexport interface EmailTemplateArtifactTarget {\n ownerId: string;\n templateRef: string;\n dirPath: string;\n templatePath: string;\n backendRoot: string;\n}\n\nexport function templateRefToRelativeDir(templateRef: string): string {\n if (templateRef.startsWith('system.')) {\n return path.posix.join(\n 'system',\n templateRef\n .slice('system.'.length)\n .replace(/\\./g, '/')\n .replace(/_/g, '-'),\n );\n }\n\n if (templateRef.startsWith('email.')) {\n const [, resourceType, ...remainder] = templateRef.split('.');\n if (!resourceType || remainder.length === 0) {\n throw new Error(`Invalid resource email template ref: ${templateRef}`);\n }\n\n return path.posix.join('resources', resourceType, remainder.join('.'));\n }\n\n throw new Error(`Unsupported email template ref: ${templateRef}`);\n}\n\n/**\n * The ref a template directory registers as, given its path RELATIVE to an email root (`system/...` or `resources/...`).\n * The inverse of {@link templateRefToRelativeDir}, and the same derivation as the `keyFromPath` an application's\n * `email-template-definitions.ts` gives its scanner: `system/{name}` registers as `system.{name, - → _, / → .}` and\n * `resources/{path}` as `email.{path, / → .}`. Undefined for any other directory.\n */\nexport function relativeDirToTemplateRef(relativeDir: string): string | undefined {\n const posix = relativeDir.split(path.sep).join('/');\n if (posix.startsWith('system/')) return `system.${posix.slice('system/'.length).replace(/-/g, '_').replace(/\\//g, '.')}`;\n if (posix.startsWith('resources/')) return `email.${posix.slice('resources/'.length).replace(/\\//g, '.')}`;\n return undefined;\n}\n\n/**\n * Every template ref an email root holds: each directory under its `system/` and `resources/` that contains a\n * `template.tsx`. Read from the delivered engine canon (#3156) to know which engine templates exist at all, since the\n * application's own registry lists only the folders it already has. An absent root holds none.\n */\nexport async function listTemplateRefsUnderEmailRoot(emailRoot: string): Promise<string[]> {\n const refs: string[] = [];\n const walk = async (relativeDir: string): Promise<void> => {\n let entries: Dirent[];\n try {\n entries = await fs.readdir(path.join(emailRoot, relativeDir), { withFileTypes: true });\n } catch {\n return;\n }\n if (entries.some((entry) => entry.isFile() && entry.name === 'template.tsx')) {\n const ref = relativeDirToTemplateRef(relativeDir);\n if (ref) refs.push(ref);\n }\n for (const entry of entries) {\n if (entry.isDirectory()) await walk(path.join(relativeDir, entry.name));\n }\n };\n await walk('system');\n await walk('resources');\n return refs.sort();\n}\n\n/**\n * The ownership, with the ENGINE owner also answering for every engine template the delivered canon carries (#3156).\n *\n * The engine owner's refs come from the application's own registry, which SCANS the application's email folders, so a\n * template the engine added after the application was created was in no target list: `wildo generate email` could not\n * deliver it, and asking for it by ref was refused as unknown. `wildo init` copies the whole canon, so a canon ref the\n * application lacks is one an application created today would have; adding it here lets the run seed it from the canon\n * with no model call, and lets a caller name it. A domain module's refs are its own and are left alone.\n */\nexport function withDeliveredCanonEngineRefs<Owner extends CompanionEmailTemplateOwnershipDescriptor>(\n ownership: Owner[],\n canonRefs: readonly string[],\n): Owner[] {\n if (canonRefs.length === 0) return ownership;\n return ownership.map((owner) => (owner.artifactClass === CompanionArtifactClass.ENGINE\n ? { ...owner, templateRefs: [...new Set([...owner.templateRefs, ...canonRefs])] }\n : owner));\n}\n\nexport function resolveEmailTemplateArtifactTargets(\n workspaceRoot: string,\n ownership: readonly EmailTemplateOwnershipPlacement[],\n templateRefs?: string[],\n): EmailTemplateArtifactTarget[] {\n return resolveEmailTemplateArtifactPlacement(workspaceRoot, ownership, templateRefs).targets;\n}\n\n/**\n * The directory a template is written to, relative to its owner's email root (#3904 review F5): the folder the owner's\n * scanner registers the ref's family from (`email.` → its `subdir`), then the ref's path within it, derived as the\n * standard `keyFromPath` derives it. An owner with no layout (the engine) uses the standard folders. A family the owner's\n * definitions file registers from no readable folder is unplaced, with the reason.\n */\nfunction templateDirectoryUnderRoot(templateRef: string, layout: ModuleEmailTemplateLayout | undefined): { readonly relativeDir: string } | { readonly reason: string } {\n const standard = templateRefToRelativeDir(templateRef);\n if (layout === undefined) return { relativeDir: standard };\n if (!layout.determined) return { reason: layout.reason };\n const prefix = templateRef.slice(0, templateRef.indexOf('.') + 1);\n const directory = layout.directoriesByRefPrefix[prefix];\n if (directory === undefined) {\n return {\n reason: `${layout.definitionsFile} registers no \\`${prefix}\\` refs from a folder that can be read`\n + (layout.undeterminedScannerCalls > 0 ? ` (${layout.undeterminedScannerCalls} of its scanner call(s) have a \\`subdir\\` or \\`keyFromPath\\` that is not a literal)` : '')\n + ', so nothing is written for it',\n };\n }\n const withinFamily = standard.slice(standard.indexOf('/') + 1);\n return { relativeDir: directory === '.' ? withinFamily : path.posix.join(directory, withinFamily) };\n}\n\n/**\n * Where each owned template is written (`targets`), and the templates that are NOT written because their owner's\n * registration cannot be read (`unplaced`, #3904 review F2). A caller that generates must report the unplaced ones; one\n * that only lists files may ignore them.\n */\nexport function resolveEmailTemplateArtifactPlacement(\n workspaceRoot: string,\n ownership: readonly EmailTemplateOwnershipPlacement[],\n templateRefs?: string[],\n): { readonly targets: EmailTemplateArtifactTarget[]; readonly unplaced: UnplacedEmailTemplate[] } {\n const allow = templateRefs?.length ? new Set(templateRefs) : null;\n const deduped = new Map<string, EmailTemplateArtifactTarget>();\n const unplaced = new Map<string, UnplacedEmailTemplate>();\n\n for (const owner of ownership) {\n const backendRoot = owner.rootsByRole.backend;\n if (!backendRoot) {\n continue;\n }\n\n for (const templateRef of owner.templateRefs) {\n if (allow && !allow.has(templateRef)) {\n continue;\n }\n\n const placement = templateDirectoryUnderRoot(templateRef, owner.backendEmailLayout);\n if ('reason' in placement) {\n unplaced.set(templateRef, { ownerId: owner.ownerId, templateRef, reason: placement.reason });\n continue;\n }\n const dirPath = path.resolve(workspaceRoot, backendRoot, placement.relativeDir);\n\n unplaced.delete(templateRef);\n deduped.set(templateRef, {\n ownerId: owner.ownerId,\n templateRef,\n dirPath,\n templatePath: templateFilePath(dirPath),\n backendRoot,\n });\n }\n }\n\n return { targets: Array.from(deduped.values()), unplaced: [...unplaced.values()].filter((entry) => !deduped.has(entry.templateRef)) };\n}\n\nexport async function readUtf8File(p: string): Promise<string> {\n return fs.readFile(p, 'utf-8');\n}\n\nexport async function writeUtf8File(p: string, content: string): Promise<void> {\n await fs.mkdir(path.dirname(p), { recursive: true });\n await fs.writeFile(p, content, 'utf-8');\n}\n\nexport function labelsFilePath(dirPath: string, localeCode: string): string {\n return path.join(dirPath, `labels.${localeCode}.ts`);\n}\n\nexport function templateFilePath(dirPath: string): string {\n return path.join(dirPath, 'template.tsx');\n}\n\nexport async function fileExists(p: string): Promise<boolean> {\n try {\n const st = await fs.stat(p);\n return st.isFile();\n } catch {\n return false;\n }\n}\n"]}
@@ -0,0 +1,19 @@
1
+ /** The engine function every module email definitions file calls to read its templates from disk. */
2
+ export declare const EMAIL_TEMPLATE_SCANNER_FUNCTION = "scanEmailTemplateDirectory";
3
+ /** One call to the scanner, with what could be read of its arguments. */
4
+ export interface EmailTemplateScannerCall {
5
+ /** 1-based line of the call. */
6
+ readonly line: number;
7
+ /** The directory it scans, relative to the calling file, when written as a literal; `null` otherwise. */
8
+ readonly subdir: string | null;
9
+ /**
10
+ * The prefix of every ref the call registers (`email.`, `system.`), read from what `keyFromPath` returns when that is a
11
+ * template or string literal starting with a dotted prefix; `null` otherwise.
12
+ */
13
+ readonly refPrefix: string | null;
14
+ }
15
+ /** Cheap pre-filter: a file that never names the scanner cannot call it. */
16
+ export declare function mayCallEmailTemplateScanner(sourceText: string): boolean;
17
+ /** Every call `sourceText` makes to the engine's scanner, in source order; empty when it makes none. */
18
+ export declare function readEmailTemplateScannerCalls(sourceText: string, fileName: string): readonly EmailTemplateScannerCall[];
19
+ //# sourceMappingURL=email-template-scanner-calls.companion.utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"email-template-scanner-calls.companion.utils.d.ts","sourceRoot":"","sources":["../../../../src/email/utils/email-template-scanner-calls.companion.utils.ts"],"names":[],"mappings":"AAgCA,qGAAqG;AACrG,eAAO,MAAM,+BAA+B,+BAA+B,CAAC;AAI5E,yEAAyE;AACzE,MAAM,WAAW,wBAAwB;IACvC,gCAAgC;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,yGAAyG;IACzG,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B;;;OAGG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CACnC;AAED,4EAA4E;AAC5E,wBAAgB,2BAA2B,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAEvE;AAED,wGAAwG;AACxG,wBAAgB,6BAA6B,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,wBAAwB,EAAE,CA4CvH"}
@@ -0,0 +1,171 @@
1
+ /**
2
+ * The calls a source file makes to `scanEmailTemplateDirectory`, read from its SYNTAX TREE (#3904 review F5, F6).
3
+ *
4
+ * Two readers need them: the companion's module email root (`module-email-root.companion.utils.ts`), which places a
5
+ * generated template where the module's scanner registers it, and the build lane's `check:module-layout`, which refuses a
6
+ * module's email definitions outside `emails/`. Both used a regex until #3904: it matched the call inside a COMMENT (a
7
+ * file that only mentions the scanner was taken for the module's definitions file) and missed
8
+ * `import { scanEmailTemplateDirectory as scan }` (an aliased scanner was not seen at all). A syntax tree has neither
9
+ * blind spot: comments are not nodes, and the local name a call uses is read from the file's own import.
10
+ *
11
+ * Only a binding imported from `@wildo-ai/saas-backend-lib` (the root or any of its subpaths) counts: a local function
12
+ * that happens to be called `scanEmailTemplateDirectory` is not the scanner. An application that wraps the scanner in a
13
+ * helper of its own is seen at the helper, not at the file calling the helper: recorded, not guessed past.
14
+ *
15
+ * Each call's `subdir` and the prefix of the refs its `keyFromPath` derives are read when they are LITERALS — a string
16
+ * `subdir`, and a `keyFromPath` that returns a template or string literal whose head is the prefix (`email.${…}`). Any
17
+ * other form is reported `null` (undetermined), never assumed to be the standard layout.
18
+ */
19
+ import { createRequire } from 'node:module';
20
+ /*
21
+ * TypeScript is loaded on first use, not at import: this file is also reached from the application's introspection
22
+ * subprocess (the email placement), which reads a few files and should not pay for the compiler unless one names the
23
+ * scanner (`mayCallEmailTemplateScanner`).
24
+ */
25
+ let typescriptModule;
26
+ function typescript() {
27
+ typescriptModule ??= createRequire(import.meta.url)('typescript');
28
+ return typescriptModule;
29
+ }
30
+ /** The engine function every module email definitions file calls to read its templates from disk. */
31
+ export const EMAIL_TEMPLATE_SCANNER_FUNCTION = 'scanEmailTemplateDirectory';
32
+ /** The package the scanner is imported from: its root, or any subpath of it. */
33
+ const SCANNER_PACKAGE = '@wildo-ai/saas-backend-lib';
34
+ /** Cheap pre-filter: a file that never names the scanner cannot call it. */
35
+ export function mayCallEmailTemplateScanner(sourceText) {
36
+ return sourceText.includes(EMAIL_TEMPLATE_SCANNER_FUNCTION);
37
+ }
38
+ /** Every call `sourceText` makes to the engine's scanner, in source order; empty when it makes none. */
39
+ export function readEmailTemplateScannerCalls(sourceText, fileName) {
40
+ if (!mayCallEmailTemplateScanner(sourceText))
41
+ return [];
42
+ const sourceFile = typescript().createSourceFile(fileName, sourceText, typescript().ScriptTarget.Latest, true, scriptKindOf(fileName));
43
+ const localNames = new Set();
44
+ const namespaceNames = new Set();
45
+ for (const statement of sourceFile.statements) {
46
+ if (!typescript().isImportDeclaration(statement) || !typescript().isStringLiteral(statement.moduleSpecifier))
47
+ continue;
48
+ const specifier = statement.moduleSpecifier.text;
49
+ if (specifier !== SCANNER_PACKAGE && !specifier.startsWith(`${SCANNER_PACKAGE}/`))
50
+ continue;
51
+ const bindings = statement.importClause?.namedBindings;
52
+ if (bindings === undefined)
53
+ continue;
54
+ if (typescript().isNamespaceImport(bindings)) {
55
+ namespaceNames.add(bindings.name.text);
56
+ continue;
57
+ }
58
+ for (const element of bindings.elements) {
59
+ if ((element.propertyName ?? element.name).text === EMAIL_TEMPLATE_SCANNER_FUNCTION)
60
+ localNames.add(element.name.text);
61
+ }
62
+ }
63
+ if (localNames.size === 0 && namespaceNames.size === 0)
64
+ return [];
65
+ const calls = [];
66
+ const isScanner = (callee) => {
67
+ const target = typescript().isParenthesizedExpression(callee) ? callee.expression : callee;
68
+ if (typescript().isIdentifier(target))
69
+ return localNames.has(target.text);
70
+ return typescript().isPropertyAccessExpression(target)
71
+ && typescript().isIdentifier(target.expression)
72
+ && namespaceNames.has(target.expression.text)
73
+ && target.name.text === EMAIL_TEMPLATE_SCANNER_FUNCTION;
74
+ };
75
+ const visit = (node) => {
76
+ if (typescript().isCallExpression(node) && isScanner(node.expression)) {
77
+ const options = node.arguments[0];
78
+ const objectLiteral = options !== undefined && typescript().isObjectLiteralExpression(options) ? options : undefined;
79
+ calls.push({
80
+ line: sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile)).line + 1,
81
+ subdir: objectLiteral === undefined ? null : readLiteralSubdir(objectLiteral),
82
+ refPrefix: objectLiteral === undefined ? null : readKeyPrefix(objectLiteral),
83
+ });
84
+ }
85
+ typescript().forEachChild(node, visit);
86
+ };
87
+ visit(sourceFile);
88
+ return calls;
89
+ }
90
+ function scriptKindOf(fileName) {
91
+ if (fileName.endsWith('.tsx'))
92
+ return typescript().ScriptKind.TSX;
93
+ if (/\.(?:js|mjs|cjs)$/u.test(fileName))
94
+ return typescript().ScriptKind.JS;
95
+ return typescript().ScriptKind.TS;
96
+ }
97
+ /** The property named `name` the literal declares itself (a spread contributes nothing readable). Last one wins, as at runtime. */
98
+ function findProperty(objectLiteral, name) {
99
+ let found;
100
+ for (const property of objectLiteral.properties) {
101
+ if (typescript().isSpreadAssignment(property)) {
102
+ // A spread AFTER a declared value may override it: what the call passes is no longer readable.
103
+ if (found !== undefined)
104
+ found = undefined;
105
+ continue;
106
+ }
107
+ const propertyName = property.name;
108
+ if (propertyName !== undefined && (typescript().isIdentifier(propertyName) || typescript().isStringLiteral(propertyName)) && propertyName.text === name)
109
+ found = property;
110
+ }
111
+ return found;
112
+ }
113
+ function literalText(expression) {
114
+ if (typescript().isStringLiteral(expression) || typescript().isNoSubstitutionTemplateLiteral(expression))
115
+ return expression.text;
116
+ return null;
117
+ }
118
+ function readLiteralSubdir(objectLiteral) {
119
+ const property = findProperty(objectLiteral, 'subdir');
120
+ if (property === undefined || !typescript().isPropertyAssignment(property))
121
+ return null;
122
+ const text = literalText(property.initializer);
123
+ // Normalized to a relative POSIX directory; `.`/empty would scan the definitions file's own folder.
124
+ return text === null ? null : text.replace(/^\.\/+/u, '').replace(/\/+$/u, '') || '.';
125
+ }
126
+ function readKeyPrefix(objectLiteral) {
127
+ const property = findProperty(objectLiteral, 'keyFromPath');
128
+ if (property === undefined)
129
+ return null;
130
+ let body;
131
+ if (typescript().isMethodDeclaration(property))
132
+ body = property.body;
133
+ else if (typescript().isPropertyAssignment(property) && (typescript().isArrowFunction(property.initializer) || typescript().isFunctionExpression(property.initializer)))
134
+ body = property.initializer.body;
135
+ if (body === undefined)
136
+ return null;
137
+ const returned = [];
138
+ if (typescript().isBlock(body)) {
139
+ const collect = (node) => {
140
+ if (typescript().isReturnStatement(node)) {
141
+ if (node.expression !== undefined)
142
+ returned.push(node.expression);
143
+ return;
144
+ }
145
+ // A nested function's returns are not this function's.
146
+ if (typescript().isFunctionLike(node))
147
+ return;
148
+ typescript().forEachChild(node, collect);
149
+ };
150
+ typescript().forEachChild(body, collect);
151
+ }
152
+ else {
153
+ returned.push(body);
154
+ }
155
+ const prefixes = new Set(returned.map(prefixOfReturnedKey));
156
+ if (prefixes.size !== 1)
157
+ return null;
158
+ return [...prefixes][0] ?? null;
159
+ }
160
+ /** `email.${x}` → `email.`; `'system.' + x` → `system.`; anything else → null. */
161
+ function prefixOfReturnedKey(expression) {
162
+ const unwrapped = typescript().isParenthesizedExpression(expression) ? expression.expression : expression;
163
+ let head = null;
164
+ if (typescript().isTemplateExpression(unwrapped))
165
+ head = unwrapped.head.text;
166
+ else if (typescript().isBinaryExpression(unwrapped) && unwrapped.operatorToken.kind === typescript().SyntaxKind.PlusToken)
167
+ head = literalText(unwrapped.left);
168
+ const match = head === null ? null : /^([a-z][a-z0-9_-]*\.)/u.exec(head);
169
+ return match?.[1] ?? null;
170
+ }
171
+ //# sourceMappingURL=email-template-scanner-calls.companion.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"email-template-scanner-calls.companion.utils.js","sourceRoot":"","sources":["../../../../src/email/utils/email-template-scanner-calls.companion.utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C;;;;GAIG;AACH,IAAI,gBAAuC,CAAC;AAC5C,SAAS,UAAU;IACjB,gBAAgB,KAAK,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,YAAY,CAAc,CAAC;IAC/E,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED,qGAAqG;AACrG,MAAM,CAAC,MAAM,+BAA+B,GAAG,4B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,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;AAClC,CAAC;AAED,kFAAkF;AAClF,SAAS,mBAAmB,CAAC,UAAyB;IACpD,MAAM,SAAS,GAAG,UAAU,EAAE,CAAC,yBAAyB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC;IAC1G,IAAI,IAAI,GAAkB,IAAI,CAAC;IAC/B,IAAI,UAAU,EAAE,CAAC,oBAAoB,CAAC,SAAS,CAAC;QAAE,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;SACxE,IAAI,UAAU,EAAE,CAAC,kBAAkB,CAAC,SAAS,CAAC,IAAI,SAAS,CAAC,aAAa,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC,UAAU,CAAC,SAAS;QAAE,IAAI,GAAG,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAC9J,MAAM,KAAK,GAAG,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,wBAAwB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzE,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;AAC5B,CAAC","sourcesContent":["/**\n * The calls a source file makes to `scanEmailTemplateDirectory`, read from its SYNTAX TREE (#3904 review F5, F6).\n *\n * Two readers need them: the companion's module email root (`module-email-root.companion.utils.ts`), which places a\n * generated template where the module's scanner registers it, and the build lane's `check:module-layout`, which refuses a\n * module's email definitions outside `emails/`. Both used a regex until #3904: it matched the call inside a COMMENT (a\n * file that only mentions the scanner was taken for the module's definitions file) and missed\n * `import { scanEmailTemplateDirectory as scan }` (an aliased scanner was not seen at all). A syntax tree has neither\n * blind spot: comments are not nodes, and the local name a call uses is read from the file's own import.\n *\n * Only a binding imported from `@wildo-ai/saas-backend-lib` (the root or any of its subpaths) counts: a local function\n * that happens to be called `scanEmailTemplateDirectory` is not the scanner. An application that wraps the scanner in a\n * helper of its own is seen at the helper, not at the file calling the helper: recorded, not guessed past.\n *\n * Each call's `subdir` and the prefix of the refs its `keyFromPath` derives are read when they are LITERALS — a string\n * `subdir`, and a `keyFromPath` that returns a template or string literal whose head is the prefix (`email.${…}`). Any\n * other form is reported `null` (undetermined), never assumed to be the standard layout.\n */\nimport { createRequire } from 'node:module';\nimport type ts from 'typescript';\n\n/*\n * TypeScript is loaded on first use, not at import: this file is also reached from the application's introspection\n * subprocess (the email placement), which reads a few files and should not pay for the compiler unless one names the\n * scanner (`mayCallEmailTemplateScanner`).\n */\nlet typescriptModule: typeof ts | undefined;\nfunction typescript(): typeof ts {\n typescriptModule ??= createRequire(import.meta.url)('typescript') as typeof ts;\n return typescriptModule;\n}\n\n/** The engine function every module email definitions file calls to read its templates from disk. */\nexport const EMAIL_TEMPLATE_SCANNER_FUNCTION = 'scanEmailTemplateDirectory';\n/** The package the scanner is imported from: its root, or any subpath of it. */\nconst SCANNER_PACKAGE = '@wildo-ai/saas-backend-lib';\n\n/** One call to the scanner, with what could be read of its arguments. */\nexport interface EmailTemplateScannerCall {\n /** 1-based line of the call. */\n readonly line: number;\n /** The directory it scans, relative to the calling file, when written as a literal; `null` otherwise. */\n readonly subdir: string | null;\n /**\n * The prefix of every ref the call registers (`email.`, `system.`), read from what `keyFromPath` returns when that is a\n * template or string literal starting with a dotted prefix; `null` otherwise.\n */\n readonly refPrefix: string | null;\n}\n\n/** Cheap pre-filter: a file that never names the scanner cannot call it. */\nexport function mayCallEmailTemplateScanner(sourceText: string): boolean {\n return sourceText.includes(EMAIL_TEMPLATE_SCANNER_FUNCTION);\n}\n\n/** Every call `sourceText` makes to the engine's scanner, in source order; empty when it makes none. */\nexport function readEmailTemplateScannerCalls(sourceText: string, fileName: string): readonly EmailTemplateScannerCall[] {\n if (!mayCallEmailTemplateScanner(sourceText)) return [];\n const sourceFile = typescript().createSourceFile(fileName, sourceText, typescript().ScriptTarget.Latest, true, scriptKindOf(fileName));\n const localNames = new Set<string>();\n const namespaceNames = new Set<string>();\n for (const statement of sourceFile.statements) {\n if (!typescript().isImportDeclaration(statement) || !typescript().isStringLiteral(statement.moduleSpecifier)) continue;\n const specifier = statement.moduleSpecifier.text;\n if (specifier !== SCANNER_PACKAGE && !specifier.startsWith(`${SCANNER_PACKAGE}/`)) continue;\n const bindings = statement.importClause?.namedBindings;\n if (bindings === undefined) continue;\n if (typescript().isNamespaceImport(bindings)) {\n namespaceNames.add(bindings.name.text);\n continue;\n }\n for (const element of bindings.elements) {\n if ((element.propertyName ?? element.name).text === EMAIL_TEMPLATE_SCANNER_FUNCTION) localNames.add(element.name.text);\n }\n }\n if (localNames.size === 0 && namespaceNames.size === 0) return [];\n\n const calls: EmailTemplateScannerCall[] = [];\n const isScanner = (callee: ts.Expression): boolean => {\n const target = typescript().isParenthesizedExpression(callee) ? callee.expression : callee;\n if (typescript().isIdentifier(target)) return localNames.has(target.text);\n return typescript().isPropertyAccessExpression(target)\n && typescript().isIdentifier(target.expression)\n && namespaceNames.has(target.expression.text)\n && target.name.text === EMAIL_TEMPLATE_SCANNER_FUNCTION;\n };\n const visit = (node: ts.Node): void => {\n if (typescript().isCallExpression(node) && isScanner(node.expression)) {\n const options = node.arguments[0];\n const objectLiteral = options !== undefined && typescript().isObjectLiteralExpression(options) ? options : undefined;\n calls.push({\n line: sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile)).line + 1,\n subdir: objectLiteral === undefined ? null : readLiteralSubdir(objectLiteral),\n refPrefix: objectLiteral === undefined ? null : readKeyPrefix(objectLiteral),\n });\n }\n typescript().forEachChild(node, visit);\n };\n visit(sourceFile);\n return calls;\n}\n\nfunction scriptKindOf(fileName: string): ts.ScriptKind {\n if (fileName.endsWith('.tsx')) return typescript().ScriptKind.TSX;\n if (/\\.(?:js|mjs|cjs)$/u.test(fileName)) return typescript().ScriptKind.JS;\n return typescript().ScriptKind.TS;\n}\n\n/** The property named `name` the literal declares itself (a spread contributes nothing readable). Last one wins, as at runtime. */\nfunction findProperty(objectLiteral: ts.ObjectLiteralExpression, name: string): ts.ObjectLiteralElementLike | undefined {\n let found: ts.ObjectLiteralElementLike | undefined;\n for (const property of objectLiteral.properties) {\n if (typescript().isSpreadAssignment(property)) {\n // A spread AFTER a declared value may override it: what the call passes is no longer readable.\n if (found !== undefined) found = undefined;\n continue;\n }\n const propertyName = property.name;\n if (propertyName !== undefined && (typescript().isIdentifier(propertyName) || typescript().isStringLiteral(propertyName)) && propertyName.text === name) found = property;\n }\n return found;\n}\n\nfunction literalText(expression: ts.Expression): string | null {\n if (typescript().isStringLiteral(expression) || typescript().isNoSubstitutionTemplateLiteral(expression)) return expression.text;\n return null;\n}\n\nfunction readLiteralSubdir(objectLiteral: ts.ObjectLiteralExpression): string | null {\n const property = findProperty(objectLiteral, 'subdir');\n if (property === undefined || !typescript().isPropertyAssignment(property)) return null;\n const text = literalText(property.initializer);\n // Normalized to a relative POSIX directory; `.`/empty would scan the definitions file's own folder.\n return text === null ? null : text.replace(/^\\.\\/+/u, '').replace(/\\/+$/u, '') || '.';\n}\n\nfunction readKeyPrefix(objectLiteral: ts.ObjectLiteralExpression): string | null {\n const property = findProperty(objectLiteral, 'keyFromPath');\n if (property === undefined) return null;\n let body: ts.ConciseBody | undefined;\n if (typescript().isMethodDeclaration(property)) body = property.body;\n else if (typescript().isPropertyAssignment(property) && (typescript().isArrowFunction(property.initializer) || typescript().isFunctionExpression(property.initializer))) body = property.initializer.body;\n if (body === undefined) return null;\n const returned: ts.Expression[] = [];\n if (typescript().isBlock(body)) {\n const collect = (node: ts.Node): void => {\n if (typescript().isReturnStatement(node)) {\n if (node.expression !== undefined) returned.push(node.expression);\n return;\n }\n // A nested function's returns are not this function's.\n if (typescript().isFunctionLike(node)) return;\n typescript().forEachChild(node, collect);\n };\n typescript().forEachChild(body, collect);\n } else {\n returned.push(body);\n }\n const prefixes = new Set(returned.map(prefixOfReturnedKey));\n if (prefixes.size !== 1) return null;\n return [...prefixes][0] ?? null;\n}\n\n/** `email.${x}` → `email.`; `'system.' + x` → `system.`; anything else → null. */\nfunction prefixOfReturnedKey(expression: ts.Expression): string | null {\n const unwrapped = typescript().isParenthesizedExpression(expression) ? expression.expression : expression;\n let head: string | null = null;\n if (typescript().isTemplateExpression(unwrapped)) head = unwrapped.head.text;\n else if (typescript().isBinaryExpression(unwrapped) && unwrapped.operatorToken.kind === typescript().SyntaxKind.PlusToken) head = literalText(unwrapped.left);\n const match = head === null ? null : /^([a-z][a-z0-9_-]*\\.)/u.exec(head);\n return match?.[1] ?? null;\n}\n"]}
@@ -0,0 +1,75 @@
1
+ /** The conventional email root, under a module's source directory. */
2
+ export declare const CONVENTIONAL_MODULE_EMAIL_ROOT = "emails";
3
+ /** The conventional definitions file, under the email root. */
4
+ export declare const CONVENTIONAL_MODULE_EMAIL_DEFINITIONS_FILE = "module-email-template-definitions.ts";
5
+ /** Where one module's emails live, relative to the module's source directory (POSIX separators). */
6
+ export interface ModuleEmailRoot {
7
+ /** The directory templates are written under and scanned from (`emails`, `email`, …). */
8
+ readonly rootDirectory: string;
9
+ /** The definitions file, relative to the module's directory (`emails/module-email-template-definitions.ts`). */
10
+ readonly definitionsFile: string;
11
+ /** Whether it was read from the module's source (true) or is the convention, nothing scanning yet (false). */
12
+ readonly discovered: boolean;
13
+ /**
14
+ * The directory, relative to the email root, each family of refs is registered from, keyed by the refs' prefix
15
+ * (`email.` → `resources`), read from the definitions file's literal scanner calls. Empty when not discovered.
16
+ */
17
+ readonly directoriesByRefPrefix: Readonly<Record<string, string>>;
18
+ /** How many of the definitions file's scanner calls had a `subdir` or `keyFromPath` that is not a literal. */
19
+ readonly undeterminedScannerCalls: number;
20
+ }
21
+ /**
22
+ * The email root of the module whose source directory is `moduleSourceDirectory` (`backend-api/src/modules/<module>`).
23
+ * Pure but for the reads; never throws: an unreadable directory answers the convention, undiscovered.
24
+ */
25
+ export declare function resolveModuleEmailRoot(moduleSourceDirectory: string): ModuleEmailRoot;
26
+ /** The compiled form of a definitions file (`emails/x.ts` → `emails/x.js`), as the preview imports it from `dist`. */
27
+ export declare function compiledDefinitionsFile(definitionsFile: string): string;
28
+ /**
29
+ * The template map a module's definitions file exports, chosen by its CONTENT (#3904 review F1): the exported object whose
30
+ * keys include one of the module's own registered template refs. A definitions file may export the map under any name
31
+ * (`clientDocumentsEmailTemplateDefinitions`), so a fixed name finds nothing for most of them. The conventional names are
32
+ * tried first, then every other export, then the default export's members. `{}` when nothing matches: the module's
33
+ * templates are then not refreshed, never replaced by another export's.
34
+ */
35
+ export declare function selectModuleEmailTemplateDefinitions(moduleExports: Record<string, unknown>, ownTemplateRefs: readonly string[]): Record<string, unknown>;
36
+ /**
37
+ * What the generation step may write for a business module's templates (#3904 review F2, F5):
38
+ *
39
+ * - `determined: true`: the templates of each ref family go under `<root>/<directoriesByRefPrefix[prefix]>/…`;
40
+ * - `determined: false`: where the module registers its templates cannot be read (no file calls the scanner, or none of
41
+ * its calls has literal arguments). The generation step then writes NOTHING for the module and says why, instead of
42
+ * writing into a folder nothing registers. `check:module-layout` is what corrects such a module.
43
+ */
44
+ export type ModuleEmailTemplateLayout = {
45
+ readonly determined: true;
46
+ /** Application-relative definitions file the layout was read from. */
47
+ readonly definitionsFile: string;
48
+ readonly directoriesByRefPrefix: Readonly<Record<string, string>>;
49
+ readonly undeterminedScannerCalls: number;
50
+ } | {
51
+ readonly determined: false;
52
+ readonly reason: string;
53
+ };
54
+ /**
55
+ * A business module's email placement, as the `email-template-placement-info` introspection reports it (#3904): the
56
+ * APPLICATION-relative root, `<the backend service's path>/src/modules/<module>/<root>` (the service's path read from where
57
+ * the service is, review F4, not assumed to be `backend-api`), and the layout the generation step may write under it.
58
+ */
59
+ export declare function moduleEmailTemplatePlacement(input: {
60
+ readonly applicationRoot: string;
61
+ readonly backendPackageRoot: string;
62
+ readonly moduleId: string;
63
+ }): {
64
+ readonly backend: string;
65
+ readonly layout: ModuleEmailTemplateLayout;
66
+ };
67
+ /** A business module's email root, APPLICATION-relative: {@link moduleEmailTemplatePlacement}'s `backend`. */
68
+ export declare function moduleEmailRootApplicationPath(input: {
69
+ readonly applicationRoot: string;
70
+ readonly backendPackageRoot: string;
71
+ readonly moduleId: string;
72
+ }): string;
73
+ /** The compiled definitions file the preview imports for a business module (#3904): `dist` mirrors `src` (`rootDir: src`). */
74
+ export declare function moduleEmailDefinitionsEntryPath(backendDistRoot: string, moduleId: string): string;
75
+ //# sourceMappingURL=module-email-root.companion.utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module-email-root.companion.utils.d.ts","sourceRoot":"","sources":["../../../../src/email/utils/module-email-root.companion.utils.ts"],"names":[],"mappings":"AA+BA,sEAAsE;AACtE,eAAO,MAAM,8BAA8B,WAAyB,CAAC;AACrE,+DAA+D;AAC/D,eAAO,MAAM,0CAA0C,yCAAgC,CAAC;AAExF,oGAAoG;AACpG,MAAM,WAAW,eAAe;IAC9B,yFAAyF;IACzF,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,gHAAgH;IAChH,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,8GAA8G;IAC9G,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B;;;OAGG;IACH,QAAQ,CAAC,sBAAsB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAClE,8GAA8G;IAC9G,QAAQ,CAAC,wBAAwB,EAAE,MAAM,CAAC;CAC3C;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,qBAAqB,EAAE,MAAM,GAAG,eAAe,CA2CrF;AAED,sHAAsH;AACtH,wBAAgB,uBAAuB,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM,CAEvE;AAED;;;;;;GAMG;AACH,wBAAgB,oCAAoC,CAAC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,EAAE,SAAS,MAAM,EAAE,GAAG,MA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