@mdsnai/sdk 0.2.2 → 0.3.3
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/README.md +40 -76
- package/dist/core/errors.d.ts +14 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +13 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/index.d.ts +16 -4
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +69 -13
- package/dist/core/index.js.map +1 -0
- package/dist/core/markdown-body.d.ts +3 -0
- package/dist/core/markdown-body.d.ts.map +1 -0
- package/dist/core/markdown-body.js +65 -0
- package/dist/core/markdown-body.js.map +1 -0
- package/dist/core/markdown-renderer.d.ts +5 -0
- package/dist/core/markdown-renderer.d.ts.map +1 -0
- package/dist/core/markdown-renderer.js +75 -0
- package/dist/core/markdown-renderer.js.map +1 -0
- package/dist/core/negotiate.d.ts +3 -0
- package/dist/core/negotiate.d.ts.map +1 -0
- package/dist/core/negotiate.js +63 -0
- package/dist/core/negotiate.js.map +1 -0
- package/dist/core/parse/anchors.d.ts +2 -0
- package/dist/core/parse/anchors.d.ts.map +1 -0
- package/dist/core/parse/anchors.js +26 -0
- package/dist/core/parse/anchors.js.map +1 -0
- package/dist/core/parse/block-parser.d.ts +3 -0
- package/dist/core/parse/block-parser.d.ts.map +1 -0
- package/dist/core/parse/block-parser.js +116 -0
- package/dist/core/parse/block-parser.js.map +1 -0
- package/dist/core/parse/executable-block.d.ts +6 -0
- package/dist/core/parse/executable-block.d.ts.map +1 -0
- package/dist/core/parse/executable-block.js +48 -0
- package/dist/core/parse/executable-block.js.map +1 -0
- package/dist/core/parse/frontmatter.d.ts +7 -0
- package/dist/core/parse/frontmatter.d.ts.map +1 -0
- package/dist/core/parse/frontmatter.js +45 -0
- package/dist/core/parse/frontmatter.js.map +1 -0
- package/dist/core/serialize.d.ts +4 -0
- package/dist/core/serialize.d.ts.map +1 -0
- package/dist/core/serialize.js +123 -0
- package/dist/core/serialize.js.map +1 -0
- package/dist/core/types.d.ts +66 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +2 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/validate.d.ts +3 -0
- package/dist/core/validate.d.ts.map +1 -0
- package/dist/core/validate.js +91 -0
- package/dist/core/validate.js.map +1 -0
- package/dist/elements/components/mdsn-action.d.ts +6 -0
- package/dist/elements/components/mdsn-action.d.ts.map +1 -0
- package/dist/elements/components/mdsn-action.js +34 -0
- package/dist/elements/components/mdsn-action.js.map +1 -0
- package/dist/elements/components/mdsn-block.d.ts +9 -0
- package/dist/elements/components/mdsn-block.d.ts.map +1 -0
- package/dist/elements/components/mdsn-block.js +36 -0
- package/dist/elements/components/mdsn-block.js.map +1 -0
- package/dist/elements/components/mdsn-error.d.ts +9 -0
- package/dist/elements/components/mdsn-error.d.ts.map +1 -0
- package/dist/elements/components/mdsn-error.js +36 -0
- package/dist/elements/components/mdsn-error.js.map +1 -0
- package/dist/elements/components/mdsn-field.d.ts +6 -0
- package/dist/elements/components/mdsn-field.d.ts.map +1 -0
- package/dist/elements/components/mdsn-field.js +35 -0
- package/dist/elements/components/mdsn-field.js.map +1 -0
- package/dist/elements/components/mdsn-form.d.ts +6 -0
- package/dist/elements/components/mdsn-form.d.ts.map +1 -0
- package/dist/elements/components/mdsn-form.js +22 -0
- package/dist/elements/components/mdsn-form.js.map +1 -0
- package/dist/elements/components/mdsn-page.d.ts +9 -0
- package/dist/elements/components/mdsn-page.d.ts.map +1 -0
- package/dist/elements/components/mdsn-page.js +46 -0
- package/dist/elements/components/mdsn-page.js.map +1 -0
- package/dist/elements/index.d.ts +3 -0
- package/dist/elements/index.d.ts.map +1 -0
- package/dist/elements/index.js +3 -0
- package/dist/elements/index.js.map +1 -0
- package/dist/elements/mount.d.ts +11 -0
- package/dist/elements/mount.d.ts.map +1 -0
- package/dist/elements/mount.js +245 -0
- package/dist/elements/mount.js.map +1 -0
- package/dist/elements/register.d.ts +2 -0
- package/dist/elements/register.d.ts.map +1 -0
- package/dist/elements/register.js +27 -0
- package/dist/elements/register.js.map +1 -0
- package/dist/elements/theme.d.ts +2 -0
- package/dist/elements/theme.d.ts.map +1 -0
- package/dist/elements/theme.js +13 -0
- package/dist/elements/theme.js.map +1 -0
- package/dist/index.d.ts +4 -8
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -35
- package/dist/index.js.map +1 -0
- package/dist/server/hosted-app.d.ts +35 -0
- package/dist/server/hosted-app.d.ts.map +1 -0
- package/dist/server/hosted-app.js +105 -0
- package/dist/server/hosted-app.js.map +1 -0
- package/dist/server/html-render.d.ts +13 -0
- package/dist/server/html-render.d.ts.map +1 -0
- package/dist/server/html-render.js +316 -0
- package/dist/server/html-render.js.map +1 -0
- package/dist/server/index.d.ts +8 -15
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +6 -32
- package/dist/server/index.js.map +1 -0
- package/dist/server/node.d.ts +23 -0
- package/dist/server/node.d.ts.map +1 -0
- package/dist/server/node.js +200 -0
- package/dist/server/node.js.map +1 -0
- package/dist/server/result.d.ts +15 -0
- package/dist/server/result.d.ts.map +1 -0
- package/dist/server/result.js +64 -0
- package/dist/server/result.js.map +1 -0
- package/dist/server/router.d.ts +12 -0
- package/dist/server/router.d.ts.map +1 -0
- package/dist/server/router.js +24 -0
- package/dist/server/router.js.map +1 -0
- package/dist/server/runtime.d.ts +15 -0
- package/dist/server/runtime.d.ts.map +1 -0
- package/dist/server/runtime.js +245 -0
- package/dist/server/runtime.js.map +1 -0
- package/dist/server/session.d.ts +5 -40
- package/dist/server/session.d.ts.map +1 -0
- package/dist/server/session.js +11 -213
- package/dist/server/session.js.map +1 -0
- package/dist/server/types.d.ts +62 -0
- package/dist/server/types.d.ts.map +1 -0
- package/dist/server/types.js +2 -0
- package/dist/server/types.js.map +1 -0
- package/dist/web/headless.d.ts +22 -92
- package/dist/web/headless.d.ts.map +1 -0
- package/dist/web/headless.js +311 -337
- package/dist/web/headless.js.map +1 -0
- package/dist/web/index.d.ts +2 -11
- package/dist/web/index.d.ts.map +1 -0
- package/dist/web/index.js +2 -23
- package/dist/web/index.js.map +1 -0
- package/package.json +19 -43
- package/LICENSE +0 -21
- package/dist/cli/args.d.ts +0 -8
- package/dist/cli/args.js +0 -63
- package/dist/cli/commands/build.d.ts +0 -5
- package/dist/cli/commands/build.js +0 -19
- package/dist/cli/commands/create.d.ts +0 -2
- package/dist/cli/commands/create.js +0 -39
- package/dist/cli/commands/dev.d.ts +0 -10
- package/dist/cli/commands/dev.js +0 -13
- package/dist/cli/commands/start.d.ts +0 -9
- package/dist/cli/commands/start.js +0 -13
- package/dist/cli/entry.d.ts +0 -2
- package/dist/cli/entry.js +0 -8
- package/dist/cli/index.d.ts +0 -9
- package/dist/cli/index.js +0 -58
- package/dist/core/document/frontmatter.d.ts +0 -5
- package/dist/core/document/frontmatter.js +0 -41
- package/dist/core/document/markdown.d.ts +0 -5
- package/dist/core/document/markdown.js +0 -81
- package/dist/core/document/page-definition.d.ts +0 -2
- package/dist/core/document/page-definition.js +0 -23
- package/dist/core/model/block.d.ts +0 -26
- package/dist/core/model/block.js +0 -8
- package/dist/core/model/document.d.ts +0 -11
- package/dist/core/model/document.js +0 -2
- package/dist/core/model/fragment.d.ts +0 -4
- package/dist/core/model/fragment.js +0 -2
- package/dist/core/model/index.d.ts +0 -4
- package/dist/core/model/index.js +0 -2
- package/dist/core/model/input.d.ts +0 -10
- package/dist/core/model/input.js +0 -2
- package/dist/core/protocol/mdsn.d.ts +0 -4
- package/dist/core/protocol/mdsn.js +0 -66
- package/dist/core/protocol/statements.d.ts +0 -7
- package/dist/core/protocol/statements.js +0 -115
- package/dist/core/protocol/validation.d.ts +0 -3
- package/dist/core/protocol/validation.js +0 -70
- package/dist/core/utils/html.d.ts +0 -6
- package/dist/core/utils/html.js +0 -28
- package/dist/core/utils/index.d.ts +0 -2
- package/dist/core/utils/index.js +0 -12
- package/dist/core/utils/logger.d.ts +0 -12
- package/dist/core/utils/logger.js +0 -45
- package/dist/framework/create-framework-app.d.ts +0 -13
- package/dist/framework/create-framework-app.js +0 -12
- package/dist/framework/hosted-app.d.ts +0 -34
- package/dist/framework/hosted-app.js +0 -223
- package/dist/framework/index.d.ts +0 -6
- package/dist/framework/index.js +0 -9
- package/dist/framework/site-app.d.ts +0 -13
- package/dist/framework/site-app.js +0 -147
- package/dist/server/action-context.d.ts +0 -11
- package/dist/server/action-context.js +0 -26
- package/dist/server/action-host.d.ts +0 -2
- package/dist/server/action-host.js +0 -10
- package/dist/server/action-inputs.d.ts +0 -3
- package/dist/server/action-inputs.js +0 -178
- package/dist/server/action-runtime.d.ts +0 -8
- package/dist/server/action-runtime.js +0 -62
- package/dist/server/action.d.ts +0 -33
- package/dist/server/action.js +0 -101
- package/dist/server/build.d.ts +0 -10
- package/dist/server/build.js +0 -170
- package/dist/server/config.d.ts +0 -56
- package/dist/server/config.js +0 -42
- package/dist/server/dev.d.ts +0 -48
- package/dist/server/dev.js +0 -90
- package/dist/server/error-fragments.d.ts +0 -46
- package/dist/server/error-fragments.js +0 -77
- package/dist/server/init.d.ts +0 -1
- package/dist/server/init.js +0 -176
- package/dist/server/layout.d.ts +0 -17
- package/dist/server/layout.js +0 -40
- package/dist/server/markdown.d.ts +0 -49
- package/dist/server/markdown.js +0 -77
- package/dist/server/module-loader.d.ts +0 -4
- package/dist/server/module-loader.js +0 -71
- package/dist/server/negotiate.d.ts +0 -3
- package/dist/server/negotiate.js +0 -61
- package/dist/server/page-host.d.ts +0 -21
- package/dist/server/page-host.js +0 -66
- package/dist/server/page-links.d.ts +0 -10
- package/dist/server/page-links.js +0 -80
- package/dist/server/route-matcher.d.ts +0 -6
- package/dist/server/route-matcher.js +0 -73
- package/dist/server/routes.d.ts +0 -6
- package/dist/server/routes.js +0 -73
- package/dist/server/server.d.ts +0 -28
- package/dist/server/server.js +0 -161
- package/dist/server/site.d.ts +0 -11
- package/dist/server/site.js +0 -59
- package/dist/server/targets.d.ts +0 -7
- package/dist/server/targets.js +0 -21
- package/dist/web/block-runtime.d.ts +0 -2
- package/dist/web/block-runtime.js +0 -25
- package/dist/web/fragment-render.d.ts +0 -8
- package/dist/web/fragment-render.js +0 -58
- package/dist/web/i18n.d.ts +0 -29
- package/dist/web/i18n.js +0 -65
- package/dist/web/navigation.d.ts +0 -3
- package/dist/web/navigation.js +0 -32
- package/dist/web/page-bootstrap.d.ts +0 -6
- package/dist/web/page-bootstrap.js +0 -28
- package/dist/web/page-client-runtime.d.ts +0 -4
- package/dist/web/page-client-runtime.js +0 -7
- package/dist/web/page-client-script.d.ts +0 -1
- package/dist/web/page-client-script.js +0 -579
- package/dist/web/page-html.d.ts +0 -8
- package/dist/web/page-html.js +0 -42
- package/dist/web/page-render.d.ts +0 -20
- package/dist/web/page-render.js +0 -84
- package/dist/web/public-client-runtime.d.ts +0 -1
- package/dist/web/public-client-runtime.js +0 -5
- package/dist/web/public-render.d.ts +0 -12
- package/dist/web/public-render.js +0 -18
- package/dist/web/target-path.d.ts +0 -1
- package/dist/web/target-path.js +0 -35
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.createHostedApp = createHostedApp;
|
|
7
|
-
const express_1 = __importDefault(require("express"));
|
|
8
|
-
const page_definition_1 = require("../core/document/page-definition");
|
|
9
|
-
const block_1 = require("../core/model/block");
|
|
10
|
-
const action_host_1 = require("../server/action-host");
|
|
11
|
-
const action_inputs_1 = require("../server/action-inputs");
|
|
12
|
-
const error_fragments_1 = require("../server/error-fragments");
|
|
13
|
-
const page_links_1 = require("../server/page-links");
|
|
14
|
-
const page_host_1 = require("../server/page-host");
|
|
15
|
-
const negotiate_1 = require("../server/negotiate");
|
|
16
|
-
const route_matcher_1 = require("../server/route-matcher");
|
|
17
|
-
const fragment_render_1 = require("../web/fragment-render");
|
|
18
|
-
const page_client_script_1 = require("../web/page-client-script");
|
|
19
|
-
function normalizeActionId(target) {
|
|
20
|
-
const trimmed = String(target).trim();
|
|
21
|
-
if (!trimmed || /^https?:\/\//i.test(trimmed)) {
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
if (trimmed.toLowerCase().endsWith(".md")) {
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
27
|
-
return trimmed.replace(/^\/+/u, "");
|
|
28
|
-
}
|
|
29
|
-
function createActionBindingKey(method, path) {
|
|
30
|
-
return `${method}:${path}`;
|
|
31
|
-
}
|
|
32
|
-
function buildActionBindings(pages) {
|
|
33
|
-
const bindings = new Map();
|
|
34
|
-
for (const pageSource of Object.values(pages)) {
|
|
35
|
-
let document;
|
|
36
|
-
try {
|
|
37
|
-
document = (0, page_definition_1.parsePageDefinition)(pageSource);
|
|
38
|
-
}
|
|
39
|
-
catch {
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
for (const block of document.blocks) {
|
|
43
|
-
for (const operation of block.reads) {
|
|
44
|
-
if (!operation.name || (0, block_1.isStreamAccept)(operation.accept)) {
|
|
45
|
-
continue;
|
|
46
|
-
}
|
|
47
|
-
const targetPath = (0, page_links_1.mapPageTargetToHttpPath)(operation.target);
|
|
48
|
-
const actionId = normalizeActionId(operation.target);
|
|
49
|
-
if (!actionId) {
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
const key = createActionBindingKey("GET", targetPath);
|
|
53
|
-
const existing = bindings.get(key);
|
|
54
|
-
if (existing
|
|
55
|
-
&& (existing.actionId !== actionId || existing.blockName !== block.name || existing.kind !== "read")) {
|
|
56
|
-
throw new Error(`Action target must bind to one stable block context: GET ${targetPath}`);
|
|
57
|
-
}
|
|
58
|
-
bindings.set(key, {
|
|
59
|
-
actionId,
|
|
60
|
-
blockName: block.name,
|
|
61
|
-
block,
|
|
62
|
-
kind: "read",
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
for (const operation of block.writes) {
|
|
66
|
-
const targetPath = (0, page_links_1.mapPageTargetToHttpPath)(operation.target);
|
|
67
|
-
const actionId = normalizeActionId(operation.target);
|
|
68
|
-
if (!actionId) {
|
|
69
|
-
continue;
|
|
70
|
-
}
|
|
71
|
-
const key = createActionBindingKey("POST", targetPath);
|
|
72
|
-
const existing = bindings.get(key);
|
|
73
|
-
if (existing
|
|
74
|
-
&& (existing.actionId !== actionId || existing.blockName !== block.name || existing.kind !== "write")) {
|
|
75
|
-
throw new Error(`Action target must bind to one stable block context: POST ${targetPath}`);
|
|
76
|
-
}
|
|
77
|
-
bindings.set(key, {
|
|
78
|
-
actionId,
|
|
79
|
-
blockName: block.name,
|
|
80
|
-
block,
|
|
81
|
-
kind: "write",
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
return bindings;
|
|
87
|
-
}
|
|
88
|
-
function blockToSerializableBlock(block) {
|
|
89
|
-
return {
|
|
90
|
-
name: block.name,
|
|
91
|
-
inputs: block.inputs.map((input) => ({
|
|
92
|
-
name: input.name,
|
|
93
|
-
type: input.type,
|
|
94
|
-
required: input.required,
|
|
95
|
-
secret: input.secret,
|
|
96
|
-
options: input.options,
|
|
97
|
-
})),
|
|
98
|
-
reads: block.reads.map((read) => ({
|
|
99
|
-
name: read.name,
|
|
100
|
-
target: read.target,
|
|
101
|
-
inputs: read.inputs,
|
|
102
|
-
accept: read.accept,
|
|
103
|
-
})),
|
|
104
|
-
writes: block.writes.map((write) => ({
|
|
105
|
-
name: write.name,
|
|
106
|
-
target: write.target,
|
|
107
|
-
inputs: write.inputs,
|
|
108
|
-
})),
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
function sendActionFragment(reqAccept, status, markdown, binding, res, options) {
|
|
112
|
-
if ((0, negotiate_1.wantsMarkdown)(reqAccept) && !(0, negotiate_1.wantsHtml)(reqAccept)) {
|
|
113
|
-
res.status(status).type("text/markdown; charset=utf-8").send(markdown);
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
res.status(status).type("text/html; charset=utf-8").send((0, fragment_render_1.renderBlockFragmentHtml)(markdown, binding.blockName, {
|
|
117
|
-
mapActionTarget: options.render?.mapActionTarget ?? page_links_1.mapPageTargetToHttpPath,
|
|
118
|
-
markdown: options.render?.markdown,
|
|
119
|
-
}));
|
|
120
|
-
}
|
|
121
|
-
function createHostedApp(options) {
|
|
122
|
-
const app = (0, express_1.default)();
|
|
123
|
-
const actionBindings = buildActionBindings(options.pages);
|
|
124
|
-
const errorFragments = {
|
|
125
|
-
actionNotAvailable: (ctx) => (0, error_fragments_1.renderActionNotAvailableFragment)({ block: ctx.block }),
|
|
126
|
-
unsupportedContentType: (ctx) => (0, error_fragments_1.renderUnsupportedContentTypeFragment)({ block: ctx.block }),
|
|
127
|
-
internalError: (ctx) => (0, error_fragments_1.renderInternalErrorFragment)({ block: ctx.block, error: ctx.error }),
|
|
128
|
-
...options.errorFragments,
|
|
129
|
-
};
|
|
130
|
-
const routedPages = (0, route_matcher_1.sortRoutedPagesForMatching)(Object.entries(options.pages).map(([routePath, source]) => ({
|
|
131
|
-
routePath,
|
|
132
|
-
source,
|
|
133
|
-
})));
|
|
134
|
-
app.use(express_1.default.text({
|
|
135
|
-
type: ["text/markdown"],
|
|
136
|
-
limit: "1mb",
|
|
137
|
-
}));
|
|
138
|
-
if (typeof options.publicDir === "string") {
|
|
139
|
-
app.use(express_1.default.static(options.publicDir));
|
|
140
|
-
}
|
|
141
|
-
app.get("/__mdsn/client.js", (_req, res) => {
|
|
142
|
-
res.type("application/javascript; charset=utf-8").send((0, page_client_script_1.getPageClientRuntimeScript)());
|
|
143
|
-
});
|
|
144
|
-
async function handleActionRequest(req, res, method, next) {
|
|
145
|
-
const binding = actionBindings.get(createActionBindingKey(method, req.path));
|
|
146
|
-
if (!binding) {
|
|
147
|
-
next();
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
const action = options.actions?.[binding.actionId];
|
|
151
|
-
if (!action) {
|
|
152
|
-
const block = blockToSerializableBlock(binding.block);
|
|
153
|
-
sendActionFragment(req.headers.accept, 404, errorFragments.actionNotAvailable({
|
|
154
|
-
actionId: binding.actionId,
|
|
155
|
-
block,
|
|
156
|
-
method,
|
|
157
|
-
path: req.path,
|
|
158
|
-
}), binding, res, options);
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
try {
|
|
162
|
-
if (method === "POST") {
|
|
163
|
-
const contentType = req.headers["content-type"] ?? "";
|
|
164
|
-
const normalized = String(contentType).toLowerCase();
|
|
165
|
-
if (!normalized.includes("text/markdown")) {
|
|
166
|
-
const block = blockToSerializableBlock(binding.block);
|
|
167
|
-
sendActionFragment(req.headers.accept, 415, errorFragments.unsupportedContentType({
|
|
168
|
-
actionId: binding.actionId,
|
|
169
|
-
block,
|
|
170
|
-
method,
|
|
171
|
-
path: req.path,
|
|
172
|
-
contentType: String(contentType),
|
|
173
|
-
}), binding, res, options);
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
const result = await (0, action_host_1.executeActionHandler)(action, {
|
|
178
|
-
inputs: method === "GET"
|
|
179
|
-
? (0, action_inputs_1.parseActionInputs)(req.query)
|
|
180
|
-
: (0, action_inputs_1.parseActionInputs)(typeof req.body === "string" ? req.body : ""),
|
|
181
|
-
});
|
|
182
|
-
sendActionFragment(req.headers.accept, 200, result, binding, res, options);
|
|
183
|
-
}
|
|
184
|
-
catch (error) {
|
|
185
|
-
sendActionFragment(req.headers.accept, 500, errorFragments.internalError({
|
|
186
|
-
actionId: binding.actionId,
|
|
187
|
-
block: blockToSerializableBlock(binding.block),
|
|
188
|
-
method,
|
|
189
|
-
path: req.path,
|
|
190
|
-
error,
|
|
191
|
-
}), binding, res, options);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
app.post("*", async (req, res, next) => {
|
|
195
|
-
await handleActionRequest(req, res, "POST", next);
|
|
196
|
-
});
|
|
197
|
-
app.get("*", async (req, res) => {
|
|
198
|
-
const actionBinding = actionBindings.get(createActionBindingKey("GET", req.path));
|
|
199
|
-
if (actionBinding) {
|
|
200
|
-
await handleActionRequest(req, res, "GET", () => undefined);
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
const matchedPage = (0, route_matcher_1.resolveRoutedPageForPath)(req.path, routedPages);
|
|
204
|
-
if (!matchedPage) {
|
|
205
|
-
res.status(404).type("text/plain; charset=utf-8").send("Not Found");
|
|
206
|
-
return;
|
|
207
|
-
}
|
|
208
|
-
const rendered = (0, page_host_1.renderHostedPage)(matchedPage.source, {
|
|
209
|
-
accept: req.headers.accept,
|
|
210
|
-
routePath: req.path,
|
|
211
|
-
siteTitle: options.render?.siteTitle,
|
|
212
|
-
siteDescription: options.render?.siteDescription,
|
|
213
|
-
siteBaseUrl: options.render?.siteBaseUrl,
|
|
214
|
-
locales: options.render?.locales,
|
|
215
|
-
defaultLocale: options.render?.defaultLocale,
|
|
216
|
-
markdown: options.render?.markdown,
|
|
217
|
-
mapActionTarget: options.render?.mapActionTarget ?? page_links_1.mapPageTargetToHttpPath,
|
|
218
|
-
layoutTemplate: options.render?.resolveLayoutTemplate?.(req.path, matchedPage.source),
|
|
219
|
-
});
|
|
220
|
-
res.status(rendered.status).type(rendered.contentType).send(rendered.body);
|
|
221
|
-
});
|
|
222
|
-
return app;
|
|
223
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { createHostedApp } from "./hosted-app";
|
|
2
|
-
export { createFrameworkApp } from "./create-framework-app";
|
|
3
|
-
export type { CreateHostedAppOptions } from "./hosted-app";
|
|
4
|
-
export type { CreateFrameworkAppOptions } from "./create-framework-app";
|
|
5
|
-
export { defineConfig } from "../server/config";
|
|
6
|
-
export type { MdsnConfig } from "../server/config";
|
package/dist/framework/index.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.defineConfig = exports.createFrameworkApp = exports.createHostedApp = void 0;
|
|
4
|
-
var hosted_app_1 = require("./hosted-app");
|
|
5
|
-
Object.defineProperty(exports, "createHostedApp", { enumerable: true, get: function () { return hosted_app_1.createHostedApp; } });
|
|
6
|
-
var create_framework_app_1 = require("./create-framework-app");
|
|
7
|
-
Object.defineProperty(exports, "createFrameworkApp", { enumerable: true, get: function () { return create_framework_app_1.createFrameworkApp; } });
|
|
8
|
-
var config_1 = require("../server/config");
|
|
9
|
-
Object.defineProperty(exports, "defineConfig", { enumerable: true, get: function () { return config_1.defineConfig; } });
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { type CreateHostedAppOptions } from "./hosted-app";
|
|
2
|
-
import type { ActionHandler } from "../server/action-host";
|
|
3
|
-
import { type MdsnConfig } from "../server/config";
|
|
4
|
-
export declare function loadActionHandlers(serverDir: string): Record<string, ActionHandler<{
|
|
5
|
-
inputs: Record<string, unknown>;
|
|
6
|
-
}>>;
|
|
7
|
-
export interface CreateSiteAppOptions {
|
|
8
|
-
rootDir: string;
|
|
9
|
-
config?: MdsnConfig;
|
|
10
|
-
actions?: CreateHostedAppOptions["actions"];
|
|
11
|
-
errorFragments?: CreateHostedAppOptions["errorFragments"];
|
|
12
|
-
}
|
|
13
|
-
export declare function createSiteApp(options: CreateSiteAppOptions): import("express-serve-static-core").Express;
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.loadActionHandlers = loadActionHandlers;
|
|
7
|
-
exports.createSiteApp = createSiteApp;
|
|
8
|
-
const node_fs_1 = require("node:fs");
|
|
9
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
10
|
-
const hosted_app_1 = require("./hosted-app");
|
|
11
|
-
const frontmatter_1 = require("../core/document/frontmatter");
|
|
12
|
-
const config_1 = require("../server/config");
|
|
13
|
-
const module_loader_1 = require("../server/module-loader");
|
|
14
|
-
const site_1 = require("../server/site");
|
|
15
|
-
const routes_1 = require("../server/routes");
|
|
16
|
-
function walkMarkdownFiles(directory) {
|
|
17
|
-
const files = [];
|
|
18
|
-
for (const entry of (0, node_fs_1.readdirSync)(directory, { withFileTypes: true })) {
|
|
19
|
-
const absolutePath = node_path_1.default.join(directory, entry.name);
|
|
20
|
-
if (entry.isDirectory()) {
|
|
21
|
-
files.push(...walkMarkdownFiles(absolutePath));
|
|
22
|
-
continue;
|
|
23
|
-
}
|
|
24
|
-
if (entry.isFile() && absolutePath.endsWith(".md")) {
|
|
25
|
-
files.push(absolutePath);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return files;
|
|
29
|
-
}
|
|
30
|
-
function actionFileToId(filePath, serverDir) {
|
|
31
|
-
return node_path_1.default.relative(serverDir, filePath).split(node_path_1.default.sep).join("/").replace(/\.[^.]+$/u, "");
|
|
32
|
-
}
|
|
33
|
-
function resolveActionLocation(actionId, actionFilesById) {
|
|
34
|
-
const directFile = actionFilesById.get(actionId);
|
|
35
|
-
if (directFile) {
|
|
36
|
-
return { filePath: directFile };
|
|
37
|
-
}
|
|
38
|
-
const segments = actionId.split("/").filter(Boolean);
|
|
39
|
-
const exportName = segments.pop();
|
|
40
|
-
if (!exportName) {
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
const actionsFileId = segments.length > 0 ? `${segments.join("/")}/actions` : "actions";
|
|
44
|
-
const actionsFile = actionFilesById.get(actionsFileId);
|
|
45
|
-
if (!actionsFile) {
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
return {
|
|
49
|
-
filePath: actionsFile,
|
|
50
|
-
exportName,
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
function resolveLayoutTemplate(layoutsDir, rawPage) {
|
|
54
|
-
const { frontmatter } = (0, frontmatter_1.parseFrontmatter)(rawPage);
|
|
55
|
-
const value = frontmatter.layout;
|
|
56
|
-
if (typeof value !== "string") {
|
|
57
|
-
return undefined;
|
|
58
|
-
}
|
|
59
|
-
const normalized = value.trim();
|
|
60
|
-
if (!normalized || normalized.toLowerCase() === "none") {
|
|
61
|
-
return undefined;
|
|
62
|
-
}
|
|
63
|
-
if (!/^[a-zA-Z0-9/_-]+$/u.test(normalized)) {
|
|
64
|
-
return undefined;
|
|
65
|
-
}
|
|
66
|
-
const root = node_path_1.default.resolve(layoutsDir);
|
|
67
|
-
const candidate = node_path_1.default.resolve(root, `${normalized}.html`);
|
|
68
|
-
const relative = node_path_1.default.relative(root, candidate);
|
|
69
|
-
if (relative.startsWith("..") || node_path_1.default.isAbsolute(relative) || !(0, node_fs_1.existsSync)(candidate)) {
|
|
70
|
-
return undefined;
|
|
71
|
-
}
|
|
72
|
-
return (0, node_fs_1.readFileSync)(candidate, "utf8");
|
|
73
|
-
}
|
|
74
|
-
function loadActionHandlers(serverDir) {
|
|
75
|
-
const actionFiles = (0, site_1.findActionFiles)(serverDir);
|
|
76
|
-
const actionFilesById = new Map(actionFiles.map((filePath) => [actionFileToId(filePath, serverDir), filePath]));
|
|
77
|
-
const handlers = new Map();
|
|
78
|
-
return new Proxy({}, {
|
|
79
|
-
get(_target, property) {
|
|
80
|
-
if (typeof property !== "string") {
|
|
81
|
-
return undefined;
|
|
82
|
-
}
|
|
83
|
-
const cached = handlers.get(property);
|
|
84
|
-
if (cached) {
|
|
85
|
-
return cached;
|
|
86
|
-
}
|
|
87
|
-
const resolved = resolveActionLocation(property, actionFilesById);
|
|
88
|
-
if (!resolved) {
|
|
89
|
-
return undefined;
|
|
90
|
-
}
|
|
91
|
-
const handler = async (ctx) => {
|
|
92
|
-
const mod = await (0, module_loader_1.importModuleFromFile)(resolved.filePath);
|
|
93
|
-
const actionModule = (resolved.exportName
|
|
94
|
-
? mod.default?.[resolved.exportName]
|
|
95
|
-
?? mod.actions?.[resolved.exportName]
|
|
96
|
-
?? mod[resolved.exportName]
|
|
97
|
-
: mod.default?.action
|
|
98
|
-
?? mod.default
|
|
99
|
-
?? mod.action
|
|
100
|
-
?? mod);
|
|
101
|
-
if (typeof actionModule?.run !== "function") {
|
|
102
|
-
throw new Error(resolved.exportName
|
|
103
|
-
? `Action module must export ${resolved.exportName} from ${resolved.filePath}`
|
|
104
|
-
: `Action module must export a run() function: ${resolved.filePath}`);
|
|
105
|
-
}
|
|
106
|
-
return actionModule.run(ctx);
|
|
107
|
-
};
|
|
108
|
-
handlers.set(property, handler);
|
|
109
|
-
return handler;
|
|
110
|
-
},
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
function createSiteApp(options) {
|
|
114
|
-
const resolvedConfig = (0, config_1.resolveConfig)(options.config ?? {});
|
|
115
|
-
const pagesDir = node_path_1.default.join(options.rootDir, resolvedConfig.dirs.pages);
|
|
116
|
-
const serverDir = node_path_1.default.join(options.rootDir, resolvedConfig.dirs.server);
|
|
117
|
-
const publicDir = node_path_1.default.join(options.rootDir, resolvedConfig.dirs.public);
|
|
118
|
-
const layoutsDir = node_path_1.default.join(options.rootDir, resolvedConfig.dirs.layouts);
|
|
119
|
-
const pageFiles = walkMarkdownFiles(pagesDir);
|
|
120
|
-
const pages = {};
|
|
121
|
-
const actions = options.actions ?? loadActionHandlers(serverDir);
|
|
122
|
-
for (const filePath of pageFiles) {
|
|
123
|
-
const routePath = (0, routes_1.pagePathToRoutePath)(filePath, pagesDir);
|
|
124
|
-
const pageSource = (0, node_fs_1.readFileSync)(filePath, "utf8");
|
|
125
|
-
pages[routePath] = pageSource;
|
|
126
|
-
const fallbackRoutePath = (0, routes_1.defaultLocaleRouteToFallbackPath)(routePath, resolvedConfig.i18n.defaultLocale);
|
|
127
|
-
if (fallbackRoutePath && !pages[fallbackRoutePath]) {
|
|
128
|
-
pages[fallbackRoutePath] = pageSource;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
const app = (0, hosted_app_1.createHostedApp)({
|
|
132
|
-
pages,
|
|
133
|
-
actions,
|
|
134
|
-
publicDir,
|
|
135
|
-
errorFragments: options.errorFragments,
|
|
136
|
-
render: {
|
|
137
|
-
siteTitle: resolvedConfig.site.title,
|
|
138
|
-
siteDescription: resolvedConfig.site.description,
|
|
139
|
-
siteBaseUrl: resolvedConfig.site.baseUrl,
|
|
140
|
-
locales: resolvedConfig.i18n.locales,
|
|
141
|
-
defaultLocale: resolvedConfig.i18n.defaultLocale,
|
|
142
|
-
markdown: resolvedConfig.markdown,
|
|
143
|
-
resolveLayoutTemplate: (_routePath, rawPage) => resolveLayoutTemplate(layoutsDir, rawPage),
|
|
144
|
-
},
|
|
145
|
-
});
|
|
146
|
-
return app;
|
|
147
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type express from "express";
|
|
2
|
-
import type { ActionContext } from "./action";
|
|
3
|
-
export interface CreateActionContextFromRequestOptions {
|
|
4
|
-
inputs?: Record<string, unknown>;
|
|
5
|
-
pathname?: string;
|
|
6
|
-
cookies?: Record<string, string>;
|
|
7
|
-
env?: Record<string, string | undefined>;
|
|
8
|
-
siteTitle?: string;
|
|
9
|
-
siteBaseUrl?: string;
|
|
10
|
-
}
|
|
11
|
-
export declare function createActionContextFromRequest(req: express.Request, options?: CreateActionContextFromRequestOptions): ActionContext;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createActionContextFromRequest = createActionContextFromRequest;
|
|
4
|
-
function createActionContextFromRequest(req, options = {}) {
|
|
5
|
-
const body = (req.body ?? {});
|
|
6
|
-
return {
|
|
7
|
-
inputs: options.inputs ?? body.inputs ?? {},
|
|
8
|
-
params: Object.fromEntries(Object.entries(req.params).map(([key, value]) => [key, String(value)])),
|
|
9
|
-
query: new URLSearchParams(Object.entries(req.query).flatMap(([key, value]) => {
|
|
10
|
-
if (value === undefined)
|
|
11
|
-
return [];
|
|
12
|
-
if (Array.isArray(value)) {
|
|
13
|
-
return value.map((item) => [key, String(item)]);
|
|
14
|
-
}
|
|
15
|
-
return [[key, String(value)]];
|
|
16
|
-
})),
|
|
17
|
-
pathname: options.pathname ?? (typeof body.pathname === "string" ? body.pathname : req.path),
|
|
18
|
-
request: req,
|
|
19
|
-
cookies: options.cookies ?? {},
|
|
20
|
-
env: options.env ?? process.env,
|
|
21
|
-
site: {
|
|
22
|
-
title: options.siteTitle,
|
|
23
|
-
baseUrl: options.siteBaseUrl,
|
|
24
|
-
},
|
|
25
|
-
};
|
|
26
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.executeActionHandler = executeActionHandler;
|
|
4
|
-
async function executeActionHandler(handler, ctx) {
|
|
5
|
-
const result = await handler(ctx);
|
|
6
|
-
if (typeof result !== "string") {
|
|
7
|
-
throw new Error("Invalid action result: expected markdown string");
|
|
8
|
-
}
|
|
9
|
-
return result;
|
|
10
|
-
}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export declare function serializeActionInputsAsMarkdown(inputs: Record<string, unknown>): string;
|
|
2
|
-
export declare function parseActionInputs(payload: unknown): Record<string, unknown>;
|
|
3
|
-
export declare function normalizeActionInputPayloadToMarkdown(payload: unknown): string;
|
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.serializeActionInputsAsMarkdown = serializeActionInputsAsMarkdown;
|
|
4
|
-
exports.parseActionInputs = parseActionInputs;
|
|
5
|
-
exports.normalizeActionInputPayloadToMarkdown = normalizeActionInputPayloadToMarkdown;
|
|
6
|
-
const core_1 = require("../core");
|
|
7
|
-
function isPlainObject(value) {
|
|
8
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9
|
-
}
|
|
10
|
-
function parseScalarToken(raw) {
|
|
11
|
-
const trimmed = raw.trim();
|
|
12
|
-
if (!trimmed) {
|
|
13
|
-
return "";
|
|
14
|
-
}
|
|
15
|
-
(0, core_1.validateInputLength)(trimmed, core_1.MAX_INPUT_LENGTH);
|
|
16
|
-
if (trimmed.startsWith("{")
|
|
17
|
-
|| trimmed.startsWith("[")
|
|
18
|
-
|| trimmed.startsWith("\"")
|
|
19
|
-
|| trimmed === "true"
|
|
20
|
-
|| trimmed === "false"
|
|
21
|
-
|| trimmed === "null"
|
|
22
|
-
|| /^-?\d+(\.\d+)?([eE][+-]?\d+)?$/u.test(trimmed)) {
|
|
23
|
-
try {
|
|
24
|
-
return JSON.parse(trimmed);
|
|
25
|
-
}
|
|
26
|
-
catch {
|
|
27
|
-
// Fall through to plain string.
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
if ((trimmed.startsWith("'") && trimmed.endsWith("'"))
|
|
31
|
-
|| (trimmed.startsWith("\"") && trimmed.endsWith("\""))) {
|
|
32
|
-
return trimmed.slice(1, -1);
|
|
33
|
-
}
|
|
34
|
-
return trimmed;
|
|
35
|
-
}
|
|
36
|
-
function parseMarkdownInputs(source) {
|
|
37
|
-
(0, core_1.validateInputLength)(source, core_1.MAX_INPUT_LENGTH * 10);
|
|
38
|
-
const inputs = {};
|
|
39
|
-
const segments = splitInputPairs(source);
|
|
40
|
-
for (const segment of segments) {
|
|
41
|
-
const separator = segment.indexOf(":");
|
|
42
|
-
if (separator <= 0) {
|
|
43
|
-
continue;
|
|
44
|
-
}
|
|
45
|
-
const name = segment.slice(0, separator).trim();
|
|
46
|
-
if (!/^[a-zA-Z_][\w-]*$/u.test(name)) {
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
if (name.length > core_1.MAX_IDENTIFIER_LENGTH) {
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
const value = segment.slice(separator + 1);
|
|
53
|
-
inputs[name] = parseScalarToken(value);
|
|
54
|
-
}
|
|
55
|
-
return inputs;
|
|
56
|
-
}
|
|
57
|
-
function splitInputPairs(source) {
|
|
58
|
-
const pairs = [];
|
|
59
|
-
let current = "";
|
|
60
|
-
let depthObject = 0;
|
|
61
|
-
let depthArray = 0;
|
|
62
|
-
let inSingleQuote = false;
|
|
63
|
-
let inDoubleQuote = false;
|
|
64
|
-
let escaped = false;
|
|
65
|
-
const flushCurrent = () => {
|
|
66
|
-
const trimmed = current.trim();
|
|
67
|
-
if (trimmed) {
|
|
68
|
-
pairs.push(trimmed);
|
|
69
|
-
}
|
|
70
|
-
current = "";
|
|
71
|
-
};
|
|
72
|
-
for (const char of source) {
|
|
73
|
-
if (escaped) {
|
|
74
|
-
current += char;
|
|
75
|
-
escaped = false;
|
|
76
|
-
continue;
|
|
77
|
-
}
|
|
78
|
-
if (inSingleQuote) {
|
|
79
|
-
current += char;
|
|
80
|
-
if (char === "\\") {
|
|
81
|
-
escaped = true;
|
|
82
|
-
}
|
|
83
|
-
else if (char === "'") {
|
|
84
|
-
inSingleQuote = false;
|
|
85
|
-
}
|
|
86
|
-
continue;
|
|
87
|
-
}
|
|
88
|
-
if (inDoubleQuote) {
|
|
89
|
-
current += char;
|
|
90
|
-
if (char === "\\") {
|
|
91
|
-
escaped = true;
|
|
92
|
-
}
|
|
93
|
-
else if (char === "\"") {
|
|
94
|
-
inDoubleQuote = false;
|
|
95
|
-
}
|
|
96
|
-
continue;
|
|
97
|
-
}
|
|
98
|
-
if (char === "'") {
|
|
99
|
-
inSingleQuote = true;
|
|
100
|
-
current += char;
|
|
101
|
-
continue;
|
|
102
|
-
}
|
|
103
|
-
if (char === "\"") {
|
|
104
|
-
inDoubleQuote = true;
|
|
105
|
-
current += char;
|
|
106
|
-
continue;
|
|
107
|
-
}
|
|
108
|
-
if (char === "{") {
|
|
109
|
-
depthObject += 1;
|
|
110
|
-
current += char;
|
|
111
|
-
continue;
|
|
112
|
-
}
|
|
113
|
-
if (char === "}") {
|
|
114
|
-
depthObject = Math.max(0, depthObject - 1);
|
|
115
|
-
current += char;
|
|
116
|
-
continue;
|
|
117
|
-
}
|
|
118
|
-
if (char === "[") {
|
|
119
|
-
depthArray += 1;
|
|
120
|
-
current += char;
|
|
121
|
-
continue;
|
|
122
|
-
}
|
|
123
|
-
if (char === "]") {
|
|
124
|
-
depthArray = Math.max(0, depthArray - 1);
|
|
125
|
-
current += char;
|
|
126
|
-
continue;
|
|
127
|
-
}
|
|
128
|
-
const isTopLevel = depthObject === 0 && depthArray === 0;
|
|
129
|
-
if (isTopLevel && (char === "," || char === "," || char === "\n" || char === "\r")) {
|
|
130
|
-
flushCurrent();
|
|
131
|
-
continue;
|
|
132
|
-
}
|
|
133
|
-
current += char;
|
|
134
|
-
}
|
|
135
|
-
flushCurrent();
|
|
136
|
-
return pairs;
|
|
137
|
-
}
|
|
138
|
-
function normalizeObjectInputs(payload) {
|
|
139
|
-
const inputs = {};
|
|
140
|
-
for (const [name, value] of Object.entries(payload)) {
|
|
141
|
-
if (!/^[a-zA-Z_][\w-]*$/u.test(name)) {
|
|
142
|
-
continue;
|
|
143
|
-
}
|
|
144
|
-
if (Array.isArray(value)) {
|
|
145
|
-
if (value.length > 0) {
|
|
146
|
-
inputs[name] = value[0];
|
|
147
|
-
}
|
|
148
|
-
continue;
|
|
149
|
-
}
|
|
150
|
-
if (typeof value === "string") {
|
|
151
|
-
inputs[name] = parseScalarToken(value);
|
|
152
|
-
continue;
|
|
153
|
-
}
|
|
154
|
-
if (typeof value === "number" || typeof value === "boolean") {
|
|
155
|
-
inputs[name] = value;
|
|
156
|
-
continue;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
return inputs;
|
|
160
|
-
}
|
|
161
|
-
function serializeActionInputsAsMarkdown(inputs) {
|
|
162
|
-
return Object.entries(inputs)
|
|
163
|
-
.filter(([, value]) => value !== undefined)
|
|
164
|
-
.map(([name, value]) => `${name}: ${JSON.stringify(value)}`)
|
|
165
|
-
.join(", ");
|
|
166
|
-
}
|
|
167
|
-
function parseActionInputs(payload) {
|
|
168
|
-
if (typeof payload === "string") {
|
|
169
|
-
return parseMarkdownInputs(payload);
|
|
170
|
-
}
|
|
171
|
-
if (isPlainObject(payload)) {
|
|
172
|
-
return normalizeObjectInputs(payload);
|
|
173
|
-
}
|
|
174
|
-
return {};
|
|
175
|
-
}
|
|
176
|
-
function normalizeActionInputPayloadToMarkdown(payload) {
|
|
177
|
-
return serializeActionInputsAsMarkdown(parseActionInputs(payload));
|
|
178
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { type ActionRegistry } from "./action";
|
|
2
|
-
import { createActionContextFromRequest } from "./action-context";
|
|
3
|
-
export declare function summarizeActionInputs(inputs: Record<string, unknown>): string;
|
|
4
|
-
export declare function createActionFilesSignature(actionFiles: string[], actionsDir: string): string;
|
|
5
|
-
export declare function loadActionRegistry(actionFiles: string[], actionsDir: string, options?: {
|
|
6
|
-
fresh?: boolean;
|
|
7
|
-
}): Promise<ActionRegistry>;
|
|
8
|
-
export declare function createActionContext(req: Parameters<typeof createActionContextFromRequest>[0], siteTitle?: string, siteBaseUrl?: string): import("./action").ActionContext;
|