@almadar/runtime 4.4.3 → 4.6.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,4 +1,4 @@
1
- import { EventBus, createUnifiedLoader, preprocessSchema, StateMachineManager, createContextFromBindings, EffectExecutor } from './chunk-QKH3SGBA.js';
1
+ import { EventBus, createUnifiedLoader, preprocessSchema, StateMachineManager, createContextFromBindings, EffectExecutor } from './chunk-32BOI7LH.js';
2
2
  import './chunk-PZ5AY32C.js';
3
3
  import { Router } from 'express';
4
4
  import * as fs from 'fs';
@@ -229,42 +229,41 @@ var MockPersistenceAdapter = class {
229
229
  }
230
230
  }
231
231
  /**
232
- * Generate a string value based on field name heuristics.
232
+ * Generate a string value based on the field's declared schema metadata.
233
+ * Reads `values` (enum) first, then `format` (email/url/phone/uuid/date/
234
+ * datetime), then falls back to faker.lorem.words. No field-name heuristics
235
+ * — the schema is the source of truth. If a caller needs a real email, they
236
+ * declare `format: "email"`; if they need an enum, they declare `values: [...]`.
233
237
  */
234
- generateStringValue(entityName, field, index) {
235
- const name = field.name.toLowerCase();
238
+ generateStringValue(_entityName, field, _index) {
236
239
  if (field.values && field.values.length > 0) {
237
240
  return faker.helpers.arrayElement(field.values);
238
241
  }
239
- if (name.includes("email")) return faker.internet.email();
240
- if (name.includes("phone")) return faker.phone.number();
241
- if (name.includes("address")) return faker.location.streetAddress();
242
- if (name.includes("city")) return faker.location.city();
243
- if (name.includes("country")) return faker.location.country();
244
- if (name.includes("url") || name.includes("website")) return faker.internet.url();
245
- if (name.includes("avatar") || name.includes("image")) return faker.image.avatar();
246
- if (name.includes("color")) return faker.color.human();
247
- if (name.includes("uuid")) return faker.string.uuid();
248
- if (name.includes("description") || name.includes("bio")) return faker.lorem.paragraph();
249
- const entityLabel = this.capitalizeFirst(entityName);
250
- const fieldLabel = this.capitalizeFirst(field.name);
251
- return `${entityLabel} ${fieldLabel} ${index}`;
242
+ switch (field.format) {
243
+ case "email":
244
+ return faker.internet.email();
245
+ case "url":
246
+ return faker.internet.url();
247
+ case "phone":
248
+ return faker.phone.number();
249
+ case "uuid":
250
+ return faker.string.uuid();
251
+ case "date":
252
+ return faker.date.recent().toISOString().split("T")[0];
253
+ case "datetime":
254
+ return faker.date.recent().toISOString();
255
+ default:
256
+ return faker.lorem.words(2);
257
+ }
252
258
  }
253
259
  /**
254
- * Generate a date value based on field name heuristics.
260
+ * Generate a date value. Uses the field's `format` (date vs datetime) to
261
+ * decide ISO shape; otherwise returns a recent ISO-8601 datetime. No
262
+ * field-name heuristics.
255
263
  */
256
264
  generateDateValue(field) {
257
- const name = field.name.toLowerCase();
258
- let date;
259
- if (name.includes("created") || name.includes("start") || name.includes("birth")) {
260
- date = faker.date.past({ years: 2 });
261
- } else if (name.includes("updated") || name.includes("modified")) {
262
- date = faker.date.recent({ days: 30 });
263
- } else if (name.includes("deadline") || name.includes("due") || name.includes("end") || name.includes("expires")) {
264
- date = faker.date.future({ years: 1 });
265
- } else {
266
- date = faker.date.anytime();
267
- }
265
+ const date = faker.date.recent({ days: 30 });
266
+ if (field.format === "date") return date.toISOString().split("T")[0];
268
267
  return date.toISOString();
269
268
  }
270
269
  capitalizeFirst(str) {