-
Notifications
You must be signed in to change notification settings - Fork 16
Feature/idaas 805/tenants client alternative #617
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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.
24029f8 to
299a391
Compare
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
Tenantsclient 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:
/api/tenant/bindingsroutes should use/api/license-manager/bindingroutes instead (you can use this PR's new client methods as reference)./api/tenant/tenantsroute should be replaced by inferred data or data sought from different places:idandmetadataproperties returned from the Tenants client were incorrectly typed, because the API did not actually return these fields.slugandtitlecorrespond to the requestedtenantname.editionandinfrafields, but I found out that these fields are mostly hard-coded by the Tenants system to return'vtex:tier-1339'and'VTEX'.bindingsfield should be sought from the License Manager API:/api/license-manager/binding/site/{tenant}. In the new client, you should usecontext.clients.licenseManager.listBindings({ tenant, adminUserAuthToken })instead (more details below).defaultCurrencyanddefaultLocalefields 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 usecontext.clients.catalog.getSalesChannel(1)(more details below).Result from Tenants client should be replaced like this:
defaultLocale->CultureInfofromcontext.clients.catalog.getSalesChannel(1).defaultCurrency->CurrencyCodefromcontext.clients.catalog.getSalesChannel(1).bindings[x].id->Idfromcontext.clients.licenseManager.listBindings().bindings[x].canonicalBaseAddress-> result of concatenation:`${Addresses[i].Host}/${Addresses[i].BasePath}`bindings[x].alternateBaseAddresses-> list with concatenation results:`${Addresses[i].Host}/${Addresses[i].BasePath}`bindings[x].defaultLocale->DefaultLocalefromcontext.clients.licenseManager.listBindings().bindings[x].supportedLocales-> fromSupportedLocalesfromcontext.clients.licenseManager.listBindings().bindings[x].defaultCurrency->CurrencyCodefromcontext.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 toDefaultSalesChannelIdfromcontext.clients.licenseManager.listBindings().bindings[x].targetProduct-> This value should be inferred from thebindings[x].canonicalBaseAddressandbindings[x].alternateBaseAddressesfields, following this logic: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-apiclient call, like this:graphql/schema.graphqlnode/index.tsTo test these GraphQL queries, go into this GraphiQL workspace.
You can check out the following queries/mutations to test the application:
Get Sales Channel

List Bindings

Get Binding

Create Binding
Delete Binding
Update Binding
Types of changes