@payloadcms/codemod 4.0.0-internal.4a8e202 → 4.0.0-internal.4c2ee12
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.
- package/README.md +96 -27
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.help.d.ts +4 -0
- package/dist/cli.help.d.ts.map +1 -0
- package/dist/cli.help.js +29 -0
- package/dist/cli.help.js.map +1 -0
- package/dist/cli.js +49 -27
- package/dist/cli.js.map +1 -1
- package/dist/cli.parseFlags.d.ts +15 -0
- package/dist/cli.parseFlags.d.ts.map +1 -1
- package/dist/cli.parseFlags.js +35 -2
- package/dist/cli.parseFlags.js.map +1 -1
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +21 -1
- package/dist/registry.js.map +1 -1
- package/dist/runbook/payload-v4-upgrade.md +55 -0
- package/dist/runbook/v4.mdx +2500 -0
- package/dist/transforms/add-override-access-true/basic.input.js +41 -0
- package/dist/transforms/add-override-access-true/basic.input.js.map +1 -0
- package/dist/transforms/add-override-access-true/basic.output.js +50 -0
- package/dist/transforms/add-override-access-true/basic.output.js.map +1 -0
- package/dist/transforms/add-override-access-true/comment-between-properties.input.js +11 -0
- package/dist/transforms/add-override-access-true/comment-between-properties.input.js.map +1 -0
- package/dist/transforms/add-override-access-true/comment-between-properties.output.js +12 -0
- package/dist/transforms/add-override-access-true/comment-between-properties.output.js.map +1 -0
- package/dist/transforms/add-override-access-true/index.d.ts +20 -0
- package/dist/transforms/add-override-access-true/index.d.ts.map +1 -0
- package/dist/transforms/add-override-access-true/index.js +208 -0
- package/dist/transforms/add-override-access-true/index.js.map +1 -0
- package/dist/transforms/add-override-access-true/javascript.input.d.ts +6 -0
- package/dist/transforms/add-override-access-true/javascript.input.d.ts.map +1 -0
- package/dist/transforms/add-override-access-true/javascript.input.js +24 -0
- package/dist/transforms/add-override-access-true/javascript.input.js.map +1 -0
- package/dist/transforms/add-override-access-true/javascript.output.d.ts +6 -0
- package/dist/transforms/add-override-access-true/javascript.output.d.ts.map +1 -0
- package/dist/transforms/add-override-access-true/javascript.output.js +26 -0
- package/dist/transforms/add-override-access-true/javascript.output.js.map +1 -0
- package/dist/transforms/add-override-access-true/non-matching.input.js +42 -0
- package/dist/transforms/add-override-access-true/non-matching.input.js.map +1 -0
- package/dist/transforms/add-override-access-true/non-matching.output.js +42 -0
- package/dist/transforms/add-override-access-true/non-matching.output.js.map +1 -0
- package/dist/transforms/add-override-access-true/single-line.input.js +13 -0
- package/dist/transforms/add-override-access-true/single-line.input.js.map +1 -0
- package/dist/transforms/add-override-access-true/single-line.output.js +17 -0
- package/dist/transforms/add-override-access-true/single-line.output.js.map +1 -0
- package/dist/transforms/add-override-access-true/trailing-comment.input.js +10 -0
- package/dist/transforms/add-override-access-true/trailing-comment.input.js.map +1 -0
- package/dist/transforms/add-override-access-true/trailing-comment.output.js +12 -0
- package/dist/transforms/add-override-access-true/trailing-comment.output.js.map +1 -0
- package/dist/transforms/migrate-admin-context-properties/basic.input.js +32 -0
- package/dist/transforms/migrate-admin-context-properties/basic.input.js.map +1 -0
- package/dist/transforms/migrate-admin-context-properties/basic.output.js +30 -0
- package/dist/transforms/migrate-admin-context-properties/basic.output.js.map +1 -0
- package/dist/transforms/migrate-admin-context-properties/index.d.ts +3 -0
- package/dist/transforms/migrate-admin-context-properties/index.d.ts.map +1 -0
- package/dist/transforms/migrate-admin-context-properties/index.js +302 -0
- package/dist/transforms/migrate-admin-context-properties/index.js.map +1 -0
- package/dist/transforms/migrate-admin-context-properties/no-match.input.js +30 -0
- package/dist/transforms/migrate-admin-context-properties/no-match.input.js.map +1 -0
- package/dist/transforms/migrate-admin-context-properties/no-match.output.js +30 -0
- package/dist/transforms/migrate-admin-context-properties/no-match.output.js.map +1 -0
- package/dist/transforms/migrate-aliased-exports/index.d.ts.map +1 -1
- package/dist/transforms/migrate-aliased-exports/index.js +6 -5
- package/dist/transforms/migrate-aliased-exports/index.js.map +1 -1
- package/dist/transforms/migrate-aliased-exports/request.input.js +6 -0
- package/dist/transforms/migrate-aliased-exports/request.input.js.map +1 -0
- package/dist/transforms/migrate-aliased-exports/request.output.js +5 -0
- package/dist/transforms/migrate-aliased-exports/request.output.js.map +1 -0
- package/dist/transforms/migrate-authorship-default/already-set.input.js +15 -0
- package/dist/transforms/migrate-authorship-default/already-set.input.js.map +1 -0
- package/dist/transforms/migrate-authorship-default/already-set.output.js +15 -0
- package/dist/transforms/migrate-authorship-default/already-set.output.js.map +1 -0
- package/dist/transforms/migrate-authorship-default/basic.input.js +16 -0
- package/dist/transforms/migrate-authorship-default/basic.input.js.map +1 -0
- package/dist/transforms/migrate-authorship-default/basic.output.js +18 -0
- package/dist/transforms/migrate-authorship-default/basic.output.js.map +1 -0
- package/dist/transforms/migrate-authorship-default/build-config.input.js +32 -0
- package/dist/transforms/migrate-authorship-default/build-config.input.js.map +1 -0
- package/dist/transforms/migrate-authorship-default/build-config.output.js +35 -0
- package/dist/transforms/migrate-authorship-default/build-config.output.js.map +1 -0
- package/dist/transforms/migrate-authorship-default/globals.input.js +16 -0
- package/dist/transforms/migrate-authorship-default/globals.input.js.map +1 -0
- package/dist/transforms/migrate-authorship-default/globals.output.js +17 -0
- package/dist/transforms/migrate-authorship-default/globals.output.js.map +1 -0
- package/dist/transforms/migrate-authorship-default/index.d.ts +11 -0
- package/dist/transforms/migrate-authorship-default/index.d.ts.map +1 -0
- package/dist/transforms/migrate-authorship-default/index.js +141 -0
- package/dist/transforms/migrate-authorship-default/index.js.map +1 -0
- package/dist/transforms/migrate-authorship-default/non-matching.input.js +18 -0
- package/dist/transforms/migrate-authorship-default/non-matching.input.js.map +1 -0
- package/dist/transforms/migrate-authorship-default/non-matching.output.js +18 -0
- package/dist/transforms/migrate-authorship-default/non-matching.output.js.map +1 -0
- package/dist/transforms/migrate-authorship-default/satisfies.input.js +11 -0
- package/dist/transforms/migrate-authorship-default/satisfies.input.js.map +1 -0
- package/dist/transforms/migrate-authorship-default/satisfies.output.js +13 -0
- package/dist/transforms/migrate-authorship-default/satisfies.output.js.map +1 -0
- package/dist/transforms/migrate-field-component-types/basic.input.js +8 -0
- package/dist/transforms/migrate-field-component-types/basic.input.js.map +1 -0
- package/dist/transforms/migrate-field-component-types/basic.output.js +8 -0
- package/dist/transforms/migrate-field-component-types/basic.output.js.map +1 -0
- package/dist/transforms/migrate-field-component-types/index.d.ts +3 -0
- package/dist/transforms/migrate-field-component-types/index.d.ts.map +1 -0
- package/dist/transforms/migrate-field-component-types/index.js +620 -0
- package/dist/transforms/migrate-field-component-types/index.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/aliases.input.js +8 -0
- package/dist/transforms/migrate-payload-request-creation/aliases.input.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/aliases.output.js +31 -0
- package/dist/transforms/migrate-payload-request-creation/aliases.output.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/collision.input.js +9 -0
- package/dist/transforms/migrate-payload-request-creation/collision.input.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/comments.input.js +9 -0
- package/dist/transforms/migrate-payload-request-creation/comments.input.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/comments.output.js +34 -0
- package/dist/transforms/migrate-payload-request-creation/comments.output.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/empty.input.js +5 -0
- package/dist/transforms/migrate-payload-request-creation/empty.input.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/empty.output.js +7 -0
- package/dist/transforms/migrate-payload-request-creation/empty.output.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/evaluation-order.input.js +10 -0
- package/dist/transforms/migrate-payload-request-creation/evaluation-order.input.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/expression.input.js +8 -0
- package/dist/transforms/migrate-payload-request-creation/expression.input.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/expression.output.js +8 -0
- package/dist/transforms/migrate-payload-request-creation/expression.output.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/getters.input.js +52 -0
- package/dist/transforms/migrate-payload-request-creation/getters.input.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/index.d.ts +3 -0
- package/dist/transforms/migrate-payload-request-creation/index.d.ts.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/index.js +236 -0
- package/dist/transforms/migrate-payload-request-creation/index.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/internal.input.js +6 -0
- package/dist/transforms/migrate-payload-request-creation/internal.input.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/internal.output.js +6 -0
- package/dist/transforms/migrate-payload-request-creation/internal.output.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/non-matching.input.js +5 -0
- package/dist/transforms/migrate-payload-request-creation/non-matching.input.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/populated.input.js +7 -0
- package/dist/transforms/migrate-payload-request-creation/populated.input.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/populated.output.js +30 -0
- package/dist/transforms/migrate-payload-request-creation/populated.output.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/shadowed.input.js +7 -0
- package/dist/transforms/migrate-payload-request-creation/shadowed.input.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/shadowed.output.js +9 -0
- package/dist/transforms/migrate-payload-request-creation/shadowed.output.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/shorthand.input.js +12 -0
- package/dist/transforms/migrate-payload-request-creation/shorthand.input.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/shorthand.output.js +12 -0
- package/dist/transforms/migrate-payload-request-creation/shorthand.output.js.map +1 -0
- package/dist/transforms/migrate-payload-request-creation/unsupported.input.js +9 -0
- package/dist/transforms/migrate-payload-request-creation/unsupported.input.js.map +1 -0
- package/dist/transforms/migrate-sharp-to-transformer/basic.input.js +28 -0
- package/dist/transforms/migrate-sharp-to-transformer/basic.input.js.map +1 -0
- package/dist/transforms/migrate-sharp-to-transformer/basic.output.js +39 -0
- package/dist/transforms/migrate-sharp-to-transformer/basic.output.js.map +1 -0
- package/dist/transforms/migrate-sharp-to-transformer/existing-transformers.input.js +27 -0
- package/dist/transforms/migrate-sharp-to-transformer/existing-transformers.input.js.map +1 -0
- package/dist/transforms/migrate-sharp-to-transformer/existing-transformers.output.js +33 -0
- package/dist/transforms/migrate-sharp-to-transformer/existing-transformers.output.js.map +1 -0
- package/dist/transforms/migrate-sharp-to-transformer/index.d.ts +3 -0
- package/dist/transforms/migrate-sharp-to-transformer/index.d.ts.map +1 -0
- package/dist/transforms/migrate-sharp-to-transformer/index.js +430 -0
- package/dist/transforms/migrate-sharp-to-transformer/index.js.map +1 -0
- package/dist/transforms/migrate-sharp-to-transformer/no-match.input.js +11 -0
- package/dist/transforms/migrate-sharp-to-transformer/no-match.input.js.map +1 -0
- package/dist/transforms/migrate-sharp-to-transformer/no-match.output.js +11 -0
- package/dist/transforms/migrate-sharp-to-transformer/no-match.output.js.map +1 -0
- package/dist/transforms/migrate-versions-default/index.js +5 -5
- package/dist/transforms/migrate-versions-default/index.js.map +1 -1
- package/dist/transforms/remove-default-locale-publish-option/all-value.input.js +13 -0
- package/dist/transforms/remove-default-locale-publish-option/all-value.input.js.map +1 -0
- package/dist/transforms/remove-default-locale-publish-option/basic.input.js +13 -0
- package/dist/transforms/remove-default-locale-publish-option/basic.input.js.map +1 -0
- package/dist/transforms/remove-default-locale-publish-option/basic.output.js +12 -0
- package/dist/transforms/remove-default-locale-publish-option/basic.output.js.map +1 -0
- package/dist/transforms/remove-default-locale-publish-option/dynamic.input.js +17 -0
- package/dist/transforms/remove-default-locale-publish-option/dynamic.input.js.map +1 -0
- package/dist/transforms/remove-default-locale-publish-option/index.d.ts +10 -0
- package/dist/transforms/remove-default-locale-publish-option/index.d.ts.map +1 -0
- package/dist/transforms/remove-default-locale-publish-option/index.js +103 -0
- package/dist/transforms/remove-default-locale-publish-option/index.js.map +1 -0
- package/dist/transforms/remove-default-locale-publish-option/no-match.input.js +10 -0
- package/dist/transforms/remove-default-locale-publish-option/no-match.input.js.map +1 -0
- package/dist/transforms/remove-default-locale-publish-option/no-match.output.js +10 -0
- package/dist/transforms/remove-default-locale-publish-option/no-match.output.js.map +1 -0
- package/dist/transforms/remove-default-locale-publish-option/reassigned.input.js +22 -0
- package/dist/transforms/remove-default-locale-publish-option/reassigned.input.js.map +1 -0
- package/dist/transforms/remove-default-locale-publish-option/shorthand.input.js +14 -0
- package/dist/transforms/remove-default-locale-publish-option/shorthand.input.js.map +1 -0
- package/dist/transforms/remove-default-locale-publish-option/shorthand.output.js +13 -0
- package/dist/transforms/remove-default-locale-publish-option/shorthand.output.js.map +1 -0
- package/dist/transforms/remove-publish-specific-locale/index.d.ts.map +1 -1
- package/dist/transforms/remove-publish-specific-locale/index.js.map +1 -1
- package/dist/transforms/remove-storage-always-insert-fields/aliased.input.js +11 -0
- package/dist/transforms/remove-storage-always-insert-fields/aliased.input.js.map +1 -0
- package/dist/transforms/remove-storage-always-insert-fields/aliased.output.js +10 -0
- package/dist/transforms/remove-storage-always-insert-fields/aliased.output.js.map +1 -0
- package/dist/transforms/remove-storage-always-insert-fields/basic.input.js +54 -0
- package/dist/transforms/remove-storage-always-insert-fields/basic.input.js.map +1 -0
- package/dist/transforms/remove-storage-always-insert-fields/basic.output.js +48 -0
- package/dist/transforms/remove-storage-always-insert-fields/basic.output.js.map +1 -0
- package/dist/transforms/remove-storage-always-insert-fields/index.d.ts +3 -0
- package/dist/transforms/remove-storage-always-insert-fields/index.d.ts.map +1 -0
- package/dist/transforms/remove-storage-always-insert-fields/index.js +75 -0
- package/dist/transforms/remove-storage-always-insert-fields/index.js.map +1 -0
- package/dist/transforms/remove-storage-always-insert-fields/no-match.input.js +27 -0
- package/dist/transforms/remove-storage-always-insert-fields/no-match.input.js.map +1 -0
- package/dist/transforms/remove-storage-always-insert-fields/no-match.output.js +27 -0
- package/dist/transforms/remove-storage-always-insert-fields/no-match.output.js.map +1 -0
- package/dist/transforms/remove-versions-true/index.js +4 -4
- package/dist/transforms/remove-versions-true/index.js.map +1 -1
- package/dist/transforms/rename-diff-value-props/basic.input.js +38 -0
- package/dist/transforms/rename-diff-value-props/basic.input.js.map +1 -0
- package/dist/transforms/rename-diff-value-props/basic.output.js +38 -0
- package/dist/transforms/rename-diff-value-props/basic.output.js.map +1 -0
- package/dist/transforms/rename-diff-value-props/index.d.ts +3 -0
- package/dist/transforms/rename-diff-value-props/index.d.ts.map +1 -0
- package/dist/transforms/rename-diff-value-props/index.js +328 -0
- package/dist/transforms/rename-diff-value-props/index.js.map +1 -0
- package/dist/transforms/rename-diff-value-props/no-match.input.js +8 -0
- package/dist/transforms/rename-diff-value-props/no-match.input.js.map +1 -0
- package/dist/transforms/rename-experimental-table-feature/alias.input.js +6 -0
- package/dist/transforms/rename-experimental-table-feature/alias.input.js.map +1 -0
- package/dist/transforms/rename-experimental-table-feature/alias.output.js +6 -0
- package/dist/transforms/rename-experimental-table-feature/alias.output.js.map +1 -0
- package/dist/transforms/rename-experimental-table-feature/basic.input.js +19 -0
- package/dist/transforms/rename-experimental-table-feature/basic.input.js.map +1 -0
- package/dist/transforms/rename-experimental-table-feature/basic.output.js +19 -0
- package/dist/transforms/rename-experimental-table-feature/basic.output.js.map +1 -0
- package/dist/transforms/rename-experimental-table-feature/collision.input.js +7 -0
- package/dist/transforms/rename-experimental-table-feature/collision.input.js.map +1 -0
- package/dist/transforms/rename-experimental-table-feature/index.d.ts +3 -0
- package/dist/transforms/rename-experimental-table-feature/index.d.ts.map +1 -0
- package/dist/transforms/rename-experimental-table-feature/index.js +50 -0
- package/dist/transforms/rename-experimental-table-feature/index.js.map +1 -0
- package/dist/transforms/rename-experimental-table-feature/no-match.input.js +9 -0
- package/dist/transforms/rename-experimental-table-feature/no-match.input.js.map +1 -0
- package/dist/upgrade/defaultTag.d.ts +9 -0
- package/dist/upgrade/defaultTag.d.ts.map +1 -0
- package/dist/upgrade/defaultTag.js +25 -0
- package/dist/upgrade/defaultTag.js.map +1 -0
- package/dist/upgrade/detectPackageManager.d.ts +8 -0
- package/dist/upgrade/detectPackageManager.d.ts.map +1 -0
- package/dist/upgrade/detectPackageManager.js +38 -0
- package/dist/upgrade/detectPackageManager.js.map +1 -0
- package/dist/upgrade/dispatch.d.ts +38 -0
- package/dist/upgrade/dispatch.d.ts.map +1 -0
- package/dist/upgrade/dispatch.js +132 -0
- package/dist/upgrade/dispatch.js.map +1 -0
- package/dist/upgrade/index.d.ts +25 -0
- package/dist/upgrade/index.d.ts.map +1 -0
- package/dist/upgrade/index.js +209 -0
- package/dist/upgrade/index.js.map +1 -0
- package/dist/upgrade/prompt.d.ts +14 -0
- package/dist/upgrade/prompt.d.ts.map +1 -0
- package/dist/upgrade/prompt.js +77 -0
- package/dist/upgrade/prompt.js.map +1 -0
- package/dist/upgrade/report.d.ts +21 -0
- package/dist/upgrade/report.d.ts.map +1 -0
- package/dist/upgrade/report.js +47 -0
- package/dist/upgrade/report.js.map +1 -0
- package/dist/upgrade/resolveVersions.d.ts +13 -0
- package/dist/upgrade/resolveVersions.d.ts.map +1 -0
- package/dist/upgrade/resolveVersions.js +55 -0
- package/dist/upgrade/resolveVersions.js.map +1 -0
- package/dist/upgrade/rewritePackageJson.d.ts +32 -0
- package/dist/upgrade/rewritePackageJson.d.ts.map +1 -0
- package/dist/upgrade/rewritePackageJson.js +164 -0
- package/dist/upgrade/rewritePackageJson.js.map +1 -0
- package/dist/upgrade/runInstall.d.ts +16 -0
- package/dist/upgrade/runInstall.d.ts.map +1 -0
- package/dist/upgrade/runInstall.js +17 -0
- package/dist/upgrade/runInstall.js.map +1 -0
- package/dist/upgrade/selectAgent.d.ts +45 -0
- package/dist/upgrade/selectAgent.d.ts.map +1 -0
- package/dist/upgrade/selectAgent.js +54 -0
- package/dist/upgrade/selectAgent.js.map +1 -0
- package/dist/upgrade/selfCommand.d.ts +13 -0
- package/dist/upgrade/selfCommand.d.ts.map +1 -0
- package/dist/upgrade/selfCommand.js +17 -0
- package/dist/upgrade/selfCommand.js.map +1 -0
- package/dist/upgrade/types.d.ts +47 -0
- package/dist/upgrade/types.d.ts.map +1 -0
- package/dist/upgrade/types.js +11 -0
- package/dist/upgrade/types.js.map +1 -0
- package/dist/utils/project.d.ts +10 -0
- package/dist/utils/project.d.ts.map +1 -0
- package/dist/utils/project.js +43 -0
- package/dist/utils/project.js.map +1 -0
- package/package.json +9 -5
- package/dist/cli.parseFlags.spec.d.ts +0 -2
- package/dist/cli.parseFlags.spec.d.ts.map +0 -1
- package/dist/cli.parseFlags.spec.js +0 -49
- package/dist/cli.parseFlags.spec.js.map +0 -1
- package/dist/runner.spec.d.ts +0 -2
- package/dist/runner.spec.d.ts.map +0 -1
- package/dist/runner.spec.js +0 -88
- package/dist/runner.spec.js.map +0 -1
- package/dist/transforms/example-noop/index.spec.d.ts +0 -2
- package/dist/transforms/example-noop/index.spec.d.ts.map +0 -1
- package/dist/transforms/example-noop/index.spec.js +0 -29
- package/dist/transforms/example-noop/index.spec.js.map +0 -1
- package/dist/transforms/globals-components-edit/index.spec.d.ts +0 -2
- package/dist/transforms/globals-components-edit/index.spec.d.ts.map +0 -1
- package/dist/transforms/globals-components-edit/index.spec.js +0 -37
- package/dist/transforms/globals-components-edit/index.spec.js.map +0 -1
- package/dist/transforms/migrate-after-operation-read/index.spec.d.ts +0 -2
- package/dist/transforms/migrate-after-operation-read/index.spec.d.ts.map +0 -1
- package/dist/transforms/migrate-after-operation-read/index.spec.js +0 -62
- package/dist/transforms/migrate-after-operation-read/index.spec.js.map +0 -1
- package/dist/transforms/migrate-aliased-exports/index.spec.d.ts +0 -2
- package/dist/transforms/migrate-aliased-exports/index.spec.d.ts.map +0 -1
- package/dist/transforms/migrate-aliased-exports/index.spec.js +0 -55
- package/dist/transforms/migrate-aliased-exports/index.spec.js.map +0 -1
- package/dist/transforms/migrate-azure-chunk-large-files/index.spec.d.ts +0 -2
- package/dist/transforms/migrate-azure-chunk-large-files/index.spec.d.ts.map +0 -1
- package/dist/transforms/migrate-azure-chunk-large-files/index.spec.js +0 -67
- package/dist/transforms/migrate-azure-chunk-large-files/index.spec.js.map +0 -1
- package/dist/transforms/migrate-block-references-to-blocks/index.spec.d.ts +0 -2
- package/dist/transforms/migrate-block-references-to-blocks/index.spec.d.ts.map +0 -1
- package/dist/transforms/migrate-block-references-to-blocks/index.spec.js +0 -45
- package/dist/transforms/migrate-block-references-to-blocks/index.spec.js.map +0 -1
- package/dist/transforms/migrate-build-script/index.spec.d.ts +0 -2
- package/dist/transforms/migrate-build-script/index.spec.d.ts.map +0 -1
- package/dist/transforms/migrate-build-script/index.spec.js +0 -81
- package/dist/transforms/migrate-build-script/index.spec.js.map +0 -1
- package/dist/transforms/migrate-db-types-subpath/index.spec.d.ts +0 -2
- package/dist/transforms/migrate-db-types-subpath/index.spec.d.ts.map +0 -1
- package/dist/transforms/migrate-db-types-subpath/index.spec.js +0 -46
- package/dist/transforms/migrate-db-types-subpath/index.spec.js.map +0 -1
- package/dist/transforms/migrate-disabled-fields/index.spec.d.ts +0 -2
- package/dist/transforms/migrate-disabled-fields/index.spec.d.ts.map +0 -1
- package/dist/transforms/migrate-disabled-fields/index.spec.js +0 -73
- package/dist/transforms/migrate-disabled-fields/index.spec.js.map +0 -1
- package/dist/transforms/migrate-document-title-context/index.spec.d.ts +0 -2
- package/dist/transforms/migrate-document-title-context/index.spec.d.ts.map +0 -1
- package/dist/transforms/migrate-document-title-context/index.spec.js +0 -86
- package/dist/transforms/migrate-document-title-context/index.spec.js.map +0 -1
- package/dist/transforms/migrate-force-select/index.spec.d.ts +0 -2
- package/dist/transforms/migrate-force-select/index.spec.d.ts.map +0 -1
- package/dist/transforms/migrate-force-select/index.spec.js +0 -107
- package/dist/transforms/migrate-force-select/index.spec.js.map +0 -1
- package/dist/transforms/migrate-hide-api-url/index.spec.d.ts +0 -2
- package/dist/transforms/migrate-hide-api-url/index.spec.d.ts.map +0 -1
- package/dist/transforms/migrate-hide-api-url/index.spec.js +0 -118
- package/dist/transforms/migrate-hide-api-url/index.spec.js.map +0 -1
- package/dist/transforms/migrate-import-export-hooks/index.spec.d.ts +0 -2
- package/dist/transforms/migrate-import-export-hooks/index.spec.d.ts.map +0 -1
- package/dist/transforms/migrate-import-export-hooks/index.spec.js +0 -65
- package/dist/transforms/migrate-import-export-hooks/index.spec.js.map +0 -1
- package/dist/transforms/migrate-list-view-select-api/index.spec.d.ts +0 -2
- package/dist/transforms/migrate-list-view-select-api/index.spec.d.ts.map +0 -1
- package/dist/transforms/migrate-list-view-select-api/index.spec.js +0 -37
- package/dist/transforms/migrate-list-view-select-api/index.spec.js.map +0 -1
- package/dist/transforms/migrate-next-generate-viewport-export/index.spec.d.ts +0 -2
- package/dist/transforms/migrate-next-generate-viewport-export/index.spec.d.ts.map +0 -1
- package/dist/transforms/migrate-next-generate-viewport-export/index.spec.js +0 -41
- package/dist/transforms/migrate-next-generate-viewport-export/index.spec.js.map +0 -1
- package/dist/transforms/migrate-next-subpath-exports/index.spec.d.ts +0 -2
- package/dist/transforms/migrate-next-subpath-exports/index.spec.d.ts.map +0 -1
- package/dist/transforms/migrate-next-subpath-exports/index.spec.js +0 -46
- package/dist/transforms/migrate-next-subpath-exports/index.spec.js.map +0 -1
- package/dist/transforms/migrate-slug-field/index.spec.d.ts +0 -2
- package/dist/transforms/migrate-slug-field/index.spec.d.ts.map +0 -1
- package/dist/transforms/migrate-slug-field/index.spec.js +0 -47
- package/dist/transforms/migrate-slug-field/index.spec.js.map +0 -1
- package/dist/transforms/migrate-storage-adapters-to-config/index.spec.d.ts +0 -2
- package/dist/transforms/migrate-storage-adapters-to-config/index.spec.d.ts.map +0 -1
- package/dist/transforms/migrate-storage-adapters-to-config/index.spec.js +0 -85
- package/dist/transforms/migrate-storage-adapters-to-config/index.spec.js.map +0 -1
- package/dist/transforms/migrate-versions-default/index.spec.d.ts +0 -2
- package/dist/transforms/migrate-versions-default/index.spec.d.ts.map +0 -1
- package/dist/transforms/migrate-versions-default/index.spec.js +0 -81
- package/dist/transforms/migrate-versions-default/index.spec.js.map +0 -1
- package/dist/transforms/remove-group-by-true/index.spec.d.ts +0 -2
- package/dist/transforms/remove-group-by-true/index.spec.d.ts.map +0 -1
- package/dist/transforms/remove-group-by-true/index.spec.js +0 -47
- package/dist/transforms/remove-group-by-true/index.spec.js.map +0 -1
- package/dist/transforms/remove-localize-status-config/index.spec.d.ts +0 -2
- package/dist/transforms/remove-localize-status-config/index.spec.d.ts.map +0 -1
- package/dist/transforms/remove-localize-status-config/index.spec.js +0 -38
- package/dist/transforms/remove-localize-status-config/index.spec.js.map +0 -1
- package/dist/transforms/remove-publish-specific-locale/index.spec.d.ts +0 -2
- package/dist/transforms/remove-publish-specific-locale/index.spec.d.ts.map +0 -1
- package/dist/transforms/remove-publish-specific-locale/index.spec.js +0 -47
- package/dist/transforms/remove-publish-specific-locale/index.spec.js.map +0 -1
- package/dist/transforms/remove-versions-true/index.spec.d.ts +0 -2
- package/dist/transforms/remove-versions-true/index.spec.d.ts.map +0 -1
- package/dist/transforms/remove-versions-true/index.spec.js +0 -38
- package/dist/transforms/remove-versions-true/index.spec.js.map +0 -1
- package/dist/transforms/rename-storage-adapters-to-storage/index.spec.d.ts +0 -2
- package/dist/transforms/rename-storage-adapters-to-storage/index.spec.d.ts.map +0 -1
- package/dist/transforms/rename-storage-adapters-to-storage/index.spec.js +0 -55
- package/dist/transforms/rename-storage-adapters-to-storage/index.spec.js.map +0 -1
- package/dist/transforms/rename-typescript-schema-to-json-schema/index.spec.d.ts +0 -2
- package/dist/transforms/rename-typescript-schema-to-json-schema/index.spec.d.ts.map +0 -1
- package/dist/transforms/rename-typescript-schema-to-json-schema/index.spec.js +0 -45
- package/dist/transforms/rename-typescript-schema-to-json-schema/index.spec.js.map +0 -1
- package/dist/utils/packageJson.spec.d.ts +0 -2
- package/dist/utils/packageJson.spec.d.ts.map +0 -1
- package/dist/utils/packageJson.spec.js +0 -41
- package/dist/utils/packageJson.spec.js.map +0 -1
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { s3Storage as payloadS3Storage } from '@payloadcms/storage-s3';
|
|
2
|
+
const options = {
|
|
3
|
+
alwaysInsertFields: true,
|
|
4
|
+
bucket: 'media',
|
|
5
|
+
collections: {
|
|
6
|
+
media: true
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
const s3Storage = (value)=>value;
|
|
10
|
+
export const indirectStorage = payloadS3Storage(options);
|
|
11
|
+
export const unrelatedStorage = s3Storage({
|
|
12
|
+
alwaysInsertFields: true,
|
|
13
|
+
bucket: 'media',
|
|
14
|
+
collections: {
|
|
15
|
+
media: true
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
export const spreadBeforeProperty = payloadS3Storage({
|
|
19
|
+
...options,
|
|
20
|
+
alwaysInsertFields: false
|
|
21
|
+
});
|
|
22
|
+
export const spreadAfterProperty = payloadS3Storage({
|
|
23
|
+
alwaysInsertFields: false,
|
|
24
|
+
...options
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=no-match.output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/transforms/remove-storage-always-insert-fields/no-match.output.ts"],"sourcesContent":["import { s3Storage as payloadS3Storage } from '@payloadcms/storage-s3'\n\nconst options = {\n alwaysInsertFields: true,\n bucket: 'media',\n collections: { media: true },\n}\n\nconst s3Storage = (value: typeof options) => value\n\nexport const indirectStorage = payloadS3Storage(options)\nexport const unrelatedStorage = s3Storage({\n alwaysInsertFields: true,\n bucket: 'media',\n collections: { media: true },\n})\nexport const spreadBeforeProperty = payloadS3Storage({\n ...options,\n alwaysInsertFields: false,\n})\nexport const spreadAfterProperty = payloadS3Storage({\n alwaysInsertFields: false,\n ...options,\n})\n"],"names":["s3Storage","payloadS3Storage","options","alwaysInsertFields","bucket","collections","media","value","indirectStorage","unrelatedStorage","spreadBeforeProperty","spreadAfterProperty"],"mappings":"AAAA,SAASA,aAAaC,gBAAgB,QAAQ,yBAAwB;AAEtE,MAAMC,UAAU;IACdC,oBAAoB;IACpBC,QAAQ;IACRC,aAAa;QAAEC,OAAO;IAAK;AAC7B;AAEA,MAAMN,YAAY,CAACO,QAA0BA;AAE7C,OAAO,MAAMC,kBAAkBP,iBAAiBC,SAAQ;AACxD,OAAO,MAAMO,mBAAmBT,UAAU;IACxCG,oBAAoB;IACpBC,QAAQ;IACRC,aAAa;QAAEC,OAAO;IAAK;AAC7B,GAAE;AACF,OAAO,MAAMI,uBAAuBT,iBAAiB;IACnD,GAAGC,OAAO;IACVC,oBAAoB;AACtB,GAAE;AACF,OAAO,MAAMQ,sBAAsBV,iBAAiB;IAClDE,oBAAoB;IACpB,GAAGD,OAAO;AACZ,GAAE"}
|
|
@@ -71,13 +71,13 @@ const isVersionedConfigTypeName = (typeText)=>{
|
|
|
71
71
|
return undefined;
|
|
72
72
|
}
|
|
73
73
|
// Form 2: { ... } satisfies CollectionConfig
|
|
74
|
-
if (
|
|
75
|
-
const typeNode = node.getTypeNode
|
|
74
|
+
if (Node.isSatisfiesExpression(node)) {
|
|
75
|
+
const typeNode = node.getTypeNode();
|
|
76
76
|
if (!typeNode || !isVersionedConfigTypeName(typeNode.getText().trim())) {
|
|
77
77
|
return undefined;
|
|
78
78
|
}
|
|
79
|
-
const expr = node.getExpression
|
|
80
|
-
if (
|
|
79
|
+
const expr = node.getExpression();
|
|
80
|
+
if (Node.isObjectLiteralExpression(expr)) {
|
|
81
81
|
return expr;
|
|
82
82
|
}
|
|
83
83
|
return undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/transforms/remove-versions-true/index.ts"],"sourcesContent":["import { Node, SyntaxKind } from 'ts-morph'\n\nimport type { Transform } from '../../types.js'\n\nconst VERSIONED_CONFIG_TYPE_NAMES = new Set([\n 'CollectionConfig',\n 'GlobalConfig',\n 'SanitizedCollectionConfig',\n 'SanitizedGlobalConfig',\n])\n\nconst isVersionedConfigTypeName = (typeText: string): boolean => {\n const baseName = typeText.replace(/<.*>$/, '').trim()\n return VERSIONED_CONFIG_TYPE_NAMES.has(baseName)\n}\n\n/**\n * Removes `versions: true` (bare boolean true — not an object) from\n * CollectionConfig and GlobalConfig objects. Now that versions defaults to\n * true, the explicit property is redundant.\n *\n * Only removes the property when the initializer is exactly the `true` keyword.\n * Object-form versions configs (e.g. `versions: { drafts: true }`) are left\n * untouched.\n */\nexport const removeVersionsTrue: Transform = {\n name: 'remove-versions-true',\n apply: ({ project }) => {\n const filesChanged = new Set<string>()\n\n for (const sourceFile of project.getSourceFiles()) {\n let mutated = false\n\n sourceFile.forEachDescendant((node) => {\n const objectLiteral = resolveVersionedConfigObject(node)\n if (!objectLiteral) {\n return\n }\n\n const versionsProp = objectLiteral.getProperty('versions')\n if (!versionsProp || !Node.isPropertyAssignment(versionsProp)) {\n return\n }\n\n const initializer = versionsProp.getInitializer()\n if (!initializer || initializer.getKind() !== SyntaxKind.TrueKeyword) {\n return\n }\n\n versionsProp.remove()\n mutated = true\n })\n\n if (mutated) {\n filesChanged.add(sourceFile.getFilePath())\n }\n }\n\n return { filesChanged: [...filesChanged] }\n },\n description:\n 'Remove redundant `versions: true` from CollectionConfig and GlobalConfig objects. Versions are now enabled by default so the explicit boolean true is no longer needed.',\n}\n\n/**\n * Given a node, returns its ObjectLiteralExpression if the node represents a\n * CollectionConfig- or GlobalConfig-typed value in one of the three recognised forms.\n */\nconst resolveVersionedConfigObject = (node: Node) => {\n // Form 1: const X: CollectionConfig = { ... }\n if (Node.isVariableDeclaration(node)) {\n const typeNode = node.getTypeNode()\n if (!typeNode) {\n return undefined\n }\n if (!isVersionedConfigTypeName(typeNode.getText().trim())) {\n return undefined\n }\n const initializer = node.getInitializer()\n if (initializer && Node.isObjectLiteralExpression(initializer)) {\n return initializer\n }\n return undefined\n }\n\n // Form 2: { ... } satisfies CollectionConfig\n if (
|
|
1
|
+
{"version":3,"sources":["../../../src/transforms/remove-versions-true/index.ts"],"sourcesContent":["import { Node, SyntaxKind } from 'ts-morph'\n\nimport type { Transform } from '../../types.js'\n\nconst VERSIONED_CONFIG_TYPE_NAMES = new Set([\n 'CollectionConfig',\n 'GlobalConfig',\n 'SanitizedCollectionConfig',\n 'SanitizedGlobalConfig',\n])\n\nconst isVersionedConfigTypeName = (typeText: string): boolean => {\n const baseName = typeText.replace(/<.*>$/, '').trim()\n return VERSIONED_CONFIG_TYPE_NAMES.has(baseName)\n}\n\n/**\n * Removes `versions: true` (bare boolean true — not an object) from\n * CollectionConfig and GlobalConfig objects. Now that versions defaults to\n * true, the explicit property is redundant.\n *\n * Only removes the property when the initializer is exactly the `true` keyword.\n * Object-form versions configs (e.g. `versions: { drafts: true }`) are left\n * untouched.\n */\nexport const removeVersionsTrue: Transform = {\n name: 'remove-versions-true',\n apply: ({ project }) => {\n const filesChanged = new Set<string>()\n\n for (const sourceFile of project.getSourceFiles()) {\n let mutated = false\n\n sourceFile.forEachDescendant((node) => {\n const objectLiteral = resolveVersionedConfigObject(node)\n if (!objectLiteral) {\n return\n }\n\n const versionsProp = objectLiteral.getProperty('versions')\n if (!versionsProp || !Node.isPropertyAssignment(versionsProp)) {\n return\n }\n\n const initializer = versionsProp.getInitializer()\n if (!initializer || initializer.getKind() !== SyntaxKind.TrueKeyword) {\n return\n }\n\n versionsProp.remove()\n mutated = true\n })\n\n if (mutated) {\n filesChanged.add(sourceFile.getFilePath())\n }\n }\n\n return { filesChanged: [...filesChanged] }\n },\n description:\n 'Remove redundant `versions: true` from CollectionConfig and GlobalConfig objects. Versions are now enabled by default so the explicit boolean true is no longer needed.',\n}\n\n/**\n * Given a node, returns its ObjectLiteralExpression if the node represents a\n * CollectionConfig- or GlobalConfig-typed value in one of the three recognised forms.\n */\nconst resolveVersionedConfigObject = (node: Node) => {\n // Form 1: const X: CollectionConfig = { ... }\n if (Node.isVariableDeclaration(node)) {\n const typeNode = node.getTypeNode()\n if (!typeNode) {\n return undefined\n }\n if (!isVersionedConfigTypeName(typeNode.getText().trim())) {\n return undefined\n }\n const initializer = node.getInitializer()\n if (initializer && Node.isObjectLiteralExpression(initializer)) {\n return initializer\n }\n return undefined\n }\n\n // Form 2: { ... } satisfies CollectionConfig\n if (Node.isSatisfiesExpression(node)) {\n const typeNode = node.getTypeNode()\n if (!typeNode || !isVersionedConfigTypeName(typeNode.getText().trim())) {\n return undefined\n }\n const expr = node.getExpression()\n if (Node.isObjectLiteralExpression(expr)) {\n return expr\n }\n return undefined\n }\n\n // Form 3: { ... } as CollectionConfig\n if (Node.isAsExpression(node)) {\n const typeNode = node.getTypeNode()\n if (!typeNode || !isVersionedConfigTypeName(typeNode.getText().trim())) {\n return undefined\n }\n const expr = node.getExpression()\n if (Node.isObjectLiteralExpression(expr)) {\n return expr\n }\n return undefined\n }\n\n return undefined\n}\n"],"names":["Node","SyntaxKind","VERSIONED_CONFIG_TYPE_NAMES","Set","isVersionedConfigTypeName","typeText","baseName","replace","trim","has","removeVersionsTrue","name","apply","project","filesChanged","sourceFile","getSourceFiles","mutated","forEachDescendant","node","objectLiteral","resolveVersionedConfigObject","versionsProp","getProperty","isPropertyAssignment","initializer","getInitializer","getKind","TrueKeyword","remove","add","getFilePath","description","isVariableDeclaration","typeNode","getTypeNode","undefined","getText","isObjectLiteralExpression","isSatisfiesExpression","expr","getExpression","isAsExpression"],"mappings":"AAAA,SAASA,IAAI,EAAEC,UAAU,QAAQ,WAAU;AAI3C,MAAMC,8BAA8B,IAAIC,IAAI;IAC1C;IACA;IACA;IACA;CACD;AAED,MAAMC,4BAA4B,CAACC;IACjC,MAAMC,WAAWD,SAASE,OAAO,CAAC,SAAS,IAAIC,IAAI;IACnD,OAAON,4BAA4BO,GAAG,CAACH;AACzC;AAEA;;;;;;;;CAQC,GACD,OAAO,MAAMI,qBAAgC;IAC3CC,MAAM;IACNC,OAAO,CAAC,EAAEC,OAAO,EAAE;QACjB,MAAMC,eAAe,IAAIX;QAEzB,KAAK,MAAMY,cAAcF,QAAQG,cAAc,GAAI;YACjD,IAAIC,UAAU;YAEdF,WAAWG,iBAAiB,CAAC,CAAC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OAAO;QAC7B,MAAMe,WAAWf,KAAKgB,WAAW;QACjC,IAAI,CAACD,YAAY,CAAC9B,0BAA0B8B,SAASG,OAAO,GAAG7B,IAAI,KAAK;YACtE,OAAO4B;QACT;QACA,MAAMI,OAAOrB,KAAKsB,aAAa;QAC/B,IAAIzC,KAAKsC,yBAAyB,CAACE,OAAO;YACxC,OAAOA;QACT;QACA,OAAOJ;IACT;IAEA,OAAOA;AACT"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export const Destructured = ({ comparisonValue, field, versionValue })=>{
|
|
2
|
+
const hasChanged = comparisonValue !== versionValue;
|
|
3
|
+
return hasChanged ? `${String(comparisonValue)} -> ${String(versionValue)}` : field.name;
|
|
4
|
+
};
|
|
5
|
+
export const LegacyComponentType = ({ comparisonValue, versionValue = '' })=>`${String(comparisonValue)} -> ${String(versionValue)}`;
|
|
6
|
+
export const Aliased = ({ comparisonValue: before, versionValue: valueTo })=>[
|
|
7
|
+
before,
|
|
8
|
+
valueTo
|
|
9
|
+
];
|
|
10
|
+
export default async function PropsObject(props) {
|
|
11
|
+
const { comparisonValue, req } = props;
|
|
12
|
+
return [
|
|
13
|
+
comparisonValue,
|
|
14
|
+
props.versionValue,
|
|
15
|
+
props['comparisonValue'],
|
|
16
|
+
req.locale
|
|
17
|
+
];
|
|
18
|
+
}
|
|
19
|
+
export function LocalPropsType({ label, versionValue }) {
|
|
20
|
+
return [
|
|
21
|
+
label,
|
|
22
|
+
versionValue
|
|
23
|
+
];
|
|
24
|
+
}
|
|
25
|
+
export const RestProps = ({ field, ...rest })=>[
|
|
26
|
+
field,
|
|
27
|
+
rest.comparisonValue
|
|
28
|
+
];
|
|
29
|
+
export const NameCollision = ({ comparisonValue })=>{
|
|
30
|
+
const valueFrom = 'unrelated';
|
|
31
|
+
return [
|
|
32
|
+
comparisonValue,
|
|
33
|
+
valueFrom
|
|
34
|
+
];
|
|
35
|
+
};
|
|
36
|
+
export const formatValue = (value)=>String(value);
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=basic.input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/transforms/rename-diff-value-props/basic.input.ts"],"sourcesContent":["import type {\n FieldDiffServerProps,\n TextFieldDiffClientComponent,\n TextFieldDiffClientProps,\n TextFieldDiffServerProps,\n} from 'payload'\nimport type React from 'react'\n\nexport const Destructured: React.FC<TextFieldDiffClientProps> = ({\n comparisonValue,\n field,\n versionValue,\n}) => {\n const hasChanged = comparisonValue !== versionValue\n return hasChanged ? `${String(comparisonValue)} -> ${String(versionValue)}` : field.name\n}\n\nexport const LegacyComponentType: TextFieldDiffClientComponent = ({\n comparisonValue,\n versionValue = '',\n}) => `${String(comparisonValue)} -> ${String(versionValue)}`\n\nexport const Aliased = ({\n comparisonValue: before,\n versionValue: valueTo,\n}: TextFieldDiffClientProps) => [before, valueTo]\n\nexport default async function PropsObject(props: TextFieldDiffServerProps) {\n const { comparisonValue, req } = props\n return [comparisonValue, props.versionValue, props['comparisonValue'], req.locale]\n}\n\ntype PropsWithLabel = { label: string } & TextFieldDiffClientProps\n\nexport function LocalPropsType({ label, versionValue }: PropsWithLabel) {\n return [label, versionValue]\n}\n\nexport const RestProps = ({ field, ...rest }: FieldDiffServerProps) => [field, rest.comparisonValue]\n\nexport const NameCollision = ({ comparisonValue }: TextFieldDiffClientProps) => {\n const valueFrom = 'unrelated'\n return [comparisonValue, valueFrom]\n}\n\nexport const formatValue = (value: TextFieldDiffClientProps['versionValue']) => String(value)\n"],"names":["Destructured","comparisonValue","field","versionValue","hasChanged","String","name","LegacyComponentType","Aliased","before","valueTo","PropsObject","props","req","locale","LocalPropsType","label","RestProps","rest","NameCollision","valueFrom","formatValue","value"],"mappings":"AAQA,OAAO,MAAMA,eAAmD,CAAC,EAC/DC,eAAe,EACfC,KAAK,EACLC,YAAY,EACb;IACC,MAAMC,aAAaH,oBAAoBE;IACvC,OAAOC,aAAa,GAAGC,OAAOJ,iBAAiB,IAAI,EAAEI,OAAOF,eAAe,GAAGD,MAAMI,IAAI;AAC1F,EAAC;AAED,OAAO,MAAMC,sBAAoD,CAAC,EAChEN,eAAe,EACfE,eAAe,EAAE,EAClB,GAAK,GAAGE,OAAOJ,iBAAiB,IAAI,EAAEI,OAAOF,eAAe,CAAA;AAE7D,OAAO,MAAMK,UAAU,CAAC,EACtBP,iBAAiBQ,MAAM,EACvBN,cAAcO,OAAO,EACI,GAAK;QAACD;QAAQC;KAAQ,CAAA;AAEjD,eAAe,eAAeC,YAAYC,KAA+B;IACvE,MAAM,EAAEX,eAAe,EAAEY,GAAG,EAAE,GAAGD;IACjC,OAAO;QAACX;QAAiBW,MAAMT,YAAY;QAAES,KAAK,CAAC,kBAAkB;QAAEC,IAAIC,MAAM;KAAC;AACpF;AAIA,OAAO,SAASC,eAAe,EAAEC,KAAK,EAAEb,YAAY,EAAkB;IACpE,OAAO;QAACa;QAAOb;KAAa;AAC9B;AAEA,OAAO,MAAMc,YAAY,CAAC,EAAEf,KAAK,EAAE,GAAGgB,MAA4B,GAAK;QAAChB;QAAOgB,KAAKjB,eAAe;KAAC,CAAA;AAEpG,OAAO,MAAMkB,gBAAgB,CAAC,EAAElB,eAAe,EAA4B;IACzE,MAAMmB,YAAY;IAClB,OAAO;QAACnB;QAAiBmB;KAAU;AACrC,EAAC;AAED,OAAO,MAAMC,cAAc,CAACC,QAAoDjB,OAAOiB,OAAM"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export const Destructured = ({ valueFrom, field, valueTo })=>{
|
|
2
|
+
const hasChanged = valueFrom !== valueTo;
|
|
3
|
+
return hasChanged ? `${String(valueFrom)} -> ${String(valueTo)}` : field.name;
|
|
4
|
+
};
|
|
5
|
+
export const LegacyComponentType = ({ valueFrom, valueTo = '' })=>`${String(valueFrom)} -> ${String(valueTo)}`;
|
|
6
|
+
export const Aliased = ({ valueFrom: before, valueTo })=>[
|
|
7
|
+
before,
|
|
8
|
+
valueTo
|
|
9
|
+
];
|
|
10
|
+
export default async function PropsObject(props) {
|
|
11
|
+
const { valueFrom, req } = props;
|
|
12
|
+
return [
|
|
13
|
+
valueFrom,
|
|
14
|
+
props.valueTo,
|
|
15
|
+
props['valueFrom'],
|
|
16
|
+
req.locale
|
|
17
|
+
];
|
|
18
|
+
}
|
|
19
|
+
export function LocalPropsType({ label, valueTo }) {
|
|
20
|
+
return [
|
|
21
|
+
label,
|
|
22
|
+
valueTo
|
|
23
|
+
];
|
|
24
|
+
}
|
|
25
|
+
export const RestProps = ({ field, ...rest })=>[
|
|
26
|
+
field,
|
|
27
|
+
rest.valueFrom
|
|
28
|
+
];
|
|
29
|
+
export const NameCollision = ({ valueFrom: comparisonValue })=>{
|
|
30
|
+
const valueFrom = 'unrelated';
|
|
31
|
+
return [
|
|
32
|
+
comparisonValue,
|
|
33
|
+
valueFrom
|
|
34
|
+
];
|
|
35
|
+
};
|
|
36
|
+
export const formatValue = (value)=>String(value);
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=basic.output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/transforms/rename-diff-value-props/basic.output.ts"],"sourcesContent":["import type {\n FieldDiffServerProps,\n TextFieldDiffClientComponent,\n TextFieldDiffClientProps,\n TextFieldDiffServerProps,\n} from 'payload'\nimport type React from 'react'\n\nexport const Destructured: React.FC<TextFieldDiffClientProps> = ({\n valueFrom,\n field,\n valueTo,\n}) => {\n const hasChanged = valueFrom !== valueTo\n return hasChanged ? `${String(valueFrom)} -> ${String(valueTo)}` : field.name\n}\n\nexport const LegacyComponentType: TextFieldDiffClientComponent = ({\n valueFrom,\n valueTo = '',\n}) => `${String(valueFrom)} -> ${String(valueTo)}`\n\nexport const Aliased = ({\n valueFrom: before,\n valueTo,\n}: TextFieldDiffClientProps) => [before, valueTo]\n\nexport default async function PropsObject(props: TextFieldDiffServerProps) {\n const { valueFrom, req } = props\n return [valueFrom, props.valueTo, props['valueFrom'], req.locale]\n}\n\ntype PropsWithLabel = { label: string } & TextFieldDiffClientProps\n\nexport function LocalPropsType({ label, valueTo }: PropsWithLabel) {\n return [label, valueTo]\n}\n\nexport const RestProps = ({ field, ...rest }: FieldDiffServerProps) => [field, rest.valueFrom]\n\nexport const NameCollision = ({ valueFrom: comparisonValue }: TextFieldDiffClientProps) => {\n const valueFrom = 'unrelated'\n return [comparisonValue, valueFrom]\n}\n\nexport const formatValue = (value: TextFieldDiffClientProps['valueTo']) => String(value)\n"],"names":["Destructured","valueFrom","field","valueTo","hasChanged","String","name","LegacyComponentType","Aliased","before","PropsObject","props","req","locale","LocalPropsType","label","RestProps","rest","NameCollision","comparisonValue","formatValue","value"],"mappings":"AAQA,OAAO,MAAMA,eAAmD,CAAC,EAC/DC,SAAS,EACTC,KAAK,EACLC,OAAO,EACR;IACC,MAAMC,aAAaH,cAAcE;IACjC,OAAOC,aAAa,GAAGC,OAAOJ,WAAW,IAAI,EAAEI,OAAOF,UAAU,GAAGD,MAAMI,IAAI;AAC/E,EAAC;AAED,OAAO,MAAMC,sBAAoD,CAAC,EAChEN,SAAS,EACTE,UAAU,EAAE,EACb,GAAK,GAAGE,OAAOJ,WAAW,IAAI,EAAEI,OAAOF,UAAU,CAAA;AAElD,OAAO,MAAMK,UAAU,CAAC,EACtBP,WAAWQ,MAAM,EACjBN,OAAO,EACkB,GAAK;QAACM;QAAQN;KAAQ,CAAA;AAEjD,eAAe,eAAeO,YAAYC,KAA+B;IACvE,MAAM,EAAEV,SAAS,EAAEW,GAAG,EAAE,GAAGD;IAC3B,OAAO;QAACV;QAAWU,MAAMR,OAAO;QAAEQ,KAAK,CAAC,YAAY;QAAEC,IAAIC,MAAM;KAAC;AACnE;AAIA,OAAO,SAASC,eAAe,EAAEC,KAAK,EAAEZ,OAAO,EAAkB;IAC/D,OAAO;QAACY;QAAOZ;KAAQ;AACzB;AAEA,OAAO,MAAMa,YAAY,CAAC,EAAEd,KAAK,EAAE,GAAGe,MAA4B,GAAK;QAACf;QAAOe,KAAKhB,SAAS;KAAC,CAAA;AAE9F,OAAO,MAAMiB,gBAAgB,CAAC,EAAEjB,WAAWkB,eAAe,EAA4B;IACpF,MAAMlB,YAAY;IAClB,OAAO;QAACkB;QAAiBlB;KAAU;AACrC,EAAC;AAED,OAAO,MAAMmB,cAAc,CAACC,QAA+ChB,OAAOgB,OAAM"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transforms/rename-diff-value-props/index.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAsB/C,eAAO,MAAM,oBAAoB,EAAE,SAwClC,CAAA"}
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
import { Node, SyntaxKind } from 'ts-morph';
|
|
2
|
+
const RENAMED_PROPS = new Map([
|
|
3
|
+
[
|
|
4
|
+
'comparisonValue',
|
|
5
|
+
'valueFrom'
|
|
6
|
+
],
|
|
7
|
+
[
|
|
8
|
+
'versionValue',
|
|
9
|
+
'valueTo'
|
|
10
|
+
]
|
|
11
|
+
]);
|
|
12
|
+
/**
|
|
13
|
+
* Matches every Diff component type exported from `payload`, in both the v3 component-alias
|
|
14
|
+
* form (`TextFieldDiffClientComponent`) and the props form (`TextFieldDiffClientProps`), so this
|
|
15
|
+
* transform works regardless of whether `migrate-field-component-types` has already run.
|
|
16
|
+
*/ const DIFF_TYPE_NAME_PATTERN = /^[A-Za-z]*FieldDiff(?:Client|Server)(?:Component|Props)$/;
|
|
17
|
+
/**
|
|
18
|
+
* Every rewrite removes one old prop name, so the per-file loop always terminates. This cap only
|
|
19
|
+
* guards against an unexpected regression turning it into an infinite loop.
|
|
20
|
+
*/ const MAX_REWRITES_PER_FILE = 1000;
|
|
21
|
+
export const renameDiffValueProps = {
|
|
22
|
+
name: 'rename-diff-value-props',
|
|
23
|
+
apply: ({ project })=>{
|
|
24
|
+
const filesChanged = [];
|
|
25
|
+
const notes = [];
|
|
26
|
+
for (const sourceFile of project.getSourceFiles()){
|
|
27
|
+
if (sourceFile.isDeclarationFile() || sourceFile.isInNodeModules()) {
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
const diffTypeNames = collectDiffTypeNames({
|
|
31
|
+
sourceFile
|
|
32
|
+
});
|
|
33
|
+
if (diffTypeNames.size === 0) {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
let rewriteCount = 0;
|
|
37
|
+
while(rewriteCount < MAX_REWRITES_PER_FILE && rewriteNextOccurrence({
|
|
38
|
+
diffTypeNames,
|
|
39
|
+
sourceFile
|
|
40
|
+
})){
|
|
41
|
+
rewriteCount++;
|
|
42
|
+
}
|
|
43
|
+
if (rewriteCount > 0) {
|
|
44
|
+
filesChanged.push(sourceFile.getFilePath());
|
|
45
|
+
}
|
|
46
|
+
notes.push(...collectLeftoverNotes({
|
|
47
|
+
sourceFile
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
filesChanged,
|
|
52
|
+
...notes.length > 0 ? {
|
|
53
|
+
notes
|
|
54
|
+
} : {}
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
description: 'Rename the `comparisonValue` and `versionValue` props read by custom Diff components to `valueFrom` and `valueTo`.'
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Returns the local names of Diff component types imported from `payload`, plus same-file type
|
|
61
|
+
* aliases and interfaces built from them (e.g. `type Props = TextFieldDiffClientProps & { ... }`).
|
|
62
|
+
*/ function collectDiffTypeNames({ sourceFile }) {
|
|
63
|
+
const diffTypeNames = new Set();
|
|
64
|
+
for (const importDeclaration of sourceFile.getImportDeclarations()){
|
|
65
|
+
if (importDeclaration.getModuleSpecifierValue() !== 'payload') {
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
for (const namedImport of importDeclaration.getNamedImports()){
|
|
69
|
+
if (DIFF_TYPE_NAME_PATTERN.test(namedImport.getName())) {
|
|
70
|
+
diffTypeNames.add(namedImport.getAliasNode()?.getText() ?? namedImport.getName());
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (diffTypeNames.size === 0) {
|
|
75
|
+
return diffTypeNames;
|
|
76
|
+
}
|
|
77
|
+
let hasFoundNewName = true;
|
|
78
|
+
while(hasFoundNewName){
|
|
79
|
+
hasFoundNewName = false;
|
|
80
|
+
const derivedTypeNames = [
|
|
81
|
+
...sourceFile.getTypeAliases().filter((typeAlias)=>referencesDiffType({
|
|
82
|
+
diffTypeNames,
|
|
83
|
+
typeNode: typeAlias.getTypeNodeOrThrow()
|
|
84
|
+
})),
|
|
85
|
+
...sourceFile.getInterfaces().filter((declaration)=>declaration.getExtends().some((heritage)=>diffTypeNames.has(heritage.getExpression().getText())))
|
|
86
|
+
].map((declaration)=>declaration.getName());
|
|
87
|
+
for (const typeName of derivedTypeNames){
|
|
88
|
+
if (!diffTypeNames.has(typeName)) {
|
|
89
|
+
diffTypeNames.add(typeName);
|
|
90
|
+
hasFoundNewName = true;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return diffTypeNames;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Applies a single rewrite and reports whether one was made. Renames replace source text, which
|
|
98
|
+
* invalidates previously queried nodes, so the caller re-scans the file after every rewrite.
|
|
99
|
+
*/ function rewriteNextOccurrence({ diffTypeNames, sourceFile }) {
|
|
100
|
+
for (const component of findDiffComponents({
|
|
101
|
+
diffTypeNames,
|
|
102
|
+
sourceFile
|
|
103
|
+
})){
|
|
104
|
+
const propsParameterName = component.getParameters()[0].getNameNode();
|
|
105
|
+
const propsBindingPatterns = [];
|
|
106
|
+
const propsIdentifiers = [];
|
|
107
|
+
if (Node.isObjectBindingPattern(propsParameterName)) {
|
|
108
|
+
propsBindingPatterns.push(propsParameterName);
|
|
109
|
+
const restElementName = propsParameterName.getElements().find((element)=>element.getDotDotDotToken())?.getNameNode();
|
|
110
|
+
if (restElementName && Node.isIdentifier(restElementName)) {
|
|
111
|
+
propsIdentifiers.push(restElementName);
|
|
112
|
+
}
|
|
113
|
+
} else if (Node.isIdentifier(propsParameterName)) {
|
|
114
|
+
propsIdentifiers.push(propsParameterName);
|
|
115
|
+
}
|
|
116
|
+
const readsProps = (node)=>Node.isIdentifier(node) && propsIdentifiers.some((propsIdentifier)=>isReferenceTo({
|
|
117
|
+
declaration: propsIdentifier,
|
|
118
|
+
identifier: node
|
|
119
|
+
}));
|
|
120
|
+
for (const declaration of component.getDescendantsOfKind(SyntaxKind.VariableDeclaration)){
|
|
121
|
+
const declarationName = declaration.getNameNode();
|
|
122
|
+
const initializer = declaration.getInitializer();
|
|
123
|
+
if (Node.isObjectBindingPattern(declarationName) && initializer && readsProps(initializer)) {
|
|
124
|
+
propsBindingPatterns.push(declarationName);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
for (const pattern of propsBindingPatterns){
|
|
128
|
+
for (const element of pattern.getElements()){
|
|
129
|
+
if (rewriteBindingElement({
|
|
130
|
+
component,
|
|
131
|
+
element
|
|
132
|
+
})) {
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
for (const access of component.getDescendantsOfKind(SyntaxKind.PropertyAccessExpression)){
|
|
138
|
+
const newName = RENAMED_PROPS.get(access.getName());
|
|
139
|
+
if (newName && readsProps(access.getExpression())) {
|
|
140
|
+
access.getNameNode().replaceWithText(newName);
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
for (const access of component.getDescendantsOfKind(SyntaxKind.ElementAccessExpression)){
|
|
145
|
+
const argument = access.getArgumentExpression();
|
|
146
|
+
if (!argument || !Node.isStringLiteral(argument) || !readsProps(access.getExpression())) {
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
const newName = RENAMED_PROPS.get(argument.getLiteralValue());
|
|
150
|
+
if (newName) {
|
|
151
|
+
argument.setLiteralValue(newName);
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
for (const indexedAccess of sourceFile.getDescendantsOfKind(SyntaxKind.IndexedAccessType)){
|
|
157
|
+
const indexType = indexedAccess.getIndexTypeNode();
|
|
158
|
+
const literal = Node.isLiteralTypeNode(indexType) ? indexType.getLiteral() : undefined;
|
|
159
|
+
if (!literal || !Node.isStringLiteral(literal) || !referencesDiffType({
|
|
160
|
+
diffTypeNames,
|
|
161
|
+
typeNode: indexedAccess.getObjectTypeNode()
|
|
162
|
+
})) {
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
const newName = RENAMED_PROPS.get(literal.getLiteralValue());
|
|
166
|
+
if (newName) {
|
|
167
|
+
literal.setLiteralValue(newName);
|
|
168
|
+
return true;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Finds functions whose first parameter is typed with a Diff type, either directly
|
|
175
|
+
* (`(props: TextFieldDiffClientProps) => ...`) or through the variable they are assigned to
|
|
176
|
+
* (`const Diff: React.FC<TextFieldDiffClientProps> = (props) => ...`).
|
|
177
|
+
*/ function findDiffComponents({ diffTypeNames, sourceFile }) {
|
|
178
|
+
const functions = [
|
|
179
|
+
...sourceFile.getDescendantsOfKind(SyntaxKind.ArrowFunction),
|
|
180
|
+
...sourceFile.getDescendantsOfKind(SyntaxKind.FunctionDeclaration),
|
|
181
|
+
...sourceFile.getDescendantsOfKind(SyntaxKind.FunctionExpression)
|
|
182
|
+
];
|
|
183
|
+
return functions.filter((component)=>{
|
|
184
|
+
const propsParameter = component.getParameters()[0];
|
|
185
|
+
if (!propsParameter) {
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
const parent = component.getParent();
|
|
189
|
+
const typeNodes = [
|
|
190
|
+
propsParameter.getTypeNode(),
|
|
191
|
+
Node.isVariableDeclaration(parent) ? parent.getTypeNode() : undefined
|
|
192
|
+
];
|
|
193
|
+
return typeNodes.some((typeNode)=>typeNode && referencesDiffType({
|
|
194
|
+
diffTypeNames,
|
|
195
|
+
typeNode
|
|
196
|
+
}));
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
function referencesDiffType({ diffTypeNames, typeNode }) {
|
|
200
|
+
return [
|
|
201
|
+
typeNode,
|
|
202
|
+
...typeNode.getDescendantsOfKind(SyntaxKind.TypeReference)
|
|
203
|
+
].some((node)=>Node.isTypeReference(node) && diffTypeNames.has(node.getTypeName().getText()) && !isWrappedWithin({
|
|
204
|
+
node,
|
|
205
|
+
root: typeNode
|
|
206
|
+
}));
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Whether `node` sits inside a type that wraps the props rather than describing them, such as
|
|
210
|
+
* `{ diff: TextFieldDiffClientProps }` or `TextFieldDiffClientProps['valueFrom']`.
|
|
211
|
+
*/ function isWrappedWithin({ node, root }) {
|
|
212
|
+
const stopAt = root.getParent();
|
|
213
|
+
for(let ancestor = node.getParent(); ancestor && ancestor !== stopAt; ancestor = ancestor.getParent()){
|
|
214
|
+
if (Node.isPropertySignature(ancestor) || Node.isIndexedAccessTypeNode(ancestor)) {
|
|
215
|
+
return true;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return false;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Renames the destructured key of a single binding element. Returns `false` when the element
|
|
222
|
+
* doesn't destructure one of the renamed props.
|
|
223
|
+
*/ function rewriteBindingElement({ component, element }) {
|
|
224
|
+
if (element.getDotDotDotToken()) {
|
|
225
|
+
return false;
|
|
226
|
+
}
|
|
227
|
+
const nameNode = element.getNameNode();
|
|
228
|
+
const propertyNameNode = element.getPropertyNameNode();
|
|
229
|
+
const propertyName = propertyNameNode ? getPropertyNameText({
|
|
230
|
+
node: propertyNameNode
|
|
231
|
+
}) : nameNode.getText();
|
|
232
|
+
const newName = propertyName ? RENAMED_PROPS.get(propertyName) : undefined;
|
|
233
|
+
if (!propertyName || !newName) {
|
|
234
|
+
return false;
|
|
235
|
+
}
|
|
236
|
+
const initializer = element.getInitializer();
|
|
237
|
+
const initializerText = initializer ? ` = ${initializer.getText()}` : '';
|
|
238
|
+
if (propertyNameNode) {
|
|
239
|
+
const localName = nameNode.getText();
|
|
240
|
+
element.replaceWithText(localName === newName ? `${newName}${initializerText}` : `${newName}: ${localName}${initializerText}`);
|
|
241
|
+
return true;
|
|
242
|
+
}
|
|
243
|
+
// A shorthand `{ comparisonValue }` also declares a local variable. Renaming it through the
|
|
244
|
+
// language service updates every reference, and `usePrefixAndSuffixText` leaves the element as
|
|
245
|
+
// `comparisonValue: valueFrom`, which the next pass collapses to `valueFrom`.
|
|
246
|
+
if (Node.isIdentifier(nameNode) && !containsIdentifierNamed({
|
|
247
|
+
name: newName,
|
|
248
|
+
node: component
|
|
249
|
+
})) {
|
|
250
|
+
const sourceFile = element.getSourceFile();
|
|
251
|
+
const textBeforeRename = sourceFile.getFullText();
|
|
252
|
+
try {
|
|
253
|
+
nameNode.rename(newName, {
|
|
254
|
+
usePrefixAndSuffixText: true
|
|
255
|
+
});
|
|
256
|
+
} catch {
|
|
257
|
+
// Fall back to keeping the local variable name below
|
|
258
|
+
}
|
|
259
|
+
if (sourceFile.getFullText() !== textBeforeRename) {
|
|
260
|
+
return true;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
element.replaceWithText(`${newName}: ${propertyName}${initializerText}`);
|
|
264
|
+
return true;
|
|
265
|
+
}
|
|
266
|
+
function getPropertyNameText({ node }) {
|
|
267
|
+
if (Node.isIdentifier(node)) {
|
|
268
|
+
return node.getText();
|
|
269
|
+
}
|
|
270
|
+
if (Node.isStringLiteral(node)) {
|
|
271
|
+
return node.getLiteralValue();
|
|
272
|
+
}
|
|
273
|
+
return undefined;
|
|
274
|
+
}
|
|
275
|
+
function containsIdentifierNamed({ name, node }) {
|
|
276
|
+
return node.getDescendantsOfKind(SyntaxKind.Identifier).some((identifier)=>identifier.getText() === name);
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Compares symbols so an inner variable that shadows the props parameter isn't mistaken for it.
|
|
280
|
+
* Falls back to comparing names when the type checker can't resolve a symbol.
|
|
281
|
+
*/ function isReferenceTo({ declaration, identifier }) {
|
|
282
|
+
if (identifier.getText() !== declaration.getText()) {
|
|
283
|
+
return false;
|
|
284
|
+
}
|
|
285
|
+
const declarationSymbol = declaration.getSymbol();
|
|
286
|
+
return !declarationSymbol || identifier.getSymbol() === declarationSymbol;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Flags old prop names that remain in a property position, e.g. a JSX attribute passing
|
|
290
|
+
* `comparisonValue` to another component, or `Pick<Props, 'versionValue'>`. Local variables that
|
|
291
|
+
* merely share the old name are left alone.
|
|
292
|
+
*/ function collectLeftoverNotes({ sourceFile }) {
|
|
293
|
+
const notedLocations = new Set();
|
|
294
|
+
const notes = [];
|
|
295
|
+
const candidates = [
|
|
296
|
+
...sourceFile.getDescendantsOfKind(SyntaxKind.Identifier).filter((identifier)=>isPropertyNamePosition({
|
|
297
|
+
identifier
|
|
298
|
+
})),
|
|
299
|
+
...sourceFile.getDescendantsOfKind(SyntaxKind.StringLiteral)
|
|
300
|
+
].sort((a, b)=>a.getStart() - b.getStart());
|
|
301
|
+
for (const candidate of candidates){
|
|
302
|
+
const oldName = Node.isStringLiteral(candidate) ? candidate.getLiteralValue() : candidate.getText();
|
|
303
|
+
const newName = RENAMED_PROPS.get(oldName);
|
|
304
|
+
const location = `${sourceFile.getFilePath()}:${candidate.getStartLineNumber()}`;
|
|
305
|
+
if (!newName || notedLocations.has(`${location}:${oldName}`)) {
|
|
306
|
+
continue;
|
|
307
|
+
}
|
|
308
|
+
notedLocations.add(`${location}:${oldName}`);
|
|
309
|
+
notes.push(`${location}: \`${oldName}\` was not migrated. If it refers to a Diff component prop, rename it to \`${newName}\`.`);
|
|
310
|
+
}
|
|
311
|
+
return notes;
|
|
312
|
+
}
|
|
313
|
+
function isPropertyNamePosition({ identifier }) {
|
|
314
|
+
const parent = identifier.getParent();
|
|
315
|
+
if (Node.isShorthandPropertyAssignment(parent) || Node.isJsxAttribute(parent)) {
|
|
316
|
+
return true;
|
|
317
|
+
}
|
|
318
|
+
if (Node.isBindingElement(parent)) {
|
|
319
|
+
const propertyNameNode = parent.getPropertyNameNode();
|
|
320
|
+
return propertyNameNode ? propertyNameNode === identifier : !parent.getDotDotDotToken();
|
|
321
|
+
}
|
|
322
|
+
if (Node.isPropertyAccessExpression(parent) || Node.isPropertyAssignment(parent) || Node.isPropertySignature(parent)) {
|
|
323
|
+
return parent.getNameNode() === identifier;
|
|
324
|
+
}
|
|
325
|
+
return false;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/transforms/rename-diff-value-props/index.ts"],"sourcesContent":["import type {\n ArrowFunction,\n BindingElement,\n FunctionDeclaration,\n FunctionExpression,\n Identifier,\n ObjectBindingPattern,\n SourceFile,\n TypeNode,\n} from 'ts-morph'\n\nimport { Node, SyntaxKind } from 'ts-morph'\n\nimport type { Transform } from '../../types.js'\n\nconst RENAMED_PROPS = new Map([\n ['comparisonValue', 'valueFrom'],\n ['versionValue', 'valueTo'],\n])\n\n/**\n * Matches every Diff component type exported from `payload`, in both the v3 component-alias\n * form (`TextFieldDiffClientComponent`) and the props form (`TextFieldDiffClientProps`), so this\n * transform works regardless of whether `migrate-field-component-types` has already run.\n */\nconst DIFF_TYPE_NAME_PATTERN = /^[A-Za-z]*FieldDiff(?:Client|Server)(?:Component|Props)$/\n\n/**\n * Every rewrite removes one old prop name, so the per-file loop always terminates. This cap only\n * guards against an unexpected regression turning it into an infinite loop.\n */\nconst MAX_REWRITES_PER_FILE = 1000\n\ntype ComponentFunction = ArrowFunction | FunctionDeclaration | FunctionExpression\n\nexport const renameDiffValueProps: Transform = {\n name: 'rename-diff-value-props',\n apply: ({ project }) => {\n const filesChanged: string[] = []\n const notes: string[] = []\n\n for (const sourceFile of project.getSourceFiles()) {\n if (sourceFile.isDeclarationFile() || sourceFile.isInNodeModules()) {\n continue\n }\n\n const diffTypeNames = collectDiffTypeNames({ sourceFile })\n\n if (diffTypeNames.size === 0) {\n continue\n }\n\n let rewriteCount = 0\n\n while (\n rewriteCount < MAX_REWRITES_PER_FILE &&\n rewriteNextOccurrence({ diffTypeNames, sourceFile })\n ) {\n rewriteCount++\n }\n\n if (rewriteCount > 0) {\n filesChanged.push(sourceFile.getFilePath())\n }\n\n notes.push(...collectLeftoverNotes({ sourceFile }))\n }\n\n return {\n filesChanged,\n ...(notes.length > 0 ? { notes } : {}),\n }\n },\n description:\n 'Rename the `comparisonValue` and `versionValue` props read by custom Diff components to `valueFrom` and `valueTo`.',\n}\n\n/**\n * Returns the local names of Diff component types imported from `payload`, plus same-file type\n * aliases and interfaces built from them (e.g. `type Props = TextFieldDiffClientProps & { ... }`).\n */\nfunction collectDiffTypeNames({ sourceFile }: { sourceFile: SourceFile }): Set<string> {\n const diffTypeNames = new Set<string>()\n\n for (const importDeclaration of sourceFile.getImportDeclarations()) {\n if (importDeclaration.getModuleSpecifierValue() !== 'payload') {\n continue\n }\n\n for (const namedImport of importDeclaration.getNamedImports()) {\n if (DIFF_TYPE_NAME_PATTERN.test(namedImport.getName())) {\n diffTypeNames.add(namedImport.getAliasNode()?.getText() ?? namedImport.getName())\n }\n }\n }\n\n if (diffTypeNames.size === 0) {\n return diffTypeNames\n }\n\n let hasFoundNewName = true\n\n while (hasFoundNewName) {\n hasFoundNewName = false\n\n const derivedTypeNames = [\n ...sourceFile\n .getTypeAliases()\n .filter((typeAlias) =>\n referencesDiffType({ diffTypeNames, typeNode: typeAlias.getTypeNodeOrThrow() }),\n ),\n ...sourceFile\n .getInterfaces()\n .filter((declaration) =>\n declaration\n .getExtends()\n .some((heritage) => diffTypeNames.has(heritage.getExpression().getText())),\n ),\n ].map((declaration) => declaration.getName())\n\n for (const typeName of derivedTypeNames) {\n if (!diffTypeNames.has(typeName)) {\n diffTypeNames.add(typeName)\n hasFoundNewName = true\n }\n }\n }\n\n return diffTypeNames\n}\n\n/**\n * Applies a single rewrite and reports whether one was made. Renames replace source text, which\n * invalidates previously queried nodes, so the caller re-scans the file after every rewrite.\n */\nfunction rewriteNextOccurrence({\n diffTypeNames,\n sourceFile,\n}: {\n diffTypeNames: Set<string>\n sourceFile: SourceFile\n}): boolean {\n for (const component of findDiffComponents({ diffTypeNames, sourceFile })) {\n const propsParameterName = component.getParameters()[0]!.getNameNode()\n const propsBindingPatterns: ObjectBindingPattern[] = []\n const propsIdentifiers: Identifier[] = []\n\n if (Node.isObjectBindingPattern(propsParameterName)) {\n propsBindingPatterns.push(propsParameterName)\n\n const restElementName = propsParameterName\n .getElements()\n .find((element) => element.getDotDotDotToken())\n ?.getNameNode()\n\n if (restElementName && Node.isIdentifier(restElementName)) {\n propsIdentifiers.push(restElementName)\n }\n } else if (Node.isIdentifier(propsParameterName)) {\n propsIdentifiers.push(propsParameterName)\n }\n\n const readsProps = (node: Node): boolean =>\n Node.isIdentifier(node) &&\n propsIdentifiers.some((propsIdentifier) =>\n isReferenceTo({ declaration: propsIdentifier, identifier: node }),\n )\n\n for (const declaration of component.getDescendantsOfKind(SyntaxKind.VariableDeclaration)) {\n const declarationName = declaration.getNameNode()\n const initializer = declaration.getInitializer()\n\n if (Node.isObjectBindingPattern(declarationName) && initializer && readsProps(initializer)) {\n propsBindingPatterns.push(declarationName)\n }\n }\n\n for (const pattern of propsBindingPatterns) {\n for (const element of pattern.getElements()) {\n if (rewriteBindingElement({ component, element })) {\n return true\n }\n }\n }\n\n for (const access of component.getDescendantsOfKind(SyntaxKind.PropertyAccessExpression)) {\n const newName = RENAMED_PROPS.get(access.getName())\n\n if (newName && readsProps(access.getExpression())) {\n access.getNameNode().replaceWithText(newName)\n return true\n }\n }\n\n for (const access of component.getDescendantsOfKind(SyntaxKind.ElementAccessExpression)) {\n const argument = access.getArgumentExpression()\n\n if (!argument || !Node.isStringLiteral(argument) || !readsProps(access.getExpression())) {\n continue\n }\n\n const newName = RENAMED_PROPS.get(argument.getLiteralValue())\n\n if (newName) {\n argument.setLiteralValue(newName)\n return true\n }\n }\n }\n\n for (const indexedAccess of sourceFile.getDescendantsOfKind(SyntaxKind.IndexedAccessType)) {\n const indexType = indexedAccess.getIndexTypeNode()\n const literal = Node.isLiteralTypeNode(indexType) ? indexType.getLiteral() : undefined\n\n if (\n !literal ||\n !Node.isStringLiteral(literal) ||\n !referencesDiffType({ diffTypeNames, typeNode: indexedAccess.getObjectTypeNode() })\n ) {\n continue\n }\n\n const newName = RENAMED_PROPS.get(literal.getLiteralValue())\n\n if (newName) {\n literal.setLiteralValue(newName)\n return true\n }\n }\n\n return false\n}\n\n/**\n * Finds functions whose first parameter is typed with a Diff type, either directly\n * (`(props: TextFieldDiffClientProps) => ...`) or through the variable they are assigned to\n * (`const Diff: React.FC<TextFieldDiffClientProps> = (props) => ...`).\n */\nfunction findDiffComponents({\n diffTypeNames,\n sourceFile,\n}: {\n diffTypeNames: Set<string>\n sourceFile: SourceFile\n}): ComponentFunction[] {\n const functions: ComponentFunction[] = [\n ...sourceFile.getDescendantsOfKind(SyntaxKind.ArrowFunction),\n ...sourceFile.getDescendantsOfKind(SyntaxKind.FunctionDeclaration),\n ...sourceFile.getDescendantsOfKind(SyntaxKind.FunctionExpression),\n ]\n\n return functions.filter((component) => {\n const propsParameter = component.getParameters()[0]\n\n if (!propsParameter) {\n return false\n }\n\n const parent = component.getParent()\n const typeNodes = [\n propsParameter.getTypeNode(),\n Node.isVariableDeclaration(parent) ? parent.getTypeNode() : undefined,\n ]\n\n return typeNodes.some((typeNode) => typeNode && referencesDiffType({ diffTypeNames, typeNode }))\n })\n}\n\nfunction referencesDiffType({\n diffTypeNames,\n typeNode,\n}: {\n diffTypeNames: Set<string>\n typeNode: TypeNode\n}): boolean {\n return [typeNode, ...typeNode.getDescendantsOfKind(SyntaxKind.TypeReference)].some(\n (node) =>\n Node.isTypeReference(node) &&\n diffTypeNames.has(node.getTypeName().getText()) &&\n !isWrappedWithin({ node, root: typeNode }),\n )\n}\n\n/**\n * Whether `node` sits inside a type that wraps the props rather than describing them, such as\n * `{ diff: TextFieldDiffClientProps }` or `TextFieldDiffClientProps['valueFrom']`.\n */\nfunction isWrappedWithin({ node, root }: { node: Node; root: TypeNode }): boolean {\n const stopAt = root.getParent()\n\n for (\n let ancestor = node.getParent();\n ancestor && ancestor !== stopAt;\n ancestor = ancestor.getParent()\n ) {\n if (Node.isPropertySignature(ancestor) || Node.isIndexedAccessTypeNode(ancestor)) {\n return true\n }\n }\n\n return false\n}\n\n/**\n * Renames the destructured key of a single binding element. Returns `false` when the element\n * doesn't destructure one of the renamed props.\n */\nfunction rewriteBindingElement({\n component,\n element,\n}: {\n component: ComponentFunction\n element: BindingElement\n}): boolean {\n if (element.getDotDotDotToken()) {\n return false\n }\n\n const nameNode = element.getNameNode()\n const propertyNameNode = element.getPropertyNameNode()\n const propertyName = propertyNameNode\n ? getPropertyNameText({ node: propertyNameNode })\n : nameNode.getText()\n const newName = propertyName ? RENAMED_PROPS.get(propertyName) : undefined\n\n if (!propertyName || !newName) {\n return false\n }\n\n const initializer = element.getInitializer()\n const initializerText = initializer ? ` = ${initializer.getText()}` : ''\n\n if (propertyNameNode) {\n const localName = nameNode.getText()\n\n element.replaceWithText(\n localName === newName\n ? `${newName}${initializerText}`\n : `${newName}: ${localName}${initializerText}`,\n )\n return true\n }\n\n // A shorthand `{ comparisonValue }` also declares a local variable. Renaming it through the\n // language service updates every reference, and `usePrefixAndSuffixText` leaves the element as\n // `comparisonValue: valueFrom`, which the next pass collapses to `valueFrom`.\n if (Node.isIdentifier(nameNode) && !containsIdentifierNamed({ name: newName, node: component })) {\n const sourceFile = element.getSourceFile()\n const textBeforeRename = sourceFile.getFullText()\n\n try {\n nameNode.rename(newName, { usePrefixAndSuffixText: true })\n } catch {\n // Fall back to keeping the local variable name below\n }\n\n if (sourceFile.getFullText() !== textBeforeRename) {\n return true\n }\n }\n\n element.replaceWithText(`${newName}: ${propertyName}${initializerText}`)\n return true\n}\n\nfunction getPropertyNameText({ node }: { node: Node }): string | undefined {\n if (Node.isIdentifier(node)) {\n return node.getText()\n }\n\n if (Node.isStringLiteral(node)) {\n return node.getLiteralValue()\n }\n\n return undefined\n}\n\nfunction containsIdentifierNamed({ name, node }: { name: string; node: Node }): boolean {\n return node\n .getDescendantsOfKind(SyntaxKind.Identifier)\n .some((identifier) => identifier.getText() === name)\n}\n\n/**\n * Compares symbols so an inner variable that shadows the props parameter isn't mistaken for it.\n * Falls back to comparing names when the type checker can't resolve a symbol.\n */\nfunction isReferenceTo({\n declaration,\n identifier,\n}: {\n declaration: Identifier\n identifier: Identifier\n}): boolean {\n if (identifier.getText() !== declaration.getText()) {\n return false\n }\n\n const declarationSymbol = declaration.getSymbol()\n\n return !declarationSymbol || identifier.getSymbol() === declarationSymbol\n}\n\n/**\n * Flags old prop names that remain in a property position, e.g. a JSX attribute passing\n * `comparisonValue` to another component, or `Pick<Props, 'versionValue'>`. Local variables that\n * merely share the old name are left alone.\n */\nfunction collectLeftoverNotes({ sourceFile }: { sourceFile: SourceFile }): string[] {\n const notedLocations = new Set<string>()\n const notes: string[] = []\n const candidates = [\n ...sourceFile\n .getDescendantsOfKind(SyntaxKind.Identifier)\n .filter((identifier) => isPropertyNamePosition({ identifier })),\n ...sourceFile.getDescendantsOfKind(SyntaxKind.StringLiteral),\n ].sort((a, b) => a.getStart() - b.getStart())\n\n for (const candidate of candidates) {\n const oldName = Node.isStringLiteral(candidate)\n ? candidate.getLiteralValue()\n : candidate.getText()\n const newName = RENAMED_PROPS.get(oldName)\n const location = `${sourceFile.getFilePath()}:${candidate.getStartLineNumber()}`\n\n if (!newName || notedLocations.has(`${location}:${oldName}`)) {\n continue\n }\n\n notedLocations.add(`${location}:${oldName}`)\n notes.push(\n `${location}: \\`${oldName}\\` was not migrated. If it refers to a Diff component prop, rename it to \\`${newName}\\`.`,\n )\n }\n\n return notes\n}\n\nfunction isPropertyNamePosition({ identifier }: { identifier: Identifier }): boolean {\n const parent = identifier.getParent()\n\n if (Node.isShorthandPropertyAssignment(parent) || Node.isJsxAttribute(parent)) {\n return true\n }\n\n if (Node.isBindingElement(parent)) {\n const propertyNameNode = parent.getPropertyNameNode()\n\n return propertyNameNode ? propertyNameNode === identifier : !parent.getDotDotDotToken()\n }\n\n if (\n Node.isPropertyAccessExpression(parent) ||\n Node.isPropertyAssignment(parent) ||\n Node.isPropertySignature(parent)\n ) {\n return parent.getNameNode() === identifier\n }\n\n return false\n}\n"],"names":["Node","SyntaxKind","RENAMED_PROPS","Map","DIFF_TYPE_NAME_PATTERN","MAX_REWRITES_PER_FILE","renameDiffValueProps","name","apply","project","filesChanged","notes","sourceFile","getSourceFiles","isDeclarationFile","isInNodeModules","diffTypeNames","collectDiffTypeNames","size","rewriteCount","rewriteNextOccurrence","push","getFilePath","collectLeftoverNotes","length","description","Set","importDeclaration","getImportDeclarations","getModuleSpecifierValue","namedImport","getNamedImports","test","getName","add","getAliasNode","getText","hasFoundNewName","derivedTypeNames","getTypeAliases","filter","typeAlias","referencesDiffType","typeNode","getTypeNodeOrThrow","getInterfaces","declaration","getExtends","some","heritage","has","getExpression","map","typeName","component","findDiffComponents","propsParameterName","getParameters","getNameNode","propsBindingPatterns","propsIdentifiers","isObjectBindingPattern","restElementName","getElements","find","element","getDotDotDotToken","isIdentifier","readsProps","node","propsIdentifier","isReferenceTo","identifier","getDescendantsOfKind","VariableDeclaration","declarationName","initializer","getInitializer","pattern","rewriteBindingElement","access","PropertyAccessExpression","newName","get","replaceWithText","ElementAccessExpression","argument","getArgumentExpression","isStringLiteral","getLiteralValue","setLiteralValue","indexedAccess","IndexedAccessType","indexType","getIndexTypeNode","literal","isLiteralTypeNode","getLiteral","undefined","getObjectTypeNode","functions","ArrowFunction","FunctionDeclaration","FunctionExpression","propsParameter","parent","getParent","typeNodes","getTypeNode","isVariableDeclaration","TypeReference","isTypeReference","getTypeName","isWrappedWithin","root","stopAt","ancestor","isPropertySignature","isIndexedAccessTypeNode","nameNode","propertyNameNode","getPropertyNameNode","propertyName","getPropertyNameText","initializerText","localName","containsIdentifierNamed","getSourceFile","textBeforeRename","getFullText","rename","usePrefixAndSuffixText","Identifier","declarationSymbol","getSymbol","notedLocations","candidates","isPropertyNamePosition","StringLiteral","sort","a","b","getStart","candidate","oldName","location","getStartLineNumber","isShorthandPropertyAssignment","isJsxAttribute","isBindingElement","isPropertyAccessExpression","isPropertyAssignment"],"mappings":"AAWA,SAASA,IAAI,EAAEC,UAAU,QAAQ,WAAU;AAI3C,MAAMC,gBAAgB,IAAIC,IAAI;IAC5B;QAAC;QAAmB;KAAY;IAChC;QAAC;QAAgB;KAAU;CAC5B;AAED;;;;CAIC,GACD,MAAMC,yBAAyB;AAE/B;;;CAGC,GACD,MAAMC,wBAAwB;AAI9B,OAAO,MAAMC,uBAAkC;IAC7CC,MAAM;IACNC,OAAO,CAAC,EAAEC,OAAO,EAAE;QACjB,MAAMC,eAAyB,EAAE;QACjC,MAAMC,QAAkB,EAAE;QAE1B,KAAK,MAAMC,cAAcH,QAAQI,cAAc,GAAI;YACjD,IAAID,WAAWE,iBAAiB,MAAMF,WAAWG,eAAe,IAAI;gBAClE;YACF;YAEA,MAAMC,gBAAgBC,qBAAqB;gBAAEL;YAAW;YAExD,IAAII,cAAcE,IAAI,KAAK,GAAG;gBAC5B;YACF;YAEA,IAAIC,eAAe;YAEnB,MACEA,eAAed,yBACfe,sBAAsB;gBAAEJ;gBAAeJ;YAAW,GAClD;gBACAO;YACF;YAEA,IAAIA,eAAe,GAAG;gBACpBT,aAAaW,IAAI,CAACT,WAAWU,WAAW;YAC1C;YAEAX,MAAMU,IAAI,IAAIE,qBAAqB;gBAAEX;YAAW;QAClD;QAEA,OAAO;YACLF;YACA,GAAIC,MAAMa,MAAM,GAAG,IAAI;gBAAEb;Y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AWzG,KAAKoJ,cAAc,CAAC3C,SAAS;QAC7E,OAAO;IACT;IAEA,IAAIzG,KAAKqJ,gBAAgB,CAAC5C,SAAS;QACjC,MAAMe,mBAAmBf,OAAOgB,mBAAmB;QAEnD,OAAOD,mBAAmBA,qBAAqBhD,aAAa,CAACiC,OAAOvC,iBAAiB;IACvF;IAEA,IACElE,KAAKsJ,0BAA0B,CAAC7C,WAChCzG,KAAKuJ,oBAAoB,CAAC9C,WAC1BzG,KAAKqH,mBAAmB,CAACZ,SACzB;QACA,OAAOA,OAAO/C,WAAW,OAAOc;IAClC;IAEA,OAAO;AACT"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const isUnchanged = ({ comparisonValue, versionValue })=>comparisonValue === versionValue;
|
|
2
|
+
export const TextField = (props)=>props.versionValue;
|
|
3
|
+
export const versionValueField = {
|
|
4
|
+
name: 'versionValue',
|
|
5
|
+
type: 'text'
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
//# sourceMappingURL=no-match.input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/transforms/rename-diff-value-props/no-match.input.ts"],"sourcesContent":["import type { Field, TextFieldClientProps } from 'payload'\n\ntype Comparison = { comparisonValue: unknown; versionValue: unknown }\n\nexport const isUnchanged = ({ comparisonValue, versionValue }: Comparison) =>\n comparisonValue === versionValue\n\nexport const TextField = (props: TextFieldClientProps & Comparison) => props.versionValue\n\nexport const versionValueField: Field = { name: 'versionValue', type: 'text' }\n"],"names":["isUnchanged","comparisonValue","versionValue","TextField","props","versionValueField","name","type"],"mappings":"AAIA,OAAO,MAAMA,cAAc,CAAC,EAAEC,eAAe,EAAEC,YAAY,EAAc,GACvED,oBAAoBC,aAAY;AAElC,OAAO,MAAMC,YAAY,CAACC,QAA6CA,MAAMF,YAAY,CAAA;AAEzF,OAAO,MAAMG,oBAA2B;IAAEC,MAAM;IAAgBC,MAAM;AAAO,EAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/transforms/rename-experimental-table-feature/alias.input.ts"],"sourcesContent":["import { EXPERIMENTAL_TableFeature as TableFeatureFn } from '@payloadcms/richtext-lexical'\n\nexport const features = [TableFeatureFn()]\n"],"names":["EXPERIMENTAL_TableFeature","TableFeatureFn","features"],"mappings":"AAAA,SAASA,6BAA6BC,cAAc,QAAQ,+BAA8B;AAE1F,OAAO,MAAMC,WAAW;IAACD;CAAiB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/transforms/rename-experimental-table-feature/alias.output.ts"],"sourcesContent":["import { TableFeature as TableFeatureFn } from '@payloadcms/richtext-lexical'\n\nexport const features = [TableFeatureFn()]\n"],"names":["TableFeature","TableFeatureFn","features"],"mappings":"AAAA,SAASA,gBAAgBC,cAAc,QAAQ,+BAA8B;AAE7E,OAAO,MAAMC,WAAW;IAACD;CAAiB,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { EXPERIMENTAL_TableFeature, FixedToolbarFeature, lexicalEditor } from '@payloadcms/richtext-lexical';
|
|
2
|
+
export const RichText = {
|
|
3
|
+
fields: [
|
|
4
|
+
{
|
|
5
|
+
name: 'content',
|
|
6
|
+
type: 'richText',
|
|
7
|
+
editor: lexicalEditor({
|
|
8
|
+
features: ({ defaultFeatures })=>[
|
|
9
|
+
...defaultFeatures,
|
|
10
|
+
FixedToolbarFeature(),
|
|
11
|
+
EXPERIMENTAL_TableFeature()
|
|
12
|
+
]
|
|
13
|
+
})
|
|
14
|
+
}
|
|
15
|
+
],
|
|
16
|
+
slug: 'richtext'
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=basic.input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/transforms/rename-experimental-table-feature/basic.input.ts"],"sourcesContent":["import type { CollectionConfig } from 'payload'\n\nimport { EXPERIMENTAL_TableFeature, FixedToolbarFeature, lexicalEditor } from '@payloadcms/richtext-lexical'\n\nexport const RichText: CollectionConfig = {\n fields: [\n {\n name: 'content',\n type: 'richText',\n editor: lexicalEditor({\n features: ({ defaultFeatures }) => [\n ...defaultFeatures,\n FixedToolbarFeature(),\n EXPERIMENTAL_TableFeature(),\n ],\n }),\n },\n ],\n slug: 'richtext',\n}\n"],"names":["EXPERIMENTAL_TableFeature","FixedToolbarFeature","lexicalEditor","RichText","fields","name","type","editor","features","defaultFeatures","slug"],"mappings":"AAEA,SAASA,yBAAyB,EAAEC,mBAAmB,EAAEC,aAAa,QAAQ,+BAA8B;AAE5G,OAAO,MAAMC,WAA6B;IACxCC,QAAQ;QACN;YACEC,MAAM;YACNC,MAAM;YACNC,QAAQL,cAAc;gBACpBM,UAAU,CAAC,EAAEC,eAAe,EAAE,GAAK;2BAC9BA;wBACHR;wBACAD;qBACD;YACH;QACF;KACD;IACDU,MAAM;AACR,EAAC"}
|