@constela/core 0.16.0 → 0.16.1
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 +3 -44
- package/dist/index.js +2 -27
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -429,20 +429,7 @@ interface IfStep {
|
|
|
429
429
|
then: ActionStep[];
|
|
430
430
|
else?: ActionStep[];
|
|
431
431
|
}
|
|
432
|
-
|
|
433
|
-
* Generate step - generates DSL using AI at runtime
|
|
434
|
-
*/
|
|
435
|
-
interface GenerateStep {
|
|
436
|
-
do: 'generate';
|
|
437
|
-
provider: AiProviderType;
|
|
438
|
-
prompt: Expression;
|
|
439
|
-
output: AiOutputType;
|
|
440
|
-
result: string;
|
|
441
|
-
model?: string;
|
|
442
|
-
onSuccess?: ActionStep[];
|
|
443
|
-
onError?: ActionStep[];
|
|
444
|
-
}
|
|
445
|
-
type ActionStep = SetStep | UpdateStep | SetPathStep | FetchStep | StorageStep | ClipboardStep | NavigateStep | ImportStep | CallStep | SubscribeStep | DisposeStep | DomStep | SendStep | CloseStep | DelayStep | IntervalStep | ClearTimerStep | FocusStep | IfStep | GenerateStep;
|
|
432
|
+
type ActionStep = SetStep | UpdateStep | SetPathStep | FetchStep | StorageStep | ClipboardStep | NavigateStep | ImportStep | CallStep | SubscribeStep | DisposeStep | DomStep | SendStep | CloseStep | DelayStep | IntervalStep | ClearTimerStep | FocusStep | IfStep;
|
|
446
433
|
type LocalActionStep = SetStep | UpdateStep | SetPathStep;
|
|
447
434
|
/**
|
|
448
435
|
* Event handler options for special events like intersect
|
|
@@ -586,7 +573,7 @@ type DataTransform = (typeof DATA_TRANSFORMS)[number];
|
|
|
586
573
|
/**
|
|
587
574
|
* Data source types
|
|
588
575
|
*/
|
|
589
|
-
declare const DATA_SOURCE_TYPES: readonly ["glob", "file", "api"
|
|
576
|
+
declare const DATA_SOURCE_TYPES: readonly ["glob", "file", "api"];
|
|
590
577
|
type DataSourceType = (typeof DATA_SOURCE_TYPES)[number];
|
|
591
578
|
/**
|
|
592
579
|
* Reference to imported components for MDX transformation
|
|
@@ -606,26 +593,6 @@ interface DataSource {
|
|
|
606
593
|
transform?: DataTransform;
|
|
607
594
|
components?: string | ComponentsRef;
|
|
608
595
|
}
|
|
609
|
-
/**
|
|
610
|
-
* AI provider types for AI data source
|
|
611
|
-
*/
|
|
612
|
-
declare const AI_PROVIDER_TYPES: readonly ["anthropic", "openai"];
|
|
613
|
-
type AiProviderType = (typeof AI_PROVIDER_TYPES)[number];
|
|
614
|
-
/**
|
|
615
|
-
* AI output types for AI data source
|
|
616
|
-
*/
|
|
617
|
-
declare const AI_OUTPUT_TYPES: readonly ["component", "view"];
|
|
618
|
-
type AiOutputType = (typeof AI_OUTPUT_TYPES)[number];
|
|
619
|
-
/**
|
|
620
|
-
* AI data source for AI-generated content at build time
|
|
621
|
-
*/
|
|
622
|
-
interface AiDataSource {
|
|
623
|
-
type: 'ai';
|
|
624
|
-
provider: AiProviderType;
|
|
625
|
-
prompt: string;
|
|
626
|
-
output: AiOutputType;
|
|
627
|
-
model?: string;
|
|
628
|
-
}
|
|
629
596
|
/**
|
|
630
597
|
* Static paths definition for SSG
|
|
631
598
|
*/
|
|
@@ -799,14 +766,6 @@ declare function isValidityExpr(value: unknown): value is ValidityExpr;
|
|
|
799
766
|
* Checks if value is a data source
|
|
800
767
|
*/
|
|
801
768
|
declare function isDataSource(value: unknown): value is DataSource;
|
|
802
|
-
/**
|
|
803
|
-
* Checks if value is an AI data source
|
|
804
|
-
*/
|
|
805
|
-
declare function isAiDataSource(value: unknown): value is AiDataSource;
|
|
806
|
-
/**
|
|
807
|
-
* Checks if value is a GenerateStep
|
|
808
|
-
*/
|
|
809
|
-
declare function isGenerateStep(value: unknown): value is GenerateStep;
|
|
810
769
|
/**
|
|
811
770
|
* Checks if value is a static paths definition
|
|
812
771
|
*/
|
|
@@ -2144,4 +2103,4 @@ declare const astSchema: {
|
|
|
2144
2103
|
};
|
|
2145
2104
|
};
|
|
2146
2105
|
|
|
2147
|
-
export {
|
|
2106
|
+
export { type ActionDefinition, type ActionStep, type ArrayExpr, 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, isArrayExpr, 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
|
@@ -45,9 +45,7 @@ var VALIDITY_PROPERTIES = [
|
|
|
45
45
|
var NAVIGATE_TARGETS = ["_self", "_blank"];
|
|
46
46
|
var PARAM_TYPES = ["string", "number", "boolean", "json"];
|
|
47
47
|
var DATA_TRANSFORMS = ["mdx", "yaml", "csv"];
|
|
48
|
-
var DATA_SOURCE_TYPES = ["glob", "file", "api"
|
|
49
|
-
var AI_PROVIDER_TYPES = ["anthropic", "openai"];
|
|
50
|
-
var AI_OUTPUT_TYPES = ["component", "view"];
|
|
48
|
+
var DATA_SOURCE_TYPES = ["glob", "file", "api"];
|
|
51
49
|
|
|
52
50
|
// src/types/guards.ts
|
|
53
51
|
function isObject(value) {
|
|
@@ -192,28 +190,9 @@ function isDataSource(value) {
|
|
|
192
190
|
case "api":
|
|
193
191
|
if (typeof value["url"] !== "string") return false;
|
|
194
192
|
break;
|
|
195
|
-
case "ai":
|
|
196
|
-
return isAiDataSource(value);
|
|
197
193
|
}
|
|
198
194
|
return true;
|
|
199
195
|
}
|
|
200
|
-
function isAiDataSource(value) {
|
|
201
|
-
if (!isObject(value)) return false;
|
|
202
|
-
if (value["type"] !== "ai") return false;
|
|
203
|
-
if (!AI_PROVIDER_TYPES.includes(value["provider"])) return false;
|
|
204
|
-
if (typeof value["prompt"] !== "string") return false;
|
|
205
|
-
if (!AI_OUTPUT_TYPES.includes(value["output"])) return false;
|
|
206
|
-
return true;
|
|
207
|
-
}
|
|
208
|
-
function isGenerateStep(value) {
|
|
209
|
-
if (!isObject(value)) return false;
|
|
210
|
-
if (value["do"] !== "generate") return false;
|
|
211
|
-
if (!AI_PROVIDER_TYPES.includes(value["provider"])) return false;
|
|
212
|
-
if (!("prompt" in value)) return false;
|
|
213
|
-
if (!AI_OUTPUT_TYPES.includes(value["output"])) return false;
|
|
214
|
-
if (typeof value["result"] !== "string") return false;
|
|
215
|
-
return true;
|
|
216
|
-
}
|
|
217
196
|
function isStaticPathsDefinition(value) {
|
|
218
197
|
if (!isObject(value)) return false;
|
|
219
198
|
if (typeof value["source"] !== "string") return false;
|
|
@@ -414,7 +393,7 @@ function isFocusStep(value) {
|
|
|
414
393
|
return true;
|
|
415
394
|
}
|
|
416
395
|
function isActionStep(value) {
|
|
417
|
-
return isSetStep(value) || isUpdateStep(value) || isSetPathStep(value) || isFetchStep(value) || isStorageStep(value) || isClipboardStep(value) || isNavigateStep(value) || isImportStep(value) || isCallStep(value) || isSubscribeStep(value) || isDisposeStep(value) || isDelayStep(value) || isIntervalStep(value) || isClearTimerStep(value) || isFocusStep(value)
|
|
396
|
+
return isSetStep(value) || isUpdateStep(value) || isSetPathStep(value) || isFetchStep(value) || isStorageStep(value) || isClipboardStep(value) || isNavigateStep(value) || isImportStep(value) || isCallStep(value) || isSubscribeStep(value) || isDisposeStep(value) || isDelayStep(value) || isIntervalStep(value) || isClearTimerStep(value) || isFocusStep(value);
|
|
418
397
|
}
|
|
419
398
|
function isLocalActionStep(value) {
|
|
420
399
|
return isSetStep(value) || isUpdateStep(value) || isSetPathStep(value);
|
|
@@ -2268,8 +2247,6 @@ var astSchema = {
|
|
|
2268
2247
|
}
|
|
2269
2248
|
};
|
|
2270
2249
|
export {
|
|
2271
|
-
AI_OUTPUT_TYPES,
|
|
2272
|
-
AI_PROVIDER_TYPES,
|
|
2273
2250
|
BINARY_OPERATORS,
|
|
2274
2251
|
CLIPBOARD_OPERATIONS,
|
|
2275
2252
|
ConstelaError,
|
|
@@ -2326,7 +2303,6 @@ export {
|
|
|
2326
2303
|
createUnsupportedVersionError,
|
|
2327
2304
|
findSimilarNames,
|
|
2328
2305
|
isActionStep,
|
|
2329
|
-
isAiDataSource,
|
|
2330
2306
|
isArrayExpr,
|
|
2331
2307
|
isBinExpr,
|
|
2332
2308
|
isBooleanField,
|
|
@@ -2347,7 +2323,6 @@ export {
|
|
|
2347
2323
|
isExpression,
|
|
2348
2324
|
isFetchStep,
|
|
2349
2325
|
isFocusStep,
|
|
2350
|
-
isGenerateStep,
|
|
2351
2326
|
isGetExpr,
|
|
2352
2327
|
isIfNode,
|
|
2353
2328
|
isImportExpr,
|