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:
fatequod
2026-07-08 11:21:35 +02:00
co-authored by Cursor
parent f163100ad4
commit 1a6a978a21
25 changed files with 365 additions and 189 deletions
+6 -9
View File
@@ -1,25 +1,22 @@
const { getOrderStatuses, searchOrders } = require('../../src/orders-api');
// status.get_with_counts — lista statusów zamówień (z core/orders) wraz z liczbą
// zamówień PrestaShop w każdym statusie. Wynik krótko cache'owany per firma,
// bo zlicza N zapytań (po jednym na status).
const cache = new Map();
const CACHE_TTL = 5000;
const CACHE_KEY = 'default';
module.exports = async function(companyId, instanceId, params, ctx) {
const key = companyId?.toString?.() ?? companyId;
module.exports = async function(params, ctx) {
const now = Date.now();
const cached = cache.get(key);
const cached = cache.get(CACHE_KEY);
if (cached && now - cached.ts < CACHE_TTL) {
return { data: cached.data };
}
const statuses = await getOrderStatuses(companyId);
const statuses = await getOrderStatuses();
const data = [];
for (const status of statuses) {
const statusId = status._id?.toString?.() ?? status._id;
const result = await searchOrders(companyId, {
const result = await searchOrders({
statusId,
page: 1,
perPage: 1
@@ -36,6 +33,6 @@ module.exports = async function(companyId, instanceId, params, ctx) {
data.sort((a, b) => (a.positionInGroup ?? 0) - (b.positionInGroup ?? 0));
cache.set(key, { ts: now, data });
cache.set(CACHE_KEY, { ts: now, data });
return { data };
};