@almadar/core 10.40.0 → 10.42.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,7 @@
1
- import { E as EntityPersistence, a as EntityField, F as FieldValue, b as EntityRow } from '../entity-DfD-iXkn.js';
1
+ import { O as OrbitalSchema } from '../schema-C_lv_cta.js';
2
+ import { a as EntityPersistence, E as EntityField, F as FieldValue, f as EntityRow } from '../effect-D4os99OL.js';
3
+ import '../trait-BQIlqUHC.js';
4
+ import '../expression-DpAj1RzP.js';
2
5
  import 'zod';
3
6
 
4
7
  /**
@@ -54,6 +57,33 @@ declare function randomUrl(): string;
54
57
  /** Random phone number. */
55
58
  declare function randomPhone(): string;
56
59
 
60
+ /**
61
+ * Owner columns derived from a program's `[identity]` entity.
62
+ *
63
+ * The JS mirror of `orbital-core/src/runtime/seed.rs`
64
+ * (`identity_entity_name` / `owner_fields_from_schema`). Both paths must agree:
65
+ * a column is an owner column because the source *declared* it as a relation to
66
+ * the `[identity]` entity (`patientId : Person`), never because its name looks
67
+ * like one — a name-matching guess would silently scope the wrong column.
68
+ *
69
+ * @packageDocumentation
70
+ */
71
+
72
+ /**
73
+ * The name of the schema's `[identity]` entity, if it declares one.
74
+ *
75
+ * At most one per composed program (`ORB_S_IDENTITY_NOT_UNIQUE`); same-name
76
+ * duplicates across orbitals are rejected upstream by `validate_entity_uniqueness`,
77
+ * so the first match is the only match.
78
+ */
79
+ declare function identityEntityName(schema: OrbitalSchema): string | undefined;
80
+ /**
81
+ * Owner columns as `Entity.field` pairs — every relation field pointing at the
82
+ * `[identity]` entity. Empty when the program declares no identity, which keeps
83
+ * every unmigrated app behaving exactly as before.
84
+ */
85
+ declare function ownerFieldsFromSchema(schema: OrbitalSchema): string[];
86
+
57
87
  /**
58
88
  * The one owner of mock-seed value synthesis.
59
89
  *
@@ -116,4 +146,4 @@ declare function sampleRow(entity: SampleEntity, ctx: Omit<SampleContext, 'entit
116
146
  /** `count` rows, 1-based, honoring the runtime-singleton gate. */
117
147
  declare function sampleRows(entity: SampleEntity, count: number, strategy: SampleStrategy): EntityRow[];
118
148
 
119
- export { IMAGE_FIELD_NAMES, type SampleContext, type SampleEntity, type SampleStrategy, isDeclaredDefaultHonored, randomAnytimeDate, randomArrayElement, randomBoolean, randomColor, randomEmail, randomFloat, randomInt, randomPassword, randomPastDate, randomPhone, randomRecentDate, randomSentence, randomUrl, randomUuid, randomWords, sampleFieldValue, sampleImageUrl, sampleRow, sampleRowCount, sampleRows, seedRandom, shuffleArray };
149
+ export { IMAGE_FIELD_NAMES, type SampleContext, type SampleEntity, type SampleStrategy, identityEntityName, isDeclaredDefaultHonored, ownerFieldsFromSchema, randomAnytimeDate, randomArrayElement, randomBoolean, randomColor, randomEmail, randomFloat, randomInt, randomPassword, randomPastDate, randomPhone, randomRecentDate, randomSentence, randomUrl, randomUuid, randomWords, sampleFieldValue, sampleImageUrl, sampleRow, sampleRowCount, sampleRows, seedRandom, shuffleArray };
@@ -161,6 +161,36 @@ function randomPhone() {
161
161
  const line = randomInt({ min: 0, max: 9999 }).toString().padStart(4, "0");
162
162
  return `+1 (${area}) ${prefix}-${line}`;
163
163
  }
164
+
165
+ // src/mock/identityOwners.ts
166
+ function inlineEntities(schema) {
167
+ const out = [];
168
+ for (const orbital of schema.orbitals ?? []) {
169
+ const refs = [orbital.entity, ...orbital.auxiliaryEntities ?? []];
170
+ for (const ref of refs) {
171
+ if (typeof ref === "object" && ref !== null && "fields" in ref) {
172
+ out.push(ref);
173
+ }
174
+ }
175
+ }
176
+ return out;
177
+ }
178
+ function identityEntityName(schema) {
179
+ return inlineEntities(schema).find((def) => def.identity === true)?.name;
180
+ }
181
+ function ownerFieldsFromSchema(schema) {
182
+ const identity = identityEntityName(schema);
183
+ if (identity === void 0) return [];
184
+ const out = [];
185
+ for (const def of inlineEntities(schema)) {
186
+ for (const field of def.fields ?? []) {
187
+ if (field.name && field.type === "relation" && field.relation.entity === identity) {
188
+ out.push(`${def.name}.${field.name}`);
189
+ }
190
+ }
191
+ }
192
+ return out;
193
+ }
164
194
  var ID_PREFIXES = {
165
195
  orbital: "orb_",
166
196
  entity: "ent_",
@@ -695,6 +725,6 @@ function sampleRows(entity, count, strategy) {
695
725
  return rows;
696
726
  }
697
727
 
698
- export { IMAGE_FIELD_NAMES, isDeclaredDefaultHonored, randomAnytimeDate, randomArrayElement, randomBoolean, randomColor, randomEmail, randomFloat, randomInt, randomPassword, randomPastDate, randomPhone, randomRecentDate, randomSentence, randomUrl, randomUuid, randomWords, sampleFieldValue, sampleImageUrl, sampleRow, sampleRowCount, sampleRows, seedRandom, shuffleArray };
728
+ export { IMAGE_FIELD_NAMES, identityEntityName, isDeclaredDefaultHonored, ownerFieldsFromSchema, randomAnytimeDate, randomArrayElement, randomBoolean, randomColor, randomEmail, randomFloat, randomInt, randomPassword, randomPastDate, randomPhone, randomRecentDate, randomSentence, randomUrl, randomUuid, randomWords, sampleFieldValue, sampleImageUrl, sampleRow, sampleRowCount, sampleRows, seedRandom, shuffleArray };
699
729
  //# sourceMappingURL=index.js.map
700
730
  //# sourceMappingURL=index.js.map