@almadar/runtime 5.3.0 → 5.4.1
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.
- package/dist/OrbitalServerRuntime.js +6 -2
- package/dist/OrbitalServerRuntime.js.map +1 -1
- package/dist/{chunk-FAWWBERN.js → chunk-ADHL7L4X.js} +34 -16
- package/dist/chunk-ADHL7L4X.js.map +1 -0
- package/dist/index.d.ts +9 -3
- package/dist/index.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-FAWWBERN.js.map +0 -1
|
@@ -1684,6 +1684,9 @@ function buildEmitsFromTraits(traits, explicitEmits) {
|
|
|
1684
1684
|
}
|
|
1685
1685
|
return result;
|
|
1686
1686
|
}
|
|
1687
|
+
var mockLog = createLogger("almadar:runtime:mock");
|
|
1688
|
+
var DEFAULT_MOCK_SEED = 42;
|
|
1689
|
+
var SEED_REFERENCE_TIMESTAMP = "2024-01-01T00:00:00.000Z";
|
|
1687
1690
|
var MockPersistenceAdapter = class {
|
|
1688
1691
|
stores = /* @__PURE__ */ new Map();
|
|
1689
1692
|
schemas = /* @__PURE__ */ new Map();
|
|
@@ -1693,13 +1696,22 @@ var MockPersistenceAdapter = class {
|
|
|
1693
1696
|
this.config = {
|
|
1694
1697
|
defaultSeedCount: 6,
|
|
1695
1698
|
debug: false,
|
|
1696
|
-
...config
|
|
1699
|
+
...config,
|
|
1700
|
+
// Apply default after spread so an undefined `seed` in the
|
|
1701
|
+
// input doesn't overwrite the default.
|
|
1702
|
+
seed: config.seed ?? DEFAULT_MOCK_SEED
|
|
1697
1703
|
};
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1704
|
+
faker.seed(this.config.seed);
|
|
1705
|
+
mockLog.debug("mock:adapter:init", { seed: this.config.seed });
|
|
1706
|
+
}
|
|
1707
|
+
/** Re-anchor faker's PRNG to the configured seed. Called before every
|
|
1708
|
+
* re-seed loop so identical reseed sequences produce identical rows
|
|
1709
|
+
* (timestamps + faker-generated fields). Without this, the first
|
|
1710
|
+
* reseed produces row set A, the second produces row set B, and
|
|
1711
|
+
* diff observers see all rows as "changed" between frames. */
|
|
1712
|
+
resetFakerSeed() {
|
|
1713
|
+
if (this.config.seed !== void 0) {
|
|
1714
|
+
faker.seed(this.config.seed);
|
|
1703
1715
|
}
|
|
1704
1716
|
}
|
|
1705
1717
|
// ============================================================================
|
|
@@ -1747,12 +1759,11 @@ var MockPersistenceAdapter = class {
|
|
|
1747
1759
|
}
|
|
1748
1760
|
for (const instance of instances) {
|
|
1749
1761
|
const id = instance.id || this.nextId(entityName);
|
|
1750
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
1751
1762
|
const item = {
|
|
1752
1763
|
...instance,
|
|
1753
1764
|
id,
|
|
1754
|
-
createdAt: instance.createdAt ||
|
|
1755
|
-
updatedAt:
|
|
1765
|
+
createdAt: instance.createdAt || SEED_REFERENCE_TIMESTAMP,
|
|
1766
|
+
updatedAt: SEED_REFERENCE_TIMESTAMP
|
|
1756
1767
|
};
|
|
1757
1768
|
store.set(id, item);
|
|
1758
1769
|
}
|
|
@@ -1766,21 +1777,26 @@ var MockPersistenceAdapter = class {
|
|
|
1766
1777
|
if (this.config.debug) {
|
|
1767
1778
|
console.log(`[MockPersistence] Seeding ${count} ${entityName}...`);
|
|
1768
1779
|
}
|
|
1780
|
+
const generated = [];
|
|
1769
1781
|
for (let i = 0; i < count; i++) {
|
|
1770
1782
|
const item = this.generateMockItem(normalized, entityName, fields, i + 1);
|
|
1771
1783
|
store.set(item.id, item);
|
|
1784
|
+
generated.push({
|
|
1785
|
+
id: item.id,
|
|
1786
|
+
updatedAt: typeof item.updatedAt === "string" ? item.updatedAt : ""
|
|
1787
|
+
});
|
|
1772
1788
|
}
|
|
1789
|
+
mockLog.debug("mock:seed", { entityName, count, idsAndTimestamps: JSON.stringify(generated) });
|
|
1773
1790
|
}
|
|
1774
1791
|
/**
|
|
1775
1792
|
* Generate a single mock item based on field schemas.
|
|
1776
1793
|
*/
|
|
1777
1794
|
generateMockItem(normalizedName, entityName, fields, index) {
|
|
1778
1795
|
const id = this.nextId(entityName);
|
|
1779
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
1780
1796
|
const item = {
|
|
1781
1797
|
id,
|
|
1782
1798
|
createdAt: faker.date.past({ years: 1 }).toISOString(),
|
|
1783
|
-
updatedAt:
|
|
1799
|
+
updatedAt: SEED_REFERENCE_TIMESTAMP
|
|
1784
1800
|
};
|
|
1785
1801
|
for (const field of fields) {
|
|
1786
1802
|
if (field.name === "id" || field.name === "createdAt" || field.name === "updatedAt") {
|
|
@@ -1946,12 +1962,14 @@ var MockPersistenceAdapter = class {
|
|
|
1946
1962
|
this.stores.delete(normalized);
|
|
1947
1963
|
this.idCounters.delete(normalized);
|
|
1948
1964
|
}
|
|
1949
|
-
/**
|
|
1950
|
-
*
|
|
1951
|
-
*/
|
|
1965
|
+
/** Clear all data + re-anchor faker so the next seed loop reproduces
|
|
1966
|
+
* identical rows. Hermetic-frame mode calls this between every step
|
|
1967
|
+
* via OrbitalServerRuntime.resetMockPersistence. */
|
|
1952
1968
|
clearAll() {
|
|
1953
1969
|
this.stores.clear();
|
|
1954
1970
|
this.idCounters.clear();
|
|
1971
|
+
this.resetFakerSeed();
|
|
1972
|
+
mockLog.debug("mock:adapter:clearAll", { reanchored: this.config.seed });
|
|
1955
1973
|
}
|
|
1956
1974
|
/**
|
|
1957
1975
|
* Get count of items for an entity.
|
|
@@ -3396,5 +3414,5 @@ var InMemoryPersistence = class {
|
|
|
3396
3414
|
};
|
|
3397
3415
|
|
|
3398
3416
|
export { EffectExecutor, EventBus, HANDLER_MANIFEST, InMemoryPersistence, MockPersistenceAdapter, StateMachineManager, buildEmitsFromTraits, containsBindings, createContextFromBindings, createInitialTraitState, createLogger, createMockPersistence, createTestExecutor, createUnifiedLoader, extractBindings, findInitialState, findTransition, formatPayloadValidationError, getIsolatedCollectionName, getNamespacedEvent, interpolateProps, interpolateValue, isBrowser, isElectron, isNamespacedEvent, isNode, normalizeEventKey, parseNamespacedEvent, preprocessSchema, processEvent, validateEventPayload, validatePayloadShapes };
|
|
3399
|
-
//# sourceMappingURL=chunk-
|
|
3400
|
-
//# sourceMappingURL=chunk-
|
|
3417
|
+
//# sourceMappingURL=chunk-ADHL7L4X.js.map
|
|
3418
|
+
//# sourceMappingURL=chunk-ADHL7L4X.js.map
|