@almadar/runtime 6.64.0 → 6.66.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,5 +1,5 @@
|
|
|
1
|
-
import { createTickScheduler, EventBus, createUnifiedLoader, MockPersistenceAdapter, InMemoryPersistence, preprocessSchema, normalizeCallSiteConfigToValues, StateMachineManager, parseDurationString, validateEventPayload, formatPayloadValidationError, collectDeclaredConfigDefaults, collectDeclaredEntityDefaults, EffectExecutor } from './chunk-
|
|
2
|
-
export { InMemoryPersistence, collectDeclaredConfigDefaults } from './chunk-
|
|
1
|
+
import { createTickScheduler, EventBus, createUnifiedLoader, MockPersistenceAdapter, InMemoryPersistence, preprocessSchema, normalizeCallSiteConfigToValues, StateMachineManager, parseDurationString, validateEventPayload, formatPayloadValidationError, collectDeclaredConfigDefaults, collectDeclaredEntityDefaults, EffectExecutor } from './chunk-VD774ZUH.js';
|
|
2
|
+
export { InMemoryPersistence, collectDeclaredConfigDefaults } from './chunk-VD774ZUH.js';
|
|
3
3
|
import { isValidCronExpression } from './chunk-OU3ITB5S.js';
|
|
4
4
|
import { createContextFromBindings, checkMutationAccess, resolveCallSitePayloadCaptures, applyRowAccess, accessDeniedMessage } from './chunk-ZJ62H3ES.js';
|
|
5
5
|
import './chunk-T4VDAB4C.js';
|
|
@@ -4,7 +4,7 @@ import { seedRandom, randomArrayElement, randomInt, shuffleArray, randomPastDate
|
|
|
4
4
|
import { collectTraitRefsFromValue, collectTraitRefsFromEffects } from './chunk-SCRAHWOC.js';
|
|
5
5
|
import { createLogger, setNamespaceLevel } from '@almadar/logger';
|
|
6
6
|
import { evaluateGuard, SExpressionEvaluator } from '@almadar/evaluator';
|
|
7
|
-
import { OrbitalSchemaSchema, isInlineTrait, isEntityCall, isEntityReference, parseEntityRef, parseImportedTraitRef, isPageReference, isPageReferenceString, isPageReferenceObject, parsePageRef, isReferenceConfigType, configRefEventKnob, normalizeCallSiteConfigToValues, resolveConfigRefEventName } from '@almadar/core';
|
|
7
|
+
import { OrbitalSchemaSchema, isInlineTrait, isEntityCall, isEntityReference, parseEntityRef, parseImportedTraitRef, isPageReference, isPageReferenceString, isPageReferenceObject, parsePageRef, isReferenceConfigType, configRefEventKnob, normalizeCallSiteConfigToValues, resolveConfigRefEventName, eventListPropsOf } from '@almadar/core';
|
|
8
8
|
export { normalizeCallSiteConfigToValues } from '@almadar/core';
|
|
9
9
|
import { sampleRowCount, sampleRow } from '@almadar/core/mock';
|
|
10
10
|
|
|
@@ -1351,14 +1351,21 @@ var EffectExecutor = class _EffectExecutor {
|
|
|
1351
1351
|
try {
|
|
1352
1352
|
if (action === "batch") {
|
|
1353
1353
|
const operations = args[1];
|
|
1354
|
-
await this.handlers.persist("batch", "", {
|
|
1354
|
+
const batchSummary = await this.handlers.persist("batch", "", {
|
|
1355
|
+
operations
|
|
1356
|
+
});
|
|
1355
1357
|
persistLog.debug("persist:success", {
|
|
1356
1358
|
action,
|
|
1357
1359
|
entityType: "batch",
|
|
1358
1360
|
opCount: operations.length,
|
|
1359
1361
|
willEmit: emitCfg?.success
|
|
1360
1362
|
});
|
|
1361
|
-
this.emitSuccess(
|
|
1363
|
+
this.emitSuccess(
|
|
1364
|
+
emitCfg,
|
|
1365
|
+
"success",
|
|
1366
|
+
batchSummary ?? { totalCount: operations.length },
|
|
1367
|
+
true
|
|
1368
|
+
);
|
|
1362
1369
|
persistLog.debug("persist:emit-fired", { action, eventName: emitCfg?.success });
|
|
1363
1370
|
} else {
|
|
1364
1371
|
const entityType = args[1];
|
|
@@ -3644,6 +3651,8 @@ function renameEventsInRenderUiConfig(node, rename) {
|
|
|
3644
3651
|
if (typeof node !== "object") return node;
|
|
3645
3652
|
const obj = node;
|
|
3646
3653
|
const next = { ...obj };
|
|
3654
|
+
const rawType = obj.type;
|
|
3655
|
+
const patternType = typeof rawType === "string" ? rawType : void 0;
|
|
3647
3656
|
for (const [key, value] of Object.entries(obj)) {
|
|
3648
3657
|
if (key === "action" && typeof value === "string" && !value.startsWith("@")) {
|
|
3649
3658
|
next[key] = rename(value) ?? value;
|
|
@@ -3657,12 +3666,14 @@ function renameEventsInRenderUiConfig(node, rename) {
|
|
|
3657
3666
|
next[key] = rename(value) ?? value;
|
|
3658
3667
|
continue;
|
|
3659
3668
|
}
|
|
3660
|
-
|
|
3669
|
+
const eventField = patternType !== void 0 ? eventListPropsOf(patternType).get(key) : void 0;
|
|
3670
|
+
if (eventField !== void 0 && Array.isArray(value)) {
|
|
3661
3671
|
const rewrittenArray = value.map((entry) => {
|
|
3662
3672
|
if (!entry || typeof entry !== "object" || Array.isArray(entry)) return entry;
|
|
3663
3673
|
const action = entry;
|
|
3664
|
-
|
|
3665
|
-
|
|
3674
|
+
const current = action[eventField];
|
|
3675
|
+
if (typeof current === "string" && !current.startsWith("@")) {
|
|
3676
|
+
return { ...action, [eventField]: rename(current) ?? current };
|
|
3666
3677
|
}
|
|
3667
3678
|
return action;
|
|
3668
3679
|
});
|
|
@@ -3673,6 +3684,58 @@ function renameEventsInRenderUiConfig(node, rename) {
|
|
|
3673
3684
|
}
|
|
3674
3685
|
return next;
|
|
3675
3686
|
}
|
|
3687
|
+
function renameEventTypedMembers(value, items, rename) {
|
|
3688
|
+
if (items === void 0 || value === null || value === void 0) return value;
|
|
3689
|
+
if (Array.isArray(value)) {
|
|
3690
|
+
return value.map((entry2) => renameEventTypedMembers(entry2, items, rename));
|
|
3691
|
+
}
|
|
3692
|
+
if (typeof value !== "object") return value;
|
|
3693
|
+
const properties = items.properties;
|
|
3694
|
+
if (properties === void 0) return value;
|
|
3695
|
+
const entry = value;
|
|
3696
|
+
const next = { ...entry };
|
|
3697
|
+
let touched = false;
|
|
3698
|
+
for (const [member, decl] of Object.entries(properties)) {
|
|
3699
|
+
const current = entry[member];
|
|
3700
|
+
if (decl.type === "event") {
|
|
3701
|
+
if (typeof current === "string" && current !== "" && !current.startsWith("@")) {
|
|
3702
|
+
const renamed = rename(current);
|
|
3703
|
+
if (renamed !== void 0 && renamed !== current) {
|
|
3704
|
+
next[member] = renamed;
|
|
3705
|
+
touched = true;
|
|
3706
|
+
}
|
|
3707
|
+
}
|
|
3708
|
+
continue;
|
|
3709
|
+
}
|
|
3710
|
+
if (decl.items !== void 0 && current !== void 0) {
|
|
3711
|
+
const nested = renameEventTypedMembers(current, decl.items, rename);
|
|
3712
|
+
if (nested !== current) {
|
|
3713
|
+
next[member] = nested;
|
|
3714
|
+
touched = true;
|
|
3715
|
+
}
|
|
3716
|
+
}
|
|
3717
|
+
}
|
|
3718
|
+
return touched ? next : value;
|
|
3719
|
+
}
|
|
3720
|
+
function renameEventsInDeclaredConfig(config, rename) {
|
|
3721
|
+
if (config === void 0) return config;
|
|
3722
|
+
let touched = false;
|
|
3723
|
+
const next = {};
|
|
3724
|
+
for (const [knob, field] of Object.entries(config)) {
|
|
3725
|
+
if (field.default === void 0) {
|
|
3726
|
+
next[knob] = field;
|
|
3727
|
+
continue;
|
|
3728
|
+
}
|
|
3729
|
+
const renamedDefault = field.type === "event" ? typeof field.default === "string" && field.default !== "" && !field.default.startsWith("@") ? rename(field.default) ?? field.default : field.default : renameEventTypedMembers(field.default, field.items, rename);
|
|
3730
|
+
if (renamedDefault !== field.default) {
|
|
3731
|
+
next[knob] = { ...field, default: renamedDefault };
|
|
3732
|
+
touched = true;
|
|
3733
|
+
} else {
|
|
3734
|
+
next[knob] = field;
|
|
3735
|
+
}
|
|
3736
|
+
}
|
|
3737
|
+
return touched ? next : config;
|
|
3738
|
+
}
|
|
3676
3739
|
function renameEventsInEffects(effects, rename) {
|
|
3677
3740
|
return effects.map((effect) => renameEventRefsInNode(effect, rename));
|
|
3678
3741
|
}
|
|
@@ -4041,6 +4104,7 @@ function applyEventRenames(trait, renames) {
|
|
|
4041
4104
|
const nextTriggers = rename(l.triggers) ?? l.triggers;
|
|
4042
4105
|
return nextEvent === l.event && nextTriggers === l.triggers ? l : { ...l, event: nextEvent, triggers: nextTriggers };
|
|
4043
4106
|
});
|
|
4107
|
+
const nextConfig = renameEventsInDeclaredConfig(trait.config, rename);
|
|
4044
4108
|
return {
|
|
4045
4109
|
...trait,
|
|
4046
4110
|
stateMachine: sm ? {
|
|
@@ -4050,9 +4114,27 @@ function applyEventRenames(trait, renames) {
|
|
|
4050
4114
|
} : sm,
|
|
4051
4115
|
...trait.ticks ? { ticks: nextTicks } : {},
|
|
4052
4116
|
...trait.listens ? { listens: nextListens } : {},
|
|
4117
|
+
...nextConfig !== void 0 ? { config: nextConfig } : {},
|
|
4053
4118
|
emits: nextEmits
|
|
4054
4119
|
};
|
|
4055
4120
|
}
|
|
4121
|
+
function applyEventRenamesToCallSiteConfig(config, declared, renames) {
|
|
4122
|
+
if (config === void 0 || declared === void 0) return config;
|
|
4123
|
+
if (!renames || Object.keys(renames).length === 0) return config;
|
|
4124
|
+
const rename = (k) => k !== void 0 && k in renames ? renames[k] : k;
|
|
4125
|
+
let touched = false;
|
|
4126
|
+
const next = { ...config };
|
|
4127
|
+
for (const [knob, value] of Object.entries(config)) {
|
|
4128
|
+
const field = declared[knob];
|
|
4129
|
+
if (field === void 0) continue;
|
|
4130
|
+
const renamed = field.type === "event" ? typeof value === "string" && value !== "" && !value.startsWith("@") ? rename(value) ?? value : value : renameEventTypedMembers(value, field.items, rename);
|
|
4131
|
+
if (renamed !== value) {
|
|
4132
|
+
next[knob] = renamed;
|
|
4133
|
+
touched = true;
|
|
4134
|
+
}
|
|
4135
|
+
}
|
|
4136
|
+
return touched ? next : config;
|
|
4137
|
+
}
|
|
4056
4138
|
function resolveConfigRefEmitNames(trait, callSiteConfig) {
|
|
4057
4139
|
const emits = trait.emits ?? [];
|
|
4058
4140
|
const hasRef = emits.some((em) => configRefEventKnob(em.event) !== void 0);
|
|
@@ -4590,6 +4672,7 @@ var ReferenceResolver = class {
|
|
|
4590
4672
|
}
|
|
4591
4673
|
const reboundTrait = applyLinkedEntityRename(configResolvedTrait, linkedEntity);
|
|
4592
4674
|
const renamedTrait = applyEventRenames(reboundTrait, eventRenames);
|
|
4675
|
+
const renamedConfig = applyEventRenamesToCallSiteConfig(config, reboundTrait.config, eventRenames);
|
|
4593
4676
|
const finalTrait = listensOverride !== void 0 ? { ...renamedTrait, listens: listensOverride } : renamedTrait;
|
|
4594
4677
|
if (listensOverride !== void 0) {
|
|
4595
4678
|
refResolverLog.info("listens-override:imported", {
|
|
@@ -4604,7 +4687,7 @@ var ReferenceResolver = class {
|
|
|
4604
4687
|
data: {
|
|
4605
4688
|
trait: finalTrait,
|
|
4606
4689
|
source: { type: "imported", alias: parsed.alias, traitName: parsed.traitName },
|
|
4607
|
-
config,
|
|
4690
|
+
config: renamedConfig,
|
|
4608
4691
|
linkedEntity
|
|
4609
4692
|
},
|
|
4610
4693
|
warnings: []
|
|
@@ -4619,6 +4702,7 @@ var ReferenceResolver = class {
|
|
|
4619
4702
|
}
|
|
4620
4703
|
const reboundLocal = applyLinkedEntityRename(configResolvedLocal, linkedEntity);
|
|
4621
4704
|
const renamedLocalTrait = applyEventRenames(reboundLocal, eventRenames);
|
|
4705
|
+
const renamedLocalConfig = applyEventRenamesToCallSiteConfig(config, reboundLocal.config, eventRenames);
|
|
4622
4706
|
const finalLocalTrait = listensOverride !== void 0 ? { ...renamedLocalTrait, listens: listensOverride } : renamedLocalTrait;
|
|
4623
4707
|
if (listensOverride !== void 0) {
|
|
4624
4708
|
refResolverLog.info("listens-override:local", {
|
|
@@ -4633,7 +4717,7 @@ var ReferenceResolver = class {
|
|
|
4633
4717
|
data: {
|
|
4634
4718
|
trait: finalLocalTrait,
|
|
4635
4719
|
source: { type: "local", name: ref },
|
|
4636
|
-
config,
|
|
4720
|
+
config: renamedLocalConfig,
|
|
4637
4721
|
linkedEntity
|
|
4638
4722
|
},
|
|
4639
4723
|
warnings: []
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { EffectExecutor } from './chunk-
|
|
2
|
-
export { EffectExecutor, EventBus, HANDLER_MANIFEST, InMemoryPersistence, MockPersistenceAdapter, StateMachineManager, TickScheduler, buildEmitsFromTraits, collectDeclaredConfigDefaults, collectDeclaredEntityDefaults, createInitialTraitState, createMockPersistence, createTestExecutor, createTickScheduler, createUnifiedLoader, findInitialState, findTransition, formatPayloadValidationError, getIsolatedCollectionName, getNamespacedEvent, isBrowser, isElectron, isNamespacedEvent, isNode, isValidDurationString, normalizeCallSiteConfigToValues, normalizeEventKey, parseDurationString, parseNamespacedEvent, preprocessSchema, processEvent, validateEventPayload, validatePayloadShapes } from './chunk-
|
|
1
|
+
import { EffectExecutor } from './chunk-VD774ZUH.js';
|
|
2
|
+
export { EffectExecutor, EventBus, HANDLER_MANIFEST, InMemoryPersistence, MockPersistenceAdapter, StateMachineManager, TickScheduler, buildEmitsFromTraits, collectDeclaredConfigDefaults, collectDeclaredEntityDefaults, createInitialTraitState, createMockPersistence, createTestExecutor, createTickScheduler, createUnifiedLoader, findInitialState, findTransition, formatPayloadValidationError, getIsolatedCollectionName, getNamespacedEvent, isBrowser, isElectron, isNamespacedEvent, isNode, isValidDurationString, normalizeCallSiteConfigToValues, normalizeEventKey, parseDurationString, parseNamespacedEvent, preprocessSchema, processEvent, validateEventPayload, validatePayloadShapes } from './chunk-VD774ZUH.js';
|
|
3
3
|
export { cronMatches, cronMinuteKey, isValidCronExpression, parseCron, parseCronField } from './chunk-OU3ITB5S.js';
|
|
4
4
|
import { createContextFromBindings, applyRowAccess, checkMutationAccess, accessDeniedMessage } from './chunk-ZJ62H3ES.js';
|
|
5
5
|
export { CALLSITE_PAYLOAD_PREFIX, applyRowAccess, checkMutationAccess, containsBindings, createContextFromBindings, createMinimalContext, deferEntityBindings, extractBindings, interpolateProps, interpolateValue, resolveCallSitePayloadCaptures } from './chunk-ZJ62H3ES.js';
|
|
@@ -340,18 +340,19 @@ function createServerEffectHandlers(opts) {
|
|
|
340
340
|
}
|
|
341
341
|
if (batchFailed) break;
|
|
342
342
|
}
|
|
343
|
+
const batchSummary = {
|
|
344
|
+
operations: batchResults,
|
|
345
|
+
completedCount: completed.length,
|
|
346
|
+
totalCount: operations.length
|
|
347
|
+
};
|
|
343
348
|
record({
|
|
344
349
|
effect: "persist",
|
|
345
350
|
action: "batch",
|
|
346
|
-
data:
|
|
347
|
-
operations: batchResults,
|
|
348
|
-
completedCount: completed.length,
|
|
349
|
-
totalCount: operations.length
|
|
350
|
-
},
|
|
351
|
+
data: batchSummary,
|
|
351
352
|
success: !batchFailed,
|
|
352
353
|
...batchFailed ? { error: batchError } : {}
|
|
353
354
|
});
|
|
354
|
-
return;
|
|
355
|
+
return batchSummary;
|
|
355
356
|
}
|
|
356
357
|
const type = targetEntityType || entityType;
|
|
357
358
|
let resultData;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@almadar/runtime",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.66.0",
|
|
4
4
|
"description": "Interpreted runtime for Almadar orbital applications (OrbitalServerRuntime)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -57,11 +57,11 @@
|
|
|
57
57
|
"access": "public"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@almadar/core": "^10.
|
|
61
|
-
"@almadar/evaluator": "^2.
|
|
62
|
-
"@almadar/logger": "^1.
|
|
63
|
-
"@almadar/server": "^2.
|
|
64
|
-
"@almadar/std": "^16.
|
|
60
|
+
"@almadar/core": "^10.76.0",
|
|
61
|
+
"@almadar/evaluator": "^2.43.0",
|
|
62
|
+
"@almadar/logger": "^1.12.0",
|
|
63
|
+
"@almadar/server": "^2.39.0",
|
|
64
|
+
"@almadar/std": "^16.196.0"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
67
|
"express": "^5.0.0"
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
}
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
|
-
"@almadar/eslint-plugin": "^2.
|
|
75
|
+
"@almadar/eslint-plugin": "^2.17.0",
|
|
76
76
|
"@types/express": "^5.0.0",
|
|
77
77
|
"@types/node": "^20.0.0",
|
|
78
78
|
"@typescript-eslint/parser": "8.65.0",
|