@almadar/runtime 6.4.0 → 6.5.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.
- package/dist/{OrbitalServerRuntime-BtG18R0H.d.ts → OrbitalServerRuntime-DhrQA78C.d.ts} +1 -1
- package/dist/OrbitalServerRuntime.d.ts +1 -1
- package/dist/OrbitalServerRuntime.js +1 -1
- package/dist/ServerBridge.js +4 -4
- package/dist/ServerBridge.js.map +1 -1
- package/dist/{chunk-BKMLP2TV.js → chunk-VCDCBBYE.js} +205 -140
- package/dist/chunk-VCDCBBYE.js.map +1 -0
- package/dist/createOsHandlers.js +10 -7
- package/dist/createOsHandlers.js.map +1 -1
- package/dist/index.d.ts +9 -7
- package/dist/index.js +24 -23
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-BKMLP2TV.js.map +0 -1
|
@@ -145,40 +145,44 @@ function interpolateProps(props, ctx) {
|
|
|
145
145
|
const typeBindingRaw = props["type"];
|
|
146
146
|
const patternType = typeof typeBindingRaw === "string" ? typeBindingRaw : void 0;
|
|
147
147
|
if (typeof entityBindingRaw === "string") {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
148
|
+
renderLog.debug("interpolateProps:entity", () => {
|
|
149
|
+
const resolvedEntity = result["entity"];
|
|
150
|
+
const resolvedRow = resolvedEntity !== null && typeof resolvedEntity === "object" && !Array.isArray(resolvedEntity) ? resolvedEntity : null;
|
|
151
|
+
const ctxRow = ctx.payload["row"];
|
|
152
|
+
const ctxPayloadKeys = Object.keys(ctx.payload).join(",");
|
|
153
|
+
const payloadDataRaw = ctx.payload["data"];
|
|
154
|
+
const payloadDataLen = Array.isArray(payloadDataRaw) ? payloadDataRaw.length : null;
|
|
155
|
+
const ctxEntityRaw = ctx.entity;
|
|
156
|
+
const ctxEntityLen = Array.isArray(ctxEntityRaw) ? ctxEntityRaw.length : null;
|
|
157
|
+
const resolvedLen = Array.isArray(resolvedEntity) ? resolvedEntity.length : null;
|
|
158
|
+
return {
|
|
159
|
+
patternType,
|
|
160
|
+
entityBinding: entityBindingRaw,
|
|
161
|
+
resolvedIsObject: resolvedRow !== null,
|
|
162
|
+
resolvedIsArray: Array.isArray(resolvedEntity),
|
|
163
|
+
resolvedLen,
|
|
164
|
+
resolvedEqualsCtxRow: ctxRow !== void 0 && resolvedRow !== null && resolvedRow === ctxRow,
|
|
165
|
+
resolvedRowId: resolvedRow?.id,
|
|
166
|
+
ctxPayloadKeys,
|
|
167
|
+
ctxPayloadDataLen: payloadDataLen,
|
|
168
|
+
ctxEntityIsArray: Array.isArray(ctxEntityRaw),
|
|
169
|
+
ctxEntityLen
|
|
170
|
+
};
|
|
169
171
|
});
|
|
170
172
|
}
|
|
171
173
|
if (patternType === "form-section" || patternType === "form") {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
174
|
+
bindLog.debug("form-binding", () => {
|
|
175
|
+
const modeRaw = result["mode"];
|
|
176
|
+
const submitRaw = result["submitEvent"];
|
|
177
|
+
const cancelRaw = result["cancelEvent"];
|
|
178
|
+
return {
|
|
179
|
+
patternType,
|
|
180
|
+
mode: typeof modeRaw === "string" ? modeRaw : void 0,
|
|
181
|
+
submitEvent: typeof submitRaw === "string" ? submitRaw : void 0,
|
|
182
|
+
cancelEvent: typeof cancelRaw === "string" ? cancelRaw : void 0,
|
|
183
|
+
entity: JSON.stringify(result["entity"] ?? null),
|
|
184
|
+
fields: JSON.stringify(result["fields"] ?? null)
|
|
185
|
+
};
|
|
182
186
|
});
|
|
183
187
|
}
|
|
184
188
|
return anyChanged ? result : props;
|
|
@@ -234,13 +238,13 @@ function interpolateArray(value, ctx) {
|
|
|
234
238
|
}
|
|
235
239
|
if (isSExpression(value)) {
|
|
236
240
|
const result = evaluate(value, ctx);
|
|
237
|
-
bindLog.
|
|
241
|
+
bindLog.debug("sexpr:eval", () => ({
|
|
238
242
|
operator: typeof value[0] === "string" ? value[0] : "<non-string>",
|
|
239
243
|
argCount: value.length - 1,
|
|
240
244
|
inputJson: JSON.stringify(value).slice(0, 300),
|
|
241
245
|
resultType: typeof result,
|
|
242
246
|
resultJson: typeof result === "object" && result !== null ? JSON.stringify(result).slice(0, 2e3) : String(result)
|
|
243
|
-
});
|
|
247
|
+
}));
|
|
244
248
|
return result;
|
|
245
249
|
}
|
|
246
250
|
const mapped = [];
|
|
@@ -311,7 +315,7 @@ function createContextFromBindings(bindings, strictBindings, contextExtensions)
|
|
|
311
315
|
var smLog = createLogger("almadar:runtime:sm");
|
|
312
316
|
function findInitialState(trait) {
|
|
313
317
|
if (!trait.states || trait.states.length === 0) {
|
|
314
|
-
|
|
318
|
+
smLog.warn("trait-has-no-states", { trait: trait.name });
|
|
315
319
|
return "unknown";
|
|
316
320
|
}
|
|
317
321
|
const markedInitial = trait.states.find((s) => s.isInitial)?.name;
|
|
@@ -418,10 +422,12 @@ function processEvent(options) {
|
|
|
418
422
|
lastFailedGuardTransition = transition;
|
|
419
423
|
} catch (error) {
|
|
420
424
|
if (guardMode === "strict") {
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
+
smLog.error("guard-error-blocks-transition", {
|
|
426
|
+
from: traitState.currentState,
|
|
427
|
+
to: transition.to,
|
|
428
|
+
event: normalizedEvent,
|
|
429
|
+
error: error instanceof Error ? error : String(error)
|
|
430
|
+
});
|
|
425
431
|
return {
|
|
426
432
|
executed: false,
|
|
427
433
|
newState: traitState.currentState,
|
|
@@ -435,7 +441,9 @@ function processEvent(options) {
|
|
|
435
441
|
guardResult: false
|
|
436
442
|
};
|
|
437
443
|
}
|
|
438
|
-
|
|
444
|
+
smLog.error("guard-evaluation-error", {
|
|
445
|
+
error: error instanceof Error ? error : String(error)
|
|
446
|
+
});
|
|
439
447
|
return {
|
|
440
448
|
executed: true,
|
|
441
449
|
newState: transition.to,
|
|
@@ -941,7 +949,7 @@ var EffectExecutor = class {
|
|
|
941
949
|
const parsed = parseEffect(effect);
|
|
942
950
|
if (!parsed) {
|
|
943
951
|
if (this.debug) {
|
|
944
|
-
|
|
952
|
+
effectLog.warn("invalid-effect-format", () => ({ effectJson: JSON.stringify(effect ?? null) }));
|
|
945
953
|
}
|
|
946
954
|
return;
|
|
947
955
|
}
|
|
@@ -976,14 +984,16 @@ var EffectExecutor = class {
|
|
|
976
984
|
}
|
|
977
985
|
effectLog.debug("execute", { operator, argCount: resolvedArgs.length, context: this.context.traitName });
|
|
978
986
|
if (this.debug) {
|
|
979
|
-
|
|
987
|
+
effectLog.debug("executing", () => ({ operator, argsJson: JSON.stringify(resolvedArgs) }));
|
|
980
988
|
}
|
|
981
989
|
try {
|
|
982
990
|
await this.dispatch(operator, resolvedArgs);
|
|
983
991
|
effectLog.debug("execute:result", { operator, success: true });
|
|
984
992
|
} catch (error) {
|
|
985
|
-
effectLog.
|
|
986
|
-
|
|
993
|
+
effectLog.error("execute:error", {
|
|
994
|
+
operator,
|
|
995
|
+
error: error instanceof Error ? error : String(error)
|
|
996
|
+
});
|
|
987
997
|
throw error;
|
|
988
998
|
}
|
|
989
999
|
}
|
|
@@ -1310,7 +1320,7 @@ var EffectExecutor = class {
|
|
|
1310
1320
|
this.handlers.watch(watchEntityType, watchOptions);
|
|
1311
1321
|
} else {
|
|
1312
1322
|
if (this.debug) {
|
|
1313
|
-
|
|
1323
|
+
effectLog.debug("watch:noop-server", { entityType: typeof args[0] === "string" ? args[0] : void 0 });
|
|
1314
1324
|
}
|
|
1315
1325
|
}
|
|
1316
1326
|
break;
|
|
@@ -1353,7 +1363,10 @@ var EffectExecutor = class {
|
|
|
1353
1363
|
const data = args[2];
|
|
1354
1364
|
this.handlers.log(message, level, data);
|
|
1355
1365
|
} else {
|
|
1356
|
-
|
|
1366
|
+
effectLog.debug("log:fallback", () => ({
|
|
1367
|
+
message: typeof args[0] === "string" ? args[0] : JSON.stringify(args[0] ?? null),
|
|
1368
|
+
extraJson: JSON.stringify(args.slice(1))
|
|
1369
|
+
}));
|
|
1357
1370
|
}
|
|
1358
1371
|
break;
|
|
1359
1372
|
}
|
|
@@ -1388,7 +1401,9 @@ var EffectExecutor = class {
|
|
|
1388
1401
|
const type = args[1] || "info";
|
|
1389
1402
|
this.handlers.notify(message, type);
|
|
1390
1403
|
} else {
|
|
1391
|
-
|
|
1404
|
+
const category = typeof args[1] === "string" ? args[1] : "info";
|
|
1405
|
+
const message = typeof args[0] === "string" ? args[0] : JSON.stringify(args[0] ?? null);
|
|
1406
|
+
effectLog.info("notify", { category, message });
|
|
1392
1407
|
}
|
|
1393
1408
|
break;
|
|
1394
1409
|
}
|
|
@@ -1548,16 +1563,14 @@ var EffectExecutor = class {
|
|
|
1548
1563
|
}
|
|
1549
1564
|
default: {
|
|
1550
1565
|
if (this.debug) {
|
|
1551
|
-
|
|
1566
|
+
effectLog.warn("unknown-operator", { operator });
|
|
1552
1567
|
}
|
|
1553
1568
|
}
|
|
1554
1569
|
}
|
|
1555
1570
|
}
|
|
1556
1571
|
logUnsupported(operator) {
|
|
1557
1572
|
if (this.debug) {
|
|
1558
|
-
|
|
1559
|
-
`[EffectExecutor] Effect "${operator}" not supported on this platform`
|
|
1560
|
-
);
|
|
1573
|
+
effectLog.warn("unsupported-on-platform", { operator });
|
|
1561
1574
|
}
|
|
1562
1575
|
}
|
|
1563
1576
|
};
|
|
@@ -1758,7 +1771,7 @@ var MockPersistenceAdapter = class {
|
|
|
1758
1771
|
seedFromInstances(entityName, instances) {
|
|
1759
1772
|
const store = this.getStore(entityName);
|
|
1760
1773
|
if (this.config.debug) {
|
|
1761
|
-
|
|
1774
|
+
mockLog.debug("seeding-from-instances", { count: instances.length, entity: entityName });
|
|
1762
1775
|
}
|
|
1763
1776
|
for (const instance of instances) {
|
|
1764
1777
|
const id = instance.id || this.nextId(entityName);
|
|
@@ -1778,7 +1791,7 @@ var MockPersistenceAdapter = class {
|
|
|
1778
1791
|
const store = this.getStore(entityName);
|
|
1779
1792
|
const normalized = entityName.toLowerCase();
|
|
1780
1793
|
if (this.config.debug) {
|
|
1781
|
-
|
|
1794
|
+
mockLog.debug("seeding", { count, entity: entityName });
|
|
1782
1795
|
}
|
|
1783
1796
|
const generated = [];
|
|
1784
1797
|
for (let i = 0; i < count; i++) {
|
|
@@ -1789,7 +1802,7 @@ var MockPersistenceAdapter = class {
|
|
|
1789
1802
|
updatedAt: typeof item.updatedAt === "string" ? item.updatedAt : ""
|
|
1790
1803
|
});
|
|
1791
1804
|
}
|
|
1792
|
-
mockLog.debug("mock:seed", { entityName, count, idsAndTimestamps: JSON.stringify(generated) });
|
|
1805
|
+
mockLog.debug("mock:seed", () => ({ entityName, count, idsAndTimestamps: JSON.stringify(generated) }));
|
|
1793
1806
|
}
|
|
1794
1807
|
/**
|
|
1795
1808
|
* Generate a single mock item based on field schemas.
|
|
@@ -3323,6 +3336,7 @@ var UnifiedLoader = class {
|
|
|
3323
3336
|
function createUnifiedLoader(options) {
|
|
3324
3337
|
return new UnifiedLoader(options);
|
|
3325
3338
|
}
|
|
3339
|
+
createLogger("almadar:runtime:studio-config");
|
|
3326
3340
|
|
|
3327
3341
|
// src/UsesIntegration.ts
|
|
3328
3342
|
async function preprocessSchema(schema, options) {
|
|
@@ -3535,6 +3549,9 @@ var effectLog2 = createLogger("almadar:runtime:effects");
|
|
|
3535
3549
|
var busLog = createLogger("almadar:runtime:bus");
|
|
3536
3550
|
var renderLog2 = createLogger("almadar:runtime:render-ui");
|
|
3537
3551
|
var xOrbitalLog = createLogger("almadar:runtime:cross-orbital");
|
|
3552
|
+
var persistLog = createLogger("almadar:runtime:persist");
|
|
3553
|
+
var registerLog = createLogger("almadar:runtime:register");
|
|
3554
|
+
var dynamicLog = createLogger("almadar:runtime:dynamic");
|
|
3538
3555
|
function isNodeEnv() {
|
|
3539
3556
|
return typeof process !== "undefined" && Boolean(process.versions?.node);
|
|
3540
3557
|
}
|
|
@@ -3611,7 +3628,7 @@ var OrbitalServerRuntime = class {
|
|
|
3611
3628
|
debug: config.debug
|
|
3612
3629
|
});
|
|
3613
3630
|
if (config.debug) {
|
|
3614
|
-
|
|
3631
|
+
persistLog.debug("mock:init", { adapter: "MockPersistenceAdapter" });
|
|
3615
3632
|
}
|
|
3616
3633
|
} else {
|
|
3617
3634
|
this.persistence = config.persistence || new InMemoryPersistence();
|
|
@@ -3673,15 +3690,11 @@ var OrbitalServerRuntime = class {
|
|
|
3673
3690
|
scopedPaths: this.config.loaderConfig?.scopedPaths
|
|
3674
3691
|
});
|
|
3675
3692
|
if (this.config.debug) {
|
|
3676
|
-
|
|
3677
|
-
`[OrbitalRuntime] Default loader constructed: basePath=${basePath} stdLibPath=${stdLibPath}`
|
|
3678
|
-
);
|
|
3693
|
+
registerLog.debug("loader:constructed", { basePath, stdLibPath });
|
|
3679
3694
|
}
|
|
3680
3695
|
} catch (err) {
|
|
3681
3696
|
if (this.config.debug) {
|
|
3682
|
-
|
|
3683
|
-
`[OrbitalRuntime] Could not auto-construct loader: ${err instanceof Error ? err.message : String(err)}`
|
|
3684
|
-
);
|
|
3697
|
+
registerLog.warn("loader:construct-failed", { error: err instanceof Error ? err : String(err) });
|
|
3685
3698
|
}
|
|
3686
3699
|
}
|
|
3687
3700
|
}
|
|
@@ -3705,13 +3718,13 @@ var OrbitalServerRuntime = class {
|
|
|
3705
3718
|
*/
|
|
3706
3719
|
async register(schema) {
|
|
3707
3720
|
if (this.config.debug) {
|
|
3708
|
-
|
|
3721
|
+
registerLog.debug("register:schema", { name: schema.name });
|
|
3709
3722
|
}
|
|
3710
3723
|
if (needsPreprocessing(schema)) {
|
|
3711
3724
|
await this.ensureLoader();
|
|
3712
3725
|
if (this.loader) {
|
|
3713
3726
|
if (this.config.debug) {
|
|
3714
|
-
|
|
3727
|
+
registerLog.debug("register:auto-preprocessing", { name: schema.name });
|
|
3715
3728
|
}
|
|
3716
3729
|
const result = await preprocessSchema(schema, {
|
|
3717
3730
|
basePath: this.config.loaderConfig?.basePath || process.cwd(),
|
|
@@ -3735,9 +3748,7 @@ var OrbitalServerRuntime = class {
|
|
|
3735
3748
|
...result.data.eventNamespaces
|
|
3736
3749
|
};
|
|
3737
3750
|
} else if (this.config.debug) {
|
|
3738
|
-
|
|
3739
|
-
`[OrbitalRuntime] Schema has uses/refs but no loader available \u2014 proceeding without preprocessing. Cross-orbital trait refs will be empty.`
|
|
3740
|
-
);
|
|
3751
|
+
registerLog.warn("register:no-loader", { name: schema.name });
|
|
3741
3752
|
}
|
|
3742
3753
|
}
|
|
3743
3754
|
for (const orbital of schema.orbitals) {
|
|
@@ -3754,7 +3765,7 @@ var OrbitalServerRuntime = class {
|
|
|
3754
3765
|
*/
|
|
3755
3766
|
registerSync(schema) {
|
|
3756
3767
|
if (this.config.debug) {
|
|
3757
|
-
|
|
3768
|
+
registerLog.debug("register:schema-sync", { name: schema.name });
|
|
3758
3769
|
}
|
|
3759
3770
|
for (const orbital of schema.orbitals) {
|
|
3760
3771
|
this.registerOrbital(orbital);
|
|
@@ -3847,7 +3858,7 @@ var OrbitalServerRuntime = class {
|
|
|
3847
3858
|
const cached = this.preprocessedCache.get(cacheKey);
|
|
3848
3859
|
if (cached) {
|
|
3849
3860
|
if (this.config.debug) {
|
|
3850
|
-
|
|
3861
|
+
registerLog.debug("preprocess:cache-hit", { name: schema.name });
|
|
3851
3862
|
}
|
|
3852
3863
|
this.register(cached.schema);
|
|
3853
3864
|
this.entitySharingMap = { ...this.entitySharingMap, ...cached.entitySharing };
|
|
@@ -3860,7 +3871,7 @@ var OrbitalServerRuntime = class {
|
|
|
3860
3871
|
};
|
|
3861
3872
|
}
|
|
3862
3873
|
if (this.config.debug) {
|
|
3863
|
-
|
|
3874
|
+
registerLog.debug("preprocess:start", { name: schema.name });
|
|
3864
3875
|
}
|
|
3865
3876
|
const result = await preprocessSchema(schema, {
|
|
3866
3877
|
basePath: this.config.loaderConfig?.basePath || ".",
|
|
@@ -3967,25 +3978,29 @@ var OrbitalServerRuntime = class {
|
|
|
3967
3978
|
if (entity?.name && entity.instances && Array.isArray(entity.instances)) {
|
|
3968
3979
|
const instances = entity.instances;
|
|
3969
3980
|
if (instances.length > 0) {
|
|
3970
|
-
|
|
3981
|
+
persistLog.debug("seed:start", { entity: entity.name, count: instances.length });
|
|
3971
3982
|
const results = await Promise.all(
|
|
3972
3983
|
instances.map(async (instance) => {
|
|
3973
3984
|
try {
|
|
3974
3985
|
const result = await this.persistence.create(entity.name, instance);
|
|
3975
|
-
|
|
3986
|
+
persistLog.debug("seed:instance", { entity: entity.name, id: instance.id ?? "no-id" });
|
|
3976
3987
|
return result;
|
|
3977
3988
|
} catch (err) {
|
|
3978
|
-
|
|
3989
|
+
persistLog.error("seed:instance-error", {
|
|
3990
|
+
entity: entity.name,
|
|
3991
|
+
id: instance.id,
|
|
3992
|
+
error: err instanceof Error ? err : String(err)
|
|
3993
|
+
});
|
|
3979
3994
|
return null;
|
|
3980
3995
|
}
|
|
3981
3996
|
})
|
|
3982
3997
|
);
|
|
3983
3998
|
const successCount = results.filter((r) => r !== null).length;
|
|
3984
|
-
|
|
3999
|
+
persistLog.debug("seed:done", { entity: entity.name, success: successCount, total: instances.length });
|
|
3985
4000
|
}
|
|
3986
4001
|
} else if (this.config.mode === "mock" && this.persistence instanceof MockPersistenceAdapter) {
|
|
3987
4002
|
if (this.config.debug) {
|
|
3988
|
-
|
|
4003
|
+
persistLog.debug("mock:generate", { entity: entity?.name });
|
|
3989
4004
|
}
|
|
3990
4005
|
if (entity?.name && entity.fields) {
|
|
3991
4006
|
const fields = entity.fields.filter(
|
|
@@ -3999,7 +4014,7 @@ var OrbitalServerRuntime = class {
|
|
|
3999
4014
|
}));
|
|
4000
4015
|
this.persistence.registerEntity({ name: entity.name, fields });
|
|
4001
4016
|
if (this.config.debug) {
|
|
4002
|
-
|
|
4017
|
+
persistLog.debug("mock:seeded", { entity: entity.name, count: this.persistence.count(entity.name) });
|
|
4003
4018
|
}
|
|
4004
4019
|
}
|
|
4005
4020
|
}
|
|
@@ -4020,16 +4035,18 @@ var OrbitalServerRuntime = class {
|
|
|
4020
4035
|
}));
|
|
4021
4036
|
this.persistence.registerEntity({ name: auxEntity.name, fields: auxFields });
|
|
4022
4037
|
if (this.config.debug) {
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4038
|
+
persistLog.debug("mock:seeded-auxiliary", {
|
|
4039
|
+
entity: auxEntity.name,
|
|
4040
|
+
count: this.persistence.count(auxEntity.name)
|
|
4041
|
+
});
|
|
4026
4042
|
}
|
|
4027
4043
|
}
|
|
4028
4044
|
}
|
|
4029
4045
|
if (this.config.debug) {
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4046
|
+
registerLog.debug("register:orbital", {
|
|
4047
|
+
name: orbital.name,
|
|
4048
|
+
traitCount: (orbital.traits || []).length
|
|
4049
|
+
});
|
|
4033
4050
|
}
|
|
4034
4051
|
}
|
|
4035
4052
|
/**
|
|
@@ -4037,7 +4054,10 @@ var OrbitalServerRuntime = class {
|
|
|
4037
4054
|
*/
|
|
4038
4055
|
registerOrbital(orbital) {
|
|
4039
4056
|
this.registerOrbitalAsync(orbital).catch((err) => {
|
|
4040
|
-
|
|
4057
|
+
registerLog.error("register:failed", {
|
|
4058
|
+
name: orbital.name,
|
|
4059
|
+
error: err instanceof Error ? err : String(err)
|
|
4060
|
+
});
|
|
4041
4061
|
});
|
|
4042
4062
|
}
|
|
4043
4063
|
/**
|
|
@@ -4056,9 +4076,13 @@ var OrbitalServerRuntime = class {
|
|
|
4056
4076
|
const cleanup = this.eventBus.on(bareEvent, async (event) => {
|
|
4057
4077
|
if (!matcher(event.source)) return;
|
|
4058
4078
|
if (this.config.debug) {
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4079
|
+
xOrbitalLog.debug("listen:received", () => ({
|
|
4080
|
+
receiverOrbital: orbitalName,
|
|
4081
|
+
receiverTrait: trait.name,
|
|
4082
|
+
event: listener.event,
|
|
4083
|
+
sourceOrbital: event.source?.orbital ?? "?",
|
|
4084
|
+
sourceTrait: event.source?.trait ?? "?"
|
|
4085
|
+
}));
|
|
4062
4086
|
}
|
|
4063
4087
|
let mappedPayload = event.payload;
|
|
4064
4088
|
if (listener.payloadMapping && event.payload) {
|
|
@@ -4103,9 +4127,7 @@ var OrbitalServerRuntime = class {
|
|
|
4103
4127
|
}
|
|
4104
4128
|
}
|
|
4105
4129
|
if (this.config.debug && this.tickBindings.length > 0) {
|
|
4106
|
-
|
|
4107
|
-
`[OrbitalRuntime] Registered ${this.tickBindings.length} tick(s)`
|
|
4108
|
-
);
|
|
4130
|
+
registerLog.debug("register:ticks", { count: this.tickBindings.length });
|
|
4109
4131
|
}
|
|
4110
4132
|
}
|
|
4111
4133
|
/**
|
|
@@ -4121,9 +4143,12 @@ var OrbitalServerRuntime = class {
|
|
|
4121
4143
|
intervalMs = 1e3;
|
|
4122
4144
|
}
|
|
4123
4145
|
if (this.config.debug) {
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4146
|
+
registerLog.debug("register:tick", {
|
|
4147
|
+
orbital: orbitalName,
|
|
4148
|
+
trait: traitName,
|
|
4149
|
+
tick: tick.name,
|
|
4150
|
+
intervalMs
|
|
4151
|
+
});
|
|
4127
4152
|
}
|
|
4128
4153
|
const timerId = setInterval(async () => {
|
|
4129
4154
|
await this.executeTick(orbitalName, traitName, tick, registered);
|
|
@@ -4142,9 +4167,7 @@ var OrbitalServerRuntime = class {
|
|
|
4142
4167
|
parseIntervalString(interval) {
|
|
4143
4168
|
const match = interval.match(/^(\d+)(ms|s|m|h)?$/);
|
|
4144
4169
|
if (!match) {
|
|
4145
|
-
|
|
4146
|
-
`[OrbitalRuntime] Invalid interval format: ${interval}, defaulting to 1000ms`
|
|
4147
|
-
);
|
|
4170
|
+
registerLog.warn("register:tick-invalid-interval", { interval, defaultMs: 1e3 });
|
|
4148
4171
|
return 1e3;
|
|
4149
4172
|
}
|
|
4150
4173
|
const value = parseInt(match[1], 10);
|
|
@@ -4175,9 +4198,12 @@ var OrbitalServerRuntime = class {
|
|
|
4175
4198
|
entities = entities.filter((e) => appliesToSet.has(e.id));
|
|
4176
4199
|
}
|
|
4177
4200
|
if (this.config.debug && entities.length > 0) {
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4201
|
+
effectLog2.debug("tick:processing", () => ({
|
|
4202
|
+
orbital: orbitalName,
|
|
4203
|
+
trait: traitName,
|
|
4204
|
+
tick: tick.name,
|
|
4205
|
+
entityCount: entities.length
|
|
4206
|
+
}));
|
|
4181
4207
|
}
|
|
4182
4208
|
for (const entity of entities) {
|
|
4183
4209
|
if (tick.guard) {
|
|
@@ -4193,17 +4219,19 @@ var OrbitalServerRuntime = class {
|
|
|
4193
4219
|
);
|
|
4194
4220
|
if (!guardPasses) {
|
|
4195
4221
|
if (this.config.debug) {
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4222
|
+
effectLog2.debug("tick:guard-failed", () => ({
|
|
4223
|
+
tick: tick.name,
|
|
4224
|
+
entityId: typeof entity.id === "string" ? entity.id : void 0
|
|
4225
|
+
}));
|
|
4199
4226
|
}
|
|
4200
4227
|
continue;
|
|
4201
4228
|
}
|
|
4202
4229
|
} catch (error) {
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4230
|
+
effectLog2.error("tick:guard-error", {
|
|
4231
|
+
tick: tick.name,
|
|
4232
|
+
entityId: typeof entity.id === "string" ? entity.id : void 0,
|
|
4233
|
+
error: error instanceof Error ? error : String(error)
|
|
4234
|
+
});
|
|
4207
4235
|
continue;
|
|
4208
4236
|
}
|
|
4209
4237
|
}
|
|
@@ -4225,17 +4253,18 @@ var OrbitalServerRuntime = class {
|
|
|
4225
4253
|
tickEffectResults
|
|
4226
4254
|
);
|
|
4227
4255
|
if (this.config.debug) {
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4256
|
+
effectLog2.debug("tick:effects-executed", () => ({
|
|
4257
|
+
tick: tick.name,
|
|
4258
|
+
entityId: typeof entity.id === "string" ? entity.id : void 0
|
|
4259
|
+
}));
|
|
4231
4260
|
}
|
|
4232
4261
|
}
|
|
4233
4262
|
}
|
|
4234
4263
|
} catch (error) {
|
|
4235
|
-
|
|
4236
|
-
|
|
4237
|
-
error
|
|
4238
|
-
);
|
|
4264
|
+
effectLog2.error("tick:execute-error", {
|
|
4265
|
+
tick: tick.name,
|
|
4266
|
+
error: error instanceof Error ? error : String(error)
|
|
4267
|
+
});
|
|
4239
4268
|
}
|
|
4240
4269
|
}
|
|
4241
4270
|
/**
|
|
@@ -4323,7 +4352,7 @@ var OrbitalServerRuntime = class {
|
|
|
4323
4352
|
payloadRowId: typeof payloadRowId === "string" || typeof payloadRowId === "number" ? payloadRowId : void 0,
|
|
4324
4353
|
entityId: request.entityId
|
|
4325
4354
|
});
|
|
4326
|
-
busLog.debug("bus:incoming", {
|
|
4355
|
+
busLog.debug("bus:incoming", () => ({
|
|
4327
4356
|
orbital: orbitalName,
|
|
4328
4357
|
event: request.event,
|
|
4329
4358
|
payload: JSON.stringify(request.payload ?? null),
|
|
@@ -4334,15 +4363,15 @@ var OrbitalServerRuntime = class {
|
|
|
4334
4363
|
currentState: state.currentState
|
|
4335
4364
|
}))
|
|
4336
4365
|
)
|
|
4337
|
-
});
|
|
4338
|
-
xOrbitalLog.info("processOrbitalEvent:enter", {
|
|
4366
|
+
}));
|
|
4367
|
+
xOrbitalLog.info("processOrbitalEvent:enter", () => ({
|
|
4339
4368
|
orbital: orbitalName,
|
|
4340
4369
|
event: request.event,
|
|
4341
4370
|
traitsInOrbital: registered.traits.map((t) => t.name).join(","),
|
|
4342
4371
|
payloadActiveTraits: JSON.stringify(
|
|
4343
4372
|
request.payload?.["_activeTraits"] ?? null
|
|
4344
4373
|
)
|
|
4345
|
-
});
|
|
4374
|
+
}));
|
|
4346
4375
|
const { event, payload, entityId, user } = request;
|
|
4347
4376
|
const validationFailures = [];
|
|
4348
4377
|
for (const trait of registered.traits) {
|
|
@@ -4396,7 +4425,11 @@ var OrbitalServerRuntime = class {
|
|
|
4396
4425
|
);
|
|
4397
4426
|
const filteredResults = activeTraits && activeTraits.length > 0 ? results.filter(({ traitName }) => activeTraits.includes(traitName)) : results;
|
|
4398
4427
|
if (this.config.debug && activeTraits) {
|
|
4399
|
-
|
|
4428
|
+
busLog.debug("dispatch:filter-traits", () => ({
|
|
4429
|
+
total: results.length,
|
|
4430
|
+
active: filteredResults.length,
|
|
4431
|
+
activeTraits: activeTraits.join(",")
|
|
4432
|
+
}));
|
|
4400
4433
|
}
|
|
4401
4434
|
for (const { traitName, result } of filteredResults) {
|
|
4402
4435
|
if (result.effects.length > 0) {
|
|
@@ -4451,7 +4484,12 @@ var OrbitalServerRuntime = class {
|
|
|
4451
4484
|
const handlers = {
|
|
4452
4485
|
emit: (event, eventPayload, source) => {
|
|
4453
4486
|
if (this.config.debug) {
|
|
4454
|
-
|
|
4487
|
+
busLog.debug("emit:dispatch", () => ({
|
|
4488
|
+
event,
|
|
4489
|
+
payloadJson: JSON.stringify(eventPayload ?? null),
|
|
4490
|
+
sourceOrbital: source?.orbital,
|
|
4491
|
+
sourceTrait: source?.trait
|
|
4492
|
+
}));
|
|
4455
4493
|
}
|
|
4456
4494
|
const stamp = source ?? {
|
|
4457
4495
|
orbital: registered.schema.name,
|
|
@@ -4650,9 +4688,7 @@ var OrbitalServerRuntime = class {
|
|
|
4650
4688
|
...paramsEcho
|
|
4651
4689
|
};
|
|
4652
4690
|
} else {
|
|
4653
|
-
|
|
4654
|
-
`[OrbitalRuntime] call-service not configured: ${service}.${action}`
|
|
4655
|
-
);
|
|
4691
|
+
effectLog2.warn("call-service:not-configured", { service, action });
|
|
4656
4692
|
}
|
|
4657
4693
|
effectResults.push({
|
|
4658
4694
|
effect: "call-service",
|
|
@@ -4673,7 +4709,7 @@ var OrbitalServerRuntime = class {
|
|
|
4673
4709
|
},
|
|
4674
4710
|
fetch: async (fetchEntityType, options) => {
|
|
4675
4711
|
try {
|
|
4676
|
-
xOrbitalLog.info("fetch:enter", {
|
|
4712
|
+
xOrbitalLog.info("fetch:enter", () => ({
|
|
4677
4713
|
entityType: fetchEntityType,
|
|
4678
4714
|
hasOptions: options !== void 0 && options !== null,
|
|
4679
4715
|
optionsKeys: options ? Object.keys(options).join(",") : "",
|
|
@@ -4681,7 +4717,7 @@ var OrbitalServerRuntime = class {
|
|
|
4681
4717
|
filterIsArray: Array.isArray(options?.filter),
|
|
4682
4718
|
filterJson: JSON.stringify(options?.filter ?? null).slice(0, 300),
|
|
4683
4719
|
payloadJson: JSON.stringify(bindingsRef?.payload ?? null).slice(0, 300)
|
|
4684
|
-
});
|
|
4720
|
+
}));
|
|
4685
4721
|
let result = null;
|
|
4686
4722
|
let total = 0;
|
|
4687
4723
|
if (options?.id) {
|
|
@@ -4706,10 +4742,10 @@ var OrbitalServerRuntime = class {
|
|
|
4706
4742
|
try {
|
|
4707
4743
|
return Boolean(evaluate(predicate, ctx));
|
|
4708
4744
|
} catch (err) {
|
|
4709
|
-
|
|
4710
|
-
|
|
4711
|
-
err
|
|
4712
|
-
);
|
|
4745
|
+
effectLog2.error("fetch:filter-eval-error", {
|
|
4746
|
+
entityType: fetchEntityType,
|
|
4747
|
+
error: err instanceof Error ? err : String(err)
|
|
4748
|
+
});
|
|
4713
4749
|
return false;
|
|
4714
4750
|
}
|
|
4715
4751
|
});
|
|
@@ -4729,7 +4765,10 @@ var OrbitalServerRuntime = class {
|
|
|
4729
4765
|
}
|
|
4730
4766
|
return result === null ? null : { rows: result, total };
|
|
4731
4767
|
} catch (error) {
|
|
4732
|
-
|
|
4768
|
+
effectLog2.error("fetch:error", {
|
|
4769
|
+
entityType: fetchEntityType,
|
|
4770
|
+
error: error instanceof Error ? error : String(error)
|
|
4771
|
+
});
|
|
4733
4772
|
return null;
|
|
4734
4773
|
}
|
|
4735
4774
|
},
|
|
@@ -4738,7 +4777,10 @@ var OrbitalServerRuntime = class {
|
|
|
4738
4777
|
try {
|
|
4739
4778
|
return await handlers.fetch(refEntityType, options);
|
|
4740
4779
|
} catch (error) {
|
|
4741
|
-
|
|
4780
|
+
effectLog2.error("ref:error", {
|
|
4781
|
+
entityType: refEntityType,
|
|
4782
|
+
error: error instanceof Error ? error : String(error)
|
|
4783
|
+
});
|
|
4742
4784
|
return null;
|
|
4743
4785
|
}
|
|
4744
4786
|
},
|
|
@@ -4834,7 +4876,7 @@ var OrbitalServerRuntime = class {
|
|
|
4834
4876
|
},
|
|
4835
4877
|
watch: (_watchEntityType, _watchOptions) => {
|
|
4836
4878
|
if (this.config.debug) {
|
|
4837
|
-
|
|
4879
|
+
effectLog2.debug("watch:noop-server", { entityType: _watchEntityType });
|
|
4838
4880
|
}
|
|
4839
4881
|
},
|
|
4840
4882
|
atomic: async (atomicEffects) => {
|
|
@@ -4890,13 +4932,18 @@ var OrbitalServerRuntime = class {
|
|
|
4890
4932
|
},
|
|
4891
4933
|
notify: (message, type) => {
|
|
4892
4934
|
if (this.config.debug) {
|
|
4893
|
-
|
|
4935
|
+
effectLog2.info("notify", { type, message });
|
|
4894
4936
|
}
|
|
4895
4937
|
pushClientEffect(["notify", message, { type }]);
|
|
4896
4938
|
},
|
|
4897
4939
|
log: (message, level) => {
|
|
4898
|
-
|
|
4899
|
-
|
|
4940
|
+
if (level === "error") {
|
|
4941
|
+
dynamicLog.error(message);
|
|
4942
|
+
} else if (level === "warn") {
|
|
4943
|
+
dynamicLog.warn(message);
|
|
4944
|
+
} else {
|
|
4945
|
+
dynamicLog.debug(message);
|
|
4946
|
+
}
|
|
4900
4947
|
},
|
|
4901
4948
|
// Allow custom handlers to override
|
|
4902
4949
|
...this.config.effectHandlers
|
|
@@ -5026,7 +5073,10 @@ var OrbitalServerRuntime = class {
|
|
|
5026
5073
|
}
|
|
5027
5074
|
}
|
|
5028
5075
|
if (this.config.debug) {
|
|
5029
|
-
|
|
5076
|
+
persistLog.debug("cascade-delete", {
|
|
5077
|
+
count: affectedRecords.length,
|
|
5078
|
+
entityType: referringEntityType
|
|
5079
|
+
});
|
|
5030
5080
|
}
|
|
5031
5081
|
break;
|
|
5032
5082
|
case "nullify":
|
|
@@ -5045,7 +5095,11 @@ var OrbitalServerRuntime = class {
|
|
|
5045
5095
|
}
|
|
5046
5096
|
}
|
|
5047
5097
|
if (this.config.debug) {
|
|
5048
|
-
|
|
5098
|
+
persistLog.debug("nullify", {
|
|
5099
|
+
field: field.name,
|
|
5100
|
+
count: affectedRecords.length,
|
|
5101
|
+
entityType: referringEntityType
|
|
5102
|
+
});
|
|
5049
5103
|
}
|
|
5050
5104
|
break;
|
|
5051
5105
|
}
|
|
@@ -5056,7 +5110,11 @@ var OrbitalServerRuntime = class {
|
|
|
5056
5110
|
const maxDepth = 2;
|
|
5057
5111
|
if (depth >= maxDepth || visited.has(entityType)) {
|
|
5058
5112
|
if (this.config.debug) {
|
|
5059
|
-
|
|
5113
|
+
persistLog.debug("populate:skip", {
|
|
5114
|
+
entityType,
|
|
5115
|
+
depth,
|
|
5116
|
+
visited: visited.has(entityType)
|
|
5117
|
+
});
|
|
5060
5118
|
}
|
|
5061
5119
|
return;
|
|
5062
5120
|
}
|
|
@@ -5072,7 +5130,7 @@ var OrbitalServerRuntime = class {
|
|
|
5072
5130
|
}
|
|
5073
5131
|
if (!entityFields) {
|
|
5074
5132
|
if (this.config.debug) {
|
|
5075
|
-
|
|
5133
|
+
persistLog.warn("populate:no-entity-def", { entityType });
|
|
5076
5134
|
}
|
|
5077
5135
|
return;
|
|
5078
5136
|
}
|
|
@@ -5083,7 +5141,7 @@ var OrbitalServerRuntime = class {
|
|
|
5083
5141
|
});
|
|
5084
5142
|
if (!relationField?.relation?.entity) {
|
|
5085
5143
|
if (this.config.debug) {
|
|
5086
|
-
|
|
5144
|
+
persistLog.warn("populate:no-relation-field", { includeField, entityType });
|
|
5087
5145
|
}
|
|
5088
5146
|
continue;
|
|
5089
5147
|
}
|
|
@@ -5113,7 +5171,10 @@ var OrbitalServerRuntime = class {
|
|
|
5113
5171
|
}
|
|
5114
5172
|
} catch (error) {
|
|
5115
5173
|
if (this.config.debug) {
|
|
5116
|
-
|
|
5174
|
+
persistLog.error("populate:fetch-related-error", {
|
|
5175
|
+
entityType: relatedEntityType,
|
|
5176
|
+
error: error instanceof Error ? error : String(error)
|
|
5177
|
+
});
|
|
5117
5178
|
}
|
|
5118
5179
|
}
|
|
5119
5180
|
}
|
|
@@ -5149,7 +5210,11 @@ var OrbitalServerRuntime = class {
|
|
|
5149
5210
|
}
|
|
5150
5211
|
}
|
|
5151
5212
|
if (this.config.debug) {
|
|
5152
|
-
|
|
5213
|
+
persistLog.debug("populate:done", {
|
|
5214
|
+
field: populatedFieldName,
|
|
5215
|
+
count: entities.length,
|
|
5216
|
+
entityType
|
|
5217
|
+
});
|
|
5153
5218
|
}
|
|
5154
5219
|
}
|
|
5155
5220
|
}
|
|
@@ -5333,5 +5398,5 @@ function buildMatcher(src, listenerOrbital) {
|
|
|
5333
5398
|
}
|
|
5334
5399
|
|
|
5335
5400
|
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 };
|
|
5336
|
-
//# sourceMappingURL=chunk-
|
|
5337
|
-
//# sourceMappingURL=chunk-
|
|
5401
|
+
//# sourceMappingURL=chunk-VCDCBBYE.js.map
|
|
5402
|
+
//# sourceMappingURL=chunk-VCDCBBYE.js.map
|