Skip to content

Commit 52f55d0

Browse files
authored
Merge pull request #12789 from CesiumGS/itwindata-remove-deprecation
Remove code for deprecated argument signatures in `ITwinData`
2 parents 59741ef + f770e6f commit 52f55d0

File tree

3 files changed

+30
-143
lines changed

3 files changed

+30
-143
lines changed

CHANGES.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Change Log
22

3+
## 1.133 - 2025-09-02
4+
5+
### @cesium/engine
6+
7+
#### Breaking Changes :mega:
8+
9+
- Removed the argument fallback in `ITwinData.*` functions. Please switch to the new options argument signature [#12778](https://github.com/CesiumGS/cesium/issues/12778)
10+
311
## 1.132 - 2025-08-01
412

513
### @cesium/engine

packages/engine/Source/Scene/ITwinData.js

Lines changed: 22 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import Check from "../Core/Check.js";
77
import KmlDataSource from "../DataSources/KmlDataSource.js";
88
import GeoJsonDataSource from "../DataSources/GeoJsonDataSource.js";
99
import DeveloperError from "../Core/DeveloperError.js";
10-
import deprecationWarning from "../Core/deprecationWarning.js";
1110

1211
/**
1312
* Methods for loading iTwin platform data into CesiumJS
@@ -45,20 +44,11 @@ const ITwinData = {};
4544
* @throws {RuntimeError} If all exports for the given iModel are Invalid
4645
* @throws {RuntimeError} If the iTwin API request is not successful
4746
*/
48-
ITwinData.createTilesetFromIModelId = async function (options) {
49-
let internalOptions = options;
50-
51-
if (typeof options === "string") {
52-
// the old signature was (iModelId: string, options?: Cesium3DTileset.ConstructorOptions)
53-
// grab the later arguments directly instead of in the params only for this special case
54-
internalOptions = { iModelId: options, tilesetOptions: arguments[1] };
55-
deprecationWarning(
56-
"ITwinData.createTilesetFromIModelId",
57-
"The arguments signature for ITwinData functions has changed in 1.132 in favor of a single options object. Please update your code. This fallback will be removed in 1.133",
58-
);
59-
}
60-
61-
const { iModelId, changesetId, tilesetOptions } = internalOptions;
47+
ITwinData.createTilesetFromIModelId = async function ({
48+
iModelId,
49+
changesetId,
50+
tilesetOptions,
51+
}) {
6252
const { exports } = await ITwinPlatform.getExports(iModelId, changesetId);
6353

6454
if (
@@ -111,26 +101,12 @@ ITwinData.createTilesetFromIModelId = async function (options) {
111101
*
112102
* @throws {RuntimeError} if the type of reality data is not supported by this function
113103
*/
114-
ITwinData.createTilesetForRealityDataId = async function (options) {
115-
let internalOptions = options;
116-
117-
if (typeof options === "string") {
118-
// the old signature was (iTwinId: string, realityDataId: string, type: RealityDataType, rootDocument: string)
119-
// grab the later arguments directly instead of in the params only for this special case
120-
internalOptions = {
121-
iTwinId: options,
122-
realityDataId: arguments[1],
123-
type: arguments[2],
124-
rootDocument: arguments[3],
125-
};
126-
deprecationWarning(
127-
"ITwinData.createTilesetFromIModelId",
128-
"The arguments signature for ITwinData functions has changed in 1.132 in favor of a single options object. Please update your code. This fallback will be removed in 1.133",
129-
);
130-
}
131-
const { iTwinId, realityDataId } = internalOptions;
132-
let { type, rootDocument } = internalOptions;
133-
104+
ITwinData.createTilesetForRealityDataId = async function ({
105+
iTwinId,
106+
realityDataId,
107+
type,
108+
rootDocument,
109+
}) {
134110
//>>includeStart('debug', pragmas.debug);
135111
Check.typeOf.string("iTwinId", iTwinId);
136112
Check.typeOf.string("realityDataId", realityDataId);
@@ -189,26 +165,12 @@ ITwinData.createTilesetForRealityDataId = async function (options) {
189165
*
190166
* @throws {RuntimeError} if the type of reality data is not supported by this function
191167
*/
192-
ITwinData.createDataSourceForRealityDataId = async function (options) {
193-
let internalOptions = options;
194-
195-
if (typeof options === "string") {
196-
// the old signature was (iTwinId: string, realityDataId: string, type: RealityDataType, rootDocument: string)
197-
// grab the later arguments directly instead of in the params only for this special case
198-
internalOptions = {
199-
iTwinId: options,
200-
realityDataId: arguments[1],
201-
type: arguments[2],
202-
rootDocument: arguments[3],
203-
};
204-
deprecationWarning(
205-
"ITwinData.createTilesetFromIModelId",
206-
"The arguments signature for ITwinData functions has changed in 1.132 in favor of a single options object. Please update your code. This fallback will be removed in 1.133",
207-
);
208-
}
209-
const { iTwinId, realityDataId } = internalOptions;
210-
let { type, rootDocument } = internalOptions;
211-
168+
ITwinData.createDataSourceForRealityDataId = async function ({
169+
iTwinId,
170+
realityDataId,
171+
type,
172+
rootDocument,
173+
}) {
212174
//>>includeStart('debug', pragmas.debug);
213175
Check.typeOf.string("iTwinId", iTwinId);
214176
Check.typeOf.string("realityDataId", realityDataId);
@@ -263,25 +225,11 @@ ITwinData.createDataSourceForRealityDataId = async function (options) {
263225
* @param {number} [options.limit=10000] number of items per page, must be between 1 and 10,000 inclusive
264226
* @returns {Promise<GeoJsonDataSource>}
265227
*/
266-
ITwinData.loadGeospatialFeatures = async function (options) {
267-
let internalOptions = options;
268-
269-
if (typeof options === "string") {
270-
// the old signature was (iTwinId: string, collectionId: string, limit: number)
271-
// grab the later arguments directly instead of in the params only for this special case
272-
internalOptions = {
273-
iTwinId: options,
274-
collectionId: arguments[1],
275-
limit: arguments[2],
276-
};
277-
deprecationWarning(
278-
"ITwinData.createTilesetFromIModelId",
279-
"The arguments signature for ITwinData functions has changed in 1.132 in favor of a single options object. Please update your code. This fallback will be removed in 1.133",
280-
);
281-
}
282-
283-
const { iTwinId, collectionId, limit } = internalOptions;
284-
228+
ITwinData.loadGeospatialFeatures = async function ({
229+
iTwinId,
230+
collectionId,
231+
limit,
232+
}) {
285233
//>>includeStart('debug', pragmas.debug);
286234
Check.typeOf.string("iTwinId", iTwinId);
287235
Check.typeOf.string("collectionId", collectionId);

packages/engine/Specs/Scene/ITwinDataSpec.js

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -126,17 +126,6 @@ describe("ITwinData", () => {
126126
expect(tilesetSpy).toHaveBeenCalledTimes(1);
127127
expect(tilesetSpy.calls.mostRecent().args[1]).toEqual(tilesetOptions);
128128
});
129-
130-
it("passes tileset options through to the tileset constructor DEPRECATED arguments", async () => {
131-
spyOn(ITwinPlatform, "getExports").and.resolveTo({
132-
exports: [createMockExport(1, ITwinPlatform.ExportStatus.Complete)],
133-
});
134-
const tilesetSpy = spyOn(Cesium3DTileset, "fromUrl");
135-
const tilesetOptions = { show: false };
136-
await ITwinData.createTilesetFromIModelId("imodel-id-1", tilesetOptions);
137-
expect(tilesetSpy).toHaveBeenCalledTimes(1);
138-
expect(tilesetSpy.calls.mostRecent().args[1]).toEqual(tilesetOptions);
139-
});
140129
});
141130

142131
describe("createTilesetForRealityDataId", () => {
@@ -242,23 +231,6 @@ describe("ITwinData", () => {
242231
maximumScreenSpaceError: 4,
243232
});
244233
});
245-
246-
it("creates a tileset from the constructed blob url using DEPRECATED arguments", async () => {
247-
const tilesetUrl =
248-
"https://example.com/root/document/path.json?auth=token";
249-
getUrlSpy.and.resolveTo(tilesetUrl);
250-
251-
await ITwinData.createTilesetForRealityDataId(
252-
"itwin-id-1",
253-
"reality-data-id-1",
254-
ITwinPlatform.RealityDataType.Cesium3DTiles,
255-
"root/document/path.json",
256-
);
257-
258-
expect(tilesetSpy).toHaveBeenCalledOnceWith(tilesetUrl, {
259-
maximumScreenSpaceError: 4,
260-
});
261-
});
262234
});
263235

264236
describe("createDataSourceForRealityDataId", () => {
@@ -367,22 +339,6 @@ describe("ITwinData", () => {
367339
expect(kmlSpy).not.toHaveBeenCalled();
368340
});
369341

370-
it("creates a GeoJsonDataSource from the constructed blob url if the type is GeoJSON using DEPRECATED arguments", async () => {
371-
const tilesetUrl =
372-
"https://example.com/root/document/path.json?auth=token";
373-
getUrlSpy.and.resolveTo(tilesetUrl);
374-
375-
await ITwinData.createDataSourceForRealityDataId(
376-
"itwin-id-1",
377-
"reality-data-id-1",
378-
ITwinPlatform.RealityDataType.GeoJSON,
379-
"root/document/path.json",
380-
);
381-
382-
expect(geojsonSpy).toHaveBeenCalledOnceWith(tilesetUrl);
383-
expect(kmlSpy).not.toHaveBeenCalled();
384-
});
385-
386342
it("creates a KmlDataSource from the constructed blob url if the type is KML", async () => {
387343
const tilesetUrl =
388344
"https://example.com/root/document/path.json?auth=token";
@@ -398,22 +354,6 @@ describe("ITwinData", () => {
398354
expect(kmlSpy).toHaveBeenCalledOnceWith(tilesetUrl);
399355
expect(geojsonSpy).not.toHaveBeenCalled();
400356
});
401-
402-
it("creates a KmlDataSource from the constructed blob url if the type is KML using DEPRECATED arguments", async () => {
403-
const tilesetUrl =
404-
"https://example.com/root/document/path.json?auth=token";
405-
getUrlSpy.and.resolveTo(tilesetUrl);
406-
407-
await ITwinData.createDataSourceForRealityDataId(
408-
"itwin-id-1",
409-
"reality-data-id-1",
410-
ITwinPlatform.RealityDataType.KML,
411-
"root/document/path.json",
412-
);
413-
414-
expect(kmlSpy).toHaveBeenCalledOnceWith(tilesetUrl);
415-
expect(geojsonSpy).not.toHaveBeenCalled();
416-
});
417357
});
418358

419359
describe("loadGeospatialFeatures", () => {
@@ -489,14 +429,5 @@ describe("ITwinData", () => {
489429
"https://api.bentley.com/geospatial-features/itwins/itwin-id-1/ogc/collections/collection-id-1/items?limit=10000&client=CesiumJS",
490430
);
491431
});
492-
493-
it("creates a GeoJsonDataSource from the constructed blob url if the type is GeoJSON using DEPRECATED arguments", async () => {
494-
await ITwinData.loadGeospatialFeatures("itwin-id-1", "collection-id-1");
495-
496-
expect(geojsonSpy).toHaveBeenCalledTimes(1);
497-
expect(geojsonSpy.calls.mostRecent().args[0].url).toEqual(
498-
"https://api.bentley.com/geospatial-features/itwins/itwin-id-1/ogc/collections/collection-id-1/items?limit=10000&client=CesiumJS",
499-
);
500-
});
501432
});
502433
});

0 commit comments

Comments
 (0)