@constela/core 0.12.3 → 0.14.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/dist/index.d.ts +33 -2
- package/dist/index.js +38 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -154,7 +154,25 @@ interface ValidityExpr {
|
|
|
154
154
|
ref: string;
|
|
155
155
|
property?: ValidityProperty;
|
|
156
156
|
}
|
|
157
|
-
|
|
157
|
+
/**
|
|
158
|
+
* Call expression - calls a method on a target
|
|
159
|
+
*/
|
|
160
|
+
interface CallExpr {
|
|
161
|
+
expr: 'call';
|
|
162
|
+
target: Expression;
|
|
163
|
+
method: string;
|
|
164
|
+
args?: Expression[];
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Lambda expression - anonymous function for array methods
|
|
168
|
+
*/
|
|
169
|
+
interface LambdaExpr {
|
|
170
|
+
expr: 'lambda';
|
|
171
|
+
param: string;
|
|
172
|
+
index?: string;
|
|
173
|
+
body: Expression;
|
|
174
|
+
}
|
|
175
|
+
type Expression = LitExpr | StateExpr | VarExpr | BinExpr | NotExpr | ParamExpr | CondExpr | GetExpr | RouteExpr | ImportExpr | DataExpr | RefExpr | IndexExpr | StyleExpr | ConcatExpr | ValidityExpr | CallExpr | LambdaExpr;
|
|
158
176
|
/**
|
|
159
177
|
* Cookie expression for state initial value
|
|
160
178
|
*/
|
|
@@ -575,6 +593,15 @@ interface StaticPathsDefinition {
|
|
|
575
593
|
source: string;
|
|
576
594
|
params: Record<string, Expression>;
|
|
577
595
|
}
|
|
596
|
+
/**
|
|
597
|
+
* JSON-LD structured data definition for SEO
|
|
598
|
+
*/
|
|
599
|
+
interface JsonLdDefinition {
|
|
600
|
+
/** Schema.org type (e.g., "Article", "WebPage", "Organization") */
|
|
601
|
+
type: string;
|
|
602
|
+
/** Properties to include in the JSON-LD object */
|
|
603
|
+
properties: Record<string, Expression>;
|
|
604
|
+
}
|
|
578
605
|
/**
|
|
579
606
|
* Route definition for a page
|
|
580
607
|
*/
|
|
@@ -585,6 +612,10 @@ interface RouteDefinition {
|
|
|
585
612
|
layoutParams?: Record<string, Expression>;
|
|
586
613
|
meta?: Record<string, Expression>;
|
|
587
614
|
getStaticPaths?: StaticPathsDefinition;
|
|
615
|
+
/** Canonical URL for SEO (supports expressions for dynamic routes) */
|
|
616
|
+
canonical?: Expression;
|
|
617
|
+
/** JSON-LD structured data for SEO */
|
|
618
|
+
jsonLd?: JsonLdDefinition;
|
|
588
619
|
}
|
|
589
620
|
/**
|
|
590
621
|
* Lifecycle hooks for component/page lifecycle events
|
|
@@ -2061,4 +2092,4 @@ declare const astSchema: {
|
|
|
2061
2092
|
};
|
|
2062
2093
|
};
|
|
2063
2094
|
|
|
2064
|
-
export { type ActionDefinition, type ActionStep, BINARY_OPERATORS, type BinExpr, type BinaryOperator, type BooleanField, CLIPBOARD_OPERATIONS, type CallStep, type ClearTimerStep, type ClipboardOperation, type ClipboardStep, type CloseStep, type CodeNode, type ComponentDef, type ComponentNode, type ComponentsRef, type CompoundVariant, type ConcatExpr, type CondExpr, type ConstelaAst, ConstelaError, type ConstelaProgram, type CookieInitialExpr, DATA_SOURCE_TYPES, DATA_TRANSFORMS, type DataExpr, type DataSource, type DataSourceType, type DataTransform, type DelayStep, type DisposeStep, type DomStep, type EachNode, type ElementNode, type ErrorCode, type ErrorOptions, type EventHandler, type EventHandlerOptions, type Expression, FOCUS_OPERATIONS, type FetchStep, type FocusOperation, type FocusStep, type GetExpr, HTTP_METHODS, type HttpMethod, type IfNode, type IfStep, type ImportExpr, type ImportStep, type IntervalStep, type LayoutProgram, type LifecycleHooks, type ListField, type LitExpr, type LocalActionDefinition, type LocalActionStep, type MarkdownNode, NAVIGATE_TARGETS, type NavigateStep, type NavigateTarget, type NotExpr, type NumberField, type ObjectField, PARAM_TYPES, type ParamDef, type ParamExpr, type ParamType, type PortalNode, type Program, type RefExpr, type RouteDefinition, type RouteExpr, STORAGE_OPERATIONS, STORAGE_TYPES, type SendStep, type SetPathStep, type SetStep, type SlotNode, type StateExpr, type StateField, type StaticPathsDefinition, type StorageOperation, type StorageStep, type StorageType, type StringField, type StyleExpr, type StylePreset, type SubscribeStep, type TextNode, UPDATE_OPERATIONS, type UpdateOperation, type UpdateStep, VALIDITY_PROPERTIES, type ValidationFailure, type ValidationResult, type ValidationSuccess, type ValidityExpr, type ValidityProperty, type VarExpr, type ViewNode, astSchema, createClipboardWriteMissingValueError, createComponentCycleError, createComponentNotFoundError, createComponentPropMissingError, createComponentPropTypeError, createCondElseRequiredError, createDataNotDefinedError, createDuplicateActionError, createDuplicateDefaultSlotError, createDuplicateSlotNameError, createImportsNotDefinedError, createInvalidClipboardOperationError, createInvalidDataSourceError, createInvalidNavigateTargetError, createInvalidSlotNameError, createInvalidStorageOperationError, createInvalidStorageTypeError, createLayoutMissingSlotError, createLayoutNotFoundError, createLocalActionInvalidStepError, createOperationInvalidForTypeError, createOperationMissingFieldError, createOperationUnknownError, createRouteNotDefinedError, createSchemaError, createSlotInLoopError, createStorageSetMissingValueError, createUndefinedActionError, createUndefinedDataError, createUndefinedDataSourceError, createUndefinedImportError, createUndefinedLocalStateError, createUndefinedParamError, createUndefinedRefError, createUndefinedRouteParamError, createUndefinedStateError, createUndefinedStyleError, createUndefinedVarError, createUndefinedVariantError, createUnsupportedVersionError, findSimilarNames, isActionStep, isBinExpr, isBooleanField, isCallStep, isClipboardStep, isCodeNode, isComponentNode, isConcatExpr, isCondExpr, isConstelaError, isCookieInitialExpr, isDataExpr, isDataSource, isDisposeStep, isEachNode, isElementNode, isEventHandler, isExpression, isFetchStep, isFocusStep, isGetExpr, isIfNode, isImportExpr, isImportStep, isLayoutProgram, isLifecycleHooks, isListField, isLitExpr, isLocalActionDefinition, isLocalActionStep, isMarkdownNode, isNamedSlotNode, isNavigateStep, isNotExpr, isNumberField, isObjectField, isParamExpr, isPortalNode, isRefExpr, isRouteDefinition, isRouteExpr, isSetPathStep, isSetStep, isSlotNode, isStateExpr, isStateField, isStaticPathsDefinition, isStorageStep, isStringField, isStyleExpr, isSubscribeStep, isTextNode, isUpdateStep, isValidityExpr, isVarExpr, isViewNode, validateAst };
|
|
2095
|
+
export { type ActionDefinition, type ActionStep, BINARY_OPERATORS, type BinExpr, type BinaryOperator, type BooleanField, CLIPBOARD_OPERATIONS, type CallExpr, type CallStep, type ClearTimerStep, type ClipboardOperation, type ClipboardStep, type CloseStep, type CodeNode, type ComponentDef, type ComponentNode, type ComponentsRef, type CompoundVariant, type ConcatExpr, type CondExpr, type ConstelaAst, ConstelaError, type ConstelaProgram, type CookieInitialExpr, DATA_SOURCE_TYPES, DATA_TRANSFORMS, type DataExpr, type DataSource, type DataSourceType, type DataTransform, type DelayStep, type DisposeStep, type DomStep, type EachNode, type ElementNode, type ErrorCode, type ErrorOptions, type EventHandler, type EventHandlerOptions, type Expression, FOCUS_OPERATIONS, type FetchStep, type FocusOperation, type FocusStep, type GetExpr, HTTP_METHODS, type HttpMethod, type IfNode, type IfStep, type ImportExpr, type ImportStep, type IndexExpr, type IntervalStep, type LambdaExpr, type LayoutProgram, type LifecycleHooks, type ListField, type LitExpr, type LocalActionDefinition, type LocalActionStep, type MarkdownNode, NAVIGATE_TARGETS, type NavigateStep, type NavigateTarget, type NotExpr, type NumberField, type ObjectField, PARAM_TYPES, type ParamDef, type ParamExpr, type ParamType, type PortalNode, type Program, type RefExpr, type RouteDefinition, type RouteExpr, STORAGE_OPERATIONS, STORAGE_TYPES, type SendStep, type SetPathStep, type SetStep, type SlotNode, type StateExpr, type StateField, type StaticPathsDefinition, type StorageOperation, type StorageStep, type StorageType, type StringField, type StyleExpr, type StylePreset, type SubscribeStep, type TextNode, UPDATE_OPERATIONS, type UpdateOperation, type UpdateStep, VALIDITY_PROPERTIES, type ValidationFailure, type ValidationResult, type ValidationSuccess, type ValidityExpr, type ValidityProperty, type VarExpr, type ViewNode, astSchema, createClipboardWriteMissingValueError, createComponentCycleError, createComponentNotFoundError, createComponentPropMissingError, createComponentPropTypeError, createCondElseRequiredError, createDataNotDefinedError, createDuplicateActionError, createDuplicateDefaultSlotError, createDuplicateSlotNameError, createImportsNotDefinedError, createInvalidClipboardOperationError, createInvalidDataSourceError, createInvalidNavigateTargetError, createInvalidSlotNameError, createInvalidStorageOperationError, createInvalidStorageTypeError, createLayoutMissingSlotError, createLayoutNotFoundError, createLocalActionInvalidStepError, createOperationInvalidForTypeError, createOperationMissingFieldError, createOperationUnknownError, createRouteNotDefinedError, createSchemaError, createSlotInLoopError, createStorageSetMissingValueError, createUndefinedActionError, createUndefinedDataError, createUndefinedDataSourceError, createUndefinedImportError, createUndefinedLocalStateError, createUndefinedParamError, createUndefinedRefError, createUndefinedRouteParamError, createUndefinedStateError, createUndefinedStyleError, createUndefinedVarError, createUndefinedVariantError, createUnsupportedVersionError, findSimilarNames, isActionStep, isBinExpr, isBooleanField, isCallStep, isClipboardStep, isCodeNode, isComponentNode, isConcatExpr, isCondExpr, isConstelaError, isCookieInitialExpr, isDataExpr, isDataSource, isDisposeStep, isEachNode, isElementNode, isEventHandler, isExpression, isFetchStep, isFocusStep, isGetExpr, isIfNode, isImportExpr, isImportStep, isLayoutProgram, isLifecycleHooks, isListField, isLitExpr, isLocalActionDefinition, isLocalActionStep, isMarkdownNode, isNamedSlotNode, isNavigateStep, isNotExpr, isNumberField, isObjectField, isParamExpr, isPortalNode, isRefExpr, isRouteDefinition, isRouteExpr, isSetPathStep, isSetStep, isSlotNode, isStateExpr, isStateField, isStaticPathsDefinition, isStorageStep, isStringField, isStyleExpr, isSubscribeStep, isTextNode, isUpdateStep, isValidityExpr, isVarExpr, isViewNode, validateAst };
|
package/dist/index.js
CHANGED
|
@@ -840,7 +840,7 @@ function isObject2(value) {
|
|
|
840
840
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
841
841
|
}
|
|
842
842
|
var VALID_VIEW_KINDS = ["element", "text", "if", "each", "component", "slot", "markdown", "code", "portal"];
|
|
843
|
-
var VALID_EXPR_TYPES = ["lit", "state", "var", "bin", "not", "param", "cond", "get", "style", "validity", "index"];
|
|
843
|
+
var VALID_EXPR_TYPES = ["lit", "state", "var", "bin", "not", "param", "cond", "get", "style", "validity", "index", "call", "lambda"];
|
|
844
844
|
var VALID_PARAM_TYPES = ["string", "number", "boolean", "json"];
|
|
845
845
|
var VALID_ACTION_TYPES = ["set", "update", "fetch", "delay", "interval", "clearTimer", "focus", "if"];
|
|
846
846
|
var VALID_STATE_TYPES = ["number", "string", "list", "boolean", "object"];
|
|
@@ -978,7 +978,7 @@ function validateExpression(expr, path) {
|
|
|
978
978
|
return { path: path + "/expr", message: "expr is required" };
|
|
979
979
|
}
|
|
980
980
|
if (!VALID_EXPR_TYPES.includes(exprType)) {
|
|
981
|
-
return { path: path + "/expr", message: "must be one of: lit, state, var, bin, not, param, cond, get, style, validity, index" };
|
|
981
|
+
return { path: path + "/expr", message: "must be one of: lit, state, var, bin, not, param, cond, get, style, validity, index, call, lambda" };
|
|
982
982
|
}
|
|
983
983
|
switch (exprType) {
|
|
984
984
|
case "lit":
|
|
@@ -1085,6 +1085,42 @@ function validateExpression(expr, path) {
|
|
|
1085
1085
|
if (keyError) return keyError;
|
|
1086
1086
|
}
|
|
1087
1087
|
break;
|
|
1088
|
+
case "call":
|
|
1089
|
+
if (!("target" in expr)) {
|
|
1090
|
+
return { path: path + "/target", message: "target is required" };
|
|
1091
|
+
}
|
|
1092
|
+
if (typeof expr["method"] !== "string") {
|
|
1093
|
+
return { path: path + "/method", message: "method is required" };
|
|
1094
|
+
}
|
|
1095
|
+
{
|
|
1096
|
+
const targetError = validateExpression(expr["target"], path + "/target");
|
|
1097
|
+
if (targetError) return targetError;
|
|
1098
|
+
if ("args" in expr && expr["args"] !== void 0) {
|
|
1099
|
+
if (!Array.isArray(expr["args"])) {
|
|
1100
|
+
return { path: path + "/args", message: "args must be an array" };
|
|
1101
|
+
}
|
|
1102
|
+
for (let i = 0; i < expr["args"].length; i++) {
|
|
1103
|
+
const argError = validateExpression(expr["args"][i], path + "/args/" + i);
|
|
1104
|
+
if (argError) return argError;
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
break;
|
|
1109
|
+
case "lambda":
|
|
1110
|
+
if (typeof expr["param"] !== "string") {
|
|
1111
|
+
return { path: path + "/param", message: "param is required" };
|
|
1112
|
+
}
|
|
1113
|
+
if ("index" in expr && typeof expr["index"] !== "string") {
|
|
1114
|
+
return { path: path + "/index", message: "index must be a string" };
|
|
1115
|
+
}
|
|
1116
|
+
if (!("body" in expr)) {
|
|
1117
|
+
return { path: path + "/body", message: "body is required" };
|
|
1118
|
+
}
|
|
1119
|
+
{
|
|
1120
|
+
const bodyError = validateExpression(expr["body"], path + "/body");
|
|
1121
|
+
if (bodyError) return bodyError;
|
|
1122
|
+
}
|
|
1123
|
+
break;
|
|
1088
1124
|
}
|
|
1089
1125
|
return null;
|
|
1090
1126
|
}
|