Skip to content

Conversation

@rafarubim
Copy link

@rafarubim rafarubim commented Oct 28, 2025

What is the purpose of this pull request?

Add LM and Catalog client methods to enable applications to replace requests to the Tenants systems (the Tenants client should be marked as deprecated from now on).

The new API client methods reflect the API interface directly, without converting data or applying business logic. Therefore, any code that depends on the Tenants client or API should adapt to the new data structure interface.

Data fetch and CRUD operations should be replaced like this:
  • Requests to /api/tenant/bindings routes should use /api/license-manager/binding routes instead (you can use this PR's new client methods as reference).
  • Requests to /api/tenant/tenants route should be replaced by inferred data or data sought from different places:
    • The id and metadata properties returned from the Tenants client were incorrectly typed, because the API did not actually return these fields.
    • slug and title correspond to the requested tenant name.
    • I (@rafarubim) am uncertain of how to replace the edition and infra fields, but I found out that these fields are mostly hard-coded by the Tenants system to return 'vtex:tier-1339' and 'VTEX'.
    • The bindings field should be sought from the License Manager API: /api/license-manager/binding/site/{tenant}. In the new client, you should use context.clients.licenseManager.listBindings({ tenant, adminUserAuthToken }) instead (more details below).
    • The defaultCurrency and defaultLocale fields should be sought from the Tenant's first sales channel, from the Catalog API: /api/catalog_system/pub/saleschannel/1. In the new client, you should use context.clients.catalog.getSalesChannel(1) (more details below).
Result from Tenants client should be replaced like this:
  • defaultLocale -> CultureInfo from context.clients.catalog.getSalesChannel(1).
  • defaultCurrency -> CurrencyCode from context.clients.catalog.getSalesChannel(1).
  • bindings[x].id -> Id from context.clients.licenseManager.listBindings().
  • bindings[x].canonicalBaseAddress -> result of concatenation:
`${Addresses[i].Host}/${Addresses[i].BasePath}`

Where Addresses is from context.clients.licenseManager.listBindings() and i corresponds to the address with Addresses[i].IsCanonical equal to true.

  • bindings[x].alternateBaseAddresses -> list with concatenation results:
`${Addresses[i].Host}/${Addresses[i].BasePath}`

Where Addresses is from context.clients.licenseManager.listBindings() and i corresponds to all addresses with Adresses[i].IsCanonical equal to false.

  • bindings[x].defaultLocale -> DefaultLocale from context.clients.licenseManager.listBindings().
  • bindings[x].supportedLocales -> from SupportedLocales from context.clients.licenseManager.listBindings().
  • bindings[x].defaultCurrency -> CurrencyCode from context.clients.catalog.getSalesChannel(1).
  • bindings[x].supportedCurrencies -> I (@rafarubim) am uncertain of a replacement, but [CurrencyCode] seems acceptable.
  • bindings[x].extraContext -> I (@rafarubim) am uncertain of a replacement, but I believe it could be related to DefaultSalesChannelId from context.clients.licenseManager.listBindings().
  • bindings[x].targetProduct -> This value should be inferred from the bindings[x].canonicalBaseAddress and bindings[x].alternateBaseAddresses fields, following this logic:
const isAdmin = canonicalBaseAddress.endsWith('myvtex.com/admin') || alternateBaseAddresses.some(addr => addr.endsWith('myvtex.com/admin'))

const targetProduct = isAdmin ? 'vtex-admin' : 'vtex-storefront'

How should this be manually tested?

This PR's changes have been locally linked, then have been added to a test branch in the vtex/auth-admin repository.

This branch adds GraphQL queries and server resolvers that correspond to a node-vtex-api client call, like this:

graphql/schema.graphql
image

node/index.ts
image

To test these GraphQL queries, go into this GraphiQL workspace.

You can check out the following queries/mutations to test the application:

Get Sales Channel
image

List Bindings
image

Get Binding
image

Create Binding

⚠️ Ensure you pass valid parameters (e.g., use a valid host registered in the tenant, don't start path with a leading slash /) to avoid a 4xx response
⚠️ Wait a few minutes after deletion, as License Manager has a durable cache.

image

Delete Binding

⚠️ Wait a few minutes after deletion, as License Manager has a durable cache.

image

Update Binding

⚠️ Wait a few minutes after updating, as License Manager has a durable cache.

image

Types of changes

  • Bug fix (a non-breaking change which fixes an issue)
  • New feature (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Requires change to documentation, which has been updated accordingly.

@rafarubim rafarubim requested review from a team and Copilot October 28, 2025 00:59
@rafarubim rafarubim self-assigned this Oct 28, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a Catalog client and significantly expands the LicenseManager client with binding management capabilities. The LicenseManager has been refactored from a single file into a modular directory structure with separate type definitions, and new methods for creating, reading, updating, and deleting tenant bindings have been added.

Key changes:

  • Added a new Catalog client with sales channel retrieval functionality
  • Expanded LicenseManager with CRUD operations for tenant bindings
  • Refactored LicenseManager into a modular directory structure with dedicated type definitions

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/clients/janus/index.ts Exports the new Catalog client
src/clients/janus/LicenseManager/types.ts Defines TypeScript interfaces for binding operations and API request/response structures
src/clients/janus/LicenseManager/index.ts Implements the refactored LicenseManager with new binding management methods
src/clients/janus/LicenseManager.ts Removes the old single-file LicenseManager implementation
src/clients/janus/Catalog/types.ts Defines the SalesChannel interface for catalog operations
src/clients/janus/Catalog/index.ts Implements the Catalog client with sales channel retrieval
src/clients/IOClients.ts Adds getter for the new Catalog client and updates LicenseManager import

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@rafarubim rafarubim force-pushed the feature/IDAAS-805/tenants-client-alternative branch from 24029f8 to 299a391 Compare October 28, 2025 20:18
@rafarubim rafarubim marked this pull request as ready for review October 29, 2025 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants