@almadar/core 10.69.0 → 10.71.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,7 +1,7 @@
1
- import { O as OrbitalSchema } from '../schema-8Mhua_qQ.js';
2
- export { E as EntityAccessPolicies, e as entityAccessPolicies, a as entityAccessTable } from '../entityAccess-9IWedk_w.js';
3
- import { a as EntityPersistence, E as EntityField, F as FieldValue, f as EntityRow } from '../effect-CNaVPA4-.js';
4
- import '../trait-SUGkA3Jn.js';
1
+ import { O as OrbitalSchema } from '../schema-CrlpehQq.js';
2
+ export { E as EntityAccessPolicies, e as entityAccessPolicies, a as entityAccessTable } from '../entityAccess-B0r5mJ43.js';
3
+ import { a as EntityPersistence, E as EntityField, F as FieldValue, f as EntityRow } from '../effect-CrsTJ7h8.js';
4
+ import '../trait-CdcDJqPW.js';
5
5
  import '../expression-Fk8bQWef.js';
6
6
  import 'zod';
7
7
 
@@ -80,15 +80,22 @@ declare function randomPhone(): string;
80
80
  /**
81
81
  * The name of the schema's `[identity]` entity, if it declares one.
82
82
  *
83
- * At most one per composed program (`ORB_S_IDENTITY_NOT_UNIQUE`); same-name
84
- * duplicates across orbitals are rejected upstream by `validate_entity_uniqueness`,
85
- * so the first match is the only match.
83
+ * A behavior declares its own roster so it runs standalone. Composing it never
84
+ * imports that orbital, but a trait bound to one of its siblings drags the
85
+ * roster in as an auxiliary copy, tag and all — so a PRIMARY roster shadows
86
+ * every imported copy: the composing app decides who `@user` is. With no
87
+ * primary roster the copies still count, which is what lets a thin app that
88
+ * wraps one behavior inherit that behavior's roster.
89
+ *
90
+ * Compiled-path twin: `identity_entities` in
91
+ * `orbital-compiler/src/phases/validation/user_identity.rs`.
86
92
  */
87
93
  declare function identityEntityName(schema: OrbitalSchema): string | undefined;
88
94
  /**
89
- * Owner columns as `Entity.field` pairs — every relation field pointing at the
90
- * `[identity]` entity. Empty when the program declares no identity, which keeps
91
- * every unmigrated app behaving exactly as before.
95
+ * Owner columns as `Entity.field` pairs — every relation field pointing at an
96
+ * `[identity]`-tagged entity, shadowed imported rosters included. Empty when the
97
+ * program declares no identity, which keeps every unmigrated app behaving
98
+ * exactly as before.
92
99
  */
93
100
  declare function ownerFieldsFromSchema(schema: OrbitalSchema): string[];
94
101
 
@@ -179,18 +179,43 @@ function inlineEntities(schema) {
179
179
  }
180
180
  return out;
181
181
  }
182
+ function identityEntitiesTagged(schema) {
183
+ const out = [];
184
+ for (const orbital of schema.orbitals ?? []) {
185
+ const ref = orbital.entity;
186
+ if (typeof ref === "object" && ref !== null && "fields" in ref && ref.identity === true) {
187
+ out.push({ def: ref, primary: true });
188
+ }
189
+ }
190
+ for (const orbital of schema.orbitals ?? []) {
191
+ for (const ref of orbital.auxiliaryEntities ?? []) {
192
+ if (typeof ref === "object" && ref !== null && "fields" in ref && ref.identity === true) {
193
+ out.push({ def: ref, primary: false });
194
+ }
195
+ }
196
+ }
197
+ return out;
198
+ }
182
199
  function identityEntityName(schema) {
183
- return inlineEntities(schema).find((def) => def.identity === true)?.name;
200
+ const tagged = identityEntitiesTagged(schema);
201
+ return (tagged.find((e) => e.primary) ?? tagged[0])?.def.name;
202
+ }
203
+ function identityEntityNames(schema) {
204
+ const out = [];
205
+ for (const { def } of identityEntitiesTagged(schema)) {
206
+ if (!out.includes(def.name)) out.push(def.name);
207
+ }
208
+ return out;
184
209
  }
185
210
  function ownerFieldsFromSchema(schema) {
186
- const identity = identityEntityName(schema);
187
- if (identity === void 0) return [];
211
+ const identities = identityEntityNames(schema);
212
+ if (identities.length === 0) return [];
188
213
  const out = [];
189
214
  const defs = inlineEntities(schema);
190
215
  const declaredByCollection = /* @__PURE__ */ new Map();
191
216
  for (const def of defs) {
192
217
  for (const field of def.fields ?? []) {
193
- if (field.name && field.type === "relation" && field.relation.entity === identity) {
218
+ if (field.name && field.type === "relation" && identities.includes(field.relation.entity)) {
194
219
  out.push(`${def.name}.${field.name}`);
195
220
  if (def.collection) {
196
221
  const cols = declaredByCollection.get(def.collection) ?? [];