mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-27 07:14:56 +00:00
config: json,script,example (6 files)
This commit is contained in:
@@ -1,23 +1,32 @@
|
||||
{
|
||||
"$schema": "./script.schema.json",
|
||||
"schema_version": "2.1.0",
|
||||
"package": "json_script_example",
|
||||
"description": "Example using imports from other script files",
|
||||
|
||||
"imports": [
|
||||
{
|
||||
"from": "math_utils",
|
||||
"import": ["add", "multiply", "clamp", "PI"]
|
||||
"import": [
|
||||
"add",
|
||||
"multiply",
|
||||
"clamp",
|
||||
"PI"
|
||||
]
|
||||
},
|
||||
{
|
||||
"from": "validation",
|
||||
"import": ["validateRange", "isNotEmpty"]
|
||||
"import": [
|
||||
"validateRange",
|
||||
"isNotEmpty"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
"exports": {
|
||||
"functions": ["calculateArea", "validateInput"]
|
||||
"functions": [
|
||||
"calculateArea",
|
||||
"validateInput"
|
||||
]
|
||||
},
|
||||
|
||||
"functions": [
|
||||
{
|
||||
"id": "calculate_area_fn",
|
||||
@@ -25,8 +34,14 @@
|
||||
"description": "Calculate area of rectangle using imported math functions",
|
||||
"exported": true,
|
||||
"params": [
|
||||
{"name": "width", "type": "number"},
|
||||
{"name": "height", "type": "number"}
|
||||
{
|
||||
"name": "width",
|
||||
"type": "number"
|
||||
},
|
||||
{
|
||||
"name": "height",
|
||||
"type": "number"
|
||||
}
|
||||
],
|
||||
"returnType": "number",
|
||||
"body": [
|
||||
@@ -40,7 +55,10 @@
|
||||
"value": {
|
||||
"type": "call_expression",
|
||||
"callee": "$ref:imports.math_utils.multiply",
|
||||
"args": ["$ref:params.width", "$ref:params.height"]
|
||||
"args": [
|
||||
"$ref:params.width",
|
||||
"$ref:params.height"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -52,7 +70,11 @@
|
||||
"value": {
|
||||
"type": "call_expression",
|
||||
"callee": "$ref:imports.math_utils.clamp",
|
||||
"args": ["$ref:local.area", 0, 1000]
|
||||
"args": [
|
||||
"$ref:local.area",
|
||||
0,
|
||||
1000
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -89,11 +111,13 @@
|
||||
"value": {
|
||||
"type": "call_expression",
|
||||
"callee": "$ref:imports.validation.isNotEmpty",
|
||||
"args": [{
|
||||
"type": "member_access",
|
||||
"object": "$ref:params.input",
|
||||
"property": "name"
|
||||
}]
|
||||
"args": [
|
||||
{
|
||||
"type": "member_access",
|
||||
"object": "$ref:params.input",
|
||||
"property": "name"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -174,7 +198,9 @@
|
||||
"left": {
|
||||
"type": "call_expression",
|
||||
"callee": "$ref:imports.Object.keys",
|
||||
"args": ["$ref:local.errors"]
|
||||
"args": [
|
||||
"$ref:local.errors"
|
||||
]
|
||||
},
|
||||
"operator": ">",
|
||||
"right": 0
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
{
|
||||
"$schema": "./script.schema.json",
|
||||
"schema_version": "2.1.0",
|
||||
"package": "json_script_example",
|
||||
"description": "UI component examples using JSON script",
|
||||
|
||||
"exports": {
|
||||
"components": ["ExpressionDemo", "OperatorDemo", "ResultDisplay"]
|
||||
"components": [
|
||||
"ExpressionDemo",
|
||||
"OperatorDemo",
|
||||
"ResultDisplay"
|
||||
]
|
||||
},
|
||||
|
||||
"components": [
|
||||
{
|
||||
"id": "expression_demo",
|
||||
@@ -42,7 +45,12 @@
|
||||
}
|
||||
],
|
||||
"since": "1.0.0",
|
||||
"tags": ["component", "demo", "interactive", "expressions"]
|
||||
"tags": [
|
||||
"component",
|
||||
"demo",
|
||||
"interactive",
|
||||
"expressions"
|
||||
]
|
||||
},
|
||||
"props": [
|
||||
{
|
||||
@@ -114,7 +122,9 @@
|
||||
},
|
||||
"handlers": {
|
||||
"setA": {
|
||||
"params": ["value"],
|
||||
"params": [
|
||||
"value"
|
||||
],
|
||||
"body": [
|
||||
{
|
||||
"type": "setState",
|
||||
@@ -125,7 +135,9 @@
|
||||
]
|
||||
},
|
||||
"setB": {
|
||||
"params": ["value"],
|
||||
"params": [
|
||||
"value"
|
||||
],
|
||||
"body": [
|
||||
{
|
||||
"type": "setState",
|
||||
@@ -144,7 +156,10 @@
|
||||
"value": {
|
||||
"type": "call_expression",
|
||||
"callee": "$ref:imports.script.all_expressions",
|
||||
"args": ["$ref:state.a", "$ref:state.b"]
|
||||
"args": [
|
||||
"$ref:state.a",
|
||||
"$ref:state.b"
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -175,7 +190,12 @@
|
||||
}
|
||||
],
|
||||
"since": "1.0.0",
|
||||
"tags": ["component", "demo", "operators", "table"]
|
||||
"tags": [
|
||||
"component",
|
||||
"demo",
|
||||
"operators",
|
||||
"table"
|
||||
]
|
||||
},
|
||||
"props": [
|
||||
{
|
||||
@@ -347,7 +367,10 @@
|
||||
"value": {
|
||||
"type": "call_expression",
|
||||
"callee": "$ref:imports.script.all_operators",
|
||||
"args": ["$ref:props.x", "$ref:props.y"]
|
||||
"args": [
|
||||
"$ref:props.x",
|
||||
"$ref:props.y"
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -369,7 +392,11 @@
|
||||
}
|
||||
],
|
||||
"since": "1.0.0",
|
||||
"tags": ["component", "display", "results"]
|
||||
"tags": [
|
||||
"component",
|
||||
"display",
|
||||
"results"
|
||||
]
|
||||
},
|
||||
"props": [
|
||||
{
|
||||
@@ -474,11 +501,13 @@
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
"imports": [
|
||||
{
|
||||
"from": "script",
|
||||
"import": ["all_expressions", "all_operators"]
|
||||
"import": [
|
||||
"all_expressions",
|
||||
"all_operators"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,13 +1,21 @@
|
||||
{
|
||||
"$schema": "./script.schema.json",
|
||||
"schema_version": "2.1.0",
|
||||
"package": "json_script_example",
|
||||
"description": "Math utility functions",
|
||||
|
||||
"exports": {
|
||||
"functions": ["add", "subtract", "multiply", "divide", "clamp"],
|
||||
"constants": ["PI", "E"]
|
||||
"functions": [
|
||||
"add",
|
||||
"subtract",
|
||||
"multiply",
|
||||
"divide",
|
||||
"clamp"
|
||||
],
|
||||
"constants": [
|
||||
"PI",
|
||||
"E"
|
||||
]
|
||||
},
|
||||
|
||||
"constants": [
|
||||
{
|
||||
"id": "pi_const",
|
||||
@@ -24,7 +32,6 @@
|
||||
"exported": true
|
||||
}
|
||||
],
|
||||
|
||||
"functions": [
|
||||
{
|
||||
"id": "add_fn",
|
||||
@@ -32,8 +39,14 @@
|
||||
"description": "Add two numbers",
|
||||
"exported": true,
|
||||
"params": [
|
||||
{"name": "a", "type": "number"},
|
||||
{"name": "b", "type": "number"}
|
||||
{
|
||||
"name": "a",
|
||||
"type": "number"
|
||||
},
|
||||
{
|
||||
"name": "b",
|
||||
"type": "number"
|
||||
}
|
||||
],
|
||||
"returnType": "number",
|
||||
"body": [
|
||||
@@ -54,8 +67,14 @@
|
||||
"description": "Subtract two numbers",
|
||||
"exported": true,
|
||||
"params": [
|
||||
{"name": "a", "type": "number"},
|
||||
{"name": "b", "type": "number"}
|
||||
{
|
||||
"name": "a",
|
||||
"type": "number"
|
||||
},
|
||||
{
|
||||
"name": "b",
|
||||
"type": "number"
|
||||
}
|
||||
],
|
||||
"returnType": "number",
|
||||
"body": [
|
||||
@@ -76,8 +95,14 @@
|
||||
"description": "Multiply two numbers",
|
||||
"exported": true,
|
||||
"params": [
|
||||
{"name": "a", "type": "number"},
|
||||
{"name": "b", "type": "number"}
|
||||
{
|
||||
"name": "a",
|
||||
"type": "number"
|
||||
},
|
||||
{
|
||||
"name": "b",
|
||||
"type": "number"
|
||||
}
|
||||
],
|
||||
"returnType": "number",
|
||||
"body": [
|
||||
@@ -98,8 +123,14 @@
|
||||
"description": "Divide two numbers",
|
||||
"exported": true,
|
||||
"params": [
|
||||
{"name": "a", "type": "number"},
|
||||
{"name": "b", "type": "number"}
|
||||
{
|
||||
"name": "a",
|
||||
"type": "number"
|
||||
},
|
||||
{
|
||||
"name": "b",
|
||||
"type": "number"
|
||||
}
|
||||
],
|
||||
"returnType": "number",
|
||||
"body": [
|
||||
@@ -139,9 +170,18 @@
|
||||
"description": "Clamp a value between min and max",
|
||||
"exported": true,
|
||||
"params": [
|
||||
{"name": "value", "type": "number"},
|
||||
{"name": "min", "type": "number"},
|
||||
{"name": "max", "type": "number"}
|
||||
{
|
||||
"name": "value",
|
||||
"type": "number"
|
||||
},
|
||||
{
|
||||
"name": "min",
|
||||
"type": "number"
|
||||
},
|
||||
{
|
||||
"name": "max",
|
||||
"type": "number"
|
||||
}
|
||||
],
|
||||
"returnType": "number",
|
||||
"body": [
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"$schema": "./script.schema.json",
|
||||
"schema_version": "2.1.0",
|
||||
"package": "json_script_example",
|
||||
"description": "Complete demonstration of JSON script specification",
|
||||
|
||||
"constants": [
|
||||
{
|
||||
"id": "max_value",
|
||||
@@ -14,7 +14,9 @@
|
||||
"summary": "Maximum allowed value for calculations",
|
||||
"description": "Used as an upper bound in validation and clamping operations",
|
||||
"since": "1.0.0",
|
||||
"see": ["clamp"]
|
||||
"see": [
|
||||
"clamp"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -46,7 +48,6 @@
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
"functions": [
|
||||
{
|
||||
"id": "all_expressions_demo",
|
||||
@@ -83,9 +84,16 @@
|
||||
"code": "const result = all_expressions(-3, 7);\n// result.bothPositive === false\n// result.max === 7"
|
||||
}
|
||||
],
|
||||
"see": ["all_statements", "all_operators"],
|
||||
"see": [
|
||||
"all_statements",
|
||||
"all_operators"
|
||||
],
|
||||
"since": "1.0.0",
|
||||
"tags": ["demo", "expressions", "examples"]
|
||||
"tags": [
|
||||
"demo",
|
||||
"expressions",
|
||||
"examples"
|
||||
]
|
||||
},
|
||||
"params": [
|
||||
{
|
||||
@@ -285,9 +293,17 @@
|
||||
"code": "const result = all_statements([]);\n// result.count === 0\n// result.average === 0"
|
||||
}
|
||||
],
|
||||
"see": ["all_expressions", "control_flow"],
|
||||
"see": [
|
||||
"all_expressions",
|
||||
"control_flow"
|
||||
],
|
||||
"since": "1.0.0",
|
||||
"tags": ["demo", "statements", "loops", "error-handling"]
|
||||
"tags": [
|
||||
"demo",
|
||||
"statements",
|
||||
"loops",
|
||||
"error-handling"
|
||||
]
|
||||
},
|
||||
"params": [
|
||||
{
|
||||
@@ -472,9 +488,17 @@
|
||||
"code": "const result = all_operators(10, 5);\n// result.arithmetic.add === 15\n// result.arithmetic.divide === 2\n// result.comparison.greaterThan === true"
|
||||
}
|
||||
],
|
||||
"see": ["all_expressions"],
|
||||
"see": [
|
||||
"all_expressions"
|
||||
],
|
||||
"since": "1.0.0",
|
||||
"tags": ["demo", "operators", "arithmetic", "comparison", "logical"]
|
||||
"tags": [
|
||||
"demo",
|
||||
"operators",
|
||||
"arithmetic",
|
||||
"comparison",
|
||||
"logical"
|
||||
]
|
||||
},
|
||||
"params": [
|
||||
{
|
||||
@@ -653,9 +677,15 @@
|
||||
"code": "control_flow(500) // Returns 'large'"
|
||||
}
|
||||
],
|
||||
"see": ["all_statements"],
|
||||
"see": [
|
||||
"all_statements"
|
||||
],
|
||||
"since": "1.0.0",
|
||||
"tags": ["demo", "control-flow", "classification"]
|
||||
"tags": [
|
||||
"demo",
|
||||
"control-flow",
|
||||
"classification"
|
||||
]
|
||||
},
|
||||
"params": [
|
||||
{
|
||||
@@ -763,9 +793,16 @@
|
||||
"code": "const result = data_structures();\n// result.numbers === [1, 2, 3, 4, 5]\n// result.person.name === 'John Doe'\n// result.config.server.port === 3000\n// result.extractedName === 'John Doe'"
|
||||
}
|
||||
],
|
||||
"see": ["all_expressions"],
|
||||
"see": [
|
||||
"all_expressions"
|
||||
],
|
||||
"since": "1.0.0",
|
||||
"tags": ["demo", "data-structures", "objects", "arrays"]
|
||||
"tags": [
|
||||
"demo",
|
||||
"data-structures",
|
||||
"objects",
|
||||
"arrays"
|
||||
]
|
||||
},
|
||||
"params": [],
|
||||
"returnType": "object",
|
||||
@@ -779,7 +816,13 @@
|
||||
"name": "numbers",
|
||||
"value": {
|
||||
"type": "array_literal",
|
||||
"elements": [1, 2, 3, 4, 5]
|
||||
"elements": [
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -819,7 +862,11 @@
|
||||
},
|
||||
"features": {
|
||||
"type": "array_literal",
|
||||
"elements": ["auth", "api", "dashboard"]
|
||||
"elements": [
|
||||
"auth",
|
||||
"api",
|
||||
"dashboard"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
128
packages/json_script_example/seed/types.schema.json
Normal file
128
packages/json_script_example/seed/types.schema.json
Normal file
@@ -0,0 +1,128 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"$id": "https://metabuilder.dev/schemas/json-script-types.schema.json",
|
||||
"title": "JSON Script Types",
|
||||
"description": "TypeScript-style type definitions for JSON scripts",
|
||||
"type": "object",
|
||||
"required": ["schema_version", "package", "types"],
|
||||
"properties": {
|
||||
"schema_version": {
|
||||
"type": "string",
|
||||
"description": "Schema version",
|
||||
"pattern": "^\\d+\\.\\d+\\.\\d+$"
|
||||
},
|
||||
"package": {
|
||||
"type": "string",
|
||||
"description": "Package identifier"
|
||||
},
|
||||
"description": {
|
||||
"type": "string",
|
||||
"description": "Type file description"
|
||||
},
|
||||
"types": {
|
||||
"type": "array",
|
||||
"description": "Type definitions",
|
||||
"items": {
|
||||
"$ref": "#/definitions/typeDefinition"
|
||||
}
|
||||
},
|
||||
"exports": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"types": {
|
||||
"type": "array",
|
||||
"items": { "type": "string" }
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"typeDefinition": {
|
||||
"type": "object",
|
||||
"required": ["id", "name", "type"],
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string",
|
||||
"description": "Unique identifier"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"description": "Type name (PascalCase)"
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"description": "Base type",
|
||||
"enum": ["object", "string", "number", "boolean", "array", "null", "any"]
|
||||
},
|
||||
"exported": {
|
||||
"type": "boolean",
|
||||
"description": "Whether type is exported"
|
||||
},
|
||||
"description": {
|
||||
"type": "string",
|
||||
"description": "Type description"
|
||||
},
|
||||
"docstring": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"summary": { "type": "string" },
|
||||
"description": { "type": "string" },
|
||||
"examples": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"title": { "type": "string" },
|
||||
"code": { "type": "string" }
|
||||
}
|
||||
}
|
||||
},
|
||||
"see": {
|
||||
"type": "array",
|
||||
"items": { "type": "string" }
|
||||
},
|
||||
"since": { "type": "string" }
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"type": "object",
|
||||
"description": "Object type properties",
|
||||
"additionalProperties": {
|
||||
"$ref": "#/definitions/propertyDefinition"
|
||||
}
|
||||
},
|
||||
"enum": {
|
||||
"type": "array",
|
||||
"description": "Enum values",
|
||||
"items": { "type": "string" }
|
||||
},
|
||||
"additionalProperties": {
|
||||
"type": "object",
|
||||
"description": "Schema for dynamic keys",
|
||||
"properties": {
|
||||
"type": { "type": "string" },
|
||||
"description": { "type": "string" }
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"propertyDefinition": {
|
||||
"type": "object",
|
||||
"required": ["type"],
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"description": "Property type"
|
||||
},
|
||||
"required": {
|
||||
"type": "boolean",
|
||||
"description": "Whether property is required"
|
||||
},
|
||||
"description": {
|
||||
"type": "string",
|
||||
"description": "Property description"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,15 @@
|
||||
{
|
||||
"$schema": "./script.schema.json",
|
||||
"schema_version": "2.1.0",
|
||||
"package": "json_script_example",
|
||||
"description": "Validation utility functions",
|
||||
|
||||
"exports": {
|
||||
"functions": ["isEmail", "isNotEmpty", "validateRange"]
|
||||
"functions": [
|
||||
"isEmail",
|
||||
"isNotEmpty",
|
||||
"validateRange"
|
||||
]
|
||||
},
|
||||
|
||||
"functions": [
|
||||
{
|
||||
"id": "is_email_fn",
|
||||
@@ -14,7 +17,10 @@
|
||||
"description": "Check if string is a valid email",
|
||||
"exported": true,
|
||||
"params": [
|
||||
{"name": "email", "type": "string"}
|
||||
{
|
||||
"name": "email",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"returnType": "boolean",
|
||||
"body": [
|
||||
@@ -30,7 +36,10 @@
|
||||
"left": {
|
||||
"type": "call_expression",
|
||||
"callee": "$ref:imports.string.indexOf",
|
||||
"args": ["$ref:params.email", "@"]
|
||||
"args": [
|
||||
"$ref:params.email",
|
||||
"@"
|
||||
]
|
||||
},
|
||||
"operator": ">",
|
||||
"right": 0
|
||||
@@ -44,13 +53,19 @@
|
||||
"left": {
|
||||
"type": "call_expression",
|
||||
"callee": "$ref:imports.string.lastIndexOf",
|
||||
"args": ["$ref:params.email", "."]
|
||||
"args": [
|
||||
"$ref:params.email",
|
||||
"."
|
||||
]
|
||||
},
|
||||
"operator": ">",
|
||||
"right": {
|
||||
"type": "call_expression",
|
||||
"callee": "$ref:imports.string.indexOf",
|
||||
"args": ["$ref:params.email", "@"]
|
||||
"args": [
|
||||
"$ref:params.email",
|
||||
"@"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -71,7 +86,10 @@
|
||||
"description": "Check if string is not empty after trimming",
|
||||
"exported": true,
|
||||
"params": [
|
||||
{"name": "str", "type": "string"}
|
||||
{
|
||||
"name": "str",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"returnType": "boolean",
|
||||
"body": [
|
||||
@@ -81,7 +99,9 @@
|
||||
"value": {
|
||||
"type": "call_expression",
|
||||
"callee": "$ref:imports.string.trim",
|
||||
"args": ["$ref:params.str"]
|
||||
"args": [
|
||||
"$ref:params.str"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -105,9 +125,18 @@
|
||||
"description": "Check if number is within range",
|
||||
"exported": true,
|
||||
"params": [
|
||||
{"name": "value", "type": "number"},
|
||||
{"name": "min", "type": "number"},
|
||||
{"name": "max", "type": "number"}
|
||||
{
|
||||
"name": "value",
|
||||
"type": "number"
|
||||
},
|
||||
{
|
||||
"name": "min",
|
||||
"type": "number"
|
||||
},
|
||||
{
|
||||
"name": "max",
|
||||
"type": "number"
|
||||
}
|
||||
],
|
||||
"returnType": "boolean",
|
||||
"body": [
|
||||
|
||||
Reference in New Issue
Block a user