@almadar/core 4.4.2 → 4.5.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.
@@ -1,5 +1,5 @@
1
- import { T as TraitEventContract, E as EntityField, a as EntityPersistence, b as EntityRow, O as OrbitalDefinition, c as OrbitalSchema, d as Trait, e as Entity, P as Page } from './schema-B0Yin-RM.js';
2
- export { C as ComposeBehaviorsInput, a as ComposeBehaviorsResult, E as EventWiringEntry, L as LayoutStrategy, b as applyEventWiring, c as composeBehaviors, d as detectLayoutStrategy } from './compose-behaviors-Da0YDcli.js';
1
+ import { T as TraitEventContract, E as EntityField, a as EntityPersistence, b as EntityRow, O as OrbitalDefinition, c as OrbitalSchema, d as Trait, e as Entity, P as Page } from './schema-D4VBpRZI.js';
2
+ export { C as ComposeBehaviorsInput, a as ComposeBehaviorsResult, E as EventWiringEntry, L as LayoutStrategy, b as applyEventWiring, c as composeBehaviors, d as detectLayoutStrategy } from './compose-behaviors-BtjmpmIC.js';
3
3
  import 'zod';
4
4
  import '@almadar/patterns';
5
5
 
package/dist/builders.js CHANGED
@@ -46,34 +46,61 @@ var FieldFormatSchema = z.enum([
46
46
  "datetime",
47
47
  "uuid"
48
48
  ]);
49
+ var FIELD_TYPE_ALIASES = {
50
+ text: "string",
51
+ int: "number",
52
+ float: "number",
53
+ ts: "timestamp"
54
+ };
49
55
  var EntityFieldSchema = z.lazy(
50
- () => z.object({
51
- name: z.string().min(1, "Field name is required"),
52
- type: FieldTypeSchema,
53
- required: z.boolean().optional(),
54
- default: z.unknown().optional(),
55
- values: z.array(z.string()).optional(),
56
- enum: z.array(z.string()).optional(),
57
- format: FieldFormatSchema.optional(),
58
- min: z.number().optional(),
59
- max: z.number().optional(),
60
- items: EntityFieldSchema.optional(),
61
- relation: RelationConfigSchema.optional()
62
- }).refine(
63
- (field) => field.type !== "relation" || field.relation !== void 0,
64
- { message: 'Relation config is required when type is "relation"', path: ["relation"] }
65
- ).refine(
66
- // Enum fields must carry their allowed values. Without this refine,
67
- // the type was lying about what's valid — bare `type: 'enum'` without
68
- // `values` passed zod but failed `orb validate` downstream with
69
- // ORB_E_EMPTY_ENUM_VALUES, stalling the agent pipeline for 20 minutes.
70
- // `enum` is the legacy field-name alias; accept either.
71
- (field) => {
72
- if (field.type !== "enum") return true;
73
- const vals = field.values ?? field.enum;
74
- return Array.isArray(vals) && vals.length > 0;
56
+ () => z.preprocess(
57
+ (input) => {
58
+ if (input !== null && typeof input === "object" && "type" in input && typeof input.type === "string") {
59
+ const raw = input.type;
60
+ const canonical = FIELD_TYPE_ALIASES[raw];
61
+ if (canonical !== void 0) {
62
+ return { ...input, type: canonical };
63
+ }
64
+ }
65
+ return input;
75
66
  },
76
- { message: "Enum field requires a non-empty `values` array", path: ["values"] }
67
+ z.object({
68
+ name: z.string().min(1, "Field name is required"),
69
+ type: FieldTypeSchema,
70
+ required: z.boolean().optional(),
71
+ default: z.unknown().optional(),
72
+ values: z.array(z.string()).optional(),
73
+ enum: z.array(z.string()).optional(),
74
+ format: FieldFormatSchema.optional(),
75
+ min: z.number().optional(),
76
+ max: z.number().optional(),
77
+ items: EntityFieldSchema.optional(),
78
+ relation: RelationConfigSchema.optional()
79
+ }).refine(
80
+ (field) => field.type !== "relation" || field.relation !== void 0,
81
+ { message: 'Relation config is required when type is "relation"', path: ["relation"] }
82
+ ).refine(
83
+ // Enum fields must carry their allowed values. Without this refine,
84
+ // the type was lying about what's valid — bare `type: 'enum'` without
85
+ // `values` passed zod but failed `orb validate` downstream with
86
+ // ORB_E_EMPTY_ENUM_VALUES, stalling the agent pipeline for 20 minutes.
87
+ // `enum` is the legacy field-name alias; accept either.
88
+ (field) => {
89
+ if (field.type !== "enum") return true;
90
+ const vals = field.values ?? field.enum;
91
+ return Array.isArray(vals) && vals.length > 0;
92
+ },
93
+ { message: "Enum field requires a non-empty `values` array", path: ["values"] }
94
+ ).refine(
95
+ // Array fields must describe their element shape. Bare `type: 'array'`
96
+ // with no `items` forces downstream consumers (builders, UI renderers,
97
+ // persistence) to guess, so reject it at the schema boundary.
98
+ (field) => {
99
+ if (field.type !== "array") return true;
100
+ return field.items !== void 0;
101
+ },
102
+ { message: "Array field requires an `items` schema describing each element", path: ["items"] }
103
+ )
77
104
  )
78
105
  );
79
106
  var ENTITY_ROLES = [
@@ -370,6 +397,8 @@ var RequiredFieldSchema = z.object({
370
397
  });
371
398
  z.object({
372
399
  ref: z.string().min(1),
400
+ // Phase 1.2: optional registry path disambiguator, pairs with `ref`.
401
+ from: z.string().optional(),
373
402
  linkedEntity: z.string().optional(),
374
403
  name: z.string().optional(),
375
404
  events: z.record(
@@ -735,6 +764,8 @@ var PageRefStringSchema = z.string().regex(
735
764
  );
736
765
  var PageRefObjectSchema = z.object({
737
766
  ref: PageRefStringSchema,
767
+ // Phase 1.2: optional registry path disambiguator, pairs with `ref`.
768
+ from: z.string().optional(),
738
769
  path: z.string().startsWith("/").optional(),
739
770
  linkedEntity: z.string().optional(),
740
771
  traits: z.array(TraitRefSchema).optional()