@almadar/core 10.11.0 → 10.12.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 { a as OrbitalDefinition, O as OrbitalSchema } from './schema-CtOoanon.js';
1
+ import { a as OrbitalDefinition, O as OrbitalSchema } from './schema-CSn8gU27.js';
2
2
 
3
3
  /**
4
4
  * Event Wiring
@@ -1,6 +1,6 @@
1
- import { g as FactoryParamValue, c as FactoryConfigTier, b as FactoryConfigParam, F as FactoryCallSite, h as FactorySignature, R as RuleOverlay, p as RuleOverlayEntry, o as PresentationOverlay, q as TraitOverlay } from '../types-COc0mLs1.js';
2
- export { a as FactoryCallSiteParams, d as FactoryEntitySignature, e as FactoryEventSignature, f as FactoryPageSignature, i as FactorySignatureCatalog, j as FactorySignatureEntityField, k as FactoryTraitSignature, m as JsonSchema, n as JsonSchemaType, J as JsonValue, O as OwnershipOverlayEntry, P as PresentationNavItem, S as SchemaFieldType, r as TraitOverlayEntry, s as TraitOverlayListener } from '../types-COc0mLs1.js';
3
- import { g as EntityPersistence, f as EntityField, j as TraitReference } from '../trait-BB1dc5A_.js';
1
+ import { g as FactoryParamValue, c as FactoryConfigTier, b as FactoryConfigParam, F as FactoryCallSite, h as FactorySignature, R as RuleOverlay, p as RuleOverlayEntry, o as PresentationOverlay, q as TraitOverlay } from '../types-C16w56HW.js';
2
+ export { a as FactoryCallSiteParams, d as FactoryEntitySignature, e as FactoryEventSignature, f as FactoryPageSignature, i as FactorySignatureCatalog, j as FactorySignatureEntityField, k as FactoryTraitSignature, m as JsonSchema, n as JsonSchemaType, J as JsonValue, O as OwnershipOverlayEntry, P as PresentationNavItem, S as SchemaFieldType, r as TraitOverlayEntry, s as TraitOverlayListener } from '../types-C16w56HW.js';
3
+ import { g as EntityPersistence, f as EntityField, j as TraitReference } from '../trait-DecHZfpm.js';
4
4
  import 'zod';
5
5
  import '../expression-BUIi9ezJ.js';
6
6
  import '@almadar/patterns';
@@ -1,10 +1,10 @@
1
- import { O as OrbitalSchema, a as OrbitalDefinition } from '../schema-CtOoanon.js';
2
- import { f as EntityField, g as EntityPersistence, C as CallSiteConfig, Y as CallSiteConfigEntry, a as Trait } from '../trait-BB1dc5A_.js';
1
+ import { O as OrbitalSchema, a as OrbitalDefinition } from '../schema-CSn8gU27.js';
2
+ import { f as EntityField, g as EntityPersistence, C as CallSiteConfig, Y as CallSiteConfigEntry, a as Trait } from '../trait-DecHZfpm.js';
3
3
  import { MakeTraitRefOpts } from '../builders.js';
4
4
  import '../expression-BUIi9ezJ.js';
5
5
  import 'zod';
6
6
  import '@almadar/patterns';
7
- import '../compose-behaviors-D9bQEgqN.js';
7
+ import '../compose-behaviors-Bhf-XFFc.js';
8
8
 
9
9
  /**
10
10
  * Orbital factory manifest types — shared across all packages.
@@ -1,67 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  import '@almadar/patterns';
3
3
 
4
- // src/factory-runtime/extract-manifest.ts
5
- var STATIC_PARAM_FIELDS = [
6
- {
7
- name: "fields",
8
- type: "EntityField[]",
9
- description: "Extra fields appended to the canonical entity."
10
- },
11
- {
12
- name: "pagePath",
13
- type: "string",
14
- description: "URL override for the orbital first page."
15
- },
16
- {
17
- name: "persistence",
18
- type: "'persistent' | 'runtime' | 'singleton' | 'instance' | 'local'",
19
- description: "Override the canonical entity persistence mode."
20
- },
21
- {
22
- name: "entityName",
23
- type: "string",
24
- description: "Rename the canonical entity. PascalCase singular, \u226432 chars. Threads through every trait's linkedEntity binding; compiler rewrites @Entity.x refs."
25
- },
26
- {
27
- name: "collection",
28
- type: "string",
29
- description: "Override derived collection key. Defaults to plural(entityName).toLowerCase()."
30
- },
31
- {
32
- name: "traitOverrides",
33
- type: "Partial<Record<TraitName, { config?, linkedEntity?, events?, name?, emitsScope?, listens? }>>",
34
- description: ".lolo's native trait-composition surface 1:1: per-imported-trait config, linkedEntity, events, name, emitsScope, listens. effects is excluded (atom-owned; use listens via a sibling trait)."
35
- }
36
- ];
37
- function splitTraits(traits) {
38
- const refTraitNames = [];
39
- const inlineTraitNames = [];
40
- for (const t of traits) {
41
- if (!t || typeof t !== "object") continue;
42
- const tName = typeof t.name === "string" ? t.name : null;
43
- if (!tName) continue;
44
- if (typeof t.ref === "string") {
45
- refTraitNames.push(tName);
46
- } else {
47
- inlineTraitNames.push(tName);
48
- }
49
- }
50
- return { refTraitNames, inlineTraitNames };
51
- }
52
- function extractManifest(orb) {
53
- const behaviorName = orb.name;
54
- return orb.orbitals.map((orbital) => {
55
- const { refTraitNames, inlineTraitNames } = splitTraits(orbital.traits);
56
- return {
57
- organism: behaviorName,
58
- orbitalName: orbital.name,
59
- paramFields: STATIC_PARAM_FIELDS,
60
- traitNames: refTraitNames,
61
- inlineTraitNames
62
- };
63
- });
64
- }
4
+ // src/types/orbital.ts
65
5
  z.enum([
66
6
  "string",
67
7
  "number",
@@ -296,6 +236,9 @@ var OrbitalEntitySchema = z.object({
296
236
  assetRef: SemanticAssetRefSchema.optional()
297
237
  });
298
238
  var EntitySchema = OrbitalEntitySchema;
239
+ function persistenceModeAllowsOverrides(persistence) {
240
+ return persistence === "persistent" || persistence === void 0;
241
+ }
299
242
  var UI_SLOTS = [
300
243
  // App slots
301
244
  "main",
@@ -1311,6 +1254,80 @@ z.object({
1311
1254
  });
1312
1255
  z.string();
1313
1256
 
1257
+ // src/factory-runtime/extract-manifest.ts
1258
+ var STATIC_PARAM_FIELDS = [
1259
+ {
1260
+ name: "fields",
1261
+ type: "EntityField[]",
1262
+ description: "Extra fields appended to the canonical entity."
1263
+ },
1264
+ {
1265
+ name: "pagePath",
1266
+ type: "string",
1267
+ description: "URL override for the orbital first page."
1268
+ },
1269
+ {
1270
+ name: "persistence",
1271
+ type: "'persistent' | 'runtime' | 'singleton' | 'instance' | 'local'",
1272
+ description: "Override the canonical entity persistence mode."
1273
+ },
1274
+ {
1275
+ name: "entityName",
1276
+ type: "string",
1277
+ description: "Rename the canonical entity. PascalCase singular, \u226432 chars. Threads through every trait's linkedEntity binding; compiler rewrites @Entity.x refs."
1278
+ },
1279
+ {
1280
+ name: "collection",
1281
+ type: "string",
1282
+ description: "Override derived collection key. Defaults to plural(entityName).toLowerCase()."
1283
+ },
1284
+ {
1285
+ name: "traitOverrides",
1286
+ type: "Partial<Record<TraitName, { config?, linkedEntity?, events?, name?, emitsScope?, listens? }>>",
1287
+ description: ".lolo's native trait-composition surface 1:1: per-imported-trait config, linkedEntity, events, name, emitsScope, listens. effects is excluded (atom-owned; use listens via a sibling trait)."
1288
+ }
1289
+ ];
1290
+ function entityPersistence(entity) {
1291
+ if (entity && typeof entity === "object" && !("extends" in entity)) {
1292
+ return entity.persistence;
1293
+ }
1294
+ return void 0;
1295
+ }
1296
+ function paramFieldsForPersistence(persistence) {
1297
+ if (persistenceModeAllowsOverrides(persistence)) {
1298
+ return STATIC_PARAM_FIELDS;
1299
+ }
1300
+ return STATIC_PARAM_FIELDS.filter((f) => f.name !== "persistence" && f.name !== "collection");
1301
+ }
1302
+ function splitTraits(traits) {
1303
+ const refTraitNames = [];
1304
+ const inlineTraitNames = [];
1305
+ for (const t of traits) {
1306
+ if (!t || typeof t !== "object") continue;
1307
+ const tName = typeof t.name === "string" ? t.name : null;
1308
+ if (!tName) continue;
1309
+ if (typeof t.ref === "string") {
1310
+ refTraitNames.push(tName);
1311
+ } else {
1312
+ inlineTraitNames.push(tName);
1313
+ }
1314
+ }
1315
+ return { refTraitNames, inlineTraitNames };
1316
+ }
1317
+ function extractManifest(orb) {
1318
+ const behaviorName = orb.name;
1319
+ return orb.orbitals.map((orbital) => {
1320
+ const { refTraitNames, inlineTraitNames } = splitTraits(orbital.traits);
1321
+ return {
1322
+ organism: behaviorName,
1323
+ orbitalName: orbital.name,
1324
+ paramFields: paramFieldsForPersistence(entityPersistence(orbital.entity)),
1325
+ traitNames: refTraitNames,
1326
+ inlineTraitNames
1327
+ };
1328
+ });
1329
+ }
1330
+
1314
1331
  // src/builders.ts
1315
1332
  function makeTraitRef(opts) {
1316
1333
  const ref2 = { ref: opts.ref };
@@ -1352,14 +1369,7 @@ function validateOrbitalFactoryParams(manifest, raw) {
1352
1369
  error: { kind: "not-object", received: Array.isArray(raw) ? "array" : "null" }
1353
1370
  };
1354
1371
  }
1355
- const ALLOWED_KEYS = /* @__PURE__ */ new Set([
1356
- "fields",
1357
- "pagePath",
1358
- "persistence",
1359
- "entityName",
1360
- "collection",
1361
- "traitOverrides"
1362
- ]);
1372
+ const ALLOWED_KEYS = new Set(manifest.paramFields.map((f) => f.name));
1363
1373
  for (const key of Object.keys(raw)) {
1364
1374
  if (!ALLOWED_KEYS.has(key)) {
1365
1375
  return { ok: false, error: { kind: "unknown-key", key } };
@@ -1450,12 +1460,15 @@ function buildEntity(ctx, effectiveName, effectiveCollection, params) {
1450
1460
  ...extras
1451
1461
  ];
1452
1462
  }
1463
+ const allowPersistenceOverride = persistenceModeAllowsOverrides(
1464
+ ctx.canonicalEntity.persistence
1465
+ );
1453
1466
  const entity = {
1454
1467
  name: effectiveName,
1455
- persistence: params.persistence ?? ctx.canonicalEntity.persistence,
1468
+ persistence: allowPersistenceOverride ? params.persistence ?? ctx.canonicalEntity.persistence : ctx.canonicalEntity.persistence,
1456
1469
  fields: [...mergedFields]
1457
1470
  };
1458
- if (effectiveCollection !== void 0) {
1471
+ if (allowPersistenceOverride && effectiveCollection !== void 0) {
1459
1472
  entity.collection = effectiveCollection;
1460
1473
  }
1461
1474
  return entity;