@_tc/template-core 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (297) hide show
  1. package/.skills/tc-component-usage-skills/reference/component-api.md +27 -0
  2. package/.skills/tc-generator/SKILL.md +1 -1
  3. package/.skills/tc-generator/reference/project-template/ssr/apps/hello/hello.entry.tsx +6 -1
  4. package/.skills/tc-generator/reference/runtime-extensions.md +10 -0
  5. package/AGENT_README.md +8 -2
  6. package/CHANGE.md +27 -0
  7. package/README.md +157 -8
  8. package/cjs/app/ai/agent/agent-scanner.service.js +1 -1
  9. package/cjs/app/ai/agent/agent.module.js +1 -1
  10. package/cjs/app/ai/ai-config.module.js +1 -1
  11. package/cjs/app/ai/ai-config.service.js +1 -1
  12. package/cjs/app/ai/ai.controller.js +1 -1
  13. package/cjs/app/ai/ai.module.js +1 -1
  14. package/cjs/app/ai/guardrail/guardrail.module.js +1 -1
  15. package/cjs/app/ai/guardrail/guardrail.service.js +1 -1
  16. package/cjs/app/ai/index.js +1 -0
  17. package/cjs/app/ai/mcp/internal/read-sse-response.js +2 -0
  18. package/cjs/app/ai/mcp/internal/stdio-process.js +1 -0
  19. package/cjs/app/ai/mcp/mcp-registry.service.js +2 -2
  20. package/cjs/app/ai/mcp/mcp.client.js +2 -3
  21. package/cjs/app/ai/mcp/mcp.loader.js +1 -1
  22. package/cjs/app/ai/mcp/mcp.module.js +1 -1
  23. package/cjs/app/ai/memory/checkpoint.service.js +1 -1
  24. package/cjs/app/ai/memory/memory.module.js +1 -1
  25. package/cjs/app/ai/memory/thread.service.js +1 -1
  26. package/cjs/app/ai/models/chat-sse.js +4 -0
  27. package/cjs/app/ai/models/chat.js +1 -0
  28. package/cjs/app/ai/models/http.js +1 -0
  29. package/cjs/app/ai/models/image.js +1 -0
  30. package/cjs/app/ai/models/video.js +1 -0
  31. package/cjs/app/ai/nest-service-provider.js +1 -0
  32. package/cjs/app/ai/rag/rag.module.js +1 -1
  33. package/cjs/app/ai/rag/retriever.service.js +1 -1
  34. package/cjs/app/ai/retention/conversation-retention.service.js +1 -1
  35. package/cjs/app/ai/runtime/ai-runtime-startup.validator.js +1 -1
  36. package/cjs/app/ai/runtime/ai-runtime.js +1 -0
  37. package/cjs/app/ai/runtime/internal/context-compaction.service.js +3 -3
  38. package/cjs/app/ai/runtime/internal/declaration-snapshot.js +1 -0
  39. package/cjs/app/ai/runtime/internal/owned-runtime-resources.js +1 -0
  40. package/cjs/app/ai/runtime/langchain/langchain-planner.service.js +1 -1
  41. package/cjs/app/ai/runtime/langgraph/langgraph-orchestrator.service.js +1 -1
  42. package/cjs/app/ai/runtime/runtime.module.js +1 -1
  43. package/cjs/app/ai/skill/skill-scanner.service.js +1 -1
  44. package/cjs/app/ai/skill/skill.module.js +1 -1
  45. package/cjs/app/ai/snapshot-data.js +1 -0
  46. package/cjs/app/ai/store/internal/create-vector-store.js +1 -0
  47. package/cjs/app/ai/store/store.module.js +1 -1
  48. package/cjs/app/ai/tool/builtin/index.js +1 -1
  49. package/cjs/app/ai/tool/builtin/invoke-agent.tool.js +1 -1
  50. package/cjs/app/ai/tool/builtin/retrieve.tool.js +1 -1
  51. package/cjs/app/ai/tool/executor.service.js +1 -1
  52. package/cjs/app/ai/tool/tool-registry.service.js +1 -1
  53. package/cjs/app/ai/tool/tool.module.js +1 -1
  54. package/cjs/app/ai/trace/trace.service.js +1 -1
  55. package/cjs/app/csr/controller.js +1 -1
  56. package/cjs/app/csr/types.js +0 -0
  57. package/cjs/app/html/browser-options.js +1 -1
  58. package/cjs/app/html/shell.js +31 -16
  59. package/cjs/app/http/api-signing.js +1 -0
  60. package/cjs/app/http/body-parser.middleware.js +1 -1
  61. package/cjs/app/http/csp-nonce.js +1 -0
  62. package/cjs/app/http/error-response.js +1 -1
  63. package/cjs/app/http/exception-filter.js +1 -1
  64. package/cjs/app/http/request-body-parser-policy.js +1 -0
  65. package/cjs/app/http/security.guard.js +1 -1
  66. package/cjs/app/project/controller.js +1 -1
  67. package/cjs/app/project/service.js +1 -1
  68. package/cjs/app/providers/foundation.js +1 -1
  69. package/cjs/app/ssr/artifacts.js +1 -1
  70. package/cjs/app/ssr/controller.js +1 -1
  71. package/cjs/app/ssr/html.js +17 -17
  72. package/cjs/app/ssr/stream.js +1 -1
  73. package/cjs/app/static-assets.middleware.js +1 -1
  74. package/cjs/app/template-core.module.js +1 -1
  75. package/cjs/app/view/entry.tpl +2 -2
  76. package/cjs/bundler/buildSSR.js +1 -1
  77. package/cjs/bundler/entryCollect.js +1 -1
  78. package/cjs/bundler/feSharedConfig.js +1 -1
  79. package/cjs/bundler/utils.js +3 -3
  80. package/cjs/config/config.default.js +1 -1
  81. package/cjs/packages/common/index.js +1 -1
  82. package/cjs/packages/core/bootstrap.js +1 -1
  83. package/cjs/packages/core/startup.js +1 -1
  84. package/esm/app/ai/agent/agent-scanner.service.js +33 -36
  85. package/esm/app/ai/agent/agent.module.js +9 -7
  86. package/esm/app/ai/ai-config.module.js +14 -7
  87. package/esm/app/ai/ai-config.service.js +24 -20
  88. package/esm/app/ai/ai.controller.js +41 -41
  89. package/esm/app/ai/ai.module.js +15 -15
  90. package/esm/app/ai/guardrail/guardrail.module.js +11 -9
  91. package/esm/app/ai/guardrail/guardrail.service.js +5 -10
  92. package/esm/app/ai/index.js +2 -0
  93. package/esm/app/ai/mcp/internal/read-sse-response.js +35 -0
  94. package/esm/app/ai/mcp/internal/stdio-process.js +59 -0
  95. package/esm/app/ai/mcp/mcp-registry.service.js +10 -15
  96. package/esm/app/ai/mcp/mcp.client.js +77 -78
  97. package/esm/app/ai/mcp/mcp.loader.js +64 -42
  98. package/esm/app/ai/mcp/mcp.module.js +62 -22
  99. package/esm/app/ai/memory/checkpoint.service.js +18 -28
  100. package/esm/app/ai/memory/memory.module.js +15 -12
  101. package/esm/app/ai/memory/thread.service.js +21 -26
  102. package/esm/app/ai/models/chat-sse.js +44 -0
  103. package/esm/app/ai/models/chat.js +60 -0
  104. package/esm/app/ai/models/http.js +52 -0
  105. package/esm/app/ai/models/image.js +37 -0
  106. package/esm/app/ai/models/video.js +32 -0
  107. package/esm/app/ai/nest-service-provider.js +10 -0
  108. package/esm/app/ai/rag/rag.module.js +24 -15
  109. package/esm/app/ai/rag/retriever.service.js +37 -54
  110. package/esm/app/ai/retention/conversation-retention.service.js +16 -34
  111. package/esm/app/ai/runtime/ai-runtime-startup.validator.js +2 -19
  112. package/esm/app/ai/runtime/ai-runtime.js +104 -0
  113. package/esm/app/ai/runtime/internal/context-compaction.service.js +139 -145
  114. package/esm/app/ai/runtime/internal/declaration-snapshot.js +32 -0
  115. package/esm/app/ai/runtime/internal/owned-runtime-resources.js +21 -0
  116. package/esm/app/ai/runtime/langchain/langchain-planner.service.js +43 -49
  117. package/esm/app/ai/runtime/langgraph/langgraph-orchestrator.service.js +273 -225
  118. package/esm/app/ai/runtime/runtime.module.js +56 -35
  119. package/esm/app/ai/skill/skill-scanner.service.js +11 -16
  120. package/esm/app/ai/skill/skill.module.js +11 -9
  121. package/esm/app/ai/snapshot-data.js +24 -0
  122. package/esm/app/ai/store/internal/create-vector-store.js +10 -0
  123. package/esm/app/ai/store/store.module.js +9 -13
  124. package/esm/app/ai/tool/builtin/index.js +16 -4
  125. package/esm/app/ai/tool/builtin/invoke-agent.tool.js +30 -34
  126. package/esm/app/ai/tool/builtin/retrieve.tool.js +9 -13
  127. package/esm/app/ai/tool/executor.service.js +22 -29
  128. package/esm/app/ai/tool/tool-registry.service.js +6 -16
  129. package/esm/app/ai/tool/tool.module.js +26 -12
  130. package/esm/app/ai/trace/trace.service.js +15 -28
  131. package/esm/app/csr/controller.js +114 -63
  132. package/esm/app/csr/types.js +0 -0
  133. package/esm/app/html/browser-options.js +2 -2
  134. package/esm/app/html/shell.js +173 -32
  135. package/esm/app/http/api-signing.js +13 -0
  136. package/esm/app/http/body-parser.middleware.js +47 -27
  137. package/esm/app/http/csp-nonce.js +13 -0
  138. package/esm/app/http/error-response.js +8 -5
  139. package/esm/app/http/exception-filter.js +4 -4
  140. package/esm/app/http/request-body-parser-policy.js +46 -0
  141. package/esm/app/http/security.guard.js +23 -21
  142. package/esm/app/project/controller.js +15 -15
  143. package/esm/app/project/service.js +3 -3
  144. package/esm/app/providers/foundation.js +5 -5
  145. package/esm/app/ssr/artifacts.js +25 -21
  146. package/esm/app/ssr/controller.js +148 -75
  147. package/esm/app/ssr/html.js +49 -44
  148. package/esm/app/ssr/stream.js +25 -24
  149. package/esm/app/static-assets.middleware.js +4 -4
  150. package/esm/app/template-core.module.js +57 -52
  151. package/esm/app/view/entry.tpl +2 -2
  152. package/esm/bundler/buildSSR.js +1 -1
  153. package/esm/bundler/entryCollect.js +9 -9
  154. package/esm/bundler/feSharedConfig.js +42 -42
  155. package/esm/bundler/utils.js +78 -90
  156. package/esm/config/config.default.js +4 -3
  157. package/esm/packages/common/index.js +6 -6
  158. package/esm/packages/core/bootstrap.js +5 -5
  159. package/esm/packages/core/startup.js +69 -46
  160. package/fe/frontend/src/common/request.js +5 -2
  161. package/fe/frontend/src/hooks/useRouterParams.d.ts +4 -2
  162. package/fe/packages/common/ssr/hydration.d.ts +9 -0
  163. package/fe/packages/react/core/Label/Label.d.ts +1 -0
  164. package/fe/packages/react/core/Label/Label.js +3 -1
  165. package/fe/packages/react/core/internal/i18n/default.d.ts +13 -0
  166. package/fe/packages/react/core/internal/i18n/default.js +16 -1
  167. package/fe/packages/react/core/internal/i18n/en-US.d.ts +13 -0
  168. package/fe/packages/react/core/internal/i18n/en-US.js +16 -1
  169. package/fe/packages/react/forms/DataTable/index.d.ts +2 -0
  170. package/fe/packages/react/forms/DataTable/index.js +43 -29
  171. package/fe/packages/react/forms/Form/FormItem.js +39 -12
  172. package/fe/packages/react/forms/MultiSelect/MultiSelect.d.ts +26 -0
  173. package/fe/packages/react/forms/MultiSelect/MultiSelect.js +218 -0
  174. package/fe/packages/react/forms/MultiSelect/index.d.ts +1 -0
  175. package/fe/packages/react/forms/MultiSelect/index.js +2 -0
  176. package/fe/packages/react/forms/Pagination/Pagination.d.ts +6 -1
  177. package/fe/packages/react/forms/Pagination/Pagination.js +13 -4
  178. package/fe/packages/react/forms/Select/Select.d.ts +11 -0
  179. package/fe/packages/react/forms/Select/Select.js +20 -7
  180. package/fe/packages/react/forms/index.d.ts +1 -0
  181. package/fe/packages/react/forms/index.js +3 -1
  182. package/fe/packages/react/i18n/getUiReactLocale.d.ts +26 -0
  183. package/fe/packages/react/index.js +2 -1
  184. package/fe/packages/react/overlays/Drawer/Drawer.d.ts +3 -2
  185. package/fe/packages/react/overlays/Drawer/Drawer.js +16 -2
  186. package/fe/packages/react/overlays/Dropdown/Dropdown.d.ts +12 -2
  187. package/fe/packages/react/overlays/Dropdown/Dropdown.js +27 -14
  188. package/fe/packages/react/overlays/Modal/Modal.d.ts +11 -3
  189. package/fe/packages/react/overlays/Modal/Modal.js +26 -2
  190. package/fe/packages/react/overlays/Modal/ModalManager.d.ts +13 -12
  191. package/fe/packages/react/overlays/Modal/ModalManager.js +15 -5
  192. package/fe/packages/react/overlays/Modal/index.d.ts +1 -0
  193. package/fe/packages/react/overlays/Overlay/Overlay.d.ts +6 -2
  194. package/fe/packages/react/overlays/Overlay/Overlay.js +31 -14
  195. package/fe/packages/react/overlays/Overlay/focusTypes.d.ts +8 -0
  196. package/fe/packages/react/overlays/Overlay/focusTypes.js +0 -0
  197. package/fe/packages/react/overlays/Overlay/index.d.ts +1 -0
  198. package/fe/packages/react/overlays/Overlay/overlayStack.d.ts +16 -0
  199. package/fe/packages/react/overlays/Overlay/overlayStack.js +290 -0
  200. package/fe/packages/react/overlays/Popup/Popup.d.ts +5 -4
  201. package/fe/packages/react/overlays/Popup/Popup.js +28 -11
  202. package/fe/packages/react/ui/components/index.js +2 -1
  203. package/fe/packages/react/ui/index.js +2 -1
  204. package/fe/ssr/components/StreamingRender/StreamingCache.d.ts +1 -0
  205. package/fe/ssr/components/StreamingRender/StreamingCache.js +5 -1
  206. package/fe/ssr/components/StreamingRender/StreamingRender.js +1 -1
  207. package/fe/ssr/components/StreamingRender/StreamingScript.d.ts +1 -0
  208. package/fe/ssr/components/StreamingRender/StreamingScript.js +9 -1
  209. package/fe/ssr/createSSREntry.d.ts +9 -3
  210. package/fe/ssr/createSSREntry.js +43 -19
  211. package/fe/ssr/index.d.ts +4 -1
  212. package/fe/ssr/index.js +2 -1
  213. package/fe/ssr/router.d.ts +76 -0
  214. package/fe/ssr/router.js +349 -0
  215. package/fe/ssr/types.d.ts +1 -1
  216. package/models/packages/common/ssr/hydration.d.ts +9 -0
  217. package/models/packages/react/core/Label/Label.d.ts +1 -0
  218. package/models/packages/react/core/internal/i18n/default.d.ts +13 -0
  219. package/models/packages/react/core/internal/i18n/en-US.d.ts +13 -0
  220. package/models/packages/react/forms/DataTable/index.d.ts +2 -0
  221. package/models/packages/react/forms/MultiSelect/MultiSelect.d.ts +26 -0
  222. package/models/packages/react/forms/MultiSelect/index.d.ts +1 -0
  223. package/models/packages/react/forms/Pagination/Pagination.d.ts +6 -1
  224. package/models/packages/react/forms/Select/Select.d.ts +11 -0
  225. package/models/packages/react/forms/index.d.ts +1 -0
  226. package/models/packages/react/i18n/getUiReactLocale.d.ts +26 -0
  227. package/models/packages/react/overlays/Drawer/Drawer.d.ts +3 -2
  228. package/models/packages/react/overlays/Dropdown/Dropdown.d.ts +12 -2
  229. package/models/packages/react/overlays/Modal/Modal.d.ts +11 -3
  230. package/models/packages/react/overlays/Modal/ModalManager.d.ts +13 -12
  231. package/models/packages/react/overlays/Modal/index.d.ts +1 -0
  232. package/models/packages/react/overlays/Overlay/Overlay.d.ts +6 -2
  233. package/models/packages/react/overlays/Overlay/focusTypes.d.ts +8 -0
  234. package/models/packages/react/overlays/Overlay/index.d.ts +1 -0
  235. package/models/packages/react/overlays/Overlay/overlayStack.d.ts +16 -0
  236. package/models/packages/react/overlays/Popup/Popup.d.ts +5 -4
  237. package/package.json +26 -1
  238. package/types/app/ai/agent/agent-scanner.service.d.ts +4 -4
  239. package/types/app/ai/ai-config.service.d.ts +7 -3
  240. package/types/app/ai/guardrail/guardrail.service.d.ts +2 -2
  241. package/types/app/ai/index.d.ts +9 -0
  242. package/types/app/ai/mcp/internal/load-mcp-config.d.ts +2 -2
  243. package/types/app/ai/mcp/internal/read-sse-response.d.ts +2 -0
  244. package/types/app/ai/mcp/internal/stdio-process.d.ts +5 -0
  245. package/types/app/ai/mcp/mcp-registry.service.d.ts +5 -3
  246. package/types/app/ai/mcp/mcp.client.d.ts +7 -4
  247. package/types/app/ai/mcp/mcp.loader.d.ts +11 -11
  248. package/types/app/ai/mcp/mcp.module.d.ts +5 -5
  249. package/types/app/ai/memory/thread.service.d.ts +3 -3
  250. package/types/app/ai/models/chat-sse.d.ts +5 -0
  251. package/types/app/ai/models/chat.d.ts +22 -0
  252. package/types/app/ai/models/http.d.ts +20 -0
  253. package/types/app/ai/models/image.d.ts +69 -0
  254. package/types/app/ai/models/video.d.ts +99 -0
  255. package/types/app/ai/nest-service-provider.d.ts +6 -0
  256. package/types/app/ai/retention/conversation-retention.service.d.ts +3 -4
  257. package/types/app/ai/runtime/ai-runtime-startup.validator.d.ts +2 -3
  258. package/types/app/ai/runtime/ai-runtime.d.ts +46 -0
  259. package/types/app/ai/runtime/internal/agent-run-context.d.ts +4 -0
  260. package/types/app/ai/runtime/internal/context-compaction.service.d.ts +2 -2
  261. package/types/app/ai/runtime/internal/declaration-snapshot.d.ts +8 -0
  262. package/types/app/ai/runtime/internal/owned-runtime-resources.d.ts +5 -0
  263. package/types/app/ai/runtime/langchain/langchain-planner.service.d.ts +1 -1
  264. package/types/app/ai/runtime/langgraph/langgraph-orchestrator.service.d.ts +33 -16
  265. package/types/app/ai/skill/skill-scanner.service.d.ts +3 -4
  266. package/types/app/ai/snapshot-data.d.ts +1 -0
  267. package/types/app/ai/store/internal/create-vector-store.d.ts +4 -0
  268. package/types/app/ai/tool/builtin/index.d.ts +1 -1
  269. package/types/app/ai/tool/builtin/invoke-agent.tool.d.ts +10 -3
  270. package/types/app/ai/tool/builtin/retrieve.tool.d.ts +4 -3
  271. package/types/app/ai/tool/executor.service.d.ts +3 -3
  272. package/types/app/ai/tool/tool-registry.service.d.ts +2 -7
  273. package/types/app/ai/tool/tool.interface.d.ts +1 -1
  274. package/types/app/ai/tool/tool.module.d.ts +8 -1
  275. package/types/app/ai/trace/trace.service.d.ts +4 -5
  276. package/types/app/csr/types.d.ts +10 -0
  277. package/types/app/html/browser-options.d.ts +1 -1
  278. package/types/app/html/shell.d.ts +37 -10
  279. package/types/app/http/api-signing.d.ts +16 -0
  280. package/types/app/http/body-parser.middleware.d.ts +6 -2
  281. package/types/app/http/csp-nonce.d.ts +3 -0
  282. package/types/app/http/error-response.d.ts +1 -0
  283. package/types/app/http/request-body-parser-policy.d.ts +8 -0
  284. package/types/app/http/security.guard.d.ts +1 -0
  285. package/types/app/ssr/artifacts.d.ts +6 -3
  286. package/types/app/ssr/html.d.ts +7 -0
  287. package/types/app/ssr/stream.d.ts +1 -1
  288. package/types/app/ssr/types.d.ts +56 -0
  289. package/types/bundler/buildSSR.d.ts +2 -1
  290. package/types/bundler/index.d.ts +1 -1
  291. package/types/bundler/state.d.ts +13 -0
  292. package/types/bundler/utils.d.ts +3 -14
  293. package/types/config/config.default.d.ts +9 -3
  294. package/types/index.d.ts +4 -1
  295. package/types/packages/common/ssr/hydration.d.ts +13 -0
  296. package/types/packages/core/index.d.ts +1 -1
  297. package/types/packages/core/startup.d.ts +41 -0
@@ -1,53 +1,73 @@
1
1
  import { TC_LOGGER as e } from "../../packages/core/tokens.js";
2
2
  import "../../packages/core/index.js";
3
- import { respondWithTemplateError as t } from "./error-response.js";
4
- import { Inject as n, Injectable as r } from "@nestjs/common";
5
- import i from "@oxc-project/runtime/helpers/decorateMetadata";
6
- import a from "@oxc-project/runtime/helpers/decorate";
7
- import o from "@oxc-project/runtime/helpers/decorateParam";
8
- import s from "co-body";
3
+ import { logTemplateError as t, respondWithTemplateError as n } from "./error-response.js";
4
+ import { REQUEST_BODY_PARSER_POLICIES as r } from "./request-body-parser-policy.js";
5
+ import { Inject as i, Injectable as a } from "@nestjs/common";
6
+ import o from "@oxc-project/runtime/helpers/decorate";
7
+ import s from "@oxc-project/runtime/helpers/decorateMetadata";
8
+ import c from "@oxc-project/runtime/helpers/decorateParam";
9
+ import l from "co-body";
9
10
  //#region app/http/body-parser.middleware.ts
10
- var c = new Set([
11
+ var u = new Set([
11
12
  "application/json",
12
13
  "application/json-patch+json",
13
14
  "application/vnd.api+json",
14
15
  "application/csp-report",
15
16
  "application/scim+json"
16
- ]), l = "application/x-www-form-urlencoded", u = "text/plain";
17
- function d(e) {
17
+ ]), d = "application/x-www-form-urlencoded", f = "text/plain";
18
+ function p(e) {
18
19
  return e.headers["content-type"]?.split(";", 1)[0]?.trim().toLowerCase();
19
20
  }
20
- var f = class {
21
- constructor(e) {
22
- this.logger = e;
21
+ var m = class {
22
+ constructor(e, t) {
23
+ this.logger = e, this.policies = t;
23
24
  }
24
- use(e, n, r) {
25
- this.parse(e).then(() => r(), (r) => t(r, e, n, this.logger));
25
+ use(e, t, n) {
26
+ this.parse(e).then(() => n(), (n) => this.respondToParserError(n, e, t));
27
+ }
28
+ respondToParserError(e, r, i) {
29
+ if (!(i.headersSent || i.writableEnded || i.destroyed)) {
30
+ if (this.shouldReturnMalformedJsonStatus(e, r)) {
31
+ t(e, this.logger), i.status(500).end();
32
+ return;
33
+ }
34
+ n(e, r, i, this.logger);
35
+ }
36
+ }
37
+ shouldReturnMalformedJsonStatus(e, t) {
38
+ return !u.has(p(t) ?? "") || h(e) !== "malformed-json" ? !1 : this.policies.some((e) => e.method === t.method && e.matches(t.path) && e.onMalformedJson === "status-500-empty");
26
39
  }
27
40
  async parse(e) {
28
- let t = d(e);
29
- if (t && c.has(t)) {
30
- e.body = await s.json(e, { limit: "1mb" });
41
+ let t = p(e);
42
+ if (t && u.has(t)) {
43
+ e.body = await l.json(e, { limit: "1mb" });
31
44
  return;
32
45
  }
33
- if (t === l) {
34
- e.body = await s.form(e, {
46
+ if (t === d) {
47
+ e.body = await l.form(e, {
35
48
  limit: "1000mb",
36
49
  queryString: { allowDots: !0 }
37
50
  });
38
51
  return;
39
52
  }
40
- if (t === u) {
41
- e.body = await s.text(e, { limit: "1mb" }) || "";
53
+ if (t === f) {
54
+ e.body = await l.text(e, { limit: "1mb" }) || "";
42
55
  return;
43
56
  }
44
57
  e.body = {};
45
58
  }
46
59
  };
47
- f = a([
48
- r(),
49
- o(0, n(e)),
50
- i("design:paramtypes", [Object])
51
- ], f);
60
+ m = o([
61
+ a(),
62
+ c(0, i(e)),
63
+ c(1, i(r)),
64
+ s("design:paramtypes", [Object, Array])
65
+ ], m);
66
+ function h(e) {
67
+ return e instanceof SyntaxError && g(e, "status") === 400 ? "malformed-json" : g(e, "status") === 413 || g(e, "statusCode") === 413 || g(e, "type") === "entity.too.large" ? "body-size" : "other";
68
+ }
69
+ function g(e, t) {
70
+ if (!(!e || typeof e != "object")) return e[t];
71
+ }
52
72
  //#endregion
53
- export { f as RequestBodyParserMiddleware };
73
+ export { m as RequestBodyParserMiddleware };
@@ -0,0 +1,13 @@
1
+ //#region app/http/csp-nonce.ts
2
+ async function e(e, t, n) {
3
+ let r = t.locals?.cspNonce;
4
+ if (typeof r == "string" && r) return r;
5
+ let i = n.ssr;
6
+ if (!i || typeof i != "object" || Array.isArray(i)) return;
7
+ let a = i.cspNonce;
8
+ if (typeof a != "function") return;
9
+ let o = await a(e, t);
10
+ return typeof o == "string" && o ? o : void 0;
11
+ }
12
+ //#endregion
13
+ export { e as resolveCspNonce };
@@ -3,8 +3,8 @@ import { getRequestErrorMessage as t, requestT as n } from "../utils/i18n.js";
3
3
  //#region app/http/error-response.ts
4
4
  function r(r, o, s, c) {
5
5
  if (s.headersSent || s.writableEnded || s.destroyed) return;
6
- let l = i(r), u = e(l) || l.returnError === !0;
7
- if (c.info(`error info -> ${a(r)}`), c.error("-- [exception] --", r), u) {
6
+ let l = a(r), u = e(l) || l.returnError === !0;
7
+ if (i(r, c), u) {
8
8
  let e = l.status ?? 200, n = t(o, l, l.message), r = l.code ?? 5e4, i = "data" in l ? {
9
9
  code: r,
10
10
  data: l.data,
@@ -21,10 +21,13 @@ function r(r, o, s, c) {
21
21
  message: n(o, "server.errors.network")
22
22
  });
23
23
  }
24
- function i(e) {
25
- return e instanceof Error ? e : Error(String(e));
24
+ function i(e, t) {
25
+ t.info(`error info -> ${o(e)}`), t.error("-- [exception] --", e);
26
26
  }
27
27
  function a(e) {
28
+ return e instanceof Error ? e : Error(String(e));
29
+ }
30
+ function o(e) {
28
31
  if (e instanceof Error) return e.message;
29
32
  try {
30
33
  return JSON.stringify(e);
@@ -33,4 +36,4 @@ function a(e) {
33
36
  }
34
37
  }
35
38
  //#endregion
36
- export { r as respondWithTemplateError };
39
+ export { i as logTemplateError, r as respondWithTemplateError };
@@ -4,8 +4,8 @@ import "../../packages/core/index.js";
4
4
  import { respondWithTemplateError as n } from "./error-response.js";
5
5
  import { TemplateCoreSecurityGuard as r } from "./security.guard.js";
6
6
  import { BadRequestException as i, Catch as a, Inject as o, NotFoundException as s } from "@nestjs/common";
7
- import c from "@oxc-project/runtime/helpers/decorateMetadata";
8
- import l from "@oxc-project/runtime/helpers/decorate";
7
+ import c from "@oxc-project/runtime/helpers/decorate";
8
+ import l from "@oxc-project/runtime/helpers/decorateMetadata";
9
9
  import u from "@oxc-project/runtime/helpers/decorateParam";
10
10
  //#region app/http/exception-filter.ts
11
11
  var d, f, p = class {
@@ -36,10 +36,10 @@ var d, f, p = class {
36
36
  n(e, a, r, this.logger);
37
37
  }
38
38
  };
39
- p = l([
39
+ p = c([
40
40
  a(),
41
41
  u(0, o(e)),
42
- c("design:paramtypes", [
42
+ l("design:paramtypes", [
43
43
  Object,
44
44
  typeof (d = t !== void 0 && t) == "function" ? d : Object,
45
45
  typeof (f = r !== void 0 && r) == "function" ? f : Object
@@ -0,0 +1,46 @@
1
+ import { match as e } from "path-to-regexp";
2
+ //#region app/http/request-body-parser-policy.ts
3
+ var t = Symbol("template-core:request-body-parser-policies");
4
+ function n(e) {
5
+ if (e !== void 0 && (!e || typeof e != "object" || Array.isArray(e))) throw Error("[http] requestBodyParser must be an object");
6
+ let t = e?.policies;
7
+ if (t === void 0) return [];
8
+ if (!Array.isArray(t)) throw Error("[http] requestBodyParser.policies must be an array");
9
+ let n = /* @__PURE__ */ new Set();
10
+ return t.map((e, t) => r(e, t, n));
11
+ }
12
+ function r(t, n, r) {
13
+ if (!t || typeof t != "object" || Array.isArray(t)) throw Error(`[http] requestBodyParser.policies[${n}] must be an object`);
14
+ if (!i(t.method)) throw Error(`[http] requestBodyParser.policies[${n}].method is not a supported HTTP method`);
15
+ if (typeof t.path != "string" || !t.path.startsWith("/")) throw Error(`[http] requestBodyParser.policies[${n}].path must be an absolute route pattern`);
16
+ if (t.onMalformedJson !== "status-500-empty") throw Error(`[http] requestBodyParser.policies[${n}].onMalformedJson is not supported`);
17
+ let a = `${t.method}:${t.path.toLowerCase()}`;
18
+ if (r.has(a)) throw Error(`[http] Duplicate request body parser policy for ${t.method} ${t.path}`);
19
+ r.add(a);
20
+ let o;
21
+ try {
22
+ o = e(t.path, { decode: !1 });
23
+ } catch (e) {
24
+ throw Error(`[http] Invalid request body parser policy path ${t.path}`, { cause: e });
25
+ }
26
+ return {
27
+ method: t.method,
28
+ onMalformedJson: t.onMalformedJson,
29
+ matches: (e) => o(e) !== !1
30
+ };
31
+ }
32
+ function i(e) {
33
+ return typeof e == "string" && [
34
+ "CONNECT",
35
+ "DELETE",
36
+ "GET",
37
+ "HEAD",
38
+ "OPTIONS",
39
+ "PATCH",
40
+ "POST",
41
+ "PUT",
42
+ "TRACE"
43
+ ].includes(e);
44
+ }
45
+ //#endregion
46
+ export { t as REQUEST_BODY_PARSER_POLICIES, n as compileRequestBodyParserPolicies };
@@ -2,16 +2,18 @@ import { TC_CRYPTO as e } from "../../packages/core/tokens.js";
2
2
  import { TemplateCoreRuntime as t } from "../../packages/core/startup.js";
3
3
  import "../../packages/core/index.js";
4
4
  import { createTemplateCoreError as n } from "./errors.js";
5
- import { getProjectKey as r } from "./context.js";
6
- import { Inject as i, Injectable as a } from "@nestjs/common";
7
- import o from "@oxc-project/runtime/helpers/decorateMetadata";
5
+ import { resolveApiSigningMode as r } from "./api-signing.js";
6
+ import { getProjectKey as i } from "./context.js";
7
+ import { Inject as a, Injectable as o } from "@nestjs/common";
8
8
  import s from "@oxc-project/runtime/helpers/decorate";
9
- import c from "@oxc-project/runtime/helpers/decorateParam";
10
- import l from "md5";
9
+ import c from "@oxc-project/runtime/helpers/decorateMetadata";
10
+ import l from "@oxc-project/runtime/helpers/decorateParam";
11
+ import u from "md5";
11
12
  //#region app/http/security.guard.ts
12
- var u, d = 600 * 1e3, f = Symbol("template-core:request-security-verified"), p = class {
13
+ var d, f = 600 * 1e3, p = Symbol("template-core:request-security-verified"), m = class {
14
+ signingMode;
13
15
  constructor(e, t) {
14
- this.crypto = e, this.runtime = t;
16
+ this.crypto = e, this.runtime = t, this.signingMode = r(t.config);
15
17
  }
16
18
  canActivate(e) {
17
19
  let t = e.switchToHttp().getRequest();
@@ -19,33 +21,33 @@ var u, d = 600 * 1e3, f = Symbol("template-core:request-security-verified"), p =
19
21
  }
20
22
  assertRequestAllowed(e) {
21
23
  let t = e;
22
- t[f] || (this.validateRequest(e), t[f] = !0);
24
+ t[p] || (this.validateRequest(e), t[p] = !0);
23
25
  }
24
26
  validateRequest(e) {
25
- let t = e.path, i = this.runtime.options.apiPrefix, a = r(e);
26
- if (t.includes(`${i}/proj/`) && (!a || ["undefined", "null"].includes(a))) throw n("", {
27
+ let t = e.path, r = this.runtime.options.apiPrefix, a = i(e);
28
+ if (t.includes(`${r}/proj/`) && (!a || ["undefined", "null"].includes(a))) throw n("", {
27
29
  code: 110,
28
30
  data: null,
29
31
  i18nKey: "server.errors.invalidRequest"
30
32
  });
31
- if (this.runtime.environment === "local" || !t.includes(i) || this.runtime.config.apiSignVerify && h(t, this.runtime.config.apiSignVerify)) return;
32
- let o = m(e, "s_t"), s = m(e, "s_sign"), c = l(`${String(this.runtime.config.signKey)}_${o}`);
33
- if (!o || !s || !this.crypto.safeEqual(s.toLowerCase(), c) || Date.now() - Number(o) > d) throw n("signature not correct or api timeout", { code: 100014 });
33
+ if (this.signingMode === "shared" && this.runtime.environment === "local" || !t.includes(r) || this.runtime.config.apiSignVerify && g(t, this.runtime.config.apiSignVerify)) return;
34
+ let o = h(e, "s_t"), s = h(e, "s_sign"), c = u(`${String(this.runtime.config.signKey)}_${o}`);
35
+ if (!o || !s || !this.crypto.safeEqual(s.toLowerCase(), c) || Date.now() - Number(o) > f) throw n("signature not correct or api timeout", { code: 100014 });
34
36
  }
35
37
  };
36
- p = s([
37
- a(),
38
- c(0, i(e)),
39
- o("design:paramtypes", [Object, typeof (u = t !== void 0 && t) == "function" ? u : Object])
40
- ], p);
41
- function m(e, t) {
38
+ m = s([
39
+ o(),
40
+ l(0, a(e)),
41
+ c("design:paramtypes", [Object, typeof (d = t !== void 0 && t) == "function" ? d : Object])
42
+ ], m);
43
+ function h(e, t) {
42
44
  let n = e.headers[t];
43
45
  return Array.isArray(n) ? n[0] : n;
44
46
  }
45
- function h(e, t) {
47
+ function g(e, t) {
46
48
  if (!t || typeof t != "object" || !("whiteList" in t)) return !1;
47
49
  let n = t.whiteList;
48
50
  return Array.isArray(n) && n.includes(e);
49
51
  }
50
52
  //#endregion
51
- export { p as TemplateCoreSecurityGuard };
53
+ export { m as TemplateCoreSecurityGuard };
@@ -4,8 +4,8 @@ import { RequestData as r } from "../http/request-data.js";
4
4
  import { RequestSchema as i } from "../http/request-schema.pipe.js";
5
5
  import { TemplateCoreProjectService as a } from "./service.js";
6
6
  import { Controller as o, Get as s, Param as c } from "@nestjs/common";
7
- import l from "@oxc-project/runtime/helpers/decorateMetadata";
8
- import u from "@oxc-project/runtime/helpers/decorate";
7
+ import l from "@oxc-project/runtime/helpers/decorate";
8
+ import u from "@oxc-project/runtime/helpers/decorateMetadata";
9
9
  import d from "@oxc-project/runtime/helpers/decorateParam";
10
10
  //#region app/project/controller.ts
11
11
  function f(f) {
@@ -44,22 +44,22 @@ function f(f) {
44
44
  return o ? n(o) : t(10001, e(a, "server.errors.getProjectFailed"));
45
45
  }
46
46
  };
47
- return u([
47
+ return l([
48
48
  s("model_list"),
49
- l("design:type", Function),
50
- l("design:paramtypes", []),
51
- l("design:returntype", void 0)
52
- ], m.prototype, "getModelList", null), u([
49
+ u("design:type", Function),
50
+ u("design:paramtypes", []),
51
+ u("design:returntype", void 0)
52
+ ], m.prototype, "getModelList", null), l([
53
53
  s("list"),
54
54
  d(0, i({ query: {
55
55
  type: "object",
56
56
  properties: { projk: { type: "string" } }
57
57
  } })),
58
58
  d(1, r()),
59
- l("design:type", Function),
60
- l("design:paramtypes", [Object, Object]),
61
- l("design:returntype", void 0)
62
- ], m.prototype, "getProjectList", null), u([
59
+ u("design:type", Function),
60
+ u("design:paramtypes", [Object, Object]),
61
+ u("design:returntype", void 0)
62
+ ], m.prototype, "getProjectList", null), l([
63
63
  s(":key"),
64
64
  d(0, i({ params: {
65
65
  type: "object",
@@ -68,14 +68,14 @@ function f(f) {
68
68
  } })),
69
69
  d(1, c("key")),
70
70
  d(2, r()),
71
- l("design:type", Function),
72
- l("design:paramtypes", [
71
+ u("design:type", Function),
72
+ u("design:paramtypes", [
73
73
  Object,
74
74
  String,
75
75
  Object
76
76
  ]),
77
- l("design:returntype", void 0)
78
- ], m.prototype, "getProject", null), m = u([o(`${f}/project`), l("design:paramtypes", [typeof (p = a !== void 0 && a) == "function" ? p : Object])], m), m;
77
+ u("design:returntype", void 0)
78
+ ], m.prototype, "getProject", null), m = l([o(`${f}/project`), u("design:paramtypes", [typeof (p = a !== void 0 && a) == "function" ? p : Object])], m), m;
79
79
  }
80
80
  //#endregion
81
81
  export { f as createProjectController };
@@ -2,8 +2,8 @@ import { TemplateCoreRuntime as e } from "../../packages/core/startup.js";
2
2
  import t from "../../packages/core/loader/model.js";
3
3
  import "../../packages/core/index.js";
4
4
  import { Injectable as n } from "@nestjs/common";
5
- import r from "@oxc-project/runtime/helpers/decorateMetadata";
6
- import i from "@oxc-project/runtime/helpers/decorate";
5
+ import r from "@oxc-project/runtime/helpers/decorate";
6
+ import i from "@oxc-project/runtime/helpers/decorateMetadata";
7
7
  //#region app/project/service.ts
8
8
  var a, o = "tc:project-service", s = class {
9
9
  modelData;
@@ -29,7 +29,7 @@ var a, o = "tc:project-service", s = class {
29
29
  return t;
30
30
  }
31
31
  };
32
- s = i([n(), r("design:paramtypes", [typeof (a = e !== void 0 && e) == "function" ? a : Object])], s);
32
+ s = r([n(), i("design:paramtypes", [typeof (a = e !== void 0 && e) == "function" ? a : Object])], s);
33
33
  var c = Symbol.for("tc:project-service-constructor"), l = globalThis, u = l[c] ??= s;
34
34
  //#endregion
35
35
  export { o as TC_PROJECT_SERVICE, u as TemplateCoreProjectService };
@@ -6,9 +6,9 @@ import { createCrypto as m } from "../extends/crypto.js";
6
6
  import { createFrameworkDB as h } from "../extends/db.js";
7
7
  import { createFrameworkLogger as g } from "../extends/logger.js";
8
8
  import { Inject as _, Injectable as v } from "@nestjs/common";
9
- import { ModuleRef as y } from "@nestjs/core";
10
- import b from "@oxc-project/runtime/helpers/decorateMetadata";
11
- import x from "@oxc-project/runtime/helpers/decorate";
9
+ import y from "@oxc-project/runtime/helpers/decorate";
10
+ import { ModuleRef as b } from "@nestjs/core";
11
+ import x from "@oxc-project/runtime/helpers/decorateMetadata";
12
12
  import S from "@oxc-project/runtime/helpers/decorateParam";
13
13
  //#region app/providers/foundation.ts
14
14
  var C, w;
@@ -70,10 +70,10 @@ var E = class {
70
70
  if (a.length > 1) throw AggregateError(a, "[core] Unable to initialize foundation providers");
71
71
  }
72
72
  };
73
- E = x([
73
+ E = y([
74
74
  v(),
75
75
  S(1, _(s)),
76
- b("design:paramtypes", [typeof (C = y !== void 0 && y) == "function" ? C : Object, typeof (w = s !== void 0 && s) == "function" ? w : Object])
76
+ x("design:paramtypes", [typeof (C = b !== void 0 && b) == "function" ? C : Object, typeof (w = s !== void 0 && s) == "function" ? w : Object])
77
77
  ], E);
78
78
  function D(s, c = []) {
79
79
  let l = s.options.providerOverrides, u = [
@@ -2,12 +2,12 @@ import { TemplateCoreRuntime as e } from "../../packages/core/startup.js";
2
2
  import "../../packages/core/index.js";
3
3
  import { FrontendDevelopment as t } from "../frontend-development.js";
4
4
  import { SSR_CLIENT_MANIFEST_FILE as n, SSR_MANIFEST_OUT_DIR as r, SSR_SERVER_OUT_DIR as i, resolveSSRPrivateDir as a } from "../../ssrSharedData/outputPaths.js";
5
- import { Injectable as o } from "@nestjs/common";
6
- import s from "node:fs";
7
- import c from "node:path";
8
- import { pathToFileURL as l } from "node:url";
9
- import u from "@oxc-project/runtime/helpers/decorateMetadata";
10
- import d from "@oxc-project/runtime/helpers/decorate";
5
+ import o from "node:fs";
6
+ import s from "node:path";
7
+ import { pathToFileURL as c } from "node:url";
8
+ import { Injectable as l } from "@nestjs/common";
9
+ import u from "@oxc-project/runtime/helpers/decorate";
10
+ import d from "@oxc-project/runtime/helpers/decorateMetadata";
11
11
  //#region app/ssr/artifacts.ts
12
12
  var f, p, m = class {
13
13
  bundles = /* @__PURE__ */ new Map();
@@ -24,11 +24,11 @@ var f, p, m = class {
24
24
  }
25
25
  let t = this.resolvePrivateDirectory(i);
26
26
  if (!t) return null;
27
- let n = s.realpathSync(t), r = [`${e}.mjs`, `${e}.js`].map((e) => c.resolve(t, e)).find((e) => this.isInside(e, t) && s.existsSync(e) && this.isInside(s.realpathSync(e), n));
27
+ let n = o.realpathSync(t), r = [`${e}.mjs`, `${e}.js`].map((e) => s.resolve(t, e)).find((e) => this.isInside(e, t) && o.existsSync(e) && this.isInside(o.realpathSync(e), n));
28
28
  if (!r) return null;
29
- let a = s.statSync(r).mtimeMs, o = this.bundles.get(e);
30
- if (o?.path === r && o.mtime === a) return o.module;
31
- let u = l(r);
29
+ let a = o.statSync(r).mtimeMs, l = this.bundles.get(e);
30
+ if (l?.path === r && l.mtime === a) return l.module;
31
+ let u = c(r);
32
32
  u.searchParams.set("t", String(a));
33
33
  let d = await import(u.href);
34
34
  return this.bundles.set(e, {
@@ -40,27 +40,31 @@ var f, p, m = class {
40
40
  readManifest() {
41
41
  let e = this.resolvePrivateDirectory(r);
42
42
  if (!e) return null;
43
- let t = c.join(e, n);
44
- if (!s.existsSync(t)) return null;
45
- let i = s.statSync(t).mtimeMs, a = this.manifests.get(t);
43
+ let t = s.join(e, n);
44
+ if (!o.existsSync(t)) return null;
45
+ let i = o.statSync(t).mtimeMs, a = this.manifests.get(t);
46
46
  if (a?.mtime === i) return a.manifest;
47
- let o = JSON.parse(s.readFileSync(t, "utf8"));
47
+ let c = JSON.parse(o.readFileSync(t, "utf8"));
48
48
  return this.manifests.set(t, {
49
- manifest: o,
49
+ manifest: c,
50
50
  mtime: i
51
- }), o;
51
+ }), c;
52
+ }
53
+ readBuildKey() {
54
+ let e = this.runtime.paths.publicPaths.map((e) => s.resolve(e, "dist/FEBuildKey")).find((e) => o.existsSync(e));
55
+ return e && o.readFileSync(e, "utf8").trim() || null;
52
56
  }
53
57
  resolvePrivateDirectory(e) {
54
- return this.runtime.paths.publicPaths.map((t) => a(t, e)).find((e) => s.existsSync(e));
58
+ return this.runtime.paths.publicPaths.map((t) => a(t, e)).find((e) => o.existsSync(e));
55
59
  }
56
60
  isInside(e, t) {
57
- let n = c.relative(t, e);
58
- return !!n && !n.startsWith("..") && !c.isAbsolute(n);
61
+ let n = s.relative(t, e);
62
+ return !!n && !n.startsWith("..") && !s.isAbsolute(n);
59
63
  }
60
64
  };
61
- m = d([o(), u("design:paramtypes", [typeof (f = e !== void 0 && e) == "function" ? f : Object, typeof (p = t !== void 0 && t) == "function" ? p : Object])], m);
65
+ m = u([l(), d("design:paramtypes", [typeof (f = e !== void 0 && e) == "function" ? f : Object, typeof (p = t !== void 0 && t) == "function" ? p : Object])], m);
62
66
  function h(e) {
63
- return !e || typeof e != "object" || !("default" in e) || typeof e.default != "function" && (typeof e.default != "object" || !e.default) ? !1 : !("getServerProps" in e) || e.getServerProps === void 0 || typeof e.getServerProps == "function";
67
+ return !e || typeof e != "object" || !("default" in e) || typeof e.default != "function" && (typeof e.default != "object" || !e.default) || "getServerProps" in e && e.getServerProps !== void 0 && typeof e.getServerProps != "function" ? !1 : !("layout" in e) || e.layout === void 0 || typeof e.layout == "function";
64
68
  }
65
69
  //#endregion
66
70
  export { m as SSRArtifacts };