meld-ast
Version:
AST parser for Meld
1,651 lines (1,635 loc) • 280 kB
JavaScript
'use strict';
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
var __commonJS = (cb, mod) => function __require() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
__defProp(target, "default", { value: mod, enumerable: true }) ,
mod
));
// node_modules/meld-spec/dist/esm/types/directives.js
var require_directives = __commonJS({
"node_modules/meld-spec/dist/esm/types/directives.js"(exports) {
Object.defineProperty(exports, "__esModule", { value: true });
}
});
// node_modules/meld-spec/dist/esm/types/syntax.js
var require_syntax = __commonJS({
"node_modules/meld-spec/dist/esm/types/syntax.js"(exports) {
Object.defineProperty(exports, "__esModule", { value: true });
}
});
// node_modules/meld-spec/dist/esm/types/schema.js
var require_schema = __commonJS({
"node_modules/meld-spec/dist/esm/types/schema.js"(exports) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.SCHEMA_FORMATS = void 0;
exports.SCHEMA_FORMATS = {
DATE: "date",
DATE_TIME: "date-time",
EMAIL: "email",
URI: "uri",
UUID: "uuid"
};
}
});
// node_modules/meld-spec/dist/esm/types/api.js
var require_api = __commonJS({
"node_modules/meld-spec/dist/esm/types/api.js"(exports) {
Object.defineProperty(exports, "__esModule", { value: true });
}
});
// node_modules/meld-spec/dist/esm/types/variables.js
var require_variables = __commonJS({
"node_modules/meld-spec/dist/esm/types/variables.js"(exports) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.VAR_PATTERNS = exports.ENV_VAR_PREFIX = exports.SPECIAL_PATH_VARS = void 0;
exports.SPECIAL_PATH_VARS = {
HOME: ["$HOMEPATH", "$~"],
PROJECT: ["$PROJECTPATH", "$."]
};
exports.ENV_VAR_PREFIX = "ENV_";
exports.VAR_PATTERNS = {
TEXT: /\${([^}]+)}/,
DATA: /#{([^}]+)}/,
PATH: /\$([A-Za-z0-9_~]+)/,
FORMAT: />>\(([^)]+)\)/
};
}
});
// node_modules/meld-spec/dist/esm/types/parser.js
var require_parser = __commonJS({
"node_modules/meld-spec/dist/esm/types/parser.js"(exports) {
Object.defineProperty(exports, "__esModule", { value: true });
}
});
// node_modules/meld-spec/dist/esm/types/validation.js
var require_validation = __commonJS({
"node_modules/meld-spec/dist/esm/types/validation.js"(exports) {
Object.defineProperty(exports, "__esModule", { value: true });
}
});
// node_modules/meld-spec/dist/esm/spec/tests/directives/api/api.test.js
var require_api_test = __commonJS({
"node_modules/meld-spec/dist/esm/spec/tests/directives/api/api.test.js"(exports) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.apiTests = void 0;
exports.apiTests = [
// Minimal API configuration
{
name: "minimal-api",
input: '@api github = {{ baseUrl: "https://api.github.com" }}',
expected: {
type: "Directive",
directive: {
kind: "api",
identifier: "github",
config: {
baseUrl: "https://api.github.com"
}
}
},
description: "Minimal API with only baseUrl"
},
// Full API configuration
{
name: "full-api",
input: '@api github = {{\n baseUrl: "https://api.github.com",\n headers: {\n Authorization: "Bearer ${ENV_TOKEN}",\n Accept: "application/json"\n },\n timeout: 5000,\n retries: 3\n }}',
expected: {
type: "Directive",
directive: {
kind: "api",
identifier: "github",
config: {
baseUrl: "https://api.github.com",
headers: {
Authorization: "Bearer ${ENV_TOKEN}",
Accept: "application/json"
},
timeout: 5e3,
retries: 3
}
}
},
description: "Full API configuration with all optional fields"
},
// Basic endpoint definition
{
name: "basic-endpoint",
input: '@api github.issues = {{\n path: "/repos/${owner}/${repo}/issues"\n }}',
expected: {
type: "Directive",
directive: {
kind: "api",
identifier: "github.issues",
endpoint: {
path: "/repos/${owner}/${repo}/issues"
}
}
},
description: "Basic endpoint definition with path"
},
// Endpoint with methods
{
name: "endpoint-with-methods",
input: '@api github.issues = {{\n path: "/repos/${owner}/${repo}/issues",\n methods: ["GET", "POST"]\n }}',
expected: {
type: "Directive",
directive: {
kind: "api",
identifier: "github.issues",
endpoint: {
path: "/repos/${owner}/${repo}/issues",
methods: ["GET", "POST"]
}
}
},
description: "Endpoint with allowed methods"
},
// Endpoint with path parameters
{
name: "endpoint-with-params",
input: '@api github.issue = {{\n path: "/repos/${owner}/${repo}/issues/${number}",\n methods: ["GET", "PATCH", "DELETE"]\n }}',
expected: {
type: "Directive",
directive: {
kind: "api",
identifier: "github.issue",
endpoint: {
path: "/repos/${owner}/${repo}/issues/${number}",
methods: ["GET", "PATCH", "DELETE"]
}
}
},
description: "Endpoint with path parameters"
},
// API with data variables
{
name: "api-with-data",
input: '@api github = {{\n baseUrl: "https://api.github.com",\n headers: "#{headers}",\n timeout: "#{config.timeout}"\n }}',
expected: {
type: "Directive",
directive: {
kind: "api",
identifier: "github",
config: {
baseUrl: "https://api.github.com",
headers: "#{headers}",
timeout: "#{config.timeout}"
}
}
},
description: "API configuration with data variables"
},
// Endpoint with query parameters
{
name: "endpoint-with-query",
input: '@api github.search = {{\n path: "/search/repositories?q=${query}&sort=${sort}",\n methods: ["GET"]\n }}',
expected: {
type: "Directive",
directive: {
kind: "api",
identifier: "github.search",
endpoint: {
path: "/search/repositories?q=${query}&sort=${sort}",
methods: ["GET"]
}
}
},
description: "Endpoint with query parameters"
},
// Nested endpoint paths
{
name: "nested-endpoint",
input: '@api github.repos.issues = {{\n path: "/repos/${owner}/${repo}/issues",\n methods: ["GET", "POST"]\n }}',
expected: {
type: "Directive",
directive: {
kind: "api",
identifier: "github.repos.issues",
endpoint: {
path: "/repos/${owner}/${repo}/issues",
methods: ["GET", "POST"]
}
}
},
description: "Deeply nested endpoint definition"
}
];
}
});
// node_modules/meld-spec/dist/esm/spec/tests/directives/api/api-invalid.test.js
var require_api_invalid_test = __commonJS({
"node_modules/meld-spec/dist/esm/spec/tests/directives/api/api-invalid.test.js"(exports) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.apiInvalidTests = void 0;
exports.apiInvalidTests = [
// Invalid identifiers
{
name: "empty-identifier",
input: '@api = {{ baseUrl: "https://api.com" }}',
expected: {
type: "Error",
error: "API identifier cannot be empty"
},
description: "API identifier is required"
},
{
name: "invalid-identifier",
input: '@api 123api = {{ baseUrl: "https://api.com" }}',
expected: {
type: "Error",
error: "Invalid identifier: must start with letter or underscore"
},
description: "API identifier must be valid"
},
{
name: "invalid-endpoint-segment",
input: '@api api.123endpoint = {{ path: "/test" }}',
expected: {
type: "Error",
error: "Invalid endpoint identifier segment: must be valid identifier"
},
description: "Endpoint path segments must be valid identifiers"
},
// Missing required fields
{
name: "missing-baseurl",
input: "@api github = {{ timeout: 5000 }}",
expected: {
type: "Error",
error: "API configuration requires baseUrl"
},
description: "baseUrl is required for API configuration"
},
{
name: "empty-baseurl",
input: '@api github = {{ baseUrl: "" }}',
expected: {
type: "Error",
error: "baseUrl cannot be empty"
},
description: "baseUrl must have value"
},
// Invalid URL formats
{
name: "invalid-baseurl",
input: '@api github = {{ baseUrl: "not a url" }}',
expected: {
type: "Error",
error: "Invalid baseUrl: must be valid URL"
},
description: "baseUrl must be valid URL"
},
{
name: "relative-baseurl",
input: '@api github = {{ baseUrl: "/api" }}',
expected: {
type: "Error",
error: "Invalid baseUrl: must be absolute URL"
},
description: "baseUrl must be absolute"
},
// Invalid endpoint paths
{
name: "absolute-endpoint-path",
input: '@api github.issues = {{ path: "https://api.github.com/issues" }}',
expected: {
type: "Error",
error: "Endpoint path must be relative"
},
description: "Endpoint paths must be relative"
},
{
name: "empty-endpoint-path",
input: '@api github.issues = {{ path: "" }}',
expected: {
type: "Error",
error: "Endpoint path cannot be empty"
},
description: "Endpoint path must have value"
},
// Invalid methods
{
name: "invalid-method",
input: '@api github.issues = {{ path: "/issues", methods: ["INVALID"] }}',
expected: {
type: "Error",
error: "Invalid HTTP method: must be GET, POST, PUT, PATCH, or DELETE"
},
description: "Methods must be valid HTTP methods"
},
{
name: "empty-methods",
input: '@api github.issues = {{ path: "/issues", methods: [] }}',
expected: {
type: "Error",
error: "Methods array cannot be empty"
},
description: "Methods must contain at least one method"
},
{
name: "duplicate-methods",
input: '@api github.issues = {{ path: "/issues", methods: ["GET", "GET"] }}',
expected: {
type: "Error",
error: "Duplicate HTTP method in methods array"
},
description: "Methods must be unique"
},
// Invalid object syntax
{
name: "missing-braces",
input: '@api github = baseUrl: "https://api.github.com"',
expected: {
type: "Error",
error: "API configuration must be object literal"
},
description: "Configuration must be in braces"
},
{
name: "unclosed-braces",
input: '@api github = {{ baseUrl: "https://api.github.com"',
expected: {
type: "Error",
error: "Unclosed object literal"
},
description: "Object literal must be closed"
},
// Invalid field values
{
name: "invalid-timeout",
input: '@api github = {{ baseUrl: "https://api.github.com", timeout: "5000" }}',
expected: {
type: "Error",
error: "timeout must be a number"
},
description: "Numeric fields must be numbers"
},
{
name: "invalid-retries",
input: '@api github = {{ baseUrl: "https://api.github.com", retries: -1 }}',
expected: {
type: "Error",
error: "retries must be non-negative"
},
description: "Retries must be non-negative"
},
// Invalid headers
{
name: "invalid-header-name",
input: '@api github = {{ baseUrl: "https://api.github.com", headers: { "Invalid:Name": "value" } }}',
expected: {
type: "Error",
error: "Invalid header name: cannot contain colon"
},
description: "Header names must be valid"
},
{
name: "non-string-header",
input: '@api github = {{ baseUrl: "https://api.github.com", headers: { Accept: 123 } }}',
expected: {
type: "Error",
error: "Header values must be strings"
},
description: "Headers must have string values"
},
// Indentation errors
{
name: "indented-directive",
input: ' @api github = {{ baseUrl: "https://api.github.com" }}',
expected: {
type: "Error",
error: "Directives must appear at start of line"
},
description: "Directives cannot be indented"
},
// Syntax errors
{
name: "missing-equals",
input: '@api github {{ baseUrl: "https://api.github.com" }}',
expected: {
type: "Error",
error: "Missing = in API assignment"
},
description: "API assignment requires equals sign"
},
{
name: "extra-tokens",
input: '@api github = {{ baseUrl: "https://api.github.com" }} extra',
expected: {
type: "Error",
error: "Unexpected tokens after API configuration"
},
description: "No extra tokens allowed after configuration"
}
];
}
});
// node_modules/meld-spec/dist/esm/spec/tests/directives/data/data.test.js
var require_data_test = __commonJS({
"node_modules/meld-spec/dist/esm/spec/tests/directives/data/data.test.js"(exports) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.dataTests = void 0;
exports.dataTests = [
// Basic value assignments
{
name: "object-literal",
input: '@data config = {{ name: "test", version: 1 }}',
expected: {
type: "Directive",
directive: {
kind: "data",
identifier: "config",
value: {
name: "test",
version: 1
},
source: "literal"
}
},
description: "Object literal assignment"
},
// Schema validation
{
name: "with-schema",
input: '@data config : ConfigSchema = {{ name: "test" }}',
expected: {
type: "Directive",
directive: {
kind: "data",
identifier: "config",
schema: "ConfigSchema",
value: {
name: "test"
},
source: "literal"
}
},
description: "Value with schema validation"
},
// @embed source
{
name: "embed-source",
input: "@data config = @embed [config.json]",
expected: {
type: "Directive",
directive: {
kind: "data",
identifier: "config",
source: "embed",
embed: {
kind: "embed",
path: {
raw: "config.json",
normalized: "./config.json",
structured: {
base: ".",
segments: ["config.json"],
variables: {},
cwd: true
}
}
}
}
},
description: "Data from embed directive"
},
{
name: "embed-with-schema",
input: "@data config : ConfigSchema = @embed [config.json]",
expected: {
type: "Directive",
directive: {
kind: "data",
identifier: "config",
schema: "ConfigSchema",
source: "embed",
embed: {
kind: "embed",
path: {
raw: "config.json",
normalized: "./config.json",
structured: {
base: ".",
segments: ["config.json"],
variables: {},
cwd: true
}
}
}
}
},
description: "Data from embed with schema"
},
// @run source
{
name: "run-source",
input: '@data output = @run [echo "{\\"key\\": \\"value\\"}"]',
expected: {
type: "Directive",
directive: {
kind: "data",
identifier: "output",
source: "run",
run: {
kind: "run",
command: 'echo "{\\"key\\": \\"value\\"}"'
}
}
},
description: "Data from run directive"
},
// @call source
{
name: "call-source",
input: "@data response = @call api.get [/data]",
expected: {
type: "Directive",
directive: {
kind: "data",
identifier: "response",
source: "call",
call: {
kind: "call",
api: "api",
method: "get",
path: "/data"
}
}
},
description: "Data from API call"
},
// Complex object with variables
{
name: "complex-object",
input: "@data user = {{\n name: ${name},\n age: 30,\n settings: {\n theme: ${theme},\n enabled: true\n },\n tags: [${tag1}, ${tag2}]\n }}",
expected: {
type: "Directive",
directive: {
kind: "data",
identifier: "user",
value: {
name: "${name}",
age: 30,
settings: {
theme: "${theme}",
enabled: true
},
tags: ["${tag1}", "${tag2}"]
},
source: "literal"
}
},
description: "Complex object with nested structures and variables"
},
// Special values
{
name: "special-values",
input: "@data values = {{\n null_value: null,\n bool_true: true,\n bool_false: false,\n number: 42.5\n }}",
expected: {
type: "Directive",
directive: {
kind: "data",
identifier: "values",
value: {
null_value: null,
bool_true: true,
bool_false: false,
number: 42.5
},
source: "literal"
}
},
description: "Object with special JSON values"
}
];
}
});
// node_modules/meld-spec/dist/esm/spec/tests/directives/data/data-invalid.test.js
var require_data_invalid_test = __commonJS({
"node_modules/meld-spec/dist/esm/spec/tests/directives/data/data-invalid.test.js"(exports) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.dataInvalidTests = void 0;
exports.dataInvalidTests = [
// Invalid identifiers
{
name: "empty-identifier",
input: "@data = {{ value: 1 }}",
expected: {
type: "Error",
error: "Data identifier cannot be empty"
},
description: "Data identifier is required"
},
{
name: "invalid-identifier",
input: "@data 123data = {{ value: 1 }}",
expected: {
type: "Error",
error: "Invalid identifier: must start with letter or underscore"
},
description: "Data identifier must be valid"
},
// Invalid object literals
{
name: "unclosed-object",
input: '@data config = {{ name: "test"',
expected: {
type: "Error",
error: "Unclosed object literal"
},
description: "Object literals must be closed"
},
{
name: "invalid-key",
input: '@data config = {{ 123: "value" }}',
expected: {
type: "Error",
error: "Invalid object key: must be valid identifier"
},
description: "Object keys must be valid identifiers"
},
{
name: "missing-colon",
input: '@data config = {{ name "value" }}',
expected: {
type: "Error",
error: "Missing : in object property"
},
description: "Object properties require colon"
},
// Invalid array literals
{
name: "unclosed-array",
input: "@data list = [[ 1, 2, 3",
expected: {
type: "Error",
error: "Unclosed array literal"
},
description: "Array literals must be closed"
},
{
name: "missing-comma",
input: "@data list = [[ 1 2 3 ]]",
expected: {
type: "Error",
error: "Missing comma between array elements"
},
description: "Array elements must be comma-separated"
},
// Schema errors
{
name: "invalid-schema",
input: "@data config : 123Schema = {{ value: 1 }}",
expected: {
type: "Error",
error: "Invalid schema identifier"
},
description: "Schema must be valid identifier"
},
{
name: "missing-schema-equals",
input: "@data config : Schema {{ value: 1 }}",
expected: {
type: "Error",
error: "Missing = after schema"
},
description: "Schema must be followed by equals"
},
// Invalid embed source
{
name: "invalid-embed",
input: "@data config = @embed config.json",
expected: {
type: "Error",
error: "Invalid embed syntax: missing []"
},
description: "Embed source must use proper syntax"
},
{
name: "empty-embed-path",
input: "@data config = @embed []",
expected: {
type: "Error",
error: "Empty path in embed source"
},
description: "Embed path cannot be empty"
},
// Invalid run source
{
name: "invalid-run",
input: '@data output = @run echo "hello"',
expected: {
type: "Error",
error: "Invalid run syntax: missing []"
},
description: "Run source must use proper syntax"
},
{
name: "empty-run-command",
input: "@data output = @run []",
expected: {
type: "Error",
error: "Empty command in run source"
},
description: "Run command cannot be empty"
},
// Invalid call source
{
name: "invalid-call",
input: "@data response = @call api",
expected: {
type: "Error",
error: "Invalid call syntax: missing method and path"
},
description: "Call source must specify method and path"
},
{
name: "invalid-call-method",
input: "@data response = @call api.invalid [/path]",
expected: {
type: "Error",
error: "Invalid HTTP method in call source"
},
description: "Call method must be valid HTTP method"
},
// Invalid values
{
name: "invalid-json",
input: "@data config = {{ function() {} }}",
expected: {
type: "Error",
error: "Invalid value: must be valid JSON"
},
description: "Values must be valid JSON"
},
{
name: "undefined-value",
input: "@data config = {{ value: undefined }}",
expected: {
type: "Error",
error: "Invalid value: undefined not allowed"
},
description: "Undefined not allowed in values"
},
// Indentation errors
{
name: "indented-directive",
input: " @data config = {{ value: 1 }}",
expected: {
type: "Error",
error: "Directives must appear at start of line"
},
description: "Directives cannot be indented"
},
// Syntax errors
{
name: "missing-equals",
input: "@data config {{ value: 1 }}",
expected: {
type: "Error",
error: "Missing = in data assignment"
},
description: "Data assignment requires equals sign"
},
{
name: "extra-tokens",
input: "@data config = {{ value: 1 }} extra",
expected: {
type: "Error",
error: "Unexpected tokens after data value"
},
description: "No extra tokens allowed after value"
}
];
}
});
// node_modules/meld-spec/dist/esm/spec/tests/directives/define/define.test.js
var require_define_test = __commonJS({
"node_modules/meld-spec/dist/esm/spec/tests/directives/define/define.test.js"(exports) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.defineTests = void 0;
exports.defineTests = [
// Basic command definition
{
name: "basic-command",
input: '@define greet = @run [echo "hello"]',
expected: {
type: "Directive",
directive: {
kind: "define",
name: "greet",
command: {
kind: "run",
command: 'echo "hello"'
}
}
},
description: "Basic command definition"
},
// Command with parameters
{
name: "command-with-params",
input: '@define greet(name, message) = @run [echo "Hello ${name}, ${message}"]',
expected: {
type: "Directive",
directive: {
kind: "define",
name: "greet",
parameters: ["name", "message"],
command: {
kind: "run",
command: 'echo "Hello ${name}, ${message}"'
}
}
},
description: "Command with parameters"
},
// Command with single parameter
{
name: "single-param",
input: "@define echo(message) = @run [echo ${message}]",
expected: {
type: "Directive",
directive: {
kind: "define",
name: "echo",
parameters: ["message"],
command: {
kind: "run",
command: "echo ${message}"
}
}
},
description: "Command with single parameter"
},
// Command with risk metadata
{
name: "risk-metadata",
input: '@define cmd.risk = "low"',
expected: {
type: "Directive",
directive: {
kind: "define",
name: "cmd",
field: "risk",
value: "low"
}
},
description: "Command with risk level"
},
// Command with specific risk levels
{
name: "risk-high",
input: '@define cmd.risk.high = "Destructive operation"',
expected: {
type: "Directive",
directive: {
kind: "define",
name: "cmd",
field: "risk.high",
value: "Destructive operation"
}
},
description: "Command with high risk"
},
{
name: "risk-med",
input: '@define cmd.risk.med = "Use with caution"',
expected: {
type: "Directive",
directive: {
kind: "define",
name: "cmd",
field: "risk.med",
value: "Use with caution"
}
},
description: "Command with medium risk"
},
{
name: "risk-low",
input: '@define cmd.risk.low = "Safe operation"',
expected: {
type: "Directive",
directive: {
kind: "define",
name: "cmd",
field: "risk.low",
value: "Safe operation"
}
},
description: "Command with low risk"
},
// Command with about metadata
{
name: "about-metadata",
input: '@define cmd.about = "Description of the command"',
expected: {
type: "Directive",
directive: {
kind: "define",
name: "cmd",
field: "about",
value: "Description of the command"
}
},
description: "Command with about information"
},
// Command with meta metadata
{
name: "meta-metadata",
input: '@define cmd.meta = "Additional metadata"',
expected: {
type: "Directive",
directive: {
kind: "define",
name: "cmd",
field: "meta",
value: "Additional metadata"
}
},
description: "Command with meta information"
},
// Complex command with multiple parameters
{
name: "complex-command",
input: '@define deploy(env, version) = @run [echo "Deploying ${version} to ${env}" && deploy --env=${env} --version=${version}]',
expected: {
type: "Directive",
directive: {
kind: "define",
name: "deploy",
parameters: ["env", "version"],
command: {
kind: "run",
command: 'echo "Deploying ${version} to ${env}" && deploy --env=${env} --version=${version}'
}
}
},
description: "Complex command with multiple parameters"
},
// Command with special path variables
{
name: "path-variables",
input: "@define backup(name) = @run [cp $PROJECTPATH/src/${name} $HOMEPATH/backups/]",
expected: {
type: "Directive",
directive: {
kind: "define",
name: "backup",
parameters: ["name"],
command: {
kind: "run",
command: "cp $PROJECTPATH/src/${name} $HOMEPATH/backups/"
}
}
},
description: "Command using special path variables"
}
];
}
});
// node_modules/meld-spec/dist/esm/spec/tests/directives/define/define-invalid.test.js
var require_define_invalid_test = __commonJS({
"node_modules/meld-spec/dist/esm/spec/tests/directives/define/define-invalid.test.js"(exports) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.defineInvalidTests = void 0;
exports.defineInvalidTests = [
// Invalid command body
{
name: "non-run-directive",
input: "@define cmd = @embed [file.md]",
expected: {
type: "Error",
error: "Command body must be an @run directive"
},
description: "Cannot use other directives as command body"
},
{
name: "string-body",
input: '@define cmd = "hello"',
expected: {
type: "Error",
error: "Command body must be an @run directive"
},
description: "Cannot use string as command body"
},
// Invalid identifiers
{
name: "empty-identifier",
input: '@define = @run [echo "hello"]',
expected: {
type: "Error",
error: "Command name cannot be empty"
},
description: "Command name is required"
},
{
name: "invalid-identifier",
input: '@define 123cmd = @run [echo "hello"]',
expected: {
type: "Error",
error: "Invalid command name: must start with letter or underscore"
},
description: "Command name must be valid identifier"
},
{
name: "special-chars",
input: '@define cmd! = @run [echo "hello"]',
expected: {
type: "Error",
error: "Invalid command name: cannot contain special characters"
},
description: "Command name cannot have special characters"
},
// Invalid parameters
{
name: "empty-param-list",
input: '@define cmd() = @run [echo "hello"]',
expected: {
type: "Error",
error: "Empty parameter list not allowed"
},
description: "Must have at least one parameter if using parentheses"
},
{
name: "invalid-param-name",
input: "@define cmd(123param) = @run [echo ${123param}]",
expected: {
type: "Error",
error: "Invalid parameter name: must start with letter or underscore"
},
description: "Parameter names must be valid identifiers"
},
{
name: "unused-param",
input: '@define cmd(param) = @run [echo "hello"]',
expected: {
type: "Error",
error: "Parameter param is not used in command body"
},
description: "All parameters must be used in command"
},
{
name: "duplicate-params",
input: "@define cmd(param, param) = @run [echo ${param}]",
expected: {
type: "Error",
error: "Duplicate parameter name: param"
},
description: "Parameter names must be unique"
},
// Invalid metadata fields
{
name: "invalid-field",
input: '@define cmd.invalid = "value"',
expected: {
type: "Error",
error: "Invalid metadata field: must be risk, risk.high, risk.med, risk.low, about, or meta"
},
description: "Only specific metadata fields are allowed"
},
{
name: "empty-field",
input: '@define cmd. = "value"',
expected: {
type: "Error",
error: "Empty metadata field"
},
description: "Metadata field cannot be empty"
},
{
name: "invalid-risk-level",
input: '@define cmd.risk.invalid = "value"',
expected: {
type: "Error",
error: "Invalid risk level: must be high, med, or low"
},
description: "Only specific risk levels are allowed"
},
{
name: "run-with-field",
input: '@define cmd.risk = @run [echo "hello"]',
expected: {
type: "Error",
error: "Metadata fields must have string values"
},
description: "Cannot use @run with metadata fields"
},
// Syntax errors
{
name: "missing-equals",
input: '@define cmd @run [echo "hello"]',
expected: {
type: "Error",
error: "Missing = in @define directive"
},
description: "Must have equals sign"
},
{
name: "missing-closing-paren",
input: "@define cmd(param = @run [echo ${param}]",
expected: {
type: "Error",
error: "Unclosed ( in parameter list"
},
description: "Must close parameter list"
},
{
name: "missing-param-comma",
input: "@define cmd(param1 param2) = @run [echo ${param1} ${param2}]",
expected: {
type: "Error",
error: "Missing comma between parameters"
},
description: "Parameters must be comma-separated"
},
// Indentation errors
{
name: "indented-directive",
input: ' @define cmd = @run [echo "hello"]',
expected: {
type: "Error",
error: "Directives must appear at the start of a line"
},
description: "Directives cannot be indented"
},
// Variable errors
{
name: "data-var-in-command",
input: "@define cmd = @run [echo #{data}]",
expected: {
type: "Error",
error: "Data variables not allowed in command arguments"
},
description: "Cannot use data variables in commands"
},
{
name: "nested-var",
input: "@define cmd(param) = @run [echo ${var${param}}]",
expected: {
type: "Error",
error: "Nested variable interpolation not allowed"
},
description: "Cannot nest variable references"
}
];
}
});
// node_modules/meld-spec/dist/esm/spec/tests/directives/embed/embed.test.js
var require_embed_test = __commonJS({
"node_modules/meld-spec/dist/esm/spec/tests/directives/embed/embed.test.js"(exports) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.embedTests = void 0;
exports.embedTests = [
// Basic usage
{
name: "basic-embed",
input: "@embed [file.md]",
expected: {
type: "Directive",
directive: {
kind: "embed",
path: {
raw: "file.md",
normalized: "./file.md",
structured: {
base: ".",
segments: ["file.md"],
variables: {},
cwd: true
}
}
}
},
description: "Basic file embed"
},
// Section embedding
{
name: "section-embed",
input: "@embed [file.md # Introduction]",
expected: {
type: "Directive",
directive: {
kind: "embed",
path: {
raw: "file.md",
normalized: "./file.md",
structured: {
base: ".",
segments: ["file.md"],
variables: {},
cwd: true
}
},
section: "Introduction"
}
},
description: "Embed specific section"
},
// Header level adjustment
{
name: "header-level",
input: "@embed [file.md] as ###",
expected: {
type: "Directive",
directive: {
kind: "embed",
path: {
raw: "file.md",
normalized: "./file.md",
structured: {
base: ".",
segments: ["file.md"],
variables: {}
}
},
headerLevel: 3
}
},
description: "Embed with header level adjustment"
},
// Section with header level
{
name: "section-with-header",
input: "@embed [file.md # Introduction] as ##",
expected: {
type: "Directive",
directive: {
kind: "embed",
path: {
raw: "file.md",
normalized: "./file.md",
structured: {
base: ".",
segments: ["file.md"],
variables: {}
}
},
section: "Introduction",
headerLevel: 2
}
},
description: "Embed section with header level adjustment"
},
// Named embed
{
name: "named-embed",
input: "@embed { config } from [config.json]",
expected: {
type: "Directive",
directive: {
kind: "embed",
path: {
raw: "config.json",
normalized: "./config.json",
structured: {
base: ".",
segments: ["config.json"],
variables: {}
}
},
names: ["config"]
}
},
description: "Named embed"
},
// Multiple named embeds
{
name: "multiple-names",
input: "@embed { user, settings } from [data.json]",
expected: {
type: "Directive",
directive: {
kind: "embed",
path: {
raw: "data.json",
normalized: "./data.json",
structured: {
base: ".",
segments: ["data.json"],
variables: {}
}
},
names: ["user", "settings"]
}
},
description: "Multiple named embeds"
},
// Under header
{
name: "under-header",
input: "@embed [content.md] under My Section",
expected: {
type: "Directive",
directive: {
kind: "embed",
path: {
raw: "content.md",
normalized: "./content.md",
structured: {
base: ".",
segments: ["content.md"],
variables: {}
}
},
underHeader: "My Section"
}
},
description: "Embed under header"
},
// Complex paths
{
name: "relative-path",
input: "@embed [../path/to/file.md]",
expected: {
type: "Directive",
directive: {
kind: "embed",
path: {
raw: "../path/to/file.md",
normalized: "../path/to/file.md",
structured: {
base: "..",
segments: ["path", "to", "file.md"],
variables: {}
}
}
}
},
description: "Embed with relative path"
},
// Variable interpolation
{
name: "variable-path",
input: "@embed [${file_path}]",
expected: {
type: "Directive",
directive: {
kind: "embed",
path: {
raw: "${file_path}",
normalized: "./${file_path}",
structured: {
base: ".",
segments: ["${file_path}"],
variables: {
text: ["file_path"]
},
cwd: true
}
}
}
},
description: "Embed with variable in path"
},
// Path with brackets
{
name: "path-with-brackets",
input: "@embed [path/with [brackets].md]",
expected: {
type: "Directive",
directive: {
kind: "embed",
path: {
raw: "path/with [brackets].md",
normalized: "./path/with [brackets].md",
structured: {
base: ".",
segments: ["path", "with [brackets].md"],
variables: {}
}
}
}
},
description: "Embed with brackets in path"
},
// Special path variables
{
name: "home-path",
input: "@embed [$~/docs/file.md]",
expected: {
type: "Directive",
directive: {
kind: "embed",
path: {
raw: "$~/docs/file.md",
normalized: "$HOMEPATH/docs/file.md",
structured: {
base: "$~",
segments: ["docs", "file.md"],
variables: {
special: ["HOMEPATH"]
}
}
}
}
},
description: "Path with home alias"
},
// Project path alias
{
name: "project-path",
input: "@embed [$./src/file.md]",
expected: {
type: "Directive",
directive: {
kind: "embed",
path: {
raw: "$./src/file.md",
normalized: "$PROJECTPATH/src/file.md",
structured: {
base: "$.",
segments: ["src", "file.md"],
variables: {
special: ["PROJECTPATH"]
}
}
}
}
},
description: "Path with project alias"
}
];
}
});
// node_modules/meld-spec/dist/esm/spec/tests/directives/embed/embed-invalid.test.js
var require_embed_invalid_test = __commonJS({
"node_modules/meld-spec/dist/esm/spec/tests/directives/embed/embed-invalid.test.js"(exports) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.embedInvalidTests = void 0;
exports.embedInvalidTests = [
// Indentation errors
{
name: "indented-directive",
input: " @embed [file.md]",
expected: {
type: "Error",
error: "Directives must appear at the start of a line"
},
description: "Directives cannot be indented"
},
// Empty paths
{
name: "empty-path",
input: "@embed []",
expected: {
type: "Error",
error: "Empty path in @embed directive"
},
description: "Path cannot be empty"
},
{
name: "whitespace-path",
input: "@embed [ ]",
expected: {
type: "Error",
error: "Empty path in @embed directive"
},
description: "Path cannot be only whitespace"
},
// Invalid section syntax
{
name: "empty-section",
input: "@embed [file.md #]",
expected: {
type: "Error",
error: "Empty section name"
},
description: "Section marker must be followed by text"
},
{
name: "whitespace-section",
input: "@embed [file.md # ]",
expected: {
type: "Error",
error: "Empty section name"
},
description: "Section name cannot be only whitespace"
},
{
name: "missing-section-space",
input: "@embed [file.md #section]",
expected: {
type: "Error",
error: "Invalid section syntax: missing space after #"
},
description: "Must have space after section marker"
},
// Invalid name syntax
{
name: "invalid-name-hyphen",
input: "@embed { invalid-name } from [file.md]",
expected: {
type: "Error",
error: "Invalid identifier: invalid-name"
},
description: "Names cannot contain hyphens"
},
{
name: "invalid-name-number-start",
input: "@embed { 123name } from [file.md]",
expected: {
type: "Error",
error: "Invalid identifier: 123name"
},
description: "Names cannot start with numbers"
},
{
name: "invalid-name-special-chars",
input: "@embed { name! } from [file.md]",
expected: {
type: "Error",
error: "Invalid identifier: name!"
},
description: "Names cannot contain special characters"
},
// Invalid header levels
{
name: "too-many-hashes",
input: "@embed [file.md] as ######",
expected: {
type: "Error",
error: "Invalid header level: maximum is 6"
},
description: "Header levels cannot exceed 6"
},
{
name: "invalid-header-marker",
input: "@embed [file.md] as ##.#",
expected: {
type: "Error",
error: "Invalid header level syntax"
},
description: "Header markers must be consecutive hashes"
},
// Syntax errors
{
name: "missing-closing-bracket",
input: "@embed [file.md",
expected: {
type: "Error",
error: "Unclosed [ in @embed directive"
},
description: "Must close brackets"
},
{
name: "missing-opening-bracket",
input: "@embed file.md]",
expected: {
type: "Error",
error: "Missing [ in @embed directive"
},
description: "Must open brackets"
},
{
name: "missing-closing-brace",
input: "@embed { name from [file.md]",
expected: {
type: "Error",
error: "Unclosed { in @embed directive"
},
description: "Must close braces"
},
// Invalid combinations
{
name: "section-and-names",
input: "@embed { name } from [file.md # Section]",
expected: {
type: "Error",
error: "Cannot combine named embed with section"
},
description: "Cannot use both named embed and section syntax"
},
{
name: "header-and-names",
input: "@embed { name } from [file.md] as ##",
expected: {
type: "Error",
error: "Cannot combine named embed with header level"
},
description: "Cannot use both named embed and header level"
},
// Path validation
{
name: "ab