This commit is contained in:
seb
2026-07-31 09:00:14 +02:00
parent 4f98082061
commit 99dd76075e
24 changed files with 1477 additions and 1175 deletions

View File

@@ -70,9 +70,9 @@ const MENU = {
company: {
label: 'company',
items: [
{ value: 'company.create', label: 'create', hint: 'authId, iso639, name, taxes → result' },
{ value: 'company.create', label: 'create', hint: 'googleAuthId, iso639, name, taxes → result' },
{ value: 'company.update', label: 'update', hint: 'id + fields → result' },
{ value: 'company.list', label: 'list', hint: 'authId → result[]' },
{ value: 'company.list', label: 'list', hint: 'googleAuthId → result[]' },
{ value: 'company.delete', label: 'delete', hint: 'companyId' },
],
},
@@ -95,17 +95,16 @@ const MENU = {
category: {
label: 'category',
items: [
{ value: 'category.create', label: 'create', hint: '{parentId, sort} → id' },
{ value: 'category.createUnderParent', label: 'createUnderParent', hint: 'googleAuthId, parentId, name → row' },
{ value: 'category.updateParentId', label: 'updateParentId', hint: 'id, parentId' },
{ value: 'category.delete', label: 'delete', hint: 'id' },
{ value: 'category.getTree', label: 'getTree', hint: 'rootId → rows' },
{ value: 'category.getTreeForCompany', label: 'getTreeForCompany', hint: 'authId, companyId → rows' },
{ value: 'category.getTreeForCompany', label: 'getTreeForCompany', hint: 'googleAuthId, companyId → rows' },
],
},
companyuser: {
label: 'companyuser',
items: [
{ value: 'companyuser.add', label: 'add', hint: 'companyId, authId → id' },
{ value: 'companyuser.add', label: 'add', hint: 'companyId, googleAuthId → id' },
{ value: 'companyuser.delete', label: 'delete', hint: 'id' },
{ value: 'companyuser.getByEmail', label: 'getByEmail', hint: 'email → ids' },
],
@@ -117,7 +116,7 @@ const MENU = {
{ value: 'google_auth.getByEmail', label: 'getByEmail', hint: 'email → row' },
{ value: 'google_auth.listAllowedEmails', label: 'listAllowedEmails', hint: '→ rows' },
{ value: 'google_auth.removeAllowedEmail', label: 'removeAllowedEmail', hint: 'email' },
{ value: 'google_auth.setSelectedCompany', label: 'setSelectedCompany', hint: 'authId, companyId' },
{ value: 'google_auth.setSelectedCompany', label: 'setSelectedCompany', hint: 'googleAuthId, companyId' },
],
},
schema: {
@@ -180,7 +179,7 @@ async function runMethod(client, action) {
if (reducedtaxrate == null) return;
const existing = await client.google_auth.getByEmail(email);
const authId = existing
const googleAuthId = existing
? existing.id
: await client.google_auth.add(email);
@@ -189,16 +188,16 @@ async function runMethod(client, action) {
name,
taxrate,
reducedtaxrate,
authId,
googleAuthId,
});
const companyId = created.id;
await client.google_auth.setSelectedCompany(authId, companyId);
await client.google_auth.setSelectedCompany(googleAuthId, companyId);
return [
'created',
{
...created,
authId,
googleAuthId,
email,
name,
iso639,
@@ -208,8 +207,8 @@ async function runMethod(client, action) {
];
}
case 'company.create': {
const authId = await askInt('google_auth id');
if (authId == null) return;
const googleAuthId = await askInt('google_auth id');
if (googleAuthId == null) return;
const name = await askText('Name', {
placeholder: 'Acme',
validate: (v) => (!v?.trim() ? 'Required' : undefined),
@@ -231,7 +230,7 @@ async function runMethod(client, action) {
name,
taxrate,
reducedtaxrate,
authId: Number(authId),
googleAuthId: Number(googleAuthId),
}),
];
}
@@ -263,9 +262,9 @@ async function runMethod(client, action) {
];
}
case 'company.list': {
const authId = await askInt('google_auth id');
if (authId == null) return;
return ['result[]', await client.company.list(Number(authId))];
const googleAuthId = await askInt('google_auth id');
if (googleAuthId == null) return;
return ['result[]', await client.company.list(Number(googleAuthId))];
}
case 'company.delete': {
const companyId = await askInt('Company id');
@@ -303,17 +302,23 @@ async function runMethod(client, action) {
await client.lang.delete(Number(id));
return ['ok', true];
}
case 'category.create': {
const parentRaw = await askText('parentId (null as empty)', {
placeholder: '',
validate: (v) =>
v?.trim() && !/^\d+$/.test(v.trim()) ? 'Integer or empty' : undefined,
case 'category.createUnderParent': {
const googleAuthId = await askInt('google_auth id');
if (googleAuthId == null) return;
const parentId = await askInt('parent category id');
if (parentId == null) return;
const name = await askText('name', {
validate: (v) => (!v?.trim() ? 'Required' : undefined),
});
if (parentRaw == null) return;
const sortRaw = await askInt('sort', '0');
if (sortRaw == null) return;
const parentId = parentRaw === '' ? null : Number(parentRaw);
return ['id', await client.category.create({ parentId, sort: Number(sortRaw) })];
if (name == null) return;
return [
'result',
await client.category.createUnderParent({
googleAuthId: Number(googleAuthId),
parentId: Number(parentId),
name,
}),
];
}
case 'category.updateParentId': {
const id = await askInt('Category id');
@@ -334,27 +339,22 @@ async function runMethod(client, action) {
await client.category.delete(Number(id));
return ['ok', true];
}
case 'category.getTree': {
const rootId = await askInt('Root category id');
if (rootId == null) return;
return ['rows', await client.category.getTree(Number(rootId))];
}
case 'category.getTreeForCompany': {
const authId = await askInt('google_auth id');
if (authId == null) return;
const googleAuthId = await askInt('google_auth id');
if (googleAuthId == null) return;
const companyId = await askInt('company id');
if (companyId == null) return;
return [
'rows',
await client.category.getTreeForCompany(Number(authId), Number(companyId)),
await client.category.getTreeForCompany(Number(googleAuthId), Number(companyId)),
];
}
case 'companyuser.add': {
const companyId = await askInt('Company id');
if (companyId == null) return;
const authId = await askInt('Auth id');
if (authId == null) return;
return ['id', await client.companyuser.add(Number(companyId), Number(authId))];
const googleAuthId = await askInt('Auth id');
if (googleAuthId == null) return;
return ['id', await client.companyuser.add(Number(companyId), Number(googleAuthId))];
}
case 'companyuser.delete': {
const id = await askInt('Company user id');