@itwin/core-backend 4.4.0-dev.9 → 4.5.0-dev.2
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 +8 -1
- package/lib/cjs/BackendHubAccess.js.map +1 -1
- package/lib/cjs/BackendLoggerCategory.js.map +1 -1
- package/lib/cjs/BisCoreSchema.js.map +1 -1
- package/lib/cjs/BlobContainerService.js.map +1 -1
- package/lib/cjs/BriefcaseManager.js.map +1 -1
- package/lib/cjs/Category.js.map +1 -1
- package/lib/cjs/ChangeSummaryManager.js +2 -2
- package/lib/cjs/ChangeSummaryManager.js.map +1 -1
- package/lib/cjs/ChangedElementsDb.js.map +1 -1
- package/lib/cjs/ChangedElementsManager.js.map +1 -1
- package/lib/cjs/ChangesetECAdaptor.d.ts +8 -1
- package/lib/cjs/ChangesetECAdaptor.d.ts.map +1 -1
- package/lib/cjs/ChangesetECAdaptor.js +290 -232
- package/lib/cjs/ChangesetECAdaptor.js.map +1 -1
- package/lib/cjs/ChannelControl.js.map +1 -1
- package/lib/cjs/CheckpointManager.js.map +1 -1
- package/lib/cjs/ClassRegistry.js +5 -5
- package/lib/cjs/ClassRegistry.js.map +1 -1
- package/lib/cjs/CloudSqlite.js.map +1 -1
- package/lib/cjs/CodeService.js.map +1 -1
- package/lib/cjs/CodeSpecs.js.map +1 -1
- package/lib/cjs/ConcurrentQuery.js.map +1 -1
- package/lib/cjs/CustomViewState3dCreator.js.map +1 -1
- package/lib/cjs/DevTools.js.map +1 -1
- package/lib/cjs/DisplayStyle.js.map +1 -1
- package/lib/cjs/ECDb.js.map +1 -1
- package/lib/cjs/ECSchemaXmlContext.js.map +1 -1
- package/lib/cjs/ECSqlStatement.js.map +1 -1
- package/lib/cjs/Element.js.map +1 -1
- package/lib/cjs/ElementAspect.js.map +1 -1
- package/lib/cjs/ElementGraphics.js.map +1 -1
- package/lib/cjs/ElementTreeWalker.js.map +1 -1
- package/lib/cjs/Entity.js.map +1 -1
- package/lib/cjs/EntityReferences.js.map +1 -1
- package/lib/cjs/ExportGraphics.js.map +1 -1
- package/lib/cjs/ExternalSource.js.map +1 -1
- package/lib/cjs/GeoCoordConfig.js.map +1 -1
- package/lib/cjs/GeometrySummary.js +47 -47
- package/lib/cjs/GeometrySummary.js.map +1 -1
- package/lib/cjs/HubMock.js.map +1 -1
- package/lib/cjs/IModelCloneContext.js.map +1 -1
- package/lib/cjs/IModelDb.js +8 -8
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/cjs/IModelElementCloneContext.js.map +1 -1
- package/lib/cjs/IModelHost.js.map +1 -1
- package/lib/cjs/IModelJsFs.js.map +1 -1
- package/lib/cjs/IpcHost.js.map +1 -1
- package/lib/cjs/LineStyle.js.map +1 -1
- package/lib/cjs/LocalHub.js +1 -1
- package/lib/cjs/LocalHub.js.map +1 -1
- package/lib/cjs/LocalhostIpcHost.js.map +1 -1
- package/lib/cjs/Material.d.ts +4 -1
- package/lib/cjs/Material.d.ts.map +1 -1
- package/lib/cjs/Material.js +13 -0
- package/lib/cjs/Material.js.map +1 -1
- package/lib/cjs/Model.js.map +1 -1
- package/lib/cjs/NativeAppStorage.js.map +1 -1
- package/lib/cjs/NativeHost.js.map +1 -1
- package/lib/cjs/NavigationRelationship.js.map +1 -1
- package/lib/cjs/PromiseMemoizer.js.map +1 -1
- package/lib/cjs/PropertyStore.js.map +1 -1
- package/lib/cjs/Relationship.js.map +1 -1
- package/lib/cjs/RpcBackend.js.map +1 -1
- package/lib/cjs/SQLiteDb.js.map +1 -1
- package/lib/cjs/Schema.js.map +1 -1
- package/lib/cjs/SchemaSync.js.map +1 -1
- package/lib/cjs/SchemaUtils.js.map +1 -1
- package/lib/cjs/ServerBasedLocks.js.map +1 -1
- package/lib/cjs/SqliteChangesetReader.js.map +1 -1
- package/lib/cjs/SqliteStatement.js.map +1 -1
- package/lib/cjs/Texture.js.map +1 -1
- package/lib/cjs/TileStorage.js.map +1 -1
- package/lib/cjs/TxnManager.js.map +1 -1
- package/lib/cjs/ViewDefinition.js.map +1 -1
- package/lib/cjs/ViewStateHydrator.js.map +1 -1
- package/lib/cjs/ViewStore.js.map +1 -1
- package/lib/cjs/assets/IModelChange.02.00.00.ecschema.xml +90 -90
- package/lib/cjs/assets/Settings/Schemas/Cloud.Schema.json +44 -44
- package/lib/cjs/assets/Settings/Schemas/Gcs.schema.json +31 -31
- package/lib/cjs/assets/Settings/Schemas/Workspace.Schema.json +52 -52
- package/lib/cjs/assets/Settings/backend.setting.json5 +132 -132
- package/lib/cjs/core-backend.js.map +1 -1
- package/lib/cjs/domains/FunctionalElements.js.map +1 -1
- package/lib/cjs/domains/FunctionalSchema.js.map +1 -1
- package/lib/cjs/domains/GenericElements.js.map +1 -1
- package/lib/cjs/domains/GenericSchema.js.map +1 -1
- package/lib/cjs/rpc/multipart.js.map +1 -1
- package/lib/cjs/rpc/tracing.js.map +1 -1
- package/lib/cjs/rpc/web/logging.js.map +1 -1
- package/lib/cjs/rpc/web/request.js.map +1 -1
- package/lib/cjs/rpc/web/response.js.map +1 -1
- package/lib/cjs/rpc-impl/DevToolsRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/IModelTileRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.d.ts +13 -5
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.d.ts.map +1 -1
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js +10 -5
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
- package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/WipRpcImpl.js.map +1 -1
- package/lib/cjs/workspace/Settings.js.map +1 -1
- package/lib/cjs/workspace/SettingsSchemas.js.map +1 -1
- package/lib/cjs/workspace/Workspace.js.map +1 -1
- package/package.json +15 -15
|
@@ -16,14 +16,14 @@ class ECDbMap {
|
|
|
16
16
|
this._cacheTables = new Map();
|
|
17
17
|
}
|
|
18
18
|
getAllDerivedClasses(classFullName) {
|
|
19
|
-
const sql = `
|
|
20
|
-
SELECT format('0x%x', ch.ClassId)
|
|
21
|
-
FROM [ec_cache_ClassHierarchy] [ch]
|
|
22
|
-
JOIN [ec_Class] [cs] ON [cs].[Id] = [ch].[BaseClassId]
|
|
23
|
-
JOIN [ec_Schema] [sc] ON [sc].[Id] = [cs].[SchemaId]
|
|
24
|
-
WHERE (([sc].[Alias] = :schemaNameOrAlias
|
|
25
|
-
OR [sc].[Name] = :schemaNameOrAlias)
|
|
26
|
-
AND ([cs].[Name] = :className))
|
|
19
|
+
const sql = `
|
|
20
|
+
SELECT format('0x%x', ch.ClassId)
|
|
21
|
+
FROM [ec_cache_ClassHierarchy] [ch]
|
|
22
|
+
JOIN [ec_Class] [cs] ON [cs].[Id] = [ch].[BaseClassId]
|
|
23
|
+
JOIN [ec_Schema] [sc] ON [sc].[Id] = [cs].[SchemaId]
|
|
24
|
+
WHERE (([sc].[Alias] = :schemaNameOrAlias
|
|
25
|
+
OR [sc].[Name] = :schemaNameOrAlias)
|
|
26
|
+
AND ([cs].[Name] = :className))
|
|
27
27
|
`;
|
|
28
28
|
return this.db.withPreparedSqliteStatement(sql, (stmt) => {
|
|
29
29
|
const parts = classFullName.indexOf(".") !== -1 ? classFullName.split(".") : classFullName.split(":");
|
|
@@ -38,34 +38,34 @@ class ECDbMap {
|
|
|
38
38
|
getTable(tableName) {
|
|
39
39
|
if (this._cacheTables.has(tableName))
|
|
40
40
|
return this._cacheTables.get(tableName);
|
|
41
|
-
const sql = `
|
|
42
|
-
SELECT
|
|
43
|
-
JSON_OBJECT (
|
|
44
|
-
'id', FORMAT ('0x%x', [t].[id]),
|
|
45
|
-
'name', [t].[Name],
|
|
46
|
-
'type', (
|
|
47
|
-
CASE
|
|
48
|
-
[t].[type]
|
|
49
|
-
WHEN 0 THEN 'Primary'
|
|
50
|
-
WHEN 1 THEN 'Joined'
|
|
51
|
-
WHEN 2 THEN 'Existing'
|
|
52
|
-
WHEN 3 THEN 'Overflow'
|
|
53
|
-
WHEN 4 THEN 'Virtual'
|
|
54
|
-
END
|
|
55
|
-
),
|
|
56
|
-
'exclusiveRootClassId', FORMAT ('0x%x', [t].[ExclusiveRootClassId]),
|
|
57
|
-
'isClassIdVirtual', (
|
|
58
|
-
SELECT
|
|
59
|
-
[c].[IsVirtual]
|
|
60
|
-
FROM
|
|
61
|
-
[ec_Column] [c]
|
|
62
|
-
WHERE
|
|
63
|
-
[c].[Name] = 'ECClassId' AND [c].[TableId] = [t].[Id]
|
|
64
|
-
)
|
|
65
|
-
)
|
|
66
|
-
FROM [ec_Table] [t]
|
|
67
|
-
WHERE
|
|
68
|
-
[t].[Name] = ?;
|
|
41
|
+
const sql = `
|
|
42
|
+
SELECT
|
|
43
|
+
JSON_OBJECT (
|
|
44
|
+
'id', FORMAT ('0x%x', [t].[id]),
|
|
45
|
+
'name', [t].[Name],
|
|
46
|
+
'type', (
|
|
47
|
+
CASE
|
|
48
|
+
[t].[type]
|
|
49
|
+
WHEN 0 THEN 'Primary'
|
|
50
|
+
WHEN 1 THEN 'Joined'
|
|
51
|
+
WHEN 2 THEN 'Existing'
|
|
52
|
+
WHEN 3 THEN 'Overflow'
|
|
53
|
+
WHEN 4 THEN 'Virtual'
|
|
54
|
+
END
|
|
55
|
+
),
|
|
56
|
+
'exclusiveRootClassId', FORMAT ('0x%x', [t].[ExclusiveRootClassId]),
|
|
57
|
+
'isClassIdVirtual', (
|
|
58
|
+
SELECT
|
|
59
|
+
[c].[IsVirtual]
|
|
60
|
+
FROM
|
|
61
|
+
[ec_Column] [c]
|
|
62
|
+
WHERE
|
|
63
|
+
[c].[Name] = 'ECClassId' AND [c].[TableId] = [t].[Id]
|
|
64
|
+
)
|
|
65
|
+
)
|
|
66
|
+
FROM [ec_Table] [t]
|
|
67
|
+
WHERE
|
|
68
|
+
[t].[Name] = ?;
|
|
69
69
|
`;
|
|
70
70
|
return this.db.withPreparedSqliteStatement(sql, (stmt) => {
|
|
71
71
|
stmt.bindString(1, tableName);
|
|
@@ -86,186 +86,186 @@ class ECDbMap {
|
|
|
86
86
|
getClassMap(classId) {
|
|
87
87
|
if (this._cachedClassMaps.has(classId))
|
|
88
88
|
return this._cachedClassMaps.get(classId);
|
|
89
|
-
const sql = `
|
|
90
|
-
SELECT
|
|
91
|
-
JSON_OBJECT(
|
|
92
|
-
'id', format('0x%x', cs.id),
|
|
93
|
-
'name', format('%s
|
|
94
|
-
'mapStrategy',
|
|
95
|
-
(
|
|
96
|
-
CASE cm.MapStrategy
|
|
97
|
-
WHEN 0 THEN 'NotMapped'
|
|
98
|
-
WHEN 1 THEN 'OwnTable'
|
|
99
|
-
WHEN 2 THEN 'TablePerHierarchy'
|
|
100
|
-
WHEN 3 THEN 'ExistingTable'
|
|
101
|
-
WHEN 10 THEN 'ForeignKeyInTargetTable'
|
|
102
|
-
WHEN 11 THEN 'ForeignKeyInSourceTable'
|
|
103
|
-
END
|
|
104
|
-
),
|
|
105
|
-
'type',
|
|
106
|
-
(
|
|
107
|
-
CASE cs.Type
|
|
108
|
-
WHEN 0 THEN 'Entity'
|
|
109
|
-
WHEN 1 THEN 'Relationship'
|
|
110
|
-
WHEN 2 THEN 'Struct'
|
|
111
|
-
WHEN 3 THEN 'CustomAttribute'
|
|
112
|
-
END
|
|
113
|
-
),
|
|
114
|
-
'modifier',
|
|
115
|
-
(
|
|
116
|
-
CASE cs.Modifier
|
|
117
|
-
WHEN 0 THEN 'None'
|
|
118
|
-
WHEN 1 THEN 'Abstract'
|
|
119
|
-
WHEN 2 THEN 'Sealed'
|
|
120
|
-
END
|
|
121
|
-
),
|
|
122
|
-
'properties',
|
|
123
|
-
(
|
|
124
|
-
SELECT
|
|
125
|
-
JSON_GROUP_ARRAY(JSON(propJson))
|
|
126
|
-
FROM
|
|
127
|
-
(
|
|
128
|
-
SELECT
|
|
129
|
-
JSON_OBJECT(
|
|
130
|
-
'id', format('0x%x', pt.id),
|
|
131
|
-
'name', pt.Name,
|
|
132
|
-
'kind',
|
|
133
|
-
(
|
|
134
|
-
CASE pt.Kind
|
|
135
|
-
WHEN 0 THEN 'Primitive'
|
|
136
|
-
WHEN 1 THEN 'Struct'
|
|
137
|
-
WHEN 2 THEN 'PrimitiveArray'
|
|
138
|
-
WHEN 3 THEN 'StructArray'
|
|
139
|
-
WHEN 4 THEN 'Navigation'
|
|
140
|
-
END
|
|
141
|
-
),
|
|
142
|
-
'primitiveType',
|
|
143
|
-
(
|
|
144
|
-
CASE pt.PrimitiveType
|
|
145
|
-
WHEN 0x101 THEN 'Binary'
|
|
146
|
-
WHEN 0x201 THEN 'Boolean'
|
|
147
|
-
WHEN 0x301 THEN 'DateTime'
|
|
148
|
-
WHEN 0x401 THEN 'Double'
|
|
149
|
-
WHEN 0x501 THEN 'Integer'
|
|
150
|
-
WHEN 0x601 THEN 'Long'
|
|
151
|
-
WHEN 0x701 THEN 'Point2d'
|
|
152
|
-
WHEN 0x801 THEN 'Point3d'
|
|
153
|
-
WHEN 0x901 THEN 'String'
|
|
154
|
-
WHEN 0xa01 THEN 'IGeometry'
|
|
155
|
-
END
|
|
156
|
-
),
|
|
157
|
-
'extendedTypeName', ExtendedTypeName,
|
|
158
|
-
'navigationRelationship',
|
|
159
|
-
(
|
|
160
|
-
SELECT
|
|
161
|
-
JSON_OBJECT(
|
|
162
|
-
'classId', format('0x%x', nc.Id),
|
|
163
|
-
'
|
|
164
|
-
)
|
|
165
|
-
FROM ec_Class nc
|
|
166
|
-
JOIN ec_Schema ns ON ns.Id = nc.SchemaId
|
|
167
|
-
WHERE
|
|
168
|
-
nc.Id = pt.NavigationRelationshipClassId
|
|
169
|
-
),
|
|
170
|
-
'structClass',
|
|
171
|
-
(
|
|
172
|
-
SELECT
|
|
173
|
-
JSON_OBJECT(
|
|
174
|
-
'classId', format('0x%x', nc.Id),
|
|
175
|
-
'
|
|
176
|
-
)
|
|
177
|
-
FROM ec_Class nc
|
|
178
|
-
JOIN ec_Schema ns ON ns.Id = nc.SchemaId
|
|
179
|
-
WHERE
|
|
180
|
-
nc.Id = pt.StructClassId
|
|
181
|
-
),
|
|
182
|
-
'dateTimeInfo', (
|
|
183
|
-
SELECT
|
|
184
|
-
JSON_OBJECT (
|
|
185
|
-
'dateTimeKind', (
|
|
186
|
-
CASE
|
|
187
|
-
WHEN [ca].[Instance] LIKE '%<DateTimeKind>Utc</DateTimeKind>%' COLLATE [NoCase] THEN 'Utc'
|
|
188
|
-
WHEN [ca].[Instance] LIKE '%<DateTimeKind>Local</DateTimeKind>%' COLLATE [NoCase] THEN 'Local'
|
|
189
|
-
ELSE 'Unspecified'
|
|
190
|
-
END
|
|
191
|
-
),
|
|
192
|
-
'dateTimeComponent', (
|
|
193
|
-
CASE
|
|
194
|
-
WHEN [ca].[Instance] LIKE '%<DateTimeComponent>DateTime</DateTimeComponent>%' COLLATE [NoCase] THEN 'DateTime'
|
|
195
|
-
WHEN [ca].[Instance] LIKE '%<DateTimeComponent>Date</DateTimeComponent>%' COLLATE [NoCase] THEN 'Date'
|
|
196
|
-
WHEN [ca].[Instance] LIKE '%<DateTimeComponent>TimeOfDay</DateTimeComponent>%' COLLATE [NoCase] THEN 'TimeOfDay'
|
|
197
|
-
ELSE 'DateTime'
|
|
198
|
-
END
|
|
199
|
-
)
|
|
200
|
-
)
|
|
201
|
-
FROM
|
|
202
|
-
[ec_CustomAttribute] [ca]
|
|
203
|
-
JOIN [ec_Class] [cl] ON [cl].[Id] = [ca].[ClassId]
|
|
204
|
-
JOIN [ec_Schema] [sc] ON [sc].[Id] = [cl].[SchemaId]
|
|
205
|
-
WHERE
|
|
206
|
-
[ca].[ContainerType] = 992
|
|
207
|
-
AND [cl].[Name] = 'DateTimeInfo'
|
|
208
|
-
AND [sc].[Name] = 'CoreCustomAttributes'
|
|
209
|
-
AND [ca].[ContainerId] = [pt].[Id]
|
|
210
|
-
),
|
|
211
|
-
'columns',
|
|
212
|
-
(
|
|
213
|
-
SELECT
|
|
214
|
-
JSON_GROUP_ARRAY(JSON(columnJson))
|
|
215
|
-
FROM
|
|
216
|
-
(
|
|
217
|
-
SELECT
|
|
218
|
-
JSON_OBJECT(
|
|
219
|
-
'table', tb.Name,
|
|
220
|
-
'column', cc.Name,
|
|
221
|
-
'type',
|
|
222
|
-
(
|
|
223
|
-
CASE cc.Type
|
|
224
|
-
WHEN 0 THEN 'Any'
|
|
225
|
-
WHEN 1 THEN 'Boolean'
|
|
226
|
-
WHEN 2 THEN 'Blob'
|
|
227
|
-
WHEN 3 THEN 'Timestamp'
|
|
228
|
-
WHEN 4 THEN 'Real'
|
|
229
|
-
WHEN 5 THEN 'Integer'
|
|
230
|
-
WHEN 6 THEN 'Text'
|
|
231
|
-
END
|
|
232
|
-
),
|
|
233
|
-
'columnKind',
|
|
234
|
-
(
|
|
235
|
-
CASE cc.ColumnKind
|
|
236
|
-
WHEN 0 THEN 'Default'
|
|
237
|
-
WHEN 1 THEN 'Id'
|
|
238
|
-
WHEN 2 THEN 'ClassId'
|
|
239
|
-
WHEN 4 THEN 'SharedData'
|
|
240
|
-
END
|
|
241
|
-
),
|
|
242
|
-
'accessString', pp0.AccessString,
|
|
243
|
-
'isVirtual', cc.IsVirtual OR tb.Type = 4
|
|
244
|
-
) columnJson
|
|
245
|
-
FROM [ec_PropertyMap] [pm0]
|
|
246
|
-
JOIN [ec_Column] [cc] ON [cc].[Id] = [pm0].[ColumnId]
|
|
247
|
-
JOIN [ec_Table] [tb] ON [tb].[Id] = [cc].[TableId]
|
|
248
|
-
JOIN [ec_PropertyPath] [pp0] ON [pp0].[Id] = [pm0].[PropertyPathId]
|
|
249
|
-
WHERE
|
|
250
|
-
[pp0].[RootPropertyId] = pt.Id AND pm0.ClassId = cs.Id
|
|
251
|
-
)
|
|
252
|
-
)
|
|
253
|
-
) propJson
|
|
254
|
-
FROM [ec_PropertyMap] [pm]
|
|
255
|
-
JOIN [ec_PropertyPath] [pp] ON [pp].[Id] = [pm].[PropertyPathId]
|
|
256
|
-
JOIN [ec_Property] [pt] ON [pt].[Id] = [pp].[RootPropertyId]
|
|
257
|
-
WHERE
|
|
258
|
-
pm.ClassId = cs.Id
|
|
259
|
-
GROUP BY
|
|
260
|
-
pt.Id
|
|
261
|
-
)
|
|
262
|
-
)
|
|
263
|
-
) classDef
|
|
264
|
-
FROM [ec_Class] [cs]
|
|
265
|
-
JOIN [ec_ClassMap] [cm] ON [cm].[ClassId] = [cs].[Id]
|
|
266
|
-
JOIN [ec_Schema] [ss] ON [ss].[Id] = [cs].[SchemaId]
|
|
267
|
-
WHERE
|
|
268
|
-
[cs].[Id] = ?
|
|
89
|
+
const sql = `
|
|
90
|
+
SELECT
|
|
91
|
+
JSON_OBJECT(
|
|
92
|
+
'id', format('0x%x', cs.id),
|
|
93
|
+
'name', format('%s:%s', ss.Name, cs.Name),
|
|
94
|
+
'mapStrategy',
|
|
95
|
+
(
|
|
96
|
+
CASE cm.MapStrategy
|
|
97
|
+
WHEN 0 THEN 'NotMapped'
|
|
98
|
+
WHEN 1 THEN 'OwnTable'
|
|
99
|
+
WHEN 2 THEN 'TablePerHierarchy'
|
|
100
|
+
WHEN 3 THEN 'ExistingTable'
|
|
101
|
+
WHEN 10 THEN 'ForeignKeyInTargetTable'
|
|
102
|
+
WHEN 11 THEN 'ForeignKeyInSourceTable'
|
|
103
|
+
END
|
|
104
|
+
),
|
|
105
|
+
'type',
|
|
106
|
+
(
|
|
107
|
+
CASE cs.Type
|
|
108
|
+
WHEN 0 THEN 'Entity'
|
|
109
|
+
WHEN 1 THEN 'Relationship'
|
|
110
|
+
WHEN 2 THEN 'Struct'
|
|
111
|
+
WHEN 3 THEN 'CustomAttribute'
|
|
112
|
+
END
|
|
113
|
+
),
|
|
114
|
+
'modifier',
|
|
115
|
+
(
|
|
116
|
+
CASE cs.Modifier
|
|
117
|
+
WHEN 0 THEN 'None'
|
|
118
|
+
WHEN 1 THEN 'Abstract'
|
|
119
|
+
WHEN 2 THEN 'Sealed'
|
|
120
|
+
END
|
|
121
|
+
),
|
|
122
|
+
'properties',
|
|
123
|
+
(
|
|
124
|
+
SELECT
|
|
125
|
+
JSON_GROUP_ARRAY(JSON(propJson))
|
|
126
|
+
FROM
|
|
127
|
+
(
|
|
128
|
+
SELECT
|
|
129
|
+
JSON_OBJECT(
|
|
130
|
+
'id', format('0x%x', pt.id),
|
|
131
|
+
'name', pt.Name,
|
|
132
|
+
'kind',
|
|
133
|
+
(
|
|
134
|
+
CASE pt.Kind
|
|
135
|
+
WHEN 0 THEN 'Primitive'
|
|
136
|
+
WHEN 1 THEN 'Struct'
|
|
137
|
+
WHEN 2 THEN 'PrimitiveArray'
|
|
138
|
+
WHEN 3 THEN 'StructArray'
|
|
139
|
+
WHEN 4 THEN 'Navigation'
|
|
140
|
+
END
|
|
141
|
+
),
|
|
142
|
+
'primitiveType',
|
|
143
|
+
(
|
|
144
|
+
CASE pt.PrimitiveType
|
|
145
|
+
WHEN 0x101 THEN 'Binary'
|
|
146
|
+
WHEN 0x201 THEN 'Boolean'
|
|
147
|
+
WHEN 0x301 THEN 'DateTime'
|
|
148
|
+
WHEN 0x401 THEN 'Double'
|
|
149
|
+
WHEN 0x501 THEN 'Integer'
|
|
150
|
+
WHEN 0x601 THEN 'Long'
|
|
151
|
+
WHEN 0x701 THEN 'Point2d'
|
|
152
|
+
WHEN 0x801 THEN 'Point3d'
|
|
153
|
+
WHEN 0x901 THEN 'String'
|
|
154
|
+
WHEN 0xa01 THEN 'IGeometry'
|
|
155
|
+
END
|
|
156
|
+
),
|
|
157
|
+
'extendedTypeName', ExtendedTypeName,
|
|
158
|
+
'navigationRelationship',
|
|
159
|
+
(
|
|
160
|
+
SELECT
|
|
161
|
+
JSON_OBJECT(
|
|
162
|
+
'classId', format('0x%x', nc.Id),
|
|
163
|
+
'classFullName', format('%s:%s', ns.Name, nc.Name)
|
|
164
|
+
)
|
|
165
|
+
FROM ec_Class nc
|
|
166
|
+
JOIN ec_Schema ns ON ns.Id = nc.SchemaId
|
|
167
|
+
WHERE
|
|
168
|
+
nc.Id = pt.NavigationRelationshipClassId
|
|
169
|
+
),
|
|
170
|
+
'structClass',
|
|
171
|
+
(
|
|
172
|
+
SELECT
|
|
173
|
+
JSON_OBJECT(
|
|
174
|
+
'classId', format('0x%x', nc.Id),
|
|
175
|
+
'classFullName', format('%s:%s', ns.Name, nc.Name)
|
|
176
|
+
)
|
|
177
|
+
FROM ec_Class nc
|
|
178
|
+
JOIN ec_Schema ns ON ns.Id = nc.SchemaId
|
|
179
|
+
WHERE
|
|
180
|
+
nc.Id = pt.StructClassId
|
|
181
|
+
),
|
|
182
|
+
'dateTimeInfo', (
|
|
183
|
+
SELECT
|
|
184
|
+
JSON_OBJECT (
|
|
185
|
+
'dateTimeKind', (
|
|
186
|
+
CASE
|
|
187
|
+
WHEN [ca].[Instance] LIKE '%<DateTimeKind>Utc</DateTimeKind>%' COLLATE [NoCase] THEN 'Utc'
|
|
188
|
+
WHEN [ca].[Instance] LIKE '%<DateTimeKind>Local</DateTimeKind>%' COLLATE [NoCase] THEN 'Local'
|
|
189
|
+
ELSE 'Unspecified'
|
|
190
|
+
END
|
|
191
|
+
),
|
|
192
|
+
'dateTimeComponent', (
|
|
193
|
+
CASE
|
|
194
|
+
WHEN [ca].[Instance] LIKE '%<DateTimeComponent>DateTime</DateTimeComponent>%' COLLATE [NoCase] THEN 'DateTime'
|
|
195
|
+
WHEN [ca].[Instance] LIKE '%<DateTimeComponent>Date</DateTimeComponent>%' COLLATE [NoCase] THEN 'Date'
|
|
196
|
+
WHEN [ca].[Instance] LIKE '%<DateTimeComponent>TimeOfDay</DateTimeComponent>%' COLLATE [NoCase] THEN 'TimeOfDay'
|
|
197
|
+
ELSE 'DateTime'
|
|
198
|
+
END
|
|
199
|
+
)
|
|
200
|
+
)
|
|
201
|
+
FROM
|
|
202
|
+
[ec_CustomAttribute] [ca]
|
|
203
|
+
JOIN [ec_Class] [cl] ON [cl].[Id] = [ca].[ClassId]
|
|
204
|
+
JOIN [ec_Schema] [sc] ON [sc].[Id] = [cl].[SchemaId]
|
|
205
|
+
WHERE
|
|
206
|
+
[ca].[ContainerType] = 992
|
|
207
|
+
AND [cl].[Name] = 'DateTimeInfo'
|
|
208
|
+
AND [sc].[Name] = 'CoreCustomAttributes'
|
|
209
|
+
AND [ca].[ContainerId] = [pt].[Id]
|
|
210
|
+
),
|
|
211
|
+
'columns',
|
|
212
|
+
(
|
|
213
|
+
SELECT
|
|
214
|
+
JSON_GROUP_ARRAY(JSON(columnJson))
|
|
215
|
+
FROM
|
|
216
|
+
(
|
|
217
|
+
SELECT
|
|
218
|
+
JSON_OBJECT(
|
|
219
|
+
'table', tb.Name,
|
|
220
|
+
'column', cc.Name,
|
|
221
|
+
'type',
|
|
222
|
+
(
|
|
223
|
+
CASE cc.Type
|
|
224
|
+
WHEN 0 THEN 'Any'
|
|
225
|
+
WHEN 1 THEN 'Boolean'
|
|
226
|
+
WHEN 2 THEN 'Blob'
|
|
227
|
+
WHEN 3 THEN 'Timestamp'
|
|
228
|
+
WHEN 4 THEN 'Real'
|
|
229
|
+
WHEN 5 THEN 'Integer'
|
|
230
|
+
WHEN 6 THEN 'Text'
|
|
231
|
+
END
|
|
232
|
+
),
|
|
233
|
+
'columnKind',
|
|
234
|
+
(
|
|
235
|
+
CASE cc.ColumnKind
|
|
236
|
+
WHEN 0 THEN 'Default'
|
|
237
|
+
WHEN 1 THEN 'Id'
|
|
238
|
+
WHEN 2 THEN 'ClassId'
|
|
239
|
+
WHEN 4 THEN 'SharedData'
|
|
240
|
+
END
|
|
241
|
+
),
|
|
242
|
+
'accessString', pp0.AccessString,
|
|
243
|
+
'isVirtual', cc.IsVirtual OR tb.Type = 4
|
|
244
|
+
) columnJson
|
|
245
|
+
FROM [ec_PropertyMap] [pm0]
|
|
246
|
+
JOIN [ec_Column] [cc] ON [cc].[Id] = [pm0].[ColumnId]
|
|
247
|
+
JOIN [ec_Table] [tb] ON [tb].[Id] = [cc].[TableId]
|
|
248
|
+
JOIN [ec_PropertyPath] [pp0] ON [pp0].[Id] = [pm0].[PropertyPathId]
|
|
249
|
+
WHERE
|
|
250
|
+
[pp0].[RootPropertyId] = pt.Id AND pm0.ClassId = cs.Id
|
|
251
|
+
)
|
|
252
|
+
)
|
|
253
|
+
) propJson
|
|
254
|
+
FROM [ec_PropertyMap] [pm]
|
|
255
|
+
JOIN [ec_PropertyPath] [pp] ON [pp].[Id] = [pm].[PropertyPathId]
|
|
256
|
+
JOIN [ec_Property] [pt] ON [pt].[Id] = [pp].[RootPropertyId]
|
|
257
|
+
WHERE
|
|
258
|
+
pm.ClassId = cs.Id
|
|
259
|
+
GROUP BY
|
|
260
|
+
pt.Id
|
|
261
|
+
)
|
|
262
|
+
)
|
|
263
|
+
) classDef
|
|
264
|
+
FROM [ec_Class] [cs]
|
|
265
|
+
JOIN [ec_ClassMap] [cm] ON [cm].[ClassId] = [cs].[Id]
|
|
266
|
+
JOIN [ec_Schema] [ss] ON [ss].[Id] = [cs].[SchemaId]
|
|
267
|
+
WHERE
|
|
268
|
+
[cs].[Id] = ?
|
|
269
269
|
`;
|
|
270
270
|
return this.db.withPreparedSqliteStatement(sql, (stmt) => {
|
|
271
271
|
stmt.bindId(1, classId);
|
|
@@ -326,15 +326,52 @@ class PartialECChangeUnifier {
|
|
|
326
326
|
this._cache = new Map();
|
|
327
327
|
this._readonly = false;
|
|
328
328
|
}
|
|
329
|
+
/**
|
|
330
|
+
* Get root class id for a given class
|
|
331
|
+
* @param classId given class id
|
|
332
|
+
* @param db use to find root class
|
|
333
|
+
* @returns return root class id
|
|
334
|
+
*/
|
|
335
|
+
static getRootClassId(classId, db) {
|
|
336
|
+
const sql = `
|
|
337
|
+
WITH
|
|
338
|
+
[base_class]([classId], [baseClassId], [Level]) AS(
|
|
339
|
+
SELECT [ch].[ClassId], [ch].[BaseClassId], 0
|
|
340
|
+
FROM [ec_ClassHasBaseClasses] [ch] WHERE [ch].[ClassId] = ?
|
|
341
|
+
UNION ALL
|
|
342
|
+
SELECT [ch].[ClassId], [ch].[BaseClassId], [Level] + 1
|
|
343
|
+
FROM [ec_ClassHasBaseClasses] [ch], [base_class] [bc] WHERE [bc].[BaseClassId] = [ch].[ClassId]
|
|
344
|
+
|
|
345
|
+
)
|
|
346
|
+
SELECT FORMAT('0x%x', [bc].[BaseClassId]) rootClass
|
|
347
|
+
FROM [base_class] [bc]
|
|
348
|
+
WHERE [bc].[ClassId] <> [bc].[BaseClassId]
|
|
349
|
+
AND [bc].[BaseClassId] NOT IN (SELECT [ca].[ContainerId]
|
|
350
|
+
FROM [ec_CustomAttribute] [ca]
|
|
351
|
+
WHERE [ca].[ContainerType] = 30
|
|
352
|
+
AND [ca].[ClassId] IN (SELECT [cc].[Id]
|
|
353
|
+
FROM [ec_Class] [cc]
|
|
354
|
+
JOIN [ec_Schema] [ss] ON [ss].[Id] = [cc].[SchemaId]
|
|
355
|
+
WHERE [cc].[Name] = 'IsMixIn'
|
|
356
|
+
AND [ss].[Name] = 'CoreCustomAttributes'))
|
|
357
|
+
ORDER BY [Level] DESC`;
|
|
358
|
+
return db.withSqliteStatement(sql, (stmt) => {
|
|
359
|
+
stmt.bindId(1, classId);
|
|
360
|
+
if (stmt.step() === core_bentley_1.DbResult.BE_SQLITE_ROW && !stmt.isValueNull(0)) {
|
|
361
|
+
return stmt.getValueString(0);
|
|
362
|
+
}
|
|
363
|
+
return classId;
|
|
364
|
+
});
|
|
365
|
+
}
|
|
329
366
|
/**
|
|
330
367
|
* Combine partial instance with instance with same key if already exists.
|
|
331
368
|
* @param rhs partial instance
|
|
332
369
|
*/
|
|
333
|
-
combine(rhs) {
|
|
370
|
+
combine(rhs, db) {
|
|
334
371
|
if (!rhs.$meta) {
|
|
335
372
|
throw new Error("PartialECChange being combine must have '$meta' property");
|
|
336
373
|
}
|
|
337
|
-
const key = PartialECChangeUnifier.buildKey(rhs);
|
|
374
|
+
const key = PartialECChangeUnifier.buildKey(rhs, db);
|
|
338
375
|
const lhs = this._cache.get(key);
|
|
339
376
|
if (lhs) {
|
|
340
377
|
const { $meta: _, ...restOfRhs } = rhs;
|
|
@@ -342,6 +379,21 @@ class PartialECChangeUnifier {
|
|
|
342
379
|
if (lhs.$meta && rhs.$meta) {
|
|
343
380
|
lhs.$meta.tables = [...rhs.$meta?.tables, ...lhs.$meta?.tables];
|
|
344
381
|
lhs.$meta.changeIndexes = [...rhs.$meta?.changeIndexes, ...lhs.$meta?.changeIndexes];
|
|
382
|
+
// we preserve child class name & id when merging instance.
|
|
383
|
+
if (rhs.$meta.fallbackClassId && lhs.$meta.fallbackClassId && db && rhs.$meta.fallbackClassId !== lhs.$meta.fallbackClassId) {
|
|
384
|
+
const lhsClassId = lhs.$meta.fallbackClassId;
|
|
385
|
+
const rhsClassId = rhs.$meta.fallbackClassId;
|
|
386
|
+
const isRhsIsSubClassOfLhs = db.withPreparedStatement("SELECT ec_instanceof(?,?)", (stmt) => {
|
|
387
|
+
stmt.bindId(1, rhsClassId);
|
|
388
|
+
stmt.bindId(2, lhsClassId);
|
|
389
|
+
stmt.step();
|
|
390
|
+
return stmt.getValue(0).getInteger() === 1;
|
|
391
|
+
});
|
|
392
|
+
if (isRhsIsSubClassOfLhs) {
|
|
393
|
+
lhs.$meta.fallbackClassId = rhs.$meta.fallbackClassId;
|
|
394
|
+
lhs.$meta.classFullName = rhs.$meta.classFullName;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
345
397
|
}
|
|
346
398
|
}
|
|
347
399
|
else {
|
|
@@ -353,8 +405,17 @@ class PartialECChangeUnifier {
|
|
|
353
405
|
* @param change EC change
|
|
354
406
|
* @returns key created from EC change.
|
|
355
407
|
*/
|
|
356
|
-
static buildKey(change) {
|
|
357
|
-
|
|
408
|
+
static buildKey(change, db) {
|
|
409
|
+
let classId = change.ECClassId;
|
|
410
|
+
if (typeof classId === "undefined") {
|
|
411
|
+
if (db && change.$meta?.fallbackClassId) {
|
|
412
|
+
classId = this.getRootClassId(change.$meta.fallbackClassId, db);
|
|
413
|
+
}
|
|
414
|
+
if (typeof classId === "undefined") {
|
|
415
|
+
throw new Error(`unable to resolve ECClassId to root class id.`);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
return `${change.ECInstanceId}-${classId}-${change.$meta?.stage}`.toLowerCase();
|
|
358
419
|
}
|
|
359
420
|
/**
|
|
360
421
|
* Append partial changes which will be combine using there instance key.
|
|
@@ -371,14 +432,14 @@ class PartialECChangeUnifier {
|
|
|
371
432
|
throw new Error("this instance is marked as readonly.");
|
|
372
433
|
}
|
|
373
434
|
if (adaptor.op === "Updated" && adaptor.inserted && adaptor.deleted) {
|
|
374
|
-
this.combine(adaptor.inserted);
|
|
375
|
-
this.combine(adaptor.deleted);
|
|
435
|
+
this.combine(adaptor.inserted, adaptor.reader.db);
|
|
436
|
+
this.combine(adaptor.deleted, adaptor.reader.db);
|
|
376
437
|
}
|
|
377
438
|
else if (adaptor.op === "Inserted" && adaptor.inserted) {
|
|
378
|
-
this.combine(adaptor.inserted);
|
|
439
|
+
this.combine(adaptor.inserted, adaptor.reader.db);
|
|
379
440
|
}
|
|
380
441
|
else if (adaptor.op === "Deleted" && adaptor.deleted) {
|
|
381
|
-
this.combine(adaptor.deleted);
|
|
442
|
+
this.combine(adaptor.deleted, adaptor.reader.db);
|
|
382
443
|
}
|
|
383
444
|
}
|
|
384
445
|
/**
|
|
@@ -591,7 +652,7 @@ class ChangesetECAdaptor {
|
|
|
591
652
|
throw new Error(`unable to get change from changeset reader`);
|
|
592
653
|
}
|
|
593
654
|
let ecClassId = this.reader.op === "Inserted" ? change.inserted?.ECClassId : change.deleted?.ECClassId;
|
|
594
|
-
const
|
|
655
|
+
const classIdPresentInChange = typeof ecClassId !== "undefined";
|
|
595
656
|
let classMap;
|
|
596
657
|
let fallbackClassId;
|
|
597
658
|
if (table.isClassIdVirtual) {
|
|
@@ -604,12 +665,9 @@ class ChangesetECAdaptor {
|
|
|
604
665
|
if (primaryKeys.length === 1) {
|
|
605
666
|
ecClassId = this.getClassIdFromDb(this.reader.tableName, this.reader.primaryKeyValues[0]);
|
|
606
667
|
}
|
|
607
|
-
// this is update and does not include ECClassId and it was also not found from db
|
|
608
|
-
// so its unrecoverable error. Call can skip updates to ignore this error.
|
|
609
|
-
if (!ecClassId)
|
|
610
|
-
throw new Error(`change arg must contain 'ECClassId' property.`);
|
|
611
668
|
}
|
|
612
|
-
|
|
669
|
+
if (ecClassId)
|
|
670
|
+
classMap = this._mapCache.getClassMap(ecClassId);
|
|
613
671
|
if (!classMap) {
|
|
614
672
|
// fallback to root map for table.
|
|
615
673
|
classMap = this._mapCache.getClassMap(table.exclusiveRootClassId);
|
|
@@ -619,7 +677,7 @@ class ChangesetECAdaptor {
|
|
|
619
677
|
}
|
|
620
678
|
if (!classMap)
|
|
621
679
|
throw new Error(`unable to load class map`);
|
|
622
|
-
if (!
|
|
680
|
+
if (!classIdPresentInChange && !ecClassId && !fallbackClassId)
|
|
623
681
|
ecClassId = classMap.id;
|
|
624
682
|
if (this._allowedClasses.size !== 0) {
|
|
625
683
|
if (!this._allowedClasses.has(classMap.id))
|
|
@@ -628,7 +686,7 @@ class ChangesetECAdaptor {
|
|
|
628
686
|
const $meta = {
|
|
629
687
|
tables: [this.reader.tableName],
|
|
630
688
|
op: this.reader.op,
|
|
631
|
-
|
|
689
|
+
classFullName: classMap.name,
|
|
632
690
|
fallbackClassId,
|
|
633
691
|
changeIndexes: [this.reader.changeIndex],
|
|
634
692
|
};
|