composite & deleted

This commit is contained in:
seb
2026-07-12 20:39:01 +02:00
parent 3ca6e894ab
commit ca190b2832
17 changed files with 571 additions and 11 deletions

View File

@@ -1,4 +1,4 @@
import { createImageHandler } from './image-handler.js';
import { createImageHandler } from '../image-handler.js';
export const method = 'GET';
export const path = '/v1/cimage';

View File

@@ -0,0 +1,14 @@
import { sendJson } from '../http.js';
import { getDeletedEntityList } from '../queries/deleted-entity-list.js';
export const method = 'GET';
export const path = '/v1/deletedentity';
export async function handle(_req, res, { url }) {
const cursor = Number(url.searchParams.get('lastChangedDeletedEntity')) || 0;
const limit = Number(url.searchParams.get('limit')) || 600;
const deletedEntities = await getDeletedEntityList({ cursor, limit });
return sendJson(res, 200, deletedEntities);
}

View File

@@ -1,21 +0,0 @@
import { sendBinary, sendJson } from '../http.js';
import { resizeImage } from '../image-resize.js';
import { getImageByHash } from '../queries/image.js';
export function createImageHandler() {
return async function handle(_req, res, { url }) {
const path = url.searchParams.get('path');
if (!path) {
return sendJson(res, 400, { Message: "Missing required query parameter 'path'." });
}
const image = await getImageByHash(path, '200');
if (!image) {
return sendJson(res, 404, { Message: `No image was found for path '${path}'.` });
}
const buffer = await resizeImage(image.buffer);
return sendBinary(res, 200, buffer, image.contentType);
};
}

View File

@@ -2,9 +2,11 @@ import * as category from './category.js';
import * as cimage from './cimage.js';
import * as client from './client.js';
import * as customergroup from './customergroup.js';
import * as deletedEntity from './deleted-entity.js';
import * as init from './init.js';
import * as order from './order.js';
import * as pimage from './pimage.js';
import * as product from './product.js';
import * as productcomposite from './productcomposite.js';
export const endpoints = [client, init, category, product, pimage, cimage, customergroup, order];
export const endpoints = [client, init, category, product, productcomposite, deletedEntity, pimage, cimage, customergroup, order];

View File

@@ -1,7 +1,9 @@
import { sendJson } from '../http.js';
import { getMaxExternalId } from '../order-log.js';
import { getCategoryCount } from '../queries/category-count.js';
import { getCompositeProductCount } from '../queries/composite-product-count.js';
import { getCustomerGroupCount } from '../queries/customer-groups.js';
import { getDeletedEntityCount } from '../queries/deleted-entity-count.js';
import { getProductCount } from '../queries/product-count.js';
export const method = 'GET';
@@ -11,11 +13,15 @@ export async function handle(_req, res, { url }) {
const productCursor = Number(url.searchParams.get('lastChangedProduct')) || 0;
const categoryCursor = Number(url.searchParams.get('lastChangedCategory')) || 0;
const customerGroupCursor = Number(url.searchParams.get('lastChangedCustomerGroup')) || 0;
const compositeProductCursor = Number(url.searchParams.get('lastChangedCompositeProduct')) || 0;
const deletedEntityCursor = Number(url.searchParams.get('lastChangedDeletedEntity')) || 0;
const [productCount, categoryCount, customerGroupCount] = await Promise.all([
const [productCount, categoryCount, customerGroupCount, compositeProductCount, deletedEntityCount] = await Promise.all([
getProductCount({ cursor: productCursor }),
getCategoryCount({ cursor: categoryCursor }),
getCustomerGroupCount({ cursor: customerGroupCursor }),
getCompositeProductCount({ cursor: compositeProductCursor }),
getDeletedEntityCount({ cursor: deletedEntityCursor }),
]);
return sendJson(res, 200, {
@@ -24,10 +30,10 @@ export async function handle(_req, res, { url }) {
category_count: String(categoryCount),
customer_count: '0',
customerGroup_count: String(customerGroupCount),
compositeProduct_count: '0',
compositeProduct_count: String(compositeProductCount),
configurationGroup_count: '0',
configurationItem_count: '0',
deletedEntity_count: '0',
deletedEntity_count: String(deletedEntityCount),
max_orderId_count: getMaxExternalId(),
});
}

View File

@@ -1,4 +1,4 @@
import { createImageHandler } from './image-handler.js';
import { createImageHandler } from '../image-handler.js';
export const method = 'GET';
export const path = '/v1/pimage';

View File

@@ -0,0 +1,14 @@
import { sendJson } from '../http.js';
import { getCompositeProductList } from '../queries/composite-product-list.js';
export const method = 'GET';
export const path = '/v1/productcomposite';
export async function handle(_req, res, { url }) {
const cursor = Number(url.searchParams.get('lastChangedCompositeProduct')) || 0;
const limit = Number(url.searchParams.get('limit')) || 100;
const composites = await getCompositeProductList({ cursor, limit });
return sendJson(res, 200, composites);
}