-
Notifications
You must be signed in to change notification settings - Fork 31
refactor integration config #766
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: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,45 +1,7 @@ | ||
| import { | ||
| Articles, | ||
| Auth, | ||
| BillingAccounts, | ||
| CMS, | ||
| Cache, | ||
| Carts, | ||
| Checkout, | ||
| Customers, | ||
| Invoices, | ||
| Notifications, | ||
| Orders, | ||
| Organizations, | ||
| Payments, | ||
| Products, | ||
| Resources, | ||
| Search, | ||
| Tickets, | ||
| Users, | ||
| } from '@o2s/configs.integrations'; | ||
| import { integrations } from '@o2s/configs.integrations'; | ||
|
|
||
| import { ApiConfig } from '@o2s/framework/modules'; | ||
|
|
||
| export const AppConfig: ApiConfig = { | ||
| integrations: { | ||
| users: Users.UsersIntegrationConfig, | ||
| organizations: Organizations.OrganizationsIntegrationConfig, | ||
| tickets: Tickets.TicketsIntegrationConfig, | ||
| notifications: Notifications.NotificationsIntegrationConfig, | ||
| articles: Articles.ArticlesIntegrationConfig, | ||
| resources: Resources.ResourcesIntegrationConfig, | ||
| invoices: Invoices.InvoicesIntegrationConfig, | ||
| cms: CMS.CmsIntegrationConfig, | ||
| cache: Cache.CacheIntegrationConfig, | ||
| billingAccounts: BillingAccounts.BillingAccountsIntegrationConfig, | ||
| search: Search.SearchIntegrationConfig, | ||
| products: Products.ProductsIntegrationConfig, | ||
| orders: Orders.OrdersIntegrationConfig, | ||
| carts: Carts.CartsIntegrationConfig, | ||
| customers: Customers.CustomersIntegrationConfig, | ||
| payments: Payments.PaymentsIntegrationConfig, | ||
| checkout: Checkout.CheckoutIntegrationConfig, | ||
| auth: Auth.AuthIntegrationConfig, | ||
| }, | ||
| integrations, | ||
| }; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| import * as Mocked from '@o2s/integrations.mocked/integration'; | ||
|
|
||
| import { createIntegrationConfig } from '@o2s/framework/config'; | ||
| import type { ApiConfig } from '@o2s/framework/modules'; | ||
|
|
||
| // Single swap point: change Mocked → another integration per domain | ||
| // When swapping a domain, update BOTH the assignment below AND the matching export import | ||
| const result = createIntegrationConfig({ | ||
| articles: Mocked, | ||
| auth: Mocked, | ||
| billingAccounts: Mocked, | ||
| cache: Mocked, | ||
| carts: Mocked, | ||
| checkout: Mocked, | ||
| cms: Mocked, | ||
| customers: Mocked, | ||
| invoices: Mocked, | ||
| notifications: Mocked, | ||
| orders: Mocked, | ||
| organizations: Mocked, | ||
| payments: Mocked, | ||
| products: Mocked, | ||
| resources: Mocked, | ||
| search: Mocked, | ||
| tickets: Mocked, | ||
| users: Mocked, | ||
| }); | ||
|
|
||
| export const integrations: ApiConfig['integrations'] = result.integrations; | ||
|
|
||
| // Type exports — re-export the integration namespace so consumers get the correct types, | ||
| // including any model extensions defined by the integration (e.g. extended Notification). | ||
| // Keep these in sync with the createIntegrationConfig assignments above. | ||
| export import Articles = Mocked.Integration.Articles; | ||
| export import Auth = Mocked.Integration.Auth; | ||
| export import BillingAccounts = Mocked.Integration.BillingAccounts; | ||
| export import Cache = Mocked.Integration.Cache; | ||
| export import Carts = Mocked.Integration.Carts; | ||
| export import Checkout = Mocked.Integration.Checkout; | ||
| export import CMS = Mocked.Integration.CMS; | ||
| export import Customers = Mocked.Integration.Customers; | ||
| export import Invoices = Mocked.Integration.Invoices; | ||
| export import Notifications = Mocked.Integration.Notifications; | ||
| export import Orders = Mocked.Integration.Orders; | ||
| export import Organizations = Mocked.Integration.Organizations; | ||
| export import Payments = Mocked.Integration.Payments; | ||
| export import Products = Mocked.Integration.Products; | ||
| export import Resources = Mocked.Integration.Resources; | ||
| export import Search = Mocked.Integration.Search; | ||
| export import Tickets = Mocked.Integration.Tickets; | ||
| export import Users = Mocked.Integration.Users; | ||
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,21 @@ | ||
| export * as Articles from './articles'; | ||
| export * as Auth from './auth'; | ||
| export * as BillingAccounts from './billing-accounts'; | ||
| export * as Cache from './cache'; | ||
| export * as Carts from './carts'; | ||
| export * as Checkout from './checkout'; | ||
| export * as CMS from './cms'; | ||
| export * as Customers from './customers'; | ||
| export * as Invoices from './invoices'; | ||
| export * as Notifications from './notifications'; | ||
| export * as Orders from './orders'; | ||
| export * as Organizations from './organizations'; | ||
| export * as Payments from './payments'; | ||
| export * as Products from './products'; | ||
| export * as Resources from './resources'; | ||
| export * as Search from './search'; | ||
| export * as Tickets from './tickets'; | ||
| export * as Users from './users'; | ||
| export { | ||
| integrations, | ||
| Articles, | ||
| Auth, | ||
| BillingAccounts, | ||
| Cache, | ||
| Carts, | ||
| Checkout, | ||
| CMS, | ||
| Customers, | ||
| Invoices, | ||
| Notifications, | ||
| Orders, | ||
| Organizations, | ||
| Payments, | ||
| Products, | ||
| Resources, | ||
| Search, | ||
| Tickets, | ||
| Users, | ||
| } from '../config'; |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
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.
🛠️ Refactor suggestion | 🟠 Major
Remove the second source of truth for domain bindings.
The runtime map and the exported domain namespaces can drift independently here. If
articlesis switched to another provider in Lines 8-27 butexport import Articles = Mocked.Integration.Articlesis missed in Lines 34-51, consumers will compile againstMockedtypes whileintegrations.articlespoints somewhere else. That breaks the PR’s “single swap point” goal and makes future provider swaps unsafe. Please derive both surfaces from one source of truth, or keep/generate per-domain adapters so they cannot diverge.Also applies to: 33-51
🤖 Prompt for AI Agents