-
Notifications
You must be signed in to change notification settings - Fork 214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix GraphicRepresentation types according to latest Mesh Export API docs #7570
base: master
Are you sure you want to change the base?
Changes from 5 commits
3e32c78
fb522b4
67f0bb2
5c26cd4
c5c03d6
d142fdd
49ed469
671b1c8
d116c2a
6c62d84
10b3b02
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"changes": [ | ||
{ | ||
"packageName": "@itwin/frontend-tiles", | ||
"comment": "Update GraphicRepresentationFormat type and GraphicRepresentationStatus enum to reflect the latest Mesh Export Service docs.", | ||
"type": "none" | ||
} | ||
], | ||
"packageName": "@itwin/frontend-tiles" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
|
||
import { IModelApp, IModelConnection, SpatialTileTreeReferences, SpatialViewState } from "@itwin/core-frontend"; | ||
import { createBatchedSpatialTileTreeReferences } from "./BatchedSpatialTileTreeRefs"; | ||
import { queryGraphicRepresentations } from "./GraphicsProvider/GraphicRepresentationProvider"; | ||
import { GraphicRepresentationFormat, queryGraphicRepresentations } from "./GraphicsProvider/GraphicRepresentationProvider"; | ||
import { AccessToken } from "@itwin/core-bentley"; | ||
import { obtainIModelTilesetUrl, ObtainIModelTilesetUrlArgs } from "./GraphicsProvider/GraphicsProvider"; | ||
|
||
|
@@ -92,7 +92,7 @@ export async function* queryMeshExports(args: QueryMeshExportsArgs): AsyncIterab | |
changeId: args.changesetId, | ||
type: "IMODEL", | ||
}, | ||
format: "IMDL", | ||
format: "IMODEL" as GraphicRepresentationFormat, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is the cast here necessary? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Without the cast the compiler was complaining about the type of
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. while wordier, i think its safer to extract the type out for an internal interface to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed |
||
urlPrefix: args.urlPrefix, | ||
includeIncomplete: args.includeIncomplete, | ||
enableCDN: args.enableCDN, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,19 +10,17 @@ import { IModelApp, ITWINJS_CORE_VERSION } from "@itwin/core-frontend"; | |
/** The expected format of the Graphic Representation | ||
* @beta | ||
*/ | ||
/* eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents */ | ||
export type GraphicRepresentationFormat = "IMDL" | "3DTILES" | string; | ||
export type GraphicRepresentationFormat = "IMODEL" | "3DTiles" | "CESIUM"; | ||
|
||
/** Graphic representations are generated from Data Sources. | ||
* The status of a Graphic Representation indicates the progress of that generation process. | ||
* @beta | ||
*/ | ||
// ###TODO this needs to be expanded to include more statuses, and/or "failed" needs to be replaced with "invalid". | ||
export enum GraphicRepresentationStatus { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. curious why in one place we're using a string literal type and another place an enum There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't completely remember, but my guess is because GraphicRepresentationFormat used to have enum values that were strings different from the constant names, like this:
Why those different strings were necessary to begin with, I'm not sure and it could have just been a poor decision. Since all that is needed are the strings "InProgress", "Complete", "NotStarted", and "Invalid", it could become a type like GraphicRepresentationFormat There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I realized one reason we did this is the enum is used in a conditional type definition of GraphicRepresentation here:
Where the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @aruniverse do you have a preference between enum and string literal type here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I personally would prefer the string literals, not a huge fan of enums. I think the Exclude utility would be perfect for the discriminated union type There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also fixed this |
||
InProgress = "In progress", | ||
InProgress = "InProgress", | ||
Complete = "Complete", | ||
NotStarted = "Not started", | ||
Failed = "Failed", | ||
NotStarted = "NotStarted", | ||
Invalid = "Invalid", | ||
} | ||
|
||
/** | ||
|
@@ -138,8 +136,6 @@ export async function* queryGraphicRepresentations(args: QueryGraphicRepresentat | |
iModelId: string; | ||
changesetId: string; | ||
exportType: string; | ||
geometryOptions: any; | ||
viewDefinitionFilter: any; | ||
}; | ||
|
||
/* eslint-disable-next-line @typescript-eslint/naming-convention */ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@danieliborra @arvindsvenkat To clarify, is "3DFT" as an export type still returned by the service? If so I'll add it here