Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 2 additions & 40 deletions apps/api-harmonization/src/app.config.ts
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,
};
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 51 additions & 0 deletions packages/configs/integrations/src/config.ts
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({
Comment on lines +7 to +8
Copy link
Copy Markdown
Contributor

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 articles is switched to another provider in Lines 8-27 but export import Articles = Mocked.Integration.Articles is missed in Lines 34-51, consumers will compile against Mocked types while integrations.articles points 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
Verify each finding against the current code and only fix it if needed.

In `@packages/configs/integrations/src/config.ts` around lines 7 - 8, The runtime
domain map and the exported namespace are duplicated: remove the second source
of truth by deriving the exported domain bindings from the single
createIntegrationConfig result (the const result =
createIntegrationConfig({...}) used for integrations. Replace the manual export
imports like "export import Articles = Mocked.Integration.Articles" with
types/aliases derived from result (or generate per-domain adapter types from the
same config) so that symbols such as result, createIntegrationConfig, Articles
and Mocked.Integration.* are the single source of truth and cannot drift
independently.

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;
9 changes: 0 additions & 9 deletions packages/configs/integrations/src/models/articles.ts

This file was deleted.

9 changes: 0 additions & 9 deletions packages/configs/integrations/src/models/auth.ts

This file was deleted.

9 changes: 0 additions & 9 deletions packages/configs/integrations/src/models/billing-accounts.ts

This file was deleted.

7 changes: 0 additions & 7 deletions packages/configs/integrations/src/models/cache.ts

This file was deleted.

9 changes: 0 additions & 9 deletions packages/configs/integrations/src/models/carts.ts

This file was deleted.

9 changes: 0 additions & 9 deletions packages/configs/integrations/src/models/checkout.ts

This file was deleted.

9 changes: 0 additions & 9 deletions packages/configs/integrations/src/models/cms.ts

This file was deleted.

9 changes: 0 additions & 9 deletions packages/configs/integrations/src/models/customers.ts

This file was deleted.

39 changes: 21 additions & 18 deletions packages/configs/integrations/src/models/index.ts
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';
9 changes: 0 additions & 9 deletions packages/configs/integrations/src/models/invoices.ts

This file was deleted.

9 changes: 0 additions & 9 deletions packages/configs/integrations/src/models/notifications.ts

This file was deleted.

9 changes: 0 additions & 9 deletions packages/configs/integrations/src/models/orders.ts

This file was deleted.

9 changes: 0 additions & 9 deletions packages/configs/integrations/src/models/organizations.ts

This file was deleted.

9 changes: 0 additions & 9 deletions packages/configs/integrations/src/models/payments.ts

This file was deleted.

9 changes: 0 additions & 9 deletions packages/configs/integrations/src/models/products.ts

This file was deleted.

9 changes: 0 additions & 9 deletions packages/configs/integrations/src/models/resources.ts

This file was deleted.

7 changes: 0 additions & 7 deletions packages/configs/integrations/src/models/search.ts

This file was deleted.

8 changes: 0 additions & 8 deletions packages/configs/integrations/src/models/tickets.ts

This file was deleted.

9 changes: 0 additions & 9 deletions packages/configs/integrations/src/models/users.ts

This file was deleted.

4 changes: 4 additions & 0 deletions packages/framework/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
},
"type": "commonjs",
"exports": {
"./config": {
"import": "./dist/src/config/index.js",
"require": "./dist/src/config/index.js"
},
"./modules": {
"import": "./dist/src/index.js",
"require": "./dist/src/index.js"
Expand Down
Loading
Loading