@itwin/presentation-shared 0.1.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.
- package/CHANGELOG.md +7 -0
- package/LICENSE.md +9 -0
- package/README.md +434 -0
- package/lib/cjs/presentation-shared.d.ts +13 -0
- package/lib/cjs/presentation-shared.d.ts.map +1 -0
- package/lib/cjs/presentation-shared.js +58 -0
- package/lib/cjs/presentation-shared.js.map +1 -0
- package/lib/cjs/shared/ConcatenatedValue.d.ts +47 -0
- package/lib/cjs/shared/ConcatenatedValue.d.ts.map +1 -0
- package/lib/cjs/shared/ConcatenatedValue.js +45 -0
- package/lib/cjs/shared/ConcatenatedValue.js.map +1 -0
- package/lib/cjs/shared/ECSqlCore.d.ts +91 -0
- package/lib/cjs/shared/ECSqlCore.d.ts.map +1 -0
- package/lib/cjs/shared/ECSqlCore.js +7 -0
- package/lib/cjs/shared/ECSqlCore.js.map +1 -0
- package/lib/cjs/shared/Event.d.ts +9 -0
- package/lib/cjs/shared/Event.d.ts.map +1 -0
- package/lib/cjs/shared/Event.js +7 -0
- package/lib/cjs/shared/Event.js.map +1 -0
- package/lib/cjs/shared/Formatting.d.ts +39 -0
- package/lib/cjs/shared/Formatting.d.ts.map +1 -0
- package/lib/cjs/shared/Formatting.js +132 -0
- package/lib/cjs/shared/Formatting.js.map +1 -0
- package/lib/cjs/shared/InstanceLabelSelectClauseFactory.d.ts +129 -0
- package/lib/cjs/shared/InstanceLabelSelectClauseFactory.d.ts.map +1 -0
- package/lib/cjs/shared/InstanceLabelSelectClauseFactory.js +167 -0
- package/lib/cjs/shared/InstanceLabelSelectClauseFactory.js.map +1 -0
- package/lib/cjs/shared/InternalUtils.d.ts +3 -0
- package/lib/cjs/shared/InternalUtils.d.ts.map +1 -0
- package/lib/cjs/shared/InternalUtils.js +14 -0
- package/lib/cjs/shared/InternalUtils.js.map +1 -0
- package/lib/cjs/shared/Logging.d.ts +27 -0
- package/lib/cjs/shared/Logging.d.ts.map +1 -0
- package/lib/cjs/shared/Logging.js +20 -0
- package/lib/cjs/shared/Logging.js.map +1 -0
- package/lib/cjs/shared/MappedTypes.d.ts +11 -0
- package/lib/cjs/shared/MappedTypes.d.ts.map +1 -0
- package/lib/cjs/shared/MappedTypes.js +7 -0
- package/lib/cjs/shared/MappedTypes.js.map +1 -0
- package/lib/cjs/shared/Metadata.d.ts +268 -0
- package/lib/cjs/shared/Metadata.d.ts.map +1 -0
- package/lib/cjs/shared/Metadata.js +54 -0
- package/lib/cjs/shared/Metadata.js.map +1 -0
- package/lib/cjs/shared/Utils.d.ts +26 -0
- package/lib/cjs/shared/Utils.d.ts.map +1 -0
- package/lib/cjs/shared/Utils.js +50 -0
- package/lib/cjs/shared/Utils.js.map +1 -0
- package/lib/cjs/shared/Values.d.ts +119 -0
- package/lib/cjs/shared/Values.d.ts.map +1 -0
- package/lib/cjs/shared/Values.js +156 -0
- package/lib/cjs/shared/Values.js.map +1 -0
- package/lib/cjs/shared/ecsql-snippets/ECSqlJoinSnippets.d.ts +48 -0
- package/lib/cjs/shared/ecsql-snippets/ECSqlJoinSnippets.d.ts.map +1 -0
- package/lib/cjs/shared/ecsql-snippets/ECSqlJoinSnippets.js +139 -0
- package/lib/cjs/shared/ecsql-snippets/ECSqlJoinSnippets.js.map +1 -0
- package/lib/cjs/shared/ecsql-snippets/ECSqlValueSelectorSnippets.d.ts +116 -0
- package/lib/cjs/shared/ecsql-snippets/ECSqlValueSelectorSnippets.d.ts.map +1 -0
- package/lib/cjs/shared/ecsql-snippets/ECSqlValueSelectorSnippets.js +244 -0
- package/lib/cjs/shared/ecsql-snippets/ECSqlValueSelectorSnippets.js.map +1 -0
- package/lib/cjs/shared/ecsql-snippets/index.d.ts +3 -0
- package/lib/cjs/shared/ecsql-snippets/index.d.ts.map +1 -0
- package/lib/cjs/shared/ecsql-snippets/index.js +16 -0
- package/lib/cjs/shared/ecsql-snippets/index.js.map +1 -0
- package/lib/esm/presentation-shared.d.ts +13 -0
- package/lib/esm/presentation-shared.d.ts.map +1 -0
- package/lib/esm/presentation-shared.js +15 -0
- package/lib/esm/presentation-shared.js.map +1 -0
- package/lib/esm/shared/ConcatenatedValue.d.ts +47 -0
- package/lib/esm/shared/ConcatenatedValue.d.ts.map +1 -0
- package/lib/esm/shared/ConcatenatedValue.js +42 -0
- package/lib/esm/shared/ConcatenatedValue.js.map +1 -0
- package/lib/esm/shared/ECSqlCore.d.ts +91 -0
- package/lib/esm/shared/ECSqlCore.d.ts.map +1 -0
- package/lib/esm/shared/ECSqlCore.js +6 -0
- package/lib/esm/shared/ECSqlCore.js.map +1 -0
- package/lib/esm/shared/Event.d.ts +9 -0
- package/lib/esm/shared/Event.d.ts.map +1 -0
- package/lib/esm/shared/Event.js +6 -0
- package/lib/esm/shared/Event.js.map +1 -0
- package/lib/esm/shared/Formatting.d.ts +39 -0
- package/lib/esm/shared/Formatting.d.ts.map +1 -0
- package/lib/esm/shared/Formatting.js +127 -0
- package/lib/esm/shared/Formatting.js.map +1 -0
- package/lib/esm/shared/InstanceLabelSelectClauseFactory.d.ts +129 -0
- package/lib/esm/shared/InstanceLabelSelectClauseFactory.d.ts.map +1 -0
- package/lib/esm/shared/InstanceLabelSelectClauseFactory.js +160 -0
- package/lib/esm/shared/InstanceLabelSelectClauseFactory.js.map +1 -0
- package/lib/esm/shared/InternalUtils.d.ts +3 -0
- package/lib/esm/shared/InternalUtils.d.ts.map +1 -0
- package/lib/esm/shared/InternalUtils.js +10 -0
- package/lib/esm/shared/InternalUtils.js.map +1 -0
- package/lib/esm/shared/Logging.d.ts +27 -0
- package/lib/esm/shared/Logging.d.ts.map +1 -0
- package/lib/esm/shared/Logging.js +17 -0
- package/lib/esm/shared/Logging.js.map +1 -0
- package/lib/esm/shared/MappedTypes.d.ts +11 -0
- package/lib/esm/shared/MappedTypes.d.ts.map +1 -0
- package/lib/esm/shared/MappedTypes.js +6 -0
- package/lib/esm/shared/MappedTypes.js.map +1 -0
- package/lib/esm/shared/Metadata.d.ts +268 -0
- package/lib/esm/shared/Metadata.d.ts.map +1 -0
- package/lib/esm/shared/Metadata.js +49 -0
- package/lib/esm/shared/Metadata.js.map +1 -0
- package/lib/esm/shared/Utils.d.ts +26 -0
- package/lib/esm/shared/Utils.d.ts.map +1 -0
- package/lib/esm/shared/Utils.js +44 -0
- package/lib/esm/shared/Utils.js.map +1 -0
- package/lib/esm/shared/Values.d.ts +119 -0
- package/lib/esm/shared/Values.d.ts.map +1 -0
- package/lib/esm/shared/Values.js +153 -0
- package/lib/esm/shared/Values.js.map +1 -0
- package/lib/esm/shared/ecsql-snippets/ECSqlJoinSnippets.d.ts +48 -0
- package/lib/esm/shared/ecsql-snippets/ECSqlJoinSnippets.d.ts.map +1 -0
- package/lib/esm/shared/ecsql-snippets/ECSqlJoinSnippets.js +135 -0
- package/lib/esm/shared/ecsql-snippets/ECSqlJoinSnippets.js.map +1 -0
- package/lib/esm/shared/ecsql-snippets/ECSqlValueSelectorSnippets.d.ts +116 -0
- package/lib/esm/shared/ecsql-snippets/ECSqlValueSelectorSnippets.d.ts.map +1 -0
- package/lib/esm/shared/ecsql-snippets/ECSqlValueSelectorSnippets.js +236 -0
- package/lib/esm/shared/ecsql-snippets/ECSqlValueSelectorSnippets.js.map +1 -0
- package/lib/esm/shared/ecsql-snippets/index.d.ts +3 -0
- package/lib/esm/shared/ecsql-snippets/index.d.ts.map +1 -0
- package/lib/esm/shared/ecsql-snippets/index.js +7 -0
- package/lib/esm/shared/ecsql-snippets/index.js.map +1 -0
- package/package.json +59 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InternalUtils.js","sourceRoot":"","sources":["../../../src/shared/InternalUtils.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,gBAAgB;AAChB,SAAgB,gBAAgB,CAAC,UAAkB;IACjD,MAAM,MAAM,GAAG,CAAC,UAAU,GAAG,SAAS,CAAC,GAAG,QAAQ,CAAC;IACnD,OAAO,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC;AAC1B,CAAC;AAHD,4CAGC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defines a type for a logging function.
|
|
3
|
+
* @beta
|
|
4
|
+
*/
|
|
5
|
+
export type LogFunction = (category: string, message: string) => void;
|
|
6
|
+
/**
|
|
7
|
+
* Defines logging severities.
|
|
8
|
+
* @beta
|
|
9
|
+
*/
|
|
10
|
+
export type LogLevel = "error" | "warning" | "info" | "trace";
|
|
11
|
+
/**
|
|
12
|
+
* An interface for a logger used by presentation packages.
|
|
13
|
+
* @beta
|
|
14
|
+
*/
|
|
15
|
+
export interface ILogger {
|
|
16
|
+
isEnabled: (category: string, level: LogLevel) => boolean;
|
|
17
|
+
logError: LogFunction;
|
|
18
|
+
logWarning: LogFunction;
|
|
19
|
+
logInfo: LogFunction;
|
|
20
|
+
logTrace: LogFunction;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A logger implementation that does nothing.
|
|
24
|
+
* @beta
|
|
25
|
+
*/
|
|
26
|
+
export declare const NOOP_LOGGER: ILogger;
|
|
27
|
+
//# sourceMappingURL=Logging.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Logging.d.ts","sourceRoot":"","sources":["../../../src/shared/Logging.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;AAEtE;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;AAE9D;;;GAGG;AACH,MAAM,WAAW,OAAO;IACtB,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,KAAK,OAAO,CAAC;IAC1D,QAAQ,EAAE,WAAW,CAAC;IACtB,UAAU,EAAE,WAAW,CAAC;IACxB,OAAO,EAAE,WAAW,CAAC;IACrB,QAAQ,EAAE,WAAW,CAAC;CACvB;AAED;;;GAGG;AAEH,eAAO,MAAM,WAAW,EAAE,OAMzB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.NOOP_LOGGER = void 0;
|
|
8
|
+
/**
|
|
9
|
+
* A logger implementation that does nothing.
|
|
10
|
+
* @beta
|
|
11
|
+
*/
|
|
12
|
+
// istanbul ignore next
|
|
13
|
+
exports.NOOP_LOGGER = {
|
|
14
|
+
isEnabled: () => false,
|
|
15
|
+
logError: () => { },
|
|
16
|
+
logWarning: () => { },
|
|
17
|
+
logInfo: () => { },
|
|
18
|
+
logTrace: () => { },
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=Logging.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Logging.js","sourceRoot":"","sources":["../../../src/shared/Logging.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AA0BhG;;;GAGG;AACH,uBAAuB;AACV,QAAA,WAAW,GAAY;IAClC,SAAS,EAAE,GAAG,EAAE,CAAC,KAAK;IACtB,QAAQ,EAAE,GAAG,EAAE,GAAE,CAAC;IAClB,UAAU,EAAE,GAAG,EAAE,GAAE,CAAC;IACpB,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC;IACjB,QAAQ,EAAE,GAAG,EAAE,GAAE,CAAC;CACnB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An utility `Omit` type which works with union types.
|
|
3
|
+
* @beta
|
|
4
|
+
*/
|
|
5
|
+
export type OmitOverUnion<T, K extends PropertyKey> = T extends T ? Omit<T, K> : never;
|
|
6
|
+
/**
|
|
7
|
+
* An utility generic type to get array element's type.
|
|
8
|
+
* @beta
|
|
9
|
+
*/
|
|
10
|
+
export type ArrayElement<ArrayType extends readonly unknown[]> = ArrayType extends readonly (infer ElementType)[] ? ElementType : never;
|
|
11
|
+
//# sourceMappingURL=MappedTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MappedTypes.d.ts","sourceRoot":"","sources":["../../../src/shared/MappedTypes.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,MAAM,MAAM,aAAa,CAAC,CAAC,EAAE,CAAC,SAAS,WAAW,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC;AAEvF;;;GAGG;AACH,MAAM,MAAM,YAAY,CAAC,SAAS,SAAS,SAAS,OAAO,EAAE,IAAI,SAAS,SAAS,SAAS,CAAC,MAAM,WAAW,CAAC,EAAE,GAAG,WAAW,GAAG,KAAK,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
//# sourceMappingURL=MappedTypes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MappedTypes.js","sourceRoot":"","sources":["../../../src/shared/MappedTypes.ts"],"names":[],"mappings":";AAAA;;;gGAGgG"}
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An interface for an object that knows how to get an ECSchema from an iModel.
|
|
3
|
+
*
|
|
4
|
+
* @see `createECSchemaProvider` in `@itwin/presentation-core-interop`.
|
|
5
|
+
* @beta
|
|
6
|
+
*/
|
|
7
|
+
export interface ECSchemaProvider {
|
|
8
|
+
getSchema(schemaName: string): Promise<EC.Schema | undefined>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* An interface for a class hierarchy inspector that can be used to determine if one class derives from another.
|
|
12
|
+
* @see `createCachingECClassHierarchyInspector`
|
|
13
|
+
* @beta
|
|
14
|
+
*/
|
|
15
|
+
export interface ECClassHierarchyInspector {
|
|
16
|
+
classDerivesFrom(derivedClassFullName: string, candidateBaseClassFullName: string): Promise<boolean> | boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Creates a new `ECClassHierarchyInspector` that caches results of `derivesFrom` calls.
|
|
20
|
+
* @beta
|
|
21
|
+
*/
|
|
22
|
+
export declare function createCachingECClassHierarchyInspector(props: {
|
|
23
|
+
/** Schema provider used to load schemas and their classes. */
|
|
24
|
+
schemaProvider: ECSchemaProvider;
|
|
25
|
+
/** Optional cache size, describing the number of derived/base class combinations to store in cache. Defaults to `0`, which means no caching. */
|
|
26
|
+
cacheSize?: number;
|
|
27
|
+
}): ECClassHierarchyInspector;
|
|
28
|
+
/**
|
|
29
|
+
* A namespace containing various [EC types](https://www.itwinjs.org/bis/ec/).
|
|
30
|
+
* @beta
|
|
31
|
+
* @see `ECSchemaProvider`
|
|
32
|
+
*/
|
|
33
|
+
export declare namespace EC {
|
|
34
|
+
/**
|
|
35
|
+
* Represents an ECSchema that contains classes, relationships, etc.
|
|
36
|
+
* @see https://www.itwinjs.org/reference/ecschema-metadata/metadata/schema/
|
|
37
|
+
* @beta
|
|
38
|
+
*/
|
|
39
|
+
interface Schema {
|
|
40
|
+
name: string;
|
|
41
|
+
getClass(name: string): Promise<Class | undefined>;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Represents an ECSchema item - a class, relationship, etc.
|
|
45
|
+
* @see https://www.itwinjs.org/reference/ecschema-metadata/metadata/schemaitem/
|
|
46
|
+
* @beta
|
|
47
|
+
*/
|
|
48
|
+
interface SchemaItem {
|
|
49
|
+
schema: Schema;
|
|
50
|
+
fullName: string;
|
|
51
|
+
name: string;
|
|
52
|
+
label?: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Represents an ECClass.
|
|
56
|
+
* @see https://www.itwinjs.org/reference/ecschema-metadata/metadata/ecclass/
|
|
57
|
+
* @beta
|
|
58
|
+
*/
|
|
59
|
+
interface Class extends SchemaItem {
|
|
60
|
+
is(className: string, schemaName: string): Promise<boolean>;
|
|
61
|
+
is(other: Class): Promise<boolean>;
|
|
62
|
+
getProperty(name: string): Promise<Property | undefined>;
|
|
63
|
+
getProperties(): Promise<Array<Property>>;
|
|
64
|
+
isEntityClass(): this is EntityClass;
|
|
65
|
+
isRelationshipClass(): this is RelationshipClass;
|
|
66
|
+
isStructClass(): this is StructClass;
|
|
67
|
+
isMixin(): this is Mixin;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Represents an entity class.
|
|
71
|
+
* @see https://www.itwinjs.org/reference/ecschema-metadata/metadata/entityclass/
|
|
72
|
+
* @beta
|
|
73
|
+
*/
|
|
74
|
+
type EntityClass = Class;
|
|
75
|
+
/**
|
|
76
|
+
* Represents a struct class.
|
|
77
|
+
* @see https://www.itwinjs.org/reference/ecschema-metadata/metadata/structclass/
|
|
78
|
+
* @beta
|
|
79
|
+
*/
|
|
80
|
+
type StructClass = Class;
|
|
81
|
+
/**
|
|
82
|
+
* Represents a mixin.
|
|
83
|
+
* @see https://www.itwinjs.org/reference/ecschema-metadata/metadata/mixin/
|
|
84
|
+
* @beta
|
|
85
|
+
*/
|
|
86
|
+
type Mixin = Class;
|
|
87
|
+
/**
|
|
88
|
+
* Represents a kind of quantity.
|
|
89
|
+
* @see https://www.itwinjs.org/reference/ecschema-metadata/metadata/kindofquantity/
|
|
90
|
+
* @beta
|
|
91
|
+
*/
|
|
92
|
+
type KindOfQuantity = SchemaItem;
|
|
93
|
+
/**
|
|
94
|
+
* Represents a relationship constraint multiplicity.
|
|
95
|
+
* @see https://www.itwinjs.org/reference/ecschema-metadata/metadata/relationshipmultiplicity/
|
|
96
|
+
* @beta
|
|
97
|
+
*/
|
|
98
|
+
interface RelationshipConstraintMultiplicity {
|
|
99
|
+
lowerLimit: number;
|
|
100
|
+
upperLimit: number;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Represents a relationship constraint.
|
|
104
|
+
* @see https://www.itwinjs.org/reference/ecschema-metadata/metadata/relationshipconstraint/
|
|
105
|
+
* @beta
|
|
106
|
+
*/
|
|
107
|
+
interface RelationshipConstraint {
|
|
108
|
+
multiplicity?: RelationshipConstraintMultiplicity;
|
|
109
|
+
polymorphic: boolean;
|
|
110
|
+
abstractConstraint: Promise<EntityClass | Mixin | RelationshipClass | undefined>;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Represents a relationship class.
|
|
114
|
+
* @see https://www.itwinjs.org/reference/ecschema-metadata/metadata/relationshipclass/
|
|
115
|
+
* @beta
|
|
116
|
+
*/
|
|
117
|
+
interface RelationshipClass extends Class {
|
|
118
|
+
direction: "Forward" | "Backward";
|
|
119
|
+
source: RelationshipConstraint;
|
|
120
|
+
target: RelationshipConstraint;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Represents an enumerator.
|
|
124
|
+
* @see https://www.itwinjs.org/reference/ecschema-metadata/metadata/enumerator/
|
|
125
|
+
* @beta
|
|
126
|
+
*/
|
|
127
|
+
interface Enumerator<T> {
|
|
128
|
+
name: string;
|
|
129
|
+
value: T;
|
|
130
|
+
label?: string;
|
|
131
|
+
description?: string;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Represents an enumeration.
|
|
135
|
+
* @see https://www.itwinjs.org/reference/ecschema-metadata/metadata/enumeration/
|
|
136
|
+
* @beta
|
|
137
|
+
*/
|
|
138
|
+
interface Enumeration extends SchemaItem {
|
|
139
|
+
enumerators: Array<Enumerator<string | number>>;
|
|
140
|
+
type: "String" | "Number";
|
|
141
|
+
isStrict: boolean;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Represents a property.
|
|
145
|
+
* @see https://www.itwinjs.org/reference/ecschema-metadata/metadata/property/
|
|
146
|
+
* @beta
|
|
147
|
+
*/
|
|
148
|
+
interface Property {
|
|
149
|
+
name: string;
|
|
150
|
+
class: Class;
|
|
151
|
+
label?: string;
|
|
152
|
+
kindOfQuantity: Promise<KindOfQuantity | undefined>;
|
|
153
|
+
isArray(): this is ArrayProperty;
|
|
154
|
+
isStruct(): this is StructProperty;
|
|
155
|
+
isPrimitive(): this is PrimitiveProperty;
|
|
156
|
+
isEnumeration(): this is EnumerationProperty;
|
|
157
|
+
isNavigation(): this is NavigationProperty;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Defines array property attributes.
|
|
161
|
+
* @see https://www.itwinjs.org/reference/ecschema-metadata/metadata/arrayproperty/
|
|
162
|
+
* @beta
|
|
163
|
+
*/
|
|
164
|
+
interface ArrayPropertyAttributes {
|
|
165
|
+
minOccurs: number;
|
|
166
|
+
maxOccurs?: number;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Defines a structs array property.
|
|
170
|
+
* @see https://www.itwinjs.org/reference/ecschema-metadata/metadata/structarrayproperty/
|
|
171
|
+
* @beta
|
|
172
|
+
*/
|
|
173
|
+
type StructArrayProperty = StructProperty & ArrayPropertyAttributes;
|
|
174
|
+
/**
|
|
175
|
+
* Defines an enumerations array property.
|
|
176
|
+
* @see https://www.itwinjs.org/reference/ecschema-metadata/metadata/enumerationarrayproperty/
|
|
177
|
+
* @beta
|
|
178
|
+
*/
|
|
179
|
+
type EnumerationArrayProperty = EnumerationProperty & ArrayPropertyAttributes;
|
|
180
|
+
/**
|
|
181
|
+
* Defines a primitives array property.
|
|
182
|
+
* @see https://www.itwinjs.org/reference/ecschema-metadata/metadata/primitivearrayproperty/
|
|
183
|
+
* @beta
|
|
184
|
+
*/
|
|
185
|
+
type PrimitiveArrayProperty = PrimitiveProperty & ArrayPropertyAttributes;
|
|
186
|
+
/**
|
|
187
|
+
* Defines an array property.
|
|
188
|
+
* @see https://www.itwinjs.org/reference/ecschema-metadata/metadata/anyarrayproperty/
|
|
189
|
+
* @beta
|
|
190
|
+
*/
|
|
191
|
+
type ArrayProperty = StructArrayProperty | EnumerationArrayProperty | PrimitiveArrayProperty;
|
|
192
|
+
/**
|
|
193
|
+
* Defines a struct property.
|
|
194
|
+
* @see https://www.itwinjs.org/reference/ecschema-metadata/metadata/structproperty/
|
|
195
|
+
* @beta
|
|
196
|
+
*/
|
|
197
|
+
interface StructProperty extends Property {
|
|
198
|
+
structClass: StructClass;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Defines an enumeration property.
|
|
202
|
+
* @see https://www.itwinjs.org/reference/ecschema-metadata/metadata/enumerationproperty/
|
|
203
|
+
* @beta
|
|
204
|
+
*/
|
|
205
|
+
interface EnumerationProperty extends Property {
|
|
206
|
+
enumeration: Promise<Enumeration | undefined>;
|
|
207
|
+
extendedTypeName?: string;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Defines a navigation property.
|
|
211
|
+
* @see https://www.itwinjs.org/reference/ecschema-metadata/metadata/navigationproperty/
|
|
212
|
+
* @beta
|
|
213
|
+
*/
|
|
214
|
+
interface NavigationProperty extends Property {
|
|
215
|
+
relationshipClass: Promise<RelationshipClass>;
|
|
216
|
+
direction: "Forward" | "Backward";
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Defines a primitive property type.
|
|
220
|
+
* @see https://www.itwinjs.org/reference/ecschema-metadata/metadata/primitivetype/
|
|
221
|
+
* @beta
|
|
222
|
+
*/
|
|
223
|
+
type PrimitiveType = "Binary" | "Boolean" | "DateTime" | "Double" | "Integer" | "Long" | "Point2d" | "Point3d" | "String" | "IGeometry";
|
|
224
|
+
/**
|
|
225
|
+
* Defines a primitive property.
|
|
226
|
+
* @see https://www.itwinjs.org/reference/ecschema-metadata/metadata/primitiveproperty/
|
|
227
|
+
* @beta
|
|
228
|
+
*/
|
|
229
|
+
interface PrimitiveProperty extends Property {
|
|
230
|
+
primitiveType: PrimitiveType;
|
|
231
|
+
extendedTypeName?: string;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* An identifiers' union of all supported primitive value types.
|
|
236
|
+
* @internal This is an internal type used in public API.
|
|
237
|
+
*/
|
|
238
|
+
export type PrimitiveValueType = "Id" | Exclude<EC.PrimitiveType, "Binary" | "IGeometry">;
|
|
239
|
+
/**
|
|
240
|
+
* Describes a single step through an ECRelationship from source ECClass to target ECClass.
|
|
241
|
+
* @internal This is an internal type used in public API.
|
|
242
|
+
*/
|
|
243
|
+
export interface RelationshipPathStep {
|
|
244
|
+
/** Full name of the source ECClass */
|
|
245
|
+
sourceClassName: string;
|
|
246
|
+
/** Full name of the target ECClass */
|
|
247
|
+
targetClassName: string;
|
|
248
|
+
/** Full name of the ECRelationshipClass */
|
|
249
|
+
relationshipName: string;
|
|
250
|
+
/**
|
|
251
|
+
* Indicates that the relationship direction be reversed. This should be set to `true` when step direction
|
|
252
|
+
* doesn't match relationship direction, e.g. relationship is from source `A` to target `B` and the step
|
|
253
|
+
* describes a step from `B` to `A`.
|
|
254
|
+
*/
|
|
255
|
+
relationshipReverse?: boolean;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Describes a path from source ECClass to target ECClass through multiple ECRelationships.
|
|
259
|
+
* @internal This is an internal type used in public API.
|
|
260
|
+
*/
|
|
261
|
+
export type RelationshipPath<TStep extends RelationshipPathStep = RelationshipPathStep> = TStep[];
|
|
262
|
+
/**
|
|
263
|
+
* Finds a class with the specified full class name using the given `ECSchemaProvider`.
|
|
264
|
+
* @throws Error if the schema or class is not found.
|
|
265
|
+
* @beta
|
|
266
|
+
*/
|
|
267
|
+
export declare function getClass(schemaProvider: ECSchemaProvider, fullClassName: string): Promise<EC.Class>;
|
|
268
|
+
//# sourceMappingURL=Metadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Metadata.d.ts","sourceRoot":"","sources":["../../../src/shared/Metadata.ts"],"names":[],"mappings":"AAQA;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;CAC/D;AAED;;;;GAIG;AACH,MAAM,WAAW,yBAAyB;IACxC,gBAAgB,CAAC,oBAAoB,EAAE,MAAM,EAAE,0BAA0B,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;CAChH;AAED;;;GAGG;AACH,wBAAgB,sCAAsC,CAAC,KAAK,EAAE;IAC5D,8DAA8D;IAC9D,cAAc,EAAE,gBAAgB,CAAC;IACjC,gJAAgJ;IAChJ,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,yBAAyB,CAsB5B;AAED;;;;GAIG;AACH,yBAAiB,EAAE,CAAC;IAClB;;;;OAIG;IACH,UAAiB,MAAM;QACrB,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,GAAG,SAAS,CAAC,CAAC;KACpD;IAED;;;;OAIG;IACH,UAAiB,UAAU;QACzB,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB;IAED;;;;OAIG;IACH,UAAiB,KAAM,SAAQ,UAAU;QACvC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;QAC5D,EAAE,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,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;IAED;;;;OAIG;IACH,UAAiB,kBAAmB,SAAQ,QAAQ;QAClD,iBAAiB,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC;QAC9C,SAAS,EAAE,SAAS,GAAG,UAAU,CAAC;KACnC;IAED;;;;OAIG;IACH,KAAY,aAAa,GAAG,QAAQ,GAAG,SAAS,GAAG,UAAU,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,WAAW,CAAC;IAE/I;;;;OAIG;IACH,UAAiB,iBAAkB,SAAQ,QAAQ;QACjD,aAAa,EAAE,aAAa,CAAC;QAC7B,gBAAgB,CAAC,EAAE,MAAM,CAAC;KAC3B;CACF;AAED;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG,IAAI,GAAG,OAAO,CAAC,EAAE,CAAC,aAAa,EAAE,QAAQ,GAAG,WAAW,CAAC,CAAC;AAE1F;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,sCAAsC;IACtC,eAAe,EAAE,MAAM,CAAC;IACxB,sCAAsC;IACtC,eAAe,EAAE,MAAM,CAAC;IACxB,2CAA2C;IAC3C,gBAAgB,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED;;;GAGG;AACH,MAAM,MAAM,gBAAgB,CAAC,KAAK,SAAS,oBAAoB,GAAG,oBAAoB,IAAI,KAAK,EAAE,CAAC;AAElG;;;;GAIG;AACH,wBAAsB,QAAQ,CAAC,cAAc,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,CAWzG"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.getClass = exports.createCachingECClassHierarchyInspector = void 0;
|
|
8
|
+
const core_bentley_1 = require("@itwin/core-bentley");
|
|
9
|
+
const Utils_1 = require("./Utils");
|
|
10
|
+
/**
|
|
11
|
+
* Creates a new `ECClassHierarchyInspector` that caches results of `derivesFrom` calls.
|
|
12
|
+
* @beta
|
|
13
|
+
*/
|
|
14
|
+
function createCachingECClassHierarchyInspector(props) {
|
|
15
|
+
const map = new core_bentley_1.LRUMap(props.cacheSize ?? 0);
|
|
16
|
+
function createCacheKey(derivedClassName, baseClassName) {
|
|
17
|
+
return `${derivedClassName}/${baseClassName}`;
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
classDerivesFrom(derivedClassFullName, candidateBaseClassFullName) {
|
|
21
|
+
const cacheKey = createCacheKey(derivedClassFullName, candidateBaseClassFullName);
|
|
22
|
+
let result = map.get(cacheKey);
|
|
23
|
+
if (result === undefined) {
|
|
24
|
+
result = Promise.all([getClass(props.schemaProvider, derivedClassFullName), getClass(props.schemaProvider, candidateBaseClassFullName)]).then(async ([derivedClass, baseClass]) => {
|
|
25
|
+
const resolvedResult = await derivedClass.is(baseClass);
|
|
26
|
+
map.set(cacheKey, resolvedResult);
|
|
27
|
+
return resolvedResult;
|
|
28
|
+
});
|
|
29
|
+
map.set(cacheKey, result);
|
|
30
|
+
}
|
|
31
|
+
return result;
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
exports.createCachingECClassHierarchyInspector = createCachingECClassHierarchyInspector;
|
|
36
|
+
/**
|
|
37
|
+
* Finds a class with the specified full class name using the given `ECSchemaProvider`.
|
|
38
|
+
* @throws Error if the schema or class is not found.
|
|
39
|
+
* @beta
|
|
40
|
+
*/
|
|
41
|
+
async function getClass(schemaProvider, fullClassName) {
|
|
42
|
+
const { schemaName, className } = (0, Utils_1.parseFullClassName)(fullClassName);
|
|
43
|
+
const schema = await schemaProvider.getSchema(schemaName);
|
|
44
|
+
if (!schema) {
|
|
45
|
+
throw new Error(`Schema "${schemaName}" not found.`);
|
|
46
|
+
}
|
|
47
|
+
const lookupClass = await schema.getClass(className);
|
|
48
|
+
if (!lookupClass) {
|
|
49
|
+
throw new Error(`Class "${className}" not found in schema "${schemaName}".`);
|
|
50
|
+
}
|
|
51
|
+
return lookupClass;
|
|
52
|
+
}
|
|
53
|
+
exports.getClass = getClass;
|
|
54
|
+
//# sourceMappingURL=Metadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Metadata.js","sourceRoot":"","sources":["../../../src/shared/Metadata.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,sDAA6C;AAC7C,mCAA6C;AAqB7C;;;GAGG;AACH,SAAgB,sCAAsC,CAAC,KAKtD;IACC,MAAM,GAAG,GAAG,IAAI,qBAAM,CAAqC,KAAK,CAAC,SAAS,IAAI,CAAC,CAAC,CAAC;IACjF,SAAS,cAAc,CAAC,gBAAwB,EAAE,aAAqB;QACrE,OAAO,GAAG,gBAAgB,IAAI,aAAa,EAAE,CAAC;IAChD,CAAC;IACD,OAAO;QACL,gBAAgB,CAAC,oBAA4B,EAAE,0BAAkC;YAC/E,MAAM,QAAQ,GAAG,cAAc,CAAC,oBAAoB,EAAE,0BAA0B,CAAC,CAAC;YAClF,IAAI,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAC/B,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;gBACzB,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,EAAE,oBAAoB,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC,cAAc,EAAE,0BAA0B,CAAC,CAAC,CAAC,CAAC,IAAI,CAC3I,KAAK,EAAE,CAAC,YAAY,EAAE,SAAS,CAAC,EAAE,EAAE;oBAClC,MAAM,cAAc,GAAG,MAAM,YAAY,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC;oBACxD,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;oBAClC,OAAO,cAAc,CAAC;gBACxB,CAAC,CACF,CAAC;gBACF,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;YAC5B,CAAC;YACD,OAAO,MAAM,CAAC;QAChB,CAAC;KACF,CAAC;AACJ,CAAC;AA3BD,wFA2BC;AAoQD;;;;GAIG;AACI,KAAK,UAAU,QAAQ,CAAC,cAAgC,EAAE,aAAqB;IACpF,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,IAAA,0BAAkB,EAAC,aAAa,CAAC,CAAC;IACpE,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IAC1D,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,WAAW,UAAU,cAAc,CAAC,CAAC;IACvD,CAAC;IACD,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IACrD,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,UAAU,SAAS,0BAA0B,UAAU,IAAI,CAAC,CAAC;IAC/E,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC;AAXD,4BAWC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An utility to parse schema and class names from full class name, where
|
|
3
|
+
* schema and class names are separated by either `:` or `.`.
|
|
4
|
+
* @beta
|
|
5
|
+
*/
|
|
6
|
+
export declare function parseFullClassName(fullClassName: string): {
|
|
7
|
+
schemaName: string;
|
|
8
|
+
className: string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* An utility to normalize full class name from either `SchemaName:ClassName` or
|
|
12
|
+
* `SchemaName.ClassName` to always use the dot format.
|
|
13
|
+
* @beta
|
|
14
|
+
*/
|
|
15
|
+
export declare function normalizeFullClassName(fullClassName: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* An utility to remove all extra whitespace from a given string.
|
|
18
|
+
* @beta
|
|
19
|
+
*/
|
|
20
|
+
export declare function trimWhitespace(str: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* An utility to remove all extra whitespace from a given string.
|
|
23
|
+
* @beta
|
|
24
|
+
*/
|
|
25
|
+
export declare function trimWhitespace(str: string | undefined): string | undefined;
|
|
26
|
+
//# sourceMappingURL=Utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Utils.d.ts","sourceRoot":"","sources":["../../../src/shared/Utils.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,MAAM;;;EAIvD;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CASpE;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;AACpD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.trimWhitespace = exports.normalizeFullClassName = exports.parseFullClassName = void 0;
|
|
8
|
+
const core_bentley_1 = require("@itwin/core-bentley");
|
|
9
|
+
/**
|
|
10
|
+
* An utility to parse schema and class names from full class name, where
|
|
11
|
+
* schema and class names are separated by either `:` or `.`.
|
|
12
|
+
* @beta
|
|
13
|
+
*/
|
|
14
|
+
function parseFullClassName(fullClassName) {
|
|
15
|
+
const [schemaName, className] = fullClassName.split(/[\.:]/);
|
|
16
|
+
(0, core_bentley_1.assert)(!!schemaName && !!className, "Invalid full class name");
|
|
17
|
+
return { schemaName, className };
|
|
18
|
+
}
|
|
19
|
+
exports.parseFullClassName = parseFullClassName;
|
|
20
|
+
/**
|
|
21
|
+
* An utility to normalize full class name from either `SchemaName:ClassName` or
|
|
22
|
+
* `SchemaName.ClassName` to always use the dot format.
|
|
23
|
+
* @beta
|
|
24
|
+
*/
|
|
25
|
+
function normalizeFullClassName(fullClassName) {
|
|
26
|
+
const colonPos = fullClassName.indexOf(":");
|
|
27
|
+
if (-1 === colonPos) {
|
|
28
|
+
(0, core_bentley_1.assert)(fullClassName.indexOf(".") !== -1, "Invalid full class name");
|
|
29
|
+
return fullClassName;
|
|
30
|
+
}
|
|
31
|
+
const schemaName = fullClassName.slice(0, colonPos);
|
|
32
|
+
const className = fullClassName.slice(colonPos + 1);
|
|
33
|
+
return `${schemaName}.${className}`;
|
|
34
|
+
}
|
|
35
|
+
exports.normalizeFullClassName = normalizeFullClassName;
|
|
36
|
+
/** @beta */
|
|
37
|
+
function trimWhitespace(str) {
|
|
38
|
+
// istanbul ignore next
|
|
39
|
+
if (!str) {
|
|
40
|
+
return str;
|
|
41
|
+
}
|
|
42
|
+
return str
|
|
43
|
+
.replaceAll(/\s+/gm, " ") // replace all consecutive spaces with a single space
|
|
44
|
+
.replaceAll(/\(\s+/g, "(") // remove spaces after opening parentheses
|
|
45
|
+
.replaceAll(/\s+\)/g, ")") // remove spaces before closing parentheses
|
|
46
|
+
.replaceAll(/\s+,/g, ",") // remove spaces before comma
|
|
47
|
+
.trim(); // remove spaces from beginning and end of the string
|
|
48
|
+
}
|
|
49
|
+
exports.trimWhitespace = trimWhitespace;
|
|
50
|
+
//# sourceMappingURL=Utils.js.map
|
|
@@ -0,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C;SACpE,UAAU,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,2CAA2C;SACrE,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,6BAA6B;SACtD,IAAI,EAAE,CAAC,CAAC,qDAAqD;AAClE,CAAC;AAXD,wCAWC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { Id64String } from "@itwin/core-bentley";
|
|
2
|
+
import { PrimitiveValueType } from "./Metadata";
|
|
3
|
+
/**
|
|
4
|
+
* A data structure uniquely identifying an ECInstance in an iModel.
|
|
5
|
+
* @beta
|
|
6
|
+
*/
|
|
7
|
+
export interface InstanceKey {
|
|
8
|
+
/** Full class name in format `SchemaName.ClassName` */
|
|
9
|
+
className: string;
|
|
10
|
+
/** ECInstance ID */
|
|
11
|
+
id: Id64String;
|
|
12
|
+
}
|
|
13
|
+
/** @beta */
|
|
14
|
+
export declare namespace InstanceKey {
|
|
15
|
+
/**
|
|
16
|
+
* Checks whether the two given instance keys are equal.
|
|
17
|
+
* @beta
|
|
18
|
+
*/
|
|
19
|
+
function equals(lhs: InstanceKey, rhs: InstanceKey): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Compares two given instance keys.
|
|
22
|
+
* @returns
|
|
23
|
+
*- `0` if they are equal
|
|
24
|
+
*- `negative value` if lhs key is less than rhs key
|
|
25
|
+
*- `positive value` if lhs key is more than rhs key
|
|
26
|
+
*/
|
|
27
|
+
function compare(lhs: InstanceKey, rhs: InstanceKey): number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* A data structure for a 2d point.
|
|
31
|
+
* @internal This is an internal type used in public API.
|
|
32
|
+
*/
|
|
33
|
+
export interface Point2d {
|
|
34
|
+
x: number;
|
|
35
|
+
y: number;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* A data structure for a 3d point.
|
|
39
|
+
* @internal This is an internal type used in public API.
|
|
40
|
+
*/
|
|
41
|
+
export interface Point3d {
|
|
42
|
+
x: number;
|
|
43
|
+
y: number;
|
|
44
|
+
z: number;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* A union for all supported primitive value types.
|
|
48
|
+
* @beta
|
|
49
|
+
*/
|
|
50
|
+
export type PrimitiveValue = Id64String | string | number | boolean | Date | Point2d | Point3d;
|
|
51
|
+
/** @beta */
|
|
52
|
+
export declare namespace PrimitiveValue {
|
|
53
|
+
/**
|
|
54
|
+
* Checks whether the given value is a `Point2d`.
|
|
55
|
+
* @note Since `Point3d` is a superset of `Point2d`, this function will return `true` for `Point3d` as well.
|
|
56
|
+
* @beta
|
|
57
|
+
*/
|
|
58
|
+
function isPoint2d(value: PrimitiveValue): value is Point2d;
|
|
59
|
+
/**
|
|
60
|
+
* Checks whether the given value is a `Point3d`.
|
|
61
|
+
* @beta
|
|
62
|
+
*/
|
|
63
|
+
function isPoint3d(value: PrimitiveValue): value is Point3d;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* A type for a primitive value, its type and, optionally, its extended type.
|
|
67
|
+
* @note Use `TypedPrimitiveValue.create` to create an instance of this type.
|
|
68
|
+
* @beta
|
|
69
|
+
*/
|
|
70
|
+
export type TypedPrimitiveValue = ({
|
|
71
|
+
value: number;
|
|
72
|
+
type: "Integer" | "Long";
|
|
73
|
+
} | {
|
|
74
|
+
value: number;
|
|
75
|
+
type: "Double";
|
|
76
|
+
koqName?: string;
|
|
77
|
+
} | {
|
|
78
|
+
value: boolean;
|
|
79
|
+
type: "Boolean";
|
|
80
|
+
} | {
|
|
81
|
+
value: Id64String;
|
|
82
|
+
type: "Id";
|
|
83
|
+
} | {
|
|
84
|
+
value: string;
|
|
85
|
+
type: "String";
|
|
86
|
+
} | {
|
|
87
|
+
value: number | string | Date;
|
|
88
|
+
type: "DateTime";
|
|
89
|
+
} | {
|
|
90
|
+
value: Point2d;
|
|
91
|
+
type: "Point2d";
|
|
92
|
+
} | {
|
|
93
|
+
value: Point3d;
|
|
94
|
+
type: "Point3d";
|
|
95
|
+
}) & {
|
|
96
|
+
extendedType?: string;
|
|
97
|
+
};
|
|
98
|
+
/** @beta */
|
|
99
|
+
export declare namespace TypedPrimitiveValue {
|
|
100
|
+
/**
|
|
101
|
+
* A function for a creating a `TypedPrimitiveValue` object.
|
|
102
|
+
* @throws Error if primitive type and value are incompatible.
|
|
103
|
+
* @beta
|
|
104
|
+
*/
|
|
105
|
+
function create(value: PrimitiveValue, type: PrimitiveValueType, koqName?: string, extendedType?: string): TypedPrimitiveValue;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* A type for a primitive property value and its metadata - property name and its class full name.
|
|
109
|
+
* @internal This is an internal type used in public API.
|
|
110
|
+
*/
|
|
111
|
+
export interface PrimitivePropertyValue {
|
|
112
|
+
/** Full name of the class containing the property with `propertyName` name. */
|
|
113
|
+
className: string;
|
|
114
|
+
/** Name of the primitive property whose value this data structure holds. */
|
|
115
|
+
propertyName: string;
|
|
116
|
+
/** Raw value of the primitive property. */
|
|
117
|
+
value: PrimitiveValue;
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=Values.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Values.d.ts","sourceRoot":"","sources":["../../../src/shared/Values.ts"],"names":[],"mappings":"AAKA,OAAO,EAAwB,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,uDAAuD;IACvD,SAAS,EAAE,MAAM,CAAC;IAClB,oBAAoB;IACpB,EAAE,EAAE,UAAU,CAAC;CAChB;AAED,YAAY;AACZ,yBAAiB,WAAW,CAAC;IAC3B;;;OAGG;IACH,SAAgB,MAAM,CAAC,GAAG,EAAE,WAAW,EAAE,GAAG,EAAE,WAAW,GAAG,OAAO,CAElE;IACD;;;;;;OAMG;IACH,SAAgB,OAAO,CAAC,GAAG,EAAE,WAAW,EAAE,GAAG,E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