@almadar/core 10.94.0 → 10.96.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,10 +1,10 @@
1
- import { O as OrbitalEntity, a as EntityPersistence, E as EntityField, F as FieldValue, g as EntityRow } from '../effect-D73ryQpY.js';
2
- import { a as OrbitalDefinition, O as OrbitalSchema } from '../schema-BRVT0vy-.js';
1
+ import { O as OrbitalEntity, a as EntityPersistence, E as EntityField, F as FieldValue, g as EntityRow } from '../effect-Bw8T4qh5.js';
2
+ import { a as OrbitalDefinition, O as OrbitalSchema } from '../schema-DPpES4qj.js';
3
3
  import { S as SExpr } from '../expression-WfTp2arD.js';
4
- export { E as EntityAccessPolicies, e as entityAccessPolicies, a as entityAccessPoliciesByStoreKey, b as entityAccessTable } from '../entityAccess-B0rGIlYJ.js';
4
+ export { E as EntityAccessPolicies, e as entityAccessPolicies, a as entityAccessPoliciesByStoreKey, b as entityAccessTable } from '../entityAccess-DfoXs9mc.js';
5
5
  import 'zod';
6
6
  import '../json-D8gmyK3l.js';
7
- import '../trait-ZaXauUvA.js';
7
+ import '../trait-DXXRrRMP.js';
8
8
 
9
9
  /**
10
10
  * Lightweight seeded pseudo-random generator for mock data.
@@ -262,8 +262,23 @@ declare function sampleImageUrl(entityName: string, fieldName: string, ctx: Samp
262
262
  * Is `field.default` a value the synthesizer must return verbatim?
263
263
  *
264
264
  * Exported so codegen and tests share the one predicate rather than restating it.
265
+ *
266
+ * `isRuntime` defaults to `false` (the persistent/multi-row behavior) —
267
+ * a `[runtime]` singleton's seeded row must equal its declared-defaults
268
+ * projection outright (gate 1: persistence must agree with the default
269
+ * layer in the `@entity` merge, or the machine boots into the wrong
270
+ * state), so ANY declared default is honored there, unconditionally.
271
+ * For a persistent, multi-row entity a number/boolean default is a
272
+ * NEW-RECORD default, not a claim about every existing row — same
273
+ * reasoning already applied below to a string default on a closed
274
+ * vocabulary (the row cycle wins over it). Honoring it verbatim made
275
+ * every mock-seeded counter/amount field (`hours = 0`, `debit = 0`, a
276
+ * runtime-only concern accidentally applied to every row of a real
277
+ * collection) read as literally, uniformly zero across the whole
278
+ * collection — confirmed 2026-09-17 across `LedgerEntry.debit/credit`,
279
+ * `ExecTimeEntry.hours/costRate`, `ExecCost.amount`.
265
280
  */
266
- declare function isDeclaredDefaultHonored(field: EntityField): boolean;
281
+ declare function isDeclaredDefaultHonored(field: EntityField, isRuntime?: boolean): boolean;
267
282
  /** Rows to synthesize. A `[runtime]` entity is a per-orbital singleton. */
268
283
  declare function sampleRowCount(entity: SampleEntity, requested: number): number;
269
284
  /**
@@ -566,6 +566,7 @@ var EntityFieldSchema = z.lazy(() => {
566
566
  intrinsic: z.boolean().optional(),
567
567
  description: z.string().optional(),
568
568
  synonyms: z.string().optional(),
569
+ mock: z.string().optional(),
569
570
  mergedFrom: z.string().optional()
570
571
  };
571
572
  function scalarVariant(t) {
@@ -923,10 +924,11 @@ function declaredValues(field) {
923
924
  const values = "values" in field ? field.values : void 0;
924
925
  return values && values.length > 0 ? values : void 0;
925
926
  }
926
- function isDeclaredDefaultHonored(field) {
927
+ function isDeclaredDefaultHonored(field, isRuntime = false) {
927
928
  const value = field.default;
928
929
  if (value === void 0 || value === null) return false;
929
- if (typeof value === "number" || typeof value === "boolean") return true;
930
+ if (isRuntime) return true;
931
+ if (typeof value === "number" || typeof value === "boolean") return false;
930
932
  if (Array.isArray(value)) return true;
931
933
  if (typeof value === "object") return true;
932
934
  if (typeof value !== "string") return false;
@@ -937,6 +939,13 @@ function isDeclaredDefaultHonored(field) {
937
939
  function sampleRowCount(entity, requested) {
938
940
  return entity.persistence === "runtime" ? 1 : requested;
939
941
  }
942
+ function mockFieldValue(declared, index) {
943
+ const candidates = declared.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
944
+ if (candidates.length > 1) {
945
+ return candidates[(index - 1) % candidates.length];
946
+ }
947
+ return `${declared.trim()}-${index}`;
948
+ }
940
949
  function sampleText(field, ctx) {
941
950
  const fieldName = field.name ?? "field";
942
951
  if (IMAGE_FIELD_NAMES.has(fieldName.toLowerCase())) {
@@ -1000,8 +1009,7 @@ function sampleFieldValue(field, ctx) {
1000
1009
  const honoredDefault = field.default !== void 0 && isFieldValue(field.default) ? field.default : void 0;
1001
1010
  if (field.intrinsic === true) return honoredDefault;
1002
1011
  const isRuntime = ctx.persistence === "runtime";
1003
- if (isRuntime && honoredDefault !== void 0) return honoredDefault;
1004
- if (!isRuntime && isDeclaredDefaultHonored(field) && honoredDefault !== void 0) {
1012
+ if (isDeclaredDefaultHonored(field, isRuntime) && honoredDefault !== void 0) {
1005
1013
  return honoredDefault;
1006
1014
  }
1007
1015
  if (!field.required && field.default === void 0 && field.type !== "relation" && omitsUndefaultedOptionalFields(ctx)) {
@@ -1012,6 +1020,10 @@ function sampleFieldValue(field, ctx) {
1012
1020
  const ordinal = isRuntime ? 1 : ctx.index;
1013
1021
  return values[(ordinal - 1) % values.length];
1014
1022
  }
1023
+ if (field.mock !== void 0) {
1024
+ const ordinal = isRuntime ? 1 : ctx.index;
1025
+ return mockFieldValue(field.mock, ordinal);
1026
+ }
1015
1027
  switch (field.type) {
1016
1028
  case "string":
1017
1029
  return sampleText(field, ctx);