@_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.
- package/.skills/tc-component-usage-skills/reference/component-api.md +27 -0
- package/.skills/tc-generator/SKILL.md +1 -1
- package/.skills/tc-generator/reference/project-template/ssr/apps/hello/hello.entry.tsx +6 -1
- package/.skills/tc-generator/reference/runtime-extensions.md +10 -0
- package/AGENT_README.md +8 -2
- package/CHANGE.md +27 -0
- package/README.md +157 -8
- package/cjs/app/ai/agent/agent-scanner.service.js +1 -1
- package/cjs/app/ai/agent/agent.module.js +1 -1
- package/cjs/app/ai/ai-config.module.js +1 -1
- package/cjs/app/ai/ai-config.service.js +1 -1
- package/cjs/app/ai/ai.controller.js +1 -1
- package/cjs/app/ai/ai.module.js +1 -1
- package/cjs/app/ai/guardrail/guardrail.module.js +1 -1
- package/cjs/app/ai/guardrail/guardrail.service.js +1 -1
- package/cjs/app/ai/index.js +1 -0
- package/cjs/app/ai/mcp/internal/read-sse-response.js +2 -0
- package/cjs/app/ai/mcp/internal/stdio-process.js +1 -0
- package/cjs/app/ai/mcp/mcp-registry.service.js +2 -2
- package/cjs/app/ai/mcp/mcp.client.js +2 -3
- package/cjs/app/ai/mcp/mcp.loader.js +1 -1
- package/cjs/app/ai/mcp/mcp.module.js +1 -1
- package/cjs/app/ai/memory/checkpoint.service.js +1 -1
- package/cjs/app/ai/memory/memory.module.js +1 -1
- package/cjs/app/ai/memory/thread.service.js +1 -1
- package/cjs/app/ai/models/chat-sse.js +4 -0
- package/cjs/app/ai/models/chat.js +1 -0
- package/cjs/app/ai/models/http.js +1 -0
- package/cjs/app/ai/models/image.js +1 -0
- package/cjs/app/ai/models/video.js +1 -0
- package/cjs/app/ai/nest-service-provider.js +1 -0
- package/cjs/app/ai/rag/rag.module.js +1 -1
- package/cjs/app/ai/rag/retriever.service.js +1 -1
- package/cjs/app/ai/retention/conversation-retention.service.js +1 -1
- package/cjs/app/ai/runtime/ai-runtime-startup.validator.js +1 -1
- package/cjs/app/ai/runtime/ai-runtime.js +1 -0
- package/cjs/app/ai/runtime/internal/context-compaction.service.js +3 -3
- package/cjs/app/ai/runtime/internal/declaration-snapshot.js +1 -0
- package/cjs/app/ai/runtime/internal/owned-runtime-resources.js +1 -0
- package/cjs/app/ai/runtime/langchain/langchain-planner.service.js +1 -1
- package/cjs/app/ai/runtime/langgraph/langgraph-orchestrator.service.js +1 -1
- package/cjs/app/ai/runtime/runtime.module.js +1 -1
- package/cjs/app/ai/skill/skill-scanner.service.js +1 -1
- package/cjs/app/ai/skill/skill.module.js +1 -1
- package/cjs/app/ai/snapshot-data.js +1 -0
- package/cjs/app/ai/store/internal/create-vector-store.js +1 -0
- package/cjs/app/ai/store/store.module.js +1 -1
- package/cjs/app/ai/tool/builtin/index.js +1 -1
- package/cjs/app/ai/tool/builtin/invoke-agent.tool.js +1 -1
- package/cjs/app/ai/tool/builtin/retrieve.tool.js +1 -1
- package/cjs/app/ai/tool/executor.service.js +1 -1
- package/cjs/app/ai/tool/tool-registry.service.js +1 -1
- package/cjs/app/ai/tool/tool.module.js +1 -1
- package/cjs/app/ai/trace/trace.service.js +1 -1
- package/cjs/app/csr/controller.js +1 -1
- package/cjs/app/csr/types.js +0 -0
- package/cjs/app/html/browser-options.js +1 -1
- package/cjs/app/html/shell.js +31 -16
- package/cjs/app/http/api-signing.js +1 -0
- package/cjs/app/http/body-parser.middleware.js +1 -1
- package/cjs/app/http/csp-nonce.js +1 -0
- package/cjs/app/http/error-response.js +1 -1
- package/cjs/app/http/exception-filter.js +1 -1
- package/cjs/app/http/request-body-parser-policy.js +1 -0
- package/cjs/app/http/security.guard.js +1 -1
- package/cjs/app/project/controller.js +1 -1
- package/cjs/app/project/service.js +1 -1
- package/cjs/app/providers/foundation.js +1 -1
- package/cjs/app/ssr/artifacts.js +1 -1
- package/cjs/app/ssr/controller.js +1 -1
- package/cjs/app/ssr/html.js +17 -17
- package/cjs/app/ssr/stream.js +1 -1
- package/cjs/app/static-assets.middleware.js +1 -1
- package/cjs/app/template-core.module.js +1 -1
- package/cjs/app/view/entry.tpl +2 -2
- package/cjs/bundler/buildSSR.js +1 -1
- package/cjs/bundler/entryCollect.js +1 -1
- package/cjs/bundler/feSharedConfig.js +1 -1
- package/cjs/bundler/utils.js +3 -3
- package/cjs/config/config.default.js +1 -1
- package/cjs/packages/common/index.js +1 -1
- package/cjs/packages/core/bootstrap.js +1 -1
- package/cjs/packages/core/startup.js +1 -1
- package/esm/app/ai/agent/agent-scanner.service.js +33 -36
- package/esm/app/ai/agent/agent.module.js +9 -7
- package/esm/app/ai/ai-config.module.js +14 -7
- package/esm/app/ai/ai-config.service.js +24 -20
- package/esm/app/ai/ai.controller.js +41 -41
- package/esm/app/ai/ai.module.js +15 -15
- package/esm/app/ai/guardrail/guardrail.module.js +11 -9
- package/esm/app/ai/guardrail/guardrail.service.js +5 -10
- package/esm/app/ai/index.js +2 -0
- package/esm/app/ai/mcp/internal/read-sse-response.js +35 -0
- package/esm/app/ai/mcp/internal/stdio-process.js +59 -0
- package/esm/app/ai/mcp/mcp-registry.service.js +10 -15
- package/esm/app/ai/mcp/mcp.client.js +77 -78
- package/esm/app/ai/mcp/mcp.loader.js +64 -42
- package/esm/app/ai/mcp/mcp.module.js +62 -22
- package/esm/app/ai/memory/checkpoint.service.js +18 -28
- package/esm/app/ai/memory/memory.module.js +15 -12
- package/esm/app/ai/memory/thread.service.js +21 -26
- package/esm/app/ai/models/chat-sse.js +44 -0
- package/esm/app/ai/models/chat.js +60 -0
- package/esm/app/ai/models/http.js +52 -0
- package/esm/app/ai/models/image.js +37 -0
- package/esm/app/ai/models/video.js +32 -0
- package/esm/app/ai/nest-service-provider.js +10 -0
- package/esm/app/ai/rag/rag.module.js +24 -15
- package/esm/app/ai/rag/retriever.service.js +37 -54
- package/esm/app/ai/retention/conversation-retention.service.js +16 -34
- package/esm/app/ai/runtime/ai-runtime-startup.validator.js +2 -19
- package/esm/app/ai/runtime/ai-runtime.js +104 -0
- package/esm/app/ai/runtime/internal/context-compaction.service.js +139 -145
- package/esm/app/ai/runtime/internal/declaration-snapshot.js +32 -0
- package/esm/app/ai/runtime/internal/owned-runtime-resources.js +21 -0
- package/esm/app/ai/runtime/langchain/langchain-planner.service.js +43 -49
- package/esm/app/ai/runtime/langgraph/langgraph-orchestrator.service.js +273 -225
- package/esm/app/ai/runtime/runtime.module.js +56 -35
- package/esm/app/ai/skill/skill-scanner.service.js +11 -16
- package/esm/app/ai/skill/skill.module.js +11 -9
- package/esm/app/ai/snapshot-data.js +24 -0
- package/esm/app/ai/store/internal/create-vector-store.js +10 -0
- package/esm/app/ai/store/store.module.js +9 -13
- package/esm/app/ai/tool/builtin/index.js +16 -4
- package/esm/app/ai/tool/builtin/invoke-agent.tool.js +30 -34
- package/esm/app/ai/tool/builtin/retrieve.tool.js +9 -13
- package/esm/app/ai/tool/executor.service.js +22 -29
- package/esm/app/ai/tool/tool-registry.service.js +6 -16
- package/esm/app/ai/tool/tool.module.js +26 -12
- package/esm/app/ai/trace/trace.service.js +15 -28
- package/esm/app/csr/controller.js +114 -63
- package/esm/app/csr/types.js +0 -0
- package/esm/app/html/browser-options.js +2 -2
- package/esm/app/html/shell.js +173 -32
- package/esm/app/http/api-signing.js +13 -0
- package/esm/app/http/body-parser.middleware.js +47 -27
- package/esm/app/http/csp-nonce.js +13 -0
- package/esm/app/http/error-response.js +8 -5
- package/esm/app/http/exception-filter.js +4 -4
- package/esm/app/http/request-body-parser-policy.js +46 -0
- package/esm/app/http/security.guard.js +23 -21
- package/esm/app/project/controller.js +15 -15
- package/esm/app/project/service.js +3 -3
- package/esm/app/providers/foundation.js +5 -5
- package/esm/app/ssr/artifacts.js +25 -21
- package/esm/app/ssr/controller.js +148 -75
- package/esm/app/ssr/html.js +49 -44
- package/esm/app/ssr/stream.js +25 -24
- package/esm/app/static-assets.middleware.js +4 -4
- package/esm/app/template-core.module.js +57 -52
- package/esm/app/view/entry.tpl +2 -2
- package/esm/bundler/buildSSR.js +1 -1
- package/esm/bundler/entryCollect.js +9 -9
- package/esm/bundler/feSharedConfig.js +42 -42
- package/esm/bundler/utils.js +78 -90
- package/esm/config/config.default.js +4 -3
- package/esm/packages/common/index.js +6 -6
- package/esm/packages/core/bootstrap.js +5 -5
- package/esm/packages/core/startup.js +69 -46
- package/fe/frontend/src/common/request.js +5 -2
- package/fe/frontend/src/hooks/useRouterParams.d.ts +4 -2
- package/fe/packages/common/ssr/hydration.d.ts +9 -0
- package/fe/packages/react/core/Label/Label.d.ts +1 -0
- package/fe/packages/react/core/Label/Label.js +3 -1
- package/fe/packages/react/core/internal/i18n/default.d.ts +13 -0
- package/fe/packages/react/core/internal/i18n/default.js +16 -1
- package/fe/packages/react/core/internal/i18n/en-US.d.ts +13 -0
- package/fe/packages/react/core/internal/i18n/en-US.js +16 -1
- package/fe/packages/react/forms/DataTable/index.d.ts +2 -0
- package/fe/packages/react/forms/DataTable/index.js +43 -29
- package/fe/packages/react/forms/Form/FormItem.js +39 -12
- package/fe/packages/react/forms/MultiSelect/MultiSelect.d.ts +26 -0
- package/fe/packages/react/forms/MultiSelect/MultiSelect.js +218 -0
- package/fe/packages/react/forms/MultiSelect/index.d.ts +1 -0
- package/fe/packages/react/forms/MultiSelect/index.js +2 -0
- package/fe/packages/react/forms/Pagination/Pagination.d.ts +6 -1
- package/fe/packages/react/forms/Pagination/Pagination.js +13 -4
- package/fe/packages/react/forms/Select/Select.d.ts +11 -0
- package/fe/packages/react/forms/Select/Select.js +20 -7
- package/fe/packages/react/forms/index.d.ts +1 -0
- package/fe/packages/react/forms/index.js +3 -1
- package/fe/packages/react/i18n/getUiReactLocale.d.ts +26 -0
- package/fe/packages/react/index.js +2 -1
- package/fe/packages/react/overlays/Drawer/Drawer.d.ts +3 -2
- package/fe/packages/react/overlays/Drawer/Drawer.js +16 -2
- package/fe/packages/react/overlays/Dropdown/Dropdown.d.ts +12 -2
- package/fe/packages/react/overlays/Dropdown/Dropdown.js +27 -14
- package/fe/packages/react/overlays/Modal/Modal.d.ts +11 -3
- package/fe/packages/react/overlays/Modal/Modal.js +26 -2
- package/fe/packages/react/overlays/Modal/ModalManager.d.ts +13 -12
- package/fe/packages/react/overlays/Modal/ModalManager.js +15 -5
- package/fe/packages/react/overlays/Modal/index.d.ts +1 -0
- package/fe/packages/react/overlays/Overlay/Overlay.d.ts +6 -2
- package/fe/packages/react/overlays/Overlay/Overlay.js +31 -14
- package/fe/packages/react/overlays/Overlay/focusTypes.d.ts +8 -0
- package/fe/packages/react/overlays/Overlay/focusTypes.js +0 -0
- package/fe/packages/react/overlays/Overlay/index.d.ts +1 -0
- package/fe/packages/react/overlays/Overlay/overlayStack.d.ts +16 -0
- package/fe/packages/react/overlays/Overlay/overlayStack.js +290 -0
- package/fe/packages/react/overlays/Popup/Popup.d.ts +5 -4
- package/fe/packages/react/overlays/Popup/Popup.js +28 -11
- package/fe/packages/react/ui/components/index.js +2 -1
- package/fe/packages/react/ui/index.js +2 -1
- package/fe/ssr/components/StreamingRender/StreamingCache.d.ts +1 -0
- package/fe/ssr/components/StreamingRender/StreamingCache.js +5 -1
- package/fe/ssr/components/StreamingRender/StreamingRender.js +1 -1
- package/fe/ssr/components/StreamingRender/StreamingScript.d.ts +1 -0
- package/fe/ssr/components/StreamingRender/StreamingScript.js +9 -1
- package/fe/ssr/createSSREntry.d.ts +9 -3
- package/fe/ssr/createSSREntry.js +43 -19
- package/fe/ssr/index.d.ts +4 -1
- package/fe/ssr/index.js +2 -1
- package/fe/ssr/router.d.ts +76 -0
- package/fe/ssr/router.js +349 -0
- package/fe/ssr/types.d.ts +1 -1
- package/models/packages/common/ssr/hydration.d.ts +9 -0
- package/models/packages/react/core/Label/Label.d.ts +1 -0
- package/models/packages/react/core/internal/i18n/default.d.ts +13 -0
- package/models/packages/react/core/internal/i18n/en-US.d.ts +13 -0
- package/models/packages/react/forms/DataTable/index.d.ts +2 -0
- package/models/packages/react/forms/MultiSelect/MultiSelect.d.ts +26 -0
- package/models/packages/react/forms/MultiSelect/index.d.ts +1 -0
- package/models/packages/react/forms/Pagination/Pagination.d.ts +6 -1
- package/models/packages/react/forms/Select/Select.d.ts +11 -0
- package/models/packages/react/forms/index.d.ts +1 -0
- package/models/packages/react/i18n/getUiReactLocale.d.ts +26 -0
- package/models/packages/react/overlays/Drawer/Drawer.d.ts +3 -2
- package/models/packages/react/overlays/Dropdown/Dropdown.d.ts +12 -2
- package/models/packages/react/overlays/Modal/Modal.d.ts +11 -3
- package/models/packages/react/overlays/Modal/ModalManager.d.ts +13 -12
- package/models/packages/react/overlays/Modal/index.d.ts +1 -0
- package/models/packages/react/overlays/Overlay/Overlay.d.ts +6 -2
- package/models/packages/react/overlays/Overlay/focusTypes.d.ts +8 -0
- package/models/packages/react/overlays/Overlay/index.d.ts +1 -0
- package/models/packages/react/overlays/Overlay/overlayStack.d.ts +16 -0
- package/models/packages/react/overlays/Popup/Popup.d.ts +5 -4
- package/package.json +26 -1
- package/types/app/ai/agent/agent-scanner.service.d.ts +4 -4
- package/types/app/ai/ai-config.service.d.ts +7 -3
- package/types/app/ai/guardrail/guardrail.service.d.ts +2 -2
- package/types/app/ai/index.d.ts +9 -0
- package/types/app/ai/mcp/internal/load-mcp-config.d.ts +2 -2
- package/types/app/ai/mcp/internal/read-sse-response.d.ts +2 -0
- package/types/app/ai/mcp/internal/stdio-process.d.ts +5 -0
- package/types/app/ai/mcp/mcp-registry.service.d.ts +5 -3
- package/types/app/ai/mcp/mcp.client.d.ts +7 -4
- package/types/app/ai/mcp/mcp.loader.d.ts +11 -11
- package/types/app/ai/mcp/mcp.module.d.ts +5 -5
- package/types/app/ai/memory/thread.service.d.ts +3 -3
- package/types/app/ai/models/chat-sse.d.ts +5 -0
- package/types/app/ai/models/chat.d.ts +22 -0
- package/types/app/ai/models/http.d.ts +20 -0
- package/types/app/ai/models/image.d.ts +69 -0
- package/types/app/ai/models/video.d.ts +99 -0
- package/types/app/ai/nest-service-provider.d.ts +6 -0
- package/types/app/ai/retention/conversation-retention.service.d.ts +3 -4
- package/types/app/ai/runtime/ai-runtime-startup.validator.d.ts +2 -3
- package/types/app/ai/runtime/ai-runtime.d.ts +46 -0
- package/types/app/ai/runtime/internal/agent-run-context.d.ts +4 -0
- package/types/app/ai/runtime/internal/context-compaction.service.d.ts +2 -2
- package/types/app/ai/runtime/internal/declaration-snapshot.d.ts +8 -0
- package/types/app/ai/runtime/internal/owned-runtime-resources.d.ts +5 -0
- package/types/app/ai/runtime/langchain/langchain-planner.service.d.ts +1 -1
- package/types/app/ai/runtime/langgraph/langgraph-orchestrator.service.d.ts +33 -16
- package/types/app/ai/skill/skill-scanner.service.d.ts +3 -4
- package/types/app/ai/snapshot-data.d.ts +1 -0
- package/types/app/ai/store/internal/create-vector-store.d.ts +4 -0
- package/types/app/ai/tool/builtin/index.d.ts +1 -1
- package/types/app/ai/tool/builtin/invoke-agent.tool.d.ts +10 -3
- package/types/app/ai/tool/builtin/retrieve.tool.d.ts +4 -3
- package/types/app/ai/tool/executor.service.d.ts +3 -3
- package/types/app/ai/tool/tool-registry.service.d.ts +2 -7
- package/types/app/ai/tool/tool.interface.d.ts +1 -1
- package/types/app/ai/tool/tool.module.d.ts +8 -1
- package/types/app/ai/trace/trace.service.d.ts +4 -5
- package/types/app/csr/types.d.ts +10 -0
- package/types/app/html/browser-options.d.ts +1 -1
- package/types/app/html/shell.d.ts +37 -10
- package/types/app/http/api-signing.d.ts +16 -0
- package/types/app/http/body-parser.middleware.d.ts +6 -2
- package/types/app/http/csp-nonce.d.ts +3 -0
- package/types/app/http/error-response.d.ts +1 -0
- package/types/app/http/request-body-parser-policy.d.ts +8 -0
- package/types/app/http/security.guard.d.ts +1 -0
- package/types/app/ssr/artifacts.d.ts +6 -3
- package/types/app/ssr/html.d.ts +7 -0
- package/types/app/ssr/stream.d.ts +1 -1
- package/types/app/ssr/types.d.ts +56 -0
- package/types/bundler/buildSSR.d.ts +2 -1
- package/types/bundler/index.d.ts +1 -1
- package/types/bundler/state.d.ts +13 -0
- package/types/bundler/utils.d.ts +3 -14
- package/types/config/config.default.d.ts +9 -3
- package/types/index.d.ts +4 -1
- package/types/packages/common/ssr/hydration.d.ts +13 -0
- package/types/packages/core/index.d.ts +1 -1
- 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 {
|
|
4
|
-
import {
|
|
5
|
-
import i from "@
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
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
|
|
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
|
-
]),
|
|
17
|
-
function
|
|
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
|
|
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,
|
|
25
|
-
this.parse(e).then(() =>
|
|
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 =
|
|
29
|
-
if (t &&
|
|
30
|
-
e.body = await
|
|
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 ===
|
|
34
|
-
e.body = await
|
|
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 ===
|
|
41
|
-
e.body = await
|
|
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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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 {
|
|
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 =
|
|
7
|
-
if (
|
|
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
|
-
|
|
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/
|
|
8
|
-
import l from "@oxc-project/runtime/helpers/
|
|
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 =
|
|
39
|
+
p = c([
|
|
40
40
|
a(),
|
|
41
41
|
u(0, o(e)),
|
|
42
|
-
|
|
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 {
|
|
6
|
-
import {
|
|
7
|
-
import o from "@
|
|
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/
|
|
10
|
-
import l from "
|
|
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
|
|
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[
|
|
24
|
+
t[p] || (this.validateRequest(e), t[p] = !0);
|
|
23
25
|
}
|
|
24
26
|
validateRequest(e) {
|
|
25
|
-
let t = e.path,
|
|
26
|
-
if (t.includes(`${
|
|
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(
|
|
32
|
-
let o =
|
|
33
|
-
if (!o || !s || !this.crypto.safeEqual(s.toLowerCase(), c) || Date.now() - Number(o) >
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
],
|
|
41
|
-
function
|
|
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
|
|
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 {
|
|
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/
|
|
8
|
-
import u from "@oxc-project/runtime/helpers/
|
|
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
|
|
47
|
+
return l([
|
|
48
48
|
s("model_list"),
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
], m.prototype, "getModelList", null),
|
|
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
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
], m.prototype, "getProjectList", null),
|
|
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
|
-
|
|
72
|
-
|
|
71
|
+
u("design:type", Function),
|
|
72
|
+
u("design:paramtypes", [
|
|
73
73
|
Object,
|
|
74
74
|
String,
|
|
75
75
|
Object
|
|
76
76
|
]),
|
|
77
|
-
|
|
78
|
-
], m.prototype, "getProject", null), 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/
|
|
6
|
-
import i from "@oxc-project/runtime/helpers/
|
|
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 =
|
|
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
|
|
10
|
-
import b from "@
|
|
11
|
-
import x from "@oxc-project/runtime/helpers/
|
|
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 =
|
|
73
|
+
E = y([
|
|
74
74
|
v(),
|
|
75
75
|
S(1, _(s)),
|
|
76
|
-
|
|
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 = [
|
package/esm/app/ssr/artifacts.js
CHANGED
|
@@ -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
|
|
6
|
-
import s from "node:
|
|
7
|
-
import c from "node:
|
|
8
|
-
import {
|
|
9
|
-
import u from "@oxc-project/runtime/helpers/
|
|
10
|
-
import d from "@oxc-project/runtime/helpers/
|
|
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 =
|
|
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 =
|
|
30
|
-
if (
|
|
31
|
-
let u =
|
|
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 =
|
|
44
|
-
if (!
|
|
45
|
-
let i =
|
|
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
|
|
47
|
+
let c = JSON.parse(o.readFileSync(t, "utf8"));
|
|
48
48
|
return this.manifests.set(t, {
|
|
49
|
-
manifest:
|
|
49
|
+
manifest: c,
|
|
50
50
|
mtime: i
|
|
51
|
-
}),
|
|
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) =>
|
|
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 =
|
|
58
|
-
return !!n && !n.startsWith("..") && !
|
|
61
|
+
let n = s.relative(t, e);
|
|
62
|
+
return !!n && !n.startsWith("..") && !s.isAbsolute(n);
|
|
59
63
|
}
|
|
60
64
|
};
|
|
61
|
-
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 : !("
|
|
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 };
|