Add company-scoped delivery store on manifest
This commit is contained in:
@@ -183,6 +183,36 @@ const MENU = {
|
||||
},
|
||||
],
|
||||
},
|
||||
delivery: {
|
||||
label: 'delivery',
|
||||
items: [
|
||||
{
|
||||
value: 'delivery.list',
|
||||
label: 'list',
|
||||
hint: 'googleAuthId, companyId → summaries',
|
||||
},
|
||||
{
|
||||
value: 'delivery.getById',
|
||||
label: 'getById',
|
||||
hint: 'googleAuthId, companyId, id → delivery',
|
||||
},
|
||||
{
|
||||
value: 'delivery.create',
|
||||
label: 'create',
|
||||
hint: 'googleAuthId, companyId, JSON body → delivery',
|
||||
},
|
||||
{
|
||||
value: 'delivery.update',
|
||||
label: 'update',
|
||||
hint: 'googleAuthId, companyId, id, JSON patch → delivery',
|
||||
},
|
||||
{
|
||||
value: 'delivery.delete',
|
||||
label: 'delete',
|
||||
hint: 'googleAuthId, companyId, id',
|
||||
},
|
||||
],
|
||||
},
|
||||
category: {
|
||||
label: 'category',
|
||||
items: [
|
||||
@@ -712,6 +742,108 @@ async function runMethod(client, action) {
|
||||
);
|
||||
return ['ok', true];
|
||||
}
|
||||
case 'delivery.list': {
|
||||
const googleAuthId = await askInt('google_auth id');
|
||||
if (googleAuthId == null) return;
|
||||
const companyId = await askInt('company id');
|
||||
if (companyId == null) return;
|
||||
return [
|
||||
'result[]',
|
||||
await client.delivery.list(Number(googleAuthId), Number(companyId)),
|
||||
];
|
||||
}
|
||||
case 'delivery.getById': {
|
||||
const googleAuthId = await askInt('google_auth id');
|
||||
if (googleAuthId == null) return;
|
||||
const companyId = await askInt('company id');
|
||||
if (companyId == null) return;
|
||||
const id = await askInt('delivery id');
|
||||
if (id == null) return;
|
||||
return [
|
||||
'result',
|
||||
await client.delivery.getById(
|
||||
Number(googleAuthId),
|
||||
Number(companyId),
|
||||
Number(id),
|
||||
),
|
||||
];
|
||||
}
|
||||
case 'delivery.create': {
|
||||
const googleAuthId = await askInt('google_auth id');
|
||||
if (googleAuthId == null) return;
|
||||
const companyId = await askInt('company id');
|
||||
if (companyId == null) return;
|
||||
const bodyJson = await askText('delivery JSON', {
|
||||
placeholder:
|
||||
'{"number":"DHL-123","date":"2026-08-10","supplierId":1,"lines":[{"sku":"1","amount":10,"net":99.5,"tax":19}]}',
|
||||
validate: (v) => {
|
||||
if (!v?.trim()) return 'Required';
|
||||
try {
|
||||
const parsed = JSON.parse(v);
|
||||
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
||||
return 'Must be a JSON object';
|
||||
}
|
||||
} catch {
|
||||
return 'Invalid JSON';
|
||||
}
|
||||
},
|
||||
});
|
||||
if (bodyJson == null) return;
|
||||
return [
|
||||
'result',
|
||||
await client.delivery.create(
|
||||
Number(googleAuthId),
|
||||
Number(companyId),
|
||||
JSON.parse(bodyJson),
|
||||
),
|
||||
];
|
||||
}
|
||||
case 'delivery.update': {
|
||||
const googleAuthId = await askInt('google_auth id');
|
||||
if (googleAuthId == null) return;
|
||||
const companyId = await askInt('company id');
|
||||
if (companyId == null) return;
|
||||
const id = await askInt('delivery id');
|
||||
if (id == null) return;
|
||||
const patchJson = await askText('patch JSON', {
|
||||
placeholder: '{"number":"DHL-124","lines":[]}',
|
||||
validate: (v) => {
|
||||
if (!v?.trim()) return 'Required';
|
||||
try {
|
||||
const parsed = JSON.parse(v);
|
||||
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
||||
return 'Must be a JSON object';
|
||||
}
|
||||
} catch {
|
||||
return 'Invalid JSON';
|
||||
}
|
||||
},
|
||||
});
|
||||
if (patchJson == null) return;
|
||||
return [
|
||||
'result',
|
||||
await client.delivery.update(
|
||||
Number(googleAuthId),
|
||||
Number(companyId),
|
||||
Number(id),
|
||||
JSON.parse(patchJson),
|
||||
),
|
||||
];
|
||||
}
|
||||
case 'delivery.delete': {
|
||||
const googleAuthId = await askInt('google_auth id');
|
||||
if (googleAuthId == null) return;
|
||||
const companyId = await askInt('company id');
|
||||
if (companyId == null) return;
|
||||
const id = await askInt('delivery id');
|
||||
if (id == null) return;
|
||||
await client.delivery.delete(
|
||||
Number(googleAuthId),
|
||||
Number(companyId),
|
||||
Number(id),
|
||||
);
|
||||
return ['ok', true];
|
||||
}
|
||||
case 'lang.create': {
|
||||
const iso639 = await askText('ISO 639', {
|
||||
placeholder: 'de',
|
||||
|
||||
Reference in New Issue
Block a user