This commit is contained in:
seb
2026-08-02 19:01:00 +02:00
parent 787e411547
commit b890843445
10 changed files with 480 additions and 0 deletions

View File

@@ -162,6 +162,7 @@ const MENU = {
label: 'category',
items: [
{ value: 'category.createUnderParent', label: 'createUnderParent', hint: 'googleAuthId, parentId, name → row' },
{ value: 'category.rename', label: 'rename', hint: 'googleAuthId, id, name → row' },
{ value: 'category.delete', label: 'delete', hint: 'googleAuthId, id' },
{ value: 'category.getTreeForCompany', label: 'getTreeForCompany', hint: 'googleAuthId, companyId → rows' },
{ value: 'category.getCategoryArticles', label: 'getCategoryArticles', hint: 'googleAuthId, categoryId → rows' },
@@ -190,6 +191,26 @@ const MENU = {
label: 'setPricesBySku',
hint: 'googleAuthId, sku, JSON prices → row',
},
{
value: 'article.setEansBySku',
label: 'setEansBySku',
hint: 'googleAuthId, sku, JSON eans → row',
},
{
value: 'article.setBrandIdBySku',
label: 'setBrandIdBySku',
hint: 'googleAuthId, sku, brandId|null → row',
},
{
value: 'article.setWeightBySku',
label: 'setWeightBySku',
hint: 'googleAuthId, sku, weight → row',
},
{
value: 'article.setCategoryIdsBySku',
label: 'setCategoryIdsBySku',
hint: 'googleAuthId, sku, JSON categoryIds → row',
},
{
value: 'article.addImage',
label: 'addImage',
@@ -631,6 +652,24 @@ async function runMethod(client, action) {
}),
];
}
case 'category.rename': {
const googleAuthId = await askInt('google_auth id');
if (googleAuthId == null) return;
const id = await askInt('Category id');
if (id == null) return;
const name = await askText('name', {
validate: (v) => (!v?.trim() ? 'Required' : undefined),
});
if (name == null) return;
return [
'row',
await client.category.rename({
googleAuthId: Number(googleAuthId),
id: Number(id),
name,
}),
];
}
case 'category.delete': {
const googleAuthId = await askInt('google_auth id');
if (googleAuthId == null) return;
@@ -755,6 +794,108 @@ async function runMethod(client, action) {
),
];
}
case 'article.setEansBySku': {
const googleAuthId = await askInt('google_auth id');
if (googleAuthId == null) return;
const sku = await askText('sku', {
validate: (v) => (!v?.trim() ? 'Required' : undefined),
});
if (sku == null) return;
const eansJson = await askText('eans JSON', {
placeholder: '["4006381333931","4012345678901"]',
validate: (v) => {
if (!v?.trim()) return 'Required';
try {
const parsed = JSON.parse(v);
if (!Array.isArray(parsed)) return 'Must be a JSON array';
} catch {
return 'Invalid JSON';
}
},
});
if (eansJson == null) return;
return [
'result',
await client.article.setEansBySku(
Number(googleAuthId),
sku,
JSON.parse(eansJson),
),
];
}
case 'article.setBrandIdBySku': {
const googleAuthId = await askInt('google_auth id');
if (googleAuthId == null) return;
const sku = await askText('sku', {
validate: (v) => (!v?.trim() ? 'Required' : undefined),
});
if (sku == null) return;
const raw = await askText('brandId (or "null")', {
validate: (v) => {
if (v === null || v === undefined || v.trim() === '') return 'Required';
const t = v.trim();
if (t === 'null') return undefined;
if (!Number.isFinite(Number(t))) return 'Must be a number or null';
},
});
if (raw == null) return;
const brandId = raw.trim() === 'null' ? null : Number(raw.trim());
return [
'result',
await client.article.setBrandIdBySku(
Number(googleAuthId),
sku,
brandId,
),
];
}
case 'article.setWeightBySku': {
const googleAuthId = await askInt('google_auth id');
if (googleAuthId == null) return;
const sku = await askText('sku', {
validate: (v) => (!v?.trim() ? 'Required' : undefined),
});
if (sku == null) return;
const weight = await askInt('weight');
if (weight == null) return;
return [
'result',
await client.article.setWeightBySku(
Number(googleAuthId),
sku,
weight,
),
];
}
case 'article.setCategoryIdsBySku': {
const googleAuthId = await askInt('google_auth id');
if (googleAuthId == null) return;
const sku = await askText('sku', {
validate: (v) => (!v?.trim() ? 'Required' : undefined),
});
if (sku == null) return;
const categoryIdsJson = await askText('categoryIds JSON', {
placeholder: '[10,23,42]',
validate: (v) => {
if (!v?.trim()) return 'Required';
try {
const parsed = JSON.parse(v);
if (!Array.isArray(parsed)) return 'Must be a JSON array';
} catch {
return 'Invalid JSON';
}
},
});
if (categoryIdsJson == null) return;
return [
'result',
await client.article.setCategoryIdsBySku(
Number(googleAuthId),
sku,
JSON.parse(categoryIdsJson),
),
];
}
case 'article.addImage': {
const googleAuthId = await askInt('google_auth id');
if (googleAuthId == null) return;