Skip to content

test(schema-codemod): add codemod tests#1

Draft
BobrImperator wants to merge 65 commits intomainfrom
schema-codemod-main
Draft

test(schema-codemod): add codemod tests#1
BobrImperator wants to merge 65 commits intomainfrom
schema-codemod-main

Conversation

@BobrImperator
Copy link
Copy Markdown
Collaborator

@BobrImperator BobrImperator commented Jan 21, 2026

Continuation of warp-drive-data#10386, warp-drive-data#10434

Relevant
warp-drive-data#10455
https://mainmatter.notion.site/Consolidated-Warp-drive-structure-proposal-2f664e58ddfa806d920eef0bbcc94696?pvs=73

Related branches
#2

  • Extracts the test suite from the original PR
  • Refactors the testing setup to be less repetitive
  • Changes tests to grab a snapshot of all the files in the temp directory instead of only checking for their presence
  • Removes leftover testing from packages/codemods which are a part of the tests/codemods
  • Removes unnecessary fixture and uses a snapshot instead

Status

  • Use the standardized naming convention
    https://warp-drive.io/api/@warp-drive/core/types/schema/fields/interfaces/ObjectSchema#type

    • for globally shared objects: The pattern $field:${KlassName} e.g. $field:AddressObject

    • for resource-specific objects: The pattern $${ResourceKlassName}:$field:${KlassName} e.g. $User:$field:ReusableAddress

    • for inline objects: The pattern $${ResourceKlassName}.${fieldPath}:$field:anonymous e.g. $User.shippingAddress:$field:anonymous
      
  • is able to successfully transform simple models. It runs in ESA and generates schemas.

  • BaseModel class resolution

import BaseModel from 'my-app/models/base-model';
import Schedulable from 'my-app/mixins/schedulable';
export default class Job extends BaseModel.extend(Schedulable) {}
  • outputs code with incorrect imports
    @ember-data/core-types -> @warp-drive/core/types
  • doesn’t install warp-drive packages automatically
  • doesn’t appear to work in a large project - might be bailing out early without producing anything when encounters an error
  • Doesn't run when a model is extended by an imported class that's not the @ember-data/model source e.g.
import BaseModel, { attr, belongsTo, hasMany } from '@ember-data/warp-drive/v1/model'; 
  
export default class ActionPlan extends BaseModel {
 @attr('boolean') isFlattened;
}
  • Import extraction must respect the emberDataImportSource
  • Simple mixins should become traits instead of extensions
// mixins/amendable.js
export default Mixin.create({
  amendments: hasMany('amendment', { inverse: 'amendable' })
});

Becomes:

// traits/amendable.js
   export const amendableTrait = {
     "name": "amendable",
     "mode": "legacy",
     "fields": []
   };
 
// extensions/amendable.js
   export const amendableExtension = {
     amendments: hasMany('amendment', {
       async: false,
       inverse: 'amendable',
         as: 'amendable',
    })
   };
  • Typescript Extension needs to specify a "Base" class cast to the interface of a schema for a proper typescript type resolution
   import { ControlCategory } from './control-category.schema';
  
   export interface ControlCategoryExtension extends ControlCategory {}
  
   const Base = class {} as { new(): ControlCategory };
   export class ControlCategoryExtension extends Base {}

The above should simply be a trait field definition and an extension can be removed.

  • Migrating models that are re-exports of other models.
   import DataFieldModel from '../core/data-field-model.ts';
  
   export default class ControlCustomMultiSelect2 extends DataFieldModel {}
  • .d.ts handling (priority: 🔽 )
  • Add ability to modify the warp-drive store definition.
    • Add registering traits
    • Add registering extensions

@BobrImperator BobrImperator force-pushed the schema-codemod-main branch 2 times, most recently from 1a91b89 to eef0fc7 Compare January 21, 2026 11:04
@BobrImperator BobrImperator marked this pull request as draft January 22, 2026 11:31
BobrImperator and others added 18 commits February 6, 2026 03:16
feat: implement proposed file structure, export schemas as default from the file.
…sible. Reduce the amount of raw string operations
refactor(codemods): move legacy-compat-builders codemod to its own module
@BobrImperator BobrImperator force-pushed the schema-codemod-main branch 2 times, most recently from 79d1343 to 81f7748 Compare February 12, 2026 04:57
There's a discrepancy between local and CI lint output at this moment
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.

1 participant