chore(plugin-multi-tenant)!: remove deprecated APIs#16598
Conversation
📦 esbuild Bundle Analysis for payloadThis analysis was generated by esbuild-bundle-analyzer. 🤖 |
|
/ai-review |
There was a problem hiding this comment.
Issues
Minor (nice to have)
-
[packages/plugin-multi-tenant/src/fields/tenantField/index.ts:114] — The new
tenantFieldValidatefunction is now always set asvalidateon the field, butrequired: trueis also set. These two can conflict: Payload's built-inrequiredvalidation runs alongside any customvalidatefunction, but the customvalidatehere also enforces the required invariant redundantly. More importantly,validatewas previously overrideable from_overrides(the old code accepted and threadedvalidatethroughfieldValidation), but now thevalidatekey has been removed from the destructure and the external override is silently dropped. If a user previously passedvalidatein_overrides, it is now ignored without any warning — this is a subtle behaviour change worth documenting or explicitly excluding fromRootTenantFieldConfigOverrides. -
[packages/plugin-multi-tenant/src/types.ts:215] —
'validate'has been added toRootTenantFieldConfigOverridesbut the implementation no longer accepts it (it was removed from the_overridesdestructure). The type now advertises an option the runtime silently ignores. Either honour the override or remove'validate'from this union. -
[packages/codemod/src/transforms/migrate-multi-tenant-tenant-selector-label/index.ts:12] — The
.filter()call pre-filters forwasForgotten() === false, but the inner loop immediately re-checksprop.wasForgotten()again. The second guard is redundant. This is harmless but adds noise — remove the innerif (prop.wasForgotten()) { continue }(lines 18–20). -
[packages/codemod/src/transforms/migrate-multi-tenant-tenant-selector-label/index.ts:75] — The generated replacement text
i18n: { translations: { ${localeEntries.join(', ')} } }produces a single-line object regardless of the original formatting style. This is fine for a codemod (users are expected to reformat), but it is worth noting that the output fixture (object.output.ts) reflects this by having the entirei18nblock on one very long line, which may surprise users. Consider adding a brief note in the README that users should run their formatter after applying the codemod.
Recommendations
The removal of useBaseListFilter and tenantSelectorLabel is clean and the codemods are well-structured with idempotency tests and no-match guards. One broader point: the tenantFieldValidate refactor (collapsing fieldValidation into a simple top-level const) is a good simplification, but the interaction between required: true and the custom validate function should be resolved — either keep required: true and drop the custom validate (relying on Payload's built-in required enforcement), or keep the custom validate and drop required: true to avoid double-validation. As it stands both run, which is harmless but redundant.
Assessment
Ready to merge? Yes with fixes
Reasoning: The breaking-change removals, codemods, and documentation are all consistent and well-tested. The only material concern is the mismatch between the 'validate' entry added to RootTenantFieldConfigOverrides and the runtime code that now silently ignores any user-supplied validate override — this should be resolved before merge to avoid a confusing developer experience.
…nant)/-remove-deprecated-APIs # Conflicts: # packages/codemod/src/registry.ts
@payloadcms/plugin-multi-tenantand adds codemods + migration guide entries for eachuseBaseListFilterper-collection option renamed touseBaseFilter; codemod (migrate-multi-tenant-use-base-list-filter) auto-migratestenantSelectorLabelplugin option removed in favour ofi18n.translations['nav-tenantSelector-label']; codemod (migrate-multi-tenant-tenant-selector-label) auto-migrates locale-keyed objects, emits a manual-migration note for string values or configs that already havei18ngetGlobalViewRedirectbasePathargument removed; function now derives the redirect path internally from the Payload configtenantFieldValidatefunction from the tenant field — Payload's built-inrequired: truealready rejectsnull,undefined, and empty arrays onhasManyrelationship fields, making the custom validator redundant;validateis now excluded fromRootTenantFieldConfigOverridesBreaking changes
collections[slug].useBaseListFiltercollections[slug].useBaseFiltertenantSelectorLabeli18n.translations[locale]['nav-tenantSelector-label']getGlobalViewRedirect({ basePath })RootTenantFieldConfigOverrides.validaterequired: true(default)