@mdsnai/sdk 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -75
- 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,26 +0,0 @@
|
|
|
1
|
-
import type { InputDefinition } from "./input";
|
|
2
|
-
export declare const STREAM_ACCEPT = "text/event-stream";
|
|
3
|
-
export declare function isStreamAccept(accept?: string): boolean;
|
|
4
|
-
export interface ReadDefinition {
|
|
5
|
-
id: string;
|
|
6
|
-
block: string;
|
|
7
|
-
name?: string;
|
|
8
|
-
target: string;
|
|
9
|
-
inputs: string[];
|
|
10
|
-
accept?: string;
|
|
11
|
-
order: number;
|
|
12
|
-
}
|
|
13
|
-
export interface WriteDefinition {
|
|
14
|
-
id: string;
|
|
15
|
-
block: string;
|
|
16
|
-
name: string;
|
|
17
|
-
target: string;
|
|
18
|
-
inputs: string[];
|
|
19
|
-
order: number;
|
|
20
|
-
}
|
|
21
|
-
export interface BlockDefinition {
|
|
22
|
-
name: string;
|
|
23
|
-
inputs: InputDefinition[];
|
|
24
|
-
reads: ReadDefinition[];
|
|
25
|
-
writes: WriteDefinition[];
|
|
26
|
-
}
|
package/dist/core/model/block.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.STREAM_ACCEPT = void 0;
|
|
4
|
-
exports.isStreamAccept = isStreamAccept;
|
|
5
|
-
exports.STREAM_ACCEPT = "text/event-stream";
|
|
6
|
-
function isStreamAccept(accept) {
|
|
7
|
-
return String(accept ?? "").toLowerCase() === exports.STREAM_ACCEPT;
|
|
8
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { BlockDefinition } from "./block";
|
|
2
|
-
export type FrontmatterData = Record<string, unknown>;
|
|
3
|
-
export interface BlockAnchorDefinition {
|
|
4
|
-
name: string;
|
|
5
|
-
}
|
|
6
|
-
export interface DocumentDefinition {
|
|
7
|
-
frontmatter: FrontmatterData;
|
|
8
|
-
markdown: string;
|
|
9
|
-
blocks: BlockDefinition[];
|
|
10
|
-
blockAnchors: BlockAnchorDefinition[];
|
|
11
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export type { BlockAnchorDefinition, DocumentDefinition, FrontmatterData, } from "./document";
|
|
2
|
-
export type { BlockDefinition, ReadDefinition, WriteDefinition, } from "./block";
|
|
3
|
-
export type { InputDefinition, InputType, } from "./input";
|
|
4
|
-
export type { MarkdownFragmentDefinition } from "./fragment";
|
package/dist/core/model/index.js
DELETED
package/dist/core/model/input.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseMdsnBlocks = parseMdsnBlocks;
|
|
4
|
-
const statements_1 = require("./statements");
|
|
5
|
-
function createBlock(name) {
|
|
6
|
-
return {
|
|
7
|
-
name,
|
|
8
|
-
inputs: [],
|
|
9
|
-
reads: [],
|
|
10
|
-
writes: [],
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
function parseMdsnBlocks(blocks) {
|
|
14
|
-
const documentBlocks = [];
|
|
15
|
-
let currentBlock = null;
|
|
16
|
-
for (const blockText of blocks) {
|
|
17
|
-
const lines = blockText.split(/\r?\n/);
|
|
18
|
-
let index = 0;
|
|
19
|
-
while (index < lines.length) {
|
|
20
|
-
const line = lines[index].trim();
|
|
21
|
-
if (!line) {
|
|
22
|
-
index += 1;
|
|
23
|
-
continue;
|
|
24
|
-
}
|
|
25
|
-
if (!currentBlock) {
|
|
26
|
-
if (line.startsWith("BLOCK ")) {
|
|
27
|
-
currentBlock = createBlock((0, statements_1.parseBlockHeaderLine)(line));
|
|
28
|
-
documentBlocks.push(currentBlock);
|
|
29
|
-
index += 1;
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
if (line === "}") {
|
|
33
|
-
throw new Error(`Unexpected block terminator: ${line}`);
|
|
34
|
-
}
|
|
35
|
-
throw new Error(`Unsupported MDSN statement: ${line}`);
|
|
36
|
-
}
|
|
37
|
-
if (line === "}") {
|
|
38
|
-
currentBlock = null;
|
|
39
|
-
index += 1;
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
if (line.startsWith("INPUT ")) {
|
|
43
|
-
currentBlock.inputs.push((0, statements_1.parseInputLine)(line, currentBlock.name));
|
|
44
|
-
index += 1;
|
|
45
|
-
continue;
|
|
46
|
-
}
|
|
47
|
-
if (line.startsWith("GET ")) {
|
|
48
|
-
currentBlock.reads.push((0, statements_1.parseReadOrWriteLine)(line, "read", currentBlock.name, (0, statements_1.getNextOperationOrder)(currentBlock)));
|
|
49
|
-
index += 1;
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
if (line.startsWith("POST ")) {
|
|
53
|
-
currentBlock.writes.push((0, statements_1.parseReadOrWriteLine)(line, "write", currentBlock.name, (0, statements_1.getNextOperationOrder)(currentBlock)));
|
|
54
|
-
index += 1;
|
|
55
|
-
continue;
|
|
56
|
-
}
|
|
57
|
-
throw new Error(`Unsupported MDSN statement: ${line}`);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
if (currentBlock) {
|
|
61
|
-
throw new Error(`Unterminated block declaration: ${currentBlock.name}`);
|
|
62
|
-
}
|
|
63
|
-
return {
|
|
64
|
-
blocks: documentBlocks,
|
|
65
|
-
};
|
|
66
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { type BlockDefinition, type ReadDefinition, type WriteDefinition } from "../model/block";
|
|
2
|
-
import type { InputDefinition } from "../model/input";
|
|
3
|
-
export declare function parseBlockHeaderLine(line: string): string;
|
|
4
|
-
export declare function parseInputLine(line: string, blockName: string): InputDefinition;
|
|
5
|
-
export declare function parseReadOrWriteLine(line: string, kind: "read", blockName: string, index: number): ReadDefinition;
|
|
6
|
-
export declare function parseReadOrWriteLine(line: string, kind: "write", blockName: string, index: number): WriteDefinition;
|
|
7
|
-
export declare function getNextOperationOrder(block: BlockDefinition): number;
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseBlockHeaderLine = parseBlockHeaderLine;
|
|
4
|
-
exports.parseInputLine = parseInputLine;
|
|
5
|
-
exports.parseReadOrWriteLine = parseReadOrWriteLine;
|
|
6
|
-
exports.getNextOperationOrder = getNextOperationOrder;
|
|
7
|
-
const block_1 = require("../model/block");
|
|
8
|
-
function isIdentifier(value) {
|
|
9
|
-
return /^[a-zA-Z_][\w-]*$/.test(value);
|
|
10
|
-
}
|
|
11
|
-
function parseIdentifierList(raw) {
|
|
12
|
-
const trimmed = raw.trim();
|
|
13
|
-
if (!trimmed)
|
|
14
|
-
return [];
|
|
15
|
-
const items = trimmed.split(",").map((part) => part.trim()).filter(Boolean);
|
|
16
|
-
for (const item of items) {
|
|
17
|
-
if (!isIdentifier(item)) {
|
|
18
|
-
throw new Error(`Invalid identifier in argument list: ${item}`);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return items;
|
|
22
|
-
}
|
|
23
|
-
function parseStringArrayLiteral(raw) {
|
|
24
|
-
const parsed = JSON.parse(raw);
|
|
25
|
-
if (!Array.isArray(parsed) || !parsed.every((item) => typeof item === "string")) {
|
|
26
|
-
throw new Error(`Invalid array literal: ${raw}`);
|
|
27
|
-
}
|
|
28
|
-
return parsed;
|
|
29
|
-
}
|
|
30
|
-
function parseBlockHeaderLine(line) {
|
|
31
|
-
const match = line.trim().match(/^BLOCK\s+([a-zA-Z_][\w-]*)\s*\{$/);
|
|
32
|
-
if (!match) {
|
|
33
|
-
throw new Error(`Invalid block declaration: ${line}`);
|
|
34
|
-
}
|
|
35
|
-
return match[1];
|
|
36
|
-
}
|
|
37
|
-
function parseInputLine(line, blockName) {
|
|
38
|
-
const match = line.trim().match(/^INPUT\s+(text|number|boolean|choice|asset)(?:\s+(.*?))?\s*->\s*([a-zA-Z_][\w-]*)$/);
|
|
39
|
-
if (!match) {
|
|
40
|
-
throw new Error(`Invalid input declaration: ${line}`);
|
|
41
|
-
}
|
|
42
|
-
const [, type, trailing, name] = match;
|
|
43
|
-
const tail = (trailing ?? "").trim();
|
|
44
|
-
const required = /\brequired\b/u.test(tail);
|
|
45
|
-
const secret = /\bsecret\b/u.test(tail);
|
|
46
|
-
const optionsMatch = tail.match(/(\[.*\])/u);
|
|
47
|
-
const optionsLiteral = optionsMatch?.[1];
|
|
48
|
-
const normalizedTail = tail
|
|
49
|
-
.replace(/\brequired\b/gu, "")
|
|
50
|
-
.replace(/\bsecret\b/gu, "")
|
|
51
|
-
.replace(/(\[.*\])/u, "")
|
|
52
|
-
.trim();
|
|
53
|
-
if (normalizedTail) {
|
|
54
|
-
throw new Error(`Invalid input declaration: ${line}`);
|
|
55
|
-
}
|
|
56
|
-
const input = {
|
|
57
|
-
id: `${blockName}::input::${name}`,
|
|
58
|
-
block: blockName,
|
|
59
|
-
name,
|
|
60
|
-
type: type,
|
|
61
|
-
required,
|
|
62
|
-
secret,
|
|
63
|
-
};
|
|
64
|
-
if (optionsLiteral) {
|
|
65
|
-
input.options = parseStringArrayLiteral(optionsLiteral);
|
|
66
|
-
}
|
|
67
|
-
if (input.type === "choice" && (!input.options || input.options.length === 0)) {
|
|
68
|
-
throw new Error(`Choice input ${name} in block ${blockName} must define options`);
|
|
69
|
-
}
|
|
70
|
-
if (input.type !== "choice" && input.options) {
|
|
71
|
-
throw new Error(`Only choice input ${name} in block ${blockName} can define options`);
|
|
72
|
-
}
|
|
73
|
-
return input;
|
|
74
|
-
}
|
|
75
|
-
function parseReadOrWriteLine(line, kind, blockName, index) {
|
|
76
|
-
if (kind === "read") {
|
|
77
|
-
const match = line.trim().match(/^GET\s+"([^"]+)"(?:\s*\(([^)]*)\))?(?:\s+accept:"([^"]+)")?(?:\s*->\s*([a-zA-Z_][\w-]*))?$/);
|
|
78
|
-
if (!match) {
|
|
79
|
-
throw new Error(`Invalid ${kind} declaration: ${line}`);
|
|
80
|
-
}
|
|
81
|
-
const [, target, rawInputs, accept, name] = match;
|
|
82
|
-
if (!name && !(0, block_1.isStreamAccept)(accept)) {
|
|
83
|
-
throw new Error(`Invalid ${kind} declaration: ${line}`);
|
|
84
|
-
}
|
|
85
|
-
if ((0, block_1.isStreamAccept)(accept) && name) {
|
|
86
|
-
throw new Error(`Invalid ${kind} declaration: ${line}`);
|
|
87
|
-
}
|
|
88
|
-
return {
|
|
89
|
-
id: `${blockName}::${kind}::${index}`,
|
|
90
|
-
block: blockName,
|
|
91
|
-
name,
|
|
92
|
-
target,
|
|
93
|
-
inputs: parseIdentifierList(rawInputs ?? ""),
|
|
94
|
-
accept,
|
|
95
|
-
order: index,
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
const match = line.trim().match(/^POST\s+"([^"]+)"\s*\(([^)]*)\)\s*->\s*([a-zA-Z_][\w-]*)$/);
|
|
99
|
-
if (!match) {
|
|
100
|
-
throw new Error(`Invalid ${kind} declaration: ${line}`);
|
|
101
|
-
}
|
|
102
|
-
const [, target, rawInputs, name] = match;
|
|
103
|
-
const base = {
|
|
104
|
-
id: `${blockName}::${kind}::${index}`,
|
|
105
|
-
block: blockName,
|
|
106
|
-
name,
|
|
107
|
-
target,
|
|
108
|
-
inputs: parseIdentifierList(rawInputs ?? ""),
|
|
109
|
-
order: index,
|
|
110
|
-
};
|
|
111
|
-
return base;
|
|
112
|
-
}
|
|
113
|
-
function getNextOperationOrder(block) {
|
|
114
|
-
return block.reads.length + block.writes.length;
|
|
115
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateDocumentStructure = validateDocumentStructure;
|
|
4
|
-
const block_1 = require("../model/block");
|
|
5
|
-
function validateDocumentStructure(blocks, blockAnchors) {
|
|
6
|
-
const blockNames = new Set();
|
|
7
|
-
for (const block of blocks) {
|
|
8
|
-
if (blockNames.has(block.name)) {
|
|
9
|
-
throw new Error(`Duplicate block name: ${block.name}`);
|
|
10
|
-
}
|
|
11
|
-
blockNames.add(block.name);
|
|
12
|
-
}
|
|
13
|
-
const anchorNames = new Set();
|
|
14
|
-
for (const anchor of blockAnchors) {
|
|
15
|
-
if (anchorNames.has(anchor.name)) {
|
|
16
|
-
throw new Error(`Duplicate block anchor: ${anchor.name}`);
|
|
17
|
-
}
|
|
18
|
-
anchorNames.add(anchor.name);
|
|
19
|
-
if (!blockNames.has(anchor.name)) {
|
|
20
|
-
throw new Error(`Unknown block ${anchor.name} referenced by mdsn:block anchor`);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
if (blockAnchors.length > 0) {
|
|
24
|
-
for (const block of blocks) {
|
|
25
|
-
if (!anchorNames.has(block.name)) {
|
|
26
|
-
throw new Error(`Missing mdsn:block anchor for block ${block.name}`);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
for (const block of blocks) {
|
|
31
|
-
const inputNames = new Set();
|
|
32
|
-
const operationNames = new Set();
|
|
33
|
-
for (const input of block.inputs) {
|
|
34
|
-
if (inputNames.has(input.name)) {
|
|
35
|
-
throw new Error(`Duplicate input name in block ${block.name}: ${input.name}`);
|
|
36
|
-
}
|
|
37
|
-
inputNames.add(input.name);
|
|
38
|
-
}
|
|
39
|
-
for (const operation of block.reads) {
|
|
40
|
-
if (!operation.name && !(0, block_1.isStreamAccept)(operation.accept)) {
|
|
41
|
-
throw new Error(`Read operations must declare a name unless they accept text/event-stream: ${operation.id}`);
|
|
42
|
-
}
|
|
43
|
-
if ((0, block_1.isStreamAccept)(operation.accept) && operation.name) {
|
|
44
|
-
throw new Error(`Stream read operations must not declare a name: ${operation.id}`);
|
|
45
|
-
}
|
|
46
|
-
if (operation.name) {
|
|
47
|
-
if (operationNames.has(operation.name)) {
|
|
48
|
-
throw new Error(`Duplicate operation name in block ${block.name}: ${operation.name}`);
|
|
49
|
-
}
|
|
50
|
-
operationNames.add(operation.name);
|
|
51
|
-
}
|
|
52
|
-
for (const inputName of operation.inputs) {
|
|
53
|
-
if (!inputNames.has(inputName)) {
|
|
54
|
-
throw new Error(`Unknown input ${inputName} referenced by ${operation.id}`);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
for (const operation of block.writes) {
|
|
59
|
-
if (operationNames.has(operation.name)) {
|
|
60
|
-
throw new Error(`Duplicate operation name in block ${block.name}: ${operation.name}`);
|
|
61
|
-
}
|
|
62
|
-
operationNames.add(operation.name);
|
|
63
|
-
for (const inputName of operation.inputs) {
|
|
64
|
-
if (!inputNames.has(inputName)) {
|
|
65
|
-
throw new Error(`Unknown input ${inputName} referenced by ${operation.id}`);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export declare function escapeHtml(value: string): string;
|
|
2
|
-
export declare function escapeRegExp(value: string): string;
|
|
3
|
-
export declare const MAX_INPUT_LENGTH = 10000;
|
|
4
|
-
export declare const MAX_IDENTIFIER_LENGTH = 256;
|
|
5
|
-
export declare function validateInputLength(value: string, maxLength?: number): void;
|
|
6
|
-
export declare function trimTrailingBlankLines(value: string): string;
|
package/dist/core/utils/html.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MAX_IDENTIFIER_LENGTH = exports.MAX_INPUT_LENGTH = void 0;
|
|
4
|
-
exports.escapeHtml = escapeHtml;
|
|
5
|
-
exports.escapeRegExp = escapeRegExp;
|
|
6
|
-
exports.validateInputLength = validateInputLength;
|
|
7
|
-
exports.trimTrailingBlankLines = trimTrailingBlankLines;
|
|
8
|
-
function escapeHtml(value) {
|
|
9
|
-
return value
|
|
10
|
-
.replace(/&/g, "&")
|
|
11
|
-
.replace(/</g, "<")
|
|
12
|
-
.replace(/>/g, ">")
|
|
13
|
-
.replace(/"/g, """)
|
|
14
|
-
.replace(/'/g, "'");
|
|
15
|
-
}
|
|
16
|
-
function escapeRegExp(value) {
|
|
17
|
-
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
18
|
-
}
|
|
19
|
-
exports.MAX_INPUT_LENGTH = 10000;
|
|
20
|
-
exports.MAX_IDENTIFIER_LENGTH = 256;
|
|
21
|
-
function validateInputLength(value, maxLength = exports.MAX_INPUT_LENGTH) {
|
|
22
|
-
if (value.length > maxLength) {
|
|
23
|
-
throw new Error(`Input exceeds maximum length of ${maxLength} characters`);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
function trimTrailingBlankLines(value) {
|
|
27
|
-
return value.replace(/\n+$/u, "\n");
|
|
28
|
-
}
|
package/dist/core/utils/index.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createLogger = exports.MAX_IDENTIFIER_LENGTH = exports.MAX_INPUT_LENGTH = exports.trimTrailingBlankLines = exports.validateInputLength = exports.escapeRegExp = exports.escapeHtml = void 0;
|
|
4
|
-
var html_1 = require("./html");
|
|
5
|
-
Object.defineProperty(exports, "escapeHtml", { enumerable: true, get: function () { return html_1.escapeHtml; } });
|
|
6
|
-
Object.defineProperty(exports, "escapeRegExp", { enumerable: true, get: function () { return html_1.escapeRegExp; } });
|
|
7
|
-
Object.defineProperty(exports, "validateInputLength", { enumerable: true, get: function () { return html_1.validateInputLength; } });
|
|
8
|
-
Object.defineProperty(exports, "trimTrailingBlankLines", { enumerable: true, get: function () { return html_1.trimTrailingBlankLines; } });
|
|
9
|
-
Object.defineProperty(exports, "MAX_INPUT_LENGTH", { enumerable: true, get: function () { return html_1.MAX_INPUT_LENGTH; } });
|
|
10
|
-
Object.defineProperty(exports, "MAX_IDENTIFIER_LENGTH", { enumerable: true, get: function () { return html_1.MAX_IDENTIFIER_LENGTH; } });
|
|
11
|
-
var logger_1 = require("./logger");
|
|
12
|
-
Object.defineProperty(exports, "createLogger", { enumerable: true, get: function () { return logger_1.createLogger; } });
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export type LogLevel = "debug" | "info" | "warn" | "error";
|
|
2
|
-
export interface Logger {
|
|
3
|
-
debug(message: string, context?: Record<string, unknown>): void;
|
|
4
|
-
info(message: string, context?: Record<string, unknown>): void;
|
|
5
|
-
warn(message: string, context?: Record<string, unknown>): void;
|
|
6
|
-
error(message: string, context?: Record<string, unknown>): void;
|
|
7
|
-
}
|
|
8
|
-
export interface CreateLoggerOptions {
|
|
9
|
-
level?: LogLevel;
|
|
10
|
-
prefix?: string;
|
|
11
|
-
}
|
|
12
|
-
export declare function createLogger(options?: CreateLoggerOptions): Logger;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createLogger = createLogger;
|
|
4
|
-
const LOG_LEVELS = {
|
|
5
|
-
debug: 0,
|
|
6
|
-
info: 1,
|
|
7
|
-
warn: 2,
|
|
8
|
-
error: 3,
|
|
9
|
-
};
|
|
10
|
-
function formatTimestamp() {
|
|
11
|
-
return new Date().toISOString();
|
|
12
|
-
}
|
|
13
|
-
function formatMessage(level, prefix, message, context) {
|
|
14
|
-
const timestamp = formatTimestamp();
|
|
15
|
-
const prefixPart = prefix ? `[${prefix}] ` : "";
|
|
16
|
-
const contextPart = context ? ` ${JSON.stringify(context)}` : "";
|
|
17
|
-
return `${timestamp} ${prefixPart}${level.toUpperCase()}: ${message}${contextPart}`;
|
|
18
|
-
}
|
|
19
|
-
function createLogger(options = {}) {
|
|
20
|
-
const level = options.level ?? "info";
|
|
21
|
-
const prefix = options.prefix;
|
|
22
|
-
const levelNumber = LOG_LEVELS[level];
|
|
23
|
-
return {
|
|
24
|
-
debug(message, context) {
|
|
25
|
-
if (levelNumber <= LOG_LEVELS.debug) {
|
|
26
|
-
console.debug(formatMessage("debug", prefix, message, context));
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
info(message, context) {
|
|
30
|
-
if (levelNumber <= LOG_LEVELS.info) {
|
|
31
|
-
console.info(formatMessage("info", prefix, message, context));
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
warn(message, context) {
|
|
35
|
-
if (levelNumber <= LOG_LEVELS.warn) {
|
|
36
|
-
console.warn(formatMessage("warn", prefix, message, context));
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
error(message, context) {
|
|
40
|
-
if (levelNumber <= LOG_LEVELS.error) {
|
|
41
|
-
console.error(formatMessage("error", prefix, message, context));
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { ActionHandler } from "../server/action-host";
|
|
2
|
-
import type { MdsnConfig } from "../server/config";
|
|
3
|
-
export interface CreateFrameworkAppOptions {
|
|
4
|
-
rootDir: string;
|
|
5
|
-
config?: MdsnConfig;
|
|
6
|
-
actions?: Record<string, ActionHandler<{
|
|
7
|
-
inputs: Record<string, unknown>;
|
|
8
|
-
}>>;
|
|
9
|
-
errorFragments?: import("./hosted-app").CreateHostedAppOptions["errorFragments"];
|
|
10
|
-
mode?: "dev" | "start";
|
|
11
|
-
devState?: unknown;
|
|
12
|
-
}
|
|
13
|
-
export declare function createFrameworkApp(options: CreateFrameworkAppOptions): import("express-serve-static-core").Express;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createFrameworkApp = createFrameworkApp;
|
|
4
|
-
const site_app_1 = require("./site-app");
|
|
5
|
-
function createFrameworkApp(options) {
|
|
6
|
-
return (0, site_app_1.createSiteApp)({
|
|
7
|
-
rootDir: options.rootDir,
|
|
8
|
-
config: options.config,
|
|
9
|
-
actions: options.actions,
|
|
10
|
-
errorFragments: options.errorFragments,
|
|
11
|
-
});
|
|
12
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { type ActionHandler } from "../server/action-host";
|
|
2
|
-
import { type SerializableBlock } from "../server/markdown";
|
|
3
|
-
import { type RenderHostedPageOptions } from "../server/page-host";
|
|
4
|
-
export interface CreateHostedAppOptions {
|
|
5
|
-
pages: Record<string, string>;
|
|
6
|
-
actions?: Record<string, ActionHandler<{
|
|
7
|
-
inputs: Record<string, unknown>;
|
|
8
|
-
}>>;
|
|
9
|
-
publicDir?: string;
|
|
10
|
-
errorFragments?: Partial<HostedAppErrorFragments>;
|
|
11
|
-
render?: Omit<RenderHostedPageOptions, "accept" | "routePath" | "layoutTemplate"> & {
|
|
12
|
-
resolveLayoutTemplate?: (routePath: string, rawPage: string) => string | undefined;
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
export interface HostedAppErrorFragmentContext {
|
|
16
|
-
actionId: string;
|
|
17
|
-
block: SerializableBlock;
|
|
18
|
-
method: "GET" | "POST";
|
|
19
|
-
path: string;
|
|
20
|
-
}
|
|
21
|
-
export interface HostedAppActionNotAvailableContext extends HostedAppErrorFragmentContext {
|
|
22
|
-
}
|
|
23
|
-
export interface HostedAppUnsupportedContentTypeContext extends HostedAppErrorFragmentContext {
|
|
24
|
-
contentType: string;
|
|
25
|
-
}
|
|
26
|
-
export interface HostedAppInternalErrorContext extends HostedAppErrorFragmentContext {
|
|
27
|
-
error: unknown;
|
|
28
|
-
}
|
|
29
|
-
export interface HostedAppErrorFragments {
|
|
30
|
-
actionNotAvailable: (ctx: HostedAppActionNotAvailableContext) => string;
|
|
31
|
-
unsupportedContentType: (ctx: HostedAppUnsupportedContentTypeContext) => string;
|
|
32
|
-
internalError: (ctx: HostedAppInternalErrorContext) => string;
|
|
33
|
-
}
|
|
34
|
-
export declare function createHostedApp(options: CreateHostedAppOptions): import("express-serve-static-core").Express;
|