@almadar/runtime 6.6.0 → 6.8.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
|
-
export { InMemoryPersistence, OrbitalServerRuntime, collectDeclaredConfigDefaults, createOrbitalServerRuntime } from './chunk-
|
|
1
|
+
export { InMemoryPersistence, OrbitalServerRuntime, collectDeclaredConfigDefaults, createOrbitalServerRuntime } from './chunk-WOXI5KCA.js';
|
|
2
2
|
import './chunk-PZ5AY32C.js';
|
|
3
3
|
//# sourceMappingURL=OrbitalServerRuntime.js.map
|
|
4
4
|
//# sourceMappingURL=OrbitalServerRuntime.js.map
|
|
@@ -218,10 +218,10 @@ function interpolateString(value, ctx) {
|
|
|
218
218
|
return value;
|
|
219
219
|
}
|
|
220
220
|
function isPureBinding(value) {
|
|
221
|
-
return /^@[\w]+(?:\.[\w]+)*$/.test(value);
|
|
221
|
+
return /^@[\w]+(?:\[\d+\])*(?:\.[\w]+(?:\[\d+\])*)*$/.test(value);
|
|
222
222
|
}
|
|
223
223
|
function interpolateEmbeddedBindings(value, ctx) {
|
|
224
|
-
return value.replace(/@[\w]+(?:\.[\w]+)*/g, (match) => {
|
|
224
|
+
return value.replace(/@[\w]+(?:\[\d+\])*(?:\.[\w]+(?:\[\d+\])*)*/g, (match) => {
|
|
225
225
|
if (isClientOnlyBinding(match)) {
|
|
226
226
|
return match;
|
|
227
227
|
}
|
|
@@ -1861,13 +1861,50 @@ var MockPersistenceAdapter = class {
|
|
|
1861
1861
|
return null;
|
|
1862
1862
|
// Relations need special handling
|
|
1863
1863
|
case "array":
|
|
1864
|
-
return
|
|
1864
|
+
return this.generateArrayValue(entityName, field, index);
|
|
1865
1865
|
case "object":
|
|
1866
|
-
return
|
|
1866
|
+
return this.generateObjectValue(entityName, field, index);
|
|
1867
1867
|
default:
|
|
1868
1868
|
return this.generateStringValue(entityName, field, index);
|
|
1869
1869
|
}
|
|
1870
1870
|
}
|
|
1871
|
+
/**
|
|
1872
|
+
* Generate 3–5 elements for an array field. When `items` describes an
|
|
1873
|
+
* object shape (the common case for `tiles: [KpiTile]`-style declarations),
|
|
1874
|
+
* each element is recursively mock-generated against `items.properties`.
|
|
1875
|
+
* When `items` describes a scalar, each element uses the scalar generator
|
|
1876
|
+
* for that type. When `items` is missing (legacy `[object] = []` declarations
|
|
1877
|
+
* with no element schema), falls back to an empty array — the historical
|
|
1878
|
+
* behavior.
|
|
1879
|
+
*/
|
|
1880
|
+
generateArrayValue(entityName, field, index) {
|
|
1881
|
+
if (!field.items) return [];
|
|
1882
|
+
const count = faker.number.int({ min: 3, max: 5 });
|
|
1883
|
+
const out = [];
|
|
1884
|
+
for (let i = 0; i < count; i++) {
|
|
1885
|
+
const elementField = {
|
|
1886
|
+
...field.items,
|
|
1887
|
+
name: `${field.name}[${i}]`
|
|
1888
|
+
};
|
|
1889
|
+
out.push(this.generateFieldValue(entityName, elementField, index * 10 + i));
|
|
1890
|
+
}
|
|
1891
|
+
return out;
|
|
1892
|
+
}
|
|
1893
|
+
/**
|
|
1894
|
+
* Generate a single object value with each declared property populated
|
|
1895
|
+
* by faker. Walks `properties` and recursively delegates to
|
|
1896
|
+
* `generateFieldValue` per property so nested objects-of-arrays-of-objects
|
|
1897
|
+
* compose correctly.
|
|
1898
|
+
*/
|
|
1899
|
+
generateObjectValue(entityName, field, index) {
|
|
1900
|
+
if (!field.properties) return null;
|
|
1901
|
+
const out = {};
|
|
1902
|
+
for (const [propName, propField] of Object.entries(field.properties)) {
|
|
1903
|
+
const childField = { ...propField, name: propName };
|
|
1904
|
+
out[propName] = this.generateFieldValue(entityName, childField, index);
|
|
1905
|
+
}
|
|
1906
|
+
return out;
|
|
1907
|
+
}
|
|
1871
1908
|
/**
|
|
1872
1909
|
* Generate a string value based on the field's declared schema metadata.
|
|
1873
1910
|
* Reads `values` (enum) first, then `format` (email/url/phone/uuid/date/
|
|
@@ -3589,6 +3626,32 @@ function needsPreprocessing(schema) {
|
|
|
3589
3626
|
}
|
|
3590
3627
|
return false;
|
|
3591
3628
|
}
|
|
3629
|
+
function mapFieldForMock(f) {
|
|
3630
|
+
const rec = f;
|
|
3631
|
+
const out = {
|
|
3632
|
+
name: f.name,
|
|
3633
|
+
type: rec["type"]
|
|
3634
|
+
};
|
|
3635
|
+
if (typeof rec["required"] === "boolean") out.required = rec["required"];
|
|
3636
|
+
if (Array.isArray(rec["values"])) out.values = rec["values"];
|
|
3637
|
+
if (rec["default"] !== void 0) out.default = rec["default"];
|
|
3638
|
+
if (typeof rec["format"] === "string") out.format = rec["format"];
|
|
3639
|
+
const items = rec["items"];
|
|
3640
|
+
if (items && typeof items === "object" && "type" in items) {
|
|
3641
|
+
out.items = mapFieldForMock({ name: "", ...items });
|
|
3642
|
+
}
|
|
3643
|
+
const properties = rec["properties"];
|
|
3644
|
+
if (properties && typeof properties === "object" && !Array.isArray(properties)) {
|
|
3645
|
+
const propsOut = {};
|
|
3646
|
+
for (const [k, v] of Object.entries(properties)) {
|
|
3647
|
+
if (v && typeof v === "object" && "type" in v) {
|
|
3648
|
+
propsOut[k] = mapFieldForMock({ name: k, ...v });
|
|
3649
|
+
}
|
|
3650
|
+
}
|
|
3651
|
+
if (Object.keys(propsOut).length > 0) out.properties = propsOut;
|
|
3652
|
+
}
|
|
3653
|
+
return out;
|
|
3654
|
+
}
|
|
3592
3655
|
var OrbitalServerRuntime = class {
|
|
3593
3656
|
orbitals = /* @__PURE__ */ new Map();
|
|
3594
3657
|
eventBus;
|
|
@@ -4005,13 +4068,7 @@ var OrbitalServerRuntime = class {
|
|
|
4005
4068
|
if (entity?.name && entity.fields) {
|
|
4006
4069
|
const fields = entity.fields.filter(
|
|
4007
4070
|
(f) => typeof f.name === "string" && f.name.length > 0
|
|
4008
|
-
).map((f) => (
|
|
4009
|
-
name: f.name,
|
|
4010
|
-
type: f.type,
|
|
4011
|
-
required: f.required,
|
|
4012
|
-
values: f.values,
|
|
4013
|
-
default: f.default
|
|
4014
|
-
}));
|
|
4071
|
+
).map((f) => mapFieldForMock(f));
|
|
4015
4072
|
this.persistence.registerEntity({ name: entity.name, fields });
|
|
4016
4073
|
if (this.config.debug) {
|
|
4017
4074
|
persistLog.debug("mock:seeded", { entity: entity.name, count: this.persistence.count(entity.name) });
|
|
@@ -4026,13 +4083,7 @@ var OrbitalServerRuntime = class {
|
|
|
4026
4083
|
if (!auxEntity.name || !auxEntity.fields) continue;
|
|
4027
4084
|
const auxFields = auxEntity.fields.filter(
|
|
4028
4085
|
(f) => typeof f.name === "string" && f.name.length > 0
|
|
4029
|
-
).map((f) => (
|
|
4030
|
-
name: f.name,
|
|
4031
|
-
type: f.type,
|
|
4032
|
-
required: f.required,
|
|
4033
|
-
values: f.values,
|
|
4034
|
-
default: f.default
|
|
4035
|
-
}));
|
|
4086
|
+
).map((f) => mapFieldForMock(f));
|
|
4036
4087
|
this.persistence.registerEntity({ name: auxEntity.name, fields: auxFields });
|
|
4037
4088
|
if (this.config.debug) {
|
|
4038
4089
|
persistLog.debug("mock:seeded-auxiliary", {
|
|
@@ -4314,13 +4365,7 @@ var OrbitalServerRuntime = class {
|
|
|
4314
4365
|
if (entity?.name && entity.fields) {
|
|
4315
4366
|
const fields = entity.fields.filter(
|
|
4316
4367
|
(f) => typeof f.name === "string" && f.name.length > 0
|
|
4317
|
-
).map((f) => (
|
|
4318
|
-
name: f.name,
|
|
4319
|
-
type: f.type,
|
|
4320
|
-
required: f.required,
|
|
4321
|
-
values: f.values,
|
|
4322
|
-
default: f.default
|
|
4323
|
-
}));
|
|
4368
|
+
).map((f) => mapFieldForMock(f));
|
|
4324
4369
|
this.persistence.registerEntity({ name: entity.name, fields });
|
|
4325
4370
|
}
|
|
4326
4371
|
}
|
|
@@ -5398,5 +5443,5 @@ function buildMatcher(src, listenerOrbital) {
|
|
|
5398
5443
|
}
|
|
5399
5444
|
|
|
5400
5445
|
export { EffectExecutor, EventBus, HANDLER_MANIFEST, InMemoryPersistence, MockPersistenceAdapter, OrbitalServerRuntime, StateMachineManager, buildEmitsFromTraits, collectDeclaredConfigDefaults, containsBindings, createContextFromBindings, createInitialTraitState, createMockPersistence, createOrbitalServerRuntime, createTestExecutor, createUnifiedLoader, extractBindings, findInitialState, findTransition, formatPayloadValidationError, getIsolatedCollectionName, getNamespacedEvent, interpolateProps, interpolateValue, isBrowser, isElectron, isNamespacedEvent, isNode, normalizeEventKey, parseNamespacedEvent, preprocessSchema, processEvent, validateEventPayload, validatePayloadShapes };
|
|
5401
|
-
//# sourceMappingURL=chunk-
|
|
5402
|
-
//# sourceMappingURL=chunk-
|
|
5446
|
+
//# sourceMappingURL=chunk-WOXI5KCA.js.map
|
|
5447
|
+
//# sourceMappingURL=chunk-WOXI5KCA.js.map
|