Migrate to @orbito/api-lib 2.0.0 for single-company container model.
Remove companyId from handlers, models, cron jobs, and cross-module calls to match the v2 one-module-one-company architecture. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+4
-4
@@ -4,8 +4,8 @@ const PrestashopApi = require('../src/PrestaApi');
|
||||
const { importFromPSOrder } = require('../src/OrderImporter');
|
||||
const { isLegacyApi } = require('../src/utils');
|
||||
|
||||
module.exports = async function (companyId, instanceId, params, ctx) {
|
||||
const configs = await ShopConfig.find({ companyId, isRemoved: { $ne: true } });
|
||||
module.exports = async function(params, ctx) {
|
||||
const configs = await ShopConfig.find({ isRemoved: { $ne: true } });
|
||||
const active = configs.filter(c => c.apiUrl && c.apiKey);
|
||||
|
||||
if (active.length === 0) return { error: 'No active shop configs found' };
|
||||
@@ -34,7 +34,7 @@ module.exports = async function (companyId, instanceId, params, ctx) {
|
||||
const errors = [];
|
||||
for (const order of orders) {
|
||||
const uniqueId = order.reference + ':' + order.id;
|
||||
const searchResult = await Core.callModule(companyId, 'core/orders', 'search', {
|
||||
const searchResult = await Core.callModule( 'core/orders', 'search', {
|
||||
source: { moduleCode: 'core/prestashop', uniqueId }
|
||||
});
|
||||
if (searchResult?.data?.length > 0) {
|
||||
@@ -42,7 +42,7 @@ module.exports = async function (companyId, instanceId, params, ctx) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
await importFromPSOrder(companyId, order.id, api, config);
|
||||
await importFromPSOrder(order.id, api, config);
|
||||
imported.push({ id: order.id, status: 'imported' });
|
||||
} catch (e) {
|
||||
errors.push({ id: order.id, error: e.message });
|
||||
|
||||
Reference in New Issue
Block a user