Skip to content
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

Move validation types from perseus to perseus-score #2101

Merged
merged 9 commits into from
Jan 17, 2025

Conversation

handeyeco
Copy link
Contributor

@handeyeco handeyeco commented Jan 14, 2025

Summary:

This looks like a lot, but it's basically just moving one file and updating imports.

Issue: LEMS-2737

Test plan:

  • No functionality should change, just moving types

@handeyeco handeyeco self-assigned this Jan 14, 2025
Copy link
Contributor

github-actions bot commented Jan 14, 2025

npm Snapshot: Published

Good news!! We've packaged up the latest commit from this PR (31e4d4f) and published it to npm. You
can install it using the tag PR2101.

Example:

yarn add @khanacademy/perseus@PR2101

If you are working in Khan Academy's webapp, you can run:

./dev/tools/bump_perseus_version.sh -t PR2101

Copy link
Contributor

github-actions bot commented Jan 14, 2025

Size Change: +176 B (+0.01%)

Total Size: 1.47 MB

Filename Size Change
packages/kmath/dist/es/index.js 86.8 kB +3.71 kB (+4.47%)
packages/math-input/dist/es/index.js 77.6 kB -355 B (-0.46%)
packages/perseus-core/dist/es/index.js 27.1 kB +4.03 kB (+17.47%) ⚠️
packages/perseus-editor/dist/es/index.js 689 kB -268 B (-0.04%)
packages/perseus-score/dist/es/index.js 113 kB +10.1 kB (+9.81%) ⚠️
packages/perseus/dist/es/index.js 395 kB -17.1 kB (-4.14%)
packages/perseus/dist/es/strings.js 5.1 kB +54 B (+1.07%)
ℹ️ View Unchanged
Filename Size
packages/kas/dist/es/index.js 39 kB
packages/keypad-context/dist/es/index.js 760 B
packages/math-input/dist/es/strings.js 1.79 kB
packages/perseus-linter/dist/es/index.js 22.2 kB
packages/pure-markdown/dist/es/index.js 3.66 kB
packages/simple-markdown/dist/es/index.js 12.5 kB

compressed-size-action

@handeyeco handeyeco changed the title move validation types Move validation types from perseus to perseus-score Jan 14, 2025
@handeyeco handeyeco marked this pull request as ready for review January 14, 2025 16:26
@handeyeco handeyeco requested review from jeremywiebe, Myranae and a team January 14, 2025 16:28
Copy link
Collaborator

@jeremywiebe jeremywiebe left a comment

Choose a reason for hiding this comment

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

Looks good. The one bit I'm not 100% sure on is if we put the UserInput types into perseus-score or perseus-core. I guess it's a bit of a two-way door that we can change if we need to.

packages/perseus-core/src/types.ts Outdated Show resolved Hide resolved

// TODO: should these be part of data-schema?
// Used for NumberLine
export type Relationship = "lt" | "gt" | "le" | "ge";
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think so, yes. Looks like correctRel on the NumberLineWidgetOptions should actually be using this also.

correctRel: string | null | undefined;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm 🤔 But correctRel also has "eq"

    // The correct relative value. default: "eq". options: "eq", "lt", "gt", "le", "ge"
    correctRel: string | null | undefined;

Whereas Relationship doesn't include that. I'm just going to update my TODO to be about investigating merging the two.

@@ -4,7 +4,7 @@ import scoreDropdown from "./score-dropdown";
import type {
PerseusDropdownRubric,
PerseusDropdownUserInput,
} from "../../validation.types";
} from "@khanacademy/perseus-score";
Copy link
Collaborator

Choose a reason for hiding this comment

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

I was scanning this PR and only noticed this at this point...

If we put UserInput types in @perseus-score, then perseus will need to reference it as the widgets themselves originate that data (in getUserInput()). I feel these user input types should go in perseus-core (not in data-schema.ts necessarily, but they are a shared type).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Jeremy and I talked about this in Slack and decided that validation.types can stay in perseus-score for now.

Jeremy was concerned about perseus depending on perseus-score, but we realized that we'll have to do that because the BE and the FE will both require access to the validators in perseus-score.

We're going to ship as-is and iterate as-needed.

* move categorizer scoring logic

* Move NumericInput and InputNumber scoring logic to `perseus-score` (#2105)

* move numeric-input and input-number

* respond to Jeremy's feedback

* Move Radio scorer/validator (#2106)

* move radio scorer/validator

* lint errorToString better

* comment my unique type

* respond to Jeremy's feedback

* Move scoring logic: CSProgram, Iframe, and Dropdown (#2111)

* cs-program

* move dropdown

* move iframe

* Move scoring logic: Table, NumberLine, Matcher (#2112)

* move table

* number-line

* move matcher

* Move scorers: Plotter and Sorter (#2113)

* plotter

* sorter

* Move scorer: Orderer (#2114)

* orderer

* Move scorerer: LabelImage (#2115)

* move label-image

* rename labelImageScoreMarker

* Move scoring logic: Matrix (#2116)

* move matrix

* Move scoring logic: Expression (#2118)

* move expression scorer

* respond to Ben's feedback

* merge Grapher move

* fix conflict again

* Move scorer: Grapher (#2119)

* move matrix

* move expression scorer

* move grapher scorer

* respond to Ben's feedback

* Move scorer: Interactive Graph (#2120)

* STOPSHIP some type errors still

* add back duplicate declarations

* add back Line duplicate

* all tests passing

* Revert changes to underscore's isEqual (#2125)

## Summary:
[Original comment](#2113 (comment))

I made a separate PR because I made this mistake in a couple of PRs so I thought I'd knock them out all at once.

Issue: LEMS-2737

## Test plan:

Author: handeyeco

Reviewers: jeremywiebe, benchristel

Required Reviewers:

Approved By: jeremywiebe

Checks: ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ❌ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ✅ Check builds for changes in size (ubuntu-latest, 20.x), ⏹️  [cancelled] Publish npm snapshot (ubuntu-latest, 20.x), ⏹️  [cancelled] Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ⏹️  [cancelled] Check builds for changes in size (ubuntu-latest, 20.x), ⏹️  [cancelled] Cypress (ubuntu-latest, 20.x), ⏹️  [cancelled] Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ⏹️  [cancelled] Publish npm snapshot (ubuntu-latest, 20.x), ⏹️  [cancelled] Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ⏹️  [cancelled] Check builds for changes in size (ubuntu-latest, 20.x), ⏹️  [cancelled] Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ⏹️  [cancelled] Cypress (ubuntu-latest, 20.x), ✅ Publish Storybook to Chromatic (ubuntu-latest, 20.x)

Pull Request URL: #2125

* respond to Jeremy's feedback
@handeyeco handeyeco merged commit 9cabe68 into main Jan 17, 2025
8 checks passed
@handeyeco handeyeco deleted the LEMS-2737/validation-types branch January 17, 2025 21:38
jeremywiebe pushed a commit that referenced this pull request Jan 20, 2025
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated.


# Releases
## @khanacademy/perseus@51.0.0

### Major Changes

-   [#2101](#2101) [`9cabe689a`](9cabe68) Thanks [@handeyeco](https://github.com/handeyeco)! - Move scorers and validators to `perseus-score`

### Minor Changes

-   [#2127](#2127) [`6f2813cfc`](6f2813c) Thanks [@benchristel](https://github.com/benchristel)! - Avoid adding undefined values to objects parsed from Perseus JSON when properties are missing.

### Patch Changes

-   [#2130](#2130) [`165305e11`](165305e) Thanks [@jeremywiebe](https://github.com/jeremywiebe)! - Change interactive-graph visual regression stories to Storybook's CSF v3


-   [#2077](#2077) [`faccc2d59`](faccc2d) Thanks [@benchristel](https://github.com/benchristel)! - Internal: Enable the exhaustive test tool for parsePerseusItem to test articles.


-   [#2030](#2030) [`d96821e08`](d96821e) Thanks [@nishasy](https://github.com/nishasy)! - [SR] Linear System - add screen reader support for Linear System interactive graph


-   [#2036](#2036) [`0f8d11c0b`](0f8d11c) Thanks [@nishasy](https://github.com/nishasy)! - [SR] Ray graph - Add screen reader support for Ray interactive graph


-   [#2109](#2109) [`41ffd4a71`](41ffd4a) Thanks [@dependabot](https://github.com/apps/dependabot)! - Updating our wonder-blocks packages with the latest versions.

-   Updated dependencies \[[`9cabe689a`](9cabe68), [`41ffd4a71`](41ffd4a)]:
    -   @khanacademy/kmath@0.3.0
    -   @khanacademy/perseus-core@3.2.0
    -   @khanacademy/perseus-score@1.1.0
    -   @khanacademy/math-input@22.2.1
    -   @khanacademy/kas@0.4.11
    -   @khanacademy/keypad-context@1.0.14
    -   @khanacademy/perseus-linter@1.2.13
    -   @khanacademy/pure-markdown@0.3.22
    -   @khanacademy/simple-markdown@0.13.15

## @khanacademy/kmath@0.3.0

### Minor Changes

-   [#2101](#2101) [`9cabe689a`](9cabe68) Thanks [@handeyeco](https://github.com/handeyeco)! - Move scorers and validators to `perseus-score`

### Patch Changes

-   Updated dependencies \[[`9cabe689a`](9cabe68)]:
    -   @khanacademy/perseus-core@3.2.0

## @khanacademy/perseus-core@3.2.0

### Minor Changes

-   [#2101](#2101) [`9cabe689a`](9cabe68) Thanks [@handeyeco](https://github.com/handeyeco)! - Move scorers and validators to `perseus-score`

## @khanacademy/perseus-score@1.1.0

### Minor Changes

-   [#2101](#2101) [`9cabe689a`](9cabe68) Thanks [@handeyeco](https://github.com/handeyeco)! - Move scorers and validators to `perseus-score`

### Patch Changes

-   Updated dependencies \[[`9cabe689a`](9cabe68)]:
    -   @khanacademy/kmath@0.3.0
    -   @khanacademy/perseus-core@3.2.0
    -   @khanacademy/kas@0.4.11

## @khanacademy/kas@0.4.11

### Patch Changes

-   Updated dependencies \[[`9cabe689a`](9cabe68)]:
    -   @khanacademy/perseus-core@3.2.0

## @khanacademy/keypad-context@1.0.14

### Patch Changes

-   Updated dependencies \[[`9cabe689a`](9cabe68)]:
    -   @khanacademy/perseus-core@3.2.0

## @khanacademy/math-input@22.2.1

### Patch Changes

-   [#2101](#2101) [`9cabe689a`](9cabe68) Thanks [@handeyeco](https://github.com/handeyeco)! - Move scorers and validators to `perseus-score`


-   [#2109](#2109) [`41ffd4a71`](41ffd4a) Thanks [@dependabot](https://github.com/apps/dependabot)! - Updating our wonder-blocks packages with the latest versions.

-   Updated dependencies \[[`9cabe689a`](9cabe68)]:
    -   @khanacademy/perseus-core@3.2.0
    -   @khanacademy/keypad-context@1.0.14

## @khanacademy/perseus-editor@17.3.1

### Patch Changes

-   [#2101](#2101) [`9cabe689a`](9cabe68) Thanks [@handeyeco](https://github.com/handeyeco)! - Move scorers and validators to `perseus-score`


-   [#2126](#2126) [`518b005f2`](518b005) Thanks [@benchristel](https://github.com/benchristel)! - Fix a React warning about non-unique component keys in the exercise editor.


-   [#2109](#2109) [`41ffd4a71`](41ffd4a) Thanks [@dependabot](https://github.com/apps/dependabot)! - Updating our wonder-blocks packages with the latest versions.

-   Updated dependencies \[[`165305e11`](165305e), [`6f2813cfc`](6f2813c), [`faccc2d59`](faccc2d), [`9cabe689a`](9cabe68), [`d96821e08`](d96821e), [`0f8d11c0b`](0f8d11c), [`41ffd4a71`](41ffd4a)]:
    -   @khanacademy/perseus@51.0.0
    -   @khanacademy/kmath@0.3.0
    -   @khanacademy/perseus-core@3.2.0
    -   @khanacademy/perseus-score@1.1.0
    -   @khanacademy/math-input@22.2.1
    -   @khanacademy/kas@0.4.11
    -   @khanacademy/keypad-context@1.0.14
    -   @khanacademy/pure-markdown@0.3.22

## @khanacademy/perseus-linter@1.2.13

### Patch Changes

-   Updated dependencies \[[`9cabe689a`](9cabe68)]:
    -   @khanacademy/perseus-core@3.2.0

## @khanacademy/pure-markdown@0.3.22

### Patch Changes

-   Updated dependencies \[[`9cabe689a`](9cabe68)]:
    -   @khanacademy/perseus-core@3.2.0
    -   @khanacademy/simple-markdown@0.13.15

## @khanacademy/simple-markdown@0.13.15

### Patch Changes

-   Updated dependencies \[[`9cabe689a`](9cabe68)]:
    -   @khanacademy/perseus-core@3.2.0

## @khanacademy/perseus-dev-ui@5.1.1

### Patch Changes

-   [#2101](#2101) [`9cabe689a`](9cabe68) Thanks [@handeyeco](https://github.com/handeyeco)! - Move scorers and validators to `perseus-score`


-   [#2109](#2109) [`41ffd4a71`](41ffd4a) Thanks [@dependabot](https://github.com/apps/dependabot)! - Updating our wonder-blocks packages with the latest versions.

-   Updated dependencies \[[`9cabe689a`](9cabe68), [`41ffd4a71`](41ffd4a)]:
    -   @khanacademy/kmath@0.3.0
    -   @khanacademy/perseus-core@3.2.0
    -   @khanacademy/math-input@22.2.1
    -   @khanacademy/kas@0.4.11
    -   @khanacademy/perseus-linter@1.2.13
    -   @khanacademy/pure-markdown@0.3.22
    -   @khanacademy/simple-markdown@0.13.15

Author: khan-actions-bot

Reviewers: jeremywiebe

Required Reviewers:

Approved By: jeremywiebe

Checks: ⏭️  Publish npm snapshot, ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ Check builds for changes in size (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x)

Pull Request URL: #2117
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