@payloadcms/codemod 4.0.0-internal.44ac9c8 → 4.0.0-internal.4a6b4c3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/README.md +6 -2
  2. package/dist/cli.d.ts.map +1 -1
  3. package/dist/cli.help.d.ts +4 -0
  4. package/dist/cli.help.d.ts.map +1 -0
  5. package/dist/cli.help.js +29 -0
  6. package/dist/cli.help.js.map +1 -0
  7. package/dist/cli.js +8 -0
  8. package/dist/cli.js.map +1 -1
  9. package/dist/cli.parseFlags.d.ts +1 -0
  10. package/dist/cli.parseFlags.d.ts.map +1 -1
  11. package/dist/cli.parseFlags.js +6 -0
  12. package/dist/cli.parseFlags.js.map +1 -1
  13. package/dist/registry.d.ts.map +1 -1
  14. package/dist/registry.js +6 -0
  15. package/dist/registry.js.map +1 -1
  16. package/dist/runbook/payload-v4-upgrade.md +2 -2
  17. package/dist/runbook/v4.mdx +370 -80
  18. package/dist/transforms/migrate-admin-context-properties/basic.input.js +32 -0
  19. package/dist/transforms/migrate-admin-context-properties/basic.input.js.map +1 -0
  20. package/dist/transforms/migrate-admin-context-properties/basic.output.js +30 -0
  21. package/dist/transforms/migrate-admin-context-properties/basic.output.js.map +1 -0
  22. package/dist/transforms/migrate-admin-context-properties/index.d.ts +3 -0
  23. package/dist/transforms/migrate-admin-context-properties/index.d.ts.map +1 -0
  24. package/dist/transforms/migrate-admin-context-properties/index.js +302 -0
  25. package/dist/transforms/migrate-admin-context-properties/index.js.map +1 -0
  26. package/dist/transforms/migrate-admin-context-properties/no-match.input.js +30 -0
  27. package/dist/transforms/migrate-admin-context-properties/no-match.input.js.map +1 -0
  28. package/dist/transforms/migrate-admin-context-properties/no-match.output.js +30 -0
  29. package/dist/transforms/migrate-admin-context-properties/no-match.output.js.map +1 -0
  30. package/dist/transforms/migrate-displayed-field-value-args/basic.input.js +4 -0
  31. package/dist/transforms/migrate-displayed-field-value-args/basic.input.js.map +1 -0
  32. package/dist/transforms/migrate-displayed-field-value-args/basic.output.js +8 -0
  33. package/dist/transforms/migrate-displayed-field-value-args/basic.output.js.map +1 -0
  34. package/dist/transforms/migrate-displayed-field-value-args/index.d.ts +3 -0
  35. package/dist/transforms/migrate-displayed-field-value-args/index.d.ts.map +1 -0
  36. package/dist/transforms/migrate-displayed-field-value-args/index.js +84 -0
  37. package/dist/transforms/migrate-displayed-field-value-args/index.js.map +1 -0
  38. package/dist/transforms/migrate-displayed-field-value-args/namespace.input.js +4 -0
  39. package/dist/transforms/migrate-displayed-field-value-args/namespace.input.js.map +1 -0
  40. package/dist/transforms/migrate-displayed-field-value-args/namespace.output.js +8 -0
  41. package/dist/transforms/migrate-displayed-field-value-args/namespace.output.js.map +1 -0
  42. package/dist/transforms/migrate-displayed-field-value-args/no-match.input.js +4 -0
  43. package/dist/transforms/migrate-displayed-field-value-args/no-match.input.js.map +1 -0
  44. package/dist/transforms/migrate-displayed-field-value-args/no-match.output.js +4 -0
  45. package/dist/transforms/migrate-displayed-field-value-args/no-match.output.js.map +1 -0
  46. package/dist/transforms/migrate-field-component-types/index.d.ts.map +1 -1
  47. package/dist/transforms/migrate-field-component-types/index.js +4 -0
  48. package/dist/transforms/migrate-field-component-types/index.js.map +1 -1
  49. package/dist/transforms/migrate-sharp-to-transformer/basic.output.js +1 -1
  50. package/dist/transforms/migrate-sharp-to-transformer/basic.output.js.map +1 -1
  51. package/dist/transforms/migrate-sharp-to-transformer/existing-transformers.output.js +1 -1
  52. package/dist/transforms/migrate-sharp-to-transformer/existing-transformers.output.js.map +1 -1
  53. package/dist/transforms/migrate-sharp-to-transformer/index.d.ts.map +1 -1
  54. package/dist/transforms/migrate-sharp-to-transformer/index.js +232 -82
  55. package/dist/transforms/migrate-sharp-to-transformer/index.js.map +1 -1
  56. package/dist/transforms/remove-storage-always-insert-fields/index.d.ts.map +1 -1
  57. package/dist/transforms/remove-storage-always-insert-fields/index.js +4 -0
  58. package/dist/transforms/remove-storage-always-insert-fields/index.js.map +1 -1
  59. package/dist/transforms/rename-diff-value-props/basic.input.js +38 -0
  60. package/dist/transforms/rename-diff-value-props/basic.input.js.map +1 -0
  61. package/dist/transforms/rename-diff-value-props/basic.output.js +38 -0
  62. package/dist/transforms/rename-diff-value-props/basic.output.js.map +1 -0
  63. package/dist/transforms/rename-diff-value-props/index.d.ts +3 -0
  64. package/dist/transforms/rename-diff-value-props/index.d.ts.map +1 -0
  65. package/dist/transforms/rename-diff-value-props/index.js +328 -0
  66. package/dist/transforms/rename-diff-value-props/index.js.map +1 -0
  67. package/dist/transforms/rename-diff-value-props/no-match.input.js +8 -0
  68. package/dist/transforms/rename-diff-value-props/no-match.input.js.map +1 -0
  69. package/dist/transforms/rename-experimental-table-feature/index.d.ts.map +1 -1
  70. package/dist/transforms/rename-experimental-table-feature/index.js +7 -1
  71. package/dist/transforms/rename-experimental-table-feature/index.js.map +1 -1
  72. package/dist/upgrade/defaultTag.d.ts +1 -1
  73. package/dist/upgrade/defaultTag.js +2 -2
  74. package/dist/upgrade/defaultTag.js.map +1 -1
  75. package/dist/upgrade/prompt.js +2 -2
  76. package/dist/upgrade/prompt.js.map +1 -1
  77. package/dist/upgrade/rewritePackageJson.d.ts.map +1 -1
  78. package/dist/upgrade/rewritePackageJson.js +52 -11
  79. package/dist/upgrade/rewritePackageJson.js.map +1 -1
  80. package/dist/utils/project.d.ts +7 -1
  81. package/dist/utils/project.d.ts.map +1 -1
  82. package/dist/utils/project.js +20 -7
  83. package/dist/utils/project.js.map +1 -1
  84. package/package.json +2 -2
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/transforms/migrate-displayed-field-value-args/index.ts"],"sourcesContent":["import type { CallExpression, Identifier } from 'ts-morph'\n\nimport { Node } from 'ts-morph'\n\nimport type { Transform } from '../../types.js'\n\nconst moduleName = '@payloadcms/ui/utilities/getDisplayedFieldValue'\nconst functionName = 'getDisplayedFieldValue'\n\nexport const migrateDisplayedFieldValueArgs: Transform = {\n name: 'migrate-displayed-field-value-args',\n apply: ({ project }) => {\n const filesChanged: string[] = []\n const notes: string[] = []\n\n for (const file of project.getSourceFiles()) {\n const calls = new Set<CallExpression>()\n\n for (const declaration of file.getImportDeclarations()) {\n if (declaration.getModuleSpecifierValue() !== moduleName) {\n continue\n }\n\n for (const specifier of declaration.getNamedImports()) {\n if (specifier.getName() !== functionName || specifier.isTypeOnly()) {\n continue\n }\n\n const localName = specifier.getAliasNode() ?? specifier.getNameNode()\n\n if (Node.isIdentifier(localName)) {\n collectCalls({ calls, localName, notes })\n }\n }\n\n const namespace = declaration.getNamespaceImport()\n\n if (namespace) {\n collectCalls({ calls, isNamespace: true, localName: namespace, notes })\n }\n }\n\n const original = file.getFullText()\n\n for (const call of [...calls].sort((a, b) => b.getStart() - a.getStart())) {\n const args = call.getArguments()\n\n if (args.length === 1 && Node.isObjectLiteralExpression(args[0])) {\n continue\n }\n\n if (args.length !== 3 || args.some(Node.isSpreadElement)) {\n notes.push(\n `${file.getFilePath()}:${call.getStartLineNumber()}: ${call.getText()} has unsupported arguments; migrate manually.`,\n )\n continue\n }\n\n call.replaceWithText(\n `${call.getExpression().getText()}({ cellData: ${args[0]!.getText()}, field: ${args[1]!.getText()}, i18n: ${args[2]!.getText()} })`,\n )\n }\n\n if (file.getFullText() !== original) {\n filesChanged.push(file.getFilePath())\n }\n }\n\n return { filesChanged, ...(notes.length > 0 ? { notes } : {}) }\n },\n description:\n 'Migrates `getDisplayedFieldValue(cellData, field, i18n)` calls imported from `@payloadcms/ui/utilities/getDisplayedFieldValue` to object arguments.',\n}\n\nfunction collectCalls({\n calls,\n isNamespace = false,\n localName,\n notes,\n}: {\n calls: Set<CallExpression>\n isNamespace?: boolean\n localName: Identifier\n notes: string[]\n}): void {\n for (const reference of localName.findReferencesAsNodes()) {\n if (reference === localName) {\n continue\n }\n\n const parent = reference.getParent()\n const expression = isNamespace\n ? Node.isPropertyAccessExpression(parent) &&\n parent.getExpression() === reference &&\n parent.getName() === functionName\n ? parent\n : undefined\n : reference\n\n if (!expression) {\n continue\n }\n\n const call = expression.getParent()\n\n if (Node.isCallExpression(call) && call.getExpression() === expression) {\n calls.add(call)\n } else {\n notes.push(\n `${reference.getSourceFile().getFilePath()}:${reference.getStartLineNumber()}: ${expression.getText()} is referenced without a direct call; migrate manually.`,\n )\n }\n }\n}\n"],"names":["Node","moduleName","functionName","migrateDisplayedFieldValueArgs","name","apply","project","filesChanged","notes","file","getSourceFiles","calls","Set","declaration","getImportDeclarations","getModuleSpecifierValue","specifier","getNamedImports","getName","isTypeOnly","localName","getAliasNode","getNameNode","isIdentifier","collectCalls","namespace","getNamespaceImport","isNamespace","original","getFullText","call","sort","a","b","getStart","args","getArguments","length","isObjectLiteralExpression","some","isSpreadElement","push","getFilePath","getStartLineNumber","getText","replaceWithText","getExpression","description","reference","findReferencesAsNodes","parent","getParent","expression","isPropertyAccessExpression","undefined","isCallExpression","add","getSourceFile"],"mappings":"AAEA,SAASA,IAAI,QAAQ,WAAU;AAI/B,MAAMC,aAAa;AACnB,MAAMC,eAAe;AAErB,OAAO,MAAMC,iCAA4C;IACvDC,MAAM;IACNC,OAAO,CAAC,EAAEC,OAAO,EAAE;QACjB,MAAMC,eAAyB,EAAE;QACjC,MAAMC,QAAkB,EAAE;QAE1B,KAAK,MAAMC,QAAQH,QAAQI,cAAc,GAAI;YAC3C,MAAMC,QAAQ,IAAIC;YAElB,KAAK,MAAMC,eAAeJ,KAAKK,qBAAqB,GAAI;gBACtD,IAAID,YAAYE,uBAAuB,OAAOd,YAAY;oBACxD;gBACF;gBAEA,KAAK,MAAMe,aAAaH,YAAYI,eAAe,GAAI;oBACrD,IAAID,UAAUE,OAAO,OAAOhB,gBAAgBc,UAAUG,UAAU,IAAI;wBAClE;oBACF;oBAEA,MAAMC,YAAYJ,UAAUK,YAAY,MAAML,UAAUM,WAAW;oBAEnE,IAAItB,KAAKuB,YAAY,CAACH,YAAY;wBAChCI,aAAa;4BAAEb;4BAAOS;4BAAWZ;w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,EAMN;IACC,KAAK,MAAMwC,aAAa5B,UAAU6B,qBAAqB,GAAI;QACzD,IAAID,cAAc5B,WAAW;YAC3B;QACF;QAEA,MAAM8B,SAASF,UAAUG,SAAS;QAClC,MAAMC,aAAazB,cACf3B,KAAKqD,0BAA0B,CAACH,WAChCA,OAAOJ,aAAa,OAAOE,aAC3BE,OAAOhC,OAAO,OAAOhB,eACnBgD,SACAI,YACFN;QAEJ,IAAI,CAACI,YAAY;YACf;QACF;QAEA,MAAMtB,OAAOsB,WAAWD,SAAS;QAEjC,IAAInD,KAAKuD,gBAAgB,CAACzB,SAASA,KAAKgB,aAAa,OAAOM,YAAY;YACtEzC,MAAM6C,GAAG,CAAC1B;QACZ,OAAO;YACLtB,MAAMiC,IAAI,CACR,GAAGO,UAAUS,aAAa,GAAGf,WAAW,GAAG,CAAC,EAAEM,UAAUL,kBAAkB,GAAG,EAAE,EAAES,WAAWR,OAAO,GAAG,uDAAuD,CAAC;QAElK;IACF;AACF"}
@@ -0,0 +1,4 @@
1
+ import * as display from '@payloadcms/ui/utilities/getDisplayedFieldValue';
2
+ const result = display.getDisplayedFieldValue(fileSize, field, i18n);
3
+
4
+ //# sourceMappingURL=namespace.input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/transforms/migrate-displayed-field-value-args/namespace.input.ts"],"sourcesContent":["import * as display from '@payloadcms/ui/utilities/getDisplayedFieldValue'\n\nconst result = display.getDisplayedFieldValue(fileSize, field, i18n)\n"],"names":["display","result","getDisplayedFieldValue","fileSize","field","i18n"],"mappings":"AAAA,YAAYA,aAAa,kDAAiD;AAE1E,MAAMC,SAASD,QAAQE,sBAAsB,CAACC,UAAUC,OAAOC"}
@@ -0,0 +1,8 @@
1
+ import * as display from '@payloadcms/ui/utilities/getDisplayedFieldValue';
2
+ const result = display.getDisplayedFieldValue({
3
+ cellData: fileSize,
4
+ field: field,
5
+ i18n: i18n
6
+ });
7
+
8
+ //# sourceMappingURL=namespace.output.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/transforms/migrate-displayed-field-value-args/namespace.output.ts"],"sourcesContent":["import * as display from '@payloadcms/ui/utilities/getDisplayedFieldValue'\n\nconst result = display.getDisplayedFieldValue({ cellData: fileSize, field: field, i18n: i18n })\n"],"names":["display","result","getDisplayedFieldValue","cellData","fileSize","field","i18n"],"mappings":"AAAA,YAAYA,aAAa,kDAAiD;AAE1E,MAAMC,SAASD,QAAQE,sBAAsB,CAAC;IAAEC,UAAUC;IAAUC,OAAOA;IAAOC,MAAMA;AAAK"}
@@ -0,0 +1,4 @@
1
+ import { getDisplayedFieldValue } from './local-display.js';
2
+ const result = getDisplayedFieldValue(fileSize, field, i18n);
3
+
4
+ //# sourceMappingURL=no-match.input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/transforms/migrate-displayed-field-value-args/no-match.input.ts"],"sourcesContent":["import { getDisplayedFieldValue } from './local-display.js'\n\nconst result = getDisplayedFieldValue(fileSize, field, i18n)\n"],"names":["getDisplayedFieldValue","result","fileSize","field","i18n"],"mappings":"AAAA,SAASA,sBAAsB,QAAQ,qBAAoB;AAE3D,MAAMC,SAASD,uBAAuBE,UAAUC,OAAOC"}
@@ -0,0 +1,4 @@
1
+ import { getDisplayedFieldValue } from './local-display.js';
2
+ const result = getDisplayedFieldValue(fileSize, field, i18n);
3
+
4
+ //# sourceMappingURL=no-match.output.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/transforms/migrate-displayed-field-value-args/no-match.output.ts"],"sourcesContent":["import { getDisplayedFieldValue } from './local-display.js'\n\nconst result = getDisplayedFieldValue(fileSize, field, i18n)\n"],"names":["getDisplayedFieldValue","result","fileSize","field","i18n"],"mappings":"AAAA,SAASA,sBAAsB,QAAQ,qBAAoB;AAE3D,MAAMC,SAASD,uBAAuBE,UAAUC,OAAOC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transforms/migrate-field-component-types/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAiG/C,eAAO,MAAM,0BAA0B,EAAE,SAkKxC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transforms/migrate-field-component-types/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAiG/C,eAAO,MAAM,0BAA0B,EAAE,SAwKxC,CAAA"}
@@ -197,6 +197,10 @@ export const migrateFieldComponentTypes = {
197
197
  continue;
198
198
  }
199
199
  const binding = specifier.getAliasNode() ?? specifier.getNameNode();
200
+ // Always an Identifier in valid code: a string-literal import name requires an alias.
201
+ if (!Node.isIdentifier(binding)) {
202
+ continue;
203
+ }
200
204
  const references = binding.findReferencesAsNodes().filter((node)=>node !== binding && node.getSourceFile() === file);
201
205
  const unsupportedReference = references.find((reference)=>{
202
206
  const parent = reference.getParent();
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/transforms/migrate-field-component-types/index.ts"],"sourcesContent":["import type { Expression, ImportDeclaration, SourceFile } from 'ts-morph'\n\nimport { Node, SyntaxKind, VariableDeclarationKind } from 'ts-morph'\n\nimport type { Transform } from '../../types.js'\n\nconst FIELD_NAMES = [\n 'Array',\n 'Blocks',\n 'Checkbox',\n 'Code',\n 'Collapsible',\n 'Date',\n 'Email',\n 'Group',\n 'Join',\n 'JSON',\n 'Number',\n 'Point',\n 'Radio',\n 'Relationship',\n 'RichText',\n 'Row',\n 'Select',\n 'Tabs',\n 'Text',\n 'Textarea',\n 'UI',\n 'Upload',\n] as const\n\nconst FIELDS_WITH_SPECIALIZED_COMPONENTS = [\n 'Array',\n 'Blocks',\n 'Checkbox',\n 'Code',\n 'Collapsible',\n 'Date',\n 'Email',\n 'Group',\n 'Join',\n 'JSON',\n 'Number',\n 'Point',\n 'Radio',\n 'Relationship',\n 'RichText',\n 'Row',\n 'Select',\n 'Tabs',\n 'Text',\n 'Textarea',\n 'Upload',\n] as const\n\nconst SPECIALIZED_COMPONENT_NAMES = [\n 'FieldDescriptionClient',\n 'FieldDescriptionServer',\n 'FieldDiffClient',\n 'FieldDiffServer',\n 'FieldErrorClient',\n 'FieldErrorServer',\n 'FieldLabelClient',\n 'FieldLabelServer',\n] as const\n\nconst COMPONENT_TO_PROPS = new Map<string, string>([\n ['BlockRowLabelClientComponent', 'BlockRowLabelClientProps'],\n ['BlockRowLabelServerComponent', 'BlockRowLabelServerProps'],\n ['FieldClientComponent', 'FieldClientProps'],\n ['FieldDescriptionClientComponent', 'FieldDescriptionClientProps'],\n ['FieldDescriptionServerComponent', 'FieldDescriptionServerProps'],\n ['FieldDiffClientComponent', 'FieldDiffClientProps'],\n ['FieldDiffServerComponent', 'FieldDiffServerProps'],\n ['FieldErrorClientComponent', 'FieldErrorClientProps'],\n ['FieldErrorServerComponent', 'FieldErrorServerProps'],\n ['FieldLabelClientComponent', 'FieldLabelClientProps'],\n ['FieldLabelServerComponent', 'FieldLabelServerProps'],\n ['FieldServerComponent', 'FieldServerProps'],\n ...FIELD_NAMES.flatMap((fieldName) => [\n [`${fieldName}FieldClientComponent`, `${fieldName}FieldClientProps`] as const,\n [`${fieldName}FieldServerComponent`, `${fieldName}FieldServerProps`] as const,\n ]),\n ...FIELDS_WITH_SPECIALIZED_COMPONENTS.flatMap((fieldName) =>\n SPECIALIZED_COMPONENT_NAMES.map(\n (componentName) =>\n [`${fieldName}${componentName}Component`, `${fieldName}${componentName}Props`] as const,\n ),\n ),\n ['UIFieldDiffClientComponent', 'UIFieldDiffClientProps'],\n ['UIFieldDiffServerComponent', 'UIFieldDiffServerProps'],\n])\n\nconst COMPONENT_GENERIC_DEFAULTS = new Map<string, readonly string[]>([\n ['FieldDiffClientComponent', ['ClientFieldWithOptionalType']],\n ['FieldDiffServerComponent', ['Field', 'ClientFieldWithOptionalType']],\n ['FieldErrorServerComponent', ['Field', 'ClientFieldWithOptionalType']],\n ['FieldLabelClientComponent', ['ClientFieldWithOptionalType']],\n ['FieldLabelServerComponent', ['Field', 'ClientFieldWithOptionalType']],\n])\n\nexport const migrateFieldComponentTypes: Transform = {\n name: 'migrate-field-component-types',\n apply: ({ project }) => {\n const filesChanged = new Set<string>()\n const notes: string[] = []\n\n for (const file of project.getSourceFiles()) {\n collectUnsupportedImportNotes({ file, notes })\n\n let mutated = false\n let reactBinding: ResolvedReactBinding | undefined\n\n for (const importDeclaration of [...file.getImportDeclarations()]) {\n if (importDeclaration.getModuleSpecifierValue() !== 'payload') {\n continue\n }\n\n const componentImports = importDeclaration\n .getNamedImports()\n .filter((specifier) => COMPONENT_TO_PROPS.has(specifier.getName()))\n .map((specifier) => ({\n componentName: specifier.getName(),\n localName: specifier.getAliasNode()?.getText() ?? specifier.getName(),\n }))\n let importMutated = false\n\n for (const componentImport of componentImports) {\n const { componentName, localName } = componentImport\n const propsName = COMPONENT_TO_PROPS.get(componentName)\n\n if (!propsName) {\n continue\n }\n\n const specifier = importDeclaration\n .getNamedImports()\n .find(\n (namedImport) =>\n namedImport.getName() === componentName &&\n (namedImport.getAliasNode()?.getText() ?? namedImport.getName()) === localName,\n )\n\n if (!specifier) {\n continue\n }\n\n const binding = specifier.getAliasNode() ?? specifier.getNameNode()\n const references = binding\n .findReferencesAsNodes()\n .filter((node) => node !== binding && node.getSourceFile() === file)\n const unsupportedReference = references.find((reference) => {\n const parent = reference.getParent()\n\n return !Node.isTypeReference(parent) || parent.getTypeName() !== reference\n })\n\n if (unsupportedReference) {\n notes.push(\n `${file.getFilePath()}:${unsupportedReference.getStartLineNumber()}: Unsupported use of \\`${componentName}\\`. Replace it with the corresponding props type manually.`,\n )\n continue\n }\n\n const classDeclaration = references\n .map((reference) => reference.getFirstAncestorByKind(SyntaxKind.VariableDeclaration))\n .find((declaration, referenceIndex) => {\n const initializer = declaration?.getInitializer()\n const reference = references[referenceIndex]\n const componentPropertyPath = reference\n ? getComponentPropertyPath({ reference })\n : undefined\n\n return initializer\n ? initializerContainsClassComponent({ componentPropertyPath, initializer })\n : false\n })\n\n if (classDeclaration) {\n notes.push(\n `${file.getFilePath()}:${classDeclaration.getStartLineNumber()}: Cannot automatically migrate \\`${componentName}\\` because it types a class component. Replace it with a compatible props annotation manually.`,\n )\n continue\n }\n\n if (references.length === 0) {\n specifier.remove()\n importMutated = true\n mutated = true\n continue\n }\n\n const propsImport = resolvePropsImport({\n file,\n propsName,\n })\n\n reactBinding ??= resolveReactTypeBinding(file)\n\n for (const reference of references.reverse()) {\n const typeReference = reference.getParentIfKindOrThrow(SyntaxKind.TypeReference)\n const typeArguments = typeReference\n .getTypeArguments()\n .map((typeArgument) => typeArgument.getText())\n const propsTypeArguments = materializeGenericDefaults({\n componentName,\n file,\n importDeclaration,\n typeArguments,\n })\n const propsType =\n propsTypeArguments.length > 0\n ? `${propsImport.localName}<${propsTypeArguments.join(', ')}>`\n : propsImport.localName\n\n typeReference.replaceWithText(`${reactBinding.localName}.FC<${propsType}>`)\n }\n\n const currentSpecifier = importDeclaration\n .getNamedImports()\n .find(\n (namedImport) =>\n namedImport.getName() === componentName &&\n (namedImport.getAliasNode()?.getText() ?? namedImport.getName()) === localName,\n )\n\n if (propsImport.exists) {\n currentSpecifier?.remove()\n } else if (currentSpecifier) {\n currentSpecifier.setName(propsName)\n\n if (propsImport.localName === propsName) {\n currentSpecifier.removeAlias()\n } else {\n currentSpecifier.setAlias(propsImport.localName)\n }\n }\n\n importMutated = true\n mutated = true\n }\n\n if (importMutated) {\n removeEmptyImport(importDeclaration)\n }\n }\n\n if (reactBinding?.shouldAddImport) {\n addReactTypeImport({ file, reactName: reactBinding.localName })\n }\n\n if (mutated) {\n filesChanged.add(file.getFilePath())\n }\n }\n\n return {\n filesChanged: [...filesChanged],\n ...(notes.length > 0 ? { notes } : {}),\n }\n },\n description:\n 'Replace field component aliases imported from `payload` with the corresponding props types wrapped in `React.FC`. Generic arguments are preserved. Explicit class components and unsupported import forms are left unchanged with notes for manual migration.',\n}\n\ntype ResolvePropsImportArgs = {\n file: SourceFile\n propsName: string\n}\n\ntype MaterializeGenericDefaultsArgs = {\n componentName: string\n file: SourceFile\n importDeclaration: ImportDeclaration\n typeArguments: string[]\n}\n\nfunction materializeGenericDefaults({\n componentName,\n file,\n importDeclaration,\n typeArguments,\n}: MaterializeGenericDefaultsArgs): string[] {\n const genericDefaults = COMPONENT_GENERIC_DEFAULTS.get(componentName)\n\n if (!genericDefaults || typeArguments.length >= genericDefaults.length) {\n return typeArguments\n }\n\n return [\n ...typeArguments,\n ...genericDefaults.slice(typeArguments.length).map((typeName) =>\n resolvePayloadTypeImport({\n file,\n importDeclaration,\n typeName,\n }),\n ),\n ]\n}\n\ntype ResolvePayloadTypeImportArgs = {\n file: SourceFile\n importDeclaration: ImportDeclaration\n typeName: string\n}\n\nfunction resolvePayloadTypeImport({\n file,\n importDeclaration,\n typeName,\n}: ResolvePayloadTypeImportArgs): string {\n for (const declaration of file.getImportDeclarations()) {\n if (declaration.getModuleSpecifierValue() !== 'payload') {\n continue\n }\n\n const existing = declaration\n .getNamedImports()\n .find((namedImport) => namedImport.getName() === typeName)\n\n if (existing) {\n const localName = existing.getAliasNode()?.getText() ?? typeName\n\n if (\n !hasCompetingDeclaration({\n file,\n importDeclaration: declaration,\n localName,\n })\n ) {\n return localName\n }\n }\n }\n\n const localName = getAvailableName({ file, preferredName: typeName, suffix: 'Type' })\n\n importDeclaration.addNamedImport({\n name: typeName,\n alias: localName === typeName ? undefined : localName,\n isTypeOnly: !importDeclaration.isTypeOnly(),\n })\n\n return localName\n}\n\ntype ResolvedPropsImport = {\n exists: boolean\n localName: string\n}\n\nfunction resolvePropsImport({ file, propsName }: ResolvePropsImportArgs): ResolvedPropsImport {\n for (const declaration of file.getImportDeclarations()) {\n if (declaration.getModuleSpecifierValue() !== 'payload') {\n continue\n }\n\n const existing = declaration\n .getNamedImports()\n .find((namedImport) => namedImport.getName() === propsName)\n\n if (existing) {\n const localName = existing.getAliasNode()?.getText() ?? propsName\n\n if (\n !hasCompetingDeclaration({\n file,\n importDeclaration: declaration,\n localName,\n })\n ) {\n return {\n exists: true,\n localName,\n }\n }\n }\n }\n\n const localName = getAvailableName({ file, preferredName: propsName, suffix: 'Type' })\n\n return { exists: false, localName }\n}\n\ntype ResolvedReactBinding = {\n localName: string\n shouldAddImport: boolean\n}\n\nfunction resolveReactTypeBinding(file: SourceFile): ResolvedReactBinding {\n const reactImports = file\n .getImportDeclarations()\n .filter((declaration) => declaration.getModuleSpecifierValue() === 'react')\n\n for (const declaration of reactImports) {\n const namespaceImport = declaration.getNamespaceImport()\n if (\n namespaceImport &&\n !hasCompetingDeclaration({\n file,\n importDeclaration: declaration,\n localName: namespaceImport.getText(),\n })\n ) {\n return { localName: namespaceImport.getText(), shouldAddImport: false }\n }\n\n const defaultImport = declaration.getDefaultImport()\n if (\n defaultImport &&\n !hasCompetingDeclaration({\n file,\n importDeclaration: declaration,\n localName: defaultImport.getText(),\n })\n ) {\n return { localName: defaultImport.getText(), shouldAddImport: false }\n }\n }\n\n return {\n localName: getAvailableName({ file, preferredName: 'React', suffix: 'Type' }),\n shouldAddImport: true,\n }\n}\n\ntype HasCompetingDeclarationArgs = {\n file: SourceFile\n importDeclaration: ImportDeclaration\n localName: string\n}\n\nfunction hasCompetingDeclaration({\n file,\n importDeclaration,\n localName,\n}: HasCompetingDeclarationArgs): boolean {\n return file.getDescendantsOfKind(SyntaxKind.Identifier).some((identifier) => {\n if (\n identifier.getText() !== localName ||\n identifier.getFirstAncestorByKind(SyntaxKind.ImportDeclaration) === importDeclaration\n ) {\n return false\n }\n\n const parent = identifier.getParent()\n\n return (\n (Node.isTypeParameterDeclaration(parent) ||\n Node.isParameterDeclaration(parent) ||\n Node.isVariableDeclaration(parent) ||\n Node.isFunctionDeclaration(parent) ||\n Node.isClassDeclaration(parent) ||\n Node.isTypeAliasDeclaration(parent) ||\n Node.isInterfaceDeclaration(parent)) &&\n parent.getNameNode() === identifier\n )\n })\n}\n\ntype AddReactTypeImportArgs = {\n file: SourceFile\n reactName: string\n}\n\nfunction addReactTypeImport({ file, reactName }: AddReactTypeImportArgs): void {\n const importDeclarations = file.getImportDeclarations()\n const lastImport = importDeclarations.at(-1)\n const statements = file.getStatements()\n const insertionIndex = lastImport ? statements.indexOf(lastImport) + 1 : 0\n const nextStatement = statements.at(insertionIndex)\n const needsTerminator =\n lastImport && nextStatement\n ? lastImport.getEndLineNumber() === nextStatement.getStartLineNumber()\n : false\n\n file.insertStatements(\n insertionIndex,\n `import type ${reactName} from 'react'${needsTerminator ? ';' : ''}`,\n )\n}\n\ntype InitializerContainsClassComponentArgs = {\n componentPropertyPath?: string[]\n initializer: Expression\n visitedExpressions?: Set<Expression>\n}\n\nfunction initializerContainsClassComponent({\n componentPropertyPath,\n initializer,\n visitedExpressions = new Set<Expression>(),\n}: InitializerContainsClassComponentArgs): boolean {\n let expression = initializer\n\n while (\n Node.isParenthesizedExpression(expression) ||\n Node.isAsExpression(expression) ||\n Node.isSatisfiesExpression(expression) ||\n Node.isTypeAssertion(expression) ||\n Node.isNonNullExpression(expression)\n ) {\n expression = expression.getExpression()\n }\n\n if (visitedExpressions.has(expression)) {\n return false\n }\n\n visitedExpressions.add(expression)\n\n if (Node.isClassExpression(expression)) {\n return true\n }\n\n if (Node.isArrayLiteralExpression(expression)) {\n return expression.getElements().some((element) => {\n const nestedExpression = Node.isSpreadElement(element) ? element.getExpression() : element\n\n return Node.isExpression(nestedExpression)\n ? initializerContainsClassComponent({\n componentPropertyPath,\n initializer: nestedExpression,\n visitedExpressions,\n })\n : false\n })\n }\n\n if (Node.isConditionalExpression(expression)) {\n return [expression.getWhenTrue(), expression.getWhenFalse()].some((nestedExpression) =>\n initializerContainsClassComponent({\n componentPropertyPath,\n initializer: nestedExpression,\n visitedExpressions,\n }),\n )\n }\n\n if (Node.isObjectLiteralExpression(expression)) {\n const properties = expression.getProperties()\n const componentPropertyName = componentPropertyPath?.[0]\n const remainingComponentPropertyPath = componentPropertyPath?.slice(1)\n const propertiesToInspect = componentPropertyName\n ? properties.filter((property) => {\n if (Node.isSpreadAssignment(property)) {\n return true\n }\n\n if (\n !Node.isPropertyAssignment(property) &&\n !Node.isShorthandPropertyAssignment(property)\n ) {\n return false\n }\n\n const propertyName = getStaticPropertyName({ nameNode: property.getNameNode() })\n\n return propertyName === undefined || propertyName === componentPropertyName\n })\n : properties\n\n return propertiesToInspect.some((property) => {\n if (Node.isPropertyAssignment(property)) {\n const propertyInitializer = property.getInitializer()\n\n return propertyInitializer && Node.isExpression(propertyInitializer)\n ? initializerContainsClassComponent({\n componentPropertyPath: remainingComponentPropertyPath,\n initializer: propertyInitializer,\n visitedExpressions,\n })\n : false\n }\n\n if (Node.isShorthandPropertyAssignment(property)) {\n return initializerContainsClassComponent({\n componentPropertyPath: remainingComponentPropertyPath,\n initializer: property.getNameNode(),\n visitedExpressions,\n })\n }\n\n return Node.isSpreadAssignment(property)\n ? initializerContainsClassComponent({\n componentPropertyPath,\n initializer: property.getExpression(),\n visitedExpressions,\n })\n : false\n })\n }\n\n if (!Node.isIdentifier(expression)) {\n return false\n }\n\n return expression.getDefinitions().some((definition) => {\n const declaration = definition.getDeclarationNode()\n\n if (Node.isClassDeclaration(declaration)) {\n return true\n }\n\n if (Node.isVariableDeclaration(declaration)) {\n const referencedInitializer = declaration.getInitializer()\n\n return referencedInitializer\n ? initializerContainsClassComponent({\n componentPropertyPath,\n initializer: referencedInitializer,\n visitedExpressions,\n })\n : false\n }\n\n return false\n })\n}\n\ntype GetComponentPropertyPathArgs = {\n reference: Node\n}\n\nfunction getComponentPropertyPath({\n reference,\n}: GetComponentPropertyPathArgs): string[] | undefined {\n const propertySignatures = reference.getAncestors().filter(Node.isPropertySignature).reverse()\n\n if (propertySignatures.length === 0) {\n return undefined\n }\n\n const propertyPath = propertySignatures.map((property) =>\n getStaticPropertyName({ nameNode: property.getNameNode() }),\n )\n\n return propertyPath.every((propertyName): propertyName is string => propertyName !== undefined)\n ? propertyPath\n : undefined\n}\n\ntype GetStaticPropertyNameArgs = {\n nameNode: Node\n}\n\nfunction getStaticPropertyName({ nameNode }: GetStaticPropertyNameArgs): string | undefined {\n if (Node.isComputedPropertyName(nameNode)) {\n return getStaticComputedPropertyName({ expression: nameNode.getExpression() })\n }\n\n if (Node.isStringLiteral(nameNode) || Node.isNoSubstitutionTemplateLiteral(nameNode)) {\n return nameNode.getLiteralText()\n }\n\n if (Node.isNumericLiteral(nameNode)) {\n return String(nameNode.getLiteralValue())\n }\n\n return Node.isIdentifier(nameNode) ? nameNode.getText() : undefined\n}\n\ntype GetStaticComputedPropertyNameArgs = {\n expression: Expression\n visitedExpressions?: Set<Expression>\n}\n\nfunction getStaticComputedPropertyName({\n expression: initialExpression,\n visitedExpressions = new Set<Expression>(),\n}: GetStaticComputedPropertyNameArgs): string | undefined {\n let expression = initialExpression\n\n while (\n Node.isParenthesizedExpression(expression) ||\n Node.isAsExpression(expression) ||\n Node.isSatisfiesExpression(expression) ||\n Node.isTypeAssertion(expression) ||\n Node.isNonNullExpression(expression)\n ) {\n expression = expression.getExpression()\n }\n\n if (visitedExpressions.has(expression)) {\n return undefined\n }\n\n visitedExpressions.add(expression)\n\n if (Node.isStringLiteral(expression) || Node.isNoSubstitutionTemplateLiteral(expression)) {\n return expression.getLiteralText()\n }\n\n if (Node.isNumericLiteral(expression)) {\n return String(expression.getLiteralValue())\n }\n\n if (!Node.isIdentifier(expression)) {\n return undefined\n }\n\n for (const definition of expression.getDefinitions()) {\n const declaration = definition.getDeclarationNode()\n\n if (\n Node.isVariableDeclaration(declaration) &&\n declaration.getVariableStatement()?.getDeclarationKind() === VariableDeclarationKind.Const\n ) {\n const initializer = declaration.getInitializer()\n const propertyName =\n initializer && Node.isExpression(initializer)\n ? getStaticComputedPropertyName({ expression: initializer, visitedExpressions })\n : undefined\n\n if (propertyName !== undefined) {\n return propertyName\n }\n }\n }\n\n return undefined\n}\n\ntype GetAvailableNameArgs = {\n file: SourceFile\n preferredName: string\n suffix: string\n}\n\nfunction getAvailableName({ file, preferredName, suffix }: GetAvailableNameArgs): string {\n const usedNames = new Set(\n file.getDescendantsOfKind(SyntaxKind.Identifier).map((identifier) => identifier.getText()),\n )\n\n if (!usedNames.has(preferredName)) {\n return preferredName\n }\n\n let candidate = `${preferredName}${suffix}`\n let index = 2\n\n while (usedNames.has(candidate)) {\n candidate = `${preferredName}${suffix}${index}`\n index++\n }\n\n return candidate\n}\n\ntype CollectUnsupportedImportNotesArgs = {\n file: SourceFile\n notes: string[]\n}\n\nfunction collectUnsupportedImportNotes({ file, notes }: CollectUnsupportedImportNotesArgs): void {\n for (const exportDeclaration of file.getExportDeclarations()) {\n if (exportDeclaration.getModuleSpecifierValue() !== 'payload') {\n continue\n }\n\n for (const namedExport of exportDeclaration.getNamedExports()) {\n if (COMPONENT_TO_PROPS.has(namedExport.getName())) {\n notes.push(\n `${file.getFilePath()}:${namedExport.getStartLineNumber()}: Unsupported re-export of \\`${namedExport.getName()}\\`. Replace it with the corresponding props type manually.`,\n )\n }\n }\n }\n\n for (const importDeclaration of file.getImportDeclarations()) {\n if (importDeclaration.getModuleSpecifierValue() !== 'payload') {\n continue\n }\n\n const namespaceImport = importDeclaration.getNamespaceImport()\n if (!namespaceImport) {\n continue\n }\n\n const namespaceName = namespaceImport.getText()\n for (const qualifiedName of file.getDescendantsOfKind(SyntaxKind.QualifiedName)) {\n const componentName = qualifiedName.getRight().getText()\n\n if (\n qualifiedName.getLeft().getText() === namespaceName &&\n COMPONENT_TO_PROPS.has(componentName)\n ) {\n notes.push(\n `${file.getFilePath()}:${qualifiedName.getStartLineNumber()}: Unsupported namespace reference to \\`${componentName}\\`. Replace it with the corresponding props type manually.`,\n )\n }\n }\n }\n\n for (const importType of file.getDescendantsOfKind(SyntaxKind.ImportType)) {\n const argument = importType.getArgument()\n const literal = Node.isLiteralTypeNode(argument) ? argument.getLiteral() : undefined\n const qualifier = importType.getQualifier()\n\n if (\n Node.isStringLiteral(literal) &&\n literal.getLiteralText() === 'payload' &&\n qualifier &&\n COMPONENT_TO_PROPS.has(qualifier.getText())\n ) {\n const componentName = qualifier.getText()\n\n notes.push(\n `${file.getFilePath()}:${importType.getStartLineNumber()}: Unsupported inline import of \\`${componentName}\\`. Replace it with the corresponding props type manually.`,\n )\n }\n }\n}\n\nfunction removeEmptyImport(importDeclaration: ImportDeclaration): void {\n if (\n importDeclaration.wasForgotten() ||\n importDeclaration.getNamedImports().length > 0 ||\n importDeclaration.getDefaultImport() ||\n importDeclaration.getNamespaceImport()\n ) {\n return\n }\n\n importDeclaration.remove()\n}\n"],"names":["Node","SyntaxKind","VariableDeclarationKind","FIELD_NAMES","FIELDS_WITH_SPECIALIZED_COMPONENTS","SPECIALIZED_COMPONENT_NAMES","COMPONENT_TO_PROPS","Map","flatMap","fieldName","map","componentName","COMPONENT_GENERIC_DEFAULTS","migrateFieldComponentTypes","name","apply","project","filesChanged","Set","notes","file","getSourceFiles","collectUnsupportedImportNotes","mutated","reactBinding","importDeclaration","getImportDeclarations","getModuleSpecifierValue","componentImports","getNamedImports","filter","specifier","has","getName","localName","getAliasNode","getText","importMutated","componentImport","propsName","get","find","namedImport","binding","getNameNode","references","findReferencesAsNodes","node","getSourceFile","unsupportedReference","reference","parent","getParent","isTypeReference","getTypeName","push","getFilePath","getStartLineNumber","classDeclaration","getFirstAncestorByKind","VariableDeclaration","declaration","referenceIndex","initializer","getInitializer","componentPropertyPath","getComponentPropertyPath","undefined","initializerContainsClassComponent","length","remove","propsImport","resolvePropsImport","resolveReactTypeBinding","reverse","typeReference","getParentIfKindOrThrow","TypeReference","typeArguments","getTypeArguments","typeArgument","propsTypeArguments","materializeGenericDefaults","propsType","join","replaceWithText","currentSpecifier","exists","setName","removeAlias","setAlias","removeEmptyImport","shouldAddImport","addReactTypeImport","reactName","add","description","genericDefaults","slice","typeName","resolvePayloadTypeImport","existing","hasCompetingDeclaration","getAvailableName","preferredName","suffix","addNamedImport","alias","isTypeOnly","reactImports","namespaceImport","getNamespaceImport","defaultImport","getDefaultImport","getDescendantsOfKind","Identifier","some","identifier","ImportDeclaration","isTypeParameterDeclaration","isParameterDeclaration","isVariableDeclaration","isFunctionDeclaration","isClassDeclaration","isTypeAliasDeclaration","isInterfaceDeclaration","importDeclarations","lastImport","at","statements","getStatements","insertionIndex","indexOf","nextStatement","needsTerminator","getEndLineNumber","insertStatements","visitedExpressions","expression","isParenthesizedExpression","isAsExpression","isSatisfiesExpression","isTypeAssertion","isNonNullExpression","getExpression","isClassExpression","isArrayLiteralExpression","getElements","element","nestedExpression","isSpreadElement","isExpression","isConditionalExpression","getWhenTrue","getWhenFalse","isObjectLiteralExpression","properties","getProperties","componentPropertyName","remainingComponentPropertyPath","propertiesToInspect","property","isSpreadAssignment","isPropertyAssignment","isShorthandPropertyAssignment","propertyName","getStaticPropertyName","nameNode","propertyInitializer","isIdentifier","getDefinitions","definition","getDeclarationNode","referencedInitializer","propertySignatures","getAncestors","isPropertySignature","propertyPath","every","isComputedPropertyName","getStaticComputedPropertyName","isStringLiteral","isNoSubstitutionTemplateLiteral","getLiteralText","isNumericLiteral","String","getLiteralValue","initialExpression","getVariableStatement","getDeclarationKind","Const","usedNames","candidate","index","exportDeclaration","getExportDeclarations","namedExport","getNamedExports","namespaceName","qualifiedName","QualifiedName","getRight","getLeft","importType","ImportType","argument","getArgument","literal","isLiteralTypeNode","getLiteral","qualifier","getQualifier","wasForgotten"],"mappings":"AAEA,SAASA,IAAI,EAAEC,UAAU,EAAEC,uBAAuB,QAAQ,WAAU;AAIpE,MAAMC,cAAc;IAClB;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAED,MAAMC,qCAAqC;IACzC;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAED,MAAMC,8BAA8B;IAClC;IACA;IACA;IACA;IACA;IAC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AC/E,MAAM7L,gBAAgB4L,cAAcE,QAAQ,GAAGrK,OAAO;YAEtD,IACEmK,cAAcG,OAAO,GAAGtK,OAAO,OAAOkK,iBACtChM,mBAAmB0B,GAAG,CAACrB,gBACvB;gBACAQ,MAAMoC,IAAI,CACR,GAAGnC,KAAKoC,WAAW,GAAG,CAAC,EAAE+I,cAAc9I,kBAAkB,GAAG,uCAAuC,EAAE9C,cAAc,0DAA0D,CAAC;YAElL;QACF;IACF;IAEA,KAAK,MAAMgM,cAAcvL,KAAK8F,oBAAoB,CAACjH,WAAW2M,UAAU,EAAG;QACzE,MAAMC,WAAWF,WAAWG,WAAW;QACvC,MAAMC,UAAU/M,KAAKgN,iBAAiB,CAACH,YAAYA,SAASI,UAAU,KAAK9I;QAC3E,MAAM+I,YAAYP,WAAWQ,YAAY;QAEzC,IACEnN,KAAKqL,eAAe,CAAC0B,YACrBA,QAAQxB,cAAc,OAAO,aAC7B2B,aACA5M,mBAAmB0B,GAAG,CAACkL,UAAU9K,OAAO,KACxC;YACA,MAAMzB,gBAAgBuM,UAAU9K,OAAO;YAEvCjB,MAAMoC,IAAI,CACR,GAAGnC,KAAKoC,WAAW,GAAG,CAAC,EAAEmJ,WAAWlJ,kBAAkB,GAAG,iCAAiC,EAAE9C,cAAc,0DAA0D,CAAC;QAEzK;IACF;AACF;AAEA,SAASgF,kBAAkBlE,iBAAoC;IAC7D,IACEA,kBAAkB2L,YAAY,MAC9B3L,kBAAkBI,eAAe,GAAGwC,MAAM,GAAG,KAC7C5C,kBAAkBwF,gBAAgB,MAClCxF,kBAAkBsF,kBAAkB,IACpC;QACA;IACF;IAEAtF,kBAAkB6C,MAAM;AAC1B"}
1
+ {"version":3,"sources":["../../../src/transforms/migrate-field-component-types/index.ts"],"sourcesContent":["import type { Expression, ImportDeclaration, SourceFile } from 'ts-morph'\n\nimport { Node, SyntaxKind, VariableDeclarationKind } from 'ts-morph'\n\nimport type { Transform } from '../../types.js'\n\nconst FIELD_NAMES = [\n 'Array',\n 'Blocks',\n 'Checkbox',\n 'Code',\n 'Collapsible',\n 'Date',\n 'Email',\n 'Group',\n 'Join',\n 'JSON',\n 'Number',\n 'Point',\n 'Radio',\n 'Relationship',\n 'RichText',\n 'Row',\n 'Select',\n 'Tabs',\n 'Text',\n 'Textarea',\n 'UI',\n 'Upload',\n] as const\n\nconst FIELDS_WITH_SPECIALIZED_COMPONENTS = [\n 'Array',\n 'Blocks',\n 'Checkbox',\n 'Code',\n 'Collapsible',\n 'Date',\n 'Email',\n 'Group',\n 'Join',\n 'JSON',\n 'Number',\n 'Point',\n 'Radio',\n 'Relationship',\n 'RichText',\n 'Row',\n 'Select',\n 'Tabs',\n 'Text',\n 'Textarea',\n 'Upload',\n] as const\n\nconst SPECIALIZED_COMPONENT_NAMES = [\n 'FieldDescriptionClient',\n 'FieldDescriptionServer',\n 'FieldDiffClient',\n 'FieldDiffServer',\n 'FieldErrorClient',\n 'FieldErrorServer',\n 'FieldLabelClient',\n 'FieldLabelServer',\n] as const\n\nconst COMPONENT_TO_PROPS = new Map<string, string>([\n ['BlockRowLabelClientComponent', 'BlockRowLabelClientProps'],\n ['BlockRowLabelServerComponent', 'BlockRowLabelServerProps'],\n ['FieldClientComponent', 'FieldClientProps'],\n ['FieldDescriptionClientComponent', 'FieldDescriptionClientProps'],\n ['FieldDescriptionServerComponent', 'FieldDescriptionServerProps'],\n ['FieldDiffClientComponent', 'FieldDiffClientProps'],\n ['FieldDiffServerComponent', 'FieldDiffServerProps'],\n ['FieldErrorClientComponent', 'FieldErrorClientProps'],\n ['FieldErrorServerComponent', 'FieldErrorServerProps'],\n ['FieldLabelClientComponent', 'FieldLabelClientProps'],\n ['FieldLabelServerComponent', 'FieldLabelServerProps'],\n ['FieldServerComponent', 'FieldServerProps'],\n ...FIELD_NAMES.flatMap((fieldName) => [\n [`${fieldName}FieldClientComponent`, `${fieldName}FieldClientProps`] as const,\n [`${fieldName}FieldServerComponent`, `${fieldName}FieldServerProps`] as const,\n ]),\n ...FIELDS_WITH_SPECIALIZED_COMPONENTS.flatMap((fieldName) =>\n SPECIALIZED_COMPONENT_NAMES.map(\n (componentName) =>\n [`${fieldName}${componentName}Component`, `${fieldName}${componentName}Props`] as const,\n ),\n ),\n ['UIFieldDiffClientComponent', 'UIFieldDiffClientProps'],\n ['UIFieldDiffServerComponent', 'UIFieldDiffServerProps'],\n])\n\nconst COMPONENT_GENERIC_DEFAULTS = new Map<string, readonly string[]>([\n ['FieldDiffClientComponent', ['ClientFieldWithOptionalType']],\n ['FieldDiffServerComponent', ['Field', 'ClientFieldWithOptionalType']],\n ['FieldErrorServerComponent', ['Field', 'ClientFieldWithOptionalType']],\n ['FieldLabelClientComponent', ['ClientFieldWithOptionalType']],\n ['FieldLabelServerComponent', ['Field', 'ClientFieldWithOptionalType']],\n])\n\nexport const migrateFieldComponentTypes: Transform = {\n name: 'migrate-field-component-types',\n apply: ({ project }) => {\n const filesChanged = new Set<string>()\n const notes: string[] = []\n\n for (const file of project.getSourceFiles()) {\n collectUnsupportedImportNotes({ file, notes })\n\n let mutated = false\n let reactBinding: ResolvedReactBinding | undefined\n\n for (const importDeclaration of [...file.getImportDeclarations()]) {\n if (importDeclaration.getModuleSpecifierValue() !== 'payload') {\n continue\n }\n\n const componentImports = importDeclaration\n .getNamedImports()\n .filter((specifier) => COMPONENT_TO_PROPS.has(specifier.getName()))\n .map((specifier) => ({\n componentName: specifier.getName(),\n localName: specifier.getAliasNode()?.getText() ?? specifier.getName(),\n }))\n let importMutated = false\n\n for (const componentImport of componentImports) {\n const { componentName, localName } = componentImport\n const propsName = COMPONENT_TO_PROPS.get(componentName)\n\n if (!propsName) {\n continue\n }\n\n const specifier = importDeclaration\n .getNamedImports()\n .find(\n (namedImport) =>\n namedImport.getName() === componentName &&\n (namedImport.getAliasNode()?.getText() ?? namedImport.getName()) === localName,\n )\n\n if (!specifier) {\n continue\n }\n\n const binding = specifier.getAliasNode() ?? specifier.getNameNode()\n\n // Always an Identifier in valid code: a string-literal import name requires an alias.\n if (!Node.isIdentifier(binding)) {\n continue\n }\n\n const references = binding\n .findReferencesAsNodes()\n .filter((node) => node !== binding && node.getSourceFile() === file)\n const unsupportedReference = references.find((reference) => {\n const parent = reference.getParent()\n\n return !Node.isTypeReference(parent) || parent.getTypeName() !== reference\n })\n\n if (unsupportedReference) {\n notes.push(\n `${file.getFilePath()}:${unsupportedReference.getStartLineNumber()}: Unsupported use of \\`${componentName}\\`. Replace it with the corresponding props type manually.`,\n )\n continue\n }\n\n const classDeclaration = references\n .map((reference) => reference.getFirstAncestorByKind(SyntaxKind.VariableDeclaration))\n .find((declaration, referenceIndex) => {\n const initializer = declaration?.getInitializer()\n const reference = references[referenceIndex]\n const componentPropertyPath = reference\n ? getComponentPropertyPath({ reference })\n : undefined\n\n return initializer\n ? initializerContainsClassComponent({ componentPropertyPath, initializer })\n : false\n })\n\n if (classDeclaration) {\n notes.push(\n `${file.getFilePath()}:${classDeclaration.getStartLineNumber()}: Cannot automatically migrate \\`${componentName}\\` because it types a class component. Replace it with a compatible props annotation manually.`,\n )\n continue\n }\n\n if (references.length === 0) {\n specifier.remove()\n importMutated = true\n mutated = true\n continue\n }\n\n const propsImport = resolvePropsImport({\n file,\n propsName,\n })\n\n reactBinding ??= resolveReactTypeBinding(file)\n\n for (const reference of references.reverse()) {\n const typeReference = reference.getParentIfKindOrThrow(SyntaxKind.TypeReference)\n const typeArguments = typeReference\n .getTypeArguments()\n .map((typeArgument) => typeArgument.getText())\n const propsTypeArguments = materializeGenericDefaults({\n componentName,\n file,\n importDeclaration,\n typeArguments,\n })\n const propsType =\n propsTypeArguments.length > 0\n ? `${propsImport.localName}<${propsTypeArguments.join(', ')}>`\n : propsImport.localName\n\n typeReference.replaceWithText(`${reactBinding.localName}.FC<${propsType}>`)\n }\n\n const currentSpecifier = importDeclaration\n .getNamedImports()\n .find(\n (namedImport) =>\n namedImport.getName() === componentName &&\n (namedImport.getAliasNode()?.getText() ?? namedImport.getName()) === localName,\n )\n\n if (propsImport.exists) {\n currentSpecifier?.remove()\n } else if (currentSpecifier) {\n currentSpecifier.setName(propsName)\n\n if (propsImport.localName === propsName) {\n currentSpecifier.removeAlias()\n } else {\n currentSpecifier.setAlias(propsImport.localName)\n }\n }\n\n importMutated = true\n mutated = true\n }\n\n if (importMutated) {\n removeEmptyImport(importDeclaration)\n }\n }\n\n if (reactBinding?.shouldAddImport) {\n addReactTypeImport({ file, reactName: reactBinding.localName })\n }\n\n if (mutated) {\n filesChanged.add(file.getFilePath())\n }\n }\n\n return {\n filesChanged: [...filesChanged],\n ...(notes.length > 0 ? { notes } : {}),\n }\n },\n description:\n 'Replace field component aliases imported from `payload` with the corresponding props types wrapped in `React.FC`. Generic arguments are preserved. Explicit class components and unsupported import forms are left unchanged with notes for manual migration.',\n}\n\ntype ResolvePropsImportArgs = {\n file: SourceFile\n propsName: string\n}\n\ntype MaterializeGenericDefaultsArgs = {\n componentName: string\n file: SourceFile\n importDeclaration: ImportDeclaration\n typeArguments: string[]\n}\n\nfunction materializeGenericDefaults({\n componentName,\n file,\n importDeclaration,\n typeArguments,\n}: MaterializeGenericDefaultsArgs): string[] {\n const genericDefaults = COMPONENT_GENERIC_DEFAULTS.get(componentName)\n\n if (!genericDefaults || typeArguments.length >= genericDefaults.length) {\n return typeArguments\n }\n\n return [\n ...typeArguments,\n ...genericDefaults.slice(typeArguments.length).map((typeName) =>\n resolvePayloadTypeImport({\n file,\n importDeclaration,\n typeName,\n }),\n ),\n ]\n}\n\ntype ResolvePayloadTypeImportArgs = {\n file: SourceFile\n importDeclaration: ImportDeclaration\n typeName: string\n}\n\nfunction resolvePayloadTypeImport({\n file,\n importDeclaration,\n typeName,\n}: ResolvePayloadTypeImportArgs): string {\n for (const declaration of file.getImportDeclarations()) {\n if (declaration.getModuleSpecifierValue() !== 'payload') {\n continue\n }\n\n const existing = declaration\n .getNamedImports()\n .find((namedImport) => namedImport.getName() === typeName)\n\n if (existing) {\n const localName = existing.getAliasNode()?.getText() ?? typeName\n\n if (\n !hasCompetingDeclaration({\n file,\n importDeclaration: declaration,\n localName,\n })\n ) {\n return localName\n }\n }\n }\n\n const localName = getAvailableName({ file, preferredName: typeName, suffix: 'Type' })\n\n importDeclaration.addNamedImport({\n name: typeName,\n alias: localName === typeName ? undefined : localName,\n isTypeOnly: !importDeclaration.isTypeOnly(),\n })\n\n return localName\n}\n\ntype ResolvedPropsImport = {\n exists: boolean\n localName: string\n}\n\nfunction resolvePropsImport({ file, propsName }: ResolvePropsImportArgs): ResolvedPropsImport {\n for (const declaration of file.getImportDeclarations()) {\n if (declaration.getModuleSpecifierValue() !== 'payload') {\n continue\n }\n\n const existing = declaration\n .getNamedImports()\n .find((namedImport) => namedImport.getName() === propsName)\n\n if (existing) {\n const localName = existing.getAliasNode()?.getText() ?? propsName\n\n if (\n !hasCompetingDeclaration({\n file,\n importDeclaration: declaration,\n localName,\n })\n ) {\n return {\n exists: true,\n localName,\n }\n }\n }\n }\n\n const localName = getAvailableName({ file, preferredName: propsName, suffix: 'Type' })\n\n return { exists: false, localName }\n}\n\ntype ResolvedReactBinding = {\n localName: string\n shouldAddImport: boolean\n}\n\nfunction resolveReactTypeBinding(file: SourceFile): ResolvedReactBinding {\n const reactImports = file\n .getImportDeclarations()\n .filter((declaration) => declaration.getModuleSpecifierValue() === 'react')\n\n for (const declaration of reactImports) {\n const namespaceImport = declaration.getNamespaceImport()\n if (\n namespaceImport &&\n !hasCompetingDeclaration({\n file,\n importDeclaration: declaration,\n localName: namespaceImport.getText(),\n })\n ) {\n return { localName: namespaceImport.getText(), shouldAddImport: false }\n }\n\n const defaultImport = declaration.getDefaultImport()\n if (\n defaultImport &&\n !hasCompetingDeclaration({\n file,\n importDeclaration: declaration,\n localName: defaultImport.getText(),\n })\n ) {\n return { localName: defaultImport.getText(), shouldAddImport: false }\n }\n }\n\n return {\n localName: getAvailableName({ file, preferredName: 'React', suffix: 'Type' }),\n shouldAddImport: true,\n }\n}\n\ntype HasCompetingDeclarationArgs = {\n file: SourceFile\n importDeclaration: ImportDeclaration\n localName: string\n}\n\nfunction hasCompetingDeclaration({\n file,\n importDeclaration,\n localName,\n}: HasCompetingDeclarationArgs): boolean {\n return file.getDescendantsOfKind(SyntaxKind.Identifier).some((identifier) => {\n if (\n identifier.getText() !== localName ||\n identifier.getFirstAncestorByKind(SyntaxKind.ImportDeclaration) === importDeclaration\n ) {\n return false\n }\n\n const parent = identifier.getParent()\n\n return (\n (Node.isTypeParameterDeclaration(parent) ||\n Node.isParameterDeclaration(parent) ||\n Node.isVariableDeclaration(parent) ||\n Node.isFunctionDeclaration(parent) ||\n Node.isClassDeclaration(parent) ||\n Node.isTypeAliasDeclaration(parent) ||\n Node.isInterfaceDeclaration(parent)) &&\n parent.getNameNode() === identifier\n )\n })\n}\n\ntype AddReactTypeImportArgs = {\n file: SourceFile\n reactName: string\n}\n\nfunction addReactTypeImport({ file, reactName }: AddReactTypeImportArgs): void {\n const importDeclarations = file.getImportDeclarations()\n const lastImport = importDeclarations.at(-1)\n const statements = file.getStatements()\n const insertionIndex = lastImport ? statements.indexOf(lastImport) + 1 : 0\n const nextStatement = statements.at(insertionIndex)\n const needsTerminator =\n lastImport && nextStatement\n ? lastImport.getEndLineNumber() === nextStatement.getStartLineNumber()\n : false\n\n file.insertStatements(\n insertionIndex,\n `import type ${reactName} from 'react'${needsTerminator ? ';' : ''}`,\n )\n}\n\ntype InitializerContainsClassComponentArgs = {\n componentPropertyPath?: string[]\n initializer: Expression\n visitedExpressions?: Set<Expression>\n}\n\nfunction initializerContainsClassComponent({\n componentPropertyPath,\n initializer,\n visitedExpressions = new Set<Expression>(),\n}: InitializerContainsClassComponentArgs): boolean {\n let expression = initializer\n\n while (\n Node.isParenthesizedExpression(expression) ||\n Node.isAsExpression(expression) ||\n Node.isSatisfiesExpression(expression) ||\n Node.isTypeAssertion(expression) ||\n Node.isNonNullExpression(expression)\n ) {\n expression = expression.getExpression()\n }\n\n if (visitedExpressions.has(expression)) {\n return false\n }\n\n visitedExpressions.add(expression)\n\n if (Node.isClassExpression(expression)) {\n return true\n }\n\n if (Node.isArrayLiteralExpression(expression)) {\n return expression.getElements().some((element) => {\n const nestedExpression = Node.isSpreadElement(element) ? element.getExpression() : element\n\n return Node.isExpression(nestedExpression)\n ? initializerContainsClassComponent({\n componentPropertyPath,\n initializer: nestedExpression,\n visitedExpressions,\n })\n : false\n })\n }\n\n if (Node.isConditionalExpression(expression)) {\n return [expression.getWhenTrue(), expression.getWhenFalse()].some((nestedExpression) =>\n initializerContainsClassComponent({\n componentPropertyPath,\n initializer: nestedExpression,\n visitedExpressions,\n }),\n )\n }\n\n if (Node.isObjectLiteralExpression(expression)) {\n const properties = expression.getProperties()\n const componentPropertyName = componentPropertyPath?.[0]\n const remainingComponentPropertyPath = componentPropertyPath?.slice(1)\n const propertiesToInspect = componentPropertyName\n ? properties.filter((property) => {\n if (Node.isSpreadAssignment(property)) {\n return true\n }\n\n if (\n !Node.isPropertyAssignment(property) &&\n !Node.isShorthandPropertyAssignment(property)\n ) {\n return false\n }\n\n const propertyName = getStaticPropertyName({ nameNode: property.getNameNode() })\n\n return propertyName === undefined || propertyName === componentPropertyName\n })\n : properties\n\n return propertiesToInspect.some((property) => {\n if (Node.isPropertyAssignment(property)) {\n const propertyInitializer = property.getInitializer()\n\n return propertyInitializer && Node.isExpression(propertyInitializer)\n ? initializerContainsClassComponent({\n componentPropertyPath: remainingComponentPropertyPath,\n initializer: propertyInitializer,\n visitedExpressions,\n })\n : false\n }\n\n if (Node.isShorthandPropertyAssignment(property)) {\n return initializerContainsClassComponent({\n componentPropertyPath: remainingComponentPropertyPath,\n initializer: property.getNameNode(),\n visitedExpressions,\n })\n }\n\n return Node.isSpreadAssignment(property)\n ? initializerContainsClassComponent({\n componentPropertyPath,\n initializer: property.getExpression(),\n visitedExpressions,\n })\n : false\n })\n }\n\n if (!Node.isIdentifier(expression)) {\n return false\n }\n\n return expression.getDefinitions().some((definition) => {\n const declaration = definition.getDeclarationNode()\n\n if (Node.isClassDeclaration(declaration)) {\n return true\n }\n\n if (Node.isVariableDeclaration(declaration)) {\n const referencedInitializer = declaration.getInitializer()\n\n return referencedInitializer\n ? initializerContainsClassComponent({\n componentPropertyPath,\n initializer: referencedInitializer,\n visitedExpressions,\n })\n : false\n }\n\n return false\n })\n}\n\ntype GetComponentPropertyPathArgs = {\n reference: Node\n}\n\nfunction getComponentPropertyPath({\n reference,\n}: GetComponentPropertyPathArgs): string[] | undefined {\n const propertySignatures = reference.getAncestors().filter(Node.isPropertySignature).reverse()\n\n if (propertySignatures.length === 0) {\n return undefined\n }\n\n const propertyPath = propertySignatures.map((property) =>\n getStaticPropertyName({ nameNode: property.getNameNode() }),\n )\n\n return propertyPath.every((propertyName): propertyName is string => propertyName !== undefined)\n ? propertyPath\n : undefined\n}\n\ntype GetStaticPropertyNameArgs = {\n nameNode: Node\n}\n\nfunction getStaticPropertyName({ nameNode }: GetStaticPropertyNameArgs): string | undefined {\n if (Node.isComputedPropertyName(nameNode)) {\n return getStaticComputedPropertyName({ expression: nameNode.getExpression() })\n }\n\n if (Node.isStringLiteral(nameNode) || Node.isNoSubstitutionTemplateLiteral(nameNode)) {\n return nameNode.getLiteralText()\n }\n\n if (Node.isNumericLiteral(nameNode)) {\n return String(nameNode.getLiteralValue())\n }\n\n return Node.isIdentifier(nameNode) ? nameNode.getText() : undefined\n}\n\ntype GetStaticComputedPropertyNameArgs = {\n expression: Expression\n visitedExpressions?: Set<Expression>\n}\n\nfunction getStaticComputedPropertyName({\n expression: initialExpression,\n visitedExpressions = new Set<Expression>(),\n}: GetStaticComputedPropertyNameArgs): string | undefined {\n let expression = initialExpression\n\n while (\n Node.isParenthesizedExpression(expression) ||\n Node.isAsExpression(expression) ||\n Node.isSatisfiesExpression(expression) ||\n Node.isTypeAssertion(expression) ||\n Node.isNonNullExpression(expression)\n ) {\n expression = expression.getExpression()\n }\n\n if (visitedExpressions.has(expression)) {\n return undefined\n }\n\n visitedExpressions.add(expression)\n\n if (Node.isStringLiteral(expression) || Node.isNoSubstitutionTemplateLiteral(expression)) {\n return expression.getLiteralText()\n }\n\n if (Node.isNumericLiteral(expression)) {\n return String(expression.getLiteralValue())\n }\n\n if (!Node.isIdentifier(expression)) {\n return undefined\n }\n\n for (const definition of expression.getDefinitions()) {\n const declaration = definition.getDeclarationNode()\n\n if (\n Node.isVariableDeclaration(declaration) &&\n declaration.getVariableStatement()?.getDeclarationKind() === VariableDeclarationKind.Const\n ) {\n const initializer = declaration.getInitializer()\n const propertyName =\n initializer && Node.isExpression(initializer)\n ? getStaticComputedPropertyName({ expression: initializer, visitedExpressions })\n : undefined\n\n if (propertyName !== undefined) {\n return propertyName\n }\n }\n }\n\n return undefined\n}\n\ntype GetAvailableNameArgs = {\n file: SourceFile\n preferredName: string\n suffix: string\n}\n\nfunction getAvailableName({ file, preferredName, suffix }: GetAvailableNameArgs): string {\n const usedNames = new Set(\n file.getDescendantsOfKind(SyntaxKind.Identifier).map((identifier) => identifier.getText()),\n )\n\n if (!usedNames.has(preferredName)) {\n return preferredName\n }\n\n let candidate = `${preferredName}${suffix}`\n let index = 2\n\n while (usedNames.has(candidate)) {\n candidate = `${preferredName}${suffix}${index}`\n index++\n }\n\n return candidate\n}\n\ntype CollectUnsupportedImportNotesArgs = {\n file: SourceFile\n notes: string[]\n}\n\nfunction collectUnsupportedImportNotes({ file, notes }: CollectUnsupportedImportNotesArgs): void {\n for (const exportDeclaration of file.getExportDeclarations()) {\n if (exportDeclaration.getModuleSpecifierValue() !== 'payload') {\n continue\n }\n\n for (const namedExport of exportDeclaration.getNamedExports()) {\n if (COMPONENT_TO_PROPS.has(namedExport.getName())) {\n notes.push(\n `${file.getFilePath()}:${namedExport.getStartLineNumber()}: Unsupported re-export of \\`${namedExport.getName()}\\`. Replace it with the corresponding props type manually.`,\n )\n }\n }\n }\n\n for (const importDeclaration of file.getImportDeclarations()) {\n if (importDeclaration.getModuleSpecifierValue() !== 'payload') {\n continue\n }\n\n const namespaceImport = importDeclaration.getNamespaceImport()\n if (!namespaceImport) {\n continue\n }\n\n const namespaceName = namespaceImport.getText()\n for (const qualifiedName of file.getDescendantsOfKind(SyntaxKind.QualifiedName)) {\n const componentName = qualifiedName.getRight().getText()\n\n if (\n qualifiedName.getLeft().getText() === namespaceName &&\n COMPONENT_TO_PROPS.has(componentName)\n ) {\n notes.push(\n `${file.getFilePath()}:${qualifiedName.getStartLineNumber()}: Unsupported namespace reference to \\`${componentName}\\`. Replace it with the corresponding props type manually.`,\n )\n }\n }\n }\n\n for (const importType of file.getDescendantsOfKind(SyntaxKind.ImportType)) {\n const argument = importType.getArgument()\n const literal = Node.isLiteralTypeNode(argument) ? argument.getLiteral() : undefined\n const qualifier = importType.getQualifier()\n\n if (\n Node.isStringLiteral(literal) &&\n literal.getLiteralText() === 'payload' &&\n qualifier &&\n COMPONENT_TO_PROPS.has(qualifier.getText())\n ) {\n const componentName = qualifier.getText()\n\n notes.push(\n `${file.getFilePath()}:${importType.getStartLineNumber()}: Unsupported inline import of \\`${componentName}\\`. Replace it with the corresponding props type manually.`,\n )\n }\n }\n}\n\nfunction removeEmptyImport(importDeclaration: ImportDeclaration): void {\n if (\n importDeclaration.wasForgotten() ||\n importDeclaration.getNamedImports().length > 0 ||\n importDeclaration.getDefaultImport() ||\n importDeclaration.getNamespaceImport()\n ) {\n return\n }\n\n importDeclaration.remove()\n}\n"],"names":["Node","SyntaxKind","VariableDeclarationKind","FIELD_NAMES","FIELDS_WITH_SPECIALIZED_COMPONENTS","SPECIALIZED_COMPONENT_NAMES","COMPONENT_TO_PROPS","Map","flatMap","fieldName","map","componentName","COMPONENT_GENERIC_DEFAULTS","migrateFieldComponentTypes","name","apply","project","filesChanged","Set","notes","file","getSourceFiles","collectUnsupportedImportNotes","mutated","reactBinding","importDeclaration","getImportDeclarations","getModuleSpecifierValue","componentImports","getNamedImports","filter","specifier","has","getName","localName","getAliasNode","getText","importMutated","componentImport","propsName","get","find","namedImport","binding","getNameNode","isIdentifier","references","findReferencesAsNodes","node","getSourceFile","unsupportedReference","reference","parent","getParent","isTypeReference","getTypeName","push","getFilePath","getStartLineNumber","classDeclaration","getFirstAncestorByKind","VariableDeclaration","declaration","referenceIndex","initializer","getInitializer","componentPropertyPath","getComponentPropertyPath","undefined","initializerContainsClassComponent","length","remove","propsImport","resolvePropsImport","resolveReactTypeBinding","reverse","typeReference","getParentIfKindOrThrow","TypeReference","typeArguments","getTypeArguments","typeArgument","propsTypeArguments","materializeGenericDefaults","propsType","join","replaceWithText","currentSpecifier","exists","setName","removeAlias","setAlias","removeEmptyImport","shouldAddImport","addReactTypeImport","reactName","add","description","genericDefaults","slice","typeName","resolvePayloadTypeImport","existing","hasCompetingDeclaration","getAvailableName","preferredName","suffix","addNamedImport","alias","isTypeOnly","reactImports","namespaceImport","getNamespaceImport","defaultImport","getDefaultImport","getDescendantsOfKind","Identifier","some","identifier","ImportDeclaration","isTypeParameterDeclaration","isParameterDeclaration","isVariableDeclaration","isFunctionDeclaration","isClassDeclaration","isTypeAliasDeclaration","isInterfaceDeclaration","importDeclarations","lastImport","at","statements","getStatements","insertionIndex","indexOf","nextStatement","needsTerminator","getEndLineNumber","insertStatements","visitedExpressions","expression","isParenthesizedExpression","isAsExpression","isSatisfiesExpression","isTypeAssertion","isNonNullExpression","getExpression","isClassExpression","isArrayLiteralExpression","getElements","element","nestedExpression","isSpreadElement","isExpression","isConditionalExpression","getWhenTrue","getWhenFalse","isObjectLiteralExpression","properties","getProperties","componentPropertyName","remainingComponentPropertyPath","propertiesToInspect","property","isSpreadAssignment","isPropertyAssignment","isShorthandPropertyAssignment","propertyName","getStaticPropertyName","nameNode","propertyInitializer","getDefinitions","definition","getDeclarationNode","referencedInitializer","propertySignatures","getAncestors","isPropertySignature","propertyPath","every","isComputedPropertyName","getStaticComputedPropertyName","isStringLiteral","isNoSubstitutionTemplateLiteral","getLiteralText","isNumericLiteral","String","getLiteralValue","initialExpression","getVariableStatement","getDeclarationKind","Const","usedNames","candidate","index","exportDeclaration","getExportDeclarations","namedExport","getNamedExports","namespaceName","qualifiedName","QualifiedName","getRight","getLeft","importType","ImportType","argument","getArgument","literal","isLiteralTypeNode","getLiteral","qualifier","getQualifier","wasForgotten"],"mappings":"AAEA,SAASA,IAAI,EAAEC,UAAU,EAAEC,uBAAuB,QAAQ,WAAU;AAIpE,MAAMC,cAAc;IAClB;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAED,MAAMC,qCAAqC;IACzC;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAED,MAAMC,8BAA8B;IAClC;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAED,MAAMC,qBAAqB,IAAIC,IAAoB;IACjD;QAAC;QAAgC;KAA2B;IAC5D;QAAC;QAAgC;KAA2B;IAC5D;QAAC;QAAwB;KAAmB;IAC5C;QAAC;QAAmC;KAA8B;IAClE;QAAC;QAAmC;KAA8B;IAClE;QAAC;QAA4B;KAAuB;IACpD;QAAC;QAA4B;KAAuB;IACpD;QAAC;QAA6B;KAAwB;IACtD;QAAC;QAA6B;KAAwB;IACtD;QAAC;QAA6B;KAAwB;IACtD;QAAC;QAA6B;KAAwB;IACtD;QAAC;QAAwB;KAAmB;OACzCJ,YAAYK,OAAO,CAAC,CAACC,YAAc;YACpC;gBAAC,GAAGA,UAAU,oBAAoB,CAAC;gBAAE,GAAGA,UAAU,gBAAgB,CAAC;aAAC;YACpE;gBAAC,GAAGA,UAAU,oBAAoB,CAAC;gBAAE,GAAGA,UAAU,gBAAgB,CAAC;aAAC;SACrE;OACEL,mCAAmCI,OAAO,CAAC,CAACC,YAC7CJ,4BAA4BK,GAAG,CAC7B,CAACC,gBACC;gBAAC,GAAGF,YAAYE,cAAc,SAAS,CAAC;gBAAE,GAAGF,YAAYE,cAAc,KAAK,CAAC;aAAC;I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OAAO;YAEvCjB,MAAMqC,IAAI,CACR,GAAGpC,KAAKqC,WAAW,GAAG,CAAC,EAAEkJ,WAAWjJ,kBAAkB,GAAG,iCAAiC,EAAE/C,cAAc,0DAA0D,CAAC;QAEzK;IACF;AACF;AAEA,SAASiF,kBAAkBnE,iBAAoC;IAC7D,IACEA,kBAAkB2L,YAAY,MAC9B3L,kBAAkBI,eAAe,GAAGyC,MAAM,GAAG,KAC7C7C,kBAAkByF,gBAAgB,MAClCzF,kBAAkBuF,kBAAkB,IACpC;QACA;IACF;IAEAvF,kBAAkB8C,MAAM;AAC1B"}
@@ -21,7 +21,7 @@ export default buildConfig({
21
21
  width: 200,
22
22
  height: 200
23
23
  },
24
- imageSizes: [
24
+ variants: [
25
25
  {
26
26
  name: 'square',
27
27
  height: 400,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/transforms/migrate-sharp-to-transformer/basic.output.ts"],"sourcesContent":["import sharp from 'sharp'\nimport { buildConfig } from 'payload'\nimport { sharpTransformer } from '@payloadcms/transformer-sharp'\n\nexport default buildConfig({\n collections: [\n {\n slug: 'media',\n fields: [],\n upload: {\n staticDir: 'media',\n },\n },\n ],\n upload: { transformers: [sharpTransformer({ sharp, collections: { media: { resizeOptions: {\n width: 200,\n height: 200,\n }, imageSizes: [{ name: 'square', height: 400, width: 400 }], crop: false } } })] },\n})\n"],"names":["sharp","buildConfig","sharpTransformer","collections","slug","fields","upload","staticDir","transformers","media","resizeOptions","width","height","imageSizes","name","crop"],"mappings":"AAAA,OAAOA,WAAW,QAAO;AACzB,SAASC,WAAW,QAAQ,UAAS;AACrC,SAASC,gBAAgB,QAAQ,gCAA+B;AAEhE,eAAeD,YAAY;IACzBE,aAAa;QACX;YACEC,MAAM;YACNC,QAAQ,EAAE;YACVC,QAAQ;gBACNC,WAAW;YACb;QACF;KACD;IACDD,QAAQ;QAAEE,cAAc;YAACN,iBAAiB;gBAAEF;gBAAOG,aAAa;oBAAEM,OAAO;wBAAEC,eAAe;4BACpFC,OAAO;4BACPC,QAAQ;wBACZ;wBAAGC,YAAY;4BAAC;gCAAEC,MAAM;gCAAUF,QAAQ;gCAAKD,OAAO;4BAAI;yBAAE;wBAAEI,MAAM;oBAAM;gBAAE;YAAE;SAAG;IAAC;AACtF,GAAE"}
1
+ {"version":3,"sources":["../../../src/transforms/migrate-sharp-to-transformer/basic.output.ts"],"sourcesContent":["import sharp from 'sharp'\nimport { buildConfig } from 'payload'\nimport { sharpTransformer } from '@payloadcms/transformer-sharp'\n\nexport default buildConfig({\n collections: [\n {\n slug: 'media',\n fields: [],\n upload: {\n staticDir: 'media',\n },\n },\n ],\n upload: { transformers: [sharpTransformer({ sharp, collections: { media: { resizeOptions: {\n width: 200,\n height: 200,\n }, variants: [{ name: 'square', height: 400, width: 400 }], crop: false } } })] },\n})\n"],"names":["sharp","buildConfig","sharpTransformer","collections","slug","fields","upload","staticDir","transformers","media","resizeOptions","width","height","variants","name","crop"],"mappings":"AAAA,OAAOA,WAAW,QAAO;AACzB,SAASC,WAAW,QAAQ,UAAS;AACrC,SAASC,gBAAgB,QAAQ,gCAA+B;AAEhE,eAAeD,YAAY;IACzBE,aAAa;QACX;YACEC,MAAM;YACNC,QAAQ,EAAE;YACVC,QAAQ;gBACNC,WAAW;YACb;QACF;KACD;IACDD,QAAQ;QAAEE,cAAc;YAACN,iBAAiB;gBAAEF;gBAAOG,aAAa;oBAAEM,OAAO;wBAAEC,eAAe;4BACpFC,OAAO;4BACPC,QAAQ;wBACZ;wBAAGC,UAAU;4BAAC;gCAAEC,MAAM;gCAAUF,QAAQ;gCAAKD,OAAO;4BAAI;yBAAE;wBAAEI,MAAM;oBAAM;gBAAE;YAAE;SAAG;IAAC;AACpF,GAAE"}
@@ -16,7 +16,7 @@ export default buildConfig({
16
16
  sharpTransformer({
17
17
  collections: {
18
18
  media: {
19
- imageSizes: [
19
+ variants: [
20
20
  {
21
21
  name: 'square',
22
22
  height: 400,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/transforms/migrate-sharp-to-transformer/existing-transformers.output.ts"],"sourcesContent":["import { customTransformer } from './customTransformer.js'\nimport { buildConfig } from 'payload'\nimport { sharpTransformer } from '@payloadcms/transformer-sharp'\n\nexport default buildConfig({\n collections: [\n {\n slug: 'media',\n fields: [],\n upload: {},\n },\n ],\n upload: {\n abortOnLimit: true,\n transformers: [customTransformer(), sharpTransformer({ collections: { media: { imageSizes: [{ name: 'square', height: 400, width: 400 }] } } })],\n },\n})\n"],"names":["customTransformer","buildConfig","sharpTransformer","collections","slug","fields","upload","abortOnLimit","transformers","media","imageSizes","name","height","width"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,yBAAwB;AAC1D,SAASC,WAAW,QAAQ,UAAS;AACrC,SAASC,gBAAgB,QAAQ,gCAA+B;AAEhE,eAAeD,YAAY;IACzBE,aAAa;QACX;YACEC,MAAM;YACNC,QAAQ,EAAE;YACVC,QAAQ,CAAC;QACX;KACD;IACDA,QAAQ;QACNC,cAAc;QACdC,cAAc;YAACR;YAAqBE,iBAAiB;gBAAEC,aAAa;oBAAEM,OAAO;wBAAEC,YAAY;4BAAC;gCAAEC,MAAM;gCAAUC,QAAQ;gCAAKC,OAAO;4BAAI;yBAAE;oBAAC;gBAAE;YAAE;SAAG;IAClJ;AACF,GAAE"}
1
+ {"version":3,"sources":["../../../src/transforms/migrate-sharp-to-transformer/existing-transformers.output.ts"],"sourcesContent":["import { customTransformer } from './customTransformer.js'\nimport { buildConfig } from 'payload'\nimport { sharpTransformer } from '@payloadcms/transformer-sharp'\n\nexport default buildConfig({\n collections: [\n {\n slug: 'media',\n fields: [],\n upload: {},\n },\n ],\n upload: {\n abortOnLimit: true,\n transformers: [customTransformer(), sharpTransformer({ collections: { media: { variants: [{ name: 'square', height: 400, width: 400 }] } } })],\n },\n})\n"],"names":["customTransformer","buildConfig","sharpTransformer","collections","slug","fields","upload","abortOnLimit","transformers","media","variants","name","height","width"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,yBAAwB;AAC1D,SAASC,WAAW,QAAQ,UAAS;AACrC,SAASC,gBAAgB,QAAQ,gCAA+B;AAEhE,eAAeD,YAAY;IACzBE,aAAa;QACX;YACEC,MAAM;YACNC,QAAQ,EAAE;YACVC,QAAQ,CAAC;QACX;KACD;IACDA,QAAQ;QACNC,cAAc;QACdC,cAAc;YAACR;YAAqBE,iBAAiB;gBAAEC,aAAa;oBAAEM,OAAO;wBAAEC,UAAU;4BAAC;gCAAEC,MAAM;gCAAUC,QAAQ;gCAAKC,OAAO;4BAAI;yBAAE;oBAAC;gBAAE;YAAE;SAAG;IAChJ;AACF,GAAE"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transforms/migrate-sharp-to-transformer/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AA6P/C,eAAO,MAAM,yBAAyB,EAAE,SAmHvC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transforms/migrate-sharp-to-transformer/index.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAoe/C,eAAO,MAAM,yBAAyB,EAAE,SA4JvC,CAAA"}