Skip to content

Conversation

@eablack
Copy link
Contributor

@eablack eablack commented Jun 14, 2024

  • Update json-schema-to-typescript to v14
  • Update types to latest json.schema
  • Replace tslint with latest eslint
  • Introduce script for updating the types

@eablack eablack requested a review from a team as a code owner June 14, 2024 20:45
* result of postdeploy script
*/
export type Postdeploy = {
[k: string]: unknown
Copy link
Contributor

@justinwilaby justinwilaby Jun 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have strong reservations about this. The ability to append arbitrary keys and make all properties optional to every interface within this schema is generally not useful.

This is a Postdeploy object according to this schema. It's also a PlatformAddOnPlanAction. It's also literally any type in this schema.

const actions: Postdeploy = { notThere: 'myValue' };

This usually indicates a mistake but TS allows it to go on it's merry way.

Also, this will mandate the use of the optional chaining operator when reading keys:

const postdeploy: Postdeploy = {exit_code: 0};
if (postdeploy?.exit_code === 0) {
  // Do stuff
}

PostDeploy.exit_code is also listed as readonly in the schema but it's optional/read/write in the interface

"exit_code": {
              "description": "The exit code of the postdeploy script",
              "example": 1,
              "readOnly": true,
              "type": [
                "integer"
              ]
            }

@justinwilaby
Copy link
Contributor

justinwilaby commented Jun 14, 2024

I'm not sure this new schema alleviates the problems we have with the existing one.
1.readOnly flag not honored
2. strictProperties flag not honored. ref: https://github.com/java-json-tools/json-schema-validator/wiki/v5%3a-strictProperties
3. Strange unions and intersections with excessive inlining.

I believe we need a parser that understand JSON Hyper-Schema since this is what is specified in the Heroku API JSON document. e.g.

"release": {
      "description": "A release represents a combination of code, config vars and add-ons for an app on Heroku.",
      "$schema": "http://json-schema.org/draft-04/hyper-schema", <----------- Hyper Schema
// ...

Copy link
Contributor

@justinwilaby justinwilaby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not yet convinced this is the best path forward. See the main thread for a comment on my specific concerns.

@eablack eablack marked this pull request as draft June 14, 2024 23:26
@eablack eablack requested a review from justinwilaby July 12, 2024 18:13
@eablack eablack marked this pull request as ready for review July 12, 2024 18:13
Copy link
Contributor

@justinwilaby justinwilaby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After a discussion with Eric, this PR will be used for 1.x while 2.x efforts focus on applying hyper-schema rules.

@eablack eablack merged commit 26b54d0 into main Jul 26, 2024
@eablack eablack deleted the eb/upgrade-tool-and-update-types branch July 26, 2024 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants