@itwin/ecschema-metadata 5.10.0-dev.19 → 5.10.0-dev.21

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.
Files changed (33) hide show
  1. package/lib/cjs/SchemaView.d.ts +653 -0
  2. package/lib/cjs/SchemaView.d.ts.map +1 -0
  3. package/lib/cjs/SchemaView.js +1204 -0
  4. package/lib/cjs/SchemaView.js.map +1 -0
  5. package/lib/cjs/SchemaViewBinaryReader.d.ts +16 -0
  6. package/lib/cjs/SchemaViewBinaryReader.d.ts.map +1 -0
  7. package/lib/cjs/SchemaViewBinaryReader.js +610 -0
  8. package/lib/cjs/SchemaViewBinaryReader.js.map +1 -0
  9. package/lib/cjs/SchemaViewInterfaces.d.ts +220 -0
  10. package/lib/cjs/SchemaViewInterfaces.d.ts.map +1 -0
  11. package/lib/cjs/SchemaViewInterfaces.js +69 -0
  12. package/lib/cjs/SchemaViewInterfaces.js.map +1 -0
  13. package/lib/cjs/ecschema-metadata.d.ts +3 -0
  14. package/lib/cjs/ecschema-metadata.d.ts.map +1 -1
  15. package/lib/cjs/ecschema-metadata.js +3 -0
  16. package/lib/cjs/ecschema-metadata.js.map +1 -1
  17. package/lib/esm/SchemaView.d.ts +653 -0
  18. package/lib/esm/SchemaView.d.ts.map +1 -0
  19. package/lib/esm/SchemaView.js +1199 -0
  20. package/lib/esm/SchemaView.js.map +1 -0
  21. package/lib/esm/SchemaViewBinaryReader.d.ts +16 -0
  22. package/lib/esm/SchemaViewBinaryReader.d.ts.map +1 -0
  23. package/lib/esm/SchemaViewBinaryReader.js +607 -0
  24. package/lib/esm/SchemaViewBinaryReader.js.map +1 -0
  25. package/lib/esm/SchemaViewInterfaces.d.ts +220 -0
  26. package/lib/esm/SchemaViewInterfaces.d.ts.map +1 -0
  27. package/lib/esm/SchemaViewInterfaces.js +66 -0
  28. package/lib/esm/SchemaViewInterfaces.js.map +1 -0
  29. package/lib/esm/ecschema-metadata.d.ts +3 -0
  30. package/lib/esm/ecschema-metadata.d.ts.map +1 -1
  31. package/lib/esm/ecschema-metadata.js +3 -0
  32. package/lib/esm/ecschema-metadata.js.map +1 -1
  33. package/package.json +6 -6
@@ -0,0 +1,653 @@
1
+ /** @packageDocumentation
2
+ * @module Schema
3
+ */
4
+ import { type ClassData, ClassModifier, ClassType, type EnumerationData, type EnumeratorData, type KoqData, type PropCategoryData, type PropertyDef, PropertyKind, type PropertyRef, type RelConstraintData, type SchemaData, SchemaViewPrimitiveType } from "./SchemaViewInterfaces";
5
+ import { StrengthDirection, StrengthType } from "./ECObjects";
6
+ declare const _storage: unique symbol;
7
+ /** Internal runtime storage attached to a SchemaView instance. Carries the immutable data
8
+ * tables built by SchemaViewBuilder plus two mutable caches populated lazily at runtime.
9
+ * @internal
10
+ */
11
+ interface SchemaViewStorage extends SchemaViewData {
12
+ readonly transitiveBaseCache: Map<number, ReadonlySet<number>>;
13
+ derivedClassMap: ReadonlyMap<number, readonly number[]> | undefined;
14
+ }
15
+ /** A property reference paired with the index of the class that declared it. Used for
16
+ * property inheritance resolution - the classIdx tracks where each property originates
17
+ * (base class, mixin, or own) so consumers can discover the declaring class.
18
+ * @internal
19
+ */
20
+ export interface ResolvedPropertyRef {
21
+ readonly ref: PropertyRef;
22
+ readonly classIdx: number;
23
+ }
24
+ /** Internal data bag passed from the builder to the context constructor.
25
+ * @internal
26
+ */
27
+ export interface SchemaViewData {
28
+ readonly strings: readonly string[];
29
+ readonly lowerStrings: readonly string[];
30
+ readonly schemas: readonly SchemaData[];
31
+ readonly classes: readonly ClassData[];
32
+ readonly classMixins: readonly number[];
33
+ readonly propDefs: readonly PropertyDef[];
34
+ readonly propertyRefs: readonly PropertyRef[];
35
+ readonly relConstraints: readonly RelConstraintData[];
36
+ readonly constraintClassRefs: readonly number[];
37
+ readonly enumerations: readonly EnumerationData[];
38
+ readonly enumerators: readonly EnumeratorData[];
39
+ readonly koqs: readonly KoqData[];
40
+ readonly propCategories: readonly PropCategoryData[];
41
+ readonly schemaByName: ReadonlyMap<string, number>;
42
+ readonly schemaByAlias: ReadonlyMap<string, number>;
43
+ readonly classByName: ReadonlyMap<number, ReadonlyMap<string, number>>;
44
+ readonly enumByName: ReadonlyMap<number, ReadonlyMap<string, number>>;
45
+ readonly koqByName: ReadonlyMap<number, ReadonlyMap<string, number>>;
46
+ readonly catByName: ReadonlyMap<number, ReadonlyMap<string, number>>;
47
+ }
48
+ /** Read-only schema metadata view. Optimized for fast lookup and low memory usage.
49
+ *
50
+ * All data is stored in flat arrays. View objects (`SchemaView.Schema`, `SchemaView.Class`, etc.) are
51
+ * stateless wrappers that hold a reference to this view plus an index. They allocate nothing
52
+ * and cache nothing.
53
+ *
54
+ * The view is immutable after construction. Build it via `SchemaViewBuilder` or parse
55
+ * from a binary blob via `fromBinary`.
56
+ * @beta
57
+ */
58
+ export declare class SchemaView {
59
+ /** @internal */
60
+ readonly [_storage]: SchemaViewStorage;
61
+ private _schemaToken;
62
+ private _outdated;
63
+ /** @internal */
64
+ constructor(data: SchemaViewData, schemaToken?: string);
65
+ /** SHA3-256 content hash of the ec_ schema tables at the time this view was built.
66
+ * Empty string if not set (e.g., when built from a builder without a token).
67
+ * @beta
68
+ */
69
+ get schemaToken(): string;
70
+ /** True if the host (`IModelDb` / `IModelConnection`) has replaced this view with a newer one.
71
+ * The view remains fully functional - it returns stale data rather than throwing.
72
+ * Consumers who stored a reference can check this flag for diagnostics.
73
+ * @beta
74
+ */
75
+ get isOutdated(): boolean;
76
+ /** Mark this view as outdated. Called by the host when a newer view replaces it.
77
+ * @internal
78
+ */
79
+ markOutdated(): void;
80
+ /** Number of schemas in the view. */
81
+ get schemaCount(): number;
82
+ /** Number of classes across all schemas. */
83
+ get classCount(): number;
84
+ /** Get a schema by name (case-insensitive). */
85
+ getSchema(name: string): SchemaView.Schema | undefined;
86
+ /** Get a schema by alias (case-insensitive). */
87
+ getSchemaByAlias(alias: string): SchemaView.Schema | undefined;
88
+ /** Iterate all schemas. */
89
+ getSchemas(): IterableIterator<SchemaView.Schema>;
90
+ /** Find a class by qualified name ("SchemaName:ClassName" or "SchemaName.ClassName").
91
+ * The namespace part matches schema name first, then alias. Case-insensitive.
92
+ */
93
+ findClass(qualifiedName: string): SchemaView.Class | undefined;
94
+ /** Find an enumeration by qualified name ("SchemaName:EnumName" or "SchemaName.EnumName").
95
+ * The namespace part matches schema name first, then alias. Case-insensitive.
96
+ */
97
+ findEnumeration(qualifiedName: string): SchemaView.Enumeration | undefined;
98
+ /** Find a KindOfQuantity by qualified name ("SchemaName:KoqName" or "SchemaName.KoqName").
99
+ * The namespace part matches schema name first, then alias. Case-insensitive.
100
+ */
101
+ findKindOfQuantity(qualifiedName: string): SchemaView.KindOfQuantity | undefined;
102
+ /** Find a PropertyCategory by qualified name ("SchemaName:CategoryName" or "SchemaName.CategoryName").
103
+ * The namespace part matches schema name first, then alias. Case-insensitive.
104
+ */
105
+ findPropertyCategory(qualifiedName: string): SchemaView.PropertyCategory | undefined;
106
+ /** Parse a binary blob into a SchemaView. Synchronous.
107
+ * @param blob - The binary blob from `PRAGMA schema_view`.
108
+ * @param schemaToken - Optional SHA3-256 content hash for cache invalidation.
109
+ * @beta
110
+ */
111
+ static fromBinary(blob: Uint8Array, schemaToken?: string): SchemaView;
112
+ /** Build from a pre-populated builder (used by the binary parser).
113
+ * @internal
114
+ */
115
+ static fromBuilder(builder: SchemaViewBuilder, schemaToken?: string): SchemaView;
116
+ /** Resolve a qualified "SchemaName:ItemName" (or dot-separated) to an index using the given
117
+ * per-schema name map. Returns undefined if not found. @internal */
118
+ private _resolveSchemaItemIdx;
119
+ /** @internal */
120
+ resolveClassIdx(qualifiedName: string): number;
121
+ /** @internal */
122
+ getTransitiveBases(classIdx: number): ReadonlySet<number>;
123
+ private _buildTransitiveBases;
124
+ /** @internal */
125
+ resolveAllProperties(classIdx: number): readonly ResolvedPropertyRef[];
126
+ private _collectProperties;
127
+ private _collectMixinProperties;
128
+ /** @internal */
129
+ buildDerivedClassMap(): ReadonlyMap<number, readonly number[]>;
130
+ }
131
+ /** @beta */
132
+ export declare namespace SchemaView {
133
+ /** Lightweight view over a schema in a `SchemaView`. Holds only a view reference and
134
+ * an index - no data duplication, no mutable state.
135
+ * @beta
136
+ */
137
+ class Schema {
138
+ private readonly _ctx;
139
+ /** @internal */ readonly idx: number;
140
+ /** @internal */
141
+ constructor(_ctx: SchemaView,
142
+ /** @internal */ idx: number);
143
+ private get _data();
144
+ /** Row ID from ec_Schema. Matches `ECInstanceId` in ECDbMeta views, e.g.
145
+ * `SELECT * FROM meta.ECSchemaDef WHERE ECInstanceId = ?`.
146
+ *
147
+ * This is not an array index or internal handle - it is the database row ID from the ec_Schema
148
+ * table, carried through the binary blob so consumers can fall back to ECSQL meta-queries for
149
+ * data not included in the schema view (custom attributes, schema references, etc.).
150
+ */
151
+ get ecInstanceId(): number;
152
+ get name(): string;
153
+ get alias(): string;
154
+ get label(): string;
155
+ get description(): string;
156
+ get readVersion(): number;
157
+ get writeVersion(): number;
158
+ get minorVersion(): number;
159
+ /** Reflects the `HiddenSchema` custom attribute from `CoreCustomAttributes`.
160
+ * Schemas marked hidden are typically excluded from UI display but remain accessible programmatically. */
161
+ get isHidden(): boolean;
162
+ /** "SchemaName.RR.WW.mm" - dot-separated, matching the EC schema versioning convention. */
163
+ get fullName(): string;
164
+ /** Find a class by name within this schema (case-insensitive). */
165
+ getClass(name: string): Class | undefined;
166
+ /** Iterate classes in this schema. Pass a `ClassType` to filter to a single kind
167
+ * (e.g. `getClasses(ClassType.View)`). Omit the argument to iterate every class
168
+ * regardless of type.
169
+ */
170
+ getClasses(filter?: ClassType): IterableIterator<Class>;
171
+ /** Find an enumeration by name within this schema (case-insensitive). */
172
+ getEnumeration(name: string): Enumeration | undefined;
173
+ /** Find a KindOfQuantity by name within this schema (case-insensitive). */
174
+ getKindOfQuantity(name: string): KindOfQuantity | undefined;
175
+ /** Find a PropertyCategory by name within this schema (case-insensitive). */
176
+ getPropertyCategory(name: string): PropertyCategory | undefined;
177
+ /** Iterate all enumerations in this schema. */
178
+ getEnumerations(): IterableIterator<Enumeration>;
179
+ /** Iterate all KindOfQuantity items in this schema. */
180
+ getKindOfQuantities(): IterableIterator<KindOfQuantity>;
181
+ /** Iterate all PropertyCategory items in this schema. */
182
+ getPropertyCategories(): IterableIterator<PropertyCategory>;
183
+ }
184
+ /** Lightweight view over a class in a `SchemaView`. For relationship-specific
185
+ * fields (strength, direction, source/target constraints), narrow via `isRelationship()`
186
+ * or `assertRelationship()` to get a `SchemaView.RelationshipClass`.
187
+ * @beta
188
+ */
189
+ class Class {
190
+ protected readonly _ctx: SchemaView;
191
+ /** @internal */ readonly idx: number;
192
+ /** @internal */
193
+ constructor(_ctx: SchemaView,
194
+ /** @internal */ idx: number);
195
+ /** @internal */
196
+ protected get _data(): ClassData;
197
+ /** Row ID from ec_Class. Matches `ECInstanceId` in ECDbMeta views, e.g.
198
+ * `SELECT * FROM meta.ECClassDef WHERE ECInstanceId = ?`.
199
+ */
200
+ get ecInstanceId(): number;
201
+ get name(): string;
202
+ get label(): string;
203
+ get description(): string;
204
+ /** "SchemaName:ClassName" - colon-separated, matching the EC class full name convention.
205
+ * Use either ":" or "." as separator when passing to `findClass()`. */
206
+ get fullName(): string;
207
+ get schema(): Schema;
208
+ get type(): ClassType;
209
+ get modifier(): ClassModifier;
210
+ isEntity(): boolean;
211
+ /** Type predicate - narrows to `SchemaView.RelationshipClass` for access to strength, direction,
212
+ * source, and target constraint fields. */
213
+ isRelationship(): this is RelationshipClass;
214
+ isStruct(): boolean;
215
+ isMixin(): boolean;
216
+ isCustomAttribute(): boolean;
217
+ isView(): boolean;
218
+ /** @see isRelationship */
219
+ assertRelationship(): asserts this is RelationshipClass;
220
+ get isAbstract(): boolean;
221
+ get isSealed(): boolean;
222
+ /** Reflects the `HiddenClass` custom attribute from `CoreCustomAttributes`.
223
+ * Returns `true` when this class is directly hidden (via `HiddenClass(Show!=true)` or
224
+ * schema-level `HiddenSchema(ShowClasses!=true)`). Does NOT consider base class inheritance -
225
+ * use `isEffectivelyHidden` for that.
226
+ *
227
+ * Note: `false` means explicitly shown via `HiddenClass(Show=true)`. `undefined` means
228
+ * no `HiddenClass` CA and the schema does not hide its classes. Both are "not hidden" for
229
+ * this property, but `isEffectivelyHidden` distinguishes them when walking the hierarchy. */
230
+ get isHidden(): boolean | undefined;
231
+ /** Computed hidden status that walks the base class chain (not mixins).
232
+ *
233
+ * Returns `true` if this class is hidden or any ancestor in the base class chain is hidden,
234
+ * unless this class or an intermediate class explicitly breaks the chain with
235
+ * `HiddenClass(Show=true)` (i.e. `isHidden === false`).
236
+ *
237
+ * Mixins are intentionally excluded - a hidden mixin represents a hidden capability,
238
+ * not a hidden identity. */
239
+ get isEffectivelyHidden(): boolean;
240
+ /** Single base class. undefined for root classes. */
241
+ get baseClass(): Class | undefined;
242
+ /** Applied mixins in declaration order. Only meaningful for entity classes. */
243
+ get mixins(): readonly Class[];
244
+ /** IS-A check. Returns true if this class is, or derives from, `other` (transitively, including mixins).
245
+ * Accepts a `SchemaView.Class` or a qualified name string ("SchemaName:ClassName").
246
+ */
247
+ is(classOrName: Class | string): boolean;
248
+ /** Direct derived classes. Expensive on first call (builds reverse map across all classes). */
249
+ get derivedClasses(): readonly Class[];
250
+ /** Find a property by name (case-insensitive). Searches own + inherited.
251
+ *
252
+ * Note: this resolves the full property list and linear-scans it on every call. For workloads
253
+ * that hit `getProperty` repeatedly on the same class with different names, a per-class
254
+ * resolved-property map cache could be added on the view. Not done now - measure before
255
+ * optimizing. */
256
+ getProperty(name: string): Property | undefined;
257
+ /** All properties including inherited, in inheritance order (base first, then mixins, then own). */
258
+ getProperties(): readonly Property[];
259
+ /** Own properties only (not inherited), in ordinal order. */
260
+ getOwnProperties(): readonly Property[];
261
+ }
262
+ /** A relationship class with constraint and strength metadata. Created by `createClass()`
263
+ * when the underlying `ClassType` is `Relationship`. Use `cls.isRelationship()` to narrow a
264
+ * `SchemaView.Class` to this type.
265
+ * @beta
266
+ */
267
+ class RelationshipClass extends Class {
268
+ get strength(): StrengthType;
269
+ get strengthDirection(): StrengthDirection;
270
+ get source(): RelConstraint | undefined;
271
+ get target(): RelConstraint | undefined;
272
+ }
273
+ /** @internal */
274
+ function createClass(ctx: SchemaView, idx: number): Class;
275
+ /** Lightweight view over a property in a `SchemaView`. Subclasses provide
276
+ * type-safe access to kind-specific fields. Use `isPrimitive()`, `isStruct()`,
277
+ * `isArray()`, or `isNavigation()` to narrow, or the corresponding `assert*()` methods.
278
+ * @beta
279
+ */
280
+ abstract class Property {
281
+ protected readonly _ctx: SchemaView;
282
+ private readonly _ref;
283
+ /** Index of the class that declared or contributed this property through inheritance.
284
+ * For own properties, this is the class itself. For inherited properties, this is the
285
+ * base class or mixin that introduced it. -1 for view properties. */
286
+ private readonly _classIdx;
287
+ /** @internal */
288
+ constructor(_ctx: SchemaView, _ref: PropertyRef,
289
+ /** Index of the class that declared or contributed this property through inheritance.
290
+ * For own properties, this is the class itself. For inherited properties, this is the
291
+ * base class or mixin that introduced it. -1 for view properties. */
292
+ _classIdx: number);
293
+ /** @internal */
294
+ protected get _def(): PropertyDef;
295
+ /** Row ID from ec_Property. Matches `ECInstanceId` in ECDbMeta views, e.g.
296
+ * `SELECT * FROM meta.ECPropertyDef WHERE ECInstanceId = ?`.
297
+ *
298
+ * Stored per-reference (not per-definition) because each class-property pair has a unique
299
+ * ec_Property row even when the structural definition is deduplicated.
300
+ */
301
+ get ecInstanceId(): number;
302
+ get name(): string;
303
+ /** Display label. Falls back to the property name if no explicit label is set.
304
+ * Labels are stored per-reference (not per-definition) because EC allows class overrides. */
305
+ get label(): string;
306
+ get description(): string;
307
+ get kind(): PropertyKind;
308
+ get isReadOnly(): boolean;
309
+ /** Reflects the `HiddenProperty` custom attribute from `CoreCustomAttributes`.
310
+ * Properties marked hidden are typically excluded from UI display but remain accessible programmatically. */
311
+ get isHidden(): boolean;
312
+ /** Display priority. Higher values should be displayed more prominently. 0 means default. */
313
+ get priority(): number;
314
+ /** The class that declared or contributed this property through inheritance.
315
+ * For own properties, returns the class itself. For inherited properties, returns the
316
+ * base class or mixin that introduced it. Returns `undefined` for view properties.
317
+ * This is the class array index, not the ec_Class.Id from the database.
318
+ * @beta
319
+ */
320
+ get declaringClass(): Class | undefined;
321
+ /** Property category, or undefined if none assigned. Available on all property kinds. */
322
+ get category(): PropertyCategory | undefined;
323
+ /** True for `SchemaView.PrimitiveProperty` and `SchemaView.PrimitiveArrayProperty`.
324
+ * Matches ecschema-metadata behavior where `isPrimitive()` includes primitive arrays. */
325
+ isPrimitive(): this is AnyPrimitiveProperty;
326
+ /** True for `SchemaView.StructProperty` and `SchemaView.StructArrayProperty`. */
327
+ isStruct(): this is AnyStructProperty;
328
+ /** True for `SchemaView.PrimitiveArrayProperty` and `SchemaView.StructArrayProperty`. */
329
+ isArray(): this is AnyArrayProperty;
330
+ /** True for `SchemaView.NavigationProperty`. */
331
+ isNavigation(): this is NavigationProperty;
332
+ /** True if this property is backed by an enumeration. Enumerations are a facet of primitive
333
+ * properties - an enum property IS a primitive property with an enum binding. Narrows to
334
+ * `AnyPrimitiveProperty` so you can access `enumeration`, `primitiveType`, etc. */
335
+ isEnumeration(): this is AnyPrimitiveProperty;
336
+ /** @see isPrimitive */
337
+ assertPrimitive(): asserts this is AnyPrimitiveProperty;
338
+ /** @see isStruct */
339
+ assertStruct(): asserts this is AnyStructProperty;
340
+ /** @see isArray */
341
+ assertArray(): asserts this is AnyArrayProperty;
342
+ /** @see isNavigation */
343
+ assertNavigation(): asserts this is NavigationProperty;
344
+ }
345
+ /** A scalar primitive property. May optionally be backed by an enumeration -
346
+ * check `isEnumeration()` or `enumeration`.
347
+ * @beta
348
+ */
349
+ class PrimitiveProperty extends Property {
350
+ get primitiveType(): SchemaViewPrimitiveType;
351
+ get extendedTypeName(): string | undefined;
352
+ get enumeration(): Enumeration | undefined;
353
+ get kindOfQuantity(): KindOfQuantity | undefined;
354
+ }
355
+ /** An array of primitive values. Same primitive/enum fields as `PrimitiveProperty`,
356
+ * plus array bounds.
357
+ * @beta
358
+ */
359
+ class PrimitiveArrayProperty extends Property {
360
+ get primitiveType(): SchemaViewPrimitiveType;
361
+ get extendedTypeName(): string | undefined;
362
+ get enumeration(): Enumeration | undefined;
363
+ get kindOfQuantity(): KindOfQuantity | undefined;
364
+ get arrayMinOccurs(): number | undefined;
365
+ get arrayMaxOccurs(): number | undefined;
366
+ }
367
+ /** A scalar struct property. `structClass` is non-nullable - the binary parser drops
368
+ * properties whose struct class can't be resolved (e.g. from excluded schemas).
369
+ * @beta
370
+ */
371
+ class StructProperty extends Property {
372
+ get structClass(): Class;
373
+ }
374
+ /** An array of struct values. Same struct field as `StructProperty`, plus array bounds.
375
+ * @beta
376
+ */
377
+ class StructArrayProperty extends Property {
378
+ get structClass(): Class;
379
+ get arrayMinOccurs(): number | undefined;
380
+ get arrayMaxOccurs(): number | undefined;
381
+ }
382
+ /** A navigation property. `relationshipClass` is non-nullable - the binary parser drops
383
+ * properties whose relationship class can't be resolved.
384
+ * @beta
385
+ */
386
+ class NavigationProperty extends Property {
387
+ get direction(): StrengthDirection;
388
+ get relationshipClass(): RelationshipClass;
389
+ }
390
+ /** Any primitive property (scalar or array). Useful for accessing `primitiveType`,
391
+ * `extendedTypeName`, `enumeration`, `kindOfQuantity` after an `isPrimitive()` check.
392
+ * @beta
393
+ */
394
+ type AnyPrimitiveProperty = PrimitiveProperty | PrimitiveArrayProperty;
395
+ /** Any struct property (scalar or array). Useful for accessing `structClass` after an `isStruct()` check.
396
+ * @beta
397
+ */
398
+ type AnyStructProperty = StructProperty | StructArrayProperty;
399
+ /** Any array property (primitive or struct). Useful for accessing `arrayMinOccurs`/`arrayMaxOccurs`
400
+ * after an `isArray()` check.
401
+ * @beta
402
+ */
403
+ type AnyArrayProperty = PrimitiveArrayProperty | StructArrayProperty;
404
+ /** Union of all concrete property types.
405
+ * @beta
406
+ */
407
+ type AnyProperty = PrimitiveProperty | PrimitiveArrayProperty | StructProperty | StructArrayProperty | NavigationProperty;
408
+ /** @internal */
409
+ function createProperty(ctx: SchemaView, ref: PropertyRef, classIdx: number): Property;
410
+ /** Lightweight view over an enumeration in a `SchemaView`.
411
+ * @beta
412
+ */
413
+ class Enumeration {
414
+ private readonly _ctx;
415
+ /** @internal */ readonly idx: number;
416
+ /** @internal */
417
+ constructor(_ctx: SchemaView,
418
+ /** @internal */ idx: number);
419
+ private get _data();
420
+ /** Row ID from ec_Enumeration. Matches `ECInstanceId` in ECDbMeta views, e.g.
421
+ * `SELECT * FROM meta.ECEnumerationDef WHERE ECInstanceId = ?`.
422
+ */
423
+ get ecInstanceId(): number;
424
+ get name(): string;
425
+ get label(): string;
426
+ get description(): string;
427
+ /** "SchemaName:EnumName" - colon-separated. */
428
+ get fullName(): string;
429
+ get schema(): Schema;
430
+ get primitiveType(): SchemaViewPrimitiveType;
431
+ get isStrict(): boolean;
432
+ /** Iterate enumerators in declaration order. */
433
+ getEnumerators(): IterableIterator<Enumerator>;
434
+ /** Find enumerator by name (case-insensitive). */
435
+ getEnumeratorByName(name: string): Enumerator | undefined;
436
+ /** Find enumerator by value. */
437
+ getEnumerator(value: number | string): Enumerator | undefined;
438
+ }
439
+ /** Thin view over an enumerator.
440
+ * @beta
441
+ */
442
+ class Enumerator {
443
+ private readonly _ctx;
444
+ /** @internal */ readonly idx: number;
445
+ /** @internal */
446
+ constructor(_ctx: SchemaView,
447
+ /** @internal */ idx: number);
448
+ private get _data();
449
+ get name(): string;
450
+ get label(): string;
451
+ get description(): string;
452
+ get value(): number | string;
453
+ }
454
+ /** A parsed presentation format override from a KindOfQuantity. Names are alias-qualified
455
+ * as stored in ECDb (e.g. `"f:DefaultRealU"`, `"u:M"`). The alias can be resolved to a
456
+ * full schema name via the schema's alias if needed.
457
+ *
458
+ * Format string syntax: `formatName(precision)[unitName|label][unitName|label]...`
459
+ * @beta
460
+ */
461
+ interface PresentationFormat {
462
+ /** Format name (alias-qualified), e.g. `"f:DefaultRealU"`. */
463
+ readonly name: string;
464
+ /** Precision override. `undefined` if the format string does not override precision. */
465
+ readonly precision?: number;
466
+ /** Unit overrides as `[unitName, labelOverride]` tuples. `unitName` is alias-qualified
467
+ * (e.g. `"u:M"`). `labelOverride` is `undefined` when no label was specified, or a
468
+ * string (possibly empty) when a `|` separator was present.
469
+ */
470
+ readonly unitAndLabels?: ReadonlyArray<readonly [string, string | undefined]>;
471
+ }
472
+ /** Parse a single format override string into a `PresentationFormat`.
473
+ * @internal
474
+ */
475
+ function parseFormatString(formatString: string): PresentationFormat;
476
+ /** Lightweight view over a KindOfQuantity in a `SchemaView`.
477
+ * @beta
478
+ */
479
+ class KindOfQuantity {
480
+ private readonly _ctx;
481
+ /** @internal */ readonly idx: number;
482
+ /** @internal */
483
+ constructor(_ctx: SchemaView,
484
+ /** @internal */ idx: number);
485
+ private get _data();
486
+ /** Row ID from ec_KindOfQuantity. Matches `ECInstanceId` in ECDbMeta views, e.g.
487
+ * `SELECT * FROM meta.ECKindOfQuantityDef WHERE ECInstanceId = ?`.
488
+ */
489
+ get ecInstanceId(): number;
490
+ get name(): string;
491
+ get label(): string;
492
+ get description(): string;
493
+ /** "SchemaName:KoqName" - colon-separated. */
494
+ get fullName(): string;
495
+ get schema(): Schema;
496
+ get relativeError(): number;
497
+ /** Persistence unit as a full name string, e.g. "Units:M".
498
+ *
499
+ * On iModels still on ECDb profile `4.0.0.1` (predates the 2018 EC3.2 Units/Formats migration)
500
+ * this string is in legacy FUS format rather than the EC3.2 alias-qualified form.
501
+ * Upgrade the iModel's ECDb profile to get EC3.2 strings.
502
+ */
503
+ get persistenceUnit(): string;
504
+ /** Raw presentation format string as stored in ECDb (`ec_KindOfQuantity.PresentationUnits`).
505
+ * This is a JSON array of format override strings. Empty string if none are defined.
506
+ * Prefer `presentationFormats` for structured access.
507
+ *
508
+ * On iModels still on ECDb profile `4.0.0.1` (predates the 2018 EC3.2 Units/Formats migration)
509
+ * the strings are in legacy FUS format and will not parse via `presentationFormats`.
510
+ * Upgrade the iModel's ECDb profile to get EC3.2 strings.
511
+ */
512
+ get presentationFormatsRaw(): string;
513
+ /** Presentation formats parsed into structured overrides. Each entry has the format name
514
+ * (alias-qualified, e.g. `"f:DefaultRealU"`), optional precision override, and optional
515
+ * unit-and-label overrides. Returns an empty array if no presentation formats are defined.
516
+ *
517
+ * Example - given a raw string of `["f:DefaultRealU(4)[u:M_PER_SEC_SQ]","f:DefaultRealU(4)[u:CM_PER_SEC_SQ]"]`:
518
+ * ```ts
519
+ * // [
520
+ * // { name: "f:DefaultRealU", precision: 4, unitAndLabels: [["u:M_PER_SEC_SQ", undefined]] },
521
+ * // { name: "f:DefaultRealU", precision: 4, unitAndLabels: [["u:CM_PER_SEC_SQ", undefined]] },
522
+ * // ]
523
+ * ```
524
+ */
525
+ get presentationFormats(): readonly PresentationFormat[];
526
+ }
527
+ /** Lightweight view over a PropertyCategory in a `SchemaView`.
528
+ * @beta
529
+ */
530
+ class PropertyCategory {
531
+ private readonly _ctx;
532
+ /** @internal */ readonly idx: number;
533
+ /** @internal */
534
+ constructor(_ctx: SchemaView,
535
+ /** @internal */ idx: number);
536
+ private get _data();
537
+ /** Row ID from ec_PropertyCategory. Matches `ECInstanceId` in ECDbMeta views, e.g.
538
+ * `SELECT * FROM meta.ECPropertyCategoryDef WHERE ECInstanceId = ?`.
539
+ */
540
+ get ecInstanceId(): number;
541
+ get name(): string;
542
+ get label(): string;
543
+ get description(): string;
544
+ /** "SchemaName:CategoryName" - colon-separated. */
545
+ get fullName(): string;
546
+ get schema(): Schema;
547
+ get priority(): number;
548
+ }
549
+ /** Lightweight view over a relationship constraint in a `SchemaView`.
550
+ * @beta
551
+ */
552
+ class RelConstraint {
553
+ private readonly _ctx;
554
+ private readonly _idx;
555
+ /** @internal */
556
+ constructor(_ctx: SchemaView, _idx: number);
557
+ private get _data();
558
+ get abstractConstraint(): Class | undefined;
559
+ get polymorphic(): boolean;
560
+ /** Multiplicity lower bound (0 = unbounded). */
561
+ get multiplicityLower(): number;
562
+ /** Multiplicity upper bound (0 = unbounded). */
563
+ get multiplicityUpper(): number;
564
+ /** Role label string, or empty if not set. */
565
+ get roleLabel(): string;
566
+ get constraintClasses(): readonly Class[];
567
+ }
568
+ }
569
+ /** Builder for constructing an immutable `SchemaView`.
570
+ *
571
+ * Collects data during binary blob parsing, then freezes it into a view.
572
+ * Handles string interning and property definition deduplication.
573
+ *
574
+ * Consumers should not use this directly - read views via `IModelDb.getSchemaView`
575
+ * / `IModelConnection.getSchemaView` (or `SchemaView.fromBinary` if you have a raw blob).
576
+ * @internal
577
+ */
578
+ export declare class SchemaViewBuilder {
579
+ private readonly _strings;
580
+ private readonly _lowerStrings;
581
+ private readonly _stringMap;
582
+ private readonly _schemas;
583
+ private readonly _classes;
584
+ private readonly _classMixins;
585
+ private readonly _propDefs;
586
+ private readonly _propertyRefs;
587
+ private readonly _relConstraints;
588
+ private readonly _constraintClassRefs;
589
+ private readonly _enumerations;
590
+ private readonly _enumerators;
591
+ private readonly _koqs;
592
+ private readonly _propCategories;
593
+ private readonly _propDefMap;
594
+ /** Intern a string, returning its SID. Empty/undefined strings return 0.
595
+ * Interning is case-sensitive - "MyLabel" and "MYLABEL" get distinct SIDs.
596
+ * The `lowerStrings` array provides case-insensitive lookup without mutating display values.
597
+ */
598
+ internString(value: string | undefined): number;
599
+ /** Add a schema. Returns its index. */
600
+ addSchema(data: SchemaData): number;
601
+ /** Add a class. Returns its index. Must be called after the owning schema. */
602
+ addClass(data: ClassData): number;
603
+ /** Add a property definition with deduplication. Returns the def index (possibly existing). */
604
+ addPropertyDef(data: PropertyDef): number;
605
+ /** Append a property reference to the flat refs array. */
606
+ addPropertyRef(ref: PropertyRef): void;
607
+ /** Add an enumeration. Returns its index. */
608
+ addEnumeration(data: EnumerationData): number;
609
+ /** Append an enumerator to the flat enumerators array. */
610
+ addEnumerator(data: EnumeratorData): void;
611
+ /** Add a KindOfQuantity. Returns its index. */
612
+ addKoq(data: KoqData): number;
613
+ /** Add a PropertyCategory. Returns its index. */
614
+ addPropertyCategory(data: PropCategoryData): number;
615
+ /** Add a relationship constraint. Returns its index. */
616
+ addRelConstraint(data: RelConstraintData): number;
617
+ /** Append a constraint class reference to the flat array. */
618
+ addConstraintClassRef(classIdx: number): void;
619
+ /** Append a mixin class reference to the flat array. */
620
+ addClassMixin(classIdx: number): void;
621
+ /** The current count of property refs (used to set ownPropStart on ClassData). */
622
+ get propertyRefCount(): number;
623
+ /** The current count of enumerators (used to set enumeratorStart on EnumerationData). */
624
+ get enumeratorCount(): number;
625
+ /** The current count of constraint class refs (used to set classRefStart). */
626
+ get constraintClassRefCount(): number;
627
+ /** The current count of class mixins (used to set mixinStartIdx). */
628
+ get classMixinCount(): number;
629
+ /** Get a string by SID. @internal */
630
+ getString(sid: number): string;
631
+ /** Replace class data at the given index (used during deferred cross-ref resolution). @internal */
632
+ updateClass(classIdx: number, data: ClassData): void;
633
+ /** Update range fields on a schema (used after all items for a schema are collected). @internal */
634
+ updateSchemaRanges(schemaIdx: number, ranges: {
635
+ classRangeStart: number;
636
+ classCount: number;
637
+ enumRangeStart: number;
638
+ enumCount: number;
639
+ koqRangeStart: number;
640
+ koqCount: number;
641
+ catRangeStart: number;
642
+ catCount: number;
643
+ }): void;
644
+ /** Freeze all data and produce an immutable SchemaView. */
645
+ build(schemaToken?: string): SchemaView;
646
+ /** Produce a dedup signature for a PropertyDef. Label and priority are excluded because
647
+ * they are per-PropertyRef overrides, not part of the structural definition.
648
+ * Uses SIDs (not lowercase strings) for name/description so that case-preserving names
649
+ * stay distinct - matching the C++ writer's dedup behavior. */
650
+ private _propDefSignature;
651
+ }
652
+ export {};
653
+ //# sourceMappingURL=SchemaView.d.ts.map