@almadar/core 8.5.1 → 8.6.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/builders.d.ts +3 -3
- package/dist/builders.js +62 -50
- package/dist/builders.js.map +1 -1
- package/dist/{compose-behaviors-TSp2c_dn.d.ts → compose-behaviors-CzTKCtrh.d.ts} +1 -1
- package/dist/factory/index.d.ts +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +96 -59
- package/dist/index.js.map +1 -1
- package/dist/{schema-Dp98Xt5i.d.ts → schema--EDm7mx5.d.ts} +1 -1
- package/dist/{trait-BV1DyJ2A.d.ts → trait-D1kGh81D.d.ts} +55 -12
- package/dist/types/index.d.ts +4 -4
- package/dist/types/index.js +61 -49
- package/dist/types/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { d as Expression, S as SExpr } from './expression-BVRFm0sV.js';
|
|
2
|
-
import { bj as TraitConfig, bk as TraitConfigObject, aW as ServiceRef, y as Entity, B as EntityField, H as EntityPersistence, bx as TraitRef, R as EventPayloadField, n as ConfigFieldDeclaration, aS as ServiceDefinition, bg as Trait } from './trait-
|
|
2
|
+
import { bj as TraitConfig, bk as TraitConfigObject, aW as ServiceRef, y as Entity, B as EntityField, H as EntityPersistence, bx as TraitRef, R as EventPayloadField, n as ConfigFieldDeclaration, aS as ServiceDefinition, bg as Trait } from './trait-D1kGh81D.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -96,42 +96,85 @@ declare const RelationConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
96
96
|
type FieldFormat = 'email' | 'url' | 'phone' | 'date' | 'datetime' | 'uuid';
|
|
97
97
|
declare const FieldFormatSchema: z.ZodEnum<["email", "url", "phone", "date", "datetime", "uuid"]>;
|
|
98
98
|
/**
|
|
99
|
-
*
|
|
99
|
+
* Field-type tags that don't carry a type-dependent payload. The base
|
|
100
|
+
* `EntityField` shape applies as-is.
|
|
100
101
|
*/
|
|
101
|
-
|
|
102
|
+
type ScalarFieldType = 'string' | 'number' | 'boolean' | 'date' | 'timestamp' | 'datetime' | 'object' | 'trait' | 'slot' | 'pattern';
|
|
103
|
+
/** Fields shared across every variant. */
|
|
104
|
+
interface EntityFieldBase {
|
|
102
105
|
/**
|
|
103
106
|
* Field name (camelCase). Optional for nested item/property descriptors
|
|
104
107
|
* where the name is implied by the parent (`items`, `properties[k]`).
|
|
105
108
|
* Mirrors Rust's `FieldDefinition.name: Option<String>`.
|
|
106
109
|
*/
|
|
107
110
|
name?: string;
|
|
108
|
-
/** Data type */
|
|
109
|
-
type: FieldType;
|
|
110
111
|
/** Whether the field is required */
|
|
111
112
|
required?: boolean;
|
|
112
113
|
/** Default value */
|
|
113
114
|
default?: unknown;
|
|
114
|
-
/** Allowed values for enum types */
|
|
115
|
-
values?: string[];
|
|
116
|
-
/** @deprecated Use 'values' instead */
|
|
117
|
-
enum?: string[];
|
|
118
115
|
/** Validation format */
|
|
119
116
|
format?: FieldFormat;
|
|
120
117
|
/** Minimum value (for number) or length (for string) */
|
|
121
118
|
min?: number;
|
|
122
119
|
/** Maximum value or length */
|
|
123
120
|
max?: number;
|
|
124
|
-
/** Array item schema (for array type) */
|
|
125
|
-
items?: EntityField;
|
|
126
121
|
/** Object property schemas keyed by property name (for object type).
|
|
127
122
|
* Mirrors Rust's `FieldDefinition.properties: Option<HashMap<String,
|
|
128
123
|
* FieldDefinition>>`. Populated by the lolo lowerer when a field /
|
|
129
124
|
* config slot's type expression resolves to a struct shape
|
|
130
125
|
* (`TypeExpr::Object`), including named-type aliases like `[MetricSpec]`. */
|
|
131
126
|
properties?: Record<string, EntityField>;
|
|
132
|
-
/** Relation configuration (required when type is 'relation') */
|
|
133
|
-
relation?: RelationConfig;
|
|
134
127
|
}
|
|
128
|
+
/**
|
|
129
|
+
* Scalar / structural fields — no type-dependent payload required.
|
|
130
|
+
* `values?` is permitted as an OPTIONAL UI/validation hint (e.g. lolo's
|
|
131
|
+
* `'a' | 'b' | 'c'` string-union sugar lowers to `type: 'string', values:
|
|
132
|
+
* [...]`). Only `EnumEntityField` MANDATES values.
|
|
133
|
+
*/
|
|
134
|
+
interface ScalarEntityField extends EntityFieldBase {
|
|
135
|
+
type: ScalarFieldType;
|
|
136
|
+
/** Optional vocabulary hint for scalar fields (e.g. string unions
|
|
137
|
+
* authored as `'a'|'b'|'c'` in lolo). Not required at this variant. */
|
|
138
|
+
values?: string[];
|
|
139
|
+
}
|
|
140
|
+
/** `type: 'enum'` REQUIRES the closed vocabulary in `values`. */
|
|
141
|
+
interface EnumEntityField extends EntityFieldBase {
|
|
142
|
+
type: 'enum';
|
|
143
|
+
/** Closed string vocabulary the field accepts. */
|
|
144
|
+
values: string[];
|
|
145
|
+
}
|
|
146
|
+
/** `type: 'relation'` REQUIRES the relation target binding. */
|
|
147
|
+
interface RelationEntityField extends EntityFieldBase {
|
|
148
|
+
type: 'relation';
|
|
149
|
+
/** Relation target binding (entity + cardinality). */
|
|
150
|
+
relation: RelationConfig;
|
|
151
|
+
}
|
|
152
|
+
/** `type: 'array'` REQUIRES the element schema in `items`. */
|
|
153
|
+
interface ArrayEntityField extends EntityFieldBase {
|
|
154
|
+
type: 'array';
|
|
155
|
+
/** Element schema for the array. */
|
|
156
|
+
items: EntityField;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Entity field definition — discriminated union by `type`. Each variant
|
|
160
|
+
* statically enforces its dependent payload (`values` for enum,
|
|
161
|
+
* `relation` for relation, `items` for array) so TS / Zod / JSON Schema
|
|
162
|
+
* consumers all agree on the dependency, not just the Rust validator.
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* { name: 'status', type: 'enum', values: ['draft', 'published'] }
|
|
166
|
+
* { name: 'authorId', type: 'relation', relation: { entity: 'User', cardinality: 'one' } }
|
|
167
|
+
* { name: 'tags', type: 'array', items: { type: 'string' } }
|
|
168
|
+
*/
|
|
169
|
+
type EntityField = ScalarEntityField | EnumEntityField | RelationEntityField | ArrayEntityField;
|
|
170
|
+
/**
|
|
171
|
+
* Zod schema for `EntityField`. Preprocess normalizes:
|
|
172
|
+
* - legacy `type` aliases (text → string, int → number, etc.)
|
|
173
|
+
* - legacy `enum: string[]` alias → `values: string[]`
|
|
174
|
+
*
|
|
175
|
+
* Branches on `type` so TS narrows the parsed output to the matching
|
|
176
|
+
* discriminated-union variant.
|
|
177
|
+
*/
|
|
135
178
|
declare const EntityFieldSchema: z.ZodType<EntityField, z.ZodTypeDef, unknown>;
|
|
136
179
|
type EntityFieldInput = z.input<typeof EntityFieldSchema>;
|
|
137
180
|
/** Alias for EntityField - preferred name */
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { a3 as OrbitalSchema, T as Orbital, aa as Page, u as DomainContext } from '../schema
|
|
2
|
-
export { A as AGENT_DOMAIN_CATEGORIES, a as ALLOWED_CUSTOM_COMPONENTS, b as AgentDomainCategory, c as AgentDomainCategorySchema, d as AllowedCustomComponent, C as ComputedEventContract, e as ComputedEventContractSchema, f as ComputedEventListener, g as ComputedEventListenerSchema, h as CustomPatternDefinition, i as CustomPatternDefinitionInput, j as CustomPatternDefinitionSchema, k as CustomPatternMap, l as CustomPatternMapInput, m as CustomPatternMapSchema, D as DesignPreferences, n as DesignPreferencesInput, o as DesignPreferencesSchema, p as DesignTokens, q as DesignTokensInput, r as DesignTokensSchema, s as DomainCategory, t as DomainCategorySchema, v as DomainContextInput, w as DomainContextSchema, x as DomainVocabulary, y as DomainVocabularySchema, E as EntityCall, z as EntityCallSchema, B as EntityRef, F as EntityRefSchema, G as EntityRefStringSchema, H as EntitySemanticRole, I as EntitySemanticRoleSchema, J as EventListener, K as EventListenerSchema, L as EventSemanticRole, M as EventSemanticRoleSchema, N as EventSource, O as EventSourceSchema, P as GameSubCategory, Q as GameSubCategorySchema, R as NodeClassification, S as NodeClassificationSchema, U as OrbitalConfig, V as OrbitalConfigInput, W as OrbitalConfigSchema, X as OrbitalDefinition, Y as OrbitalDefinitionSchema, Z as OrbitalInput, _ as OrbitalPage, $ as OrbitalPageInput, a0 as OrbitalPageSchema, a1 as OrbitalPageStrictInput, a2 as OrbitalPageStrictSchema, a5 as OrbitalSchemaInput, a6 as OrbitalSchemaSchema, a7 as OrbitalSchemaWithTraits, a8 as OrbitalUnit, a9 as OrbitalUnitSchema, a4 as OrbitalZodSchema, ab as PageRef, ac as PageRefObject, ad as PageRefObjectSchema, ae as PageRefSchema, af as PageRefStringSchema, ag as PageSchema, ah as PageTraitRef, ai as PageTraitRefSchema, aj as RelatedLink, ak as RelatedLinkSchema, al as StateSemanticRole, am as StateSemanticRoleSchema, an as SuggestedGuard, ao as SuggestedGuardSchema, ap as ThemeDefinition, aq as ThemeDefinitionSchema, ar as ThemeRef, as as ThemeRefSchema, at as ThemeRefStringSchema, au as ThemeTokens, av as ThemeTokensSchema, aw as ThemeVariant, ax as ThemeVariantSchema, ay as UXHints, az as UXHintsSchema, aA as UseDeclaration, aB as UseDeclarationSchema, aC as UserPersona, aD as UserPersonaInput, aE as UserPersonaSchema, aF as ViewType, aG as ViewTypeSchema, aH as isEntityCall, aI as isEntityReference, aJ as isEntityReferenceAny, aK as isImportedTraitRef, aL as isOrbitalDefinition, aM as isPageReference, aN as isPageReferenceObject, aO as isPageReferenceString, aP as isThemeReference, aQ as parseEntityRef, aR as parseImportedTraitRef, aS as parseOrbitalSchema, aT as parsePageRef, aU as safeParseOrbitalSchema } from '../schema
|
|
3
|
-
import { aU as ServiceParams, bg as Trait, y as Entity, L as EntityRow, a3 as FieldValue, D as DeclaredTraitConfig, bj as TraitConfig } from '../trait-
|
|
4
|
-
export { A as AgentEffect, a as AnimationDef, b as AnimationDefInput, c as AnimationDefSchema, d as AssetMap, e as AssetMapInput, f as AssetMapSchema, g as AssetMapping, h as AssetMappingInput, i as AssetMappingSchema, j as AtomicEffect, C as CallServiceConfig, k as CallServiceEffect, l as CheckpointLoadEffect, m as CheckpointSaveEffect, n as ConfigFieldDeclaration, o as ConfigFieldDeclarationSchema, p as DeclaredTraitConfigSchema, q as DerefEffect, r as DespawnEffect, s as DoEffect, E as ENTITY_ROLES, t as Effect, u as EffectInput, v as EffectSchema, w as EmitConfig, x as EmitEffect, z as EntityData, B as EntityField, F as EntityFieldInput, G as EntityFieldSchema, H as EntityPersistence, I as EntityPersistenceSchema, J as EntityRole, K as EntityRoleSchema, M as EntitySchema, N as EvaluateConfig, O as EvaluateEffect, P as Event, Q as EventInput, R as EventPayloadField, S as EventPayloadFieldSchema, T as EventSchema, U as EventScope, V as EventScopeSchema, W as FetchEffect, X as FetchOptions, Y as FetchResult, Z as Field, _ as FieldFormat, $ as FieldFormatSchema, a0 as FieldSchema, a1 as FieldType, a2 as FieldTypeSchema, a4 as ForwardConfig, a5 as ForwardEffect, a6 as GAME_TYPES, a7 as GameType, a8 as GameTypeSchema, a9 as Guard, aa as GuardInput, ab as GuardSchema, ac as ListenSource, ad as ListenSourceSchema, ae as LogEffect, af as McpServiceDef, ag as McpServiceDefSchema, ah as NavigateEffect, ai as NnConfig, aj as NnLayer, ak as NotifyEffect, al as OrbitalEntity, am as OrbitalEntityInput, an as OrbitalEntitySchema, ao as OrbitalTraitRef, ap as OrbitalTraitRefSchema, aq as OsEffect, ar as PayloadField, as as PayloadFieldSchema, at as PersistData, au as PersistEffect, av as PersistEmitConfig, aw as PresentationType, ax as RefEffect, ay as RelationConfig, az as RelationConfigSchema, aA as RenderItemLambda, aB as RenderUIConfig, aC as RenderUIEffect, aD as RenderUINode, aE as RequiredField, aF as RequiredFieldSchema, aG as ResolvedAsset, aH as ResolvedAssetInput, aI as ResolvedAssetSchema, aJ as ResolvedPatternProps, aK as RestAuthConfig, aL as RestAuthConfigSchema, aM as RestServiceDef, aN as RestServiceDefSchema, aO as SERVICE_TYPES, aP as SemanticAssetRef, aQ as SemanticAssetRefInput, aR as SemanticAssetRefSchema, aS as ServiceDefinition, aT as ServiceDefinitionSchema, aV as ServiceParamsValue, aW as ServiceRef, aX as ServiceRefObject, aY as ServiceRefObjectSchema, aZ as ServiceRefSchema, a_ as ServiceRefStringSchema, a$ as ServiceType, b0 as ServiceTypeSchema, b1 as SetEffect, b2 as SocketEvents, b3 as SocketEventsSchema, b4 as SocketServiceDef, b5 as SocketServiceDefSchema, b6 as SpawnEffect, b7 as State, b8 as StateInput, b9 as StateMachine, ba as StateMachineInput, bb as StateMachineSchema, bc as StateSchema, bd as SwapEffect, be as TrainConfig, bf as TrainEffect, bh as TraitCategory, bi as TraitCategorySchema, bk as TraitConfigObject, bl as TraitConfigSchema, bm as TraitConfigValue, bn as TraitConfigValueSchema, bo as TraitDataEntity, bp as TraitDataEntitySchema, bq as TraitEntityField, br as TraitEntityFieldSchema, bs as TraitEventContract, bt as TraitEventContractSchema, bu as TraitEventListener, bv as TraitEventListenerSchema, bw as TraitInput, bx as TraitRef, by as TraitRefSchema, bz as TraitReference, bA as TraitReferenceInput, bB as TraitReferenceSchema, bC as TraitSchema, bD as TraitTick, bE as TraitTickSchema, bF as TraitUIBinding, bG as Transition, bH as TransitionInput, bI as TransitionSchema, bJ as TypedEffect, bK as UISlot, bL as UISlotSchema, bM as UI_SLOTS, bN as VISUAL_STYLES, bO as VisualStyle, bP as VisualStyleSchema, bQ as WatchEffect, bR as WatchOptions, bS as atomic, bT as callService, bU as createAssetKey, bV as deref, bW as deriveCollection, bX as despawn, bY as doEffects, bZ as emit, b_ as findService, b$ as getDefaultAnimationsForRole, c0 as getServiceNames, c1 as getTraitConfig, c2 as getTraitName, c3 as hasService, c4 as isCircuitEvent, c5 as isEffect, c6 as isInlineTrait, c7 as isMcpService, c8 as isRestService, c9 as isRuntimeEntity, ca as isSExprEffect, cb as isServiceReference, cc as isServiceReferenceObject, cd as isSingletonEntity, ce as isSocketService, cf as navigate, cg as normalizeTraitRef, ch as notify, ci as parseAssetKey, cj as parseServiceRef, ck as persist, cl as ref, cm as renderUI, cn as set, co as spawn, cp as swap, cq as validateAssetAnimations, cr as watch } from '../trait-
|
|
1
|
+
import { a3 as OrbitalSchema, T as Orbital, aa as Page, u as DomainContext } from '../schema--EDm7mx5.js';
|
|
2
|
+
export { A as AGENT_DOMAIN_CATEGORIES, a as ALLOWED_CUSTOM_COMPONENTS, b as AgentDomainCategory, c as AgentDomainCategorySchema, d as AllowedCustomComponent, C as ComputedEventContract, e as ComputedEventContractSchema, f as ComputedEventListener, g as ComputedEventListenerSchema, h as CustomPatternDefinition, i as CustomPatternDefinitionInput, j as CustomPatternDefinitionSchema, k as CustomPatternMap, l as CustomPatternMapInput, m as CustomPatternMapSchema, D as DesignPreferences, n as DesignPreferencesInput, o as DesignPreferencesSchema, p as DesignTokens, q as DesignTokensInput, r as DesignTokensSchema, s as DomainCategory, t as DomainCategorySchema, v as DomainContextInput, w as DomainContextSchema, x as DomainVocabulary, y as DomainVocabularySchema, E as EntityCall, z as EntityCallSchema, B as EntityRef, F as EntityRefSchema, G as EntityRefStringSchema, H as EntitySemanticRole, I as EntitySemanticRoleSchema, J as EventListener, K as EventListenerSchema, L as EventSemanticRole, M as EventSemanticRoleSchema, N as EventSource, O as EventSourceSchema, P as GameSubCategory, Q as GameSubCategorySchema, R as NodeClassification, S as NodeClassificationSchema, U as OrbitalConfig, V as OrbitalConfigInput, W as OrbitalConfigSchema, X as OrbitalDefinition, Y as OrbitalDefinitionSchema, Z as OrbitalInput, _ as OrbitalPage, $ as OrbitalPageInput, a0 as OrbitalPageSchema, a1 as OrbitalPageStrictInput, a2 as OrbitalPageStrictSchema, a5 as OrbitalSchemaInput, a6 as OrbitalSchemaSchema, a7 as OrbitalSchemaWithTraits, a8 as OrbitalUnit, a9 as OrbitalUnitSchema, a4 as OrbitalZodSchema, ab as PageRef, ac as PageRefObject, ad as PageRefObjectSchema, ae as PageRefSchema, af as PageRefStringSchema, ag as PageSchema, ah as PageTraitRef, ai as PageTraitRefSchema, aj as RelatedLink, ak as RelatedLinkSchema, al as StateSemanticRole, am as StateSemanticRoleSchema, an as SuggestedGuard, ao as SuggestedGuardSchema, ap as ThemeDefinition, aq as ThemeDefinitionSchema, ar as ThemeRef, as as ThemeRefSchema, at as ThemeRefStringSchema, au as ThemeTokens, av as ThemeTokensSchema, aw as ThemeVariant, ax as ThemeVariantSchema, ay as UXHints, az as UXHintsSchema, aA as UseDeclaration, aB as UseDeclarationSchema, aC as UserPersona, aD as UserPersonaInput, aE as UserPersonaSchema, aF as ViewType, aG as ViewTypeSchema, aH as isEntityCall, aI as isEntityReference, aJ as isEntityReferenceAny, aK as isImportedTraitRef, aL as isOrbitalDefinition, aM as isPageReference, aN as isPageReferenceObject, aO as isPageReferenceString, aP as isThemeReference, aQ as parseEntityRef, aR as parseImportedTraitRef, aS as parseOrbitalSchema, aT as parsePageRef, aU as safeParseOrbitalSchema } from '../schema--EDm7mx5.js';
|
|
3
|
+
import { aU as ServiceParams, bg as Trait, y as Entity, L as EntityRow, a3 as FieldValue, D as DeclaredTraitConfig, bj as TraitConfig } from '../trait-D1kGh81D.js';
|
|
4
|
+
export { A as AgentEffect, a as AnimationDef, b as AnimationDefInput, c as AnimationDefSchema, d as AssetMap, e as AssetMapInput, f as AssetMapSchema, g as AssetMapping, h as AssetMappingInput, i as AssetMappingSchema, j as AtomicEffect, C as CallServiceConfig, k as CallServiceEffect, l as CheckpointLoadEffect, m as CheckpointSaveEffect, n as ConfigFieldDeclaration, o as ConfigFieldDeclarationSchema, p as DeclaredTraitConfigSchema, q as DerefEffect, r as DespawnEffect, s as DoEffect, E as ENTITY_ROLES, t as Effect, u as EffectInput, v as EffectSchema, w as EmitConfig, x as EmitEffect, z as EntityData, B as EntityField, F as EntityFieldInput, G as EntityFieldSchema, H as EntityPersistence, I as EntityPersistenceSchema, J as EntityRole, K as EntityRoleSchema, M as EntitySchema, N as EvaluateConfig, O as EvaluateEffect, P as Event, Q as EventInput, R as EventPayloadField, S as EventPayloadFieldSchema, T as EventSchema, U as EventScope, V as EventScopeSchema, W as FetchEffect, X as FetchOptions, Y as FetchResult, Z as Field, _ as FieldFormat, $ as FieldFormatSchema, a0 as FieldSchema, a1 as FieldType, a2 as FieldTypeSchema, a4 as ForwardConfig, a5 as ForwardEffect, a6 as GAME_TYPES, a7 as GameType, a8 as GameTypeSchema, a9 as Guard, aa as GuardInput, ab as GuardSchema, ac as ListenSource, ad as ListenSourceSchema, ae as LogEffect, af as McpServiceDef, ag as McpServiceDefSchema, ah as NavigateEffect, ai as NnConfig, aj as NnLayer, ak as NotifyEffect, al as OrbitalEntity, am as OrbitalEntityInput, an as OrbitalEntitySchema, ao as OrbitalTraitRef, ap as OrbitalTraitRefSchema, aq as OsEffect, ar as PayloadField, as as PayloadFieldSchema, at as PersistData, au as PersistEffect, av as PersistEmitConfig, aw as PresentationType, ax as RefEffect, ay as RelationConfig, az as RelationConfigSchema, aA as RenderItemLambda, aB as RenderUIConfig, aC as RenderUIEffect, aD as RenderUINode, aE as RequiredField, aF as RequiredFieldSchema, aG as ResolvedAsset, aH as ResolvedAssetInput, aI as ResolvedAssetSchema, aJ as ResolvedPatternProps, aK as RestAuthConfig, aL as RestAuthConfigSchema, aM as RestServiceDef, aN as RestServiceDefSchema, aO as SERVICE_TYPES, aP as SemanticAssetRef, aQ as SemanticAssetRefInput, aR as SemanticAssetRefSchema, aS as ServiceDefinition, aT as ServiceDefinitionSchema, aV as ServiceParamsValue, aW as ServiceRef, aX as ServiceRefObject, aY as ServiceRefObjectSchema, aZ as ServiceRefSchema, a_ as ServiceRefStringSchema, a$ as ServiceType, b0 as ServiceTypeSchema, b1 as SetEffect, b2 as SocketEvents, b3 as SocketEventsSchema, b4 as SocketServiceDef, b5 as SocketServiceDefSchema, b6 as SpawnEffect, b7 as State, b8 as StateInput, b9 as StateMachine, ba as StateMachineInput, bb as StateMachineSchema, bc as StateSchema, bd as SwapEffect, be as TrainConfig, bf as TrainEffect, bh as TraitCategory, bi as TraitCategorySchema, bk as TraitConfigObject, bl as TraitConfigSchema, bm as TraitConfigValue, bn as TraitConfigValueSchema, bo as TraitDataEntity, bp as TraitDataEntitySchema, bq as TraitEntityField, br as TraitEntityFieldSchema, bs as TraitEventContract, bt as TraitEventContractSchema, bu as TraitEventListener, bv as TraitEventListenerSchema, bw as TraitInput, bx as TraitRef, by as TraitRefSchema, bz as TraitReference, bA as TraitReferenceInput, bB as TraitReferenceSchema, bC as TraitSchema, bD as TraitTick, bE as TraitTickSchema, bF as TraitUIBinding, bG as Transition, bH as TransitionInput, bI as TransitionSchema, bJ as TypedEffect, bK as UISlot, bL as UISlotSchema, bM as UI_SLOTS, bN as VISUAL_STYLES, bO as VisualStyle, bP as VisualStyleSchema, bQ as WatchEffect, bR as WatchOptions, bS as atomic, bT as callService, bU as createAssetKey, bV as deref, bW as deriveCollection, bX as despawn, bY as doEffects, bZ as emit, b_ as findService, b$ as getDefaultAnimationsForRole, c0 as getServiceNames, c1 as getTraitConfig, c2 as getTraitName, c3 as hasService, c4 as isCircuitEvent, c5 as isEffect, c6 as isInlineTrait, c7 as isMcpService, c8 as isRestService, c9 as isRuntimeEntity, ca as isSExprEffect, cb as isServiceReference, cc as isServiceReferenceObject, cd as isSingletonEntity, ce as isSocketService, cf as navigate, cg as normalizeTraitRef, ch as notify, ci as parseAssetKey, cj as parseServiceRef, ck as persist, cl as ref, cm as renderUI, cn as set, co as spawn, cp as swap, cq as validateAssetAnimations, cr as watch } from '../trait-D1kGh81D.js';
|
|
5
5
|
import { c as EventPayloadValue, b as EventPayload, L as LogMeta, S as SExpr } from '../expression-BVRFm0sV.js';
|
|
6
6
|
export { C as CORE_BINDINGS, a as CoreBinding, E as EvalContext, d as Expression, e as ExpressionInput, f as ExpressionSchema, P as ParsedBinding, g as SExprAtom, h as SExprAtomSchema, i as SExprInput, j as SExprSchema, k as collectBindings, l as getArgs, m as getOperator, n as isBinding, o as isSExpr, p as isSExprAtom, q as isSExprCall, r as isValidBinding, s as parseBinding, t as sexpr, w as walkSExpr } from '../expression-BVRFm0sV.js';
|
|
7
7
|
import { z } from 'zod';
|
package/dist/types/index.js
CHANGED
|
@@ -57,58 +57,70 @@ var FIELD_TYPE_ALIASES = {
|
|
|
57
57
|
float: "number",
|
|
58
58
|
ts: "timestamp"
|
|
59
59
|
};
|
|
60
|
-
var EntityFieldSchema = z.lazy(
|
|
61
|
-
|
|
60
|
+
var EntityFieldSchema = z.lazy(() => {
|
|
61
|
+
const baseFieldShape = {
|
|
62
|
+
name: z.string().min(1, "Field name is required").optional(),
|
|
63
|
+
required: z.boolean().optional(),
|
|
64
|
+
default: z.unknown().optional(),
|
|
65
|
+
format: FieldFormatSchema.optional(),
|
|
66
|
+
min: z.number().optional(),
|
|
67
|
+
max: z.number().optional(),
|
|
68
|
+
properties: z.record(EntityFieldSchema).optional()
|
|
69
|
+
};
|
|
70
|
+
function scalarVariant(t) {
|
|
71
|
+
return z.object({
|
|
72
|
+
...baseFieldShape,
|
|
73
|
+
type: z.literal(t),
|
|
74
|
+
values: z.array(z.string()).optional()
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
return z.preprocess(
|
|
62
78
|
(input) => {
|
|
63
|
-
if (input
|
|
64
|
-
|
|
65
|
-
const canonical = FIELD_TYPE_ALIASES[raw];
|
|
66
|
-
if (canonical !== void 0) {
|
|
67
|
-
return { ...input, type: canonical };
|
|
68
|
-
}
|
|
79
|
+
if (input === null || typeof input !== "object" || !("type" in input) || typeof input.type !== "string") {
|
|
80
|
+
return input;
|
|
69
81
|
}
|
|
70
|
-
|
|
82
|
+
const obj = input;
|
|
83
|
+
const next = { ...obj };
|
|
84
|
+
const aliased = FIELD_TYPE_ALIASES[obj.type];
|
|
85
|
+
if (aliased !== void 0) next["type"] = aliased;
|
|
86
|
+
if (next["enum"] !== void 0 && next["values"] === void 0) {
|
|
87
|
+
next["values"] = next["enum"];
|
|
88
|
+
}
|
|
89
|
+
delete next["enum"];
|
|
90
|
+
return next;
|
|
71
91
|
},
|
|
72
|
-
z.
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
//
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
(field) => {
|
|
105
|
-
if (field.type !== "array") return true;
|
|
106
|
-
return field.items !== void 0;
|
|
107
|
-
},
|
|
108
|
-
{ message: "Array field requires an `items` schema describing each element", path: ["items"] }
|
|
109
|
-
)
|
|
110
|
-
)
|
|
111
|
-
);
|
|
92
|
+
z.discriminatedUnion("type", [
|
|
93
|
+
scalarVariant("string"),
|
|
94
|
+
scalarVariant("number"),
|
|
95
|
+
scalarVariant("boolean"),
|
|
96
|
+
scalarVariant("date"),
|
|
97
|
+
scalarVariant("timestamp"),
|
|
98
|
+
scalarVariant("datetime"),
|
|
99
|
+
scalarVariant("object"),
|
|
100
|
+
scalarVariant("trait"),
|
|
101
|
+
scalarVariant("slot"),
|
|
102
|
+
scalarVariant("pattern"),
|
|
103
|
+
// Enum variant — REQUIRES non-empty values.
|
|
104
|
+
z.object({
|
|
105
|
+
...baseFieldShape,
|
|
106
|
+
type: z.literal("enum"),
|
|
107
|
+
values: z.array(z.string()).min(1, "Enum field requires a non-empty `values` array")
|
|
108
|
+
}),
|
|
109
|
+
// Relation variant — REQUIRES relation config.
|
|
110
|
+
z.object({
|
|
111
|
+
...baseFieldShape,
|
|
112
|
+
type: z.literal("relation"),
|
|
113
|
+
relation: RelationConfigSchema
|
|
114
|
+
}),
|
|
115
|
+
// Array variant — REQUIRES items schema.
|
|
116
|
+
z.object({
|
|
117
|
+
...baseFieldShape,
|
|
118
|
+
type: z.literal("array"),
|
|
119
|
+
items: EntityFieldSchema
|
|
120
|
+
})
|
|
121
|
+
])
|
|
122
|
+
);
|
|
123
|
+
});
|
|
112
124
|
var FieldSchema = EntityFieldSchema;
|
|
113
125
|
var ENTITY_ROLES = [
|
|
114
126
|
"player",
|