@almadar/runtime 6.40.0 → 6.42.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,7 +1,7 @@
1
- import { createTickScheduler, EventBus, createUnifiedLoader, MockPersistenceAdapter, InMemoryPersistence, preprocessSchema, normalizeCallSiteConfigToValues, StateMachineManager, parseDurationString, createContextFromBindings, validateEventPayload, formatPayloadValidationError, collectDeclaredConfigDefaults, resolveCallSitePayloadCaptures, collectDeclaredEntityDefaults, EffectExecutor } from './chunk-QZTBGSYQ.js';
2
- export { InMemoryPersistence, collectDeclaredConfigDefaults } from './chunk-QZTBGSYQ.js';
1
+ import { createTickScheduler, EventBus, createUnifiedLoader, MockPersistenceAdapter, InMemoryPersistence, preprocessSchema, normalizeCallSiteConfigToValues, StateMachineManager, parseDurationString, createContextFromBindings, validateEventPayload, formatPayloadValidationError, collectDeclaredConfigDefaults, resolveCallSitePayloadCaptures, collectDeclaredEntityDefaults, EffectExecutor } from './chunk-USANWPGZ.js';
2
+ export { InMemoryPersistence, collectDeclaredConfigDefaults } from './chunk-USANWPGZ.js';
3
3
  import { isValidCronExpression } from './chunk-OU3ITB5S.js';
4
- import './chunk-OQJIK6PZ.js';
4
+ import './chunk-T4VDAB4C.js';
5
5
  import './chunk-SCRAHWOC.js';
6
6
  import './chunk-MLKGABMK.js';
7
7
  import { createLogger } from '@almadar/logger';
@@ -554,7 +554,12 @@ var OrbitalServerRuntime = class {
554
554
  const fields = entity.fields.filter(
555
555
  (f) => typeof f.name === "string" && f.name.length > 0
556
556
  );
557
- this.persistence.registerEntity({ name: entity.name, id: entity.id, fields });
557
+ this.persistence.registerEntity({
558
+ name: entity.name,
559
+ id: entity.id,
560
+ fields,
561
+ persistence: entity.persistence
562
+ });
558
563
  if (this.config.debug) {
559
564
  persistLog.debug("mock:seeded", { entity: entity.name, count: this.persistence.count(entity.name) });
560
565
  }
@@ -569,7 +574,12 @@ var OrbitalServerRuntime = class {
569
574
  const auxFields = auxEntity.fields.filter(
570
575
  (f) => typeof f.name === "string" && f.name.length > 0
571
576
  );
572
- this.persistence.registerEntity({ name: auxEntity.name, id: auxEntity.id, fields: auxFields });
577
+ this.persistence.registerEntity({
578
+ name: auxEntity.name,
579
+ id: auxEntity.id,
580
+ fields: auxFields,
581
+ persistence: auxEntity.persistence
582
+ });
573
583
  if (this.config.debug) {
574
584
  persistLog.debug("mock:seeded-auxiliary", {
575
585
  entity: auxEntity.name,
@@ -842,7 +852,12 @@ var OrbitalServerRuntime = class {
842
852
  const fields = entity.fields.filter(
843
853
  (f) => typeof f.name === "string" && f.name.length > 0
844
854
  );
845
- this.persistence.registerEntity({ name: entity.name, id: entity.id, fields });
855
+ this.persistence.registerEntity({
856
+ name: entity.name,
857
+ id: entity.id,
858
+ fields,
859
+ persistence: entity.persistence
860
+ });
846
861
  }
847
862
  }
848
863
  }
@@ -1,4 +1,5 @@
1
1
  import { isEntityCall } from '@almadar/core';
2
+ import { sampleRowCount, sampleFieldValue, sampleRow } from '@almadar/core/mock';
2
3
  import { createLogger, isLogLevelEnabled } from '@almadar/logger';
3
4
 
4
5
  // src/ui/contract-errors.ts
@@ -203,28 +204,13 @@ var perfStore = {
203
204
 
204
205
  // src/ui/prepareSchemaForPreview.ts
205
206
  function generateEntityRow(entity, idx) {
206
- const row = { id: String(idx) };
207
- for (const f of entity.fields) {
208
- if (f.name === void 0 || f.name === "id") continue;
209
- row[f.name] = generateFieldValue(entity.name, f, idx);
210
- }
211
- return row;
212
- }
213
- function generateFieldValue(entityName, field, idx) {
214
- if ("values" in field && field.values && field.values.length > 0) {
215
- return field.values[(idx - 1) % field.values.length];
216
- }
217
- const fieldName = field.name ?? "";
218
- switch (field.type) {
219
- case "string":
220
- return `${entityName} ${fieldName.charAt(0).toUpperCase() + fieldName.slice(1)} ${idx}`;
221
- case "number":
222
- return idx * 10;
223
- case "boolean":
224
- return idx % 2 === 0;
225
- default:
226
- return field.default ?? null;
227
- }
207
+ return {
208
+ ...sampleRow(
209
+ { name: entity.name ?? "Entity", persistence: entity.persistence, fields: entity.fields },
210
+ { index: idx, strategy: "index", persistence: entity.persistence }
211
+ ),
212
+ id: String(idx)
213
+ };
228
214
  }
229
215
  function buildMockData(schema) {
230
216
  const t = perfStart("build-mock-data");
@@ -239,11 +225,11 @@ function buildMockData(schema) {
239
225
  result[entityName] = entity.instances;
240
226
  continue;
241
227
  }
242
- const rows = Array.from(
243
- { length: 10 },
244
- (_, i) => generateEntityRow(entity, i + 1)
228
+ const count = sampleRowCount(
229
+ { name: entityName, persistence: entity.persistence, fields: entity.fields },
230
+ 10
245
231
  );
246
- result[entityName] = rows;
232
+ result[entityName] = Array.from({ length: count }, (_, i) => generateEntityRow(entity, i + 1));
247
233
  }
248
234
  for (const orbital of schema.orbitals) {
249
235
  for (const traitRef of orbital.traits ?? []) {
@@ -267,7 +253,13 @@ function buildMockData(schema) {
267
253
  for (const f of sourceEntity.fields) {
268
254
  if (f.name === void 0 || f.name === "id") continue;
269
255
  if (row[f.name] !== void 0) continue;
270
- row[f.name] = generateFieldValue(sourceName, f, i + 1);
256
+ const value = sampleFieldValue(f, {
257
+ entityName: sourceName,
258
+ index: i + 1,
259
+ strategy: "index",
260
+ persistence: sourceEntity.persistence
261
+ });
262
+ if (value !== void 0) row[f.name] = value;
271
263
  }
272
264
  });
273
265
  }
@@ -0,0 +1 @@
1
+ export { randomAnytimeDate, randomArrayElement, randomBoolean, randomColor, randomEmail, randomFloat, randomInt, randomPassword, randomPastDate, randomPhone, randomRecentDate, randomSentence, randomUrl, randomUuid, randomWords, seedRandom, shuffleArray } from '@almadar/core/mock';
@@ -1,5 +1,5 @@
1
1
  import { parseCron, cronMinuteKey, cronMatches } from './chunk-OU3ITB5S.js';
2
- import { seedRandom, randomArrayElement, randomInt, shuffleArray, randomPastDate, randomBoolean, randomRecentDate, randomUuid, randomPhone, randomUrl, randomEmail, randomWords } from './chunk-OQJIK6PZ.js';
2
+ import { seedRandom, randomArrayElement, randomInt, shuffleArray, randomPastDate } from './chunk-T4VDAB4C.js';
3
3
  import { collectTraitRefsFromValue, collectTraitRefsFromEffects } from './chunk-SCRAHWOC.js';
4
4
  import { createLogger, setNamespaceLevel } from '@almadar/logger';
5
5
  import { createMinimalContext, resolveBinding, evaluate, evaluateGuard, SExpressionEvaluator } from '@almadar/evaluator';
@@ -7,6 +7,7 @@ export { createMinimalContext } from '@almadar/evaluator';
7
7
  import { isKnownStdOperator } from '@almadar/std/registry';
8
8
  import { OrbitalSchemaSchema, isInlineTrait, isEntityCall, isEntityReference, parseEntityRef, parseImportedTraitRef, isPageReference, isPageReferenceString, isPageReferenceObject, parsePageRef, isReferenceConfigType, configRefEventKnob, normalizeCallSiteConfigToValues, resolveConfigRefEventName } from '@almadar/core';
9
9
  export { normalizeCallSiteConfigToValues } from '@almadar/core';
10
+ import { sampleRowCount, sampleRow } from '@almadar/core/mock';
10
11
 
11
12
  var log = createLogger("almadar:runtime:eventbus");
12
13
  var EventBus = class {
@@ -2320,12 +2321,9 @@ function collectDeclaredEntityDefaults(entity) {
2320
2321
  }
2321
2322
  var mockLog = createLogger("almadar:runtime:mock");
2322
2323
  var DEFAULT_MOCK_SEED = 42;
2323
- function picsumUrl(entityName, fieldName, width = 400, height = 400) {
2324
- const seed = `${entityName}-${fieldName}-${randomInt({ min: 0, max: 1e3 })}`;
2325
- return `https://picsum.photos/seed/${encodeURIComponent(seed)}/${width}/${height}`;
2326
- }
2327
2324
  var SEED_REFERENCE_TIMESTAMP = "2024-01-01T00:00:00.000Z";
2328
- var MockPersistenceAdapter = class _MockPersistenceAdapter {
2325
+ var MS_PER_DAY = 864e5;
2326
+ var MockPersistenceAdapter = class {
2329
2327
  stores = /* @__PURE__ */ new Map();
2330
2328
  schemas = /* @__PURE__ */ new Map();
2331
2329
  idCounters = /* @__PURE__ */ new Map();
@@ -2388,8 +2386,12 @@ var MockPersistenceAdapter = class _MockPersistenceAdapter {
2388
2386
  if (schema.seedData && schema.seedData.length > 0) {
2389
2387
  this.seedFromInstances(schema.name, schema.seedData);
2390
2388
  } else {
2391
- const count = seedCount ?? this.config.defaultSeedCount ?? 6;
2392
- this.seed(schema.name, schema.fields, count);
2389
+ const requested = seedCount ?? this.config.defaultSeedCount ?? 6;
2390
+ const count = sampleRowCount(
2391
+ { name: schema.name, persistence: schema.persistence, fields: schema.fields },
2392
+ requested
2393
+ );
2394
+ this.seed(schema.name, schema.fields, count, schema.persistence);
2393
2395
  }
2394
2396
  this.linkRelationFields();
2395
2397
  }
@@ -2460,7 +2462,7 @@ var MockPersistenceAdapter = class _MockPersistenceAdapter {
2460
2462
  /**
2461
2463
  * Seed an entity with mock data.
2462
2464
  */
2463
- seed(entityName, fields, count) {
2465
+ seed(entityName, fields, count, persistence) {
2464
2466
  const store = this.getStore(entityName);
2465
2467
  const normalized = entityName.toLowerCase();
2466
2468
  if (this.config.debug) {
@@ -2470,7 +2472,7 @@ var MockPersistenceAdapter = class _MockPersistenceAdapter {
2470
2472
  const ownerId = this.config.ownerId;
2471
2473
  const generated = [];
2472
2474
  for (let i = 0; i < count; i++) {
2473
- const item = this.generateMockItem(normalized, entityName, fields, i + 1);
2475
+ const item = this.generateMockItem(entityName, fields, i + 1, persistence);
2474
2476
  if (ownerId && ownerCols.length > 0 && i % 2 === 0) {
2475
2477
  for (const col of ownerCols) item[col] = ownerId;
2476
2478
  }
@@ -2483,170 +2485,24 @@ var MockPersistenceAdapter = class _MockPersistenceAdapter {
2483
2485
  mockLog.debug("mock:seed", () => ({ entityName, count, idsAndTimestamps: JSON.stringify(generated) }));
2484
2486
  }
2485
2487
  /**
2486
- * Generate a single mock item based on field schemas.
2488
+ * Generate a single mock item. Field values come from the canonical policy in
2489
+ * `@almadar/core/mock`; this method owns only the id and timestamp stamping.
2487
2490
  */
2488
- generateMockItem(normalizedName, entityName, fields, index) {
2491
+ generateMockItem(entityName, fields, index, persistence) {
2489
2492
  const id = this.nextId(entityName);
2490
- const item = {
2493
+ const createdAt = randomPastDate({ years: 1 });
2494
+ const updatedAt = new Date(
2495
+ Math.min(createdAt.getTime() + randomInt({ min: 0, max: 30 }) * MS_PER_DAY, Date.now())
2496
+ );
2497
+ return {
2498
+ ...sampleRow(
2499
+ { name: entityName, persistence, fields },
2500
+ { index, strategy: "seeded", persistence }
2501
+ ),
2491
2502
  id,
2492
- createdAt: randomPastDate({ years: 1 }).toISOString(),
2493
- updatedAt: SEED_REFERENCE_TIMESTAMP
2503
+ createdAt: createdAt.toISOString(),
2504
+ updatedAt: updatedAt.toISOString()
2494
2505
  };
2495
- for (const field of fields) {
2496
- if (!field.name) continue;
2497
- if (field.name === "id" || field.name === "createdAt" || field.name === "updatedAt") {
2498
- continue;
2499
- }
2500
- item[field.name] = this.generateFieldValue(entityName, field, index);
2501
- }
2502
- return item;
2503
- }
2504
- /** Max nesting depth for recursive array/object schemas (e.g. a Comment
2505
- * entity whose `replies: [Comment]` field references itself). Without
2506
- * this guard, generateArrayValue → generateObjectValue → generateArray…
2507
- * recurses until stack overflow on every recursive type. Three levels
2508
- * is enough to render a useful thread depth (parent → reply → sub-reply)
2509
- * in catalog/preview without blowing the fixture. */
2510
- static MAX_NESTED_DEPTH = 3;
2511
- /**
2512
- * Generate a mock value for a field based on its schema.
2513
- */
2514
- generateFieldValue(entityName, field, index, depth = 0) {
2515
- const fieldTypeLc = field.type.toLowerCase();
2516
- const values = "values" in field ? field.values : void 0;
2517
- mockLog.debug("field:generate", {
2518
- entityName,
2519
- fieldName: field.name,
2520
- fieldType: fieldTypeLc,
2521
- hasValues: !!values?.length,
2522
- valuesCount: values?.length ?? 0,
2523
- values: values?.length ? values.join(",") : null,
2524
- format: field.format ?? null,
2525
- hasDefault: field.default !== void 0
2526
- });
2527
- if (field.default !== void 0) {
2528
- return field.default;
2529
- }
2530
- switch (field.type) {
2531
- case "string":
2532
- return this.generateStringValue(entityName, field, index);
2533
- case "number":
2534
- return randomInt({ min: 0, max: 100 });
2535
- case "boolean":
2536
- return randomBoolean();
2537
- case "date":
2538
- case "timestamp":
2539
- case "datetime":
2540
- return this.generateDateValue(field);
2541
- case "enum":
2542
- if (field.values && field.values.length > 0) {
2543
- return randomArrayElement(field.values);
2544
- }
2545
- return null;
2546
- case "relation":
2547
- return field.relation?.cardinality === "one" ? "" : [];
2548
- case "array":
2549
- return this.generateArrayValue(entityName, field, index, depth);
2550
- case "object":
2551
- return this.generateObjectValue(entityName, field, index, depth);
2552
- default:
2553
- return this.generateStringValue(entityName, field, index);
2554
- }
2555
- }
2556
- /**
2557
- * Generate 3–5 elements for an array field. When `items` describes an
2558
- * object shape (the common case for `tiles: [KpiTile]`-style declarations),
2559
- * each element is recursively mock-generated against `items.properties`.
2560
- * When `items` describes a scalar, each element uses the scalar generator
2561
- * for that type. When `items` is missing (legacy `[object] = []` declarations
2562
- * with no element schema), falls back to an empty array — the historical
2563
- * behavior.
2564
- */
2565
- generateArrayValue(entityName, field, index, depth = 0) {
2566
- if (field.type !== "array" || !field.items) return [];
2567
- if (depth >= _MockPersistenceAdapter.MAX_NESTED_DEPTH) return [];
2568
- const count = randomInt({ min: 3, max: 5 });
2569
- const out = [];
2570
- const elementName = field.name ?? "item";
2571
- for (let i = 0; i < count; i++) {
2572
- const elementField = {
2573
- ...field.items,
2574
- name: `${elementName}[${i}]`
2575
- };
2576
- out.push(this.generateFieldValue(entityName, elementField, index * 10 + i, depth + 1));
2577
- }
2578
- return out;
2579
- }
2580
- /**
2581
- * Generate a single object value with each declared property populated
2582
- * by the seeded PRNG. Walks `properties` and recursively delegates to
2583
- * `generateFieldValue` per property so nested objects-of-arrays-of-objects
2584
- * compose correctly.
2585
- */
2586
- generateObjectValue(entityName, field, index, depth = 0) {
2587
- if (!field.properties) return null;
2588
- if (depth >= _MockPersistenceAdapter.MAX_NESTED_DEPTH) return null;
2589
- const out = {};
2590
- for (const [propName, propField] of Object.entries(field.properties)) {
2591
- const childField = { ...propField, name: propName };
2592
- out[propName] = this.generateFieldValue(entityName, childField, index, depth + 1);
2593
- }
2594
- return out;
2595
- }
2596
- /**
2597
- * Generate a string value based on the field's declared schema metadata.
2598
- * Reads `values` (enum) first, then `format` (email/url/phone/uuid/date/
2599
- * datetime), then falls back to randomWords. No field-name heuristics
2600
- * — the schema is the source of truth. If a caller needs a real email, they
2601
- * declare `format: "email"`; if they need an enum, they declare `values: [...]`.
2602
- */
2603
- generateStringValue(entityName, field, _index) {
2604
- const values = "values" in field ? field.values : void 0;
2605
- if (values && values.length > 0) {
2606
- return randomArrayElement(values);
2607
- }
2608
- const fieldName = field.name ?? "field";
2609
- switch (field.format) {
2610
- case "email":
2611
- return randomEmail();
2612
- case "url":
2613
- return randomUrl();
2614
- case "phone":
2615
- return randomPhone();
2616
- case "uuid":
2617
- return randomUuid();
2618
- case "date":
2619
- return randomRecentDate().toISOString().split("T")[0];
2620
- case "datetime":
2621
- return randomRecentDate().toISOString();
2622
- case "image":
2623
- case "avatar":
2624
- case "thumbnail":
2625
- return picsumUrl(entityName, fieldName);
2626
- }
2627
- const lname = fieldName.toLowerCase();
2628
- if (lname === "image" || lname === "imageurl" || lname === "image_url" || lname === "photo" || lname === "photourl" || lname === "photo_url" || lname === "avatar" || lname === "avatarurl" || lname === "avatar_url" || lname === "thumbnail" || lname === "thumbnailurl" || lname === "thumbnail_url" || lname === "picture" || lname === "pictureurl" || lname === "cover" || lname === "coverurl" || lname === "banner" || lname === "bannerurl") {
2629
- return picsumUrl(entityName, fieldName);
2630
- }
2631
- const value = randomWords(2);
2632
- mockLog.debug("field:fallback-lorem", () => ({
2633
- entityName,
2634
- fieldName: field.name,
2635
- hasValues: false,
2636
- format: field.format ?? null,
2637
- generated: value
2638
- }));
2639
- return value;
2640
- }
2641
- /**
2642
- * Generate a date value. Uses the field's `format` (date vs datetime) to
2643
- * decide ISO shape; otherwise returns a recent ISO-8601 datetime. No
2644
- * field-name heuristics.
2645
- */
2646
- generateDateValue(field) {
2647
- const date = randomRecentDate({ days: 30 });
2648
- if (field.format === "date") return date.toISOString().split("T")[0];
2649
- return date.toISOString();
2650
2506
  }
2651
2507
  capitalizeFirst(str) {
2652
2508
  return str.charAt(0).toUpperCase() + str.slice(1);
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ import { U as UnifiedLoaderOptions, S as SchemaLoader, I as ImportChainLike, L a
4
4
  export { E as EntitySharingMap, c as EventBus, d as EventNamespaceMap, e as InMemoryPersistence, O as OrbitalEventRequest, f as OrbitalEventResponse, g as OrbitalServerRuntimeConfig, h as PreprocessOptions, i as PreprocessResult, j as PreprocessedSchema, k as ProcessEventOptions, R as RegisteredOrbital, l as RuntimeOrbital, m as RuntimeOrbitalSchema, n as RuntimeTrait, o as StateMachineManager, p as collectDeclaredConfigDefaults, q as collectDeclaredEntityDefaults, r as createInitialTraitState, s as findInitialState, t as findTransition, u as getIsolatedCollectionName, v as getNamespacedEvent, w as isBrowser, x as isElectron, y as isNamespacedEvent, z as isNode, A as normalizeEventKey, B as parseNamespacedEvent, C as preprocessSchema, D as processEvent } from './OrbitalServerRuntime-C3TtYP6I.js';
5
5
  import { EvaluationContext, SExpressionEvaluator } from '@almadar/evaluator';
6
6
  export { EvaluationContext, createMinimalContext } from '@almadar/evaluator';
7
- import { TraitConfigObject, EventPayload, PatternConfig, EntityId, EntityField, EntityRow, ServiceParams, PayloadField, OrbitalDefinition, OrbitalSchema } from '@almadar/core';
7
+ import { TraitConfigObject, EventPayload, PatternConfig, EntityId, EntityField, EntityRow, EntityPersistence, ServiceParams, PayloadField, OrbitalDefinition, OrbitalSchema } from '@almadar/core';
8
8
  export { EntityField, normalizeCallSiteConfigToValues } from '@almadar/core';
9
9
  export { ServerBridgeConfig, ServerBridgeState } from './ServerBridge.js';
10
10
  export { OsHandlerContext, OsHandlerResult } from './createOsHandlers.js';
@@ -545,6 +545,11 @@ interface EntitySchema {
545
545
  fields: NamedEntityField[];
546
546
  /** Pre-authored instance data from the schema (used instead of generated mocks) */
547
547
  seedData?: EntityRow[];
548
+ /** A `[runtime]` entity is a per-orbital singleton, so it seeds ONE row whose
549
+ * values equal its declared defaults. Without this the persistence layer can
550
+ * disagree with the declared-default layer in the `@entity` merge and boot a
551
+ * machine into the wrong state. */
552
+ persistence?: EntityPersistence;
548
553
  }
549
554
  interface MockPersistenceConfig {
550
555
  /** Seed for deterministic generation */
@@ -615,53 +620,12 @@ declare class MockPersistenceAdapter implements PersistenceAdapter {
615
620
  /**
616
621
  * Seed an entity with mock data.
617
622
  */
618
- seed(entityName: string, fields: EntityField[], count: number): void;
623
+ seed(entityName: string, fields: EntityField[], count: number, persistence?: EntityPersistence): void;
619
624
  /**
620
- * Generate a single mock item based on field schemas.
625
+ * Generate a single mock item. Field values come from the canonical policy in
626
+ * `@almadar/core/mock`; this method owns only the id and timestamp stamping.
621
627
  */
622
628
  private generateMockItem;
623
- /** Max nesting depth for recursive array/object schemas (e.g. a Comment
624
- * entity whose `replies: [Comment]` field references itself). Without
625
- * this guard, generateArrayValue → generateObjectValue → generateArray…
626
- * recurses until stack overflow on every recursive type. Three levels
627
- * is enough to render a useful thread depth (parent → reply → sub-reply)
628
- * in catalog/preview without blowing the fixture. */
629
- private static MAX_NESTED_DEPTH;
630
- /**
631
- * Generate a mock value for a field based on its schema.
632
- */
633
- private generateFieldValue;
634
- /**
635
- * Generate 3–5 elements for an array field. When `items` describes an
636
- * object shape (the common case for `tiles: [KpiTile]`-style declarations),
637
- * each element is recursively mock-generated against `items.properties`.
638
- * When `items` describes a scalar, each element uses the scalar generator
639
- * for that type. When `items` is missing (legacy `[object] = []` declarations
640
- * with no element schema), falls back to an empty array — the historical
641
- * behavior.
642
- */
643
- private generateArrayValue;
644
- /**
645
- * Generate a single object value with each declared property populated
646
- * by the seeded PRNG. Walks `properties` and recursively delegates to
647
- * `generateFieldValue` per property so nested objects-of-arrays-of-objects
648
- * compose correctly.
649
- */
650
- private generateObjectValue;
651
- /**
652
- * Generate a string value based on the field's declared schema metadata.
653
- * Reads `values` (enum) first, then `format` (email/url/phone/uuid/date/
654
- * datetime), then falls back to randomWords. No field-name heuristics
655
- * — the schema is the source of truth. If a caller needs a real email, they
656
- * declare `format: "email"`; if they need an enum, they declare `values: [...]`.
657
- */
658
- private generateStringValue;
659
- /**
660
- * Generate a date value. Uses the field's `format` (date vs datetime) to
661
- * decide ISO shape; otherwise returns a recent ISO-8601 datetime. No
662
- * field-name heuristics.
663
- */
664
- private generateDateValue;
665
629
  private capitalizeFirst;
666
630
  create(entityType: string, data: EntityRow): Promise<{
667
631
  id: string;
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
- import { EffectExecutor, createContextFromBindings } from './chunk-QZTBGSYQ.js';
2
- export { CALLSITE_PAYLOAD_PREFIX, EffectExecutor, EventBus, HANDLER_MANIFEST, InMemoryPersistence, MockPersistenceAdapter, StateMachineManager, TickScheduler, buildEmitsFromTraits, collectDeclaredConfigDefaults, collectDeclaredEntityDefaults, containsBindings, createContextFromBindings, createInitialTraitState, createMinimalContext, createMockPersistence, createTestExecutor, createTickScheduler, createUnifiedLoader, extractBindings, findInitialState, findTransition, formatPayloadValidationError, getIsolatedCollectionName, getNamespacedEvent, interpolateProps, interpolateValue, isBrowser, isElectron, isNamespacedEvent, isNode, isValidDurationString, normalizeCallSiteConfigToValues, normalizeEventKey, parseDurationString, parseNamespacedEvent, preprocessSchema, processEvent, resolveCallSitePayloadCaptures, validateEventPayload, validatePayloadShapes } from './chunk-QZTBGSYQ.js';
1
+ import { EffectExecutor, createContextFromBindings } from './chunk-USANWPGZ.js';
2
+ export { CALLSITE_PAYLOAD_PREFIX, EffectExecutor, EventBus, HANDLER_MANIFEST, InMemoryPersistence, MockPersistenceAdapter, StateMachineManager, TickScheduler, buildEmitsFromTraits, collectDeclaredConfigDefaults, collectDeclaredEntityDefaults, containsBindings, createContextFromBindings, createInitialTraitState, createMinimalContext, createMockPersistence, createTestExecutor, createTickScheduler, createUnifiedLoader, extractBindings, findInitialState, findTransition, formatPayloadValidationError, getIsolatedCollectionName, getNamespacedEvent, interpolateProps, interpolateValue, isBrowser, isElectron, isNamespacedEvent, isNode, isValidDurationString, normalizeCallSiteConfigToValues, normalizeEventKey, parseDurationString, parseNamespacedEvent, preprocessSchema, processEvent, resolveCallSitePayloadCaptures, validateEventPayload, validatePayloadShapes } from './chunk-USANWPGZ.js';
3
3
  export { cronMatches, cronMinuteKey, isValidCronExpression, parseCron, parseCronField } from './chunk-OU3ITB5S.js';
4
- import './chunk-OQJIK6PZ.js';
5
- export { PERF_NAMESPACE, RendererContractViolationError, adjustSchemaForMockData, aggregateSlotContent, assertIsMultiSourceSlotManager, assertIsSlotManager, bindEventBus, bindTraitStateGetter, buildMockData, buildOrbitalsByTrait, clearPerf, createSlotSetter, ensureVerificationApi, getOrbitalVerification, perfEnd, perfStart, perfStore, perfTime, prepareSchemaForPreview, pushPerfEntry, validateSlotContent, wrapCallbackForEvent } from './chunk-O5VGKPTG.js';
4
+ import './chunk-T4VDAB4C.js';
5
+ export { PERF_NAMESPACE, RendererContractViolationError, adjustSchemaForMockData, aggregateSlotContent, assertIsMultiSourceSlotManager, assertIsSlotManager, bindEventBus, bindTraitStateGetter, buildMockData, buildOrbitalsByTrait, clearPerf, createSlotSetter, ensureVerificationApi, getOrbitalVerification, perfEnd, perfStart, perfStore, perfTime, prepareSchemaForPreview, pushPerfEntry, validateSlotContent, wrapCallbackForEvent } from './chunk-FOFLEZRJ.js';
6
6
  export { collectEmbeddedTraits, collectTraitRefsFromResolvedTrait } from './chunk-SCRAHWOC.js';
7
7
  import { __export } from './chunk-MLKGABMK.js';
8
8
  import { createLogger } from '@almadar/logger';
@@ -1,54 +1 @@
1
- /**
2
- * Lightweight seeded pseudo-random generator for mock data.
3
- *
4
- * Replaces @faker-js/faker in browser-facing code so the client bundle does
5
- * not pay the ~3.7 MB faker cost. The API surface is intentionally narrow:
6
- * only the helpers actually used by MockPersistenceAdapter.
7
- */
8
- /** Re-seed the generator. Same signature as `faker.seed()`. */
9
- declare function seedRandom(value: number | undefined): void;
10
- /** Integer in [min, max]. */
11
- declare function randomInt({ min, max }: {
12
- min: number;
13
- max: number;
14
- }): number;
15
- /** Float in [min, max] with fixed fraction digits. */
16
- declare function randomFloat({ min, max, fractionDigits, }: {
17
- min: number;
18
- max: number;
19
- fractionDigits?: number;
20
- }): number;
21
- /** True/false with 50% probability. */
22
- declare function randomBoolean(): boolean;
23
- /** Pick one element from an array. */
24
- declare function randomArrayElement<T>(array: ReadonlyArray<T>): T;
25
- /** Return a shallow-shuffled copy of the array (Fisher-Yates). */
26
- declare function shuffleArray<T>(array: ReadonlyArray<T>): T[];
27
- /** ISO-8601 date string roughly `years` in the past. */
28
- declare function randomPastDate({ years }?: {
29
- years?: number;
30
- }): Date;
31
- /** ISO-8601 date string within the last `days`. */
32
- declare function randomRecentDate({ days }?: {
33
- days?: number;
34
- }): Date;
35
- /** Any date in the last ~100 years. */
36
- declare function randomAnytimeDate(): Date;
37
- /** A few random words. */
38
- declare function randomWords(count: number): string;
39
- /** A short sentence. */
40
- declare function randomSentence(): string;
41
- /** UUID v4-like string (random, not strictly compliant). */
42
- declare function randomUuid(): string;
43
- /** Random hex color (#rrggbb). */
44
- declare function randomColor(): string;
45
- /** Random password of the given length. */
46
- declare function randomPassword(length?: number): string;
47
- /** Random email address. */
48
- declare function randomEmail(): string;
49
- /** Random URL. */
50
- declare function randomUrl(): string;
51
- /** Random phone number. */
52
- declare function randomPhone(): string;
53
-
54
- export { randomAnytimeDate, randomArrayElement, randomBoolean, randomColor, randomEmail, randomFloat, randomInt, randomPassword, randomPastDate, randomPhone, randomRecentDate, randomSentence, randomUrl, randomUuid, randomWords, seedRandom, shuffleArray };
1
+ export { randomAnytimeDate, randomArrayElement, randomBoolean, randomColor, randomEmail, randomFloat, randomInt, randomPassword, randomPastDate, randomPhone, randomRecentDate, randomSentence, randomUrl, randomUuid, randomWords, seedRandom, shuffleArray } from '@almadar/core/mock';
@@ -1,2 +1,2 @@
1
- export { randomAnytimeDate, randomArrayElement, randomBoolean, randomColor, randomEmail, randomFloat, randomInt, randomPassword, randomPastDate, randomPhone, randomRecentDate, randomSentence, randomUrl, randomUuid, randomWords, seedRandom, shuffleArray } from './chunk-OQJIK6PZ.js';
1
+ export { randomAnytimeDate, randomArrayElement, randomBoolean, randomColor, randomEmail, randomFloat, randomInt, randomPassword, randomPastDate, randomPhone, randomRecentDate, randomSentence, randomUrl, randomUuid, randomWords, seedRandom, shuffleArray } from './chunk-T4VDAB4C.js';
2
2
  import './chunk-MLKGABMK.js';
package/dist/ui/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export { PERF_NAMESPACE, RendererContractViolationError, adjustSchemaForMockData, aggregateSlotContent, assertIsMultiSourceSlotManager, assertIsSlotManager, bindEventBus, bindTraitStateGetter, buildMockData, buildOrbitalsByTrait, clearPerf, createSlotSetter, ensureVerificationApi, getOrbitalVerification, perfEnd, perfStart, perfStore, perfTime, prepareSchemaForPreview, pushPerfEntry, validateSlotContent, wrapCallbackForEvent } from '../chunk-O5VGKPTG.js';
1
+ export { PERF_NAMESPACE, RendererContractViolationError, adjustSchemaForMockData, aggregateSlotContent, assertIsMultiSourceSlotManager, assertIsSlotManager, bindEventBus, bindTraitStateGetter, buildMockData, buildOrbitalsByTrait, clearPerf, createSlotSetter, ensureVerificationApi, getOrbitalVerification, perfEnd, perfStart, perfStore, perfTime, prepareSchemaForPreview, pushPerfEntry, validateSlotContent, wrapCallbackForEvent } from '../chunk-FOFLEZRJ.js';
2
2
  export { collectEmbeddedTraits, collectTraitRefsFromResolvedTrait } from '../chunk-SCRAHWOC.js';
3
3
  import '../chunk-MLKGABMK.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@almadar/runtime",
3
- "version": "6.40.0",
3
+ "version": "6.42.0",
4
4
  "description": "Interpreted runtime for Almadar orbital applications (OrbitalServerRuntime)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -52,11 +52,11 @@
52
52
  "access": "public"
53
53
  },
54
54
  "dependencies": {
55
- "@almadar/core": "^10.37.0",
55
+ "@almadar/core": "^10.38.0",
56
56
  "@almadar/evaluator": "^2.37.0",
57
57
  "@almadar/logger": "^1.10.0",
58
- "@almadar/server": "^2.28.0",
59
- "@almadar/std": "^16.146.0"
58
+ "@almadar/server": "^2.29.0",
59
+ "@almadar/std": "^16.149.0"
60
60
  },
61
61
  "peerDependencies": {
62
62
  "express": "^5.0.0"
@@ -1,163 +0,0 @@
1
- // src/mockRandom.ts
2
- var seedState = 42;
3
- function seedRandom(value) {
4
- seedState = (value ?? 42) >>> 0;
5
- }
6
- function nextFloat() {
7
- seedState = seedState * 1664525 + 1013904223 >>> 0;
8
- return seedState / 4294967296;
9
- }
10
- function randomInt({ min, max }) {
11
- return Math.floor(nextFloat() * (max - min + 1)) + min;
12
- }
13
- function randomFloat({
14
- min,
15
- max,
16
- fractionDigits = 2
17
- }) {
18
- const value = nextFloat() * (max - min) + min;
19
- const factor = 10 ** fractionDigits;
20
- return Math.round(value * factor) / factor;
21
- }
22
- function randomBoolean() {
23
- return nextFloat() < 0.5;
24
- }
25
- function randomArrayElement(array) {
26
- return array[randomInt({ min: 0, max: array.length - 1 })];
27
- }
28
- function shuffleArray(array) {
29
- const copy = array.slice();
30
- for (let i = copy.length - 1; i > 0; i--) {
31
- const j = randomInt({ min: 0, max: i });
32
- const tmp = copy[i];
33
- copy[i] = copy[j];
34
- copy[j] = tmp;
35
- }
36
- return copy;
37
- }
38
- function randomPastDate({ years = 1 } = {}) {
39
- const now = Date.now();
40
- const maxAge = years * 365 * 24 * 60 * 60 * 1e3;
41
- const age = Math.floor(nextFloat() * maxAge);
42
- return new Date(now - age);
43
- }
44
- function randomRecentDate({ days = 30 } = {}) {
45
- const now = Date.now();
46
- const maxAge = days * 24 * 60 * 60 * 1e3;
47
- const age = Math.floor(nextFloat() * maxAge);
48
- return new Date(now - age);
49
- }
50
- function randomAnytimeDate() {
51
- const now = Date.now();
52
- const maxAge = 100 * 365 * 24 * 60 * 60 * 1e3;
53
- const age = Math.floor(nextFloat() * maxAge);
54
- return new Date(now - age);
55
- }
56
- var LOREM_WORDS = [
57
- "lorem",
58
- "ipsum",
59
- "dolor",
60
- "sit",
61
- "amet",
62
- "consectetur",
63
- "adipiscing",
64
- "elit",
65
- "sed",
66
- "do",
67
- "eiusmod",
68
- "tempor",
69
- "incididunt",
70
- "ut",
71
- "labore",
72
- "et",
73
- "dolore",
74
- "magna",
75
- "aliqua",
76
- "enim",
77
- "ad",
78
- "minim",
79
- "veniam",
80
- "quis",
81
- "nostrud",
82
- "exercitation",
83
- "ullamco",
84
- "laboris",
85
- "nisi",
86
- "aliquip",
87
- "ex",
88
- "ea",
89
- "commodo",
90
- "consequat",
91
- "duis",
92
- "aute",
93
- "irure",
94
- "in",
95
- "reprehenderit",
96
- "voluptate",
97
- "velit",
98
- "esse",
99
- "cillum",
100
- "fugiat",
101
- "nulla",
102
- "pariatur",
103
- "excepteur",
104
- "sint",
105
- "occaecat",
106
- "cupidatat",
107
- "non",
108
- "proident",
109
- "sunt",
110
- "culpa",
111
- "qui",
112
- "officia",
113
- "deserunt",
114
- "mollit",
115
- "anim",
116
- "id",
117
- "est",
118
- "laborum"
119
- ];
120
- function randomWords(count) {
121
- const words = [];
122
- for (let i = 0; i < count; i++) {
123
- words.push(randomArrayElement(LOREM_WORDS));
124
- }
125
- return words.join(" ");
126
- }
127
- function randomSentence() {
128
- const words = randomWords(randomInt({ min: 4, max: 8 }));
129
- return words.charAt(0).toUpperCase() + words.slice(1) + ".";
130
- }
131
- function randomUuid() {
132
- const hex = () => randomInt({ min: 0, max: 15 }).toString(16);
133
- return `${hex()}${hex()}${hex()}${hex()}${hex()}${hex()}${hex()}${hex()}-${hex()}${hex()}${hex()}${hex()}-4${hex()}${hex()}${hex()}-${hex()}${hex()}${hex()}${hex()}-${hex()}${hex()}${hex()}${hex()}${hex()}${hex()}${hex()}${hex()}${hex()}${hex()}${hex()}${hex()}`;
134
- }
135
- function randomColor() {
136
- const channel = () => randomInt({ min: 0, max: 255 }).toString(16).padStart(2, "0");
137
- return `#${channel()}${channel()}${channel()}`;
138
- }
139
- var PASSWORD_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*";
140
- function randomPassword(length = 12) {
141
- let password = "";
142
- for (let i = 0; i < length; i++) {
143
- password += randomArrayElement(PASSWORD_CHARS.split(""));
144
- }
145
- return password;
146
- }
147
- function randomEmail() {
148
- const user = randomWords(1).toLowerCase().replace(/\s+/g, ".");
149
- const domain = randomWords(1).toLowerCase().replace(/\s+/g, "");
150
- return `${user}@${domain}.com`;
151
- }
152
- function randomUrl() {
153
- const slug = randomWords(2).toLowerCase().replace(/\s+/g, "-");
154
- return `https://example.com/${slug}`;
155
- }
156
- function randomPhone() {
157
- const area = randomInt({ min: 200, max: 999 });
158
- const prefix = randomInt({ min: 200, max: 999 });
159
- const line = randomInt({ min: 0, max: 9999 }).toString().padStart(4, "0");
160
- return `+1 (${area}) ${prefix}-${line}`;
161
- }
162
-
163
- export { randomAnytimeDate, randomArrayElement, randomBoolean, randomColor, randomEmail, randomFloat, randomInt, randomPassword, randomPastDate, randomPhone, randomRecentDate, randomSentence, randomUrl, randomUuid, randomWords, seedRandom, shuffleArray };