@constela/core 0.16.1 → 0.16.2

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 CHANGED
@@ -429,7 +429,20 @@ interface IfStep {
429
429
  then: ActionStep[];
430
430
  else?: ActionStep[];
431
431
  }
432
- type ActionStep = SetStep | UpdateStep | SetPathStep | FetchStep | StorageStep | ClipboardStep | NavigateStep | ImportStep | CallStep | SubscribeStep | DisposeStep | DomStep | SendStep | CloseStep | DelayStep | IntervalStep | ClearTimerStep | FocusStep | IfStep;
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;
433
446
  type LocalActionStep = SetStep | UpdateStep | SetPathStep;
434
447
  /**
435
448
  * Event handler options for special events like intersect
@@ -573,7 +586,7 @@ type DataTransform = (typeof DATA_TRANSFORMS)[number];
573
586
  /**
574
587
  * Data source types
575
588
  */
576
- declare const DATA_SOURCE_TYPES: readonly ["glob", "file", "api"];
589
+ declare const DATA_SOURCE_TYPES: readonly ["glob", "file", "api", "ai"];
577
590
  type DataSourceType = (typeof DATA_SOURCE_TYPES)[number];
578
591
  /**
579
592
  * Reference to imported components for MDX transformation
@@ -593,6 +606,26 @@ interface DataSource {
593
606
  transform?: DataTransform;
594
607
  components?: string | ComponentsRef;
595
608
  }
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
+ }
596
629
  /**
597
630
  * Static paths definition for SSG
598
631
  */
@@ -766,6 +799,14 @@ declare function isValidityExpr(value: unknown): value is ValidityExpr;
766
799
  * Checks if value is a data source
767
800
  */
768
801
  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;
769
810
  /**
770
811
  * Checks if value is a static paths definition
771
812
  */
@@ -2103,4 +2144,4 @@ declare const astSchema: {
2103
2144
  };
2104
2145
  };
2105
2146
 
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 };
2147
+ export { AI_OUTPUT_TYPES, AI_PROVIDER_TYPES, type ActionDefinition, type ActionStep, type AiDataSource, type AiOutputType, type AiProviderType, 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 GenerateStep, 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, isAiDataSource, isArrayExpr, isBinExpr, isBooleanField, isCallStep, isClipboardStep, isCodeNode, isComponentNode, isConcatExpr, isCondExpr, isConstelaError, isCookieInitialExpr, isDataExpr, isDataSource, isDisposeStep, isEachNode, isElementNode, isEventHandler, isExpression, isFetchStep, isFocusStep, isGenerateStep, 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,7 +45,9 @@ 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"];
48
+ var DATA_SOURCE_TYPES = ["glob", "file", "api", "ai"];
49
+ var AI_PROVIDER_TYPES = ["anthropic", "openai"];
50
+ var AI_OUTPUT_TYPES = ["component", "view"];
49
51
 
50
52
  // src/types/guards.ts
51
53
  function isObject(value) {
@@ -190,9 +192,28 @@ function isDataSource(value) {
190
192
  case "api":
191
193
  if (typeof value["url"] !== "string") return false;
192
194
  break;
195
+ case "ai":
196
+ return isAiDataSource(value);
193
197
  }
194
198
  return true;
195
199
  }
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
+ }
196
217
  function isStaticPathsDefinition(value) {
197
218
  if (!isObject(value)) return false;
198
219
  if (typeof value["source"] !== "string") return false;
@@ -393,7 +414,7 @@ function isFocusStep(value) {
393
414
  return true;
394
415
  }
395
416
  function isActionStep(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);
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) || isGenerateStep(value);
397
418
  }
398
419
  function isLocalActionStep(value) {
399
420
  return isSetStep(value) || isUpdateStep(value) || isSetPathStep(value);
@@ -2247,6 +2268,8 @@ var astSchema = {
2247
2268
  }
2248
2269
  };
2249
2270
  export {
2271
+ AI_OUTPUT_TYPES,
2272
+ AI_PROVIDER_TYPES,
2250
2273
  BINARY_OPERATORS,
2251
2274
  CLIPBOARD_OPERATIONS,
2252
2275
  ConstelaError,
@@ -2303,6 +2326,7 @@ export {
2303
2326
  createUnsupportedVersionError,
2304
2327
  findSimilarNames,
2305
2328
  isActionStep,
2329
+ isAiDataSource,
2306
2330
  isArrayExpr,
2307
2331
  isBinExpr,
2308
2332
  isBooleanField,
@@ -2323,6 +2347,7 @@ export {
2323
2347
  isExpression,
2324
2348
  isFetchStep,
2325
2349
  isFocusStep,
2350
+ isGenerateStep,
2326
2351
  isGetExpr,
2327
2352
  isIfNode,
2328
2353
  isImportExpr,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constela/core",
3
- "version": "0.16.1",
3
+ "version": "0.16.2",
4
4
  "description": "Core types, schema, and validator for Constela UI framework",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",