Compose SDK schema not as type safe as initially thought
Hello!
I have recently started working with the Sisense SDK with great success. I am pleased with the experience so far, so I would like first to congratulate the team on the results!
I am currently using the Sisense CLI to generate a typescript schema for a couple of elasticubes and it has been a wonderful boost to my productivity.
I write to you because I noticed an issue after some schema changes: tsc did not warn me of missing Dimensions. I would have expected it to show errors when the schema dropped dimensions that are referenced in code. Alas, I got nothing but a runtime error. I tracked the issue down to this line: https://github.com/sisense/compose-sdk-monorepo/blob/aac97b0e92b07143cea40013fd39a4509f8ea233/packages/sdk-data/src/dimensional-model/interfaces.ts#L252
That line makes the entire schema less type safe. Would it be possible to remove it or make it more type safe some other way?
Thank you!
Kind regards,
Cristian Necula
cristinecula
OP1 year agoOleh_Zaichenko Hi there! Is there any update on this?
Oleh_Zaichenko
·1 year agoHi Cristian,
Thank you for your kind words and for sharing your experience with ComposeSDK! We’re glad to hear it has been a boost to your productivity.
Regarding the issue you encountered, I’d like to clarify:
Are you looking for an automatic mechanism that updates the datasource TS types generated by the `sdk-cli` tool whenever there are schema changes in the Sisense instance?
cristinecula
OP1 year ago> Are you looking for an automatic mechanism that updates the datasource TS types generated by the `sdk-cli` tool whenever there are schema changes in the Sisense instance?
No. I am expressing my concern that the generated schema is too lax and does not warn me when Dimensions have been removed. More specifically: I am using the schema to build a query for `useExecuteQuery` and I am specifying dimensions such as `DM.Article.SupplierName`. The problem I ran into is that I made changes to the elasticube and updated the schema using the cli and now the `SupplierName` dimension does not exist anymore, but I get no error from the typescript type checker. One can type `DM.Article.BogusDimension` and there will be no error. This could be easily solved in the SDK by dropping `[propName: string]: any;` from the type definition of `Dimension`.
Oleh_Zaichenko
·1 year agoI understand now, and I really appreciate the detailed explanation. I fully agree that this is something that should be improved.
I believe we will address this in the near future.
Thank you!