codemods: model-to-schema typescript support#10474
codemods: model-to-schema typescript support#10474runspired merged 16 commits intowarp-drive-data:mainfrom
Conversation
7d61f8b to
83d7f90
Compare
| collectTraitImports(extendedTraits, imports, options); | ||
|
|
||
| const traitSchemaName = traitInterfaceName; | ||
| const traitSchemaName = `${toPascalCase(baseName)}Schema`; |
There was a problem hiding this comment.
A recurring problem so far is shotgun surgeries like this which are also very error prone that Claude was very happy with. Additionally the codemod often lacks the ability to quickly refer from a file to it's dependencies for the exact same reason.
There's on-going effort to wrangle this up https://github.com/BobrImperator/data/compare/codemod/typescript-support...BobrImperator:data:codemod/poc-typescript?expand=1
6d62aed to
5894553
Compare
5894553 to
d5cec6a
Compare
…e, update codemod to account
260f072 to
640d45c
Compare
640d45c to
5801423
Compare
aa9411f to
bf28e98
Compare
| readonly isForControlsAssessment: boolean | null; | ||
| readonly frameworks: HasMany<Framework>; | ||
| }", | ||
| // @ts-expect-error TS disallows it. However in real world \`Resource\` "wins" when merged. |
There was a problem hiding this comment.
Perhaps could contain a documentation link
0d94f23 to
23db85f
Compare
Merges the codemod-tests branch which adds: - SchemaArtifact config system (artifact.ts) - createExtension utility for stripping schema fields from models - New test harness with basic-native-model-class and extension tests - Updated generateMergedSchemaCode to return GeneratedSchemaParts - Refactored function signatures across schema-generation utils
Replace FIXME placeholder in mixin and model trait generation with actual assembled code from generateMergedSchemaCode return value. Add combineSchemasAndTypes, resourcesImport, and traitsImport to DEFAULT_TEST_OPTIONS. Fix stale test assertions: .schema.js → .schema.ts, unknown | null → unknown, import path extensions, and import prefix bug in transformModelToResourceImport.
23db85f to
823ba15
Compare
| "resources/": "__dir__", | ||
| "resources/typed.ext.ts": " | ||
| import BaseModel from 'test-app/models/base-model'; | ||
| import type { Typed } from './typed.type.ts'; |
There was a problem hiding this comment.
typed.type.ts is used but not generated
| import type { Type } from '@ember-data/core-types/symbols'; | ||
| import type { StaticBaseModelTraitTrait } from 'test-app/data/traits/static-base-model-trait.schema'; | ||
| import type { TypedExtension } from 'test-app/data/resources/typed.ext'; | ||
| import type { LegacyResourceSchema } from '@warp-drive/core-types/schema/fields'; |
There was a problem hiding this comment.
Removes the imports but there's no typed.ts file which would declare the merged interfaces
Add more tests for combineSchemaAndTypes true/false setting
6183097 to
52248f6
Compare
When a model like `class Foo extends BaseModel.extend(Mixin1, Mixin2)` is transformed, the generated extension class now includes the mixins in its extends clause: `export class FooExtension extends Mixin1, Mixin2`. - Add heritageLocalNames to ParsedFile to track original mixin identifiers - Thread heritageLocalNames through ModelAnalysisResult to extension generation - Add extendsClause parameter to generateExtensionCode for class format - Update snapshots to reflect new extends clause in extension classes
…e default setting
* main: (157 commits) chore(docs): fix link to /guides/migrating/index.md (warp-drive-data#10502) Release v5.9.0-alpha.10 chore(codemods): add codemods guide documentation (warp-drive-data#10501) fix(deploy): @ember-data/codemods fails on different platforms (warp-drive-data#10500) Release v5.9.0-alpha.9 feat(codemods): various codemod output fixes (warp-drive-data#10496) chore(deploy): fix scheduled canary deployments (warp-drive-data#10499) fix(codemods): resolve eslint errors in schema-migration (warp-drive-data#10497) Fix incorrect `console.log` warning when `belongsTo` has `linkMode: true` (warp-drive-data#10492) codemods: model-to-schema typescript support (warp-drive-data#10474) feat(codemods): log what and why files were skipped (warp-drive-data#10486) refactor(codemods): use the existing file parsing utility (warp-drive-data#10485) refactor(codemods): remove extraenous logger implementation (warp-drive-data#10484) chore(codemods): add ast-grep related skills (warp-drive-data#10483) refactor(codemods): deduplicate interface generation (warp-drive-data#10481) refactor(codemods): small cleanups (warp-drive-data#10480) feat(codemods): Publishing `@ember-data/codemods` (warp-drive-data#10479) Update the JSONAPI adapter and serializer import paths (warp-drive-data#10476) chore(internal-tooling): fix volta.extends path (warp-drive-data#10475) [docs] Ensure consistent legacy package warnings (warp-drive-data#10471) ...
Pulls changes from #10487
TraitorExtensionResourceBrandsBrands using Typescript interface merging.disableTypescriptSchemasandcombineSchemasAndTypessettingsThis does rely on the fact that some imports are effectively circular, but Typescript appears to be fine with that.