FacetService.ensureUniqueCode enforces global uniqueness across Channels while FacetService.findAll/findOne are Channel-scoped (silent -2 suffixing)#5754
Describe the bug
In @vendure/core 3.8.1, FacetService.findAll(ctx) and FacetService.findOne(ctx, facetId) scope queries to ctx.channelId:
FacetService.findAllpasseschannelId: ctx.channelIdtoListQueryBuilder.build().FacetService.findOnecallsthis.connection.findOneInChannel(ctx, Facet, facetId, ctx.channelId, ...).
Consequently, an Admin API caller scoped to Channel B (ReadCatalog / CreateCatalog / CreateFacet) cannot observe a Facet created in Channel A via the facets or facet Admin GraphQL queries unless that facet is also assigned to Channel B.
However, Facet.code has a table-wide @Column({ unique: true }) constraint, and FacetService.ensureUniqueCode(ctx, code, id) (called from FacetService.create and FacetService.update) queries Facet globally across all Channels without a Channel predicate:
// packages/core/src/service/services/facet.service.ts
const match = await this.connection
.getRepository(ctx, Facet)
.findOne({ where: { code: candidate } });